filters
aiimport.cc00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include <qdom.h>
00021 #include <qcstring.h>
00022 #include <qfile.h>
00023 #include <qstring.h>
00024
00025 #include <kgenericfactory.h>
00026 #include <KoFilterChain.h>
00027 #include <KoStore.h>
00028
00029 #include <kdebug.h>
00030
00031 #include "aiimport.h"
00032 #include "karbonaiparserbase.h"
00033
00034 class AiImportFactory : KGenericFactory<AiImport, KoFilter>
00035 {
00036 public:
00037 AiImportFactory( void )
00038 : KGenericFactory<AiImport, KoFilter>( "karbonaiimport" )
00039 {}
00040
00041 protected:
00042 virtual void setupTranslations( void )
00043 {
00044 KGlobal::locale()->insertCatalogue( "kofficefilters" );
00045 }
00046 };
00047
00048 K_EXPORT_COMPONENT_FACTORY( libkarbonaiimport, AiImportFactory() )
00049
00050 AiImport::AiImport( KoFilter*, const char*, const QStringList& )
00051 : KoFilter()
00052 {
00053 }
00054
00055 AiImport::~AiImport()
00056 {
00057 }
00058
00059 KoFilter::ConversionStatus
00060 AiImport::convert( const QCString& from, const QCString& to )
00061 {
00062 if ( from != "application/illustrator" || to != "application/x-karbon" )
00063 {
00064 return KoFilter::NotImplemented;
00065 }
00066 QFile fileIn( m_chain->inputFile() );
00067 if( !fileIn.open( IO_ReadOnly ) )
00068 {
00069 fileIn.close();
00070 return KoFilter::FileNotFound;
00071 }
00072
00073 QDomDocument doc ("DOC");
00074 KarbonAIParserBase parser;
00075
00076 if (!parser.parse (fileIn, doc))
00077 {
00078 fileIn.close();
00079 return KoFilter::CreationError;
00080 }
00081 QString result = doc.toString();
00082
00083 kdDebug() << result << endl;
00084 KoStoreDevice* storeOut = m_chain->storageFile( "root", KoStore::Write );
00085 if( !storeOut )
00086 {
00087 fileIn.close();
00088 return KoFilter::StorageCreationError;
00089 }
00090
00091 QCString cStr = result.latin1();
00092 storeOut->writeBlock( cStr, cStr.size() - 1 );
00093
00094 return KoFilter::OK;
00095 }
00096
00097
00098 #include "aiimport.moc"
00099
00100
00101
|