1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_sfx2.hxx" 30 31 #include "fltlst.hxx" 32 33 //***************************************************************************************************************** 34 // includes 35 //***************************************************************************************************************** 36 #include <com/sun/star/uno/Sequence.hxx> 37 #include <com/sun/star/uno/Any.hxx> 38 #include <comphelper/processfactory.hxx> 39 40 #include <sfx2/sfxuno.hxx> 41 #include <sfx2/docfac.hxx> 42 43 #include <vcl/svapp.hxx> 44 #include <vos/mutex.hxx> 45 46 //***************************************************************************************************************** 47 // namespaces 48 //***************************************************************************************************************** 49 using namespace ::com::sun::star; 50 51 //***************************************************************************************************************** 52 // definitions 53 //***************************************************************************************************************** 54 55 /*-************************************************************************************************************//** 56 @short ctor 57 @descr These initialize an instance of a SfxFilterListener class. Created object listen automaticly 58 on right FilterFactory-Service for all changes and synchronize right SfxFilterContainer with 59 corresponding framework-cache. 60 We use given "sFactory" value to decide which query must be used to fill "pContainer" with new values. 61 Given "pContainer" hold us alive as uno reference and we use it to syschronize it with framework caches. 62 We will die, if he die! see dtor for further informations. 63 64 @seealso dtor 65 @seealso class framework::FilterCache 66 @seealso service ::document::FilterFactory 67 68 @param "sFactory" , short name of module which contains filter container 69 @param "pContainer", pointer to filter container which will be informed 70 @return - 71 72 @onerror We show some assertions in non product version. 73 Otherwise we do nothing! 74 @threadsafe yes 75 76 @last_change 17.10.2001 10:27 77 *//*-*************************************************************************************************************/ 78 SfxFilterListener::SfxFilterListener() 79 { 80 uno::Reference< lang::XMultiServiceFactory > xSmgr = ::comphelper::getProcessServiceFactory(); 81 if( xSmgr.is() == sal_True ) 82 { 83 uno::Reference< util::XRefreshable > xNotifier( xSmgr->createInstance( DEFINE_CONST_OUSTRING("com.sun.star.document.FilterConfigRefresh") ), uno::UNO_QUERY ); 84 if( xNotifier.is() == sal_True ) 85 { 86 m_xFilterCache = xNotifier; 87 m_xFilterCache->addRefreshListener( this ); 88 } 89 } 90 } 91 92 SfxFilterListener::~SfxFilterListener() 93 { 94 } 95 96 void SAL_CALL SfxFilterListener::refreshed( const lang::EventObject& aSource ) throw( uno::RuntimeException ) 97 { 98 ::vos::OGuard aGuard( Application::GetSolarMutex() ); 99 uno::Reference< util::XRefreshable > xContainer( aSource.Source, uno::UNO_QUERY ); 100 if( 101 (xContainer.is() ) && 102 (xContainer==m_xFilterCache) 103 ) 104 { 105 SfxFilterContainer::ReadFilters_Impl( sal_True ); 106 } 107 } 108 109 void SAL_CALL SfxFilterListener::disposing( const lang::EventObject& aSource ) throw( uno::RuntimeException ) 110 { 111 ::vos::OGuard aGuard( Application::GetSolarMutex() ); 112 uno::Reference< util::XRefreshable > xNotifier( aSource.Source, uno::UNO_QUERY ); 113 if (!xNotifier.is()) 114 return; 115 116 if (xNotifier == m_xFilterCache) 117 m_xFilterCache.clear(); 118 } 119