xref: /aoo41x/main/sfx2/source/bastyp/fltlst.cxx (revision d119d52d)
1*d119d52dSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*d119d52dSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*d119d52dSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*d119d52dSAndrew Rist  * distributed with this work for additional information
6*d119d52dSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*d119d52dSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*d119d52dSAndrew Rist  * "License"); you may not use this file except in compliance
9*d119d52dSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*d119d52dSAndrew Rist  *
11*d119d52dSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*d119d52dSAndrew Rist  *
13*d119d52dSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*d119d52dSAndrew Rist  * software distributed under the License is distributed on an
15*d119d52dSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*d119d52dSAndrew Rist  * KIND, either express or implied.  See the License for the
17*d119d52dSAndrew Rist  * specific language governing permissions and limitations
18*d119d52dSAndrew Rist  * under the License.
19*d119d52dSAndrew Rist  *
20*d119d52dSAndrew Rist  *************************************************************/
21*d119d52dSAndrew Rist 
22*d119d52dSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sfx2.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include "fltlst.hxx"
28cdf0e10cSrcweir 
29cdf0e10cSrcweir //*****************************************************************************************************************
30cdf0e10cSrcweir //  includes
31cdf0e10cSrcweir //*****************************************************************************************************************
32cdf0e10cSrcweir #include <com/sun/star/uno/Sequence.hxx>
33cdf0e10cSrcweir #include <com/sun/star/uno/Any.hxx>
34cdf0e10cSrcweir #include <comphelper/processfactory.hxx>
35cdf0e10cSrcweir 
36cdf0e10cSrcweir #include <sfx2/sfxuno.hxx>
37cdf0e10cSrcweir #include <sfx2/docfac.hxx>
38cdf0e10cSrcweir 
39cdf0e10cSrcweir #include <vcl/svapp.hxx>
40cdf0e10cSrcweir #include <vos/mutex.hxx>
41cdf0e10cSrcweir 
42cdf0e10cSrcweir //*****************************************************************************************************************
43cdf0e10cSrcweir //  namespaces
44cdf0e10cSrcweir //*****************************************************************************************************************
45cdf0e10cSrcweir using namespace ::com::sun::star;
46cdf0e10cSrcweir 
47cdf0e10cSrcweir //*****************************************************************************************************************
48cdf0e10cSrcweir //  definitions
49cdf0e10cSrcweir //*****************************************************************************************************************
50cdf0e10cSrcweir 
51cdf0e10cSrcweir /*-************************************************************************************************************//**
52cdf0e10cSrcweir     @short          ctor
53cdf0e10cSrcweir     @descr          These initialize an instance of a SfxFilterListener class. Created object listen automaticly
54cdf0e10cSrcweir                     on right FilterFactory-Service for all changes and synchronize right SfxFilterContainer with
55cdf0e10cSrcweir                     corresponding framework-cache.
56cdf0e10cSrcweir                     We use given "sFactory" value to decide which query must be used to fill "pContainer" with new values.
57cdf0e10cSrcweir                     Given "pContainer" hold us alive as uno reference and we use it to syschronize it with framework caches.
58cdf0e10cSrcweir                     We will die, if he die! see dtor for further informations.
59cdf0e10cSrcweir 
60cdf0e10cSrcweir     @seealso        dtor
61cdf0e10cSrcweir     @seealso        class framework::FilterCache
62cdf0e10cSrcweir     @seealso        service ::document::FilterFactory
63cdf0e10cSrcweir 
64cdf0e10cSrcweir     @param          "sFactory"  , short name of module which contains filter container
65cdf0e10cSrcweir     @param          "pContainer", pointer to filter container which will be informed
66cdf0e10cSrcweir     @return         -
67cdf0e10cSrcweir 
68cdf0e10cSrcweir     @onerror        We show some assertions in non product version.
69cdf0e10cSrcweir                     Otherwise we do nothing!
70cdf0e10cSrcweir     @threadsafe     yes
71cdf0e10cSrcweir 
72cdf0e10cSrcweir     @last_change    17.10.2001 10:27
73cdf0e10cSrcweir *//*-*************************************************************************************************************/
SfxFilterListener()74cdf0e10cSrcweir SfxFilterListener::SfxFilterListener()
75cdf0e10cSrcweir {
76cdf0e10cSrcweir     uno::Reference< lang::XMultiServiceFactory > xSmgr = ::comphelper::getProcessServiceFactory();
77cdf0e10cSrcweir     if( xSmgr.is() == sal_True )
78cdf0e10cSrcweir     {
79cdf0e10cSrcweir         uno::Reference< util::XRefreshable > xNotifier( xSmgr->createInstance( DEFINE_CONST_OUSTRING("com.sun.star.document.FilterConfigRefresh") ), uno::UNO_QUERY );
80cdf0e10cSrcweir         if( xNotifier.is() == sal_True )
81cdf0e10cSrcweir         {
82cdf0e10cSrcweir             m_xFilterCache = xNotifier;
83cdf0e10cSrcweir             m_xFilterCache->addRefreshListener( this );
84cdf0e10cSrcweir         }
85cdf0e10cSrcweir     }
86cdf0e10cSrcweir }
87cdf0e10cSrcweir 
~SfxFilterListener()88cdf0e10cSrcweir SfxFilterListener::~SfxFilterListener()
89cdf0e10cSrcweir {
90cdf0e10cSrcweir }
91cdf0e10cSrcweir 
refreshed(const lang::EventObject & aSource)92cdf0e10cSrcweir void SAL_CALL SfxFilterListener::refreshed( const lang::EventObject& aSource ) throw( uno::RuntimeException )
93cdf0e10cSrcweir {
94cdf0e10cSrcweir     ::vos::OGuard aGuard( Application::GetSolarMutex() );
95cdf0e10cSrcweir     uno::Reference< util::XRefreshable > xContainer( aSource.Source, uno::UNO_QUERY );
96cdf0e10cSrcweir     if(
97cdf0e10cSrcweir         (xContainer.is()           ) &&
98cdf0e10cSrcweir         (xContainer==m_xFilterCache)
99cdf0e10cSrcweir       )
100cdf0e10cSrcweir     {
101cdf0e10cSrcweir 		SfxFilterContainer::ReadFilters_Impl( sal_True );
102cdf0e10cSrcweir     }
103cdf0e10cSrcweir }
104cdf0e10cSrcweir 
disposing(const lang::EventObject & aSource)105cdf0e10cSrcweir void SAL_CALL SfxFilterListener::disposing( const lang::EventObject& aSource ) throw( uno::RuntimeException )
106cdf0e10cSrcweir {
107cdf0e10cSrcweir     ::vos::OGuard aGuard( Application::GetSolarMutex() );
108cdf0e10cSrcweir     uno::Reference< util::XRefreshable > xNotifier( aSource.Source, uno::UNO_QUERY );
109cdf0e10cSrcweir     if (!xNotifier.is())
110cdf0e10cSrcweir         return;
111cdf0e10cSrcweir 
112cdf0e10cSrcweir     if (xNotifier == m_xFilterCache)
113cdf0e10cSrcweir         m_xFilterCache.clear();
114cdf0e10cSrcweir }
115