include/docmodel/color/ComplexColor.hxx | 7 include/oox/export/ColorExportUtils.hxx | 44 include/xmloff/XMLComplexColorContext.hxx | 45 include/xmloff/XMLComplexColorExport.hxx | 11 include/xmloff/xmltoken.hxx | 14 oox/Library_oox.mk | 1 oox/source/drawingml/color.cxx | 7 oox/source/export/ColorExportUtils.cxx | 55 + sc/CppunitTest_sc_sparkline_test.mk | 1 sc/CppunitTest_sc_ucalc_sparkline.mk | 3 sc/Library_scfilt.mk | 1 sc/inc/SparklineAttributes.hxx | 35 sc/qa/unit/SparklineImportExportTest.cxx | 92 + sc/qa/unit/data/fods/Sparklines.fods | 590 ++++++++++++ sc/qa/unit/ucalc_sparkline.cxx | 120 ++ sc/source/filter/excel/export/ExportTools.cxx | 45 sc/source/filter/excel/export/SparklineExt.cxx | 60 - sc/source/filter/excel/xestyle.cxx | 1 sc/source/filter/inc/export/ExportTools.hxx | 21 sc/source/filter/oox/SparklineFragment.cxx | 35 sc/source/filter/xml/SparklineGroupsExport.cxx | 32 sc/source/filter/xml/SparklineGroupsExport.hxx | 9 sc/source/filter/xml/SparklineGroupsImportContext.cxx | 126 ++ sc/source/filter/xml/SparklineGroupsImportContext.hxx | 19 sc/source/filter/xml/xmlstyli.cxx | 2 sc/source/ui/dialogs/SparklineDialog.cxx | 28 sc/source/ui/inc/SparklineRenderer.hxx | 42 sc/source/ui/sparklines/SparklineAttributes.cxx | 126 +- sc/source/ui/theme/ThemeColorChanger.cxx | 50 + schema/libreoffice/OpenDocument-v1.3+libreoffice-schema.rng | 88 + xmloff/source/core/xmltoken.cxx | 14 xmloff/source/draw/XMLShapePropertySetContext.cxx | 2 xmloff/source/style/StylePropertiesContext.cxx | 3 xmloff/source/text/XMLComplexColorContext.cxx | 69 + xmloff/source/text/XMLComplexColorExport.cxx | 35 xmloff/source/text/XMLTextPropertySetContext.cxx | 2 xmloff/source/text/XMLTextShapeStyleContext.cxx | 2 xmloff/source/token/tokens.txt | 14 38 files changed, 1515 insertions(+), 336 deletions(-)
New commits: commit 99537f0459ae4143447e122ef1b3aae5a9dbe785 Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Sun Jul 30 08:52:44 2023 +0200 Commit: Mike Kaganski <mike.kagan...@collabora.com> CommitDate: Mon Aug 28 12:41:43 2023 +0200 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 <qui...@gmail.com> (cherry picked from commit c8d8bf4282cbd04abacfa69ba2cc0fa4300e35e1) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156106 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com> diff --git a/include/docmodel/color/ComplexColor.hxx b/include/docmodel/color/ComplexColor.hxx index e9597b15186b..88ff7a42a478 100644 --- a/include/docmodel/color/ComplexColor.hxx +++ b/include/docmodel/color/ComplexColor.hxx @@ -246,6 +246,13 @@ public: o3tl::hash_combine(seed, sal_uInt32(maFinalColor)); return seed; } + + static model::ComplexColor RGB(Color const& rColor) + { + model::ComplexColor aComplexColor; + aComplexColor.setColor(rColor); + return aComplexColor; + } }; } // end of namespace svx diff --git a/include/oox/export/ColorExportUtils.hxx b/include/oox/export/ColorExportUtils.hxx index 63716a10839d..f9dafe260b46 100644 --- a/include/oox/export/ColorExportUtils.hxx +++ b/include/oox/export/ColorExportUtils.hxx @@ -9,47 +9,21 @@ #pragma once -#include <sal/config.h> +#include <oox/dllapi.h> -#include <docmodel/color/ComplexColor.hxx> - -namespace oox +namespace model { -static double convertColorTransformsToTintOrShade(model::ComplexColor const& rComplexColor) +class ComplexColor; +} +namespace model { - sal_Int16 nLumMod = 10'000; - sal_Int16 nLumOff = 0; - - for (auto const& rTransform : rComplexColor.getTransformations()) - { - if (rTransform.meType == model::TransformationType::LumMod) - nLumMod = rTransform.mnValue; - if (rTransform.meType == model::TransformationType::LumOff) - nLumOff = rTransform.mnValue; - } - - if (nLumMod == 10'000 && nLumOff == 0) - return 0.0; - - double fTint = 0.0; - - if (nLumOff > 0) // tint - fTint = double(nLumOff) / 10'000.0; - else - fTint = -double(10'000 - nLumMod) / 10'000.0; - - return fTint; +enum class ThemeColorType : sal_Int32; } -static sal_Int32 convertThemeColorTypeToExcelThemeNumber(model::ThemeColorType eType) +namespace oox { - if (eType == model::ThemeColorType::Unknown) - return -1; - - constexpr std::array<sal_Int32, 12> constMap = { 1, 0, 3, 2, 4, 5, 6, 7, 8, 9, 10, 11 }; - - return constMap[sal_Int32(eType)]; -} +OOX_DLLPUBLIC double convertColorTransformsToTintOrShade(model::ComplexColor const& rComplexColor); +OOX_DLLPUBLIC sal_Int32 convertThemeColorTypeToExcelThemeNumber(model::ThemeColorType eType); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/xmloff/XMLComplexColorContext.hxx b/include/xmloff/XMLComplexColorContext.hxx index cbb785994169..5654cc204206 100644 --- a/include/xmloff/XMLComplexColorContext.hxx +++ b/include/xmloff/XMLComplexColorContext.hxx @@ -10,25 +10,60 @@ #pragma once #include <xmloff/dllapi.h> + #include <memory> #include <xmloff/XMLElementPropertyContext.hxx> -#include <docmodel/uno/UnoComplexColor.hxx> +#include <xmloff/xmlictxt.hxx> +#include <docmodel/color/ComplexColor.hxx> -class XMLOFF_DLLPUBLIC XMLComplexColorContext final : public XMLElementPropertyContext +class XMLOFF_DLLPUBLIC XMLComplexColorImport { +private: + model::ComplexColor& mrComplexColor; + +public: + XMLComplexColorImport(model::ComplexColor& rComplexColor); + void fillAttributes(const css::uno::Reference<css::xml::sax::XFastAttributeList>& xAttrList); + bool + handleTransformContext(sal_Int32 nElement, + const css::uno::Reference<css::xml::sax::XFastAttributeList>& xAttrList); +}; + +class XMLOFF_DLLPUBLIC XMLPropertyComplexColorContext final : public XMLElementPropertyContext +{ +private: model::ComplexColor maComplexColor; sal_Int32 mnRootElement; + XMLComplexColorImport maComplexColorImport; + public: - XMLComplexColorContext(SvXMLImport& rImport, sal_Int32 nElement, - const css::uno::Reference<css::xml::sax::XFastAttributeList>& xAttrList, - const XMLPropertyState& rProp, std::vector<XMLPropertyState>& rProps); + XMLPropertyComplexColorContext( + SvXMLImport& rImport, sal_Int32 nElement, + const css::uno::Reference<css::xml::sax::XFastAttributeList>& xAttrList, + const XMLPropertyState& rProp, std::vector<XMLPropertyState>& rProps); css::uno::Reference<css::xml::sax::XFastContextHandler> SAL_CALL createFastChildContext( sal_Int32 nElement, const css::uno::Reference<css::xml::sax::XFastAttributeList>& AttrList) override; void SAL_CALL endFastElement(sal_Int32 nElement) override; + + model::ComplexColor getComplexColor() { return maComplexColor; } +}; + +class XMLOFF_DLLPUBLIC XMLComplexColorContext final : public SvXMLImportContext +{ +private: + XMLComplexColorImport maComplexColorImport; + +public: + XMLComplexColorContext(SvXMLImport& rImport, model::ComplexColor& rComplexColor, + const css::uno::Reference<css::xml::sax::XFastAttributeList>& xAttrList); + + css::uno::Reference<css::xml::sax::XFastContextHandler> SAL_CALL createFastChildContext( + sal_Int32 nElement, + const css::uno::Reference<css::xml::sax::XFastAttributeList>& AttrList) override; }; /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/xmloff/XMLComplexColorExport.hxx b/include/xmloff/XMLComplexColorExport.hxx index 28911737ff89..51425f52ab55 100644 --- a/include/xmloff/XMLComplexColorExport.hxx +++ b/include/xmloff/XMLComplexColorExport.hxx @@ -11,20 +11,31 @@ #include <xmloff/dllapi.h> #include <sal/types.h> #include <rtl/ustring.hxx> +#include <xmloff/xmltoken.hxx> namespace com::sun::star::uno { class Any; } +namespace model +{ +class ComplexColor; +} + class SvXMLExport; class XMLOFF_DLLPUBLIC XMLComplexColorExport { SvXMLExport& mrExport; + void doExport(model::ComplexColor const& rComplexColor, sal_uInt16 nPrefix, + const OUString& rLocalName); + public: XMLComplexColorExport(SvXMLExport& rExport); + void exportComplexColor(model::ComplexColor const& rComplexColor, sal_uInt16 nPrefix, + xmloff::token::XMLTokenEnum nToken); void exportXML(const css::uno::Any& rAny, sal_uInt16 nPrefix, const OUString& rLocalName); }; diff --git a/include/xmloff/xmltoken.hxx b/include/xmloff/xmltoken.hxx index 580285fa5d30..8d88f616324e 100644 --- a/include/xmloff/xmltoken.hxx +++ b/include/xmloff/xmltoken.hxx @@ -1800,10 +1800,18 @@ namespace xmloff::token { XML_SOURCE_RANGE_ADDRESS, XML_SOURCE_SERVICE, XML_SPACE_BEFORE, - XML_SPARKLINE_GROUPS, - XML_SPARKLINE_GROUP, - XML_SPARKLINES, XML_SPARKLINE, + XML_SPARKLINES, + XML_SPARKLINE_AXIS_COMPLEX_COLOR, + XML_SPARKLINE_FIRST_COMPLEX_COLOR, + XML_SPARKLINE_GROUP, + XML_SPARKLINE_GROUPS, + XML_SPARKLINE_HIGH_COMPLEX_COLOR, + XML_SPARKLINE_LAST_COMPLEX_COLOR, + XML_SPARKLINE_LOW_COMPLEX_COLOR, + XML_SPARKLINE_MARKERS_COMPLEX_COLOR, + XML_SPARKLINE_NEGATIVE_COMPLEX_COLOR, + XML_SPARKLINE_SERIES_COMPLEX_COLOR, XML_SPAN, XML_SPECULAR, XML_SPECULAR_COLOR, diff --git a/oox/Library_oox.mk b/oox/Library_oox.mk index ac130d90350c..f7c96ea1498b 100644 --- a/oox/Library_oox.mk +++ b/oox/Library_oox.mk @@ -228,6 +228,7 @@ $(eval $(call gb_Library_add_exception_objects,oox,\ oox/source/dump/oledumper \ oox/source/dump/pptxdumper \ oox/source/export/ColorPropertySet \ + oox/source/export/ColorExportUtils \ oox/source/export/drawingml \ oox/source/export/DMLPresetShapeExport \ oox/source/export/shapes \ diff --git a/oox/source/drawingml/color.cxx b/oox/source/drawingml/color.cxx index cb0929c4fc00..1a9e39f3832d 100644 --- a/oox/source/drawingml/color.cxx +++ b/oox/source/drawingml/color.cxx @@ -823,9 +823,14 @@ model::ComplexColor Color::createComplexColor(const GraphicHelper& /*rGraphicHel auto eTheme = getThemeColorType(); aNewComplexColor.setSchemeColor(eTheme); } + else if (meMode == COLOR_RGB) + { + ::Color aColor(ColorTransparency, lclRgbComponentsToRgb(mnC1, mnC2, mnC3)); + aNewComplexColor = model::ComplexColor::RGB(aColor); + } else { - // TODO + // TODO - Add other options return aNewComplexColor; } diff --git a/oox/source/export/ColorExportUtils.cxx b/oox/source/export/ColorExportUtils.cxx new file mode 100644 index 000000000000..2b9f7baabc53 --- /dev/null +++ b/oox/source/export/ColorExportUtils.cxx @@ -0,0 +1,55 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include <sal/config.h> +#include <array> +#include <oox/export/ColorExportUtils.hxx> +#include <docmodel/color/ComplexColor.hxx> + +namespace oox +{ +double convertColorTransformsToTintOrShade(model::ComplexColor const& rComplexColor) +{ + sal_Int16 nLumMod = 10'000; + sal_Int16 nLumOff = 0; + + for (auto const& rTransform : rComplexColor.getTransformations()) + { + if (rTransform.meType == model::TransformationType::LumMod) + nLumMod = rTransform.mnValue; + if (rTransform.meType == model::TransformationType::LumOff) + nLumOff = rTransform.mnValue; + } + + if (nLumMod == 10'000 && nLumOff == 0) + return 0.0; + + double fTint = 0.0; + + if (nLumOff > 0) // tint + fTint = double(nLumOff) / 10'000.0; + else + fTint = -double(10'000 - nLumMod) / 10'000.0; + + return fTint; +} + +sal_Int32 convertThemeColorTypeToExcelThemeNumber(model::ThemeColorType eType) +{ + if (eType == model::ThemeColorType::Unknown) + return -1; + + static constexpr std::array<sal_Int32, 12> constThemeColorMapToXmlMap + = { 1, 0, 3, 2, 4, 5, 6, 7, 8, 9, 10, 11 }; + + return constThemeColorMapToXmlMap[sal_Int32(eType)]; +} +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/CppunitTest_sc_sparkline_test.mk b/sc/CppunitTest_sc_sparkline_test.mk index ca678f4829d8..c1f06f65e3d2 100644 --- a/sc/CppunitTest_sc_sparkline_test.mk +++ b/sc/CppunitTest_sc_sparkline_test.mk @@ -28,6 +28,7 @@ $(eval $(call gb_CppunitTest_use_libraries,sc_sparkline_test, \ comphelper \ cppu \ cppuhelper \ + docmodel \ sal \ salhelper \ sax \ diff --git a/sc/CppunitTest_sc_ucalc_sparkline.mk b/sc/CppunitTest_sc_ucalc_sparkline.mk index 99f75e086fc0..24d24b99ee4e 100644 --- a/sc/CppunitTest_sc_ucalc_sparkline.mk +++ b/sc/CppunitTest_sc_ucalc_sparkline.mk @@ -28,12 +28,15 @@ $(eval $(call gb_CppunitTest_use_libraries,sc_ucalc_sparkline, \ comphelper \ cppu \ cppuhelper \ + docmodel \ + editeng \ sal \ salhelper \ sax \ sc \ scqahelper \ sfx \ + svxcore \ subsequenttest \ test \ tl \ diff --git a/sc/Library_scfilt.mk b/sc/Library_scfilt.mk index aa4e1fae787c..19d7d788e6ee 100644 --- a/sc/Library_scfilt.mk +++ b/sc/Library_scfilt.mk @@ -132,6 +132,7 @@ $(eval $(call gb_Library_add_exception_objects,scfilt,\ sc/source/filter/excel/xltracer \ sc/source/filter/excel/xlview \ sc/source/filter/excel/export/SparklineExt \ + sc/source/filter/excel/export/ExportTools \ sc/source/filter/ftools/fapihelper \ sc/source/filter/ftools/fprogressbar \ sc/source/filter/ftools/ftools \ diff --git a/sc/inc/SparklineAttributes.hxx b/sc/inc/SparklineAttributes.hxx index d1baf732ced3..04a6c0abb696 100644 --- a/sc/inc/SparklineAttributes.hxx +++ b/sc/inc/SparklineAttributes.hxx @@ -13,6 +13,7 @@ #include "scdllapi.h" #include <sal/types.h> #include <tools/color.hxx> +#include <docmodel/color/ComplexColor.hxx> #include <optional> #include <o3tl/cow_wrapper.hxx> @@ -63,29 +64,31 @@ public: return !(SparklineAttributes::operator==(rOther)); } - Color getColorSeries() const; - void setColorSeries(Color aColorSeries); + void resetColors(); - Color getColorNegative() const; - void setColorNegative(Color aColorSeries); + model::ComplexColor getColorSeries() const; + void setColorSeries(model::ComplexColor const& rColorSeries); - Color getColorAxis() const; - void setColorAxis(Color aColorSeries); + model::ComplexColor getColorNegative() const; + void setColorNegative(model::ComplexColor const& rColorSeries); - Color getColorMarkers() const; - void setColorMarkers(Color aColorSeries); + model::ComplexColor getColorAxis() const; + void setColorAxis(model::ComplexColor const& rColorSeries); - Color getColorFirst() const; - void setColorFirst(Color aColorSeries); + model::ComplexColor getColorMarkers() const; + void setColorMarkers(model::ComplexColor const& rColorSeries); - Color getColorLast() const; - void setColorLast(Color aColorSeries); + model::ComplexColor getColorFirst() const; + void setColorFirst(model::ComplexColor const& rColorSeries); - Color getColorHigh() const; - void setColorHigh(Color aColorSeries); + model::ComplexColor getColorLast() const; + void setColorLast(model::ComplexColor const& rColorSeries); - Color getColorLow() const; - void setColorLow(Color aColorSeries); + model::ComplexColor getColorHigh() const; + void setColorHigh(model::ComplexColor const& rColorSeries); + + model::ComplexColor getColorLow() const; + void setColorLow(model::ComplexColor const& rColorSeries); AxisType getMinAxisType() const; void setMinAxisType(AxisType eAxisType); diff --git a/sc/qa/unit/SparklineImportExportTest.cxx b/sc/qa/unit/SparklineImportExportTest.cxx index 993303e00a4e..2e381b5668ae 100644 --- a/sc/qa/unit/SparklineImportExportTest.cxx +++ b/sc/qa/unit/SparklineImportExportTest.cxx @@ -35,12 +35,16 @@ public: void testSparklinesExportODS(); void testSparklinesRoundtripODS(); void testNoSparklinesInDocumentXLSX(); + void testSparklinesRoundtripThemeColorsODS(); + void testSparklinesRoundtripThemeColorsOOXML(); CPPUNIT_TEST_SUITE(SparklineImportExportTest); CPPUNIT_TEST(testSparklinesRoundtripXLSX); CPPUNIT_TEST(testSparklinesExportODS); CPPUNIT_TEST(testSparklinesRoundtripODS); CPPUNIT_TEST(testNoSparklinesInDocumentXLSX); + CPPUNIT_TEST(testSparklinesRoundtripThemeColorsODS); + CPPUNIT_TEST(testSparklinesRoundtripThemeColorsOOXML); CPPUNIT_TEST_SUITE_END(); }; @@ -58,14 +62,14 @@ void checkSparklines(ScDocument& rDocument) auto& rAttributes = pSparkline->getSparklineGroup()->getAttributes(); CPPUNIT_ASSERT_EQUAL(sc::SparklineType::Line, rAttributes.getType()); - CPPUNIT_ASSERT_EQUAL(Color(0x376092), rAttributes.getColorSeries()); - CPPUNIT_ASSERT_EQUAL(Color(0x00b050), rAttributes.getColorNegative()); - CPPUNIT_ASSERT_EQUAL(COL_BLACK, rAttributes.getColorAxis()); - CPPUNIT_ASSERT_EQUAL(COL_BLACK, rAttributes.getColorMarkers()); - CPPUNIT_ASSERT_EQUAL(Color(0x7030a0), rAttributes.getColorFirst()); - CPPUNIT_ASSERT_EQUAL(Color(0xff0000), rAttributes.getColorLast()); - CPPUNIT_ASSERT_EQUAL(Color(0x92d050), rAttributes.getColorHigh()); - CPPUNIT_ASSERT_EQUAL(Color(0x00b0f0), rAttributes.getColorLow()); + CPPUNIT_ASSERT_EQUAL(Color(0x376092), rAttributes.getColorSeries().getFinalColor()); + CPPUNIT_ASSERT_EQUAL(Color(0x00b050), rAttributes.getColorNegative().getFinalColor()); + CPPUNIT_ASSERT_EQUAL(COL_BLACK, rAttributes.getColorAxis().getFinalColor()); + CPPUNIT_ASSERT_EQUAL(COL_BLACK, rAttributes.getColorMarkers().getFinalColor()); + CPPUNIT_ASSERT_EQUAL(Color(0x7030a0), rAttributes.getColorFirst().getFinalColor()); + CPPUNIT_ASSERT_EQUAL(Color(0xff0000), rAttributes.getColorLast().getFinalColor()); + CPPUNIT_ASSERT_EQUAL(Color(0x92d050), rAttributes.getColorHigh().getFinalColor()); + CPPUNIT_ASSERT_EQUAL(Color(0x00b0f0), rAttributes.getColorLow().getFinalColor()); CPPUNIT_ASSERT_DOUBLES_EQUAL(1.0, rAttributes.getLineWeight(), 1E-2); CPPUNIT_ASSERT_EQUAL(false, rAttributes.isDateAxis()); @@ -91,14 +95,14 @@ void checkSparklines(ScDocument& rDocument) auto& rAttributes = pSparkline->getSparklineGroup()->getAttributes(); CPPUNIT_ASSERT_EQUAL(sc::SparklineType::Column, rAttributes.getType()); - CPPUNIT_ASSERT_EQUAL(Color(0x376092), rAttributes.getColorSeries()); - CPPUNIT_ASSERT_EQUAL(Color(0xff0000), rAttributes.getColorNegative()); - CPPUNIT_ASSERT_EQUAL(COL_BLACK, rAttributes.getColorAxis()); - CPPUNIT_ASSERT_EQUAL(Color(0xd00000), rAttributes.getColorMarkers()); - CPPUNIT_ASSERT_EQUAL(Color(0x92d050), rAttributes.getColorFirst()); - CPPUNIT_ASSERT_EQUAL(Color(0x00b0f0), rAttributes.getColorLast()); - CPPUNIT_ASSERT_EQUAL(Color(0x7030a0), rAttributes.getColorHigh()); - CPPUNIT_ASSERT_EQUAL(Color(0xffc000), rAttributes.getColorLow()); + CPPUNIT_ASSERT_EQUAL(Color(0x376092), rAttributes.getColorSeries().getFinalColor()); + CPPUNIT_ASSERT_EQUAL(Color(0xff0000), rAttributes.getColorNegative().getFinalColor()); + CPPUNIT_ASSERT_EQUAL(COL_BLACK, rAttributes.getColorAxis().getFinalColor()); + CPPUNIT_ASSERT_EQUAL(Color(0xd00000), rAttributes.getColorMarkers().getFinalColor()); + CPPUNIT_ASSERT_EQUAL(Color(0x92d050), rAttributes.getColorFirst().getFinalColor()); + CPPUNIT_ASSERT_EQUAL(Color(0x00b0f0), rAttributes.getColorLast().getFinalColor()); + CPPUNIT_ASSERT_EQUAL(Color(0x7030a0), rAttributes.getColorHigh().getFinalColor()); + CPPUNIT_ASSERT_EQUAL(Color(0xffc000), rAttributes.getColorLow().getFinalColor()); CPPUNIT_ASSERT_EQUAL(0.75, rAttributes.getLineWeight()); CPPUNIT_ASSERT_EQUAL(false, rAttributes.isDateAxis()); @@ -228,7 +232,7 @@ void SparklineImportExportTest::testSparklinesRoundtripODS() void SparklineImportExportTest::testNoSparklinesInDocumentXLSX() { // tdf#148835 - // Check no sparkline elements are written when there is none in the document + // Check no sparkline elements are written when there are none in the document // Load the document containing NO sparklines loadFromURL(u"xlsx/empty.xlsx"); @@ -243,6 +247,60 @@ void SparklineImportExportTest::testNoSparklinesInDocumentXLSX() assertXPath(pXmlDoc, "/x:worksheet/x:extLst", 0); } +namespace +{ +void checkSparklineThemeColors(ScDocument& rDocument) +{ + auto pSparkline = rDocument.GetSparkline(ScAddress(0, 1, 0)); // A2 + CPPUNIT_ASSERT(pSparkline); + CPPUNIT_ASSERT_EQUAL(OString("{1C5C5DE0-3C09-4CB3-A3EC-9E763301EC82}"), + pSparkline->getSparklineGroup()->getID().getString()); + + auto& rAttributes = pSparkline->getSparklineGroup()->getAttributes(); + CPPUNIT_ASSERT_EQUAL(sc::SparklineType::Column, rAttributes.getType()); + + CPPUNIT_ASSERT_EQUAL(model::ThemeColorType::Accent3, + rAttributes.getColorSeries().getSchemeType()); + CPPUNIT_ASSERT_EQUAL(model::ThemeColorType::Accent6, + rAttributes.getColorNegative().getSchemeType()); + CPPUNIT_ASSERT_EQUAL(model::ColorType::Unused, rAttributes.getColorAxis().getType()); + CPPUNIT_ASSERT_EQUAL(model::ThemeColorType::Light1, + rAttributes.getColorMarkers().getSchemeType()); + CPPUNIT_ASSERT_EQUAL(model::ThemeColorType::Accent5, + rAttributes.getColorFirst().getSchemeType()); + CPPUNIT_ASSERT_EQUAL(model::ThemeColorType::Accent2, + rAttributes.getColorLast().getSchemeType()); + CPPUNIT_ASSERT_EQUAL(model::ThemeColorType::Accent1, + rAttributes.getColorHigh().getSchemeType()); + CPPUNIT_ASSERT_EQUAL(model::ThemeColorType::Accent4, rAttributes.getColorLow().getSchemeType()); +} +} // end anonymous namespace + +void SparklineImportExportTest::testSparklinesRoundtripThemeColorsODS() +{ + loadFromURL(u"fods/Sparklines.fods"); + + ScModelObj* pModelObj = comphelper::getFromUnoTunnel<ScModelObj>(mxComponent); + CPPUNIT_ASSERT(pModelObj); + checkSparklineThemeColors(*pModelObj->GetDocument()); + + saveAndReload("calc8"); + + pModelObj = comphelper::getFromUnoTunnel<ScModelObj>(mxComponent); + CPPUNIT_ASSERT(pModelObj); + checkSparklineThemeColors(*pModelObj->GetDocument()); +} + +void SparklineImportExportTest::testSparklinesRoundtripThemeColorsOOXML() +{ + loadFromURL(u"fods/Sparklines.fods"); + saveAndReload("Calc Office Open XML"); + + ScModelObj* pModelObj = comphelper::getFromUnoTunnel<ScModelObj>(mxComponent); + CPPUNIT_ASSERT(pModelObj); + checkSparklineThemeColors(*pModelObj->GetDocument()); +} + CPPUNIT_TEST_SUITE_REGISTRATION(SparklineImportExportTest); CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sc/qa/unit/data/fods/Sparklines.fods b/sc/qa/unit/data/fods/Sparklines.fods new file mode 100644 index 000000000000..b952471b5550 --- /dev/null +++ b/sc/qa/unit/data/fods/Sparklines.fods @@ -0,0 +1,590 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<office:document xmlns:presentation="urn:oasis:names:tc:opendocument:xmlns:presentation:1.0" xmlns:css3t="http://www.w3.org/TR/css3-text/" xmlns:grddl="http://www.w3.org/2003/g/data-view#" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xforms="http://www.w3.org/2002/xforms" xmlns:dom="http://www.w3.org/2001/xml-events" xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:ooo="http://openoffice.org/2004/office" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0" xmlns:ooow="http://openoffice.org/2004/writer" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:drawooo="http://openoffice.org/2010/draw" xmlns:oooc="http://o penoffice.org/2004/calc" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:calcext="urn:org:documentfoundation:names:experimental:calc:xmlns:calcext:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:of="urn:oasis:names:tc:opendocument:xmlns:of:1.2" xmlns:tableooo="http://openoffice.org/2009/table" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:rpt="http://openoffice.org/2005/report" xmlns:formx="urn:openoffice:names:experimental:ooxml-odf-interop:xmlns:form:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:field="urn:openoffice:names:experimental:ooo-ms-interop:xmlns:field:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:meta="urn:oasis:name s:tc:opendocument:xmlns:meta:1.0" xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0" office:version="1.3" office:mimetype="application/vnd.oasis.opendocument.spreadsheet"> + <office:meta><meta:initial-creator>quikee</meta:initial-creator><meta:creation-date>2022-02-23T12:01:27</meta:creation-date><dc:date>2023-07-30T09:09:00.836498837</dc:date><meta:generator>LibreOfficeDev/24.2.0.0.alpha0$Linux_X86_64 LibreOffice_project/392723e6d33455e375b469a6eabfc843cc311599</meta:generator><meta:editing-duration>PT3M20S</meta:editing-duration><meta:editing-cycles>1</meta:editing-cycles><meta:document-statistic meta:table-count="1" meta:cell-count="12" meta:object-count="0"/><meta:user-defined meta:name="AppVersion">16.0300</meta:user-defined></office:meta> + <office:settings> + <config:config-item-set config:name="ooo:view-settings"> + <config:config-item config:name="VisibleAreaTop" config:type="int">0</config:config-item> + <config:config-item config:name="VisibleAreaLeft" config:type="int">0</config:config-item> + <config:config-item config:name="VisibleAreaWidth" config:type="int">27824</config:config-item> + <config:config-item config:name="VisibleAreaHeight" config:type="int">4445</config:config-item> + <config:config-item-map-indexed config:name="Views"> + <config:config-item-map-entry> + <config:config-item config:name="ViewId" config:type="string">view1</config:config-item> + <config:config-item-map-named config:name="Tables"> + <config:config-item-map-entry config:name="Sheet1"> + <config:config-item config:name="CursorPositionX" config:type="int">0</config:config-item> + <config:config-item config:name="CursorPositionY" config:type="int">1</config:config-item> + <config:config-item config:name="ActiveSplitRange" config:type="short">2</config:config-item> + <config:config-item config:name="PositionLeft" config:type="int">0</config:config-item> + <config:config-item config:name="PositionRight" config:type="int">0</config:config-item> + <config:config-item config:name="PositionTop" config:type="int">0</config:config-item> + <config:config-item config:name="PositionBottom" config:type="int">0</config:config-item> + <config:config-item config:name="ZoomType" config:type="short">0</config:config-item> + <config:config-item config:name="ZoomValue" config:type="int">100</config:config-item> + <config:config-item config:name="PageViewZoomValue" config:type="int">60</config:config-item> + <config:config-item config:name="ShowGrid" config:type="boolean">true</config:config-item> + <config:config-item config:name="AnchoredTextOverflowLegacy" config:type="boolean">false</config:config-item> + <config:config-item config:name="LegacySingleLineFontwork" config:type="boolean">false</config:config-item> + <config:config-item config:name="ConnectorUseSnapRect" config:type="boolean">false</config:config-item> + <config:config-item config:name="IgnoreBreakAfterMultilineField" config:type="boolean">false</config:config-item> + </config:config-item-map-entry> + </config:config-item-map-named> + <config:config-item config:name="ActiveTable" config:type="string">Sheet1</config:config-item> + <config:config-item config:name="HorizontalScrollbarWidth" config:type="int">1744</config:config-item> + <config:config-item config:name="ZoomType" config:type="short">0</config:config-item> + <config:config-item config:name="ZoomValue" config:type="int">100</config:config-item> + <config:config-item config:name="PageViewZoomValue" config:type="int">60</config:config-item> + <config:config-item config:name="ShowPageBreakPreview" config:type="boolean">false</config:config-item> + <config:config-item config:name="ShowZeroValues" config:type="boolean">true</config:config-item> + <config:config-item config:name="ShowNotes" config:type="boolean">true</config:config-item> + <config:config-item config:name="ShowFormulasMarks" config:type="boolean">false</config:config-item> + <config:config-item config:name="ShowGrid" config:type="boolean">true</config:config-item> + <config:config-item config:name="GridColor" config:type="int">-1</config:config-item> + <config:config-item config:name="ShowPageBreaks" config:type="boolean">true</config:config-item> + <config:config-item config:name="FormulaBarHeight" config:type="short">1</config:config-item> + <config:config-item config:name="HasSheetTabs" config:type="boolean">true</config:config-item> + <config:config-item config:name="IsOutlineSymbolsSet" config:type="boolean">true</config:config-item> + <config:config-item config:name="IsValueHighlightingEnabled" config:type="boolean">false</config:config-item> + <config:config-item config:name="IsSnapToRaster" config:type="boolean">false</config:config-item> + <config:config-item config:name="RasterIsVisible" config:type="boolean">false</config:config-item> + <config:config-item config:name="RasterResolutionX" config:type="int">1000</config:config-item> + <config:config-item config:name="RasterResolutionY" config:type="int">1000</config:config-item> + <config:config-item config:name="RasterSubdivisionX" config:type="int">1</config:config-item> + <config:config-item config:name="RasterSubdivisionY" config:type="int">1</config:config-item> + <config:config-item config:name="IsRasterAxisSynchronized" config:type="boolean">true</config:config-item> + <config:config-item config:name="AnchoredTextOverflowLegacy" config:type="boolean">false</config:config-item> + <config:config-item config:name="LegacySingleLineFontwork" config:type="boolean">false</config:config-item> + <config:config-item config:name="ConnectorUseSnapRect" config:type="boolean">false</config:config-item> + <config:config-item config:name="IgnoreBreakAfterMultilineField" config:type="boolean">false</config:config-item> + </config:config-item-map-entry> + </config:config-item-map-indexed> + </config:config-item-set> + <config:config-item-set config:name="ooo:configuration-settings"> + <config:config-item config:name="AllowPrintJobCancel" config:type="boolean">true</config:config-item> + <config:config-item config:name="ApplyUserData" config:type="boolean">true</config:config-item> + <config:config-item config:name="AutoCalculate" config:type="boolean">true</config:config-item> + <config:config-item config:name="CharacterCompressionType" config:type="short">0</config:config-item> + <config:config-item config:name="EmbedAsianScriptFonts" config:type="boolean">true</config:config-item> + <config:config-item config:name="EmbedComplexScriptFonts" config:type="boolean">true</config:config-item> + <config:config-item config:name="EmbedFonts" config:type="boolean">false</config:config-item> + <config:config-item config:name="EmbedLatinScriptFonts" config:type="boolean">true</config:config-item> + <config:config-item config:name="EmbedOnlyUsedFonts" config:type="boolean">false</config:config-item> + <config:config-item config:name="GridColor" config:type="int">-1</config:config-item> + <config:config-item config:name="HasColumnRowHeaders" config:type="boolean">true</config:config-item> + <config:config-item config:name="HasSheetTabs" config:type="boolean">true</config:config-item> + <config:config-item config:name="ImagePreferredDPI" config:type="int">0</config:config-item> + <config:config-item config:name="IsDocumentShared" config:type="boolean">false</config:config-item> + <config:config-item config:name="IsKernAsianPunctuation" config:type="boolean">false</config:config-item> + <config:config-item config:name="IsOutlineSymbolsSet" config:type="boolean">true</config:config-item> + <config:config-item config:name="IsRasterAxisSynchronized" config:type="boolean">true</config:config-item> + <config:config-item config:name="IsSnapToRaster" config:type="boolean">false</config:config-item> + <config:config-item config:name="LinkUpdateMode" config:type="short">3</config:config-item> + <config:config-item config:name="LoadReadonly" config:type="boolean">false</config:config-item> + <config:config-item config:name="PrinterName" config:type="string"/> + <config:config-item config:name="PrinterPaperFromSetup" config:type="boolean">false</config:config-item> + <config:config-item config:name="PrinterSetup" config:type="base64Binary"/> + <config:config-item config:name="RasterIsVisible" config:type="boolean">false</config:config-item> + <config:config-item config:name="RasterResolutionX" config:type="int">1000</config:config-item> + <config:config-item config:name="RasterResolutionY" config:type="int">1000</config:config-item> + <config:config-item config:name="RasterSubdivisionX" config:type="int">1</config:config-item> + <config:config-item config:name="RasterSubdivisionY" config:type="int">1</config:config-item> + <config:config-item config:name="SaveThumbnail" config:type="boolean">true</config:config-item> + <config:config-item config:name="SaveVersionOnClose" config:type="boolean">false</config:config-item> + <config:config-item config:name="ShowFormulasMarks" config:type="boolean">false</config:config-item> + <config:config-item config:name="ShowGrid" config:type="boolean">true</config:config-item> + <config:config-item config:name="ShowNotes" config:type="boolean">true</config:config-item> + <config:config-item config:name="ShowPageBreaks" config:type="boolean">true</config:config-item> + <config:config-item config:name="ShowZeroValues" config:type="boolean">true</config:config-item> + <config:config-item config:name="SyntaxStringRef" config:type="short">2</config:config-item> + <config:config-item config:name="UpdateFromTemplate" config:type="boolean">true</config:config-item> + </config:config-item-set> + </office:settings> + <office:scripts> + <office:script script:language="ooo:Basic"> + <ooo:libraries xmlns:ooo="http://openoffice.org/2004/office" xmlns:xlink="http://www.w3.org/1999/xlink"/> + </office:script> + </office:scripts> + <office:font-face-decls> + <style:font-face style:name="Calibri" svg:font-family="Calibri" style:font-family-generic="swiss"/> + <style:font-face style:name="Liberation Sans" svg:font-family="'Liberation Sans'" style:font-family-generic="swiss" style:font-pitch="variable"/> + <style:font-face style:name="Lohit Devanagari" svg:font-family="'Lohit Devanagari'" style:font-family-generic="system" style:font-pitch="variable"/> + <style:font-face style:name="Source Han Sans CN" svg:font-family="'Source Han Sans CN'" style:font-family-generic="system" style:font-pitch="variable"/> + </office:font-face-decls> + <office:styles> + <style:default-style style:family="table-cell"> + <style:paragraph-properties style:tab-stop-distance="1.25cm"/> + <style:text-properties style:font-name="Liberation Sans" fo:font-size="10pt" fo:language="en" fo:country="GB" style:font-name-asian="Source Han Sans CN" style:font-size-asian="10pt" style:language-asian="zh" style:country-asian="CN" style:font-name-complex="Lohit Devanagari" style:font-size-complex="10pt" style:language-complex="hi" style:country-complex="IN"/> + </style:default-style> + <style:default-style style:family="graphic"> + <style:graphic-properties svg:stroke-color="#3465a4" draw:fill-color="#729fcf" fo:wrap-option="no-wrap" draw:shadow-offset-x="0.3cm" draw:shadow-offset-y="0.3cm" style:writing-mode="page"/> + <style:paragraph-properties style:text-autospace="ideograph-alpha" style:punctuation-wrap="simple" style:line-break="strict" style:writing-mode="page" style:font-independent-line-spacing="false"> + <style:tab-stops/> + </style:paragraph-properties> + <style:text-properties style:use-window-font-color="true" loext:opacity="0%" fo:font-family="'Liberation Serif'" style:font-family-generic="roman" style:font-pitch="variable" fo:font-size="12pt" fo:language="en" fo:country="GB" style:letter-kerning="true" style:font-family-asian="'DejaVu Sans'" style:font-family-generic-asian="system" style:font-pitch-asian="variable" style:font-size-asian="12pt" style:language-asian="zh" style:country-asian="CN" style:font-family-complex="'Bitstream Vera Sans'" style:font-family-generic-complex="system" style:font-pitch-complex="variable" style:font-size-complex="12pt" style:language-complex="hi" style:country-complex="IN"/> + </style:default-style> + <style:style style:name="Default" style:family="graphic"/> + <style:style style:name="Note" style:family="graphic" style:parent-style-name="Default"> + <style:graphic-properties draw:stroke="solid" draw:marker-start="Arrowheads_20_1" draw:marker-start-width="0.2cm" draw:marker-start-center="false" draw:fill="solid" draw:fill-color="#ffffc0" draw:auto-grow-height="true" draw:auto-grow-width="false" fo:padding-top="0.1cm" fo:padding-bottom="0.1cm" fo:padding-left="0.1cm" fo:padding-right="0.1cm" draw:shadow="visible" draw:shadow-offset-x="0.1cm" draw:shadow-offset-y="0.1cm"/> + <style:text-properties style:font-name="Liberation Sans" fo:font-family="'Liberation Sans'" style:font-family-generic="swiss" style:font-pitch="variable" fo:font-size="10pt" style:font-name-asian="Source Han Sans CN" style:font-family-asian="'Source Han Sans CN'" style:font-family-generic-asian="system" style:font-pitch-asian="variable" style:font-size-asian="10pt" style:font-name-complex="Lohit Devanagari" style:font-family-complex="'Lohit Devanagari'" style:font-family-generic-complex="system" style:font-pitch-complex="variable" style:font-size-complex="10pt"/> + </style:style> + <number:number-style style:name="N0"> + <number:number number:min-integer-digits="1"/> + </number:number-style> + <number:date-style style:name="N119"> + <number:day number:style="long"/> + <number:text>-</number:text> + <number:month number:textual="true"/> + <number:text>-</number:text> + <number:year/> + </number:date-style> + <number:date-style style:name="N120"> + <number:day number:style="long"/> + <number:text>-</number:text> + <number:month number:textual="true"/> + </number:date-style> + <number:date-style style:name="N121"> + <number:month number:textual="true"/> + <number:text>-</number:text> + <number:year/> + </number:date-style> + <number:time-style style:name="N122"> + <number:hours/> + <number:text>:</number:text> + <number:minutes number:style="long"/> + <number:text> </number:text> + <number:am-pm/> + </number:time-style> + <number:time-style style:name="N123"> + <number:hours/> + <number:text>:</number:text> + <number:minutes number:style="long"/> + <number:text>:</number:text> + <number:seconds number:style="long"/> + <number:text> </number:text> + <number:am-pm/> + </number:time-style> + <number:number-style style:name="N124P0" style:volatile="true"> + <number:number number:decimal-places="0" number:min-decimal-places="0" number:min-integer-digits="1" number:grouping="true"/> + </number:number-style> + <number:number-style style:name="N124"> + <number:text>-</number:text> + <number:number number:decimal-places="0" number:min-decimal-places="0" number:min-integer-digits="1" number:grouping="true"/> + <style:map style:condition="value()>=0" style:apply-style-name="N124P0"/> + </number:number-style> + <number:number-style style:name="N125P0" style:volatile="true"> + <number:number number:decimal-places="0" number:min-decimal-places="0" number:min-integer-digits="1" number:grouping="true"/> + </number:number-style> + <number:number-style style:name="N125"> + <style:text-properties fo:color="#ff0000"/> + <number:text>-</number:text> + <number:number number:decimal-places="0" number:min-decimal-places="0" number:min-integer-digits="1" number:grouping="true"/> + <style:map style:condition="value()>=0" style:apply-style-name="N125P0"/> + </number:number-style> + <number:number-style style:name="N126P0" style:volatile="true"> + <number:number number:decimal-places="2" number:min-decimal-places="2" number:min-integer-digits="1" number:grouping="true"/> + </number:number-style> + <number:number-style style:name="N126"> + <number:text>-</number:text> + <number:number number:decimal-places="2" number:min-decimal-places="2" number:min-integer-digits="1" number:grouping="true"/> + <style:map style:condition="value()>=0" style:apply-style-name="N126P0"/> + </number:number-style> + <number:number-style style:name="N127P0" style:volatile="true"> + <number:number number:decimal-places="2" number:min-decimal-places="2" number:min-integer-digits="1" number:grouping="true"/> + </number:number-style> + <number:number-style style:name="N127"> + <style:text-properties fo:color="#ff0000"/> + <number:text>-</number:text> + <number:number number:decimal-places="2" number:min-decimal-places="2" number:min-integer-digits="1" number:grouping="true"/> + <style:map style:condition="value()>=0" style:apply-style-name="N127P0"/> + </number:number-style> + <number:number-style style:name="N128P0" style:volatile="true"> + <number:text> </number:text> + <number:fill-character> </number:fill-character> + <number:number number:decimal-places="0" number:min-decimal-places="0" number:min-integer-digits="1" number:grouping="true"/> + <number:text> </number:text> + </number:number-style> + <number:number-style style:name="N128P1" style:volatile="true"> + <number:text>-</number:text> + <number:fill-character> </number:fill-character> + <number:number number:decimal-places="0" number:min-decimal-places="0" number:min-integer-digits="1" number:grouping="true"/> + <number:text> </number:text> + </number:number-style> + <number:number-style style:name="N128P2" style:volatile="true"> + <number:text> </number:text> + <number:fill-character> </number:fill-character> + <number:text>- </number:text> + </number:number-style> + <number:text-style style:name="N128"> + <number:text> </number:text> + <number:text-content/> + <number:text> </number:text> + <style:map style:condition="value()>0" style:apply-style-name="N128P0"/> + <style:map style:condition="value()<0" style:apply-style-name="N128P1"/> + <style:map style:condition="value()=0" style:apply-style-name="N128P2"/> + </number:text-style> + <number:number-style style:name="N129P0" style:volatile="true"> + <number:text> £</number:text> + <number:fill-character> </number:fill-character> + <number:number number:decimal-places="0" number:min-decimal-places="0" number:min-integer-digits="1" number:grouping="true"/> + <number:text> </number:text> + </number:number-style> + <number:number-style style:name="N129P1" style:volatile="true"> + <number:text>-£</number:text> + <number:fill-character> </number:fill-character> + <number:number number:decimal-places="0" number:min-decimal-places="0" number:min-integer-digits="1" number:grouping="true"/> + <number:text> </number:text> + </number:number-style> + <number:number-style style:name="N129P2" style:volatile="true"> + <number:text> £</number:text> + <number:fill-character> </number:fill-character> + <number:text>- </number:text> + </number:number-style> + <number:text-style style:name="N129"> + <number:text> </number:text> + <number:text-content/> + <number:text> </number:text> + <style:map style:condition="value()>0" style:apply-style-name="N129P0"/> + <style:map style:condition="value()<0" style:apply-style-name="N129P1"/> + <style:map style:condition="value()=0" style:apply-style-name="N129P2"/> + </number:text-style> + <number:number-style style:name="N130P0" style:volatile="true"> + <number:text> </number:text> + <number:fill-character> </number:fill-character> + <number:number number:decimal-places="2" number:min-decimal-places="2" number:min-integer-digits="1" number:grouping="true"/> + <number:text> </number:text> + </number:number-style> + <number:number-style style:name="N130P1" style:volatile="true"> + <number:text>-</number:text> + <number:fill-character> </number:fill-character> + <number:number number:decimal-places="2" number:min-decimal-places="2" number:min-integer-digits="1" number:grouping="true"/> + <number:text> </number:text> + </number:number-style> + <number:number-style style:name="N130P2" style:volatile="true"> + <number:text> </number:text> + <number:fill-character> </number:fill-character> + <number:text>-</number:text> + <number:number number:decimal-places="0" number:min-decimal-places="0" number:min-integer-digits="2" loext:max-blank-integer-digits="2"/> + <number:text> </number:text> + </number:number-style> + <number:text-style style:name="N130"> + <number:text> </number:text> + <number:text-content/> + <number:text> </number:text> + <style:map style:condition="value()>0" style:apply-style-name="N130P0"/> + <style:map style:condition="value()<0" style:apply-style-name="N130P1"/> + <style:map style:condition="value()=0" style:apply-style-name="N130P2"/> + </number:text-style> + <number:number-style style:name="N131P0" style:volatile="true"> + <number:text> £</number:text> + <number:fill-character> </number:fill-character> + <number:number number:decimal-places="2" number:min-decimal-places="2" number:min-integer-digits="1" number:grouping="true"/> + <number:text> </number:text> + </number:number-style> + <number:number-style style:name="N131P1" style:volatile="true"> + <number:text>-£</number:text> + <number:fill-character> </number:fill-character> + <number:number number:decimal-places="2" number:min-decimal-places="2" number:min-integer-digits="1" number:grouping="true"/> + <number:text> </number:text> + </number:number-style> + <number:number-style style:name="N131P2" style:volatile="true"> + <number:text> £</number:text> + <number:fill-character> </number:fill-character> + <number:text>-</number:text> + <number:number number:decimal-places="0" number:min-decimal-places="0" number:min-integer-digits="2" loext:max-blank-integer-digits="2"/> + <number:text> </number:text> + </number:number-style> + <number:text-style style:name="N131"> + <number:text> </number:text> + <number:text-content/> + <number:text> </number:text> + <style:map style:condition="value()>0" style:apply-style-name="N131P0"/> + <style:map style:condition="value()<0" style:apply-style-name="N131P1"/> + <style:map style:condition="value()=0" style:apply-style-name="N131P2"/> + </number:text-style> + <number:time-style style:name="N132"> + <number:minutes number:style="long"/> + <number:text>:</number:text> + <number:seconds number:style="long"/> + </number:time-style> + <number:time-style style:name="N133" number:truncate-on-overflow="false"> + <number:hours/> + <number:text>:</number:text> + <number:minutes number:style="long"/> + <number:text>:</number:text> + <number:seconds number:style="long"/> + </number:time-style> + <number:time-style style:name="N134"> + <number:minutes number:style="long"/> + <number:text>:</number:text> + <number:seconds number:style="long" number:decimal-places="1"/> + </number:time-style> + <number:number-style style:name="N135"> + <number:scientific-number number:decimal-places="1" number:min-decimal-places="1" number:min-integer-digits="1" number:min-exponent-digits="1" number:exponent-interval="3" number:forced-exponent-sign="true"/> + </number:number-style> + <style:style style:name="Default" style:family="table-cell"> + <style:table-cell-properties style:rotation-align="none" style:vertical-align="bottom"/> + <style:text-properties fo:color="#000000" style:font-name="Calibri" fo:font-family="Calibri" style:font-family-generic="swiss" fo:font-size="11pt" style:font-size-asian="11pt" style:font-size-complex="11pt"> + <loext:char-complex-color loext:theme-type="dark1" loext:color-type="theme"/> + </style:text-properties> + </style:style> + <style:style style:name="Heading" style:family="table-cell" style:parent-style-name="Default"> + <style:table-cell-properties fo:wrap-option="no-wrap" style:shrink-to-fit="false"/> + <style:text-properties fo:color="#000000" fo:font-size="24pt" fo:font-style="normal" fo:font-weight="bold" style:font-size-asian="24pt" style:font-style-asian="normal" style:font-weight-asian="bold" style:font-size-complex="24pt" style:font-style-complex="normal" style:font-weight-complex="bold"/> + </style:style> + <style:style style:name="Heading_20_1" style:display-name="Heading 1" style:family="table-cell" style:parent-style-name="Heading"> + <style:table-cell-properties fo:wrap-option="no-wrap" style:shrink-to-fit="false"/> + <style:text-properties fo:font-size="18pt" style:font-size-asian="18pt" style:font-size-complex="18pt"/> + </style:style> + <style:style style:name="Heading_20_2" style:display-name="Heading 2" style:family="table-cell" style:parent-style-name="Heading"> + <style:table-cell-properties fo:wrap-option="no-wrap" style:shrink-to-fit="false"/> + <style:text-properties fo:font-size="12pt" style:font-size-asian="12pt" style:font-size-complex="12pt"/> + </style:style> + <style:style style:name="Text" style:family="table-cell" style:parent-style-name="Default"> + <style:table-cell-properties fo:wrap-option="no-wrap" style:shrink-to-fit="false"/> + </style:style> + <style:style style:name="Note" style:family="table-cell" style:parent-style-name="Text"> + <style:table-cell-properties fo:background-color="#ffffcc" style:diagonal-bl-tr="none" style:diagonal-tl-br="none" fo:wrap-option="no-wrap" fo:border="0.74pt solid #808080" style:shrink-to-fit="false"/> + <style:text-properties fo:color="#333333"/> + </style:style> + <style:style style:name="Footnote" style:family="table-cell" style:parent-style-name="Text"> + <style:table-cell-properties fo:wrap-option="no-wrap" style:shrink-to-fit="false"/> + <style:text-properties fo:color="#808080" fo:font-style="italic" style:font-style-asian="italic" style:font-style-complex="italic"/> + </style:style> + <style:style style:name="Hyperlink" style:family="table-cell" style:parent-style-name="Text"> + <style:table-cell-properties fo:wrap-option="no-wrap" style:shrink-to-fit="false"/> + <style:text-properties fo:color="#0000ee" style:text-underline-style="solid" style:text-underline-width="auto" style:text-underline-color="#0000ee"/> + </style:style> + <style:style style:name="Status" style:family="table-cell" style:parent-style-name="Default"> + <style:table-cell-properties fo:wrap-option="no-wrap" style:shrink-to-fit="false"/> + </style:style> + <style:style style:name="Good" style:family="table-cell" style:parent-style-name="Status"> + <style:table-cell-properties fo:background-color="#ccffcc" fo:wrap-option="no-wrap" style:shrink-to-fit="false"/> + <style:text-properties fo:color="#006600"/> + </style:style> + <style:style style:name="Neutral" style:family="table-cell" style:parent-style-name="Status"> + <style:table-cell-properties fo:background-color="#ffffcc" fo:wrap-option="no-wrap" style:shrink-to-fit="false"/> + <style:text-properties fo:color="#996600"/> + </style:style> + <style:style style:name="Bad" style:family="table-cell" style:parent-style-name="Status"> + <style:table-cell-properties fo:background-color="#ffcccc" fo:wrap-option="no-wrap" style:shrink-to-fit="false"/> + <style:text-properties fo:color="#cc0000"/> + </style:style> + <style:style style:name="Warning" style:family="table-cell" style:parent-style-name="Status"> + <style:table-cell-properties fo:wrap-option="no-wrap" style:shrink-to-fit="false"/> + <style:text-properties fo:color="#cc0000"/> + </style:style> + <style:style style:name="Error" style:family="table-cell" style:parent-style-name="Status"> + <style:table-cell-properties fo:background-color="#cc0000" fo:wrap-option="no-wrap" style:shrink-to-fit="false"/> + <style:text-properties fo:color="#ffffff" fo:font-weight="bold" style:font-weight-asian="bold" style:font-weight-complex="bold"/> + </style:style> + <style:style style:name="Accent" style:family="table-cell" style:parent-style-name="Default"> + <style:table-cell-properties fo:wrap-option="no-wrap" style:shrink-to-fit="false"/> + <style:text-properties fo:font-weight="bold" style:font-weight-asian="bold" style:font-weight-complex="bold"/> + </style:style> + <style:style style:name="Accent_20_1" style:display-name="Accent 1" style:family="table-cell" style:parent-style-name="Accent"> + <style:table-cell-properties fo:background-color="#000000" fo:wrap-option="no-wrap" style:shrink-to-fit="false"/> + <style:text-properties fo:color="#ffffff"/> + </style:style> + <style:style style:name="Accent_20_2" style:display-name="Accent 2" style:family="table-cell" style:parent-style-name="Accent"> + <style:table-cell-properties fo:background-color="#808080" fo:wrap-option="no-wrap" style:shrink-to-fit="false"/> + <style:text-properties fo:color="#ffffff"/> + </style:style> + <style:style style:name="Accent_20_3" style:display-name="Accent 3" style:family="table-cell" style:parent-style-name="Accent"> + <style:table-cell-properties fo:background-color="#dddddd" fo:wrap-option="no-wrap" style:shrink-to-fit="false"/> + </style:style> + <style:style style:name="Result" style:family="table-cell" style:parent-style-name="Default"> + <style:table-cell-properties fo:wrap-option="no-wrap" style:shrink-to-fit="false"/> + <style:text-properties fo:font-style="italic" style:text-underline-style="solid" style:text-underline-width="auto" style:text-underline-color="font-color" fo:font-weight="bold" style:font-style-asian="italic" style:font-weight-asian="bold" style:font-style-complex="italic" style:font-weight-complex="bold"/> + </style:style> + <draw:marker draw:name="Arrowheads_20_1" draw:display-name="Arrowheads 1" svg:viewBox="0 0 20 30" svg:d="M10 0l-10 30h20z"/> + </office:styles> + <office:automatic-styles> + <style:style style:name="co1" style:family="table-column"> + <style:table-column-properties fo:break-before="auto" style:column-width="7.44cm"/> + </style:style> + <style:style style:name="co2" style:family="table-column"> + <style:table-column-properties fo:break-before="auto" style:column-width="1.699cm"/> + </style:style> + <style:style style:name="ro1" style:family="table-row"> + <style:table-row-properties style:row-height="0.503cm" fo:break-before="auto" style:use-optimal-row-height="true"/> + </style:style> + <style:style style:name="ro2" style:family="table-row"> + <style:table-row-properties style:row-height="3.942cm" fo:break-before="auto" style:use-optimal-row-height="false"/> + </style:style> + <style:style style:name="ro3" style:family="table-row"> + <style:table-row-properties style:row-height="0.452cm" fo:break-before="auto" style:use-optimal-row-height="true"/> + </style:style> + <style:style style:name="ta1" style:family="table" style:master-page-name="PageStyle_5f_Sheet1"> + <style:table-properties table:display="true" style:writing-mode="lr-tb"/> + </style:style> + <number:number-style style:name="N2"> + <number:number number:decimal-places="2" number:min-decimal-places="2" number:min-integer-digits="1"/> + </number:number-style> + <style:page-layout style:name="pm1"> + <style:page-layout-properties style:first-page-number="continue" style:writing-mode="lr-tb"/> + <style:header-style> + <style:header-footer-properties fo:min-height="0.75cm" fo:margin-left="0cm" fo:margin-right="0cm" fo:margin-bottom="0.25cm"/> + </style:header-style> + <style:footer-style> + <style:header-footer-properties fo:min-height="0.75cm" fo:margin-left="0cm" fo:margin-right="0cm" fo:margin-top="0.25cm"/> + </style:footer-style> + </style:page-layout> + <style:page-layout style:name="pm2"> + <style:page-layout-properties style:writing-mode="lr-tb"/> + <style:header-style> + <style:header-footer-properties fo:min-height="0.75cm" fo:margin-left="0cm" fo:margin-right="0cm" fo:margin-bottom="0.25cm" fo:border="1.5pt solid #000000" fo:padding="0.018cm" fo:background-color="#c0c0c0"> + <style:background-image/> + </style:header-footer-properties> + </style:header-style> + <style:footer-style> + <style:header-footer-properties fo:min-height="0.75cm" fo:margin-left="0cm" fo:margin-right="0cm" fo:margin-top="0.25cm" fo:border="1.5pt solid #000000" fo:padding="0.018cm" fo:background-color="#c0c0c0"> + <style:background-image/> + </style:header-footer-properties> + </style:footer-style> + </style:page-layout> + <style:page-layout style:name="pm3"> + <style:page-layout-properties style:num-format="1" style:print-orientation="portrait" fo:margin-top="1.905cm" fo:margin-bottom="1.905cm" fo:margin-left="1.778cm" fo:margin-right="1.778cm" style:print-page-order="ttb" style:first-page-number="continue" style:scale-to="100%" style:writing-mode="lr-tb" style:print="charts drawings objects zero-values"/> + <style:header-style> + <style:header-footer-properties fo:min-height="0.75cm" fo:margin-left="0cm" fo:margin-right="0cm" fo:margin-bottom="0.25cm"/> + </style:header-style> + <style:footer-style> + <style:header-footer-properties fo:min-height="0.75cm" fo:margin-left="0cm" fo:margin-right="0cm" fo:margin-top="0.25cm"/> + </style:footer-style> + </style:page-layout> + </office:automatic-styles> + <office:master-styles> + <style:master-page style:name="Default" style:page-layout-name="pm1"> + <style:header> + <text:p><text:sheet-name>???</text:sheet-name></text:p> + </style:header> + <style:header-left style:display="false"/> + <style:header-first style:display="false"/> + <style:footer> + <text:p>Page <text:page-number>1</text:page-number></text:p> + </style:footer> + <style:footer-left style:display="false"/> + <style:footer-first style:display="false"/> + </style:master-page> + <style:master-page style:name="Report" style:page-layout-name="pm2"> + <style:header> + <style:region-left> + <text:p><text:sheet-name>???</text:sheet-name><text:s/>(<text:title>???</text:title>)</text:p> + </style:region-left> + <style:region-right> + <text:p><text:date style:data-style-name="N2" text:date-value="2023-07-30">00/00/0000</text:date>, <text:time>00:00:00</text:time></text:p> + </style:region-right> + </style:header> + <style:header-left style:display="false"/> + <style:header-first style:display="false"/> + <style:footer> + <text:p>Page <text:page-number>1</text:page-number><text:s/>/ <text:page-count>99</text:page-count></text:p> + </style:footer> + <style:footer-left style:display="false"/> + <style:footer-first style:display="false"/> + </style:master-page> + <style:master-page style:name="PageStyle_5f_Sheet1" style:display-name="PageStyle_Sheet1" style:page-layout-name="pm3"> + <style:header style:display="false"/> + <style:header-left style:display="false"/> + <style:header-first style:display="false"/> + <style:footer style:display="false"/> + <style:footer-left style:display="false"/> + <style:footer-first style:display="false"/> + </style:master-page> + <style:master-page style:name="PageStyle_5f_Sheet2" style:display-name="PageStyle_Sheet2" style:page-layout-name="pm3"> + <style:header style:display="false"/> + <style:header-left style:display="false"/> + <style:header-first style:display="false"/> + <style:footer style:display="false"/> + <style:footer-left style:display="false"/> + <style:footer-first style:display="false"/> + </style:master-page> + <style:master-page style:name="PageStyle_5f_Sheet3" style:display-name="PageStyle_Sheet3" style:page-layout-name="pm3"> + <style:header style:display="false"/> + <style:header-left style:display="false"/> + <style:header-first style:display="false"/> + <style:footer style:display="false"/> + <style:footer-left style:display="false"/> + <style:footer-first style:display="false"/> + </style:master-page> + </office:master-styles> + <office:body> + <office:spreadsheet> + <table:calculation-settings table:case-sensitive="false" table:automatic-find-labels="false" table:use-regular-expressions="false" table:use-wildcards="true"> + <table:iteration table:maximum-difference="0.0001"/> + </table:calculation-settings> + <table:table table:name="Sheet1" table:style-name="ta1"> + <office:forms form:automatic-focus="false" form:apply-design-mode="false"/> + <table:table-column table:style-name="co1" table:default-cell-style-name="Default"/> + <table:table-column table:style-name="co2" table:number-columns-repeated="16383" table:default-cell-style-name="Default"/> + <table:table-row table:style-name="ro1"> + <table:table-cell/> + <table:table-cell office:value-type="float" office:value="4" calcext:value-type="float"> + <text:p>4</text:p> + </table:table-cell> + <table:table-cell office:value-type="float" office:value="2" calcext:value-type="float"> + <text:p>2</text:p> + </table:table-cell> + <table:table-cell office:value-type="float" office:value="7" calcext:value-type="float"> + <text:p>7</text:p> + </table:table-cell> + <table:table-cell office:value-type="float" office:value="-2" calcext:value-type="float"> + <text:p>-2</text:p> + </table:table-cell> + <table:table-cell office:value-type="float" office:value="-5" calcext:value-type="float"> + <text:p>-5</text:p> + </table:table-cell> + <table:table-cell office:value-type="float" office:value="4" calcext:value-type="float"> + <text:p>4</text:p> + </table:table-cell> + <table:table-cell office:value-type="float" office:value="3" calcext:value-type="float"> + <text:p>3</text:p> + </table:table-cell> + <table:table-cell office:value-type="float" office:value="6" calcext:value-type="float"> + <text:p>6</text:p> + </table:table-cell> + <table:table-cell office:value-type="float" office:value="-2" calcext:value-type="float"> + <text:p>-2</text:p> + </table:table-cell> + <table:table-cell office:value-type="float" office:value="0" calcext:value-type="float"> + <text:p>0</text:p> + </table:table-cell> + <table:table-cell office:value-type="float" office:value="-3" calcext:value-type="float"> + <text:p>-3</text:p> + </table:table-cell> + <table:table-cell office:value-type="float" office:value="1" calcext:value-type="float"> + <text:p>1</text:p> + </table:table-cell> + <table:table-cell table:number-columns-repeated="16371"/> + </table:table-row> + <table:table-row table:style-name="ro2"> + <table:table-cell table:number-columns-repeated="16384"/> + </table:table-row> + <table:table-row table:style-name="ro1" table:number-rows-repeated="1048573"> + <table:table-cell table:number-columns-repeated="16384"/> + </table:table-row> + <table:table-row table:style-name="ro3"> + <table:table-cell table:number-columns-repeated="16384"/> + </table:table-row> + <calcext:sparkline-groups> + <calcext:sparkline-group calcext:id="{1C5C5DE0-3C09-4CB3-A3EC-9E763301EC82}" calcext:type="column" calcext:line-width="1pt" calcext:display-empty-cells-as="gap" calcext:markers="true" calcext:high="true" calcext:low="true" calcext:first="true" calcext:last="true" calcext:negative="true" calcext:display-x-axis="true" calcext:min-axis-type="individual" calcext:max-axis-type="individual" calcext:color-series="#0369a3" calcext:color-negative="#c99c00" calcext:color-markers="#000000" calcext:color-first="#8e03a3" calcext:color-last="#34b3fb" calcext:color-high="#18a303" calcext:color-low="#c9211e"> + <calcext:sparkline-series-complex-color loext:theme-type="accent3" loext:color-type="theme"/> + <calcext:sparkline-negative-complex-color loext:theme-type="accent6" loext:color-type="theme"/> + <calcext:sparkline-markers-complex-color loext:theme-type="light1" loext:color-type="theme"/> + <calcext:sparkline-first-complex-color loext:theme-type="accent5" loext:color-type="theme"/> + <calcext:sparkline-last-complex-color loext:theme-type="accent2" loext:color-type="theme"> + <loext:transformation loext:type="lummod" loext:value="6000"/> + <loext:transformation loext:type="lumoff" loext:value="4000"/> + </calcext:sparkline-last-complex-color> + <calcext:sparkline-high-complex-color loext:theme-type="accent1" loext:color-type="theme"/> + <calcext:sparkline-low-complex-color loext:theme-type="accent4" loext:color-type="theme"/> + <calcext:sparklines> + <calcext:sparkline calcext:cell-address="Sheet1.A2" calcext:data-range="Sheet1.B1:Sheet1.M1"/> + </calcext:sparklines> + </calcext:sparkline-group> + </calcext:sparkline-groups> + </table:table> + <table:named-expressions/> + </office:spreadsheet> + </office:body> +</office:document> diff --git a/sc/qa/unit/ucalc_sparkline.cxx b/sc/qa/unit/ucalc_sparkline.cxx index 807f9d8b033e..66c2db81913e 100644 --- a/sc/qa/unit/ucalc_sparkline.cxx +++ b/sc/qa/unit/ucalc_sparkline.cxx @@ -17,6 +17,9 @@ #include <Sparkline.hxx> #include <SparklineGroup.hxx> #include <SparklineList.hxx> +#include <SparklineAttributes.hxx> +#include <ThemeColorChanger.hxx> +#include <docmodel/theme/Theme.hxx> using namespace css; @@ -511,16 +514,16 @@ void SparklineTest::testUndoRedoEditSparklineGroup() { sc::SparklineAttributes& rAttibutes = pSparklineGroup->getAttributes(); rAttibutes.setType(sc::SparklineType::Column); - rAttibutes.setColorSeries(COL_YELLOW); - rAttibutes.setColorAxis(COL_GREEN); + rAttibutes.setColorSeries(model::ComplexColor::RGB(COL_YELLOW)); + rAttibutes.setColorAxis(model::ComplexColor::RGB(COL_GREEN)); } m_pDoc->CreateSparkline(ScAddress(0, 6, 0), pSparklineGroup); sc::SparklineAttributes aNewAttributes; aNewAttributes.setType(sc::SparklineType::Stacked); - aNewAttributes.setColorSeries(COL_BLACK); - aNewAttributes.setColorAxis(COL_BLUE); + aNewAttributes.setColorSeries(model::ComplexColor::RGB(COL_BLACK)); + aNewAttributes.setColorAxis(model::ComplexColor::RGB(COL_BLUE)); sc::SparklineAttributes aInitialAttibutes(pSparklineGroup->getAttributes()); @@ -530,8 +533,10 @@ void SparklineTest::testUndoRedoEditSparklineGroup() CPPUNIT_ASSERT_EQUAL(false, aNewAttributes == pSparklineGroup->getAttributes()); CPPUNIT_ASSERT_EQUAL(sc::SparklineType::Column, pSparklineGroup->getAttributes().getType()); - CPPUNIT_ASSERT_EQUAL(COL_YELLOW, pSparklineGroup->getAttributes().getColorSeries()); - CPPUNIT_ASSERT_EQUAL(COL_GREEN, pSparklineGroup->getAttributes().getColorAxis()); + CPPUNIT_ASSERT_EQUAL(COL_YELLOW, + pSparklineGroup->getAttributes().getColorSeries().getFinalColor()); + CPPUNIT_ASSERT_EQUAL(COL_GREEN, + pSparklineGroup->getAttributes().getColorAxis().getFinalColor()); rDocFunc.ChangeSparklineGroupAttributes(pSparklineGroup, aNewAttributes); @@ -539,8 +544,9 @@ void SparklineTest::testUndoRedoEditSparklineGroup() CPPUNIT_ASSERT_EQUAL(true, aNewAttributes == pSparklineGroup->getAttributes()); CPPUNIT_ASSERT_EQUAL(sc::SparklineType::Stacked, pSparklineGroup->getAttributes().getType()); - CPPUNIT_ASSERT_EQUAL(COL_BLACK, pSparklineGroup->getAttributes().getColorSeries()); - CPPUNIT_ASSERT_EQUAL(COL_BLUE, pSparklineGroup->getAttributes().getColorAxis()); + CPPUNIT_ASSERT_EQUAL(COL_BLACK, + pSparklineGroup->getAttributes().getColorSeries().getFinalColor()); + CPPUNIT_ASSERT_EQUAL(COL_BLUE, pSparklineGroup->getAttributes().getColorAxis().getFinalColor()); m_pDoc->GetUndoManager()->Undo(); @@ -548,8 +554,10 @@ void SparklineTest::testUndoRedoEditSparklineGroup() CPPUNIT_ASSERT_EQUAL(false, aNewAttributes == pSparklineGroup->getAttributes()); CPPUNIT_ASSERT_EQUAL(sc::SparklineType::Column, pSparklineGroup->getAttributes().getType()); - CPPUNIT_ASSERT_EQUAL(COL_YELLOW, pSparklineGroup->getAttributes().getColorSeries()); - CPPUNIT_ASSERT_EQUAL(COL_GREEN, pSparklineGroup->getAttributes().getColorAxis()); + CPPUNIT_ASSERT_EQUAL(COL_YELLOW, + pSparklineGroup->getAttributes().getColorSeries().getFinalColor()); + CPPUNIT_ASSERT_EQUAL(COL_GREEN, + pSparklineGroup->getAttributes().getColorAxis().getFinalColor()); m_pDoc->GetUndoManager()->Redo(); @@ -557,8 +565,9 @@ void SparklineTest::testUndoRedoEditSparklineGroup() CPPUNIT_ASSERT_EQUAL(true, aNewAttributes == pSparklineGroup->getAttributes()); CPPUNIT_ASSERT_EQUAL(sc::SparklineType::Stacked, pSparklineGroup->getAttributes().getType()); - CPPUNIT_ASSERT_EQUAL(COL_BLACK, pSparklineGroup->getAttributes().getColorSeries()); - CPPUNIT_ASSERT_EQUAL(COL_BLUE, pSparklineGroup->getAttributes().getColorAxis()); + CPPUNIT_ASSERT_EQUAL(COL_BLACK, + pSparklineGroup->getAttributes().getColorSeries().getFinalColor()); + CPPUNIT_ASSERT_EQUAL(COL_BLUE, pSparklineGroup->getAttributes().getColorAxis().getFinalColor()); m_pDoc->DeleteTab(0); } @@ -897,6 +906,93 @@ void SparklineTest::testSparklineList() } } +CPPUNIT_TEST_FIXTURE(SparklineTest, testSparklineThemeColorChange) +{ + m_pDoc->InitDrawLayer(); + m_pDoc->InsertTab(0, "Test"); + + // insert test data - A1:A6 + insertTestData(*m_pDoc); + + auto& rDocFunc = m_xDocShell->GetDocFunc(); + + ScDrawLayer* pDrawLayer = m_pDoc->GetDrawLayer(); + CPPUNIT_ASSERT(pDrawLayer); + const SdrPage* pPage(pDrawLayer->GetPage(0)); + CPPUNIT_ASSERT(pPage); + auto const& pTheme = pPage->getSdrPageProperties().GetTheme(); + CPPUNIT_ASSERT(pTheme); + + // Sparkline range + ScRange aDataRange(0, 0, 0, 3, 5, 0); //A1:D6 + ScRange aRange(0, 6, 0, 3, 6, 0); // A7:D7 + + { + auto pSparklineGroup = std::make_shared<sc::SparklineGroup>(); + sc::SparklineAttributes& rAttibutes = pSparklineGroup->getAttributes(); + + model::ComplexColor aSeriesComplexColor; + aSeriesComplexColor.setSchemeColor(model::ThemeColorType::Accent3); + aSeriesComplexColor.setFinalColor(pTheme->getColorSet()->resolveColor(aSeriesComplexColor)); + rAttibutes.setColorSeries(aSeriesComplexColor); + + model::ComplexColor aAxisComplexColor; + aAxisComplexColor.setSchemeColor(model::ThemeColorType::Accent1); + aAxisComplexColor.setFinalColor(pTheme->getColorSet()->resolveColor(aAxisComplexColor)); + rAttibutes.setColorAxis(aAxisComplexColor); + + CPPUNIT_ASSERT(rDocFunc.InsertSparklines(aDataRange, aRange, pSparklineGroup)); + } + + { + CPPUNIT_ASSERT_EQUAL(true, m_pDoc->HasSparkline(ScAddress(0, 6, 0))); // A7 + auto pGroup = m_pDoc->GetSparkline(ScAddress(0, 6, 0))->getSparklineGroup(); + CPPUNIT_ASSERT(pGroup); + sc::SparklineAttributes& rAttibutes = pGroup->getAttributes(); + CPPUNIT_ASSERT_EQUAL(Color(0xa33e03), rAttibutes.getColorSeries().getFinalColor()); + CPPUNIT_ASSERT_EQUAL(Color(0x18a303), rAttibutes.getColorAxis().getFinalColor()); + } + + { + auto pColorSet = std::make_shared<model::ColorSet>("TestColorScheme"); + pColorSet->add(model::ThemeColorType::Dark1, 0x000000); + pColorSet->add(model::ThemeColorType::Light1, 0x111111); + pColorSet->add(model::ThemeColorType::Dark2, 0x222222); + pColorSet->add(model::ThemeColorType::Light2, 0x333333); + pColorSet->add(model::ThemeColorType::Accent1, 0x444444); + pColorSet->add(model::ThemeColorType::Accent2, 0x555555); + pColorSet->add(model::ThemeColorType::Accent3, 0x666666); + pColorSet->add(model::ThemeColorType::Accent4, 0x777777); + pColorSet->add(model::ThemeColorType::Accent5, 0x888888); + pColorSet->add(model::ThemeColorType::Accent6, 0x999999); + pColorSet->add(model::ThemeColorType::Hyperlink, 0xaaaaaa); + pColorSet->add(model::ThemeColorType::FollowedHyperlink, 0xbbbbbb); + + sc::ThemeColorChanger aChanger(*m_xDocShell); + aChanger.apply(pColorSet); + } + + { + CPPUNIT_ASSERT_EQUAL(true, m_pDoc->HasSparkline(ScAddress(0, 6, 0))); // A7 + auto pGroup = m_pDoc->GetSparkline(ScAddress(0, 6, 0))->getSparklineGroup(); + CPPUNIT_ASSERT(pGroup); + sc::SparklineAttributes& rAttibutes = pGroup->getAttributes(); + CPPUNIT_ASSERT_EQUAL(Color(0x666666), rAttibutes.getColorSeries().getFinalColor()); + CPPUNIT_ASSERT_EQUAL(Color(0x444444), rAttibutes.getColorAxis().getFinalColor()); + } + + m_pDoc->GetUndoManager()->Undo(); + + { + CPPUNIT_ASSERT_EQUAL(true, m_pDoc->HasSparkline(ScAddress(0, 6, 0))); // A7 + auto pGroup = m_pDoc->GetSparkline(ScAddress(0, 6, 0))->getSparklineGroup(); + CPPUNIT_ASSERT(pGroup); + sc::SparklineAttributes& rAttibutes = pGroup->getAttributes(); + CPPUNIT_ASSERT_EQUAL(Color(0xa33e03), rAttibutes.getColorSeries().getFinalColor()); + CPPUNIT_ASSERT_EQUAL(Color(0x18a303), rAttibutes.getColorAxis().getFinalColor()); + } +} + CPPUNIT_TEST_SUITE_REGISTRATION(SparklineTest); CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sc/source/filter/excel/export/ExportTools.cxx b/sc/source/filter/excel/export/ExportTools.cxx new file mode 100644 index 000000000000..a132dd148408 --- /dev/null +++ b/sc/source/filter/excel/export/ExportTools.cxx @@ -0,0 +1,45 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include <export/ExportTools.hxx> +#include <oox/export/ColorExportUtils.hxx> +#include <oox/token/tokens.hxx> +#include <oox/token/namespaces.hxx> +#include <xestream.hxx> + +namespace oox::xls +{ +void writeComplexColor(sax_fastparser::FSHelperPtr& pFS, sal_Int32 nElement, + model::ComplexColor const& rComplexColor, Color const& rColor) +{ + if (rComplexColor.isValidSchemeType()) + { + sal_Int32 nTheme + = oox::convertThemeColorTypeToExcelThemeNumber(rComplexColor.getSchemeType()); + double fTintShade = oox::convertColorTransformsToTintOrShade(rComplexColor); + pFS->singleElement(nElement, XML_theme, OString::number(nTheme), XML_tint, + sax_fastparser::UseIf(OString::number(fTintShade), fTintShade != 0.0)); + } + else if (rColor != COL_TRANSPARENT) + { + pFS->singleElement(nElement, XML_rgb, XclXmlUtils::ToOString(rColor)); + } +} + +void writeComplexColor(sax_fastparser::FSHelperPtr& pFS, sal_Int32 nElement, + model::ComplexColor const& rComplexColor) +{ + if (rComplexColor.isValidSchemeType() || rComplexColor.getType() == model::ColorType::RGB) + { + writeComplexColor(pFS, nElement, rComplexColor, rComplexColor.getFinalColor()); + } +} +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/filter/excel/export/SparklineExt.cxx b/sc/source/filter/excel/export/SparklineExt.cxx index 487698e19ba1..fb5c98148323 100644 --- a/sc/source/filter/excel/export/SparklineExt.cxx +++ b/sc/source/filter/excel/export/SparklineExt.cxx @@ -14,6 +14,7 @@ #include <oox/token/tokens.hxx> #include <SparklineGroup.hxx> #include <SparklineList.hxx> +#include <export/ExportTools.hxx> using namespace oox; @@ -126,50 +127,21 @@ void SparklineExt::addSparklineGroupColors(XclExpXmlStream& rStream, { sax_fastparser::FSHelperPtr& rWorksheet = rStream.GetCurrentStream(); - rWorksheet->singleElementNS(XML_x14, XML_colorSeries, XML_rgb, - XclXmlUtils::ToOString(rAttributes.getColorSeries())); - - if (rAttributes.getColorNegative() != COL_TRANSPARENT) - { - rWorksheet->singleElementNS(XML_x14, XML_colorNegative, XML_rgb, - XclXmlUtils::ToOString(rAttributes.getColorNegative())); - } - - if (rAttributes.getColorAxis() != COL_TRANSPARENT) - { - rWorksheet->singleElementNS(XML_x14, XML_colorAxis, XML_rgb, - XclXmlUtils::ToOString(rAttributes.getColorAxis())); - } - - if (rAttributes.getColorMarkers() != COL_TRANSPARENT) - { - rWorksheet->singleElementNS(XML_x14, XML_colorMarkers, XML_rgb, - XclXmlUtils::ToOString(rAttributes.getColorMarkers())); - } - - if (rAttributes.getColorFirst() != COL_TRANSPARENT) - { - rWorksheet->singleElementNS(XML_x14, XML_colorFirst, XML_rgb, - XclXmlUtils::ToOString(rAttributes.getColorFirst())); - } - - if (rAttributes.getColorLast() != COL_TRANSPARENT) - { - rWorksheet->singleElementNS(XML_x14, XML_colorLast, XML_rgb, - XclXmlUtils::ToOString(rAttributes.getColorLast())); - } - - if (rAttributes.getColorHigh() != COL_TRANSPARENT) - { - rWorksheet->singleElementNS(XML_x14, XML_colorHigh, XML_rgb, - XclXmlUtils::ToOString(rAttributes.getColorHigh())); - } - - if (rAttributes.getColorLow() != COL_TRANSPARENT) - { - rWorksheet->singleElementNS(XML_x14, XML_colorLow, XML_rgb, - XclXmlUtils::ToOString(rAttributes.getColorLow())); - } + oox::xls::writeComplexColor(rWorksheet, FSNS(XML_x14, XML_colorSeries), + rAttributes.getColorSeries()); + oox::xls::writeComplexColor(rWorksheet, FSNS(XML_x14, XML_colorNegative), + rAttributes.getColorNegative()); + oox::xls::writeComplexColor(rWorksheet, FSNS(XML_x14, XML_colorAxis), + rAttributes.getColorAxis()); + oox::xls::writeComplexColor(rWorksheet, FSNS(XML_x14, XML_colorMarkers), + rAttributes.getColorMarkers()); + oox::xls::writeComplexColor(rWorksheet, FSNS(XML_x14, XML_colorFirst), + rAttributes.getColorFirst()); + oox::xls::writeComplexColor(rWorksheet, FSNS(XML_x14, XML_colorLast), + rAttributes.getColorLast()); + oox::xls::writeComplexColor(rWorksheet, FSNS(XML_x14, XML_colorHigh), + rAttributes.getColorHigh()); + oox::xls::writeComplexColor(rWorksheet, FSNS(XML_x14, XML_colorLow), rAttributes.getColorLow()); } void SparklineExt::addSparklineGroup(XclExpXmlStream& rStream, sc::SparklineGroup& rSparklineGroup, diff --git a/sc/source/filter/excel/xestyle.cxx b/sc/source/filter/excel/xestyle.cxx index 50db4781f1d4..292ce2acff43 100644 --- a/sc/source/filter/excel/xestyle.cxx +++ b/sc/source/filter/excel/xestyle.cxx @@ -53,7 +53,6 @@ #include <o3tl/safeint.hxx> #include <oox/export/utils.hxx> -#include <oox/export/ColorExportUtils.hxx> #include <oox/token/tokens.hxx> #include <oox/token/namespaces.hxx> #include <oox/token/relationship.hxx> diff --git a/sc/source/filter/inc/export/ExportTools.hxx b/sc/source/filter/inc/export/ExportTools.hxx index e5ea27561f39..369728f06e10 100644 --- a/sc/source/filter/inc/export/ExportTools.hxx +++ b/sc/source/filter/inc/export/ExportTools.hxx @@ -11,28 +11,13 @@ #include <docmodel/color/ComplexColor.hxx> #include <sax/fshelper.hxx> -#include <oox/export/ColorExportUtils.hxx> -#include <oox/token/tokens.hxx> -#include <oox/token/namespaces.hxx> namespace oox::xls { void writeComplexColor(sax_fastparser::FSHelperPtr& pFS, sal_Int32 nElement, - model::ComplexColor const& rComplexColor, Color const& rColor) -{ - if (rComplexColor.isValidSchemeType()) - { - sal_Int32 nTheme - = oox::convertThemeColorTypeToExcelThemeNumber(rComplexColor.getSchemeType()); - double fTintShade = oox::convertColorTransformsToTintOrShade(rComplexColor); - pFS->singleElement(nElement, XML_theme, OString::number(nTheme), XML_tint, - sax_fastparser::UseIf(OString::number(fTintShade), fTintShade != 0.0)); - } - else if (rColor != COL_TRANSPARENT) - { - pFS->singleElement(nElement, XML_rgb, XclXmlUtils::ToOString(rColor)); - } -} + model::ComplexColor const& rComplexColor, Color const& rColor); +void writeComplexColor(sax_fastparser::FSHelperPtr& pFS, sal_Int32 nElement, + model::ComplexColor const& rComplexColor); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ 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): diff --git a/sc/source/filter/xml/SparklineGroupsExport.cxx b/sc/source/filter/xml/SparklineGroupsExport.cxx index 077d43beab60..fd577e5c6c10 100644 --- a/sc/source/filter/xml/SparklineGroupsExport.cxx +++ b/sc/source/filter/xml/SparklineGroupsExport.cxx @@ -21,6 +21,7 @@ #include <rtl/ustrbuf.hxx> #include <sax/tools/converter.hxx> #include <o3tl/unit_conversion.hxx> +#include <xmloff/XMLComplexColorExport.hxx> using namespace css; using namespace xmloff::token; @@ -33,14 +34,24 @@ SparklineGroupsExport::SparklineGroupsExport(ScXMLExport& rExport, SCTAB nTable) { } -void SparklineGroupsExport::insertColor(Color aColor, XMLTokenEnum eToken) +void SparklineGroupsExport::insertColor(model::ComplexColor const& rComplexColor, + XMLTokenEnum eToken) { + if (rComplexColor.getType() == model::ColorType::Unused) + return; + OUStringBuffer aStringBuffer; - if (aColor != COL_TRANSPARENT) - { - sax::Converter::convertColor(aStringBuffer, aColor); - m_rExport.AddAttribute(XML_NAMESPACE_CALC_EXT, eToken, aStringBuffer.makeStringAndClear()); - } + sax::Converter::convertColor(aStringBuffer, rComplexColor.getFinalColor()); + m_rExport.AddAttribute(XML_NAMESPACE_CALC_EXT, eToken, aStringBuffer.makeStringAndClear()); +} + +void SparklineGroupsExport::insertComplexColor(model::ComplexColor const& rComplexColor, + XMLTokenEnum eToken) +{ + if (!rComplexColor.isValidSchemeType()) + return; + XMLComplexColorExport aComplexColorExport(m_rExport); + aComplexColorExport.exportComplexColor(rComplexColor, XML_NAMESPACE_CALC_EXT, eToken); } void SparklineGroupsExport::insertBool(bool bValue, XMLTokenEnum eToken) @@ -182,6 +193,15 @@ void SparklineGroupsExport::addSparklineGroup( SvXMLElementExport aElementSparklineGroup(m_rExport, XML_NAMESPACE_CALC_EXT, XML_SPARKLINE_GROUP, true, true); + insertComplexColor(rAttributes.getColorSeries(), XML_SPARKLINE_SERIES_COMPLEX_COLOR); + insertComplexColor(rAttributes.getColorNegative(), XML_SPARKLINE_NEGATIVE_COMPLEX_COLOR); + insertComplexColor(rAttributes.getColorAxis(), XML_SPARKLINE_AXIS_COMPLEX_COLOR); + insertComplexColor(rAttributes.getColorMarkers(), XML_SPARKLINE_MARKERS_COMPLEX_COLOR); + insertComplexColor(rAttributes.getColorFirst(), XML_SPARKLINE_FIRST_COMPLEX_COLOR); + insertComplexColor(rAttributes.getColorLast(), XML_SPARKLINE_LAST_COMPLEX_COLOR); + insertComplexColor(rAttributes.getColorHigh(), XML_SPARKLINE_HIGH_COMPLEX_COLOR); + insertComplexColor(rAttributes.getColorLow(), XML_SPARKLINE_LOW_COMPLEX_COLOR); + SvXMLElementExport aElementSparklines(m_rExport, XML_NAMESPACE_CALC_EXT, XML_SPARKLINES, true, true); diff --git a/sc/source/filter/xml/SparklineGroupsExport.hxx b/sc/source/filter/xml/SparklineGroupsExport.hxx index 9359413735dc..a2ed4a8ef853 100644 --- a/sc/source/filter/xml/SparklineGroupsExport.hxx +++ b/sc/source/filter/xml/SparklineGroupsExport.hxx @@ -19,6 +19,10 @@ #include <SparklineGroup.hxx> class ScXMLExport; +namespace model +{ +class ComplexColor; +} namespace sc { @@ -33,7 +37,10 @@ class SparklineGroupsExport std::vector<std::shared_ptr<Sparkline>> const& rSparklines); void addSparklineAttributes(Sparkline const& rSparkline); - void insertColor(Color aColor, xmloff::token::XMLTokenEnum eToken); + void insertColor(model::ComplexColor const& rComplexColor, xmloff::token::XMLTokenEnum eToken); + void insertComplexColor(model::ComplexColor const& rComplexColor, + xmloff::token::XMLTokenEnum eToken); + void insertBool(bool bValue, xmloff::token::XMLTokenEnum eToken); public: diff --git a/sc/source/filter/xml/SparklineGroupsImportContext.cxx b/sc/source/filter/xml/SparklineGroupsImportContext.cxx index b1164e3ef993..59c24cdd45a4 100644 --- a/sc/source/filter/xml/SparklineGroupsImportContext.cxx +++ b/sc/source/filter/xml/SparklineGroupsImportContext.cxx @@ -13,6 +13,7 @@ #include <xmloff/xmlnamespace.hxx> #include <xmloff/xmltoken.hxx> #include <xmloff/xmluconv.hxx> +#include <xmloff/XMLComplexColorContext.hxx> #include <document.hxx> #include <rangeutl.hxx> @@ -181,58 +182,50 @@ void SparklineGroupsImportContext::fillSparklineGroupAttributes( } case XML_ELEMENT(CALC_EXT, XML_COLOR_SERIES): { - Color aColor; - sax::Converter::convertColor(aColor, rIter.toView()); - rAttributes.setColorSeries(aColor); + maSeriesColor = COL_TRANSPARENT; + sax::Converter::convertColor(maSeriesColor, rIter.toView()); break; } case XML_ELEMENT(CALC_EXT, XML_COLOR_NEGATIVE): { - Color aColor; - sax::Converter::convertColor(aColor, rIter.toView()); - rAttributes.setColorNegative(aColor); + maNegativeColor = COL_TRANSPARENT; + sax::Converter::convertColor(maNegativeColor, rIter.toView()); break; } case XML_ELEMENT(CALC_EXT, XML_COLOR_AXIS): { - Color aColor; - sax::Converter::convertColor(aColor, rIter.toView()); - rAttributes.setColorAxis(aColor); + maAxisColor = COL_TRANSPARENT; + sax::Converter::convertColor(maAxisColor, rIter.toView()); break; } case XML_ELEMENT(CALC_EXT, XML_COLOR_MARKERS): { - Color aColor; - sax::Converter::convertColor(aColor, rIter.toView()); - rAttributes.setColorMarkers(aColor); + maMarkersColor = COL_TRANSPARENT; + sax::Converter::convertColor(maMarkersColor, rIter.toView()); break; } case XML_ELEMENT(CALC_EXT, XML_COLOR_FIRST): { - Color aColor; - sax::Converter::convertColor(aColor, rIter.toView()); - rAttributes.setColorFirst(aColor); + maFirstColor = COL_TRANSPARENT; + sax::Converter::convertColor(maFirstColor, rIter.toView()); break; } case XML_ELEMENT(CALC_EXT, XML_COLOR_LAST): { - Color aColor; - sax::Converter::convertColor(aColor, rIter.toView()); - rAttributes.setColorLast(aColor); + maLastColor = COL_TRANSPARENT; + sax::Converter::convertColor(maLastColor, rIter.toView()); break; } case XML_ELEMENT(CALC_EXT, XML_COLOR_HIGH): { - Color aColor; - sax::Converter::convertColor(aColor, rIter.toView()); - rAttributes.setColorHigh(aColor); + maHighColor = COL_TRANSPARENT; + sax::Converter::convertColor(maHighColor, rIter.toView()); break; } case XML_ELEMENT(CALC_EXT, XML_COLOR_LOW): { - Color aColor; - sax::Converter::convertColor(aColor, rIter.toView()); - rAttributes.setColorLow(aColor); + maLowColor = COL_TRANSPARENT; + sax::Converter::convertColor(maLowColor, rIter.toView()); break; } default: @@ -281,23 +274,72 @@ uno::Reference<xml::sax::XFastContextHandler> case XML_ELEMENT(CALC_EXT, XML_SPARKLINE_GROUP): { m_pCurrentSparklineGroup = std::make_shared<sc::SparklineGroup>(); + maAxisComplexColor = model::ComplexColor(); + maFirstComplexColor = model::ComplexColor(); + maLastComplexColor = model::ComplexColor(); + maHighComplexColor = model::ComplexColor(); + maLowComplexColor = model::ComplexColor(); + maSeriesComplexColor = model::ComplexColor(); + maNegativeComplexColor = model::ComplexColor(); + maMarkersComplexColor = model::ComplexColor(); + fillSparklineGroupID(xAttrList); fillSparklineGroupAttributes(xAttrList); pContext = this; - break; } + break; case XML_ELEMENT(CALC_EXT, XML_SPARKLINES): { pContext = this; - break; } + break; case XML_ELEMENT(CALC_EXT, XML_SPARKLINE): { SparklineImportData& rImportData = m_aCurrentSparklineDataList.emplace_back(); fillSparklineAttributes(rImportData, xAttrList); pContext = this; - break; } + break; + case XML_ELEMENT(CALC_EXT, XML_SPARKLINE_AXIS_COMPLEX_COLOR): + { + pContext = new XMLComplexColorContext(GetImport(), maAxisComplexColor, xAttrList); + } + break; + case XML_ELEMENT(CALC_EXT, XML_SPARKLINE_FIRST_COMPLEX_COLOR): + { + pContext = new XMLComplexColorContext(GetImport(), maFirstComplexColor, xAttrList); + } + break; + case XML_ELEMENT(CALC_EXT, XML_SPARKLINE_LAST_COMPLEX_COLOR): + { + pContext = new XMLComplexColorContext(GetImport(), maLastComplexColor, xAttrList); + } + break; + case XML_ELEMENT(CALC_EXT, XML_SPARKLINE_HIGH_COMPLEX_COLOR): + { + pContext = new XMLComplexColorContext(GetImport(), maHighComplexColor, xAttrList); + } + break; + case XML_ELEMENT(CALC_EXT, XML_SPARKLINE_LOW_COMPLEX_COLOR): + { + pContext = new XMLComplexColorContext(GetImport(), maLowComplexColor, xAttrList); + } + break; + case XML_ELEMENT(CALC_EXT, XML_SPARKLINE_SERIES_COMPLEX_COLOR): + { + pContext = new XMLComplexColorContext(GetImport(), maSeriesComplexColor, xAttrList); + } + break; + case XML_ELEMENT(CALC_EXT, XML_SPARKLINE_NEGATIVE_COMPLEX_COLOR): + { + pContext = new XMLComplexColorContext(GetImport(), maNegativeComplexColor, xAttrList); + } + break; + case XML_ELEMENT(CALC_EXT, XML_SPARKLINE_MARKERS_COMPLEX_COLOR): + { + pContext = new XMLComplexColorContext(GetImport(), maMarkersComplexColor, xAttrList); + } + break; } return pContext; @@ -314,12 +356,42 @@ void SparklineGroupsImportContext::insertSparklines() } } +namespace +{ +model::ComplexColor combineComplexColorAndColor(model::ComplexColor& rComplexColor, Color aColor) +{ + if (rComplexColor.getType() != model::ColorType::Unused) + rComplexColor.setFinalColor(aColor); + else if (aColor != COL_TRANSPARENT) + rComplexColor = model::ComplexColor::RGB(aColor); + return rComplexColor; +} +} // end anonymous namespace + void SAL_CALL SparklineGroupsImportContext::endFastElement(sal_Int32 nElement) { switch (nElement) { case XML_ELEMENT(CALC_EXT, XML_SPARKLINE_GROUP): { + sc::SparklineAttributes& rAttributes = m_pCurrentSparklineGroup->getAttributes(); + { + rAttributes.setColorAxis( + combineComplexColorAndColor(maAxisComplexColor, maAxisColor)); + rAttributes.setColorFirst( + combineComplexColorAndColor(maFirstComplexColor, maFirstColor)); + rAttributes.setColorLast( + combineComplexColorAndColor(maLastComplexColor, maLastColor)); + rAttributes.setColorHigh( + combineComplexColorAndColor(maHighComplexColor, maHighColor)); + rAttributes.setColorLow(combineComplexColorAndColor(maLowComplexColor, maLowColor)); + rAttributes.setColorSeries( + combineComplexColorAndColor(maSeriesComplexColor, maSeriesColor)); + rAttributes.setColorNegative( + combineComplexColorAndColor(maNegativeComplexColor, maNegativeColor)); + rAttributes.setColorMarkers( + combineComplexColorAndColor(maMarkersComplexColor, maMarkersColor)); + } insertSparklines(); m_pCurrentSparklineGroup.reset(); m_aCurrentSparklineDataList.clear(); diff --git a/sc/source/filter/xml/SparklineGroupsImportContext.hxx b/sc/source/filter/xml/SparklineGroupsImportContext.hxx index b8161c96506d..197eca9ca09a 100644 --- a/sc/source/filter/xml/SparklineGroupsImportContext.hxx +++ b/sc/source/filter/xml/SparklineGroupsImportContext.hxx @@ -14,6 +14,7 @@ #include "xmlimprt.hxx" #include <address.hxx> #include <rangelst.hxx> +#include <docmodel/color/ComplexColor.hxx> namespace sax_fastparser { @@ -38,6 +39,24 @@ private: std::shared_ptr<sc::SparklineGroup> m_pCurrentSparklineGroup; std::vector<SparklineImportData> m_aCurrentSparklineDataList; + model::ComplexColor maAxisComplexColor; + model::ComplexColor maFirstComplexColor; + model::ComplexColor maLastComplexColor; + model::ComplexColor maHighComplexColor; + model::ComplexColor maLowComplexColor; + model::ComplexColor maSeriesComplexColor; + model::ComplexColor maNegativeComplexColor; + model::ComplexColor maMarkersComplexColor; + + Color maAxisColor = COL_TRANSPARENT; + Color maFirstColor = COL_TRANSPARENT; + Color maLastColor = COL_TRANSPARENT; + Color maHighColor = COL_TRANSPARENT; + Color maLowColor = COL_TRANSPARENT; + Color maSeriesColor = COL_TRANSPARENT; + Color maNegativeColor = COL_TRANSPARENT; + Color maMarkersColor = COL_TRANSPARENT; + void fillSparklineGroupID(css::uno::Reference<css::xml::sax::XFastAttributeList> const& xAttrList); void fillSparklineGroupAttributes( diff --git a/sc/source/filter/xml/xmlstyli.cxx b/sc/source/filter/xml/xmlstyli.cxx index d562661d6a95..24486dfaba19 100644 --- a/sc/source/filter/xml/xmlstyli.cxx +++ b/sc/source/filter/xml/xmlstyli.cxx @@ -307,7 +307,7 @@ css::uno::Reference< css::xml::sax::XFastContextHandler > XMLTableCellPropsConte { case CTF_COMPLEX_COLOR: { ... etc. - the rest is truncated