[Libreoffice-commits] core.git: svx/source sw/qa
Miklos Vajna (via logerrit)
logerrit at kemper.freedesktop.org
Mon Aug 9 18:11:19 UTC 2021
svx/source/xoutdev/_xoutbmp.cxx | 3 ++-
sw/qa/extras/htmlexport/data/ole2.odt |binary
sw/qa/extras/htmlexport/htmlexport.cxx | 21 +++++++++++++++++++++
3 files changed, 23 insertions(+), 1 deletion(-)
New commits:
commit 82a444eabc38b74d762debb6f1af50e93e5b74f1
Author: Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Mon Aug 9 16:16:35 2021 +0200
Commit: Miklos Vajna <vmiklos at collabora.com>
CommitDate: Mon Aug 9 20:10:41 2021 +0200
sw HTML export: avoid writing EMF data with JPG extension
Regression from commit f3b2fc2276ee8a7f64e73d9975d0143d1696362c (sw
XHTML import, improved <object> handling for images: support more
formats, 2021-07-20), the problem was that now an EMF image was written
with the JPG extension in the HTML export.
Solve the problem by making the "use emf as-is" check more strict in
XOutBitmap::WriteGraphic(): that will be still true in the XHTML case
when the source image is EMF, but the filter name will be JPG in the
HTML case, so that will avoid the unwanted EMF data in the HTML case.
Change-Id: I7bced482d677cf121be1ed494a3aaeb319e1c5b4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120209
Reviewed-by: Miklos Vajna <vmiklos at collabora.com>
Tested-by: Jenkins
diff --git a/svx/source/xoutdev/_xoutbmp.cxx b/svx/source/xoutdev/_xoutbmp.cxx
index a2a672ede2b5..8eaec8e5a5fc 100644
--- a/svx/source/xoutdev/_xoutbmp.cxx
+++ b/svx/source/xoutdev/_xoutbmp.cxx
@@ -132,12 +132,13 @@ ErrCode XOutBitmap::WriteGraphic( const Graphic& rGraphic, OUString& rFileName,
if (rVectorGraphicDataPtr && rVectorGraphicDataPtr->getBinaryDataContainer().getSize())
{
+ // Does the filter name match the original format?
const bool bIsSvg(rFilterName.equalsIgnoreAsciiCase("svg") && VectorGraphicDataType::Svg == rVectorGraphicDataPtr->getType());
const bool bIsWmf(rFilterName.equalsIgnoreAsciiCase("wmf") && VectorGraphicDataType::Wmf == rVectorGraphicDataPtr->getType());
bool bIsEmf(rFilterName.equalsIgnoreAsciiCase("emf") && VectorGraphicDataType::Emf == rVectorGraphicDataPtr->getType());
if (!bIsEmf)
{
- bIsEmf = rGraphic.GetGfxLink().IsEMF();
+ bIsEmf = rFilterName.equalsIgnoreAsciiCase("emf") && rGraphic.GetGfxLink().IsEMF();
}
const bool bIsPdf(rFilterName.equalsIgnoreAsciiCase("pdf") && VectorGraphicDataType::Pdf == rVectorGraphicDataPtr->getType());
diff --git a/sw/qa/extras/htmlexport/data/ole2.odt b/sw/qa/extras/htmlexport/data/ole2.odt
new file mode 100644
index 000000000000..a10cfbb5b542
Binary files /dev/null and b/sw/qa/extras/htmlexport/data/ole2.odt differ
diff --git a/sw/qa/extras/htmlexport/htmlexport.cxx b/sw/qa/extras/htmlexport/htmlexport.cxx
index 76f27831ec10..e58641ac6f8a 100644
--- a/sw/qa/extras/htmlexport/htmlexport.cxx
+++ b/sw/qa/extras/htmlexport/htmlexport.cxx
@@ -1960,6 +1960,27 @@ CPPUNIT_TEST_FIXTURE(SwHtmlDomExportTest, testListsHeading)
"list 1, header 1");
}
+CPPUNIT_TEST_FIXTURE(SwHtmlDomExportTest, testOleEmfPreviewToHtml)
+{
+ // Given a document containing an embedded object, with EMF preview:
+ OUString aURL = m_directories.getURLFromSrc(DATA_DIRECTORY) + "ole2.odt";
+ mxComponent = loadFromDesktop(aURL, "com.sun.star.text.TextDocument", {});
+
+ // When exporting to 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);
+
+ // Then make sure the <img> tag has matching file extension and data:
+ htmlDocUniquePtr pDoc = parseHtml(maTempFile);
+ OUString aPath = getXPath(pDoc, "/html/body/p/img", "src");
+ // Without the accompanying fix in place, this test would have failed, as aPath was
+ // ole_html_3978e5f373402b43.JPG, with EMF data.
+ CPPUNIT_ASSERT(aPath.endsWith("gif"));
+}
+
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
More information about the Libreoffice-commits
mailing list