LCOV - code coverage report
Current view: top level - filter/source/config/cache - configflush.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 24 41 58.5 %
Date: 2014-04-11 Functions: 8 12 66.7 %
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             : #include "configflush.hxx"
      21             : #include "constant.hxx"
      22             : #include <cppuhelper/supportsservice.hxx>
      23             : 
      24             : #include <osl/diagnose.h>
      25             : 
      26             : namespace filter{
      27             :     namespace config{
      28             : 
      29          75 : ConfigFlush::ConfigFlush(const css::uno::Reference< css::lang::XMultiServiceFactory >& xSMGR)
      30             :     : BaseLock   (       )
      31             :     , m_xSMGR    (xSMGR  )
      32          75 :     , m_lListener(m_aLock)
      33             : {
      34          75 : }
      35             : 
      36         148 : ConfigFlush::~ConfigFlush()
      37             : {
      38         148 : }
      39             : 
      40           0 : OUString SAL_CALL ConfigFlush::getImplementationName()
      41             :     throw (css::uno::RuntimeException, std::exception)
      42             : {
      43           0 :     return impl_getImplementationName();
      44             :     // <- SAFE
      45             : }
      46             : 
      47           0 : sal_Bool SAL_CALL ConfigFlush::supportsService(const OUString& sServiceName)
      48             :     throw (css::uno::RuntimeException, std::exception)
      49             : {
      50           0 :     return cppu::supportsService(this, sServiceName);
      51             : }
      52             : 
      53           0 : css::uno::Sequence< OUString > SAL_CALL ConfigFlush::getSupportedServiceNames()
      54             :     throw (css::uno::RuntimeException, std::exception)
      55             : {
      56           0 :     return impl_getSupportedServiceNames();
      57             : }
      58             : 
      59           1 : void SAL_CALL ConfigFlush::refresh()
      60             :     throw(css::uno::RuntimeException, std::exception)
      61             : {
      62             :     // notify listener outside the lock!
      63             :     // The used listener helper lives if we live
      64             :     // and is threadsafe by itself.
      65             :     // Further its not a good idea to hold the own lock
      66             :     // if an outside object is called :-)
      67           1 :     css::lang::EventObject             aSource    (static_cast< css::util::XRefreshable* >(this));
      68           1 :     ::cppu::OInterfaceContainerHelper* pContainer = m_lListener.getContainer(::getCppuType(static_cast< css::uno::Reference< css::util::XRefreshListener >* >(NULL)));
      69           1 :     if (pContainer)
      70             :     {
      71           0 :         ::cppu::OInterfaceIteratorHelper pIterator(*pContainer);
      72           0 :         while (pIterator.hasMoreElements())
      73             :         {
      74             :             try
      75             :             {
      76             :                 // ... this pointer can be interesting to find out, where will be called as listener
      77             :                 // Dont optimize it to a direct iterator cast :-)
      78           0 :                 css::util::XRefreshListener* pListener = (css::util::XRefreshListener*)pIterator.next();
      79           0 :                 pListener->refreshed(aSource);
      80             :             }
      81           0 :             catch(const css::uno::Exception&)
      82             :             {
      83             :                 // ignore any "damaged" flush listener!
      84             :                 // May its remote reference is broken ...
      85           0 :                 pIterator.remove();
      86             :             }
      87           0 :         }
      88           1 :     }
      89           1 : }
      90             : 
      91             : 
      92          70 : void SAL_CALL ConfigFlush::addRefreshListener(const css::uno::Reference< css::util::XRefreshListener >& xListener)
      93             :     throw(css::uno::RuntimeException, std::exception)
      94             : {
      95             :     // no locks necessary
      96             :     // used helper lives if we live and is threadsafe by itself ...
      97          70 :     m_lListener.addInterface(::getCppuType(static_cast< css::uno::Reference< css::util::XRefreshListener >* >(NULL)),
      98         140 :                              xListener);
      99          70 : }
     100             : 
     101             : 
     102           0 : void SAL_CALL ConfigFlush::removeRefreshListener(const css::uno::Reference< css::util::XRefreshListener >& xListener)
     103             :     throw(css::uno::RuntimeException, std::exception)
     104             : {
     105             :     // no locks necessary
     106             :     // used helper lives if we live and is threadsafe by itself ...
     107           0 :     m_lListener.removeInterface(::getCppuType(static_cast< css::uno::Reference< css::util::XRefreshListener >* >(NULL)),
     108           0 :                                 xListener);
     109           0 : }
     110             : 
     111             : 
     112         387 : OUString ConfigFlush::impl_getImplementationName()
     113             : {
     114         387 :     return OUString("com.sun.star.comp.filter.config.ConfigFlush");
     115             : }
     116             : 
     117             : 
     118          75 : css::uno::Sequence< OUString > ConfigFlush::impl_getSupportedServiceNames()
     119             : {
     120          75 :     css::uno::Sequence< OUString > lServiceNames(1);
     121          75 :     lServiceNames[0] = "com.sun.star.document.FilterConfigRefresh";
     122          75 :     return lServiceNames;
     123             : }
     124             : 
     125             : 
     126          75 : css::uno::Reference< css::uno::XInterface > ConfigFlush::impl_createInstance(const css::uno::Reference< css::lang::XMultiServiceFactory >& xSMGR)
     127             : {
     128          75 :     ConfigFlush* pNew = new ConfigFlush(xSMGR);
     129          75 :     return css::uno::Reference< css::uno::XInterface >(static_cast< css::util::XRefreshable* >(pNew), css::uno::UNO_QUERY);
     130             : }
     131             : 
     132             :     } // namespace config
     133             : } // namespace filter
     134             : 
     135             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10