summaryrefslogtreecommitdiff
path: root/chart2/source
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2022-05-06 15:41:23 +0900
committerTomaž Vajngerl <quikee@gmail.com>2022-05-11 01:58:14 +0200
commit35f4f75a506839025bca529bd7cc5a60ffe7a20f (patch)
tree9a0a3d9ae42a499b48a680986188a9bdf6b79f9c /chart2/source
parent23689e492feb41a391738586cef04ab82cc21f80 (diff)
chart2: simplify with structured binding decl. and some cleanup
- use structured binding declaration to simplify the code - use cend() instead of end() - use std::clamp to bound a value Change-Id: I83b9ba926e70d173cc161db713c53940df422241 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133923 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'chart2/source')
-rw-r--r--chart2/source/view/axes/VCartesianCoordinateSystem.cxx20
-rw-r--r--chart2/source/view/axes/VCoordinateSystem.cxx51
-rw-r--r--chart2/source/view/main/SeriesPlotterContainer.cxx18
3 files changed, 40 insertions, 49 deletions
diff --git a/chart2/source/view/axes/VCartesianCoordinateSystem.cxx b/chart2/source/view/axes/VCartesianCoordinateSystem.cxx
index 866c8fdd89bb..1257ff6f4e77 100644
--- a/chart2/source/view/axes/VCartesianCoordinateSystem.cxx
+++ b/chart2/source/view/axes/VCartesianCoordinateSystem.cxx
@@ -175,16 +175,13 @@ void VCartesianCoordinateSystem::initVAxisInList()
sal_Int32 nDimensionCount = m_xCooSysModel->getDimension();
bool bSwapXAndY = getPropertySwapXAndYAxis();
- for (auto const& elem : m_aAxisMap)
+ for (auto const& [nIndexPair, pVAxis] : m_aAxisMap)
{
- VAxisBase* pVAxis = elem.second.get();
- if( pVAxis )
+ if (pVAxis)
{
- sal_Int32 nDimensionIndex = elem.first.first;
- sal_Int32 nAxisIndex = elem.first.second;
+ auto [nDimensionIndex, nAxisIndex] = nIndexPair;
pVAxis->setExplicitScaleAndIncrement( getExplicitScale( nDimensionIndex, nAxisIndex ), getExplicitIncrement( nDimensionIndex, nAxisIndex ) );
- pVAxis->initPlotter(m_xLogicTargetForAxes,m_xFinalTarget
- , createCIDForAxis( nDimensionIndex, nAxisIndex ) );
+ pVAxis->initPlotter(m_xLogicTargetForAxes, m_xFinalTarget, createCIDForAxis( nDimensionIndex, nAxisIndex ) );
if(nDimensionCount==2)
pVAxis->setTransformationSceneToScreen( m_aMatrixSceneToScreen );
pVAxis->setScales( getExplicitScales(nDimensionIndex,nAxisIndex), bSwapXAndY );
@@ -200,13 +197,12 @@ void VCartesianCoordinateSystem::updateScalesAndIncrementsOnAxes()
sal_Int32 nDimensionCount = m_xCooSysModel->getDimension();
bool bSwapXAndY = getPropertySwapXAndYAxis();
- for (auto const& elem : m_aAxisMap)
+ for (auto const& [nIndexPair, pVAxis] : m_aAxisMap)
{
- VAxisBase* pVAxis = elem.second.get();
- if( pVAxis )
+ if (pVAxis)
{
- sal_Int32 nDimensionIndex = elem.first.first;
- sal_Int32 nAxisIndex = elem.first.second;
+ auto [nDimensionIndex, nAxisIndex] = nIndexPair;
+
pVAxis->setExplicitScaleAndIncrement( getExplicitScale( nDimensionIndex, nAxisIndex ), getExplicitIncrement( nDimensionIndex, nAxisIndex ) );
if(nDimensionCount==2)
pVAxis->setTransformationSceneToScreen( m_aMatrixSceneToScreen );
diff --git a/chart2/source/view/axes/VCoordinateSystem.cxx b/chart2/source/view/axes/VCoordinateSystem.cxx
index 7819a916e039..25a0f5d35c09 100644
--- a/chart2/source/view/axes/VCoordinateSystem.cxx
+++ b/chart2/source/view/axes/VCoordinateSystem.cxx
@@ -208,10 +208,7 @@ std::vector< Reference< beans::XPropertySet > > VCoordinateSystem::getGridListFr
void VCoordinateSystem::impl_adjustDimension( sal_Int32& rDimensionIndex )
{
- if( rDimensionIndex<0 )
- rDimensionIndex=0;
- if( rDimensionIndex>2 )
- rDimensionIndex=2;
+ rDimensionIndex = std::clamp<sal_Int32>(rDimensionIndex, 0, 2);
}
void VCoordinateSystem::impl_adjustDimensionAndIndex( sal_Int32& rDimensionIndex, sal_Int32& rAxisIndex ) const
@@ -419,7 +416,7 @@ VAxisBase* VCoordinateSystem::getVAxis( sal_Int32 nDimensionIndex, sal_Int32 nAx
tFullAxisIndex aFullAxisIndex( nDimensionIndex, nAxisIndex );
tVAxisMap::const_iterator aIt = m_aAxisMap.find( aFullAxisIndex );
- if( aIt != m_aAxisMap.end() )
+ if (aIt != m_aAxisMap.cend())
pRet = aIt->second.get();
return pRet;
@@ -455,26 +452,26 @@ void VCoordinateSystem::set3DWallPositions( CuboidPlanePosition eLeftWallPos, Cu
void VCoordinateSystem::createMaximumAxesLabels()
{
- for (auto const& elem : m_aAxisMap)
+ for (auto const&[unused, pVAxis] : m_aAxisMap)
{
- VAxisBase* pVAxis = elem.second.get();
- if( pVAxis )
+ (void)unused;
+ if (pVAxis)
{
- if(pVAxis->getDimensionCount()==2)
- pVAxis->setTransformationSceneToScreen( m_aMatrixSceneToScreen );
+ if (pVAxis->getDimensionCount() == 2)
+ pVAxis->setTransformationSceneToScreen(m_aMatrixSceneToScreen);
pVAxis->createMaximumLabels();
}
}
}
void VCoordinateSystem::createAxesLabels()
{
- for (auto const& elem : m_aAxisMap)
+ for (auto const&[unused, pVAxis] : m_aAxisMap)
{
- VAxisBase* pVAxis = elem.second.get();
- if( pVAxis )
+ (void)unused;
+ if (pVAxis)
{
- if(pVAxis->getDimensionCount()==2)
- pVAxis->setTransformationSceneToScreen( m_aMatrixSceneToScreen );
+ if (pVAxis->getDimensionCount() == 2)
+ pVAxis->setTransformationSceneToScreen(m_aMatrixSceneToScreen);
pVAxis->createLabels();
}
}
@@ -482,12 +479,12 @@ void VCoordinateSystem::createAxesLabels()
void VCoordinateSystem::updatePositions()
{
- for (auto const& elem : m_aAxisMap)
+ for (auto const&[unused, pVAxis] : m_aAxisMap)
{
- VAxisBase* pVAxis = elem.second.get();
- if( pVAxis )
+ (void)unused;
+ if (pVAxis)
{
- if(pVAxis->getDimensionCount()==2)
+ if (pVAxis->getDimensionCount() == 2)
pVAxis->setTransformationSceneToScreen( m_aMatrixSceneToScreen );
pVAxis->updatePositions();
}
@@ -496,24 +493,24 @@ void VCoordinateSystem::updatePositions()
void VCoordinateSystem::createAxesShapes()
{
- for (auto const& elem : m_aAxisMap)
+ for (auto const&[aFullAxisIndex, pVAxis] : m_aAxisMap)
{
- VAxisBase* pVAxis = elem.second.get();
- if( pVAxis )
+ if (pVAxis)
{
- if(pVAxis->getDimensionCount()==2)
+ auto const&[nDimensionIndex, nAxisIndex] = aFullAxisIndex;
+
+ if (pVAxis->getDimensionCount() == 2)
pVAxis->setTransformationSceneToScreen( m_aMatrixSceneToScreen );
- tFullAxisIndex aFullAxisIndex = elem.first;
- if( aFullAxisIndex.second == 0 )
+ if (nAxisIndex == 0)
{
- if( aFullAxisIndex.first == 0 )
+ if (nDimensionIndex == 0)
{
if( m_aExplicitScales[1].AxisType!=AxisType::CATEGORY )
pVAxis->setExtraLinePositionAtOtherAxis(
m_aExplicitScales[1].Origin );
}
- else if( aFullAxisIndex.first == 1 )
+ else if (nDimensionIndex == 1)
{
if( m_aExplicitScales[0].AxisType!=AxisType::CATEGORY )
pVAxis->setExtraLinePositionAtOtherAxis(
diff --git a/chart2/source/view/main/SeriesPlotterContainer.cxx b/chart2/source/view/main/SeriesPlotterContainer.cxx
index 427c9c169b11..1e8bd45ee489 100644
--- a/chart2/source/view/main/SeriesPlotterContainer.cxx
+++ b/chart2/source/view/main/SeriesPlotterContainer.cxx
@@ -498,10 +498,9 @@ void SeriesPlotterContainer::doAutoScaling(ChartModel& rChartModel)
for (sal_Int32 nAxisIndex = 0; nAxisIndex <= m_nMaxAxisIndex; ++nAxisIndex)
{
// - first do autoscale for all x and z scales (because they are treated independent)
- for (auto& axisUsage : m_aAxisUsageList)
+ for (auto & [ rAxis, rAxisUsage ] : m_aAxisUsageList)
{
- AxisUsage& rAxisUsage = axisUsage.second;
-
+ (void)rAxis;
rAxisUsage.prepareAutomaticAxisScaling(rAxisUsage.aAutoScaling, 0, nAxisIndex);
rAxisUsage.prepareAutomaticAxisScaling(rAxisUsage.aAutoScaling, 2, nAxisIndex);
@@ -517,10 +516,9 @@ void SeriesPlotterContainer::doAutoScaling(ChartModel& rChartModel)
}
// - second do autoscale for the dependent y scales (the coordinate systems are prepared with x and z scales already )
- for (auto& axisUsage : m_aAxisUsageList)
+ for (auto & [ rAxis, rAxisUsage ] : m_aAxisUsageList)
{
- AxisUsage& rAxisUsage = axisUsage.second;
-
+ (void)rAxis;
rAxisUsage.prepareAutomaticAxisScaling(rAxisUsage.aAutoScaling, 1, nAxisIndex);
ExplicitScaleData aExplicitScale;
@@ -544,9 +542,9 @@ void SeriesPlotterContainer::AdaptScaleOfYAxisWithoutAttachedSeries(ChartModel&
//issue #i80518#
for (sal_Int32 nAxisIndex = 0; nAxisIndex <= m_nMaxAxisIndex; nAxisIndex++)
{
- for (auto& axisUsage : m_aAxisUsageList)
+ for (auto & [ rAxis, rAxisUsage ] : m_aAxisUsageList)
{
- AxisUsage& rAxisUsage = axisUsage.second;
+ (void)rAxis;
std::vector<VCoordinateSystem*> aVCooSysList_Y
= rAxisUsage.getCoordinateSystems(1, nAxisIndex);
if (aVCooSysList_Y.empty())
@@ -648,9 +646,9 @@ void SeriesPlotterContainer::AdaptScaleOfYAxisWithoutAttachedSeries(ChartModel&
//correct origin for y main axis (the origin is where the other main axis crosses)
sal_Int32 nAxisIndex = 0;
sal_Int32 nDimensionIndex = 1;
- for (auto& axisUsage : m_aAxisUsageList)
+ for (auto & [ rAxis, rAxisUsage ] : m_aAxisUsageList)
{
- AxisUsage& rAxisUsage = axisUsage.second;
+ (void)rAxis;
std::vector<VCoordinateSystem*> aVCooSysList
= rAxisUsage.getCoordinateSystems(nDimensionIndex, nAxisIndex);
size_t nC;