1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
21 #include "paneldecklisteners.hxx"
22 #include <svtools/toolpanel/toolpaneldeck.hxx>
30 //= PanelDeckListeners
33 PanelDeckListeners::PanelDeckListeners()
38 PanelDeckListeners::~PanelDeckListeners()
43 void PanelDeckListeners::PanelInserted( const PToolPanel
& i_pPanel
, const size_t i_nPosition
)
45 ::std::vector
< IToolPanelDeckListener
* > aListeners( m_aListeners
);
46 for ( ::std::vector
< IToolPanelDeckListener
* >::const_iterator loop
= aListeners
.begin();
47 loop
!= aListeners
.end();
51 (*loop
)->PanelInserted( i_pPanel
, i_nPosition
);
56 void PanelDeckListeners::PanelRemoved( const size_t i_nPosition
)
58 ::std::vector
< IToolPanelDeckListener
* > aListeners( m_aListeners
);
59 for ( ::std::vector
< IToolPanelDeckListener
* >::const_iterator loop
= aListeners
.begin();
60 loop
!= aListeners
.end();
64 (*loop
)->PanelRemoved( i_nPosition
);
69 void PanelDeckListeners::ActivePanelChanged( const ::boost::optional
< size_t >& i_rOldActive
, const ::boost::optional
< size_t >& i_rNewActive
)
71 ::std::vector
< IToolPanelDeckListener
* > aListeners( m_aListeners
);
72 for ( ::std::vector
< IToolPanelDeckListener
* >::const_iterator loop
= aListeners
.begin();
73 loop
!= aListeners
.end();
77 (*loop
)->ActivePanelChanged( i_rOldActive
, i_rNewActive
);
82 void PanelDeckListeners::LayouterChanged( const PDeckLayouter
& i_rNewLayouter
)
84 ::std::vector
< IToolPanelDeckListener
* > aListeners( m_aListeners
);
85 for ( ::std::vector
< IToolPanelDeckListener
* >::const_iterator loop
= aListeners
.begin();
86 loop
!= aListeners
.end();
90 (*loop
)->LayouterChanged( i_rNewLayouter
);
95 void PanelDeckListeners::Dying()
97 while ( !m_aListeners
.empty() )
99 IToolPanelDeckListener
* pListener( *m_aListeners
.begin() );
100 m_aListeners
.erase( m_aListeners
.begin() );
106 void PanelDeckListeners::AddListener( IToolPanelDeckListener
& i_rListener
)
108 m_aListeners
.push_back( &i_rListener
);
112 void PanelDeckListeners::RemoveListener( IToolPanelDeckListener
& i_rListener
)
114 for ( ::std::vector
< IToolPanelDeckListener
* >::iterator lookup
= m_aListeners
.begin();
115 lookup
!= m_aListeners
.end();
119 if ( *lookup
== &i_rListener
)
121 m_aListeners
.erase( lookup
);
131 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */