filters
imageexport.cpp00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include <qpixmap.h>
00021 #include <qpainter.h>
00022
00023 #include <kmessagebox.h>
00024
00025 #include <KoFilterChain.h>
00026 #include <KoStore.h>
00027 #include <kgenericfactory.h>
00028 #include <KoDocument.h>
00029
00030 #include "imageexport.h"
00031 #include "kchart_part.h"
00032
00033 ImageExport::ImageExport(KoFilter *, const char *, const QStringList&)
00034 : KoFilter()
00035 {
00036 }
00037
00038 ImageExport::~ImageExport()
00039 {
00040 }
00041
00042
00043 KoFilter::ConversionStatus
00044 ImageExport::convert(const QCString& from, const QCString& to)
00045 {
00046
00047 if ( from != "application/x-kchart" || to != exportFormat() )
00048 return KoFilter::NotImplemented;
00049
00050
00051 KoStoreDevice* storeIn = m_chain->storageFile( "root", KoStore::Read );
00052 if ( !storeIn ) {
00053 KMessageBox::error( 0, i18n("Failed to read data." ),
00054 i18n( "Export Error" ) );
00055 return KoFilter::FileNotFound;
00056 }
00057
00058
00059 QDomDocument domIn;
00060 domIn.setContent( storeIn );
00061 QDomElement docNode = domIn.documentElement();
00062
00063
00064 KChart::KChartPart kchartDoc;
00065 if ( !kchartDoc.loadXML(0, domIn) ) {
00066 KMessageBox::error( 0, i18n( "Malformed XML data." ),
00067 i18n( "Export Error" ) );
00068 return KoFilter::WrongFormat;
00069 }
00070 width = 500;
00071 height = 400;
00072 extraImageAttribute();
00073 pixmap = QPixmap(width, height);
00074 QPainter painter(&pixmap);
00075 kchartDoc.paintContent(painter, pixmap.rect(), false);
00076 saveImage( m_chain->outputFile());
00077 return KoFilter::OK;
00078 }
00079
00080
00081 #include "imageexport.moc"
00082
|