diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2020-11-25 18:01:08 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2020-11-26 07:37:29 +0100 |
commit | 6bb0e09e2423ae00e06e6b7ae2c5a0af6ca100a1 (patch) | |
tree | 50e5851be6063a4fac78e0632b36ac8a42711e70 /vcl | |
parent | a45ea4f7939e7ca2e5c071ad209c957702b527e6 (diff) |
WMF export: just write the source data as is for from-WMF graphics
This was already working on master since commit
5868745db74ae930edb0058490076d82aaeafbe9 (emfplus: make VectorFormats
Emf/Wmf/Svg work, 2017-06-12), but a matching testcase was missing.
Change-Id: I7661cd5e66d13b1750f16c0c423c4b69420577a0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/106607
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Tested-by: Jenkins
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/qa/cppunit/GraphicTest.cxx | 30 | ||||
-rw-r--r-- | vcl/qa/cppunit/data/roundtrip.wmf | bin | 0 -> 6475 bytes |
2 files changed, 30 insertions, 0 deletions
diff --git a/vcl/qa/cppunit/GraphicTest.cxx b/vcl/qa/cppunit/GraphicTest.cxx index 50ff4a133f86..df9711b54a35 100644 --- a/vcl/qa/cppunit/GraphicTest.cxx +++ b/vcl/qa/cppunit/GraphicTest.cxx @@ -24,6 +24,7 @@ #include <comphelper/DirectoryHelper.hxx> #include <comphelper/hash.hxx> #include <unotools/ucbstreamhelper.hxx> +#include <unotools/tempfile.hxx> #include <impgraph.hxx> @@ -49,6 +50,7 @@ private: void testSwapping(); void testSwappingVectorGraphic(); void testSwappingPageNumber(); + void testWMFRoundtrip(); CPPUNIT_TEST_SUITE(GraphicTest); CPPUNIT_TEST(testUnloadedGraphic); @@ -59,6 +61,7 @@ private: CPPUNIT_TEST(testSwapping); CPPUNIT_TEST(testSwappingVectorGraphic); CPPUNIT_TEST(testSwappingPageNumber); + CPPUNIT_TEST(testWMFRoundtrip); CPPUNIT_TEST_SUITE_END(); }; @@ -468,6 +471,33 @@ void GraphicTest::testSwappingPageNumber() CPPUNIT_ASSERT_EQUAL(sal_Int32(1), aGraphic.getVectorGraphicData()->getPageIndex()); } +void GraphicTest::testWMFRoundtrip() +{ + // Load a WMF file. + test::Directories aDirectories; + OUString aURL = aDirectories.getURLFromSrc("vcl/qa/cppunit/data/roundtrip.wmf"); + SvFileStream aStream(aURL, StreamMode::READ); + sal_uInt64 nExpectedSize = aStream.TellEnd(); + GraphicFilter& rGraphicFilter = GraphicFilter::GetGraphicFilter(); + Graphic aGraphic = rGraphicFilter.ImportUnloadedGraphic(aStream); + + // Save as WMF. + utl::TempFile aTempFile; + aTempFile.EnableKillingFile(); + sal_uInt16 nFormat = rGraphicFilter.GetExportFormatNumberForShortName(u"WMF"); + SvStream& rOutStream = *aTempFile.GetStream(StreamMode::READWRITE); + rGraphicFilter.ExportGraphic(aGraphic, OUString(), rOutStream, nFormat); + + // Check if we preserved the WMF data perfectly. + sal_uInt64 nActualSize = rOutStream.TellEnd(); + + // Without the accompanying fix in place, this test would have failed with: + // - Expected: 6475 + // - Actual : 2826 + // i.e. we lost some of the WMF data on roundtrip. + CPPUNIT_ASSERT_EQUAL(nExpectedSize, nActualSize); +} + } // namespace CPPUNIT_TEST_SUITE_REGISTRATION(GraphicTest); diff --git a/vcl/qa/cppunit/data/roundtrip.wmf b/vcl/qa/cppunit/data/roundtrip.wmf Binary files differnew file mode 100644 index 000000000000..83210546c373 --- /dev/null +++ b/vcl/qa/cppunit/data/roundtrip.wmf |