filters
wmfimport.cc00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #include <config.h>
00024 #include <qdom.h>
00025 #include <qcstring.h>
00026 #include <kdebug.h>
00027 #include <kgenericfactory.h>
00028 #include <KoFilterChain.h>
00029 #include <KoStoreDevice.h>
00030 #include <core/vdocument.h>
00031
00032 #include "wmfimport.h"
00033 #include "wmfimportparser.h"
00034
00035 typedef KGenericFactory<WMFImport, KoFilter> WMFImportFactory;
00036 K_EXPORT_COMPONENT_FACTORY( libwmfimport, WMFImportFactory( "kofficefilters" ) )
00037
00038
00039 WMFImport::WMFImport( KoFilter *, const char *, const QStringList&) :
00040 KoFilter()
00041 {
00042 }
00043
00044 WMFImport::~WMFImport()
00045 {
00046 }
00047
00048 KoFilter::ConversionStatus WMFImport::convert( const QCString& from, const QCString& to )
00049 {
00050 if( to != "application/x-karbon" || from != "image/x-wmf" )
00051 return KoFilter::NotImplemented;
00052
00053 WMFImportParser wmfParser;
00054 if( !wmfParser.load( m_chain->inputFile() ) ) {
00055 return KoFilter::WrongFormat;
00056 }
00057
00058
00059 VDocument document;
00060 if (!wmfParser.play( document )) {
00061 return KoFilter::WrongFormat;
00062 }
00063
00064 KoStoreDevice* out = m_chain->storageFile( "root", KoStore::Write );
00065 if( !out ) {
00066 kdError(3800) << "Unable to open output file!" << endl;
00067 return KoFilter::StorageCreationError;
00068 }
00069 QDomDocument outdoc = document.saveXML();
00070 QCString content = outdoc.toCString();
00071
00072 out->writeBlock( content , content.length() );
00073
00074 return KoFilter::OK;
00075 }
00076
00077
00078 #include <wmfimport.moc>
|