1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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"
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"
68 namespace com
{ namespace sun
{ namespace star
{
70 class XHierarchicalPropertySetInfo
;
71 class XPropertiesChangeListener
;
72 class XPropertyChangeListener
;
73 class XVetoableChangeListener
;
76 namespace container
{ class XContainerListener
; }
77 namespace lang
{ class XEventListener
; }
83 namespace util
{ struct ElementChange
; }
85 namespace rtl
{ class OUString
; }
96 public cppu::OWeakObject
, public com::sun::star::lang::XTypeProvider
,
97 public com::sun::star::lang::XServiceInfo
,
98 public com::sun::star::lang::XComponent
,
99 public com::sun::star::container::XHierarchicalNameReplace
,
100 public com::sun::star::container::XContainer
,
101 public com::sun::star::beans::XExactName
,
102 public com::sun::star::beans::XPropertySetInfo
,
103 public com::sun::star::container::XHierarchicalName
,
104 public com::sun::star::container::XNamed
,
105 public com::sun::star::beans::XProperty
,
106 public com::sun::star::beans::XPropertySet
,
107 public com::sun::star::beans::XMultiPropertySet
,
108 public com::sun::star::beans::XHierarchicalPropertySet
,
109 public com::sun::star::beans::XMultiHierarchicalPropertySet
,
110 public com::sun::star::beans::XHierarchicalPropertySetInfo
,
111 public com::sun::star::container::XNameContainer
,
112 public com::sun::star::lang::XSingleServiceFactory
,
113 private boost::noncopyable
116 oslInterlockedCount
acquireCounting();
118 void releaseNondeleting();
122 void markChildAsModified(rtl::Reference
< ChildAccess
> const & child
);
123 void releaseChild(rtl::OUString
const & name
);
125 virtual Path
getAbsolutePath() = 0;
126 virtual Path
getRelativePath() = 0;
128 virtual rtl::OUString
getRelativePathRepresentation() = 0;
129 virtual rtl::Reference
< Node
> getNode() = 0;
131 virtual bool isFinalized() = 0;
133 virtual void initBroadcaster(
134 Modifications::Node
const & modifications
, Broadcaster
* broadcaster
);
136 using OWeakObject::acquire
;
137 using OWeakObject::release
;
139 virtual com::sun::star::uno::Sequence
< com::sun::star::uno::Type
> SAL_CALL
140 getTypes() throw (com::sun::star::uno::RuntimeException
);
142 virtual com::sun::star::uno::Sequence
< sal_Int8
> SAL_CALL
143 getImplementationId() throw (com::sun::star::uno::RuntimeException
);
145 virtual rtl::OUString SAL_CALL
getImplementationName()
146 throw (com::sun::star::uno::RuntimeException
);
148 virtual sal_Bool SAL_CALL
supportsService(rtl::OUString
const & ServiceName
)
149 throw (com::sun::star::uno::RuntimeException
);
151 virtual com::sun::star::uno::Sequence
< rtl::OUString
> SAL_CALL
152 getSupportedServiceNames() throw (com::sun::star::uno::RuntimeException
);
154 virtual void SAL_CALL
dispose()
155 throw (com::sun::star::uno::RuntimeException
);
157 virtual void SAL_CALL
addEventListener(
158 com::sun::star::uno::Reference
< com::sun::star::lang::XEventListener
>
160 throw (com::sun::star::uno::RuntimeException
);
162 virtual void SAL_CALL
removeEventListener(
163 com::sun::star::uno::Reference
< com::sun::star::lang::XEventListener
>
165 throw (com::sun::star::uno::RuntimeException
);
167 virtual com::sun::star::uno::Type SAL_CALL
getElementType()
168 throw (com::sun::star::uno::RuntimeException
);
170 virtual sal_Bool SAL_CALL
hasElements()
171 throw (com::sun::star::uno::RuntimeException
);
173 virtual com::sun::star::uno::Any SAL_CALL
getByName(
174 rtl::OUString
const & aName
)
176 com::sun::star::container::NoSuchElementException
,
177 com::sun::star::lang::WrappedTargetException
,
178 com::sun::star::uno::RuntimeException
);
180 virtual com::sun::star::uno::Sequence
< rtl::OUString
> SAL_CALL
181 getElementNames() throw (com::sun::star::uno::RuntimeException
);
183 virtual sal_Bool SAL_CALL
hasByName(rtl::OUString
const & aName
)
184 throw (com::sun::star::uno::RuntimeException
);
186 virtual com::sun::star::uno::Any SAL_CALL
getByHierarchicalName(
187 rtl::OUString
const & aName
)
189 com::sun::star::container::NoSuchElementException
,
190 com::sun::star::uno::RuntimeException
);
192 virtual sal_Bool SAL_CALL
hasByHierarchicalName(rtl::OUString
const & aName
)
193 throw (com::sun::star::uno::RuntimeException
);
195 virtual void SAL_CALL
replaceByHierarchicalName(
196 rtl::OUString
const & aName
, com::sun::star::uno::Any
const & aElement
)
198 com::sun::star::lang::IllegalArgumentException
,
199 com::sun::star::container::NoSuchElementException
,
200 com::sun::star::lang::WrappedTargetException
,
201 com::sun::star::uno::RuntimeException
);
203 virtual void SAL_CALL
addContainerListener(
204 com::sun::star::uno::Reference
<
205 com::sun::star::container::XContainerListener
> const & xListener
)
206 throw (com::sun::star::uno::RuntimeException
);
208 virtual void SAL_CALL
removeContainerListener(
209 com::sun::star::uno::Reference
<
210 com::sun::star::container::XContainerListener
> const & xListener
)
211 throw (com::sun::star::uno::RuntimeException
);
213 virtual rtl::OUString SAL_CALL
getExactName(
214 rtl::OUString
const & aApproximateName
)
215 throw (com::sun::star::uno::RuntimeException
);
217 virtual com::sun::star::uno::Sequence
< com::sun::star::beans::Property
>
218 SAL_CALL
getProperties() throw (com::sun::star::uno::RuntimeException
);
220 virtual com::sun::star::beans::Property SAL_CALL
getPropertyByName(
221 rtl::OUString
const & aName
)
223 com::sun::star::beans::UnknownPropertyException
,
224 com::sun::star::uno::RuntimeException
);
226 virtual sal_Bool SAL_CALL
hasPropertyByName(rtl::OUString
const & Name
)
227 throw (com::sun::star::uno::RuntimeException
);
229 virtual rtl::OUString SAL_CALL
getHierarchicalName()
230 throw (com::sun::star::uno::RuntimeException
);
232 virtual rtl::OUString SAL_CALL
composeHierarchicalName(
233 rtl::OUString
const & aRelativeName
)
235 com::sun::star::lang::IllegalArgumentException
,
236 com::sun::star::lang::NoSupportException
,
237 com::sun::star::uno::RuntimeException
);
239 virtual rtl::OUString SAL_CALL
getName()
240 throw (com::sun::star::uno::RuntimeException
);
242 virtual void SAL_CALL
setName(rtl::OUString
const & aName
)
243 throw (com::sun::star::uno::RuntimeException
);
245 virtual com::sun::star::beans::Property SAL_CALL
getAsProperty()
246 throw (com::sun::star::uno::RuntimeException
);
249 com::sun::star::uno::Reference
< com::sun::star::beans::XPropertySetInfo
>
250 SAL_CALL
getPropertySetInfo() throw (com::sun::star::uno::RuntimeException
);
252 virtual void SAL_CALL
setPropertyValue(
253 rtl::OUString
const & aPropertyName
,
254 com::sun::star::uno::Any
const & aValue
)
256 com::sun::star::beans::UnknownPropertyException
,
257 com::sun::star::beans::PropertyVetoException
,
258 com::sun::star::lang::IllegalArgumentException
,
259 com::sun::star::lang::WrappedTargetException
,
260 com::sun::star::uno::RuntimeException
);
262 virtual com::sun::star::uno::Any SAL_CALL
getPropertyValue(
263 rtl::OUString
const & PropertyName
)
265 com::sun::star::beans::UnknownPropertyException
,
266 com::sun::star::lang::WrappedTargetException
,
267 com::sun::star::uno::RuntimeException
);
269 virtual void SAL_CALL
addPropertyChangeListener(
270 rtl::OUString
const & aPropertyName
,
271 com::sun::star::uno::Reference
<
272 com::sun::star::beans::XPropertyChangeListener
> const & xListener
)
274 com::sun::star::beans::UnknownPropertyException
,
275 com::sun::star::lang::WrappedTargetException
,
276 com::sun::star::uno::RuntimeException
);
278 virtual void SAL_CALL
removePropertyChangeListener(
279 rtl::OUString
const & aPropertyName
,
280 com::sun::star::uno::Reference
<
281 com::sun::star::beans::XPropertyChangeListener
> const & aListener
)
283 com::sun::star::beans::UnknownPropertyException
,
284 com::sun::star::lang::WrappedTargetException
,
285 com::sun::star::uno::RuntimeException
);
287 virtual void SAL_CALL
addVetoableChangeListener(
288 rtl::OUString
const & PropertyName
,
289 com::sun::star::uno::Reference
<
290 com::sun::star::beans::XVetoableChangeListener
> const & aListener
)
292 com::sun::star::beans::UnknownPropertyException
,
293 com::sun::star::lang::WrappedTargetException
,
294 com::sun::star::uno::RuntimeException
);
296 virtual void SAL_CALL
removeVetoableChangeListener(
297 rtl::OUString
const & PropertyName
,
298 com::sun::star::uno::Reference
<
299 com::sun::star::beans::XVetoableChangeListener
> const & aListener
)
301 com::sun::star::beans::UnknownPropertyException
,
302 com::sun::star::lang::WrappedTargetException
,
303 com::sun::star::uno::RuntimeException
);
305 virtual void SAL_CALL
setPropertyValues(
306 com::sun::star::uno::Sequence
< rtl::OUString
> const & aPropertyNames
,
307 com::sun::star::uno::Sequence
< com::sun::star::uno::Any
> const &
310 com::sun::star::beans::PropertyVetoException
,
311 com::sun::star::lang::IllegalArgumentException
,
312 com::sun::star::lang::WrappedTargetException
,
313 com::sun::star::uno::RuntimeException
);
315 virtual com::sun::star::uno::Sequence
< com::sun::star::uno::Any
> SAL_CALL
317 com::sun::star::uno::Sequence
< rtl::OUString
> const & aPropertyNames
)
318 throw (com::sun::star::uno::RuntimeException
);
320 virtual void SAL_CALL
addPropertiesChangeListener(
321 com::sun::star::uno::Sequence
< rtl::OUString
> const & aPropertyNames
,
322 com::sun::star::uno::Reference
<
323 com::sun::star::beans::XPropertiesChangeListener
> const &
325 throw (com::sun::star::uno::RuntimeException
);
327 virtual void SAL_CALL
removePropertiesChangeListener(
328 com::sun::star::uno::Reference
<
329 com::sun::star::beans::XPropertiesChangeListener
> const &
331 throw (com::sun::star::uno::RuntimeException
);
333 virtual void SAL_CALL
firePropertiesChangeEvent(
334 com::sun::star::uno::Sequence
< rtl::OUString
> const & aPropertyNames
,
335 com::sun::star::uno::Reference
<
336 com::sun::star::beans::XPropertiesChangeListener
> const &
338 throw (com::sun::star::uno::RuntimeException
);
341 com::sun::star::uno::Reference
<
342 com::sun::star::beans::XHierarchicalPropertySetInfo
> SAL_CALL
343 getHierarchicalPropertySetInfo()
344 throw (com::sun::star::uno::RuntimeException
);
346 virtual void SAL_CALL
setHierarchicalPropertyValue(
347 rtl::OUString
const & aHierarchicalPropertyName
,
348 com::sun::star::uno::Any
const & aValue
)
350 com::sun::star::beans::UnknownPropertyException
,
351 com::sun::star::beans::PropertyVetoException
,
352 com::sun::star::lang::IllegalArgumentException
,
353 com::sun::star::lang::WrappedTargetException
,
354 com::sun::star::uno::RuntimeException
);
356 virtual com::sun::star::uno::Any SAL_CALL
getHierarchicalPropertyValue(
357 rtl::OUString
const & aHierarchicalPropertyName
)
359 com::sun::star::beans::UnknownPropertyException
,
360 com::sun::star::lang::IllegalArgumentException
,
361 com::sun::star::lang::WrappedTargetException
,
362 com::sun::star::uno::RuntimeException
);
364 virtual void SAL_CALL
setHierarchicalPropertyValues(
365 com::sun::star::uno::Sequence
< rtl::OUString
> const &
366 aHierarchicalPropertyNames
,
367 com::sun::star::uno::Sequence
< com::sun::star::uno::Any
> const &
370 com::sun::star::beans::PropertyVetoException
,
371 com::sun::star::lang::IllegalArgumentException
,
372 com::sun::star::lang::WrappedTargetException
,
373 com::sun::star::uno::RuntimeException
);
375 virtual com::sun::star::uno::Sequence
< com::sun::star::uno::Any
> SAL_CALL
376 getHierarchicalPropertyValues(
377 com::sun::star::uno::Sequence
< rtl::OUString
> const &
378 aHierarchicalPropertyNames
)
380 com::sun::star::lang::IllegalArgumentException
,
381 com::sun::star::lang::WrappedTargetException
,
382 com::sun::star::uno::RuntimeException
);
384 virtual com::sun::star::beans::Property SAL_CALL
385 getPropertyByHierarchicalName(rtl::OUString
const & aHierarchicalName
)
387 com::sun::star::beans::UnknownPropertyException
,
388 com::sun::star::uno::RuntimeException
);
390 virtual sal_Bool SAL_CALL
hasPropertyByHierarchicalName(
391 rtl::OUString
const & aHierarchicalName
)
392 throw (com::sun::star::uno::RuntimeException
);
394 virtual void SAL_CALL
replaceByName(
395 rtl::OUString
const & aName
, com::sun::star::uno::Any
const & aElement
)
397 com::sun::star::lang::IllegalArgumentException
,
398 com::sun::star::container::NoSuchElementException
,
399 com::sun::star::lang::WrappedTargetException
,
400 com::sun::star::uno::RuntimeException
);
402 virtual void SAL_CALL
insertByName(
403 rtl::OUString
const & aName
, com::sun::star::uno::Any
const & aElement
)
405 com::sun::star::lang::IllegalArgumentException
,
406 com::sun::star::container::ElementExistException
,
407 com::sun::star::lang::WrappedTargetException
,
408 com::sun::star::uno::RuntimeException
);
410 virtual void SAL_CALL
removeByName(rtl::OUString
const & aName
)
412 com::sun::star::container::NoSuchElementException
,
413 com::sun::star::lang::WrappedTargetException
,
414 com::sun::star::uno::RuntimeException
);
416 virtual com::sun::star::uno::Reference
< com::sun::star::uno::XInterface
>
417 SAL_CALL
createInstance()
419 com::sun::star::uno::Exception
,
420 com::sun::star::uno::RuntimeException
);
422 virtual com::sun::star::uno::Reference
< com::sun::star::uno::XInterface
>
423 SAL_CALL
createInstanceWithArguments(
424 com::sun::star::uno::Sequence
< com::sun::star::uno::Any
> const &
427 com::sun::star::uno::Exception
,
428 com::sun::star::uno::RuntimeException
);
431 Access(Components
& components
);
435 virtual rtl::OUString
getNameInternal() = 0;
436 virtual rtl::Reference
< RootAccess
> getRootAccess() = 0;
437 virtual rtl::Reference
< Access
> getParentAccess() = 0;
439 virtual void addTypes(std::vector
< com::sun::star::uno::Type
> * types
)
442 virtual void addSupportedServiceNames(
443 std::vector
< rtl::OUString
> * services
) = 0;
445 virtual void initDisposeBroadcaster(Broadcaster
* broadcaster
);
446 virtual void clearListeners() throw ();
448 virtual com::sun::star::uno::Any SAL_CALL
queryInterface(
449 com::sun::star::uno::Type
const & aType
)
450 throw (com::sun::star::uno::RuntimeException
);
452 Components
& getComponents() const;
454 void checkLocalizedPropertyAccess();
456 rtl::Reference
< Node
> getParentNode();
457 rtl::Reference
< ChildAccess
> getChild(rtl::OUString
const & name
);
458 std::vector
< rtl::Reference
< ChildAccess
> > getAllChildren();
461 com::sun::star::uno::Any
const & value
, Type type
, bool nillable
);
463 void insertLocalizedValueChild(
464 rtl::OUString
const & name
, com::sun::star::uno::Any
const & value
,
465 Modifications
* localModifications
);
467 void reportChildChanges(
468 std::vector
< com::sun::star::util::ElementChange
> * changes
);
470 void commitChildChanges(bool valid
, Modifications
* globalModifications
);
472 void initBroadcasterAndChanges(
473 Modifications::Node
const & modifications
, Broadcaster
* broadcaster
,
474 std::vector
< com::sun::star::util::ElementChange
> * changes
);
476 bool isDisposed() const;
479 struct ModifiedChild
{
480 rtl::Reference
< ChildAccess
> child
;
481 bool directlyModified
;
486 rtl::Reference
< ChildAccess
> const & theChild
,
487 bool theDirectlyModified
);
490 typedef std::map
< rtl::OUString
, ModifiedChild
> ModifiedChildren
;
492 rtl::Reference
< ChildAccess
> getModifiedChild(
493 ModifiedChildren::iterator
const & childIterator
);
495 rtl::Reference
< ChildAccess
> getUnmodifiedChild(
496 rtl::OUString
const & name
);
498 rtl::Reference
< ChildAccess
> getSubChild(rtl::OUString
const & path
);
500 bool setChildProperty(
501 rtl::OUString
const & name
, com::sun::star::uno::Any
const & value
,
502 Modifications
* localModifications
);
504 com::sun::star::beans::Property
asProperty();
506 void checkFinalized();
508 void checkKnownProperty(rtl::OUString
const & descriptor
);
510 rtl::Reference
< ChildAccess
> getFreeSetMember(
511 com::sun::star::uno::Any
const & value
);
513 rtl::Reference
< Access
> getNotificationRoot();
515 typedef std::map
< rtl::OUString
, ChildAccess
* > WeakChildMap
;
519 com::sun::star::uno::Reference
<
520 com::sun::star::lang::XEventListener
> >
525 com::sun::star::uno::Reference
<
526 com::sun::star::container::XContainerListener
> >
531 com::sun::star::uno::Reference
<
532 com::sun::star::beans::XPropertyChangeListener
> >
533 PropertyChangeListenersElement
;
535 typedef std::map
< rtl::OUString
, PropertyChangeListenersElement
>
536 PropertyChangeListeners
;
540 com::sun::star::uno::Reference
<
541 com::sun::star::beans::XVetoableChangeListener
> >
542 VetoableChangeListenersElement
;
544 typedef std::map
< rtl::OUString
, VetoableChangeListenersElement
>
545 VetoableChangeListeners
;
549 com::sun::star::uno::Reference
<
550 com::sun::star::beans::XPropertiesChangeListener
> >
551 PropertiesChangeListeners
;
553 Components
& components_
;
554 ModifiedChildren modifiedChildren_
;
555 WeakChildMap cachedChildren_
;
556 DisposeListeners disposeListeners_
;
557 ContainerListeners containerListeners_
;
558 PropertyChangeListeners propertyChangeListeners_
;
559 VetoableChangeListeners vetoableChangeListeners_
;
560 PropertiesChangeListeners propertiesChangeListeners_
;
563 boost::shared_ptr
<osl::Mutex
> lock_
;
568 IS_ANY
= 0, IS_GROUP
= 0x01, IS_SET
= 0x02, IS_EXTENSIBLE
= 0x04,
569 IS_GROUP_MEMBER
= 0x08, IS_SET_MEMBER
= 0x10, IS_UPDATE
= 0x20 };
570 bool thisIs(int what
);
578 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */