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 )
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:
......
......@@ -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 );
......
......@@ -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 );
}
......
......@@ -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<int>( nId ) ] );
}
SbxRes::SbxRes( sal_uInt16 nId )
SbxRes::SbxRes( StringId nId )
: OUString( OUString::createFromAscii( GetSbxRes( nId ) ) )
{}
......
......@@ -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
......
......@@ -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;
......
......@@ -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<StringId>( static_cast<int>( 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<StringId>( static_cast<int>( StringId::Types ) + et ) ) );
}
else
{
aTmp += OUString( SbxRes( STRING_ANY ) );
aTmp += OUString( SbxRes( StringId::Any ) );
}
}
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