include/oox/drawingml/color.hxx | 4 ++-- oox/source/drawingml/color.cxx | 4 ++-- oox/source/drawingml/fillproperties.cxx | 6 ++++++ oox/source/token/properties.txt | 2 ++ svx/qa/unit/data/theme.pptx |binary svx/qa/unit/styles.cxx | 26 ++++++++++++++++++++++++-- svx/source/styles/ColorSets.cxx | 9 +++++++++ 7 files changed, 45 insertions(+), 6 deletions(-)
New commits: commit 4b304a96719f78cf531dc2ce1a67618615f318c7 Author: Miklos Vajna <[email protected]> AuthorDate: Wed Apr 27 20:12:52 2022 +0200 Commit: Miklos Vajna <[email protected]> CommitDate: Fri Jul 1 11:42:03 2022 +0200 sd theme: add PPTX import for shape fill color effects This is always direct formatting, so FillProperties::pushToPropMap() always has the needed info at hand. (cherry picked from commit 30735bdb5a0a81619000fdd24b2d0fbf45687f01) Change-Id: I3317b618e0e8bb7688d0f0fbfe4546e2e8b4e947 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136716 Tested-by: Jenkins CollaboraOffice <[email protected]> Reviewed-by: Miklos Vajna <[email protected]> diff --git a/include/oox/drawingml/color.hxx b/include/oox/drawingml/color.hxx index c0dd8d67a31c..cc65c1346720 100644 --- a/include/oox/drawingml/color.hxx +++ b/include/oox/drawingml/color.hxx @@ -100,8 +100,8 @@ public: const OUString& getSchemeColorName() const { return msSchemeName; } sal_Int16 getSchemeColorIndex() const; sal_Int16 getTintOrShade(); - sal_Int16 getLumMod(); - sal_Int16 getLumOff(); + sal_Int16 getLumMod() const; + sal_Int16 getLumOff() const; /** Returns the unaltered list of transformations for interoperability purposes */ const css::uno::Sequence< css::beans::PropertyValue >& getTransformations() const { return maInteropTransformations;} diff --git a/oox/source/drawingml/color.cxx b/oox/source/drawingml/color.cxx index ee854a761fa2..982b77ff4831 100644 --- a/oox/source/drawingml/color.cxx +++ b/oox/source/drawingml/color.cxx @@ -496,7 +496,7 @@ sal_Int16 Color::getTintOrShade() return 0; } -sal_Int16 Color::getLumMod() +sal_Int16 Color::getLumMod() const { for (const auto& rTransform : maTransforms) { @@ -512,7 +512,7 @@ sal_Int16 Color::getLumMod() return 10000; } -sal_Int16 Color::getLumOff() +sal_Int16 Color::getLumOff() const { for (const auto& rTransform : maTransforms) { diff --git a/oox/source/drawingml/fillproperties.cxx b/oox/source/drawingml/fillproperties.cxx index f0b092bbb774..87b0e62a6fa4 100644 --- a/oox/source/drawingml/fillproperties.cxx +++ b/oox/source/drawingml/fillproperties.cxx @@ -403,6 +403,12 @@ void FillProperties::pushToPropMap( ShapePropertyMap& rPropMap, { rPropMap.setProperty(PROP_FillColorTheme, nPhClrTheme); } + else + { + rPropMap.setProperty(PROP_FillColorTheme, maFillColor.getSchemeColorIndex()); + rPropMap.setProperty(PROP_FillColorLumMod, maFillColor.getLumMod()); + rPropMap.setProperty(PROP_FillColorLumOff, maFillColor.getLumOff()); + } eFillStyle = FillStyle_SOLID; } diff --git a/oox/source/token/properties.txt b/oox/source/token/properties.txt index e318e0038ecb..8467d3683875 100644 --- a/oox/source/token/properties.txt +++ b/oox/source/token/properties.txt @@ -177,6 +177,8 @@ FillBitmapSizeY FillBitmap FillColor FillColorTheme +FillColorLumMod +FillColorLumOff FillGradient FillGradientName FillHatch diff --git a/svx/qa/unit/styles.cxx b/svx/qa/unit/styles.cxx index ce9a039ce453..dd27e24f02ae 100644 --- a/svx/qa/unit/styles.cxx +++ b/svx/qa/unit/styles.cxx @@ -94,17 +94,26 @@ CPPUNIT_TEST_FIXTURE(Test, testThemeChange) // Blue. CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0x4472c4), GetShapeFillColor(xShape4)); // The theme index of this filled shape is set by the PPTX import: - sal_Int32 nColorTheme = -1; + sal_Int16 nColorTheme = -1; xShape4->getPropertyValue("FillColorTheme") >>= nColorTheme; // 4 means accent1, this was -1 without the PPTX import bit in place. - CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(4), nColorTheme); + CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16>(4), nColorTheme); uno::Reference<beans::XPropertySet> xShape5(xDrawPageShapes->getByIndex(5), uno::UNO_QUERY); // Blue, lighter. CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0xb4c7e7), GetShapeFillColor(xShape5)); - // Set theme index to accent 1 & effects till PPTX import is missing. - xShape5->setPropertyValue("FillColorTheme", uno::makeAny(static_cast<sal_Int16>(4))); - xShape5->setPropertyValue("FillColorLumMod", uno::makeAny(static_cast<sal_Int16>(4000))); - xShape5->setPropertyValue("FillColorLumOff", uno::makeAny(static_cast<sal_Int16>(6000))); + // The theme index, and effects (lum mod, lum off) are set by the PPTX import: + nColorTheme = -1; + xShape5->getPropertyValue("FillColorTheme") >>= nColorTheme; + // 4 means accent1, this was -1 without the PPTX import bit in place. + CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16>(4), nColorTheme); + sal_Int16 nColorLumMod = 10000; + xShape5->getPropertyValue("FillColorLumMod") >>= nColorLumMod; + // This was 10000 without the PPTX import bit in place. + CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16>(4000), nColorLumMod); + sal_Int16 nColorLumOff = 0; + xShape5->getPropertyValue("FillColorLumOff") >>= nColorLumOff; + // This was 0 without the PPTX import bit in place. + CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16>(6000), nColorLumOff); // When changing the master slide of slide 1 to use the theme of the second master slide: uno::Reference<drawing::XMasterPageTarget> xDrawPage2( commit 777ede8e59de396487180da01b50116f223a3316 Author: Miklos Vajna <[email protected]> AuthorDate: Thu Apr 21 20:08:06 2022 +0200 Commit: Miklos Vajna <[email protected]> CommitDate: Fri Jul 1 11:41:37 2022 +0200 sd theme: add rendering for shape fill color effects Only the no-effects variant was working previously. (cherry picked from commit 1f2a07e06b440ff1b15d66c2a2e72338301cdf0a) Change-Id: I50811a4c49d19dc801f0d1c841cbbdb2fae1ad60 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136715 Tested-by: Jenkins CollaboraOffice <[email protected]> Reviewed-by: Miklos Vajna <[email protected]> diff --git a/svx/qa/unit/data/theme.pptx b/svx/qa/unit/data/theme.pptx index ebed899cd42c..08e4a3b6f130 100644 Binary files a/svx/qa/unit/data/theme.pptx and b/svx/qa/unit/data/theme.pptx differ diff --git a/svx/qa/unit/styles.cxx b/svx/qa/unit/styles.cxx index 3bfa6d8cf09b..ce9a039ce453 100644 --- a/svx/qa/unit/styles.cxx +++ b/svx/qa/unit/styles.cxx @@ -98,6 +98,13 @@ CPPUNIT_TEST_FIXTURE(Test, testThemeChange) xShape4->getPropertyValue("FillColorTheme") >>= nColorTheme; // 4 means accent1, this was -1 without the PPTX import bit in place. CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(4), nColorTheme); + uno::Reference<beans::XPropertySet> xShape5(xDrawPageShapes->getByIndex(5), uno::UNO_QUERY); + // Blue, lighter. + CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0xb4c7e7), GetShapeFillColor(xShape5)); + // Set theme index to accent 1 & effects till PPTX import is missing. + xShape5->setPropertyValue("FillColorTheme", uno::makeAny(static_cast<sal_Int16>(4))); + xShape5->setPropertyValue("FillColorLumMod", uno::makeAny(static_cast<sal_Int16>(4000))); + xShape5->setPropertyValue("FillColorLumOff", uno::makeAny(static_cast<sal_Int16>(6000))); // When changing the master slide of slide 1 to use the theme of the second master slide: uno::Reference<drawing::XMasterPageTarget> xDrawPage2( @@ -126,6 +133,12 @@ CPPUNIT_TEST_FIXTURE(Test, testThemeChange) // - Expected: 9486886 (#90c226, green) // - Actual : 4485828 (#4472c4, blue) CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0x90c226), GetShapeFillColor(xShape4)); + // Green, lighter: + // Without the accompanying fix in place, this test would have failed with: + // - Expected: 14020002 (#d5eda2, light green) + // - Actual : 9486886 (#90c226, green) + // i.e. the "light" effect on green was not applied. + CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0xd5eda2), GetShapeFillColor(xShape5)); } } diff --git a/svx/source/styles/ColorSets.cxx b/svx/source/styles/ColorSets.cxx index 5dcd089fd4ba..895ae91c8e47 100644 --- a/svx/source/styles/ColorSets.cxx +++ b/svx/source/styles/ColorSets.cxx @@ -80,6 +80,15 @@ void UpdateFillColorSet(const uno::Reference<beans::XPropertySet>& xShape, svx:: } Color aColor = rColorSet.getColor(nFillColorTheme); + sal_Int32 nFillColorLumMod{}; + xShape->getPropertyValue(UNO_NAME_FILLCOLOR_LUM_MOD) >>= nFillColorLumMod; + sal_Int32 nFillColorLumOff{}; + xShape->getPropertyValue(UNO_NAME_FILLCOLOR_LUM_OFF) >>= nFillColorLumOff; + if (nFillColorLumMod != 10000 || nFillColorLumOff != 0) + { + aColor.ApplyLumModOff(nFillColorLumMod, nFillColorLumOff); + } + xShape->setPropertyValue(UNO_NAME_FILLCOLOR, uno::makeAny(static_cast<sal_Int32>(aColor))); }
