[Libreoffice-commits] core.git: 2 commits - include/svx pyuno/source sw/source testtools/source

Noel Grandin noel.grandin at collabora.co.uk
Tue Feb 21 06:06:05 UTC 2017


 include/svx/svdobj.hxx                  |    1 
 pyuno/source/loader/pyuno_loader.cxx    |    6 +----
 pyuno/source/module/pyuno.cxx           |    6 -----
 pyuno/source/module/pyuno_adapter.cxx   |   10 +--------
 pyuno/source/module/pyuno_except.cxx    |   14 +++----------
 pyuno/source/module/pyuno_module.cxx    |   16 ++++-----------
 pyuno/source/module/pyuno_runtime.cxx   |   18 ++++------------
 pyuno/source/module/pyuno_type.cxx      |   34 +++++++++++---------------------
 pyuno/source/module/pyuno_util.cxx      |    5 ----
 sw/source/core/draw/dcontact.cxx        |    1 
 testtools/source/performance/ubtest.cxx |   28 ++++----------------------
 11 files changed, 37 insertions(+), 102 deletions(-)

New commits:
commit 8b1bb368eb07186a681918871b5c534fa88c02be
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Mon Feb 20 14:02:26 2017 +0200

    remove unused ChildCopy from SdrUserCallType enum
    
    Change-Id: If08d4c7b3a8565672e27e008d4806510cf8aab1e
    Reviewed-on: https://gerrit.libreoffice.org/34470
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/include/svx/svdobj.hxx b/include/svx/svdobj.hxx
index 308ffb9..cce1221 100644
--- a/include/svx/svdobj.hxx
+++ b/include/svx/svdobj.hxx
@@ -165,7 +165,6 @@ enum class SdrUserCallType {
     ChildResize,      // a child within a group has changed
     ChildChangeAttr,  // a child within a group has changed
     ChildDelete,      // a child within a group has changed
-    ChildCopy,        // a child within a group has changed
     ChildInserted,    // a child within a group has changed
     ChildRemoved      // a child within a group has changed
 };
diff --git a/sw/source/core/draw/dcontact.cxx b/sw/source/core/draw/dcontact.cxx
index 6d2c08b..178705e 100644
--- a/sw/source/core/draw/dcontact.cxx
+++ b/sw/source/core/draw/dcontact.cxx
@@ -1245,7 +1245,6 @@ void SwDrawContact::Changed_( const SdrObject& rObj,
         case SdrUserCallType::ChildResize :
         case SdrUserCallType::ChildChangeAttr :
         case SdrUserCallType::ChildDelete :
-        case SdrUserCallType::ChildCopy :
         {
             // #i31698# - improvement
             // get instance <SwAnchoredDrawObject> only once
commit 657f067b917169f41a8432c8f329877f6e50c3f6
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Mon Feb 20 13:55:39 2017 +0200

    remove some unnecessary OUStringBuffer usage
    
    Change-Id: Iae9146a3be569107019d9c5af404b94e51e76cd5
    Reviewed-on: https://gerrit.libreoffice.org/34469
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/pyuno/source/loader/pyuno_loader.cxx b/pyuno/source/loader/pyuno_loader.cxx
index 0187863..adbf6c8 100644
--- a/pyuno/source/loader/pyuno_loader.cxx
+++ b/pyuno/source/loader/pyuno_loader.cxx
@@ -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;
 }
diff --git a/pyuno/source/module/pyuno.cxx b/pyuno/source/module/pyuno.cxx
index 473df58..0281f70 100644
--- a/pyuno/source/module/pyuno.cxx
+++ b/pyuno/source/module/pyuno.cxx
@@ -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,
diff --git a/pyuno/source/module/pyuno_adapter.cxx b/pyuno/source/module/pyuno_adapter.cxx
index 9d2140e..3a3b572 100644
--- a/pyuno/source/module/pyuno_adapter.cxx
+++ b/pyuno/source/module/pyuno_adapter.cxx
@@ -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 );
     }
diff --git a/pyuno/source/module/pyuno_except.cxx b/pyuno/source/module/pyuno_except.cxx
index 643f3aa..074fd7d 100644
--- a/pyuno/source/module/pyuno_except.cxx
+++ b/pyuno/source/module/pyuno_except.cxx
@@ -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
diff --git a/pyuno/source/module/pyuno_module.cxx b/pyuno/source/module/pyuno_module.cxx
index 8388880..40ed69e 100644
--- a/pyuno/source/module/pyuno_module.cxx
+++ b/pyuno/source/module/pyuno_module.cxx
@@ -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();
diff --git a/pyuno/source/module/pyuno_runtime.cxx b/pyuno/source/module/pyuno_runtime.cxx
index 755a6dc..69e5a17 100644
--- a/pyuno/source/module/pyuno_runtime.cxx
+++ b/pyuno/source/module/pyuno_runtime.cxx
@@ -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()) );
     }
     }
 }
diff --git a/pyuno/source/module/pyuno_type.cxx b/pyuno/source/module/pyuno_type.cxx
index 2de1b90..b09c78d 100644
--- a/pyuno/source/module/pyuno_type.cxx
+++ b/pyuno/source/module/pyuno_type.cxx
@@ -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;
 }
diff --git a/pyuno/source/module/pyuno_util.cxx b/pyuno/source/module/pyuno_util.cxx
index 4f5901e..ecb3832 100644
--- a/pyuno/source/module/pyuno_util.cxx
+++ b/pyuno/source/module/pyuno_util.cxx
@@ -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;
 }
diff --git a/testtools/source/performance/ubtest.cxx b/testtools/source/performance/ubtest.cxx
index acf0969..065d473 100644
--- a/testtools/source/performance/ubtest.cxx
+++ b/testtools/source/performance/ubtest.cxx
@@ -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 + "\"!" );
                 }
             }
         }


More information about the Libreoffice-commits mailing list