LibreOffice Module configmgr (master)  1
update.cxx
Go to the documentation of this file.
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 <com/sun/star/configuration/XUpdate.hpp>
26 #include <com/sun/star/uno/Reference.hxx>
27 #include <com/sun/star/uno/Sequence.hxx>
28 #include <com/sun/star/uno/XInterface.hpp>
29 #include <cppuhelper/implbase.hxx>
30 #include <cppuhelper/weak.hxx>
31 #include <osl/mutex.hxx>
32 #include <rtl/ref.hxx>
33 #include <rtl/ustring.hxx>
34 #include <sal/types.h>
35 
36 #include "broadcaster.hxx"
37 #include "components.hxx"
38 #include "lock.hxx"
39 #include "modifications.hxx"
40 #include "rootaccess.hxx"
41 
42 namespace configmgr::update {
43 
44 namespace {
45 
46 std::set< OUString > seqToSet(
47  css::uno::Sequence< OUString > const & sequence)
48 {
49  return std::set< OUString >( sequence.begin(), sequence.end() );
50 }
51 
52 class Service:
53  public cppu::WeakImplHelper< css::configuration::XUpdate >
54 {
55 public:
56  explicit Service(const css::uno::Reference< css::uno::XComponentContext >& context):
57  context_(context)
58  {
59  assert(context.is());
60  lock_ = lock();
61  }
62 
63 private:
64  Service(const Service&) = delete;
65  Service& operator=(const Service&) = delete;
66 
67  virtual ~Service() override {}
68 
69  virtual void SAL_CALL insertExtensionXcsFile(
70  sal_Bool shared, OUString const & fileUri) override;
71 
72  virtual void SAL_CALL insertExtensionXcuFile(
73  sal_Bool shared, OUString const & fileUri) override;
74 
75  virtual void SAL_CALL removeExtensionXcuFile(OUString const & fileUri) override;
76 
77  virtual void SAL_CALL insertModificationXcuFile(
78  OUString const & fileUri,
79  css::uno::Sequence< OUString > const & includedPaths,
80  css::uno::Sequence< OUString > const & excludedPaths) override;
81 
82  std::shared_ptr<osl::Mutex> lock_;
83  css::uno::Reference< css::uno::XComponentContext > context_;
84 };
85 
86 void Service::insertExtensionXcsFile(
87  sal_Bool shared, OUString const & fileUri)
88 {
89  osl::MutexGuard g(*lock_);
91 }
92 
93 void Service::insertExtensionXcuFile(
94  sal_Bool shared, OUString const & fileUri)
95 {
96  Broadcaster bc;
97  {
98  osl::MutexGuard g(*lock_);
100  Modifications mods;
101  components.insertExtensionXcuFile(shared, fileUri, &mods);
102  components.initGlobalBroadcaster(
103  mods, rtl::Reference< RootAccess >(), &bc);
104  }
105  bc.send();
106 }
107 
108 void Service::removeExtensionXcuFile(OUString const & fileUri)
109 {
110  Broadcaster bc;
111  {
112  osl::MutexGuard g(*lock_);
114  Modifications mods;
115  components.removeExtensionXcuFile(fileUri, &mods);
116  components.initGlobalBroadcaster(
117  mods, rtl::Reference< RootAccess >(), &bc);
118  }
119  bc.send();
120 }
121 
122 void Service::insertModificationXcuFile(
123  OUString const & fileUri,
124  css::uno::Sequence< OUString > const & includedPaths,
125  css::uno::Sequence< OUString > const & excludedPaths)
126 {
127  Broadcaster bc;
128  {
129  osl::MutexGuard g(*lock_);
131  Modifications mods;
132  components.insertModificationXcuFile(
133  fileUri, seqToSet(includedPaths), seqToSet(excludedPaths), &mods);
134  components.initGlobalBroadcaster(
135  mods, rtl::Reference< RootAccess >(), &bc);
136  }
137  bc.send();
138 }
139 
140 }
141 }
142 
143 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
145  css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any> const& )
146 {
147  return cppu::acquire(new configmgr::update::Service(context));
148 }
149 
150 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void insertExtensionXcsFile(bool shared, OUString const &fileUri)
Definition: components.cxx:307
std::shared_ptr< osl::Mutex > lock_
Definition: update.cxx:82
std::set< OUString > excludedPaths
const BorderLinePrimitive2D *pCandidateB assert(pCandidateA)
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * com_sun_star_comp_configuration_Update_get_implementation(css::uno::XComponentContext *context, css::uno::Sequence< css::uno::Any > const &)
Definition: update.cxx:144
unsigned char sal_Bool
std::vector< uno::Reference< sheet::XSpreadsheetDocument > > Components
std::set< OUString > includedPaths
css::uno::Reference< css::uno::XComponentContext > context_
Definition: update.cxx:83
std::shared_ptr< osl::Mutex > const & lock()
Definition: lock.cxx:28
static Components & getSingleton(css::uno::Reference< css::uno::XComponentContext > const &context)
Definition: components.cxx:197