diff options
author | Fridrich Štrba <fridrich.strba@bluewin.ch> | 2012-04-08 22:11:52 +0200 |
---|---|---|
committer | Fridrich Štrba <fridrich.strba@bluewin.ch> | 2012-04-08 22:11:52 +0200 |
commit | e79c9c4c5a84f0409362361901fbdcb6a574ed87 (patch) | |
tree | 3418853134cf90e23ea9e1e5fe336ad99ebcb80f /writerperfect/source | |
parent | 04950bf3c339f074588fbcff7121fdff76f00163 (diff) |
Generate SVG preview of embedded WPG image
Diffstat (limited to 'writerperfect/source')
-rw-r--r-- | writerperfect/source/wpdimp/WordPerfectImportFilter.cxx | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/writerperfect/source/wpdimp/WordPerfectImportFilter.cxx b/writerperfect/source/wpdimp/WordPerfectImportFilter.cxx index a82338f6727e..2dab43a0e82d 100644 --- a/writerperfect/source/wpdimp/WordPerfectImportFilter.cxx +++ b/writerperfect/source/wpdimp/WordPerfectImportFilter.cxx @@ -85,7 +85,7 @@ using com::sun::star::xml::sax::XParser; void callHandler(uno::Reference < XDocumentHandler > xDocHandler); -static bool handleEmbeddedWPG(const WPXBinaryData &data, OdfDocumentHandler *pHandler, const OdfStreamType streamType) +static bool handleEmbeddedWPGObject(const WPXBinaryData &data, OdfDocumentHandler *pHandler, const OdfStreamType streamType) { OdgGenerator exporter(pHandler, streamType); @@ -97,6 +97,22 @@ static bool handleEmbeddedWPG(const WPXBinaryData &data, OdfDocumentHandler *pHa return libwpg::WPGraphics::parse(const_cast<WPXInputStream *>(data.getDataStream()), &exporter, fileFormat); } +static bool handleEmbeddedWPGImage(const WPXBinaryData &input, WPXBinaryData &output) +{ + WPXString svgOutput; + libwpg::WPGFileFormat fileFormat = libwpg::WPG_AUTODETECT; + + if (!libwpg::WPGraphics::isSupported(const_cast<WPXInputStream *>(input.getDataStream()))) + fileFormat = libwpg::WPG_WPG1; + + if (!libwpg::WPGraphics::generateSVG(const_cast<WPXInputStream *>(input.getDataStream()), svgOutput, fileFormat)) + return false; + + output.clear(); + output.append((unsigned char *)svgOutput.cstr(), strlen(svgOutput.cstr())); + return true; +} + sal_Bool SAL_CALL WordPerfectImportFilter::importImpl( const Sequence< ::com::sun::star::beans::PropertyValue >& aDescriptor ) throw (RuntimeException) { @@ -159,7 +175,8 @@ throw (RuntimeException) DocumentHandler xHandler(xInternalHandler); OdtGenerator collector(&xHandler, ODF_FLAT_XML); - collector.registerEmbeddedObjectHandler("image/x-wpg", &handleEmbeddedWPG); + collector.registerEmbeddedObjectHandler("image/x-wpg", &handleEmbeddedWPGObject); + collector.registerEmbeddedImageHandler("image/x-wpg", &handleEmbeddedWPGImage); if (WPD_OK == WPDocument::parse(&input, &collector, aUtf8Passwd.isEmpty() ? 0 : aUtf8Passwd.getStr())) return sal_True; return sal_False; |