summaryrefslogtreecommitdiff
path: root/chart2
diff options
context:
space:
mode:
authorMuthu Subramanian <sumuthu@suse.com>2013-01-08 12:40:45 +0530
committerNoel Power <noel.power@suse.com>2013-01-15 13:01:05 +0000
commit40fe0c77091f97a30fb550dbd14ed5f3d57b34fe (patch)
treeb5e17f5f8bb946d613412533070fb77f7e85a427 /chart2
parentfb3becfdb10cde48b6ee5d6fdc9337bf71796fd6 (diff)
n#791985: Automatically rotate chart labels (if overlapping).
This bug fixes two issues: * Overlap detection seems to be approximate and doesn't work for rotated text. Added a workaround for labels rotated at angles 45-135 and 225-315. * Auto rotate labels, which overlap. This is done only for labels having zero degrees rotate. For forcing angles, use 'enable overlap' or non-zero angles (1 degree). Of course, zero degrees plus skipping of labels would no longer occur. Better solutions? Signed-off-by: Noel Power <noel.power@suse.com>
Diffstat (limited to 'chart2')
-rw-r--r--chart2/source/view/axes/VCartesianAxis.cxx16
1 files changed, 15 insertions, 1 deletions
diff --git a/chart2/source/view/axes/VCartesianAxis.cxx b/chart2/source/view/axes/VCartesianAxis.cxx
index f394ef828c24..40b48862d7c1 100644
--- a/chart2/source/view/axes/VCartesianAxis.cxx
+++ b/chart2/source/view/axes/VCartesianAxis.cxx
@@ -137,6 +137,11 @@ bool doesOverlap( const Reference< drawing::XShape >& xShape1
if( !xShape1.is() || !xShape2.is() )
return false;
+ sal_Int32 nAngle = abs(fRotationAngleDegree);
+
+ if( ( nAngle >= 45 && nAngle <= 135 ) || ( nAngle >= 225 && nAngle <= 315 ) )
+ return false;
+
::basegfx::B2IRectangle aRect1( BaseGFXHelper::makeRectangle(xShape1->getPosition(),ShapeFactory::getSizeAfterRotation( xShape1, fRotationAngleDegree )));
::basegfx::B2IRectangle aRect2( BaseGFXHelper::makeRectangle(xShape2->getPosition(),ShapeFactory::getSizeAfterRotation( xShape2, fRotationAngleDegree )));
return aRect1.overlaps(aRect2);
@@ -662,7 +667,7 @@ bool VCartesianAxis::createTextShapes(
pPREPreviousVisibleTickInfo : pPreviousVisibleTickInfo;
//don't create labels which does not fit into the rhythm
- if( nTick%rAxisLabelProperties.nRhythm != 0)
+ if( nTick%rAxisLabelProperties.nRhythm != 0 )
continue;
//don't create labels for invisible ticks
@@ -776,6 +781,15 @@ bool VCartesianAxis::createTextShapes(
}
if( bOverlapAlsoAfterSwitchingOnAutoStaggering )
{
+ /* Try auto-rotating to 45 degrees */
+ if( !rAxisLabelProperties.bOverlapAllowed && ::rtl::math::approxEqual( rAxisLabelProperties.fRotationAngleDegree, 0.0 ) )
+ {
+ rAxisLabelProperties.fRotationAngleDegree = 45;
+ rAxisLabelProperties.bLineBreakAllowed = false;
+ m_aAxisLabelProperties.fRotationAngleDegree = rAxisLabelProperties.fRotationAngleDegree;
+ removeTextShapesFromTicks();
+ return false;
+ }
if( rAxisLabelProperties.bRhythmIsFix )
{
xTarget->remove(pTickInfo->xTextShape);