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

Generated by: LCOV version 1.10