diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2023-08-16 22:06:23 +0300 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2023-08-16 23:31:06 +0200 |
commit | 953e586dbce1c3195ecb07b2491b6e1a20a2cd7f (patch) | |
tree | 89560400691c5928b0d7800196f31a23df67bec1 /oox/source/drawingml | |
parent | 930cb8440697d80df0a399d765dc85966732ddce (diff) |
tdf#153012: import chart's c:clrMapOvr element
Otherwise, a wrong mapping could be used, e.g. from slide.
Change-Id: I8b0fcebcd21ac2bab8b7f58d0c24753d2eca02c7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155748
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'oox/source/drawingml')
-rw-r--r-- | oox/source/drawingml/chart/chartspacefragment.cxx | 19 | ||||
-rw-r--r-- | oox/source/drawingml/shape.cxx | 26 |
2 files changed, 40 insertions, 5 deletions
diff --git a/oox/source/drawingml/chart/chartspacefragment.cxx b/oox/source/drawingml/chart/chartspacefragment.cxx index 7f0a6cd549f9..f43908d65cb5 100644 --- a/oox/source/drawingml/chart/chartspacefragment.cxx +++ b/oox/source/drawingml/chart/chartspacefragment.cxx @@ -75,6 +75,25 @@ ContextHandlerRef ChartSpaceFragment::onCreateContext( sal_Int32 nElement, const case C_TOKEN (externalData): mrModel.maSheetPath = getFragmentPathFromRelId(rAttribs.getStringDefaulted(R_TOKEN(id))); return nullptr; + case C_TOKEN(clrMapOvr): + if (mrModel.mpClrMap) + for (auto nClrToken : { + XML_bg1, + XML_tx1, + XML_bg2, + XML_tx2, + XML_accent1, + XML_accent2, + XML_accent3, + XML_accent4, + XML_accent5, + XML_accent6, + XML_hlink, + XML_folHlink, + }) + if (auto oMappedToken = rAttribs.getToken(nClrToken)) + mrModel.mpClrMap->setColorMap(nClrToken, *oMappedToken); + return nullptr; } break; diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx index 78a20b46861b..4f600528b56a 100644 --- a/oox/source/drawingml/shape.cxx +++ b/oox/source/drawingml/shape.cxx @@ -2190,13 +2190,24 @@ void Shape::finalizeXShape( XmlFilterBase& rFilter, const Reference< XShapes >& // in the imported chart data bool bMSO2007Doc = rFilter.isMSO2007Document(); chart::ChartSpaceModel aModel(bMSO2007Doc); + oox::ppt::PowerPointImport* pPowerPointImport + = dynamic_cast<oox::ppt::PowerPointImport*>(&rFilter); + + ClrMapPtr pClrMap; // The original color map + if (pPowerPointImport) + { + // Use a copy of current color map, which the fragment may override locally + pClrMap = pPowerPointImport->getActualSlidePersist()->getClrMap(); + aModel.mpClrMap = pClrMap ? std::make_shared<ClrMap>(*pClrMap) + : std::make_shared<ClrMap>(); + pPowerPointImport->getActualSlidePersist()->setClrMap(aModel.mpClrMap); + } + rtl::Reference<chart::ChartSpaceFragment> pChartSpaceFragment = new chart::ChartSpaceFragment( rFilter, mxChartShapeInfo->maFragmentPath, aModel ); const OUString aThemeOverrideFragmentPath( pChartSpaceFragment-> getFragmentPathFromFirstTypeFromOfficeDoc(u"themeOverride") ); rFilter.importFragment( pChartSpaceFragment ); - ::oox::ppt::PowerPointImport *pPowerPointImport = - dynamic_cast< ::oox::ppt::PowerPointImport* >(&rFilter); // The original theme. ThemePtr pTheme; @@ -2236,10 +2247,15 @@ void Shape::finalizeXShape( XmlFilterBase& rFilter, const Reference< XShapes >& } - if (!aThemeOverrideFragmentPath.isEmpty() && pPowerPointImport) + if (pPowerPointImport) { - // Restore the original theme. - pPowerPointImport->getActualSlidePersist()->setTheme(pTheme); + if (!aThemeOverrideFragmentPath.isEmpty()) + { + // Restore the original theme. + pPowerPointImport->getActualSlidePersist()->setTheme(pTheme); + } + // Restore the original color map + pPowerPointImport->getActualSlidePersist()->setClrMap(pClrMap); } #endif } |