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/uno/Sequence.hxx>
24 #include <com/sun/star/uno/Any.hxx>
25 #include <com/sun/star/document/FilterConfigRefresh.hpp>
26 #include <comphelper/processfactory.hxx>
28 #include <sfx2/sfxuno.hxx>
29 #include <sfx2/docfac.hxx>
31 #include <vcl/svapp.hxx>
32 #include <osl/mutex.hxx>
37 using namespace ::com::sun::star
;
40 class SfxRefreshListener
: public ::cppu::WeakImplHelper1
<com::sun::star::util::XRefreshListener
>
43 SfxFilterListener
*m_pOwner
;
46 SfxRefreshListener(SfxFilterListener
*pOwner
)
51 virtual ~SfxRefreshListener()
55 // util.XRefreshListener
56 virtual void SAL_CALL
refreshed( const ::com::sun::star::lang::EventObject
& rEvent
)
57 throw(com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
59 m_pOwner
->refreshed(rEvent
);
62 // lang.XEventListener
63 virtual void SAL_CALL
disposing(const com::sun::star::lang::EventObject
& rEvent
)
64 throw(com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
66 m_pOwner
->disposing(rEvent
);
70 /*-************************************************************************************************************
72 @descr These initialize an instance of a SfxFilterListener class. Created object listen automatically
73 on right FilterFactory-Service for all changes and synchronize right SfxFilterContainer with
74 corresponding framework-cache.
75 We use given "sFactory" value to decide which query must be used to fill "pContainer" with new values.
76 Given "pContainer" hold us alive as uno reference and we use it to syschronize it with framework caches.
77 We will die, if he die! see dtor for further information.
80 @seealso class framework::FilterCache
81 @seealso service ::document::FilterFactory
83 @param "sFactory" , short name of module which contains filter container
84 @param "pContainer", pointer to filter container which will be informed
85 @onerror We show some assertions in non product version.
86 Otherwise we do nothing!
88 *//*-*************************************************************************************************************/
89 SfxFilterListener::SfxFilterListener()
91 m_xFilterCache
= document::FilterConfigRefresh::create( comphelper::getProcessComponentContext() );
92 m_xFilterCacheListener
= new SfxRefreshListener(this);
93 m_xFilterCache
->addRefreshListener( m_xFilterCacheListener
);
96 SfxFilterListener::~SfxFilterListener()
100 void SAL_CALL
SfxFilterListener::refreshed( const lang::EventObject
& aSource
) throw( uno::RuntimeException
)
102 SolarMutexGuard aGuard
;
103 uno::Reference
< util::XRefreshable
> xContainer( aSource
.Source
, uno::UNO_QUERY
);
105 (xContainer
.is() ) &&
106 (xContainer
==m_xFilterCache
)
109 SfxFilterContainer::ReadFilters_Impl( true );
113 void SAL_CALL
SfxFilterListener::disposing( const lang::EventObject
& aSource
) throw( uno::RuntimeException
)
115 SolarMutexGuard aGuard
;
116 uno::Reference
< util::XRefreshable
> xNotifier( aSource
.Source
, uno::UNO_QUERY
);
120 if (xNotifier
== m_xFilterCache
)
121 m_xFilterCache
.clear();
124 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */