1*0841af79SAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*0841af79SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*0841af79SAndrew Rist * or more contributor license agreements. See the NOTICE file
5*0841af79SAndrew Rist * distributed with this work for additional information
6*0841af79SAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*0841af79SAndrew Rist * to you under the Apache License, Version 2.0 (the
8*0841af79SAndrew Rist * "License"); you may not use this file except in compliance
9*0841af79SAndrew Rist * with the License. You may obtain a copy of the License at
10cdf0e10cSrcweir *
11*0841af79SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir *
13*0841af79SAndrew Rist * Unless required by applicable law or agreed to in writing,
14*0841af79SAndrew Rist * software distributed under the License is distributed on an
15*0841af79SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*0841af79SAndrew Rist * KIND, either express or implied. See the License for the
17*0841af79SAndrew Rist * specific language governing permissions and limitations
18*0841af79SAndrew Rist * under the License.
19cdf0e10cSrcweir *
20*0841af79SAndrew Rist *************************************************************/
21*0841af79SAndrew Rist
22*0841af79SAndrew 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 ) :
39cdf0e10cSrcweir AccessibleExtendedComponentHelper_BASE( new VCLExternalSolarLock() ),
40cdf0e10cSrcweir m_pTabBar( 0 )
41cdf0e10cSrcweir {
42cdf0e10cSrcweir m_pExternalLock = static_cast< VCLExternalSolarLock* >( getExternalLock() );
43cdf0e10cSrcweir SetTabBarPointer( pTabBar );
44cdf0e10cSrcweir }
45cdf0e10cSrcweir
~AccessibleTabBarBase()46cdf0e10cSrcweir AccessibleTabBarBase::~AccessibleTabBarBase()
47cdf0e10cSrcweir {
48cdf0e10cSrcweir ClearTabBarPointer();
49cdf0e10cSrcweir DELETEZ( m_pExternalLock );
50cdf0e10cSrcweir }
51cdf0e10cSrcweir
IMPL_LINK(AccessibleTabBarBase,WindowEventListener,VclSimpleEvent *,pEvent)52cdf0e10cSrcweir IMPL_LINK( AccessibleTabBarBase, WindowEventListener, VclSimpleEvent*, pEvent )
53cdf0e10cSrcweir {
54cdf0e10cSrcweir VclWindowEvent* pWinEvent = dynamic_cast< VclWindowEvent* >( pEvent );
55cdf0e10cSrcweir DBG_ASSERT( pWinEvent, "AccessibleTabBarBase::WindowEventListener - unknown window event" );
56cdf0e10cSrcweir if( pWinEvent )
57cdf0e10cSrcweir {
58cdf0e10cSrcweir Window* pEventWindow = pWinEvent->GetWindow();
59cdf0e10cSrcweir DBG_ASSERT( pEventWindow, "AccessibleTabBarBase::WindowEventListener: no window!" );
60cdf0e10cSrcweir
61cdf0e10cSrcweir if( ( pWinEvent->GetId() == VCLEVENT_TABBAR_PAGEREMOVED ) &&
62cdf0e10cSrcweir ( (sal_uInt16)(sal_IntPtr) pWinEvent->GetData() == TabBar::PAGE_NOT_FOUND ) &&
63cdf0e10cSrcweir ( dynamic_cast< AccessibleTabBarPageList *> (this) != NULL ) )
64cdf0e10cSrcweir {
65cdf0e10cSrcweir return 0;
66cdf0e10cSrcweir }
67cdf0e10cSrcweir
68cdf0e10cSrcweir if ( !pEventWindow->IsAccessibilityEventsSuppressed() || (pWinEvent->GetId() == VCLEVENT_OBJECT_DYING) )
69cdf0e10cSrcweir ProcessWindowEvent( *pWinEvent );
70cdf0e10cSrcweir }
71cdf0e10cSrcweir return 0;
72cdf0e10cSrcweir }
73cdf0e10cSrcweir
ProcessWindowEvent(const VclWindowEvent & rVclWindowEvent)74cdf0e10cSrcweir void AccessibleTabBarBase::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
75cdf0e10cSrcweir {
76cdf0e10cSrcweir if( rVclWindowEvent.GetId() == VCLEVENT_OBJECT_DYING )
77cdf0e10cSrcweir ClearTabBarPointer();
78cdf0e10cSrcweir }
79cdf0e10cSrcweir
80cdf0e10cSrcweir // XComponent
81cdf0e10cSrcweir
disposing()82cdf0e10cSrcweir void AccessibleTabBarBase::disposing()
83cdf0e10cSrcweir {
84cdf0e10cSrcweir AccessibleExtendedComponentHelper_BASE::disposing();
85cdf0e10cSrcweir ClearTabBarPointer();
86cdf0e10cSrcweir }
87cdf0e10cSrcweir
88cdf0e10cSrcweir // private
89cdf0e10cSrcweir
SetTabBarPointer(TabBar * pTabBar)90cdf0e10cSrcweir void AccessibleTabBarBase::SetTabBarPointer( TabBar* pTabBar )
91cdf0e10cSrcweir {
92cdf0e10cSrcweir DBG_ASSERT( !m_pTabBar, "AccessibleTabBarBase::SetTabBarPointer - multiple call" );
93cdf0e10cSrcweir m_pTabBar = pTabBar;
94cdf0e10cSrcweir if( m_pTabBar )
95cdf0e10cSrcweir m_pTabBar->AddEventListener( LINK( this, AccessibleTabBarBase, WindowEventListener ) );
96cdf0e10cSrcweir }
97cdf0e10cSrcweir
ClearTabBarPointer()98cdf0e10cSrcweir void AccessibleTabBarBase::ClearTabBarPointer()
99cdf0e10cSrcweir {
100cdf0e10cSrcweir if( m_pTabBar )
101cdf0e10cSrcweir {
102cdf0e10cSrcweir m_pTabBar->RemoveEventListener( LINK( this, AccessibleTabBarBase, WindowEventListener ) );
103cdf0e10cSrcweir m_pTabBar = 0;
104cdf0e10cSrcweir }
105cdf0e10cSrcweir }
106cdf0e10cSrcweir
107cdf0e10cSrcweir //.........................................................................
108cdf0e10cSrcweir } // namespace accessibility
109cdf0e10cSrcweir //.........................................................................
110cdf0e10cSrcweir
111