sw/qa/extras/htmlexport/htmlexport.cxx | 28 ++++++++++++++++++++++++++++ sw/source/filter/html/htmlflywriter.cxx | 4 ++-- test/source/htmltesttools.cxx | 5 ++++- 3 files changed, 34 insertions(+), 3 deletions(-)
New commits: commit 559181f925b5791512408c87ce32e3aed90ecded Author: Miklos Vajna <vmik...@collabora.com> AuthorDate: Thu Jul 8 17:08:06 2021 +0200 Commit: Miklos Vajna <vmik...@collabora.com> CommitDate: Fri Jul 9 15:10:46 2021 +0200 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. (cherry picked from commit 2d9580e6a65a2699ff61fc1b0e07f62b4946de84) Change-Id: I0fc1bc13ad4bf808afbe68407e7db802f910c7a7 diff --git a/sw/qa/extras/htmlexport/htmlexport.cxx b/sw/qa/extras/htmlexport/htmlexport.cxx index 3dfe581a4858..f1fcc3631dae 100644 --- a/sw/qa/extras/htmlexport/htmlexport.cxx +++ b/sw/qa/extras/htmlexport/htmlexport.cxx @@ -1757,6 +1757,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 6f01a5c7008d..847dae7cb93b 100644 --- a/sw/source/filter/html/htmlflywriter.cxx +++ b/sw/source/filter/html/htmlflywriter.cxx @@ -1801,7 +1801,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; @@ -1896,7 +1896,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; diff --git a/test/source/htmltesttools.cxx b/test/source/htmltesttools.cxx index 9f9a1bbddfc6..d61f07bd3d1b 100644 --- a/test/source/htmltesttools.cxx +++ b/test/source/htmltesttools.cxx @@ -8,6 +8,7 @@ */ #include <test/htmltesttools.hxx> +#include <sal/log.hxx> #include <memory> @@ -30,7 +31,9 @@ htmlDocUniquePtr HtmlTestTools::parseHtmlStream(SvStream* pStream) std::unique_ptr<sal_uInt8[]> pBuffer(new sal_uInt8[nSize + 1]); pStream->ReadBytes(pBuffer.get(), nSize); pBuffer[nSize] = 0; - return htmlDocUniquePtr(htmlParseDoc(reinterpret_cast<xmlChar*>(pBuffer.get()), nullptr)); + auto pCharBuffer = reinterpret_cast<xmlChar*>(pBuffer.get()); + SAL_INFO("test", "HtmlTestTools::parseXmlStream: pBuffer is '" << pCharBuffer << "'"); + return htmlDocUniquePtr(htmlParseDoc(pCharBuffer, nullptr)); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits