From 459e3fe7c97abe922e42e464ace2914546602f44 Mon Sep 17 00:00:00 2001 From: baltasarq Date: Wed, 24 Feb 2016 11:10:39 +0100 Subject: 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/22655 Reviewed-by: Noel Grandin Tested-by: Noel Grandin --- basic/source/sbx/sbxbool.cxx | 8 ++++---- basic/source/sbx/sbxcoll.cxx | 8 ++++---- basic/source/sbx/sbxobj.cxx | 4 ++-- basic/source/sbx/sbxres.cxx | 6 +++--- basic/source/sbx/sbxres.hxx | 42 ++++++++++++++++++++++-------------------- basic/source/sbx/sbxstr.cxx | 2 +- basic/source/sbx/sbxvar.cxx | 16 ++++++++-------- 7 files changed, 44 insertions(+), 42 deletions(-) (limited to 'basic') diff --git a/basic/source/sbx/sbxbool.cxx b/basic/source/sbx/sbxbool.cxx index 8d896939c8f8..402214b4b275 100644 --- a/basic/source/sbx/sbxbool.cxx +++ b/basic/source/sbx/sbxbool.cxx @@ -70,9 +70,9 @@ enum SbxBOOL ImpGetBool( const SbxValues* p ) nRes = SbxFALSE; if ( p->pOUString ) { - if( p->pOUString->equalsIgnoreAsciiCase( SbxRes( STRING_TRUE ) ) ) + if( p->pOUString->equalsIgnoreAsciiCase( SbxRes( StringId::True ) ) ) 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 bool bError = true; @@ -174,9 +174,9 @@ void ImpPutBool( SbxValues* p, sal_Int16 n ) case SbxSTRING: case SbxLPSTR: if ( !p->pOUString ) - p->pOUString = new OUString( SbxRes( n ? STRING_TRUE : STRING_FALSE ) ); + p->pOUString = new OUString( SbxRes( n ? StringId::True : StringId::False ) ); else - *p->pOUString = SbxRes( n ? STRING_TRUE : STRING_FALSE ); + *p->pOUString = SbxRes( n ? StringId::True : StringId::False ); break; case SbxOBJECT: diff --git a/basic/source/sbx/sbxcoll.cxx b/basic/source/sbx/sbxcoll.cxx index 83df80bd6869..6b8ba2fc029a 100644 --- a/basic/source/sbx/sbxcoll.cxx +++ b/basic/source/sbx/sbxcoll.cxx @@ -35,10 +35,10 @@ SbxCollection::SbxCollection( const OUString& rClass ) { if( !nCountHash ) { - pCount = OUString::createFromAscii(GetSbxRes( STRING_COUNTPROP )); - pAdd = OUString::createFromAscii(GetSbxRes( STRING_ADDMETH )); - pItem = OUString::createFromAscii(GetSbxRes( STRING_ITEMMETH )); - pRemove = OUString::createFromAscii(GetSbxRes( STRING_REMOVEMETH )); + pCount = OUString::createFromAscii(GetSbxRes( StringId::CountProp )); + pAdd = OUString::createFromAscii(GetSbxRes( StringId::AddMeth )); + pItem = OUString::createFromAscii(GetSbxRes( StringId::ItemMeth )); + pRemove = OUString::createFromAscii(GetSbxRes( StringId::RemoveMeth )); nCountHash = MakeHashCode( pCount ); nAddHash = MakeHashCode( pAdd ); nItemHash = MakeHashCode( pItem ); diff --git a/basic/source/sbx/sbxobj.cxx b/basic/source/sbx/sbxobj.cxx index d342ef0f3b20..33dae801cd48 100644 --- a/basic/source/sbx/sbxobj.cxx +++ b/basic/source/sbx/sbxobj.cxx @@ -40,8 +40,8 @@ SbxObject::SbxObject( const OUString& rClass ) aData.pObj = this; if( !nNameHash ) { - pNameProp = OUString::createFromAscii(GetSbxRes( STRING_NAMEPROP )); - pParentProp = OUString::createFromAscii(GetSbxRes( STRING_PARENTPROP )); + pNameProp = OUString::createFromAscii(GetSbxRes( StringId::NameProp )); + pParentProp = OUString::createFromAscii(GetSbxRes( StringId::ParentProp )); nNameHash = MakeHashCode( pNameProp ); nParentHash = MakeHashCode( pParentProp ); } diff --git a/basic/source/sbx/sbxres.cxx b/basic/source/sbx/sbxres.cxx index 1f588251dab0..608b3e224a3c 100644 --- a/basic/source/sbx/sbxres.cxx +++ b/basic/source/sbx/sbxres.cxx @@ -72,12 +72,12 @@ static const char* pSbxRes[] = { "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( nId ) ] ); } -SbxRes::SbxRes( sal_uInt16 nId ) +SbxRes::SbxRes( StringId nId ) : OUString( OUString::createFromAscii( GetSbxRes( nId ) ) ) {} diff --git a/basic/source/sbx/sbxres.hxx b/basic/source/sbx/sbxres.hxx index aafb73d98119..82ffe7c39839 100644 --- a/basic/source/sbx/sbxres.hxx +++ b/basic/source/sbx/sbxres.hxx @@ -26,32 +26,34 @@ // Because it is non-critical resources (BASIC-Keywords), // we can work with dummies. -#define STRING_TYPES 0 -#define STRING_ANY 13 -#define STRING_AS 32 -#define STRING_OPTIONAL 33 -#define STRING_BYREF 34 - -#define STRING_NAMEPROP 35 -#define STRING_PARENTPROP 36 -#define STRING_COUNTPROP 38 -#define STRING_ADDMETH 39 -#define STRING_ITEMMETH 40 -#define STRING_REMOVEMETH 41 - -#define STRING_ERRORMSG 42 -#define STRING_FALSE 43 -#define STRING_TRUE 44 - -#define SBXRES_MAX 44 +enum class StringId { + Types = 0, + Any = 13, + As = 32, + Optional = 33, + ByRef = 34, + + NameProp = 35, + ParentProp = 36, + CountProp = 38, + AddMeth = 39, + ItemMeth = 40, + RemoveMeth = 41, + + ErrorMsg = 42, + False = 43, + True = 44, + + LastValue = 44 +}; class SbxRes : public OUString { public: - explicit SbxRes( sal_uInt16 ); + explicit SbxRes( StringId ); }; -const char* GetSbxRes( sal_uInt16 ); +const char* GetSbxRes( StringId ); #endif diff --git a/basic/source/sbx/sbxstr.cxx b/basic/source/sbx/sbxstr.cxx index f095e04dcbb1..465a72f95628 100644 --- a/basic/source/sbx/sbxstr.cxx +++ b/basic/source/sbx/sbxstr.cxx @@ -102,7 +102,7 @@ OUString ImpGetString( const SbxValues* p ) } case SbxERROR: // Here the String "Error n" is generated - aRes = SbxRes( STRING_ERRORMSG ); + aRes = SbxRes( StringId::ErrorMsg ); aRes += OUString::number(p->nUShort); break; case SbxDATE: ImpPutDate( &aTmp, p->nDouble ); break; diff --git a/basic/source/sbx/sbxvar.cxx b/basic/source/sbx/sbxvar.cxx index 2bbe5081044b..2a15eed59ff2 100644 --- a/basic/source/sbx/sbxvar.cxx +++ b/basic/source/sbx/sbxvar.cxx @@ -258,11 +258,11 @@ const OUString& SbxVariable::GetName( SbxNameType t ) const } if( i->nFlags & SbxFlagBits::Optional ) { - aTmp += OUString( SbxRes( STRING_OPTIONAL ) ); + aTmp += OUString( SbxRes( StringId::Optional ) ); } if( i->eType & SbxBYREF ) { - aTmp += OUString( SbxRes( STRING_BYREF ) ); + aTmp += OUString( SbxRes( StringId::ByRef ) ); } aTmp += i->aName; cType = ' '; @@ -291,14 +291,14 @@ const OUString& SbxVariable::GetName( SbxNameType t ) const // long type? if( t != SbxNAME_SHORT ) { - aTmp += OUString( SbxRes( STRING_AS ) ); + aTmp += OUString( SbxRes( StringId::As ) ); if( nt < 32 ) { - aTmp += OUString( SbxRes( sal::static_int_cast< sal_uInt16 >( STRING_TYPES + nt ) ) ); + aTmp += OUString( SbxRes( static_cast( static_cast( StringId::Types ) + nt ) ) ); } else { - aTmp += OUString( SbxRes( STRING_ANY ) ); + aTmp += OUString( SbxRes( StringId::Any ) ); } } } @@ -307,14 +307,14 @@ const OUString& SbxVariable::GetName( SbxNameType t ) const // Long type? Then fetch it if( t == SbxNAME_LONG_TYPES && et != SbxEMPTY ) { - aTmp += OUString( SbxRes( STRING_AS ) ); + aTmp += OUString( SbxRes( StringId::As ) ); if( et < 32 ) { - aTmp += OUString( SbxRes( sal::static_int_cast< sal_uInt16 >( STRING_TYPES + et ) ) ); + aTmp += OUString( SbxRes( static_cast( static_cast( StringId::Types ) + et ) ) ); } else { - aTmp += OUString( SbxRes( STRING_ANY ) ); + aTmp += OUString( SbxRes( StringId::Any ) ); } } const_cast(this)->aToolString = aTmp; -- cgit