[Libreoffice-commits] core.git: Branch 'distro/vector/vector-7.0' - svx/source sw/qa
Miklos Vajna (via logerrit)
logerrit at kemper.freedesktop.org
Tue Aug 10 09:51:38 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 440ac7b55f3648c1a21f2bf3607cbdceeeac8204
Author: Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Mon Aug 9 16:16:35 2021 +0200
Commit: Miklos Vajna <vmiklos at collabora.com>
CommitDate: Tue Aug 10 11:50:57 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.
(cherry picked from commit 82a444eabc38b74d762debb6f1af50e93e5b74f1)
Conflicts:
svx/source/xoutdev/_xoutbmp.cxx
Change-Id: I7bced482d677cf121be1ed494a3aaeb319e1c5b4
diff --git a/svx/source/xoutdev/_xoutbmp.cxx b/svx/source/xoutdev/_xoutbmp.cxx
index 5bc11f752aba..be5f7790e1f4 100644
--- a/svx/source/xoutdev/_xoutbmp.cxx
+++ b/svx/source/xoutdev/_xoutbmp.cxx
@@ -134,12 +134,13 @@ ErrCode XOutBitmap::WriteGraphic( const Graphic& rGraphic, OUString& rFileName,
if (rVectorGraphicDataPtr && rVectorGraphicDataPtr->getVectorGraphicDataArrayLength())
{
+ // Does the filter name match the original format?
const bool bIsSvg(rFilterName.equalsIgnoreAsciiCase("svg") && VectorGraphicDataType::Svg == rVectorGraphicDataPtr->getVectorGraphicDataType());
const bool bIsWmf(rFilterName.equalsIgnoreAsciiCase("wmf") && VectorGraphicDataType::Wmf == rVectorGraphicDataPtr->getVectorGraphicDataType());
bool bIsEmf(rFilterName.equalsIgnoreAsciiCase("emf") && VectorGraphicDataType::Emf == rVectorGraphicDataPtr->getVectorGraphicDataType());
if (!bIsEmf)
{
- bIsEmf = rGraphic.GetGfxLink().IsEMF();
+ bIsEmf = rFilterName.equalsIgnoreAsciiCase("emf") && rGraphic.GetGfxLink().IsEMF();
}
const bool bIsPdf(rFilterName.equalsIgnoreAsciiCase("pdf") && VectorGraphicDataType::Pdf == rVectorGraphicDataPtr->getVectorGraphicDataType());
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 f1fcc3631dae..e5d9b4fdc8b9 100644
--- a/sw/qa/extras/htmlexport/htmlexport.cxx
+++ b/sw/qa/extras/htmlexport/htmlexport.cxx
@@ -1963,6 +1963,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