1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 <osx/a11yfocustracker.hxx>
21 #include <osx/a11yfactory.h>
23 #include "a11yfocuslistener.hxx"
25 using namespace ::com::sun::star::accessibility
;
26 using namespace ::com::sun::star::uno
;
28 rtl::Reference
< AquaA11yFocusListener
> AquaA11yFocusListener::theListener
;
30 rtl::Reference
< AquaA11yFocusListener
> const & AquaA11yFocusListener::get()
32 if ( ! theListener
.is() )
33 theListener
= new AquaA11yFocusListener();
38 AquaA11yFocusListener::AquaA11yFocusListener() : m_focusedObject(nil
)
42 id
AquaA11yFocusListener::getFocusedUIElement()
44 if ( nil
== m_focusedObject
) {
45 Reference
< XAccessible
> xAccessible( TheAquaA11yFocusTracker::get().getFocusedObject() );
47 if( xAccessible
.is() ) {
48 Reference
< XAccessibleContext
> xContext(xAccessible
->getAccessibleContext());
50 m_focusedObject
= [ AquaA11yFactory wrapperForAccessibleContext
: xContext
];
52 } catch(const RuntimeException
&) {
53 // intentionally do nothing ..
57 return m_focusedObject
;
61 AquaA11yFocusListener::focusedObjectChanged(const Reference
< XAccessible
>& xAccessible
)
63 if ( nil
!= m_focusedObject
) {
64 [ m_focusedObject release
];
65 m_focusedObject
= nil
;
69 if( xAccessible
.is() ) {
70 Reference
< XAccessibleContext
> xContext(xAccessible
->getAccessibleContext());
73 m_focusedObject
= [ AquaA11yFactory wrapperForAccessibleContext
: xContext
];
74 NSAccessibilityPostNotification(m_focusedObject
, NSAccessibilityFocusedUIElementChangedNotification
);
77 } catch(const RuntimeException
&) {
78 // intentionally do nothing ..
82 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */