diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2019-05-27 21:24:42 +0200 |
---|---|---|
committer | Xisco FaulĂ <xiscofauli@libreoffice.org> | 2019-06-13 18:27:50 +0200 |
commit | e6f0794be0bfaa55c992758a38444e1bcc481c45 (patch) | |
tree | 8dd06f951ae10f19cce7161c0f1f4e3d9e9c95a5 | |
parent | d0b03870b7eb67a5a4f4981c1e104ca03bd6e993 (diff) |
tdf#125281 DOC import: fix size of lazy-loaded metafiles
Metafiles may have an external header, so once graphic data is read, we
need to set the size explicitly. Otherwise the width of the EMF image in
the bugdoc will be too small.
(cherry picked from commit 69b62cfcbd364d7f62142149c2f690104b217ca1)
Conflicts:
filter/source/msfilter/msdffimp.cxx
sw/qa/extras/ww8import/ww8import.cxx
Change-Id: I2441eda61278b0f4973db5d9aa14618ccd17c397
Reviewed-on: https://gerrit.libreoffice.org/73180
Tested-by: Jenkins
Reviewed-by: Xisco FaulĂ <xiscofauli@libreoffice.org>
-rw-r--r-- | filter/source/msfilter/msdffimp.cxx | 5 | ||||
-rw-r--r-- | sw/CppunitTest_sw_ww8import.mk | 30 | ||||
-rw-r--r-- | sw/qa/extras/ww8import/data/tdf125281.doc | bin | 0 -> 82432 bytes | |||
-rw-r--r-- | sw/qa/extras/ww8import/ww8import.cxx | 17 |
4 files changed, 23 insertions, 29 deletions
diff --git a/filter/source/msfilter/msdffimp.cxx b/filter/source/msfilter/msdffimp.cxx index c9087180ecdf..b6898f1478fb 100644 --- a/filter/source/msfilter/msdffimp.cxx +++ b/filter/source/msfilter/msdffimp.cxx @@ -6558,6 +6558,11 @@ bool SvxMSDffManager::GetBLIPDirect( SvStream& rBLIPStream, Graphic& rData, tool // size to the size of this record. sal_uInt64 maxSize = pGrStream == &rBLIPStream ? nLength : 0; Graphic aGraphic = rGF.ImportUnloadedGraphic(*pGrStream, maxSize); + + // Size available in metafile header, set that here. + if (aMtfSize100.getWidth() && aMtfSize100.getHeight()) + aGraphic.SetPrefSize(aMtfSize100); + if (aGraphic) { rData = aGraphic; diff --git a/sw/CppunitTest_sw_ww8import.mk b/sw/CppunitTest_sw_ww8import.mk index 1ccc1a3f20aa..932878b0e557 100644 --- a/sw/CppunitTest_sw_ww8import.mk +++ b/sw/CppunitTest_sw_ww8import.mk @@ -50,35 +50,7 @@ $(eval $(call gb_CppunitTest_use_api,sw_ww8import,\ $(eval $(call gb_CppunitTest_use_ure,sw_ww8import)) $(eval $(call gb_CppunitTest_use_vcl,sw_ww8import)) -$(eval $(call gb_CppunitTest_use_components,sw_ww8import,\ - basic/util/sb \ - comphelper/util/comphelp \ - configmgr/source/configmgr \ - dbaccess/util/dba \ - filter/source/config/cache/filterconfig1 \ - forms/util/frm \ - framework/util/fwk \ - i18npool/util/i18npool \ - linguistic/source/lng \ - package/util/package2 \ - package/source/xstor/xstor \ - sw/util/msword \ - sw/util/sw \ - sw/util/swd \ - sfx2/util/sfx \ - svl/source/fsstor/fsstorage \ - svtools/util/svt \ - toolkit/util/tk \ - ucb/source/core/ucb1 \ - ucb/source/ucp/file/ucpfile1 \ - ucb/source/ucp/tdoc/ucptdoc1 \ - unotools/util/utl \ - unoxml/source/rdf/unordf \ - unoxml/source/service/unoxml \ - uui/util/uui \ - vcl/vcl.common \ - $(if $(filter DESKTOP,$(BUILD_TYPE)),xmlhelp/util/ucpchelp1) \ -)) +$(eval $(call gb_CppunitTest_use_rdb,sw_ww8import,services)) $(eval $(call gb_CppunitTest_use_configuration,sw_ww8import)) diff --git a/sw/qa/extras/ww8import/data/tdf125281.doc b/sw/qa/extras/ww8import/data/tdf125281.doc Binary files differnew file mode 100644 index 000000000000..15146f9e3daf --- /dev/null +++ b/sw/qa/extras/ww8import/data/tdf125281.doc diff --git a/sw/qa/extras/ww8import/ww8import.cxx b/sw/qa/extras/ww8import/ww8import.cxx index 09e3a1752504..fdc816088f62 100644 --- a/sw/qa/extras/ww8import/ww8import.cxx +++ b/sw/qa/extras/ww8import/ww8import.cxx @@ -14,6 +14,7 @@ #include <ndtxt.hxx> #include <viscrs.hxx> #include <wrtsh.hxx> +#include <ndgrf.hxx> #include <sfx2/docfile.hxx> #include <sfx2/docfilt.hxx> @@ -161,6 +162,22 @@ DECLARE_WW8IMPORT_TEST(testTdf112346, "tdf112346.doc") CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0), xDrawPage->getCount()); } +DECLARE_WW8IMPORT_TEST(testTdf125281, "tdf125281.doc") +{ + // Load a .doc file which has an embedded .emf image. + SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get()); + SwDoc* pDoc = pTextDoc->GetDocShell()->GetDoc(); + SwNode* pNode = pDoc->GetNodes()[6]; + CPPUNIT_ASSERT(pNode->IsGrfNode()); + SwGrfNode* pGrfNode = pNode->GetGrfNode(); + const Graphic& rGraphic = pGrfNode->GetGrf(); + + // Without the accompanying fix in place, this test would have failed, as pref size was 0 till + // an actual Paint() was performed (and even then, it was wrong). + long nExpected = 25664; + CPPUNIT_ASSERT_EQUAL(nExpected, rGraphic.GetPrefSize().getWidth()); +} + DECLARE_WW8IMPORT_TEST(testTdf110987, "tdf110987") { // The input document is an empty .doc, but without file name |