LibreOffice Module ucbhelper (master) 1
contenthelper.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#include <sal/config.h>
21
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>
37#include "contentinfo.hxx"
39#include <ucbhelper/macros.hxx>
40
41#include <osl/diagnose.h>
42#include <osl/mutex.hxx>
43#include <rtl/ref.hxx>
44
45#include <unordered_map>
46#include <utility>
47
48using namespace com::sun::star;
49
51{
52
53namespace {
54
55class PropertyEventSequence
56{
57 uno::Sequence< beans::PropertyChangeEvent > m_aSeq;
58 sal_uInt32 m_nPos;
59
60public:
61 explicit PropertyEventSequence( sal_uInt32 nSize )
62 : m_aSeq( nSize ), m_nPos( 0 ) {};
63
64 void append( const beans::PropertyChangeEvent& rEvt )
65 { m_aSeq.getArray()[ m_nPos ] = rEvt; ++m_nPos; }
66
67 const uno::Sequence< beans::PropertyChangeEvent >& getEvents()
68 { m_aSeq.realloc( m_nPos ); return m_aSeq; }
69};
70
71}
72
73typedef void* XPropertiesChangeListenerPtr; // -> Compiler problems!
74
75namespace {
76
77struct equalPtr
78{
79 bool operator()( const XPropertiesChangeListenerPtr& rp1,
80 const XPropertiesChangeListenerPtr& rp2 ) const
81 {
82 return ( rp1 == rp2 );
83 }
84};
85
86struct hashPtr
87{
88 size_t operator()( const XPropertiesChangeListenerPtr& rp ) const
89 {
90 return reinterpret_cast<size_t>(rp);
91 }
92};
93
94}
95
96typedef std::unordered_map
97<
99 PropertyEventSequence,
100 hashPtr,
101 equalPtr
102>
104
107
109{
112 std::unique_ptr<cppu::OInterfaceContainerHelper> m_pDisposeEventListeners;
113 std::unique_ptr<comphelper::OInterfaceContainerHelper3<css::ucb::XContentEventListener>>
115 std::unique_ptr<comphelper::OInterfaceContainerHelper3<beans::XPropertySetInfoChangeListener>>
117 std::unique_ptr<cppu::OInterfaceContainerHelper> m_pCommandChangeListeners;
118 std::unique_ptr<PropertyChangeListeners> m_pPropertyChangeListeners;
119};
120
121} // namespace ucbhelper_impl
122
123using namespace ucbhelper_impl;
124
125namespace ucbhelper {
126
128 uno::Reference< uno::XComponentContext > xContext,
130 uno::Reference<
131 css::ucb::XContentIdentifier > Identifier )
133 m_xContext(std::move( xContext )),
134 m_xIdentifier(std::move( Identifier )),
135 m_xProvider(std::move( xProvider )),
136 m_nCommandId( 0 )
137{
138}
139
140// virtual
142{
143}
144
146 noexcept
147{
148 // #144882# - Call to OWeakObject::release may destroy m_xProvider.
149 // Prevent this.
151 m_xProvider );
152
153 osl::MutexGuard aGuard( m_xProvider->m_aMutex );
154 OWeakObject::release();
155}
156
158{
159 css::uno::Any aRet = cppu::queryInterface( rType,
160 static_cast< lang::XTypeProvider * >(this),
161 static_cast< lang::XServiceInfo * >(this),
162 static_cast< lang::XComponent * >(this),
163 static_cast< css::ucb::XContent * >(this),
164 static_cast< css::ucb::XCommandProcessor * >(this),
165 static_cast< beans::XPropertiesChangeNotifier * >(this),
166 static_cast< css::ucb::XCommandInfoChangeNotifier * >(this),
167 static_cast< beans::XPropertyContainer * >(this),
168 static_cast< beans::XPropertySetInfoChangeNotifier * >(this),
169 static_cast< container::XChild * >(this));
170 return aRet.hasValue() ? aRet : cppu::OWeakObject::queryInterface( rType );
171}
172
174 lang::XTypeProvider,
175 lang::XServiceInfo,
176 lang::XComponent,
177 css::ucb::XContent,
178 css::ucb::XCommandProcessor,
179 beans::XPropertiesChangeNotifier,
180 css::ucb::XCommandInfoChangeNotifier,
181 beans::XPropertyContainer,
182 beans::XPropertySetInfoChangeNotifier,
183 container::XChild );
184
185// virtual
187 const OUString& ServiceName )
188{
190}
191
192// virtual
194{
195 osl::MutexGuard aGuard( m_aMutex );
196
197 if ( m_pImpl->m_pDisposeEventListeners &&
198 m_pImpl->m_pDisposeEventListeners->getLength() )
199 {
200 lang::EventObject aEvt;
201 aEvt.Source = static_cast< lang::XComponent * >( this );
202 m_pImpl->m_pDisposeEventListeners->disposeAndClear( aEvt );
203 }
204
205 if ( m_pImpl->m_pContentEventListeners &&
206 m_pImpl->m_pContentEventListeners->getLength() )
207 {
208 lang::EventObject aEvt;
209 aEvt.Source = static_cast< css::ucb::XContent * >( this );
210 m_pImpl->m_pContentEventListeners->disposeAndClear( aEvt );
211 }
212
213 if ( m_pImpl->m_pPropSetChangeListeners &&
214 m_pImpl->m_pPropSetChangeListeners->getLength() )
215 {
216 lang::EventObject aEvt;
217 aEvt.Source
218 = static_cast< beans::XPropertySetInfoChangeNotifier * >( this );
219 m_pImpl->m_pPropSetChangeListeners->disposeAndClear( aEvt );
220 }
221
222 if ( m_pImpl->m_pCommandChangeListeners &&
223 m_pImpl->m_pCommandChangeListeners->getLength() )
224 {
225 lang::EventObject aEvt;
226 aEvt.Source = static_cast< css::ucb::XCommandInfoChangeNotifier * >( this );
227 m_pImpl->m_pCommandChangeListeners->disposeAndClear( aEvt );
228 }
229
230 if ( m_pImpl->m_pPropertyChangeListeners )
231 {
232 lang::EventObject aEvt;
233 aEvt.Source
234 = static_cast< beans::XPropertiesChangeNotifier * >( this );
235 m_pImpl->m_pPropertyChangeListeners->disposeAndClear( aEvt );
236 }
237}
238
239// virtual
241 const uno::Reference< lang::XEventListener >& Listener )
242{
243 osl::MutexGuard aGuard( m_aMutex );
244
245 if ( !m_pImpl->m_pDisposeEventListeners )
246 m_pImpl->m_pDisposeEventListeners.reset(
248
249 m_pImpl->m_pDisposeEventListeners->addInterface( Listener );
250}
251
252// virtual
254 const uno::Reference< lang::XEventListener >& Listener )
255{
256 osl::MutexGuard aGuard( m_aMutex );
257
258 if ( m_pImpl->m_pDisposeEventListeners )
259 m_pImpl->m_pDisposeEventListeners->removeInterface( Listener );
260}
261
262// virtual
263uno::Reference< css::ucb::XContentIdentifier > SAL_CALL
265{
266 return m_xIdentifier;
267}
268
269// virtual
271 const uno::Reference< css::ucb::XContentEventListener >& Listener )
272{
273 osl::MutexGuard aGuard( m_aMutex );
274
275 if ( !m_pImpl->m_pContentEventListeners )
276 m_pImpl->m_pContentEventListeners.reset(
278
279 m_pImpl->m_pContentEventListeners->addInterface( Listener );
280}
281
282// virtual
284 const uno::Reference< css::ucb::XContentEventListener >& Listener )
285{
286 osl::MutexGuard aGuard( m_aMutex );
287
288 if ( m_pImpl->m_pContentEventListeners )
289 m_pImpl->m_pContentEventListeners->removeInterface( Listener );
290}
291
292// virtual
294{
295 osl::MutexGuard aGuard( m_aMutex );
296
297 // Just increase counter on every call to generate an identifier.
298 return ++m_nCommandId;
299}
300
301// virtual
303 const uno::Sequence< OUString >& PropertyNames,
304 const uno::Reference< beans::XPropertiesChangeListener >& Listener )
305{
306 osl::MutexGuard aGuard( m_aMutex );
307
308 if ( !m_pImpl->m_pPropertyChangeListeners )
309 m_pImpl->m_pPropertyChangeListeners.reset(
311
312 if ( !PropertyNames.hasElements() )
313 {
314 // Note: An empty sequence means a listener for "all" properties.
315 m_pImpl->m_pPropertyChangeListeners->addInterface(
316 OUString(), Listener );
317 }
318 else
319 {
320 for ( const OUString& rName : PropertyNames )
321 {
322 if ( !rName.isEmpty() )
323 m_pImpl->m_pPropertyChangeListeners->addInterface(
324 rName, Listener );
325 }
326 }
327}
328
329// virtual
331 const uno::Sequence< OUString >& PropertyNames,
332 const uno::Reference< beans::XPropertiesChangeListener >& Listener )
333{
334 osl::MutexGuard aGuard( m_aMutex );
335
336 if ( !m_pImpl->m_pPropertyChangeListeners )
337 return;
338
339 if ( !PropertyNames.hasElements() )
340 {
341 // Note: An empty sequence means a listener for "all" properties.
342 m_pImpl->m_pPropertyChangeListeners->removeInterface(
343 OUString(), Listener );
344 }
345 else
346 {
347 for ( const OUString& rName : PropertyNames )
348 {
349 if ( !rName.isEmpty() )
350 m_pImpl->m_pPropertyChangeListeners->removeInterface(
351 rName, Listener );
352 }
353 }
354}
355
356// virtual
358 const uno::Reference< css::ucb::XCommandInfoChangeListener >& Listener )
359{
360 osl::MutexGuard aGuard( m_aMutex );
361
362 if ( !m_pImpl->m_pCommandChangeListeners )
363 m_pImpl->m_pCommandChangeListeners.reset(
365
366 m_pImpl->m_pCommandChangeListeners->addInterface( Listener );
367}
368
369// virtual
371 const uno::Reference< css::ucb::XCommandInfoChangeListener >& Listener )
372{
373 osl::MutexGuard aGuard( m_aMutex );
374
375 if ( m_pImpl->m_pCommandChangeListeners )
376 m_pImpl->m_pCommandChangeListeners->removeInterface( Listener );
377}
378
379// virtual
381 const OUString& Name,
382 sal_Int16 Attributes,
383 const uno::Any& DefaultValue )
384{
385 osl::MutexGuard aGuard( m_aMutex );
386
387 // Make sure a property with the requested name does not already
388 // exist in dynamic and static(!) properties.
389
390 // @@@ Need real command environment here, but where to get it from?
391 // XPropertyContainer interface should be replaced by
392 // XCommandProcessor commands!
393 uno::Reference< css::ucb::XCommandEnvironment > xEnv;
394
395 if ( getPropertySetInfo( xEnv )->hasPropertyByName( Name ) )
396 {
397 // Property does already exist.
398 throw beans::PropertyExistException();
399 }
400
401 // Add a new dynamic property.
402 // Open/create persistent property set.
403 uno::Reference< css::ucb::XPersistentPropertySet > xSet(
404 getAdditionalPropertySet( true ) );
405
406 OSL_ENSURE( xSet.is(),
407 "ContentImplHelper::addProperty - No property set!" );
408
409 if ( !xSet.is() )
410 return;
411
412 uno::Reference< beans::XPropertyContainer > xContainer(
413 xSet, uno::UNO_QUERY );
414
415 OSL_ENSURE(
416 xContainer.is(),
417 "ContentImplHelper::addProperty - No property container!" );
418
419 if ( !xContainer.is() )
420 return;
421
422 // Property is always removable.
423 Attributes |= beans::PropertyAttribute::REMOVABLE;
424
425 try
426 {
427 xContainer->addProperty( Name, Attributes, DefaultValue );
428 }
429 catch ( beans::PropertyExistException const & )
430 {
431 OSL_FAIL( "ContentImplHelper::addProperty - Exists!" );
432 throw;
433 }
434 catch ( beans::IllegalTypeException const & )
435 {
436 OSL_FAIL( "ContentImplHelper::addProperty - Wrong Type!" );
437 throw;
438 }
439 catch ( lang::IllegalArgumentException const & )
440 {
441 OSL_FAIL( "ContentImplHelper::addProperty - Illegal Arg!" );
442 throw;
443 }
444
445 // Success!
446
447 if ( m_pImpl->m_xPropSetInfo.is() )
448 {
449 // Info cached in propertyset info is invalid now!
450 m_pImpl->m_xPropSetInfo->reset();
451 }
452
453 // Notify propertyset info change listeners.
454 if ( m_pImpl->m_pPropSetChangeListeners &&
455 m_pImpl->m_pPropSetChangeListeners->getLength() )
456 {
457 beans::PropertySetInfoChangeEvent evt(
458 getXWeak(),
459 Name,
460 -1, // No handle available
461 beans::PropertySetInfoChange::PROPERTY_INSERTED );
463 }
464}
465
466// virtual
467void SAL_CALL ContentImplHelper::removeProperty( const OUString& Name )
468{
469 osl::MutexGuard aGuard( m_aMutex );
470
471 try
472 {
473 // @@@ Need real command environment here, but where to get it from?
474 // XPropertyContainer interface should be replaced by
475 // XCommandProcessor commands!
476 uno::Reference< css::ucb::XCommandEnvironment > xEnv;
477
478 beans::Property aProp
479 = getPropertySetInfo( xEnv )->getPropertyByName( Name );
480
481 if ( !( aProp.Attributes & beans::PropertyAttribute::REMOVABLE ) )
482 {
483 // Not removable!
484 throw beans::NotRemoveableException();
485 }
486 }
487 catch ( beans::UnknownPropertyException const & )
488 {
489 OSL_FAIL( "ContentImplHelper::removeProperty - Unknown!" );
490 throw;
491 }
492
493 // Try to remove property from dynamic property set.
494 // Open persistent property set, if exists.
495 uno::Reference< css::ucb::XPersistentPropertySet > xSet(
496 getAdditionalPropertySet( false ) );
497 if ( !xSet.is() )
498 return;
499
500 uno::Reference< beans::XPropertyContainer > xContainer(
501 xSet, uno::UNO_QUERY );
502
503 OSL_ENSURE(
504 xContainer.is(),
505 "ContentImplHelper::removeProperty - No property container!" );
506
507 if ( !xContainer.is() )
508 return;
509
510 try
511 {
512 xContainer->removeProperty( Name );
513 }
514 catch ( beans::UnknownPropertyException const & )
515 {
516 OSL_FAIL( "ContentImplHelper::removeProperty - Unknown!" );
517 throw;
518 }
519 catch ( beans::NotRemoveableException const & )
520 {
521 OSL_FAIL(
522 "ContentImplHelper::removeProperty - Unremovable!" );
523 throw;
524 }
525
526 xContainer = nullptr;
527
528 // Success!
529
530 if ( !xSet->getPropertySetInfo()->getProperties().hasElements() )
531 {
532 // Remove empty propertyset from registry.
533 uno::Reference< css::ucb::XPropertySetRegistry >
534 xReg = xSet->getRegistry();
535 if ( xReg.is() )
536 {
537 OUString aKey( xSet->getKey() );
538 xSet = nullptr;
539 xReg->removePropertySet( aKey );
540 }
541 }
542
543 if ( m_pImpl->m_xPropSetInfo.is() )
544 {
545 // Info cached in propertyset info is invalid now!
546 m_pImpl->m_xPropSetInfo->reset();
547 }
548
549 // Notify propertyset info change listeners.
550 if ( m_pImpl->m_pPropSetChangeListeners &&
551 m_pImpl->m_pPropSetChangeListeners->getLength() )
552 {
553 beans::PropertySetInfoChangeEvent evt(
554 getXWeak(),
555 Name,
556 -1, // No handle available
557 beans::PropertySetInfoChange::PROPERTY_REMOVED );
559 }
560}
561
562// virtual
564 const uno::Reference< beans::XPropertySetInfoChangeListener >& Listener )
565{
566 osl::MutexGuard aGuard( m_aMutex );
567
568 if ( !m_pImpl->m_pPropSetChangeListeners )
569 m_pImpl->m_pPropSetChangeListeners.reset(
571
572 m_pImpl->m_pPropSetChangeListeners->addInterface( Listener );
573}
574
575// virtual
577 const uno::Reference< beans::XPropertySetInfoChangeListener >& Listener )
578{
579 osl::MutexGuard aGuard( m_aMutex );
580
581 if ( m_pImpl->m_pPropSetChangeListeners )
582 m_pImpl->m_pPropSetChangeListeners->removeInterface( Listener );
583}
584
585// virtual
586uno::Reference< uno::XInterface > SAL_CALL ContentImplHelper::getParent()
587{
588 uno::Reference< uno::XInterface > xParent;
589 OUString aURL = getParentURL();
590
591 if ( !aURL.isEmpty() )
592 {
593 uno::Reference< css::ucb::XContentIdentifier > xId(
594 new ContentIdentifier( aURL ) );
595 try
596 {
597 xParent.set( m_xProvider->queryContent( xId ) );
598 }
599 catch ( css::ucb::IllegalIdentifierException const & )
600 {
601 }
602 }
603
604 return xParent;
605}
606
607// virtual
609 const uno::Reference< uno::XInterface >& )
610{
611 throw lang::NoSupportException();
612}
613
614uno::Reference< css::ucb::XPersistentPropertySet >
616{
617 // Get propertyset from provider.
618 return m_xProvider->getAdditionalPropertySet(
619 m_xIdentifier->getContentIdentifier(), bCreate );
620}
621
623 const OUString& rOldKey,
624 const OUString& rNewKey )
625{
626 return m_xProvider->renameAdditionalPropertySet(
627 rOldKey, rNewKey, true/*bRecursive*/ );
628}
629
631 const OUString& rSourceKey,
632 const OUString& rTargetKey )
633{
634 return m_xProvider->copyAdditionalPropertySet(
635 rSourceKey, rTargetKey, true/*bRecursive*/ );
636}
637
639{
640 return m_xProvider->removeAdditionalPropertySet(
641 m_xIdentifier->getContentIdentifier(), true/*bRecursive*/ );
642}
643
645 const uno::Sequence< beans::PropertyChangeEvent >& evt ) const
646{
647 if ( !m_pImpl->m_pPropertyChangeListeners )
648 return;
649
650 sal_Int32 nCount = evt.getLength();
651 if ( !nCount )
652 return;
653
654 // First, notify listeners interested in changes of every property.
655 cppu::OInterfaceContainerHelper* pAllPropsContainer
656 = m_pImpl->m_pPropertyChangeListeners->getContainer(
657 OUString() );
658 if ( pAllPropsContainer )
659 {
660 cppu::OInterfaceIteratorHelper aIter( *pAllPropsContainer );
661 while ( aIter.hasMoreElements() )
662 {
663 // Propagate event.
664 static_cast< beans::XPropertiesChangeListener* >(
665 aIter.next())->propertiesChange( evt );
666 }
667 }
668
670
671 for ( const beans::PropertyChangeEvent& rEvent : evt )
672 {
673 const OUString& rName = rEvent.PropertyName;
674
675 cppu::OInterfaceContainerHelper* pPropsContainer
676 = m_pImpl->m_pPropertyChangeListeners->getContainer( rName );
677 if ( pPropsContainer )
678 {
679 cppu::OInterfaceIteratorHelper aIter( *pPropsContainer );
680 while ( aIter.hasMoreElements() )
681 {
682 PropertyEventSequence* p = nullptr;
683
684 beans::XPropertiesChangeListener* pListener =
685 static_cast< beans::XPropertiesChangeListener * >(
686 aIter.next() );
687 PropertiesEventListenerMap::iterator it =
688 aListeners.find( pListener );
689 if ( it == aListeners.end() )
690 {
691 // Not in map - create and insert new entry.
692 p = &aListeners.emplace( pListener, PropertyEventSequence(nCount)).first->second;
693 }
694 else
695 p = &it->second;
696
697 if ( p )
698 p->append( rEvent );
699 }
700 }
701 }
702
703 // Notify listeners.
704 PropertiesEventListenerMap::iterator it = aListeners.begin();
705 while ( !aListeners.empty() )
706 {
707 beans::XPropertiesChangeListener* pListener =
708 static_cast< beans::XPropertiesChangeListener * >( (*it).first );
709 PropertyEventSequence pSeq = std::move(it->second);
710
711 // Remove current element.
712 aListeners.erase( it );
713
714 // Propagate event.
715 pListener->propertiesChange( pSeq.getEvents() );
716
717 it = aListeners.begin();
718 }
719}
720
722 const beans::PropertySetInfoChangeEvent& evt ) const
723{
724 if ( !m_pImpl->m_pPropSetChangeListeners )
725 return;
726
727 // Notify event listeners.
728 m_pImpl->m_pPropSetChangeListeners->notifyEach( &beans::XPropertySetInfoChangeListener::propertySetInfoChange, evt );
729}
730
732 const css::ucb::ContentEvent& evt ) const
733{
734 if ( !m_pImpl->m_pContentEventListeners )
735 return;
736
737 // Notify event listeners.
738 m_pImpl->m_pContentEventListeners->notifyEach( &css::ucb::XContentEventListener::contentEvent, evt);
739}
740
742{
743 // Content is not yet registered at provider.
744 m_xProvider->registerNewContent( this );
745
746 // If the parent content is currently not instantiated, there can be
747 // no listeners interested in changes ;-)
748
750 = m_xProvider->queryExistingContent( getParentURL() );
751
752 if ( xParent.is() )
753 {
754 css::ucb::ContentEvent aEvt(
755 xParent->getXWeak(), // Source
756 css::ucb::ContentAction::INSERTED, // Action
757 this, // Content
758 xParent->getIdentifier() ); // Id
759 xParent->notifyContentEvent( aEvt );
760 }
761}
762
764{
765 uno::Reference< css::ucb::XContent > xThis = this;
766
768 = m_xProvider->queryExistingContent( getParentURL() );
769
770 if ( xParent.is() )
771 {
772 // Let parent notify "REMOVED" event.
773 css::ucb::ContentEvent aEvt(
774 xParent->getXWeak(),
775 css::ucb::ContentAction::REMOVED,
776 this,
777 xParent->getIdentifier() );
778 xParent->notifyContentEvent( aEvt );
779 }
780
781 // Notify "DELETED" event.
782 css::ucb::ContentEvent aEvt1(
783 getXWeak(),
784 css::ucb::ContentAction::DELETED,
785 this,
786 getIdentifier() );
787 notifyContentEvent( aEvt1 );
788
789 m_xProvider->removeContent( this );
790}
791
793 const uno::Reference< css::ucb::XContentIdentifier >& rNewId )
794{
795 uno::Reference< css::ucb::XContent > xThis = this;
796
797 osl::ClearableMutexGuard aGuard( m_aMutex );
798
800 = m_xProvider->queryExistingContent( rNewId );
801 if ( xContent.is() )
802 {
803 // @@@
804 // Big trouble. Another object with the new identity exists.
805 // How shall I mutate to / merge with the other object?
806 return false;
807 }
808
809 uno::Reference< css::ucb::XContentIdentifier > xOldId
810 = getIdentifier();
811
812 // Re-insert at provider.
813 m_xProvider->removeContent( this );
814 m_xIdentifier = rNewId;
815 m_xProvider->registerNewContent( this );
816
817 aGuard.clear();
818
819 // Notify "EXCHANGED" event.
820 css::ucb::ContentEvent aEvt(
821 getXWeak(),
822 css::ucb::ContentAction::EXCHANGED,
823 this,
824 xOldId );
825 notifyContentEvent( aEvt );
826 return true;
827}
828
829uno::Reference< css::ucb::XCommandInfo >
831 const uno::Reference< css::ucb::XCommandEnvironment > & xEnv,
832 bool bCache )
833{
834 osl::MutexGuard aGuard( m_aMutex );
835
836 if ( !m_pImpl->m_xCommandsInfo.is() )
837 m_pImpl->m_xCommandsInfo
838 = new CommandProcessorInfo( xEnv, this );
839 else if ( !bCache )
840 m_pImpl->m_xCommandsInfo->reset();
841
842 return m_pImpl->m_xCommandsInfo;
843}
844
845uno::Reference< beans::XPropertySetInfo >
847 const uno::Reference< css::ucb::XCommandEnvironment > & xEnv,
848 bool bCache )
849{
850 osl::MutexGuard aGuard( m_aMutex );
851
852 if ( !m_pImpl->m_xPropSetInfo.is() )
853 m_pImpl->m_xPropSetInfo
854 = new PropertySetInfo( xEnv, this );
855 else if ( !bCache )
856 m_pImpl->m_xPropSetInfo->reset();
857
858 return m_pImpl->m_xPropSetInfo;
859}
860
861} // namespace ucbhelper
862
863/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
::std::unique_ptr< XmlIdRegistry_Impl > m_pImpl
Reference< XComponentContext > m_xContext
css::uno::XInterface *SAL_CALL next()
bool SAL_CALL hasMoreElements() const
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &rType) SAL_OVERRIDE
This class implements a simple identifier object for UCB contents.
This is an abstract base class for implementations of the service com.sun.star.ucb....
virtual void SAL_CALL addCommandInfoChangeListener(const css::uno::Reference< css::ucb::XCommandInfoChangeListener > &Listener) override
void deleted()
Use this method to announce the destruction of this content at the end of your implementation of the ...
virtual void SAL_CALL setParent(const css::uno::Reference< css::uno::XInterface > &Parent) override
The implementation of this method always throws a NoSupportException.
css::uno::Reference< css::ucb::XPersistentPropertySet > getAdditionalPropertySet(bool bCreate)
Use this method to get access to the Additional Core Properties of the content ( added using content'...
void notifyPropertySetInfoChange(const css::beans::PropertySetInfoChangeEvent &evt) const
This method can be used to propagate changes of the propertyset info of your content (i....
virtual void SAL_CALL removeEventListener(const css::uno::Reference< css::lang::XEventListener > &Listener) override
virtual ~ContentImplHelper() override
Destructor.
virtual void SAL_CALL addPropertiesChangeListener(const css::uno::Sequence< OUString > &PropertyNames, const css::uno::Reference< css::beans::XPropertiesChangeListener > &Listener) override
virtual UCBHELPER_DLLPRIVATE OUString getParentURL()=0
The implementation of this method shall return the URL of the parent of your content.
void inserted()
Use this method to announce the insertion of this content at the end of your implementation of the co...
css::uno::Reference< css::ucb::XCommandInfo > getCommandInfo(const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv, bool bCache=true)
This method returns complete meta data for the commands supported by the content.
virtual void SAL_CALL addEventListener(const css::uno::Reference< css::lang::XEventListener > &Listener) override
bool renameAdditionalPropertySet(const OUString &rOldKey, const OUString &rNewKey)
This method renames the propertyset containing the Additional Core Properties of the content.
virtual void SAL_CALL removePropertySetInfoChangeListener(const css::uno::Reference< css::beans::XPropertySetInfoChangeListener > &Listener) override
virtual void SAL_CALL removePropertiesChangeListener(const css::uno::Sequence< OUString > &PropertyNames, const css::uno::Reference< css::beans::XPropertiesChangeListener > &Listener) override
rtl::Reference< ContentProviderImplHelper > m_xProvider
virtual void SAL_CALL release() noexcept override
void notifyContentEvent(const css::ucb::ContentEvent &evt) const
This method can be used to propagate content events.
virtual void SAL_CALL addPropertySetInfoChangeListener(const css::uno::Reference< css::beans::XPropertySetInfoChangeListener > &Listener) override
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &rType) override
std::unique_ptr< ucbhelper_impl::ContentImplHelper_Impl > m_pImpl
virtual css::uno::Reference< css::ucb::XContentIdentifier > SAL_CALL getIdentifier() override
virtual css::uno::Reference< css::uno::XInterface > SAL_CALL getParent() override
This method returns the content representing the parent of a content, if such a parent exists.
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
bool removeAdditionalPropertySet()
This method removes the propertyset containing the Additional Core Properties of the content.
virtual void SAL_CALL addContentEventListener(const css::uno::Reference< css::ucb::XContentEventListener > &Listener) override
ContentImplHelper(css::uno::Reference< css::uno::XComponentContext > xContext, rtl::Reference< ContentProviderImplHelper > xProvider, css::uno::Reference< css::ucb::XContentIdentifier > Identifier)
Constructor.
bool copyAdditionalPropertySet(const OUString &rSourceKey, const OUString &rTargetKey)
This method copies the propertyset containing the Additional Core Properties of the content.
virtual void SAL_CALL removeProperty(const OUString &Name) override
This method removes a property from the content according to the interface specification.
bool exchange(const css::uno::Reference< css::ucb::XContentIdentifier > &rNewId)
Use this method to change the identity of a content.
virtual void SAL_CALL addProperty(const OUString &Name, sal_Int16 Attributes, const css::uno::Any &DefaultValue) override
This method adds a property to the content according to the interface specification.
css::uno::Reference< css::beans::XPropertySetInfo > getPropertySetInfo(const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv, bool bCache=true)
This method returns complete meta data for the properties ( including Additional Core Properties supp...
virtual sal_Int32 SAL_CALL createCommandIdentifier() override
css::uno::Reference< css::ucb::XContentIdentifier > m_xIdentifier
virtual void SAL_CALL removeContentEventListener(const css::uno::Reference< css::ucb::XContentEventListener > &Listener) override
virtual void SAL_CALL removeCommandInfoChangeListener(const css::uno::Reference< css::ucb::XCommandInfoChangeListener > &Listener) override
void notifyPropertiesChange(const css::uno::Sequence< css::beans::PropertyChangeEvent > &evt) const
This method can be used to propagate changes of property values.
virtual void SAL_CALL dispose() override
uno::Sequence< beans::PropertyChangeEvent > m_aSeq
sal_uInt32 m_nPos
int nCount
Listeners aListeners
URL aURL
void * p
css::uno::Any SAL_CALL queryInterface(const css::uno::Type &rType, Interface1 *p1)
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
constexpr OUStringLiteral first
cppu::OMultiTypeInterfaceContainerHelperVar< OUString > PropertyChangeListeners
std::unordered_map< XPropertiesChangeListenerPtr, PropertyEventSequence, hashPtr, equalPtr > PropertiesEventListenerMap
void * XPropertiesChangeListenerPtr
XTYPEPROVIDER_IMPL_10(ContentImplHelper, lang::XTypeProvider, lang::XServiceInfo, lang::XComponent, css::ucb::XContent, css::ucb::XCommandProcessor, beans::XPropertiesChangeNotifier, css::ucb::XCommandInfoChangeNotifier, beans::XPropertyContainer, beans::XPropertySetInfoChangeNotifier, container::XChild)
std::unique_ptr< cppu::OInterfaceContainerHelper > m_pCommandChangeListeners
rtl::Reference< ::ucbhelper::PropertySetInfo > m_xPropSetInfo
std::unique_ptr< comphelper::OInterfaceContainerHelper3< beans::XPropertySetInfoChangeListener > > m_pPropSetChangeListeners
std::unique_ptr< comphelper::OInterfaceContainerHelper3< css::ucb::XContentEventListener > > m_pContentEventListeners
std::unique_ptr< PropertyChangeListeners > m_pPropertyChangeListeners
std::unique_ptr< cppu::OInterfaceContainerHelper > m_pDisposeEventListeners
rtl::Reference< ::ucbhelper::CommandProcessorInfo > m_xCommandsInfo
OUString Name
unsigned char sal_Bool