[Libreoffice-commits] core.git: Branch 'libreoffice-6-0' - chart2/source
Jochen Nitschke
j.nitschke+logerrit at ok.de
Sun Jan 7 14:18:47 UTC 2018
chart2/source/view/axes/Tickmarks.cxx | 21 ++++++++++++++++++---
chart2/source/view/axes/VCartesianAxis.cxx | 26 +++++---------------------
2 files changed, 23 insertions(+), 24 deletions(-)
New commits:
commit e328b25e634035cf3810061579d33623846173c0
Author: Jochen Nitschke <j.nitschke+logerrit at ok.de>
Date: Tue Jun 6 11:19:50 2017 +0200
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 at ok.de>
Tested-by: Jochen Nitschke <j.nitschke+logerrit at ok.de>
(cherry picked from commit 38bf5f69663f64434a3a0a74e02c1a23f876b677)
Reviewed-on: https://gerrit.libreoffice.org/47015
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Markus Mohrhard <markus.mohrhard at googlemail.com>
diff --git a/chart2/source/view/axes/Tickmarks.cxx b/chart2/source/view/axes/Tickmarks.cxx
index 95f967b3b215..3d6d25a044bf 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 c53f890a07a6..9493102a93c4 100644
--- a/chart2/source/view/axes/VCartesianAxis.cxx
+++ b/chart2/source/view/axes/VCartesianAxis.cxx
@@ -104,25 +104,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() ) );
@@ -744,8 +732,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.
@@ -759,8 +746,7 @@ bool VCartesianAxis::createTextShapes(
if( !pLastVisibleNeighbourTickInfo ||
!lcl_doesShapeOverlapWithTickmark( pLastVisibleNeighbourTickInfo->xTextShape
, rAxisLabelProperties.fRotationAngleDegree
- , pTickInfo->aTickScreenPosition
- , bIsHorizontalAxis, bIsVerticalAxis ) )
+ , pTickInfo->aTickScreenPosition ) )
bOverlapsAfterAutoStagger = false;
}
@@ -841,8 +827,7 @@ bool VCartesianAxis::createTextShapes(
if( !pLastVisibleNeighbourTickInfo ||
!lcl_doesShapeOverlapWithTickmark( pLastVisibleNeighbourTickInfo->xTextShape
, rAxisLabelProperties.fRotationAngleDegree
- , pTickInfo->aTickScreenPosition
- , bIsHorizontalAxis, bIsVerticalAxis ) )
+ , pTickInfo->aTickScreenPosition ) )
bOverlapsAfterAutoStagger = false;
}
}
@@ -933,8 +918,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.
More information about the Libreoffice-commits
mailing list