[Libreoffice-commits] core.git: vcl/qa
Miklos Vajna (via logerrit)
logerrit at kemper.freedesktop.org
Thu Nov 26 06:38:20 UTC 2020
vcl/qa/cppunit/GraphicTest.cxx | 30 ++++++++++++++++++++++++++++++
vcl/qa/cppunit/data/roundtrip.wmf |binary
2 files changed, 30 insertions(+)
New commits:
commit 6bb0e09e2423ae00e06e6b7ae2c5a0af6ca100a1
Author: Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Wed Nov 25 18:01:08 2020 +0100
Commit: Miklos Vajna <vmiklos at collabora.com>
CommitDate: Thu Nov 26 07:37:29 2020 +0100
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 at collabora.com>
Tested-by: Jenkins
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
new file mode 100644
index 000000000000..83210546c373
Binary files /dev/null and b/vcl/qa/cppunit/data/roundtrip.wmf differ
More information about the Libreoffice-commits
mailing list