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 0 : PanelDeckListeners::PanelDeckListeners()
34 : {
35 0 : }
36 :
37 :
38 0 : PanelDeckListeners::~PanelDeckListeners()
39 : {
40 0 : }
41 :
42 :
43 0 : void PanelDeckListeners::PanelInserted( const PToolPanel& i_pPanel, const size_t i_nPosition )
44 : {
45 0 : ::std::vector< IToolPanelDeckListener* > aListeners( m_aListeners );
46 0 : for ( ::std::vector< IToolPanelDeckListener* >::const_iterator loop = aListeners.begin();
47 0 : loop != aListeners.end();
48 : ++loop
49 : )
50 : {
51 0 : (*loop)->PanelInserted( i_pPanel, i_nPosition );
52 0 : }
53 0 : }
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 0 : void PanelDeckListeners::ActivePanelChanged( const ::boost::optional< size_t >& i_rOldActive, const ::boost::optional< size_t >& i_rNewActive )
70 : {
71 0 : ::std::vector< IToolPanelDeckListener* > aListeners( m_aListeners );
72 0 : for ( ::std::vector< IToolPanelDeckListener* >::const_iterator loop = aListeners.begin();
73 0 : loop != aListeners.end();
74 : ++loop
75 : )
76 : {
77 0 : (*loop)->ActivePanelChanged( i_rOldActive, i_rNewActive );
78 0 : }
79 0 : }
80 :
81 :
82 0 : void PanelDeckListeners::LayouterChanged( const PDeckLayouter& i_rNewLayouter )
83 : {
84 0 : ::std::vector< IToolPanelDeckListener* > aListeners( m_aListeners );
85 0 : for ( ::std::vector< IToolPanelDeckListener* >::const_iterator loop = aListeners.begin();
86 0 : loop != aListeners.end();
87 : ++loop
88 : )
89 : {
90 0 : (*loop)->LayouterChanged( i_rNewLayouter );
91 0 : }
92 0 : }
93 :
94 :
95 0 : void PanelDeckListeners::Dying()
96 : {
97 0 : while ( !m_aListeners.empty() )
98 : {
99 0 : IToolPanelDeckListener* pListener( *m_aListeners.begin() );
100 0 : m_aListeners.erase( m_aListeners.begin() );
101 0 : pListener->Dying();
102 : }
103 0 : }
104 :
105 :
106 0 : void PanelDeckListeners::AddListener( IToolPanelDeckListener& i_rListener )
107 : {
108 0 : m_aListeners.push_back( &i_rListener );
109 0 : }
110 :
111 :
112 0 : void PanelDeckListeners::RemoveListener( IToolPanelDeckListener& i_rListener )
113 : {
114 0 : for ( ::std::vector< IToolPanelDeckListener* >::iterator lookup = m_aListeners.begin();
115 0 : lookup != m_aListeners.end();
116 : ++lookup
117 : )
118 : {
119 0 : if ( *lookup == &i_rListener )
120 : {
121 0 : m_aListeners.erase( lookup );
122 0 : return;
123 : }
124 : }
125 : }
126 :
127 :
128 : } // namespace svt
129 :
130 :
131 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|