filters
htmlexport.cc00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034 #include <qtextcodec.h>
00035
00036 #include <kdebug.h>
00037 #include <kgenericfactory.h>
00038 #include <KoFilterChain.h>
00039 #include <KoFilterManager.h>
00040
00041 #include <KWEFBaseWorker.h>
00042 #include <KWEFKWordLeader.h>
00043
00044 #include "ExportDialog.h"
00045 #include "ExportFilter.h"
00046 #include "ExportCss.h"
00047 #include "ExportBasic.h"
00048 #include "ExportDocStruct.h"
00049
00050 #include <htmlexport.h>
00051 #include <htmlexport.moc>
00052
00053 typedef KGenericFactory<HTMLExport, KoFilter> HTMLExportFactory;
00054 K_EXPORT_COMPONENT_FACTORY( libhtmlexport, HTMLExportFactory( "kofficefilters" ) )
00055
00056
00057
00058
00059
00060 HTMLExport::HTMLExport(KoFilter *, const char *, const QStringList &) :
00061 KoFilter() {
00062 }
00063
00064 KoFilter::ConversionStatus HTMLExport::convert( const QCString& from, const QCString& to )
00065 {
00066 if ((from != "application/x-kword") || (to != "text/html"))
00067 {
00068 return KoFilter::NotImplemented;
00069 }
00070
00071 bool batch=false;
00072 if ( m_chain->manager() )
00073 batch = m_chain->manager()->getBatchMode();
00074
00075 HtmlWorker* worker;
00076
00077 if (batch)
00078 {
00079 worker=new HtmlCssWorker();
00080 worker->setXML(true);
00081 worker->setCodec(QTextCodec::codecForName("UTF-8"));
00082 }
00083 else
00084 {
00085 HtmlExportDialog dialog;
00086
00087 if (!dialog.exec())
00088 {
00089 kdDebug(30503) << "Dialog was aborted! Aborting filter!" << endl;
00090 return KoFilter::UserCancelled;
00091 }
00092
00093 const HtmlExportDialog::Mode mode = dialog.getMode();
00094 switch (mode)
00095 {
00096 case HtmlExportDialog::Light:
00097 worker=new HtmlDocStructWorker();
00098 break;
00099 case HtmlExportDialog::Basic:
00100 worker=new HtmlBasicWorker();
00101 break;
00102 case HtmlExportDialog::CustomCSS:
00103 worker=new HtmlBasicWorker( dialog.cssURL() );
00104 break;
00105 default:
00106 worker=new HtmlCssWorker();
00107 }
00108
00109 worker->setXML(dialog.isXHtml());
00110 worker->setCodec(dialog.getCodec());
00111 }
00112
00113 KWEFKWordLeader* leader=new KWEFKWordLeader(worker);
00114
00115 if (!leader)
00116 {
00117 kdError(30503) << "Cannot create Worker! Aborting!" << endl;
00118 delete worker;
00119 return KoFilter::StupidError;
00120 }
00121 KoFilter::ConversionStatus result=leader->convert(m_chain,from,to);
00122
00123 delete leader;
00124 delete worker;
00125
00126 return result;
00127 }
|