diff options
Diffstat (limited to 'oox/source')
-rw-r--r-- | oox/source/drawingml/ThemeOverrideFragmentHandler.cxx | 19 | ||||
-rw-r--r-- | oox/source/drawingml/clrschemecontext.cxx | 45 | ||||
-rw-r--r-- | oox/source/drawingml/diagram/diagramhelper.cxx | 4 | ||||
-rw-r--r-- | oox/source/drawingml/shape.cxx | 4 | ||||
-rw-r--r-- | oox/source/drawingml/themeelementscontext.cxx | 32 | ||||
-rw-r--r-- | oox/source/drawingml/themefragmenthandler.cxx | 18 | ||||
-rw-r--r-- | oox/source/ppt/presentationfragmenthandler.cxx | 4 | ||||
-rw-r--r-- | oox/source/shape/ShapeContextHandler.cxx | 3 |
8 files changed, 82 insertions, 47 deletions
diff --git a/oox/source/drawingml/ThemeOverrideFragmentHandler.cxx b/oox/source/drawingml/ThemeOverrideFragmentHandler.cxx index 1be56980cff8..72f93a7e2581 100644 --- a/oox/source/drawingml/ThemeOverrideFragmentHandler.cxx +++ b/oox/source/drawingml/ThemeOverrideFragmentHandler.cxx @@ -8,17 +8,18 @@ */ #include <drawingml/ThemeOverrideFragmentHandler.hxx> -#include <oox/drawingml/theme.hxx> #include <oox/token/namespaces.hxx> #include <drawingml/themeelementscontext.hxx> using namespace ::oox::core; -namespace oox::drawingml { +namespace oox::drawingml +{ -ThemeOverrideFragmentHandler::ThemeOverrideFragmentHandler( XmlFilterBase& rFilter, const OUString& rFragmentPath, Theme& rTheme ) : - FragmentHandler2( rFilter, rFragmentPath ), - mrTheme( rTheme ) +ThemeOverrideFragmentHandler::ThemeOverrideFragmentHandler(XmlFilterBase& rFilter, const OUString& rFragmentPath, Theme& rOoxTheme, model::Theme& rTheme) + : FragmentHandler2(rFilter, rFragmentPath) + , mrOoxTheme(rOoxTheme) + , mrTheme(rTheme) { } @@ -26,16 +27,16 @@ ThemeOverrideFragmentHandler::~ThemeOverrideFragmentHandler() { } -ContextHandlerRef ThemeOverrideFragmentHandler::onCreateContext( sal_Int32 nElement, const AttributeList& ) +ContextHandlerRef ThemeOverrideFragmentHandler::onCreateContext(sal_Int32 nElement, const AttributeList& /*rAttribute*/) { // CT_OfficeStyleSheet - switch( getCurrentElement() ) + switch (getCurrentElement()) { case XML_ROOT_CONTEXT: - switch( nElement ) + switch (nElement) { case A_TOKEN( themeOverride ): // CT_BaseStylesOverride - return new ThemeElementsContext( *this, mrTheme ); + return new ThemeElementsContext(*this, mrOoxTheme, mrTheme); } break; } diff --git a/oox/source/drawingml/clrschemecontext.cxx b/oox/source/drawingml/clrschemecontext.cxx index e8850974c683..5e423f3a7e8a 100644 --- a/oox/source/drawingml/clrschemecontext.cxx +++ b/oox/source/drawingml/clrschemecontext.cxx @@ -57,21 +57,44 @@ clrMapContext::clrMapContext( ContextHandler2Helper const & rParent, setClrMap( rAttributes, rClrMap, XML_folHlink ); } -clrSchemeColorContext::clrSchemeColorContext( ContextHandler2Helper const & rParent, ClrScheme& rClrScheme, sal_Int32 nColorToken ) : - ColorContext( rParent, *this ), - mrClrScheme( rClrScheme ), - mnColorToken( nColorToken ) +clrSchemeColorContext::clrSchemeColorContext(ContextHandler2Helper const & rParent, ClrScheme& rClrScheme, model::ColorSet& rColorSet, sal_Int32 nColorToken) + : ColorContext(rParent, *this) + , mrClrScheme(rClrScheme) + , mrColorSet(rColorSet) + , mnColorToken(nColorToken) { } clrSchemeColorContext::~clrSchemeColorContext() { - mrClrScheme.setColor( mnColorToken, getColor( getFilter().getGraphicHelper() ) ); + ::Color aColor = getColor(getFilter().getGraphicHelper()); + mrClrScheme.setColor(mnColorToken, aColor); + switch (mnColorToken) + { + case XML_tx1: + case XML_dk1: mrColorSet.add(model::ThemeColorType::Dark1, aColor); break; + case XML_bg1: + case XML_lt1: mrColorSet.add(model::ThemeColorType::Light1, aColor); break; + case XML_tx2: + case XML_dk2: mrColorSet.add(model::ThemeColorType::Dark2, aColor); break; + case XML_bg2: + case XML_lt2: mrColorSet.add(model::ThemeColorType::Light2, aColor); break; + case XML_accent1: mrColorSet.add(model::ThemeColorType::Accent1, aColor); break; + case XML_accent2: mrColorSet.add(model::ThemeColorType::Accent2, aColor); break; + case XML_accent3: mrColorSet.add(model::ThemeColorType::Accent3, aColor); break; + case XML_accent4: mrColorSet.add(model::ThemeColorType::Accent4, aColor); break; + case XML_accent5: mrColorSet.add(model::ThemeColorType::Accent5, aColor); break; + case XML_accent6: mrColorSet.add(model::ThemeColorType::Accent6, aColor); break; + case XML_hlink: mrColorSet.add(model::ThemeColorType::Hyperlink, aColor); break; + case XML_folHlink: mrColorSet.add(model::ThemeColorType::FollowedHyperlink, aColor); break; + default: break; + } } -clrSchemeContext::clrSchemeContext( ContextHandler2Helper const & rParent, ClrScheme& rClrScheme ) : - ContextHandler2( rParent ), - mrClrScheme( rClrScheme ) +clrSchemeContext::clrSchemeContext(ContextHandler2Helper const & rParent, ClrScheme& rClrScheme, model::ColorSet& rColorSet) + : ContextHandler2(rParent) + , mrClrScheme(rClrScheme) + , mrColorSet(rColorSet) { } @@ -81,9 +104,13 @@ ContextHandlerRef clrSchemeContext::onCreateContext( switch( nElement ) { case A_TOKEN( dk1 ): + case A_TOKEN( tx1 ): case A_TOKEN( lt1 ): + case A_TOKEN( bg1 ): case A_TOKEN( dk2 ): + case A_TOKEN( tx2 ): case A_TOKEN( lt2 ): + case A_TOKEN( bg2 ): case A_TOKEN( accent1 ): case A_TOKEN( accent2 ): case A_TOKEN( accent3 ): @@ -92,7 +119,7 @@ ContextHandlerRef clrSchemeContext::onCreateContext( case A_TOKEN( accent6 ): case A_TOKEN( hlink ): case A_TOKEN( folHlink ): - return new clrSchemeColorContext( *this, mrClrScheme, getBaseToken( nElement ) ); + return new clrSchemeColorContext(*this, mrClrScheme, mrColorSet, getBaseToken(nElement)); } return nullptr; } diff --git a/oox/source/drawingml/diagram/diagramhelper.cxx b/oox/source/drawingml/diagram/diagramhelper.cxx index e0e7202d3966..daf3047b6433 100644 --- a/oox/source/drawingml/diagram/diagramhelper.cxx +++ b/oox/source/drawingml/diagram/diagramhelper.cxx @@ -251,11 +251,11 @@ const std::shared_ptr< ::oox::drawingml::Theme >& AdvancedDiagramHelper::getOrCr // reset local Theme ModelData *always* to get rid of former data that would // else be added additionally const_cast<AdvancedDiagramHelper*>(this)->mpThemePtr = std::make_shared<oox::drawingml::Theme>(); + model::Theme aTheme; // import Theme ModelData rxFilter->importFragment( - new ThemeFragmentHandler( - *rxFilter, OUString(), *mpThemePtr ), + new ThemeFragmentHandler(*rxFilter, OUString(), *mpThemePtr, aTheme), uno::Reference< css::xml::sax::XFastSAXSerializable >( xThemeDocument, uno::UNO_QUERY_THROW)); diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx index fac027376784..ccfd61410bd5 100644 --- a/oox/source/drawingml/shape.cxx +++ b/oox/source/drawingml/shape.cxx @@ -2170,9 +2170,9 @@ void Shape::finalizeXShape( XmlFilterBase& rFilter, const Reference< XShapes >& rFilter.importFragment(aThemeOverrideFragmentPath), uno::UNO_QUERY_THROW); pTheme = pPowerPointImport->getActualSlidePersist()->getTheme(); auto pThemeOverride = std::make_shared<Theme>(*pTheme); + model::Theme aTheme; rFilter.importFragment( - new ThemeOverrideFragmentHandler(rFilter, aThemeOverrideFragmentPath, - *pThemeOverride), + new ThemeOverrideFragmentHandler(rFilter, aThemeOverrideFragmentPath, *pThemeOverride, aTheme), xDoc); pPowerPointImport->getActualSlidePersist()->setTheme(pThemeOverride); } diff --git a/oox/source/drawingml/themeelementscontext.cxx b/oox/source/drawingml/themeelementscontext.cxx index cb62f4ef0a70..fdc691427040 100644 --- a/oox/source/drawingml/themeelementscontext.cxx +++ b/oox/source/drawingml/themeelementscontext.cxx @@ -213,45 +213,49 @@ void FontSchemeContext::onEndElement() } } -ThemeElementsContext::ThemeElementsContext( ContextHandler2Helper const & rParent, Theme& rTheme ) : - ContextHandler2( rParent ), - mrTheme( rTheme ) +ThemeElementsContext::ThemeElementsContext(ContextHandler2Helper const & rParent, Theme& rOoxTheme, model::Theme& rTheme) + : ContextHandler2(rParent) + , mrOoxTheme(rOoxTheme) + , mrTheme(rTheme) { } -ContextHandlerRef ThemeElementsContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ) +ContextHandlerRef ThemeElementsContext::onCreateContext(sal_Int32 nElement, const AttributeList& rAttribs) { // CT_BaseStyles - switch( nElement ) + switch (nElement) { case A_TOKEN( clrScheme ): // CT_ColorScheme { + OUString aColorSchemeName = rAttribs.getStringDefaulted(XML_name); + mrTheme.SetColorSet(std::make_unique<model::ColorSet>(aColorSchemeName)); if (rAttribs.hasAttribute(XML_name)) - mrTheme.getClrScheme().SetName(rAttribs.getStringDefaulted(XML_name)); - return new clrSchemeContext(*this, mrTheme.getClrScheme()); + mrOoxTheme.getClrScheme().SetName(rAttribs.getStringDefaulted(XML_name)); + return new clrSchemeContext(*this, mrOoxTheme.getClrScheme(), *mrTheme.GetColorSet()); } case A_TOKEN( fontScheme ): // CT_FontScheme { if (rAttribs.hasAttribute(XML_name)) - mrTheme.setFontSchemeName(rAttribs.getStringDefaulted(XML_name)); - return new FontSchemeContext(*this, mrTheme.getFontScheme(), mrTheme.getSupplementalFontMap()); + mrOoxTheme.setFontSchemeName(rAttribs.getStringDefaulted(XML_name)); + + return new FontSchemeContext(*this, mrOoxTheme.getFontScheme(), mrOoxTheme.getSupplementalFontMap()); } case A_TOKEN( fmtScheme ): // CT_StyleMatrix { if (rAttribs.hasAttribute(XML_name)) - mrTheme.setFormatSchemeName(rAttribs.getStringDefaulted(XML_name)); + mrOoxTheme.setFormatSchemeName(rAttribs.getStringDefaulted(XML_name)); return this; } case A_TOKEN( fillStyleLst ): // CT_FillStyleList - return new FillStyleListContext( *this, mrTheme.getFillStyleList() ); + return new FillStyleListContext( *this, mrOoxTheme.getFillStyleList() ); case A_TOKEN( lnStyleLst ): // CT_LineStyleList - return new LineStyleListContext( *this, mrTheme.getLineStyleList() ); + return new LineStyleListContext( *this, mrOoxTheme.getLineStyleList() ); case A_TOKEN( effectStyleLst ): // CT_EffectStyleList - return new EffectStyleListContext( *this, mrTheme.getEffectStyleList() ); + return new EffectStyleListContext( *this, mrOoxTheme.getEffectStyleList() ); case A_TOKEN( bgFillStyleLst ): // CT_BackgroundFillStyleList - return new FillStyleListContext( *this, mrTheme.getBgFillStyleList() ); + return new FillStyleListContext( *this, mrOoxTheme.getBgFillStyleList() ); } return nullptr; } diff --git a/oox/source/drawingml/themefragmenthandler.cxx b/oox/source/drawingml/themefragmenthandler.cxx index db2d6677567d..baaec066219b 100644 --- a/oox/source/drawingml/themefragmenthandler.cxx +++ b/oox/source/drawingml/themefragmenthandler.cxx @@ -26,11 +26,13 @@ using namespace ::oox::core; -namespace oox::drawingml { +namespace oox::drawingml +{ -ThemeFragmentHandler::ThemeFragmentHandler( XmlFilterBase& rFilter, const OUString& rFragmentPath, Theme& rTheme ) : - FragmentHandler2( rFilter, rFragmentPath ), - mrTheme( rTheme ) +ThemeFragmentHandler::ThemeFragmentHandler(XmlFilterBase& rFilter, const OUString& rFragmentPath, Theme& rOoxTheme, model::Theme& rTheme) + : FragmentHandler2(rFilter, rFragmentPath) + , mrOoxTheme(rOoxTheme) + , mrTheme(rTheme) { } @@ -43,12 +45,12 @@ ContextHandlerRef ThemeFragmentHandler::onCreateContext( sal_Int32 nElement, con // CT_OfficeStyleSheet if (getCurrentElement() == A_TOKEN(theme)) { - switch(nElement) + switch (nElement) { case A_TOKEN( themeElements ): // CT_BaseStyles - return new ThemeElementsContext( *this, mrTheme ); + return new ThemeElementsContext(*this, mrOoxTheme, mrTheme); case A_TOKEN( objectDefaults ): // CT_ObjectStyleDefaults - return new objectDefaultContext( *this, mrTheme ); + return new objectDefaultContext(*this, mrOoxTheme); case A_TOKEN( extraClrSchemeLst ): // CT_ColorSchemeList return nullptr; case A_TOKEN( custClrLst ): // CustomColorList @@ -69,7 +71,7 @@ void ThemeFragmentHandler::onStartElement(const AttributeList& rAttribs) { if (getCurrentElement() == A_TOKEN(theme)) { - mrTheme.setThemeName(rAttribs.getStringDefaulted(XML_name)); + mrOoxTheme.setThemeName(rAttribs.getStringDefaulted(XML_name)); } } diff --git a/oox/source/ppt/presentationfragmenthandler.cxx b/oox/source/ppt/presentationfragmenthandler.cxx index c3bfc9cab9e2..b8906c735d16 100644 --- a/oox/source/ppt/presentationfragmenthandler.cxx +++ b/oox/source/ppt/presentationfragmenthandler.cxx @@ -351,9 +351,9 @@ void PresentationFragmentHandler::importSlide(sal_uInt32 nSlide, bool bFirstPage Reference<xml::dom::XDocument> xDoc= rFilter.importFragment(aThemeFragmentPath); + model::Theme aTheme; rFilter.importFragment( - new ThemeFragmentHandler( - rFilter, aThemeFragmentPath, *pThemePtr ), + new ThemeFragmentHandler(rFilter, aThemeFragmentPath, *pThemePtr, aTheme), Reference<xml::sax::XFastSAXSerializable>( xDoc, UNO_QUERY_THROW)); diff --git a/oox/source/shape/ShapeContextHandler.cxx b/oox/source/shape/ShapeContextHandler.cxx index a0d10e12bbc9..b6d4bcab0345 100644 --- a/oox/source/shape/ShapeContextHandler.cxx +++ b/oox/source/shape/ShapeContextHandler.cxx @@ -280,8 +280,9 @@ void SAL_CALL ShapeContextHandler::startFastElement if(!aThemeFragmentPath.isEmpty()) { + model::Theme aTheme; uno::Reference<xml::sax::XFastSAXSerializable> xDoc(mxShapeFilterBase->importFragment(aThemeFragmentPath), uno::UNO_QUERY_THROW); - mxShapeFilterBase->importFragment(new ThemeFragmentHandler(*mxShapeFilterBase, aThemeFragmentPath, *mpThemePtr ), xDoc); + mxShapeFilterBase->importFragment(new ThemeFragmentHandler(*mxShapeFilterBase, aThemeFragmentPath, *mpThemePtr, aTheme), xDoc); mxShapeFilterBase->setCurrentTheme(mpThemePtr); } } |