[Libreoffice-commits] core.git: Branch 'libreoffice-6-3' - vcl/qa vcl/source

Miklos Vajna (via logerrit) logerrit at kemper.freedesktop.org
Wed Nov 20 20:36:51 UTC 2019


 vcl/qa/cppunit/GraphicTest.cxx    |   22 ++++++++++++++++++++++
 vcl/qa/cppunit/data/inch-size.emf |binary
 vcl/source/gdi/impgraph.cxx       |    4 +++-
 3 files changed, 25 insertions(+), 1 deletion(-)

New commits:
commit 427973bc2958b34464cfb5b38b3b06c422a919df
Author:     Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Mon Nov 18 21:18:24 2019 +0100
Commit:     Miklos Vajna <vmiklos at collabora.com>
CommitDate: Wed Nov 20 21:35:52 2019 +0100

    tdf#128632 vcl image lazy-load: take unit into account when setting size
    
    It makes no sense to set the size of an image based on the swap info
    when the swap info unit and the actually loaded image's unit doesn't
    match.
    
    Converting the size would be also an option, but let's wait for the
    first case when a custom size is actually needed for mismatching units.
    
    (cherry picked from commit 0098563895f6a4024b400582d1bf93cb4435ceed)
    
    Change-Id: I96b5c237f0be5587bb2f938faf3c69fa0e1d4a5c
    Reviewed-on: https://gerrit.libreoffice.org/83160
    Tested-by: Jenkins
    Reviewed-by: Miklos Vajna <vmiklos at collabora.com>
    Signed-off-by: Xisco Fauli <xiscofauli at libreoffice.org>
    Reviewed-on: https://gerrit.libreoffice.org/83288
    Reviewed-by: Michael Stahl <michael.stahl at cib.de>

diff --git a/vcl/qa/cppunit/GraphicTest.cxx b/vcl/qa/cppunit/GraphicTest.cxx
index c9593434674b..2b1bfda8a919 100644
--- a/vcl/qa/cppunit/GraphicTest.cxx
+++ b/vcl/qa/cppunit/GraphicTest.cxx
@@ -19,6 +19,7 @@
 #include <vcl/graphicfilter.hxx>
 #include <tools/stream.hxx>
 #include <vcl/pngwrite.hxx>
+#include <unotest/directories.hxx>
 
 using namespace css;
 
@@ -30,12 +31,14 @@ class GraphicTest : public CppUnit::TestFixture
     void testUnloadedGraphicLoading();
     void testUnloadedGraphicWmf();
     void testUnloadedGraphicAlpha();
+    void testUnloadedGraphicSizeUnit();
 
     CPPUNIT_TEST_SUITE(GraphicTest);
     CPPUNIT_TEST(testUnloadedGraphic);
     CPPUNIT_TEST(testUnloadedGraphicLoading);
     CPPUNIT_TEST(testUnloadedGraphicWmf);
     CPPUNIT_TEST(testUnloadedGraphicAlpha);
+    CPPUNIT_TEST(testUnloadedGraphicSizeUnit);
     CPPUNIT_TEST_SUITE_END();
 };
 
@@ -80,6 +83,8 @@ Graphic makeUnloadedGraphic(OUString const& sType, bool alpha = false)
     return rGraphicFilter.ImportUnloadedGraphic(aStream);
 }
 
+char const DATA_DIRECTORY[] = "/vcl/qa/cppunit/data/";
+
 void GraphicTest::testUnloadedGraphic()
 {
     // make unloaded test graphic
@@ -195,6 +200,23 @@ void GraphicTest::testUnloadedGraphicAlpha()
     CPPUNIT_ASSERT_EQUAL(false, aGraphic.isAvailable());
 }
 
+void GraphicTest::testUnloadedGraphicSizeUnit()
+{
+    GraphicFilter& rGraphicFilter = GraphicFilter::GetGraphicFilter();
+    test::Directories aDirectories;
+    OUString aURL = aDirectories.getURLFromSrc(DATA_DIRECTORY) + "inch-size.emf";
+    Size aMtfSize100(42, 42);
+    SvFileStream aStream(aURL, StreamMode::READ);
+    Graphic aGraphic = rGraphicFilter.ImportUnloadedGraphic(aStream, 0, &aMtfSize100);
+    aGraphic.makeAvailable();
+
+    // Without the accompanying fix in place, this test would have failed with:
+    // - Expected: 400x363
+    // - Actual  : 42x42
+    // i.e. a mm100 size was used as a hint and the inch size was set for a non-matching unit.
+    CPPUNIT_ASSERT_EQUAL(Size(400, 363), aGraphic.GetPrefSize());
+}
+
 } // namespace
 
 CPPUNIT_TEST_SUITE_REGISTRATION(GraphicTest);
diff --git a/vcl/qa/cppunit/data/inch-size.emf b/vcl/qa/cppunit/data/inch-size.emf
new file mode 100644
index 000000000000..ac5a1b805cf2
Binary files /dev/null and b/vcl/qa/cppunit/data/inch-size.emf differ
diff --git a/vcl/source/gdi/impgraph.cxx b/vcl/source/gdi/impgraph.cxx
index e15644c9fdc2..8616e08e1c9d 100644
--- a/vcl/source/gdi/impgraph.cxx
+++ b/vcl/source/gdi/impgraph.cxx
@@ -1556,10 +1556,12 @@ bool ImpGraphic::loadPrepared()
         GraphicExternalLink aLink = maGraphicExternalLink;
 
         Size aPrefSize = maSwapInfo.maPrefSize;
+        MapMode aPrefMapMode = maSwapInfo.maPrefMapMode;
         *this = *aGraphic.ImplGetImpGraphic();
-        if (aPrefSize.getWidth() && aPrefSize.getHeight())
+        if (aPrefSize.getWidth() && aPrefSize.getHeight() && aPrefMapMode == ImplGetPrefMapMode())
         {
             // Use custom preferred size if it was set when the graphic was still unloaded.
+            // Only set the size in case the unloaded and loaded unit matches.
             ImplSetPrefSize(aPrefSize);
         }
 


More information about the Libreoffice-commits mailing list