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

Generated by: LCOV version 1.10