1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <sal/config.h>
26 #include <com/sun/star/configuration/XUpdate.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>
30 #include <cppuhelper/implbase.hxx>
31 #include <cppuhelper/weak.hxx>
32 #include <osl/mutex.hxx>
33 #include <rtl/ref.hxx>
34 #include <rtl/ustring.hxx>
35 #include <sal/types.h>
37 #include "broadcaster.hxx"
38 #include "components.hxx"
40 #include "modifications.hxx"
41 #include "rootaccess.hxx"
44 namespace configmgr
{ namespace update
{
48 std::set
< OUString
> seqToSet(
49 css::uno::Sequence
< OUString
> const & sequence
)
51 return std::set
< OUString
>( sequence
.begin(), sequence
.end() );
55 public cppu::WeakImplHelper
< css::configuration::XUpdate
>
58 explicit Service(const css::uno::Reference
< css::uno::XComponentContext
>& context
):
66 Service(const Service
&) = delete;
67 Service
& operator=(const Service
&) = delete;
69 virtual ~Service() override
{}
71 virtual void SAL_CALL
insertExtensionXcsFile(
72 sal_Bool shared
, OUString
const & fileUri
) override
;
74 virtual void SAL_CALL
insertExtensionXcuFile(
75 sal_Bool shared
, OUString
const & fileUri
) override
;
77 virtual void SAL_CALL
removeExtensionXcuFile(OUString
const & fileUri
) override
;
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
;
84 std::shared_ptr
<osl::Mutex
> lock_
;
85 css::uno::Reference
< css::uno::XComponentContext
> context_
;
88 void Service::insertExtensionXcsFile(
89 sal_Bool shared
, OUString
const & fileUri
)
91 osl::MutexGuard
g(*lock_
);
92 Components::getSingleton(context_
).insertExtensionXcsFile(shared
, fileUri
);
95 void Service::insertExtensionXcuFile(
96 sal_Bool shared
, OUString
const & fileUri
)
100 osl::MutexGuard
g(*lock_
);
101 Components
& components
= Components::getSingleton(context_
);
103 components
.insertExtensionXcuFile(shared
, fileUri
, &mods
);
104 components
.initGlobalBroadcaster(
105 mods
, rtl::Reference
< RootAccess
>(), &bc
);
110 void Service::removeExtensionXcuFile(OUString
const & fileUri
)
114 osl::MutexGuard
g(*lock_
);
115 Components
& components
= Components::getSingleton(context_
);
117 components
.removeExtensionXcuFile(fileUri
, &mods
);
118 components
.initGlobalBroadcaster(
119 mods
, rtl::Reference
< RootAccess
>(), &bc
);
124 void Service::insertModificationXcuFile(
125 OUString
const & fileUri
,
126 css::uno::Sequence
< OUString
> const & includedPaths
,
127 css::uno::Sequence
< OUString
> const & excludedPaths
)
131 osl::MutexGuard
g(*lock_
);
132 Components
& components
= Components::getSingleton(context_
);
134 components
.insertModificationXcuFile(
135 fileUri
, seqToSet(includedPaths
), seqToSet(excludedPaths
), &mods
);
136 components
.initGlobalBroadcaster(
137 mods
, rtl::Reference
< RootAccess
>(), &bc
);
144 css::uno::Reference
< css::uno::XInterface
> create(
145 css::uno::Reference
< css::uno::XComponentContext
> const & context
)
147 return static_cast< cppu::OWeakObject
* >(new Service(context
));
150 OUString
getImplementationName() {
151 return "com.sun.star.comp.configuration.Update";
154 css::uno::Sequence
< OUString
> getSupportedServiceNames() {
155 return css::uno::Sequence
< OUString
> { "com.sun.star.configuration.Update_Service" };
160 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */