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: confignotifier.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 "confignotifier.hxx"
36 #include "notifierimpl.hxx"
37 #include "broadcaster.hxx"
39 #include "noderef.hxx"
40 #include "valueref.hxx"
41 #include "nodechange.hxx"
43 #include "apinodeaccess.hxx"
44 #include "apitreeaccess.hxx"
45 #include "apitreeimplobj.hxx"
54 // ---------------------------------------------------------------------------------------------------
55 // class Notifier (-Impl)
56 // ---------------------------------------------------------------------------------------------------
58 Notifier::Notifier(vos::ORef
<NotifierImpl
> const& aImpl
,ApiTreeImpl
const* pTree
)
62 OSL_ENSURE(aImpl
.isValid(),"Invalid initialization of a Notifier: No impl");
63 OSL_ENSURE(pTree
,"Invalid initialization of a Notifier: No tree");
65 // ---------------------------------------------------------------------------------------------------
67 Notifier::Notifier(Notifier
const& aOther
)
68 : m_aImpl(aOther
.m_aImpl
)
69 , m_pTree(aOther
.m_pTree
)
72 // ---------------------------------------------------------------------------------------------------
77 // ---------------------------------------------------------------------------------------------------
79 Broadcaster
Notifier::makeBroadcaster(configuration::NodeChange
const& aChange
, bool bLocal
) const
81 return Broadcaster(*this,aChange
,bLocal
);
83 // ---------------------------------------------------------------------------------------------------
85 Broadcaster
Notifier::makeBroadcaster(configuration::NodeChanges
const& aChanges
, bool bLocal
) const
87 OSL_ENSURE(!aChanges
.isEmpty(),"Creating broadcaster for no changes");
88 return Broadcaster(*this,aChanges
,bLocal
);
90 // ---------------------------------------------------------------------------------------------------
92 NotifierImpl::NotifierImpl(rtl::Reference
< configuration::Tree
> const& aTree
)
93 : m_aListeners(aTree
->nodeCount(), SubNodeToIndex(aTree
))
96 // ---------------------------------------------------------------------------------------------------
98 NotifierImpl::~NotifierImpl()
102 // ---------------------------------------------------------------------------------------------------
104 void Notifier::add(configuration::NodeRef
const& aNode
, uno::Reference
< css::lang::XEventListener
> const& xListener
) const
107 m_aImpl
->add( configuration::NodeID(m_pTree
->getTree(),aNode
), xListener
);
109 // ---------------------------------------------------------------------------------------------------
111 void Notifier::add(configuration::NodeRef
const& aNode
, uno::Reference
< css::container::XContainerListener
> const& xListener
) const
114 m_aImpl
->add( configuration::NodeID(m_pTree
->getTree(),aNode
), xListener
);
116 // ---------------------------------------------------------------------------------------------------
118 void Notifier::add(configuration::NodeRef
const& aNode
, uno::Reference
< css::util::XChangesListener
> const& xListener
) const
121 m_aImpl
->add( configuration::NodeID(m_pTree
->getTree(),aNode
), xListener
);
123 // ---------------------------------------------------------------------------------------------------
125 void Notifier::addForAll(configuration::NodeRef
const& aNode
, uno::Reference
< css::beans::XPropertyChangeListener
> const& xListener
) const
128 m_aImpl
->addForAll( configuration::NodeID(m_pTree
->getTree(),aNode
), xListener
);
130 // ---------------------------------------------------------------------------------------------------
132 void Notifier::addForOne(configuration::NodeRef
const& aNode
, uno::Reference
< css::beans::XPropertyChangeListener
> const& xListener
, rtl::OUString
const& aName
) const
135 m_aImpl
->addNamed( configuration::SubNodeID(m_pTree
->getTree(),aNode
, aName
), xListener
);
137 // ---------------------------------------------------------------------------------------------------
139 void Notifier::addForAll(configuration::NodeRef
const& aNode
, uno::Reference
< css::beans::XVetoableChangeListener
> const& xListener
) const
142 m_aImpl
->addForAll( configuration::NodeID(m_pTree
->getTree(),aNode
), xListener
);
144 // ---------------------------------------------------------------------------------------------------
146 void Notifier::addForOne(configuration::NodeRef
const& aNode
, uno::Reference
< css::beans::XVetoableChangeListener
> const& xListener
, rtl::OUString
const& aName
) const
149 m_aImpl
->addNamed( configuration::SubNodeID(m_pTree
->getTree(),aNode
, aName
), xListener
);
151 // ---------------------------------------------------------------------------------------------------
153 void Notifier::add(configuration::NodeRef
const& aNode
, uno::Reference
< css::beans::XPropertiesChangeListener
> const& xListener
, uno::Sequence
<rtl::OUString
> const& aNames
) const
157 if (aNames
.getLength() > 0)
158 m_aImpl
->add( configuration::NodeID(m_pTree
->getTree(),aNode
), xListener
, aNames
);
160 m_aImpl
->add( configuration::NodeID(m_pTree
->getTree(),aNode
), xListener
);
163 // ---------------------------------------------------------------------------------------------------
165 void Notifier::remove(configuration::NodeRef
const& aNode
, uno::Reference
< css::lang::XEventListener
> const& xListener
) const
168 m_aImpl
->remove( configuration::NodeID(m_pTree
->getTree(),aNode
), xListener
);
170 // ---------------------------------------------------------------------------------------------------
172 void Notifier::remove(configuration::NodeRef
const& aNode
, uno::Reference
< css::container::XContainerListener
> const& xListener
) const
175 m_aImpl
->remove( configuration::NodeID(m_pTree
->getTree(),aNode
), xListener
);
177 // ---------------------------------------------------------------------------------------------------
179 void Notifier::remove(configuration::NodeRef
const& aNode
, uno::Reference
< css::util::XChangesListener
> const& xListener
) const
182 m_aImpl
->remove( configuration::NodeID(m_pTree
->getTree(),aNode
), xListener
);
184 // ---------------------------------------------------------------------------------------------------
186 void Notifier::removeForAll(configuration::NodeRef
const& aNode
, uno::Reference
< css::beans::XPropertyChangeListener
> const& xListener
) const
189 m_aImpl
->removeForAll( configuration::NodeID(m_pTree
->getTree(),aNode
), xListener
);
191 // ---------------------------------------------------------------------------------------------------
193 void Notifier::removeForOne(configuration::NodeRef
const& aNode
, uno::Reference
< css::beans::XPropertyChangeListener
> const& xListener
, rtl::OUString
const& aName
) const
196 m_aImpl
->removeNamed( configuration::SubNodeID(m_pTree
->getTree(),aNode
, aName
), xListener
);
198 // ---------------------------------------------------------------------------------------------------
200 void Notifier::removeForAll(configuration::NodeRef
const& aNode
, uno::Reference
< css::beans::XVetoableChangeListener
> const& xListener
) const
203 m_aImpl
->removeForAll( configuration::NodeID(m_pTree
->getTree(),aNode
), xListener
);
205 // ---------------------------------------------------------------------------------------------------
207 void Notifier::removeForOne(configuration::NodeRef
const& aNode
, uno::Reference
< css::beans::XVetoableChangeListener
> const& xListener
, rtl::OUString
const& aName
) const
210 m_aImpl
->removeNamed( configuration::SubNodeID(m_pTree
->getTree(),aNode
, aName
), xListener
);
212 // ---------------------------------------------------------------------------------------------------
214 void Notifier::remove(configuration::NodeRef
const& aNode
, uno::Reference
< css::beans::XPropertiesChangeListener
> const& xListener
) const
217 m_aImpl
->remove( configuration::NodeID(m_pTree
->getTree(),aNode
), xListener
);
220 // ---------------------------------------------------------------------------------------------------
221 // ---------------------------------------------------------------------------------------------------
223 DisposeGuardImpl::DisposeGuardImpl(Notifier
const&) throw()
226 // ---------------------------------------------------------------------------------------------------
227 DisposeGuardImpl::~DisposeGuardImpl() throw ()
230 // ---------------------------------------------------------------------------------------------------
231 GuardedNotifier::GuardedNotifier(NodeAccess
& rNode
) throw()
232 : m_aNotifier(rNode
.getNotifier())
233 , m_aImpl(m_aNotifier
)
236 // ---------------------------------------------------------------------------------------------------
238 DisposeGuard::DisposeGuard(NodeAccess
& rNode
) throw(css::lang::DisposedException
)
239 : m_aImpl(rNode
.getNotifier())
243 // ---------------------------------------------------------------------------------------------------