xref: /trunk/main/configmgr/source/components.hxx (revision cdf0e10c)
1 /*************************************************************************
2 *
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
6 *
7 * OpenOffice.org - a multi-platform office productivity suite
8 *
9 * This file is part of OpenOffice.org.
10 *
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
14 *
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
20 *
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org.  If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
25 *
26 ************************************************************************/
27 
28 #ifndef INCLUDED_CONFIGMGR_SOURCE_COMPONENTS_HXX
29 #define INCLUDED_CONFIGMGR_SOURCE_COMPONENTS_HXX
30 
31 #include "sal/config.h"
32 
33 #include <map>
34 #include <set>
35 
36 #include "boost/noncopyable.hpp"
37 #include "com/sun/star/beans/Optional.hpp"
38 #include "com/sun/star/uno/Reference.hxx"
39 #include "rtl/ref.hxx"
40 
41 #include "additions.hxx"
42 #include "data.hxx"
43 #include "modifications.hxx"
44 #include "nodemap.hxx"
45 #include "path.hxx"
46 
47 namespace com { namespace sun { namespace star {
48     namespace beans { class XPropertySet; }
49     namespace uno {
50         class Any;
51         class XComponentContext;
52     }
53 } } }
54 namespace rtl {
55     class Bootstrap;
56     class OUString;
57 }
58 
59 namespace configmgr {
60 
61 class Broadcaster;
62 class Node;
63 class Partial;
64 class RootAccess;
65 
66 class Components: private boost::noncopyable {
67 public:
68     static Components & getSingleton(
69         com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext >
70             const & context);
71 
72     static bool allLocales(rtl::OUString const & locale);
73 
74     rtl::Reference< Node > resolvePathRepresentation(
75         rtl::OUString const & pathRepresentation,
76         rtl::OUString * canonicRepresenation, Path * path, int * finalizedLayer)
77         const;
78 
79     rtl::Reference< Node > getTemplate(
80         int layer, rtl::OUString const & fullName) const;
81 
82     void addRootAccess(rtl::Reference< RootAccess > const & access);
83 
84     void removeRootAccess(RootAccess * access);
85 
86     void initGlobalBroadcaster(
87         Modifications const & modifications,
88         rtl::Reference< RootAccess > const & exclude,
89         Broadcaster * broadcaster);
90 
91     void addModification(Path const & path);
92 
93     void writeModifications();
94 
95     void flushModifications();
96         // must be called with configmgr::lock unaquired; must be called before
97         // shutdown if writeModifications has ever been called (probably
98         // indirectly, via removeExtensionXcuFile)
99 
100     void insertExtensionXcsFile(bool shared, rtl::OUString const & fileUri);
101 
102     void insertExtensionXcuFile(
103         bool shared, rtl::OUString const & fileUri,
104         Modifications * modifications);
105 
106     void removeExtensionXcuFile(
107         rtl::OUString const & fileUri, Modifications * modifications);
108 
109     void insertModificationXcuFile(
110         rtl::OUString const & fileUri,
111         std::set< rtl::OUString > const & includedPaths,
112         std::set< rtl::OUString > const & excludedPaths,
113         Modifications * modifications);
114 
115     com::sun::star::beans::Optional< com::sun::star::uno::Any >
116     getExternalValue(rtl::OUString const & descriptor);
117 
118 private:
119     typedef void FileParser(
120         rtl::OUString const &, int, Data &, Partial const *, Modifications *,
121         Additions *);
122 
123     Components(
124         com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext >
125             const & context);
126 
127     ~Components();
128 
129     void parseFileLeniently(
130         FileParser * parseFile, rtl::OUString const & url, int layer,
131         Data & data, Partial const * partial, Modifications * modifications,
132         Additions * additions);
133 
134     void parseFiles(
135         int layer, rtl::OUString const & extension, FileParser * parseFile,
136         rtl::OUString const & url, bool recursive);
137 
138     void parseFileList(
139         int layer, FileParser * parseFile, rtl::OUString const & urls,
140         rtl::Bootstrap const & ini, bool recordAdditions);
141 
142     void parseXcdFiles(int layer, rtl::OUString const & url);
143 
144     void parseXcsXcuLayer(int layer, rtl::OUString const & url);
145 
146     void parseXcsXcuIniLayer(
147         int layer, rtl::OUString const & url, bool recordAdditions);
148 
149     void parseModuleLayer(int layer, rtl::OUString const & url);
150 
151     void parseResLayer(int layer, rtl::OUString const & url);
152 
153     rtl::OUString getModificationFileUrl() const;
154 
155     void parseModificationLayer();
156 
157     typedef std::set< RootAccess * > WeakRootSet;
158 
159     typedef
160         std::map<
161             rtl::OUString,
162             com::sun::star::uno::Reference<
163                 com::sun::star::beans::XPropertySet > >
164         ExternalServices;
165 
166     class WriteThread;
167 
168     com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext >
169         context_;
170     Data data_;
171     WeakRootSet roots_;
172     ExternalServices externalServices_;
173     rtl::Reference< WriteThread > writeThread_;
174 };
175 
176 }
177 
178 #endif
179