Kaydet (Commit) a60f9112 authored tarafından Ricardo Montania's avatar Ricardo Montania Kaydeden (comit) Stephan Bergmann

OUString and RTL_CONSTASCII cleanup

Change-Id: Ic56451b2c13d8561bb6e6ee92bf9147b35640a5c
üst a82e532c
......@@ -179,15 +179,13 @@ Bridge::Bridge(
css::uno::Reference< css::bridge::XInstanceProvider > const & provider):
factory_(factory), name_(name), connection_(connection),
provider_(provider),
binaryUno_(OUString(RTL_CONSTASCII_USTRINGPARAM(UNO_LB_UNO))),
binaryUno_(UNO_LB_UNO),
cppToBinaryMapping_(
OUString(
RTL_CONSTASCII_USTRINGPARAM(CPPU_CURRENT_LANGUAGE_BINDING_NAME)),
OUString(RTL_CONSTASCII_USTRINGPARAM(UNO_LB_UNO))),
CPPU_CURRENT_LANGUAGE_BINDING_NAME,
UNO_LB_UNO),
binaryToCppMapping_(
OUString(RTL_CONSTASCII_USTRINGPARAM(UNO_LB_UNO)),
OUString(
RTL_CONSTASCII_USTRINGPARAM(CPPU_CURRENT_LANGUAGE_BINDING_NAME))),
UNO_LB_UNO,
CPPU_CURRENT_LANGUAGE_BINDING_NAME),
protPropTid_(
reinterpret_cast< sal_Int8 const * >(".UrpProtocolPropertiesTid"),
RTL_CONSTASCII_LENGTH(".UrpProtocolPropertiesTid")),
......@@ -196,13 +194,9 @@ Bridge::Bridge(
cppu::UnoType<
css::uno::Reference< css::bridge::XProtocolProperties > >::get()),
protPropRequest_(
OUString(
RTL_CONSTASCII_USTRINGPARAM(
"com.sun.star.bridge.XProtocolProperties::requestChange"))),
"com.sun.star.bridge.XProtocolProperties::requestChange"),
protPropCommit_(
OUString(
RTL_CONSTASCII_USTRINGPARAM(
"com.sun.star.bridge.XProtocolProperties::commitChange"))),
"com.sun.star.bridge.XProtocolProperties::commitChange"),
state_(STATE_INITIAL), threadPool_(0), currentContextMode_(false),
proxies_(0), calls_(0), normalCall_(false), activeCalls_(0),
mode_(MODE_REQUESTED)
......@@ -210,14 +204,12 @@ Bridge::Bridge(
assert(factory.is() && connection.is());
if (!binaryUno_.is()) {
throw css::uno::RuntimeException(
OUString(
RTL_CONSTASCII_USTRINGPARAM("URP: no binary UNO environment")),
"URP: no binary UNO environment",
css::uno::Reference< css::uno::XInterface >());
}
if (!(cppToBinaryMapping_.is() && binaryToCppMapping_.is())) {
throw css::uno::RuntimeException(
OUString(
RTL_CONSTASCII_USTRINGPARAM("URP: no C++ UNO mapping")),
"URP: no C++ UNO mapping",
css::uno::Reference< css::uno::XInterface >());
}
passive_.set();
......@@ -473,9 +465,7 @@ OUString Bridge::registerOutgoingInterface(
assert(stub != &newStub);
if (j->second.references == SAL_MAX_UINT32) {
throw css::uno::RuntimeException(
OUString(
RTL_CONSTASCII_USTRINGPARAM(
"URP: stub reference count overflow")),
"URP: stub reference count overflow",
css::uno::Reference< css::uno::XInterface >());
}
++j->second.references;
......@@ -517,15 +507,13 @@ void Bridge::releaseStub(
Stubs::iterator i(stubs_.find(oid));
if (i == stubs_.end()) {
throw css::uno::RuntimeException(
OUString(
RTL_CONSTASCII_USTRINGPARAM("URP: release unknown stub")),
"URP: release unknown stub",
css::uno::Reference< css::uno::XInterface >());
}
Stub::iterator j(i->second.find(type));
if (j == i->second.end()) {
throw css::uno::RuntimeException(
OUString(
RTL_CONSTASCII_USTRINGPARAM("URP: release unknown stub")),
"URP: release unknown stub",
css::uno::Reference< css::uno::XInterface >());
}
assert(j->second.references > 0);
......@@ -643,9 +631,7 @@ bool Bridge::makeCall(
}
if (resp.get() == 0) {
throw css::lang::DisposedException(
OUString(
RTL_CONSTASCII_USTRINGPARAM(
"Binary URP bridge disposed during call")),
"Binary URP bridge disposed during call",
static_cast< cppu::OWeakObject * >(this));
}
*returnValue = resp->returnValue;
......@@ -710,10 +696,8 @@ void Bridge::handleRequestChangeReply(
}
if (n != exp) {
throw css::uno::RuntimeException(
OUString(
RTL_CONSTASCII_USTRINGPARAM(
"URP: requestChange reply with unexpected return value"
" received")),
"URP: requestChange reply with unexpected return value"
" received",
static_cast< cppu::OWeakObject * >(this));
}
decrementCalls();
......@@ -796,9 +780,7 @@ void Bridge::handleRequestChangeRequest(
}
default:
throw css::uno::RuntimeException(
OUString(
RTL_CONSTASCII_USTRINGPARAM(
"URP: unexpected requestChange request received")),
"URP: unexpected requestChange request received",
static_cast< cppu::OWeakObject * >(this));
}
}
......@@ -824,9 +806,7 @@ void Bridge::handleCommitChangeRequest(
ret = mapCppToBinaryAny(
css::uno::makeAny(
css::bridge::InvalidProtocolChangeException(
OUString(
RTL_CONSTASCII_USTRINGPARAM(
"InvalidProtocolChangeException")),
"InvalidProtocolChangeException",
css::uno::Reference< css::uno::XInterface >(), s[i],
1)));
break;
......@@ -853,9 +833,7 @@ void Bridge::handleCommitChangeRequest(
break;
default:
throw css::uno::RuntimeException(
OUString(
RTL_CONSTASCII_USTRINGPARAM(
"URP: unexpected commitChange request received")),
"URP: unexpected commitChange request received",
static_cast< cppu::OWeakObject * >(this));
}
}
......@@ -899,18 +877,14 @@ css::uno::Reference< css::uno::XInterface > Bridge::getInstance(
{
if (sInstanceName.isEmpty()) {
throw css::uno::RuntimeException(
OUString(
RTL_CONSTASCII_USTRINGPARAM(
"XBridge::getInstance sInstanceName must be non-empty")),
"XBridge::getInstance sInstanceName must be non-empty",
static_cast< cppu::OWeakObject * >(this));
}
for (sal_Int32 i = 0; i != sInstanceName.getLength(); ++i) {
if (sInstanceName[i] > 0x7F) {
throw css::io::IOException(
OUString(
RTL_CONSTASCII_USTRINGPARAM(
"XBridge::getInstance sInstanceName contains non-ASCII"
" character")),
"XBridge::getInstance sInstanceName contains non-ASCII"
" character",
css::uno::Reference< css::uno::XInterface >());
}
}
......@@ -927,9 +901,7 @@ css::uno::Reference< css::uno::XInterface > Bridge::getInstance(
bool exc = makeCall(
sInstanceName,
css::uno::TypeDescription(
OUString(
RTL_CONSTASCII_USTRINGPARAM(
"com.sun.star.uno.XInterface::queryInterface"))),
"com.sun.star.uno.XInterface::queryInterface"),
false, inArgs, &ret, &outArgs);
throwException(exc, ret);
return css::uno::Reference< css::uno::XInterface >(
......@@ -996,7 +968,7 @@ void Bridge::removeEventListener(
void Bridge::sendCommitChangeRequest() {
assert(mode_ == MODE_REQUESTED || mode_ == MODE_REPLY_1);
css::uno::Sequence< css::bridge::ProtocolProperty > s(1);
s[0].Name = OUString(RTL_CONSTASCII_USTRINGPARAM("CurrentContext"));
s[0].Name = "CurrentContext";
std::vector< BinaryAny > a;
a.push_back(mapCppToBinaryAny(css::uno::makeAny(s)));
sendProtPropRequest(OutgoingRequest::KIND_COMMIT_CHANGE, a);
......@@ -1026,9 +998,7 @@ void Bridge::makeReleaseCall(
sendRequest(
att.getTid(), oid, type,
css::uno::TypeDescription(
OUString(
RTL_CONSTASCII_USTRINGPARAM(
"com.sun.star.uno.XInterface::release"))),
"com.sun.star.uno.XInterface::release"),
std::vector< BinaryAny >());
}
......@@ -1075,9 +1045,7 @@ void Bridge::checkDisposed() {
assert(state_ != STATE_INITIAL);
if (state_ != STATE_STARTED) {
throw css::lang::DisposedException(
OUString(
RTL_CONSTASCII_USTRINGPARAM(
"Binary URP bridge already disposed")),
"Binary URP bridge already disposed",
static_cast< cppu::OWeakObject * >(this));
}
}
......
......@@ -53,14 +53,13 @@ css::uno::Reference< css::uno::XInterface > BridgeFactory::static_create(
OUString BridgeFactory::static_getImplementationName() {
return OUString(
RTL_CONSTASCII_USTRINGPARAM(
"com.sun.star.comp.bridge.BridgeFactory"));
"com.sun.star.comp.bridge.BridgeFactory");
}
css::uno::Sequence< OUString >
BridgeFactory::static_getSupportedServiceNames() {
OUString name(
RTL_CONSTASCII_USTRINGPARAM("com.sun.star.bridge.BridgeFactory"));
"com.sun.star.bridge.BridgeFactory");
return css::uno::Sequence< OUString >(&name, 1);
}
......@@ -136,10 +135,8 @@ css::uno::Reference< css::bridge::XBridge > BridgeFactory::createBridge(
if ( sProtocol != "urp" || !aConnection.is() )
{
throw css::lang::IllegalArgumentException(
OUString(
RTL_CONSTASCII_USTRINGPARAM(
"BridgeFactory::createBridge: sProtocol != urp ||"
" aConnection == null")),
"BridgeFactory::createBridge: sProtocol != urp ||"
" aConnection == null",
static_cast< cppu::OWeakObject * >(this), -1);
}
b.set(new Bridge(this, sName, aConnection, anInstanceProvider));
......@@ -168,17 +165,13 @@ BridgeFactory::getExistingBridges() throw (css::uno::RuntimeException) {
osl::MutexGuard g(*this);
if (unnamed_.size() > SAL_MAX_INT32) {
throw css::uno::RuntimeException(
OUString(
RTL_CONSTASCII_USTRINGPARAM(
"BridgeFactory::getExistingBridges: too many")),
"BridgeFactory::getExistingBridges: too many",
static_cast< cppu::OWeakObject * >(this));
}
sal_Int32 n = static_cast< sal_Int32 >(unnamed_.size());
if (named_.size() > static_cast< sal_uInt32 >(SAL_MAX_INT32 - n)) {
throw css::uno::RuntimeException(
OUString(
RTL_CONSTASCII_USTRINGPARAM(
"BridgeFactory::getExistingBridges: too many")),
"BridgeFactory::getExistingBridges: too many",
static_cast< cppu::OWeakObject * >(this));
}
n = static_cast< sal_Int32 >(n + named_.size());
......
......@@ -44,11 +44,10 @@ css::uno::UnoInterfaceReference get() {
css::uno::UnoInterfaceReference cc;
if (!uno_getCurrentContext(
reinterpret_cast< void ** >(&cc.m_pUnoI),
OUString(RTL_CONSTASCII_USTRINGPARAM(UNO_LB_UNO)).pData, 0))
OUString(UNO_LB_UNO).pData, 0))
{
throw css::uno::RuntimeException(
OUString(
RTL_CONSTASCII_USTRINGPARAM("uno_getCurrentContext failed")),
"uno_getCurrentContext failed",
css::uno::Reference< css::uno::XInterface >());
}
return cc;
......@@ -58,11 +57,10 @@ void set(css::uno::UnoInterfaceReference const & value) {
css::uno::UnoInterfaceReference cc(value);
if (!uno_setCurrentContext(
cc.m_pUnoI,
OUString(RTL_CONSTASCII_USTRINGPARAM(UNO_LB_UNO)).pData, 0))
OUString(UNO_LB_UNO).pData, 0))
{
throw css::uno::RuntimeException(
OUString(
RTL_CONSTASCII_USTRINGPARAM("uno_setCurrentContext failed")),
"uno_setCurrentContext failed",
css::uno::Reference< css::uno::XInterface >());
}
}
......
......@@ -80,8 +80,7 @@ void IncomingRequest::execute() const {
isExc = !execute_throw(&ret, &outArgs);
} catch (const std::exception & e) {
throw css::uno::RuntimeException(
(OUString(
RTL_CONSTASCII_USTRINGPARAM("caught C++ exception: ")) +
("caught C++ exception: " +
rtl::OStringToOUString(
rtl::OString(e.what()), RTL_TEXTENCODING_ASCII_US)),
css::uno::Reference< css::uno::XInterface >());
......
......@@ -83,9 +83,7 @@ void writeString(
RTL_UNICODETOTEXT_FLAGS_INVALID_ERROR)))
{
throw css::uno::RuntimeException(
OUString(
RTL_CONSTASCII_USTRINGPARAM(
"UNO string contains invalid UTF-16 sequence")),
"UNO string contains invalid UTF-16 sequence",
css::uno::Reference< css::uno::XInterface >());
}
writeCompressed(buffer, static_cast< sal_uInt32 >(v.getLength()));
......
......@@ -51,8 +51,7 @@ OutgoingRequest OutgoingRequests::top(rtl::ByteSequence const & tid) {
Map::iterator i(map_.find(tid));
if (i == map_.end()) {
throw css::uno::RuntimeException(
OUString(
RTL_CONSTASCII_USTRINGPARAM("URP: reply for unknown TID")),
"URP: reply for unknown TID",
css::uno::Reference< css::uno::XInterface >());
}
OSL_ASSERT(!i->second.empty());
......
......@@ -109,10 +109,9 @@ void Proxy::do_dispatch(
do_dispatch_throw(member, returnValue, arguments, exception);
} catch (const std::exception & e) {
throw css::uno::RuntimeException(
(OUString(
RTL_CONSTASCII_USTRINGPARAM("caught C++ exception: ")) +
rtl::OStringToOUString(
rtl::OString(e.what()), RTL_TEXTENCODING_ASCII_US)),
("caught C++ exception: " +
rtl::OStringToOUString(
rtl::OString(e.what()), RTL_TEXTENCODING_ASCII_US)),
css::uno::Reference< css::uno::XInterface >());
// best-effort string conversion
}
......
......@@ -69,9 +69,7 @@ css::uno::Sequence< sal_Int8 > read(
assert(connection.is());
if (size > SAL_MAX_INT32) {
throw css::uno::RuntimeException(
OUString(
RTL_CONSTASCII_USTRINGPARAM(
"binaryurp::Reader: block size too large")),
"binaryurp::Reader: block size too large",
css::uno::Reference< css::uno::XInterface >());
}
css::uno::Sequence< sal_Int8 > buf;
......@@ -81,9 +79,7 @@ css::uno::Sequence< sal_Int8 > read(
}
if (n != static_cast< sal_Int32 >(size)) {
throw css::io::IOException(
OUString(
RTL_CONSTASCII_USTRINGPARAM(
"binaryurp::Reader: premature end of input")),
"binaryurp::Reader: premature end of input",
css::uno::Reference< css::uno::XInterface >());
}
assert(buf.getLength() == static_cast< sal_Int32 >(size));
......@@ -123,10 +119,8 @@ void Reader::execute() {
header.done();
if (count == 0) {
throw css::io::IOException(
OUString(
RTL_CONSTASCII_USTRINGPARAM(
"binaryurp::Reader: block with zero message count"
" received")),
"binaryurp::Reader: block with zero message count"
" received",
css::uno::Reference< css::uno::XInterface >());
}
Unmarshal block(bridge_, state_, read(con, size, false));
......@@ -164,10 +158,8 @@ void Reader::readMessage(Unmarshal & unmarshal) {
if (((flags2 & 0x40) != 0) != forceSynchronous) {
// bit 6: SYNCHRONOUS
throw css::uno::RuntimeException(
OUString(
RTL_CONSTASCII_USTRINGPARAM(
"URP: request message with MUSTREPLY != SYNCHRONOUS"
" received")),
"URP: request message with MUSTREPLY != SYNCHRONOUS"
" received",
css::uno::Reference< css::uno::XInterface >());
}
} else {
......@@ -190,10 +182,8 @@ void Reader::readMessage(Unmarshal & unmarshal) {
} else {
if (!lastType_.is()) {
throw css::uno::RuntimeException(
OUString(
RTL_CONSTASCII_USTRINGPARAM(
"URP: request message with NEWTYPE received when last"
" interface type has not yet been set")),
"URP: request message with NEWTYPE received when last"
" interface type has not yet been set",
css::uno::Reference< css::uno::XInterface >());
}
type = lastType_;
......@@ -203,19 +193,15 @@ void Reader::readMessage(Unmarshal & unmarshal) {
oid = unmarshal.readOid();
if (oid.isEmpty()) {
throw css::io::IOException(
OUString(
RTL_CONSTASCII_USTRINGPARAM(
"binaryurp::Unmarshal: emtpy OID")),
"binaryurp::Unmarshal: emtpy OID",
css::uno::Reference< css::uno::XInterface >());
}
lastOid_ = oid;
} else {
if (lastOid_.isEmpty()) {
throw css::uno::RuntimeException(
OUString(
RTL_CONSTASCII_USTRINGPARAM(
"URP: request message with NEWOID received when last"
" OID has not yet been set")),
"URP: request message with NEWOID received when last"
" OID has not yet been set",
css::uno::Reference< css::uno::XInterface >());
}
oid = lastOid_;
......@@ -225,19 +211,15 @@ void Reader::readMessage(Unmarshal & unmarshal) {
type.makeComplete();
if (type.get()->eTypeClass != typelib_TypeClass_INTERFACE) {
throw css::uno::RuntimeException(
OUString(
RTL_CONSTASCII_USTRINGPARAM(
"URP: request message with non-interface interface type"
" received")),
"URP: request message with non-interface interface type"
" received",
css::uno::Reference< css::uno::XInterface >());
}
typelib_InterfaceTypeDescription * itd =
reinterpret_cast< typelib_InterfaceTypeDescription * >(type.get());
if (functionId >= itd->nMapFunctionIndexToMemberIndex) {
throw css::uno::RuntimeException(
OUString(
RTL_CONSTASCII_USTRINGPARAM(
"URP: request message with unknown function ID received")),
"URP: request message with unknown function ID received",
css::uno::Reference< css::uno::XInterface >());
}
sal_Int32 memberId = itd->pMapFunctionIndexToMemberIndex[functionId];
......@@ -266,10 +248,8 @@ void Reader::readMessage(Unmarshal & unmarshal) {
} else {
if (forceSynchronous) {
throw css::uno::RuntimeException(
OUString(
RTL_CONSTASCII_USTRINGPARAM(
"URP: synchronous request message with non-oneway"
" function ID received")),
"URP: synchronous request message with non-oneway"
" function ID received",
css::uno::Reference< css::uno::XInterface >());
}
synchronous = true;
......@@ -322,10 +302,8 @@ void Reader::readMessage(Unmarshal & unmarshal) {
break;
default:
throw css::uno::RuntimeException(
OUString(
RTL_CONSTASCII_USTRINGPARAM(
"URP: request message with UrpProtocolProperties OID"
" and unknown function ID received")),
"URP: request message with UrpProtocolProperties OID"
" and unknown function ID received",
css::uno::Reference< css::uno::XInterface >());
}
} else {
......@@ -355,20 +333,16 @@ void Reader::readMessage(Unmarshal & unmarshal) {
css::uno::XInterface > >::get())))))
{
throw css::uno::RuntimeException(
OUString(
RTL_CONSTASCII_USTRINGPARAM(
"URP: queryInterface request message with"
" unknown OID received")),
"URP: queryInterface request message with"
" unknown OID received",
css::uno::Reference< css::uno::XInterface >());
}
}
break;
case SPECIAL_FUNCTION_ID_RESERVED:
throw css::uno::RuntimeException(
OUString(
RTL_CONSTASCII_USTRINGPARAM(
"URP: request message with unknown function ID 1"
" received")),
"URP: request message with unknown function ID 1"
" received",
css::uno::Reference< css::uno::XInterface >());
case SPECIAL_FUNCTION_ID_RELEASE:
break;
......@@ -376,9 +350,7 @@ void Reader::readMessage(Unmarshal & unmarshal) {
obj = bridge_->findStub(oid, type);
if (!obj.is()) {
throw css::uno::RuntimeException(
OUString(
RTL_CONSTASCII_USTRINGPARAM(
"URP: request message with unknown OID received")),
"URP: request message with unknown OID received",
css::uno::Reference< css::uno::XInterface >());
}
break;
......@@ -457,10 +429,8 @@ void Reader::readReplyMessage(Unmarshal & unmarshal, sal_uInt8 flags1) {
}
if (!ok) {
throw css::uno::RuntimeException(
OUString(
RTL_CONSTASCII_USTRINGPARAM(
"URP: reply message with bad exception type"
" received")),
"URP: reply message with bad exception type"
" received",
css::uno::Reference< css::uno::XInterface >());
}
}
......@@ -532,10 +502,8 @@ rtl::ByteSequence Reader::getTid(Unmarshal & unmarshal, bool newTid) const {
}
if (lastTid_.getLength() == 0) {
throw css::uno::RuntimeException(
OUString(
RTL_CONSTASCII_USTRINGPARAM(
"URP: message with NEWTID received when last TID has not"
" yet been set")),
"URP: message with NEWTID received when last TID has not"
" yet been set",
css::uno::Reference< css::uno::XInterface >());
}
return lastTid_;
......
This diff is collapsed.
......@@ -163,10 +163,8 @@ void Writer::execute() {
(item.oid != "UrpProtocolProperties" &&
!item.member.equals(
css::uno::TypeDescription(
OUString(
RTL_CONSTASCII_USTRINGPARAM(
"com.sun.star.uno.XInterface::"
"release")))) &&
"com.sun.star.uno.XInterface::"
"release")) &&
bridge_->isCurrentContextMode()),
item.currentContext);
} else {
......@@ -241,8 +239,7 @@ void Writer::sendRequest(
OSL_ASSERT(functionId >= 0);
if (functionId > SAL_MAX_UINT16) {
throw css::uno::RuntimeException(
OUString(
RTL_CONSTASCII_USTRINGPARAM("function ID too large for URP")),
"function ID too large for URP",
css::uno::Reference< css::uno::XInterface >());
}
std::vector< unsigned char > buf;
......@@ -409,8 +406,7 @@ void Writer::sendMessage(std::vector< unsigned char > const & buffer) {
std::vector< unsigned char > header;
if (buffer.size() > SAL_MAX_UINT32) {
throw css::uno::RuntimeException(
OUString(
RTL_CONSTASCII_USTRINGPARAM("message too large for URP")),
"message too large for URP",
css::uno::Reference< css::uno::XInterface >());
}
Marshal::write32(&header, static_cast< sal_uInt32 >(buffer.size()));
......@@ -435,10 +431,8 @@ void Writer::sendMessage(std::vector< unsigned char > const & buffer) {
} catch (const css::io::IOException & e) {
css::uno::Any exc(cppu::getCaughtException());
throw css::lang::WrappedTargetRuntimeException(
(OUString(
RTL_CONSTASCII_USTRINGPARAM(
"Binary URP write raised IO exception: ")) +
e.Message),
("Binary URP write raised IO exception: " +
e.Message),
css::uno::Reference< css::uno::XInterface >(), exc);
}
n = static_cast< std::vector< unsigned char >::size_type >(n - k);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment