diff options
author | Henry Castro <hcastro@collabora.com> | 2023-10-09 07:34:02 -0400 |
---|---|---|
committer | Henry Castro <hcastro@collabora.com> | 2023-10-31 21:09:19 +0100 |
commit | f2ae8b934aaac7c444e8493ed5e8189c6ce63328 (patch) | |
tree | 936021425c09fdc505e6d0331f7eee8cf872296e /oox | |
parent | 046e9545956d8ad1d69345d6b4a4c0a33714d179 (diff) |
tdf#155512: oox: ppt: fix import master slides, follow up
Import all master slides.
Signed-off-by: Henry Castro <hcastro@collabora.com>
Change-Id: Ieac68bacf15c75e4c23ec692aadcb16033cdd092
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157701
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158716
Tested-by: Jenkins
Diffstat (limited to 'oox')
-rw-r--r-- | oox/source/ppt/presentationfragmenthandler.cxx | 42 |
1 files changed, 22 insertions, 20 deletions
diff --git a/oox/source/ppt/presentationfragmenthandler.cxx b/oox/source/ppt/presentationfragmenthandler.cxx index edb523161c9e..2e0f48bbae98 100644 --- a/oox/source/ppt/presentationfragmenthandler.cxx +++ b/oox/source/ppt/presentationfragmenthandler.cxx @@ -215,18 +215,16 @@ void PresentationFragmentHandler::importCustomSlideShow(std::vector<CustomShow>& } } -SlidePersistPtr PresentationFragmentHandler::importMasterSlide(const Reference<frame::XModel>& xModel, - PowerPointImport& rFilter, - std::u16string_view rLayoutFragmentPath, - std::u16string_view rMasterFragmentPath) +void PresentationFragmentHandler::importMasterSlide(const Reference<frame::XModel>& xModel, + PowerPointImport& rFilter, + const OUString& rMasterFragmentPath) { OUString aLayoutFragmentPath; - OUString aMasterFragmentPath(rMasterFragmentPath); - SlidePersistPtr pMasterPersistPtr, pMasterPtr; + SlidePersistPtr pMasterPersistPtr; Reference< drawing::XDrawPage > xMasterPage; Reference< drawing::XMasterPagesSupplier > xMPS( xModel, uno::UNO_QUERY_THROW ); Reference< drawing::XDrawPages > xMasterPages( xMPS->getMasterPages(), uno::UNO_SET_THROW ); - RelationsRef xMasterRelations = rFilter.importRelations( aMasterFragmentPath ); + RelationsRef xMasterRelations = rFilter.importRelations( rMasterFragmentPath ); for (const auto& rEntry : *xMasterRelations) { @@ -252,7 +250,7 @@ SlidePersistPtr PresentationFragmentHandler::importMasterSlide(const Reference<f pMasterPersistPtr->setLayoutPath( aLayoutFragmentPath ); rFilter.getMasterPages().push_back( pMasterPersistPtr ); rFilter.setActualSlidePersist( pMasterPersistPtr ); - FragmentHandlerRef xMasterFragmentHandler( new SlideFragmentHandler( rFilter, aMasterFragmentPath, pMasterPersistPtr, Master ) ); + FragmentHandlerRef xMasterFragmentHandler( new SlideFragmentHandler( rFilter, rMasterFragmentPath, pMasterPersistPtr, Master ) ); // set the correct theme OUString aThemeFragmentPath = xMasterFragmentHandler->getFragmentPathFromFirstTypeFromOfficeDoc( u"theme" ); @@ -297,14 +295,7 @@ SlidePersistPtr PresentationFragmentHandler::importMasterSlide(const Reference<f { pTheme->addTheme(pMasterPersistPtr->getPage()); } - - if (pMasterPersistPtr->getLayoutPath() == rLayoutFragmentPath) - { - pMasterPtr = pMasterPersistPtr; - } } - - return pMasterPtr; } void PresentationFragmentHandler::saveThemeToGrabBag(const oox::drawingml::ThemePtr& pThemePtr, @@ -374,6 +365,19 @@ void PresentationFragmentHandler::saveThemeToGrabBag(const oox::drawingml::Theme } } +void PresentationFragmentHandler::importMasterSlides() +{ + OUString aMasterFragmentPath; + PowerPointImport& rFilter = dynamic_cast<PowerPointImport&>(getFilter()); + Reference<frame::XModel> xModel(rFilter.getModel()); + + for (size_t nMaster = 0; nMaster < maSlideMasterVector.size(); ++nMaster) + { + aMasterFragmentPath = getFragmentPathFromRelId(maSlideMasterVector[nMaster]); + importMasterSlide(xModel, rFilter, aMasterFragmentPath); + } +} + void PresentationFragmentHandler::importSlide(sal_uInt32 nSlide, bool bFirstPage, bool bImportNotesPage) { PowerPointImport& rFilter = dynamic_cast< PowerPointImport& >( getFilter() ); @@ -388,7 +392,10 @@ void PresentationFragmentHandler::importSlide(sal_uInt32 nSlide, bool bFirstPage try { if( bFirstPage ) + { xDrawPages->getByIndex( 0 ) >>= xSlide; + importMasterSlides(); + } else xSlide = xDrawPages->insertNewByIndex( xDrawPages->getCount() ); @@ -421,11 +428,6 @@ void PresentationFragmentHandler::importSlide(sal_uInt32 nSlide, bool bFirstPage break; } } - - if ( !pMasterPersistPtr ) - { // masterpersist not found, we have to load it - pMasterPersistPtr = importMasterSlide(xModel, rFilter, aLayoutFragmentPath, aMasterFragmentPath); - } } } |