filters
palmdocexport.cc00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include <config.h>
00021
00022 #ifdef HAVE_UNISTD_H
00023 #include <unistd.h>
00024 #endif
00025
00026 #include <qfile.h>
00027 #include <qfileinfo.h>
00028 #include <qtextstream.h>
00029
00030 #include <kdebug.h>
00031 #include <KoFilterChain.h>
00032 #include <kgenericfactory.h>
00033
00034 #include <KWEFStructures.h>
00035 #include <KWEFBaseWorker.h>
00036 #include <KWEFKWordLeader.h>
00037
00038 #include "palmdoc.h"
00039
00040 #include "palmdocexport.h"
00041
00042 typedef KGenericFactory<PalmDocExport, KoFilter> PalmDocExportFactory;
00043 K_EXPORT_COMPONENT_FACTORY( libpalmdocexport, PalmDocExportFactory( "kofficefilters" ) )
00044
00045 class PalmDocWorker : public KWEFBaseWorker
00046 {
00047 public:
00048 PalmDocWorker(void) { }
00049 virtual ~PalmDocWorker(void) { }
00050 public:
00051 virtual bool doOpenFile(const QString& filenameOut, const QString& to);
00052 virtual bool doCloseFile(void);
00053 virtual bool doOpenDocument(void);
00054 virtual bool doCloseDocument(void);
00055 virtual bool doFullDocumentInfo(const KWEFDocumentInfo& docInfo);
00056 virtual bool doFullParagraph(const QString& paraText, const LayoutData& layout,
00057 const ValueListFormatData& paraFormatDataList);
00058 private:
00059 QString title;
00060 QString outfile;
00061 QString text;
00062 };
00063
00064 bool PalmDocWorker::doOpenFile(const QString& filenameOut, const QString& )
00065 {
00066 outfile = filenameOut;
00067 return TRUE;
00068 }
00069
00070 bool PalmDocWorker::doCloseFile(void)
00071 {
00072 if( title.isEmpty() )
00073 {
00074 QFileInfo info( outfile );
00075 title = info.baseName();
00076 }
00077
00078 PalmDoc doc;
00079 doc.setName( title );
00080 doc.setText( text );
00081 doc.save( outfile.latin1() );
00082
00083 return TRUE;
00084 }
00085
00086 bool PalmDocWorker::doOpenDocument(void)
00087 {
00088 text = QString::null;
00089 return TRUE;
00090 }
00091
00092 bool PalmDocWorker::doCloseDocument(void)
00093 {
00094 return TRUE;
00095 }
00096
00097 bool PalmDocWorker::doFullDocumentInfo( const KWEFDocumentInfo& docInfo )
00098 {
00099 title = docInfo.title;
00100 return TRUE;
00101 }
00102
00103 bool PalmDocWorker::doFullParagraph(const QString& paraText,
00104 const LayoutData& , const ValueListFormatData& )
00105 {
00106 kdDebug(30525) << "Entering ::doFullParagraph" << endl;
00107 text.append( paraText );
00108 text.append( "\n\n" );
00109
00110 return TRUE;
00111 }
00112
00113 PalmDocExport::PalmDocExport( KoFilter *, const char *, const QStringList& ):
00114 KoFilter()
00115 {
00116 }
00117
00118 KoFilter::ConversionStatus PalmDocExport::convert( const QCString& from,
00119 const QCString& to )
00120 {
00121
00122 if( to!= "application/vnd.palm" || from != "application/x-kword" )
00123 return KoFilter::NotImplemented;
00124
00125 PalmDocWorker* worker = new PalmDocWorker();
00126 KWEFKWordLeader* leader = new KWEFKWordLeader( worker );
00127
00128 KoFilter::ConversionStatus result;
00129 result = leader->convert( m_chain, from, to );
00130
00131 delete worker;
00132 delete leader;
00133
00134 return result;
00135 }
00136
00137 #include "palmdocexport.moc"
|