1*ac9096f4SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*ac9096f4SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*ac9096f4SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*ac9096f4SAndrew Rist  * distributed with this work for additional information
6*ac9096f4SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*ac9096f4SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*ac9096f4SAndrew Rist  * "License"); you may not use this file except in compliance
9*ac9096f4SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*ac9096f4SAndrew Rist  *
11*ac9096f4SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*ac9096f4SAndrew Rist  *
13*ac9096f4SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*ac9096f4SAndrew Rist  * software distributed under the License is distributed on an
15*ac9096f4SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*ac9096f4SAndrew Rist  * KIND, either express or implied.  See the License for the
17*ac9096f4SAndrew Rist  * specific language governing permissions and limitations
18*ac9096f4SAndrew Rist  * under the License.
19*ac9096f4SAndrew Rist  *
20*ac9096f4SAndrew Rist  *************************************************************/
21*ac9096f4SAndrew Rist 
22*ac9096f4SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_ucbhelper.hxx"
26cdf0e10cSrcweir /**************************************************************************
27cdf0e10cSrcweir 								TODO
28cdf0e10cSrcweir  **************************************************************************
29cdf0e10cSrcweir 
30cdf0e10cSrcweir  *************************************************************************/
31cdf0e10cSrcweir 
32cdf0e10cSrcweir #include <hash_map>
33cdf0e10cSrcweir #include <com/sun/star/ucb/ContentAction.hpp>
34cdf0e10cSrcweir #include <com/sun/star/ucb/CommandInfoChange.hpp>
35cdf0e10cSrcweir #include <com/sun/star/ucb/XPersistentPropertySet.hpp>
36cdf0e10cSrcweir #include <com/sun/star/beans/PropertyAttribute.hpp>
37cdf0e10cSrcweir #include <com/sun/star/beans/PropertySetInfoChange.hpp>
38cdf0e10cSrcweir #include <cppuhelper/interfacecontainer.hxx>
39cdf0e10cSrcweir 
40cdf0e10cSrcweir #include "osl/diagnose.h"
41cdf0e10cSrcweir #include "osl/mutex.hxx"
42cdf0e10cSrcweir #include "rtl/ref.hxx"
43cdf0e10cSrcweir #include <ucbhelper/contentidentifier.hxx>
44cdf0e10cSrcweir #include <ucbhelper/contenthelper.hxx>
45cdf0e10cSrcweir #include <ucbhelper/providerhelper.hxx>
46cdf0e10cSrcweir #include <ucbhelper/contentinfo.hxx>
47cdf0e10cSrcweir 
48cdf0e10cSrcweir using namespace com::sun::star;
49cdf0e10cSrcweir 
50cdf0e10cSrcweir namespace ucbhelper_impl
51cdf0e10cSrcweir {
52cdf0e10cSrcweir 
53cdf0e10cSrcweir //=========================================================================
54cdf0e10cSrcweir //
55cdf0e10cSrcweir // class PropertyEventSequence.
56cdf0e10cSrcweir //
57cdf0e10cSrcweir //=========================================================================
58cdf0e10cSrcweir 
59cdf0e10cSrcweir class PropertyEventSequence
60cdf0e10cSrcweir {
61cdf0e10cSrcweir 	uno::Sequence< beans::PropertyChangeEvent > m_aSeq;
62cdf0e10cSrcweir 	sal_uInt32                                  m_nPos;
63cdf0e10cSrcweir 
64cdf0e10cSrcweir public:
PropertyEventSequence(sal_uInt32 nSize)65cdf0e10cSrcweir 	PropertyEventSequence( sal_uInt32 nSize )
66cdf0e10cSrcweir 	: m_aSeq( nSize ), m_nPos( 0 ) {};
67cdf0e10cSrcweir 
append(const beans::PropertyChangeEvent & rEvt)68cdf0e10cSrcweir 	void append( const beans::PropertyChangeEvent& rEvt )
69cdf0e10cSrcweir 	{ m_aSeq.getArray()[ m_nPos ] = rEvt; ++m_nPos; }
70cdf0e10cSrcweir 
getEvents()71cdf0e10cSrcweir 	const uno::Sequence< beans::PropertyChangeEvent >& getEvents()
72cdf0e10cSrcweir 	{ m_aSeq.realloc( m_nPos ); return m_aSeq; }
73cdf0e10cSrcweir };
74cdf0e10cSrcweir 
75cdf0e10cSrcweir //=========================================================================
76cdf0e10cSrcweir //
77cdf0e10cSrcweir // PropertiesEventListenerMap.
78cdf0e10cSrcweir //
79cdf0e10cSrcweir //=========================================================================
80cdf0e10cSrcweir 
81cdf0e10cSrcweir typedef void* XPropertiesChangeListenerPtr; // -> Compiler problems!
82cdf0e10cSrcweir 
83cdf0e10cSrcweir struct equalPtr
84cdf0e10cSrcweir {
operator ()ucbhelper_impl::equalPtr85cdf0e10cSrcweir 	bool operator()( const XPropertiesChangeListenerPtr& rp1,
86cdf0e10cSrcweir 					 const XPropertiesChangeListenerPtr& rp2 ) const
87cdf0e10cSrcweir 	{
88cdf0e10cSrcweir 		return ( rp1 == rp2 );
89cdf0e10cSrcweir 	}
90cdf0e10cSrcweir };
91cdf0e10cSrcweir 
92cdf0e10cSrcweir struct hashPtr
93cdf0e10cSrcweir {
operator ()ucbhelper_impl::hashPtr94cdf0e10cSrcweir 	size_t operator()( const XPropertiesChangeListenerPtr& rp ) const
95cdf0e10cSrcweir 	{
96cdf0e10cSrcweir 		return (size_t)rp;
97cdf0e10cSrcweir 	}
98cdf0e10cSrcweir };
99cdf0e10cSrcweir 
100cdf0e10cSrcweir typedef std::hash_map
101cdf0e10cSrcweir <
102cdf0e10cSrcweir 	XPropertiesChangeListenerPtr,
103cdf0e10cSrcweir 	PropertyEventSequence*,
104cdf0e10cSrcweir 	hashPtr,
105cdf0e10cSrcweir 	equalPtr
106cdf0e10cSrcweir >
107cdf0e10cSrcweir PropertiesEventListenerMap;
108cdf0e10cSrcweir 
109cdf0e10cSrcweir //=========================================================================
110cdf0e10cSrcweir //
111cdf0e10cSrcweir // PropertyChangeListenerContainer.
112cdf0e10cSrcweir //
113cdf0e10cSrcweir //=========================================================================
114cdf0e10cSrcweir 
115cdf0e10cSrcweir struct equalStr
116cdf0e10cSrcweir {
operator ()ucbhelper_impl::equalStr117cdf0e10cSrcweir 	bool operator()( const rtl::OUString& s1, const rtl::OUString& s2 ) const
118cdf0e10cSrcweir   	{
119cdf0e10cSrcweir 		return !!( s1 == s2 );
120cdf0e10cSrcweir 	}
121cdf0e10cSrcweir };
122cdf0e10cSrcweir 
123cdf0e10cSrcweir struct hashStr
124cdf0e10cSrcweir {
operator ()ucbhelper_impl::hashStr125cdf0e10cSrcweir 	size_t operator()( const rtl::OUString& rName ) const
126cdf0e10cSrcweir 	{
127cdf0e10cSrcweir 		return rName.hashCode();
128cdf0e10cSrcweir 	}
129cdf0e10cSrcweir };
130cdf0e10cSrcweir 
131cdf0e10cSrcweir typedef cppu::OMultiTypeInterfaceContainerHelperVar
132cdf0e10cSrcweir <
133cdf0e10cSrcweir 	rtl::OUString,
134cdf0e10cSrcweir 	hashStr,
135cdf0e10cSrcweir 	equalStr
136cdf0e10cSrcweir > PropertyChangeListeners;
137cdf0e10cSrcweir 
138cdf0e10cSrcweir //=========================================================================
139cdf0e10cSrcweir //
140cdf0e10cSrcweir // struct ContentImplHelper_Impl
141cdf0e10cSrcweir //
142cdf0e10cSrcweir //=========================================================================
143cdf0e10cSrcweir 
144cdf0e10cSrcweir struct ContentImplHelper_Impl
145cdf0e10cSrcweir {
146cdf0e10cSrcweir 	rtl::Reference< ::ucbhelper::PropertySetInfo > 	    m_xPropSetInfo;
147cdf0e10cSrcweir 	rtl::Reference< ::ucbhelper::CommandProcessorInfo > m_xCommandsInfo;
148cdf0e10cSrcweir 	cppu::OInterfaceContainerHelper*              m_pDisposeEventListeners;
149cdf0e10cSrcweir 	cppu::OInterfaceContainerHelper*              m_pContentEventListeners;
150cdf0e10cSrcweir 	cppu::OInterfaceContainerHelper*              m_pPropSetChangeListeners;
151cdf0e10cSrcweir 	cppu::OInterfaceContainerHelper*              m_pCommandChangeListeners;
152cdf0e10cSrcweir 	PropertyChangeListeners*    	              m_pPropertyChangeListeners;
153cdf0e10cSrcweir 
ContentImplHelper_Implucbhelper_impl::ContentImplHelper_Impl154cdf0e10cSrcweir 	ContentImplHelper_Impl()
155cdf0e10cSrcweir 	: m_pDisposeEventListeners( 0 ),
156cdf0e10cSrcweir   	  m_pContentEventListeners( 0 ),
157cdf0e10cSrcweir 	  m_pPropSetChangeListeners( 0 ),
158cdf0e10cSrcweir   	  m_pCommandChangeListeners( 0 ),
159cdf0e10cSrcweir 	  m_pPropertyChangeListeners( 0 ) {}
160cdf0e10cSrcweir 
~ContentImplHelper_Implucbhelper_impl::ContentImplHelper_Impl161cdf0e10cSrcweir 	~ContentImplHelper_Impl()
162cdf0e10cSrcweir 	{
163cdf0e10cSrcweir 		delete m_pDisposeEventListeners;
164cdf0e10cSrcweir 		delete m_pContentEventListeners;
165cdf0e10cSrcweir 		delete m_pPropSetChangeListeners;
166cdf0e10cSrcweir 		delete m_pCommandChangeListeners;
167cdf0e10cSrcweir 		delete m_pPropertyChangeListeners;
168cdf0e10cSrcweir 	}
169cdf0e10cSrcweir };
170cdf0e10cSrcweir 
171cdf0e10cSrcweir } // namespace ucbhelper_impl
172cdf0e10cSrcweir 
173cdf0e10cSrcweir using namespace ucbhelper_impl;
174cdf0e10cSrcweir 
175cdf0e10cSrcweir //=========================================================================
176cdf0e10cSrcweir //=========================================================================
177cdf0e10cSrcweir //
178cdf0e10cSrcweir // ContentImplHelper Implementation.
179cdf0e10cSrcweir //
180cdf0e10cSrcweir //=========================================================================
181cdf0e10cSrcweir //=========================================================================
182cdf0e10cSrcweir 
183cdf0e10cSrcweir namespace ucbhelper {
184cdf0e10cSrcweir 
ContentImplHelper(const uno::Reference<lang::XMultiServiceFactory> & rxSMgr,const rtl::Reference<ContentProviderImplHelper> & rxProvider,const uno::Reference<com::sun::star::ucb::XContentIdentifier> & Identifier)185cdf0e10cSrcweir ContentImplHelper::ContentImplHelper(
186cdf0e10cSrcweir 			const uno::Reference< lang::XMultiServiceFactory >& rxSMgr,
187cdf0e10cSrcweir 			const rtl::Reference< ContentProviderImplHelper >& rxProvider,
188cdf0e10cSrcweir 			const uno::Reference<
189cdf0e10cSrcweir             com::sun::star::ucb::XContentIdentifier >& Identifier )
190cdf0e10cSrcweir : m_pImpl( new ContentImplHelper_Impl ),
191cdf0e10cSrcweir   m_xSMgr( rxSMgr ),
192cdf0e10cSrcweir   m_xIdentifier( Identifier ),
193cdf0e10cSrcweir   m_xProvider( rxProvider ),
194cdf0e10cSrcweir   m_nCommandId( 0 )
195cdf0e10cSrcweir {
196cdf0e10cSrcweir }
197cdf0e10cSrcweir 
198cdf0e10cSrcweir //=========================================================================
199cdf0e10cSrcweir // virtual
~ContentImplHelper()200cdf0e10cSrcweir ContentImplHelper::~ContentImplHelper()
201cdf0e10cSrcweir {
202cdf0e10cSrcweir 	delete m_pImpl;
203cdf0e10cSrcweir }
204cdf0e10cSrcweir 
205cdf0e10cSrcweir //=========================================================================
206cdf0e10cSrcweir //
207cdf0e10cSrcweir // XInterface methods.
208cdf0e10cSrcweir //
209cdf0e10cSrcweir //=========================================================================
210cdf0e10cSrcweir 
acquire()211cdf0e10cSrcweir void SAL_CALL ContentImplHelper::acquire()
212cdf0e10cSrcweir 	throw()
213cdf0e10cSrcweir {
214cdf0e10cSrcweir 	cppu::OWeakObject::acquire();
215cdf0e10cSrcweir }
216cdf0e10cSrcweir 
release()217cdf0e10cSrcweir void SAL_CALL ContentImplHelper::release()
218cdf0e10cSrcweir 	throw()
219cdf0e10cSrcweir {
220cdf0e10cSrcweir     // #144882# - Call to OWeakObject::release may destroy m_xProvider.
221cdf0e10cSrcweir     //            Prevent this.
222cdf0e10cSrcweir     rtl::Reference< ContentProviderImplHelper > xKeepProviderAlive(
223cdf0e10cSrcweir         m_xProvider );
224cdf0e10cSrcweir 
225cdf0e10cSrcweir     {
226cdf0e10cSrcweir         osl::MutexGuard aGuard( m_xProvider->m_aMutex );
227cdf0e10cSrcweir         OWeakObject::release();
228cdf0e10cSrcweir     }
229cdf0e10cSrcweir }
230cdf0e10cSrcweir 
queryInterface(const uno::Type & rType)231cdf0e10cSrcweir uno::Any SAL_CALL ContentImplHelper::queryInterface( const uno::Type & rType )
232cdf0e10cSrcweir 	throw( uno::RuntimeException )
233cdf0e10cSrcweir {
234cdf0e10cSrcweir 	com::sun::star::uno::Any aRet = cppu::queryInterface( rType,
235cdf0e10cSrcweir 			static_cast< lang::XTypeProvider * >(this),
236cdf0e10cSrcweir 			static_cast< lang::XServiceInfo * >(this),
237cdf0e10cSrcweir 			static_cast< lang::XComponent * >(this),
238cdf0e10cSrcweir 			static_cast< com::sun::star::ucb::XContent * >(this),
239cdf0e10cSrcweir 			static_cast< com::sun::star::ucb::XCommandProcessor * >(this),
240cdf0e10cSrcweir 			static_cast< beans::XPropertiesChangeNotifier * >(this),
241cdf0e10cSrcweir 			static_cast< com::sun::star::ucb::XCommandInfoChangeNotifier * >(this),
242cdf0e10cSrcweir 			static_cast< beans::XPropertyContainer * >(this),
243cdf0e10cSrcweir 			static_cast< beans::XPropertySetInfoChangeNotifier * >(this),
244cdf0e10cSrcweir 			static_cast< container::XChild * >(this));
245cdf0e10cSrcweir 	return aRet.hasValue() ? aRet : cppu::OWeakObject::queryInterface( rType );
246cdf0e10cSrcweir }
247cdf0e10cSrcweir 
248cdf0e10cSrcweir //=========================================================================
249cdf0e10cSrcweir //
250cdf0e10cSrcweir // XTypeProvider methods.
251cdf0e10cSrcweir //
252cdf0e10cSrcweir //=========================================================================
253cdf0e10cSrcweir 
254cdf0e10cSrcweir XTYPEPROVIDER_IMPL_10( ContentImplHelper,
255cdf0e10cSrcweir 					   lang::XTypeProvider,
256cdf0e10cSrcweir 					   lang::XServiceInfo,
257cdf0e10cSrcweir 					   lang::XComponent,
258cdf0e10cSrcweir 					   com::sun::star::ucb::XContent,
259cdf0e10cSrcweir 					   com::sun::star::ucb::XCommandProcessor,
260cdf0e10cSrcweir 					   beans::XPropertiesChangeNotifier,
261cdf0e10cSrcweir 					   com::sun::star::ucb::XCommandInfoChangeNotifier,
262cdf0e10cSrcweir 					   beans::XPropertyContainer,
263cdf0e10cSrcweir 					   beans::XPropertySetInfoChangeNotifier,
264cdf0e10cSrcweir 					   container::XChild );
265cdf0e10cSrcweir 
266cdf0e10cSrcweir //=========================================================================
267cdf0e10cSrcweir //
268cdf0e10cSrcweir // XServiceInfo methods.
269cdf0e10cSrcweir //
270cdf0e10cSrcweir //=========================================================================
271cdf0e10cSrcweir 
272cdf0e10cSrcweir // virtual
supportsService(const rtl::OUString & ServiceName)273cdf0e10cSrcweir sal_Bool SAL_CALL ContentImplHelper::supportsService(
274cdf0e10cSrcweir 											const rtl::OUString& ServiceName )
275cdf0e10cSrcweir 	throw( uno::RuntimeException )
276cdf0e10cSrcweir {
277cdf0e10cSrcweir 	uno::Sequence< rtl::OUString > aSNL = getSupportedServiceNames();
278cdf0e10cSrcweir 	const rtl::OUString* pArray = aSNL.getConstArray();
279cdf0e10cSrcweir 	for ( sal_Int32 i = 0; i < aSNL.getLength(); i++ )
280cdf0e10cSrcweir 	{
281cdf0e10cSrcweir 		if ( pArray[ i ] == ServiceName )
282cdf0e10cSrcweir 			return sal_True;
283cdf0e10cSrcweir 	}
284cdf0e10cSrcweir 
285cdf0e10cSrcweir 	return sal_False;
286cdf0e10cSrcweir }
287cdf0e10cSrcweir 
288cdf0e10cSrcweir //=========================================================================
289cdf0e10cSrcweir //
290cdf0e10cSrcweir // XComponent methods.
291cdf0e10cSrcweir //
292cdf0e10cSrcweir //=========================================================================
293cdf0e10cSrcweir 
294cdf0e10cSrcweir // virtual
dispose()295cdf0e10cSrcweir void SAL_CALL ContentImplHelper::dispose()
296cdf0e10cSrcweir 	throw( uno::RuntimeException )
297cdf0e10cSrcweir {
298cdf0e10cSrcweir 	osl::MutexGuard aGuard( m_aMutex );
299cdf0e10cSrcweir 
300cdf0e10cSrcweir 	if ( m_pImpl->m_pDisposeEventListeners &&
301cdf0e10cSrcweir 	     m_pImpl->m_pDisposeEventListeners->getLength() )
302cdf0e10cSrcweir 	{
303cdf0e10cSrcweir 		lang::EventObject aEvt;
304cdf0e10cSrcweir 		aEvt.Source = static_cast< lang::XComponent * >( this );
305cdf0e10cSrcweir 		m_pImpl->m_pDisposeEventListeners->disposeAndClear( aEvt );
306cdf0e10cSrcweir 	}
307cdf0e10cSrcweir 
308cdf0e10cSrcweir 	if ( m_pImpl->m_pContentEventListeners &&
309cdf0e10cSrcweir 	     m_pImpl->m_pContentEventListeners->getLength() )
310cdf0e10cSrcweir 	{
311cdf0e10cSrcweir 		lang::EventObject aEvt;
312cdf0e10cSrcweir 		aEvt.Source = static_cast< com::sun::star::ucb::XContent * >( this );
313cdf0e10cSrcweir 		m_pImpl->m_pContentEventListeners->disposeAndClear( aEvt );
314cdf0e10cSrcweir 	}
315cdf0e10cSrcweir 
316cdf0e10cSrcweir 	if ( m_pImpl->m_pPropSetChangeListeners &&
317cdf0e10cSrcweir 	     m_pImpl->m_pPropSetChangeListeners->getLength() )
318cdf0e10cSrcweir 	{
319cdf0e10cSrcweir 		lang::EventObject aEvt;
320cdf0e10cSrcweir 		aEvt.Source
321cdf0e10cSrcweir             = static_cast< beans::XPropertySetInfoChangeNotifier * >( this );
322cdf0e10cSrcweir 		m_pImpl->m_pPropSetChangeListeners->disposeAndClear( aEvt );
323cdf0e10cSrcweir 	}
324cdf0e10cSrcweir 
325cdf0e10cSrcweir 	if ( m_pImpl->m_pCommandChangeListeners &&
326cdf0e10cSrcweir 	     m_pImpl->m_pCommandChangeListeners->getLength() )
327cdf0e10cSrcweir 	{
328cdf0e10cSrcweir 		lang::EventObject aEvt;
329cdf0e10cSrcweir 		aEvt.Source = static_cast<  com::sun::star::ucb::XCommandInfoChangeNotifier * >( this );
330cdf0e10cSrcweir 		m_pImpl->m_pCommandChangeListeners->disposeAndClear( aEvt );
331cdf0e10cSrcweir 	}
332cdf0e10cSrcweir 
333cdf0e10cSrcweir 	if ( m_pImpl->m_pPropertyChangeListeners )
334cdf0e10cSrcweir 	{
335cdf0e10cSrcweir 		lang::EventObject aEvt;
336cdf0e10cSrcweir 		aEvt.Source
337cdf0e10cSrcweir             = static_cast< beans::XPropertiesChangeNotifier * >( this );
338cdf0e10cSrcweir 		m_pImpl->m_pPropertyChangeListeners->disposeAndClear( aEvt );
339cdf0e10cSrcweir 	}
340cdf0e10cSrcweir }
341cdf0e10cSrcweir 
342cdf0e10cSrcweir //=========================================================================
343cdf0e10cSrcweir // virtual
addEventListener(const uno::Reference<lang::XEventListener> & Listener)344cdf0e10cSrcweir void SAL_CALL ContentImplHelper::addEventListener(
345cdf0e10cSrcweir         const uno::Reference< lang::XEventListener >& Listener )
346cdf0e10cSrcweir 	throw( uno::RuntimeException )
347cdf0e10cSrcweir {
348cdf0e10cSrcweir 	osl::MutexGuard aGuard( m_aMutex );
349cdf0e10cSrcweir 
350cdf0e10cSrcweir 	if ( !m_pImpl->m_pDisposeEventListeners )
351cdf0e10cSrcweir 		m_pImpl->m_pDisposeEventListeners
352cdf0e10cSrcweir 			= new cppu::OInterfaceContainerHelper( m_aMutex );
353cdf0e10cSrcweir 
354cdf0e10cSrcweir 	m_pImpl->m_pDisposeEventListeners->addInterface( Listener );
355cdf0e10cSrcweir }
356cdf0e10cSrcweir 
357cdf0e10cSrcweir //=========================================================================
358cdf0e10cSrcweir // virtual
removeEventListener(const uno::Reference<lang::XEventListener> & Listener)359cdf0e10cSrcweir void SAL_CALL ContentImplHelper::removeEventListener(
360cdf0e10cSrcweir         const uno::Reference< lang::XEventListener >& Listener )
361cdf0e10cSrcweir 	throw( uno::RuntimeException )
362cdf0e10cSrcweir {
363cdf0e10cSrcweir 	osl::MutexGuard aGuard( m_aMutex );
364cdf0e10cSrcweir 
365cdf0e10cSrcweir 	if ( m_pImpl->m_pDisposeEventListeners )
366cdf0e10cSrcweir 		m_pImpl->m_pDisposeEventListeners->removeInterface( Listener );
367cdf0e10cSrcweir }
368cdf0e10cSrcweir 
369cdf0e10cSrcweir //=========================================================================
370cdf0e10cSrcweir //
371cdf0e10cSrcweir // XContent methods.
372cdf0e10cSrcweir //
373cdf0e10cSrcweir //=========================================================================
374cdf0e10cSrcweir 
375cdf0e10cSrcweir // virtual
376cdf0e10cSrcweir uno::Reference< com::sun::star::ucb::XContentIdentifier > SAL_CALL
getIdentifier()377cdf0e10cSrcweir ContentImplHelper::getIdentifier()
378cdf0e10cSrcweir 	throw( uno::RuntimeException )
379cdf0e10cSrcweir {
380cdf0e10cSrcweir 	return m_xIdentifier;
381cdf0e10cSrcweir }
382cdf0e10cSrcweir 
383cdf0e10cSrcweir //=========================================================================
384cdf0e10cSrcweir // virtual
addContentEventListener(const uno::Reference<com::sun::star::ucb::XContentEventListener> & Listener)385cdf0e10cSrcweir void SAL_CALL ContentImplHelper::addContentEventListener(
386cdf0e10cSrcweir         const uno::Reference< com::sun::star::ucb::XContentEventListener >& Listener )
387cdf0e10cSrcweir 	throw( uno::RuntimeException )
388cdf0e10cSrcweir {
389cdf0e10cSrcweir 	osl::MutexGuard aGuard( m_aMutex );
390cdf0e10cSrcweir 
391cdf0e10cSrcweir 	if ( !m_pImpl->m_pContentEventListeners )
392cdf0e10cSrcweir 		m_pImpl->m_pContentEventListeners
393cdf0e10cSrcweir 			= new cppu::OInterfaceContainerHelper( m_aMutex );
394cdf0e10cSrcweir 
395cdf0e10cSrcweir 	m_pImpl->m_pContentEventListeners->addInterface( Listener );
396cdf0e10cSrcweir }
397cdf0e10cSrcweir 
398cdf0e10cSrcweir //=========================================================================
399cdf0e10cSrcweir // virtual
removeContentEventListener(const uno::Reference<com::sun::star::ucb::XContentEventListener> & Listener)400cdf0e10cSrcweir void SAL_CALL ContentImplHelper::removeContentEventListener(
401cdf0e10cSrcweir         const uno::Reference< com::sun::star::ucb::XContentEventListener >& Listener )
402cdf0e10cSrcweir 	throw( uno::RuntimeException )
403cdf0e10cSrcweir {
404cdf0e10cSrcweir 	osl::MutexGuard aGuard( m_aMutex );
405cdf0e10cSrcweir 
406cdf0e10cSrcweir 	if ( m_pImpl->m_pContentEventListeners )
407cdf0e10cSrcweir 		m_pImpl->m_pContentEventListeners->removeInterface( Listener );
408cdf0e10cSrcweir }
409cdf0e10cSrcweir 
410cdf0e10cSrcweir //=========================================================================
411cdf0e10cSrcweir //
412cdf0e10cSrcweir // XCommandProcessor methods.
413cdf0e10cSrcweir //
414cdf0e10cSrcweir //=========================================================================
415cdf0e10cSrcweir 
416cdf0e10cSrcweir // virtual
createCommandIdentifier()417cdf0e10cSrcweir sal_Int32 SAL_CALL ContentImplHelper::createCommandIdentifier()
418cdf0e10cSrcweir 	throw( uno::RuntimeException )
419cdf0e10cSrcweir {
420cdf0e10cSrcweir 	osl::MutexGuard aGuard( m_aMutex );
421cdf0e10cSrcweir 
422cdf0e10cSrcweir 	// Just increase counter on every call to generate an identifier.
423cdf0e10cSrcweir 	return ++m_nCommandId;
424cdf0e10cSrcweir }
425cdf0e10cSrcweir 
426cdf0e10cSrcweir //=========================================================================
427cdf0e10cSrcweir //
428cdf0e10cSrcweir // XPropertiesChangeNotifier methods.
429cdf0e10cSrcweir //
430cdf0e10cSrcweir //=========================================================================
431cdf0e10cSrcweir 
432cdf0e10cSrcweir // virtual
addPropertiesChangeListener(const uno::Sequence<rtl::OUString> & PropertyNames,const uno::Reference<beans::XPropertiesChangeListener> & Listener)433cdf0e10cSrcweir void SAL_CALL ContentImplHelper::addPropertiesChangeListener(
434cdf0e10cSrcweir         const uno::Sequence< rtl::OUString >& PropertyNames,
435cdf0e10cSrcweir         const uno::Reference< beans::XPropertiesChangeListener >& Listener )
436cdf0e10cSrcweir 	throw( uno::RuntimeException )
437cdf0e10cSrcweir {
438cdf0e10cSrcweir 	osl::MutexGuard aGuard( m_aMutex );
439cdf0e10cSrcweir 
440cdf0e10cSrcweir 	if ( !m_pImpl->m_pPropertyChangeListeners )
441cdf0e10cSrcweir 		m_pImpl->m_pPropertyChangeListeners
442cdf0e10cSrcweir 			= new PropertyChangeListeners( m_aMutex );
443cdf0e10cSrcweir 
444cdf0e10cSrcweir 	sal_Int32 nCount = PropertyNames.getLength();
445cdf0e10cSrcweir 	if ( !nCount )
446cdf0e10cSrcweir 	{
447cdf0e10cSrcweir 		// Note: An empty sequence means a listener for "all" properties.
448cdf0e10cSrcweir 		m_pImpl->m_pPropertyChangeListeners->addInterface(
449cdf0e10cSrcweir             rtl::OUString(), Listener );
450cdf0e10cSrcweir 	}
451cdf0e10cSrcweir 	else
452cdf0e10cSrcweir 	{
453cdf0e10cSrcweir 		const rtl::OUString* pSeq = PropertyNames.getConstArray();
454cdf0e10cSrcweir 
455cdf0e10cSrcweir 		for ( sal_Int32 n = 0; n < nCount; ++n )
456cdf0e10cSrcweir 		{
457cdf0e10cSrcweir 			const rtl::OUString& rName = pSeq[ n ];
458cdf0e10cSrcweir 			if ( rName.getLength() )
459cdf0e10cSrcweir 				m_pImpl->m_pPropertyChangeListeners->addInterface(
460cdf0e10cSrcweir                     rName, Listener );
461cdf0e10cSrcweir 		}
462cdf0e10cSrcweir 	}
463cdf0e10cSrcweir }
464cdf0e10cSrcweir 
465cdf0e10cSrcweir //=========================================================================
466cdf0e10cSrcweir // virtual
removePropertiesChangeListener(const uno::Sequence<rtl::OUString> & PropertyNames,const uno::Reference<beans::XPropertiesChangeListener> & Listener)467cdf0e10cSrcweir void SAL_CALL ContentImplHelper::removePropertiesChangeListener(
468cdf0e10cSrcweir         const uno::Sequence< rtl::OUString >& PropertyNames,
469cdf0e10cSrcweir         const uno::Reference< beans::XPropertiesChangeListener >& Listener )
470cdf0e10cSrcweir 	throw( uno::RuntimeException )
471cdf0e10cSrcweir {
472cdf0e10cSrcweir 	osl::MutexGuard aGuard( m_aMutex );
473cdf0e10cSrcweir 
474cdf0e10cSrcweir 	if ( !m_pImpl->m_pPropertyChangeListeners )
475cdf0e10cSrcweir 		return;
476cdf0e10cSrcweir 
477cdf0e10cSrcweir 	sal_Int32 nCount = PropertyNames.getLength();
478cdf0e10cSrcweir 	if ( !nCount )
479cdf0e10cSrcweir 	{
480cdf0e10cSrcweir 		// Note: An empty sequence means a listener for "all" properties.
481cdf0e10cSrcweir 		m_pImpl->m_pPropertyChangeListeners->removeInterface(
482cdf0e10cSrcweir             rtl::OUString(), Listener );
483cdf0e10cSrcweir 	}
484cdf0e10cSrcweir 	else
485cdf0e10cSrcweir 	{
486cdf0e10cSrcweir 		const rtl::OUString* pSeq = PropertyNames.getConstArray();
487cdf0e10cSrcweir 
488cdf0e10cSrcweir 		for ( sal_Int32 n = 0; n < nCount; ++n )
489cdf0e10cSrcweir 		{
490cdf0e10cSrcweir 			const rtl::OUString& rName = pSeq[ n ];
491cdf0e10cSrcweir 			if ( rName.getLength() )
492cdf0e10cSrcweir 				m_pImpl->m_pPropertyChangeListeners->removeInterface(
493cdf0e10cSrcweir                     rName, Listener );
494cdf0e10cSrcweir 		}
495cdf0e10cSrcweir 	}
496cdf0e10cSrcweir }
497cdf0e10cSrcweir 
498cdf0e10cSrcweir //=========================================================================
499cdf0e10cSrcweir //
500cdf0e10cSrcweir // XCommandInfoChangeNotifier methods.
501cdf0e10cSrcweir //
502cdf0e10cSrcweir //=========================================================================
503cdf0e10cSrcweir 
504cdf0e10cSrcweir // virtual
addCommandInfoChangeListener(const uno::Reference<com::sun::star::ucb::XCommandInfoChangeListener> & Listener)505cdf0e10cSrcweir void SAL_CALL ContentImplHelper::addCommandInfoChangeListener(
506cdf0e10cSrcweir         const uno::Reference< com::sun::star::ucb::XCommandInfoChangeListener >& Listener )
507cdf0e10cSrcweir 	throw( uno::RuntimeException )
508cdf0e10cSrcweir {
509cdf0e10cSrcweir 	osl::MutexGuard aGuard( m_aMutex );
510cdf0e10cSrcweir 
511cdf0e10cSrcweir 	if ( !m_pImpl->m_pCommandChangeListeners )
512cdf0e10cSrcweir 		m_pImpl->m_pCommandChangeListeners
513cdf0e10cSrcweir 			= new cppu::OInterfaceContainerHelper( m_aMutex );
514cdf0e10cSrcweir 
515cdf0e10cSrcweir 	m_pImpl->m_pCommandChangeListeners->addInterface( Listener );
516cdf0e10cSrcweir }
517cdf0e10cSrcweir 
518cdf0e10cSrcweir //=========================================================================
519cdf0e10cSrcweir // virtual
removeCommandInfoChangeListener(const uno::Reference<com::sun::star::ucb::XCommandInfoChangeListener> & Listener)520cdf0e10cSrcweir void SAL_CALL ContentImplHelper::removeCommandInfoChangeListener(
521cdf0e10cSrcweir         const uno::Reference< com::sun::star::ucb::XCommandInfoChangeListener >& Listener )
522cdf0e10cSrcweir 	throw( uno::RuntimeException )
523cdf0e10cSrcweir {
524cdf0e10cSrcweir 	osl::MutexGuard aGuard( m_aMutex );
525cdf0e10cSrcweir 
526cdf0e10cSrcweir 	if ( m_pImpl->m_pCommandChangeListeners )
527cdf0e10cSrcweir 		m_pImpl->m_pCommandChangeListeners->removeInterface( Listener );
528cdf0e10cSrcweir }
529cdf0e10cSrcweir 
530cdf0e10cSrcweir //=========================================================================
531cdf0e10cSrcweir //
532cdf0e10cSrcweir // XPropertyContainer methods.
533cdf0e10cSrcweir //
534cdf0e10cSrcweir //=========================================================================
535cdf0e10cSrcweir 
536cdf0e10cSrcweir // virtual
addProperty(const rtl::OUString & Name,sal_Int16 Attributes,const uno::Any & DefaultValue)537cdf0e10cSrcweir void SAL_CALL ContentImplHelper::addProperty(
538cdf0e10cSrcweir         const rtl::OUString& Name,
539cdf0e10cSrcweir         sal_Int16 Attributes,
540cdf0e10cSrcweir         const uno::Any& DefaultValue )
541cdf0e10cSrcweir 	throw( beans::PropertyExistException,
542cdf0e10cSrcweir 		   beans::IllegalTypeException,
543cdf0e10cSrcweir 		   lang::IllegalArgumentException,
544cdf0e10cSrcweir 		   uno::RuntimeException )
545cdf0e10cSrcweir {
546cdf0e10cSrcweir 	osl::MutexGuard aGuard( m_aMutex );
547cdf0e10cSrcweir 
548cdf0e10cSrcweir 	//////////////////////////////////////////////////////////////////////
549cdf0e10cSrcweir 	// Make sure a property with the requested name does not already
550cdf0e10cSrcweir 	// exist in dynamic and static(!) properties.
551cdf0e10cSrcweir 	//////////////////////////////////////////////////////////////////////
552cdf0e10cSrcweir 
553cdf0e10cSrcweir 	// @@@ Need real command environment here, but where to get it from?
554cdf0e10cSrcweir 	//     XPropertyContainer interface should be replaced by
555cdf0e10cSrcweir 	//     XCommandProcessor commands!
556cdf0e10cSrcweir 	uno::Reference< com::sun::star::ucb::XCommandEnvironment > xEnv;
557cdf0e10cSrcweir 
558cdf0e10cSrcweir 	if ( getPropertySetInfo( xEnv )->hasPropertyByName( Name ) )
559cdf0e10cSrcweir 	{
560cdf0e10cSrcweir 		// Property does already exist.
561cdf0e10cSrcweir 		throw beans::PropertyExistException();
562cdf0e10cSrcweir 	}
563cdf0e10cSrcweir 
564cdf0e10cSrcweir 	//////////////////////////////////////////////////////////////////////
565cdf0e10cSrcweir 	// Add a new dynamic property.
566cdf0e10cSrcweir 	//////////////////////////////////////////////////////////////////////
567cdf0e10cSrcweir 
568cdf0e10cSrcweir 	// Open/create persistent property set.
569cdf0e10cSrcweir     uno::Reference< com::sun::star::ucb::XPersistentPropertySet > xSet(
570cdf0e10cSrcweir 									getAdditionalPropertySet( sal_True ) );
571cdf0e10cSrcweir 
572cdf0e10cSrcweir 	OSL_ENSURE( xSet.is(),
573cdf0e10cSrcweir                 "ContentImplHelper::addProperty - No property set!" );
574cdf0e10cSrcweir 
575cdf0e10cSrcweir 	if ( xSet.is() )
576cdf0e10cSrcweir 	{
577cdf0e10cSrcweir 		uno::Reference< beans::XPropertyContainer > xContainer(
578cdf0e10cSrcweir             xSet, uno::UNO_QUERY );
579cdf0e10cSrcweir 
580cdf0e10cSrcweir 		OSL_ENSURE(
581cdf0e10cSrcweir             xContainer.is(),
582cdf0e10cSrcweir             "ContentImplHelper::addProperty - No property container!" );
583cdf0e10cSrcweir 
584cdf0e10cSrcweir 		if ( xContainer.is() )
585cdf0e10cSrcweir 		{
586cdf0e10cSrcweir 			// Property is always removeable.
587cdf0e10cSrcweir 			Attributes |= beans::PropertyAttribute::REMOVEABLE;
588cdf0e10cSrcweir 
589cdf0e10cSrcweir 			try
590cdf0e10cSrcweir 			{
591cdf0e10cSrcweir 				xContainer->addProperty( Name, Attributes, DefaultValue );
592cdf0e10cSrcweir 			}
593cdf0e10cSrcweir 			catch ( beans::PropertyExistException const & )
594cdf0e10cSrcweir 			{
595cdf0e10cSrcweir 				OSL_ENSURE( sal_False,
596cdf0e10cSrcweir 							"ContentImplHelper::addProperty - Exists!" );
597cdf0e10cSrcweir 				throw;
598cdf0e10cSrcweir 			}
599cdf0e10cSrcweir 			catch ( beans::IllegalTypeException const & )
600cdf0e10cSrcweir 			{
601cdf0e10cSrcweir 				OSL_ENSURE( sal_False,
602cdf0e10cSrcweir 							"ContentImplHelper::addProperty - Wrong Type!" );
603cdf0e10cSrcweir 				throw;
604cdf0e10cSrcweir 			}
605cdf0e10cSrcweir 			catch ( lang::IllegalArgumentException const & )
606cdf0e10cSrcweir 			{
607cdf0e10cSrcweir 				OSL_ENSURE( sal_False,
608cdf0e10cSrcweir 							"ContentImplHelper::addProperty - Illegal Arg!" );
609cdf0e10cSrcweir 				throw;
610cdf0e10cSrcweir 			}
611cdf0e10cSrcweir 
612cdf0e10cSrcweir 			// Success!
613cdf0e10cSrcweir 
614cdf0e10cSrcweir 			if ( m_pImpl->m_xPropSetInfo.is() )
615cdf0e10cSrcweir 			{
616cdf0e10cSrcweir 				// Info cached in propertyset info is invalid now!
617cdf0e10cSrcweir 				m_pImpl->m_xPropSetInfo->reset();
618cdf0e10cSrcweir 			}
619cdf0e10cSrcweir 
620cdf0e10cSrcweir 			// Notify propertyset info change listeners.
621cdf0e10cSrcweir 			if ( m_pImpl->m_pPropSetChangeListeners &&
622cdf0e10cSrcweir 				 m_pImpl->m_pPropSetChangeListeners->getLength() )
623cdf0e10cSrcweir 			{
624cdf0e10cSrcweir 				beans::PropertySetInfoChangeEvent evt(
625cdf0e10cSrcweir 							static_cast< cppu::OWeakObject * >( this ),
626cdf0e10cSrcweir 							Name,
627cdf0e10cSrcweir 							-1, // No handle available
628cdf0e10cSrcweir 							beans::PropertySetInfoChange::PROPERTY_INSERTED );
629cdf0e10cSrcweir 				notifyPropertySetInfoChange( evt );
630cdf0e10cSrcweir 			}
631cdf0e10cSrcweir 		}
632cdf0e10cSrcweir 	}
633cdf0e10cSrcweir }
634cdf0e10cSrcweir 
635cdf0e10cSrcweir //=========================================================================
636cdf0e10cSrcweir // virtual
removeProperty(const rtl::OUString & Name)637cdf0e10cSrcweir void SAL_CALL ContentImplHelper::removeProperty( const rtl::OUString& Name )
638cdf0e10cSrcweir 	throw( beans::UnknownPropertyException,
639cdf0e10cSrcweir 		   beans::NotRemoveableException,
640cdf0e10cSrcweir 		   uno::RuntimeException )
641cdf0e10cSrcweir {
642cdf0e10cSrcweir 	osl::MutexGuard aGuard( m_aMutex );
643cdf0e10cSrcweir 
644cdf0e10cSrcweir 	try
645cdf0e10cSrcweir 	{
646cdf0e10cSrcweir 		// @@@ Need real command environment here, but where to get it from?
647cdf0e10cSrcweir 		//     XPropertyContainer interface should be replaced by
648cdf0e10cSrcweir 		//     XCommandProcessor commands!
649cdf0e10cSrcweir 		uno::Reference< com::sun::star::ucb::XCommandEnvironment > xEnv;
650cdf0e10cSrcweir 
651cdf0e10cSrcweir 		beans::Property aProp
652cdf0e10cSrcweir             = getPropertySetInfo( xEnv )->getPropertyByName( Name );
653cdf0e10cSrcweir 
654cdf0e10cSrcweir 		if ( !( aProp.Attributes & beans::PropertyAttribute::REMOVEABLE ) )
655cdf0e10cSrcweir 		{
656cdf0e10cSrcweir 			// Not removeable!
657cdf0e10cSrcweir 			throw beans::NotRemoveableException();
658cdf0e10cSrcweir 		}
659cdf0e10cSrcweir 	}
660cdf0e10cSrcweir 	catch ( beans::UnknownPropertyException const & )
661cdf0e10cSrcweir 	{
662cdf0e10cSrcweir 		OSL_ENSURE( sal_False, "ContentImplHelper::removeProperty - Unknown!" );
663cdf0e10cSrcweir 		throw;
664cdf0e10cSrcweir 	}
665cdf0e10cSrcweir 
666cdf0e10cSrcweir 	//////////////////////////////////////////////////////////////////////
667cdf0e10cSrcweir 	// Try to remove property from dynamic property set.
668cdf0e10cSrcweir 	//////////////////////////////////////////////////////////////////////
669cdf0e10cSrcweir 
670cdf0e10cSrcweir 	// Open persistent property set, if exists.
671cdf0e10cSrcweir     uno::Reference< com::sun::star::ucb::XPersistentPropertySet > xSet(
672cdf0e10cSrcweir         getAdditionalPropertySet( sal_False ) );
673cdf0e10cSrcweir 	if ( xSet.is() )
674cdf0e10cSrcweir 	{
675cdf0e10cSrcweir 		uno::Reference< beans::XPropertyContainer > xContainer(
676cdf0e10cSrcweir             xSet, uno::UNO_QUERY );
677cdf0e10cSrcweir 
678cdf0e10cSrcweir 		OSL_ENSURE(
679cdf0e10cSrcweir             xContainer.is(),
680cdf0e10cSrcweir             "ContentImplHelper::removeProperty - No property container!" );
681cdf0e10cSrcweir 
682cdf0e10cSrcweir 		if ( xContainer.is() )
683cdf0e10cSrcweir 		{
684cdf0e10cSrcweir 			try
685cdf0e10cSrcweir 			{
686cdf0e10cSrcweir 				xContainer->removeProperty( Name );
687cdf0e10cSrcweir 			}
688cdf0e10cSrcweir 			catch ( beans::UnknownPropertyException const & )
689cdf0e10cSrcweir 			{
690cdf0e10cSrcweir 				OSL_ENSURE( sal_False,
691cdf0e10cSrcweir 							"ContentImplHelper::removeProperty - Unknown!" );
692cdf0e10cSrcweir 				throw;
693cdf0e10cSrcweir 			}
694cdf0e10cSrcweir 			catch ( beans::NotRemoveableException const & )
695cdf0e10cSrcweir 			{
696cdf0e10cSrcweir 				OSL_ENSURE(
697cdf0e10cSrcweir                     sal_False,
698cdf0e10cSrcweir                     "ContentImplHelper::removeProperty - Unremoveable!" );
699cdf0e10cSrcweir 				throw;
700cdf0e10cSrcweir 			}
701cdf0e10cSrcweir 
702cdf0e10cSrcweir 			xContainer = 0;
703cdf0e10cSrcweir 
704cdf0e10cSrcweir 			// Success!
705cdf0e10cSrcweir 
706cdf0e10cSrcweir 			if ( xSet->getPropertySetInfo()->getProperties().getLength() == 0 )
707cdf0e10cSrcweir 			{
708cdf0e10cSrcweir 				// Remove empty propertyset from registry.
709cdf0e10cSrcweir     			uno::Reference< com::sun::star::ucb::XPropertySetRegistry >
710cdf0e10cSrcweir                     xReg = xSet->getRegistry();
711cdf0e10cSrcweir 				if ( xReg.is() )
712cdf0e10cSrcweir 				{
713cdf0e10cSrcweir 					rtl::OUString aKey( xSet->getKey() );
714cdf0e10cSrcweir 					xSet = 0;
715cdf0e10cSrcweir 					xReg->removePropertySet( aKey );
716cdf0e10cSrcweir 				}
717cdf0e10cSrcweir 			}
718cdf0e10cSrcweir 
719cdf0e10cSrcweir 			if ( m_pImpl->m_xPropSetInfo.is() )
720cdf0e10cSrcweir 			{
721cdf0e10cSrcweir 				// Info cached in propertyset info is invalid now!
722cdf0e10cSrcweir 				m_pImpl->m_xPropSetInfo->reset();
723cdf0e10cSrcweir 			}
724cdf0e10cSrcweir 
725cdf0e10cSrcweir 			// Notify propertyset info change listeners.
726cdf0e10cSrcweir 			if ( m_pImpl->m_pPropSetChangeListeners &&
727cdf0e10cSrcweir 				 m_pImpl->m_pPropSetChangeListeners->getLength() )
728cdf0e10cSrcweir 			{
729cdf0e10cSrcweir 				beans::PropertySetInfoChangeEvent evt(
730cdf0e10cSrcweir 							static_cast< cppu::OWeakObject * >( this ),
731cdf0e10cSrcweir 							Name,
732cdf0e10cSrcweir 							-1, // No handle available
733cdf0e10cSrcweir 							beans::PropertySetInfoChange::PROPERTY_REMOVED );
734cdf0e10cSrcweir 				notifyPropertySetInfoChange( evt );
735cdf0e10cSrcweir 			}
736cdf0e10cSrcweir 		}
737cdf0e10cSrcweir 	}
738cdf0e10cSrcweir }
739cdf0e10cSrcweir 
740cdf0e10cSrcweir //=========================================================================
741cdf0e10cSrcweir //
742cdf0e10cSrcweir // XPropertySetInfoChangeNotifier methods.
743cdf0e10cSrcweir //
744cdf0e10cSrcweir //=========================================================================
745cdf0e10cSrcweir 
746cdf0e10cSrcweir // virtual
addPropertySetInfoChangeListener(const uno::Reference<beans::XPropertySetInfoChangeListener> & Listener)747cdf0e10cSrcweir void SAL_CALL ContentImplHelper::addPropertySetInfoChangeListener(
748cdf0e10cSrcweir         const uno::Reference< beans::XPropertySetInfoChangeListener >& Listener )
749cdf0e10cSrcweir 	throw( uno::RuntimeException )
750cdf0e10cSrcweir {
751cdf0e10cSrcweir 	osl::MutexGuard aGuard( m_aMutex );
752cdf0e10cSrcweir 
753cdf0e10cSrcweir 	if ( !m_pImpl->m_pPropSetChangeListeners )
754cdf0e10cSrcweir 		m_pImpl->m_pPropSetChangeListeners
755cdf0e10cSrcweir 			= new cppu::OInterfaceContainerHelper( m_aMutex );
756cdf0e10cSrcweir 
757cdf0e10cSrcweir 	m_pImpl->m_pPropSetChangeListeners->addInterface( Listener );
758cdf0e10cSrcweir }
759cdf0e10cSrcweir 
760cdf0e10cSrcweir //=========================================================================
761cdf0e10cSrcweir // virtual
removePropertySetInfoChangeListener(const uno::Reference<beans::XPropertySetInfoChangeListener> & Listener)762cdf0e10cSrcweir void SAL_CALL ContentImplHelper::removePropertySetInfoChangeListener(
763cdf0e10cSrcweir         const uno::Reference< beans::XPropertySetInfoChangeListener >& Listener )
764cdf0e10cSrcweir 	throw( uno::RuntimeException )
765cdf0e10cSrcweir {
766cdf0e10cSrcweir 	osl::MutexGuard aGuard( m_aMutex );
767cdf0e10cSrcweir 
768cdf0e10cSrcweir 	if ( m_pImpl->m_pPropSetChangeListeners )
769cdf0e10cSrcweir 		m_pImpl->m_pPropSetChangeListeners->removeInterface( Listener );
770cdf0e10cSrcweir }
771cdf0e10cSrcweir 
772cdf0e10cSrcweir //=========================================================================
773cdf0e10cSrcweir //
774cdf0e10cSrcweir // XChild methods.
775cdf0e10cSrcweir //
776cdf0e10cSrcweir //=========================================================================
777cdf0e10cSrcweir 
778cdf0e10cSrcweir // virtual
getParent()779cdf0e10cSrcweir uno::Reference< uno::XInterface > SAL_CALL ContentImplHelper::getParent()
780cdf0e10cSrcweir 	throw( uno::RuntimeException )
781cdf0e10cSrcweir {
782cdf0e10cSrcweir     uno::Reference< uno::XInterface > xParent;
783cdf0e10cSrcweir 	rtl::OUString aURL = getParentURL();
784cdf0e10cSrcweir 
785cdf0e10cSrcweir 	if ( aURL.getLength() )
786cdf0e10cSrcweir 	{
787cdf0e10cSrcweir 		uno::Reference< com::sun::star::ucb::XContentIdentifier > xId(
788cdf0e10cSrcweir             new ContentIdentifier( m_xSMgr, aURL ) );
789cdf0e10cSrcweir         try
790cdf0e10cSrcweir         {
791cdf0e10cSrcweir             xParent.set( m_xProvider->queryContent( xId ) );
792cdf0e10cSrcweir         }
793cdf0e10cSrcweir         catch ( com::sun::star::ucb::IllegalIdentifierException const & )
794cdf0e10cSrcweir         {
795cdf0e10cSrcweir         }
796cdf0e10cSrcweir 	}
797cdf0e10cSrcweir 
798cdf0e10cSrcweir     return xParent;
799cdf0e10cSrcweir }
800cdf0e10cSrcweir 
801cdf0e10cSrcweir //=========================================================================
802cdf0e10cSrcweir // virtual
setParent(const uno::Reference<uno::XInterface> &)803cdf0e10cSrcweir void SAL_CALL ContentImplHelper::setParent(
804cdf0e10cSrcweir 									const uno::Reference< uno::XInterface >& )
805cdf0e10cSrcweir 	throw( lang::NoSupportException, uno::RuntimeException )
806cdf0e10cSrcweir {
807cdf0e10cSrcweir 	throw lang::NoSupportException();
808cdf0e10cSrcweir }
809cdf0e10cSrcweir 
810cdf0e10cSrcweir //=========================================================================
811cdf0e10cSrcweir //
812cdf0e10cSrcweir // Non-interface methods
813cdf0e10cSrcweir //
814cdf0e10cSrcweir //=========================================================================
815cdf0e10cSrcweir 
816cdf0e10cSrcweir uno::Reference< com::sun::star::ucb::XPersistentPropertySet >
getAdditionalPropertySet(sal_Bool bCreate)817cdf0e10cSrcweir ContentImplHelper::getAdditionalPropertySet( sal_Bool bCreate )
818cdf0e10cSrcweir {
819cdf0e10cSrcweir 	// Get propertyset from provider.
820cdf0e10cSrcweir 	return m_xProvider->getAdditionalPropertySet(
821cdf0e10cSrcweir 							m_xIdentifier->getContentIdentifier(), bCreate );
822cdf0e10cSrcweir }
823cdf0e10cSrcweir 
824cdf0e10cSrcweir //=========================================================================
renameAdditionalPropertySet(const rtl::OUString & rOldKey,const rtl::OUString & rNewKey,sal_Bool bRecursive)825cdf0e10cSrcweir sal_Bool ContentImplHelper::renameAdditionalPropertySet(
826cdf0e10cSrcweir     const rtl::OUString& rOldKey,
827cdf0e10cSrcweir     const rtl::OUString& rNewKey,
828cdf0e10cSrcweir     sal_Bool bRecursive )
829cdf0e10cSrcweir {
830cdf0e10cSrcweir 	return m_xProvider->renameAdditionalPropertySet(
831cdf0e10cSrcweir 											rOldKey, rNewKey, bRecursive );
832cdf0e10cSrcweir }
833cdf0e10cSrcweir 
834cdf0e10cSrcweir //=========================================================================
copyAdditionalPropertySet(const rtl::OUString & rSourceKey,const rtl::OUString & rTargetKey,sal_Bool bRecursive)835cdf0e10cSrcweir sal_Bool ContentImplHelper::copyAdditionalPropertySet(
836cdf0e10cSrcweir     const rtl::OUString& rSourceKey,
837cdf0e10cSrcweir     const rtl::OUString& rTargetKey,
838cdf0e10cSrcweir     sal_Bool bRecursive )
839cdf0e10cSrcweir {
840cdf0e10cSrcweir 	return m_xProvider->copyAdditionalPropertySet(
841cdf0e10cSrcweir 										rSourceKey, rTargetKey, bRecursive );
842cdf0e10cSrcweir }
843cdf0e10cSrcweir 
844cdf0e10cSrcweir //=========================================================================
removeAdditionalPropertySet(sal_Bool bRecursive)845cdf0e10cSrcweir sal_Bool ContentImplHelper::removeAdditionalPropertySet( sal_Bool bRecursive )
846cdf0e10cSrcweir {
847cdf0e10cSrcweir 	return m_xProvider->removeAdditionalPropertySet(
848cdf0e10cSrcweir 					m_xIdentifier->getContentIdentifier(), bRecursive );
849cdf0e10cSrcweir }
850cdf0e10cSrcweir 
851cdf0e10cSrcweir //=========================================================================
notifyPropertiesChange(const uno::Sequence<beans::PropertyChangeEvent> & evt) const852cdf0e10cSrcweir void ContentImplHelper::notifyPropertiesChange(
853cdf0e10cSrcweir     const uno::Sequence< beans::PropertyChangeEvent >& evt ) const
854cdf0e10cSrcweir {
855cdf0e10cSrcweir 	if ( !m_pImpl->m_pPropertyChangeListeners )
856cdf0e10cSrcweir 		return;
857cdf0e10cSrcweir 
858cdf0e10cSrcweir 	sal_Int32 nCount = evt.getLength();
859cdf0e10cSrcweir 	if ( nCount )
860cdf0e10cSrcweir 	{
861cdf0e10cSrcweir 		// First, notify listeners interested in changes of every property.
862cdf0e10cSrcweir 		cppu::OInterfaceContainerHelper* pAllPropsContainer
863cdf0e10cSrcweir 			= m_pImpl->m_pPropertyChangeListeners->getContainer(
864cdf0e10cSrcweir                 rtl::OUString() );
865cdf0e10cSrcweir 		if ( pAllPropsContainer )
866cdf0e10cSrcweir 		{
867cdf0e10cSrcweir 			cppu::OInterfaceIteratorHelper aIter( *pAllPropsContainer );
868cdf0e10cSrcweir 			while ( aIter.hasMoreElements() )
869cdf0e10cSrcweir 			{
870cdf0e10cSrcweir 				// Propagate event.
871cdf0e10cSrcweir 				uno::Reference< beans::XPropertiesChangeListener > xListener(
872cdf0e10cSrcweir                     aIter.next(), uno::UNO_QUERY );
873cdf0e10cSrcweir 				if ( xListener.is() )
874cdf0e10cSrcweir 					xListener->propertiesChange( evt );
875cdf0e10cSrcweir 			}
876cdf0e10cSrcweir 		}
877cdf0e10cSrcweir 
878cdf0e10cSrcweir 		PropertiesEventListenerMap aListeners;
879cdf0e10cSrcweir 
880cdf0e10cSrcweir 		const beans::PropertyChangeEvent* pEvents = evt.getConstArray();
881cdf0e10cSrcweir 
882cdf0e10cSrcweir 		for ( sal_Int32 n = 0; n < nCount; ++n )
883cdf0e10cSrcweir 		{
884cdf0e10cSrcweir 			const beans::PropertyChangeEvent& rEvent = pEvents[ n ];
885cdf0e10cSrcweir 			const rtl::OUString& rName = rEvent.PropertyName;
886cdf0e10cSrcweir 
887cdf0e10cSrcweir 			cppu::OInterfaceContainerHelper* pPropsContainer
888cdf0e10cSrcweir 				= m_pImpl->m_pPropertyChangeListeners->getContainer( rName );
889cdf0e10cSrcweir 			if ( pPropsContainer )
890cdf0e10cSrcweir 			{
891cdf0e10cSrcweir 				cppu::OInterfaceIteratorHelper aIter( *pPropsContainer );
892cdf0e10cSrcweir 				while ( aIter.hasMoreElements() )
893cdf0e10cSrcweir 				{
894cdf0e10cSrcweir 					PropertyEventSequence* p = NULL;
895cdf0e10cSrcweir 
896cdf0e10cSrcweir 					beans::XPropertiesChangeListener* pListener =
897cdf0e10cSrcweir 						static_cast< beans::XPropertiesChangeListener * >(
898cdf0e10cSrcweir 															aIter.next() );
899cdf0e10cSrcweir 					PropertiesEventListenerMap::iterator it =
900cdf0e10cSrcweir 							aListeners.find( pListener );
901cdf0e10cSrcweir 					if ( it == aListeners.end() )
902cdf0e10cSrcweir 					{
903cdf0e10cSrcweir 						// Not in map - create and insert new entry.
904cdf0e10cSrcweir 						p = new PropertyEventSequence( nCount );
905cdf0e10cSrcweir 						aListeners[ pListener ] = p;
906cdf0e10cSrcweir 					}
907cdf0e10cSrcweir 					else
908cdf0e10cSrcweir 						p = (*it).second;
909cdf0e10cSrcweir 
910cdf0e10cSrcweir 					if ( p )
911cdf0e10cSrcweir 						p->append( rEvent );
912cdf0e10cSrcweir 				}
913cdf0e10cSrcweir 			}
914cdf0e10cSrcweir 		}
915cdf0e10cSrcweir 
916cdf0e10cSrcweir 		// Notify listeners.
917cdf0e10cSrcweir 		PropertiesEventListenerMap::iterator it = aListeners.begin();
918cdf0e10cSrcweir 		while ( !aListeners.empty() )
919cdf0e10cSrcweir 		{
920cdf0e10cSrcweir 			beans::XPropertiesChangeListener* pListener =
921cdf0e10cSrcweir                 static_cast< beans::XPropertiesChangeListener * >( (*it).first );
922cdf0e10cSrcweir 			PropertyEventSequence* pSeq = (*it).second;
923cdf0e10cSrcweir 
924cdf0e10cSrcweir 			// Remove current element.
925cdf0e10cSrcweir 			aListeners.erase( it );
926cdf0e10cSrcweir 
927cdf0e10cSrcweir 			// Propagate event.
928cdf0e10cSrcweir 			pListener->propertiesChange( pSeq->getEvents() );
929cdf0e10cSrcweir 
930cdf0e10cSrcweir 			delete pSeq;
931cdf0e10cSrcweir 
932cdf0e10cSrcweir 			it = aListeners.begin();
933cdf0e10cSrcweir 		}
934cdf0e10cSrcweir 	}
935cdf0e10cSrcweir }
936cdf0e10cSrcweir 
937cdf0e10cSrcweir //=========================================================================
notifyPropertySetInfoChange(const beans::PropertySetInfoChangeEvent & evt) const938cdf0e10cSrcweir void ContentImplHelper::notifyPropertySetInfoChange(
939cdf0e10cSrcweir     const beans::PropertySetInfoChangeEvent& evt ) const
940cdf0e10cSrcweir {
941cdf0e10cSrcweir 	if ( !m_pImpl->m_pPropSetChangeListeners )
942cdf0e10cSrcweir 		return;
943cdf0e10cSrcweir 
944cdf0e10cSrcweir 	// Notify event listeners.
945cdf0e10cSrcweir 	cppu::OInterfaceIteratorHelper aIter( *m_pImpl->m_pPropSetChangeListeners );
946cdf0e10cSrcweir 	while ( aIter.hasMoreElements() )
947cdf0e10cSrcweir 	{
948cdf0e10cSrcweir 		// Propagate event.
949cdf0e10cSrcweir 		uno::Reference< beans::XPropertySetInfoChangeListener >
950cdf0e10cSrcweir             xListener( aIter.next(), uno::UNO_QUERY );
951cdf0e10cSrcweir 		if ( xListener.is() )
952cdf0e10cSrcweir 			xListener->propertySetInfoChange( evt );
953cdf0e10cSrcweir 	}
954cdf0e10cSrcweir }
955cdf0e10cSrcweir 
956cdf0e10cSrcweir //=========================================================================
notifyCommandInfoChange(const com::sun::star::ucb::CommandInfoChangeEvent & evt) const957cdf0e10cSrcweir void ContentImplHelper::notifyCommandInfoChange(
958cdf0e10cSrcweir     const com::sun::star::ucb::CommandInfoChangeEvent& evt ) const
959cdf0e10cSrcweir {
960cdf0e10cSrcweir 	if ( !m_pImpl->m_pCommandChangeListeners )
961cdf0e10cSrcweir 		return;
962cdf0e10cSrcweir 
963cdf0e10cSrcweir 	// Notify event listeners.
964cdf0e10cSrcweir 	cppu::OInterfaceIteratorHelper aIter(
965cdf0e10cSrcweir         *m_pImpl->m_pCommandChangeListeners );
966cdf0e10cSrcweir 	while ( aIter.hasMoreElements() )
967cdf0e10cSrcweir 	{
968cdf0e10cSrcweir 		// Propagate event.
969cdf0e10cSrcweir 		uno::Reference< com::sun::star::ucb::XCommandInfoChangeListener >
970cdf0e10cSrcweir             xListener( aIter.next(), uno::UNO_QUERY );
971cdf0e10cSrcweir 		if ( xListener.is() )
972cdf0e10cSrcweir 			xListener->commandInfoChange( evt );
973cdf0e10cSrcweir 	}
974cdf0e10cSrcweir }
975cdf0e10cSrcweir 
976cdf0e10cSrcweir //=========================================================================
notifyContentEvent(const com::sun::star::ucb::ContentEvent & evt) const977cdf0e10cSrcweir void ContentImplHelper::notifyContentEvent(
978cdf0e10cSrcweir     const com::sun::star::ucb::ContentEvent& evt ) const
979cdf0e10cSrcweir {
980cdf0e10cSrcweir 	if ( !m_pImpl->m_pContentEventListeners )
981cdf0e10cSrcweir 		return;
982cdf0e10cSrcweir 
983cdf0e10cSrcweir 	// Notify event listeners.
984cdf0e10cSrcweir 	cppu::OInterfaceIteratorHelper aIter( *m_pImpl->m_pContentEventListeners );
985cdf0e10cSrcweir 	while ( aIter.hasMoreElements() )
986cdf0e10cSrcweir 	{
987cdf0e10cSrcweir 		// Propagate event.
988cdf0e10cSrcweir 		uno::Reference<
989cdf0e10cSrcweir             com::sun::star::ucb::XContentEventListener > xListener(
990cdf0e10cSrcweir                 aIter.next(), uno::UNO_QUERY );
991cdf0e10cSrcweir 		if ( xListener.is() )
992cdf0e10cSrcweir 			xListener->contentEvent( evt );
993cdf0e10cSrcweir 	}
994cdf0e10cSrcweir }
995cdf0e10cSrcweir 
996cdf0e10cSrcweir //=========================================================================
inserted()997cdf0e10cSrcweir void ContentImplHelper::inserted()
998cdf0e10cSrcweir {
999cdf0e10cSrcweir 	// Content is not yet registered at provider.
1000cdf0e10cSrcweir 	m_xProvider->registerNewContent( this );
1001cdf0e10cSrcweir 
1002cdf0e10cSrcweir 	// If the parent content is currently not instanciated, there can be
1003cdf0e10cSrcweir 	// no listeners interested in changes ;-)
1004cdf0e10cSrcweir 
1005cdf0e10cSrcweir 	rtl::Reference< ContentImplHelper > xParent
1006cdf0e10cSrcweir 				= m_xProvider->queryExistingContent( getParentURL() );
1007cdf0e10cSrcweir 
1008cdf0e10cSrcweir 	if ( xParent.is() )
1009cdf0e10cSrcweir 	{
1010cdf0e10cSrcweir 		com::sun::star::ucb::ContentEvent aEvt(
1011cdf0e10cSrcweir             static_cast< cppu::OWeakObject * >( xParent.get() ), // Source
1012cdf0e10cSrcweir             com::sun::star::ucb::ContentAction::INSERTED,		 // Action
1013cdf0e10cSrcweir             this,									             // Content
1014cdf0e10cSrcweir             xParent->getIdentifier() );				             // Id
1015cdf0e10cSrcweir 		xParent->notifyContentEvent( aEvt );
1016cdf0e10cSrcweir 	}
1017cdf0e10cSrcweir }
1018cdf0e10cSrcweir 
1019cdf0e10cSrcweir //=========================================================================
deleted()1020cdf0e10cSrcweir void ContentImplHelper::deleted()
1021cdf0e10cSrcweir {
1022cdf0e10cSrcweir 	uno::Reference< com::sun::star::ucb::XContent > xThis = this;
1023cdf0e10cSrcweir 
1024cdf0e10cSrcweir 	rtl::Reference< ContentImplHelper > xParent
1025cdf0e10cSrcweir 					= m_xProvider->queryExistingContent( getParentURL() );
1026cdf0e10cSrcweir 
1027cdf0e10cSrcweir 	if ( xParent.is() )
1028cdf0e10cSrcweir 	{
1029cdf0e10cSrcweir 		// Let parent notify "REMOVED" event.
1030cdf0e10cSrcweir 		com::sun::star::ucb::ContentEvent aEvt(
1031cdf0e10cSrcweir             static_cast< cppu::OWeakObject * >( xParent.get() ),
1032cdf0e10cSrcweir             com::sun::star::ucb::ContentAction::REMOVED,
1033cdf0e10cSrcweir             this,
1034cdf0e10cSrcweir             xParent->getIdentifier()	);
1035cdf0e10cSrcweir 		xParent->notifyContentEvent( aEvt );
1036cdf0e10cSrcweir 	}
1037cdf0e10cSrcweir 
1038cdf0e10cSrcweir 	// Notify "DELETED" event.
1039cdf0e10cSrcweir 	com::sun::star::ucb::ContentEvent aEvt1(
1040cdf0e10cSrcweir         static_cast< cppu::OWeakObject * >( this ),
1041cdf0e10cSrcweir         com::sun::star::ucb::ContentAction::DELETED,
1042cdf0e10cSrcweir         this,
1043cdf0e10cSrcweir         getIdentifier() );
1044cdf0e10cSrcweir 	notifyContentEvent( aEvt1 );
1045cdf0e10cSrcweir 
1046cdf0e10cSrcweir 	m_xProvider->removeContent( this );
1047cdf0e10cSrcweir }
1048cdf0e10cSrcweir 
1049cdf0e10cSrcweir //=========================================================================
exchange(const uno::Reference<com::sun::star::ucb::XContentIdentifier> & rNewId)1050cdf0e10cSrcweir sal_Bool ContentImplHelper::exchange(
1051cdf0e10cSrcweir     const uno::Reference< com::sun::star::ucb::XContentIdentifier >& rNewId )
1052cdf0e10cSrcweir {
1053cdf0e10cSrcweir 	uno::Reference< com::sun::star::ucb::XContent > xThis = this;
1054cdf0e10cSrcweir 
1055cdf0e10cSrcweir 	osl::ClearableMutexGuard aGuard( m_aMutex );
1056cdf0e10cSrcweir 
1057cdf0e10cSrcweir 	rtl::Reference< ContentImplHelper > xContent
1058cdf0e10cSrcweir         = m_xProvider->queryExistingContent( rNewId );
1059cdf0e10cSrcweir 	if ( xContent.is() )
1060cdf0e10cSrcweir 	{
1061cdf0e10cSrcweir 		// @@@
1062cdf0e10cSrcweir 		// Big trouble. Another object with the new identity exists.
1063cdf0e10cSrcweir 		// How shall I mutate to / merge with the other object?
1064cdf0e10cSrcweir 		return sal_False;
1065cdf0e10cSrcweir 	}
1066cdf0e10cSrcweir 
1067cdf0e10cSrcweir 	uno::Reference< com::sun::star::ucb::XContentIdentifier > xOldId
1068cdf0e10cSrcweir         = getIdentifier();
1069cdf0e10cSrcweir 
1070cdf0e10cSrcweir 	// Re-insert at provider.
1071cdf0e10cSrcweir 	m_xProvider->removeContent( this );
1072cdf0e10cSrcweir 	m_xIdentifier = rNewId;
1073cdf0e10cSrcweir 	m_xProvider->registerNewContent( this );
1074cdf0e10cSrcweir 
1075cdf0e10cSrcweir 	aGuard.clear();
1076cdf0e10cSrcweir 
1077cdf0e10cSrcweir 	// Notify "EXCHANGED" event.
1078cdf0e10cSrcweir 	com::sun::star::ucb::ContentEvent aEvt(
1079cdf0e10cSrcweir         static_cast< cppu::OWeakObject * >( this ),
1080cdf0e10cSrcweir         com::sun::star::ucb::ContentAction::EXCHANGED,
1081cdf0e10cSrcweir         this,
1082cdf0e10cSrcweir         xOldId );
1083cdf0e10cSrcweir 	notifyContentEvent( aEvt );
1084cdf0e10cSrcweir 	return sal_True;
1085cdf0e10cSrcweir }
1086cdf0e10cSrcweir 
1087cdf0e10cSrcweir //=========================================================================
1088cdf0e10cSrcweir uno::Reference< com::sun::star::ucb::XCommandInfo >
getCommandInfo(const uno::Reference<com::sun::star::ucb::XCommandEnvironment> & xEnv,sal_Bool bCache)1089cdf0e10cSrcweir ContentImplHelper::getCommandInfo(
1090cdf0e10cSrcweir     const uno::Reference< com::sun::star::ucb::XCommandEnvironment > & xEnv,
1091cdf0e10cSrcweir     sal_Bool bCache )
1092cdf0e10cSrcweir {
1093cdf0e10cSrcweir 	osl::MutexGuard aGuard( m_aMutex );
1094cdf0e10cSrcweir 
1095cdf0e10cSrcweir 	if ( !m_pImpl->m_xCommandsInfo.is() )
1096cdf0e10cSrcweir 		m_pImpl->m_xCommandsInfo
1097cdf0e10cSrcweir 			= new CommandProcessorInfo( m_xSMgr, xEnv, this );
1098cdf0e10cSrcweir 	else if ( !bCache )
1099cdf0e10cSrcweir 		m_pImpl->m_xCommandsInfo->reset();
1100cdf0e10cSrcweir 
1101cdf0e10cSrcweir 	return uno::Reference< com::sun::star::ucb::XCommandInfo >(
1102cdf0e10cSrcweir         m_pImpl->m_xCommandsInfo.get() );
1103cdf0e10cSrcweir }
1104cdf0e10cSrcweir 
1105cdf0e10cSrcweir //=========================================================================
1106cdf0e10cSrcweir uno::Reference< beans::XPropertySetInfo >
getPropertySetInfo(const uno::Reference<com::sun::star::ucb::XCommandEnvironment> & xEnv,sal_Bool bCache)1107cdf0e10cSrcweir ContentImplHelper::getPropertySetInfo(
1108cdf0e10cSrcweir     const uno::Reference< com::sun::star::ucb::XCommandEnvironment > & xEnv,
1109cdf0e10cSrcweir     sal_Bool bCache )
1110cdf0e10cSrcweir {
1111cdf0e10cSrcweir 	osl::MutexGuard aGuard( m_aMutex );
1112cdf0e10cSrcweir 
1113cdf0e10cSrcweir 	if ( !m_pImpl->m_xPropSetInfo.is() )
1114cdf0e10cSrcweir 		m_pImpl->m_xPropSetInfo
1115cdf0e10cSrcweir 			= new PropertySetInfo( m_xSMgr, xEnv, this );
1116cdf0e10cSrcweir 	else if ( !bCache )
1117cdf0e10cSrcweir 		m_pImpl->m_xPropSetInfo->reset();
1118cdf0e10cSrcweir 
1119cdf0e10cSrcweir 	return uno::Reference< beans::XPropertySetInfo >(
1120cdf0e10cSrcweir 									m_pImpl->m_xPropSetInfo.get() );
1121cdf0e10cSrcweir }
1122cdf0e10cSrcweir 
1123cdf0e10cSrcweir } // namespace ucbhelper
1124