summaryrefslogtreecommitdiff
path: root/oox/qa
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 /oox/qa
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 'oox/qa')
-rw-r--r--oox/qa/unit/drawingml.cxx99
-rw-r--r--oox/qa/unit/shape.cxx15
2 files changed, 55 insertions, 59 deletions
diff --git a/oox/qa/unit/drawingml.cxx b/oox/qa/unit/drawingml.cxx
index 14e9321562ee..10dc88e4954d 100644
--- a/oox/qa/unit/drawingml.cxx
+++ b/oox/qa/unit/drawingml.cxx
@@ -30,7 +30,7 @@
#include <com/sun/star/table/XCellRange.hpp>
#include <com/sun/star/util/XTheme.hpp>
-#include <docmodel/uno/UnoThemeColor.hxx>
+#include <docmodel/uno/UnoComplexColor.hxx>
#include <docmodel/uno/UnoTheme.hxx>
#include <docmodel/theme/Theme.hxx>
@@ -416,18 +416,17 @@ CPPUNIT_TEST_FIXTURE(OoxDrawingmlTest, testPptxTheme)
// Check the theme colors are as expected
{
- uno::Reference<util::XThemeColor> xThemeColor;
- CPPUNIT_ASSERT(xPortion->getPropertyValue("CharColorThemeReference") >>= 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(xPortion->getPropertyValue("CharComplexColor") >>= 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(6000), aThemeColor.getTransformations()[0].mnValue);
+ aComplexColor.getTransformations()[0].meType);
+ CPPUNIT_ASSERT_EQUAL(sal_Int16(6000), aComplexColor.getTransformations()[0].mnValue);
CPPUNIT_ASSERT_EQUAL(model::TransformationType::LumOff,
- aThemeColor.getTransformations()[1].meType);
- CPPUNIT_ASSERT_EQUAL(sal_Int16(4000), aThemeColor.getTransformations()[1].mnValue);
+ aComplexColor.getTransformations()[1].meType);
+ CPPUNIT_ASSERT_EQUAL(sal_Int16(4000), aComplexColor.getTransformations()[1].mnValue);
}
}
@@ -472,28 +471,26 @@ CPPUNIT_TEST_FIXTURE(OoxDrawingmlTest, testThemeColorTint_Table)
// check theme color
{
- uno::Reference<util::XThemeColor> xThemeColor;
- CPPUNIT_ASSERT(xA1->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(xA1->getPropertyValue("FillComplexColor") >>= xComplexColor);
+ CPPUNIT_ASSERT(xComplexColor.is());
+ auto aComplexColor = model::color::getFromXComplexColor(xComplexColor);
+ CPPUNIT_ASSERT_EQUAL(model::ThemeColorType::Accent1, aComplexColor.getSchemeType());
{
- auto const& rTrans = aThemeColor.getTransformations();
+ auto const& rTrans = aComplexColor.getTransformations();
CPPUNIT_ASSERT_EQUAL(size_t(0), rTrans.size());
}
}
{
- uno::Reference<util::XThemeColor> xThemeColor;
uno::Reference<beans::XPropertySet> xA2(xTable->getCellByPosition(0, 1), uno::UNO_QUERY);
- CPPUNIT_ASSERT(xA2->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(xA2->getPropertyValue("FillComplexColor") >>= xComplexColor);
+ CPPUNIT_ASSERT(xComplexColor.is());
+ auto aComplexColor = model::color::getFromXComplexColor(xComplexColor);
+ CPPUNIT_ASSERT_EQUAL(model::ThemeColorType::Accent1, aComplexColor.getSchemeType());
{
- auto const& rTrans = aThemeColor.getTransformations();
+ auto const& rTrans = aComplexColor.getTransformations();
CPPUNIT_ASSERT_EQUAL(size_t(1), rTrans.size());
CPPUNIT_ASSERT_EQUAL(model::TransformationType::Tint, rTrans[0].meType);
CPPUNIT_ASSERT_EQUAL(sal_Int16(4000), rTrans[0].mnValue);
@@ -514,16 +511,15 @@ CPPUNIT_TEST_FIXTURE(OoxDrawingmlTest, testThemeColor_Shape)
// check line and fill theme color of shape1
{
- model::ThemeColor aThemeColor;
- uno::Reference<util::XThemeColor> xThemeColor;
uno::Reference<beans::XPropertySet> xShape(xDrawPage->getByIndex(0), uno::UNO_QUERY);
-
- CPPUNIT_ASSERT(xShape->getPropertyValue("FillColorThemeReference") >>= xThemeColor);
- CPPUNIT_ASSERT(xThemeColor.is());
- model::theme::setFromXThemeColor(aThemeColor, xThemeColor);
- CPPUNIT_ASSERT_EQUAL(model::ThemeColorType::Accent6, aThemeColor.getType());
+ uno::Reference<util::XComplexColor> xComplexColor;
+ CPPUNIT_ASSERT(xShape->getPropertyValue("FillComplexColor") >>= xComplexColor);
+ CPPUNIT_ASSERT(xComplexColor.is());
{
- auto const& rTrans = aThemeColor.getTransformations();
+ auto aComplexColor = model::color::getFromXComplexColor(xComplexColor);
+ CPPUNIT_ASSERT_EQUAL(model::ThemeColorType::Accent6, aComplexColor.getSchemeType());
+
+ auto const& rTrans = aComplexColor.getTransformations();
CPPUNIT_ASSERT_EQUAL(size_t(2), rTrans.size());
CPPUNIT_ASSERT_EQUAL(model::TransformationType::LumMod, rTrans[0].meType);
CPPUNIT_ASSERT_EQUAL(sal_Int16(4000), rTrans[0].mnValue);
@@ -531,12 +527,13 @@ CPPUNIT_TEST_FIXTURE(OoxDrawingmlTest, testThemeColor_Shape)
CPPUNIT_ASSERT_EQUAL(sal_Int16(6000), rTrans[1].mnValue);
}
- CPPUNIT_ASSERT(xShape->getPropertyValue("LineColorThemeReference") >>= xThemeColor);
- CPPUNIT_ASSERT(xThemeColor.is());
- model::theme::setFromXThemeColor(aThemeColor, xThemeColor);
- CPPUNIT_ASSERT_EQUAL(model::ThemeColorType::Accent6, aThemeColor.getType());
+ CPPUNIT_ASSERT(xShape->getPropertyValue("LineComplexColor") >>= xComplexColor);
+ CPPUNIT_ASSERT(xComplexColor.is());
{
- auto const& rTrans = aThemeColor.getTransformations();
+ auto aComplexColor = model::color::getFromXComplexColor(xComplexColor);
+ CPPUNIT_ASSERT_EQUAL(model::ThemeColorType::Accent6, aComplexColor.getSchemeType());
+
+ auto const& rTrans = aComplexColor.getTransformations();
CPPUNIT_ASSERT_EQUAL(size_t(1), rTrans.size());
CPPUNIT_ASSERT_EQUAL(model::TransformationType::LumMod, rTrans[0].meType);
CPPUNIT_ASSERT_EQUAL(sal_Int16(5000), rTrans[0].mnValue);
@@ -544,25 +541,25 @@ CPPUNIT_TEST_FIXTURE(OoxDrawingmlTest, testThemeColor_Shape)
}
// check line and fill theme color of shape2
{
- model::ThemeColor aThemeColor;
- uno::Reference<util::XThemeColor> xThemeColor;
+ uno::Reference<util::XComplexColor> xComplexColor;
uno::Reference<beans::XPropertySet> xShape(xDrawPage->getByIndex(1), uno::UNO_QUERY);
-
- CPPUNIT_ASSERT(xShape->getPropertyValue("FillColorThemeReference") >>= xThemeColor);
- CPPUNIT_ASSERT(xThemeColor.is());
- model::theme::setFromXThemeColor(aThemeColor, xThemeColor);
- CPPUNIT_ASSERT_EQUAL(model::ThemeColorType::Accent1, aThemeColor.getType());
+ CPPUNIT_ASSERT(xShape->getPropertyValue("FillComplexColor") >>= xComplexColor);
+ CPPUNIT_ASSERT(xComplexColor.is());
{
- auto const& rTrans = aThemeColor.getTransformations();
+ auto aComplexColor = model::color::getFromXComplexColor(xComplexColor);
+ CPPUNIT_ASSERT_EQUAL(model::ThemeColorType::Accent1, aComplexColor.getSchemeType());
+
+ auto const& rTrans = aComplexColor.getTransformations();
CPPUNIT_ASSERT_EQUAL(size_t(0), rTrans.size());
}
- CPPUNIT_ASSERT(xShape->getPropertyValue("LineColorThemeReference") >>= xThemeColor);
- CPPUNIT_ASSERT(xThemeColor.is());
- model::theme::setFromXThemeColor(aThemeColor, xThemeColor);
- CPPUNIT_ASSERT_EQUAL(model::ThemeColorType::Accent1, aThemeColor.getType());
+ CPPUNIT_ASSERT(xShape->getPropertyValue("LineComplexColor") >>= xComplexColor);
+ CPPUNIT_ASSERT(xComplexColor.is());
{
- auto const& rTrans = aThemeColor.getTransformations();
+ auto aComplexColor = model::color::getFromXComplexColor(xComplexColor);
+ CPPUNIT_ASSERT_EQUAL(model::ThemeColorType::Accent1, aComplexColor.getSchemeType());
+
+ auto const& rTrans = aComplexColor.getTransformations();
CPPUNIT_ASSERT_EQUAL(size_t(1), rTrans.size());
CPPUNIT_ASSERT_EQUAL(model::TransformationType::LumMod, rTrans[0].meType);
CPPUNIT_ASSERT_EQUAL(sal_Int16(7500), rTrans[0].mnValue);
diff --git a/oox/qa/unit/shape.cxx b/oox/qa/unit/shape.cxx
index e8d4f188b8d3..ad43fb52b4a1 100644
--- a/oox/qa/unit/shape.cxx
+++ b/oox/qa/unit/shape.cxx
@@ -36,7 +36,7 @@
#include <rtl/math.hxx>
#include <svx/svdoashp.hxx>
#include <tools/color.hxx>
-#include <docmodel/uno/UnoThemeColor.hxx>
+#include <docmodel/uno/UnoComplexColor.hxx>
#include <basegfx/utils/gradienttools.hxx>
using namespace ::com::sun::star;
@@ -313,15 +313,14 @@ CPPUNIT_TEST_FIXTURE(OoxShapeTest, testTdf54095_SmartArtThemeTextColor)
// - Actual : 16777215 (0xFFFFFF), that is text was white
CPPUNIT_ASSERT_EQUAL(sal_Int32(0x1F497D), nActualColor);
- // clrScheme. For map between name in docx and index from CharColorThemeReference see
+ // clrScheme. For map between name in docx and index from CharComplexColor see
// oox::drawingml::Color::getSchemeColorIndex()
// Without fix the color scheme was "lt1" (1) but should be "dk2" (2).
- uno::Reference<util::XThemeColor> xThemeColor;
- CPPUNIT_ASSERT(xPortion->getPropertyValue("CharColorThemeReference") >>= xThemeColor);
- CPPUNIT_ASSERT(xThemeColor.is());
- model::ThemeColor aThemeColor;
- model::theme::setFromXThemeColor(aThemeColor, xThemeColor);
- CPPUNIT_ASSERT_EQUAL(model::ThemeColorType::Dark2, aThemeColor.getType());
+ uno::Reference<util::XComplexColor> xComplexColor;
+ xPortion->getPropertyValue("CharComplexColor") >>= xComplexColor;
+ CPPUNIT_ASSERT(xComplexColor.is());
+ auto aComplexColor = model::color::getFromXComplexColor(xComplexColor);
+ CPPUNIT_ASSERT_EQUAL(model::ThemeColorType::Dark2, aComplexColor.getSchemeType());
if (!bUseGroup)
{