chart2/Library_chart2.mk | 14 chart2/qa/extras/chart2export2.cxx | 85 ++++ chart2/qa/extras/data/xlsx/boxWhisker.xlsx |binary chart2/qa/extras/data/xlsx/clusteredColumn.xlsx |binary chart2/qa/extras/data/xlsx/paretoLine.xlsx |binary chart2/qa/extras/data/xlsx/regionMap.xlsx |binary chart2/qa/extras/data/xlsx/sunburst.xlsx |binary chart2/qa/extras/data/xlsx/treemap.xlsx |binary chart2/qa/extras/data/xlsx/waterfall.xlsx |binary chart2/source/chart2.component | 35 + chart2/source/controller/dialogs/ChartResourceGroups.cxx | 1 chart2/source/inc/servicenames_charttypes.hxx | 14 chart2/source/model/template/BoxWhiskerChartType.cxx | 78 ++++ chart2/source/model/template/BoxWhiskerChartType.hxx | 40 ++ chart2/source/model/template/BoxWhiskerChartTypeTemplate.cxx | 191 +++++++++ chart2/source/model/template/BoxWhiskerChartTypeTemplate.hxx | 61 +++ chart2/source/model/template/ChartTypeManager.cxx | 49 ++ chart2/source/model/template/ClusteredColumnChartType.cxx | 78 ++++ chart2/source/model/template/ClusteredColumnChartType.hxx | 40 ++ chart2/source/model/template/ClusteredColumnChartTypeTemplate.cxx | 193 ++++++++++ chart2/source/model/template/ClusteredColumnChartTypeTemplate.hxx | 62 +++ chart2/source/model/template/FunnelChartTypeTemplate.cxx | 4 chart2/source/model/template/ParetoLineChartType.cxx | 78 ++++ chart2/source/model/template/ParetoLineChartType.hxx | 40 ++ chart2/source/model/template/ParetoLineChartTypeTemplate.cxx | 191 +++++++++ chart2/source/model/template/ParetoLineChartTypeTemplate.hxx | 61 +++ chart2/source/model/template/RegionMapChartType.cxx | 78 ++++ chart2/source/model/template/RegionMapChartType.hxx | 40 ++ chart2/source/model/template/RegionMapChartTypeTemplate.cxx | 191 +++++++++ chart2/source/model/template/RegionMapChartTypeTemplate.hxx | 61 +++ chart2/source/model/template/SunburstChartType.cxx | 78 ++++ chart2/source/model/template/SunburstChartType.hxx | 40 ++ chart2/source/model/template/SunburstChartTypeTemplate.cxx | 191 +++++++++ chart2/source/model/template/SunburstChartTypeTemplate.hxx | 61 +++ chart2/source/model/template/TreemapChartType.cxx | 75 +++ chart2/source/model/template/TreemapChartType.hxx | 40 ++ chart2/source/model/template/TreemapChartTypeTemplate.cxx | 191 +++++++++ chart2/source/model/template/TreemapChartTypeTemplate.hxx | 61 +++ chart2/source/model/template/WaterfallChartType.cxx | 78 ++++ chart2/source/model/template/WaterfallChartType.hxx | 40 ++ chart2/source/model/template/WaterfallChartTypeTemplate.cxx | 191 +++++++++ chart2/source/model/template/WaterfallChartTypeTemplate.hxx | 61 +++ chart2/source/tools/ChartTypeHelper.cxx | 12 include/oox/export/chartexport.hxx | 18 oox/inc/drawingml/chart/typegroupconverter.hxx | 10 oox/source/core/contexthandler2.cxx | 4 oox/source/drawingml/chart/typegroupconverter.cxx | 33 + oox/source/export/chartexport.cxx | 166 +++++++- oox/source/token/tokens.txt | 2 49 files changed, 3010 insertions(+), 27 deletions(-)
New commits: commit 2dba43e31707b183d9b7cb7975209bd334900268 Author: Kurt Nordback <[email protected]> AuthorDate: Fri Nov 21 09:57:20 2025 -0700 Commit: Tomaž Vajngerl <[email protected]> CommitDate: Fri Jan 9 07:21:24 2026 +0100 tdf#165742 Step 5.1: Support basic I/O for additional chartex types Previous work on this project added support for Funnel charts, one of the chartex types. This commit expands that to all the other chartex types, including RegionMap. Largely this is parallel to what was done for Funnel, but there are some namespace differences, and ParetoLine requires some special handling because Microsoft Office seems to encode it as a combination of clusteredColumn type and paretoLine type. ParetoLine support is incomplete, especially on the export side. Change-Id: Ib751632ec05f3fbf248e0f194f7a6f36f2fa6a88 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/194933 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <[email protected]> diff --git a/chart2/Library_chart2.mk b/chart2/Library_chart2.mk index 187b640189f0..3cf268eeb9cb 100644 --- a/chart2/Library_chart2.mk +++ b/chart2/Library_chart2.mk @@ -308,6 +308,8 @@ $(eval $(call gb_Library_add_exception_objects,chart2,\ chart2/source/model/template/AreaChartTypeTemplate \ chart2/source/model/template/BarChartType \ chart2/source/model/template/BarChartTypeTemplate \ + chart2/source/model/template/BoxWhiskerChartType \ + chart2/source/model/template/BoxWhiskerChartTypeTemplate \ chart2/source/model/template/BubbleChartType \ chart2/source/model/template/BubbleChartTypeTemplate \ chart2/source/model/template/BubbleDataInterpreter \ @@ -315,6 +317,8 @@ $(eval $(call gb_Library_add_exception_objects,chart2,\ chart2/source/model/template/ChartType \ chart2/source/model/template/ChartTypeManager \ chart2/source/model/template/ChartTypeTemplate \ + chart2/source/model/template/ClusteredColumnChartType \ + chart2/source/model/template/ClusteredColumnChartTypeTemplate \ chart2/source/model/template/ColumnChartType \ chart2/source/model/template/ColumnLineChartTypeTemplate \ chart2/source/model/template/ColumnLineDataInterpreter \ @@ -326,12 +330,22 @@ $(eval $(call gb_Library_add_exception_objects,chart2,\ chart2/source/model/template/LineChartTypeTemplate \ chart2/source/model/template/NetChartType \ chart2/source/model/template/NetChartTypeTemplate \ + chart2/source/model/template/ParetoLineChartType \ + chart2/source/model/template/ParetoLineChartTypeTemplate \ chart2/source/model/template/PieChartType \ chart2/source/model/template/PieChartTypeTemplate \ + chart2/source/model/template/RegionMapChartType \ + chart2/source/model/template/RegionMapChartTypeTemplate \ chart2/source/model/template/ScatterChartType \ chart2/source/model/template/ScatterChartTypeTemplate \ + chart2/source/model/template/SunburstChartType \ + chart2/source/model/template/SunburstChartTypeTemplate \ chart2/source/model/template/StockChartTypeTemplate \ chart2/source/model/template/StockDataInterpreter \ + chart2/source/model/template/TreemapChartType \ + chart2/source/model/template/TreemapChartTypeTemplate \ + chart2/source/model/template/WaterfallChartType \ + chart2/source/model/template/WaterfallChartTypeTemplate \ chart2/source/model/template/XYDataInterpreter \ )) diff --git a/chart2/qa/extras/chart2export2.cxx b/chart2/qa/extras/chart2export2.cxx index f3bc023082ef..d425d6acbebd 100644 --- a/chart2/qa/extras/chart2export2.cxx +++ b/chart2/qa/extras/chart2export2.cxx @@ -152,9 +152,32 @@ CPPUNIT_TEST_FIXTURE(Chart2ExportTest2, testCrossBetweenODS) CPPUNIT_TEST_FIXTURE(Chart2ExportTest2, testChartexTitleXLSX) { + xmlDocUniquePtr pXmlDoc; + + // ==== + loadFromFile(u"xlsx/boxWhisker.xlsx"); + save(TestFilter::XLSX); + pXmlDoc = parseExport(u"xl/charts/chartEx1.xml"_ustr); + CPPUNIT_ASSERT(pXmlDoc); + + assertXPath(pXmlDoc, "/cx:chartSpace/cx:chart/cx:plotArea/cx:plotAreaRegion/cx:series", 3, 0, + "layoutId", u"boxWhisker"); + assertXPathContent(pXmlDoc, "/cx:chartSpace/cx:chart/cx:title/cx:tx/cx:txData/cx:v", + u"BoxWhisker"); + // ==== + loadFromFile(u"xlsx/clusteredColumn.xlsx"); + save(TestFilter::XLSX); + pXmlDoc = parseExport(u"xl/charts/chartEx1.xml"_ustr); + CPPUNIT_ASSERT(pXmlDoc); + + assertXPath(pXmlDoc, "/cx:chartSpace/cx:chart/cx:plotArea/cx:plotAreaRegion/cx:series", + "layoutId", u"clusteredColumn"); + assertXPathContent(pXmlDoc, "/cx:chartSpace/cx:chart/cx:title/cx:tx/cx:txData/cx:v", + u"Clustered Column"); + // ==== loadFromFile(u"xlsx/funnel1.xlsx"); save(TestFilter::XLSX); - xmlDocUniquePtr pXmlDoc = parseExport(u"xl/charts/chartEx1.xml"_ustr); + pXmlDoc = parseExport(u"xl/charts/chartEx1.xml"_ustr); CPPUNIT_ASSERT(pXmlDoc); assertXPath(pXmlDoc, "/cx:chartSpace/cx:chart/cx:plotArea/cx:plotAreaRegion/cx:series", @@ -166,6 +189,66 @@ CPPUNIT_TEST_FIXTURE(Chart2ExportTest2, testChartexTitleXLSX) "val", u"c55a11"); assertXPathContent(pXmlDoc, "/cx:chartSpace/cx:chart/cx:title/cx:tx/cx:txData/cx:v", u"Funnel chart!"); + + // ==== + loadFromFile(u"xlsx/paretoLine.xlsx"); + save(TestFilter::XLSX); + pXmlDoc = parseExport(u"xl/charts/chartEx1.xml"_ustr); + CPPUNIT_ASSERT(pXmlDoc); + +#if 0 + // This is what it really should be, based on MSO output + assertXPath(pXmlDoc, "/cx:chartSpace/cx:chart/cx:plotArea/cx:plotAreaRegion/cx:series", + 2, 0, "layoutId", u"clusteredColumn"); + assertXPath(pXmlDoc, "/cx:chartSpace/cx:chart/cx:plotArea/cx:plotAreaRegion/cx:series", + 2, 1, "layoutId", u"paretoLine"); +#else + // This is what LO currently produces + assertXPath(pXmlDoc, "/cx:chartSpace/cx:chart/cx:plotArea/cx:plotAreaRegion/cx:series", 2, 0, + "layoutId", u"paretoLine"); +#endif + assertXPathContent(pXmlDoc, "/cx:chartSpace/cx:chart/cx:title/cx:tx/cx:txData/cx:v", + u"ParetoLine"); + // ==== + loadFromFile(u"xlsx/regionMap.xlsx"); + save(TestFilter::XLSX); + pXmlDoc = parseExport(u"xl/charts/chartEx1.xml"_ustr); + CPPUNIT_ASSERT(pXmlDoc); + + assertXPath(pXmlDoc, "/cx:chartSpace/cx:chart/cx:plotArea/cx:plotAreaRegion/cx:series", + "layoutId", u"regionMap"); + assertXPathContent(pXmlDoc, "/cx:chartSpace/cx:chart/cx:title/cx:tx/cx:txData/cx:v", + u"RegionMap"); + // ==== + loadFromFile(u"xlsx/sunburst.xlsx"); + save(TestFilter::XLSX); + pXmlDoc = parseExport(u"xl/charts/chartEx1.xml"_ustr); + CPPUNIT_ASSERT(pXmlDoc); + + assertXPath(pXmlDoc, "/cx:chartSpace/cx:chart/cx:plotArea/cx:plotAreaRegion/cx:series", + "layoutId", u"sunburst"); + assertXPathContent(pXmlDoc, "/cx:chartSpace/cx:chart/cx:title/cx:tx/cx:txData/cx:v", + u"Sunburst"); + // ==== + loadFromFile(u"xlsx/treemap.xlsx"); + save(TestFilter::XLSX); + pXmlDoc = parseExport(u"xl/charts/chartEx1.xml"_ustr); + CPPUNIT_ASSERT(pXmlDoc); + + assertXPath(pXmlDoc, "/cx:chartSpace/cx:chart/cx:plotArea/cx:plotAreaRegion/cx:series", + "layoutId", u"treemap"); + assertXPathContent(pXmlDoc, "/cx:chartSpace/cx:chart/cx:title/cx:tx/cx:txData/cx:v", + u"Treemap"); + // ==== + loadFromFile(u"xlsx/waterfall.xlsx"); + save(TestFilter::XLSX); + pXmlDoc = parseExport(u"xl/charts/chartEx1.xml"_ustr); + CPPUNIT_ASSERT(pXmlDoc); + + assertXPath(pXmlDoc, "/cx:chartSpace/cx:chart/cx:plotArea/cx:plotAreaRegion/cx:series", + "layoutId", u"waterfall"); + assertXPathContent(pXmlDoc, "/cx:chartSpace/cx:chart/cx:title/cx:tx/cx:txData/cx:v", + u"Waterfall"); } CPPUNIT_TEST_FIXTURE(Chart2ExportTest2, testChartexPPTX) diff --git a/chart2/qa/extras/data/xlsx/boxWhisker.xlsx b/chart2/qa/extras/data/xlsx/boxWhisker.xlsx new file mode 100644 index 000000000000..68b2b5be652b Binary files /dev/null and b/chart2/qa/extras/data/xlsx/boxWhisker.xlsx differ diff --git a/chart2/qa/extras/data/xlsx/clusteredColumn.xlsx b/chart2/qa/extras/data/xlsx/clusteredColumn.xlsx new file mode 100644 index 000000000000..708fe47bba1c Binary files /dev/null and b/chart2/qa/extras/data/xlsx/clusteredColumn.xlsx differ diff --git a/chart2/qa/extras/data/xlsx/paretoLine.xlsx b/chart2/qa/extras/data/xlsx/paretoLine.xlsx new file mode 100644 index 000000000000..0f4458cbc6da Binary files /dev/null and b/chart2/qa/extras/data/xlsx/paretoLine.xlsx differ diff --git a/chart2/qa/extras/data/xlsx/regionMap.xlsx b/chart2/qa/extras/data/xlsx/regionMap.xlsx new file mode 100644 index 000000000000..55ff2b005e89 Binary files /dev/null and b/chart2/qa/extras/data/xlsx/regionMap.xlsx differ diff --git a/chart2/qa/extras/data/xlsx/sunburst.xlsx b/chart2/qa/extras/data/xlsx/sunburst.xlsx new file mode 100644 index 000000000000..010ea1054a17 Binary files /dev/null and b/chart2/qa/extras/data/xlsx/sunburst.xlsx differ diff --git a/chart2/qa/extras/data/xlsx/treemap.xlsx b/chart2/qa/extras/data/xlsx/treemap.xlsx new file mode 100644 index 000000000000..52f98fab9bd0 Binary files /dev/null and b/chart2/qa/extras/data/xlsx/treemap.xlsx differ diff --git a/chart2/qa/extras/data/xlsx/waterfall.xlsx b/chart2/qa/extras/data/xlsx/waterfall.xlsx new file mode 100644 index 000000000000..c810d9490823 Binary files /dev/null and b/chart2/qa/extras/data/xlsx/waterfall.xlsx differ diff --git a/chart2/source/chart2.component b/chart2/source/chart2.component index 5e41ddf69b1a..4f1fcb92ed0d 100644 --- a/chart2/source/chart2.component +++ b/chart2/source/chart2.component @@ -116,6 +116,11 @@ <service name="com.sun.star.chart2.BarChartType"/> <service name="com.sun.star.chart2.ChartType"/> </implementation> + <implementation name="com.sun.star.comp.chart.BoxWhiskerChartType" + constructor="com_sun_star_comp_chart_BoxWhiskerChartType_get_implementation"> + <service name="com.sun.star.chart2.ChartType"/> + <service name="com.sun.star.chart2.BoxWhiskerChartType"/> + </implementation> <implementation name="com.sun.star.comp.chart.BubbleChartType" constructor="com_sun_star_comp_chart_BubbleChartType_get_implementation"> <service name="com.sun.star.beans.PropertySet"/> @@ -132,6 +137,11 @@ constructor="com_sun_star_comp_chart_ChartTypeManager_get_implementation"> <service name="com.sun.star.chart2.ChartTypeManager"/> </implementation> + <implementation name="com.sun.star.comp.chart.ClusteredColumnChartType" + constructor="com_sun_star_comp_chart_ClusteredColumnChartType_get_implementation"> + <service name="com.sun.star.chart2.ChartType"/> + <service name="com.sun.star.chart2.ClusteredColumnChartType"/> + </implementation> <implementation name="com.sun.star.comp.chart.ColumnChartType" constructor="com_sun_star_comp_chart_ColumnChartType_get_implementation"> <service name="com.sun.star.chart2.ChartType"/> @@ -172,18 +182,43 @@ <service name="com.sun.star.chart2.ChartType"/> <service name="com.sun.star.chart2.NetChartType"/> </implementation> + <implementation name="com.sun.star.comp.chart.ParetoLineChartType" + constructor="com_sun_star_comp_chart_ParetoLineChartType_get_implementation"> + <service name="com.sun.star.chart2.ChartType"/> + <service name="com.sun.star.chart2.ParetoLineChartType"/> + </implementation> <implementation name="com.sun.star.comp.chart.PieChartType" constructor="com_sun_star_comp_chart_PieChartType_get_implementation"> <service name="com.sun.star.beans.PropertySet"/> <service name="com.sun.star.chart2.ChartType"/> <service name="com.sun.star.chart2.PieChartType"/> </implementation> + <implementation name="com.sun.star.comp.chart.RegionMapChartType" + constructor="com_sun_star_comp_chart_RegionMapChartType_get_implementation"> + <service name="com.sun.star.chart2.ChartType"/> + <service name="com.sun.star.chart2.RegionMapChartType"/> + </implementation> <implementation name="com.sun.star.comp.chart.ScatterChartType" constructor="com_sun_star_comp_chart_ScatterChartType_get_implementation"> <service name="com.sun.star.beans.PropertySet"/> <service name="com.sun.star.chart2.ChartType"/> <service name="com.sun.star.chart2.ScatterChartType"/> </implementation> + <implementation name="com.sun.star.comp.chart.SunburstChartType" + constructor="com_sun_star_comp_chart_SunburstChartType_get_implementation"> + <service name="com.sun.star.chart2.ChartType"/> + <service name="com.sun.star.chart2.SunburstChartType"/> + </implementation> + <implementation name="com.sun.star.comp.chart.TreemapChartType" + constructor="com_sun_star_comp_chart_TreemapChartType_get_implementation"> + <service name="com.sun.star.chart2.ChartType"/> + <service name="com.sun.star.chart2.TreemapChartType"/> + </implementation> + <implementation name="com.sun.star.comp.chart.WaterfallChartType" + constructor="com_sun_star_comp_chart_WaterfallChartType_get_implementation"> + <service name="com.sun.star.chart2.ChartType"/> + <service name="com.sun.star.chart2.WaterfallChartType"/> + </implementation> <implementation name="com.sun.star.comp.chart2.Axis" constructor="com_sun_star_comp_chart2_Axis_get_implementation"> <service name="com.sun.star.beans.PropertySet"/> diff --git a/chart2/source/controller/dialogs/ChartResourceGroups.cxx b/chart2/source/controller/dialogs/ChartResourceGroups.cxx index b344a1fda3c8..9d4f1099f59b 100644 --- a/chart2/source/controller/dialogs/ChartResourceGroups.cxx +++ b/chart2/source/controller/dialogs/ChartResourceGroups.cxx @@ -34,6 +34,7 @@ Dim3DLookResourceGroup::Dim3DLookResourceGroup(weld::Builder* pBuilder) { m_xCB_3DLook->connect_toggled(LINK(this, Dim3DLookResourceGroup, Dim3DLookCheckHdl)); m_xLB_Scheme->connect_changed(LINK(this, Dim3DLookResourceGroup, SelectSchemeHdl)); + m_xCB_3DLook->set_active(false); } void Dim3DLookResourceGroup::showControls(bool bShow) diff --git a/chart2/source/inc/servicenames_charttypes.hxx b/chart2/source/inc/servicenames_charttypes.hxx index 5a84e3b92c0c..22e9f446a996 100644 --- a/chart2/source/inc/servicenames_charttypes.hxx +++ b/chart2/source/inc/servicenames_charttypes.hxx @@ -40,7 +40,21 @@ inline constexpr OUString CHART2_SERVICE_NAME_CHARTTYPE_CANDLESTICK = u"com.sun.star.chart2.CandleStickChartType"_ustr; inline constexpr OUString CHART2_SERVICE_NAME_CHARTTYPE_BUBBLE = u"com.sun.star.chart2.BubbleChartType"_ustr; +inline constexpr OUString CHART2_SERVICE_NAME_CHARTTYPE_BOXWHISKER + = u"com.sun.star.chart2.BoxWhiskerChartType"_ustr; +inline constexpr OUString CHART2_SERVICE_NAME_CHARTTYPE_CLUSTEREDCOLUMN + = u"com.sun.star.chart2.ClusteredColumnChartType"_ustr; inline constexpr OUString CHART2_SERVICE_NAME_CHARTTYPE_FUNNEL = u"com.sun.star.chart2.FunnelChartType"_ustr; +inline constexpr OUString CHART2_SERVICE_NAME_CHARTTYPE_PARETOLINE + = u"com.sun.star.chart2.ParetoLineChartType"_ustr; +inline constexpr OUString CHART2_SERVICE_NAME_CHARTTYPE_REGIONMAP + = u"com.sun.star.chart2.RegionMapChartType"_ustr; +inline constexpr OUString CHART2_SERVICE_NAME_CHARTTYPE_SUNBURST + = u"com.sun.star.chart2.SunburstChartType"_ustr; +inline constexpr OUString CHART2_SERVICE_NAME_CHARTTYPE_TREEMAP + = u"com.sun.star.chart2.TreemapChartType"_ustr; +inline constexpr OUString CHART2_SERVICE_NAME_CHARTTYPE_WATERFALL + = u"com.sun.star.chart2.WaterfallChartType"_ustr; /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/model/template/BoxWhiskerChartType.cxx b/chart2/source/model/template/BoxWhiskerChartType.cxx new file mode 100644 index 000000000000..02847c668107 --- /dev/null +++ b/chart2/source/model/template/BoxWhiskerChartType.cxx @@ -0,0 +1,78 @@ +/* -*- 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 "BoxWhiskerChartType.hxx" +#include <servicenames_charttypes.hxx> +#include <cppuhelper/supportsservice.hxx> + +namespace com::sun::star::uno +{ +class XComponentContext; +} + +using namespace ::com::sun::star; + +namespace chart +{ +BoxWhiskerChartType::BoxWhiskerChartType() {} + +BoxWhiskerChartType::BoxWhiskerChartType(const BoxWhiskerChartType& rOther) + : ChartType(rOther) +{ +} + +BoxWhiskerChartType::~BoxWhiskerChartType() {} + +// ____ XCloneable ____ +uno::Reference<util::XCloneable> SAL_CALL BoxWhiskerChartType::createClone() +{ + return uno::Reference<util::XCloneable>(new BoxWhiskerChartType(*this)); +} + +rtl::Reference<ChartType> BoxWhiskerChartType::cloneChartType() const +{ + return new BoxWhiskerChartType(*this); +} + +// ____ XChartType ____ +OUString SAL_CALL BoxWhiskerChartType::getChartType() +{ + return CHART2_SERVICE_NAME_CHARTTYPE_BOXWHISKER; +} + +uno::Sequence<OUString> BoxWhiskerChartType::getSupportedPropertyRoles() +{ + return { "FillColor", "BorderColor" }; +} + +OUString SAL_CALL BoxWhiskerChartType::getImplementationName() +{ + return "com.sun.star.comp.chart.BoxWhiskerChartType"; +} + +sal_Bool SAL_CALL BoxWhiskerChartType::supportsService(const OUString& rServiceName) +{ + return cppu::supportsService(this, rServiceName); +} + +css::uno::Sequence<OUString> SAL_CALL BoxWhiskerChartType::getSupportedServiceNames() +{ + return { CHART2_SERVICE_NAME_CHARTTYPE_BOXWHISKER, "com.sun.star.chart2.ChartType" }; +} + +} // namespace chart + +extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface* +com_sun_star_comp_chart_BoxWhiskerChartType_get_implementation( + css::uno::XComponentContext* /*context*/, css::uno::Sequence<css::uno::Any> const&) +{ + return cppu::acquire(new ::chart::BoxWhiskerChartType); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/model/template/BoxWhiskerChartType.hxx b/chart2/source/model/template/BoxWhiskerChartType.hxx new file mode 100644 index 000000000000..76a25d3fba0f --- /dev/null +++ b/chart2/source/model/template/BoxWhiskerChartType.hxx @@ -0,0 +1,40 @@ +/* -*- 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/. + */ +#pragma once + +#include <ChartType.hxx> + +namespace chart +{ +class BoxWhiskerChartType final : public ChartType +{ +public: + explicit BoxWhiskerChartType(); + virtual ~BoxWhiskerChartType() override; + + virtual OUString SAL_CALL getImplementationName() override; + virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) override; + virtual css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override; + + virtual rtl::Reference<ChartType> cloneChartType() const override; + +private: + explicit BoxWhiskerChartType(const BoxWhiskerChartType& rOther); + + // ____ XChartType ____ + virtual OUString SAL_CALL getChartType() override; + virtual css::uno::Sequence<OUString> SAL_CALL getSupportedPropertyRoles() override; + + // ____ XCloneable ____ + virtual css::uno::Reference<css::util::XCloneable> SAL_CALL createClone() override; +}; + +} // namespace chart + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/model/template/BoxWhiskerChartTypeTemplate.cxx b/chart2/source/model/template/BoxWhiskerChartTypeTemplate.cxx new file mode 100644 index 000000000000..116321b53dd4 --- /dev/null +++ b/chart2/source/model/template/BoxWhiskerChartTypeTemplate.cxx @@ -0,0 +1,191 @@ +/* -*- 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 "BoxWhiskerChartTypeTemplate.hxx" +#include "BoxWhiskerChartType.hxx" +#include <Diagram.hxx> +#include <DataSeries.hxx> +#include <DataSeriesHelper.hxx> +#include <PropertyHelper.hxx> +#include <com/sun/star/beans/PropertyAttribute.hpp> +#include <com/sun/star/drawing/LineStyle.hpp> +#include <com/sun/star/chart2/DataPointGeometry3D.hpp> +#include <com/sun/star/uno/XComponentContext.hpp> +#include <comphelper/diagnose_ex.hxx> + +#include <algorithm> + +using namespace ::com::sun::star; + +using ::com::sun::star::uno::Reference; +using ::com::sun::star::uno::Sequence; +using ::com::sun::star::beans::Property; + +namespace +{ +enum +{ + PROP_BOXWHISKER_TEMPLATE_DIMENSION, + PROP_BOXWHISKER_TEMPLATE_GEOMETRY3D +}; + +void lcl_AddPropertiesToVector(std::vector<Property>& rOutProperties) +{ + rOutProperties.emplace_back( + "Dimension", PROP_BOXWHISKER_TEMPLATE_DIMENSION, cppu::UnoType<sal_Int32>::get(), + beans::PropertyAttribute::BOUND | beans::PropertyAttribute::MAYBEDEFAULT); + rOutProperties.emplace_back( + "Geometry3D", PROP_BOXWHISKER_TEMPLATE_GEOMETRY3D, cppu::UnoType<sal_Int32>::get(), + beans::PropertyAttribute::BOUND | beans::PropertyAttribute::MAYBEDEFAULT); +} + +::cppu::OPropertyArrayHelper& StaticBoxWhiskerChartTypeTemplateInfoHelper() +{ + static ::cppu::OPropertyArrayHelper aPropHelper = []() { + std::vector<css::beans::Property> aProperties; + lcl_AddPropertiesToVector(aProperties); + + std::sort(aProperties.begin(), aProperties.end(), ::chart::PropertyNameLess()); + + return comphelper::containerToSequence(aProperties); + }(); + return aPropHelper; +}; + +} // anonymous namespace + +namespace chart +{ +BoxWhiskerChartTypeTemplate::BoxWhiskerChartTypeTemplate( + Reference<uno::XComponentContext> const& xContext, const OUString& rServiceName, + sal_Int32 nDim /* = 2 */) + : ChartTypeTemplate(xContext, rServiceName) + , m_nDim(nDim) +{ +} + +BoxWhiskerChartTypeTemplate::~BoxWhiskerChartTypeTemplate() {} + +sal_Int32 BoxWhiskerChartTypeTemplate::getDimension() const { return m_nDim; } + +// ____ ChartTypeTemplate ____ +bool BoxWhiskerChartTypeTemplate::matchesTemplate2(const rtl::Reference<::chart::Diagram>& xDiagram, + bool bAdaptProperties) +{ + bool bResult = ChartTypeTemplate::matchesTemplate2(xDiagram, bAdaptProperties); + + // adapt solid-type of template according to values in series + if (bAdaptProperties && bResult && getDimension() == 3) + { + bool bGeomFound = false, bGeomAmbiguous = false; + sal_Int32 aCommonGeom = xDiagram->getGeometry3D(bGeomFound, bGeomAmbiguous); + + if (!bGeomAmbiguous) + { + setFastPropertyValue_NoBroadcast(PROP_BOXWHISKER_TEMPLATE_GEOMETRY3D, + uno::Any(aCommonGeom)); + } + } + + return bResult; +} + +rtl::Reference<ChartType> + BoxWhiskerChartTypeTemplate::getChartTypeForIndex(sal_Int32 /*nChartTypeIndex*/) +{ + return new BoxWhiskerChartType(); +} + +rtl::Reference<ChartType> BoxWhiskerChartTypeTemplate::getChartTypeForNewSeries2( + const std::vector<rtl::Reference<ChartType>>& aFormerlyUsedChartTypes) +{ + rtl::Reference<ChartType> xResult(getChartTypeForIndex(0)); + ChartTypeTemplate::copyPropertiesFromOldToNewCoordinateSystem(aFormerlyUsedChartTypes, xResult); + return xResult; +} + +// ____ OPropertySet ____ +void BoxWhiskerChartTypeTemplate::GetDefaultValue(sal_Int32 nHandle, uno::Any& rAny) const +{ + static ::chart::tPropertyValueMap aStaticDefaults = []() { + ::chart::tPropertyValueMap aTmp; + ::chart::PropertyHelper::setPropertyValueDefault<sal_Int32>( + aTmp, PROP_BOXWHISKER_TEMPLATE_DIMENSION, 2); + ::chart::PropertyHelper::setPropertyValueDefault(aTmp, PROP_BOXWHISKER_TEMPLATE_GEOMETRY3D, + ::chart2::DataPointGeometry3D::CUBOID); + return aTmp; + }(); + tPropertyValueMap::const_iterator aFound(aStaticDefaults.find(nHandle)); + if (aFound == aStaticDefaults.end()) + rAny.clear(); + else + rAny = (*aFound).second; +} + +::cppu::IPropertyArrayHelper& SAL_CALL BoxWhiskerChartTypeTemplate::getInfoHelper() +{ + return StaticBoxWhiskerChartTypeTemplateInfoHelper(); +} + +// ____ XPropertySet ____ +Reference<beans::XPropertySetInfo> SAL_CALL BoxWhiskerChartTypeTemplate::getPropertySetInfo() +{ + static uno::Reference<beans::XPropertySetInfo> xPropertySetInfo( + ::cppu::OPropertySetHelper::createPropertySetInfo( + StaticBoxWhiskerChartTypeTemplateInfoHelper())); + return xPropertySetInfo; +} + +void BoxWhiskerChartTypeTemplate::applyStyle2(const rtl::Reference<DataSeries>& xSeries, + ::sal_Int32 nChartTypeIndex, ::sal_Int32 nSeriesIndex, + ::sal_Int32 nSeriesCount) +{ + ChartTypeTemplate::applyStyle2(xSeries, nChartTypeIndex, nSeriesIndex, nSeriesCount); + xSeries->setPropertyAlsoToAllAttributedDataPoints("BorderStyle", + uno::Any(drawing::LineStyle_NONE)); + if (getDimension() != 3) + return; + + try + { + //apply Geometry3D + uno::Any aAGeometry3D; + getFastPropertyValue(aAGeometry3D, PROP_BOXWHISKER_TEMPLATE_GEOMETRY3D); + xSeries->setPropertyAlsoToAllAttributedDataPoints("Geometry3D", aAGeometry3D); + } + catch (const uno::Exception&) + { + DBG_UNHANDLED_EXCEPTION("chart2"); + } +} + +void BoxWhiskerChartTypeTemplate::resetStyles2(const rtl::Reference<::chart::Diagram>& xDiagram) +{ + ChartTypeTemplate::resetStyles2(xDiagram); + std::vector<rtl::Reference<DataSeries>> aSeriesVec(xDiagram->getDataSeries()); + uno::Any aLineStyleAny(drawing::LineStyle_NONE); + for (auto const& series : aSeriesVec) + { + if (getDimension() == 3) + series->setPropertyToDefault("Geometry3D"); + if (series->getPropertyValue("BorderStyle") == aLineStyleAny) + { + series->setPropertyToDefault("BorderStyle"); + } + } + + xDiagram->setVertical(false); +} + +IMPLEMENT_FORWARD_XINTERFACE2(BoxWhiskerChartTypeTemplate, ChartTypeTemplate, OPropertySet) +IMPLEMENT_FORWARD_XTYPEPROVIDER2(BoxWhiskerChartTypeTemplate, ChartTypeTemplate, OPropertySet) + +} // namespace chart + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/model/template/BoxWhiskerChartTypeTemplate.hxx b/chart2/source/model/template/BoxWhiskerChartTypeTemplate.hxx new file mode 100644 index 000000000000..a6721483ea16 --- /dev/null +++ b/chart2/source/model/template/BoxWhiskerChartTypeTemplate.hxx @@ -0,0 +1,61 @@ +/* -*- 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/. + */ +#pragma once + +#include <OPropertySet.hxx> +#include <comphelper/uno3.hxx> + +#include <ChartTypeTemplate.hxx> + +namespace chart +{ +class BoxWhiskerChartTypeTemplate : public ChartTypeTemplate, public ::property::OPropertySet +{ +public: + BoxWhiskerChartTypeTemplate(css::uno::Reference<css::uno::XComponentContext> const& xContext, + const OUString& rServiceName, sal_Int32 nDim = 2); + virtual ~BoxWhiskerChartTypeTemplate() override; + + /// merge XInterface implementations + DECLARE_XINTERFACE() + /// merge XTypeProvider implementations + DECLARE_XTYPEPROVIDER() + +protected: + // ____ OPropertySet ____ + virtual void GetDefaultValue(sal_Int32 nHandle, css::uno::Any& rAny) const override; + virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper() override; + + // ____ XPropertySet ____ + virtual css::uno::Reference<css::beans::XPropertySetInfo> + SAL_CALL getPropertySetInfo() override; + + // ____ ChartTypeTemplate ____ + virtual bool matchesTemplate2(const rtl::Reference<::chart::Diagram>& xDiagram, + bool bAdaptProperties) override; + virtual rtl::Reference<::chart::ChartType> getChartTypeForNewSeries2( + const std::vector<rtl::Reference<::chart::ChartType>>& aFormerlyUsedChartTypes) override; + virtual void applyStyle2(const rtl::Reference<::chart::DataSeries>& xSeries, + ::sal_Int32 nChartTypeGroupIndex, ::sal_Int32 nSeriesIndex, + ::sal_Int32 nSeriesCount) override; + virtual void resetStyles2(const rtl::Reference<::chart::Diagram>& xDiagram) override; + + // ____ ChartTypeTemplate ____ + virtual sal_Int32 getDimension() const override; + + virtual rtl::Reference<::chart::ChartType> + getChartTypeForIndex(sal_Int32 nChartTypeIndex) override; + +private: + sal_Int32 m_nDim; +}; + +} // namespace chart + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/model/template/ChartTypeManager.cxx b/chart2/source/model/template/ChartTypeManager.cxx index 7acb02a6c894..89cb3518ff3f 100644 --- a/chart2/source/model/template/ChartTypeManager.cxx +++ b/chart2/source/model/template/ChartTypeManager.cxx @@ -30,6 +30,13 @@ #include "NetChartTypeTemplate.hxx" #include "BubbleChartTypeTemplate.hxx" #include "FunnelChartTypeTemplate.hxx" +#include "BoxWhiskerChartTypeTemplate.hxx" +#include "ClusteredColumnChartTypeTemplate.hxx" +#include "ParetoLineChartTypeTemplate.hxx" +#include "RegionMapChartTypeTemplate.hxx" +#include "SunburstChartTypeTemplate.hxx" +#include "TreemapChartTypeTemplate.hxx" +#include "WaterfallChartTypeTemplate.hxx" #include <cppuhelper/supportsservice.hxx> #include <com/sun/star/container/XContentEnumerationAccess.hpp> #include <com/sun/star/lang/XServiceName.hpp> @@ -118,6 +125,13 @@ enum TemplateId TEMPLATE_STOCKVOLUMEOPENLOWHIGHCLOSE, TEMPLATE_BUBBLE, TEMPLATE_FUNNEL, + TEMPLATE_BOXWHISKER, + TEMPLATE_CLUSTEREDCOLUMN, + TEMPLATE_PARETOLINE, + TEMPLATE_REGIONMAP, + TEMPLATE_SUNBURST, + TEMPLATE_TREEMAP, + TEMPLATE_WATERFALL, // TEMPLATE_SURFACE, // TEMPLATE_ADDIN, TEMPLATE_NOT_FOUND = 0xffff @@ -196,6 +210,13 @@ const tTemplateMapType & lcl_DefaultChartTypeMap() {"com.sun.star.chart2.template.StockVolumeOpenLowHighClose", TEMPLATE_STOCKVOLUMEOPENLOWHIGHCLOSE}, {"com.sun.star.chart2.template.Bubble", TEMPLATE_BUBBLE}, {"com.sun.star.chart2.template.Funnel", TEMPLATE_FUNNEL}, + {"com.sun.star.chart2.template.BoxWhisker", TEMPLATE_BOXWHISKER}, + {"com.sun.star.chart2.template.ClusteredColumn", TEMPLATE_CLUSTEREDCOLUMN}, + {"com.sun.star.chart2.template.ParetoLine", TEMPLATE_PARETOLINE}, + {"com.sun.star.chart2.template.RegionMap", TEMPLATE_REGIONMAP}, + {"com.sun.star.chart2.template.Sunburst", TEMPLATE_SUNBURST}, + {"com.sun.star.chart2.template.Treemap", TEMPLATE_TREEMAP}, + {"com.sun.star.chart2.template.Waterfall", TEMPLATE_WATERFALL}, // {"com.sun.star.chart2.template.Surface", TEMPLATE_SURFACE}, // {"com.sun.star.chart2.template.Addin", TEMPLATE_ADDIN}, }; @@ -532,6 +553,34 @@ rtl::Reference< ::chart::ChartTypeTemplate > ChartTypeManager::createTemplate( xTemplate.set( new FunnelChartTypeTemplate( m_xContext, aServiceSpecifier)); break; + case TEMPLATE_BOXWHISKER: + xTemplate.set( new BoxWhiskerChartTypeTemplate( m_xContext, + aServiceSpecifier)); + break; + case TEMPLATE_CLUSTEREDCOLUMN: + xTemplate.set( new ClusteredColumnChartTypeTemplate( m_xContext, + aServiceSpecifier)); + break; + case TEMPLATE_PARETOLINE: + xTemplate.set( new ParetoLineChartTypeTemplate( m_xContext, + aServiceSpecifier)); + break; + case TEMPLATE_REGIONMAP: + xTemplate.set( new RegionMapChartTypeTemplate( m_xContext, + aServiceSpecifier)); + break; + case TEMPLATE_SUNBURST: + xTemplate.set( new SunburstChartTypeTemplate( m_xContext, + aServiceSpecifier)); + break; + case TEMPLATE_TREEMAP: + xTemplate.set( new TreemapChartTypeTemplate( m_xContext, + aServiceSpecifier)); + break; + case TEMPLATE_WATERFALL: + xTemplate.set( new WaterfallChartTypeTemplate( m_xContext, + aServiceSpecifier)); + break; case TEMPLATE_NOT_FOUND: SAL_WARN("chart2", "Couldn't instantiate service: "<< aServiceSpecifier ); assert(false); diff --git a/chart2/source/model/template/ClusteredColumnChartType.cxx b/chart2/source/model/template/ClusteredColumnChartType.cxx new file mode 100644 index 000000000000..618286b894f8 --- /dev/null +++ b/chart2/source/model/template/ClusteredColumnChartType.cxx @@ -0,0 +1,78 @@ +/* -*- 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 "ClusteredColumnChartType.hxx" +#include <servicenames_charttypes.hxx> +#include <cppuhelper/supportsservice.hxx> + +namespace com::sun::star::uno +{ +class XComponentContext; +} + +using namespace ::com::sun::star; + +namespace chart +{ +ClusteredColumnChartType::ClusteredColumnChartType() {} + +ClusteredColumnChartType::ClusteredColumnChartType(const ClusteredColumnChartType& rOther) + : ChartType(rOther) +{ +} + +ClusteredColumnChartType::~ClusteredColumnChartType() {} + +// ____ XCloneable ____ +uno::Reference<util::XCloneable> SAL_CALL ClusteredColumnChartType::createClone() +{ + return uno::Reference<util::XCloneable>(new ClusteredColumnChartType(*this)); +} + +rtl::Reference<ChartType> ClusteredColumnChartType::cloneChartType() const +{ + return new ClusteredColumnChartType(*this); +} + +// ____ XChartType ____ +OUString SAL_CALL ClusteredColumnChartType::getChartType() +{ + return CHART2_SERVICE_NAME_CHARTTYPE_CLUSTEREDCOLUMN; +} + +uno::Sequence<OUString> ClusteredColumnChartType::getSupportedPropertyRoles() +{ + return { "FillColor", "BorderColor" }; +} + +OUString SAL_CALL ClusteredColumnChartType::getImplementationName() +{ + return "com.sun.star.comp.chart.ClusteredColumnChartType"; +} + +sal_Bool SAL_CALL ClusteredColumnChartType::supportsService(const OUString& rServiceName) +{ + return cppu::supportsService(this, rServiceName); +} + +css::uno::Sequence<OUString> SAL_CALL ClusteredColumnChartType::getSupportedServiceNames() +{ + return { CHART2_SERVICE_NAME_CHARTTYPE_CLUSTEREDCOLUMN, "com.sun.star.chart2.ChartType" }; +} + +} // namespace chart + +extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface* +com_sun_star_comp_chart_ClusteredColumnChartType_get_implementation( + css::uno::XComponentContext* /*context*/, css::uno::Sequence<css::uno::Any> const&) +{ + return cppu::acquire(new ::chart::ClusteredColumnChartType); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/model/template/ClusteredColumnChartType.hxx b/chart2/source/model/template/ClusteredColumnChartType.hxx new file mode 100644 index 000000000000..d60d7753afa5 --- /dev/null +++ b/chart2/source/model/template/ClusteredColumnChartType.hxx @@ -0,0 +1,40 @@ +/* -*- 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/. + */ +#pragma once + +#include <ChartType.hxx> + +namespace chart +{ +class ClusteredColumnChartType final : public ChartType +{ +public: + explicit ClusteredColumnChartType(); + virtual ~ClusteredColumnChartType() override; + + virtual OUString SAL_CALL getImplementationName() override; + virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) override; + virtual css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override; + + virtual rtl::Reference<ChartType> cloneChartType() const override; + +private: + explicit ClusteredColumnChartType(const ClusteredColumnChartType& rOther); + + // ____ XChartType ____ + virtual OUString SAL_CALL getChartType() override; + virtual css::uno::Sequence<OUString> SAL_CALL getSupportedPropertyRoles() override; + + // ____ XCloneable ____ + virtual css::uno::Reference<css::util::XCloneable> SAL_CALL createClone() override; +}; + +} // namespace chart + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/model/template/ClusteredColumnChartTypeTemplate.cxx b/chart2/source/model/template/ClusteredColumnChartTypeTemplate.cxx new file mode 100644 index 000000000000..355c14e1ce05 --- /dev/null +++ b/chart2/source/model/template/ClusteredColumnChartTypeTemplate.cxx @@ -0,0 +1,193 @@ +/* -*- 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 "ClusteredColumnChartTypeTemplate.hxx" +#include "ClusteredColumnChartType.hxx" +#include <Diagram.hxx> +#include <DataSeries.hxx> +#include <DataSeriesHelper.hxx> +#include <PropertyHelper.hxx> +#include <com/sun/star/beans/PropertyAttribute.hpp> +#include <com/sun/star/drawing/LineStyle.hpp> +#include <com/sun/star/chart2/DataPointGeometry3D.hpp> +#include <com/sun/star/uno/XComponentContext.hpp> +#include <comphelper/diagnose_ex.hxx> + +#include <algorithm> + +using namespace ::com::sun::star; + +using ::com::sun::star::uno::Reference; +using ::com::sun::star::uno::Sequence; +using ::com::sun::star::beans::Property; + +namespace +{ +enum +{ + PROP_CLUSTEREDCOLUMN_TEMPLATE_DIMENSION, + PROP_CLUSTEREDCOLUMN_TEMPLATE_GEOMETRY3D +}; + +void lcl_AddPropertiesToVector(std::vector<Property>& rOutProperties) +{ + rOutProperties.emplace_back( + "Dimension", PROP_CLUSTEREDCOLUMN_TEMPLATE_DIMENSION, cppu::UnoType<sal_Int32>::get(), + beans::PropertyAttribute::BOUND | beans::PropertyAttribute::MAYBEDEFAULT); + rOutProperties.emplace_back( + "Geometry3D", PROP_CLUSTEREDCOLUMN_TEMPLATE_GEOMETRY3D, cppu::UnoType<sal_Int32>::get(), + beans::PropertyAttribute::BOUND | beans::PropertyAttribute::MAYBEDEFAULT); +} + +::cppu::OPropertyArrayHelper& StaticClusteredColumnChartTypeTemplateInfoHelper() +{ + static ::cppu::OPropertyArrayHelper aPropHelper = []() { + std::vector<css::beans::Property> aProperties; + lcl_AddPropertiesToVector(aProperties); + + std::sort(aProperties.begin(), aProperties.end(), ::chart::PropertyNameLess()); + + return comphelper::containerToSequence(aProperties); + }(); + return aPropHelper; +}; + +} // anonymous namespace + +namespace chart +{ +ClusteredColumnChartTypeTemplate::ClusteredColumnChartTypeTemplate( + Reference<uno::XComponentContext> const& xContext, const OUString& rServiceName, + sal_Int32 nDim /* = 2 */) + : ChartTypeTemplate(xContext, rServiceName) + , m_nDim(nDim) +{ +} + +ClusteredColumnChartTypeTemplate::~ClusteredColumnChartTypeTemplate() {} + +sal_Int32 ClusteredColumnChartTypeTemplate::getDimension() const { return m_nDim; } + +// ____ ChartTypeTemplate ____ +bool ClusteredColumnChartTypeTemplate::matchesTemplate2( + const rtl::Reference<::chart::Diagram>& xDiagram, bool bAdaptProperties) +{ + bool bResult = ChartTypeTemplate::matchesTemplate2(xDiagram, bAdaptProperties); + + // adapt solid-type of template according to values in series + if (bAdaptProperties && bResult && getDimension() == 3) + { + bool bGeomFound = false, bGeomAmbiguous = false; + sal_Int32 aCommonGeom = xDiagram->getGeometry3D(bGeomFound, bGeomAmbiguous); + + if (!bGeomAmbiguous) + { + setFastPropertyValue_NoBroadcast(PROP_CLUSTEREDCOLUMN_TEMPLATE_GEOMETRY3D, + uno::Any(aCommonGeom)); + } + } + + return bResult; +} + +rtl::Reference<ChartType> + ClusteredColumnChartTypeTemplate::getChartTypeForIndex(sal_Int32 /*nChartTypeIndex*/) +{ + return new ClusteredColumnChartType(); +} + +rtl::Reference<ChartType> ClusteredColumnChartTypeTemplate::getChartTypeForNewSeries2( + const std::vector<rtl::Reference<ChartType>>& aFormerlyUsedChartTypes) +{ + rtl::Reference<ChartType> xResult(getChartTypeForIndex(0)); + ChartTypeTemplate::copyPropertiesFromOldToNewCoordinateSystem(aFormerlyUsedChartTypes, xResult); + return xResult; +} + +// ____ OPropertySet ____ +void ClusteredColumnChartTypeTemplate::GetDefaultValue(sal_Int32 nHandle, uno::Any& rAny) const +{ + static ::chart::tPropertyValueMap aStaticDefaults = []() { + ::chart::tPropertyValueMap aTmp; + ::chart::PropertyHelper::setPropertyValueDefault<sal_Int32>( + aTmp, PROP_CLUSTEREDCOLUMN_TEMPLATE_DIMENSION, 2); + ::chart::PropertyHelper::setPropertyValueDefault( + aTmp, PROP_CLUSTEREDCOLUMN_TEMPLATE_GEOMETRY3D, ::chart2::DataPointGeometry3D::CUBOID); + return aTmp; + }(); + tPropertyValueMap::const_iterator aFound(aStaticDefaults.find(nHandle)); + if (aFound == aStaticDefaults.end()) + rAny.clear(); + else + rAny = (*aFound).second; +} + +::cppu::IPropertyArrayHelper& SAL_CALL ClusteredColumnChartTypeTemplate::getInfoHelper() +{ + return StaticClusteredColumnChartTypeTemplateInfoHelper(); +} + +// ____ XPropertySet ____ +Reference<beans::XPropertySetInfo> SAL_CALL ClusteredColumnChartTypeTemplate::getPropertySetInfo() +{ + static uno::Reference<beans::XPropertySetInfo> xPropertySetInfo( + ::cppu::OPropertySetHelper::createPropertySetInfo( + StaticClusteredColumnChartTypeTemplateInfoHelper())); + return xPropertySetInfo; +} + +void ClusteredColumnChartTypeTemplate::applyStyle2(const rtl::Reference<DataSeries>& xSeries, + ::sal_Int32 nChartTypeIndex, + ::sal_Int32 nSeriesIndex, + ::sal_Int32 nSeriesCount) +{ + ChartTypeTemplate::applyStyle2(xSeries, nChartTypeIndex, nSeriesIndex, nSeriesCount); + xSeries->setPropertyAlsoToAllAttributedDataPoints("BorderStyle", + uno::Any(drawing::LineStyle_NONE)); + if (getDimension() != 3) + return; + + try + { + //apply Geometry3D + uno::Any aAGeometry3D; + getFastPropertyValue(aAGeometry3D, PROP_CLUSTEREDCOLUMN_TEMPLATE_GEOMETRY3D); + xSeries->setPropertyAlsoToAllAttributedDataPoints("Geometry3D", aAGeometry3D); + } + catch (const uno::Exception&) + { + DBG_UNHANDLED_EXCEPTION("chart2"); + } +} + +void ClusteredColumnChartTypeTemplate::resetStyles2( + const rtl::Reference<::chart::Diagram>& xDiagram) +{ + ChartTypeTemplate::resetStyles2(xDiagram); + std::vector<rtl::Reference<DataSeries>> aSeriesVec(xDiagram->getDataSeries()); + uno::Any aLineStyleAny(drawing::LineStyle_NONE); + for (auto const& series : aSeriesVec) + { + if (getDimension() == 3) + series->setPropertyToDefault("Geometry3D"); + if (series->getPropertyValue("BorderStyle") == aLineStyleAny) + { + series->setPropertyToDefault("BorderStyle"); + } + } + + xDiagram->setVertical(false); +} + +IMPLEMENT_FORWARD_XINTERFACE2(ClusteredColumnChartTypeTemplate, ChartTypeTemplate, OPropertySet) +IMPLEMENT_FORWARD_XTYPEPROVIDER2(ClusteredColumnChartTypeTemplate, ChartTypeTemplate, OPropertySet) + +} // namespace chart + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/model/template/ClusteredColumnChartTypeTemplate.hxx b/chart2/source/model/template/ClusteredColumnChartTypeTemplate.hxx new file mode 100644 index 000000000000..b56c0d01a54f --- /dev/null +++ b/chart2/source/model/template/ClusteredColumnChartTypeTemplate.hxx @@ -0,0 +1,62 @@ +/* -*- 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/. + */ +#pragma once + +#include <OPropertySet.hxx> +#include <comphelper/uno3.hxx> + +#include <ChartTypeTemplate.hxx> + +namespace chart +{ +class ClusteredColumnChartTypeTemplate : public ChartTypeTemplate, public ::property::OPropertySet +{ +public: + ClusteredColumnChartTypeTemplate( + css::uno::Reference<css::uno::XComponentContext> const& xContext, + const OUString& rServiceName, sal_Int32 nDim = 2); + virtual ~ClusteredColumnChartTypeTemplate() override; + + /// merge XInterface implementations + DECLARE_XINTERFACE() + /// merge XTypeProvider implementations + DECLARE_XTYPEPROVIDER() + +protected: + // ____ OPropertySet ____ + virtual void GetDefaultValue(sal_Int32 nHandle, css::uno::Any& rAny) const override; + virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper() override; + + // ____ XPropertySet ____ + virtual css::uno::Reference<css::beans::XPropertySetInfo> + SAL_CALL getPropertySetInfo() override; + + // ____ ChartTypeTemplate ____ + virtual bool matchesTemplate2(const rtl::Reference<::chart::Diagram>& xDiagram, + bool bAdaptProperties) override; + virtual rtl::Reference<::chart::ChartType> getChartTypeForNewSeries2( + const std::vector<rtl::Reference<::chart::ChartType>>& aFormerlyUsedChartTypes) override; + virtual void applyStyle2(const rtl::Reference<::chart::DataSeries>& xSeries, + ::sal_Int32 nChartTypeGroupIndex, ::sal_Int32 nSeriesIndex, + ::sal_Int32 nSeriesCount) override; + virtual void resetStyles2(const rtl::Reference<::chart::Diagram>& xDiagram) override; + + // ____ ChartTypeTemplate ____ + virtual sal_Int32 getDimension() const override; + + virtual rtl::Reference<::chart::ChartType> + getChartTypeForIndex(sal_Int32 nChartTypeIndex) override; + +private: + sal_Int32 m_nDim; +}; + +} // namespace chart + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/model/template/FunnelChartTypeTemplate.cxx b/chart2/source/model/template/FunnelChartTypeTemplate.cxx index 3e6d95b5be51..a262b8ab23bf 100644 --- a/chart2/source/model/template/FunnelChartTypeTemplate.cxx +++ b/chart2/source/model/template/FunnelChartTypeTemplate.cxx @@ -8,7 +8,7 @@ */ #include "FunnelChartTypeTemplate.hxx" -#include "ColumnChartType.hxx" +#include "FunnelChartType.hxx" #include <Diagram.hxx> #include <DataSeries.hxx> #include <DataSeriesHelper.hxx> @@ -99,7 +99,7 @@ bool FunnelChartTypeTemplate::matchesTemplate2(const rtl::Reference<::chart::Dia rtl::Reference<ChartType> FunnelChartTypeTemplate::getChartTypeForIndex(sal_Int32 /*nChartTypeIndex*/) { - return new ColumnChartType(); + return new FunnelChartType(); } rtl::Reference<ChartType> FunnelChartTypeTemplate::getChartTypeForNewSeries2( diff --git a/chart2/source/model/template/ParetoLineChartType.cxx b/chart2/source/model/template/ParetoLineChartType.cxx new file mode 100644 index 000000000000..8e9fa7a25af7 --- /dev/null +++ b/chart2/source/model/template/ParetoLineChartType.cxx @@ -0,0 +1,78 @@ +/* -*- 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 "ParetoLineChartType.hxx" +#include <servicenames_charttypes.hxx> +#include <cppuhelper/supportsservice.hxx> + +namespace com::sun::star::uno +{ +class XComponentContext; +} + +using namespace ::com::sun::star; + +namespace chart +{ +ParetoLineChartType::ParetoLineChartType() {} + +ParetoLineChartType::ParetoLineChartType(const ParetoLineChartType& rOther) + : ChartType(rOther) +{ +} + +ParetoLineChartType::~ParetoLineChartType() {} + +// ____ XCloneable ____ +uno::Reference<util::XCloneable> SAL_CALL ParetoLineChartType::createClone() +{ + return uno::Reference<util::XCloneable>(new ParetoLineChartType(*this)); +} + +rtl::Reference<ChartType> ParetoLineChartType::cloneChartType() const +{ + return new ParetoLineChartType(*this); +} + +// ____ XChartType ____ +OUString SAL_CALL ParetoLineChartType::getChartType() +{ + return CHART2_SERVICE_NAME_CHARTTYPE_PARETOLINE; +} + +uno::Sequence<OUString> ParetoLineChartType::getSupportedPropertyRoles() +{ + return { "FillColor", "BorderColor" }; +} + +OUString SAL_CALL ParetoLineChartType::getImplementationName() +{ + return "com.sun.star.comp.chart.ParetoLineChartType"; +} + +sal_Bool SAL_CALL ParetoLineChartType::supportsService(const OUString& rServiceName) +{ + return cppu::supportsService(this, rServiceName); +} + +css::uno::Sequence<OUString> SAL_CALL ParetoLineChartType::getSupportedServiceNames() +{ + return { CHART2_SERVICE_NAME_CHARTTYPE_PARETOLINE, "com.sun.star.chart2.ChartType" }; +} + +} // namespace chart + +extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface* +com_sun_star_comp_chart_ParetoLineChartType_get_implementation( + css::uno::XComponentContext* /*context*/, css::uno::Sequence<css::uno::Any> const&) +{ + return cppu::acquire(new ::chart::ParetoLineChartType); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/model/template/ParetoLineChartType.hxx b/chart2/source/model/template/ParetoLineChartType.hxx new file mode 100644 index 000000000000..0c84bc65f17f --- /dev/null +++ b/chart2/source/model/template/ParetoLineChartType.hxx @@ -0,0 +1,40 @@ +/* -*- 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/. + */ +#pragma once + +#include <ChartType.hxx> + +namespace chart +{ +class ParetoLineChartType final : public ChartType +{ +public: + explicit ParetoLineChartType(); + virtual ~ParetoLineChartType() override; + + virtual OUString SAL_CALL getImplementationName() override; + virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) override; + virtual css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override; + + virtual rtl::Reference<ChartType> cloneChartType() const override; + +private: + explicit ParetoLineChartType(const ParetoLineChartType& rOther); + + // ____ XChartType ____ + virtual OUString SAL_CALL getChartType() override; + virtual css::uno::Sequence<OUString> SAL_CALL getSupportedPropertyRoles() override; + + // ____ XCloneable ____ + virtual css::uno::Reference<css::util::XCloneable> SAL_CALL createClone() override; +}; + +} // namespace chart + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/model/template/ParetoLineChartTypeTemplate.cxx b/chart2/source/model/template/ParetoLineChartTypeTemplate.cxx new file mode 100644 index 000000000000..7612f29d327a --- /dev/null +++ b/chart2/source/model/template/ParetoLineChartTypeTemplate.cxx @@ -0,0 +1,191 @@ +/* -*- 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 "ParetoLineChartTypeTemplate.hxx" +#include "ParetoLineChartType.hxx" +#include <Diagram.hxx> +#include <DataSeries.hxx> +#include <DataSeriesHelper.hxx> +#include <PropertyHelper.hxx> +#include <com/sun/star/beans/PropertyAttribute.hpp> +#include <com/sun/star/drawing/LineStyle.hpp> +#include <com/sun/star/chart2/DataPointGeometry3D.hpp> +#include <com/sun/star/uno/XComponentContext.hpp> +#include <comphelper/diagnose_ex.hxx> + +#include <algorithm> + +using namespace ::com::sun::star; + +using ::com::sun::star::uno::Reference; +using ::com::sun::star::uno::Sequence; +using ::com::sun::star::beans::Property; + +namespace +{ +enum +{ + PROP_PARETOLINE_TEMPLATE_DIMENSION, + PROP_PARETOLINE_TEMPLATE_GEOMETRY3D +}; + +void lcl_AddPropertiesToVector(std::vector<Property>& rOutProperties) +{ + rOutProperties.emplace_back( + "Dimension", PROP_PARETOLINE_TEMPLATE_DIMENSION, cppu::UnoType<sal_Int32>::get(), + beans::PropertyAttribute::BOUND | beans::PropertyAttribute::MAYBEDEFAULT); + rOutProperties.emplace_back( + "Geometry3D", PROP_PARETOLINE_TEMPLATE_GEOMETRY3D, cppu::UnoType<sal_Int32>::get(), + beans::PropertyAttribute::BOUND | beans::PropertyAttribute::MAYBEDEFAULT); +} + +::cppu::OPropertyArrayHelper& StaticParetoLineChartTypeTemplateInfoHelper() +{ + static ::cppu::OPropertyArrayHelper aPropHelper = []() { + std::vector<css::beans::Property> aProperties; + lcl_AddPropertiesToVector(aProperties); + + std::sort(aProperties.begin(), aProperties.end(), ::chart::PropertyNameLess()); + + return comphelper::containerToSequence(aProperties); + }(); + return aPropHelper; +}; + +} // anonymous namespace + +namespace chart +{ +ParetoLineChartTypeTemplate::ParetoLineChartTypeTemplate( + Reference<uno::XComponentContext> const& xContext, const OUString& rServiceName, + sal_Int32 nDim /* = 2 */) + : ChartTypeTemplate(xContext, rServiceName) + , m_nDim(nDim) +{ +} + +ParetoLineChartTypeTemplate::~ParetoLineChartTypeTemplate() {} + +sal_Int32 ParetoLineChartTypeTemplate::getDimension() const { return m_nDim; } + +// ____ ChartTypeTemplate ____ +bool ParetoLineChartTypeTemplate::matchesTemplate2(const rtl::Reference<::chart::Diagram>& xDiagram, + bool bAdaptProperties) +{ + bool bResult = ChartTypeTemplate::matchesTemplate2(xDiagram, bAdaptProperties); + + // adapt solid-type of template according to values in series + if (bAdaptProperties && bResult && getDimension() == 3) + { + bool bGeomFound = false, bGeomAmbiguous = false; + sal_Int32 aCommonGeom = xDiagram->getGeometry3D(bGeomFound, bGeomAmbiguous); + + if (!bGeomAmbiguous) + { + setFastPropertyValue_NoBroadcast(PROP_PARETOLINE_TEMPLATE_GEOMETRY3D, + uno::Any(aCommonGeom)); + } + } + + return bResult; +} + +rtl::Reference<ChartType> + ParetoLineChartTypeTemplate::getChartTypeForIndex(sal_Int32 /*nChartTypeIndex*/) +{ + return new ParetoLineChartType(); +} + +rtl::Reference<ChartType> ParetoLineChartTypeTemplate::getChartTypeForNewSeries2( + const std::vector<rtl::Reference<ChartType>>& aFormerlyUsedChartTypes) +{ + rtl::Reference<ChartType> xResult(getChartTypeForIndex(0)); + ChartTypeTemplate::copyPropertiesFromOldToNewCoordinateSystem(aFormerlyUsedChartTypes, xResult); + return xResult; +} + +// ____ OPropertySet ____ +void ParetoLineChartTypeTemplate::GetDefaultValue(sal_Int32 nHandle, uno::Any& rAny) const +{ + static ::chart::tPropertyValueMap aStaticDefaults = []() { + ::chart::tPropertyValueMap aTmp; + ::chart::PropertyHelper::setPropertyValueDefault<sal_Int32>( + aTmp, PROP_PARETOLINE_TEMPLATE_DIMENSION, 2); + ::chart::PropertyHelper::setPropertyValueDefault(aTmp, PROP_PARETOLINE_TEMPLATE_GEOMETRY3D, + ::chart2::DataPointGeometry3D::CUBOID); + return aTmp; + }(); + tPropertyValueMap::const_iterator aFound(aStaticDefaults.find(nHandle)); + if (aFound == aStaticDefaults.end()) + rAny.clear(); + else + rAny = (*aFound).second; +} + +::cppu::IPropertyArrayHelper& SAL_CALL ParetoLineChartTypeTemplate::getInfoHelper() +{ + return StaticParetoLineChartTypeTemplateInfoHelper(); +} + +// ____ XPropertySet ____ +Reference<beans::XPropertySetInfo> SAL_CALL ParetoLineChartTypeTemplate::getPropertySetInfo() +{ + static uno::Reference<beans::XPropertySetInfo> xPropertySetInfo( + ::cppu::OPropertySetHelper::createPropertySetInfo( + StaticParetoLineChartTypeTemplateInfoHelper())); + return xPropertySetInfo; +} + +void ParetoLineChartTypeTemplate::applyStyle2(const rtl::Reference<DataSeries>& xSeries, + ::sal_Int32 nChartTypeIndex, ::sal_Int32 nSeriesIndex, + ::sal_Int32 nSeriesCount) +{ + ChartTypeTemplate::applyStyle2(xSeries, nChartTypeIndex, nSeriesIndex, nSeriesCount); + xSeries->setPropertyAlsoToAllAttributedDataPoints("BorderStyle", + uno::Any(drawing::LineStyle_NONE)); + if (getDimension() != 3) + return; + + try + { + //apply Geometry3D + uno::Any aAGeometry3D; + getFastPropertyValue(aAGeometry3D, PROP_PARETOLINE_TEMPLATE_GEOMETRY3D); + xSeries->setPropertyAlsoToAllAttributedDataPoints("Geometry3D", aAGeometry3D); + } + catch (const uno::Exception&) + { + DBG_UNHANDLED_EXCEPTION("chart2"); + } +} + +void ParetoLineChartTypeTemplate::resetStyles2(const rtl::Reference<::chart::Diagram>& xDiagram) +{ + ChartTypeTemplate::resetStyles2(xDiagram); + std::vector<rtl::Reference<DataSeries>> aSeriesVec(xDiagram->getDataSeries()); + uno::Any aLineStyleAny(drawing::LineStyle_NONE); + for (auto const& series : aSeriesVec) + { + if (getDimension() == 3) + series->setPropertyToDefault("Geometry3D"); + if (series->getPropertyValue("BorderStyle") == aLineStyleAny) + { + series->setPropertyToDefault("BorderStyle"); + } + } + + xDiagram->setVertical(false); +} + +IMPLEMENT_FORWARD_XINTERFACE2(ParetoLineChartTypeTemplate, ChartTypeTemplate, OPropertySet) +IMPLEMENT_FORWARD_XTYPEPROVIDER2(ParetoLineChartTypeTemplate, ChartTypeTemplate, OPropertySet) + +} // namespace chart + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/model/template/ParetoLineChartTypeTemplate.hxx b/chart2/source/model/template/ParetoLineChartTypeTemplate.hxx new file mode 100644 index 000000000000..aa095f567cea --- /dev/null +++ b/chart2/source/model/template/ParetoLineChartTypeTemplate.hxx @@ -0,0 +1,61 @@ +/* -*- 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/. + */ +#pragma once + +#include <OPropertySet.hxx> +#include <comphelper/uno3.hxx> + +#include <ChartTypeTemplate.hxx> + +namespace chart +{ +class ParetoLineChartTypeTemplate : public ChartTypeTemplate, public ::property::OPropertySet +{ +public: + ParetoLineChartTypeTemplate(css::uno::Reference<css::uno::XComponentContext> const& xContext, + const OUString& rServiceName, sal_Int32 nDim = 2); + virtual ~ParetoLineChartTypeTemplate() override; + + /// merge XInterface implementations + DECLARE_XINTERFACE() + /// merge XTypeProvider implementations + DECLARE_XTYPEPROVIDER() + +protected: + // ____ OPropertySet ____ + virtual void GetDefaultValue(sal_Int32 nHandle, css::uno::Any& rAny) const override; + virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper() override; + + // ____ XPropertySet ____ + virtual css::uno::Reference<css::beans::XPropertySetInfo> + SAL_CALL getPropertySetInfo() override; + + // ____ ChartTypeTemplate ____ + virtual bool matchesTemplate2(const rtl::Reference<::chart::Diagram>& xDiagram, + bool bAdaptProperties) override; + virtual rtl::Reference<::chart::ChartType> getChartTypeForNewSeries2( + const std::vector<rtl::Reference<::chart::ChartType>>& aFormerlyUsedChartTypes) override; + virtual void applyStyle2(const rtl::Reference<::chart::DataSeries>& xSeries, + ::sal_Int32 nChartTypeGroupIndex, ::sal_Int32 nSeriesIndex, + ::sal_Int32 nSeriesCount) override; + virtual void resetStyles2(const rtl::Reference<::chart::Diagram>& xDiagram) override; + + // ____ ChartTypeTemplate ____ + virtual sal_Int32 getDimension() const override; + + virtual rtl::Reference<::chart::ChartType> + getChartTypeForIndex(sal_Int32 nChartTypeIndex) override; + +private: + sal_Int32 m_nDim; +}; + +} // namespace chart + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/model/template/RegionMapChartType.cxx b/chart2/source/model/template/RegionMapChartType.cxx new file mode 100644 index 000000000000..594735302181 --- /dev/null +++ b/chart2/source/model/template/RegionMapChartType.cxx @@ -0,0 +1,78 @@ +/* -*- 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 "RegionMapChartType.hxx" +#include <servicenames_charttypes.hxx> +#include <cppuhelper/supportsservice.hxx> + +namespace com::sun::star::uno +{ +class XComponentContext; +} + +using namespace ::com::sun::star; + +namespace chart +{ +RegionMapChartType::RegionMapChartType() {} + +RegionMapChartType::RegionMapChartType(const RegionMapChartType& rOther) + : ChartType(rOther) +{ +} + +RegionMapChartType::~RegionMapChartType() {} + +// ____ XCloneable ____ +uno::Reference<util::XCloneable> SAL_CALL RegionMapChartType::createClone() +{ + return uno::Reference<util::XCloneable>(new RegionMapChartType(*this)); +} + +rtl::Reference<ChartType> RegionMapChartType::cloneChartType() const +{ + return new RegionMapChartType(*this); +} + +// ____ XChartType ____ +OUString SAL_CALL RegionMapChartType::getChartType() +{ + return CHART2_SERVICE_NAME_CHARTTYPE_REGIONMAP; +} + +uno::Sequence<OUString> RegionMapChartType::getSupportedPropertyRoles() +{ + return { "FillColor", "BorderColor" }; +} + +OUString SAL_CALL RegionMapChartType::getImplementationName() +{ + return "com.sun.star.comp.chart.RegionMapChartType"; +} + +sal_Bool SAL_CALL RegionMapChartType::supportsService(const OUString& rServiceName) +{ + return cppu::supportsService(this, rServiceName); +} + +css::uno::Sequence<OUString> SAL_CALL RegionMapChartType::getSupportedServiceNames() +{ + return { CHART2_SERVICE_NAME_CHARTTYPE_REGIONMAP, "com.sun.star.chart2.ChartType" }; +} + +} // namespace chart + +extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface* +com_sun_star_comp_chart_RegionMapChartType_get_implementation( + css::uno::XComponentContext* /*context*/, css::uno::Sequence<css::uno::Any> const&) +{ + return cppu::acquire(new ::chart::RegionMapChartType); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/model/template/RegionMapChartType.hxx b/chart2/source/model/template/RegionMapChartType.hxx new file mode 100644 index 000000000000..c02c70988b17 --- /dev/null +++ b/chart2/source/model/template/RegionMapChartType.hxx @@ -0,0 +1,40 @@ +/* -*- 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/. + */ +#pragma once + +#include <ChartType.hxx> + +namespace chart +{ +class RegionMapChartType final : public ChartType +{ +public: + explicit RegionMapChartType(); + virtual ~RegionMapChartType() override; + + virtual OUString SAL_CALL getImplementationName() override; + virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) override; + virtual css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override; + + virtual rtl::Reference<ChartType> cloneChartType() const override; + +private: + explicit RegionMapChartType(const RegionMapChartType& rOther); + + // ____ XChartType ____ + virtual OUString SAL_CALL getChartType() override; + virtual css::uno::Sequence<OUString> SAL_CALL getSupportedPropertyRoles() override; + + // ____ XCloneable ____ + virtual css::uno::Reference<css::util::XCloneable> SAL_CALL createClone() override; +}; + +} // namespace chart + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/model/template/RegionMapChartTypeTemplate.cxx b/chart2/source/model/template/RegionMapChartTypeTemplate.cxx new file mode 100644 index 000000000000..ed4c6df444fe --- /dev/null +++ b/chart2/source/model/template/RegionMapChartTypeTemplate.cxx @@ -0,0 +1,191 @@ +/* -*- 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 "RegionMapChartTypeTemplate.hxx" +#include "RegionMapChartType.hxx" +#include <Diagram.hxx> +#include <DataSeries.hxx> +#include <DataSeriesHelper.hxx> +#include <PropertyHelper.hxx> +#include <com/sun/star/beans/PropertyAttribute.hpp> +#include <com/sun/star/drawing/LineStyle.hpp> +#include <com/sun/star/chart2/DataPointGeometry3D.hpp> +#include <com/sun/star/uno/XComponentContext.hpp> +#include <comphelper/diagnose_ex.hxx> + +#include <algorithm> + +using namespace ::com::sun::star; + +using ::com::sun::star::uno::Reference; +using ::com::sun::star::uno::Sequence; +using ::com::sun::star::beans::Property; + +namespace +{ +enum +{ + PROP_REGIONMAP_TEMPLATE_DIMENSION, + PROP_REGIONMAP_TEMPLATE_GEOMETRY3D +}; + +void lcl_AddPropertiesToVector(std::vector<Property>& rOutProperties) +{ + rOutProperties.emplace_back( + "Dimension", PROP_REGIONMAP_TEMPLATE_DIMENSION, cppu::UnoType<sal_Int32>::get(), + beans::PropertyAttribute::BOUND | beans::PropertyAttribute::MAYBEDEFAULT); + rOutProperties.emplace_back( + "Geometry3D", PROP_REGIONMAP_TEMPLATE_GEOMETRY3D, cppu::UnoType<sal_Int32>::get(), + beans::PropertyAttribute::BOUND | beans::PropertyAttribute::MAYBEDEFAULT); +} + +::cppu::OPropertyArrayHelper& StaticRegionMapChartTypeTemplateInfoHelper() +{ + static ::cppu::OPropertyArrayHelper aPropHelper = []() { + std::vector<css::beans::Property> aProperties; + lcl_AddPropertiesToVector(aProperties); + + std::sort(aProperties.begin(), aProperties.end(), ::chart::PropertyNameLess()); + + return comphelper::containerToSequence(aProperties); + }(); + return aPropHelper; +}; + +} // anonymous namespace + +namespace chart +{ +RegionMapChartTypeTemplate::RegionMapChartTypeTemplate( + Reference<uno::XComponentContext> const& xContext, const OUString& rServiceName, + sal_Int32 nDim /* = 2 */) + : ChartTypeTemplate(xContext, rServiceName) + , m_nDim(nDim) +{ +} + +RegionMapChartTypeTemplate::~RegionMapChartTypeTemplate() {} + +sal_Int32 RegionMapChartTypeTemplate::getDimension() const { return m_nDim; } + +// ____ ChartTypeTemplate ____ +bool RegionMapChartTypeTemplate::matchesTemplate2(const rtl::Reference<::chart::Diagram>& xDiagram, + bool bAdaptProperties) +{ + bool bResult = ChartTypeTemplate::matchesTemplate2(xDiagram, bAdaptProperties); + + // adapt solid-type of template according to values in series + if (bAdaptProperties && bResult && getDimension() == 3) + { + bool bGeomFound = false, bGeomAmbiguous = false; + sal_Int32 aCommonGeom = xDiagram->getGeometry3D(bGeomFound, bGeomAmbiguous); + + if (!bGeomAmbiguous) + { + setFastPropertyValue_NoBroadcast(PROP_REGIONMAP_TEMPLATE_GEOMETRY3D, + uno::Any(aCommonGeom)); + } + } + + return bResult; +} + +rtl::Reference<ChartType> + RegionMapChartTypeTemplate::getChartTypeForIndex(sal_Int32 /*nChartTypeIndex*/) +{ + return new RegionMapChartType(); +} + +rtl::Reference<ChartType> RegionMapChartTypeTemplate::getChartTypeForNewSeries2( + const std::vector<rtl::Reference<ChartType>>& aFormerlyUsedChartTypes) +{ + rtl::Reference<ChartType> xResult(getChartTypeForIndex(0)); + ChartTypeTemplate::copyPropertiesFromOldToNewCoordinateSystem(aFormerlyUsedChartTypes, xResult); + return xResult; +} + +// ____ OPropertySet ____ +void RegionMapChartTypeTemplate::GetDefaultValue(sal_Int32 nHandle, uno::Any& rAny) const +{ + static ::chart::tPropertyValueMap aStaticDefaults = []() { + ::chart::tPropertyValueMap aTmp; + ::chart::PropertyHelper::setPropertyValueDefault<sal_Int32>( + aTmp, PROP_REGIONMAP_TEMPLATE_DIMENSION, 2); + ::chart::PropertyHelper::setPropertyValueDefault(aTmp, PROP_REGIONMAP_TEMPLATE_GEOMETRY3D, + ::chart2::DataPointGeometry3D::CUBOID); + return aTmp; + }(); + tPropertyValueMap::const_iterator aFound(aStaticDefaults.find(nHandle)); + if (aFound == aStaticDefaults.end()) + rAny.clear(); + else + rAny = (*aFound).second; +} + +::cppu::IPropertyArrayHelper& SAL_CALL RegionMapChartTypeTemplate::getInfoHelper() +{ + return StaticRegionMapChartTypeTemplateInfoHelper(); +} + +// ____ XPropertySet ____ +Reference<beans::XPropertySetInfo> SAL_CALL RegionMapChartTypeTemplate::getPropertySetInfo() +{ + static uno::Reference<beans::XPropertySetInfo> xPropertySetInfo( + ::cppu::OPropertySetHelper::createPropertySetInfo( + StaticRegionMapChartTypeTemplateInfoHelper())); + return xPropertySetInfo; +} + +void RegionMapChartTypeTemplate::applyStyle2(const rtl::Reference<DataSeries>& xSeries, + ::sal_Int32 nChartTypeIndex, ::sal_Int32 nSeriesIndex, + ::sal_Int32 nSeriesCount) +{ + ChartTypeTemplate::applyStyle2(xSeries, nChartTypeIndex, nSeriesIndex, nSeriesCount); + xSeries->setPropertyAlsoToAllAttributedDataPoints("BorderStyle", + uno::Any(drawing::LineStyle_NONE)); + if (getDimension() != 3) + return; + + try + { + //apply Geometry3D + uno::Any aAGeometry3D; + getFastPropertyValue(aAGeometry3D, PROP_REGIONMAP_TEMPLATE_GEOMETRY3D); + xSeries->setPropertyAlsoToAllAttributedDataPoints("Geometry3D", aAGeometry3D); + } + catch (const uno::Exception&) + { + DBG_UNHANDLED_EXCEPTION("chart2"); + } +} + +void RegionMapChartTypeTemplate::resetStyles2(const rtl::Reference<::chart::Diagram>& xDiagram) +{ + ChartTypeTemplate::resetStyles2(xDiagram); + std::vector<rtl::Reference<DataSeries>> aSeriesVec(xDiagram->getDataSeries()); + uno::Any aLineStyleAny(drawing::LineStyle_NONE); + for (auto const& series : aSeriesVec) + { + if (getDimension() == 3) + series->setPropertyToDefault("Geometry3D"); + if (series->getPropertyValue("BorderStyle") == aLineStyleAny) + { + series->setPropertyToDefault("BorderStyle"); + } + } + + xDiagram->setVertical(false); +} + +IMPLEMENT_FORWARD_XINTERFACE2(RegionMapChartTypeTemplate, ChartTypeTemplate, OPropertySet) +IMPLEMENT_FORWARD_XTYPEPROVIDER2(RegionMapChartTypeTemplate, ChartTypeTemplate, OPropertySet) + +} // namespace chart + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/model/template/RegionMapChartTypeTemplate.hxx b/chart2/source/model/template/RegionMapChartTypeTemplate.hxx new file mode 100644 index 000000000000..ad2266a6568b --- /dev/null +++ b/chart2/source/model/template/RegionMapChartTypeTemplate.hxx @@ -0,0 +1,61 @@ +/* -*- 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/. + */ +#pragma once + +#include <OPropertySet.hxx> +#include <comphelper/uno3.hxx> + +#include <ChartTypeTemplate.hxx> + +namespace chart +{ +class RegionMapChartTypeTemplate : public ChartTypeTemplate, public ::property::OPropertySet +{ +public: + RegionMapChartTypeTemplate(css::uno::Reference<css::uno::XComponentContext> const& xContext, + const OUString& rServiceName, sal_Int32 nDim = 2); + virtual ~RegionMapChartTypeTemplate() override; + + /// merge XInterface implementations + DECLARE_XINTERFACE() + /// merge XTypeProvider implementations + DECLARE_XTYPEPROVIDER() + +protected: + // ____ OPropertySet ____ + virtual void GetDefaultValue(sal_Int32 nHandle, css::uno::Any& rAny) const override; + virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper() override; + + // ____ XPropertySet ____ + virtual css::uno::Reference<css::beans::XPropertySetInfo> + SAL_CALL getPropertySetInfo() override; + + // ____ ChartTypeTemplate ____ + virtual bool matchesTemplate2(const rtl::Reference<::chart::Diagram>& xDiagram, + bool bAdaptProperties) override; + virtual rtl::Reference<::chart::ChartType> getChartTypeForNewSeries2( + const std::vector<rtl::Reference<::chart::ChartType>>& aFormerlyUsedChartTypes) override; + virtual void applyStyle2(const rtl::Reference<::chart::DataSeries>& xSeries, + ::sal_Int32 nChartTypeGroupIndex, ::sal_Int32 nSeriesIndex, + ::sal_Int32 nSeriesCount) override; + virtual void resetStyles2(const rtl::Reference<::chart::Diagram>& xDiagram) override; + + // ____ ChartTypeTemplate ____ + virtual sal_Int32 getDimension() const override; + + virtual rtl::Reference<::chart::ChartType> + getChartTypeForIndex(sal_Int32 nChartTypeIndex) override; + +private: + sal_Int32 m_nDim; +}; + +} // namespace chart + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/model/template/SunburstChartType.cxx b/chart2/source/model/template/SunburstChartType.cxx new file mode 100644 index 000000000000..c157134a0820 --- /dev/null +++ b/chart2/source/model/template/SunburstChartType.cxx @@ -0,0 +1,78 @@ +/* -*- 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 "SunburstChartType.hxx" +#include <servicenames_charttypes.hxx> +#include <cppuhelper/supportsservice.hxx> + +namespace com::sun::star::uno +{ +class XComponentContext; +} + +using namespace ::com::sun::star; + +namespace chart +{ +SunburstChartType::SunburstChartType() {} + +SunburstChartType::SunburstChartType(const SunburstChartType& rOther) + : ChartType(rOther) +{ +} + +SunburstChartType::~SunburstChartType() {} + +// ____ XCloneable ____ +uno::Reference<util::XCloneable> SAL_CALL SunburstChartType::createClone() +{ + return uno::Reference<util::XCloneable>(new SunburstChartType(*this)); +} + +rtl::Reference<ChartType> SunburstChartType::cloneChartType() const +{ + return new SunburstChartType(*this); +} + +// ____ XChartType ____ +OUString SAL_CALL SunburstChartType::getChartType() +{ + return CHART2_SERVICE_NAME_CHARTTYPE_SUNBURST; +} + +uno::Sequence<OUString> SunburstChartType::getSupportedPropertyRoles() +{ + return { "FillColor", "BorderColor" }; +} + +OUString SAL_CALL SunburstChartType::getImplementationName() +{ + return "com.sun.star.comp.chart.SunburstChartType"; +} + +sal_Bool SAL_CALL SunburstChartType::supportsService(const OUString& rServiceName) +{ + return cppu::supportsService(this, rServiceName); +} + +css::uno::Sequence<OUString> SAL_CALL SunburstChartType::getSupportedServiceNames() +{ + return { CHART2_SERVICE_NAME_CHARTTYPE_SUNBURST, "com.sun.star.chart2.ChartType" }; +} + +} // namespace chart + +extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface* +com_sun_star_comp_chart_SunburstChartType_get_implementation( + css::uno::XComponentContext* /*context*/, css::uno::Sequence<css::uno::Any> const&) +{ + return cppu::acquire(new ::chart::SunburstChartType); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/model/template/SunburstChartType.hxx b/chart2/source/model/template/SunburstChartType.hxx new file mode 100644 index 000000000000..c6b9736fe08c --- /dev/null +++ b/chart2/source/model/template/SunburstChartType.hxx @@ -0,0 +1,40 @@ +/* -*- 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/. + */ +#pragma once + +#include <ChartType.hxx> + +namespace chart +{ +class SunburstChartType final : public ChartType +{ +public: + explicit SunburstChartType(); + virtual ~SunburstChartType() override; + + virtual OUString SAL_CALL getImplementationName() override; + virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) override; + virtual css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override; + + virtual rtl::Reference<ChartType> cloneChartType() const override; + +private: + explicit SunburstChartType(const SunburstChartType& rOther); + + // ____ XChartType ____ + virtual OUString SAL_CALL getChartType() override; + virtual css::uno::Sequence<OUString> SAL_CALL getSupportedPropertyRoles() override; + + // ____ XCloneable ____ + virtual css::uno::Reference<css::util::XCloneable> SAL_CALL createClone() override; +}; + +} // namespace chart + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/model/template/SunburstChartTypeTemplate.cxx b/chart2/source/model/template/SunburstChartTypeTemplate.cxx new file mode 100644 index 000000000000..011202997e4c --- /dev/null +++ b/chart2/source/model/template/SunburstChartTypeTemplate.cxx @@ -0,0 +1,191 @@ +/* -*- 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 "SunburstChartTypeTemplate.hxx" +#include "SunburstChartType.hxx" +#include <Diagram.hxx> +#include <DataSeries.hxx> +#include <DataSeriesHelper.hxx> +#include <PropertyHelper.hxx> +#include <com/sun/star/beans/PropertyAttribute.hpp> +#include <com/sun/star/drawing/LineStyle.hpp> +#include <com/sun/star/chart2/DataPointGeometry3D.hpp> +#include <com/sun/star/uno/XComponentContext.hpp> +#include <comphelper/diagnose_ex.hxx> + +#include <algorithm> + +using namespace ::com::sun::star; + +using ::com::sun::star::uno::Reference; +using ::com::sun::star::uno::Sequence; +using ::com::sun::star::beans::Property; + +namespace +{ +enum +{ + PROP_SUNBURST_TEMPLATE_DIMENSION, + PROP_SUNBURST_TEMPLATE_GEOMETRY3D +}; + +void lcl_AddPropertiesToVector(std::vector<Property>& rOutProperties) +{ + rOutProperties.emplace_back( + "Dimension", PROP_SUNBURST_TEMPLATE_DIMENSION, cppu::UnoType<sal_Int32>::get(), + beans::PropertyAttribute::BOUND | beans::PropertyAttribute::MAYBEDEFAULT); + rOutProperties.emplace_back( + "Geometry3D", PROP_SUNBURST_TEMPLATE_GEOMETRY3D, cppu::UnoType<sal_Int32>::get(), + beans::PropertyAttribute::BOUND | beans::PropertyAttribute::MAYBEDEFAULT); +} + +::cppu::OPropertyArrayHelper& StaticSunburstChartTypeTemplateInfoHelper() +{ + static ::cppu::OPropertyArrayHelper aPropHelper = []() { + std::vector<css::beans::Property> aProperties; + lcl_AddPropertiesToVector(aProperties); + + std::sort(aProperties.begin(), aProperties.end(), ::chart::PropertyNameLess()); + + return comphelper::containerToSequence(aProperties); + }(); + return aPropHelper; +}; + +} // anonymous namespace + +namespace chart +{ +SunburstChartTypeTemplate::SunburstChartTypeTemplate( + Reference<uno::XComponentContext> const& xContext, const OUString& rServiceName, + sal_Int32 nDim /* = 2 */) + : ChartTypeTemplate(xContext, rServiceName) + , m_nDim(nDim) +{ +} + +SunburstChartTypeTemplate::~SunburstChartTypeTemplate() {} + +sal_Int32 SunburstChartTypeTemplate::getDimension() const { return m_nDim; } + +// ____ ChartTypeTemplate ____ +bool SunburstChartTypeTemplate::matchesTemplate2(const rtl::Reference<::chart::Diagram>& xDiagram, + bool bAdaptProperties) +{ + bool bResult = ChartTypeTemplate::matchesTemplate2(xDiagram, bAdaptProperties); + + // adapt solid-type of template according to values in series + if (bAdaptProperties && bResult && getDimension() == 3) + { + bool bGeomFound = false, bGeomAmbiguous = false; + sal_Int32 aCommonGeom = xDiagram->getGeometry3D(bGeomFound, bGeomAmbiguous); + + if (!bGeomAmbiguous) + { + setFastPropertyValue_NoBroadcast(PROP_SUNBURST_TEMPLATE_GEOMETRY3D, + uno::Any(aCommonGeom)); + } + } + + return bResult; +} + +rtl::Reference<ChartType> + SunburstChartTypeTemplate::getChartTypeForIndex(sal_Int32 /*nChartTypeIndex*/) +{ + return new SunburstChartType(); +} + +rtl::Reference<ChartType> SunburstChartTypeTemplate::getChartTypeForNewSeries2( + const std::vector<rtl::Reference<ChartType>>& aFormerlyUsedChartTypes) +{ + rtl::Reference<ChartType> xResult(getChartTypeForIndex(0)); + ChartTypeTemplate::copyPropertiesFromOldToNewCoordinateSystem(aFormerlyUsedChartTypes, xResult); + return xResult; +} + +// ____ OPropertySet ____ +void SunburstChartTypeTemplate::GetDefaultValue(sal_Int32 nHandle, uno::Any& rAny) const +{ + static ::chart::tPropertyValueMap aStaticDefaults = []() { + ::chart::tPropertyValueMap aTmp; + ::chart::PropertyHelper::setPropertyValueDefault<sal_Int32>( + aTmp, PROP_SUNBURST_TEMPLATE_DIMENSION, 2); + ::chart::PropertyHelper::setPropertyValueDefault(aTmp, PROP_SUNBURST_TEMPLATE_GEOMETRY3D, + ::chart2::DataPointGeometry3D::CUBOID); + return aTmp; + }(); + tPropertyValueMap::const_iterator aFound(aStaticDefaults.find(nHandle)); + if (aFound == aStaticDefaults.end()) + rAny.clear(); + else + rAny = (*aFound).second; +} + +::cppu::IPropertyArrayHelper& SAL_CALL SunburstChartTypeTemplate::getInfoHelper() +{ + return StaticSunburstChartTypeTemplateInfoHelper(); +} + +// ____ XPropertySet ____ +Reference<beans::XPropertySetInfo> SAL_CALL SunburstChartTypeTemplate::getPropertySetInfo() +{ + static uno::Reference<beans::XPropertySetInfo> xPropertySetInfo( + ::cppu::OPropertySetHelper::createPropertySetInfo( + StaticSunburstChartTypeTemplateInfoHelper())); + return xPropertySetInfo; +} + +void SunburstChartTypeTemplate::applyStyle2(const rtl::Reference<DataSeries>& xSeries, + ::sal_Int32 nChartTypeIndex, ::sal_Int32 nSeriesIndex, + ::sal_Int32 nSeriesCount) +{ + ChartTypeTemplate::applyStyle2(xSeries, nChartTypeIndex, nSeriesIndex, nSeriesCount); + xSeries->setPropertyAlsoToAllAttributedDataPoints("BorderStyle", + uno::Any(drawing::LineStyle_NONE)); + if (getDimension() != 3) + return; + + try + { + //apply Geometry3D + uno::Any aAGeometry3D; + getFastPropertyValue(aAGeometry3D, PROP_SUNBURST_TEMPLATE_GEOMETRY3D); + xSeries->setPropertyAlsoToAllAttributedDataPoints("Geometry3D", aAGeometry3D); + } + catch (const uno::Exception&) + { + DBG_UNHANDLED_EXCEPTION("chart2"); + } +} + +void SunburstChartTypeTemplate::resetStyles2(const rtl::Reference<::chart::Diagram>& xDiagram) +{ + ChartTypeTemplate::resetStyles2(xDiagram); + std::vector<rtl::Reference<DataSeries>> aSeriesVec(xDiagram->getDataSeries()); + uno::Any aLineStyleAny(drawing::LineStyle_NONE); + for (auto const& series : aSeriesVec) + { + if (getDimension() == 3) + series->setPropertyToDefault("Geometry3D"); + if (series->getPropertyValue("BorderStyle") == aLineStyleAny) + { + series->setPropertyToDefault("BorderStyle"); + } + } + + xDiagram->setVertical(false); +} + +IMPLEMENT_FORWARD_XINTERFACE2(SunburstChartTypeTemplate, ChartTypeTemplate, OPropertySet) +IMPLEMENT_FORWARD_XTYPEPROVIDER2(SunburstChartTypeTemplate, ChartTypeTemplate, OPropertySet) + +} // namespace chart + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/model/template/SunburstChartTypeTemplate.hxx b/chart2/source/model/template/SunburstChartTypeTemplate.hxx new file mode 100644 index 000000000000..fb8975b3f188 --- /dev/null +++ b/chart2/source/model/template/SunburstChartTypeTemplate.hxx @@ -0,0 +1,61 @@ +/* -*- 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/. + */ +#pragma once + +#include <OPropertySet.hxx> +#include <comphelper/uno3.hxx> + +#include <ChartTypeTemplate.hxx> + +namespace chart +{ +class SunburstChartTypeTemplate : public ChartTypeTemplate, public ::property::OPropertySet +{ +public: + SunburstChartTypeTemplate(css::uno::Reference<css::uno::XComponentContext> const& xContext, + const OUString& rServiceName, sal_Int32 nDim = 2); + virtual ~SunburstChartTypeTemplate() override; + + /// merge XInterface implementations + DECLARE_XINTERFACE() + /// merge XTypeProvider implementations + DECLARE_XTYPEPROVIDER() + +protected: + // ____ OPropertySet ____ + virtual void GetDefaultValue(sal_Int32 nHandle, css::uno::Any& rAny) const override; + virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper() override; + + // ____ XPropertySet ____ + virtual css::uno::Reference<css::beans::XPropertySetInfo> + SAL_CALL getPropertySetInfo() override; + + // ____ ChartTypeTemplate ____ + virtual bool matchesTemplate2(const rtl::Reference<::chart::Diagram>& xDiagram, + bool bAdaptProperties) override; + virtual rtl::Reference<::chart::ChartType> getChartTypeForNewSeries2( + const std::vector<rtl::Reference<::chart::ChartType>>& aFormerlyUsedChartTypes) override; + virtual void applyStyle2(const rtl::Reference<::chart::DataSeries>& xSeries, + ::sal_Int32 nChartTypeGroupIndex, ::sal_Int32 nSeriesIndex, + ::sal_Int32 nSeriesCount) override; + virtual void resetStyles2(const rtl::Reference<::chart::Diagram>& xDiagram) override; + + // ____ ChartTypeTemplate ____ + virtual sal_Int32 getDimension() const override; + + virtual rtl::Reference<::chart::ChartType> + getChartTypeForIndex(sal_Int32 nChartTypeIndex) override; + +private: + sal_Int32 m_nDim; +}; + +} // namespace chart + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/model/template/TreemapChartType.cxx b/chart2/source/model/template/TreemapChartType.cxx new file mode 100644 index 000000000000..3059ac9ef45a --- /dev/null +++ b/chart2/source/model/template/TreemapChartType.cxx @@ -0,0 +1,75 @@ +/* -*- 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 "TreemapChartType.hxx" +#include <servicenames_charttypes.hxx> +#include <cppuhelper/supportsservice.hxx> + +namespace com::sun::star::uno +{ +class XComponentContext; +} + +using namespace ::com::sun::star; + +namespace chart +{ +TreemapChartType::TreemapChartType() {} + +TreemapChartType::TreemapChartType(const TreemapChartType& rOther) + : ChartType(rOther) +{ +} + +TreemapChartType::~TreemapChartType() {} + +// ____ XCloneable ____ +uno::Reference<util::XCloneable> SAL_CALL TreemapChartType::createClone() +{ + return uno::Reference<util::XCloneable>(new TreemapChartType(*this)); +} + +rtl::Reference<ChartType> TreemapChartType::cloneChartType() const +{ + return new TreemapChartType(*this); +} + +// ____ XChartType ____ +OUString SAL_CALL TreemapChartType::getChartType() { return CHART2_SERVICE_NAME_CHARTTYPE_TREEMAP; } + +uno::Sequence<OUString> TreemapChartType::getSupportedPropertyRoles() +{ + return { "FillColor", "BorderColor" }; +} + +OUString SAL_CALL TreemapChartType::getImplementationName() +{ + return "com.sun.star.comp.chart.TreemapChartType"; +} + +sal_Bool SAL_CALL TreemapChartType::supportsService(const OUString& rServiceName) +{ + return cppu::supportsService(this, rServiceName); +} + +css::uno::Sequence<OUString> SAL_CALL TreemapChartType::getSupportedServiceNames() +{ + return { CHART2_SERVICE_NAME_CHARTTYPE_TREEMAP, "com.sun.star.chart2.ChartType" }; +} + +} // namespace chart + +extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface* +com_sun_star_comp_chart_TreemapChartType_get_implementation( + css::uno::XComponentContext* /*context*/, css::uno::Sequence<css::uno::Any> const&) +{ + return cppu::acquire(new ::chart::TreemapChartType); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/model/template/TreemapChartType.hxx b/chart2/source/model/template/TreemapChartType.hxx new file mode 100644 index 000000000000..334c534e1fd6 --- /dev/null +++ b/chart2/source/model/template/TreemapChartType.hxx @@ -0,0 +1,40 @@ +/* -*- 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/. + */ +#pragma once + +#include <ChartType.hxx> + +namespace chart +{ +class TreemapChartType final : public ChartType +{ +public: + explicit TreemapChartType(); + virtual ~TreemapChartType() override; + + virtual OUString SAL_CALL getImplementationName() override; + virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) override; + virtual css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override; + + virtual rtl::Reference<ChartType> cloneChartType() const override; + +private: + explicit TreemapChartType(const TreemapChartType& rOther); + + // ____ XChartType ____ + virtual OUString SAL_CALL getChartType() override; + virtual css::uno::Sequence<OUString> SAL_CALL getSupportedPropertyRoles() override; + + // ____ XCloneable ____ + virtual css::uno::Reference<css::util::XCloneable> SAL_CALL createClone() override; +}; + +} // namespace chart + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/model/template/TreemapChartTypeTemplate.cxx b/chart2/source/model/template/TreemapChartTypeTemplate.cxx new file mode 100644 index 000000000000..f4b444c4f455 --- /dev/null +++ b/chart2/source/model/template/TreemapChartTypeTemplate.cxx @@ -0,0 +1,191 @@ +/* -*- 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 "TreemapChartTypeTemplate.hxx" +#include "TreemapChartType.hxx" +#include <Diagram.hxx> +#include <DataSeries.hxx> +#include <DataSeriesHelper.hxx> +#include <PropertyHelper.hxx> +#include <com/sun/star/beans/PropertyAttribute.hpp> +#include <com/sun/star/drawing/LineStyle.hpp> +#include <com/sun/star/chart2/DataPointGeometry3D.hpp> +#include <com/sun/star/uno/XComponentContext.hpp> +#include <comphelper/diagnose_ex.hxx> + +#include <algorithm> + +using namespace ::com::sun::star; + +using ::com::sun::star::uno::Reference; +using ::com::sun::star::uno::Sequence; +using ::com::sun::star::beans::Property; + +namespace +{ +enum +{ + PROP_TREEMAP_TEMPLATE_DIMENSION, + PROP_TREEMAP_TEMPLATE_GEOMETRY3D +}; + +void lcl_AddPropertiesToVector(std::vector<Property>& rOutProperties) +{ + rOutProperties.emplace_back( + "Dimension", PROP_TREEMAP_TEMPLATE_DIMENSION, cppu::UnoType<sal_Int32>::get(), + beans::PropertyAttribute::BOUND | beans::PropertyAttribute::MAYBEDEFAULT); + rOutProperties.emplace_back( + "Geometry3D", PROP_TREEMAP_TEMPLATE_GEOMETRY3D, cppu::UnoType<sal_Int32>::get(), + beans::PropertyAttribute::BOUND | beans::PropertyAttribute::MAYBEDEFAULT); +} + +::cppu::OPropertyArrayHelper& StaticTreemapChartTypeTemplateInfoHelper() +{ + static ::cppu::OPropertyArrayHelper aPropHelper = []() { + std::vector<css::beans::Property> aProperties; + lcl_AddPropertiesToVector(aProperties); + + std::sort(aProperties.begin(), aProperties.end(), ::chart::PropertyNameLess()); + + return comphelper::containerToSequence(aProperties); + }(); + return aPropHelper; +}; + +} // anonymous namespace + +namespace chart +{ +TreemapChartTypeTemplate::TreemapChartTypeTemplate( + Reference<uno::XComponentContext> const& xContext, const OUString& rServiceName, + sal_Int32 nDim /* = 2 */) + : ChartTypeTemplate(xContext, rServiceName) + , m_nDim(nDim) +{ +} + +TreemapChartTypeTemplate::~TreemapChartTypeTemplate() {} + +sal_Int32 TreemapChartTypeTemplate::getDimension() const { return m_nDim; } + +// ____ ChartTypeTemplate ____ +bool TreemapChartTypeTemplate::matchesTemplate2(const rtl::Reference<::chart::Diagram>& xDiagram, + bool bAdaptProperties) +{ + bool bResult = ChartTypeTemplate::matchesTemplate2(xDiagram, bAdaptProperties); + + // adapt solid-type of template according to values in series + if (bAdaptProperties && bResult && getDimension() == 3) + { + bool bGeomFound = false, bGeomAmbiguous = false; + sal_Int32 aCommonGeom = xDiagram->getGeometry3D(bGeomFound, bGeomAmbiguous); + + if (!bGeomAmbiguous) + { + setFastPropertyValue_NoBroadcast(PROP_TREEMAP_TEMPLATE_GEOMETRY3D, + uno::Any(aCommonGeom)); + } + } + + return bResult; +} + +rtl::Reference<ChartType> + TreemapChartTypeTemplate::getChartTypeForIndex(sal_Int32 /*nChartTypeIndex*/) +{ + return new TreemapChartType(); +} + +rtl::Reference<ChartType> TreemapChartTypeTemplate::getChartTypeForNewSeries2( + const std::vector<rtl::Reference<ChartType>>& aFormerlyUsedChartTypes) +{ + rtl::Reference<ChartType> xResult(getChartTypeForIndex(0)); + ChartTypeTemplate::copyPropertiesFromOldToNewCoordinateSystem(aFormerlyUsedChartTypes, xResult); + return xResult; +} + +// ____ OPropertySet ____ +void TreemapChartTypeTemplate::GetDefaultValue(sal_Int32 nHandle, uno::Any& rAny) const +{ + static ::chart::tPropertyValueMap aStaticDefaults = []() { + ::chart::tPropertyValueMap aTmp; + ::chart::PropertyHelper::setPropertyValueDefault<sal_Int32>( + aTmp, PROP_TREEMAP_TEMPLATE_DIMENSION, 2); + ::chart::PropertyHelper::setPropertyValueDefault(aTmp, PROP_TREEMAP_TEMPLATE_GEOMETRY3D, + ::chart2::DataPointGeometry3D::CUBOID); + return aTmp; + }(); + tPropertyValueMap::const_iterator aFound(aStaticDefaults.find(nHandle)); + if (aFound == aStaticDefaults.end()) + rAny.clear(); + else + rAny = (*aFound).second; +} + +::cppu::IPropertyArrayHelper& SAL_CALL TreemapChartTypeTemplate::getInfoHelper() +{ + return StaticTreemapChartTypeTemplateInfoHelper(); +} + +// ____ XPropertySet ____ +Reference<beans::XPropertySetInfo> SAL_CALL TreemapChartTypeTemplate::getPropertySetInfo() +{ + static uno::Reference<beans::XPropertySetInfo> xPropertySetInfo( + ::cppu::OPropertySetHelper::createPropertySetInfo( + StaticTreemapChartTypeTemplateInfoHelper())); + return xPropertySetInfo; +} + +void TreemapChartTypeTemplate::applyStyle2(const rtl::Reference<DataSeries>& xSeries, + ::sal_Int32 nChartTypeIndex, ::sal_Int32 nSeriesIndex, + ::sal_Int32 nSeriesCount) +{ -e ... etc. - the rest is truncated
