1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <sal/config.h>
22 #include <com/sun/star/lang/NoSupportException.hpp>
23 #include <com/sun/star/ucb/ContentAction.hpp>
24 #include <com/sun/star/ucb/IllegalIdentifierException.hpp>
25 #include <com/sun/star/ucb/XPersistentPropertySet.hpp>
26 #include <com/sun/star/beans/IllegalTypeException.hpp>
27 #include <com/sun/star/beans/NotRemoveableException.hpp>
28 #include <com/sun/star/beans/PropertyAttribute.hpp>
29 #include <com/sun/star/beans/PropertyExistException.hpp>
30 #include <com/sun/star/beans/PropertySetInfoChange.hpp>
31 #include <cppuhelper/interfacecontainer.hxx>
32 #include <cppuhelper/supportsservice.hxx>
33 #include <cppuhelper/queryinterface.hxx>
34 #include <ucbhelper/contenthelper.hxx>
35 #include <ucbhelper/contentidentifier.hxx>
36 #include <ucbhelper/contentinfo.hxx>
37 #include <ucbhelper/providerhelper.hxx>
38 #include <ucbhelper/macros.hxx>
40 #include <osl/diagnose.h>
41 #include <osl/mutex.hxx>
42 #include <rtl/ref.hxx>
44 #include <unordered_map>
46 using namespace com::sun::star
;
48 namespace ucbhelper_impl
51 class PropertyEventSequence
53 uno::Sequence
< beans::PropertyChangeEvent
> m_aSeq
;
57 explicit PropertyEventSequence( sal_uInt32 nSize
)
58 : m_aSeq( nSize
), m_nPos( 0 ) {};
60 void append( const beans::PropertyChangeEvent
& rEvt
)
61 { m_aSeq
.getArray()[ m_nPos
] = rEvt
; ++m_nPos
; }
63 const uno::Sequence
< beans::PropertyChangeEvent
>& getEvents()
64 { m_aSeq
.realloc( m_nPos
); return m_aSeq
; }
67 typedef void* XPropertiesChangeListenerPtr
; // -> Compiler problems!
71 bool operator()( const XPropertiesChangeListenerPtr
& rp1
,
72 const XPropertiesChangeListenerPtr
& rp2
) const
74 return ( rp1
== rp2
);
80 size_t operator()( const XPropertiesChangeListenerPtr
& rp
) const
82 return reinterpret_cast<size_t>(rp
);
86 typedef std::unordered_map
88 XPropertiesChangeListenerPtr
,
89 PropertyEventSequence
,
93 PropertiesEventListenerMap
;
95 typedef cppu::OMultiTypeInterfaceContainerHelperVar
<OUString
>
96 PropertyChangeListeners
;
98 struct ContentImplHelper_Impl
100 rtl::Reference
< ::ucbhelper::PropertySetInfo
> m_xPropSetInfo
;
101 rtl::Reference
< ::ucbhelper::CommandProcessorInfo
> m_xCommandsInfo
;
102 std::unique_ptr
<cppu::OInterfaceContainerHelper
> m_pDisposeEventListeners
;
103 std::unique_ptr
<cppu::OInterfaceContainerHelper
> m_pContentEventListeners
;
104 std::unique_ptr
<cppu::OInterfaceContainerHelper
> m_pPropSetChangeListeners
;
105 std::unique_ptr
<cppu::OInterfaceContainerHelper
> m_pCommandChangeListeners
;
106 std::unique_ptr
<PropertyChangeListeners
> m_pPropertyChangeListeners
;
109 } // namespace ucbhelper_impl
111 using namespace ucbhelper_impl
;
113 namespace ucbhelper
{
115 ContentImplHelper::ContentImplHelper(
116 const uno::Reference
< uno::XComponentContext
>& rxContext
,
117 const rtl::Reference
< ContentProviderImplHelper
>& rxProvider
,
118 const uno::Reference
<
119 css::ucb::XContentIdentifier
>& Identifier
)
120 : m_pImpl( new ContentImplHelper_Impl
),
121 m_xContext( rxContext
),
122 m_xIdentifier( Identifier
),
123 m_xProvider( rxProvider
),
129 ContentImplHelper::~ContentImplHelper()
133 void SAL_CALL
ContentImplHelper::acquire()
136 cppu::OWeakObject::acquire();
139 void SAL_CALL
ContentImplHelper::release()
142 // #144882# - Call to OWeakObject::release may destroy m_xProvider.
144 rtl::Reference
< ContentProviderImplHelper
> xKeepProviderAlive(
147 osl::MutexGuard
aGuard( m_xProvider
->m_aMutex
);
148 OWeakObject::release();
151 uno::Any SAL_CALL
ContentImplHelper::queryInterface( const uno::Type
& rType
)
153 css::uno::Any aRet
= cppu::queryInterface( rType
,
154 static_cast< lang::XTypeProvider
* >(this),
155 static_cast< lang::XServiceInfo
* >(this),
156 static_cast< lang::XComponent
* >(this),
157 static_cast< css::ucb::XContent
* >(this),
158 static_cast< css::ucb::XCommandProcessor
* >(this),
159 static_cast< beans::XPropertiesChangeNotifier
* >(this),
160 static_cast< css::ucb::XCommandInfoChangeNotifier
* >(this),
161 static_cast< beans::XPropertyContainer
* >(this),
162 static_cast< beans::XPropertySetInfoChangeNotifier
* >(this),
163 static_cast< container::XChild
* >(this));
164 return aRet
.hasValue() ? aRet
: cppu::OWeakObject::queryInterface( rType
);
167 XTYPEPROVIDER_IMPL_10( ContentImplHelper
,
172 css::ucb::XCommandProcessor
,
173 beans::XPropertiesChangeNotifier
,
174 css::ucb::XCommandInfoChangeNotifier
,
175 beans::XPropertyContainer
,
176 beans::XPropertySetInfoChangeNotifier
,
180 sal_Bool SAL_CALL
ContentImplHelper::supportsService(
181 const OUString
& ServiceName
)
183 return cppu::supportsService(this, ServiceName
);
187 void SAL_CALL
ContentImplHelper::dispose()
189 osl::MutexGuard
aGuard( m_aMutex
);
191 if ( m_pImpl
->m_pDisposeEventListeners
&&
192 m_pImpl
->m_pDisposeEventListeners
->getLength() )
194 lang::EventObject aEvt
;
195 aEvt
.Source
= static_cast< lang::XComponent
* >( this );
196 m_pImpl
->m_pDisposeEventListeners
->disposeAndClear( aEvt
);
199 if ( m_pImpl
->m_pContentEventListeners
&&
200 m_pImpl
->m_pContentEventListeners
->getLength() )
202 lang::EventObject aEvt
;
203 aEvt
.Source
= static_cast< css::ucb::XContent
* >( this );
204 m_pImpl
->m_pContentEventListeners
->disposeAndClear( aEvt
);
207 if ( m_pImpl
->m_pPropSetChangeListeners
&&
208 m_pImpl
->m_pPropSetChangeListeners
->getLength() )
210 lang::EventObject aEvt
;
212 = static_cast< beans::XPropertySetInfoChangeNotifier
* >( this );
213 m_pImpl
->m_pPropSetChangeListeners
->disposeAndClear( aEvt
);
216 if ( m_pImpl
->m_pCommandChangeListeners
&&
217 m_pImpl
->m_pCommandChangeListeners
->getLength() )
219 lang::EventObject aEvt
;
220 aEvt
.Source
= static_cast< css::ucb::XCommandInfoChangeNotifier
* >( this );
221 m_pImpl
->m_pCommandChangeListeners
->disposeAndClear( aEvt
);
224 if ( m_pImpl
->m_pPropertyChangeListeners
)
226 lang::EventObject aEvt
;
228 = static_cast< beans::XPropertiesChangeNotifier
* >( this );
229 m_pImpl
->m_pPropertyChangeListeners
->disposeAndClear( aEvt
);
234 void SAL_CALL
ContentImplHelper::addEventListener(
235 const uno::Reference
< lang::XEventListener
>& Listener
)
237 osl::MutexGuard
aGuard( m_aMutex
);
239 if ( !m_pImpl
->m_pDisposeEventListeners
)
240 m_pImpl
->m_pDisposeEventListeners
.reset(
241 new cppu::OInterfaceContainerHelper( m_aMutex
));
243 m_pImpl
->m_pDisposeEventListeners
->addInterface( Listener
);
247 void SAL_CALL
ContentImplHelper::removeEventListener(
248 const uno::Reference
< lang::XEventListener
>& Listener
)
250 osl::MutexGuard
aGuard( m_aMutex
);
252 if ( m_pImpl
->m_pDisposeEventListeners
)
253 m_pImpl
->m_pDisposeEventListeners
->removeInterface( Listener
);
257 uno::Reference
< css::ucb::XContentIdentifier
> SAL_CALL
258 ContentImplHelper::getIdentifier()
260 return m_xIdentifier
;
264 void SAL_CALL
ContentImplHelper::addContentEventListener(
265 const uno::Reference
< css::ucb::XContentEventListener
>& Listener
)
267 osl::MutexGuard
aGuard( m_aMutex
);
269 if ( !m_pImpl
->m_pContentEventListeners
)
270 m_pImpl
->m_pContentEventListeners
.reset(
271 new cppu::OInterfaceContainerHelper( m_aMutex
));
273 m_pImpl
->m_pContentEventListeners
->addInterface( Listener
);
277 void SAL_CALL
ContentImplHelper::removeContentEventListener(
278 const uno::Reference
< css::ucb::XContentEventListener
>& Listener
)
280 osl::MutexGuard
aGuard( m_aMutex
);
282 if ( m_pImpl
->m_pContentEventListeners
)
283 m_pImpl
->m_pContentEventListeners
->removeInterface( Listener
);
287 sal_Int32 SAL_CALL
ContentImplHelper::createCommandIdentifier()
289 osl::MutexGuard
aGuard( m_aMutex
);
291 // Just increase counter on every call to generate an identifier.
292 return ++m_nCommandId
;
296 void SAL_CALL
ContentImplHelper::addPropertiesChangeListener(
297 const uno::Sequence
< OUString
>& PropertyNames
,
298 const uno::Reference
< beans::XPropertiesChangeListener
>& Listener
)
300 osl::MutexGuard
aGuard( m_aMutex
);
302 if ( !m_pImpl
->m_pPropertyChangeListeners
)
303 m_pImpl
->m_pPropertyChangeListeners
.reset(
304 new PropertyChangeListeners( m_aMutex
));
306 if ( !PropertyNames
.hasElements() )
308 // Note: An empty sequence means a listener for "all" properties.
309 m_pImpl
->m_pPropertyChangeListeners
->addInterface(
310 OUString(), Listener
);
314 for ( const OUString
& rName
: PropertyNames
)
316 if ( !rName
.isEmpty() )
317 m_pImpl
->m_pPropertyChangeListeners
->addInterface(
324 void SAL_CALL
ContentImplHelper::removePropertiesChangeListener(
325 const uno::Sequence
< OUString
>& PropertyNames
,
326 const uno::Reference
< beans::XPropertiesChangeListener
>& Listener
)
328 osl::MutexGuard
aGuard( m_aMutex
);
330 if ( !m_pImpl
->m_pPropertyChangeListeners
)
333 if ( !PropertyNames
.hasElements() )
335 // Note: An empty sequence means a listener for "all" properties.
336 m_pImpl
->m_pPropertyChangeListeners
->removeInterface(
337 OUString(), Listener
);
341 for ( const OUString
& rName
: PropertyNames
)
343 if ( !rName
.isEmpty() )
344 m_pImpl
->m_pPropertyChangeListeners
->removeInterface(
351 void SAL_CALL
ContentImplHelper::addCommandInfoChangeListener(
352 const uno::Reference
< css::ucb::XCommandInfoChangeListener
>& Listener
)
354 osl::MutexGuard
aGuard( m_aMutex
);
356 if ( !m_pImpl
->m_pCommandChangeListeners
)
357 m_pImpl
->m_pCommandChangeListeners
.reset(
358 new cppu::OInterfaceContainerHelper( m_aMutex
));
360 m_pImpl
->m_pCommandChangeListeners
->addInterface( Listener
);
364 void SAL_CALL
ContentImplHelper::removeCommandInfoChangeListener(
365 const uno::Reference
< css::ucb::XCommandInfoChangeListener
>& Listener
)
367 osl::MutexGuard
aGuard( m_aMutex
);
369 if ( m_pImpl
->m_pCommandChangeListeners
)
370 m_pImpl
->m_pCommandChangeListeners
->removeInterface( Listener
);
374 void SAL_CALL
ContentImplHelper::addProperty(
375 const OUString
& Name
,
376 sal_Int16 Attributes
,
377 const uno::Any
& DefaultValue
)
379 osl::MutexGuard
aGuard( m_aMutex
);
381 // Make sure a property with the requested name does not already
382 // exist in dynamic and static(!) properties.
384 // @@@ Need real command environment here, but where to get it from?
385 // XPropertyContainer interface should be replaced by
386 // XCommandProcessor commands!
387 uno::Reference
< css::ucb::XCommandEnvironment
> xEnv
;
389 if ( getPropertySetInfo( xEnv
)->hasPropertyByName( Name
) )
391 // Property does already exist.
392 throw beans::PropertyExistException();
395 // Add a new dynamic property.
396 // Open/create persistent property set.
397 uno::Reference
< css::ucb::XPersistentPropertySet
> xSet(
398 getAdditionalPropertySet( true ) );
400 OSL_ENSURE( xSet
.is(),
401 "ContentImplHelper::addProperty - No property set!" );
405 uno::Reference
< beans::XPropertyContainer
> xContainer(
406 xSet
, uno::UNO_QUERY
);
410 "ContentImplHelper::addProperty - No property container!" );
412 if ( xContainer
.is() )
414 // Property is always removable.
415 Attributes
|= beans::PropertyAttribute::REMOVABLE
;
419 xContainer
->addProperty( Name
, Attributes
, DefaultValue
);
421 catch ( beans::PropertyExistException
const & )
423 OSL_FAIL( "ContentImplHelper::addProperty - Exists!" );
426 catch ( beans::IllegalTypeException
const & )
428 OSL_FAIL( "ContentImplHelper::addProperty - Wrong Type!" );
431 catch ( lang::IllegalArgumentException
const & )
433 OSL_FAIL( "ContentImplHelper::addProperty - Illegal Arg!" );
439 if ( m_pImpl
->m_xPropSetInfo
.is() )
441 // Info cached in propertyset info is invalid now!
442 m_pImpl
->m_xPropSetInfo
->reset();
445 // Notify propertyset info change listeners.
446 if ( m_pImpl
->m_pPropSetChangeListeners
&&
447 m_pImpl
->m_pPropSetChangeListeners
->getLength() )
449 beans::PropertySetInfoChangeEvent
evt(
450 static_cast< cppu::OWeakObject
* >( this ),
452 -1, // No handle available
453 beans::PropertySetInfoChange::PROPERTY_INSERTED
);
454 notifyPropertySetInfoChange( evt
);
461 void SAL_CALL
ContentImplHelper::removeProperty( const OUString
& Name
)
463 osl::MutexGuard
aGuard( m_aMutex
);
467 // @@@ Need real command environment here, but where to get it from?
468 // XPropertyContainer interface should be replaced by
469 // XCommandProcessor commands!
470 uno::Reference
< css::ucb::XCommandEnvironment
> xEnv
;
472 beans::Property aProp
473 = getPropertySetInfo( xEnv
)->getPropertyByName( Name
);
475 if ( !( aProp
.Attributes
& beans::PropertyAttribute::REMOVABLE
) )
478 throw beans::NotRemoveableException();
481 catch ( beans::UnknownPropertyException
const & )
483 OSL_FAIL( "ContentImplHelper::removeProperty - Unknown!" );
487 // Try to remove property from dynamic property set.
488 // Open persistent property set, if exists.
489 uno::Reference
< css::ucb::XPersistentPropertySet
> xSet(
490 getAdditionalPropertySet( false ) );
493 uno::Reference
< beans::XPropertyContainer
> xContainer(
494 xSet
, uno::UNO_QUERY
);
498 "ContentImplHelper::removeProperty - No property container!" );
500 if ( xContainer
.is() )
504 xContainer
->removeProperty( Name
);
506 catch ( beans::UnknownPropertyException
const & )
508 OSL_FAIL( "ContentImplHelper::removeProperty - Unknown!" );
511 catch ( beans::NotRemoveableException
const & )
514 "ContentImplHelper::removeProperty - Unremovable!" );
518 xContainer
= nullptr;
522 if ( !xSet
->getPropertySetInfo()->getProperties().hasElements() )
524 // Remove empty propertyset from registry.
525 uno::Reference
< css::ucb::XPropertySetRegistry
>
526 xReg
= xSet
->getRegistry();
529 OUString
aKey( xSet
->getKey() );
531 xReg
->removePropertySet( aKey
);
535 if ( m_pImpl
->m_xPropSetInfo
.is() )
537 // Info cached in propertyset info is invalid now!
538 m_pImpl
->m_xPropSetInfo
->reset();
541 // Notify propertyset info change listeners.
542 if ( m_pImpl
->m_pPropSetChangeListeners
&&
543 m_pImpl
->m_pPropSetChangeListeners
->getLength() )
545 beans::PropertySetInfoChangeEvent
evt(
546 static_cast< cppu::OWeakObject
* >( this ),
548 -1, // No handle available
549 beans::PropertySetInfoChange::PROPERTY_REMOVED
);
550 notifyPropertySetInfoChange( evt
);
557 void SAL_CALL
ContentImplHelper::addPropertySetInfoChangeListener(
558 const uno::Reference
< beans::XPropertySetInfoChangeListener
>& Listener
)
560 osl::MutexGuard
aGuard( m_aMutex
);
562 if ( !m_pImpl
->m_pPropSetChangeListeners
)
563 m_pImpl
->m_pPropSetChangeListeners
.reset(
564 new cppu::OInterfaceContainerHelper( m_aMutex
));
566 m_pImpl
->m_pPropSetChangeListeners
->addInterface( Listener
);
570 void SAL_CALL
ContentImplHelper::removePropertySetInfoChangeListener(
571 const uno::Reference
< beans::XPropertySetInfoChangeListener
>& Listener
)
573 osl::MutexGuard
aGuard( m_aMutex
);
575 if ( m_pImpl
->m_pPropSetChangeListeners
)
576 m_pImpl
->m_pPropSetChangeListeners
->removeInterface( Listener
);
580 uno::Reference
< uno::XInterface
> SAL_CALL
ContentImplHelper::getParent()
582 uno::Reference
< uno::XInterface
> xParent
;
583 OUString aURL
= getParentURL();
585 if ( !aURL
.isEmpty() )
587 uno::Reference
< css::ucb::XContentIdentifier
> xId(
588 new ContentIdentifier( aURL
) );
591 xParent
.set( m_xProvider
->queryContent( xId
) );
593 catch ( css::ucb::IllegalIdentifierException
const & )
602 void SAL_CALL
ContentImplHelper::setParent(
603 const uno::Reference
< uno::XInterface
>& )
605 throw lang::NoSupportException();
608 uno::Reference
< css::ucb::XPersistentPropertySet
>
609 ContentImplHelper::getAdditionalPropertySet( bool bCreate
)
611 // Get propertyset from provider.
612 return m_xProvider
->getAdditionalPropertySet(
613 m_xIdentifier
->getContentIdentifier(), bCreate
);
616 bool ContentImplHelper::renameAdditionalPropertySet(
617 const OUString
& rOldKey
,
618 const OUString
& rNewKey
)
620 return m_xProvider
->renameAdditionalPropertySet(
621 rOldKey
, rNewKey
, true/*bRecursive*/ );
624 bool ContentImplHelper::copyAdditionalPropertySet(
625 const OUString
& rSourceKey
,
626 const OUString
& rTargetKey
)
628 return m_xProvider
->copyAdditionalPropertySet(
629 rSourceKey
, rTargetKey
, true/*bRecursive*/ );
632 bool ContentImplHelper::removeAdditionalPropertySet()
634 return m_xProvider
->removeAdditionalPropertySet(
635 m_xIdentifier
->getContentIdentifier(), true/*bRecursive*/ );
638 void ContentImplHelper::notifyPropertiesChange(
639 const uno::Sequence
< beans::PropertyChangeEvent
>& evt
) const
641 if ( !m_pImpl
->m_pPropertyChangeListeners
)
644 sal_Int32 nCount
= evt
.getLength();
647 // First, notify listeners interested in changes of every property.
648 cppu::OInterfaceContainerHelper
* pAllPropsContainer
649 = m_pImpl
->m_pPropertyChangeListeners
->getContainer(
651 if ( pAllPropsContainer
)
653 cppu::OInterfaceIteratorHelper
aIter( *pAllPropsContainer
);
654 while ( aIter
.hasMoreElements() )
657 uno::Reference
< beans::XPropertiesChangeListener
> xListener(
658 aIter
.next(), uno::UNO_QUERY
);
659 if ( xListener
.is() )
660 xListener
->propertiesChange( evt
);
664 PropertiesEventListenerMap aListeners
;
666 for ( const beans::PropertyChangeEvent
& rEvent
: evt
)
668 const OUString
& rName
= rEvent
.PropertyName
;
670 cppu::OInterfaceContainerHelper
* pPropsContainer
671 = m_pImpl
->m_pPropertyChangeListeners
->getContainer( rName
);
672 if ( pPropsContainer
)
674 cppu::OInterfaceIteratorHelper
aIter( *pPropsContainer
);
675 while ( aIter
.hasMoreElements() )
677 PropertyEventSequence
* p
= nullptr;
679 beans::XPropertiesChangeListener
* pListener
=
680 static_cast< beans::XPropertiesChangeListener
* >(
682 PropertiesEventListenerMap::iterator it
=
683 aListeners
.find( pListener
);
684 if ( it
== aListeners
.end() )
686 // Not in map - create and insert new entry.
687 p
= &aListeners
.emplace( pListener
, PropertyEventSequence(nCount
)).first
->second
;
699 PropertiesEventListenerMap::iterator it
= aListeners
.begin();
700 while ( !aListeners
.empty() )
702 beans::XPropertiesChangeListener
* pListener
=
703 static_cast< beans::XPropertiesChangeListener
* >( (*it
).first
);
704 PropertyEventSequence pSeq
= std::move(it
->second
);
706 // Remove current element.
707 aListeners
.erase( it
);
710 pListener
->propertiesChange( pSeq
.getEvents() );
712 it
= aListeners
.begin();
717 void ContentImplHelper::notifyPropertySetInfoChange(
718 const beans::PropertySetInfoChangeEvent
& evt
) const
720 if ( !m_pImpl
->m_pPropSetChangeListeners
)
723 // Notify event listeners.
724 cppu::OInterfaceIteratorHelper
aIter( *m_pImpl
->m_pPropSetChangeListeners
);
725 while ( aIter
.hasMoreElements() )
728 uno::Reference
< beans::XPropertySetInfoChangeListener
>
729 xListener( aIter
.next(), uno::UNO_QUERY
);
730 if ( xListener
.is() )
731 xListener
->propertySetInfoChange( evt
);
735 void ContentImplHelper::notifyContentEvent(
736 const css::ucb::ContentEvent
& evt
) const
738 if ( !m_pImpl
->m_pContentEventListeners
)
741 // Notify event listeners.
742 cppu::OInterfaceIteratorHelper
aIter( *m_pImpl
->m_pContentEventListeners
);
743 while ( aIter
.hasMoreElements() )
747 css::ucb::XContentEventListener
> xListener(
748 aIter
.next(), uno::UNO_QUERY
);
749 if ( xListener
.is() )
750 xListener
->contentEvent( evt
);
754 void ContentImplHelper::inserted()
756 // Content is not yet registered at provider.
757 m_xProvider
->registerNewContent( this );
759 // If the parent content is currently not instantiated, there can be
760 // no listeners interested in changes ;-)
762 rtl::Reference
< ContentImplHelper
> xParent
763 = m_xProvider
->queryExistingContent( getParentURL() );
767 css::ucb::ContentEvent
aEvt(
768 static_cast< cppu::OWeakObject
* >( xParent
.get() ), // Source
769 css::ucb::ContentAction::INSERTED
, // Action
771 xParent
->getIdentifier() ); // Id
772 xParent
->notifyContentEvent( aEvt
);
776 void ContentImplHelper::deleted()
778 uno::Reference
< css::ucb::XContent
> xThis
= this;
780 rtl::Reference
< ContentImplHelper
> xParent
781 = m_xProvider
->queryExistingContent( getParentURL() );
785 // Let parent notify "REMOVED" event.
786 css::ucb::ContentEvent
aEvt(
787 static_cast< cppu::OWeakObject
* >( xParent
.get() ),
788 css::ucb::ContentAction::REMOVED
,
790 xParent
->getIdentifier() );
791 xParent
->notifyContentEvent( aEvt
);
794 // Notify "DELETED" event.
795 css::ucb::ContentEvent
aEvt1(
796 static_cast< cppu::OWeakObject
* >( this ),
797 css::ucb::ContentAction::DELETED
,
800 notifyContentEvent( aEvt1
);
802 m_xProvider
->removeContent( this );
805 bool ContentImplHelper::exchange(
806 const uno::Reference
< css::ucb::XContentIdentifier
>& rNewId
)
808 uno::Reference
< css::ucb::XContent
> xThis
= this;
810 osl::ClearableMutexGuard
aGuard( m_aMutex
);
812 rtl::Reference
< ContentImplHelper
> xContent
813 = m_xProvider
->queryExistingContent( rNewId
);
817 // Big trouble. Another object with the new identity exists.
818 // How shall I mutate to / merge with the other object?
822 uno::Reference
< css::ucb::XContentIdentifier
> xOldId
825 // Re-insert at provider.
826 m_xProvider
->removeContent( this );
827 m_xIdentifier
= rNewId
;
828 m_xProvider
->registerNewContent( this );
832 // Notify "EXCHANGED" event.
833 css::ucb::ContentEvent
aEvt(
834 static_cast< cppu::OWeakObject
* >( this ),
835 css::ucb::ContentAction::EXCHANGED
,
838 notifyContentEvent( aEvt
);
842 uno::Reference
< css::ucb::XCommandInfo
>
843 ContentImplHelper::getCommandInfo(
844 const uno::Reference
< css::ucb::XCommandEnvironment
> & xEnv
,
847 osl::MutexGuard
aGuard( m_aMutex
);
849 if ( !m_pImpl
->m_xCommandsInfo
.is() )
850 m_pImpl
->m_xCommandsInfo
851 = new CommandProcessorInfo( xEnv
, this );
853 m_pImpl
->m_xCommandsInfo
->reset();
855 return uno::Reference
< css::ucb::XCommandInfo
>(
856 m_pImpl
->m_xCommandsInfo
.get() );
859 uno::Reference
< beans::XPropertySetInfo
>
860 ContentImplHelper::getPropertySetInfo(
861 const uno::Reference
< css::ucb::XCommandEnvironment
> & xEnv
,
864 osl::MutexGuard
aGuard( m_aMutex
);
866 if ( !m_pImpl
->m_xPropSetInfo
.is() )
867 m_pImpl
->m_xPropSetInfo
868 = new PropertySetInfo( xEnv
, this );
870 m_pImpl
->m_xPropSetInfo
->reset();
872 return uno::Reference
< beans::XPropertySetInfo
>(
873 m_pImpl
->m_xPropSetInfo
.get() );
876 } // namespace ucbhelper
878 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */