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