diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2022-03-23 20:06:49 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2022-03-24 08:36:25 +0100 |
commit | 37c41f2c445ecf519f4137c23fb36f3942328b6b (patch) | |
tree | ff6b5562bbd8eeb40ed436b3df66e1b91cc2846c /oox | |
parent | 6f80e618a79ac70bc6658771b64d018cd228200e (diff) |
sd theme: add PPTX export for shape fill color
Do this only in case there are no effects on the color, as that is not
yet handled.
Note that the theme color was already stored in the grab-bag, so this is
primarily interesting in case the theme color was changed or the source
format was ODP.
Change-Id: Ia4995be68d5f243875632eec4aaf8afbb8f4d5cc
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131984
Tested-by: Jenkins
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'oox')
-rw-r--r-- | oox/qa/unit/data/refer-to-theme-shape-fill.odp | bin | 0 -> 15506 bytes | |||
-rw-r--r-- | oox/qa/unit/export.cxx | 19 | ||||
-rw-r--r-- | oox/source/export/drawingml.cxx | 28 |
3 files changed, 46 insertions, 1 deletions
diff --git a/oox/qa/unit/data/refer-to-theme-shape-fill.odp b/oox/qa/unit/data/refer-to-theme-shape-fill.odp Binary files differnew file mode 100644 index 000000000000..b12772e111e3 --- /dev/null +++ b/oox/qa/unit/data/refer-to-theme-shape-fill.odp diff --git a/oox/qa/unit/export.cxx b/oox/qa/unit/export.cxx index 8876d507dd9c..56546384820c 100644 --- a/oox/qa/unit/export.cxx +++ b/oox/qa/unit/export.cxx @@ -396,6 +396,25 @@ CPPUNIT_TEST_FIXTURE(Test, testReferToTheme) assertXPath(pXmlDoc, "//p:sp[3]/p:txBody/a:p/a:r/a:rPr/a:solidFill/a:schemeClr/a:lumOff", 0); } +CPPUNIT_TEST_FIXTURE(Test, testReferToThemeShapeFill) +{ + // Given an ODP file that contains references to a theme for shape fill: + OUString aURL = m_directories.getURLFromSrc(DATA_DIRECTORY) + "refer-to-theme-shape-fill.odp"; + + // When saving that document: + loadAndSave(aURL, "Impress Office Open XML"); + + // Then make sure the shape fill color is a scheme color: + // Without the accompanying fix in place, this test would have failed with: + // - Expected: 1 + // - Actual : 0 + // i.e. the <a:schemeClr> element was not written. Note that this was already working from PPTX + // files via grab-bags, so this test intentionally uses an ODP file as input. + std::unique_ptr<SvStream> pStream = parseExportStream(getTempFile(), "ppt/slides/slide1.xml"); + xmlDocUniquePtr pXmlDoc = parseXmlStream(pStream.get()); + assertXPath(pXmlDoc, "//p:sp[1]/p:spPr/a:solidFill/a:schemeClr", "val", "accent1"); +} + CPPUNIT_TEST_FIXTURE(Test, testTdf146690_endParagraphRunPropertiesNewLinesTextSize) { // Given a PPTX file that contains references to a theme: diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx index 4615bbd39503..85c7a34d5f5f 100644 --- a/oox/source/export/drawingml.cxx +++ b/oox/source/export/drawingml.cxx @@ -551,7 +551,10 @@ void DrawingML::WriteSolidFill( const Reference< XPropertySet >& rXPropSet ) else if ( nFillColor != nOriginalColor ) { // the user has set a different color for the shape - WriteSolidFill( ::Color(ColorTransparency, nFillColor & 0xffffff), nAlpha ); + if (aTransformations.hasElements() || !WriteFillColor(rXPropSet)) + { + WriteSolidFill(::Color(ColorTransparency, nFillColor & 0xffffff), nAlpha); + } } else if ( !sColorFillScheme.isEmpty() ) { @@ -566,6 +569,29 @@ void DrawingML::WriteSolidFill( const Reference< XPropertySet >& rXPropSet ) } } +bool DrawingML::WriteFillColor(const uno::Reference<beans::XPropertySet>& xPropertySet) +{ + if (!xPropertySet->getPropertySetInfo()->hasPropertyByName("FillColorTheme")) + { + return false; + } + + sal_Int32 nFillColorTheme = -1; + xPropertySet->getPropertyValue("FillColorTheme") >>= nFillColorTheme; + if (nFillColorTheme < 0 || nFillColorTheme > 11) + { + return false; + } + + const char* pColorName = g_aPredefinedClrNames[nFillColorTheme]; + + mpFS->startElementNS(XML_a, XML_solidFill); + mpFS->singleElementNS(XML_a, XML_schemeClr, XML_val, pColorName); + mpFS->endElementNS(XML_a, XML_solidFill); + + return true; +} + void DrawingML::WriteGradientStop(sal_uInt16 nStop, ::Color nColor, sal_Int32 nAlpha) { mpFS->startElementNS(XML_a, XML_gs, XML_pos, OString::number(nStop * 1000)); |