summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJochen Nitschke <j.nitschke+logerrit@ok.de>2017-06-06 11:19:50 +0200
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2018-01-07 15:18:30 +0100
commit5ecffcb48140eb055e71b0d8905d693036e61bc6 (patch)
treefb929ba66623b36fa1363c451c2bc685db40faea
parentd3789ea2fb2981d82447418dd5e2e5c7f7cec4d1 (diff)
tdf#108031 Area chart labels not rotated
This fixes recognition of x-axis or y-axis when the coordinate system is rotated (3D-view). So the labels are rotated correctly. Change-Id: Iaacfec943f3885c58e99a55585714a79f1d0d9d5 Reviewed-on: https://gerrit.libreoffice.org/38355 Reviewed-by: Jochen Nitschke <j.nitschke+logerrit@ok.de> Tested-by: Jochen Nitschke <j.nitschke+logerrit@ok.de> (cherry picked from commit 38bf5f69663f64434a3a0a74e02c1a23f876b677) Reviewed-on: https://gerrit.libreoffice.org/47016 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Markus Mohrhard <markus.mohrhard@googlemail.com>
-rw-r--r--chart2/source/view/axes/Tickmarks.cxx21
-rw-r--r--chart2/source/view/axes/VCartesianAxis.cxx26
2 files changed, 23 insertions, 24 deletions
diff --git a/chart2/source/view/axes/Tickmarks.cxx b/chart2/source/view/axes/Tickmarks.cxx
index c3d98df7456c..2d4c3244cc97 100644
--- a/chart2/source/view/axes/Tickmarks.cxx
+++ b/chart2/source/view/axes/Tickmarks.cxx
@@ -172,13 +172,28 @@ TickFactory2D::~TickFactory2D()
bool TickFactory2D::isHorizontalAxis() const
{
- return ( m_aAxisStartScreenPosition2D.getY() == m_aAxisEndScreenPosition2D.getY() );
+ // check trivial cases:
+ if ( m_aAxisStartScreenPosition2D.getY() == m_aAxisEndScreenPosition2D.getY() )
+ return true;
+ if ( m_aAxisStartScreenPosition2D.getX() == m_aAxisEndScreenPosition2D.getX() )
+ return false;
+
+ // for skew axes compare angle with horizontal vector
+ double fInclination = std::abs(B2DVector(m_aAxisEndScreenPosition2D-m_aAxisStartScreenPosition2D).angle(B2DVector(1.0, 0.0)));
+ return fInclination < F_PI4 || fInclination > (F_PI-F_PI4);
}
bool TickFactory2D::isVerticalAxis() const
{
- return ( m_aAxisStartScreenPosition2D.getX() == m_aAxisEndScreenPosition2D.getX() );
+ // check trivial cases:
+ if ( m_aAxisStartScreenPosition2D.getX() == m_aAxisEndScreenPosition2D.getX() )
+ return true;
+ if ( m_aAxisStartScreenPosition2D.getY() == m_aAxisEndScreenPosition2D.getY() )
+ return false;
+
+ // for skew axes compare angle with vertical vector
+ double fInclination = std::abs(B2DVector(m_aAxisEndScreenPosition2D-m_aAxisStartScreenPosition2D).angle(B2DVector(0.0, -1.0)));
+ return fInclination < F_PI4 || fInclination > (F_PI-F_PI4);
}
-
//static
sal_Int32 TickFactory2D::getTickScreenDistance( TickIter& rIter )
{
diff --git a/chart2/source/view/axes/VCartesianAxis.cxx b/chart2/source/view/axes/VCartesianAxis.cxx
index 3ff5cd913cfb..89bd3536d2ce 100644
--- a/chart2/source/view/axes/VCartesianAxis.cxx
+++ b/chart2/source/view/axes/VCartesianAxis.cxx
@@ -105,25 +105,13 @@ Reference< drawing::XShape > createSingleLabel(
bool lcl_doesShapeOverlapWithTickmark( const Reference< drawing::XShape >& xShape
, double fRotationAngleDegree
- , const basegfx::B2DVector& rTickScreenPosition
- , bool bIsHorizontalAxis, bool bIsVerticalAxis )
+ , const basegfx::B2DVector& rTickScreenPosition )
{
if(!xShape.is())
return false;
::basegfx::B2IRectangle aShapeRect = BaseGFXHelper::makeRectangle(xShape->getPosition(),AbstractShapeFactory::getSizeAfterRotation( xShape, fRotationAngleDegree ));
- if( bIsVerticalAxis )
- {
- return ( (rTickScreenPosition.getY() >= aShapeRect.getMinY())
- && (rTickScreenPosition.getY() <= aShapeRect.getMaxY()) );
- }
- if( bIsHorizontalAxis )
- {
- return ( (rTickScreenPosition.getX() >= aShapeRect.getMinX())
- && (rTickScreenPosition.getX() <= aShapeRect.getMaxX()) );
- }
-
basegfx::B2IVector aPosition(
static_cast<sal_Int32>( rTickScreenPosition.getX() )
, static_cast<sal_Int32>( rTickScreenPosition.getY() ) );
@@ -745,8 +733,7 @@ bool VCartesianAxis::createTextShapes(
if( lcl_doesShapeOverlapWithTickmark( pLastVisibleNeighbourTickInfo->xTextShape
, rAxisLabelProperties.fRotationAngleDegree
- , pTickInfo->aTickScreenPosition
- , bIsHorizontalAxis, bIsVerticalAxis ) )
+ , pTickInfo->aTickScreenPosition ) )
{
// This tick overlaps with its neighbor. Try to stagger (if
// auto staggering is allowed) to avoid overlapping.
@@ -760,8 +747,7 @@ bool VCartesianAxis::createTextShapes(
if( !pLastVisibleNeighbourTickInfo ||
!lcl_doesShapeOverlapWithTickmark( pLastVisibleNeighbourTickInfo->xTextShape
, rAxisLabelProperties.fRotationAngleDegree
- , pTickInfo->aTickScreenPosition
- , bIsHorizontalAxis, bIsVerticalAxis ) )
+ , pTickInfo->aTickScreenPosition ) )
bOverlapsAfterAutoStagger = false;
}
@@ -842,8 +828,7 @@ bool VCartesianAxis::createTextShapes(
if( !pLastVisibleNeighbourTickInfo ||
!lcl_doesShapeOverlapWithTickmark( pLastVisibleNeighbourTickInfo->xTextShape
, rAxisLabelProperties.fRotationAngleDegree
- , pTickInfo->aTickScreenPosition
- , bIsHorizontalAxis, bIsVerticalAxis ) )
+ , pTickInfo->aTickScreenPosition ) )
bOverlapsAfterAutoStagger = false;
}
}
@@ -934,8 +919,7 @@ bool VCartesianAxis::createTextShapesSimple(
if( lcl_doesShapeOverlapWithTickmark( pLastVisibleNeighbourTickInfo->xTextShape
, rAxisLabelProperties.fRotationAngleDegree
- , pTickInfo->aTickScreenPosition
- , bIsHorizontalAxis, bIsVerticalAxis ) )
+ , pTickInfo->aTickScreenPosition ) )
{
// This tick overlaps with its neighbor. Increment the visible
// tick intervals (if that's allowed) and start over.