1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 #include "precompiled_svtools.hxx" 25 26 #include "paneldecklisteners.hxx" 27 #include "svtools/toolpanel/toolpaneldeck.hxx" 28 29 //........................................................................ 30 namespace svt 31 { 32 //........................................................................ 33 34 //==================================================================== 35 //= PanelDeckListeners 36 //==================================================================== 37 //-------------------------------------------------------------------- PanelDeckListeners()38 PanelDeckListeners::PanelDeckListeners() 39 { 40 } 41 42 //-------------------------------------------------------------------- ~PanelDeckListeners()43 PanelDeckListeners::~PanelDeckListeners() 44 { 45 } 46 47 //-------------------------------------------------------------------- PanelInserted(const PToolPanel & i_pPanel,const size_t i_nPosition)48 void PanelDeckListeners::PanelInserted( const PToolPanel& i_pPanel, const size_t i_nPosition ) 49 { 50 ::std::vector< IToolPanelDeckListener* > aListeners( m_aListeners ); 51 for ( ::std::vector< IToolPanelDeckListener* >::const_iterator loop = aListeners.begin(); 52 loop != aListeners.end(); 53 ++loop 54 ) 55 { 56 (*loop)->PanelInserted( i_pPanel, i_nPosition ); 57 } 58 } 59 60 //-------------------------------------------------------------------- PanelRemoved(const size_t i_nPosition)61 void PanelDeckListeners::PanelRemoved( const size_t i_nPosition ) 62 { 63 ::std::vector< IToolPanelDeckListener* > aListeners( m_aListeners ); 64 for ( ::std::vector< IToolPanelDeckListener* >::const_iterator loop = aListeners.begin(); 65 loop != aListeners.end(); 66 ++loop 67 ) 68 { 69 (*loop)->PanelRemoved( i_nPosition ); 70 } 71 } 72 73 //-------------------------------------------------------------------- ActivePanelChanged(const::boost::optional<size_t> & i_rOldActive,const::boost::optional<size_t> & i_rNewActive)74 void PanelDeckListeners::ActivePanelChanged( const ::boost::optional< size_t >& i_rOldActive, const ::boost::optional< size_t >& i_rNewActive ) 75 { 76 ::std::vector< IToolPanelDeckListener* > aListeners( m_aListeners ); 77 for ( ::std::vector< IToolPanelDeckListener* >::const_iterator loop = aListeners.begin(); 78 loop != aListeners.end(); 79 ++loop 80 ) 81 { 82 (*loop)->ActivePanelChanged( i_rOldActive, i_rNewActive ); 83 } 84 } 85 86 //-------------------------------------------------------------------- LayouterChanged(const PDeckLayouter & i_rNewLayouter)87 void PanelDeckListeners::LayouterChanged( const PDeckLayouter& i_rNewLayouter ) 88 { 89 ::std::vector< IToolPanelDeckListener* > aListeners( m_aListeners ); 90 for ( ::std::vector< IToolPanelDeckListener* >::const_iterator loop = aListeners.begin(); 91 loop != aListeners.end(); 92 ++loop 93 ) 94 { 95 (*loop)->LayouterChanged( i_rNewLayouter ); 96 } 97 } 98 99 //-------------------------------------------------------------------- Dying()100 void PanelDeckListeners::Dying() 101 { 102 while ( !m_aListeners.empty() ) 103 { 104 IToolPanelDeckListener* pListener( *m_aListeners.begin() ); 105 m_aListeners.erase( m_aListeners.begin() ); 106 pListener->Dying(); 107 } 108 } 109 110 //-------------------------------------------------------------------- AddListener(IToolPanelDeckListener & i_rListener)111 void PanelDeckListeners::AddListener( IToolPanelDeckListener& i_rListener ) 112 { 113 m_aListeners.push_back( &i_rListener ); 114 } 115 116 //-------------------------------------------------------------------- RemoveListener(IToolPanelDeckListener & i_rListener)117 void PanelDeckListeners::RemoveListener( IToolPanelDeckListener& i_rListener ) 118 { 119 for ( ::std::vector< IToolPanelDeckListener* >::iterator lookup = m_aListeners.begin(); 120 lookup != m_aListeners.end(); 121 ++lookup 122 ) 123 { 124 if ( *lookup == &i_rListener ) 125 { 126 m_aListeners.erase( lookup ); 127 return; 128 } 129 } 130 } 131 132 //........................................................................ 133 } // namespace svt 134 //........................................................................ 135