diff options
author | Balazs Varga <balazs.varga991@gmail.com> | 2019-05-17 11:40:27 +0200 |
---|---|---|
committer | László Németh <nemeth@numbertext.org> | 2019-05-18 00:06:28 +0200 |
commit | 75ef0e41ea8a9096ac619356d2b837c5333b47e6 (patch) | |
tree | 3d5b27ef9aa05a39b4098d4bfe092ecbb26d6bf1 /chart2/source/view/axes | |
parent | 9976aa7b8420daa9f7a5290ae433e2ab338ca146 (diff) |
tdf#125334 Chart: allow text break in bar chart axis labels
Now vertical category axis labels support text breaking.
Change-Id: I8b1c6eff921ea999bc4f745aa5f85bae278e735b
Reviewed-on: https://gerrit.libreoffice.org/72457
Tested-by: Jenkins
Reviewed-by: László Németh <nemeth@numbertext.org>
Diffstat (limited to 'chart2/source/view/axes')
-rw-r--r-- | chart2/source/view/axes/VCartesianAxis.cxx | 25 | ||||
-rw-r--r-- | chart2/source/view/axes/VCartesianAxis.hxx | 2 |
2 files changed, 19 insertions, 8 deletions
diff --git a/chart2/source/view/axes/VCartesianAxis.cxx b/chart2/source/view/axes/VCartesianAxis.cxx index 234e1000140a..4fac1f83b72e 100644 --- a/chart2/source/view/axes/VCartesianAxis.cxx +++ b/chart2/source/view/axes/VCartesianAxis.cxx @@ -510,7 +510,7 @@ TickInfo* MaxLabelTickIter::nextInfo() } bool VCartesianAxis::isBreakOfLabelsAllowed( - const AxisLabelProperties& rAxisLabelProperties, bool bIsHorizontalAxis ) const + const AxisLabelProperties& rAxisLabelProperties, bool bIsHorizontalAxis, bool bIsVerticalAxis) const { if( m_aTextLabels.getLength() > 100 ) return false; @@ -525,8 +525,10 @@ bool VCartesianAxis::isBreakOfLabelsAllowed( rAxisLabelProperties.fRotationAngleDegree == 90.0 || rAxisLabelProperties.fRotationAngleDegree == 270.0 ) ) return false; - //break only for horizontal axis - return bIsHorizontalAxis; + if ( !m_aAxisProperties.m_bSwapXAndY ) + return bIsHorizontalAxis; + else + return bIsVerticalAxis; } namespace{ @@ -702,7 +704,7 @@ bool VCartesianAxis::createTextShapes( const bool bIsHorizontalAxis = pTickFactory->isHorizontalAxis(); const bool bIsVerticalAxis = pTickFactory->isVerticalAxis(); - if (!isBreakOfLabelsAllowed(rAxisLabelProperties, bIsHorizontalAxis) && + if (!isBreakOfLabelsAllowed(rAxisLabelProperties, bIsHorizontalAxis, bIsVerticalAxis) && !isAutoStaggeringOfLabelsAllowed(rAxisLabelProperties, bIsHorizontalAxis, bIsVerticalAxis) && !rAxisLabelProperties.isStaggered()) return createTextShapesSimple(xTarget, rTickIter, rAxisLabelProperties, pTickFactory); @@ -714,7 +716,7 @@ bool VCartesianAxis::createTextShapes( B2DVector aTextToTickDistance = pTickFactory->getDistanceAxisTickToText(m_aAxisProperties, true); sal_Int32 nLimitedSpaceForText = -1; - if( isBreakOfLabelsAllowed( rAxisLabelProperties, bIsHorizontalAxis ) ) + if( isBreakOfLabelsAllowed( rAxisLabelProperties, bIsHorizontalAxis, bIsVerticalAxis ) ) { nLimitedSpaceForText = nScreenDistanceBetweenTicks; if( bIsStaggered ) @@ -742,6 +744,12 @@ bool VCartesianAxis::createTextShapes( nLimitedSpaceForText = -1; } } + + // recalculate the nLimitedSpaceForText in case of vertical category axis if the text break is true + if ( m_aAxisProperties.m_bSwapXAndY && bIsVerticalAxis && rAxisLabelProperties.fRotationAngleDegree == 0.0 ) + { + nLimitedSpaceForText = rAxisLabelProperties.m_aMaximumSpaceForLabels.X; + } } // Stores an array of text label strings in case of a normal @@ -750,8 +758,11 @@ bool VCartesianAxis::createTextShapes( if( m_bUseTextLabels && !m_aAxisProperties.m_bComplexCategories ) pCategories = &m_aTextLabels; - bool bLimitedHeight = fabs(aTextToTickDistance.getX()) > fabs(aTextToTickDistance.getY()); - + bool bLimitedHeight; + if( !m_aAxisProperties.m_bSwapXAndY ) + bLimitedHeight = fabs(aTextToTickDistance.getX()) > fabs(aTextToTickDistance.getY()); + else + bLimitedHeight = fabs(aTextToTickDistance.getX()) < fabs(aTextToTickDistance.getY()); //prepare properties for multipropertyset-interface of shape tNameSequence aPropNames; tAnySequence aPropValues; diff --git a/chart2/source/view/axes/VCartesianAxis.hxx b/chart2/source/view/axes/VCartesianAxis.hxx index df15e4896198..1c020bc4174c 100644 --- a/chart2/source/view/axes/VCartesianAxis.hxx +++ b/chart2/source/view/axes/VCartesianAxis.hxx @@ -150,7 +150,7 @@ private: //methods * @return true if we can break a single line label text into multiple * lines for better fitting, otherwise false. */ - bool isBreakOfLabelsAllowed( const AxisLabelProperties& rAxisLabelProperties, bool bIsHorizontalAxis ) const; + bool isBreakOfLabelsAllowed( const AxisLabelProperties& rAxisLabelProperties, bool bIsHorizontalAxis, bool bIsVerticalAxis ) const; ::basegfx::B2DVector getScreenPosition( double fLogicX, double fLogicY, double fLogicZ ) const; ScreenPosAndLogicPos getScreenPosAndLogicPos( double fLogicX, double fLogicY, double fLogicZ ) const; |