diff options
-rw-r--r-- | vcl/CppunitTest_vcl_filter_igif.mk | 46 | ||||
-rw-r--r-- | vcl/Module_vcl.mk | 1 | ||||
-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 | ||||
-rw-r--r-- | vcl/source/filter/graphicfilter.cxx | 7 | ||||
-rw-r--r-- | vcl/source/filter/igif/gifread.cxx | 10 | ||||
-rw-r--r-- | vcl/source/filter/igif/gifread.hxx | 2 |
7 files changed, 110 insertions, 3 deletions
diff --git a/vcl/CppunitTest_vcl_filter_igif.mk b/vcl/CppunitTest_vcl_filter_igif.mk new file mode 100644 index 000000000000..c6b6759899b0 --- /dev/null +++ b/vcl/CppunitTest_vcl_filter_igif.mk @@ -0,0 +1,46 @@ +# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- +#************************************************************************* +# +# 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/. +# +#************************************************************************* + +$(eval $(call gb_CppunitTest_CppunitTest,vcl_filter_igif)) + +$(eval $(call gb_CppunitTest_use_externals,vcl_filter_igif,\ + boost_headers \ +)) + +$(eval $(call gb_CppunitTest_add_exception_objects,vcl_filter_igif, \ + vcl/qa/cppunit/filter/igif/igif \ +)) + +$(eval $(call gb_CppunitTest_use_libraries,vcl_filter_igif, \ + comphelper \ + cppu \ + sal \ + test \ + tl \ + unotest \ + utl \ + vcl \ +)) + +$(eval $(call gb_CppunitTest_use_sdk_api,vcl_filter_igif)) + +$(eval $(call gb_CppunitTest_use_ure,vcl_filter_igif)) +$(eval $(call gb_CppunitTest_use_vcl,vcl_filter_igif)) + +$(eval $(call gb_CppunitTest_use_rdb,vcl_filter_igif,services)) + +$(eval $(call gb_CppunitTest_use_custom_headers,vcl_filter_igif,\ + officecfg/registry \ +)) + +$(eval $(call gb_CppunitTest_use_configuration,vcl_filter_igif)) + +# vim: set noet sw=4 ts=4: diff --git a/vcl/Module_vcl.mk b/vcl/Module_vcl.mk index 8bfc67c1e2ef..3a3626157b1f 100644 --- a/vcl/Module_vcl.mk +++ b/vcl/Module_vcl.mk @@ -211,6 +211,7 @@ $(eval $(call gb_Module_add_check_targets,vcl,\ CppunitTest_vcl_pdfium_library_test) \ $(if $(filter SKIA,$(BUILD_TYPE)), \ CppunitTest_vcl_skia) \ + CppunitTest_vcl_filter_igif \ )) ifeq ($(USING_X11),TRUE) 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: */ diff --git a/vcl/source/filter/graphicfilter.cxx b/vcl/source/filter/graphicfilter.cxx index 4d0c4cbd9cc1..65ae12a65931 100644 --- a/vcl/source/filter/graphicfilter.cxx +++ b/vcl/source/filter/graphicfilter.cxx @@ -1403,10 +1403,15 @@ Graphic GraphicFilter::ImportUnloadedGraphic(SvStream& rIStream, sal_uInt64 size if( nStatus == ERRCODE_NONE ) { bool bAnimated = false; + Size aLogicSize; if (eLinkType == GfxLinkType::NativeGif) { SvMemoryStream aMemoryStream(pGraphicContent.get(), nGraphicContentSize, StreamMode::READ); - bAnimated = IsGIFAnimated(aMemoryStream); + bAnimated = IsGIFAnimated(aMemoryStream, aLogicSize); + if (!pSizeHint && aLogicSize.getWidth() && aLogicSize.getHeight()) + { + pSizeHint = &aLogicSize; + } } aGraphic.SetGfxLink(std::make_shared<GfxLink>(std::move(pGraphicContent), nGraphicContentSize, eLinkType)); aGraphic.ImplGetImpGraphic()->ImplSetPrepared(bAnimated, pSizeHint); diff --git a/vcl/source/filter/igif/gifread.cxx b/vcl/source/filter/igif/gifread.cxx index 7751cc359f85..180e9d6fa1e2 100644 --- a/vcl/source/filter/igif/gifread.cxx +++ b/vcl/source/filter/igif/gifread.cxx @@ -115,6 +115,7 @@ public: ReadState ReadGIF( Graphic& rGraphic ); bool ReadIsAnimated(); + void GetLogicSize(Size& rLogicSize); Graphic GetIntermediateGraphic(); explicit GIFReader( SvStream& rStm ); @@ -910,6 +911,12 @@ bool GIFReader::ReadIsAnimated() return false; } +void GIFReader::GetLogicSize(Size& rLogicSize) +{ + rLogicSize.setWidth(nLogWidth100); + rLogicSize.setHeight(nLogHeight100); +} + ReadState GIFReader::ReadGIF( Graphic& rGraphic ) { ReadState eReadState; @@ -946,13 +953,14 @@ ReadState GIFReader::ReadGIF( Graphic& rGraphic ) return eReadState; } -bool IsGIFAnimated(SvStream & rStm) +bool IsGIFAnimated(SvStream & rStm, Size& rLogicSize) { GIFReader aReader(rStm); SvStreamEndian nOldFormat = rStm.GetEndian(); rStm.SetEndian(SvStreamEndian::LITTLE); bool bResult = aReader.ReadIsAnimated(); + aReader.GetLogicSize(rLogicSize); rStm.SetEndian(nOldFormat); return bResult; diff --git a/vcl/source/filter/igif/gifread.hxx b/vcl/source/filter/igif/gifread.hxx index def223483883..de9a506f24b9 100644 --- a/vcl/source/filter/igif/gifread.hxx +++ b/vcl/source/filter/igif/gifread.hxx @@ -23,7 +23,7 @@ #include <vcl/graph.hxx> VCL_DLLPUBLIC bool ImportGIF(SvStream& rStream, Graphic& rGraphic); -bool IsGIFAnimated(SvStream& rStream); +bool IsGIFAnimated(SvStream& rStream, Size& rLogicSize); #endif // INCLUDED_VCL_SOURCE_FILTER_IGIF_GIFREAD_HXX |