LCOV - code coverage report
Current view: top level - filter/source/config/cache - configflush.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 24 47 51.1 %
Date: 2012-08-25 Functions: 8 12 66.7 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 15 54 27.8 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      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.
      15                 :            :  *
      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).
      21                 :            :  *
      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.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : 
      30                 :            : #include "configflush.hxx"
      31                 :            : #include "constant.hxx"
      32                 :            : 
      33                 :            : #include <osl/diagnose.h>
      34                 :            : 
      35                 :            : 
      36                 :            : namespace css = ::com::sun::star;
      37                 :            : 
      38                 :            : namespace filter{
      39                 :            :     namespace config{
      40                 :            : 
      41                 :            : 
      42                 :            : //-----------------------------------------------
      43                 :        127 : ConfigFlush::ConfigFlush(const css::uno::Reference< css::lang::XMultiServiceFactory >& xSMGR)
      44                 :            :     : BaseLock   (       )
      45                 :            :     , m_xSMGR    (xSMGR  )
      46 [ +  - ][ +  - ]:        127 :     , m_lListener(m_aLock)
      47                 :            : {
      48                 :        127 : }
      49                 :            : 
      50                 :            : //-----------------------------------------------
      51 [ +  - ][ +  - ]:        127 : ConfigFlush::~ConfigFlush()
      52                 :            : {
      53         [ -  + ]:        254 : }
      54                 :            : 
      55                 :            : //-----------------------------------------------
      56                 :          0 : ::rtl::OUString SAL_CALL ConfigFlush::getImplementationName()
      57                 :            :     throw (css::uno::RuntimeException)
      58                 :            : {
      59                 :          0 :     return impl_getImplementationName();
      60                 :            :     // <- SAFE
      61                 :            : }
      62                 :            : 
      63                 :            : //-----------------------------------------------
      64                 :          0 : sal_Bool SAL_CALL ConfigFlush::supportsService(const ::rtl::OUString& sServiceName)
      65                 :            :     throw (css::uno::RuntimeException)
      66                 :            : {
      67         [ #  # ]:          0 :           css::uno::Sequence< ::rtl::OUString > lServiceNames = impl_getSupportedServiceNames();
      68                 :          0 :           sal_Int32                             c             = lServiceNames.getLength();
      69                 :          0 :     const ::rtl::OUString*                      pNames        = lServiceNames.getConstArray();
      70         [ #  # ]:          0 :     for (sal_Int32 i=0; i<c; ++i)
      71                 :            :     {
      72         [ #  # ]:          0 :         if (pNames[i].equals(sServiceName))
      73                 :          0 :             return sal_True;
      74                 :            :     }
      75         [ #  # ]:          0 :     return sal_False;
      76                 :            : }
      77                 :            : 
      78                 :            : //-----------------------------------------------
      79                 :          0 : css::uno::Sequence< ::rtl::OUString > SAL_CALL ConfigFlush::getSupportedServiceNames()
      80                 :            :     throw (css::uno::RuntimeException)
      81                 :            : {
      82                 :          0 :     return impl_getSupportedServiceNames();
      83                 :            : }
      84                 :            : 
      85                 :            : //-----------------------------------------------
      86                 :          2 : void SAL_CALL ConfigFlush::refresh()
      87                 :            :     throw(css::uno::RuntimeException)
      88                 :            : {
      89                 :            :     // notify listener outside the lock!
      90                 :            :     // The used listener helper lives if we live
      91                 :            :     // and is threadsafe by itself.
      92                 :            :     // Further its not a good idea to hold the own lock
      93                 :            :     // if an outside object is called :-)
      94 [ +  - ][ +  - ]:          2 :     css::lang::EventObject             aSource    (static_cast< css::util::XRefreshable* >(this));
      95 [ +  - ][ +  - ]:          2 :     ::cppu::OInterfaceContainerHelper* pContainer = m_lListener.getContainer(::getCppuType(static_cast< css::uno::Reference< css::util::XRefreshListener >* >(NULL)));
      96         [ -  + ]:          2 :     if (pContainer)
      97                 :            :     {
      98         [ #  # ]:          0 :         ::cppu::OInterfaceIteratorHelper pIterator(*pContainer);
      99         [ #  # ]:          0 :         while (pIterator.hasMoreElements())
     100                 :            :         {
     101                 :            :             try
     102                 :            :             {
     103                 :            :                 // ... this pointer can be interesting to find out, where will be called as listener
     104                 :            :                 // Dont optimize it to a direct iterator cast :-)
     105         [ #  # ]:          0 :                 css::util::XRefreshListener* pListener = (css::util::XRefreshListener*)pIterator.next();
     106         [ #  # ]:          0 :                 pListener->refreshed(aSource);
     107                 :            :             }
     108   [ #  #  #  # ]:          0 :             catch(const css::uno::Exception&)
     109                 :            :             {
     110                 :            :                 // ignore any "damaged" flush listener!
     111                 :            :                 // May its remote reference is broken ...
     112         [ #  # ]:          0 :                 pIterator.remove();
     113                 :            :             }
     114         [ #  # ]:          0 :         }
     115         [ +  - ]:          2 :     }
     116                 :          2 : }
     117                 :            : 
     118                 :            : //-----------------------------------------------
     119                 :        127 : void SAL_CALL ConfigFlush::addRefreshListener(const css::uno::Reference< css::util::XRefreshListener >& xListener)
     120                 :            :     throw(css::uno::RuntimeException)
     121                 :            : {
     122                 :            :     // no locks neccessary
     123                 :            :     // used helper lives if we live and is threadsafe by itself ...
     124                 :        127 :     m_lListener.addInterface(::getCppuType(static_cast< css::uno::Reference< css::util::XRefreshListener >* >(NULL)),
     125                 :        254 :                              xListener);
     126                 :        127 : }
     127                 :            : 
     128                 :            : //-----------------------------------------------
     129                 :          0 : void SAL_CALL ConfigFlush::removeRefreshListener(const css::uno::Reference< css::util::XRefreshListener >& xListener)
     130                 :            :     throw(css::uno::RuntimeException)
     131                 :            : {
     132                 :            :     // no locks neccessary
     133                 :            :     // used helper lives if we live and is threadsafe by itself ...
     134                 :          0 :     m_lListener.removeInterface(::getCppuType(static_cast< css::uno::Reference< css::util::XRefreshListener >* >(NULL)),
     135                 :          0 :                                 xListener);
     136                 :          0 : }
     137                 :            : 
     138                 :            : //-----------------------------------------------
     139                 :        639 : ::rtl::OUString ConfigFlush::impl_getImplementationName()
     140                 :            : {
     141                 :        639 :     return ::rtl::OUString("com.sun.star.comp.filter.config.ConfigFlush");
     142                 :            : }
     143                 :            : 
     144                 :            : //-----------------------------------------------
     145                 :        127 : css::uno::Sequence< ::rtl::OUString > ConfigFlush::impl_getSupportedServiceNames()
     146                 :            : {
     147                 :        127 :     css::uno::Sequence< ::rtl::OUString > lServiceNames(1);
     148 [ +  - ][ +  - ]:        127 :     lServiceNames[0] = SERVICE_FILTERCONFIGREFRESH;
     149                 :        127 :     return lServiceNames;
     150                 :            : }
     151                 :            : 
     152                 :            : //-----------------------------------------------
     153                 :        127 : css::uno::Reference< css::uno::XInterface > ConfigFlush::impl_createInstance(const css::uno::Reference< css::lang::XMultiServiceFactory >& xSMGR)
     154                 :            : {
     155         [ +  - ]:        127 :     ConfigFlush* pNew = new ConfigFlush(xSMGR);
     156         [ +  - ]:        127 :     return css::uno::Reference< css::uno::XInterface >(static_cast< css::util::XRefreshable* >(pNew), css::uno::UNO_QUERY);
     157                 :            : }
     158                 :            : 
     159                 :            :     } // namespace config
     160                 :            : } // namespace filter
     161                 :            : 
     162                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10