Branch data 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 : 19694 : SvtListenerIter::SvtListenerIter( SvtBroadcaster& rBrdcst )
28 : 19694 : : rRoot( rBrdcst )
29 : : {
30 : : // hinten einketten!
31 : 19694 : pNxtIter = 0;
32 [ + + ]: 19694 : if( pListenerIters )
33 : : {
34 : 5 : SvtListenerIter* pTmp = pListenerIters;
35 [ - + ]: 5 : while( pTmp->pNxtIter )
36 : 0 : pTmp = pTmp->pNxtIter;
37 : 5 : pTmp->pNxtIter = this;
38 : : }
39 : : else
40 : 19689 : pListenerIters = this;
41 : :
42 : 19694 : pAkt = rRoot.pRoot;
43 : 19694 : pDelNext = pAkt;
44 : 19694 : }
45 : :
46 : :
47 : :
48 : 19694 : SvtListenerIter::~SvtListenerIter()
49 : : {
50 [ + - ]: 19694 : if( pListenerIters )
51 : : {
52 [ + + ]: 19694 : if( pListenerIters == this )
53 : 19689 : pListenerIters = pNxtIter;
54 : : else
55 : : {
56 : 5 : SvtListenerIter* pTmp = pListenerIters;
57 [ - + ]: 5 : while( pTmp->pNxtIter != this )
58 [ # # ]: 0 : if( 0 == ( pTmp = pTmp->pNxtIter ) )
59 : 0 : return ;
60 : 5 : pTmp->pNxtIter = pNxtIter;
61 : : }
62 : : }
63 : 19694 : }
64 : :
65 : 21890 : void SvtListenerIter::RemoveListener( SvtListenerBase& rDel,
66 : : SvtListenerBase* pNext )
67 : : {
68 : : // Update the ListenerIter
69 : 21890 : SvtListenerIter* pTmp = pListenerIters;
70 [ + + ]: 34127 : while( pTmp )
71 : : {
72 [ - + ][ # # ]: 12237 : if( pTmp->pAkt == &rDel || pTmp->pDelNext == &rDel )
73 : 12237 : pTmp->pDelNext = pNext;
74 : 12237 : pTmp = pTmp->pNxtIter;
75 : : }
76 : 21890 : }
77 : :
78 : 20240 : SvtListener* SvtListenerIter::GoNext()
79 : : {
80 [ + + ]: 20240 : if( pDelNext == pAkt )
81 : : {
82 : 16199 : pAkt = pAkt->GetRight();
83 : 16199 : pDelNext = pAkt;
84 : : }
85 : : else
86 : 4041 : pAkt = pDelNext;
87 [ + + ]: 20240 : return pAkt ? pAkt->GetListener() : 0;
88 : : }
89 : :
90 : 19693 : SvtListener* SvtListenerIter::GoStart() // zum Anfang des Baums
91 : : {
92 : 19693 : pAkt = rRoot.pRoot;
93 [ + + ]: 19693 : if( pAkt )
94 [ + + ]: 18196 : while( pAkt->GetLeft() )
95 : 569 : pAkt = pAkt->GetLeft();
96 : 19693 : pDelNext = pAkt;
97 [ + + ]: 19693 : return pAkt ? pAkt->GetListener() : 0;
98 : : }
99 : :
100 : 1 : SvtListener* SvtListenerIter::GetCurr() const // returns the current
101 : : {
102 [ + - ]: 1 : return pDelNext ? pDelNext->GetListener() : 0;
103 : : }
104 : :
105 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|