Kaydet (Commit) 459e3fe7 authored tarafından baltasarq's avatar baltasarq Kaydeden (comit) Noel Grandin

Removing #defines for String_XXX in sbxres.hxx

This is a [partial] patch for BUG #84938:
https://bugs.documentfoundation.org/show_bug.cgi?id=84938

The objective is to substitute all apparitions of #defined constants
for enum class.

The victim here is the series of constants STRING_xxx that were
located in sbres.hxx and were changed for a StringId enum class.
Obviously some other files where the type is used must be changed too.

Change-Id: I31fa684eb5eb3508d2025c9a319d5b245cc177af
Reviewed-on: https://gerrit.libreoffice.org/22655Reviewed-by: 's avatarNoel Grandin <noelgrandin@gmail.com>
Tested-by: 's avatarNoel Grandin <noelgrandin@gmail.com>
üst 0103c52d
...@@ -70,9 +70,9 @@ enum SbxBOOL ImpGetBool( const SbxValues* p ) ...@@ -70,9 +70,9 @@ enum SbxBOOL ImpGetBool( const SbxValues* p )
nRes = SbxFALSE; nRes = SbxFALSE;
if ( p->pOUString ) if ( p->pOUString )
{ {
if( p->pOUString->equalsIgnoreAsciiCase( SbxRes( STRING_TRUE ) ) ) if( p->pOUString->equalsIgnoreAsciiCase( SbxRes( StringId::True ) ) )
nRes = SbxTRUE; nRes = SbxTRUE;
else if( !p->pOUString->equalsIgnoreAsciiCase( SbxRes( STRING_FALSE ) ) ) else if( !p->pOUString->equalsIgnoreAsciiCase( SbxRes( StringId::False ) ) )
{ {
// it can be convertible to a number // it can be convertible to a number
bool bError = true; bool bError = true;
...@@ -174,9 +174,9 @@ void ImpPutBool( SbxValues* p, sal_Int16 n ) ...@@ -174,9 +174,9 @@ void ImpPutBool( SbxValues* p, sal_Int16 n )
case SbxSTRING: case SbxSTRING:
case SbxLPSTR: case SbxLPSTR:
if ( !p->pOUString ) if ( !p->pOUString )
p->pOUString = new OUString( SbxRes( n ? STRING_TRUE : STRING_FALSE ) ); p->pOUString = new OUString( SbxRes( n ? StringId::True : StringId::False ) );
else else
*p->pOUString = SbxRes( n ? STRING_TRUE : STRING_FALSE ); *p->pOUString = SbxRes( n ? StringId::True : StringId::False );
break; break;
case SbxOBJECT: case SbxOBJECT:
......
...@@ -35,10 +35,10 @@ SbxCollection::SbxCollection( const OUString& rClass ) ...@@ -35,10 +35,10 @@ SbxCollection::SbxCollection( const OUString& rClass )
{ {
if( !nCountHash ) if( !nCountHash )
{ {
pCount = OUString::createFromAscii(GetSbxRes( STRING_COUNTPROP )); pCount = OUString::createFromAscii(GetSbxRes( StringId::CountProp ));
pAdd = OUString::createFromAscii(GetSbxRes( STRING_ADDMETH )); pAdd = OUString::createFromAscii(GetSbxRes( StringId::AddMeth ));
pItem = OUString::createFromAscii(GetSbxRes( STRING_ITEMMETH )); pItem = OUString::createFromAscii(GetSbxRes( StringId::ItemMeth ));
pRemove = OUString::createFromAscii(GetSbxRes( STRING_REMOVEMETH )); pRemove = OUString::createFromAscii(GetSbxRes( StringId::RemoveMeth ));
nCountHash = MakeHashCode( pCount ); nCountHash = MakeHashCode( pCount );
nAddHash = MakeHashCode( pAdd ); nAddHash = MakeHashCode( pAdd );
nItemHash = MakeHashCode( pItem ); nItemHash = MakeHashCode( pItem );
......
...@@ -40,8 +40,8 @@ SbxObject::SbxObject( const OUString& rClass ) ...@@ -40,8 +40,8 @@ SbxObject::SbxObject( const OUString& rClass )
aData.pObj = this; aData.pObj = this;
if( !nNameHash ) if( !nNameHash )
{ {
pNameProp = OUString::createFromAscii(GetSbxRes( STRING_NAMEPROP )); pNameProp = OUString::createFromAscii(GetSbxRes( StringId::NameProp ));
pParentProp = OUString::createFromAscii(GetSbxRes( STRING_PARENTPROP )); pParentProp = OUString::createFromAscii(GetSbxRes( StringId::ParentProp ));
nNameHash = MakeHashCode( pNameProp ); nNameHash = MakeHashCode( pNameProp );
nParentHash = MakeHashCode( pParentProp ); nParentHash = MakeHashCode( pParentProp );
} }
......
...@@ -72,12 +72,12 @@ static const char* pSbxRes[] = { ...@@ -72,12 +72,12 @@ static const char* pSbxRes[] = {
"True" "True"
}; };
const char* GetSbxRes( sal_uInt16 nId ) const char* GetSbxRes( StringId nId )
{ {
return ( ( nId > SBXRES_MAX ) ? "???" : pSbxRes[ nId ] ); return ( ( nId > StringId::LastValue ) ? "???" : pSbxRes[ static_cast<int>( nId ) ] );
} }
SbxRes::SbxRes( sal_uInt16 nId ) SbxRes::SbxRes( StringId nId )
: OUString( OUString::createFromAscii( GetSbxRes( nId ) ) ) : OUString( OUString::createFromAscii( GetSbxRes( nId ) ) )
{} {}
......
...@@ -26,32 +26,34 @@ ...@@ -26,32 +26,34 @@
// Because it is non-critical resources (BASIC-Keywords), // Because it is non-critical resources (BASIC-Keywords),
// we can work with dummies. // we can work with dummies.
#define STRING_TYPES 0 enum class StringId {
#define STRING_ANY 13 Types = 0,
#define STRING_AS 32 Any = 13,
#define STRING_OPTIONAL 33 As = 32,
#define STRING_BYREF 34 Optional = 33,
ByRef = 34,
#define STRING_NAMEPROP 35
#define STRING_PARENTPROP 36 NameProp = 35,
#define STRING_COUNTPROP 38 ParentProp = 36,
#define STRING_ADDMETH 39 CountProp = 38,
#define STRING_ITEMMETH 40 AddMeth = 39,
#define STRING_REMOVEMETH 41 ItemMeth = 40,
RemoveMeth = 41,
#define STRING_ERRORMSG 42
#define STRING_FALSE 43 ErrorMsg = 42,
#define STRING_TRUE 44 False = 43,
True = 44,
#define SBXRES_MAX 44
LastValue = 44
};
class SbxRes : public OUString class SbxRes : public OUString
{ {
public: public:
explicit SbxRes( sal_uInt16 ); explicit SbxRes( StringId );
}; };
const char* GetSbxRes( sal_uInt16 ); const char* GetSbxRes( StringId );
#endif #endif
......
...@@ -102,7 +102,7 @@ OUString ImpGetString( const SbxValues* p ) ...@@ -102,7 +102,7 @@ OUString ImpGetString( const SbxValues* p )
} }
case SbxERROR: case SbxERROR:
// Here the String "Error n" is generated // Here the String "Error n" is generated
aRes = SbxRes( STRING_ERRORMSG ); aRes = SbxRes( StringId::ErrorMsg );
aRes += OUString::number(p->nUShort); break; aRes += OUString::number(p->nUShort); break;
case SbxDATE: case SbxDATE:
ImpPutDate( &aTmp, p->nDouble ); break; ImpPutDate( &aTmp, p->nDouble ); break;
......
...@@ -258,11 +258,11 @@ const OUString& SbxVariable::GetName( SbxNameType t ) const ...@@ -258,11 +258,11 @@ const OUString& SbxVariable::GetName( SbxNameType t ) const
} }
if( i->nFlags & SbxFlagBits::Optional ) if( i->nFlags & SbxFlagBits::Optional )
{ {
aTmp += OUString( SbxRes( STRING_OPTIONAL ) ); aTmp += OUString( SbxRes( StringId::Optional ) );
} }
if( i->eType & SbxBYREF ) if( i->eType & SbxBYREF )
{ {
aTmp += OUString( SbxRes( STRING_BYREF ) ); aTmp += OUString( SbxRes( StringId::ByRef ) );
} }
aTmp += i->aName; aTmp += i->aName;
cType = ' '; cType = ' ';
...@@ -291,14 +291,14 @@ const OUString& SbxVariable::GetName( SbxNameType t ) const ...@@ -291,14 +291,14 @@ const OUString& SbxVariable::GetName( SbxNameType t ) const
// long type? // long type?
if( t != SbxNAME_SHORT ) if( t != SbxNAME_SHORT )
{ {
aTmp += OUString( SbxRes( STRING_AS ) ); aTmp += OUString( SbxRes( StringId::As ) );
if( nt < 32 ) if( nt < 32 )
{ {
aTmp += OUString( SbxRes( sal::static_int_cast< sal_uInt16 >( STRING_TYPES + nt ) ) ); aTmp += OUString( SbxRes( static_cast<StringId>( static_cast<int>( StringId::Types ) + nt ) ) );
} }
else else
{ {
aTmp += OUString( SbxRes( STRING_ANY ) ); aTmp += OUString( SbxRes( StringId::Any ) );
} }
} }
} }
...@@ -307,14 +307,14 @@ const OUString& SbxVariable::GetName( SbxNameType t ) const ...@@ -307,14 +307,14 @@ const OUString& SbxVariable::GetName( SbxNameType t ) const
// Long type? Then fetch it // Long type? Then fetch it
if( t == SbxNAME_LONG_TYPES && et != SbxEMPTY ) if( t == SbxNAME_LONG_TYPES && et != SbxEMPTY )
{ {
aTmp += OUString( SbxRes( STRING_AS ) ); aTmp += OUString( SbxRes( StringId::As ) );
if( et < 32 ) if( et < 32 )
{ {
aTmp += OUString( SbxRes( sal::static_int_cast< sal_uInt16 >( STRING_TYPES + et ) ) ); aTmp += OUString( SbxRes( static_cast<StringId>( static_cast<int>( StringId::Types ) + et ) ) );
} }
else else
{ {
aTmp += OUString( SbxRes( STRING_ANY ) ); aTmp += OUString( SbxRes( StringId::Any ) );
} }
} }
const_cast<SbxVariable*>(this)->aToolString = aTmp; const_cast<SbxVariable*>(this)->aToolString = aTmp;
......
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