Kaydet (Commit) 657f067b authored tarafından Noel Grandin's avatar Noel Grandin

remove some unnecessary OUStringBuffer usage

Change-Id: Iae9146a3be569107019d9c5af404b94e51e76cd5
Reviewed-on: https://gerrit.libreoffice.org/34469Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst 778d6ddc
......@@ -100,10 +100,8 @@ static PyRef getObjectFromLoaderModule( const char * func )
PyRef object( PyDict_GetItemString(getLoaderModule().get(), func ) );
if( !object.is() )
{
OUStringBuffer buf;
buf.append( "pythonloader: couldn't find core element pythonloader." );
buf.appendAscii( func );
throw RuntimeException(buf.makeStringAndClear());
throw RuntimeException( "pythonloader: couldn't find core element pythonloader." +
OUString::createFromAscii( func ));
}
return object;
}
......
......@@ -403,11 +403,7 @@ PyObject *PyUNO_invoke( PyObject *object, const char *name , PyObject *args )
OUString attrName = OUString::createFromAscii(name);
if (! me->members->xInvocation->hasMethod (attrName))
{
OUStringBuffer buf;
buf.append( "Attribute " );
buf.append( attrName );
buf.append( " unknown" );
throw RuntimeException( buf.makeStringAndClear() );
throw RuntimeException( "Attribute " + attrName + " unknown" );
}
callable = PyUNO_callable_new (
me->members->xInvocation,
......
......@@ -355,10 +355,7 @@ void Adapter::setValue( const OUString & aPropertyName, const Any & value )
{
if( !hasProperty( aPropertyName ) )
{
OUStringBuffer buf;
buf.append( "pyuno::Adapter: Property " ).append( aPropertyName );
buf.append( " is unknown." );
throw UnknownPropertyException( buf.makeStringAndClear() );
throw UnknownPropertyException( "pyuno::Adapter: Property " + aPropertyName + " is unknown." );
}
PyThreadAttach guard( mInterpreter );
......@@ -401,10 +398,7 @@ Any Adapter::getValue( const OUString & aPropertyName )
if (!pyRef.is() || PyErr_Occurred())
{
OUStringBuffer buf;
buf.append( "pyuno::Adapter: Property " ).append( aPropertyName );
buf.append( " is unknown." );
throw UnknownPropertyException( buf.makeStringAndClear() );
throw UnknownPropertyException( "pyuno::Adapter: Property " + aPropertyName + " is unknown." );
}
ret = runtime.pyObject2Any( pyRef );
}
......
......@@ -82,10 +82,7 @@ static PyRef createClass( const OUString & name, const Runtime &runtime )
TypeDescription desc( name );
if( ! desc.is() )
{
OUStringBuffer buf;
buf.append( "pyuno.getClass: uno exception " );
buf.append(name).append( " is unknown" );
throw RuntimeException( buf.makeStringAndClear() );
throw RuntimeException( "pyuno.getClass: uno exception " + name + " is unknown" );
}
bool isStruct = desc.get()->eTypeClass == typelib_TypeClass_STRUCT;
......@@ -93,12 +90,9 @@ static PyRef createClass( const OUString & name, const Runtime &runtime )
bool isInterface = desc.get()->eTypeClass == typelib_TypeClass_INTERFACE;
if( !isStruct && !isExc && ! isInterface )
{
OUStringBuffer buf;
buf.append( "pyuno.getClass: " ).append(name).append( "is a " );
buf.appendAscii(
typeClassToString( (css::uno::TypeClass) desc.get()->eTypeClass));
buf.append( ", expected EXCEPTION, STRUCT or INTERFACE" );
throw RuntimeException( buf.makeStringAndClear() );
throw RuntimeException( "pyuno.getClass: " + name + "is a " +
OUString::createFromAscii( typeClassToString( (css::uno::TypeClass) desc.get()->eTypeClass) ) +
", expected EXCEPTION, STRUCT or INTERFACE" );
}
// retrieve base class
......
......@@ -416,13 +416,10 @@ static PyObject *createUnoStructHelper(
fillStruct( me->members->xInvocation, pCompType, initializer, keywordArgs, state, runtime );
if( state.getCntConsumed() != PyTuple_Size(initializer) )
{
OUStringBuffer buf;
buf.append( "pyuno._createUnoStructHelper: too many ");
buf.append( "elements in the initializer list, expected " );
buf.append( state.getCntConsumed() );
buf.append( ", got " );
buf.append( (sal_Int32) PyTuple_Size(initializer) );
throw RuntimeException( buf.makeStringAndClear());
throw RuntimeException( "pyuno._createUnoStructHelper: too many "
"elements in the initializer list, expected " +
OUString::number(state.getCntConsumed()) + ", got " +
OUString::number( PyTuple_Size(initializer) ) );
}
ret = PyRef( PyTuple_Pack(2, returnCandidate.get(), state.getUsed()), SAL_NO_ACQUIRE);
}
......@@ -518,10 +515,7 @@ static PyObject *getConstantByName(
typeName)
>>= td))
{
OUStringBuffer buf;
buf.append( "pyuno.getConstantByName: " ).append( typeName );
buf.append( "is not a constant" );
throw RuntimeException(buf.makeStringAndClear() );
throw RuntimeException( "pyuno.getConstantByName: " + typeName + "is not a constant" );
}
PyRef constant = runtime.any2PyObject( td->getConstantValue() );
ret = constant.getAcquired();
......
......@@ -464,11 +464,8 @@ PyRef Runtime::any2PyObject (const Any &a ) const
}
}
}
OUStringBuffer buf;
buf.append( "Any carries enum " );
buf.append( a.getValueType().getTypeName());
buf.append( " with invalid value " ).append( l );
throw RuntimeException( buf.makeStringAndClear() );
throw RuntimeException( "Any carries enum " + a.getValueType().getTypeName() +
" with invalid value " + OUString::number(l) );
}
case typelib_TypeClass_EXCEPTION:
case typelib_TypeClass_STRUCT:
......@@ -480,10 +477,8 @@ PyRef Runtime::any2PyObject (const Any &a ) const
PyRef ret( PyObject_CallObject( excClass.get() , argsTuple.get() ), SAL_NO_ACQUIRE );
if( ! ret.is() )
{
OUStringBuffer buf;
buf.append( "Couldn't instantiate python representation of structured UNO type " );
buf.append( a.getValueType().getTypeName() );
throw RuntimeException( buf.makeStringAndClear() );
throw RuntimeException( "Couldn't instantiate python representation of structured UNO type " +
a.getValueType().getTypeName() );
}
if( auto e = o3tl::tryAccess<css::uno::Exception>(a) )
......@@ -550,10 +545,7 @@ PyRef Runtime::any2PyObject (const Any &a ) const
}
default:
{
OUStringBuffer buf;
buf.append( "Unknown UNO type class " );
buf.append( (sal_Int32 ) a.getValueTypeClass() );
throw RuntimeException(buf.makeStringAndClear( ) );
throw RuntimeException( "Unknown UNO type class " + OUString::number(a.getValueTypeClass()) );
}
}
}
......
......@@ -164,12 +164,9 @@ Any PyEnum2Enum( PyObject *obj )
{
if(desc.get()->eTypeClass != typelib_TypeClass_ENUM )
{
OUStringBuffer buf;
buf.append( "pyuno.checkEnum: " ).append(strTypeName).append( "is a " );
buf.appendAscii(
typeClassToString( (css::uno::TypeClass) desc.get()->eTypeClass));
buf.append( ", expected ENUM" );
throw RuntimeException( buf.makeStringAndClear() );
throw RuntimeException( "pyuno.checkEnum: " + strTypeName + "is a " +
OUString::createFromAscii(typeClassToString( (css::uno::TypeClass) desc.get()->eTypeClass)) +
", expected ENUM" );
}
desc.makeComplete();
......@@ -185,18 +182,15 @@ Any PyEnum2Enum( PyObject *obj )
}
if( i == pEnumDesc->nEnumValues )
{
OUStringBuffer buf;
buf.append( "value " ).appendAscii( stringValue ).append( "is unknown in enum " );
buf.appendAscii( PyStr_AsString( typeName.get() ) );
throw RuntimeException( buf.makeStringAndClear() );
throw RuntimeException( "value " + OUString::createFromAscii( stringValue ) +
"is unknown in enum " +
OUString::createFromAscii( PyStr_AsString( typeName.get() ) ) );
}
ret = Any( &pEnumDesc->pEnumValues[i], desc.get()->pWeakRef );
}
else
{
OUStringBuffer buf;
buf.append( "enum " ).appendAscii( PyStr_AsString(typeName.get()) ).append( " is unknown" );
throw RuntimeException( buf.makeStringAndClear() );
throw RuntimeException( "enum " + OUString::createFromAscii( PyStr_AsString(typeName.get()) ) + " is unknown" );
}
return ret;
}
......@@ -218,19 +212,15 @@ Type PyType2Type( PyObject * o )
TypeDescription desc( name );
if( ! desc.is() )
{
OUStringBuffer buf;
buf.append( "type " ).append(name).append( " is unknown" );
throw RuntimeException( buf.makeStringAndClear() );
throw RuntimeException( "type " + name + " is unknown" );
}
css::uno::TypeClass tc = *o3tl::doAccess<css::uno::TypeClass>(enumValue);
if( static_cast<css::uno::TypeClass>(desc.get()->eTypeClass) != tc )
{
OUStringBuffer buf;
buf.append( "pyuno.checkType: " ).append(name).append( " is a " );
buf.appendAscii( typeClassToString( (TypeClass) desc.get()->eTypeClass) );
buf.append( ", but type got construct with typeclass " );
buf.appendAscii( typeClassToString( tc ) );
throw RuntimeException( buf.makeStringAndClear() );
throw RuntimeException( "pyuno.checkType: " + name + " is a " +
OUString::createFromAscii( typeClassToString( (TypeClass) desc.get()->eTypeClass) ) +
", but type got construct with typeclass " +
OUString::createFromAscii( typeClassToString( tc ) ) );
}
return desc.get()->pWeakRef;
}
......
......@@ -107,10 +107,7 @@ PyRef getObjectFromUnoModule( const Runtime &runtime, const char * func )
PyRef object(PyDict_GetItemString( runtime.getImpl()->cargo->getUnoModule().get(), func ) );
if( !object.is() )
{
OUStringBuffer buf;
buf.append( "couldn't find core function " );
buf.appendAscii( func );
throw RuntimeException(buf.makeStringAndClear());
throw RuntimeException("couldn't find core function " + OUString::createFromAscii(func));
}
return object;
}
......
......@@ -371,24 +371,14 @@ static void createInstance( Reference< T > & rxOut,
if (! x.is())
{
OUStringBuffer buf( 64 );
buf.append( "cannot get service instance \"" );
buf.append( rServiceName );
buf.append( "\"!" );
throw RuntimeException( buf.makeStringAndClear() );
throw RuntimeException( "cannot get service instance \"" + rServiceName );
}
rxOut = Reference< T >::query( x );
if (! rxOut.is())
{
OUStringBuffer buf( 64 );
buf.append( "service instance \"" );
buf.append( rServiceName );
buf.append( "\" does not support demanded interface \"" );
const Type & rType = cppu::UnoType<T>::get();
buf.append( rType.getTypeName() );
buf.append( "\"!" );
throw RuntimeException( buf.makeStringAndClear() );
throw RuntimeException( "service instance \"" + rServiceName +
"\" does not support demanded interface \"" + cppu::UnoType<T>::get().getTypeName() );
}
}
......@@ -490,11 +480,7 @@ Reference< XInterface > TestImpl::resolveObject( const OUString & rUnoUrl )
if (! xResolvedObject.is())
{
OUStringBuffer buf( 32 );
buf.append( "cannot resolve object \"" );
buf.append( rUnoUrl );
buf.append( "\"!" );
throw RuntimeException( buf.makeStringAndClear() );
throw RuntimeException( "cannot resolve object \"" + rUnoUrl + "\"!" );
}
return xResolvedObject;
......@@ -987,11 +973,7 @@ sal_Int32 TestImpl::run( const Sequence< OUString > & rArgs )
stream = ::fopen( aFileName.getStr(), "w" );
if (! stream)
{
OUStringBuffer buf( 32 );
buf.append( "cannot open file for writing: \"" );
buf.append( aLogStr );
buf.append( "\"!" );
throw RuntimeException( buf.makeStringAndClear() );
throw RuntimeException( "cannot open file for writing: \"" + aLogStr + "\"!" );
}
}
}
......
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