xref: /trunk/main/configmgr/source/components.hxx (revision a2faadff)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef INCLUDED_CONFIGMGR_SOURCE_COMPONENTS_HXX
25 #define INCLUDED_CONFIGMGR_SOURCE_COMPONENTS_HXX
26 
27 #include "sal/config.h"
28 
29 #include <map>
30 #include <set>
31 
32 #include "boost/noncopyable.hpp"
33 #include "com/sun/star/beans/Optional.hpp"
34 #include "com/sun/star/uno/Reference.hxx"
35 #include "rtl/ref.hxx"
36 
37 #include "additions.hxx"
38 #include "data.hxx"
39 #include "modifications.hxx"
40 #include "nodemap.hxx"
41 #include "path.hxx"
42 
43 namespace com { namespace sun { namespace star {
44     namespace beans { class XPropertySet; }
45     namespace uno {
46         class Any;
47         class XComponentContext;
48     }
49 } } }
50 namespace rtl {
51     class Bootstrap;
52     class OUString;
53 }
54 
55 namespace configmgr {
56 
57 class Broadcaster;
58 class Node;
59 class Partial;
60 class RootAccess;
61 
62 class Components: private boost::noncopyable {
63 public:
64     static Components & getSingleton(
65         com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext >
66             const & context);
67 
68     static bool allLocales(rtl::OUString const & locale);
69 
70     rtl::Reference< Node > resolvePathRepresentation(
71         rtl::OUString const & pathRepresentation,
72         rtl::OUString * canonicRepresenation, Path * path, int * finalizedLayer)
73         const;
74 
75     rtl::Reference< Node > getTemplate(
76         int layer, rtl::OUString const & fullName) const;
77 
78     void addRootAccess(rtl::Reference< RootAccess > const & access);
79 
80     void removeRootAccess(RootAccess * access);
81 
82     void initGlobalBroadcaster(
83         Modifications const & modifications,
84         rtl::Reference< RootAccess > const & exclude,
85         Broadcaster * broadcaster);
86 
87     void addModification(Path const & path);
88 
89     void writeModifications();
90 
91     void flushModifications();
92         // must be called with configmgr::lock unaquired; must be called before
93         // shutdown if writeModifications has ever been called (probably
94         // indirectly, via removeExtensionXcuFile)
95 
96     void insertExtensionXcsFile(bool shared, rtl::OUString const & fileUri);
97 
98     void insertExtensionXcuFile(
99         bool shared, rtl::OUString const & fileUri,
100         Modifications * modifications);
101 
102     void removeExtensionXcuFile(
103         rtl::OUString const & fileUri, Modifications * modifications);
104 
105     void insertModificationXcuFile(
106         rtl::OUString const & fileUri,
107         std::set< rtl::OUString > const & includedPaths,
108         std::set< rtl::OUString > const & excludedPaths,
109         Modifications * modifications);
110 
111     com::sun::star::beans::Optional< com::sun::star::uno::Any >
112     getExternalValue(rtl::OUString const & descriptor);
113 
114 private:
115     typedef void FileParser(
116         rtl::OUString const &, int, Data &, Partial const *, Modifications *,
117         Additions *);
118 
119     Components(
120         com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext >
121             const & context);
122 
123     ~Components();
124 
125     void parseFileLeniently(
126         FileParser * parseFile, rtl::OUString const & url, int layer,
127         Data & data, Partial const * partial, Modifications * modifications,
128         Additions * additions);
129 
130     void parseFiles(
131         int layer, rtl::OUString const & extension, FileParser * parseFile,
132         rtl::OUString const & url, bool recursive);
133 
134     void parseFileList(
135         int layer, FileParser * parseFile, rtl::OUString const & urls,
136         rtl::Bootstrap const & ini, bool recordAdditions);
137 
138     void parseXcdFiles(int layer, rtl::OUString const & url);
139 
140     void parseXcsXcuLayer(int layer, rtl::OUString const & url);
141 
142     void parseXcsXcuIniLayer(
143         int layer, rtl::OUString const & url, bool recordAdditions);
144 
145     void parseModuleLayer(int layer, rtl::OUString const & url);
146 
147     void parseResLayer(int layer, rtl::OUString const & url);
148 
149     rtl::OUString getModificationFileUrl() const;
150 
151     void parseModificationLayer();
152 
153     typedef std::set< RootAccess * > WeakRootSet;
154 
155     typedef
156         std::map<
157             rtl::OUString,
158             com::sun::star::uno::Reference<
159                 com::sun::star::beans::XPropertySet > >
160         ExternalServices;
161 
162     class WriteThread;
163 
164     com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext >
165         context_;
166     Data data_;
167     WeakRootSet roots_;
168     ExternalServices externalServices_;
169     rtl::Reference< WriteThread > writeThread_;
170 };
171 
172 }
173 
174 #endif
175