Branch libreoffice-5-0-4
[LibreOffice.git] / accessibility / source / extended / accessibletabbarbase.cxx
blob18c6ae50b1a377622e2d5d5eb0b68a00f759c30c
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include "accessibility/extended/accessibletabbarbase.hxx"
21 #ifndef ACCESSIBILITY_EXT_ACCESSIBLETABBARPAGELIST
22 #include "accessibility/extended/accessibletabbarpagelist.hxx"
23 #endif
24 #include <toolkit/helper/externallock.hxx>
25 #include <svtools/tabbar.hxx>
28 namespace accessibility
32 AccessibleTabBarBase::AccessibleTabBarBase( TabBar* pTabBar ) :
33 AccessibleExtendedComponentHelper_BASE( new VCLExternalSolarLock() ),
34 m_pTabBar( 0 )
36 m_pExternalLock = static_cast< VCLExternalSolarLock* >( getExternalLock() );
37 SetTabBarPointer( pTabBar );
40 AccessibleTabBarBase::~AccessibleTabBarBase()
42 ClearTabBarPointer();
43 DELETEZ( m_pExternalLock );
46 IMPL_LINK( AccessibleTabBarBase, WindowEventListener, VclSimpleEvent*, pEvent )
48 VclWindowEvent* pWinEvent = dynamic_cast< VclWindowEvent* >( pEvent );
49 OSL_ENSURE( pWinEvent, "AccessibleTabBarBase::WindowEventListener - unknown window event" );
50 if( pWinEvent )
52 vcl::Window* pEventWindow = pWinEvent->GetWindow();
53 OSL_ENSURE( pEventWindow, "AccessibleTabBarBase::WindowEventListener: no window!" );
55 if( ( pWinEvent->GetId() == VCLEVENT_TABBAR_PAGEREMOVED ) &&
56 ( (sal_uInt16)reinterpret_cast<sal_IntPtr>(pWinEvent->GetData()) == TabBar::PAGE_NOT_FOUND ) &&
57 ( dynamic_cast< AccessibleTabBarPageList *> (this) != NULL ) )
59 return 0;
62 if ( !pEventWindow->IsAccessibilityEventsSuppressed() || (pWinEvent->GetId() == VCLEVENT_OBJECT_DYING) )
63 ProcessWindowEvent( *pWinEvent );
65 return 0;
68 void AccessibleTabBarBase::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
70 if( rVclWindowEvent.GetId() == VCLEVENT_OBJECT_DYING )
71 ClearTabBarPointer();
74 // XComponent
76 void AccessibleTabBarBase::disposing()
78 AccessibleExtendedComponentHelper_BASE::disposing();
79 ClearTabBarPointer();
82 // private
84 void AccessibleTabBarBase::SetTabBarPointer( TabBar* pTabBar )
86 OSL_ENSURE( !m_pTabBar, "AccessibleTabBarBase::SetTabBarPointer - multiple call" );
87 m_pTabBar = pTabBar;
88 if( m_pTabBar )
89 m_pTabBar->AddEventListener( LINK( this, AccessibleTabBarBase, WindowEventListener ) );
92 void AccessibleTabBarBase::ClearTabBarPointer()
94 if( m_pTabBar )
96 m_pTabBar->RemoveEventListener( LINK( this, AccessibleTabBarBase, WindowEventListener ) );
97 m_pTabBar = 0;
102 } // namespace accessibility
105 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */