diff options
author | Marco Cecchetti <marco.cecchetti@collabora.com> | 2015-07-31 22:14:41 +0200 |
---|---|---|
committer | Andras Timar <andras.timar@collabora.com> | 2015-10-07 09:07:48 +0000 |
commit | d52d448e7b34cb8c2457948489e6691049f4a571 (patch) | |
tree | 81cd0bb8391d32a243229c87f97ba4fb2ffd92d3 /chart2/source | |
parent | 6dd8193524a8a0208d7b424e396095f8e409cbc5 (diff) |
tdf#88154 workaround and unit test
Fixed 45-degree layout for axis labels, too.
Change-Id: I9764e281aeee0a439fa9eec1e3b0df840221b72f
Reviewed-on: https://gerrit.libreoffice.org/18889
Reviewed-by: Jan Holesovsky <kendy@collabora.com>
Tested-by: Jan Holesovsky <kendy@collabora.com>
Diffstat (limited to 'chart2/source')
-rw-r--r-- | chart2/source/controller/chartapiwrapper/AxisWrapper.cxx | 13 | ||||
-rw-r--r-- | chart2/source/model/main/Axis.cxx | 15 | ||||
-rw-r--r-- | chart2/source/view/axes/VAxisProperties.cxx | 7 | ||||
-rw-r--r-- | chart2/source/view/axes/VAxisProperties.hxx | 5 | ||||
-rw-r--r-- | chart2/source/view/axes/VCartesianAxis.cxx | 23 |
5 files changed, 52 insertions, 11 deletions
diff --git a/chart2/source/controller/chartapiwrapper/AxisWrapper.cxx b/chart2/source/controller/chartapiwrapper/AxisWrapper.cxx index 6abfbf48f429..2cc97cebc91d 100644 --- a/chart2/source/controller/chartapiwrapper/AxisWrapper.cxx +++ b/chart2/source/controller/chartapiwrapper/AxisWrapper.cxx @@ -102,7 +102,8 @@ enum PROP_AXIS_OVERLAP, PROP_AXIS_GAP_WIDTH, PROP_AXIS_DISPLAY_UNITS, - PROP_AXIS_BUILTINUNIT + PROP_AXIS_BUILTINUNIT, + PROP_AXIS_TRY_STAGGERING_FIRST }; void lcl_AddPropertiesToVector( @@ -356,6 +357,15 @@ void lcl_AddPropertiesToVector( cppu::UnoType<OUString>::get(), beans::PropertyAttribute::BOUND | beans::PropertyAttribute::MAYBEDEFAULT )); + + // Compatibility option: starting from LibreOffice 5.1 the rotated + // layout is preferred to staggering for axis labels. + rOutProperties.push_back( + Property( "TryStaggeringFirst", + PROP_AXIS_TRY_STAGGERING_FIRST, + cppu::UnoType<bool>::get(), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::MAYBEDEFAULT )); } struct StaticAxisWrapperPropertyArray_Initializer @@ -656,6 +666,7 @@ const std::vector< WrappedProperty* > AxisWrapper::createWrappedProperties() aWrappedProperties.push_back( new WrappedProperty("ArrangeOrder","ArrangeOrder") ); aWrappedProperties.push_back( new WrappedProperty("Visible","Show") ); aWrappedProperties.push_back( new WrappedDirectStateProperty("DisplayLabels","DisplayLabels") ); + aWrappedProperties.push_back( new WrappedDirectStateProperty("TryStaggeringFirst","TryStaggeringFirst") ); aWrappedProperties.push_back( new WrappedDirectStateProperty("TextBreak","TextBreak") ); aWrappedProperties.push_back( new WrappedNumberFormatProperty(m_spChart2ModelContact) ); aWrappedProperties.push_back( new WrappedLinkNumberFormatProperty(m_spChart2ModelContact) ); diff --git a/chart2/source/model/main/Axis.cxx b/chart2/source/model/main/Axis.cxx index 7fcaaec81eef..79855d68ac44 100644 --- a/chart2/source/model/main/Axis.cxx +++ b/chart2/source/model/main/Axis.cxx @@ -83,7 +83,9 @@ enum PROP_AXIS_MARK_POSITION, PROP_AXIS_DISPLAY_UNITS, - PROP_AXIS_BUILTINUNIT + PROP_AXIS_BUILTINUNIT, + + PROP_AXIS_TRY_STAGGERING_FIRST }; void lcl_AddPropertiesToVector( @@ -210,6 +212,16 @@ void lcl_AddPropertiesToVector( cppu::UnoType<OUString>::get(), beans::PropertyAttribute::BOUND | beans::PropertyAttribute::MAYBEDEFAULT )); + + // Compatibility option: starting from LibreOffice 5.1 the rotated + // layout is preferred to staggering for axis labels. + rOutProperties.push_back( + Property( "TryStaggeringFirst", + PROP_AXIS_TRY_STAGGERING_FIRST, + cppu::UnoType<bool>::get(), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::MAYBEDEFAULT )); + } struct StaticAxisDefaults_Initializer @@ -246,6 +258,7 @@ private: ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, PROP_AXIS_MINOR_TICKMARKS, 0 /* CHAXIS_MARK_NONE */ ); ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_AXIS_MARK_POSITION, ::com::sun::star::chart::ChartAxisMarkPosition_AT_LABELS_AND_AXIS ); ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_AXIS_DISPLAY_UNITS, false ); + ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_AXIS_TRY_STAGGERING_FIRST, false ); } }; diff --git a/chart2/source/view/axes/VAxisProperties.cxx b/chart2/source/view/axes/VAxisProperties.cxx index 3db365d5b04f..85721ada8309 100644 --- a/chart2/source/view/axes/VAxisProperties.cxx +++ b/chart2/source/view/axes/VAxisProperties.cxx @@ -164,6 +164,7 @@ AxisProperties::AxisProperties( const uno::Reference< XAxis >& xAxisModel , m_bCrossingAxisHasReverseDirection(false) , m_bCrossingAxisIsCategoryAxes(false) , m_bDisplayLabels( true ) + , m_bTryStaggeringFirst( false ) , m_nNumberFormatKey(0) , m_nMajorTickmarks(1) , m_nMinorTickmarks(1) @@ -189,6 +190,7 @@ AxisProperties::AxisProperties( const AxisProperties& rAxisProperties ) , m_bCrossingAxisIsCategoryAxes( rAxisProperties.m_bCrossingAxisIsCategoryAxes ) , maLabelAlignment( rAxisProperties.maLabelAlignment ) , m_bDisplayLabels( rAxisProperties.m_bDisplayLabels ) + , m_bTryStaggeringFirst( rAxisProperties.m_bTryStaggeringFirst ) , m_nNumberFormatKey( rAxisProperties.m_nNumberFormatKey ) , m_nMajorTickmarks( rAxisProperties.m_nMajorTickmarks ) , m_nMinorTickmarks( rAxisProperties.m_nMinorTickmarks ) @@ -331,6 +333,11 @@ void AxisProperties::init( bool bCartesian ) //init display labels xProp->getPropertyValue( "DisplayLabels" ) >>= m_bDisplayLabels; + // Init layout strategy hint for axis labels. + // Compatibility option: starting from LibreOffice 5.1 the rotated + // layout is preferred to staggering for axis labels. + xProp->getPropertyValue( "TryStaggeringFirst" ) >>= m_bTryStaggeringFirst; + //init TickmarkProperties xProp->getPropertyValue( "MajorTickmarks" ) >>= m_nMajorTickmarks; xProp->getPropertyValue( "MinorTickmarks" ) >>= m_nMinorTickmarks; diff --git a/chart2/source/view/axes/VAxisProperties.hxx b/chart2/source/view/axes/VAxisProperties.hxx index 1eadf707d8bd..039bd1cb1166 100644 --- a/chart2/source/view/axes/VAxisProperties.hxx +++ b/chart2/source/view/axes/VAxisProperties.hxx @@ -118,6 +118,11 @@ struct AxisProperties SAL_FINAL bool m_bDisplayLabels; + // Compatibility option: starting from LibreOffice 5.1 the rotated + // layout is preferred to staggering for axis labels. + // So the default value of this flag for new documents is `false`. + bool m_bTryStaggeringFirst; + sal_Int32 m_nNumberFormatKey; /* diff --git a/chart2/source/view/axes/VCartesianAxis.cxx b/chart2/source/view/axes/VCartesianAxis.cxx index a8022b355812..46feff4866d9 100644 --- a/chart2/source/view/axes/VCartesianAxis.cxx +++ b/chart2/source/view/axes/VCartesianAxis.cxx @@ -825,15 +825,20 @@ bool VCartesianAxis::createTextShapes( bool bOverlapsAfterAutoStagger = true; if( !bIsStaggered && isAutoStaggeringOfLabelsAllowed( rAxisLabelProperties, bIsHorizontalAxis, bIsVerticalAxis ) ) { - bIsStaggered = true; - rAxisLabelProperties.eStaggering = STAGGER_EVEN; - pLastVisibleNeighbourTickInfo = pPREPreviousVisibleTickInfo; - if( !pLastVisibleNeighbourTickInfo || - !lcl_doesShapeOverlapWithTickmark( pLastVisibleNeighbourTickInfo->xTextShape - , rAxisLabelProperties.fRotationAngleDegree - , pTickInfo->aTickScreenPosition - , bIsHorizontalAxis, bIsVerticalAxis ) ) - bOverlapsAfterAutoStagger = false; + // Compatibility option: starting from LibreOffice 5.1 the rotated + // layout is preferred to staggering for axis labels. + if( m_aAxisProperties.m_bTryStaggeringFirst || !(::rtl::math::approxEqual( rAxisLabelProperties.fRotationAngleDegree, 0.0 ) ) ) + { + bIsStaggered = true; + rAxisLabelProperties.eStaggering = STAGGER_EVEN; + pLastVisibleNeighbourTickInfo = pPREPreviousVisibleTickInfo; + if( !pLastVisibleNeighbourTickInfo || + !lcl_doesShapeOverlapWithTickmark( pLastVisibleNeighbourTickInfo->xTextShape + , rAxisLabelProperties.fRotationAngleDegree + , pTickInfo->aTickScreenPosition + , bIsHorizontalAxis, bIsVerticalAxis ) ) + bOverlapsAfterAutoStagger = false; + } } if (bOverlapsAfterAutoStagger) |