summaryrefslogtreecommitdiff
path: root/sc/source/filter/oox
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2023-07-30 08:52:44 +0200
committerTomaž Vajngerl <quikee@gmail.com>2023-08-02 21:22:43 +0200
commitc8d8bf4282cbd04abacfa69ba2cc0fa4300e35e1 (patch)
tree270fcf114ac38a4d1b374b6837fa4cc6c9c5d649 /sc/source/filter/oox
parent2d96d69322ac18f53668b75397c8587f94cd043b (diff)
sc: theme color support for sparklines + ODF & OOXML import/export
This changes Sparkline colors to use complex colors instead and adds Sparkline theme color import and export support for ODF and OOXML. Change-Id: I58edd525d50f95199bd4fe7825afb51aaa7fc091 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155113 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'sc/source/filter/oox')
-rw-r--r--sc/source/filter/oox/SparklineFragment.cxx35
1 files changed, 25 insertions, 10 deletions
diff --git a/sc/source/filter/oox/SparklineFragment.cxx b/sc/source/filter/oox/SparklineFragment.cxx
index 38af462c5b3a..afb3f64285ae 100644
--- a/sc/source/filter/oox/SparklineFragment.cxx
+++ b/sc/source/filter/oox/SparklineFragment.cxx
@@ -17,6 +17,7 @@
#include <rangeutl.hxx>
#include <Sparkline.hxx>
#include <themebuffer.hxx>
+#include <docmodel/color/ComplexColor.hxx>
using ::oox::core::ContextHandlerRef;
@@ -56,34 +57,46 @@ namespace
return ::Color();
}
+model::ComplexColor fillComplexColor(const AttributeList& rAttribs, ThemeBuffer const& rThemeBuffer,
+ const GraphicHelper& rGraphicHelper)
+{
+ XlsColor aColor;
+ aColor.importColor(rAttribs);
+ model::ComplexColor aComplexColor = aColor.createComplexColor(rGraphicHelper, -1);
+ ::Color aFinalColor = getColor(rAttribs, rThemeBuffer);
+ aComplexColor.setFinalColor(aFinalColor);
+ return aComplexColor;
+}
+
void addColorsToSparklineAttributes(sc::SparklineAttributes& rAttributes, sal_Int32 nElement,
- const AttributeList& rAttribs, ThemeBuffer& rThemeBuffer)
+ const AttributeList& rAttribs, ThemeBuffer& rThemeBuffer,
+ const GraphicHelper& rHelper)
{
switch (nElement)
{
case XLS14_TOKEN(colorSeries):
- rAttributes.setColorSeries(getColor(rAttribs, rThemeBuffer));
+ rAttributes.setColorSeries(fillComplexColor(rAttribs, rThemeBuffer, rHelper));
break;
case XLS14_TOKEN(colorNegative):
- rAttributes.setColorNegative(getColor(rAttribs, rThemeBuffer));
+ rAttributes.setColorNegative(fillComplexColor(rAttribs, rThemeBuffer, rHelper));
break;
case XLS14_TOKEN(colorAxis):
- rAttributes.setColorAxis(getColor(rAttribs, rThemeBuffer));
+ rAttributes.setColorAxis(fillComplexColor(rAttribs, rThemeBuffer, rHelper));
break;
case XLS14_TOKEN(colorMarkers):
- rAttributes.setColorMarkers(getColor(rAttribs, rThemeBuffer));
+ rAttributes.setColorMarkers(fillComplexColor(rAttribs, rThemeBuffer, rHelper));
break;
case XLS14_TOKEN(colorFirst):
- rAttributes.setColorFirst(getColor(rAttribs, rThemeBuffer));
+ rAttributes.setColorFirst(fillComplexColor(rAttribs, rThemeBuffer, rHelper));
break;
case XLS14_TOKEN(colorLast):
- rAttributes.setColorLast(getColor(rAttribs, rThemeBuffer));
+ rAttributes.setColorLast(fillComplexColor(rAttribs, rThemeBuffer, rHelper));
break;
case XLS14_TOKEN(colorHigh):
- rAttributes.setColorHigh(getColor(rAttribs, rThemeBuffer));
+ rAttributes.setColorHigh(fillComplexColor(rAttribs, rThemeBuffer, rHelper));
break;
case XLS14_TOKEN(colorLow):
- rAttributes.setColorLow(getColor(rAttribs, rThemeBuffer));
+ rAttributes.setColorLow(fillComplexColor(rAttribs, rThemeBuffer, rHelper));
break;
default:
break;
@@ -172,6 +185,7 @@ ContextHandlerRef SparklineGroupsContext::onCreateContext(sal_Int32 nElement,
{
auto& rLastGroup = m_aSparklineGroups.emplace_back();
auto& rSparklineAttributes = rLastGroup.getSparklineGroup()->getAttributes();
+ rSparklineAttributes.resetColors();
addAttributesToSparklineAttributes(rSparklineAttributes, rAttribs);
OUString sGUID = rAttribs.getString(XR2_TOKEN(uid), OUString());
tools::Guid aGuid(OUStringToOString(sGUID, RTL_TEXTENCODING_ASCII_US));
@@ -189,7 +203,8 @@ ContextHandlerRef SparklineGroupsContext::onCreateContext(sal_Int32 nElement,
{
auto& rLastGroup = m_aSparklineGroups.back();
auto& rSparklineAttributes = rLastGroup.getSparklineGroup()->getAttributes();
- addColorsToSparklineAttributes(rSparklineAttributes, nElement, rAttribs, getTheme());
+ addColorsToSparklineAttributes(rSparklineAttributes, nElement, rAttribs, getTheme(),
+ getBaseFilter().getGraphicHelper());
return this;
}
case XLS14_TOKEN(sparklines):