Update ooo320-m1
[ooovba.git] / vcl / aqua / source / a11y / aqua11yfocuslistener.cxx
blobc8896b54a462cefa06b599b04af94f0e031f2054
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: aqua11yfocuslistener.cxx,v $
11 * $Revision: 1.2 $
13 * This file is part of OpenOffice.org.
15 * OpenOffice.org is free software: you can redistribute it and/or modify
16 * it under the terms of the GNU Lesser General Public License version 3
17 * only, as published by the Free Software Foundation.
19 * OpenOffice.org is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU Lesser General Public License version 3 for more details
23 * (a copy is included in the LICENSE file that accompanied this code).
25 * You should have received a copy of the GNU Lesser General Public License
26 * version 3 along with OpenOffice.org. If not, see
27 * <http://www.openoffice.org/license.html>
28 * for a copy of the LGPLv3 License.
30 ************************************************************************/
32 // MARKER(update_precomp.py): autogen include statement, do not remove
33 #include "precompiled_vcl.hxx"
35 #include "aqua11yfocuslistener.hxx"
36 #include "aqua11yfocustracker.hxx"
37 #include "aqua11yfactory.h"
39 #include <salhelper/refobj.hxx>
41 using namespace ::com::sun::star::accessibility;
42 using namespace ::com::sun::star::uno;
45 rtl::Reference< AquaA11yFocusListener > AquaA11yFocusListener::theListener;
47 //------------------------------------------------------------------------------
49 rtl::Reference< AquaA11yFocusListener > AquaA11yFocusListener::get()
51 if ( ! theListener.is() )
52 theListener = new AquaA11yFocusListener();
54 return theListener;
57 //------------------------------------------------------------------------------
59 AquaA11yFocusListener::AquaA11yFocusListener() : m_focusedObject(nil)
63 //------------------------------------------------------------------------------
65 id AquaA11yFocusListener::getFocusedUIElement()
67 if ( nil == m_focusedObject ) {
68 Reference< XAccessible > xAccessible( AquaA11yFocusTracker::get().getFocusedObject() );
69 try {
70 if( xAccessible.is() ) {
71 Reference< XAccessibleContext > xContext(xAccessible->getAccessibleContext());
72 if( xContext.is() )
73 m_focusedObject = [ AquaA11yFactory wrapperForAccessibleContext: xContext ];
75 } catch( RuntimeException ) {
76 // intentionally do nothing ..
80 return m_focusedObject;
83 //------------------------------------------------------------------------------
85 void SAL_CALL
86 AquaA11yFocusListener::focusedObjectChanged(const Reference< XAccessible >& xAccessible)
88 if ( nil != m_focusedObject ) {
89 [ m_focusedObject release ];
90 m_focusedObject = nil;
93 try {
94 if( xAccessible.is() ) {
95 Reference< XAccessibleContext > xContext(xAccessible->getAccessibleContext());
96 if( xContext.is() )
98 m_focusedObject = [ AquaA11yFactory wrapperForAccessibleContext: xContext ];
99 NSAccessibilityPostNotification(m_focusedObject, NSAccessibilityFocusedUIElementChangedNotification);
102 } catch( RuntimeException ) {
103 // intentionally do nothing ..
107 //------------------------------------------------------------------------------
109 oslInterlockedCount SAL_CALL
110 AquaA11yFocusListener::acquire() SAL_THROW(())
112 return ReferenceObject::acquire();
115 //------------------------------------------------------------------------------
117 oslInterlockedCount SAL_CALL
118 AquaA11yFocusListener::release() SAL_THROW(())
120 return ReferenceObject::release();