sd/qa/unit/misc-tests.cxx | 25 +++++++++++++++++++++++++ sd/source/core/drawdoc3.cxx | 5 ++++- 2 files changed, 29 insertions(+), 1 deletion(-)
New commits: commit 8100f1a3f85b6a0c755b75fea3697da960e6e96e Author: Andreas Heinisch <andreas.heini...@yahoo.de> AuthorDate: Sun Jan 12 12:44:50 2025 +0100 Commit: Christian Lohmaier <lohmaier+libreoff...@googlemail.com> CommitDate: Mon Jan 27 15:30:47 2025 +0100 tdf#164284 - Prevent page name change during page move Change-Id: I341c5b9baf7cc39b8d543df89b4c46a59bf2a9e6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/180138 Tested-by: Jenkins Reviewed-by: Andreas Heinisch <andreas.heini...@yahoo.de> (cherry picked from commit 74358a0f500a5f102791a55ac9e090df0c236488) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/180155 Reviewed-by: Christian Lohmaier <lohmaier+libreoff...@googlemail.com> diff --git a/sd/qa/unit/misc-tests.cxx b/sd/qa/unit/misc-tests.cxx index 9b7aed2dfd30..590bd52b21d3 100644 --- a/sd/qa/unit/misc-tests.cxx +++ b/sd/qa/unit/misc-tests.cxx @@ -83,6 +83,7 @@ public: void testTdf129898LayerDrawnInSlideshow(); void testTdf136956(); void testTdf39519(); + void testTdf164284(); void testEncodedTableStyles(); void testTdf157117(); @@ -107,6 +108,7 @@ public: CPPUNIT_TEST(testTdf129898LayerDrawnInSlideshow); CPPUNIT_TEST(testTdf136956); CPPUNIT_TEST(testTdf39519); + CPPUNIT_TEST(testTdf164284); CPPUNIT_TEST(testEncodedTableStyles); CPPUNIT_TEST(testTdf157117); CPPUNIT_TEST_SUITE_END(); @@ -910,6 +912,29 @@ void SdMiscTest::testTdf39519() CPPUNIT_ASSERT(pCopiedPage->GetName() != pPage->GetName()); } +void SdMiscTest::testTdf164284() +{ + createSdImpressDoc(); + SdXImpressDocument* pXImpressDocument = dynamic_cast<SdXImpressDocument*>(mxComponent.get()); + CPPUNIT_ASSERT(pXImpressDocument); + + // Change the name of the first page in the newly created document + SdDrawDocument* pDoc = pXImpressDocument->GetDoc(); + SdPage* pPage = static_cast<SdPage*>(pDoc->GetPage(1)); + pPage->SetName(u"Test"_ustr); + + // Move a bookmark as a page using the same name + pDoc->DoMakePageObjectsNamesUnique(false); + std::vector<OUString> aBookmarkList = { u"Test"_ustr }; + pDoc->InsertBookmarkAsPage(aBookmarkList, nullptr, false, false, 2, true, pDoc->GetDocSh(), + true, false, false); + + // Check if the moved page has the same name + SdPage* pMovedPage = static_cast<SdPage*>(pDoc->GetPage(2)); + // Without the fix in place, the names of the pages would be different + CPPUNIT_ASSERT_EQUAL(pPage->GetName(), pMovedPage->GetName()); +} + void SdMiscTest::testEncodedTableStyles() { // Silence unrelated failure: diff --git a/sd/source/core/drawdoc3.cxx b/sd/source/core/drawdoc3.cxx index bb857701481e..30a03145eed3 100644 --- a/sd/source/core/drawdoc3.cxx +++ b/sd/source/core/drawdoc3.cxx @@ -724,7 +724,10 @@ bool SdDrawDocument::InsertBookmarkAsPage( // tdf#39519 - rename page if its name is not unique, e.g., if a slide is copied by // ctrl + drag and drop (DND_ACTION_COPY) - if (bMustRename || !mpDocSh->IsPageNameUnique(aPgName)) + if (bMustRename + // tdf#164284 - prevent page name change during page move + || (pBookmarkDoc->DoesMakePageObjectsNamesUnique() + && !mpDocSh->IsPageNameUnique(aPgName))) { // Page name already in use -> use default name for default and // notes page