diff options
author | Dennis Francis <dennis.francis@collabora.com> | 2021-08-25 20:51:56 +0530 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2021-09-01 09:15:03 +0200 |
commit | 9d8324524bdcd1244cd6e9d93b063b981d47c9be (patch) | |
tree | 1bbd6560ef3a292b0685d4b768ea1a07c17259b8 /include/oox | |
parent | b365358075d484e034eb9cd6bceeea9d639835b6 (diff) |
tdf#143942: oox: import/export labels from <c15:datalabelsRange>
When <c15:showDataLabelsRange> boolean flag is present, the imported
label texts are added as the first text field in oox data label model.
The cell-range associated is also preserved. The export part preserves
the how labels were store originally in <c15:datalabelsRange>.
However in order to make the custom labels reflect the contents of the
cells in the associated cell-range, more work needs to be done. For this
the labels present in <c15:datalabelsRange> needs to be made available
as a data-sequence with a new "role" like "point-labels" in
XInternalDataProvider implementation and and make the label renderer
read this data source rather than consulting the custom label fields
property which is static after import.
Change-Id: Ibc7045fa5ea209d463680c96efb49a06662d2500
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121313
Tested-by: Jenkins
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'include/oox')
-rw-r--r-- | include/oox/export/chartexport.hxx | 40 |
1 files changed, 39 insertions, 1 deletions
diff --git a/include/oox/export/chartexport.hxx b/include/oox/export/chartexport.hxx index 5dbf8c20ac0b..c4440ae08419 100644 --- a/include/oox/export/chartexport.hxx +++ b/include/oox/export/chartexport.hxx @@ -91,6 +91,43 @@ struct AxisIdPair{ {} }; +/** + A helper container class to collect the chart data point labels and the address + of the cell[range] from which the labels are sourced if that is the case. This + is then used to write the label texts under the extension tag <c15:datalabelsRange>. + + @since LibreOffice 7.3.0 + */ +class DataLabelsRange +{ +public: + + /// type of the internal container that stores the indexed label text. + typedef std::map<sal_Int32, OUString> LabelsRangeMap; + + /// Returns whether the container is empty or not. + bool empty() const; + /// Returns the count of labels stored. + size_t count() const; + /// Indicates whether the container has a label with index specified by nIndex. + bool hasLabel(sal_Int32 nIndex) const; + /// Returns the address of the cell[range] from which label contents are sourced. + OUString getRange() const; + + /// Sets the address of the cell[range] from which label contents are sourced. + void setRange(const OUString& rRange); + /// Adds a new indexed label text. + void setLabel(sal_Int32 nIndex, const OUString& rText); + + LabelsRangeMap::const_iterator begin() const; + LabelsRangeMap::const_iterator end() const; + +private: + OUString maRange; + LabelsRangeMap maLabels; +}; + + class OOX_DLLPUBLIC ChartExport final : public DrawingML { public: @@ -184,7 +221,8 @@ private: void exportDataPoints( const css::uno::Reference< css::beans::XPropertySet >& xSeriesProperties, sal_Int32 nSeriesLength, sal_Int32 eChartType ); - void exportDataLabels( const css::uno::Reference<css::chart2::XDataSeries>& xSeries, sal_Int32 nSeriesLength, sal_Int32 eChartType ); + void exportDataLabels( const css::uno::Reference<css::chart2::XDataSeries>& xSeries, sal_Int32 nSeriesLength, + sal_Int32 eChartType, DataLabelsRange& rDLblsRange ); void exportGrouping( bool isBar = false ); void exportTrendlines( const css::uno::Reference< css::chart2::XDataSeries >& xSeries ); void exportMarker( const css::uno::Reference< css::beans::XPropertySet >& xPropSet ); |