diff options
author | Henry Castro <hcastro@collabora.com> | 2023-09-28 15:01:43 -0400 |
---|---|---|
committer | Henry Castro <hcastro@collabora.com> | 2023-10-04 21:07:14 +0200 |
commit | adcde78935fb8ca2b93322aa3a558d0b3ccdbfad (patch) | |
tree | d500c200f07a058a120fe5aa26e5d009bd01fbb1 /oox | |
parent | b75d4156a3b2550db2cff1360a598e508ee51c8f (diff) |
tdf#155512: oox: ppt: fix import master slides
Import all master slides according to
the relationship with slide layouts.
Adjust unit test values:
SdOOXMLExportTest2::testTdf106867
I do not know why those values change since
importing embedded video source code was not touched
SdOOXMLExportTest2::testAccentColor
The accent6 is a constant value.
Signed-off-by: Henry Castro <hcastro@collabora.com>
Change-Id: Ic7c70d2c4ce30a7f2d2d1cf22604f1119a66f5f7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157387
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Tested-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
(cherry picked from commit 08ed103d734ebf65202dc097c7bb0990573f8fd1)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157532
Tested-by: Jenkins
Diffstat (limited to 'oox')
-rw-r--r-- | oox/source/ppt/presentationfragmenthandler.cxx | 121 |
1 files changed, 67 insertions, 54 deletions
diff --git a/oox/source/ppt/presentationfragmenthandler.cxx b/oox/source/ppt/presentationfragmenthandler.cxx index 538d79df7f50..5dd00957b8b8 100644 --- a/oox/source/ppt/presentationfragmenthandler.cxx +++ b/oox/source/ppt/presentationfragmenthandler.cxx @@ -217,75 +217,88 @@ void PresentationFragmentHandler::importCustomSlideShow(std::vector<CustomShow>& SlidePersistPtr PresentationFragmentHandler::importMasterSlide(const Reference<frame::XModel>& xModel, PowerPointImport& rFilter, - const OUString& rLayoutFragmentPath, - const OUString& rMasterFragmentPath) + std::u16string_view rLayoutFragmentPath, + std::u16string_view rMasterFragmentPath) { - SlidePersistPtr pMasterPersistPtr; + OUString aLayoutFragmentPath; + OUString aMasterFragmentPath(rMasterFragmentPath); + SlidePersistPtr pMasterPersistPtr, pMasterPtr; 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 ); - sal_Int32 nIndex; - if( rFilter.getMasterPages().empty() ) + for (const auto& rEntry : *xMasterRelations) { - nIndex = 0; - xMasterPages->getByIndex( nIndex ) >>= xMasterPage; - } - else - { - nIndex = xMasterPages->getCount(); - xMasterPage = xMasterPages->insertNewByIndex( nIndex ); - } + aLayoutFragmentPath = xMasterRelations->getFragmentPathFromRelation(rEntry.second); - pMasterPersistPtr = std::make_shared<SlidePersist>( rFilter, true, false, xMasterPage, - std::make_shared<PPTShape>( Master, "com.sun.star.drawing.GroupShape" ), mpTextListStyle ); - pMasterPersistPtr->setLayoutPath( rLayoutFragmentPath ); - rFilter.getMasterPages().push_back( pMasterPersistPtr ); - rFilter.setActualSlidePersist( pMasterPersistPtr ); - FragmentHandlerRef xMasterFragmentHandler( new SlideFragmentHandler( rFilter, rMasterFragmentPath, pMasterPersistPtr, Master ) ); - - // set the correct theme - OUString aThemeFragmentPath = xMasterFragmentHandler->getFragmentPathFromFirstTypeFromOfficeDoc( u"theme" ); - if( !aThemeFragmentPath.isEmpty() ) - { - std::map< OUString, oox::drawingml::ThemePtr >& rThemes( rFilter.getThemes() ); - std::map< OUString, oox::drawingml::ThemePtr >::iterator aIter2( rThemes.find( aThemeFragmentPath ) ); - if( aIter2 == rThemes.end() ) + sal_Int32 nIndex; + if( rFilter.getMasterPages().empty() ) { - oox::drawingml::ThemePtr pThemePtr = std::make_shared<oox::drawingml::Theme>(); - pMasterPersistPtr->setTheme( pThemePtr ); - Reference<xml::dom::XDocument> xDoc= - rFilter.importFragment(aThemeFragmentPath); - - auto pTheme = std::make_shared<model::Theme>(); - pThemePtr->setTheme(pTheme); - - rFilter.importFragment( - new ThemeFragmentHandler(rFilter, aThemeFragmentPath, *pThemePtr, *pTheme), - Reference<xml::sax::XFastSAXSerializable>( - xDoc, - UNO_QUERY_THROW)); - rThemes[ aThemeFragmentPath ] = pThemePtr; - pThemePtr->setFragment(xDoc); - saveThemeToGrabBag(pThemePtr, nIndex + 1); + nIndex = 0; + xMasterPages->getByIndex( nIndex ) >>= xMasterPage; } else { - pMasterPersistPtr->setTheme( (*aIter2).second ); + nIndex = xMasterPages->getCount(); + xMasterPage = xMasterPages->insertNewByIndex( nIndex ); } - } - importSlide( xMasterFragmentHandler, pMasterPersistPtr ); - rFilter.importFragment( new LayoutFragmentHandler( rFilter, rLayoutFragmentPath, pMasterPersistPtr ) ); - pMasterPersistPtr->createBackground( rFilter ); - pMasterPersistPtr->createXShapes( rFilter ); - oox::drawingml::ThemePtr pTheme = pMasterPersistPtr->getTheme(); - if (pTheme) - { - pTheme->addTheme(pMasterPersistPtr->getPage()); + pMasterPersistPtr = std::make_shared<SlidePersist>( rFilter, true, false, xMasterPage, + std::make_shared<PPTShape>( Master, "com.sun.star.drawing.GroupShape" ), mpTextListStyle ); + pMasterPersistPtr->setLayoutPath( aLayoutFragmentPath ); + rFilter.getMasterPages().push_back( pMasterPersistPtr ); + rFilter.setActualSlidePersist( pMasterPersistPtr ); + FragmentHandlerRef xMasterFragmentHandler( new SlideFragmentHandler( rFilter, aMasterFragmentPath, pMasterPersistPtr, Master ) ); + + // set the correct theme + OUString aThemeFragmentPath = xMasterFragmentHandler->getFragmentPathFromFirstTypeFromOfficeDoc( u"theme" ); + if( !aThemeFragmentPath.isEmpty() ) + { + std::map< OUString, oox::drawingml::ThemePtr >& rThemes( rFilter.getThemes() ); + std::map< OUString, oox::drawingml::ThemePtr >::iterator aIter2( rThemes.find( aThemeFragmentPath ) ); + if( aIter2 == rThemes.end() ) + { + oox::drawingml::ThemePtr pThemePtr = std::make_shared<oox::drawingml::Theme>(); + pMasterPersistPtr->setTheme( pThemePtr ); + Reference<xml::dom::XDocument> xDoc= + rFilter.importFragment(aThemeFragmentPath); + + auto pTheme = std::make_shared<model::Theme>(); + pThemePtr->setTheme(pTheme); + + rFilter.importFragment( + new ThemeFragmentHandler(rFilter, aThemeFragmentPath, *pThemePtr, *pTheme), + Reference<xml::sax::XFastSAXSerializable>( + xDoc, + UNO_QUERY_THROW)); + rThemes[ aThemeFragmentPath ] = pThemePtr; + pThemePtr->setFragment(xDoc); + saveThemeToGrabBag(pThemePtr, nIndex + 1); + } + else + { + pMasterPersistPtr->setTheme( (*aIter2).second ); + } + } + importSlide( xMasterFragmentHandler, pMasterPersistPtr ); + rFilter.importFragment( new LayoutFragmentHandler( rFilter, aLayoutFragmentPath, pMasterPersistPtr ) ); + pMasterPersistPtr->createBackground( rFilter ); + pMasterPersistPtr->createXShapes( rFilter ); + + oox::drawingml::ThemePtr pTheme = pMasterPersistPtr->getTheme(); + if (pTheme) + { + pTheme->addTheme(pMasterPersistPtr->getPage()); + } + + if (pMasterPersistPtr->getLayoutPath() == rLayoutFragmentPath) + { + pMasterPtr = pMasterPersistPtr; + } } - return pMasterPersistPtr; + return pMasterPtr; } void PresentationFragmentHandler::saveThemeToGrabBag(const oox::drawingml::ThemePtr& pThemePtr, |