filters

pngexport.cc

00001 /* This file is part of the KDE project
00002    Copyright (C) 2002 Ulrich Kuettler <ulrich.kuettler@mailbox.tu-dresden.de>
00003 
00004    This library is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU Library General Public
00006    License as published by the Free Software Foundation; either
00007    version 2 of the License, or (at your option) any later version.
00008 
00009    This library is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012    Library General Public License for more details.
00013 
00014    You should have received a copy of the GNU Library General Public License
00015    along with this library; see the file COPYING.LIB.  If not, write to
00016    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00017  * Boston, MA 02110-1301, USA.
00018 */
00019 
00020 #include <qstring.h>
00021 #include <qtextstream.h>
00022 #include <qfile.h>
00023 #include <qobject.h>
00024 
00025 #include <kapplication.h>
00026 #include <kdebug.h>
00027 #include <kgenericfactory.h>
00028 #include <kmessagebox.h>
00029 
00030 #include <KoFilterChain.h>
00031 #include <KoStore.h>
00032 #include <KoStoreDevice.h>
00033 
00034 
00035 #include "pngexport.h"
00036 #include "pngexportdia.h"
00037 
00038 
00039 typedef KGenericFactory<PNGExport, KoFilter> PNGExportFactory;
00040 K_EXPORT_COMPONENT_FACTORY( libkfopngexport, PNGExportFactory( "kofficefilters" ) )
00041 
00042 
00043 PNGExport::PNGExport( KoFilter */*parent*/, const char */*name*/, const QStringList& )
00044     : KoFilter()
00045 {
00046 }
00047 
00048 
00049 KoFilter::ConversionStatus PNGExport::convert( const QCString& from, const QCString& to )
00050 {
00051     if ( to != "image/png" || from != "application/x-kformula" )
00052         return KoFilter::NotImplemented;
00053 
00054     KoStoreDevice* in = m_chain->storageFile( "root", KoStore::Read );
00055     if(!in) {
00056         kapp->restoreOverrideCursor();
00057         KMessageBox::error( 0, i18n( "Failed to read data." ), i18n( "PNG Export Error" ) );
00058         return KoFilter::FileNotFound;
00059     }
00060 
00061     QDomDocument dom( "KFORMULA" );
00062     if ( !dom.setContent( in, false ) ) {
00063         kapp->restoreOverrideCursor();
00064         KMessageBox::error( 0, i18n( "Malformed XML data." ), i18n( "PNG Export Error" ) );
00065         return KoFilter::WrongFormat;
00066     }
00067 
00068     PNGExportDia* dialog = new PNGExportDia( dom, m_chain->outputFile() );
00069     dialog->exec();
00070     delete dialog;
00071     return KoFilter::OK;
00072 }
00073 
00074 #include "pngexport.moc"
KDE Home | KDE Accessibility Home | Description of Access Keys