summaryrefslogtreecommitdiff
path: root/oox
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2023-08-03 10:14:40 +0200
committerMike Kaganski <mike.kaganski@collabora.com>2023-08-28 12:42:43 +0200
commite9e18abdc76368e2599dd7a5c4f2d9903a0b9cf6 (patch)
tree35e7750f82325d299468c20478ba96d4352aaaef /oox
parent0cc5861d6adf60f44b0fa5d307ced948b817e20a (diff)
ComplexColor various clean-up and (trivial) refactorings
Don't allow access to member variables of ComplexColor and makes them private. Needs a lot of changes. Change "scheme" to "theme" to be more consistent. In LO we usually call the "theme color" what is usually refered to as "scheme color" in OOXML, where it is sometimes refered to as "scheme" and other times as theme color. Remove ThemeColor class which was replaced with CmplexColor some time ago. Remove un-needed includes and un-needed components. Use isValidThemeColor in many places where we check that the ComplexColor is of "Theme" type and that ThemeColorType is set to a valid value. Change-Id: I325595fa65b8e56a4707e9d22acc6330aac28961 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155359 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <quikee@gmail.com> (cherry picked from commit 9d5a7d9257db78eb3f4d77c39eae1affe877ea6b) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156150 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'oox')
-rw-r--r--oox/inc/pch/precompiled_oox.hxx3
-rw-r--r--oox/qa/unit/drawingml.cxx14
-rw-r--r--oox/qa/unit/shape.cxx2
-rw-r--r--oox/source/drawingml/color.cxx7
-rw-r--r--oox/source/drawingml/colorchoicecontext.cxx11
-rw-r--r--oox/source/drawingml/fillproperties.cxx2
-rw-r--r--oox/source/drawingml/lineproperties.cxx4
-rw-r--r--oox/source/export/ThemeExport.cxx36
-rw-r--r--oox/source/export/drawingml.cxx4
9 files changed, 42 insertions, 41 deletions
diff --git a/oox/inc/pch/precompiled_oox.hxx b/oox/inc/pch/precompiled_oox.hxx
index cba76097feed..927eb8ab33a1 100644
--- a/oox/inc/pch/precompiled_oox.hxx
+++ b/oox/inc/pch/precompiled_oox.hxx
@@ -202,6 +202,9 @@
#include <cppuhelper/implbase_ex.hxx>
#include <cppuhelper/weak.hxx>
#include <cppuhelper/weakref.hxx>
+#include <docmodel/color/ComplexColor.hxx>
+#include <docmodel/dllapi.h>
+#include <docmodel/theme/ColorSet.hxx>
#include <docmodel/theme/ThemeColorType.hxx>
#include <drawinglayer/primitive2d/Primitive2DContainer.hxx>
#include <drawingml/colorchoicecontext.hxx>
diff --git a/oox/qa/unit/drawingml.cxx b/oox/qa/unit/drawingml.cxx
index b9a699f35bd4..4f69d8e9c7e2 100644
--- a/oox/qa/unit/drawingml.cxx
+++ b/oox/qa/unit/drawingml.cxx
@@ -419,7 +419,7 @@ CPPUNIT_TEST_FIXTURE(OoxDrawingmlTest, testPptxTheme)
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::ThemeColorType::Accent1, aComplexColor.getThemeColorType());
CPPUNIT_ASSERT_EQUAL(model::TransformationType::LumMod,
aComplexColor.getTransformations()[0].meType);
CPPUNIT_ASSERT_EQUAL(sal_Int16(6000), aComplexColor.getTransformations()[0].mnValue);
@@ -474,7 +474,7 @@ CPPUNIT_TEST_FIXTURE(OoxDrawingmlTest, testThemeColorTint_Table)
CPPUNIT_ASSERT(xA1->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::ThemeColorType::Accent1, aComplexColor.getThemeColorType());
{
auto const& rTrans = aComplexColor.getTransformations();
CPPUNIT_ASSERT_EQUAL(size_t(0), rTrans.size());
@@ -487,7 +487,7 @@ CPPUNIT_TEST_FIXTURE(OoxDrawingmlTest, testThemeColorTint_Table)
CPPUNIT_ASSERT(xA2->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::ThemeColorType::Accent1, aComplexColor.getThemeColorType());
{
auto const& rTrans = aComplexColor.getTransformations();
CPPUNIT_ASSERT_EQUAL(size_t(1), rTrans.size());
@@ -516,7 +516,7 @@ CPPUNIT_TEST_FIXTURE(OoxDrawingmlTest, testThemeColor_Shape)
CPPUNIT_ASSERT(xComplexColor.is());
{
auto aComplexColor = model::color::getFromXComplexColor(xComplexColor);
- CPPUNIT_ASSERT_EQUAL(model::ThemeColorType::Accent6, aComplexColor.getSchemeType());
+ CPPUNIT_ASSERT_EQUAL(model::ThemeColorType::Accent6, aComplexColor.getThemeColorType());
auto const& rTrans = aComplexColor.getTransformations();
CPPUNIT_ASSERT_EQUAL(size_t(2), rTrans.size());
@@ -530,7 +530,7 @@ CPPUNIT_TEST_FIXTURE(OoxDrawingmlTest, testThemeColor_Shape)
CPPUNIT_ASSERT(xComplexColor.is());
{
auto aComplexColor = model::color::getFromXComplexColor(xComplexColor);
- CPPUNIT_ASSERT_EQUAL(model::ThemeColorType::Accent6, aComplexColor.getSchemeType());
+ CPPUNIT_ASSERT_EQUAL(model::ThemeColorType::Accent6, aComplexColor.getThemeColorType());
auto const& rTrans = aComplexColor.getTransformations();
CPPUNIT_ASSERT_EQUAL(size_t(1), rTrans.size());
@@ -546,7 +546,7 @@ CPPUNIT_TEST_FIXTURE(OoxDrawingmlTest, testThemeColor_Shape)
CPPUNIT_ASSERT(xComplexColor.is());
{
auto aComplexColor = model::color::getFromXComplexColor(xComplexColor);
- CPPUNIT_ASSERT_EQUAL(model::ThemeColorType::Accent1, aComplexColor.getSchemeType());
+ CPPUNIT_ASSERT_EQUAL(model::ThemeColorType::Accent1, aComplexColor.getThemeColorType());
auto const& rTrans = aComplexColor.getTransformations();
CPPUNIT_ASSERT_EQUAL(size_t(0), rTrans.size());
@@ -556,7 +556,7 @@ CPPUNIT_TEST_FIXTURE(OoxDrawingmlTest, testThemeColor_Shape)
CPPUNIT_ASSERT(xComplexColor.is());
{
auto aComplexColor = model::color::getFromXComplexColor(xComplexColor);
- CPPUNIT_ASSERT_EQUAL(model::ThemeColorType::Accent1, aComplexColor.getSchemeType());
+ CPPUNIT_ASSERT_EQUAL(model::ThemeColorType::Accent1, aComplexColor.getThemeColorType());
auto const& rTrans = aComplexColor.getTransformations();
CPPUNIT_ASSERT_EQUAL(size_t(1), rTrans.size());
diff --git a/oox/qa/unit/shape.cxx b/oox/qa/unit/shape.cxx
index 97bec7121e2d..cc44152a84b4 100644
--- a/oox/qa/unit/shape.cxx
+++ b/oox/qa/unit/shape.cxx
@@ -307,7 +307,7 @@ CPPUNIT_TEST_FIXTURE(OoxShapeTest, testTdf54095_SmartArtThemeTextColor)
xPortion->getPropertyValue("CharComplexColor") >>= xComplexColor;
CPPUNIT_ASSERT(xComplexColor.is());
auto aComplexColor = model::color::getFromXComplexColor(xComplexColor);
- CPPUNIT_ASSERT_EQUAL(model::ThemeColorType::Dark2, aComplexColor.getSchemeType());
+ CPPUNIT_ASSERT_EQUAL(model::ThemeColorType::Dark2, aComplexColor.getThemeColorType());
if (!bUseGroup)
{
diff --git a/oox/source/drawingml/color.cxx b/oox/source/drawingml/color.cxx
index 1a9e39f3832d..1f6e68d73bd5 100644
--- a/oox/source/drawingml/color.cxx
+++ b/oox/source/drawingml/color.cxx
@@ -617,8 +617,7 @@ sal_Int16 Color::getLumOff() const
model::ComplexColor Color::getComplexColor() const
{
- model::ComplexColor aComplexColor;
- aComplexColor.setSchemeColor(model::convertToThemeColorType(getSchemeColorIndex()));
+ auto aComplexColor = model::ComplexColor::Theme(model::convertToThemeColorType(getSchemeColorIndex()));
if (getTintOrShade() > 0)
{
@@ -816,12 +815,12 @@ model::ComplexColor Color::createComplexColor(const GraphicHelper& /*rGraphicHel
if (meMode == COLOR_PH)
{
auto eTheme = model::convertToThemeColorType(nPhClrTheme);
- aNewComplexColor.setSchemeColor(eTheme);
+ aNewComplexColor.setThemeColor(eTheme);
}
else if (meMode == COLOR_SCHEME)
{
auto eTheme = getThemeColorType();
- aNewComplexColor.setSchemeColor(eTheme);
+ aNewComplexColor.setThemeColor(eTheme);
}
else if (meMode == COLOR_RGB)
{
diff --git a/oox/source/drawingml/colorchoicecontext.cxx b/oox/source/drawingml/colorchoicecontext.cxx
index b0977c5e003c..4a47a5d4a761 100644
--- a/oox/source/drawingml/colorchoicecontext.cxx
+++ b/oox/source/drawingml/colorchoicecontext.cxx
@@ -185,12 +185,12 @@ void ColorValueContext::onStartElement( const AttributeList& rAttribs )
{
if (nToken == XML_phClr)
{
- mpComplexColor->setSchemePlaceholder();
+ mpComplexColor->setThemePlaceholder();
}
else
{
model::ThemeColorType eType = schemeNameToThemeColorType(*sSchemeName);
- mpComplexColor->setSchemeColor(eType);
+ mpComplexColor->setThemeColor(eType);
}
}
}
@@ -205,10 +205,7 @@ void ColorValueContext::onStartElement( const AttributeList& rAttribs )
{
// TODO - just converted to RGB for now
::Color nRgbValue = Color::getDmlPresetColor(nToken, API_RGB_TRANSPARENT);
- mpComplexColor->mnComponent1 = nRgbValue.GetRed();
- mpComplexColor->mnComponent2 = nRgbValue.GetGreen();
- mpComplexColor->mnComponent3 = nRgbValue.GetBlue();
- mpComplexColor->meType = model::ColorType::RGB;
+ mpComplexColor->setColor(nRgbValue);
}
}
break;
@@ -279,7 +276,7 @@ void ColorValueContext::onStartElement( const AttributeList& rAttribs )
else
nValue = rAttribs.getInteger(XML_val, 0);
- mpComplexColor->maTransformations.push_back({eType, sal_Int16(nValue / 10)});
+ mpComplexColor->addTransformation({eType, sal_Int16(nValue / 10)});
}
}
diff --git a/oox/source/drawingml/fillproperties.cxx b/oox/source/drawingml/fillproperties.cxx
index becc632fd923..0cee56835183 100644
--- a/oox/source/drawingml/fillproperties.cxx
+++ b/oox/source/drawingml/fillproperties.cxx
@@ -430,7 +430,7 @@ void FillProperties::pushToPropMap(ShapePropertyMap& rPropMap, const GraphicHelp
model::ComplexColor aComplexColor;
if (aFillColor == nPhClr)
{
- aComplexColor.setSchemeColor(model::convertToThemeColorType(nPhClrTheme));
+ aComplexColor.setThemeColor(model::convertToThemeColorType(nPhClrTheme));
}
else
{
diff --git a/oox/source/drawingml/lineproperties.cxx b/oox/source/drawingml/lineproperties.cxx
index 277e1bf9da3d..f5e3a814405b 100644
--- a/oox/source/drawingml/lineproperties.cxx
+++ b/oox/source/drawingml/lineproperties.cxx
@@ -504,12 +504,12 @@ void LineProperties::pushToPropMap( ShapePropertyMap& rPropMap,
if (aColor == nPhClr)
{
- aComplexColor.setSchemeColor(model::convertToThemeColorType(nPhClrTheme));
+ aComplexColor.setThemeColor(model::convertToThemeColorType(nPhClrTheme));
rPropMap.setProperty(PROP_LineComplexColor, model::color::createXComplexColor(aComplexColor));
}
else
{
- aComplexColor.setSchemeColor(model::convertToThemeColorType(aLineColor.getSchemeColorIndex()));
+ aComplexColor.setThemeColor(model::convertToThemeColorType(aLineColor.getSchemeColorIndex()));
if (aLineColor.getLumMod() != 10000)
aComplexColor.addTransformation({model::TransformationType::LumMod, aLineColor.getLumMod()});
if (aLineColor.getLumOff() != 0)
diff --git a/oox/source/export/ThemeExport.cxx b/oox/source/export/ThemeExport.cxx
index 568d0dbbf615..05cb19c0850b 100644
--- a/oox/source/export/ThemeExport.cxx
+++ b/oox/source/export/ThemeExport.cxx
@@ -174,23 +174,25 @@ void ThemeExport::writeColorRGB(model::ComplexColor const& rComplexColor)
void ThemeExport::writeColorCRGB(model::ComplexColor const& rComplexColor)
{
- mpFS->startElementNS(XML_a, XML_scrgbClr, XML_r, OString::number(rComplexColor.mnComponent1),
- XML_g, OString::number(rComplexColor.mnComponent2), XML_b,
- OString::number(rComplexColor.mnComponent3));
- writeColorTransformations(rComplexColor.maTransformations);
+ mpFS->startElementNS(XML_a, XML_scrgbClr, XML_r,
+ OString::number(sal_Int32(rComplexColor.getRed())), XML_g,
+ OString::number(sal_Int32(rComplexColor.getGreen())), XML_b,
+ OString::number(sal_Int32(rComplexColor.getBlue())));
+ writeColorTransformations(rComplexColor.getTransformations());
mpFS->endElementNS(XML_a, XML_scrgbClr);
}
void ThemeExport::writeColorHSL(model::ComplexColor const& rComplexColor)
{
- mpFS->startElementNS(XML_a, XML_hslClr, XML_hue, OString::number(rComplexColor.mnComponent1),
- XML_sat, OString::number(rComplexColor.mnComponent2), XML_lum,
- OString::number(rComplexColor.mnComponent3));
- writeColorTransformations(rComplexColor.maTransformations);
+ mpFS->startElementNS(XML_a, XML_hslClr, XML_hue,
+ OString::number(sal_Int32(rComplexColor.getRed())), XML_sat,
+ OString::number(sal_Int32(rComplexColor.getGreen())), XML_lum,
+ OString::number(sal_Int32(rComplexColor.getBlue())));
+ writeColorTransformations(rComplexColor.getTransformations());
mpFS->endElementNS(XML_a, XML_hslClr);
}
-void ThemeExport::writeColorScheme(model::ComplexColor const& rComplexColor)
+void ThemeExport::writeColorTheme(model::ComplexColor const& rComplexColor)
{
static std::unordered_map<model::ThemeColorType, const char*> constThemeColorTypeTokenMap
= { { model::ThemeColorType::Dark1, "dk1" },
@@ -205,12 +207,12 @@ void ThemeExport::writeColorScheme(model::ComplexColor const& rComplexColor)
{ model::ThemeColorType::Accent6, "accent6" },
{ model::ThemeColorType::Hyperlink, "hlink" },
{ model::ThemeColorType::FollowedHyperlink, "folHlink" } };
- auto iterator = constThemeColorTypeTokenMap.find(rComplexColor.meSchemeType);
+ auto iterator = constThemeColorTypeTokenMap.find(rComplexColor.getThemeColorType());
if (iterator != constThemeColorTypeTokenMap.end())
{
const char* sValue = iterator->second;
mpFS->startElementNS(XML_a, XML_schemeClr, XML_val, sValue);
- writeColorTransformations(rComplexColor.maTransformations);
+ writeColorTransformations(rComplexColor.getTransformations());
mpFS->endElementNS(XML_a, XML_schemeClr);
}
}
@@ -249,13 +251,13 @@ void ThemeExport::writeColorSystem(model::ComplexColor const& rComplexColor)
{ model::SystemColorType::WindowFrame, "windowFrame" },
{ model::SystemColorType::WindowText, "windowText" },
};
- auto iterator = constThemeColorTypeTokenMap.find(rComplexColor.meSystemColorType);
+ auto iterator = constThemeColorTypeTokenMap.find(rComplexColor.getSystemColorType());
if (iterator != constThemeColorTypeTokenMap.end())
{
const char* sValue = iterator->second;
mpFS->startElementNS(XML_a, XML_sysClr, XML_val, sValue);
//XML_lastClr
- writeColorTransformations(rComplexColor.maTransformations);
+ writeColorTransformations(rComplexColor.getTransformations());
mpFS->endElementNS(XML_a, XML_schemeClr);
}
}
@@ -263,13 +265,13 @@ void ThemeExport::writeColorSystem(model::ComplexColor const& rComplexColor)
void ThemeExport::writeColorPlaceholder(model::ComplexColor const& rComplexColor)
{
mpFS->startElementNS(XML_a, XML_schemeClr, XML_val, "phClr");
- writeColorTransformations(rComplexColor.maTransformations);
+ writeColorTransformations(rComplexColor.getTransformations());
mpFS->endElementNS(XML_a, XML_schemeClr);
}
void ThemeExport::writeComplexColor(model::ComplexColor const& rComplexColor)
{
- switch (rComplexColor.meType)
+ switch (rComplexColor.getType())
{
case model::ColorType::Unused:
break;
@@ -282,8 +284,8 @@ void ThemeExport::writeComplexColor(model::ComplexColor const& rComplexColor)
case model::ColorType::HSL:
writeColorHSL(rComplexColor);
break;
- case model::ColorType::Scheme:
- writeColorScheme(rComplexColor);
+ case model::ColorType::Theme:
+ writeColorTheme(rComplexColor);
break;
case model::ColorType::Palette:
break;
diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index c0d82d41996b..2e8bf4129860 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -537,9 +537,9 @@ bool DrawingML::WriteSchemeColor(OUString const& rPropertyName, const uno::Refer
return false;
auto aComplexColor = model::color::getFromXComplexColor(xComplexColor);
- if (aComplexColor.getSchemeType() == model::ThemeColorType::Unknown)
+ if (aComplexColor.getThemeColorType() == model::ThemeColorType::Unknown)
return false;
- const char* pColorName = g_aPredefinedClrNames[sal_Int16(aComplexColor.getSchemeType())];
+ const char* pColorName = g_aPredefinedClrNames[sal_Int16(aComplexColor.getThemeColorType())];
mpFS->startElementNS(XML_a, XML_solidFill);
mpFS->startElementNS(XML_a, XML_schemeClr, XML_val, pColorName);
for (auto const& rTransform : aComplexColor.getTransformations())