[Libreoffice-commits] core.git: sw/qa sw/source test/source
Miklos Vajna (via logerrit)
logerrit at kemper.freedesktop.org
Thu Jul 1 16:25:37 UTC 2021
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 2d9580e6a65a2699ff61fc1b0e07f62b4946de84
Author: Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Thu Jul 1 17:33:42 2021 +0200
Commit: Miklos Vajna <vmiklos at collabora.com>
CommitDate: Thu Jul 1 18:25:01 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.
Change-Id: I0fc1bc13ad4bf808afbe68407e7db802f910c7a7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118233
Reviewed-by: Miklos Vajna <vmiklos at collabora.com>
Tested-by: Jenkins
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 bc065a7d64c0..e02d73b07016 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;
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: */
More information about the Libreoffice-commits
mailing list