From f863d2602fca7d180f49cc4b6fb1bdba57e6a012 Mon Sep 17 00:00:00 2001 From: Krisztian Pinter Date: Sat, 28 Mar 2015 05:18:46 +0000 Subject: fdo#57950 Replace chained append() with operator+ Replaced all in cli_ure Change-Id: I144542f386fe26444c290edd9e23b26cb07941a6 Reviewed-on: https://gerrit.libreoffice.org/15040 Tested-by: Jenkins Reviewed-by: Noel Grandin --- cli_ure/source/uno_bridge/cli_data.cxx | 104 ++++++++------------------------ cli_ure/source/uno_bridge/cli_proxy.cxx | 36 +++-------- cli_ure/source/uno_bridge/cli_uno.cxx | 6 +- 3 files changed, 33 insertions(+), 113 deletions(-) (limited to 'cli_ure/source/uno_bridge') diff --git a/cli_ure/source/uno_bridge/cli_data.cxx b/cli_ure/source/uno_bridge/cli_data.cxx index 3efd7a426a52..68cd3aa20936 100644 --- a/cli_ure/source/uno_bridge/cli_data.cxx +++ b/cli_ure/source/uno_bridge/cli_data.cxx @@ -443,10 +443,7 @@ typelib_TypeDescriptionReference* mapCliType(System::Type^ cliType) } if (retVal == NULL) { - OUStringBuffer buf( 128 ); - buf.append( "[cli_uno bridge] mapCliType():could not map type: " ); - buf.append(mapCliString(cliType->FullName)); - throw BridgeRuntimeError( buf.makeStringAndClear() ); + throw BridgeRuntimeError("[cli_uno bridge] mapCliType():could not map type: " + mapCliString(cliType->FullName)); } return retVal; } @@ -975,11 +972,7 @@ void Bridge::map_to_uno(void * uno_data, System::Object^ cli_data, } default: { - OUStringBuffer buf( 128 ); - buf.append( "[map_to_uno():" ); - buf.append(value_td.getTypeName()); - buf.append( "] unsupported value type of any!" ); - throw BridgeRuntimeError( buf.makeStringAndClear() ); + throw BridgeRuntimeError("[map_to_uno():" + value_td.getTypeName() + "] unsupported value type of any!"); } } } @@ -988,20 +981,15 @@ void Bridge::map_to_uno(void * uno_data, System::Object^ cli_data, // ToDo check this if (assign) uno_any_construct( pAny, 0, 0, 0 ); // restore some valid any - OUStringBuffer buf( 256 ); - buf.append( "[map_to_uno():Any" ); - buf.append(value_td.getTypeName()); - buf.append( "]The Any type "); - buf.append(value_td.getTypeName()); - buf.append( " does not correspond to its value type: " ); + OUString str = "[map_to_uno():Any" + value_td.getTypeName() + "]The Any type " + value_td.getTypeName() + " does not correspond to its value type: "; if(aAny.Value != nullptr) { css::uno::Type td(mapCliType(aAny.Value->GetType()), SAL_NO_ACQUIRE); - buf.append(td.getTypeName()); + str += td.getTypeName(); } if (assign) uno_any_construct( pAny, 0, 0, 0 ); // restore some valid any - throw BridgeRuntimeError( buf.makeStringAndClear() ); + throw BridgeRuntimeError(str); } catch (BridgeRuntimeError& ) { @@ -1081,10 +1069,7 @@ void Bridge::map_to_uno(void * uno_data, System::Object^ cli_data, } else { - OUStringBuffer buf(512); - buf.append("[map_to_uno(): Member: "); - buf.append(comp_td->ppMemberNames[nPos]); - throw BridgeRuntimeError(buf.makeStringAndClear()); + throw BridgeRuntimeError("[map_to_uno(): Member: " + *reinterpret_cast< OUString const * >(comp_td->ppMemberNames[nPos])); } } else @@ -1179,31 +1164,24 @@ void Bridge::map_to_uno(void * uno_data, System::Object^ cli_data, catch (BridgeRuntimeError& e) { bException= true; - OUStringBuffer buf(512); - buf.append("[map_to_uno():"); + OUString str = "[map_to_uno():"; if (cliType) { - buf.append(mapCliString(cliType->FullName)); - buf.append("."); - buf.append(comp_td->ppMemberNames[nPos]); - buf.append(" "); + str += mapCliString(cliType->FullName) + "." + *reinterpret_cast< OUString const * >(comp_td->ppMemberNames[nPos]) + " "; } - buf.append(e.m_message); - throw BridgeRuntimeError(buf.makeStringAndClear()); + str += e.m_message; + throw BridgeRuntimeError(str); } catch (System::InvalidCastException^ ) { bException= true; - OUStringBuffer buf( 256 ); - buf.append( "[map_to_uno():" ); + OUString str = "[map_to_uno():"; if (cliType) { - buf.append(mapCliString(cliType->FullName)); - buf.append( "." ); - buf.append(comp_td->ppMemberNames[nPos]); + str += mapCliString(cliType->FullName) + "." + *reinterpret_cast< OUString const * >(comp_td->ppMemberNames[nPos]); } - buf.append( "] Value has not the required type." ); - throw BridgeRuntimeError(buf.makeStringAndClear()); + str += "] Value has not the required type."; + throw BridgeRuntimeError(str); } catch (...) { @@ -1367,33 +1345,20 @@ void Bridge::map_to_uno(void * uno_data, System::Object^ cli_data, } default: { - OUStringBuffer buf( 128 ); - buf.append( "[map_to_uno():" ); - buf.append( *reinterpret_cast< OUString const * >( &type->pTypeName ) ); - buf.append( "] unsupported sequence element type: " ); - buf.append( *reinterpret_cast< OUString const * >( &element_type->pTypeName ) ); - throw BridgeRuntimeError( buf.makeStringAndClear() ); + throw BridgeRuntimeError("[map_to_uno():" + *reinterpret_cast< OUString const * >( &type->pTypeName ) + + "] unsupported sequence element type: " + *reinterpret_cast< OUString const * >( &element_type->pTypeName )); } } } catch (BridgeRuntimeError& e) { - OUStringBuffer buf( 128 ); - buf.append( "[map_to_uno():" ); - buf.append( *reinterpret_cast< OUString const * >( &type->pTypeName )); - buf.append( "] conversion failed\n "); - buf.append(e.m_message); - throw BridgeRuntimeError(buf.makeStringAndClear()); + throw BridgeRuntimeError("[map_to_uno():" + *reinterpret_cast< OUString const * >( &type->pTypeName ) + "] conversion failed\n " + e.m_message); } catch (System::InvalidCastException^ ) { // Ok, checked - OUStringBuffer buf( 128 ); - buf.append( "[map_to_uno():" ); - buf.append( *reinterpret_cast< OUString const * >( &type->pTypeName) ); - buf.append( "] could not convert sequence element type: " ); - buf.append( *reinterpret_cast< OUString const * >( &element_type->pTypeName ) ); - throw BridgeRuntimeError( buf.makeStringAndClear() ); + throw BridgeRuntimeError("[map_to_uno():" + *reinterpret_cast< OUString const * >( &type->pTypeName) + + "] could not convert sequence element type: " + *reinterpret_cast< OUString const * >( &element_type->pTypeName )); } catch (...) { @@ -1436,11 +1401,7 @@ void Bridge::map_to_uno(void * uno_data, System::Object^ cli_data, default: { //ToDo check - OUStringBuffer buf( 128 ); - buf.append( "[map_to_uno():" ); - buf.append( *reinterpret_cast< OUString const * >( &type->pTypeName ) ); - buf.append( "] unsupported type!" ); - throw BridgeRuntimeError( buf.makeStringAndClear() ); + throw BridgeRuntimeError("[map_to_uno():" + *reinterpret_cast< OUString const * >( &type->pTypeName ) + "] unsupported type!"); } } } @@ -1448,18 +1409,11 @@ void Bridge::map_to_uno(void * uno_data, System::Object^ cli_data, catch (System::InvalidCastException^ ) { //ToDo check - OUStringBuffer buf( 128 ); - buf.append( "[map_to_uno():" ); - buf.append( *reinterpret_cast< OUString const * >( &type->pTypeName ) ); - buf.append( "] could not convert type!" ); - throw BridgeRuntimeError( buf.makeStringAndClear() ); + throw BridgeRuntimeError("[map_to_uno():" + *reinterpret_cast< OUString const * >( &type->pTypeName ) + "] could not convert type!"); } catch (System::NullReferenceException ^ e) { - OUStringBuffer buf(512); - buf.append( "[map_to_uno()] Illegal null reference passed!\n" ); - buf.append(mapCliString(e->StackTrace)); - throw BridgeRuntimeError( buf.makeStringAndClear() ); + throw BridgeRuntimeError("[map_to_uno()] Illegal null reference passed!\n" + mapCliString(e->StackTrace)); } catch (BridgeRuntimeError& ) { @@ -1938,12 +1892,8 @@ void Bridge::map_to_cli( } default: { - OUStringBuffer buf( 128 ); - buf.append( "[map_to_cli():" ); - buf.append( *reinterpret_cast< OUString const * >( &type->pTypeName ) ); - buf.append( "] unsupported element type: " ); - buf.append( *reinterpret_cast< OUString const * >( &element_type->pTypeName ) ); - throw BridgeRuntimeError( buf.makeStringAndClear() ); + throw BridgeRuntimeError("[map_to_cli():" + *reinterpret_cast< OUString const * >( &type->pTypeName ) + + "] unsupported element type: " + *reinterpret_cast< OUString const * >( &element_type->pTypeName )); } } break; @@ -1964,11 +1914,7 @@ void Bridge::map_to_cli( default: { //ToDo check this exception. The String is probably crippled - OUStringBuffer buf( 128 ); - buf.append( "[map_to_cli():" ); - buf.append( *reinterpret_cast< OUString const * >( &type->pTypeName ) ); - buf.append( "] unsupported type!" ); - throw BridgeRuntimeError( buf.makeStringAndClear() ); + throw BridgeRuntimeError("[map_to_cli():" + *reinterpret_cast< OUString const * >( &type->pTypeName ) + "] unsupported type!"); } } //switch } // method diff --git a/cli_ure/source/uno_bridge/cli_proxy.cxx b/cli_ure/source/uno_bridge/cli_proxy.cxx index c5734c1af935..90add1df52b1 100644 --- a/cli_ure/source/uno_bridge/cli_proxy.cxx +++ b/cli_ure/source/uno_bridge/cli_proxy.cxx @@ -79,11 +79,7 @@ UnoInterfaceInfo::UnoInterfaceInfo(Bridge const * bridge, uno_Interface* unoI, sal_Bool bComplete = ::typelib_typedescription_complete( & _pt); if( ! bComplete) { - OUStringBuffer buf( 128 ); - buf.append( "cannot make type complete: " ); - buf.append( *reinterpret_cast< OUString const * >( - & m_typeDesc->aBase.pTypeName)); - throw BridgeRuntimeError(buf.makeStringAndClear()); + throw BridgeRuntimeError("cannot make type complete: " + *reinterpret_cast< OUString const * >(& m_typeDesc->aBase.pTypeName)); } } } @@ -198,13 +194,7 @@ void UnoInterfaceProxy::addUnoInterface(uno_Interface* pUnoI, "id:\n\t{0}\n\t{1}"), m_oid, sInterfaceName)); // add to the string that contains all interface names _numInterfaces++; - OUStringBuffer buf(512); - buf.append("\t"); - buf.append( OUString::number(_numInterfaces)); - buf.append(". "); - buf.append(mapCliString(sInterfaceName)); - buf.append("\n"); - OUString _sNewInterface = buf.makeStringAndClear(); + OUString _sNewInterface = "\t" + OUString::number(_numInterfaces) + ". " + mapCliString(sInterfaceName) + "\n"; pin_ptr pp_sInterfaces = &_sInterfaces; rtl_uString_newConcat( pp_sInterfaces, * pp_sInterfaces, _sNewInterface.pData); @@ -551,13 +541,9 @@ srrm::IMessage^ UnoInterfaceProxy::Invoke(srrm::IMessage^ callmsg) } // ToDo check if the message of the exception is not crippled // the thing that should not be... no method info found! - OUStringBuffer buf( 64 ); - buf.append( "[cli_uno bridge]calling undeclared function on interface " ); - buf.append( *reinterpret_cast< OUString const * >( - & ((typelib_TypeDescription *)info->m_typeDesc)->pTypeName)); - buf.append( ": " ); - buf.append( usMethodName ); - throw BridgeRuntimeError( buf.makeStringAndClear() ); + throw BridgeRuntimeError("[cli_uno bridge]calling undeclared function on interface " + + *reinterpret_cast< OUString const * >(& ((typelib_TypeDescription *)info->m_typeDesc)->pTypeName) + + ": " + usMethodName); } catch (BridgeRuntimeError & err) { @@ -750,11 +736,7 @@ void CliProxy::makeMethodInfos() } catch (System::InvalidCastException^ ) { - OUStringBuffer buf( 128 ); - buf.append( "[cli_uno bridge] preparing proxy for cli interface: " ); - buf.append(mapCliString(m_type->ToString() )); - buf.append( " \nfailed!" ); - throw BridgeRuntimeError( buf.makeStringAndClear() ); + throw BridgeRuntimeError("[cli_uno bridge] preparing proxy for cli interface: " + mapCliString(m_type->ToString()) + " \nfailed!"); } } @@ -814,11 +796,7 @@ sr::MethodInfo^ CliProxy::getMethodInfo(int nUnoFunctionPos, } if (indexCliMethod == -1) { - OUStringBuffer buf(256); - buf.append( "[cli_uno bridge] CliProxy::getMethodInfo():" - "cli object does not implement interface method: " ); - buf.append(usMethodName); - throw BridgeRuntimeError(buf.makeStringAndClear()); + throw BridgeRuntimeError("[cli_uno bridge] CliProxy::getMethodInfo():cli object does not implement interface method: " + usMethodName); } m_arUnoPosToCliPos[nUnoFunctionPos] = indexCliMethod; ret = m_arMethodInfos[indexCliMethod]; diff --git a/cli_ure/source/uno_bridge/cli_uno.cxx b/cli_ure/source/uno_bridge/cli_uno.cxx index aa1a1a03a0ca..82c4f818757d 100644 --- a/cli_ure/source/uno_bridge/cli_uno.cxx +++ b/cli_ure/source/uno_bridge/cli_uno.cxx @@ -230,11 +230,7 @@ void Bridge::call_cli( } catch (System::Exception^ e) { - OUStringBuffer buf( 128 ); - buf.append( "Unexpected exception during invocation of cli object. " - "Original message is: \n" ); - buf.append(mapCliString(e->Message)); - throw BridgeRuntimeError( buf.makeStringAndClear() ); + throw BridgeRuntimeError("Unexpected exception during invocation of cli object. Original message is: \n" + mapCliString(e->Message)); } //convert out, in/out params -- cgit