cool#10610 Ensure the parent-child relations of comments.
[LibreOffice.git] / svtools / source / control / accessibletabbarbase.cxx
blob08142db60f6f0834ac02131d0d89254bbcd5f320
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 "accessibletabbarbase.hxx"
21 #include "accessibletabbarpagelist.hxx"
23 #include <svtools/tabbar.hxx>
24 #include <vcl/vclevent.hxx>
27 namespace accessibility
31 AccessibleTabBarBase::AccessibleTabBarBase( TabBar* pTabBar ) :
32 m_pTabBar( nullptr )
34 SetTabBarPointer( pTabBar );
37 AccessibleTabBarBase::~AccessibleTabBarBase()
39 ClearTabBarPointer();
42 IMPL_LINK( AccessibleTabBarBase, WindowEventListener, VclWindowEvent&, rEvent, void )
44 vcl::Window* pEventWindow = rEvent.GetWindow();
45 OSL_ENSURE( pEventWindow, "AccessibleTabBarBase::WindowEventListener: no window!" );
47 if( ( rEvent.GetId() == VclEventId::TabbarPageRemoved ) &&
48 ( static_cast<sal_uInt16>(reinterpret_cast<sal_IntPtr>(rEvent.GetData())) == TabBar::PAGE_NOT_FOUND ) &&
49 (dynamic_cast<AccessibleTabBarPageList *>(this) == nullptr))
51 return;
54 if ( !pEventWindow->IsAccessibilityEventsSuppressed() || (rEvent.GetId() == VclEventId::ObjectDying) )
55 ProcessWindowEvent( rEvent );
58 void AccessibleTabBarBase::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
60 if( rVclWindowEvent.GetId() == VclEventId::ObjectDying )
61 ClearTabBarPointer();
64 // XComponent
66 void AccessibleTabBarBase::disposing()
68 OAccessibleExtendedComponentHelper::disposing();
69 ClearTabBarPointer();
72 // private
74 void AccessibleTabBarBase::SetTabBarPointer( TabBar* pTabBar )
76 OSL_ENSURE( !m_pTabBar, "AccessibleTabBarBase::SetTabBarPointer - multiple call" );
77 m_pTabBar = pTabBar;
78 if( m_pTabBar )
79 m_pTabBar->AddEventListener( LINK( this, AccessibleTabBarBase, WindowEventListener ) );
82 void AccessibleTabBarBase::ClearTabBarPointer()
84 if( m_pTabBar )
86 m_pTabBar->RemoveEventListener( LINK( this, AccessibleTabBarBase, WindowEventListener ) );
87 m_pTabBar = nullptr;
92 } // namespace accessibility
95 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */