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

View File

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

View File

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

View File

@@ -72,13 +72,9 @@ static const char* pSbxRes[] = {
"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: */

View File

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

View File

@@ -102,8 +102,8 @@ OUString ImpGetString( const SbxValues* p )
}
case SbxERROR:
// Here the String "Error n" is generated
aRes = SbxRes( StringId::ErrorMsg );
aRes += OUString::number(p->nUShort); break;
aRes = GetSbxRes( StringId::ErrorMsg ) + OUString::number(p->nUShort);
break;
case SbxDATE:
ImpPutDate( &aTmp, p->nDouble ); break;

View File

@@ -258,11 +258,11 @@ const OUString& SbxVariable::GetName( SbxNameType t ) const
}
if( i->nFlags & SbxFlagBits::Optional )
{
aTmp += OUString( SbxRes( StringId::Optional ) );
aTmp += GetSbxRes( StringId::Optional );
}
if( i->eType & SbxBYREF )
{
aTmp += OUString( SbxRes( StringId::ByRef ) );
aTmp += GetSbxRes( 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( StringId::As ) );
aTmp += GetSbxRes( StringId::As );
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
{
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
if( t == SbxNAME_LONG_TYPES && et != SbxEMPTY )
{
aTmp += OUString( SbxRes( StringId::As ) );
aTmp += GetSbxRes( StringId::As );
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
{
aTmp += OUString( SbxRes( StringId::Any ) );
aTmp += GetSbxRes( StringId::Any );
}
}
const_cast<SbxVariable*>(this)->aToolString = aTmp;