1*3a7cf181SAndrew Rist /**************************************************************
2*3a7cf181SAndrew Rist *
3*3a7cf181SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*3a7cf181SAndrew Rist * or more contributor license agreements. See the NOTICE file
5*3a7cf181SAndrew Rist * distributed with this work for additional information
6*3a7cf181SAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*3a7cf181SAndrew Rist * to you under the Apache License, Version 2.0 (the
8*3a7cf181SAndrew Rist * "License"); you may not use this file except in compliance
9*3a7cf181SAndrew Rist * with the License. You may obtain a copy of the License at
10*3a7cf181SAndrew Rist *
11*3a7cf181SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12*3a7cf181SAndrew Rist *
13*3a7cf181SAndrew Rist * Unless required by applicable law or agreed to in writing,
14*3a7cf181SAndrew Rist * software distributed under the License is distributed on an
15*3a7cf181SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*3a7cf181SAndrew Rist * KIND, either express or implied. See the License for the
17*3a7cf181SAndrew Rist * specific language governing permissions and limitations
18*3a7cf181SAndrew Rist * under the License.
19*3a7cf181SAndrew Rist *
20*3a7cf181SAndrew Rist *************************************************************/
21*3a7cf181SAndrew Rist
22*3a7cf181SAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir #include "precompiled_configmgr.hxx"
25cdf0e10cSrcweir #include "sal/config.h"
26cdf0e10cSrcweir
27cdf0e10cSrcweir #include <vector>
28cdf0e10cSrcweir
29cdf0e10cSrcweir #include "com/sun/star/beans/Property.hpp"
30cdf0e10cSrcweir #include "com/sun/star/beans/PropertyAttribute.hpp"
31cdf0e10cSrcweir #include "com/sun/star/beans/PropertyChangeEvent.hpp"
32cdf0e10cSrcweir #include "com/sun/star/beans/PropertyVetoException.hpp"
33cdf0e10cSrcweir #include "com/sun/star/beans/UnknownPropertyException.hpp"
34cdf0e10cSrcweir #include "com/sun/star/beans/XExactName.hpp"
35cdf0e10cSrcweir #include "com/sun/star/beans/XHierarchicalPropertySet.hpp"
36cdf0e10cSrcweir #include "com/sun/star/beans/XHierarchicalPropertySetInfo.hpp"
37cdf0e10cSrcweir #include "com/sun/star/beans/XMultiHierarchicalPropertySet.hpp"
38cdf0e10cSrcweir #include "com/sun/star/beans/XMultiPropertySet.hpp"
39cdf0e10cSrcweir #include "com/sun/star/beans/XPropertiesChangeListener.hpp"
40cdf0e10cSrcweir #include "com/sun/star/beans/XProperty.hpp"
41cdf0e10cSrcweir #include "com/sun/star/beans/XPropertyChangeListener.hpp"
42cdf0e10cSrcweir #include "com/sun/star/beans/XPropertySet.hpp"
43cdf0e10cSrcweir #include "com/sun/star/beans/XPropertySetInfo.hpp"
44cdf0e10cSrcweir #include "com/sun/star/beans/XVetoableChangeListener.hpp"
45cdf0e10cSrcweir #include "com/sun/star/container/ContainerEvent.hpp"
46cdf0e10cSrcweir #include "com/sun/star/container/NoSuchElementException.hpp"
47cdf0e10cSrcweir #include "com/sun/star/container/XContainer.hpp"
48cdf0e10cSrcweir #include "com/sun/star/container/XContainerListener.hpp"
49cdf0e10cSrcweir #include "com/sun/star/container/XElementAccess.hpp"
50cdf0e10cSrcweir #include "com/sun/star/container/XHierarchicalName.hpp"
51cdf0e10cSrcweir #include "com/sun/star/container/XHierarchicalNameAccess.hpp"
52cdf0e10cSrcweir #include "com/sun/star/container/XNameAccess.hpp"
53cdf0e10cSrcweir #include "com/sun/star/container/XNameContainer.hpp"
54cdf0e10cSrcweir #include "com/sun/star/container/XNamed.hpp"
55cdf0e10cSrcweir #include "com/sun/star/lang/DisposedException.hpp"
56cdf0e10cSrcweir #include "com/sun/star/lang/EventObject.hpp"
57cdf0e10cSrcweir #include "com/sun/star/lang/IllegalArgumentException.hpp"
58cdf0e10cSrcweir #include "com/sun/star/lang/NoSupportException.hpp"
59cdf0e10cSrcweir #include "com/sun/star/lang/WrappedTargetException.hpp"
60cdf0e10cSrcweir #include "com/sun/star/lang/XComponent.hpp"
61cdf0e10cSrcweir #include "com/sun/star/lang/XEventListener.hpp"
62cdf0e10cSrcweir #include "com/sun/star/lang/XServiceInfo.hpp"
63cdf0e10cSrcweir #include "com/sun/star/lang/XSingleServiceFactory.hpp"
64cdf0e10cSrcweir #include "com/sun/star/lang/XTypeProvider.hpp"
65cdf0e10cSrcweir #include "com/sun/star/lang/XUnoTunnel.hpp"
66cdf0e10cSrcweir #include "com/sun/star/uno/Any.hxx"
67cdf0e10cSrcweir #include "com/sun/star/uno/Reference.hxx"
68cdf0e10cSrcweir #include "com/sun/star/uno/RuntimeException.hpp"
69cdf0e10cSrcweir #include "com/sun/star/uno/Sequence.hxx"
70cdf0e10cSrcweir #include "com/sun/star/uno/Type.hxx"
71cdf0e10cSrcweir #include "com/sun/star/uno/TypeClass.hpp"
72cdf0e10cSrcweir #include "com/sun/star/uno/XInterface.hpp"
73cdf0e10cSrcweir #include "com/sun/star/uno/XWeak.hpp"
74cdf0e10cSrcweir #include "com/sun/star/util/ElementChange.hpp"
75cdf0e10cSrcweir #include "comphelper/sequenceasvector.hxx"
76cdf0e10cSrcweir #include "cppu/unotype.hxx"
77cdf0e10cSrcweir #include "cppuhelper/queryinterface.hxx"
78cdf0e10cSrcweir #include "cppuhelper/weak.hxx"
79cdf0e10cSrcweir #include "osl/diagnose.h"
80cdf0e10cSrcweir #include "osl/interlck.h"
81cdf0e10cSrcweir #include "osl/mutex.hxx"
82cdf0e10cSrcweir #include "rtl/ref.hxx"
83cdf0e10cSrcweir #include "rtl/ustrbuf.hxx"
84cdf0e10cSrcweir #include "rtl/ustring.h"
85cdf0e10cSrcweir #include "rtl/ustring.hxx"
86cdf0e10cSrcweir #include "sal/types.h"
87cdf0e10cSrcweir
88cdf0e10cSrcweir #include "access.hxx"
89cdf0e10cSrcweir #include "broadcaster.hxx"
90cdf0e10cSrcweir #include "childaccess.hxx"
91cdf0e10cSrcweir #include "components.hxx"
92cdf0e10cSrcweir #include "data.hxx"
93cdf0e10cSrcweir #include "groupnode.hxx"
94cdf0e10cSrcweir #include "localizedpropertynode.hxx"
95cdf0e10cSrcweir #include "localizedvaluenode.hxx"
96cdf0e10cSrcweir #include "lock.hxx"
97cdf0e10cSrcweir #include "modifications.hxx"
98cdf0e10cSrcweir #include "node.hxx"
99cdf0e10cSrcweir #include "nodemap.hxx"
100cdf0e10cSrcweir #include "path.hxx"
101cdf0e10cSrcweir #include "propertynode.hxx"
102cdf0e10cSrcweir #include "rootaccess.hxx"
103cdf0e10cSrcweir #include "setnode.hxx"
104cdf0e10cSrcweir #include "type.hxx"
105cdf0e10cSrcweir
106cdf0e10cSrcweir namespace configmgr {
107cdf0e10cSrcweir
108cdf0e10cSrcweir namespace {
109cdf0e10cSrcweir
110cdf0e10cSrcweir namespace css = com::sun::star;
111cdf0e10cSrcweir
112cdf0e10cSrcweir }
113cdf0e10cSrcweir
acquireCounting()114cdf0e10cSrcweir oslInterlockedCount Access::acquireCounting() {
115cdf0e10cSrcweir return osl_incrementInterlockedCount(&m_refCount);
116cdf0e10cSrcweir }
117cdf0e10cSrcweir
releaseNondeleting()118cdf0e10cSrcweir void Access::releaseNondeleting() {
119cdf0e10cSrcweir osl_decrementInterlockedCount(&m_refCount);
120cdf0e10cSrcweir }
121cdf0e10cSrcweir
isValue()122cdf0e10cSrcweir bool Access::isValue() {
123cdf0e10cSrcweir rtl::Reference< Node > p(getNode());
124cdf0e10cSrcweir switch (p->kind()) {
125cdf0e10cSrcweir case Node::KIND_PROPERTY:
126cdf0e10cSrcweir case Node::KIND_LOCALIZED_VALUE:
127cdf0e10cSrcweir return true;
128cdf0e10cSrcweir case Node::KIND_LOCALIZED_PROPERTY:
129cdf0e10cSrcweir return !Components::allLocales(getRootAccess()->getLocale());
130cdf0e10cSrcweir default:
131cdf0e10cSrcweir return false;
132cdf0e10cSrcweir }
133cdf0e10cSrcweir }
134cdf0e10cSrcweir
markChildAsModified(rtl::Reference<ChildAccess> const & child)135cdf0e10cSrcweir void Access::markChildAsModified(rtl::Reference< ChildAccess > const & child) {
136cdf0e10cSrcweir OSL_ASSERT(child.is() && child->getParentAccess() == this);
137cdf0e10cSrcweir modifiedChildren_[child->getNameInternal()] = ModifiedChild(child, true);
138cdf0e10cSrcweir for (rtl::Reference< Access > p(this);;) {
139cdf0e10cSrcweir rtl::Reference< Access > parent(p->getParentAccess());
140cdf0e10cSrcweir if (!parent.is()) {
141cdf0e10cSrcweir break;
142cdf0e10cSrcweir }
143cdf0e10cSrcweir OSL_ASSERT(dynamic_cast< ChildAccess * >(p.get()) != 0);
144cdf0e10cSrcweir parent->modifiedChildren_.insert(
145cdf0e10cSrcweir ModifiedChildren::value_type(
146cdf0e10cSrcweir p->getNameInternal(),
147cdf0e10cSrcweir ModifiedChild(dynamic_cast< ChildAccess * >(p.get()), false)));
148cdf0e10cSrcweir p = parent;
149cdf0e10cSrcweir }
150cdf0e10cSrcweir }
151cdf0e10cSrcweir
releaseChild(rtl::OUString const & name)152cdf0e10cSrcweir void Access::releaseChild(rtl::OUString const & name) {
153cdf0e10cSrcweir cachedChildren_.erase(name);
154cdf0e10cSrcweir }
155cdf0e10cSrcweir
initBroadcaster(Modifications::Node const & modifications,Broadcaster * broadcaster)156cdf0e10cSrcweir void Access::initBroadcaster(
157cdf0e10cSrcweir Modifications::Node const & modifications, Broadcaster * broadcaster)
158cdf0e10cSrcweir {
159cdf0e10cSrcweir initBroadcasterAndChanges(modifications, broadcaster, 0);
160cdf0e10cSrcweir }
161cdf0e10cSrcweir
Access(Components & components)162cdf0e10cSrcweir Access::Access(Components & components):
163cdf0e10cSrcweir components_(components), disposed_(false)
164cdf0e10cSrcweir {}
165cdf0e10cSrcweir
~Access()166cdf0e10cSrcweir Access::~Access() {}
167cdf0e10cSrcweir
initDisposeBroadcaster(Broadcaster * broadcaster)168cdf0e10cSrcweir void Access::initDisposeBroadcaster(Broadcaster * broadcaster) {
169cdf0e10cSrcweir OSL_ASSERT(broadcaster != 0);
170cdf0e10cSrcweir for (DisposeListeners::iterator i(disposeListeners_.begin());
171cdf0e10cSrcweir i != disposeListeners_.end(); ++i)
172cdf0e10cSrcweir {
173cdf0e10cSrcweir broadcaster->addDisposeNotification(
174cdf0e10cSrcweir *i,
175cdf0e10cSrcweir css::lang::EventObject(static_cast< cppu::OWeakObject * >(this)));
176cdf0e10cSrcweir }
177cdf0e10cSrcweir for (ContainerListeners::iterator i(containerListeners_.begin());
178cdf0e10cSrcweir i != containerListeners_.end(); ++i)
179cdf0e10cSrcweir {
180cdf0e10cSrcweir broadcaster->addDisposeNotification(
181cdf0e10cSrcweir i->get(),
182cdf0e10cSrcweir css::lang::EventObject(static_cast< cppu::OWeakObject * >(this)));
183cdf0e10cSrcweir }
184cdf0e10cSrcweir for (PropertyChangeListeners::iterator i(propertyChangeListeners_.begin());
185cdf0e10cSrcweir i != propertyChangeListeners_.end(); ++i)
186cdf0e10cSrcweir {
187cdf0e10cSrcweir for (PropertyChangeListenersElement::iterator j(i->second.begin());
188cdf0e10cSrcweir j != i->second.end(); ++j)
189cdf0e10cSrcweir {
190cdf0e10cSrcweir broadcaster->addDisposeNotification(
191cdf0e10cSrcweir j->get(),
192cdf0e10cSrcweir css::lang::EventObject(
193cdf0e10cSrcweir static_cast< cppu::OWeakObject * >(this)));
194cdf0e10cSrcweir }
195cdf0e10cSrcweir }
196cdf0e10cSrcweir for (VetoableChangeListeners::iterator i(vetoableChangeListeners_.begin());
197cdf0e10cSrcweir i != vetoableChangeListeners_.end(); ++i)
198cdf0e10cSrcweir {
199cdf0e10cSrcweir for (VetoableChangeListenersElement::iterator j(i->second.begin());
200cdf0e10cSrcweir j != i->second.end(); ++j)
201cdf0e10cSrcweir {
202cdf0e10cSrcweir broadcaster->addDisposeNotification(
203cdf0e10cSrcweir j->get(),
204cdf0e10cSrcweir css::lang::EventObject(
205cdf0e10cSrcweir static_cast< cppu::OWeakObject * >(this)));
206cdf0e10cSrcweir }
207cdf0e10cSrcweir }
208cdf0e10cSrcweir for (PropertiesChangeListeners::iterator i(
209cdf0e10cSrcweir propertiesChangeListeners_.begin());
210cdf0e10cSrcweir i != propertiesChangeListeners_.end(); ++i)
211cdf0e10cSrcweir {
212cdf0e10cSrcweir broadcaster->addDisposeNotification(
213cdf0e10cSrcweir i->get(),
214cdf0e10cSrcweir css::lang::EventObject(static_cast< cppu::OWeakObject * >(this)));
215cdf0e10cSrcweir }
216cdf0e10cSrcweir //TODO: iterate over children w/ listeners (incl. unmodified ones):
217cdf0e10cSrcweir for (ModifiedChildren::iterator i(modifiedChildren_.begin());
218cdf0e10cSrcweir i != modifiedChildren_.end(); ++i)
219cdf0e10cSrcweir {
220cdf0e10cSrcweir rtl::Reference< ChildAccess > child(getModifiedChild(i));
221cdf0e10cSrcweir if (child.is()) {
222cdf0e10cSrcweir child->initDisposeBroadcaster(broadcaster);
223cdf0e10cSrcweir }
224cdf0e10cSrcweir }
225cdf0e10cSrcweir }
226cdf0e10cSrcweir
clearListeners()227cdf0e10cSrcweir void Access::clearListeners() throw() {
228cdf0e10cSrcweir disposeListeners_.clear();
229cdf0e10cSrcweir containerListeners_.clear();
230cdf0e10cSrcweir propertyChangeListeners_.clear();
231cdf0e10cSrcweir vetoableChangeListeners_.clear();
232cdf0e10cSrcweir propertiesChangeListeners_.clear();
233cdf0e10cSrcweir //TODO: iterate over children w/ listeners (incl. unmodified ones):
234cdf0e10cSrcweir for (ModifiedChildren::iterator i(modifiedChildren_.begin());
235cdf0e10cSrcweir i != modifiedChildren_.end(); ++i)
236cdf0e10cSrcweir {
237cdf0e10cSrcweir rtl::Reference< ChildAccess > child(getModifiedChild(i));
238cdf0e10cSrcweir if (child.is()) {
239cdf0e10cSrcweir child->clearListeners();
240cdf0e10cSrcweir }
241cdf0e10cSrcweir }
242cdf0e10cSrcweir }
243cdf0e10cSrcweir
queryInterface(css::uno::Type const & aType)244cdf0e10cSrcweir css::uno::Any Access::queryInterface(css::uno::Type const & aType)
245cdf0e10cSrcweir throw (css::uno::RuntimeException)
246cdf0e10cSrcweir {
247cdf0e10cSrcweir css::uno::Any res(OWeakObject::queryInterface(aType));
248cdf0e10cSrcweir if (res.hasValue()) {
249cdf0e10cSrcweir return res;
250cdf0e10cSrcweir }
251cdf0e10cSrcweir res = cppu::queryInterface(
252cdf0e10cSrcweir aType, static_cast< css::lang::XTypeProvider * >(this),
253cdf0e10cSrcweir static_cast< css::lang::XServiceInfo * >(this),
254cdf0e10cSrcweir static_cast< css::lang::XComponent * >(this),
255cdf0e10cSrcweir static_cast< css::container::XHierarchicalNameAccess * >(this),
256cdf0e10cSrcweir static_cast< css::container::XContainer * >(this),
257cdf0e10cSrcweir static_cast< css::beans::XExactName * >(this),
258cdf0e10cSrcweir static_cast< css::container::XHierarchicalName * >(this),
259cdf0e10cSrcweir static_cast< css::container::XNamed * >(this),
260cdf0e10cSrcweir static_cast< css::beans::XProperty * >(this),
261cdf0e10cSrcweir static_cast< css::container::XElementAccess * >(this),
262cdf0e10cSrcweir static_cast< css::container::XNameAccess * >(this));
263cdf0e10cSrcweir if (res.hasValue()) {
264cdf0e10cSrcweir return res;
265cdf0e10cSrcweir }
266cdf0e10cSrcweir if (getNode()->kind() == Node::KIND_GROUP) {
267cdf0e10cSrcweir res = cppu::queryInterface(
268cdf0e10cSrcweir aType, static_cast< css::beans::XPropertySetInfo * >(this),
269cdf0e10cSrcweir static_cast< css::beans::XPropertySet * >(this),
270cdf0e10cSrcweir static_cast< css::beans::XMultiPropertySet * >(this),
271cdf0e10cSrcweir static_cast< css::beans::XHierarchicalPropertySet * >(this),
272cdf0e10cSrcweir static_cast< css::beans::XMultiHierarchicalPropertySet * >(this),
273cdf0e10cSrcweir static_cast< css::beans::XHierarchicalPropertySetInfo * >(this));
274cdf0e10cSrcweir if (res.hasValue()) {
275cdf0e10cSrcweir return res;
276cdf0e10cSrcweir }
277cdf0e10cSrcweir }
278cdf0e10cSrcweir if (getRootAccess()->isUpdate()) {
279cdf0e10cSrcweir res = cppu::queryInterface(
280cdf0e10cSrcweir aType, static_cast< css::container::XNameReplace * >(this));
281cdf0e10cSrcweir if (res.hasValue()) {
282cdf0e10cSrcweir return res;
283cdf0e10cSrcweir }
284cdf0e10cSrcweir if (getNode()->kind() != Node::KIND_GROUP ||
285cdf0e10cSrcweir dynamic_cast< GroupNode * >(getNode().get())->isExtensible())
286cdf0e10cSrcweir {
287cdf0e10cSrcweir res = cppu::queryInterface(
288cdf0e10cSrcweir aType, static_cast< css::container::XNameContainer * >(this));
289cdf0e10cSrcweir if (res.hasValue()) {
290cdf0e10cSrcweir return res;
291cdf0e10cSrcweir }
292cdf0e10cSrcweir }
293cdf0e10cSrcweir if (getNode()->kind() == Node::KIND_SET) {
294cdf0e10cSrcweir res = cppu::queryInterface(
295cdf0e10cSrcweir aType, static_cast< css::lang::XSingleServiceFactory * >(this));
296cdf0e10cSrcweir }
297cdf0e10cSrcweir }
298cdf0e10cSrcweir return res;
299cdf0e10cSrcweir }
300cdf0e10cSrcweir
getComponents() const301cdf0e10cSrcweir Components & Access::getComponents() const {
302cdf0e10cSrcweir return components_;
303cdf0e10cSrcweir }
304cdf0e10cSrcweir
checkLocalizedPropertyAccess()305cdf0e10cSrcweir void Access::checkLocalizedPropertyAccess() {
306cdf0e10cSrcweir if (getNode()->kind() == Node::KIND_LOCALIZED_PROPERTY &&
307cdf0e10cSrcweir !Components::allLocales(getRootAccess()->getLocale()))
308cdf0e10cSrcweir {
309cdf0e10cSrcweir throw css::uno::RuntimeException(
310cdf0e10cSrcweir rtl::OUString(
311cdf0e10cSrcweir RTL_CONSTASCII_USTRINGPARAM(
312cdf0e10cSrcweir "configmgr Access to specialized LocalizedPropertyNode")),
313cdf0e10cSrcweir static_cast< cppu::OWeakObject * >(this));
314cdf0e10cSrcweir }
315cdf0e10cSrcweir }
316cdf0e10cSrcweir
getParentNode()317cdf0e10cSrcweir rtl::Reference< Node > Access::getParentNode() {
318cdf0e10cSrcweir rtl::Reference< Access > parent(getParentAccess());
319cdf0e10cSrcweir return parent.is() ? parent->getNode() : rtl::Reference< Node >();
320cdf0e10cSrcweir }
321cdf0e10cSrcweir
getChild(rtl::OUString const & name)322cdf0e10cSrcweir rtl::Reference< ChildAccess > Access::getChild(rtl::OUString const & name) {
323cdf0e10cSrcweir ModifiedChildren::iterator i(modifiedChildren_.find(name));
324cdf0e10cSrcweir return i == modifiedChildren_.end()
325cdf0e10cSrcweir ? getUnmodifiedChild(name) : getModifiedChild(i);
326cdf0e10cSrcweir }
327cdf0e10cSrcweir
getAllChildren()328cdf0e10cSrcweir std::vector< rtl::Reference< ChildAccess > > Access::getAllChildren() {
329cdf0e10cSrcweir std::vector< rtl::Reference< ChildAccess > > vec;
330cdf0e10cSrcweir NodeMap & members = getNode()->getMembers();
331cdf0e10cSrcweir for (NodeMap::iterator i(members.begin()); i != members.end(); ++i) {
332cdf0e10cSrcweir if (modifiedChildren_.find(i->first) == modifiedChildren_.end()) {
333cdf0e10cSrcweir vec.push_back(getUnmodifiedChild(i->first));
334cdf0e10cSrcweir OSL_ASSERT(vec.back().is());
335cdf0e10cSrcweir }
336cdf0e10cSrcweir }
337cdf0e10cSrcweir for (ModifiedChildren::iterator i(modifiedChildren_.begin());
338cdf0e10cSrcweir i != modifiedChildren_.end(); ++i)
339cdf0e10cSrcweir {
340cdf0e10cSrcweir rtl::Reference< ChildAccess > child(getModifiedChild(i));
341cdf0e10cSrcweir if (child.is()) {
342cdf0e10cSrcweir vec.push_back(child);
343cdf0e10cSrcweir }
344cdf0e10cSrcweir }
345cdf0e10cSrcweir return vec;
346cdf0e10cSrcweir }
347cdf0e10cSrcweir
checkValue(css::uno::Any const & value,Type type,bool nillable)348cdf0e10cSrcweir void Access::checkValue(css::uno::Any const & value, Type type, bool nillable) {
349cdf0e10cSrcweir bool ok;
350cdf0e10cSrcweir switch (type) {
351cdf0e10cSrcweir case TYPE_NIL:
352cdf0e10cSrcweir OSL_ASSERT(false);
353cdf0e10cSrcweir // fall through (cannot happen)
354cdf0e10cSrcweir case TYPE_ERROR:
355cdf0e10cSrcweir ok = false;
356cdf0e10cSrcweir break;
357cdf0e10cSrcweir case TYPE_ANY:
358cdf0e10cSrcweir switch (getDynamicType(value)) {
359cdf0e10cSrcweir case TYPE_ANY:
360cdf0e10cSrcweir OSL_ASSERT(false);
361cdf0e10cSrcweir // fall through (cannot happen)
362cdf0e10cSrcweir case TYPE_ERROR:
363cdf0e10cSrcweir ok = false;
364cdf0e10cSrcweir break;
365cdf0e10cSrcweir case TYPE_NIL:
366cdf0e10cSrcweir ok = nillable;
367cdf0e10cSrcweir break;
368cdf0e10cSrcweir default:
369cdf0e10cSrcweir ok = true;
370cdf0e10cSrcweir break;
371cdf0e10cSrcweir }
372cdf0e10cSrcweir break;
373cdf0e10cSrcweir default:
374cdf0e10cSrcweir ok = value.hasValue() ? value.isExtractableTo(mapType(type)) : nillable;
375cdf0e10cSrcweir break;
376cdf0e10cSrcweir }
377cdf0e10cSrcweir if (!ok) {
378cdf0e10cSrcweir throw css::lang::IllegalArgumentException(
379cdf0e10cSrcweir rtl::OUString(
380cdf0e10cSrcweir RTL_CONSTASCII_USTRINGPARAM(
381cdf0e10cSrcweir "configmgr inappropriate property value")),
382cdf0e10cSrcweir static_cast< cppu::OWeakObject * >(this), -1);
383cdf0e10cSrcweir }
384cdf0e10cSrcweir }
385cdf0e10cSrcweir
insertLocalizedValueChild(rtl::OUString const & name,css::uno::Any const & value,Modifications * localModifications)386cdf0e10cSrcweir void Access::insertLocalizedValueChild(
387cdf0e10cSrcweir rtl::OUString const & name, css::uno::Any const & value,
388cdf0e10cSrcweir Modifications * localModifications)
389cdf0e10cSrcweir {
390cdf0e10cSrcweir OSL_ASSERT(localModifications != 0);
391cdf0e10cSrcweir LocalizedPropertyNode * locprop = dynamic_cast< LocalizedPropertyNode * >(
392cdf0e10cSrcweir getNode().get());
393cdf0e10cSrcweir checkValue(value, locprop->getStaticType(), locprop->isNillable());
394cdf0e10cSrcweir rtl::Reference< ChildAccess > child(
395cdf0e10cSrcweir new ChildAccess(
396cdf0e10cSrcweir components_, getRootAccess(), this, name,
397cdf0e10cSrcweir new LocalizedValueNode(Data::NO_LAYER, value)));
398cdf0e10cSrcweir markChildAsModified(child);
399cdf0e10cSrcweir localModifications->add(child->getRelativePath());
400cdf0e10cSrcweir }
401cdf0e10cSrcweir
reportChildChanges(std::vector<css::util::ElementChange> * changes)402cdf0e10cSrcweir void Access::reportChildChanges(
403cdf0e10cSrcweir std::vector< css::util::ElementChange > * changes)
404cdf0e10cSrcweir {
405cdf0e10cSrcweir OSL_ASSERT(changes != 0);
406cdf0e10cSrcweir for (ModifiedChildren::iterator i(modifiedChildren_.begin());
407cdf0e10cSrcweir i != modifiedChildren_.end(); ++i)
408cdf0e10cSrcweir {
409cdf0e10cSrcweir rtl::Reference< ChildAccess > child(getModifiedChild(i));
410cdf0e10cSrcweir if (child.is()) {
411cdf0e10cSrcweir child->reportChildChanges(changes);
412cdf0e10cSrcweir changes->push_back(css::util::ElementChange());
413cdf0e10cSrcweir //TODO: changed value and/or inserted node
414cdf0e10cSrcweir } else {
415cdf0e10cSrcweir changes->push_back(css::util::ElementChange()); //TODO: removed node
416cdf0e10cSrcweir }
417cdf0e10cSrcweir }
418cdf0e10cSrcweir }
419cdf0e10cSrcweir
commitChildChanges(bool valid,Modifications * globalModifications)420cdf0e10cSrcweir void Access::commitChildChanges(
421cdf0e10cSrcweir bool valid, Modifications * globalModifications)
422cdf0e10cSrcweir {
423cdf0e10cSrcweir OSL_ASSERT(globalModifications != 0);
424cdf0e10cSrcweir while (!modifiedChildren_.empty()) {
425cdf0e10cSrcweir bool childValid = valid;
426cdf0e10cSrcweir ModifiedChildren::iterator i(modifiedChildren_.begin());
427cdf0e10cSrcweir rtl::Reference< ChildAccess > child(getModifiedChild(i));
428cdf0e10cSrcweir if (child.is()) {
429cdf0e10cSrcweir childValid = childValid && !child->isFinalized();
430cdf0e10cSrcweir child->commitChanges(childValid, globalModifications);
431cdf0e10cSrcweir //TODO: currently, this is called here for directly inserted
432cdf0e10cSrcweir // children as well as for children whose sub-children were
433cdf0e10cSrcweir // modified (and should never be called for directly removed
434cdf0e10cSrcweir // children); clarify what exactly should happen here for
435cdf0e10cSrcweir // directly inserted children
436cdf0e10cSrcweir }
437cdf0e10cSrcweir NodeMap & members = getNode()->getMembers();
438cdf0e10cSrcweir NodeMap::iterator j(members.find(i->first));
439cdf0e10cSrcweir if (child.is()) {
440cdf0e10cSrcweir // Inserted:
441cdf0e10cSrcweir if (j != members.end()) {
442cdf0e10cSrcweir childValid = childValid &&
443cdf0e10cSrcweir j->second->getFinalized() == Data::NO_LAYER;
444cdf0e10cSrcweir if (childValid) {
445cdf0e10cSrcweir child->getNode()->setMandatory(j->second->getMandatory());
446cdf0e10cSrcweir }
447cdf0e10cSrcweir }
448cdf0e10cSrcweir if (childValid) {
449cdf0e10cSrcweir members[i->first] = child->getNode();
450cdf0e10cSrcweir }
451cdf0e10cSrcweir } else {
452cdf0e10cSrcweir // Removed:
453cdf0e10cSrcweir childValid = childValid && j != members.end() &&
454cdf0e10cSrcweir j->second->getFinalized() == Data::NO_LAYER &&
455cdf0e10cSrcweir j->second->getMandatory() == Data::NO_LAYER;
456cdf0e10cSrcweir if (childValid) {
457cdf0e10cSrcweir members.erase(j);
458cdf0e10cSrcweir }
459cdf0e10cSrcweir }
460cdf0e10cSrcweir if (childValid && i->second.directlyModified) {
461cdf0e10cSrcweir Path path(getAbsolutePath());
462cdf0e10cSrcweir path.push_back(i->first);
463cdf0e10cSrcweir components_.addModification(path);
464cdf0e10cSrcweir globalModifications->add(path);
465cdf0e10cSrcweir }
466cdf0e10cSrcweir i->second.child->committed();
467cdf0e10cSrcweir modifiedChildren_.erase(i);
468cdf0e10cSrcweir }
469cdf0e10cSrcweir }
470cdf0e10cSrcweir
initBroadcasterAndChanges(Modifications::Node const & modifications,Broadcaster * broadcaster,std::vector<css::util::ElementChange> * allChanges)471cdf0e10cSrcweir void Access::initBroadcasterAndChanges(
472cdf0e10cSrcweir Modifications::Node const & modifications, Broadcaster * broadcaster,
473cdf0e10cSrcweir std::vector< css::util::ElementChange > * allChanges)
474cdf0e10cSrcweir {
475cdf0e10cSrcweir OSL_ASSERT(broadcaster != 0);
476cdf0e10cSrcweir comphelper::SequenceAsVector< css::beans::PropertyChangeEvent > propChanges;
477cdf0e10cSrcweir bool collectPropChanges = !propertiesChangeListeners_.empty();
478cdf0e10cSrcweir for (Modifications::Node::Children::const_iterator i(
479cdf0e10cSrcweir modifications.children.begin());
480cdf0e10cSrcweir i != modifications.children.end(); ++i)
481cdf0e10cSrcweir {
482cdf0e10cSrcweir rtl::Reference< ChildAccess > child(getChild(i->first));
483cdf0e10cSrcweir if (child.is()) {
484cdf0e10cSrcweir switch (child->getNode()->kind()) {
485cdf0e10cSrcweir case Node::KIND_LOCALIZED_PROPERTY:
486cdf0e10cSrcweir if (!i->second.children.empty()) {
487cdf0e10cSrcweir if (Components::allLocales(getRootAccess()->getLocale())) {
488cdf0e10cSrcweir child->initBroadcasterAndChanges(
489cdf0e10cSrcweir i->second, broadcaster, allChanges);
490cdf0e10cSrcweir //TODO: if allChanges==0, recurse only into children
491cdf0e10cSrcweir // w/ listeners
492cdf0e10cSrcweir } else {
493cdf0e10cSrcweir //TODO: filter child mods that are irrelevant for
494cdf0e10cSrcweir // locale:
495cdf0e10cSrcweir for (ContainerListeners::iterator j(
496cdf0e10cSrcweir containerListeners_.begin());
497cdf0e10cSrcweir j != containerListeners_.end(); ++j)
498cdf0e10cSrcweir {
499cdf0e10cSrcweir broadcaster->
500cdf0e10cSrcweir addContainerElementReplacedNotification(
501cdf0e10cSrcweir *j,
502cdf0e10cSrcweir css::container::ContainerEvent(
503cdf0e10cSrcweir static_cast< cppu::OWeakObject * >(
504cdf0e10cSrcweir this),
505cdf0e10cSrcweir css::uno::makeAny(i->first),
506cdf0e10cSrcweir css::uno::Any(), css::uno::Any()));
507cdf0e10cSrcweir //TODO: non-void Element, ReplacedElement
508cdf0e10cSrcweir }
509cdf0e10cSrcweir PropertyChangeListeners::iterator j(
510cdf0e10cSrcweir propertyChangeListeners_.find(i->first));
511cdf0e10cSrcweir if (j != propertyChangeListeners_.end()) {
512cdf0e10cSrcweir for (PropertyChangeListenersElement::iterator k(
513cdf0e10cSrcweir j->second.begin());
514cdf0e10cSrcweir k != j->second.end(); ++k)
515cdf0e10cSrcweir {
516cdf0e10cSrcweir broadcaster->addPropertyChangeNotification(
517cdf0e10cSrcweir *k,
518cdf0e10cSrcweir css::beans::PropertyChangeEvent(
519cdf0e10cSrcweir static_cast< cppu::OWeakObject * >(
520cdf0e10cSrcweir this),
521cdf0e10cSrcweir i->first, false, -1, css::uno::Any(),
522cdf0e10cSrcweir css::uno::Any()));
523cdf0e10cSrcweir }
524cdf0e10cSrcweir }
525cdf0e10cSrcweir j = propertyChangeListeners_.find(rtl::OUString());
526cdf0e10cSrcweir if (j != propertyChangeListeners_.end()) {
527cdf0e10cSrcweir for (PropertyChangeListenersElement::iterator k(
528cdf0e10cSrcweir j->second.begin());
529cdf0e10cSrcweir k != j->second.end(); ++k)
530cdf0e10cSrcweir {
531cdf0e10cSrcweir broadcaster->addPropertyChangeNotification(
532cdf0e10cSrcweir *k,
533cdf0e10cSrcweir css::beans::PropertyChangeEvent(
534cdf0e10cSrcweir static_cast< cppu::OWeakObject * >(
535cdf0e10cSrcweir this),
536cdf0e10cSrcweir i->first, false, -1, css::uno::Any(),
537cdf0e10cSrcweir css::uno::Any()));
538cdf0e10cSrcweir }
539cdf0e10cSrcweir }
540cdf0e10cSrcweir if (allChanges != 0) {
541cdf0e10cSrcweir allChanges->push_back(
542cdf0e10cSrcweir css::util::ElementChange(
543cdf0e10cSrcweir css::uno::makeAny(
544cdf0e10cSrcweir child->getRelativePathRepresentation()),
545cdf0e10cSrcweir css::uno::Any(), css::uno::Any()));
546cdf0e10cSrcweir //TODO: non-void Element, ReplacedElement
547cdf0e10cSrcweir }
548cdf0e10cSrcweir if (collectPropChanges) {
549cdf0e10cSrcweir propChanges.push_back(
550cdf0e10cSrcweir css::beans::PropertyChangeEvent(
551cdf0e10cSrcweir static_cast< cppu::OWeakObject * >(this),
552cdf0e10cSrcweir i->first, false, -1, css::uno::Any(),
553cdf0e10cSrcweir css::uno::Any()));
554cdf0e10cSrcweir }
555cdf0e10cSrcweir }
556cdf0e10cSrcweir }
557cdf0e10cSrcweir // else: spurious Modifications::Node not representing a change
558cdf0e10cSrcweir break;
559cdf0e10cSrcweir case Node::KIND_LOCALIZED_VALUE:
560cdf0e10cSrcweir OSL_ASSERT(
561cdf0e10cSrcweir Components::allLocales(getRootAccess()->getLocale()));
562cdf0e10cSrcweir for (ContainerListeners::iterator j(
563cdf0e10cSrcweir containerListeners_.begin());
564cdf0e10cSrcweir j != containerListeners_.end(); ++j)
565cdf0e10cSrcweir {
566cdf0e10cSrcweir broadcaster->addContainerElementReplacedNotification(
567cdf0e10cSrcweir *j,
568cdf0e10cSrcweir css::container::ContainerEvent(
569cdf0e10cSrcweir static_cast< cppu::OWeakObject * >(this),
570cdf0e10cSrcweir css::uno::makeAny(i->first), child->asValue(),
571cdf0e10cSrcweir css::uno::Any()));
572cdf0e10cSrcweir //TODO: distinguish add/modify; non-void ReplacedElement
573cdf0e10cSrcweir }
574cdf0e10cSrcweir if (allChanges != 0) {
575cdf0e10cSrcweir allChanges->push_back(
576cdf0e10cSrcweir css::util::ElementChange(
577cdf0e10cSrcweir css::uno::makeAny(
578cdf0e10cSrcweir child->getRelativePathRepresentation()),
579cdf0e10cSrcweir child->asValue(), css::uno::Any()));
580cdf0e10cSrcweir //TODO: non-void ReplacedElement
581cdf0e10cSrcweir }
582cdf0e10cSrcweir OSL_ASSERT(!collectPropChanges);
583cdf0e10cSrcweir break;
584cdf0e10cSrcweir case Node::KIND_PROPERTY:
585cdf0e10cSrcweir {
586cdf0e10cSrcweir for (ContainerListeners::iterator j(
587cdf0e10cSrcweir containerListeners_.begin());
588cdf0e10cSrcweir j != containerListeners_.end(); ++j)
589cdf0e10cSrcweir {
590cdf0e10cSrcweir broadcaster->addContainerElementReplacedNotification(
591cdf0e10cSrcweir *j,
592cdf0e10cSrcweir css::container::ContainerEvent(
593cdf0e10cSrcweir static_cast< cppu::OWeakObject * >(this),
594cdf0e10cSrcweir css::uno::makeAny(i->first), child->asValue(),
595cdf0e10cSrcweir css::uno::Any()));
596cdf0e10cSrcweir //TODO: distinguish add/remove/modify; non-void
597cdf0e10cSrcweir // ReplacedElement
598cdf0e10cSrcweir }
599cdf0e10cSrcweir PropertyChangeListeners::iterator j(
600cdf0e10cSrcweir propertyChangeListeners_.find(i->first));
601cdf0e10cSrcweir if (j != propertyChangeListeners_.end()) {
602cdf0e10cSrcweir for (PropertyChangeListenersElement::iterator k(
603cdf0e10cSrcweir j->second.begin());
604cdf0e10cSrcweir k != j->second.end(); ++k)
605cdf0e10cSrcweir {
606cdf0e10cSrcweir broadcaster->addPropertyChangeNotification(
607cdf0e10cSrcweir *k,
608cdf0e10cSrcweir css::beans::PropertyChangeEvent(
609cdf0e10cSrcweir static_cast< cppu::OWeakObject * >(this),
610cdf0e10cSrcweir i->first, false, -1, css::uno::Any(),
611cdf0e10cSrcweir css::uno::Any()));
612cdf0e10cSrcweir }
613cdf0e10cSrcweir }
614cdf0e10cSrcweir j = propertyChangeListeners_.find(rtl::OUString());
615cdf0e10cSrcweir if (j != propertyChangeListeners_.end()) {
616cdf0e10cSrcweir for (PropertyChangeListenersElement::iterator k(
617cdf0e10cSrcweir j->second.begin());
618cdf0e10cSrcweir k != j->second.end(); ++k)
619cdf0e10cSrcweir {
620cdf0e10cSrcweir broadcaster->addPropertyChangeNotification(
621cdf0e10cSrcweir *k,
622cdf0e10cSrcweir css::beans::PropertyChangeEvent(
623cdf0e10cSrcweir static_cast< cppu::OWeakObject * >(this),
624cdf0e10cSrcweir i->first, false, -1, css::uno::Any(),
625cdf0e10cSrcweir css::uno::Any()));
626cdf0e10cSrcweir }
627cdf0e10cSrcweir }
628cdf0e10cSrcweir if (allChanges != 0) {
629cdf0e10cSrcweir allChanges->push_back(
630cdf0e10cSrcweir css::util::ElementChange(
631cdf0e10cSrcweir css::uno::makeAny(
632cdf0e10cSrcweir child->getRelativePathRepresentation()),
633cdf0e10cSrcweir child->asValue(), css::uno::Any()));
634cdf0e10cSrcweir //TODO: non-void ReplacedElement
635cdf0e10cSrcweir }
636cdf0e10cSrcweir if (collectPropChanges) {
637cdf0e10cSrcweir propChanges.push_back(
638cdf0e10cSrcweir css::beans::PropertyChangeEvent(
639cdf0e10cSrcweir static_cast< cppu::OWeakObject * >(this),
640cdf0e10cSrcweir i->first, false, -1, css::uno::Any(),
641cdf0e10cSrcweir css::uno::Any()));
642cdf0e10cSrcweir }
643cdf0e10cSrcweir }
644cdf0e10cSrcweir break;
645cdf0e10cSrcweir case Node::KIND_GROUP:
646cdf0e10cSrcweir case Node::KIND_SET:
647cdf0e10cSrcweir if (i->second.children.empty()) {
648cdf0e10cSrcweir if (child->getNode()->getTemplateName().getLength() != 0) {
649cdf0e10cSrcweir for (ContainerListeners::iterator j(
650cdf0e10cSrcweir containerListeners_.begin());
651cdf0e10cSrcweir j != containerListeners_.end(); ++j)
652cdf0e10cSrcweir {
653cdf0e10cSrcweir broadcaster->
654cdf0e10cSrcweir addContainerElementInsertedNotification(
655cdf0e10cSrcweir *j,
656cdf0e10cSrcweir css::container::ContainerEvent(
657cdf0e10cSrcweir static_cast< cppu::OWeakObject * >(
658cdf0e10cSrcweir this),
659cdf0e10cSrcweir css::uno::makeAny(i->first),
660cdf0e10cSrcweir child->asValue(), css::uno::Any()));
661cdf0e10cSrcweir }
662cdf0e10cSrcweir if (allChanges != 0) {
663cdf0e10cSrcweir allChanges->push_back(
664cdf0e10cSrcweir css::util::ElementChange(
665cdf0e10cSrcweir css::uno::makeAny(
666cdf0e10cSrcweir child->getRelativePathRepresentation()),
667cdf0e10cSrcweir css::uno::Any(), css::uno::Any()));
668cdf0e10cSrcweir //TODO: non-void Element, ReplacedElement
669cdf0e10cSrcweir }
670cdf0e10cSrcweir }
671cdf0e10cSrcweir // else: spurious Modifications::Node not representing a
672cdf0e10cSrcweir // change
673cdf0e10cSrcweir } else {
674cdf0e10cSrcweir child->initBroadcasterAndChanges(
675cdf0e10cSrcweir i->second, broadcaster, allChanges);
676cdf0e10cSrcweir //TODO: if allChanges==0, recurse only into children w/
677cdf0e10cSrcweir // listeners
678cdf0e10cSrcweir }
679cdf0e10cSrcweir break;
680cdf0e10cSrcweir }
681cdf0e10cSrcweir } else {
682cdf0e10cSrcweir switch (getNode()->kind()) {
683cdf0e10cSrcweir case Node::KIND_LOCALIZED_PROPERTY:
684cdf0e10cSrcweir // Removed localized property value:
685cdf0e10cSrcweir OSL_ASSERT(
686cdf0e10cSrcweir Components::allLocales(getRootAccess()->getLocale()));
687cdf0e10cSrcweir for (ContainerListeners::iterator j(
688cdf0e10cSrcweir containerListeners_.begin());
689cdf0e10cSrcweir j != containerListeners_.end(); ++j)
690cdf0e10cSrcweir {
691cdf0e10cSrcweir broadcaster->addContainerElementRemovedNotification(
692cdf0e10cSrcweir *j,
693cdf0e10cSrcweir css::container::ContainerEvent(
694cdf0e10cSrcweir static_cast< cppu::OWeakObject * >(this),
695cdf0e10cSrcweir css::uno::makeAny(i->first), css::uno::Any(),
696cdf0e10cSrcweir css::uno::Any()));
697cdf0e10cSrcweir //TODO: non-void ReplacedElement
698cdf0e10cSrcweir }
699cdf0e10cSrcweir if (allChanges != 0) {
700cdf0e10cSrcweir rtl::OUStringBuffer path(getRelativePathRepresentation());
701cdf0e10cSrcweir if (path.getLength() != 0) {
702cdf0e10cSrcweir path.append(sal_Unicode('/'));
703cdf0e10cSrcweir }
704cdf0e10cSrcweir path.append(
705cdf0e10cSrcweir Data::createSegment(
706cdf0e10cSrcweir rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("*")),
707cdf0e10cSrcweir i->first));
708cdf0e10cSrcweir allChanges->push_back(
709cdf0e10cSrcweir css::util::ElementChange(
710cdf0e10cSrcweir css::uno::makeAny(path.makeStringAndClear()),
711cdf0e10cSrcweir css::uno::Any(), css::uno::Any()));
712cdf0e10cSrcweir //TODO: non-void ReplacedElement
713cdf0e10cSrcweir }
714cdf0e10cSrcweir OSL_ASSERT(!collectPropChanges);
715cdf0e10cSrcweir break;
716cdf0e10cSrcweir case Node::KIND_GROUP:
717cdf0e10cSrcweir {
718cdf0e10cSrcweir // Removed (non-localized) extension property:
719cdf0e10cSrcweir for (ContainerListeners::iterator j(
720cdf0e10cSrcweir containerListeners_.begin());
721cdf0e10cSrcweir j != containerListeners_.end(); ++j)
722cdf0e10cSrcweir {
723cdf0e10cSrcweir broadcaster->addContainerElementRemovedNotification(
724cdf0e10cSrcweir *j,
725cdf0e10cSrcweir css::container::ContainerEvent(
726cdf0e10cSrcweir static_cast< cppu::OWeakObject * >(this),
727cdf0e10cSrcweir css::uno::makeAny(i->first), css::uno::Any(),
728cdf0e10cSrcweir css::uno::Any()));
729cdf0e10cSrcweir //TODO: non-void ReplacedElement
730cdf0e10cSrcweir }
731cdf0e10cSrcweir PropertyChangeListeners::iterator j(
732cdf0e10cSrcweir propertyChangeListeners_.find(i->first));
733cdf0e10cSrcweir if (j != propertyChangeListeners_.end()) {
734cdf0e10cSrcweir for (PropertyChangeListenersElement::iterator k(
735cdf0e10cSrcweir j->second.begin());
736cdf0e10cSrcweir k != j->second.end(); ++k)
737cdf0e10cSrcweir {
738cdf0e10cSrcweir broadcaster->addPropertyChangeNotification(
739cdf0e10cSrcweir *k,
740cdf0e10cSrcweir css::beans::PropertyChangeEvent(
741cdf0e10cSrcweir static_cast< cppu::OWeakObject * >(this),
742cdf0e10cSrcweir i->first, false, -1, css::uno::Any(),
743cdf0e10cSrcweir css::uno::Any()));
744cdf0e10cSrcweir }
745cdf0e10cSrcweir }
746cdf0e10cSrcweir j = propertyChangeListeners_.find(rtl::OUString());
747cdf0e10cSrcweir if (j != propertyChangeListeners_.end()) {
748cdf0e10cSrcweir for (PropertyChangeListenersElement::iterator k(
749cdf0e10cSrcweir j->second.begin());
750cdf0e10cSrcweir k != j->second.end(); ++k)
751cdf0e10cSrcweir {
752cdf0e10cSrcweir broadcaster->addPropertyChangeNotification(
753cdf0e10cSrcweir *k,
754cdf0e10cSrcweir css::beans::PropertyChangeEvent(
755cdf0e10cSrcweir static_cast< cppu::OWeakObject * >(this),
756cdf0e10cSrcweir i->first, false, -1, css::uno::Any(),
757cdf0e10cSrcweir css::uno::Any()));
758cdf0e10cSrcweir }
759cdf0e10cSrcweir }
760cdf0e10cSrcweir if (allChanges != 0) {
761cdf0e10cSrcweir rtl::OUStringBuffer path(
762cdf0e10cSrcweir getRelativePathRepresentation());
763cdf0e10cSrcweir if (path.getLength() != 0) {
764cdf0e10cSrcweir path.append(sal_Unicode('/'));
765cdf0e10cSrcweir }
766cdf0e10cSrcweir path.append(i->first);
767cdf0e10cSrcweir allChanges->push_back(
768cdf0e10cSrcweir css::util::ElementChange(
769cdf0e10cSrcweir css::uno::makeAny(path.makeStringAndClear()),
770cdf0e10cSrcweir css::uno::Any(), css::uno::Any()));
771cdf0e10cSrcweir //TODO: non-void ReplacedElement
772cdf0e10cSrcweir }
773cdf0e10cSrcweir if (collectPropChanges) {
774cdf0e10cSrcweir propChanges.push_back(
775cdf0e10cSrcweir css::beans::PropertyChangeEvent(
776cdf0e10cSrcweir static_cast< cppu::OWeakObject * >(this),
777cdf0e10cSrcweir i->first, false, -1, css::uno::Any(),
778cdf0e10cSrcweir css::uno::Any()));
779cdf0e10cSrcweir }
780cdf0e10cSrcweir }
781cdf0e10cSrcweir break;
782cdf0e10cSrcweir case Node::KIND_SET:
783cdf0e10cSrcweir // Removed set member:
784cdf0e10cSrcweir if (i->second.children.empty()) {
785cdf0e10cSrcweir for (ContainerListeners::iterator j(
786cdf0e10cSrcweir containerListeners_.begin());
787cdf0e10cSrcweir j != containerListeners_.end(); ++j)
788cdf0e10cSrcweir {
789cdf0e10cSrcweir broadcaster->addContainerElementRemovedNotification(
790cdf0e10cSrcweir *j,
791cdf0e10cSrcweir css::container::ContainerEvent(
792cdf0e10cSrcweir static_cast< cppu::OWeakObject * >(this),
793cdf0e10cSrcweir css::uno::makeAny(i->first),
794cdf0e10cSrcweir css::uno::Any(), css::uno::Any()));
795cdf0e10cSrcweir //TODO: non-void ReplacedElement
796cdf0e10cSrcweir }
797cdf0e10cSrcweir if (allChanges != 0) {
798cdf0e10cSrcweir rtl::OUStringBuffer path(
799cdf0e10cSrcweir getRelativePathRepresentation());
800cdf0e10cSrcweir if (path.getLength() != 0) {
801cdf0e10cSrcweir path.append(sal_Unicode('/'));
802cdf0e10cSrcweir }
803cdf0e10cSrcweir path.append(
804cdf0e10cSrcweir Data::createSegment(
805cdf0e10cSrcweir rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("*")),
806cdf0e10cSrcweir i->first));
807cdf0e10cSrcweir allChanges->push_back(
808cdf0e10cSrcweir css::util::ElementChange(
809cdf0e10cSrcweir css::uno::makeAny(path.makeStringAndClear()),
810cdf0e10cSrcweir css::uno::Any(), css::uno::Any()));
811cdf0e10cSrcweir //TODO: non-void ReplacedElement
812cdf0e10cSrcweir }
813cdf0e10cSrcweir }
814cdf0e10cSrcweir // else: spurious Modifications::Node not representing a change
815cdf0e10cSrcweir break;
816cdf0e10cSrcweir default:
817cdf0e10cSrcweir OSL_ASSERT(false); // this cannot happen
818cdf0e10cSrcweir break;
819cdf0e10cSrcweir }
820cdf0e10cSrcweir }
821cdf0e10cSrcweir }
822cdf0e10cSrcweir if (!propChanges.empty()) {
823cdf0e10cSrcweir css::uno::Sequence< css::beans::PropertyChangeEvent > seq(
824cdf0e10cSrcweir propChanges.getAsConstList());
825cdf0e10cSrcweir for (PropertiesChangeListeners::iterator i(
826cdf0e10cSrcweir propertiesChangeListeners_.begin());
827cdf0e10cSrcweir i != propertiesChangeListeners_.end(); ++i)
828cdf0e10cSrcweir {
829cdf0e10cSrcweir broadcaster->addPropertiesChangeNotification(*i, seq);
830cdf0e10cSrcweir }
831cdf0e10cSrcweir }
832cdf0e10cSrcweir }
833cdf0e10cSrcweir
isDisposed() const834cdf0e10cSrcweir bool Access::isDisposed() const {
835cdf0e10cSrcweir return disposed_;
836cdf0e10cSrcweir }
837cdf0e10cSrcweir
ModifiedChild()838cdf0e10cSrcweir Access::ModifiedChild::ModifiedChild() {}
839cdf0e10cSrcweir
ModifiedChild(rtl::Reference<ChildAccess> const & theChild,bool theDirectlyModified)840cdf0e10cSrcweir Access::ModifiedChild::ModifiedChild(
841cdf0e10cSrcweir rtl::Reference< ChildAccess > const & theChild, bool theDirectlyModified):
842cdf0e10cSrcweir child(theChild), directlyModified(theDirectlyModified)
843cdf0e10cSrcweir {}
844cdf0e10cSrcweir
getTypes()845cdf0e10cSrcweir css::uno::Sequence< css::uno::Type > Access::getTypes()
846cdf0e10cSrcweir throw (css::uno::RuntimeException)
847cdf0e10cSrcweir {
848cdf0e10cSrcweir OSL_ASSERT(thisIs(IS_ANY));
849cdf0e10cSrcweir osl::MutexGuard g(lock);
850cdf0e10cSrcweir checkLocalizedPropertyAccess();
851cdf0e10cSrcweir comphelper::SequenceAsVector< css::uno::Type > types;
852cdf0e10cSrcweir types.push_back(cppu::UnoType< css::uno::XInterface >::get());
853cdf0e10cSrcweir types.push_back(cppu::UnoType< css::uno::XWeak >::get());
854cdf0e10cSrcweir types.push_back(cppu::UnoType< css::lang::XTypeProvider >::get());
855cdf0e10cSrcweir types.push_back(cppu::UnoType< css::lang::XServiceInfo >::get());
856cdf0e10cSrcweir types.push_back(cppu::UnoType< css::lang::XComponent >::get());
857cdf0e10cSrcweir types.push_back(
858cdf0e10cSrcweir cppu::UnoType< css::container::XHierarchicalNameAccess >::get());
859cdf0e10cSrcweir types.push_back(cppu::UnoType< css::container::XContainer >::get());
860cdf0e10cSrcweir types.push_back(cppu::UnoType< css::beans::XExactName >::get());
861cdf0e10cSrcweir types.push_back(cppu::UnoType< css::container::XHierarchicalName >::get());
862cdf0e10cSrcweir types.push_back(cppu::UnoType< css::container::XNamed >::get());
863cdf0e10cSrcweir types.push_back(cppu::UnoType< css::beans::XProperty >::get());
864cdf0e10cSrcweir types.push_back(cppu::UnoType< css::container::XElementAccess >::get());
865cdf0e10cSrcweir types.push_back(cppu::UnoType< css::container::XNameAccess >::get());
866cdf0e10cSrcweir if (getNode()->kind() == Node::KIND_GROUP) {
867cdf0e10cSrcweir types.push_back(cppu::UnoType< css::beans::XPropertySetInfo >::get());
868cdf0e10cSrcweir types.push_back(cppu::UnoType< css::beans::XPropertySet >::get());
869cdf0e10cSrcweir types.push_back(cppu::UnoType< css::beans::XMultiPropertySet >::get());
870cdf0e10cSrcweir types.push_back(
871cdf0e10cSrcweir cppu::UnoType< css::beans::XHierarchicalPropertySet >::get());
872cdf0e10cSrcweir types.push_back(
873cdf0e10cSrcweir cppu::UnoType< css::beans::XMultiHierarchicalPropertySet >::get());
874cdf0e10cSrcweir types.push_back(
875cdf0e10cSrcweir cppu::UnoType< css::beans::XHierarchicalPropertySetInfo >::get());
876cdf0e10cSrcweir }
877cdf0e10cSrcweir if (getRootAccess()->isUpdate()) {
878cdf0e10cSrcweir types.push_back(cppu::UnoType< css::container::XNameReplace >::get());
879cdf0e10cSrcweir if (getNode()->kind() != Node::KIND_GROUP ||
880cdf0e10cSrcweir dynamic_cast< GroupNode * >(getNode().get())->isExtensible())
881cdf0e10cSrcweir {
882cdf0e10cSrcweir types.push_back(
883cdf0e10cSrcweir cppu::UnoType< css::container::XNameContainer >::get());
884cdf0e10cSrcweir }
885cdf0e10cSrcweir if (getNode()->kind() == Node::KIND_SET) {
886cdf0e10cSrcweir types.push_back(
887cdf0e10cSrcweir cppu::UnoType< css::lang::XSingleServiceFactory >::get());
888cdf0e10cSrcweir }
889cdf0e10cSrcweir }
890cdf0e10cSrcweir addTypes(&types);
891cdf0e10cSrcweir return types.getAsConstList();
892cdf0e10cSrcweir }
893cdf0e10cSrcweir
getImplementationId()894cdf0e10cSrcweir css::uno::Sequence< sal_Int8 > Access::getImplementationId()
895cdf0e10cSrcweir throw (css::uno::RuntimeException)
896cdf0e10cSrcweir {
897cdf0e10cSrcweir OSL_ASSERT(thisIs(IS_ANY));
898cdf0e10cSrcweir osl::MutexGuard g(lock);
899cdf0e10cSrcweir checkLocalizedPropertyAccess();
900cdf0e10cSrcweir return css::uno::Sequence< sal_Int8 >();
901cdf0e10cSrcweir }
902cdf0e10cSrcweir
getImplementationName()903cdf0e10cSrcweir rtl::OUString Access::getImplementationName() throw (css::uno::RuntimeException)
904cdf0e10cSrcweir {
905cdf0e10cSrcweir OSL_ASSERT(thisIs(IS_ANY));
906cdf0e10cSrcweir osl::MutexGuard g(lock);
907cdf0e10cSrcweir checkLocalizedPropertyAccess();
908cdf0e10cSrcweir return rtl::OUString(
909cdf0e10cSrcweir RTL_CONSTASCII_USTRINGPARAM("org.openoffice-configmgr::Access"));
910cdf0e10cSrcweir }
911cdf0e10cSrcweir
supportsService(rtl::OUString const & ServiceName)912cdf0e10cSrcweir sal_Bool Access::supportsService(rtl::OUString const & ServiceName)
913cdf0e10cSrcweir throw (css::uno::RuntimeException)
914cdf0e10cSrcweir {
915cdf0e10cSrcweir OSL_ASSERT(thisIs(IS_ANY));
916cdf0e10cSrcweir osl::MutexGuard g(lock);
917cdf0e10cSrcweir checkLocalizedPropertyAccess();
918cdf0e10cSrcweir css::uno::Sequence< rtl::OUString > names(getSupportedServiceNames());
919cdf0e10cSrcweir for (sal_Int32 i = 0; i < names.getLength(); ++i) {
920cdf0e10cSrcweir if (names[i] == ServiceName) {
921cdf0e10cSrcweir return true;
922cdf0e10cSrcweir }
923cdf0e10cSrcweir }
924cdf0e10cSrcweir return false;
925cdf0e10cSrcweir }
926cdf0e10cSrcweir
getSupportedServiceNames()927cdf0e10cSrcweir css::uno::Sequence< rtl::OUString > Access::getSupportedServiceNames()
928cdf0e10cSrcweir throw (css::uno::RuntimeException)
929cdf0e10cSrcweir {
930cdf0e10cSrcweir OSL_ASSERT(thisIs(IS_ANY));
931cdf0e10cSrcweir osl::MutexGuard g(lock);
932cdf0e10cSrcweir checkLocalizedPropertyAccess();
933cdf0e10cSrcweir comphelper::SequenceAsVector< rtl::OUString > services;
934cdf0e10cSrcweir services.push_back(
935cdf0e10cSrcweir rtl::OUString(
936cdf0e10cSrcweir RTL_CONSTASCII_USTRINGPARAM(
937cdf0e10cSrcweir "com.sun.star.configuration.ConfigurationAccess")));
938cdf0e10cSrcweir if (getRootAccess()->isUpdate()) {
939cdf0e10cSrcweir services.push_back(
940cdf0e10cSrcweir rtl::OUString(
941cdf0e10cSrcweir RTL_CONSTASCII_USTRINGPARAM(
942cdf0e10cSrcweir "com.sun.star.configuration.ConfigurationUpdateAccess")));
943cdf0e10cSrcweir }
944cdf0e10cSrcweir services.push_back(
945cdf0e10cSrcweir rtl::OUString(
946cdf0e10cSrcweir RTL_CONSTASCII_USTRINGPARAM(
947cdf0e10cSrcweir "com.sun.star.configuration.HierarchyAccess")));
948cdf0e10cSrcweir services.push_back(
949cdf0e10cSrcweir rtl::OUString(
950cdf0e10cSrcweir RTL_CONSTASCII_USTRINGPARAM(
951cdf0e10cSrcweir "com.sun.star.configuration.HierarchyElement")));
952cdf0e10cSrcweir if (getNode()->kind() == Node::KIND_GROUP) {
953cdf0e10cSrcweir services.push_back(
954cdf0e10cSrcweir rtl::OUString(
955cdf0e10cSrcweir RTL_CONSTASCII_USTRINGPARAM(
956cdf0e10cSrcweir "com.sun.star.configuration.GroupAccess")));
957cdf0e10cSrcweir services.push_back(
958cdf0e10cSrcweir rtl::OUString(
959cdf0e10cSrcweir RTL_CONSTASCII_USTRINGPARAM(
960cdf0e10cSrcweir "com.sun.star.configuration.PropertyHierarchy")));
961cdf0e10cSrcweir if (getRootAccess()->isUpdate()) {
962cdf0e10cSrcweir services.push_back(
963cdf0e10cSrcweir rtl::OUString(
964cdf0e10cSrcweir RTL_CONSTASCII_USTRINGPARAM(
965cdf0e10cSrcweir "com.sun.star.configuration.GroupUpdate")));
966cdf0e10cSrcweir }
967cdf0e10cSrcweir } else {
968cdf0e10cSrcweir services.push_back(
969cdf0e10cSrcweir rtl::OUString(
970cdf0e10cSrcweir RTL_CONSTASCII_USTRINGPARAM(
971cdf0e10cSrcweir "com.sun.star.configuration.SetAccess")));
972cdf0e10cSrcweir services.push_back(
973cdf0e10cSrcweir rtl::OUString(
974cdf0e10cSrcweir RTL_CONSTASCII_USTRINGPARAM(
975cdf0e10cSrcweir "com.sun.star.configuration.SimpleSetAccess")));
976cdf0e10cSrcweir if (getRootAccess()->isUpdate()) {
977cdf0e10cSrcweir services.push_back(
978cdf0e10cSrcweir rtl::OUString(
979cdf0e10cSrcweir RTL_CONSTASCII_USTRINGPARAM(
980cdf0e10cSrcweir "com.sun.star.configuration.SetUpdate")));
981cdf0e10cSrcweir services.push_back(
982cdf0e10cSrcweir rtl::OUString(
983cdf0e10cSrcweir RTL_CONSTASCII_USTRINGPARAM(
984cdf0e10cSrcweir "com.sun.star.configuration.SimpleSetUpdate")));
985cdf0e10cSrcweir }
986cdf0e10cSrcweir }
987cdf0e10cSrcweir addSupportedServiceNames(&services);
988cdf0e10cSrcweir return services.getAsConstList();
989cdf0e10cSrcweir }
990cdf0e10cSrcweir
dispose()991cdf0e10cSrcweir void Access::dispose() throw (css::uno::RuntimeException) {
992cdf0e10cSrcweir OSL_ASSERT(thisIs(IS_ANY));
993cdf0e10cSrcweir Broadcaster bc;
994cdf0e10cSrcweir {
995cdf0e10cSrcweir osl::MutexGuard g(lock);
996cdf0e10cSrcweir checkLocalizedPropertyAccess();
997cdf0e10cSrcweir if (getParentAccess().is()) {
998cdf0e10cSrcweir throw css::uno::RuntimeException(
999cdf0e10cSrcweir rtl::OUString(
1000cdf0e10cSrcweir RTL_CONSTASCII_USTRINGPARAM(
1001cdf0e10cSrcweir "configmgr dispose inappropriate Access")),
1002cdf0e10cSrcweir static_cast< cppu::OWeakObject * >(this));
1003cdf0e10cSrcweir }
1004cdf0e10cSrcweir if (disposed_) {
1005cdf0e10cSrcweir return;
1006cdf0e10cSrcweir }
1007cdf0e10cSrcweir initDisposeBroadcaster(&bc);
1008cdf0e10cSrcweir clearListeners();
1009cdf0e10cSrcweir disposed_ = true;
1010cdf0e10cSrcweir }
1011cdf0e10cSrcweir bc.send();
1012cdf0e10cSrcweir }
1013cdf0e10cSrcweir
addEventListener(css::uno::Reference<css::lang::XEventListener> const & xListener)1014cdf0e10cSrcweir void Access::addEventListener(
1015cdf0e10cSrcweir css::uno::Reference< css::lang::XEventListener > const & xListener)
1016cdf0e10cSrcweir throw (css::uno::RuntimeException)
1017cdf0e10cSrcweir {
1018cdf0e10cSrcweir OSL_ASSERT(thisIs(IS_ANY));
1019cdf0e10cSrcweir {
1020cdf0e10cSrcweir osl::MutexGuard g(lock);
1021cdf0e10cSrcweir checkLocalizedPropertyAccess();
1022cdf0e10cSrcweir if (!xListener.is()) {
1023cdf0e10cSrcweir throw css::uno::RuntimeException(
1024cdf0e10cSrcweir rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("null listener")),
1025cdf0e10cSrcweir static_cast< cppu::OWeakObject * >(this));
1026cdf0e10cSrcweir }
1027cdf0e10cSrcweir if (!disposed_) {
1028cdf0e10cSrcweir disposeListeners_.insert(xListener);
1029cdf0e10cSrcweir return;
1030cdf0e10cSrcweir }
1031cdf0e10cSrcweir }
1032cdf0e10cSrcweir try {
1033cdf0e10cSrcweir xListener->disposing(
1034cdf0e10cSrcweir css::lang::EventObject(static_cast< cppu::OWeakObject * >(this)));
1035cdf0e10cSrcweir } catch (css::lang::DisposedException &) {}
1036cdf0e10cSrcweir }
1037cdf0e10cSrcweir
removeEventListener(css::uno::Reference<css::lang::XEventListener> const & aListener)1038cdf0e10cSrcweir void Access::removeEventListener(
1039cdf0e10cSrcweir css::uno::Reference< css::lang::XEventListener > const & aListener)
1040cdf0e10cSrcweir throw (css::uno::RuntimeException)
1041cdf0e10cSrcweir {
1042cdf0e10cSrcweir OSL_ASSERT(thisIs(IS_ANY));
1043cdf0e10cSrcweir osl::MutexGuard g(lock);
1044cdf0e10cSrcweir checkLocalizedPropertyAccess();
1045cdf0e10cSrcweir DisposeListeners::iterator i(disposeListeners_.find(aListener));
1046cdf0e10cSrcweir if (i != disposeListeners_.end()) {
1047cdf0e10cSrcweir disposeListeners_.erase(i);
1048cdf0e10cSrcweir }
1049cdf0e10cSrcweir }
1050cdf0e10cSrcweir
getElementType()1051cdf0e10cSrcweir css::uno::Type Access::getElementType() throw (css::uno::RuntimeException) {
1052cdf0e10cSrcweir OSL_ASSERT(thisIs(IS_ANY));
1053cdf0e10cSrcweir osl::MutexGuard g(lock);
1054cdf0e10cSrcweir checkLocalizedPropertyAccess();
1055cdf0e10cSrcweir rtl::Reference< Node > p(getNode());
1056cdf0e10cSrcweir switch (p->kind()) {
1057cdf0e10cSrcweir case Node::KIND_LOCALIZED_PROPERTY:
1058cdf0e10cSrcweir return mapType(
1059cdf0e10cSrcweir dynamic_cast< LocalizedPropertyNode * >(p.get())->getStaticType());
1060cdf0e10cSrcweir case Node::KIND_GROUP:
1061cdf0e10cSrcweir //TODO: Should a specific type be returned for a non-extensible group
1062cdf0e10cSrcweir // with homogeneous members or for an extensible group that currently
1063cdf0e10cSrcweir // has only homegeneous members?
1064cdf0e10cSrcweir return cppu::UnoType< cppu::UnoVoidType >::get();
1065cdf0e10cSrcweir case Node::KIND_SET:
1066cdf0e10cSrcweir return cppu::UnoType< cppu::UnoVoidType >::get(); //TODO: correct?
1067cdf0e10cSrcweir default:
1068cdf0e10cSrcweir OSL_ASSERT(false);
1069cdf0e10cSrcweir throw css::uno::RuntimeException(
1070cdf0e10cSrcweir rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("this cannot happen")),
1071cdf0e10cSrcweir static_cast< cppu::OWeakObject * >(this));
1072cdf0e10cSrcweir }
1073cdf0e10cSrcweir }
1074cdf0e10cSrcweir
hasElements()1075cdf0e10cSrcweir sal_Bool Access::hasElements() throw (css::uno::RuntimeException) {
1076cdf0e10cSrcweir OSL_ASSERT(thisIs(IS_ANY));
1077cdf0e10cSrcweir osl::MutexGuard g(lock);
1078cdf0e10cSrcweir checkLocalizedPropertyAccess();
1079cdf0e10cSrcweir return !getAllChildren().empty(); //TODO: optimize
1080cdf0e10cSrcweir }
1081cdf0e10cSrcweir
getByName(rtl::OUString const & aName)1082cdf0e10cSrcweir css::uno::Any Access::getByName(rtl::OUString const & aName)
1083cdf0e10cSrcweir throw (
1084cdf0e10cSrcweir css::container::NoSuchElementException,
1085cdf0e10cSrcweir css::lang::WrappedTargetException, css::uno::RuntimeException)
1086cdf0e10cSrcweir {
1087cdf0e10cSrcweir OSL_ASSERT(thisIs(IS_ANY));
1088cdf0e10cSrcweir osl::MutexGuard g(lock);
1089cdf0e10cSrcweir checkLocalizedPropertyAccess();
1090cdf0e10cSrcweir rtl::Reference< ChildAccess > child(getChild(aName));
1091cdf0e10cSrcweir if (!child.is()) {
1092cdf0e10cSrcweir throw css::container::NoSuchElementException(
1093cdf0e10cSrcweir aName, static_cast< cppu::OWeakObject * >(this));
1094cdf0e10cSrcweir }
1095cdf0e10cSrcweir return child->asValue();
1096cdf0e10cSrcweir }
1097cdf0e10cSrcweir
getElementNames()1098cdf0e10cSrcweir css::uno::Sequence< rtl::OUString > Access::getElementNames()
1099cdf0e10cSrcweir throw (css::uno::RuntimeException)
1100cdf0e10cSrcweir {
1101cdf0e10cSrcweir OSL_ASSERT(thisIs(IS_ANY));
1102cdf0e10cSrcweir osl::MutexGuard g(lock);
1103cdf0e10cSrcweir checkLocalizedPropertyAccess();
1104cdf0e10cSrcweir std::vector< rtl::Reference< ChildAccess > > children(getAllChildren());
1105cdf0e10cSrcweir comphelper::SequenceAsVector< rtl::OUString > names;
1106cdf0e10cSrcweir for (std::vector< rtl::Reference< ChildAccess > >::iterator i(
1107cdf0e10cSrcweir children.begin());
1108cdf0e10cSrcweir i != children.end(); ++i)
1109cdf0e10cSrcweir {
1110cdf0e10cSrcweir names.push_back((*i)->getNameInternal());
1111cdf0e10cSrcweir }
1112cdf0e10cSrcweir return names.getAsConstList();
1113cdf0e10cSrcweir }
1114cdf0e10cSrcweir
hasByName(rtl::OUString const & aName)1115cdf0e10cSrcweir sal_Bool Access::hasByName(rtl::OUString const & aName)
1116cdf0e10cSrcweir throw (css::uno::RuntimeException)
1117cdf0e10cSrcweir {
1118cdf0e10cSrcweir OSL_ASSERT(thisIs(IS_ANY));
1119cdf0e10cSrcweir osl::MutexGuard g(lock);
1120cdf0e10cSrcweir checkLocalizedPropertyAccess();
1121cdf0e10cSrcweir return getChild(aName).is();
1122cdf0e10cSrcweir }
1123cdf0e10cSrcweir
getByHierarchicalName(rtl::OUString const & aName)1124cdf0e10cSrcweir css::uno::Any Access::getByHierarchicalName(rtl::OUString const & aName)
1125cdf0e10cSrcweir throw (css::container::NoSuchElementException, css::uno::RuntimeException)
1126cdf0e10cSrcweir {
1127cdf0e10cSrcweir OSL_ASSERT(thisIs(IS_ANY));
1128cdf0e10cSrcweir osl::MutexGuard g(lock);
1129cdf0e10cSrcweir checkLocalizedPropertyAccess();
1130cdf0e10cSrcweir rtl::Reference< ChildAccess > child(getSubChild(aName));
1131cdf0e10cSrcweir if (!child.is()) {
1132cdf0e10cSrcweir throw css::container::NoSuchElementException(
1133cdf0e10cSrcweir aName, static_cast< cppu::OWeakObject * >(this));
1134cdf0e10cSrcweir }
1135cdf0e10cSrcweir return child->asValue();
1136cdf0e10cSrcweir }
1137cdf0e10cSrcweir
hasByHierarchicalName(rtl::OUString const & aName)1138cdf0e10cSrcweir sal_Bool Access::hasByHierarchicalName(rtl::OUString const & aName)
1139cdf0e10cSrcweir throw (css::uno::RuntimeException)
1140cdf0e10cSrcweir {
1141cdf0e10cSrcweir OSL_ASSERT(thisIs(IS_ANY));
1142cdf0e10cSrcweir osl::MutexGuard g(lock);
1143cdf0e10cSrcweir checkLocalizedPropertyAccess();
1144cdf0e10cSrcweir return getSubChild(aName).is();
1145cdf0e10cSrcweir }
1146cdf0e10cSrcweir
addContainerListener(css::uno::Reference<css::container::XContainerListener> const & xListener)1147cdf0e10cSrcweir void Access::addContainerListener(
1148cdf0e10cSrcweir css::uno::Reference< css::container::XContainerListener > const & xListener)
1149cdf0e10cSrcweir throw (css::uno::RuntimeException)
1150cdf0e10cSrcweir {
1151cdf0e10cSrcweir OSL_ASSERT(thisIs(IS_ANY));
1152cdf0e10cSrcweir {
1153cdf0e10cSrcweir osl::MutexGuard g(lock);
1154cdf0e10cSrcweir checkLocalizedPropertyAccess();
1155cdf0e10cSrcweir if (!xListener.is()) {
1156cdf0e10cSrcweir throw css::uno::RuntimeException(
1157cdf0e10cSrcweir rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("null listener")),
1158cdf0e10cSrcweir static_cast< cppu::OWeakObject * >(this));
1159cdf0e10cSrcweir }
1160cdf0e10cSrcweir if (!disposed_) {
1161cdf0e10cSrcweir containerListeners_.insert(xListener);
1162cdf0e10cSrcweir return;
1163cdf0e10cSrcweir }
1164cdf0e10cSrcweir }
1165cdf0e10cSrcweir try {
1166cdf0e10cSrcweir xListener->disposing(
1167cdf0e10cSrcweir css::lang::EventObject(static_cast< cppu::OWeakObject * >(this)));
1168cdf0e10cSrcweir } catch (css::lang::DisposedException &) {}
1169cdf0e10cSrcweir }
1170cdf0e10cSrcweir
removeContainerListener(css::uno::Reference<css::container::XContainerListener> const & xListener)1171cdf0e10cSrcweir void Access::removeContainerListener(
1172cdf0e10cSrcweir css::uno::Reference< css::container::XContainerListener > const & xListener)
1173cdf0e10cSrcweir throw (css::uno::RuntimeException)
1174cdf0e10cSrcweir {
1175cdf0e10cSrcweir OSL_ASSERT(thisIs(IS_ANY));
1176cdf0e10cSrcweir osl::MutexGuard g(lock);
1177cdf0e10cSrcweir checkLocalizedPropertyAccess();
1178cdf0e10cSrcweir ContainerListeners::iterator i(containerListeners_.find(xListener));
1179cdf0e10cSrcweir if (i != containerListeners_.end()) {
1180cdf0e10cSrcweir containerListeners_.erase(i);
1181cdf0e10cSrcweir }
1182cdf0e10cSrcweir }
1183cdf0e10cSrcweir
getExactName(rtl::OUString const & aApproximateName)1184cdf0e10cSrcweir rtl::OUString Access::getExactName(rtl::OUString const & aApproximateName)
1185cdf0e10cSrcweir throw (css::uno::RuntimeException)
1186cdf0e10cSrcweir {
1187cdf0e10cSrcweir OSL_ASSERT(thisIs(IS_ANY));
1188cdf0e10cSrcweir osl::MutexGuard g(lock);
1189cdf0e10cSrcweir checkLocalizedPropertyAccess();
1190cdf0e10cSrcweir return aApproximateName;
1191cdf0e10cSrcweir }
1192cdf0e10cSrcweir
getProperties()1193cdf0e10cSrcweir css::uno::Sequence< css::beans::Property > Access::getProperties()
1194cdf0e10cSrcweir throw (css::uno::RuntimeException)
1195cdf0e10cSrcweir {
1196cdf0e10cSrcweir OSL_ASSERT(thisIs(IS_GROUP));
1197cdf0e10cSrcweir osl::MutexGuard g(lock);
1198cdf0e10cSrcweir std::vector< rtl::Reference< ChildAccess > > children(getAllChildren());
1199cdf0e10cSrcweir comphelper::SequenceAsVector< css::beans::Property > properties;
1200cdf0e10cSrcweir for (std::vector< rtl::Reference< ChildAccess > >::iterator i(
1201cdf0e10cSrcweir children.begin());
1202cdf0e10cSrcweir i != children.end(); ++i)
1203cdf0e10cSrcweir {
1204cdf0e10cSrcweir properties.push_back((*i)->asProperty());
1205cdf0e10cSrcweir }
1206cdf0e10cSrcweir return properties.getAsConstList();
1207cdf0e10cSrcweir }
1208cdf0e10cSrcweir
getPropertyByName(rtl::OUString const & aName)1209cdf0e10cSrcweir css::beans::Property Access::getPropertyByName(rtl::OUString const & aName)
1210cdf0e10cSrcweir throw (css::beans::UnknownPropertyException, css::uno::RuntimeException)
1211cdf0e10cSrcweir {
1212cdf0e10cSrcweir OSL_ASSERT(thisIs(IS_GROUP));
1213cdf0e10cSrcweir osl::MutexGuard g(lock);
1214cdf0e10cSrcweir rtl::Reference< ChildAccess > child(getChild(aName));
1215cdf0e10cSrcweir if (!child.is()) {
1216cdf0e10cSrcweir throw css::beans::UnknownPropertyException(
1217cdf0e10cSrcweir aName, static_cast< cppu::OWeakObject * >(this));
1218cdf0e10cSrcweir }
1219cdf0e10cSrcweir return child->asProperty();
1220cdf0e10cSrcweir }
1221cdf0e10cSrcweir
hasPropertyByName(rtl::OUString const & Name)1222cdf0e10cSrcweir sal_Bool Access::hasPropertyByName(rtl::OUString const & Name)
1223cdf0e10cSrcweir throw (css::uno::RuntimeException)
1224cdf0e10cSrcweir {
1225cdf0e10cSrcweir OSL_ASSERT(thisIs(IS_GROUP));
1226cdf0e10cSrcweir osl::MutexGuard g(lock);
1227cdf0e10cSrcweir return getChild(Name).is();
1228cdf0e10cSrcweir }
1229cdf0e10cSrcweir
getHierarchicalName()1230cdf0e10cSrcweir rtl::OUString Access::getHierarchicalName() throw (css::uno::RuntimeException) {
1231cdf0e10cSrcweir OSL_ASSERT(thisIs(IS_ANY));
1232cdf0e10cSrcweir osl::MutexGuard g(lock);
1233cdf0e10cSrcweir checkLocalizedPropertyAccess();
1234cdf0e10cSrcweir // For backwards compatibility, return an absolute path representation where
1235cdf0e10cSrcweir // available:
1236cdf0e10cSrcweir rtl::OUStringBuffer path;
1237cdf0e10cSrcweir rtl::Reference< RootAccess > root(getRootAccess());
1238cdf0e10cSrcweir if (root.is()) {
1239cdf0e10cSrcweir path.append(root->getAbsolutePathRepresentation());
1240cdf0e10cSrcweir }
1241cdf0e10cSrcweir rtl::OUString rel(getRelativePathRepresentation());
1242cdf0e10cSrcweir if (path.getLength() != 0 && rel.getLength() != 0) {
1243cdf0e10cSrcweir path.append(sal_Unicode('/'));
1244cdf0e10cSrcweir }
1245cdf0e10cSrcweir path.append(rel);
1246cdf0e10cSrcweir return path.makeStringAndClear();
1247cdf0e10cSrcweir }
1248cdf0e10cSrcweir
composeHierarchicalName(rtl::OUString const & aRelativeName)1249cdf0e10cSrcweir rtl::OUString Access::composeHierarchicalName(
1250cdf0e10cSrcweir rtl::OUString const & aRelativeName)
1251cdf0e10cSrcweir throw (
1252cdf0e10cSrcweir css::lang::IllegalArgumentException, css::lang::NoSupportException,
1253cdf0e10cSrcweir css::uno::RuntimeException)
1254cdf0e10cSrcweir {
1255cdf0e10cSrcweir OSL_ASSERT(thisIs(IS_ANY));
1256cdf0e10cSrcweir osl::MutexGuard g(lock);
1257cdf0e10cSrcweir checkLocalizedPropertyAccess();
1258cdf0e10cSrcweir if (aRelativeName.getLength() == 0 || aRelativeName[0] == '/') {
1259cdf0e10cSrcweir throw css::lang::IllegalArgumentException(
1260cdf0e10cSrcweir rtl::OUString(
1261cdf0e10cSrcweir RTL_CONSTASCII_USTRINGPARAM(
1262cdf0e10cSrcweir "configmgr composeHierarchicalName inappropriate relative"
1263cdf0e10cSrcweir " name")),
1264cdf0e10cSrcweir static_cast< cppu::OWeakObject * >(this), -1);
1265cdf0e10cSrcweir }
1266cdf0e10cSrcweir rtl::OUStringBuffer path(getRelativePathRepresentation());
1267cdf0e10cSrcweir if (path.getLength() != 0) {
1268cdf0e10cSrcweir path.append(sal_Unicode('/'));
1269cdf0e10cSrcweir }
1270cdf0e10cSrcweir path.append(aRelativeName);
1271cdf0e10cSrcweir return path.makeStringAndClear();
1272cdf0e10cSrcweir }
1273cdf0e10cSrcweir
getName()1274cdf0e10cSrcweir rtl::OUString Access::getName() throw (css::uno::RuntimeException) {
1275cdf0e10cSrcweir OSL_ASSERT(thisIs(IS_ANY));
1276cdf0e10cSrcweir osl::MutexGuard g(lock);
1277cdf0e10cSrcweir checkLocalizedPropertyAccess();
1278cdf0e10cSrcweir return getNameInternal();
1279cdf0e10cSrcweir }
1280cdf0e10cSrcweir
setName(rtl::OUString const & aName)1281cdf0e10cSrcweir void Access::setName(rtl::OUString const & aName)
1282cdf0e10cSrcweir throw (css::uno::RuntimeException)
1283cdf0e10cSrcweir {
1284cdf0e10cSrcweir OSL_ASSERT(thisIs(IS_ANY));
1285cdf0e10cSrcweir Broadcaster bc;
1286cdf0e10cSrcweir {
1287cdf0e10cSrcweir osl::MutexGuard g(lock);
1288cdf0e10cSrcweir checkLocalizedPropertyAccess();
1289cdf0e10cSrcweir checkFinalized();
1290cdf0e10cSrcweir Modifications localMods;
1291cdf0e10cSrcweir switch (getNode()->kind()) {
1292cdf0e10cSrcweir case Node::KIND_GROUP:
1293cdf0e10cSrcweir case Node::KIND_SET:
1294cdf0e10cSrcweir {
1295cdf0e10cSrcweir rtl::Reference< Access > parent(getParentAccess());
1296cdf0e10cSrcweir if (parent.is()) {
1297cdf0e10cSrcweir rtl::Reference< Node > node(getNode());
1298cdf0e10cSrcweir if (node->getTemplateName().getLength() != 0) {
1299cdf0e10cSrcweir rtl::Reference< ChildAccess > other(
1300cdf0e10cSrcweir parent->getChild(aName));
1301cdf0e10cSrcweir if (other.get() == this) {
1302cdf0e10cSrcweir break;
1303cdf0e10cSrcweir }
1304cdf0e10cSrcweir if (node->getMandatory() == Data::NO_LAYER &&
1305cdf0e10cSrcweir !(other.is() && other->isFinalized()))
1306cdf0e10cSrcweir {
1307cdf0e10cSrcweir rtl::Reference< RootAccess > root(getRootAccess());
1308cdf0e10cSrcweir rtl::Reference< ChildAccess > childAccess(
1309cdf0e10cSrcweir dynamic_cast< ChildAccess * >(this));
1310cdf0e10cSrcweir localMods.add(getRelativePath());
1311cdf0e10cSrcweir // unbind() modifies the parent chain that
1312cdf0e10cSrcweir // markChildAsModified() walks, so order is
1313cdf0e10cSrcweir // important:
1314cdf0e10cSrcweir parent->markChildAsModified(childAccess);
1315cdf0e10cSrcweir //TODO: must not throw
1316cdf0e10cSrcweir childAccess->unbind(); // must not throw
1317cdf0e10cSrcweir if (other.is()) {
1318cdf0e10cSrcweir other->unbind(); // must not throw
1319cdf0e10cSrcweir }
1320cdf0e10cSrcweir childAccess->bind(root, parent, aName);
1321cdf0e10cSrcweir // must not throw
1322cdf0e10cSrcweir parent->markChildAsModified(childAccess);
1323cdf0e10cSrcweir //TODO: must not throw
1324cdf0e10cSrcweir localMods.add(getRelativePath());
1325cdf0e10cSrcweir break;
1326cdf0e10cSrcweir }
1327cdf0e10cSrcweir }
1328cdf0e10cSrcweir }
1329cdf0e10cSrcweir }
1330cdf0e10cSrcweir // fall through
1331cdf0e10cSrcweir case Node::KIND_LOCALIZED_PROPERTY:
1332cdf0e10cSrcweir // renaming a property could only work for an extension property,
1333cdf0e10cSrcweir // but a localized property is never an extension property
1334cdf0e10cSrcweir throw css::uno::RuntimeException(
1335cdf0e10cSrcweir rtl::OUString(
1336cdf0e10cSrcweir RTL_CONSTASCII_USTRINGPARAM(
1337cdf0e10cSrcweir "configmgr setName inappropriate node")),
1338cdf0e10cSrcweir static_cast< cppu::OWeakObject * >(this));
1339cdf0e10cSrcweir default:
1340cdf0e10cSrcweir OSL_ASSERT(false); // this cannot happen
1341cdf0e10cSrcweir break;
1342cdf0e10cSrcweir }
1343cdf0e10cSrcweir getNotificationRoot()->initBroadcaster(localMods.getRoot(), &bc);
1344cdf0e10cSrcweir }
1345cdf0e10cSrcweir bc.send();
1346cdf0e10cSrcweir }
1347cdf0e10cSrcweir
getAsProperty()1348cdf0e10cSrcweir css::beans::Property Access::getAsProperty() throw (css::uno::RuntimeException)
1349cdf0e10cSrcweir {
1350cdf0e10cSrcweir OSL_ASSERT(thisIs(IS_ANY));
1351cdf0e10cSrcweir osl::MutexGuard g(lock);
1352cdf0e10cSrcweir checkLocalizedPropertyAccess();
1353cdf0e10cSrcweir return asProperty();
1354cdf0e10cSrcweir }
1355cdf0e10cSrcweir
getPropertySetInfo()1356cdf0e10cSrcweir css::uno::Reference< css::beans::XPropertySetInfo > Access::getPropertySetInfo()
1357cdf0e10cSrcweir throw (css::uno::RuntimeException)
1358cdf0e10cSrcweir {
1359cdf0e10cSrcweir OSL_ASSERT(thisIs(IS_GROUP));
1360cdf0e10cSrcweir return this;
1361cdf0e10cSrcweir }
1362cdf0e10cSrcweir
setPropertyValue(rtl::OUString const & aPropertyName,css::uno::Any const & aValue)1363cdf0e10cSrcweir void Access::setPropertyValue(
1364cdf0e10cSrcweir rtl::OUString const & aPropertyName, css::uno::Any const & aValue)
1365cdf0e10cSrcweir throw (
1366cdf0e10cSrcweir css::beans::UnknownPropertyException, css::beans::PropertyVetoException,
1367cdf0e10cSrcweir css::lang::IllegalArgumentException, css::lang::WrappedTargetException,
1368cdf0e10cSrcweir css::uno::RuntimeException)
1369cdf0e10cSrcweir {
1370cdf0e10cSrcweir OSL_ASSERT(thisIs(IS_GROUP));
1371cdf0e10cSrcweir Broadcaster bc;
1372cdf0e10cSrcweir {
1373cdf0e10cSrcweir osl::MutexGuard g(lock);
1374cdf0e10cSrcweir if (!getRootAccess()->isUpdate()) {
1375cdf0e10cSrcweir throw css::uno::RuntimeException(
1376cdf0e10cSrcweir rtl::OUString(
1377cdf0e10cSrcweir RTL_CONSTASCII_USTRINGPARAM(
1378cdf0e10cSrcweir "configmgr setPropertyValue on non-update access")),
1379cdf0e10cSrcweir static_cast< cppu::OWeakObject * >(this));
1380cdf0e10cSrcweir }
1381cdf0e10cSrcweir Modifications localMods;
1382cdf0e10cSrcweir if (!setChildProperty(aPropertyName, aValue, &localMods)) {
1383cdf0e10cSrcweir throw css::beans::UnknownPropertyException(
1384cdf0e10cSrcweir aPropertyName, static_cast< cppu::OWeakObject * >(this));
1385cdf0e10cSrcweir }
1386cdf0e10cSrcweir getNotificationRoot()->initBroadcaster(localMods.getRoot(), &bc);
1387cdf0e10cSrcweir }
1388cdf0e10cSrcweir bc.send();
1389cdf0e10cSrcweir }
1390cdf0e10cSrcweir
getPropertyValue(rtl::OUString const & PropertyName)1391cdf0e10cSrcweir css::uno::Any Access::getPropertyValue(rtl::OUString const & PropertyName)
1392cdf0e10cSrcweir throw (
1393cdf0e10cSrcweir css::beans::UnknownPropertyException, css::lang::WrappedTargetException,
1394cdf0e10cSrcweir css::uno::RuntimeException)
1395cdf0e10cSrcweir {
1396cdf0e10cSrcweir OSL_ASSERT(thisIs(IS_GROUP));
1397cdf0e10cSrcweir osl::MutexGuard g(lock);
1398cdf0e10cSrcweir rtl::Reference< ChildAccess > child(getChild(PropertyName));
1399cdf0e10cSrcweir if (!child.is()) {
1400cdf0e10cSrcweir throw css::beans::UnknownPropertyException(
1401cdf0e10cSrcweir PropertyName, static_cast< cppu::OWeakObject * >(this));
1402cdf0e10cSrcweir }
1403cdf0e10cSrcweir return child->asValue();
1404cdf0e10cSrcweir }
1405cdf0e10cSrcweir
addPropertyChangeListener(rtl::OUString const & aPropertyName,css::uno::Reference<css::beans::XPropertyChangeListener> const & xListener)1406cdf0e10cSrcweir void Access::addPropertyChangeListener(
1407cdf0e10cSrcweir rtl::OUString const & aPropertyName,
1408cdf0e10cSrcweir css::uno::Reference< css::beans::XPropertyChangeListener > const &
1409cdf0e10cSrcweir xListener)
1410cdf0e10cSrcweir throw (
1411cdf0e10cSrcweir css::beans::UnknownPropertyException, css::lang::WrappedTargetException,
1412cdf0e10cSrcweir css::uno::RuntimeException)
1413cdf0e10cSrcweir {
1414cdf0e10cSrcweir OSL_ASSERT(thisIs(IS_GROUP));
1415cdf0e10cSrcweir {
1416cdf0e10cSrcweir osl::MutexGuard g(lock);
1417cdf0e10cSrcweir if (!xListener.is()) {
1418cdf0e10cSrcweir throw css::uno::RuntimeException(
1419cdf0e10cSrcweir rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("null listener")),
1420cdf0e10cSrcweir static_cast< cppu::OWeakObject * >(this));
1421cdf0e10cSrcweir }
1422cdf0e10cSrcweir checkKnownProperty(aPropertyName);
1423cdf0e10cSrcweir if (!disposed_) {
1424cdf0e10cSrcweir propertyChangeListeners_[aPropertyName].insert(xListener);
1425cdf0e10cSrcweir return;
1426cdf0e10cSrcweir }
1427cdf0e10cSrcweir }
1428cdf0e10cSrcweir try {
1429cdf0e10cSrcweir xListener->disposing(
1430cdf0e10cSrcweir css::lang::EventObject(static_cast< cppu::OWeakObject * >(this)));
1431cdf0e10cSrcweir } catch (css::lang::DisposedException &) {}
1432cdf0e10cSrcweir }
1433cdf0e10cSrcweir
removePropertyChangeListener(rtl::OUString const & aPropertyName,css::uno::Reference<css::beans::XPropertyChangeListener> const & aListener)1434cdf0e10cSrcweir void Access::removePropertyChangeListener(
1435cdf0e10cSrcweir rtl::OUString const & aPropertyName,
1436cdf0e10cSrcweir css::uno::Reference< css::beans::XPropertyChangeListener > const &
1437cdf0e10cSrcweir aListener)
1438cdf0e10cSrcweir throw (
1439cdf0e10cSrcweir css::beans::UnknownPropertyException, css::lang::WrappedTargetException,
1440cdf0e10cSrcweir css::uno::RuntimeException)
1441cdf0e10cSrcweir {
1442cdf0e10cSrcweir OSL_ASSERT(thisIs(IS_GROUP));
1443cdf0e10cSrcweir osl::MutexGuard g(lock);
1444cdf0e10cSrcweir checkKnownProperty(aPropertyName);
1445cdf0e10cSrcweir PropertyChangeListeners::iterator i(
1446cdf0e10cSrcweir propertyChangeListeners_.find(aPropertyName));
1447cdf0e10cSrcweir if (i != propertyChangeListeners_.end()) {
1448cdf0e10cSrcweir PropertyChangeListenersElement::iterator j(i->second.find(aListener));
1449cdf0e10cSrcweir if (j != i->second.end()) {
1450cdf0e10cSrcweir i->second.erase(j);
1451cdf0e10cSrcweir if (i->second.empty()) {
1452cdf0e10cSrcweir propertyChangeListeners_.erase(i);
1453cdf0e10cSrcweir }
1454cdf0e10cSrcweir }
1455cdf0e10cSrcweir }
1456cdf0e10cSrcweir }
1457cdf0e10cSrcweir
addVetoableChangeListener(rtl::OUString const & PropertyName,css::uno::Reference<css::beans::XVetoableChangeListener> const & aListener)1458cdf0e10cSrcweir void Access::addVetoableChangeListener(
1459cdf0e10cSrcweir rtl::OUString const & PropertyName,
1460cdf0e10cSrcweir css::uno::Reference< css::beans::XVetoableChangeListener > const &
1461cdf0e10cSrcweir aListener)
1462cdf0e10cSrcweir throw (
1463cdf0e10cSrcweir css::beans::UnknownPropertyException, css::lang::WrappedTargetException,
1464cdf0e10cSrcweir css::uno::RuntimeException)
1465cdf0e10cSrcweir {
1466cdf0e10cSrcweir OSL_ASSERT(thisIs(IS_GROUP));
1467cdf0e10cSrcweir {
1468cdf0e10cSrcweir osl::MutexGuard g(lock);
1469cdf0e10cSrcweir if (!aListener.is()) {
1470cdf0e10cSrcweir throw css::uno::RuntimeException(
1471cdf0e10cSrcweir rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("null listener")),
1472cdf0e10cSrcweir static_cast< cppu::OWeakObject * >(this));
1473cdf0e10cSrcweir }
1474cdf0e10cSrcweir checkKnownProperty(PropertyName);
1475cdf0e10cSrcweir if (!disposed_) {
1476cdf0e10cSrcweir vetoableChangeListeners_[PropertyName].insert(aListener);
1477cdf0e10cSrcweir //TODO: actually call vetoableChangeListeners_
1478cdf0e10cSrcweir return;
1479cdf0e10cSrcweir }
1480cdf0e10cSrcweir }
1481cdf0e10cSrcweir try {
1482cdf0e10cSrcweir aListener->disposing(
1483cdf0e10cSrcweir css::lang::EventObject(static_cast< cppu::OWeakObject * >(this)));
1484cdf0e10cSrcweir } catch (css::lang::DisposedException &) {}
1485cdf0e10cSrcweir }
1486cdf0e10cSrcweir
removeVetoableChangeListener(rtl::OUString const & PropertyName,css::uno::Reference<css::beans::XVetoableChangeListener> const & aListener)1487cdf0e10cSrcweir void Access::removeVetoableChangeListener(
1488cdf0e10cSrcweir rtl::OUString const & PropertyName,
1489cdf0e10cSrcweir css::uno::Reference< css::beans::XVetoableChangeListener > const &
1490cdf0e10cSrcweir aListener)
1491cdf0e10cSrcweir throw (
1492cdf0e10cSrcweir css::beans::UnknownPropertyException, css::lang::WrappedTargetException,
1493cdf0e10cSrcweir css::uno::RuntimeException)
1494cdf0e10cSrcweir {
1495cdf0e10cSrcweir OSL_ASSERT(thisIs(IS_GROUP));
1496cdf0e10cSrcweir osl::MutexGuard g(lock);
1497cdf0e10cSrcweir checkKnownProperty(PropertyName);
1498cdf0e10cSrcweir VetoableChangeListeners::iterator i(
1499cdf0e10cSrcweir vetoableChangeListeners_.find(PropertyName));
1500cdf0e10cSrcweir if (i != vetoableChangeListeners_.end()) {
1501cdf0e10cSrcweir VetoableChangeListenersElement::iterator j(i->second.find(aListener));
1502cdf0e10cSrcweir if (j != i->second.end()) {
1503cdf0e10cSrcweir i->second.erase(j);
1504cdf0e10cSrcweir if (i->second.empty()) {
1505cdf0e10cSrcweir vetoableChangeListeners_.erase(i);
1506cdf0e10cSrcweir }
1507cdf0e10cSrcweir }
1508cdf0e10cSrcweir }
1509cdf0e10cSrcweir }
1510cdf0e10cSrcweir
setPropertyValues(css::uno::Sequence<rtl::OUString> const & aPropertyNames,css::uno::Sequence<css::uno::Any> const & aValues)1511cdf0e10cSrcweir void Access::setPropertyValues(
1512cdf0e10cSrcweir css::uno::Sequence< rtl::OUString > const & aPropertyNames,
1513cdf0e10cSrcweir css::uno::Sequence< css::uno::Any > const & aValues)
1514cdf0e10cSrcweir throw (
1515cdf0e10cSrcweir css::beans::PropertyVetoException, css::lang::IllegalArgumentException,
1516cdf0e10cSrcweir css::lang::WrappedTargetException, css::uno::RuntimeException)
1517cdf0e10cSrcweir {
1518cdf0e10cSrcweir OSL_ASSERT(thisIs(IS_GROUP));
1519cdf0e10cSrcweir Broadcaster bc;
1520cdf0e10cSrcweir {
1521cdf0e10cSrcweir osl::MutexGuard g(lock);
1522cdf0e10cSrcweir if (!getRootAccess()->isUpdate()) {
1523cdf0e10cSrcweir throw css::uno::RuntimeException(
1524cdf0e10cSrcweir rtl::OUString(
1525cdf0e10cSrcweir RTL_CONSTASCII_USTRINGPARAM(
1526cdf0e10cSrcweir "configmgr setPropertyValues on non-update access")),
1527cdf0e10cSrcweir static_cast< cppu::OWeakObject * >(this));
1528cdf0e10cSrcweir }
1529cdf0e10cSrcweir if (aPropertyNames.getLength() != aValues.getLength()) {
1530cdf0e10cSrcweir throw css::lang::IllegalArgumentException(
1531cdf0e10cSrcweir rtl::OUString(
1532cdf0e10cSrcweir RTL_CONSTASCII_USTRINGPARAM(
1533cdf0e10cSrcweir "configmgr setPropertyValues: aPropertyNames/aValues of"
1534cdf0e10cSrcweir " different length")),
1535cdf0e10cSrcweir static_cast< cppu::OWeakObject * >(this), -1);
1536cdf0e10cSrcweir }
1537cdf0e10cSrcweir Modifications localMods;
1538cdf0e10cSrcweir for (sal_Int32 i = 0; i < aPropertyNames.getLength(); ++i) {
1539cdf0e10cSrcweir if (!setChildProperty(aPropertyNames[i], aValues[i], &localMods)) {
1540cdf0e10cSrcweir throw css::lang::IllegalArgumentException(
1541cdf0e10cSrcweir rtl::OUString(
1542cdf0e10cSrcweir RTL_CONSTASCII_USTRINGPARAM(
1543cdf0e10cSrcweir "configmgr setPropertyValues inappropriate property"
1544cdf0e10cSrcweir " name")),
1545cdf0e10cSrcweir static_cast< cppu::OWeakObject * >(this), -1);
1546cdf0e10cSrcweir }
1547cdf0e10cSrcweir }
1548cdf0e10cSrcweir getNotificationRoot()->initBroadcaster(localMods.getRoot(), &bc);
1549cdf0e10cSrcweir }
1550cdf0e10cSrcweir bc.send();
1551cdf0e10cSrcweir }
1552cdf0e10cSrcweir
getPropertyValues(css::uno::Sequence<rtl::OUString> const & aPropertyNames)1553cdf0e10cSrcweir css::uno::Sequence< css::uno::Any > Access::getPropertyValues(
1554cdf0e10cSrcweir css::uno::Sequence< rtl::OUString > const & aPropertyNames)
1555cdf0e10cSrcweir throw (css::uno::RuntimeException)
1556cdf0e10cSrcweir {
1557cdf0e10cSrcweir OSL_ASSERT(thisIs(IS_GROUP));
1558cdf0e10cSrcweir osl::MutexGuard g(lock);
1559cdf0e10cSrcweir css::uno::Sequence< css::uno::Any > vals(aPropertyNames.getLength());
1560cdf0e10cSrcweir for (sal_Int32 i = 0; i < aPropertyNames.getLength(); ++i) {
1561cdf0e10cSrcweir rtl::Reference< ChildAccess > child(getChild(aPropertyNames[i]));
1562cdf0e10cSrcweir if (!child.is()) {
1563cdf0e10cSrcweir throw css::uno::RuntimeException(
1564cdf0e10cSrcweir rtl::OUString(
1565cdf0e10cSrcweir RTL_CONSTASCII_USTRINGPARAM(
1566cdf0e10cSrcweir "configmgr getPropertyValues inappropriate property"
1567cdf0e10cSrcweir " name")),
1568cdf0e10cSrcweir static_cast< cppu::OWeakObject * >(this));
1569cdf0e10cSrcweir }
1570cdf0e10cSrcweir vals[i] = child->asValue();
1571cdf0e10cSrcweir }
1572cdf0e10cSrcweir return vals;
1573cdf0e10cSrcweir }
1574cdf0e10cSrcweir
addPropertiesChangeListener(css::uno::Sequence<rtl::OUString> const &,css::uno::Reference<css::beans::XPropertiesChangeListener> const & xListener)1575cdf0e10cSrcweir void Access::addPropertiesChangeListener(
1576cdf0e10cSrcweir css::uno::Sequence< rtl::OUString > const &,
1577cdf0e10cSrcweir css::uno::Reference< css::beans::XPropertiesChangeListener > const &
1578cdf0e10cSrcweir xListener)
1579cdf0e10cSrcweir throw (css::uno::RuntimeException)
1580cdf0e10cSrcweir {
1581cdf0e10cSrcweir OSL_ASSERT(thisIs(IS_GROUP));
1582cdf0e10cSrcweir {
1583cdf0e10cSrcweir osl::MutexGuard g(lock);
1584cdf0e10cSrcweir if (!xListener.is()) {
1585cdf0e10cSrcweir throw css::uno::RuntimeException(
1586cdf0e10cSrcweir rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("null listener")),
1587cdf0e10cSrcweir static_cast< cppu::OWeakObject * >(this));
1588cdf0e10cSrcweir }
1589cdf0e10cSrcweir if (!disposed_) {
1590cdf0e10cSrcweir propertiesChangeListeners_.insert(xListener);
1591cdf0e10cSrcweir return;
1592cdf0e10cSrcweir }
1593cdf0e10cSrcweir }
1594cdf0e10cSrcweir try {
1595cdf0e10cSrcweir xListener->disposing(
1596cdf0e10cSrcweir css::lang::EventObject(static_cast< cppu::OWeakObject * >(this)));
1597cdf0e10cSrcweir } catch (css::lang::DisposedException &) {}
1598cdf0e10cSrcweir }
1599cdf0e10cSrcweir
removePropertiesChangeListener(css::uno::Reference<css::beans::XPropertiesChangeListener> const & xListener)1600cdf0e10cSrcweir void Access::removePropertiesChangeListener(
1601cdf0e10cSrcweir css::uno::Reference< css::beans::XPropertiesChangeListener > const &
1602cdf0e10cSrcweir xListener)
1603cdf0e10cSrcweir throw (css::uno::RuntimeException)
1604cdf0e10cSrcweir {
1605cdf0e10cSrcweir OSL_ASSERT(thisIs(IS_GROUP));
1606cdf0e10cSrcweir osl::MutexGuard g(lock);
1607cdf0e10cSrcweir PropertiesChangeListeners::iterator i(
1608cdf0e10cSrcweir propertiesChangeListeners_.find(xListener));
1609cdf0e10cSrcweir if (i != propertiesChangeListeners_.end()) {
1610cdf0e10cSrcweir propertiesChangeListeners_.erase(i);
1611cdf0e10cSrcweir }
1612cdf0e10cSrcweir }
1613cdf0e10cSrcweir
firePropertiesChangeEvent(css::uno::Sequence<rtl::OUString> const & aPropertyNames,css::uno::Reference<css::beans::XPropertiesChangeListener> const & xListener)1614cdf0e10cSrcweir void Access::firePropertiesChangeEvent(
1615cdf0e10cSrcweir css::uno::Sequence< rtl::OUString > const & aPropertyNames,
1616cdf0e10cSrcweir css::uno::Reference< css::beans::XPropertiesChangeListener > const &
1617cdf0e10cSrcweir xListener)
1618cdf0e10cSrcweir throw (css::uno::RuntimeException)
1619cdf0e10cSrcweir {
1620cdf0e10cSrcweir OSL_ASSERT(thisIs(IS_GROUP));
1621cdf0e10cSrcweir css::uno::Sequence< css::beans::PropertyChangeEvent > events(
1622cdf0e10cSrcweir aPropertyNames.getLength());
1623cdf0e10cSrcweir for (sal_Int32 i = 0; i < events.getLength(); ++i) {
1624cdf0e10cSrcweir events[i].Source = static_cast< cppu::OWeakObject * >(this);
1625cdf0e10cSrcweir events[i].PropertyName = aPropertyNames[i];
1626cdf0e10cSrcweir events[i].Further = false;
1627cdf0e10cSrcweir events[i].PropertyHandle = -1;
1628cdf0e10cSrcweir }
1629cdf0e10cSrcweir xListener->propertiesChange(events);
1630cdf0e10cSrcweir }
1631cdf0e10cSrcweir
1632cdf0e10cSrcweir css::uno::Reference< css::beans::XHierarchicalPropertySetInfo >
getHierarchicalPropertySetInfo()1633cdf0e10cSrcweir Access::getHierarchicalPropertySetInfo() throw (css::uno::RuntimeException) {
1634cdf0e10cSrcweir OSL_ASSERT(thisIs(IS_GROUP));
1635cdf0e10cSrcweir return this;
1636cdf0e10cSrcweir }
1637cdf0e10cSrcweir
setHierarchicalPropertyValue(rtl::OUString const & aHierarchicalPropertyName,css::uno::Any const & aValue)1638cdf0e10cSrcweir void Access::setHierarchicalPropertyValue(
1639cdf0e10cSrcweir rtl::OUString const & aHierarchicalPropertyName,
1640cdf0e10cSrcweir css::uno::Any const & aValue)
1641cdf0e10cSrcweir throw (
1642cdf0e10cSrcweir css::beans::UnknownPropertyException, css::beans::PropertyVetoException,
1643cdf0e10cSrcweir css::lang::IllegalArgumentException, css::lang::WrappedTargetException,
1644cdf0e10cSrcweir css::uno::RuntimeException)
1645cdf0e10cSrcweir {
1646cdf0e10cSrcweir OSL_ASSERT(thisIs(IS_GROUP));
1647cdf0e10cSrcweir Broadcaster bc;
1648cdf0e10cSrcweir {
1649cdf0e10cSrcweir osl::MutexGuard g(lock);
1650cdf0e10cSrcweir if (!getRootAccess()->isUpdate()) {
1651cdf0e10cSrcweir throw css::uno::RuntimeException(
1652cdf0e10cSrcweir rtl::OUString(
1653cdf0e10cSrcweir RTL_CONSTASCII_USTRINGPARAM(
1654cdf0e10cSrcweir "configmgr setHierarchicalPropertyName on non-update"
1655cdf0e10cSrcweir " access")),
1656cdf0e10cSrcweir static_cast< cppu::OWeakObject * >(this));
1657cdf0e10cSrcweir }
1658cdf0e10cSrcweir rtl::Reference< ChildAccess > child(
1659cdf0e10cSrcweir getSubChild(aHierarchicalPropertyName));
1660cdf0e10cSrcweir if (!child.is()) {
1661cdf0e10cSrcweir throw css::beans::UnknownPropertyException(
1662cdf0e10cSrcweir aHierarchicalPropertyName,
1663cdf0e10cSrcweir static_cast< cppu::OWeakObject * >(this));
1664cdf0e10cSrcweir }
1665cdf0e10cSrcweir child->checkFinalized();
1666cdf0e10cSrcweir Modifications localMods;
1667cdf0e10cSrcweir child->setProperty(aValue, &localMods);
1668cdf0e10cSrcweir getNotificationRoot()->initBroadcaster(localMods.getRoot(), &bc);
1669cdf0e10cSrcweir }
1670cdf0e10cSrcweir bc.send();
1671cdf0e10cSrcweir }
1672cdf0e10cSrcweir
getHierarchicalPropertyValue(rtl::OUString const & aHierarchicalPropertyName)1673cdf0e10cSrcweir css::uno::Any Access::getHierarchicalPropertyValue(
1674cdf0e10cSrcweir rtl::OUString const & aHierarchicalPropertyName)
1675cdf0e10cSrcweir throw (
1676cdf0e10cSrcweir css::beans::UnknownPropertyException,
1677cdf0e10cSrcweir css::lang::IllegalArgumentException, css::lang::WrappedTargetException,
1678cdf0e10cSrcweir css::uno::RuntimeException)
1679cdf0e10cSrcweir {
1680cdf0e10cSrcweir OSL_ASSERT(thisIs(IS_GROUP));
1681cdf0e10cSrcweir osl::MutexGuard g(lock);
1682cdf0e10cSrcweir rtl::Reference< ChildAccess > child(getSubChild(aHierarchicalPropertyName));
1683cdf0e10cSrcweir if (!child.is()) {
1684cdf0e10cSrcweir throw css::beans::UnknownPropertyException(
1685cdf0e10cSrcweir aHierarchicalPropertyName,
1686cdf0e10cSrcweir static_cast< cppu::OWeakObject * >(this));
1687cdf0e10cSrcweir }
1688cdf0e10cSrcweir return child->asValue();
1689cdf0e10cSrcweir }
1690cdf0e10cSrcweir
setHierarchicalPropertyValues(css::uno::Sequence<rtl::OUString> const & aHierarchicalPropertyNames,css::uno::Sequence<css::uno::Any> const & Values)1691cdf0e10cSrcweir void Access::setHierarchicalPropertyValues(
1692cdf0e10cSrcweir css::uno::Sequence< rtl::OUString > const & aHierarchicalPropertyNames,
1693cdf0e10cSrcweir css::uno::Sequence< css::uno::Any > const & Values)
1694cdf0e10cSrcweir throw (
1695cdf0e10cSrcweir css::beans::PropertyVetoException, css::lang::IllegalArgumentException,
1696cdf0e10cSrcweir css::lang::WrappedTargetException, css::uno::RuntimeException)
1697cdf0e10cSrcweir {
1698cdf0e10cSrcweir OSL_ASSERT(thisIs(IS_GROUP));
1699cdf0e10cSrcweir Broadcaster bc;
1700cdf0e10cSrcweir {
1701cdf0e10cSrcweir osl::MutexGuard g(lock);
1702cdf0e10cSrcweir if (!getRootAccess()->isUpdate()) {
1703cdf0e10cSrcweir throw css::uno::RuntimeException(
1704cdf0e10cSrcweir rtl::OUString(
1705cdf0e10cSrcweir RTL_CONSTASCII_USTRINGPARAM(
1706cdf0e10cSrcweir "configmgr setPropertyValues on non-update access")),
1707cdf0e10cSrcweir static_cast< cppu::OWeakObject * >(this));
1708cdf0e10cSrcweir }
1709cdf0e10cSrcweir if (aHierarchicalPropertyNames.getLength() != Values.getLength()) {
1710cdf0e10cSrcweir throw css::lang::IllegalArgumentException(
1711cdf0e10cSrcweir rtl::OUString(
1712cdf0e10cSrcweir RTL_CONSTASCII_USTRINGPARAM(
1713cdf0e10cSrcweir "configmgr setHierarchicalPropertyValues:"
1714cdf0e10cSrcweir " aHierarchicalPropertyNames/Values of different"
1715cdf0e10cSrcweir " length")),
1716cdf0e10cSrcweir static_cast< cppu::OWeakObject * >(this), -1);
1717cdf0e10cSrcweir }
1718cdf0e10cSrcweir Modifications localMods;
1719cdf0e10cSrcweir for (sal_Int32 i = 0; i < aHierarchicalPropertyNames.getLength(); ++i) {
1720cdf0e10cSrcweir rtl::Reference< ChildAccess > child(
1721cdf0e10cSrcweir getSubChild(aHierarchicalPropertyNames[i]));
1722cdf0e10cSrcweir if (!child.is()) {
1723cdf0e10cSrcweir throw css::lang::IllegalArgumentException(
1724cdf0e10cSrcweir rtl::OUString(
1725cdf0e10cSrcweir RTL_CONSTASCII_USTRINGPARAM(
1726cdf0e10cSrcweir "configmgr setHierarchicalPropertyValues"
1727cdf0e10cSrcweir " inappropriate property name")),
1728cdf0e10cSrcweir static_cast< cppu::OWeakObject * >(this), -1);
1729cdf0e10cSrcweir }
1730cdf0e10cSrcweir child->checkFinalized();
1731cdf0e10cSrcweir child->setProperty(Values[i], &localMods);
1732cdf0e10cSrcweir }
1733cdf0e10cSrcweir getNotificationRoot()->initBroadcaster(localMods.getRoot(), &bc);
1734cdf0e10cSrcweir }
1735cdf0e10cSrcweir bc.send();
1736cdf0e10cSrcweir }
1737cdf0e10cSrcweir
getHierarchicalPropertyValues(css::uno::Sequence<rtl::OUString> const & aHierarchicalPropertyNames)1738cdf0e10cSrcweir css::uno::Sequence< css::uno::Any > Access::getHierarchicalPropertyValues(
1739cdf0e10cSrcweir css::uno::Sequence< rtl::OUString > const & aHierarchicalPropertyNames)
1740cdf0e10cSrcweir throw (
1741cdf0e10cSrcweir css::lang::IllegalArgumentException, css::lang::WrappedTargetException,
1742cdf0e10cSrcweir css::uno::RuntimeException)
1743cdf0e10cSrcweir {
1744cdf0e10cSrcweir OSL_ASSERT(thisIs(IS_GROUP));
1745cdf0e10cSrcweir osl::MutexGuard g(lock);
1746cdf0e10cSrcweir css::uno::Sequence< css::uno::Any > vals(
1747cdf0e10cSrcweir aHierarchicalPropertyNames.getLength());
1748cdf0e10cSrcweir for (sal_Int32 i = 0; i < aHierarchicalPropertyNames.getLength(); ++i) {
1749cdf0e10cSrcweir rtl::Reference< ChildAccess > child(
1750cdf0e10cSrcweir getSubChild(aHierarchicalPropertyNames[i]));
1751cdf0e10cSrcweir if (!child.is()) {
1752cdf0e10cSrcweir throw css::lang::IllegalArgumentException(
1753cdf0e10cSrcweir rtl::OUString(
1754cdf0e10cSrcweir RTL_CONSTASCII_USTRINGPARAM(
1755cdf0e10cSrcweir "configmgr getHierarchicalPropertyValues inappropriate"
1756cdf0e10cSrcweir " hierarchical property name")),
1757cdf0e10cSrcweir static_cast< cppu::OWeakObject * >(this), -1);
1758cdf0e10cSrcweir }
1759cdf0e10cSrcweir vals[i] = child->asValue();
1760cdf0e10cSrcweir }
1761cdf0e10cSrcweir return vals;
1762cdf0e10cSrcweir }
1763cdf0e10cSrcweir
getPropertyByHierarchicalName(rtl::OUString const & aHierarchicalName)1764cdf0e10cSrcweir css::beans::Property Access::getPropertyByHierarchicalName(
1765cdf0e10cSrcweir rtl::OUString const & aHierarchicalName)
1766cdf0e10cSrcweir throw (css::beans::UnknownPropertyException, css::uno::RuntimeException)
1767cdf0e10cSrcweir {
1768cdf0e10cSrcweir OSL_ASSERT(thisIs(IS_GROUP));
1769cdf0e10cSrcweir osl::MutexGuard g(lock);
1770cdf0e10cSrcweir rtl::Reference< ChildAccess > child(getSubChild(aHierarchicalName));
1771cdf0e10cSrcweir if (!child.is()) {
1772cdf0e10cSrcweir throw css::beans::UnknownPropertyException(
1773cdf0e10cSrcweir aHierarchicalName, static_cast< cppu::OWeakObject * >(this));
1774cdf0e10cSrcweir }
1775cdf0e10cSrcweir return child->asProperty();
1776cdf0e10cSrcweir }
1777cdf0e10cSrcweir
hasPropertyByHierarchicalName(rtl::OUString const & aHierarchicalName)1778cdf0e10cSrcweir sal_Bool Access::hasPropertyByHierarchicalName(
1779cdf0e10cSrcweir rtl::OUString const & aHierarchicalName)
1780cdf0e10cSrcweir throw (css::uno::RuntimeException)
1781cdf0e10cSrcweir {
1782cdf0e10cSrcweir OSL_ASSERT(thisIs(IS_GROUP));
1783cdf0e10cSrcweir osl::MutexGuard g(lock);
1784cdf0e10cSrcweir return getSubChild(aHierarchicalName).is();
1785cdf0e10cSrcweir }
1786cdf0e10cSrcweir
replaceByName(rtl::OUString const & aName,css::uno::Any const & aElement)1787cdf0e10cSrcweir void Access::replaceByName(
1788cdf0e10cSrcweir rtl::OUString const & aName, css::uno::Any const & aElement)
1789cdf0e10cSrcweir throw (
1790cdf0e10cSrcweir css::lang::IllegalArgumentException,
1791cdf0e10cSrcweir css::container::NoSuchElementException,
1792cdf0e10cSrcweir css::lang::WrappedTargetException, css::uno::RuntimeException)
1793cdf0e10cSrcweir {
1794cdf0e10cSrcweir OSL_ASSERT(thisIs(IS_UPDATE));
1795cdf0e10cSrcweir Broadcaster bc;
1796cdf0e10cSrcweir {
1797cdf0e10cSrcweir osl::MutexGuard g(lock);
1798cdf0e10cSrcweir checkLocalizedPropertyAccess();
1799cdf0e10cSrcweir rtl::Reference< ChildAccess > child(getChild(aName));
1800cdf0e10cSrcweir if (!child.is()) {
1801cdf0e10cSrcweir throw css::container::NoSuchElementException(
1802cdf0e10cSrcweir aName, static_cast< cppu::OWeakObject * >(this));
1803cdf0e10cSrcweir }
1804cdf0e10cSrcweir child->checkFinalized();
1805cdf0e10cSrcweir Modifications localMods;
1806cdf0e10cSrcweir switch (getNode()->kind()) {
1807cdf0e10cSrcweir case Node::KIND_LOCALIZED_PROPERTY:
1808cdf0e10cSrcweir case Node::KIND_GROUP:
1809cdf0e10cSrcweir child->setProperty(aElement, &localMods);
1810cdf0e10cSrcweir break;
1811cdf0e10cSrcweir case Node::KIND_SET:
1812cdf0e10cSrcweir {
1813cdf0e10cSrcweir rtl::Reference< ChildAccess > freeAcc(
1814cdf0e10cSrcweir getFreeSetMember(aElement));
1815cdf0e10cSrcweir rtl::Reference< RootAccess > root(getRootAccess());
1816cdf0e10cSrcweir localMods.add(child->getRelativePath());
1817cdf0e10cSrcweir child->unbind(); // must not throw
1818cdf0e10cSrcweir freeAcc->bind(root, this, aName); // must not throw
1819cdf0e10cSrcweir markChildAsModified(freeAcc); //TODO: must not throw
1820cdf0e10cSrcweir }
1821cdf0e10cSrcweir break;
1822cdf0e10cSrcweir default:
1823cdf0e10cSrcweir OSL_ASSERT(false); // this cannot happen
1824cdf0e10cSrcweir break;
1825cdf0e10cSrcweir }
1826cdf0e10cSrcweir getNotificationRoot()->initBroadcaster(localMods.getRoot(), &bc);
1827cdf0e10cSrcweir }
1828cdf0e10cSrcweir bc.send();
1829cdf0e10cSrcweir }
1830cdf0e10cSrcweir
insertByName(rtl::OUString const & aName,css::uno::Any const & aElement)1831cdf0e10cSrcweir void Access::insertByName(
1832cdf0e10cSrcweir rtl::OUString const & aName, css::uno::Any const & aElement)
1833cdf0e10cSrcweir throw (
1834cdf0e10cSrcweir css::lang::IllegalArgumentException,
1835cdf0e10cSrcweir css::container::ElementExistException,
1836cdf0e10cSrcweir css::lang::WrappedTargetException, css::uno::RuntimeException)
1837cdf0e10cSrcweir {
1838cdf0e10cSrcweir OSL_ASSERT(thisIs(IS_EXTENSIBLE|IS_UPDATE));
1839cdf0e10cSrcweir Broadcaster bc;
1840cdf0e10cSrcweir {
1841cdf0e10cSrcweir osl::MutexGuard g(lock);
1842cdf0e10cSrcweir checkLocalizedPropertyAccess();
1843cdf0e10cSrcweir checkFinalized();
1844cdf0e10cSrcweir if (getChild(aName).is()) {
1845cdf0e10cSrcweir throw css::container::ElementExistException(
1846cdf0e10cSrcweir aName, static_cast< cppu::OWeakObject * >(this));
1847cdf0e10cSrcweir }
1848cdf0e10cSrcweir Modifications localMods;
1849cdf0e10cSrcweir switch (getNode()->kind()) {
1850cdf0e10cSrcweir case Node::KIND_LOCALIZED_PROPERTY:
1851cdf0e10cSrcweir insertLocalizedValueChild(aName, aElement, &localMods);
1852cdf0e10cSrcweir break;
1853cdf0e10cSrcweir case Node::KIND_GROUP:
1854cdf0e10cSrcweir {
1855cdf0e10cSrcweir checkValue(aElement, TYPE_ANY, true);
1856cdf0e10cSrcweir rtl::Reference< ChildAccess > child(
1857cdf0e10cSrcweir new ChildAccess(
1858cdf0e10cSrcweir components_, getRootAccess(), this, aName,
1859cdf0e10cSrcweir new PropertyNode(
1860cdf0e10cSrcweir Data::NO_LAYER, TYPE_ANY, true, aElement, true)));
1861cdf0e10cSrcweir markChildAsModified(child);
1862cdf0e10cSrcweir localMods.add(child->getRelativePath());
1863cdf0e10cSrcweir }
1864cdf0e10cSrcweir break;
1865cdf0e10cSrcweir case Node::KIND_SET:
1866cdf0e10cSrcweir {
1867cdf0e10cSrcweir rtl::Reference< ChildAccess > freeAcc(
1868cdf0e10cSrcweir getFreeSetMember(aElement));
1869cdf0e10cSrcweir freeAcc->bind(getRootAccess(), this, aName); // must not throw
1870cdf0e10cSrcweir markChildAsModified(freeAcc); //TODO: must not throw
1871cdf0e10cSrcweir localMods.add(freeAcc->getRelativePath());
1872cdf0e10cSrcweir }
1873cdf0e10cSrcweir break;
1874cdf0e10cSrcweir default:
1875cdf0e10cSrcweir OSL_ASSERT(false); // this cannot happen
1876cdf0e10cSrcweir break;
1877cdf0e10cSrcweir }
1878cdf0e10cSrcweir getNotificationRoot()->initBroadcaster(localMods.getRoot(), &bc);
1879cdf0e10cSrcweir }
1880cdf0e10cSrcweir bc.send();
1881cdf0e10cSrcweir }
1882cdf0e10cSrcweir
removeByName(rtl::OUString const & aName)1883cdf0e10cSrcweir void Access::removeByName(rtl::OUString const & aName)
1884cdf0e10cSrcweir throw (
1885cdf0e10cSrcweir css::container::NoSuchElementException,
1886cdf0e10cSrcweir css::lang::WrappedTargetException, css::uno::RuntimeException)
1887cdf0e10cSrcweir {
1888cdf0e10cSrcweir OSL_ASSERT(thisIs(IS_EXTENSIBLE|IS_UPDATE));
1889cdf0e10cSrcweir Broadcaster bc;
1890cdf0e10cSrcweir {
1891cdf0e10cSrcweir osl::MutexGuard g(lock);
1892cdf0e10cSrcweir checkLocalizedPropertyAccess();
1893cdf0e10cSrcweir rtl::Reference< ChildAccess > child(getChild(aName));
1894cdf0e10cSrcweir if (!child.is() || child->isFinalized() ||
1895cdf0e10cSrcweir child->getNode()->getMandatory() != Data::NO_LAYER)
1896cdf0e10cSrcweir {
1897cdf0e10cSrcweir throw css::container::NoSuchElementException(
1898cdf0e10cSrcweir aName, static_cast< cppu::OWeakObject * >(this));
1899cdf0e10cSrcweir }
1900cdf0e10cSrcweir if (getNode()->kind() == Node::KIND_GROUP) {
1901cdf0e10cSrcweir rtl::Reference< Node > p(child->getNode());
1902cdf0e10cSrcweir if (p->kind() != Node::KIND_PROPERTY ||
1903cdf0e10cSrcweir !dynamic_cast< PropertyNode * >(p.get())->isExtension())
1904cdf0e10cSrcweir {
1905cdf0e10cSrcweir throw css::container::NoSuchElementException(
1906cdf0e10cSrcweir aName, static_cast< cppu::OWeakObject * >(this));
1907cdf0e10cSrcweir }
1908cdf0e10cSrcweir }
1909cdf0e10cSrcweir Modifications localMods;
1910cdf0e10cSrcweir localMods.add(child->getRelativePath());
1911cdf0e10cSrcweir // unbind() modifies the parent chain that markChildAsModified() walks,
1912cdf0e10cSrcweir // so order is important:
1913cdf0e10cSrcweir markChildAsModified(child); //TODO: must not throw
1914cdf0e10cSrcweir child->unbind();
1915cdf0e10cSrcweir getNotificationRoot()->initBroadcaster(localMods.getRoot(), &bc);
1916cdf0e10cSrcweir }
1917cdf0e10cSrcweir bc.send();
1918cdf0e10cSrcweir }
1919cdf0e10cSrcweir
createInstance()1920cdf0e10cSrcweir css::uno::Reference< css::uno::XInterface > Access::createInstance()
1921cdf0e10cSrcweir throw (css::uno::Exception, css::uno::RuntimeException)
1922cdf0e10cSrcweir {
1923cdf0e10cSrcweir OSL_ASSERT(thisIs(IS_SET|IS_UPDATE));
1924cdf0e10cSrcweir rtl::OUString tmplName(
1925cdf0e10cSrcweir dynamic_cast< SetNode * >(getNode().get())->getDefaultTemplateName());
1926cdf0e10cSrcweir rtl::Reference< Node > tmpl(
1927cdf0e10cSrcweir components_.getTemplate(Data::NO_LAYER, tmplName));
1928cdf0e10cSrcweir if (!tmpl.is()) {
1929cdf0e10cSrcweir throw css::uno::Exception(
1930cdf0e10cSrcweir (rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("unknown template ")) +
1931cdf0e10cSrcweir tmplName),
1932cdf0e10cSrcweir static_cast< cppu::OWeakObject * >(this));
1933cdf0e10cSrcweir }
1934cdf0e10cSrcweir rtl::Reference< Node > node(tmpl->clone(true));
1935cdf0e10cSrcweir node->setLayer(Data::NO_LAYER);
1936cdf0e10cSrcweir return static_cast< cppu::OWeakObject * >(
1937cdf0e10cSrcweir new ChildAccess(components_, getRootAccess(), node));
1938cdf0e10cSrcweir }
1939cdf0e10cSrcweir
createInstanceWithArguments(css::uno::Sequence<css::uno::Any> const & aArguments)1940cdf0e10cSrcweir css::uno::Reference< css::uno::XInterface > Access::createInstanceWithArguments(
1941cdf0e10cSrcweir css::uno::Sequence< css::uno::Any > const & aArguments)
1942cdf0e10cSrcweir throw (css::uno::Exception, css::uno::RuntimeException)
1943cdf0e10cSrcweir {
1944cdf0e10cSrcweir OSL_ASSERT(thisIs(IS_SET|IS_UPDATE));
1945cdf0e10cSrcweir if (aArguments.getLength() != 0) {
1946cdf0e10cSrcweir throw css::uno::Exception(
1947cdf0e10cSrcweir rtl::OUString(
1948cdf0e10cSrcweir RTL_CONSTASCII_USTRINGPARAM(
1949cdf0e10cSrcweir "configuration SimpleSetUpdate createInstanceWithArguments"
1950cdf0e10cSrcweir " must not specify any arguments")),
1951cdf0e10cSrcweir static_cast< cppu::OWeakObject * >(this));
1952cdf0e10cSrcweir }
1953cdf0e10cSrcweir return createInstance();
1954cdf0e10cSrcweir }
1955cdf0e10cSrcweir
getModifiedChild(ModifiedChildren::iterator const & childIterator)1956cdf0e10cSrcweir rtl::Reference< ChildAccess > Access::getModifiedChild(
1957cdf0e10cSrcweir ModifiedChildren::iterator const & childIterator)
1958cdf0e10cSrcweir {
1959cdf0e10cSrcweir return (childIterator->second.child->getParentAccess() == this &&
1960cdf0e10cSrcweir (childIterator->second.child->getNameInternal() ==
1961cdf0e10cSrcweir childIterator->first))
1962cdf0e10cSrcweir ? childIterator->second.child : rtl::Reference< ChildAccess >();
1963cdf0e10cSrcweir }
1964cdf0e10cSrcweir
getUnmodifiedChild(rtl::OUString const & name)1965cdf0e10cSrcweir rtl::Reference< ChildAccess > Access::getUnmodifiedChild(
1966cdf0e10cSrcweir rtl::OUString const & name)
1967cdf0e10cSrcweir {
1968cdf0e10cSrcweir OSL_ASSERT(modifiedChildren_.find(name) == modifiedChildren_.end());
1969cdf0e10cSrcweir rtl::Reference< Node > node(getNode()->getMember(name));
1970cdf0e10cSrcweir if (!node.is()) {
1971cdf0e10cSrcweir return rtl::Reference< ChildAccess >();
1972cdf0e10cSrcweir }
1973cdf0e10cSrcweir WeakChildMap::iterator i(cachedChildren_.find(name));
1974cdf0e10cSrcweir if (i != cachedChildren_.end()) {
1975cdf0e10cSrcweir rtl::Reference< ChildAccess > child;
1976cdf0e10cSrcweir if (i->second->acquireCounting() > 1) {
1977cdf0e10cSrcweir child.set(i->second); // must not throw
1978cdf0e10cSrcweir }
1979cdf0e10cSrcweir i->second->releaseNondeleting();
1980cdf0e10cSrcweir if (child.is()) {
1981cdf0e10cSrcweir child->setNode(node);
1982cdf0e10cSrcweir return child;
1983cdf0e10cSrcweir }
1984cdf0e10cSrcweir }
1985cdf0e10cSrcweir rtl::Reference< ChildAccess > child(
1986cdf0e10cSrcweir new ChildAccess(components_, getRootAccess(), this, name, node));
1987cdf0e10cSrcweir cachedChildren_[name] = child.get();
1988cdf0e10cSrcweir return child;
1989cdf0e10cSrcweir }
1990cdf0e10cSrcweir
getSubChild(rtl::OUString const & path)1991cdf0e10cSrcweir rtl::Reference< ChildAccess > Access::getSubChild(rtl::OUString const & path) {
1992cdf0e10cSrcweir sal_Int32 i = 0;
1993cdf0e10cSrcweir // For backwards compatibility, allow absolute paths where meaningful:
1994cdf0e10cSrcweir if (path.getLength() != 0 && path[0] == '/') {
1995cdf0e10cSrcweir ++i;
1996cdf0e10cSrcweir if (!getRootAccess().is()) {
1997cdf0e10cSrcweir return rtl::Reference< ChildAccess >();
1998cdf0e10cSrcweir }
1999cdf0e10cSrcweir Path abs(getAbsolutePath());
2000cdf0e10cSrcweir for (Path::iterator j(abs.begin()); j != abs.end(); ++j) {
2001cdf0e10cSrcweir rtl::OUString name1;
2002cdf0e10cSrcweir bool setElement1;
2003cdf0e10cSrcweir rtl::OUString templateName1;
2004cdf0e10cSrcweir i = Data::parseSegment(
2005cdf0e10cSrcweir path, i, &name1, &setElement1, &templateName1);
2006cdf0e10cSrcweir if (i == -1 || (i != path.getLength() && path[i] != '/')) {
2007cdf0e10cSrcweir return rtl::Reference< ChildAccess >();
2008cdf0e10cSrcweir }
2009cdf0e10cSrcweir rtl::OUString name2;
2010cdf0e10cSrcweir bool setElement2;
2011cdf0e10cSrcweir rtl::OUString templateName2;
2012cdf0e10cSrcweir Data::parseSegment(*j, 0, &name2, &setElement2, &templateName2);
2013cdf0e10cSrcweir if (name1 != name2 || setElement1 != setElement2 ||
2014cdf0e10cSrcweir (setElement1 &&
2015cdf0e10cSrcweir !Data::equalTemplateNames(templateName1, templateName2)))
2016cdf0e10cSrcweir {
2017cdf0e10cSrcweir return rtl::Reference< ChildAccess >();
2018cdf0e10cSrcweir }
2019cdf0e10cSrcweir if (i != path.getLength()) {
2020cdf0e10cSrcweir ++i;
2021cdf0e10cSrcweir }
2022cdf0e10cSrcweir }
2023cdf0e10cSrcweir }
2024cdf0e10cSrcweir for (rtl::Reference< Access > parent(this);;) {
2025cdf0e10cSrcweir rtl::OUString name;
2026cdf0e10cSrcweir bool setElement;
2027cdf0e10cSrcweir rtl::OUString templateName;
2028cdf0e10cSrcweir i = Data::parseSegment(path, i, &name, &setElement, &templateName);
2029cdf0e10cSrcweir if (i == -1 || (i != path.getLength() && path[i] != '/')) {
2030cdf0e10cSrcweir return rtl::Reference< ChildAccess >();
2031cdf0e10cSrcweir }
2032cdf0e10cSrcweir rtl::Reference< ChildAccess > child(parent->getChild(name));
2033cdf0e10cSrcweir if (!child.is()) {
2034cdf0e10cSrcweir return rtl::Reference< ChildAccess >();
2035cdf0e10cSrcweir }
2036cdf0e10cSrcweir if (setElement) {
2037cdf0e10cSrcweir rtl::Reference< Node > p(parent->getNode());
2038cdf0e10cSrcweir switch (p->kind()) {
2039cdf0e10cSrcweir case Node::KIND_LOCALIZED_PROPERTY:
2040cdf0e10cSrcweir if (!Components::allLocales(getRootAccess()->getLocale()) ||
2041cdf0e10cSrcweir templateName.getLength() != 0)
2042cdf0e10cSrcweir {
2043cdf0e10cSrcweir return rtl::Reference< ChildAccess >();
2044cdf0e10cSrcweir }
2045cdf0e10cSrcweir break;
2046cdf0e10cSrcweir case Node::KIND_SET:
2047cdf0e10cSrcweir if (templateName.getLength() != 0 &&
2048cdf0e10cSrcweir !dynamic_cast< SetNode * >(p.get())->isValidTemplate(
2049cdf0e10cSrcweir templateName))
2050cdf0e10cSrcweir {
2051cdf0e10cSrcweir return rtl::Reference< ChildAccess >();
2052cdf0e10cSrcweir }
2053cdf0e10cSrcweir break;
2054cdf0e10cSrcweir default:
2055cdf0e10cSrcweir return rtl::Reference< ChildAccess >();
2056cdf0e10cSrcweir }
2057cdf0e10cSrcweir }
2058cdf0e10cSrcweir // For backwards compatibility, ignore a final slash after non-value
2059cdf0e10cSrcweir // nodes:
2060cdf0e10cSrcweir if (child->isValue()) {
2061cdf0e10cSrcweir return i == path.getLength()
2062cdf0e10cSrcweir ? child : rtl::Reference< ChildAccess >();
2063cdf0e10cSrcweir } else if (i >= path.getLength() - 1) {
2064cdf0e10cSrcweir return child;
2065cdf0e10cSrcweir }
2066cdf0e10cSrcweir ++i;
2067cdf0e10cSrcweir parent = child.get();
2068cdf0e10cSrcweir }
2069cdf0e10cSrcweir }
2070cdf0e10cSrcweir
setChildProperty(rtl::OUString const & name,css::uno::Any const & value,Modifications * localModifications)2071cdf0e10cSrcweir bool Access::setChildProperty(
2072cdf0e10cSrcweir rtl::OUString const & name, css::uno::Any const & value,
2073cdf0e10cSrcweir Modifications * localModifications)
2074cdf0e10cSrcweir {
2075cdf0e10cSrcweir OSL_ASSERT(localModifications != 0);
2076cdf0e10cSrcweir rtl::Reference< ChildAccess > child(getChild(name));
2077cdf0e10cSrcweir if (!child.is()) {
2078cdf0e10cSrcweir return false;
2079cdf0e10cSrcweir }
2080cdf0e10cSrcweir child->checkFinalized();
2081cdf0e10cSrcweir child->setProperty(value, localModifications);
2082cdf0e10cSrcweir return true;
2083cdf0e10cSrcweir }
2084cdf0e10cSrcweir
asProperty()2085cdf0e10cSrcweir css::beans::Property Access::asProperty() {
2086cdf0e10cSrcweir css::uno::Type type;
2087cdf0e10cSrcweir bool nillable;
2088cdf0e10cSrcweir bool removable;
2089cdf0e10cSrcweir rtl::Reference< Node > p(getNode());
2090cdf0e10cSrcweir switch (p->kind()) {
2091cdf0e10cSrcweir case Node::KIND_PROPERTY:
2092cdf0e10cSrcweir {
2093cdf0e10cSrcweir PropertyNode * prop = dynamic_cast< PropertyNode * >(p.get());
2094cdf0e10cSrcweir type = mapType(prop->getStaticType());
2095cdf0e10cSrcweir nillable = prop->isNillable();
2096cdf0e10cSrcweir removable = prop->isExtension();
2097cdf0e10cSrcweir }
2098cdf0e10cSrcweir break;
2099cdf0e10cSrcweir case Node::KIND_LOCALIZED_PROPERTY:
2100cdf0e10cSrcweir {
2101cdf0e10cSrcweir LocalizedPropertyNode * locprop =
2102cdf0e10cSrcweir dynamic_cast< LocalizedPropertyNode *>(p.get());
2103cdf0e10cSrcweir if (Components::allLocales(getRootAccess()->getLocale())) {
2104cdf0e10cSrcweir type = cppu::UnoType< css::uno::XInterface >::get();
2105cdf0e10cSrcweir //TODO: correct?
2106cdf0e10cSrcweir removable = false;
2107cdf0e10cSrcweir } else {
2108cdf0e10cSrcweir type = mapType(locprop->getStaticType());
2109cdf0e10cSrcweir removable = false; //TODO ???
2110cdf0e10cSrcweir }
2111cdf0e10cSrcweir nillable = locprop->isNillable();
2112cdf0e10cSrcweir }
2113cdf0e10cSrcweir break;
2114cdf0e10cSrcweir case Node::KIND_LOCALIZED_VALUE:
2115cdf0e10cSrcweir {
2116cdf0e10cSrcweir LocalizedPropertyNode * locprop =
2117cdf0e10cSrcweir dynamic_cast< LocalizedPropertyNode * >(getParentNode().get());
2118cdf0e10cSrcweir type = mapType(locprop->getStaticType());
2119cdf0e10cSrcweir nillable = locprop->isNillable();
2120cdf0e10cSrcweir removable = false; //TODO ???
2121cdf0e10cSrcweir }
2122cdf0e10cSrcweir break;
2123cdf0e10cSrcweir default:
2124cdf0e10cSrcweir type = cppu::UnoType< css::uno::XInterface >::get(); //TODO: correct?
2125cdf0e10cSrcweir nillable = false;
2126cdf0e10cSrcweir rtl::Reference< Node > parent(getParentNode());
2127cdf0e10cSrcweir removable = parent.is() && parent->kind() == Node::KIND_SET;
2128cdf0e10cSrcweir break;
2129cdf0e10cSrcweir }
2130cdf0e10cSrcweir return css::beans::Property(
2131cdf0e10cSrcweir getNameInternal(), -1, type,
2132cdf0e10cSrcweir (css::beans::PropertyAttribute::BOUND | //TODO: correct for group/set?
2133cdf0e10cSrcweir css::beans::PropertyAttribute::CONSTRAINED |
2134cdf0e10cSrcweir (nillable ? css::beans::PropertyAttribute::MAYBEVOID : 0) |
2135cdf0e10cSrcweir (getRootAccess()->isUpdate()
2136cdf0e10cSrcweir ? (removable ? css::beans::PropertyAttribute::REMOVEABLE : 0)
2137cdf0e10cSrcweir : css::beans::PropertyAttribute::READONLY))); //TODO: MAYBEDEFAULT
2138cdf0e10cSrcweir }
2139cdf0e10cSrcweir
checkFinalized()2140cdf0e10cSrcweir void Access::checkFinalized() {
2141cdf0e10cSrcweir if (isFinalized()) {
2142cdf0e10cSrcweir throw css::lang::IllegalArgumentException(
2143cdf0e10cSrcweir rtl::OUString(
2144cdf0e10cSrcweir RTL_CONSTASCII_USTRINGPARAM(
2145cdf0e10cSrcweir "configmgr modification of finalized item")),
2146cdf0e10cSrcweir static_cast< cppu::OWeakObject * >(this), -1);
2147cdf0e10cSrcweir }
2148cdf0e10cSrcweir }
2149cdf0e10cSrcweir
checkKnownProperty(rtl::OUString const & descriptor)2150cdf0e10cSrcweir void Access::checkKnownProperty(rtl::OUString const & descriptor) {
2151cdf0e10cSrcweir if (descriptor.getLength() == 0) {
2152cdf0e10cSrcweir return;
2153cdf0e10cSrcweir }
2154cdf0e10cSrcweir rtl::Reference< ChildAccess > child(getChild(descriptor));
2155cdf0e10cSrcweir if (child.is()) {
2156cdf0e10cSrcweir switch (child->getNode()->kind()) {
2157cdf0e10cSrcweir case Node::KIND_PROPERTY:
2158cdf0e10cSrcweir return;
2159cdf0e10cSrcweir case Node::KIND_LOCALIZED_PROPERTY:
2160cdf0e10cSrcweir if (!Components::allLocales(getRootAccess()->getLocale())) {
2161cdf0e10cSrcweir return;
2162cdf0e10cSrcweir }
2163cdf0e10cSrcweir break;
2164cdf0e10cSrcweir case Node::KIND_LOCALIZED_VALUE:
2165cdf0e10cSrcweir if (Components::allLocales(getRootAccess()->getLocale())) {
2166cdf0e10cSrcweir return;
2167cdf0e10cSrcweir }
2168cdf0e10cSrcweir break;
2169cdf0e10cSrcweir default:
2170cdf0e10cSrcweir break;
2171cdf0e10cSrcweir }
2172cdf0e10cSrcweir }
2173cdf0e10cSrcweir throw css::beans::UnknownPropertyException(
2174cdf0e10cSrcweir descriptor, static_cast< cppu::OWeakObject * >(this));
2175cdf0e10cSrcweir }
2176cdf0e10cSrcweir
getFreeSetMember(css::uno::Any const & value)2177cdf0e10cSrcweir rtl::Reference< ChildAccess > Access::getFreeSetMember(
2178cdf0e10cSrcweir css::uno::Any const & value)
2179cdf0e10cSrcweir {
2180cdf0e10cSrcweir rtl::Reference< ChildAccess > freeAcc;
2181cdf0e10cSrcweir css::uno::Reference< css::lang::XUnoTunnel > tunnel;
2182cdf0e10cSrcweir value >>= tunnel;
2183cdf0e10cSrcweir if (tunnel.is()) {
2184cdf0e10cSrcweir freeAcc.set(
2185cdf0e10cSrcweir reinterpret_cast< ChildAccess * >(
2186cdf0e10cSrcweir tunnel->getSomething(ChildAccess::getTunnelId())));
2187cdf0e10cSrcweir }
2188cdf0e10cSrcweir if (!freeAcc.is() || freeAcc->getParentAccess().is() ||
2189cdf0e10cSrcweir (freeAcc->isInTransaction() &&
2190cdf0e10cSrcweir freeAcc->getRootAccess() != getRootAccess()))
2191cdf0e10cSrcweir {
2192cdf0e10cSrcweir throw css::lang::IllegalArgumentException(
2193cdf0e10cSrcweir rtl::OUString(
2194cdf0e10cSrcweir RTL_CONSTASCII_USTRINGPARAM(
2195cdf0e10cSrcweir "configmgr inappropriate set element")),
2196cdf0e10cSrcweir static_cast< cppu::OWeakObject * >(this), 1);
2197cdf0e10cSrcweir }
2198cdf0e10cSrcweir OSL_ASSERT(dynamic_cast< SetNode * >(getNode().get()) != 0);
2199cdf0e10cSrcweir if (!dynamic_cast< SetNode * >(getNode().get())->isValidTemplate(
2200cdf0e10cSrcweir freeAcc->getNode()->getTemplateName()))
2201cdf0e10cSrcweir {
2202cdf0e10cSrcweir throw css::lang::IllegalArgumentException(
2203cdf0e10cSrcweir rtl::OUString(
2204cdf0e10cSrcweir RTL_CONSTASCII_USTRINGPARAM(
2205cdf0e10cSrcweir "configmgr inappropriate set element")),
2206cdf0e10cSrcweir static_cast< cppu::OWeakObject * >(this), 1);
2207cdf0e10cSrcweir }
2208cdf0e10cSrcweir return freeAcc;
2209cdf0e10cSrcweir }
2210cdf0e10cSrcweir
getNotificationRoot()2211cdf0e10cSrcweir rtl::Reference< Access > Access::getNotificationRoot() {
2212cdf0e10cSrcweir for (rtl::Reference< Access > p(this);;) {
2213cdf0e10cSrcweir rtl::Reference< Access > parent(p->getParentAccess());
2214cdf0e10cSrcweir if (!parent.is()) {
2215cdf0e10cSrcweir return p;
2216cdf0e10cSrcweir }
2217cdf0e10cSrcweir p = parent;
2218cdf0e10cSrcweir }
2219cdf0e10cSrcweir }
2220cdf0e10cSrcweir
2221cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 0
thisIs(int what)2222cdf0e10cSrcweir bool Access::thisIs(int what) {
2223cdf0e10cSrcweir osl::MutexGuard g(lock);
2224cdf0e10cSrcweir rtl::Reference< Node > p(getNode());
2225cdf0e10cSrcweir Node::Kind k(p->kind());
2226cdf0e10cSrcweir return k != Node::KIND_PROPERTY && k != Node::KIND_LOCALIZED_VALUE &&
2227cdf0e10cSrcweir ((what & IS_GROUP) == 0 || k == Node::KIND_GROUP) &&
2228cdf0e10cSrcweir ((what & IS_SET) == 0 || k == Node::KIND_SET) &&
2229cdf0e10cSrcweir ((what & IS_EXTENSIBLE) == 0 || k != Node::KIND_GROUP ||
2230cdf0e10cSrcweir dynamic_cast< GroupNode * >(p.get())->isExtensible()) &&
2231cdf0e10cSrcweir ((what & IS_GROUP_MEMBER) == 0 ||
2232cdf0e10cSrcweir getParentNode()->kind() == Node::KIND_GROUP) ||
2233cdf0e10cSrcweir ((what & IS_SET_MEMBER) == 0 ||
2234cdf0e10cSrcweir getParentNode()->kind() == Node::KIND_SET) ||
2235cdf0e10cSrcweir ((what & IS_UPDATE) == 0 || getRootAccess()->isUpdate());
2236cdf0e10cSrcweir }
2237cdf0e10cSrcweir #endif
2238cdf0e10cSrcweir
2239cdf0e10cSrcweir }
2240