[Libreoffice-commits] core.git: Branch 'distro/vector/vector-7.0' - vcl/qa

Miklos Vajna (via logerrit) logerrit at kemper.freedesktop.org
Thu Nov 26 15:48:07 UTC 2020


 vcl/qa/cppunit/GraphicTest.cxx    |   30 ++++++++++++++++++++++++++++++
 vcl/qa/cppunit/data/roundtrip.wmf |binary
 2 files changed, 30 insertions(+)

New commits:
commit 9c56f46f71bbbb72b9f8aef855032971ba07bcca
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 16:47:24 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.
    
    (cherry picked from commit 6bb0e09e2423ae00e06e6b7ae2c5a0af6ca100a1)
    
    Conflicts:
            vcl/qa/cppunit/GraphicTest.cxx
    
    Change-Id: I7661cd5e66d13b1750f16c0c423c4b69420577a0

diff --git a/vcl/qa/cppunit/GraphicTest.cxx b/vcl/qa/cppunit/GraphicTest.cxx
index 6a70ba921942..7f60343e17c7 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>
 
@@ -48,6 +49,7 @@ private:
     void testUnloadedGraphicSizeUnit();
     void testSwapping();
     void testSwappingVectorGraphic();
+    void testWMFRoundtrip();
 
     CPPUNIT_TEST_SUITE(GraphicTest);
     CPPUNIT_TEST(testUnloadedGraphic);
@@ -57,6 +59,7 @@ private:
     CPPUNIT_TEST(testUnloadedGraphicSizeUnit);
     CPPUNIT_TEST(testSwapping);
     CPPUNIT_TEST(testSwappingVectorGraphic);
+    CPPUNIT_TEST(testWMFRoundtrip);
     CPPUNIT_TEST_SUITE_END();
 };
 
@@ -426,6 +429,33 @@ void GraphicTest::testSwappingVectorGraphic()
     CPPUNIT_ASSERT_EQUAL(false, comphelper::DirectoryHelper::fileExists(rSwapFileURL));
 }
 
+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