diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2021-07-01 17:33:42 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@vmiklos.hu> | 2021-07-02 15:22:03 +0200 |
commit | e8903df87ecdef73471e379193bdccbb015f79f0 (patch) | |
tree | c2fa7ea8a362f1e41fe152aa0f4ba753a38ce796 /sw | |
parent | 3c7172bf9cfec0a8dfb103d3ab9df927407cf6ff (diff) |
tdf#142871 sw HTML export: avoid unwanted inner PNG for images
Regression from commit e76471c5ce725dae9abb6f78b7674c6f77df34f4 (sw
XHTML / reqif export: export non-PNG graphic shapes directly,
2021-06-02), reqif wants to have a PNG fallback for non-PNG pixel
formats, but this is not needed for plain HTML, make this reqif-only.
Change-Id: I0fc1bc13ad4bf808afbe68407e7db802f910c7a7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118233
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Tested-by: Jenkins
(cherry picked from commit 2d9580e6a65a2699ff61fc1b0e07f62b4946de84)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118268
Reviewed-by: Miklos Vajna <vmiklos@vmiklos.hu>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/qa/extras/htmlexport/htmlexport.cxx | 28 | ||||
-rw-r--r-- | sw/source/filter/html/htmlflywriter.cxx | 4 |
2 files changed, 30 insertions, 2 deletions
diff --git a/sw/qa/extras/htmlexport/htmlexport.cxx b/sw/qa/extras/htmlexport/htmlexport.cxx index 180a2cccc599..b4f307131e8f 100644 --- a/sw/qa/extras/htmlexport/htmlexport.cxx +++ b/sw/qa/extras/htmlexport/htmlexport.cxx @@ -1755,6 +1755,34 @@ CPPUNIT_TEST_FIXTURE(SwHtmlDomExportTest, testReqifEmbedShapeAsPNG) OUString::number(aPixelSize.getWidth())); } +CPPUNIT_TEST_FIXTURE(SwHtmlDomExportTest, testShapeAsImageHtml) +{ + // 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(5080, 2540)); + uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY); + xDrawPageSupplier->getDrawPage()->add(xShape); + + // When exporting to plain HTML: + uno::Reference<frame::XStorable> xStorable(mxComponent, uno::UNO_QUERY); + uno::Sequence<beans::PropertyValue> aStoreProperties = { + comphelper::makePropertyValue("FilterName", OUString("HTML (StarWriter)")), + }; + xStorable->storeToURL(maTempFile.GetURL(), aStoreProperties); + mxComponent->dispose(); + + // Then make sure importing it back results in a clean doc model: + mxComponent = loadFromDesktop(maTempFile.GetURL()); + // Without the accompanying fix in place, this test would have failed with: + // - Expected: + // - Actual : /> + // i.e. the output was not well-formed. + CPPUNIT_ASSERT_EQUAL(OUString(" "), getParagraph(1)->getString()); +} + CPPUNIT_TEST_FIXTURE(SwHtmlDomExportTest, testReqifEmbedShapeAsPNGCustomDPI) { // Given a document with a shape: diff --git a/sw/source/filter/html/htmlflywriter.cxx b/sw/source/filter/html/htmlflywriter.cxx index 472f406c28c6..d245bb5d4bce 100644 --- a/sw/source/filter/html/htmlflywriter.cxx +++ b/sw/source/filter/html/htmlflywriter.cxx @@ -1798,7 +1798,7 @@ static void OutHTML_ImageOLEEnd(SwHTMLWriter& rHTMLWrt) static Writer & OutHTML_FrameFormatAsImage( Writer& rWrt, const SwFrameFormat& rFrameFormat, bool bPNGFallback) { SwHTMLWriter& rHTMLWrt = static_cast<SwHTMLWriter&>(rWrt); - bool bWritePNGFallback = !rHTMLWrt.m_bExportImagesAsOLE && bPNGFallback; + bool bWritePNGFallback = rHTMLWrt.mbReqIF && !rHTMLWrt.m_bExportImagesAsOLE && bPNGFallback; if (rHTMLWrt.mbSkipImages) return rWrt; @@ -1893,7 +1893,7 @@ static Writer& OutHTML_FrameFormatGrfNode( Writer& rWrt, const SwFrameFormat& rF bool bInCntnr, bool bPNGFallback ) { SwHTMLWriter& rHTMLWrt = static_cast<SwHTMLWriter&>(rWrt); - bool bWritePNGFallback = !rHTMLWrt.m_bExportImagesAsOLE && bPNGFallback; + bool bWritePNGFallback = rHTMLWrt.mbReqIF && !rHTMLWrt.m_bExportImagesAsOLE && bPNGFallback; if (rHTMLWrt.mbSkipImages) return rWrt; |