diff options
Diffstat (limited to 'sw/source/core')
-rw-r--r-- | sw/source/core/access/accselectionhelper.cxx | 5 | ||||
-rw-r--r-- | sw/source/core/access/acctable.cxx | 5 | ||||
-rw-r--r-- | sw/source/core/crsr/findtxt.cxx | 3 | ||||
-rw-r--r-- | sw/source/core/doc/DocumentContentOperationsManager.cxx | 3 | ||||
-rw-r--r-- | sw/source/core/doc/doccomp.cxx | 7 | ||||
-rw-r--r-- | sw/source/core/doc/docnum.cxx | 5 | ||||
-rw-r--r-- | sw/source/core/edit/edglss.cxx | 5 | ||||
-rw-r--r-- | sw/source/core/fields/cellfml.cxx | 5 | ||||
-rw-r--r-- | sw/source/core/text/itradj.cxx | 6 | ||||
-rw-r--r-- | sw/source/core/text/redlnitr.cxx | 3 | ||||
-rw-r--r-- | sw/source/core/tox/ToxWhitespaceStripper.cxx | 3 | ||||
-rw-r--r-- | sw/source/core/txtnode/txtedt.cxx | 3 | ||||
-rw-r--r-- | sw/source/core/unocore/unocoll.cxx | 5 | ||||
-rw-r--r-- | sw/source/core/unocore/unofield.cxx | 3 | ||||
-rw-r--r-- | sw/source/core/unocore/unoflatpara.cxx | 5 | ||||
-rw-r--r-- | sw/source/core/unocore/unoobj.cxx | 3 | ||||
-rw-r--r-- | sw/source/core/unocore/unoobj2.cxx | 3 | ||||
-rw-r--r-- | sw/source/core/unocore/unoredlines.cxx | 3 | ||||
-rw-r--r-- | sw/source/core/unocore/unostyle.cxx | 5 | ||||
-rw-r--r-- | sw/source/core/unocore/unotbl.cxx | 7 | ||||
-rw-r--r-- | sw/source/core/unocore/unotextmarkup.cxx | 5 |
21 files changed, 61 insertions, 31 deletions
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(); |