xref: /aoo41x/main/ucb/source/core/ucbstore.cxx (revision 2f86921c)
1*2f86921cSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*2f86921cSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*2f86921cSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*2f86921cSAndrew Rist  * distributed with this work for additional information
6*2f86921cSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*2f86921cSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*2f86921cSAndrew Rist  * "License"); you may not use this file except in compliance
9*2f86921cSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*2f86921cSAndrew Rist  *
11*2f86921cSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*2f86921cSAndrew Rist  *
13*2f86921cSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*2f86921cSAndrew Rist  * software distributed under the License is distributed on an
15*2f86921cSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*2f86921cSAndrew Rist  * KIND, either express or implied.  See the License for the
17*2f86921cSAndrew Rist  * specific language governing permissions and limitations
18*2f86921cSAndrew Rist  * under the License.
19*2f86921cSAndrew Rist  *
20*2f86921cSAndrew Rist  *************************************************************/
21*2f86921cSAndrew Rist 
22*2f86921cSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_ucb.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir /**************************************************************************
28cdf0e10cSrcweir 								TODO
29cdf0e10cSrcweir  **************************************************************************
30cdf0e10cSrcweir 
31cdf0e10cSrcweir   *************************************************************************/
32cdf0e10cSrcweir 
33cdf0e10cSrcweir #include <list>
34cdf0e10cSrcweir #include <hash_map>
35cdf0e10cSrcweir #include <osl/diagnose.h>
36cdf0e10cSrcweir #include <rtl/ustrbuf.hxx>
37cdf0e10cSrcweir #include <cppuhelper/interfacecontainer.hxx>
38cdf0e10cSrcweir #include <com/sun/star/beans/PropertyAttribute.hpp>
39cdf0e10cSrcweir #include <com/sun/star/beans/PropertySetInfoChange.hpp>
40cdf0e10cSrcweir #include <com/sun/star/container/XHierarchicalNameAccess.hpp>
41cdf0e10cSrcweir #include <com/sun/star/container/XNameContainer.hpp>
42cdf0e10cSrcweir #include <com/sun/star/container/XNameReplace.hpp>
43cdf0e10cSrcweir #include <com/sun/star/util/XChangesBatch.hpp>
44cdf0e10cSrcweir #include "ucbstore.hxx"
45cdf0e10cSrcweir 
46cdf0e10cSrcweir using namespace com::sun::star::beans;
47cdf0e10cSrcweir using namespace com::sun::star::container;
48cdf0e10cSrcweir using namespace com::sun::star::lang;
49cdf0e10cSrcweir using namespace com::sun::star::ucb;
50cdf0e10cSrcweir using namespace com::sun::star::uno;
51cdf0e10cSrcweir using namespace com::sun::star::util;
52cdf0e10cSrcweir using namespace cppu;
53cdf0e10cSrcweir using namespace rtl;
54cdf0e10cSrcweir 
55cdf0e10cSrcweir //=========================================================================
makeHierarchalNameSegment(const rtl::OUString & rIn)56cdf0e10cSrcweir rtl::OUString makeHierarchalNameSegment( const rtl::OUString & rIn  )
57cdf0e10cSrcweir {
58cdf0e10cSrcweir     rtl::OUStringBuffer aBuffer;
59cdf0e10cSrcweir     aBuffer.appendAscii( "['" );
60cdf0e10cSrcweir 
61cdf0e10cSrcweir     sal_Int32 nCount = rIn.getLength();
62cdf0e10cSrcweir     for ( sal_Int32 n = 0; n < nCount; ++n )
63cdf0e10cSrcweir     {
64cdf0e10cSrcweir         const sal_Unicode c = rIn.getStr()[ n ];
65cdf0e10cSrcweir         switch ( c )
66cdf0e10cSrcweir         {
67cdf0e10cSrcweir             case '&':
68cdf0e10cSrcweir                 aBuffer.appendAscii( "&amp;" );
69cdf0e10cSrcweir                 break;
70cdf0e10cSrcweir 
71cdf0e10cSrcweir             case '"':
72cdf0e10cSrcweir                 aBuffer.appendAscii( "&quot;" );
73cdf0e10cSrcweir                 break;
74cdf0e10cSrcweir 
75cdf0e10cSrcweir             case '\'':
76cdf0e10cSrcweir                 aBuffer.appendAscii( "&apos;" );
77cdf0e10cSrcweir                 break;
78cdf0e10cSrcweir 
79cdf0e10cSrcweir             case '<':
80cdf0e10cSrcweir                 aBuffer.appendAscii( "&lt;" );
81cdf0e10cSrcweir                 break;
82cdf0e10cSrcweir 
83cdf0e10cSrcweir             case '>':
84cdf0e10cSrcweir                 aBuffer.appendAscii( "&gt;" );
85cdf0e10cSrcweir                 break;
86cdf0e10cSrcweir 
87cdf0e10cSrcweir             default:
88cdf0e10cSrcweir                 aBuffer.append( c );
89cdf0e10cSrcweir                 break;
90cdf0e10cSrcweir         }
91cdf0e10cSrcweir     }
92cdf0e10cSrcweir 
93cdf0e10cSrcweir     aBuffer.appendAscii( "']" );
94cdf0e10cSrcweir     return rtl::OUString( aBuffer.makeStringAndClear() );
95cdf0e10cSrcweir }
96cdf0e10cSrcweir 
97cdf0e10cSrcweir //=========================================================================
98cdf0e10cSrcweir 
99cdf0e10cSrcweir #define STORE_CONTENTPROPERTIES_KEY	"/org.openoffice.ucb.Store/ContentProperties"
100cdf0e10cSrcweir 
101cdf0e10cSrcweir // describe path of cfg entry
102cdf0e10cSrcweir #define	CFGPROPERTY_NODEPATH		"nodepath"
103cdf0e10cSrcweir // true->async. update; false->sync. update
104cdf0e10cSrcweir #define	CFGPROPERTY_LAZYWRITE		"lazywrite"
105cdf0e10cSrcweir 
106cdf0e10cSrcweir //=========================================================================
107cdf0e10cSrcweir 
108cdf0e10cSrcweir struct equalString_Impl
109cdf0e10cSrcweir {
operator ()equalString_Impl110cdf0e10cSrcweir   bool operator()( const OUString& s1, const OUString& s2 ) const
111cdf0e10cSrcweir   {
112cdf0e10cSrcweir 		return !!( s1 == s2 );
113cdf0e10cSrcweir   }
114cdf0e10cSrcweir };
115cdf0e10cSrcweir 
116cdf0e10cSrcweir struct hashString_Impl
117cdf0e10cSrcweir {
operator ()hashString_Impl118cdf0e10cSrcweir 	size_t operator()( const OUString & rName ) const
119cdf0e10cSrcweir 	{
120cdf0e10cSrcweir 		return rName.hashCode();
121cdf0e10cSrcweir 	}
122cdf0e10cSrcweir };
123cdf0e10cSrcweir 
124cdf0e10cSrcweir //=========================================================================
125cdf0e10cSrcweir //
126cdf0e10cSrcweir // PropertySetMap_Impl.
127cdf0e10cSrcweir //
128cdf0e10cSrcweir //=========================================================================
129cdf0e10cSrcweir 
130cdf0e10cSrcweir typedef std::hash_map
131cdf0e10cSrcweir <
132cdf0e10cSrcweir 	OUString,
133cdf0e10cSrcweir 	PersistentPropertySet*,
134cdf0e10cSrcweir 	hashString_Impl,
135cdf0e10cSrcweir 	equalString_Impl
136cdf0e10cSrcweir >
137cdf0e10cSrcweir PropertySetMap_Impl;
138cdf0e10cSrcweir 
139cdf0e10cSrcweir //=========================================================================
140cdf0e10cSrcweir //
141cdf0e10cSrcweir // class PropertySetInfo_Impl
142cdf0e10cSrcweir //
143cdf0e10cSrcweir //=========================================================================
144cdf0e10cSrcweir 
145cdf0e10cSrcweir class PropertySetInfo_Impl :
146cdf0e10cSrcweir 		public OWeakObject,	public XTypeProvider, public XPropertySetInfo
147cdf0e10cSrcweir {
148cdf0e10cSrcweir 	Reference< XMultiServiceFactory > m_xSMgr;
149cdf0e10cSrcweir 	Sequence< Property >* 			  m_pProps;
150cdf0e10cSrcweir 	PersistentPropertySet*			  m_pOwner;
151cdf0e10cSrcweir 
152cdf0e10cSrcweir public:
153cdf0e10cSrcweir 	PropertySetInfo_Impl( const Reference< XMultiServiceFactory >& rxSMgr,
154cdf0e10cSrcweir 	                      PersistentPropertySet* pOwner );
155cdf0e10cSrcweir 	virtual ~PropertySetInfo_Impl();
156cdf0e10cSrcweir 
157cdf0e10cSrcweir 	// XInterface
158cdf0e10cSrcweir 	XINTERFACE_DECL()
159cdf0e10cSrcweir 
160cdf0e10cSrcweir 	// XTypeProvider
161cdf0e10cSrcweir 	XTYPEPROVIDER_DECL()
162cdf0e10cSrcweir 
163cdf0e10cSrcweir 	// XPropertySetInfo
164cdf0e10cSrcweir     virtual Sequence< Property > SAL_CALL getProperties()
165cdf0e10cSrcweir 		throw( RuntimeException );
166cdf0e10cSrcweir     virtual Property SAL_CALL getPropertyByName( const OUString& aName )
167cdf0e10cSrcweir 		throw( UnknownPropertyException, RuntimeException );
168cdf0e10cSrcweir     virtual sal_Bool SAL_CALL hasPropertyByName( const OUString& Name )
169cdf0e10cSrcweir 		throw( RuntimeException );
170cdf0e10cSrcweir 
171cdf0e10cSrcweir 	// Non-interface methods.
reset()172cdf0e10cSrcweir 	void reset() { delete m_pProps; m_pProps = 0; }
173cdf0e10cSrcweir };
174cdf0e10cSrcweir 
175cdf0e10cSrcweir //=========================================================================
176cdf0e10cSrcweir //
177cdf0e10cSrcweir // UcbStore_Impl.
178cdf0e10cSrcweir //
179cdf0e10cSrcweir //=========================================================================
180cdf0e10cSrcweir 
181cdf0e10cSrcweir struct UcbStore_Impl
182cdf0e10cSrcweir {
183cdf0e10cSrcweir 	osl::Mutex						  m_aMutex;
184cdf0e10cSrcweir 	Sequence< Any > 				  m_aInitArgs;
185cdf0e10cSrcweir 	Reference< XPropertySetRegistry > m_xTheRegistry;
186cdf0e10cSrcweir };
187cdf0e10cSrcweir 
188cdf0e10cSrcweir //=========================================================================
189cdf0e10cSrcweir //=========================================================================
190cdf0e10cSrcweir //=========================================================================
191cdf0e10cSrcweir //
192cdf0e10cSrcweir // UcbStore Implementation.
193cdf0e10cSrcweir //
194cdf0e10cSrcweir //=========================================================================
195cdf0e10cSrcweir //=========================================================================
196cdf0e10cSrcweir //=========================================================================
197cdf0e10cSrcweir 
UcbStore(const Reference<XMultiServiceFactory> & rXSMgr)198cdf0e10cSrcweir UcbStore::UcbStore(	const Reference< XMultiServiceFactory >& rXSMgr )
199cdf0e10cSrcweir : m_xSMgr( rXSMgr ),
200cdf0e10cSrcweir   m_pImpl( new UcbStore_Impl() )
201cdf0e10cSrcweir {
202cdf0e10cSrcweir }
203cdf0e10cSrcweir 
204cdf0e10cSrcweir //=========================================================================
205cdf0e10cSrcweir // virtual
~UcbStore()206cdf0e10cSrcweir UcbStore::~UcbStore()
207cdf0e10cSrcweir {
208cdf0e10cSrcweir 	delete m_pImpl;
209cdf0e10cSrcweir }
210cdf0e10cSrcweir 
211cdf0e10cSrcweir //=========================================================================
212cdf0e10cSrcweir //
213cdf0e10cSrcweir // XInterface methods.
214cdf0e10cSrcweir //
215cdf0e10cSrcweir //=========================================================================
216cdf0e10cSrcweir 
217cdf0e10cSrcweir XINTERFACE_IMPL_4( UcbStore,
218cdf0e10cSrcweir 				   XTypeProvider,
219cdf0e10cSrcweir 				   XServiceInfo,
220cdf0e10cSrcweir 				   XPropertySetRegistryFactory,
221cdf0e10cSrcweir 				   XInitialization );
222cdf0e10cSrcweir 
223cdf0e10cSrcweir //=========================================================================
224cdf0e10cSrcweir //
225cdf0e10cSrcweir // XTypeProvider methods.
226cdf0e10cSrcweir //
227cdf0e10cSrcweir //=========================================================================
228cdf0e10cSrcweir 
229cdf0e10cSrcweir XTYPEPROVIDER_IMPL_4( UcbStore,
230cdf0e10cSrcweir 				   	  XTypeProvider,
231cdf0e10cSrcweir 				   	  XServiceInfo,
232cdf0e10cSrcweir 					  XPropertySetRegistryFactory,
233cdf0e10cSrcweir 					  XInitialization );
234cdf0e10cSrcweir 
235cdf0e10cSrcweir //=========================================================================
236cdf0e10cSrcweir //
237cdf0e10cSrcweir // XServiceInfo methods.
238cdf0e10cSrcweir //
239cdf0e10cSrcweir //=========================================================================
240cdf0e10cSrcweir 
241cdf0e10cSrcweir XSERVICEINFO_IMPL_1( UcbStore,
242cdf0e10cSrcweir 					 OUString::createFromAscii(
243cdf0e10cSrcweir 					 	"com.sun.star.comp.ucb.UcbStore" ),
244cdf0e10cSrcweir 					 OUString::createFromAscii(
245cdf0e10cSrcweir 					 	STORE_SERVICE_NAME ) );
246cdf0e10cSrcweir 
247cdf0e10cSrcweir //=========================================================================
248cdf0e10cSrcweir //
249cdf0e10cSrcweir // Service factory implementation.
250cdf0e10cSrcweir //
251cdf0e10cSrcweir //=========================================================================
252cdf0e10cSrcweir 
253cdf0e10cSrcweir ONE_INSTANCE_SERVICE_FACTORY_IMPL( UcbStore );
254cdf0e10cSrcweir 
255cdf0e10cSrcweir //=========================================================================
256cdf0e10cSrcweir //
257cdf0e10cSrcweir // XPropertySetRegistryFactory methods.
258cdf0e10cSrcweir //
259cdf0e10cSrcweir //=========================================================================
260cdf0e10cSrcweir 
261cdf0e10cSrcweir // virtual
262cdf0e10cSrcweir Reference< XPropertySetRegistry > SAL_CALL
createPropertySetRegistry(const OUString &)263cdf0e10cSrcweir UcbStore::createPropertySetRegistry( const OUString& )
264cdf0e10cSrcweir 	throw( RuntimeException )
265cdf0e10cSrcweir {
266cdf0e10cSrcweir 	// The URL parameter is ignored by this interface implementation. It always
267cdf0e10cSrcweir     // uses the configuration server as storage medium.
268cdf0e10cSrcweir 
269cdf0e10cSrcweir 	if ( !m_pImpl->m_xTheRegistry.is() )
270cdf0e10cSrcweir 	{
271cdf0e10cSrcweir 		osl::Guard< osl::Mutex > aGuard( m_pImpl->m_aMutex );
272cdf0e10cSrcweir 		if ( !m_pImpl->m_xTheRegistry.is() )
273cdf0e10cSrcweir 			m_pImpl->m_xTheRegistry = new PropertySetRegistry( m_xSMgr, getInitArgs() );
274cdf0e10cSrcweir 	}
275cdf0e10cSrcweir 
276cdf0e10cSrcweir 	return m_pImpl->m_xTheRegistry;
277cdf0e10cSrcweir }
278cdf0e10cSrcweir 
279cdf0e10cSrcweir //=========================================================================
280cdf0e10cSrcweir //
281cdf0e10cSrcweir // XInitialization methods.
282cdf0e10cSrcweir //
283cdf0e10cSrcweir //=========================================================================
284cdf0e10cSrcweir 
285cdf0e10cSrcweir // virtual
initialize(const Sequence<Any> & aArguments)286cdf0e10cSrcweir void SAL_CALL UcbStore::initialize( const Sequence< Any >& aArguments )
287cdf0e10cSrcweir 	throw( Exception, RuntimeException )
288cdf0e10cSrcweir {
289cdf0e10cSrcweir 	osl::Guard< osl::Mutex > aGuard( m_pImpl->m_aMutex );
290cdf0e10cSrcweir 	m_pImpl->m_aInitArgs = aArguments;
291cdf0e10cSrcweir }
292cdf0e10cSrcweir 
293cdf0e10cSrcweir //=========================================================================
getInitArgs() const294cdf0e10cSrcweir const Sequence< Any >& UcbStore::getInitArgs() const
295cdf0e10cSrcweir {
296cdf0e10cSrcweir 	return m_pImpl->m_aInitArgs;
297cdf0e10cSrcweir }
298cdf0e10cSrcweir 
299cdf0e10cSrcweir //=========================================================================
300cdf0e10cSrcweir //
301cdf0e10cSrcweir // PropertySetRegistry_Impl.
302cdf0e10cSrcweir //
303cdf0e10cSrcweir //=========================================================================
304cdf0e10cSrcweir 
305cdf0e10cSrcweir struct PropertySetRegistry_Impl
306cdf0e10cSrcweir {
307cdf0e10cSrcweir 	const Sequence< Any >			  m_aInitArgs;
308cdf0e10cSrcweir 	PropertySetMap_Impl 			  m_aPropSets;
309cdf0e10cSrcweir 	Reference< XMultiServiceFactory > m_xConfigProvider;
310cdf0e10cSrcweir 	Reference< XInterface >			  m_xRootReadAccess;
311cdf0e10cSrcweir 	Reference< XInterface >			  m_xRootWriteAccess;
312cdf0e10cSrcweir 	osl::Mutex						  m_aMutex;
313cdf0e10cSrcweir 	sal_Bool			  			  m_bTriedToGetRootReadAccess;  // #82494#
314cdf0e10cSrcweir 	sal_Bool			  			  m_bTriedToGetRootWriteAccess; // #82494#
315cdf0e10cSrcweir 
PropertySetRegistry_ImplPropertySetRegistry_Impl316cdf0e10cSrcweir 	PropertySetRegistry_Impl( const Sequence< Any > &rInitArgs )
317cdf0e10cSrcweir 	: m_aInitArgs( rInitArgs ),
318cdf0e10cSrcweir 	  m_bTriedToGetRootReadAccess( sal_False ),
319cdf0e10cSrcweir 	  m_bTriedToGetRootWriteAccess( sal_False )
320cdf0e10cSrcweir 	{
321cdf0e10cSrcweir 	}
322cdf0e10cSrcweir };
323cdf0e10cSrcweir 
324cdf0e10cSrcweir //=========================================================================
325cdf0e10cSrcweir //=========================================================================
326cdf0e10cSrcweir //=========================================================================
327cdf0e10cSrcweir //
328cdf0e10cSrcweir // PropertySetRegistry Implementation.
329cdf0e10cSrcweir //
330cdf0e10cSrcweir //=========================================================================
331cdf0e10cSrcweir //=========================================================================
332cdf0e10cSrcweir //=========================================================================
333cdf0e10cSrcweir 
PropertySetRegistry(const Reference<XMultiServiceFactory> & rXSMgr,const Sequence<Any> & rInitArgs)334cdf0e10cSrcweir PropertySetRegistry::PropertySetRegistry(
335cdf0e10cSrcweir 						const Reference< XMultiServiceFactory >& rXSMgr,
336cdf0e10cSrcweir 						const Sequence< Any > &rInitArgs )
337cdf0e10cSrcweir : m_xSMgr( rXSMgr ),
338cdf0e10cSrcweir   m_pImpl( new PropertySetRegistry_Impl( rInitArgs ) )
339cdf0e10cSrcweir {
340cdf0e10cSrcweir }
341cdf0e10cSrcweir 
342cdf0e10cSrcweir //=========================================================================
343cdf0e10cSrcweir // virtual
~PropertySetRegistry()344cdf0e10cSrcweir PropertySetRegistry::~PropertySetRegistry()
345cdf0e10cSrcweir {
346cdf0e10cSrcweir 	delete m_pImpl;
347cdf0e10cSrcweir }
348cdf0e10cSrcweir 
349cdf0e10cSrcweir //=========================================================================
350cdf0e10cSrcweir //
351cdf0e10cSrcweir // XInterface methods.
352cdf0e10cSrcweir //
353cdf0e10cSrcweir //=========================================================================
354cdf0e10cSrcweir 
355cdf0e10cSrcweir XINTERFACE_IMPL_5( PropertySetRegistry,
356cdf0e10cSrcweir 				   XTypeProvider,
357cdf0e10cSrcweir 				   XServiceInfo,
358cdf0e10cSrcweir 				   XPropertySetRegistry,
359cdf0e10cSrcweir 				   XElementAccess, /* base of XNameAccess */
360cdf0e10cSrcweir 				   XNameAccess );
361cdf0e10cSrcweir 
362cdf0e10cSrcweir //=========================================================================
363cdf0e10cSrcweir //
364cdf0e10cSrcweir // XTypeProvider methods.
365cdf0e10cSrcweir //
366cdf0e10cSrcweir //=========================================================================
367cdf0e10cSrcweir 
368cdf0e10cSrcweir XTYPEPROVIDER_IMPL_4( PropertySetRegistry,
369cdf0e10cSrcweir 				   	  XTypeProvider,
370cdf0e10cSrcweir 					  XServiceInfo,
371cdf0e10cSrcweir 					  XPropertySetRegistry,
372cdf0e10cSrcweir 					  XNameAccess );
373cdf0e10cSrcweir 
374cdf0e10cSrcweir //=========================================================================
375cdf0e10cSrcweir //
376cdf0e10cSrcweir // XServiceInfo methods.
377cdf0e10cSrcweir //
378cdf0e10cSrcweir //=========================================================================
379cdf0e10cSrcweir 
380cdf0e10cSrcweir XSERVICEINFO_NOFACTORY_IMPL_1( PropertySetRegistry,
381cdf0e10cSrcweir 					 		   OUString::createFromAscii(
382cdf0e10cSrcweir 				   				"com.sun.star.comp.ucb.PropertySetRegistry" ),
383cdf0e10cSrcweir 					 		   OUString::createFromAscii(
384cdf0e10cSrcweir 				   				PROPSET_REG_SERVICE_NAME ) );
385cdf0e10cSrcweir 
386cdf0e10cSrcweir //=========================================================================
387cdf0e10cSrcweir //
388cdf0e10cSrcweir // XPropertySetRegistry methods.
389cdf0e10cSrcweir //
390cdf0e10cSrcweir //=========================================================================
391cdf0e10cSrcweir 
392cdf0e10cSrcweir // virtual
393cdf0e10cSrcweir Reference< XPersistentPropertySet > SAL_CALL
openPropertySet(const OUString & key,sal_Bool create)394cdf0e10cSrcweir PropertySetRegistry::openPropertySet( const OUString& key, sal_Bool create )
395cdf0e10cSrcweir 	throw( RuntimeException )
396cdf0e10cSrcweir {
397cdf0e10cSrcweir 	if ( key.getLength() )
398cdf0e10cSrcweir 	{
399cdf0e10cSrcweir 		osl::Guard< osl::Mutex > aGuard( m_pImpl->m_aMutex );
400cdf0e10cSrcweir 
401cdf0e10cSrcweir 		PropertySetMap_Impl& rSets = m_pImpl->m_aPropSets;
402cdf0e10cSrcweir 
403cdf0e10cSrcweir 		PropertySetMap_Impl::const_iterator it = rSets.find( key );
404cdf0e10cSrcweir 		if ( it != rSets.end() )
405cdf0e10cSrcweir 		{
406cdf0e10cSrcweir 			// Already instanciated.
407cdf0e10cSrcweir 			return Reference< XPersistentPropertySet >( (*it).second );
408cdf0e10cSrcweir 		}
409cdf0e10cSrcweir 		else
410cdf0e10cSrcweir 		{
411cdf0e10cSrcweir 			// Create new instance.
412cdf0e10cSrcweir             Reference< XNameAccess > xRootNameAccess(
413cdf0e10cSrcweir 									getRootConfigReadAccess(), UNO_QUERY );
414cdf0e10cSrcweir             if ( xRootNameAccess.is() )
415cdf0e10cSrcweir 			{
416cdf0e10cSrcweir 				// Propertyset in registry?
417cdf0e10cSrcweir                 if ( xRootNameAccess->hasByName( key ) )
418cdf0e10cSrcweir 				{
419cdf0e10cSrcweir 					// Yep!
420cdf0e10cSrcweir 					return Reference< XPersistentPropertySet >(
421cdf0e10cSrcweir 											new PersistentPropertySet(
422cdf0e10cSrcweir 													m_xSMgr, *this, key ) );
423cdf0e10cSrcweir 				}
424cdf0e10cSrcweir 				else if ( create )
425cdf0e10cSrcweir 				{
426cdf0e10cSrcweir 					// No. Create entry for propertyset.
427cdf0e10cSrcweir 
428cdf0e10cSrcweir 					Reference< XSingleServiceFactory > xFac(
429cdf0e10cSrcweir 							getConfigWriteAccess( OUString() ), UNO_QUERY );
430cdf0e10cSrcweir 					Reference< XChangesBatch >  xBatch( xFac, UNO_QUERY );
431cdf0e10cSrcweir 					Reference< XNameContainer > xContainer( xFac, UNO_QUERY );
432cdf0e10cSrcweir 
433cdf0e10cSrcweir 					OSL_ENSURE( xFac.is(),
434cdf0e10cSrcweir 								"PropertySetRegistry::openPropertySet - "
435cdf0e10cSrcweir 								"No factory!" );
436cdf0e10cSrcweir 
437cdf0e10cSrcweir 					OSL_ENSURE( xBatch.is(),
438cdf0e10cSrcweir 								"PropertySetRegistry::openPropertySet - "
439cdf0e10cSrcweir 								"No batch!" );
440cdf0e10cSrcweir 
441cdf0e10cSrcweir 					OSL_ENSURE( xContainer.is(),
442cdf0e10cSrcweir 								"PropertySetRegistry::openPropertySet - "
443cdf0e10cSrcweir 								"No conteiner!" );
444cdf0e10cSrcweir 
445cdf0e10cSrcweir 					if ( xFac.is() && xBatch.is() && xContainer.is() )
446cdf0e10cSrcweir 					{
447cdf0e10cSrcweir 						try
448cdf0e10cSrcweir 						{
449cdf0e10cSrcweir 							// Create new "Properties" config item.
450cdf0e10cSrcweir 							Reference< XNameReplace > xNameReplace(
451cdf0e10cSrcweir 										xFac->createInstance(), UNO_QUERY );
452cdf0e10cSrcweir 
453cdf0e10cSrcweir 							if ( xNameReplace.is() )
454cdf0e10cSrcweir 							{
455cdf0e10cSrcweir 								// Fill new item...
456cdf0e10cSrcweir 
457cdf0e10cSrcweir //								// Set Values
458cdf0e10cSrcweir //								xNameReplace->replaceByName(
459cdf0e10cSrcweir //										OUString::createFromAscii( "Values" ),
460cdf0e10cSrcweir //										makeAny( ... ) );
461cdf0e10cSrcweir 
462cdf0e10cSrcweir 								// Insert new item.
463cdf0e10cSrcweir 								xContainer->insertByName(
464cdf0e10cSrcweir                                         key, makeAny( xNameReplace ) );
465cdf0e10cSrcweir 								// Commit changes.
466cdf0e10cSrcweir 								xBatch->commitChanges();
467cdf0e10cSrcweir 
468cdf0e10cSrcweir 								return Reference< XPersistentPropertySet >(
469cdf0e10cSrcweir 											new PersistentPropertySet(
470cdf0e10cSrcweir 													m_xSMgr, *this, key ) );
471cdf0e10cSrcweir 							}
472cdf0e10cSrcweir 						}
473cdf0e10cSrcweir 						catch ( IllegalArgumentException& )
474cdf0e10cSrcweir 						{
475cdf0e10cSrcweir 							// insertByName
476cdf0e10cSrcweir 
477cdf0e10cSrcweir 							OSL_ENSURE( sal_False,
478cdf0e10cSrcweir 										"PropertySetRegistry::openPropertySet - "
479cdf0e10cSrcweir 										"caught IllegalArgumentException!" );
480cdf0e10cSrcweir 						}
481cdf0e10cSrcweir 						catch ( ElementExistException& )
482cdf0e10cSrcweir 						{
483cdf0e10cSrcweir 							// insertByName
484cdf0e10cSrcweir 
485cdf0e10cSrcweir 							OSL_ENSURE( sal_False,
486cdf0e10cSrcweir 										"PropertySetRegistry::openPropertySet - "
487cdf0e10cSrcweir 										"caught ElementExistException!" );
488cdf0e10cSrcweir 						}
489cdf0e10cSrcweir 						catch ( WrappedTargetException& )
490cdf0e10cSrcweir 						{
491cdf0e10cSrcweir 							// insertByName, commitChanges
492cdf0e10cSrcweir 
493cdf0e10cSrcweir 							OSL_ENSURE( sal_False,
494cdf0e10cSrcweir 										"PropertySetRegistry::openPropertySet - "
495cdf0e10cSrcweir 										"caught WrappedTargetException!" );
496cdf0e10cSrcweir 						}
497cdf0e10cSrcweir 						catch ( RuntimeException& )
498cdf0e10cSrcweir 						{
499cdf0e10cSrcweir 							OSL_ENSURE( sal_False,
500cdf0e10cSrcweir 										"PropertySetRegistry::openPropertySet - "
501cdf0e10cSrcweir 										"caught RuntimeException!" );
502cdf0e10cSrcweir 						}
503cdf0e10cSrcweir 						catch ( Exception& )
504cdf0e10cSrcweir 						{
505cdf0e10cSrcweir 							// createInstance
506cdf0e10cSrcweir 
507cdf0e10cSrcweir 							OSL_ENSURE( sal_False,
508cdf0e10cSrcweir 										"PropertySetRegistry::openPropertySet - "
509cdf0e10cSrcweir 										"caught Exception!" );
510cdf0e10cSrcweir 						}
511cdf0e10cSrcweir 					}
512cdf0e10cSrcweir 				}
513cdf0e10cSrcweir 				else
514cdf0e10cSrcweir 				{
515cdf0e10cSrcweir 					// No entry. Fail, but no error.
516cdf0e10cSrcweir 					return Reference< XPersistentPropertySet >();
517cdf0e10cSrcweir 				}
518cdf0e10cSrcweir 			}
519cdf0e10cSrcweir 
520cdf0e10cSrcweir 			OSL_ENSURE( sal_False,
521cdf0e10cSrcweir 						"PropertySetRegistry::openPropertySet - Error!" );
522cdf0e10cSrcweir 		}
523cdf0e10cSrcweir 	}
524cdf0e10cSrcweir 
525cdf0e10cSrcweir 	return Reference< XPersistentPropertySet >();
526cdf0e10cSrcweir }
527cdf0e10cSrcweir 
528cdf0e10cSrcweir //=========================================================================
529cdf0e10cSrcweir // virtual
removePropertySet(const OUString & key)530cdf0e10cSrcweir void SAL_CALL PropertySetRegistry::removePropertySet( const OUString& key )
531cdf0e10cSrcweir 	throw( RuntimeException )
532cdf0e10cSrcweir {
533cdf0e10cSrcweir 	if ( !key.getLength() )
534cdf0e10cSrcweir 		return;
535cdf0e10cSrcweir 
536cdf0e10cSrcweir 	osl::Guard< osl::Mutex > aGuard( m_pImpl->m_aMutex );
537cdf0e10cSrcweir 
538cdf0e10cSrcweir     Reference< XNameAccess > xRootNameAccess(
539cdf0e10cSrcweir 									getRootConfigReadAccess(), UNO_QUERY );
540cdf0e10cSrcweir     if ( xRootNameAccess.is() )
541cdf0e10cSrcweir 	{
542cdf0e10cSrcweir 		// Propertyset in registry?
543cdf0e10cSrcweir         if ( !xRootNameAccess->hasByName( key ) )
544cdf0e10cSrcweir 			return;
545cdf0e10cSrcweir 		Reference< XChangesBatch > xBatch(
546cdf0e10cSrcweir 							getConfigWriteAccess( OUString() ), UNO_QUERY );
547cdf0e10cSrcweir 		Reference< XNameContainer > xContainer( xBatch, UNO_QUERY );
548cdf0e10cSrcweir 
549cdf0e10cSrcweir 		OSL_ENSURE( xBatch.is(),
550cdf0e10cSrcweir 					"PropertySetRegistry::removePropertySet - "
551cdf0e10cSrcweir 					"No batch!" );
552cdf0e10cSrcweir 
553cdf0e10cSrcweir 		OSL_ENSURE( xContainer.is(),
554cdf0e10cSrcweir 					"PropertySetRegistry::removePropertySet - "
555cdf0e10cSrcweir 					"No conteiner!" );
556cdf0e10cSrcweir 
557cdf0e10cSrcweir 		if ( xBatch.is() && xContainer.is() )
558cdf0e10cSrcweir 		{
559cdf0e10cSrcweir 			try
560cdf0e10cSrcweir 			{
561cdf0e10cSrcweir 				// Remove item.
562cdf0e10cSrcweir                 xContainer->removeByName( key );
563cdf0e10cSrcweir 				// Commit changes.
564cdf0e10cSrcweir 				xBatch->commitChanges();
565cdf0e10cSrcweir 
566cdf0e10cSrcweir 				// Success.
567cdf0e10cSrcweir 				return;
568cdf0e10cSrcweir 			}
569cdf0e10cSrcweir 			catch ( NoSuchElementException& )
570cdf0e10cSrcweir 			{
571cdf0e10cSrcweir 				// removeByName
572cdf0e10cSrcweir 
573cdf0e10cSrcweir 				OSL_ENSURE( sal_False,
574cdf0e10cSrcweir 							"PropertySetRegistry::removePropertySet - "
575cdf0e10cSrcweir 							"caught NoSuchElementException!" );
576cdf0e10cSrcweir 				return;
577cdf0e10cSrcweir 			}
578cdf0e10cSrcweir 			catch ( WrappedTargetException& )
579cdf0e10cSrcweir 			{
580cdf0e10cSrcweir 				// commitChanges
581cdf0e10cSrcweir 
582cdf0e10cSrcweir 				OSL_ENSURE( sal_False,
583cdf0e10cSrcweir 							"PropertySetRegistry::removePropertySet - "
584cdf0e10cSrcweir 							"caught WrappedTargetException!" );
585cdf0e10cSrcweir 				return;
586cdf0e10cSrcweir 			}
587cdf0e10cSrcweir 		}
588cdf0e10cSrcweir 
589cdf0e10cSrcweir 		return;
590cdf0e10cSrcweir 	}
591cdf0e10cSrcweir 
592cdf0e10cSrcweir 	OSL_ENSURE( sal_False, "PropertySetRegistry::removePropertySet - Error!" );
593cdf0e10cSrcweir }
594cdf0e10cSrcweir 
595cdf0e10cSrcweir //=========================================================================
596cdf0e10cSrcweir //
597cdf0e10cSrcweir // XElementAccess methods.
598cdf0e10cSrcweir //
599cdf0e10cSrcweir //=========================================================================
600cdf0e10cSrcweir 
601cdf0e10cSrcweir // virtual
getElementType()602cdf0e10cSrcweir com::sun::star::uno::Type SAL_CALL PropertySetRegistry::getElementType()
603cdf0e10cSrcweir 	throw( RuntimeException )
604cdf0e10cSrcweir {
605cdf0e10cSrcweir 	return getCppuType( ( Reference< XPersistentPropertySet > * ) 0 );
606cdf0e10cSrcweir }
607cdf0e10cSrcweir 
608cdf0e10cSrcweir //=========================================================================
609cdf0e10cSrcweir // virtual
hasElements()610cdf0e10cSrcweir sal_Bool SAL_CALL PropertySetRegistry::hasElements()
611cdf0e10cSrcweir 	throw( RuntimeException )
612cdf0e10cSrcweir {
613cdf0e10cSrcweir 	osl::Guard< osl::Mutex > aGuard( m_pImpl->m_aMutex );
614cdf0e10cSrcweir 
615cdf0e10cSrcweir 	Reference< XElementAccess > xElemAccess(
616cdf0e10cSrcweir 									getRootConfigReadAccess(), UNO_QUERY );
617cdf0e10cSrcweir 	if ( xElemAccess.is() )
618cdf0e10cSrcweir 		return xElemAccess->hasElements();
619cdf0e10cSrcweir 
620cdf0e10cSrcweir 	return sal_False;
621cdf0e10cSrcweir }
622cdf0e10cSrcweir 
623cdf0e10cSrcweir //=========================================================================
624cdf0e10cSrcweir //
625cdf0e10cSrcweir // XNameAccess methods.
626cdf0e10cSrcweir //
627cdf0e10cSrcweir //=========================================================================
628cdf0e10cSrcweir 
629cdf0e10cSrcweir // virtual
getByName(const OUString & aName)630cdf0e10cSrcweir Any SAL_CALL PropertySetRegistry::getByName( const OUString& aName )
631cdf0e10cSrcweir 	throw( NoSuchElementException, WrappedTargetException, RuntimeException )
632cdf0e10cSrcweir {
633cdf0e10cSrcweir 	osl::Guard< osl::Mutex > aGuard( m_pImpl->m_aMutex );
634cdf0e10cSrcweir 
635cdf0e10cSrcweir 	Reference< XNameAccess > xNameAccess(
636cdf0e10cSrcweir 									getRootConfigReadAccess(), UNO_QUERY );
637cdf0e10cSrcweir 	if ( xNameAccess.is() )
638cdf0e10cSrcweir 	{
639cdf0e10cSrcweir 
640cdf0e10cSrcweir 		try
641cdf0e10cSrcweir 		{
642cdf0e10cSrcweir             return xNameAccess->getByName( aName );
643cdf0e10cSrcweir 		}
644cdf0e10cSrcweir 		catch ( NoSuchElementException& )
645cdf0e10cSrcweir 		{
646cdf0e10cSrcweir 			// getByName
647cdf0e10cSrcweir 		}
648cdf0e10cSrcweir 		catch ( WrappedTargetException& )
649cdf0e10cSrcweir 		{
650cdf0e10cSrcweir 			// getByName
651cdf0e10cSrcweir 		}
652cdf0e10cSrcweir 	}
653cdf0e10cSrcweir 
654cdf0e10cSrcweir 	return Any();
655cdf0e10cSrcweir }
656cdf0e10cSrcweir 
657cdf0e10cSrcweir //=========================================================================
658cdf0e10cSrcweir // virtual
getElementNames()659cdf0e10cSrcweir Sequence< OUString > SAL_CALL PropertySetRegistry::getElementNames()
660cdf0e10cSrcweir 	throw( RuntimeException )
661cdf0e10cSrcweir {
662cdf0e10cSrcweir 	osl::Guard< osl::Mutex > aGuard( m_pImpl->m_aMutex );
663cdf0e10cSrcweir 
664cdf0e10cSrcweir 	Reference< XNameAccess > xNameAccess(
665cdf0e10cSrcweir 									getRootConfigReadAccess(), UNO_QUERY );
666cdf0e10cSrcweir 	if ( xNameAccess.is() )
667cdf0e10cSrcweir 	{
668cdf0e10cSrcweir         return xNameAccess->getElementNames();
669cdf0e10cSrcweir 	}
670cdf0e10cSrcweir 	return Sequence< OUString >( 0 );
671cdf0e10cSrcweir }
672cdf0e10cSrcweir 
673cdf0e10cSrcweir //=========================================================================
674cdf0e10cSrcweir // virtual
hasByName(const OUString & aName)675cdf0e10cSrcweir sal_Bool SAL_CALL PropertySetRegistry::hasByName( const OUString& aName )
676cdf0e10cSrcweir 	throw( RuntimeException )
677cdf0e10cSrcweir {
678cdf0e10cSrcweir 	osl::Guard< osl::Mutex > aGuard( m_pImpl->m_aMutex );
679cdf0e10cSrcweir 
680cdf0e10cSrcweir 	Reference< XNameAccess > xNameAccess(
681cdf0e10cSrcweir 									getRootConfigReadAccess(), UNO_QUERY );
682cdf0e10cSrcweir 	if ( xNameAccess.is() )
683cdf0e10cSrcweir 	{
684cdf0e10cSrcweir         return xNameAccess->hasByName( aName );
685cdf0e10cSrcweir 	}
686cdf0e10cSrcweir 
687cdf0e10cSrcweir 	return sal_False;
688cdf0e10cSrcweir }
689cdf0e10cSrcweir 
690cdf0e10cSrcweir //=========================================================================
add(PersistentPropertySet * pSet)691cdf0e10cSrcweir void PropertySetRegistry::add( PersistentPropertySet* pSet )
692cdf0e10cSrcweir {
693cdf0e10cSrcweir 	OUString key( pSet->getKey() );
694cdf0e10cSrcweir 
695cdf0e10cSrcweir 	if ( key.getLength() )
696cdf0e10cSrcweir 	{
697cdf0e10cSrcweir 		osl::Guard< osl::Mutex > aGuard( m_pImpl->m_aMutex );
698cdf0e10cSrcweir 		m_pImpl->m_aPropSets[ key ] = pSet;
699cdf0e10cSrcweir 	}
700cdf0e10cSrcweir }
701cdf0e10cSrcweir 
702cdf0e10cSrcweir //=========================================================================
remove(PersistentPropertySet * pSet)703cdf0e10cSrcweir void PropertySetRegistry::remove( PersistentPropertySet* pSet )
704cdf0e10cSrcweir {
705cdf0e10cSrcweir 	OUString key( pSet->getKey() );
706cdf0e10cSrcweir 
707cdf0e10cSrcweir 	if ( key.getLength() )
708cdf0e10cSrcweir 	{
709cdf0e10cSrcweir 		osl::Guard< osl::Mutex > aGuard( m_pImpl->m_aMutex );
710cdf0e10cSrcweir 
711cdf0e10cSrcweir 		PropertySetMap_Impl& rSets = m_pImpl->m_aPropSets;
712cdf0e10cSrcweir 
713cdf0e10cSrcweir 		PropertySetMap_Impl::iterator it = rSets.find( key );
714cdf0e10cSrcweir 		if ( it != rSets.end() )
715cdf0e10cSrcweir 		{
716cdf0e10cSrcweir 			// Found.
717cdf0e10cSrcweir 			rSets.erase( it );
718cdf0e10cSrcweir 		}
719cdf0e10cSrcweir 	}
720cdf0e10cSrcweir }
721cdf0e10cSrcweir 
722cdf0e10cSrcweir //=========================================================================
renamePropertySet(const OUString & rOldKey,const OUString & rNewKey)723cdf0e10cSrcweir void PropertySetRegistry::renamePropertySet( const OUString& rOldKey,
724cdf0e10cSrcweir 										     const OUString& rNewKey )
725cdf0e10cSrcweir {
726cdf0e10cSrcweir 	if ( rOldKey == rNewKey )
727cdf0e10cSrcweir 		return;
728cdf0e10cSrcweir 
729cdf0e10cSrcweir     Reference< XNameAccess > xRootNameAccess(
730cdf0e10cSrcweir 							getConfigWriteAccess( OUString() ), UNO_QUERY );
731cdf0e10cSrcweir     if ( xRootNameAccess.is() )
732cdf0e10cSrcweir 	{
733cdf0e10cSrcweir         // Old key present?
734cdf0e10cSrcweir         if ( xRootNameAccess->hasByName( rOldKey ) )
735cdf0e10cSrcweir         {
736cdf0e10cSrcweir             // New key not present?
737cdf0e10cSrcweir             if ( xRootNameAccess->hasByName( rNewKey ) )
738cdf0e10cSrcweir             {
739cdf0e10cSrcweir                 OSL_ENSURE( sal_False,
740cdf0e10cSrcweir                             "PropertySetRegistry::renamePropertySet - "
741cdf0e10cSrcweir                             "New key exists!" );
742cdf0e10cSrcweir                 return;
743cdf0e10cSrcweir             }
744cdf0e10cSrcweir             Reference< XSingleServiceFactory > xFac(
745cdf0e10cSrcweir                                                 xRootNameAccess, UNO_QUERY );
746cdf0e10cSrcweir             Reference< XChangesBatch >  xBatch( xFac, UNO_QUERY );
747cdf0e10cSrcweir             Reference< XNameContainer > xContainer( xFac, UNO_QUERY );
748cdf0e10cSrcweir 
749cdf0e10cSrcweir             OSL_ENSURE( xFac.is(),
750cdf0e10cSrcweir                         "PropertySetRegistry::renamePropertySet - "
751cdf0e10cSrcweir                         "No factory!" );
752cdf0e10cSrcweir 
753cdf0e10cSrcweir             OSL_ENSURE( xBatch.is(),
754cdf0e10cSrcweir                         "PropertySetRegistry::renamePropertySet - "
755cdf0e10cSrcweir                         "No batch!" );
756cdf0e10cSrcweir 
757cdf0e10cSrcweir             OSL_ENSURE( xContainer.is(),
758cdf0e10cSrcweir                         "PropertySetRegistry::renamePropertySet - "
759cdf0e10cSrcweir                         "No container!" );
760cdf0e10cSrcweir 
761cdf0e10cSrcweir             if ( xFac.is() && xBatch.is() && xContainer.is() )
762cdf0e10cSrcweir             {
763cdf0e10cSrcweir                 //////////////////////////////////////////////////////
764cdf0e10cSrcweir                 // Create new "Properties" config item.
765cdf0e10cSrcweir                 //////////////////////////////////////////////////////
766cdf0e10cSrcweir 
767cdf0e10cSrcweir                 try
768cdf0e10cSrcweir                 {
769cdf0e10cSrcweir                     Reference< XNameReplace > xNameReplace(
770cdf0e10cSrcweir                                     xFac->createInstance(), UNO_QUERY );
771cdf0e10cSrcweir 
772cdf0e10cSrcweir                     if ( xNameReplace.is() )
773cdf0e10cSrcweir                     {
774cdf0e10cSrcweir                         // Insert new item.
775cdf0e10cSrcweir                         xContainer->insertByName(
776cdf0e10cSrcweir                                     rNewKey, makeAny( xNameReplace ) );
777cdf0e10cSrcweir                         // Commit changes.
778cdf0e10cSrcweir                         xBatch->commitChanges();
779cdf0e10cSrcweir                     }
780cdf0e10cSrcweir                 }
781cdf0e10cSrcweir                 catch ( IllegalArgumentException& )
782cdf0e10cSrcweir                 {
783cdf0e10cSrcweir                     // insertByName
784cdf0e10cSrcweir 
785cdf0e10cSrcweir                     OSL_ENSURE( sal_False,
786cdf0e10cSrcweir                                 "PropertySetRegistry::renamePropertySet - "
787cdf0e10cSrcweir                                 "caught IllegalArgumentException!" );
788cdf0e10cSrcweir                     return;
789cdf0e10cSrcweir                 }
790cdf0e10cSrcweir                 catch ( ElementExistException& )
791cdf0e10cSrcweir                 {
792cdf0e10cSrcweir                     // insertByName
793cdf0e10cSrcweir 
794cdf0e10cSrcweir                     OSL_ENSURE( sal_False,
795cdf0e10cSrcweir                                 "PropertySetRegistry::renamePropertySet - "
796cdf0e10cSrcweir                                 "caught ElementExistException!" );
797cdf0e10cSrcweir                     return;
798cdf0e10cSrcweir                 }
799cdf0e10cSrcweir                 catch ( WrappedTargetException& )
800cdf0e10cSrcweir                 {
801cdf0e10cSrcweir                     // insertByName, commitChanges
802cdf0e10cSrcweir 
803cdf0e10cSrcweir                     OSL_ENSURE( sal_False,
804cdf0e10cSrcweir                                 "PropertySetRegistry::renamePropertySet - "
805cdf0e10cSrcweir                                 "caught WrappedTargetException!" );
806cdf0e10cSrcweir                     return;
807cdf0e10cSrcweir                 }
808cdf0e10cSrcweir                 catch ( RuntimeException& )
809cdf0e10cSrcweir                 {
810cdf0e10cSrcweir                     OSL_ENSURE( sal_False,
811cdf0e10cSrcweir                                 "PropertySetRegistry::renamePropertySet - "
812cdf0e10cSrcweir                                 "caught RuntimeException!" );
813cdf0e10cSrcweir                     return;
814cdf0e10cSrcweir                 }
815cdf0e10cSrcweir                 catch ( Exception& )
816cdf0e10cSrcweir                 {
817cdf0e10cSrcweir                     // createInstance
818cdf0e10cSrcweir 
819cdf0e10cSrcweir                     OSL_ENSURE( sal_False,
820cdf0e10cSrcweir                                 "PropertySetRegistry::renamePropertySet - "
821cdf0e10cSrcweir                                 "caught Exception!" );
822cdf0e10cSrcweir                     return;
823cdf0e10cSrcweir                 }
824cdf0e10cSrcweir 
825cdf0e10cSrcweir                 //////////////////////////////////////////////////////
826cdf0e10cSrcweir                 // Copy data...
827cdf0e10cSrcweir                 //////////////////////////////////////////////////////
828cdf0e10cSrcweir 
829cdf0e10cSrcweir                 Reference< XHierarchicalNameAccess > xRootHierNameAccess(
830cdf0e10cSrcweir                                                 xRootNameAccess, UNO_QUERY );
831cdf0e10cSrcweir                 if ( !xRootHierNameAccess.is() )
832cdf0e10cSrcweir                 {
833cdf0e10cSrcweir                     OSL_ENSURE( sal_False,
834cdf0e10cSrcweir                                 "PropertySetRegistry::renamePropertySet - "
835cdf0e10cSrcweir                                 "No hierarchical name access!" );
836cdf0e10cSrcweir                     return;
837cdf0e10cSrcweir                 }
838cdf0e10cSrcweir 
839cdf0e10cSrcweir                 try
840cdf0e10cSrcweir                 {
841cdf0e10cSrcweir                     rtl::OUString aOldValuesKey
842cdf0e10cSrcweir                         = makeHierarchalNameSegment( rOldKey );
843cdf0e10cSrcweir                     aOldValuesKey += OUString::createFromAscii( "/Values" );
844cdf0e10cSrcweir 
845cdf0e10cSrcweir                     Reference< XNameAccess > xOldNameAccess;
846cdf0e10cSrcweir                     xRootHierNameAccess->getByHierarchicalName(
847cdf0e10cSrcweir                                                         aOldValuesKey )
848cdf0e10cSrcweir                         >>= xOldNameAccess;
849cdf0e10cSrcweir                     if ( !xOldNameAccess.is() )
850cdf0e10cSrcweir                     {
851cdf0e10cSrcweir                         OSL_ENSURE( sal_False,
852cdf0e10cSrcweir                             "PersistentPropertySet::renamePropertySet - "
853cdf0e10cSrcweir                             "No old name access!" );
854cdf0e10cSrcweir                         return;
855cdf0e10cSrcweir                     }
856cdf0e10cSrcweir 
857cdf0e10cSrcweir                     // Obtain property names.
858cdf0e10cSrcweir                     Sequence< OUString > aElems
859cdf0e10cSrcweir                                     = xOldNameAccess->getElementNames();
860cdf0e10cSrcweir                     sal_Int32 nCount = aElems.getLength();
861cdf0e10cSrcweir                     if ( nCount )
862cdf0e10cSrcweir                     {
863cdf0e10cSrcweir                         rtl::OUString aNewValuesKey
864cdf0e10cSrcweir                             = makeHierarchalNameSegment( rNewKey );
865cdf0e10cSrcweir                         aNewValuesKey += OUString::createFromAscii( "/Values" );
866cdf0e10cSrcweir 
867cdf0e10cSrcweir                         Reference< XSingleServiceFactory > xNewFac;
868cdf0e10cSrcweir                         xRootHierNameAccess->getByHierarchicalName(
869cdf0e10cSrcweir                                                         aNewValuesKey )
870cdf0e10cSrcweir                             >>= xNewFac;
871cdf0e10cSrcweir                         if ( !xNewFac.is() )
872cdf0e10cSrcweir                         {
873cdf0e10cSrcweir                             OSL_ENSURE( sal_False,
874cdf0e10cSrcweir                                 "PersistentPropertySet::renamePropertySet - "
875cdf0e10cSrcweir                                 "No new factory!" );
876cdf0e10cSrcweir                             return;
877cdf0e10cSrcweir                         }
878cdf0e10cSrcweir 
879cdf0e10cSrcweir                         Reference< XNameContainer > xNewContainer(
880cdf0e10cSrcweir                                                     xNewFac, UNO_QUERY );
881cdf0e10cSrcweir                         if ( !xNewContainer.is() )
882cdf0e10cSrcweir                         {
883cdf0e10cSrcweir                             OSL_ENSURE( sal_False,
884cdf0e10cSrcweir                                 "PersistentPropertySet::renamePropertySet - "
885cdf0e10cSrcweir                                 "No new container!" );
886cdf0e10cSrcweir                             return;
887cdf0e10cSrcweir                         }
888cdf0e10cSrcweir 
889cdf0e10cSrcweir                         aOldValuesKey += OUString::createFromAscii( "/" );
890cdf0e10cSrcweir 
891cdf0e10cSrcweir                         OUString aHandleKey
892cdf0e10cSrcweir                             = OUString::createFromAscii( "/Handle" );
893cdf0e10cSrcweir                         OUString aValueKey
894cdf0e10cSrcweir                             = OUString::createFromAscii( "/Value" );
895cdf0e10cSrcweir                         OUString aStateKey
896cdf0e10cSrcweir                             = OUString::createFromAscii( "/State" );
897cdf0e10cSrcweir                         OUString aAttrKey
898cdf0e10cSrcweir                             = OUString::createFromAscii( "/Attributes" );
899cdf0e10cSrcweir 
900cdf0e10cSrcweir                         for ( sal_Int32 n = 0; n < nCount; ++n )
901cdf0e10cSrcweir                         {
902cdf0e10cSrcweir                             const OUString& rPropName = aElems[ n ];
903cdf0e10cSrcweir 
904cdf0e10cSrcweir                             // Create new item.
905cdf0e10cSrcweir                             Reference< XNameReplace > xNewPropNameReplace(
906cdf0e10cSrcweir                                 xNewFac->createInstance(), UNO_QUERY );
907cdf0e10cSrcweir 
908cdf0e10cSrcweir                             if ( !xNewPropNameReplace.is() )
909cdf0e10cSrcweir                             {
910cdf0e10cSrcweir                                 OSL_ENSURE( sal_False,
911cdf0e10cSrcweir                                     "PersistentPropertySet::renamePropertySet - "
912cdf0e10cSrcweir                                     "No new prop name replace!" );
913cdf0e10cSrcweir                                 return;
914cdf0e10cSrcweir                             }
915cdf0e10cSrcweir 
916cdf0e10cSrcweir                             // Fill new item...
917cdf0e10cSrcweir 
918cdf0e10cSrcweir                             // Set Values
919cdf0e10cSrcweir                             OUString aKey = aOldValuesKey;
920cdf0e10cSrcweir                             aKey += makeHierarchalNameSegment( rPropName );
921cdf0e10cSrcweir 
922cdf0e10cSrcweir                             // ... handle
923cdf0e10cSrcweir                             OUString aNewKey1 = aKey;
924cdf0e10cSrcweir                             aNewKey1 += aHandleKey;
925cdf0e10cSrcweir                             Any aAny =
926cdf0e10cSrcweir                                 xRootHierNameAccess->getByHierarchicalName(
927cdf0e10cSrcweir                                     aNewKey1 );
928cdf0e10cSrcweir                             xNewPropNameReplace->replaceByName(
929cdf0e10cSrcweir                                 OUString::createFromAscii( "Handle" ),
930cdf0e10cSrcweir                                 aAny );
931cdf0e10cSrcweir 
932cdf0e10cSrcweir                             // ... value
933cdf0e10cSrcweir                             aNewKey1 = aKey;
934cdf0e10cSrcweir                             aNewKey1 += aValueKey;
935cdf0e10cSrcweir                             aAny =
936cdf0e10cSrcweir                                 xRootHierNameAccess->getByHierarchicalName(
937cdf0e10cSrcweir                                     aNewKey1 );
938cdf0e10cSrcweir                             xNewPropNameReplace->replaceByName(
939cdf0e10cSrcweir                                 OUString::createFromAscii( "Value" ),
940cdf0e10cSrcweir                                 aAny );
941cdf0e10cSrcweir 
942cdf0e10cSrcweir                             // ... state
943cdf0e10cSrcweir                             aNewKey1 = aKey;
944cdf0e10cSrcweir                             aNewKey1 += aStateKey;
945cdf0e10cSrcweir                             aAny =
946cdf0e10cSrcweir                                 xRootHierNameAccess->getByHierarchicalName(
947cdf0e10cSrcweir                                     aNewKey1 );
948cdf0e10cSrcweir                             xNewPropNameReplace->replaceByName(
949cdf0e10cSrcweir                                 OUString::createFromAscii( "State" ),
950cdf0e10cSrcweir                                 aAny );
951cdf0e10cSrcweir 
952cdf0e10cSrcweir                             // ... attributes
953cdf0e10cSrcweir                             aNewKey1 = aKey;
954cdf0e10cSrcweir                             aNewKey1 += aAttrKey;
955cdf0e10cSrcweir                             aAny =
956cdf0e10cSrcweir                                 xRootHierNameAccess->getByHierarchicalName(
957cdf0e10cSrcweir                                     aNewKey1 );
958cdf0e10cSrcweir                             xNewPropNameReplace->replaceByName(
959cdf0e10cSrcweir                                 OUString::createFromAscii( "Attributes" ),
960cdf0e10cSrcweir                                 aAny );
961cdf0e10cSrcweir 
962cdf0e10cSrcweir                             // Insert new item.
963cdf0e10cSrcweir                             xNewContainer->insertByName(
964cdf0e10cSrcweir                                 rPropName, makeAny( xNewPropNameReplace ) );
965cdf0e10cSrcweir 
966cdf0e10cSrcweir                             // Commit changes.
967cdf0e10cSrcweir                             xBatch->commitChanges();
968cdf0e10cSrcweir                         }
969cdf0e10cSrcweir                     }
970cdf0e10cSrcweir                 }
971cdf0e10cSrcweir                 catch ( IllegalArgumentException& )
972cdf0e10cSrcweir                 {
973cdf0e10cSrcweir                     // insertByName, replaceByName
974cdf0e10cSrcweir 
975cdf0e10cSrcweir                     OSL_ENSURE( sal_False,
976cdf0e10cSrcweir                                 "PropertySetRegistry::renamePropertySet - "
977cdf0e10cSrcweir                                 "caught IllegalArgumentException!" );
978cdf0e10cSrcweir                     return;
979cdf0e10cSrcweir                 }
980cdf0e10cSrcweir                 catch ( ElementExistException& )
981cdf0e10cSrcweir                 {
982cdf0e10cSrcweir                     // insertByName
983cdf0e10cSrcweir 
984cdf0e10cSrcweir                     OSL_ENSURE( sal_False,
985cdf0e10cSrcweir                                 "PropertySetRegistry::renamePropertySet - "
986cdf0e10cSrcweir                                 "caught ElementExistException!" );
987cdf0e10cSrcweir                     return;
988cdf0e10cSrcweir                 }
989cdf0e10cSrcweir                 catch ( WrappedTargetException& )
990cdf0e10cSrcweir                 {
991cdf0e10cSrcweir                     // insertByName, replaceByName, commitChanges
992cdf0e10cSrcweir 
993cdf0e10cSrcweir                     OSL_ENSURE( sal_False,
994cdf0e10cSrcweir                                 "PropertySetRegistry::renamePropertySet - "
995cdf0e10cSrcweir                                 "caught WrappedTargetException!" );
996cdf0e10cSrcweir                     return;
997cdf0e10cSrcweir                 }
998cdf0e10cSrcweir                 catch ( NoSuchElementException& )
999cdf0e10cSrcweir                 {
1000cdf0e10cSrcweir                     // getByHierarchicalName, replaceByName
1001cdf0e10cSrcweir 
1002cdf0e10cSrcweir                     OSL_ENSURE( sal_False,
1003cdf0e10cSrcweir                                 "PropertySetRegistry::renamePropertySet - "
1004cdf0e10cSrcweir                                 "caught NoSuchElementException!" );
1005cdf0e10cSrcweir                     return;
1006cdf0e10cSrcweir                 }
1007cdf0e10cSrcweir                 catch ( RuntimeException& )
1008cdf0e10cSrcweir                 {
1009cdf0e10cSrcweir                     OSL_ENSURE( sal_False,
1010cdf0e10cSrcweir                                 "PropertySetRegistry::renamePropertySet - "
1011cdf0e10cSrcweir                                 "caught RuntimeException!" );
1012cdf0e10cSrcweir                     return;
1013cdf0e10cSrcweir                 }
1014cdf0e10cSrcweir                 catch ( Exception& )
1015cdf0e10cSrcweir                 {
1016cdf0e10cSrcweir                     // createInstance
1017cdf0e10cSrcweir 
1018cdf0e10cSrcweir                     OSL_ENSURE( sal_False,
1019cdf0e10cSrcweir                                 "PropertySetRegistry::renamePropertySet - "
1020cdf0e10cSrcweir                                 "caught Exception!" );
1021cdf0e10cSrcweir                     return;
1022cdf0e10cSrcweir                 }
1023cdf0e10cSrcweir 
1024cdf0e10cSrcweir                 //////////////////////////////////////////////////////
1025cdf0e10cSrcweir                 // Remove old entry...
1026cdf0e10cSrcweir                 //////////////////////////////////////////////////////
1027cdf0e10cSrcweir 
1028cdf0e10cSrcweir                 try
1029cdf0e10cSrcweir                 {
1030cdf0e10cSrcweir                     // Remove item.
1031cdf0e10cSrcweir                     xContainer->removeByName( rOldKey );
1032cdf0e10cSrcweir                     // Commit changes.
1033cdf0e10cSrcweir                     xBatch->commitChanges();
1034cdf0e10cSrcweir 
1035cdf0e10cSrcweir                     // Success.
1036cdf0e10cSrcweir                     return;
1037cdf0e10cSrcweir                 }
1038cdf0e10cSrcweir                 catch ( NoSuchElementException& )
1039cdf0e10cSrcweir                 {
1040cdf0e10cSrcweir                     // removeByName
1041cdf0e10cSrcweir 
1042cdf0e10cSrcweir                     OSL_ENSURE( sal_False,
1043cdf0e10cSrcweir                                 "PropertySetRegistry::renamePropertySet - "
1044cdf0e10cSrcweir                                 "caught NoSuchElementException!" );
1045cdf0e10cSrcweir                     return;
1046cdf0e10cSrcweir                 }
1047cdf0e10cSrcweir                 catch ( WrappedTargetException& )
1048cdf0e10cSrcweir                 {
1049cdf0e10cSrcweir                     // commitChanges
1050cdf0e10cSrcweir 
1051cdf0e10cSrcweir                     OSL_ENSURE( sal_False,
1052cdf0e10cSrcweir                                 "PropertySetRegistry::renamePropertySet - "
1053cdf0e10cSrcweir                                 "caught WrappedTargetException!" );
1054cdf0e10cSrcweir                     return;
1055cdf0e10cSrcweir                 }
1056cdf0e10cSrcweir             }
1057cdf0e10cSrcweir         }
1058cdf0e10cSrcweir 	}
1059cdf0e10cSrcweir 
1060cdf0e10cSrcweir 	OSL_ENSURE( sal_False, "PropertySetRegistry::renamePropertySet - Error!" );
1061cdf0e10cSrcweir }
1062cdf0e10cSrcweir 
1063cdf0e10cSrcweir //=========================================================================
getConfigProvider()1064cdf0e10cSrcweir Reference< XMultiServiceFactory > PropertySetRegistry::getConfigProvider()
1065cdf0e10cSrcweir {
1066cdf0e10cSrcweir 	if ( !m_pImpl->m_xConfigProvider.is() )
1067cdf0e10cSrcweir 	{
1068cdf0e10cSrcweir 		osl::Guard< osl::Mutex > aGuard( m_pImpl->m_aMutex );
1069cdf0e10cSrcweir 		if ( !m_pImpl->m_xConfigProvider.is() )
1070cdf0e10cSrcweir 		{
1071cdf0e10cSrcweir 			const Sequence< Any >& rInitArgs = m_pImpl->m_aInitArgs;
1072cdf0e10cSrcweir 
1073cdf0e10cSrcweir 			if ( rInitArgs.getLength() > 0 )
1074cdf0e10cSrcweir 			{
1075cdf0e10cSrcweir 				// Extract config provider from service init args.
1076cdf0e10cSrcweir 				rInitArgs[ 0 ] >>= m_pImpl->m_xConfigProvider;
1077cdf0e10cSrcweir 
1078cdf0e10cSrcweir 				OSL_ENSURE( m_pImpl->m_xConfigProvider.is(),
1079cdf0e10cSrcweir 							"PropertySetRegistry::getConfigProvider - "
1080cdf0e10cSrcweir 							"No config provider!" );
1081cdf0e10cSrcweir 			}
1082cdf0e10cSrcweir 			else
1083cdf0e10cSrcweir 			{
1084cdf0e10cSrcweir 				try
1085cdf0e10cSrcweir 				{
1086cdf0e10cSrcweir 					m_pImpl->m_xConfigProvider
1087cdf0e10cSrcweir 						= Reference< XMultiServiceFactory >(
1088cdf0e10cSrcweir 							m_xSMgr->createInstance(
1089cdf0e10cSrcweir 								OUString::createFromAscii(
1090cdf0e10cSrcweir 									"com.sun.star.configuration."
1091cdf0e10cSrcweir 									"ConfigurationProvider" ) ),
1092cdf0e10cSrcweir 							UNO_QUERY );
1093cdf0e10cSrcweir 
1094cdf0e10cSrcweir 					OSL_ENSURE( m_pImpl->m_xConfigProvider.is(),
1095cdf0e10cSrcweir 								"PropertySetRegistry::getConfigProvider - "
1096cdf0e10cSrcweir 								"No config provider!" );
1097cdf0e10cSrcweir 
1098cdf0e10cSrcweir 				}
1099cdf0e10cSrcweir 				catch ( Exception& )
1100cdf0e10cSrcweir 				{
1101cdf0e10cSrcweir 					OSL_ENSURE( sal_False,
1102cdf0e10cSrcweir 								"PropertySetRegistry::getConfigProvider - "
1103cdf0e10cSrcweir 								"caught exception!" );
1104cdf0e10cSrcweir 				}
1105cdf0e10cSrcweir 			}
1106cdf0e10cSrcweir 		}
1107cdf0e10cSrcweir 	}
1108cdf0e10cSrcweir 
1109cdf0e10cSrcweir 	return m_pImpl->m_xConfigProvider;
1110cdf0e10cSrcweir }
1111cdf0e10cSrcweir 
1112cdf0e10cSrcweir //=========================================================================
getRootConfigReadAccess()1113cdf0e10cSrcweir Reference< XInterface > PropertySetRegistry::getRootConfigReadAccess()
1114cdf0e10cSrcweir {
1115cdf0e10cSrcweir 	try
1116cdf0e10cSrcweir 	{
1117cdf0e10cSrcweir 		osl::Guard< osl::Mutex > aGuard( m_pImpl->m_aMutex );
1118cdf0e10cSrcweir 
1119cdf0e10cSrcweir 		if ( !m_pImpl->m_xRootReadAccess.is() )
1120cdf0e10cSrcweir 		{
1121cdf0e10cSrcweir 			if ( m_pImpl->m_bTriedToGetRootReadAccess ) // #82494#
1122cdf0e10cSrcweir 			{
1123cdf0e10cSrcweir 				OSL_ENSURE( sal_False,
1124cdf0e10cSrcweir 							"PropertySetRegistry::getRootConfigReadAccess - "
1125cdf0e10cSrcweir 							"Unable to read any config data! -> #82494#" );
1126cdf0e10cSrcweir 				return Reference< XInterface >();
1127cdf0e10cSrcweir 			}
1128cdf0e10cSrcweir 
1129cdf0e10cSrcweir 			getConfigProvider();
1130cdf0e10cSrcweir 
1131cdf0e10cSrcweir 			if ( m_pImpl->m_xConfigProvider.is() )
1132cdf0e10cSrcweir 			{
1133cdf0e10cSrcweir 				Sequence< Any > aArguments( 1 );
1134cdf0e10cSrcweir                 PropertyValue aProperty;
1135cdf0e10cSrcweir                 aProperty.Name
1136cdf0e10cSrcweir                     = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(
1137cdf0e10cSrcweir                                             CFGPROPERTY_NODEPATH ) );
1138cdf0e10cSrcweir                 aProperty.Value
1139cdf0e10cSrcweir                     <<= rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(
1140cdf0e10cSrcweir                                             STORE_CONTENTPROPERTIES_KEY ) );
1141cdf0e10cSrcweir                 aArguments[ 0 ] <<= aProperty;
1142cdf0e10cSrcweir 
1143cdf0e10cSrcweir 				m_pImpl->m_bTriedToGetRootReadAccess = sal_True;
1144cdf0e10cSrcweir 
1145cdf0e10cSrcweir 				m_pImpl->m_xRootReadAccess =
1146cdf0e10cSrcweir 					m_pImpl->m_xConfigProvider->createInstanceWithArguments(
1147cdf0e10cSrcweir 						OUString::createFromAscii(
1148cdf0e10cSrcweir 							"com.sun.star.configuration.ConfigurationAccess" ),
1149cdf0e10cSrcweir 						aArguments );
1150cdf0e10cSrcweir 
1151cdf0e10cSrcweir 				if ( m_pImpl->m_xRootReadAccess.is() )
1152cdf0e10cSrcweir 					return m_pImpl->m_xRootReadAccess;
1153cdf0e10cSrcweir 			}
1154cdf0e10cSrcweir 		}
1155cdf0e10cSrcweir 		else
1156cdf0e10cSrcweir 			return m_pImpl->m_xRootReadAccess;
1157cdf0e10cSrcweir 	}
1158cdf0e10cSrcweir 	catch ( RuntimeException& )
1159cdf0e10cSrcweir 	{
1160cdf0e10cSrcweir 		throw;
1161cdf0e10cSrcweir 	}
1162cdf0e10cSrcweir 	catch ( Exception& )
1163cdf0e10cSrcweir 	{
1164cdf0e10cSrcweir 		// createInstance, createInstanceWithArguments
1165cdf0e10cSrcweir 
1166cdf0e10cSrcweir 		OSL_ENSURE( sal_False,
1167cdf0e10cSrcweir 			"PropertySetRegistry::getRootConfigReadAccess - caught Exception!" );
1168cdf0e10cSrcweir 		return Reference< XInterface >();
1169cdf0e10cSrcweir 	}
1170cdf0e10cSrcweir 
1171cdf0e10cSrcweir 	OSL_ENSURE( sal_False,
1172cdf0e10cSrcweir 				"PropertySetRegistry::getRootConfigReadAccess - Error!" );
1173cdf0e10cSrcweir 	return Reference< XInterface >();
1174cdf0e10cSrcweir }
1175cdf0e10cSrcweir 
1176cdf0e10cSrcweir //=========================================================================
getConfigWriteAccess(const OUString & rPath)1177cdf0e10cSrcweir Reference< XInterface > PropertySetRegistry::getConfigWriteAccess(
1178cdf0e10cSrcweir 													const OUString& rPath )
1179cdf0e10cSrcweir {
1180cdf0e10cSrcweir 	try
1181cdf0e10cSrcweir 	{
1182cdf0e10cSrcweir 		osl::Guard< osl::Mutex > aGuard( m_pImpl->m_aMutex );
1183cdf0e10cSrcweir 
1184cdf0e10cSrcweir 		if ( !m_pImpl->m_xRootWriteAccess.is() )
1185cdf0e10cSrcweir 		{
1186cdf0e10cSrcweir 			if ( m_pImpl->m_bTriedToGetRootWriteAccess ) // #82494#
1187cdf0e10cSrcweir 			{
1188cdf0e10cSrcweir 				OSL_ENSURE( sal_False,
1189cdf0e10cSrcweir 							"PropertySetRegistry::getConfigWriteAccess - "
1190cdf0e10cSrcweir 							"Unable to write any config data! -> #82494#" );
1191cdf0e10cSrcweir 				return Reference< XInterface >();
1192cdf0e10cSrcweir 			}
1193cdf0e10cSrcweir 
1194cdf0e10cSrcweir 			getConfigProvider();
1195cdf0e10cSrcweir 
1196cdf0e10cSrcweir 			if ( m_pImpl->m_xConfigProvider.is() )
1197cdf0e10cSrcweir 			{
1198cdf0e10cSrcweir 				Sequence< Any > aArguments( 2 );
1199cdf0e10cSrcweir 				PropertyValue	aProperty;
1200cdf0e10cSrcweir 
1201cdf0e10cSrcweir 				aProperty.Name
1202cdf0e10cSrcweir 					= OUString( RTL_CONSTASCII_USTRINGPARAM(
1203cdf0e10cSrcweir 											CFGPROPERTY_NODEPATH ) );
1204cdf0e10cSrcweir 				aProperty.Value
1205cdf0e10cSrcweir 					<<= OUString( RTL_CONSTASCII_USTRINGPARAM(
1206cdf0e10cSrcweir 											STORE_CONTENTPROPERTIES_KEY ) );
1207cdf0e10cSrcweir 				aArguments[ 0 ]	<<= aProperty;
1208cdf0e10cSrcweir 
1209cdf0e10cSrcweir 				aProperty.Name
1210cdf0e10cSrcweir 					= OUString(	RTL_CONSTASCII_USTRINGPARAM(
1211cdf0e10cSrcweir 											CFGPROPERTY_LAZYWRITE ) );
1212cdf0e10cSrcweir 				aProperty.Value	<<= sal_True;
1213cdf0e10cSrcweir 				aArguments[ 1 ]	<<= aProperty;
1214cdf0e10cSrcweir 
1215cdf0e10cSrcweir 				m_pImpl->m_bTriedToGetRootWriteAccess = sal_True;
1216cdf0e10cSrcweir 
1217cdf0e10cSrcweir 				m_pImpl->m_xRootWriteAccess =
1218cdf0e10cSrcweir 					m_pImpl->m_xConfigProvider->createInstanceWithArguments(
1219cdf0e10cSrcweir 						OUString::createFromAscii(
1220cdf0e10cSrcweir 							"com.sun.star.configuration.ConfigurationUpdateAccess" ),
1221cdf0e10cSrcweir 						aArguments );
1222cdf0e10cSrcweir 
1223cdf0e10cSrcweir 				OSL_ENSURE( m_pImpl->m_xRootWriteAccess.is(),
1224cdf0e10cSrcweir 							"PropertySetRegistry::getConfigWriteAccess - "
1225cdf0e10cSrcweir 							"No config update access!" );
1226cdf0e10cSrcweir 			}
1227cdf0e10cSrcweir 		}
1228cdf0e10cSrcweir 
1229cdf0e10cSrcweir 		if ( m_pImpl->m_xRootWriteAccess.is() )
1230cdf0e10cSrcweir 		{
1231cdf0e10cSrcweir 			if ( rPath.getLength() )
1232cdf0e10cSrcweir 			{
1233cdf0e10cSrcweir 				Reference< XHierarchicalNameAccess > xNA(
1234cdf0e10cSrcweir 								m_pImpl->m_xRootWriteAccess, UNO_QUERY );
1235cdf0e10cSrcweir 				if ( xNA.is() )
1236cdf0e10cSrcweir 				{
1237cdf0e10cSrcweir 					Reference< XInterface > xInterface;
1238cdf0e10cSrcweir 					xNA->getByHierarchicalName( rPath )	>>= xInterface;
1239cdf0e10cSrcweir 
1240cdf0e10cSrcweir 					if ( xInterface.is() )
1241cdf0e10cSrcweir 						return xInterface;
1242cdf0e10cSrcweir 				}
1243cdf0e10cSrcweir 			}
1244cdf0e10cSrcweir 			else
1245cdf0e10cSrcweir 				return m_pImpl->m_xRootWriteAccess;
1246cdf0e10cSrcweir 		}
1247cdf0e10cSrcweir 	}
1248cdf0e10cSrcweir 	catch ( RuntimeException& )
1249cdf0e10cSrcweir 	{
1250cdf0e10cSrcweir 		throw;
1251cdf0e10cSrcweir 	}
1252cdf0e10cSrcweir 	catch ( NoSuchElementException& )
1253cdf0e10cSrcweir 	{
1254cdf0e10cSrcweir 		// getByHierarchicalName
1255cdf0e10cSrcweir 
1256cdf0e10cSrcweir 		OSL_ENSURE( sal_False,
1257cdf0e10cSrcweir 			"PropertySetRegistry::getConfigWriteAccess - "
1258cdf0e10cSrcweir 			"caught NoSuchElementException!" );
1259cdf0e10cSrcweir 		return Reference< XInterface >();
1260cdf0e10cSrcweir 	}
1261cdf0e10cSrcweir 	catch ( Exception& )
1262cdf0e10cSrcweir 	{
1263cdf0e10cSrcweir 		// createInstance, createInstanceWithArguments
1264cdf0e10cSrcweir 
1265cdf0e10cSrcweir 		OSL_ENSURE( sal_False,
1266cdf0e10cSrcweir 					"PropertySetRegistry::getConfigWriteAccess - "
1267cdf0e10cSrcweir 					"caught Exception!" );
1268cdf0e10cSrcweir 		return Reference< XInterface >();
1269cdf0e10cSrcweir 	}
1270cdf0e10cSrcweir 
1271cdf0e10cSrcweir 	OSL_ENSURE( sal_False,
1272cdf0e10cSrcweir 				"PropertySetRegistry::getConfigWriteAccess - Error!" );
1273cdf0e10cSrcweir 	return Reference< XInterface >();
1274cdf0e10cSrcweir }
1275cdf0e10cSrcweir 
1276cdf0e10cSrcweir //=========================================================================
1277cdf0e10cSrcweir //
1278cdf0e10cSrcweir // PropertyListeners_Impl.
1279cdf0e10cSrcweir //
1280cdf0e10cSrcweir //=========================================================================
1281cdf0e10cSrcweir 
1282cdf0e10cSrcweir typedef OMultiTypeInterfaceContainerHelperVar
1283cdf0e10cSrcweir <
1284cdf0e10cSrcweir 	OUString,
1285cdf0e10cSrcweir 	hashString_Impl,
1286cdf0e10cSrcweir 	equalString_Impl
1287cdf0e10cSrcweir > PropertyListeners_Impl;
1288cdf0e10cSrcweir 
1289cdf0e10cSrcweir //=========================================================================
1290cdf0e10cSrcweir //
1291cdf0e10cSrcweir // PersistentPropertySet_Impl.
1292cdf0e10cSrcweir //
1293cdf0e10cSrcweir //=========================================================================
1294cdf0e10cSrcweir 
1295cdf0e10cSrcweir struct PersistentPropertySet_Impl
1296cdf0e10cSrcweir {
1297cdf0e10cSrcweir 	PropertySetRegistry* 		m_pCreator;
1298cdf0e10cSrcweir 	PropertySetInfo_Impl*		m_pInfo;
1299cdf0e10cSrcweir 	OUString			 		m_aKey;
1300cdf0e10cSrcweir 	OUString			 		m_aFullKey;
1301cdf0e10cSrcweir 	osl::Mutex       			m_aMutex;
1302cdf0e10cSrcweir 	OInterfaceContainerHelper*	m_pDisposeEventListeners;
1303cdf0e10cSrcweir 	OInterfaceContainerHelper*  m_pPropSetChangeListeners;
1304cdf0e10cSrcweir 	PropertyListeners_Impl*		m_pPropertyChangeListeners;
1305cdf0e10cSrcweir 
PersistentPropertySet_ImplPersistentPropertySet_Impl1306cdf0e10cSrcweir 	PersistentPropertySet_Impl( PropertySetRegistry& rCreator,
1307cdf0e10cSrcweir 								const OUString& rKey )
1308cdf0e10cSrcweir 	: m_pCreator( &rCreator ), m_pInfo( NULL ), m_aKey( rKey ),
1309cdf0e10cSrcweir 	  m_pDisposeEventListeners( NULL ), m_pPropSetChangeListeners( NULL ),
1310cdf0e10cSrcweir 	  m_pPropertyChangeListeners( NULL )
1311cdf0e10cSrcweir 	{
1312cdf0e10cSrcweir 		m_pCreator->acquire();
1313cdf0e10cSrcweir 	}
1314cdf0e10cSrcweir 
~PersistentPropertySet_ImplPersistentPropertySet_Impl1315cdf0e10cSrcweir 	~PersistentPropertySet_Impl()
1316cdf0e10cSrcweir 	{
1317cdf0e10cSrcweir 		m_pCreator->release();
1318cdf0e10cSrcweir 
1319cdf0e10cSrcweir 		if ( m_pInfo )
1320cdf0e10cSrcweir 			m_pInfo->release();
1321cdf0e10cSrcweir 
1322cdf0e10cSrcweir 		delete m_pDisposeEventListeners;
1323cdf0e10cSrcweir 		delete m_pPropSetChangeListeners;
1324cdf0e10cSrcweir 		delete m_pPropertyChangeListeners;
1325cdf0e10cSrcweir 	}
1326cdf0e10cSrcweir };
1327cdf0e10cSrcweir 
1328cdf0e10cSrcweir //=========================================================================
1329cdf0e10cSrcweir //=========================================================================
1330cdf0e10cSrcweir //=========================================================================
1331cdf0e10cSrcweir //
1332cdf0e10cSrcweir // PersistentPropertySet Implementation.
1333cdf0e10cSrcweir //
1334cdf0e10cSrcweir //=========================================================================
1335cdf0e10cSrcweir //=========================================================================
1336cdf0e10cSrcweir //=========================================================================
1337cdf0e10cSrcweir 
PersistentPropertySet(const Reference<XMultiServiceFactory> & rXSMgr,PropertySetRegistry & rCreator,const OUString & rKey)1338cdf0e10cSrcweir PersistentPropertySet::PersistentPropertySet(
1339cdf0e10cSrcweir 						const Reference< XMultiServiceFactory >& rXSMgr,
1340cdf0e10cSrcweir 						PropertySetRegistry& rCreator,
1341cdf0e10cSrcweir 						const OUString& rKey )
1342cdf0e10cSrcweir : m_xSMgr( rXSMgr ),
1343cdf0e10cSrcweir   m_pImpl( new PersistentPropertySet_Impl( rCreator, rKey ) )
1344cdf0e10cSrcweir {
1345cdf0e10cSrcweir 	// register at creator.
1346cdf0e10cSrcweir 	rCreator.add( this );
1347cdf0e10cSrcweir }
1348cdf0e10cSrcweir 
1349cdf0e10cSrcweir //=========================================================================
1350cdf0e10cSrcweir // virtual
~PersistentPropertySet()1351cdf0e10cSrcweir PersistentPropertySet::~PersistentPropertySet()
1352cdf0e10cSrcweir {
1353cdf0e10cSrcweir 	// deregister at creator.
1354cdf0e10cSrcweir 	m_pImpl->m_pCreator->remove( this );
1355cdf0e10cSrcweir 
1356cdf0e10cSrcweir 	delete m_pImpl;
1357cdf0e10cSrcweir }
1358cdf0e10cSrcweir 
1359cdf0e10cSrcweir //=========================================================================
1360cdf0e10cSrcweir //
1361cdf0e10cSrcweir // XInterface methods.
1362cdf0e10cSrcweir //
1363cdf0e10cSrcweir //=========================================================================
1364cdf0e10cSrcweir 
1365cdf0e10cSrcweir XINTERFACE_IMPL_9( PersistentPropertySet,
1366cdf0e10cSrcweir 				   XTypeProvider,
1367cdf0e10cSrcweir 				   XServiceInfo,
1368cdf0e10cSrcweir 				   XComponent,
1369cdf0e10cSrcweir 				   XPropertySet, /* base of XPersistentPropertySet */
1370cdf0e10cSrcweir 				   XNamed,
1371cdf0e10cSrcweir 				   XPersistentPropertySet,
1372cdf0e10cSrcweir 				   XPropertyContainer,
1373cdf0e10cSrcweir 				   XPropertySetInfoChangeNotifier,
1374cdf0e10cSrcweir 				   XPropertyAccess );
1375cdf0e10cSrcweir 
1376cdf0e10cSrcweir //=========================================================================
1377cdf0e10cSrcweir //
1378cdf0e10cSrcweir // XTypeProvider methods.
1379cdf0e10cSrcweir //
1380cdf0e10cSrcweir //=========================================================================
1381cdf0e10cSrcweir 
1382cdf0e10cSrcweir XTYPEPROVIDER_IMPL_8( PersistentPropertySet,
1383cdf0e10cSrcweir 				   	  XTypeProvider,
1384cdf0e10cSrcweir 				   	  XServiceInfo,
1385cdf0e10cSrcweir 					  XComponent,
1386cdf0e10cSrcweir 					  XPersistentPropertySet,
1387cdf0e10cSrcweir 					  XNamed,
1388cdf0e10cSrcweir 					  XPropertyContainer,
1389cdf0e10cSrcweir 					  XPropertySetInfoChangeNotifier,
1390cdf0e10cSrcweir 					  XPropertyAccess );
1391cdf0e10cSrcweir 
1392cdf0e10cSrcweir //=========================================================================
1393cdf0e10cSrcweir //
1394cdf0e10cSrcweir // XServiceInfo methods.
1395cdf0e10cSrcweir //
1396cdf0e10cSrcweir //=========================================================================
1397cdf0e10cSrcweir 
1398cdf0e10cSrcweir XSERVICEINFO_NOFACTORY_IMPL_1( PersistentPropertySet,
1399cdf0e10cSrcweir 					 		   OUString::createFromAscii(
1400cdf0e10cSrcweir 							   	"com.sun.star.comp.ucb.PersistentPropertySet" ),
1401cdf0e10cSrcweir 					 		   OUString::createFromAscii(
1402cdf0e10cSrcweir 							   	PERS_PROPSET_SERVICE_NAME ) );
1403cdf0e10cSrcweir 
1404cdf0e10cSrcweir //=========================================================================
1405cdf0e10cSrcweir //
1406cdf0e10cSrcweir // XComponent methods.
1407cdf0e10cSrcweir //
1408cdf0e10cSrcweir //=========================================================================
1409cdf0e10cSrcweir 
1410cdf0e10cSrcweir // virtual
dispose()1411cdf0e10cSrcweir void SAL_CALL PersistentPropertySet::dispose()
1412cdf0e10cSrcweir 	throw( RuntimeException )
1413cdf0e10cSrcweir {
1414cdf0e10cSrcweir 	if ( m_pImpl->m_pDisposeEventListeners &&
1415cdf0e10cSrcweir 	     m_pImpl->m_pDisposeEventListeners->getLength() )
1416cdf0e10cSrcweir 	{
1417cdf0e10cSrcweir 		EventObject aEvt;
1418cdf0e10cSrcweir 		aEvt.Source = static_cast< XComponent * >( this  );
1419cdf0e10cSrcweir 		m_pImpl->m_pDisposeEventListeners->disposeAndClear( aEvt );
1420cdf0e10cSrcweir 	}
1421cdf0e10cSrcweir 
1422cdf0e10cSrcweir 	if ( m_pImpl->m_pPropSetChangeListeners &&
1423cdf0e10cSrcweir 	     m_pImpl->m_pPropSetChangeListeners->getLength() )
1424cdf0e10cSrcweir 	{
1425cdf0e10cSrcweir 		EventObject aEvt;
1426cdf0e10cSrcweir 		aEvt.Source = static_cast< XPropertySetInfoChangeNotifier * >( this  );
1427cdf0e10cSrcweir 		m_pImpl->m_pPropSetChangeListeners->disposeAndClear( aEvt );
1428cdf0e10cSrcweir 	}
1429cdf0e10cSrcweir 
1430cdf0e10cSrcweir 	if ( m_pImpl->m_pPropertyChangeListeners )
1431cdf0e10cSrcweir 	{
1432cdf0e10cSrcweir 		EventObject aEvt;
1433cdf0e10cSrcweir 		aEvt.Source = static_cast< XPropertySet * >( this  );
1434cdf0e10cSrcweir 		m_pImpl->m_pPropertyChangeListeners->disposeAndClear( aEvt );
1435cdf0e10cSrcweir 	}
1436cdf0e10cSrcweir }
1437cdf0e10cSrcweir 
1438cdf0e10cSrcweir //=========================================================================
1439cdf0e10cSrcweir // virtual
addEventListener(const Reference<XEventListener> & Listener)1440cdf0e10cSrcweir void SAL_CALL PersistentPropertySet::addEventListener(
1441cdf0e10cSrcweir 							const Reference< XEventListener >& Listener )
1442cdf0e10cSrcweir 	throw( RuntimeException )
1443cdf0e10cSrcweir {
1444cdf0e10cSrcweir 	if ( !m_pImpl->m_pDisposeEventListeners )
1445cdf0e10cSrcweir 		m_pImpl->m_pDisposeEventListeners =
1446cdf0e10cSrcweir 					new OInterfaceContainerHelper( m_pImpl->m_aMutex );
1447cdf0e10cSrcweir 
1448cdf0e10cSrcweir 	m_pImpl->m_pDisposeEventListeners->addInterface( Listener );
1449cdf0e10cSrcweir }
1450cdf0e10cSrcweir 
1451cdf0e10cSrcweir //=========================================================================
1452cdf0e10cSrcweir // virtual
removeEventListener(const Reference<XEventListener> & Listener)1453cdf0e10cSrcweir void SAL_CALL PersistentPropertySet::removeEventListener(
1454cdf0e10cSrcweir 							const Reference< XEventListener >& Listener )
1455cdf0e10cSrcweir 	throw( RuntimeException )
1456cdf0e10cSrcweir {
1457cdf0e10cSrcweir 	if ( m_pImpl->m_pDisposeEventListeners )
1458cdf0e10cSrcweir 		m_pImpl->m_pDisposeEventListeners->removeInterface( Listener );
1459cdf0e10cSrcweir 
1460cdf0e10cSrcweir 	// Note: Don't want to delete empty container here -> performance.
1461cdf0e10cSrcweir }
1462cdf0e10cSrcweir 
1463cdf0e10cSrcweir //=========================================================================
1464cdf0e10cSrcweir //
1465cdf0e10cSrcweir // XPropertySet methods.
1466cdf0e10cSrcweir //
1467cdf0e10cSrcweir //=========================================================================
1468cdf0e10cSrcweir 
1469cdf0e10cSrcweir // virtual
1470cdf0e10cSrcweir Reference< XPropertySetInfo > SAL_CALL
getPropertySetInfo()1471cdf0e10cSrcweir 								PersistentPropertySet::getPropertySetInfo()
1472cdf0e10cSrcweir 	throw( RuntimeException )
1473cdf0e10cSrcweir {
1474cdf0e10cSrcweir 	osl::Guard< osl::Mutex > aGuard( m_pImpl->m_aMutex );
1475cdf0e10cSrcweir 
1476cdf0e10cSrcweir 	PropertySetInfo_Impl*& rpInfo = m_pImpl->m_pInfo;
1477cdf0e10cSrcweir 	if ( !rpInfo )
1478cdf0e10cSrcweir 	{
1479cdf0e10cSrcweir 		rpInfo = new PropertySetInfo_Impl( m_xSMgr, this );
1480cdf0e10cSrcweir 		rpInfo->acquire();
1481cdf0e10cSrcweir 	}
1482cdf0e10cSrcweir 	return Reference< XPropertySetInfo >( rpInfo );
1483cdf0e10cSrcweir }
1484cdf0e10cSrcweir 
1485cdf0e10cSrcweir //=========================================================================
1486cdf0e10cSrcweir // virtual
setPropertyValue(const OUString & aPropertyName,const Any & aValue)1487cdf0e10cSrcweir void SAL_CALL PersistentPropertySet::setPropertyValue(
1488cdf0e10cSrcweir 						const OUString& aPropertyName, const Any& aValue )
1489cdf0e10cSrcweir 	throw( UnknownPropertyException,
1490cdf0e10cSrcweir 		   PropertyVetoException,
1491cdf0e10cSrcweir 		   IllegalArgumentException,
1492cdf0e10cSrcweir 		   WrappedTargetException,
1493cdf0e10cSrcweir 		   RuntimeException )
1494cdf0e10cSrcweir {
1495cdf0e10cSrcweir 	if ( !aPropertyName.getLength() )
1496cdf0e10cSrcweir 		throw UnknownPropertyException();
1497cdf0e10cSrcweir 
1498cdf0e10cSrcweir 	osl::ClearableGuard< osl::Mutex > aCGuard( m_pImpl->m_aMutex );
1499cdf0e10cSrcweir 
1500cdf0e10cSrcweir 	Reference< XHierarchicalNameAccess > xRootHierNameAccess(
1501cdf0e10cSrcweir 				m_pImpl->m_pCreator->getRootConfigReadAccess(), UNO_QUERY );
1502cdf0e10cSrcweir 	if ( xRootHierNameAccess.is() )
1503cdf0e10cSrcweir 	{
1504cdf0e10cSrcweir 		OUString aFullPropName( getFullKey() );
1505cdf0e10cSrcweir 		aFullPropName += OUString::createFromAscii( "/" );
1506cdf0e10cSrcweir         aFullPropName += makeHierarchalNameSegment( aPropertyName );
1507cdf0e10cSrcweir 
1508cdf0e10cSrcweir 		// Does property exist?
1509cdf0e10cSrcweir 		if ( xRootHierNameAccess->hasByHierarchicalName( aFullPropName ) )
1510cdf0e10cSrcweir 		{
1511cdf0e10cSrcweir 			Reference< XNameReplace > xNameReplace(
1512cdf0e10cSrcweir 					m_pImpl->m_pCreator->getConfigWriteAccess(
1513cdf0e10cSrcweir 											aFullPropName ), UNO_QUERY );
1514cdf0e10cSrcweir 			Reference< XChangesBatch > xBatch(
1515cdf0e10cSrcweir 					m_pImpl->m_pCreator->getConfigWriteAccess(
1516cdf0e10cSrcweir 											OUString() ), UNO_QUERY );
1517cdf0e10cSrcweir 
1518cdf0e10cSrcweir 			if ( xNameReplace.is() && xBatch.is() )
1519cdf0e10cSrcweir 			{
1520cdf0e10cSrcweir 				try
1521cdf0e10cSrcweir 				{
1522cdf0e10cSrcweir 					// Obtain old value
1523cdf0e10cSrcweir 					OUString aValueName = aFullPropName;
1524cdf0e10cSrcweir 					aValueName += OUString::createFromAscii( "/Value" );
1525cdf0e10cSrcweir 					Any aOldValue
1526cdf0e10cSrcweir 						= xRootHierNameAccess->getByHierarchicalName(
1527cdf0e10cSrcweir 																aValueName );
1528cdf0e10cSrcweir 					// Check value type.
1529cdf0e10cSrcweir 					if ( aOldValue.getValueType() != aValue.getValueType() )
1530cdf0e10cSrcweir 					{
1531cdf0e10cSrcweir 						aCGuard.clear();
1532cdf0e10cSrcweir 						throw IllegalArgumentException();
1533cdf0e10cSrcweir 					}
1534cdf0e10cSrcweir 
1535cdf0e10cSrcweir 					// Write value
1536cdf0e10cSrcweir 					xNameReplace->replaceByName(
1537cdf0e10cSrcweir 									OUString::createFromAscii( "Value" ),
1538cdf0e10cSrcweir 									aValue );
1539cdf0e10cSrcweir 
1540cdf0e10cSrcweir 					// Write state ( Now it is a directly set value )
1541cdf0e10cSrcweir 					xNameReplace->replaceByName(
1542cdf0e10cSrcweir 									OUString::createFromAscii( "State" ),
1543cdf0e10cSrcweir 									makeAny(
1544cdf0e10cSrcweir                                         sal_Int32(
1545cdf0e10cSrcweir                                             PropertyState_DIRECT_VALUE ) ) );
1546cdf0e10cSrcweir 
1547cdf0e10cSrcweir 					// Commit changes.
1548cdf0e10cSrcweir 					xBatch->commitChanges();
1549cdf0e10cSrcweir 
1550cdf0e10cSrcweir 					PropertyChangeEvent aEvt;
1551cdf0e10cSrcweir 					if ( m_pImpl->m_pPropertyChangeListeners )
1552cdf0e10cSrcweir 					{
1553cdf0e10cSrcweir 						// Obtain handle
1554cdf0e10cSrcweir 						aValueName = aFullPropName;
1555cdf0e10cSrcweir 						aValueName += OUString::createFromAscii( "/Handle" );
1556cdf0e10cSrcweir 						sal_Int32 nHandle = -1;
1557cdf0e10cSrcweir 						xRootHierNameAccess->getByHierarchicalName(	aValueName )
1558cdf0e10cSrcweir 							>>= nHandle;
1559cdf0e10cSrcweir 
1560cdf0e10cSrcweir 						aEvt.Source 	    = (OWeakObject*)this;
1561cdf0e10cSrcweir 						aEvt.PropertyName   = aPropertyName;
1562cdf0e10cSrcweir 						aEvt.PropertyHandle = nHandle;
1563cdf0e10cSrcweir 						aEvt.Further        = sal_False;
1564cdf0e10cSrcweir 						aEvt.OldValue       = aOldValue;
1565cdf0e10cSrcweir 						aEvt.NewValue       = aValue;
1566cdf0e10cSrcweir 
1567cdf0e10cSrcweir 						// Callback follows!
1568cdf0e10cSrcweir 						aCGuard.clear();
1569cdf0e10cSrcweir 
1570cdf0e10cSrcweir 						notifyPropertyChangeEvent( aEvt );
1571cdf0e10cSrcweir 					}
1572cdf0e10cSrcweir 					return;
1573cdf0e10cSrcweir 				}
1574cdf0e10cSrcweir 				catch ( IllegalArgumentException& )
1575cdf0e10cSrcweir 				{
1576cdf0e10cSrcweir 					// replaceByName
1577cdf0e10cSrcweir 				}
1578cdf0e10cSrcweir 				catch ( NoSuchElementException& )
1579cdf0e10cSrcweir 				{
1580cdf0e10cSrcweir 					// getByHierarchicalName, replaceByName
1581cdf0e10cSrcweir 				}
1582cdf0e10cSrcweir 				catch ( WrappedTargetException& )
1583cdf0e10cSrcweir 				{
1584cdf0e10cSrcweir 					// replaceByName, commitChanges
1585cdf0e10cSrcweir 				}
1586cdf0e10cSrcweir 			}
1587cdf0e10cSrcweir 		}
1588cdf0e10cSrcweir 	}
1589cdf0e10cSrcweir 
1590cdf0e10cSrcweir 	throw UnknownPropertyException();
1591cdf0e10cSrcweir }
1592cdf0e10cSrcweir 
1593cdf0e10cSrcweir //=========================================================================
1594cdf0e10cSrcweir // virtual
getPropertyValue(const OUString & PropertyName)1595cdf0e10cSrcweir Any SAL_CALL PersistentPropertySet::getPropertyValue(
1596cdf0e10cSrcweir 											const OUString& PropertyName )
1597cdf0e10cSrcweir 	throw( UnknownPropertyException,
1598cdf0e10cSrcweir 		   WrappedTargetException,
1599cdf0e10cSrcweir 		   RuntimeException )
1600cdf0e10cSrcweir {
1601cdf0e10cSrcweir 	if ( !PropertyName.getLength() )
1602cdf0e10cSrcweir 		throw UnknownPropertyException();
1603cdf0e10cSrcweir 
1604cdf0e10cSrcweir 	osl::Guard< osl::Mutex > aGuard( m_pImpl->m_aMutex );
1605cdf0e10cSrcweir 
1606cdf0e10cSrcweir 	Reference< XHierarchicalNameAccess > xNameAccess(
1607cdf0e10cSrcweir 				m_pImpl->m_pCreator->getRootConfigReadAccess(), UNO_QUERY );
1608cdf0e10cSrcweir 	if ( xNameAccess.is() )
1609cdf0e10cSrcweir 	{
1610cdf0e10cSrcweir 		OUString aFullPropName( getFullKey() );
1611cdf0e10cSrcweir 		aFullPropName += OUString::createFromAscii( "/" );
1612cdf0e10cSrcweir         aFullPropName += makeHierarchalNameSegment( PropertyName );
1613cdf0e10cSrcweir         aFullPropName += OUString::createFromAscii( "/Value" );
1614cdf0e10cSrcweir 		try
1615cdf0e10cSrcweir 		{
1616cdf0e10cSrcweir 			return xNameAccess->getByHierarchicalName( aFullPropName );
1617cdf0e10cSrcweir 		}
1618cdf0e10cSrcweir 		catch ( NoSuchElementException& )
1619cdf0e10cSrcweir 		{
1620cdf0e10cSrcweir 			throw UnknownPropertyException();
1621cdf0e10cSrcweir 		}
1622cdf0e10cSrcweir 	}
1623cdf0e10cSrcweir 
1624cdf0e10cSrcweir 	throw UnknownPropertyException();
1625cdf0e10cSrcweir }
1626cdf0e10cSrcweir 
1627cdf0e10cSrcweir //=========================================================================
1628cdf0e10cSrcweir // virtual
addPropertyChangeListener(const OUString & aPropertyName,const Reference<XPropertyChangeListener> & xListener)1629cdf0e10cSrcweir void SAL_CALL PersistentPropertySet::addPropertyChangeListener(
1630cdf0e10cSrcweir 					const OUString& aPropertyName,
1631cdf0e10cSrcweir 					const Reference< XPropertyChangeListener >& xListener )
1632cdf0e10cSrcweir 	throw( UnknownPropertyException,
1633cdf0e10cSrcweir 		   WrappedTargetException,
1634cdf0e10cSrcweir 		   RuntimeException )
1635cdf0e10cSrcweir {
1636cdf0e10cSrcweir //	load();
1637cdf0e10cSrcweir 
1638cdf0e10cSrcweir 	if ( !m_pImpl->m_pPropertyChangeListeners )
1639cdf0e10cSrcweir 		m_pImpl->m_pPropertyChangeListeners =
1640cdf0e10cSrcweir 					new PropertyListeners_Impl( m_pImpl->m_aMutex );
1641cdf0e10cSrcweir 
1642cdf0e10cSrcweir 	m_pImpl->m_pPropertyChangeListeners->addInterface(
1643cdf0e10cSrcweir 												aPropertyName, xListener );
1644cdf0e10cSrcweir }
1645cdf0e10cSrcweir 
1646cdf0e10cSrcweir //=========================================================================
1647cdf0e10cSrcweir // virtual
removePropertyChangeListener(const OUString & aPropertyName,const Reference<XPropertyChangeListener> & aListener)1648cdf0e10cSrcweir void SAL_CALL PersistentPropertySet::removePropertyChangeListener(
1649cdf0e10cSrcweir 					const OUString& aPropertyName,
1650cdf0e10cSrcweir 					const Reference< XPropertyChangeListener >& aListener )
1651cdf0e10cSrcweir 	throw( UnknownPropertyException,
1652cdf0e10cSrcweir 		   WrappedTargetException,
1653cdf0e10cSrcweir 		   RuntimeException )
1654cdf0e10cSrcweir {
1655cdf0e10cSrcweir //	load();
1656cdf0e10cSrcweir 
1657cdf0e10cSrcweir 	if ( m_pImpl->m_pPropertyChangeListeners )
1658cdf0e10cSrcweir 		m_pImpl->m_pPropertyChangeListeners->removeInterface(
1659cdf0e10cSrcweir 												aPropertyName, aListener );
1660cdf0e10cSrcweir 
1661cdf0e10cSrcweir 	// Note: Don't want to delete empty container here -> performance.
1662cdf0e10cSrcweir }
1663cdf0e10cSrcweir 
1664cdf0e10cSrcweir //=========================================================================
1665cdf0e10cSrcweir // virtual
addVetoableChangeListener(const OUString &,const Reference<XVetoableChangeListener> &)1666cdf0e10cSrcweir void SAL_CALL PersistentPropertySet::addVetoableChangeListener(
1667cdf0e10cSrcweir 					const OUString&,
1668cdf0e10cSrcweir 					const Reference< XVetoableChangeListener >& )
1669cdf0e10cSrcweir 	throw( UnknownPropertyException,
1670cdf0e10cSrcweir 		   WrappedTargetException,
1671cdf0e10cSrcweir 		   RuntimeException )
1672cdf0e10cSrcweir {
1673cdf0e10cSrcweir //	load();
1674cdf0e10cSrcweir //	OSL_ENSURE( sal_False,
1675cdf0e10cSrcweir //				"PersistentPropertySet::addVetoableChangeListener - N.Y.I." );
1676cdf0e10cSrcweir }
1677cdf0e10cSrcweir 
1678cdf0e10cSrcweir //=========================================================================
1679cdf0e10cSrcweir // virtual
removeVetoableChangeListener(const OUString &,const Reference<XVetoableChangeListener> &)1680cdf0e10cSrcweir void SAL_CALL PersistentPropertySet::removeVetoableChangeListener(
1681cdf0e10cSrcweir 					const OUString&,
1682cdf0e10cSrcweir 					const Reference< XVetoableChangeListener >& )
1683cdf0e10cSrcweir 	throw( UnknownPropertyException,
1684cdf0e10cSrcweir 		   WrappedTargetException,
1685cdf0e10cSrcweir 		   RuntimeException )
1686cdf0e10cSrcweir {
1687cdf0e10cSrcweir //	load();
1688cdf0e10cSrcweir //	OSL_ENSURE( sal_False,
1689cdf0e10cSrcweir //				"PersistentPropertySet::removeVetoableChangeListener - N.Y.I." );
1690cdf0e10cSrcweir }
1691cdf0e10cSrcweir 
1692cdf0e10cSrcweir //=========================================================================
1693cdf0e10cSrcweir //
1694cdf0e10cSrcweir // XPersistentPropertySet methods.
1695cdf0e10cSrcweir //
1696cdf0e10cSrcweir //=========================================================================
1697cdf0e10cSrcweir 
1698cdf0e10cSrcweir // virtual
getRegistry()1699cdf0e10cSrcweir Reference< XPropertySetRegistry > SAL_CALL PersistentPropertySet::getRegistry()
1700cdf0e10cSrcweir 	throw( RuntimeException )
1701cdf0e10cSrcweir {
1702cdf0e10cSrcweir 	return Reference< XPropertySetRegistry >( m_pImpl->m_pCreator );
1703cdf0e10cSrcweir }
1704cdf0e10cSrcweir 
1705cdf0e10cSrcweir //=========================================================================
1706cdf0e10cSrcweir // virtual
getKey()1707cdf0e10cSrcweir OUString SAL_CALL PersistentPropertySet::getKey()
1708cdf0e10cSrcweir 	throw( RuntimeException )
1709cdf0e10cSrcweir {
1710cdf0e10cSrcweir 	return m_pImpl->m_aKey;
1711cdf0e10cSrcweir }
1712cdf0e10cSrcweir 
1713cdf0e10cSrcweir //=========================================================================
1714cdf0e10cSrcweir //
1715cdf0e10cSrcweir // XNamed methods.
1716cdf0e10cSrcweir //
1717cdf0e10cSrcweir //=========================================================================
1718cdf0e10cSrcweir 
1719cdf0e10cSrcweir // virtual
getName()1720cdf0e10cSrcweir rtl::OUString SAL_CALL PersistentPropertySet::getName()
1721cdf0e10cSrcweir 	throw( RuntimeException )
1722cdf0e10cSrcweir {
1723cdf0e10cSrcweir 	// same as getKey()
1724cdf0e10cSrcweir 	return m_pImpl->m_aKey;
1725cdf0e10cSrcweir }
1726cdf0e10cSrcweir 
1727cdf0e10cSrcweir //=========================================================================
1728cdf0e10cSrcweir // virtual
setName(const OUString & aName)1729cdf0e10cSrcweir void SAL_CALL PersistentPropertySet::setName( const OUString& aName )
1730cdf0e10cSrcweir 	throw( RuntimeException )
1731cdf0e10cSrcweir {
1732cdf0e10cSrcweir 	if ( aName != m_pImpl->m_aKey )
1733cdf0e10cSrcweir 		m_pImpl->m_pCreator->renamePropertySet( m_pImpl->m_aKey, aName );
1734cdf0e10cSrcweir }
1735cdf0e10cSrcweir 
1736cdf0e10cSrcweir //=========================================================================
1737cdf0e10cSrcweir //
1738cdf0e10cSrcweir // XPropertyContainer methods.
1739cdf0e10cSrcweir //
1740cdf0e10cSrcweir //=========================================================================
1741cdf0e10cSrcweir 
1742cdf0e10cSrcweir // virtual
addProperty(const OUString & Name,sal_Int16 Attributes,const Any & DefaultValue)1743cdf0e10cSrcweir void SAL_CALL PersistentPropertySet::addProperty(
1744cdf0e10cSrcweir 		const OUString& Name, sal_Int16 Attributes, const Any& DefaultValue )
1745cdf0e10cSrcweir 	throw( PropertyExistException,
1746cdf0e10cSrcweir 		   IllegalTypeException,
1747cdf0e10cSrcweir 		   IllegalArgumentException,
1748cdf0e10cSrcweir 		   RuntimeException )
1749cdf0e10cSrcweir {
1750cdf0e10cSrcweir 	if ( !Name.getLength() )
1751cdf0e10cSrcweir 		throw IllegalArgumentException();
1752cdf0e10cSrcweir 
1753cdf0e10cSrcweir 	// @@@ What other types can't be written to config server?
1754cdf0e10cSrcweir 
1755cdf0e10cSrcweir 	// Check type class ( Not all types can be written to storage )
1756cdf0e10cSrcweir 	TypeClass eTypeClass = DefaultValue.getValueTypeClass();
1757cdf0e10cSrcweir 	if ( eTypeClass == TypeClass_INTERFACE )
1758cdf0e10cSrcweir 		throw IllegalTypeException();
1759cdf0e10cSrcweir 
1760cdf0e10cSrcweir 	osl::Guard< osl::Mutex > aGuard( m_pImpl->m_aMutex );
1761cdf0e10cSrcweir 
1762cdf0e10cSrcweir 	// Property already in set?
1763cdf0e10cSrcweir 
1764cdf0e10cSrcweir 	OUString aFullValuesName;
1765cdf0e10cSrcweir 
1766cdf0e10cSrcweir 	Reference< XHierarchicalNameAccess > xRootHierNameAccess(
1767cdf0e10cSrcweir 				m_pImpl->m_pCreator->getRootConfigReadAccess(), UNO_QUERY );
1768cdf0e10cSrcweir 	if ( xRootHierNameAccess.is() )
1769cdf0e10cSrcweir 	{
1770cdf0e10cSrcweir 		aFullValuesName = getFullKey();
1771cdf0e10cSrcweir 		OUString aFullPropName = aFullValuesName;
1772cdf0e10cSrcweir 		aFullPropName += OUString::createFromAscii( "/" );
1773cdf0e10cSrcweir         aFullPropName += makeHierarchalNameSegment( Name );
1774cdf0e10cSrcweir 
1775cdf0e10cSrcweir 		if ( xRootHierNameAccess->hasByHierarchicalName( aFullPropName ) )
1776cdf0e10cSrcweir 		{
1777cdf0e10cSrcweir 			// Already in set.
1778cdf0e10cSrcweir 			throw PropertyExistException();
1779cdf0e10cSrcweir 		}
1780cdf0e10cSrcweir 	}
1781cdf0e10cSrcweir 
1782cdf0e10cSrcweir 	// Property is always removeable.
1783cdf0e10cSrcweir 	Attributes |= PropertyAttribute::REMOVEABLE;
1784cdf0e10cSrcweir 
1785cdf0e10cSrcweir 	// Add property.
1786cdf0e10cSrcweir 
1787cdf0e10cSrcweir 	Reference< XSingleServiceFactory > xFac(
1788cdf0e10cSrcweir 				m_pImpl->m_pCreator->getConfigWriteAccess( aFullValuesName ),
1789cdf0e10cSrcweir 				UNO_QUERY );
1790cdf0e10cSrcweir 	Reference< XNameContainer > xContainer( xFac, UNO_QUERY );
1791cdf0e10cSrcweir 	Reference< XChangesBatch >  xBatch(
1792cdf0e10cSrcweir 				m_pImpl->m_pCreator->getConfigWriteAccess( OUString() ),
1793cdf0e10cSrcweir 				UNO_QUERY );
1794cdf0e10cSrcweir 
1795cdf0e10cSrcweir 	OSL_ENSURE( xFac.is(),
1796cdf0e10cSrcweir 				"PersistentPropertySet::addProperty - No factory!" );
1797cdf0e10cSrcweir 
1798cdf0e10cSrcweir 	OSL_ENSURE( xBatch.is(),
1799cdf0e10cSrcweir 				"PersistentPropertySet::addProperty - No batch!" );
1800cdf0e10cSrcweir 
1801cdf0e10cSrcweir 	OSL_ENSURE( xContainer.is(),
1802cdf0e10cSrcweir 				"PersistentPropertySet::addProperty - No container!" );
1803cdf0e10cSrcweir 
1804cdf0e10cSrcweir 	if ( xFac.is() && xBatch.is() && xContainer.is() )
1805cdf0e10cSrcweir 	{
1806cdf0e10cSrcweir 		try
1807cdf0e10cSrcweir 		{
1808cdf0e10cSrcweir 			// Create new "PropertyValue" config item.
1809cdf0e10cSrcweir 			Reference< XNameReplace > xNameReplace(
1810cdf0e10cSrcweir 										xFac->createInstance(), UNO_QUERY );
1811cdf0e10cSrcweir 
1812cdf0e10cSrcweir 			if ( xNameReplace.is() )
1813cdf0e10cSrcweir 			{
1814cdf0e10cSrcweir 				// Fill new item...
1815cdf0e10cSrcweir 
1816cdf0e10cSrcweir 				// Set handle
1817cdf0e10cSrcweir 				xNameReplace->replaceByName(
1818cdf0e10cSrcweir 									OUString::createFromAscii( "Handle" ),
1819cdf0e10cSrcweir 									makeAny( sal_Int32( -1 ) ) );
1820cdf0e10cSrcweir 
1821cdf0e10cSrcweir 				// Set default value
1822cdf0e10cSrcweir 				xNameReplace->replaceByName(
1823cdf0e10cSrcweir 									OUString::createFromAscii( "Value" ),
1824cdf0e10cSrcweir 									DefaultValue );
1825cdf0e10cSrcweir 
1826cdf0e10cSrcweir 				// Set state ( always "default" )
1827cdf0e10cSrcweir 				xNameReplace->replaceByName(
1828cdf0e10cSrcweir 									OUString::createFromAscii( "State" ),
1829cdf0e10cSrcweir 									makeAny(
1830cdf0e10cSrcweir                                         sal_Int32(
1831cdf0e10cSrcweir                                             PropertyState_DEFAULT_VALUE ) ) );
1832cdf0e10cSrcweir 
1833cdf0e10cSrcweir 				// Set attributes
1834cdf0e10cSrcweir 				xNameReplace->replaceByName(
1835cdf0e10cSrcweir 									OUString::createFromAscii( "Attributes" ),
1836cdf0e10cSrcweir 									makeAny( sal_Int32( Attributes ) ) );
1837cdf0e10cSrcweir 
1838cdf0e10cSrcweir 				// Insert new item.
1839cdf0e10cSrcweir 				xContainer->insertByName( Name, makeAny( xNameReplace ) );
1840cdf0e10cSrcweir 
1841cdf0e10cSrcweir 				// Commit changes.
1842cdf0e10cSrcweir 				xBatch->commitChanges();
1843cdf0e10cSrcweir 
1844cdf0e10cSrcweir 				// Property set info is invalid.
1845cdf0e10cSrcweir 				if ( m_pImpl->m_pInfo )
1846cdf0e10cSrcweir 					m_pImpl->m_pInfo->reset();
1847cdf0e10cSrcweir 
1848cdf0e10cSrcweir 				// Notify propertyset info change listeners.
1849cdf0e10cSrcweir 				if ( m_pImpl->m_pPropSetChangeListeners &&
1850cdf0e10cSrcweir 			 		m_pImpl->m_pPropSetChangeListeners->getLength() )
1851cdf0e10cSrcweir 				{
1852cdf0e10cSrcweir 					PropertySetInfoChangeEvent evt(
1853cdf0e10cSrcweir 									static_cast< OWeakObject * >( this ),
1854cdf0e10cSrcweir 									Name,
1855cdf0e10cSrcweir 									-1,
1856cdf0e10cSrcweir 									PropertySetInfoChange::PROPERTY_INSERTED );
1857cdf0e10cSrcweir 					notifyPropertySetInfoChange( evt );
1858cdf0e10cSrcweir 				}
1859cdf0e10cSrcweir 
1860cdf0e10cSrcweir 				// Success.
1861cdf0e10cSrcweir 				return;
1862cdf0e10cSrcweir 			}
1863cdf0e10cSrcweir 		}
1864cdf0e10cSrcweir 		catch ( IllegalArgumentException& )
1865cdf0e10cSrcweir 		{
1866cdf0e10cSrcweir 			// insertByName
1867cdf0e10cSrcweir 
1868cdf0e10cSrcweir 			OSL_ENSURE( sal_False,
1869cdf0e10cSrcweir 						"PersistentPropertySet::addProperty - "
1870cdf0e10cSrcweir 						"caught IllegalArgumentException!" );
1871cdf0e10cSrcweir 			return;
1872cdf0e10cSrcweir 		}
1873cdf0e10cSrcweir 		catch ( ElementExistException& )
1874cdf0e10cSrcweir 		{
1875cdf0e10cSrcweir 			// insertByName
1876cdf0e10cSrcweir 
1877cdf0e10cSrcweir 			OSL_ENSURE( sal_False,
1878cdf0e10cSrcweir 						"PersistentPropertySet::addProperty - "
1879cdf0e10cSrcweir 						"caught ElementExistException!" );
1880cdf0e10cSrcweir 			return;
1881cdf0e10cSrcweir 		}
1882cdf0e10cSrcweir 		catch ( WrappedTargetException& )
1883cdf0e10cSrcweir 		{
1884cdf0e10cSrcweir 			// replaceByName, insertByName, commitChanges
1885cdf0e10cSrcweir 
1886cdf0e10cSrcweir 			OSL_ENSURE( sal_False,
1887cdf0e10cSrcweir 						"PersistentPropertySet::addProperty - "
1888cdf0e10cSrcweir 						"caught WrappedTargetException!" );
1889cdf0e10cSrcweir 			return;
1890cdf0e10cSrcweir 		}
1891cdf0e10cSrcweir 		catch ( RuntimeException& )
1892cdf0e10cSrcweir 		{
1893cdf0e10cSrcweir 			throw;
1894cdf0e10cSrcweir 		}
1895cdf0e10cSrcweir 		catch ( Exception& )
1896cdf0e10cSrcweir 		{
1897cdf0e10cSrcweir 			// createInstance
1898cdf0e10cSrcweir 
1899cdf0e10cSrcweir 			OSL_ENSURE( sal_False,
1900cdf0e10cSrcweir 						"PersistentPropertySet::addProperty - "
1901cdf0e10cSrcweir 						"caught Exception!" );
1902cdf0e10cSrcweir 			return;
1903cdf0e10cSrcweir 		}
1904cdf0e10cSrcweir 	}
1905cdf0e10cSrcweir 
1906cdf0e10cSrcweir 	OSL_ENSURE( sal_False,
1907cdf0e10cSrcweir 				"PersistentPropertySet::addProperty - Error!" );
1908cdf0e10cSrcweir }
1909cdf0e10cSrcweir 
1910cdf0e10cSrcweir //=========================================================================
1911cdf0e10cSrcweir // virtual
removeProperty(const OUString & Name)1912cdf0e10cSrcweir void SAL_CALL PersistentPropertySet::removeProperty( const OUString& Name )
1913cdf0e10cSrcweir 	throw( UnknownPropertyException,
1914cdf0e10cSrcweir 		   NotRemoveableException,
1915cdf0e10cSrcweir 		   RuntimeException )
1916cdf0e10cSrcweir {
1917cdf0e10cSrcweir 	osl::Guard< osl::Mutex > aGuard( m_pImpl->m_aMutex );
1918cdf0e10cSrcweir 
1919cdf0e10cSrcweir 	OUString aFullValuesName;
1920cdf0e10cSrcweir 	OUString aFullPropName;
1921cdf0e10cSrcweir 
1922cdf0e10cSrcweir 	Reference< XHierarchicalNameAccess > xRootHierNameAccess(
1923cdf0e10cSrcweir 				m_pImpl->m_pCreator->getRootConfigReadAccess(), UNO_QUERY );
1924cdf0e10cSrcweir 	if ( xRootHierNameAccess.is() )
1925cdf0e10cSrcweir 	{
1926cdf0e10cSrcweir 		aFullValuesName = getFullKey();
1927cdf0e10cSrcweir 		aFullPropName   = aFullValuesName;
1928cdf0e10cSrcweir         aFullPropName   += OUString::createFromAscii( "/" );
1929cdf0e10cSrcweir         aFullPropName   += makeHierarchalNameSegment( Name );
1930cdf0e10cSrcweir 
1931cdf0e10cSrcweir 		// Property in set?
1932cdf0e10cSrcweir 		if ( !xRootHierNameAccess->hasByHierarchicalName( aFullPropName ) )
1933cdf0e10cSrcweir 			throw UnknownPropertyException();
1934cdf0e10cSrcweir 
1935cdf0e10cSrcweir 		// Property removeable?
1936cdf0e10cSrcweir 		try
1937cdf0e10cSrcweir 		{
1938cdf0e10cSrcweir 			OUString aFullAttrName = aFullPropName;
1939cdf0e10cSrcweir 			aFullAttrName += OUString::createFromAscii( "/Attributes" );
1940cdf0e10cSrcweir 
1941cdf0e10cSrcweir 			sal_Int32 nAttribs = 0;
1942cdf0e10cSrcweir 			if ( xRootHierNameAccess->getByHierarchicalName( aFullAttrName )
1943cdf0e10cSrcweir 					>>= nAttribs )
1944cdf0e10cSrcweir 			{
1945cdf0e10cSrcweir 				if ( !( nAttribs & PropertyAttribute::REMOVEABLE ) )
1946cdf0e10cSrcweir 				{
1947cdf0e10cSrcweir 					// Not removeable!
1948cdf0e10cSrcweir 					throw NotRemoveableException();
1949cdf0e10cSrcweir 				}
1950cdf0e10cSrcweir 			}
1951cdf0e10cSrcweir 			else
1952cdf0e10cSrcweir 			{
1953cdf0e10cSrcweir 				OSL_ENSURE( sal_False,
1954cdf0e10cSrcweir 							"PersistentPropertySet::removeProperty - "
1955cdf0e10cSrcweir 							"No attributes!" );
1956cdf0e10cSrcweir 				return;
1957cdf0e10cSrcweir 			}
1958cdf0e10cSrcweir 		}
1959cdf0e10cSrcweir 		catch ( NoSuchElementException& )
1960cdf0e10cSrcweir 		{
1961cdf0e10cSrcweir 			// getByHierarchicalName
1962cdf0e10cSrcweir 
1963cdf0e10cSrcweir 			OSL_ENSURE( sal_False,
1964cdf0e10cSrcweir 						"PersistentPropertySet::removeProperty - "
1965cdf0e10cSrcweir 						"caught NoSuchElementException!" );
1966cdf0e10cSrcweir 		}
1967cdf0e10cSrcweir 
1968cdf0e10cSrcweir 		// Remove property...
1969cdf0e10cSrcweir 
1970cdf0e10cSrcweir 		Reference< XNameContainer > xContainer(
1971cdf0e10cSrcweir 				m_pImpl->m_pCreator->getConfigWriteAccess( aFullValuesName ),
1972cdf0e10cSrcweir 				UNO_QUERY );
1973cdf0e10cSrcweir 		Reference< XChangesBatch > xBatch(
1974cdf0e10cSrcweir 				m_pImpl->m_pCreator->getConfigWriteAccess( OUString() ),
1975cdf0e10cSrcweir 				UNO_QUERY );
1976cdf0e10cSrcweir 
1977cdf0e10cSrcweir 		OSL_ENSURE( xBatch.is(),
1978cdf0e10cSrcweir 					"PersistentPropertySet::removeProperty - No batch!" );
1979cdf0e10cSrcweir 
1980cdf0e10cSrcweir 		OSL_ENSURE( xContainer.is(),
1981cdf0e10cSrcweir 					"PersistentPropertySet::removeProperty - No container!" );
1982cdf0e10cSrcweir 
1983cdf0e10cSrcweir 		if ( xBatch.is() && xContainer.is() )
1984cdf0e10cSrcweir 		{
1985cdf0e10cSrcweir 			try
1986cdf0e10cSrcweir 			{
1987cdf0e10cSrcweir 				sal_Int32 nHandle = -1;
1988cdf0e10cSrcweir 
1989cdf0e10cSrcweir 				if ( m_pImpl->m_pPropSetChangeListeners &&
1990cdf0e10cSrcweir 	 		 		 m_pImpl->m_pPropSetChangeListeners->getLength() )
1991cdf0e10cSrcweir 				{
1992cdf0e10cSrcweir 					// Obtain property handle ( needed for propertysetinfo
1993cdf0e10cSrcweir 					// change event )...
1994cdf0e10cSrcweir 
1995cdf0e10cSrcweir 					try
1996cdf0e10cSrcweir 					{
1997cdf0e10cSrcweir 						OUString aFullHandleName = aFullPropName;
1998cdf0e10cSrcweir 						aFullHandleName
1999cdf0e10cSrcweir 								+= OUString::createFromAscii( "/Handle" );
2000cdf0e10cSrcweir 
2001cdf0e10cSrcweir 						if ( ! ( xRootHierNameAccess->getByHierarchicalName(
2002cdf0e10cSrcweir 										aFullHandleName ) >>= nHandle ) )
2003cdf0e10cSrcweir 							nHandle = -1;
2004cdf0e10cSrcweir 
2005cdf0e10cSrcweir 					}
2006cdf0e10cSrcweir 					catch ( NoSuchElementException& )
2007cdf0e10cSrcweir 					{
2008cdf0e10cSrcweir 						// getByHierarchicalName
2009cdf0e10cSrcweir 
2010cdf0e10cSrcweir 						OSL_ENSURE( sal_False,
2011cdf0e10cSrcweir 									"PersistentPropertySet::removeProperty - "
2012cdf0e10cSrcweir 									"caught NoSuchElementException!" );
2013cdf0e10cSrcweir 						nHandle = -1;
2014cdf0e10cSrcweir 					}
2015cdf0e10cSrcweir 				}
2016cdf0e10cSrcweir 
2017cdf0e10cSrcweir 				xContainer->removeByName( Name );
2018cdf0e10cSrcweir 				xBatch->commitChanges();
2019cdf0e10cSrcweir 
2020cdf0e10cSrcweir 				// Property set info is invalid.
2021cdf0e10cSrcweir 				if ( m_pImpl->m_pInfo )
2022cdf0e10cSrcweir 					m_pImpl->m_pInfo->reset();
2023cdf0e10cSrcweir 
2024cdf0e10cSrcweir 				// Notify propertyset info change listeners.
2025cdf0e10cSrcweir 				if ( m_pImpl->m_pPropSetChangeListeners &&
2026cdf0e10cSrcweir 	 		 		m_pImpl->m_pPropSetChangeListeners->getLength() )
2027cdf0e10cSrcweir 				{
2028cdf0e10cSrcweir 					PropertySetInfoChangeEvent evt(
2029cdf0e10cSrcweir 									static_cast< OWeakObject * >( this ),
2030cdf0e10cSrcweir 									Name,
2031cdf0e10cSrcweir 									nHandle,
2032cdf0e10cSrcweir 									PropertySetInfoChange::PROPERTY_REMOVED );
2033cdf0e10cSrcweir 					notifyPropertySetInfoChange( evt );
2034cdf0e10cSrcweir 				}
2035cdf0e10cSrcweir 
2036cdf0e10cSrcweir 				// Success.
2037cdf0e10cSrcweir 				return;
2038cdf0e10cSrcweir 			}
2039cdf0e10cSrcweir 			catch ( NoSuchElementException& )
2040cdf0e10cSrcweir 			{
2041cdf0e10cSrcweir 				// removeByName
2042cdf0e10cSrcweir 
2043cdf0e10cSrcweir 				OSL_ENSURE( sal_False,
2044cdf0e10cSrcweir 							"PersistentPropertySet::removeProperty - "
2045cdf0e10cSrcweir 							"caught NoSuchElementException!" );
2046cdf0e10cSrcweir 				return;
2047cdf0e10cSrcweir 			}
2048cdf0e10cSrcweir 			catch ( WrappedTargetException& )
2049cdf0e10cSrcweir 			{
2050cdf0e10cSrcweir 				// commitChanges
2051cdf0e10cSrcweir 
2052cdf0e10cSrcweir 				OSL_ENSURE( sal_False,
2053cdf0e10cSrcweir 							"PersistentPropertySet::removeProperty - "
2054cdf0e10cSrcweir 							"caught WrappedTargetException!" );
2055cdf0e10cSrcweir 				return;
2056cdf0e10cSrcweir 			}
2057cdf0e10cSrcweir 		}
2058cdf0e10cSrcweir 	}
2059cdf0e10cSrcweir 
2060cdf0e10cSrcweir 	OSL_ENSURE( sal_False,
2061cdf0e10cSrcweir 				"PersistentPropertySet::removeProperty - Error!" );
2062cdf0e10cSrcweir }
2063cdf0e10cSrcweir 
2064cdf0e10cSrcweir //=========================================================================
2065cdf0e10cSrcweir //
2066cdf0e10cSrcweir // XPropertySetInfoChangeNotifier methods.
2067cdf0e10cSrcweir //
2068cdf0e10cSrcweir //=========================================================================
2069cdf0e10cSrcweir 
2070cdf0e10cSrcweir // virtual
addPropertySetInfoChangeListener(const Reference<XPropertySetInfoChangeListener> & Listener)2071cdf0e10cSrcweir void SAL_CALL PersistentPropertySet::addPropertySetInfoChangeListener(
2072cdf0e10cSrcweir 				const Reference< XPropertySetInfoChangeListener >& Listener )
2073cdf0e10cSrcweir 	throw( RuntimeException )
2074cdf0e10cSrcweir {
2075cdf0e10cSrcweir 	if ( !m_pImpl->m_pPropSetChangeListeners )
2076cdf0e10cSrcweir 		m_pImpl->m_pPropSetChangeListeners =
2077cdf0e10cSrcweir 					new OInterfaceContainerHelper( m_pImpl->m_aMutex );
2078cdf0e10cSrcweir 
2079cdf0e10cSrcweir 	m_pImpl->m_pPropSetChangeListeners->addInterface( Listener );
2080cdf0e10cSrcweir }
2081cdf0e10cSrcweir 
2082cdf0e10cSrcweir //=========================================================================
2083cdf0e10cSrcweir // virtual
removePropertySetInfoChangeListener(const Reference<XPropertySetInfoChangeListener> & Listener)2084cdf0e10cSrcweir void SAL_CALL PersistentPropertySet::removePropertySetInfoChangeListener(
2085cdf0e10cSrcweir 				const Reference< XPropertySetInfoChangeListener >& Listener )
2086cdf0e10cSrcweir 	throw( RuntimeException )
2087cdf0e10cSrcweir {
2088cdf0e10cSrcweir 	if ( m_pImpl->m_pPropSetChangeListeners )
2089cdf0e10cSrcweir 		m_pImpl->m_pPropSetChangeListeners->removeInterface( Listener );
2090cdf0e10cSrcweir }
2091cdf0e10cSrcweir 
2092cdf0e10cSrcweir //=========================================================================
2093cdf0e10cSrcweir //
2094cdf0e10cSrcweir // XPropertyAccess methods.
2095cdf0e10cSrcweir //
2096cdf0e10cSrcweir //=========================================================================
2097cdf0e10cSrcweir 
2098cdf0e10cSrcweir // virtual
getPropertyValues()2099cdf0e10cSrcweir Sequence< PropertyValue > SAL_CALL PersistentPropertySet::getPropertyValues()
2100cdf0e10cSrcweir 	throw( RuntimeException )
2101cdf0e10cSrcweir {
2102cdf0e10cSrcweir 	osl::Guard< osl::Mutex > aGuard( m_pImpl->m_aMutex );
2103cdf0e10cSrcweir 
2104cdf0e10cSrcweir 	Reference< XHierarchicalNameAccess > xRootHierNameAccess(
2105cdf0e10cSrcweir 				m_pImpl->m_pCreator->getRootConfigReadAccess(), UNO_QUERY );
2106cdf0e10cSrcweir 	if ( xRootHierNameAccess.is() )
2107cdf0e10cSrcweir 	{
2108cdf0e10cSrcweir 		try
2109cdf0e10cSrcweir 		{
2110cdf0e10cSrcweir 			Reference< XNameAccess > xNameAccess;
2111cdf0e10cSrcweir 			xRootHierNameAccess->getByHierarchicalName(getFullKey())
2112cdf0e10cSrcweir                 >>= xNameAccess;
2113cdf0e10cSrcweir 			if ( xNameAccess.is() )
2114cdf0e10cSrcweir 			{
2115cdf0e10cSrcweir 				// Obtain property names.
2116cdf0e10cSrcweir 
2117cdf0e10cSrcweir 				Sequence< OUString > aElems = xNameAccess->getElementNames();
2118cdf0e10cSrcweir 
2119cdf0e10cSrcweir 				sal_Int32 nCount = aElems.getLength();
2120cdf0e10cSrcweir 				if ( nCount )
2121cdf0e10cSrcweir 				{
2122cdf0e10cSrcweir 					Reference< XHierarchicalNameAccess > xHierNameAccess(
2123cdf0e10cSrcweir 													xNameAccess, UNO_QUERY );
2124cdf0e10cSrcweir 
2125cdf0e10cSrcweir 					OSL_ENSURE( xHierNameAccess.is(),
2126cdf0e10cSrcweir 								"PersistentPropertySet::getPropertyValues - "
2127cdf0e10cSrcweir 								"No hierarchical name access!" );
2128cdf0e10cSrcweir 
2129cdf0e10cSrcweir 					if ( xHierNameAccess.is() )
2130cdf0e10cSrcweir 					{
2131cdf0e10cSrcweir 						Sequence< PropertyValue > aValues( nCount );
2132cdf0e10cSrcweir 
2133cdf0e10cSrcweir                         const OUString aHandleName
2134cdf0e10cSrcweir 									= OUString::createFromAscii( "/Handle" );
2135cdf0e10cSrcweir                         const OUString aValueName
2136cdf0e10cSrcweir 									= OUString::createFromAscii( "/Value" );
2137cdf0e10cSrcweir                         const OUString aStateName
2138cdf0e10cSrcweir 									= OUString::createFromAscii( "/State" );
2139cdf0e10cSrcweir 
2140cdf0e10cSrcweir 						for ( sal_Int32 n = 0; n < nCount; ++n )
2141cdf0e10cSrcweir 						{
2142cdf0e10cSrcweir 							PropertyValue& rValue = aValues[ n ];
2143cdf0e10cSrcweir                             OUString rName    = aElems[ n ];
2144cdf0e10cSrcweir                             OUString aXMLName
2145cdf0e10cSrcweir                                         = makeHierarchalNameSegment( rName );
2146cdf0e10cSrcweir 
2147cdf0e10cSrcweir 							// Set property name.
2148cdf0e10cSrcweir 
2149cdf0e10cSrcweir 							rValue.Name = rName;
2150cdf0e10cSrcweir 
2151cdf0e10cSrcweir 							try
2152cdf0e10cSrcweir 							{
2153cdf0e10cSrcweir 								// Obtain and set property handle
2154cdf0e10cSrcweir                                 OUString aHierName = aXMLName;
2155cdf0e10cSrcweir 								aHierName += aHandleName;
2156cdf0e10cSrcweir 								Any aKeyValue
2157cdf0e10cSrcweir 									= xHierNameAccess->getByHierarchicalName(
2158cdf0e10cSrcweir 										aHierName );
2159cdf0e10cSrcweir 
2160cdf0e10cSrcweir 								if ( !( aKeyValue >>= rValue.Handle ) )
2161cdf0e10cSrcweir 									OSL_ENSURE( sal_False,
2162cdf0e10cSrcweir 									  "PersistentPropertySet::getPropertyValues - "
2163cdf0e10cSrcweir 									  "Error getting property handle!" );
2164cdf0e10cSrcweir 							}
2165cdf0e10cSrcweir 							catch ( NoSuchElementException& )
2166cdf0e10cSrcweir 							{
2167cdf0e10cSrcweir 								// getByHierarchicalName
2168cdf0e10cSrcweir 
2169cdf0e10cSrcweir 								OSL_ENSURE( sal_False,
2170cdf0e10cSrcweir 								  "PersistentPropertySet::getPropertyValues - "
2171cdf0e10cSrcweir 								  "NoSuchElementException!" );
2172cdf0e10cSrcweir 							}
2173cdf0e10cSrcweir 
2174cdf0e10cSrcweir 							try
2175cdf0e10cSrcweir 							{
2176cdf0e10cSrcweir 								// Obtain and set property value
2177cdf0e10cSrcweir                                 OUString aHierName = aXMLName;
2178cdf0e10cSrcweir 								aHierName += aValueName;
2179cdf0e10cSrcweir 								rValue.Value
2180cdf0e10cSrcweir 									= xHierNameAccess->getByHierarchicalName(
2181cdf0e10cSrcweir 										aHierName );
2182cdf0e10cSrcweir 
2183cdf0e10cSrcweir 								// Note: The value may be void if addProperty
2184cdf0e10cSrcweir 								//       was called with a default value
2185cdf0e10cSrcweir 								//       of type void.
2186cdf0e10cSrcweir 							}
2187cdf0e10cSrcweir 							catch ( NoSuchElementException& )
2188cdf0e10cSrcweir 							{
2189cdf0e10cSrcweir 								// getByHierarchicalName
2190cdf0e10cSrcweir 
2191cdf0e10cSrcweir 								OSL_ENSURE( sal_False,
2192cdf0e10cSrcweir 								  "PersistentPropertySet::getPropertyValues - "
2193cdf0e10cSrcweir 								  "NoSuchElementException!" );
2194cdf0e10cSrcweir 							}
2195cdf0e10cSrcweir 
2196cdf0e10cSrcweir 							try
2197cdf0e10cSrcweir 							{
2198cdf0e10cSrcweir 								// Obtain and set property state
2199cdf0e10cSrcweir                                 OUString aHierName = aXMLName;
2200cdf0e10cSrcweir 								aHierName += aStateName;
2201cdf0e10cSrcweir 								Any aKeyValue
2202cdf0e10cSrcweir 									= xHierNameAccess->getByHierarchicalName(
2203cdf0e10cSrcweir 										aHierName );
2204cdf0e10cSrcweir 
2205cdf0e10cSrcweir 								sal_Int32 nState = 0;
2206cdf0e10cSrcweir 								if ( !( aKeyValue >>= nState ) )
2207cdf0e10cSrcweir 									OSL_ENSURE( sal_False,
2208cdf0e10cSrcweir 									  "PersistentPropertySet::getPropertyValues - "
2209cdf0e10cSrcweir 									  "Error getting property state!" );
2210cdf0e10cSrcweir 								else
2211cdf0e10cSrcweir 									rValue.State = PropertyState( nState );
2212cdf0e10cSrcweir 							}
2213cdf0e10cSrcweir 							catch ( NoSuchElementException& )
2214cdf0e10cSrcweir 							{
2215cdf0e10cSrcweir 								// getByHierarchicalName
2216cdf0e10cSrcweir 
2217cdf0e10cSrcweir 								OSL_ENSURE( sal_False,
2218cdf0e10cSrcweir 								  "PersistentPropertySet::getPropertyValues - "
2219cdf0e10cSrcweir 								  "NoSuchElementException!" );
2220cdf0e10cSrcweir 							}
2221cdf0e10cSrcweir 						}
2222cdf0e10cSrcweir 
2223cdf0e10cSrcweir 						return aValues;
2224cdf0e10cSrcweir 					}
2225cdf0e10cSrcweir 				}
2226cdf0e10cSrcweir 			}
2227cdf0e10cSrcweir 		}
2228cdf0e10cSrcweir 		catch ( NoSuchElementException& )
2229cdf0e10cSrcweir 		{
2230cdf0e10cSrcweir 			// getByHierarchicalName
2231cdf0e10cSrcweir 		}
2232cdf0e10cSrcweir 	}
2233cdf0e10cSrcweir 
2234cdf0e10cSrcweir 	return Sequence< PropertyValue >( 0 );
2235cdf0e10cSrcweir }
2236cdf0e10cSrcweir 
2237cdf0e10cSrcweir //=========================================================================
2238cdf0e10cSrcweir // virtual
setPropertyValues(const Sequence<PropertyValue> & aProps)2239cdf0e10cSrcweir void SAL_CALL PersistentPropertySet::setPropertyValues(
2240cdf0e10cSrcweir  								const Sequence< PropertyValue >& aProps )
2241cdf0e10cSrcweir 	throw( UnknownPropertyException,
2242cdf0e10cSrcweir 		   PropertyVetoException,
2243cdf0e10cSrcweir 		   IllegalArgumentException,
2244cdf0e10cSrcweir 		   WrappedTargetException,
2245cdf0e10cSrcweir 		   RuntimeException )
2246cdf0e10cSrcweir {
2247cdf0e10cSrcweir 	sal_Int32 nCount = aProps.getLength();
2248cdf0e10cSrcweir 	if ( !nCount )
2249cdf0e10cSrcweir 		return;
2250cdf0e10cSrcweir 
2251cdf0e10cSrcweir 	osl::ClearableGuard< osl::Mutex > aCGuard( m_pImpl->m_aMutex );
2252cdf0e10cSrcweir 
2253cdf0e10cSrcweir 	Reference< XHierarchicalNameAccess > xRootHierNameAccess(
2254cdf0e10cSrcweir 				m_pImpl->m_pCreator->getRootConfigReadAccess(), UNO_QUERY );
2255cdf0e10cSrcweir 	if ( xRootHierNameAccess.is() )
2256cdf0e10cSrcweir 	{
2257cdf0e10cSrcweir 		const PropertyValue* pNewValues = aProps.getConstArray();
2258cdf0e10cSrcweir 
2259cdf0e10cSrcweir 		typedef std::list< PropertyChangeEvent > Events;
2260cdf0e10cSrcweir 		Events aEvents;
2261cdf0e10cSrcweir 
2262cdf0e10cSrcweir 		OUString aFullPropNamePrefix( getFullKey() );
2263cdf0e10cSrcweir 		aFullPropNamePrefix += OUString::createFromAscii( "/" );
2264cdf0e10cSrcweir 
2265cdf0e10cSrcweir 		// Iterate over given property value sequence.
2266cdf0e10cSrcweir 		for ( sal_Int32 n = 0; n < nCount; ++n )
2267cdf0e10cSrcweir 		{
2268cdf0e10cSrcweir 			const PropertyValue& rNewValue = pNewValues[ n ];
2269cdf0e10cSrcweir 			const OUString& rName = rNewValue.Name;
2270cdf0e10cSrcweir 
2271cdf0e10cSrcweir 			OUString aFullPropName = aFullPropNamePrefix;
2272cdf0e10cSrcweir             aFullPropName += makeHierarchalNameSegment( rName );
2273cdf0e10cSrcweir 
2274cdf0e10cSrcweir 			// Does property exist?
2275cdf0e10cSrcweir 			if ( xRootHierNameAccess->hasByHierarchicalName( aFullPropName ) )
2276cdf0e10cSrcweir 			{
2277cdf0e10cSrcweir 				Reference< XNameReplace > xNameReplace(
2278cdf0e10cSrcweir 					m_pImpl->m_pCreator->getConfigWriteAccess(
2279cdf0e10cSrcweir 											aFullPropName ), UNO_QUERY );
2280cdf0e10cSrcweir 				Reference< XChangesBatch > xBatch(
2281cdf0e10cSrcweir 					m_pImpl->m_pCreator->getConfigWriteAccess(
2282cdf0e10cSrcweir 											OUString() ), UNO_QUERY );
2283cdf0e10cSrcweir 
2284cdf0e10cSrcweir 				if ( xNameReplace.is() && xBatch.is() )
2285cdf0e10cSrcweir 				{
2286cdf0e10cSrcweir 					try
2287cdf0e10cSrcweir 					{
2288cdf0e10cSrcweir 						// Write handle
2289cdf0e10cSrcweir 						xNameReplace->replaceByName(
2290cdf0e10cSrcweir 									OUString::createFromAscii( "Handle" ),
2291cdf0e10cSrcweir 									makeAny( rNewValue.Handle ) );
2292cdf0e10cSrcweir 
2293cdf0e10cSrcweir 						// Save old value
2294cdf0e10cSrcweir 						OUString aValueName = aFullPropName;
2295cdf0e10cSrcweir 						aValueName += OUString::createFromAscii( "/Value" );
2296cdf0e10cSrcweir 						Any aOldValue
2297cdf0e10cSrcweir 							= xRootHierNameAccess->getByHierarchicalName(
2298cdf0e10cSrcweir 																aValueName );
2299cdf0e10cSrcweir 						// Write value
2300cdf0e10cSrcweir 						xNameReplace->replaceByName(
2301cdf0e10cSrcweir 									OUString::createFromAscii( "Value" ),
2302cdf0e10cSrcweir 									rNewValue.Value );
2303cdf0e10cSrcweir 
2304cdf0e10cSrcweir 						// Write state ( Now it is a directly set value )
2305cdf0e10cSrcweir 						xNameReplace->replaceByName(
2306cdf0e10cSrcweir 									OUString::createFromAscii( "State" ),
2307cdf0e10cSrcweir 									makeAny(
2308cdf0e10cSrcweir                                         sal_Int32(
2309cdf0e10cSrcweir                                             PropertyState_DIRECT_VALUE ) ) );
2310cdf0e10cSrcweir 
2311cdf0e10cSrcweir 						// Commit changes.
2312cdf0e10cSrcweir 						xBatch->commitChanges();
2313cdf0e10cSrcweir 
2314cdf0e10cSrcweir 						if ( m_pImpl->m_pPropertyChangeListeners )
2315cdf0e10cSrcweir 						{
2316cdf0e10cSrcweir 							PropertyChangeEvent aEvt;
2317cdf0e10cSrcweir 							aEvt.Source 	    = (OWeakObject*)this;
2318cdf0e10cSrcweir 							aEvt.PropertyName   = rNewValue.Name;
2319cdf0e10cSrcweir 							aEvt.PropertyHandle = rNewValue.Handle;
2320cdf0e10cSrcweir 							aEvt.Further        = sal_False;
2321cdf0e10cSrcweir 							aEvt.OldValue       = aOldValue;
2322cdf0e10cSrcweir 							aEvt.NewValue       = rNewValue.Value;
2323cdf0e10cSrcweir 
2324cdf0e10cSrcweir 							aEvents.push_back( aEvt );
2325cdf0e10cSrcweir 						}
2326cdf0e10cSrcweir 					}
2327cdf0e10cSrcweir 					catch ( IllegalArgumentException& )
2328cdf0e10cSrcweir 					{
2329cdf0e10cSrcweir 						// replaceByName
2330cdf0e10cSrcweir 					}
2331cdf0e10cSrcweir 					catch ( NoSuchElementException& )
2332cdf0e10cSrcweir 					{
2333cdf0e10cSrcweir 						// getByHierarchicalName, replaceByName
2334cdf0e10cSrcweir 					}
2335cdf0e10cSrcweir 					catch ( WrappedTargetException& )
2336cdf0e10cSrcweir 					{
2337cdf0e10cSrcweir 						// replaceByName, commitChanges
2338cdf0e10cSrcweir 					}
2339cdf0e10cSrcweir 				}
2340cdf0e10cSrcweir 			}
2341cdf0e10cSrcweir 		}
2342cdf0e10cSrcweir 
2343cdf0e10cSrcweir 		// Callback follows!
2344cdf0e10cSrcweir 		aCGuard.clear();
2345cdf0e10cSrcweir 
2346cdf0e10cSrcweir 		if ( m_pImpl->m_pPropertyChangeListeners )
2347cdf0e10cSrcweir 		{
2348cdf0e10cSrcweir 			// Notify property changes.
2349cdf0e10cSrcweir 			Events::const_iterator it  = aEvents.begin();
2350cdf0e10cSrcweir 			Events::const_iterator end = aEvents.end();
2351cdf0e10cSrcweir 
2352cdf0e10cSrcweir 			while ( it != end )
2353cdf0e10cSrcweir 			{
2354cdf0e10cSrcweir 				notifyPropertyChangeEvent( (*it) );
2355cdf0e10cSrcweir 				it++;
2356cdf0e10cSrcweir 			}
2357cdf0e10cSrcweir 		}
2358cdf0e10cSrcweir 
2359cdf0e10cSrcweir 		return;
2360cdf0e10cSrcweir 	}
2361cdf0e10cSrcweir 
2362cdf0e10cSrcweir 	OSL_ENSURE( sal_False,
2363cdf0e10cSrcweir 				"PersistentPropertySet::setPropertyValues - Nothing set!" );
2364cdf0e10cSrcweir }
2365cdf0e10cSrcweir 
2366cdf0e10cSrcweir //=========================================================================
2367cdf0e10cSrcweir //
2368cdf0e10cSrcweir // Non-interface methods
2369cdf0e10cSrcweir //
2370cdf0e10cSrcweir //=========================================================================
2371cdf0e10cSrcweir 
notifyPropertyChangeEvent(const PropertyChangeEvent & rEvent) const2372cdf0e10cSrcweir void PersistentPropertySet::notifyPropertyChangeEvent(
2373cdf0e10cSrcweir 									const PropertyChangeEvent& rEvent ) const
2374cdf0e10cSrcweir {
2375cdf0e10cSrcweir 	// Get "normal" listeners for the property.
2376cdf0e10cSrcweir 	OInterfaceContainerHelper* pContainer =
2377cdf0e10cSrcweir 			m_pImpl->m_pPropertyChangeListeners->getContainer(
2378cdf0e10cSrcweir 													rEvent.PropertyName );
2379cdf0e10cSrcweir 	if ( pContainer && pContainer->getLength() )
2380cdf0e10cSrcweir 	{
2381cdf0e10cSrcweir 		OInterfaceIteratorHelper aIter( *pContainer );
2382cdf0e10cSrcweir 		while ( aIter.hasMoreElements() )
2383cdf0e10cSrcweir 		{
2384cdf0e10cSrcweir 			// Propagate event.
2385cdf0e10cSrcweir 			Reference< XPropertyChangeListener > xListener(
2386cdf0e10cSrcweir 													aIter.next(), UNO_QUERY );
2387cdf0e10cSrcweir 			if ( xListener.is() )
2388cdf0e10cSrcweir 				xListener->propertyChange( rEvent );
2389cdf0e10cSrcweir 		}
2390cdf0e10cSrcweir 	}
2391cdf0e10cSrcweir 
2392cdf0e10cSrcweir 	// Get "normal" listeners for all properties.
2393cdf0e10cSrcweir 	OInterfaceContainerHelper* pNoNameContainer =
2394cdf0e10cSrcweir 			m_pImpl->m_pPropertyChangeListeners->getContainer( OUString() );
2395cdf0e10cSrcweir 	if ( pNoNameContainer && pNoNameContainer->getLength() )
2396cdf0e10cSrcweir 	{
2397cdf0e10cSrcweir 		OInterfaceIteratorHelper aIter( *pNoNameContainer );
2398cdf0e10cSrcweir 		while ( aIter.hasMoreElements() )
2399cdf0e10cSrcweir 		{
2400cdf0e10cSrcweir 			// Propagate event.
2401cdf0e10cSrcweir 			Reference< XPropertyChangeListener > xListener(
2402cdf0e10cSrcweir 													aIter.next(), UNO_QUERY );
2403cdf0e10cSrcweir 			if ( xListener.is() )
2404cdf0e10cSrcweir 				xListener->propertyChange( rEvent );
2405cdf0e10cSrcweir 		}
2406cdf0e10cSrcweir 	}
2407cdf0e10cSrcweir }
2408cdf0e10cSrcweir 
2409cdf0e10cSrcweir //=========================================================================
notifyPropertySetInfoChange(const PropertySetInfoChangeEvent & evt) const2410cdf0e10cSrcweir void PersistentPropertySet::notifyPropertySetInfoChange(
2411cdf0e10cSrcweir 								const PropertySetInfoChangeEvent& evt ) const
2412cdf0e10cSrcweir {
2413cdf0e10cSrcweir 	if ( !m_pImpl->m_pPropSetChangeListeners )
2414cdf0e10cSrcweir 		return;
2415cdf0e10cSrcweir 
2416cdf0e10cSrcweir 	// Notify event listeners.
2417cdf0e10cSrcweir 	OInterfaceIteratorHelper aIter( *( m_pImpl->m_pPropSetChangeListeners ) );
2418cdf0e10cSrcweir 	while ( aIter.hasMoreElements() )
2419cdf0e10cSrcweir 	{
2420cdf0e10cSrcweir 		// Propagate event.
2421cdf0e10cSrcweir 		Reference< XPropertySetInfoChangeListener >
2422cdf0e10cSrcweir 							xListener( aIter.next(), UNO_QUERY );
2423cdf0e10cSrcweir 		if ( xListener.is() )
2424cdf0e10cSrcweir 			xListener->propertySetInfoChange( evt );
2425cdf0e10cSrcweir 	}
2426cdf0e10cSrcweir }
2427cdf0e10cSrcweir 
2428cdf0e10cSrcweir //=========================================================================
getFullKey()2429cdf0e10cSrcweir const OUString& PersistentPropertySet::getFullKey()
2430cdf0e10cSrcweir {
2431cdf0e10cSrcweir 	if ( !m_pImpl->m_aFullKey.getLength() )
2432cdf0e10cSrcweir 	{
2433cdf0e10cSrcweir         osl::Guard< osl::Mutex > aGuard( m_pImpl->m_aMutex );
2434cdf0e10cSrcweir         if ( !m_pImpl->m_aFullKey.getLength() )
2435cdf0e10cSrcweir         {
2436cdf0e10cSrcweir             m_pImpl->m_aFullKey
2437cdf0e10cSrcweir                 = makeHierarchalNameSegment( m_pImpl->m_aKey );
2438cdf0e10cSrcweir             m_pImpl->m_aFullKey
2439cdf0e10cSrcweir                 += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "/Values" ) );
2440cdf0e10cSrcweir         }
2441cdf0e10cSrcweir 	}
2442cdf0e10cSrcweir 
2443cdf0e10cSrcweir 	return m_pImpl->m_aFullKey;
2444cdf0e10cSrcweir }
2445cdf0e10cSrcweir 
2446cdf0e10cSrcweir //=========================================================================
getPropertySetRegistry()2447cdf0e10cSrcweir PropertySetRegistry& PersistentPropertySet::getPropertySetRegistry()
2448cdf0e10cSrcweir {
2449cdf0e10cSrcweir 	return *m_pImpl->m_pCreator;
2450cdf0e10cSrcweir }
2451cdf0e10cSrcweir 
2452cdf0e10cSrcweir //=========================================================================
2453cdf0e10cSrcweir //=========================================================================
2454cdf0e10cSrcweir //
2455cdf0e10cSrcweir // PropertySetInfo_Impl Implementation.
2456cdf0e10cSrcweir //
2457cdf0e10cSrcweir //=========================================================================
2458cdf0e10cSrcweir //=========================================================================
2459cdf0e10cSrcweir 
PropertySetInfo_Impl(const Reference<XMultiServiceFactory> & rxSMgr,PersistentPropertySet * pOwner)2460cdf0e10cSrcweir PropertySetInfo_Impl::PropertySetInfo_Impl(
2461cdf0e10cSrcweir 						const Reference< XMultiServiceFactory >& rxSMgr,
2462cdf0e10cSrcweir 						PersistentPropertySet* pOwner )
2463cdf0e10cSrcweir : m_xSMgr( rxSMgr ),
2464cdf0e10cSrcweir   m_pProps( NULL ),
2465cdf0e10cSrcweir   m_pOwner( pOwner )
2466cdf0e10cSrcweir {
2467cdf0e10cSrcweir }
2468cdf0e10cSrcweir 
2469cdf0e10cSrcweir //=========================================================================
2470cdf0e10cSrcweir // virtual
~PropertySetInfo_Impl()2471cdf0e10cSrcweir PropertySetInfo_Impl::~PropertySetInfo_Impl()
2472cdf0e10cSrcweir {
2473cdf0e10cSrcweir 	delete m_pProps;
2474cdf0e10cSrcweir 
2475cdf0e10cSrcweir 	// !!! Do not delete m_pOwner !!!
2476cdf0e10cSrcweir }
2477cdf0e10cSrcweir 
2478cdf0e10cSrcweir //=========================================================================
2479cdf0e10cSrcweir //
2480cdf0e10cSrcweir // XInterface methods.
2481cdf0e10cSrcweir //
2482cdf0e10cSrcweir //=========================================================================
2483cdf0e10cSrcweir 
2484cdf0e10cSrcweir XINTERFACE_IMPL_2( PropertySetInfo_Impl,
2485cdf0e10cSrcweir 				   XTypeProvider,
2486cdf0e10cSrcweir 				   XPropertySetInfo );
2487cdf0e10cSrcweir 
2488cdf0e10cSrcweir //=========================================================================
2489cdf0e10cSrcweir //
2490cdf0e10cSrcweir // XTypeProvider methods.
2491cdf0e10cSrcweir //
2492cdf0e10cSrcweir //=========================================================================
2493cdf0e10cSrcweir 
2494cdf0e10cSrcweir XTYPEPROVIDER_IMPL_2( PropertySetInfo_Impl,
2495cdf0e10cSrcweir 				   	  XTypeProvider,
2496cdf0e10cSrcweir 				   	  XPropertySetInfo );
2497cdf0e10cSrcweir 
2498cdf0e10cSrcweir //=========================================================================
2499cdf0e10cSrcweir //
2500cdf0e10cSrcweir // XPropertySetInfo methods.
2501cdf0e10cSrcweir //
2502cdf0e10cSrcweir //=========================================================================
2503cdf0e10cSrcweir 
2504cdf0e10cSrcweir // virtual
getProperties()2505cdf0e10cSrcweir Sequence< Property > SAL_CALL PropertySetInfo_Impl::getProperties()
2506cdf0e10cSrcweir 	throw( RuntimeException )
2507cdf0e10cSrcweir {
2508cdf0e10cSrcweir 	if ( !m_pProps )
2509cdf0e10cSrcweir 	{
2510cdf0e10cSrcweir 		Reference< XHierarchicalNameAccess > xRootHierNameAccess(
2511cdf0e10cSrcweir 			m_pOwner->getPropertySetRegistry().getRootConfigReadAccess(),
2512cdf0e10cSrcweir 			UNO_QUERY );
2513cdf0e10cSrcweir 		if ( xRootHierNameAccess.is() )
2514cdf0e10cSrcweir 		{
2515cdf0e10cSrcweir 			try
2516cdf0e10cSrcweir 			{
2517cdf0e10cSrcweir 				Reference< XNameAccess > xNameAccess;
2518cdf0e10cSrcweir 				xRootHierNameAccess->getByHierarchicalName(
2519cdf0e10cSrcweir 							m_pOwner->getFullKey() )
2520cdf0e10cSrcweir 					>>= xNameAccess;
2521cdf0e10cSrcweir 				if ( xNameAccess.is() )
2522cdf0e10cSrcweir 				{
2523cdf0e10cSrcweir 					// Obtain property names.
2524cdf0e10cSrcweir 
2525cdf0e10cSrcweir 					Sequence< OUString > aElems
2526cdf0e10cSrcweir 											= xNameAccess->getElementNames();
2527cdf0e10cSrcweir 
2528cdf0e10cSrcweir 					sal_uInt32 nCount = aElems.getLength();
2529cdf0e10cSrcweir 					Sequence< Property >* pPropSeq
2530cdf0e10cSrcweir 										= new Sequence< Property >( nCount );
2531cdf0e10cSrcweir 
2532cdf0e10cSrcweir 					if ( nCount )
2533cdf0e10cSrcweir 					{
2534cdf0e10cSrcweir 						Reference< XHierarchicalNameAccess > xHierNameAccess(
2535cdf0e10cSrcweir 													xNameAccess, UNO_QUERY );
2536cdf0e10cSrcweir 
2537cdf0e10cSrcweir 						OSL_ENSURE( xHierNameAccess.is(),
2538cdf0e10cSrcweir 									"PropertySetInfo_Impl::getProperties - "
2539cdf0e10cSrcweir 									"No hierarchical name access!" );
2540cdf0e10cSrcweir 
2541cdf0e10cSrcweir 						if ( xHierNameAccess.is() )
2542cdf0e10cSrcweir 						{
2543cdf0e10cSrcweir                             const OUString aHandleName
2544cdf0e10cSrcweir 								= OUString::createFromAscii( "/Handle" );
2545cdf0e10cSrcweir                             const OUString aValueName
2546cdf0e10cSrcweir 								= OUString::createFromAscii( "/Value" );
2547cdf0e10cSrcweir                             const OUString aAttrName
2548cdf0e10cSrcweir 								= OUString::createFromAscii( "/Attributes" );
2549cdf0e10cSrcweir 
2550cdf0e10cSrcweir 							Property* pProps = pPropSeq->getArray();
2551cdf0e10cSrcweir 
2552cdf0e10cSrcweir 							for ( sal_uInt32 n = 0; n < nCount; ++n )
2553cdf0e10cSrcweir 							{
2554cdf0e10cSrcweir 								Property& rProp = pProps[ n ];
2555cdf0e10cSrcweir                                 OUString  rName = aElems[ n ];
2556cdf0e10cSrcweir                                 OUString aXMLName
2557cdf0e10cSrcweir                                     = makeHierarchalNameSegment( rName );
2558cdf0e10cSrcweir 
2559cdf0e10cSrcweir 								// Set property name.
2560cdf0e10cSrcweir 
2561cdf0e10cSrcweir 								rProp.Name = rName;
2562cdf0e10cSrcweir 
2563cdf0e10cSrcweir 								try
2564cdf0e10cSrcweir 								{
2565cdf0e10cSrcweir 									// Obtain and set property handle
2566cdf0e10cSrcweir                                     rtl::OUString aHierName = aXMLName;
2567cdf0e10cSrcweir 									aHierName += aHandleName;
2568cdf0e10cSrcweir 									Any aKeyValue
2569cdf0e10cSrcweir 										= xHierNameAccess->getByHierarchicalName(
2570cdf0e10cSrcweir 											aHierName );
2571cdf0e10cSrcweir 
2572cdf0e10cSrcweir 									if ( !( aKeyValue >>= rProp.Handle ) )
2573cdf0e10cSrcweir 										OSL_ENSURE( sal_False,
2574cdf0e10cSrcweir 									  	"PropertySetInfo_Impl::getProperties - "
2575cdf0e10cSrcweir 									  	"Error getting property handle!" );
2576cdf0e10cSrcweir 								}
2577cdf0e10cSrcweir 								catch ( NoSuchElementException& )
2578cdf0e10cSrcweir 								{
2579cdf0e10cSrcweir 									// getByHierarchicalName
2580cdf0e10cSrcweir 
2581cdf0e10cSrcweir 									OSL_ENSURE( sal_False,
2582cdf0e10cSrcweir 								  	"PropertySetInfo_Impl::getProperties - "
2583cdf0e10cSrcweir 								  	"NoSuchElementException!" );
2584cdf0e10cSrcweir 								}
2585cdf0e10cSrcweir 
2586cdf0e10cSrcweir 								try
2587cdf0e10cSrcweir 								{
2588cdf0e10cSrcweir 									// Obtain and set property type
2589cdf0e10cSrcweir                                     rtl::OUString aHierName = aXMLName;
2590cdf0e10cSrcweir 									aHierName += aValueName;
2591cdf0e10cSrcweir 									Any aKeyValue
2592cdf0e10cSrcweir 										= xHierNameAccess->getByHierarchicalName(
2593cdf0e10cSrcweir 											aHierName );
2594cdf0e10cSrcweir 
2595cdf0e10cSrcweir 									// Note: The type may be void if addProperty
2596cdf0e10cSrcweir 									//       was called with a default value
2597cdf0e10cSrcweir 									//       of type void.
2598cdf0e10cSrcweir 
2599cdf0e10cSrcweir 									rProp.Type = aKeyValue.getValueType();
2600cdf0e10cSrcweir 								}
2601cdf0e10cSrcweir 								catch ( NoSuchElementException& )
2602cdf0e10cSrcweir 								{
2603cdf0e10cSrcweir 									// getByHierarchicalName
2604cdf0e10cSrcweir 
2605cdf0e10cSrcweir 									OSL_ENSURE( sal_False,
2606cdf0e10cSrcweir 								  	"PropertySetInfo_Impl::getProperties - "
2607cdf0e10cSrcweir 								  	"NoSuchElementException!" );
2608cdf0e10cSrcweir 								}
2609cdf0e10cSrcweir 
2610cdf0e10cSrcweir 								try
2611cdf0e10cSrcweir 								{
2612cdf0e10cSrcweir 									// Obtain and set property attributes
2613cdf0e10cSrcweir                                     rtl::OUString aHierName = aXMLName;
2614cdf0e10cSrcweir 									aHierName += aAttrName;
2615cdf0e10cSrcweir 									Any aKeyValue
2616cdf0e10cSrcweir 										= xHierNameAccess->getByHierarchicalName(
2617cdf0e10cSrcweir 											aHierName );
2618cdf0e10cSrcweir 
2619cdf0e10cSrcweir 									sal_Int32 nAttribs = 0;
2620cdf0e10cSrcweir 									if ( aKeyValue >>= nAttribs )
2621cdf0e10cSrcweir 										rProp.Attributes
2622cdf0e10cSrcweir 											= sal_Int16( nAttribs );
2623cdf0e10cSrcweir 									else
2624cdf0e10cSrcweir 										OSL_ENSURE( sal_False,
2625cdf0e10cSrcweir 									  	"PropertySetInfo_Impl::getProperties - "
2626cdf0e10cSrcweir 									  	"Error getting property attributes!" );
2627cdf0e10cSrcweir 								}
2628cdf0e10cSrcweir 								catch ( NoSuchElementException& )
2629cdf0e10cSrcweir 								{
2630cdf0e10cSrcweir 									// getByHierarchicalName
2631cdf0e10cSrcweir 
2632cdf0e10cSrcweir 									OSL_ENSURE( sal_False,
2633cdf0e10cSrcweir 								  	"PropertySetInfo_Impl::getProperties - "
2634cdf0e10cSrcweir 								  	"NoSuchElementException!" );
2635cdf0e10cSrcweir 								}
2636cdf0e10cSrcweir 							}
2637cdf0e10cSrcweir 						}
2638cdf0e10cSrcweir 					}
2639cdf0e10cSrcweir 
2640cdf0e10cSrcweir 					// Success.
2641cdf0e10cSrcweir 					m_pProps = pPropSeq;
2642cdf0e10cSrcweir 					return *m_pProps;
2643cdf0e10cSrcweir 				}
2644cdf0e10cSrcweir 			}
2645cdf0e10cSrcweir 			catch ( NoSuchElementException& )
2646cdf0e10cSrcweir 			{
2647cdf0e10cSrcweir 				// getByHierarchicalName
2648cdf0e10cSrcweir 			}
2649cdf0e10cSrcweir 		}
2650cdf0e10cSrcweir 
2651cdf0e10cSrcweir 		OSL_ENSURE( sal_False, "PropertySetInfo_Impl::getProperties - Error!" );
2652cdf0e10cSrcweir 		m_pProps = new Sequence< Property >( 0 );
2653cdf0e10cSrcweir 	}
2654cdf0e10cSrcweir 
2655cdf0e10cSrcweir 	return *m_pProps;
2656cdf0e10cSrcweir }
2657cdf0e10cSrcweir 
2658cdf0e10cSrcweir //=========================================================================
2659cdf0e10cSrcweir // virtual
getPropertyByName(const OUString & aName)2660cdf0e10cSrcweir Property SAL_CALL PropertySetInfo_Impl::getPropertyByName(
2661cdf0e10cSrcweir 													const OUString& aName )
2662cdf0e10cSrcweir 	throw( UnknownPropertyException, RuntimeException )
2663cdf0e10cSrcweir {
2664cdf0e10cSrcweir 	Reference< XHierarchicalNameAccess > xRootHierNameAccess(
2665cdf0e10cSrcweir 			m_pOwner->getPropertySetRegistry().getRootConfigReadAccess(),
2666cdf0e10cSrcweir 			UNO_QUERY );
2667cdf0e10cSrcweir 	if ( xRootHierNameAccess.is() )
2668cdf0e10cSrcweir 	{
2669cdf0e10cSrcweir 		OUString aFullPropName( m_pOwner->getFullKey() );
2670cdf0e10cSrcweir 		aFullPropName += OUString::createFromAscii( "/" );
2671cdf0e10cSrcweir         aFullPropName += makeHierarchalNameSegment( aName );
2672cdf0e10cSrcweir 
2673cdf0e10cSrcweir 		// Does property exist?
2674cdf0e10cSrcweir 		if ( !xRootHierNameAccess->hasByHierarchicalName( aFullPropName ) )
2675cdf0e10cSrcweir 			throw UnknownPropertyException();
2676cdf0e10cSrcweir 
2677cdf0e10cSrcweir 		try
2678cdf0e10cSrcweir 		{
2679cdf0e10cSrcweir 			Property aProp;
2680cdf0e10cSrcweir 
2681cdf0e10cSrcweir 			// Obtain handle.
2682cdf0e10cSrcweir 			OUString aKey = aFullPropName;
2683cdf0e10cSrcweir 			aKey += OUString::createFromAscii( "/Handle" );
2684cdf0e10cSrcweir 
2685cdf0e10cSrcweir 			if ( !( xRootHierNameAccess->getByHierarchicalName( aKey )
2686cdf0e10cSrcweir 					>>= aProp.Handle ) )
2687cdf0e10cSrcweir 			{
2688cdf0e10cSrcweir 				OSL_ENSURE( sal_False,
2689cdf0e10cSrcweir 							"PropertySetInfo_Impl::getPropertyByName - "
2690cdf0e10cSrcweir 							"No handle!" );
2691cdf0e10cSrcweir 				return Property();
2692cdf0e10cSrcweir 			}
2693cdf0e10cSrcweir 
2694cdf0e10cSrcweir 			// Obtain Value and extract type.
2695cdf0e10cSrcweir 			aKey = aFullPropName;
2696cdf0e10cSrcweir 			aKey += OUString::createFromAscii( "/Value" );
2697cdf0e10cSrcweir 
2698cdf0e10cSrcweir 			Any aValue = xRootHierNameAccess->getByHierarchicalName( aKey );
2699cdf0e10cSrcweir 			if ( !aValue.hasValue() )
2700cdf0e10cSrcweir 			{
2701cdf0e10cSrcweir 				OSL_ENSURE( sal_False,
2702cdf0e10cSrcweir 							"PropertySetInfo_Impl::getPropertyByName - "
2703cdf0e10cSrcweir 							"No Value!" );
2704cdf0e10cSrcweir 				return Property();
2705cdf0e10cSrcweir 			}
2706cdf0e10cSrcweir 
2707cdf0e10cSrcweir 			aProp.Type = aValue.getValueType();
2708cdf0e10cSrcweir 
2709cdf0e10cSrcweir 			// Obtain Attributes.
2710cdf0e10cSrcweir 			aKey = aFullPropName;
2711cdf0e10cSrcweir 			aKey += OUString::createFromAscii( "/Attributes" );
2712cdf0e10cSrcweir 
2713cdf0e10cSrcweir 			sal_Int32 nAttribs = 0;
2714cdf0e10cSrcweir 			if ( xRootHierNameAccess->getByHierarchicalName( aKey )
2715cdf0e10cSrcweir 					>>= nAttribs )
2716cdf0e10cSrcweir 				aProp.Attributes = sal_Int16( nAttribs );
2717cdf0e10cSrcweir 			else
2718cdf0e10cSrcweir 			{
2719cdf0e10cSrcweir 				OSL_ENSURE( sal_False,
2720cdf0e10cSrcweir 							"PropertySetInfo_Impl::getPropertyByName - "
2721cdf0e10cSrcweir 							"No attributes!" );
2722cdf0e10cSrcweir 				return Property();
2723cdf0e10cSrcweir 			}
2724cdf0e10cSrcweir 
2725cdf0e10cSrcweir 			// set name.
2726cdf0e10cSrcweir 			aProp.Name = aName;
2727cdf0e10cSrcweir 
2728cdf0e10cSrcweir 			// Success.
2729cdf0e10cSrcweir 			return aProp;
2730cdf0e10cSrcweir 		}
2731cdf0e10cSrcweir 		catch ( NoSuchElementException& )
2732cdf0e10cSrcweir 		{
2733cdf0e10cSrcweir 			// getByHierarchicalName
2734cdf0e10cSrcweir 
2735cdf0e10cSrcweir 			OSL_ENSURE( sal_False,
2736cdf0e10cSrcweir 						"PropertySetInfo_Impl::getPropertyByName - "
2737cdf0e10cSrcweir 						"caught NoSuchElementException!" );
2738cdf0e10cSrcweir 		}
2739cdf0e10cSrcweir 
2740cdf0e10cSrcweir 	}
2741cdf0e10cSrcweir 
2742cdf0e10cSrcweir 	OSL_ENSURE( sal_False, "PropertySetInfo_Impl::getPropertyByName - Error!" );
2743cdf0e10cSrcweir 	return Property();
2744cdf0e10cSrcweir }
2745cdf0e10cSrcweir 
2746cdf0e10cSrcweir //=========================================================================
2747cdf0e10cSrcweir // virtual
hasPropertyByName(const OUString & Name)2748cdf0e10cSrcweir sal_Bool SAL_CALL PropertySetInfo_Impl::hasPropertyByName(
2749cdf0e10cSrcweir 													const OUString& Name )
2750cdf0e10cSrcweir 	throw( RuntimeException )
2751cdf0e10cSrcweir {
2752cdf0e10cSrcweir 	Reference< XHierarchicalNameAccess > xRootHierNameAccess(
2753cdf0e10cSrcweir 			m_pOwner->getPropertySetRegistry().getRootConfigReadAccess(),
2754cdf0e10cSrcweir 			UNO_QUERY );
2755cdf0e10cSrcweir 	if ( xRootHierNameAccess.is() )
2756cdf0e10cSrcweir 	{
2757cdf0e10cSrcweir 		OUString aFullPropName( m_pOwner->getFullKey() );
2758cdf0e10cSrcweir 		aFullPropName += OUString::createFromAscii( "/" );
2759cdf0e10cSrcweir         aFullPropName += makeHierarchalNameSegment( Name );
2760cdf0e10cSrcweir 
2761cdf0e10cSrcweir 		return xRootHierNameAccess->hasByHierarchicalName( aFullPropName );
2762cdf0e10cSrcweir 	}
2763cdf0e10cSrcweir 
2764cdf0e10cSrcweir 	return sal_False;
2765cdf0e10cSrcweir }
2766cdf0e10cSrcweir 
2767