sw/qa/uibase/shells/shells.cxx | 9 +++++++-- sw/source/uibase/shells/textsh1.cxx | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-)
New commits: commit 1f0d6c660c799900cfda070f7319c8e0cdde41f5 Author: Miklos Vajna <vmik...@collabora.com> AuthorDate: Mon Jan 9 16:27:15 2023 +0100 Commit: Pranam Lashkari <lpra...@collabora.com> CommitDate: Wed Jan 11 01:11:19 2023 +0000 sw, UpdateBookmarks: support renaming bookmarks The problem was that the LOK API client wanted to change the name of the bookmark, but nothing happened, because we had a sanity check that made sure the provided vs existing bookmark names match. The intention was that the bookmark name is just an ID (you can store additional properties in per-doc custom properties, those can change), so we can require that bookmarks never get renamed when using this command. Fix the problem by dropping this requirement and rather use renameMark() to adjust the in-doc bookmark name if needed. This also handles undo/redo for us. (cherry picked from commit d2318503d559c3797965da777627e4ee45143043) Change-Id: I7a426c865ddf24f13741c0369fb3991da2e881b2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145280 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Pranam Lashkari <lpra...@collabora.com> diff --git a/sw/qa/uibase/shells/shells.cxx b/sw/qa/uibase/shells/shells.cxx index 794932e8cf25..33f0d615b250 100644 --- a/sw/qa/uibase/shells/shells.cxx +++ b/sw/qa/uibase/shells/shells.cxx @@ -405,7 +405,7 @@ CPPUNIT_TEST_FIXTURE(SwUibaseShellsTest, testUpdateBookmarks) { "Bookmark": { "type": "string", - "value": "ZOTERO_BREF_GiQ7DAWQYWLy" + "value": "ZOTERO_BREF_new1" }, "BookmarkText": { "type": "string", @@ -415,7 +415,7 @@ CPPUNIT_TEST_FIXTURE(SwUibaseShellsTest, testUpdateBookmarks) { "Bookmark": { "type": "string", - "value": "ZOTERO_BREF_PRxDGUb4SWXF" + "value": "ZOTERO_BREF_new2" }, "BookmarkText": { "type": "string", @@ -437,6 +437,11 @@ CPPUNIT_TEST_FIXTURE(SwUibaseShellsTest, testUpdateBookmarks) // - Actual : ABCDE // i.e. the content was not updated. CPPUNIT_ASSERT_EQUAL(OUString("Anew result 1Cnew result 2E"), aActual); + + // Without the accompanying fix in place, this test would have failed, ZOTERO_BREF_GiQ7DAWQYWLy + // was not renamed to ZOTERO_BREF_new1. + auto it = pDoc->getIDocumentMarkAccess()->findMark("ZOTERO_BREF_new1"); + CPPUNIT_ASSERT(it != pDoc->getIDocumentMarkAccess()->getAllMarksEnd()); } CPPUNIT_TEST_FIXTURE(SwUibaseShellsTest, testInsertFieldmarkReadonly) diff --git a/sw/source/uibase/shells/textsh1.cxx b/sw/source/uibase/shells/textsh1.cxx index 4641aede858f..2acf9b037602 100644 --- a/sw/source/uibase/shells/textsh1.cxx +++ b/sw/source/uibase/shells/textsh1.cxx @@ -425,7 +425,7 @@ void UpdateBookmarks(SfxRequest& rReq, SwWrtShell& rWrtSh) comphelper::SequenceAsHashMap aMap(aBookmarks[nBookmarkIndex++]); if (aMap["Bookmark"].get<OUString>() != pMark->GetName()) { - continue; + rIDMA.renameMark(pMark, aMap["Bookmark"].get<OUString>()); } OUString aBookmarkText = aMap["BookmarkText"].get<OUString>();