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 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_accessibility.hxx"
26 #include <accessibility/extended/listboxaccessible.hxx>
27 #include <svtools/svtreebx.hxx>
28 
29 //........................................................................
30 namespace accessibility
31 {
32 //........................................................................
33 
34 	//====================================================================
35 	//= ListBoxAccessibleBase
36 	//====================================================================
37 	//--------------------------------------------------------------------
ListBoxAccessibleBase(SvTreeListBox & _rWindow)38 	ListBoxAccessibleBase::ListBoxAccessibleBase( SvTreeListBox& _rWindow )
39 		:m_pWindow( &_rWindow )
40 	{
41 		m_pWindow->AddEventListener( LINK( this, ListBoxAccessibleBase, WindowEventListener ) );
42 	}
43 
44 	//--------------------------------------------------------------------
~ListBoxAccessibleBase()45 	ListBoxAccessibleBase::~ListBoxAccessibleBase( )
46 	{
47 		if ( m_pWindow )
48 		{
49 			// cannot call "dispose" here, as it is abstract, so the VTABLE of the derived class
50 			// is not intact anymore
51 			// so we call our "disposing" only
52 			disposing();
53 		}
54 	}
55 
56 	//--------------------------------------------------------------------
IMPL_LINK(ListBoxAccessibleBase,WindowEventListener,VclSimpleEvent *,pEvent)57 	IMPL_LINK( ListBoxAccessibleBase, WindowEventListener, VclSimpleEvent*, pEvent )
58 	{
59 		DBG_ASSERT( pEvent && pEvent->ISA( VclWindowEvent ), "ListBoxAccessibleBase::WindowEventListener: unexpected WindowEvent!" );
60 		if ( pEvent && pEvent->ISA( VclWindowEvent ) )
61 		{
62 			DBG_ASSERT( static_cast< VclWindowEvent* >( pEvent )->GetWindow() , "ListBoxAccessibleBase::WindowEventListener: no event window!" );
63 			DBG_ASSERT( static_cast< VclWindowEvent* >( pEvent )->GetWindow() == m_pWindow, "ListBoxAccessibleBase::WindowEventListener: where did this come from?" );
64 
65 			ProcessWindowEvent( *static_cast< VclWindowEvent* >( pEvent ) );
66 		}
67 		return 0;
68 	}
69 
70 	// -----------------------------------------------------------------------------
disposing()71 	void ListBoxAccessibleBase::disposing()
72 	{
73 		if ( m_pWindow )
74 			m_pWindow->RemoveEventListener( LINK( this, ListBoxAccessibleBase, WindowEventListener ) );
75 		m_pWindow = NULL;
76 	}
77 
78 	// -----------------------------------------------------------------------------
ProcessWindowEvent(const VclWindowEvent & _rVclWindowEvent)79 	void ListBoxAccessibleBase::ProcessWindowEvent( const VclWindowEvent& _rVclWindowEvent )
80 	{
81 		if ( isAlive() )
82 		{
83 			switch ( _rVclWindowEvent.GetId() )
84 			{
85 				case VCLEVENT_OBJECT_DYING :
86 				{
87 					if ( m_pWindow )
88 						m_pWindow->RemoveEventListener( LINK( this, ListBoxAccessibleBase, WindowEventListener ) );
89 					m_pWindow = NULL;
90 					dispose();
91 					break;
92 				}
93 			}
94 		}
95 	}
96 
97 //........................................................................
98 }	// namespace accessibility
99 //........................................................................
100