diff options
Diffstat (limited to 'sw')
37 files changed, 114 insertions, 67 deletions
diff --git a/sw/qa/extras/globalfilter/globalfilter.cxx b/sw/qa/extras/globalfilter/globalfilter.cxx index f0d61355ea86..4ec7563ff324 100644 --- a/sw/qa/extras/globalfilter/globalfilter.cxx +++ b/sw/qa/extras/globalfilter/globalfilter.cxx @@ -12,6 +12,7 @@ #include <com/sun/star/awt/XBitmap.hpp> #include <com/sun/star/graphic/XGraphic.hpp> #include <com/sun/star/graphic/GraphicType.hpp> +#include <o3tl/safeint.hxx> #include <officecfg/Office/Common.hxx> #include <sfx2/linkmgr.hxx> #include <comphelper/propertysequence.hxx> @@ -1056,7 +1057,7 @@ void Test::testBulletAsImage() CPPUNIT_ASSERT_MESSAGE(sFailedMessage.getStr(), xBitmap.is()); Graphic aGraphic(uno::Reference<graphic::XGraphic>(xBitmap, uno::UNO_QUERY)); CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), GraphicType::Bitmap, aGraphic.GetType()); - CPPUNIT_ASSERT_MESSAGE(sFailedMessage.getStr(), aGraphic.GetSizeBytes() > sal_uLong(0)); + CPPUNIT_ASSERT_MESSAGE(sFailedMessage.getStr(), aGraphic.GetSizeBytes() > o3tl::make_unsigned(0)); CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), 16L, aGraphic.GetSizePixel().Width()); CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), 16L, aGraphic.GetSizePixel().Height()); @@ -1116,7 +1117,7 @@ void Test::testBulletAsImage() CPPUNIT_ASSERT_MESSAGE(sFailedMessage.getStr(), xBitmap.is()); Graphic aGraphic(uno::Reference<graphic::XGraphic>(xBitmap, uno::UNO_QUERY)); CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), GraphicType::Bitmap, aGraphic.GetType()); - CPPUNIT_ASSERT_MESSAGE(sFailedMessage.getStr(), aGraphic.GetSizeBytes() > sal_uLong(0)); + CPPUNIT_ASSERT_MESSAGE(sFailedMessage.getStr(), aGraphic.GetSizeBytes() > o3tl::make_unsigned(0)); CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), 16L, aGraphic.GetSizePixel().Width()); CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), 16L, aGraphic.GetSizePixel().Height()); diff --git a/sw/source/core/access/accselectionhelper.cxx b/sw/source/core/access/accselectionhelper.cxx index 8b1416b9d576..be92d4a2c5aa 100644 --- a/sw/source/core/access/accselectionhelper.cxx +++ b/sw/source/core/access/accselectionhelper.cxx @@ -22,6 +22,7 @@ #include "acccontext.hxx" #include <accmap.hxx> +#include <o3tl/safeint.hxx> #include <svx/AccessibleShape.hxx> #include <viewsh.hxx> #include <fesh.hxx> @@ -225,7 +226,7 @@ sal_Int32 SwAccessibleSelectionHelper::getSelectedAccessibleChildCount( ) { nCount++; } - if (static_cast<size_t>(nCount) >= nSelObjs) + if (o3tl::make_unsigned(nCount) >= nSelObjs) break; } } @@ -284,7 +285,7 @@ Reference<XAccessible> SwAccessibleSelectionHelper::getSelectedAccessibleChild( else { const size_t nSelObjs = pFEShell->IsObjSelected(); - if( 0 == nSelObjs || static_cast<size_t>(nSelectedChildIndex) >= nSelObjs ) + if( 0 == nSelObjs || o3tl::make_unsigned(nSelectedChildIndex) >= nSelObjs ) throwIndexOutOfBoundsException(); std::list< SwAccessibleChild > aChildren; diff --git a/sw/source/core/access/acctable.cxx b/sw/source/core/access/acctable.cxx index 0a2fc87c75f8..d3cf02d8291a 100644 --- a/sw/source/core/access/acctable.cxx +++ b/sw/source/core/access/acctable.cxx @@ -27,6 +27,7 @@ #include <com/sun/star/accessibility/AccessibleTableModelChange.hpp> #include <com/sun/star/accessibility/AccessibleTableModelChangeType.hpp> #include <com/sun/star/lang/IndexOutOfBoundsException.hpp> +#include <o3tl/safeint.hxx> #include <unotools/accessiblestatesethelper.hxx> #include <vcl/svapp.hxx> #include <frmfmt.hxx> @@ -488,9 +489,9 @@ uno::Sequence < sal_Int32 > SwAccAllTableSelHander_Impl::GetSelSequence() void SwAccAllTableSelHander_Impl::Unselect( sal_Int32 nRowOrCol, sal_Int32 nExt ) { - OSL_ENSURE( static_cast< size_t >( nRowOrCol ) < m_aSelected.size(), + OSL_ENSURE( o3tl::make_unsigned( nRowOrCol ) < m_aSelected.size(), "index too large" ); - OSL_ENSURE( static_cast< size_t >( nRowOrCol+nExt ) <= m_aSelected.size(), + OSL_ENSURE( o3tl::make_unsigned( nRowOrCol+nExt ) <= m_aSelected.size(), "extent too large" ); while( nExt ) { diff --git a/sw/source/core/crsr/findtxt.cxx b/sw/source/core/crsr/findtxt.cxx index 729fef65c063..ec1dc65d63a6 100644 --- a/sw/source/core/crsr/findtxt.cxx +++ b/sw/source/core/crsr/findtxt.cxx @@ -22,6 +22,7 @@ #include <com/sun/star/util/SearchFlags.hpp> #include <com/sun/star/util/SearchResult.hpp> #include <comphelper/lok.hxx> +#include <o3tl/safeint.hxx> #include <svx/svdview.hxx> #include <svl/srchitem.hxx> #include <sfx2/sfxsids.hrc> @@ -620,7 +621,7 @@ bool FindTextImpl(SwPaM & rSearchPam, AmbiguousIndex nEndInside; sal_Int32 aLoop = bSrchForward ? 0 : postits.size(); - while ((0 <= aLoop) && (static_cast<size_t>(aLoop) <= postits.size())) + while ((0 <= aLoop) && (o3tl::make_unsigned(aLoop) <= postits.size())) { if (bSrchForward) { diff --git a/sw/source/core/doc/DocumentContentOperationsManager.cxx b/sw/source/core/doc/DocumentContentOperationsManager.cxx index 7c880c26ff68..4a412897da24 100644 --- a/sw/source/core/doc/DocumentContentOperationsManager.cxx +++ b/sw/source/core/doc/DocumentContentOperationsManager.cxx @@ -66,6 +66,7 @@ #include <hints.hxx> #include <fmtflcnt.hxx> #include <docedt.hxx> +#include <o3tl/safeint.hxx> #include <sal/log.hxx> #include <unotools/charclass.hxx> #include <unotools/configmgr.hxx> @@ -668,7 +669,7 @@ namespace { const sal_uInt64 nSum = pStt->nContent.GetIndex() + pEndNd->GetText().getLength() - pEnd->nContent.GetIndex(); - return nSum > static_cast<sal_uInt64>(SAL_MAX_INT32); + return nSum > o3tl::make_unsigned(SAL_MAX_INT32); } } return false; diff --git a/sw/source/core/doc/doccomp.cxx b/sw/source/core/doc/doccomp.cxx index cc58624de54c..4576e7077760 100644 --- a/sw/source/core/doc/doccomp.cxx +++ b/sw/source/core/doc/doccomp.cxx @@ -17,6 +17,9 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include <sal/config.h> + +#include <o3tl/safeint.hxx> #include <osl/diagnose.h> #include <rtl/character.hxx> #include <swmodule.hxx> @@ -878,7 +881,7 @@ sal_uLong Compare::CompareSequence::CheckDiag( sal_uLong nStt1, sal_uLong nEnd1, else x = thi; y = x - d; - while( sal_uLong(x) < nEnd1 && sal_uLong(y) < nEnd2 && + while( o3tl::make_unsigned(x) < nEnd1 && o3tl::make_unsigned(y) < nEnd2 && rMoved1.GetIndex( x ) == rMoved2.GetIndex( y )) { ++x; @@ -910,7 +913,7 @@ sal_uLong Compare::CompareSequence::CheckDiag( sal_uLong nStt1, sal_uLong nEnd1, else x = thi - 1; y = x - d; - while( sal_uLong(x) > nStt1 && sal_uLong(y) > nStt2 && + while( o3tl::make_unsigned(x) > nStt1 && o3tl::make_unsigned(y) > nStt2 && rMoved1.GetIndex( x - 1 ) == rMoved2.GetIndex( y - 1 )) { --x; diff --git a/sw/source/core/doc/docnum.cxx b/sw/source/core/doc/docnum.cxx index f28a1562a8af..f4f83dcd56ab 100644 --- a/sw/source/core/doc/docnum.cxx +++ b/sw/source/core/doc/docnum.cxx @@ -48,6 +48,7 @@ #include <calbck.hxx> #include <comphelper/string.hxx> #include <comphelper/random.hxx> +#include <o3tl/safeint.hxx> #include <tools/datetimeutils.hxx> #include <map> @@ -518,7 +519,7 @@ bool SwDoc::MoveOutlinePara( const SwPaM& rPam, SwOutlineNodes::difference_type ++aEndRg; // calculation of the new position - if( nOffset < 0 && nCurrentPos < SwOutlineNodes::size_type(-nOffset) ) + if( nOffset < 0 && nCurrentPos < o3tl::make_unsigned(-nOffset) ) pNd = GetNodes().GetEndOfContent().StartOfSectionNode(); else if( nCurrentPos + nOffset >= GetNodes().GetOutLineNds().size() ) pNd = &GetNodes().GetEndOfContent(); @@ -1987,7 +1988,7 @@ bool SwDoc::MoveParagraphImpl(SwPaM& rPam, long const nOffset, else { // Impossible to move to negative index - if( sal_uLong(std::abs( nOffset )) > nStIdx) + if( o3tl::make_unsigned(std::abs( nOffset )) > nStIdx) return false; nInEndIdx = nStIdx - 1; diff --git a/sw/source/core/edit/edglss.cxx b/sw/source/core/edit/edglss.cxx index 7d691913435a..b35c45a6fcf2 100644 --- a/sw/source/core/edit/edglss.cxx +++ b/sw/source/core/edit/edglss.cxx @@ -17,6 +17,9 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include <sal/config.h> + +#include <o3tl/safeint.hxx> #include <osl/endian.h> #include <tools/urlobj.hxx> #include <doc.hxx> @@ -311,7 +314,7 @@ void SwEditShell::GetSelectedText( OUString &rBuf, ParaBreakType nHndlParaBrk ) else { const sal_uInt64 nLen = aStream.GetSize(); - OSL_ENSURE( nLen/sizeof( sal_Unicode )<static_cast<sal_uInt64>(SAL_MAX_INT32), "Stream can't fit in OUString" ); + OSL_ENSURE( nLen/sizeof( sal_Unicode )<o3tl::make_unsigned(SAL_MAX_INT32), "Stream can't fit in OUString" ); rtl_uString *pStr = rtl_uString_alloc(static_cast<sal_Int32>(nLen / sizeof( sal_Unicode ))); aStream.Seek( 0 ); aStream.ResetError(); diff --git a/sw/source/core/fields/cellfml.cxx b/sw/source/core/fields/cellfml.cxx index c4232accddfa..e7e3830f6983 100644 --- a/sw/source/core/fields/cellfml.cxx +++ b/sw/source/core/fields/cellfml.cxx @@ -44,6 +44,7 @@ #include <cellatr.hxx> #include <ndindex.hxx> #include <comphelper/string.hxx> +#include <o3tl/safeint.hxx> namespace { @@ -796,14 +797,14 @@ static const SwTableBox* lcl_RelToBox( const SwTable& rTable, nLineOffset < 0 ) return nullptr; - if( static_cast<size_t>(nLineOffset) >= pLines->size() ) + if( o3tl::make_unsigned(nLineOffset) >= pLines->size() ) return nullptr; pLine = (*pLines)[ nLineOffset ]; // ... then search the box pBoxes = &pLine->GetTabBoxes(); - if( static_cast<size_t>(nBoxOffset) >= pBoxes->size() ) + if( o3tl::make_unsigned(nBoxOffset) >= pBoxes->size() ) return nullptr; pBox = (*pBoxes)[ nBoxOffset ]; diff --git a/sw/source/core/text/itradj.cxx b/sw/source/core/text/itradj.cxx index 6c511f63f429..b1b712db4274 100644 --- a/sw/source/core/text/itradj.cxx +++ b/sw/source/core/text/itradj.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 <IDocumentSettingAccess.hxx> #include <doc.hxx> @@ -127,7 +131,7 @@ static bool lcl_CheckKashidaPositions( SwScriptInfo& rSI, SwTextSizeInfo& rInf, // if two characters are replaced by a ligature glyph, there will be no place for a kashida std::vector<TextFrameIndex> aKashidaPos; rSI.GetKashidaPositions(nIdx, rItr.GetLength(), aKashidaPos); - assert(aKashidaPos.size() >= static_cast<size_t>(rKashidas)); + assert(aKashidaPos.size() >= o3tl::make_unsigned(rKashidas)); std::vector<TextFrameIndex> aKashidaPosDropped(aKashidaPos.size()); sal_Int32 nKashidaIdx = 0; while ( rKashidas && nIdx < nEnd ) diff --git a/sw/source/core/text/redlnitr.cxx b/sw/source/core/text/redlnitr.cxx index 39868efa72d3..6d3881533ac0 100644 --- a/sw/source/core/text/redlnitr.cxx +++ b/sw/source/core/text/redlnitr.cxx @@ -22,6 +22,7 @@ #include <string_view> #include <hintids.hxx> +#include <o3tl/safeint.hxx> #include <svl/whiter.hxx> #include <com/sun/star/i18n/ScriptType.hpp> #include <scriptinfo.hxx> @@ -911,7 +912,7 @@ sal_Int32 SwExtend::Next(sal_uLong const nNode, sal_Int32 nNext) { sal_Int32 nIdx = m_nPos - m_nStart; const ExtTextInputAttr nAttr = m_rArr[ nIdx ]; - while (static_cast<size_t>(++nIdx) < m_rArr.size() && nAttr == m_rArr[nIdx]) + while (o3tl::make_unsigned(++nIdx) < m_rArr.size() && nAttr == m_rArr[nIdx]) ; //nothing nIdx = nIdx + m_nStart; if( nNext > nIdx ) diff --git a/sw/source/core/tox/ToxWhitespaceStripper.cxx b/sw/source/core/tox/ToxWhitespaceStripper.cxx index fc51a94c2e33..b2fe68727714 100644 --- a/sw/source/core/tox/ToxWhitespaceStripper.cxx +++ b/sw/source/core/tox/ToxWhitespaceStripper.cxx @@ -9,6 +9,7 @@ #include <ToxWhitespaceStripper.hxx> +#include <o3tl/safeint.hxx> #include <rtl/ustrbuf.hxx> #include <sal/log.hxx> @@ -49,7 +50,7 @@ sal_Int32 ToxWhitespaceStripper::GetPositionInStrippedString(sal_Int32 pos) const { assert(0 <= pos); - if (static_cast<size_t>(pos) >= mNewPositions.size()) { + if (o3tl::make_unsigned(pos) >= mNewPositions.size()) { // TODO probably this should assert, not just warn? SAL_WARN("sw.core", "Requested position of TOX entry text which does not exist. " "Maybe the formatting hint is corrupt?"); diff --git a/sw/source/core/txtnode/txtedt.cxx b/sw/source/core/txtnode/txtedt.cxx index 54af3640e13b..e7f6a326dae2 100644 --- a/sw/source/core/txtnode/txtedt.cxx +++ b/sw/source/core/txtnode/txtedt.cxx @@ -27,6 +27,7 @@ #include <editeng/hangulhanja.hxx> #include <i18nutil/transliteration.hxx> #include <SwSmartTagMgr.hxx> +#include <o3tl/safeint.hxx> #include <officecfg/Office/Writer.hxx> #include <unotools/transliterationwrapper.hxx> #include <unotools/charclass.hxx> @@ -1904,7 +1905,7 @@ void SwTextNode::TransliterateText( swTransliterationChgData & rData = aChanges[ aChanges.size() - 1 - i ]; nSum += rData.sChanged.getLength() - rData.nLen; - if (nSum > static_cast<size_t>(GetSpaceLeft())) + if (nSum > o3tl::make_unsigned(GetSpaceLeft())) { SAL_WARN("sw.core", "SwTextNode::ReplaceTextOnly: " "node text with insertion > node capacity."); diff --git a/sw/source/core/unocore/unocoll.cxx b/sw/source/core/unocore/unocoll.cxx index bf8ea87af1e4..a0f972f85628 100644 --- a/sw/source/core/unocore/unocoll.cxx +++ b/sw/source/core/unocore/unocoll.cxx @@ -32,6 +32,7 @@ #include <fmtftn.hxx> #include <txtftn.hxx> #include <com/sun/star/text/XTextTable.hpp> +#include <o3tl/safeint.hxx> #include <svtools/unoimap.hxx> #include <svtools/unoevent.hxx> #include <unotbl.hxx> @@ -1410,7 +1411,7 @@ uno::Any SwXTextSections::getByIndex(sal_Int32 nIndex) if(static_cast<size_t>(nIndex) == i) break; } - if(!(nIndex >= 0 && static_cast<size_t>(nIndex) < rFormats.size())) + if(!(nIndex >= 0 && o3tl::make_unsigned(nIndex) < rFormats.size())) throw IndexOutOfBoundsException(); SwSectionFormat* pFormat = rFormats[nIndex]; @@ -1699,7 +1700,7 @@ uno::Any SwXNumberingRulesCollection::getByIndex(sal_Int32 nIndex) throw uno::RuntimeException(); uno::Reference< XIndexReplace > xRef; - if ( static_cast<size_t>(nIndex) < GetDoc()->GetNumRuleTable().size() ) + if ( o3tl::make_unsigned(nIndex) < GetDoc()->GetNumRuleTable().size() ) { xRef = new SwXNumberingRules( *GetDoc()->GetNumRuleTable()[ nIndex ], GetDoc()); aRet <<= xRef; diff --git a/sw/source/core/unocore/unofield.cxx b/sw/source/core/unocore/unofield.cxx index 4254b3fa42c6..0067dff27216 100644 --- a/sw/source/core/unocore/unofield.cxx +++ b/sw/source/core/unocore/unofield.cxx @@ -79,6 +79,7 @@ #include <svl/listener.hxx> #include <svx/dataaccessdescriptor.hxx> #include <o3tl/any.hxx> +#include <o3tl/safeint.hxx> #include <osl/mutex.hxx> #include <vcl/svapp.hxx> #include <textapi.hxx> @@ -1029,7 +1030,7 @@ OUString SwXFieldMaster::GetProgrammaticName(const SwFieldType& rType, SwDoc& rD if(SwFieldIds::SetExp == rType.Which()) { const SwFieldTypes* pTypes = rDoc.getIDocumentFieldsAccess().GetFieldTypes(); - for( size_t i = 0; i <= size_t(INIT_FLDTYPES); i++ ) + for( size_t i = 0; i <= o3tl::make_unsigned(INIT_FLDTYPES); i++ ) { if((*pTypes)[i].get() == &rType) { diff --git a/sw/source/core/unocore/unoflatpara.cxx b/sw/source/core/unocore/unoflatpara.cxx index 6a1546372361..15ffb4441aa7 100644 --- a/sw/source/core/unocore/unoflatpara.cxx +++ b/sw/source/core/unocore/unoflatpara.cxx @@ -21,6 +21,7 @@ #include <unocrsrhelper.hxx> #include <unoflatpara.hxx> +#include <o3tl/safeint.hxx> #include <vcl/svapp.hxx> #include <com/sun/star/text/TextMarkupType.hpp> #include <com/sun/star/beans/PropertyAttribute.hpp> @@ -250,7 +251,7 @@ void SAL_CALL SwXFlatParagraph::changeText(::sal_Int32 nPos, ::sal_Int32 nLen, c SwTextNode *const pOldTextNode = GetTextNode(); - if (nPos < 0 || pOldTextNode->Len() < nPos || nLen < 0 || static_cast<sal_uInt32>(pOldTextNode->Len()) < static_cast<sal_uInt32>(nPos) + nLen) + if (nPos < 0 || pOldTextNode->Len() < nPos || nLen < 0 || o3tl::make_unsigned(pOldTextNode->Len()) < static_cast<sal_uInt32>(nPos) + nLen) { throw lang::IllegalArgumentException(); } @@ -283,7 +284,7 @@ void SAL_CALL SwXFlatParagraph::changeAttributes(::sal_Int32 nPos, ::sal_Int32 n if (!GetTextNode()) return; - if (nPos < 0 || GetTextNode()->Len() < nPos || nLen < 0 || static_cast<sal_uInt32>(GetTextNode()->Len()) < static_cast<sal_uInt32>(nPos) + nLen) + if (nPos < 0 || GetTextNode()->Len() < nPos || nLen < 0 || o3tl::make_unsigned(GetTextNode()->Len()) < static_cast<sal_uInt32>(nPos) + nLen) { throw lang::IllegalArgumentException(); } diff --git a/sw/source/core/unocore/unoobj.cxx b/sw/source/core/unocore/unoobj.cxx index 612adeb01e90..ddd352386d11 100644 --- a/sw/source/core/unocore/unoobj.cxx +++ b/sw/source/core/unocore/unoobj.cxx @@ -22,6 +22,7 @@ #include <cppuhelper/supportsservice.hxx> #include <svl/itemprop.hxx> #include <o3tl/any.hxx> +#include <o3tl/safeint.hxx> #include <osl/endian.h> #include <unotools/collatorwrapper.hxx> #include <swtypes.hxx> @@ -156,7 +157,7 @@ void SwUnoCursorHelper::GetTextFromPam(SwPaM & rPam, OUString & rBuffer, if( ! aWriter.Write( xWrt ).IsError() ) { const sal_uInt64 lUniLen = aStream.GetSize()/sizeof( sal_Unicode ); - if (lUniLen < static_cast<sal_uInt64>(SAL_MAX_INT32-1)) + if (lUniLen < o3tl::make_unsigned(SAL_MAX_INT32-1)) { aStream.WriteUInt16( '\0' ); diff --git a/sw/source/core/unocore/unoobj2.cxx b/sw/source/core/unocore/unoobj2.cxx index a4708d249970..417370f05980 100644 --- a/sw/source/core/unocore/unoobj2.cxx +++ b/sw/source/core/unocore/unoobj2.cxx @@ -21,6 +21,7 @@ #include <comphelper/servicehelper.hxx> #include <cppuhelper/supportsservice.hxx> +#include <o3tl/safeint.hxx> #include <svl/listener.hxx> #include <svx/svdobj.hxx> #include <vcl/svapp.hxx> @@ -1487,7 +1488,7 @@ sal_Int32 SAL_CALL SwXTextRangesImpl::getCount() uno::Any SAL_CALL SwXTextRangesImpl::getByIndex(sal_Int32 nIndex) { SolarMutexGuard aGuard; - if ((nIndex < 0) || (static_cast<size_t>(nIndex) >= m_Ranges.size())) + if ((nIndex < 0) || (o3tl::make_unsigned(nIndex) >= m_Ranges.size())) throw lang::IndexOutOfBoundsException(); uno::Any ret; ret <<= m_Ranges.at(nIndex); diff --git a/sw/source/core/unocore/unoredlines.cxx b/sw/source/core/unocore/unoredlines.cxx index 9e1db2b8e637..bbab06ed6a13 100644 --- a/sw/source/core/unocore/unoredlines.cxx +++ b/sw/source/core/unocore/unoredlines.cxx @@ -22,6 +22,7 @@ #include <cppuhelper/supportsservice.hxx> #include <vcl/svapp.hxx> +#include <o3tl/safeint.hxx> #include <osl/diagnose.h> #include <unoredlines.hxx> @@ -59,7 +60,7 @@ uno::Any SwXRedlines::getByIndex(sal_Int32 nIndex) if(!IsValid()) throw uno::RuntimeException(); const SwRedlineTable& rRedTable = GetDoc()->getIDocumentRedlineAccess().GetRedlineTable(); - if ((rRedTable.size() <= static_cast<size_t>(nIndex)) || (nIndex < 0)) + if ((nIndex < 0) || (rRedTable.size() <= o3tl::make_unsigned(nIndex))) throw lang::IndexOutOfBoundsException(); uno::Reference <beans::XPropertySet> xRet = SwXRedlines::GetObject( *rRedTable[nIndex], *GetDoc() ); diff --git a/sw/source/core/unocore/unostyle.cxx b/sw/source/core/unocore/unostyle.cxx index 4ca49fee3864..7301c7afb8fa 100644 --- a/sw/source/core/unocore/unostyle.cxx +++ b/sw/source/core/unocore/unostyle.cxx @@ -17,6 +17,9 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include <sal/config.h> + +#include <o3tl/safeint.hxx> #include <svx/svxids.hrc> #include <hintids.hxx> #include <vcl/svapp.hxx> @@ -4720,7 +4723,7 @@ SwBoxAutoFormat* SwXTextCellStyle::GetBoxAutoFormat(SwDocShell* pDocShell, const return nullptr; const auto& rTableTemplateMap = SwTableAutoFormat::GetTableTemplateMap(); - if (rTableTemplateMap.size() <= static_cast<size_t>(nTemplateIndex)) + if (rTableTemplateMap.size() <= o3tl::make_unsigned(nTemplateIndex)) return nullptr; SwTableAutoFormat* pTableAutoFormat = pDocShell->GetDoc()->GetTableStyles().FindAutoFormat(sParentName); diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx index 73b64b806968..779b1078c528 100644 --- a/sw/source/core/unocore/unotbl.cxx +++ b/sw/source/core/unocore/unotbl.cxx @@ -24,6 +24,7 @@ #include <algorithm> #include <o3tl/any.hxx> +#include <o3tl/safeint.hxx> #include <svx/svxids.hrc> #include <editeng/memberids.h> #include <float.h> @@ -4037,7 +4038,7 @@ uno::Any SwXTableRows::getByIndex(sal_Int32 nIndex) if(nIndex < 0) throw lang::IndexOutOfBoundsException(); SwTable* pTable = SwTable::FindTable( pFrameFormat ); - if(static_cast<size_t>(nIndex) >= pTable->GetTabLines().size()) + if(o3tl::make_unsigned(nIndex) >= pTable->GetTabLines().size()) throw lang::IndexOutOfBoundsException(); SwTableLine* pLine = pTable->GetTabLines()[nIndex]; FindUnoInstanceHint<SwTableLine,SwXTextTableRow> aHint{pLine}; @@ -4071,7 +4072,7 @@ void SwXTableRows::insertByIndex(sal_Int32 nIndex, sal_Int32 nCount) SwFrameFormat* pFrameFormat(lcl_EnsureCoreConnected(GetFrameFormat(), static_cast<cppu::OWeakObject*>(this))); SwTable* pTable = lcl_EnsureTableNotComplex(SwTable::FindTable(pFrameFormat), static_cast<cppu::OWeakObject*>(this)); const size_t nRowCount = pTable->GetTabLines().size(); - if (nCount <= 0 || !(0 <= nIndex && static_cast<size_t>(nIndex) <= nRowCount)) + if (nCount <= 0 || !(0 <= nIndex && o3tl::make_unsigned(nIndex) <= nRowCount)) throw uno::RuntimeException("Illegal arguments", static_cast<cppu::OWeakObject*>(this)); const OUString sTLName = sw_GetCellName(0, nIndex); const SwTableBox* pTLBox = pTable->GetTableBox(sTLName); @@ -4230,7 +4231,7 @@ void SwXTableColumns::insertByIndex(sal_Int32 nIndex, sal_Int32 nCount) SwTableLines& rLines = pTable->GetTabLines(); SwTableLine* pLine = rLines.front(); const size_t nColCount = pLine->GetTabBoxes().size(); - if (nCount <= 0 || !(0 <= nIndex && static_cast<size_t>(nIndex) <= nColCount)) + if (nCount <= 0 || !(0 <= nIndex && o3tl::make_unsigned(nIndex) <= nColCount)) throw uno::RuntimeException("Illegal arguments", static_cast<cppu::OWeakObject*>(this)); const OUString sTLName = sw_GetCellName(nIndex, 0); const SwTableBox* pTLBox = pTable->GetTableBox( sTLName ); diff --git a/sw/source/core/unocore/unotextmarkup.cxx b/sw/source/core/unocore/unotextmarkup.cxx index 1d4074d4462a..f20b47e15651 100644 --- a/sw/source/core/unocore/unotextmarkup.cxx +++ b/sw/source/core/unocore/unotextmarkup.cxx @@ -19,6 +19,7 @@ #include <unotextmarkup.hxx> +#include <o3tl/safeint.hxx> #include <osl/diagnose.h> #include <svl/listener.hxx> #include <vcl/svapp.hxx> @@ -513,7 +514,7 @@ void SAL_CALL SwXStringKeyMap::insertValue(const OUString & aKey, const uno::Any OUString SAL_CALL SwXStringKeyMap::getKeyByIndex(::sal_Int32 nIndex) { - if ( static_cast<sal_uInt32>(nIndex) >= maMap.size() ) + if ( o3tl::make_unsigned(nIndex) >= maMap.size() ) throw lang::IndexOutOfBoundsException(); return OUString(); @@ -521,7 +522,7 @@ OUString SAL_CALL SwXStringKeyMap::getKeyByIndex(::sal_Int32 nIndex) uno::Any SAL_CALL SwXStringKeyMap::getValueByIndex(::sal_Int32 nIndex) { - if ( static_cast<sal_uInt32>(nIndex) >= maMap.size() ) + if ( o3tl::make_unsigned(nIndex) >= maMap.size() ) throw lang::IndexOutOfBoundsException(); return uno::Any(); diff --git a/sw/source/filter/basflt/fltshell.cxx b/sw/source/filter/basflt/fltshell.cxx index deffb3c791f4..e6ab4c67fe47 100644 --- a/sw/source/filter/basflt/fltshell.cxx +++ b/sw/source/filter/basflt/fltshell.cxx @@ -20,6 +20,7 @@ #include <memory> #include <sal/config.h> #include <sal/log.hxx> +#include <o3tl/safeint.hxx> #include <osl/diagnose.h> #include <cstddef> @@ -355,7 +356,7 @@ SwFltStackEntry* SwFltControlStack::SetAttr(const SwPosition& rPos, OSL_ENSURE(!nAttrId || (POOLATTR_BEGIN <= nAttrId && POOLATTR_END > nAttrId) || - (RES_FLTRATTR_BEGIN <= nAttrId && sal_uInt16(RES_FLTRATTR_END) > nAttrId), + (RES_FLTRATTR_BEGIN <= nAttrId && o3tl::make_unsigned(RES_FLTRATTR_END) > nAttrId), "Wrong id for attribute"); auto aI = m_Entries.begin(); diff --git a/sw/source/filter/html/htmlplug.cxx b/sw/source/filter/html/htmlplug.cxx index bf35d49b244d..ddff54de50ab 100644 --- a/sw/source/filter/html/htmlplug.cxx +++ b/sw/source/filter/html/htmlplug.cxx @@ -76,6 +76,7 @@ #include <comphelper/propertysequence.hxx> #include <filter/msfilter/msoleexp.hxx> #include <comphelper/fileurl.hxx> +#include <o3tl/safeint.hxx> #include <osl/file.hxx> #include <comphelper/propertyvalue.hxx> @@ -1490,7 +1491,7 @@ Writer& OutHTML_FrameFormatOLENodeGrf( Writer& rWrt, const SwFrameFormat& rFrame aMediaDescriptor["FilterOptions"] <<= OUString("SkipHeaderFooter"); aMediaDescriptor["OutputStream"] <<= xOutputStream; xStorable->storeToURL("private:stream", aMediaDescriptor.getAsConstPropertyValueList()); - SAL_WARN_IF(aStream.GetSize()>=static_cast<sal_uInt64>(SAL_MAX_INT32), "sw.html", "Stream can't fit in OString"); + SAL_WARN_IF(aStream.GetSize()>=o3tl::make_unsigned(SAL_MAX_INT32), "sw.html", "Stream can't fit in OString"); OString aData(static_cast<const char*>(aStream.GetData()), static_cast<sal_Int32>(aStream.GetSize())); // Wrap output in a <span> tag to avoid 'HTML parser error: Unexpected end tag: p' HTMLOutFuncs::Out_AsciiTag(rWrt.Strm(), rHTMLWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_span); diff --git a/sw/source/filter/ww8/wrtww8.cxx b/sw/source/filter/ww8/wrtww8.cxx index 5815d7cb72b8..84bf1a645531 100644 --- a/sw/source/filter/ww8/wrtww8.cxx +++ b/sw/source/filter/ww8/wrtww8.cxx @@ -27,6 +27,7 @@ #include <map> #include <hintids.hxx> #include <string.h> +#include <o3tl/safeint.hxx> #include <osl/endian.h> #include <sal/log.hxx> #include <docsh.hxx> @@ -1205,7 +1206,7 @@ bool WW8_WrFkp::Append( WW8_FC nEndFc, sal_uInt16 nVarLen, const sal_uInt8* pSpr nPos &= 0xFFFE; // Pos for Sprms ( gerade Pos ) } - if( static_cast<sal_uInt16>(nPos) <= ( nIMax + 2U ) * 4U + ( nIMax + 1U ) * nItemSize ) + if( o3tl::make_unsigned(nPos) <= ( nIMax + 2U ) * 4U + ( nIMax + 1U ) * nItemSize ) // does it fits after the CPs and offsets? return false; // no @@ -1418,7 +1419,7 @@ void WW8_WrPct::SetParaBreak() WW8_CP WW8_WrPct::Fc2Cp( sal_uLong nFc ) const { - OSL_ENSURE( nFc >= static_cast<sal_uLong>(nOldFc), "FilePos lies in front of last piece" ); + OSL_ENSURE( nFc >= o3tl::make_unsigned(nOldFc), "FilePos lies in front of last piece" ); OSL_ENSURE( ! m_Pcts.empty(), "Fc2Cp no piece available" ); nFc -= nOldFc; diff --git a/sw/source/filter/ww8/ww8atr.cxx b/sw/source/filter/ww8/ww8atr.cxx index 6d3749b75d47..945badc3bfb1 100644 --- a/sw/source/filter/ww8/ww8atr.cxx +++ b/sw/source/filter/ww8/ww8atr.cxx @@ -24,6 +24,7 @@ #include <hintids.hxx> +#include <o3tl/safeint.hxx> #include <vcl/svapp.hxx> #include <vcl/settings.hxx> #include <sal/log.hxx> @@ -3750,7 +3751,7 @@ sal_uLong WW8Export::ReplaceCr( sal_uInt8 nChar ) SvStream& rStrm = Strm(); sal_uLong nRetPos = 0, nPos = rStrm.Tell(); //If there is at least two characters already output - if (nPos - 2 >= sal_uLong(pFib->m_fcMin)) + if (nPos - 2 >= o3tl::make_unsigned(pFib->m_fcMin)) { sal_uInt16 nUCode=0; @@ -3760,7 +3761,7 @@ sal_uLong WW8Export::ReplaceCr( sal_uInt8 nChar ) if (nUCode == 0x0d) // CR ? { if ((nChar == 0x0c) && - (nPos - 4 >= sal_uLong(pFib->m_fcMin))) + (nPos - 4 >= o3tl::make_unsigned(pFib->m_fcMin))) { rStrm.SeekRel(-4); rStrm.ReadUInt16( nUCode ); diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx index 92aa8e00c2e8..eaa7e9d957ae 100644 --- a/sw/source/filter/ww8/ww8par.cxx +++ b/sw/source/filter/ww8/ww8par.cxx @@ -127,6 +127,7 @@ #include <basic/basmgr.hxx> #include "ww8toolbar.hxx" +#include <o3tl/safeint.hxx> #include <osl/file.hxx> #include <breakit.hxx> @@ -2841,7 +2842,7 @@ rtl_TextEncoding SwWW8ImplReader::GetCurrentCharSet() eSrcCharSet = GetCharSetFromLanguage(); else if (!m_aFontSrcCharSets.empty()) eSrcCharSet = m_aFontSrcCharSets.top(); - if ((eSrcCharSet == RTL_TEXTENCODING_DONTKNOW) && m_nCharFormat >= 0 && static_cast<size_t>(m_nCharFormat) < m_vColl.size() ) + if ((eSrcCharSet == RTL_TEXTENCODING_DONTKNOW) && m_nCharFormat >= 0 && o3tl::make_unsigned(m_nCharFormat) < m_vColl.size() ) eSrcCharSet = m_vColl[m_nCharFormat].GetCharSet(); if ((eSrcCharSet == RTL_TEXTENCODING_DONTKNOW) && StyleExists(m_nCurrentColl) && m_nCurrentColl < m_vColl.size()) eSrcCharSet = m_vColl[m_nCurrentColl].GetCharSet(); @@ -2865,7 +2866,7 @@ rtl_TextEncoding SwWW8ImplReader::GetCurrentCJKCharSet() { if (!m_aFontSrcCJKCharSets.empty()) eSrcCharSet = m_aFontSrcCJKCharSets.top(); - if ((eSrcCharSet == RTL_TEXTENCODING_DONTKNOW) && m_nCharFormat >= 0 && static_cast<size_t>(m_nCharFormat) < m_vColl.size() ) + if ((eSrcCharSet == RTL_TEXTENCODING_DONTKNOW) && m_nCharFormat >= 0 && o3tl::make_unsigned(m_nCharFormat) < m_vColl.size() ) eSrcCharSet = m_vColl[m_nCharFormat].GetCJKCharSet(); if (eSrcCharSet == RTL_TEXTENCODING_DONTKNOW && StyleExists(m_nCurrentColl) && m_nCurrentColl < m_vColl.size()) eSrcCharSet = m_vColl[m_nCurrentColl].GetCJKCharSet(); @@ -3491,7 +3492,7 @@ bool SwWW8ImplReader::ReadChars(WW8_CP& rPos, WW8_CP nNextAttr, long nTextEnd, if (m_bSymbol) // Insert special chars { sal_uInt64 nMaxPossible = m_pStrm->remainingSize(); - if (static_cast<sal_uInt64>(nRequested) > nMaxPossible) + if (o3tl::make_unsigned(nRequested) > nMaxPossible) { SAL_WARN("sw.ww8", "document claims to have more characters, " << nRequested << " than remaining, " << nMaxPossible); nRequested = nMaxPossible; @@ -6548,7 +6549,7 @@ bool SwWW8ImplReader::InEqualApo(int nLvl) const // If we are in a table, see if an apo was inserted at the level below the table. if (nLvl) --nLvl; - if (nLvl < 0 || static_cast<size_t>(nLvl) >= m_aApos.size()) + if (nLvl < 0 || o3tl::make_unsigned(nLvl) >= m_aApos.size()) return false; return m_aApos[nLvl]; } diff --git a/sw/source/filter/ww8/ww8par2.cxx b/sw/source/filter/ww8/ww8par2.cxx index 53069581d400..8a52b7eb9641 100644 --- a/sw/source/filter/ww8/ww8par2.cxx +++ b/sw/source/filter/ww8/ww8par2.cxx @@ -21,6 +21,7 @@ #include <sal/log.hxx> #include <comphelper/string.hxx> +#include <o3tl/safeint.hxx> #include <tools/solar.h> #include <vcl/font.hxx> #include <hintids.hxx> @@ -786,7 +787,7 @@ void SwWW8ImplReader::Read_ANLevelDesc( sal_uInt16, const sal_uInt8* pData, shor return; } - if (static_cast<size_t>(nLen) < sizeof(WW8_ANLD)) + if (o3tl::make_unsigned(nLen) < sizeof(WW8_ANLD)) { SAL_WARN("sw.ww8", "ANLevelDesc property is " << nLen << " long, needs to be at least " << sizeof(WW8_ANLD)); m_nSwNumLevel = 0xff; @@ -854,7 +855,7 @@ void SwWW8ImplReader::Read_OLST( sal_uInt16, const sal_uInt8* pData, short nLen if (nLen <= 0) return; - if (static_cast<size_t>(nLen) < sizeof(WW8_OLST)) + if (o3tl::make_unsigned(nLen) < sizeof(WW8_OLST)) { SAL_WARN("sw.ww8", "WW8_OLST property is " << nLen << " long, needs to be at least " << sizeof(WW8_OLST)); return; @@ -2858,9 +2859,9 @@ WW8SelBoxInfo* WW8TabDesc::FindMergeGroup(short nX1, short nWidth, bool bExact) bool WW8TabDesc::IsValidCell(short nCol) const { - return (static_cast<size_t>(nCol) < SAL_N_ELEMENTS(m_pActBand->bExist)) && + return (o3tl::make_unsigned(nCol) < SAL_N_ELEMENTS(m_pActBand->bExist)) && m_pActBand->bExist[nCol] && - static_cast<sal_uInt16>(m_nCurrentRow) < m_pTabLines->size(); + o3tl::make_unsigned(m_nCurrentRow) < m_pTabLines->size(); } bool WW8TabDesc::InFirstParaInCell() const @@ -2886,7 +2887,7 @@ void WW8TabDesc::SetPamInCell(short nWwCol, bool bPam) sal_uInt16 nCol = m_pActBand->transCell(nWwCol); - if (static_cast<sal_uInt16>(m_nCurrentRow) >= m_pTabLines->size()) + if (o3tl::make_unsigned(m_nCurrentRow) >= m_pTabLines->size()) { OSL_ENSURE(false, "Actual row bigger than expected." ); if (bPam) diff --git a/sw/source/filter/ww8/ww8par6.cxx b/sw/source/filter/ww8/ww8par6.cxx index bb435b9a6485..9b1c95217cb8 100644 --- a/sw/source/filter/ww8/ww8par6.cxx +++ b/sw/source/filter/ww8/ww8par6.cxx @@ -18,6 +18,7 @@ */ #include <stdlib.h> +#include <o3tl/safeint.hxx> #include <svl/itemiter.hxx> #include <svl/grabbagitem.hxx> #include <rtl/tencinfo.h> @@ -598,7 +599,7 @@ void wwSectionManager::GetPageULData(const wwSection &rSection, // #i19922# - correction: // consider that <nWWUp> can be negative, compare only if it's positive if ( nWWUp > 0 && - static_cast<sal_uInt32>(abs(nWWUp)) >= nWWHTop ) + o3tl::make_unsigned(abs(nWWUp)) >= nWWHTop ) rData.nSwHLo = nWWUp - nWWHTop; else rData.nSwHLo = 0; @@ -616,7 +617,7 @@ void wwSectionManager::GetPageULData(const wwSection &rSection, rData.nSwLo = nWWFBot; // footer -> convert // #i19922# - correction: consider that <nWWLo> can be negative, compare only if it's positive if ( nWWLo > 0 && - static_cast<sal_uInt32>(abs(nWWLo)) >= nWWFBot ) + o3tl::make_unsigned(abs(nWWLo)) >= nWWFBot ) rData.nSwFUp = nWWLo - nWWFBot; else rData.nSwFUp = 0; diff --git a/sw/source/filter/ww8/ww8scan.cxx b/sw/source/filter/ww8/ww8scan.cxx index e3c5ac3a4098..89cba1fce16f 100644 --- a/sw/source/filter/ww8/ww8scan.cxx +++ b/sw/source/filter/ww8/ww8scan.cxx @@ -7108,7 +7108,7 @@ namespace { assert(p <= pEnd); assert(value != nullptr); - if (offset >= static_cast<std::size_t>(pEnd - p)) { + if (offset >= o3tl::make_unsigned(pEnd - p)) { return false; } *value = p[offset]; @@ -7121,7 +7121,7 @@ namespace { assert(p <= pEnd); assert(value != nullptr); - if (offset > static_cast<std::size_t>(pEnd - p) + if (offset > o3tl::make_unsigned(pEnd - p) || static_cast<std::size_t>(pEnd - p) - offset < 2) { return false; @@ -7135,7 +7135,7 @@ namespace { assert(p <= pEnd); assert(pEnd - p <= SAL_MAX_INT32); - if (offset >= static_cast<std::size_t>(pEnd - p)) { + if (offset >= o3tl::make_unsigned(pEnd - p)) { return -1; } void const * p2 = std::memchr( @@ -7163,7 +7163,7 @@ WW8Fonts::WW8Fonts( SvStream& rSt, WW8Fib const & rFib ) sal_Int32 nFFn = rFib.m_lcbSttbfffn - 2; const sal_uInt64 nMaxPossible = rSt.remainingSize(); - if (static_cast<sal_uInt64>(nFFn) > nMaxPossible) + if (o3tl::make_unsigned(nFFn) > nMaxPossible) { SAL_WARN("sw.ww8", "FFN structure longer than available data"); nFFn = nMaxPossible; diff --git a/sw/source/filter/ww8/ww8toolbar.cxx b/sw/source/filter/ww8/ww8toolbar.cxx index e4909b83da01..3cb4f4e335f9 100644 --- a/sw/source/filter/ww8/ww8toolbar.cxx +++ b/sw/source/filter/ww8/ww8toolbar.cxx @@ -19,6 +19,7 @@ #include <comphelper/documentinfo.hxx> #include <comphelper/processfactory.hxx> #include <comphelper/sequence.hxx> +#include <o3tl/safeint.hxx> #include <sfx2/objsh.hxx> #include <tools/diagnose_ex.h> #include <unotools/configmgr.hxx> @@ -165,7 +166,7 @@ bool SwCTBWrapper::Read( SvStream& rS ) } for ( const auto& rIndex : dropDownMenuIndices ) { - if (rIndex < 0 || static_cast<size_t>(rIndex) >= rCustomizations.size()) + if (rIndex < 0 || o3tl::make_unsigned(rIndex) >= rCustomizations.size()) continue; rCustomizations[rIndex].bIsDroppedMenuTB = true; } @@ -760,7 +761,7 @@ bool PlfMcd::Read(SvStream &rS) if (iMac < 0) return false; auto nMaxPossibleRecords = rS.remainingSize() / 24 /*sizeof MCD*/; - if (static_cast<sal_uInt32>(iMac) > nMaxPossibleRecords) + if (o3tl::make_unsigned(iMac) > nMaxPossibleRecords) { SAL_WARN("sw.ww8", iMac << " records claimed, but max possible is " << nMaxPossibleRecords); iMac = nMaxPossibleRecords; @@ -795,7 +796,7 @@ bool PlfAcd::Read( SvStream &rS) if (iMac < 0) return false; auto nMaxPossibleRecords = rS.remainingSize() / (sizeof(sal_uInt16)*2); - if (static_cast<sal_uInt32>(iMac) > nMaxPossibleRecords) + if (o3tl::make_unsigned(iMac) > nMaxPossibleRecords) { SAL_WARN("sw.ww8", iMac << " records claimed, but max possible is " << nMaxPossibleRecords); iMac = nMaxPossibleRecords; @@ -831,7 +832,7 @@ bool PlfKme::Read(SvStream &rS) { //each Kme is 14 bytes in size size_t nMaxAvailableRecords = rS.remainingSize() / 14; - if (static_cast<sal_uInt32>(iMac) > nMaxAvailableRecords) + if (o3tl::make_unsigned(iMac) > nMaxAvailableRecords) return false; rgkme.reset( new Kme[ iMac ] ); diff --git a/sw/source/ui/dbui/mmaddressblockpage.cxx b/sw/source/ui/dbui/mmaddressblockpage.cxx index a8545852032e..11d884ec6652 100644 --- a/sw/source/ui/dbui/mmaddressblockpage.cxx +++ b/sw/source/ui/dbui/mmaddressblockpage.cxx @@ -22,6 +22,7 @@ #include <swtypes.hxx> #include "addresslistdialog.hxx" #include <editeng/eeitem.hxx> +#include <o3tl/safeint.hxx> #include <svl/grabbagitem.hxx> #include <svl/itemset.hxx> #include <vcl/event.hxx> @@ -864,7 +865,7 @@ void SwAssignFieldsControl::Init(SwAssignFieldsDialog* pDialog, SwMailMergeConfi rNewLB.append_text(rField); //select the ListBox //if there is an assignment - if(static_cast<sal_uInt32>(aAssignments.getLength()) > i && !aAssignments[i].isEmpty()) + if(o3tl::make_unsigned(aAssignments.getLength()) > i && !aAssignments[i].isEmpty()) rNewLB.set_active_text(aAssignments[i]); else //otherwise the current column name may match one of the db columns rNewLB.set_active_text(rHeader); diff --git a/sw/source/ui/fldui/fldref.cxx b/sw/source/ui/fldui/fldref.cxx index a64f2eb20831..9a94726ad74d 100644 --- a/sw/source/ui/fldui/fldref.cxx +++ b/sw/source/ui/fldui/fldref.cxx @@ -33,6 +33,7 @@ #include <unotools/charclass.hxx> #include <comphelper/string.hxx> +#include <o3tl/safeint.hxx> #define REFFLDFLAG 0x4000 #define REFFLDFLAG_BOOKMARK 0x4800 @@ -191,7 +192,7 @@ void SwFieldRefPage::Reset(const SfxItemSet* ) const size_t nFieldTypeCnt = pSh->GetFieldTypeCount(SwFieldIds::SetExp); - OSL_ENSURE( nFieldTypeCnt < static_cast<size_t>(REFFLDFLAG), "<SwFieldRefPage::Reset> - Item index will overlap flags!" ); + OSL_ENSURE( nFieldTypeCnt < o3tl::make_unsigned(REFFLDFLAG), "<SwFieldRefPage::Reset> - Item index will overlap flags!" ); for (size_t n = 0; n < nFieldTypeCnt; ++n) { diff --git a/sw/source/ui/frmdlg/frmpage.cxx b/sw/source/ui/frmdlg/frmpage.cxx index 5ba7541fb468..00188e194f9a 100644 --- a/sw/source/ui/frmdlg/frmpage.cxx +++ b/sw/source/ui/frmdlg/frmpage.cxx @@ -24,6 +24,7 @@ #include <cmdid.h> #include <hintids.hxx> #include <bitmaps.hlst> +#include <o3tl/safeint.hxx> #include <vcl/mnemonic.hxx> #include <svl/stritem.hxx> #include <sfx2/htmlmode.hxx> @@ -1595,7 +1596,7 @@ sal_Int16 SwFramePage::GetAlignment(FrameMap const *pMap, sal_Int32 nMapPos, const size_t nMapCount = ::lcl_GetFrameMapCount(pMap); - if (static_cast<size_t>(nMapPos) >= nMapCount) + if (o3tl::make_unsigned(nMapPos) >= nMapCount) return 0; // i#22341 special handling also for map <aVCharMap>, diff --git a/sw/source/ui/index/cnttab.cxx b/sw/source/ui/index/cnttab.cxx index 0c181975d5bf..d5aa63eeeae6 100644 --- a/sw/source/ui/index/cnttab.cxx +++ b/sw/source/ui/index/cnttab.cxx @@ -17,6 +17,9 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include <sal/config.h> + +#include <o3tl/safeint.hxx> #include <sal/log.hxx> #include <svl/style.hxx> #include <vcl/weld.hxx> @@ -3678,7 +3681,7 @@ bool SwEntryBrowseBox::SeekRow( long nRow ) OUString SwEntryBrowseBox::GetCellText(long nRow, sal_uInt16 nColumn) const { OUString pRet; - if (static_cast<size_t>(nRow) < m_Entries.size()) + if (o3tl::make_unsigned(nRow) < m_Entries.size()) { const AutoMarkEntry* pEntry = m_Entries[ nRow ].get(); switch(nColumn) diff --git a/sw/source/uibase/dbui/mailmergehelper.cxx b/sw/source/uibase/dbui/mailmergehelper.cxx index ea3573dd8f5c..0981bce7fdaa 100644 --- a/sw/source/uibase/dbui/mailmergehelper.cxx +++ b/sw/source/uibase/dbui/mailmergehelper.cxx @@ -32,6 +32,7 @@ #include <com/sun/star/mail/MailServiceProvider.hpp> #include <com/sun/star/mail/XSmtpService.hpp> #include <comphelper/processfactory.hxx> +#include <o3tl/safeint.hxx> #include <vcl/event.hxx> #include <vcl/settings.hxx> #include <vcl/svapp.hxx> @@ -460,7 +461,7 @@ bool SwAddressPreview::KeyInput( const KeyEvent& rKEvt ) bHandled = true; break; case KEY_DOWN: - if(pImpl->aAddresses.size() > sal_uInt32(pImpl->nSelectedAddress + pImpl->nColumns)) + if(pImpl->aAddresses.size() > o3tl::make_unsigned(pImpl->nSelectedAddress + pImpl->nColumns)) ++nSelectedRow; bHandled = true; break; @@ -470,7 +471,7 @@ bool SwAddressPreview::KeyInput( const KeyEvent& rKEvt ) bHandled = true; break; case KEY_RIGHT: - if(nSelectedColumn < sal_uInt32(pImpl->nColumns - 1) && + if(nSelectedColumn < o3tl::make_unsigned(pImpl->nColumns - 1) && pImpl->aAddresses.size() - 1 > pImpl->nSelectedAddress ) ++nSelectedColumn; bHandled = true; diff --git a/sw/source/uibase/uno/unoatxt.cxx b/sw/source/uibase/uno/unoatxt.cxx index 3d7901bcfcef..0b2d341b309b 100644 --- a/sw/source/uibase/uno/unoatxt.cxx +++ b/sw/source/uibase/uno/unoatxt.cxx @@ -23,6 +23,7 @@ #include <com/sun/star/lang/IndexOutOfBoundsException.hpp> #include <com/sun/star/lang/WrappedTargetRuntimeException.hpp> #include <com/sun/star/container/ElementExistException.hpp> +#include <o3tl/safeint.hxx> #include <osl/diagnose.h> #include <rtl/character.hxx> #include <vcl/svapp.hxx> @@ -69,7 +70,7 @@ SwXAutoTextContainer::~SwXAutoTextContainer() sal_Int32 SwXAutoTextContainer::getCount() { - OSL_ENSURE(pGlossaries->GetGroupCnt() < static_cast<size_t>(SAL_MAX_INT32), + OSL_ENSURE(pGlossaries->GetGroupCnt() < o3tl::make_unsigned(SAL_MAX_INT32), "SwXAutoTextContainer::getCount: too many items"); return static_cast<sal_Int32>(pGlossaries->GetGroupCnt()); } @@ -78,7 +79,7 @@ uno::Any SwXAutoTextContainer::getByIndex(sal_Int32 nIndex) { SolarMutexGuard aGuard; const size_t nCount = pGlossaries->GetGroupCnt(); - if ( nIndex < 0 || static_cast<size_t>(nIndex) >= nCount ) + if ( nIndex < 0 || o3tl::make_unsigned(nIndex) >= nCount ) throw lang::IndexOutOfBoundsException(); return getByName(pGlossaries->GetGroupName( static_cast<size_t>(nIndex) )); } @@ -114,7 +115,7 @@ uno::Sequence< OUString > SwXAutoTextContainer::getElementNames() { SolarMutexGuard aGuard; const size_t nCount = pGlossaries->GetGroupCnt(); - OSL_ENSURE(nCount < static_cast<size_t>(SAL_MAX_INT32), + OSL_ENSURE(nCount < o3tl::make_unsigned(SAL_MAX_INT32), "SwXAutoTextContainer::getElementNames: too many groups"); uno::Sequence< OUString > aGroupNames(static_cast<sal_Int32>(nCount)); |