diff options
author | Tibor Nagy <nagy.tibor2@nisz.hu> | 2021-04-28 13:10:59 +0200 |
---|---|---|
committer | László Németh <nemeth@numbertext.org> | 2021-05-04 17:27:55 +0200 |
commit | cfa672013a1a75ff53993084ae5e69fcd985d010 (patch) | |
tree | ac929f2ee06b2a19430074b243d48f8471ceae96 /oox | |
parent | 84b4bca314ded015911ab986e8f999518616b248 (diff) |
tdf#103347 PPTX import: fix duplicated slide name
PPTX import uses title text as slide names, but this resulted
duplicated slide names in the case of repeating title
text, which forbidden by UNO API:
== GenericDrawPage.idl ==
/** Gets or sets the name of this page.
<p>Duplicated page names inside a document are not allowed.
*/
[optional] interface com::sun::star::container::XNamed;
Now the import code skips the duplicated title text,
resulting default numbered slide names instead of the
duplicated title names.
Note: it seems, this hasn't fixed the jumping slide selection,
e.g. sometimes pressing Shift-F5 still presents the first slide
instead of the actual one.
Change-Id: I98511c3c9a59598ea113e7387db5202d7f8a7cd4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/114810
Tested-by: László Németh <nemeth@numbertext.org>
Reviewed-by: László Németh <nemeth@numbertext.org>
Diffstat (limited to 'oox')
-rw-r--r-- | oox/source/ppt/pptshape.cxx | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/oox/source/ppt/pptshape.cxx b/oox/source/ppt/pptshape.cxx index 62a070e5c840..2f346cca2192 100644 --- a/oox/source/ppt/pptshape.cxx +++ b/oox/source/ppt/pptshape.cxx @@ -26,6 +26,8 @@ #include <com/sun/star/frame/XModel.hpp> #include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <com/sun/star/drawing/XDrawPage.hpp> +#include <com/sun/star/drawing/XDrawPages.hpp> +#include <com/sun/star/drawing/XDrawPagesSupplier.hpp> #include <com/sun/star/drawing/XShapes.hpp> #include <com/sun/star/text/XText.hpp> #include <basegfx/matrix/b2dhommatrix.hxx> @@ -363,14 +365,29 @@ void PPTShape::addShape( setMasterTextListStyle( aMasterTextListStyle ); Reference< XShape > xShape( createAndInsert( rFilterBase, sServiceName, pTheme, rxShapes, bClearText, bool(mpPlaceholder), aTransformation, getFillProperties() ) ); + // if exists and not duplicated, try to use the title text as slide name to help its re-use on UI if (!rSlidePersist.isMasterPage() && rSlidePersist.getPage().is() && mnSubType == XML_title) - { + { try { OUString aTitleText; Reference<XTextRange> xText(xShape, UNO_QUERY_THROW); aTitleText = xText->getString(); - if (!aTitleText.isEmpty() && (aTitleText.getLength() < 64)) // just a magic value, but we don't want to set slide names which are too long + Reference<drawing::XDrawPagesSupplier> xDPS(rFilterBase.getModel(), uno::UNO_QUERY_THROW); + Reference<drawing::XDrawPages> xDrawPages(xDPS->getDrawPages(), uno::UNO_SET_THROW); + sal_uInt32 nMaxPages = xDrawPages->getCount(); + bool bUseTitleAsSlideName = !aTitleText.isEmpty() && + // 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 ) { Reference<container::XNamed> xName(rSlidePersist.getPage(), UNO_QUERY_THROW); xName->setName(aTitleText); |