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>
34 //*****************************************************************************************************************
36 //*****************************************************************************************************************
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
)
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
)
66 m_pOwner
->disposing(rEvent
);
70 /*-************************************************************************************************************//**
72 @descr These initialize an instance of a SfxFilterListener class. Created object listen automaticly
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
87 @onerror We show some assertions in non product version.
88 Otherwise we do nothing!
90 *//*-*************************************************************************************************************/
91 SfxFilterListener::SfxFilterListener()
93 m_xFilterCache
= document::FilterConfigRefresh::create( comphelper::getProcessComponentContext() );
94 m_xFilterCacheListener
= new SfxRefreshListener(this);
95 m_xFilterCache
->addRefreshListener( m_xFilterCacheListener
);
98 SfxFilterListener::~SfxFilterListener()
102 void SAL_CALL
SfxFilterListener::refreshed( const lang::EventObject
& aSource
) throw( uno::RuntimeException
)
104 SolarMutexGuard aGuard
;
105 uno::Reference
< util::XRefreshable
> xContainer( aSource
.Source
, uno::UNO_QUERY
);
107 (xContainer
.is() ) &&
108 (xContainer
==m_xFilterCache
)
111 SfxFilterContainer::ReadFilters_Impl( sal_True
);
115 void SAL_CALL
SfxFilterListener::disposing( const lang::EventObject
& aSource
) throw( uno::RuntimeException
)
117 SolarMutexGuard aGuard
;
118 uno::Reference
< util::XRefreshable
> xNotifier( aSource
.Source
, uno::UNO_QUERY
);
122 if (xNotifier
== m_xFilterCache
)
123 m_xFilterCache
.clear();
126 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */