update dev300-m58
[ooovba.git] / accessibility / source / extended / accessibletabbarbase.cxx
blob99f5a9b1c073fd9af6cfb3eade14d49f198cdb34
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: accessibletabbarbase.cxx,v $
10 * $Revision: 1.3 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_accessibility.hxx"
33 #include "accessibility/extended/accessibletabbarbase.hxx"
34 #ifndef ACCESSIBILITY_EXT_ACCESSIBLETABBARPAGELIST
35 #include "accessibility/extended/accessibletabbarpagelist.hxx"
36 #endif
37 #include <toolkit/helper/externallock.hxx>
38 #include <svtools/tabbar.hxx>
40 //.........................................................................
41 namespace accessibility
43 //.........................................................................
45 AccessibleTabBarBase::AccessibleTabBarBase( TabBar* pTabBar ) :
46 AccessibleExtendedComponentHelper_BASE( new VCLExternalSolarLock() ),
47 m_pTabBar( 0 )
49 m_pExternalLock = static_cast< VCLExternalSolarLock* >( getExternalLock() );
50 SetTabBarPointer( pTabBar );
53 AccessibleTabBarBase::~AccessibleTabBarBase()
55 ClearTabBarPointer();
56 DELETEZ( m_pExternalLock );
59 IMPL_LINK( AccessibleTabBarBase, WindowEventListener, VclSimpleEvent*, pEvent )
61 VclWindowEvent* pWinEvent = dynamic_cast< VclWindowEvent* >( pEvent );
62 DBG_ASSERT( pWinEvent, "AccessibleTabBarBase::WindowEventListener - unknown window event" );
63 if( pWinEvent )
65 Window* pEventWindow = pWinEvent->GetWindow();
66 DBG_ASSERT( pEventWindow, "AccessibleTabBarBase::WindowEventListener: no window!" );
68 if( ( pWinEvent->GetId() == VCLEVENT_TABBAR_PAGEREMOVED ) &&
69 ( (sal_uInt16)(sal_IntPtr) pWinEvent->GetData() == TABBAR_PAGE_NOTFOUND ) &&
70 ( dynamic_cast< AccessibleTabBarPageList *> (this) != NULL ) )
72 return 0;
75 if ( !pEventWindow->IsAccessibilityEventsSuppressed() || (pWinEvent->GetId() == VCLEVENT_OBJECT_DYING) )
76 ProcessWindowEvent( *pWinEvent );
78 return 0;
81 void AccessibleTabBarBase::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
83 if( rVclWindowEvent.GetId() == VCLEVENT_OBJECT_DYING )
84 ClearTabBarPointer();
87 // XComponent
89 void AccessibleTabBarBase::disposing()
91 AccessibleExtendedComponentHelper_BASE::disposing();
92 ClearTabBarPointer();
95 // private
97 void AccessibleTabBarBase::SetTabBarPointer( TabBar* pTabBar )
99 DBG_ASSERT( !m_pTabBar, "AccessibleTabBarBase::SetTabBarPointer - multiple call" );
100 m_pTabBar = pTabBar;
101 if( m_pTabBar )
102 m_pTabBar->AddEventListener( LINK( this, AccessibleTabBarBase, WindowEventListener ) );
105 void AccessibleTabBarBase::ClearTabBarPointer()
107 if( m_pTabBar )
109 m_pTabBar->RemoveEventListener( LINK( this, AccessibleTabBarBase, WindowEventListener ) );
110 m_pTabBar = 0;
114 //.........................................................................
115 } // namespace accessibility
116 //.........................................................................