[Libreoffice-commits] core.git: comphelper/qa comphelper/source connectivity/source desktop/source extensions/source framework/source io/source scripting/source svtools/source toolkit/source

Noel Grandin noel.grandin at collabora.co.uk
Thu Feb 2 07:49:03 UTC 2017


 comphelper/qa/unit/variadictemplates.cxx                                |   11 -
 comphelper/source/container/enumerablemap.cxx                           |   12 --
 comphelper/source/misc/configurationhelper.cxx                          |   21 ---
 comphelper/source/misc/namedvaluecollection.cxx                         |   13 --
 comphelper/source/property/propertycontainerhelper.cxx                  |   17 +-
 connectivity/source/drivers/postgresql/pq_array.cxx                     |   15 +-
 connectivity/source/drivers/postgresql/pq_baseresultset.cxx             |   32 ++---
 connectivity/source/drivers/postgresql/pq_connection.cxx                |   35 ++---
 connectivity/source/drivers/postgresql/pq_preparedstatement.cxx         |   41 +++---
 connectivity/source/drivers/postgresql/pq_resultsetmetadata.cxx         |   10 -
 connectivity/source/drivers/postgresql/pq_sequenceresultsetmetadata.cxx |   11 -
 connectivity/source/drivers/postgresql/pq_statement.cxx                 |    9 -
 connectivity/source/drivers/postgresql/pq_tools.cxx                     |   10 -
 connectivity/source/drivers/postgresql/pq_updateableresultset.cxx       |    9 -
 connectivity/source/drivers/postgresql/pq_xbase.cxx                     |    9 -
 connectivity/source/drivers/postgresql/pq_xcolumns.cxx                  |   11 -
 connectivity/source/drivers/postgresql/pq_xcontainer.cxx                |   59 +++-------
 connectivity/source/drivers/postgresql/pq_xindexes.cxx                  |   12 --
 connectivity/source/drivers/postgresql/pq_xkeys.cxx                     |    7 -
 connectivity/source/drivers/postgresql/pq_xtables.cxx                   |    8 -
 connectivity/source/drivers/postgresql/pq_xusers.cxx                    |   19 +--
 connectivity/source/drivers/postgresql/pq_xviews.cxx                    |   11 -
 desktop/source/pkgchk/unopkg/unopkg_misc.cxx                            |   10 -
 extensions/source/config/ldap/ldapaccess.cxx                            |   15 --
 framework/source/services/autorecovery.cxx                              |    7 -
 framework/source/services/pathsettings.cxx                              |   20 +--
 framework/source/xml/acceleratorconfigurationreader.cxx                 |    6 -
 io/source/acceptor/acc_socket.cxx                                       |   27 +---
 io/source/stm/omark.cxx                                                 |   48 +++-----
 scripting/source/basprov/basprov.cxx                                    |   12 --
 scripting/source/provider/ActiveMSPList.cxx                             |   26 ++--
 scripting/source/provider/MasterScriptProvider.cxx                      |    5 
 svtools/source/uno/wizard/unowizard.cxx                                 |    7 -
 toolkit/source/controls/unocontrolmodel.cxx                             |   14 --
 34 files changed, 212 insertions(+), 367 deletions(-)

New commits:
commit c0f9bdd3e644e3ebf690aff9eb1aeec4f16dbf27
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Wed Feb 1 12:24:07 2017 +0200

    unnecessary use of OUStringBuffer in throwing exceptions
    
    Change-Id: Iec1473264426f19c31e72260dfce9494389e474f
    Reviewed-on: https://gerrit.libreoffice.org/33788
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/comphelper/qa/unit/variadictemplates.cxx b/comphelper/qa/unit/variadictemplates.cxx
index 77114df..2a3d0fe 100644
--- a/comphelper/qa/unit/variadictemplates.cxx
+++ b/comphelper/qa/unit/variadictemplates.cxx
@@ -44,14 +44,11 @@ inline void extract(
             xErrorContext, static_cast<sal_Int16>(nArg) );
     }
     if (! fromAny(seq[nArg], &v)) {
-        OUStringBuffer buf;
-        buf.append( "Cannot extract ANY { " );
-        buf.append( seq[nArg].getValueType().getTypeName() );
-        buf.append( " } to " );
-        buf.append( ::cppu::UnoType<T>::get().getTypeName() );
-        buf.append( static_cast<sal_Unicode>('!') );
         throw ::com::sun::star::lang::IllegalArgumentException(
-            buf.makeStringAndClear(), xErrorContext,
+            "Cannot extract ANY { "
+            + seq[nArg].getValueType().getTypeName()
+            + " } to " + ::cppu::UnoType<T>::get().getTypeName(),
+            xErrorContext,
             static_cast<sal_Int16>(nArg) );
     }
 }
diff --git a/comphelper/source/container/enumerablemap.cxx b/comphelper/source/container/enumerablemap.cxx
index 69e8976..b87f2c1 100644
--- a/comphelper/source/container/enumerablemap.cxx
+++ b/comphelper/source/container/enumerablemap.cxx
@@ -445,13 +445,11 @@ namespace comphelper
 
         if ( !bValid )
         {
-            OUStringBuffer aMessage;
-            aMessage.append( "Incompatible value type. Found '" );
-            aMessage.append( _value.getValueTypeName() );
-            aMessage.append( "', where '" );
-            aMessage.append( m_aData.m_aValueType.getTypeName() );
-            aMessage.append( "' (or compatible type) is expected." );
-            throw IllegalTypeException( aMessage.makeStringAndClear(), *const_cast< EnumerableMap* >( this ) );
+            throw IllegalTypeException(
+                "Incompatible value type. Found '" + _value.getValueTypeName()
+                + "', where '" + m_aData.m_aValueType.getTypeName()
+                + "' (or compatible type) is expected.",
+                *const_cast< EnumerableMap* >( this ) );
         }
 
         impl_checkNaN_throw( _value, m_aData.m_aValueType );
diff --git a/comphelper/source/misc/configurationhelper.cxx b/comphelper/source/misc/configurationhelper.cxx
index 3da8109..6da6926 100644
--- a/comphelper/source/misc/configurationhelper.cxx
+++ b/comphelper/source/misc/configurationhelper.cxx
@@ -86,13 +86,8 @@ css::uno::Any ConfigurationHelper::readRelativeKey(const css::uno::Reference< cs
     xAccess->getByHierarchicalName(sRelPath) >>= xProps;
     if (!xProps.is())
     {
-        OUStringBuffer sMsg(256);
-        sMsg.append("The requested path \"");
-        sMsg.append     (sRelPath               );
-        sMsg.append("\" does not exists."  );
-
         throw css::container::NoSuchElementException(
-                    sMsg.makeStringAndClear());
+            "The requested path \"" + sRelPath + "\" does not exist.");
     }
     return xProps->getPropertyValue(sKey);
 }
@@ -109,13 +104,8 @@ void ConfigurationHelper::writeRelativeKey(const css::uno::Reference< css::uno::
     xAccess->getByHierarchicalName(sRelPath) >>= xProps;
     if (!xProps.is())
     {
-        OUStringBuffer sMsg(256);
-        sMsg.append("The requested path \"");
-        sMsg.append     (sRelPath               );
-        sMsg.append("\" does not exists."  );
-
         throw css::container::NoSuchElementException(
-                    sMsg.makeStringAndClear());
+            "The requested path \"" + sRelPath + "\" does not exist.");
     }
     xProps->setPropertyValue(sKey, aValue);
 }
@@ -130,13 +120,8 @@ css::uno::Reference< css::uno::XInterface > ConfigurationHelper::makeSureSetNode
     xAccess->getByHierarchicalName(sRelPathToSet) >>= xSet;
     if (!xSet.is())
     {
-        OUStringBuffer sMsg(256);
-        sMsg.append("The requested path \"");
-        sMsg.append     (sRelPathToSet          );
-        sMsg.append("\" does not exists."  );
-
         throw css::container::NoSuchElementException(
-                    sMsg.makeStringAndClear());
+            "The requested path \"" + sRelPathToSet + "\" does not exist." );
     }
 
     css::uno::Reference< css::uno::XInterface > xNode;
diff --git a/comphelper/source/misc/namedvaluecollection.cxx b/comphelper/source/misc/namedvaluecollection.cxx
index 53af3a7..ff47011 100644
--- a/comphelper/source/misc/namedvaluecollection.cxx
+++ b/comphelper/source/misc/namedvaluecollection.cxx
@@ -260,14 +260,11 @@ namespace comphelper
                 return true;
 
             // argument exists, but is of wrong type
-            OUStringBuffer aBuffer;
-            aBuffer.append( "Invalid value type for '" );
-            aBuffer.append     ( _rValueName );
-            aBuffer.append( "'.\nExpected: " );
-            aBuffer.append     ( _rExpectedValueType.getTypeName() );
-            aBuffer.append( "\nFound: " );
-            aBuffer.append     ( pos->second.getValueType().getTypeName() );
-            throw IllegalArgumentException( aBuffer.makeStringAndClear(), nullptr, 0 );
+            throw IllegalArgumentException(
+                "Invalid value type for '" + _rValueName
+                + "'.\nExpected: " + _rExpectedValueType.getTypeName()
+                + "\nFound: " + pos->second.getValueType().getTypeName(),
+                nullptr, 0 );
         }
 
         // argument does not exist
diff --git a/comphelper/source/property/propertycontainerhelper.cxx b/comphelper/source/property/propertycontainerhelper.cxx
index 5e7fa4f..adaa655 100644
--- a/comphelper/source/property/propertycontainerhelper.cxx
+++ b/comphelper/source/property/propertycontainerhelper.cxx
@@ -200,16 +200,13 @@ namespace
 {
     void lcl_throwIllegalPropertyValueTypeException( const PropertyDescription& _rProperty, const Any& _rValue )
     {
-        OUStringBuffer aErrorMessage;
-        aErrorMessage.append( "The given value cannot be converted to the required property type." );
-        aErrorMessage.append( "\n(property name \"" );
-        aErrorMessage.append( _rProperty.aProperty.Name );
-        aErrorMessage.append( "\", found value type \"" );
-        aErrorMessage.append( _rValue.getValueType().getTypeName() );
-        aErrorMessage.append( "\", required property type \"" );
-        aErrorMessage.append( _rProperty.aProperty.Type.getTypeName() );
-        aErrorMessage.append( "\")" );
-        throw IllegalArgumentException( aErrorMessage.makeStringAndClear(), nullptr, 4 );
+        throw IllegalArgumentException(
+            "The given value cannot be converted to the required property type."
+            " (property name \"" +  _rProperty.aProperty.Name
+            + "\", found value type \"" + _rValue.getValueType().getTypeName()
+            + "\", required property type \"" + _rProperty.aProperty.Type.getTypeName()
+            + "\")",
+            nullptr, 4 );
     }
 }
 
diff --git a/connectivity/source/drivers/postgresql/pq_array.cxx b/connectivity/source/drivers/postgresql/pq_array.cxx
index cf4b439..c00cc20 100644
--- a/connectivity/source/drivers/postgresql/pq_array.cxx
+++ b/connectivity/source/drivers/postgresql/pq_array.cxx
@@ -110,15 +110,12 @@ void Array::checkRange( sal_Int32 index, sal_Int32 count )
 {
     if( index >= 1 && index -1 + count <= (sal_Int32)m_data.size() )
         return;
-    OUStringBuffer buf;
-    buf.append( "Array::getArrayAtIndex(): allowed range for index + count " );
-    buf.append( (sal_Int32)m_data.size() );
-    buf.append( ", got " );
-    buf.append( index );
-    buf.append( " + " );
-    buf.append( count );
-
-    throw SQLException( buf.makeStringAndClear() , *this, OUString(), 1, Any());
+    throw SQLException(
+        "Array::getArrayAtIndex(): allowed range for index + count "
+        + OUString::number( m_data.size() )
+        + ", got " + OUString::number( index )
+        + " + " + OUString::number( count ),
+        *this, OUString(), 1, Any());
 
 }
 
diff --git a/connectivity/source/drivers/postgresql/pq_baseresultset.cxx b/connectivity/source/drivers/postgresql/pq_baseresultset.cxx
index 19e0309..053a3e5 100644
--- a/connectivity/source/drivers/postgresql/pq_baseresultset.cxx
+++ b/connectivity/source/drivers/postgresql/pq_baseresultset.cxx
@@ -590,11 +590,9 @@ sal_Bool BaseResultSet::convertFastPropertyValue(
     }
     default:
     {
-        OUStringBuffer buf(128);
-        buf.append( "pq_resultset: Invalid property handle (" );
-        buf.append( nHandle );
-        buf.append( ")" );
-        throw IllegalArgumentException( buf.makeStringAndClear(), *this, 2 );
+        throw IllegalArgumentException(
+            "pq_resultset: Invalid property handle (" + OUString::number( nHandle ) + ")",
+            *this, 2 );
     }
     }
     return bRet;
@@ -626,13 +624,12 @@ void BaseResultSet::checkColumnIndex(sal_Int32 index )
 {
     if( index < 1 || index > m_fieldCount )
     {
-        OUStringBuffer buf(128);
-        buf.append( "pq_resultset: index out of range (" );
-        buf.append( index );
-        buf.append( ", allowed range is 1 to " );
-        buf.append( m_fieldCount );
-        buf.append( ")" );
-        throw SQLException( buf.makeStringAndClear(), *this, OUString(), 1, Any() );
+        throw SQLException(
+            "pq_resultset: index out of range ("
+            + OUString::number( index )
+            + ", allowed range is 1 to " + OUString::number( m_fieldCount )
+            + ")",
+            *this, OUString(), 1, Any() );
     }
 
 }
@@ -641,13 +638,10 @@ void BaseResultSet::checkRowIndex()
 {
     if( m_row < 0 || m_row >= m_rowCount )
     {
-        OUStringBuffer buf( 128 );
-        buf.append( "pq_baseresultset: row index out of range, allowed is " );
-        buf.append( "0 to " );
-        buf.append( ((sal_Int32)(m_rowCount -1)) );
-        buf.append( ", got " );
-        buf.append( m_row );
-        throw SQLException( buf.makeStringAndClear(), *this, OUString(),1, Any() );
+        throw SQLException(
+            "pq_baseresultset: row index out of range, allowed is 0 to " + OUString::number( m_rowCount -1 )
+            + ", got " + OUString::number( m_row ),
+            *this, OUString(),1, Any() );
     }
 }
 
