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