/src/libreoffice/configmgr/source/components.hxx
Line | Count | Source |
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 | | #pragma once |
21 | | |
22 | | #include <sal/config.h> |
23 | | |
24 | | #include <string_view> |
25 | | |
26 | | #include <com/sun/star/beans/Optional.hpp> |
27 | | #include <com/sun/star/uno/Reference.hxx> |
28 | | #include <rtl/ref.hxx> |
29 | | #include <o3tl/sorted_vector.hxx> |
30 | | |
31 | | #include "additions.hxx" |
32 | | #include "data.hxx" |
33 | | #include "modifications.hxx" |
34 | | |
35 | | namespace com::sun::star { |
36 | | namespace beans { class XPropertySet; } |
37 | | namespace uno { |
38 | | class Any; |
39 | | class XComponentContext; |
40 | | } |
41 | | } |
42 | | |
43 | | namespace configmgr { |
44 | | |
45 | | class Broadcaster; |
46 | | class Node; |
47 | | class Partial; |
48 | | class RootAccess; |
49 | | |
50 | | class Components { |
51 | | public: |
52 | | static Components & getSingleton( |
53 | | css::uno::Reference< css::uno::XComponentContext > const & context); |
54 | | |
55 | | static bool allLocales(std::u16string_view locale); |
56 | | |
57 | | rtl::Reference< Node > resolvePathRepresentation( |
58 | | OUString const & pathRepresentation, |
59 | | OUString * canonicRepresentation, std::vector<OUString> * path, int * finalizedLayer) |
60 | | const; |
61 | | |
62 | | rtl::Reference< Node > getTemplate( OUString const & fullName) const; |
63 | | |
64 | | void addRootAccess(rtl::Reference< RootAccess > const & access); |
65 | | |
66 | | void removeRootAccess(RootAccess * access); |
67 | | |
68 | | void initGlobalBroadcaster( |
69 | | Modifications const & modifications, |
70 | | rtl::Reference< RootAccess > const & exclude, |
71 | | Broadcaster * broadcaster); |
72 | | |
73 | | void addModification(std::vector<OUString> const & path); |
74 | | |
75 | | void writeModifications(); |
76 | | |
77 | | void flushModifications(); |
78 | | // must be called with configmgr::lock unacquired; must be called before |
79 | | // shutdown if writeModifications has ever been called (probably |
80 | | // indirectly, via removeExtensionXcuFile) |
81 | | |
82 | | void insertExtensionXcsFile(bool shared, OUString const & fileUri); |
83 | | |
84 | | void insertExtensionXcuFile( |
85 | | bool shared, OUString const & fileUri, |
86 | | Modifications * modifications); |
87 | | |
88 | | void removeExtensionXcuFile( |
89 | | OUString const & fileUri, Modifications * modifications); |
90 | | |
91 | | void insertModificationXcuFile( |
92 | | OUString const & fileUri, |
93 | | css::uno::Sequence< OUString > const & includedPaths, |
94 | | css::uno::Sequence< OUString > const & excludedPaths, |
95 | | Modifications * modifications); |
96 | | |
97 | | css::beans::Optional< css::uno::Any > |
98 | | getExternalValue(std::u16string_view descriptor); |
99 | | |
100 | 0 | osl::Mutex & getLock() const { return *lock_; } |
101 | | |
102 | | private: |
103 | | Components(const Components&) = delete; |
104 | | Components& operator=(const Components&) = delete; |
105 | | |
106 | | typedef void FileParser( |
107 | | OUString const &, int, Data &, Partial const *, Modifications *, |
108 | | Additions *); |
109 | | public: |
110 | | explicit Components( |
111 | | css::uno::Reference< css::uno::XComponentContext > const & context); |
112 | | |
113 | | ~Components(); |
114 | | private: |
115 | | |
116 | | void parseFileLeniently( |
117 | | FileParser * parseFile, OUString const & url, int layer, |
118 | | Partial const * partial, Modifications * modifications, |
119 | | Additions * additions); |
120 | | |
121 | | void parseFiles( |
122 | | int layer, OUString const & extension, FileParser * parseFile, |
123 | | OUString const & url, bool recursive); |
124 | | |
125 | | void parseFileList( |
126 | | int layer, FileParser * parseFile, std::u16string_view urls, |
127 | | bool recordAdditions); |
128 | | |
129 | | void parseXcdFiles(int layer, OUString const & url); |
130 | | |
131 | | void parseXcsXcuLayer(int layer, OUString const & url); |
132 | | |
133 | | void parseXcsXcuIniLayer( |
134 | | int layer, OUString const & url, bool recordAdditions); |
135 | | |
136 | | void parseResLayer(int layer, std::u16string_view url); |
137 | | |
138 | | void parseModificationLayer(int layer, OUString const & url); |
139 | | |
140 | | int getExtensionLayer(bool shared) const; |
141 | | |
142 | | typedef |
143 | | config_map< |
144 | | css::uno::Reference< |
145 | | css::beans::XPropertySet > > |
146 | | ExternalServices; |
147 | | |
148 | | class WriteThread; |
149 | | |
150 | | enum class ModificationTarget { None, File, Dconf }; |
151 | | |
152 | | css::uno::Reference< css::uno::XComponentContext > |
153 | | context_; |
154 | | Data data_; |
155 | | o3tl::sorted_vector< RootAccess * > roots_; |
156 | | ExternalServices externalServices_; |
157 | | rtl::Reference< WriteThread > writeThread_; |
158 | | int sharedExtensionLayer_; |
159 | | int userExtensionLayer_; |
160 | | ModificationTarget modificationTarget_; |
161 | | OUString modificationFileUrl_; |
162 | | std::shared_ptr<osl::Mutex> lock_; |
163 | | }; |
164 | | |
165 | | } |
166 | | |
167 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |