diff options
author | Marco Cecchetti <marco.cecchetti@collabora.com> | 2015-07-19 18:18:00 +0200 |
---|---|---|
committer | Andras Timar <andras.timar@collabora.com> | 2015-09-09 07:41:51 +0000 |
commit | 9ed1dd01be8afa0961e388a79e9ff4c1235820c2 (patch) | |
tree | 366cad6bae91e791be462e4c03f499ab0ba3e2f2 /chart2/source/controller | |
parent | 79bc956e7f44b762bfd6560e5a9c9812fa3dcf4d (diff) |
tdf#90839: support for wrapped text in data labels and for centered data value
Now in a pie chart the text of a label can be wrapped, the wrapping is
automatic and the maximum text width is fixed to almost half the pie
radius. This feature is used to import correctly the relative text
wrapping property provided by MSO.
Moreover the data value and percent value of a label are now centered
horizontally, respect with the label text.
Conflicts:
chart2/qa/extras/xshape/chart2xshape.cxx
Change-Id: Ie10d6184365436f763cd9693a5bbefcfa9b3862b
Reviewed-on: https://gerrit.libreoffice.org/17193
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Andras Timar <andras.timar@collabora.com>
Diffstat (limited to 'chart2/source/controller')
5 files changed, 107 insertions, 0 deletions
diff --git a/chart2/source/controller/chartapiwrapper/DataSeriesPointWrapper.cxx b/chart2/source/controller/chartapiwrapper/DataSeriesPointWrapper.cxx index 4c6c5b563d28..2b6c2da72882 100644 --- a/chart2/source/controller/chartapiwrapper/DataSeriesPointWrapper.cxx +++ b/chart2/source/controller/chartapiwrapper/DataSeriesPointWrapper.cxx @@ -81,6 +81,7 @@ enum PROP_SERIES_NUMBERFORMAT, PROP_SERIES_LINK_NUMBERFORMAT_TO_SOURCE, PROP_SERIES_PERCENTAGE_NUMBERFORMAT, + PROP_SERIES_DATAPOINT_TEXT_WORD_WRAP, PROP_SERIES_DATAPOINT_LABEL_PLACEMENT, //other series properties PROP_SERIES_ATTACHED_AXIS, @@ -138,6 +139,13 @@ void lcl_AddPropertiesToVector_PointProperties( | beans::PropertyAttribute::MAYBEVOID )); rOutProperties.push_back( + Property( "TextWordWrap", + PROP_SERIES_DATAPOINT_TEXT_WORD_WRAP, + cppu::UnoType<bool>::get(), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::MAYBEVOID )); + + rOutProperties.push_back( Property( "LabelPlacement", PROP_SERIES_DATAPOINT_LABEL_PLACEMENT, cppu::UnoType<sal_Int32>::get(), diff --git a/chart2/source/controller/dialogs/res_DataLabel.cxx b/chart2/source/controller/dialogs/res_DataLabel.cxx index 0c532e081d9f..591b8fa3bf51 100644 --- a/chart2/source/controller/dialogs/res_DataLabel.cxx +++ b/chart2/source/controller/dialogs/res_DataLabel.cxx @@ -105,6 +105,7 @@ DataLabelResources::DataLabelResources(VclBuilderContainer* pWindow, vcl::Window pWindow->get(m_pFT_NumberFormatForPercent,"STR_DLG_NUMBERFORMAT_FOR_PERCENTAGE_VALUE"); pWindow->get(m_pCBCategory, "CB_CATEGORY"); pWindow->get(m_pCBSymbol, "CB_SYMBOL"); + pWindow->get(m_pCBWrapText, "CB_WRAP_TEXT"); pWindow->get(m_pBxLabelPlacement, "boxPLACEMENT"); pWindow->get(m_pLB_LabelPlacement, "LB_LABEL_PLACEMENT"); @@ -155,6 +156,7 @@ DataLabelResources::DataLabelResources(VclBuilderContainer* pWindow, vcl::Window m_pCBPercent->SetClickHdl( LINK( this, DataLabelResources, CheckHdl )); m_pCBCategory->SetClickHdl( LINK( this, DataLabelResources, CheckHdl )); m_pCBSymbol->SetClickHdl( LINK( this, DataLabelResources, CheckHdl )); + m_pCBWrapText->SetClickHdl( 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); @@ -238,6 +240,9 @@ void DataLabelResources::EnableControls() m_pCBSymbol->Enable( m_pCBNumber->IsChecked() || (m_pCBPercent->IsChecked() && m_pCBPercent->IsEnabled()) || m_pCBCategory->IsChecked() ); + m_pCBWrapText->Enable( m_pCBNumber->IsChecked() || (m_pCBPercent->IsChecked() && m_pCBPercent->IsEnabled()) + || m_pCBCategory->IsChecked() ); + // Enable or disable separator, placement and direction based on the check // box states. Note that the check boxes are tri-state. { @@ -289,6 +294,8 @@ bool DataLabelResources::FillItemSet( SfxItemSet* rOutAttrs ) const rOutAttrs->Put( SfxBoolItem( SCHATTR_DATADESCR_SHOW_CATEGORY, m_pCBCategory->IsChecked() ) ); if( m_pCBSymbol->GetState()!= TRISTATE_INDET ) rOutAttrs->Put( SfxBoolItem( SCHATTR_DATADESCR_SHOW_SYMBOL, m_pCBSymbol->IsChecked()) ); + if( m_pCBSymbol->GetState()!= TRISTATE_INDET ) + rOutAttrs->Put( SfxBoolItem( SCHATTR_DATADESCR_WRAP_TEXT, m_pCBWrapText->IsChecked()) ); OUString aSep = m_aEntryMap[m_pLB_Separator->GetSelectEntryPos()]; rOutAttrs->Put( SfxStringItem( SCHATTR_DATADESCR_SEPARATOR, aSep) ); @@ -321,6 +328,7 @@ void DataLabelResources::Reset(const SfxItemSet& rInAttrs) lcl_setBoolItemToCheckBox( rInAttrs, SCHATTR_DATADESCR_SHOW_PERCENTAGE, *m_pCBPercent ); lcl_setBoolItemToCheckBox( rInAttrs, SCHATTR_DATADESCR_SHOW_CATEGORY, *m_pCBCategory ); lcl_setBoolItemToCheckBox( rInAttrs, SCHATTR_DATADESCR_SHOW_SYMBOL, *m_pCBSymbol ); + lcl_setBoolItemToCheckBox( rInAttrs, SCHATTR_DATADESCR_WRAP_TEXT, *m_pCBWrapText ); 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 acfc93a30dde..e716320072dc 100644 --- a/chart2/source/controller/dialogs/res_DataLabel.hxx +++ b/chart2/source/controller/dialogs/res_DataLabel.hxx @@ -52,6 +52,7 @@ private: VclPtr<FixedText> m_pFT_NumberFormatForPercent; VclPtr<CheckBox> m_pCBCategory; VclPtr<CheckBox> m_pCBSymbol; + VclPtr<CheckBox> m_pCBWrapText; VclPtr<VclHBox> m_pSeparatorResources; VclPtr<ListBox> m_pLB_Separator; diff --git a/chart2/source/controller/itemsetwrapper/DataPointItemConverter.cxx b/chart2/source/controller/itemsetwrapper/DataPointItemConverter.cxx index 6c3e874afe64..b3e9bd271dcb 100644 --- a/chart2/source/controller/itemsetwrapper/DataPointItemConverter.cxx +++ b/chart2/source/controller/itemsetwrapper/DataPointItemConverter.cxx @@ -376,6 +376,37 @@ bool DataPointItemConverter::ApplySpecialItem( } break; + case SCHATTR_DATADESCR_WRAP_TEXT: + { + + try + { + bool bNew = static_cast< const SfxBoolItem & >( rItemSet.Get( nWhichId )).GetValue(); + bool bOld = false; + GetPropertySet()->getPropertyValue( "TextWordWrap" ) >>= bOld; + if( m_bOverwriteLabelsForAttributedDataPointsAlso ) + { + Reference< chart2::XDataSeries > xSeries( GetPropertySet(), uno::UNO_QUERY); + if( bOld!=bNew || + DataSeriesHelper::hasAttributedDataPointDifferentValue( xSeries, "TextWordWrap", uno::makeAny( bOld ) ) ) + { + DataSeriesHelper::setPropertyAlsoToAllAttributedDataPoints( xSeries, "TextWordWrap", uno::makeAny( bNew ) ); + bChanged = true; + } + } + else if( bOld!=bNew ) + { + GetPropertySet()->setPropertyValue( "TextWordWrap", uno::makeAny( bNew )); + bChanged = true; + } + } + catch( const uno::Exception& e ) + { + ASSERT_EXCEPTION( e ); + } + } + break; + case SCHATTR_DATADESCR_PLACEMENT: { @@ -596,6 +627,21 @@ void DataPointItemConverter::FillSpecialItem( } break; + case SCHATTR_DATADESCR_WRAP_TEXT: + { + bool bValue = false; + try + { + GetPropertySet()->getPropertyValue( "TextWordWrap" ) >>= bValue; + rOutItemSet.Put( SfxBoolItem( nWhichId, bValue )); + } + catch( const uno::Exception& e ) + { + ASSERT_EXCEPTION( e ); + } + } + break; + case SCHATTR_DATADESCR_PLACEMENT: { try diff --git a/chart2/source/controller/itemsetwrapper/TextLabelItemConverter.cxx b/chart2/source/controller/itemsetwrapper/TextLabelItemConverter.cxx index faee4a61d291..2731f709bbaf 100644 --- a/chart2/source/controller/itemsetwrapper/TextLabelItemConverter.cxx +++ b/chart2/source/controller/itemsetwrapper/TextLabelItemConverter.cxx @@ -335,6 +335,36 @@ bool TextLabelItemConverter::ApplySpecialItem( sal_uInt16 nWhichId, const SfxIte } } break; + case SCHATTR_DATADESCR_WRAP_TEXT: + { + + try + { + bool bNew = static_cast< const SfxBoolItem & >( rItemSet.Get( nWhichId )).GetValue(); + bool bOld = false; + GetPropertySet()->getPropertyValue( "TextWordWrap" ) >>= bOld; + if( mbDataSeries ) + { + Reference< chart2::XDataSeries > xSeries( GetPropertySet(), uno::UNO_QUERY); + if( bOld!=bNew || + DataSeriesHelper::hasAttributedDataPointDifferentValue( xSeries, "TextWordWrap", uno::makeAny( bOld ) ) ) + { + DataSeriesHelper::setPropertyAlsoToAllAttributedDataPoints( xSeries, "TextWordWrap", uno::makeAny( bNew ) ); + bChanged = true; + } + } + else if( bOld!=bNew ) + { + GetPropertySet()->setPropertyValue( "TextWordWrap", uno::makeAny( bNew )); + bChanged = true; + } + } + catch( const uno::Exception& e ) + { + ASSERT_EXCEPTION( e ); + } + } + break; case SCHATTR_DATADESCR_PLACEMENT: { try @@ -544,6 +574,20 @@ void TextLabelItemConverter::FillSpecialItem( sal_uInt16 nWhichId, SfxItemSet& r } } break; + case SCHATTR_DATADESCR_WRAP_TEXT: + { + bool bValue = false; + try + { + GetPropertySet()->getPropertyValue( "TextWordWrap" ) >>= bValue; + rOutItemSet.Put( SfxBoolItem( nWhichId, bValue )); + } + catch( const uno::Exception& e ) + { + ASSERT_EXCEPTION( e ); + } + } + break; case SCHATTR_DATADESCR_PLACEMENT: { try |