writerperfect/source/wpdimp/WordPerfectImportFilter.cxx | 21 ++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-)
New commits: commit e79c9c4c5a84f0409362361901fbdcb6a574ed87 Author: Fridrich Å trba <[email protected]> Date: Sun Apr 8 22:11:52 2012 +0200 Generate SVG preview of embedded WPG image diff --git a/writerperfect/source/wpdimp/WordPerfectImportFilter.cxx b/writerperfect/source/wpdimp/WordPerfectImportFilter.cxx index a82338f..2dab43a 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;
_______________________________________________ Libreoffice-commits mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
