diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2021-06-03 17:10:57 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2021-06-03 17:52:52 +0200 |
commit | c8a9396e5695675ffe92935a9ba40354fc76ed79 (patch) | |
tree | 789971ca6842d93c2003d3236c6cd166b8abd1f8 /sw | |
parent | 988175a5111d214aee6c52be8065b1b79be26497 (diff) |
sw XHTML / reqif export: fix PNG export of shapes
image/x-vclgraphic is not something anybody else will understand.
Change-Id: I5a5b37b7f769de351bd3dfc38ccd57381bc43319
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/116673
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Tested-by: Jenkins
Diffstat (limited to 'sw')
-rw-r--r-- | sw/qa/extras/htmlexport/htmlexport.cxx | 31 | ||||
-rw-r--r-- | sw/source/filter/html/htmlflywriter.cxx | 5 |
2 files changed, 36 insertions, 0 deletions
diff --git a/sw/qa/extras/htmlexport/htmlexport.cxx b/sw/qa/extras/htmlexport/htmlexport.cxx index 3484ff938230..b97cf7968640 100644 --- a/sw/qa/extras/htmlexport/htmlexport.cxx +++ b/sw/qa/extras/htmlexport/htmlexport.cxx @@ -1694,6 +1694,37 @@ CPPUNIT_TEST_FIXTURE(SwHtmlDomExportTest, testReqifEmbedPNGShapeAsOLE) assertXPath(pXmlDoc, "//reqif-xhtml:p/reqif-xhtml:object", "type", "text/rtf"); } +CPPUNIT_TEST_FIXTURE(SwHtmlDomExportTest, testReqifEmbedShapeAsPNG) +{ + // Given a document with a shape: + loadURL("private:factory/swriter", nullptr); + uno::Reference<css::lang::XMultiServiceFactory> xFactory(mxComponent, uno::UNO_QUERY); + uno::Reference<drawing::XShape> xShape( + xFactory->createInstance("com.sun.star.drawing.RectangleShape"), uno::UNO_QUERY); + xShape->setSize(awt::Size(10000, 10000)); + uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY); + xDrawPageSupplier->getDrawPage()->add(xShape); + + // When exporting to XHTML: + uno::Reference<frame::XStorable> xStorable(mxComponent, uno::UNO_QUERY); + uno::Sequence<beans::PropertyValue> aStoreProperties = { + comphelper::makePropertyValue("FilterName", OUString("HTML (StarWriter)")), + comphelper::makePropertyValue("FilterOptions", OUString("xhtmlns=reqif-xhtml")), + }; + xStorable->storeToURL(maTempFile.GetURL(), aStoreProperties); + + // Then make sure the shape is embedded as a PNG: + SvMemoryStream aStream; + HtmlExportTest::wrapFragment(maTempFile, aStream); + xmlDocUniquePtr pXmlDoc = parseXmlStream(&aStream); + CPPUNIT_ASSERT(pXmlDoc); + // Without the accompanying fix in place, this test would have failed with: + // - Expected: image/png + // - Actual : image/x-vclgraphic + // i.e. the result was invalid ReqIF. + assertXPath(pXmlDoc, "//reqif-xhtml:p/reqif-xhtml:object", "type", "image/png"); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/filter/html/htmlflywriter.cxx b/sw/source/filter/html/htmlflywriter.cxx index cd2350a75171..ed6d646594ee 100644 --- a/sw/source/filter/html/htmlflywriter.cxx +++ b/sw/source/filter/html/htmlflywriter.cxx @@ -1797,6 +1797,11 @@ static Writer & OutHTML_FrameFormatAsImage( Writer& rWrt, const SwFrameFormat& r { aGraphic = pGrafObj->GetGraphic(); } + else + { + // We only have a bitmap, write that as PNG without any fallback. + bWritePNGFallback = false; + } } Size aSz( 0, 0 ); |