build fix
[LibreOffice.git] / sfx2 / source / bastyp / fltlst.cxx
blob046e0ee9fe6be37203f5529f2d710ca8d36a6c6b
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 .
21 #include "fltlst.hxx"
23 #include <com/sun/star/document/FilterConfigRefresh.hpp>
24 #include <comphelper/processfactory.hxx>
26 #include <sfx2/sfxuno.hxx>
27 #include <sfx2/docfac.hxx>
29 #include <vcl/svapp.hxx>
30 #include <osl/mutex.hxx>
31 #include <cppuhelper/implbase.hxx>
34 // namespaces
36 using namespace ::com::sun::star;
39 class SfxRefreshListener : public ::cppu::WeakImplHelper<css::util::XRefreshListener>
41 private:
42 SfxFilterListener *m_pOwner;
44 public:
45 explicit SfxRefreshListener(SfxFilterListener *pOwner)
46 : m_pOwner(pOwner)
50 virtual ~SfxRefreshListener() override
54 // util.XRefreshListener
55 virtual void SAL_CALL refreshed( const css::lang::EventObject& rEvent )
56 throw(css::uno::RuntimeException, std::exception) override
58 m_pOwner->refreshed(rEvent);
61 // lang.XEventListener
62 virtual void SAL_CALL disposing(const css::lang::EventObject& rEvent)
63 throw(css::uno::RuntimeException, std::exception) override
65 m_pOwner->disposing(rEvent);
69 /*-************************************************************************************************************
70 @short ctor
71 @descr These initialize an instance of a SfxFilterListener class. Created object listen automatically
72 on right FilterFactory-Service for all changes and synchronize right SfxFilterContainer with
73 corresponding framework-cache.
74 We use given "sFactory" value to decide which query must be used to fill "pContainer" with new values.
75 Given "pContainer" hold us alive as uno reference and we use it to synchronize it with framework caches.
76 We will die, if he die! see dtor for further information.
78 @seealso dtor
79 @seealso class framework::FilterCache
80 @seealso service ::document::FilterFactory
82 @param "sFactory" , short name of module which contains filter container
83 @param "pContainer", pointer to filter container which will be informed
84 @onerror We show some assertions in non product version.
85 Otherwise we do nothing!
86 @threadsafe yes
87 *//*-*************************************************************************************************************/
88 SfxFilterListener::SfxFilterListener()
90 m_xFilterCache = document::FilterConfigRefresh::create( comphelper::getProcessComponentContext() );
91 m_xFilterCacheListener = new SfxRefreshListener(this);
92 m_xFilterCache->addRefreshListener( m_xFilterCacheListener );
95 SfxFilterListener::~SfxFilterListener()
99 void SAL_CALL SfxFilterListener::refreshed( const lang::EventObject& aSource ) throw( uno::RuntimeException, std::exception )
101 SolarMutexGuard aGuard;
102 uno::Reference< util::XRefreshable > xContainer( aSource.Source, uno::UNO_QUERY );
104 (xContainer.is() ) &&
105 (xContainer==m_xFilterCache)
108 SfxFilterContainer::ReadFilters_Impl( true );
112 void SAL_CALL SfxFilterListener::disposing( const lang::EventObject& aSource ) throw( uno::RuntimeException )
114 SolarMutexGuard aGuard;
115 uno::Reference< util::XRefreshable > xNotifier( aSource.Source, uno::UNO_QUERY );
116 if (!xNotifier.is())
117 return;
119 if (xNotifier == m_xFilterCache)
120 m_xFilterCache.clear();
123 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */