From 15d3a3864879ff405c3f50003571989088be54c3 Mon Sep 17 00:00:00 2001 From: Justin Luth Date: Fri, 31 Jul 2020 13:42:20 +0300 Subject: tdf#135338 sw layout: show FirstLeft on very first left page style. Although extremely unlikely, the Left Page style can have a different Left and FirstLeft. In the even more unlikely case that the document starts off using a left-page-only style, then the first header would not show on the first page, but only on all of the following left-only pages. So, of course, we want the very first visible page in the document to show the defined First header/footer. Change-Id: I7e74fdc085509fb8d6b80f36d1402309b9db9404 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/99862 Tested-by: Jenkins Reviewed-by: Justin Luth --- .../odfexport/data/tdf135338_firstLeftPageFooter.odt | Bin 0 -> 10687 bytes sw/qa/extras/odfexport/odfexport.cxx | 7 +++++++ sw/source/core/inc/frmtool.hxx | 2 +- sw/source/core/layout/frmtool.cxx | 5 +++-- sw/source/core/layout/newfrm.cxx | 2 +- 5 files changed, 12 insertions(+), 4 deletions(-) create mode 100644 sw/qa/extras/odfexport/data/tdf135338_firstLeftPageFooter.odt diff --git a/sw/qa/extras/odfexport/data/tdf135338_firstLeftPageFooter.odt b/sw/qa/extras/odfexport/data/tdf135338_firstLeftPageFooter.odt new file mode 100644 index 000000000000..4f9808875812 Binary files /dev/null and b/sw/qa/extras/odfexport/data/tdf135338_firstLeftPageFooter.odt differ diff --git a/sw/qa/extras/odfexport/odfexport.cxx b/sw/qa/extras/odfexport/odfexport.cxx index f74980ebc51b..e28ae2515f0b 100644 --- a/sw/qa/extras/odfexport/odfexport.cxx +++ b/sw/qa/extras/odfexport/odfexport.cxx @@ -1666,6 +1666,13 @@ DECLARE_ODFEXPORT_TEST(testTdf118393, "tdf118393.odt") CPPUNIT_ASSERT_EQUAL(OUString("Seite * von *"), parseDump("/root/page[7]/footer/txt/text()")); } +DECLARE_ODFEXPORT_TEST(testTdf135338_firstLeftPageFooter, "tdf135338_firstLeftPageFooter.odt") +{ + // The first page is a left page only style, but it should still show the first page footer + // instead of the left footer text "EVEN/LEFT (Left page only)" + CPPUNIT_ASSERT_EQUAL(OUString("First (Left page only)"), parseDump("/root/page[2]/footer/txt/text()")); +} + DECLARE_ODFEXPORT_TEST(testGerrit13858, "gerrit13858.odt") { CPPUNIT_ASSERT_EQUAL(1, getShapes()); diff --git a/sw/source/core/inc/frmtool.hxx b/sw/source/core/inc/frmtool.hxx index 9710bfab7cc1..027fd6b6461d 100644 --- a/sw/source/core/inc/frmtool.hxx +++ b/sw/source/core/inc/frmtool.hxx @@ -167,7 +167,7 @@ bool IsRightPageByNumber(SwRootFrame const& rLayout, sal_uInt16 nPageNum); SwPageFrame *InsertNewPage( SwPageDesc &rDesc, SwFrame *pUpper, bool isRightPage, bool bFirst, bool bInsertEmpty, bool bFootnote, - SwFrame *pSibling ); + SwFrame *pSibling, bool bVeryFirstPage = false ); // connect Flys with page void RegistFlys( SwPageFrame*, const SwLayoutFrame* ); diff --git a/sw/source/core/layout/frmtool.cxx b/sw/source/core/layout/frmtool.cxx index 0ade3a3315ed..1cadf5f06aec 100644 --- a/sw/source/core/layout/frmtool.cxx +++ b/sw/source/core/layout/frmtool.cxx @@ -2998,7 +2998,8 @@ bool IsRightPageByNumber(SwRootFrame const& rLayout, sal_uInt16 const nPageNum) SwPageFrame * InsertNewPage( SwPageDesc &rDesc, SwFrame *pUpper, bool const isRightPage, bool const bFirst, bool bInsertEmpty, bool const bFootnote, - SwFrame *pSibling ) + SwFrame *pSibling, + bool const bVeryFirstPage ) { assert(pUpper); assert(pUpper->IsRootFrame()); @@ -3030,7 +3031,7 @@ SwPageFrame * InsertNewPage( SwPageDesc &rDesc, SwFrame *pUpper, // If there is no FrameFormat for this page, add an empty page if ( !pFormat ) { - pFormat = isRightPage ? rDesc.GetLeftFormat() : rDesc.GetRightFormat(); + pFormat = isRightPage ? rDesc.GetLeftFormat(bVeryFirstPage) : rDesc.GetRightFormat(bVeryFirstPage); OSL_ENSURE( pFormat, "Descriptor without any format?!" ); bInsertEmpty = !bInsertEmpty; } diff --git a/sw/source/core/layout/newfrm.cxx b/sw/source/core/layout/newfrm.cxx index 07ba49b7b626..a24a23bc9f30 100644 --- a/sw/source/core/layout/newfrm.cxx +++ b/sw/source/core/layout/newfrm.cxx @@ -488,7 +488,7 @@ void SwRootFrame::Init( SwFrameFormat* pFormat ) // Create a page and put it in the layout // The first page is always a right-page and always a first-page - SwPageFrame *pPage = ::InsertNewPage(*pDesc, this, true, true, false, false, nullptr); + SwPageFrame *pPage = ::InsertNewPage(*pDesc, this, true, true, false, false, nullptr, true); // Find the first page in the Bodytext section. SwLayoutFrame *pLay = pPage->FindBodyCont(); -- cgit