diff options
-rw-r--r-- | sd/qa/unit/misc-tests.cxx | 25 | ||||
-rw-r--r-- | sd/source/core/drawdoc3.cxx | 5 |
2 files changed, 29 insertions, 1 deletions
diff --git a/sd/qa/unit/misc-tests.cxx b/sd/qa/unit/misc-tests.cxx index 7d66061c69ec..59628256fcce 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(); @@ -909,6 +911,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 f04e56712940..3e8c088e1067 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 |