1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 <cppuhelper/supportsservice.hxx>
22 #include <cppuhelper/weak.hxx>
23 #include <com/sun/star/uno/XComponentContext.hpp>
26 namespace filter::config
{
28 ConfigFlush::ConfigFlush()
32 ConfigFlush::~ConfigFlush()
36 OUString SAL_CALL
ConfigFlush::getImplementationName()
38 return "com.sun.star.comp.filter.config.ConfigFlush";
42 sal_Bool SAL_CALL
ConfigFlush::supportsService(const OUString
& sServiceName
)
44 return cppu::supportsService(this, sServiceName
);
47 css::uno::Sequence
< OUString
> SAL_CALL
ConfigFlush::getSupportedServiceNames()
49 return { "com.sun.star.document.FilterConfigRefresh" };
52 void SAL_CALL
ConfigFlush::refresh()
54 // notify listener outside the lock!
55 // The used listener helper lives if we live
56 // and is threadsafe by itself.
57 // Further it's not a good idea to hold the own lock
58 // if an outside object is called :-)
59 std::unique_lock
g(m_aMutex
);
60 if (!m_aRefreshListeners
.getLength(g
))
62 css::lang::EventObject
aSource(static_cast< css::util::XRefreshable
* >(this));
63 m_aRefreshListeners
.notifyEach(g
, &css::util::XRefreshListener::refreshed
, aSource
);
67 void SAL_CALL
ConfigFlush::addRefreshListener(const css::uno::Reference
< css::util::XRefreshListener
>& xListener
)
69 std::unique_lock
g(m_aMutex
);
70 m_aRefreshListeners
.addInterface(g
, xListener
);
74 void SAL_CALL
ConfigFlush::removeRefreshListener(const css::uno::Reference
< css::util::XRefreshListener
>& xListener
)
76 std::unique_lock
g(m_aMutex
);
77 m_aRefreshListeners
.removeInterface(g
, xListener
);
81 } // namespace filter::config
83 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
84 filter_ConfigFlush_get_implementation(
85 css::uno::XComponentContext
* , css::uno::Sequence
<css::uno::Any
> const&)
87 return cppu::acquire(new filter::config::ConfigFlush());
90 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */