Clean up string concatenation

Change-Id: I83515f8907b000eb0506410e9b04f28f4257a3b8
This commit is contained in:
Stephan Bergmann
2013-12-03 15:59:00 +01:00
parent 214c379958
commit 86268546a0
4 changed files with 77 additions and 133 deletions

View File

@@ -24,7 +24,6 @@
#include "jni_bridge.h"
#include "rtl/strbuf.hxx"
#include "rtl/ustrbuf.hxx"
#include "uno/sequence2.h"
@@ -388,12 +387,9 @@ void Bridge::map_to_uno(
}
if (0 == java_data.l)
{
OUStringBuffer buf( 128 );
buf.append( "[map_to_uno():" );
buf.append( OUString::unacquired( &type->pTypeName ) );
buf.append( "] null-ref given!" );
buf.append( jni.get_stack_trace() );
throw BridgeRuntimeError( buf.makeStringAndClear() );
throw BridgeRuntimeError(
"[map_to_uno():" + OUString::unacquired( &type->pTypeName )
+ "] null-ref given!" + jni.get_stack_trace() );
}
if (! assign)
*(rtl_uString **)uno_data = 0;
@@ -413,12 +409,9 @@ void Bridge::map_to_uno(
}
if (0 == java_data.l)
{
OUStringBuffer buf( 128 );
buf.append( "[map_to_uno():" );
buf.append( OUString::unacquired( &type->pTypeName ) );
buf.append( "] null-ref given!" );
buf.append( jni.get_stack_trace() );
throw BridgeRuntimeError( buf.makeStringAndClear() );
throw BridgeRuntimeError(
"[map_to_uno():" + OUString::unacquired( &type->pTypeName )
+ "] null-ref given!" + jni.get_stack_trace() );
}
// type name
@@ -427,26 +420,20 @@ void Bridge::map_to_uno(
java_data.l, m_jni_info->m_field_Type__typeName ) );
if (! jo_type_name.is())
{
OUStringBuffer buf( 128 );
buf.append( "[map_to_uno():" );
buf.append( OUString::unacquired( &type->pTypeName ) );
buf.append("] incomplete type object: "
"no type name!" );
buf.append( jni.get_stack_trace() );
throw BridgeRuntimeError( buf.makeStringAndClear() );
throw BridgeRuntimeError(
"[map_to_uno():" + OUString::unacquired( &type->pTypeName )
+ "] incomplete type object: no type name!"
+ jni.get_stack_trace() );
}
OUString type_name(
jstring_to_oustring( jni, (jstring) jo_type_name.get() ) );
::com::sun::star::uno::TypeDescription td( type_name );
if (! td.is())
{
OUStringBuffer buf( 128 );
buf.append( "[map_to_uno():" );
buf.append( OUString::unacquired( &type->pTypeName ) );
buf.append( "] UNO type not found: " );
buf.append( type_name );
buf.append( jni.get_stack_trace() );
throw BridgeRuntimeError( buf.makeStringAndClear() );
throw BridgeRuntimeError(
"[map_to_uno():" + OUString::unacquired( &type->pTypeName )
+ "] UNO type not found: " + type_name
+ jni.get_stack_trace() );
}
typelib_typedescriptionreference_acquire( td.get()->pWeakRef );
if (assign)
@@ -489,12 +476,10 @@ void Bridge::map_to_uno(
java_data.l, m_jni_info->m_field_Any__type ) );
if (! jo_type.is())
{
OUStringBuffer buf( 128 );
buf.append( "[map_to_uno():" );
buf.append( OUString::unacquired( &type->pTypeName ) );
buf.append( "] no type set at " "com.sun.star.uno.Any!" );
buf.append( jni.get_stack_trace() );
throw BridgeRuntimeError( buf.makeStringAndClear() );
throw BridgeRuntimeError(
"[map_to_uno():" + OUString::unacquired( &type->pTypeName )
+ "] no type set at com.sun.star.uno.Any!"
+ jni.get_stack_trace() );
}
// wrapped value
jo_wrapped_holder.reset(
@@ -520,13 +505,10 @@ void Bridge::map_to_uno(
::com::sun::star::uno::TypeDescription value_td( type_name );
if (! value_td.is())
{
OUStringBuffer buf( 128 );
buf.append( "[map_to_uno():" );
buf.append( OUString::unacquired( &type->pTypeName ) );
buf.append( "] UNO type not found: " );
buf.append( type_name );
buf.append( jni.get_stack_trace() );
throw BridgeRuntimeError( buf.makeStringAndClear() );
throw BridgeRuntimeError(
"[map_to_uno():" + OUString::unacquired( &type->pTypeName )
+ "] UNO type not found: " + type_name
+ jni.get_stack_trace() );
}
typelib_TypeClass type_class = value_td.get()->eTypeClass;
@@ -671,12 +653,10 @@ void Bridge::map_to_uno(
}
default:
{
OUStringBuffer buf( 128 );
buf.append( "[map_to_uno():" );
buf.append( type_name );
buf.append( "] unsupported value type " "of any!" );
buf.append( jni.get_stack_trace() );
throw BridgeRuntimeError( buf.makeStringAndClear() );
throw BridgeRuntimeError(
"[map_to_uno():" + type_name
+ "] unsupported value type of any!"
+ jni.get_stack_trace() );
}
}
}
@@ -705,12 +685,9 @@ void Bridge::map_to_uno(
}
if (0 == java_data.l)
{
OUStringBuffer buf( 128 );
buf.append( "[map_to_uno():" );
buf.append( OUString::unacquired( &type->pTypeName ) );
buf.append( "] null-ref given!" );
buf.append( jni.get_stack_trace() );
throw BridgeRuntimeError( buf.makeStringAndClear() );
throw BridgeRuntimeError(
"[map_to_uno():" + OUString::unacquired( &type->pTypeName )
+ "] null-ref given!" + jni.get_stack_trace() );
}
*(jint *) uno_data = jni->GetIntField(
@@ -730,12 +707,9 @@ void Bridge::map_to_uno(
}
if (0 == java_data.l)
{
OUStringBuffer buf( 128 );
buf.append( "[map_to_uno():" );
buf.append( OUString::unacquired( &type->pTypeName ) );
buf.append( "] null-ref given!" );
buf.append( jni.get_stack_trace() );
throw BridgeRuntimeError( buf.makeStringAndClear() );
throw BridgeRuntimeError(
"[map_to_uno():" + OUString::unacquired( &type->pTypeName )
+ "] null-ref given!" + jni.get_stack_trace() );
}
if (0 == info)
@@ -1002,12 +976,9 @@ void Bridge::map_to_uno(
}
if (0 == java_data.l)
{
OUStringBuffer buf( 128 );
buf.append( "[map_to_uno():" );
buf.append( OUString::unacquired( &type->pTypeName ) );
buf.append( "] null-ref given!" );
buf.append( jni.get_stack_trace() );
throw BridgeRuntimeError( buf.makeStringAndClear() );
throw BridgeRuntimeError(
"[map_to_uno():" + OUString::unacquired( &type->pTypeName )
+ "] null-ref given!" + jni.get_stack_trace() );
}
TypeDescr td( type );
@@ -1140,13 +1111,11 @@ void Bridge::map_to_uno(
}
default:
{
OUStringBuffer buf( 128 );
buf.append( "[map_to_uno():" );
buf.append( OUString::unacquired( &type->pTypeName ) );
buf.append( "] unsupported sequence element" " type: " );
buf.append( OUString::unacquired( &element_type->pTypeName ) );
buf.append( jni.get_stack_trace() );
throw BridgeRuntimeError( buf.makeStringAndClear() );
throw BridgeRuntimeError(
"[map_to_uno():" + OUString::unacquired( &type->pTypeName )
+ "] unsupported sequence element type: "
+ OUString::unacquired( &element_type->pTypeName )
+ jni.get_stack_trace() );
}
}
@@ -1195,12 +1164,9 @@ void Bridge::map_to_uno(
}
default:
{
OUStringBuffer buf( 128 );
buf.append( "[map_to_uno():" );
buf.append( OUString::unacquired( &type->pTypeName ) );
buf.append( "] unsupported type!" );
buf.append( jni.get_stack_trace() );
throw BridgeRuntimeError( buf.makeStringAndClear() );
throw BridgeRuntimeError(
"[map_to_uno():" + OUString::unacquired( &type->pTypeName )
+ "] unsupported type!" + jni.get_stack_trace() );
}
}
}
@@ -2443,13 +2409,11 @@ void Bridge::map_to_java(
}
default:
{
OUStringBuffer buf( 128 );
buf.append( "[map_to_java():" );
buf.append( OUString::unacquired( &type->pTypeName ) );
buf.append( "] unsupported element type: " );
buf.append( OUString::unacquired( &element_type->pTypeName ) );
buf.append( jni.get_stack_trace() );
throw BridgeRuntimeError( buf.makeStringAndClear() );
throw BridgeRuntimeError(
"[map_to_java():" + OUString::unacquired( &type->pTypeName )
+ "] unsupported element type: "
+ OUString::unacquired( &element_type->pTypeName )
+ jni.get_stack_trace() );
}
}
@@ -2524,12 +2488,9 @@ void Bridge::map_to_java(
}
default:
{
OUStringBuffer buf( 128 );
buf.append( "[map_to_java():" );
buf.append( OUString::unacquired( &type->pTypeName ) );
buf.appendAscii( "] unsupported type!" );
buf.append( jni.get_stack_trace() );
throw BridgeRuntimeError( buf.makeStringAndClear() );
throw BridgeRuntimeError(
"[map_to_java():" + OUString::unacquired( &type->pTypeName )
+ "] unsupported type!" + jni.get_stack_trace() );
}
}
}

View File

@@ -49,11 +49,10 @@ JNI_type_info::JNI_type_info(
m_td.makeComplete();
if (! m_td.get()->bComplete)
{
OUStringBuffer buf( 128 );
buf.append( "cannot make type complete: " );
buf.append( OUString::unacquired( &m_td.get()->pTypeName ) );
buf.append( jni.get_stack_trace() );
throw BridgeRuntimeError( buf.makeStringAndClear() );
throw BridgeRuntimeError(
"cannot make type complete: "
+ OUString::unacquired( &m_td.get()->pTypeName )
+ jni.get_stack_trace() );
}
}
@@ -366,11 +365,8 @@ JNI_type_info const * JNI_info::create_type_info(
}
default:
{
OUStringBuffer buf( 128 );
buf.append( "type info not supported for " );
buf.append( uno_name );
buf.append( jni.get_stack_trace() );
throw BridgeRuntimeError( buf.makeStringAndClear() );
throw BridgeRuntimeError(
"type info not supported for " + uno_name + jni.get_stack_trace() );
}
}
@@ -465,11 +461,8 @@ JNI_type_info const * JNI_info::get_type_info(
css::uno::TypeDescription td( uno_name );
if (! td.is())
{
OUStringBuffer buf( 128 );
buf.append( "UNO type not found: " );
buf.append( uno_name );
buf.append( jni.get_stack_trace() );
throw BridgeRuntimeError( buf.makeStringAndClear() );
throw BridgeRuntimeError(
"UNO type not found: " + uno_name + jni.get_stack_trace() );
}
info = create_type_info( jni, td.get() );
}

View File

@@ -19,16 +19,13 @@
#include <sal/config.h>
#include <algorithm>
#include <cassert>
#include <sal/alloca.h>
#include "jni_bridge.h"
#include <rtl/ustrbuf.hxx>
#include <algorithm>
using namespace ::rtl;
namespace jni_uno
@@ -125,11 +122,10 @@ void Bridge::handle_uno_exc( JNI_context const & jni, uno_Any * uno_exc ) const
jni, jni->CallObjectMethodA(
jo_exc.get(), m_jni_info->m_method_Object_toString, 0 ) );
jni.ensure_no_exception();
OUStringBuffer buf( 128 );
buf.append( "throwing java exception failed: " );
buf.append( jstring_to_oustring( jni, (jstring) jo_descr.get() ) );
buf.append( jni.get_stack_trace() );
throw BridgeRuntimeError( buf.makeStringAndClear() );
throw BridgeRuntimeError(
"throwing java exception failed: "
+ jstring_to_oustring( jni, (jstring) jo_descr.get() )
+ jni.get_stack_trace() );
}
}
else
@@ -579,14 +575,10 @@ JNICALL Java_com_sun_star_bridges_jni_1uno_JNI_1proxy_dispatch_1call(
}
}
// the thing that should not be... no method info found!
OUStringBuffer buf( 64 );
buf.append( "calling undeclared function on interface " );
buf.append( OUString::unacquired(
&((typelib_TypeDescription *)td)->pTypeName ) );
buf.append( ": " );
buf.append( method_name );
buf.append( jni.get_stack_trace() );
throw BridgeRuntimeError( buf.makeStringAndClear() );
throw BridgeRuntimeError(
"calling undeclared function on interface "
+ OUString::unacquired(&((typelib_TypeDescription *)td)->pTypeName)
+ ": " + method_name + jni.get_stack_trace() );
}
catch (const BridgeRuntimeError & err)
{

View File

@@ -90,11 +90,10 @@ void Bridge::handle_java_exc(
jni, jni->CallObjectMethodA(
jo_exc.get(), m_jni_info->m_method_Object_toString, 0 ) );
jni.ensure_no_exception();
OUStringBuffer buf( 128 );
buf.append( "non-UNO exception occurred: " );
buf.append( jstring_to_oustring( jni, (jstring) jo_descr.get() ) );
buf.append( jni.get_stack_trace( jo_exc.get() ) );
throw BridgeRuntimeError( buf.makeStringAndClear() );
throw BridgeRuntimeError(
"non-UNO exception occurred: "
+ jstring_to_oustring( jni, (jstring) jo_descr.get() )
+ jni.get_stack_trace( jo_exc.get() ) );
}
SAL_WNODEPRECATED_DECLARATIONS_PUSH
@@ -144,11 +143,10 @@ void Bridge::call_java(
reinterpret_cast<typelib_TypeDescription *>(iface_td) );
iface_holder.makeComplete();
if (! iface_holder.get()->bComplete) {
OUStringBuffer buf;
buf.append( "cannot make type complete: " );
buf.append( OUString::unacquired(&iface_holder.get()->pTypeName) );
buf.append( jni.get_stack_trace() );
throw BridgeRuntimeError( buf.makeStringAndClear() );
throw BridgeRuntimeError(
"cannot make type complete: "
+ OUString::unacquired(&iface_holder.get()->pTypeName)
+ jni.get_stack_trace() );
}
iface_td = reinterpret_cast<typelib_InterfaceTypeDescription *>(
iface_holder.get() );