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