1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: broadcaster.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_configmgr.hxx"
34 #include "broadcaster.hxx"
35 #include "notifierimpl.hxx"
36 #include "confignotifier.hxx"
37 #include "noderef.hxx"
38 #include "nodechange.hxx"
39 #include "nodechangeinfo.hxx"
40 #include "translatechanges.hxx"
41 #include "apifactory.hxx"
42 #include "apitreeaccess.hxx"
43 #include "apitreeimplobj.hxx"
44 #include <vos/refernce.hxx>
54 #ifndef INCLUDED_FUNCTIONAL
56 #define INCLUDED_FUNCTIONAL
63 // ---------------------------------------------------------------------------------------------------
64 // Broadcaster implementation
65 // ---------------------------------------------------------------------------------------------------
66 class BroadcasterHelper
69 static vos::ORef
<NotifierImpl
> getImpl(Notifier
const& aNotifier
) { return aNotifier
.m_aImpl
; }
71 // ---------------------------------------------------------------------------------------------------
75 // -----------------------------------------------------------------------------------------------
77 struct LessORefBodyPtr
79 bool operator()(vos::ORef
<T
> const& lhs
, vos::ORef
<T
> const& rhs
) const
81 return ptr_less(lhs
.getBodyPtr(), rhs
.getBodyPtr());
84 std::less
<T
*> ptr_less
;
86 // -----------------------------------------------------------------------------------------------
89 ApiTreeImpl
const* m_pApiTree
;
90 uno::Reference
<uno::XInterface
> m_xKeepAlive
;
92 explicit ApiTreeRef(ApiTreeImpl
const* _pApiTree
= NULL
)
93 : m_pApiTree(_pApiTree
)
96 if (m_pApiTree
) m_xKeepAlive
= m_pApiTree
->getUnoInstance();
101 OSL_ASSERT(!m_pApiTree
== !m_xKeepAlive
.is());
102 return m_pApiTree
!= NULL
;
105 ApiTreeImpl
const* get() const { return m_pApiTree
; }
106 ApiTreeImpl
const* operator->() const { return m_pApiTree
; }
108 friend bool operator==(ApiTreeRef
const& lhs
,ApiTreeRef
const& rhs
)
109 { return lhs
.m_pApiTree
== rhs
.m_pApiTree
; }
111 friend bool operator!=(ApiTreeRef
const& lhs
,ApiTreeRef
const& rhs
)
112 { return lhs
.m_pApiTree
!= rhs
.m_pApiTree
; }
114 // -----------------------------------------------------------------------------------------------
115 typedef std::map
< vos::ORef
<NotifierImpl
>, ApiTreeRef
, LessORefBodyPtr
<NotifierImpl
> > NotifierSet
;
116 // -----------------------------------------------------------------------------------------------
119 // ---------------------------------------------------------------------------------------------------
120 // class Broadcaster::Impl
121 // ---------------------------------------------------------------------------------------------------
122 class Broadcaster::Impl
: public vos::OReference
125 NotifierSet::value_type m_aNotifierData
;
127 Impl(NotifierSet::value_type
const& aNotifierData
) : m_aNotifierData(aNotifierData
) {}
129 NotifierSet::value_type
getNotifierData() const { return m_aNotifierData
; }
131 bool translateChanges(configuration::NodeChangesInformation
& aInfos
, configuration::NodeChanges
const& aChanges
, bool bSingleBase
) const;
132 bool translateChanges(configuration::NodeChangesInformation
& aInfos
, configuration::NodeChangesInformation
const& aChanges
, bool bSingleBase
) const;
134 void queryConstraints(configuration::NodeChangesInformation
const& aChanges
) { this->doQueryConstraints(aChanges
); }
135 void notifyListeners(configuration::NodeChangesInformation
const& aChanges
) { this->doNotifyListeners(aChanges
); }
137 void notifyRootListeners(configuration::NodeChangesInformation
const& aChanges
);
139 static vos::ORef
<Impl
> create(vos::ORef
<NotifierImpl
> const& rNotifierImpl
, ApiTreeRef
const& pTreeImpl
, configuration::NodeChange
const& aChange
, bool bLocal
);
140 static vos::ORef
<Impl
> create(vos::ORef
<NotifierImpl
> const& rNotifierImpl
, ApiTreeRef
const& pTreeImpl
, configuration::NodeChanges
const& aChange
, bool bLocal
);
141 static vos::ORef
<Impl
> create(vos::ORef
<NotifierImpl
> const& rNotifierImpl
, ApiTreeRef
const& pTreeImpl
, configuration::NodeChangeInformation
const& aChange
, bool bLocal
);
142 static vos::ORef
<Impl
> create(vos::ORef
<NotifierImpl
> const& rNotifierImpl
, ApiTreeRef
const& pTreeImpl
, configuration::NodeChangesInformation
const& aChange
, bool bLocal
);
145 virtual void doQueryConstraints(configuration::NodeChangesInformation
const& aChanges
) = 0;
146 virtual void doNotifyListeners(configuration::NodeChangesInformation
const& aChanges
) = 0;
148 // ---------------------------------------------------------------------------------------------------
151 // -----------------------------------------------------------------------------------------------
153 class EmptyBroadcaster_Impl
: public Broadcaster::Impl
155 EmptyBroadcaster_Impl(NotifierSet::value_type
const& rNotifierData
)
156 : Broadcaster::Impl(rNotifierData
)
161 vos::ORef
< Broadcaster::Impl
> create(NotifierSet::value_type
const& rRootNotifier
)
163 return new EmptyBroadcaster_Impl(rRootNotifier
);
166 virtual void doQueryConstraints(configuration::NodeChangesInformation
const& aChanges
);
167 virtual void doNotifyListeners(configuration::NodeChangesInformation
const& aChanges
);
170 void EmptyBroadcaster_Impl::doQueryConstraints(configuration::NodeChangesInformation
const&) {}
171 void EmptyBroadcaster_Impl::doNotifyListeners(configuration::NodeChangesInformation
const&) {}
172 // -----------------------------------------------------------------------------------------------
174 class NodeLocalBroadcaster_Impl
: public Broadcaster::Impl
176 configuration::NodeID aAffectedNode
;
179 NodeLocalBroadcaster_Impl(NotifierSet::value_type
const& rTreeNotifierData
, configuration::NodeID
const& aAffectedID
)
180 : Broadcaster::Impl(rTreeNotifierData
)
181 , aAffectedNode(aAffectedID
)
185 configuration::NodeID
getAffectedNodeID() const { return aAffectedNode
; }
186 unsigned int getNodeIndex() const { return aAffectedNode
.toIndex(); }
189 void querySingleConstraint(configuration::NodeChangeInformation
const& aChange
, bool bMore
);
190 void notifySingleChange(configuration::NodeChangeInformation
const& aChange
, bool bMore
, css::beans::PropertyChangeEvent
*& pCurEvent
);
192 // -----------------------------------------------------------------------------------------------
194 class SingleChangeBroadcaster_Impl
: public NodeLocalBroadcaster_Impl
196 configuration::SubNodeID m_aChangingValue
;
198 SingleChangeBroadcaster_Impl(NotifierSet::value_type
const& rTreeNotifierData
, configuration::NodeID
const& aAffectedID
, configuration::SubNodeID
const& aChangedValue
);
202 NodeLocalBroadcaster_Impl
* create(
203 NotifierSet::value_type
const& rLocalNotifier
,
204 configuration::NodeChangeLocation
const& aChange
);
206 NodeLocalBroadcaster_Impl
* create(
207 NotifierSet::value_type
const& rLocalNotifier
,
208 configuration::NodeID
const& aAffectedID
,
209 configuration::NodeChangeLocation
const& aChange
);
211 NodeLocalBroadcaster_Impl
* create(
212 NotifierSet::value_type
const& rLocalNotifier
,
213 configuration::NodeID
const& aAffectedID
,
214 configuration::SubNodeID
const& aChangedNode
,
215 configuration::NodeChangeLocation
const& aChange
);
217 virtual void doQueryConstraints(configuration::NodeChangesInformation
const& aChanges
);
218 virtual void doNotifyListeners(configuration::NodeChangesInformation
const& aChanges
);
221 // -----------------------------------------------------------------------------------------------
222 class MultiChangeBroadcaster_Impl
: public NodeLocalBroadcaster_Impl
224 std::set
< configuration::SubNodeID
> m_aChangingNodes
;
226 MultiChangeBroadcaster_Impl(NotifierSet::value_type
const& rTreeNotifierData
, configuration::NodeID
const& aAffectedID
, std::set
< configuration::SubNodeID
>& aChangedNodes
);
230 NodeLocalBroadcaster_Impl
* create(
231 NotifierSet::value_type
const& rLocalNotifier
,
232 configuration::NodeChangesInformation
const& aChanges
);
234 NodeLocalBroadcaster_Impl
* create(
235 NotifierSet::value_type
const& rLocalNotifier
,
236 configuration::NodeID
const& aAffectedID
,
237 configuration::NodeChangesInformation
const& aChanges
);
239 virtual void doQueryConstraints(configuration::NodeChangesInformation
const& aChanges
);
240 virtual void doNotifyListeners(configuration::NodeChangesInformation
const& aChanges
);
242 // -----------------------------------------------------------------------------------------------
243 class SingleTreeBroadcaster_Impl
: public Broadcaster::Impl
245 std::vector
< vos::ORef
<NodeLocalBroadcaster_Impl
> > m_aBroadcasters
;
247 SingleTreeBroadcaster_Impl(NotifierSet::value_type
const& rTreeNotifierData
, std::vector
< vos::ORef
<NodeLocalBroadcaster_Impl
> >& aBroadcasters
);
250 //--------------------------
252 vos::ORef
< Broadcaster::Impl
> create(
253 NotifierSet::value_type
const& rRootNotifier
,
254 NotifierSet::value_type
const& rLocalNotifier
,
255 configuration::NodeChangesInformation
const& aChanges
);
257 static bool selectChanges(configuration::NodeChangesInformation
& rSelected
, configuration::NodeChangesInformation
const& aOriginal
, configuration::NodeID
const& aSelector
);
258 //--------------------------
260 virtual void doQueryConstraints(configuration::NodeChangesInformation
const& aChanges
);
261 virtual void doNotifyListeners(configuration::NodeChangesInformation
const& aChanges
);
263 // -----------------------------------------------------------------------------------------------
264 class MultiTreeBroadcaster_Impl
: public Broadcaster::Impl
266 std::vector
< vos::ORef
< Broadcaster::Impl
> > m_aBroadcasters
;
268 MultiTreeBroadcaster_Impl(NotifierSet::value_type
const& rRootNotifierData
, std::vector
< vos::ORef
< Broadcaster::Impl
> >& aBroadcasters
);
270 //--------------------------
272 vos::ORef
< Broadcaster::Impl
> create(
273 NotifierSet::value_type
const& rRootNotifier
,
274 NotifierSet
const& rNotifiers
,
275 configuration::NodeChangesInformation
const& aChanges
);
277 static bool selectChanges(configuration::NodeChangesInformation
& rSelected
, configuration::NodeChangesInformation
const& aOriginal
, NotifierSet::value_type
const& aSelector
);
278 //--------------------------
280 virtual void doQueryConstraints(configuration::NodeChangesInformation
const& aChanges
);
281 virtual void doNotifyListeners(configuration::NodeChangesInformation
const& aChanges
);
284 // -----------------------------------------------------------------------------------------------
286 inline configuration::NodeID
makeRootID( rtl::Reference
< configuration::Tree
> const& aTree
) { return configuration::NodeID( aTree
, aTree
->getRootNode() ); }
287 inline configuration::NodeID
makeRootID( ApiTreeRef
const& pTreeImpl
) { return makeRootID( pTreeImpl
->getTree() ); }
288 // -----------------------------------------------------------------------------------------------
289 NotifierSet::value_type
findNotifier(configuration::NodeChangeLocation
const& aChange
, ApiTreeRef
const& pTreeImpl
)
291 OSL_ENSURE(aChange
.isValidData(),"Invalid change location - cannot find notifier");
293 configuration::NodeID aAffectedNode
= aChange
.getAffectedNodeID();
294 if (aAffectedNode
.isEmpty())
295 return NotifierSet::value_type();
297 ApiTreeRef
aAffectedImpl( Factory::findDescendantTreeImpl(aAffectedNode
, pTreeImpl
.get()) );
298 if (aAffectedImpl
.is())
300 vos::ORef
<NotifierImpl
> aAffectedNotifier
= BroadcasterHelper::getImpl(aAffectedImpl
->getNotifier());
302 return NotifierSet::value_type(aAffectedNotifier
, aAffectedImpl
);
305 return NotifierSet::value_type();
307 // -----------------------------------------------------------------------------------------------
309 NotifierSet::value_type
findNotifier(configuration::NodeChangeInformation
const& aChange
, ApiTreeRef
const& pTreeImpl
)
311 return findNotifier(aChange
.location
,pTreeImpl
);
313 // -----------------------------------------------------------------------------------------------
315 void findNotifiers(NotifierSet
& aNotifiers
, configuration::NodeChangesInformation
const& aChanges
, ApiTreeRef
const& pTreeImpl
)
317 for (std::vector
< configuration::NodeChangeInformation
>::const_iterator it
= aChanges
.begin(); it
!= aChanges
.end(); ++it
)
319 NotifierSet::value_type
aNotifierData( findNotifier(*it
,pTreeImpl
) );
321 if (aNotifierData
.first
.isValid())
323 aNotifiers
.insert( aNotifierData
);
324 OSL_ENSURE( aNotifiers
[aNotifierData
.first
] == aNotifierData
.second
, "Different Api Trees for the same notifier" );
328 // -----------------------------------------------------------------------------------------------
329 // NodeLocalBroadcaster_Impl
330 // -----------------------------------------------------------------------------------------------
331 void NodeLocalBroadcaster_Impl::querySingleConstraint(configuration::NodeChangeInformation
const& aChange
, bool bMore
)
333 uno::Reference
< css::beans::XVetoableChangeListener
> const * const SelectListener
= 0;
335 vos::ORef
<NotifierImpl
> pNotifierImpl
= getNotifierData().first
;
337 cppu::OInterfaceContainerHelper
* pListeners
= pNotifierImpl
->m_aListeners
.getContainer( getNodeIndex(), getCppuType(SelectListener
) );
338 cppu::OInterfaceContainerHelper
* pSpecial
= pNotifierImpl
->m_aListeners
.getSpecialContainer( aChange
.location
.getChangingValueID() );
340 if (pSpecial
|| pListeners
)
342 css::beans::PropertyChangeEvent aEvent
;
343 aEvent
.Source
= pNotifierImpl
->m_aListeners
.getObjectAt( getNodeIndex() );
345 if (configapi::fillEventDataFromResolved(aEvent
,aChange
,bMore
))
347 // Catch only RuntimeExceptions here: vetoableChange issues its veto by throwing
348 // a PropertyVetoException (which is not a RuntimeException)
351 ListenerContainerIterator
< css::beans::XVetoableChangeListener
> aIterator(*pListeners
);
353 UnoApiLockReleaser aGuardReleaser
;
354 while (aIterator
.hasMoreElements())
357 aIterator
.next()->vetoableChange(aEvent
);
359 catch (uno::RuntimeException
& )
364 ListenerContainerIterator
< css::beans::XVetoableChangeListener
> aIterator(*pSpecial
);
366 UnoApiLockReleaser aGuardReleaser
;
367 while (aIterator
.hasMoreElements())
370 aIterator
.next()->vetoableChange(aEvent
);
372 catch (uno::RuntimeException
& )
379 // -----------------------------------------------------------------------------------------------
380 void NodeLocalBroadcaster_Impl::notifySingleChange(configuration::NodeChangeInformation
const& aChange
, bool bMore
, css::beans::PropertyChangeEvent
*& pCurEvent
)
382 uno::Reference
< css::beans::XPropertyChangeListener
> const * const SelectPropertyListener
= 0;
383 uno::Reference
< css::container::XContainerListener
> const * const SelectContainerListener
= 0;
385 vos::ORef
<NotifierImpl
> pNotifierImpl
= getNotifierData().first
;
387 cppu::OInterfaceContainerHelper
* pContainerListeners
= pNotifierImpl
->m_aListeners
.getContainer( getNodeIndex(), getCppuType(SelectContainerListener
) );
389 if (pContainerListeners
)
391 css::container::ContainerEvent aEvent
;
392 aEvent
.Source
= pNotifierImpl
->m_aListeners
.getObjectAt( getNodeIndex() );
394 if (configapi::fillEventDataFromResolved(aEvent
,aChange
))
397 ListenerContainerIterator
< css::container::XContainerListener
> aIterator(*pContainerListeners
);
399 UnoApiLockReleaser aGuardReleaser
;
400 while (aIterator
.hasMoreElements())
403 uno::Reference
<css::container::XContainerListener
> xListener( aIterator
.next() );
404 OSL_ASSERT( xListener
.is() );
406 switch (aChange
.change
.type
)
408 case configuration::NodeChangeData::eSetValue
:
409 case configuration::NodeChangeData::eSetDefault
:
410 case configuration::NodeChangeData::eReplaceElement
:
411 xListener
->elementReplaced(aEvent
);
414 case configuration::NodeChangeData::eInsertElement
:
415 xListener
->elementInserted(aEvent
);
418 case configuration::NodeChangeData::eRemoveElement
:
419 xListener
->elementRemoved(aEvent
);
423 case configuration::NodeChangeData::eResetSetDefault
:
424 case configuration::NodeChangeData::eRenameElementTree
:
425 case configuration::NodeChangeData::eNoChange
:
430 catch (uno::Exception
&)
436 OSL_ASSERT(pCurEvent
);
437 css::beans::PropertyChangeEvent
& rEvent
= *pCurEvent
;
439 rEvent
.Source
= pNotifierImpl
->m_aListeners
.getObjectAt( getNodeIndex() );
441 if (configapi::fillEventDataFromResolved(rEvent
,aChange
,bMore
))
443 cppu::OInterfaceContainerHelper
* pPropertyListeners
= pNotifierImpl
->m_aListeners
.getContainer( getNodeIndex(), getCppuType(SelectPropertyListener
) );
444 if (pPropertyListeners
)
446 ListenerContainerIterator
< css::beans::XPropertyChangeListener
> aIterator(*pPropertyListeners
);
447 UnoApiLockReleaser aGuardReleaser
;
448 while (aIterator
.hasMoreElements())
449 try { aIterator
.next()->propertyChange(rEvent
); } catch (uno::Exception
& ) {}
452 cppu::OInterfaceContainerHelper
* pSpecialListeners
= pNotifierImpl
->m_aListeners
.getSpecialContainer( aChange
.location
.getChangingValueID() );
453 if (pSpecialListeners
)
455 ListenerContainerIterator
< css::beans::XPropertyChangeListener
> aIterator(*pSpecialListeners
);
456 UnoApiLockReleaser aGuardReleaser
;
457 while (aIterator
.hasMoreElements())
458 try { aIterator
.next()->propertyChange(rEvent
); } catch (uno::Exception
& ) {}
465 // -----------------------------------------------------------------------------------------------
467 // -----------------------------------------------------------------------------------------------
468 // SingleBroadcaster_Impl
469 // -----------------------------------------------------------------------------------------------
470 SingleChangeBroadcaster_Impl::SingleChangeBroadcaster_Impl(
471 NotifierSet::value_type
const& rTreeNotifierData
,
472 configuration::NodeID
const& aAffectedID
, configuration::SubNodeID
const& aChangedNode
474 : NodeLocalBroadcaster_Impl(rTreeNotifierData
,aAffectedID
)
475 , m_aChangingValue(aChangedNode
)
478 // -----------------------------------------------------------------------------------------------
479 NodeLocalBroadcaster_Impl
* SingleChangeBroadcaster_Impl::create(
480 NotifierSet::value_type
const& rLocalNotifier
,
481 configuration::NodeChangeLocation
const& aChange
)
483 OSL_ENSURE(rLocalNotifier
.second
->getTree() == aChange
.getAffectedTreeRef(),
484 "ERROR: Tree Mismatch creating Single Broadcaster");
486 OSL_ENSURE(aChange
.isValidData(), "ERROR: Invalid Change Location for Broadcaster");
488 configuration::NodeID aAffectedNodeID
= aChange
.getAffectedNodeID();
489 if (aAffectedNodeID
.isEmpty())
492 return create(rLocalNotifier
,aAffectedNodeID
,aChange
.getChangingValueID(),aChange
);
494 // -----------------------------------------------------------------------------------------------
495 NodeLocalBroadcaster_Impl
* SingleChangeBroadcaster_Impl::create(
496 NotifierSet::value_type
const& rLocalNotifier
,
497 configuration::NodeID
const& aAffectedID
,
498 configuration::NodeChangeLocation
const& aChange
)
501 return create(rLocalNotifier
,aAffectedID
,aChange
.getChangingValueID(),aChange
);
503 // -----------------------------------------------------------------------------------------------
504 NodeLocalBroadcaster_Impl
* SingleChangeBroadcaster_Impl::create(
505 NotifierSet::value_type
const& rLocalNotifier
,
506 configuration::NodeID
const& aAffectedID
,
507 configuration::SubNodeID
const& aChangedNodeID
,
508 configuration::NodeChangeLocation
const& aChange
)
511 OSL_ENSURE(aChange
.isValidData(), "ERROR: Invalid Change Location for Broadcaster");
512 OSL_ENSURE(aAffectedID
.isValidNode(),"Cannot broadcast without affected node");
514 OSL_ENSURE(rLocalNotifier
.second
->getTree() == aChange
.getAffectedTreeRef(),
515 "ERROR: Tree Mismatch creating Single Broadcaster");
516 OSL_ENSURE( aChange
.getAffectedNodeID() == aAffectedID
,
517 "ERROR: Node Mismatch creating Single Broadcaster");
518 OSL_ENSURE( aChange
.getChangingValueID() == aChangedNodeID
,
519 "ERROR: Value Node Mismatch creating Single Broadcaster");
521 return new SingleChangeBroadcaster_Impl(rLocalNotifier
,aAffectedID
,aChangedNodeID
);
523 // -----------------------------------------------------------------------------------------------
524 void SingleChangeBroadcaster_Impl::doQueryConstraints(configuration::NodeChangesInformation
const& aChanges
)
526 OSL_ASSERT(aChanges
.size() <= 1);
527 if (!aChanges
.empty())
529 std::vector
< configuration::NodeChangeInformation
>::const_iterator it
= aChanges
.begin();
531 OSL_ENSURE( m_aChangingValue
== it
->location
.getChangingValueID(), "Broadcasting unanticipated change");
533 querySingleConstraint(*it
, false);
537 // -----------------------------------------------------------------------------------------------
538 void SingleChangeBroadcaster_Impl::doNotifyListeners(configuration::NodeChangesInformation
const& aChanges
)
540 OSL_ASSERT(aChanges
.size() <= 1);
541 if (!aChanges
.empty())
543 css::beans::PropertyChangeEvent aEvent
;
544 css::beans::PropertyChangeEvent
* pEventNext
= &aEvent
;
546 std::vector
< configuration::NodeChangeInformation
>::const_iterator it
= aChanges
.begin();
548 OSL_ENSURE( m_aChangingValue
== it
->location
.getChangingValueID(), "Broadcasting unanticipated change");
550 notifySingleChange(*it
, false, pEventNext
);
552 if (pEventNext
!= &aEvent
)
554 uno::Sequence
< css::beans::PropertyChangeEvent
> aPropertyEvents(&aEvent
,1);
556 uno::Reference
< css::beans::XPropertiesChangeListener
> const * const SelectListener
= 0;
558 vos::ORef
<NotifierImpl
> pNotifierImpl
= getNotifierData().first
;
560 cppu::OInterfaceContainerHelper
* pContainer
= pNotifierImpl
->m_aListeners
.getContainer( getNodeIndex(), getCppuType(SelectListener
) );
564 ListenerContainerIterator
< css::beans::XPropertiesChangeListener
> aIterator(*pContainer
);
565 UnoApiLockReleaser aGuardReleaser
;
566 while (aIterator
.hasMoreElements())
567 try { aIterator
.next()->propertiesChange(aPropertyEvents
); } catch (uno::Exception
& ) {}
573 // -----------------------------------------------------------------------------------------------
574 // MultiChangeBroadcaster_Impl
575 // -----------------------------------------------------------------------------------------------
577 MultiChangeBroadcaster_Impl::MultiChangeBroadcaster_Impl(
578 NotifierSet::value_type
const& rTreeNotifierData
,
579 configuration::NodeID
const& aAffectedID
, std::set
< configuration::SubNodeID
>& aChangedNodes
581 : NodeLocalBroadcaster_Impl(rTreeNotifierData
,aAffectedID
)
584 m_aChangingNodes
.swap(aChangedNodes
);
586 // -----------------------------------------------------------------------------------------------
587 NodeLocalBroadcaster_Impl
* MultiChangeBroadcaster_Impl::create(
588 NotifierSet::value_type
const& rLocalNotifier
,
589 configuration::NodeChangesInformation
const& aChanges
)
591 if (aChanges
.empty())
594 OSL_ENSURE(aChanges
.begin()->hasValidLocation(), "ERROR: Invalid Change Location for Broadcaster");
596 configuration::NodeID aAffectedNodeID
= aChanges
.begin()->location
.getAffectedNodeID();
597 if (aAffectedNodeID
.isEmpty())
600 return create(rLocalNotifier
, aAffectedNodeID
, aChanges
);
602 // -----------------------------------------------------------------------------------------------
603 NodeLocalBroadcaster_Impl
* MultiChangeBroadcaster_Impl::create(
604 NotifierSet::value_type
const& rLocalNotifier
,
605 configuration::NodeID
const& aAffectedNodeID
,
606 configuration::NodeChangesInformation
const& aChanges
)
608 if (aChanges
.empty())
611 else if (aChanges
.size() == 1)
612 return SingleChangeBroadcaster_Impl::create(rLocalNotifier
,aAffectedNodeID
,aChanges
.begin()->location
);
616 OSL_ENSURE(aAffectedNodeID
.isValidNode(),"Cannot broadcast without affected node");
618 std::set
< configuration::SubNodeID
> aChangedNodes
;
619 for (std::vector
< configuration::NodeChangeInformation
>::const_iterator it
= aChanges
.begin(); it
!= aChanges
.end(); ++it
)
621 OSL_ENSURE(it
->hasValidLocation(), "ERROR: Invalid Change Location for Broadcaster");
623 OSL_ENSURE(it
->location
.getAffectedNodeID() == aAffectedNodeID
, "ERROR: Change is not local to affected node (as advertised)");
624 OSL_ENSURE(rLocalNotifier
.second
->getTree() == it
->location
.getAffectedTreeRef(),
625 "ERROR: Tree Mismatch creating Multi Change Broadcaster");
627 configuration::SubNodeID aChangedValueID
= it
->location
.getChangingValueID();
629 aChangedNodes
.insert(aChangedValueID
);
631 OSL_ENSURE(!aChangedNodes
.empty(), "Changes don't affect any nodes");
633 if (aChangedNodes
.size() == 1) OSL_TRACE("WARNING: Different changes all affect the same node !");
635 return new MultiChangeBroadcaster_Impl(rLocalNotifier
, aAffectedNodeID
, aChangedNodes
);
638 // -----------------------------------------------------------------------------------------------
639 void MultiChangeBroadcaster_Impl::doQueryConstraints(configuration::NodeChangesInformation
const& aChanges
)
641 std::vector
< configuration::NodeChangeInformation
>::const_iterator
const stop
= aChanges
.end(), last
= stop
-1;
643 for (std::vector
< configuration::NodeChangeInformation
>::const_iterator it
= aChanges
.begin(); it
!= stop
; ++it
)
645 OSL_ENSURE( m_aChangingNodes
.find( it
->location
.getChangingValueID() ) != m_aChangingNodes
.end(), "Broadcasting unanticipated change");
647 querySingleConstraint(*it
, it
!= last
);
651 // -----------------------------------------------------------------------------------------------
652 void MultiChangeBroadcaster_Impl::doNotifyListeners(configuration::NodeChangesInformation
const& aChanges
)
654 uno::Sequence
< css::beans::PropertyChangeEvent
> aPropertyEvents(aChanges
.size());
656 css::beans::PropertyChangeEvent
* const pEventStart
= aPropertyEvents
.getArray();
657 css::beans::PropertyChangeEvent
* pEventNext
= pEventStart
;
659 std::vector
< configuration::NodeChangeInformation
>::const_iterator
const stop
= aChanges
.end(), last
= stop
-1;
661 for (std::vector
< configuration::NodeChangeInformation
>::const_iterator it
= aChanges
.begin(); it
!= stop
; ++it
)
663 // #92463# Skip nodes that are not in the tree
664 if (it
->location
.getAffectedNodeID().isEmpty()) continue;
666 OSL_ENSURE( m_aChangingNodes
.find( it
->location
.getChangingValueID() ) != m_aChangingNodes
.end(), "Broadcasting unanticipated change");
668 notifySingleChange(*it
, it
!= last
, pEventNext
);
671 sal_Int32 nPropertyEvents
= pEventNext
-pEventStart
;
673 if (nPropertyEvents
> 0)
675 OSL_ASSERT(nPropertyEvents
<= aPropertyEvents
.getLength());
676 if (nPropertyEvents
!= aPropertyEvents
.getLength())
677 aPropertyEvents
.realloc(nPropertyEvents
);
679 uno::Reference
< css::beans::XPropertiesChangeListener
> const * const SelectListener
= 0;
681 vos::ORef
<NotifierImpl
> pNotifierImpl
= getNotifierData().first
;
683 cppu::OInterfaceContainerHelper
* pContainer
= pNotifierImpl
->m_aListeners
.getContainer( getNodeIndex(), getCppuType(SelectListener
) );
687 ListenerContainerIterator
< css::beans::XPropertiesChangeListener
> aIterator(*pContainer
);
688 UnoApiLockReleaser aGuardReleaser
;
689 while (aIterator
.hasMoreElements())
690 try { aIterator
.next()->propertiesChange(aPropertyEvents
); } catch (uno::Exception
& ) {}
694 // -----------------------------------------------------------------------------------------------
695 // TreeLocalBroadcaster_Impl
696 // -----------------------------------------------------------------------------------------------
698 SingleTreeBroadcaster_Impl::SingleTreeBroadcaster_Impl(
699 NotifierSet::value_type
const& aTreeNotifierData
,
700 std::vector
< vos::ORef
<NodeLocalBroadcaster_Impl
> >& aBroadcasters
702 : Broadcaster::Impl(aTreeNotifierData
)
705 m_aBroadcasters
.swap(aBroadcasters
);
708 // -----------------------------------------------------------------------------------------------
710 bool SingleTreeBroadcaster_Impl::selectChanges(configuration::NodeChangesInformation
& rSelected
, configuration::NodeChangesInformation
const& aOriginal
, configuration::NodeID
const& aSelector
)
712 OSL_ASSERT(rSelected
.empty()); // nothing in there yet
714 for (std::vector
< configuration::NodeChangeInformation
>::const_iterator it
= aOriginal
.begin(); it
!= aOriginal
.end(); ++it
)
716 if ( it
->location
.getAffectedNodeID() == aSelector
)
718 rSelected
.push_back(*it
);
721 return !rSelected
.empty();
723 // -----------------------------------------------------------------------------------------------
725 vos::ORef
< Broadcaster::Impl
> SingleTreeBroadcaster_Impl::create(
726 NotifierSet::value_type
const& rRootNotifier
,
727 NotifierSet::value_type
const& rLocalNotifier
,
728 configuration::NodeChangesInformation
const& aChanges
)
730 std::set
< configuration::NodeID
> aNodes
;
731 for (std::vector
< configuration::NodeChangeInformation
>::const_iterator itChanges
= aChanges
.begin(); itChanges
!= aChanges
.end(); ++itChanges
)
733 OSL_ENSURE(itChanges
->hasValidLocation(), "ERROR: Invalid Change Location for Broadcaster");
735 configuration::NodeID aAffectedNodeID
= itChanges
->location
.getAffectedNodeID();
736 if (!aAffectedNodeID
.isEmpty())
737 aNodes
.insert(aAffectedNodeID
);
740 std::vector
< vos::ORef
<NodeLocalBroadcaster_Impl
> > aNodecasters
;
741 for (std::set
< configuration::NodeID
>::const_iterator itNodes
= aNodes
.begin(); itNodes
!= aNodes
.end(); ++itNodes
)
743 OSL_ASSERT(itNodes
->isValidNode()); // filtered empty ones above
745 configuration::NodeChangesInformation aSelectedChanges
;
746 if ( selectChanges(aSelectedChanges
, aChanges
, *itNodes
))
748 NodeLocalBroadcaster_Impl
* pSelectedImpl
= MultiChangeBroadcaster_Impl::create(rLocalNotifier
, *itNodes
, aSelectedChanges
);
750 aNodecasters
.push_back(pSelectedImpl
);
754 if (aNodecasters
.empty())
757 else if (aNodecasters
.size() == 1)
758 return aNodecasters
.begin()->getBodyPtr();
761 return new SingleTreeBroadcaster_Impl(rRootNotifier
, aNodecasters
);
763 // -----------------------------------------------------------------------------------------------
764 void SingleTreeBroadcaster_Impl::doQueryConstraints(configuration::NodeChangesInformation
const& aChanges
)
766 for(std::vector
< vos::ORef
<NodeLocalBroadcaster_Impl
> >::iterator it
= m_aBroadcasters
.begin(); it
!= m_aBroadcasters
.end(); ++it
)
768 configuration::NodeChangesInformation aSelectedInfos
;
769 if ( selectChanges(aSelectedInfos
, aChanges
, (*it
)->getAffectedNodeID()) )
770 (*it
)->queryConstraints(aSelectedInfos
);
773 // -----------------------------------------------------------------------------------------------
774 void SingleTreeBroadcaster_Impl::doNotifyListeners(configuration::NodeChangesInformation
const& aChanges
)
776 for(std::vector
< vos::ORef
<NodeLocalBroadcaster_Impl
> >::iterator it
= m_aBroadcasters
.begin(); it
!= m_aBroadcasters
.end(); ++it
)
778 configuration::NodeChangesInformation aSelectedInfos
;
779 if ( selectChanges(aSelectedInfos
, aChanges
, (*it
)->getAffectedNodeID()) )
780 (*it
)->notifyListeners(aSelectedInfos
);
783 // -----------------------------------------------------------------------------------------------
784 // MultiTreeBroadcaster_Impl
785 // -----------------------------------------------------------------------------------------------
786 MultiTreeBroadcaster_Impl::MultiTreeBroadcaster_Impl(NotifierSet::value_type
const& aRootSelector
, std::vector
< vos::ORef
< Broadcaster::Impl
> >& aBroadcasters
)
787 : Broadcaster::Impl(aRootSelector
)
790 m_aBroadcasters
.swap(aBroadcasters
);
793 // -----------------------------------------------------------------------------------------------
795 bool MultiTreeBroadcaster_Impl::selectChanges(configuration::NodeChangesInformation
& rSelected
, configuration::NodeChangesInformation
const& aOriginal
, NotifierSet::value_type
const& aSelector
)
797 OSL_ASSERT(aSelector
.first
.isValid());
798 OSL_ASSERT(aSelector
.second
.is());
800 OSL_ASSERT(rSelected
.empty()); // nothing in there yet
802 rtl::Reference
< configuration::Tree
> const aSelectedTree( aSelector
.second
->getTree() );
804 for (std::vector
< configuration::NodeChangeInformation
>::const_iterator it
= aOriginal
.begin(); it
!= aOriginal
.end(); ++it
)
806 if (it
->location
.getAffectedTreeRef() == aSelectedTree
)
808 rSelected
.push_back(*it
);
811 return !rSelected
.empty();
813 // -------------------------------------------------------------------------------------------
815 vos::ORef
< Broadcaster::Impl
> MultiTreeBroadcaster_Impl::create(NotifierSet::value_type
const& rRootNotifier
, NotifierSet
const& rNotifiers
, configuration::NodeChangesInformation
const& aChanges
)
817 std::vector
< vos::ORef
< Broadcaster::Impl
> > aTreecasters
;
818 for (NotifierSet::const_iterator it
= rNotifiers
.begin(); it
!= rNotifiers
.end(); ++it
)
820 configuration::NodeChangesInformation aSelectedChanges
;
821 if ( selectChanges(aSelectedChanges
, aChanges
, *it
))
823 vos::ORef
< Broadcaster::Impl
> pSelectedImpl
= SingleTreeBroadcaster_Impl::create(rRootNotifier
, *it
, aSelectedChanges
);
824 if (pSelectedImpl
.isValid())
825 aTreecasters
.push_back(pSelectedImpl
);
829 if (aTreecasters
.empty())
832 else if (aTreecasters
.size() == 1)
833 return *aTreecasters
.begin();
836 return new MultiTreeBroadcaster_Impl(rRootNotifier
, aTreecasters
);
838 // -------------------------------------------------------------------------------------------
840 void MultiTreeBroadcaster_Impl::doQueryConstraints(configuration::NodeChangesInformation
const& aChanges
)
842 for(std::vector
< vos::ORef
< Broadcaster::Impl
> >::iterator it
= m_aBroadcasters
.begin(); it
!= m_aBroadcasters
.end(); ++it
)
844 configuration::NodeChangesInformation aSelectedInfos
;
845 if ( selectChanges(aSelectedInfos
, aChanges
, (*it
)->getNotifierData()) )
846 (*it
)->queryConstraints(aSelectedInfos
);
849 // -------------------------------------------------------------------------------------------
851 void MultiTreeBroadcaster_Impl::doNotifyListeners(configuration::NodeChangesInformation
const& aChanges
)
853 for(std::vector
< vos::ORef
< Broadcaster::Impl
> >::iterator it
= m_aBroadcasters
.begin(); it
!= m_aBroadcasters
.end(); ++it
)
855 configuration::NodeChangesInformation aSelectedInfos
;
856 if ( selectChanges(aSelectedInfos
, aChanges
, (*it
)->getNotifierData()) )
857 (*it
)->notifyListeners(aSelectedInfos
);
860 // -----------------------------------------------------------------------------------------------
862 // ---------------------------------------------------------------------------------------------------
864 vos::ORef
< Broadcaster::Impl
> Broadcaster::Impl::create(vos::ORef
<NotifierImpl
> const& rNotifierImpl
, ApiTreeRef
const& pTreeImpl
, configuration::NodeChange
const& aChange
, bool bLocal
)
866 OSL_ASSERT(pTreeImpl
.is());
868 vos::ORef
< Broadcaster::Impl
> pRet
;
870 configuration::NodeChangeLocation aLocation
;
871 if (aChange
.getChangeLocation(aLocation
))
875 pRet
= SingleChangeBroadcaster_Impl::create( NotifierSet::value_type(rNotifierImpl
,pTreeImpl
), aLocation
);
879 NotifierSet::value_type
aAffectedNotifier( findNotifier(aLocation
, pTreeImpl
) );
880 if (aAffectedNotifier
.second
.is()) // only if we found a notifier we are able to create a broadcaster (DG)
881 pRet
= SingleChangeBroadcaster_Impl::create( aAffectedNotifier
, aLocation
);
886 OSL_ENSURE(false, "Invalid change location set in node change - cannot broadcast");
887 // can't create a matching change - must still create an empty one
891 pRet
= EmptyBroadcaster_Impl::create( NotifierSet::value_type(rNotifierImpl
,pTreeImpl
) );
895 // ---------------------------------------------------------------------------------------------------
897 vos::ORef
< Broadcaster::Impl
> Broadcaster::Impl::create(vos::ORef
<NotifierImpl
> const& rNotifierImpl
, ApiTreeRef
const& pTreeImpl
, configuration::NodeChanges
const& aChanges
, bool bLocal
)
899 NotifierSet::value_type
aRootData(rNotifierImpl
, pTreeImpl
);
901 configuration::NodeChangesInformation aChangeInfos
;
902 if (aChanges
.getChangesInfos(aChangeInfos
))
904 return create(rNotifierImpl
,pTreeImpl
,aChangeInfos
,bLocal
);
908 OSL_ENSURE(aChanges
.isEmpty(), "Cannot get information for changes - cannot notify");
910 // make an empty one below
911 vos::ORef
< Broadcaster::Impl
> pRet
= EmptyBroadcaster_Impl::create( aRootData
);
917 // ---------------------------------------------------------------------------------------------------
919 vos::ORef
< Broadcaster::Impl
> Broadcaster::Impl::create(vos::ORef
<NotifierImpl
> const& rNotifierImpl
, ApiTreeRef
const& pTreeImpl
, configuration::NodeChangeInformation
const& aChange
, bool bLocal
)
921 OSL_ASSERT(pTreeImpl
.is());
923 vos::ORef
< Broadcaster::Impl
> pRet
;
925 if (aChange
.hasValidLocation())
929 pRet
= SingleChangeBroadcaster_Impl::create( NotifierSet::value_type(rNotifierImpl
,pTreeImpl
), aChange
.location
);
933 NotifierSet::value_type
aAffectedNotifier( findNotifier(aChange
.location
, pTreeImpl
) );
934 if (aAffectedNotifier
.second
.is()) // only if we found a notifier we are able to create a broadcaster (DG)
935 pRet
= SingleChangeBroadcaster_Impl::create( aAffectedNotifier
, aChange
.location
);
940 OSL_ENSURE(false, "Invalid change location set in node change - cannot broadcast");
941 // can't create a matching change - must still create an empty one
945 pRet
= EmptyBroadcaster_Impl::create( NotifierSet::value_type(rNotifierImpl
,pTreeImpl
) );
949 // ---------------------------------------------------------------------------------------------------
951 vos::ORef
< Broadcaster::Impl
> Broadcaster::Impl::create(vos::ORef
<NotifierImpl
> const& rNotifierImpl
, ApiTreeRef
const& pTreeImpl
, configuration::NodeChangesInformation
const& aChanges
, bool bLocal
)
953 vos::ORef
< Broadcaster::Impl
> pRet
;
955 NotifierSet::value_type
aRootData(rNotifierImpl
, pTreeImpl
);
957 if (aChanges
.size() == 1)
959 pRet
= create(rNotifierImpl
, pTreeImpl
, *aChanges
.begin(), bLocal
);
963 pRet
= MultiChangeBroadcaster_Impl::create( aRootData
, aChanges
);
967 NotifierSet aNotifiers
;
968 findNotifiers( aNotifiers
, aChanges
, pTreeImpl
);
970 if (aNotifiers
.size() > 1)
972 pRet
= MultiTreeBroadcaster_Impl::create(aRootData
, aNotifiers
, aChanges
);
974 else if (!aNotifiers
.empty())
976 pRet
= SingleTreeBroadcaster_Impl::create(aRootData
, *aNotifiers
.begin(), aChanges
);
982 pRet
= EmptyBroadcaster_Impl::create( aRootData
);
986 // ---------------------------------------------------------------------------------------------------
988 bool Broadcaster::Impl::translateChanges(configuration::NodeChangesInformation
& _rInfos
, configuration::NodeChanges
const& aChanges
, bool /*bSingleBase*/) const
990 rtl::Reference
< configuration::Tree
> aBaseTree
= m_aNotifierData
.second
->getTree();
991 Factory
& rFactory
= m_aNotifierData
.second
->getFactory();
993 configuration::NodeChangesInformation aRawInfos
;
995 sal_uInt32 nChanges
= aChanges
.getChangesInfos(aRawInfos
);
997 OSL_ENSURE(nChanges
, "Cannot get info(s) for change - skipping for notification");
998 OSL_ENSURE(nChanges
== aRawInfos
.size(), "Incorrect change count returned");
1000 configuration::NodeChangesInformation aNewInfos
;
1001 aNewInfos
.reserve(nChanges
);
1003 for (std::vector
< configuration::NodeChangeInformation
>::const_iterator pos
= aRawInfos
.begin(); pos
!= aRawInfos
.end(); ++pos
)
1005 configuration::NodeChangeInformation aInfo
= *pos
;
1006 if( !configapi::rebaseChange(aInfo
.location
,aBaseTree
) )
1008 OSL_TRACE("Change is not within expected tree - skipping for notification");
1012 OSL_ENSURE(!pos
->isEmptyChange(), "Empty Change Found for Notification");
1013 // it actually is expected that elements may not be found - thus ignoring result
1014 configapi::resolveToUno(aInfo
.change
, rFactory
);
1016 aNewInfos
.push_back( aInfo
);
1019 aNewInfos
.swap(_rInfos
);
1021 return !_rInfos
.empty();
1024 // ---------------------------------------------------------------------------------------------------
1026 bool Broadcaster::Impl::translateChanges(configuration::NodeChangesInformation
& aInfos
, configuration::NodeChangesInformation
const& aChanges
, bool /*bSingleBase*/) const
1028 configuration::NodeChangesInformation aNewInfos
;
1029 aNewInfos
.reserve( aChanges
.size() );
1031 rtl::Reference
< configuration::Tree
> aBaseTree
= m_aNotifierData
.second
->getTree();
1032 Factory
& rFactory
= m_aNotifierData
.second
->getFactory();
1034 for (std::vector
< configuration::NodeChangeInformation
>::const_iterator it
= aChanges
.begin(); it
!= aChanges
.end(); ++it
)
1036 configuration::NodeChangeInformation
aInfo(*it
);
1037 if( !configapi::rebaseChange(aInfo
.location
,aBaseTree
) )
1039 OSL_TRACE("Change is not within expected tree - skipping for notification");
1043 if( !configapi::resolveToUno(aInfo
.change
,rFactory
) )
1045 // it actually is expected that elements may not be found
1046 // OSL_TRACE("Cannot find affected elements of Change");
1049 aNewInfos
.push_back( aInfo
);
1052 aNewInfos
.swap(aInfos
);
1053 return !aInfos
.empty();
1056 // ---------------------------------------------------------------------------------------------------
1057 void Broadcaster::Impl::notifyRootListeners(configuration::NodeChangesInformation
const& aChanges
)
1059 if (aChanges
.empty()) return;
1061 ApiTreeRef
pRootTree( m_aNotifierData
.second
->getRootTreeImpl() );
1064 vos::ORef
<NotifierImpl
> aRootNotifier
= BroadcasterHelper::getImpl(pRootTree
->getNotifier());
1065 if (aRootNotifier
.isValid())
1067 uno::Reference
< css::util::XChangesListener
> const * const pSelect
= 0;
1069 configuration::NodeID aNotifiedNode
= makeRootID( pRootTree
);
1071 if (cppu::OInterfaceContainerHelper
* pContainer
= aRootNotifier
->m_aListeners
.getContainer(aNotifiedNode
.toIndex(), ::getCppuType(pSelect
)) )
1073 css::util::ChangesEvent aEvent
;
1074 aEvent
.Source
= pRootTree
->getUnoInstance();
1076 uno::Reference
<uno::XInterface
> xBaseInstance
= m_aNotifierData
.second
->getUnoInstance();
1077 aEvent
.Base
<<= xBaseInstance
;
1079 // translate and collect the changes
1080 aEvent
.Changes
.realloc(aChanges
.size());
1081 css::util::ElementChange
* pChange
= aEvent
.Changes
.getArray();
1083 for (std::vector
< configuration::NodeChangeInformation
>::const_iterator it
= aChanges
.begin(); it
!= aChanges
.end(); ++it
)
1085 fillChangeFromResolved(*pChange
, *it
);
1090 ListenerContainerIterator
< css::util::XChangesListener
> aIter(*pContainer
);
1092 UnoApiLockReleaser aGuardReleaser
;
1093 while (aIter
.hasMoreElements())
1094 try { aIter
.next()->changesOccurred(aEvent
); } catch (uno::Exception
& ) {}
1100 // ---------------------------------------------------------------------------------------------------
1101 // class Broadcaster
1102 // ---------------------------------------------------------------------------------------------------
1103 Broadcaster::Broadcaster(Notifier
const& aNotifier
, configuration::NodeChange
const& aChange
, bool bLocal
)
1104 : m_pImpl( Impl::create(aNotifier
.m_aImpl
,ApiTreeRef(aNotifier
.m_pTree
),aChange
,bLocal
) )
1106 OSL_ASSERT(m_pImpl
.isValid());
1108 // ---------------------------------------------------------------------------------------------------
1109 Broadcaster::Broadcaster(Notifier
const& aNotifier
, configuration::NodeChanges
const& aChanges
, bool bLocal
)
1110 : m_pImpl( Impl::create(aNotifier
.m_aImpl
,ApiTreeRef(aNotifier
.m_pTree
),aChanges
,bLocal
) )
1112 OSL_ASSERT(m_pImpl
.isValid());
1114 // ---------------------------------------------------------------------------------------------------
1115 Broadcaster::Broadcaster(Notifier
const& aNotifier
, configuration::NodeChangesInformation
const& aChanges
, bool bLocal
)
1116 : m_pImpl( Impl::create(aNotifier
.m_aImpl
,ApiTreeRef(aNotifier
.m_pTree
),aChanges
,bLocal
) )
1118 OSL_ASSERT(m_pImpl
.isValid());
1120 // ---------------------------------------------------------------------------------------------------
1122 Broadcaster::Broadcaster(Broadcaster
const& aOther
)
1123 : m_pImpl(aOther
.m_pImpl
)
1125 OSL_ASSERT(m_pImpl
.isValid());
1127 // ---------------------------------------------------------------------------------------------------
1129 Broadcaster::~Broadcaster()
1132 // ---------------------------------------------------------------------------------------------------
1134 void Broadcaster::queryConstraints(configuration::NodeChange
const& aChange
) throw(beans::PropertyVetoException
)
1136 OSL_ENSURE(aChange
.isChange(),"Constraint query without a change !");
1138 configuration::NodeChanges aChanges
;
1139 aChanges
.add(aChange
);
1140 this->queryConstraints(aChanges
,true);
1142 // ---------------------------------------------------------------------------------------------------
1144 void Broadcaster::queryConstraints(configuration::NodeChanges
const& aChanges
, bool bSingleBase
) throw(beans::PropertyVetoException
)
1146 OSL_ENSURE(!aChanges
.isEmpty(),"Constraint query without a change !");
1150 configuration::NodeChangesInformation aInfos
;
1151 if (m_pImpl
->translateChanges(aInfos
,aChanges
,bSingleBase
))
1153 m_pImpl
->queryConstraints(aInfos
);
1156 catch (beans::PropertyVetoException
& )
1160 catch (uno::Exception
& )
1162 OSL_ENSURE(false, "configmgr::Broadcaster: Unexpected UNO exception in notifyListeners");
1164 catch (configuration::Exception
& )
1166 OSL_ENSURE(false, "configmgr::Broadcaster: Unexpected internal exception in notifyListeners");
1169 // ---------------------------------------------------------------------------------------------------
1171 void Broadcaster::notifyListeners(configuration::NodeChange
const& aChange
) throw()
1173 OSL_ENSURE(aChange
.isChange(),"Notifying without a change !");
1175 configuration::NodeChanges aChanges
;
1176 aChanges
.add(aChange
);
1177 this->notifyListeners(aChanges
, true);
1179 // ---------------------------------------------------------------------------------------------------
1181 void Broadcaster::notifyListeners(configuration::NodeChanges
const& aChanges
, bool bSingleBase
) throw()
1183 OSL_ENSURE(!aChanges
.isEmpty(),"Notifying without a change !");
1187 configuration::NodeChangesInformation aInfos
;
1188 if (m_pImpl
->translateChanges(aInfos
,aChanges
, bSingleBase
))
1190 m_pImpl
->notifyListeners(aInfos
);
1191 m_pImpl
->notifyRootListeners(aInfos
);
1194 catch (uno::Exception
& )
1196 OSL_ENSURE(false, "configmgr::Broadcaster: Unexpected UNO exception in notifyListeners");
1198 catch (configuration::Exception
& )
1200 OSL_ENSURE(false, "configmgr::Broadcaster: Unexpected internal exception in notifyListeners");
1203 // ---------------------------------------------------------------------------------------------------
1205 void Broadcaster::notifyListeners(configuration::NodeChangesInformation
const& aChanges
, bool bSingleBase
) throw()
1207 OSL_ENSURE(!aChanges
.empty(),"Notifying without a change !");
1211 configuration::NodeChangesInformation aInfos
;
1212 if (m_pImpl
->translateChanges(aInfos
,aChanges
, bSingleBase
))
1214 m_pImpl
->notifyListeners(aInfos
);
1215 m_pImpl
->notifyRootListeners(aInfos
);
1218 catch (uno::Exception
& )
1220 OSL_ENSURE(false, "configmgr::Broadcaster: Unexpected UNO exception in notifyListeners");
1222 catch (configuration::Exception
& )
1224 OSL_ENSURE(false, "configmgr::Broadcaster: Unexpected internal exception in notifyListeners");
1227 // ---------------------------------------------------------------------------------------------------