10841af79SAndrew Rist /**************************************************************
2*d69df039Smseidel  *
30841af79SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
40841af79SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
50841af79SAndrew Rist  * distributed with this work for additional information
60841af79SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
70841af79SAndrew Rist  * to you under the Apache License, Version 2.0 (the
80841af79SAndrew Rist  * "License"); you may not use this file except in compliance
90841af79SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*d69df039Smseidel  *
110841af79SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*d69df039Smseidel  *
130841af79SAndrew Rist  * Unless required by applicable law or agreed to in writing,
140841af79SAndrew Rist  * software distributed under the License is distributed on an
150841af79SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
160841af79SAndrew Rist  * KIND, either express or implied.  See the License for the
170841af79SAndrew Rist  * specific language governing permissions and limitations
180841af79SAndrew Rist  * under the License.
19*d69df039Smseidel  *
200841af79SAndrew Rist  *************************************************************/
210841af79SAndrew Rist 
220841af79SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_accessibility.hxx"
26cdf0e10cSrcweir #include "accessibility/extended/accessibletabbarbase.hxx"
27cdf0e10cSrcweir #ifndef ACCESSIBILITY_EXT_ACCESSIBLETABBARPAGELIST
28cdf0e10cSrcweir #include "accessibility/extended/accessibletabbarpagelist.hxx"
29cdf0e10cSrcweir #endif
30cdf0e10cSrcweir #include <toolkit/helper/externallock.hxx>
31cdf0e10cSrcweir #include <svtools/tabbar.hxx>
32cdf0e10cSrcweir 
33cdf0e10cSrcweir //.........................................................................
34cdf0e10cSrcweir namespace accessibility
35cdf0e10cSrcweir {
36cdf0e10cSrcweir //.........................................................................
37cdf0e10cSrcweir 
AccessibleTabBarBase(TabBar * pTabBar)38cdf0e10cSrcweir AccessibleTabBarBase::AccessibleTabBarBase( TabBar* pTabBar ) :
39*d69df039Smseidel 	AccessibleExtendedComponentHelper_BASE( new VCLExternalSolarLock() ),
40*d69df039Smseidel 	m_pTabBar( 0 )
41cdf0e10cSrcweir {
42*d69df039Smseidel 	m_pExternalLock = static_cast< VCLExternalSolarLock* >( getExternalLock() );
43*d69df039Smseidel 	SetTabBarPointer( pTabBar );
44cdf0e10cSrcweir }
45cdf0e10cSrcweir 
~AccessibleTabBarBase()46cdf0e10cSrcweir AccessibleTabBarBase::~AccessibleTabBarBase()
47cdf0e10cSrcweir {
48*d69df039Smseidel 	ClearTabBarPointer();
49*d69df039Smseidel 	DELETEZ( m_pExternalLock );
50cdf0e10cSrcweir }
51cdf0e10cSrcweir 
IMPL_LINK(AccessibleTabBarBase,WindowEventListener,VclSimpleEvent *,pEvent)52cdf0e10cSrcweir IMPL_LINK( AccessibleTabBarBase, WindowEventListener, VclSimpleEvent*, pEvent )
53cdf0e10cSrcweir {
54*d69df039Smseidel 	VclWindowEvent* pWinEvent = dynamic_cast< VclWindowEvent* >( pEvent );
55*d69df039Smseidel 	DBG_ASSERT( pWinEvent, "AccessibleTabBarBase::WindowEventListener - unknown window event" );
56*d69df039Smseidel 	if( pWinEvent )
57*d69df039Smseidel 	{
58*d69df039Smseidel 		Window* pEventWindow = pWinEvent->GetWindow();
59*d69df039Smseidel 		DBG_ASSERT( pEventWindow, "AccessibleTabBarBase::WindowEventListener: no window!" );
60*d69df039Smseidel 
61*d69df039Smseidel 		if( ( pWinEvent->GetId() == VCLEVENT_TABBAR_PAGEREMOVED ) &&
62*d69df039Smseidel 			( (sal_uInt16)(sal_IntPtr) pWinEvent->GetData() == TabBar::PAGE_NOT_FOUND ) &&
63*d69df039Smseidel 			( dynamic_cast< AccessibleTabBarPageList *> (this) != NULL ) )
64*d69df039Smseidel 		{
65*d69df039Smseidel 			return 0;
66*d69df039Smseidel 		}
67*d69df039Smseidel 
68*d69df039Smseidel 		if ( !pEventWindow->IsAccessibilityEventsSuppressed() || (pWinEvent->GetId() == VCLEVENT_OBJECT_DYING) )
69*d69df039Smseidel 			ProcessWindowEvent( *pWinEvent );
70*d69df039Smseidel 	}
71*d69df039Smseidel 	return 0;
72cdf0e10cSrcweir }
73cdf0e10cSrcweir 
ProcessWindowEvent(const VclWindowEvent & rVclWindowEvent)74cdf0e10cSrcweir void AccessibleTabBarBase::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
75cdf0e10cSrcweir {
76*d69df039Smseidel 	if( rVclWindowEvent.GetId() == VCLEVENT_OBJECT_DYING )
77*d69df039Smseidel 		ClearTabBarPointer();
78cdf0e10cSrcweir }
79cdf0e10cSrcweir 
80cdf0e10cSrcweir // XComponent
81cdf0e10cSrcweir 
disposing()82cdf0e10cSrcweir void AccessibleTabBarBase::disposing()
83cdf0e10cSrcweir {
84*d69df039Smseidel 	AccessibleExtendedComponentHelper_BASE::disposing();
85*d69df039Smseidel 	ClearTabBarPointer();
86cdf0e10cSrcweir }
87cdf0e10cSrcweir 
88cdf0e10cSrcweir // private
89cdf0e10cSrcweir 
SetTabBarPointer(TabBar * pTabBar)90cdf0e10cSrcweir void AccessibleTabBarBase::SetTabBarPointer( TabBar* pTabBar )
91cdf0e10cSrcweir {
92*d69df039Smseidel 	DBG_ASSERT( !m_pTabBar, "AccessibleTabBarBase::SetTabBarPointer - multiple call" );
93*d69df039Smseidel 	m_pTabBar = pTabBar;
94*d69df039Smseidel 	if( m_pTabBar )
95*d69df039Smseidel 		m_pTabBar->AddEventListener( LINK( this, AccessibleTabBarBase, WindowEventListener ) );
96cdf0e10cSrcweir }
97cdf0e10cSrcweir 
ClearTabBarPointer()98cdf0e10cSrcweir void AccessibleTabBarBase::ClearTabBarPointer()
99cdf0e10cSrcweir {
100*d69df039Smseidel 	if( m_pTabBar )
101*d69df039Smseidel 	{
102*d69df039Smseidel 		m_pTabBar->RemoveEventListener( LINK( this, AccessibleTabBarBase, WindowEventListener ) );
103*d69df039Smseidel 		m_pTabBar = 0;
104*d69df039Smseidel 	}
105cdf0e10cSrcweir }
106cdf0e10cSrcweir 
107cdf0e10cSrcweir //.........................................................................
108*d69df039Smseidel }	// namespace accessibility
109cdf0e10cSrcweir //.........................................................................
110cdf0e10cSrcweir 
111