diff --git a/connectivity/source/drivers/postgresql/pq_connection.cxx b/connectivity/source/drivers/postgresql/pq_connection.cxx
index fac27fd..d652bb7 100644
--- a/connectivity/source/drivers/postgresql/pq_connection.cxx
+++ b/connectivity/source/drivers/postgresql/pq_connection.cxx
@@ -489,18 +489,17 @@ void Connection::initialize( const Sequence< Any >& aArguments )
     }
     if( aArguments.getLength() != 2 )
     {
-        OUStringBuffer buf(128);
-        buf.append( "pq_driver: expected 2 arguments, got " );
-        buf.append( aArguments.getLength( ) );
-        throw IllegalArgumentException(buf.makeStringAndClear(), Reference< XInterface > () , 0 );
+        throw IllegalArgumentException(
+            "pq_driver: expected 2 arguments, got " + OUString::number( aArguments.getLength( ) ),
+            Reference< XInterface > () , 0 );
     }
 
     if( ! (aArguments[0] >>= url) )
     {
-        OUStringBuffer buf(128);
-        buf.append( "pq_driver: expected string as first argument, got " );
-        buf.append( aArguments[0].getValueType().getTypeName() );
-        throw IllegalArgumentException( buf.makeStringAndClear() , *this, 0 );
+        throw IllegalArgumentException(
+            "pq_driver: expected string as first argument, got "
+            + aArguments[0].getValueType().getTypeName(),
+            *this, 0 );
     }
 
     tc->convertTo( aArguments[1], cppu::UnoType<decltype(args)>::get() ) >>= args;
@@ -533,14 +532,11 @@ void Connection::initialize( const Sequence< Any >& aArguments )
                 }
                 else
                     errorMessage = "#no error message#";
-                OUStringBuffer buf( 128 );
-                buf.append( "Error in database URL '" );
-                buf.append( url );
-                buf.append( "':\n" );
-                buf.append( errorMessage );
                 // HY092 is "Invalid attribute/option identifier."
                 // Just the most likely error; the error might be  HY024 "Invalid attribute value".
-                throw SQLException( buf.makeStringAndClear(), *this, "HY092", 5, Any() );
+                throw SQLException(
+                    "Error in database URL '" + url + "':\n"  + errorMessage,
+                    *this, "HY092", 5, Any() );
             }
 
             for (  PQconninfoOption * opt = oOpts.get(); opt->keyword != nullptr; ++opt)
@@ -562,17 +558,14 @@ void Connection::initialize( const Sequence< Any >& aArguments )
         throw RuntimeException("pq_driver: out of memory" );
     if( PQstatus( m_settings.pConnection ) == CONNECTION_BAD )
     {
-        OUStringBuffer buf( 128 );
-
         const char * error = PQerrorMessage( m_settings.pConnection );
         OUString errorMessage( error, strlen( error) , RTL_TEXTENCODING_ASCII_US );
-        buf.append( "Couldn't establish database connection to '" );
-        buf.append( url );
-        buf.append( "'\n" );
-        buf.append( errorMessage );
         PQfinish( m_settings.pConnection );
         m_settings.pConnection = nullptr;
-        throw SQLException( buf.makeStringAndClear(), *this, errorMessage, CONNECTION_BAD, Any() );
+        throw SQLException(
+            "Couldn't establish database connection to '" + url + "'\n"
+            + errorMessage,
+            *this, errorMessage, CONNECTION_BAD, Any() );
     }
     PQsetClientEncoding( m_settings.pConnection, "UNICODE" );
     char *p = PQuser( m_settings.pConnection );
diff --git a/connectivity/source/drivers/postgresql/pq_preparedstatement.cxx b/connectivity/source/drivers/postgresql/pq_preparedstatement.cxx
index 1ec3b80..16e7ddf 100644
--- a/connectivity/source/drivers/postgresql/pq_preparedstatement.cxx
+++ b/connectivity/source/drivers/postgresql/pq_preparedstatement.cxx
@@ -212,15 +212,13 @@ void PreparedStatement::checkColumnIndex( sal_Int32 parameterIndex )
 {
     if( parameterIndex < 1 || parameterIndex > (sal_Int32) m_vars.size() )
     {
-        OUStringBuffer buf( 128 );
-        buf.append( "pq_preparedstatement: parameter index out of range (expected 1 to " );
-        buf.append( (sal_Int32 ) m_vars.size() );
-        buf.append( ", got " );
-        buf.append( parameterIndex );
-        buf.append( ", statement '" );
-        buf.append( OStringToOUString( m_stmt, ConnectionSettings::encoding ) );
-        buf.append( "')" );
-        throw SQLException( buf.makeStringAndClear(), *this, OUString(), 1, Any () );
+        throw SQLException(
+            "pq_preparedstatement: parameter index out of range (expected 1 to "
+            + OUString::number( m_vars.size() )
+            + ", got " + OUString::number( parameterIndex )
+            + ", statement '" + OStringToOUString( m_stmt, ConnectionSettings::encoding )
+            + "')",
+            *this, OUString(), 1, Any () );
     }
 }
 void PreparedStatement::checkClosed()
@@ -580,10 +578,9 @@ void PreparedStatement::setObject( sal_Int32 parameterIndex, const Any& x )
 {
     if( ! implSetObject( this, parameterIndex, x ))
     {
-        OUStringBuffer buf;
-        buf.append( "pq_preparedstatement::setObject: can't convert value of type " );
-        buf.append( x.getValueTypeName() );
-        throw SQLException( buf.makeStringAndClear(), *this, OUString(), 1, Any () );
+        throw SQLException(
+            "pq_preparedstatement::setObject: can't convert value of type " + x.getValueTypeName(),
+            *this, OUString(), 1, Any () );
     }
 }
 
@@ -614,11 +611,10 @@ void PreparedStatement::setObjectWithInfo(
         }
         else
         {
-            OUStringBuffer buf;
-            buf.append( "pq_preparedstatement::setObjectWithInfo: can't convert value of type " );
-            buf.append( x.getValueTypeName() );
-            buf.append( " to type DECIMAL or NUMERIC" );
-            throw SQLException( buf.makeStringAndClear(), *this, OUString(), 1, Any () );
+            throw SQLException(
+                "pq_preparedstatement::setObjectWithInfo: can't convert value of type "
+                +  x.getValueTypeName() + " to type DECIMAL or NUMERIC",
+                *this, OUString(), 1, Any () );
         }
     }
     else
@@ -731,11 +727,10 @@ sal_Bool PreparedStatement::convertFastPropertyValue(
     }
     default:
     {
-        OUStringBuffer buf(128);
-        buf.append( "pq_statement: Invalid property handle (" );
-        buf.append( nHandle );
-        buf.append( ")" );
-        throw IllegalArgumentException( buf.makeStringAndClear(), *this, 2 );
+        throw IllegalArgumentException(
+            "pq_statement: Invalid property handle ("
+            + OUString::number( nHandle ) +  ")",
+            *this, 2 );
     }
     }
     return bRet;
diff --git a/connectivity/source/drivers/postgresql/pq_resultsetmetadata.cxx b/connectivity/source/drivers/postgresql/pq_resultsetmetadata.cxx
index a121354..b958ab5 100644
--- a/connectivity/source/drivers/postgresql/pq_resultsetmetadata.cxx
+++ b/connectivity/source/drivers/postgresql/pq_resultsetmetadata.cxx
@@ -436,14 +436,10 @@ void ResultSetMetaData::checkColumnIndex(sal_Int32 columnIndex)
 {
     if( columnIndex < 1 || columnIndex > m_colCount )
     {
-        OUStringBuffer buf(128);
-
-        buf.append( "pq_resultsetmetadata: index out of range (expected 1 to " );
-        buf.append( m_colCount );
-        buf.append( ", got " );
-        buf.append( columnIndex );
         throw SQLException(
-            buf.makeStringAndClear(), *this, OUString(), 1, Any() );
+            "pq_resultsetmetadata: index out of range (expected 1 to "
+            + OUString::number( m_colCount ) + ", got " + OUString::number( columnIndex ),
+            *this, OUString(), 1, Any() );
     }
 }
 
diff --git a/connectivity/source/drivers/postgresql/pq_sequenceresultsetmetadata.cxx b/connectivity/source/drivers/postgresql/pq_sequenceresultsetmetadata.cxx
index bde1ac3..2dc1dfd 100644
--- a/connectivity/source/drivers/postgresql/pq_sequenceresultsetmetadata.cxx
+++ b/connectivity/source/drivers/postgresql/pq_sequenceresultsetmetadata.cxx
@@ -179,14 +179,11 @@ void SequenceResultSetMetaData::checkColumnIndex(sal_Int32 columnIndex)
 {
     if( columnIndex < 1 || columnIndex > m_colCount )
     {
-        OUStringBuffer buf(128);
-
-        buf.append( "pq_sequenceresultsetmetadata: index out of range (expected 1 to " );
-        buf.append( m_colCount );
-        buf.append( ", got " );
-        buf.append( columnIndex );
         throw SQLException(
-            buf.makeStringAndClear(), *this, OUString(), 1, Any() );
+            "pq_sequenceresultsetmetadata: index out of range (expected 1 to "
+            + OUString::number( m_colCount )
+            + ", got " + OUString::number( columnIndex ),
+            *this, OUString(), 1, Any() );
     }
 }
 
diff --git a/connectivity/source/drivers/postgresql/pq_statement.cxx b/connectivity/source/drivers/postgresql/pq_statement.cxx
index 51a3805..31b9bf6 100644
--- a/connectivity/source/drivers/postgresql/pq_statement.cxx
+++ b/connectivity/source/drivers/postgresql/pq_statement.cxx
@@ -917,11 +917,10 @@ sal_Bool Statement::convertFastPropertyValue(
     }
     default:
     {
-        OUStringBuffer buf(128);
-        buf.append( "pq_statement: Invalid property handle (" );
-        buf.append( nHandle );
-        buf.append( ")" );
-        throw IllegalArgumentException( buf.makeStringAndClear(), *this, 2 );
+        throw IllegalArgumentException(
+            "pq_statement: Invalid property handle ("
+            + OUString::number( nHandle ) + ")",
+            *this, 2 );
     }
     }
     return bRet;
diff --git a/connectivity/source/drivers/postgresql/pq_tools.cxx b/connectivity/source/drivers/postgresql/pq_tools.cxx
index 48728f5..a7f2e28 100644
--- a/connectivity/source/drivers/postgresql/pq_tools.cxx
+++ b/connectivity/source/drivers/postgresql/pq_tools.cxx
@@ -638,15 +638,9 @@ std::vector< Any > parseArray( const OUString & str )
             brackets --;
             if( brackets < 0 )
             {
-
-                OUStringBuffer buf;
-                buf.append( "error during array parsing, didn't expect a } at position " );
-                buf.append( (sal_Int32) i );
-                buf.append( " ('" );
-                buf.append( str );
-                buf.append( "')" );
                 throw SQLException(
-                    buf.makeStringAndClear(),
+                    "error during array parsing, didn't expect a } at position "
+                    + OUString::number(i) + " ('" + str + "')",
                     Reference< XInterface > (), OUString(), 1, Any() );
             }
             if( brackets == 0 )
diff --git a/connectivity/source/drivers/postgresql/pq_updateableresultset.cxx b/connectivity/source/drivers/postgresql/pq_updateableresultset.cxx
index 3ec872e..304e769 100644
--- a/connectivity/source/drivers/postgresql/pq_updateableresultset.cxx
+++ b/connectivity/source/drivers/postgresql/pq_updateableresultset.cxx
@@ -348,11 +348,10 @@ void UpdateableResultSet::deleteRow(  )
 
     if( m_row < 0 || m_row >= m_rowCount )
     {
-        OUStringBuffer buf( 128 );
-        buf.append( "deleteRow cannot be called on invalid row (" );
-        buf.append( m_row );
-        buf.append( ")" );
-        throw SQLException( buf.makeStringAndClear() , *this, OUString(), 0, Any() );
+        throw SQLException(
+            "deleteRow cannot be called on invalid row ("
+            + OUString::number(m_row) + ")",
+            *this, OUString(), 0, Any() );
     }
 
     Reference< XStatement > stmt = extractConnectionFromStatement(m_owner)->createStatement();
diff --git a/connectivity/source/drivers/postgresql/pq_xbase.cxx b/connectivity/source/drivers/postgresql/pq_xbase.cxx
index 627e60f..8da5422 100644
--- a/connectivity/source/drivers/postgresql/pq_xbase.cxx
+++ b/connectivity/source/drivers/postgresql/pq_xbase.cxx
@@ -99,12 +99,9 @@ void ReflectionBase::setPropertyValue_NoBroadcast_public(
     sal_Int32 nHandle = m_propsDesc.getHandleByName( name );
     if( -1 == nHandle  )
     {
-        OUStringBuffer buf(128);
-        buf.append( "Unknown property '" );
-        buf.append( name );
-        buf.append( "' in " );
-        buf.append( m_implName );
-        throw css::uno::RuntimeException( buf.makeStringAndClear() , *this );
+        throw css::uno::RuntimeException(
+            "Unknown property '" + name + "' in " + m_implName,
+            *this );
     }
     setFastPropertyValue_NoBroadcast( nHandle , value );
 }
diff --git a/connectivity/source/drivers/postgresql/pq_xcolumns.cxx b/connectivity/source/drivers/postgresql/pq_xcolumns.cxx
index da43c62..86fa618 100644
--- a/connectivity/source/drivers/postgresql/pq_xcolumns.cxx
+++ b/connectivity/source/drivers/postgresql/pq_xcolumns.cxx
@@ -498,14 +498,11 @@ void Columns::dropByIndex( sal_Int32 index )
     osl::MutexGuard guard( m_refMutex->mutex );
     if( index < 0 ||  index >= (sal_Int32)m_values.size() )
     {
-        OUStringBuffer buf( 128 );
-        buf.append( "COLUMNS: Index out of range (allowed 0 to " );
-        buf.append((sal_Int32)(m_values.size() -1) );
-        buf.append( ", got " );
-        buf.append( index );
-        buf.append( ")" );
         throw css::lang::IndexOutOfBoundsException(
-            buf.makeStringAndClear(), *this );
+            "COLUMNS: Index out of range (allowed 0 to "
+            + OUString::number(m_values.size() -1)
+            + ", got " + OUString::number( index ) + ")",
+            *this );
     }
 
     Reference< XPropertySet > set;
diff --git a/connectivity/source/drivers/postgresql/pq_xcontainer.cxx b/connectivity/source/drivers/postgresql/pq_xcontainer.cxx
index 2710f8b..6a7b9dd 100644
--- a/connectivity/source/drivers/postgresql/pq_xcontainer.cxx
+++ b/connectivity/source/drivers/postgresql/pq_xcontainer.cxx
@@ -150,13 +150,9 @@ Any Container::getByName( const OUString& aName )
     String2IntMap::const_iterator ii = m_name2index.find( aName );
     if( ii == m_name2index.end() )
     {
-        OUStringBuffer buf(128);
-        buf.append( "Element "  );
-        buf.append( aName );
-        buf.append( " unknown in " );
-        buf.append( m_type );
-        buf.append( "-Container" );
-        throw NoSuchElementException( buf.makeStringAndClear() , *this );
+        throw NoSuchElementException(
+            "Element " + aName + " unknown in " + m_type + "-Container",
+            *this );
     }
     OSL_ASSERT( ii->second >= 0 && ii->second < (int)m_values.size() );
     return m_values[ ii->second ];
