chart2/Library_chart2.mk | 14 chart2/qa/extras/chart2export2.cxx | 80 +++ 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/typegroupcontext.hxx | 3 oox/inc/drawingml/chart/typegroupconverter.hxx | 10 oox/source/core/contexthandler2.cxx | 4 oox/source/drawingml/chart/datasourcecontext.cxx | 1 oox/source/drawingml/chart/plotareacontext.cxx | 50 ++ oox/source/drawingml/chart/seriescontext.cxx | 1 oox/source/drawingml/chart/typegroupcontext.cxx | 54 -- oox/source/drawingml/chart/typegroupconverter.cxx | 33 + oox/source/export/chartexport.cxx | 205 +++++++++- oox/source/token/tokens.txt | 2 54 files changed, 3095 insertions(+), 85 deletions(-)
New commits: commit b0ea54f713fedf39efb07e3a8efa3e2ea1d04aa2 Author: Kurt Nordback <[email protected]> AuthorDate: Mon Jan 5 11:41:08 2026 -0700 Commit: Tomaž Vajngerl <[email protected]> CommitDate: Mon Jan 12 06:14:09 2026 +0100 tdf#165742 Step 5.3: Fix pareto chart import Restructure chartex parsing architecture a bit, to fix handling of multiple series in a chart (as in pareto charts, as created by MSO). This is necessitated by the difference between chart and chartex structure: the former includes a 'type group' tag (e.g., barChart) which can contain multiple series; the latter has the chart type attached to the series tag as an attribute. Change-Id: I4bd20b189248888dc88939398bf47bd750f57c26 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/196580 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <[email protected]> Signed-off-by: Xisco Fauli <[email protected]> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/196929 diff --git a/chart2/qa/extras/chart2export2.cxx b/chart2/qa/extras/chart2export2.cxx index d28c87dcfef1..fc207d8a19d6 100644 --- a/chart2/qa/extras/chart2export2.cxx +++ b/chart2/qa/extras/chart2export2.cxx @@ -196,17 +196,12 @@ CPPUNIT_TEST_FIXTURE(Chart2ExportTest2, testChartexTitleXLSX) 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 + // A pareto chart from MSO really consists of two subcharts: a pareto line + // and a clustered column chart. 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"); -#endif assertXPathContent(pXmlDoc, "/cx:chartSpace/cx:chart/cx:title/cx:tx/cx:txData/cx:v", u"ParetoLine"); // ==== diff --git a/oox/inc/drawingml/chart/typegroupcontext.hxx b/oox/inc/drawingml/chart/typegroupcontext.hxx index c64f18d74c72..07b45d5c50bd 100644 --- a/oox/inc/drawingml/chart/typegroupcontext.hxx +++ b/oox/inc/drawingml/chart/typegroupcontext.hxx @@ -162,9 +162,6 @@ public: explicit ChartexTypeGroupContext( ::oox::core::ContextHandler2Helper& rParent, TypeGroupModel& rModel ); virtual ~ChartexTypeGroupContext() override; - // Explicitly create a new series - void CreateSeries(); - virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ) override; }; diff --git a/oox/source/drawingml/chart/plotareacontext.cxx b/oox/source/drawingml/chart/plotareacontext.cxx index 731c23368933..c3c3fc6af82f 100644 --- a/oox/source/drawingml/chart/plotareacontext.cxx +++ b/oox/source/drawingml/chart/plotareacontext.cxx @@ -170,7 +170,7 @@ ContextHandlerRef PlotAreaContext::onCreateContext( sal_Int32 nElement, [[maybe_ case CX_TOKEN(plotArea) : switch (nElement) { case CX_TOKEN(plotAreaRegion) : - return new ChartexTypeGroupContext(*this, mrModel.maTypeGroups.create(nElement, false)); + return this; case CX_TOKEN(axis) : if (rAttribs.hasAttribute(XML_id)) { sal_Int32 nId = rAttribs.getInteger(XML_id, -1); @@ -186,6 +186,54 @@ ContextHandlerRef PlotAreaContext::onCreateContext( sal_Int32 nElement, [[maybe_ return nullptr; } break; + case CX_TOKEN(plotAreaRegion): + switch (nElement) { + case CX_TOKEN(series): + if (rAttribs.hasAttribute(XML_layoutId)) { + sal_Int32 nTypeId = 0; + OUString sChartId = rAttribs.getStringDefaulted(XML_layoutId); + assert(!sChartId.isEmpty()); + + if (sChartId == "boxWhisker") { + nTypeId = CX_TOKEN(boxWhisker); + } else if (sChartId == "clusteredColumn") { + nTypeId = CX_TOKEN(clusteredColumn); + } else if (sChartId == "funnel") { + nTypeId = CX_TOKEN(funnel); + } else if (sChartId == "paretoLine") { + nTypeId = CX_TOKEN(paretoLine); + } else if (sChartId == "regionMap") { + nTypeId = CX_TOKEN(regionMap); + } else if (sChartId == "sunburst") { + nTypeId = CX_TOKEN(sunburst); + } else if (sChartId == "treemap") { + nTypeId = CX_TOKEN(treemap); + } else if (sChartId == "waterfall") { + nTypeId = CX_TOKEN(waterfall); + } else { + assert(false); + } + + // The chartex schema doesn't have the same structure as + // chart. Specifically, there's not a chart type tag + // (which corresponds to the "type group" used in oox) + // plus enclosed series tags. Instead, in chartex, each + // series has an attribute specifying the chart type. As + // a result, we don't want to call the type group + // context handler, but we still need to create a type + // group in the model tree, since much of the existing + // machinery depends on it. + mrModel.maTypeGroups.create(nTypeId, false); + std::shared_ptr<TypeGroupModel> aTGM = + mrModel.maTypeGroups.get(mrModel.maTypeGroups.size() - 1); + return new ChartexSeriesContext(*this, aTGM->maSeries.create(false)); + } + return nullptr; + case CX_TOKEN(plotSurface) : + // TODO + return nullptr; + + } } return nullptr; } diff --git a/oox/source/drawingml/chart/typegroupcontext.cxx b/oox/source/drawingml/chart/typegroupcontext.cxx index f29b42ab42bf..4f2ea33652e9 100644 --- a/oox/source/drawingml/chart/typegroupcontext.cxx +++ b/oox/source/drawingml/chart/typegroupcontext.cxx @@ -405,61 +405,11 @@ ChartexTypeGroupContext::~ChartexTypeGroupContext() { } -void ChartexTypeGroupContext::CreateSeries() -{ - mrModel.maSeries.create(false); -} - ContextHandlerRef ChartexTypeGroupContext::onCreateContext( [[maybe_unused]] sal_Int32 nElement, [[maybe_unused]] const AttributeList& rAttribs ) { - if (isRootElement()) switch (nElement) { - case CX_TOKEN(plotSurface) : - // TODO - return nullptr; - case CX_TOKEN(series) : - if (rAttribs.hasAttribute(XML_layoutId)) { - // If this is the first series, then the type ID is currently - // set to <cx:plotAreaRegion>. If this is not the first series - // in a multi-series chart, it should be set to the previous - // chart type in the series (which *should* only be another - // chartex type, not a <c> type). In either case, set it - // to the specific chart type based on the layoutId attribute - assert(mrModel.mnTypeId == CX_TOKEN(plotAreaRegion) || - mrModel.mnTypeId == CX_TOKEN(boxWhisker) || - mrModel.mnTypeId == CX_TOKEN(clusteredColumn) || - mrModel.mnTypeId == CX_TOKEN(funnel) || - mrModel.mnTypeId == CX_TOKEN(paretoLine) || - mrModel.mnTypeId == CX_TOKEN(regionMap) || - mrModel.mnTypeId == CX_TOKEN(sunburst) || - mrModel.mnTypeId == CX_TOKEN(treemap) || - mrModel.mnTypeId == CX_TOKEN(waterfall)); - OUString sChartId = rAttribs.getStringDefaulted(XML_layoutId); - assert(!sChartId.isEmpty()); - - if (sChartId == "boxWhisker") { - mrModel.mnTypeId = CX_TOKEN(boxWhisker); - } else if (sChartId == "clusteredColumn") { - mrModel.mnTypeId = CX_TOKEN(clusteredColumn); - } else if (sChartId == "funnel") { - mrModel.mnTypeId = CX_TOKEN(funnel); - } else if (sChartId == "paretoLine") { - mrModel.mnTypeId = CX_TOKEN(paretoLine); - } else if (sChartId == "regionMap") { - mrModel.mnTypeId = CX_TOKEN(regionMap); - } else if (sChartId == "sunburst") { - mrModel.mnTypeId = CX_TOKEN(sunburst); - } else if (sChartId == "treemap") { - mrModel.mnTypeId = CX_TOKEN(treemap); - } else if (sChartId == "waterfall") { - mrModel.mnTypeId = CX_TOKEN(waterfall); - } else { - assert(false); - } - - return new ChartexSeriesContext(*this, mrModel.maSeries.create(false)); - } - break; + if (isRootElement()) { + return new ChartexSeriesContext(*this, mrModel.maSeries.create(false)); } return nullptr; commit 32b018652dd9a348b868d0b42656a128f2c06102 Author: Kurt Nordback <[email protected]> AuthorDate: Mon Dec 29 13:36:25 2025 -0700 Commit: Tomaž Vajngerl <[email protected]> CommitDate: Mon Jan 12 06:14:02 2026 +0100 tdf#165742 Step 5.2: Fix some round-trip failures Fix formula references in chartex data elements, and put in special handling for sunburst and treemap formula references (these two types, at least, require category references as well as value references). Change-Id: Id9a2b1c54559f0f19a39d3635ff314e5894a9f0f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/196316 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <[email protected]> Signed-off-by: Xisco Fauli <[email protected]> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/196928 diff --git a/oox/source/drawingml/chart/datasourcecontext.cxx b/oox/source/drawingml/chart/datasourcecontext.cxx index d27b715dbbc7..2532b6ad866d 100644 --- a/oox/source/drawingml/chart/datasourcecontext.cxx +++ b/oox/source/drawingml/chart/datasourcecontext.cxx @@ -298,6 +298,7 @@ void StringSequenceContext::onCharacters( const OUString& rChars ) switch( getCurrentElement() ) { case C_TOKEN( f ): + case CX_TOKEN( f ): mrModel.maFormula = rChars; break; case C15_TOKEN( f ): diff --git a/oox/source/drawingml/chart/seriescontext.cxx b/oox/source/drawingml/chart/seriescontext.cxx index c913aa31928e..ba0876e2222b 100644 --- a/oox/source/drawingml/chart/seriescontext.cxx +++ b/oox/source/drawingml/chart/seriescontext.cxx @@ -790,6 +790,7 @@ ContextHandlerRef ChartexSeriesContext::onCreateContext( sal_Int32 nElement, con return new DataLabelsContext( *this, mrModel.mxLabels.create(false) ); case CX_TOKEN( dataId ): mrModel.mnDataId = rAttribs.getInteger(XML_val, -1); + mrModel.mnIndex = rAttribs.getInteger( XML_val, -1 ); return nullptr; case CX_TOKEN( layoutPr ): // This looks complicated. TODO diff --git a/oox/source/export/chartexport.cxx b/oox/source/export/chartexport.cxx index 3b8cc5e99712..fa89b448f129 100644 --- a/oox/source/export/chartexport.cxx +++ b/oox/source/export/chartexport.cxx @@ -1589,14 +1589,49 @@ void ChartExport::exportData_chartex( [[maybe_unused]] const Reference< css::cha // The data id needs to agree with the id in exportSeries(). See DATA_ID_COMMENT pFS->startElement(FSNS(XML_cx, XML_data), XML_id, OUString::number(nSeriesIndex)); - // .xlsx chartex files seem to have this magical "_xlchart.v2.0" string, + // .xlsx chartex files seem to have this magical "_xlchart..." string, // and no explicit data, while .docx and .pptx contain the literal data, // as well as a ../embeddings file (which LO doesn't seem to produce). // But there's probably a smarter way to determine which pathway to take // than based on document type. if (GetDocumentType() == DOCUMENT_XLSX) { // Just hard-coding this for now - pFS->startElement(FSNS(XML_cx, XML_numDim), XML_type, "val"); + + sal_Int32 nSuffixVal = nSeriesIndex; + + // Output category data formula for some chart types. + // (This is completely hacky) + if (eChartType == chart::TYPEID_SUNBURST || + eChartType == chart::TYPEID_TREEMAP) { + pFS->startElement(FSNS(XML_cx, XML_strDim), XML_type, "cat"); + pFS->startElement(FSNS(XML_cx, XML_f)); + + std::string sFormulaId = "_xlchart.v1."; + sFormulaId.append(std::to_string(nSuffixVal)); + + pFS->writeEscaped(sFormulaId); + + pFS->endElement(FSNS(XML_cx, XML_f)); + pFS->endElement(FSNS(XML_cx, XML_strDim)); + + ++nSuffixVal; + } + + // Set the ST_NumericDimensionType. For some (stupid?) + // reason, MSO requires the value data for sunburst and + // treemap to be type "size", while for most other chart + // types it's of type "val". + std::string sNumDimType; + if (eChartType == chart::TYPEID_SUNBURST || + eChartType == chart::TYPEID_TREEMAP) { + sNumDimType = "size"; + } else { + sNumDimType = "val"; + } + + // Now output value data formula + pFS->startElement(FSNS(XML_cx, XML_numDim), XML_type, + sNumDimType.c_str()); pFS->startElement(FSNS(XML_cx, XML_f)); // Set the formula value based on the chart type. This @@ -1627,7 +1662,7 @@ void ChartExport::exportData_chartex( [[maybe_unused]] const Reference< css::cha // Append the id value, which seems (?) to be what // follows the period in the string. E.g., for id=2 we // might end up with "_xlchart.v1.2" - sFormulaId.append(std::to_string(nSeriesIndex)); + sFormulaId.append(std::to_string(nSuffixVal)); pFS->writeEscaped(sFormulaId); commit 06d0e9ed24f017f0206b7f20e179043006948978 Author: Kurt Nordback <[email protected]> AuthorDate: Fri Nov 21 09:57:20 2025 -0700 Commit: Tomaž Vajngerl <[email protected]> CommitDate: Mon Jan 12 06:13:57 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]> Signed-off-by: Xisco Fauli <[email protected]> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/196927 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 1be3ab2a3822..d28c87dcfef1 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) + { -e ... etc. - the rest is truncated
