merged tag ooo/DEV300_m102
[LibreOffice.git] / accessibility / source / extended / accessibletabbarbase.cxx
blob5c26185f6b039f36acc2515d1d5f6e94e02e3342
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_accessibility.hxx"
30 #include "accessibility/extended/accessibletabbarbase.hxx"
31 #ifndef ACCESSIBILITY_EXT_ACCESSIBLETABBARPAGELIST
32 #include "accessibility/extended/accessibletabbarpagelist.hxx"
33 #endif
34 #include <toolkit/helper/externallock.hxx>
35 #include <svtools/tabbar.hxx>
37 //.........................................................................
38 namespace accessibility
40 //.........................................................................
42 AccessibleTabBarBase::AccessibleTabBarBase( TabBar* pTabBar ) :
43 AccessibleExtendedComponentHelper_BASE( new VCLExternalSolarLock() ),
44 m_pTabBar( 0 )
46 m_pExternalLock = static_cast< VCLExternalSolarLock* >( getExternalLock() );
47 SetTabBarPointer( pTabBar );
50 AccessibleTabBarBase::~AccessibleTabBarBase()
52 ClearTabBarPointer();
53 DELETEZ( m_pExternalLock );
56 IMPL_LINK( AccessibleTabBarBase, WindowEventListener, VclSimpleEvent*, pEvent )
58 VclWindowEvent* pWinEvent = dynamic_cast< VclWindowEvent* >( pEvent );
59 DBG_ASSERT( pWinEvent, "AccessibleTabBarBase::WindowEventListener - unknown window event" );
60 if( pWinEvent )
62 Window* pEventWindow = pWinEvent->GetWindow();
63 DBG_ASSERT( pEventWindow, "AccessibleTabBarBase::WindowEventListener: no window!" );
65 if( ( pWinEvent->GetId() == VCLEVENT_TABBAR_PAGEREMOVED ) &&
66 ( (sal_uInt16)(sal_IntPtr) pWinEvent->GetData() == TabBar::PAGE_NOT_FOUND ) &&
67 ( dynamic_cast< AccessibleTabBarPageList *> (this) != NULL ) )
69 return 0;
72 if ( !pEventWindow->IsAccessibilityEventsSuppressed() || (pWinEvent->GetId() == VCLEVENT_OBJECT_DYING) )
73 ProcessWindowEvent( *pWinEvent );
75 return 0;
78 void AccessibleTabBarBase::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
80 if( rVclWindowEvent.GetId() == VCLEVENT_OBJECT_DYING )
81 ClearTabBarPointer();
84 // XComponent
86 void AccessibleTabBarBase::disposing()
88 AccessibleExtendedComponentHelper_BASE::disposing();
89 ClearTabBarPointer();
92 // private
94 void AccessibleTabBarBase::SetTabBarPointer( TabBar* pTabBar )
96 DBG_ASSERT( !m_pTabBar, "AccessibleTabBarBase::SetTabBarPointer - multiple call" );
97 m_pTabBar = pTabBar;
98 if( m_pTabBar )
99 m_pTabBar->AddEventListener( LINK( this, AccessibleTabBarBase, WindowEventListener ) );
102 void AccessibleTabBarBase::ClearTabBarPointer()
104 if( m_pTabBar )
106 m_pTabBar->RemoveEventListener( LINK( this, AccessibleTabBarBase, WindowEventListener ) );
107 m_pTabBar = 0;
111 //.........................................................................
112 } // namespace accessibility
113 //.........................................................................