@@ -195,14 +191,11 @@ Any Container::getByIndex( sal_Int32 Index )
 {
     if( Index < 0 || Index >= (sal_Int32)m_values.size() )
     {
-        OUStringBuffer buf(128);
-        buf.append( "Index " );
-        buf.append( Index );
-        buf.append(" out of range for " );
-        buf.append( m_type );
-        buf.append("-Container, expected 0 <= x <= " );
-        buf.append( (sal_Int32 ) (m_values.size() -1));
-        throw IndexOutOfBoundsException( buf.makeStringAndClear(), *this );
+        throw IndexOutOfBoundsException(
+            "Index " + OUString::number( Index )
+            + " out of range for " + m_type + "-Container, expected 0 <= x <= "
+            + OUString::number(m_values.size() -1),
+            *this );
     }
     return m_values[Index];
 }
@@ -292,18 +285,10 @@ void Container::dropByName( const OUString& elementName )
     String2IntMap::const_iterator ii = m_name2index.find( elementName );
     if( ii == m_name2index.end() )
     {
-        OUStringBuffer buf( 128 );
-        buf.append( "Column " );
-        buf.append( elementName );
-        buf.append( " is unknown in " );
-        buf.append( m_type );
-//         buf.appendAscii( " " );
-//         buf.append( m_schemaName );
-//         buf.appendAscii( "." );
-//         buf.append( m_tableName );
-        buf.append( " container, so it can't be dropped" );
         throw css::container::NoSuchElementException(
-            buf.makeStringAndClear(), *this );
+            "Column " + elementName + " is unknown in "
+            + m_type + " container, so it can't be dropped",
+            *this );
     }
     dropByIndex( ii->second );
 }
@@ -313,15 +298,12 @@ void Container::dropByIndex( sal_Int32 index )
     osl::MutexGuard guard( m_refMutex->mutex );
     if( index < 0 ||  index >=(sal_Int32)m_values.size() )
     {
-        OUStringBuffer buf( 128 );
-        buf.append( "Index out of range (allowed 0 to " );
-        buf.append((sal_Int32)(m_values.size() -1) );
-        buf.append( ", got " );
-        buf.append( index );
-        buf.append( ") in " );
-        buf.append( m_type );
         throw css::lang::IndexOutOfBoundsException(
-            buf.makeStringAndClear(), *this );
+            "Index out of range (allowed 0 to "
+            + OUString::number(m_values.size() -1)
+            + ", got " + OUString::number( index )
+            + ") in " + m_type,
+            *this );
     }
 
     OUString name;
@@ -367,14 +349,9 @@ void Container::append(
 
     if( hasByName( name ) )
     {
-        OUStringBuffer buf( 128 );
-        buf.append( "a ");
-        buf.append( m_type );
-        buf.append( " with name " );
-        buf.append( name );
-        buf.append( " already exists in this container" );
         throw css::container::ElementExistException(
-            buf.makeStringAndClear() , *this );
+            "a " + m_type + " with name " + name + " already exists in this container",
+            *this );
     }
 
     int index = m_values.size();
diff --git a/connectivity/source/drivers/postgresql/pq_xindexes.cxx b/connectivity/source/drivers/postgresql/pq_xindexes.cxx
index 19001cf..031584f 100644
--- a/connectivity/source/drivers/postgresql/pq_xindexes.cxx
+++ b/connectivity/source/drivers/postgresql/pq_xindexes.cxx
@@ -243,14 +243,12 @@ void Indexes::dropByIndex( sal_Int32 index )
     osl::MutexGuard guard( m_refMutex->mutex );
     if( index < 0 ||  index >= (sal_Int32)m_values.size() )
     {
-        OUStringBuffer buf( 128 );
-        buf.append( "Indexes: Index out of range (allowed 0 to " );
-        buf.append( (sal_Int32) (m_values.size() -1) );
-        buf.append( ", got " );
-        buf.append( index );
-        buf.append( ")" );
         throw css::lang::IndexOutOfBoundsException(
-            buf.makeStringAndClear(), *this );
+            "Indexes: Index out of range (allowed 0 to "
+            + OUString::number( m_values.size() -1 )
+            + ", got " + OUString::number( index )
+            + ")",
+            *this );
     }
 
     Reference< XPropertySet > set;
diff --git a/connectivity/source/drivers/postgresql/pq_xkeys.cxx b/connectivity/source/drivers/postgresql/pq_xkeys.cxx
index 4fd0f33..4e8f772 100644
--- a/connectivity/source/drivers/postgresql/pq_xkeys.cxx
+++ b/connectivity/source/drivers/postgresql/pq_xkeys.cxx
@@ -226,11 +226,10 @@ void Keys::dropByIndex( sal_Int32 index )
     osl::MutexGuard guard( m_refMutex->mutex );
     if( index < 0 ||  index >= (sal_Int32)m_values.size() )
     {
-        OUStringBuffer buf( 128 );
-        buf.append( "TABLES: Index out of range (allowed 0 to " + OUString::number(m_values.size() -1) +
-                    ", got " + OUString::number( index ) + ")" );
         throw css::lang::IndexOutOfBoundsException(
-            buf.makeStringAndClear(), *this );
+            "TABLES: Index out of range (allowed 0 to " + OUString::number(m_values.size() -1)
+            + ", got " + OUString::number( index ) + ")",
+            *this );
     }
 
 
diff --git a/connectivity/source/drivers/postgresql/pq_xtables.cxx b/connectivity/source/drivers/postgresql/pq_xtables.cxx
index b5d39ba..dbb04549 100644
--- a/connectivity/source/drivers/postgresql/pq_xtables.cxx
+++ b/connectivity/source/drivers/postgresql/pq_xtables.cxx
@@ -313,10 +313,10 @@ void Tables::dropByIndex( sal_Int32 index )
     osl::MutexGuard guard( m_refMutex->mutex );
     if( index < 0 ||  index >= (sal_Int32)m_values.size() )
     {
-        OUStringBuffer buf( 128 );
-        buf.append( "TABLES: Index out of range (allowed 0 to " + OUString::number(m_values.size() -1) +
-                    ", got " + OUString::number( index ) + ")" );
-        throw css::lang::IndexOutOfBoundsException( buf.makeStringAndClear(), *this );
+        throw css::lang::IndexOutOfBoundsException(
+            "TABLES: Index out of range (allowed 0 to " + OUString::number(m_values.size() -1)
+            + ", got " + OUString::number( index ) + ")",
+            *this );
     }
 
     Reference< XPropertySet > set;
diff --git a/connectivity/source/drivers/postgresql/pq_xusers.cxx b/connectivity/source/drivers/postgresql/pq_xusers.cxx
index aae6c1b..ff87f1b 100644
--- a/connectivity/source/drivers/postgresql/pq_xusers.cxx
+++ b/connectivity/source/drivers/postgresql/pq_xusers.cxx
@@ -136,12 +136,9 @@ void Users::dropByName( const OUString& elementName )
     String2IntMap::const_iterator ii = m_name2index.find( elementName );
     if( ii == m_name2index.end() )
     {
-        OUStringBuffer buf( 128 );
-        buf.append( "User " );
-        buf.append( elementName );
-        buf.append( " is unknown, so it can't be dropped" );
         throw css::container::NoSuchElementException(
-            buf.makeStringAndClear(), *this );
+            "User " + elementName + " is unknown, so it can't be dropped",
+            *this );
     }
     dropByIndex( ii->second );
 }
@@ -152,14 +149,12 @@ void Users::dropByIndex( sal_Int32 index )
     osl::MutexGuard guard( m_refMutex->mutex );
     if( index < 0 ||  index >= (sal_Int32)m_values.size() )
     {
-        OUStringBuffer buf( 128 );
-        buf.append( "USERS: Index out of range (allowed 0 to " );
-        buf.append( (sal_Int32) (m_values.size() -1) );
-        buf.append( ", got " );
-        buf.append( index );
-        buf.append( ")" );
         throw css::lang::IndexOutOfBoundsException(
-            buf.makeStringAndClear(), *this );
+            "USERS: Index out of range (allowed 0 to "
+            + OUString::number( m_values.size() -1 )
+            +  ", got " + OUString::number( index )
+            + ")",
+            *this );
     }
 
     Reference< XPropertySet > set;
