diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2021-06-03 17:10:57 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2021-06-04 16:46:43 +0200 |
commit | 72b12ac7afd40e5d51ac4edd1d57505994067cc9 (patch) | |
tree | 00412750b1d8c3e68a30f5e7fad0b4e0251865bb | |
parent | 9beb47b7121fe992a4328719736e2e9f4e11aaf1 (diff) |
sw XHTML / reqif export: fix PNG export of shapes
image/x-vclgraphic is not something anybody else will understand.
(cherry picked from commit c8a9396e5695675ffe92935a9ba40354fc76ed79)
Change-Id: I5a5b37b7f769de351bd3dfc38ccd57381bc43319
-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 4d0e66802d78..21367abfaa0f 100644 --- a/sw/qa/extras/htmlexport/htmlexport.cxx +++ b/sw/qa/extras/htmlexport/htmlexport.cxx @@ -1696,6 +1696,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 57a92eeed34f..4cc591c9d566 100644 --- a/sw/source/filter/html/htmlflywriter.cxx +++ b/sw/source/filter/html/htmlflywriter.cxx @@ -1800,6 +1800,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 ); |