summaryrefslogtreecommitdiffstats
path: root/sc
diff options
context:
space:
mode:
Diffstat (limited to 'sc')
-rw-r--r--sc/source/core/data/column.cxx11
-rw-r--r--sc/source/core/data/column2.cxx10
-rw-r--r--sc/source/core/data/column4.cxx9
-rw-r--r--sc/source/core/data/columnspanset.cxx6
-rw-r--r--sc/source/core/data/dociter.cxx3
-rw-r--r--sc/source/core/data/documen2.cxx3
-rw-r--r--sc/source/core/data/document.cxx11
-rw-r--r--sc/source/core/data/documentimport.cxx5
-rw-r--r--sc/source/core/data/dpcache.cxx5
-rw-r--r--sc/source/core/data/dpfilteredcache.cxx4
-rw-r--r--sc/source/core/data/dpoutput.cxx19
-rw-r--r--sc/source/core/data/dptabres.cxx11
-rw-r--r--sc/source/core/data/dptabsrc.cxx5
-rw-r--r--sc/source/core/data/table1.cxx3
-rw-r--r--sc/source/core/data/table2.cxx5
-rw-r--r--sc/source/core/tool/compiler.cxx7
-rw-r--r--sc/source/core/tool/dbdata.cxx3
-rw-r--r--sc/source/core/tool/grouparealistener.cxx3
-rw-r--r--sc/source/core/tool/interpr1.cxx13
-rw-r--r--sc/source/core/tool/interpr4.cxx5
-rw-r--r--sc/source/core/tool/token.cxx3
-rw-r--r--sc/source/filter/excel/excdoc.cxx5
-rw-r--r--sc/source/filter/excel/excform8.cxx4
-rw-r--r--sc/source/filter/excel/impop.cxx3
-rw-r--r--sc/source/filter/excel/xeformula.cxx7
-rw-r--r--sc/source/filter/excel/xepivotxml.cxx3
-rw-r--r--sc/source/filter/excel/xestring.cxx5
-rw-r--r--sc/source/filter/excel/xestyle.cxx3
-rw-r--r--sc/source/filter/excel/xiview.cxx6
-rw-r--r--sc/source/filter/excel/xladdress.cxx5
-rw-r--r--sc/source/filter/oox/externallinkbuffer.cxx3
-rw-r--r--sc/source/filter/oox/formulabuffer.cxx13
-rw-r--r--sc/source/filter/oox/pivotcachebuffer.cxx3
-rw-r--r--sc/source/filter/xml/XMLStylesExportHelper.cxx45
-rw-r--r--sc/source/ui/Accessibility/AccessibleDocument.cxx6
-rw-r--r--sc/source/ui/Accessibility/AccessibleFilterMenu.cxx11
-rw-r--r--sc/source/ui/Accessibility/AccessibleSpreadsheet.cxx5
-rw-r--r--sc/source/ui/condformat/condformathelper.cxx5
-rw-r--r--sc/source/ui/dbgui/consdlg.cxx3
-rw-r--r--sc/source/ui/docshell/docfunc.cxx3
-rw-r--r--sc/source/ui/docshell/externalrefmgr.cxx11
-rw-r--r--sc/source/ui/unoobj/PivotTableDataProvider.cxx7
-rw-r--r--sc/source/ui/unoobj/PivotTableDataSequence.cxx4
-rw-r--r--sc/source/ui/unoobj/cellsuno.cxx5
-rw-r--r--sc/source/ui/unoobj/chart2uno.cxx5
-rw-r--r--sc/source/ui/unoobj/condformatuno.cxx7
-rw-r--r--sc/source/ui/unoobj/docuno.cxx5
-rw-r--r--sc/source/ui/vba/vbawindow.cxx3
-rw-r--r--sc/source/ui/vba/vbawindows.cxx3
-rw-r--r--sc/source/ui/view/viewdata.cxx8
50 files changed, 196 insertions, 144 deletions
diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx
index 5d3cbcbd99e7..36432e9f3358 100644
--- a/sc/source/core/data/column.cxx
+++ b/sc/source/core/data/column.cxx
@@ -49,6 +49,7 @@
#include <svl/sharedstringpool.hxx>
#include <editeng/fieldupdater.hxx>
#include <formula/errorcodes.hxx>
+#include <o3tl/safeint.hxx>
#include <osl/diagnose.h>
#include <map>
@@ -841,11 +842,11 @@ bool ScColumn::TestInsertRow( SCROW nStartRow, SCSIZE nSize ) const
if (it->type == sc::element_type_empty)
nLastNonEmptyRow -= it->size;
- if (nLastNonEmptyRow < static_cast<size_t>(nStartRow))
+ if (nLastNonEmptyRow < o3tl::make_unsigned(nStartRow))
// No cells would get pushed out.
return pAttrArray->TestInsertRow(nSize);
- if (nLastNonEmptyRow + nSize > static_cast<size_t>(GetDoc()->MaxRow()))
+ if (nLastNonEmptyRow + nSize > o3tl::make_unsigned(GetDoc()->MaxRow()))
// At least one cell would get pushed out. Not good.
return false;
@@ -983,7 +984,7 @@ public:
maDestPos.miCellPos = aPos.first;
sc::SharedFormulaUtil::joinFormulaCellAbove(aPos);
size_t nLastRow = nTopRow + nDataSize;
- if (nLastRow < static_cast<size_t>(mrSrcDoc.MaxRow()))
+ if (nLastRow < o3tl::make_unsigned(mrSrcDoc.MaxRow()))
{
aPos = rDestCells.position(maDestPos.miCellPos, nLastRow+1);
sc::SharedFormulaUtil::joinFormulaCellAbove(aPos);
@@ -1069,11 +1070,11 @@ void ScColumn::CopyStaticToDocument(
size_t nDataSize = 0;
size_t nCurRow = nRow1;
- for (; it != maCells.end() && nCurRow <= static_cast<size_t>(nRow2); ++it, nOffset = 0, nCurRow += nDataSize)
+ for (; it != maCells.end() && nCurRow <= o3tl::make_unsigned(nRow2); ++it, nOffset = 0, nCurRow += nDataSize)
{
bool bLastBlock = false;
nDataSize = it->size - nOffset;
- if (nCurRow + nDataSize - 1 > static_cast<size_t>(nRow2))
+ if (nCurRow + nDataSize - 1 > o3tl::make_unsigned(nRow2))
{
// Truncate the block to copy to clipboard.
nDataSize = nRow2 - nCurRow + 1;
diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx
index d3db033b63f2..10e09421fa98 100644
--- a/sc/source/core/data/column2.cxx
+++ b/sc/source/core/data/column2.cxx
@@ -44,7 +44,7 @@
#include <recursionhelper.hxx>
#include <editeng/eeitem.hxx>
-
+#include <o3tl/safeint.hxx>
#include <svx/algitem.hxx>
#include <editeng/editobj.hxx>
#include <editeng/editstat.hxx>
@@ -2710,7 +2710,7 @@ formula::VectorRefArray ScColumn::FetchVectorRefArray( SCROW nRow1, SCROW nRow2
{
case sc::element_type_numeric:
{
- if (static_cast<size_t>(nRow2) < itBlk->size)
+ if (o3tl::make_unsigned(nRow2) < itBlk->size)
{
// Requested range falls within the first block. No need to cache.
const double* p = &sc::numeric_block::at(*itBlk->data, nRow1);
@@ -2757,7 +2757,7 @@ formula::VectorRefArray ScColumn::FetchVectorRefArray( SCROW nRow1, SCROW nRow2
// Failed to insert a new cached column array.
return formula::VectorRefArray();
- if (static_cast<size_t>(nRow2) < itBlk->size)
+ if (o3tl::make_unsigned(nRow2) < itBlk->size)
{
// Requested range falls within the first block.
copyFirstStringBlock(*pDocument, rArray, nRow2+1, itBlk);
@@ -2789,7 +2789,7 @@ formula::VectorRefArray ScColumn::FetchVectorRefArray( SCROW nRow1, SCROW nRow2
break;
case sc::element_type_formula:
{
- if (static_cast<size_t>(nRow2) < itBlk->size)
+ if (o3tl::make_unsigned(nRow2) < itBlk->size)
{
// Requested length is within a single block, and the data is
// not cached.
@@ -2844,7 +2844,7 @@ formula::VectorRefArray ScColumn::FetchVectorRefArray( SCROW nRow1, SCROW nRow2
// Failed to insert a new cached column array.
return formula::VectorRefArray(formula::VectorRefArray::Invalid);
- if (static_cast<size_t>(nRow2) < itBlk->size)
+ if (o3tl::make_unsigned(nRow2) < itBlk->size)
return formula::VectorRefArray(&(*pColArray->mpNumArray)[nRow1]);
// Fill the remaining array with values from the following blocks.
diff --git a/sc/source/core/data/column4.cxx b/sc/source/core/data/column4.cxx
index 6bb39705079b..fed5e01c3e3a 100644
--- a/sc/source/core/data/column4.cxx
+++ b/sc/source/core/data/column4.cxx
@@ -30,6 +30,7 @@
#include <compiler.hxx>
#include <recursionhelper.hxx>
+#include <o3tl/safeint.hxx>
#include <svl/sharedstringpool.hxx>
#include <sal/log.hxx>
#include <tools/stream.hxx>
@@ -728,13 +729,13 @@ public:
sc::cellnote_block::const_iterator it = sc::cellnote_block::begin(*node.data);
sc::cellnote_block::const_iterator itEnd = sc::cellnote_block::end(*node.data);
size_t nOffset = 0;
- if(nTopRow < size_t(mnStartRow))
+ if(nTopRow < o3tl::make_unsigned(mnStartRow))
{
std::advance(it, mnStartRow - nTopRow);
nOffset = mnStartRow - nTopRow;
}
- for (; it != itEnd && nTopRow + nOffset <= size_t(mnEndRow);
+ for (; it != itEnd && nTopRow + nOffset <= o3tl::make_unsigned(mnEndRow);
++it, ++nOffset)
{
ScAddress aPos(mnCol, nTopRow + nOffset, mnTab);
@@ -1336,7 +1337,7 @@ public:
SCROW nBackTrackSize = pFC->aPos.Row() - pFC->GetSharedTopRow();
if (nBackTrackSize > 0)
{
- assert(static_cast<size_t>(nBackTrackSize) <= nOffset);
+ assert(o3tl::make_unsigned(nBackTrackSize) <= nOffset);
for (SCROW i = 0; i < nBackTrackSize; ++i)
--pp;
endListening(mrEndCxt, pp, ppBeg);
@@ -1413,7 +1414,7 @@ public:
SCROW nBackTrackSize = pFC->aPos.Row() - pFC->GetSharedTopRow();
if (nBackTrackSize > 0)
{
- assert(static_cast<size_t>(nBackTrackSize) <= nOffset);
+ assert(o3tl::make_unsigned(nBackTrackSize) <= nOffset);
for (SCROW i = 0; i < nBackTrackSize; ++i)
--pp;
mnStartRow -= nBackTrackSize;
diff --git a/sc/source/core/data/columnspanset.cxx b/sc/source/core/data/columnspanset.cxx
index 849783b5bce5..5d605dc79b2b 100644
--- a/sc/source/core/data/columnspanset.cxx
+++ b/sc/source/core/data/columnspanset.cxx
@@ -19,6 +19,8 @@
#include <algorithm>
#include <memory>
+#include <o3tl/safeint.hxx>
+
namespace sc {
namespace {
@@ -64,14 +66,14 @@ ColumnSpanSet::~ColumnSpanSet()
ColumnSpanSet::ColumnType& ColumnSpanSet::getColumn(const ScDocument& rDoc, SCTAB nTab, SCCOL nCol)
{
- if (static_cast<size_t>(nTab) >= maTables.size())
+ if (o3tl::make_unsigned(nTab) >= maTables.size())
maTables.resize(nTab+1);
if (!maTables[nTab])
maTables[nTab].reset(new TableType);
TableType& rTab = *maTables[nTab];
- if (static_cast<size_t>(nCol) >= rTab.size())
+ if (o3tl::make_unsigned(nCol) >= rTab.size())
rTab.resize(nCol+1);
if (!rTab[nCol])
diff --git a/sc/source/core/data/dociter.cxx b/sc/source/core/data/dociter.cxx
index bad6d64ff7c8..2308a8477e20 100644
--- a/sc/source/core/data/dociter.cxx
+++ b/sc/source/core/data/dociter.cxx
@@ -39,6 +39,7 @@
#include <scmatrix.hxx>
#include <rowheightcontext.hxx>
+#include <o3tl/safeint.hxx>
#include <tools/fract.hxx>
#include <editeng/editobj.hxx>
#include <svl/sharedstring.hxx>
@@ -2229,7 +2230,7 @@ SCROW ScHorizontalCellIterator::FindNextNonEmptyRow()
for (const ColParam& r : maColPositions)
{
- assert(static_cast<size_t>(mnRow) <= r.maPos->position);
+ assert(o3tl::make_unsigned(mnRow) <= r.maPos->position);
nNextRow = std::min (nNextRow, static_cast<size_t>(r.maPos->position));
}
diff --git a/sc/source/core/data/documen2.cxx b/sc/source/core/data/documen2.cxx
index 4b6e7fac9b0f..36b4d2d0556a 100644
--- a/sc/source/core/data/documen2.cxx
+++ b/sc/source/core/data/documen2.cxx
@@ -20,6 +20,7 @@
#include <scextopt.hxx>
#include <autonamecache.hxx>
+#include <o3tl/safeint.hxx>
#include <osl/thread.h>
#include <svx/xtable.hxx>
#include <sfx2/bindings.hxx>
@@ -526,7 +527,7 @@ void ScDocument::ResetClip( ScDocument* pSourceDoc, SCTAB nTab )
void ScDocument::EnsureTable( SCTAB nTab )
{
bool bExtras = !bIsUndo; // Column-Widths, Row-Heights, Flags
- if (static_cast<size_t>(nTab) >= maTabs.size())
+ if (o3tl::make_unsigned(nTab) >= maTabs.size())
maTabs.resize(nTab+1);
if (!maTabs[nTab])
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index 9a36ed567d90..7366d6702a95 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -21,6 +21,7 @@
#include <editeng/boxitem.hxx>
#include <editeng/editobj.hxx>
+#include <o3tl/safeint.hxx>
#include <svx/sdrundomanager.hxx>
#include <svx/svditer.hxx>
#include <sfx2/objsh.hxx>
@@ -1758,7 +1759,7 @@ bool ScDocument::HasPartOfMerged( const ScRange& rRange )
size_t ScDocument::GetFormulaHash( const ScAddress& rPos ) const
{
SCTAB nTab = rPos.Tab();
- if (!ValidTab(nTab) || static_cast<size_t>(nTab) >= maTabs.size() || !maTabs[nTab])
+ if (!ValidTab(nTab) || o3tl::make_unsigned(nTab) >= maTabs.size() || !maTabs[nTab])
return 0;
return maTabs[nTab]->GetFormulaHash(rPos.Col(), rPos.Row());
@@ -1767,7 +1768,7 @@ size_t ScDocument::GetFormulaHash( const ScAddress& rPos ) const
ScFormulaVectorState ScDocument::GetFormulaVectorState( const ScAddress& rPos ) const
{
SCTAB nTab = rPos.Tab();
- if (!ValidTab(nTab) || static_cast<size_t>(nTab) >= maTabs.size() || !maTabs[nTab])
+ if (!ValidTab(nTab) || o3tl::make_unsigned(nTab) >= maTabs.size() || !maTabs[nTab])
return FormulaVectorUnknown;
return maTabs[nTab]->GetFormulaVectorState(rPos.Col(), rPos.Row());
@@ -2500,7 +2501,7 @@ void ScDocument::DumpAreaBroadcasters() const
bool ScDocument::TableExists( SCTAB nTab ) const
{
- return ValidTab(nTab) && static_cast<size_t>(nTab) < maTabs.size() && maTabs[nTab];
+ return ValidTab(nTab) && o3tl::make_unsigned(nTab) < maTabs.size() && maTabs[nTab];
}
ScTable* ScDocument::FetchTable( SCTAB nTab )
@@ -4807,7 +4808,7 @@ void ScDocument::ApplyPatternIfNumberformatIncompatible( const ScRange& rRange,
void ScDocument::AddCondFormatData( const ScRangeList& rRange, SCTAB nTab, sal_uInt32 nIndex )
{
- if(static_cast<size_t>(nTab) >= maTabs.size())
+ if(o3tl::make_unsigned(nTab) >= maTabs.size())
return;
if(!maTabs[nTab])
@@ -4818,7 +4819,7 @@ void ScDocument::AddCondFormatData( const ScRangeList& rRange, SCTAB nTab, sal_u
void ScDocument::RemoveCondFormatData( const ScRangeList& rRange, SCTAB nTab, sal_uInt32 nIndex )
{
- if(static_cast<size_t>(nTab) >= maTabs.size())
+ if(o3tl::make_unsigned(nTab) >= maTabs.size())
return;
if(!maTabs[nTab])
diff --git a/sc/source/core/data/documentimport.cxx b/sc/source/core/data/documentimport.cxx
index 2fd7f744d34c..83429a587a9e 100644
--- a/sc/source/core/data/documentimport.cxx
+++ b/sc/source/core/data/documentimport.cxx
@@ -24,6 +24,7 @@
#include <bcaslot.hxx>
#include <scopetools.hxx>
+#include <o3tl/safeint.hxx>
#include <svl/sharedstringpool.hxx>
#include <svl/languageoptions.hxx>
#include <unotools/configmgr.hxx>
@@ -59,7 +60,7 @@ struct ScDocumentImportImpl
bool isValid( size_t nTab, size_t nCol )
{
- return (nTab <= size_t(MAXTAB) && nCol <= size_t(mrDoc.MaxCol()));
+ return (nTab <= o3tl::make_unsigned(MAXTAB) && nCol <= o3tl::make_unsigned(mrDoc.MaxCol()));
}
ColAttr* getColAttr( size_t nTab, size_t nCol )
@@ -82,7 +83,7 @@ struct ScDocumentImportImpl
if (!isValid(nTab, nCol))
return nullptr;
- if (size_t(nTab) >= maBlockPosSet.size())
+ if (o3tl::make_unsigned(nTab) >= maBlockPosSet.size())
{
for (SCTAB i = maBlockPosSet.size(); i <= nTab; ++i)
maBlockPosSet.emplace_back(mrDoc, i);
diff --git a/sc/source/core/data/dpcache.cxx b/sc/source/core/data/dpcache.cxx
index d86ab2a300be..60b8a2f87d24 100644
--- a/sc/source/core/data/dpcache.cxx
+++ b/sc/source/core/data/dpcache.cxx
@@ -39,6 +39,7 @@
#include <unotools/localedatawrapper.hxx>
#include <unotools/collatorwrapper.hxx>
#include <svl/zforlist.hxx>
+#include <o3tl/safeint.hxx>
#include <osl/diagnose.h>
#if DUMP_PIVOT_TABLE
@@ -962,7 +963,7 @@ SCROW ScDPCache::GetItemDataId(sal_uInt16 nDim, SCROW nRow, bool bRepeatIfEmpty)
OSL_ENSURE(nDim < mnColumnCount, "ScDPTableDataCache::GetItemDataId ");
const Field& rField = *maFields[nDim];
- if (static_cast<size_t>(nRow) >= rField.maData.size())
+ if (o3tl::make_unsigned(nRow) >= rField.maData.size())
{
// nRow is in the trailing empty rows area.
if (bRepeatIfEmpty)
@@ -1151,7 +1152,7 @@ SCROW ScDPCache::GetIdByItemData(long nDim, const ScDPItemData& rItem) const
// group field.
nDim -= mnColumnCount;
- if (static_cast<size_t>(nDim) < maGroupFields.size())
+ if (o3tl::make_unsigned(nDim) < maGroupFields.size())
{
const ScDPItemDataVec& rGI = maGroupFields[nDim]->maItems;
for (size_t i = 0, n = rGI.size(); i < n; ++i)
diff --git a/sc/source/core/data/dpfilteredcache.cxx b/sc/source/core/data/dpfilteredcache.cxx
index a0fce6afdbbc..a95144ee5f9a 100644
--- a/sc/source/core/data/dpfilteredcache.cxx
+++ b/sc/source/core/data/dpfilteredcache.cxx
@@ -23,7 +23,7 @@
#include <queryparam.hxx>
#include <dpitemdata.hxx>
#include <com/sun/star/uno/Sequence.hxx>
-
+#include <o3tl/safeint.hxx>
#include <osl/diagnose.h>
#include <algorithm>
@@ -281,7 +281,7 @@ OUString ScDPFilteredCache::getFieldName(SCCOL nIndex) const
const ::std::vector<SCROW>& ScDPFilteredCache::getFieldEntries( sal_Int32 nColumn ) const
{
- if (nColumn < 0 || static_cast<size_t>(nColumn) >= maFieldEntries.size())
+ if (nColumn < 0 || o3tl::make_unsigned(nColumn) >= maFieldEntries.size())
{
// index out of bound. Hopefully this code will never be reached.
static const ::std::vector<SCROW> emptyEntries{};
diff --git a/sc/source/core/data/dpoutput.cxx b/sc/source/core/data/dpoutput.cxx
index 60b423aec6c6..e0636a38d136 100644
--- a/sc/source/core/data/dpoutput.cxx
+++ b/sc/source/core/data/dpoutput.cxx
@@ -22,6 +22,7 @@
#include <editeng/boxitem.hxx>
#include <editeng/wghtitem.hxx>
#include <editeng/justifyitem.hxx>
+#include <o3tl/safeint.hxx>
#include <osl/diagnose.h>
#include <svl/itemset.hxx>
@@ -1559,7 +1560,7 @@ long ScDPOutput::GetHeaderDim( const ScAddress& rPos, sheet::DataPilotFieldOrien
// test for column header
- if ( nRow == nTabStartRow && nCol >= nDataStartCol && static_cast<size_t>(nCol) < nDataStartCol + pColFields.size())
+ if ( nRow == nTabStartRow && nCol >= nDataStartCol && o3tl::make_unsigned(nCol) < nDataStartCol + pColFields.size())
{
rOrient = sheet::DataPilotFieldOrientation_COLUMN;
long nField = nCol - nDataStartCol;
@@ -1568,7 +1569,7 @@ long ScDPOutput::GetHeaderDim( const ScAddress& rPos, sheet::DataPilotFieldOrien
// test for row header
- if ( nRow+1 == nDataStartRow && nCol >= nTabStartCol && static_cast<size_t>(nCol) < nTabStartCol + pRowFields.size() )
+ if ( nRow+1 == nDataStartRow && nCol >= nTabStartCol && o3tl::make_unsigned(nCol) < nTabStartCol + pRowFields.size() )
{
rOrient = sheet::DataPilotFieldOrientation_ROW;
long nField = nCol - nTabStartCol;
@@ -1578,7 +1579,7 @@ long ScDPOutput::GetHeaderDim( const ScAddress& rPos, sheet::DataPilotFieldOrien
// test for page field
SCROW nPageStartRow = aStartPos.Row() + ( bDoFilter ? 1 : 0 );
- if ( nCol == aStartPos.Col() && nRow >= nPageStartRow && static_cast<size_t>(nRow) < nPageStartRow + pPageFields.size() )
+ if ( nCol == aStartPos.Col() && nRow >= nPageStartRow && o3tl::make_unsigned(nRow) < nPageStartRow + pPageFields.size() )
{
rOrient = sheet::DataPilotFieldOrientation_PAGE;
long nField = nRow - nPageStartRow;
@@ -1610,7 +1611,7 @@ bool ScDPOutput::GetHeaderDrag( const ScAddress& rPos, bool bMouseLeft, bool bMo
// test for column header
if ( nCol >= nDataStartCol && nCol <= nTabEndCol &&
- nRow + 1 >= nMemberStartRow && static_cast<size_t>(nRow) < nMemberStartRow + pColFields.size())
+ nRow + 1 >= nMemberStartRow && o3tl::make_unsigned(nRow) < nMemberStartRow + pColFields.size())
{
long nField = nRow - nMemberStartRow;
if (nField < 0)
@@ -1626,7 +1627,7 @@ bool ScDPOutput::GetHeaderDrag( const ScAddress& rPos, bool bMouseLeft, bool bMo
bool bFound = false; // is this within the same orientation?
bool bBeforeDrag = false;
bool bAfterDrag = false;
- for (long nPos=0; static_cast<size_t>(nPos)<pColFields.size() && !bFound; nPos++)
+ for (long nPos=0; o3tl::make_unsigned(nPos)<pColFields.size() && !bFound; nPos++)
{
if (pColFields[nPos].mnDim == nDragDim)
{
@@ -1669,7 +1670,7 @@ bool ScDPOutput::GetHeaderDrag( const ScAddress& rPos, bool bMouseLeft, bool bMo
pRowFields.empty() && nCol == nTabStartCol && bMouseLeft );
if ( bSpecial || ( nRow+1 >= nDataStartRow && nRow <= nTabEndRow &&
- nCol + 1 >= nTabStartCol && static_cast<size_t>(nCol) < nTabStartCol + pRowFields.size() ) )
+ nCol + 1 >= nTabStartCol && o3tl::make_unsigned(nCol) < nTabStartCol + pRowFields.size() ) )
{
long nField = nCol - nTabStartCol;
//TODO: find start of dimension
@@ -1680,7 +1681,7 @@ bool ScDPOutput::GetHeaderDrag( const ScAddress& rPos, bool bMouseLeft, bool bMo
bool bFound = false; // is this within the same orientation?
bool bBeforeDrag = false;
bool bAfterDrag = false;
- for (long nPos=0; static_cast<size_t>(nPos)<pRowFields.size() && !bFound; nPos++)
+ for (long nPos=0; o3tl::make_unsigned(nPos)<pRowFields.size() && !bFound; nPos++)
{
if (pRowFields[nPos].mnDim == nDragDim)
{
@@ -1720,7 +1721,7 @@ bool ScDPOutput::GetHeaderDrag( const ScAddress& rPos, bool bMouseLeft, bool bMo
SCROW nPageStartRow = aStartPos.Row() + ( bDoFilter ? 1 : 0 );
if ( nCol >= aStartPos.Col() && nCol <= nTabEndCol &&
- nRow + 1 >= nPageStartRow && static_cast<size_t>(nRow) < nPageStartRow + pPageFields.size() )
+ nRow + 1 >= nPageStartRow && o3tl::make_unsigned(nRow) < nPageStartRow + pPageFields.size() )
{
long nField = nRow - nPageStartRow;
if (nField < 0)
@@ -1736,7 +1737,7 @@ bool ScDPOutput::GetHeaderDrag( const ScAddress& rPos, bool bMouseLeft, bool bMo
bool bFound = false; // is this within the same orientation?
bool bBeforeDrag = false;
bool bAfterDrag = false;
- for (long nPos=0; static_cast<size_t>(nPos)<pPageFields.size() && !bFound; nPos++)
+ for (long nPos=0; o3tl::make_unsigned(nPos)<pPageFields.size() && !bFound; nPos++)
{
if (pPageFields[nPos].mnDim == nDragDim)
{
diff --git a/sc/source/core/data/dptabres.cxx b/sc/source/core/data/dptabres.cxx
index b535d5cdc08e..db117a13f638 100644
--- a/sc/source/core/data/dptabres.cxx
+++ b/sc/source/core/data/dptabres.cxx
@@ -32,6 +32,7 @@
#include <dpresfilter.hxx>
#include <dputil.hxx>
+#include <o3tl/safeint.hxx>
#include <osl/diagnose.h>
#include <rtl/math.hxx>
#include <sal/log.hxx>
@@ -819,19 +820,19 @@ long ScDPResultData::GetRowStartMeasure() const
ScSubTotalFunc ScDPResultData::GetMeasureFunction(long nMeasure) const
{
- OSL_ENSURE(static_cast<size_t>(nMeasure) < maMeasureFuncs.size(), "bumm");
+ OSL_ENSURE(o3tl::make_unsigned(nMeasure) < maMeasureFuncs.size(), "bumm");
return maMeasureFuncs[nMeasure];
}
const sheet::DataPilotFieldReference& ScDPResultData::GetMeasureRefVal(long nMeasure) const
{
- OSL_ENSURE(static_cast<size_t>(nMeasure) < maMeasureRefs.size(), "bumm");
+ OSL_ENSURE(o3tl::make_unsigned(nMeasure) < maMeasureRefs.size(), "bumm");
return maMeasureRefs[nMeasure];
}
sheet::DataPilotFieldOrientation ScDPResultData::GetMeasureRefOrient(long nMeasure) const
{
- OSL_ENSURE(static_cast<size_t>(nMeasure) < maMeasureRefOrients.size(), "bumm");
+ OSL_ENSURE(o3tl::make_unsigned(nMeasure) < maMeasureRefOrients.size(), "bumm");
return maMeasureRefOrients[nMeasure];
}
@@ -853,7 +854,7 @@ OUString ScDPResultData::GetMeasureString(long nMeasure, bool bForce, ScSubTotal
}
else
{
- OSL_ENSURE(static_cast<size_t>(nMeasure) < maMeasureFuncs.size(), "bumm");
+ OSL_ENSURE(o3tl::make_unsigned(nMeasure) < maMeasureFuncs.size(), "bumm");
const ScDPDimension* pDataDim = mrSource.GetDataDimension(nMeasure);
if (pDataDim)
{
@@ -3938,7 +3939,7 @@ void ScDPResultVisibilityData::fillFieldFilters(vector<ScDPFilteredCache::Criter
ScDPDimension* pDim = pDims->getByIndex(nDimIndex);
ScDPMembers* pMembers = pDim->GetHierarchiesObject()->getByIndex(0)->
GetLevelsObject()->getByIndex(0)->GetMembersObject();
- if (pGrpFilter->getMatchItemCount() < static_cast<size_t>(pMembers->getCount()))
+ if (pGrpFilter->getMatchItemCount() < o3tl::make_unsigned(pMembers->getCount()))
rFilters.push_back(aCri);
}
}
diff --git a/sc/source/core/data/dptabsrc.cxx b/sc/source/core/data/dptabsrc.cxx
index e8bbd3c91c19..bfc89049a708 100644
--- a/sc/source/core/data/dptabsrc.cxx
+++ b/sc/source/core/data/dptabsrc.cxx
@@ -26,6 +26,7 @@
#include <comphelper/sequence.hxx>
#include <o3tl/any.hxx>
+#include <o3tl/safeint.hxx>
#include <osl/diagnose.h>
#include <rtl/math.hxx>
#include <sal/log.hxx>
@@ -139,7 +140,7 @@ long ScDPSource::GetDataDimensionCount() const
ScDPDimension* ScDPSource::GetDataDimension(long nIndex)
{
- if (nIndex < 0 || static_cast<size_t>(nIndex) >= maDataDims.size())
+ if (nIndex < 0 || o3tl::make_unsigned(nIndex) >= maDataDims.size())
return nullptr;
long nDimIndex = maDataDims[nIndex];
@@ -708,7 +709,7 @@ void ScDPSource::FilterCacheByPageDimensions()
pGrpFilter->addMatchItem(aData);
}
}
- if (pGrpFilter->getMatchItemCount() < static_cast<size_t>(nMemCount))
+ if (pGrpFilter->getMatchItemCount() < o3tl::make_unsigned(nMemCount))
// there is at least one invisible item. Add this filter criterion to the mix.
aCriteria.push_back(aFilter);
diff --git a/sc/source/core/data/table1.cxx b/sc/source/core/data/table1.cxx
index 583982ed5f2c..7b6f1f771eb8 100644
--- a/sc/source/core/data/table1.cxx
+++ b/sc/source/core/data/table1.cxx
@@ -19,6 +19,7 @@
#include <scitems.hxx>
#include <editeng/justifyitem.hxx>
+#include <o3tl/safeint.hxx>
#include <unotools/textsearch.hxx>
#include <unotools/charclass.hxx>
@@ -167,7 +168,7 @@ bool SetOptimalHeightsToRows(
SCROW nRngEnd = 0;
sal_uInt16 nLast = 0;
sal_uInt16 nExtraHeight = rCxt.getExtraHeight();
- for (SCSIZE i = nStartRow; i <= static_cast<SCSIZE>(nEndRow); i++)
+ for (SCSIZE i = nStartRow; i <= o3tl::make_unsigned(nEndRow); i++)
{
size_t nIndex;
SCROW nRegionEndRow;
diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx
index f24a3459a803..cb0aabf72628 100644
--- a/sc/source/core/data/table2.cxx
+++ b/sc/source/core/data/table2.cxx
@@ -56,6 +56,7 @@
#include <scitems.hxx>
#include <editeng/boxitem.hxx>
#include <editeng/editobj.hxx>
+#include <o3tl/safeint.hxx>
#include <svl/poolcach.hxx>
#include <unotools/charclass.hxx>
#include <math.h>
@@ -249,7 +250,7 @@ void ScTable::DeleteRow(
bool ScTable::TestInsertCol( SCROW nStartRow, SCROW nEndRow, SCSIZE nSize ) const
{
- if ( nSize > static_cast<SCSIZE>(pDocument->MaxCol()) )
+ if ( nSize > o3tl::make_unsigned(pDocument->MaxCol()) )
return false;
if ( nStartRow==0 && nEndRow==pDocument->MaxRow() && pOutlineTable
@@ -348,7 +349,7 @@ void ScTable::DeleteCol(
{
if (mpColWidth && mpColFlags)
{
- assert( nStartCol + nSize <= size_t(pDocument->MaxCol()+1) ); // moving 0 if ==pDocument->MaxCol()+1 is correct
+ assert( nStartCol + nSize <= o3tl::make_unsigned(pDocument->MaxCol()+1) ); // moving 0 if ==pDocument->MaxCol()+1 is correct
mpColWidth->RemovePreservingSize(nStartCol, nSize, STD_COL_WIDTH);
mpColFlags->RemovePreservingSize(nStartCol, nSize, CRFlags::NONE);
}
diff --git a/sc/source/core/tool/compiler.cxx b/sc/source/core/tool/compiler.cxx
index 66ce3d569f91..b7e2a1f60f4b 100644
--- a/sc/source/core/tool/compiler.cxx
+++ b/sc/source/core/tool/compiler.cxx
@@ -30,6 +30,7 @@
#include <svl/sharedstringpool.hxx>
#include <sal/macros.h>
#include <sal/log.hxx>
+#include <o3tl/safeint.hxx>
#include <osl/diagnose.h>
#include <rtl/character.hxx>
#include <tools/solar.h>
@@ -766,7 +767,7 @@ struct ConventionOOO_A1 : public Convention_A1
static void MakeTabStr( OUStringBuffer &rBuf, const std::vector<OUString>& rTabNames, SCTAB nTab )
{
- if (static_cast<size_t>(nTab) >= rTabNames.size())
+ if (o3tl::make_unsigned(nTab) >= rTabNames.size())
rBuf.append(ScResId(STR_NO_REF_TABLE));
else
rBuf.append(rTabNames[nTab]);
@@ -1102,7 +1103,7 @@ struct ConventionXL
const ScSingleRefData& rRef, OUString& rTabName )
{
ScAddress aAbs = rRef.toAbs(rLimits, rPos);
- if (rRef.IsTabDeleted() || static_cast<size_t>(aAbs.Tab()) >= rTabNames.size())
+ if (rRef.IsTabDeleted() || o3tl::make_unsigned(aAbs.Tab()) >= rTabNames.size())
{
rTabName = ScResId( STR_NO_REF_TABLE );
return;
@@ -4507,7 +4508,7 @@ std::unique_ptr<ScTokenArray> ScCompiler::CompileString( const OUString& rFormul
bool bUseFunctionStack = (bPODF || bOOXML);
const size_t nAlloc = 512;
FunctionStack aFuncs[ nAlloc ];
- FunctionStack* pFunctionStack = (bUseFunctionStack && static_cast<size_t>(rFormula.getLength()) > nAlloc ?
+ FunctionStack* pFunctionStack = (bUseFunctionStack && o3tl::make_unsigned(rFormula.getLength()) > nAlloc ?
new FunctionStack[rFormula.getLength()] : &aFuncs[0]);
pFunctionStack[0].eOp = ocNone;
pFunctionStack[0].nSep = 0;
diff --git a/sc/source/core/tool/dbdata.cxx b/sc/source/core/tool/dbdata.cxx
index 8e77f5410dc4..80476b494fa9 100644
--- a/sc/source/core/tool/dbdata.cxx
+++ b/sc/source/core/tool/dbdata.cxx
@@ -20,6 +20,7 @@
#include <sal/config.h>
#include <sal/log.hxx>
+#include <o3tl/safeint.hxx>
#include <unotools/transliterationwrapper.hxx>
#include <unotools/charclass.hxx>
@@ -884,7 +885,7 @@ const OUString& ScDBData::GetTableColumnName( SCCOL nCol ) const
return EMPTY_OUSTRING;
SCCOL nOffset = nCol - nStartCol;
- if (nOffset < 0 || maTableColumnNames.size() <= static_cast<size_t>(nOffset))
+ if (nOffset < 0 || maTableColumnNames.size() <= o3tl::make_unsigned(nOffset))
return EMPTY_OUSTRING;
return maTableColumnNames[nOffset];
diff --git a/sc/source/core/tool/grouparealistener.cxx b/sc/source/core/tool/grouparealistener.cxx
index acbace1c4300..fa234fbcc1c1 100644
--- a/sc/source/core/tool/grouparealistener.cxx
+++ b/sc/source/core/tool/grouparealistener.cxx
@@ -18,6 +18,7 @@
#include <document.hxx>
#include <table.hxx>
+#include <o3tl/safeint.hxx>
#include <sal/log.hxx>
namespace sc {
@@ -230,7 +231,7 @@ void FormulaGroupAreaListener::collectFormulaCells(
* the content of a shifted column. Effectively this workaround has the
* consequence that the group area listener is fouled up and not all
* formula cells are notified... */
- if (nBlockSize < static_cast<size_t>(mnGroupLen))
+ if (nBlockSize < o3tl::make_unsigned(mnGroupLen))
{
SAL_WARN("sc.core","FormulaGroupAreaListener::collectFormulaCells() nBlockSize " <<
nBlockSize << " < " << mnGroupLen << " mnGroupLen");
diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx
index b6fa53b43528..89e7b39786cf 100644
--- a/sc/source/core/tool/interpr1.cxx
+++ b/sc/source/core/tool/interpr1.cxx
@@ -22,6 +22,7 @@
#include <scitems.hxx>
#include <editeng/langitem.hxx>
#include <editeng/justifyitem.hxx>
+#include <o3tl/safeint.hxx>
#include <osl/thread.h>
#include <svx/algitem.hxx>
#include <unotools/textsearch.hxx>
@@ -655,9 +656,9 @@ bool ScInterpreter::JumpMatrix( short nStackLevel )
ScAddress aAdr( aRange.aStart);
sal_uLong nCol = static_cast<sal_uLong>(aAdr.Col()) + nC;
sal_uLong nRow = static_cast<sal_uLong>(aAdr.Row()) + nR;
- if ((nCol > static_cast<sal_uLong>(aRange.aEnd.Col()) &&
+ if ((nCol > o3tl::make_unsigned(aRange.aEnd.Col()) &&
aRange.aEnd.Col() != aRange.aStart.Col())
- || (nRow > static_cast<sal_uLong>(aRange.aEnd.Row()) &&
+ || (nRow > o3tl::make_unsigned(aRange.aEnd.Row()) &&
aRange.aEnd.Row() != aRange.aStart.Row()))
{
fVal = CreateDoubleError( FormulaError::NotAvailable );
@@ -6974,7 +6975,7 @@ void ScInterpreter::ScLookup()
VectorMatrixAccessor aMatAcc(*pDataMat, bVertical);
SCCOLROW i = nDelta;
SCSIZE n = aMatAcc.GetElementCount();
- if (static_cast<SCSIZE>(i) >= n)
+ if (o3tl::make_unsigned(i) >= n)
i = static_cast<SCCOLROW>(n);
bool bByString = rEntry.GetQueryItem().meType == ScQueryEntry::ByString;
if (bByString == aMatAcc.IsValue(i))
@@ -6993,7 +6994,7 @@ void ScInterpreter::ScLookup()
{
VectorMatrixAccessor aResMatAcc(*pResMat, bVertical);
// result array is matrix.
- if (static_cast<SCSIZE>(nDelta) >= aResMatAcc.GetElementCount())
+ if (o3tl::make_unsigned(nDelta) >= aResMatAcc.GetElementCount())
{
PushNA();
return;
@@ -8532,8 +8533,8 @@ void ScInterpreter::ScIndex()
SCSIZE nElement = ::std::max( static_cast<SCSIZE>(nCol),
static_cast<SCSIZE>(nRow));
if (nC == 0 || nR == 0 ||
- (!bVector && (static_cast<SCSIZE>(nCol) > nC ||
- static_cast<SCSIZE>(nRow) > nR)) ||
+ (!bVector && (o3tl::make_unsigned(nCol) > nC ||
+ o3tl::make_unsigned(nRow) > nR)) ||
(bVector && nElement > nC * nR))
PushIllegalArgument();
else if (nCol == 0 && nRow == 0)
diff --git a/sc/source/core/tool/interpr4.cxx b/sc/source/core/tool/interpr4.cxx
index b1a3658961ce..7716a973fd6e 100644
--- a/sc/source/core/tool/interpr4.cxx
+++ b/sc/source/core/tool/interpr4.cxx
@@ -22,6 +22,7 @@
#include <interpre.hxx>
#include <rangelst.hxx>
+#include <o3tl/safeint.hxx>
#include <rtl/math.hxx>
#include <sfx2/app.hxx>
#include <sfx2/docfile.hxx>
@@ -1509,9 +1510,9 @@ bool ScInterpreter::ConvertMatrixParameters()
{
if ( eType == formula::ParamClass::Value )
{ // only if single value expected
- if ( nJumpCols < static_cast<SCSIZE>(nCol2 - nCol1 + 1) )
+ if ( nJumpCols < o3tl::make_unsigned(nCol2 - nCol1 + 1) )
nJumpCols = static_cast<SCSIZE>(nCol2 - nCol1 + 1);
- if ( nJumpRows < static_cast<SCSIZE>(nRow2 - nRow1 + 1) )
+ if ( nJumpRows < o3tl::make_unsigned(nRow2 - nRow1 + 1) )
nJumpRows = static_cast<SCSIZE>(nRow2 - nRow1 + 1);
}
formula::FormulaToken* pNew = new ScMatrixToken( pMat);
diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx
index 1070fca89e23..99775f5de4b6 100644
--- a/sc/source/core/tool/token.cxx
+++ b/sc/source/core/tool/token.cxx
@@ -61,6 +61,7 @@ using ::std::vector;
#include <com/sun/star/sheet/ReferenceFlags.hpp>
#include <com/sun/star/sheet/NameToken.hpp>
#include <utility>
+#include <o3tl/safeint.hxx>
#include <o3tl/sorted_vector.hxx>
using namespace formula;
@@ -4990,7 +4991,7 @@ void appendTokenByType( ScSheetLimits& rLimits, sc::TokenStringContext& rCxt, OU
{
// On other sheet.
OUString aName;
- if (static_cast<size_t>(nTab) < rCxt.maTabNames.size())
+ if (o3tl::make_unsigned(nTab) < rCxt.maTabNames.size())
aName = rCxt.maTabNames[nTab];
if (!aName.isEmpty())
{
diff --git a/sc/source/filter/excel/excdoc.cxx b/sc/source/filter/excel/excdoc.cxx
index ca21fe210da5..e21164f43632 100644
--- a/sc/source/filter/excel/excdoc.cxx
+++ b/sc/source/filter/excel/excdoc.cxx
@@ -48,6 +48,7 @@
#include <xltools.hxx>
#include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
+#include <o3tl/safeint.hxx>
#include <oox/token/tokens.hxx>
#include <oox/token/namespaces.hxx>
#include <memory>
@@ -410,7 +411,7 @@ void ExcTable::FillAsTableBinary( SCTAB nCodeNameIdx )
ScDocument& rDoc = GetDoc();
OSL_ENSURE( (mnScTab >= 0) && (mnScTab <= MAXTAB), "-ExcTable::Table(): mnScTab - no ordinary table!" );
- OSL_ENSURE( nExcTab <= static_cast<sal_uInt16>(MAXTAB), "-ExcTable::Table(): nExcTab - no ordinary table!" );
+ OSL_ENSURE( nExcTab <= o3tl::make_unsigned(MAXTAB), "-ExcTable::Table(): nExcTab - no ordinary table!" );
// create a new OBJ list for this sheet (may be used by notes, autofilter, data validation)
if( eBiff == EXC_BIFF8 )
@@ -552,7 +553,7 @@ void ExcTable::FillAsTableXml()
ScDocument& rDoc = GetDoc();
OSL_ENSURE( (mnScTab >= 0) && (mnScTab <= MAXTAB), "-ExcTable::Table(): mnScTab - no ordinary table!" );
- OSL_ENSURE( nExcTab <= static_cast<sal_uInt16>(MAXTAB), "-ExcTable::Table(): nExcTab - no ordinary table!" );
+ OSL_ENSURE( nExcTab <= o3tl::make_unsigned(MAXTAB), "-ExcTable::Table(): nExcTab - no ordinary table!" );
// create a new OBJ list for this sheet (may be used by notes, autofilter, data validation)
GetObjectManager().StartSheet();
diff --git a/sc/source/filter/excel/excform8.cxx b/sc/source/filter/excel/excform8.cxx
index 4d53dbce4f29..a16dbe60a0f7 100644
--- a/sc/source/filter/excel/excform8.cxx
+++ b/sc/source/filter/excel/excform8.cxx
@@ -31,6 +31,8 @@
#include <cstring>
+#include <o3tl/safeint.hxx>
+
using ::std::vector;
namespace {
@@ -53,7 +55,7 @@ bool extractFilePath(const OUString& rUrl, OUString& rPath)
OUStringBuffer aBuf;
const sal_Unicode* p = rUrl.getStr();
- for (size_t i = 0; i < static_cast<size_t>(n); ++i, ++p)
+ for (size_t i = 0; i < o3tl::make_unsigned(n); ++i, ++p)
{
if (i < nPrefixLen)
{
diff --git a/sc/source/filter/excel/impop.cxx b/sc/source/filter/excel/impop.cxx
index e200dc2aea89..9f94d7b536af 100644
--- a/sc/source/filter/excel/impop.cxx
+++ b/sc/source/filter/excel/impop.cxx
@@ -24,6 +24,7 @@
#include <scitems.hxx>
+#include <o3tl/safeint.hxx>
#include <sfx2/docfile.hxx>
#include <svx/svxids.hrc>
#include <svl/zforlist.hxx>
@@ -246,7 +247,7 @@ void ImportExcel::ReadDimensions()
aXclUsedArea.maFirst.mnCol = maStrm.ReaduInt16();
aXclUsedArea.maLast.mnCol = maStrm.ReaduInt16();
if( (nXclRow1 < nXclRow2) && (aXclUsedArea.GetColCount() > 1) &&
- (nXclRow1 <= static_cast< sal_uInt32 >( GetScMaxPos().Row() )) )
+ (nXclRow1 <= o3tl::make_unsigned( GetScMaxPos().Row() )) )
{
// Excel stores first unused row/column index
--nXclRow2;
diff --git a/sc/source/filter/excel/xeformula.cxx b/sc/source/filter/excel/xeformula.cxx
index f6cf9a2f53b3..9990155ea2e0 100644
--- a/sc/source/filter/excel/xeformula.cxx
+++ b/sc/source/filter/excel/xeformula.cxx
@@ -32,6 +32,7 @@
#include <xestring.hxx>
#include <xllink.hxx>
#include <xltools.hxx>
+#include <o3tl/safeint.hxx>
#include <sal/log.hxx>
#include <basegfx/numeric/ftools.hxx>
@@ -197,7 +198,7 @@ void XclExpFuncData::IncParamInfoIdx()
if( mpParamInfo )
{
// move pointer to next entry, if something explicit follows
- if( (static_cast< size_t >( mpParamInfo - mrFuncInfo.mpParamInfos + 1 ) < EXC_FUNCINFO_PARAMINFO_COUNT) && (mpParamInfo[ 1 ].meValid != EXC_PARAM_NONE) )
+ if( (o3tl::make_unsigned( mpParamInfo - mrFuncInfo.mpParamInfos + 1 ) < EXC_FUNCINFO_PARAMINFO_COUNT) && (mpParamInfo[ 1 ].meValid != EXC_PARAM_NONE) )
++mpParamInfo;
// if last parameter type is 'Excel-only' or 'Calc-only', do not repeat it
else if( IsExcelOnlyParam() || IsCalcOnlyParam() )
@@ -2496,7 +2497,7 @@ void XclExpFmlaCompImpl::InsertZeros( sal_uInt16 nInsertPos, sal_uInt16 nInsertS
void XclExpFmlaCompImpl::Overwrite( sal_uInt16 nWriteToPos, sal_uInt16 nOffset )
{
- OSL_ENSURE( static_cast< size_t >( nWriteToPos + 1 ) < mxData->maTokVec.size(), "XclExpFmlaCompImpl::Overwrite - invalid position" );
+ OSL_ENSURE( o3tl::make_unsigned( nWriteToPos + 1 ) < mxData->maTokVec.size(), "XclExpFmlaCompImpl::Overwrite - invalid position" );
ShortToSVBT16( nOffset, &mxData->maTokVec[ nWriteToPos ] );
}
@@ -2513,7 +2514,7 @@ void XclExpFmlaCompImpl::UpdateAttrGoto( sal_uInt16 nAttrPos )
bool XclExpFmlaCompImpl::IsSpaceToken( sal_uInt16 nPos ) const
{
return
- (static_cast< size_t >( nPos + 4 ) <= mxData->maTokVec.size()) &&
+ (o3tl::make_unsigned( nPos + 4 ) <= mxData->maTokVec.size()) &&
(mxData->maTokVec[ nPos ] == EXC_TOKID_ATTR) &&
(mxData->maTokVec[ nPos + 1 ] == EXC_TOK_ATTR_SPACE);
}
diff --git a/sc/source/filter/excel/xepivotxml.cxx b/sc/source/filter/excel/xepivotxml.cxx
index 5d95ffe9c6a1..8bb77f5eb1a0 100644
--- a/sc/source/filter/excel/xepivotxml.cxx
+++ b/sc/source/filter/excel/xepivotxml.cxx
@@ -21,6 +21,7 @@
#include <xeroot.hxx>
#include <o3tl/temporary.hxx>
+#include <o3tl/safeint.hxx>
#include <oox/export/utils.hxx>
#include <oox/token/namespaces.hxx>
#include <sax/tools/converter.hxx>
@@ -58,7 +59,7 @@ void savePivotCacheRecordsXml( XclExpXmlStream& rStrm, const ScDPCache& rCache )
{
const ScDPCache::IndexArrayType* pArray = rCache.GetFieldIndexArray(nField);
assert(pArray);
- assert(static_cast<size_t>(i) < pArray->size());
+ assert(o3tl::make_unsigned(i) < pArray->size());
// We are using XML_x reference (like: <x v="0"/>), instead of values here (eg: <s v="No Discount"/>).
// That's why in SavePivotCacheXml method, we need to list all items.
diff --git a/sc/source/filter/excel/xestring.cxx b/sc/source/filter/excel/xestring.cxx
index 80a89af7a25d..45be12cbbcbf 100644
--- a/sc/source/filter/excel/xestring.cxx
+++ b/sc/source/filter/excel/xestring.cxx
@@ -20,6 +20,7 @@
#include <algorithm>
#include <cassert>
+#include <o3tl/safeint.hxx>
#include <osl/diagnose.h>
#include <tools/solar.h>
#include <xlstyle.hxx>
@@ -458,7 +459,7 @@ void XclExpString::SetStrLen( sal_Int32 nNewLen )
void XclExpString::CharsToBuffer( const sal_Unicode* pcSource, sal_Int32 nBegin, sal_Int32 nLen )
{
- OSL_ENSURE( maUniBuffer.size() >= static_cast< size_t >( nBegin + nLen ),
+ OSL_ENSURE( maUniBuffer.size() >= o3tl::make_unsigned( nBegin + nLen ),
"XclExpString::CharsToBuffer - char buffer invalid" );
ScfUInt16Vec::iterator aBeg = maUniBuffer.begin() + nBegin;
ScfUInt16Vec::iterator aEnd = aBeg + nLen;
@@ -475,7 +476,7 @@ void XclExpString::CharsToBuffer( const sal_Unicode* pcSource, sal_Int32 nBegin,
void XclExpString::CharsToBuffer( const char* pcSource, sal_Int32 nBegin, sal_Int32 nLen )
{
- OSL_ENSURE( maCharBuffer.size() >= static_cast< size_t >( nBegin + nLen ),
+ OSL_ENSURE( maCharBuffer.size() >= o3tl::make_unsigned( nBegin + nLen ),
"XclExpString::CharsToBuffer - char buffer invalid" );
ScfUInt8Vec::iterator aBeg = maCharBuffer.begin() + nBegin;
ScfUInt8Vec::iterator aEnd = aBeg + nLen;
diff --git a/sc/source/filter/excel/xestyle.cxx b/sc/source/filter/excel/xestyle.cxx
index 6bb80bf7dc9d..03a63404d696 100644
--- a/sc/source/filter/excel/xestyle.cxx
+++ b/sc/source/filter/excel/xestyle.cxx
@@ -47,6 +47,7 @@
#include <xltools.hxx>
#include <conditio.hxx>
+#include <o3tl/safeint.hxx>
#include <oox/export/utils.hxx>
#include <oox/token/tokens.hxx>
#include <oox/token/namespaces.hxx>
@@ -1358,7 +1359,7 @@ sal_uInt16 XclExpNumFmtBuffer::Insert( sal_uInt32 nScNumFmt )
return aIt->mnXclNumFmt;
size_t nSize = maFormatMap.size();
- if( nSize < static_cast< size_t >( 0xFFFF - mnXclOffset ) )
+ if( nSize < o3tl::make_unsigned( 0xFFFF - mnXclOffset ) )
{
sal_uInt16 nXclNumFmt = static_cast< sal_uInt16 >( nSize + mnXclOffset );
maFormatMap.emplace_back( nScNumFmt, nXclNumFmt, GetFormatCode( nScNumFmt ) );
diff --git a/sc/source/filter/excel/xiview.cxx b/sc/source/filter/excel/xiview.cxx
index 143512b2bd92..29674e896bc6 100644
--- a/sc/source/filter/excel/xiview.cxx
+++ b/sc/source/filter/excel/xiview.cxx
@@ -17,6 +17,10 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
+#include <sal/config.h>
+
+#include <o3tl/safeint.hxx>
+
#include <xiview.hxx>
#include <document.hxx>
#include <scextopt.hxx>
@@ -251,7 +255,7 @@ void XclImpTabViewSettings::Finalize()
#i35812# Excel uses number of visible rows/columns, Calc uses position of freeze. */
if( (maData.mnSplitX > 0) && (maData.maFirstXclPos.mnCol + maData.mnSplitX <= GetScMaxPos().Col()) )
rTabSett.maFreezePos.SetCol( static_cast< SCCOL >( maData.maFirstXclPos.mnCol + maData.mnSplitX ) );
- if( (maData.mnSplitY > 0) && (maData.maFirstXclPos.mnRow + maData.mnSplitY <= static_cast<unsigned>(GetScMaxPos().Row())) )
+ if( (maData.mnSplitY > 0) && (maData.maFirstXclPos.mnRow + maData.mnSplitY <= o3tl::make_unsigned(GetScMaxPos().Row())) )
rTabSett.maFreezePos.SetRow( static_cast< SCROW >( maData.maFirstXclPos.mnRow + maData.mnSplitY ) );
}
else
diff --git a/sc/source/filter/excel/xladdress.cxx b/sc/source/filter/excel/xladdress.cxx
index a11b1959ca64..f897a92a70a3 100644
--- a/sc/source/filter/excel/xladdress.cxx
+++ b/sc/source/filter/excel/xladdress.cxx
@@ -22,6 +22,7 @@
#include <xltracer.hxx>
#include <xistream.hxx>
+#include <o3tl/safeint.hxx>
#include <osl/diagnose.h>
void XclAddress::Read( XclImpStream& rStrm )
@@ -128,8 +129,8 @@ XclAddressConverterBase::XclAddressConverterBase( XclTracer& rTracer, const ScAd
mbRowTrunc( false ),
mbTabTrunc( false )
{
- OSL_ENSURE( static_cast< size_t >( rMaxPos.Col() ) <= SAL_MAX_UINT16, "XclAddressConverterBase::XclAddressConverterBase - invalid max column" );
- OSL_ENSURE( static_cast< size_t >( rMaxPos.Row() ) <= SAL_MAX_UINT32, "XclAddressConverterBase::XclAddressConverterBase - invalid max row" );
+ OSL_ENSURE( o3tl::make_unsigned( rMaxPos.Col() ) <= SAL_MAX_UINT16, "XclAddressConverterBase::XclAddressConverterBase - invalid max column" );
+ OSL_ENSURE( o3tl::make_unsigned( rMaxPos.Row() ) <= SAL_MAX_UINT32, "XclAddressConverterBase::XclAddressConverterBase - invalid max row" );
}
XclAddressConverterBase::~XclAddressConverterBase()
diff --git a/sc/source/filter/oox/externallinkbuffer.cxx b/sc/source/filter/oox/externallinkbuffer.cxx
index 2164c7f71a23..2c6f9d20b78a 100644
--- a/sc/source/filter/oox/externallinkbuffer.cxx
+++ b/sc/source/filter/oox/externallinkbuffer.cxx
@@ -25,6 +25,7 @@
#include <com/sun/star/sheet/XDDELinks.hpp>
#include <com/sun/star/sheet/XDDELinkResults.hpp>
#include <com/sun/star/sheet/XExternalDocLinks.hpp>
+#include <o3tl/safeint.hxx>
#include <osl/diagnose.h>
#include <sal/log.hxx>
#include <oox/core/filterbase.hxx>
@@ -660,7 +661,7 @@ ExternalLinkRef ExternalLinkBuffer::createExternalLink()
const RefSheetsModel* ExternalLinkBuffer::getRefSheets( sal_Int32 nRefId ) const
{
- return ((0 <= nRefId) && (static_cast< size_t >( nRefId ) < maRefSheets.size())) ?
+ return ((0 <= nRefId) && (o3tl::make_unsigned( nRefId ) < maRefSheets.size())) ?
&maRefSheets[ static_cast< size_t >( nRefId ) ] : nullptr;
}
diff --git a/sc/source/filter/oox/formulabuffer.cxx b/sc/source/filter/oox/formulabuffer.cxx
index 26aec23827db..0d1855468bf1 100644
--- a/sc/source/filter/oox/formulabuffer.cxx
+++ b/sc/source/filter/oox/formulabuffer.cxx
@@ -18,6 +18,7 @@
#include <sharedformulagroups.hxx>
#include <externalrefmgr.hxx>
#include <tokenstringcontext.hxx>
+#include <o3tl/safeint.hxx>
#include <oox/token/tokens.hxx>
#include <oox/helper/progressbar.hxx>
#include <svl/sharedstringpool.hxx>
@@ -399,7 +400,7 @@ FormulaBuffer::SheetItem FormulaBuffer::getSheetItem( SCTAB nTab )
SheetItem aItem;
- if( static_cast<size_t>(nTab) >= maCellFormulas.size() )
+ if( o3tl::make_unsigned(nTab) >= maCellFormulas.size() )
{
SAL_WARN( "sc", "Tab " << nTab << " out of bounds " << maCellFormulas.size() );
return aItem;
@@ -423,7 +424,7 @@ void FormulaBuffer::createSharedFormulaMapEntry(
const ScAddress& rAddress,
sal_Int32 nSharedId, const OUString& rTokens )
{
- assert( rAddress.Tab() >= 0 && static_cast<size_t>(rAddress.Tab()) < maSharedFormulas.size() );
+ assert( rAddress.Tab() >= 0 && o3tl::make_unsigned(rAddress.Tab()) < maSharedFormulas.size() );
std::vector<SharedFormulaEntry>& rSharedFormulas = maSharedFormulas[ rAddress.Tab() ];
SharedFormulaEntry aEntry(rAddress, rTokens, nSharedId);
rSharedFormulas.push_back( aEntry );
@@ -431,14 +432,14 @@ void FormulaBuffer::createSharedFormulaMapEntry(
void FormulaBuffer::setCellFormula( const ScAddress& rAddress, const OUString& rTokenStr )
{
- assert( rAddress.Tab() >= 0 && static_cast<size_t>(rAddress.Tab()) < maCellFormulas.size() );
+ assert( rAddress.Tab() >= 0 && o3tl::make_unsigned(rAddress.Tab()) < maCellFormulas.size() );
maCellFormulas[ rAddress.Tab() ].emplace_back( rTokenStr, rAddress );
}
void FormulaBuffer::setCellFormula(
const ScAddress& rAddress, sal_Int32 nSharedId, const OUString& rCellValue, sal_Int32 nValueType )
{
- assert( rAddress.Tab() >= 0 && static_cast<size_t>(rAddress.Tab()) < maSharedFormulaIds.size() );
+ assert( rAddress.Tab() >= 0 && o3tl::make_unsigned(rAddress.Tab()) < maSharedFormulaIds.size() );
maSharedFormulaIds[rAddress.Tab()].emplace_back(rAddress, nSharedId, rCellValue, nValueType);
}
@@ -446,14 +447,14 @@ void FormulaBuffer::setCellArrayFormula( const ScRange& rRangeAddress, const ScA
{
TokenAddressItem tokenPair( rTokenStr, rTokenAddress );
- assert( rRangeAddress.aStart.Tab() >= 0 && static_cast<size_t>(rRangeAddress.aStart.Tab()) < maCellArrayFormulas.size() );
+ assert( rRangeAddress.aStart.Tab() >= 0 && o3tl::make_unsigned(rRangeAddress.aStart.Tab()) < maCellArrayFormulas.size() );
maCellArrayFormulas[ rRangeAddress.aStart.Tab() ].emplace_back( tokenPair, rRangeAddress );
}
void FormulaBuffer::setCellFormulaValue(
const ScAddress& rAddress, const OUString& rValueStr, sal_Int32 nCellType )
{
- assert( rAddress.Tab() >= 0 && static_cast<size_t>(rAddress.Tab()) < maCellFormulaValues.size() );
+ assert( rAddress.Tab() >= 0 && o3tl::make_unsigned(rAddress.Tab()) < maCellFormulaValues.size() );
FormulaValue aVal;
aVal.maAddress = rAddress;
aVal.maValueStr = rValueStr;
diff --git a/sc/source/filter/oox/pivotcachebuffer.cxx b/sc/source/filter/oox/pivotcachebuffer.cxx
index a2e5d8d66360..e80605b9c130 100644
--- a/sc/source/filter/oox/pivotcachebuffer.cxx
+++ b/sc/source/filter/oox/pivotcachebuffer.cxx
@@ -26,6 +26,7 @@
#include <com/sun/star/sheet/DataPilotFieldGroupBy.hpp>
#include <com/sun/star/sheet/DataPilotFieldGroupInfo.hpp>
#include <com/sun/star/sheet/XDataPilotFieldGrouping.hpp>
+#include <o3tl/safeint.hxx>
#include <osl/diagnose.h>
#include <sal/log.hxx>
#include <oox/helper/attributelist.hxx>
@@ -305,7 +306,7 @@ void PivotCacheItemList::applyItemCaptions( const IdCaptionPairList& vCaptions )
{
for( const auto& [rId, rCaption] : vCaptions )
{
- if ( static_cast<sal_uInt32>( rId ) < maItems.size() )
+ if ( o3tl::make_unsigned( rId ) < maItems.size() )
maItems[ rId ].setStringValue( rCaption );
}
}
diff --git a/sc/source/filter/xml/XMLStylesExportHelper.cxx b/sc/source/filter/xml/XMLStylesExportHelper.cxx
index 5c3b9b5163f1..f5a374529b8b 100644
--- a/sc/source/filter/xml/XMLStylesExportHelper.cxx
+++ b/sc/source/filter/xml/XMLStylesExportHelper.cxx
@@ -34,6 +34,7 @@
#include <comphelper/extract.hxx>
#include <comphelper/propertysequence.hxx>
#include <sfx2/app.hxx>
+#include <o3tl/safeint.hxx>
#include <osl/diagnose.h>
using namespace com::sun::star;
@@ -423,7 +424,7 @@ void ScMyValidationsContainer::WriteValidations(ScXMLExport& rExport)
const OUString& ScMyValidationsContainer::GetValidationName(const sal_Int32 nIndex)
{
- OSL_ENSURE( static_cast<size_t>(nIndex) < aValidationVec.size(), "out of range" );
+ OSL_ENSURE( o3tl::make_unsigned(nIndex) < aValidationVec.size(), "out of range" );
return aValidationVec[nIndex].sName;
}
@@ -728,7 +729,7 @@ sal_Int32 ScFormatRangeStyles::GetIndexOfStyleName(const OUString& rString, cons
sal_Int32 nPrefixLength(rPrefix.getLength());
OUString sTemp(rString.copy(nPrefixLength));
sal_Int32 nIndex(sTemp.toInt32());
- if (nIndex > 0 && static_cast<size_t>(nIndex-1) < aAutoStyleNames.size() && aAutoStyleNames.at(nIndex - 1) == rString)
+ if (nIndex > 0 && o3tl::make_unsigned(nIndex-1) < aAutoStyleNames.size() && aAutoStyleNames.at(nIndex - 1) == rString)
{
bIsAutoStyle = true;
return nIndex - 1;
@@ -737,7 +738,7 @@ sal_Int32 ScFormatRangeStyles::GetIndexOfStyleName(const OUString& rString, cons
{
sal_Int32 i(0);
bool bFound(false);
- while (!bFound && static_cast<size_t>(i) < aStyleNames.size())
+ while (!bFound && o3tl::make_unsigned(i) < aStyleNames.size())
{
if (aStyleNames[i] == rString)
bFound = true;
@@ -752,7 +753,7 @@ sal_Int32 ScFormatRangeStyles::GetIndexOfStyleName(const OUString& rString, cons
else
{
i = 0;
- while (!bFound && static_cast<size_t>(i) < aAutoStyleNames.size())
+ while (!bFound && o3tl::make_unsigned(i) < aAutoStyleNames.size())
{
if (aAutoStyleNames[i] == rString)
bFound = true;
@@ -773,8 +774,8 @@ sal_Int32 ScFormatRangeStyles::GetIndexOfStyleName(const OUString& rString, cons
sal_Int32 ScFormatRangeStyles::GetStyleNameIndex(const sal_Int32 nTable,
const sal_Int32 nColumn, const sal_Int32 nRow, bool& bIsAutoStyle) const
{
- OSL_ENSURE(static_cast<size_t>(nTable) < aTables.size(), "wrong table");
- if (static_cast<size_t>(nTable) >= aTables.size())
+ OSL_ENSURE(o3tl::make_unsigned(nTable) < aTables.size(), "wrong table");
+ if (o3tl::make_unsigned(nTable) >= aTables.size())
return -1;
for (const ScMyFormatRange & rFormatRange : aTables[nTable])
{
@@ -793,8 +794,8 @@ sal_Int32 ScFormatRangeStyles::GetStyleNameIndex(const sal_Int32 nTable,
sal_Int32 ScFormatRangeStyles::GetStyleNameIndex(const sal_Int32 nTable, const sal_Int32 nColumn, const sal_Int32 nRow,
bool& bIsAutoStyle, sal_Int32& nValidationIndex, sal_Int32& nNumberFormat, const sal_Int32 nRemoveBeforeRow)
{
- OSL_ENSURE(static_cast<size_t>(nTable) < aTables.size(), "wrong table");
- if (static_cast<size_t>(nTable) >= aTables.size())
+ OSL_ENSURE(o3tl::make_unsigned(nTable) < aTables.size(), "wrong table");
+ if (o3tl::make_unsigned(nTable) >= aTables.size())
return -1;
ScMyFormatRangeAddresses& rFormatRanges(aTables[nTable]);
ScMyFormatRangeAddresses::iterator aItr(rFormatRanges.begin());
@@ -809,8 +810,8 @@ sal_Int32 ScFormatRangeStyles::GetStyleNameIndex(const sal_Int32 nTable, const s
bIsAutoStyle = aItr->bIsAutoStyle;
nValidationIndex = aItr->nValidationIndex;
nNumberFormat = aItr->nNumberFormat;
- OSL_ENSURE( static_cast<size_t>(nColumn) < pColDefaults->size(), "nColumn out of bounds");
- if (static_cast<size_t>(nColumn) < pColDefaults->size() &&
+ OSL_ENSURE( o3tl::make_unsigned(nColumn) < pColDefaults->size(), "nColumn out of bounds");
+ if (o3tl::make_unsigned(nColumn) < pColDefaults->size() &&
((*pColDefaults)[nColumn].nIndex != -1) &&
((*pColDefaults)[nColumn].nIndex == (*aItr).nStyleNameIndex) &&
((*pColDefaults)[nColumn].bIsAutoStyle == (*aItr).bIsAutoStyle))
@@ -833,7 +834,7 @@ void ScFormatRangeStyles::GetFormatRanges(const sal_Int32 nStartColumn, const sa
const sal_Int32 nTable, ScRowFormatRanges* pRowFormatRanges)
{
sal_Int32 nTotalColumns(nEndColumn - nStartColumn + 1);
- OSL_ENSURE(static_cast<size_t>(nTable) < aTables.size(), "wrong table");
+ OSL_ENSURE(o3tl::make_unsigned(nTable) < aTables.size(), "wrong table");
ScMyFormatRangeAddresses& rFormatRanges(aTables[nTable]);
ScMyFormatRangeAddresses::iterator aItr(rFormatRanges.begin());
ScMyFormatRangeAddresses::iterator aEndItr(rFormatRanges.end());
@@ -901,7 +902,7 @@ void ScFormatRangeStyles::AddRangeStyleName(const table::CellRangeAddress& rCell
aFormatRange.nValidationIndex = nValidationIndex;
aFormatRange.nNumberFormat = nNumberFormat;
aFormatRange.bIsAutoStyle = bIsAutoStyle;
- OSL_ENSURE(static_cast<size_t>(rCellRangeAddress.Sheet) < aTables.size(), "wrong table");
+ OSL_ENSURE(o3tl::make_unsigned(rCellRangeAddress.Sheet) < aTables.size(), "wrong table");
ScMyFormatRangeAddresses& rFormatRanges(aTables[rCellRangeAddress.Sheet]);
rFormatRanges.push_back(aFormatRange);
}
@@ -940,13 +941,13 @@ sal_Int32 ScColumnRowStylesBase::GetIndexOfStyleName(const OUString& rString, co
sal_Int32 nPrefixLength(rPrefix.getLength());
OUString sTemp(rString.copy(nPrefixLength));
sal_Int32 nIndex(sTemp.toInt32());
- if (nIndex > 0 && static_cast<size_t>(nIndex-1) < aStyleNames.size() && aStyleNames.at(nIndex - 1) == rString)
+ if (nIndex > 0 && o3tl::make_unsigned(nIndex-1) < aStyleNames.size() && aStyleNames.at(nIndex - 1) == rString)
return nIndex - 1;
else
{
sal_Int32 i(0);
bool bFound(false);
- while (!bFound && static_cast<size_t>(i) < aStyleNames.size())
+ while (!bFound && o3tl::make_unsigned(i) < aStyleNames.size())
{
if (aStyleNames.at(i) == rString)
bFound = true;
@@ -989,8 +990,8 @@ void ScColumnStyles::AddNewTable(const sal_Int32 nTable, const sal_Int32 nFields
sal_Int32 ScColumnStyles::GetStyleNameIndex(const sal_Int32 nTable, const sal_Int32 nField,
bool& bIsVisible)
{
- OSL_ENSURE(static_cast<size_t>(nTable) < aTables.size(), "wrong table");
- if (static_cast<size_t>(nField) < aTables[nTable].size())
+ OSL_ENSURE(o3tl::make_unsigned(nTable) < aTables.size(), "wrong table");
+ if (o3tl::make_unsigned(nField) < aTables[nTable].size())
{
bIsVisible = aTables[nTable][nField].bIsVisible;
return aTables[nTable][nField].nIndex;
@@ -1005,8 +1006,8 @@ sal_Int32 ScColumnStyles::GetStyleNameIndex(const sal_Int32 nTable, const sal_In
void ScColumnStyles::AddFieldStyleName(const sal_Int32 nTable, const sal_Int32 nField,
const sal_Int32 nStringIndex, const bool bIsVisible)
{
- OSL_ENSURE(static_cast<size_t>(nTable) < aTables.size(), "wrong table");
- OSL_ENSURE(aTables[nTable].size() >= static_cast<sal_uInt32>(nField), "wrong field");
+ OSL_ENSURE(o3tl::make_unsigned(nTable) < aTables.size(), "wrong table");
+ OSL_ENSURE(aTables[nTable].size() >= o3tl::make_unsigned(nField), "wrong field");
ScColumnStyle aStyle;
aStyle.nIndex = nStringIndex;
aStyle.bIsVisible = bIsVisible;
@@ -1044,8 +1045,8 @@ void ScRowStyles::AddNewTable(const sal_Int32 nTable, const sal_Int32 nFields)
sal_Int32 ScRowStyles::GetStyleNameIndex(const sal_Int32 nTable, const sal_Int32 nField)
{
- OSL_ENSURE(static_cast<size_t>(nTable) < aTables.size(), "wrong table");
- if (static_cast<size_t>(nTable) >= aTables.size())
+ OSL_ENSURE(o3tl::make_unsigned(nTable) < aTables.size(), "wrong table");
+ if (o3tl::make_unsigned(nTable) >= aTables.size())
return -1;
if (maCache.hasCache(nTable, nField))
@@ -1073,7 +1074,7 @@ sal_Int32 ScRowStyles::GetStyleNameIndex(const sal_Int32 nTable, const sal_Int32
void ScRowStyles::AddFieldStyleName(const sal_Int32 nTable, const sal_Int32 nField,
const sal_Int32 nStringIndex)
{
- OSL_ENSURE(static_cast<size_t>(nTable) < aTables.size(), "wrong table");
+ OSL_ENSURE(o3tl::make_unsigned(nTable) < aTables.size(), "wrong table");
StylesType& r = *aTables[nTable];
r.insert_back(nField, nField+1, nStringIndex);
}
@@ -1082,7 +1083,7 @@ void ScRowStyles::AddFieldStyleName(const sal_Int32 nTable, const sal_Int32 nSta
const sal_Int32 nStringIndex, const sal_Int32 nEndField)
{
OSL_ENSURE( nStartField <= nEndField, "bad field range");
- OSL_ENSURE(static_cast<size_t>(nTable) < aTables.size(), "wrong table");
+ OSL_ENSURE(o3tl::make_unsigned(nTable) < aTables.size(), "wrong table");
StylesType& r = *aTables[nTable];
r.insert_back(nStartField, nEndField+1, nStringIndex);
}
diff --git a/sc/source/ui/Accessibility/AccessibleDocument.cxx b/sc/source/ui/Accessibility/AccessibleDocument.cxx
index a9da52b3d073..22bdd25ea433 100644
--- a/sc/source/ui/Accessibility/AccessibleDocument.cxx
+++ b/sc/source/ui/Accessibility/AccessibleDocument.cxx
@@ -42,7 +42,7 @@
#include <com/sun/star/drawing/XShape.hpp>
#include <com/sun/star/drawing/XShapes.hpp>
#include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
-
+#include <o3tl/safeint.hxx>
#include <unotools/accessiblestatesethelper.hxx>
#include <tools/gen.hxx>
#include <svx/svdpage.hxx>
@@ -550,7 +550,7 @@ uno::Reference< XAccessible > ScChildrenShapes::Get(sal_Int32 nIndex) const
mbShapesNeedSorting = false;
}
- if (static_cast<sal_uInt32>(nIndex) >= maZOrderedShapes.size())
+ if (o3tl::make_unsigned(nIndex) >= maZOrderedShapes.size())
return nullptr;
return Get(maZOrderedShapes[nIndex]);
@@ -810,7 +810,7 @@ uno::Reference< XAccessible > ScChildrenShapes::GetSelected(sal_Int32 nSelectedC
std::vector < uno::Reference < drawing::XShape > > aShapes;
FillShapes(aShapes);
- if (nSelectedChildIndex < 0 || static_cast<size_t>(nSelectedChildIndex) >= aShapes.size())
+ if (nSelectedChildIndex < 0 || o3tl::make_unsigned(nSelectedChildIndex) >= aShapes.size())
return xAccessible;
SortedShapes::iterator aItr;
diff --git a/sc/source/ui/Accessibility/AccessibleFilterMenu.cxx b/sc/source/ui/Accessibility/AccessibleFilterMenu.cxx
index 7dfcae0e7edf..70202f93170f 100644
--- a/sc/source/ui/Accessibility/AccessibleFilterMenu.cxx
+++ b/sc/source/ui/Accessibility/AccessibleFilterMenu.cxx
@@ -21,6 +21,7 @@
#include <AccessibleFilterMenu.hxx>
#include <AccessibleFilterMenuItem.hxx>
+#include <o3tl/safeint.hxx>
#include <tools/gen.hxx>
#include <checklistmenu.hxx>
@@ -116,7 +117,7 @@ sal_Int32 ScAccessibleFilterMenu::getAccessibleChildCount()
Reference<XAccessible> ScAccessibleFilterMenu::getAccessibleChild(sal_Int32 nIndex)
{
- if (maMenuItems.size() <= static_cast<size_t>(nIndex))
+ if (maMenuItems.size() <= o3tl::make_unsigned(nIndex))
throw IndexOutOfBoundsException();
return maMenuItems[nIndex];
@@ -153,7 +154,7 @@ void ScAccessibleFilterMenu::removeAccessibleEventListener(
void ScAccessibleFilterMenu::selectAccessibleChild(sal_Int32 nChildIndex)
{
- if (static_cast<size_t>(nChildIndex) >= maMenuItems.size())
+ if (o3tl::make_unsigned(nChildIndex) >= maMenuItems.size())
throw IndexOutOfBoundsException();
mpWindow->setSelectedMenuItem(nChildIndex, false, true);
@@ -161,7 +162,7 @@ void ScAccessibleFilterMenu::selectAccessibleChild(sal_Int32 nChildIndex)
sal_Bool ScAccessibleFilterMenu::isAccessibleChildSelected(sal_Int32 nChildIndex)
{
- if (static_cast<size_t>(nChildIndex) >= maMenuItems.size())
+ if (o3tl::make_unsigned(nChildIndex) >= maMenuItems.size())
throw IndexOutOfBoundsException();
return mpWindow->isMenuItemSelected(static_cast<size_t>(nChildIndex));
@@ -185,7 +186,7 @@ sal_Int32 ScAccessibleFilterMenu::getSelectedAccessibleChildCount()
Reference<XAccessible> ScAccessibleFilterMenu::getSelectedAccessibleChild(sal_Int32 nChildIndex)
{
- if (static_cast<size_t>(nChildIndex) >= maMenuItems.size())
+ if (o3tl::make_unsigned(nChildIndex) >= maMenuItems.size())
throw IndexOutOfBoundsException();
return maMenuItems[nChildIndex];
@@ -193,7 +194,7 @@ Reference<XAccessible> ScAccessibleFilterMenu::getSelectedAccessibleChild(sal_In
void ScAccessibleFilterMenu::deselectAccessibleChild(sal_Int32 nChildIndex)
{
- if (static_cast<size_t>(nChildIndex) >= maMenuItems.size())
+ if (o3tl::make_unsigned(nChildIndex) >= maMenuItems.size())
throw IndexOutOfBoundsException();
mpWindow->selectMenuItem(nChildIndex, false, false);
diff --git a/sc/source/ui/Accessibility/AccessibleSpreadsheet.cxx b/sc/source/ui/Accessibility/AccessibleSpreadsheet.cxx
index a25f33658367..b2c743b8234b 100644
--- a/sc/source/ui/Accessibility/AccessibleSpreadsheet.cxx
+++ b/sc/source/ui/Accessibility/AccessibleSpreadsheet.cxx
@@ -27,6 +27,7 @@
#include <markdata.hxx>
#include <gridwin.hxx>
+#include <o3tl/safeint.hxx>
#include <unotools/accessiblestatesethelper.hxx>
#include <unotools/accessiblerelationsethelper.hxx>
#include <com/sun/star/accessibility/AccessibleStateType.hpp>
@@ -200,7 +201,7 @@ bool ScAccessibleSpreadsheet::CalcScRangeListDifferenceMax(ScRangeList *pSrc, Sc
int nSize =0;
if (pDest->GetCellCount() == 0)//if the Dest Rang List is empty
{
- if (pSrc->GetCellCount() > sal_uInt32(nMax))//if the Src Cell count is greater than nMax
+ if (pSrc->GetCellCount() > o3tl::make_unsigned(nMax))//if the Src Cell count is greater than nMax
{
return true;
}
@@ -1144,7 +1145,7 @@ uno::Reference<XAccessible > SAL_CALL
if (mpMarkedRanges)
{
if ((nSelectedChildIndex < 0) ||
- (mpMarkedRanges->GetCellCount() <= static_cast<sal_uInt32>(nSelectedChildIndex)))
+ (mpMarkedRanges->GetCellCount() <= o3tl::make_unsigned(nSelectedChildIndex)))
{
throw lang::IndexOutOfBoundsException();
}
diff --git a/sc/source/ui/condformat/condformathelper.cxx b/sc/source/ui/condformat/condformathelper.cxx
index dc40f5464803..130785249469 100644
--- a/sc/source/ui/condformat/condformathelper.cxx
+++ b/sc/source/ui/condformat/condformathelper.cxx
@@ -7,6 +7,9 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
+#include <sal/config.h>
+
+#include <o3tl/safeint.hxx>
#include <rtl/ustrbuf.hxx>
#include <condformathelper.hxx>
#include <globstr.hrc>
@@ -117,7 +120,7 @@ OUString getDateString(sal_Int32 nIndex)
STR_COND_NEXTYEAR
};
- if (nIndex >= 0 && static_cast<sal_uInt32>(nIndex) < SAL_N_ELEMENTS(aCondStrs))
+ if (nIndex >= 0 && o3tl::make_unsigned(nIndex) < SAL_N_ELEMENTS(aCondStrs))
return ScResId(aCondStrs[nIndex]);
assert(false);
return OUString();
diff --git a/sc/source/ui/dbgui/consdlg.cxx b/sc/source/ui/dbgui/consdlg.cxx
index 4892cf044377..db55aaa0c657 100644
--- a/sc/source/ui/dbgui/consdlg.cxx
+++ b/sc/source/ui/dbgui/consdlg.cxx
@@ -32,6 +32,7 @@
#include <strings.hrc>
#include <consdlg.hxx>
+#include <o3tl/safeint.hxx>
#include <vcl/svapp.hxx>
#include <vcl/weld.hxx>
@@ -452,7 +453,7 @@ IMPL_LINK( ScConsolidateDlg, SelectCBHdl, weld::ComboBox&, rLb, void )
&& (nAreaDataCount > 0)
&& (pAreaData != nullptr) )
{
- if ( static_cast<size_t>(nSelPos) <= nAreaDataCount )
+ if ( o3tl::make_unsigned(nSelPos) <= nAreaDataCount )
{
OUString aString( pAreaData[nSelPos-1].aStrArea );
diff --git a/sc/source/ui/docshell/docfunc.cxx b/sc/source/ui/docshell/docfunc.cxx
index b65edc73a8c0..ae76b44f9551 100644
--- a/sc/source/ui/docshell/docfunc.cxx
+++ b/sc/source/ui/docshell/docfunc.cxx
@@ -20,6 +20,7 @@
#include <scitems.hxx>
#include <comphelper/lok.hxx>
+#include <o3tl/safeint.hxx>
#include <sfx2/app.hxx>
#include <editeng/editobj.hxx>
#include <editeng/justifyitem.hxx>
@@ -1028,7 +1029,7 @@ bool ScDocFunc::SetFormulaCells( const ScAddress& rPos, std::vector<ScFormulaCel
ScDocument& rDoc = rDocShell.GetDocument();
const size_t nLength = rCells.size();
- if (rPos.Row() + nLength - 1 > static_cast<size_t>(rDoc.MaxRow()))
+ if (rPos.Row() + nLength - 1 > o3tl::make_unsigned(rDoc.MaxRow()))
// out of bound
return false;
diff --git a/sc/source/ui/docshell/externalrefmgr.cxx b/sc/source/ui/docshell/externalrefmgr.cxx
index b06fefbf687d..f16f0f70b066 100644
--- a/sc/source/ui/docshell/externalrefmgr.cxx
+++ b/sc/source/ui/docshell/externalrefmgr.cxx
@@ -36,6 +36,7 @@
#include <defaultsoptions.hxx>
#include <scmod.hxx>
+#include <o3tl/safeint.hxx>
#include <osl/file.hxx>
#include <sfx2/app.hxx>
#include <sfx2/docfile.hxx>
@@ -636,8 +637,8 @@ ScExternalRefCache::TokenArrayRef ScExternalRefCache::getCellRangeData(
}
}
- if (nMinCol <= nMaxCol && ((static_cast<SCSIZE>(nMaxCol-nMinCol+1) < nMatrixColumns) ||
- (static_cast<SCSIZE>(nDataRow2-nDataRow1+1) < nMatrixRows)))
+ if (nMinCol <= nMaxCol && ((o3tl::make_unsigned(nMaxCol-nMinCol+1) < nMatrixColumns) ||
+ (o3tl::make_unsigned(nDataRow2-nDataRow1+1) < nMatrixRows)))
{
nMatrixColumns = static_cast<SCSIZE>(nMaxCol-nMinCol+1);
nMatrixRows = static_cast<SCSIZE>(nDataRow2-nDataRow1+1);
@@ -825,7 +826,7 @@ void ScExternalRefCache::setCellRangeData(sal_uInt16 nFileId, const ScRange& rRa
const ScMatrixRef& pMat = rItem.mpRangeData;
SCSIZE nMatCols, nMatRows;
pMat->GetDimensions( nMatCols, nMatRows);
- if (nMatCols > static_cast<SCSIZE>(nCol2 - nCol1) && nMatRows > static_cast<SCSIZE>(nRow2 - nRow1))
+ if (nMatCols > o3tl::make_unsigned(nCol2 - nCol1) && nMatRows > o3tl::make_unsigned(nRow2 - nRow1))
{
ScMatrix::DoubleOpFunction aDoubleFunc = [=](size_t row, size_t col, double val) -> void
{
@@ -1577,8 +1578,8 @@ static std::unique_ptr<ScTokenArray> convertToTokenArray(
}
else if ((nCol1 == 0 && nCol2 == MAXCOL) || (nRow1 == 0 && nRow2 == MAXROW))
{
- if ((static_cast<SCSIZE>(nDataCol2-nDataCol1+1) < nMatrixColumns) ||
- (static_cast<SCSIZE>(nDataRow2-nDataRow1+1) < nMatrixRows))
+ if ((o3tl::make_unsigned(nDataCol2-nDataCol1+1) < nMatrixColumns) ||
+ (o3tl::make_unsigned(nDataRow2-nDataRow1+1) < nMatrixRows))
{
nMatrixColumns = static_cast<SCSIZE>(nDataCol2-nDataCol1+1);
nMatrixRows = static_cast<SCSIZE>(nDataRow2-nDataRow1+1);
diff --git a/sc/source/ui/unoobj/PivotTableDataProvider.cxx b/sc/source/ui/unoobj/PivotTableDataProvider.cxx
index d7979cda8cbe..859ef12208cb 100644
--- a/sc/source/ui/unoobj/PivotTableDataProvider.cxx
+++ b/sc/source/ui/unoobj/PivotTableDataProvider.cxx
@@ -23,6 +23,7 @@
#include <dpobject.hxx>
#include <hints.hxx>
+#include <o3tl/safeint.hxx>
#include <vcl/svapp.hxx>
#include <sfx2/objsh.hxx>
#include <comphelper/propertysequence.hxx>
@@ -410,7 +411,7 @@ void PivotTableDataProvider::collectPivotTableData()
if (i >= m_aLabels.size())
m_aLabels.resize(i + 1);
- if (size_t(nDimPos) >= m_aLabels[i].size())
+ if (o3tl::make_unsigned(nDimPos) >= m_aLabels[i].size())
m_aLabels[i].resize(nDimPos + 1);
m_aLabels[i][nDimPos] = ValueAndFormat(sCaption);
@@ -459,11 +460,11 @@ void PivotTableDataProvider::collectPivotTableData()
if (i >= m_aCategoriesRowOrientation.size())
m_aCategoriesRowOrientation.resize(i + 1);
- if (size_t(nDimPos) >= m_aCategoriesColumnOrientation.size())
+ if (o3tl::make_unsigned(nDimPos) >= m_aCategoriesColumnOrientation.size())
m_aCategoriesColumnOrientation.resize(nDimPos + 1);
m_aCategoriesColumnOrientation[nDimPos].push_back(*pItem);
- if (size_t(nDimPos) >= m_aCategoriesRowOrientation[i].size())
+ if (o3tl::make_unsigned(nDimPos) >= m_aCategoriesRowOrientation[i].size())
m_aCategoriesRowOrientation[i].resize(nDimPos + 1);
m_aCategoriesRowOrientation[i][nDimPos] = *pItem;
diff --git a/sc/source/ui/unoobj/PivotTableDataSequence.cxx b/sc/source/ui/unoobj/PivotTableDataSequence.cxx
index 706cedd3e025..ad198c190452 100644
--- a/sc/source/ui/unoobj/PivotTableDataSequence.cxx
+++ b/sc/source/ui/unoobj/PivotTableDataSequence.cxx
@@ -12,7 +12,7 @@
#include <sal/config.h>
#include <sal/log.hxx>
-
+#include <o3tl/safeint.hxx>
#include <osl/diagnose.h>
#include <vcl/svapp.hxx>
@@ -152,7 +152,7 @@ sal_Int32 SAL_CALL PivotTableDataSequence::getNumberFormatKeyByIndex(sal_Int32 n
{
return m_aData[0].m_nNumberFormat;
}
- else if (nIndex < 0 && size_t(nIndex) >= m_aData.size())
+ else if (nIndex < 0 && o3tl::make_unsigned(nIndex) >= m_aData.size())
{
SAL_WARN("sc.ui", "Passed invalid index to getNumberFormatKeyByIndex(). Will return default value '0'.");
return 0;
diff --git a/sc/source/ui/unoobj/cellsuno.cxx b/sc/source/ui/unoobj/cellsuno.cxx
index dc1cd9c1e754..89cd63a9144d 100644
--- a/sc/source/ui/unoobj/cellsuno.cxx
+++ b/sc/source/ui/unoobj/cellsuno.cxx
@@ -19,6 +19,7 @@
#include <scitems.hxx>
#include <editeng/eeitem.hxx>
+#include <o3tl/safeint.hxx>
#include <svx/svdpool.hxx>
#include <vcl/svapp.hxx>
@@ -9286,7 +9287,7 @@ uno::Any SAL_CALL ScUniqueCellFormatsObj::getByIndex( sal_Int32 nIndex )
{
SolarMutexGuard aGuard;
- if(static_cast<sal_uInt32>(nIndex) >= aRangeLists.size())
+ if(o3tl::make_unsigned(nIndex) >= aRangeLists.size())
throw lang::IndexOutOfBoundsException();
return uno::makeAny(uno::Reference<sheet::XSheetCellRangeContainer>(new ScCellRangesObj(pDocShell, aRangeLists[nIndex])));
@@ -9349,7 +9350,7 @@ void ScUniqueCellFormatsEnumeration::Notify( SfxBroadcaster&, const SfxHint& rHi
sal_Bool SAL_CALL ScUniqueCellFormatsEnumeration::hasMoreElements()
{
SolarMutexGuard aGuard;
- return static_cast<sal_uInt32>(nCurrentPosition) < aRangeLists.size();
+ return o3tl::make_unsigned(nCurrentPosition) < aRangeLists.size();
}
uno::Any SAL_CALL ScUniqueCellFormatsEnumeration::nextElement()
diff --git a/sc/source/ui/unoobj/chart2uno.cxx b/sc/source/ui/unoobj/chart2uno.cxx
index ab8ae531690e..b1cbba83bb77 100644
--- a/sc/source/ui/unoobj/chart2uno.cxx
+++ b/sc/source/ui/unoobj/chart2uno.cxx
@@ -44,6 +44,7 @@
#include <brdcst.hxx>
#include <formula/opcode.hxx>
+#include <o3tl/safeint.hxx>
#include <svl/sharedstring.hxx>
#include <sfx2/objsh.hxx>
@@ -164,7 +165,7 @@ struct TokenTable
void push_back( std::unique_ptr<FormulaToken> pToken )
{
maTokens.push_back( std::move(pToken) );
- OSL_ENSURE( maTokens.size()<= static_cast<sal_uInt32>( mnColCount*mnRowCount ), "too many tokens" );
+ OSL_ENSURE( maTokens.size()<= o3tl::make_unsigned( mnColCount*mnRowCount ), "too many tokens" );
}
sal_uInt32 getIndex(SCCOL nCol, SCROW nRow) const
@@ -172,7 +173,7 @@ struct TokenTable
OSL_ENSURE( nCol<mnColCount, "wrong column index" );
OSL_ENSURE( nRow<mnRowCount, "wrong row index" );
sal_uInt32 nRet = static_cast<sal_uInt32>(nCol*mnRowCount + nRow);
- OSL_ENSURE( maTokens.size()>= static_cast<sal_uInt32>( mnColCount*mnRowCount ), "too few tokens" );
+ OSL_ENSURE( maTokens.size()>= o3tl::make_unsigned( mnColCount*mnRowCount ), "too few tokens" );
return nRet;
}
diff --git a/sc/source/ui/unoobj/condformatuno.cxx b/sc/source/ui/unoobj/condformatuno.cxx
index 038064c87cc3..692e3a9591a6 100644
--- a/sc/source/ui/unoobj/condformatuno.cxx
+++ b/sc/source/ui/unoobj/condformatuno.cxx
@@ -20,6 +20,7 @@
#include <cellsuno.hxx>
#include <convuno.hxx>
+#include <o3tl/safeint.hxx>
#include <vcl/svapp.hxx>
#include <rtl/ustring.hxx>
#include <sal/log.hxx>
@@ -509,7 +510,7 @@ void ScCondFormatObj::createEntry(const sal_Int32 nType, const sal_Int32 nPos)
void ScCondFormatObj::removeByIndex(const sal_Int32 nIndex)
{
SolarMutexGuard aGuard;
- if (getCoreObject()->size() >= size_t(nIndex))
+ if (getCoreObject()->size() >= o3tl::make_unsigned(nIndex))
throw lang::IllegalArgumentException();
getCoreObject()->RemoveEntry(nIndex);
@@ -538,7 +539,7 @@ sal_Int32 ScCondFormatObj::getCount()
uno::Any ScCondFormatObj::getByIndex(sal_Int32 nIndex)
{
SolarMutexGuard aGuard;
- if (getCoreObject()->size() <= size_t(nIndex))
+ if (getCoreObject()->size() <= o3tl::make_unsigned(nIndex))
throw lang::IllegalArgumentException();
const ScFormatEntry* pEntry = getCoreObject()->GetEntry(nIndex);
@@ -1587,7 +1588,7 @@ void SAL_CALL ScIconSetFormatObj::setPropertyValue(
// TODO: we need to check that the number of entries
// corresponds to the icon type
sal_Int32 nLength = aEntries.getLength();
- for (size_t i = 0; i < size_t(nLength); ++i)
+ for (size_t i = 0; i < o3tl::make_unsigned(nLength); ++i)
{
setIconSetEntry(getCoreObject(), aEntries[i], i);
}
diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx
index 347102005723..a79540c7a20b 100644
--- a/sc/source/ui/unoobj/docuno.cxx
+++ b/sc/source/ui/unoobj/docuno.cxx
@@ -26,6 +26,7 @@
#include <editeng/editview.hxx>
#include <editeng/outliner.hxx>
#include <o3tl/any.hxx>
+#include <o3tl/safeint.hxx>
#include <svx/fmview.hxx>
#include <svx/svditer.hxx>
#include <svx/svdpage.hxx>
@@ -3242,10 +3243,10 @@ void ScModelObj::selectOpenCLDevice( sal_Int32 nPlatform, sal_Int32 nDevice )
#else
std::vector<OpenCLPlatformInfo> aPlatformInfo;
sc::FormulaGroupInterpreter::fillOpenCLInfo(aPlatformInfo);
- if(size_t(nPlatform) >= aPlatformInfo.size())
+ if(o3tl::make_unsigned(nPlatform) >= aPlatformInfo.size())
throw uno::RuntimeException();
- if(size_t(nDevice) >= aPlatformInfo[nPlatform].maDevices.size())
+ if(o3tl::make_unsigned(nDevice) >= aPlatformInfo[nPlatform].maDevices.size())
throw uno::RuntimeException();
OUString aDeviceString = aPlatformInfo[nPlatform].maVendor + " " + aPlatformInfo[nPlatform].maDevices[nDevice].maName;
diff --git a/sc/source/ui/vba/vbawindow.cxx b/sc/source/ui/vba/vbawindow.cxx
index 34e2e95d54b3..d7dda7c89f0d 100644
--- a/sc/source/ui/vba/vbawindow.cxx
+++ b/sc/source/ui/vba/vbawindow.cxx
@@ -31,6 +31,7 @@
#include <com/sun/star/container/XNamed.hpp>
#include <com/sun/star/view/DocumentZoomType.hpp>
#include <com/sun/star/table/CellRangeAddress.hpp>
+#include <o3tl/safeint.hxx>
#include <ooo/vba/excel/XApplication.hpp>
#include <ooo/vba/excel/XlWindowState.hpp>
#include <ooo/vba/excel/XlWindowView.hpp>
@@ -144,7 +145,7 @@ public:
virtual uno::Any SAL_CALL getByIndex( ::sal_Int32 Index ) override
{
if ( Index < 0
- || static_cast< Sheets::size_type >( Index ) >= sheets.size() )
+ || o3tl::make_unsigned( Index ) >= sheets.size() )
throw lang::IndexOutOfBoundsException();
return uno::makeAny( sheets[ Index ] );
diff --git a/sc/source/ui/vba/vbawindows.cxx b/sc/source/ui/vba/vbawindows.cxx
index b9b869f60412..26f621eb2330 100644
--- a/sc/source/ui/vba/vbawindows.cxx
+++ b/sc/source/ui/vba/vbawindows.cxx
@@ -23,6 +23,7 @@
#include <com/sun/star/frame/Desktop.hpp>
#include <cppuhelper/implbase.hxx>
#include <comphelper/sequence.hxx>
+#include <o3tl/safeint.hxx>
#include <rtl/ref.hxx>
#include "vbawindow.hxx"
@@ -160,7 +161,7 @@ public:
virtual uno::Any SAL_CALL getByIndex( ::sal_Int32 Index ) override
{
if ( Index < 0
- || static_cast< Components::size_type >( Index ) >= m_windows.size() )
+ || o3tl::make_unsigned( Index ) >= m_windows.size() )
throw lang::IndexOutOfBoundsException();
return makeAny( m_windows[ Index ] ); // returns xspreadsheetdoc
}
diff --git a/sc/source/ui/view/viewdata.cxx b/sc/source/ui/view/viewdata.cxx
index b719605dde56..cef40898bce6 100644
--- a/sc/source/ui/view/viewdata.cxx
+++ b/sc/source/ui/view/viewdata.cxx
@@ -19,7 +19,7 @@
#include <scitems.hxx>
#include <editeng/eeitem.hxx>
-
+#include <o3tl/safeint.hxx>
#include <sfx2/lokhelper.hxx>
#include <sfx2/viewfrm.hxx>
#include <editeng/adjustitem.hxx>
@@ -859,7 +859,7 @@ ScViewData::~ScViewData() COVERITY_NOEXCEPT_FALSE
void ScViewData::UpdateCurrentTab()
{
- assert(0 <= nTabNo && static_cast<size_t>(nTabNo) < maTabData.size());
+ assert(0 <= nTabNo && o3tl::make_unsigned(nTabNo) < maTabData.size());
pThisTab = maTabData[nTabNo].get();
while (!pThisTab)
{
@@ -911,7 +911,7 @@ void ScViewData::DeleteTab( SCTAB nTab )
assert(nTab < static_cast<SCTAB>(maTabData.size()));
maTabData.erase(maTabData.begin() + nTab);
- if (static_cast<size_t>(nTabNo) >= maTabData.size())
+ if (o3tl::make_unsigned(nTabNo) >= maTabData.size())
{
EnsureTabDataSize(1);
nTabNo = maTabData.size() - 1;
@@ -927,7 +927,7 @@ void ScViewData::DeleteTabs( SCTAB nTab, SCTAB nSheets )
mpMarkData->DeleteTab( nTab + i );
}
maTabData.erase(maTabData.begin() + nTab, maTabData.begin()+ nTab+nSheets);
- if (static_cast<size_t>(nTabNo) >= maTabData.size())
+ if (o3tl::make_unsigned(nTabNo) >= maTabData.size())
{
EnsureTabDataSize(1);
nTabNo = maTabData.size() - 1;