1*b1cdbd2cSJim Jagielski /**************************************************************
2*b1cdbd2cSJim Jagielski *
3*b1cdbd2cSJim Jagielski * Licensed to the Apache Software Foundation (ASF) under one
4*b1cdbd2cSJim Jagielski * or more contributor license agreements. See the NOTICE file
5*b1cdbd2cSJim Jagielski * distributed with this work for additional information
6*b1cdbd2cSJim Jagielski * regarding copyright ownership. The ASF licenses this file
7*b1cdbd2cSJim Jagielski * to you under the Apache License, Version 2.0 (the
8*b1cdbd2cSJim Jagielski * "License"); you may not use this file except in compliance
9*b1cdbd2cSJim Jagielski * with the License. You may obtain a copy of the License at
10*b1cdbd2cSJim Jagielski *
11*b1cdbd2cSJim Jagielski * http://www.apache.org/licenses/LICENSE-2.0
12*b1cdbd2cSJim Jagielski *
13*b1cdbd2cSJim Jagielski * Unless required by applicable law or agreed to in writing,
14*b1cdbd2cSJim Jagielski * software distributed under the License is distributed on an
15*b1cdbd2cSJim Jagielski * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*b1cdbd2cSJim Jagielski * KIND, either express or implied. See the License for the
17*b1cdbd2cSJim Jagielski * specific language governing permissions and limitations
18*b1cdbd2cSJim Jagielski * under the License.
19*b1cdbd2cSJim Jagielski *
20*b1cdbd2cSJim Jagielski *************************************************************/
21*b1cdbd2cSJim Jagielski
22*b1cdbd2cSJim Jagielski #include "precompiled_framework.hxx"
23*b1cdbd2cSJim Jagielski
24*b1cdbd2cSJim Jagielski #include "services/ContextChangeEventMultiplexer.hxx"
25*b1cdbd2cSJim Jagielski #include "services.h"
26*b1cdbd2cSJim Jagielski
27*b1cdbd2cSJim Jagielski using ::rtl::OUString;
28*b1cdbd2cSJim Jagielski
29*b1cdbd2cSJim Jagielski #define A2S(s) ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(s))
30*b1cdbd2cSJim Jagielski
31*b1cdbd2cSJim Jagielski using namespace css;
32*b1cdbd2cSJim Jagielski using namespace cssu;
33*b1cdbd2cSJim Jagielski
34*b1cdbd2cSJim Jagielski namespace framework {
35*b1cdbd2cSJim Jagielski
36*b1cdbd2cSJim Jagielski #define IMPLEMENTATION_NAME "org.apache.openoffice.comp.framework.ContextChangeEventMultiplexer"
37*b1cdbd2cSJim Jagielski #define SERVICE_NAME "com.sun.star.ui.ContextChangeEventMultiplexer"
38*b1cdbd2cSJim Jagielski #define SINGLETON_NAME "org.apache.openoffice.comp.framework.ContextChangeEventMultiplexerSigleton"
39*b1cdbd2cSJim Jagielski
40*b1cdbd2cSJim Jagielski
ContextChangeEventMultiplexer(const cssu::Reference<cssu::XComponentContext> & rxContext)41*b1cdbd2cSJim Jagielski ContextChangeEventMultiplexer::ContextChangeEventMultiplexer (
42*b1cdbd2cSJim Jagielski const cssu::Reference<cssu::XComponentContext>& rxContext)
43*b1cdbd2cSJim Jagielski : ContextChangeEventMultiplexerInterfaceBase(m_aMutex),
44*b1cdbd2cSJim Jagielski maListeners()
45*b1cdbd2cSJim Jagielski {
46*b1cdbd2cSJim Jagielski (void)rxContext;
47*b1cdbd2cSJim Jagielski }
48*b1cdbd2cSJim Jagielski
49*b1cdbd2cSJim Jagielski
50*b1cdbd2cSJim Jagielski
51*b1cdbd2cSJim Jagielski
~ContextChangeEventMultiplexer(void)52*b1cdbd2cSJim Jagielski ContextChangeEventMultiplexer::~ContextChangeEventMultiplexer (void)
53*b1cdbd2cSJim Jagielski {
54*b1cdbd2cSJim Jagielski }
55*b1cdbd2cSJim Jagielski
56*b1cdbd2cSJim Jagielski
57*b1cdbd2cSJim Jagielski
58*b1cdbd2cSJim Jagielski
disposing(void)59*b1cdbd2cSJim Jagielski void SAL_CALL ContextChangeEventMultiplexer::disposing (void)
60*b1cdbd2cSJim Jagielski {
61*b1cdbd2cSJim Jagielski ListenerMap aListeners;
62*b1cdbd2cSJim Jagielski aListeners.swap(maListeners);
63*b1cdbd2cSJim Jagielski
64*b1cdbd2cSJim Jagielski cssu::Reference<cssu::XInterface> xThis (static_cast<XWeak*>(this));
65*b1cdbd2cSJim Jagielski css::lang::EventObject aEvent (xThis);
66*b1cdbd2cSJim Jagielski for (ListenerMap::const_iterator iContainer(aListeners.begin()), iEnd(aListeners.end());
67*b1cdbd2cSJim Jagielski iContainer!=iEnd;
68*b1cdbd2cSJim Jagielski ++iContainer)
69*b1cdbd2cSJim Jagielski {
70*b1cdbd2cSJim Jagielski // Unregister from the focus object.
71*b1cdbd2cSJim Jagielski Reference<lang::XComponent> xComponent (iContainer->first, UNO_QUERY);
72*b1cdbd2cSJim Jagielski if (xComponent.is())
73*b1cdbd2cSJim Jagielski xComponent->removeEventListener(this);
74*b1cdbd2cSJim Jagielski
75*b1cdbd2cSJim Jagielski // Tell all listeners that we are being disposed.
76*b1cdbd2cSJim Jagielski const FocusDescriptor& rFocusDescriptor (iContainer->second);
77*b1cdbd2cSJim Jagielski for (ListenerContainer::const_iterator
78*b1cdbd2cSJim Jagielski iListener(rFocusDescriptor.maListeners.begin()),
79*b1cdbd2cSJim Jagielski iContainerEnd(rFocusDescriptor.maListeners.end());
80*b1cdbd2cSJim Jagielski iListener!=iContainerEnd;
81*b1cdbd2cSJim Jagielski ++iListener)
82*b1cdbd2cSJim Jagielski {
83*b1cdbd2cSJim Jagielski (*iListener)->disposing(aEvent);
84*b1cdbd2cSJim Jagielski }
85*b1cdbd2cSJim Jagielski }
86*b1cdbd2cSJim Jagielski }
87*b1cdbd2cSJim Jagielski
88*b1cdbd2cSJim Jagielski
89*b1cdbd2cSJim Jagielski
90*b1cdbd2cSJim Jagielski
91*b1cdbd2cSJim Jagielski // XContextChangeEventMultiplexer
92*b1cdbd2cSJim Jagielski
addContextChangeEventListener(const cssu::Reference<css::ui::XContextChangeEventListener> & rxListener,const cssu::Reference<cssu::XInterface> & rxEventFocus)93*b1cdbd2cSJim Jagielski void SAL_CALL ContextChangeEventMultiplexer::addContextChangeEventListener (
94*b1cdbd2cSJim Jagielski const cssu::Reference<css::ui::XContextChangeEventListener>& rxListener,
95*b1cdbd2cSJim Jagielski const cssu::Reference<cssu::XInterface>& rxEventFocus)
96*b1cdbd2cSJim Jagielski throw(cssu::RuntimeException,cssl::IllegalArgumentException)
97*b1cdbd2cSJim Jagielski {
98*b1cdbd2cSJim Jagielski if ( ! rxListener.is())
99*b1cdbd2cSJim Jagielski throw css::lang::IllegalArgumentException(
100*b1cdbd2cSJim Jagielski A2S("can not add an empty reference"),
101*b1cdbd2cSJim Jagielski static_cast<XWeak*>(this),
102*b1cdbd2cSJim Jagielski 0);
103*b1cdbd2cSJim Jagielski
104*b1cdbd2cSJim Jagielski FocusDescriptor* pFocusDescriptor = GetFocusDescriptor(rxEventFocus, true);
105*b1cdbd2cSJim Jagielski if (pFocusDescriptor != NULL)
106*b1cdbd2cSJim Jagielski {
107*b1cdbd2cSJim Jagielski ListenerContainer& rContainer (pFocusDescriptor->maListeners);
108*b1cdbd2cSJim Jagielski if (::std::find(rContainer.begin(), rContainer.end(), rxListener) == rContainer.end())
109*b1cdbd2cSJim Jagielski rContainer.push_back(rxListener);
110*b1cdbd2cSJim Jagielski else
111*b1cdbd2cSJim Jagielski {
112*b1cdbd2cSJim Jagielski // The listener was added for the same event focus
113*b1cdbd2cSJim Jagielski // previously. That is an error.
114*b1cdbd2cSJim Jagielski throw cssl::IllegalArgumentException(A2S("listener added twice"), static_cast<XWeak*>(this), 0);
115*b1cdbd2cSJim Jagielski }
116*b1cdbd2cSJim Jagielski }
117*b1cdbd2cSJim Jagielski
118*b1cdbd2cSJim Jagielski // Send out an initial event that informs the new listener about
119*b1cdbd2cSJim Jagielski // the current context.
120*b1cdbd2cSJim Jagielski if (rxEventFocus.is() && pFocusDescriptor!=NULL)
121*b1cdbd2cSJim Jagielski {
122*b1cdbd2cSJim Jagielski css::ui::ContextChangeEventObject aEvent (
123*b1cdbd2cSJim Jagielski NULL,
124*b1cdbd2cSJim Jagielski pFocusDescriptor->msCurrentApplicationName,
125*b1cdbd2cSJim Jagielski pFocusDescriptor->msCurrentContextName);
126*b1cdbd2cSJim Jagielski rxListener->notifyContextChangeEvent(aEvent);
127*b1cdbd2cSJim Jagielski }
128*b1cdbd2cSJim Jagielski }
129*b1cdbd2cSJim Jagielski
130*b1cdbd2cSJim Jagielski
131*b1cdbd2cSJim Jagielski
132*b1cdbd2cSJim Jagielski
removeContextChangeEventListener(const cssu::Reference<css::ui::XContextChangeEventListener> & rxListener,const cssu::Reference<cssu::XInterface> & rxEventFocus)133*b1cdbd2cSJim Jagielski void SAL_CALL ContextChangeEventMultiplexer::removeContextChangeEventListener (
134*b1cdbd2cSJim Jagielski const cssu::Reference<css::ui::XContextChangeEventListener>& rxListener,
135*b1cdbd2cSJim Jagielski const cssu::Reference<cssu::XInterface>& rxEventFocus)
136*b1cdbd2cSJim Jagielski throw(cssu::RuntimeException,cssl::IllegalArgumentException)
137*b1cdbd2cSJim Jagielski {
138*b1cdbd2cSJim Jagielski if ( ! rxListener.is())
139*b1cdbd2cSJim Jagielski throw cssl::IllegalArgumentException(
140*b1cdbd2cSJim Jagielski A2S("can not remove an empty reference"),
141*b1cdbd2cSJim Jagielski static_cast<XWeak*>(this), 0);
142*b1cdbd2cSJim Jagielski
143*b1cdbd2cSJim Jagielski FocusDescriptor* pFocusDescriptor = GetFocusDescriptor(rxEventFocus, false);
144*b1cdbd2cSJim Jagielski if (pFocusDescriptor != NULL)
145*b1cdbd2cSJim Jagielski {
146*b1cdbd2cSJim Jagielski ListenerContainer& rContainer (pFocusDescriptor->maListeners);
147*b1cdbd2cSJim Jagielski const ListenerContainer::iterator iListener (
148*b1cdbd2cSJim Jagielski ::std::find(rContainer.begin(), rContainer.end(), rxListener));
149*b1cdbd2cSJim Jagielski if (iListener != rContainer.end())
150*b1cdbd2cSJim Jagielski {
151*b1cdbd2cSJim Jagielski rContainer.erase(iListener);
152*b1cdbd2cSJim Jagielski
153*b1cdbd2cSJim Jagielski // We hold on to the focus descriptor even when the last listener has been removed.
154*b1cdbd2cSJim Jagielski // This allows us to keep track of the current context and send it to new listeners.
155*b1cdbd2cSJim Jagielski }
156*b1cdbd2cSJim Jagielski }
157*b1cdbd2cSJim Jagielski
158*b1cdbd2cSJim Jagielski }
159*b1cdbd2cSJim Jagielski
160*b1cdbd2cSJim Jagielski
161*b1cdbd2cSJim Jagielski
162*b1cdbd2cSJim Jagielski
removeAllContextChangeEventListeners(const cssu::Reference<css::ui::XContextChangeEventListener> & rxListener)163*b1cdbd2cSJim Jagielski void SAL_CALL ContextChangeEventMultiplexer::removeAllContextChangeEventListeners (
164*b1cdbd2cSJim Jagielski const cssu::Reference<css::ui::XContextChangeEventListener>& rxListener)
165*b1cdbd2cSJim Jagielski throw(cssu::RuntimeException,cssl::IllegalArgumentException)
166*b1cdbd2cSJim Jagielski {
167*b1cdbd2cSJim Jagielski if ( ! rxListener.is())
168*b1cdbd2cSJim Jagielski throw cssl::IllegalArgumentException(
169*b1cdbd2cSJim Jagielski A2S("can not remove an empty reference"),
170*b1cdbd2cSJim Jagielski static_cast<XWeak*>(this), 0);
171*b1cdbd2cSJim Jagielski
172*b1cdbd2cSJim Jagielski for (ListenerMap::iterator
173*b1cdbd2cSJim Jagielski iContainer(maListeners.begin()),
174*b1cdbd2cSJim Jagielski iEnd(maListeners.end());
175*b1cdbd2cSJim Jagielski iContainer!=iEnd;
176*b1cdbd2cSJim Jagielski ++iContainer)
177*b1cdbd2cSJim Jagielski {
178*b1cdbd2cSJim Jagielski const ListenerContainer::iterator iListener (
179*b1cdbd2cSJim Jagielski ::std::find(iContainer->second.maListeners.begin(), iContainer->second.maListeners.end(), rxListener));
180*b1cdbd2cSJim Jagielski if (iListener != iContainer->second.maListeners.end())
181*b1cdbd2cSJim Jagielski {
182*b1cdbd2cSJim Jagielski iContainer->second.maListeners.erase(iListener);
183*b1cdbd2cSJim Jagielski
184*b1cdbd2cSJim Jagielski // We hold on to the focus descriptor even when the last listener has been removed.
185*b1cdbd2cSJim Jagielski // This allows us to keep track of the current context and send it to new listeners.
186*b1cdbd2cSJim Jagielski }
187*b1cdbd2cSJim Jagielski }
188*b1cdbd2cSJim Jagielski }
189*b1cdbd2cSJim Jagielski
190*b1cdbd2cSJim Jagielski
191*b1cdbd2cSJim Jagielski
192*b1cdbd2cSJim Jagielski
broadcastContextChangeEvent(const css::ui::ContextChangeEventObject & rEventObject,const cssu::Reference<cssu::XInterface> & rxEventFocus)193*b1cdbd2cSJim Jagielski void SAL_CALL ContextChangeEventMultiplexer::broadcastContextChangeEvent (
194*b1cdbd2cSJim Jagielski const css::ui::ContextChangeEventObject& rEventObject,
195*b1cdbd2cSJim Jagielski const cssu::Reference<cssu::XInterface>& rxEventFocus)
196*b1cdbd2cSJim Jagielski throw(cssu::RuntimeException)
197*b1cdbd2cSJim Jagielski {
198*b1cdbd2cSJim Jagielski // Remember the current context.
199*b1cdbd2cSJim Jagielski if (rxEventFocus.is())
200*b1cdbd2cSJim Jagielski {
201*b1cdbd2cSJim Jagielski FocusDescriptor* pFocusDescriptor = GetFocusDescriptor(rxEventFocus, true);
202*b1cdbd2cSJim Jagielski if (pFocusDescriptor != NULL)
203*b1cdbd2cSJim Jagielski {
204*b1cdbd2cSJim Jagielski pFocusDescriptor->msCurrentApplicationName = rEventObject.ApplicationName;
205*b1cdbd2cSJim Jagielski pFocusDescriptor->msCurrentContextName = rEventObject.ContextName;
206*b1cdbd2cSJim Jagielski }
207*b1cdbd2cSJim Jagielski }
208*b1cdbd2cSJim Jagielski
209*b1cdbd2cSJim Jagielski BroadcastEventToSingleContainer(rEventObject, rxEventFocus);
210*b1cdbd2cSJim Jagielski if (rxEventFocus.is())
211*b1cdbd2cSJim Jagielski BroadcastEventToSingleContainer(rEventObject, NULL);
212*b1cdbd2cSJim Jagielski }
213*b1cdbd2cSJim Jagielski
214*b1cdbd2cSJim Jagielski
215*b1cdbd2cSJim Jagielski
216*b1cdbd2cSJim Jagielski
BroadcastEventToSingleContainer(const css::ui::ContextChangeEventObject & rEventObject,const cssu::Reference<cssu::XInterface> & rxEventFocus)217*b1cdbd2cSJim Jagielski void ContextChangeEventMultiplexer::BroadcastEventToSingleContainer (
218*b1cdbd2cSJim Jagielski const css::ui::ContextChangeEventObject& rEventObject,
219*b1cdbd2cSJim Jagielski const cssu::Reference<cssu::XInterface>& rxEventFocus)
220*b1cdbd2cSJim Jagielski {
221*b1cdbd2cSJim Jagielski FocusDescriptor* pFocusDescriptor = GetFocusDescriptor(rxEventFocus, false);
222*b1cdbd2cSJim Jagielski if (pFocusDescriptor != NULL)
223*b1cdbd2cSJim Jagielski {
224*b1cdbd2cSJim Jagielski // Create a copy of the listener container to avoid problems
225*b1cdbd2cSJim Jagielski // when one of the called listeners calls add... or remove...
226*b1cdbd2cSJim Jagielski ListenerContainer aContainer (pFocusDescriptor->maListeners);
227*b1cdbd2cSJim Jagielski for (ListenerContainer::const_iterator
228*b1cdbd2cSJim Jagielski iListener(aContainer.begin()),
229*b1cdbd2cSJim Jagielski iEnd(aContainer.end());
230*b1cdbd2cSJim Jagielski iListener!=iEnd;
231*b1cdbd2cSJim Jagielski ++iListener)
232*b1cdbd2cSJim Jagielski {
233*b1cdbd2cSJim Jagielski (*iListener)->notifyContextChangeEvent(rEventObject);
234*b1cdbd2cSJim Jagielski }
235*b1cdbd2cSJim Jagielski }
236*b1cdbd2cSJim Jagielski }
237*b1cdbd2cSJim Jagielski
238*b1cdbd2cSJim Jagielski
239*b1cdbd2cSJim Jagielski
240*b1cdbd2cSJim Jagielski
GetFocusDescriptor(const cssu::Reference<cssu::XInterface> & rxEventFocus,const bool bCreateWhenMissing)241*b1cdbd2cSJim Jagielski ContextChangeEventMultiplexer::FocusDescriptor* ContextChangeEventMultiplexer::GetFocusDescriptor (
242*b1cdbd2cSJim Jagielski const cssu::Reference<cssu::XInterface>& rxEventFocus,
243*b1cdbd2cSJim Jagielski const bool bCreateWhenMissing)
244*b1cdbd2cSJim Jagielski {
245*b1cdbd2cSJim Jagielski ListenerMap::iterator iDescriptor (maListeners.find(rxEventFocus));
246*b1cdbd2cSJim Jagielski if (iDescriptor == maListeners.end() && bCreateWhenMissing)
247*b1cdbd2cSJim Jagielski {
248*b1cdbd2cSJim Jagielski // Listen for the focus being disposed.
249*b1cdbd2cSJim Jagielski Reference<lang::XComponent> xComponent (rxEventFocus, UNO_QUERY);
250*b1cdbd2cSJim Jagielski if (xComponent.is())
251*b1cdbd2cSJim Jagielski xComponent->addEventListener(this);
252*b1cdbd2cSJim Jagielski
253*b1cdbd2cSJim Jagielski // Create a new listener container for the event focus.
254*b1cdbd2cSJim Jagielski iDescriptor = maListeners.insert(
255*b1cdbd2cSJim Jagielski ListenerMap::value_type(
256*b1cdbd2cSJim Jagielski rxEventFocus,
257*b1cdbd2cSJim Jagielski FocusDescriptor())).first;
258*b1cdbd2cSJim Jagielski }
259*b1cdbd2cSJim Jagielski if (iDescriptor != maListeners.end())
260*b1cdbd2cSJim Jagielski return &iDescriptor->second;
261*b1cdbd2cSJim Jagielski else
262*b1cdbd2cSJim Jagielski return NULL;
263*b1cdbd2cSJim Jagielski }
264*b1cdbd2cSJim Jagielski
265*b1cdbd2cSJim Jagielski
266*b1cdbd2cSJim Jagielski
267*b1cdbd2cSJim Jagielski
268*b1cdbd2cSJim Jagielski // XSingleComponentFactory
269*b1cdbd2cSJim Jagielski
createInstanceWithContext(const cssu::Reference<cssu::XComponentContext> & rxContext)270*b1cdbd2cSJim Jagielski cssu::Reference<cssu::XInterface> SAL_CALL ContextChangeEventMultiplexer::createInstanceWithContext (
271*b1cdbd2cSJim Jagielski const cssu::Reference<cssu::XComponentContext>& rxContext)
272*b1cdbd2cSJim Jagielski throw (cssu::Exception, cssu::RuntimeException)
273*b1cdbd2cSJim Jagielski {
274*b1cdbd2cSJim Jagielski (void)rxContext;
275*b1cdbd2cSJim Jagielski return cssu::Reference<cssu::XInterface>();
276*b1cdbd2cSJim Jagielski }
277*b1cdbd2cSJim Jagielski
278*b1cdbd2cSJim Jagielski
279*b1cdbd2cSJim Jagielski
280*b1cdbd2cSJim Jagielski
createInstanceWithArgumentsAndContext(const cssu::Sequence<cssu::Any> & rArguments,const cssu::Reference<cssu::XComponentContext> & rxContext)281*b1cdbd2cSJim Jagielski cssu::Reference<cssu::XInterface > SAL_CALL ContextChangeEventMultiplexer::createInstanceWithArgumentsAndContext (
282*b1cdbd2cSJim Jagielski const cssu::Sequence<cssu::Any>& rArguments,
283*b1cdbd2cSJim Jagielski const cssu::Reference<cssu::XComponentContext>& rxContext)
284*b1cdbd2cSJim Jagielski throw (cssu::Exception, cssu::RuntimeException)
285*b1cdbd2cSJim Jagielski {
286*b1cdbd2cSJim Jagielski (void)rArguments;
287*b1cdbd2cSJim Jagielski (void)rxContext;
288*b1cdbd2cSJim Jagielski return cssu::Reference<cssu::XInterface>();
289*b1cdbd2cSJim Jagielski }
290*b1cdbd2cSJim Jagielski
291*b1cdbd2cSJim Jagielski
292*b1cdbd2cSJim Jagielski
293*b1cdbd2cSJim Jagielski
294*b1cdbd2cSJim Jagielski // XServiceInfo
295*b1cdbd2cSJim Jagielski
getImplementationName(void)296*b1cdbd2cSJim Jagielski ::rtl::OUString SAL_CALL ContextChangeEventMultiplexer::getImplementationName (void)
297*b1cdbd2cSJim Jagielski throw(cssu::RuntimeException)
298*b1cdbd2cSJim Jagielski {
299*b1cdbd2cSJim Jagielski return impl_getStaticImplementationName();
300*b1cdbd2cSJim Jagielski }
301*b1cdbd2cSJim Jagielski
302*b1cdbd2cSJim Jagielski
303*b1cdbd2cSJim Jagielski
304*b1cdbd2cSJim Jagielski
305*b1cdbd2cSJim Jagielski
supportsService(const::rtl::OUString & rsServiceName)306*b1cdbd2cSJim Jagielski sal_Bool SAL_CALL ContextChangeEventMultiplexer::supportsService (
307*b1cdbd2cSJim Jagielski const ::rtl::OUString& rsServiceName)
308*b1cdbd2cSJim Jagielski throw (cssu::RuntimeException)
309*b1cdbd2cSJim Jagielski {
310*b1cdbd2cSJim Jagielski return ::comphelper::findValue(static_GetSupportedServiceNames(), rsServiceName, sal_True).getLength() != 0;
311*b1cdbd2cSJim Jagielski }
312*b1cdbd2cSJim Jagielski
313*b1cdbd2cSJim Jagielski
314*b1cdbd2cSJim Jagielski
315*b1cdbd2cSJim Jagielski
getSupportedServiceNames(void)316*b1cdbd2cSJim Jagielski cssu::Sequence<OUString> SAL_CALL ContextChangeEventMultiplexer::getSupportedServiceNames (void)
317*b1cdbd2cSJim Jagielski throw (cssu::RuntimeException)
318*b1cdbd2cSJim Jagielski {
319*b1cdbd2cSJim Jagielski return static_GetSupportedServiceNames();
320*b1cdbd2cSJim Jagielski }
321*b1cdbd2cSJim Jagielski
322*b1cdbd2cSJim Jagielski
323*b1cdbd2cSJim Jagielski
324*b1cdbd2cSJim Jagielski
disposing(const css::lang::EventObject & rEvent)325*b1cdbd2cSJim Jagielski void SAL_CALL ContextChangeEventMultiplexer::disposing (
326*b1cdbd2cSJim Jagielski const css::lang::EventObject& rEvent)
327*b1cdbd2cSJim Jagielski throw (cssu::RuntimeException)
328*b1cdbd2cSJim Jagielski {
329*b1cdbd2cSJim Jagielski ListenerMap::iterator iDescriptor (maListeners.find(rEvent.Source));
330*b1cdbd2cSJim Jagielski
331*b1cdbd2cSJim Jagielski if (iDescriptor == maListeners.end())
332*b1cdbd2cSJim Jagielski {
333*b1cdbd2cSJim Jagielski OSL_ASSERT(iDescriptor != maListeners.end());
334*b1cdbd2cSJim Jagielski return;
335*b1cdbd2cSJim Jagielski }
336*b1cdbd2cSJim Jagielski
337*b1cdbd2cSJim Jagielski // Should we notify the remaining listeners?
338*b1cdbd2cSJim Jagielski
339*b1cdbd2cSJim Jagielski maListeners.erase(iDescriptor);
340*b1cdbd2cSJim Jagielski }
341*b1cdbd2cSJim Jagielski
342*b1cdbd2cSJim Jagielski
343*b1cdbd2cSJim Jagielski
344*b1cdbd2cSJim Jagielski
345*b1cdbd2cSJim Jagielski // Local and static methods.
346*b1cdbd2cSJim Jagielski
impl_getStaticImplementationName(void)347*b1cdbd2cSJim Jagielski OUString SAL_CALL ContextChangeEventMultiplexer::impl_getStaticImplementationName (void)
348*b1cdbd2cSJim Jagielski {
349*b1cdbd2cSJim Jagielski return A2S(IMPLEMENTATION_NAME);
350*b1cdbd2cSJim Jagielski }
351*b1cdbd2cSJim Jagielski
352*b1cdbd2cSJim Jagielski
353*b1cdbd2cSJim Jagielski
354*b1cdbd2cSJim Jagielski
static_GetSupportedServiceNames(void)355*b1cdbd2cSJim Jagielski cssu::Sequence<OUString> SAL_CALL ContextChangeEventMultiplexer::static_GetSupportedServiceNames (void)
356*b1cdbd2cSJim Jagielski {
357*b1cdbd2cSJim Jagielski cssu::Sequence<OUString> aServiceNames (2);
358*b1cdbd2cSJim Jagielski aServiceNames[0] = A2S(SERVICE_NAME);
359*b1cdbd2cSJim Jagielski aServiceNames[1] = A2S(SINGLETON_NAME);
360*b1cdbd2cSJim Jagielski return aServiceNames;
361*b1cdbd2cSJim Jagielski }
362*b1cdbd2cSJim Jagielski
363*b1cdbd2cSJim Jagielski
364*b1cdbd2cSJim Jagielski
365*b1cdbd2cSJim Jagielski
impl_createFactory(const cssu::Reference<cssl::XMultiServiceFactory> & rxServiceManager)366*b1cdbd2cSJim Jagielski cssu::Reference<cssu::XInterface> ContextChangeEventMultiplexer::impl_createFactory (
367*b1cdbd2cSJim Jagielski const cssu::Reference<cssl::XMultiServiceFactory>& rxServiceManager)
368*b1cdbd2cSJim Jagielski {
369*b1cdbd2cSJim Jagielski (void)rxServiceManager;
370*b1cdbd2cSJim Jagielski return cppu::createSingleComponentFactory(
371*b1cdbd2cSJim Jagielski ContextChangeEventMultiplexer::static_CreateInstance,
372*b1cdbd2cSJim Jagielski ContextChangeEventMultiplexer::impl_getStaticImplementationName(),
373*b1cdbd2cSJim Jagielski ContextChangeEventMultiplexer::static_GetSupportedServiceNames()
374*b1cdbd2cSJim Jagielski );
375*b1cdbd2cSJim Jagielski }
376*b1cdbd2cSJim Jagielski
377*b1cdbd2cSJim Jagielski
378*b1cdbd2cSJim Jagielski
379*b1cdbd2cSJim Jagielski
static_CreateInstance(const cssu::Reference<cssu::XComponentContext> & rxComponentContext)380*b1cdbd2cSJim Jagielski cssu::Reference<cssu::XInterface> SAL_CALL ContextChangeEventMultiplexer::static_CreateInstance (
381*b1cdbd2cSJim Jagielski const cssu::Reference<cssu::XComponentContext>& rxComponentContext)
382*b1cdbd2cSJim Jagielski throw (cssu::Exception)
383*b1cdbd2cSJim Jagielski {
384*b1cdbd2cSJim Jagielski ContextChangeEventMultiplexer* pObject = new ContextChangeEventMultiplexer(rxComponentContext);
385*b1cdbd2cSJim Jagielski cssu::Reference<cssu::XInterface> xService (static_cast<XWeak*>(pObject), cssu::UNO_QUERY);
386*b1cdbd2cSJim Jagielski return xService;
387*b1cdbd2cSJim Jagielski }
388*b1cdbd2cSJim Jagielski
389*b1cdbd2cSJim Jagielski } // end of namespace framework
390