summaryrefslogtreecommitdiff
path: root/chart2/source/view/axes
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2020-04-18 14:08:51 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2020-04-19 11:01:18 +0200
commit9df2821e61979dab32390d5c64dd49bee868adbb (patch)
tree5b827e29e73ac2300c164b0a389a784a358956e6 /chart2/source/view/axes
parent8b0a69498b025e13d9772689e9e4fa3d6b05e609 (diff)
loplugin:flatten in chart2
Change-Id: Iadc4da6515a7d82e7a92b33d74d589b61fa2c64f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/92480 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'chart2/source/view/axes')
-rw-r--r--chart2/source/view/axes/ScaleAutomatism.cxx60
-rw-r--r--chart2/source/view/axes/Tickmarks_Equidistant.cxx28
-rw-r--r--chart2/source/view/axes/VAxisBase.cxx16
-rw-r--r--chart2/source/view/axes/VAxisProperties.cxx56
-rw-r--r--chart2/source/view/axes/VCartesianAxis.cxx120
-rw-r--r--chart2/source/view/axes/VPolarAngleAxis.cxx32
6 files changed, 156 insertions, 156 deletions
diff --git a/chart2/source/view/axes/ScaleAutomatism.cxx b/chart2/source/view/axes/ScaleAutomatism.cxx
index 1adcfe64d652..10fc3ccd4f56 100644
--- a/chart2/source/view/axes/ScaleAutomatism.cxx
+++ b/chart2/source/view/axes/ScaleAutomatism.cxx
@@ -695,40 +695,40 @@ void ScaleAutomatism::calculateExplicitIncrementAndScaleForDateTimeAxis(
if( nDayCount/nIntervalDayCount > nMaxMainIncrementCount )
bAutoMinor = true;
}
- if( bAutoMinor )
+ if( !bAutoMinor )
+ return;
+
+ rExplicitIncrement.MinorTimeInterval.TimeUnit = rExplicitIncrement.MajorTimeInterval.TimeUnit;
+ rExplicitIncrement.MinorTimeInterval.Number = 1;
+ if( nMainIncrementCount > 100 )
+ rExplicitIncrement.MinorTimeInterval.Number = rExplicitIncrement.MajorTimeInterval.Number;
+ else
{
- rExplicitIncrement.MinorTimeInterval.TimeUnit = rExplicitIncrement.MajorTimeInterval.TimeUnit;
- rExplicitIncrement.MinorTimeInterval.Number = 1;
- if( nMainIncrementCount > 100 )
- rExplicitIncrement.MinorTimeInterval.Number = rExplicitIncrement.MajorTimeInterval.Number;
+ if( rExplicitIncrement.MajorTimeInterval.Number >= 2 )
+ {
+ if( !(rExplicitIncrement.MajorTimeInterval.Number%2) )
+ rExplicitIncrement.MinorTimeInterval.Number = rExplicitIncrement.MajorTimeInterval.Number/2;
+ else if( !(rExplicitIncrement.MajorTimeInterval.Number%3) )
+ rExplicitIncrement.MinorTimeInterval.Number = rExplicitIncrement.MajorTimeInterval.Number/3;
+ else if( !(rExplicitIncrement.MajorTimeInterval.Number%5) )
+ rExplicitIncrement.MinorTimeInterval.Number = rExplicitIncrement.MajorTimeInterval.Number/5;
+ else if( rExplicitIncrement.MajorTimeInterval.Number > 50 )
+ rExplicitIncrement.MinorTimeInterval.Number = rExplicitIncrement.MajorTimeInterval.Number;
+ }
else
{
- if( rExplicitIncrement.MajorTimeInterval.Number >= 2 )
+ switch( rExplicitIncrement.MajorTimeInterval.TimeUnit )
{
- if( !(rExplicitIncrement.MajorTimeInterval.Number%2) )
- rExplicitIncrement.MinorTimeInterval.Number = rExplicitIncrement.MajorTimeInterval.Number/2;
- else if( !(rExplicitIncrement.MajorTimeInterval.Number%3) )
- rExplicitIncrement.MinorTimeInterval.Number = rExplicitIncrement.MajorTimeInterval.Number/3;
- else if( !(rExplicitIncrement.MajorTimeInterval.Number%5) )
- rExplicitIncrement.MinorTimeInterval.Number = rExplicitIncrement.MajorTimeInterval.Number/5;
- else if( rExplicitIncrement.MajorTimeInterval.Number > 50 )
- rExplicitIncrement.MinorTimeInterval.Number = rExplicitIncrement.MajorTimeInterval.Number;
- }
- else
- {
- switch( rExplicitIncrement.MajorTimeInterval.TimeUnit )
- {
- case DAY:
- break;
- case MONTH:
- if( rExplicitScale.TimeResolution == DAY )
- rExplicitIncrement.MinorTimeInterval.TimeUnit = DAY;
- break;
- case YEAR:
- if( rExplicitScale.TimeResolution <= MONTH )
- rExplicitIncrement.MinorTimeInterval.TimeUnit = MONTH;
- break;
- }
+ case DAY:
+ break;
+ case MONTH:
+ if( rExplicitScale.TimeResolution == DAY )
+ rExplicitIncrement.MinorTimeInterval.TimeUnit = DAY;
+ break;
+ case YEAR:
+ if( rExplicitScale.TimeResolution <= MONTH )
+ rExplicitIncrement.MinorTimeInterval.TimeUnit = MONTH;
+ break;
}
}
}
diff --git a/chart2/source/view/axes/Tickmarks_Equidistant.cxx b/chart2/source/view/axes/Tickmarks_Equidistant.cxx
index d678b58e56ad..60f6e63311ad 100644
--- a/chart2/source/view/axes/Tickmarks_Equidistant.cxx
+++ b/chart2/source/view/axes/Tickmarks_Equidistant.cxx
@@ -105,23 +105,23 @@ EquidistantTickFactory::EquidistantTickFactory(
m_fOuterMajorTickBorderMin_Scaled = m_fOuterMajorTickBorderMin;
m_fOuterMajorTickBorderMax_Scaled = m_fOuterMajorTickBorderMax;
- if(!m_rIncrement.PostEquidistant && m_xInverseScaling.is() )
+ if(!(!m_rIncrement.PostEquidistant && m_xInverseScaling.is()) )
+ return;
+
+ m_fOuterMajorTickBorderMin_Scaled = m_rScale.Scaling->doScaling(m_fOuterMajorTickBorderMin);
+ m_fOuterMajorTickBorderMax_Scaled = m_rScale.Scaling->doScaling(m_fOuterMajorTickBorderMax);
+
+ //check validity of new range: m_fOuterMajorTickBorderMin <-> m_fOuterMajorTickBorderMax
+ //it is assumed here, that the original range in the given Scale is valid
+ if( !std::isfinite(m_fOuterMajorTickBorderMin_Scaled) )
{
+ m_fOuterMajorTickBorderMin += m_rIncrement.Distance;
m_fOuterMajorTickBorderMin_Scaled = m_rScale.Scaling->doScaling(m_fOuterMajorTickBorderMin);
+ }
+ if( !std::isfinite(m_fOuterMajorTickBorderMax_Scaled) )
+ {
+ m_fOuterMajorTickBorderMax -= m_rIncrement.Distance;
m_fOuterMajorTickBorderMax_Scaled = m_rScale.Scaling->doScaling(m_fOuterMajorTickBorderMax);
-
- //check validity of new range: m_fOuterMajorTickBorderMin <-> m_fOuterMajorTickBorderMax
- //it is assumed here, that the original range in the given Scale is valid
- if( !std::isfinite(m_fOuterMajorTickBorderMin_Scaled) )
- {
- m_fOuterMajorTickBorderMin += m_rIncrement.Distance;
- m_fOuterMajorTickBorderMin_Scaled = m_rScale.Scaling->doScaling(m_fOuterMajorTickBorderMin);
- }
- if( !std::isfinite(m_fOuterMajorTickBorderMax_Scaled) )
- {
- m_fOuterMajorTickBorderMax -= m_rIncrement.Distance;
- m_fOuterMajorTickBorderMax_Scaled = m_rScale.Scaling->doScaling(m_fOuterMajorTickBorderMax);
- }
}
}
diff --git a/chart2/source/view/axes/VAxisBase.cxx b/chart2/source/view/axes/VAxisBase.cxx
index 16d951bdb5ad..164a9147cc4f 100644
--- a/chart2/source/view/axes/VAxisBase.cxx
+++ b/chart2/source/view/axes/VAxisBase.cxx
@@ -212,17 +212,17 @@ size_t VAxisBase::getIndexOfLongestLabel( const uno::Sequence<OUString>& rLabels
void VAxisBase::removeTextShapesFromTicks()
{
- if( m_xTextTarget.is() )
+ if( !m_xTextTarget.is() )
+ return;
+
+ for (auto & tickInfos : m_aAllTickInfos)
{
- for (auto & tickInfos : m_aAllTickInfos)
+ for (auto & tickInfo : tickInfos)
{
- for (auto & tickInfo : tickInfos)
+ if(tickInfo.xTextShape.is())
{
- if(tickInfo.xTextShape.is())
- {
- m_xTextTarget->remove(tickInfo.xTextShape);
- tickInfo.xTextShape = nullptr;
- }
+ m_xTextTarget->remove(tickInfo.xTextShape);
+ tickInfo.xTextShape = nullptr;
}
}
}
diff --git a/chart2/source/view/axes/VAxisProperties.cxx b/chart2/source/view/axes/VAxisProperties.cxx
index d35bc04a0d24..27a4950a886b 100644
--- a/chart2/source/view/axes/VAxisProperties.cxx
+++ b/chart2/source/view/axes/VAxisProperties.cxx
@@ -349,38 +349,38 @@ void AxisLabelProperties::init( const uno::Reference< XAxis >& xAxisModel )
{
uno::Reference< beans::XPropertySet > xProp =
uno::Reference<beans::XPropertySet>::query( xAxisModel );
- if(xProp.is())
+ if(!xProp.is())
+ return;
+
+ try
{
- try
+ xProp->getPropertyValue( "TextBreak" ) >>= bLineBreakAllowed;
+ xProp->getPropertyValue( "TextOverlap" ) >>= bOverlapAllowed;
+ xProp->getPropertyValue( "StackCharacters" ) >>= bStackCharacters;
+ xProp->getPropertyValue( "TextRotation" ) >>= fRotationAngleDegree;
+
+ css::chart::ChartAxisArrangeOrderType eArrangeOrder;
+ xProp->getPropertyValue( "ArrangeOrder" ) >>= eArrangeOrder;
+ switch(eArrangeOrder)
{
- xProp->getPropertyValue( "TextBreak" ) >>= bLineBreakAllowed;
- xProp->getPropertyValue( "TextOverlap" ) >>= bOverlapAllowed;
- xProp->getPropertyValue( "StackCharacters" ) >>= bStackCharacters;
- xProp->getPropertyValue( "TextRotation" ) >>= fRotationAngleDegree;
-
- css::chart::ChartAxisArrangeOrderType eArrangeOrder;
- xProp->getPropertyValue( "ArrangeOrder" ) >>= eArrangeOrder;
- switch(eArrangeOrder)
- {
- case css::chart::ChartAxisArrangeOrderType_SIDE_BY_SIDE:
- eStaggering = AxisLabelStaggering::SideBySide;
- break;
- case css::chart::ChartAxisArrangeOrderType_STAGGER_EVEN:
- eStaggering = AxisLabelStaggering::StaggerEven;
- break;
- case css::chart::ChartAxisArrangeOrderType_STAGGER_ODD:
- eStaggering = AxisLabelStaggering::StaggerOdd;
- break;
- default:
- eStaggering = AxisLabelStaggering::StaggerAuto;
- break;
- }
- }
- catch( const uno::Exception& )
- {
- TOOLS_WARN_EXCEPTION("chart2", "" );
+ case css::chart::ChartAxisArrangeOrderType_SIDE_BY_SIDE:
+ eStaggering = AxisLabelStaggering::SideBySide;
+ break;
+ case css::chart::ChartAxisArrangeOrderType_STAGGER_EVEN:
+ eStaggering = AxisLabelStaggering::StaggerEven;
+ break;
+ case css::chart::ChartAxisArrangeOrderType_STAGGER_ODD:
+ eStaggering = AxisLabelStaggering::StaggerOdd;
+ break;
+ default:
+ eStaggering = AxisLabelStaggering::StaggerAuto;
+ break;
}
}
+ catch( const uno::Exception& )
+ {
+ TOOLS_WARN_EXCEPTION("chart2", "" );
+ }
}
bool AxisLabelProperties::isStaggered() const
diff --git a/chart2/source/view/axes/VCartesianAxis.cxx b/chart2/source/view/axes/VCartesianAxis.cxx
index dbf360ad8ab0..d4183118cca5 100644
--- a/chart2/source/view/axes/VCartesianAxis.cxx
+++ b/chart2/source/view/axes/VCartesianAxis.cxx
@@ -105,18 +105,18 @@ static void lcl_ResizeTextShapeToFitAvailableSpace( Reference< drawing::XShape >
nNewLen = ( rLabel.getLength() >= sDots.getLength() ) ? sDots.getLength() : rLabel.getLength();
bool bCrop = nCharsToRemove > 0;
- if( bCrop )
- {
- OUString aNewLabel = rLabel.copy( 0, nNewLen );
- if( nNewLen > sDots.getLength() )
- aNewLabel += sDots;
- xTextRange->setString( aNewLabel );
+ if( !bCrop )
+ return;
- uno::Reference< beans::XPropertySet > xProp( xTextRange, uno::UNO_QUERY );
- if( xProp.is() )
- {
- PropertyMapper::setMultiProperties( rPropNames, rPropValues, xProp );
- }
+ OUString aNewLabel = rLabel.copy( 0, nNewLen );
+ if( nNewLen > sDots.getLength() )
+ aNewLabel += sDots;
+ xTextRange->setString( aNewLabel );
+
+ uno::Reference< beans::XPropertySet > xProp( xTextRange, uno::UNO_QUERY );
+ if( xProp.is() )
+ {
+ PropertyMapper::setMultiProperties( rPropNames, rPropValues, xProp );
}
}
@@ -1448,65 +1448,65 @@ void VCartesianAxis::get2DAxisMainLine(
if(m_nDimension==3 && !AxisHelper::isAxisPositioningEnabled() )
rAlignment.mfInnerTickDirection = rAlignment.mfLabelDirection;//to behave like before
- if(m_nDimension==3 && AxisHelper::isAxisPositioningEnabled() )
- {
- double fDeltaX = rEnd.getX() - rStart.getX();
- double fDeltaY = rEnd.getY() - rStart.getY();
-
- if( m_nDimensionIndex==2 )
- {
- if( m_eLeftWallPos != CuboidPlanePosition_Left )
- {
- rAlignment.mfLabelDirection *= -1.0;
- rAlignment.mfInnerTickDirection *= -1.0;
- }
+ if(!(m_nDimension==3 && AxisHelper::isAxisPositioningEnabled()) )
+ return;
- rAlignment.meAlignment =
- (rAlignment.mfLabelDirection < 0) ?
- LABEL_ALIGN_LEFT : LABEL_ALIGN_RIGHT;
+ double fDeltaX = rEnd.getX() - rStart.getX();
+ double fDeltaY = rEnd.getY() - rStart.getY();
- if( ( fDeltaY<0 && m_aScale.Orientation == chart2::AxisOrientation_REVERSE ) ||
- ( fDeltaY>0 && m_aScale.Orientation == chart2::AxisOrientation_MATHEMATICAL ) )
- rAlignment.meAlignment =
- (rAlignment.meAlignment == LABEL_ALIGN_RIGHT) ?
- LABEL_ALIGN_LEFT : LABEL_ALIGN_RIGHT;
- }
- else if( fabs(fDeltaY) > fabs(fDeltaX) )
+ if( m_nDimensionIndex==2 )
+ {
+ if( m_eLeftWallPos != CuboidPlanePosition_Left )
{
- if( m_eBackWallPos != CuboidPlanePosition_Back )
- {
- rAlignment.mfLabelDirection *= -1.0;
- rAlignment.mfInnerTickDirection *= -1.0;
- }
+ rAlignment.mfLabelDirection *= -1.0;
+ rAlignment.mfInnerTickDirection *= -1.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 ) )
rAlignment.meAlignment =
- (rAlignment.mfLabelDirection < 0) ?
+ (rAlignment.meAlignment == LABEL_ALIGN_RIGHT) ?
LABEL_ALIGN_LEFT : LABEL_ALIGN_RIGHT;
-
- if( ( fDeltaY<0 && m_aScale.Orientation == chart2::AxisOrientation_REVERSE ) ||
- ( fDeltaY>0 && m_aScale.Orientation == chart2::AxisOrientation_MATHEMATICAL ) )
- rAlignment.meAlignment =
- (rAlignment.meAlignment == LABEL_ALIGN_RIGHT) ?
- LABEL_ALIGN_LEFT : LABEL_ALIGN_RIGHT;
- }
- else
+ }
+ else if( fabs(fDeltaY) > fabs(fDeltaX) )
+ {
+ if( m_eBackWallPos != CuboidPlanePosition_Back )
{
- if( m_eBackWallPos != CuboidPlanePosition_Back )
- {
- rAlignment.mfLabelDirection *= -1.0;
- rAlignment.mfInnerTickDirection *= -1.0;
- }
+ rAlignment.mfLabelDirection *= -1.0;
+ rAlignment.mfInnerTickDirection *= -1.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 ) )
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 ) )
- rAlignment.meAlignment =
- (rAlignment.meAlignment == LABEL_ALIGN_TOP) ?
- LABEL_ALIGN_BOTTOM : LABEL_ALIGN_TOP;
+ (rAlignment.meAlignment == LABEL_ALIGN_RIGHT) ?
+ LABEL_ALIGN_LEFT : LABEL_ALIGN_RIGHT;
+ }
+ else
+ {
+ if( m_eBackWallPos != CuboidPlanePosition_Back )
+ {
+ rAlignment.mfLabelDirection *= -1.0;
+ rAlignment.mfInnerTickDirection *= -1.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 ) )
+ rAlignment.meAlignment =
+ (rAlignment.meAlignment == LABEL_ALIGN_TOP) ?
+ LABEL_ALIGN_BOTTOM : LABEL_ALIGN_TOP;
}
}
diff --git a/chart2/source/view/axes/VPolarAngleAxis.cxx b/chart2/source/view/axes/VPolarAngleAxis.cxx
index cc2427a87581..f9b7399694b0 100644
--- a/chart2/source/view/axes/VPolarAngleAxis.cxx
+++ b/chart2/source/view/axes/VPolarAngleAxis.cxx
@@ -160,26 +160,26 @@ void VPolarAngleAxis::createLabels()
double fLogicRadius = m_pPosHelper->getOuterLogicRadius();
- if( m_aAxisProperties.m_bDisplayLabels )
- {
- //create tick mark text shapes
- //@todo: iterate through all tick depth which should be labeled
+ if( !m_aAxisProperties.m_bDisplayLabels )
+ return;
- EquidistantTickIter aTickIter( m_aAllTickInfos, m_aIncrement, 0 );
- updateUnscaledValuesAtTicks( aTickIter );
+ //create tick mark text shapes
+ //@todo: iterate through all tick depth which should be labeled
- removeTextShapesFromTicks();
+ EquidistantTickIter aTickIter( m_aAllTickInfos, m_aIncrement, 0 );
+ updateUnscaledValuesAtTicks( aTickIter );
- AxisLabelProperties aAxisLabelProperties( m_aAxisLabelProperties );
- aAxisLabelProperties.bOverlapAllowed = true;
- double const fLogicZ = 1.0;//as defined
- createTextShapes_ForAngleAxis( m_xTextTarget, aTickIter
- , aAxisLabelProperties
- , fLogicRadius, fLogicZ
- );
+ removeTextShapesFromTicks();
- //no staggering for polar angle axis
- }
+ AxisLabelProperties aAxisLabelProperties( m_aAxisLabelProperties );
+ aAxisLabelProperties.bOverlapAllowed = true;
+ double const fLogicZ = 1.0;//as defined
+ createTextShapes_ForAngleAxis( m_xTextTarget, aTickIter
+ , aAxisLabelProperties
+ , fLogicRadius, fLogicZ
+ );
+
+ //no staggering for polar angle axis
}
void VPolarAngleAxis::createShapes()