summaryrefslogtreecommitdiff
path: root/xmloff/qa/unit
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2023-05-08 14:09:00 +0900
committerTomaž Vajngerl <quikee@gmail.com>2023-05-12 05:00:28 +0200
commit1df0565fb92972bd410e7db85eef1e4bec3fcc31 (patch)
tree863c5cf54a5941ca84e2d76b68c4e895159d78de /xmloff/qa/unit
parent99a88c9e55872214ce01d89447d18708e47e956b (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 'xmloff/qa/unit')
-rw-r--r--xmloff/qa/unit/draw.cxx119
1 files changed, 57 insertions, 62 deletions
diff --git a/xmloff/qa/unit/draw.cxx b/xmloff/qa/unit/draw.cxx
index e412a13c2833..716a1ad1cc7c 100644
--- a/xmloff/qa/unit/draw.cxx
+++ b/xmloff/qa/unit/draw.cxx
@@ -28,7 +28,7 @@
#include <svx/unopage.hxx>
#include <svx/svdpage.hxx>
#include <svx/svdomedia.hxx>
-#include <docmodel/uno/UnoThemeColor.hxx>
+#include <docmodel/uno/UnoComplexColor.hxx>
#include <docmodel/uno/UnoTheme.hxx>
#include <docmodel/theme/Theme.hxx>
@@ -292,17 +292,16 @@ CPPUNIT_TEST_FIXTURE(XmloffDrawTest, testThemeColorExportImport)
uno::Reference<drawing::XShape> xShape(getShape(0));
CPPUNIT_ASSERT(xShape.is());
uno::Reference<beans::XPropertySet> xShapeProperties(xShape, uno::UNO_QUERY);
- uno::Reference<util::XThemeColor> xThemeColor;
- xShapeProperties->getPropertyValue("FillColorThemeReference") >>= xThemeColor;
- CPPUNIT_ASSERT(xThemeColor.is());
- model::ThemeColor aThemeColor;
- model::theme::setFromXThemeColor(aThemeColor, xThemeColor);
- CPPUNIT_ASSERT_EQUAL(model::ThemeColorType::Accent2, aThemeColor.getType());
- CPPUNIT_ASSERT_EQUAL(size_t(2), aThemeColor.getTransformations().size());
- auto const& rTrans1 = aThemeColor.getTransformations()[0];
+ uno::Reference<util::XComplexColor> xComplexColor;
+ xShapeProperties->getPropertyValue("FillComplexColor") >>= xComplexColor;
+ CPPUNIT_ASSERT(xComplexColor.is());
+ auto aComplexColor = model::color::getFromXComplexColor(xComplexColor);
+ CPPUNIT_ASSERT_EQUAL(model::ThemeColorType::Accent2, aComplexColor.getSchemeType());
+ CPPUNIT_ASSERT_EQUAL(size_t(2), aComplexColor.getTransformations().size());
+ auto const& rTrans1 = aComplexColor.getTransformations()[0];
CPPUNIT_ASSERT_EQUAL(model::TransformationType::LumMod, rTrans1.meType);
CPPUNIT_ASSERT_EQUAL(sal_Int16(2000), rTrans1.mnValue);
- auto const& rTrans2 = aThemeColor.getTransformations()[1];
+ auto const& rTrans2 = aComplexColor.getTransformations()[1];
CPPUNIT_ASSERT_EQUAL(model::TransformationType::LumOff, rTrans2.meType);
CPPUNIT_ASSERT_EQUAL(sal_Int16(8000), rTrans2.mnValue);
}
@@ -310,17 +309,16 @@ CPPUNIT_TEST_FIXTURE(XmloffDrawTest, testThemeColorExportImport)
uno::Reference<drawing::XShape> xShape(getShape(1));
CPPUNIT_ASSERT(xShape.is());
uno::Reference<beans::XPropertySet> xShapeProperties(xShape, uno::UNO_QUERY);
- uno::Reference<util::XThemeColor> xThemeColor;
- xShapeProperties->getPropertyValue("FillColorThemeReference") >>= xThemeColor;
- CPPUNIT_ASSERT(xThemeColor.is());
- model::ThemeColor aThemeColor;
- model::theme::setFromXThemeColor(aThemeColor, xThemeColor);
- CPPUNIT_ASSERT_EQUAL(model::ThemeColorType::Accent2, aThemeColor.getType());
- CPPUNIT_ASSERT_EQUAL(size_t(2), aThemeColor.getTransformations().size());
- auto const& rTrans1 = aThemeColor.getTransformations()[0];
+ uno::Reference<util::XComplexColor> xComplexColor;
+ xShapeProperties->getPropertyValue("FillComplexColor") >>= xComplexColor;
+ CPPUNIT_ASSERT(xComplexColor.is());
+ auto aComplexColor = model::color::getFromXComplexColor(xComplexColor);
+ CPPUNIT_ASSERT_EQUAL(model::ThemeColorType::Accent2, aComplexColor.getSchemeType());
+ CPPUNIT_ASSERT_EQUAL(size_t(2), aComplexColor.getTransformations().size());
+ auto const& rTrans1 = aComplexColor.getTransformations()[0];
CPPUNIT_ASSERT_EQUAL(model::TransformationType::LumMod, rTrans1.meType);
CPPUNIT_ASSERT_EQUAL(sal_Int16(6000), rTrans1.mnValue);
- auto const& rTrans2 = aThemeColor.getTransformations()[1];
+ auto const& rTrans2 = aComplexColor.getTransformations()[1];
CPPUNIT_ASSERT_EQUAL(model::TransformationType::LumOff, rTrans2.meType);
CPPUNIT_ASSERT_EQUAL(sal_Int16(4000), rTrans2.mnValue);
}
@@ -328,14 +326,13 @@ CPPUNIT_TEST_FIXTURE(XmloffDrawTest, testThemeColorExportImport)
uno::Reference<drawing::XShape> xShape(getShape(2));
CPPUNIT_ASSERT(xShape.is());
uno::Reference<beans::XPropertySet> xShapeProperties(xShape, uno::UNO_QUERY);
- uno::Reference<util::XThemeColor> xThemeColor;
- xShapeProperties->getPropertyValue("FillColorThemeReference") >>= xThemeColor;
- CPPUNIT_ASSERT(xThemeColor.is());
- model::ThemeColor aThemeColor;
- model::theme::setFromXThemeColor(aThemeColor, xThemeColor);
- CPPUNIT_ASSERT_EQUAL(model::ThemeColorType::Accent2, aThemeColor.getType());
- CPPUNIT_ASSERT_EQUAL(size_t(1), aThemeColor.getTransformations().size());
- auto const& rTrans1 = aThemeColor.getTransformations()[0];
+ uno::Reference<util::XComplexColor> xComplexColor;
+ xShapeProperties->getPropertyValue("FillComplexColor") >>= xComplexColor;
+ CPPUNIT_ASSERT(xComplexColor.is());
+ auto aComplexColor = model::color::getFromXComplexColor(xComplexColor);
+ CPPUNIT_ASSERT_EQUAL(model::ThemeColorType::Accent2, aComplexColor.getSchemeType());
+ CPPUNIT_ASSERT_EQUAL(size_t(1), aComplexColor.getTransformations().size());
+ auto const& rTrans1 = aComplexColor.getTransformations()[0];
CPPUNIT_ASSERT_EQUAL(model::TransformationType::LumMod, rTrans1.meType);
CPPUNIT_ASSERT_EQUAL(sal_Int16(5000), rTrans1.mnValue);
}
@@ -348,17 +345,17 @@ CPPUNIT_TEST_FIXTURE(XmloffDrawTest, testThemeColorExportImport)
CPPUNIT_ASSERT(xShape.is());
uno::Reference<beans::XPropertySet> xPortion = getShapeTextPortion(0, xShape);
CPPUNIT_ASSERT(xPortion.is());
- uno::Reference<util::XThemeColor> xThemeColor;
- xPortion->getPropertyValue("CharColorThemeReference") >>= xThemeColor;
- CPPUNIT_ASSERT(xThemeColor.is());
- model::ThemeColor aThemeColor;
- model::theme::setFromXThemeColor(aThemeColor, xThemeColor);
- CPPUNIT_ASSERT_EQUAL(model::ThemeColorType::Accent3, aThemeColor.getType());
- CPPUNIT_ASSERT_EQUAL(size_t(2), aThemeColor.getTransformations().size());
- auto const& rTrans1 = aThemeColor.getTransformations()[0];
+ uno::Reference<util::XComplexColor> xComplexColor;
+ xPortion->getPropertyValue("CharComplexColor") >>= xComplexColor;
+ CPPUNIT_ASSERT(xComplexColor.is());
+ auto aComplexColor = model::color::getFromXComplexColor(xComplexColor);
+ CPPUNIT_ASSERT_EQUAL(model::ThemeColorType::Accent3, aComplexColor.getSchemeType());
+ auto const& rTransforms = aComplexColor.getTransformations();
+ CPPUNIT_ASSERT_EQUAL(size_t(2), rTransforms.size());
+ auto const& rTrans1 = rTransforms[0];
CPPUNIT_ASSERT_EQUAL(model::TransformationType::LumMod, rTrans1.meType);
CPPUNIT_ASSERT_EQUAL(sal_Int16(2000), rTrans1.mnValue);
- auto const& rTrans2 = aThemeColor.getTransformations()[1];
+ auto const& rTrans2 = rTransforms[1];
CPPUNIT_ASSERT_EQUAL(model::TransformationType::LumOff, rTrans2.meType);
CPPUNIT_ASSERT_EQUAL(sal_Int16(8000), rTrans2.mnValue);
}
@@ -369,17 +366,17 @@ CPPUNIT_TEST_FIXTURE(XmloffDrawTest, testThemeColorExportImport)
CPPUNIT_ASSERT(xShape.is());
uno::Reference<beans::XPropertySet> xPortion = getShapeTextPortion(0, xShape);
CPPUNIT_ASSERT(xPortion.is());
- uno::Reference<util::XThemeColor> xThemeColor;
- xPortion->getPropertyValue("CharColorThemeReference") >>= xThemeColor;
- CPPUNIT_ASSERT(xThemeColor.is());
- model::ThemeColor aThemeColor;
- model::theme::setFromXThemeColor(aThemeColor, xThemeColor);
- CPPUNIT_ASSERT_EQUAL(model::ThemeColorType::Accent3, aThemeColor.getType());
- CPPUNIT_ASSERT_EQUAL(size_t(2), aThemeColor.getTransformations().size());
- auto const& rTrans1 = aThemeColor.getTransformations()[0];
+ uno::Reference<util::XComplexColor> xComplexColor;
+ xPortion->getPropertyValue("CharComplexColor") >>= xComplexColor;
+ CPPUNIT_ASSERT(xComplexColor.is());
+ auto aComplexColor = model::color::getFromXComplexColor(xComplexColor);
+ CPPUNIT_ASSERT_EQUAL(model::ThemeColorType::Accent3, aComplexColor.getSchemeType());
+ auto const& rTransforms = aComplexColor.getTransformations();
+ CPPUNIT_ASSERT_EQUAL(size_t(2), rTransforms.size());
+ auto const& rTrans1 = rTransforms[0];
CPPUNIT_ASSERT_EQUAL(model::TransformationType::LumMod, rTrans1.meType);
CPPUNIT_ASSERT_EQUAL(sal_Int16(6000), rTrans1.mnValue);
- auto const& rTrans2 = aThemeColor.getTransformations()[1];
+ auto const& rTrans2 = rTransforms[1];
CPPUNIT_ASSERT_EQUAL(model::TransformationType::LumOff, rTrans2.meType);
CPPUNIT_ASSERT_EQUAL(sal_Int16(4000), rTrans2.mnValue);
}
@@ -390,14 +387,13 @@ CPPUNIT_TEST_FIXTURE(XmloffDrawTest, testThemeColorExportImport)
CPPUNIT_ASSERT(xShape.is());
uno::Reference<beans::XPropertySet> xPortion = getShapeTextPortion(0, xShape);
CPPUNIT_ASSERT(xPortion.is());
- uno::Reference<util::XThemeColor> xThemeColor;
- xPortion->getPropertyValue("CharColorThemeReference") >>= xThemeColor;
- CPPUNIT_ASSERT(xThemeColor.is());
- model::ThemeColor aThemeColor;
- model::theme::setFromXThemeColor(aThemeColor, xThemeColor);
- CPPUNIT_ASSERT_EQUAL(model::ThemeColorType::Accent3, aThemeColor.getType());
- CPPUNIT_ASSERT_EQUAL(size_t(1), aThemeColor.getTransformations().size());
- auto const& rTrans1 = aThemeColor.getTransformations()[0];
+ uno::Reference<util::XComplexColor> xComplexColor;
+ xPortion->getPropertyValue("CharComplexColor") >>= xComplexColor;
+ CPPUNIT_ASSERT(xComplexColor.is());
+ auto aComplexColor = model::color::getFromXComplexColor(xComplexColor);
+ CPPUNIT_ASSERT_EQUAL(model::ThemeColorType::Accent3, aComplexColor.getSchemeType());
+ CPPUNIT_ASSERT_EQUAL(size_t(1), aComplexColor.getTransformations().size());
+ auto const& rTrans1 = aComplexColor.getTransformations()[0];
CPPUNIT_ASSERT_EQUAL(model::TransformationType::LumMod, rTrans1.meType);
CPPUNIT_ASSERT_EQUAL(sal_Int16(5000), rTrans1.mnValue);
}
@@ -414,16 +410,15 @@ CPPUNIT_TEST_FIXTURE(XmloffDrawTest, testThemeColor_ShapeFill)
uno::Reference<drawing::XShape> xShape(getShape(0));
CPPUNIT_ASSERT(xShape.is());
uno::Reference<beans::XPropertySet> xShapeProperties(xShape, uno::UNO_QUERY);
- uno::Reference<util::XThemeColor> xThemeColor;
- xShapeProperties->getPropertyValue("FillColorThemeReference") >>= xThemeColor;
- CPPUNIT_ASSERT(xThemeColor.is());
- model::ThemeColor aThemeColor;
- model::theme::setFromXThemeColor(aThemeColor, xThemeColor);
- CPPUNIT_ASSERT_EQUAL(model::ThemeColorType::Accent6, aThemeColor.getType());
- CPPUNIT_ASSERT_EQUAL(size_t(1), aThemeColor.getTransformations().size());
+ uno::Reference<util::XComplexColor> xComplexColor;
+ xShapeProperties->getPropertyValue("FillComplexColor") >>= xComplexColor;
+ CPPUNIT_ASSERT(xComplexColor.is());
+ auto aComplexColor = model::color::getFromXComplexColor(xComplexColor);
+ CPPUNIT_ASSERT_EQUAL(model::ThemeColorType::Accent6, aComplexColor.getSchemeType());
+ CPPUNIT_ASSERT_EQUAL(size_t(1), aComplexColor.getTransformations().size());
CPPUNIT_ASSERT_EQUAL(model::TransformationType::LumMod,
- aThemeColor.getTransformations()[0].meType);
- CPPUNIT_ASSERT_EQUAL(sal_Int16(7500), aThemeColor.getTransformations()[0].mnValue);
+ aComplexColor.getTransformations()[0].meType);
+ CPPUNIT_ASSERT_EQUAL(sal_Int16(7500), aComplexColor.getTransformations()[0].mnValue);
}
CPPUNIT_TEST_FIXTURE(XmloffDrawTest, testTableInShape)