summaryrefslogtreecommitdiff
path: root/configmgr/source/configurationregistry.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'configmgr/source/configurationregistry.cxx')
-rw-r--r--configmgr/source/configurationregistry.cxx188
1 files changed, 96 insertions, 92 deletions
diff --git a/configmgr/source/configurationregistry.cxx b/configmgr/source/configurationregistry.cxx
index 3e809f3054ef..d162c430382b 100644
--- a/configmgr/source/configurationregistry.cxx
+++ b/configmgr/source/configurationregistry.cxx
@@ -50,8 +50,9 @@
#include <cppuhelper/implbase.hxx>
#include <cppuhelper/supportsservice.hxx>
#include <cppuhelper/weak.hxx>
-#include <osl/mutex.hxx>
+#include <mutex>
#include <rtl/ustring.hxx>
+#include <utility>
#include <sal/types.h>
namespace com::sun::star::util {
@@ -77,14 +78,14 @@ private:
virtual ~Service() override {}
virtual OUString SAL_CALL getImplementationName() override
- { return "com.sun.star.comp.configuration.ConfigurationRegistry"; }
+ { return u"com.sun.star.comp.configuration.ConfigurationRegistry"_ustr; }
virtual sal_Bool SAL_CALL supportsService(OUString const & ServiceName) override
{ return cppu::supportsService(this, ServiceName); }
virtual css::uno::Sequence< OUString > SAL_CALL
getSupportedServiceNames() override
- { return { "com.sun.star.configuration.ConfigurationRegistry" }; }
+ { return { u"com.sun.star.configuration.ConfigurationRegistry"_ustr }; }
virtual OUString SAL_CALL getURL() override;
@@ -119,7 +120,7 @@ private:
void doClose();
css::uno::Reference< css::lang::XMultiServiceFactory > provider_;
- osl::Mutex mutex_;
+ std::mutex mutex_;
css::uno::Reference< css::uno::XInterface > access_;
OUString url_;
bool readOnly_;
@@ -131,8 +132,8 @@ class RegistryKey:
public cppu::WeakImplHelper< css::registry::XRegistryKey >
{
public:
- RegistryKey(Service & service, css::uno::Any const & value):
- service_(service), value_(value) {}
+ RegistryKey(Service & service, css::uno::Any value):
+ service_(service), value_(std::move(value)) {}
private:
RegistryKey(const RegistryKey&) = delete;
@@ -220,7 +221,7 @@ Service::Service(
try {
provider_.set(
context->getServiceManager()->createInstanceWithContext(
- "com.sun.star.configuration.DefaultProvider", context),
+ u"com.sun.star.configuration.DefaultProvider"_ustr, context),
css::uno::UNO_QUERY_THROW);
} catch (css::uno::RuntimeException &) {
throw;
@@ -234,7 +235,7 @@ Service::Service(
}
OUString Service::getURL() {
- osl::MutexGuard g(mutex_);
+ std::unique_lock g(mutex_);
checkValid_RuntimeException();
return url_;
}
@@ -242,18 +243,17 @@ OUString Service::getURL() {
void Service::open(OUString const & rURL, sal_Bool bReadOnly, sal_Bool)
{
//TODO: bCreate
- osl::MutexGuard g(mutex_);
+ std::unique_lock g(mutex_);
if (access_.is()) {
doClose();
}
- css::uno::Sequence< css::uno::Any > args(1);
- args[0] <<= css::beans::NamedValue("nodepath", css::uno::Any(rURL));
+ css::uno::Sequence< css::uno::Any > args{ css::uno::Any(
+ css::beans::NamedValue(u"nodepath"_ustr, css::uno::Any(rURL))) };
try {
access_ = provider_->createInstanceWithArguments(
(bReadOnly
- ? OUString("com.sun.star.configuration.ConfigurationAccess")
- : OUString(
- "com.sun.star.configuration.ConfigurationUpdateAccess")),
+ ? u"com.sun.star.configuration.ConfigurationAccess"_ustr
+ : u"com.sun.star.configuration.ConfigurationUpdateAccess"_ustr),
args);
} catch (css::uno::RuntimeException &) {
throw;
@@ -262,20 +262,20 @@ void Service::open(OUString const & rURL, sal_Bool bReadOnly, sal_Bool)
throw css::lang::WrappedTargetRuntimeException(
"com.sun.star.configuration.ConfigurationRegistry: open failed: " +
e.Message,
- static_cast< cppu::OWeakObject * >(this), anyEx );
+ getXWeak(), anyEx );
}
url_ = rURL;
readOnly_ = bReadOnly;
}
sal_Bool Service::isValid() {
- osl::MutexGuard g(mutex_);
+ std::unique_lock g(mutex_);
return access_.is();
}
void Service::close()
{
- osl::MutexGuard g(mutex_);
+ std::unique_lock g(mutex_);
checkValid();
doClose();
}
@@ -283,19 +283,19 @@ void Service::close()
void Service::destroy()
{
throw css::uno::RuntimeException(
- "com.sun.star.configuration.ConfigurationRegistry: not implemented",
- static_cast< cppu::OWeakObject * >(this));
+ u"com.sun.star.configuration.ConfigurationRegistry: not implemented"_ustr,
+ getXWeak());
}
css::uno::Reference< css::registry::XRegistryKey > Service::getRootKey()
{
- osl::MutexGuard g(mutex_);
+ std::unique_lock g(mutex_);
checkValid();
return new RegistryKey(*this, css::uno::Any(access_));
}
sal_Bool Service::isReadOnly() {
- osl::MutexGuard g(mutex_);
+ std::unique_lock g(mutex_);
checkValid_RuntimeException();
return readOnly_;
}
@@ -303,46 +303,46 @@ sal_Bool Service::isReadOnly() {
void Service::mergeKey(OUString const &, OUString const &)
{
throw css::uno::RuntimeException(
- "com.sun.star.configuration.ConfigurationRegistry: not implemented",
- static_cast< cppu::OWeakObject * >(this));
+ u"com.sun.star.configuration.ConfigurationRegistry: not implemented"_ustr,
+ getXWeak());
}
void Service::flush()
{
throw css::uno::RuntimeException(
- "com.sun.star.configuration.ConfigurationRegistry: not implemented",
- static_cast< cppu::OWeakObject * >(this));
+ u"com.sun.star.configuration.ConfigurationRegistry: not implemented"_ustr,
+ getXWeak());
}
void Service::addFlushListener(
css::uno::Reference< css::util::XFlushListener > const &)
{
throw css::uno::RuntimeException(
- "com.sun.star.configuration.ConfigurationRegistry: not implemented",
- static_cast< cppu::OWeakObject * >(this));
+ u"com.sun.star.configuration.ConfigurationRegistry: not implemented"_ustr,
+ getXWeak());
}
void Service::removeFlushListener(
css::uno::Reference< css::util::XFlushListener > const &)
{
throw css::uno::RuntimeException(
- "com.sun.star.configuration.ConfigurationRegistry: not implemented",
- static_cast< cppu::OWeakObject * >(this));
+ u"com.sun.star.configuration.ConfigurationRegistry: not implemented"_ustr,
+ getXWeak());
}
void Service::checkValid() {
if (!access_.is()) {
throw css::registry::InvalidRegistryException(
- "com.sun.star.configuration.ConfigurationRegistry: not valid",
- static_cast< cppu::OWeakObject * >(this));
+ u"com.sun.star.configuration.ConfigurationRegistry: not valid"_ustr,
+ getXWeak());
}
}
void Service::checkValid_RuntimeException() {
if (!access_.is()) {
throw css::uno::RuntimeException(
- "com.sun.star.configuration.ConfigurationRegistry: not valid",
- static_cast< cppu::OWeakObject * >(this));
+ u"com.sun.star.configuration.ConfigurationRegistry: not valid"_ustr,
+ getXWeak());
}
}
@@ -351,20 +351,20 @@ void Service::doClose() {
}
OUString RegistryKey::getKeyName() {
- osl::MutexGuard g(service_.mutex_);
+ std::unique_lock g(service_.mutex_);
service_.checkValid_RuntimeException();
css::uno::Reference< css::container::XNamed > named;
if (value_ >>= named) {
return named->getName();
}
throw css::uno::RuntimeException(
- "com.sun.star.configuration.ConfigurationRegistry: not implemented",
- static_cast< cppu::OWeakObject * >(this));
+ u"com.sun.star.configuration.ConfigurationRegistry: not implemented"_ustr,
+ getXWeak());
}
sal_Bool RegistryKey::isReadOnly()
{
- osl::MutexGuard g(service_.mutex_);
+ std::unique_lock g(service_.mutex_);
service_.checkValid_RuntimeException();
return service_.readOnly_; //TODO: read-only sub-nodes in update access?
}
@@ -375,14 +375,14 @@ sal_Bool RegistryKey::isValid() {
css::registry::RegistryKeyType RegistryKey::getKeyType(OUString const &)
{
- osl::MutexGuard g(service_.mutex_);
+ std::unique_lock g(service_.mutex_);
service_.checkValid();
return css::registry::RegistryKeyType_KEY;
}
css::registry::RegistryValueType RegistryKey::getValueType()
{
- osl::MutexGuard g(service_.mutex_);
+ std::unique_lock g(service_.mutex_);
service_.checkValid();
css::uno::Type t(value_.getValueType());
switch (t.getTypeClass()) {
@@ -409,149 +409,153 @@ css::registry::RegistryValueType RegistryKey::getValueType()
sal_Int32 RegistryKey::getLongValue()
{
- osl::MutexGuard g(service_.mutex_);
+ std::unique_lock g(service_.mutex_);
service_.checkValid();
- sal_Int32 v = 0;
- if (value_ >>= v) {
- return v;
+ sal_Int32 v1 = 0;
+ if (value_ >>= v1) {
+ return v1;
+ }
+ bool v2;
+ if (value_ >>= v2) {
+ return sal_Int32(v2);
}
throw css::registry::InvalidValueException(
- "com.sun.star.configuration.ConfigurationRegistry",
- static_cast< cppu::OWeakObject * >(this));
+ u"com.sun.star.configuration.ConfigurationRegistry"_ustr,
+ getXWeak());
}
void RegistryKey::setLongValue(sal_Int32)
{
throw css::uno::RuntimeException(
- "com.sun.star.configuration.ConfigurationRegistry: not implemented",
- static_cast< cppu::OWeakObject * >(this));
+ u"com.sun.star.configuration.ConfigurationRegistry: not implemented"_ustr,
+ getXWeak());
}
css::uno::Sequence< sal_Int32 > RegistryKey::getLongListValue()
{
- osl::MutexGuard g(service_.mutex_);
+ std::unique_lock g(service_.mutex_);
service_.checkValid();
css::uno::Sequence< sal_Int32 > v;
if (value_ >>= v) {
return v;
}
throw css::registry::InvalidValueException(
- "com.sun.star.configuration.ConfigurationRegistry",
- static_cast< cppu::OWeakObject * >(this));
+ u"com.sun.star.configuration.ConfigurationRegistry"_ustr,
+ getXWeak());
}
void RegistryKey::setLongListValue(css::uno::Sequence< sal_Int32 > const &)
{
throw css::uno::RuntimeException(
- "com.sun.star.configuration.ConfigurationRegistry: not implemented",
- static_cast< cppu::OWeakObject * >(this));
+ u"com.sun.star.configuration.ConfigurationRegistry: not implemented"_ustr,
+ getXWeak());
}
OUString RegistryKey::getAsciiValue()
{
- osl::MutexGuard g(service_.mutex_);
+ std::unique_lock g(service_.mutex_);
service_.checkValid();
OUString v;
if (value_ >>= v) {
return v;
}
throw css::registry::InvalidValueException(
- "com.sun.star.configuration.ConfigurationRegistry",
- static_cast< cppu::OWeakObject * >(this));
+ u"com.sun.star.configuration.ConfigurationRegistry"_ustr,
+ getXWeak());
}
void RegistryKey::setAsciiValue(OUString const &)
{
throw css::uno::RuntimeException(
- "com.sun.star.configuration.ConfigurationRegistry: not implemented",
- static_cast< cppu::OWeakObject * >(this));
+ u"com.sun.star.configuration.ConfigurationRegistry: not implemented"_ustr,
+ getXWeak());
}
css::uno::Sequence< OUString > RegistryKey::getAsciiListValue()
{
- osl::MutexGuard g(service_.mutex_);
+ std::unique_lock g(service_.mutex_);
service_.checkValid();
css::uno::Sequence< OUString > v;
if (value_ >>= v) {
return v;
}
throw css::registry::InvalidValueException(
- "com.sun.star.configuration.ConfigurationRegistry",
- static_cast< cppu::OWeakObject * >(this));
+ u"com.sun.star.configuration.ConfigurationRegistry"_ustr,
+ getXWeak());
}
void RegistryKey::setAsciiListValue(css::uno::Sequence< OUString > const &)
{
throw css::uno::RuntimeException(
- "com.sun.star.configuration.ConfigurationRegistry: not implemented",
- static_cast< cppu::OWeakObject * >(this));
+ u"com.sun.star.configuration.ConfigurationRegistry: not implemented"_ustr,
+ getXWeak());
}
OUString RegistryKey::getStringValue()
{
- osl::MutexGuard g(service_.mutex_);
+ std::unique_lock g(service_.mutex_);
service_.checkValid();
OUString v;
if (value_ >>= v) {
return v;
}
throw css::registry::InvalidValueException(
- "com.sun.star.configuration.ConfigurationRegistry",
- static_cast< cppu::OWeakObject * >(this));
+ u"com.sun.star.configuration.ConfigurationRegistry"_ustr,
+ getXWeak());
}
void RegistryKey::setStringValue(OUString const &)
{
throw css::uno::RuntimeException(
- "com.sun.star.configuration.ConfigurationRegistry: not implemented",
- static_cast< cppu::OWeakObject * >(this));
+ u"com.sun.star.configuration.ConfigurationRegistry: not implemented"_ustr,
+ getXWeak());
}
css::uno::Sequence< OUString > RegistryKey::getStringListValue()
{
- osl::MutexGuard g(service_.mutex_);
+ std::unique_lock g(service_.mutex_);
service_.checkValid();
css::uno::Sequence< OUString > v;
if (value_ >>= v) {
return v;
}
throw css::registry::InvalidValueException(
- "com.sun.star.configuration.ConfigurationRegistry",
- static_cast< cppu::OWeakObject * >(this));
+ u"com.sun.star.configuration.ConfigurationRegistry"_ustr,
+ getXWeak());
}
void RegistryKey::setStringListValue(
css::uno::Sequence< OUString > const &)
{
throw css::uno::RuntimeException(
- "com.sun.star.configuration.ConfigurationRegistry: not implemented",
- static_cast< cppu::OWeakObject * >(this));
+ u"com.sun.star.configuration.ConfigurationRegistry: not implemented"_ustr,
+ getXWeak());
}
css::uno::Sequence< sal_Int8 > RegistryKey::getBinaryValue()
{
- osl::MutexGuard g(service_.mutex_);
+ std::unique_lock g(service_.mutex_);
service_.checkValid();
css::uno::Sequence< sal_Int8 > v;
if (value_ >>= v) {
return v;
}
throw css::registry::InvalidValueException(
- "com.sun.star.configuration.ConfigurationRegistry",
- static_cast< cppu::OWeakObject * >(this));
+ u"com.sun.star.configuration.ConfigurationRegistry"_ustr,
+ getXWeak());
}
void RegistryKey::setBinaryValue(css::uno::Sequence< sal_Int8 > const &)
{
throw css::uno::RuntimeException(
- "com.sun.star.configuration.ConfigurationRegistry: not implemented",
- static_cast< cppu::OWeakObject * >(this));
+ u"com.sun.star.configuration.ConfigurationRegistry: not implemented"_ustr,
+ getXWeak());
}
css::uno::Reference< css::registry::XRegistryKey > RegistryKey::openKey(
OUString const & aKeyName)
{
- osl::MutexGuard g(service_.mutex_);
+ std::unique_lock g(service_.mutex_);
service_.checkValid_RuntimeException();
css::uno::Reference< css::container::XHierarchicalNameAccess > access;
if (value_ >>= access) {
@@ -567,61 +571,61 @@ css::uno::Reference< css::registry::XRegistryKey > RegistryKey::createKey(
OUString const &)
{
throw css::uno::RuntimeException(
- "com.sun.star.configuration.ConfigurationRegistry: not implemented",
- static_cast< cppu::OWeakObject * >(this));
+ u"com.sun.star.configuration.ConfigurationRegistry: not implemented"_ustr,
+ getXWeak());
}
void RegistryKey::closeKey()
{
- osl::MutexGuard g(service_.mutex_);
+ std::unique_lock g(service_.mutex_);
service_.checkValid_RuntimeException();
}
void RegistryKey::deleteKey(OUString const &)
{
throw css::uno::RuntimeException(
- "com.sun.star.configuration.ConfigurationRegistry: not implemented",
- static_cast< cppu::OWeakObject * >(this));
+ u"com.sun.star.configuration.ConfigurationRegistry: not implemented"_ustr,
+ getXWeak());
}
css::uno::Sequence< css::uno::Reference< css::registry::XRegistryKey > >
RegistryKey::openKeys()
{
throw css::uno::RuntimeException(
- "com.sun.star.configuration.ConfigurationRegistry: not implemented",
- static_cast< cppu::OWeakObject * >(this));
+ u"com.sun.star.configuration.ConfigurationRegistry: not implemented"_ustr,
+ getXWeak());
}
css::uno::Sequence< OUString > RegistryKey::getKeyNames()
{
throw css::uno::RuntimeException(
- "com.sun.star.configuration.ConfigurationRegistry: not implemented",
- static_cast< cppu::OWeakObject * >(this));
+ u"com.sun.star.configuration.ConfigurationRegistry: not implemented"_ustr,
+ getXWeak());
}
sal_Bool RegistryKey::createLink(OUString const &, OUString const &)
{
- osl::MutexGuard g(service_.mutex_);
+ std::unique_lock g(service_.mutex_);
service_.checkValid_RuntimeException();
return false;
}
void RegistryKey::deleteLink(OUString const &)
{
- osl::MutexGuard g(service_.mutex_);
+ std::unique_lock g(service_.mutex_);
service_.checkValid_RuntimeException();
}
OUString RegistryKey::getLinkTarget(OUString const &)
{
- osl::MutexGuard g(service_.mutex_);
+ std::unique_lock g(service_.mutex_);
service_.checkValid_RuntimeException();
return OUString();
}
OUString RegistryKey::getResolvedName(OUString const & aKeyName)
{
- osl::MutexGuard g(service_.mutex_);
+ std::unique_lock g(service_.mutex_);
service_.checkValid_RuntimeException();
return aKeyName;
}
@@ -632,7 +636,7 @@ extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
com_sun_star_comp_configuration_ConfigurationRegistry_get_implementation(
css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any> const&)
{
- return cppu::acquire(static_cast< cppu::OWeakObject * >(new Service(context)));
+ return cppu::acquire(new Service(context));
}
}