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 /chart2/source | |
parent | CppunitTest_sw_ooxmlexport7: avoid DECLARE_OOXMLEXPORT_EXPORTONLY_TEST() (diff) | |
download | core-9d8324524bdcd1244cd6e9d93b063b981d47c9be.tar.gz core-9d8324524bdcd1244cd6e9d93b063b981d47c9be.zip |
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 'chart2/source')
-rw-r--r-- | chart2/source/model/main/FormattedString.cxx | 34 | ||||
-rw-r--r-- | chart2/source/model/main/FormattedString.hxx | 6 | ||||
-rw-r--r-- | chart2/source/view/charttypes/VSeriesPlotter.cxx | 9 |
3 files changed, 48 insertions, 1 deletions
diff --git a/chart2/source/model/main/FormattedString.cxx b/chart2/source/model/main/FormattedString.cxx index 5433f3683d78..782729294789 100644 --- a/chart2/source/model/main/FormattedString.cxx +++ b/chart2/source/model/main/FormattedString.cxx @@ -98,6 +98,7 @@ namespace chart FormattedString::FormattedString() : ::property::OPropertySet( m_aMutex ), m_aType(chart2::DataPointCustomLabelFieldType::DataPointCustomLabelFieldType_TEXT), + m_bDataLabelsRange(false), m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder()) {} @@ -107,6 +108,7 @@ FormattedString::FormattedString( const FormattedString & rOther ) : m_aString( rOther.m_aString ), m_aType(rOther.m_aType), m_aGuid(rOther.m_aGuid), + m_bDataLabelsRange(rOther.m_bDataLabelsRange), m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder()) {} @@ -172,6 +174,38 @@ void SAL_CALL FormattedString::setGuid( const OUString& guid ) } +sal_Bool SAL_CALL FormattedString::getDataLabelsRange() +{ + MutexGuard aGuard( m_aMutex); + return m_bDataLabelsRange; +} + +void SAL_CALL FormattedString::setDataLabelsRange( sal_Bool dataLabelsRange ) +{ + { + MutexGuard aGuard( m_aMutex); + m_bDataLabelsRange = dataLabelsRange; + } + //don't keep the mutex locked while calling out + fireModifyEvent(); +} + +OUString SAL_CALL FormattedString::getCellRange() +{ + MutexGuard aGuard( m_aMutex); + return m_aCellRange; +} + +void SAL_CALL FormattedString::setCellRange( const OUString& cellRange ) +{ + { + MutexGuard aGuard( m_aMutex); + m_aCellRange = cellRange; + } + //don't keep the mutex locked while calling out + fireModifyEvent(); +} + // ____ XModifyBroadcaster ____ void SAL_CALL FormattedString::addModifyListener( const uno::Reference< util::XModifyListener >& aListener ) { diff --git a/chart2/source/model/main/FormattedString.hxx b/chart2/source/model/main/FormattedString.hxx index a7f9e36bb134..bd7415fb921a 100644 --- a/chart2/source/model/main/FormattedString.hxx +++ b/chart2/source/model/main/FormattedString.hxx @@ -87,6 +87,10 @@ private: setFieldType( const css::chart2::DataPointCustomLabelFieldType FieldType ) override; virtual OUString SAL_CALL getGuid() override; void SAL_CALL setGuid( const OUString& guid ) override; + virtual sal_Bool SAL_CALL getDataLabelsRange() override; + virtual void SAL_CALL setDataLabelsRange( sal_Bool dataLabelsRange ) override; + virtual OUString SAL_CALL getCellRange() override; + virtual void SAL_CALL setCellRange( const OUString& cellRange ) override; // ____ OPropertySet ____ virtual css::uno::Any GetDefaultValue( sal_Int32 nHandle ) const override; @@ -127,6 +131,8 @@ private: // ____ XDataPointCustomLabelField ____ css::chart2::DataPointCustomLabelFieldType m_aType; OUString m_aGuid; + OUString m_aCellRange; + bool m_bDataLabelsRange; css::uno::Reference< css::util::XModifyListener > m_xModifyEventForwarder; }; diff --git a/chart2/source/view/charttypes/VSeriesPlotter.cxx b/chart2/source/view/charttypes/VSeriesPlotter.cxx index b0a591d3c065..b5bfc8d871b0 100644 --- a/chart2/source/view/charttypes/VSeriesPlotter.cxx +++ b/chart2/source/view/charttypes/VSeriesPlotter.cxx @@ -540,9 +540,16 @@ uno::Reference< drawing::XShape > VSeriesPlotter::createDataLabel( const uno::Re aTextList[i] = getLabelTextForValue(rDataSeries, nPointIndex, fValue, true); break; } - case DataPointCustomLabelFieldType_CELLREF: case DataPointCustomLabelFieldType_CELLRANGE: { + if (aCustomLabels[i]->getDataLabelsRange()) + aTextList[i] = aCustomLabels[i]->getString(); + else + aTextList[i] = OUString(); + break; + } + case DataPointCustomLabelFieldType_CELLREF: + { // TODO: for now doesn't show placeholder aTextList[i] = OUString(); break; |