diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2023-05-08 14:09:00 +0900 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2023-05-12 05:00:28 +0200 |
commit | 1df0565fb92972bd410e7db85eef1e4bec3fcc31 (patch) | |
tree | 863c5cf54a5941ca84e2d76b68c4e895159d78de /svx/qa/unit | |
parent | 99a88c9e55872214ce01d89447d18708e47e956b (diff) |
use ComplexColor instead of ThemeColor for better OOXML compat.
In OOXML a color definition includes more represenations, one of
which is scheme color (which is what is implemented in ThemeColor
currently), but it supports other representations too (RGB, HSL,
System,..). ComplexColor includes all the representations, so to
have a better compatibility with OOXML, this changes all uses of
ThemeColor to ComplexColor.
In many cases the usage of ComplexColor isn't the same as the
usage of ThemeColors, but this cases will need to be changed in a
later commit.
Change-Id: I9cc8acee2ac0a1998fe9b98247bcf4a96273149a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151492
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'svx/qa/unit')
-rw-r--r-- | svx/qa/unit/styles.cxx | 32 | ||||
-rw-r--r-- | svx/qa/unit/xoutdev.cxx | 33 |
2 files changed, 31 insertions, 34 deletions
diff --git a/svx/qa/unit/styles.cxx b/svx/qa/unit/styles.cxx index d44bf9ac4dc8..05eeb451ba1b 100644 --- a/svx/qa/unit/styles.cxx +++ b/svx/qa/unit/styles.cxx @@ -13,7 +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> +#include <docmodel/uno/UnoComplexColor.hxx> using namespace ::com::sun::star; @@ -75,30 +75,28 @@ CPPUNIT_TEST_FIXTURE(Test, testThemeChange) // 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<util::XComplexColor> xComplexColor; + CPPUNIT_ASSERT(xShape4->getPropertyValue("FillComplexColor") >>= xComplexColor); + CPPUNIT_ASSERT(xComplexColor.is()); + auto aComplexColor = model::color::getFromXComplexColor(xComplexColor); + CPPUNIT_ASSERT_EQUAL(model::ThemeColorType::Accent1, aComplexColor.getSchemeType()); } uno::Reference<beans::XPropertySet> xShape5(xDrawPageShapes->getByIndex(5), uno::UNO_QUERY); // Blue, lighter. CPPUNIT_ASSERT_EQUAL(Color(0xb4c7e7), GetShapeFillColor(xShape5)); // The theme index, and effects (lum mod, lum off) are set by the PPTX import: { - 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()); + uno::Reference<util::XComplexColor> xComplexColor; + CPPUNIT_ASSERT(xShape5->getPropertyValue("FillComplexColor") >>= xComplexColor); + CPPUNIT_ASSERT(xComplexColor.is()); + auto aComplexColor = model::color::getFromXComplexColor(xComplexColor); + CPPUNIT_ASSERT_EQUAL(model::ThemeColorType::Accent1, aComplexColor.getSchemeType()); CPPUNIT_ASSERT_EQUAL(model::TransformationType::LumMod, - aThemeColor.getTransformations()[0].meType); - CPPUNIT_ASSERT_EQUAL(sal_Int16(4000), aThemeColor.getTransformations()[0].mnValue); + aComplexColor.getTransformations()[0].meType); + CPPUNIT_ASSERT_EQUAL(sal_Int16(4000), aComplexColor.getTransformations()[0].mnValue); CPPUNIT_ASSERT_EQUAL(model::TransformationType::LumOff, - aThemeColor.getTransformations()[1].meType); - CPPUNIT_ASSERT_EQUAL(sal_Int16(6000), aThemeColor.getTransformations()[1].mnValue); + aComplexColor.getTransformations()[1].meType); + CPPUNIT_ASSERT_EQUAL(sal_Int16(6000), aComplexColor.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( diff --git a/svx/qa/unit/xoutdev.cxx b/svx/qa/unit/xoutdev.cxx index 6cd68a0c8172..800c709770de 100644 --- a/svx/qa/unit/xoutdev.cxx +++ b/svx/qa/unit/xoutdev.cxx @@ -19,7 +19,7 @@ #include <vcl/graphicfilter.hxx> #include <svx/xoutbmp.hxx> #include <vcl/filter/PDFiumLibrary.hxx> -#include <docmodel/uno/UnoThemeColor.hxx> +#include <docmodel/uno/UnoComplexColor.hxx> using namespace com::sun::star; @@ -103,28 +103,27 @@ CPPUNIT_TEST_FIXTURE(XOutdevTest, testFillColorThemeUnoApi) uno::Reference<beans::XPropertySet> xShape(xPage->getByIndex(0), uno::UNO_QUERY); // 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))); + model::ComplexColor aComplexColor; + aComplexColor.setSchemeColor(model::ThemeColorType::Accent1); + aComplexColor.addTransformation({ model::TransformationType::LumMod, 2000 }); + aComplexColor.addTransformation({ model::TransformationType::LumOff, 8000 }); + xShape->setPropertyValue("FillComplexColor", + uno::Any(model::color::createXComplexColor(aComplexColor))); } // Then make sure the value we read back is the expected one: { - 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()); + uno::Reference<util::XComplexColor> xComplexColor; + CPPUNIT_ASSERT(xShape->getPropertyValue("FillComplexColor") >>= xComplexColor); + CPPUNIT_ASSERT(xComplexColor.is()); + auto aComplexColor = model::color::getFromXComplexColor(xComplexColor); + CPPUNIT_ASSERT_EQUAL(model::ThemeColorType::Accent1, aComplexColor.getSchemeType()); CPPUNIT_ASSERT_EQUAL(model::TransformationType::LumMod, - aThemeColor.getTransformations()[0].meType); - CPPUNIT_ASSERT_EQUAL(sal_Int16(2000), aThemeColor.getTransformations()[0].mnValue); + aComplexColor.getTransformations()[0].meType); + CPPUNIT_ASSERT_EQUAL(sal_Int16(2000), aComplexColor.getTransformations()[0].mnValue); CPPUNIT_ASSERT_EQUAL(model::TransformationType::LumOff, - aThemeColor.getTransformations()[1].meType); - CPPUNIT_ASSERT_EQUAL(sal_Int16(8000), aThemeColor.getTransformations()[1].mnValue); + aComplexColor.getTransformations()[1].meType); + CPPUNIT_ASSERT_EQUAL(sal_Int16(8000), aComplexColor.getTransformations()[1].mnValue); } } |