diff options
Diffstat (limited to 'editeng')
-rw-r--r-- | editeng/source/editeng/editdoc.cxx | 23 | ||||
-rw-r--r-- | editeng/source/editeng/editeng.cxx | 3 | ||||
-rw-r--r-- | editeng/source/editeng/impedit2.cxx | 2 |
3 files changed, 15 insertions, 13 deletions
diff --git a/editeng/source/editeng/editdoc.cxx b/editeng/source/editeng/editdoc.cxx index fba3408f1cc6..b0df5683b03a 100644 --- a/editeng/source/editeng/editdoc.cxx +++ b/editeng/source/editeng/editdoc.cxx @@ -50,6 +50,7 @@ #include <rtl/ustrbuf.hxx> #include <sal/log.hxx> +#include <o3tl/safeint.hxx> #include <osl/diagnose.h> #include <svl/grabbagitem.hxx> @@ -690,17 +691,17 @@ sal_Int32 ParaPortionList::GetPos(const ParaPortion* p) const ParaPortion* ParaPortionList::operator [](sal_Int32 nPos) { - return 0 <= nPos && nPos < static_cast<sal_Int32>(maPortions.size()) ? maPortions[nPos].get() : nullptr; + return 0 <= nPos && o3tl::make_unsigned(nPos) < maPortions.size() ? maPortions[nPos].get() : nullptr; } const ParaPortion* ParaPortionList::operator [](sal_Int32 nPos) const { - return 0 <= nPos && nPos < static_cast<sal_Int32>(maPortions.size()) ? maPortions[nPos].get() : nullptr; + return 0 <= nPos && o3tl::make_unsigned(nPos) < maPortions.size() ? maPortions[nPos].get() : nullptr; } std::unique_ptr<ParaPortion> ParaPortionList::Release(sal_Int32 nPos) { - if (nPos < 0 || static_cast<sal_Int32>(maPortions.size()) <= nPos) + if (nPos < 0 || maPortions.size() <= o3tl::make_unsigned(nPos)) { SAL_WARN( "editeng", "ParaPortionList::Release - out of bounds pos " << nPos); return nullptr; @@ -712,7 +713,7 @@ std::unique_ptr<ParaPortion> ParaPortionList::Release(sal_Int32 nPos) void ParaPortionList::Remove(sal_Int32 nPos) { - if (nPos < 0 || static_cast<sal_Int32>(maPortions.size()) <= nPos) + if (nPos < 0 || maPortions.size() <= o3tl::make_unsigned(nPos)) { SAL_WARN( "editeng", "ParaPortionList::Remove - out of bounds pos " << nPos); return; @@ -722,7 +723,7 @@ void ParaPortionList::Remove(sal_Int32 nPos) void ParaPortionList::Insert(sal_Int32 nPos, std::unique_ptr<ParaPortion> p) { - if (nPos < 0 || static_cast<sal_Int32>(maPortions.size()) < nPos) + if (nPos < 0 || maPortions.size() < o3tl::make_unsigned(nPos)) { SAL_WARN( "editeng", "ParaPortionList::Insert - out of bounds pos " << nPos); return; @@ -779,12 +780,12 @@ sal_Int32 ParaPortionList::FindParagraph(tools::Long nYOffset) const const ParaPortion* ParaPortionList::SafeGetObject(sal_Int32 nPos) const { - return 0 <= nPos && nPos < static_cast<sal_Int32>(maPortions.size()) ? maPortions[nPos].get() : nullptr; + return 0 <= nPos && o3tl::make_unsigned(nPos) < maPortions.size() ? maPortions[nPos].get() : nullptr; } ParaPortion* ParaPortionList::SafeGetObject(sal_Int32 nPos) { - return 0 <= nPos && nPos < static_cast<sal_Int32>(maPortions.size()) ? maPortions[nPos].get() : nullptr; + return 0 <= nPos && o3tl::make_unsigned(nPos) < maPortions.size() ? maPortions[nPos].get() : nullptr; } #if OSL_DEBUG_LEVEL > 0 && !defined NDEBUG @@ -2073,12 +2074,12 @@ sal_Int32 EditDoc::GetPos(const ContentNode* p) const const ContentNode* EditDoc::GetObject(sal_Int32 nPos) const { - return 0 <= nPos && nPos < static_cast<sal_Int32>(maContents.size()) ? maContents[nPos].get() : nullptr; + return 0 <= nPos && o3tl::make_unsigned(nPos) < maContents.size() ? maContents[nPos].get() : nullptr; } ContentNode* EditDoc::GetObject(sal_Int32 nPos) { - return 0 <= nPos && nPos < static_cast<sal_Int32>(maContents.size()) ? maContents[nPos].get() : nullptr; + return 0 <= nPos && o3tl::make_unsigned(nPos) < maContents.size() ? maContents[nPos].get() : nullptr; } const ContentNode* EditDoc::operator[](sal_Int32 nPos) const @@ -2103,7 +2104,7 @@ void EditDoc::Insert(sal_Int32 nPos, ContentNode* p) void EditDoc::Remove(sal_Int32 nPos) { - if (nPos < 0 || nPos >= static_cast<sal_Int32>(maContents.size())) + if (nPos < 0 || o3tl::make_unsigned(nPos) >= maContents.size()) { SAL_WARN( "editeng", "EditDoc::Remove - out of bounds pos " << nPos); return; @@ -2113,7 +2114,7 @@ void EditDoc::Remove(sal_Int32 nPos) void EditDoc::Release(sal_Int32 nPos) { - if (nPos < 0 || nPos >= static_cast<sal_Int32>(maContents.size())) + if (nPos < 0 || o3tl::make_unsigned(nPos) >= maContents.size()) { SAL_WARN( "editeng", "EditDoc::Release - out of bounds pos " << nPos); return; diff --git a/editeng/source/editeng/editeng.cxx b/editeng/source/editeng/editeng.cxx index 5869bcdeeeb4..1b8b446c3a15 100644 --- a/editeng/source/editeng/editeng.cxx +++ b/editeng/source/editeng/editeng.cxx @@ -23,6 +23,7 @@ #include <comphelper/lok.hxx> #include <comphelper/processfactory.hxx> #include <config_global.h> +#include <o3tl/safeint.hxx> #include <vcl/svapp.hxx> #include <vcl/weld.hxx> #include <vcl/window.hxx> @@ -2040,7 +2041,7 @@ bool EditEngine::IsTextPos( const Point& rPaperPos, sal_uInt16 nBorder ) // take unrotated positions for calculation here Point aDocPos = GetDocPos( rPaperPos ); - if ( ( aDocPos.Y() > 0 ) && ( aDocPos.Y() < static_cast<tools::Long>(pImpEditEngine->GetTextHeight()) ) ) + if ( ( aDocPos.Y() > 0 ) && ( o3tl::make_unsigned(aDocPos.Y()) < pImpEditEngine->GetTextHeight() ) ) return pImpEditEngine->IsTextPos(aDocPos, nBorder); return false; } diff --git a/editeng/source/editeng/impedit2.cxx b/editeng/source/editeng/impedit2.cxx index 78a6c8d0e492..f04623a03292 100644 --- a/editeng/source/editeng/impedit2.cxx +++ b/editeng/source/editeng/impedit2.cxx @@ -4243,7 +4243,7 @@ tools::Long ImpEditEngine::GetXPos( if( !pLine->GetCharPosArray().empty() ) { sal_Int32 nPos = nIndex - 1 - pLine->GetStart(); - if (nPos < 0 || nPos >= static_cast<sal_Int32>(pLine->GetCharPosArray().size())) + if (nPos < 0 || o3tl::make_unsigned(nPos) >= pLine->GetCharPosArray().size()) { nPos = pLine->GetCharPosArray().size()-1; OSL_FAIL("svx::ImpEditEngine::GetXPos(), index out of range!"); |