sw/qa/extras/uiwriter/data/tdf168355.odt |binary sw/qa/extras/uiwriter/uiwriter9.cxx | 18 ++++++++++++++++++ sw/source/core/layout/trvlfrm.cxx | 24 ++++++++++++++++++++++++ 3 files changed, 42 insertions(+)
New commits: commit 46720a15474c6c6cfbbb78ff15b446fbd004120c Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Thu Sep 11 11:49:25 2025 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Fri Sep 12 09:46:40 2025 +0200 tdf#168355 Page break with page style with page number in table regression from commit 7d924018f3ea58050081936bde067391714a8bb5 Author: Noel Grandin <noel.gran...@collabora.co.uk> Date: Fri Jul 19 10:44:10 2024 +0200 don't use GetItemSurrogates in SwFrame::GetVirtPageNum Change-Id: Ibdc223842013ad11b56f402571f276de38a01f6a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/190814 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/sw/qa/extras/uiwriter/data/tdf168355.odt b/sw/qa/extras/uiwriter/data/tdf168355.odt new file mode 100644 index 000000000000..bdb5a412b867 Binary files /dev/null and b/sw/qa/extras/uiwriter/data/tdf168355.odt differ diff --git a/sw/qa/extras/uiwriter/uiwriter9.cxx b/sw/qa/extras/uiwriter/uiwriter9.cxx index ebf852b7dc1b..e0bf576ac8ca 100644 --- a/sw/qa/extras/uiwriter/uiwriter9.cxx +++ b/sw/qa/extras/uiwriter/uiwriter9.cxx @@ -62,6 +62,7 @@ #include <fmtinfmt.hxx> #include <rootfrm.hxx> #include <svx/svxids.hrc> +#include <pagefrm.hxx> #include <svx/svdview.hxx> #include <svx/svdmark.hxx> @@ -1645,6 +1646,23 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest9, testTdf167006) getSwDocShell()->GetWrtShell()->LaunchOLEObj(); } +// tdf#168355 Page break with page style with page number in table properties is wrong +CPPUNIT_TEST_FIXTURE(SwUiWriterTest9, testTdf168355) +{ + createSwDoc("tdf168355.odt"); + SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get()); + CPPUNIT_ASSERT(pTextDoc); + SwDoc* pDoc = pTextDoc->GetDocShell()->GetDoc(); + const SwRootFrame* pLayout = pDoc->getIDocumentLayoutAccess().GetCurrentLayout(); + const SwPageFrame* pPageFrm = static_cast<const SwPageFrame*>(pLayout->Lower()); + CPPUNIT_ASSERT_EQUAL(sal_uInt16(1), pPageFrm->GetVirtPageNum()); + pPageFrm = static_cast<const SwPageFrame*>(pPageFrm->GetNext()); + CPPUNIT_ASSERT_EQUAL(sal_uInt16(2), pPageFrm->GetVirtPageNum()); + pPageFrm = static_cast<const SwPageFrame*>(pPageFrm->GetNext()); + // this used to be page 3 + CPPUNIT_ASSERT_EQUAL(sal_uInt16(1), pPageFrm->GetVirtPageNum()); +} + } // end of anonymous namespace CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sw/source/core/layout/trvlfrm.cxx b/sw/source/core/layout/trvlfrm.cxx index bc6db0fffd79..77aadac373f6 100644 --- a/sw/source/core/layout/trvlfrm.cxx +++ b/sw/source/core/layout/trvlfrm.cxx @@ -1888,11 +1888,35 @@ static const SwFrame* lcl_FindStartOfVirtualPages(const SwPageFrame *pPage) return aHint.GetFrame(); } } + // might have to search tables too, they may set page number in their text flow properties + const SwLayoutFrame* pParentFrame = pContentFrame->GetUpper(); + while (pParentFrame) + { + if (const SwTabFrame* pTabFrame = pParentFrame->FindTabFrame()) + if (const SwTable* pTable = pTabFrame->GetTable()) + if (const SwTableFormat* pTableFormat = pTable->GetFrameFormat()) + { + const SwFormatPageDesc& rFormatPageDesc2 = pTableFormat->GetPageDesc(); + + if ( rFormatPageDesc2.GetNumOffset() && rFormatPageDesc2.GetDefinedIn() ) + { + const sw::BroadcastingModify* pMod = rFormatPageDesc2.GetDefinedIn(); + sw::VirtPageNumHint aHint(pPage); + pMod->CallSwClientNotify(aHint); + if(aHint.GetPage()) + { + return aHint.GetFrame(); + } + } + } + pParentFrame = pParentFrame->GetUpper(); + } } pPageFrameIter = static_cast<const SwPageFrame*>(pPageFrameIter->GetPrev()); } return nullptr; } + /** @return the virtual page number with the offset. */ sal_uInt16 SwFrame::GetVirtPageNum() const {