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-17 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       14946 : SvtListenerIter::SvtListenerIter( SvtBroadcaster& rBrdcst )
      28       14946 :     : rRoot( rBrdcst )
      29             : {
      30             :     // hinten einketten!
      31       14946 :     pNxtIter = 0;
      32       14946 :     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       14946 :         pListenerIters = this;
      41             : 
      42       14946 :     pAkt = rRoot.pRoot;
      43       14946 :     pDelNext = pAkt;
      44       14946 : }
      45             : 
      46             : 
      47             : 
      48       14946 : SvtListenerIter::~SvtListenerIter()
      49             : {
      50       14946 :     if( pListenerIters )
      51             :     {
      52       14946 :         if( pListenerIters == this )
      53       14946 :             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       14946 : }
      64             : 
      65       13924 : void SvtListenerIter::RemoveListener( SvtListenerBase& rDel,
      66             :                                         SvtListenerBase* pNext )
      67             : {
      68             :     // Update the ListenerIter
      69       13924 :     SvtListenerIter* pTmp = pListenerIters;
      70       33624 :     while( pTmp )
      71             :     {
      72        5776 :         if( pTmp->pAkt == &rDel || pTmp->pDelNext == &rDel )
      73        5776 :             pTmp->pDelNext = pNext;
      74        5776 :         pTmp = pTmp->pNxtIter;
      75             :     }
      76       13924 : }
      77             : 
      78        8260 : SvtListener* SvtListenerIter::GoNext()
      79             : {
      80        8260 :     if( pDelNext == pAkt )
      81             :     {
      82        6644 :         pAkt = pAkt->GetRight();
      83        6644 :         pDelNext = pAkt;
      84             :     }
      85             :     else
      86        1616 :         pAkt = pDelNext;
      87        8260 :     return pAkt ? pAkt->GetListener() : 0;
      88             : }
      89             : 
      90       14946 : SvtListener* SvtListenerIter::GoStart()         // zum Anfang des Baums
      91             : {
      92       14946 :     pAkt = rRoot.pRoot;
      93       14946 :     if( pAkt )
      94       17400 :         while( pAkt->GetLeft() )
      95         128 :             pAkt = pAkt->GetLeft();
      96       14946 :     pDelNext = pAkt;
      97       14946 :     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