Kaydet (Commit) 79502678 authored tarafından Stephan Bergmann's avatar Stephan Bergmann

Clean-up std::bad_alloc handling

...post 0bc89aac "cppumaker: Allow UNO interface functions to throw std::exception."

Change-Id: I5fede822d279c3c758103192a813447bb4906679
üst ef57fc04
...@@ -49,6 +49,7 @@ ...@@ -49,6 +49,7 @@
#include <algorithm> #include <algorithm>
#include /*MSVC trouble: <cstdlib>*/ <stdlib.h> #include /*MSVC trouble: <cstdlib>*/ <stdlib.h>
#include <exception>
#include <new> #include <new>
#include <vector> #include <vector>
...@@ -191,7 +192,6 @@ private: ...@@ -191,7 +192,6 @@ private:
stoc::uriproc::UriReference m_base; stoc::uriproc::UriReference m_base;
}; };
// throws std::bad_alloc
css::uno::Reference< css::uri::XUriReference > parseGeneric( css::uno::Reference< css::uri::XUriReference > parseGeneric(
OUString const & scheme, OUString const & schemeSpecificPart) OUString const & scheme, OUString const & schemeSpecificPart)
{ {
...@@ -291,7 +291,7 @@ public: ...@@ -291,7 +291,7 @@ public:
virtual css::uno::Reference< css::uri::XUriReference > SAL_CALL virtual css::uno::Reference< css::uri::XUriReference > SAL_CALL
parse(OUString const & uriReference) parse(OUString const & uriReference)
throw (css::uno::RuntimeException); throw (css::uno::RuntimeException, std::exception);
virtual css::uno::Reference< css::uri::XUriReference > SAL_CALL virtual css::uno::Reference< css::uri::XUriReference > SAL_CALL
makeAbsolute( makeAbsolute(
...@@ -343,7 +343,8 @@ css::uno::Sequence< OUString > Factory::getSupportedServiceNames() ...@@ -343,7 +343,8 @@ css::uno::Sequence< OUString > Factory::getSupportedServiceNames()
} }
css::uno::Reference< css::uri::XUriReference > Factory::parse( css::uno::Reference< css::uri::XUriReference > Factory::parse(
OUString const & uriReference) throw (css::uno::RuntimeException) OUString const & uriReference)
throw (css::uno::RuntimeException, std::exception)
{ {
sal_Int32 fragment = uriReference.indexOf('#'); sal_Int32 fragment = uriReference.indexOf('#');
if (fragment == -1) { if (fragment == -1) {
...@@ -403,18 +404,10 @@ css::uno::Reference< css::uri::XUriReference > Factory::parse( ...@@ -403,18 +404,10 @@ css::uno::Reference< css::uri::XUriReference > Factory::parse(
} }
} }
} }
css::uno::Reference< css::uri::XUriReference > uriRef; css::uno::Reference< css::uri::XUriReference > uriRef(
if (parser.is()) { parser.is()
uriRef = parser->parse(scheme, schemeSpecificPart); ? parser->parse(scheme, schemeSpecificPart)
} else { : parseGeneric(scheme, schemeSpecificPart));
try {
uriRef = parseGeneric(scheme, schemeSpecificPart);
} catch (std::bad_alloc &) {
throw css::uno::RuntimeException(
OUString("std::bad_alloc"),
static_cast< cppu::OWeakObject * >(this));
}
}
if (uriRef.is() && fragment != uriReference.getLength()) { if (uriRef.is() && fragment != uriReference.getLength()) {
uriRef->setFragment(uriReference.copy(fragment + 1)); uriRef->setFragment(uriReference.copy(fragment + 1));
} }
......
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#include "stocservices.hxx" #include "stocservices.hxx"
#include <exception>
#include <new> #include <new>
#include "com/sun/star/lang/IllegalArgumentException.hpp" #include "com/sun/star/lang/IllegalArgumentException.hpp"
...@@ -172,7 +173,7 @@ public: ...@@ -172,7 +173,7 @@ public:
parse( parse(
OUString const & scheme, OUString const & scheme,
OUString const & schemeSpecificPart) OUString const & schemeSpecificPart)
throw (css::uno::RuntimeException); throw (css::uno::RuntimeException, std::exception);
private: private:
Parser(Parser &); // not defined Parser(Parser &); // not defined
...@@ -204,18 +205,12 @@ css::uno::Sequence< OUString > Parser::getSupportedServiceNames() ...@@ -204,18 +205,12 @@ css::uno::Sequence< OUString > Parser::getSupportedServiceNames()
css::uno::Reference< css::uri::XUriReference > Parser::parse( css::uno::Reference< css::uri::XUriReference > Parser::parse(
OUString const & scheme, OUString const & schemeSpecificPart) OUString const & scheme, OUString const & schemeSpecificPart)
throw (css::uno::RuntimeException) throw (css::uno::RuntimeException, std::exception)
{ {
if (!parseSchemeSpecificPart(schemeSpecificPart)) { if (!parseSchemeSpecificPart(schemeSpecificPart)) {
return css::uno::Reference< css::uri::XUriReference >(); return css::uno::Reference< css::uri::XUriReference >();
} }
try { return new UrlReference(scheme, schemeSpecificPart);
return new UrlReference(scheme, schemeSpecificPart);
} catch (::std::bad_alloc &) {
throw css::uno::RuntimeException(
OUString("std::bad_alloc"),
css::uno::Reference< css::uno::XInterface >());
}
} }
} }
......
...@@ -41,6 +41,7 @@ ...@@ -41,6 +41,7 @@
#include "rtl/ustring.hxx" #include "rtl/ustring.hxx"
#include "sal/types.h" #include "sal/types.h"
#include <exception>
#include <new> #include <new>
namespace { namespace {
...@@ -394,7 +395,7 @@ public: ...@@ -394,7 +395,7 @@ public:
virtual css::uno::Reference< css::uri::XUriReference > SAL_CALL virtual css::uno::Reference< css::uri::XUriReference > SAL_CALL
parse( parse(
OUString const & scheme, OUString const & schemeSpecificPart) OUString const & scheme, OUString const & schemeSpecificPart)
throw (css::uno::RuntimeException); throw (css::uno::RuntimeException, std::exception);
private: private:
Parser(Parser &); // not implemented Parser(Parser &); // not implemented
...@@ -427,17 +428,12 @@ css::uno::Sequence< OUString > Parser::getSupportedServiceNames() ...@@ -427,17 +428,12 @@ css::uno::Sequence< OUString > Parser::getSupportedServiceNames()
css::uno::Reference< css::uri::XUriReference > css::uno::Reference< css::uri::XUriReference >
Parser::parse( Parser::parse(
OUString const & scheme, OUString const & schemeSpecificPart) OUString const & scheme, OUString const & schemeSpecificPart)
throw (css::uno::RuntimeException) throw (css::uno::RuntimeException, std::exception)
{ {
if (!parseSchemeSpecificPart(schemeSpecificPart)) { if (!parseSchemeSpecificPart(schemeSpecificPart)) {
return 0; return 0;
} }
try { return new UrlReference(scheme, schemeSpecificPart);
return new UrlReference(scheme, schemeSpecificPart);
} catch (std::bad_alloc &) {
throw css::uno::RuntimeException(
OUString("std::bad_alloc"), 0);
}
} }
} }
......
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