diff options
author | Samuel Mehrbrodt <samuel.mehrbrodt@allotropia.de> | 2021-02-03 08:01:55 +0100 |
---|---|---|
committer | Samuel Mehrbrodt <samuel.mehrbrodt@allotropia.de> | 2021-02-08 07:52:27 +0100 |
commit | b99f310d3b24dc45e3d84751e810c0bbff1d991b (patch) | |
tree | 6780680407253b0b9f7599843313730309b84368 /chart2 | |
parent | 48a8901a205000e9878c7ee5b4fb26e07ea0a607 (diff) |
tdf#94235 Add support for series name in data series labels
including ODF/OOXML import/export (and test)
Change-Id: Id5a5194630a67476f7c5390294400a00ea3ad42d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110338
Tested-by: Jenkins
Reviewed-by: Samuel Mehrbrodt <samuel.mehrbrodt@allotropia.de>
Diffstat (limited to 'chart2')
17 files changed, 159 insertions, 40 deletions
diff --git a/chart2/qa/extras/chart2export.cxx b/chart2/qa/extras/chart2export.cxx index a702d5113b13..c8b4c03755e7 100644 --- a/chart2/qa/extras/chart2export.cxx +++ b/chart2/qa/extras/chart2export.cxx @@ -140,6 +140,7 @@ public: void testAxisCrossBetweenDOCX(); void testPieChartDataPointExplosionXLSX(); void testCustomDataLabel(); + void testDataSeriesName(); void testCustomPositionofDataLabel(); void testCustomDataLabelMultipleSeries(); void testLeaderLines(); @@ -288,6 +289,7 @@ public: CPPUNIT_TEST(testAxisCrossBetweenDOCX); CPPUNIT_TEST(testPieChartDataPointExplosionXLSX); CPPUNIT_TEST(testCustomDataLabel); + CPPUNIT_TEST(testDataSeriesName); CPPUNIT_TEST(testCustomPositionofDataLabel); CPPUNIT_TEST(testCustomDataLabelMultipleSeries); CPPUNIT_TEST(testLeaderLines); @@ -2310,6 +2312,38 @@ void Chart2ExportTest::testCustomDataLabel() CPPUNIT_ASSERT_EQUAL(OUString(" <CELLREF"), aFields[1]->getString()); } +/// Test for tdf#94235 +void Chart2ExportTest::testDataSeriesName() +{ + // ODF + { + load(u"/chart2/qa/extras/data/ods/", "ser_labels.ods"); + reload("calc8"); + uno::Reference<chart2::XChartDocument> xChartDoc = getChartDocFromSheet(0, mxComponent); + uno::Reference<chart2::XDataSeries> xDataSeries(getDataSeriesFromDoc(xChartDoc, 0)); + CPPUNIT_ASSERT(xDataSeries.is()); + uno::Reference<beans::XPropertySet> xPropertySet; + chart2::DataPointLabel aDataPointLabel; + xPropertySet.set(xDataSeries->getDataPointByIndex(0), uno::UNO_SET_THROW); + xPropertySet->getPropertyValue("Label") >>= aDataPointLabel; + CPPUNIT_ASSERT_EQUAL(sal_True, aDataPointLabel.ShowSeriesName); + } + + // OOXML + { + load(u"/chart2/qa/extras/data/xlsx/", "ser_labels.xlsx"); + reload("Calc Office Open XML"); + uno::Reference<chart2::XChartDocument> xChartDoc = getChartDocFromSheet(0, mxComponent); + uno::Reference<chart2::XDataSeries> xDataSeries(getDataSeriesFromDoc(xChartDoc, 0)); + CPPUNIT_ASSERT(xDataSeries.is()); + uno::Reference<beans::XPropertySet> xPropertySet; + chart2::DataPointLabel aDataPointLabel; + xPropertySet.set(xDataSeries->getDataPointByIndex(0), uno::UNO_SET_THROW); + xPropertySet->getPropertyValue("Label") >>= aDataPointLabel; + CPPUNIT_ASSERT_EQUAL(sal_True, aDataPointLabel.ShowSeriesName); + } +} + void Chart2ExportTest::testCustomPositionofDataLabel() { load(u"/chart2/qa/extras/data/xlsx/", "testCustomPosDataLabels.xlsx"); diff --git a/chart2/qa/extras/data/ods/ser_labels.ods b/chart2/qa/extras/data/ods/ser_labels.ods Binary files differnew file mode 100644 index 000000000000..c7bd96638268 --- /dev/null +++ b/chart2/qa/extras/data/ods/ser_labels.ods diff --git a/chart2/qa/extras/data/xlsx/ser_labels.xlsx b/chart2/qa/extras/data/xlsx/ser_labels.xlsx Binary files differnew file mode 100644 index 000000000000..ba2315666eda --- /dev/null +++ b/chart2/qa/extras/data/xlsx/ser_labels.xlsx diff --git a/chart2/source/controller/chartapiwrapper/WrappedDataCaptionProperties.cxx b/chart2/source/controller/chartapiwrapper/WrappedDataCaptionProperties.cxx index c786c1b3913c..d317210c3608 100644 --- a/chart2/source/controller/chartapiwrapper/WrappedDataCaptionProperties.cxx +++ b/chart2/source/controller/chartapiwrapper/WrappedDataCaptionProperties.cxx @@ -65,13 +65,15 @@ sal_Int32 lcl_LabelToCaption( const chart2::DataPointLabel& rLabel ) nCaption |= css::chart::ChartDataCaption::TEXT; if( rLabel.ShowLegendSymbol ) nCaption |= css::chart::ChartDataCaption::SYMBOL; + if (rLabel.ShowSeriesName) + nCaption |= css::chart::ChartDataCaption::DATA_SERIES; return nCaption; } chart2::DataPointLabel lcl_CaptionToLabel( sal_Int32 nCaption ) { - chart2::DataPointLabel aLabel(false,false,false,false,false); + chart2::DataPointLabel aLabel(false,false,false,false,false,false); if( nCaption & css::chart::ChartDataCaption::VALUE ) aLabel.ShowNumber = true; @@ -83,6 +85,8 @@ chart2::DataPointLabel lcl_CaptionToLabel( sal_Int32 nCaption ) aLabel.ShowLegendSymbol = true; if( nCaption & css::chart::ChartDataCaption::CUSTOM ) aLabel.ShowCustomLabel = true; + if( nCaption & css::chart::ChartDataCaption::DATA_SERIES ) + aLabel.ShowSeriesName = true; return aLabel; } diff --git a/chart2/source/controller/dialogs/res_DataLabel.cxx b/chart2/source/controller/dialogs/res_DataLabel.cxx index 7934e90871dc..57a0d3c9565a 100644 --- a/chart2/source/controller/dialogs/res_DataLabel.cxx +++ b/chart2/source/controller/dialogs/res_DataLabel.cxx @@ -104,6 +104,7 @@ DataLabelResources::DataLabelResources(weld::Builder* pBuilder, weld::Window* pP , m_xFT_NumberFormatForPercent(pBuilder->weld_label("STR_DLG_NUMBERFORMAT_FOR_PERCENTAGE_VALUE")) , m_xCBCategory(pBuilder->weld_check_button("CB_CATEGORY")) , m_xCBSymbol(pBuilder->weld_check_button("CB_SYMBOL")) + , m_xCBDataSeries(pBuilder->weld_check_button("CB_DATA_SERIES_NAME")) , m_xCBWrapText(pBuilder->weld_check_button("CB_WRAP_TEXT")) , m_xSeparatorResources(pBuilder->weld_widget("boxSEPARATOR")) , m_xLB_Separator(pBuilder->weld_combo_box("LB_TEXT_SEPARATOR")) @@ -148,6 +149,7 @@ DataLabelResources::DataLabelResources(weld::Builder* pBuilder, weld::Window* pP m_xCBPercent->connect_toggled( LINK( this, DataLabelResources, CheckHdl )); m_xCBCategory->connect_toggled( LINK( this, DataLabelResources, CheckHdl )); m_xCBSymbol->connect_toggled( LINK( this, DataLabelResources, CheckHdl )); + m_xCBDataSeries->connect_toggled( LINK( this, DataLabelResources, CheckHdl )); m_xCBWrapText->connect_toggled( LINK( this, DataLabelResources, CheckHdl )); m_xCBCustomLeaderLines->connect_toggled( LINK( this, DataLabelResources, CheckHdl )); @@ -229,10 +231,10 @@ IMPL_LINK_NOARG(DataLabelResources, CheckHdl, weld::ToggleButton&, void) void DataLabelResources::EnableControls() { m_xCBSymbol->set_sensitive( m_xCBNumber->get_active() || (m_xCBPercent->get_active() && m_xCBPercent->get_sensitive()) - || m_xCBCategory->get_active() ); + || m_xCBCategory->get_active() || m_xCBDataSeries->get_active()); m_xCBWrapText->set_sensitive( m_xCBNumber->get_active() || (m_xCBPercent->get_active() && m_xCBPercent->get_sensitive()) - || m_xCBCategory->get_active() ); + || m_xCBCategory->get_active() || m_xCBDataSeries->get_active() ); // Enable or disable separator, placement and direction based on the check // box states. Note that the check boxes are tri-state. @@ -244,6 +246,8 @@ void DataLabelResources::EnableControls() ++nNumberOfCheckedLabelParts; if (m_xCBCategory->get_state() != TRISTATE_FALSE) ++nNumberOfCheckedLabelParts; + if (m_xCBDataSeries->get_state() != TRISTATE_FALSE) + ++nNumberOfCheckedLabelParts; m_xSeparatorResources->set_sensitive( nNumberOfCheckedLabelParts > 1 ); @@ -256,8 +260,9 @@ void DataLabelResources::EnableControls() m_xPB_NumberFormatForValue->set_sensitive( m_pNumberFormatter && m_xCBNumber->get_active() ); m_xPB_NumberFormatForPercent->set_sensitive( m_pNumberFormatter && m_xCBPercent->get_active() && m_xCBPercent->get_sensitive() ); - bool bEnableRotation = ( m_xCBNumber->get_active() || m_xCBPercent->get_active() || m_xCBCategory->get_active() ); - m_xBxOrientation->set_sensitive( bEnableRotation ); + bool bEnableRotation = (m_xCBNumber->get_active() || m_xCBPercent->get_active() + || m_xCBCategory->get_active() || m_xCBDataSeries->get_active()); + m_xBxOrientation->set_sensitive(bEnableRotation); } void DataLabelResources::FillItemSet( SfxItemSet* rOutAttrs ) const @@ -285,6 +290,8 @@ void DataLabelResources::FillItemSet( SfxItemSet* rOutAttrs ) const rOutAttrs->Put( SfxBoolItem( SCHATTR_DATADESCR_SHOW_CATEGORY, m_xCBCategory->get_active() ) ); if( m_xCBSymbol->get_state()!= TRISTATE_INDET ) rOutAttrs->Put( SfxBoolItem( SCHATTR_DATADESCR_SHOW_SYMBOL, m_xCBSymbol->get_active()) ); + if( m_xCBDataSeries->get_state()!= TRISTATE_INDET ) + rOutAttrs->Put( SfxBoolItem( SCHATTR_DATADESCR_SHOW_DATA_SERIES_NAME, m_xCBDataSeries->get_active()) ); if( m_xCBWrapText->get_state()!= TRISTATE_INDET ) rOutAttrs->Put( SfxBoolItem( SCHATTR_DATADESCR_WRAP_TEXT, m_xCBWrapText->get_active()) ); if( m_xCBCustomLeaderLines->get_state() != TRISTATE_INDET ) @@ -319,6 +326,7 @@ void DataLabelResources::Reset(const SfxItemSet& rInAttrs) lcl_setBoolItemToCheckBox( rInAttrs, SCHATTR_DATADESCR_SHOW_PERCENTAGE, *m_xCBPercent ); lcl_setBoolItemToCheckBox( rInAttrs, SCHATTR_DATADESCR_SHOW_CATEGORY, *m_xCBCategory ); lcl_setBoolItemToCheckBox( rInAttrs, SCHATTR_DATADESCR_SHOW_SYMBOL, *m_xCBSymbol ); + lcl_setBoolItemToCheckBox( rInAttrs, SCHATTR_DATADESCR_SHOW_DATA_SERIES_NAME, *m_xCBDataSeries ); lcl_setBoolItemToCheckBox( rInAttrs, SCHATTR_DATADESCR_WRAP_TEXT, *m_xCBWrapText ); lcl_setBoolItemToCheckBox( rInAttrs, SCHATTR_DATADESCR_CUSTOM_LEADER_LINES, *m_xCBCustomLeaderLines ); diff --git a/chart2/source/controller/dialogs/res_DataLabel.hxx b/chart2/source/controller/dialogs/res_DataLabel.hxx index 5358c0345495..1f832a4881a3 100644 --- a/chart2/source/controller/dialogs/res_DataLabel.hxx +++ b/chart2/source/controller/dialogs/res_DataLabel.hxx @@ -65,6 +65,7 @@ private: std::unique_ptr<weld::Label> m_xFT_NumberFormatForPercent; std::unique_ptr<weld::CheckButton> m_xCBCategory; std::unique_ptr<weld::CheckButton> m_xCBSymbol; + std::unique_ptr<weld::CheckButton> m_xCBDataSeries; std::unique_ptr<weld::CheckButton> m_xCBWrapText; std::unique_ptr<weld::Widget> m_xSeparatorResources; diff --git a/chart2/source/controller/itemsetwrapper/DataPointItemConverter.cxx b/chart2/source/controller/itemsetwrapper/DataPointItemConverter.cxx index 2c27b6ae7dc1..589972740e86 100644 --- a/chart2/source/controller/itemsetwrapper/DataPointItemConverter.cxx +++ b/chart2/source/controller/itemsetwrapper/DataPointItemConverter.cxx @@ -319,6 +319,7 @@ bool DataPointItemConverter::ApplySpecialItem( case SCHATTR_DATADESCR_SHOW_NUMBER: case SCHATTR_DATADESCR_SHOW_PERCENTAGE: case SCHATTR_DATADESCR_SHOW_CATEGORY: + case SCHATTR_DATADESCR_SHOW_DATA_SERIES_NAME: case SCHATTR_DATADESCR_SHOW_SYMBOL: { const SfxBoolItem & rItem = static_cast< const SfxBoolItem & >( rItemSet.Get( nWhichId )); @@ -329,7 +330,8 @@ bool DataPointItemConverter::ApplySpecialItem( { sal_Bool& rValue = (nWhichId==SCHATTR_DATADESCR_SHOW_NUMBER) ? aLabel.ShowNumber : ( (nWhichId==SCHATTR_DATADESCR_SHOW_PERCENTAGE) ? aLabel.ShowNumberInPercent : ( - (nWhichId==SCHATTR_DATADESCR_SHOW_CATEGORY) ? aLabel.ShowCategoryName : aLabel.ShowLegendSymbol )); + (nWhichId==SCHATTR_DATADESCR_SHOW_CATEGORY) ? aLabel.ShowCategoryName : ( + (nWhichId==SCHATTR_DATADESCR_SHOW_DATA_SERIES_NAME) ? aLabel.ShowSeriesName : aLabel.ShowLegendSymbol ))); bool bOldValue = rValue; rValue = rItem.GetValue(); if( m_bOverwriteLabelsForAttributedDataPointsAlso ) @@ -616,6 +618,7 @@ void DataPointItemConverter::FillSpecialItem( case SCHATTR_DATADESCR_SHOW_NUMBER: case SCHATTR_DATADESCR_SHOW_PERCENTAGE: case SCHATTR_DATADESCR_SHOW_CATEGORY: + case SCHATTR_DATADESCR_SHOW_DATA_SERIES_NAME: case SCHATTR_DATADESCR_SHOW_SYMBOL: { chart2::DataPointLabel aLabel; @@ -623,7 +626,8 @@ void DataPointItemConverter::FillSpecialItem( { bool bValue = (nWhichId==SCHATTR_DATADESCR_SHOW_NUMBER) ? aLabel.ShowNumber : ( (nWhichId==SCHATTR_DATADESCR_SHOW_PERCENTAGE) ? aLabel.ShowNumberInPercent : ( - (nWhichId==SCHATTR_DATADESCR_SHOW_CATEGORY) ? aLabel.ShowCategoryName : aLabel.ShowLegendSymbol )); + (nWhichId==SCHATTR_DATADESCR_SHOW_CATEGORY) ? aLabel.ShowCategoryName : ( + (nWhichId==SCHATTR_DATADESCR_SHOW_DATA_SERIES_NAME) ? aLabel.ShowSeriesName : aLabel.ShowLegendSymbol ))); rOutItemSet.Put( SfxBoolItem( nWhichId, bValue )); diff --git a/chart2/source/controller/itemsetwrapper/TextLabelItemConverter.cxx b/chart2/source/controller/itemsetwrapper/TextLabelItemConverter.cxx index adc0b849414b..f7849456d401 100644 --- a/chart2/source/controller/itemsetwrapper/TextLabelItemConverter.cxx +++ b/chart2/source/controller/itemsetwrapper/TextLabelItemConverter.cxx @@ -268,6 +268,7 @@ bool TextLabelItemConverter::ApplySpecialItem( sal_uInt16 nWhichId, const SfxIte case SCHATTR_DATADESCR_SHOW_NUMBER: case SCHATTR_DATADESCR_SHOW_PERCENTAGE: case SCHATTR_DATADESCR_SHOW_CATEGORY: + case SCHATTR_DATADESCR_SHOW_DATA_SERIES_NAME: case SCHATTR_DATADESCR_SHOW_SYMBOL: { const SfxBoolItem& rItem = static_cast<const SfxBoolItem&>(rItemSet.Get(nWhichId)); @@ -278,7 +279,8 @@ bool TextLabelItemConverter::ApplySpecialItem( sal_uInt16 nWhichId, const SfxIte { sal_Bool& rValue = (nWhichId == SCHATTR_DATADESCR_SHOW_NUMBER) ? aLabel.ShowNumber : ( (nWhichId == SCHATTR_DATADESCR_SHOW_PERCENTAGE) ? aLabel.ShowNumberInPercent : ( - (nWhichId == SCHATTR_DATADESCR_SHOW_CATEGORY) ? aLabel.ShowCategoryName : aLabel.ShowLegendSymbol)); + (nWhichId == SCHATTR_DATADESCR_SHOW_CATEGORY) ? aLabel.ShowCategoryName : + (nWhichId == SCHATTR_DATADESCR_SHOW_DATA_SERIES_NAME) ? aLabel.ShowSeriesName : aLabel.ShowLegendSymbol)); bool bOldValue = rValue; rValue = rItem.GetValue(); if (mbDataSeries) @@ -532,6 +534,7 @@ void TextLabelItemConverter::FillSpecialItem( sal_uInt16 nWhichId, SfxItemSet& r case SCHATTR_DATADESCR_SHOW_NUMBER: case SCHATTR_DATADESCR_SHOW_PERCENTAGE: case SCHATTR_DATADESCR_SHOW_CATEGORY: + case SCHATTR_DATADESCR_SHOW_DATA_SERIES_NAME: case SCHATTR_DATADESCR_SHOW_SYMBOL: { chart2::DataPointLabel aLabel; @@ -539,7 +542,8 @@ void TextLabelItemConverter::FillSpecialItem( sal_uInt16 nWhichId, SfxItemSet& r { bool bValue = (nWhichId == SCHATTR_DATADESCR_SHOW_NUMBER) ? aLabel.ShowNumber : ( (nWhichId == SCHATTR_DATADESCR_SHOW_PERCENTAGE) ? aLabel.ShowNumberInPercent : ( - (nWhichId == SCHATTR_DATADESCR_SHOW_CATEGORY) ? aLabel.ShowCategoryName : aLabel.ShowLegendSymbol)); + (nWhichId == SCHATTR_DATADESCR_SHOW_CATEGORY) ? aLabel.ShowCategoryName : ( + (nWhichId == SCHATTR_DATADESCR_SHOW_DATA_SERIES_NAME) ? aLabel.ShowSeriesName : aLabel.ShowLegendSymbol))); rOutItemSet.Put(SfxBoolItem(nWhichId, bValue)); diff --git a/chart2/source/controller/main/ChartController_Tools.cxx b/chart2/source/controller/main/ChartController_Tools.cxx index 55b4bed88ab6..093cbcdaeac8 100644 --- a/chart2/source/controller/main/ChartController_Tools.cxx +++ b/chart2/source/controller/main/ChartController_Tools.cxx @@ -770,6 +770,7 @@ bool ChartController::executeDispatch_Delete() aLabel.ShowCategoryName = false; aLabel.ShowLegendSymbol = false; aLabel.ShowCustomLabel = false; + aLabel.ShowSeriesName = false; if( aObjectType == OBJECTTYPE_DATA_LABELS ) { uno::Reference< chart2::XDataSeries > xSeries( ObjectIdentifier::getDataSeriesForCID( aCID, getModel() )); diff --git a/chart2/source/inc/chartview/ChartSfxItemIds.hxx b/chart2/source/inc/chartview/ChartSfxItemIds.hxx index 76f9e702d85b..7ed412ce4500 100644 --- a/chart2/source/inc/chartview/ChartSfxItemIds.hxx +++ b/chart2/source/inc/chartview/ChartSfxItemIds.hxx @@ -52,7 +52,8 @@ constexpr TypedWhichId<SfxBoolItem> SCHATTR_DATADESCR_NO_PERCENTVALUE constexpr TypedWhichId<SfxBoolItem> SCHATTR_DATADESCR_CUSTOM_LEADER_LINES (SCHATTR_DATADESCR_START + 9); constexpr TypedWhichId<SfxUInt32Item> SCHATTR_PERCENT_NUMBERFORMAT_VALUE (SCHATTR_DATADESCR_START + 10); constexpr TypedWhichId<SfxBoolItem> SCHATTR_PERCENT_NUMBERFORMAT_SOURCE (SCHATTR_DATADESCR_START + 11); -constexpr sal_uInt16 SCHATTR_DATADESCR_END (SCHATTR_PERCENT_NUMBERFORMAT_SOURCE); +constexpr TypedWhichId<SfxBoolItem> SCHATTR_DATADESCR_SHOW_DATA_SERIES_NAME (SCHATTR_DATADESCR_START + 12); +constexpr sal_uInt16 SCHATTR_DATADESCR_END (SCHATTR_DATADESCR_SHOW_DATA_SERIES_NAME); //legend constexpr sal_uInt16 SCHATTR_LEGEND_START (SCHATTR_DATADESCR_END + 1); diff --git a/chart2/source/model/main/DataPointProperties.cxx b/chart2/source/model/main/DataPointProperties.cxx index dcc343002ffb..267bf9014dca 100644 --- a/chart2/source/model/main/DataPointProperties.cxx +++ b/chart2/source/model/main/DataPointProperties.cxx @@ -516,7 +516,8 @@ void DataPointProperties::AddDefaultsToMap( false, // ShowNumberInPercent false, // ShowCategoryName false, // ShowLegendSymbol - false // ShowCustomLabel + false, // ShowCustomLabel + false // ShowSeriesName )); PropertyHelper::setPropertyValueDefault( rOutMap, PROP_DATAPOINT_TEXT_WORD_WRAP, false ); diff --git a/chart2/source/tools/DataSeriesHelper.cxx b/chart2/source/tools/DataSeriesHelper.cxx index c7dabaf1d4da..9f17273c1607 100644 --- a/chart2/source/tools/DataSeriesHelper.cxx +++ b/chart2/source/tools/DataSeriesHelper.cxx @@ -171,6 +171,7 @@ void lcl_insertOrDeleteDataLabelsToSeriesAndAllPoints( const Reference< chart2:: aLabel.ShowNumberInPercent = false; aLabel.ShowCategoryName = false; aLabel.ShowCustomLabel = false; + aLabel.ShowSeriesName = false; } xPointProp->setPropertyValue(CHART_UNONAME_LABEL, uno::Any(aLabel)); xPointProp->setPropertyValue(CHART_UNONAME_CUSTOM_LABEL_FIELDS, uno::Any()); @@ -720,7 +721,8 @@ bool hasDataLabelsAtSeries( const Reference< chart2::XDataSeries >& xSeries ) { DataPointLabel aLabel; if( xProp->getPropertyValue(CHART_UNONAME_LABEL) >>= aLabel ) - bRet = aLabel.ShowNumber || aLabel.ShowNumberInPercent || aLabel.ShowCategoryName; + bRet = aLabel.ShowNumber || aLabel.ShowNumberInPercent || aLabel.ShowCategoryName + || aLabel.ShowSeriesName; } } catch(const uno::Exception &) @@ -748,7 +750,9 @@ bool hasDataLabelsAtPoints( const Reference< chart2::XDataSeries >& xSeries ) { DataPointLabel aLabel; if( xPointProp->getPropertyValue(CHART_UNONAME_LABEL) >>= aLabel ) - bRet = aLabel.ShowNumber || aLabel.ShowNumberInPercent || aLabel.ShowCategoryName || aLabel.ShowCustomLabel; + bRet = aLabel.ShowNumber || aLabel.ShowNumberInPercent + || aLabel.ShowCategoryName || aLabel.ShowCustomLabel + || aLabel.ShowSeriesName; if( bRet ) break; } @@ -786,7 +790,9 @@ bool hasDataLabelAtPoint( const Reference< chart2::XDataSeries >& xSeries, sal_I { DataPointLabel aLabel; if( xProp->getPropertyValue(CHART_UNONAME_LABEL) >>= aLabel ) - bRet = aLabel.ShowNumber || aLabel.ShowNumberInPercent || aLabel.ShowCategoryName || aLabel.ShowCustomLabel; + bRet = aLabel.ShowNumber || aLabel.ShowNumberInPercent + || aLabel.ShowCategoryName || aLabel.ShowCustomLabel + || aLabel.ShowSeriesName; } } } @@ -837,6 +843,7 @@ void deleteDataLabelsFromPoint( const Reference< beans::XPropertySet >& xPointPr aLabel.ShowNumberInPercent = false; aLabel.ShowCategoryName = false; aLabel.ShowCustomLabel = false; + aLabel.ShowSeriesName = false; xPointProp->setPropertyValue(CHART_UNONAME_LABEL, uno::Any(aLabel)); xPointProp->setPropertyValue(CHART_UNONAME_CUSTOM_LABEL_FIELDS, uno::Any()); } diff --git a/chart2/source/view/charttypes/VSeriesPlotter.cxx b/chart2/source/view/charttypes/VSeriesPlotter.cxx index 92cb3786d594..c235148a2045 100644 --- a/chart2/source/view/charttypes/VSeriesPlotter.cxx +++ b/chart2/source/view/charttypes/VSeriesPlotter.cxx @@ -497,7 +497,7 @@ uno::Reference< drawing::XShape > VSeriesPlotter::createDataLabel( const uno::Re } sal_Int32 nLineCountForSymbolsize = 0; - sal_uInt32 nTextListLength = 3; + sal_uInt32 nTextListLength = 4; sal_uInt32 nCustomLabelsCount = aCustomLabels.getLength(); Sequence< OUString > aTextList( nTextListLength ); @@ -571,9 +571,18 @@ uno::Reference< drawing::XShape > VSeriesPlotter::createDataLabel( const uno::Re aTextList[0] = getCategoryName( nPointIndex ); } + if( pLabel->ShowSeriesName ) + { + OUString aRole; + if ( m_xChartTypeModel ) + aRole = m_xChartTypeModel->getRoleOfSequenceForSeriesLabel(); + const uno::Reference< XDataSeries >& xSeries( rDataSeries.getModel() ); + aTextList[1] = DataSeriesHelper::getDataSeriesLabel( xSeries, aRole ); + } + if( pLabel->ShowNumber ) { - aTextList[1] = getLabelTextForValue(rDataSeries, nPointIndex, fValue, false); + aTextList[2] = getLabelTextForValue(rDataSeries, nPointIndex, fValue, false); } if( pLabel->ShowNumberInPercent ) @@ -584,7 +593,7 @@ uno::Reference< drawing::XShape > VSeriesPlotter::createDataLabel( const uno::Re if( fValue < 0 ) fValue*=-1.0; - aTextList[2] = getLabelTextForValue(rDataSeries, nPointIndex, fValue, true); + aTextList[3] = getLabelTextForValue(rDataSeries, nPointIndex, fValue, true); } } diff --git a/chart2/source/view/main/ChartItemPool.cxx b/chart2/source/view/main/ChartItemPool.cxx index 6af1c34c6ef6..7f67cdde45ca 100644 --- a/chart2/source/view/main/ChartItemPool.cxx +++ b/chart2/source/view/main/ChartItemPool.cxx @@ -48,6 +48,7 @@ ChartItemPool::ChartItemPool(): rPoolDefaults[SCHATTR_DATADESCR_SHOW_PERCENTAGE- SCHATTR_START] = new SfxBoolItem(SCHATTR_DATADESCR_SHOW_PERCENTAGE); rPoolDefaults[SCHATTR_DATADESCR_SHOW_CATEGORY - SCHATTR_START] = new SfxBoolItem(SCHATTR_DATADESCR_SHOW_CATEGORY); rPoolDefaults[SCHATTR_DATADESCR_SHOW_SYMBOL - SCHATTR_START] = new SfxBoolItem(SCHATTR_DATADESCR_SHOW_SYMBOL); + rPoolDefaults[SCHATTR_DATADESCR_SHOW_DATA_SERIES_NAME - SCHATTR_START] = new SfxBoolItem(SCHATTR_DATADESCR_SHOW_DATA_SERIES_NAME); rPoolDefaults[SCHATTR_DATADESCR_WRAP_TEXT - SCHATTR_START] = new SfxBoolItem(SCHATTR_DATADESCR_WRAP_TEXT); rPoolDefaults[SCHATTR_DATADESCR_SEPARATOR - SCHATTR_START] = new SfxStringItem(SCHATTR_DATADESCR_SEPARATOR," "); rPoolDefaults[SCHATTR_DATADESCR_PLACEMENT - SCHATTR_START] = new SfxInt32Item(SCHATTR_DATADESCR_PLACEMENT,0); diff --git a/chart2/source/view/main/VDataSeries.cxx b/chart2/source/view/main/VDataSeries.cxx index 35606be26fa0..545254ecfccc 100644 --- a/chart2/source/view/main/VDataSeries.cxx +++ b/chart2/source/view/main/VDataSeries.cxx @@ -995,7 +995,7 @@ DataPointLabel* VDataSeries::getDataPointLabelIfLabel( sal_Int32 index ) const { DataPointLabel* pLabel = getDataPointLabel( index ); if( !pLabel || (!pLabel->ShowNumber && !pLabel->ShowNumberInPercent - && !pLabel->ShowCategoryName && !pLabel->ShowCustomLabel ) ) + && !pLabel->ShowCategoryName && !pLabel->ShowCustomLabel && !pLabel->ShowSeriesName ) ) return nullptr; return pLabel; } diff --git a/chart2/uiconfig/ui/dlg_DataLabel.ui b/chart2/uiconfig/ui/dlg_DataLabel.ui index 17b6e70899be..1851a4f9c7d7 100644 --- a/chart2/uiconfig/ui/dlg_DataLabel.ui +++ b/chart2/uiconfig/ui/dlg_DataLabel.ui @@ -88,15 +88,14 @@ <property name="label_xalign">0</property> <property name="shadow_type">none</property> <child> - <!-- n-columns=1 n-rows=1 --> <object class="GtkGrid" id="grid1"> <property name="visible">True</property> <property name="can_focus">False</property> + <property name="margin_start">12</property> + <property name="margin_top">6</property> <property name="row_spacing">6</property> <property name="column_spacing">12</property> <property name="row_homogeneous">True</property> - <property name="margin-start">12</property> - <property name="margin-top">6</property> <child> <object class="GtkCheckButton" id="CB_VALUE_AS_NUMBER"> <property name="label" translatable="yes" context="dlg_DataLabel|CB_VALUE_AS_NUMBER">Show value as _number</property> @@ -170,7 +169,7 @@ </object> <packing> <property name="left_attach">0</property> - <property name="top_attach">3</property> + <property name="top_attach">4</property> </packing> </child> <child> @@ -184,7 +183,7 @@ </object> <packing> <property name="left_attach">0</property> - <property name="top_attach">4</property> + <property name="top_attach">5</property> </packing> </child> <child> @@ -286,7 +285,7 @@ </object> <packing> <property name="left_attach">0</property> - <property name="top_attach">5</property> + <property name="top_attach">6</property> <property name="width">2</property> </packing> </child> @@ -345,7 +344,7 @@ </object> <packing> <property name="left_attach">0</property> - <property name="top_attach">6</property> + <property name="top_attach">7</property> <property name="width">2</property> </packing> </child> @@ -360,6 +359,29 @@ </packing> </child> <child> + <object class="GtkCheckButton" id="CB_DATA_SERIES_NAME"> + <property name="label" translatable="yes" context="dlg_DataLabel|CB_DATA_SERIES_NAME">Show data _series name</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="use_underline">True</property> + <property name="xalign">0</property> + <property name="draw_indicator">True</property> + <child internal-child="accessible"> + <object class="AtkObject" id="CB_DATA_SERIES_NAME-atkobject"> + <property name="AtkObject::accessible-description" translatable="yes" context="dlg_DataLabel|extended_tip|CB_DATA_SERIES_NAME">Shows the data series name in the label.</property> + </object> + </child> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">3</property> + </packing> + </child> + <child> + <placeholder/> + </child> + <child> <placeholder/> </child> </object> @@ -392,10 +414,10 @@ <object class="GtkBox" id="box5"> <property name="visible">True</property> <property name="can_focus">False</property> + <property name="margin_start">12</property> + <property name="margin_top">6</property> <property name="orientation">vertical</property> <property name="spacing">6</property> - <property name="margin-start">12</property> - <property name="margin-top">6</property> <child> <object class="GtkBox" id="boxORIENTATION"> <property name="visible">True</property> @@ -532,9 +554,9 @@ <object class="GtkBox" id="box6"> <property name="visible">True</property> <property name="can_focus">False</property> + <property name="margin_start">12</property> + <property name="margin_top">6</property> <property name="orientation">vertical</property> - <property name="margin-start">12</property> - <property name="margin-top">6</property> <child> <object class="GtkCheckButton" id="CB_CUSTOM_LEADER_LINES"> <property name="label" translatable="yes" context="dlg_DataLabel|CB_CUSTOM_LEADER_LINES">_Connect displaced data labels to data points</property> diff --git a/chart2/uiconfig/ui/tp_DataLabel.ui b/chart2/uiconfig/ui/tp_DataLabel.ui index 86965db829b4..f02c8499d96a 100644 --- a/chart2/uiconfig/ui/tp_DataLabel.ui +++ b/chart2/uiconfig/ui/tp_DataLabel.ui @@ -20,15 +20,14 @@ <property name="label_xalign">0</property> <property name="shadow_type">none</property> <child> - <!-- n-columns=1 n-rows=1 --> <object class="GtkGrid" id="grid1"> <property name="visible">True</property> <property name="can_focus">False</property> + <property name="margin_start">12</property> + <property name="margin_top">6</property> <property name="row_spacing">6</property> <property name="column_spacing">12</property> <property name="row_homogeneous">True</property> - <property name="margin-start">12</property> - <property name="margin-top">6</property> <child> <object class="GtkCheckButton" id="CB_VALUE_AS_NUMBER"> <property name="label" translatable="yes" context="tp_DataLabel|CB_VALUE_AS_NUMBER">Show value as _number</property> @@ -102,7 +101,7 @@ </object> <packing> <property name="left_attach">0</property> - <property name="top_attach">3</property> + <property name="top_attach">4</property> </packing> </child> <child> @@ -116,7 +115,7 @@ </object> <packing> <property name="left_attach">0</property> - <property name="top_attach">4</property> + <property name="top_attach">5</property> </packing> </child> <child> @@ -218,7 +217,7 @@ </object> <packing> <property name="left_attach">0</property> - <property name="top_attach">5</property> + <property name="top_attach">6</property> <property name="width">2</property> </packing> </child> @@ -277,7 +276,7 @@ </object> <packing> <property name="left_attach">0</property> - <property name="top_attach">6</property> + <property name="top_attach">7</property> <property name="width">2</property> </packing> </child> @@ -292,6 +291,29 @@ </packing> </child> <child> + <object class="GtkCheckButton" id="CB_DATA_SERIES_NAME"> + <property name="label" translatable="yes" context="tp_DataLabel|CB_DATA_SERIES_NAME">Show data _series name</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="use_underline">True</property> + <property name="xalign">0</property> + <property name="draw_indicator">True</property> + <child internal-child="accessible"> + <object class="AtkObject" id="CB_DATA_SERIES_NAME-atkobject"> + <property name="AtkObject::accessible-description" translatable="yes" context="tp_DataLabel|extended_tip|CB_DATA_SERIES_NAME">Shows the data series name in the label.</property> + </object> + </child> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">3</property> + </packing> + </child> + <child> + <placeholder/> + </child> + <child> <placeholder/> </child> </object> @@ -324,10 +346,10 @@ <object class="GtkBox" id="box5"> <property name="visible">True</property> <property name="can_focus">False</property> + <property name="margin_start">12</property> + <property name="margin_top">6</property> <property name="orientation">vertical</property> <property name="spacing">6</property> - <property name="margin-start">12</property> - <property name="margin-top">6</property> <child> <object class="GtkBox" id="boxORIENTATION"> <property name="visible">True</property> @@ -464,9 +486,9 @@ <object class="GtkBox" id="box6"> <property name="visible">True</property> <property name="can_focus">False</property> + <property name="margin_start">12</property> + <property name="margin_top">6</property> <property name="orientation">vertical</property> - <property name="margin-start">12</property> - <property name="margin-top">6</property> <child> <object class="GtkCheckButton" id="CB_CUSTOM_LEADER_LINES"> <property name="label" translatable="yes" context="tp_DataLabel|CB_CUSTOM_LEADER_LINES">_Connect displaced data labels to data points</property> |