1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
32 //*****************************************************************************************************************
34 //*****************************************************************************************************************
35 #include <com/sun/star/uno/Sequence.hxx>
36 #include <com/sun/star/uno/Any.hxx>
37 #include <comphelper/processfactory.hxx>
39 #include <sfx2/sfxuno.hxx>
40 #include <sfx2/docfac.hxx>
42 #include <vcl/svapp.hxx>
43 #include <osl/mutex.hxx>
45 //*****************************************************************************************************************
47 //*****************************************************************************************************************
48 using namespace ::com::sun::star
;
51 class SfxRefreshListener
: public ::cppu::WeakImplHelper1
<com::sun::star::util::XRefreshListener
>
54 SfxFilterListener
*m_pOwner
;
57 SfxRefreshListener(SfxFilterListener
*pOwner
)
62 virtual ~SfxRefreshListener()
66 // util.XRefreshListener
67 virtual void SAL_CALL
refreshed( const ::com::sun::star::lang::EventObject
& rEvent
)
68 throw(com::sun::star::uno::RuntimeException
)
70 m_pOwner
->refreshed(rEvent
);
73 // lang.XEventListener
74 virtual void SAL_CALL
disposing(const com::sun::star::lang::EventObject
& rEvent
)
75 throw(com::sun::star::uno::RuntimeException
)
77 m_pOwner
->disposing(rEvent
);
83 //*****************************************************************************************************************
85 //*****************************************************************************************************************
87 /*-************************************************************************************************************//**
89 @descr These initialize an instance of a SfxFilterListener class. Created object listen automaticly
90 on right FilterFactory-Service for all changes and synchronize right SfxFilterContainer with
91 corresponding framework-cache.
92 We use given "sFactory" value to decide which query must be used to fill "pContainer" with new values.
93 Given "pContainer" hold us alive as uno reference and we use it to syschronize it with framework caches.
94 We will die, if he die! see dtor for further informations.
97 @seealso class framework::FilterCache
98 @seealso service ::document::FilterFactory
100 @param "sFactory" , short name of module which contains filter container
101 @param "pContainer", pointer to filter container which will be informed
104 @onerror We show some assertions in non product version.
105 Otherwise we do nothing!
108 @last_change 17.10.2001 10:27
109 *//*-*************************************************************************************************************/
110 SfxFilterListener::SfxFilterListener()
112 uno::Reference
< lang::XMultiServiceFactory
> xSmgr
= ::comphelper::getProcessServiceFactory();
113 if( xSmgr
.is() == sal_True
)
115 uno::Reference
< util::XRefreshable
> xNotifier( xSmgr
->createInstance( DEFINE_CONST_OUSTRING("com.sun.star.document.FilterConfigRefresh") ), uno::UNO_QUERY
);
116 if( xNotifier
.is() == sal_True
)
118 m_xFilterCache
= xNotifier
;
119 m_xFilterCacheListener
= new SfxRefreshListener(this);
120 m_xFilterCache
->addRefreshListener( m_xFilterCacheListener
);
125 SfxFilterListener::~SfxFilterListener()
129 void SAL_CALL
SfxFilterListener::refreshed( const lang::EventObject
& aSource
) throw( uno::RuntimeException
)
131 SolarMutexGuard aGuard
;
132 uno::Reference
< util::XRefreshable
> xContainer( aSource
.Source
, uno::UNO_QUERY
);
134 (xContainer
.is() ) &&
135 (xContainer
==m_xFilterCache
)
138 SfxFilterContainer::ReadFilters_Impl( sal_True
);
142 void SAL_CALL
SfxFilterListener::disposing( const lang::EventObject
& aSource
) throw( uno::RuntimeException
)
144 SolarMutexGuard aGuard
;
145 uno::Reference
< util::XRefreshable
> xNotifier( aSource
.Source
, uno::UNO_QUERY
);
149 if (xNotifier
== m_xFilterCache
)
150 m_xFilterCache
.clear();
153 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */