summaryrefslogtreecommitdiff
path: root/oox
diff options
context:
space:
mode:
authorSzymon Kłos <szymon.klos@collabora.com>2017-10-17 22:14:38 +0200
committerAndras Timar <andras.timar@collabora.com>2017-11-06 14:35:34 +0100
commitc99f02e17f436a5887578f0da55e4daae78a2ca6 (patch)
tree335a1d0d6b0cf97f780b6508b5b97f4ebcd1f588 /oox
parent2342ab86aa31a9e7795742ba4b72ad06ad312b9e (diff)
PPTX export: remember color schemes in theme
Remember color scheme from loaded pptx file or use default values. Change-Id: Icb69c51603afc5f332c20c75e4ed5f659f4b5614 Reviewed-on: https://gerrit.libreoffice.org/43470 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Szymon Kłos <szymon.klos@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/44321 Reviewed-by: Andras Timar <andras.timar@collabora.com> Tested-by: Andras Timar <andras.timar@collabora.com>
Diffstat (limited to 'oox')
-rw-r--r--oox/source/export/drawingml.cxx2
-rw-r--r--oox/source/ppt/presentationfragmenthandler.cxx76
2 files changed, 77 insertions, 1 deletions
diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index 7a142d9ed8bc..686c8b3c8549 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -2904,7 +2904,7 @@ void DrawingML::WriteStyleProperties( sal_Int32 nTokenId, const Sequence< Proper
aProperties[i].Value >>= aTransformations;
}
mpFS->startElementNS( XML_a, nTokenId, XML_idx, I32S( nIdx ), FSEND );
- WriteColor( sSchemeClr, aTransformations );
+ WriteColor(sSchemeClr, aTransformations);
mpFS->endElementNS( XML_a, nTokenId );
}
else
diff --git a/oox/source/ppt/presentationfragmenthandler.cxx b/oox/source/ppt/presentationfragmenthandler.cxx
index 41a283a445d1..6b157877db9a 100644
--- a/oox/source/ppt/presentationfragmenthandler.cxx
+++ b/oox/source/ppt/presentationfragmenthandler.cxx
@@ -64,6 +64,22 @@ using namespace ::com::sun::star::xml::sax;
namespace oox { namespace ppt {
+static std::map<PredefinedClrSchemeId, sal_Int32> PredefinedClrTokens =
+{
+ //{ dk1, XML_dk1 },
+ //{ lt1, XML_lt1 },
+ { dk2, XML_dk2 },
+ { lt2, XML_lt2 },
+ { accent1, XML_accent1 },
+ { accent2, XML_accent2 },
+ { accent3, XML_accent3 },
+ { accent4, XML_accent4 },
+ { accent5, XML_accent5 },
+ { accent6, XML_accent6 },
+ { hlink, XML_hlink },
+ { folHlink, XML_folHlink }
+};
+
PresentationFragmentHandler::PresentationFragmentHandler( XmlFilterBase& rFilter, const OUString& rFragmentPath ) throw()
: FragmentHandler2( rFilter, rFragmentPath )
, mpTextListStyle( new TextListStyle )
@@ -143,6 +159,65 @@ void ResolveTextFields( XmlFilterBase& rFilter )
}
}
+void PresentationFragmentHandler::saveThemeToGrabBag(oox::drawingml::ThemePtr pThemePtr, const OUString& sTheme)
+{
+ if (!pThemePtr)
+ return;
+
+ try
+ {
+ uno::Reference<beans::XPropertySet> xDocProps(getFilter().getModel(), uno::UNO_QUERY);
+ if (xDocProps.is())
+ {
+ uno::Reference<beans::XPropertySetInfo> xPropsInfo = xDocProps->getPropertySetInfo();
+
+ const OUString aGrabBagPropName = "InteropGrabBag";
+ if (xPropsInfo.is() && xPropsInfo->hasPropertyByName(aGrabBagPropName))
+ {
+ // get existing grab bag
+ comphelper::SequenceAsHashMap aGrabBag(xDocProps->getPropertyValue(aGrabBagPropName));
+
+ uno::Sequence<beans::PropertyValue> aTheme(1);
+ comphelper::SequenceAsHashMap aThemesHashMap;
+
+ // create current theme
+ uno::Sequence<beans::PropertyValue> aCurrentTheme(PredefinedClrSchemeId::Count);
+
+ ClrScheme rClrScheme = pThemePtr->getClrScheme();
+ for (int nId = PredefinedClrSchemeId::dk2; nId != PredefinedClrSchemeId::Count; nId++)
+ {
+ sal_uInt32 nToken = PredefinedClrTokens[static_cast<PredefinedClrSchemeId>(nId)];
+ const OUString& sName = PredefinedClrNames[static_cast<PredefinedClrSchemeId>(nId)];
+ sal_Int32 nColor = 0;
+
+ rClrScheme.getColor(nToken, nColor);
+ const uno::Any& rColor = uno::makeAny(nColor);
+
+ aCurrentTheme[nId].Name = sName;
+ aCurrentTheme[nId].Value = rColor;
+ }
+
+ // add new theme to the sequence
+ aTheme[0].Name = sTheme;
+ const uno::Any& rCurrentTheme = makeAny(aCurrentTheme);
+ aTheme[0].Value = rCurrentTheme;
+
+ aThemesHashMap << aTheme;
+
+ // put the new items
+ aGrabBag.update(aThemesHashMap);
+
+ // put it back to the document
+ xDocProps->setPropertyValue(aGrabBagPropName, uno::Any(aGrabBag.getAsConstPropertyValueList()));
+ }
+ }
+ }
+ catch (const uno::Exception&)
+ {
+ SAL_WARN("oox", "oox::ppt::PresentationFragmentHandler::saveThemeToGrabBag, Failed to save grab bag");
+ }
+}
+
void PresentationFragmentHandler::importSlide(sal_uInt32 nSlide, bool bFirstPage, bool bImportNotesPage)
{
PowerPointImport& rFilter = dynamic_cast< PowerPointImport& >( getFilter() );
@@ -232,6 +307,7 @@ void PresentationFragmentHandler::importSlide(sal_uInt32 nSlide, bool bFirstPage
UNO_QUERY_THROW));
rThemes[ aThemeFragmentPath ] = pThemePtr;
pThemePtr->setFragment(xDoc);
+ saveThemeToGrabBag(pThemePtr, aThemeFragmentPath);
}
else
{