diff --git a/connectivity/source/drivers/postgresql/pq_xviews.cxx b/connectivity/source/drivers/postgresql/pq_xviews.cxx
index 311fb88..31b4c35 100644
--- a/connectivity/source/drivers/postgresql/pq_xviews.cxx
+++ b/connectivity/source/drivers/postgresql/pq_xviews.cxx
@@ -163,10 +163,8 @@ void Views::dropByName( const OUString& elementName )
     String2IntMap::const_iterator ii = m_name2index.find( elementName );
     if( ii == m_name2index.end() )
     {
-        OUStringBuffer buf( 128 );
-        buf.append( "View " + elementName + " is unknown, so it can't be dropped" );
         throw css::container::NoSuchElementException(
-            buf.makeStringAndClear(), *this );
+            "View " + elementName + " is unknown, so it can't be dropped", *this );
     }
     dropByIndex( ii->second );
 }
@@ -176,11 +174,10 @@ void Views::dropByIndex( sal_Int32 index )
     osl::MutexGuard guard( m_refMutex->mutex );
     if( index < 0 ||  index >= (sal_Int32)m_values.size() )
     {
-        OUStringBuffer buf( 128 );
-        buf.append( "VIEWS: Index out of range (allowed 0 to " + OUString::number(m_values.size() -1) +
-                    ", got " + OUString::number( index ) + ")");
         throw css::lang::IndexOutOfBoundsException(
-            buf.makeStringAndClear(), *this );
+            "VIEWS: Index out of range (allowed 0 to " + OUString::number(m_values.size() -1)
+            + ", got " + OUString::number( index ) + ")",
+            *this );
     }
 
     Reference< XPropertySet > set;
