diff options
author | Tibor Nagy <nagy.tibor2@nisz.hu> | 2021-05-12 12:14:26 +0200 |
---|---|---|
committer | László Németh <nemeth@numbertext.org> | 2021-05-25 15:44:40 +0200 |
commit | ecf48b2d4f3e54dbb2c1e295120d73e7b7a11338 (patch) | |
tree | 69b9b609e784c13024046a950c7dec8665b24fce /oox | |
parent | 63ce1ca6d7c802ab68295cf2364840959c829557 (diff) |
tdf#131390 PPTX: fix custom slide show is not imported.
Change-Id: I62e1bfaae23d1b18e71a2c16651d01144a26907c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115475
Tested-by: Jenkins
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/customshowlistcontext.cxx | 23 | ||||
-rw-r--r-- | oox/source/ppt/presentationfragmenthandler.cxx | 49 |
2 files changed, 62 insertions, 10 deletions
diff --git a/oox/source/ppt/customshowlistcontext.cxx b/oox/source/ppt/customshowlistcontext.cxx index 174ca1bbe91a..1e6befd639ae 100644 --- a/oox/source/ppt/customshowlistcontext.cxx +++ b/oox/source/ppt/customshowlistcontext.cxx @@ -33,12 +33,12 @@ namespace { class CustomShowContext : public ::oox::core::FragmentHandler2 { - CustomShow mrCustomShow; + std::vector< CustomShow >& mrCustomShowList; public: CustomShowContext( ::oox::core::FragmentHandler2 const & rParent, const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttribs, - CustomShow const & rCustomShow ); + std::vector< CustomShow >& rCustomShowList ); virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 aElementToken, const AttributeList& rAttribs ) override; }; @@ -47,12 +47,14 @@ public: CustomShowContext::CustomShowContext( FragmentHandler2 const & rParent, const Reference< XFastAttributeList >& rxAttribs, - CustomShow const & rCustomShow ) + std::vector< CustomShow >& rCustomShowList ) : FragmentHandler2( rParent ) -, mrCustomShow( rCustomShow ) +, mrCustomShowList( rCustomShowList ) { - mrCustomShow.maCustomShowName = rxAttribs->getOptionalValue( XML_name ); - mrCustomShow.mnId = rxAttribs->getOptionalValue( XML_id ); + CustomShow aCustomShow; + aCustomShow.maCustomShowName = rxAttribs->getOptionalValue( XML_name ); + aCustomShow.mnId = rxAttribs->getOptionalValue( XML_id ); + mrCustomShowList.push_back(aCustomShow); } ::oox::core::ContextHandlerRef CustomShowContext::onCreateContext( sal_Int32 aElementToken, const AttributeList& rAttribs ) @@ -60,7 +62,10 @@ CustomShowContext::CustomShowContext( FragmentHandler2 const & rParent, switch( aElementToken ) { case PPT_TOKEN( sld ) : - mrCustomShow.maSldLst.push_back( rAttribs.getString( R_TOKEN( id ), OUString() ) ); + mrCustomShowList.back().maSldLst.push_back( + getRelations() + .getRelationFromRelId(rAttribs.getString(R_TOKEN(id), OUString())) + ->maTarget); return this; default: break; @@ -86,9 +91,7 @@ CustomShowListContext::~CustomShowListContext( ) { case PPT_TOKEN( custShow ) : { - CustomShow aCustomShow; - mrCustomShowList.push_back( aCustomShow ); - return new CustomShowContext( *this, rAttribs.getFastAttributeList(), mrCustomShowList.back() ); + return new CustomShowContext( *this, rAttribs.getFastAttributeList(), mrCustomShowList ); } default: break; diff --git a/oox/source/ppt/presentationfragmenthandler.cxx b/oox/source/ppt/presentationfragmenthandler.cxx index a00b825d8c00..9aabd45d18af 100644 --- a/oox/source/ppt/presentationfragmenthandler.cxx +++ b/oox/source/ppt/presentationfragmenthandler.cxx @@ -35,6 +35,10 @@ #include <com/sun/star/xml/sax/XFastSAXSerializable.hpp> #include <com/sun/star/presentation/XPresentationPage.hpp> #include <com/sun/star/task/XStatusIndicator.hpp> +#include <com/sun/star/presentation/XCustomPresentationSupplier.hpp> +#include <com/sun/star/container/XIndexContainer.hpp> +#include <com/sun/star/lang/XSingleServiceFactory.hpp> +#include <com/sun/star/container/XNameContainer.hpp> #include <oox/drawingml/theme.hxx> #include <oox/drawingml/drawingmltypes.hxx> @@ -158,6 +162,49 @@ static void ResolveTextFields( XmlFilterBase const & rFilter ) } } +void PresentationFragmentHandler::importCustomSlideShow(std::vector<CustomShow>& rCustomShowList) +{ + PowerPointImport& rFilter = dynamic_cast<PowerPointImport&>(getFilter()); + Reference<frame::XModel> xModel(rFilter.getModel()); + Reference<XDrawPagesSupplier> xDrawPagesSupplier(xModel, UNO_QUERY_THROW); + Reference<XDrawPages> xDrawPages(xDrawPagesSupplier->getDrawPages(), UNO_SET_THROW); + + Reference<css::lang::XSingleServiceFactory> mxShowFactory; + Reference<css::container::XNameContainer> mxShows; + Reference<XCustomPresentationSupplier> xShowsSupplier(xModel, UNO_QUERY); + if (xShowsSupplier.is()) + { + mxShows = xShowsSupplier->getCustomPresentations(); + mxShowFactory.set(mxShows, UNO_QUERY); + } + + for (size_t i = 0; i < rCustomShowList.size(); ++i) + { + Reference<com::sun::star::container::XIndexContainer> xShow(mxShowFactory->createInstance(), + UNO_QUERY); + if (xShow.is()) + { + static const OUStringLiteral sSlide = u"slides/slide"; + for (size_t j = 0; j < rCustomShowList[i].maSldLst.size(); ++j) + { + OUString sCustomSlide = rCustomShowList[i].maSldLst[j]; + sal_Int32 nPageNumber = 0; + if (sCustomSlide.match(sSlide)) + nPageNumber = sCustomSlide.copy(sSlide.getLength()).toInt32(); + + Reference<XDrawPage> xPage; + xDrawPages->getByIndex(nPageNumber - 1) >>= xPage; + if (xPage.is()) + xShow->insertByIndex(xShow->getCount(), Any(xPage)); + } + + Any aAny; + aAny <<= xShow; + mxShows->insertByName(rCustomShowList[i].maCustomShowName, aAny); + } + } +} + void PresentationFragmentHandler::saveThemeToGrabBag(const oox::drawingml::ThemePtr& pThemePtr, sal_Int32 nThemeIdx) { @@ -497,6 +544,8 @@ void PresentationFragmentHandler::finalizeImport() nPagesImported++; } ResolveTextFields( rFilter ); + if (!maCustomShowList.empty()) + importCustomSlideShow(maCustomShowList); } catch( uno::Exception& ) { |