LCOV - code coverage report
Current view: top level - configmgr/source - readwriteaccess.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 45 0.0 %
Date: 2014-04-14 Functions: 0 17 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             : 
      10             : #include "sal/config.h"
      11             : 
      12             : #include "boost/noncopyable.hpp"
      13             : #include "com/sun/star/configuration/XReadWriteAccess.hpp"
      14             : #include "com/sun/star/container/NoSuchElementException.hpp"
      15             : #include "com/sun/star/lang/IllegalArgumentException.hpp"
      16             : #include "com/sun/star/lang/NotInitializedException.hpp"
      17             : #include "com/sun/star/lang/WrappedTargetException.hpp"
      18             : #include "com/sun/star/lang/XInitialization.hpp"
      19             : #include "com/sun/star/lang/XServiceInfo.hpp"
      20             : #include "com/sun/star/uno/Any.hxx"
      21             : #include "com/sun/star/uno/Exception.hpp"
      22             : #include "com/sun/star/uno/Reference.hxx"
      23             : #include "com/sun/star/uno/RuntimeException.hpp"
      24             : #include "com/sun/star/uno/Sequence.hxx"
      25             : #include "com/sun/star/uno/XComponentContext.hpp"
      26             : #include "com/sun/star/uno/XInterface.hpp"
      27             : #include "com/sun/star/util/ChangesSet.hpp"
      28             : #include "cppuhelper/implbase3.hxx"
      29             : #include "cppuhelper/supportsservice.hxx"
      30             : #include "cppuhelper/weak.hxx"
      31             : #include "osl/mutex.hxx"
      32             : #include "rtl/ref.hxx"
      33             : #include "rtl/ustring.h"
      34             : #include "rtl/ustring.hxx"
      35             : #include "sal/types.h"
      36             : 
      37             : #include "components.hxx"
      38             : #include "lock.hxx"
      39             : #include "readwriteaccess.hxx"
      40             : #include "rootaccess.hxx"
      41             : 
      42             : namespace configmgr { namespace read_write_access {
      43             : 
      44             : namespace {
      45             : 
      46             : class Service:
      47             :     public cppu::WeakImplHelper3<
      48             :         css::lang::XServiceInfo, css::lang::XInitialization,
      49             :         css::configuration::XReadWriteAccess >,
      50             :     private boost::noncopyable
      51             : {
      52             : public:
      53           0 :     explicit Service(
      54             :         css::uno::Reference< css::uno::XComponentContext > const & context):
      55           0 :         context_(context) {}
      56             : 
      57             : private:
      58           0 :     virtual ~Service() {}
      59             : 
      60           0 :     virtual OUString SAL_CALL getImplementationName()
      61             :         throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
      62           0 :     { return read_write_access::getImplementationName(); }
      63             : 
      64           0 :     virtual sal_Bool SAL_CALL supportsService(OUString const & ServiceName)
      65             :         throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
      66           0 :     { return cppu::supportsService(this, ServiceName); }
      67             : 
      68             :     virtual css::uno::Sequence< OUString > SAL_CALL
      69           0 :     getSupportedServiceNames() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
      70           0 :     { return read_write_access::getSupportedServiceNames(); }
      71             : 
      72             :     virtual void SAL_CALL initialize(
      73             :         css::uno::Sequence< css::uno::Any > const & aArguments)
      74             :         throw (css::uno::Exception, css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
      75             : 
      76           0 :     virtual css::uno::Any SAL_CALL getByHierarchicalName(
      77             :         OUString const & aName)
      78             :         throw (
      79             :             css::container::NoSuchElementException, css::uno::RuntimeException, std::exception) SAL_OVERRIDE
      80           0 :     { return getRoot()->getByHierarchicalName(aName); }
      81             : 
      82           0 :     virtual sal_Bool SAL_CALL hasByHierarchicalName(OUString const & aName)
      83             :         throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
      84           0 :     { return getRoot()->hasByHierarchicalName(aName); }
      85             : 
      86           0 :     virtual void SAL_CALL replaceByHierarchicalName(
      87             :         OUString const & aName, css::uno::Any const & aElement)
      88             :         throw (
      89             :             css::lang::IllegalArgumentException,
      90             :             css::container::NoSuchElementException,
      91             :             css::lang::WrappedTargetException, css::uno::RuntimeException, std::exception) SAL_OVERRIDE
      92           0 :     { getRoot()->replaceByHierarchicalName(aName, aElement); }
      93             : 
      94           0 :     virtual void SAL_CALL commitChanges()
      95             :         throw (css::lang::WrappedTargetException, css::uno::RuntimeException, std::exception) SAL_OVERRIDE
      96           0 :     { getRoot()->commitChanges(); }
      97             : 
      98           0 :     virtual sal_Bool SAL_CALL hasPendingChanges()
      99             :         throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
     100           0 :     { return getRoot()->hasPendingChanges(); }
     101             : 
     102           0 :     virtual css::util::ChangesSet SAL_CALL getPendingChanges()
     103             :         throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
     104           0 :     { return getRoot()->getPendingChanges(); }
     105             : 
     106             :     rtl::Reference< RootAccess > getRoot();
     107             : 
     108             :     css::uno::Reference< css::uno::XComponentContext > context_;
     109             : 
     110             :     osl::Mutex mutex_;
     111             :     rtl::Reference< RootAccess > root_;
     112             : };
     113             : 
     114           0 : void Service::initialize(css::uno::Sequence< css::uno::Any > const & aArguments)
     115             :     throw (css::uno::Exception, css::uno::RuntimeException, std::exception)
     116             : {
     117           0 :     OUString locale;
     118           0 :     if (aArguments.getLength() != 1 || !(aArguments[0] >>= locale)) {
     119             :         throw css::lang::IllegalArgumentException(
     120             :             "not exactly one string argument",
     121           0 :             static_cast< cppu::OWeakObject * >(this), -1);
     122             :     }
     123           0 :     osl::MutexGuard g1(mutex_);
     124           0 :     if (root_.is()) {
     125             :         throw css::uno::RuntimeException(
     126           0 :             "already initialized", static_cast< cppu::OWeakObject * >(this));
     127             :     }
     128           0 :     osl::MutexGuard g2(*lock());
     129           0 :     Components & components = Components::getSingleton(context_);
     130           0 :     root_ = new RootAccess(components, "/", locale, true);
     131           0 :     components.addRootAccess(root_);
     132           0 : }
     133             : 
     134           0 : rtl::Reference< RootAccess > Service::getRoot() {
     135           0 :     osl::MutexGuard g(mutex_);
     136           0 :     if (!root_.is()) {
     137             :         throw css::lang::NotInitializedException(
     138           0 :             "not initialized", static_cast< cppu::OWeakObject * >(this));
     139             :     }
     140           0 :     return root_;
     141             : }
     142             : 
     143             : }
     144             : 
     145           0 : css::uno::Reference< css::uno::XInterface > create(
     146             :     css::uno::Reference< css::uno::XComponentContext > const & context)
     147             : {
     148           0 :     return static_cast< cppu::OWeakObject * >(new Service(context));
     149             : }
     150             : 
     151           0 : OUString getImplementationName() {
     152           0 :     return OUString("com.sun.star.comp.configuration.ReadWriteAccess");
     153             : }
     154             : 
     155           0 : css::uno::Sequence< OUString > getSupportedServiceNames() {
     156           0 :     OUString name("com.sun.star.configuration.ReadWriteAccess");
     157           0 :     return css::uno::Sequence< OUString >(&name, 1);
     158             : }
     159             : 
     160             : } }
     161             : 
     162             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10