diff --git a/desktop/source/pkgchk/unopkg/unopkg_misc.cxx b/desktop/source/pkgchk/unopkg/unopkg_misc.cxx
index eaab730..031c6dd 100644
--- a/desktop/source/pkgchk/unopkg/unopkg_misc.cxx
+++ b/desktop/source/pkgchk/unopkg/unopkg_misc.cxx
@@ -211,13 +211,9 @@ OUString makeAbsoluteFileUrl(
     if (osl_getAbsoluteFileURL(
             base_url.pData, file_url.pData, &abs.pData ) != osl_File_E_None)
     {
-        OUStringBuffer buf;
-        buf.append( "making absolute file url failed: \"" );
-        buf.append( base_url );
-        buf.append( "\" (base-url) and \"" );
-        buf.append( file_url );
-        buf.append( "\" (file-url)!" );
-        throw RuntimeException( buf.makeStringAndClear() );
+        throw RuntimeException(
+            "making absolute file url failed: \"" + base_url
+            + "\" (base-url) and \"" + file_url + "\" (file-url)!" );
     }
     return abs[ abs.getLength() -1 ] == '/'
         ? abs.copy( 0, abs.getLength() -1 ) : abs;
diff --git a/extensions/source/config/ldap/ldapaccess.cxx b/extensions/source/config/ldap/ldapaccess.cxx
index a1a0fde..87d686e 100644
--- a/extensions/source/config/ldap/ldapaccess.cxx
+++ b/extensions/source/config/ldap/ldapaccess.cxx
@@ -148,10 +148,7 @@ void LdapConnection::initConnection()
 {
     if (mLdapDefinition.mServer.isEmpty())
     {
-        OUStringBuffer message ;
-
-        message.append("Cannot initialise connection to LDAP: No server specified.") ;
-        throw ldap::LdapConnectionException(message.makeStringAndClear()) ;
+        throw ldap::LdapConnectionException("Cannot initialise connection to LDAP: No server specified.");
     }
 
     if (mLdapDefinition.mPort == 0) mLdapDefinition.mPort = LDAP_PORT;
@@ -165,13 +162,9 @@ void LdapConnection::initConnection()
 #endif
     if (mConnection == nullptr)
     {
-        OUStringBuffer message ;
-
-        message.append("Cannot initialise connection to LDAP server ") ;
-        message.append(mLdapDefinition.mServer) ;
-        message.append(":") ;
-        message.append(mLdapDefinition.mPort) ;
-        throw ldap::LdapConnectionException(message.makeStringAndClear());
+        throw ldap::LdapConnectionException(
+            "Cannot initialise connection to LDAP server "
+            + mLdapDefinition.mServer + ":" + OUString::number(mLdapDefinition.mPort));
     }
 }
 
diff --git a/framework/source/services/autorecovery.cxx b/framework/source/services/autorecovery.cxx
index 4739bdc..fb9f346 100644
--- a/framework/source/services/autorecovery.cxx
+++ b/framework/source/services/autorecovery.cxx
@@ -3477,13 +3477,8 @@ void AutoRecovery::implts_openOneDoc(const OUString&               sURL       ,
         }
 
         // re-throw
-        OUStringBuffer sMsg(256);
-        sMsg.append("Recovery of \"");
-        sMsg.append     (sURL            );
-        sMsg.append("\" failed."    );
-
         throw css::lang::WrappedTargetException(
-            sMsg.makeStringAndClear(),
+            "Recovery of \"" + sURL + "\" failed.",
             static_cast< css::frame::XDispatch* >(this),
             aCaughtException
         );
diff --git a/framework/source/services/pathsettings.cxx b/framework/source/services/pathsettings.cxx
index bd4488e..0c632ef 100644
--- a/framework/source/services/pathsettings.cxx
+++ b/framework/source/services/pathsettings.cxx
@@ -1225,12 +1225,10 @@ void PathSettings::impl_setPathValue(      sal_Int32      nID ,
              {
                 if (aChangePath.bIsSinglePath)
                 {
-                    OUStringBuffer sMsg(256);
-                    sMsg.append("The path '"    );
-                    sMsg.append     (aChangePath.sPathName);
-                    sMsg.append("' is defined as SINGLE_PATH. It's sub set of internal paths can't be set.");
-                    throw css::uno::Exception(sMsg.makeStringAndClear(),
-                                              static_cast< ::cppu::OWeakObject* >(this));
+                    throw css::uno::Exception(
+                        "The path '" + aChangePath.sPathName
+                        + "' is defined as SINGLE_PATH. It's sub set of internal paths can't be set.",
+                        static_cast< ::cppu::OWeakObject* >(this));
                 }
 
                 css::uno::Sequence<OUString> lTmpList;
@@ -1246,12 +1244,10 @@ void PathSettings::impl_setPathValue(      sal_Int32      nID ,
              {
                 if (aChangePath.bIsSinglePath)
                 {
-                    OUStringBuffer sMsg(256);
-                    sMsg.append("The path '"    );
-                    sMsg.append     (aChangePath.sPathName);
-                    sMsg.append("' is defined as SINGLE_PATH. It's sub set of internal paths can't be set.");
-                    throw css::uno::Exception(sMsg.makeStringAndClear(),
-                                              static_cast< ::cppu::OWeakObject* >(this));
+                    throw css::uno::Exception(
+                        "The path '" + aChangePath.sPathName
+                        + "' is defined as SINGLE_PATH. It's sub set of internal paths can't be set.",
+                        static_cast< ::cppu::OWeakObject* >(this));
                 }
 
                 css::uno::Sequence<OUString> lTmpList;
diff --git a/framework/source/xml/acceleratorconfigurationreader.cxx b/framework/source/xml/acceleratorconfigurationreader.cxx
index b73f1f7..ac0afbc 100644
--- a/framework/source/xml/acceleratorconfigurationreader.cxx
+++ b/framework/source/xml/acceleratorconfigurationreader.cxx
@@ -47,12 +47,8 @@ namespace framework{
  */
 #define THROW_PARSEEXCEPTION(COMMENT)                                   \
     {                                                                   \
-        OUStringBuffer sMessage(256);                            \
-        sMessage.append     (implts_getErrorLineString());              \
-        sMessage.append(COMMENT                    );              \
-                                                                        \
         throw css::xml::sax::SAXException(                              \
-                sMessage.makeStringAndClear(),                          \
+                implts_getErrorLineString() + COMMENT,                  \
                 static_cast< css::xml::sax::XDocumentHandler* >(this),  \
                 css::uno::Any());                                       \
     }
diff --git a/io/source/acceptor/acc_socket.cxx b/io/source/acceptor/acc_socket.cxx
index 6d6a7b1..e1cf5a3 100644
--- a/io/source/acceptor/acc_socket.cxx
+++ b/io/source/acceptor/acc_socket.cxx
@@ -307,34 +307,29 @@ namespace io_acceptor {
     {
         if( ! m_addr.setPort( m_nPort ) )
         {
-            OUStringBuffer message( 128 );
-            message.append( "acc_socket.cxx:SocketAcceptor::init - error - invalid tcp/ip port " );
-            message.append( (sal_Int32) m_nPort );
-            throw ConnectionSetupException( message.makeStringAndClear() );
+            throw ConnectionSetupException(
+                "acc_socket.cxx:SocketAcceptor::init - error - invalid tcp/ip port " +
+                OUString::number( m_nPort ));
         }
         if( ! m_addr.setHostname( m_sSocketName.pData ) )
         {
-            OUStringBuffer message( 128 );
-            message.append( "acc_socket.cxx:SocketAcceptor::init - error - invalid host " );
-            message.append( m_sSocketName );
-            throw ConnectionSetupException( message.makeStringAndClear() );
+            throw ConnectionSetupException(
+                "acc_socket.cxx:SocketAcceptor::init - error - invalid host " + m_sSocketName );
         }
         m_socket.setOption( osl_Socket_OptionReuseAddr, 1);
 
         if(! m_socket.bind(m_addr) )
         {
-            OUStringBuffer message( 128 );
-            message.append( "acc_socket.cxx:SocketAcceptor::init - error - couldn't bind on " );
-            message.append( m_sSocketName ).append( ":" ).append((sal_Int32)m_nPort);
-            throw ConnectionSetupException( message.makeStringAndClear() );
+            throw ConnectionSetupException(
+                "acc_socket.cxx:SocketAcceptor::init - error - couldn't bind on " +
+                m_sSocketName + ":" + OUString::number(m_nPort));
         }
 
         if(! m_socket.listen() )
         {
-            OUStringBuffer message( 128 );
-            message.append( "acc_socket.cxx:SocketAcceptor::init - error - can't listen on " );
-            message.append( m_sSocketName ).append( ":" ).append( (sal_Int32) m_nPort);
-            throw ConnectionSetupException( message.makeStringAndClear() );
+            throw ConnectionSetupException(
+                "acc_socket.cxx:SocketAcceptor::init - error - can't listen on " +
+                m_sSocketName  + ":" + OUString::number(m_nPort) );
         }
     }
 
diff --git a/io/source/stm/omark.cxx b/io/source/stm/omark.cxx
index dc9fbb8..551012f 100644
--- a/io/source/stm/omark.cxx
+++ b/io/source/stm/omark.cxx
@@ -212,11 +212,9 @@ void OMarkableOutputStream::deleteMark(sal_Int32 Mark)
     map<sal_Int32,sal_Int32,less<sal_Int32> >::iterator ii = m_mapMarks.find( Mark );
 
     if( ii == m_mapMarks.end() ) {
-        OUStringBuffer buf( 128 );
-        buf.append( "MarkableOutputStream::deleteMark unknown mark (" );
-        buf.append( Mark );
-        buf.append( ")");
-        throw IllegalArgumentException( buf.makeStringAndClear(), *this, 0);
+        throw IllegalArgumentException(
+            "MarkableOutputStream::deleteMark unknown mark (" + OUString::number(Mark) + ")",
+            *this, 0);
     }
     else {
         m_mapMarks.erase( ii );
@@ -230,11 +228,9 @@ void OMarkableOutputStream::jumpToMark(sal_Int32 nMark)
     map<sal_Int32,sal_Int32,less<sal_Int32> >::iterator ii = m_mapMarks.find( nMark );
 
     if( ii == m_mapMarks.end() ) {
-        OUStringBuffer buf( 128 );
-        buf.append( "MarkableOutputStream::jumpToMark unknown mark (" );
-        buf.append( nMark );
-        buf.append( ")");
-        throw IllegalArgumentException( buf.makeStringAndClear(), *this, 0);
+        throw IllegalArgumentException(
+            "MarkableOutputStream::jumpToMark unknown mark (" + OUString::number(nMark) + ")",
+            *this, 0);
     }
     else {
         m_nCurrentPos = (*ii).second;
@@ -256,11 +252,9 @@ sal_Int32 OMarkableOutputStream::offsetToMark(sal_Int32 nMark)
 
     if( ii == m_mapMarks.end() )
     {
-        OUStringBuffer buf( 128 );
-        buf.append( "MarkableOutputStream::offsetToMark unknown mark (" );
-        buf.append( nMark );
-        buf.append( ")");
-        throw IllegalArgumentException( buf.makeStringAndClear(), *this, 0);
+        throw IllegalArgumentException(
+            "MarkableOutputStream::offsetToMark unknown mark (" + OUString::number(nMark) + ")",
+            *this, 0);
     }
     return m_nCurrentPos - (*ii).second;
 }
@@ -650,11 +644,9 @@ void OMarkableInputStream::deleteMark(sal_Int32 Mark)
     map<sal_Int32,sal_Int32,less<sal_Int32> >::iterator ii = m_mapMarks.find( Mark );
 
     if( ii == m_mapMarks.end() ) {
-        OUStringBuffer buf( 128 );
-        buf.append( "MarkableInputStream::deleteMark unknown mark (" );
-        buf.append( Mark );
-        buf.append( ")");
-        throw IllegalArgumentException( buf.makeStringAndClear(), *this , 0 );
+        throw IllegalArgumentException(
+            "MarkableInputStream::deleteMark unknown mark (" + OUString::number(Mark) + ")",
+            *this , 0 );
     }
     else {
         m_mapMarks.erase( ii );
@@ -669,11 +661,9 @@ void OMarkableInputStream::jumpToMark(sal_Int32 nMark)
 
     if( ii == m_mapMarks.end() )
     {
-        OUStringBuffer buf( 128 );
-        buf.append( "MarkableInputStream::jumpToMark unknown mark (" );
-        buf.append( nMark );
-        buf.append( ")");
-        throw IllegalArgumentException( buf.makeStringAndClear(), *this , 0 );
+        throw IllegalArgumentException(
+            "MarkableInputStream::jumpToMark unknown mark (" + OUString::number(nMark) + ")",
+            *this , 0 );
     }
     else
     {
@@ -695,11 +685,9 @@ sal_Int32 OMarkableInputStream::offsetToMark(sal_Int32 nMark)
 
     if( ii == m_mapMarks.end() )
     {
-        OUStringBuffer buf( 128 );
-        buf.append( "MarkableInputStream::offsetToMark unknown mark (" );
-        buf.append( nMark );
-        buf.append( ")");
-        throw IllegalArgumentException( buf.makeStringAndClear(), *this , 0 );
+        throw IllegalArgumentException(
+            "MarkableInputStream::offsetToMark unknown mark (" + OUString::number(nMark) + ")",
+            *this, 0 );
     }
     return m_nCurrentPos - (*ii).second;
 }
diff --git a/scripting/source/basprov/basprov.cxx b/scripting/source/basprov/basprov.cxx
index 39a95bd..3a1c047 100644
--- a/scripting/source/basprov/basprov.cxx
+++ b/scripting/source/basprov/basprov.cxx
@@ -373,14 +373,12 @@ namespace basprov
 
         if ( !xScript.is() )
         {
-            OUStringBuffer aMessage;
-            aMessage.append( "The following Basic script could not be found:\n" );
-            aMessage.append( "library: '" ).append( aLibrary ).append( "'\n" );
-            aMessage.append( "module: '" ).append( aModule ).append( "'\n" );
-            aMessage.append( "method: '" ).append( aMethod ).append( "'\n" );
-            aMessage.append( "location: '" ).append( aLocation ).append( "'\n" );
             throw provider::ScriptFrameworkErrorException(
-                aMessage.makeStringAndClear(),
+                "The following Basic script could not be found:\n"
+                "library: '" + aLibrary + "'\n"
+                "module: '" + aModule + "'\n"
+                "method: '" + aMethod + "'\n"
+                "location: '" + aLocation + "'\n",
                 Reference< XInterface >(),
                 scriptURI, "Basic",
                 provider::ScriptFrameworkErrorType::NO_SUCH_SCRIPT );
diff --git a/scripting/source/provider/ActiveMSPList.cxx b/scripting/source/provider/ActiveMSPList.cxx
index 5ff52ea..c107d28 100644
--- a/scripting/source/provider/ActiveMSPList.cxx
+++ b/scripting/source/provider/ActiveMSPList.cxx
@@ -137,10 +137,10 @@ Reference< provider::XScriptProvider >
         xScripts.set( xContext->getScriptContainer() );
     if ( !xScripts.is() )
     {
-        OUStringBuffer buf;
-        buf.append( "Failed to create MasterScriptProvider for ScriptInvocationContext: " );
-        buf.append( "Component supporting XEmbeddScripts interface not found." );
-        throw lang::IllegalArgumentException( buf.makeStringAndClear(), nullptr, 1 );
+        throw lang::IllegalArgumentException(
+            "Failed to create MasterScriptProvider for ScriptInvocationContext: "
+            "Component supporting XEmbeddScripts interface not found.",
+            nullptr, 1 );
     }
 
     ::osl::MutexGuard guard( m_mutex );
@@ -175,11 +175,11 @@ Reference< provider::XScriptProvider >
             Reference< document::XScriptInvocationContext > xScriptsContext( xModel, UNO_QUERY );
             if ( !xScripts.is() && !xScriptsContext.is() )
             {
-                OUStringBuffer buf;
-                buf.append( "Failed to create MasterScriptProvider for '" );
-                buf.append     ( context );
-                buf.append( "': Either XEmbeddScripts or XScriptInvocationContext need to be supported by the document." );
-                throw lang::IllegalArgumentException( buf.makeStringAndClear(), nullptr, 1 );
+                throw lang::IllegalArgumentException(
+                    "Failed to create MasterScriptProvider for '"
+                    + context +
+                    "': Either XEmbeddScripts or XScriptInvocationContext need to be supported by the document.",
+                    nullptr, 1 );
             }
 
             ::osl::MutexGuard guard( m_mutex );
@@ -221,12 +221,10 @@ Reference< provider::XScriptProvider >
     }
     catch( const Exception& )
     {
-        OUStringBuffer aMessage;
-        aMessage.append( "Failed to create MasterScriptProvider for context '" );
-        aMessage.append     ( context );
-        aMessage.append( "'." );
         throw lang::WrappedTargetRuntimeException(
-            aMessage.makeStringAndClear(), *this, ::cppu::getCaughtException() );
+            "Failed to create MasterScriptProvider for context '"
+            + context + "'.",
+            *this, ::cppu::getCaughtException() );
     }
     return msp;
 }
diff --git a/scripting/source/provider/MasterScriptProvider.cxx b/scripting/source/provider/MasterScriptProvider.cxx
index 941cd07..283de45 100644
--- a/scripting/source/provider/MasterScriptProvider.cxx
+++ b/scripting/source/provider/MasterScriptProvider.cxx
@@ -157,10 +157,11 @@ void SAL_CALL MasterScriptProvider::initialize( const Sequence < Any >& args )
 
                 OUStringBuffer buf;
                 buf.append( "MasterScriptProvider::initialize: caught " );
-                buf.append     ( aError.getValueTypeName() );
+                buf.append( aError.getValueTypeName() );
                 buf.append( ":" );
 
-                Exception aException; aError >>= aException;
+                Exception aException;
+                aError >>= aException;
                 buf.append     ( aException.Message );
                 throw lang::WrappedTargetException( buf.makeStringAndClear(), *this, aError );
             }
diff --git a/svtools/source/uno/wizard/unowizard.cxx b/svtools/source/uno/wizard/unowizard.cxx
index d4977cf..d585739 100644
--- a/svtools/source/uno/wizard/unowizard.cxx
+++ b/svtools/source/uno/wizard/unowizard.cxx
@@ -195,12 +195,9 @@ namespace {
                 {
                     if ( i_rPaths[i][j] <= nPreviousPageID )
                     {
-                        OStringBuffer message;
-                        message.append( "Path " );
-                        message.append( i );
-                        message.append( ": invalid page ID sequence - each page ID must be greater than the previous one." );
                         throw IllegalArgumentException(
-                            OStringToOUString( message.makeStringAndClear(), RTL_TEXTENCODING_ASCII_US ),
+                            "Path " + OUString::number(i)
+                            + ": invalid page ID sequence - each page ID must be greater than the previous one.",
                             i_rContext, 2 );
                     }
                     nPreviousPageID = i_rPaths[i][j];
diff --git a/toolkit/source/controls/unocontrolmodel.cxx b/toolkit/source/controls/unocontrolmodel.cxx
index d7e0ab6..3a2cf61 100644
--- a/toolkit/source/controls/unocontrolmodel.cxx
+++ b/toolkit/source/controls/unocontrolmodel.cxx
@@ -1143,17 +1143,11 @@ sal_Bool UnoControlModel::convertFastPropertyValue( Any & rConvertedValue, Any &
 
                 if (!bConverted)
                 {
-                    OUStringBuffer aErrorMessage;
-                    aErrorMessage.append( "Unable to convert the given value for the property " );
-                    aErrorMessage.append     ( GetPropertyName( (sal_uInt16)nPropId ) );
-                    aErrorMessage.append( ".\n" );
-                    aErrorMessage.append( "Expected type: " );
-                    aErrorMessage.append     ( pDestType->getTypeName() );
-                    aErrorMessage.append( "\n" );
-                    aErrorMessage.append( "Found type: " );
-                    aErrorMessage.append     ( rValue.getValueType().getTypeName() );
                     throw css::lang::IllegalArgumentException(
-                        aErrorMessage.makeStringAndClear(),
+                        "Unable to convert the given value for the property "
+                        + GetPropertyName( (sal_uInt16)nPropId )
+                        + ".\nExpected type: " + pDestType->getTypeName()
+                        + "\nFound type: " + rValue.getValueType().getTypeName(),
                         static_cast< css::beans::XPropertySet* >(this),
                         1);
                 }


More information about the Libreoffice-commits mailing list