Files
libreoffice/vcl/osx/a11ylistener.cxx

146 lines
5.4 KiB
C++
Raw Normal View History

/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
INTEGRATION: CWS aqua11y01 (1.1.2); FILE ADDED 2008/04/15 07:58:34 rt 1.1.2.17: Update license header to LGPL 3. 2008/02/25 11:46:14 fne 1.1.2.16: #i82877# small fixes 2008/02/19 12:13:19 fne 1.1.2.15: #i82877# notification for caret movement in calc 2008/02/18 22:43:03 obr 1.1.2.14: simulate focus notifications for active descendant changed events 2008/02/18 06:08:55 obr 1.1.2.13: make sure the SalFrameView gets inserted to the wrapper repository early enough and make the listener objects own their wrappers 2008/02/04 14:34:40 fne 1.1.2.12: #i82877# remove wrapper when the corresponding uno ui element is destroyed 2008/02/01 14:37:17 fne 1.1.2.11: #i82877# deleted voiceover imitation 2008/01/31 12:51:22 fne 1.1.2.10: #i82877# send notification when caret moves 2008/01/29 14:33:56 fne 1.1.2.9: #i82877# disabled voiceover imitation and started true voiceover support for text components 2008/01/28 09:20:33 fne 1.1.2.8: #i82877# minor fix 2008/01/24 14:01:31 fne 1.1.2.7: #i82877# voiceover imitation only when voiceover is actually running 2008/01/23 15:27:37 fne 1.1.2.6: #i82877# voiceover imitation regarding typing feedback word-wise 2008/01/22 15:54:14 fne 1.1.2.5: #i82877# further voiceover imitation 2008/01/18 14:05:08 fne 1.1.2.4: #i82877# enhanced text speaking 2008/01/17 14:05:57 fne 1.1.2.3: #i82877# speak typed character 2008/01/16 14:46:16 fne 1.1.2.2: #i82877# initial support for contents of document 2007/11/16 14:19:12 obr 1.1.2.1: #i82877# title/selected children changed events
2008-04-15 12:10:59 +00:00
#include "osx/salinst.h"
#include "osx/a11ylistener.hxx"
#include "osx/a11yfactory.h"
#include "osx/a11yfocustracker.hxx"
#include "osx/a11ywrapper.h"
#include "a11ytextwrapper.h"
INTEGRATION: CWS aqua11y01 (1.1.2); FILE ADDED 2008/04/15 07:58:34 rt 1.1.2.17: Update license header to LGPL 3. 2008/02/25 11:46:14 fne 1.1.2.16: #i82877# small fixes 2008/02/19 12:13:19 fne 1.1.2.15: #i82877# notification for caret movement in calc 2008/02/18 22:43:03 obr 1.1.2.14: simulate focus notifications for active descendant changed events 2008/02/18 06:08:55 obr 1.1.2.13: make sure the SalFrameView gets inserted to the wrapper repository early enough and make the listener objects own their wrappers 2008/02/04 14:34:40 fne 1.1.2.12: #i82877# remove wrapper when the corresponding uno ui element is destroyed 2008/02/01 14:37:17 fne 1.1.2.11: #i82877# deleted voiceover imitation 2008/01/31 12:51:22 fne 1.1.2.10: #i82877# send notification when caret moves 2008/01/29 14:33:56 fne 1.1.2.9: #i82877# disabled voiceover imitation and started true voiceover support for text components 2008/01/28 09:20:33 fne 1.1.2.8: #i82877# minor fix 2008/01/24 14:01:31 fne 1.1.2.7: #i82877# voiceover imitation only when voiceover is actually running 2008/01/23 15:27:37 fne 1.1.2.6: #i82877# voiceover imitation regarding typing feedback word-wise 2008/01/22 15:54:14 fne 1.1.2.5: #i82877# further voiceover imitation 2008/01/18 14:05:08 fne 1.1.2.4: #i82877# enhanced text speaking 2008/01/17 14:05:57 fne 1.1.2.3: #i82877# speak typed character 2008/01/16 14:46:16 fne 1.1.2.2: #i82877# initial support for contents of document 2007/11/16 14:19:12 obr 1.1.2.1: #i82877# title/selected children changed events
2008-04-15 12:10:59 +00:00
#include <com/sun/star/accessibility/AccessibleEventId.hpp>
#include <com/sun/star/accessibility/AccessibleRole.hpp>
#include <com/sun/star/accessibility/AccessibleTableModelChange.hpp>
#include <com/sun/star/accessibility/AccessibleTableModelChangeType.hpp>
using namespace ::com::sun::star::accessibility;
using namespace ::com::sun::star::awt;
INTEGRATION: CWS aqua11y01 (1.1.2); FILE ADDED 2008/04/15 07:58:34 rt 1.1.2.17: Update license header to LGPL 3. 2008/02/25 11:46:14 fne 1.1.2.16: #i82877# small fixes 2008/02/19 12:13:19 fne 1.1.2.15: #i82877# notification for caret movement in calc 2008/02/18 22:43:03 obr 1.1.2.14: simulate focus notifications for active descendant changed events 2008/02/18 06:08:55 obr 1.1.2.13: make sure the SalFrameView gets inserted to the wrapper repository early enough and make the listener objects own their wrappers 2008/02/04 14:34:40 fne 1.1.2.12: #i82877# remove wrapper when the corresponding uno ui element is destroyed 2008/02/01 14:37:17 fne 1.1.2.11: #i82877# deleted voiceover imitation 2008/01/31 12:51:22 fne 1.1.2.10: #i82877# send notification when caret moves 2008/01/29 14:33:56 fne 1.1.2.9: #i82877# disabled voiceover imitation and started true voiceover support for text components 2008/01/28 09:20:33 fne 1.1.2.8: #i82877# minor fix 2008/01/24 14:01:31 fne 1.1.2.7: #i82877# voiceover imitation only when voiceover is actually running 2008/01/23 15:27:37 fne 1.1.2.6: #i82877# voiceover imitation regarding typing feedback word-wise 2008/01/22 15:54:14 fne 1.1.2.5: #i82877# further voiceover imitation 2008/01/18 14:05:08 fne 1.1.2.4: #i82877# enhanced text speaking 2008/01/17 14:05:57 fne 1.1.2.3: #i82877# speak typed character 2008/01/16 14:46:16 fne 1.1.2.2: #i82877# initial support for contents of document 2007/11/16 14:19:12 obr 1.1.2.1: #i82877# title/selected children changed events
2008-04-15 12:10:59 +00:00
using namespace ::com::sun::star::lang;
using namespace ::com::sun::star::uno;
NSString * getTableNotification( const AccessibleEventObject& aEvent )
{
AccessibleTableModelChange aChange;
NSString * notification = nil;
if( (aEvent.NewValue >>= aChange) &&
( AccessibleTableModelChangeType::INSERT == aChange.Type || AccessibleTableModelChangeType::DELETE == aChange.Type ) &&
aChange.FirstRow != aChange.LastRow )
{
notification = NSAccessibilityRowCountChangedNotification;
}
return notification;
}
AquaA11yEventListener::AquaA11yEventListener(id wrapperObject, sal_Int16 role) : m_wrapperObject(wrapperObject), m_role(role)
{
[ m_wrapperObject retain ];
}
AquaA11yEventListener::~AquaA11yEventListener()
{
[ m_wrapperObject release ];
}
void SAL_CALL
AquaA11yEventListener::disposing( const EventObject& ) throw( RuntimeException, std::exception )
INTEGRATION: CWS aqua11y01 (1.1.2); FILE ADDED 2008/04/15 07:58:34 rt 1.1.2.17: Update license header to LGPL 3. 2008/02/25 11:46:14 fne 1.1.2.16: #i82877# small fixes 2008/02/19 12:13:19 fne 1.1.2.15: #i82877# notification for caret movement in calc 2008/02/18 22:43:03 obr 1.1.2.14: simulate focus notifications for active descendant changed events 2008/02/18 06:08:55 obr 1.1.2.13: make sure the SalFrameView gets inserted to the wrapper repository early enough and make the listener objects own their wrappers 2008/02/04 14:34:40 fne 1.1.2.12: #i82877# remove wrapper when the corresponding uno ui element is destroyed 2008/02/01 14:37:17 fne 1.1.2.11: #i82877# deleted voiceover imitation 2008/01/31 12:51:22 fne 1.1.2.10: #i82877# send notification when caret moves 2008/01/29 14:33:56 fne 1.1.2.9: #i82877# disabled voiceover imitation and started true voiceover support for text components 2008/01/28 09:20:33 fne 1.1.2.8: #i82877# minor fix 2008/01/24 14:01:31 fne 1.1.2.7: #i82877# voiceover imitation only when voiceover is actually running 2008/01/23 15:27:37 fne 1.1.2.6: #i82877# voiceover imitation regarding typing feedback word-wise 2008/01/22 15:54:14 fne 1.1.2.5: #i82877# further voiceover imitation 2008/01/18 14:05:08 fne 1.1.2.4: #i82877# enhanced text speaking 2008/01/17 14:05:57 fne 1.1.2.3: #i82877# speak typed character 2008/01/16 14:46:16 fne 1.1.2.2: #i82877# initial support for contents of document 2007/11/16 14:19:12 obr 1.1.2.1: #i82877# title/selected children changed events
2008-04-15 12:10:59 +00:00
{
[ AquaA11yFactory removeFromWrapperRepositoryFor: [ (AquaA11yWrapper *) m_wrapperObject accessibleContext ] ];
}
void SAL_CALL
AquaA11yEventListener::notifyEvent( const AccessibleEventObject& aEvent ) throw( RuntimeException, std::exception )
INTEGRATION: CWS aqua11y01 (1.1.2); FILE ADDED 2008/04/15 07:58:34 rt 1.1.2.17: Update license header to LGPL 3. 2008/02/25 11:46:14 fne 1.1.2.16: #i82877# small fixes 2008/02/19 12:13:19 fne 1.1.2.15: #i82877# notification for caret movement in calc 2008/02/18 22:43:03 obr 1.1.2.14: simulate focus notifications for active descendant changed events 2008/02/18 06:08:55 obr 1.1.2.13: make sure the SalFrameView gets inserted to the wrapper repository early enough and make the listener objects own their wrappers 2008/02/04 14:34:40 fne 1.1.2.12: #i82877# remove wrapper when the corresponding uno ui element is destroyed 2008/02/01 14:37:17 fne 1.1.2.11: #i82877# deleted voiceover imitation 2008/01/31 12:51:22 fne 1.1.2.10: #i82877# send notification when caret moves 2008/01/29 14:33:56 fne 1.1.2.9: #i82877# disabled voiceover imitation and started true voiceover support for text components 2008/01/28 09:20:33 fne 1.1.2.8: #i82877# minor fix 2008/01/24 14:01:31 fne 1.1.2.7: #i82877# voiceover imitation only when voiceover is actually running 2008/01/23 15:27:37 fne 1.1.2.6: #i82877# voiceover imitation regarding typing feedback word-wise 2008/01/22 15:54:14 fne 1.1.2.5: #i82877# further voiceover imitation 2008/01/18 14:05:08 fne 1.1.2.4: #i82877# enhanced text speaking 2008/01/17 14:05:57 fne 1.1.2.3: #i82877# speak typed character 2008/01/16 14:46:16 fne 1.1.2.2: #i82877# initial support for contents of document 2007/11/16 14:19:12 obr 1.1.2.1: #i82877# title/selected children changed events
2008-04-15 12:10:59 +00:00
{
NSString * notification = nil;
id element = m_wrapperObject;
::css::awt::Rectangle bounds;
INTEGRATION: CWS aqua11y01 (1.1.2); FILE ADDED 2008/04/15 07:58:34 rt 1.1.2.17: Update license header to LGPL 3. 2008/02/25 11:46:14 fne 1.1.2.16: #i82877# small fixes 2008/02/19 12:13:19 fne 1.1.2.15: #i82877# notification for caret movement in calc 2008/02/18 22:43:03 obr 1.1.2.14: simulate focus notifications for active descendant changed events 2008/02/18 06:08:55 obr 1.1.2.13: make sure the SalFrameView gets inserted to the wrapper repository early enough and make the listener objects own their wrappers 2008/02/04 14:34:40 fne 1.1.2.12: #i82877# remove wrapper when the corresponding uno ui element is destroyed 2008/02/01 14:37:17 fne 1.1.2.11: #i82877# deleted voiceover imitation 2008/01/31 12:51:22 fne 1.1.2.10: #i82877# send notification when caret moves 2008/01/29 14:33:56 fne 1.1.2.9: #i82877# disabled voiceover imitation and started true voiceover support for text components 2008/01/28 09:20:33 fne 1.1.2.8: #i82877# minor fix 2008/01/24 14:01:31 fne 1.1.2.7: #i82877# voiceover imitation only when voiceover is actually running 2008/01/23 15:27:37 fne 1.1.2.6: #i82877# voiceover imitation regarding typing feedback word-wise 2008/01/22 15:54:14 fne 1.1.2.5: #i82877# further voiceover imitation 2008/01/18 14:05:08 fne 1.1.2.4: #i82877# enhanced text speaking 2008/01/17 14:05:57 fne 1.1.2.3: #i82877# speak typed character 2008/01/16 14:46:16 fne 1.1.2.2: #i82877# initial support for contents of document 2007/11/16 14:19:12 obr 1.1.2.1: #i82877# title/selected children changed events
2008-04-15 12:10:59 +00:00
// TODO: NSAccessibilityValueChanged, NSAccessibilitySelectedRowsChangedNotification
switch( aEvent.EventId )
{
case AccessibleEventId::ACTIVE_DESCENDANT_CHANGED:
if( m_role != AccessibleRole::LIST ) {
Reference< XAccessible > xAccessible;
if( aEvent.NewValue >>= xAccessible )
AquaA11yFocusTracker::get().setFocusedObject( xAccessible );
}
break;
case AccessibleEventId::NAME_CHANGED:
notification = NSAccessibilityTitleChangedNotification;
break;
case AccessibleEventId::CHILD:
// only needed for tooltips (says Apple)
if ( m_role == AccessibleRole::TOOL_TIP ) {
if(aEvent.NewValue.hasValue()) {
notification = NSAccessibilityCreatedNotification;
} else if(aEvent.OldValue.hasValue()) {
notification = NSAccessibilityUIElementDestroyedNotification;
}
}
INTEGRATION: CWS aqua11y01 (1.1.2); FILE ADDED 2008/04/15 07:58:34 rt 1.1.2.17: Update license header to LGPL 3. 2008/02/25 11:46:14 fne 1.1.2.16: #i82877# small fixes 2008/02/19 12:13:19 fne 1.1.2.15: #i82877# notification for caret movement in calc 2008/02/18 22:43:03 obr 1.1.2.14: simulate focus notifications for active descendant changed events 2008/02/18 06:08:55 obr 1.1.2.13: make sure the SalFrameView gets inserted to the wrapper repository early enough and make the listener objects own their wrappers 2008/02/04 14:34:40 fne 1.1.2.12: #i82877# remove wrapper when the corresponding uno ui element is destroyed 2008/02/01 14:37:17 fne 1.1.2.11: #i82877# deleted voiceover imitation 2008/01/31 12:51:22 fne 1.1.2.10: #i82877# send notification when caret moves 2008/01/29 14:33:56 fne 1.1.2.9: #i82877# disabled voiceover imitation and started true voiceover support for text components 2008/01/28 09:20:33 fne 1.1.2.8: #i82877# minor fix 2008/01/24 14:01:31 fne 1.1.2.7: #i82877# voiceover imitation only when voiceover is actually running 2008/01/23 15:27:37 fne 1.1.2.6: #i82877# voiceover imitation regarding typing feedback word-wise 2008/01/22 15:54:14 fne 1.1.2.5: #i82877# further voiceover imitation 2008/01/18 14:05:08 fne 1.1.2.4: #i82877# enhanced text speaking 2008/01/17 14:05:57 fne 1.1.2.3: #i82877# speak typed character 2008/01/16 14:46:16 fne 1.1.2.2: #i82877# initial support for contents of document 2007/11/16 14:19:12 obr 1.1.2.1: #i82877# title/selected children changed events
2008-04-15 12:10:59 +00:00
break;
case AccessibleEventId::INVALIDATE_ALL_CHILDREN:
// TODO: depricate or remember all children
break;
case AccessibleEventId::BOUNDRECT_CHANGED:
bounds = [ element accessibleComponent ] -> getBounds();
if ( m_oldBounds.X != 0 && ( bounds.X != m_oldBounds.X || bounds.Y != m_oldBounds.Y ) ) {
NSAccessibilityPostNotification(element, NSAccessibilityMovedNotification); // post directly since both cases can happen simultaneously
}
if ( m_oldBounds.X != 0 && ( bounds.Width != m_oldBounds.Width || bounds.Height != m_oldBounds.Height ) ) {
NSAccessibilityPostNotification(element, NSAccessibilityResizedNotification); // post directly since both cases can happen simultaneously
}
m_oldBounds = bounds;
INTEGRATION: CWS aqua11y01 (1.1.2); FILE ADDED 2008/04/15 07:58:34 rt 1.1.2.17: Update license header to LGPL 3. 2008/02/25 11:46:14 fne 1.1.2.16: #i82877# small fixes 2008/02/19 12:13:19 fne 1.1.2.15: #i82877# notification for caret movement in calc 2008/02/18 22:43:03 obr 1.1.2.14: simulate focus notifications for active descendant changed events 2008/02/18 06:08:55 obr 1.1.2.13: make sure the SalFrameView gets inserted to the wrapper repository early enough and make the listener objects own their wrappers 2008/02/04 14:34:40 fne 1.1.2.12: #i82877# remove wrapper when the corresponding uno ui element is destroyed 2008/02/01 14:37:17 fne 1.1.2.11: #i82877# deleted voiceover imitation 2008/01/31 12:51:22 fne 1.1.2.10: #i82877# send notification when caret moves 2008/01/29 14:33:56 fne 1.1.2.9: #i82877# disabled voiceover imitation and started true voiceover support for text components 2008/01/28 09:20:33 fne 1.1.2.8: #i82877# minor fix 2008/01/24 14:01:31 fne 1.1.2.7: #i82877# voiceover imitation only when voiceover is actually running 2008/01/23 15:27:37 fne 1.1.2.6: #i82877# voiceover imitation regarding typing feedback word-wise 2008/01/22 15:54:14 fne 1.1.2.5: #i82877# further voiceover imitation 2008/01/18 14:05:08 fne 1.1.2.4: #i82877# enhanced text speaking 2008/01/17 14:05:57 fne 1.1.2.3: #i82877# speak typed character 2008/01/16 14:46:16 fne 1.1.2.2: #i82877# initial support for contents of document 2007/11/16 14:19:12 obr 1.1.2.1: #i82877# title/selected children changed events
2008-04-15 12:10:59 +00:00
break;
case AccessibleEventId::SELECTION_CHANGED:
notification = NSAccessibilitySelectedChildrenChangedNotification;
break;
case AccessibleEventId::TEXT_SELECTION_CHANGED:
notification = NSAccessibilitySelectedTextChangedNotification;
break;
case AccessibleEventId::TABLE_MODEL_CHANGED:
notification = getTableNotification(aEvent);
break;
case AccessibleEventId::CARET_CHANGED:
notification = NSAccessibilitySelectedTextChangedNotification;
break;
case AccessibleEventId::TEXT_CHANGED:
notification = NSAccessibilityValueChangedNotification;
break;
default:
break;
}
if( nil != notification )
NSAccessibilityPostNotification(element, notification);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */