Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 : #include <accessibility/extended/listboxaccessible.hxx>
21 : #include <svtools/treelistbox.hxx>
22 :
23 : namespace accessibility
24 : {
25 : // ListBoxAccessibleBase
26 36 : ListBoxAccessibleBase::ListBoxAccessibleBase( SvTreeListBox& _rWindow )
27 36 : :m_pWindow( &_rWindow )
28 : {
29 36 : m_pWindow->AddEventListener( LINK( this, ListBoxAccessibleBase, WindowEventListener ) );
30 36 : }
31 :
32 72 : ListBoxAccessibleBase::~ListBoxAccessibleBase( )
33 : {
34 36 : if ( m_pWindow )
35 : {
36 : // cannot call "dispose" here, as it is abstract, so the VTABLE of the derived class
37 : // is not intact anymore
38 : // so we call our "disposing" only
39 0 : disposing();
40 : }
41 36 : }
42 :
43 576 : IMPL_LINK( ListBoxAccessibleBase, WindowEventListener, VclSimpleEvent*, pEvent )
44 : {
45 : OSL_ENSURE( pEvent && pEvent->ISA( VclWindowEvent ), "ListBoxAccessibleBase::WindowEventListener: unexpected WindowEvent!" );
46 288 : if ( pEvent && pEvent->ISA( VclWindowEvent ) )
47 : {
48 : OSL_ENSURE( static_cast< VclWindowEvent* >( pEvent )->GetWindow() , "ListBoxAccessibleBase::WindowEventListener: no event window!" );
49 : OSL_ENSURE( static_cast< VclWindowEvent* >( pEvent )->GetWindow() == m_pWindow, "ListBoxAccessibleBase::WindowEventListener: where did this come from?" );
50 :
51 288 : ProcessWindowEvent( *static_cast< VclWindowEvent* >( pEvent ) );
52 : }
53 288 : return 0;
54 : }
55 :
56 36 : void ListBoxAccessibleBase::disposing()
57 : {
58 36 : if ( m_pWindow )
59 0 : m_pWindow->RemoveEventListener( LINK( this, ListBoxAccessibleBase, WindowEventListener ) );
60 36 : m_pWindow = NULL;
61 36 : }
62 :
63 288 : void ListBoxAccessibleBase::ProcessWindowEvent( const VclWindowEvent& _rVclWindowEvent )
64 : {
65 288 : if ( isAlive() )
66 : {
67 288 : switch ( _rVclWindowEvent.GetId() )
68 : {
69 : case VCLEVENT_OBJECT_DYING :
70 : {
71 36 : if ( m_pWindow )
72 36 : m_pWindow->RemoveEventListener( LINK( this, ListBoxAccessibleBase, WindowEventListener ) );
73 36 : m_pWindow = NULL;
74 36 : dispose();
75 36 : break;
76 : }
77 : }
78 : }
79 288 : }
80 36 : } // namespace accessibility
81 :
82 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|