Bump version to 5.0-14
[LibreOffice.git] / filter / source / config / cache / configflush.cxx
blob0f7d6ccefdebd2d84a8969427c81fac25e8fb826
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include "configflush.hxx"
21 #include "constant.hxx"
22 #include <cppuhelper/supportsservice.hxx>
24 #include <osl/diagnose.h>
26 namespace filter{
27 namespace config{
29 ConfigFlush::ConfigFlush(const css::uno::Reference< css::lang::XMultiServiceFactory >& xSMGR)
30 : BaseLock ( )
31 , m_xSMGR (xSMGR )
32 , m_lListener(m_aLock)
36 ConfigFlush::~ConfigFlush()
40 OUString SAL_CALL ConfigFlush::getImplementationName()
41 throw (css::uno::RuntimeException, std::exception)
43 return impl_getImplementationName();
44 // <- SAFE
47 sal_Bool SAL_CALL ConfigFlush::supportsService(const OUString& sServiceName)
48 throw (css::uno::RuntimeException, std::exception)
50 return cppu::supportsService(this, sServiceName);
53 css::uno::Sequence< OUString > SAL_CALL ConfigFlush::getSupportedServiceNames()
54 throw (css::uno::RuntimeException, std::exception)
56 return impl_getSupportedServiceNames();
59 void SAL_CALL ConfigFlush::refresh()
60 throw(css::uno::RuntimeException, std::exception)
62 // notify listener outside the lock!
63 // The used listener helper lives if we live
64 // and is threadsafe by itself.
65 // Further its not a good idea to hold the own lock
66 // if an outside object is called :-)
67 css::lang::EventObject aSource (static_cast< css::util::XRefreshable* >(this));
68 ::cppu::OInterfaceContainerHelper* pContainer = m_lListener.getContainer(cppu::UnoType<css::util::XRefreshListener>::get());
69 if (pContainer)
71 ::cppu::OInterfaceIteratorHelper pIterator(*pContainer);
72 while (pIterator.hasMoreElements())
74 try
76 // ... this pointer can be interesting to find out, where will be called as listener
77 // Dont optimize it to a direct iterator cast :-)
78 css::util::XRefreshListener* pListener = static_cast<css::util::XRefreshListener*>(pIterator.next());
79 pListener->refreshed(aSource);
81 catch(const css::uno::Exception&)
83 // ignore any "damaged" flush listener!
84 // May its remote reference is broken ...
85 pIterator.remove();
92 void SAL_CALL ConfigFlush::addRefreshListener(const css::uno::Reference< css::util::XRefreshListener >& xListener)
93 throw(css::uno::RuntimeException, std::exception)
95 // no locks necessary
96 // used helper lives if we live and is threadsafe by itself ...
97 m_lListener.addInterface(cppu::UnoType<css::util::XRefreshListener>::get(),
98 xListener);
102 void SAL_CALL ConfigFlush::removeRefreshListener(const css::uno::Reference< css::util::XRefreshListener >& xListener)
103 throw(css::uno::RuntimeException, std::exception)
105 // no locks necessary
106 // used helper lives if we live and is threadsafe by itself ...
107 m_lListener.removeInterface(cppu::UnoType<css::util::XRefreshListener>::get(),
108 xListener);
112 OUString ConfigFlush::impl_getImplementationName()
114 return OUString("com.sun.star.comp.filter.config.ConfigFlush");
118 css::uno::Sequence< OUString > ConfigFlush::impl_getSupportedServiceNames()
120 css::uno::Sequence< OUString > lServiceNames(1);
121 lServiceNames[0] = "com.sun.star.document.FilterConfigRefresh";
122 return lServiceNames;
126 css::uno::Reference< css::uno::XInterface > ConfigFlush::impl_createInstance(const css::uno::Reference< css::lang::XMultiServiceFactory >& xSMGR)
128 ConfigFlush* pNew = new ConfigFlush(xSMGR);
129 return css::uno::Reference< css::uno::XInterface >(static_cast< css::util::XRefreshable* >(pNew), css::uno::UNO_QUERY);
132 } // namespace config
133 } // namespace filter
135 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */