sw/source/uibase/shells/textfld.cxx | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-)
New commits: commit 5dc309ffa947d8eb79ac7392f9fbd79a78f5bc2e Author: Justin Luth <[email protected]> AuthorDate: Mon Sep 1 15:51:52 2025 -0400 Commit: Noel Grandin <[email protected]> CommitDate: Wed Sep 3 21:39:45 2025 +0200 tdf#165852 Revert "simplify bookmark name calculation" This reverts 25.2 commit 0c6599ca14ff4ff63224a7e34e93eb30e1ce2adc, and commit bcf4b998741da342d8612dfa2ac8b9d5d95269d4. because rSh.SetCursorInHdFt can move to a different page/footer and thus rSh.GetVirtPageNum() will change value on even and odd footers. Change-Id: I2d29e5c9f7538c47c6e11c8e7432f5f8d880bf72 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/190507 Tested-by: Jenkins Reviewed-by: Justin Luth <[email protected]> (cherry picked from commit e16da933cdfe52382274bb9493bcaa12f85d6426) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/190508 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/190526 Reviewed-by: Noel Grandin <[email protected]> diff --git a/sw/source/uibase/shells/textfld.cxx b/sw/source/uibase/shells/textfld.cxx index a3d67d44b073..9be55f6dc716 100644 --- a/sw/source/uibase/shells/textfld.cxx +++ b/sw/source/uibase/shells/textfld.cxx @@ -1133,14 +1133,14 @@ FIELD_INSERT: const bool bFooterAlreadyOn = rDesc.GetMaster().GetFooter().IsActive(); const bool bIsSinglePage = rDesc.GetFollow() != &rDesc; const size_t nMirrorPagesNeeded = rDesc.IsFirstShared() ? 2 : 3; - const OUString sBookmarkName = OUString::Concat("PageNumWizard_") - + (bHeader ? "HEADER" : "FOOTER") + "_" + rDesc.GetName() - + OUString::number(rSh.GetVirtPageNum()); + const OUString sBookmarkName(OUString::Concat("PageNumWizard_") + + (bHeader ? "HEADER" : "FOOTER") + "_" + rDesc.GetName()); IDocumentMarkAccess& rIDMA = *rSh.getIDocumentMarkAccess(); // Allow wizard to be re-run: delete previously wizard-inserted page number. // Try before creating non-shared header: avoid copying ODD bookmark onto EVEN page. - auto ppMark = rIDMA.findMark(sBookmarkName); + OUString sBookmarkOddPage(sBookmarkName + OUString::number(rSh.GetVirtPageNum())); + auto ppMark = rIDMA.findMark(sBookmarkOddPage); if (ppMark != rIDMA.getAllMarksEnd() && *ppMark) { SwPaM aDeleteOldPageNum((*ppMark)->GetMarkStart(), (*ppMark)->GetMarkEnd()); @@ -1331,7 +1331,9 @@ FIELD_INSERT: // Allow wizard to be re-run: delete previously wizard-inserted page number. // Now that the cursor may have moved to a different page, try delete again. - ppMark = rIDMA.findMark(sBookmarkName); + sBookmarkOddPage + = sBookmarkName + OUString::number(rSh.GetVirtPageNum()); + ppMark = rIDMA.findMark(sBookmarkOddPage); if (ppMark != rIDMA.getAllMarksEnd() && *ppMark) { SwPaM aDeleteOldPageNum((*ppMark)->GetMarkStart(), (*ppMark)->GetMarkEnd()); @@ -1396,8 +1398,8 @@ FIELD_INSERT: aNewBookmarkPaM.SetMark(); assert(aNewBookmarkPaM.GetPointContentNode() && "only SetContent on content node"); aNewBookmarkPaM.Start()->SetContent(nStartContentIndex); - sw::mark::MarkBase* pNewMark = rIDMA.makeMark(aNewBookmarkPaM, - sBookmarkName, + rIDMA.makeMark(aNewBookmarkPaM, + sBookmarkOddPage, IDocumentMarkAccess::MarkType::BOOKMARK, sw::mark::InsertMode::New); @@ -1406,9 +1408,12 @@ FIELD_INSERT: && rSh.SetCursorInHdFt(nPageDescIndex, bHeader, /*Even=*/true)) { assert(nEvenPage && "what? no even page and yet we got here?"); - if (pNewMark) + OUString sBookmarkEvenPage( + sBookmarkName + OUString::number(rSh.GetVirtPageNum())); + ppMark = rIDMA.findMark(sBookmarkEvenPage); + if (ppMark != rIDMA.getAllMarksEnd() && *ppMark) { - SwPaM aDeleteOldPageNum(pNewMark->GetMarkStart(), pNewMark->GetMarkEnd()); + SwPaM aDeleteOldPageNum((*ppMark)->GetMarkStart(), (*ppMark)->GetMarkEnd()); rDoc.getIDocumentContentOperations().DeleteAndJoin(aDeleteOldPageNum); } @@ -1450,7 +1455,7 @@ FIELD_INSERT: aNewEvenBookmarkPaM.SetMark(); aNewEvenBookmarkPaM.Start()->SetContent(nStartContentIndex); rIDMA.makeMark(aNewEvenBookmarkPaM, - sBookmarkName, + sBookmarkEvenPage, IDocumentMarkAccess::MarkType::BOOKMARK, sw::mark::InsertMode::New); }
