LCOV - code coverage report
Current view: top level - libreoffice/sfx2/source/bastyp - fltlst.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 19 41 46.3 %
Date: 2012-12-27 Functions: 5 10 50.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       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/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      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 .
      18             :  */
      19             : 
      20             : 
      21             : #include "fltlst.hxx"
      22             : 
      23             : #include <com/sun/star/uno/Sequence.hxx>
      24             : #include <com/sun/star/uno/Any.hxx>
      25             : #include <comphelper/processfactory.hxx>
      26             : 
      27             : #include <sfx2/sfxuno.hxx>
      28             : #include <sfx2/docfac.hxx>
      29             : 
      30             : #include <vcl/svapp.hxx>
      31             : #include <osl/mutex.hxx>
      32             : 
      33             : //*****************************************************************************************************************
      34             : //  namespaces
      35             : //*****************************************************************************************************************
      36             : using namespace ::com::sun::star;
      37             : 
      38             : 
      39             : class SfxRefreshListener : public ::cppu::WeakImplHelper1<com::sun::star::util::XRefreshListener>
      40             : {
      41             :     private:
      42             :         SfxFilterListener *m_pOwner;
      43             : 
      44             :     public:
      45          13 :         SfxRefreshListener(SfxFilterListener *pOwner)
      46          13 :             : m_pOwner(pOwner)
      47             :         {
      48          13 :         }
      49             : 
      50          26 :         virtual ~SfxRefreshListener()
      51          13 :         {
      52          26 :         }
      53             : 
      54             :         // util.XRefreshListener
      55           0 :         virtual void SAL_CALL refreshed( const ::com::sun::star::lang::EventObject& rEvent )
      56             :             throw(com::sun::star::uno::RuntimeException)
      57             :         {
      58           0 :             m_pOwner->refreshed(rEvent);
      59           0 :         }
      60             : 
      61             :         // lang.XEventListener
      62           0 :         virtual void SAL_CALL disposing(const com::sun::star::lang::EventObject& rEvent)
      63             :             throw(com::sun::star::uno::RuntimeException)
      64             :         {
      65           0 :             m_pOwner->disposing(rEvent);
      66           0 :         }
      67             : };
      68             : 
      69             : /*-************************************************************************************************************//**
      70             :     @short          ctor
      71             :     @descr          These initialize an instance of a SfxFilterListener class. Created object listen automaticly
      72             :                     on right FilterFactory-Service for all changes and synchronize right SfxFilterContainer with
      73             :                     corresponding framework-cache.
      74             :                     We use given "sFactory" value to decide which query must be used to fill "pContainer" with new values.
      75             :                     Given "pContainer" hold us alive as uno reference and we use it to syschronize it with framework caches.
      76             :                     We will die, if he die! see dtor for further informations.
      77             : 
      78             :     @seealso        dtor
      79             :     @seealso        class framework::FilterCache
      80             :     @seealso        service ::document::FilterFactory
      81             : 
      82             :     @param          "sFactory"  , short name of module which contains filter container
      83             :     @param          "pContainer", pointer to filter container which will be informed
      84             :     @return         -
      85             : 
      86             :     @onerror        We show some assertions in non product version.
      87             :                     Otherwise we do nothing!
      88             :     @threadsafe     yes
      89             : *//*-*************************************************************************************************************/
      90          13 : SfxFilterListener::SfxFilterListener()
      91             : {
      92          13 :     uno::Reference< lang::XMultiServiceFactory > xSmgr = ::comphelper::getProcessServiceFactory();
      93          13 :     if( xSmgr.is() == sal_True )
      94             :     {
      95          13 :         uno::Reference< util::XRefreshable > xNotifier( xSmgr->createInstance( DEFINE_CONST_OUSTRING("com.sun.star.document.FilterConfigRefresh") ), uno::UNO_QUERY );
      96          13 :         if( xNotifier.is() == sal_True )
      97             :         {
      98          13 :             m_xFilterCache = xNotifier;
      99          13 :             m_xFilterCacheListener = new SfxRefreshListener(this);
     100          13 :             m_xFilterCache->addRefreshListener( m_xFilterCacheListener );
     101          13 :         }
     102          13 :     }
     103          13 : }
     104             : 
     105          13 : SfxFilterListener::~SfxFilterListener()
     106             : {
     107          13 : }
     108             : 
     109           0 : void SAL_CALL SfxFilterListener::refreshed( const lang::EventObject& aSource ) throw( uno::RuntimeException )
     110             : {
     111           0 :     SolarMutexGuard aGuard;
     112           0 :     uno::Reference< util::XRefreshable > xContainer( aSource.Source, uno::UNO_QUERY );
     113           0 :     if(
     114           0 :         (xContainer.is()           ) &&
     115           0 :         (xContainer==m_xFilterCache)
     116             :       )
     117             :     {
     118           0 :         SfxFilterContainer::ReadFilters_Impl( sal_True );
     119           0 :     }
     120           0 : }
     121             : 
     122           0 : void SAL_CALL SfxFilterListener::disposing( const lang::EventObject& aSource ) throw( uno::RuntimeException )
     123             : {
     124           0 :     SolarMutexGuard aGuard;
     125           0 :     uno::Reference< util::XRefreshable > xNotifier( aSource.Source, uno::UNO_QUERY );
     126           0 :     if (!xNotifier.is())
     127           0 :         return;
     128             : 
     129           0 :     if (xNotifier == m_xFilterCache)
     130           0 :         m_xFilterCache.clear();
     131             : }
     132             : 
     133             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10