Kaydet (Commit) 9f54d384 authored tarafından Noel Grandin's avatar Noel Grandin

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
üst 453fe67d
...@@ -43,7 +43,7 @@ ...@@ -43,7 +43,7 @@
// globals ******************************************************************* // globals *******************************************************************
#define NO_INDEX ((sal_uInt16)0xFFFF) #define NO_INDEX (-1)
#define CONTENT_HELPER ::utl::UCBContentHelper #define CONTENT_HELPER ::utl::UCBContentHelper
struct SvtExtensionResIdMapping_Impl struct SvtExtensionResIdMapping_Impl
...@@ -261,12 +261,12 @@ static OUString GetImageExtensionByFactory_Impl( const OUString& rURL ) ...@@ -261,12 +261,12 @@ static OUString GetImageExtensionByFactory_Impl( const OUString& rURL )
return aExtension; 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() ) if ( !rExtension.isEmpty() )
{ {
sal_uInt16 nIndex = 0; sal_Int32 nIndex = 0;
OUString aExt = rExtension.toAsciiLowerCase(); OUString aExt = rExtension.toAsciiLowerCase();
while ( ExtensionMap_Impl[ nIndex ]._pExt ) while ( ExtensionMap_Impl[ nIndex ]._pExt )
{ {
...@@ -285,15 +285,12 @@ static sal_uInt16 GetIndexOfExtension_Impl( const OUString& rExtension ) ...@@ -285,15 +285,12 @@ static sal_uInt16 GetIndexOfExtension_Impl( const OUString& rExtension )
static sal_uInt16 GetImageId_Impl( const OUString& rExtension ) static sal_uInt16 GetImageId_Impl( const OUString& rExtension )
{ {
sal_uInt16 nImage = IMG_FILE; 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 ); nImage = ExtensionMap_Impl[ nIndex ]._nImgId;
if ( nIndex != NO_INDEX ) if ( !nImage )
{ nImage = IMG_FILE;
nImage = ExtensionMap_Impl[ nIndex ]._nImgId;
if ( !nImage )
nImage = IMG_FILE;
}
} }
return nImage; return nImage;
...@@ -411,15 +408,11 @@ static sal_uInt16 GetImageId_Impl( const INetURLObject& rObject, sal_Bool bDetec ...@@ -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 ) static sal_uInt16 GetDescriptionId_Impl( const OUString& rExtension, sal_Bool& rbShowExt )
{ {
sal_uInt16 nId = 0; sal_uInt16 nId = 0;
sal_Int32 nIndex = GetIndexOfExtension_Impl( rExtension );
if ( rExtension.getLength() != NO_INDEX ) if ( nIndex != NO_INDEX )
{ {
sal_uInt16 nIndex = GetIndexOfExtension_Impl( rExtension ); nId = ExtensionMap_Impl[ nIndex ]._nStrId;
if ( nIndex != NO_INDEX ) rbShowExt = ExtensionMap_Impl[ nIndex ]._bExt;
{
nId = ExtensionMap_Impl[ nIndex ]._nStrId;
rbShowExt = ExtensionMap_Impl[ nIndex ]._bExt;
}
} }
return nId; return nId;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment