[Libreoffice-commits] core.git: Branch 'libreoffice-6-4' - vcl/qa vcl/source
Miklos Vajna (via logerrit)
logerrit at kemper.freedesktop.org
Tue Nov 19 09:20:49 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 c1e207afd82c587c977d3497c466a82b2628cb7b
Author: Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Mon Nov 18 21:18:24 2019 +0100
Commit: Miklos Vajna <vmiklos at collabora.com>
CommitDate: Tue Nov 19 10:20:12 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>
diff --git a/vcl/qa/cppunit/GraphicTest.cxx b/vcl/qa/cppunit/GraphicTest.cxx
index 56e05c8bf3de..e67ba6ff7ee7 100644
--- a/vcl/qa/cppunit/GraphicTest.cxx
+++ b/vcl/qa/cppunit/GraphicTest.cxx
@@ -18,6 +18,7 @@
#include <vcl/graph.hxx>
#include <vcl/graphicfilter.hxx>
#include <tools/stream.hxx>
+#include <unotest/directories.hxx>
using namespace css;
@@ -29,12 +30,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();
};
@@ -79,6 +82,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
@@ -194,6 +199,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 824caae1698f..280ad3c2f1cd 100644
--- a/vcl/source/gdi/impgraph.cxx
+++ b/vcl/source/gdi/impgraph.cxx
@@ -1570,10 +1570,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