summaryrefslogtreecommitdiff
path: root/sd
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2022-05-24 15:26:06 +0200
committerStephan Bergmann <sbergman@redhat.com>2022-05-24 16:50:03 +0200
commit5060c5015882b7109c54598c4ea858949beafc43 (patch)
treec8c153d73f6c6ebbe2dae768c1da72d28312efd4 /sd
parenta86818c15a6b4773ddd012db37d55b5204163c24 (diff)
Use o3tl::make_unsigned in some places
...where a signed and an unsigned value are compared, and the signed value has just been proven to be non-negative here Change-Id: I20600d61a5d59d739bc1bee838c0038e4611aec2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134875 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'sd')
-rw-r--r--sd/source/filter/html/buttonset.cxx5
-rw-r--r--sd/source/ui/app/sdxfer.cxx3
-rw-r--r--sd/source/ui/slideshow/slideshowimpl.cxx3
-rw-r--r--sd/source/ui/slidesorter/model/SlideSorterModel.cxx3
-rw-r--r--sd/source/ui/unoidl/unocpres.cxx5
5 files changed, 12 insertions, 7 deletions
diff --git a/sd/source/filter/html/buttonset.cxx b/sd/source/filter/html/buttonset.cxx
index 1bc24a7e33cd..3929f74222e8 100644
--- a/sd/source/filter/html/buttonset.cxx
+++ b/sd/source/filter/html/buttonset.cxx
@@ -25,6 +25,7 @@
#include <com/sun/star/graphic/XGraphicProvider.hpp>
#include <com/sun/star/io/XStream.hpp>
+#include <o3tl/safeint.hxx>
#include <osl/file.hxx>
#include <comphelper/storagehelper.hxx>
#include <comphelper/oslfile2streamwrap.hxx>
@@ -195,7 +196,7 @@ int ButtonSetImpl::getCount() const
bool ButtonSetImpl::getPreview( int nSet, const std::vector< OUString >& rButtons, Image& rImage )
{
- if( (nSet >= 0) && (nSet < static_cast<int>(maButtons.size())))
+ if( (nSet >= 0) && (o3tl::make_unsigned(nSet) < maButtons.size()))
{
ButtonsImpl& rSet = *maButtons[nSet];
@@ -243,7 +244,7 @@ bool ButtonSetImpl::getPreview( int nSet, const std::vector< OUString >& rButton
bool ButtonSetImpl::exportButton( int nSet, const OUString& rPath, const OUString& rName )
{
- if( (nSet >= 0) && (nSet < static_cast<int>(maButtons.size())))
+ if( (nSet >= 0) && (o3tl::make_unsigned(nSet) < maButtons.size()))
{
ButtonsImpl& rSet = *maButtons[nSet];
diff --git a/sd/source/ui/app/sdxfer.cxx b/sd/source/ui/app/sdxfer.cxx
index 14e63798aec9..67016fd194e1 100644
--- a/sd/source/ui/app/sdxfer.cxx
+++ b/sd/source/ui/app/sdxfer.cxx
@@ -35,6 +35,7 @@
#include <editeng/outlobj.hxx>
#include <sot/storage.hxx>
#include <editeng/editobj.hxx>
+#include <o3tl/safeint.hxx>
#include <svx/svdobjkind.hxx>
#include <svx/svdouno.hxx>
#include <svx/ImageMapInfo.hxx>
@@ -725,7 +726,7 @@ sal_Int32 SdTransferable::GetUserDataCount() const
std::shared_ptr<SdTransferable::UserData> SdTransferable::GetUserData (const sal_Int32 nIndex) const
{
- if (nIndex>=0 && nIndex<sal_Int32(maUserData.size()))
+ if (nIndex>=0 && o3tl::make_unsigned(nIndex)<maUserData.size())
return maUserData[nIndex];
else
return std::shared_ptr<UserData>();
diff --git a/sd/source/ui/slideshow/slideshowimpl.cxx b/sd/source/ui/slideshow/slideshowimpl.cxx
index b896fbb4ebbf..3215a550b7c1 100644
--- a/sd/source/ui/slideshow/slideshowimpl.cxx
+++ b/sd/source/ui/slideshow/slideshowimpl.cxx
@@ -78,6 +78,7 @@
#include <comphelper/processfactory.hxx>
#include <comphelper/propertyvalue.hxx>
#include <rtl/ref.hxx>
+#include <o3tl/safeint.hxx>
#include <o3tl/string_view.hxx>
#include <avmedia/mediawindow.hxx>
#include <svtools/colrdlg.hxx>
@@ -166,7 +167,7 @@ private:
bool getSlideAPI( sal_Int32 nSlideNumber, Reference< XDrawPage >& xSlide, Reference< XAnimationNode >& xAnimNode );
sal_Int32 findSlideIndex( sal_Int32 nSlideNumber ) const;
- bool isValidIndex( sal_Int32 nIndex ) const { return (nIndex >= 0) && (nIndex < static_cast<sal_Int32>(maSlideNumbers.size())); }
+ bool isValidIndex( sal_Int32 nIndex ) const { return (nIndex >= 0) && (o3tl::make_unsigned(nIndex) < maSlideNumbers.size()); }
bool isValidSlideNumber( sal_Int32 nSlideNumber ) const { return (nSlideNumber >= 0) && (nSlideNumber < mnSlideCount); }
private:
diff --git a/sd/source/ui/slidesorter/model/SlideSorterModel.cxx b/sd/source/ui/slidesorter/model/SlideSorterModel.cxx
index 365c9127944d..4d3e7965690b 100644
--- a/sd/source/ui/slidesorter/model/SlideSorterModel.cxx
+++ b/sd/source/ui/slidesorter/model/SlideSorterModel.cxx
@@ -41,6 +41,7 @@
#include <sdpage.hxx>
#include <FrameView.hxx>
+#include <o3tl/safeint.hxx>
#include <tools/diagnose_ex.h>
using namespace ::com::sun::star;
@@ -616,7 +617,7 @@ bool SlideSorterModel::DeleteSlide (const SdPage* pPage)
bool bMarkedSelected(false);
- if(nIndex >= 0 && nIndex < static_cast<sal_Int32>(maPageDescriptors.size()))
+ if(nIndex >= 0 && o3tl::make_unsigned(nIndex) < maPageDescriptors.size())
{
if (maPageDescriptors[nIndex])
if (maPageDescriptors[nIndex]->GetPage() != pPage)
diff --git a/sd/source/ui/unoidl/unocpres.cxx b/sd/source/ui/unoidl/unocpres.cxx
index e5c9eb16e021..cc57b1e7941a 100644
--- a/sd/source/ui/unoidl/unocpres.cxx
+++ b/sd/source/ui/unoidl/unocpres.cxx
@@ -21,6 +21,7 @@
#include <com/sun/star/lang/DisposedException.hpp>
#include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
+#include <o3tl/safeint.hxx>
#include <vcl/svapp.hxx>
#include <svx/svdpage.hxx>
#include <cppuhelper/supportsservice.hxx>
@@ -84,7 +85,7 @@ void SAL_CALL SdXCustomPresentation::insertByIndex( sal_Int32 Index, const uno::
if( bDisposing )
throw lang::DisposedException();
- if( Index < 0 || Index > static_cast<sal_Int32>( mpSdCustomShow ? mpSdCustomShow->PagesVector().size() : 0 ) )
+ if( Index < 0 || o3tl::make_unsigned(Index) > ( mpSdCustomShow ? mpSdCustomShow->PagesVector().size() : 0 ) )
throw lang::IndexOutOfBoundsException();
uno::Reference< drawing::XDrawPage > xPage;
@@ -182,7 +183,7 @@ uno::Any SAL_CALL SdXCustomPresentation::getByIndex( sal_Int32 Index )
if( bDisposing )
throw lang::DisposedException();
- if (Index < 0 || !mpSdCustomShow || Index >= static_cast<sal_Int32>(mpSdCustomShow->PagesVector().size()))
+ if (Index < 0 || !mpSdCustomShow || o3tl::make_unsigned(Index) >= mpSdCustomShow->PagesVector().size())
throw lang::IndexOutOfBoundsException();
uno::Any aAny;