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 @@
// 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,16 +285,13 @@ 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_uInt16 nIndex = GetIndexOfExtension_Impl( rExtension );
sal_Int32 nIndex = GetIndexOfExtension_Impl( rExtension );
if ( nIndex != NO_INDEX )
{
nImage = ExtensionMap_Impl[ nIndex ]._nImgId;
if ( !nImage )
nImage = IMG_FILE;
}
}
return nImage;
}
......@@ -411,16 +408,12 @@ 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_uInt16 nIndex = GetIndexOfExtension_Impl( rExtension );
sal_Int32 nIndex = GetIndexOfExtension_Impl( rExtension );
if ( nIndex != NO_INDEX )
{
nId = ExtensionMap_Impl[ nIndex ]._nStrId;
rbShowExt = ExtensionMap_Impl[ nIndex ]._bExt;
}
}
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