sw/qa/extras/ooxmlexport/data/tdf159158_zOrder_headerBehind2.docx |binary sw/qa/extras/ooxmlexport/ooxmlexport18.cxx | 17 ++++++++++ writerfilter/source/dmapper/GraphicImport.cxx | 4 +- 3 files changed, 19 insertions(+), 2 deletions(-)
New commits: commit c4c5937a98572630915de497b3138164b12079e3 Author: Justin Luth <justin.l...@collabora.com> AuthorDate: Wed Feb 28 14:18:44 2024 -0500 Commit: Justin Luth <jl...@mail.com> CommitDate: Fri Mar 1 01:38:13 2024 +0100 tdf#159158 writerfilter: headers always behind text (!opaque) If the body-anchored thing is in the background, then if any header stuff was NOT in the background, then it would show up above the body thing, and that should not happen in a DOCX world. This test was not easy to produce. ODT kind of knows that headers are special, and so it tries really hard to put stuff in the background without any wrap - at least after a round-trip. So I had to hand-craft from my example DOCX that exhibited a behindDoc which actually had some wrapping component to it. make CppunitTest_sw_ooxmlexport18 \ CPPUNIT_TEST_NAME=testTdf159158_zOrder_headerBehind2 Change-Id: I31617cd7bf2d38add2233a7a06ffe9a8ec00ec0a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164130 Tested-by: Jenkins Reviewed-by: Justin Luth <jl...@mail.com> diff --git a/sw/qa/extras/ooxmlexport/data/tdf159158_zOrder_headerBehind2.docx b/sw/qa/extras/ooxmlexport/data/tdf159158_zOrder_headerBehind2.docx new file mode 100644 index 000000000000..e787b9c2605d Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf159158_zOrder_headerBehind2.docx differ diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx index 91fa26ea0a47..cb41f033730d 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx @@ -1047,6 +1047,23 @@ DECLARE_OOXMLEXPORT_TEST(testTdf159158_zOrder_headerBehind, "tdf159158_zOrder_he CPPUNIT_ASSERT_EQUAL(OUString("RectangleInBody"), getProperty<OUString>(zOrder1,"Name")); } +DECLARE_OOXMLEXPORT_TEST(testTdf159158_zOrder_headerBehind2, "tdf159158_zOrder_headerBehind2.docx") +{ + // given a logo (marked as behind text) anchored in the header + // and an overlapping blue rectangle anchored in the body text. + uno::Reference<beans::XPropertySet> zOrder0(getShape(1), uno::UNO_QUERY); + uno::Reference<beans::XPropertySet> zOrder1(getShape(2), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(zOrder0, "ZOrder")); // lower + CPPUNIT_ASSERT_EQUAL(sal_Int32(1), getProperty<sal_Int32>(zOrder1, "ZOrder")); // higher + CPPUNIT_ASSERT_EQUAL(OUString("HeaderImage"), + getProperty<OUString>(zOrder0, "LinkDisplayName")); + CPPUNIT_ASSERT_EQUAL(OUString("BodyBlueRectangle"), + getProperty<OUString>(zOrder1,"LinkDisplayName")); + // The logo should not be opaque since it is in the header. + CPPUNIT_ASSERT(!getProperty<bool>(zOrder0, "Opaque")); // logo should be invisible + CPPUNIT_ASSERT(!getProperty<bool>(zOrder1, "Opaque")); +} + DECLARE_OOXMLEXPORT_TEST(testTdf155903, "tdf155903.odt") { // Without the accompanying fix in place, this test would have crashed, diff --git a/writerfilter/source/dmapper/GraphicImport.cxx b/writerfilter/source/dmapper/GraphicImport.cxx index 386ac693d81b..f64bef09e958 100644 --- a/writerfilter/source/dmapper/GraphicImport.cxx +++ b/writerfilter/source/dmapper/GraphicImport.cxx @@ -1602,7 +1602,7 @@ void GraphicImport::lcl_sprm(Sprm& rSprm) { // tdf#137850: Word >= 2013 seems to ignore bBehindDoc except for wrapNone, but older versions honour it. if (m_pImpl->m_bBehindDoc && m_pImpl->m_rDomainMapper.GetSettingsTable()->GetWordCompatibilityMode() > 14) - m_pImpl->m_bOpaque = true; + m_pImpl->m_bOpaque = !m_pImpl->m_rDomainMapper.IsInHeaderFooter(); } break; } @@ -1720,7 +1720,7 @@ void GraphicImport::lcl_sprm(Sprm& rSprm) case NS_ooxml::LN_EG_WrapType_wrapTopAndBottom: // tdf#137850: Word >= 2013 seems to ignore bBehindDoc except for wrapNone, but older versions honour it. if (m_pImpl->m_bBehindDoc && m_pImpl->m_rDomainMapper.GetSettingsTable()->GetWordCompatibilityMode() > 14) - m_pImpl->m_bOpaque = true; + m_pImpl->m_bOpaque = !m_pImpl->m_rDomainMapper.IsInHeaderFooter(); m_pImpl->m_nWrap = text::WrapTextMode_NONE; break; case NS_ooxml::LN_CT_GraphicalObject_graphicData: