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.cxx115
1 files changed, 58 insertions, 57 deletions
diff --git a/configmgr/source/configurationregistry.cxx b/configmgr/source/configurationregistry.cxx
index 3e809f3054ef..4900b9f97d52 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 {
@@ -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;
@@ -234,7 +235,7 @@ Service::Service(
}
OUString Service::getURL() {
- osl::MutexGuard g(mutex_);
+ std::unique_lock g(mutex_);
checkValid_RuntimeException();
return url_;
}
@@ -242,12 +243,12 @@ 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("nodepath", css::uno::Any(rURL))) };
try {
access_ = provider_->createInstanceWithArguments(
(bReadOnly
@@ -262,20 +263,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();
}
@@ -284,18 +285,18 @@ void Service::destroy()
{
throw css::uno::RuntimeException(
"com.sun.star.configuration.ConfigurationRegistry: not implemented",
- static_cast< cppu::OWeakObject * >(this));
+ 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_;
}
@@ -304,14 +305,14 @@ void Service::mergeKey(OUString const &, OUString const &)
{
throw css::uno::RuntimeException(
"com.sun.star.configuration.ConfigurationRegistry: not implemented",
- static_cast< cppu::OWeakObject * >(this));
+ getXWeak());
}
void Service::flush()
{
throw css::uno::RuntimeException(
"com.sun.star.configuration.ConfigurationRegistry: not implemented",
- static_cast< cppu::OWeakObject * >(this));
+ getXWeak());
}
void Service::addFlushListener(
@@ -319,7 +320,7 @@ void Service::addFlushListener(
{
throw css::uno::RuntimeException(
"com.sun.star.configuration.ConfigurationRegistry: not implemented",
- static_cast< cppu::OWeakObject * >(this));
+ getXWeak());
}
void Service::removeFlushListener(
@@ -327,14 +328,14 @@ void Service::removeFlushListener(
{
throw css::uno::RuntimeException(
"com.sun.star.configuration.ConfigurationRegistry: not implemented",
- static_cast< cppu::OWeakObject * >(this));
+ getXWeak());
}
void Service::checkValid() {
if (!access_.is()) {
throw css::registry::InvalidRegistryException(
"com.sun.star.configuration.ConfigurationRegistry: not valid",
- static_cast< cppu::OWeakObject * >(this));
+ getXWeak());
}
}
@@ -342,7 +343,7 @@ void Service::checkValid_RuntimeException() {
if (!access_.is()) {
throw css::uno::RuntimeException(
"com.sun.star.configuration.ConfigurationRegistry: not valid",
- static_cast< cppu::OWeakObject * >(this));
+ getXWeak());
}
}
@@ -351,7 +352,7 @@ 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) {
@@ -359,12 +360,12 @@ OUString RegistryKey::getKeyName() {
}
throw css::uno::RuntimeException(
"com.sun.star.configuration.ConfigurationRegistry: not implemented",
- static_cast< cppu::OWeakObject * >(this));
+ 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 +376,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,7 +410,7 @@ 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) {
@@ -417,19 +418,19 @@ sal_Int32 RegistryKey::getLongValue()
}
throw css::registry::InvalidValueException(
"com.sun.star.configuration.ConfigurationRegistry",
- static_cast< cppu::OWeakObject * >(this));
+ getXWeak());
}
void RegistryKey::setLongValue(sal_Int32)
{
throw css::uno::RuntimeException(
"com.sun.star.configuration.ConfigurationRegistry: not implemented",
- static_cast< cppu::OWeakObject * >(this));
+ 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) {
@@ -437,19 +438,19 @@ css::uno::Sequence< sal_Int32 > RegistryKey::getLongListValue()
}
throw css::registry::InvalidValueException(
"com.sun.star.configuration.ConfigurationRegistry",
- static_cast< cppu::OWeakObject * >(this));
+ 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));
+ getXWeak());
}
OUString RegistryKey::getAsciiValue()
{
- osl::MutexGuard g(service_.mutex_);
+ std::unique_lock g(service_.mutex_);
service_.checkValid();
OUString v;
if (value_ >>= v) {
@@ -457,19 +458,19 @@ OUString RegistryKey::getAsciiValue()
}
throw css::registry::InvalidValueException(
"com.sun.star.configuration.ConfigurationRegistry",
- static_cast< cppu::OWeakObject * >(this));
+ getXWeak());
}
void RegistryKey::setAsciiValue(OUString const &)
{
throw css::uno::RuntimeException(
"com.sun.star.configuration.ConfigurationRegistry: not implemented",
- static_cast< cppu::OWeakObject * >(this));
+ 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) {
@@ -477,19 +478,19 @@ css::uno::Sequence< OUString > RegistryKey::getAsciiListValue()
}
throw css::registry::InvalidValueException(
"com.sun.star.configuration.ConfigurationRegistry",
- static_cast< cppu::OWeakObject * >(this));
+ 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));
+ getXWeak());
}
OUString RegistryKey::getStringValue()
{
- osl::MutexGuard g(service_.mutex_);
+ std::unique_lock g(service_.mutex_);
service_.checkValid();
OUString v;
if (value_ >>= v) {
@@ -497,19 +498,19 @@ OUString RegistryKey::getStringValue()
}
throw css::registry::InvalidValueException(
"com.sun.star.configuration.ConfigurationRegistry",
- static_cast< cppu::OWeakObject * >(this));
+ getXWeak());
}
void RegistryKey::setStringValue(OUString const &)
{
throw css::uno::RuntimeException(
"com.sun.star.configuration.ConfigurationRegistry: not implemented",
- static_cast< cppu::OWeakObject * >(this));
+ 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) {
@@ -517,7 +518,7 @@ css::uno::Sequence< OUString > RegistryKey::getStringListValue()
}
throw css::registry::InvalidValueException(
"com.sun.star.configuration.ConfigurationRegistry",
- static_cast< cppu::OWeakObject * >(this));
+ getXWeak());
}
void RegistryKey::setStringListValue(
@@ -525,12 +526,12 @@ void RegistryKey::setStringListValue(
{
throw css::uno::RuntimeException(
"com.sun.star.configuration.ConfigurationRegistry: not implemented",
- static_cast< cppu::OWeakObject * >(this));
+ 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) {
@@ -538,20 +539,20 @@ css::uno::Sequence< sal_Int8 > RegistryKey::getBinaryValue()
}
throw css::registry::InvalidValueException(
"com.sun.star.configuration.ConfigurationRegistry",
- static_cast< cppu::OWeakObject * >(this));
+ 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));
+ 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) {
@@ -568,12 +569,12 @@ css::uno::Reference< css::registry::XRegistryKey > RegistryKey::createKey(
{
throw css::uno::RuntimeException(
"com.sun.star.configuration.ConfigurationRegistry: not implemented",
- static_cast< cppu::OWeakObject * >(this));
+ getXWeak());
}
void RegistryKey::closeKey()
{
- osl::MutexGuard g(service_.mutex_);
+ std::unique_lock g(service_.mutex_);
service_.checkValid_RuntimeException();
}
@@ -581,7 +582,7 @@ void RegistryKey::deleteKey(OUString const &)
{
throw css::uno::RuntimeException(
"com.sun.star.configuration.ConfigurationRegistry: not implemented",
- static_cast< cppu::OWeakObject * >(this));
+ getXWeak());
}
css::uno::Sequence< css::uno::Reference< css::registry::XRegistryKey > >
@@ -589,39 +590,39 @@ RegistryKey::openKeys()
{
throw css::uno::RuntimeException(
"com.sun.star.configuration.ConfigurationRegistry: not implemented",
- static_cast< cppu::OWeakObject * >(this));
+ getXWeak());
}
css::uno::Sequence< OUString > RegistryKey::getKeyNames()
{
throw css::uno::RuntimeException(
"com.sun.star.configuration.ConfigurationRegistry: not implemented",
- static_cast< cppu::OWeakObject * >(this));
+ 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 +633,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));
}
}