summaryrefslogtreecommitdiff
path: root/sd
diff options
context:
space:
mode:
authorAndreas Heinisch <andreas.heinisch@yahoo.de>2023-07-24 11:34:27 +0200
committerAndreas Heinisch <andreas.heinisch@yahoo.de>2023-08-25 14:10:52 +0200
commit139cffc531277b57bae8e272fef13af00ace5366 (patch)
treef9be1c77d46f933d7745ce79fd075177648d972d /sd
parenta29d4aba60f9e0e7e8d34f8973a351f75a114426 (diff)
tdf#39519 - Rename slide if its name is not unique
For instance, if a slide is copied by ctrl + drag and drop (DND_ACTION_COPY) Change-Id: I1c669c299a38431680ce602922c1e2c7f117a2ab Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154838 Tested-by: Jenkins Reviewed-by: Andreas Heinisch <andreas.heinisch@yahoo.de>
Diffstat (limited to 'sd')
-rw-r--r--sd/inc/drawdoc.hxx4
-rw-r--r--sd/qa/unit/misc-tests.cxx24
-rw-r--r--sd/source/core/drawdoc3.cxx4
3 files changed, 29 insertions, 3 deletions
diff --git a/sd/inc/drawdoc.hxx b/sd/inc/drawdoc.hxx
index 50a5e2f09ca3..12814f3717b8 100644
--- a/sd/inc/drawdoc.hxx
+++ b/sd/inc/drawdoc.hxx
@@ -346,8 +346,8 @@ public:
page, or preserve the old name
*/
- SAL_DLLPRIVATE bool InsertBookmarkAsPage(const std::vector<OUString> &rBookmarkList,
- std::vector<OUString> *pExchangeList,
+ bool InsertBookmarkAsPage(const std::vector<OUString> &rBookmarkList,
+ std::vector<OUString> *pExchangeList,
bool bLink, bool bReplace, sal_uInt16 nPgPos,
bool bNoDialogs, ::sd::DrawDocShell* pBookmarkDocSh,
bool bCopy, bool bMergeMasterPages,
diff --git a/sd/qa/unit/misc-tests.cxx b/sd/qa/unit/misc-tests.cxx
index e8e34c20c8c2..3cdc212e69db 100644
--- a/sd/qa/unit/misc-tests.cxx
+++ b/sd/qa/unit/misc-tests.cxx
@@ -82,6 +82,7 @@ public:
void testTdf131033();
void testTdf129898LayerDrawnInSlideshow();
void testTdf136956();
+ void testTdf39519();
void testEncodedTableStyles();
CPPUNIT_TEST_SUITE(SdMiscTest);
@@ -104,6 +105,7 @@ public:
CPPUNIT_TEST(testTdf131033);
CPPUNIT_TEST(testTdf129898LayerDrawnInSlideshow);
CPPUNIT_TEST(testTdf136956);
+ CPPUNIT_TEST(testTdf39519);
CPPUNIT_TEST(testEncodedTableStyles);
CPPUNIT_TEST_SUITE_END();
};
@@ -886,6 +888,28 @@ void SdMiscTest::testTdf136956()
CPPUNIT_ASSERT_EQUAL(sal_Int32(3), xTable->getRowCount());
}
+void SdMiscTest::testTdf39519()
+{
+ 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("Test");
+
+ // Insert a bookmark as a new page using the same name
+ std::vector<OUString> aBookmarkList = { "Test" };
+ pDoc->InsertBookmarkAsPage(aBookmarkList, nullptr, false, false, 2, true, pDoc->GetDocSh(),
+ true, false, false);
+
+ // Check if the copied page has a different name
+ SdPage* pCopiedPage = static_cast<SdPage*>(pDoc->GetPage(2));
+ // Without the fix in place, the names of the pages would not be different
+ CPPUNIT_ASSERT(pCopiedPage->GetName() != pPage->GetName());
+}
+
void SdMiscTest::testEncodedTableStyles()
{
// Silence unrelated failure:
diff --git a/sd/source/core/drawdoc3.cxx b/sd/source/core/drawdoc3.cxx
index 00006fbefd24..357858f46222 100644
--- a/sd/source/core/drawdoc3.cxx
+++ b/sd/source/core/drawdoc3.cxx
@@ -696,7 +696,9 @@ bool SdDrawDocument::InsertBookmarkAsPage(
}
}
- if( bMustRename )
+ // 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))
{
// Page name already in use -> use default name for default and
// notes page