LCOV - code coverage report
Current view: top level - libreoffice/svl/source/notify - listeneriter.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 33 44 75.0 %
Date: 2012-12-27 Functions: 5 6 83.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             : #include "listenerbase.hxx"
      21             : #include <svl/listeneriter.hxx>
      22             : #include <svl/broadcast.hxx>
      23             : #include <svl/listener.hxx>
      24             : 
      25             : SvtListenerIter* SvtListenerIter::pListenerIters = 0;
      26             : 
      27        7389 : SvtListenerIter::SvtListenerIter( SvtBroadcaster& rBrdcst )
      28        7389 :     : rRoot( rBrdcst )
      29             : {
      30             :     // hinten einketten!
      31        7389 :     pNxtIter = 0;
      32        7389 :     if( pListenerIters )
      33             :     {
      34           0 :         SvtListenerIter* pTmp = pListenerIters;
      35           0 :         while( pTmp->pNxtIter )
      36           0 :             pTmp = pTmp->pNxtIter;
      37           0 :         pTmp->pNxtIter = this;
      38             :     }
      39             :     else
      40        7389 :         pListenerIters = this;
      41             : 
      42        7389 :     pAkt = rRoot.pRoot;
      43        7389 :     pDelNext = pAkt;
      44        7389 : }
      45             : 
      46             : 
      47             : 
      48        7389 : SvtListenerIter::~SvtListenerIter()
      49             : {
      50        7389 :     if( pListenerIters )
      51             :     {
      52        7389 :         if( pListenerIters == this )
      53        7389 :             pListenerIters = pNxtIter;
      54             :         else
      55             :         {
      56           0 :             SvtListenerIter* pTmp = pListenerIters;
      57           0 :             while( pTmp->pNxtIter != this )
      58           0 :                 if( 0 == ( pTmp = pTmp->pNxtIter ) )
      59           0 :                     return ;
      60           0 :             pTmp->pNxtIter = pNxtIter;
      61             :         }
      62             :     }
      63        7389 : }
      64             : 
      65        6863 : void SvtListenerIter::RemoveListener( SvtListenerBase& rDel,
      66             :                                         SvtListenerBase* pNext )
      67             : {
      68             :     // Update the ListenerIter
      69        6863 :     SvtListenerIter* pTmp = pListenerIters;
      70       16610 :     while( pTmp )
      71             :     {
      72        2884 :         if( pTmp->pAkt == &rDel || pTmp->pDelNext == &rDel )
      73        2884 :             pTmp->pDelNext = pNext;
      74        2884 :         pTmp = pTmp->pNxtIter;
      75             :     }
      76        6863 : }
      77             : 
      78        4114 : SvtListener* SvtListenerIter::GoNext()
      79             : {
      80        4114 :     if( pDelNext == pAkt )
      81             :     {
      82        3306 :         pAkt = pAkt->GetRight();
      83        3306 :         pDelNext = pAkt;
      84             :     }
      85             :     else
      86         808 :         pAkt = pDelNext;
      87        4114 :     return pAkt ? pAkt->GetListener() : 0;
      88             : }
      89             : 
      90        7389 : SvtListener* SvtListenerIter::GoStart()         // zum Anfang des Baums
      91             : {
      92        7389 :     pAkt = rRoot.pRoot;
      93        7389 :     if( pAkt )
      94        8660 :         while( pAkt->GetLeft() )
      95          64 :             pAkt = pAkt->GetLeft();
      96        7389 :     pDelNext = pAkt;
      97        7389 :     return pAkt ? pAkt->GetListener() : 0;
      98             : }
      99             : 
     100           0 : SvtListener* SvtListenerIter::GetCurr() const   // returns the current
     101             : {
     102           0 :     return pDelNext ? pDelNext->GetListener() : 0;
     103             : }
     104             : 
     105             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10