24#include <tdeapplication.h>
25#include <tdemessagebox.h>
27#include <KoFilterChain.h>
30#include <kgenericfactory.h>
32#include <kformulacontainer.h>
33#include "kformuladocument.h"
38typedef KGenericFactory<SvgExport, KoFilter> SvgExportFactory;
39K_EXPORT_COMPONENT_FACTORY( libkfosvgexport, SvgExportFactory( "svgexport" ) )
41SvgExport::SvgExport(KoFilter *, const char *, const TQStringList&)
46SvgExport::~SvgExport()
51KoFilter::ConversionStatus
52SvgExport::convert( const TQCString& from, const TQCString& to)
55 if ( from != "application/x-kformula" || to != "image/svg+xml" )
56 return KoFilter::NotImplemented;
59 KoStoreDevice* storeIn = m_chain->storageFile( "root", KoStore::Read );
61 KMessageBox::error( 0, i18n( "Failed to read data." ),
62 i18n( "SVG Export Error" ) );
63 return KoFilter::FileNotFound;
68 domIn.setContent( storeIn );
69 TQDomElement docNode = domIn.documentElement();
72 KFormula::DocumentWrapper* wrapper = new KFormula::DocumentWrapper( kapp->config(), 0 );
73 KFormula::Document* kformulaDoc = new KFormula::Document;
74 wrapper->document( kformulaDoc );
75 KFormula::Container* formula = kformulaDoc->createFormula();
77 if ( !kformulaDoc->loadXML( domIn ) ) {
78 KMessageBox::error( 0, i18n( "Malformed XML data." ),
79 i18n( "SVG Export Error" ) );
80 return KoFilter::WrongFormat;
85 TQPainter painter(&picture);
86 TQRect rect(TQPoint(0, 0), TQPoint(500, 400));
87 formula->draw( painter, rect, false );
91 if ( !picture.save( m_chain->outputFile(), "SVG" ) ) {
92 KMessageBox::error( 0, i18n( "Failed to write file." ),
93 i18n( "SVG Export Error" ) );
102#include <svgexport.moc>
|