diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2023-01-01 23:25:38 +0900 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2023-01-13 00:49:24 +0000 |
commit | 197e5f81213d14fdcbff40edf73385ecd4cd9815 (patch) | |
tree | 5bc1735ec61200a895b5edcf684d846245286ba5 /svx/qa | |
parent | c82fa434dab8744c548db166cd24ee82e8759e1f (diff) |
introduce {Char,Fill}ColorThemeReference which uses XThemeColor
Adds a unified UNO property for theme colors *ColorTheme
(CharColorTheme and FillColorTheme) which uses XThemeColor, that
replaces the properties *Theme, *TintOrShade, *LumOff, *LumMod.
The properties are still present for backwards compatibility and
to keep ODF support working in tests as that needs a bigger change.
Reactor the code and tests to accomodate for this change.
Change-Id: If7983decb4ba528b49fe7b5968aa9efc696a9efc
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144783
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'svx/qa')
-rw-r--r-- | svx/qa/unit/styles.cxx | 43 | ||||
-rw-r--r-- | svx/qa/unit/xoutdev.cxx | 47 |
2 files changed, 49 insertions, 41 deletions
diff --git a/svx/qa/unit/styles.cxx b/svx/qa/unit/styles.cxx index e2b356529ca5..3a4aff375fc7 100644 --- a/svx/qa/unit/styles.cxx +++ b/svx/qa/unit/styles.cxx @@ -13,6 +13,7 @@ #include <com/sun/star/drawing/XDrawPagesSupplier.hpp> #include <com/sun/star/drawing/XMasterPageTarget.hpp> #include <com/sun/star/text/XTextRange.hpp> +#include <docmodel/uno/UnoThemeColor.hxx> using namespace ::com::sun::star; @@ -71,28 +72,34 @@ CPPUNIT_TEST_FIXTURE(Test, testThemeChange) uno::Reference<beans::XPropertySet> xShape4(xDrawPageShapes->getByIndex(4), uno::UNO_QUERY); // 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_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_Int16>(4), nColorTheme); + + // The theme color of this filled shape is set by the PPTX import: + { + uno::Reference<util::XThemeColor> xThemeColor; + CPPUNIT_ASSERT(xShape4->getPropertyValue("FillColorThemeReference") >>= xThemeColor); + CPPUNIT_ASSERT(xThemeColor.is()); + model::ThemeColor aThemeColor; + model::theme::setFromXThemeColor(aThemeColor, xThemeColor); + CPPUNIT_ASSERT_EQUAL(model::ThemeColorType::Accent1, aThemeColor.getType()); + } uno::Reference<beans::XPropertySet> xShape5(xDrawPageShapes->getByIndex(5), uno::UNO_QUERY); // Blue, lighter. CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0xb4c7e7), GetShapeFillColor(xShape5)); // 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); - + { + uno::Reference<util::XThemeColor> xThemeColor; + CPPUNIT_ASSERT(xShape5->getPropertyValue("FillColorThemeReference") >>= xThemeColor); + CPPUNIT_ASSERT(xThemeColor.is()); + model::ThemeColor aThemeColor; + model::theme::setFromXThemeColor(aThemeColor, xThemeColor); + CPPUNIT_ASSERT_EQUAL(model::ThemeColorType::Accent1, aThemeColor.getType()); + CPPUNIT_ASSERT_EQUAL(model::TransformationType::LumMod, + aThemeColor.getTransformations()[0].meType); + CPPUNIT_ASSERT_EQUAL(sal_Int16(4000), aThemeColor.getTransformations()[0].mnValue); + CPPUNIT_ASSERT_EQUAL(model::TransformationType::LumOff, + aThemeColor.getTransformations()[1].meType); + CPPUNIT_ASSERT_EQUAL(sal_Int16(6000), aThemeColor.getTransformations()[1].mnValue); + } // When changing the master slide of slide 1 to use the theme of the second master slide: uno::Reference<drawing::XMasterPageTarget> xDrawPage2( xDrawPagesSupplier->getDrawPages()->getByIndex(1), uno::UNO_QUERY); diff --git a/svx/qa/unit/xoutdev.cxx b/svx/qa/unit/xoutdev.cxx index 22b304e00579..6cd68a0c8172 100644 --- a/svx/qa/unit/xoutdev.cxx +++ b/svx/qa/unit/xoutdev.cxx @@ -19,6 +19,7 @@ #include <vcl/graphicfilter.hxx> #include <svx/xoutbmp.hxx> #include <vcl/filter/PDFiumLibrary.hxx> +#include <docmodel/uno/UnoThemeColor.hxx> using namespace com::sun::star; @@ -100,31 +101,31 @@ CPPUNIT_TEST_FIXTURE(XOutdevTest, testFillColorThemeUnoApi) uno::Reference<drawing::XDrawPage> xPage(xPagesSupplier->getDrawPages()->getByIndex(0), uno::UNO_QUERY); uno::Reference<beans::XPropertySet> xShape(xPage->getByIndex(0), uno::UNO_QUERY); - sal_Int16 nExpected = 4; // Accent 1 - xShape->setPropertyValue("FillColorTheme", uno::Any(nExpected)); - - // 80% lighter - sal_Int16 nExpectedLumMod = 2000; - xShape->setPropertyValue("FillColorLumMod", uno::Any(nExpectedLumMod)); - sal_Int16 nExpectedLumOff = 8000; - xShape->setPropertyValue("FillColorLumOff", uno::Any(nExpectedLumOff)); + // Set theme color + { + model::ThemeColor aThemeColor; + aThemeColor.setType(model::ThemeColorType::Accent1); + aThemeColor.addTransformation({ model::TransformationType::LumMod, 2000 }); + aThemeColor.addTransformation({ model::TransformationType::LumOff, 8000 }); + xShape->setPropertyValue("FillColorThemeReference", + uno::Any(model::theme::createXThemeColor(aThemeColor))); + } // Then make sure the value we read back is the expected one: - sal_Int16 nActual = -1; - xShape->getPropertyValue("FillColorTheme") >>= nActual; - // Without the accompanying fix in place, this test would have failed with: - // - Expected: 4 - // - Actual : -1 - // i.e. setting the value was broken. - CPPUNIT_ASSERT_EQUAL(nExpected, nActual); - xShape->getPropertyValue("FillColorLumMod") >>= nActual; - // Without the accompanying fix in place, this test would have failed with: - // - Expected: 2000 - // - Actual : 8000 - // i.e. FillColorLumOff was set as FillColor, then getting FillColorLumMod returned FillColor. - CPPUNIT_ASSERT_EQUAL(nExpectedLumMod, nActual); - xShape->getPropertyValue("FillColorLumOff") >>= nActual; - CPPUNIT_ASSERT_EQUAL(nExpectedLumOff, nActual); + { + uno::Reference<util::XThemeColor> xThemeColor; + CPPUNIT_ASSERT(xShape->getPropertyValue("FillColorThemeReference") >>= xThemeColor); + CPPUNIT_ASSERT(xThemeColor.is()); + model::ThemeColor aThemeColor; + model::theme::setFromXThemeColor(aThemeColor, xThemeColor); + CPPUNIT_ASSERT_EQUAL(model::ThemeColorType::Accent1, aThemeColor.getType()); + CPPUNIT_ASSERT_EQUAL(model::TransformationType::LumMod, + aThemeColor.getTransformations()[0].meType); + CPPUNIT_ASSERT_EQUAL(sal_Int16(2000), aThemeColor.getTransformations()[0].mnValue); + CPPUNIT_ASSERT_EQUAL(model::TransformationType::LumOff, + aThemeColor.getTransformations()[1].meType); + CPPUNIT_ASSERT_EQUAL(sal_Int16(8000), aThemeColor.getTransformations()[1].mnValue); + } } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |