diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2020-12-07 17:10:56 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2020-12-07 18:22:24 +0100 |
commit | c06abb40f7155e92c56026ce3ea0526ceb3a0f27 (patch) | |
tree | 6c82a43adfe3c7a8a98460ec7278368e92c0cb10 /vcl/qa | |
parent | b541cd9a8038810ce449f8c49ae179d9d6eaa7e8 (diff) |
vcl graphic export: convert EMF to WMF when WMF is requested
Regression from commit 5868745db74ae930edb0058490076d82aaeafbe9
(emfplus: make VectorFormats Emf/Wmf/Svg work, 2017-06-12), we used to
export graphic data as-is when the requested format is WMF and the
source format is EMF or WMF.
Restrict the as-is copying to the WMF source format only.
Change-Id: Iad40aee79df5ae367ae37c2fb3d5f4dfad8a40fc
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107355
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Tested-by: Jenkins
Diffstat (limited to 'vcl/qa')
-rw-r--r-- | vcl/qa/cppunit/GraphicTest.cxx | 36 | ||||
-rw-r--r-- | vcl/qa/cppunit/data/to-wmf.emf | bin | 0 -> 1057 bytes |
2 files changed, 36 insertions, 0 deletions
diff --git a/vcl/qa/cppunit/GraphicTest.cxx b/vcl/qa/cppunit/GraphicTest.cxx index df9711b54a35..479a3c91f836 100644 --- a/vcl/qa/cppunit/GraphicTest.cxx +++ b/vcl/qa/cppunit/GraphicTest.cxx @@ -25,8 +25,10 @@ #include <comphelper/hash.hxx> #include <unotools/ucbstreamhelper.hxx> #include <unotools/tempfile.hxx> +#include <vcl/cvtgrf.hxx> #include <impgraph.hxx> +#include <graphic/GraphicFormatDetector.hxx> #if USE_TLS_NSS #include <nss.h> @@ -51,6 +53,7 @@ private: void testSwappingVectorGraphic(); void testSwappingPageNumber(); void testWMFRoundtrip(); + void testEmfToWmfConversion(); CPPUNIT_TEST_SUITE(GraphicTest); CPPUNIT_TEST(testUnloadedGraphic); @@ -62,6 +65,7 @@ private: CPPUNIT_TEST(testSwappingVectorGraphic); CPPUNIT_TEST(testSwappingPageNumber); CPPUNIT_TEST(testWMFRoundtrip); + CPPUNIT_TEST(testEmfToWmfConversion); CPPUNIT_TEST_SUITE_END(); }; @@ -301,6 +305,38 @@ void GraphicTest::testUnloadedGraphicSizeUnit() CPPUNIT_ASSERT_EQUAL(Size(400, 363), aGraphic.GetPrefSize()); } +void GraphicTest::testEmfToWmfConversion() +{ + // Load EMF data. + GraphicFilter aGraphicFilter; + test::Directories aDirectories; + OUString aURL = aDirectories.getURLFromSrc(DATA_DIRECTORY) + "to-wmf.emf"; + SvFileStream aStream(aURL, StreamMode::READ); + Graphic aGraphic; + // This similar to an application/x-openoffice-wmf mime type in manifest.xml in the ODF case. + sal_uInt16 nFormat = aGraphicFilter.GetImportFormatNumberForShortName(u"WMF"); + CPPUNIT_ASSERT_EQUAL(ERRCODE_NONE, + aGraphicFilter.ImportGraphic(aGraphic, OUString(), aStream, nFormat)); + CPPUNIT_ASSERT_EQUAL(VectorGraphicDataType::Wmf, + aGraphic.getVectorGraphicData()->getVectorGraphicDataType()); + + // Save as WMF. + sal_uInt16 nFilterType = aGraphicFilter.GetExportFormatNumberForShortName(u"WMF"); + SvMemoryStream aGraphicStream; + CPPUNIT_ASSERT_EQUAL(ERRCODE_NONE, aGraphicFilter.ExportGraphic(aGraphic, OUString(), + aGraphicStream, nFilterType)); + aGraphicStream.Seek(0); + vcl::GraphicFormatDetector aDetector(aGraphicStream, OUString()); + CPPUNIT_ASSERT(aDetector.detect()); + CPPUNIT_ASSERT(aDetector.checkWMForEMF()); + + // Without the accompanying fix in place, this test would have failed with: + // - Expected: WMF + // - 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); +} + void GraphicTest::testSwapping() { // Prepare Graphic from a PNG image first diff --git a/vcl/qa/cppunit/data/to-wmf.emf b/vcl/qa/cppunit/data/to-wmf.emf Binary files differnew file mode 100644 index 000000000000..e1a7b9f9e517 --- /dev/null +++ b/vcl/qa/cppunit/data/to-wmf.emf |