simply the SbxRes stuff, inheriting from OUString is icky

Change-Id: Ie9794ea164d587ad87ee13d360cb3abc18166051
This commit is contained in:
Noel Grandin
2016-02-24 12:19:44 +02:00
parent 459e3fe7c9
commit 670c2b3ca9
7 changed files with 23 additions and 33 deletions

View File

@@ -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( StringId::True ) ) ) if( p->pOUString->equalsIgnoreAsciiCase( GetSbxRes( StringId::True ) ) )
nRes = SbxTRUE; nRes = SbxTRUE;
else if( !p->pOUString->equalsIgnoreAsciiCase( SbxRes( StringId::False ) ) ) else if( !p->pOUString->equalsIgnoreAsciiCase( GetSbxRes( 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 )
case SbxSTRING: case SbxSTRING:
case SbxLPSTR: case SbxLPSTR:
if ( !p->pOUString ) if ( !p->pOUString )
p->pOUString = new OUString( SbxRes( n ? StringId::True : StringId::False ) ); p->pOUString = new OUString( GetSbxRes( n ? StringId::True : StringId::False ) );
else else
*p->pOUString = SbxRes( n ? StringId::True : StringId::False ); *p->pOUString = GetSbxRes( n ? StringId::True : StringId::False );
break; break;
case SbxOBJECT: case SbxOBJECT:

View File

@@ -35,10 +35,10 @@ SbxCollection::SbxCollection( const OUString& rClass )
{ {
if( !nCountHash ) if( !nCountHash )
{ {
pCount = OUString::createFromAscii(GetSbxRes( StringId::CountProp )); pCount = GetSbxRes( StringId::CountProp );
pAdd = OUString::createFromAscii(GetSbxRes( StringId::AddMeth )); pAdd = GetSbxRes( StringId::AddMeth );
pItem = OUString::createFromAscii(GetSbxRes( StringId::ItemMeth )); pItem = GetSbxRes( StringId::ItemMeth );
pRemove = OUString::createFromAscii(GetSbxRes( StringId::RemoveMeth )); pRemove = GetSbxRes( StringId::RemoveMeth );
nCountHash = MakeHashCode( pCount ); nCountHash = MakeHashCode( pCount );
nAddHash = MakeHashCode( pAdd ); nAddHash = MakeHashCode( pAdd );
nItemHash = MakeHashCode( pItem ); nItemHash = MakeHashCode( pItem );

View File

@@ -40,8 +40,8 @@ SbxObject::SbxObject( const OUString& rClass )
aData.pObj = this; aData.pObj = this;
if( !nNameHash ) if( !nNameHash )
{ {
pNameProp = OUString::createFromAscii(GetSbxRes( StringId::NameProp )); pNameProp = GetSbxRes( StringId::NameProp );
pParentProp = OUString::createFromAscii(GetSbxRes( StringId::ParentProp )); pParentProp = GetSbxRes( StringId::ParentProp );
nNameHash = MakeHashCode( pNameProp ); nNameHash = MakeHashCode( pNameProp );
nParentHash = MakeHashCode( pParentProp ); nParentHash = MakeHashCode( pParentProp );
} }

View File

@@ -72,13 +72,9 @@ static const char* pSbxRes[] = {
"True" "True"
}; };
const char* GetSbxRes( StringId nId ) OUString GetSbxRes( StringId nId )
{ {
return ( ( nId > StringId::LastValue ) ? "???" : pSbxRes[ static_cast<int>( nId ) ] ); return OUString::createFromAscii( ( nId > StringId::LastValue ) ? "???" : pSbxRes[ static_cast<int>( nId ) ] );
} }
SbxRes::SbxRes( StringId nId )
: OUString( OUString::createFromAscii( GetSbxRes( nId ) ) )
{}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@@ -47,13 +47,7 @@ enum class StringId {
LastValue = 44 LastValue = 44
}; };
class SbxRes : public OUString OUString GetSbxRes( StringId );
{
public:
explicit SbxRes( StringId );
};
const char* GetSbxRes( StringId );
#endif #endif

View File

@@ -102,8 +102,8 @@ 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( StringId::ErrorMsg ); aRes = GetSbxRes( StringId::ErrorMsg ) + OUString::number(p->nUShort);
aRes += OUString::number(p->nUShort); break; break;
case SbxDATE: case SbxDATE:
ImpPutDate( &aTmp, p->nDouble ); break; ImpPutDate( &aTmp, p->nDouble ); break;

View File

@@ -258,11 +258,11 @@ const OUString& SbxVariable::GetName( SbxNameType t ) const
} }
if( i->nFlags & SbxFlagBits::Optional ) if( i->nFlags & SbxFlagBits::Optional )
{ {
aTmp += OUString( SbxRes( StringId::Optional ) ); aTmp += GetSbxRes( StringId::Optional );
} }
if( i->eType & SbxBYREF ) if( i->eType & SbxBYREF )
{ {
aTmp += OUString( SbxRes( StringId::ByRef ) ); aTmp += GetSbxRes( StringId::ByRef );
} }
aTmp += i->aName; aTmp += i->aName;
cType = ' '; cType = ' ';
@@ -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( StringId::As ) ); aTmp += GetSbxRes( StringId::As );
if( nt < 32 ) if( nt < 32 )
{ {
aTmp += OUString( SbxRes( static_cast<StringId>( static_cast<int>( StringId::Types ) + nt ) ) ); aTmp += GetSbxRes( static_cast<StringId>( static_cast<int>( StringId::Types ) + nt ) );
} }
else else
{ {
aTmp += OUString( SbxRes( StringId::Any ) ); aTmp += GetSbxRes( StringId::Any );
} }
} }
} }
@@ -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( StringId::As ) ); aTmp += GetSbxRes( StringId::As );
if( et < 32 ) if( et < 32 )
{ {
aTmp += OUString( SbxRes( static_cast<StringId>( static_cast<int>( StringId::Types ) + et ) ) ); aTmp += GetSbxRes( static_cast<StringId>( static_cast<int>( StringId::Types ) + et ) );
} }
else else
{ {
aTmp += OUString( SbxRes( StringId::Any ) ); aTmp += GetSbxRes( StringId::Any );
} }
} }
const_cast<SbxVariable*>(this)->aToolString = aTmp; const_cast<SbxVariable*>(this)->aToolString = aTmp;