bump product version to 6.3.0.0.beta1
[LibreOffice.git] / configmgr / source / access.hxx
blob5fc8d183f5be900f556f8a4b59dd2d57273e3905
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 #ifndef INCLUDED_CONFIGMGR_SOURCE_ACCESS_HXX
21 #define INCLUDED_CONFIGMGR_SOURCE_ACCESS_HXX
23 #include <sal/config.h>
25 #include <map>
26 #include <memory>
27 #include <set>
28 #include <vector>
29 #include "config_map.hxx"
31 #include <com/sun/star/beans/PropertyVetoException.hpp>
32 #include <com/sun/star/beans/UnknownPropertyException.hpp>
33 #include <com/sun/star/beans/XExactName.hpp>
34 #include <com/sun/star/beans/XHierarchicalPropertySet.hpp>
35 #include <com/sun/star/beans/XHierarchicalPropertySetInfo.hpp>
36 #include <com/sun/star/beans/XMultiHierarchicalPropertySet.hpp>
37 #include <com/sun/star/beans/XMultiPropertySet.hpp>
38 #include <com/sun/star/beans/XProperty.hpp>
39 #include <com/sun/star/beans/XPropertySet.hpp>
40 #include <com/sun/star/beans/XPropertySetInfo.hpp>
41 #include <com/sun/star/container/ElementExistException.hpp>
42 #include <com/sun/star/container/NoSuchElementException.hpp>
43 #include <com/sun/star/container/XContainer.hpp>
44 #include <com/sun/star/container/XHierarchicalName.hpp>
45 #include <com/sun/star/container/XHierarchicalNameReplace.hpp>
46 #include <com/sun/star/container/XNameContainer.hpp>
47 #include <com/sun/star/container/XNamed.hpp>
48 #include <com/sun/star/lang/IllegalArgumentException.hpp>
49 #include <com/sun/star/lang/NoSupportException.hpp>
50 #include <com/sun/star/lang/WrappedTargetException.hpp>
51 #include <com/sun/star/lang/XComponent.hpp>
52 #include <com/sun/star/lang/XServiceInfo.hpp>
53 #include <com/sun/star/lang/XTypeProvider.hpp>
54 #include <com/sun/star/lang/XSingleServiceFactory.hpp>
55 #include <com/sun/star/uno/Exception.hpp>
56 #include <com/sun/star/uno/Reference.hxx>
57 #include <com/sun/star/uno/RuntimeException.hpp>
58 #include <com/sun/star/uno/Sequence.hxx>
59 #include <cppuhelper/weak.hxx>
60 #include <osl/interlck.h>
61 #include <rtl/ref.hxx>
62 #include <sal/types.h>
64 #include "modifications.hxx"
65 #include "type.hxx"
67 namespace com { namespace sun { namespace star {
68 namespace beans {
69 class XHierarchicalPropertySetInfo;
70 class XPropertiesChangeListener;
71 class XPropertyChangeListener;
72 class XVetoableChangeListener;
73 struct Property;
75 namespace container { class XContainerListener; }
76 namespace lang { class XEventListener; }
77 namespace uno {
78 class Any;
79 class Type;
80 class XInterface;
82 namespace util { struct ElementChange; }
83 } } }
85 namespace configmgr {
87 class Broadcaster;
88 class ChildAccess;
89 class Components;
90 class Node;
91 class RootAccess;
93 class Access:
94 public cppu::OWeakObject, public css::lang::XTypeProvider,
95 public css::lang::XServiceInfo,
96 public css::lang::XComponent,
97 public css::container::XHierarchicalNameReplace,
98 public css::container::XContainer,
99 public css::beans::XExactName,
100 public css::beans::XPropertySetInfo,
101 public css::container::XHierarchicalName,
102 public css::container::XNamed,
103 public css::beans::XProperty,
104 public css::beans::XPropertySet,
105 public css::beans::XMultiPropertySet,
106 public css::beans::XHierarchicalPropertySet,
107 public css::beans::XMultiHierarchicalPropertySet,
108 public css::beans::XHierarchicalPropertySetInfo,
109 public css::container::XNameContainer,
110 public css::lang::XSingleServiceFactory
112 public:
113 oslInterlockedCount acquireCounting();
115 void releaseNondeleting();
117 bool isValue();
119 void markChildAsModified(rtl::Reference< ChildAccess > const & child);
120 void releaseChild(OUString const & name);
122 virtual std::vector<OUString> getAbsolutePath() = 0;
123 virtual std::vector<OUString> getRelativePath() = 0;
125 virtual OUString getRelativePathRepresentation() = 0;
126 virtual rtl::Reference< Node > getNode() = 0;
128 virtual bool isFinalized() = 0;
130 virtual void initBroadcaster(
131 Modifications::Node const & modifications, Broadcaster * broadcaster);
133 using OWeakObject::acquire;
134 using OWeakObject::release;
136 virtual css::uno::Sequence< css::uno::Type > SAL_CALL
137 getTypes() override;
139 virtual css::uno::Sequence< sal_Int8 > SAL_CALL
140 getImplementationId() override;
142 virtual OUString SAL_CALL getImplementationName() override;
144 virtual sal_Bool SAL_CALL supportsService(OUString const & ServiceName) override;
146 virtual css::uno::Sequence< OUString > SAL_CALL
147 getSupportedServiceNames() override;
149 virtual void SAL_CALL dispose() override;
151 virtual void SAL_CALL addEventListener(
152 css::uno::Reference< css::lang::XEventListener >
153 const & xListener) override;
155 virtual void SAL_CALL removeEventListener(
156 css::uno::Reference< css::lang::XEventListener >
157 const & aListener) override;
159 virtual css::uno::Type SAL_CALL getElementType() override;
161 virtual sal_Bool SAL_CALL hasElements() override;
163 virtual css::uno::Any SAL_CALL getByName(
164 OUString const & aName) override;
166 virtual css::uno::Sequence< OUString > SAL_CALL
167 getElementNames() override;
169 virtual sal_Bool SAL_CALL hasByName(OUString const & aName) override;
171 virtual css::uno::Any SAL_CALL getByHierarchicalName(
172 OUString const & aName) override;
174 virtual sal_Bool SAL_CALL hasByHierarchicalName(OUString const & aName) override;
176 virtual void SAL_CALL replaceByHierarchicalName(
177 OUString const & aName, css::uno::Any const & aElement) override;
179 virtual void SAL_CALL addContainerListener(
180 css::uno::Reference<
181 css::container::XContainerListener > const & xListener) override;
183 virtual void SAL_CALL removeContainerListener(
184 css::uno::Reference<
185 css::container::XContainerListener > const & xListener) override;
187 virtual OUString SAL_CALL getExactName(
188 OUString const & aApproximateName) override;
190 virtual css::uno::Sequence< css::beans::Property >
191 SAL_CALL getProperties() override;
193 virtual css::beans::Property SAL_CALL getPropertyByName(
194 OUString const & aName) override;
196 virtual sal_Bool SAL_CALL hasPropertyByName(OUString const & Name) override;
198 virtual OUString SAL_CALL getHierarchicalName() override;
200 virtual OUString SAL_CALL composeHierarchicalName(
201 OUString const & aRelativeName) override;
203 virtual OUString SAL_CALL getName() override;
205 virtual void SAL_CALL setName(OUString const & aName) override;
207 virtual css::beans::Property SAL_CALL getAsProperty() override;
209 virtual
210 css::uno::Reference< css::beans::XPropertySetInfo >
211 SAL_CALL getPropertySetInfo() override;
213 virtual void SAL_CALL setPropertyValue(
214 OUString const & aPropertyName,
215 css::uno::Any const & aValue) override;
217 virtual css::uno::Any SAL_CALL getPropertyValue(
218 OUString const & PropertyName) override;
220 virtual void SAL_CALL addPropertyChangeListener(
221 OUString const & aPropertyName,
222 css::uno::Reference<
223 css::beans::XPropertyChangeListener > const & xListener) override;
225 virtual void SAL_CALL removePropertyChangeListener(
226 OUString const & aPropertyName,
227 css::uno::Reference<
228 css::beans::XPropertyChangeListener > const & aListener) override;
230 virtual void SAL_CALL addVetoableChangeListener(
231 OUString const & PropertyName,
232 css::uno::Reference<
233 css::beans::XVetoableChangeListener > const & aListener) override;
235 virtual void SAL_CALL removeVetoableChangeListener(
236 OUString const & PropertyName,
237 css::uno::Reference<
238 css::beans::XVetoableChangeListener > const & aListener) override;
240 virtual void SAL_CALL setPropertyValues(
241 css::uno::Sequence< OUString > const & aPropertyNames,
242 css::uno::Sequence< css::uno::Any > const &
243 aValues) override;
245 virtual css::uno::Sequence< css::uno::Any > SAL_CALL
246 getPropertyValues(
247 css::uno::Sequence< OUString > const & aPropertyNames) override;
249 virtual void SAL_CALL addPropertiesChangeListener(
250 css::uno::Sequence< OUString > const & aPropertyNames,
251 css::uno::Reference<
252 css::beans::XPropertiesChangeListener > const &
253 xListener) override;
255 virtual void SAL_CALL removePropertiesChangeListener(
256 css::uno::Reference<
257 css::beans::XPropertiesChangeListener > const &
258 xListener) override;
260 virtual void SAL_CALL firePropertiesChangeEvent(
261 css::uno::Sequence< OUString > const & aPropertyNames,
262 css::uno::Reference<
263 css::beans::XPropertiesChangeListener > const &
264 xListener) override;
266 virtual
267 css::uno::Reference<
268 css::beans::XHierarchicalPropertySetInfo > SAL_CALL
269 getHierarchicalPropertySetInfo() override;
271 virtual void SAL_CALL setHierarchicalPropertyValue(
272 OUString const & aHierarchicalPropertyName,
273 css::uno::Any const & aValue) override;
275 virtual css::uno::Any SAL_CALL getHierarchicalPropertyValue(
276 OUString const & aHierarchicalPropertyName) override;
278 virtual void SAL_CALL setHierarchicalPropertyValues(
279 css::uno::Sequence< OUString > const &
280 aHierarchicalPropertyNames,
281 css::uno::Sequence< css::uno::Any > const &
282 Values) override;
284 virtual css::uno::Sequence< css::uno::Any > SAL_CALL
285 getHierarchicalPropertyValues(
286 css::uno::Sequence< OUString > const &
287 aHierarchicalPropertyNames) override;
289 virtual css::beans::Property SAL_CALL
290 getPropertyByHierarchicalName(OUString const & aHierarchicalName) override;
292 virtual sal_Bool SAL_CALL hasPropertyByHierarchicalName(
293 OUString const & aHierarchicalName) override;
295 virtual void SAL_CALL replaceByName(
296 OUString const & aName, css::uno::Any const & aElement) override;
298 virtual void SAL_CALL insertByName(
299 OUString const & aName, css::uno::Any const & aElement) override;
301 virtual void SAL_CALL removeByName(OUString const & aName) override;
303 virtual css::uno::Reference< css::uno::XInterface >
304 SAL_CALL createInstance() override;
306 virtual css::uno::Reference< css::uno::XInterface >
307 SAL_CALL createInstanceWithArguments(
308 css::uno::Sequence< css::uno::Any > const &
309 aArguments) override;
311 protected:
312 explicit Access(Components & components);
314 virtual ~Access() override;
316 virtual OUString getNameInternal() = 0;
317 virtual rtl::Reference< RootAccess > getRootAccess() = 0;
318 virtual rtl::Reference< Access > getParentAccess() = 0;
320 virtual void addTypes(std::vector< css::uno::Type > * types)
321 const = 0;
323 virtual void addSupportedServiceNames(
324 std::vector<OUString> * services) = 0;
326 virtual void initDisposeBroadcaster(Broadcaster * broadcaster);
327 virtual void clearListeners() throw ();
329 virtual css::uno::Any SAL_CALL queryInterface(
330 css::uno::Type const & aType) override;
332 Components & getComponents() const { return components_;}
334 void checkLocalizedPropertyAccess();
336 rtl::Reference< Node > getParentNode();
337 rtl::Reference< ChildAccess > getChild(OUString const & name);
338 std::vector< rtl::Reference< ChildAccess > > getAllChildren();
340 void checkValue(
341 css::uno::Any const & value, Type type, bool nillable);
343 void insertLocalizedValueChild(
344 OUString const & name, css::uno::Any const & value,
345 Modifications * localModifications);
347 void reportChildChanges(
348 std::vector< css::util::ElementChange > * changes);
350 void commitChildChanges(bool valid, Modifications * globalModifications);
352 void initBroadcasterAndChanges(
353 Modifications::Node const & modifications, Broadcaster * broadcaster,
354 std::vector< css::util::ElementChange > * changes);
356 bool isDisposed() const { return disposed_;}
358 private:
359 Access(const Access&) = delete;
360 Access& operator=(const Access&) = delete;
362 struct ModifiedChild {
363 rtl::Reference< ChildAccess > child;
364 bool directlyModified;
366 ModifiedChild();
368 ModifiedChild(
369 rtl::Reference< ChildAccess > const & theChild,
370 bool theDirectlyModified);
373 typedef config_map< ModifiedChild > ModifiedChildren;
375 rtl::Reference< ChildAccess > getModifiedChild(
376 ModifiedChildren::iterator const & childIterator);
378 rtl::Reference< ChildAccess > getUnmodifiedChild(
379 OUString const & name);
381 rtl::Reference< ChildAccess > getSubChild(OUString const & path);
383 bool setChildProperty(
384 OUString const & name, css::uno::Any const & value,
385 Modifications * localModifications);
387 css::beans::Property asProperty();
389 bool getByNameFast(const OUString & name, css::uno::Any & value);
390 rtl::Reference< ChildAccess > createUnmodifiedChild(const OUString &name,
391 const rtl::Reference< Node > &node);
393 void checkFinalized();
395 void checkKnownProperty(OUString const & descriptor);
397 rtl::Reference< ChildAccess > getFreeSetMember( css::uno::Any const & value);
399 rtl::Reference< Access > getNotificationRoot();
401 typedef config_map< ChildAccess * > WeakChildMap;
403 typedef
404 std::multiset<
405 css::uno::Reference<
406 css::lang::XEventListener > >
407 DisposeListeners;
409 typedef
410 std::multiset<
411 css::uno::Reference<
412 css::container::XContainerListener > >
413 ContainerListeners;
415 typedef
416 std::multiset<
417 css::uno::Reference<
418 css::beans::XPropertyChangeListener > >
419 PropertyChangeListenersElement;
421 typedef config_map< PropertyChangeListenersElement >
422 PropertyChangeListeners;
424 typedef
425 std::multiset<
426 css::uno::Reference<
427 css::beans::XVetoableChangeListener > >
428 VetoableChangeListenersElement;
430 typedef config_map< VetoableChangeListenersElement >
431 VetoableChangeListeners;
433 typedef
434 std::multiset<
435 css::uno::Reference<
436 css::beans::XPropertiesChangeListener > >
437 PropertiesChangeListeners;
439 Components & components_;
440 ModifiedChildren modifiedChildren_;
441 WeakChildMap cachedChildren_;
442 DisposeListeners disposeListeners_;
443 ContainerListeners containerListeners_;
444 PropertyChangeListeners propertyChangeListeners_;
445 VetoableChangeListeners vetoableChangeListeners_;
446 PropertiesChangeListeners propertiesChangeListeners_;
447 bool disposed_;
449 std::shared_ptr<osl::Mutex> lock_;
451 #if !defined NDEBUG
452 protected:
453 enum {
454 IS_ANY = 0, IS_GROUP = 0x01, IS_SET = 0x02, IS_EXTENSIBLE = 0x04,
455 IS_GROUP_MEMBER = 0x08, IS_SET_MEMBER = 0x10, IS_UPDATE = 0x20 };
456 bool thisIs(int what);
457 #endif
462 #endif
464 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */