summaryrefslogtreecommitdiff
path: root/cppuhelper
diff options
context:
space:
mode:
authorNoel Grandin <noel@peralex.com>2014-05-23 12:03:21 +0200
committerNoel Grandin <noel@peralex.com>2014-05-23 15:06:00 +0200
commite7bc3cab019fbf040f9fb8b53ae2cf3f977d200b (patch)
treebc507bccee9fb71134e362b72d22991561e32aa0 /cppuhelper
parentc5d47c327a57df55fa3dac0fff6b65888d0345e4 (diff)
remove boilerplate in UNO Exception constructor calls
Now that we have default values for Exception constructor params, remove lots of boilerplate code. Change-Id: I620bd641eecfed38e6123873b3b94aaf47922e74
Diffstat (limited to 'cppuhelper')
-rw-r--r--cppuhelper/source/access_control.cxx9
-rw-r--r--cppuhelper/source/component.cxx5
-rw-r--r--cppuhelper/source/defaultbootstrap.cxx6
-rw-r--r--cppuhelper/source/exc_thrower.cxx19
-rw-r--r--cppuhelper/source/implbase.cxx4
-rw-r--r--cppuhelper/source/paths.cxx9
-rw-r--r--cppuhelper/source/propertysetmixin.cxx14
-rw-r--r--cppuhelper/source/servicemanager.cxx136
-rw-r--r--cppuhelper/test/testcmp/TestComponent.cxx3
9 files changed, 76 insertions, 129 deletions
diff --git a/cppuhelper/source/access_control.cxx b/cppuhelper/source/access_control.cxx
index fcac34619aae..8be3101ff3e5 100644
--- a/cppuhelper/source/access_control.cxx
+++ b/cppuhelper/source/access_control.cxx
@@ -47,8 +47,7 @@ AccessControl::AccessControl( Reference< XComponentContext > const & xContext )
{
if (! (xContext->getValueByName( str_ac_singleton() ) >>= m_xController))
{
- throw SecurityException(
- "no access controller!", Reference< XInterface >() );
+ throw SecurityException( "no access controller!" );
}
}
@@ -59,8 +58,7 @@ AccessControl::AccessControl(
{
if (! m_xController.is())
{
- throw SecurityException(
- "no access controller!", Reference< XInterface >() );
+ throw SecurityException( "no access controller!" );
}
}
@@ -70,8 +68,7 @@ AccessControl::AccessControl( AccessControl const & ac )
{
if (! m_xController.is())
{
- throw SecurityException(
- "no access controller!", Reference< XInterface >() );
+ throw SecurityException( "no access controller!" );
}
}
diff --git a/cppuhelper/source/component.cxx b/cppuhelper/source/component.cxx
index 8997eecdda5a..b120fc6b4ed4 100644
--- a/cppuhelper/source/component.cxx
+++ b/cppuhelper/source/component.cxx
@@ -197,9 +197,8 @@ void OComponentHelper::dispose()
catch (Exception & exc)
{
throw RuntimeException(
- OUString(
- "unexpected UNO exception caught: ") +
- exc.Message, Reference< XInterface >() );
+ OUString("unexpected UNO exception caught: ") +
+ exc.Message );
}
}
else
diff --git a/cppuhelper/source/defaultbootstrap.cxx b/cppuhelper/source/defaultbootstrap.cxx
index ff8338964132..98d36c478989 100644
--- a/cppuhelper/source/defaultbootstrap.cxx
+++ b/cppuhelper/source/defaultbootstrap.cxx
@@ -37,8 +37,7 @@ rtl::OUString getBootstrapVariable(
rtl::OUString v;
if (!bootstrap.getFrom(name, v)) {
throw css::uno::DeploymentException(
- "Cannot obtain " + name + " from uno ini",
- css::uno::Reference< css::uno::XInterface >());
+ "Cannot obtain " + name + " from uno ini");
}
return v;
}
@@ -52,8 +51,7 @@ cppu::defaultBootstrap_InitialComponentContext(rtl::OUString const & iniUri)
rtl::Bootstrap bs(iniUri);
if (bs.getHandle() == 0) {
throw css::uno::DeploymentException(
- "Cannot open uno ini " + iniUri,
- css::uno::Reference< css::uno::XInterface >());
+ "Cannot open uno ini " + iniUri);
}
rtl::Reference< cppuhelper::ServiceManager > smgr(
new cppuhelper::ServiceManager);
diff --git a/cppuhelper/source/exc_thrower.cxx b/cppuhelper/source/exc_thrower.cxx
index ab7cc8e48c7c..c307cf378767 100644
--- a/cppuhelper/source/exc_thrower.cxx
+++ b/cppuhelper/source/exc_thrower.cxx
@@ -120,8 +120,7 @@ static void SAL_CALL ExceptionThrower_dispatch(
default:
{
OSL_ASSERT( false );
- RuntimeException exc(
- "not implemented!", Reference< XInterface >() );
+ RuntimeException exc( "not implemented!" );
uno_type_any_construct(
*ppException, &exc, ::getCppuType( &exc ).getTypeLibType(), 0 );
break;
@@ -190,16 +189,14 @@ void SAL_CALL throwException( Any const & exc ) SAL_THROW( (Exception) )
{
throw RuntimeException(
"no UNO exception given "
- "(must be derived from com::sun::star::uno::Exception)!",
- Reference< XInterface >() );
+ "(must be derived from com::sun::star::uno::Exception)!" );
}
Mapping uno2cpp(Environment(UNO_LB_UNO), Environment::getCurrent());
if (! uno2cpp.is())
{
throw RuntimeException(
- "cannot get binary UNO to C++ mapping!",
- Reference< XInterface >() );
+ "cannot get binary UNO to C++ mapping!" );
}
Reference< XExceptionThrower > xThrower;
@@ -218,15 +215,13 @@ Any SAL_CALL getCaughtException()
if (! cpp2uno.is())
{
throw RuntimeException(
- "cannot get C++ to binary UNO mapping!",
- Reference< XInterface >() );
+ "cannot get C++ to binary UNO mapping!" );
}
Mapping uno2cpp(Environment(UNO_LB_UNO), Environment::getCurrent());
if (! uno2cpp.is())
{
throw RuntimeException(
- "cannot get binary UNO to C++ mapping!",
- Reference< XInterface >() );
+ "cannot get binary UNO to C++ mapping!" );
}
typelib_TypeDescription * pTD = 0;
@@ -254,9 +249,7 @@ Any SAL_CALL getCaughtException()
if (exc == 0)
{
- throw RuntimeException(
- "rethrowing C++ exception failed!",
- Reference< XInterface >() );
+ throw RuntimeException( "rethrowing C++ exception failed!" );
}
Any ret;
diff --git a/cppuhelper/source/implbase.cxx b/cppuhelper/source/implbase.cxx
index 322a25506f03..7d5f3ec48456 100644
--- a/cppuhelper/source/implbase.cxx
+++ b/cppuhelper/source/implbase.cxx
@@ -285,7 +285,7 @@ void WeakComponentImplHelperBase::dispose()
throw RuntimeException(
OUString(
"unexpected UNO exception caught: ") +
- exc.Message, Reference< XInterface >() );
+ exc.Message );
}
}
}
@@ -421,7 +421,7 @@ void WeakAggComponentImplHelperBase::dispose()
throw RuntimeException(
OUString(
"unexpected UNO exception caught: ") +
- exc.Message, Reference< XInterface >() );
+ exc.Message );
}
}
}
diff --git a/cppuhelper/source/paths.cxx b/cppuhelper/source/paths.cxx
index 5ff356fa2877..2f021d6ac794 100644
--- a/cppuhelper/source/paths.cxx
+++ b/cppuhelper/source/paths.cxx
@@ -46,8 +46,7 @@ rtl::OUString get_this_libpath() {
sal_Int32 i = uri.lastIndexOf('/');
if (i == -1) {
throw css::uno::DeploymentException(
- "URI " + uri + " is expected to contain a slash",
- css::uno::Reference< css::uno::XInterface >());
+ "URI " + uri + " is expected to contain a slash");
}
uri = uri.copy(0, i);
osl::MutexGuard guard(osl::Mutex::getGlobalMutex());
@@ -100,16 +99,14 @@ bool cppu::nextDirectoryItem(osl::Directory & directory, rtl::OUString * url) {
return false;
default:
throw css::uno::DeploymentException(
- "Cannot iterate directory",
- css::uno::Reference< css::uno::XInterface >());
+ "Cannot iterate directory");
}
osl::FileStatus stat(
osl_FileStatus_Mask_Type | osl_FileStatus_Mask_FileName |
osl_FileStatus_Mask_FileURL);
if (i.getFileStatus(stat) != osl::FileBase::E_None) {
throw css::uno::DeploymentException(
- "Cannot stat in directory",
- css::uno::Reference< css::uno::XInterface >());
+ "Cannot stat in directory");
}
if (stat.getFileType() != osl::FileStatus::Directory) { //TODO: symlinks
// Ignore backup files:
diff --git a/cppuhelper/source/propertysetmixin.cxx b/cppuhelper/source/propertysetmixin.cxx
index 51984dbe0244..cdeaca5bdc13 100644
--- a/cppuhelper/source/propertysetmixin.cxx
+++ b/cppuhelper/source/propertysetmixin.cxx
@@ -231,8 +231,7 @@ void Data::initProperties(
getTypeArguments());
if (args.getLength() != 1) {
throw css::uno::RuntimeException(
- "inconsistent UNO type registry",
- css::uno::Reference< css::uno::XInterface >());
+ "inconsistent UNO type registry");
}
t = args[0];
}
@@ -240,8 +239,7 @@ void Data::initProperties(
= handleNames->size();
if (handles > SAL_MAX_INT32) {
throw css::uno::RuntimeException(
- "interface type has too many attributes",
- css::uno::Reference< css::uno::XInterface >());
+ "interface type has too many attributes");
}
rtl::OUString name(members[i]->getMemberName());
if (!properties.insert(
@@ -258,8 +256,7 @@ void Data::initProperties(
second)
{
throw css::uno::RuntimeException(
- "inconsistent UNO type registry",
- css::uno::Reference< css::uno::XInterface >());
+ "inconsistent UNO type registry");
}
handleNames->push_back(name);
}
@@ -448,9 +445,8 @@ PropertySetMixinImpl::Impl::Impl(
css::uno::UNO_QUERY_THROW);
} catch (css::container::NoSuchElementException & e) {
throw css::uno::RuntimeException(
- ("unexpected com.sun.star.container.NoSuchElementException: "
- + e.Message),
- css::uno::Reference< css::uno::XInterface >());
+ "unexpected com.sun.star.container.NoSuchElementException: "
+ + e.Message);
}
std::vector< rtl::OUString > handleNames;
initProperties(ifc, m_absentOptional, &handleNames);
diff --git a/cppuhelper/source/servicemanager.cxx b/cppuhelper/source/servicemanager.cxx
index 94d2ec5fd529..4aca8d14a2b0 100644
--- a/cppuhelper/source/servicemanager.cxx
+++ b/cppuhelper/source/servicemanager.cxx
@@ -161,15 +161,13 @@ Parser::Parser(
break;
}
throw css::registry::InvalidRegistryException(
- reader_.getUrl() + ": unexpected item in outer level",
- css::uno::Reference< css::uno::XInterface >());
+ reader_.getUrl() + ": unexpected item in outer level");
case STATE_END:
if (res == xmlreader::XmlReader::RESULT_DONE) {
return;
}
throw css::registry::InvalidRegistryException(
- reader_.getUrl() + ": unexpected item in outer level",
- css::uno::Reference< css::uno::XInterface >());
+ reader_.getUrl() + ": unexpected item in outer level");
case STATE_COMPONENTS:
if (res == xmlreader::XmlReader::RESULT_END) {
state = STATE_END;
@@ -183,8 +181,7 @@ Parser::Parser(
break;
}
throw css::registry::InvalidRegistryException(
- reader_.getUrl() + ": unexpected item in <components>",
- css::uno::Reference< css::uno::XInterface >());
+ reader_.getUrl() + ": unexpected item in <components>");
case STATE_COMPONENT:
if (res == xmlreader::XmlReader::RESULT_END) {
state = STATE_COMPONENTS;
@@ -200,8 +197,7 @@ Parser::Parser(
break;
}
throw css::registry::InvalidRegistryException(
- reader_.getUrl() + ": unexpected item in <component>",
- css::uno::Reference< css::uno::XInterface >());
+ reader_.getUrl() + ": unexpected item in <component>");
case STATE_IMPLEMENTATION:
if (res == xmlreader::XmlReader::RESULT_END) {
state = STATE_COMPONENT;
@@ -222,24 +218,21 @@ Parser::Parser(
break;
}
throw css::registry::InvalidRegistryException(
- reader_.getUrl() + ": unexpected item in <implementation>",
- css::uno::Reference< css::uno::XInterface >());
+ reader_.getUrl() + ": unexpected item in <implementation>");
case STATE_SERVICE:
if (res == xmlreader::XmlReader::RESULT_END) {
state = STATE_IMPLEMENTATION;
break;
}
throw css::registry::InvalidRegistryException(
- reader_.getUrl() + ": unexpected item in <service>",
- css::uno::Reference< css::uno::XInterface >());
+ reader_.getUrl() + ": unexpected item in <service>");
case STATE_SINGLETON:
if (res == xmlreader::XmlReader::RESULT_END) {
state = STATE_IMPLEMENTATION;
break;
}
throw css::registry::InvalidRegistryException(
- reader_.getUrl() + ": unexpected item in <service>",
- css::uno::Reference< css::uno::XInterface >());
+ reader_.getUrl() + ": unexpected item in <service>");
}
}
}
@@ -257,90 +250,78 @@ void Parser::handleComponent() {
{
if (!attrLoader_.isEmpty()) {
throw css::registry::InvalidRegistryException(
- (reader_.getUrl()
- + ": <component> has multiple \"loader\" attributes"),
- css::uno::Reference< css::uno::XInterface >());
+ reader_.getUrl()
+ + ": <component> has multiple \"loader\" attributes");
}
attrLoader_ = reader_.getAttributeValue(false).convertFromUtf8();
if (attrLoader_.isEmpty()) {
throw css::registry::InvalidRegistryException(
- (reader_.getUrl()
- + ": <component> has empty \"loader\" attribute"),
- css::uno::Reference< css::uno::XInterface >());
+ reader_.getUrl()
+ + ": <component> has empty \"loader\" attribute");
}
} else if (nsId == xmlreader::XmlReader::NAMESPACE_NONE
&& name.equals(RTL_CONSTASCII_STRINGPARAM("uri")))
{
if (!attrUri_.isEmpty()) {
throw css::registry::InvalidRegistryException(
- (reader_.getUrl()
- + ": <component> has multiple \"uri\" attributes"),
- css::uno::Reference< css::uno::XInterface >());
+ reader_.getUrl()
+ + ": <component> has multiple \"uri\" attributes");
}
attrUri_ = reader_.getAttributeValue(false).convertFromUtf8();
if (attrUri_.isEmpty()) {
throw css::registry::InvalidRegistryException(
- (reader_.getUrl()
- + ": <component> has empty \"uri\" attribute"),
- css::uno::Reference< css::uno::XInterface >());
+ reader_.getUrl()
+ + ": <component> has empty \"uri\" attribute");
}
} else if (nsId == xmlreader::XmlReader::NAMESPACE_NONE
&& name.equals(RTL_CONSTASCII_STRINGPARAM("environment")))
{
if (!attrEnvironment_.isEmpty()) {
throw css::registry::InvalidRegistryException(
- (reader_.getUrl() +
- ": <component> has multiple \"environment\" attributes"),
- css::uno::Reference< css::uno::XInterface >());
+ reader_.getUrl() +
+ ": <component> has multiple \"environment\" attributes");
}
attrEnvironment_ = reader_.getAttributeValue(false)
.convertFromUtf8();
if (attrEnvironment_.isEmpty()) {
throw css::registry::InvalidRegistryException(
- (reader_.getUrl() +
- ": <component> has empty \"environment\" attribute"),
- css::uno::Reference< css::uno::XInterface >());
+ reader_.getUrl() +
+ ": <component> has empty \"environment\" attribute");
}
} else if (nsId == xmlreader::XmlReader::NAMESPACE_NONE
&& name.equals(RTL_CONSTASCII_STRINGPARAM("prefix")))
{
if (!attrPrefix_.isEmpty()) {
throw css::registry::InvalidRegistryException(
- (reader_.getUrl() +
- ": <component> has multiple \"prefix\" attributes"),
- css::uno::Reference< css::uno::XInterface >());
+ reader_.getUrl() +
+ ": <component> has multiple \"prefix\" attributes");
}
attrPrefix_ = reader_.getAttributeValue(false).convertFromUtf8();
if (attrPrefix_.isEmpty()) {
throw css::registry::InvalidRegistryException(
- (reader_.getUrl() +
- ": <component> has empty \"prefix\" attribute"),
- css::uno::Reference< css::uno::XInterface >());
+ reader_.getUrl() +
+ ": <component> has empty \"prefix\" attribute");
}
} else {
throw css::registry::InvalidRegistryException(
- (reader_.getUrl() + ": unexpected attribute \""
- + name.convertFromUtf8() + "\" in <component>"),
- css::uno::Reference< css::uno::XInterface >());
+ reader_.getUrl() + ": unexpected attribute \""
+ + name.convertFromUtf8() + "\" in <component>");
}
}
if (attrLoader_.isEmpty()) {
throw css::registry::InvalidRegistryException(
- reader_.getUrl() + ": <component> is missing \"loader\" attribute",
- css::uno::Reference< css::uno::XInterface >());
+ reader_.getUrl() + ": <component> is missing \"loader\" attribute");
}
if (attrUri_.isEmpty()) {
throw css::registry::InvalidRegistryException(
- reader_.getUrl() + ": <component> is missing \"uri\" attribute",
- css::uno::Reference< css::uno::XInterface >());
+ reader_.getUrl() + ": <component> is missing \"uri\" attribute");
}
#ifndef DISABLE_DYNLOADING
try {
attrUri_ = rtl::Uri::convertRelToAbs(reader_.getUrl(), attrUri_);
} catch (const rtl::MalformedUriException & e) {
throw css::registry::InvalidRegistryException(
- reader_.getUrl() + ": bad \"uri\" attribute: " + e.getMessage(),
- css::uno::Reference< css::uno::XInterface >());
+ reader_.getUrl() + ": bad \"uri\" attribute: " + e.getMessage());
}
#endif
}
@@ -356,54 +337,47 @@ void Parser::handleImplementation() {
{
if (!attrName.isEmpty()) {
throw css::registry::InvalidRegistryException(
- (reader_.getUrl()
- + ": <implementation> has multiple \"name\" attributes"),
- css::uno::Reference< css::uno::XInterface >());
+ reader_.getUrl()
+ + ": <implementation> has multiple \"name\" attributes");
}
attrName = reader_.getAttributeValue(false).convertFromUtf8();
if (attrName.isEmpty()) {
throw css::registry::InvalidRegistryException(
- (reader_.getUrl()
- + ": <implementation> has empty \"name\" attribute"),
- css::uno::Reference< css::uno::XInterface >());
+ reader_.getUrl()
+ + ": <implementation> has empty \"name\" attribute");
}
} else if (nsId == xmlreader::XmlReader::NAMESPACE_NONE
&& name.equals(RTL_CONSTASCII_STRINGPARAM("constructor")))
{
if (!attrConstructor.isEmpty()) {
throw css::registry::InvalidRegistryException(
- (reader_.getUrl()
- + (": <implementation> has multiple \"constructor\""
- " attributes")),
- css::uno::Reference< css::uno::XInterface >());
+ reader_.getUrl()
+ + ": <implementation> has multiple \"constructor\""
+ " attributes");
}
attrConstructor = reader_.getAttributeValue(false)
.convertFromUtf8();
if (attrConstructor.isEmpty()) {
throw css::registry::InvalidRegistryException(
- (reader_.getUrl()
- + ": element has empty \"constructor\" attribute"),
- css::uno::Reference< css::uno::XInterface >());
+ reader_.getUrl()
+ + ": element has empty \"constructor\" attribute");
}
if (attrEnvironment_.isEmpty()) {
throw css::registry::InvalidRegistryException(
- (reader_.getUrl()
- + (": <implementation> has \"constructor\" attribute but"
- " <component> has no \"environment\" attribute")),
- css::uno::Reference< css::uno::XInterface >());
+ reader_.getUrl()
+ + ": <implementation> has \"constructor\" attribute but"
+ " <component> has no \"environment\" attribute");
}
} else {
throw css::registry::InvalidRegistryException(
- (reader_.getUrl() + ": unexpected element attribute \""
- + name.convertFromUtf8() + "\" in <implementation>"),
- css::uno::Reference< css::uno::XInterface >());
+ reader_.getUrl() + ": unexpected element attribute \""
+ + name.convertFromUtf8() + "\" in <implementation>");
}
}
if (attrName.isEmpty()) {
throw css::registry::InvalidRegistryException(
- (reader_.getUrl()
- + ": <implementation> is missing \"name\" attribute"),
- css::uno::Reference< css::uno::XInterface >());
+ reader_.getUrl()
+ + ": <implementation> is missing \"name\" attribute");
}
implementation_.reset(
new cppuhelper::ServiceManager::Data::Implementation(
@@ -415,9 +389,8 @@ void Parser::handleImplementation() {
second)
{
throw css::registry::InvalidRegistryException(
- (reader_.getUrl() + ": duplicate <implementation name=\"" + attrName
- + "\">"),
- css::uno::Reference< css::uno::XInterface >());
+ reader_.getUrl() + ": duplicate <implementation name=\"" + attrName
+ + "\">");
}
}
@@ -443,26 +416,22 @@ rtl::OUString Parser::getNameAttribute() {
{
if (!attrName.isEmpty()) {
throw css::registry::InvalidRegistryException(
- (reader_.getUrl()
- + ": element has multiple \"name\" attributes"),
- css::uno::Reference< css::uno::XInterface >());
+ reader_.getUrl()
+ + ": element has multiple \"name\" attributes");
}
attrName = reader_.getAttributeValue(false).convertFromUtf8();
if (attrName.isEmpty()) {
throw css::registry::InvalidRegistryException(
- reader_.getUrl() + ": element has empty \"name\" attribute",
- css::uno::Reference< css::uno::XInterface >());
+ reader_.getUrl() + ": element has empty \"name\" attribute");
}
} else {
throw css::registry::InvalidRegistryException(
- reader_.getUrl() + ": expected element attribute \"name\"",
- css::uno::Reference< css::uno::XInterface >());
+ reader_.getUrl() + ": expected element attribute \"name\"");
}
}
if (attrName.isEmpty()) {
throw css::registry::InvalidRegistryException(
- reader_.getUrl() + ": element is missing \"name\" attribute",
- css::uno::Reference< css::uno::XInterface >());
+ reader_.getUrl() + ": element is missing \"name\" attribute");
}
return attrName;
}
@@ -1530,8 +1499,7 @@ bool cppuhelper::ServiceManager::readLegacyRdbFile(rtl::OUString const & uri) {
second)
{
throw css::registry::InvalidRegistryException(
- uri + ": duplicate <implementation name=\"" + name + "\">",
- css::uno::Reference< css::uno::XInterface >());
+ uri + ": duplicate <implementation name=\"" + name + "\">");
}
readLegacyRdbStrings(
uri, implKey, "UNO/SERVICES", &impl->info->services);
diff --git a/cppuhelper/test/testcmp/TestComponent.cxx b/cppuhelper/test/testcmp/TestComponent.cxx
index 3e5db32d0ad3..be1a1692a3e1 100644
--- a/cppuhelper/test/testcmp/TestComponent.cxx
+++ b/cppuhelper/test/testcmp/TestComponent.cxx
@@ -99,8 +99,7 @@ uno::Reference<uno::XInterface> SAL_CALL TestComponent::create(
}
catch (std::bad_alloc &)
{
- throw uno::RuntimeException(rtl::OUString("std::bad_alloc"),
- uno::Reference<uno::XInterface>());
+ throw uno::RuntimeException("std::bad_alloc");
}
}