sw/qa/extras/ww8export/data/tdf41542_imagePadding.odt |binary sw/qa/extras/ww8export/ww8export.cxx | 5 +++++ sw/source/filter/ww8/wrtw8esh.cxx | 12 +++++++----- 3 files changed, 12 insertions(+), 5 deletions(-)
New commits: commit 1f60ba36f4e2fa2785d31200b2a95226920ec298 Author: Justin Luth <justin.l...@collabora.com> AuthorDate: Tue Nov 26 09:02:55 2024 -0500 Commit: Justin Luth <justin.l...@collabora.com> CommitDate: Tue Nov 26 21:33:33 2024 +0100 tdf#147819 doc export: only ShapeFlag::Background if XATTR_FILL The mere presence of an object somewhere in the document was causing the document background to force a white color. This code was developed in the heady days of figuring out what bits meant what, so the documentation and code-reading is NOT clear. make CppunitTest_sw_ww8export \ CPPUNIT_TEST_NAME=testTdf41542_imagePadding (My ODT file had obviously spent some of its lifetime as a DOC because it had a white page background. I unzipped the file, and hand-adjusted styles.xml to set fo:background-color="transparent" and draw:fill="none") Change-Id: I41484ab7f71f4a3156e3193e49127b14e58949cc Reviewed-on: https://gerrit.libreoffice.org/c/core/+/177347 Tested-by: Jenkins Reviewed-by: Justin Luth <jl...@mail.com> diff --git a/sw/qa/extras/ww8export/data/tdf41542_imagePadding.odt b/sw/qa/extras/ww8export/data/tdf41542_imagePadding.odt index 019e19f247e1..8468e110195f 100644 Binary files a/sw/qa/extras/ww8export/data/tdf41542_imagePadding.odt and b/sw/qa/extras/ww8export/data/tdf41542_imagePadding.odt differ diff --git a/sw/qa/extras/ww8export/ww8export.cxx b/sw/qa/extras/ww8export/ww8export.cxx index c62078af50d0..acfc4b674bc5 100644 --- a/sw/qa/extras/ww8export/ww8export.cxx +++ b/sw/qa/extras/ww8export/ww8export.cxx @@ -41,6 +41,7 @@ #include <com/sun/star/text/XPageCursor.hpp> #include <config_fonts.h> +#include <editeng/brushitem.hxx> #include <editeng/ulspitem.hxx> #include <sfx2/bindings.hxx> #include <sfx2/request.hxx> @@ -995,6 +996,10 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf41542_imagePadding) CPPUNIT_ASSERT_EQUAL( crop.Left, crop.Top ); CPPUNIT_ASSERT_EQUAL( crop.Right, crop.Bottom ); CPPUNIT_ASSERT_EQUAL( crop.Left, crop.Right ); + + // tdf#147819 - page background should not be forced to white color + const SwFrameFormat &rFormat = getSwDoc()->GetPageDesc(0).GetMaster(); + CPPUNIT_ASSERT(!rFormat.GetItemIfSet(RES_BACKGROUND)); } DECLARE_WW8EXPORT_TEST(testFdo77454, "fdo77454.doc") diff --git a/sw/source/filter/ww8/wrtw8esh.cxx b/sw/source/filter/ww8/wrtw8esh.cxx index db3a6b9674a9..e0b1f250db55 100644 --- a/sw/source/filter/ww8/wrtw8esh.cxx +++ b/sw/source/filter/ww8/wrtw8esh.cxx @@ -2278,13 +2278,15 @@ SwEscherEx::SwEscherEx(SvStream* pStrm, WW8Export& rWW8Wrt) { OpenContainer( ESCHER_SpContainer ); - AddShape( ESCHER_ShpInst_Rectangle, - ShapeFlag::HaveAnchor | ShapeFlag::HaveShapeProperty | ShapeFlag::Background, - nSecondShapeId ); + const SwFrameFormat &rDefaultPageStyle = mrWrt.m_rDoc.GetPageDesc(0).GetMaster(); + const SvxBrushItem* pBrush = rDefaultPageStyle.GetItemIfSet(RES_BACKGROUND); + ShapeFlag nFlags = ShapeFlag::HaveAnchor | ShapeFlag::HaveShapeProperty; + if (pBrush) // document has background + nFlags |= ShapeFlag::Background; + AddShape(ESCHER_ShpInst_Rectangle, nFlags, nSecondShapeId); EscherPropertyContainer aPropOpt; - const SwFrameFormat &rFormat = mrWrt.m_rDoc.GetPageDesc(0).GetMaster(); - if (const SvxBrushItem* pBrush = rFormat.GetItemIfSet(RES_BACKGROUND)) + if (pBrush) { WriteBrushAttr(*pBrush, aPropOpt);