diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2022-05-24 15:26:06 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2022-05-24 16:50:03 +0200 |
commit | 5060c5015882b7109c54598c4ea858949beafc43 (patch) | |
tree | c8c153d73f6c6ebbe2dae768c1da72d28312efd4 /chart2/source/view | |
parent | a86818c15a6b4773ddd012db37d55b5204163c24 (diff) |
Use o3tl::make_unsigned in some places
...where a signed and an unsigned value are compared, and the signed value has
just been proven to be non-negative here
Change-Id: I20600d61a5d59d739bc1bee838c0038e4611aec2
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134875
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'chart2/source/view')
-rw-r--r-- | chart2/source/view/axes/VCartesianAxis.cxx | 3 | ||||
-rw-r--r-- | chart2/source/view/charttypes/AreaChart.cxx | 3 | ||||
-rw-r--r-- | chart2/source/view/charttypes/NetChart.cxx | 3 | ||||
-rw-r--r-- | chart2/source/view/charttypes/VSeriesPlotter.cxx | 5 |
4 files changed, 9 insertions, 5 deletions
diff --git a/chart2/source/view/axes/VCartesianAxis.cxx b/chart2/source/view/axes/VCartesianAxis.cxx index 95a86fe377c2..b14ea4e18878 100644 --- a/chart2/source/view/axes/VCartesianAxis.cxx +++ b/chart2/source/view/axes/VCartesianAxis.cxx @@ -29,6 +29,7 @@ #include "Tickmarks_Equidistant.hxx" #include <ExplicitCategoriesProvider.hxx> #include <com/sun/star/chart2/AxisType.hpp> +#include <o3tl/safeint.hxx> #include <rtl/math.hxx> #include <tools/diagnose_ex.h> #include <tools/color.hxx> @@ -662,7 +663,7 @@ void VCartesianAxis::createAllTickInfos( TickInfoArraysType& rAllTickInfos ) TickIter* VCartesianAxis::createLabelTickIterator( sal_Int32 nTextLevel ) { - if( nTextLevel>=0 && nTextLevel < static_cast< sal_Int32 >(m_aAllTickInfos.size()) ) + if( nTextLevel>=0 && o3tl::make_unsigned(nTextLevel) < m_aAllTickInfos.size() ) return new PureTickIter( m_aAllTickInfos[nTextLevel] ); return nullptr; } diff --git a/chart2/source/view/charttypes/AreaChart.cxx b/chart2/source/view/charttypes/AreaChart.cxx index d7f862ae5cec..9cb2e06ba761 100644 --- a/chart2/source/view/charttypes/AreaChart.cxx +++ b/chart2/source/view/charttypes/AreaChart.cxx @@ -38,6 +38,7 @@ #include <com/sun/star/chart/MissingValueTreatment.hpp> #include <sal/log.hxx> +#include <o3tl/safeint.hxx> #include <osl/diagnose.h> #include <com/sun/star/beans/XPropertySet.hpp> @@ -700,7 +701,7 @@ void AreaChart::createShapes() { std::vector<std::vector<css::drawing::Position3D>>& rPolygon = pSeries->m_aPolyPolygonShape3D; sal_Int32& rIndex = pSeries->m_nPolygonIndex; - if( 0<= rIndex && rIndex < static_cast<sal_Int32>(rPolygon.size()) ) + if( 0<= rIndex && o3tl::make_unsigned(rIndex) < rPolygon.size() ) { if( !rPolygon[ rIndex ].empty() ) rIndex++; //start a new polygon for the next point if the current poly is not empty diff --git a/chart2/source/view/charttypes/NetChart.cxx b/chart2/source/view/charttypes/NetChart.cxx index 647ea083f583..5b8f1db34be5 100644 --- a/chart2/source/view/charttypes/NetChart.cxx +++ b/chart2/source/view/charttypes/NetChart.cxx @@ -33,6 +33,7 @@ #include <com/sun/star/chart/DataLabelPlacement.hpp> #include <com/sun/star/chart/MissingValueTreatment.hpp> +#include <o3tl/safeint.hxx> #include <osl/diagnose.h> #include <officecfg/Office/Compatibility.hxx> @@ -440,7 +441,7 @@ void NetChart::createShapes() { std::vector<std::vector<css::drawing::Position3D>>& rPolygon = pSeries->m_aPolyPolygonShape3D; sal_Int32& rIndex = pSeries->m_nPolygonIndex; - if( 0<= rIndex && rIndex < static_cast<sal_Int32>(rPolygon.size()) ) + if( 0<= rIndex && o3tl::make_unsigned(rIndex) < rPolygon.size() ) { if( !rPolygon[ rIndex ].empty() ) rIndex++; //start a new polygon for the next point if the current poly is not empty diff --git a/chart2/source/view/charttypes/VSeriesPlotter.cxx b/chart2/source/view/charttypes/VSeriesPlotter.cxx index eaa7f0743f03..0b2ad886f68f 100644 --- a/chart2/source/view/charttypes/VSeriesPlotter.cxx +++ b/chart2/source/view/charttypes/VSeriesPlotter.cxx @@ -66,6 +66,7 @@ #include <com/sun/star/chart2/XDataPointCustomLabelField.hpp> #include <com/sun/star/container/XChild.hpp> #include <com/sun/star/chart2/RelativePosition.hpp> +#include <o3tl/safeint.hxx> #include <tools/color.hxx> #include <tools/UnitConversion.hxx> #include <rtl/ustrbuf.hxx> @@ -193,7 +194,7 @@ void VSeriesPlotter::addSeries( std::unique_ptr<VDataSeries> pSeries, sal_Int32 pSeries->setXValuesIfNone( m_pExplicitCategoriesProvider->getOriginalCategories() ); } - if(zSlot<0 || zSlot>=static_cast<sal_Int32>(m_aZSlots.size())) + if(zSlot<0 || o3tl::make_unsigned(zSlot)>=m_aZSlots.size()) { //new z slot std::vector< VDataSeriesGroup > aZSlot; @@ -205,7 +206,7 @@ void VSeriesPlotter::addSeries( std::unique_ptr<VDataSeries> pSeries, sal_Int32 //existing zslot std::vector< VDataSeriesGroup >& rXSlots = m_aZSlots[zSlot]; - if(xSlot<0 || xSlot>=static_cast<sal_Int32>(rXSlots.size())) + if(xSlot<0 || o3tl::make_unsigned(xSlot)>=rXSlots.size()) { //append the series to already existing x series rXSlots.emplace_back( std::move(pSeries) ); |