summaryrefslogtreecommitdiff
path: root/svx/source/gallery2/galtheme.cxx
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2017-12-18 09:54:02 +0000
committerCaolán McNamara <caolanm@redhat.com>2017-12-18 22:14:17 +0100
commita7c772566bb8ac6a088b808cf0ef550e7b06560b (patch)
tree56dd899b4e2081d74ea590e95e70f83f64954c48 /svx/source/gallery2/galtheme.cxx
parent877ede68f31a25a76c89d47389a190b75df1757d (diff)
coverity#1426163 Improper use of negative value
started life as sal_uIntPtr and the various checks are typically nPos < thing.size() just checking one bound, so sal_uInt32 looks safer after all Change-Id: Ibac839fc45b10d96ce4d4c8002fd26b20f70ae1c Reviewed-on: https://gerrit.libreoffice.org/46697 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'svx/source/gallery2/galtheme.cxx')
-rw-r--r--svx/source/gallery2/galtheme.cxx66
1 files changed, 33 insertions, 33 deletions
diff --git a/svx/source/gallery2/galtheme.cxx b/svx/source/gallery2/galtheme.cxx
index 5e060adefd3a..6e8b16c4ba1d 100644
--- a/svx/source/gallery2/galtheme.cxx
+++ b/svx/source/gallery2/galtheme.cxx
@@ -106,7 +106,7 @@ void GalleryTheme::ImplCreateSvDrawStorage()
}
}
-bool GalleryTheme::ImplWriteSgaObject( const SgaObject& rObj, sal_Int32 nPos, GalleryObject* pExistentEntry )
+bool GalleryTheme::ImplWriteSgaObject(const SgaObject& rObj, sal_uInt32 nPos, GalleryObject* pExistentEntry)
{
std::unique_ptr<SvStream> pOStm(::utl::UcbStreamHelper::CreateStream( GetSdgURL().GetMainURL( INetURLObject::DecodeMechanism::NONE ), StreamMode::WRITE ));
bool bRet = false;
@@ -124,7 +124,7 @@ bool GalleryTheme::ImplWriteSgaObject( const SgaObject& rObj, sal_Int32 nPos, Ga
if( !pExistentEntry )
{
pEntry = new GalleryObject;
- if ( nPos < sal_Int32(aObjectList.size()) )
+ if ( nPos < aObjectList.size() )
{
GalleryObjectList::iterator it = aObjectList.begin();
::std::advance( it, nPos );
@@ -330,7 +330,7 @@ INetURLObject GalleryTheme::ImplCreateUniqueURL( SgaObjKind eObjKind, ConvertDat
return aNewURL;
}
-void GalleryTheme::ImplBroadcast( sal_Int32 nUpdatePos )
+void GalleryTheme::ImplBroadcast(sal_uInt32 nUpdatePos)
{
if( !IsBroadcasterLocked() )
{
@@ -364,14 +364,14 @@ void GalleryTheme::UnlockBroadcaster()
ImplBroadcast( 0 );
}
-bool GalleryTheme::InsertObject( const SgaObject& rObj, sal_Int32 nInsertPos )
+bool GalleryTheme::InsertObject(const SgaObject& rObj, sal_uInt32 nInsertPos)
{
if (!rObj.IsValid())
return false;
GalleryObject* pFoundEntry = nullptr;
- size_t iFoundPos = 0;
- for (size_t n = aObjectList.size(); iFoundPos < n; ++iFoundPos)
+ sal_uInt32 iFoundPos = 0;
+ for (sal_uInt32 n = aObjectList.size(); iFoundPos < n; ++iFoundPos)
{
if (aObjectList[ iFoundPos ]->aURL == rObj.GetURL())
{
@@ -409,14 +409,14 @@ bool GalleryTheme::InsertObject( const SgaObject& rObj, sal_Int32 nInsertPos )
return true;
}
-SgaObject* GalleryTheme::AcquireObject( sal_Int32 nPos )
+SgaObject* GalleryTheme::AcquireObject(sal_uInt32 nPos)
{
- return ImplReadSgaObject( aObjectList[ nPos ] );
+ return ImplReadSgaObject(ImplGetGalleryObject(nPos));
}
-void GalleryTheme::GetPreviewBitmapExAndStrings(sal_Int32 nPos, BitmapEx& rBitmapEx, Size& rSize, OUString& rTitle, OUString& rPath) const
+void GalleryTheme::GetPreviewBitmapExAndStrings(sal_uInt32 nPos, BitmapEx& rBitmapEx, Size& rSize, OUString& rTitle, OUString& rPath) const
{
- const GalleryObject* pGalleryObject = nPos < sal_Int32(aObjectList.size()) ? aObjectList[ nPos ] : nullptr;
+ const GalleryObject* pGalleryObject = nPos < aObjectList.size() ? aObjectList[ nPos ] : nullptr;
if(pGalleryObject)
{
@@ -431,9 +431,9 @@ void GalleryTheme::GetPreviewBitmapExAndStrings(sal_Int32 nPos, BitmapEx& rBitma
}
}
-void GalleryTheme::SetPreviewBitmapExAndStrings(sal_Int32 nPos, const BitmapEx& rBitmapEx, const Size& rSize, const OUString& rTitle, const OUString& rPath)
+void GalleryTheme::SetPreviewBitmapExAndStrings(sal_uInt32 nPos, const BitmapEx& rBitmapEx, const Size& rSize, const OUString& rTitle, const OUString& rPath)
{
- GalleryObject* pGalleryObject = nPos < sal_Int32(aObjectList.size()) ? aObjectList[ nPos ] : nullptr;
+ GalleryObject* pGalleryObject = nPos < aObjectList.size() ? aObjectList[ nPos ] : nullptr;
if(pGalleryObject)
{
@@ -453,10 +453,10 @@ void GalleryTheme::ReleaseObject( SgaObject* pObject )
delete pObject;
}
-bool GalleryTheme::RemoveObject( sal_Int32 nPos )
+bool GalleryTheme::RemoveObject(sal_uInt32 nPos)
{
GalleryObject* pEntry = nullptr;
- if ( nPos < sal_Int32(aObjectList.size()) )
+ if ( nPos < aObjectList.size() )
{
GalleryObjectList::iterator it = aObjectList.begin();
::std::advance( it, nPos );
@@ -484,9 +484,9 @@ bool GalleryTheme::RemoveObject( sal_Int32 nPos )
return( pEntry != nullptr );
}
-bool GalleryTheme::ChangeObjectPos( sal_Int32 nOldPos, sal_Int32 nNewPos )
+bool GalleryTheme::ChangeObjectPos(sal_uInt32 nOldPos, sal_uInt32 nNewPos)
{
- if (nOldPos == nNewPos || nOldPos >= sal_Int32(aObjectList.size()))
+ if (nOldPos == nNewPos || nOldPos >= aObjectList.size())
return false;
GalleryObject* pEntry = aObjectList[nOldPos];
@@ -516,16 +516,16 @@ void GalleryTheme::Actualize( const Link<const INetURLObject&, void>& rActualize
Graphic aGraphic;
OUString aFormat;
GalleryObject* pEntry;
- const size_t nCount = aObjectList.size();
+ const sal_uInt32 nCount = aObjectList.size();
LockBroadcaster();
bAbortActualize = false;
// reset delete flag
- for (size_t i = 0; i < nCount; i++)
+ for (sal_uInt32 i = 0; i < nCount; i++)
aObjectList[ i ]->mbDelete = false;
- for(size_t i = 0; ( i < nCount ) && !bAbortActualize; i++)
+ for (sal_uInt32 i = 0; ( i < nCount ) && !bAbortActualize; i++)
{
if( pProgress )
pProgress->Update( i, nCount - 1 );
@@ -753,7 +753,7 @@ GalleryThemeEntry* GalleryTheme::CreateThemeEntry( const INetURLObject& rURL, bo
return pRet;
}
-bool GalleryTheme::GetThumb( sal_Int32 nPos, BitmapEx& rBmp )
+bool GalleryTheme::GetThumb(sal_uInt32 nPos, BitmapEx& rBmp)
{
SgaObject* pObj = AcquireObject( nPos );
bool bRet = false;
@@ -768,7 +768,7 @@ bool GalleryTheme::GetThumb( sal_Int32 nPos, BitmapEx& rBmp )
return bRet;
}
-bool GalleryTheme::GetGraphic( sal_Int32 nPos, Graphic& rGraphic, bool bProgress )
+bool GalleryTheme::GetGraphic(sal_uInt32 nPos, Graphic& rGraphic, bool bProgress)
{
const GalleryObject* pObject = ImplGetGalleryObject( nPos );
bool bRet = false;
@@ -841,7 +841,7 @@ bool GalleryTheme::GetGraphic( sal_Int32 nPos, Graphic& rGraphic, bool bProgress
return bRet;
}
-bool GalleryTheme::InsertGraphic( const Graphic& rGraphic, sal_Int32 nInsertPos )
+bool GalleryTheme::InsertGraphic(const Graphic& rGraphic, sal_uInt32 nInsertPos)
{
bool bRet = false;
@@ -923,7 +923,7 @@ bool GalleryTheme::InsertGraphic( const Graphic& rGraphic, sal_Int32 nInsertPos
return bRet;
}
-bool GalleryTheme::GetModel( sal_Int32 nPos, SdrModel& rModel )
+bool GalleryTheme::GetModel(sal_uInt32 nPos, SdrModel& rModel)
{
const GalleryObject* pObject = ImplGetGalleryObject( nPos );
bool bRet = false;
@@ -950,7 +950,7 @@ bool GalleryTheme::GetModel( sal_Int32 nPos, SdrModel& rModel )
return bRet;
}
-bool GalleryTheme::InsertModel( const FmFormModel& rModel, sal_Int32 nInsertPos )
+bool GalleryTheme::InsertModel(const FmFormModel& rModel, sal_uInt32 nInsertPos)
{
INetURLObject aURL( ImplCreateUniqueURL( SgaObjKind::SvDraw ) );
tools::SvRef<SotStorage> xStor( GetSvDrawStorage() );
@@ -995,7 +995,7 @@ bool GalleryTheme::InsertModel( const FmFormModel& rModel, sal_Int32 nInsertPos
return bRet;
}
-bool GalleryTheme::GetModelStream( sal_Int32 nPos, tools::SvRef<SotStorageStream> const & rxModelStream )
+bool GalleryTheme::GetModelStream(sal_uInt32 nPos, tools::SvRef<SotStorageStream> const & rxModelStream)
{
const GalleryObject* pObject = ImplGetGalleryObject( nPos );
bool bRet = false;
@@ -1046,7 +1046,7 @@ bool GalleryTheme::GetModelStream( sal_Int32 nPos, tools::SvRef<SotStorageStream
return bRet;
}
-bool GalleryTheme::InsertModelStream( const tools::SvRef<SotStorageStream>& rxModelStream, sal_Int32 nInsertPos )
+bool GalleryTheme::InsertModelStream(const tools::SvRef<SotStorageStream>& rxModelStream, sal_uInt32 nInsertPos)
{
INetURLObject aURL( ImplCreateUniqueURL( SgaObjKind::SvDraw ) );
tools::SvRef<SotStorage> xStor( GetSvDrawStorage() );
@@ -1080,7 +1080,7 @@ bool GalleryTheme::InsertModelStream( const tools::SvRef<SotStorageStream>& rxMo
return bRet;
}
-bool GalleryTheme::GetURL( sal_Int32 nPos, INetURLObject& rURL )
+bool GalleryTheme::GetURL(sal_uInt32 nPos, INetURLObject& rURL)
{
const GalleryObject* pObject = ImplGetGalleryObject( nPos );
bool bRet = false;
@@ -1094,7 +1094,7 @@ bool GalleryTheme::GetURL( sal_Int32 nPos, INetURLObject& rURL )
return bRet;
}
-bool GalleryTheme::InsertURL( const INetURLObject& rURL, sal_Int32 nInsertPos )
+bool GalleryTheme::InsertURL(const INetURLObject& rURL, sal_uInt32 nInsertPos)
{
Graphic aGraphic;
OUString aFormat;
@@ -1119,7 +1119,7 @@ bool GalleryTheme::InsertURL( const INetURLObject& rURL, sal_Int32 nInsertPos )
return bRet;
}
-bool GalleryTheme::InsertFileOrDirURL( const INetURLObject& rFileOrDirURL, sal_Int32 nInsertPos )
+bool GalleryTheme::InsertFileOrDirURL(const INetURLObject& rFileOrDirURL, sal_uInt32 nInsertPos)
{
INetURLObject aURL;
::std::vector< INetURLObject > aURLVector;
@@ -1167,7 +1167,7 @@ bool GalleryTheme::InsertFileOrDirURL( const INetURLObject& rFileOrDirURL, sal_I
return bRet;
}
-bool GalleryTheme::InsertTransferable( const uno::Reference< datatransfer::XTransferable >& rxTransferable, sal_Int32 nInsertPos )
+bool GalleryTheme::InsertTransferable(const uno::Reference< datatransfer::XTransferable >& rxTransferable, sal_uInt32 nInsertPos)
{
bool bRet = false;
@@ -1264,13 +1264,13 @@ bool GalleryTheme::InsertTransferable( const uno::Reference< datatransfer::XTran
return bRet;
}
-void GalleryTheme::CopyToClipboard( vcl::Window* pWindow, sal_Int32 nPos )
+void GalleryTheme::CopyToClipboard(vcl::Window* pWindow, sal_uInt32 nPos)
{
GalleryTransferable* pTransferable = new GalleryTransferable( this, nPos, false );
pTransferable->CopyToClipboard( pWindow );
}
-void GalleryTheme::StartDrag( vcl::Window* pWindow, sal_Int32 nPos )
+void GalleryTheme::StartDrag(vcl::Window* pWindow, sal_uInt32 nPos)
{
GalleryTransferable* pTransferable = new GalleryTransferable( this, nPos, true );
pTransferable->StartDrag( pWindow, DND_ACTION_COPY | DND_ACTION_LINK );
@@ -1341,7 +1341,7 @@ SvStream& GalleryTheme::WriteData( SvStream& rOStm ) const
}
// more recently, a 512-byte reserve buffer is written,
- // to recognize them two sal_uIntPtr-Ids will be written.
+ // to recognize them two sal_uInt32-Ids will be written.
rOStm.WriteUInt32( COMPAT_FORMAT( 'G', 'A', 'L', 'R' ) ).WriteUInt32( COMPAT_FORMAT( 'E', 'S', 'R', 'V' ) );
const long nReservePos = rOStm.Tell();