Bump version to 4.1-6
[LibreOffice.git] / configmgr / source / access.hxx
blob6703568fbd5779ff77e10705bc32949bd9f6484e
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 <set>
27 #include <vector>
29 #include "boost/noncopyable.hpp"
30 #include "boost/shared_ptr.hpp"
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 "path.hxx"
66 #include "type.hxx"
68 namespace com { namespace sun { namespace star {
69 namespace beans {
70 class XHierarchicalPropertySetInfo;
71 class XPropertiesChangeListener;
72 class XPropertyChangeListener;
73 class XVetoableChangeListener;
74 struct Property;
76 namespace container { class XContainerListener; }
77 namespace lang { class XEventListener; }
78 namespace uno {
79 class Any;
80 class Type;
81 class XInterface;
83 namespace util { struct ElementChange; }
84 } } }
86 namespace configmgr {
88 class Broadcaster;
89 class ChildAccess;
90 class Components;
91 class Node;
92 class RootAccess;
94 class Access:
95 public cppu::OWeakObject, public com::sun::star::lang::XTypeProvider,
96 public com::sun::star::lang::XServiceInfo,
97 public com::sun::star::lang::XComponent,
98 public com::sun::star::container::XHierarchicalNameReplace,
99 public com::sun::star::container::XContainer,
100 public com::sun::star::beans::XExactName,
101 public com::sun::star::beans::XPropertySetInfo,
102 public com::sun::star::container::XHierarchicalName,
103 public com::sun::star::container::XNamed,
104 public com::sun::star::beans::XProperty,
105 public com::sun::star::beans::XPropertySet,
106 public com::sun::star::beans::XMultiPropertySet,
107 public com::sun::star::beans::XHierarchicalPropertySet,
108 public com::sun::star::beans::XMultiHierarchicalPropertySet,
109 public com::sun::star::beans::XHierarchicalPropertySetInfo,
110 public com::sun::star::container::XNameContainer,
111 public com::sun::star::lang::XSingleServiceFactory,
112 private boost::noncopyable
114 public:
115 oslInterlockedCount acquireCounting();
117 void releaseNondeleting();
119 bool isValue();
121 void markChildAsModified(rtl::Reference< ChildAccess > const & child);
122 void releaseChild(OUString const & name);
124 virtual Path getAbsolutePath() = 0;
125 virtual Path getRelativePath() = 0;
127 virtual OUString getRelativePathRepresentation() = 0;
128 virtual rtl::Reference< Node > getNode() = 0;
130 virtual bool isFinalized() = 0;
132 virtual void initBroadcaster(
133 Modifications::Node const & modifications, Broadcaster * broadcaster);
135 using OWeakObject::acquire;
136 using OWeakObject::release;
138 virtual com::sun::star::uno::Sequence< com::sun::star::uno::Type > SAL_CALL
139 getTypes() throw (com::sun::star::uno::RuntimeException);
141 virtual com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL
142 getImplementationId() throw (com::sun::star::uno::RuntimeException);
144 virtual OUString SAL_CALL getImplementationName()
145 throw (com::sun::star::uno::RuntimeException);
147 virtual sal_Bool SAL_CALL supportsService(OUString const & ServiceName)
148 throw (com::sun::star::uno::RuntimeException);
150 virtual com::sun::star::uno::Sequence< OUString > SAL_CALL
151 getSupportedServiceNames() throw (com::sun::star::uno::RuntimeException);
153 virtual void SAL_CALL dispose()
154 throw (com::sun::star::uno::RuntimeException);
156 virtual void SAL_CALL addEventListener(
157 com::sun::star::uno::Reference< com::sun::star::lang::XEventListener >
158 const & xListener)
159 throw (com::sun::star::uno::RuntimeException);
161 virtual void SAL_CALL removeEventListener(
162 com::sun::star::uno::Reference< com::sun::star::lang::XEventListener >
163 const & aListener)
164 throw (com::sun::star::uno::RuntimeException);
166 virtual com::sun::star::uno::Type SAL_CALL getElementType()
167 throw (com::sun::star::uno::RuntimeException);
169 virtual sal_Bool SAL_CALL hasElements()
170 throw (com::sun::star::uno::RuntimeException);
172 virtual com::sun::star::uno::Any SAL_CALL getByName(
173 OUString const & aName)
174 throw (
175 com::sun::star::container::NoSuchElementException,
176 com::sun::star::lang::WrappedTargetException,
177 com::sun::star::uno::RuntimeException);
179 virtual com::sun::star::uno::Sequence< OUString > SAL_CALL
180 getElementNames() throw (com::sun::star::uno::RuntimeException);
182 virtual sal_Bool SAL_CALL hasByName(OUString const & aName)
183 throw (com::sun::star::uno::RuntimeException);
185 virtual com::sun::star::uno::Any SAL_CALL getByHierarchicalName(
186 OUString const & aName)
187 throw (
188 com::sun::star::container::NoSuchElementException,
189 com::sun::star::uno::RuntimeException);
191 virtual sal_Bool SAL_CALL hasByHierarchicalName(OUString const & aName)
192 throw (com::sun::star::uno::RuntimeException);
194 virtual void SAL_CALL replaceByHierarchicalName(
195 OUString const & aName, com::sun::star::uno::Any const & aElement)
196 throw (
197 com::sun::star::lang::IllegalArgumentException,
198 com::sun::star::container::NoSuchElementException,
199 com::sun::star::lang::WrappedTargetException,
200 com::sun::star::uno::RuntimeException);
202 virtual void SAL_CALL addContainerListener(
203 com::sun::star::uno::Reference<
204 com::sun::star::container::XContainerListener > const & xListener)
205 throw (com::sun::star::uno::RuntimeException);
207 virtual void SAL_CALL removeContainerListener(
208 com::sun::star::uno::Reference<
209 com::sun::star::container::XContainerListener > const & xListener)
210 throw (com::sun::star::uno::RuntimeException);
212 virtual OUString SAL_CALL getExactName(
213 OUString const & aApproximateName)
214 throw (com::sun::star::uno::RuntimeException);
216 virtual com::sun::star::uno::Sequence< com::sun::star::beans::Property >
217 SAL_CALL getProperties() throw (com::sun::star::uno::RuntimeException);
219 virtual com::sun::star::beans::Property SAL_CALL getPropertyByName(
220 OUString const & aName)
221 throw (
222 com::sun::star::beans::UnknownPropertyException,
223 com::sun::star::uno::RuntimeException);
225 virtual sal_Bool SAL_CALL hasPropertyByName(OUString const & Name)
226 throw (com::sun::star::uno::RuntimeException);
228 virtual OUString SAL_CALL getHierarchicalName()
229 throw (com::sun::star::uno::RuntimeException);
231 virtual OUString SAL_CALL composeHierarchicalName(
232 OUString const & aRelativeName)
233 throw (
234 com::sun::star::lang::IllegalArgumentException,
235 com::sun::star::lang::NoSupportException,
236 com::sun::star::uno::RuntimeException);
238 virtual OUString SAL_CALL getName()
239 throw (com::sun::star::uno::RuntimeException);
241 virtual void SAL_CALL setName(OUString const & aName)
242 throw (com::sun::star::uno::RuntimeException);
244 virtual com::sun::star::beans::Property SAL_CALL getAsProperty()
245 throw (com::sun::star::uno::RuntimeException);
247 virtual
248 com::sun::star::uno::Reference< com::sun::star::beans::XPropertySetInfo >
249 SAL_CALL getPropertySetInfo() throw (com::sun::star::uno::RuntimeException);
251 virtual void SAL_CALL setPropertyValue(
252 OUString const & aPropertyName,
253 com::sun::star::uno::Any const & aValue)
254 throw (
255 com::sun::star::beans::UnknownPropertyException,
256 com::sun::star::beans::PropertyVetoException,
257 com::sun::star::lang::IllegalArgumentException,
258 com::sun::star::lang::WrappedTargetException,
259 com::sun::star::uno::RuntimeException);
261 virtual com::sun::star::uno::Any SAL_CALL getPropertyValue(
262 OUString const & PropertyName)
263 throw (
264 com::sun::star::beans::UnknownPropertyException,
265 com::sun::star::lang::WrappedTargetException,
266 com::sun::star::uno::RuntimeException);
268 virtual void SAL_CALL addPropertyChangeListener(
269 OUString const & aPropertyName,
270 com::sun::star::uno::Reference<
271 com::sun::star::beans::XPropertyChangeListener > const & xListener)
272 throw (
273 com::sun::star::beans::UnknownPropertyException,
274 com::sun::star::lang::WrappedTargetException,
275 com::sun::star::uno::RuntimeException);
277 virtual void SAL_CALL removePropertyChangeListener(
278 OUString const & aPropertyName,
279 com::sun::star::uno::Reference<
280 com::sun::star::beans::XPropertyChangeListener > const & aListener)
281 throw (
282 com::sun::star::beans::UnknownPropertyException,
283 com::sun::star::lang::WrappedTargetException,
284 com::sun::star::uno::RuntimeException);
286 virtual void SAL_CALL addVetoableChangeListener(
287 OUString const & PropertyName,
288 com::sun::star::uno::Reference<
289 com::sun::star::beans::XVetoableChangeListener > const & aListener)
290 throw (
291 com::sun::star::beans::UnknownPropertyException,
292 com::sun::star::lang::WrappedTargetException,
293 com::sun::star::uno::RuntimeException);
295 virtual void SAL_CALL removeVetoableChangeListener(
296 OUString const & PropertyName,
297 com::sun::star::uno::Reference<
298 com::sun::star::beans::XVetoableChangeListener > const & aListener)
299 throw (
300 com::sun::star::beans::UnknownPropertyException,
301 com::sun::star::lang::WrappedTargetException,
302 com::sun::star::uno::RuntimeException);
304 virtual void SAL_CALL setPropertyValues(
305 com::sun::star::uno::Sequence< OUString > const & aPropertyNames,
306 com::sun::star::uno::Sequence< com::sun::star::uno::Any > const &
307 aValues)
308 throw (
309 com::sun::star::beans::PropertyVetoException,
310 com::sun::star::lang::IllegalArgumentException,
311 com::sun::star::lang::WrappedTargetException,
312 com::sun::star::uno::RuntimeException);
314 virtual com::sun::star::uno::Sequence< com::sun::star::uno::Any > SAL_CALL
315 getPropertyValues(
316 com::sun::star::uno::Sequence< OUString > const & aPropertyNames)
317 throw (com::sun::star::uno::RuntimeException);
319 virtual void SAL_CALL addPropertiesChangeListener(
320 com::sun::star::uno::Sequence< OUString > const & aPropertyNames,
321 com::sun::star::uno::Reference<
322 com::sun::star::beans::XPropertiesChangeListener > const &
323 xListener)
324 throw (com::sun::star::uno::RuntimeException);
326 virtual void SAL_CALL removePropertiesChangeListener(
327 com::sun::star::uno::Reference<
328 com::sun::star::beans::XPropertiesChangeListener > const &
329 xListener)
330 throw (com::sun::star::uno::RuntimeException);
332 virtual void SAL_CALL firePropertiesChangeEvent(
333 com::sun::star::uno::Sequence< OUString > const & aPropertyNames,
334 com::sun::star::uno::Reference<
335 com::sun::star::beans::XPropertiesChangeListener > const &
336 xListener)
337 throw (com::sun::star::uno::RuntimeException);
339 virtual
340 com::sun::star::uno::Reference<
341 com::sun::star::beans::XHierarchicalPropertySetInfo > SAL_CALL
342 getHierarchicalPropertySetInfo()
343 throw (com::sun::star::uno::RuntimeException);
345 virtual void SAL_CALL setHierarchicalPropertyValue(
346 OUString const & aHierarchicalPropertyName,
347 com::sun::star::uno::Any const & aValue)
348 throw (
349 com::sun::star::beans::UnknownPropertyException,
350 com::sun::star::beans::PropertyVetoException,
351 com::sun::star::lang::IllegalArgumentException,
352 com::sun::star::lang::WrappedTargetException,
353 com::sun::star::uno::RuntimeException);
355 virtual com::sun::star::uno::Any SAL_CALL getHierarchicalPropertyValue(
356 OUString const & aHierarchicalPropertyName)
357 throw (
358 com::sun::star::beans::UnknownPropertyException,
359 com::sun::star::lang::IllegalArgumentException,
360 com::sun::star::lang::WrappedTargetException,
361 com::sun::star::uno::RuntimeException);
363 virtual void SAL_CALL setHierarchicalPropertyValues(
364 com::sun::star::uno::Sequence< OUString > const &
365 aHierarchicalPropertyNames,
366 com::sun::star::uno::Sequence< com::sun::star::uno::Any > const &
367 Values)
368 throw (
369 com::sun::star::beans::PropertyVetoException,
370 com::sun::star::lang::IllegalArgumentException,
371 com::sun::star::lang::WrappedTargetException,
372 com::sun::star::uno::RuntimeException);
374 virtual com::sun::star::uno::Sequence< com::sun::star::uno::Any > SAL_CALL
375 getHierarchicalPropertyValues(
376 com::sun::star::uno::Sequence< OUString > const &
377 aHierarchicalPropertyNames)
378 throw (
379 com::sun::star::lang::IllegalArgumentException,
380 com::sun::star::lang::WrappedTargetException,
381 com::sun::star::uno::RuntimeException);
383 virtual com::sun::star::beans::Property SAL_CALL
384 getPropertyByHierarchicalName(OUString const & aHierarchicalName)
385 throw (
386 com::sun::star::beans::UnknownPropertyException,
387 com::sun::star::uno::RuntimeException);
389 virtual sal_Bool SAL_CALL hasPropertyByHierarchicalName(
390 OUString const & aHierarchicalName)
391 throw (com::sun::star::uno::RuntimeException);
393 virtual void SAL_CALL replaceByName(
394 OUString const & aName, com::sun::star::uno::Any const & aElement)
395 throw (
396 com::sun::star::lang::IllegalArgumentException,
397 com::sun::star::container::NoSuchElementException,
398 com::sun::star::lang::WrappedTargetException,
399 com::sun::star::uno::RuntimeException);
401 virtual void SAL_CALL insertByName(
402 OUString const & aName, com::sun::star::uno::Any const & aElement)
403 throw (
404 com::sun::star::lang::IllegalArgumentException,
405 com::sun::star::container::ElementExistException,
406 com::sun::star::lang::WrappedTargetException,
407 com::sun::star::uno::RuntimeException);
409 virtual void SAL_CALL removeByName(OUString const & aName)
410 throw (
411 com::sun::star::container::NoSuchElementException,
412 com::sun::star::lang::WrappedTargetException,
413 com::sun::star::uno::RuntimeException);
415 virtual com::sun::star::uno::Reference< com::sun::star::uno::XInterface >
416 SAL_CALL createInstance()
417 throw (
418 com::sun::star::uno::Exception,
419 com::sun::star::uno::RuntimeException);
421 virtual com::sun::star::uno::Reference< com::sun::star::uno::XInterface >
422 SAL_CALL createInstanceWithArguments(
423 com::sun::star::uno::Sequence< com::sun::star::uno::Any > const &
424 aArguments)
425 throw (
426 com::sun::star::uno::Exception,
427 com::sun::star::uno::RuntimeException);
429 protected:
430 Access(Components & components);
432 virtual ~Access();
434 virtual OUString getNameInternal() = 0;
435 virtual rtl::Reference< RootAccess > getRootAccess() = 0;
436 virtual rtl::Reference< Access > getParentAccess() = 0;
438 virtual void addTypes(std::vector< com::sun::star::uno::Type > * types)
439 const = 0;
441 virtual void addSupportedServiceNames(
442 std::vector< OUString > * services) = 0;
444 virtual void initDisposeBroadcaster(Broadcaster * broadcaster);
445 virtual void clearListeners() throw ();
447 virtual com::sun::star::uno::Any SAL_CALL queryInterface(
448 com::sun::star::uno::Type const & aType)
449 throw (com::sun::star::uno::RuntimeException);
451 Components & getComponents() const;
453 void checkLocalizedPropertyAccess();
455 rtl::Reference< Node > getParentNode();
456 rtl::Reference< ChildAccess > getChild(OUString const & name);
457 std::vector< rtl::Reference< ChildAccess > > getAllChildren();
459 void checkValue(
460 com::sun::star::uno::Any const & value, Type type, bool nillable);
462 void insertLocalizedValueChild(
463 OUString const & name, com::sun::star::uno::Any const & value,
464 Modifications * localModifications);
466 void reportChildChanges(
467 std::vector< com::sun::star::util::ElementChange > * changes);
469 void commitChildChanges(bool valid, Modifications * globalModifications);
471 void initBroadcasterAndChanges(
472 Modifications::Node const & modifications, Broadcaster * broadcaster,
473 std::vector< com::sun::star::util::ElementChange > * changes);
475 bool isDisposed() const;
477 private:
478 struct ModifiedChild {
479 rtl::Reference< ChildAccess > child;
480 bool directlyModified;
482 ModifiedChild();
484 ModifiedChild(
485 rtl::Reference< ChildAccess > const & theChild,
486 bool theDirectlyModified);
489 typedef std::map< OUString, ModifiedChild > ModifiedChildren;
491 rtl::Reference< ChildAccess > getModifiedChild(
492 ModifiedChildren::iterator const & childIterator);
494 rtl::Reference< ChildAccess > getUnmodifiedChild(
495 OUString const & name);
497 rtl::Reference< ChildAccess > getSubChild(OUString const & path);
499 bool setChildProperty(
500 OUString const & name, com::sun::star::uno::Any const & value,
501 Modifications * localModifications);
503 com::sun::star::beans::Property asProperty();
505 void checkFinalized();
507 void checkKnownProperty(OUString const & descriptor);
509 rtl::Reference< ChildAccess > getFreeSetMember(
510 com::sun::star::uno::Any const & value);
512 rtl::Reference< Access > getNotificationRoot();
514 typedef std::map< OUString, ChildAccess * > WeakChildMap;
516 typedef
517 std::multiset<
518 com::sun::star::uno::Reference<
519 com::sun::star::lang::XEventListener > >
520 DisposeListeners;
522 typedef
523 std::multiset<
524 com::sun::star::uno::Reference<
525 com::sun::star::container::XContainerListener > >
526 ContainerListeners;
528 typedef
529 std::multiset<
530 com::sun::star::uno::Reference<
531 com::sun::star::beans::XPropertyChangeListener > >
532 PropertyChangeListenersElement;
534 typedef std::map< OUString, PropertyChangeListenersElement >
535 PropertyChangeListeners;
537 typedef
538 std::multiset<
539 com::sun::star::uno::Reference<
540 com::sun::star::beans::XVetoableChangeListener > >
541 VetoableChangeListenersElement;
543 typedef std::map< OUString, VetoableChangeListenersElement >
544 VetoableChangeListeners;
546 typedef
547 std::multiset<
548 com::sun::star::uno::Reference<
549 com::sun::star::beans::XPropertiesChangeListener > >
550 PropertiesChangeListeners;
552 Components & components_;
553 ModifiedChildren modifiedChildren_;
554 WeakChildMap cachedChildren_;
555 DisposeListeners disposeListeners_;
556 ContainerListeners containerListeners_;
557 PropertyChangeListeners propertyChangeListeners_;
558 VetoableChangeListeners vetoableChangeListeners_;
559 PropertiesChangeListeners propertiesChangeListeners_;
560 bool disposed_;
562 boost::shared_ptr<osl::Mutex> lock_;
564 #if !defined NDEBUG
565 protected:
566 enum {
567 IS_ANY = 0, IS_GROUP = 0x01, IS_SET = 0x02, IS_EXTENSIBLE = 0x04,
568 IS_GROUP_MEMBER = 0x08, IS_SET_MEMBER = 0x10, IS_UPDATE = 0x20 };
569 bool thisIs(int what);
570 #endif
575 #endif
577 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */