summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--accessibility/source/extended/accessibletabbar.cxx3
-rw-r--r--accessibility/source/extended/accessibletabbarpagelist.cxx13
-rw-r--r--accessibility/source/standard/accessiblemenubasecomponent.cxx21
-rw-r--r--accessibility/source/standard/vclxaccessiblelist.cxx2
-rw-r--r--accessibility/source/standard/vclxaccessiblestatusbar.cxx15
-rw-r--r--accessibility/source/standard/vclxaccessibletabcontrol.cxx10
-rw-r--r--basic/source/classes/sb.cxx5
-rw-r--r--basic/source/sbx/sbxarray.cxx2
-rw-r--r--basic/source/sbx/sbxcoll.cxx5
-rw-r--r--chart2/source/controller/chartapiwrapper/DataSeriesPointWrapper.cxx3
-rw-r--r--chart2/source/model/main/BaseCoordinateSystem.cxx2
-rw-r--r--chart2/source/tools/AxisHelper.cxx5
-rw-r--r--chart2/source/tools/CommonConverters.cxx3
-rw-r--r--chart2/source/tools/DiagramHelper.cxx7
-rw-r--r--chart2/source/tools/InternalData.cxx5
-rw-r--r--chart2/source/tools/ObjectIdentifier.cxx7
-rw-r--r--chart2/source/tools/RegressionCurveHelper.cxx3
-rw-r--r--chart2/source/view/axes/VCartesianAxis.cxx3
-rw-r--r--chart2/source/view/charttypes/AreaChart.cxx3
-rw-r--r--chart2/source/view/charttypes/NetChart.cxx3
-rw-r--r--chart2/source/view/charttypes/VSeriesPlotter.cxx5
-rw-r--r--connectivity/source/commontools/FDatabaseMetaDataResultSet.cxx3
-rw-r--r--connectivity/source/commontools/paramwrapper.cxx3
-rw-r--r--connectivity/source/drivers/file/FPreparedStatement.cxx3
-rw-r--r--connectivity/source/drivers/file/FResultSet.cxx3
-rw-r--r--connectivity/source/drivers/file/FResultSetMetaData.cxx3
-rw-r--r--connectivity/source/drivers/mysqlc/mysqlc_preparedstatement.cxx3
-rw-r--r--connectivity/source/drivers/mysqlc/mysqlc_resultset.cxx2
-rw-r--r--connectivity/source/drivers/mysqlc/mysqlc_resultsetmetadata.cxx3
-rw-r--r--connectivity/source/drivers/postgresql/pq_preparedstatement.cxx3
-rw-r--r--connectivity/source/drivers/postgresql/pq_xcolumns.cxx3
-rw-r--r--connectivity/source/drivers/postgresql/pq_xcontainer.cxx7
-rw-r--r--connectivity/source/drivers/postgresql/pq_xindexes.cxx3
-rw-r--r--connectivity/source/drivers/postgresql/pq_xkeys.cxx3
-rw-r--r--connectivity/source/drivers/postgresql/pq_xtables.cxx3
-rw-r--r--connectivity/source/drivers/postgresql/pq_xusers.cxx3
-rw-r--r--connectivity/source/drivers/postgresql/pq_xviews.cxx3
-rw-r--r--connectivity/source/inc/file/FResultSet.hxx3
-rw-r--r--connectivity/source/parse/sqliterator.cxx5
-rw-r--r--dbaccess/source/core/api/RowSet.cxx2
-rw-r--r--dbaccess/source/core/api/RowSetCache.cxx8
-rw-r--r--dbaccess/source/core/api/StaticSet.cxx5
-rw-r--r--dbaccess/source/core/dataaccess/bookmarkcontainer.cxx3
-rw-r--r--dbaccess/source/core/dataaccess/definitioncontainer.cxx3
-rw-r--r--dbaccess/source/ui/control/ColumnControlWindow.cxx3
-rw-r--r--dbaccess/source/ui/dlg/indexfieldscontrol.cxx3
-rw-r--r--dbaccess/source/ui/tabledesign/TEditControl.cxx3
-rw-r--r--dbaccess/source/ui/uno/copytablewizard.cxx3
-rw-r--r--desktop/source/deployment/gui/dp_gui_extlistbox.cxx11
-rw-r--r--drawinglayer/source/processor3d/zbufferprocessor3d.cxx3
-rw-r--r--editeng/source/editeng/editdoc.cxx23
-rw-r--r--editeng/source/editeng/editeng.cxx3
-rw-r--r--editeng/source/editeng/impedit2.cxx2
-rw-r--r--extensions/source/propctrlr/formmetadata.cxx3
-rw-r--r--extensions/source/propctrlr/genericpropertyhandler.cxx3
-rw-r--r--forms/source/component/ListBox.cxx2
-rw-r--r--forms/source/component/entrylisthelper.cxx9
-rw-r--r--forms/source/misc/InterfaceContainer.cxx9
-rw-r--r--forms/source/xforms/binding.cxx3
-rw-r--r--i18nutil/source/utility/scripttypedetector.cxx5
-rw-r--r--linguistic/source/lngopt.cxx4
-rw-r--r--oox/source/ppt/comments.cxx3
-rw-r--r--reportdesign/source/core/api/Functions.cxx3
-rw-r--r--reportdesign/source/core/api/Groups.cxx3
-rw-r--r--reportdesign/source/core/api/ReportControlModel.cxx3
-rw-r--r--reportdesign/source/core/api/ReportDefinition.cxx3
-rw-r--r--sc/source/core/data/dptabsrc.cxx2
-rw-r--r--sc/source/core/data/markmulti.cxx4
-rw-r--r--sc/source/core/tool/queryparam.cxx3
-rw-r--r--sc/source/filter/oox/pivottablebuffer.cxx3
-rw-r--r--sc/source/ui/docshell/impex.cxx2
-rw-r--r--sc/source/ui/unoobj/appluno.cxx3
-rw-r--r--sc/source/ui/unoobj/chart2uno.cxx2
-rw-r--r--sc/source/ui/unoobj/dapiuno.cxx5
-rw-r--r--sc/source/ui/unoobj/fmtuno.cxx3
-rw-r--r--sc/source/ui/unoobj/nameuno.cxx3
-rw-r--r--sc/source/ui/vba/vbafiledialogitems.cxx5
-rw-r--r--sd/source/filter/html/buttonset.cxx5
-rw-r--r--sd/source/ui/app/sdxfer.cxx3
-rw-r--r--sd/source/ui/slideshow/slideshowimpl.cxx3
-rw-r--r--sd/source/ui/slidesorter/model/SlideSorterModel.cxx3
-rw-r--r--sd/source/ui/unoidl/unocpres.cxx5
-rw-r--r--sdext/source/pdfimport/tree/imagecontainer.cxx3
-rw-r--r--sdext/source/presenter/PresenterAccessibility.cxx4
-rw-r--r--sdext/source/presenter/PresenterTextView.cxx2
-rw-r--r--sfx2/source/dialog/filtergrouping.cxx3
-rw-r--r--sfx2/source/sidebar/FocusManager.cxx5
-rw-r--r--svtools/source/brwbox/brwbox1.cxx2
-rw-r--r--svx/source/form/fmshimp.cxx4
-rw-r--r--svx/source/form/formcontroller.cxx2
-rw-r--r--svx/source/table/tablelayouter.hxx5
-rw-r--r--sw/source/core/access/acctable.cxx4
-rw-r--r--sw/source/core/unocore/unostyle.cxx2
-rw-r--r--sw/source/filter/ww8/ww8toolbar.cxx2
-rw-r--r--sw/source/uibase/uiview/viewmdi.cxx3
-rw-r--r--sw/source/uibase/uno/unoatxt.cxx2
-rw-r--r--vbahelper/source/msforms/vbacontrols.cxx3
-rw-r--r--vcl/unx/generic/window/salframe.cxx5
-rw-r--r--vcl/unx/gtk3/a11y/atktextattributes.cxx3
-rw-r--r--vcl/unx/gtk3/glomenu.cxx22
-rw-r--r--xmloff/source/chart/SchXMLChartContext.cxx3
-rw-r--r--xmloff/source/style/xmlprmap.cxx15
-rw-r--r--xmlsecurity/source/gpg/XMLSecurityContext.cxx5
-rw-r--r--xmlsecurity/source/xmlsec/nss/xmlsecuritycontext_nssimpl.cxx5
104 files changed, 279 insertions, 191 deletions
diff --git a/accessibility/source/extended/accessibletabbar.cxx b/accessibility/source/extended/accessibletabbar.cxx
index e983c1e47471..8bf2d7addc1d 100644
--- a/accessibility/source/extended/accessibletabbar.cxx
+++ b/accessibility/source/extended/accessibletabbar.cxx
@@ -30,6 +30,7 @@
#include <unotools/accessiblestatesethelper.hxx>
#include <unotools/accessiblerelationsethelper.hxx>
#include <i18nlangtag/languagetag.hxx>
+#include <o3tl/safeint.hxx>
#include <vcl/svapp.hxx>
#include <vcl/settings.hxx>
#include <toolkit/awt/vclxfont.hxx>
@@ -228,7 +229,7 @@ namespace accessibility
{
OExternalLockGuard aGuard( this );
- if ( i < 0 || i >= static_cast<sal_Int32>(m_aAccessibleChildren.size()) )
+ if ( i < 0 || o3tl::make_unsigned(i) >= m_aAccessibleChildren.size() )
throw IndexOutOfBoundsException();
Reference< XAccessible > xChild = m_aAccessibleChildren[i];
diff --git a/accessibility/source/extended/accessibletabbarpagelist.cxx b/accessibility/source/extended/accessibletabbarpagelist.cxx
index 3c7f9976e0af..a65750fbd4b3 100644
--- a/accessibility/source/extended/accessibletabbarpagelist.cxx
+++ b/accessibility/source/extended/accessibletabbarpagelist.cxx
@@ -25,6 +25,7 @@
#include <com/sun/star/accessibility/AccessibleStateType.hpp>
#include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
#include <cppuhelper/supportsservice.hxx>
+#include <o3tl/safeint.hxx>
#include <unotools/accessiblestatesethelper.hxx>
#include <unotools/accessiblerelationsethelper.hxx>
#include <vcl/svapp.hxx>
@@ -73,7 +74,7 @@ namespace accessibility
{
NotifyAccessibleEvent( AccessibleEventId::SELECTION_CHANGED, Any(), Any() );
- if ( i >= 0 && i < static_cast<sal_Int32>(m_aAccessibleChildren.size()) )
+ if ( i >= 0 && o3tl::make_unsigned(i) < m_aAccessibleChildren.size() )
{
Reference< XAccessible > xChild( m_aAccessibleChildren[i] );
if ( xChild.is() )
@@ -88,7 +89,7 @@ namespace accessibility
void AccessibleTabBarPageList::UpdatePageText( sal_Int32 i )
{
- if ( i < 0 || i >= static_cast<sal_Int32>(m_aAccessibleChildren.size()) )
+ if ( i < 0 || o3tl::make_unsigned(i) >= m_aAccessibleChildren.size() )
return;
Reference< XAccessible > xChild( m_aAccessibleChildren[i] );
@@ -106,7 +107,7 @@ namespace accessibility
void AccessibleTabBarPageList::InsertChild( sal_Int32 i )
{
- if ( i < 0 || i > static_cast<sal_Int32>(m_aAccessibleChildren.size()) )
+ if ( i < 0 || o3tl::make_unsigned(i) > m_aAccessibleChildren.size() )
return;
// insert entry in child list
@@ -125,7 +126,7 @@ namespace accessibility
void AccessibleTabBarPageList::RemoveChild( sal_Int32 i )
{
- if ( i < 0 || i >= static_cast<sal_Int32>(m_aAccessibleChildren.size()) )
+ if ( i < 0 || o3tl::make_unsigned(i) >= m_aAccessibleChildren.size() )
return;
// get the accessible of the removed page
@@ -150,8 +151,8 @@ namespace accessibility
void AccessibleTabBarPageList::MoveChild( sal_Int32 i, sal_Int32 j )
{
- if ( !(i >= 0 && i < static_cast<sal_Int32>(m_aAccessibleChildren.size()) &&
- j >= 0 && j <= static_cast<sal_Int32>(m_aAccessibleChildren.size())) )
+ if ( !(i >= 0 && o3tl::make_unsigned(i) < m_aAccessibleChildren.size() &&
+ j >= 0 && o3tl::make_unsigned(j) <= m_aAccessibleChildren.size()) )
return;
if ( i < j )
diff --git a/accessibility/source/standard/accessiblemenubasecomponent.cxx b/accessibility/source/standard/accessiblemenubasecomponent.cxx
index bce5968c7cfc..f28bf8ad0570 100644
--- a/accessibility/source/standard/accessiblemenubasecomponent.cxx
+++ b/accessibility/source/standard/accessiblemenubasecomponent.cxx
@@ -27,6 +27,7 @@
#include <com/sun/star/accessibility/AccessibleRole.hpp>
#include <com/sun/star/accessibility/AccessibleStateType.hpp>
#include <cppuhelper/supportsservice.hxx>
+#include <o3tl/safeint.hxx>
#include <unotools/accessiblestatesethelper.hxx>
#include <vcl/menu.hxx>
#include <vcl/vclevent.hxx>
@@ -195,7 +196,7 @@ void OAccessibleMenuBaseComponent::SetChecked( bool bChecked )
void OAccessibleMenuBaseComponent::UpdateEnabled( sal_Int32 i, bool bEnabled )
{
- if ( i >= 0 && i < static_cast<sal_Int32>(m_aAccessibleChildren.size()) )
+ if ( i >= 0 && o3tl::make_unsigned(i) < m_aAccessibleChildren.size() )
{
Reference< XAccessible > xChild( m_aAccessibleChildren[i] );
if ( xChild.is() )
@@ -210,7 +211,7 @@ void OAccessibleMenuBaseComponent::UpdateEnabled( sal_Int32 i, bool bEnabled )
void OAccessibleMenuBaseComponent::UpdateFocused( sal_Int32 i, bool bFocused )
{
- if ( i >= 0 && i < static_cast<sal_Int32>(m_aAccessibleChildren.size()) )
+ if ( i >= 0 && o3tl::make_unsigned(i) < m_aAccessibleChildren.size() )
{
Reference< XAccessible > xChild( m_aAccessibleChildren[i] );
if ( xChild.is() )
@@ -242,7 +243,7 @@ void OAccessibleMenuBaseComponent::UpdateSelected( sal_Int32 i, bool bSelected )
{
NotifyAccessibleEvent( AccessibleEventId::SELECTION_CHANGED, Any(), Any() );
- if ( i >= 0 && i < static_cast<sal_Int32>(m_aAccessibleChildren.size()) )
+ if ( i >= 0 && o3tl::make_unsigned(i) < m_aAccessibleChildren.size() )
{
Reference< XAccessible > xChild( m_aAccessibleChildren[i] );
if ( xChild.is() )
@@ -257,7 +258,7 @@ void OAccessibleMenuBaseComponent::UpdateSelected( sal_Int32 i, bool bSelected )
void OAccessibleMenuBaseComponent::UpdateChecked( sal_Int32 i, bool bChecked )
{
- if ( i >= 0 && i < static_cast<sal_Int32>(m_aAccessibleChildren.size()) )
+ if ( i >= 0 && o3tl::make_unsigned(i) < m_aAccessibleChildren.size() )
{
Reference< XAccessible > xChild( m_aAccessibleChildren[i] );
if ( xChild.is() )
@@ -272,7 +273,7 @@ void OAccessibleMenuBaseComponent::UpdateChecked( sal_Int32 i, bool bChecked )
void OAccessibleMenuBaseComponent::UpdateAccessibleName( sal_Int32 i )
{
- if ( i >= 0 && i < static_cast<sal_Int32>(m_aAccessibleChildren.size()) )
+ if ( i >= 0 && o3tl::make_unsigned(i) < m_aAccessibleChildren.size() )
{
Reference< XAccessible > xChild( m_aAccessibleChildren[i] );
if ( xChild.is() )
@@ -287,7 +288,7 @@ void OAccessibleMenuBaseComponent::UpdateAccessibleName( sal_Int32 i )
void OAccessibleMenuBaseComponent::UpdateItemText( sal_Int32 i )
{
- if ( i >= 0 && i < static_cast<sal_Int32>(m_aAccessibleChildren.size()) )
+ if ( i >= 0 && o3tl::make_unsigned(i) < m_aAccessibleChildren.size() )
{
Reference< XAccessible > xChild( m_aAccessibleChildren[i] );
if ( xChild.is() )
@@ -376,12 +377,12 @@ Reference< XAccessible > OAccessibleMenuBaseComponent::GetChildAt( const awt::Po
void OAccessibleMenuBaseComponent::InsertChild( sal_Int32 i )
{
- if ( i > static_cast<sal_Int32>(m_aAccessibleChildren.size()) )
- i = m_aAccessibleChildren.size();
-
if ( i < 0 )
return;
+ if ( o3tl::make_unsigned(i) > m_aAccessibleChildren.size() )
+ i = m_aAccessibleChildren.size();
+
// insert entry in child list
m_aAccessibleChildren.insert( m_aAccessibleChildren.begin() + i, Reference< XAccessible >() );
@@ -410,7 +411,7 @@ void OAccessibleMenuBaseComponent::InsertChild( sal_Int32 i )
void OAccessibleMenuBaseComponent::RemoveChild( sal_Int32 i )
{
- if ( i < 0 || i >= static_cast<sal_Int32>(m_aAccessibleChildren.size()) )
+ if ( i < 0 || o3tl::make_unsigned(i) >= m_aAccessibleChildren.size() )
return;
// keep the accessible of the removed item
diff --git a/accessibility/source/standard/vclxaccessiblelist.cxx b/accessibility/source/standard/vclxaccessiblelist.cxx
index 353312e6bbae..bb81350f5dd0 100644
--- a/accessibility/source/standard/vclxaccessiblelist.cxx
+++ b/accessibility/source/standard/vclxaccessiblelist.cxx
@@ -547,7 +547,7 @@ Reference<XAccessible> SAL_CALL VCLXAccessibleList::getAccessibleChild (sal_Int3
Reference< XAccessible > xChild;
// search for the child
- if ( i >= static_cast<sal_Int32>(m_aAccessibleChildren.size()) )
+ if ( o3tl::make_unsigned(i) >= m_aAccessibleChildren.size() )
xChild = CreateChild (i);
else
{
diff --git a/accessibility/source/standard/vclxaccessiblestatusbar.cxx b/accessibility/source/standard/vclxaccessiblestatusbar.cxx
index bd70676f58cc..d6e3e0ef5cad 100644
--- a/accessibility/source/standard/vclxaccessiblestatusbar.cxx
+++ b/accessibility/source/standard/vclxaccessiblestatusbar.cxx
@@ -22,6 +22,7 @@
#include <toolkit/helper/convert.hxx>
#include <com/sun/star/accessibility/AccessibleEventId.hpp>
#include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
+#include <o3tl/safeint.hxx>
#include <vcl/status.hxx>
#include <vcl/vclevent.hxx>
@@ -47,7 +48,7 @@ VCLXAccessibleStatusBar::VCLXAccessibleStatusBar( VCLXWindow* pVCLXWindow )
void VCLXAccessibleStatusBar::UpdateShowing( sal_Int32 i, bool bShowing )
{
- if ( i >= 0 && i < static_cast<sal_Int32>(m_aAccessibleChildren.size()) )
+ if ( i >= 0 && o3tl::make_unsigned(i) < m_aAccessibleChildren.size() )
{
Reference< XAccessible > xChild( m_aAccessibleChildren[i] );
if ( xChild.is() )
@@ -62,7 +63,7 @@ void VCLXAccessibleStatusBar::UpdateShowing( sal_Int32 i, bool bShowing )
void VCLXAccessibleStatusBar::UpdateItemName( sal_Int32 i )
{
- if ( i < 0 || i >= static_cast<sal_Int32>(m_aAccessibleChildren.size()) )
+ if ( i < 0 || o3tl::make_unsigned(i) >= m_aAccessibleChildren.size() )
return;
Reference< XAccessible > xChild( m_aAccessibleChildren[i] );
@@ -80,7 +81,7 @@ void VCLXAccessibleStatusBar::UpdateItemName( sal_Int32 i )
void VCLXAccessibleStatusBar::UpdateItemText( sal_Int32 i )
{
- if ( i < 0 || i >= static_cast<sal_Int32>(m_aAccessibleChildren.size()) )
+ if ( i < 0 || o3tl::make_unsigned(i) >= m_aAccessibleChildren.size() )
return;
Reference< XAccessible > xChild( m_aAccessibleChildren[i] );
@@ -98,7 +99,7 @@ void VCLXAccessibleStatusBar::UpdateItemText( sal_Int32 i )
void VCLXAccessibleStatusBar::InsertChild( sal_Int32 i )
{
- if ( i < 0 || i > static_cast<sal_Int32>(m_aAccessibleChildren.size()) )
+ if ( i < 0 || o3tl::make_unsigned(i) > m_aAccessibleChildren.size() )
return;
// insert entry in child list
@@ -117,7 +118,7 @@ void VCLXAccessibleStatusBar::InsertChild( sal_Int32 i )
void VCLXAccessibleStatusBar::RemoveChild( sal_Int32 i )
{
- if ( i < 0 || i >= static_cast<sal_Int32>(m_aAccessibleChildren.size()) )
+ if ( i < 0 || o3tl::make_unsigned(i) >= m_aAccessibleChildren.size() )
return;
// get the accessible of the removed page
@@ -290,7 +291,7 @@ Reference< XAccessible > VCLXAccessibleStatusBar::getAccessibleChild( sal_Int32
{
OExternalLockGuard aGuard( this );
- if ( i < 0 || i >= static_cast<sal_Int32> (m_aAccessibleChildren.size()) )
+ if ( i < 0 || o3tl::make_unsigned(i) >= m_aAccessibleChildren.size() )
throw IndexOutOfBoundsException();
Reference< XAccessible > xChild = m_aAccessibleChildren[i];
@@ -323,7 +324,7 @@ Reference< XAccessible > VCLXAccessibleStatusBar::getAccessibleAtPoint( const aw
{
sal_uInt16 nItemId = m_pStatusBar->GetItemId( VCLPoint( rPoint ) );
sal_Int32 nItemPos = m_pStatusBar->GetItemPos( nItemId );
- if ( nItemPos >= 0 && nItemPos < static_cast<sal_Int32>(m_aAccessibleChildren.size()) )
+ if ( nItemPos >= 0 && o3tl::make_unsigned(nItemPos) < m_aAccessibleChildren.size() )
xChild = getAccessibleChild( nItemPos );
}
diff --git a/accessibility/source/standard/vclxaccessibletabcontrol.cxx b/accessibility/source/standard/vclxaccessibletabcontrol.cxx
index 20e2ff120cc3..c1ede974148b 100644
--- a/accessibility/source/standard/vclxaccessibletabcontrol.cxx
+++ b/accessibility/source/standard/vclxaccessibletabcontrol.cxx
@@ -72,7 +72,7 @@ void VCLXAccessibleTabControl::UpdateFocused()
void VCLXAccessibleTabControl::UpdateSelected( sal_Int32 i, bool bSelected )
{
- if ( i >= 0 && i < static_cast<sal_Int32>(m_aAccessibleChildren.size()) )
+ if ( i >= 0 && o3tl::make_unsigned(i) < m_aAccessibleChildren.size() )
{
Reference< XAccessible > xChild( m_aAccessibleChildren[i] );
if ( xChild.is() )
@@ -87,7 +87,7 @@ void VCLXAccessibleTabControl::UpdateSelected( sal_Int32 i, bool bSelected )
void VCLXAccessibleTabControl::UpdatePageText( sal_Int32 i )
{
- if ( i >= 0 && i < static_cast<sal_Int32>(m_aAccessibleChildren.size()) )
+ if ( i >= 0 && o3tl::make_unsigned(i) < m_aAccessibleChildren.size() )
{
Reference< XAccessible > xChild( m_aAccessibleChildren[i] );
if ( xChild.is() )
@@ -102,7 +102,7 @@ void VCLXAccessibleTabControl::UpdatePageText( sal_Int32 i )
void VCLXAccessibleTabControl::UpdateTabPage( sal_Int32 i, bool bNew )
{
- if ( i >= 0 && i < static_cast<sal_Int32>(m_aAccessibleChildren.size()) )
+ if ( i >= 0 && o3tl::make_unsigned(i) < m_aAccessibleChildren.size() )
{
Reference< XAccessible > xChild( m_aAccessibleChildren[i] );
if ( xChild.is() )
@@ -117,7 +117,7 @@ void VCLXAccessibleTabControl::UpdateTabPage( sal_Int32 i, bool bNew )
void VCLXAccessibleTabControl::InsertChild( sal_Int32 i )
{
- if ( i < 0 || i > static_cast<sal_Int32>(m_aAccessibleChildren.size()) )
+ if ( i < 0 || o3tl::make_unsigned(i) > m_aAccessibleChildren.size() )
return;
// insert entry in child list
@@ -136,7 +136,7 @@ void VCLXAccessibleTabControl::InsertChild( sal_Int32 i )
void VCLXAccessibleTabControl::RemoveChild( sal_Int32 i )
{
- if ( i < 0 || i >= static_cast<sal_Int32>(m_aAccessibleChildren.size()) )
+ if ( i < 0 || o3tl::make_unsigned(i) >= m_aAccessibleChildren.size() )
return;
// get the accessible of the removed page
diff --git a/basic/source/classes/sb.cxx b/basic/source/classes/sb.cxx
index 570447246cf9..4e3e716a56ca 100644
--- a/basic/source/classes/sb.cxx
+++ b/basic/source/classes/sb.cxx
@@ -18,6 +18,7 @@
*/
#include <sb.hxx>
+#include <o3tl/safeint.hxx>
#include <rtl/ustrbuf.hxx>
#include <tools/stream.hxx>
#include <tools/debug.hxx>
@@ -2172,7 +2173,7 @@ void BasicCollection::CollItem( SbxArray* pPar_ )
SbxVariable* pRes = nullptr;
SbxVariable* p = pPar_->Get(1);
sal_Int32 nIndex = implGetIndex( p );
- if (nIndex >= 0 && nIndex < static_cast<sal_Int32>(xItemArray->Count()))
+ if (nIndex >= 0 && o3tl::make_unsigned(nIndex) < xItemArray->Count())
{
pRes = xItemArray->Get(nIndex);
}
@@ -2196,7 +2197,7 @@ void BasicCollection::CollRemove( SbxArray* pPar_ )
SbxVariable* p = pPar_->Get(1);
sal_Int32 nIndex = implGetIndex( p );
- if (nIndex >= 0 && nIndex < static_cast<sal_Int32>(xItemArray->Count()))
+ if (nIndex >= 0 && o3tl::make_unsigned(nIndex) < xItemArray->Count())
{
xItemArray->Remove( nIndex );
diff --git a/basic/source/sbx/sbxarray.cxx b/basic/source/sbx/sbxarray.cxx
index 53c0ed36fa73..4bd933b126ad 100644
--- a/basic/source/sbx/sbxarray.cxx
+++ b/basic/source/sbx/sbxarray.cxx
@@ -448,7 +448,7 @@ void SbxDimArray::unoAddDim( sal_Int32 lb, sal_Int32 ub )
bool SbxDimArray::GetDim( sal_Int32 n, sal_Int32& rlb, sal_Int32& rub ) const
{
- if( n < 1 || n > static_cast<sal_Int32>(m_vDimensions.size()) )
+ if( n < 1 || o3tl::make_unsigned(n) > m_vDimensions.size() )
{
SetError( ERRCODE_BASIC_OUT_OF_RANGE );
rub = rlb = 0;
diff --git a/basic/source/sbx/sbxcoll.cxx b/basic/source/sbx/sbxcoll.cxx
index ea4eb4cdea14..328115d4f6fa 100644
--- a/basic/source/sbx/sbxcoll.cxx
+++ b/basic/source/sbx/sbxcoll.cxx
@@ -17,6 +17,7 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
+#include <o3tl/safeint.hxx>
#include <tools/stream.hxx>
#include <basic/sbx.hxx>
@@ -188,7 +189,7 @@ void SbxCollection::CollItem( SbxArray* pPar_ )
else
{
short n = p->GetInteger();
- if (n >= 1 && n <= static_cast<sal_Int32>(pObjs->Count()))
+ if (n >= 1 && o3tl::make_unsigned(n) <= pObjs->Count())
{
pRes = pObjs->Get(static_cast<sal_uInt32>(n) - 1);
}
@@ -210,7 +211,7 @@ void SbxCollection::CollRemove( SbxArray* pPar_ )
else
{
short n = pPar_->Get(1)->GetInteger();
- if (n < 1 || n > static_cast<sal_Int32>(pObjs->Count()))
+ if (n < 1 || o3tl::make_unsigned(n) > pObjs->Count())
SetError( ERRCODE_BASIC_BAD_INDEX );
else
Remove(pObjs->Get(static_cast<sal_uInt32>(n) - 1));
diff --git a/chart2/source/controller/chartapiwrapper/DataSeriesPointWrapper.cxx b/chart2/source/controller/chartapiwrapper/DataSeriesPointWrapper.cxx
index 51c917751fbd..40e4df69c603 100644
--- a/chart2/source/controller/chartapiwrapper/DataSeriesPointWrapper.cxx
+++ b/chart2/source/controller/chartapiwrapper/DataSeriesPointWrapper.cxx
@@ -39,6 +39,7 @@
#include "WrappedTextRotationProperty.hxx"
#include <unonames.hxx>
+#include <o3tl/safeint.hxx>
#include <rtl/math.hxx>
#include <algorithm>
@@ -560,7 +561,7 @@ rtl::Reference< DataSeries > DataSeriesPointWrapper::getDataSeries()
std::vector< rtl::Reference< DataSeries > > aSeriesList =
::chart::DiagramHelper::getDataSeriesFromDiagram( xDiagram );
- if( m_nSeriesIndexInNewAPI >= 0 && m_nSeriesIndexInNewAPI < static_cast<sal_Int32>(aSeriesList.size()) )
+ if( m_nSeriesIndexInNewAPI >= 0 && o3tl::make_unsigned(m_nSeriesIndexInNewAPI) < aSeriesList.size() )
xSeries = aSeriesList[m_nSeriesIndexInNewAPI];
}
diff --git a/chart2/source/model/main/BaseCoordinateSystem.cxx b/chart2/source/model/main/BaseCoordinateSystem.cxx
index 95faaed01bfd..41c7c766840c 100644
--- a/chart2/source/model/main/BaseCoordinateSystem.cxx
+++ b/chart2/source/model/main/BaseCoordinateSystem.cxx
@@ -264,7 +264,7 @@ const rtl::Reference< Axis > & BaseCoordinateSystem::getAxisByDimension2(
OSL_ASSERT( m_aAllAxis.size() == static_cast< size_t >( m_nDimensionCount));
- if( nAxisIndex < 0 || nAxisIndex > static_cast<sal_Int32>(m_aAllAxis[ nDimensionIndex ].size()) )
+ if( nAxisIndex < 0 || o3tl::make_unsigned(nAxisIndex) > m_aAllAxis[ nDimensionIndex ].size() )
throw lang::IndexOutOfBoundsException();
return m_aAllAxis[ nDimensionIndex ][nAxisIndex];
diff --git a/chart2/source/tools/AxisHelper.cxx b/chart2/source/tools/AxisHelper.cxx
index 95b50a9640f3..e34870052cec 100644
--- a/chart2/source/tools/AxisHelper.cxx
+++ b/chart2/source/tools/AxisHelper.cxx
@@ -38,6 +38,7 @@
#include <unonames.hxx>
#include <BaseCoordinateSystem.hxx>
+#include <o3tl/safeint.hxx>
#include <unotools/saveopt.hxx>
#include <com/sun/star/chart/ChartAxisPosition.hpp>
@@ -561,7 +562,7 @@ rtl::Reference< ::chart::BaseCoordinateSystem > AxisHelper::getCoordinateSystemB
if(!xDiagram.is())
return nullptr;
auto & rCooSysList = xDiagram->getBaseCoordinateSystems();
- if(0<=nIndex && nIndex < static_cast<sal_Int32>(rCooSysList.size()))
+ if(0<=nIndex && o3tl::make_unsigned(nIndex) < rCooSysList.size())
return rCooSysList[nIndex];
return nullptr;
}
@@ -1048,7 +1049,7 @@ rtl::Reference< ChartType > AxisHelper::getChartTypeByIndex( const rtl::Referenc
if( xCooSys.is() )
{
const std::vector< rtl::Reference< ChartType > > aChartTypeList( xCooSys->getChartTypes2() );
- if( nIndex >= 0 && nIndex < static_cast<sal_Int32>(aChartTypeList.size()) )
+ if( nIndex >= 0 && o3tl::make_unsigned(nIndex) < aChartTypeList.size() )
xChartType = aChartTypeList[nIndex];
}
diff --git a/chart2/source/tools/CommonConverters.cxx b/chart2/source/tools/CommonConverters.cxx
index d61a635d425d..b68cd17e20c3 100644
--- a/chart2/source/tools/CommonConverters.cxx
+++ b/chart2/source/tools/CommonConverters.cxx
@@ -24,6 +24,7 @@
#include <com/sun/star/chart2/data/XDataSequence.hpp>
#include <com/sun/star/chart2/data/XNumericalDataSequence.hpp>
#include <com/sun/star/chart2/data/XTextualDataSequence.hpp>
+#include <o3tl/safeint.hxx>
#include <osl/diagnose.h>
#include <basegfx/matrix/b3dhommatrix.hxx>
#include <basegfx/polygon/b2dpolygontools.hxx>
@@ -227,7 +228,7 @@ drawing::Position3D getPointFromPoly( const std::vector<std::vector<css::drawing
{
drawing::Position3D aRet(0.0,0.0,0.0);
- if( nPolyIndex>=0 && nPolyIndex<static_cast<sal_Int32>(rPolygon.size()))
+ if( nPolyIndex>=0 && o3tl::make_unsigned(nPolyIndex)<rPolygon.size())
{
if(nPointIndex<static_cast<sal_Int32>(rPolygon[nPolyIndex].size()))
{
diff --git a/chart2/source/tools/DiagramHelper.cxx b/chart2/source/tools/DiagramHelper.cxx
index 4526550a9e99..258dff61d8db 100644
--- a/chart2/source/tools/DiagramHelper.cxx
+++ b/chart2/source/tools/DiagramHelper.cxx
@@ -50,6 +50,7 @@
#include <com/sun/star/util/NumberFormat.hpp>
#include <com/sun/star/util/XNumberFormatsSupplier.hpp>
+#include <o3tl/safeint.hxx>
#include <unotools/saveopt.hxx>
#include <rtl/math.hxx>
#include <svl/numformat.hxx>
@@ -655,7 +656,7 @@ rtl::Reference< ChartType >
for( rtl::Reference< BaseCoordinateSystem > const & coords : xDiagram->getBaseCoordinateSystems() )
{
const std::vector< rtl::Reference< ChartType > > & aChartTypeList( coords->getChartTypes2() );
- if( nIndex >= 0 && nIndex < static_cast<sal_Int32>(nTypesSoFar + aChartTypeList.size()) )
+ if( nIndex >= 0 && o3tl::make_unsigned(nIndex) < nTypesSoFar + aChartTypeList.size() )
{
xChartType = aChartTypeList[nIndex - nTypesSoFar];
break;
@@ -1211,7 +1212,7 @@ bool lcl_moveSeriesOrCheckIfMoveIsAllowed(
else
nNewSeriesIndex++;
- if( nNewSeriesIndex >= 0 && nNewSeriesIndex < static_cast<sal_Int32>(aSeriesList.size()) )
+ if( nNewSeriesIndex >= 0 && o3tl::make_unsigned(nNewSeriesIndex) < aSeriesList.size() )
{
//move series in the same charttype
bMovedOrMoveAllowed = true;
@@ -1232,7 +1233,7 @@ bool lcl_moveSeriesOrCheckIfMoveIsAllowed(
{
std::vector< rtl::Reference< DataSeries > > aOtherSeriesList = xFormerChartType->getDataSeries2();
sal_Int32 nOtherSeriesIndex = aOtherSeriesList.size()-1;
- if( nOtherSeriesIndex >= 0 && nOtherSeriesIndex < static_cast<sal_Int32>(aOtherSeriesList.size()) )
+ if( nOtherSeriesIndex >= 0 && o3tl::make_unsigned(nOtherSeriesIndex) < aOtherSeriesList.size() )
{
rtl::Reference< DataSeries > xExchangeSeries( aOtherSeriesList[nOtherSeriesIndex] );
aOtherSeriesList[nOtherSeriesIndex] = xGivenDataSeries;
diff --git a/chart2/source/tools/InternalData.cxx b/chart2/source/tools/InternalData.cxx
index dd48289e831c..b6fc1e09044f 100644
--- a/chart2/source/tools/InternalData.cxx
+++ b/chart2/source/tools/InternalData.cxx
@@ -22,6 +22,7 @@
#include <strings.hrc>
#include <comphelper/sequence.hxx>
+#include <o3tl/safeint.hxx>
#include <osl/diagnose.h>
#ifdef DEBUG_CHART2_TOOLS
@@ -202,7 +203,7 @@ void InternalData::setComplexColumnLabel( sal_Int32 nColumnIndex, vector< uno::A
{
if( nColumnIndex < 0 )
return;
- if( nColumnIndex >= static_cast< sal_Int32 >( m_aColumnLabels.size() ) )
+ if( o3tl::make_unsigned(nColumnIndex) >= m_aColumnLabels.size() )
{
m_aColumnLabels.resize(nColumnIndex+1);
enlargeData( nColumnIndex+1, 0 );
@@ -216,7 +217,7 @@ void InternalData::setComplexRowLabel( sal_Int32 nRowIndex, vector< uno::Any >&&
{
if( nRowIndex < 0 )
return;
- if( nRowIndex >= static_cast< sal_Int32 >( m_aRowLabels.size() ) )
+ if( o3tl::make_unsigned(nRowIndex) >= m_aRowLabels.size() )
{
m_aRowLabels.resize(nRowIndex+1);
enlargeData( 0, nRowIndex+1 );
diff --git a/chart2/source/tools/ObjectIdentifier.cxx b/chart2/source/tools/ObjectIdentifier.cxx
index a4bf8bf43650..a8622e3ff4c4 100644
--- a/chart2/source/tools/ObjectIdentifier.cxx
+++ b/chart2/source/tools/ObjectIdentifier.cxx
@@ -42,6 +42,7 @@
#include <rtl/ustrbuf.hxx>
#include <tools/diagnose_ex.h>
+#include <o3tl/safeint.hxx>
#include <o3tl/string_view.hxx>
namespace com::sun::star::drawing { class XShape; }
@@ -222,7 +223,7 @@ void lcl_getDiagramAndCooSys( const OUString& rObjectCID
if( nCooSysIndex > -1 )
{
const std::vector< rtl::Reference< BaseCoordinateSystem > > aCooSysList( xDiagram->getBaseCoordinateSystems() );
- if( nCooSysIndex < static_cast<sal_Int32>(aCooSysList.size()) )
+ if( o3tl::make_unsigned(nCooSysIndex) < aCooSysList.size() )
xCooSys = aCooSysList[nCooSysIndex];
}
}
@@ -1211,7 +1212,7 @@ Reference< beans::XPropertySet > ObjectIdentifier::getObjectPropertySet(
sal_Int32 nIndex = o3tl::toInt32(aParticleID);
const std::vector< rtl::Reference< RegressionCurveModel > > & aCurveList =
xRegressionContainer->getRegressionCurves2();
- if( nIndex >= 0 && nIndex < static_cast<sal_Int32>(aCurveList.size()) )
+ if( nIndex >= 0 && o3tl::make_unsigned(nIndex) < aCurveList.size() )
{
if( eObjectType == OBJECTTYPE_DATA_CURVE_EQUATION )
xObjectProperties = aCurveList[nIndex]->getEquationProperties();
@@ -1281,7 +1282,7 @@ rtl::Reference< DataSeries > ObjectIdentifier::getDataSeriesForCID(
if( xDataSeriesContainer.is() )
{
const std::vector< rtl::Reference< DataSeries > > & aDataSeriesSeq( xDataSeriesContainer->getDataSeries2() );
- if( nSeriesIndex >= 0 && nSeriesIndex < static_cast<sal_Int32>(aDataSeriesSeq.size()) )
+ if( nSeriesIndex >= 0 && o3tl::make_unsigned(nSeriesIndex) < aDataSeriesSeq.size() )
xSeries = aDataSeriesSeq[nSeriesIndex];
}
diff --git a/chart2/source/tools/RegressionCurveHelper.cxx b/chart2/source/tools/RegressionCurveHelper.cxx
index 24be670b659c..6124007fceb8 100644
--- a/chart2/source/tools/RegressionCurveHelper.cxx
+++ b/chart2/source/tools/RegressionCurveHelper.cxx
@@ -40,6 +40,7 @@
#include <com/sun/star/chart2/XRegressionCurveContainer.hpp>
#include <com/sun/star/chart2/XDataSeries.hpp>
#include <com/sun/star/chart2/data/XDataSource.hpp>
+#include <o3tl/safeint.hxx>
#include <tools/diagnose_ex.h>
#include <comphelper/property.hxx>
@@ -668,7 +669,7 @@ rtl::Reference< RegressionCurveModel > RegressionCurveHelper::getRegressionCurve
try
{
const std::vector< rtl::Reference< RegressionCurveModel > > aCurves(xCurveContainer->getRegressionCurves2());
- if(0 <= aIndex && aIndex < static_cast<sal_Int32>(aCurves.size()))
+ if(0 <= aIndex && o3tl::make_unsigned(aIndex) < aCurves.size())
{
if(!isMeanValueLine(aCurves[aIndex]))
return aCurves[aIndex];
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) );
diff --git a/connectivity/source/commontools/FDatabaseMetaDataResultSet.cxx b/connectivity/source/commontools/FDatabaseMetaDataResultSet.cxx
index d88d9b932f4c..3c755f206224 100644
--- a/connectivity/source/commontools/FDatabaseMetaDataResultSet.cxx
+++ b/connectivity/source/commontools/FDatabaseMetaDataResultSet.cxx
@@ -27,6 +27,7 @@
#include <comphelper/sequence.hxx>
#include <cppuhelper/supportsservice.hxx>
#include <connectivity/dbexception.hxx>
+#include <o3tl/safeint.hxx>
#include <o3tl/unreachable.hxx>
#include <TConnection.hxx>
@@ -171,7 +172,7 @@ sal_Int32 SAL_CALL ODatabaseMetaDataResultSet::findColumn( const OUString& colum
void ODatabaseMetaDataResultSet::checkIndex(sal_Int32 columnIndex )
{
- if(columnIndex >= static_cast<sal_Int32>((*m_aRowsIter).size()) || columnIndex < 1)
+ if(columnIndex < 1 || o3tl::make_unsigned(columnIndex) >= (*m_aRowsIter).size())
::dbtools::throwInvalidIndexException(*this);
}
diff --git a/connectivity/source/commontools/paramwrapper.cxx b/connectivity/source/commontools/paramwrapper.cxx
index aab6daa243d1..820e2ae9ed62 100644
--- a/connectivity/source/commontools/paramwrapper.cxx
+++ b/connectivity/source/commontools/paramwrapper.cxx
@@ -28,6 +28,7 @@
#include <com/sun/star/sdb/XSingleSelectQueryAnalyzer.hpp>
#include <com/sun/star/lang/DisposedException.hpp>
+#include <o3tl/safeint.hxx>
#include <tools/diagnose_ex.h>
#include <comphelper/enumhelper.hxx>
@@ -310,7 +311,7 @@ namespace dbtools::param
::osl::MutexGuard aGuard( m_aMutex );
impl_checkDisposed_throw();
- if ( ( _nIndex < 0 ) || ( _nIndex >= static_cast<sal_Int32>(m_aParameters.size()) ) )
+ if ( ( _nIndex < 0 ) || ( o3tl::make_unsigned(_nIndex) >= m_aParameters.size() ) )
throw IndexOutOfBoundsException();
return Any( Reference< XPropertySet >( m_aParameters[ _nIndex ] ) );
diff --git a/connectivity/source/drivers/file/FPreparedStatement.cxx b/connectivity/source/drivers/file/FPreparedStatement.cxx
index 2ae516800b06..f2a8571b61e5 100644
--- a/connectivity/source/drivers/file/FPreparedStatement.cxx
+++ b/connectivity/source/drivers/file/FPreparedStatement.cxx
@@ -18,6 +18,7 @@
*/
+#include <o3tl/safeint.hxx>
#include <osl/diagnose.h>
#include <file/FPreparedStatement.hxx>
#include <com/sun/star/sdbc/DataType.hpp>
@@ -392,7 +393,7 @@ void SAL_CALL OPreparedStatement::release() noexcept
void OPreparedStatement::checkAndResizeParameters(sal_Int32 parameterIndex)
{
::connectivity::checkDisposed(OStatement_BASE::rBHelper.bDisposed);
- if ( m_aAssignValues.is() && (parameterIndex < 1 || parameterIndex >= static_cast<sal_Int32>(m_aParameterIndexes.size())) )
+ if ( m_aAssignValues.is() && (parameterIndex < 1 || o3tl::make_unsigned(parameterIndex) >= m_aParameterIndexes.size()) )
throwInvalidIndexException(*this);
else if ( static_cast<sal_Int32>(m_aParameterRow->size()) <= parameterIndex )
{
diff --git a/connectivity/source/drivers/file/FResultSet.cxx b/connectivity/source/drivers/file/FResultSet.cxx
index 43ad38739d5b..4d0e256b931e 100644
--- a/connectivity/source/drivers/file/FResultSet.cxx
+++ b/connectivity/source/drivers/file/FResultSet.cxx
@@ -29,6 +29,7 @@
#include <cppuhelper/typeprovider.hxx>
#include <connectivity/dbtools.hxx>
#include <cppuhelper/propshlp.hxx>
+#include <o3tl/safeint.hxx>
#include <sal/log.hxx>
#include <iterator>
#include <com/sun/star/sdbc/ResultSetType.hpp>
@@ -921,7 +922,7 @@ bool OResultSet::Move(IResultSetHelper::Movement eCursorPosition, sal_Int32 nOff
// The FileCursor is outside of the valid range, if:
// a.) m_nRowPos < 1
// b.) a KeySet exists and m_nRowPos > m_pFileSet->size()
- if (m_nRowPos < 0 || (m_pFileSet->isFrozen() && eCursorPosition != IResultSetHelper::BOOKMARK && m_nRowPos >= static_cast<sal_Int32>(m_pFileSet->size()) )) // && m_pFileSet->IsFrozen()
+ if (m_nRowPos < 0 || (m_pFileSet->isFrozen() && eCursorPosition != IResultSetHelper::BOOKMARK && o3tl::make_unsigned(m_nRowPos) >= m_pFileSet->size() )) // && m_pFileSet->IsFrozen()
{
goto Error;
}
diff --git a/connectivity/source/drivers/file/FResultSetMetaData.cxx b/connectivity/source/drivers/file/FResultSetMetaData.cxx
index f68a06532bb7..fdc944043d2a 100644
--- a/connectivity/source/drivers/file/FResultSetMetaData.cxx
+++ b/connectivity/source/drivers/file/FResultSetMetaData.cxx
@@ -22,6 +22,7 @@
#include <comphelper/extract.hxx>
#include <connectivity/dbexception.hxx>
#include <comphelper/types.hxx>
+#include <o3tl/safeint.hxx>
using namespace ::comphelper;
@@ -51,7 +52,7 @@ OResultSetMetaData::~OResultSetMetaData()
void OResultSetMetaData::checkColumnIndex(sal_Int32 column)
{
- if(column <= 0 || column > static_cast<sal_Int32>(m_xColumns->size()))
+ if(column <= 0 || o3tl::make_unsigned(column) > m_xColumns->size())
throwInvalidIndexException(*this);
}
diff --git a/connectivity/source/drivers/mysqlc/mysqlc_preparedstatement.cxx b/connectivity/source/drivers/mysqlc/mysqlc_preparedstatement.cxx
index a50b14bbb3b4..6ec6a89f175c 100644
--- a/connectivity/source/drivers/mysqlc/mysqlc_preparedstatement.cxx
+++ b/connectivity/source/drivers/mysqlc/mysqlc_preparedstatement.cxx
@@ -23,6 +23,7 @@
#include "mysqlc_propertyids.hxx"
#include "mysqlc_resultsetmetadata.hxx"
+#include <o3tl/safeint.hxx>
#include <sal/log.hxx>
#include <com/sun/star/sdbc/DataType.hpp>
@@ -569,7 +570,7 @@ void OPreparedStatement::setFastPropertyValue_NoBroadcast(sal_Int32 nHandle, con
void OPreparedStatement::checkParameterIndex(sal_Int32 column)
{
- if (column < 1 || column > static_cast<sal_Int32>(m_paramCount))
+ if (column < 1 || o3tl::make_unsigned(column) > m_paramCount)
{
throw SQLException("Parameter index out of range", *this, OUString(), 1, Any());
}
diff --git a/connectivity/source/drivers/mysqlc/mysqlc_resultset.cxx b/connectivity/source/drivers/mysqlc/mysqlc_resultset.cxx
index 7410ad38e6fc..f1c23ca482ad 100644
--- a/connectivity/source/drivers/mysqlc/mysqlc_resultset.cxx
+++ b/connectivity/source/drivers/mysqlc/mysqlc_resultset.cxx
@@ -1095,7 +1095,7 @@ css::uno::Reference<css::beans::XPropertySetInfo> SAL_CALL OResultSet::getProper
void OResultSet::checkColumnIndex(sal_Int32 index)
{
- if (index < 1 || index > static_cast<int>(m_aFields.size()))
+ if (index < 1 || o3tl::make_unsigned(index) > m_aFields.size())
{
/* static object for efficiency or thread safety is a problem ? */
throw SQLException("index out of range", *this, OUString(), 1, Any());
diff --git a/connectivity/source/drivers/mysqlc/mysqlc_resultsetmetadata.cxx b/connectivity/source/drivers/mysqlc/mysqlc_resultsetmetadata.cxx
index 6fc531fa943d..84cd6be2a3a7 100644
--- a/connectivity/source/drivers/mysqlc/mysqlc_resultsetmetadata.cxx
+++ b/connectivity/source/drivers/mysqlc/mysqlc_resultsetmetadata.cxx
@@ -22,6 +22,7 @@
#include <com/sun/star/sdbc/XRow.hpp>
#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
+#include <o3tl/safeint.hxx>
using namespace connectivity::mysqlc;
using namespace com::sun::star::uno;
@@ -199,7 +200,7 @@ sal_Bool SAL_CALL OResultSetMetaData::isWritable(sal_Int32 column)
void OResultSetMetaData::checkColumnIndex(sal_Int32 columnIndex)
{
auto nColCount = m_fields.size();
- if (columnIndex < 1 || columnIndex > static_cast<sal_Int32>(nColCount))
+ if (columnIndex < 1 || o3tl::make_unsigned(columnIndex) > nColCount)
{
OUString str = "Column index out of range (expected 1 to "
+ OUString::number(sal_Int32(nColCount)) + ", got "
diff --git a/connectivity/source/drivers/postgresql/pq_preparedstatement.cxx b/connectivity/source/drivers/postgresql/pq_preparedstatement.cxx
index d7a73289b077..2f31b4226c08 100644
--- a/connectivity/source/drivers/postgresql/pq_preparedstatement.cxx
+++ b/connectivity/source/drivers/postgresql/pq_preparedstatement.cxx
@@ -40,6 +40,7 @@
#include "pq_statics.hxx"
#include "pq_statement.hxx"
+#include <o3tl/safeint.hxx>
#include <rtl/strbuf.hxx>
#include <rtl/ustrbuf.hxx>
@@ -197,7 +198,7 @@ PreparedStatement::~PreparedStatement()
void PreparedStatement::checkColumnIndex( sal_Int32 parameterIndex )
{
- if( parameterIndex < 1 || parameterIndex > static_cast<sal_Int32>(m_vars.size()) )
+ if( parameterIndex < 1 || o3tl::make_unsigned(parameterIndex) > m_vars.size() )
{
throw SQLException(
"pq_preparedstatement: parameter index out of range (expected 1 to "
diff --git a/connectivity/source/drivers/postgresql/pq_xcolumns.cxx b/connectivity/source/drivers/postgresql/pq_xcolumns.cxx
index 6caf1decc6c6..f1d3c0a53e88 100644
--- a/connectivity/source/drivers/postgresql/pq_xcolumns.cxx
+++ b/connectivity/source/drivers/postgresql/pq_xcolumns.cxx
@@ -38,6 +38,7 @@
#include <string_view>
+#include <o3tl/safeint.hxx>
#include <o3tl/string_view.hxx>
#include <rtl/ref.hxx>
#include <rtl/ustrbuf.hxx>
@@ -492,7 +493,7 @@ void Columns::appendByDescriptor(
void Columns::dropByIndex( sal_Int32 index )
{
osl::MutexGuard guard( m_xMutex->GetMutex() );
- if( index < 0 || index >= static_cast<sal_Int32>(m_values.size()) )
+ if( index < 0 || o3tl::make_unsigned(index) >= m_values.size() )
{
throw css::lang::IndexOutOfBoundsException(
"COLUMNS: Index out of range (allowed 0 to "
diff --git a/connectivity/source/drivers/postgresql/pq_xcontainer.cxx b/connectivity/source/drivers/postgresql/pq_xcontainer.cxx
index 993045d3a44d..fea88b682cdb 100644
--- a/connectivity/source/drivers/postgresql/pq_xcontainer.cxx
+++ b/connectivity/source/drivers/postgresql/pq_xcontainer.cxx
@@ -37,6 +37,7 @@
#include <com/sun/star/container/ElementExistException.hpp>
#include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
#include <cppuhelper/implbase.hxx>
+#include <o3tl/safeint.hxx>
#include "pq_xcontainer.hxx"
#include "pq_statics.hxx"
@@ -155,7 +156,7 @@ Any Container::getByName( const OUString& aName )
"Element " + aName + " unknown in " + m_type + "-Container",
*this );
}
- OSL_ASSERT( ii->second >= 0 && ii->second < static_cast<int>(m_values.size()) );
+ OSL_ASSERT( ii->second >= 0 && o3tl::make_unsigned(ii->second) < m_values.size() );
return m_values[ ii->second ];
}
@@ -188,7 +189,7 @@ sal_Bool Container::hasElements( )
Any Container::getByIndex( sal_Int32 Index )
{
- if( Index < 0 || Index >= static_cast<sal_Int32>(m_values.size()) )
+ if( Index < 0 || o3tl::make_unsigned(Index) >= m_values.size() )
{
throw IndexOutOfBoundsException(
"Index " + OUString::number( Index )
@@ -298,7 +299,7 @@ void Container::dropByName( const OUString& elementName )
void Container::dropByIndex( sal_Int32 index )
{
osl::MutexGuard guard( m_xMutex->GetMutex() );
- if( index < 0 || index >=static_cast<sal_Int32>(m_values.size()) )
+ if( index < 0 || o3tl::make_unsigned(index) >=m_values.size() )
{
throw css::lang::IndexOutOfBoundsException(
"Index out of range (allowed 0 to "
diff --git a/connectivity/source/drivers/postgresql/pq_xindexes.cxx b/connectivity/source/drivers/postgresql/pq_xindexes.cxx
index d027e15b9d3c..ef1e7116a1b0 100644
--- a/connectivity/source/drivers/postgresql/pq_xindexes.cxx
+++ b/connectivity/source/drivers/postgresql/pq_xindexes.cxx
@@ -43,6 +43,7 @@
#include <com/sun/star/sdbc/XRow.hpp>
#include <com/sun/star/sdbc/XParameters.hpp>
#include <cppuhelper/exc_hlp.hxx>
+#include <o3tl/safeint.hxx>
#include "pq_xindexes.hxx"
#include "pq_xindex.hxx"
@@ -234,7 +235,7 @@ void Indexes::dropByIndex( sal_Int32 index )
osl::MutexGuard guard( m_xMutex->GetMutex() );
- if( index < 0 || index >= static_cast<sal_Int32>(m_values.size()) )
+ if( index < 0 || o3tl::make_unsigned(index) >= m_values.size() )
{
throw css::lang::IndexOutOfBoundsException(
"Indexes: Index out of range (allowed 0 to "
diff --git a/connectivity/source/drivers/postgresql/pq_xkeys.cxx b/connectivity/source/drivers/postgresql/pq_xkeys.cxx
index 0aeb32446abb..dced2bc9baa5 100644
--- a/connectivity/source/drivers/postgresql/pq_xkeys.cxx
+++ b/connectivity/source/drivers/postgresql/pq_xkeys.cxx
@@ -49,6 +49,7 @@
#include <com/sun/star/sdbc/KeyRule.hpp>
#include <com/sun/star/sdbcx/KeyType.hpp>
#include <cppuhelper/exc_hlp.hxx>
+#include <o3tl/safeint.hxx>
#include "pq_xkeys.hxx"
#include "pq_xkey.hxx"
@@ -226,7 +227,7 @@ void Keys::appendByDescriptor(
void Keys::dropByIndex( sal_Int32 index )
{
osl::MutexGuard guard( m_xMutex->GetMutex() );
- if( index < 0 || index >= static_cast<sal_Int32>(m_values.size()) )
+ if( index < 0 || o3tl::make_unsigned(index) >= m_values.size() )
{
throw css::lang::IndexOutOfBoundsException(
"TABLES: Index out of range (allowed 0 to " + OUString::number(m_values.size() -1)
diff --git a/connectivity/source/drivers/postgresql/pq_xtables.cxx b/connectivity/source/drivers/postgresql/pq_xtables.cxx
index f1a089ff031a..423ec81f2166 100644
--- a/connectivity/source/drivers/postgresql/pq_xtables.cxx
+++ b/connectivity/source/drivers/postgresql/pq_xtables.cxx
@@ -43,6 +43,7 @@
#include <com/sun/star/sdbcx/Privilege.hpp>
#include <com/sun/star/sdbc/DataType.hpp>
#include <cppuhelper/exc_hlp.hxx>
+#include <o3tl/safeint.hxx>
#include "pq_xtables.hxx"
#include "pq_xviews.hxx"
@@ -310,7 +311,7 @@ void Tables::appendByDescriptor(
void Tables::dropByIndex( sal_Int32 index )
{
osl::MutexGuard guard( m_xMutex->GetMutex() );
- if( index < 0 || index >= static_cast<sal_Int32>(m_values.size()) )
+ if( index < 0 || o3tl::make_unsigned(index) >= m_values.size() )
{
throw css::lang::IndexOutOfBoundsException(
"TABLES: Index out of range (allowed 0 to " + OUString::number(m_values.size() -1)
diff --git a/connectivity/source/drivers/postgresql/pq_xusers.cxx b/connectivity/source/drivers/postgresql/pq_xusers.cxx
index a12c86ed2375..08cdf2d1c135 100644
--- a/connectivity/source/drivers/postgresql/pq_xusers.cxx
+++ b/connectivity/source/drivers/postgresql/pq_xusers.cxx
@@ -41,6 +41,7 @@
#include <com/sun/star/sdbc/SQLException.hpp>
#include <com/sun/star/sdbc/XRow.hpp>
#include <cppuhelper/exc_hlp.hxx>
+#include <o3tl/safeint.hxx>
#include "pq_xusers.hxx"
#include "pq_xuser.hxx"
@@ -151,7 +152,7 @@ void Users::dropByIndex( sal_Int32 index )
{
osl::MutexGuard guard( m_xMutex->GetMutex() );
- if( index < 0 || index >= static_cast<sal_Int32>(m_values.size()) )
+ if( index < 0 || o3tl::make_unsigned(index) >= m_values.size() )
{
throw css::lang::IndexOutOfBoundsException(
"USERS: Index out of range (allowed 0 to "
diff --git a/connectivity/source/drivers/postgresql/pq_xviews.cxx b/connectivity/source/drivers/postgresql/pq_xviews.cxx
index 3dfdfaa5fe64..1f5b6c4fa52c 100644
--- a/connectivity/source/drivers/postgresql/pq_xviews.cxx
+++ b/connectivity/source/drivers/postgresql/pq_xviews.cxx
@@ -41,6 +41,7 @@
#include <com/sun/star/sdbc/SQLException.hpp>
#include <com/sun/star/sdbc/XRow.hpp>
#include <cppuhelper/exc_hlp.hxx>
+#include <o3tl/safeint.hxx>
#include "pq_xviews.hxx"
#include "pq_xview.hxx"
@@ -175,7 +176,7 @@ void Views::dropByName( const OUString& elementName )
void Views::dropByIndex( sal_Int32 index )
{
osl::MutexGuard guard( m_xMutex->GetMutex() );
- if( index < 0 || index >= static_cast<sal_Int32>(m_values.size()) )
+ if( index < 0 || o3tl::make_unsigned(index) >= m_values.size() )
{
throw css::lang::IndexOutOfBoundsException(
"VIEWS: Index out of range (allowed 0 to " + OUString::number(m_values.size() -1)
diff --git a/connectivity/source/inc/file/FResultSet.hxx b/connectivity/source/inc/file/FResultSet.hxx
index a7aa77ff2576..62a52fe2bc82 100644
--- a/connectivity/source/inc/file/FResultSet.hxx
+++ b/connectivity/source/inc/file/FResultSet.hxx
@@ -40,6 +40,7 @@
#include <TSortIndex.hxx>
#include <TSkipDeletedSet.hxx>
#include <com/sun/star/lang/XEventListener.hpp>
+#include <o3tl/safeint.hxx>
namespace connectivity::file
{
@@ -292,7 +293,7 @@ namespace connectivity::file
OSL_ENSURE(column > 0, "file::OResultSet::mapColumn: invalid column index!");
// the first column (index 0) is for convenience only. The first real select column is number 1.
- if ((column > 0) && (column < static_cast<sal_Int32>(m_aColMapping.size())))
+ if ((column > 0) && (o3tl::make_unsigned(column) < m_aColMapping.size()))
map = m_aColMapping[column];
return map;
diff --git a/connectivity/source/parse/sqliterator.cxx b/connectivity/source/parse/sqliterator.cxx
index 83d6342fa84b..fcebd2879a4f 100644
--- a/connectivity/source/parse/sqliterator.cxx
+++ b/connectivity/source/parse/sqliterator.cxx
@@ -37,6 +37,7 @@
#include <comphelper/types.hxx>
#include <connectivity/dbmetadata.hxx>
#include <com/sun/star/sdb/SQLFilterOperator.hpp>
+#include <o3tl/safeint.hxx>
#include <sal/log.hxx>
#include <iterator>
@@ -1758,7 +1759,7 @@ void OSQLParseTreeIterator::setOrderByColumnName(const OUString & rColumnName, O
else
{
sal_Int32 nId = rColumnName.toInt32();
- if ( nId > 0 && nId < static_cast<sal_Int32>(m_aSelectColumns->size()) )
+ if ( nId > 0 && o3tl::make_unsigned(nId) < m_aSelectColumns->size() )
m_aOrderColumns->push_back( new OOrderColumn( (*m_aSelectColumns)[nId-1], isCaseSensitive(), bAscending ) );
}
@@ -1779,7 +1780,7 @@ void OSQLParseTreeIterator::setGroupByColumnName(const OUString & rColumnName, O
else
{
sal_Int32 nId = rColumnName.toInt32();
- if ( nId > 0 && nId < static_cast<sal_Int32>(m_aSelectColumns->size()) )
+ if ( nId > 0 && o3tl::make_unsigned(nId) < m_aSelectColumns->size() )
m_aGroupColumns->push_back(new OParseColumn((*m_aSelectColumns)[nId-1],isCaseSensitive()));
}
diff --git a/dbaccess/source/core/api/RowSet.cxx b/dbaccess/source/core/api/RowSet.cxx
index 0f0a21bfb98f..28c3929953c2 100644
--- a/dbaccess/source/core/api/RowSet.cxx
+++ b/dbaccess/source/core/api/RowSet.cxx
@@ -2701,7 +2701,7 @@ void ORowSet::checkUpdateConditions(sal_Int32 columnIndex)
if ( m_aCurrentRow.isNull() )
::dbtools::throwSQLException( DBA_RES( RID_STR_INVALID_CURSOR_STATE ), StandardSQLState::INVALID_CURSOR_STATE, *this );
- if ( columnIndex <= 0 || sal_Int32((*m_aCurrentRow)->size()) <= columnIndex )
+ if ( columnIndex <= 0 || (*m_aCurrentRow)->size() <= o3tl::make_unsigned(columnIndex) )
::dbtools::throwSQLException( DBA_RES( RID_STR_INVALID_INDEX ), StandardSQLState::INVALID_DESCRIPTOR_INDEX, *this );
}
diff --git a/dbaccess/source/core/api/RowSetCache.cxx b/dbaccess/source/core/api/RowSetCache.cxx
index e3059f889b6b..46b2cea95a02 100644
--- a/dbaccess/source/core/api/RowSetCache.cxx
+++ b/dbaccess/source/core/api/RowSetCache.cxx
@@ -946,7 +946,7 @@ void ORowSetCache::moveWindow()
if ( nRowsInCache < m_nFetchSize )
{
// There is some unused space in *m_pMatrix; fill it
- OSL_ENSURE((nRowsInCache >= static_cast<ORowSetMatrix::difference_type>(0)) && (nRowsInCache < static_cast<sal_Int32>(m_pMatrix->size())),"Position is invalid!");
+ OSL_ENSURE((nRowsInCache >= static_cast<ORowSetMatrix::difference_type>(0)) && (o3tl::make_unsigned(nRowsInCache) < m_pMatrix->size()),"Position is invalid!");
sal_Int32 nPos = m_nEndPos + 1;
bool bCheck = m_xCacheSet->absolute(nPos);
ORowSetMatrix::iterator aIter = m_pMatrix->begin() + nRowsInCache;
@@ -964,7 +964,7 @@ void ORowSetCache::moveWindow()
// The rows behind this can be reused
ORowSetMatrix::iterator aIter = m_pMatrix->begin();
const sal_Int32 nNewStartPosInMatrix = nNewStartPos - m_nStartPos;
- OSL_ENSURE((nNewStartPosInMatrix >= static_cast<ORowSetMatrix::difference_type>(0)) && (nNewStartPosInMatrix < static_cast<sal_Int32>(m_pMatrix->size())),"Position is invalid!");
+ OSL_ENSURE((nNewStartPosInMatrix >= static_cast<ORowSetMatrix::difference_type>(0)) && (o3tl::make_unsigned(nNewStartPosInMatrix) < m_pMatrix->size()),"Position is invalid!");
// first position we reuse
const ORowSetMatrix::const_iterator aEnd = m_pMatrix->begin() + nNewStartPosInMatrix;
// End of used portion of the matrix. Is < m_pMatrix->end() if less data than window size
@@ -1623,8 +1623,8 @@ void ORowSetCache::clearInsertRow()
ORowSetMatrix::iterator ORowSetCache::calcPosition() const
{
sal_Int32 nValue = (m_nPosition - m_nStartPos) - 1;
- OSL_ENSURE((nValue >= static_cast<ORowSetMatrix::difference_type>(0)) && (nValue < static_cast<sal_Int32>(m_pMatrix->size())),"Position is invalid!");
- return ( nValue < 0 || nValue >= static_cast<sal_Int32>(m_pMatrix->size()) ) ? m_pMatrix->end() : (m_pMatrix->begin() + nValue);
+ OSL_ENSURE((nValue >= static_cast<ORowSetMatrix::difference_type>(0)) && (o3tl::make_unsigned(nValue) < m_pMatrix->size()),"Position is invalid!");
+ return ( nValue < 0 || o3tl::make_unsigned(nValue) >= m_pMatrix->size() ) ? m_pMatrix->end() : (m_pMatrix->begin() + nValue);
}
TORowSetOldRowHelperRef ORowSetCache::registerOldRow()
diff --git a/dbaccess/source/core/api/StaticSet.cxx b/dbaccess/source/core/api/StaticSet.cxx
index a7ea00c4376b..97226b466dbd 100644
--- a/dbaccess/source/core/api/StaticSet.cxx
+++ b/dbaccess/source/core/api/StaticSet.cxx
@@ -23,6 +23,7 @@
#include <com/sun/star/beans/XPropertySet.hpp>
#include <connectivity/CommonTools.hxx>
#include <comphelper/types.hxx>
+#include <o3tl/safeint.hxx>
#include <osl/diagnose.h>
using namespace dbaccess;
@@ -193,7 +194,7 @@ bool OStaticSet::absolute( sal_Int32 row )
}
else if(row > 0)
{
- if(row >= static_cast<sal_Int32>(m_aSet.size()))
+ if(o3tl::make_unsigned(row) >= m_aSet.size())
{
if(!m_bEnd)
{
@@ -202,7 +203,7 @@ bool OStaticSet::absolute( sal_Int32 row )
bNext = fetchRow();
}
- if(row > static_cast<sal_Int32>(m_aSet.size()))
+ if(o3tl::make_unsigned(row) > m_aSet.size())
m_aSetIter = m_aSet.end(); // check again
else
m_aSetIter = m_aSet.begin() + row;
diff --git a/dbaccess/source/core/dataaccess/bookmarkcontainer.cxx b/dbaccess/source/core/dataaccess/bookmarkcontainer.cxx
index 4072002ba326..a03caea57e93 100644
--- a/dbaccess/source/core/dataaccess/bookmarkcontainer.cxx
+++ b/dbaccess/source/core/dataaccess/bookmarkcontainer.cxx
@@ -19,6 +19,7 @@
#include <bookmarkcontainer.hxx>
+#include <o3tl/safeint.hxx>
#include <osl/diagnose.h>
#include <comphelper/enumhelper.hxx>
#include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
@@ -206,7 +207,7 @@ Any SAL_CALL OBookmarkContainer::getByIndex( sal_Int32 _nIndex )
{
MutexGuard aGuard(m_rMutex);
- if ((_nIndex < 0) || (_nIndex >= static_cast<sal_Int32>(m_aBookmarksIndexed.size())))
+ if ((_nIndex < 0) || (o3tl::make_unsigned(_nIndex) >= m_aBookmarksIndexed.size()))
throw IndexOutOfBoundsException();
return Any(m_aBookmarksIndexed[_nIndex]->second);
diff --git a/dbaccess/source/core/dataaccess/definitioncontainer.cxx b/dbaccess/source/core/dataaccess/definitioncontainer.cxx
index d3023f2885ab..81d8b03026bb 100644
--- a/dbaccess/source/core/dataaccess/definitioncontainer.cxx
+++ b/dbaccess/source/core/dataaccess/definitioncontainer.cxx
@@ -23,6 +23,7 @@
#include <strings.hxx>
#include <tools/diagnose_ex.h>
+#include <o3tl/safeint.hxx>
#include <osl/diagnose.h>
#include <comphelper/enumhelper.hxx>
#include <cppuhelper/exc_hlp.hxx>
@@ -372,7 +373,7 @@ Any SAL_CALL ODefinitionContainer::getByIndex( sal_Int32 _nIndex )
{
MutexGuard aGuard(m_aMutex);
- if ((_nIndex < 0) || (_nIndex >= static_cast<sal_Int32>(m_aDocuments.size())))
+ if ((_nIndex < 0) || (o3tl::make_unsigned(_nIndex) >= m_aDocuments.size()))
throw IndexOutOfBoundsException();
Documents::iterator aPos = m_aDocuments[_nIndex];
diff --git a/dbaccess/source/ui/control/ColumnControlWindow.cxx b/dbaccess/source/ui/control/ColumnControlWindow.cxx
index 7a419a6cfb8c..f9f786f22ec3 100644
--- a/dbaccess/source/ui/control/ColumnControlWindow.cxx
+++ b/dbaccess/source/ui/control/ColumnControlWindow.cxx
@@ -21,6 +21,7 @@
#include <unotools/syslocale.hxx>
#include <i18nlangtag/languagetag.hxx>
#include <connectivity/dbtools.hxx>
+#include <o3tl/safeint.hxx>
#include <UITools.hxx>
#include <core_resource.hxx>
#include <strings.hrc>
@@ -121,7 +122,7 @@ Reference< XNumberFormatter > OColumnControlWindow::GetFormatter() const
TOTypeInfoSP OColumnControlWindow::getTypeInfo(sal_Int32 _nPos)
{
- return ( _nPos >= 0 && _nPos < static_cast<sal_Int32>(m_aDestTypeInfoIndex.size())) ? m_aDestTypeInfoIndex[_nPos]->second : TOTypeInfoSP();
+ return ( _nPos >= 0 && o3tl::make_unsigned(_nPos) < m_aDestTypeInfoIndex.size()) ? m_aDestTypeInfoIndex[_nPos]->second : TOTypeInfoSP();
}
const OTypeInfoMap* OColumnControlWindow::getTypeInfo() const
diff --git a/dbaccess/source/ui/dlg/indexfieldscontrol.cxx b/dbaccess/source/ui/dlg/indexfieldscontrol.cxx
index 3770fb737e1a..35b0e3f02a27 100644
--- a/dbaccess/source/ui/dlg/indexfieldscontrol.cxx
+++ b/dbaccess/source/ui/dlg/indexfieldscontrol.cxx
@@ -20,6 +20,7 @@
#include <core_resource.hxx>
#include <indexfieldscontrol.hxx>
#include <strings.hrc>
+#include <o3tl/safeint.hxx>
#include <osl/diagnose.h>
#include <helpids.h>
#include <toolkit/helper/vclunohelper.hxx>
@@ -266,7 +267,7 @@ constexpr auto BROWSER_STANDARD_FLAGS = BrowserMode::COLUMNSELECTION | BrowserMo
bool IndexFieldsControl::implGetFieldDesc(sal_Int32 _nRow, IndexFields::const_iterator& _rPos)
{
_rPos = m_aFields.end();
- if ((_nRow < 0) || (_nRow >= static_cast<sal_Int32>(m_aFields.size())))
+ if ((_nRow < 0) || (o3tl::make_unsigned(_nRow) >= m_aFields.size()))
return false;
_rPos = m_aFields.begin() + _nRow;
return true;
diff --git a/dbaccess/source/ui/tabledesign/TEditControl.cxx b/dbaccess/source/ui/tabledesign/TEditControl.cxx
index cd2149efbf54..5f7809882cc6 100644
--- a/dbaccess/source/ui/tabledesign/TEditControl.cxx
+++ b/dbaccess/source/ui/tabledesign/TEditControl.cxx
@@ -36,6 +36,7 @@
#include <connectivity/dbtools.hxx>
#include <SqlNameEdit.hxx>
#include <TableRowExchange.hxx>
+#include <o3tl/safeint.hxx>
#include <sot/storage.hxx>
#include <svx/svxids.hrc>
#include <UITools.hxx>
@@ -1602,7 +1603,7 @@ void OTableEditorCtrl::SwitchType( const TOTypeInfoSP& _pType )
// Store the old description
pDescrWin->SaveData( pActFieldDescr );
- if ( nRow < 0 || nRow > static_cast<tools::Long>(m_pRowList->size()) )
+ if ( nRow < 0 || o3tl::make_unsigned(nRow) > m_pRowList->size() )
return;
// Show the new description
std::shared_ptr<OTableRow> pRow = (*m_pRowList)[nRow];
diff --git a/dbaccess/source/ui/uno/copytablewizard.cxx b/dbaccess/source/ui/uno/copytablewizard.cxx
index 14b4609476db..2645952f4b5e 100644
--- a/dbaccess/source/ui/uno/copytablewizard.cxx
+++ b/dbaccess/source/ui/uno/copytablewizard.cxx
@@ -60,6 +60,7 @@
#include <cppuhelper/exc_hlp.hxx>
#include <cppuhelper/implbase.hxx>
#include <comphelper/interfacecontainer3.hxx>
+#include <o3tl/safeint.hxx>
#include <rtl/ustrbuf.hxx>
#include <sal/log.hxx>
#include <svtools/genericunodialog.hxx>
@@ -1150,7 +1151,7 @@ void CopyTableWizard::impl_copyRows_throw( const Reference< XResultSet >& _rxSou
continue;
}
- if ( ( nSourceColumn < 1 ) || ( nSourceColumn >= static_cast<sal_Int32>(aSourceColTypes.size()) ) )
+ if ( ( nSourceColumn < 1 ) || ( o3tl::make_unsigned(nSourceColumn) >= aSourceColTypes.size() ) )
{ // ( we have to check here against 1 because the parameters are 1 based)
::dbtools::throwSQLException("Internal error: invalid column type index.",
::dbtools::StandardSQLState::INVALID_DESCRIPTOR_INDEX, *this);
diff --git a/desktop/source/deployment/gui/dp_gui_extlistbox.cxx b/desktop/source/deployment/gui/dp_gui_extlistbox.cxx
index 3b96147bbf02..a60fffd50bc2 100644
--- a/desktop/source/deployment/gui/dp_gui_extlistbox.cxx
+++ b/desktop/source/deployment/gui/dp_gui_extlistbox.cxx
@@ -35,6 +35,7 @@
#include <com/sun/star/system/SystemShellExecute.hpp>
#include <cppuhelper/weakref.hxx>
#include <i18nlangtag/languagetag.hxx>
+#include <o3tl/safeint.hxx>
#include <osl/diagnose.h>
#include <rtl/ustrbuf.hxx>
#include <vcl/event.hxx>
@@ -354,7 +355,7 @@ void ExtensionBox_Impl::selectEntry( const tools::Long nPos )
m_vEntries[ m_nActive ]->m_bActive = false;
}
- if ( ( nPos >= 0 ) && ( nPos < static_cast<tools::Long>(m_vEntries.size()) ) )
+ if ( ( nPos >= 0 ) && ( o3tl::make_unsigned(nPos) < m_vEntries.size() ) )
{
m_bHasActive = true;
m_nActive = nPos;
@@ -623,7 +624,7 @@ bool ExtensionBox_Impl::HandleCursorKey( sal_uInt16 nKeyCode )
if ( nSelect < 0 )
nSelect = 0;
- if ( nSelect >= static_cast<tools::Long>(m_vEntries.size()) )
+ if ( o3tl::make_unsigned(nSelect) >= m_vEntries.size() )
nSelect = m_vEntries.size() - 1;
selectEntry( nSelect );
@@ -732,7 +733,7 @@ bool ExtensionBox_Impl::MouseMove( const MouseEvent& rMEvt )
bool bOverHyperlink = false;
auto nPos = PointToPos( rMEvt.GetPosPixel() );
- if ( ( nPos >= 0 ) && ( nPos < static_cast<tools::Long>(m_vEntries.size()) ) )
+ if ( ( nPos >= 0 ) && ( o3tl::make_unsigned(nPos) < m_vEntries.size() ) )
{
const auto& rEntry = m_vEntries[nPos];
bOverHyperlink = !rEntry->m_sPublisher.isEmpty() && rEntry->m_aLinkRect.Contains(rMEvt.GetPosPixel());
@@ -749,7 +750,7 @@ bool ExtensionBox_Impl::MouseMove( const MouseEvent& rMEvt )
OUString ExtensionBox_Impl::RequestHelp(tools::Rectangle& rRect)
{
auto nPos = PointToPos( rRect.TopLeft() );
- if ( ( nPos >= 0 ) && ( nPos < static_cast<tools::Long>(m_vEntries.size()) ) )
+ if ( ( nPos >= 0 ) && ( o3tl::make_unsigned(nPos) < m_vEntries.size() ) )
{
const auto& rEntry = m_vEntries[nPos];
bool bOverHyperlink = !rEntry->m_sPublisher.isEmpty() && rEntry->m_aLinkRect.Contains(rRect);
@@ -774,7 +775,7 @@ bool ExtensionBox_Impl::MouseButtonDown( const MouseEvent& rMEvt )
{
auto nPos = PointToPos( rMEvt.GetPosPixel() );
- if ( ( nPos >= 0 ) && ( nPos < static_cast<tools::Long>(m_vEntries.size()) ) )
+ if ( ( nPos >= 0 ) && ( o3tl::make_unsigned(nPos) < m_vEntries.size() ) )
{
const auto& rEntry = m_vEntries[nPos];
if (!rEntry->m_sPublisher.isEmpty() && rEntry->m_aLinkRect.Contains(rMEvt.GetPosPixel()))
diff --git a/drawinglayer/source/processor3d/zbufferprocessor3d.cxx b/drawinglayer/source/processor3d/zbufferprocessor3d.cxx
index fb74a233e283..aa319161bd3d 100644
--- a/drawinglayer/source/processor3d/zbufferprocessor3d.cxx
+++ b/drawinglayer/source/processor3d/zbufferprocessor3d.cxx
@@ -27,6 +27,7 @@
#include <basegfx/polygon/b3dpolygontools.hxx>
#include <basegfx/polygon/b3dpolypolygontools.hxx>
#include <drawinglayer/attribute/sdrlightingattribute3d.hxx>
+#include <o3tl/safeint.hxx>
#include <svtools/optionsdrawinglayer.hxx>
using namespace com::sun::star;
@@ -269,7 +270,7 @@ void ZBufferRasterConverter3D::processLineSpan(const basegfx::RasterConversionLi
if(nSpanCount & 0x0001)
return;
- if(nLine < 0 || nLine >= static_cast<sal_Int32>(mrBuffer.getHeight()))
+ if(nLine < 0 || o3tl::make_unsigned(nLine) >= mrBuffer.getHeight())
return;
sal_uInt32 nXA(std::min(mrBuffer.getWidth(), static_cast<sal_uInt32>(std::max(sal_Int32(0), basegfx::fround(rA.getX().getVal())))));
diff --git a/editeng/source/editeng/editdoc.cxx b/editeng/source/editeng/editdoc.cxx
index fba3408f1cc6..b0df5683b03a 100644
--- a/editeng/source/editeng/editdoc.cxx
+++ b/editeng/source/editeng/editdoc.cxx
@@ -50,6 +50,7 @@
#include <rtl/ustrbuf.hxx>
#include <sal/log.hxx>
+#include <o3tl/safeint.hxx>
#include <osl/diagnose.h>
#include <svl/grabbagitem.hxx>
@@ -690,17 +691,17 @@ sal_Int32 ParaPortionList::GetPos(const ParaPortion* p) const
ParaPortion* ParaPortionList::operator [](sal_Int32 nPos)
{
- return 0 <= nPos && nPos < static_cast<sal_Int32>(maPortions.size()) ? maPortions[nPos].get() : nullptr;
+ return 0 <= nPos && o3tl::make_unsigned(nPos) < maPortions.size() ? maPortions[nPos].get() : nullptr;
}
const ParaPortion* ParaPortionList::operator [](sal_Int32 nPos) const
{
- return 0 <= nPos && nPos < static_cast<sal_Int32>(maPortions.size()) ? maPortions[nPos].get() : nullptr;
+ return 0 <= nPos && o3tl::make_unsigned(nPos) < maPortions.size() ? maPortions[nPos].get() : nullptr;
}
std::unique_ptr<ParaPortion> ParaPortionList::Release(sal_Int32 nPos)
{
- if (nPos < 0 || static_cast<sal_Int32>(maPortions.size()) <= nPos)
+ if (nPos < 0 || maPortions.size() <= o3tl::make_unsigned(nPos))
{
SAL_WARN( "editeng", "ParaPortionList::Release - out of bounds pos " << nPos);
return nullptr;
@@ -712,7 +713,7 @@ std::unique_ptr<ParaPortion> ParaPortionList::Release(sal_Int32 nPos)
void ParaPortionList::Remove(sal_Int32 nPos)
{
- if (nPos < 0 || static_cast<sal_Int32>(maPortions.size()) <= nPos)
+ if (nPos < 0 || maPortions.size() <= o3tl::make_unsigned(nPos))
{
SAL_WARN( "editeng", "ParaPortionList::Remove - out of bounds pos " << nPos);
return;
@@ -722,7 +723,7 @@ void ParaPortionList::Remove(sal_Int32 nPos)
void ParaPortionList::Insert(sal_Int32 nPos, std::unique_ptr<ParaPortion> p)
{
- if (nPos < 0 || static_cast<sal_Int32>(maPortions.size()) < nPos)
+ if (nPos < 0 || maPortions.size() < o3tl::make_unsigned(nPos))
{
SAL_WARN( "editeng", "ParaPortionList::Insert - out of bounds pos " << nPos);
return;
@@ -779,12 +780,12 @@ sal_Int32 ParaPortionList::FindParagraph(tools::Long nYOffset) const
const ParaPortion* ParaPortionList::SafeGetObject(sal_Int32 nPos) const
{
- return 0 <= nPos && nPos < static_cast<sal_Int32>(maPortions.size()) ? maPortions[nPos].get() : nullptr;
+ return 0 <= nPos && o3tl::make_unsigned(nPos) < maPortions.size() ? maPortions[nPos].get() : nullptr;
}
ParaPortion* ParaPortionList::SafeGetObject(sal_Int32 nPos)
{
- return 0 <= nPos && nPos < static_cast<sal_Int32>(maPortions.size()) ? maPortions[nPos].get() : nullptr;
+ return 0 <= nPos && o3tl::make_unsigned(nPos) < maPortions.size() ? maPortions[nPos].get() : nullptr;
}
#if OSL_DEBUG_LEVEL > 0 && !defined NDEBUG
@@ -2073,12 +2074,12 @@ sal_Int32 EditDoc::GetPos(const ContentNode* p) const
const ContentNode* EditDoc::GetObject(sal_Int32 nPos) const
{
- return 0 <= nPos && nPos < static_cast<sal_Int32>(maContents.size()) ? maContents[nPos].get() : nullptr;
+ return 0 <= nPos && o3tl::make_unsigned(nPos) < maContents.size() ? maContents[nPos].get() : nullptr;
}
ContentNode* EditDoc::GetObject(sal_Int32 nPos)
{
- return 0 <= nPos && nPos < static_cast<sal_Int32>(maContents.size()) ? maContents[nPos].get() : nullptr;
+ return 0 <= nPos && o3tl::make_unsigned(nPos) < maContents.size() ? maContents[nPos].get() : nullptr;
}
const ContentNode* EditDoc::operator[](sal_Int32 nPos) const
@@ -2103,7 +2104,7 @@ void EditDoc::Insert(sal_Int32 nPos, ContentNode* p)
void EditDoc::Remove(sal_Int32 nPos)
{
- if (nPos < 0 || nPos >= static_cast<sal_Int32>(maContents.size()))
+ if (nPos < 0 || o3tl::make_unsigned(nPos) >= maContents.size())
{
SAL_WARN( "editeng", "EditDoc::Remove - out of bounds pos " << nPos);
return;
@@ -2113,7 +2114,7 @@ void EditDoc::Remove(sal_Int32 nPos)
void EditDoc::Release(sal_Int32 nPos)
{
- if (nPos < 0 || nPos >= static_cast<sal_Int32>(maContents.size()))
+ if (nPos < 0 || o3tl::make_unsigned(nPos) >= maContents.size())
{
SAL_WARN( "editeng", "EditDoc::Release - out of bounds pos " << nPos);
return;
diff --git a/editeng/source/editeng/editeng.cxx b/editeng/source/editeng/editeng.cxx
index 5869bcdeeeb4..1b8b446c3a15 100644
--- a/editeng/source/editeng/editeng.cxx
+++ b/editeng/source/editeng/editeng.cxx
@@ -23,6 +23,7 @@
#include <comphelper/lok.hxx>
#include <comphelper/processfactory.hxx>
#include <config_global.h>
+#include <o3tl/safeint.hxx>
#include <vcl/svapp.hxx>
#include <vcl/weld.hxx>
#include <vcl/window.hxx>
@@ -2040,7 +2041,7 @@ bool EditEngine::IsTextPos( const Point& rPaperPos, sal_uInt16 nBorder )
// take unrotated positions for calculation here
Point aDocPos = GetDocPos( rPaperPos );
- if ( ( aDocPos.Y() > 0 ) && ( aDocPos.Y() < static_cast<tools::Long>(pImpEditEngine->GetTextHeight()) ) )
+ if ( ( aDocPos.Y() > 0 ) && ( o3tl::make_unsigned(aDocPos.Y()) < pImpEditEngine->GetTextHeight() ) )
return pImpEditEngine->IsTextPos(aDocPos, nBorder);
return false;
}
diff --git a/editeng/source/editeng/impedit2.cxx b/editeng/source/editeng/impedit2.cxx
index 78a6c8d0e492..f04623a03292 100644
--- a/editeng/source/editeng/impedit2.cxx
+++ b/editeng/source/editeng/impedit2.cxx
@@ -4243,7 +4243,7 @@ tools::Long ImpEditEngine::GetXPos(
if( !pLine->GetCharPosArray().empty() )
{
sal_Int32 nPos = nIndex - 1 - pLine->GetStart();
- if (nPos < 0 || nPos >= static_cast<sal_Int32>(pLine->GetCharPosArray().size()))
+ if (nPos < 0 || o3tl::make_unsigned(nPos) >= pLine->GetCharPosArray().size())
{
nPos = pLine->GetCharPosArray().size()-1;
OSL_FAIL("svx::ImpEditEngine::GetXPos(), index out of range!");
diff --git a/extensions/source/propctrlr/formmetadata.cxx b/extensions/source/propctrlr/formmetadata.cxx
index 54a9d7cf2e0f..13a7b32e706b 100644
--- a/extensions/source/propctrlr/formmetadata.cxx
+++ b/extensions/source/propctrlr/formmetadata.cxx
@@ -25,6 +25,7 @@
#include <strings.hrc>
#include <stringarrays.hrc>
#include <comphelper/extract.hxx>
+#include <o3tl/safeint.hxx>
#include <osl/diagnose.h>
#include <sal/macros.h>
#include <algorithm>
@@ -675,7 +676,7 @@ namespace pcr
--nIntValue;
std::vector< OUString > aEnumStrings = m_rMetaData.getPropertyEnumRepresentations( m_nPropertyId );
- if ( ( nIntValue >= 0 ) && ( nIntValue < static_cast<sal_Int32>(aEnumStrings.size()) ) )
+ if ( ( nIntValue >= 0 ) && ( o3tl::make_unsigned(nIntValue) < aEnumStrings.size() ) )
{
sReturn = aEnumStrings[ nIntValue ];
}
diff --git a/extensions/source/propctrlr/genericpropertyhandler.cxx b/extensions/source/propctrlr/genericpropertyhandler.cxx
index 6d26811cee1d..8320e5154d14 100644
--- a/extensions/source/propctrlr/genericpropertyhandler.cxx
+++ b/extensions/source/propctrlr/genericpropertyhandler.cxx
@@ -39,6 +39,7 @@
#include <comphelper/propertyvalue.hxx>
#include <comphelper/sequence.hxx>
#include <comphelper/types.hxx>
+#include <o3tl/safeint.hxx>
#include <tools/debug.hxx>
#include <tools/diagnose_ex.h>
@@ -166,7 +167,7 @@ namespace pcr
sal_Int32 index = std::find( std::cbegin(aValues), std::cend(aValues), nAsInt ) - std::cbegin(aValues);
std::vector< OUString > aDescriptions( getDescriptions() );
- if ( ( index >= 0 ) && ( index < static_cast<sal_Int32>(aDescriptions.size()) ) )
+ if ( ( index >= 0 ) && ( o3tl::make_unsigned(index) < aDescriptions.size() ) )
sDescription = aDescriptions[ index ];
else
{
diff --git a/forms/source/component/ListBox.cxx b/forms/source/component/ListBox.cxx
index d9542504a72b..a6d4bd808086 100644
--- a/forms/source/component/ListBox.cxx
+++ b/forms/source/component/ListBox.cxx
@@ -1396,7 +1396,7 @@ namespace frm
{
sal_Int32 nSelectIndex = -1;
OSL_VERIFY( _rExternalValue >>= nSelectIndex );
- if ( ( nSelectIndex >= 0 ) && ( nSelectIndex < static_cast<sal_Int32>(getStringItemList().size()) ) )
+ if ( ( nSelectIndex >= 0 ) && ( o3tl::make_unsigned(nSelectIndex) < getStringItemList().size() ) )
{
aSelectIndexes = { o3tl::narrowing<sal_Int16>(nSelectIndex) };
}
diff --git a/forms/source/component/entrylisthelper.cxx b/forms/source/component/entrylisthelper.cxx
index 84addb3afb51..0f781076328c 100644
--- a/forms/source/component/entrylisthelper.cxx
+++ b/forms/source/component/entrylisthelper.cxx
@@ -20,6 +20,7 @@
#include "entrylisthelper.hxx"
#include <FormComponent.hxx>
+#include <o3tl/safeint.hxx>
#include <osl/diagnose.h>
#include <comphelper/sequence.hxx>
#include <comphelper/property.hxx>
@@ -82,13 +83,13 @@ namespace frm
OSL_ENSURE( _rEvent.Source == m_xListSource,
"OEntryListHelper::entryChanged: where did this come from?" );
- OSL_ENSURE( ( _rEvent.Position >= 0 ) && ( _rEvent.Position < static_cast<sal_Int32>(m_aStringItems.size()) ),
+ OSL_ENSURE( ( _rEvent.Position >= 0 ) && ( o3tl::make_unsigned(_rEvent.Position) < m_aStringItems.size() ),
"OEntryListHelper::entryChanged: invalid index!" );
OSL_ENSURE( _rEvent.Entries.getLength() == 1,
"OEntryListHelper::entryChanged: invalid string list!" );
if ( ( _rEvent.Position >= 0 )
- && ( _rEvent.Position < static_cast<sal_Int32>(m_aStringItems.size()) )
+ && ( o3tl::make_unsigned(_rEvent.Position) < m_aStringItems.size() )
&& _rEvent.Entries.hasElements()
)
{
@@ -106,11 +107,11 @@ namespace frm
OSL_ENSURE( _rEvent.Source == m_xListSource,
"OEntryListHelper::entryRangeInserted: where did this come from?" );
- OSL_ENSURE( ( _rEvent.Position > 0 ) && ( _rEvent.Position < static_cast<sal_Int32>(m_aStringItems.size()) ) && _rEvent.Entries.hasElements(),
+ OSL_ENSURE( ( _rEvent.Position > 0 ) && ( o3tl::make_unsigned(_rEvent.Position) < m_aStringItems.size() ) && _rEvent.Entries.hasElements(),
"OEntryListHelper::entryRangeRemoved: invalid count and/or position!" );
if ( ( _rEvent.Position > 0 )
- && ( _rEvent.Position < static_cast<sal_Int32>(m_aStringItems.size()) )
+ && ( o3tl::make_unsigned(_rEvent.Position) < m_aStringItems.size() )
&& _rEvent.Entries.hasElements()
)
{
diff --git a/forms/source/misc/InterfaceContainer.cxx b/forms/source/misc/InterfaceContainer.cxx
index f0615970aa44..c797124bfeaf 100644
--- a/forms/source/misc/InterfaceContainer.cxx
+++ b/forms/source/misc/InterfaceContainer.cxx
@@ -43,6 +43,7 @@
#include <comphelper/sequence.hxx>
#include <comphelper/types.hxx>
#include <cppuhelper/exc_hlp.hxx>
+#include <o3tl/safeint.hxx>
#include <tools/debug.hxx>
#include <tools/diagnose_ex.h>
#include <sal/log.hxx>
@@ -722,7 +723,7 @@ sal_Int32 OInterfaceContainer::getCount()
Any OInterfaceContainer::getByIndex(sal_Int32 _nIndex)
{
- if (_nIndex < 0 || (_nIndex >= static_cast<sal_Int32>(m_aItems.size())))
+ if (_nIndex < 0 || (o3tl::make_unsigned(_nIndex) >= m_aItems.size()))
throw IndexOutOfBoundsException();
return m_aItems[_nIndex]->queryInterface( m_aElementType );
@@ -915,7 +916,7 @@ void SAL_CALL OInterfaceContainer::insertByIndex( sal_Int32 _nIndex, const Any&
void OInterfaceContainer::implReplaceByIndex( const sal_Int32 _nIndex, const Any& _rNewElement, ::osl::ClearableMutexGuard& _rClearBeforeNotify )
{
- OSL_PRECOND( ( _nIndex >= 0 ) && ( _nIndex < static_cast<sal_Int32>(m_aItems.size()) ), "OInterfaceContainer::implReplaceByIndex: precondition not met (index)!" );
+ OSL_PRECOND( ( _nIndex >= 0 ) && ( o3tl::make_unsigned(_nIndex) < m_aItems.size() ), "OInterfaceContainer::implReplaceByIndex: precondition not met (index)!" );
// approve the new object
std::unique_ptr< ElementDescription > aElementMetaData( createElementMetaData() );
@@ -991,7 +992,7 @@ void OInterfaceContainer::implReplaceByIndex( const sal_Int32 _nIndex, const Any
void OInterfaceContainer::implCheckIndex( const sal_Int32 _nIndex )
{
- if (_nIndex < 0 || _nIndex >= static_cast<sal_Int32>(m_aItems.size()))
+ if (_nIndex < 0 || o3tl::make_unsigned(_nIndex) >= m_aItems.size())
throw IndexOutOfBoundsException();
}
@@ -1008,7 +1009,7 @@ void SAL_CALL OInterfaceContainer::replaceByIndex(sal_Int32 _nIndex, const Any&
void OInterfaceContainer::implRemoveByIndex( const sal_Int32 _nIndex, ::osl::ClearableMutexGuard& _rClearBeforeNotify )
{
- OSL_PRECOND( ( _nIndex >= 0 ) && ( _nIndex < static_cast<sal_Int32>(m_aItems.size()) ), "OInterfaceContainer::implRemoveByIndex: precondition not met (index)!" );
+ OSL_PRECOND( ( _nIndex >= 0 ) && ( o3tl::make_unsigned(_nIndex) < m_aItems.size() ), "OInterfaceContainer::implRemoveByIndex: precondition not met (index)!" );
OInterfaceArray::iterator i = m_aItems.begin() + _nIndex;
css::uno::Reference<css::uno::XInterface> xElement(*i);
diff --git a/forms/source/xforms/binding.cxx b/forms/source/xforms/binding.cxx
index e2f6a8ea02c0..32eeefc75de3 100644
--- a/forms/source/xforms/binding.cxx
+++ b/forms/source/xforms/binding.cxx
@@ -31,6 +31,7 @@
#include <strings.hrc>
#include <rtl/ustrbuf.hxx>
+#include <o3tl/safeint.hxx>
#include <osl/diagnose.h>
#include <tools/diagnose_ex.h>
@@ -1042,7 +1043,7 @@ OUString Binding::getListEntry( sal_Int32 nPosition )
// check bounds and return proper item
PathExpression::NodeVector_t aNodes = maBindingExpression.getNodeList();
- if( nPosition < 0 || nPosition >= static_cast<sal_Int32>( aNodes.size() ) )
+ if( nPosition < 0 || o3tl::make_unsigned(nPosition) >= aNodes.size() )
throw IndexOutOfBoundsException("", static_cast<XValueBinding*>(this));
return lcl_getString( aNodes[ nPosition ] );
}
diff --git a/i18nutil/source/utility/scripttypedetector.cxx b/i18nutil/source/utility/scripttypedetector.cxx
index bea0714f375b..f096ecbde831 100644
--- a/i18nutil/source/utility/scripttypedetector.cxx
+++ b/i18nutil/source/utility/scripttypedetector.cxx
@@ -22,6 +22,7 @@
#include <com/sun/star/i18n/UnicodeScript.hpp>
#include <i18nutil/scripttypedetector.hxx>
#include <i18nutil/unicode.hxx>
+#include <o3tl/safeint.hxx>
using namespace com::sun::star::i18n;
@@ -99,7 +100,7 @@ sal_Int32 ScriptTypeDetector::beginOfCTLScriptType( std::u16string_view Text, sa
{
if (nPos < 0)
return 0;
- else if (nPos >= static_cast<sal_Int32>(Text.size()))
+ else if (o3tl::make_unsigned(nPos) >= Text.size())
return Text.size();
else {
sal_Int16 cType = getCTLScriptType(Text, nPos);
@@ -116,7 +117,7 @@ sal_Int32 ScriptTypeDetector::endOfCTLScriptType( std::u16string_view Text, sal_
{
if (nPos < 0)
return 0;
- else if (nPos >= static_cast<sal_Int32>(Text.size()))
+ else if (o3tl::make_unsigned(nPos) >= Text.size())
return Text.size();
else {
sal_Int16 cType = getCTLScriptType(Text, nPos);
diff --git a/linguistic/source/lngopt.cxx b/linguistic/source/lngopt.cxx
index 1b36c43c3075..1a48789aeeed 100644
--- a/linguistic/source/lngopt.cxx
+++ b/linguistic/source/lngopt.cxx
@@ -21,6 +21,7 @@
#include <sal/macros.h>
#include "lngopt.hxx"
#include <linguistic/misc.hxx>
+#include <o3tl/safeint.hxx>
#include <tools/debug.hxx>
#include <unotools/lingucfg.hxx>
@@ -124,7 +125,8 @@ OUString LinguOptions::GetName( sal_Int32 nWID )
OUString aRes;
- if (0 <= nWID && nWID < sal_Int32(SAL_N_ELEMENTS(aWID_Name)) && aWID_Name[ nWID ].nWID == nWID)
+ if (0 <= nWID && o3tl::make_unsigned(nWID) < SAL_N_ELEMENTS(aWID_Name)
+ && aWID_Name[ nWID ].nWID == nWID)
aRes = aWID_Name[nWID].aPropertyName;
else
OSL_FAIL("lng : unknown WID");
diff --git a/oox/source/ppt/comments.cxx b/oox/source/ppt/comments.cxx
index 73b78c34459a..c38397fcad69 100644
--- a/oox/source/ppt/comments.cxx
+++ b/oox/source/ppt/comments.cxx
@@ -11,6 +11,7 @@
#include <com/sun/star/lang/IllegalArgumentException.hpp>
#include <rtl/math.h>
#include <rtl/math.hxx>
+#include <o3tl/safeint.hxx>
#include <o3tl/string_view.hxx>
namespace oox::ppt
@@ -78,7 +79,7 @@ OUString Comment::getAuthor(const CommentAuthorList& list)
const Comment& CommentList::getCommentAtIndex(int index)
{
- if (index >= static_cast<int>(cmLst.size()) || index < 0)
+ if (index < 0 || o3tl::make_unsigned(index) >= cmLst.size())
throw css::lang::IllegalArgumentException();
return cmLst.at(index);
diff --git a/reportdesign/source/core/api/Functions.cxx b/reportdesign/source/core/api/Functions.cxx
index 31928d8b34ec..820d3c0eaba3 100644
--- a/reportdesign/source/core/api/Functions.cxx
+++ b/reportdesign/source/core/api/Functions.cxx
@@ -22,6 +22,7 @@
#include <strings.hrc>
#include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
#include <com/sun/star/lang/NoSupportException.hpp>
+#include <o3tl/safeint.hxx>
namespace reportdesign
{
@@ -182,7 +183,7 @@ void SAL_CALL OFunctions::removeContainerListener( const uno::Reference< contain
void OFunctions::checkIndex(sal_Int32 _nIndex)
{
- if ( _nIndex < 0 || static_cast<sal_Int32>(m_aFunctions.size()) <= _nIndex )
+ if ( _nIndex < 0 || m_aFunctions.size() <= o3tl::make_unsigned(_nIndex) )
throw lang::IndexOutOfBoundsException();
}
diff --git a/reportdesign/source/core/api/Groups.cxx b/reportdesign/source/core/api/Groups.cxx
index 6310813134a9..780c6093bec4 100644
--- a/reportdesign/source/core/api/Groups.cxx
+++ b/reportdesign/source/core/api/Groups.cxx
@@ -20,6 +20,7 @@
#include <Group.hxx>
#include <com/sun/star/lang/NoSupportException.hpp>
#include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
+#include <o3tl/safeint.hxx>
#include <core_resource.hxx>
#include <strings.hrc>
@@ -184,7 +185,7 @@ void SAL_CALL OGroups::removeContainerListener( const uno::Reference< container:
void OGroups::checkIndex(sal_Int32 _nIndex)
{
- if ( _nIndex < 0 || static_cast<sal_Int32>(m_aGroups.size()) <= _nIndex )
+ if ( _nIndex < 0 || m_aGroups.size() <= o3tl::make_unsigned(_nIndex) )
throw lang::IndexOutOfBoundsException();
}
diff --git a/reportdesign/source/core/api/ReportControlModel.cxx b/reportdesign/source/core/api/ReportControlModel.cxx
index f1a00af093a0..16dee9bd17bc 100644
--- a/reportdesign/source/core/api/ReportControlModel.cxx
+++ b/reportdesign/source/core/api/ReportControlModel.cxx
@@ -20,6 +20,7 @@
#include <com/sun/star/beans/XMultiPropertySet.hpp>
#include <com/sun/star/beans/XPropertyState.hpp>
#include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
+#include <o3tl/safeint.hxx>
namespace reportdesign
{
using namespace com::sun::star;
@@ -118,7 +119,7 @@ uno::Any OReportControlModel::getByIndex(::sal_Int32 Index)
void OReportControlModel::checkIndex(sal_Int32 _nIndex)
{
- if (_nIndex < 0 || static_cast<sal_Int32>(m_aFormatConditions.size()) <= _nIndex)
+ if (_nIndex < 0 || m_aFormatConditions.size() <= o3tl::make_unsigned(_nIndex))
throw lang::IndexOutOfBoundsException();
}
diff --git a/reportdesign/source/core/api/ReportDefinition.cxx b/reportdesign/source/core/api/ReportDefinition.cxx
index d6d5e8179d66..4ff066ba86cb 100644
--- a/reportdesign/source/core/api/ReportDefinition.cxx
+++ b/reportdesign/source/core/api/ReportDefinition.cxx
@@ -102,6 +102,7 @@
#include <dbaccess/dbaundomanager.hxx>
#include <editeng/paperinf.hxx>
#include <framework/titlehelper.hxx>
+#include <o3tl/safeint.hxx>
#include <svl/itempool.hxx>
#include <svl/undo.hxx>
#include <svx/svdlayer.hxx>
@@ -2282,7 +2283,7 @@ sal_Int32 SAL_CALL OStylesHelper::getCount( )
uno::Any SAL_CALL OStylesHelper::getByIndex( sal_Int32 Index )
{
::osl::MutexGuard aGuard(m_aMutex);
- if ( Index < 0 || Index >= static_cast<sal_Int32>(m_aElementsPos.size()) )
+ if ( Index < 0 || o3tl::make_unsigned(Index) >= m_aElementsPos.size() )
throw lang::IndexOutOfBoundsException();
return m_aElementsPos[Index]->second;
}
diff --git a/sc/source/core/data/dptabsrc.cxx b/sc/source/core/data/dptabsrc.cxx
index 17a6cc17171c..cab605f69080 100644
--- a/sc/source/core/data/dptabsrc.cxx
+++ b/sc/source/core/data/dptabsrc.cxx
@@ -2604,7 +2604,7 @@ const ScDPItemData* ScDPSource::GetItemDataById(sal_Int32 nDim, sal_Int32 nId)
const ScDPItemData* ScDPMembers::GetSrcItemDataByIndex(SCROW nIndex)
{
const std::vector< SCROW >& memberIds = pSource->GetData()->GetColumnEntries( nDim );
- if ( nIndex >= static_cast<tools::Long>(memberIds.size()) || nIndex < 0 )
+ if ( nIndex < 0 || o3tl::make_unsigned(nIndex) >= memberIds.size() )
return nullptr;
SCROW nId = memberIds[ nIndex ];
return pSource->GetItemDataById( nDim, nId );
diff --git a/sc/source/core/data/markmulti.cxx b/sc/source/core/data/markmulti.cxx
index 3d8aef3cfafc..4c92f5f25a47 100644
--- a/sc/source/core/data/markmulti.cxx
+++ b/sc/source/core/data/markmulti.cxx
@@ -23,6 +23,8 @@
#include <segmenttree.hxx>
#include <sheetlimits.hxx>
+#include <o3tl/safeint.hxx>
+
#include <algorithm>
ScMultiSel::ScMultiSel(const ScSheetLimits& rSheetLimits)
@@ -384,7 +386,7 @@ void ScMultiSel::ShiftCols(SCCOL nStartCol, sal_Int32 nColOffset)
}
aRowSel = aNewMultiSel.aRowSel;
- if (!(nColOffset > 0 && nStartCol > 0 && nStartCol < static_cast<SCCOL>(aNewMultiSel.aMultiSelContainer.size())))
+ if (!(nColOffset > 0 && nStartCol > 0 && o3tl::make_unsigned(nStartCol) < aNewMultiSel.aMultiSelContainer.size()))
return;
// insert nColOffset new columns, and select their cells if they are selected
diff --git a/sc/source/core/tool/queryparam.cxx b/sc/source/core/tool/queryparam.cxx
index 80aa2185c0b3..286a1ef4ff64 100644
--- a/sc/source/core/tool/queryparam.cxx
+++ b/sc/source/core/tool/queryparam.cxx
@@ -24,6 +24,7 @@
#include <svl/sharedstringpool.hxx>
#include <svl/numformat.hxx>
+#include <o3tl/safeint.hxx>
#include <osl/diagnose.h>
#include <algorithm>
@@ -453,7 +454,7 @@ bool ScDBQueryParamMatrix::IsValidFieldIndex() const
{
SCSIZE nC, nR;
mpMatrix->GetDimensions(nC, nR);
- return 0 <= mnField && mnField <= static_cast<SCCOL>(nC);
+ return 0 <= mnField && o3tl::make_unsigned(mnField) <= nC;
}
ScDBQueryParamMatrix::~ScDBQueryParamMatrix()
diff --git a/sc/source/filter/oox/pivottablebuffer.cxx b/sc/source/filter/oox/pivottablebuffer.cxx
index 142ec1b2406e..6d73e26928a9 100644
--- a/sc/source/filter/oox/pivottablebuffer.cxx
+++ b/sc/source/filter/oox/pivottablebuffer.cxx
@@ -40,6 +40,7 @@
#include <com/sun/star/xml/sax/XFastAttributeList.hpp>
#include <comphelper/sequence.hxx>
+#include <o3tl/safeint.hxx>
#include <osl/diagnose.h>
#include <tools/diagnose_ex.h>
#include <sal/log.hxx>
@@ -551,7 +552,7 @@ void PivotTableField::convertPageField( const PTPageFieldModel& rPageField )
else
{
// single item may be selected
- if( (0 <= rPageField.mnItem) && (rPageField.mnItem < static_cast< sal_Int32 >( maItems.size() )) )
+ if( (0 <= rPageField.mnItem) && (o3tl::make_unsigned(rPageField.mnItem) < maItems.size()) )
nCacheItem = maItems[ rPageField.mnItem ].mnCacheItem;
}
diff --git a/sc/source/ui/docshell/impex.cxx b/sc/source/ui/docshell/impex.cxx
index 76ddae4f2ef1..6e6c57f44683 100644
--- a/sc/source/ui/docshell/impex.cxx
+++ b/sc/source/ui/docshell/impex.cxx
@@ -2294,7 +2294,7 @@ bool ScImportExport::Sylk2Doc( SvStream& rStrm )
if( nCol > nEndCol )
nEndCol = nCol;
}
- if ( 0 <= nFormat && nFormat < static_cast<sal_Int32>(aFormats.size()) && !bInvalidCol && !bInvalidRow )
+ if ( 0 <= nFormat && o3tl::make_unsigned(nFormat) < aFormats.size() && !bInvalidCol && !bInvalidRow )
{
sal_uInt32 nKey = aFormats[nFormat];
rDoc.ApplyAttr( nCol, nRow, aRange.aStart.Tab(),
diff --git a/sc/source/ui/unoobj/appluno.cxx b/sc/source/ui/unoobj/appluno.cxx
index 4096c5f4c384..998d7ef50a7d 100644
--- a/sc/source/ui/unoobj/appluno.cxx
+++ b/sc/source/ui/unoobj/appluno.cxx
@@ -19,6 +19,7 @@
#include <appluno.hxx>
#include <sal/types.h>
+#include <o3tl/safeint.hxx>
#include <osl/diagnose.h>
#include <formula/funcvarargs.h>
@@ -544,7 +545,7 @@ uno::Any SAL_CALL ScFunctionListObj::getByIndex( sal_Int32 nIndex )
if ( !pFuncList )
throw uno::RuntimeException(); // should not happen
- if ( nIndex >= 0 && nIndex < static_cast<sal_Int32>(pFuncList->GetCount()) )
+ if ( nIndex >= 0 && o3tl::make_unsigned(nIndex) < pFuncList->GetCount() )
{
const ScFuncDesc* pDesc = pFuncList->GetFunction(nIndex);
if ( pDesc )
diff --git a/sc/source/ui/unoobj/chart2uno.cxx b/sc/source/ui/unoobj/chart2uno.cxx
index 194b166e6bf5..d2fec774e125 100644
--- a/sc/source/ui/unoobj/chart2uno.cxx
+++ b/sc/source/ui/unoobj/chart2uno.cxx
@@ -3205,7 +3205,7 @@ sal_uInt32 getDisplayNumberFormat(const ScDocument* pDoc, const ScAddress& rPos)
return 0;
}
- if (nIndex < 0 || nIndex >= static_cast<sal_Int32>(m_aDataArray.size()))
+ if (nIndex < 0 || o3tl::make_unsigned(nIndex) >= m_aDataArray.size())
{
SAL_WARN("sc.ui", "Passed invalid index to getNumberFormatKeyByIndex(). Will return default value '0'.");
return 0;
diff --git a/sc/source/ui/unoobj/dapiuno.cxx b/sc/source/ui/unoobj/dapiuno.cxx
index 4bf5018e2cd4..64111c1c3437 100644
--- a/sc/source/ui/unoobj/dapiuno.cxx
+++ b/sc/source/ui/unoobj/dapiuno.cxx
@@ -20,6 +20,7 @@
#include <algorithm>
#include <cmath>
+#include <o3tl/safeint.hxx>
#include <svl/hint.hxx>
#include <vcl/svapp.hxx>
#include <sal/log.hxx>
@@ -2832,7 +2833,7 @@ sal_Int32 SAL_CALL ScDataPilotFieldGroupsObj::getCount()
Any SAL_CALL ScDataPilotFieldGroupsObj::getByIndex( sal_Int32 nIndex )
{
SolarMutexGuard aGuard;
- if ((nIndex < 0) || (nIndex >= static_cast< sal_Int32 >( maGroups.size() )))
+ if ((nIndex < 0) || (o3tl::make_unsigned(nIndex) >= maGroups.size()))
throw IndexOutOfBoundsException();
return Any( Reference< XNameAccess >( new ScDataPilotFieldGroupObj( *this, maGroups[ nIndex ].maName ) ) );
}
@@ -3004,7 +3005,7 @@ Any SAL_CALL ScDataPilotFieldGroupObj::getByIndex( sal_Int32 nIndex )
{
SolarMutexGuard aGuard;
ScFieldGroupMembers& rMembers = mxParent->getFieldGroup( maGroupName ).maMembers;
- if ((nIndex < 0) || (nIndex >= static_cast< sal_Int32 >( rMembers.size() )))
+ if ((nIndex < 0) || (o3tl::make_unsigned(nIndex) >= rMembers.size()))
throw IndexOutOfBoundsException();
return Any( Reference< XNamed >( new ScDataPilotFieldGroupItemObj( *this, rMembers[ nIndex ] ) ) );
}
diff --git a/sc/source/ui/unoobj/fmtuno.cxx b/sc/source/ui/unoobj/fmtuno.cxx
index 2446ad8e5b50..64ff2841922c 100644
--- a/sc/source/ui/unoobj/fmtuno.cxx
+++ b/sc/source/ui/unoobj/fmtuno.cxx
@@ -19,6 +19,7 @@
#include <sal/config.h>
+#include <o3tl/safeint.hxx>
#include <osl/diagnose.h>
#include <svl/style.hxx>
#include <vcl/svapp.hxx>
@@ -342,7 +343,7 @@ void SAL_CALL ScTableConditionalFormat::removeByIndex( sal_Int32 nIndex )
{
SolarMutexGuard aGuard;
- if (nIndex < static_cast<sal_Int32>(maEntries.size()) && nIndex >= 0)
+ if (nIndex >= 0 && o3tl::make_unsigned(nIndex) < maEntries.size())
{
maEntries.erase(maEntries.begin()+nIndex);
}
diff --git a/sc/source/ui/unoobj/nameuno.cxx b/sc/source/ui/unoobj/nameuno.cxx
index ea54ee508831..1a1184c002be 100644
--- a/sc/source/ui/unoobj/nameuno.cxx
+++ b/sc/source/ui/unoobj/nameuno.cxx
@@ -17,6 +17,7 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
+#include <o3tl/safeint.hxx>
#include <svl/hint.hxx>
#include <vcl/svapp.hxx>
#include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
@@ -1087,7 +1088,7 @@ void SAL_CALL ScLabelRangesObj::removeByIndex( sal_Int32 nIndex )
ScDocument& rDoc = pDocShell->GetDocument();
ScRangePairList* pOldList = bColumn ? rDoc.GetColNameRanges() : rDoc.GetRowNameRanges();
- if ( pOldList && nIndex >= 0 && nIndex < static_cast<sal_Int32>(pOldList->size()) )
+ if ( pOldList && nIndex >= 0 && o3tl::make_unsigned(nIndex) < pOldList->size() )
{
ScRangePairListRef xNewList(pOldList->Clone());
diff --git a/sc/source/ui/vba/vbafiledialogitems.cxx b/sc/source/ui/vba/vbafiledialogitems.cxx
index f64f706d3a7c..d34ace3c55e3 100644
--- a/sc/source/ui/vba/vbafiledialogitems.cxx
+++ b/sc/source/ui/vba/vbafiledialogitems.cxx
@@ -16,6 +16,9 @@
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
+
+#include <o3tl/safeint.hxx>
+
#include "vbafiledialogitems.hxx"
using namespace ::com::sun::star;
@@ -71,7 +74,7 @@ ScVbaFileDialogSelectedItems::createCollectionObject( const uno::Any& aSource )
sal_Int32 nPosition = -1;
if (!(aSource >>= nPosition))
throw uno::RuntimeException("not an sal_Int32");
- if (nPosition < 0 || nPosition >= static_cast<sal_Int32>(m_sItems.size()))
+ if (nPosition < 0 || o3tl::make_unsigned(nPosition) >= m_sItems.size())
throw uno::RuntimeException("out of range");
OUString sPath = m_sItems[nPosition];
diff --git a/sd/source/filter/html/buttonset.cxx b/sd/source/filter/html/buttonset.cxx
index 1bc24a7e33cd..3929f74222e8 100644
--- a/sd/source/filter/html/buttonset.cxx
+++ b/sd/source/filter/html/buttonset.cxx
@@ -25,6 +25,7 @@
#include <com/sun/star/graphic/XGraphicProvider.hpp>
#include <com/sun/star/io/XStream.hpp>
+#include <o3tl/safeint.hxx>
#include <osl/file.hxx>
#include <comphelper/storagehelper.hxx>
#include <comphelper/oslfile2streamwrap.hxx>
@@ -195,7 +196,7 @@ int ButtonSetImpl::getCount() const
bool ButtonSetImpl::getPreview( int nSet, const std::vector< OUString >& rButtons, Image& rImage )
{
- if( (nSet >= 0) && (nSet < static_cast<int>(maButtons.size())))
+ if( (nSet >= 0) && (o3tl::make_unsigned(nSet) < maButtons.size()))
{
ButtonsImpl& rSet = *maButtons[nSet];
@@ -243,7 +244,7 @@ bool ButtonSetImpl::getPreview( int nSet, const std::vector< OUString >& rButton
bool ButtonSetImpl::exportButton( int nSet, const OUString& rPath, const OUString& rName )
{
- if( (nSet >= 0) && (nSet < static_cast<int>(maButtons.size())))
+ if( (nSet >= 0) && (o3tl::make_unsigned(nSet) < maButtons.size()))
{
ButtonsImpl& rSet = *maButtons[nSet];
diff --git a/sd/source/ui/app/sdxfer.cxx b/sd/source/ui/app/sdxfer.cxx
index 14e63798aec9..67016fd194e1 100644
--- a/sd/source/ui/app/sdxfer.cxx
+++ b/sd/source/ui/app/sdxfer.cxx
@@ -35,6 +35,7 @@
#include <editeng/outlobj.hxx>
#include <sot/storage.hxx>
#include <editeng/editobj.hxx>
+#include <o3tl/safeint.hxx>
#include <svx/svdobjkind.hxx>
#include <svx/svdouno.hxx>
#include <svx/ImageMapInfo.hxx>
@@ -725,7 +726,7 @@ sal_Int32 SdTransferable::GetUserDataCount() const
std::shared_ptr<SdTransferable::UserData> SdTransferable::GetUserData (const sal_Int32 nIndex) const
{
- if (nIndex>=0 && nIndex<sal_Int32(maUserData.size()))
+ if (nIndex>=0 && o3tl::make_unsigned(nIndex)<maUserData.size())
return maUserData[nIndex];
else
return std::shared_ptr<UserData>();
diff --git a/sd/source/ui/slideshow/slideshowimpl.cxx b/sd/source/ui/slideshow/slideshowimpl.cxx
index b896fbb4ebbf..3215a550b7c1 100644
--- a/sd/source/ui/slideshow/slideshowimpl.cxx
+++ b/sd/source/ui/slideshow/slideshowimpl.cxx
@@ -78,6 +78,7 @@
#include <comphelper/processfactory.hxx>
#include <comphelper/propertyvalue.hxx>
#include <rtl/ref.hxx>
+#include <o3tl/safeint.hxx>
#include <o3tl/string_view.hxx>
#include <avmedia/mediawindow.hxx>
#include <svtools/colrdlg.hxx>
@@ -166,7 +167,7 @@ private:
bool getSlideAPI( sal_Int32 nSlideNumber, Reference< XDrawPage >& xSlide, Reference< XAnimationNode >& xAnimNode );
sal_Int32 findSlideIndex( sal_Int32 nSlideNumber ) const;
- bool isValidIndex( sal_Int32 nIndex ) const { return (nIndex >= 0) && (nIndex < static_cast<sal_Int32>(maSlideNumbers.size())); }
+ bool isValidIndex( sal_Int32 nIndex ) const { return (nIndex >= 0) && (o3tl::make_unsigned(nIndex) < maSlideNumbers.size()); }
bool isValidSlideNumber( sal_Int32 nSlideNumber ) const { return (nSlideNumber >= 0) && (nSlideNumber < mnSlideCount); }
private:
diff --git a/sd/source/ui/slidesorter/model/SlideSorterModel.cxx b/sd/source/ui/slidesorter/model/SlideSorterModel.cxx
index 365c9127944d..4d3e7965690b 100644
--- a/sd/source/ui/slidesorter/model/SlideSorterModel.cxx
+++ b/sd/source/ui/slidesorter/model/SlideSorterModel.cxx
@@ -41,6 +41,7 @@
#include <sdpage.hxx>
#include <FrameView.hxx>
+#include <o3tl/safeint.hxx>
#include <tools/diagnose_ex.h>
using namespace ::com::sun::star;
@@ -616,7 +617,7 @@ bool SlideSorterModel::DeleteSlide (const SdPage* pPage)
bool bMarkedSelected(false);
- if(nIndex >= 0 && nIndex < static_cast<sal_Int32>(maPageDescriptors.size()))
+ if(nIndex >= 0 && o3tl::make_unsigned(nIndex) < maPageDescriptors.size())
{
if (maPageDescriptors[nIndex])
if (maPageDescriptors[nIndex]->GetPage() != pPage)
diff --git a/sd/source/ui/unoidl/unocpres.cxx b/sd/source/ui/unoidl/unocpres.cxx
index e5c9eb16e021..cc57b1e7941a 100644
--- a/sd/source/ui/unoidl/unocpres.cxx
+++ b/sd/source/ui/unoidl/unocpres.cxx
@@ -21,6 +21,7 @@
#include <com/sun/star/lang/DisposedException.hpp>
#include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
+#include <o3tl/safeint.hxx>
#include <vcl/svapp.hxx>
#include <svx/svdpage.hxx>
#include <cppuhelper/supportsservice.hxx>
@@ -84,7 +85,7 @@ void SAL_CALL SdXCustomPresentation::insertByIndex( sal_Int32 Index, const uno::
if( bDisposing )
throw lang::DisposedException();
- if( Index < 0 || Index > static_cast<sal_Int32>( mpSdCustomShow ? mpSdCustomShow->PagesVector().size() : 0 ) )
+ if( Index < 0 || o3tl::make_unsigned(Index) > ( mpSdCustomShow ? mpSdCustomShow->PagesVector().size() : 0 ) )
throw lang::IndexOutOfBoundsException();
uno::Reference< drawing::XDrawPage > xPage;
@@ -182,7 +183,7 @@ uno::Any SAL_CALL SdXCustomPresentation::getByIndex( sal_Int32 Index )
if( bDisposing )
throw lang::DisposedException();
- if (Index < 0 || !mpSdCustomShow || Index >= static_cast<sal_Int32>(mpSdCustomShow->PagesVector().size()))
+ if (Index < 0 || !mpSdCustomShow || o3tl::make_unsigned(Index) >= mpSdCustomShow->PagesVector().size())
throw lang::IndexOutOfBoundsException();
uno::Any aAny;
diff --git a/sdext/source/pdfimport/tree/imagecontainer.cxx b/sdext/source/pdfimport/tree/imagecontainer.cxx
index 9754e9134a50..a7154164d771 100644
--- a/sdext/source/pdfimport/tree/imagecontainer.cxx
+++ b/sdext/source/pdfimport/tree/imagecontainer.cxx
@@ -24,6 +24,7 @@
#include <rtl/ustrbuf.hxx>
#include <sal/log.hxx>
+#include <o3tl/safeint.hxx>
#include <osl/diagnose.h>
#include <com/sun/star/beans/PropertyValue.hpp>
@@ -111,7 +112,7 @@ ImageId ImageContainer::addImage( const uno::Sequence<beans::PropertyValue>& xBi
void ImageContainer::writeBase64EncodedStream( ImageId nId, EmitContext& rContext )
{
- OSL_ASSERT( nId >= 0 && nId < ImageId( m_aImages.size()) );
+ OSL_ASSERT( nId >= 0 && o3tl::make_unsigned(nId) < m_aImages.size() );
const uno::Sequence<beans::PropertyValue>& rEntry( m_aImages[nId] );
diff --git a/sdext/source/presenter/PresenterAccessibility.cxx b/sdext/source/presenter/PresenterAccessibility.cxx
index 10d73b88d898..e3f49ed1dddf 100644
--- a/sdext/source/presenter/PresenterAccessibility.cxx
+++ b/sdext/source/presenter/PresenterAccessibility.cxx
@@ -792,7 +792,7 @@ Reference<XAccessible> SAL_CALL
{
ThrowIfDisposed();
- if (nIndex<0 || nIndex>=sal_Int32(maChildren.size()))
+ if (nIndex<0 || o3tl::make_unsigned(nIndex)>=maChildren.size())
throw lang::IndexOutOfBoundsException("invalid child index", static_cast<uno::XWeak*>(this));
return maChildren[nIndex];
@@ -1229,7 +1229,7 @@ AccessibleStateSet::AccessibleStateSet (const sal_Int32 nStateSet)
sal_uInt32 AccessibleStateSet::GetStateMask (const sal_Int16 nState)
{
- if (nState<0 || nState>=sal_Int16(sizeof(sal_uInt32)*8))
+ if (nState<0 || o3tl::make_unsigned(nState)>=sizeof(sal_uInt32)*8)
{
throw RuntimeException("AccessibleStateSet::GetStateMask: invalid state");
}
diff --git a/sdext/source/presenter/PresenterTextView.cxx b/sdext/source/presenter/PresenterTextView.cxx
index f77ef93bc6d8..d83229b88e2a 100644
--- a/sdext/source/presenter/PresenterTextView.cxx
+++ b/sdext/source/presenter/PresenterTextView.cxx
@@ -419,7 +419,7 @@ SharedPresenterTextParagraph PresenterTextView::GetParagraph (
{
if (nParagraphIndex < 0)
return SharedPresenterTextParagraph();
- else if (nParagraphIndex>=sal_Int32(maParagraphs.size()))
+ else if (o3tl::make_unsigned(nParagraphIndex)>=maParagraphs.size())
return SharedPresenterTextParagraph();
else
return maParagraphs[nParagraphIndex];
diff --git a/sfx2/source/dialog/filtergrouping.cxx b/sfx2/source/dialog/filtergrouping.cxx
index 59388eece485..ef1a4fef3035 100644
--- a/sfx2/source/dialog/filtergrouping.cxx
+++ b/sfx2/source/dialog/filtergrouping.cxx
@@ -18,6 +18,7 @@
*/
#include "filtergrouping.hxx"
+#include <o3tl/safeint.hxx>
#include <sfx2/fcontnr.hxx>
#include <sfx2/filedlghelper.hxx>
#include <sfx2/strings.hrc>
@@ -882,7 +883,7 @@ namespace sfx2
std::shared_ptr<const SfxFilter> TSortedFilterList::impl_getFilter(sal_Int32 nIndex)
{
- if (nIndex<0 || nIndex>=static_cast<sal_Int32>(m_lFilters.size()))
+ if (nIndex<0 || o3tl::make_unsigned(nIndex)>=m_lFilters.size())
return nullptr;
const OUString& sFilterName = m_lFilters[nIndex];
if (sFilterName.isEmpty())
diff --git a/sfx2/source/sidebar/FocusManager.cxx b/sfx2/source/sidebar/FocusManager.cxx
index 42a75af4fa4e..0b8755810c42 100644
--- a/sfx2/source/sidebar/FocusManager.cxx
+++ b/sfx2/source/sidebar/FocusManager.cxx
@@ -17,6 +17,7 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
+#include <o3tl/safeint.hxx>
#include <sfx2/sidebar/FocusManager.hxx>
#include <sfx2/sidebar/Deck.hxx>
#include <sfx2/sidebar/Panel.hxx>
@@ -193,7 +194,7 @@ bool FocusManager::IsDeckTitleVisible() const
bool FocusManager::IsPanelTitleVisible (const sal_Int32 nPanelIndex) const
{
- if (nPanelIndex<0 || nPanelIndex>=static_cast<sal_Int32>(maPanels.size()))
+ if (nPanelIndex<0 || o3tl::make_unsigned(nPanelIndex)>=maPanels.size())
return false;
TitleBar* pTitleBar = maPanels[nPanelIndex]->GetTitleBar();
@@ -206,7 +207,7 @@ void FocusManager::FocusPanel (
const sal_Int32 nPanelIndex,
const bool bFallbackToDeckTitle)
{
- if (nPanelIndex<0 || nPanelIndex>=static_cast<sal_Int32>(maPanels.size()))
+ if (nPanelIndex<0 || o3tl::make_unsigned(nPanelIndex)>=maPanels.size())
{
if (bFallbackToDeckTitle)
FocusDeckTitle();
diff --git a/svtools/source/brwbox/brwbox1.cxx b/svtools/source/brwbox/brwbox1.cxx
index 1d4a13f2c725..4eafda7e9ad9 100644
--- a/svtools/source/brwbox/brwbox1.cxx
+++ b/svtools/source/brwbox/brwbox1.cxx
@@ -872,7 +872,7 @@ sal_Int32 BrowseBox::ScrollColumns( sal_Int32 nCols )
{
if ( nFirstCol + nCols < 0 ||
- nFirstCol + nCols >= static_cast<tools::Long>(mvCols.size()) )
+ o3tl::make_unsigned(nFirstCol + nCols) >= mvCols.size() )
return 0;
// implicitly hides cursor while scrolling
diff --git a/svx/source/form/fmshimp.cxx b/svx/source/form/fmshimp.cxx
index a16716ea143d..6e013df3b634 100644
--- a/svx/source/form/fmshimp.cxx
+++ b/svx/source/form/fmshimp.cxx
@@ -2161,7 +2161,7 @@ IMPL_LINK(FmXFormShell, OnFoundData_Lock, FmFoundRecordInformation&, rfriWhere,
if (impl_checkDisposed_Lock())
return;
- DBG_ASSERT((rfriWhere.nContext >= 0) && (rfriWhere.nContext < static_cast<sal_Int16>(m_aSearchForms.size())),
+ DBG_ASSERT((rfriWhere.nContext >= 0) && (o3tl::make_unsigned(rfriWhere.nContext) < m_aSearchForms.size()),
"FmXFormShell::OnFoundData : invalid context!");
Reference< XForm> xForm( m_aSearchForms.at(rfriWhere.nContext));
DBG_ASSERT(xForm.is(), "FmXFormShell::OnFoundData : invalid form!");
@@ -2244,7 +2244,7 @@ IMPL_LINK(FmXFormShell, OnCanceledNotFound_Lock, FmFoundRecordInformation&, rfri
if (impl_checkDisposed_Lock())
return;
- DBG_ASSERT((rfriWhere.nContext >= 0) && (rfriWhere.nContext < static_cast<sal_Int16>(m_aSearchForms.size())),
+ DBG_ASSERT((rfriWhere.nContext >= 0) && (o3tl::make_unsigned(rfriWhere.nContext) < m_aSearchForms.size()),
"FmXFormShell::OnCanceledNotFound : invalid context!");
Reference< XForm> xForm( m_aSearchForms.at(rfriWhere.nContext));
DBG_ASSERT(xForm.is(), "FmXFormShell::OnCanceledNotFound : invalid form!");
diff --git a/svx/source/form/formcontroller.cxx b/svx/source/form/formcontroller.cxx
index c8c68180e605..d38b14d67367 100644
--- a/svx/source/form/formcontroller.cxx
+++ b/svx/source/form/formcontroller.cxx
@@ -1067,7 +1067,7 @@ Any SAL_CALL FormController::getByIndex(sal_Int32 Index)
{
::osl::MutexGuard aGuard( m_aMutex );
if (Index < 0 ||
- Index >= static_cast<sal_Int32>(m_aChildren.size()))
+ o3tl::make_unsigned(Index) >= m_aChildren.size())
throw IndexOutOfBoundsException();
return Any( m_aChildren[ Index ] );
diff --git a/svx/source/table/tablelayouter.hxx b/svx/source/table/tablelayouter.hxx
index e40b7a5862e0..309269bcce52 100644
--- a/svx/source/table/tablelayouter.hxx
+++ b/svx/source/table/tablelayouter.hxx
@@ -23,6 +23,7 @@
#include <sal/types.h>
#include <basegfx/range/b2irectangle.hxx>
#include <basegfx/tuple/b2ituple.hxx>
+#include <o3tl/safeint.hxx>
#include <vector>
#include <svx/svdotable.hxx>
@@ -129,8 +130,8 @@ private:
void LayoutTableWidth( ::tools::Rectangle& rArea, bool bFit );
void LayoutTableHeight( ::tools::Rectangle& rArea, bool bFit );
- bool isValidColumn( sal_Int32 nColumn ) const { return (nColumn >= 0) && (nColumn < static_cast<sal_Int32>( maColumns.size())); }
- bool isValidRow( sal_Int32 nRow ) const { return (nRow >= 0) && (nRow < static_cast<sal_Int32>( maRows.size())); }
+ bool isValidColumn( sal_Int32 nColumn ) const { return (nColumn >= 0) && (o3tl::make_unsigned(nColumn) < maColumns.size()); }
+ bool isValidRow( sal_Int32 nRow ) const { return (nRow >= 0) && (o3tl::make_unsigned(nRow) < maRows.size()); }
bool isValid( const CellPos& rPos ) const { return isValidColumn( rPos.mnCol ) && isValidRow( rPos.mnRow ); }
void ClearBorderLayout();
diff --git a/sw/source/core/access/acctable.cxx b/sw/source/core/access/acctable.cxx
index 49a0520cf499..0fd373754cd4 100644
--- a/sw/source/core/access/acctable.cxx
+++ b/sw/source/core/access/acctable.cxx
@@ -396,8 +396,8 @@ inline Int32Set_Impl::const_iterator SwAccessibleTableData_Impl::GetColumnIter(
void SwAccessibleTableData_Impl::CheckRowAndCol(
sal_Int32 nRow, sal_Int32 nCol, SwAccessibleTable *pThis ) const
{
- if( ( nRow < 0 || nRow >= static_cast< sal_Int32 >( maRows.size() ) ) ||
- ( nCol < 0 || nCol >= static_cast< sal_Int32 >( maColumns.size() ) ) )
+ if( ( nRow < 0 || o3tl::make_unsigned(nRow) >= maRows.size() ) ||
+ ( nCol < 0 || o3tl::make_unsigned(nCol) >= maColumns.size() ) )
{
uno::Reference < XAccessibleTable > xThis( pThis );
lang::IndexOutOfBoundsException aExcept(
diff --git a/sw/source/core/unocore/unostyle.cxx b/sw/source/core/unocore/unostyle.cxx
index 10142d3cde00..c154272188df 100644
--- a/sw/source/core/unocore/unostyle.cxx
+++ b/sw/source/core/unocore/unostyle.cxx
@@ -532,7 +532,7 @@ uno::Any SwXStyleFamilies::getByIndex(sal_Int32 nIndex)
{
auto pEntries(lcl_GetStyleFamilyEntries());
SolarMutexGuard aGuard;
- if(nIndex < 0 || nIndex >= static_cast<sal_Int32>(pEntries->size()))
+ if(nIndex < 0 || o3tl::make_unsigned(nIndex) >= pEntries->size())
throw lang::IndexOutOfBoundsException();
if(!IsValid())
throw uno::RuntimeException();
diff --git a/sw/source/filter/ww8/ww8toolbar.cxx b/sw/source/filter/ww8/ww8toolbar.cxx
index a28d28be559e..af07d077384d 100644
--- a/sw/source/filter/ww8/ww8toolbar.cxx
+++ b/sw/source/filter/ww8/ww8toolbar.cxx
@@ -95,7 +95,7 @@ SwCTBWrapper::~SwCTBWrapper()
Customization* SwCTBWrapper::GetCustomizaton( sal_Int16 index )
{
- if ( index < 0 || index >= static_cast<sal_Int16>( rCustomizations.size() ) )
+ if ( index < 0 || o3tl::make_unsigned(index) >= rCustomizations.size() )
return nullptr;
return &rCustomizations[ index ];
}
diff --git a/sw/source/uibase/uiview/viewmdi.cxx b/sw/source/uibase/uiview/viewmdi.cxx
index 72986fe7d8d6..abbc7438700a 100644
--- a/sw/source/uibase/uiview/viewmdi.cxx
+++ b/sw/source/uibase/uiview/viewmdi.cxx
@@ -21,6 +21,7 @@
#include <sfx2/viewfrm.hxx>
#include <svx/ruler.hxx>
#include <editeng/lrspitem.hxx>
+#include <o3tl/safeint.hxx>
#include <svl/srchitem.hxx>
#include <svl/stritem.hxx>
#include <sfx2/request.hxx>
@@ -513,7 +514,7 @@ IMPL_LINK( SwView, MoveNavigationHdl, void*, p, void )
else
{
s_nActMark--;
- if (s_nActMark < 0 || s_nActMark >= static_cast<sal_Int32>(vNavMarkNames.size()))
+ if (s_nActMark < 0 || o3tl::make_unsigned(s_nActMark) >= vNavMarkNames.size())
{
s_nActMark = vNavMarkNames.size()-1;
SvxSearchDialogWrapper::SetSearchLabel( SearchLabel::ReminderStartWrapped );
diff --git a/sw/source/uibase/uno/unoatxt.cxx b/sw/source/uibase/uno/unoatxt.cxx
index 3804354a7521..e9036718b3c1 100644
--- a/sw/source/uibase/uno/unoatxt.cxx
+++ b/sw/source/uibase/uno/unoatxt.cxx
@@ -486,7 +486,7 @@ uno::Any SwXAutoTextGroup::getByIndex(sal_Int32 nIndex)
if (!pGlosGroup || pGlosGroup->GetError())
throw uno::RuntimeException();
const sal_uInt16 nCount = pGlosGroup->GetCount();
- if (nIndex < 0 || nIndex >= static_cast<sal_Int32>(nCount))
+ if (nIndex < 0 || o3tl::make_unsigned(nIndex) >= nCount)
throw lang::IndexOutOfBoundsException();
return getByName(pGlosGroup->GetShortName(o3tl::narrowing<sal_uInt16>(nIndex)));
}
diff --git a/vbahelper/source/msforms/vbacontrols.cxx b/vbahelper/source/msforms/vbacontrols.cxx
index 503c75311165..a1dc6b6eea8e 100644
--- a/vbahelper/source/msforms/vbacontrols.cxx
+++ b/vbahelper/source/msforms/vbacontrols.cxx
@@ -32,6 +32,7 @@
#include "vbacontrol.hxx"
#include <cppuhelper/exc_hlp.hxx>
#include <cppuhelper/implbase.hxx>
+#include <o3tl/safeint.hxx>
#include <unordered_map>
using namespace com::sun::star;
@@ -135,7 +136,7 @@ public:
virtual uno::Any SAL_CALL getByIndex( ::sal_Int32 Index ) override
{
- if ( Index < 0 || Index >= static_cast< sal_Int32 >( mControls.size() ) )
+ if ( Index < 0 || o3tl::make_unsigned(Index) >= mControls.size() )
throw lang::IndexOutOfBoundsException();
return uno::Any( mControls[ Index ] );
}
diff --git a/vcl/unx/generic/window/salframe.cxx b/vcl/unx/generic/window/salframe.cxx
index 943aa3d527f7..98b68c98ecee 100644
--- a/vcl/unx/generic/window/salframe.cxx
+++ b/vcl/unx/generic/window/salframe.cxx
@@ -52,6 +52,7 @@
#include <sal/macros.h>
#include <sal/log.hxx>
+#include <o3tl/safeint.hxx>
#include <o3tl/string_view.hxx>
#include <com/sun/star/uno/Exception.hpp>
@@ -2128,7 +2129,7 @@ void X11SalFrame::ShowFullScreen( bool bFullScreen, sal_Int32 nScreen )
maRestorePosSize = tools::Rectangle( Point( maGeometry.nX, maGeometry.nY ),
Size( maGeometry.nWidth, maGeometry.nHeight ) );
tools::Rectangle aRect;
- if( nScreen < 0 || nScreen >= static_cast<int>(GetDisplay()->GetXineramaScreens().size()) )
+ if( nScreen < 0 || o3tl::make_unsigned(nScreen) >= GetDisplay()->GetXineramaScreens().size() )
aRect = tools::Rectangle( Point(0,0), GetDisplay()->GetScreenSize( m_nXScreen ) );
else
aRect = GetDisplay()->GetXineramaScreens()[nScreen];
@@ -2171,7 +2172,7 @@ void X11SalFrame::ShowFullScreen( bool bFullScreen, sal_Int32 nScreen )
}
else
{
- if( nScreen < 0 || nScreen >= static_cast<int>(GetDisplay()->GetXScreenCount()) )
+ if( nScreen < 0 || o3tl::make_unsigned(nScreen) >= GetDisplay()->GetXScreenCount() )
nScreen = m_nXScreen.getXScreen();
if( nScreen != static_cast<int>(m_nXScreen.getXScreen()) )
{
diff --git a/vcl/unx/gtk3/a11y/atktextattributes.cxx b/vcl/unx/gtk3/a11y/atktextattributes.cxx
index c127333caf43..25b43f480ab7 100644
--- a/vcl/unx/gtk3/a11y/atktextattributes.cxx
+++ b/vcl/unx/gtk3/a11y/atktextattributes.cxx
@@ -38,6 +38,7 @@
#include <i18nlangtag/languagetag.hxx>
#include <tools/UnitConversion.hxx>
+#include <o3tl/safeint.hxx>
#include <o3tl/string_view.hxx>
#include <stdio.h>
@@ -451,7 +452,7 @@ Strikeout2String(const uno::Any& rAny)
{
sal_Int16 n = rAny.get<sal_Int16>();
- if( n >= 0 && n < sal_Int16(SAL_N_ELEMENTS(font_strikethrough)) )
+ if( n >= 0 && o3tl::make_unsigned(n) < SAL_N_ELEMENTS(font_strikethrough) )
return g_strdup( font_strikethrough[n] );
return nullptr;
diff --git a/vcl/unx/gtk3/glomenu.cxx b/vcl/unx/gtk3/glomenu.cxx
index ca6887cb9d95..a391649bbb6d 100644
--- a/vcl/unx/gtk3/glomenu.cxx
+++ b/vcl/unx/gtk3/glomenu.cxx
@@ -7,6 +7,8 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
+#include <o3tl/safeint.hxx>
+
#include <unx/gtk/glomenu.h>
struct GLOMenu
@@ -109,7 +111,7 @@ gint
g_lo_menu_get_n_items_from_section (GLOMenu *menu,
gint section)
{
- g_return_val_if_fail (0 <= section && section < static_cast<gint>(menu->items->len), 0);
+ g_return_val_if_fail (0 <= section && o3tl::make_unsigned(section) < menu->items->len, 0);
GLOMenu *model = g_lo_menu_get_section (menu, section);
@@ -155,7 +157,7 @@ g_lo_menu_insert_in_section (GLOMenu *menu,
const gchar *label)
{
g_return_if_fail (G_IS_LO_MENU (menu));
- g_return_if_fail (0 <= section && section < static_cast<gint>(menu->items->len));
+ g_return_if_fail (0 <= section && o3tl::make_unsigned(section) < menu->items->len);
GLOMenu *model = g_lo_menu_get_section (menu, section);
@@ -481,7 +483,7 @@ g_lo_menu_set_link (GLOMenu *menu,
g_return_if_fail (link != nullptr);
g_return_if_fail (valid_attribute_name (link));
- if (position < 0 || position >= static_cast<gint>(menu->items->len))
+ if (position < 0 || o3tl::make_unsigned(position) >= menu->items->len)
position = menu->items->len - 1;
struct item menu_item = g_array_index (menu->items, struct item, position);
@@ -500,7 +502,7 @@ g_lo_menu_insert_section (GLOMenu *menu,
{
g_return_if_fail (G_IS_LO_MENU (menu));
- if (position < 0 || position > static_cast<gint>(menu->items->len))
+ if (position < 0 || o3tl::make_unsigned(position) > menu->items->len)
position = menu->items->len;
struct item menu_item;
@@ -543,13 +545,13 @@ g_lo_menu_new_submenu_in_item_in_section (GLOMenu *menu,
gint position)
{
g_return_if_fail (G_IS_LO_MENU (menu));
- g_return_if_fail (0 <= section && section < static_cast<gint>(menu->items->len));
+ g_return_if_fail (0 <= section && o3tl::make_unsigned(section) < menu->items->len);
GLOMenu* model = g_lo_menu_get_section (menu, section);
g_return_if_fail (model != nullptr);
- if (0 <= position && position < static_cast<gint>(model->items->len)) {
+ if (0 <= position && o3tl::make_unsigned(position) < model->items->len) {
GMenuModel* submenu = G_MENU_MODEL (g_lo_menu_new());
g_lo_menu_set_link (model, position, G_MENU_LINK_SUBMENU, submenu);
@@ -568,7 +570,7 @@ g_lo_menu_get_submenu_from_item_in_section (GLOMenu *menu,
gint position)
{
g_return_val_if_fail (G_IS_LO_MENU (menu), nullptr);
- g_return_val_if_fail (0 <= section && section < static_cast<gint>(menu->items->len), nullptr);
+ g_return_val_if_fail (0 <= section && o3tl::make_unsigned(section) < menu->items->len, nullptr);
GLOMenu *model = g_lo_menu_get_section (menu, section);
@@ -576,7 +578,7 @@ g_lo_menu_get_submenu_from_item_in_section (GLOMenu *menu,
GLOMenu *submenu = nullptr;
- if (0 <= position && position < static_cast<gint>(model->items->len))
+ if (0 <= position && o3tl::make_unsigned(position) < model->items->len)
submenu = G_LO_MENU (G_MENU_MODEL_CLASS (g_lo_menu_parent_class)
->get_item_link (G_MENU_MODEL (model), position, G_MENU_LINK_SUBMENU));
//submenu = g_menu_model_get_item_link (G_MENU_MODEL (model), position, G_MENU_LINK_SUBMENU);
@@ -627,7 +629,7 @@ g_lo_menu_remove (GLOMenu *menu,
gint position)
{
g_return_if_fail (G_IS_LO_MENU (menu));
- g_return_if_fail (0 <= position && position < static_cast<gint>(menu->items->len));
+ g_return_if_fail (0 <= position && o3tl::make_unsigned(position) < menu->items->len);
g_lo_menu_clear_item (&g_array_index (menu->items, struct item, position));
g_array_remove_index (menu->items, position);
@@ -640,7 +642,7 @@ g_lo_menu_remove_from_section (GLOMenu *menu,
gint position)
{
g_return_if_fail (G_IS_LO_MENU (menu));
- g_return_if_fail (0 <= section && section < static_cast<gint>(menu->items->len));
+ g_return_if_fail (0 <= section && o3tl::make_unsigned(section) < menu->items->len);
GLOMenu *model = g_lo_menu_get_section (menu, section);
diff --git a/xmloff/source/chart/SchXMLChartContext.cxx b/xmloff/source/chart/SchXMLChartContext.cxx
index fb7deffd2527..23ea2f780041 100644
--- a/xmloff/source/chart/SchXMLChartContext.cxx
+++ b/xmloff/source/chart/SchXMLChartContext.cxx
@@ -57,6 +57,7 @@
#include <com/sun/star/container/XChild.hpp>
#include <com/sun/star/chart2/data/XDataReceiver.hpp>
+#include <o3tl/safeint.hxx>
#include <o3tl/string_view.hxx>
using namespace com::sun::star;
@@ -578,7 +579,7 @@ void lcl_swapPointAndSeriesStylesForDonutCharts( ::std::vector< DataRowPointStyl
sal_Int32 nNewSeriesIndex = aStyle.m_nPointIndex;
sal_Int32 nRepeatCount = aStyle.m_nPointRepeat;
- while( nRepeatCount && (nNewSeriesIndex>=0) && (nNewSeriesIndex< static_cast<sal_Int32>(aNewSeriesVector.size()) ) )
+ while( nRepeatCount && (nNewSeriesIndex>=0) && (o3tl::make_unsigned(nNewSeriesIndex)< aNewSeriesVector.size() ) )
{
NewDonutSeries& rNewSeries( aNewSeriesVector[nNewSeriesIndex] );
rNewSeries.setPointStyleNameToPoint( aStyle.msStyleName, nNewPointIndex );
diff --git a/xmloff/source/style/xmlprmap.cxx b/xmloff/source/style/xmlprmap.cxx
index e6f8cd29ba4c..a2e35b774bd3 100644
--- a/xmloff/source/style/xmlprmap.cxx
+++ b/xmloff/source/style/xmlprmap.cxx
@@ -17,6 +17,7 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
+#include <o3tl/safeint.hxx>
#include <rtl/ref.hxx>
#include <xmloff/xmlprmap.hxx>
@@ -158,32 +159,32 @@ sal_Int32 XMLPropertySetMapper::GetEntryCount() const
sal_uInt32 XMLPropertySetMapper::GetEntryFlags( sal_Int32 nIndex ) const
{
- assert((0 <= nIndex) && (nIndex < static_cast<sal_Int32>(mpImpl->maMapEntries.size())));
+ assert((0 <= nIndex) && (o3tl::make_unsigned(nIndex) < mpImpl->maMapEntries.size()));
return mpImpl->maMapEntries[nIndex].nType & ~MID_FLAG_MASK;
}
sal_uInt32 XMLPropertySetMapper::GetEntryType( sal_Int32 nIndex ) const
{
- assert((0 <= nIndex) && (nIndex < static_cast<sal_Int32>(mpImpl->maMapEntries.size())));
+ assert((0 <= nIndex) && (o3tl::make_unsigned(nIndex) < mpImpl->maMapEntries.size()));
sal_uInt32 nType = mpImpl->maMapEntries[nIndex].nType;
return nType;
}
sal_uInt16 XMLPropertySetMapper::GetEntryNameSpace( sal_Int32 nIndex ) const
{
- assert((0 <= nIndex) && (nIndex < static_cast<sal_Int32>(mpImpl->maMapEntries.size())));
+ assert((0 <= nIndex) && (o3tl::make_unsigned(nIndex) < mpImpl->maMapEntries.size()));
return mpImpl->maMapEntries[nIndex].nXMLNameSpace;
}
const OUString& XMLPropertySetMapper::GetEntryXMLName( sal_Int32 nIndex ) const
{
- assert((0 <= nIndex) && (nIndex < static_cast<sal_Int32>(mpImpl->maMapEntries.size())));
+ assert((0 <= nIndex) && (o3tl::make_unsigned(nIndex) < mpImpl->maMapEntries.size()));
return mpImpl->maMapEntries[nIndex].sXMLAttributeName;
}
const OUString& XMLPropertySetMapper::GetEntryAPIName( sal_Int32 nIndex ) const
{
- assert((0 <= nIndex) && (nIndex < static_cast<sal_Int32>(mpImpl->maMapEntries.size())));
+ assert((0 <= nIndex) && (o3tl::make_unsigned(nIndex) < mpImpl->maMapEntries.size()));
return mpImpl->maMapEntries[nIndex].sAPIPropertyName;
}
@@ -196,13 +197,13 @@ sal_Int16 XMLPropertySetMapper::GetEntryContextId( sal_Int32 nIndex ) const
SvtSaveOptions::ODFSaneDefaultVersion
XMLPropertySetMapper::GetEarliestODFVersionForExport(sal_Int32 const nIndex) const
{
- assert((0 <= nIndex) && (nIndex < static_cast<sal_Int32>(mpImpl->maMapEntries.size())));
+ assert((0 <= nIndex) && (o3tl::make_unsigned(nIndex) < mpImpl->maMapEntries.size()));
return mpImpl->maMapEntries[nIndex].nEarliestODFVersionForExport;
}
const XMLPropertyHandler* XMLPropertySetMapper::GetPropertyHandler( sal_Int32 nIndex ) const
{
- assert((0 <= nIndex) && (nIndex < static_cast<sal_Int32>(mpImpl->maMapEntries.size())));
+ assert((0 <= nIndex) && (o3tl::make_unsigned(nIndex) < mpImpl->maMapEntries.size()));
return mpImpl->maMapEntries[nIndex].pHdl;
}
diff --git a/xmlsecurity/source/gpg/XMLSecurityContext.cxx b/xmlsecurity/source/gpg/XMLSecurityContext.cxx
index 79746d31b637..1fb407113f7a 100644
--- a/xmlsecurity/source/gpg/XMLSecurityContext.cxx
+++ b/xmlsecurity/source/gpg/XMLSecurityContext.cxx
@@ -10,6 +10,7 @@
#include "XMLSecurityContext.hxx"
#include <cppuhelper/supportsservice.hxx>
+#include <o3tl/safeint.hxx>
using namespace css::uno;
using namespace css::lang;
@@ -40,7 +41,7 @@ sal_Int32 SAL_CALL XMLSecurityContextGpg::getSecurityEnvironmentNumber()
Reference<XSecurityEnvironment>
SAL_CALL XMLSecurityContextGpg::getSecurityEnvironmentByIndex(sal_Int32 index)
{
- if (index < 0 || index >= static_cast<sal_Int32>(m_vSecurityEnvironments.size()))
+ if (index < 0 || o3tl::make_unsigned(index) >= m_vSecurityEnvironments.size())
throw RuntimeException("Invalid index");
return m_vSecurityEnvironments[index];
@@ -49,7 +50,7 @@ Reference<XSecurityEnvironment>
Reference<XSecurityEnvironment> SAL_CALL XMLSecurityContextGpg::getSecurityEnvironment()
{
if (m_nDefaultEnvIndex < 0
- || m_nDefaultEnvIndex >= static_cast<sal_Int32>(m_vSecurityEnvironments.size()))
+ || o3tl::make_unsigned(m_nDefaultEnvIndex) >= m_vSecurityEnvironments.size())
throw RuntimeException("Invalid index");
return getSecurityEnvironmentByIndex(m_nDefaultEnvIndex);
diff --git a/xmlsecurity/source/xmlsec/nss/xmlsecuritycontext_nssimpl.cxx b/xmlsecurity/source/xmlsec/nss/xmlsecuritycontext_nssimpl.cxx
index 42d03f2dd81a..9ccf0ab982e6 100644
--- a/xmlsecurity/source/xmlsec/nss/xmlsecuritycontext_nssimpl.cxx
+++ b/xmlsecurity/source/xmlsec/nss/xmlsecuritycontext_nssimpl.cxx
@@ -23,6 +23,7 @@
#include <cppuhelper/supportsservice.hxx>
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <com/sun/star/xml/crypto/XXMLSecurityContext.hpp>
+#include <o3tl/safeint.hxx>
namespace com::sun::star::uno { class XComponentContext; }
@@ -98,7 +99,7 @@ sal_Int32 SAL_CALL XMLSecurityContext_NssImpl::getSecurityEnvironmentNumber( )
uno::Reference< xml::crypto::XSecurityEnvironment > SAL_CALL
XMLSecurityContext_NssImpl::getSecurityEnvironmentByIndex( sal_Int32 index )
{
- if (index < 0 || index >= static_cast<sal_Int32>(m_vSecurityEnvironments.size()))
+ if (index < 0 || o3tl::make_unsigned(index) >= m_vSecurityEnvironments.size())
throw uno::RuntimeException();
uno::Reference< xml::crypto::XSecurityEnvironment > xSecurityEnvironment = m_vSecurityEnvironments[index];
@@ -108,7 +109,7 @@ uno::Reference< xml::crypto::XSecurityEnvironment > SAL_CALL
uno::Reference< xml::crypto::XSecurityEnvironment > SAL_CALL
XMLSecurityContext_NssImpl::getSecurityEnvironment( )
{
- if (m_nDefaultEnvIndex < 0 || m_nDefaultEnvIndex >= static_cast<sal_Int32>(m_vSecurityEnvironments.size()))
+ if (m_nDefaultEnvIndex < 0 || o3tl::make_unsigned(m_nDefaultEnvIndex) >= m_vSecurityEnvironments.size())
throw uno::RuntimeException();
return getSecurityEnvironmentByIndex(m_nDefaultEnvIndex);