diff options
author | Noel Grandin <noel@peralex.com> | 2013-08-22 11:54:04 +0200 |
---|---|---|
committer | Noel Grandin <noel@peralex.com> | 2013-08-22 11:55:49 +0200 |
commit | 9f54d3847dd424d0e144ada64758772e14f12c1b (patch) | |
tree | 7dd984735ee1a313de530d692adef80eb61c7af4 /svtools | |
parent | fix use of dynamically allocated OUString (diff) | |
download | core-9f54d3847dd424d0e144ada64758772e14f12c1b.tar.gz core-9f54d3847dd424d0e144ada64758772e14f12c1b.zip |
fix dodgy NO_INDEX code
The comparison of NO_INDEX to getLength() makes no sense, and makes
even less sense now that the code is using OUString, after my recent
change
Change return type to sal_Int32, and change NO_INDEX to -1, so that
it can't possibly conflict with a valid index.
Change-Id: I65cb945096b4b9cb80f61d896177c2562a0d2c76
Diffstat (limited to 'svtools')
-rw-r--r-- | svtools/source/misc/imagemgr.cxx | 33 |
1 files changed, 13 insertions, 20 deletions
diff --git a/svtools/source/misc/imagemgr.cxx b/svtools/source/misc/imagemgr.cxx index 57ec73689295..b9f78c19a38a 100644 --- a/svtools/source/misc/imagemgr.cxx +++ b/svtools/source/misc/imagemgr.cxx @@ -43,7 +43,7 @@ // globals ******************************************************************* -#define NO_INDEX ((sal_uInt16)0xFFFF) +#define NO_INDEX (-1) #define CONTENT_HELPER ::utl::UCBContentHelper struct SvtExtensionResIdMapping_Impl @@ -261,12 +261,12 @@ static OUString GetImageExtensionByFactory_Impl( const OUString& rURL ) return aExtension; } -static sal_uInt16 GetIndexOfExtension_Impl( const OUString& rExtension ) +static sal_Int32 GetIndexOfExtension_Impl( const OUString& rExtension ) { - sal_uInt16 nRet = NO_INDEX; + sal_Int32 nRet = NO_INDEX; if ( !rExtension.isEmpty() ) { - sal_uInt16 nIndex = 0; + sal_Int32 nIndex = 0; OUString aExt = rExtension.toAsciiLowerCase(); while ( ExtensionMap_Impl[ nIndex ]._pExt ) { @@ -285,15 +285,12 @@ static sal_uInt16 GetIndexOfExtension_Impl( const OUString& rExtension ) static sal_uInt16 GetImageId_Impl( const OUString& rExtension ) { sal_uInt16 nImage = IMG_FILE; - if ( rExtension.getLength() != NO_INDEX ) + sal_Int32 nIndex = GetIndexOfExtension_Impl( rExtension ); + if ( nIndex != NO_INDEX ) { - sal_uInt16 nIndex = GetIndexOfExtension_Impl( rExtension ); - if ( nIndex != NO_INDEX ) - { - nImage = ExtensionMap_Impl[ nIndex ]._nImgId; - if ( !nImage ) - nImage = IMG_FILE; - } + nImage = ExtensionMap_Impl[ nIndex ]._nImgId; + if ( !nImage ) + nImage = IMG_FILE; } return nImage; @@ -411,15 +408,11 @@ static sal_uInt16 GetImageId_Impl( const INetURLObject& rObject, sal_Bool bDetec static sal_uInt16 GetDescriptionId_Impl( const OUString& rExtension, sal_Bool& rbShowExt ) { sal_uInt16 nId = 0; - - if ( rExtension.getLength() != NO_INDEX ) + sal_Int32 nIndex = GetIndexOfExtension_Impl( rExtension ); + if ( nIndex != NO_INDEX ) { - sal_uInt16 nIndex = GetIndexOfExtension_Impl( rExtension ); - if ( nIndex != NO_INDEX ) - { - nId = ExtensionMap_Impl[ nIndex ]._nStrId; - rbShowExt = ExtensionMap_Impl[ nIndex ]._bExt; - } + nId = ExtensionMap_Impl[ nIndex ]._nStrId; + rbShowExt = ExtensionMap_Impl[ nIndex ]._bExt; } return nId; |