filters

wmfimport.cc

00001 /*
00002     Copyright (C) 2000, S.R.Haque <shaheedhaque@hotmail.com>.
00003     This file is part of the KDE project
00004 
00005     This library is free software; you can redistribute it and/or
00006     modify it under the terms of the GNU Library General Public
00007     License as published by the Free Software Foundation; either
00008     version 2 of the License, or (at your option) any later version.
00009 
00010     This library is distributed in the hope that it will be useful,
00011     but WITHOUT ANY WARRANTY; without even the implied warranty of
00012     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013     Library General Public License for more details.
00014 
00015     You should have received a copy of the GNU Library General Public License
00016     along with this library; see the file COPYING.LIB.  If not, write to
00017     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00018  * Boston, MA 02110-1301, USA.
00019 
00020 DESCRIPTION
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     // Do the conversion!
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     // kdDebug() << " content : " << content << endl;
00072     out->writeBlock( content , content.length() );
00073 
00074     return KoFilter::OK;
00075 }
00076 
00077 
00078 #include <wmfimport.moc>
KDE Home | KDE Accessibility Home | Description of Access Keys