19e0fc027SAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
39e0fc027SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
49e0fc027SAndrew Rist * or more contributor license agreements. See the NOTICE file
59e0fc027SAndrew Rist * distributed with this work for additional information
69e0fc027SAndrew Rist * regarding copyright ownership. The ASF licenses this file
79e0fc027SAndrew Rist * to you under the Apache License, Version 2.0 (the
89e0fc027SAndrew Rist * "License"); you may not use this file except in compliance
99e0fc027SAndrew Rist * with the License. You may obtain a copy of the License at
109e0fc027SAndrew Rist *
119e0fc027SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
129e0fc027SAndrew Rist *
139e0fc027SAndrew Rist * Unless required by applicable law or agreed to in writing,
149e0fc027SAndrew Rist * software distributed under the License is distributed on an
159e0fc027SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
169e0fc027SAndrew Rist * KIND, either express or implied. See the License for the
179e0fc027SAndrew Rist * specific language governing permissions and limitations
189e0fc027SAndrew Rist * under the License.
199e0fc027SAndrew Rist *
209e0fc027SAndrew Rist *************************************************************/
219e0fc027SAndrew Rist
229e0fc027SAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_filter.hxx"
26cdf0e10cSrcweir
27cdf0e10cSrcweir #include "configflush.hxx"
28cdf0e10cSrcweir #include "constant.hxx"
29cdf0e10cSrcweir
30cdf0e10cSrcweir //_______________________________________________
31cdf0e10cSrcweir // includes
32cdf0e10cSrcweir #include <osl/diagnose.h>
33cdf0e10cSrcweir
34cdf0e10cSrcweir //_______________________________________________
35cdf0e10cSrcweir // namespace
36cdf0e10cSrcweir
37cdf0e10cSrcweir namespace css = ::com::sun::star;
38cdf0e10cSrcweir
39cdf0e10cSrcweir namespace filter{
40cdf0e10cSrcweir namespace config{
41cdf0e10cSrcweir
42cdf0e10cSrcweir //_______________________________________________
43cdf0e10cSrcweir // definitions
44cdf0e10cSrcweir
45cdf0e10cSrcweir //-----------------------------------------------
ConfigFlush(const css::uno::Reference<css::lang::XMultiServiceFactory> & xSMGR)46cdf0e10cSrcweir ConfigFlush::ConfigFlush(const css::uno::Reference< css::lang::XMultiServiceFactory >& xSMGR)
47cdf0e10cSrcweir : BaseLock ( )
48cdf0e10cSrcweir , m_xSMGR (xSMGR )
49cdf0e10cSrcweir , m_lListener(m_aLock)
50cdf0e10cSrcweir {
51cdf0e10cSrcweir }
52cdf0e10cSrcweir
53cdf0e10cSrcweir //-----------------------------------------------
~ConfigFlush()54cdf0e10cSrcweir ConfigFlush::~ConfigFlush()
55cdf0e10cSrcweir {
56cdf0e10cSrcweir }
57cdf0e10cSrcweir
58cdf0e10cSrcweir //-----------------------------------------------
getImplementationName()59cdf0e10cSrcweir ::rtl::OUString SAL_CALL ConfigFlush::getImplementationName()
60cdf0e10cSrcweir throw (css::uno::RuntimeException)
61cdf0e10cSrcweir {
62cdf0e10cSrcweir return impl_getImplementationName();
63cdf0e10cSrcweir // <- SAFE
64cdf0e10cSrcweir }
65cdf0e10cSrcweir
66cdf0e10cSrcweir //-----------------------------------------------
supportsService(const::rtl::OUString & sServiceName)67cdf0e10cSrcweir sal_Bool SAL_CALL ConfigFlush::supportsService(const ::rtl::OUString& sServiceName)
68cdf0e10cSrcweir throw (css::uno::RuntimeException)
69cdf0e10cSrcweir {
70cdf0e10cSrcweir css::uno::Sequence< ::rtl::OUString > lServiceNames = impl_getSupportedServiceNames();
71cdf0e10cSrcweir sal_Int32 c = lServiceNames.getLength();
72cdf0e10cSrcweir const ::rtl::OUString* pNames = lServiceNames.getConstArray();
73cdf0e10cSrcweir for (sal_Int32 i=0; i<c; ++i)
74cdf0e10cSrcweir {
75cdf0e10cSrcweir if (pNames[i].equals(sServiceName))
76cdf0e10cSrcweir return sal_True;
77cdf0e10cSrcweir }
78cdf0e10cSrcweir return sal_False;
79cdf0e10cSrcweir }
80cdf0e10cSrcweir
81cdf0e10cSrcweir //-----------------------------------------------
getSupportedServiceNames()82cdf0e10cSrcweir css::uno::Sequence< ::rtl::OUString > SAL_CALL ConfigFlush::getSupportedServiceNames()
83cdf0e10cSrcweir throw (css::uno::RuntimeException)
84cdf0e10cSrcweir {
85cdf0e10cSrcweir return impl_getSupportedServiceNames();
86cdf0e10cSrcweir }
87cdf0e10cSrcweir
88cdf0e10cSrcweir //-----------------------------------------------
refresh()89cdf0e10cSrcweir void SAL_CALL ConfigFlush::refresh()
90cdf0e10cSrcweir throw(css::uno::RuntimeException)
91cdf0e10cSrcweir {
92cdf0e10cSrcweir // notify listener outside the lock!
93cdf0e10cSrcweir // The used listener helper lives if we live
94cdf0e10cSrcweir // and is threadsafe by itself.
95cdf0e10cSrcweir // Further its not a good idea to hold the own lock
96cdf0e10cSrcweir // if an outside object is called :-)
97cdf0e10cSrcweir css::lang::EventObject aSource (static_cast< css::util::XRefreshable* >(this));
98cdf0e10cSrcweir ::cppu::OInterfaceContainerHelper* pContainer = m_lListener.getContainer(::getCppuType(static_cast< css::uno::Reference< css::util::XRefreshListener >* >(NULL)));
99cdf0e10cSrcweir if (pContainer)
100cdf0e10cSrcweir {
101cdf0e10cSrcweir ::cppu::OInterfaceIteratorHelper pIterator(*pContainer);
102cdf0e10cSrcweir while (pIterator.hasMoreElements())
103cdf0e10cSrcweir {
104cdf0e10cSrcweir try
105cdf0e10cSrcweir {
106cdf0e10cSrcweir // ... this pointer can be interesting to find out, where will be called as listener
107cdf0e10cSrcweir // Dont optimize it to a direct iterator cast :-)
108cdf0e10cSrcweir css::util::XRefreshListener* pListener = (css::util::XRefreshListener*)pIterator.next();
109cdf0e10cSrcweir pListener->refreshed(aSource);
110cdf0e10cSrcweir }
111cdf0e10cSrcweir catch(const css::uno::Exception&)
112cdf0e10cSrcweir {
113cdf0e10cSrcweir // ignore any "damaged" flush listener!
114cdf0e10cSrcweir // May its remote reference is broken ...
115cdf0e10cSrcweir pIterator.remove();
116cdf0e10cSrcweir }
117cdf0e10cSrcweir }
118cdf0e10cSrcweir }
119cdf0e10cSrcweir }
120cdf0e10cSrcweir
121cdf0e10cSrcweir //-----------------------------------------------
addRefreshListener(const css::uno::Reference<css::util::XRefreshListener> & xListener)122cdf0e10cSrcweir void SAL_CALL ConfigFlush::addRefreshListener(const css::uno::Reference< css::util::XRefreshListener >& xListener)
123cdf0e10cSrcweir throw(css::uno::RuntimeException)
124cdf0e10cSrcweir {
125*07a3d7f1SPedro Giffuni // no locks necessary
126cdf0e10cSrcweir // used helper lives if we live and is threadsafe by itself ...
127cdf0e10cSrcweir m_lListener.addInterface(::getCppuType(static_cast< css::uno::Reference< css::util::XRefreshListener >* >(NULL)),
128cdf0e10cSrcweir xListener);
129cdf0e10cSrcweir }
130cdf0e10cSrcweir
131cdf0e10cSrcweir //-----------------------------------------------
removeRefreshListener(const css::uno::Reference<css::util::XRefreshListener> & xListener)132cdf0e10cSrcweir void SAL_CALL ConfigFlush::removeRefreshListener(const css::uno::Reference< css::util::XRefreshListener >& xListener)
133cdf0e10cSrcweir throw(css::uno::RuntimeException)
134cdf0e10cSrcweir {
135*07a3d7f1SPedro Giffuni // no locks necessary
136cdf0e10cSrcweir // used helper lives if we live and is threadsafe by itself ...
137cdf0e10cSrcweir m_lListener.removeInterface(::getCppuType(static_cast< css::uno::Reference< css::util::XRefreshListener >* >(NULL)),
138cdf0e10cSrcweir xListener);
139cdf0e10cSrcweir }
140cdf0e10cSrcweir
141cdf0e10cSrcweir //-----------------------------------------------
impl_getImplementationName()142cdf0e10cSrcweir ::rtl::OUString ConfigFlush::impl_getImplementationName()
143cdf0e10cSrcweir {
144cdf0e10cSrcweir static ::rtl::OUString IMPLNAME = ::rtl::OUString::createFromAscii("com.sun.star.comp.filter.config.ConfigFlush");
145cdf0e10cSrcweir return IMPLNAME;
146cdf0e10cSrcweir }
147cdf0e10cSrcweir
148cdf0e10cSrcweir //-----------------------------------------------
impl_getSupportedServiceNames()149cdf0e10cSrcweir css::uno::Sequence< ::rtl::OUString > ConfigFlush::impl_getSupportedServiceNames()
150cdf0e10cSrcweir {
151cdf0e10cSrcweir css::uno::Sequence< ::rtl::OUString > lServiceNames(1);
152cdf0e10cSrcweir lServiceNames[0] = SERVICE_FILTERCONFIGREFRESH;
153cdf0e10cSrcweir return lServiceNames;
154cdf0e10cSrcweir }
155cdf0e10cSrcweir
156cdf0e10cSrcweir //-----------------------------------------------
impl_createInstance(const css::uno::Reference<css::lang::XMultiServiceFactory> & xSMGR)157cdf0e10cSrcweir css::uno::Reference< css::uno::XInterface > ConfigFlush::impl_createInstance(const css::uno::Reference< css::lang::XMultiServiceFactory >& xSMGR)
158cdf0e10cSrcweir {
159cdf0e10cSrcweir ConfigFlush* pNew = new ConfigFlush(xSMGR);
160cdf0e10cSrcweir return css::uno::Reference< css::uno::XInterface >(static_cast< css::util::XRefreshable* >(pNew), css::uno::UNO_QUERY);
161cdf0e10cSrcweir }
162cdf0e10cSrcweir
163cdf0e10cSrcweir } // namespace config
164cdf0e10cSrcweir } // namespace filter
165