diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2020-12-09 09:38:48 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2020-12-09 10:46:31 +0100 |
commit | ca67839234e78fe6bea21ec39906d1bd71d34d47 (patch) | |
tree | 2003f700fa05bd24bea1efc890e9549aa3507391 /vcl/qa | |
parent | c81fea2e78d66c1978cb2340868c938ba9d6c9f1 (diff) |
vcl: improve EMF+ -> WMF conversion
We throw away EMF fallback info when parsing EMF+ data. This means that
the resulting GDIMetaFile (containing EMF+ data but no EMF fallback) is
tricky to export to WMF, where EMF+ comments are not allowed.
Improve the conversion result by re-parsing such EMF+ data with EMF+
disabled, and then converting the GDIMetaFile (containing EMF fallback
data) to WMF.
Change-Id: Ib2c0388f1344aef7f601ce9be59e4a8924e8085b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107453
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Tested-by: Jenkins
Diffstat (limited to 'vcl/qa')
-rw-r--r-- | vcl/qa/cppunit/GraphicTest.cxx | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/vcl/qa/cppunit/GraphicTest.cxx b/vcl/qa/cppunit/GraphicTest.cxx index 479a3c91f836..d3671fe3c881 100644 --- a/vcl/qa/cppunit/GraphicTest.cxx +++ b/vcl/qa/cppunit/GraphicTest.cxx @@ -26,6 +26,7 @@ #include <unotools/ucbstreamhelper.hxx> #include <unotools/tempfile.hxx> #include <vcl/cvtgrf.hxx> +#include <vcl/metaact.hxx> #include <impgraph.hxx> #include <graphic/GraphicFormatDetector.hxx> @@ -335,6 +336,31 @@ void GraphicTest::testEmfToWmfConversion() // - Actual : EMF // i.e. EMF data was requested to be converted to WMF, but the output was still EMF. CPPUNIT_ASSERT_EQUAL(OUString("WMF"), aDetector.msDetectedFormat); + + // Import the WMF result and check for traces of EMF+ in it. + Graphic aWmfGraphic; + aGraphicStream.Seek(0); + CPPUNIT_ASSERT_EQUAL(ERRCODE_NONE, aGraphicFilter.ImportGraphic(aWmfGraphic, OUString(), + aGraphicStream, nFormat)); + int nCommentCount = 0; + for (size_t i = 0; i < aWmfGraphic.GetGDIMetaFile().GetActionSize(); ++i) + { + MetaAction* pAction = aWmfGraphic.GetGDIMetaFile().GetAction(i); + if (pAction->GetType() == MetaActionType::COMMENT) + { + auto pComment = static_cast<MetaCommentAction*>(pAction); + if (pComment->GetComment().startsWith("EMF_PLUS")) + { + ++nCommentCount; + } + } + } + // Without the accompanying fix in place, this test would have failed with: + // - Expected less or equal than: 4 + // - Actual : 8 + // i.e. even more EMF+ comments were left in the WMF output. The ideal would be to get this down + // to 0, though. + CPPUNIT_ASSERT_LESSEQUAL(4, nCommentCount); } void GraphicTest::testSwapping() |