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 : :
21 : : #include "paneldecklisteners.hxx"
22 : : #include "svtools/toolpanel/toolpaneldeck.hxx"
23 : :
24 : : //........................................................................
25 : : namespace svt
26 : : {
27 : : //........................................................................
28 : :
29 : : //====================================================================
30 : : //= PanelDeckListeners
31 : : //====================================================================
32 : : //--------------------------------------------------------------------
33 : 52 : PanelDeckListeners::PanelDeckListeners()
34 : : {
35 : 52 : }
36 : :
37 : : //--------------------------------------------------------------------
38 : 52 : PanelDeckListeners::~PanelDeckListeners()
39 : : {
40 : 52 : }
41 : :
42 : : //--------------------------------------------------------------------
43 : 260 : void PanelDeckListeners::PanelInserted( const PToolPanel& i_pPanel, const size_t i_nPosition )
44 : : {
45 [ + - ]: 260 : ::std::vector< IToolPanelDeckListener* > aListeners( m_aListeners );
46 [ + - ][ + - ]: 1040 : for ( ::std::vector< IToolPanelDeckListener* >::const_iterator loop = aListeners.begin();
[ + + ]
47 : 520 : loop != aListeners.end();
48 : : ++loop
49 : : )
50 : : {
51 [ + - ]: 260 : (*loop)->PanelInserted( i_pPanel, i_nPosition );
52 : 260 : }
53 : 260 : }
54 : :
55 : : //--------------------------------------------------------------------
56 : 0 : void PanelDeckListeners::PanelRemoved( const size_t i_nPosition )
57 : : {
58 [ # # ]: 0 : ::std::vector< IToolPanelDeckListener* > aListeners( m_aListeners );
59 [ # # ][ # # ]: 0 : for ( ::std::vector< IToolPanelDeckListener* >::const_iterator loop = aListeners.begin();
[ # # ]
60 : 0 : loop != aListeners.end();
61 : : ++loop
62 : : )
63 : : {
64 [ # # ]: 0 : (*loop)->PanelRemoved( i_nPosition );
65 : 0 : }
66 : 0 : }
67 : :
68 : : //--------------------------------------------------------------------
69 : 64 : void PanelDeckListeners::ActivePanelChanged( const ::boost::optional< size_t >& i_rOldActive, const ::boost::optional< size_t >& i_rNewActive )
70 : : {
71 [ + - ]: 64 : ::std::vector< IToolPanelDeckListener* > aListeners( m_aListeners );
72 [ + - ][ + - ]: 384 : for ( ::std::vector< IToolPanelDeckListener* >::const_iterator loop = aListeners.begin();
[ + + ]
73 : 192 : loop != aListeners.end();
74 : : ++loop
75 : : )
76 : : {
77 [ + - ]: 128 : (*loop)->ActivePanelChanged( i_rOldActive, i_rNewActive );
78 : 64 : }
79 : 64 : }
80 : :
81 : : //--------------------------------------------------------------------
82 : 26 : void PanelDeckListeners::LayouterChanged( const PDeckLayouter& i_rNewLayouter )
83 : : {
84 [ + - ]: 26 : ::std::vector< IToolPanelDeckListener* > aListeners( m_aListeners );
85 [ + - ][ + - ]: 104 : for ( ::std::vector< IToolPanelDeckListener* >::const_iterator loop = aListeners.begin();
[ + + ]
86 : 52 : loop != aListeners.end();
87 : : ++loop
88 : : )
89 : : {
90 [ + - ]: 26 : (*loop)->LayouterChanged( i_rNewLayouter );
91 : 26 : }
92 : 26 : }
93 : :
94 : : //--------------------------------------------------------------------
95 : 52 : void PanelDeckListeners::Dying()
96 : : {
97 [ + + ]: 78 : while ( !m_aListeners.empty() )
98 : : {
99 : 26 : IToolPanelDeckListener* pListener( *m_aListeners.begin() );
100 : 26 : m_aListeners.erase( m_aListeners.begin() );
101 : 26 : pListener->Dying();
102 : : }
103 : 52 : }
104 : :
105 : : //--------------------------------------------------------------------
106 : 104 : void PanelDeckListeners::AddListener( IToolPanelDeckListener& i_rListener )
107 : : {
108 [ + - ]: 104 : m_aListeners.push_back( &i_rListener );
109 : 104 : }
110 : :
111 : : //--------------------------------------------------------------------
112 : 130 : void PanelDeckListeners::RemoveListener( IToolPanelDeckListener& i_rListener )
113 : : {
114 [ + - ][ + + ]: 416 : for ( ::std::vector< IToolPanelDeckListener* >::iterator lookup = m_aListeners.begin();
115 : 208 : lookup != m_aListeners.end();
116 : : ++lookup
117 : : )
118 : : {
119 [ + + ]: 156 : if ( *lookup == &i_rListener )
120 : : {
121 [ + - ]: 78 : m_aListeners.erase( lookup );
122 : 130 : return;
123 : : }
124 : : }
125 : : }
126 : :
127 : : //........................................................................
128 : : } // namespace svt
129 : : //........................................................................
130 : :
131 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|