LanguageTool: don't crash if REST protocol isn't set
[LibreOffice.git] / accessibility / source / extended / accessibletabbarbase.cxx
blob1e213f0711fa0c1d86bcb922b4183c90c5b39917
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 <extended/accessibletabbarbase.hxx>
21 #ifndef ACCESSIBILITY_EXT_ACCESSIBLETABBARPAGELIST
22 #include <extended/accessibletabbarpagelist.hxx>
23 #endif
24 #include <svtools/tabbar.hxx>
25 #include <vcl/vclevent.hxx>
28 namespace accessibility
32 AccessibleTabBarBase::AccessibleTabBarBase( TabBar* pTabBar ) :
33 m_pTabBar( nullptr )
35 SetTabBarPointer( pTabBar );
38 AccessibleTabBarBase::~AccessibleTabBarBase()
40 ClearTabBarPointer();
43 IMPL_LINK( AccessibleTabBarBase, WindowEventListener, VclWindowEvent&, rEvent, void )
45 vcl::Window* pEventWindow = rEvent.GetWindow();
46 OSL_ENSURE( pEventWindow, "AccessibleTabBarBase::WindowEventListener: no window!" );
48 if( ( rEvent.GetId() == VclEventId::TabbarPageRemoved ) &&
49 ( static_cast<sal_uInt16>(reinterpret_cast<sal_IntPtr>(rEvent.GetData())) == TabBar::PAGE_NOT_FOUND ) &&
50 (dynamic_cast<AccessibleTabBarPageList *>(this) == nullptr))
52 return;
55 if ( !pEventWindow->IsAccessibilityEventsSuppressed() || (rEvent.GetId() == VclEventId::ObjectDying) )
56 ProcessWindowEvent( rEvent );
59 void AccessibleTabBarBase::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
61 if( rVclWindowEvent.GetId() == VclEventId::ObjectDying )
62 ClearTabBarPointer();
65 // XComponent
67 void AccessibleTabBarBase::disposing()
69 OAccessibleExtendedComponentHelper::disposing();
70 ClearTabBarPointer();
73 // private
75 void AccessibleTabBarBase::SetTabBarPointer( TabBar* pTabBar )
77 OSL_ENSURE( !m_pTabBar, "AccessibleTabBarBase::SetTabBarPointer - multiple call" );
78 m_pTabBar = pTabBar;
79 if( m_pTabBar )
80 m_pTabBar->AddEventListener( LINK( this, AccessibleTabBarBase, WindowEventListener ) );
83 void AccessibleTabBarBase::ClearTabBarPointer()
85 if( m_pTabBar )
87 m_pTabBar->RemoveEventListener( LINK( this, AccessibleTabBarBase, WindowEventListener ) );
88 m_pTabBar = nullptr;
93 } // namespace accessibility
96 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */