[Libreoffice-commits] core.git: sw/qa sw/source
Miklos Vajna (via logerrit)
logerrit at kemper.freedesktop.org
Thu Jun 3 15:53:35 UTC 2021
sw/qa/extras/htmlexport/htmlexport.cxx | 31 +++++++++++++++++++++++++++++++
sw/source/filter/html/htmlflywriter.cxx | 5 +++++
2 files changed, 36 insertions(+)
New commits:
commit c8a9396e5695675ffe92935a9ba40354fc76ed79
Author: Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Thu Jun 3 17:10:57 2021 +0200
Commit: Miklos Vajna <vmiklos at collabora.com>
CommitDate: Thu Jun 3 17:52:52 2021 +0200
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 at collabora.com>
Tested-by: Jenkins
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 );
More information about the Libreoffice-commits
mailing list