[Libreoffice-commits] core.git: Branch 'libreoffice-6-3' - vcl/CppunitTest_vcl_graphic_test.mk vcl/qa vcl/source
Miklos Vajna (via logerrit)
logerrit at kemper.freedesktop.org
Tue Oct 1 17:48:22 UTC 2019
vcl/CppunitTest_vcl_graphic_test.mk | 2 ++
vcl/qa/cppunit/GraphicTest.cxx | 27 +++++++++++++++++++++++++++
vcl/source/gdi/impgraph.cxx | 8 ++++++++
3 files changed, 37 insertions(+)
New commits:
commit d8371cdfd092c6426c01aae130ea4eaa6d627a6f
Author: Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Mon Sep 30 21:36:56 2019 +0200
Commit: Miklos Vajna <vmiklos at collabora.com>
CommitDate: Tue Oct 1 19:47:39 2019 +0200
tdf#127446 vcl image lazy-load: fix custom size handling of metafiles
This is a regression from commit
acb803b730f2c6bd82e39beab58949ec14f85eb0 (tdf#125591 DOC import:
lazy-load metafiles with explicit size, 2019-06-11), which assumed that
once maSwapInfo.maPrefSize stores the preferred size, it'll be set on
the Graphic when it's loaded later.
It seems there was no support for that, it was just an accident that the
guessed size of the metafile was about right.
Handle this explicitly in ImpGraphic::loadPrepared(), so that the bugdoc
(which has a custom preferred size) aspect ratio is correct.
(cherry picked from commit 12273af6f18edade1bdda828fe270fa37960e14f)
Change-Id: Ic7c4009ad6723a2e16129d27600c904311ff3daf
Reviewed-on: https://gerrit.libreoffice.org/79913
Reviewed-by: Michael Stahl <michael.stahl at cib.de>
Tested-by: Jenkins
diff --git a/vcl/CppunitTest_vcl_graphic_test.mk b/vcl/CppunitTest_vcl_graphic_test.mk
index d339cd22a5cb..fd5c7aeb039b 100644
--- a/vcl/CppunitTest_vcl_graphic_test.mk
+++ b/vcl/CppunitTest_vcl_graphic_test.mk
@@ -48,6 +48,8 @@ $(eval $(call gb_CppunitTest_use_components,vcl_graphic_test,\
i18npool/util/i18npool \
ucb/source/core/ucb1 \
unotools/util/utl \
+ emfio/emfio \
+ drawinglayer/drawinglayer \
))
$(eval $(call gb_CppunitTest_use_configuration,vcl_graphic_test))
diff --git a/vcl/qa/cppunit/GraphicTest.cxx b/vcl/qa/cppunit/GraphicTest.cxx
index 3e13a1083ce5..d094da3ca957 100644
--- a/vcl/qa/cppunit/GraphicTest.cxx
+++ b/vcl/qa/cppunit/GraphicTest.cxx
@@ -28,10 +28,12 @@ class GraphicTest : public CppUnit::TestFixture
{
void testUnloadedGraphic();
void testUnloadedGraphicLoading();
+ void testUnloadedGraphicWmf();
CPPUNIT_TEST_SUITE(GraphicTest);
CPPUNIT_TEST(testUnloadedGraphic);
CPPUNIT_TEST(testUnloadedGraphicLoading);
+ CPPUNIT_TEST(testUnloadedGraphicWmf);
CPPUNIT_TEST_SUITE_END();
};
@@ -131,6 +133,31 @@ void GraphicTest::testUnloadedGraphicLoading()
}
}
+void GraphicTest::testUnloadedGraphicWmf()
+{
+ // Create some in-memory WMF data, set its own preferred size to 99x99.
+ BitmapEx aBitmapEx = createBitmap();
+ SvMemoryStream aStream;
+ GraphicFilter& rGraphicFilter = GraphicFilter::GetGraphicFilter();
+ sal_uInt16 nFilterFormat = rGraphicFilter.GetExportFormatNumberForShortName("wmf");
+ Graphic aGraphic(aBitmapEx);
+ aGraphic.SetPrefSize(Size(99, 99));
+ aGraphic.SetPrefMapMode(MapMode(MapUnit::Map100thMM));
+ rGraphicFilter.ExportGraphic(aGraphic, "none", aStream, nFilterFormat);
+ aStream.Seek(STREAM_SEEK_TO_BEGIN);
+
+ // Now lazy-load this WMF data, with a custom preferred size of 42x42.
+ Size aMtfSize100(42, 42);
+ aGraphic = rGraphicFilter.ImportUnloadedGraphic(aStream, 0, &aMtfSize100);
+ aGraphic.makeAvailable();
+
+ // Without the accompanying fix in place, this test would have failed with:
+ // - Expected: 42x42
+ // - Actual : 99x99
+ // i.e. we the custom preferred size was lost after lazy-load.
+ CPPUNIT_ASSERT_EQUAL(Size(42, 42), aGraphic.GetPrefSize());
+}
+
} // namespace
CPPUNIT_TEST_SUITE_REGISTRATION(GraphicTest);
diff --git a/vcl/source/gdi/impgraph.cxx b/vcl/source/gdi/impgraph.cxx
index 195e40d1a45a..0a7228268876 100644
--- a/vcl/source/gdi/impgraph.cxx
+++ b/vcl/source/gdi/impgraph.cxx
@@ -1549,7 +1549,15 @@ bool ImpGraphic::loadPrepared()
if (mpGfxLink->LoadNative(aGraphic))
{
GraphicExternalLink aLink = maGraphicExternalLink;
+
+ Size aPrefSize = maSwapInfo.maPrefSize;
*this = *aGraphic.ImplGetImpGraphic();
+ if (aPrefSize.getWidth() && aPrefSize.getHeight())
+ {
+ // Use custom preferred size if it was set when the graphic was still unloaded.
+ ImplSetPrefSize(aPrefSize);
+ }
+
maGraphicExternalLink = aLink;
return true;
More information about the Libreoffice-commits
mailing list