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/accessibletabbarbase.hxx"
27 #ifndef ACCESSIBILITY_EXT_ACCESSIBLETABBARPAGELIST
28 #include "accessibility/extended/accessibletabbarpagelist.hxx"
29 #endif
30 #include <toolkit/helper/externallock.hxx>
31 #include <svtools/tabbar.hxx>
32 
33 //.........................................................................
34 namespace accessibility
35 {
36 //.........................................................................
37 
AccessibleTabBarBase(TabBar * pTabBar)38 AccessibleTabBarBase::AccessibleTabBarBase( TabBar* pTabBar ) :
39 	AccessibleExtendedComponentHelper_BASE( new VCLExternalSolarLock() ),
40 	m_pTabBar( 0 )
41 {
42 	m_pExternalLock = static_cast< VCLExternalSolarLock* >( getExternalLock() );
43 	SetTabBarPointer( pTabBar );
44 }
45 
~AccessibleTabBarBase()46 AccessibleTabBarBase::~AccessibleTabBarBase()
47 {
48 	ClearTabBarPointer();
49 	DELETEZ( m_pExternalLock );
50 }
51 
IMPL_LINK(AccessibleTabBarBase,WindowEventListener,VclSimpleEvent *,pEvent)52 IMPL_LINK( AccessibleTabBarBase, WindowEventListener, VclSimpleEvent*, pEvent )
53 {
54 	VclWindowEvent* pWinEvent = dynamic_cast< VclWindowEvent* >( pEvent );
55 	DBG_ASSERT( pWinEvent, "AccessibleTabBarBase::WindowEventListener - unknown window event" );
56 	if( pWinEvent )
57 	{
58 		Window* pEventWindow = pWinEvent->GetWindow();
59 		DBG_ASSERT( pEventWindow, "AccessibleTabBarBase::WindowEventListener: no window!" );
60 
61 		if( ( pWinEvent->GetId() == VCLEVENT_TABBAR_PAGEREMOVED ) &&
62 			( (sal_uInt16)(sal_IntPtr) pWinEvent->GetData() == TabBar::PAGE_NOT_FOUND ) &&
63 			( dynamic_cast< AccessibleTabBarPageList *> (this) != NULL ) )
64 		{
65 			return 0;
66 		}
67 
68 		if ( !pEventWindow->IsAccessibilityEventsSuppressed() || (pWinEvent->GetId() == VCLEVENT_OBJECT_DYING) )
69 			ProcessWindowEvent( *pWinEvent );
70 	}
71 	return 0;
72 }
73 
ProcessWindowEvent(const VclWindowEvent & rVclWindowEvent)74 void AccessibleTabBarBase::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
75 {
76 	if( rVclWindowEvent.GetId() == VCLEVENT_OBJECT_DYING )
77 		ClearTabBarPointer();
78 }
79 
80 // XComponent
81 
disposing()82 void AccessibleTabBarBase::disposing()
83 {
84 	AccessibleExtendedComponentHelper_BASE::disposing();
85 	ClearTabBarPointer();
86 }
87 
88 // private
89 
SetTabBarPointer(TabBar * pTabBar)90 void AccessibleTabBarBase::SetTabBarPointer( TabBar* pTabBar )
91 {
92 	DBG_ASSERT( !m_pTabBar, "AccessibleTabBarBase::SetTabBarPointer - multiple call" );
93 	m_pTabBar = pTabBar;
94 	if( m_pTabBar )
95 		m_pTabBar->AddEventListener( LINK( this, AccessibleTabBarBase, WindowEventListener ) );
96 }
97 
ClearTabBarPointer()98 void AccessibleTabBarBase::ClearTabBarPointer()
99 {
100 	if( m_pTabBar )
101 	{
102 		m_pTabBar->RemoveEventListener( LINK( this, AccessibleTabBarBase, WindowEventListener ) );
103 		m_pTabBar = 0;
104 	}
105 }
106 
107 //.........................................................................
108 }	// namespace accessibility
109 //.........................................................................
110 
111