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