LCOV - code coverage report
Current view: top level - configmgr/source - configurationregistry.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 70 219 32.0 %
Date: 2015-06-13 12:38:46 Functions: 20 55 36.4 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include <sal/config.h>
      21             : 
      22             : #include <cassert>
      23             : 
      24             : #include <com/sun/star/beans/NamedValue.hpp>
      25             : #include <com/sun/star/beans/Property.hpp>
      26             : #include <com/sun/star/beans/XProperty.hpp>
      27             : #include <com/sun/star/container/NoSuchElementException.hpp>
      28             : #include <com/sun/star/container/XHierarchicalNameAccess.hpp>
      29             : #include <com/sun/star/container/XNamed.hpp>
      30             : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
      31             : #include <com/sun/star/lang/XServiceInfo.hpp>
      32             : #include <com/sun/star/registry/InvalidRegistryException.hpp>
      33             : #include <com/sun/star/registry/InvalidValueException.hpp>
      34             : #include <com/sun/star/registry/MergeConflictException.hpp>
      35             : #include <com/sun/star/registry/RegistryKeyType.hpp>
      36             : #include <com/sun/star/registry/RegistryValueType.hpp>
      37             : #include <com/sun/star/registry/XRegistryKey.hpp>
      38             : #include <com/sun/star/registry/XSimpleRegistry.hpp>
      39             : #include <com/sun/star/uno/Any.hxx>
      40             : #include <com/sun/star/uno/DeploymentException.hpp>
      41             : #include <com/sun/star/uno/Exception.hpp>
      42             : #include <com/sun/star/uno/Reference.hxx>
      43             : #include <com/sun/star/uno/RuntimeException.hpp>
      44             : #include <com/sun/star/uno/Sequence.hxx>
      45             : #include <com/sun/star/uno/Type.hxx>
      46             : #include <com/sun/star/uno/TypeClass.hpp>
      47             : #include <com/sun/star/uno/XComponentContext.hpp>
      48             : #include <com/sun/star/uno/XInterface.hpp>
      49             : #include <com/sun/star/util/XFlushable.hpp>
      50             : #include <cppu/unotype.hxx>
      51             : #include <cppuhelper/implbase1.hxx>
      52             : #include <cppuhelper/implbase3.hxx>
      53             : #include <cppuhelper/supportsservice.hxx>
      54             : #include <cppuhelper/weak.hxx>
      55             : #include <osl/mutex.hxx>
      56             : #include <rtl/ustring.h>
      57             : #include <rtl/ustring.hxx>
      58             : #include <sal/types.h>
      59             : 
      60             : #include "configurationregistry.hxx"
      61             : 
      62             : namespace com { namespace sun { namespace star { namespace util {
      63             :     class XFlushListener;
      64             : } } } }
      65             : 
      66             : namespace configmgr { namespace configuration_registry {
      67             : 
      68             : namespace {
      69             : 
      70             : class Service:
      71             :     public cppu::WeakImplHelper3<
      72             :         css::lang::XServiceInfo, css::registry::XSimpleRegistry,
      73             :         css::util::XFlushable >
      74             : {
      75             : public:
      76             :     explicit Service(css::uno::Reference< css::uno::XComponentContext > const & context);
      77             : 
      78             : private:
      79             :     Service(const Service&) SAL_DELETED_FUNCTION;
      80             :     Service& operator=(const Service&) SAL_DELETED_FUNCTION;
      81             : 
      82          68 :     virtual ~Service() {}
      83             : 
      84           1 :     virtual OUString SAL_CALL getImplementationName()
      85             :         throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
      86           1 :     { return configuration_registry::getImplementationName(); }
      87             : 
      88           0 :     virtual sal_Bool SAL_CALL supportsService(OUString const & ServiceName)
      89             :         throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
      90           0 :     { return cppu::supportsService(this, ServiceName); }
      91             : 
      92             :     virtual css::uno::Sequence< OUString > SAL_CALL
      93           1 :     getSupportedServiceNames() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
      94           1 :     { return configuration_registry::getSupportedServiceNames(); }
      95             : 
      96             :     virtual OUString SAL_CALL getURL() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
      97             : 
      98             :     virtual void SAL_CALL open(
      99             :         OUString const & rURL, sal_Bool bReadOnly, sal_Bool)
     100             :         throw (
     101             :             css::registry::InvalidRegistryException,
     102             :             css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     103             : 
     104             :     virtual sal_Bool SAL_CALL isValid() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     105             : 
     106             :     virtual void SAL_CALL close()
     107             :         throw (
     108             :             css::registry::InvalidRegistryException,
     109             :             css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     110             : 
     111             :     virtual void SAL_CALL destroy()
     112             :         throw (
     113             :             css::registry::InvalidRegistryException,
     114             :             css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     115             : 
     116             :     virtual css::uno::Reference< css::registry::XRegistryKey > SAL_CALL
     117             :     getRootKey()
     118             :         throw (
     119             :             css::registry::InvalidRegistryException,
     120             :             css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     121             : 
     122             :     virtual sal_Bool SAL_CALL isReadOnly() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     123             : 
     124             :     virtual void SAL_CALL mergeKey(OUString const &, OUString const &)
     125             :         throw (
     126             :             css::registry::InvalidRegistryException,
     127             :             css::registry::MergeConflictException, css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     128             : 
     129             :     virtual void SAL_CALL flush() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     130             : 
     131             :     virtual void SAL_CALL addFlushListener(
     132             :         css::uno::Reference< css::util::XFlushListener > const &)
     133             :         throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     134             : 
     135             :     virtual void SAL_CALL removeFlushListener(
     136             :         css::uno::Reference< css::util::XFlushListener > const &)
     137             :         throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     138             : 
     139             :     void checkValid();
     140             : 
     141             :     void checkValid_RuntimeException();
     142             : 
     143             :     void doClose();
     144             : 
     145             :     css::uno::Reference< css::lang::XMultiServiceFactory > provider_;
     146             :     osl::Mutex mutex_;
     147             :     css::uno::Reference< css::uno::XInterface > access_;
     148             :     OUString url_;
     149             :     bool readOnly_;
     150             : 
     151             :     friend class RegistryKey;
     152             : };
     153             : 
     154             : class RegistryKey:
     155             :     public cppu::WeakImplHelper1< css::registry::XRegistryKey >
     156             : {
     157             : public:
     158         110 :     RegistryKey(Service & service, css::uno::Any const & value):
     159         110 :         service_(service), value_(value) {}
     160             : 
     161             : private:
     162             :     RegistryKey(const RegistryKey&) SAL_DELETED_FUNCTION;
     163             :     RegistryKey& operator=(const RegistryKey&) SAL_DELETED_FUNCTION;
     164             : 
     165         220 :     virtual ~RegistryKey() {}
     166             : 
     167             :     virtual OUString SAL_CALL getKeyName()
     168             :         throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     169             : 
     170             :     virtual sal_Bool SAL_CALL isReadOnly()
     171             :         throw (
     172             :             css::registry::InvalidRegistryException,
     173             :             css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     174             : 
     175             :     virtual sal_Bool SAL_CALL isValid() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     176             : 
     177             :     virtual css::registry::RegistryKeyType SAL_CALL getKeyType(
     178             :         OUString const &)
     179             :         throw (
     180             :             css::registry::InvalidRegistryException,
     181             :             css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     182             : 
     183             :     virtual css::registry::RegistryValueType SAL_CALL getValueType()
     184             :         throw (
     185             :             css::registry::InvalidRegistryException,
     186             :             css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     187             : 
     188             :     virtual sal_Int32 SAL_CALL getLongValue()
     189             :         throw (
     190             :             css::registry::InvalidRegistryException,
     191             :             css::registry::InvalidValueException, css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     192             : 
     193             :     virtual void SAL_CALL setLongValue(sal_Int32)
     194             :         throw (
     195             :             css::registry::InvalidRegistryException,
     196             :             css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     197             : 
     198             :     virtual css::uno::Sequence< sal_Int32 > SAL_CALL getLongListValue()
     199             :         throw (
     200             :             css::registry::InvalidRegistryException,
     201             :             css::registry::InvalidValueException, css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     202             : 
     203             :     virtual void SAL_CALL setLongListValue(
     204             :         css::uno::Sequence< sal_Int32 > const &)
     205             :         throw (
     206             :             css::registry::InvalidRegistryException,
     207             :             css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     208             : 
     209             :     virtual OUString SAL_CALL getAsciiValue()
     210             :         throw (
     211             :             css::registry::InvalidRegistryException,
     212             :             css::registry::InvalidValueException, css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     213             : 
     214             :     virtual void SAL_CALL setAsciiValue(OUString const &)
     215             :         throw (
     216             :             css::registry::InvalidRegistryException,
     217             :             css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     218             : 
     219             :     virtual css::uno::Sequence< OUString > SAL_CALL getAsciiListValue()
     220             :         throw (
     221             :             css::registry::InvalidRegistryException,
     222             :             css::registry::InvalidValueException, css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     223             : 
     224             :     virtual void SAL_CALL setAsciiListValue(
     225             :         css::uno::Sequence< OUString > const &)
     226             :         throw (
     227             :             css::registry::InvalidRegistryException,
     228             :             css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     229             : 
     230             :     virtual OUString SAL_CALL getStringValue()
     231             :         throw (
     232             :             css::registry::InvalidRegistryException,
     233             :             css::registry::InvalidValueException, css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     234             : 
     235             :     virtual void SAL_CALL setStringValue(OUString const &)
     236             :         throw (
     237             :             css::registry::InvalidRegistryException,
     238             :             css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     239             : 
     240             :     virtual css::uno::Sequence< OUString > SAL_CALL getStringListValue()
     241             :         throw (
     242             :             css::registry::InvalidRegistryException,
     243             :             css::registry::InvalidValueException, css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     244             : 
     245             :     virtual void SAL_CALL setStringListValue(
     246             :         css::uno::Sequence< OUString > const &)
     247             :         throw (
     248             :             css::registry::InvalidRegistryException,
     249             :             css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     250             : 
     251             :     virtual css::uno::Sequence< sal_Int8 > SAL_CALL getBinaryValue()
     252             :         throw (
     253             :             css::registry::InvalidRegistryException,
     254             :             css::registry::InvalidValueException, css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     255             : 
     256             :     virtual void SAL_CALL setBinaryValue(css::uno::Sequence< sal_Int8 > const &)
     257             :         throw (
     258             :             css::registry::InvalidRegistryException,
     259             :             css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     260             : 
     261             :     virtual css::uno::Reference< css::registry::XRegistryKey > SAL_CALL openKey(
     262             :         OUString const & aKeyName)
     263             :         throw (
     264             :             css::registry::InvalidRegistryException,
     265             :             css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     266             : 
     267             :     virtual css::uno::Reference< css::registry::XRegistryKey > SAL_CALL
     268             :     createKey(OUString const &)
     269             :         throw (
     270             :             css::registry::InvalidRegistryException,
     271             :             css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     272             : 
     273             :     virtual void SAL_CALL closeKey()
     274             :         throw (
     275             :             css::registry::InvalidRegistryException,
     276             :             css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     277             : 
     278             :     virtual void SAL_CALL deleteKey(OUString const &)
     279             :         throw (
     280             :             css::registry::InvalidRegistryException,
     281             :             css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     282             : 
     283             :     virtual
     284             :     css::uno::Sequence< css::uno::Reference< css::registry::XRegistryKey > >
     285             :     SAL_CALL openKeys()
     286             :         throw (
     287             :             css::registry::InvalidRegistryException,
     288             :             css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     289             : 
     290             :     virtual css::uno::Sequence< OUString > SAL_CALL getKeyNames()
     291             :         throw (
     292             :             css::registry::InvalidRegistryException,
     293             :             css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     294             : 
     295             :     virtual sal_Bool SAL_CALL createLink(
     296             :         OUString const &, OUString const &)
     297             :         throw (
     298             :             css::registry::InvalidRegistryException,
     299             :             css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     300             : 
     301             :     virtual void SAL_CALL deleteLink(OUString const &)
     302             :         throw (
     303             :             css::registry::InvalidRegistryException,
     304             :             css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     305             : 
     306             :     virtual OUString SAL_CALL getLinkTarget(OUString const &)
     307             :         throw (
     308             :             css::registry::InvalidRegistryException,
     309             :             css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     310             : 
     311             :     virtual OUString SAL_CALL getResolvedName(
     312             :         OUString const & aKeyName)
     313             :         throw (
     314             :             css::registry::InvalidRegistryException,
     315             :             css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     316             : 
     317             :     Service & service_;
     318             :     css::uno::Any value_;
     319             : };
     320             : 
     321          34 : Service::Service(
     322             :     css::uno::Reference< css::uno::XComponentContext > const & context)
     323          34 :     : readOnly_(false)
     324             : {
     325             :     assert(context.is());
     326             :     try {
     327          68 :         provider_ = css::uno::Reference< css::lang::XMultiServiceFactory >(
     328          68 :             context->getServiceManager()->createInstanceWithContext(
     329          34 :                 "com.sun.star.configuration.DefaultProvider", context),
     330          34 :             css::uno::UNO_QUERY_THROW);
     331           0 :     } catch (css::uno::RuntimeException &) {
     332           0 :         throw;
     333           0 :     } catch (css::uno::Exception & e) {
     334             :         throw css::uno::DeploymentException(
     335             :             ("component context fails to supply service"
     336             :              " com.sun.star.configuration.DefaultProvider of type"
     337           0 :              " com.sun.star.lang.XMultiServiceFactory: " + e.Message),
     338           0 :             context);
     339             :     }
     340          34 : }
     341             : 
     342           0 : OUString Service::getURL() throw (css::uno::RuntimeException, std::exception) {
     343           0 :     osl::MutexGuard g(mutex_);
     344           0 :     checkValid_RuntimeException();
     345           0 :     return url_;
     346             : }
     347             : 
     348          33 : void Service::open(OUString const & rURL, sal_Bool bReadOnly, sal_Bool)
     349             :     throw (css::registry::InvalidRegistryException, css::uno::RuntimeException, std::exception)
     350             : {
     351             :     //TODO: bCreate
     352          33 :     osl::MutexGuard g(mutex_);
     353          33 :     if (access_.is()) {
     354           0 :         doClose();
     355             :     }
     356          66 :     css::uno::Sequence< css::uno::Any > args(1);
     357          33 :     args[0] <<= css::beans::NamedValue("nodepath", css::uno::makeAny(rURL));
     358             :     try {
     359         132 :         access_ = provider_->createInstanceWithArguments(
     360             :             (bReadOnly
     361             :              ? OUString("com.sun.star.configuration.ConfigurationAccess")
     362             :              : OUString(
     363             :                  "com.sun.star.configuration.ConfigurationUpdateAccess")),
     364          66 :             args);
     365           0 :     } catch (css::uno::RuntimeException &) {
     366           0 :         throw;
     367           0 :     } catch (css::uno::Exception & e) {
     368             :         throw css::uno::RuntimeException(
     369           0 :             ("com.sun.star.configuration.ConfigurationRegistry: open failed: " +
     370           0 :              e.Message),
     371           0 :             static_cast< cppu::OWeakObject * >(this));
     372             :     }
     373          33 :     url_ = rURL;
     374          66 :     readOnly_ = bReadOnly;
     375          33 : }
     376             : 
     377           0 : sal_Bool Service::isValid() throw (css::uno::RuntimeException, std::exception) {
     378           0 :     osl::MutexGuard g(mutex_);
     379           0 :     return access_.is();
     380             : }
     381             : 
     382          22 : void Service::close()
     383             :     throw (css::registry::InvalidRegistryException, css::uno::RuntimeException, std::exception)
     384             : {
     385          22 :     osl::MutexGuard g(mutex_);
     386          22 :     checkValid();
     387          22 :     doClose();
     388          22 : }
     389             : 
     390           0 : void Service::destroy()
     391             :     throw (css::registry::InvalidRegistryException, css::uno::RuntimeException, std::exception)
     392             : {
     393             :     throw css::uno::RuntimeException(
     394             :         "com.sun.star.configuration.ConfigurationRegistry: not implemented",
     395           0 :         static_cast< cppu::OWeakObject * >(this));
     396             : }
     397             : 
     398          33 : css::uno::Reference< css::registry::XRegistryKey > Service::getRootKey()
     399             :     throw (css::registry::InvalidRegistryException, css::uno::RuntimeException, std::exception)
     400             : {
     401          33 :     osl::MutexGuard g(mutex_);
     402          33 :     checkValid();
     403          33 :     return new RegistryKey(*this, css::uno::makeAny(access_));
     404             : }
     405             : 
     406           0 : sal_Bool Service::isReadOnly() throw (css::uno::RuntimeException, std::exception) {
     407           0 :     osl::MutexGuard g(mutex_);
     408           0 :     checkValid_RuntimeException();
     409           0 :     return readOnly_;
     410             : }
     411             : 
     412           0 : void Service::mergeKey(OUString const &, OUString const &)
     413             :     throw (
     414             :         css::registry::InvalidRegistryException,
     415             :         css::registry::MergeConflictException, css::uno::RuntimeException, std::exception)
     416             : {
     417             :     throw css::uno::RuntimeException(
     418             :         "com.sun.star.configuration.ConfigurationRegistry: not implemented",
     419           0 :         static_cast< cppu::OWeakObject * >(this));
     420             : }
     421             : 
     422           0 : void Service::flush() throw (css::uno::RuntimeException, std::exception)
     423             : {
     424             :     throw css::uno::RuntimeException(
     425             :         "com.sun.star.configuration.ConfigurationRegistry: not implemented",
     426           0 :         static_cast< cppu::OWeakObject * >(this));
     427             : }
     428             : 
     429           0 : void Service::addFlushListener(
     430             :     css::uno::Reference< css::util::XFlushListener > const &)
     431             :     throw (css::uno::RuntimeException, std::exception)
     432             : {
     433             :     throw css::uno::RuntimeException(
     434             :         "com.sun.star.configuration.ConfigurationRegistry: not implemented",
     435           0 :         static_cast< cppu::OWeakObject * >(this));
     436             : }
     437             : 
     438           0 : void Service::removeFlushListener(
     439             :     css::uno::Reference< css::util::XFlushListener > const &)
     440             :     throw (css::uno::RuntimeException, std::exception)
     441             : {
     442             :     throw css::uno::RuntimeException(
     443             :         "com.sun.star.configuration.ConfigurationRegistry: not implemented",
     444           0 :         static_cast< cppu::OWeakObject * >(this));
     445             : }
     446             : 
     447         159 : void Service::checkValid() {
     448         159 :     if (!access_.is()) {
     449             :         throw css::registry::InvalidRegistryException(
     450             :             "com.sun.star.configuration.ConfigurationRegistry: not valid",
     451           0 :             static_cast< cppu::OWeakObject * >(this));
     452             :     }
     453         159 : }
     454             : 
     455          77 : void Service::checkValid_RuntimeException() {
     456          77 :     if (!access_.is()) {
     457             :         throw css::uno::RuntimeException(
     458             :             "com.sun.star.configuration.ConfigurationRegistry: not valid",
     459           0 :             static_cast< cppu::OWeakObject * >(this));
     460             :     }
     461          77 : }
     462             : 
     463          22 : void Service::doClose() {
     464          22 :     access_.clear();
     465          22 : }
     466             : 
     467           0 : OUString RegistryKey::getKeyName() throw (css::uno::RuntimeException, std::exception) {
     468           0 :     osl::MutexGuard g(service_.mutex_);
     469           0 :     service_.checkValid_RuntimeException();
     470           0 :     css::uno::Reference< css::container::XNamed > named;
     471           0 :     if (value_ >>= named) {
     472           0 :         return named->getName();
     473             :     }
     474             :     throw css::uno::RuntimeException(
     475             :         "com.sun.star.configuration.ConfigurationRegistry: not implemented",
     476           0 :         static_cast< cppu::OWeakObject * >(this));
     477             : }
     478             : 
     479           0 : sal_Bool RegistryKey::isReadOnly()
     480             :     throw (css::registry::InvalidRegistryException, css::uno::RuntimeException, std::exception)
     481             : {
     482           0 :     osl::MutexGuard g(service_.mutex_);
     483           0 :     service_.checkValid_RuntimeException();
     484           0 :     return service_.readOnly_; //TODO: read-only sub-nodes in update access?
     485             : }
     486             : 
     487           0 : sal_Bool RegistryKey::isValid() throw (css::uno::RuntimeException, std::exception) {
     488           0 :     return service_.isValid();
     489             : }
     490             : 
     491           0 : css::registry::RegistryKeyType RegistryKey::getKeyType(OUString const &)
     492             :     throw (css::registry::InvalidRegistryException, css::uno::RuntimeException, std::exception)
     493             : {
     494           0 :     osl::MutexGuard g(service_.mutex_);
     495           0 :     service_.checkValid();
     496           0 :     return css::registry::RegistryKeyType_KEY;
     497             : }
     498             : 
     499           0 : css::registry::RegistryValueType RegistryKey::getValueType()
     500             :     throw (css::registry::InvalidRegistryException, css::uno::RuntimeException, std::exception)
     501             : {
     502           0 :     osl::MutexGuard g(service_.mutex_);
     503           0 :     service_.checkValid();
     504           0 :     css::uno::Type t(value_.getValueType());
     505           0 :     switch (t.getTypeClass()) {
     506             :     case css::uno::TypeClass_LONG:
     507           0 :         return css::registry::RegistryValueType_LONG;
     508             :     case css::uno::TypeClass_STRING:
     509           0 :         return css::registry::RegistryValueType_STRING;
     510             :     case css::uno::TypeClass_SEQUENCE:
     511           0 :         if (t == cppu::UnoType< css::uno::Sequence< sal_Int8 > >::get()) {
     512           0 :             return css::registry::RegistryValueType_BINARY;
     513           0 :         } else if (t == cppu::UnoType< css::uno::Sequence< sal_Int32 > >::get())
     514             :         {
     515           0 :             return css::registry::RegistryValueType_LONGLIST;
     516           0 :         } else if (t ==
     517           0 :                    cppu::UnoType< css::uno::Sequence< OUString > >::get())
     518             :         {
     519           0 :             return css::registry::RegistryValueType_STRINGLIST;
     520             :         }
     521             :         // fall through
     522             :     default:
     523           0 :         return css::registry::RegistryValueType_NOT_DEFINED;
     524           0 :     }
     525             : }
     526             : 
     527          22 : sal_Int32 RegistryKey::getLongValue()
     528             :     throw (
     529             :         css::registry::InvalidRegistryException,
     530             :         css::registry::InvalidValueException, css::uno::RuntimeException, std::exception)
     531             : {
     532          22 :     osl::MutexGuard g(service_.mutex_);
     533          22 :     service_.checkValid();
     534          22 :     sal_Int32 v = 0;
     535          22 :     if (value_ >>= v) {
     536          22 :         return v;
     537             :     }
     538             :     throw css::registry::InvalidValueException(
     539             :         "com.sun.star.configuration.ConfigurationRegistry",
     540          11 :         static_cast< cppu::OWeakObject * >(this));
     541             : }
     542             : 
     543           0 : void RegistryKey::setLongValue(sal_Int32)
     544             :     throw (css::registry::InvalidRegistryException, css::uno::RuntimeException, std::exception)
     545             : {
     546             :     throw css::uno::RuntimeException(
     547             :         "com.sun.star.configuration.ConfigurationRegistry: not implemented",
     548           0 :         static_cast< cppu::OWeakObject * >(this));
     549             : }
     550             : 
     551           0 : css::uno::Sequence< sal_Int32 > RegistryKey::getLongListValue()
     552             :     throw (
     553             :         css::registry::InvalidRegistryException,
     554             :         css::registry::InvalidValueException, css::uno::RuntimeException, std::exception)
     555             : {
     556           0 :     osl::MutexGuard g(service_.mutex_);
     557           0 :     service_.checkValid();
     558           0 :     css::uno::Sequence< sal_Int32 > v;
     559           0 :     if (value_ >>= v) {
     560           0 :         return v;
     561             :     }
     562             :     throw css::registry::InvalidValueException(
     563             :         "com.sun.star.configuration.ConfigurationRegistry",
     564           0 :         static_cast< cppu::OWeakObject * >(this));
     565             : }
     566             : 
     567           0 : void RegistryKey::setLongListValue(css::uno::Sequence< sal_Int32 > const &)
     568             :     throw (css::registry::InvalidRegistryException, css::uno::RuntimeException, std::exception)
     569             : {
     570             :     throw css::uno::RuntimeException(
     571             :         "com.sun.star.configuration.ConfigurationRegistry: not implemented",
     572           0 :         static_cast< cppu::OWeakObject * >(this));
     573             : }
     574             : 
     575           0 : OUString RegistryKey::getAsciiValue()
     576             :     throw (
     577             :         css::registry::InvalidRegistryException,
     578             :         css::registry::InvalidValueException, css::uno::RuntimeException, std::exception)
     579             : {
     580           0 :     osl::MutexGuard g(service_.mutex_);
     581           0 :     service_.checkValid();
     582           0 :     OUString v;
     583           0 :     if (value_ >>= v) {
     584           0 :         return v;
     585             :     }
     586             :     throw css::registry::InvalidValueException(
     587             :         "com.sun.star.configuration.ConfigurationRegistry",
     588           0 :         static_cast< cppu::OWeakObject * >(this));
     589             : }
     590             : 
     591           0 : void RegistryKey::setAsciiValue(OUString const &)
     592             :     throw (css::registry::InvalidRegistryException, css::uno::RuntimeException, std::exception)
     593             : {
     594             :     throw css::uno::RuntimeException(
     595             :         "com.sun.star.configuration.ConfigurationRegistry: not implemented",
     596           0 :         static_cast< cppu::OWeakObject * >(this));
     597             : }
     598             : 
     599           0 : css::uno::Sequence< OUString > RegistryKey::getAsciiListValue()
     600             :     throw (
     601             :         css::registry::InvalidRegistryException,
     602             :         css::registry::InvalidValueException, css::uno::RuntimeException, std::exception)
     603             : {
     604           0 :     osl::MutexGuard g(service_.mutex_);
     605           0 :     service_.checkValid();
     606           0 :     css::uno::Sequence< OUString > v;
     607           0 :     if (value_ >>= v) {
     608           0 :         return v;
     609             :     }
     610             :     throw css::registry::InvalidValueException(
     611             :         "com.sun.star.configuration.ConfigurationRegistry",
     612           0 :         static_cast< cppu::OWeakObject * >(this));
     613             : }
     614             : 
     615           0 : void RegistryKey::setAsciiListValue(css::uno::Sequence< OUString > const &)
     616             :     throw (css::registry::InvalidRegistryException, css::uno::RuntimeException, std::exception)
     617             : {
     618             :     throw css::uno::RuntimeException(
     619             :         "com.sun.star.configuration.ConfigurationRegistry: not implemented",
     620           0 :         static_cast< cppu::OWeakObject * >(this));
     621             : }
     622             : 
     623          82 : OUString RegistryKey::getStringValue()
     624             :     throw (
     625             :         css::registry::InvalidRegistryException,
     626             :         css::registry::InvalidValueException, css::uno::RuntimeException, std::exception)
     627             : {
     628          82 :     osl::MutexGuard g(service_.mutex_);
     629          82 :     service_.checkValid();
     630          82 :     OUString v;
     631          82 :     if (value_ >>= v) {
     632         164 :         return v;
     633             :     }
     634             :     throw css::registry::InvalidValueException(
     635             :         "com.sun.star.configuration.ConfigurationRegistry",
     636           0 :         static_cast< cppu::OWeakObject * >(this));
     637             : }
     638             : 
     639           0 : void RegistryKey::setStringValue(OUString const &)
     640             :     throw (css::registry::InvalidRegistryException, css::uno::RuntimeException, std::exception)
     641             : {
     642             :     throw css::uno::RuntimeException(
     643             :         "com.sun.star.configuration.ConfigurationRegistry: not implemented",
     644           0 :         static_cast< cppu::OWeakObject * >(this));
     645             : }
     646             : 
     647           0 : css::uno::Sequence< OUString > RegistryKey::getStringListValue()
     648             :     throw (
     649             :         css::registry::InvalidRegistryException,
     650             :         css::registry::InvalidValueException, css::uno::RuntimeException, std::exception)
     651             : {
     652           0 :     osl::MutexGuard g(service_.mutex_);
     653           0 :     service_.checkValid();
     654           0 :     css::uno::Sequence< OUString > v;
     655           0 :     if (value_ >>= v) {
     656           0 :         return v;
     657             :     }
     658             :     throw css::registry::InvalidValueException(
     659             :         "com.sun.star.configuration.ConfigurationRegistry",
     660           0 :         static_cast< cppu::OWeakObject * >(this));
     661             : }
     662             : 
     663           0 : void RegistryKey::setStringListValue(
     664             :     css::uno::Sequence< OUString > const &)
     665             :     throw (css::registry::InvalidRegistryException, css::uno::RuntimeException, std::exception)
     666             : {
     667             :     throw css::uno::RuntimeException(
     668             :         "com.sun.star.configuration.ConfigurationRegistry: not implemented",
     669           0 :         static_cast< cppu::OWeakObject * >(this));
     670             : }
     671             : 
     672           0 : css::uno::Sequence< sal_Int8 > RegistryKey::getBinaryValue()
     673             :     throw (
     674             :         css::registry::InvalidRegistryException,
     675             :         css::registry::InvalidValueException, css::uno::RuntimeException, std::exception)
     676             : {
     677           0 :     osl::MutexGuard g(service_.mutex_);
     678           0 :     service_.checkValid();
     679           0 :     css::uno::Sequence< sal_Int8 > v;
     680           0 :     if (value_ >>= v) {
     681           0 :         return v;
     682             :     }
     683             :     throw css::registry::InvalidValueException(
     684             :         "com.sun.star.configuration.ConfigurationRegistry",
     685           0 :         static_cast< cppu::OWeakObject * >(this));
     686             : }
     687             : 
     688           0 : void RegistryKey::setBinaryValue(css::uno::Sequence< sal_Int8 > const &)
     689             :     throw (css::registry::InvalidRegistryException, css::uno::RuntimeException, std::exception)
     690             : {
     691             :     throw css::uno::RuntimeException(
     692             :         "com.sun.star.configuration.ConfigurationRegistry: not implemented",
     693           0 :         static_cast< cppu::OWeakObject * >(this));
     694             : }
     695             : 
     696          77 : css::uno::Reference< css::registry::XRegistryKey > RegistryKey::openKey(
     697             :     OUString const & aKeyName)
     698             :     throw (css::registry::InvalidRegistryException, css::uno::RuntimeException, std::exception)
     699             : {
     700          77 :     osl::MutexGuard g(service_.mutex_);
     701          77 :     service_.checkValid_RuntimeException();
     702         154 :     css::uno::Reference< css::container::XHierarchicalNameAccess > access;
     703          77 :     if (value_ >>= access) {
     704             :         try {
     705             :             return new RegistryKey(
     706          77 :                 service_, access->getByHierarchicalName(aKeyName));
     707           0 :         } catch (css::container::NoSuchElementException &) {}
     708             :     }
     709          77 :     return css::uno::Reference< css::registry::XRegistryKey >();
     710             : }
     711             : 
     712           0 : css::uno::Reference< css::registry::XRegistryKey > RegistryKey::createKey(
     713             :     OUString const &)
     714             :     throw (
     715             :         css::registry::InvalidRegistryException, css::uno::RuntimeException, std::exception)
     716             : {
     717             :     throw css::uno::RuntimeException(
     718             :         "com.sun.star.configuration.ConfigurationRegistry: not implemented",
     719           0 :         static_cast< cppu::OWeakObject * >(this));
     720             : }
     721             : 
     722           0 : void RegistryKey::closeKey()
     723             :     throw (
     724             :         css::registry::InvalidRegistryException, css::uno::RuntimeException, std::exception)
     725             : {
     726           0 :     osl::MutexGuard g(service_.mutex_);
     727           0 :     service_.checkValid_RuntimeException();
     728           0 : }
     729             : 
     730           0 : void RegistryKey::deleteKey(OUString const &)
     731             :     throw (css::registry::InvalidRegistryException, css::uno::RuntimeException, std::exception)
     732             : {
     733             :     throw css::uno::RuntimeException(
     734             :         "com.sun.star.configuration.ConfigurationRegistry: not implemented",
     735           0 :         static_cast< cppu::OWeakObject * >(this));
     736             : }
     737             : 
     738             : css::uno::Sequence< css::uno::Reference< css::registry::XRegistryKey > >
     739           0 : RegistryKey::openKeys()
     740             :     throw (css::registry::InvalidRegistryException, css::uno::RuntimeException, std::exception)
     741             : {
     742             :     throw css::uno::RuntimeException(
     743             :         "com.sun.star.configuration.ConfigurationRegistry: not implemented",
     744           0 :         static_cast< cppu::OWeakObject * >(this));
     745             : }
     746             : 
     747           0 : css::uno::Sequence< OUString > RegistryKey::getKeyNames()
     748             :     throw (css::registry::InvalidRegistryException, css::uno::RuntimeException, std::exception)
     749             : {
     750             :     throw css::uno::RuntimeException(
     751             :         "com.sun.star.configuration.ConfigurationRegistry: not implemented",
     752           0 :         static_cast< cppu::OWeakObject * >(this));
     753             : }
     754             : 
     755           0 : sal_Bool RegistryKey::createLink(OUString const &, OUString const &)
     756             :     throw (css::registry::InvalidRegistryException, css::uno::RuntimeException, std::exception)
     757             : {
     758           0 :     osl::MutexGuard g(service_.mutex_);
     759           0 :     service_.checkValid_RuntimeException();
     760           0 :     return false;
     761             : }
     762             : 
     763           0 : void RegistryKey::deleteLink(OUString const &)
     764             :     throw (css::registry::InvalidRegistryException, css::uno::RuntimeException, std::exception)
     765             : {
     766           0 :     osl::MutexGuard g(service_.mutex_);
     767           0 :     service_.checkValid_RuntimeException();
     768           0 : }
     769             : 
     770           0 : OUString RegistryKey::getLinkTarget(OUString const &)
     771             :     throw (css::registry::InvalidRegistryException, css::uno::RuntimeException, std::exception)
     772             : {
     773           0 :     osl::MutexGuard g(service_.mutex_);
     774           0 :     service_.checkValid_RuntimeException();
     775           0 :     return OUString();
     776             : }
     777             : 
     778           0 : OUString RegistryKey::getResolvedName(OUString const & aKeyName)
     779             :     throw (css::registry::InvalidRegistryException, css::uno::RuntimeException, std::exception)
     780             : {
     781           0 :     osl::MutexGuard g(service_.mutex_);
     782           0 :     service_.checkValid_RuntimeException();
     783           0 :     return aKeyName;
     784             : }
     785             : 
     786             : }
     787             : 
     788          34 : css::uno::Reference< css::uno::XInterface > create(
     789             :     css::uno::Reference< css::uno::XComponentContext > const & context)
     790             : {
     791          34 :     return static_cast< cppu::OWeakObject * >(new Service(context));
     792             : }
     793             : 
     794         687 : OUString getImplementationName() {
     795         687 :     return OUString("com.sun.star.comp.configuration.ConfigurationRegistry");
     796             : }
     797             : 
     798           8 : css::uno::Sequence< OUString > getSupportedServiceNames() {
     799           8 :     OUString name("com.sun.star.configuration.ConfigurationRegistry");
     800           8 :     return css::uno::Sequence< OUString >(&name, 1);
     801             : }
     802             : 
     803             : } }
     804             : 
     805             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11