LCOV - code coverage report
Current view: top level - sw/source/core/unocore - unoevtlstnr.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 34 38 89.5 %
Date: 2012-08-25 Functions: 5 5 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 29 52 55.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                 :            : #include <unoevtlstnr.hxx>
      30                 :            : #include <com/sun/star/lang/EventObject.hpp>
      31                 :            : #include <com/sun/star/lang/XEventListener.hpp>
      32                 :            : 
      33                 :            : using namespace ::com::sun::star;
      34                 :            : using namespace ::com::sun::star::uno;
      35                 :            : using namespace ::com::sun::star::lang;
      36                 :            : using namespace ::com::sun::star::uno;
      37                 :            : 
      38                 :      48158 : SwEventListenerContainer::SwEventListenerContainer( uno::XInterface* _pxParent) :
      39                 :            :     pListenerArr(0),
      40                 :      48158 :     pxParent(_pxParent)
      41                 :            : {
      42                 :      48158 : }
      43                 :            : 
      44                 :      47695 : SwEventListenerContainer::~SwEventListenerContainer()
      45                 :            : {
      46 [ +  + ][ -  + ]:      47695 :     if(pListenerArr && !pListenerArr->empty())
                 [ -  + ]
      47                 :            :     {
      48 [ #  # ][ #  # ]:          0 :         for(SwEvtLstnrArray::iterator it = pListenerArr->begin(); it != pListenerArr->end(); ++it)
      49         [ #  # ]:          0 :             delete *it;
      50                 :          0 :         pListenerArr->clear();
      51                 :            :     }
      52         [ +  + ]:      47695 :     delete pListenerArr;
      53                 :      47695 : }
      54                 :            : 
      55                 :         52 : void    SwEventListenerContainer::AddListener(const uno::Reference< lang::XEventListener > & rxListener)
      56                 :            : {
      57         [ +  + ]:         52 :     if(!pListenerArr)
      58 [ +  - ][ +  - ]:         28 :         pListenerArr = new SwEvtLstnrArray;
      59                 :         52 :     uno::Reference< lang::XEventListener > * pInsert = new uno::Reference< lang::XEventListener > ;
      60         [ +  - ]:         52 :     *pInsert = rxListener;
      61         [ +  - ]:         52 :     pListenerArr->push_back(pInsert);
      62                 :         52 : }
      63                 :            : 
      64                 :         30 : sal_Bool    SwEventListenerContainer::RemoveListener(const uno::Reference< lang::XEventListener > & rxListener)
      65                 :            : {
      66         [ -  + ]:         30 :     if(!pListenerArr)
      67                 :          0 :         return sal_False;
      68                 :            :     else
      69                 :            :     {
      70                 :         30 :          lang::XEventListener* pLeft = rxListener.get();
      71         [ +  - ]:         52 :         for(sal_uInt16 i = 0; i < pListenerArr->size(); i++)
      72                 :            :         {
      73                 :         52 :             XEventListenerPtr pElem = (*pListenerArr)[i];
      74                 :         52 :             lang::XEventListener* pRight = pElem->get();
      75         [ +  + ]:         52 :             if(pLeft == pRight)
      76                 :            :             {
      77 [ +  - ][ +  - ]:         30 :                 pListenerArr->erase(pListenerArr->begin() + i);
      78         [ +  - ]:         30 :                 delete pElem;
      79                 :         30 :                 return sal_True;
      80                 :            :             }
      81                 :            :         }
      82                 :            :     }
      83                 :         30 :     return sal_False;
      84                 :            : }
      85                 :            : 
      86                 :      18899 : void    SwEventListenerContainer::Disposing()
      87                 :            : {
      88         [ +  + ]:      18899 :     if(!pListenerArr)
      89                 :      18899 :         return;
      90                 :            : 
      91 [ +  - ][ +  - ]:         28 :     lang::EventObject aObj(pxParent);
      92         [ +  + ]:         50 :     for(sal_uInt16 i = 0; i < pListenerArr->size(); i++)
      93                 :            :     {
      94                 :         22 :         XEventListenerPtr pElem = (*pListenerArr)[i];
      95 [ +  - ][ +  - ]:         22 :         (*pElem)->disposing(aObj);
      96         [ +  - ]:         22 :         delete pElem;
      97                 :            :     }
      98         [ +  - ]:      18899 :     pListenerArr->clear();
      99                 :            : }
     100                 :            : 
     101                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10