oox/source/ppt/pptshape.cxx | 25 ++++++++++++++++--------- sd/qa/unit/import-tests.cxx | 4 ++-- 2 files changed, 18 insertions(+), 11 deletions(-)
New commits: commit 65070087508f176a2a65a0cfbe628ab2994e824f Author: Tibor Nagy <nagy.tib...@nisz.hu> AuthorDate: Wed Jun 16 11:02:48 2021 +0200 Commit: László Németh <nem...@numbertext.org> CommitDate: Mon Jun 28 10:41:09 2021 +0200 tdf#142646 PPTX import: count repeating slide names instead of using the default slide name "Slide n". PPTX slides are named after their titles. Now repeating titles got a number instead of using the default slide name "Slide n". E.g. "Title", "Title", "Title" will be slide names "Title", "Title (2)", Title (3)", and not "Title", "Slide 2", "Slide 3". Follow-up to commit I98511c3c9a59598ea113e7387db5202d7f8a7cd4 "tdf#103347: PTX import: fix duplicated slide name" Change-Id: I449d6f7d7599291b3dae7df65ad6ff86a4269fb8 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117317 Tested-by: László Németh <nem...@numbertext.org> Reviewed-by: László Németh <nem...@numbertext.org> (cherry picked from commit 253bee65bc24d999c3629a4d503d0fa01b355cfc) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117972 Tested-by: Jenkins diff --git a/oox/source/ppt/pptshape.cxx b/oox/source/ppt/pptshape.cxx index 1756ad9e32ab..563454aaaf66 100644 --- a/oox/source/ppt/pptshape.cxx +++ b/oox/source/ppt/pptshape.cxx @@ -339,6 +339,7 @@ void PPTShape::addShape( { try { + sal_Int32 nCount = 1; OUString aTitleText; Reference<XTextRange> xText(xShape, UNO_QUERY_THROW); aTitleText = xText->getString(); @@ -349,17 +350,23 @@ void PPTShape::addShape( // just a magic value, but we don't want to set slide names which are too long aTitleText.getLength() < 64; // check duplicated title name - for (sal_uInt32 nPage = 0; bUseTitleAsSlideName && nPage < nMaxPages; ++nPage) - { - Reference<XDrawPage> xDrawPage(xDrawPages->getByIndex(nPage), uno::UNO_QUERY); - Reference<container::XNamed> xNamed(xDrawPage, UNO_QUERY_THROW); - if ( xNamed->getName() == aTitleText ) - bUseTitleAsSlideName = false; - } - if ( bUseTitleAsSlideName ) + if (bUseTitleAsSlideName) { + for (sal_uInt32 nPage = 0; nPage < nMaxPages; ++nPage) + { + Reference<XDrawPage> xDrawPage(xDrawPages->getByIndex(nPage), uno::UNO_QUERY); + Reference<container::XNamed> xNamed(xDrawPage, UNO_QUERY_THROW); + OUString sRest; + if (xNamed->getName().startsWith(aTitleText, &sRest) + && (sRest.isEmpty() + || (sRest.startsWith(" (") && sRest.endsWith(")") + && sRest.copy(2, sRest.getLength() - 3).toInt32() > 0))) + nCount++; + } Reference<container::XNamed> xName(rSlidePersist.getPage(), UNO_QUERY_THROW); - xName->setName(aTitleText); + xName->setName( + aTitleText + + (nCount == 1 ? OUString("") : " (" + OUString::number(nCount) + ")")); } } catch (uno::Exception&) diff --git a/sd/qa/unit/import-tests.cxx b/sd/qa/unit/import-tests.cxx index 8d7b5333f720..ad013f280180 100644 --- a/sd/qa/unit/import-tests.cxx +++ b/sd/qa/unit/import-tests.cxx @@ -3449,11 +3449,11 @@ void SdImportTest::testTdf103347() uno::Reference<drawing::XDrawPage> xPage2(xDoc->getDrawPages()->getByIndex(1), uno::UNO_QUERY); uno::Reference<container::XNamed> xNamed2(xPage2, uno::UNO_QUERY_THROW); - CPPUNIT_ASSERT_EQUAL(OUString("page2"), xNamed2->getName()); + CPPUNIT_ASSERT_EQUAL(OUString("Hello (2)"), xNamed2->getName()); uno::Reference<drawing::XDrawPage> xPage3(xDoc->getDrawPages()->getByIndex(2), uno::UNO_QUERY); uno::Reference<container::XNamed> xNamed3(xPage3, uno::UNO_QUERY_THROW); - CPPUNIT_ASSERT_EQUAL(OUString("page3"), xNamed3->getName()); + CPPUNIT_ASSERT_EQUAL(OUString("Hello (3)"), xNamed3->getName()); xDocShRef->DoClose(); } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits