LCOV - code coverage report
Current view: top level - configmgr/source - update.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 45 0.0 %
Date: 2014-04-14 Functions: 0 11 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             : #include <set>
      24             : 
      25             : #include "boost/noncopyable.hpp"
      26             : #include "boost/shared_ptr.hpp"
      27             : #include "com/sun/star/configuration/XUpdate.hpp"
      28             : #include "com/sun/star/uno/Reference.hxx"
      29             : #include "com/sun/star/uno/RuntimeException.hpp"
      30             : #include "com/sun/star/uno/Sequence.hxx"
      31             : #include "com/sun/star/uno/XComponentContext.hpp"
      32             : #include "com/sun/star/uno/XInterface.hpp"
      33             : #include "cppuhelper/implbase1.hxx"
      34             : #include "cppuhelper/weak.hxx"
      35             : #include "osl/mutex.hxx"
      36             : #include "rtl/ref.hxx"
      37             : #include "rtl/ustring.h"
      38             : #include "rtl/ustring.hxx"
      39             : #include "sal/types.h"
      40             : 
      41             : #include "broadcaster.hxx"
      42             : #include "components.hxx"
      43             : #include "lock.hxx"
      44             : #include "modifications.hxx"
      45             : #include "rootaccess.hxx"
      46             : #include "update.hxx"
      47             : 
      48             : namespace configmgr { namespace update {
      49             : 
      50             : namespace {
      51             : 
      52           0 : std::set< OUString > seqToSet(
      53             :     css::uno::Sequence< OUString > const & sequence)
      54             : {
      55             :     return std::set< OUString >(
      56             :         sequence.getConstArray(),
      57           0 :         sequence.getConstArray() + sequence.getLength());
      58             : }
      59             : 
      60             : class Service:
      61             :     public cppu::WeakImplHelper1< css::configuration::XUpdate >,
      62             :     private boost::noncopyable
      63             : {
      64             : public:
      65           0 :     Service(css::uno::Reference< css::uno::XComponentContext > const context):
      66           0 :         context_(context)
      67             :     {
      68             :         assert(context.is());
      69           0 :         lock_ = lock();
      70           0 :     }
      71             : 
      72             : private:
      73           0 :     virtual ~Service() {}
      74             : 
      75             :     virtual void SAL_CALL insertExtensionXcsFile(
      76             :         sal_Bool shared, OUString const & fileUri)
      77             :         throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
      78             : 
      79             :     virtual void SAL_CALL insertExtensionXcuFile(
      80             :         sal_Bool shared, OUString const & fileUri)
      81             :         throw (css::uno::RuntimeException,
      82             :                std::exception) SAL_OVERRIDE;
      83             : 
      84             :     virtual void SAL_CALL removeExtensionXcuFile(OUString const & fileUri)
      85             :         throw (css::uno::RuntimeException,
      86             :                std::exception) SAL_OVERRIDE;
      87             : 
      88             :     virtual void SAL_CALL insertModificationXcuFile(
      89             :         OUString const & fileUri,
      90             :         css::uno::Sequence< OUString > const & includedPaths,
      91             :         css::uno::Sequence< OUString > const & excludedPaths)
      92             :         throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
      93             : 
      94             :     boost::shared_ptr<osl::Mutex> lock_;
      95             :     css::uno::Reference< css::uno::XComponentContext > context_;
      96             : };
      97             : 
      98           0 : void Service::insertExtensionXcsFile(
      99             :     sal_Bool shared, OUString const & fileUri)
     100             :     throw (css::uno::RuntimeException, std::exception)
     101             : {
     102           0 :     osl::MutexGuard g(*lock_);
     103           0 :     Components::getSingleton(context_).insertExtensionXcsFile(shared, fileUri);
     104           0 : }
     105             : 
     106           0 : void Service::insertExtensionXcuFile(
     107             :     sal_Bool shared, OUString const & fileUri)
     108             :     throw (css::uno::RuntimeException,
     109             :            std::exception)
     110             : {
     111           0 :     Broadcaster bc;
     112             :     {
     113           0 :         osl::MutexGuard g(*lock_);
     114           0 :         Components & components = Components::getSingleton(context_);
     115           0 :         Modifications mods;
     116           0 :         components.insertExtensionXcuFile(shared, fileUri, &mods);
     117             :         components.initGlobalBroadcaster(
     118           0 :             mods, rtl::Reference< RootAccess >(), &bc);
     119             :     }
     120           0 :     bc.send();
     121           0 : }
     122             : 
     123           0 : void Service::removeExtensionXcuFile(OUString const & fileUri)
     124             :     throw (css::uno::RuntimeException, std::exception)
     125             : {
     126           0 :     Broadcaster bc;
     127             :     {
     128           0 :         osl::MutexGuard g(*lock_);
     129           0 :         Components & components = Components::getSingleton(context_);
     130           0 :         Modifications mods;
     131           0 :         components.removeExtensionXcuFile(fileUri, &mods);
     132             :         components.initGlobalBroadcaster(
     133           0 :             mods, rtl::Reference< RootAccess >(), &bc);
     134             :     }
     135           0 :     bc.send();
     136           0 : }
     137             : 
     138           0 : void Service::insertModificationXcuFile(
     139             :     OUString const & fileUri,
     140             :     css::uno::Sequence< OUString > const & includedPaths,
     141             :     css::uno::Sequence< OUString > const & excludedPaths)
     142             :     throw (css::uno::RuntimeException, std::exception)
     143             : {
     144           0 :     Broadcaster bc;
     145             :     {
     146           0 :         osl::MutexGuard g(*lock_);
     147           0 :         Components & components = Components::getSingleton(context_);
     148           0 :         Modifications mods;
     149             :         components.insertModificationXcuFile(
     150           0 :             fileUri, seqToSet(includedPaths), seqToSet(excludedPaths), &mods);
     151             :         components.initGlobalBroadcaster(
     152           0 :             mods, rtl::Reference< RootAccess >(), &bc);
     153             :     }
     154           0 :     bc.send();
     155           0 : }
     156             : 
     157             : }
     158             : 
     159           0 : css::uno::Reference< css::uno::XInterface > create(
     160             :     css::uno::Reference< css::uno::XComponentContext > const & context)
     161             : {
     162           0 :     return static_cast< cppu::OWeakObject * >(new Service(context));
     163             : }
     164             : 
     165           0 : OUString getImplementationName() {
     166           0 :     return OUString("com.sun.star.comp.configuration.Update");
     167             : }
     168             : 
     169           0 : css::uno::Sequence< OUString > getSupportedServiceNames() {
     170           0 :     OUString name("com.sun.star.configuration.Update_Service");
     171           0 :     return css::uno::Sequence< OUString >(&name, 1);
     172             : }
     173             : 
     174             : } }
     175             : 
     176             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10