diff options
author | Balazs Varga <balazs.varga991@gmail.com> | 2020-09-08 10:21:33 +0200 |
---|---|---|
committer | László Németh <nemeth@numbertext.org> | 2020-09-15 09:57:54 +0200 |
commit | 28b53da4c49b2dc8550f28b07183fb7c60e1c298 (patch) | |
tree | 657e60ce2c1ad6f5efaff61ba43e6d71e20661c2 /chart2/source | |
parent | 4ef697e670aaa7cac547846ac961e6d26aac816d (diff) |
tdf#133227 chart UI: option to hide leader lines
between data points and displaced data labels of a data series.
Follow-up of the following commits related to the new UNO property
ShowCustomLeaderLines for data labels:
commit e2f4e65a7b8024c00b049eebf0d87637efda7f24
(tdf#134571 chart2, xmloff: add loext:custom-leader-lines)
commit 5d67d70b26706ce8a08612c12a68821f984210a2
(tdf#134563 Add UNO API for custom leader lines)
Change-Id: Id8a953b16ff737ca924c0c2c3241fba4e3ac904b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102221
Tested-by: László Németh <nemeth@numbertext.org>
Reviewed-by: László Németh <nemeth@numbertext.org>
Diffstat (limited to 'chart2/source')
7 files changed, 85 insertions, 3 deletions
diff --git a/chart2/source/controller/dialogs/res_DataLabel.cxx b/chart2/source/controller/dialogs/res_DataLabel.cxx index 35f96f775e01..62568fc71296 100644 --- a/chart2/source/controller/dialogs/res_DataLabel.cxx +++ b/chart2/source/controller/dialogs/res_DataLabel.cxx @@ -111,6 +111,7 @@ DataLabelResources::DataLabelResources(weld::Builder* pBuilder, weld::Window* pP , m_xLB_TextDirection(new TextDirectionListBox(pBuilder->weld_combo_box("LB_LABEL_TEXTDIR"))) , m_xDC_Dial(new svx::DialControl) , m_xDC_DialWin(new weld::CustomWeld(*pBuilder, "CT_DIAL", *m_xDC_Dial)) + , m_xCBCustomLeaderLines(pBuilder->weld_check_button("CB_CUSTOM_LEADER_LINES")) { m_xDC_Dial->SetText(m_xFT_Dial->get_label()); @@ -143,6 +144,7 @@ DataLabelResources::DataLabelResources(weld::Builder* pBuilder, weld::Window* pP m_xCBCategory->connect_toggled( LINK( this, DataLabelResources, CheckHdl )); m_xCBSymbol->connect_toggled( LINK( this, DataLabelResources, CheckHdl )); m_xCBWrapText->connect_toggled( LINK( this, DataLabelResources, CheckHdl )); + m_xCBCustomLeaderLines->connect_toggled( LINK( this, DataLabelResources, CheckHdl )); m_bNumberFormatMixedState = !lcl_ReadNumberFormatFromItemSet( rInAttrs, SID_ATTR_NUMBERFORMAT_VALUE, SID_ATTR_NUMBERFORMAT_SOURCE, m_nNumberFormatForValue, m_bSourceFormatForValue, m_bSourceFormatMixedState ); m_bPercentFormatMixedState = !lcl_ReadNumberFormatFromItemSet( rInAttrs, SCHATTR_PERCENT_NUMBERFORMAT_VALUE, SCHATTR_PERCENT_NUMBERFORMAT_SOURCE, m_nNumberFormatForPercent, m_bSourceFormatForPercent , m_bPercentSourceMixedState); @@ -280,6 +282,8 @@ void DataLabelResources::FillItemSet( SfxItemSet* rOutAttrs ) const rOutAttrs->Put( SfxBoolItem( SCHATTR_DATADESCR_SHOW_SYMBOL, m_xCBSymbol->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 ) + rOutAttrs->Put(SfxBoolItem( SCHATTR_DATADESCR_CUSTOM_LEADER_LINES, m_xCBCustomLeaderLines->get_active()) ); auto const aSep = our_aLBEntryMap[m_xLB_Separator->get_active()]; rOutAttrs->Put( SfxStringItem( SCHATTR_DATADESCR_SEPARATOR, aSep) ); @@ -311,6 +315,7 @@ void DataLabelResources::Reset(const SfxItemSet& rInAttrs) lcl_setBoolItemToCheckBox( rInAttrs, SCHATTR_DATADESCR_SHOW_CATEGORY, *m_xCBCategory ); lcl_setBoolItemToCheckBox( rInAttrs, SCHATTR_DATADESCR_SHOW_SYMBOL, *m_xCBSymbol ); lcl_setBoolItemToCheckBox( rInAttrs, SCHATTR_DATADESCR_WRAP_TEXT, *m_xCBWrapText ); + lcl_setBoolItemToCheckBox( rInAttrs, SCHATTR_DATADESCR_CUSTOM_LEADER_LINES, *m_xCBCustomLeaderLines ); m_bNumberFormatMixedState = !lcl_ReadNumberFormatFromItemSet( rInAttrs, SID_ATTR_NUMBERFORMAT_VALUE, SID_ATTR_NUMBERFORMAT_SOURCE, m_nNumberFormatForValue, m_bSourceFormatForValue, m_bSourceFormatMixedState ); m_bPercentFormatMixedState = !lcl_ReadNumberFormatFromItemSet( rInAttrs, SCHATTR_PERCENT_NUMBERFORMAT_VALUE, SCHATTR_PERCENT_NUMBERFORMAT_SOURCE, m_nNumberFormatForPercent, m_bSourceFormatForPercent , m_bPercentSourceMixedState); diff --git a/chart2/source/controller/dialogs/res_DataLabel.hxx b/chart2/source/controller/dialogs/res_DataLabel.hxx index f926d45c0d42..5358c0345495 100644 --- a/chart2/source/controller/dialogs/res_DataLabel.hxx +++ b/chart2/source/controller/dialogs/res_DataLabel.hxx @@ -83,6 +83,8 @@ private: std::unique_ptr<svx::DialControl> m_xDC_Dial; std::unique_ptr<weld::CustomWeld> m_xDC_DialWin; + std::unique_ptr<weld::CheckButton> m_xCBCustomLeaderLines; + DECL_LINK(NumberFormatDialogHdl, weld::Button&, void ); DECL_LINK(CheckHdl, weld::ToggleButton&, void ); void EnableControls(); diff --git a/chart2/source/controller/inc/TextLabelItemConverter.hxx b/chart2/source/controller/inc/TextLabelItemConverter.hxx index 0f5cfb0175d1..ebe1b3961d89 100644 --- a/chart2/source/controller/inc/TextLabelItemConverter.hxx +++ b/chart2/source/controller/inc/TextLabelItemConverter.hxx @@ -63,6 +63,8 @@ private: bool mbDataSeries:1; bool mbForbidPercentValue:1; + + css::uno::Reference<css::chart2::XDataSeries> m_xSeries; }; } diff --git a/chart2/source/controller/itemsetwrapper/DataPointItemConverter.cxx b/chart2/source/controller/itemsetwrapper/DataPointItemConverter.cxx index 4920d2b727e0..6328a222b622 100644 --- a/chart2/source/controller/itemsetwrapper/DataPointItemConverter.cxx +++ b/chart2/source/controller/itemsetwrapper/DataPointItemConverter.cxx @@ -581,6 +581,26 @@ bool DataPointItemConverter::ApplySpecialItem( } } break; + + case SCHATTR_DATADESCR_CUSTOM_LEADER_LINES: + { + try + { + bool bNew = static_cast<const SfxBoolItem&>(rItemSet.Get(nWhichId)).GetValue(); + bool bOld = true; + Reference<beans::XPropertySet> xSeriesProp(m_xSeries, uno::UNO_QUERY); + if( (xSeriesProp->getPropertyValue("ShowCustomLeaderLines") >>= bOld) && bOld != bNew ) + { + xSeriesProp->setPropertyValue("ShowCustomLeaderLines", uno::Any(bNew)); + bChanged = true; + } + } + catch (const uno::Exception&) + { + TOOLS_WARN_EXCEPTION("chart2", ""); + } + } + break; } return bChanged; @@ -728,6 +748,22 @@ void DataPointItemConverter::FillSpecialItem( } break; + case SCHATTR_DATADESCR_CUSTOM_LEADER_LINES: + { + try + { + bool bValue = true; + Reference<beans::XPropertySet> xSeriesProp(m_xSeries, uno::UNO_QUERY); + if( xSeriesProp->getPropertyValue( "ShowCustomLeaderLines" ) >>= bValue ) + rOutItemSet.Put(SfxBoolItem(nWhichId, bValue)); + } + catch (const uno::Exception&) + { + TOOLS_WARN_EXCEPTION("chart2", ""); + } + } + break; + case SCHATTR_STYLE_SYMBOL: { chart2::Symbol aSymbol; diff --git a/chart2/source/controller/itemsetwrapper/TextLabelItemConverter.cxx b/chart2/source/controller/itemsetwrapper/TextLabelItemConverter.cxx index 496b25e2692f..bdeffbf6cf3c 100644 --- a/chart2/source/controller/itemsetwrapper/TextLabelItemConverter.cxx +++ b/chart2/source/controller/itemsetwrapper/TextLabelItemConverter.cxx @@ -201,7 +201,8 @@ TextLabelItemConverter::TextLabelItemConverter( mnNumberFormat(nNumberFormat), mnPercentNumberFormat(nPercentNumberFormat), mbDataSeries(bDataSeries), - mbForbidPercentValue(true) + mbForbidPercentValue(true), + m_xSeries(xSeries) { maConverters.emplace_back(new CharacterPropertyItemConverter(rPropertySet, rItemPool, pRefSize, "ReferencePageSize")); @@ -498,6 +499,25 @@ bool TextLabelItemConverter::ApplySpecialItem( sal_uInt16 nWhichId, const SfxIte } } break; + case SCHATTR_DATADESCR_CUSTOM_LEADER_LINES: + { + try + { + bool bNew = static_cast<const SfxBoolItem&>(rItemSet.Get(nWhichId)).GetValue(); + bool bOld = true; + Reference<beans::XPropertySet> xSeriesProp(m_xSeries, uno::UNO_QUERY); + if( (xSeriesProp->getPropertyValue("ShowCustomLeaderLines") >>= bOld) && bOld != bNew ) + { + xSeriesProp->setPropertyValue("ShowCustomLeaderLines", uno::Any(bNew)); + bChanged = true; + } + } + catch (const uno::Exception&) + { + TOOLS_WARN_EXCEPTION("chart2", ""); + } + } + break; } return bChanged; @@ -635,6 +655,21 @@ void TextLabelItemConverter::FillSpecialItem( sal_uInt16 nWhichId, SfxItemSet& r rOutItemSet.Put(SfxBoolItem(nWhichId, mbForbidPercentValue)); } break; + case SCHATTR_DATADESCR_CUSTOM_LEADER_LINES: + { + try + { + bool bValue = true; + Reference<beans::XPropertySet> xSeriesProp(m_xSeries, uno::UNO_QUERY); + if( xSeriesProp->getPropertyValue( "ShowCustomLeaderLines" ) >>= bValue ) + rOutItemSet.Put(SfxBoolItem(nWhichId, bValue)); + } + catch (const uno::Exception&) + { + TOOLS_WARN_EXCEPTION("chart2", ""); + } + } + break; case SCHATTR_STYLE_SYMBOL: { chart2::Symbol aSymbol; diff --git a/chart2/source/inc/chartview/ChartSfxItemIds.hxx b/chart2/source/inc/chartview/ChartSfxItemIds.hxx index ac3e91fa187d..9d0e4f9aa896 100644 --- a/chart2/source/inc/chartview/ChartSfxItemIds.hxx +++ b/chart2/source/inc/chartview/ChartSfxItemIds.hxx @@ -48,8 +48,9 @@ constexpr TypedWhichId<SfxStringItem> SCHATTR_DATADESCR_SEPARATOR constexpr TypedWhichId<SfxInt32Item> SCHATTR_DATADESCR_PLACEMENT (SCHATTR_DATADESCR_START + 6); constexpr TypedWhichId<SfxIntegerListItem> SCHATTR_DATADESCR_AVAILABLE_PLACEMENTS (SCHATTR_DATADESCR_START + 7); constexpr TypedWhichId<SfxBoolItem> SCHATTR_DATADESCR_NO_PERCENTVALUE (SCHATTR_DATADESCR_START + 8); //percentage values should not be offered -constexpr TypedWhichId<SfxUInt32Item> SCHATTR_PERCENT_NUMBERFORMAT_VALUE (SCHATTR_DATADESCR_START + 9); -constexpr TypedWhichId<SfxBoolItem> SCHATTR_PERCENT_NUMBERFORMAT_SOURCE (SCHATTR_DATADESCR_START + 10); +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); //legend diff --git a/chart2/source/view/main/ChartItemPool.cxx b/chart2/source/view/main/ChartItemPool.cxx index 7e428942f0db..4275ebd09b94 100644 --- a/chart2/source/view/main/ChartItemPool.cxx +++ b/chart2/source/view/main/ChartItemPool.cxx @@ -52,6 +52,7 @@ ChartItemPool::ChartItemPool(): rPoolDefaults[SCHATTR_DATADESCR_PLACEMENT - SCHATTR_START] = new SfxInt32Item(SCHATTR_DATADESCR_PLACEMENT,0); rPoolDefaults[SCHATTR_DATADESCR_AVAILABLE_PLACEMENTS - SCHATTR_START] = new SfxIntegerListItem(SCHATTR_DATADESCR_AVAILABLE_PLACEMENTS, std::vector < sal_Int32 >() ); rPoolDefaults[SCHATTR_DATADESCR_NO_PERCENTVALUE - SCHATTR_START] = new SfxBoolItem(SCHATTR_DATADESCR_NO_PERCENTVALUE); + rPoolDefaults[SCHATTR_DATADESCR_CUSTOM_LEADER_LINES - SCHATTR_START] = new SfxBoolItem(SCHATTR_DATADESCR_CUSTOM_LEADER_LINES, true); rPoolDefaults[SCHATTR_PERCENT_NUMBERFORMAT_VALUE - SCHATTR_START] = new SfxUInt32Item(SCHATTR_PERCENT_NUMBERFORMAT_VALUE, 0); rPoolDefaults[SCHATTR_PERCENT_NUMBERFORMAT_SOURCE - SCHATTR_START] = new SfxBoolItem(SCHATTR_PERCENT_NUMBERFORMAT_SOURCE); |