sw: improve test coverage of first-page header/footer

Signed-off-by: Michael Stahl <michael.stahl@collabora.com>
Change-Id: I708f06ee82a1db3cb8a43b16c03506fa2305a803
Reviewed-on: https://gerrit.collaboraoffice.com/c/online/+/4399
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Tested-by: Jenkins CPCI <releng@collaboraoffice.com>
(cherry picked from commit d67de2f005ac782a0c2413bc151d1d76fc0415c2)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/206704
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Tested-by: Jenkins
This commit is contained in:
Michael Stahl
2026-06-18 15:36:31 +02:00
committed by Xisco Fauli
parent eef163a62a
commit 6589ba5e8a
4 changed files with 34 additions and 0 deletions
+2
View File
@@ -402,7 +402,9 @@ inline constexpr TypedWhichId<SfxBoolItem> RES_RTL_GUTTER(RES_FRMATR_BEGIN + 51)
inline constexpr TypedWhichId<SfxBoolItem> RES_DECORATIVE(RES_FRMATR_BEGIN + 52);
inline constexpr TypedWhichId<SwFormatWrapTextAtFlyStart>
RES_WRAP_TEXT_AT_FLY_START(RES_FRMATR_BEGIN + 53);
/// will be used instead of header's SID_ATTR_PAGE_SIZE/RES_UL_SPACE, if there is no header
inline constexpr TypedWhichId<SfxInt32Item> RES_FRMATR_PAGE_MIN_TOP(RES_FRMATR_BEGIN + 54);
/// will be used instead of footer's SID_ATTR_PAGE_SIZE/RES_UL_SPACE, if there is no footer
inline constexpr TypedWhichId<SfxInt32Item> RES_FRMATR_PAGE_MIN_BOTTOM(RES_FRMATR_BEGIN + 55);
inline constexpr sal_uInt16 RES_FRMATR_END(RES_FRMATR_BEGIN + 56);
@@ -438,6 +438,16 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf117805)
CPPUNIT_ASSERT_EQUAL(8, getParagraphs(textbox));
}
DECLARE_OOXMLEXPORT_TEST(testFirstPageHeaderNoFooter, "firstheadernofooter.docx")
{
xmlDocUniquePtr pXmlDoc = parseLayoutDump();
assertXPath(pXmlDoc, "/root/page[1]/header", 1);
assertXPath(pXmlDoc, "/root/page[1]/footer", 0);
assertXPath(pXmlDoc, "/root/page[2]/header", 1); // TODO: should not be there!
assertXPath(pXmlDoc, "/root/page[2]/footer", 1);
}
DECLARE_OOXMLEXPORT_TEST(testTdf113183, "tdf113183.docx")
{
// The horizontal positioning of the star shape affected the positioning of
@@ -293,6 +293,17 @@ CPPUNIT_TEST_FIXTURE(Test, emptyHeaderFirstPageRtf)
uno::UNO_QUERY);
CPPUNIT_ASSERT_EQUAL(false, getProperty<bool>(xPageStyle, u"FirstIsShared"_ustr));
CPPUNIT_ASSERT_EQUAL(true, getProperty<bool>(xPageStyle, u"HeaderNoFirst"_ustr));
SwDocShell* pDocShell = getSwDocShell();
SwDoc* pDoc = pDocShell->GetDoc();
IDocumentLayoutAccess& rIDLA = pDoc->getIDocumentLayoutAccess();
SwRootFrame* pLayout = rIDLA.GetCurrentLayout();
SwPageFrame* pLastPage = pLayout->GetLastPage();
CPPUNIT_ASSERT(pLastPage->GetLower()->IsHeaderFrame());
CPPUNIT_ASSERT(pLastPage->GetLower()->GetNext()->GetNext()->IsFooterFrame());
CPPUNIT_ASSERT(!pLastPage->GetPrev()->GetLower()->IsHeaderFrame());
CPPUNIT_ASSERT(!pLastPage->GetPrev()->GetLower()->GetNext()); // no footer
}
CPPUNIT_TEST_FIXTURE(Test, emptyHeaderFirstPageDocx)
@@ -313,6 +324,17 @@ CPPUNIT_TEST_FIXTURE(Test, emptyHeaderFirstPageDocx)
uno::UNO_QUERY);
CPPUNIT_ASSERT_EQUAL(false, getProperty<bool>(xPageStyle, u"FirstIsShared"_ustr));
CPPUNIT_ASSERT_EQUAL(true, getProperty<bool>(xPageStyle, u"HeaderNoFirst"_ustr));
SwDocShell* pDocShell = getSwDocShell();
SwDoc* pDoc = pDocShell->GetDoc();
IDocumentLayoutAccess& rIDLA = pDoc->getIDocumentLayoutAccess();
SwRootFrame* pLayout = rIDLA.GetCurrentLayout();
SwPageFrame* pLastPage = pLayout->GetLastPage();
CPPUNIT_ASSERT(pLastPage->GetLower()->IsHeaderFrame());
CPPUNIT_ASSERT(pLastPage->GetLower()->GetNext()->GetNext()->IsFooterFrame());
CPPUNIT_ASSERT(!pLastPage->GetPrev()->GetLower()->IsHeaderFrame());
CPPUNIT_ASSERT(!pLastPage->GetPrev()->GetLower()->GetNext()); // no footer
}
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */