summaryrefslogtreecommitdiff
path: root/chart2/source/view/axes/VCartesianAxis.cxx
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2014-10-14 15:07:31 +0200
committerStephan Bergmann <sbergman@redhat.com>2014-10-14 15:07:31 +0200
commit658f031bb155474fa64e69fb76326b29ef4a642c (patch)
treec380274bd55223e28631cad24bf0b583771b9577 /chart2/source/view/axes/VCartesianAxis.cxx
parent8a1679e47e681e01f91091d45889f672e6722eb1 (diff)
Revert "Revert "Make VCartesianAxis::get2DAxisMainLine() truly const method.""
This reverts commit bf302000ea8849ac7ecd9162f3014bac9da4406e, as clarified on IRC, --enable-chart-tests is known flaky and not intended to be used by anybody but moggi.
Diffstat (limited to 'chart2/source/view/axes/VCartesianAxis.cxx')
-rw-r--r--chart2/source/view/axes/VCartesianAxis.cxx102
1 files changed, 55 insertions, 47 deletions
diff --git a/chart2/source/view/axes/VCartesianAxis.cxx b/chart2/source/view/axes/VCartesianAxis.cxx
index 827973eac0fc..d28c0319b30d 100644
--- a/chart2/source/view/axes/VCartesianAxis.cxx
+++ b/chart2/source/view/axes/VCartesianAxis.cxx
@@ -98,7 +98,7 @@ Reference< drawing::XShape > createSingleLabel(
->createText( xTarget, aLabel, rPropNames, rPropValues, aATransformation );
LabelPositionHelper::correctPositionForRotation( xShape2DText
- , rAxisProperties.m_aLabelAlignment, rAxisLabelProperties.fRotationAngleDegree, rAxisProperties.m_bComplexCategories );
+ , rAxisProperties.maLabelAlignment.meAlignment, rAxisLabelProperties.fRotationAngleDegree, rAxisProperties.m_bComplexCategories );
return xShape2DText;
}
@@ -649,7 +649,7 @@ bool VCartesianAxis::createTextShapes(
, nLimitedSpaceForText, bLimitedHeight );
LabelPositionHelper::doDynamicFontResize( aPropValues, aPropNames, xProps
, m_aAxisLabelProperties.m_aFontReferenceSize );
- LabelPositionHelper::changeTextAdjustment( aPropValues, aPropNames, m_aAxisProperties.m_aLabelAlignment );
+ LabelPositionHelper::changeTextAdjustment( aPropValues, aPropNames, m_aAxisProperties.maLabelAlignment.meAlignment );
uno::Any* pColorAny = PropertyMapper::getValuePointer(aPropValues,aPropNames,"CharColor");
sal_Int32 nColor = Color( COL_AUTO ).GetColor();
@@ -922,7 +922,8 @@ struct lcl_GreaterYPos : ::std::binary_function< VCartesianAxis::ScreenPosAndLog
}
};
-void VCartesianAxis::get2DAxisMainLine( B2DVector& rStart, B2DVector& rEnd, double fCrossesOtherAxis )
+void VCartesianAxis::get2DAxisMainLine(
+ B2DVector& rStart, B2DVector& rEnd, AxisLabelAlignment& rAlignment, double fCrossesOtherAxis ) const
{
//m_aAxisProperties might get updated and changed here because
// the label alignmant and inner direction sign depends exactly of the choice of the axis line position which is made here in this method
@@ -1011,23 +1012,23 @@ void VCartesianAxis::get2DAxisMainLine( B2DVector& rStart, B2DVector& rEnd, doub
if( fabs(fDeltaY) > fabs(fDeltaX) )
{
- m_aAxisProperties.m_aLabelAlignment = LABEL_ALIGN_LEFT;
+ rAlignment.meAlignment = LABEL_ALIGN_LEFT;
//choose most left positions
::std::sort( aPosList.begin(), aPosList.end(), lcl_LessXPos() );
- m_aAxisProperties.m_fLabelDirectionSign = fDeltaY<0 ? -1 : 1;
+ rAlignment.mfLabelDirection = (fDeltaY < 0) ? -1.0 : 1.0;
}
else
{
- m_aAxisProperties.m_aLabelAlignment = LABEL_ALIGN_BOTTOM;
+ rAlignment.meAlignment = LABEL_ALIGN_BOTTOM;
//choose most bottom positions
::std::sort( aPosList.begin(), aPosList.end(), lcl_GreaterYPos() );
- m_aAxisProperties.m_fLabelDirectionSign = fDeltaX<0 ? -1 : 1;
+ rAlignment.mfLabelDirection = (fDeltaX < 0) ? -1.0 : 1.0;
}
ScreenPosAndLogicPos aBestPos( aPosList[0] );
fYStart = fYEnd = aBestPos.fLogicY;
fZStart = fZEnd = aBestPos.fLogicZ;
if( !m_pPosHelper->isMathematicalOrientationX() )
- m_aAxisProperties.m_fLabelDirectionSign *= -1;
+ rAlignment.mfLabelDirection *= -1.0;
}
}//end 3D x axis
}
@@ -1065,23 +1066,23 @@ void VCartesianAxis::get2DAxisMainLine( B2DVector& rStart, B2DVector& rEnd, doub
if( fabs(fDeltaY) > fabs(fDeltaX) )
{
- m_aAxisProperties.m_aLabelAlignment = LABEL_ALIGN_LEFT;
+ rAlignment.meAlignment = LABEL_ALIGN_LEFT;
//choose most left positions
::std::sort( aPosList.begin(), aPosList.end(), lcl_LessXPos() );
- m_aAxisProperties.m_fLabelDirectionSign = fDeltaY<0 ? -1 : 1;
+ rAlignment.mfLabelDirection = (fDeltaY < 0) ? -1.0 : 1.0;
}
else
{
- m_aAxisProperties.m_aLabelAlignment = LABEL_ALIGN_BOTTOM;
+ rAlignment.meAlignment = LABEL_ALIGN_BOTTOM;
//choose most bottom positions
::std::sort( aPosList.begin(), aPosList.end(), lcl_GreaterYPos() );
- m_aAxisProperties.m_fLabelDirectionSign = fDeltaX<0 ? -1 : 1;
+ rAlignment.mfLabelDirection = (fDeltaX < 0) ? -1.0 : 1.0;
}
ScreenPosAndLogicPos aBestPos( aPosList[0] );
fXStart = fXEnd = aBestPos.fLogicX;
fZStart = fZEnd = aBestPos.fLogicZ;
if( !m_pPosHelper->isMathematicalOrientationY() )
- m_aAxisProperties.m_fLabelDirectionSign *= -1;
+ rAlignment.mfLabelDirection *= -1.0;
}
}//end 3D y axis
}
@@ -1150,21 +1151,21 @@ void VCartesianAxis::get2DAxisMainLine( B2DVector& rStart, B2DVector& rEnd, doub
if( !::rtl::math::approxEqual( fDeltaX, 0.0 ) ) // prefer left-right alignments
{
if( aBestPos.aScreenPos.getX() > aNotSoGoodPos.aScreenPos.getX() )
- m_aAxisProperties.m_aLabelAlignment = LABEL_ALIGN_RIGHT;
+ rAlignment.meAlignment = LABEL_ALIGN_RIGHT;
else
- m_aAxisProperties.m_aLabelAlignment = LABEL_ALIGN_LEFT;
+ rAlignment.meAlignment = LABEL_ALIGN_LEFT;
}
else
{
if( aBestPos.aScreenPos.getY() > aNotSoGoodPos.aScreenPos.getY() )
- m_aAxisProperties.m_aLabelAlignment = LABEL_ALIGN_BOTTOM;
+ rAlignment.meAlignment = LABEL_ALIGN_BOTTOM;
else
- m_aAxisProperties.m_aLabelAlignment = LABEL_ALIGN_TOP;
+ rAlignment.meAlignment = LABEL_ALIGN_TOP;
}
- m_aAxisProperties.m_fLabelDirectionSign = fDeltaX<0 ? -1 : 1;
+ rAlignment.mfLabelDirection = (fDeltaX < 0) ? -1.0 : 1.0;
if( !m_pPosHelper->isMathematicalOrientationZ() )
- m_aAxisProperties.m_fLabelDirectionSign *= -1;
+ rAlignment.mfLabelDirection *= -1.0;
fXStart = fXEnd = aBestPos.fLogicX;
fYStart = fYEnd = aBestPos.fLogicY;
@@ -1176,7 +1177,7 @@ void VCartesianAxis::get2DAxisMainLine( B2DVector& rStart, B2DVector& rEnd, doub
rEnd = getScreenPosition( fXEnd, fYEnd, fZEnd );
if(3==m_nDimension && !AxisHelper::isAxisPositioningEnabled() )
- m_aAxisProperties.m_fInnerDirectionSign = m_aAxisProperties.m_fLabelDirectionSign;//to behave like before
+ rAlignment.mfInnerTickDirection = rAlignment.mfLabelDirection;//to behave like before
if(3==m_nDimension && AxisHelper::isAxisPositioningEnabled() )
{
@@ -1187,54 +1188,54 @@ void VCartesianAxis::get2DAxisMainLine( B2DVector& rStart, B2DVector& rEnd, doub
{
if( m_eLeftWallPos != CuboidPlanePosition_Left )
{
- m_aAxisProperties.m_fLabelDirectionSign *= -1.0;
- m_aAxisProperties.m_fInnerDirectionSign *= -1.0;
+ rAlignment.mfLabelDirection *= -1.0;
+ rAlignment.mfInnerTickDirection *= -1.0;
}
- m_aAxisProperties.m_aLabelAlignment =
- ( m_aAxisProperties.m_fLabelDirectionSign<0 ) ?
+ rAlignment.meAlignment =
+ (rAlignment.mfLabelDirection < 0) ?
LABEL_ALIGN_LEFT : LABEL_ALIGN_RIGHT;
if( ( fDeltaY<0 && m_aScale.Orientation == chart2::AxisOrientation_REVERSE ) ||
( fDeltaY>0 && m_aScale.Orientation == chart2::AxisOrientation_MATHEMATICAL ) )
- m_aAxisProperties.m_aLabelAlignment =
- ( m_aAxisProperties.m_aLabelAlignment==LABEL_ALIGN_RIGHT ) ?
- LABEL_ALIGN_LEFT : LABEL_ALIGN_RIGHT;
+ rAlignment.meAlignment =
+ (rAlignment.meAlignment == LABEL_ALIGN_RIGHT) ?
+ LABEL_ALIGN_LEFT : LABEL_ALIGN_RIGHT;
}
else if( fabs(fDeltaY) > fabs(fDeltaX) )
{
if( m_eBackWallPos != CuboidPlanePosition_Back )
{
- m_aAxisProperties.m_fLabelDirectionSign *= -1.0;
- m_aAxisProperties.m_fInnerDirectionSign *= -1.0;
+ rAlignment.mfLabelDirection *= -1.0;
+ rAlignment.mfInnerTickDirection *= -1.0;
}
- m_aAxisProperties.m_aLabelAlignment =
- ( m_aAxisProperties.m_fLabelDirectionSign<0 ) ?
- LABEL_ALIGN_LEFT : LABEL_ALIGN_RIGHT;
+ rAlignment.meAlignment =
+ (rAlignment.mfLabelDirection < 0) ?
+ LABEL_ALIGN_LEFT : LABEL_ALIGN_RIGHT;
if( ( fDeltaY<0 && m_aScale.Orientation == chart2::AxisOrientation_REVERSE ) ||
( fDeltaY>0 && m_aScale.Orientation == chart2::AxisOrientation_MATHEMATICAL ) )
- m_aAxisProperties.m_aLabelAlignment =
- ( m_aAxisProperties.m_aLabelAlignment==LABEL_ALIGN_RIGHT ) ?
+ rAlignment.meAlignment =
+ (rAlignment.meAlignment == LABEL_ALIGN_RIGHT) ?
LABEL_ALIGN_LEFT : LABEL_ALIGN_RIGHT;
}
else
{
if( m_eBackWallPos != CuboidPlanePosition_Back )
{
- m_aAxisProperties.m_fLabelDirectionSign *= -1.0;
- m_aAxisProperties.m_fInnerDirectionSign *= -1.0;
+ rAlignment.mfLabelDirection *= -1.0;
+ rAlignment.mfInnerTickDirection *= -1.0;
}
- m_aAxisProperties.m_aLabelAlignment =
- ( m_aAxisProperties.m_fLabelDirectionSign<0 ) ?
+ rAlignment.meAlignment =
+ (rAlignment.mfLabelDirection < 0) ?
LABEL_ALIGN_TOP : LABEL_ALIGN_BOTTOM;
if( ( fDeltaX>0 && m_aScale.Orientation == chart2::AxisOrientation_REVERSE ) ||
( fDeltaX<0 && m_aScale.Orientation == chart2::AxisOrientation_MATHEMATICAL ) )
- m_aAxisProperties.m_aLabelAlignment =
- ( m_aAxisProperties.m_aLabelAlignment==LABEL_ALIGN_TOP ) ?
+ rAlignment.meAlignment =
+ (rAlignment.meAlignment == LABEL_ALIGN_TOP) ?
LABEL_ALIGN_BOTTOM : LABEL_ALIGN_TOP;
}
}
@@ -1247,11 +1248,14 @@ TickFactory* VCartesianAxis::createTickFactory()
TickFactory2D* VCartesianAxis::createTickFactory2D()
{
+ AxisLabelAlignment aLabelAlign;
B2DVector aStart, aEnd;
- get2DAxisMainLine( aStart, aEnd, getAxisIntersectionValue() );
+ get2DAxisMainLine(aStart, aEnd, aLabelAlign, getAxisIntersectionValue());
+ m_aAxisProperties.maLabelAlignment = aLabelAlign;
B2DVector aLabelLineStart, aLabelLineEnd;
- get2DAxisMainLine( aLabelLineStart, aLabelLineEnd, getLabelLineIntersectionValue() );
+ get2DAxisMainLine(aLabelLineStart, aLabelLineEnd, aLabelAlign, getLabelLineIntersectionValue());
+ m_aAxisProperties.maLabelAlignment = aLabelAlign;
return new TickFactory2D( m_aScale, m_aIncrement, aStart, aEnd, aLabelLineStart-aStart );
}
@@ -1297,7 +1301,9 @@ sal_Int32 VCartesianAxis::estimateMaximumAutoMainIncrementCount()
return nRet;
B2DVector aStart, aEnd;
- this->get2DAxisMainLine( aStart, aEnd, getAxisIntersectionValue() );
+ AxisLabelAlignment aLabelAlign;
+ get2DAxisMainLine(aStart, aEnd, aLabelAlign, getAxisIntersectionValue());
+ m_aAxisProperties.maLabelAlignment = aLabelAlign;
sal_Int32 nMaxHeight = static_cast<sal_Int32>(fabs(aEnd.getY()-aStart.getY()));
sal_Int32 nMaxWidth = static_cast<sal_Int32>(fabs(aEnd.getX()-aStart.getX()));
@@ -1516,7 +1522,7 @@ void VCartesianAxis::updatePositions()
//correctPositionForRotation
LabelPositionHelper::correctPositionForRotation( xShape2DText
- , m_aAxisProperties.m_aLabelAlignment, fRotationAngleDegree, m_aAxisProperties.m_bComplexCategories );
+ , m_aAxisProperties.maLabelAlignment.meAlignment, fRotationAngleDegree, m_aAxisProperties.m_bComplexCategories );
}
}
}
@@ -1538,7 +1544,7 @@ void VCartesianAxis::createTickMarkLineShapes( TickInfoArrayType& rTickInfos, co
continue;
bool bTicksAtLabels = ( m_aAxisProperties.m_eTickmarkPos != ::com::sun::star::chart::ChartAxisMarkPosition_AT_AXIS );
- double fInnerDirectionSign = m_aAxisProperties.m_fInnerDirectionSign;
+ double fInnerDirectionSign = m_aAxisProperties.maLabelAlignment.mfInnerTickDirection;
if( bTicksAtLabels && m_aAxisProperties.m_eLabelPos == ::com::sun::star::chart::ChartAxisLabelPosition_OUTSIDE_END )
fInnerDirectionSign *= -1.0;
bTicksAtLabels = bTicksAtLabels || bOnlyAtLabels;
@@ -1548,7 +1554,7 @@ void VCartesianAxis::createTickMarkLineShapes( TickInfoArrayType& rTickInfos, co
//add ticks at axis (without lables):
if( !bOnlyAtLabels && m_aAxisProperties.m_eTickmarkPos == ::com::sun::star::chart::ChartAxisMarkPosition_AT_LABELS_AND_AXIS )
rTickFactory2D.addPointSequenceForTickLine( aPoints, nN++, (*aTickIter).fScaledTickValue
- , m_aAxisProperties.m_fInnerDirectionSign, rTickmarkProperties, !bTicksAtLabels );
+ , m_aAxisProperties.maLabelAlignment.mfInnerTickDirection, rTickmarkProperties, !bTicksAtLabels );
}
aPoints.realloc(nN);
m_pShapeFactory->createLine2D( m_xGroupShape_Shapes, aPoints
@@ -1641,7 +1647,9 @@ void VCartesianAxis::createShapes()
if (!rtl::math::isNan(fExtraLineCrossesOtherAxis))
{
B2DVector aStart, aEnd;
- this->get2DAxisMainLine( aStart, aEnd, fExtraLineCrossesOtherAxis );
+ AxisLabelAlignment aLabelAlign;
+ get2DAxisMainLine(aStart, aEnd, aLabelAlign, fExtraLineCrossesOtherAxis);
+ m_aAxisProperties.maLabelAlignment = aLabelAlign;
drawing::PointSequenceSequence aPoints( lcl_makePointSequence(aStart,aEnd) );
Reference< drawing::XShape > xShape = m_pShapeFactory->createLine2D(
m_xGroupShape_Shapes, aPoints, &m_aAxisProperties.m_aLineProperties );