diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2020-12-21 21:03:36 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2020-12-22 09:07:27 +0100 |
commit | c24d9447b809416575972585a5ad48e14f8d9ad9 (patch) | |
tree | 513939af51445da6058333f907096547c27e2ae3 /vcl/qa | |
parent | db866805f3eee3a15bc96ffb5ba16aa77a02ddbd (diff) |
tdf#138801 vcl: fix lazy-loading of GIF images with logic size
Regression from commit edda1e5fc8113aa4744e32f97c96a3cc311485ca (DOCX
import: lazy-read images without external headers, 2018-04-20), the
immediate problem is that GIF images from docx are now lazy-loaded.
The deeper problem is that GIF images normally only have pixel size and
can have an optional logic size as well (LO-specific extension).
The bugdoc in question is a DOCX file, which contains a .png stream,
which is in fact a GIF image, with that STARDIV extension in it.
Now the initial parsing (that only extracts the metadata) didn't read
the logic size, so the preferred map mode was pixels, but later when the
actual read happened, the preferred map mode changed to mm100.
Thid does not play nicely with writerfilter/ code that sets a different
wrap polygon depending on if the (assumed to be final) map mode is
pixels or not.
Fix the problem by reusing the "is this an animation" GIF parser to also
extract the logic size of the GIF image, if it has one. This way we
still lazy-load the GIF image, but the preferred map mode won't hange
from pixels to mm100 during the real read.
Change-Id: Ia6c66e1c4fa0cb23a1daf537e7179b081ef90def
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/108125
Tested-by: Jenkins
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'vcl/qa')
-rw-r--r-- | vcl/qa/cppunit/filter/igif/data/logic-lazy-read.gif | bin | 0 -> 1258 bytes | |||
-rw-r--r-- | vcl/qa/cppunit/filter/igif/igif.cxx | 47 |
2 files changed, 47 insertions, 0 deletions
diff --git a/vcl/qa/cppunit/filter/igif/data/logic-lazy-read.gif b/vcl/qa/cppunit/filter/igif/data/logic-lazy-read.gif Binary files differnew file mode 100644 index 000000000000..3d18891f7b6a --- /dev/null +++ b/vcl/qa/cppunit/filter/igif/data/logic-lazy-read.gif diff --git a/vcl/qa/cppunit/filter/igif/igif.cxx b/vcl/qa/cppunit/filter/igif/igif.cxx new file mode 100644 index 000000000000..8dea02ca529b --- /dev/null +++ b/vcl/qa/cppunit/filter/igif/igif.cxx @@ -0,0 +1,47 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include <sal/config.h> + +#include <test/bootstrapfixture.hxx> + +#include <tools/stream.hxx> +#include <unotest/directories.hxx> +#include <vcl/graph.hxx> +#include <vcl/graphicfilter.hxx> + +using namespace com::sun::star; + +namespace +{ +char const DATA_DIRECTORY[] = "/vcl/qa/cppunit/filter/igif/data/"; + +/// Covers vcl/source/filter/igif/ fixes. +class Test : public test::BootstrapFixture +{ +}; + +CPPUNIT_TEST_FIXTURE(Test, testLogicLazyRead) +{ + GraphicFilter aGraphicFilter; + test::Directories aDirectories; + OUString aURL = aDirectories.getURLFromSrc(DATA_DIRECTORY) + "logic-lazy-read.gif"; + SvFileStream aStream(aURL, StreamMode::READ); + Graphic aGraphic = aGraphicFilter.ImportUnloadedGraphic(aStream); + // Without the accompanying fix in place, this test would have failed with: + // - Expected: 0 + // - Actual : 10 + // i.e. the preferred unit was pixels, not mm100. + CPPUNIT_ASSERT_EQUAL(MapUnit::Map100thMM, aGraphic.GetPrefMapMode().GetMapUnit()); +} +} + +CPPUNIT_PLUGIN_IMPLEMENT(); + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |