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 b021f443eb4216dbfd42c56634a59597b246d667 Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Thu Sep 11 11:49:25 2025 +0200 Commit: Xisco Fauli <xiscofa...@libreoffice.org> CommitDate: Mon Sep 15 11:27:20 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> (cherry picked from commit 46720a15474c6c6cfbbb78ff15b446fbd004120c) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/190855 Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org> Signed-off-by: Xisco Fauli <xiscofa...@libreoffice.org> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/190869 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 6171f329a238..bbf0b8732b41 100644 --- a/sw/qa/extras/uiwriter/uiwriter9.cxx +++ b/sw/qa/extras/uiwriter/uiwriter9.cxx @@ -54,6 +54,7 @@ #include <fmtinfmt.hxx> #include <rootfrm.hxx> #include <svx/svxids.hrc> +#include <pagefrm.hxx> #include <svx/svdview.hxx> #include <svx/svdmark.hxx> @@ -1160,6 +1161,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 48050ce81213..b12b8df8658f 100644 --- a/sw/source/core/layout/trvlfrm.cxx +++ b/sw/source/core/layout/trvlfrm.cxx @@ -1894,6 +1894,30 @@ sal_uInt16 SwFrame::GetVirtPageNum() const break; } } + // 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()) + { + pFoundFrame = aHint.GetFrame(); + break; + } + } + } + pParentFrame = pParentFrame->GetUpper(); + } } pPageFrameIter = static_cast<const SwPageFrame*>(pPageFrameIter->GetPrev()); }