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 .
23 #include <com/sun/star/document/FilterConfigRefresh.hpp>
24 #include <comphelper/processfactory.hxx>
26 #include <sfx2/fcontnr.hxx>
28 #include <vcl/svapp.hxx>
29 #include <cppuhelper/implbase.hxx>
34 using namespace ::com::sun::star
;
38 class SfxRefreshListener
: public ::cppu::WeakImplHelper
<css::util::XRefreshListener
>
41 SfxFilterListener
*m_pOwner
;
44 explicit SfxRefreshListener(SfxFilterListener
*pOwner
)
49 // util.XRefreshListener
50 virtual void SAL_CALL
refreshed( const css::lang::EventObject
& rEvent
) override
52 m_pOwner
->refreshed(rEvent
);
55 // lang.XEventListener
56 virtual void SAL_CALL
disposing(const css::lang::EventObject
& rEvent
) override
58 m_pOwner
->disposing(rEvent
);
64 /*-************************************************************************************************************
66 @descr These initialize an instance of a SfxFilterListener class. Created object listen automatically
67 on right FilterFactory-Service for all changes and synchronize right SfxFilterContainer with
68 corresponding framework-cache.
69 We use given "sFactory" value to decide which query must be used to fill "pContainer" with new values.
70 Given "pContainer" hold us alive as uno reference and we use it to synchronize it with framework caches.
71 We will die, if he die! see dtor for further information.
74 @seealso class framework::FilterCache
75 @seealso service ::document::FilterFactory
77 @param "sFactory" , short name of module which contains filter container
78 @param "pContainer", pointer to filter container which will be informed
79 @onerror We show some assertions in non product version.
80 Otherwise we do nothing!
82 *//*-*************************************************************************************************************/
83 SfxFilterListener::SfxFilterListener()
84 : m_xFilterCache(document::FilterConfigRefresh::create( comphelper::getProcessComponentContext() ) ),
85 m_xFilterCacheListener(new SfxRefreshListener(this))
87 m_xFilterCache
->addRefreshListener( m_xFilterCacheListener
);
90 SfxFilterListener::~SfxFilterListener()
94 void SfxFilterListener::refreshed( const lang::EventObject
& aSource
)
96 SolarMutexGuard aGuard
;
97 uno::Reference
< util::XRefreshable
> xContainer( aSource
.Source
, uno::UNO_QUERY
);
100 (xContainer
==m_xFilterCache
)
103 SfxFilterContainer::ReadFilters_Impl( true );
107 void SfxFilterListener::disposing( const lang::EventObject
& aSource
)
109 SolarMutexGuard aGuard
;
110 uno::Reference
< util::XRefreshable
> xNotifier( aSource
.Source
, uno::UNO_QUERY
);
114 if (xNotifier
== m_xFilterCache
)
115 m_xFilterCache
.clear();
118 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */