diff options
77 files changed, 36 insertions, 13191 deletions
diff --git a/Repository.mk b/Repository.mk index 02bfe0c84511..5405d6992ad3 100644 --- a/Repository.mk +++ b/Repository.mk @@ -553,9 +553,6 @@ $(eval $(call gb_Helper_register_libraries_for_install,PLAINLIBS_OOO,ooo, \ ftransl \ $(if $(DISABLE_ATL),,\ inprocserv \ - ) \ - $(if $(ENABLE_JAVA),java_uno_accessbridge) \ - $(if $(ENABLE_IA2), \ UAccCOM \ winaccessibility \ ) \ @@ -662,7 +659,6 @@ $(eval $(call gb_Helper_register_jars,OOO, \ fax \ form \ htmlsoff \ - java_uno_accessbridge \ letter \ officebean \ pexcel \ diff --git a/RepositoryModule_host.mk b/RepositoryModule_host.mk index 91141f1020c1..48d5518779e8 100644 --- a/RepositoryModule_host.mk +++ b/RepositoryModule_host.mk @@ -142,7 +142,7 @@ $(eval $(call gb_Module_add_moduledirs,libreoffice,\ uui \ vbahelper \ vcl \ - $(if $(ENABLE_IA2),winaccessibility) \ + winaccessibility \ wizards \ writerfilter \ writerperfect \ diff --git a/accessibility/CustomTarget_bridge.mk b/accessibility/CustomTarget_bridge.mk deleted file mode 100644 index 85f278eb1614..000000000000 --- a/accessibility/CustomTarget_bridge.mk +++ /dev/null @@ -1,33 +0,0 @@ -# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- -# -# 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/. -# - -$(eval $(call gb_CustomTarget_CustomTarget,accessibility/bridge)) - -$(call gb_CustomTarget_get_target,accessibility/bridge) : \ - $(call gb_CustomTarget_get_workdir,accessibility/bridge)/org/openoffice/java/accessibility/Build.java - -ifeq ($(ENABLE_DBGUTIL),TRUE) -accessibility_DEBUG := true -accessibility_PRODUCT := false -else -accessibility_DEBUG := false -accessibility_PRODUCT := true -endif - -$(call gb_CustomTarget_get_workdir,accessibility/bridge)/org/openoffice/java/accessibility/Build.java : - $(call gb_Output_announce,$(subst $(WORKDIR)/,,$@),$(true),ECH,1) - mkdir -p $(dir $@) && (\ - echo package org.openoffice.java.accessibility\; && \ - echo public class Build \{ && \ - echo public static final boolean DEBUG = $(accessibility_DEBUG)\; && \ - echo public static final boolean PRODUCT = $(accessibility_PRODUCT)\; && \ - echo \} \ - ) > $@ - -# vim: set ts=4 sw=4 et: diff --git a/accessibility/CustomTarget_bridge_inc.mk b/accessibility/CustomTarget_bridge_inc.mk deleted file mode 100644 index 8160e6a8c13d..000000000000 --- a/accessibility/CustomTarget_bridge_inc.mk +++ /dev/null @@ -1,23 +0,0 @@ -# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- -# -# 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/. -# - -$(eval $(call gb_CustomTarget_CustomTarget,accessibility/bridge/inc)) - -$(call gb_CustomTarget_get_target,accessibility/bridge/inc) : \ - $(call gb_CustomTarget_get_workdir,accessibility/bridge/inc)/WindowsAccessBridgeAdapter.h - -$(call gb_CustomTarget_get_workdir,accessibility/bridge/inc)/WindowsAccessBridgeAdapter.h :| \ - $(call gb_CustomTarget_get_workdir,accessibility/bridge/inc)/.dir \ - $(call gb_Jar_get_target,java_uno_accessbridge) - $(call gb_Output_announce,$(subst $(WORKDIR)/,,$@),$(true),JVH,1) - cd $(call gb_JavaClassSet_get_classdir,$(call gb_Jar_get_classsetname,java_uno_accessbridge)) && \ - javah -classpath "$(call gb_Jar_get_target,ridl)$(gb_CLASSPATHSEP)$(call gb_Jar_get_target,unoil)$(gb_CLASSPATHSEP)." \ - -o $@ org.openoffice.accessibility.WindowsAccessBridgeAdapter - -# vim: set ts=4 sw=4 et: diff --git a/accessibility/Jar_uno_accessbridge.mk b/accessibility/Jar_uno_accessbridge.mk deleted file mode 100644 index 807853586cd3..000000000000 --- a/accessibility/Jar_uno_accessbridge.mk +++ /dev/null @@ -1,80 +0,0 @@ -# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- -# -# 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/. -# - -$(eval $(call gb_Jar_Jar,java_uno_accessbridge)) - -$(eval $(call gb_Jar_use_jars,java_uno_accessbridge,\ - jurt \ - ridl \ - unoil \ -)) - -$(eval $(call gb_Jar_set_packageroot,java_uno_accessbridge,org)) - -$(eval $(call gb_Jar_set_manifest,java_uno_accessbridge,$(SRCDIR)/accessibility/bridge/org/openoffice/accessibility/manifest)) - -$(eval $(call gb_Jar_set_componentfile,java_uno_accessbridge,accessibility/bridge/org/openoffice/accessibility/java_uno_accessbridge,OOO)) - -$(eval $(call gb_Jar_add_sourcefiles,java_uno_accessbridge,\ - accessibility/bridge/org/openoffice/accessibility/AccessBridge \ - accessibility/bridge/org/openoffice/accessibility/KeyHandler \ - accessibility/bridge/org/openoffice/accessibility/PopupWindow \ - accessibility/bridge/org/openoffice/accessibility/WindowsAccessBridgeAdapter \ - accessibility/bridge/org/openoffice/java/accessibility/AbstractButton \ - accessibility/bridge/org/openoffice/java/accessibility/AccessibleActionImpl \ - accessibility/bridge/org/openoffice/java/accessibility/AccessibleComponentImpl \ - accessibility/bridge/org/openoffice/java/accessibility/AccessibleEditableTextImpl \ - accessibility/bridge/org/openoffice/java/accessibility/AccessibleExtendedState \ - accessibility/bridge/org/openoffice/java/accessibility/AccessibleHypertextImpl \ - accessibility/bridge/org/openoffice/java/accessibility/AccessibleIconImpl \ - accessibility/bridge/org/openoffice/java/accessibility/AccessibleKeyBinding \ - accessibility/bridge/org/openoffice/java/accessibility/AccessibleObjectFactory \ - accessibility/bridge/org/openoffice/java/accessibility/AccessibleRoleAdapter \ - accessibility/bridge/org/openoffice/java/accessibility/AccessibleSelectionImpl \ - accessibility/bridge/org/openoffice/java/accessibility/AccessibleStateAdapter \ - accessibility/bridge/org/openoffice/java/accessibility/AccessibleTextImpl \ - accessibility/bridge/org/openoffice/java/accessibility/AccessibleValueImpl \ - accessibility/bridge/org/openoffice/java/accessibility/Alert \ - accessibility/bridge/org/openoffice/java/accessibility/Application \ - accessibility/bridge/org/openoffice/java/accessibility/Button \ - accessibility/bridge/org/openoffice/java/accessibility/CheckBox \ - accessibility/bridge/org/openoffice/java/accessibility/ComboBox \ - accessibility/bridge/org/openoffice/java/accessibility/Component \ - accessibility/bridge/org/openoffice/java/accessibility/Container \ - accessibility/bridge/org/openoffice/java/accessibility/DescendantManager \ - accessibility/bridge/org/openoffice/java/accessibility/Dialog \ - accessibility/bridge/org/openoffice/java/accessibility/FocusTraversalPolicy \ - accessibility/bridge/org/openoffice/java/accessibility/Frame \ - accessibility/bridge/org/openoffice/java/accessibility/Icon \ - accessibility/bridge/org/openoffice/java/accessibility/Label \ - accessibility/bridge/org/openoffice/java/accessibility/List \ - accessibility/bridge/org/openoffice/java/accessibility/Menu \ - accessibility/bridge/org/openoffice/java/accessibility/MenuContainer \ - accessibility/bridge/org/openoffice/java/accessibility/MenuItem \ - accessibility/bridge/org/openoffice/java/accessibility/NativeFrame \ - accessibility/bridge/org/openoffice/java/accessibility/Paragraph \ - accessibility/bridge/org/openoffice/java/accessibility/RadioButton \ - accessibility/bridge/org/openoffice/java/accessibility/ScrollBar \ - accessibility/bridge/org/openoffice/java/accessibility/Separator \ - accessibility/bridge/org/openoffice/java/accessibility/Table \ - accessibility/bridge/org/openoffice/java/accessibility/TextComponent \ - accessibility/bridge/org/openoffice/java/accessibility/ToggleButton \ - accessibility/bridge/org/openoffice/java/accessibility/ToolTip \ - accessibility/bridge/org/openoffice/java/accessibility/Tree \ - accessibility/bridge/org/openoffice/java/accessibility/Window \ - accessibility/bridge/org/openoffice/java/accessibility/logging/XAccessibleEventLog \ - accessibility/bridge/org/openoffice/java/accessibility/logging/XAccessibleHypertextLog \ - accessibility/bridge/org/openoffice/java/accessibility/logging/XAccessibleTextLog \ -)) - -$(eval $(call gb_Jar_add_generated_sourcefiles,java_uno_accessbridge,\ - CustomTarget/accessibility/bridge/org/openoffice/java/accessibility/Build \ -)) - -# vim:set noet sw=4 ts=4: diff --git a/accessibility/Library_java_uno_accessbridge.mk b/accessibility/Library_java_uno_accessbridge.mk deleted file mode 100644 index 2c643e0f90c5..000000000000 --- a/accessibility/Library_java_uno_accessbridge.mk +++ /dev/null @@ -1,32 +0,0 @@ -# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- -# -# 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/. -# - -$(eval $(call gb_Library_Library,java_uno_accessbridge)) - -$(eval $(call gb_Library_use_custom_headers,java_uno_accessbridge,accessibility/bridge/inc)) - -$(eval $(call gb_Library_use_external,java_uno_accessbridge,boost_headers)) - -$(eval $(call gb_Library_use_sdk_api,java_uno_accessbridge,)) - -$(eval $(call gb_Library_use_libraries,java_uno_accessbridge,\ - cppu \ - jvmaccess \ - sal \ - salhelper \ - tl \ - vcl \ - $(gb_UWINAPI) \ -)) - -$(eval $(call gb_Library_add_exception_objects,java_uno_accessbridge,\ - accessibility/bridge/source/java/WindowsAccessBridgeAdapter \ -)) - -# vim:set noet sw=4 ts=4: diff --git a/accessibility/Module_accessibility.mk b/accessibility/Module_accessibility.mk index e5e090ca89ee..1c565a5d7234 100644 --- a/accessibility/Module_accessibility.mk +++ b/accessibility/Module_accessibility.mk @@ -17,15 +17,4 @@ $(eval $(call gb_Module_add_l10n_targets,accessibility,\ AllLangResTarget_acc \ )) -ifneq ($(ENABLE_JAVA),) -ifeq ($(OS),WNT) -$(eval $(call gb_Module_add_targets,accessibility,\ - CustomTarget_bridge \ - CustomTarget_bridge_inc \ - Jar_uno_accessbridge \ - Library_java_uno_accessbridge \ -)) -endif -endif - # vim:set noet sw=4 ts=4: diff --git a/accessibility/bridge/org/openoffice/accessibility/AccessBridge.java b/accessibility/bridge/org/openoffice/accessibility/AccessBridge.java deleted file mode 100644 index ebd0552a4d26..000000000000 --- a/accessibility/bridge/org/openoffice/accessibility/AccessBridge.java +++ /dev/null @@ -1,232 +0,0 @@ -/* - * 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 . - */ -package org.openoffice.accessibility; - -import com.sun.star.accessibility.AccessibleRole; -import com.sun.star.accessibility.XAccessible; -import com.sun.star.accessibility.XAccessibleContext; -import com.sun.star.awt.XExtendedToolkit; -import com.sun.star.awt.XTopWindowListener; -import com.sun.star.comp.loader.FactoryHelper; -import com.sun.star.lang.XComponent; -import com.sun.star.lang.XInitialization; -import com.sun.star.lang.XMultiServiceFactory; -import com.sun.star.lang.XSingleServiceFactory; -import com.sun.star.registry.*; -import com.sun.star.uno.*; - -import org.openoffice.java.accessibility.*; - -import java.awt.EventQueue; -import java.awt.Window; - - -public class AccessBridge { - // - protected static java.util.HashMap<String, Window> topWindowMap = new java.util.HashMap<String, Window>(); - - private static java.awt.Window getTopWindowImpl(XAccessible xAccessible) { - // Because it can not be garantied that - // WindowsAccessBridgeAdapter.registerTopWindow() is called - // before windowOpened(), we have to make this operation - // atomic. - synchronized (topWindowMap) { - String oid = UnoRuntime.generateOid(xAccessible); - java.awt.Window w = topWindowMap.get(oid); - - if (w == null) { - w = AccessibleObjectFactory.getTopWindow(xAccessible); - - if (w != null) { - topWindowMap.put(oid, w); - } - } - - return w; - } - } - - protected static java.awt.Window getTopWindow(XAccessible xAccessible) { - if (xAccessible != null) { - XAccessibleContext xAccessibleContext = xAccessible.getAccessibleContext(); - if (xAccessibleContext != null) { - - // Toolkit reports the VCL peer windows as toplevels. These have an - // accessible parent which represents the native frame window - switch(xAccessibleContext.getAccessibleRole()) { - case AccessibleRole.ROOT_PANE: - case AccessibleRole.POPUP_MENU: - return getTopWindow(xAccessibleContext.getAccessibleParent()); - - case AccessibleRole.WINDOW: - case AccessibleRole.FRAME: - case AccessibleRole.DIALOG: - case AccessibleRole.ALERT: - return getTopWindowImpl(xAccessible); - - default: - break; - } - } - } - - return null; - } - - protected static java.awt.Window removeTopWindow(XAccessible xAccessible) { - if (xAccessible != null) { - XAccessibleContext xAccessibleContext = xAccessible.getAccessibleContext(); - if (xAccessibleContext != null) { - - // Toolkit reports the VCL peer windows as toplevels. These have an - // accessible parent which represents the native frame window - switch(xAccessibleContext.getAccessibleRole()) { - case AccessibleRole.ROOT_PANE: - case AccessibleRole.POPUP_MENU: - return removeTopWindow(xAccessibleContext.getAccessibleParent()); - - case AccessibleRole.WINDOW: - case AccessibleRole.FRAME: - case AccessibleRole.DIALOG: - return topWindowMap.remove(UnoRuntime.generateOid(xAccessible)); - - default: - break; - } - } - } - - return null; - } - - public static XSingleServiceFactory __getServiceFactory(String implName, - XMultiServiceFactory multiFactory, XRegistryKey regKey) { - XSingleServiceFactory xSingleServiceFactory = null; - - if (implName.equals(AccessBridge.class.getName())) { - // Initialize toolkit to register at Java <-> Windows access bridge - java.awt.Toolkit.getDefaultToolkit(); - - xSingleServiceFactory = FactoryHelper.getServiceFactory(_AccessBridge.class, - _AccessBridge._serviceName, multiFactory, regKey); - } - - return xSingleServiceFactory; - } - - static public class _AccessBridge implements XTopWindowListener, - XInitialization, XComponent { - static final String _serviceName = "com.sun.star.accessibility.AccessBridge"; - XComponentContext xComponentContext; - - public _AccessBridge(XComponentContext xComponentContext) { - this.xComponentContext = xComponentContext; - } - - /* - * XInitialization - */ - public void initialize(java.lang.Object[] arguments) { - try { - // FIXME: Currently there is no way to determine if key event forwarding is needed or not, - // so we have to do it always .. - XExtendedToolkit unoToolkit = (XExtendedToolkit) AnyConverter.toObject(new Type( - XExtendedToolkit.class), arguments[0]); - - if (unoToolkit != null) { - // FIXME this should be done in VCL - unoToolkit.addTopWindowListener(this); - - String os = System.getProperty("os.name"); - - // Try to initialize the WindowsAccessBridgeAdapter - if (os.startsWith("Windows")) { - WindowsAccessBridgeAdapter.attach(xComponentContext); - } else { - unoToolkit.addKeyHandler(new KeyHandler()); - } - } else if (Build.DEBUG) { - System.err.println( - "argument 0 is not of type XExtendedToolkit."); - } - } catch (com.sun.star.lang.IllegalArgumentException e) { - // FIXME: output - } - } - - /* - * XTopWindowListener - */ - public void windowOpened(com.sun.star.lang.EventObject event) { - XAccessible xAccessible = UnoRuntime.queryInterface(XAccessible.class, - event.Source); - java.awt.Window w = getTopWindow(xAccessible); - } - - public void windowActivated(com.sun.star.lang.EventObject event) { - } - - public void windowDeactivated(com.sun.star.lang.EventObject event) { - } - - public void windowMinimized(com.sun.star.lang.EventObject event) { - } - - public void windowNormalized(com.sun.star.lang.EventObject event) { - } - - public void windowClosing(com.sun.star.lang.EventObject event) { - } - - public void windowClosed(com.sun.star.lang.EventObject event) { - XAccessible xAccessible = UnoRuntime.queryInterface(XAccessible.class, - event.Source); - - java.awt.Window w = removeTopWindow(xAccessible); - - if (w != null) { - w.dispose(); - } - } - - public void disposing(com.sun.star.lang.EventObject event) { - } - - /* - * XComponent - */ - - public void addEventListener(com.sun.star.lang.XEventListener listener) { - } - - public void removeEventListener(com.sun.star.lang.XEventListener listener) { - } - - public void dispose() { - try { - EventQueue.invokeAndWait( - new Runnable() { - public void run() { - } - } ); - } catch (java.lang.InterruptedException e) { - } catch (java.lang.reflect.InvocationTargetException e) { - } - } - } -} diff --git a/accessibility/bridge/org/openoffice/accessibility/KeyHandler.java b/accessibility/bridge/org/openoffice/accessibility/KeyHandler.java deleted file mode 100644 index 0975839181f0..000000000000 --- a/accessibility/bridge/org/openoffice/accessibility/KeyHandler.java +++ /dev/null @@ -1,125 +0,0 @@ -/* - * 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 . - */ - - -package org.openoffice.accessibility; - -import com.sun.star.awt.XKeyHandler; -import org.openoffice.java.accessibility.AccessibleKeyBinding; -import java.awt.*; -import java.awt.event.KeyEvent; - -public class KeyHandler extends Component implements XKeyHandler, java.awt.KeyEventDispatcher { - EventQueue eventQueue; - - public class VCLKeyEvent extends KeyEvent implements Runnable { - boolean consumed = true; - - public VCLKeyEvent(Component c, int id, int modifiers, int keyCode, char keyChar) { - super(c, id, System.currentTimeMillis(), modifiers, keyCode, keyChar); - } - - public void run() { - // This is a no-op .. - } - - public void setConsumed(boolean b) { - consumed = b; - } - - public boolean isConsumed() { - return consumed; - } - } - - public KeyHandler() { - eventQueue = Toolkit.getDefaultToolkit().getSystemEventQueue(); - java.awt.KeyboardFocusManager.getCurrentKeyboardFocusManager().addKeyEventDispatcher(this); - } - - /** This method is called by the current KeyboardFocusManager requesting that this KeyEventDispatcher - * dispatch the specified event on its behalf - */ - public boolean dispatchKeyEvent(java.awt.event.KeyEvent e) { - if (e instanceof VCLKeyEvent) { - VCLKeyEvent event = (VCLKeyEvent) e; - event.setConsumed(false); - return true; - } - return false; - } - - /** Handler for KeyPressed events */ - public boolean keyPressed(com.sun.star.awt.KeyEvent event) { -// try { - VCLKeyEvent vke = new VCLKeyEvent(this, KeyEvent.KEY_PRESSED, - AccessibleKeyBinding.convertModifiers(event.Modifiers), - AccessibleKeyBinding.convertKeyCode(event.KeyCode), - event.KeyChar != 0 ? event.KeyChar : KeyEvent.CHAR_UNDEFINED); - - eventQueue.postEvent(vke); - - // VCL events for TABs have empty KeyChar - if (event.KeyCode == com.sun.star.awt.Key.TAB ) { - event.KeyChar = '\t'; - } - - // Synthesize KEY_TYPED event to emulate Java behavior - if (event.KeyChar != 0) { - eventQueue.postEvent(new VCLKeyEvent(this, - KeyEvent.KEY_TYPED, - AccessibleKeyBinding.convertModifiers(event.Modifiers), - KeyEvent.VK_UNDEFINED, - event.KeyChar)); - } - - // Wait until the key event is processed - return false; -// eventQueue.invokeAndWait(vke); -// return vke.isConsumed(); -// } catch(java.lang.InterruptedException e) { -// return false; -// } catch(java.lang.reflect.InvocationTargetException e) { -// return false; -// } - } - - /** Handler for KeyReleased events */ - public boolean keyReleased(com.sun.star.awt.KeyEvent event) { -// try { - VCLKeyEvent vke = new VCLKeyEvent(this, KeyEvent.KEY_RELEASED, - AccessibleKeyBinding.convertModifiers(event.Modifiers), - AccessibleKeyBinding.convertKeyCode(event.KeyCode), - event.KeyChar != 0 ? event.KeyChar : KeyEvent.CHAR_UNDEFINED); - eventQueue.postEvent(vke); - - // Wait until the key event is processed - return false; -// eventQueue.invokeAndWait(vke); -// return vke.isConsumed(); -// } catch(java.lang.InterruptedException e) { -// return false; -// } catch(java.lang.reflect.InvocationTargetException e) { -// return false; -// } - } - - public void disposing(com.sun.star.lang.EventObject event) { - java.awt.KeyboardFocusManager.getCurrentKeyboardFocusManager().removeKeyEventDispatcher(this); - } -} diff --git a/accessibility/bridge/org/openoffice/accessibility/PopupWindow.java b/accessibility/bridge/org/openoffice/accessibility/PopupWindow.java deleted file mode 100644 index 9f7929357da9..000000000000 --- a/accessibility/bridge/org/openoffice/accessibility/PopupWindow.java +++ /dev/null @@ -1,203 +0,0 @@ -/* - * 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 . - */ -package org.openoffice.accessibility; - -import javax.accessibility.AccessibleContext; - -import org.openoffice.java.accessibility.*; - - -/** - * - */ -public class PopupWindow extends java.awt.Window { - javax.accessibility.AccessibleContext accessibleContext = null; - ContainerProxy layeredPane = new ContainerProxy(javax.accessibility.AccessibleRole.LAYERED_PANE); - ContainerProxy rootPane = new ContainerProxy(javax.accessibility.AccessibleRole.ROOT_PANE); - ContainerProxy popupLayer = new ContainerProxy(javax.accessibility.AccessibleRole.PANEL); - boolean opened = false; - boolean visible = false; - - /** Creates a new instance of PopupWindow */ - public PopupWindow(java.awt.Window owner) { - super(owner); - super.add(rootPane); - rootPane.add(layeredPane); - - javax.accessibility.AccessibleContext ac = rootPane.getAccessibleContext(); - - if (ac != null) { - ac.setAccessibleParent(this); - } - } - - static PopupWindow create( - com.sun.star.accessibility.XAccessible xAccessible) { - java.awt.Window parent = java.awt.KeyboardFocusManager.getCurrentKeyboardFocusManager() - .getActiveWindow(); - - if (parent != null) { - PopupWindow w = new PopupWindow(parent); - w.setVisible(true); - AccessibleObjectFactory.invokeAndWait(); - AccessibleObjectFactory.addChild(w, xAccessible); - - return w; - } - - return null; - } - - public boolean isShowing() { - if (isVisible()) { - java.awt.Container parent = getParent(); - - return (parent == null) || parent.isShowing(); - } - - return false; - } - - public void addNotify() { - } - - public void removeNotify() { - } - - public boolean isVisible() { - return visible; - } - - public void setVisible(boolean b) { - if (visible != b) { - visible = b; - - if (b) { - // If it is the first show, fire WINDOW_OPENED event - if (!opened) { - AccessibleObjectFactory.postWindowOpened(this); - opened = true; - } - } - } - } - - public java.awt.Component add(java.awt.Component c) { - popupLayer.add(c); - layeredPane.add(popupLayer); - - if (c instanceof javax.accessibility.Accessible) { - javax.accessibility.AccessibleContext ac = layeredPane.getAccessibleContext(); - - if (ac != null) { - ac.firePropertyChange(AccessibleContext.ACCESSIBLE_CHILD_PROPERTY, null, - popupLayer.getAccessibleContext()); - } - } - - return c; - } - - public void remove(java.awt.Component c) { - layeredPane.remove(popupLayer); - - if (c instanceof javax.accessibility.Accessible) { - javax.accessibility.AccessibleContext ac = layeredPane.getAccessibleContext(); - - if (ac != null) { - ac.firePropertyChange(AccessibleContext.ACCESSIBLE_CHILD_PROPERTY, - popupLayer.getAccessibleContext(), null); - } - } - - popupLayer.remove(c); - } - - public void dispose() { - setVisible(false); - AccessibleObjectFactory.postWindowClosed(this); - } - - public javax.accessibility.AccessibleContext getAccessibleContext() { - if (accessibleContext == null) { - accessibleContext = new AccessiblePopupWindow(); - } - - return accessibleContext; - } - - protected class AccessiblePopupWindow - extends java.awt.Window.AccessibleAWTWindow { - AccessiblePopupWindow() { - } - } - - protected class ContainerProxy extends java.awt.Container - implements javax.accessibility.Accessible { - javax.accessibility.AccessibleContext accessibleContext = null; - javax.accessibility.AccessibleRole role; - - protected ContainerProxy(javax.accessibility.AccessibleRole role) { - this.role = role; - } - - public java.awt.Component add(java.awt.Component c) { - if (c instanceof javax.accessibility.Accessible) { - javax.accessibility.Accessible a = (javax.accessibility.Accessible) c; - javax.accessibility.AccessibleContext ac = a.getAccessibleContext(); - - if (ac != null) { - ac.setAccessibleParent(this); - } - } - - return super.add(c); - } - - public void remove(java.awt.Component c) { - if (c instanceof javax.accessibility.Accessible) { - javax.accessibility.Accessible a = (javax.accessibility.Accessible) c; - javax.accessibility.AccessibleContext ac = a.getAccessibleContext(); - - if (ac != null) { - ac.setAccessibleParent(null); - } - } - - super.remove(c); - } - - public javax.accessibility.AccessibleContext getAccessibleContext() { - if (accessibleContext == null) { - accessibleContext = new AccessibleContainerProxy(); - } - - return accessibleContext; - } - - private class AccessibleContainerProxy - extends java.awt.Container.AccessibleAWTContainer { - AccessibleContainerProxy() { - } - - public javax.accessibility.AccessibleRole getAccessibleRole() { - return ContainerProxy.this.role; - } - } - } -} diff --git a/accessibility/bridge/org/openoffice/accessibility/WindowsAccessBridgeAdapter.java b/accessibility/bridge/org/openoffice/accessibility/WindowsAccessBridgeAdapter.java deleted file mode 100644 index 5d7a81750b48..000000000000 --- a/accessibility/bridge/org/openoffice/accessibility/WindowsAccessBridgeAdapter.java +++ /dev/null @@ -1,645 +0,0 @@ -/* - * 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 . - */ -package org.openoffice.accessibility; - -import com.sun.star.accessibility.AccessibleRole; -import com.sun.star.accessibility.XAccessible; -import com.sun.star.accessibility.XAccessibleContext; -import com.sun.star.java.XJavaVM; -import com.sun.star.uno.*; - -import org.openoffice.java.accessibility.*; - -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; - -import javax.accessibility.*; - - -public class WindowsAccessBridgeAdapter { - private static Method registerVirtualFrame; - private static Method revokeVirtualFrame; - private static java.util.HashMap<Integer, Accessible> frameMap; - - protected static native byte[] getProcessID(); - - protected static native boolean createMapping(long jvmaccess); - - // On Windows all native frames must be registered to the access bridge. - // Therefor the bridge exports two methods that we try to find here. - protected static void attach(XComponentContext xComponentContext) { - try { - Class<?> bridge = Class.forName( - "com.sun.java.accessibility.AccessBridge"); - Class<?>[] parameterTypes = { - javax.accessibility.Accessible.class, Integer.class - }; - - if (bridge != null) { - registerVirtualFrame = bridge.getMethod("registerVirtualFrame", - parameterTypes); - revokeVirtualFrame = bridge.getMethod("revokeVirtualFrame", - parameterTypes); - - // load the native dll - System.loadLibrary("java_uno_accessbridge"); - - Object any = xComponentContext.getValueByName( - "/singletons/com.sun.star.java.theJavaVirtualMachine"); - - if (AnyConverter.isObject(any)) { - XJavaVM xJavaVM = UnoRuntime.queryInterface(XJavaVM.class, - AnyConverter.toObject(new Type(XJavaVM.class), any)); - - if (xJavaVM != null) { - any = xJavaVM.getJavaVM(getProcessID()); - - if (AnyConverter.isLong(any)) { - createMapping(AnyConverter.toLong(any)); - frameMap = new java.util.HashMap<Integer, Accessible>(); - } - } - } - } - } catch (NoSuchMethodException e) { - System.err.println("ERROR: incompatible AccessBridge found: " + - e.getMessage()); - - // Forward this exception to UNO to indicate that the service will - // not work correctly. - throw new com.sun.star.uno.RuntimeException( - "incompatible AccessBridge class: " + e.getMessage()); - } catch (java.lang.SecurityException e) { - System.err.println("ERROR: no access to AccessBridge: " + - e.getMessage()); - - // Forward this exception to UNO to indicate that the service will not work correctly. - throw new com.sun.star.uno.RuntimeException( - "Security exception caught: " + e.getMessage()); - } catch (ClassNotFoundException e) { - // Forward this exception to UNO to indicate that the service will not work correctly. - throw new com.sun.star.uno.RuntimeException( - "ClassNotFound exception caught: " + e.getMessage()); - } catch (IllegalArgumentException e) { - System.err.println("IllegalArgumentException caught: " + - e.getMessage()); - - // Forward this exception to UNO to indicate that the service will not work correctly. - throw new com.sun.star.uno.RuntimeException( - "IllegalArgumentException caught: " + e.getMessage()); - } catch (com.sun.star.lang.IllegalArgumentException e) { - System.err.println("UNO IllegalArgumentException caught: " + - e.getMessage()); - - // Forward this exception to UNO to indicate that the service will not work correctly. - throw new com.sun.star.uno.RuntimeException( - "UNO IllegalArgumentException caught: " + e.getMessage()); - } - } - - protected static boolean isAttached() { - return frameMap != null; - } - - protected static Accessible getAccessibleWrapper(XAccessible xAccessible) { - Accessible a = null; - - try { - XAccessibleContext xAccessibleContext = xAccessible.getAccessibleContext(); - - if (xAccessibleContext != null) { - switch (xAccessibleContext.getAccessibleRole()) { - case AccessibleRole.LIST: - a = (Accessible) AccessibleObjectFactory.getAccessibleComponent(xAccessible); - if (a != null) { - a = new ListProxy(a.getAccessibleContext()); - } - break; - - case AccessibleRole.MENU: - - Accessible tmp = (Accessible) AccessibleObjectFactory.getAccessibleComponent(xAccessible); - if (tmp != null) { - AccessibleContext ac = tmp.getAccessibleContext(); - - if (ac != null) { - a = new PopupMenuProxy(ac); - } - } - - break; - - case AccessibleRole.TOOL_TIP: - a = PopupWindow.create(xAccessible); - break; - - default: - a = AccessBridge.getTopWindow(xAccessible); - break; - } - } - } catch (com.sun.star.uno.RuntimeException e) { - } - - return a; - } - - /** Registers a native frame at the Java AccessBridge for Windows */ - public static void registerTopWindow(int handle, XAccessible xAccessible) { - Integer hwnd = new Integer(handle); - - if (!frameMap.containsKey(hwnd)) { - if (Build.DEBUG) { - System.err.println("Native frame " + hwnd + " of role " + - AccessibleRoleAdapter.getAccessibleRole(xAccessible) + - " has been opened"); - } - - Accessible a = getAccessibleWrapper(xAccessible); - - if (a != null) { - Object[] args = { a, hwnd }; - - frameMap.put(hwnd, a); - - if (Build.DEBUG) { - System.err.println("registering native frame " + hwnd); - } - - try { - registerVirtualFrame.invoke(null, args); - } catch (IllegalAccessException e) { - System.err.println("IllegalAccessException caught: " + - e.getMessage()); - } catch (IllegalArgumentException e) { - System.err.println("IllegalArgumentException caught: " + - e.getMessage()); - } catch (InvocationTargetException e) { - System.err.println("InvokationTargetException caught: " + - e.getMessage()); - } - } - } - } - - /** Revokes a native frame at the Java AccessBridge for Windows */ - public static void revokeTopWindow(int handle, XAccessible xAccessible) { - Integer hwnd = new Integer(handle); - - Accessible a = frameMap.remove(hwnd); - - if (a != null) { - Object[] args = { a, hwnd }; - - if (Build.DEBUG) { - System.err.println("revoking native frame " + hwnd); - } - - try { - revokeVirtualFrame.invoke(null, args); - } catch (IllegalAccessException e) { - System.err.println("IllegalAccessException caught: " + - e.getMessage()); - } catch (IllegalArgumentException e) { - System.err.println("IllegalArgumentException caught: " + - e.getMessage()); - } catch (InvocationTargetException e) { - System.err.println("InvokationTargetException caught: " + - e.getMessage()); - } - } - - if (a instanceof PopupWindow) { - PopupWindow toolTipWindow = (PopupWindow) a; - toolTipWindow.removeAll(); - toolTipWindow.dispose(); - } - } - - protected static class PopupMenuProxy extends AccessibleContext - implements Accessible, AccessibleComponent { - AccessibleContext menu; - AccessibleComponent menuComponent; - int x = 0; int y = 0; int width = 0; int height = 0; - - PopupMenuProxy(AccessibleContext ac) { - menu = ac; - menuComponent = menu.getAccessibleComponent(); - - /** calculate the bounding rectangle by iterating over the - * the children. - */ - int x2 = 0; int y2 = 0; - int count = ac.getAccessibleChildrenCount(); - for (int i = 0; i < count; i++) { - Accessible a = menu.getAccessibleChild(i); - - if (a != null) { - AccessibleContext childAC = a.getAccessibleContext(); - - if (childAC != null) { - AccessibleComponent comp = ac.getAccessibleComponent(); - - if (comp != null) { - java.awt.Point p = comp.getLocationOnScreen(); - java.awt.Dimension d = comp.getSize(); - - if (p != null && d != null) { - if (p.x < x) { - x = p.x; - } - if (p.y < y) { - y = p.y; - } - if (p.x + d.width > x2) { - x2 = p.x + d.width; - } - if (p.y + d.height > y2) { - y2 = p.y + d.height; - } - } - } - } - } - } - - width = x2 - x; - height = y2 - y; - } - - /** Returns the AccessibleContext associated with this object */ - public javax.accessibility.AccessibleContext getAccessibleContext() { - return this; - } - - /** Returns the AccessibleContext associated with this object */ - public javax.accessibility.AccessibleComponent getAccessibleComponent() { - return this; - } - - /** Returns the AccessibleText associated with this object */ - public javax.accessibility.AccessibleText getAccessibleText() { - return menu.getAccessibleText(); - } - - /** Returns the AccessibleContext associated with this object */ - public javax.accessibility.AccessibleStateSet getAccessibleStateSet() { - return menu.getAccessibleStateSet(); - } - - public java.util.Locale getLocale() { - return menu.getLocale(); - } - - public int getAccessibleIndexInParent() { - return -1; - } - - public int getAccessibleChildrenCount() { - return menu.getAccessibleChildrenCount(); - } - - public javax.accessibility.Accessible getAccessibleChild(int i) { - return menu.getAccessibleChild(i); - } - - public javax.accessibility.AccessibleRole getAccessibleRole() { - return javax.accessibility.AccessibleRole.POPUP_MENU; - } - - /* - * AccessibleComponent - */ - public void addFocusListener(java.awt.event.FocusListener fl) { - menuComponent.addFocusListener(fl); - } - - public void removeFocusListener(java.awt.event.FocusListener fl) { - menuComponent.removeFocusListener(fl); - } - - /** Returns the background color of the object */ - public java.awt.Color getBackground() { - return menuComponent.getBackground(); - } - - public void setBackground(java.awt.Color c) { - // Not supported by UNO accessibility API - } - - /** Returns the foreground color of the object */ - public java.awt.Color getForeground() { - return menuComponent.getForeground(); - } - - public void setForeground(java.awt.Color c) { - menuComponent.setForeground(c); - } - - public java.awt.Cursor getCursor() { - return menuComponent.getCursor(); - } - - public void setCursor(java.awt.Cursor cursor) { - menuComponent.setCursor(cursor); - } - - public java.awt.Font getFont() { - return menuComponent.getFont(); - } - - public void setFont(java.awt.Font f) { - menuComponent.setFont(f); - } - - public java.awt.FontMetrics getFontMetrics(java.awt.Font f) { - return menuComponent.getFontMetrics(f); - } - - public boolean isEnabled() { - return menuComponent.isEnabled(); - } - - public void setEnabled(boolean b) { - menuComponent.setEnabled(b); - } - - public boolean isVisible() { - return menuComponent.isVisible(); - } - - public void setVisible(boolean b) { - menuComponent.setVisible(b); - } - - public boolean isShowing() { - return menuComponent.isShowing(); - } - - public boolean contains(java.awt.Point p) { - java.awt.Dimension d = getSize(); - - if (Build.DEBUG) { - System.err.println("PopupMenuProxy.containsPoint(" + p.x + "," + - p.y + ") returns " + - (((d.width >= 0) && (p.x < d.width) && (d.height >= 0) && - (p.y < d.height)) ? "true" : "false")); - } - - if ((d.width >= 0) && (p.x < d.width) && (d.height >= 0) && - (p.y < d.height)) { - return true; - } - - return false; - } - - /** Returns the location of the object on the screen. */ - public java.awt.Point getLocationOnScreen() { - return new java.awt.Point(x,y); - } - - /** Gets the location of this component in the form of a point specifying the component's top-left corner */ - public java.awt.Point getLocation() { - // This object represents a toplevel, so this is the same as getLocationOnScreen() - return getLocationOnScreen(); - } - - /** Moves this component to a new location */ - public void setLocation(java.awt.Point p) { - // Not supported by UNO accessibility API - } - - /** Gets the bounds of this component in the form of a Rectangle object */ - public java.awt.Rectangle getBounds() { - return new java.awt.Rectangle(x, y, width, height); - } - - /** Moves and resizes this component to conform to the new bounding rectangle r */ - public void setBounds(java.awt.Rectangle r) { - // Not supported by UNO accessibility API - } - - /** Returns the size of this component in the form of a Dimension object */ - public java.awt.Dimension getSize() { - return new java.awt.Dimension(width, height); - } - - /** Resizes this component so that it has width d.width and height d.height */ - public void setSize(java.awt.Dimension d) { - // Not supported by UNO accessibility API - } - - /** Returns the Accessible child, if one exists, contained at the local - * coordinate Point - */ - public javax.accessibility.Accessible getAccessibleAt(java.awt.Point p) { - java.awt.Point p2 = menuComponent.getLocationOnScreen(); - return menuComponent.getAccessibleAt( - new java.awt.Point(p.x + x - p2.x, p.y + y - p2.y)); - } - - public boolean isFocusTraversable() { - return menuComponent.isFocusTraversable(); - } - - public void requestFocus() { - menuComponent.requestFocus(); - } - } - - protected static class ListProxy extends AccessibleContext - implements Accessible, AccessibleComponent { - AccessibleContext list; - AccessibleComponent listComponent; - - ListProxy(AccessibleContext ac) { - list = ac; - listComponent = list.getAccessibleComponent(); - } - - /** Returns the AccessibleContext associated with this object */ - public javax.accessibility.AccessibleContext getAccessibleContext() { - return this; - } - - /** Returns the AccessibleContext associated with this object */ - public javax.accessibility.AccessibleComponent getAccessibleComponent() { - return this; - } - - /** Returns the AccessibleSelection associated with this object */ - public javax.accessibility.AccessibleSelection getAccessibleSelection() { - return list.getAccessibleSelection(); - } - - /** Returns the AccessibleContext associated with this object */ - public javax.accessibility.AccessibleStateSet getAccessibleStateSet() { - return list.getAccessibleStateSet(); - } - - public java.util.Locale getLocale() { - return list.getLocale(); - } - - public int getAccessibleIndexInParent() { - return -1; - } - - public int getAccessibleChildrenCount() { - return list.getAccessibleChildrenCount(); - } - - public javax.accessibility.Accessible getAccessibleChild(int i) { - return list.getAccessibleChild(i); - } - - public javax.accessibility.AccessibleRole getAccessibleRole() { - return javax.accessibility.AccessibleRole.LIST; - } - - /* - * AccessibleComponent - */ - public void addFocusListener(java.awt.event.FocusListener fl) { - listComponent.addFocusListener(fl); - } - - public void removeFocusListener(java.awt.event.FocusListener fl) { - listComponent.removeFocusListener(fl); - } - - /** Returns the background color of the object */ - public java.awt.Color getBackground() { - return listComponent.getBackground(); - } - - public void setBackground(java.awt.Color c) { - // Not supported by UNO accessibility API - } - - /** Returns the foreground color of the object */ - public java.awt.Color getForeground() { - return listComponent.getForeground(); - } - - public void setForeground(java.awt.Color c) { - listComponent.setForeground(c); - } - - public java.awt.Cursor getCursor() { - return listComponent.getCursor(); - } - - public void setCursor(java.awt.Cursor cursor) { - listComponent.setCursor(cursor); - } - - public java.awt.Font getFont() { - return listComponent.getFont(); - } - - public void setFont(java.awt.Font f) { - listComponent.setFont(f); - } - - public java.awt.FontMetrics getFontMetrics(java.awt.Font f) { - return listComponent.getFontMetrics(f); - } - - public boolean isEnabled() { - return listComponent.isEnabled(); - } - - public void setEnabled(boolean b) { - listComponent.setEnabled(b); - } - - public boolean isVisible() { - return listComponent.isVisible(); - } - - public void setVisible(boolean b) { - listComponent.setVisible(b); - } - - public boolean isShowing() { - return listComponent.isShowing(); - } - - public boolean contains(java.awt.Point p) { - return listComponent.contains(p); - } - - /** Returns the location of the object on the screen. */ - public java.awt.Point getLocationOnScreen() { - return listComponent.getLocationOnScreen(); - } - - /** Gets the location of this component in the form of a point specifying - * the component's top-left corner - */ - public java.awt.Point getLocation() { - // This object represents a toplevel object, so getLocation() should - // return the same as getLocationOnScreen(). - return getLocationOnScreen(); - } - - /** Moves this component to a new location */ - public void setLocation(java.awt.Point p) { - // Not supported by UNO accessibility API - } - - /** Gets the bounds of this component in the form of a Rectangle object */ - public java.awt.Rectangle getBounds() { - java.awt.Point p = getLocationOnScreen(); - java.awt.Dimension d = getSize(); - return new java.awt.Rectangle(p.x, p.y, d.width, d.height); - } - - /** Moves and resizes this component to conform to the new bounding rectangle r */ - public void setBounds(java.awt.Rectangle r) { - // Not supported by UNO accessibility API - } - - /** Returns the size of this component in the form of a Dimension object */ - public java.awt.Dimension getSize() { - return listComponent.getSize(); - } - - /** Resizes this component so that it has width d.width and height d.height */ - public void setSize(java.awt.Dimension d) { - // Not supported by UNO accessibility API - } - - /** Returns the Accessible child, if one exists, contained at the local - * coordinate Point - */ - public javax.accessibility.Accessible getAccessibleAt(java.awt.Point p) { - return listComponent.getAccessibleAt(p); - } - - public boolean isFocusTraversable() { - return listComponent.isFocusTraversable(); - } - - public void requestFocus() { - listComponent.requestFocus(); - } - } -} diff --git a/accessibility/bridge/org/openoffice/accessibility/java_uno_accessbridge.component b/accessibility/bridge/org/openoffice/accessibility/java_uno_accessbridge.component deleted file mode 100644 index a1194a1c7744..000000000000 --- a/accessibility/bridge/org/openoffice/accessibility/java_uno_accessbridge.component +++ /dev/null @@ -1,25 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - * 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 . - --> - -<component loader="com.sun.star.loader.Java2" - xmlns="http://openoffice.org/2010/uno-components"> - <implementation name="org.openoffice.accessibility.AccessBridge"> - <service name="com.sun.star.accessibility.AccessBridge"/> - </implementation> -</component> diff --git a/accessibility/bridge/org/openoffice/accessibility/manifest b/accessibility/bridge/org/openoffice/accessibility/manifest deleted file mode 100644 index 4b5ffd54d34b..000000000000 --- a/accessibility/bridge/org/openoffice/accessibility/manifest +++ /dev/null @@ -1,2 +0,0 @@ -RegistrationClassName: org.openoffice.accessibility.AccessBridge -UNO-Type-Path: diff --git a/accessibility/bridge/org/openoffice/java/accessibility/AbstractButton.java b/accessibility/bridge/org/openoffice/java/accessibility/AbstractButton.java deleted file mode 100644 index c0fc21c6830c..000000000000 --- a/accessibility/bridge/org/openoffice/java/accessibility/AbstractButton.java +++ /dev/null @@ -1,163 +0,0 @@ -/* - * 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 . - */ - -package org.openoffice.java.accessibility; - -import com.sun.star.uno.*; -import com.sun.star.accessibility.*; - -/** - */ -public abstract class AbstractButton extends Component { - - protected AbstractButton(XAccessible xAccessible, XAccessibleContext xAccessibleContext) { - super(xAccessible, xAccessibleContext); - } - - protected abstract class AccessibleAbstractButton extends AccessibleUNOComponent - implements javax.accessibility.AccessibleAction { - - /** - * Though the class is abstract, this should be called by all sub-classes - */ - protected AccessibleAbstractButton() { - super(); - } - - /* - * AccessibleContext - */ - - /** Gets the AccessibleAction associated with this object that supports one or more actions */ - public javax.accessibility.AccessibleAction getAccessibleAction() { - return this; - } - - /** Gets the AccessibleText associated with this object presenting text on the display */ - public javax.accessibility.AccessibleText getAccessibleText() { - - if (disposed) - return null; - - try { - XAccessibleText unoAccessibleText = UnoRuntime.queryInterface(XAccessibleText.class,unoAccessibleComponent); - if (unoAccessibleText != null) { - return new AccessibleTextImpl(unoAccessibleText); - } else { - return null; - } - } catch (com.sun.star.uno.RuntimeException e) { - return null; - } - } - - /** Returns the relation set of this object */ - public javax.accessibility.AccessibleRelationSet getAccessibleRelationSet() { - try { - XAccessibleRelationSet unoAccessibleRelationSet = unoAccessibleContext.getAccessibleRelationSet(); - - if (unoAccessibleRelationSet == null) { - return null; - } - - javax.accessibility.AccessibleRelationSet relationSet = new javax.accessibility.AccessibleRelationSet(); - int count = unoAccessibleRelationSet.getRelationCount(); - - for (int i = 0; i < count; i++) { - AccessibleRelation unoAccessibleRelation = unoAccessibleRelationSet.getRelation(i); - - switch (unoAccessibleRelation.RelationType) { - case AccessibleRelationType.MEMBER_OF: - relationSet.add(new javax.accessibility.AccessibleRelation( - javax.accessibility.AccessibleRelation.MEMBER_OF, - getAccessibleComponents( - unoAccessibleRelation.TargetSet))); - break; - - case AccessibleRelationType.LABELED_BY: - relationSet.add(new javax.accessibility.AccessibleRelation( - javax.accessibility.AccessibleRelation.LABELED_BY, - getAccessibleComponents( - unoAccessibleRelation.TargetSet))); - break; - default: - break; - } - } - - return relationSet; - } catch (com.sun.star.lang.IndexOutOfBoundsException e) { - return null; - } catch (com.sun.star.uno.RuntimeException e) { - return null; - } - } - - /* - * AccessibleAction - */ - - /** Performs the specified Action on the object */ - public boolean doAccessibleAction(int param) { - if (param == 0) { - // HACK: this action might open a modal dialog and therefor block - // until the dialog is closed. In case of this thread being the - // AWT EventDispatcherThread this means, the opened dialog will - // not be accessible, so deligate this request to another thread. - if (java.awt.EventQueue.isDispatchThread()) { - Thread t = new Thread () { - public void run() { - AbstractButton.AccessibleAbstractButton.this.doAccessibleAction(0); - } - }; - t.start(); - return true; - } else { - // Actions of MenuItems may also be performed if the item is not - // visible, so just try .. - try { - XAccessibleContext xAccessibleContext = unoAccessibleContext; - if (xAccessibleContext != null) { - // Query for XAccessibleAction interface - XAccessibleAction xAccessibleAction = UnoRuntime.queryInterface(XAccessibleAction.class, xAccessibleContext); - - if (xAccessibleAction != null) { - return xAccessibleAction.doAccessibleAction(0); - } - } - } catch (com.sun.star.lang.IndexOutOfBoundsException e) { - } catch (com.sun.star.uno.RuntimeException e) { - } - } - } - - return false; - } - - /** Returns a description of the specified action of the object */ - public java.lang.String getAccessibleActionDescription(int param) { - return javax.swing.UIManager.getString("AbstractButton.clickText"); - } - - /** Returns the number of accessible actions available in this object */ - public int getAccessibleActionCount() { - return 1; - } - } -} - diff --git a/accessibility/bridge/org/openoffice/java/accessibility/AccessibleActionImpl.java b/accessibility/bridge/org/openoffice/java/accessibility/AccessibleActionImpl.java deleted file mode 100644 index a38820c98128..000000000000 --- a/accessibility/bridge/org/openoffice/java/accessibility/AccessibleActionImpl.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * 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 . - */ - -package org.openoffice.java.accessibility; - -import com.sun.star.accessibility.XAccessibleAction; - -/** The AccessibleActionWrapper maps the calls to the java AccessibleAction interface - * to the corresponding methods of the UNO XAccessibleAction interface. - */ -public class AccessibleActionImpl implements javax.accessibility.AccessibleAction { - - protected XAccessibleAction unoObject; - - /** Creates new AccessibleActionWrapper */ - public AccessibleActionImpl(XAccessibleAction xAccessibleAction) { - unoObject = xAccessibleAction; - } - - public boolean doAccessibleAction(int param) { - try { - return unoObject.doAccessibleAction(param); - } catch (com.sun.star.lang.IndexOutOfBoundsException e) { - return false; - } catch (com.sun.star.uno.RuntimeException e) { - return false; - } - } - - public java.lang.String getAccessibleActionDescription(int param) { - try { - return unoObject.getAccessibleActionDescription(param); - } catch (com.sun.star.lang.IndexOutOfBoundsException e) { - return null; - } catch (com.sun.star.uno.RuntimeException e) { - return null; - } - } - - public int getAccessibleActionCount() { - try { - return unoObject.getAccessibleActionCount(); - } catch (com.sun.star.uno.RuntimeException e) { - return 0; - } - } -} diff --git a/accessibility/bridge/org/openoffice/java/accessibility/AccessibleComponentImpl.java b/accessibility/bridge/org/openoffice/java/accessibility/AccessibleComponentImpl.java deleted file mode 100644 index 03e1fa56c5b1..000000000000 --- a/accessibility/bridge/org/openoffice/java/accessibility/AccessibleComponentImpl.java +++ /dev/null @@ -1,223 +0,0 @@ -/* - * 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 . - */ - -package org.openoffice.java.accessibility; - -import com.sun.star.accessibility.AccessibleStateType; -import com.sun.star.accessibility.XAccessibleContext; -import com.sun.star.accessibility.XAccessibleComponent; -// import com.sun.star.accessibility.XAccessibleExtendedComponent; -import com.sun.star.uno.UnoRuntime; - -public class AccessibleComponentImpl implements javax.accessibility.AccessibleComponent { - - protected XAccessibleComponent unoObject; -// protected XAccessibleExtendedComponent unoAccessibleExtendedComponent = null; - - /** Creates new AccessibleComponentImpl */ - public AccessibleComponentImpl(XAccessibleComponent xAccessibleComponent) { - unoObject = xAccessibleComponent; - } - - protected boolean hasState(short state) { - try { - XAccessibleContext unoAccessibleContext = UnoRuntime.queryInterface(XAccessibleContext.class, unoObject); - // All UNO accessibility implementations must support XAccessibleContext - // and return a valid XAccessibleStateSet .. - return unoAccessibleContext.getAccessibleStateSet().contains(state); - } catch (com.sun.star.uno.RuntimeException e) { - return false; - } catch (java.lang.NullPointerException e) { - System.err.println("XAccessibleContext unsupported or no XAccessibleStateSet returned."); - return false; - } - } - - /* - * XAccessibleComponent - */ - - /** Returns the background color of the object */ - public java.awt.Color getBackground() { - try { - return new java.awt.Color(unoObject.getBackground()); - } catch (com.sun.star.uno.RuntimeException e) { - return null; - } - } - - public void setBackground(java.awt.Color c) { - // Not supported by UNO accessibility API - } - - /** Returns the foreground color of the object */ - public java.awt.Color getForeground() { - try { - return new java.awt.Color(unoObject.getForeground()); - } catch (com.sun.star.uno.RuntimeException e) { - return null; - } - } - - public void setForeground(java.awt.Color c) { - // Not supported by UNO accessibility API - } - - public java.awt.Cursor getCursor() { - // Not supported by UNO accessibility API - return null; - } - - public void setCursor(java.awt.Cursor cursor) { - // Not supported by UNO accessibility API - } - - public java.awt.Font getFont() { - // FIXME - return null; - } - - public void setFont(java.awt.Font f) { - // Not supported by UNO accessibility API - } - - public java.awt.FontMetrics getFontMetrics(java.awt.Font f) { - // FIXME - return null; - } - - public boolean isEnabled() { - return hasState(AccessibleStateType.ENABLED); - } - - public void setEnabled(boolean b) { - // Not supported by UNO accessibility API - } - - public boolean isVisible() { - return hasState(AccessibleStateType.VISIBLE); - } - - public void setVisible(boolean b) { - // Not supported by UNO accessibility API - } - - public boolean isShowing() { - return hasState(AccessibleStateType.SHOWING); - } - - public boolean contains(java.awt.Point p) { - try { - return unoObject.containsPoint(new com.sun.star.awt.Point(p.x, p.y)); - } catch (com.sun.star.uno.RuntimeException e) { - return false; - } - } - - /** Returns the location of the object on the screen. */ - public java.awt.Point getLocationOnScreen() { - try { - com.sun.star.awt.Point unoPoint = unoObject.getLocationOnScreen(); - return new java.awt.Point(unoPoint.X, unoPoint.Y); - } catch (com.sun.star.uno.RuntimeException e) { - return null; - } - } - - /** Gets the location of this component in the form of a point specifying the component's top-left corner */ - public java.awt.Point getLocation() { - try { - com.sun.star.awt.Point unoPoint = unoObject.getLocation(); - return new java.awt.Point( unoPoint.X, unoPoint.Y ); - } catch (com.sun.star.uno.RuntimeException e) { - return null; - } - } - - /** Moves this component to a new location */ - public void setLocation(java.awt.Point p) { - // Not supported by UNO accessibility API - } - - /** Gets the bounds of this component in the form of a Rectangle object */ - public java.awt.Rectangle getBounds() { - try { - com.sun.star.awt.Rectangle unoRect = unoObject.getBounds(); - return new java.awt.Rectangle(unoRect.X, unoRect.Y, unoRect.Width, unoRect.Height); - } catch (com.sun.star.uno.RuntimeException e) { - return null; - } - } - - /** Moves and resizes this component to conform to the new bounding rectangle r */ - public void setBounds(java.awt.Rectangle r) { - // Not supported by UNO accessibility API - } - - /** Returns the size of this component in the form of a Dimension object */ - public java.awt.Dimension getSize() { - try { - com.sun.star.awt.Size unoSize = unoObject.getSize(); - return new java.awt.Dimension(unoSize.Width, unoSize.Height); - } catch (com.sun.star.uno.RuntimeException e) { - return null; - } - } - - /** Resizes this component so that it has width d.width and height d.height */ - public void setSize(java.awt.Dimension d) { - // Not supported by UNO accessibility API - } - - public javax.accessibility.Accessible getAccessibleAt(java.awt.Point p) { - // Not supported by this implementation - return null; - } - - public boolean isFocusTraversable() { - return hasState(AccessibleStateType.FOCUSABLE); - } - - public void requestFocus() { - unoObject.grabFocus(); - } - - /** - * Adds the specified focus listener to receive focus events from - * this component when this component gains input focus. - * If listener <code>l</code> is <code>null</code>, - * no exception is thrown and no action is performed. - */ - - public void addFocusListener(java.awt.event.FocusListener l) { - // Not supported by this implementation - } - - /** - * Removes the specified focus listener so that it no longer - * receives focus events from this component. This method performs - * no function, nor does it throw an exception, if the listener - * specified by the argument was not previously added to this component. - * If listener <code>l</code> is <code>null</code>, - * no exception is thrown and no action is performed. - */ - - public void removeFocusListener(java.awt.event.FocusListener l) { - // Not supported by this implementation - } -} diff --git a/accessibility/bridge/org/openoffice/java/accessibility/AccessibleEditableTextImpl.java b/accessibility/bridge/org/openoffice/java/accessibility/AccessibleEditableTextImpl.java deleted file mode 100644 index 8dd7e36049d2..000000000000 --- a/accessibility/bridge/org/openoffice/java/accessibility/AccessibleEditableTextImpl.java +++ /dev/null @@ -1,351 +0,0 @@ -/* - * 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 . - */ - -package org.openoffice.java.accessibility; - -import com.sun.star.awt.*; -import com.sun.star.style.*; -import com.sun.star.accessibility.XAccessibleEditableText; -import com.sun.star.beans.PropertyValue; - -import javax.swing.text.StyleConstants; - -/** The GenericAccessibleEditableText mapps the calls to the java AccessibleEditableText - * interface to the corresponding methods of the UNO XAccessibleEditableText interface. - */ -public class AccessibleEditableTextImpl extends AccessibleTextImpl implements javax.accessibility.AccessibleEditableText { - final static double toPointFactor = 1 / (7/10 + 34.5); - - /** Creates new GenericAccessibleEditableText object */ - public AccessibleEditableTextImpl(XAccessibleEditableText xAccessibleEditableText) { - super(xAccessibleEditableText); - } - - /** Cuts the text between two indices into the system clipboard */ - public void cut(int startIndex, int endIndex) { - try { - ((XAccessibleEditableText) unoObject).cutText(startIndex, endIndex); - } catch (com.sun.star.lang.IndexOutOfBoundsException e) { - } catch (com.sun.star.uno.RuntimeException e) { - } - } - - /** Deletes the text between two indices */ - public void delete(int startIndex, int endIndex) { - try { - ((XAccessibleEditableText) unoObject).deleteText(startIndex, endIndex); - } catch (com.sun.star.lang.IndexOutOfBoundsException e) { - } catch (com.sun.star.uno.RuntimeException e) { - } - } - - /** Returns the text range between two indices */ - public String getTextRange(int startIndex, int endIndex) { - try { - return unoObject.getTextRange(startIndex, endIndex); - } catch (com.sun.star.lang.IndexOutOfBoundsException e) { - } catch (com.sun.star.uno.RuntimeException e) { - } - return null; - } - - /** Inserts the specified string at the given index */ - public void insertTextAtIndex(int index, String s){ - try { - ((XAccessibleEditableText) unoObject).insertText(s, index); - } catch (com.sun.star.lang.IndexOutOfBoundsException e) { - } catch (com.sun.star.uno.RuntimeException e) { - } - } - - /** Pastes the text form the system clipboard into the text starting at the specified index */ - public void paste(int startIndex) { - try { - ((XAccessibleEditableText) unoObject).pasteText(startIndex); - } catch (com.sun.star.lang.IndexOutOfBoundsException e) { - } catch (com.sun.star.uno.RuntimeException e) { - } - } - - /** Replaces the text between two indices with the specified string */ - public void replaceText(int startIndex, int endIndex, String s) { - try { - ((XAccessibleEditableText) unoObject).replaceText(startIndex, endIndex, s); - } catch (com.sun.star.lang.IndexOutOfBoundsException e) { - } catch (com.sun.star.uno.RuntimeException e) { - } - } - - /** Selects the text between two indices */ - public void selectText(int startIndex, int endIndex) { - try { - unoObject.setSelection(startIndex, endIndex); - } catch (com.sun.star.lang.IndexOutOfBoundsException e) { - } catch (com.sun.star.uno.RuntimeException e) { - } - } - - /** Sets the attributes for the text between two indices */ - public void setAttributes(int startIndex, int endIndex, javax.swing.text.AttributeSet as) { - java.util.ArrayList<PropertyValue> propertyValues = new java.util.ArrayList<PropertyValue>(); - - // Convert Alignment attribute - Object attribute = as.getAttribute(StyleConstants.Alignment); - if (null != attribute) { - com.sun.star.beans.PropertyValue propertyValue = new com.sun.star.beans.PropertyValue(); - propertyValue.Name = "ParaAdjust"; - - switch (StyleConstants.getAlignment(as)) { - case StyleConstants.ALIGN_RIGHT: - propertyValue.Value = ParagraphAdjust.RIGHT; - break; - case StyleConstants.ALIGN_CENTER: - propertyValue.Value = ParagraphAdjust.CENTER; - break; - case StyleConstants.ALIGN_JUSTIFIED: - propertyValue.Value = ParagraphAdjust.BLOCK; - break; - default: - propertyValue.Value = ParagraphAdjust.LEFT; - break; - } - propertyValues.add(propertyValue); - } - - // Convert Background attribute - attribute = as.getAttribute(StyleConstants.Background); - if (null != attribute) { - com.sun.star.beans.PropertyValue propertyValue = new com.sun.star.beans.PropertyValue(); - propertyValue.Name = "CharBackColor"; - propertyValue.Value = new Integer(StyleConstants.getBackground(as).getRGB()); - propertyValues.add(propertyValue); - } - - // FIXME: BidiLevel - - // Set Bold attribute - attribute = as.getAttribute(StyleConstants.Bold); - if (null != attribute) { - com.sun.star.beans.PropertyValue propertyValue = new com.sun.star.beans.PropertyValue(); - propertyValue.Name = "CharWeight"; - if (StyleConstants.isBold(as)) { - propertyValue.Value = new Float(150); - } else { - propertyValue.Value = new Float(100); - } - propertyValues.add(propertyValue); - } - - // FIXME: Java 1.4 ComponentAttribute, ComponentElementName, ComposedTextAttribute - - // Set FirstLineIndent attribute - attribute = as.getAttribute(StyleConstants.FirstLineIndent); - if (null != attribute) { - com.sun.star.beans.PropertyValue propertyValue = new com.sun.star.beans.PropertyValue(); - propertyValue.Name = "ParaFirstLineIndent"; - propertyValue.Value = new Double(StyleConstants.getFirstLineIndent(as) / toPointFactor); - propertyValues.add(propertyValue); - } - - // Set font family attribute - attribute = as.getAttribute(StyleConstants.FontFamily); - if (null != attribute) { - com.sun.star.beans.PropertyValue propertyValue = new com.sun.star.beans.PropertyValue(); - propertyValue.Name = "CharFontName"; - propertyValue.Value = new String(StyleConstants.getFontFamily(as)); - propertyValues.add(propertyValue); - } - - // Set font size attribute - attribute = as.getAttribute(StyleConstants.FontSize); - if (null != attribute) { - com.sun.star.beans.PropertyValue propertyValue = new com.sun.star.beans.PropertyValue(); - propertyValue.Name = "CharHeight"; - propertyValue.Value = new Integer(StyleConstants.getFontSize(as)); - propertyValues.add(propertyValue); - } - - // Map foreground color - attribute = as.getAttribute(StyleConstants.Foreground); - if (null != attribute) { - com.sun.star.beans.PropertyValue propertyValue = new com.sun.star.beans.PropertyValue(); - propertyValue.Name = "CharColor"; - propertyValue.Value = new Integer (StyleConstants.getForeground(as).getRGB()); - propertyValues.add(propertyValue); - } - - // FIXME: IconAttribute, IconElementName - - // Set italic attribute - attribute = as.getAttribute(StyleConstants.Italic); - if (null != attribute) { - com.sun.star.beans.PropertyValue propertyValue = new com.sun.star.beans.PropertyValue(); - propertyValue.Name = "CharPosture"; - - if (StyleConstants.isItalic(as)) { - propertyValue.Value = FontSlant.ITALIC; - } else { - propertyValue.Value = FontSlant.DONTKNOW; - } - propertyValues.add(propertyValue); - } - - // Set left indent attribute - attribute = as.getAttribute(StyleConstants.LeftIndent); - if (null != attribute) { - com.sun.star.beans.PropertyValue propertyValue = new com.sun.star.beans.PropertyValue(); - propertyValue.Name = "ParaFirstLeftMargin"; - propertyValue.Value = new Integer(new Double(StyleConstants.getLeftIndent(as) / toPointFactor).intValue()); - propertyValues.add(propertyValue); - } - - // Set right indent attribute - attribute = as.getAttribute(StyleConstants.RightIndent); - if (null != attribute) { - com.sun.star.beans.PropertyValue propertyValue = new com.sun.star.beans.PropertyValue(); - propertyValue.Name = "ParaFirstRightMargin"; - propertyValue.Value = new Integer(new Double(StyleConstants.getRightIndent(as) / toPointFactor).intValue()); - propertyValues.add(propertyValue); - } - - // Set line spacing attribute - attribute = as.getAttribute(StyleConstants.LineSpacing); - if (null != attribute) { - com.sun.star.beans.PropertyValue propertyValue = new com.sun.star.beans.PropertyValue(); - propertyValue.Name = "ParaLineSpacing"; - propertyValue.Value = new Integer(new Double(StyleConstants.getLineSpacing(as) / toPointFactor).intValue()); - propertyValues.add(propertyValue); - } - - // FIXME: Java 1.4 NameAttribute, Orientation, ResolveAttribute - - // Set space above attribute - attribute = as.getAttribute(StyleConstants.SpaceAbove); - if (null != attribute) { - com.sun.star.beans.PropertyValue propertyValue = new com.sun.star.beans.PropertyValue(); - propertyValue.Name = "ParaTopMargin"; - propertyValue.Value = new Integer(new Double( StyleConstants.getSpaceAbove(as) / toPointFactor).intValue()); - propertyValues.add(propertyValue); - } - - // Set space below attribute - attribute = as.getAttribute(StyleConstants.SpaceBelow); - if (null != attribute) { - com.sun.star.beans.PropertyValue propertyValue = new com.sun.star.beans.PropertyValue(); - propertyValue.Name = "ParaBottomMargin"; - propertyValue.Value = new Integer(new Double(StyleConstants.getSpaceBelow(as) / toPointFactor).intValue()); - propertyValues.add(propertyValue); - } - - // Set strike through attribute - attribute = as.getAttribute(StyleConstants.StrikeThrough); - if (null != attribute) { - com.sun.star.beans.PropertyValue propertyValue = new com.sun.star.beans.PropertyValue(); - propertyValue.Name = "CharPosture"; - if (StyleConstants.isStrikeThrough(as)) { - propertyValue.Value = new Short(FontStrikeout.SINGLE); - } else { - propertyValue.Value = new Short(FontStrikeout.NONE); - } - propertyValues.add(propertyValue); - } - - // Set sub-/superscript attribute - attribute = as.getAttribute(StyleConstants.Superscript); - if (null == attribute) { - attribute = as.getAttribute(StyleConstants.Subscript); - } - if (null != attribute) { - com.sun.star.beans.PropertyValue propertyValue = new com.sun.star.beans.PropertyValue(); - propertyValue.Name = "CharEscapement"; - - if (StyleConstants.isSuperscript(as)) { - propertyValue.Value = new Short( "1" ); - } else if (StyleConstants.isSubscript(as)) { - propertyValue.Value = new Short( "-1" ); - } else { - propertyValue.Value = new Short( "0" ); - } - propertyValues.add(propertyValue); - } - - // Set tabset attribute - attribute = as.getAttribute(StyleConstants.TabSet); - if (null != attribute) { - com.sun.star.beans.PropertyValue propertyValue = new com.sun.star.beans.PropertyValue(); - propertyValue.Name = "ParaTabStops"; - - javax.swing.text.TabSet tabSet = StyleConstants.getTabSet(as); - java.util.ArrayList<TabStop> tabStops = new java.util.ArrayList<TabStop>(tabSet.getTabCount()); - - for (int i = 0, max = tabSet.getTabCount(); i < max; i++) { - javax.swing.text.TabStop tab = tabSet.getTab(i); - com.sun.star.style.TabStop unoTab = new com.sun.star.style.TabStop(); - - unoTab.Position = new Double(tab.getPosition() / toPointFactor).intValue(); - - switch (tab.getAlignment()) { - case javax.swing.text.TabStop.ALIGN_CENTER: - unoTab.Alignment = TabAlign.CENTER; - break; - case javax.swing.text.TabStop.ALIGN_RIGHT: - unoTab.Alignment = TabAlign.RIGHT; - break; - case javax.swing.text.TabStop.ALIGN_DECIMAL: - unoTab.Alignment = TabAlign.DECIMAL; - break; - default: - unoTab.Alignment = TabAlign.LEFT; - break; - } - - tabStops.add(unoTab); - } - propertyValue.Value = tabStops.toArray(); - propertyValues.add(propertyValue); - } - - // Set underline attribute - attribute = as.getAttribute(StyleConstants.Underline); - if (null != attribute) { - com.sun.star.beans.PropertyValue propertyValue = new com.sun.star.beans.PropertyValue(); - propertyValue.Name = "CharUnderline"; - - if (StyleConstants.isUnderline(as)) { - propertyValue.Value = new Short(FontUnderline.SINGLE); - } else { - propertyValue.Value = new Short(FontUnderline.NONE); - } - propertyValues.add(propertyValue); - } - - try { - ((XAccessibleEditableText) unoObject).setAttributes(startIndex, endIndex, (com.sun.star.beans.PropertyValue[]) propertyValues.toArray()); - } catch (com.sun.star.lang.IndexOutOfBoundsException e) { - } catch (com.sun.star.uno.RuntimeException e) { - } - } - - /** Sets the text contents to the specified string */ - public void setTextContents(String s) { - try { - ((XAccessibleEditableText) unoObject).setText(s); - } catch (com.sun.star.uno.RuntimeException e) { - } - } -} diff --git a/accessibility/bridge/org/openoffice/java/accessibility/AccessibleExtendedState.java b/accessibility/bridge/org/openoffice/java/accessibility/AccessibleExtendedState.java deleted file mode 100644 index 300b5a9b5fd8..000000000000 --- a/accessibility/bridge/org/openoffice/java/accessibility/AccessibleExtendedState.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * 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 . - */ - -package org.openoffice.java.accessibility; - -import javax.accessibility.AccessibleState; - -public class AccessibleExtendedState extends AccessibleState { - public static final AccessibleState DEFUNCT; - public static final AccessibleState INDETERMINATE; - public static final AccessibleState MANAGES_DESCENDANTS; - public static final AccessibleState SENSITIVE; - public static final AccessibleState STALE; - - static { - DEFUNCT = new AccessibleExtendedState("defunct"); - - // JAVA 1.5: will come with manages_descendants and indeterminate - INDETERMINATE = new AccessibleExtendedState("indeterminate"); - MANAGES_DESCENDANTS = new AccessibleExtendedState("managesDescendants"); - - SENSITIVE = new AccessibleExtendedState("sensitive"); - STALE = new AccessibleExtendedState("stale"); - } - - protected AccessibleExtendedState(String key) { - super(key); - } -} diff --git a/accessibility/bridge/org/openoffice/java/accessibility/AccessibleHypertextImpl.java b/accessibility/bridge/org/openoffice/java/accessibility/AccessibleHypertextImpl.java deleted file mode 100644 index 24ab5efe0687..000000000000 --- a/accessibility/bridge/org/openoffice/java/accessibility/AccessibleHypertextImpl.java +++ /dev/null @@ -1,180 +0,0 @@ -/* - * 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 . - */ - -package org.openoffice.java.accessibility; - -import org.openoffice.java.accessibility.logging.*; - -import com.sun.star.accessibility.*; -import com.sun.star.uno.*; - -/** The AccessibleHypertextImpl mapps all calls to the java AccessibleHypertext - * interface to the corresponding methods of the UNO XAccessibleHypertext - * interface. - */ -public class AccessibleHypertextImpl extends AccessibleTextImpl - implements javax.accessibility.AccessibleHypertext { - - protected class Hyperlink extends javax.accessibility.AccessibleHyperlink { - protected XAccessibleHyperlink unoObject; - - public Hyperlink(XAccessibleHyperlink xHyperlink) { - unoObject = xHyperlink; - } - - public int getStartIndex() { - try { - System.err.println("StartIndex: " + unoObject.getStartIndex()); - return unoObject.getStartIndex(); - } catch (com.sun.star.uno.RuntimeException e) { - return -1; - } - } - - public Object getAccessibleActionObject(int param) { - System.err.println("getActionObject"); - try { - Object any = unoObject.getAccessibleActionObject(param); - if (AnyConverter.isString(any)) { - String url = AnyConverter.toString(any); - if (null != url) { - return new java.net.URL(url); - } - } - } catch (com.sun.star.lang.IndexOutOfBoundsException e) { - } catch (com.sun.star.lang.IllegalArgumentException e) { - } catch (java.net.MalformedURLException exception) { - } catch (com.sun.star.uno.RuntimeException e) { - } - - return null; - } - - public int getEndIndex() { - try { - System.err.println("StartIndex: " + unoObject.getEndIndex()); - return unoObject.getEndIndex(); - } catch (com.sun.star.uno.RuntimeException e) { - return -1; - } - } - - public Object getAccessibleActionAnchor(int param) { - System.err.println("getActionAnchor"); - try { - Object any = unoObject.getAccessibleActionObject(param); - if (AnyConverter.isString(any)) { - System.err.println("Anchor: " + AnyConverter.toString(any)); - return AnyConverter.toString(any); - } - } catch (com.sun.star.lang.IndexOutOfBoundsException e) { - } catch (com.sun.star.lang.IllegalArgumentException e) { - } catch (com.sun.star.uno.RuntimeException e) { - } - return null; - } - - public boolean isValid() { - return unoObject.isValid(); - } - - public boolean doAccessibleAction(int param) { - try { - return unoObject.doAccessibleAction(param); - } catch (com.sun.star.lang.IndexOutOfBoundsException e) { - return false; - } catch (com.sun.star.uno.RuntimeException e) { - return false; - } - } - - public String getAccessibleActionDescription(int param) { - try { - return unoObject.getAccessibleActionDescription(param); - } catch (com.sun.star.lang.IndexOutOfBoundsException e) { - return null; - } - } - - public int getAccessibleActionCount() { - try { - return unoObject.getAccessibleActionCount(); - } catch (com.sun.star.uno.RuntimeException e) { - return 0; - } - } - } - - /** Creates new AccessibleHypertextImpl */ - public AccessibleHypertextImpl(XAccessibleHypertext xAccessibleHypertext) { - if (Build.PRODUCT) { - unoObject = xAccessibleHypertext; - } else { - String property = System.getProperty("AccessBridgeLogging"); - if ((property != null) && (property.indexOf("text") != -1)) { - unoObject = new XAccessibleHypertextLog(xAccessibleHypertext); - } else { - unoObject = xAccessibleHypertext; - } - } - } - - public static javax.accessibility.AccessibleText get(com.sun.star.uno.XInterface unoObject) { - try { - XAccessibleHypertext unoAccessibleHypertext = UnoRuntime.queryInterface(XAccessibleHypertext.class, unoObject); - if (unoAccessibleHypertext != null) { - return new AccessibleHypertextImpl(unoAccessibleHypertext); - } - - XAccessibleText unoAccessibleText = UnoRuntime.queryInterface(XAccessibleText.class, unoObject); - if (unoAccessibleText != null) { - return new AccessibleTextImpl(unoAccessibleText); - } - } catch (com.sun.star.uno.RuntimeException e) { - } - return null; - } - - public javax.accessibility.AccessibleHyperlink getLink(int param) { - try { - return new Hyperlink(((XAccessibleHypertext) unoObject).getHyperLink(param)); - } - - catch(com.sun.star.lang.IndexOutOfBoundsException exception) { - throw new IndexOutOfBoundsException(exception.getMessage()); - } - } - - public int getLinkCount() { - try { - return ((XAccessibleHypertext) unoObject).getHyperLinkCount(); - } catch (com.sun.star.uno.RuntimeException e) { - return 0; - } - } - - public int getLinkIndex(int param) { - try { - return ((XAccessibleHypertext) unoObject).getHyperLinkIndex(param); - } catch (com.sun.star.lang.IndexOutOfBoundsException e) { - return -1; - } catch (com.sun.star.uno.RuntimeException e) { - return -1; - } - } -} diff --git a/accessibility/bridge/org/openoffice/java/accessibility/AccessibleIconImpl.java b/accessibility/bridge/org/openoffice/java/accessibility/AccessibleIconImpl.java deleted file mode 100644 index 8e1239272ac4..000000000000 --- a/accessibility/bridge/org/openoffice/java/accessibility/AccessibleIconImpl.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * 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 . - */ - -package org.openoffice.java.accessibility; - -import com.sun.star.accessibility.XAccessibleImage; - -/** - */ -public class AccessibleIconImpl implements javax.accessibility.AccessibleIcon { - - XAccessibleImage unoAccessibleImage; - - public AccessibleIconImpl(XAccessibleImage xImage) { - unoAccessibleImage = xImage; - } - - /** Gets the description of the icon */ - public String getAccessibleIconDescription() { - try { - return unoAccessibleImage.getAccessibleImageDescription(); - } catch (com.sun.star.uno.RuntimeException e) { - return null; - } - } - - /** Gets the height of the icon */ - public int getAccessibleIconHeight() { - try { - return unoAccessibleImage.getAccessibleImageHeight(); - } catch (com.sun.star.uno.RuntimeException e) { - return 0; - } - } - - /** Gets the width of the icon */ - public int getAccessibleIconWidth() { - try { - return unoAccessibleImage.getAccessibleImageWidth(); - } catch (com.sun.star.uno.RuntimeException e) { - return 0; - } - } - - /** Sets the description of the icon */ - public void setAccessibleIconDescription(String s) { - // Not supported - } -} diff --git a/accessibility/bridge/org/openoffice/java/accessibility/AccessibleKeyBinding.java b/accessibility/bridge/org/openoffice/java/accessibility/AccessibleKeyBinding.java deleted file mode 100644 index 560f5f8dacd4..000000000000 --- a/accessibility/bridge/org/openoffice/java/accessibility/AccessibleKeyBinding.java +++ /dev/null @@ -1,376 +0,0 @@ -/* - * 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 . - */ - -package org.openoffice.java.accessibility; - -import com.sun.star.accessibility.*; -import com.sun.star.awt.KeyStroke; - -/** - * - */ -public class AccessibleKeyBinding extends Object implements javax.accessibility.AccessibleKeyBinding { - - XAccessibleKeyBinding unoAccessibleKeybinding; - - public AccessibleKeyBinding(XAccessibleKeyBinding unoKB) { - unoAccessibleKeybinding = unoKB; - } - - public static int convertModifiers(short s) { - int modifiers = 0; - if ((s & com.sun.star.awt.KeyModifier.SHIFT) != 0) { - modifiers = modifiers | java.awt.event.KeyEvent.SHIFT_DOWN_MASK; - } - - if ((s & com.sun.star.awt.KeyModifier.MOD1) != 0) { - modifiers = modifiers | java.awt.event.KeyEvent.CTRL_DOWN_MASK; - } - - if ((s & com.sun.star.awt.KeyModifier.MOD2) != 0) { - modifiers = modifiers | java.awt.event.KeyEvent.ALT_DOWN_MASK; - } - - if ((s & com.sun.star.awt.KeyModifier.MOD3) != 0) { - modifiers = modifiers | java.awt.event.KeyEvent.META_DOWN_MASK; - } - - return modifiers; - } - - public static int convertKeyCode(short s) { - int keycode = java.awt.event.KeyEvent.VK_UNDEFINED; - - switch(s) { - case com.sun.star.awt.Key.NUM0: - keycode = java.awt.event.KeyEvent.VK_0; - break; - case com.sun.star.awt.Key.NUM1: - keycode = java.awt.event.KeyEvent.VK_1; - break; - case com.sun.star.awt.Key.NUM2: - keycode = java.awt.event.KeyEvent.VK_2; - break; - case com.sun.star.awt.Key.NUM3: - keycode = java.awt.event.KeyEvent.VK_3; - break; - case com.sun.star.awt.Key.NUM4: - keycode = java.awt.event.KeyEvent.VK_4; - break; - case com.sun.star.awt.Key.NUM5: - keycode = java.awt.event.KeyEvent.VK_5; - break; - case com.sun.star.awt.Key.NUM6: - keycode = java.awt.event.KeyEvent.VK_6; - break; - case com.sun.star.awt.Key.NUM7: - keycode = java.awt.event.KeyEvent.VK_7; - break; - case com.sun.star.awt.Key.NUM8: - keycode = java.awt.event.KeyEvent.VK_8; - break; - case com.sun.star.awt.Key.NUM9: - keycode = java.awt.event.KeyEvent.VK_9; - break; - case com.sun.star.awt.Key.A: - keycode = java.awt.event.KeyEvent.VK_A; - break; - case com.sun.star.awt.Key.B: - keycode = java.awt.event.KeyEvent.VK_B; - break; - case com.sun.star.awt.Key.C: - keycode = java.awt.event.KeyEvent.VK_C; - break; - case com.sun.star.awt.Key.D: - keycode = java.awt.event.KeyEvent.VK_D; - break; - case com.sun.star.awt.Key.E: - keycode = java.awt.event.KeyEvent.VK_E; - break; - case com.sun.star.awt.Key.F: - keycode = java.awt.event.KeyEvent.VK_F; - break; - case com.sun.star.awt.Key.G: - keycode = java.awt.event.KeyEvent.VK_G; - break; - case com.sun.star.awt.Key.H: - keycode = java.awt.event.KeyEvent.VK_H; - break; - case com.sun.star.awt.Key.I: - keycode = java.awt.event.KeyEvent.VK_I; - break; - case com.sun.star.awt.Key.J: - keycode = java.awt.event.KeyEvent.VK_J; - break; - case com.sun.star.awt.Key.K: - keycode = java.awt.event.KeyEvent.VK_K; - break; - case com.sun.star.awt.Key.L: - keycode = java.awt.event.KeyEvent.VK_L; - break; - case com.sun.star.awt.Key.M: - keycode = java.awt.event.KeyEvent.VK_M; - break; - case com.sun.star.awt.Key.N: - keycode = java.awt.event.KeyEvent.VK_N; - break; - case com.sun.star.awt.Key.O: - keycode = java.awt.event.KeyEvent.VK_O; - break; - case com.sun.star.awt.Key.P: - keycode = java.awt.event.KeyEvent.VK_P; - break; - case com.sun.star.awt.Key.Q: - keycode = java.awt.event.KeyEvent.VK_Q; - break; - case com.sun.star.awt.Key.R: - keycode = java.awt.event.KeyEvent.VK_R; - break; - case com.sun.star.awt.Key.S: - keycode = java.awt.event.KeyEvent.VK_S; - break; - case com.sun.star.awt.Key.T: - keycode = java.awt.event.KeyEvent.VK_T; - break; - case com.sun.star.awt.Key.U: - keycode = java.awt.event.KeyEvent.VK_U; - break; - case com.sun.star.awt.Key.V: - keycode = java.awt.event.KeyEvent.VK_V; - break; - case com.sun.star.awt.Key.W: - keycode = java.awt.event.KeyEvent.VK_W; - break; - case com.sun.star.awt.Key.X: - keycode = java.awt.event.KeyEvent.VK_X; - break; - case com.sun.star.awt.Key.Y: - keycode = java.awt.event.KeyEvent.VK_Y; - break; - case com.sun.star.awt.Key.Z: - keycode = java.awt.event.KeyEvent.VK_Z; - break; - case com.sun.star.awt.Key.F1: - keycode = java.awt.event.KeyEvent.VK_F1; - break; - case com.sun.star.awt.Key.F2: - keycode = java.awt.event.KeyEvent.VK_F2; - break; - case com.sun.star.awt.Key.F3: - keycode = java.awt.event.KeyEvent.VK_F3; - break; - case com.sun.star.awt.Key.F4: - keycode = java.awt.event.KeyEvent.VK_F4; - break; - case com.sun.star.awt.Key.F5: - keycode = java.awt.event.KeyEvent.VK_F5; - break; - case com.sun.star.awt.Key.F6: - keycode = java.awt.event.KeyEvent.VK_F6; - break; - case com.sun.star.awt.Key.F7: - keycode = java.awt.event.KeyEvent.VK_F7; - break; - case com.sun.star.awt.Key.F8: - keycode = java.awt.event.KeyEvent.VK_F8; - break; - case com.sun.star.awt.Key.F9: - keycode = java.awt.event.KeyEvent.VK_F9; - break; - case com.sun.star.awt.Key.F10: - keycode = java.awt.event.KeyEvent.VK_F10; - break; - case com.sun.star.awt.Key.F11: - keycode = java.awt.event.KeyEvent.VK_F11; - break; - case com.sun.star.awt.Key.F12: - keycode = java.awt.event.KeyEvent.VK_F12; - break; - case com.sun.star.awt.Key.F13: - keycode = java.awt.event.KeyEvent.VK_F13; - break; - case com.sun.star.awt.Key.F14: - keycode = java.awt.event.KeyEvent.VK_F14; - break; - case com.sun.star.awt.Key.F15: - keycode = java.awt.event.KeyEvent.VK_F15; - break; - case com.sun.star.awt.Key.F16: - keycode = java.awt.event.KeyEvent.VK_F16; - break; - case com.sun.star.awt.Key.F17: - keycode = java.awt.event.KeyEvent.VK_F17; - break; - case com.sun.star.awt.Key.F18: - keycode = java.awt.event.KeyEvent.VK_F18; - break; - case com.sun.star.awt.Key.F19: - keycode = java.awt.event.KeyEvent.VK_F19; - break; - case com.sun.star.awt.Key.F20: - keycode = java.awt.event.KeyEvent.VK_F20; - break; - case com.sun.star.awt.Key.F21: - keycode = java.awt.event.KeyEvent.VK_F21; - break; - case com.sun.star.awt.Key.F22: - keycode = java.awt.event.KeyEvent.VK_F22; - break; - case com.sun.star.awt.Key.F23: - keycode = java.awt.event.KeyEvent.VK_F23; - break; - case com.sun.star.awt.Key.F24: - keycode = java.awt.event.KeyEvent.VK_F24; - break; - case com.sun.star.awt.Key.DOWN: - keycode = java.awt.event.KeyEvent.VK_DOWN; - break; - case com.sun.star.awt.Key.UP: - keycode = java.awt.event.KeyEvent.VK_UP; - break; - case com.sun.star.awt.Key.LEFT: - keycode = java.awt.event.KeyEvent.VK_LEFT; - break; - case com.sun.star.awt.Key.RIGHT: - keycode = java.awt.event.KeyEvent.VK_RIGHT; - break; - case com.sun.star.awt.Key.HOME: - keycode = java.awt.event.KeyEvent.VK_HOME; - break; - case com.sun.star.awt.Key.END: - keycode = java.awt.event.KeyEvent.VK_END; - break; - case com.sun.star.awt.Key.PAGEUP: - keycode = java.awt.event.KeyEvent.VK_PAGE_UP; - break; - case com.sun.star.awt.Key.PAGEDOWN: - keycode = java.awt.event.KeyEvent.VK_PAGE_DOWN; - break; - case com.sun.star.awt.Key.RETURN: - keycode = java.awt.event.KeyEvent.VK_ENTER; - break; - case com.sun.star.awt.Key.ESCAPE: - keycode = java.awt.event.KeyEvent.VK_ESCAPE; - break; - case com.sun.star.awt.Key.TAB: - keycode = java.awt.event.KeyEvent.VK_TAB; - break; - case com.sun.star.awt.Key.BACKSPACE: - keycode = java.awt.event.KeyEvent.VK_BACK_SPACE; - break; - case com.sun.star.awt.Key.SPACE: - keycode = java.awt.event.KeyEvent.VK_SPACE; - break; - case com.sun.star.awt.Key.INSERT: - keycode = java.awt.event.KeyEvent.VK_INSERT; - break; - case com.sun.star.awt.Key.DELETE: - keycode = java.awt.event.KeyEvent.VK_DELETE; - break; - case com.sun.star.awt.Key.ADD: - keycode = java.awt.event.KeyEvent.VK_ADD; - break; - case com.sun.star.awt.Key.SUBTRACT: - keycode = java.awt.event.KeyEvent.VK_SUBTRACT; - break; - case com.sun.star.awt.Key.MULTIPLY: - keycode = java.awt.event.KeyEvent.VK_MULTIPLY; - break; - case com.sun.star.awt.Key.DIVIDE: - keycode = java.awt.event.KeyEvent.VK_DIVIDE; - break; - case com.sun.star.awt.Key.POINT: - keycode = java.awt.event.KeyEvent.VK_PERIOD; - break; - case com.sun.star.awt.Key.COMMA: - keycode = java.awt.event.KeyEvent.VK_COMMA; - break; - case com.sun.star.awt.Key.LESS: - keycode = java.awt.event.KeyEvent.VK_LESS; - break; - case com.sun.star.awt.Key.GREATER: - keycode = java.awt.event.KeyEvent.VK_GREATER; - break; - case com.sun.star.awt.Key.EQUAL: - keycode = java.awt.event.KeyEvent.VK_EQUALS; - break; - case com.sun.star.awt.Key.CUT: - keycode = java.awt.event.KeyEvent.VK_CUT; - break; - case com.sun.star.awt.Key.COPY: - keycode = java.awt.event.KeyEvent.VK_COPY; - break; - case com.sun.star.awt.Key.PASTE: - keycode = java.awt.event.KeyEvent.VK_PASTE; - break; - case com.sun.star.awt.Key.UNDO: - keycode = java.awt.event.KeyEvent.VK_UNDO; - break; - case com.sun.star.awt.Key.FIND: - keycode = java.awt.event.KeyEvent.VK_FIND; - break; - case com.sun.star.awt.Key.PROPERTIES: - keycode = java.awt.event.KeyEvent.VK_PROPS; - break; - case com.sun.star.awt.Key.HELP: - keycode = java.awt.event.KeyEvent.VK_HELP; - break; - default: - } - return keycode; - } - - /* - * AccessibleKeyBinding - */ - - /** Returns a key binding for this object */ - public Object getAccessibleKeyBinding(int i) { - try { - KeyStroke[] keys = unoAccessibleKeybinding.getAccessibleKeyBinding(i); - javax.swing.KeyStroke[] data = new javax.swing.KeyStroke[keys.length]; - for (int j=0; j < keys.length; j++) { - int keyCode = convertKeyCode(keys[j].KeyCode); - if (keyCode != java.awt.event.KeyEvent.VK_UNDEFINED) { - data[j] = javax.swing.KeyStroke.getKeyStroke(keyCode, convertModifiers(keys[j].Modifiers)); - } else { - data[j] = null; - } - } - - if (keys.length == 1) { - return data[0]; - } else { - return data; - } - } catch (com.sun.star.lang.IndexOutOfBoundsException e) { - return null; - } catch (com.sun.star.uno.RuntimeException e) { - return null; - } - } - - /** Returns the number of key bindings for this object */ - public int getAccessibleKeyBindingCount() { - try { - return unoAccessibleKeybinding.getAccessibleKeyBindingCount(); - } catch (com.sun.star.uno.RuntimeException e) { - return 0; - } - } -} diff --git a/accessibility/bridge/org/openoffice/java/accessibility/AccessibleObjectFactory.java b/accessibility/bridge/org/openoffice/java/accessibility/AccessibleObjectFactory.java deleted file mode 100644 index 4023ee9b2c4a..000000000000 --- a/accessibility/bridge/org/openoffice/java/accessibility/AccessibleObjectFactory.java +++ /dev/null @@ -1,534 +0,0 @@ -/* - * 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 . - */ - -package org.openoffice.java.accessibility; - -import java.awt.Component; -import java.awt.EventQueue; -import java.lang.ref.WeakReference; -import com.sun.star.uno.*; -import com.sun.star.accessibility.*; -import org.openoffice.java.accessibility.logging.XAccessibleEventLog; - -/** -*/ -public class AccessibleObjectFactory { - // This type is needed for conversions from/to uno Any - public static final Type XAccessibleType = new Type(XAccessible.class); - - private static java.util.HashMap<String, WeakReference<Component>> objectList = new java.util.HashMap<String, WeakReference<Component>>(); - private static java.awt.FocusTraversalPolicy focusTraversalPolicy = new FocusTraversalPolicy(); - - private static java.awt.EventQueue theEventQueue = java.awt.Toolkit.getDefaultToolkit(). - getSystemEventQueue(); - - public static java.awt.EventQueue getEventQueue() { - return theEventQueue; - } - - public static void postFocusGained(java.awt.Component c) { - getEventQueue().postEvent(new java.awt.event.FocusEvent(c, java.awt.event.FocusEvent.FOCUS_GAINED)); - } - - public static void postWindowGainedFocus(java.awt.Window w) { - postWindowEvent(w, java.awt.event.WindowEvent.WINDOW_GAINED_FOCUS); - } - - public static void postWindowLostFocus(java.awt.Window w) { - postWindowEvent(w, java.awt.event.WindowEvent.WINDOW_LOST_FOCUS); - } - - public static void postWindowActivated(java.awt.Window w) { - postWindowEvent(w, java.awt.event.WindowEvent.WINDOW_ACTIVATED); - } - - public static void postWindowDeactivated(java.awt.Window w) { - postWindowEvent(w, java.awt.event.WindowEvent.WINDOW_DEACTIVATED); - } - - public static void postWindowOpened(java.awt.Window w) { - postWindowEvent(w, java.awt.event.WindowEvent.WINDOW_OPENED); - } - - public static void postWindowClosed(java.awt.Window w) { - postWindowEvent(w, java.awt.event.WindowEvent.WINDOW_CLOSED); - } - - public static void invokeAndWait() { - try { - EventQueue.invokeAndWait( new java.lang.Runnable () { - public void run() { - } - }); - } catch (java.lang.reflect.InvocationTargetException e) { - } catch (java.lang.InterruptedException e) { - } - } - - private static void postWindowEvent(java.awt.Window w, int i) { - theEventQueue.postEvent(new java.awt.event.WindowEvent(w, i)); - } - - public static java.awt.Component getAccessibleComponent(XAccessible xAccessible) { - java.awt.Component c = null; - if (xAccessible != null) { - // Retrieve unique id for the original UNO object to be used as a hash key - String oid = UnoRuntime.generateOid(xAccessible); - - // Check if we already have a wrapper object for this context - synchronized (objectList) { - WeakReference<java.awt.Component> r = objectList.get(oid); - if(r != null) { - c = r.get(); - } - } - } - return c; - } - - public static void addChild(java.awt.Container parent, Object any) { - try { - addChild(parent, (XAccessible) AnyConverter.toObject(XAccessibleType, any)); - } catch (com.sun.star.lang.IllegalArgumentException e) { - System.err.println(e.getClass().getName() + " caught: " + e.getMessage()); - } - } - - public static void addChild(java.awt.Container parent, XAccessible child) { - try { - if (child != null) { - XAccessibleContext childAC = child.getAccessibleContext(); - if (childAC != null) { - XAccessibleStateSet stateSet = childAC.getAccessibleStateSet(); - if (stateSet != null) { - java.awt.Component c = getAccessibleComponent(child); - - // Re-use existing wrapper if possible, create a new one otherwise - if (c != null) { - // Seems to be already in child list - if (parent.equals(c.getParent())) - return; - // Update general component states - c.setEnabled(stateSet.contains(AccessibleStateType.ENABLED)); - c.setVisible(stateSet.contains(AccessibleStateType.VISIBLE)); - } else { - c = createAccessibleComponentImpl(child, childAC, stateSet); - } - - if (c != null) { - if (c instanceof java.awt.Container) { - populateContainer((java.awt.Container) c, childAC); - } - parent.add(c); - // Simulate focus gained event for new child - if (stateSet.contains(AccessibleStateType.FOCUSED)) { - postFocusGained(c); - } - } - } - } - } - } catch (com.sun.star.uno.RuntimeException e) { - System.err.println(e.getClass().getName() + " caught: " + e.getMessage()); - e.printStackTrace(); - } - } - - protected static void removeChild(java.awt.Container parent, Object any) { - try { - XAccessible xAccessible = (XAccessible) AnyConverter.toObject(XAccessibleType, any); - java.awt.Component c = getAccessibleComponent(xAccessible); - - if (c != null) { - parent.remove(c); - - if (c instanceof java.awt.Container) { - clearContainer((java.awt.Container) c); - } - } - } catch (com.sun.star.lang.IllegalArgumentException e) { - System.err.println(e.getClass().getName() + " caught: " + e.getMessage()); - } - } - - - /** - * Removes all children from the container parent - */ - - protected static void clearContainer(java.awt.Container parent) { - // Purge all children from this container - int count = parent.getComponentCount(); - for (int i = 0; i < count; i++) { - java.awt.Component c = parent.getComponent(i); - if (c instanceof java.awt.Container) { - clearContainer((java.awt.Container) c); - } - } - parent.removeAll(); - } - - - /** - * Populates the given Container parent with wrapper objects for all children of parentAC. This method is - * intended to be called when a container is added using a CHILDREN_CHANGED event. - */ - - protected static void populateContainer(java.awt.Container parent, XAccessibleContext parentAC) { - if (parentAC != null) { - try { - int childCount = parentAC.getAccessibleChildCount(); - for (int i=0; i<childCount; i++) { - addChild(parent, parentAC.getAccessibleChild(i)); - } - } catch (java.lang.Exception e) { - System.err.println(e.getClass().getName() + " caught: " + e.getMessage()); - e.printStackTrace(); - } - } - } - - /** - * Populates the given Container parent with wrapper objects for all children of parentAC. This method is - * intended to be called when a new window has been opened. - */ - protected static void populateContainer(java.awt.Container parent, XAccessibleContext parentAC, java.awt.Window frame) { - if (parentAC != null) { - try { - int childCount = parentAC.getAccessibleChildCount(); - for (int i=0; i<childCount; i++) { - XAccessible child = parentAC.getAccessibleChild(i); - if (child != null) { - XAccessibleContext childAC = child.getAccessibleContext(); - java.awt.Component c = createAccessibleComponent(child, childAC, frame); - if (c != null) { - if (c instanceof java.awt.Container) { - populateContainer((java.awt.Container) c, childAC, frame); - } - parent.add(c); - } - } else if (Build.DEBUG) { - System.err.println("ignoring not accessible child " + i); - } - } - } - - catch (java.lang.Exception e) { - System.err.println(e.getClass().getName() + " caught: " + e.getMessage()); - e.printStackTrace(); - } - } - } - - protected static java.awt.Component createAccessibleComponent(XAccessible xAccessible) { - try { - XAccessibleContext xAccessibleContext = xAccessible.getAccessibleContext(); - if (xAccessibleContext != null) { - return createAccessibleComponentImpl(xAccessible, xAccessibleContext, xAccessibleContext.getAccessibleStateSet()); - } - } catch (com.sun.star.uno.RuntimeException e) { - System.err.println(e.getClass().getName() + " caught: " + e.getMessage()); - e.printStackTrace(); - } - return null; - } - - protected static java.awt.Component createAccessibleComponent(XAccessible xAccessible, XAccessibleContext xAccessibleContext, - java.awt.Window frame) { - if (xAccessibleContext != null) { - try { - XAccessibleStateSet xAccessibleStateSet = xAccessibleContext.getAccessibleStateSet(); - java.awt.Component c = createAccessibleComponentImpl(xAccessible, xAccessibleContext, xAccessibleStateSet); - if (c != null) { - // Set this component as initial component - if (xAccessibleStateSet.contains(AccessibleStateType.FOCUSED)) { - if (frame instanceof NativeFrame) { - ((NativeFrame) frame).setInitialComponent(c); - } - } - return c; - } - } catch (com.sun.star.uno.RuntimeException e) { - System.err.println(e.getClass().getName() + " caught: " + e.getMessage()); - e.printStackTrace(); - } - } - return null; - } - - protected static java.awt.Component createAccessibleComponentImpl(XAccessible xAccessible, XAccessibleContext xAccessibleContext, - XAccessibleStateSet xAccessibleStateSet) { - java.awt.Component c = null; - short role = xAccessibleContext.getAccessibleRole(); - switch (role) { - case AccessibleRole.CANVAS: - c = new Container(javax.accessibility.AccessibleRole.CANVAS, - xAccessible, xAccessibleContext); - break; - case AccessibleRole.CHECK_BOX: - c = new CheckBox(xAccessible, xAccessibleContext); - break; - case AccessibleRole.COMBO_BOX: - c = new ComboBox(xAccessible, xAccessibleContext); - break; - case AccessibleRole.DOCUMENT: - c = new Container(javax.accessibility.AccessibleRole.CANVAS, - xAccessible, xAccessibleContext); - break; - case AccessibleRole.EMBEDDED_OBJECT: - c = new Container(javax.accessibility.AccessibleRole.PANEL, - xAccessible, xAccessibleContext); - break; - case AccessibleRole.END_NOTE: - c = new Container(javax.accessibility.AccessibleRole.PANEL, - xAccessible, xAccessibleContext); - break; - case AccessibleRole.FILLER: - c = new Container(javax.accessibility.AccessibleRole.FILLER, - xAccessible, xAccessibleContext); - break; - case AccessibleRole.FOOTNOTE: - c = new Container(javax.accessibility.AccessibleRole.PANEL, - xAccessible, xAccessibleContext); - break; - case AccessibleRole.FOOTER: - c = new Container(javax.accessibility.AccessibleRole.PANEL, - xAccessible, xAccessibleContext); - break; - case AccessibleRole.GRAPHIC: - c = new Container(javax.accessibility.AccessibleRole.PANEL, - xAccessible, xAccessibleContext); - break; - case AccessibleRole.HEADER: - c = new Container(javax.accessibility.AccessibleRole.PANEL, - xAccessible, xAccessibleContext); - break; - case AccessibleRole.ICON: - c = new Icon(xAccessible, xAccessibleContext); - break; - case AccessibleRole.LABEL: - c = new Label(xAccessible, xAccessibleContext); - break; - case AccessibleRole.LAYERED_PANE: - c = new Container(javax.accessibility.AccessibleRole.LAYERED_PANE, - xAccessible, xAccessibleContext); - break; - case AccessibleRole.LIST: - if (xAccessibleStateSet.contains(AccessibleStateType.MANAGES_DESCENDANTS)) { - c = new List(xAccessible, xAccessibleContext); - } else { - c = new Container(javax.accessibility.AccessibleRole.LIST, - xAccessible, xAccessibleContext); - } - break; - case AccessibleRole.MENU: - c = new Menu(xAccessible, xAccessibleContext); - break; - case AccessibleRole.MENU_BAR: - c = new MenuContainer(javax.accessibility.AccessibleRole.MENU_BAR, xAccessible, xAccessibleContext); - break; - case AccessibleRole.MENU_ITEM: - c = new MenuItem(xAccessible, xAccessibleContext); - break; - case AccessibleRole.POPUP_MENU: - c = new MenuContainer(javax.accessibility.AccessibleRole.POPUP_MENU, xAccessible, xAccessibleContext); - break; - case AccessibleRole.OPTION_PANE: - c = new Container(javax.accessibility.AccessibleRole.OPTION_PANE, - xAccessible, xAccessibleContext); - break; - case AccessibleRole.PAGE_TAB: - c = new Container(javax.accessibility.AccessibleRole.PAGE_TAB, xAccessible, xAccessibleContext); - break; - case AccessibleRole.PAGE_TAB_LIST: - c = new Container(javax.accessibility.AccessibleRole.PAGE_TAB_LIST, xAccessible, xAccessibleContext); - break; - case AccessibleRole.PARAGRAPH: - case AccessibleRole.HEADING: - c = new Paragraph(xAccessible, xAccessibleContext); - break; - case AccessibleRole.PANEL: - c = new Container(javax.accessibility.AccessibleRole.PANEL, - xAccessible, xAccessibleContext); - break; - case AccessibleRole.PUSH_BUTTON: - c = new Button(xAccessible, xAccessibleContext); - break; - case AccessibleRole.RADIO_BUTTON: - c = new RadioButton(xAccessible, xAccessibleContext); - break; - case AccessibleRole.ROOT_PANE: - c = new Container(javax.accessibility.AccessibleRole.ROOT_PANE, - xAccessible, xAccessibleContext); - break; - case AccessibleRole.SCROLL_BAR: - c = new ScrollBar(xAccessible, xAccessibleContext); - break; - case AccessibleRole.SCROLL_PANE: - c = new Container(javax.accessibility.AccessibleRole.SCROLL_PANE, - xAccessible, xAccessibleContext); - break; - case AccessibleRole.SEPARATOR: - c = new Separator(xAccessible, xAccessibleContext); - break; - case AccessibleRole.SHAPE: - c = new Container(javax.accessibility.AccessibleRole.CANVAS, - xAccessible, xAccessibleContext); - break; - case AccessibleRole.SPLIT_PANE: - c = new Container(javax.accessibility.AccessibleRole.SPLIT_PANE, - xAccessible, xAccessibleContext); - break; - case AccessibleRole.STATUS_BAR: - c = new Container(javax.accessibility.AccessibleRole.STATUS_BAR, - xAccessible, xAccessibleContext); - break; - case AccessibleRole.COLUMN_HEADER: - case AccessibleRole.TABLE: - if (xAccessibleStateSet.contains(AccessibleStateType.MANAGES_DESCENDANTS)) { - c = new Table(xAccessible, xAccessibleContext, - xAccessibleStateSet.contains(AccessibleStateType.MULTI_SELECTABLE)); - } else { - c = new Container(javax.accessibility.AccessibleRole.TABLE, - xAccessible, xAccessibleContext); - } - break; - case AccessibleRole.TABLE_CELL: - if( xAccessibleContext.getAccessibleChildCount() > 0 ) - c = new Container(javax.accessibility.AccessibleRole.PANEL, - xAccessible, xAccessibleContext); - else - c = new Label(xAccessible, xAccessibleContext); - break; - case AccessibleRole.TEXT: - c = new TextComponent(xAccessible, xAccessibleContext); - break; - case AccessibleRole.TEXT_FRAME: - c = new Container(javax.accessibility.AccessibleRole.PANEL, - xAccessible, xAccessibleContext); - break; - case AccessibleRole.TOGGLE_BUTTON: - c = new ToggleButton(xAccessible, xAccessibleContext); - break; - case AccessibleRole.TOOL_BAR: - c = new Container(javax.accessibility.AccessibleRole.TOOL_BAR, - xAccessible, xAccessibleContext); - break; - case AccessibleRole.TOOL_TIP: - c = new ToolTip(xAccessible, xAccessibleContext); - break; - case AccessibleRole.TREE: - c = new Tree(xAccessible, xAccessibleContext); - break; - case AccessibleRole.VIEW_PORT: - c = new Container(javax.accessibility.AccessibleRole.VIEWPORT, - xAccessible, xAccessibleContext); - break; - default: - System.err.println("Unmapped accessible object " + role); - System.err.println("usually mapped to " + AccessibleRoleAdapter.getAccessibleRole(role)); - c = new Container(AccessibleRoleAdapter.getAccessibleRole(role), - xAccessible, xAccessibleContext); - break; - } - if (c != null) { - // Add the newly created object to the cache list - synchronized (objectList) { - objectList.put(c.toString(), new WeakReference<Component>(c)); - if (Build.DEBUG) { -// System.out.println("Object cache now contains " + objectList.size() + " objects."); - } - } - - AccessibleStateAdapter.setComponentState(c, xAccessibleStateSet); - - if (! Build.PRODUCT) { - String property = System.getProperty("AccessBridgeLogging"); - if ((property != null) && (property.indexOf("event") != -1)) { - XAccessibleEventLog.addEventListener(xAccessibleContext, c); - } - } - } - - return c; - } - - protected static void disposing(java.awt.Component c) { - if (c != null) { - synchronized (objectList) { - objectList.remove(c.toString()); - } - } - } - - public static java.awt.Window getTopWindow(XAccessible xAccessible) { - XAccessibleContext xAccessibleContext = xAccessible.getAccessibleContext(); - - if (xAccessibleContext != null) { - short role = xAccessibleContext.getAccessibleRole(); - XAccessibleStateSet xAccessibleStateSet = xAccessibleContext.getAccessibleStateSet(); - XAccessibleComponent xAccessibleComponent = UnoRuntime.queryInterface(XAccessibleComponent.class, xAccessibleContext); - - java.awt.Window w; - if (role == AccessibleRole.DIALOG) { - w = new Dialog(new Application(), - xAccessibleContext.getAccessibleName(), - xAccessibleStateSet.contains(AccessibleStateType.MODAL), - xAccessibleComponent); - } else if (role == AccessibleRole.ALERT) { - w = new Alert(new Application(), - xAccessibleContext.getAccessibleName(), - xAccessibleStateSet.contains(AccessibleStateType.MODAL), - xAccessibleComponent); - } else if (role == AccessibleRole.FRAME) { - w = new Frame(xAccessibleContext.getAccessibleName(), - xAccessibleComponent); - } else if (role == AccessibleRole.WINDOW) { - java.awt.Window activeWindow = - java.awt.KeyboardFocusManager.getCurrentKeyboardFocusManager().getActiveWindow(); - if (activeWindow != null) { - w = new Window(activeWindow, xAccessibleComponent); - } else { - if (Build.DEBUG) { - System.err.println("no active frame found for Window: " + role); - } - return null; - } - } else { - if (Build.DEBUG) { - System.err.println("invalid role for toplevel window: " + role); - } - return null; - } - populateContainer(w, xAccessibleContext, w); - w.setFocusTraversalPolicy(focusTraversalPolicy); - w.setVisible(true); - - // Make the new window the focused one if it has an initialy focused object set. - java.awt.Component c = ((NativeFrame) w).getInitialComponent(); - if (c != null) { - postWindowGainedFocus(w); - } - return w; - } - - return null; - } -} - - diff --git a/accessibility/bridge/org/openoffice/java/accessibility/AccessibleRoleAdapter.java b/accessibility/bridge/org/openoffice/java/accessibility/AccessibleRoleAdapter.java deleted file mode 100644 index b0b7ea45c9c9..000000000000 --- a/accessibility/bridge/org/openoffice/java/accessibility/AccessibleRoleAdapter.java +++ /dev/null @@ -1,139 +0,0 @@ -/* - * 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 . - */ - -package org.openoffice.java.accessibility; - -import com.sun.star.accessibility.XAccessible; -import com.sun.star.accessibility.XAccessibleContext; - -/** This class maps the AccessibleRole(s) of the UNO accessibility API - * to the corresponding javax.accessibility objects. - */ -public abstract class AccessibleRoleAdapter { - - /* This array is used as a mapping between the UNO AccessibleRole - * and the AccessibleRole objects of the Java accessibility API. - */ - public static final javax.accessibility.AccessibleRole[] data = { - javax.accessibility.AccessibleRole.UNKNOWN, - javax.accessibility.AccessibleRole.ALERT, - javax.accessibility.AccessibleRole.COLUMN_HEADER, - javax.accessibility.AccessibleRole.CANVAS, - javax.accessibility.AccessibleRole.CHECK_BOX, - javax.accessibility.AccessibleRole.CHECK_BOX, // CHECK_MENU_ITEM - javax.accessibility.AccessibleRole.COLOR_CHOOSER, - javax.accessibility.AccessibleRole.COMBO_BOX, - javax.accessibility.AccessibleRole.DATE_EDITOR, - javax.accessibility.AccessibleRole.DESKTOP_ICON, - javax.accessibility.AccessibleRole.DESKTOP_PANE, - javax.accessibility.AccessibleRole.DIRECTORY_PANE, - javax.accessibility.AccessibleRole.DIALOG, - javax.accessibility.AccessibleRole.CANVAS, // DOCUMENT - javax.accessibility.AccessibleRole.PANEL, // EMBEDDED_OBJECT - javax.accessibility.AccessibleRole.PANEL, // ENDNOTE - javax.accessibility.AccessibleRole.FILE_CHOOSER, - javax.accessibility.AccessibleRole.FILLER, - javax.accessibility.AccessibleRole.FONT_CHOOSER, - javax.accessibility.AccessibleRole.FOOTER, - javax.accessibility.AccessibleRole.PANEL, // FOOTNOTE - javax.accessibility.AccessibleRole.FRAME, - javax.accessibility.AccessibleRole.GLASS_PANE, - javax.accessibility.AccessibleRole.PANEL, // GRAPHIC - javax.accessibility.AccessibleRole.GROUP_BOX, - javax.accessibility.AccessibleRole.HEADER, - javax.accessibility.AccessibleRole.TEXT, // HEADING - javax.accessibility.AccessibleRole.HYPERLINK, - javax.accessibility.AccessibleRole.ICON, - javax.accessibility.AccessibleRole.INTERNAL_FRAME, - javax.accessibility.AccessibleRole.LABEL, - javax.accessibility.AccessibleRole.LAYERED_PANE, - javax.accessibility.AccessibleRole.LIST, - javax.accessibility.AccessibleRole.LABEL, // LIST_ITEM - required by Zoomtext - javax.accessibility.AccessibleRole.MENU, - javax.accessibility.AccessibleRole.MENU_BAR, - javax.accessibility.AccessibleRole.MENU_ITEM, - javax.accessibility.AccessibleRole.OPTION_PANE, - javax.accessibility.AccessibleRole.PAGE_TAB, - javax.accessibility.AccessibleRole.PAGE_TAB_LIST, - javax.accessibility.AccessibleRole.PANEL, - javax.accessibility.AccessibleRole.PARAGRAPH, - javax.accessibility.AccessibleRole.PASSWORD_TEXT, - javax.accessibility.AccessibleRole.POPUP_MENU, - javax.accessibility.AccessibleRole.PUSH_BUTTON, - javax.accessibility.AccessibleRole.PROGRESS_BAR, - javax.accessibility.AccessibleRole.RADIO_BUTTON, - javax.accessibility.AccessibleRole.RADIO_BUTTON, // RADIO_MENU_ITEM - javax.accessibility.AccessibleRole.ROW_HEADER, - javax.accessibility.AccessibleRole.ROOT_PANE, - javax.accessibility.AccessibleRole.SCROLL_BAR, - javax.accessibility.AccessibleRole.SCROLL_PANE, - javax.accessibility.AccessibleRole.CANVAS, // SHAPE - javax.accessibility.AccessibleRole.SEPARATOR, - javax.accessibility.AccessibleRole.SLIDER, - javax.accessibility.AccessibleRole.SPIN_BOX, - javax.accessibility.AccessibleRole.SPLIT_PANE, - javax.accessibility.AccessibleRole.STATUS_BAR, - javax.accessibility.AccessibleRole.TABLE, - javax.accessibility.AccessibleRole.LABEL, // TABLE_CELL - required by ZoomText - javax.accessibility.AccessibleRole.TEXT, - javax.accessibility.AccessibleRole.PANEL, // TEXT_FRAME - javax.accessibility.AccessibleRole.TOGGLE_BUTTON, - javax.accessibility.AccessibleRole.TOOL_BAR, - javax.accessibility.AccessibleRole.TOOL_TIP, - javax.accessibility.AccessibleRole.TREE, - javax.accessibility.AccessibleRole.VIEWPORT, - javax.accessibility.AccessibleRole.WINDOW, - javax.accessibility.AccessibleRole.RADIO_BUTTON, // BUTTON_DROPDOWN - javax.accessibility.AccessibleRole.RADIO_BUTTON, // BUTTON_MENU - javax.accessibility.AccessibleRole.PANEL, // CAPTION - javax.accessibility.AccessibleRole.PANEL, // CHART - javax.accessibility.AccessibleRole.EDITBAR, - javax.accessibility.AccessibleRole.PANEL, // FORM - javax.accessibility.AccessibleRole.PANEL, // IMAGE_MAP - javax.accessibility.AccessibleRole.PANEL, // NOTE - javax.accessibility.AccessibleRole.PANEL, // PAGE - javax.accessibility.AccessibleRole.RULER, - javax.accessibility.AccessibleRole.PANEL, // SECTION - javax.accessibility.AccessibleRole.LABEL, // TREE_ITEM - javax.accessibility.AccessibleRole.TABLE // TREE_TABLE - }; - - public static javax.accessibility.AccessibleRole getAccessibleRole(short role) { - if(role < data.length) { - if(data[role] == null) { - System.err.println("Unmapped role: " + role); - } - return data[role]; - } - // FIXME: remove debug out - System.err.println("Unmappable role: " + role); - return null; - } - - public static javax.accessibility.AccessibleRole getAccessibleRole(XAccessible unoAccessible) { - try { - XAccessibleContext unoAccessibleContext = unoAccessible.getAccessibleContext(); - if (unoAccessibleContext != null) { - return getAccessibleRole(unoAccessibleContext.getAccessibleRole()); - } - return null; - } catch (com.sun.star.uno.RuntimeException e) { - return javax.accessibility.AccessibleRole.UNKNOWN; - } - } -} diff --git a/accessibility/bridge/org/openoffice/java/accessibility/AccessibleSelectionImpl.java b/accessibility/bridge/org/openoffice/java/accessibility/AccessibleSelectionImpl.java deleted file mode 100644 index 80d07fd2dcf1..000000000000 --- a/accessibility/bridge/org/openoffice/java/accessibility/AccessibleSelectionImpl.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * 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 . - */ - -package org.openoffice.java.accessibility; - -import com.sun.star.accessibility.*; - -class AccessibleSelectionImpl implements javax.accessibility.AccessibleSelection { - XAccessibleSelection unoAccessibleSelection; - - AccessibleSelectionImpl(XAccessibleSelection xAccessibleSelection) { - unoAccessibleSelection = xAccessibleSelection; - } - - /** Returns an Accessible representing the specified selected child of the object */ - public javax.accessibility.Accessible getAccessibleSelection(int i) { - try { - return (javax.accessibility.Accessible) AccessibleObjectFactory.getAccessibleComponent( - unoAccessibleSelection.getSelectedAccessibleChild(i)); - } catch (com.sun.star.uno.Exception e) { - return null; - } - } - - /** Adds the specified Accessible child of the object to the object's selection */ - public void addAccessibleSelection(int i) { - try { - unoAccessibleSelection.selectAccessibleChild(i); - } catch (com.sun.star.uno.Exception e) { - } - } - - /** Clears the selection in the object, so that no children in the object are selected */ - public void clearAccessibleSelection() { - try { - unoAccessibleSelection.clearAccessibleSelection(); - } catch (com.sun.star.uno.RuntimeException e) { - } - } - - /** Returns the number of Accessible children currently selected */ - public int getAccessibleSelectionCount() { - try { - return unoAccessibleSelection.getSelectedAccessibleChildCount(); - } catch (com.sun.star.uno.RuntimeException e) { - return 0; - } - } - - /** Determines if the current child of this object is selected */ - public boolean isAccessibleChildSelected(int i) { - try { - return unoAccessibleSelection.isAccessibleChildSelected(i); - } catch (com.sun.star.uno.Exception e) { - return false; - } - } - - /** Removes the specified child of the object from the object's selection */ - public void removeAccessibleSelection(int i) { - try { - unoAccessibleSelection.deselectAccessibleChild(i); - } catch (com.sun.star.uno.Exception e) { - } - } - - /** Causes every child of the object to be selected if the object supports multiple selection */ - public void selectAllAccessibleSelection() { - try { - unoAccessibleSelection.selectAllAccessibleChildren(); - } catch (com.sun.star.uno.RuntimeException e) { - } - } - -} diff --git a/accessibility/bridge/org/openoffice/java/accessibility/AccessibleStateAdapter.java b/accessibility/bridge/org/openoffice/java/accessibility/AccessibleStateAdapter.java deleted file mode 100644 index cd8373fb3d5b..000000000000 --- a/accessibility/bridge/org/openoffice/java/accessibility/AccessibleStateAdapter.java +++ /dev/null @@ -1,205 +0,0 @@ -/* - * 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 . - */ - -package org.openoffice.java.accessibility; - -import javax.accessibility.AccessibleState; -import javax.accessibility.AccessibleStateSet; - -import com.sun.star.uno.AnyConverter; -import com.sun.star.accessibility.AccessibleStateType; -import com.sun.star.accessibility.XAccessibleStateSet; - -public class AccessibleStateAdapter { - - private static final AccessibleState[] stateTypeMap = { - null, - AccessibleState.ACTIVE, - AccessibleState.ARMED, - AccessibleState.BUSY, - AccessibleState.CHECKED, - AccessibleExtendedState.DEFUNCT, - AccessibleState.EDITABLE, - AccessibleState.ENABLED, - AccessibleState.EXPANDABLE, - AccessibleState.EXPANDED, - AccessibleState.FOCUSABLE, - AccessibleState.FOCUSED, - AccessibleState.HORIZONTAL, - AccessibleState.ICONIFIED, - AccessibleExtendedState.INDETERMINATE, - AccessibleExtendedState.MANAGES_DESCENDANTS, - AccessibleState.MODAL, - AccessibleState.MULTI_LINE, - AccessibleState.MULTISELECTABLE, - AccessibleState.OPAQUE, - AccessibleState.PRESSED, - AccessibleState.RESIZABLE, - AccessibleState.SELECTABLE, - AccessibleState.SELECTED, - AccessibleExtendedState.SENSITIVE, - AccessibleState.SHOWING, - AccessibleState.SINGLE_LINE, - AccessibleExtendedState.STALE, - AccessibleState.TRANSIENT, - AccessibleState.VERTICAL, - AccessibleState.VISIBLE - }; - - private static void printToplevelStateMessage(AccessibleState s, java.awt.Component c) { - System.err.println("*** ERROR *** " + s + " state is a toplevel window state " + c); - } - - private static String getDisplayName(java.awt.Component c) { - javax.accessibility.Accessible a = (javax.accessibility.Accessible) c; - if( a != null) { - javax.accessibility.AccessibleContext ac = a.getAccessibleContext(); - return "[" + ac.getAccessibleRole() + "] " + ac.getAccessibleName(); - } else { - return c.toString(); - } - } - - private static void printOutOfSyncMessage(AccessibleState s, java.awt.Component c, boolean enabled) { - System.err.println("*** ERROR *** " + s + " state out of sync (UNO state set: " + !enabled + ", Java component state: " + enabled + ") for " + getDisplayName(c)); - } - - public static AccessibleState getAccessibleState(Object any) { - try { - if (AnyConverter.isShort(any)) { - return getAccessibleState(AnyConverter.toShort(any)); - } - return null; - } catch (com.sun.star.lang.IllegalArgumentException e) { - return null; - } - } - - public static AccessibleState getAccessibleState(short unoStateType) { - if (unoStateType > 0 && unoStateType < stateTypeMap.length) { - return stateTypeMap[unoStateType]; - } - return null; - } - - public static AccessibleStateSet getDefunctStateSet() { - AccessibleStateSet ass = new AccessibleStateSet(); - ass.add(AccessibleExtendedState.DEFUNCT); - return ass; - } - - public static void setComponentState(java.awt.Component c, - XAccessibleStateSet xAccessibleStateSet) { - - try { - if (xAccessibleStateSet != null) { - // Set the boundings of the component if it is visible .. - if (!xAccessibleStateSet.contains(AccessibleStateType.VISIBLE)) { - c.setVisible(false); - } - // Set the components' enabled state .. - if (!xAccessibleStateSet.contains(AccessibleStateType.ENABLED)) { - c.setEnabled(false); - } - // Set the components' focusable state .. - if (!xAccessibleStateSet.contains(AccessibleStateType.FOCUSABLE)) { - c.setFocusable(false); - } - } - } catch (com.sun.star.uno.RuntimeException e) { - } - } - - public static AccessibleStateSet getAccessibleStateSet(java.awt.Component c, - XAccessibleStateSet xAccessibleStateSet) { - - try { - if (xAccessibleStateSet != null) { - AccessibleStateSet as = new AccessibleStateSet(); - short[] unoStateTypes = xAccessibleStateSet.getStates(); - for (int i=0; i<unoStateTypes.length; i++) { - if (unoStateTypes[i] > 0 && - unoStateTypes[i] < stateTypeMap.length) { - as.add(stateTypeMap[unoStateTypes[i]]); - } - } - - // Note: COLLAPSED does not exists in the UAA. - if (as.contains(AccessibleState.EXPANDABLE) && - ! as.contains(AccessibleState.EXPANDED)) { - as.add(AccessibleState.COLLAPSED); - } - - // Sync office and Java FOCUSED state - boolean isFocusInSync; - if (c.isFocusOwner()) { - isFocusInSync = !as.add(AccessibleState.FOCUSED); - } else { - isFocusInSync = !as.remove(AccessibleState.FOCUSED); - } - - // Sync office and Java ACTIVE state - boolean isActiveInSync; - if (c instanceof java.awt.Window && ((java.awt.Window) c).isActive()) { - isActiveInSync = !as.add(AccessibleState.ACTIVE); - } else { - isActiveInSync = !as.remove(AccessibleState.ACTIVE); - } - - // Report out-of-sync messages - if (!Build.PRODUCT) { - if (!isFocusInSync) { - printOutOfSyncMessage(AccessibleState.FOCUSED, c, c.isFocusOwner()); - } - if (!isActiveInSync) { - printOutOfSyncMessage(AccessibleState.ACTIVE, c, ((java.awt.Window) c).isActive()); - } - if (as.contains(AccessibleState.ENABLED) != c.isEnabled()) { - printOutOfSyncMessage(AccessibleState.ENABLED, c, c.isEnabled()); - } - if (as.contains(AccessibleState.FOCUSABLE) != c.isFocusable()) { - printOutOfSyncMessage(AccessibleState.FOCUSABLE, c, c.isFocusable()); - } - if (as.contains(AccessibleState.SHOWING) != c.isShowing()) { - printOutOfSyncMessage(AccessibleState.SHOWING, c, c.isShowing()); - } - if (as.contains(AccessibleState.VISIBLE) != c.isVisible()) { - printOutOfSyncMessage(AccessibleState.VISIBLE, c, c.isVisible()); - } - - // The following states are for toplevel windows only - if (! (c instanceof java.awt.Window)) { - if (as.contains(AccessibleState.ACTIVE)) { - printToplevelStateMessage(AccessibleState.ACTIVE, c); - } - if (as.contains(AccessibleState.ICONIFIED)) { - printToplevelStateMessage(AccessibleState.ICONIFIED, c); - } - if (as.contains(AccessibleState.MODAL)) { - printToplevelStateMessage(AccessibleState.MODAL, c); - } - } - } - return as; - } - return null; - } catch (com.sun.star.uno.RuntimeException e) { - return getDefunctStateSet(); - } - } -} diff --git a/accessibility/bridge/org/openoffice/java/accessibility/AccessibleTextImpl.java b/accessibility/bridge/org/openoffice/java/accessibility/AccessibleTextImpl.java deleted file mode 100644 index 92c10de8432e..000000000000 --- a/accessibility/bridge/org/openoffice/java/accessibility/AccessibleTextImpl.java +++ /dev/null @@ -1,663 +0,0 @@ -/* - * 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 . - */ -package org.openoffice.java.accessibility; - -import com.sun.star.accessibility.*; -import com.sun.star.awt.*; -import com.sun.star.style.*; -import com.sun.star.uno.*; - -import org.openoffice.java.accessibility.logging.*; - -import java.text.BreakIterator; -import javax.accessibility.AccessibleText; - -import javax.swing.text.StyleConstants; - -/** The GenericAccessibleEditableText mapps the calls to the java AccessibleEditableText - * interface to the corresponding methods of the UNO XAccessibleEditableText interface. - */ -public class AccessibleTextImpl implements javax.accessibility.AccessibleText { - final static double toPointFactor = 1 / ((7 / 10) + 34.5); - final static String[] attributeList = { - "ParaAdjust", "CharBackColor", "CharWeight", "ParaFirstLineIndent", - "CharFontName", "CharHeight", "CharColor", "CharPosture", - "ParaLeftMargin", "ParaLineSpacing", "ParaTopMargin", "ParaBottomMargin", - "CharStrikeout", "CharEscapement", "ParaTabStops", "CharUnderline" - }; - - final static String[] localeAttributeList = { - "CharLocale", "CharLocaleAsian", "CharLocaleComplex" - }; - - XAccessibleText unoObject; - private javax.swing.text.TabSet tabSet = null; - private javax.swing.text.TabStop[] tabStops = null; - private static Type TextSegmentType = new Type(TextSegment.class); - private static Type UnoLocaleType = new Type(com.sun.star.lang.Locale.class); - - /** Creates new GenericAccessibleEditableText object */ - public AccessibleTextImpl(XAccessibleText xAccessibleText) { - - if (Build.PRODUCT) { - unoObject = xAccessibleText; - } else { - String property = System.getProperty("AccessBridgeLogging"); - if ((property != null) && (property.indexOf("text") != -1)) { - unoObject = new XAccessibleTextLog(xAccessibleText); - } else { - unoObject = xAccessibleText; - } - } - } - - public AccessibleTextImpl() { - } - - public static javax.accessibility.AccessibleText get(com.sun.star.uno.XInterface unoObject) { - try { - XAccessibleText unoAccessibleText = UnoRuntime.queryInterface(XAccessibleText.class, unoObject); - if (unoAccessibleText != null) { - return new AccessibleTextImpl(unoAccessibleText); - } - } catch (com.sun.star.uno.RuntimeException e) { - } - return null; - } - - protected static Object convertTextSegment(Object any) { - try { - if (AnyConverter.isObject(any)) { - TextSegment ts = (TextSegment) - AnyConverter.toObject(TextSegmentType, any); - if (ts != null) { - // Since there is nothing like a "range" object in the JAA yet, - // the Object[3] is a private negotiation with the JABG - Object[] array = { new Integer(ts.SegmentStart), - new Integer(ts.SegmentEnd), ts.SegmentText }; - return array; - } - } - } catch (com.sun.star.lang.IllegalArgumentException e) { - } - - return null; - } - - /** Returns the locale object. - * - * Since switching the UI language only takes effect on the next - * office start, UI elements can return a cached value here - given - * that Java UNO initializes the default locale correctly, this is - * the perfect place to grab this cached values. - * - * However, since there are more sophisticated components with - * potentially more than one locale, we first check for the - * CharLocale[Asian|Complex] property. - */ - - protected java.util.Locale getLocale(int index) { - try { - com.sun.star.beans.PropertyValue[] propertyValues = - unoObject.getCharacterAttributes(index, localeAttributeList); - - if (null != propertyValues) { - for (int i = 0; i < propertyValues.length; i++) { - com.sun.star.lang.Locale unoLocale = (com.sun.star.lang.Locale) - AnyConverter.toObject(UnoLocaleType, propertyValues[i]); - if (unoLocale != null) { - return new java.util.Locale(unoLocale.Language, unoLocale.Country); - } - } - } - - return java.util.Locale.getDefault(); - } catch (com.sun.star.lang.IllegalArgumentException e) { - return java.util.Locale.getDefault(); - } catch (com.sun.star.lang.IndexOutOfBoundsException e) { - return java.util.Locale.getDefault(); - } - } - - - /** Returns the string after a given index - * - * The Java word iterator has a different understanding of what - * a word is than the word iterator used by OOo, so we use the - * Java iterators to ensure maximal compatibility with Java. - */ - public String getAfterIndex(int part, int index) { - switch (part) { - case AccessibleText.CHARACTER: - try { - String s = unoObject.getText(); - return s.substring(index+1, index+2); - } catch (IndexOutOfBoundsException e) { - return null; - } - case AccessibleText.WORD: - try { - String s = unoObject.getText(); - BreakIterator words = BreakIterator.getWordInstance(getLocale(index)); - words.setText(s); - int start = words.following(index); - if (start == BreakIterator.DONE || start >= s.length()) { - return null; - } - int end = words.following(start); - if (end == BreakIterator.DONE || end >= s.length()) { - return null; - } - return s.substring(start, end); - } catch (IllegalArgumentException e) { - return null; - } catch (IndexOutOfBoundsException e) { - return null; - } - case AccessibleText.SENTENCE: - try { - String s = unoObject.getText(); - BreakIterator sentence = - BreakIterator.getSentenceInstance(getLocale(index)); - sentence.setText(s); - int start = sentence.following(index); - if (start == BreakIterator.DONE || start >= s.length()) { - return null; - } - int end = sentence.following(start); - if (end == BreakIterator.DONE || end >= s.length()) { - return null; - } - return s.substring(start, end); - } catch (IllegalArgumentException e) { - return null; - } catch (IndexOutOfBoundsException e) { - return null; - } - case 4: - try { - TextSegment ts = unoObject.getTextBehindIndex(index, AccessibleTextType.LINE); - return ts.SegmentText; - } catch (com.sun.star.lang.IndexOutOfBoundsException e) { - // Workaround for #104847# - if (index > 0 && getCharCount() == index) { - return getAfterIndex(part, index - 1); - } - return null; - } catch (com.sun.star.lang.IllegalArgumentException e) { - return null; - } - case 5: - try { - TextSegment ts = unoObject.getTextBehindIndex(index, AccessibleTextType.ATTRIBUTE_RUN); - return ts.SegmentText; - } catch (com.sun.star.lang.IndexOutOfBoundsException e) { - return null; - } catch (com.sun.star.lang.IllegalArgumentException e) { - return null; - } - default: - return null; - } - } - - /** Returns the zero-based offset of the caret */ - public int getCaretPosition() { - try { - return unoObject.getCaretPosition(); - } catch (com.sun.star.uno.RuntimeException e) { - return -1; - } - } - - /** Returns the start offset within the selected text */ - public int getSelectionStart() { - try { - int index = unoObject.getSelectionStart(); - - if (index == -1) { - index = getCaretPosition(); - } - - return index; - } catch (com.sun.star.uno.RuntimeException e) { - return -1; - } - } - - protected void setAttribute(javax.swing.text.MutableAttributeSet as, - com.sun.star.beans.PropertyValue property) { - try { - // Map alignment attribute - if (property.Name.equals("ParaAdjust")) { - ParagraphAdjust adjust = null; - - if (property.Value instanceof ParagraphAdjust) { - adjust = (ParagraphAdjust) property.Value; - } else if (property.Value instanceof Any) { - adjust = (ParagraphAdjust) AnyConverter.toObject(new Type( - ParagraphAdjust.class), property.Value); - } else { - adjust = ParagraphAdjust.fromInt(AnyConverter.toInt( - property.Value)); - } - - if (adjust != null) { - if (adjust.equals(ParagraphAdjust.LEFT)) { - StyleConstants.setAlignment(as, - StyleConstants.ALIGN_LEFT); - } else if (adjust.equals(ParagraphAdjust.RIGHT)) { - StyleConstants.setAlignment(as, - StyleConstants.ALIGN_RIGHT); - } else if (adjust.equals(ParagraphAdjust.CENTER)) { - StyleConstants.setAlignment(as, - StyleConstants.ALIGN_CENTER); - } else if (adjust.equals(ParagraphAdjust.BLOCK) || - adjust.equals(ParagraphAdjust.STRETCH)) { - StyleConstants.setAlignment(as, - StyleConstants.ALIGN_JUSTIFIED); - } - } else if (Build.DEBUG) { - System.err.println( - "Invalid property value for key ParaAdjust: " + - property.Value.getClass().getName()); - } - - // Map background color - } else if (property.Name.equals("CharBackColor")) { - StyleConstants.setBackground(as, - new java.awt.Color(AnyConverter.toInt(property.Value))); - - // FIXME: BidiLevel - // Set bold attribute - } else if (property.Name.equals("CharWeight")) { - boolean isBold = AnyConverter.toFloat(property.Value) > 125; - StyleConstants.setBold(as, isBold); - - // FIXME: Java 1.4 ComponentAttribute, ComponentElementName, ComposedTextAttribute - // Set FirstLineIndent attribute - } else if (property.Name.equals("ParaFirstLineIndent")) { - StyleConstants.setFirstLineIndent(as, - (float) (toPointFactor * AnyConverter.toInt(property.Value))); - - // Set font family attribute - } else if (property.Name.equals("CharFontName")) { - StyleConstants.setFontFamily(as, AnyConverter.toString(property.Value)); - - // Set font size attribute - } else if (property.Name.equals("CharHeight")) { - StyleConstants.setFontSize(as, - (int) AnyConverter.toFloat(property.Value)); - - // Map foreground color - } else if (property.Name.equals("CharColor")) { - StyleConstants.setForeground(as, - new java.awt.Color(AnyConverter.toInt(property.Value))); - - // FIXME: IconAttribute, IconElementName - // Set italic attribute - } else if (property.Name.equals("CharPosture")) { - FontSlant fs = null; - - if (property.Value instanceof FontSlant) { - fs = (FontSlant) property.Value; - } else if (property.Value instanceof Any) { - fs = (FontSlant) AnyConverter.toObject(new Type( - FontSlant.class), property.Value); - } - - if (fs != null) { - StyleConstants.setItalic(as, FontSlant.ITALIC.equals(fs)); - } - - // Set left indent attribute - } else if (property.Name.equals("ParaLeftMargin")) { - StyleConstants.setLeftIndent(as, - (float) (toPointFactor * AnyConverter.toInt(property.Value))); - - // Set right indent attribute - } else if (property.Name.equals("ParaRightMargin")) { - StyleConstants.setRightIndent(as, - (float) (toPointFactor * AnyConverter.toInt(property.Value))); - } - // Set line spacing attribute - else if (property.Name.equals("ParaLineSpacing")) { - LineSpacing ls = null; - - if (property.Value instanceof LineSpacing) { - ls = (LineSpacing) property.Value; - } else if (property.Value instanceof Any) { - ls = (LineSpacing) AnyConverter.toObject(new Type( - LineSpacing.class), property.Value); - } - - if (ls != null) { - StyleConstants.setLineSpacing(as, - (float) (toPointFactor * ls.Height)); - } - } - // FIXME: Java 1.4 NameAttribute, Orientation, ResolveAttribute - // Set space above attribute - else if (property.Name.equals("ParaTopMargin")) { - StyleConstants.setSpaceAbove(as, - (float) (toPointFactor * AnyConverter.toInt(property.Value))); - } - // Set space below attribute - else if (property.Name.equals("ParaBottomMargin")) { - StyleConstants.setSpaceBelow(as, - (float) (toPointFactor * AnyConverter.toInt(property.Value))); - - // Set strike through attribute - } else if (property.Name.equals("CharStrikeout")) { - boolean isStrikeThrough = (FontStrikeout.NONE != AnyConverter.toShort(property.Value)); - StyleConstants.setStrikeThrough(as, isStrikeThrough); - - // Set sub-/superscript attribute - } else if (property.Name.equals("CharEscapement")) { - short value = AnyConverter.toShort(property.Value); - - if (value > 0) { - StyleConstants.setSuperscript(as, true); - } else if (value < 0) { - StyleConstants.setSubscript(as, true); - } - - // Set tabset attribute - } else if (property.Name.equals("ParaTabStops")) { - TabStop[] unoTabStops = (TabStop[]) AnyConverter.toArray(property.Value); - javax.swing.text.TabStop[] tabStops = new javax.swing.text.TabStop[unoTabStops.length]; - - for (int index2 = 0; index2 < unoTabStops.length; index2++) { - float pos = (float) (toPointFactor * unoTabStops[index2].Position); - - if (unoTabStops[index2].Alignment.equals(TabAlign.LEFT)) { - tabStops[index2] = new javax.swing.text.TabStop(pos, - javax.swing.text.TabStop.ALIGN_LEFT, - javax.swing.text.TabStop.LEAD_NONE); - } else if (unoTabStops[index2].Alignment.equals( - TabAlign.CENTER)) { - tabStops[index2] = new javax.swing.text.TabStop(pos, - javax.swing.text.TabStop.ALIGN_CENTER, - javax.swing.text.TabStop.LEAD_NONE); - } else if (unoTabStops[index2].Alignment.equals( - TabAlign.RIGHT)) { - tabStops[index2] = new javax.swing.text.TabStop(pos, - javax.swing.text.TabStop.ALIGN_RIGHT, - javax.swing.text.TabStop.LEAD_NONE); - } else if (unoTabStops[index2].Alignment.equals( - TabAlign.DECIMAL)) { - tabStops[index2] = new javax.swing.text.TabStop(pos, - javax.swing.text.TabStop.ALIGN_DECIMAL, - javax.swing.text.TabStop.LEAD_NONE); - } else { - tabStops[index2] = new javax.swing.text.TabStop(pos); - } - } - - // Re-use tabSet object if possible to make AttributeSet.equals work - if ((this.tabSet == null) || - !java.util.Arrays.equals(tabStops, this.tabStops)) { - this.tabStops = tabStops; - this.tabSet = new javax.swing.text.TabSet(tabStops); - } - - StyleConstants.setTabSet(as, this.tabSet); - - // Set underline attribute - } else if (property.Name.equals("CharUnderline")) { - boolean isUnderline = (FontUnderline.NONE != AnyConverter.toShort(property.Value)); - StyleConstants.setUnderline(as, isUnderline); - } - } catch (com.sun.star.lang.IllegalArgumentException e) { - if (Build.DEBUG) { - System.err.println("*** ERROR *** " + e.getClass().getName() + - " caught for property " + property.Name + ": " + - e.getMessage()); - System.err.println(" value is of type " + - property.Value.getClass().getName()); - } - } - } - - /** Returns the AttributSet for a given character at a given index */ - public javax.swing.text.AttributeSet getCharacterAttribute(int index) { - try { - com.sun.star.beans.PropertyValue[] propertyValues = unoObject.getCharacterAttributes(index, - attributeList); - javax.swing.text.SimpleAttributeSet attributeSet = new javax.swing.text.SimpleAttributeSet(); - - if (null != propertyValues) { - for (int i = 0; i < propertyValues.length; i++) { - setAttribute(attributeSet, propertyValues[i]); - } - } - - return attributeSet; - } catch (com.sun.star.lang.IndexOutOfBoundsException e) { - if ((index > 0) && (getCharCount() == index)) { - return getCharacterAttribute(index - 1); - } - return null; - } - } - - /** Given a point in local coordinates, return the zero-based index of the character under that point */ - public int getIndexAtPoint(java.awt.Point point) { - try { - return unoObject.getIndexAtPoint(new Point(point.x, point.y)); - } catch (com.sun.star.uno.RuntimeException e) { - return -1; - } - } - - /** Returns the end offset within the selected text */ - public int getSelectionEnd() { - try { - int index = unoObject.getSelectionEnd(); - - if (index == -1) { - index = getCaretPosition(); - } - - return index; - } catch (com.sun.star.uno.RuntimeException e) { - return -1; - } - } - - /** Returns the string before a given index - * - * The Java word iterator has a different understanding of what - * a word is than the word iterator used by OOo, so we use the - * Java iterators to ensure maximal compatibility with Java. - */ - public java.lang.String getBeforeIndex(int part, int index) { - switch (part) { - case AccessibleText.CHARACTER: - try { - String s = unoObject.getText(); - return s.substring(index-1, index); - } catch (IndexOutOfBoundsException e) { - return null; - } - case AccessibleText.WORD: - try { - String s = unoObject.getText(); - BreakIterator words = BreakIterator.getWordInstance(getLocale(index)); - words.setText(s); - int end = words.following(index); - end = words.previous(); - int start = words.previous(); - if (start == BreakIterator.DONE) { - return null; - } - return s.substring(start, end); - } catch (IllegalArgumentException e) { - return null; - } catch (IndexOutOfBoundsException e) { - return null; - } - case AccessibleText.SENTENCE: - try { - String s = unoObject.getText(); - BreakIterator sentence = - BreakIterator.getSentenceInstance(getLocale(index)); - sentence.setText(s); - int end = sentence.following(index); - end = sentence.previous(); - int start = sentence.previous(); - if (start == BreakIterator.DONE) { - return null; - } - return s.substring(start, end); - } catch (IllegalArgumentException e) { - return null; - } catch (IndexOutOfBoundsException e) { - return null; - } - case 4: - try { - TextSegment ts = unoObject.getTextBeforeIndex(index, AccessibleTextType.LINE); - return ts.SegmentText; - } catch (com.sun.star.lang.IndexOutOfBoundsException e) { - // Workaround for #104847# - if (index > 0 && getCharCount() == index) { - return getBeforeIndex(part, index - 1); - } - return null; - } catch (com.sun.star.lang.IllegalArgumentException e) { - return null; - } - case 5: - try { - TextSegment ts = unoObject.getTextBeforeIndex(index, AccessibleTextType.ATTRIBUTE_RUN); - return ts.SegmentText; - } catch (com.sun.star.lang.IndexOutOfBoundsException e) { - return null; - } catch (com.sun.star.lang.IllegalArgumentException e) { - return null; - } - default: - return null; - } - } - - - /** Returns the string at a given index - * - * The Java word iterator has a different understanding of what - * a word is than the word iterator used by OOo, so we use the - * Java iterators to ensure maximal compatibility with Java. - */ - public java.lang.String getAtIndex(int part, int index) { - switch (part) { - case AccessibleText.CHARACTER: - try { - String s = unoObject.getText(); - return s.substring(index, index + 1); - } catch (IndexOutOfBoundsException e) { - return null; - } - case AccessibleText.WORD: - try { - String s = unoObject.getText(); - BreakIterator words = BreakIterator.getWordInstance(getLocale(index)); - words.setText(s); - int end = words.following(index); - return s.substring(words.previous(), end); - } catch (IllegalArgumentException e) { - return null; - } catch (IndexOutOfBoundsException e) { - return null; - } - case AccessibleText.SENTENCE: - try { - String s = unoObject.getText(); - BreakIterator sentence = - BreakIterator.getSentenceInstance(getLocale(index)); - sentence.setText(s); - int end = sentence.following(index); - return s.substring(sentence.previous(), end); - } catch (IllegalArgumentException e) { - return null; - } catch (IndexOutOfBoundsException e) { - return null; - } - case 4: - try { - TextSegment ts = unoObject.getTextAtIndex(index, AccessibleTextType.LINE); - return ts.SegmentText; - } catch (com.sun.star.lang.IndexOutOfBoundsException e) { - // Workaround for #104847# - if (index > 0 && getCharCount() == index) { - return getAtIndex(part, index - 1); - } - return null; - } catch (com.sun.star.lang.IllegalArgumentException e) { - return null; - } - case 5: - try { - TextSegment ts = unoObject.getTextAtIndex(index, AccessibleTextType.ATTRIBUTE_RUN); - return ts.SegmentText; - } catch (com.sun.star.lang.IndexOutOfBoundsException e) { - return null; - } catch (com.sun.star.lang.IllegalArgumentException e) { - return null; - } - - default: - return null; - } - } - - /** Returns the number of characters (valid indicies) */ - public int getCharCount() { - try { - return unoObject.getCharacterCount(); - } catch (com.sun.star.uno.RuntimeException e) { - } - - return 0; - } - - /** Returns the portion of the text that is selected */ - public java.lang.String getSelectedText() { - try { - return unoObject.getSelectedText(); - } catch (com.sun.star.uno.RuntimeException e) { - } - - return null; - } - - /** Determines the bounding box of the character at the given index into the string */ - public java.awt.Rectangle getCharacterBounds(int index) { - try { - Rectangle unoRect = unoObject.getCharacterBounds(index); - return new java.awt.Rectangle(unoRect.X, unoRect.Y, unoRect.Width, unoRect.Height); - } catch (com.sun.star.lang.IndexOutOfBoundsException e) { - if ((index > 0) && (getCharCount() == index)) { - return getCharacterBounds(index - 1); - } - } catch (com.sun.star.uno.RuntimeException e) { - } - - return new java.awt.Rectangle(); - } -} diff --git a/accessibility/bridge/org/openoffice/java/accessibility/AccessibleValueImpl.java b/accessibility/bridge/org/openoffice/java/accessibility/AccessibleValueImpl.java deleted file mode 100644 index 32722e340c16..000000000000 --- a/accessibility/bridge/org/openoffice/java/accessibility/AccessibleValueImpl.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * 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 . - */ - -package org.openoffice.java.accessibility; - -import com.sun.star.accessibility.XAccessibleValue; -import com.sun.star.uno.AnyConverter; - -/** The AccessibleValueImpl mappes the calls to the java AccessibleValue - * interface to the corresponding methods of the UNO XAccessibleValue interface - */ -public class AccessibleValueImpl implements javax.accessibility.AccessibleValue { - protected XAccessibleValue unoObject; - - /** Creates new AccessibleValueImpl */ - public AccessibleValueImpl(XAccessibleValue xAccessibleValue) { - unoObject = xAccessibleValue; - } - - public static java.lang.Number toNumber(java.lang.Object any) { - try { - if(AnyConverter.isByte(any)) { - return new Byte(AnyConverter.toByte(any)); - } else if (AnyConverter.isShort(any)) { - return new Short(AnyConverter.toShort(any)); - } else if (AnyConverter.isInt(any)) { - return new Integer(AnyConverter.toInt(any)); - } else if (AnyConverter.isLong(any)) { - return new Long(AnyConverter.toLong(any)); - } else if (AnyConverter.isFloat(any)) { - return new Float(AnyConverter.toFloat(any)); - } else if (AnyConverter.isDouble(any)) { - return new Double(AnyConverter.toDouble(any)); - } - } catch (com.sun.star.lang.IllegalArgumentException e) { - } - - return null; - } - - public java.lang.Number getMinimumAccessibleValue() { - try { - return toNumber(unoObject.getMinimumValue()); - } catch (com.sun.star.uno.RuntimeException e) { - return null; - } - } - - public java.lang.Number getCurrentAccessibleValue() { - try { - return toNumber(unoObject.getCurrentValue()); - } catch (com.sun.star.uno.RuntimeException e) { - return null; - } - } - - public java.lang.Number getMaximumAccessibleValue() { - try { - return toNumber(unoObject.getMaximumValue()); - } catch (com.sun.star.uno.RuntimeException e) { - return null; - } - } - - public boolean setCurrentAccessibleValue(java.lang.Number number) { - try { - return unoObject.setCurrentValue(number); - } catch (com.sun.star.uno.RuntimeException e) { - return false; - } - } -} diff --git a/accessibility/bridge/org/openoffice/java/accessibility/Alert.java b/accessibility/bridge/org/openoffice/java/accessibility/Alert.java deleted file mode 100644 index 578251592a5d..000000000000 --- a/accessibility/bridge/org/openoffice/java/accessibility/Alert.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * 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 . - */ - -package org.openoffice.java.accessibility; - -import javax.accessibility.AccessibleRole; -import com.sun.star.accessibility.*; - -public class Alert extends Dialog { - - protected Alert(java.awt.Frame owner, XAccessibleComponent xAccessibleComponent) { - super(owner, xAccessibleComponent); - } - - protected Alert(java.awt.Frame owner, String name, XAccessibleComponent xAccessibleComponent) { - super(owner, name, xAccessibleComponent); - } - - protected Alert(java.awt.Frame owner, String name, boolean modal, XAccessibleComponent xAccessibleComponent) { - super(owner, name, modal, xAccessibleComponent); - } - - /** Returns the AccessibleContext associated with this object */ - public javax.accessibility.AccessibleContext getAccessibleContext() { - if (accessibleContext == null) { - accessibleContext = new AccessibleAlert(); - accessibleContext.setAccessibleName(getTitle()); - } - return accessibleContext; - } - - protected class AccessibleAlert extends AccessibleDialog { - - protected AccessibleAlert() { - super(); - } - - public AccessibleRole getAccessibleRole() { - return AccessibleRole.ALERT; - } - } -} diff --git a/accessibility/bridge/org/openoffice/java/accessibility/Application.java b/accessibility/bridge/org/openoffice/java/accessibility/Application.java deleted file mode 100644 index 2705bf29c48d..000000000000 --- a/accessibility/bridge/org/openoffice/java/accessibility/Application.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * 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 . - */ - -package org.openoffice.java.accessibility; - -import javax.accessibility.Accessible; -import javax.accessibility.AccessibleContext; - -public class Application extends java.awt.Frame implements Accessible { - - protected AccessibleContext accessibleContext = null; - - protected Application() { - super(); - } - - public boolean isShowing() { - return true; - } -} - diff --git a/accessibility/bridge/org/openoffice/java/accessibility/Button.java b/accessibility/bridge/org/openoffice/java/accessibility/Button.java deleted file mode 100644 index e0895add40a9..000000000000 --- a/accessibility/bridge/org/openoffice/java/accessibility/Button.java +++ /dev/null @@ -1,148 +0,0 @@ -/* - * 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 . - */ - -package org.openoffice.java.accessibility; - -import com.sun.star.uno.*; -import com.sun.star.accessibility.*; - -class Button extends AbstractButton implements javax.accessibility.Accessible { - - public Button(XAccessible xAccessible, XAccessibleContext xAccessibleContext) { - super(xAccessible, xAccessibleContext); - } - - protected XAccessibleEventListener createEventListener() { - return new AccessibleButtonListener(); - } - - protected class AccessibleButtonListener - extends AccessibleUNOComponentListener { - protected AccessibleButtonListener() { - super(); - } - - protected javax.accessibility.AccessibleContext getContext( Object any ) { - try { - XAccessible xAccessible = (XAccessible) - AnyConverter.toObject( AccessibleObjectFactory.XAccessibleType, any ); - - javax.accessibility.Accessible accessible = - (javax.accessibility.Accessible) Button.this.getComponent( xAccessible ); - - return accessible.getAccessibleContext(); - } catch (com.sun.star.lang.IllegalArgumentException e) { - return null; - } - } - - /** Called by OpenOffice process to notify property changes */ - public void notifyEvent(AccessibleEventObject event) { - switch (event.EventId) { - case AccessibleEventId.CHILD: - java.awt.Component c = getComponent(unoAccessible); - - Object values[] = { null, null }; - - if (AnyConverter.isObject(event.OldValue)) { - values[0] = getContext( event.OldValue ); - } - - if (AnyConverter.isObject(event.NewValue)) { - values[1] = getContext( event.NewValue); - } - - firePropertyChange(javax.accessibility.AccessibleContext.ACCESSIBLE_CHILD_PROPERTY, - values[0], values[1]); - break; - - default: - super.notifyEvent(event); - } - } - } - - /** Creates the AccessibleContext associated with this object */ - public javax.accessibility.AccessibleContext createAccessibleContext() { - return new AccessibleButton(); - } - - protected java.awt.Component getComponent(XAccessible unoAccessible) { - java.awt.Component c = AccessibleObjectFactory.getAccessibleComponent(unoAccessible); - - if (c == null) { - c = AccessibleObjectFactory.createAccessibleComponent(unoAccessible); - - if (c instanceof javax.accessibility.Accessible) { - ((javax.accessibility.Accessible) c).getAccessibleContext() - .setAccessibleParent(this); - } - - if( c instanceof java.awt.Container ) { - AccessibleObjectFactory.populateContainer((java.awt.Container) c, unoAccessible.getAccessibleContext() ); - } - } - - return c; - } - - protected class AccessibleButton extends AccessibleAbstractButton { - - /** Gets the role of this object */ - public javax.accessibility.AccessibleRole getAccessibleRole() { - return javax.accessibility.AccessibleRole.PUSH_BUTTON; - } - - /** Returns the number of accessible children of the object */ - public int getAccessibleChildrenCount() { - try { - return unoAccessibleContext.getAccessibleChildCount(); - } catch (com.sun.star.uno.RuntimeException e) { - return 0; - } - } - - /** Returns the specified Accessible child of the object */ - public synchronized javax.accessibility.Accessible getAccessibleChild( int i) { - try { - return (javax.accessibility.Accessible) getComponent( unoAccessibleContext.getAccessibleChild(i) ); - } catch (com.sun.star.uno.RuntimeException e) { - } catch (com.sun.star.lang.IndexOutOfBoundsException e) { - } - return null; - } - - /* - * AccessibleComponent - */ - - /** Returns the Accessible child, if one exists, contained at the local coordinate Point */ - public javax.accessibility.Accessible getAccessibleAt(java.awt.Point p) { - try { - java.awt.Component c = getComponent(unoAccessibleComponent.getAccessibleAtPoint( - new com.sun.star.awt.Point(p.x, p.y))); - - return (javax.accessibility.Accessible) c; - } catch (com.sun.star.uno.RuntimeException e) { - return null; - } - } - - } -} - diff --git a/accessibility/bridge/org/openoffice/java/accessibility/CheckBox.java b/accessibility/bridge/org/openoffice/java/accessibility/CheckBox.java deleted file mode 100644 index db12c24bc7e5..000000000000 --- a/accessibility/bridge/org/openoffice/java/accessibility/CheckBox.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * 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 . - */ - -package org.openoffice.java.accessibility; - -import com.sun.star.accessibility.*; - -class CheckBox extends ToggleButton { - - public CheckBox(XAccessible xAccessible, XAccessibleContext xAccessibleContext) { - super(xAccessible, xAccessibleContext); - } - - /** Creates the AccessibleContext associated with this object */ - public javax.accessibility.AccessibleContext createAccessibleContext() { - return new AccessibleCheckBox(); - } - - protected class AccessibleCheckBox extends AccessibleToggleButton { - /** Gets the role of this object */ - public javax.accessibility.AccessibleRole getAccessibleRole() { - return javax.accessibility.AccessibleRole.CHECK_BOX; - } - } -} - diff --git a/accessibility/bridge/org/openoffice/java/accessibility/ComboBox.java b/accessibility/bridge/org/openoffice/java/accessibility/ComboBox.java deleted file mode 100644 index a23967ca9dd9..000000000000 --- a/accessibility/bridge/org/openoffice/java/accessibility/ComboBox.java +++ /dev/null @@ -1,114 +0,0 @@ -/* - * 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 . - */ -package org.openoffice.java.accessibility; - -import com.sun.star.accessibility.*; -import com.sun.star.uno.*; - - -/** - */ -public class ComboBox extends Container { - private XAccessibleAction unoAccessibleAction = null; - - public ComboBox(XAccessible xAccessible, XAccessibleContext xAccessibleContext) { - super(javax.accessibility.AccessibleRole.COMBO_BOX, xAccessible, - xAccessibleContext); - } - - /** Appends the specified component to the end of this container */ - public java.awt.Component add(java.awt.Component c) { - // List should be always the first child - if (c instanceof List) { - return super.add(c, 0); - } else { - return super.add(c); - } - } - - /** Creates the AccessibleContext associated with this object */ - public javax.accessibility.AccessibleContext createAccessibleContext() { - return new AccessibleComboBox(); - } - - protected class AccessibleComboBox extends AccessibleContainer - implements javax.accessibility.AccessibleAction { - /** - * Though the class is abstract, this should be called by all sub-classes - */ - protected AccessibleComboBox() { - super(); - } - - /* - * AccessibleContext - */ - - /** Gets the AccessibleAction associated with this object that supports one or more actions */ - public javax.accessibility.AccessibleAction getAccessibleAction() { - if (unoAccessibleAction == null) { - unoAccessibleAction = UnoRuntime.queryInterface(XAccessibleAction.class, - unoAccessibleContext); - - if (unoAccessibleAction == null) { - return null; - } - } - - return this; - } - - /* - * AccessibleAction - */ - - /** Performs the specified Action on the object */ - public boolean doAccessibleAction(int param) { - if (param == 0) { - try { - return unoAccessibleAction.doAccessibleAction(0); - } catch (com.sun.star.uno.Exception e) { - } - } - - return false; - } - - /** Returns a description of the specified action of the object */ - public java.lang.String getAccessibleActionDescription(int param) { - return javax.swing.UIManager.getString("ComboBox.togglePopupText"); - } - - /** Returns the number of accessible actions available in this object */ - public int getAccessibleActionCount() { - return 1; - } - } - - /** - * Returns whether this Component can be focused. - * - * @return <code>true</code> if this Component is focusable; - * <code>false</code> otherwise. - * @see #setFocusable - * @since 1.4 - */ - public boolean isFocusable() { - return true; - } -} diff --git a/accessibility/bridge/org/openoffice/java/accessibility/Component.java b/accessibility/bridge/org/openoffice/java/accessibility/Component.java deleted file mode 100644 index 821d2e9e099a..000000000000 --- a/accessibility/bridge/org/openoffice/java/accessibility/Component.java +++ /dev/null @@ -1,728 +0,0 @@ -/* - * 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 . - */ - -package org.openoffice.java.accessibility; - -import java.awt.EventQueue; - -import javax.accessibility.AccessibleContext; -import javax.accessibility.AccessibleState; - -import com.sun.star.uno.*; -import com.sun.star.accessibility.*; - -public abstract class Component extends java.awt.Component { - public static final Type RectangleType = new Type(com.sun.star.awt.Rectangle.class); - public static final Type SelectionType = new Type(com.sun.star.awt.Selection.class); - - protected XAccessible unoAccessible; - protected XAccessibleContext unoAccessibleContext; - protected XAccessibleComponent unoAccessibleComponent; - - protected boolean disposed = false; - - protected Component(XAccessible xAccessible, XAccessibleContext xAccessibleContext) { - super(); - unoAccessible = xAccessible; - unoAccessibleContext = xAccessibleContext; - unoAccessibleComponent = UnoRuntime.queryInterface(XAccessibleComponent.class, xAccessibleContext); - // Add the event listener right away, because the global focus notification doesn't - // work yet .. - XAccessibleEventBroadcaster broadcaster = UnoRuntime.queryInterface(XAccessibleEventBroadcaster.class, - unoAccessibleComponent); - if (broadcaster != null) { - broadcaster.addAccessibleEventListener(createEventListener()); - } - } - - /** - * Determines whether this <code>Component</code> is showing on screen. - * This means that the component must be visible, and it must be in a - * <code>container</code> that is visible and showing. - * @see #addNotify - * @see #removeNotify - * @since JDK1.0 - */ - public boolean isShowing() { - if (isVisible()) { - java.awt.Container parent = getParent(); - return (parent == null) || parent.isShowing(); - } - return false; - } - - /** - * Makes this <code>Component</code> displayable by connecting it to a - * native screen resource. - * This method is called internally by the toolkit and should - * not be called directly by programs. - * @see #isDisplayable - * @see #removeNotify - * @since JDK1.0 - */ - public void addNotify() { - } - - /** - * Makes this <code>Component</code> undisplayable by destroying it native - * screen resource. - * This method is called by the toolkit internally and should - * not be called directly by programs. - * @see #isDisplayable - * @see #addNotify - * @since JDK1.0 - */ - public void removeNotify() { - } - - /* - * Fake the java focus handling. This is necessary to keep OOo focus - * in sync with the java focus. See java.awt.DefaultKeyboardFocusManager - * for implementation details. - **/ - - /** Requests focus for this object */ - public void requestFocus() { - } - - /** Requests focus for this object */ - public boolean requestFocus(boolean temporary) { - // Must be a no-op to make focus handling work - return true; - } - - /** Requests the focus for this object in the containing window */ - public boolean requestFocusInWindow() { - return requestFocusInWindow(false); - } - - /** Requests the focus for this object in the containing window */ - protected boolean requestFocusInWindow(boolean temporary) { - if (isFocusable() && isVisible()) { - getEventQueue().postEvent(new java.awt.event.FocusEvent(this, java.awt.event.FocusEvent.FOCUS_GAINED, temporary)); - return true; - } - return false; - } - - public Object[] getAccessibleComponents(Object[] targetSet) { - try { - java.util.ArrayList<java.awt.Component> list = new java.util.ArrayList<java.awt.Component>(targetSet.length); - for (int i=0; i < targetSet.length; i++) { - java.awt.Component c = AccessibleObjectFactory.getAccessibleComponent( - UnoRuntime.queryInterface(XAccessible.class, targetSet[i])); - if (c != null) { - list.add(c); - } - } - list.trimToSize(); - return list.toArray(); - } catch (com.sun.star.uno.RuntimeException e) { - return null; - } - } - - protected java.awt.EventQueue getEventQueue() { - return java.awt.Toolkit.getDefaultToolkit().getSystemEventQueue(); - } - - protected class PropertyChangeBroadcaster implements Runnable { - String propertyName; - Object oldValue; - Object newValue; - - public PropertyChangeBroadcaster(String name, Object param1, Object param2) { - propertyName = name; - oldValue = param1; - newValue = param2; - } - - public void run() { - // Because this code is executed in the DispatchThread, it is better to catch every - // exception that might occur - try { - AccessibleContext ac = accessibleContext; - if (ac != null) { - ac.firePropertyChange(propertyName, oldValue, newValue); - } - } catch (java.lang.Exception e) { - if (Build.DEBUG) { - System.err.println(e.getClass().getName() + " caught propagating " + propertyName + " event: " + e.getMessage()); - e.printStackTrace(); - } - } - } - } - - protected void firePropertyChange(String property, Object oldValue, Object newValue) { - EventQueue.invokeLater(new PropertyChangeBroadcaster(property, oldValue, newValue)); - } - - protected void fireStatePropertyChange(AccessibleState state, boolean set) { - PropertyChangeBroadcaster broadcaster; - -// if (Build.DEBUG) { -// System.err.println("[" + AccessibleRoleAdapter.getAccessibleRole(unoAccessibleContext.getAccessibleRole()) + "] " + -// unoAccessibleContext.getAccessibleName() + " is " + (set ? "now " : "no longer ") + state); -// } - - if (set) { - broadcaster = new PropertyChangeBroadcaster( - AccessibleContext.ACCESSIBLE_STATE_PROPERTY, - null, state); - } else { - broadcaster = new PropertyChangeBroadcaster( - AccessibleContext.ACCESSIBLE_STATE_PROPERTY, - state, null); - } - EventQueue.invokeLater(broadcaster); - } - - /** - * Update the proxy objects appropriatly on property change events - */ - protected class AccessibleUNOComponentListener implements XAccessibleEventListener { - - protected AccessibleUNOComponentListener() { - } - - protected void setComponentState(short state, boolean enable) { - switch (state) { - case AccessibleStateType.ACTIVE: - // Only frames should be active - break; - case AccessibleStateType.ARMED: - fireStatePropertyChange(AccessibleState.ARMED, enable); - break; - case AccessibleStateType.CHECKED: - fireStatePropertyChange(AccessibleState.CHECKED, enable); - break; - case AccessibleStateType.ENABLED: - setEnabled(enable); - // Since we can't access awt.Componet.accessibleContext, we need to fire - // this event manually .. - fireStatePropertyChange(AccessibleState.ENABLED, enable); - break; - case AccessibleStateType.FOCUSED: - getEventQueue().postEvent(new java.awt.event.FocusEvent( - Component.this, enable ? - java.awt.event.FocusEvent.FOCUS_GAINED : - java.awt.event.FocusEvent.FOCUS_LOST)); - break; - case AccessibleStateType.PRESSED: - fireStatePropertyChange(AccessibleState.PRESSED, enable); - break; - case AccessibleStateType.SELECTED: - fireStatePropertyChange(AccessibleState.SELECTED, enable); - break; - case AccessibleStateType.SENSITIVE: - // This state equals ENABLED in OOo (but not in Gtk+) and does not exist in Java 1.5 - break; - case AccessibleStateType.SHOWING: -// fireStatePropertyChange(AccessibleState.SHOWING, enable); - break; - case AccessibleStateType.VISIBLE: - Component.this.setVisible(enable); - break; - default: - if (Build.DEBUG) { - System.err.println("[component]: " + getName() + "unexpected state change " + state); - } - break; - } - } - - /** Updates the accessible name and fires the appropriate PropertyChangedEvent */ - protected void handleNameChangedEvent(Object any) { - try { - // This causes the property change event to be fired in the VCL thread - // context. If this causes problems, it has to be deligated to the java - // dispatch thread .. - if (accessibleContext != null) { - accessibleContext.setAccessibleName(AnyConverter.toString(any)); - } - } catch (com.sun.star.lang.IllegalArgumentException e) { - } - } - - /** Updates the accessible description and fires the appropriate PropertyChangedEvent */ - protected void handleDescriptionChangedEvent(Object any) { - try { - // This causes the property change event to be fired in the VCL thread - // context. If this causes problems, it has to be deligated to the java - // dispatch thread .. - if (accessibleContext != null) { - accessibleContext.setAccessibleDescription(AnyConverter.toString(any)); - } - } catch (com.sun.star.lang.IllegalArgumentException e) { - } - } - - /** Updates the internal states and fires the appropriate PropertyChangedEvent */ - protected void handleStateChangedEvent(Object any1, Object any2) { - try { - if (AnyConverter.isShort(any1)) { - setComponentState(AnyConverter.toShort(any1), false); - } - - if (AnyConverter.isShort(any2)) { - setComponentState(AnyConverter.toShort(any2), true); - } - } catch (com.sun.star.lang.IllegalArgumentException e) { - } - } - - /** Called by OpenOffice process to notify property changes */ - public void notifyEvent(AccessibleEventObject event) { - - if ( !disposed ) { - - switch (event.EventId) { - case AccessibleEventId.ACTION_CHANGED: - firePropertyChange(AccessibleContext.ACCESSIBLE_ACTION_PROPERTY, - toNumber(event.OldValue), toNumber(event.NewValue)); - break; - case AccessibleEventId.NAME_CHANGED: - // Set the accessible name for the corresponding context, which will fire a property - // change event itself - handleNameChangedEvent(event.NewValue); - break; - case AccessibleEventId.DESCRIPTION_CHANGED: - // Set the accessible description for the corresponding context, which will fire a property - // change event itself - so do not set propertyName ! - handleDescriptionChangedEvent(event.NewValue); - break; - case AccessibleEventId.CHILD: - if (Build.DEBUG) { - System.out.println("Unexpected child event for object of role " + getAccessibleContext().getAccessibleRole()); - } - break; - case AccessibleEventId.STATE_CHANGED: - // Update the internal state set and fire the appropriate PropertyChangedEvent - handleStateChangedEvent(event.OldValue, event.NewValue); - break; - case AccessibleEventId.VISIBLE_DATA_CHANGED: - case AccessibleEventId.BOUNDRECT_CHANGED: - firePropertyChange(AccessibleContext.ACCESSIBLE_VISIBLE_DATA_PROPERTY, null, null); - break; - case AccessibleEventId.TEXT_CHANGED: - firePropertyChange(AccessibleContext.ACCESSIBLE_TEXT_PROPERTY, - AccessibleTextImpl.convertTextSegment(event.OldValue), - AccessibleTextImpl.convertTextSegment(event.NewValue)); - break; - /* - * the Java AccessBridge for GNOME maps SELECTION_PROPERTY change events - * for objects of role TEXT to object:text-selection-changed - */ - case AccessibleEventId.TEXT_SELECTION_CHANGED: - firePropertyChange(AccessibleContext.ACCESSIBLE_SELECTION_PROPERTY, null, null); - break; - case AccessibleEventId.CARET_CHANGED: - firePropertyChange(AccessibleContext.ACCESSIBLE_CARET_PROPERTY, toNumber(event.OldValue), toNumber(event.NewValue)); - break; - case AccessibleEventId.VALUE_CHANGED: - firePropertyChange(AccessibleContext.ACCESSIBLE_VALUE_PROPERTY, toNumber(event.OldValue), toNumber(event.NewValue)); - default: - // Warn about unhandled events - if(Build.DEBUG) { - System.out.println(this + ": unhandled accessibility event id=" + event.EventId); - } - } - } - } - - /** Called by OpenOffice process to notify that the UNO component is disposing */ - public void disposing(com.sun.star.lang.EventObject eventObject) { - disposed = true; - AccessibleObjectFactory.disposing(Component.this); - } - } - - protected XAccessibleEventListener createEventListener() { - return new AccessibleUNOComponentListener(); - } - - protected javax.accessibility.AccessibleContext accessibleContext = null; - - /** This method actually creates the AccessibleContext object returned by - * getAccessibleContext(). - */ - protected javax.accessibility.AccessibleContext createAccessibleContext() { - return null; - } - - /** Returns the AccessibleContext associated with this object */ - public final javax.accessibility.AccessibleContext getAccessibleContext() { - if (accessibleContext == null) { - try { - AccessibleContext ac = createAccessibleContext(); - if (ac != null) { - // Set accessible name and description here to avoid - // unnecessary property change events later .. - ac.setAccessibleName(unoAccessibleContext.getAccessibleName()); - ac.setAccessibleDescription(unoAccessibleContext.getAccessibleDescription()); - accessibleContext = ac; - } - } catch (com.sun.star.uno.RuntimeException e) { - } - } - return accessibleContext; - } - - protected abstract class AccessibleUNOComponent extends java.awt.Component.AccessibleAWTComponent - implements javax.accessibility.AccessibleExtendedComponent { - - protected java.awt.event.ComponentListener accessibleComponentHandler = null; - - /** - * Fire PropertyChange listener, if one is registered, - * when shown/hidden.. - */ - protected class AccessibleComponentHandler implements java.awt.event.ComponentListener { - public void componentHidden(java.awt.event.ComponentEvent e) { - AccessibleUNOComponent.this.firePropertyChange( - AccessibleContext.ACCESSIBLE_STATE_PROPERTY, - AccessibleState.VISIBLE, null); - } - - public void componentShown(java.awt.event.ComponentEvent e) { - AccessibleUNOComponent.this.firePropertyChange( - AccessibleContext.ACCESSIBLE_STATE_PROPERTY, - null, AccessibleState.VISIBLE); - } - - public void componentMoved(java.awt.event.ComponentEvent e) { - } - - public void componentResized(java.awt.event.ComponentEvent e) { - } - } // inner class AccessibleComponentHandler - - protected java.awt.event.FocusListener accessibleFocusHandler = null; - - /** - * Fire PropertyChange listener, if one is registered, - * when focus events happen - */ - protected class AccessibleFocusHandler implements java.awt.event.FocusListener { - public void focusGained(java.awt.event.FocusEvent event) { - AccessibleUNOComponent.this.firePropertyChange( - AccessibleContext.ACCESSIBLE_STATE_PROPERTY, - null, AccessibleState.FOCUSED); - if (Build.DEBUG) { - System.err.println("[" + getAccessibleRole() + "] " + getAccessibleName() + " is now focused"); - } - } - public void focusLost(java.awt.event.FocusEvent event) { - AccessibleUNOComponent.this.firePropertyChange( - AccessibleContext.ACCESSIBLE_STATE_PROPERTY, - AccessibleState.FOCUSED, null); - if (Build.DEBUG) { - System.err.println("[" + getAccessibleRole() + "] " + getAccessibleName() + " is no longer focused"); - } - } - } // inner class AccessibleFocusHandler - - protected int propertyChangeListenerCount = 0; - - /** - * Add a PropertyChangeListener to the listener list. - * - * @param listener The PropertyChangeListener to be added - */ - public void addPropertyChangeListener(java.beans.PropertyChangeListener listener) { - if (propertyChangeListenerCount++ == 0) { - accessibleComponentHandler = new AccessibleComponentHandler(); - Component.this.addComponentListener(accessibleComponentHandler); - - accessibleFocusHandler = new AccessibleFocusHandler(); - Component.this.addFocusListener(accessibleFocusHandler); - } - super.addPropertyChangeListener(listener); - } - - /** - * Remove a PropertyChangeListener from the listener list. - * This removes a PropertyChangeListener that was registered - * for all properties. - * - * @param listener The PropertyChangeListener to be removed - */ - public void removePropertyChangeListener(java.beans.PropertyChangeListener listener) { - if (--propertyChangeListenerCount == 0) { - Component.this.removeComponentListener(accessibleComponentHandler); - accessibleComponentHandler = null; - - Component.this.removeFocusListener(accessibleFocusHandler); - accessibleFocusHandler = null; - } - super.removePropertyChangeListener(listener); - } - - /** - * Gets the current state set of this object. - * - * @return an instance of <code>AccessibleStateSet</code> - * containing the current state set of the object - * @see AccessibleState - */ - public javax.accessibility.AccessibleStateSet getAccessibleStateSet() { - if (disposed) - return AccessibleStateAdapter.getDefunctStateSet(); - - try { - return AccessibleStateAdapter.getAccessibleStateSet(Component.this, - unoAccessibleContext.getAccessibleStateSet()); - } catch (com.sun.star.uno.RuntimeException e) { - return AccessibleStateAdapter.getDefunctStateSet(); - } - } - - /** Gets the locale of the component */ - public java.util.Locale getLocale() throws java.awt.IllegalComponentStateException { - try { - com.sun.star.lang.Locale unoLocale = unoAccessible.getAccessibleContext().getLocale(); - return new java.util.Locale(unoLocale.Language, unoLocale.Country); - } catch (IllegalAccessibleComponentStateException e) { - throw new java.awt.IllegalComponentStateException(e.getMessage()); - } catch (com.sun.star.uno.RuntimeException e) { - return java.util.Locale.getDefault(); - } - } - - /* - * AccessibleExtendedComponent - */ - - /** Returns the background color of the object */ - public java.awt.Color getBackground() { - try { - return new java.awt.Color(unoAccessibleComponent.getBackground()); - } catch (com.sun.star.uno.RuntimeException e) { - return null; - } - } - - public void setBackground(java.awt.Color c) { - // Not supported by UNO accessibility API - } - - /** Returns the foreground color of the object */ - public java.awt.Color getForeground() { - try { - return new java.awt.Color(unoAccessibleComponent.getForeground()); - } catch (com.sun.star.uno.RuntimeException e) { - return null; - } - } - - public void setForeground(java.awt.Color c) { - // Not supported by UNO accessibility API - } - - public java.awt.Cursor getCursor() { - // Not supported by UNO accessibility API - return null; - } - - public void setCursor(java.awt.Cursor cursor) { - // Not supported by UNO accessibility API - } - - public java.awt.Font getFont() { - // FIXME - return null; - } - - public void setFont(java.awt.Font f) { - // Not supported by UNO accessibility API - } - - public java.awt.FontMetrics getFontMetrics(java.awt.Font f) { - // FIXME - return null; - } - - public boolean isEnabled() { - return Component.this.isEnabled(); - } - - public void setEnabled(boolean b) { - // Not supported by UNO accessibility API - } - - public boolean isVisible() { - return Component.this.isVisible(); - } - - public void setVisible(boolean b) { - // Not supported by UNO accessibility API - } - - public boolean isShowing() { - return Component.this.isShowing(); - } - - public boolean contains(java.awt.Point p) { - try { - return unoAccessibleComponent.containsPoint(new com.sun.star.awt.Point(p.x, p.y)); - } catch (com.sun.star.uno.RuntimeException e) { - return false; - } - } - - /** Returns the location of the object on the screen. */ - public java.awt.Point getLocationOnScreen() { - try { - com.sun.star.awt.Point unoPoint = unoAccessibleComponent.getLocationOnScreen(); -// if (Build.DEBUG) { -// System.err.println("Returning location on screen( " + unoPoint.X + ", " + unoPoint.Y + " )" ); -// } - return new java.awt.Point(unoPoint.X, unoPoint.Y); - } catch (com.sun.star.uno.RuntimeException e) { - return null; - } - } - - /** Gets the location of this component in the form of a point specifying the component's top-left corner */ - public java.awt.Point getLocation() { - try { - com.sun.star.awt.Point unoPoint = unoAccessibleComponent.getLocation(); - return new java.awt.Point( unoPoint.X, unoPoint.Y ); - } catch (com.sun.star.uno.RuntimeException e) { - return null; - } - } - - /** Moves this component to a new location */ - public void setLocation(java.awt.Point p) { - // Not supported by UNO accessibility API - } - - /** Gets the bounds of this component in the form of a Rectangle object */ - public java.awt.Rectangle getBounds() { - try { - com.sun.star.awt.Rectangle unoRect = unoAccessibleComponent.getBounds(); - return new java.awt.Rectangle(unoRect.X, unoRect.Y, unoRect.Width, unoRect.Height); - } catch (com.sun.star.uno.RuntimeException e) { - return null; - } - } - - /** Moves and resizes this component to conform to the new bounding rectangle r */ - public void setBounds(java.awt.Rectangle r) { - // Not supported by UNO accessibility API - } - - /** Returns the size of this component in the form of a Dimension object */ - public java.awt.Dimension getSize() { - try { - com.sun.star.awt.Size unoSize = unoAccessibleComponent.getSize(); - return new java.awt.Dimension(unoSize.Width, unoSize.Height); - } catch (com.sun.star.uno.RuntimeException e) { - return null; - } - } - - /** Resizes this component so that it has width d.width and height d.height */ - public void setSize(java.awt.Dimension d) { - // Not supported by UNO accessibility API - } - - public javax.accessibility.Accessible getAccessibleAt(java.awt.Point p) { - // Not supported by this implementation - return null; - } - - public boolean isFocusTraversable() { - return Component.this.isFocusable(); - } - - public void requestFocus() { - unoAccessibleComponent.grabFocus(); - } - - public String getToolTipText() { - try { - XAccessibleExtendedComponent unoAccessibleExtendedComponent = UnoRuntime.queryInterface(XAccessibleExtendedComponent.class, unoAccessibleComponent); - if (unoAccessibleExtendedComponent != null) { - return unoAccessibleExtendedComponent.getToolTipText(); - } - } catch (com.sun.star.uno.RuntimeException e) { - return null; - } - return null; - } - - public String getTitledBorderText() { - try { - XAccessibleExtendedComponent unoAccessibleExtendedComponent = UnoRuntime.queryInterface(XAccessibleExtendedComponent.class, unoAccessibleComponent); - if (unoAccessibleExtendedComponent != null) { - return unoAccessibleExtendedComponent.getTitledBorderText(); - } - } catch (com.sun.star.uno.RuntimeException e) { - return null; - } - return null; - } - - public javax.accessibility.AccessibleKeyBinding getAccessibleKeyBinding() { - try { - XAccessibleAction unoAccessibleAction = UnoRuntime.queryInterface(XAccessibleAction.class, unoAccessibleComponent); - if (unoAccessibleAction != null) { - XAccessibleKeyBinding unoAccessibleKeyBinding = unoAccessibleAction.getAccessibleActionKeyBinding(0); - if (unoAccessibleKeyBinding != null) { - return new AccessibleKeyBinding(unoAccessibleKeyBinding); - } - } - } catch (com.sun.star.lang.IndexOutOfBoundsException e) { - return null; - } catch (com.sun.star.uno.RuntimeException e) { - return null; - } - return null; - } - } - - // Extract a number from a UNO any - public static java.lang.Number toNumber(java.lang.Object any) { - try { - if (AnyConverter.isByte(any)) { - return new Byte(AnyConverter.toByte(any)); - } else if (AnyConverter.isShort(any)) { - return new Short(AnyConverter.toShort(any)); - } else if (AnyConverter.isInt(any)) { - return new Integer(AnyConverter.toInt(any)); - } else if (AnyConverter.isLong(any)) { - return new Long(AnyConverter.toLong(any)); - } else if (AnyConverter.isFloat(any)) { - return new Float(AnyConverter.toFloat(any)); - } else if (AnyConverter.isDouble(any)) { - return new Double(AnyConverter.toDouble(any)); - } - } catch (com.sun.star.lang.IllegalArgumentException e) { - throw new IllegalArgumentException(e.getMessage()); - } - return null; - } - - public String toString() { - return UnoRuntime.generateOid(unoAccessible); - } -} - diff --git a/accessibility/bridge/org/openoffice/java/accessibility/Container.java b/accessibility/bridge/org/openoffice/java/accessibility/Container.java deleted file mode 100644 index 4b447c9c2f92..000000000000 --- a/accessibility/bridge/org/openoffice/java/accessibility/Container.java +++ /dev/null @@ -1,754 +0,0 @@ -/* - * 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 . - */ - -package org.openoffice.java.accessibility; - -import java.awt.Component; -import java.awt.EventQueue; - -import javax.accessibility.AccessibleContext; -import javax.accessibility.AccessibleState; - -import com.sun.star.uno.*; -import com.sun.star.accessibility.*; - -public class Container extends java.awt.Container implements javax.accessibility.Accessible { - - protected XAccessible unoAccessible; - protected XAccessibleContext unoAccessibleContext; - protected XAccessibleComponent unoAccessibleComponent = null; - - protected javax.accessibility.AccessibleRole accessibleRole; - protected javax.accessibility.AccessibleText accessibleText; - protected boolean disposed = false; - - protected Container(javax.accessibility.AccessibleRole role, - XAccessible xAccessible, XAccessibleContext xAccessibleContext) { - accessibleRole = role; - unoAccessible = xAccessible; - unoAccessibleContext = xAccessibleContext; - unoAccessibleComponent = UnoRuntime.queryInterface(XAccessibleComponent.class, - xAccessibleContext); - - // Add the event listener right away, because the global focus notification doesn't - // work yet .. - XAccessibleEventBroadcaster broadcaster = UnoRuntime.queryInterface(XAccessibleEventBroadcaster.class, - unoAccessibleContext); - if (broadcaster != null) { - broadcaster.addAccessibleEventListener(createEventListener()); - } - } - - /** - * Determines whether this <code>Container</code> is showing on screen. - * This means that the component must be visible, and it must be in a - * <code>container</code> that is visible and showing. - * @see #addNotify - * @see #removeNotify - * @since JDK1.0 - */ - public boolean isShowing() { - if (isVisible()) { - java.awt.Container parent = getParent(); - return (parent == null) || parent.isShowing(); - } - return false; - } - - /** - * Makes this <code>Container</code> displayable by connecting it to a - * native screen resource. - * This method is called internally by the toolkit and should - * not be called directly by programs. - * @see #isDisplayable - * @see #removeNotify - * @since JDK1.0 - */ - public void addNotify() { - } - - /** - * Makes this <code>Container</code> undisplayable by destroying it native - * screen resource. - * This method is called by the toolkit internally and should - * not be called directly by programs. - * @see #isDisplayable - * @see #addNotify - * @since JDK1.0 - */ - public void removeNotify() { - } - - /* - * Fake the java focus handling. This is necessary to keep OOo focus - * in sync with the java focus. See java.awt.DefaultKeyboardFocusManager - * for implementation details. - **/ - - /** Requests focus for this object */ - public void requestFocus() { - } - - /** Requests focus for this object */ - public boolean requestFocus(boolean temporary) { - // Must be a no-op to make focus handling work - return true; - } - - /** Requests the focus for this object in the containing window */ - public boolean requestFocusInWindow() { - return requestFocusInWindow(false); - } - - /** Requests the focus for this object in the containing window */ - protected boolean requestFocusInWindow(boolean temporary) { - if (isFocusable() && isVisible()) { - getEventQueue().postEvent(new java.awt.event.FocusEvent(this, java.awt.event.FocusEvent.FOCUS_GAINED, temporary)); - return true; - } - return false; - } - - public Object[] getAccessibleComponents(Object[] targetSet) { - try { - java.util.ArrayList<Component> list = new java.util.ArrayList<Component>(targetSet.length); - for (int i=0; i < targetSet.length; i++) { - java.awt.Component c = AccessibleObjectFactory.getAccessibleComponent( - UnoRuntime.queryInterface(XAccessible.class, targetSet[i])); - if (c != null) { - list.add(c); - } - } - list.trimToSize(); - return list.toArray(); - } catch (com.sun.star.uno.RuntimeException e) { - return null; - } - } - - protected java.awt.EventQueue getEventQueue() { - return java.awt.Toolkit.getDefaultToolkit().getSystemEventQueue(); - } - - protected class PropertyChangeBroadcaster implements Runnable { - String propertyName; - Object oldValue; - Object newValue; - - public PropertyChangeBroadcaster(String name, Object param1, Object param2) { - propertyName = name; - oldValue = param1; - newValue = param2; - } - - public void run() { - // Because this code is executed in the DispatchThread, it is better tocatch every - // exception that might occur - try { - AccessibleContext ac = Container.this.accessibleContext; - if (ac != null) { - ac.firePropertyChange(propertyName, oldValue, newValue); - } - } catch (java.lang.Exception e) { - if (Build.DEBUG) { - System.err.println(e.getClass().getName() + " caught propagating " + propertyName + " event: " + e.getMessage()); - e.printStackTrace(); - } - } - } - } - - protected void firePropertyChange(String property, Object oldValue, Object newValue) { - EventQueue.invokeLater(new PropertyChangeBroadcaster(property, oldValue, newValue)); - } - - protected void fireStatePropertyChange(AccessibleState state, boolean set) { - PropertyChangeBroadcaster broadcaster; - if (set) { - broadcaster = new PropertyChangeBroadcaster( - AccessibleContext.ACCESSIBLE_STATE_PROPERTY, - null, state); - } else { - broadcaster = new PropertyChangeBroadcaster( - AccessibleContext.ACCESSIBLE_STATE_PROPERTY, - state, null); - } - EventQueue.invokeLater(broadcaster); - } - - /** - * Update the proxy objects appropriatly on property change events - */ - protected class AccessibleContainerListener implements XAccessibleEventListener { - - protected AccessibleContainerListener() { - } - - protected java.awt.EventQueue getEventQueue() { - return java.awt.Toolkit.getDefaultToolkit().getSystemEventQueue(); - } - - protected void setComponentState(short state, boolean enable) { - switch (state) { - case AccessibleStateType.ACTIVE: - // Only frames should be active - break; - case AccessibleStateType.ENABLED: - setEnabled(enable); - // Since we can't access awt.Componet.accessibleContext, we need to fire - // this event manually .. - fireStatePropertyChange(AccessibleState.ENABLED, enable); - break; - case AccessibleStateType.FOCUSED: - getEventQueue().postEvent(new java.awt.event.FocusEvent( - Container.this, enable ? - java.awt.event.FocusEvent.FOCUS_GAINED : - java.awt.event.FocusEvent.FOCUS_LOST)); - break; - case AccessibleStateType.SELECTED: - fireStatePropertyChange(AccessibleState.SELECTED, enable); - break; - case AccessibleStateType.SENSITIVE: - // This state equals ENABLED in OOo (but not in Gtk+) and does not exist in Java 1.5 - break; - case AccessibleStateType.SHOWING: - case AccessibleStateType.VISIBLE: - setVisible(enable); - break; - default: - if (Build.DEBUG) { - System.err.println(Container.this + "unexpected state change " + state); - } - break; - } - } - /** Updates the accessible name and fires the appropriate PropertyChangedEvent */ - protected void handleNameChangedEvent(Object any) { - try { - // This causes the property change event to be fired in the VCL thread - // context. If this causes problems, it has to be deligated to the java - // dispatch thread .. - if (accessibleContext != null) { - accessibleContext.setAccessibleName(AnyConverter.toString(any)); - } - } catch (com.sun.star.lang.IllegalArgumentException e) { - } - } - - /** Updates the accessible description and fires the appropriate PropertyChangedEvent */ - protected void handleDescriptionChangedEvent(Object any) { - try { - // This causes the property change event to be fired in the VCL thread - // context. If this causes problems, it has to be deligated to the java - // dispatch thread .. - if (accessibleContext != null) { - accessibleContext.setAccessibleDescription(AnyConverter.toString(any)); - } - } catch (com.sun.star.lang.IllegalArgumentException e) { - } - } - - /** Updates the internal states and fires the appropriate PropertyChangedEvent */ - protected void handleStateChangedEvent(Object any1, Object any2) { - try { - if (AnyConverter.isShort(any1)) { - setComponentState(AnyConverter.toShort(any1), false); - } - - if (AnyConverter.isShort(any2)) { - setComponentState(AnyConverter.toShort(any2), true); - } - } catch (com.sun.star.lang.IllegalArgumentException e) { - } - } - - /* This event is only necessary because some objects in the office don't know their parent - * and are therefor unable to revoke and re-insert themselves. - */ - protected void handleAllChildrenChangedEvent() { - javax.accessibility.Accessible parent = (javax.accessibility.Accessible) getParent(); - if (parent != null) { - javax.accessibility.AccessibleContext parentAC = parent.getAccessibleContext(); - if (parentAC != null) { - - parentAC.firePropertyChange( - javax.accessibility.AccessibleContext.ACCESSIBLE_CHILD_PROPERTY, - Container.this, - null); - - AccessibleObjectFactory.clearContainer(Container.this); - AccessibleObjectFactory.populateContainer(Container.this, unoAccessibleContext); - - parentAC.firePropertyChange( - javax.accessibility.AccessibleContext.ACCESSIBLE_CHILD_PROPERTY, - null, - Container.this); - } - } - } - - /** Called by OpenOffice process to notify property changes */ - public void notifyEvent(AccessibleEventObject event) { - - if ( !disposed ) { - - switch (event.EventId) { - case AccessibleEventId.NAME_CHANGED: - // Set the accessible name for the corresponding context, which will fire a property - // change event itself - handleNameChangedEvent(event.NewValue); - break; - case AccessibleEventId.DESCRIPTION_CHANGED: - // Set the accessible description for the corresponding context, which will fire a property - // change event itself - so do not set propertyName ! - handleDescriptionChangedEvent(event.NewValue); - break; - case AccessibleEventId.STATE_CHANGED: - // Update the internal state set and fire the appropriate PropertyChangedEvent - handleStateChangedEvent(event.OldValue, event.NewValue); - break; - case AccessibleEventId.TEXT_CHANGED: - firePropertyChange(AccessibleContext.ACCESSIBLE_TEXT_PROPERTY, - AccessibleTextImpl.convertTextSegment(event.OldValue), - AccessibleTextImpl.convertTextSegment(event.NewValue)); - break; - case AccessibleEventId.CHILD: - if (AnyConverter.isObject(event.OldValue)) { - AccessibleObjectFactory.removeChild(Container.this, event.OldValue); - } else if (AnyConverter.isObject(event.NewValue)) { - AccessibleObjectFactory.addChild(Container.this, event.NewValue); - } - break; - case AccessibleEventId.VISIBLE_DATA_CHANGED: - case AccessibleEventId.BOUNDRECT_CHANGED: - firePropertyChange(AccessibleContext.ACCESSIBLE_VISIBLE_DATA_PROPERTY, null, null); - break; - /* - * the Java AccessBridge for GNOME maps SELECTION_PROPERTY change events - * for objects of role TEXT to object:text-selection-changed - */ - case AccessibleEventId.TEXT_SELECTION_CHANGED: - case AccessibleEventId.SELECTION_CHANGED: - firePropertyChange(AccessibleContext.ACCESSIBLE_SELECTION_PROPERTY, null, null); - break; - case AccessibleEventId.INVALIDATE_ALL_CHILDREN: - handleAllChildrenChangedEvent(); - break; - default: - // Warn about unhandled events - if(Build.DEBUG) { - System.out.println(this + ": unhandled accessibility event id=" + event.EventId); - } - } - } - } - - /** Called by OpenOffice process to notify that the UNO component is disposing */ - public void disposing(com.sun.star.lang.EventObject eventObject) { - disposed = true; - AccessibleObjectFactory.disposing(Container.this); - } - } - - protected XAccessibleEventListener createEventListener() { - return new AccessibleContainerListener(); - } - - protected javax.accessibility.AccessibleContext accessibleContext = null; - - /** This method actually creates the AccessibleContext object returned by - * getAccessibleContext(). - */ - protected javax.accessibility.AccessibleContext createAccessibleContext() { - return new AccessibleContainer(); - } - - /** Returns the AccessibleContext associated with this object */ - public final javax.accessibility.AccessibleContext getAccessibleContext() { - if (accessibleContext == null) { - try { - AccessibleContext ac = createAccessibleContext(); - if (ac != null) { - // Set accessible name and description here to avoid - // unnecessary property change events later .. - ac.setAccessibleName(unoAccessibleContext.getAccessibleName()); - ac.setAccessibleDescription(unoAccessibleContext.getAccessibleDescription()); - accessibleContext = ac; - } - } catch (com.sun.star.uno.RuntimeException e) { - } - } - return accessibleContext; - } - - protected class AccessibleContainer extends java.awt.Container.AccessibleAWTContainer { - - protected AccessibleContainer() { - /* Since getAccessibleText() is heavily used by the java access - * bridge for gnome and the gnome at-tools, we do a query interface - * here and remember the result. - */ - accessibleText = AccessibleTextImpl.get(unoAccessibleContext); - } - - protected AccessibleContainer(boolean query) { - /* This constructor is explicitly for subclasses that implement - * AccessibleHypertext and therefor the default constructor would - * bring unnecessary overhead. - */ - } - - protected java.awt.event.ComponentListener accessibleComponentHandler = null; - - /** - * Fire PropertyChange listener, if one is registered, - * when shown/hidden.. - */ - protected class AccessibleComponentHandler implements java.awt.event.ComponentListener { - public void componentHidden(java.awt.event.ComponentEvent e) { - AccessibleContainer.this.firePropertyChange( - AccessibleContext.ACCESSIBLE_STATE_PROPERTY, - AccessibleState.VISIBLE, null); - } - - public void componentShown(java.awt.event.ComponentEvent e) { - AccessibleContainer.this.firePropertyChange( - AccessibleContext.ACCESSIBLE_STATE_PROPERTY, - null, AccessibleState.VISIBLE); - } - - public void componentMoved(java.awt.event.ComponentEvent e) { - } - - public void componentResized(java.awt.event.ComponentEvent e) { - } - } // inner class AccessibleContainerHandler - - protected java.awt.event.FocusListener accessibleFocusHandler = null; - - /** - * Fire PropertyChange listener, if one is registered, - * when focus events happen - */ - protected class AccessibleFocusHandler implements java.awt.event.FocusListener { - public void focusGained(java.awt.event.FocusEvent event) { - AccessibleContainer.this.firePropertyChange( - AccessibleContext.ACCESSIBLE_STATE_PROPERTY, - null, AccessibleState.FOCUSED); - if (Build.DEBUG) { - System.err.println("[" + getAccessibleRole() + "] " + getAccessibleName() + " is now focused"); - } - } - public void focusLost(java.awt.event.FocusEvent event) { - AccessibleContainer.this.firePropertyChange( - AccessibleContext.ACCESSIBLE_STATE_PROPERTY, - AccessibleState.FOCUSED, null); - if (Build.DEBUG) { - System.err.println("[" + getAccessibleRole() + "] " + getAccessibleName() + " is no longer focused"); - } - } - } // inner class AccessibleFocusHandler - - protected java.awt.event.ContainerListener accessibleContainerHandler = null; - - /** - * Fire PropertyChange listener, if one is registered, - * when children added/removed. - */ - - protected class AccessibleContainerHandler implements java.awt.event.ContainerListener { - public void componentAdded(java.awt.event.ContainerEvent e) { - java.awt.Component c = e.getChild(); - if (c != null && c instanceof javax.accessibility.Accessible) { - AccessibleContainer.this.firePropertyChange( - AccessibleContext.ACCESSIBLE_CHILD_PROPERTY, - null, ((javax.accessibility.Accessible) c).getAccessibleContext()); - } - } - public void componentRemoved(java.awt.event.ContainerEvent e) { - java.awt.Component c = e.getChild(); - if (c != null && c instanceof javax.accessibility.Accessible) { - AccessibleContainer.this.firePropertyChange( - AccessibleContext.ACCESSIBLE_CHILD_PROPERTY, - ((javax.accessibility.Accessible) c).getAccessibleContext(), null); - } - } - } - - protected int propertyChangeListenerCount = 0; - - /** - * Add a PropertyChangeListener to the listener list. - * - * @param listener The PropertyChangeListener to be added - */ - public void addPropertyChangeListener(java.beans.PropertyChangeListener listener) { - if (propertyChangeListenerCount++ == 0) { - accessibleFocusHandler = new AccessibleFocusHandler(); - Container.this.addFocusListener(accessibleFocusHandler); - - accessibleContainerHandler = new AccessibleContainerHandler(); - Container.this.addContainerListener(accessibleContainerHandler); - - accessibleComponentHandler = new AccessibleComponentHandler(); - Container.this.addComponentListener(accessibleComponentHandler); - } - super.addPropertyChangeListener(listener); - } - - /** - * Remove a PropertyChangeListener from the listener list. - * This removes a PropertyChangeListener that was registered - * for all properties. - * - * @param listener The PropertyChangeListener to be removed - */ - public void removePropertyChangeListener(java.beans.PropertyChangeListener listener) { - if (--propertyChangeListenerCount == 0) { - Container.this.removeComponentListener(accessibleComponentHandler); - accessibleComponentHandler = null; - - Container.this.removeContainerListener(accessibleContainerHandler); - accessibleContainerHandler = null; - - Container.this.removeFocusListener(accessibleFocusHandler); - accessibleFocusHandler = null; - } - super.removePropertyChangeListener(listener); - } - - /** Gets the role of this object */ - public javax.accessibility.AccessibleRole getAccessibleRole() { - return accessibleRole; - } - - /** Gets the AccessibleText associated with this object presenting text on the display */ - public javax.accessibility.AccessibleText getAccessibleText() { - - if (disposed) - return null; - - return accessibleText; - } - - /** - * Gets the current state set of this object. - * - * @return an instance of <code>AccessibleStateSet</code> - * containing the current state set of the object - * @see AccessibleState - */ - public javax.accessibility.AccessibleStateSet getAccessibleStateSet() { - if (disposed) - return AccessibleStateAdapter.getDefunctStateSet(); - - try { - return AccessibleStateAdapter.getAccessibleStateSet(Container.this, - unoAccessibleContext.getAccessibleStateSet()); - } catch (com.sun.star.uno.RuntimeException e) { - return AccessibleStateAdapter.getDefunctStateSet(); - } - } - - /** Returns the AccessibleSelection interface for this object */ - public javax.accessibility.AccessibleSelection getAccessibleSelection() { - try { - XAccessibleSelection unoAccessibleSelection = UnoRuntime.queryInterface(XAccessibleSelection.class, unoAccessibleContext); - if (unoAccessibleSelection != null) { - return new AccessibleSelectionImpl(unoAccessibleSelection); - } - } catch (com.sun.star.uno.RuntimeException e) { - } - - return null; - } - - /** Gets the locale of the component */ - public java.util.Locale getLocale() throws java.awt.IllegalComponentStateException { - try { - com.sun.star.lang.Locale unoLocale = unoAccessible.getAccessibleContext().getLocale(); - return new java.util.Locale(unoLocale.Language, unoLocale.Country); - } catch (IllegalAccessibleComponentStateException e) { - throw new java.awt.IllegalComponentStateException(e.getMessage()); - } catch (com.sun.star.uno.RuntimeException e) { - return super.getLocale(); - } - } - - /* - * AccessibleComponent - */ - - /** Returns the background color of the object */ - public java.awt.Color getBackground() { - try { - return new java.awt.Color(unoAccessibleComponent.getBackground()); - } catch (com.sun.star.uno.RuntimeException e) { - return null; - } - } - - public void setBackground(java.awt.Color c) { - // Not supported by UNO accessibility API - } - - /** Returns the foreground color of the object */ - public java.awt.Color getForeground() { - try { - return new java.awt.Color(unoAccessibleComponent.getForeground()); - } catch (com.sun.star.uno.RuntimeException e) { - return null; - } - } - - public void setForeground(java.awt.Color c) { - // Not supported by UNO accessibility API - } - - public java.awt.Cursor getCursor() { - // Not supported by UNO accessibility API - return null; - } - - public void setCursor(java.awt.Cursor cursor) { - // Not supported by UNO accessibility API - } - - public java.awt.Font getFont() { - // FIXME - return null; - } - - public void setFont(java.awt.Font f) { - // Not supported by UNO accessibility API - } - - public java.awt.FontMetrics getFontMetrics(java.awt.Font f) { - // FIXME - return null; - } - - public boolean isEnabled() { - return Container.this.isEnabled(); - } - - public void setEnabled(boolean b) { - // Not supported by UNO accessibility API - } - - public boolean isVisible() { - return Container.this.isVisible(); - } - - public void setVisible(boolean b) { - // Not supported by UNO accessibility API - } - - public boolean isShowing() { - return Container.this.isShowing(); - } - - public boolean contains(java.awt.Point p) { - try { - return unoAccessibleComponent.containsPoint(new com.sun.star.awt.Point(p.x, p.y)); - } catch (com.sun.star.uno.RuntimeException e) { - return false; - } - } - - /** Returns the location of the object on the screen. */ - public java.awt.Point getLocationOnScreen() { - try { - com.sun.star.awt.Point unoPoint = unoAccessibleComponent.getLocationOnScreen(); - return new java.awt.Point(unoPoint.X, unoPoint.Y); - } catch (com.sun.star.uno.RuntimeException e) { - return null; - } - } - - /** Gets the location of this component in the form of a point specifying the component's top-left corner */ - public java.awt.Point getLocation() { - try { - com.sun.star.awt.Point unoPoint = unoAccessibleComponent.getLocation(); - return new java.awt.Point( unoPoint.X, unoPoint.Y ); - } catch (com.sun.star.uno.RuntimeException e) { - return null; - } - } - - /** Moves this component to a new location */ - public void setLocation(java.awt.Point p) { - // Not supported by UNO accessibility API - } - - /** Gets the bounds of this component in the form of a Rectangle object */ - public java.awt.Rectangle getBounds() { - try { - com.sun.star.awt.Rectangle unoRect = unoAccessibleComponent.getBounds(); - return new java.awt.Rectangle(unoRect.X, unoRect.Y, unoRect.Width, unoRect.Height); - } catch (com.sun.star.uno.RuntimeException e) { - return null; - } - } - - /** Moves and resizes this component to conform to the new bounding rectangle r */ - public void setBounds(java.awt.Rectangle r) { - // Not supported by UNO accessibility API - } - - /** Returns the size of this component in the form of a Dimension object */ - public java.awt.Dimension getSize() { - try { - com.sun.star.awt.Size unoSize = unoAccessibleComponent.getSize(); - return new java.awt.Dimension(unoSize.Width, unoSize.Height); - } catch (com.sun.star.uno.RuntimeException e) { - return null; - } - } - - /** Resizes this component so that it has width d.width and height d.height */ - public void setSize(java.awt.Dimension d) { - // Not supported by UNO accessibility API - } - - /** Returns the Accessible child, if one exists, contained at the local coordinate Point */ - public javax.accessibility.Accessible getAccessibleAt(java.awt.Point p) { - try { - java.awt.Component c = AccessibleObjectFactory.getAccessibleComponent( - unoAccessibleComponent.getAccessibleAtPoint(new com.sun.star.awt.Point(p.x, p.y))); - - return (javax.accessibility.Accessible) c; - } catch (com.sun.star.uno.RuntimeException e) { - return null; - } - } - - public boolean isFocusTraversable() { - return Container.this.isFocusable(); - } - - public void requestFocus() { - unoAccessibleComponent.grabFocus(); - } - } - - public String toString() { - return UnoRuntime.generateOid(unoAccessible); - } -} - diff --git a/accessibility/bridge/org/openoffice/java/accessibility/DescendantManager.java b/accessibility/bridge/org/openoffice/java/accessibility/DescendantManager.java deleted file mode 100644 index 4e0aaaf1787a..000000000000 --- a/accessibility/bridge/org/openoffice/java/accessibility/DescendantManager.java +++ /dev/null @@ -1,149 +0,0 @@ -/* - * 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 . - */ -package org.openoffice.java.accessibility; - -import com.sun.star.accessibility.*; -import com.sun.star.uno.UnoRuntime; - - -public abstract class DescendantManager extends Component { - protected XAccessibleSelection unoAccessibleSelection = null; - protected javax.accessibility.Accessible activeDescendant = null; - protected boolean multiselectable = false; - - protected DescendantManager(XAccessible xAccessible, - XAccessibleContext xAccessibleContext) { - super(xAccessible, xAccessibleContext); - } - - protected DescendantManager(XAccessible xAccessible, - XAccessibleContext xAccessibleContext, boolean multiselectable) { - super(xAccessible, xAccessibleContext); - this.multiselectable = multiselectable; - } - - /** - * Update the proxy objects appropriatly on property change events - */ - protected class AccessibleDescendantManagerListener - extends AccessibleUNOComponentListener { - protected AccessibleDescendantManagerListener() { - unoAccessibleSelection = UnoRuntime.queryInterface(XAccessibleSelection.class, - unoAccessibleContext); - } - - /** Called by OpenOffice process to notify property changes */ - public void notifyEvent(AccessibleEventObject event) { - switch (event.EventId) { - case AccessibleEventId.SELECTION_CHANGED: - firePropertyChange(javax.accessibility.AccessibleContext.ACCESSIBLE_SELECTION_PROPERTY, - null, null); - - break; - - default: - super.notifyEvent(event); - } - } - } - - protected abstract class AccessibleDescendantManager - extends AccessibleUNOComponent - implements javax.accessibility.AccessibleSelection { - protected AccessibleDescendantManager() { - unoAccessibleSelection = UnoRuntime.queryInterface(XAccessibleSelection.class, - unoAccessibleContext); - } - - /* - * AccessibleContext - */ - - /** Returns the number of accessible children of the object */ - public int getAccessibleChildrenCount() { - try { - return unoAccessibleContext.getAccessibleChildCount(); - } catch (com.sun.star.uno.RuntimeException e) { - return 0; - } - } - - /** Returns the AccessibleSelection interface for this object */ - public javax.accessibility.AccessibleSelection getAccessibleSelection() { - return (unoAccessibleSelection != null) ? this : null; - } - - /* - * AccessibleSelection - */ - - /** Adds the specified Accessible child of the object to the object's selection */ - public void addAccessibleSelection(int i) { - try { - unoAccessibleSelection.selectAccessibleChild(i); - } catch (com.sun.star.lang.IndexOutOfBoundsException e) { - } catch (com.sun.star.uno.RuntimeException e) { - } - } - - /** Clears the selection in the object, so that no children in the object are selected */ - public void clearAccessibleSelection() { - try { - unoAccessibleSelection.clearAccessibleSelection(); - } catch (com.sun.star.uno.RuntimeException e) { - } - } - - /** Returns the number of Accessible children currently selected */ - public int getAccessibleSelectionCount() { - try { - return unoAccessibleSelection.getSelectedAccessibleChildCount(); - } catch (com.sun.star.uno.RuntimeException e) { - return 0; - } - } - - /** Determines if the current child of this object is selected */ - public boolean isAccessibleChildSelected(int i) { - try { - return unoAccessibleSelection.isAccessibleChildSelected(i); - } catch (com.sun.star.lang.IndexOutOfBoundsException e) { - return false; - } catch (com.sun.star.uno.RuntimeException e) { - return false; - } - } - - /** Removes the specified child of the object from the object's selection */ - public void removeAccessibleSelection(int i) { - try { - unoAccessibleSelection.deselectAccessibleChild(i); - } catch (com.sun.star.lang.IndexOutOfBoundsException e) { - } catch (com.sun.star.uno.RuntimeException e) { - } - } - - /** Causes every child of the object to be selected if the object supports multiple selection */ - public void selectAllAccessibleSelection() { - try { - unoAccessibleSelection.selectAllAccessibleChildren(); - } catch (com.sun.star.uno.RuntimeException e) { - } - } - } -} diff --git a/accessibility/bridge/org/openoffice/java/accessibility/Dialog.java b/accessibility/bridge/org/openoffice/java/accessibility/Dialog.java deleted file mode 100644 index a9b2d51a42de..000000000000 --- a/accessibility/bridge/org/openoffice/java/accessibility/Dialog.java +++ /dev/null @@ -1,642 +0,0 @@ -/* - * 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 . - */ - -package org.openoffice.java.accessibility; - -import com.sun.star.uno.*; -import com.sun.star.accessibility.*; - -public class Dialog extends java.awt.Dialog implements javax.accessibility.Accessible, NativeFrame { - protected XAccessibleComponent unoAccessibleComponent; - - boolean opened = false; - boolean visible = false; - boolean active = false; - - java.awt.EventQueue eventQueue = null; - - protected Dialog(java.awt.Frame owner, XAccessibleComponent xAccessibleComponent) { - super(owner); - initialize(xAccessibleComponent); - } - - protected Dialog(java.awt.Frame owner, String name, XAccessibleComponent xAccessibleComponent) { - super(owner, name); - initialize(xAccessibleComponent); - } - - protected Dialog(java.awt.Frame owner, String name, boolean modal, XAccessibleComponent xAccessibleComponent) { - super(owner, name, modal); - initialize(xAccessibleComponent); - } - - private void initialize(XAccessibleComponent xAccessibleComponent) { - unoAccessibleComponent = xAccessibleComponent; - eventQueue = java.awt.Toolkit.getDefaultToolkit().getSystemEventQueue(); - XAccessibleEventBroadcaster broadcaster = UnoRuntime.queryInterface(XAccessibleEventBroadcaster.class, - xAccessibleComponent); - if (broadcaster != null) { - broadcaster.addAccessibleEventListener(new AccessibleDialogListener()); - } - } - - java.awt.Component initialComponent = null; - - public java.awt.Component getInitialComponent() { - return initialComponent; - } - - public void setInitialComponent(java.awt.Component c) { - initialComponent = c; - } - - public Integer getHWND() { - return null; - } - - /** - * Determines whether this <code>Component</code> is showing on screen. - * This means that the component must be visible, and it must be in a - * <code>container</code> that is visible and showing. - * @see #addNotify - * @see #removeNotify - * @since JDK1.0 - */ - public boolean isShowing() { - if (isVisible()) { - java.awt.Container parent = getParent(); - return (parent == null) || parent.isShowing(); - } - return false; - } - - /** - * Makes this <code>Component</code> displayable by connecting it to a - * native screen resource. - * This method is called internally by the toolkit and should - * not be called directly by programs. - * @see #isDisplayable - * @see #removeNotify - * @since JDK1.0 - */ - public void addNotify() { -// createHierarchyEvents(0, null, null, 0, false); - } - - /** - * Makes this <code>Component</code> undisplayable by destroying it native - * screen resource. - * This method is called by the toolkit internally and should - * not be called directly by programs. - * @see #isDisplayable - * @see #addNotify - * @since JDK1.0 - */ - public void removeNotify() { - } - - /** - * Determines if the object is visible. Note: this means that the - * object intends to be visible; however, it may not in fact be - * showing on the screen because one of the objects that this object - * is contained by is not visible. To determine if an object is - * showing on the screen, use <code>isShowing</code>. - * - * @return true if object is visible; otherwise, false - */ - public boolean isVisible(){ - return visible; - } - - /** - * Determines whether this component is displayable. A component is - * displayable when it is connected to a native screen resource. - * <p> - * A component is made displayable either when it is added to - * a displayable containment hierarchy or when its containment - * hierarchy is made displayable. - * A containment hierarchy is made displayable when its ancestor - * window is either packed or made visible. - * <p> - * A component is made undisplayable either when it is removed from - * a displayable containment hierarchy or when its containment hierarchy - * is made undisplayable. A containment hierarchy is made - * undisplayable when its ancestor window is disposed. - * - * @return <code>true</code> if the component is displayable - */ - public boolean isDisplayable() { - return true; - } - - /** - * Shows or hides this component depending on the value of parameter - * <code>b</code>. - * @param b if <code>true</code>, shows this component; - * otherwise, hides this component - * @see #isVisible - * @since JDK1.1 - */ - public void setVisible(boolean b) { - if (visible != b){ - visible = b; - if (b) { - // If it is the first show, fire WINDOW_OPENED event - if (!opened) { - postWindowEvent(java.awt.event.WindowEvent.WINDOW_OPENED); - opened = true; - } - postComponentEvent(java.awt.event.ComponentEvent.COMPONENT_SHOWN); - } else { - postComponentEvent(java.awt.event.ComponentEvent.COMPONENT_HIDDEN); - } - } - } - - public void dispose() { - setVisible(false); - postWindowEvent(java.awt.event.WindowEvent.WINDOW_CLOSED); - } - - protected void postWindowEvent(int i) { - eventQueue.postEvent(new java.awt.event.WindowEvent(this, i)); - } - - protected void postComponentEvent(int i) { - eventQueue.postEvent(new java.awt.event.ComponentEvent(this, i)); - } - - /** - * Update the proxy objects appropriatly on property change events - */ - protected class AccessibleDialogListener implements XAccessibleEventListener { - - protected AccessibleDialogListener() { - } - - protected void setComponentState(short state, boolean enable) { - switch (state) { - case AccessibleStateType.ACTIVE: - active = enable; - if (enable) { - AccessibleObjectFactory.postWindowActivated(Dialog.this); - } else { - AccessibleObjectFactory.postWindowLostFocus(Dialog.this); - } - break; - case AccessibleStateType.ICONIFIED: - postWindowEvent(enable ? - java.awt.event.WindowEvent.WINDOW_ICONIFIED : - java.awt.event.WindowEvent.WINDOW_DEICONIFIED); - break; - case AccessibleStateType.VISIBLE: - Dialog.this.setVisible(enable); - break; - default: - if (Build.DEBUG) { - System.err.println("[dialog]: " + getTitle() + "unexpected state change " + state); - } - break; - } - } - - /** Updates the accessible name and fires the appropriate PropertyChangedEvent */ - protected void handleNameChangedEvent(Object any) { - try { - String title = AnyConverter.toString(any); - setTitle(title); - // This causes the property change event to be fired in the VCL thread - // context. If this causes problems, it has to be deligated to the java - // dispatch thread .. - javax.accessibility.AccessibleContext ac = accessibleContext; - if (ac!= null) { - ac.setAccessibleName(title); - } - } catch (com.sun.star.lang.IllegalArgumentException e) { - } - } - - /** Updates the accessible description and fires the appropriate PropertyChangedEvent */ - protected void handleDescriptionChangedEvent(Object any) { - try { - // This causes the property change event to be fired in the VCL thread - // context. If this causes problems, it has to be deligated to the java - // dispatch thread .. - javax.accessibility.AccessibleContext ac = accessibleContext; - if (ac!= null) { - ac.setAccessibleDescription(AnyConverter.toString(any)); - } - } catch (com.sun.star.lang.IllegalArgumentException e) { - } - } - - /** Updates the internal states and fires the appropriate PropertyChangedEvent */ - protected void handleStateChangedEvent(Object any1, Object any2) { - try { - if (AnyConverter.isShort(any1)) { - setComponentState(AnyConverter.toShort(any1), false); - } - - if (AnyConverter.isShort(any2)) { - setComponentState(AnyConverter.toShort(any2), true); - } - } catch (com.sun.star.lang.IllegalArgumentException e) { - } - } - - /** Fires a visible data property change event */ - protected void handleVisibleDataEvent() { - javax.accessibility.AccessibleContext ac = accessibleContext; - if (ac != null) { - ac.firePropertyChange(javax.accessibility.AccessibleContext.ACCESSIBLE_VISIBLE_DATA_PROPERTY, null, null); - } - } - - /** Called by OpenOffice process to notify property changes */ - public void notifyEvent(AccessibleEventObject event) { - switch (event.EventId) { - case AccessibleEventId.NAME_CHANGED: - // Set the accessible name for the corresponding context, which will fire a property - // change event itself - handleNameChangedEvent(event.NewValue); - break; - case AccessibleEventId.DESCRIPTION_CHANGED: - // Set the accessible description for the corresponding context, which will fire a property - // change event itself - so do not set propertyName ! - handleDescriptionChangedEvent(event.NewValue); - break; - case AccessibleEventId.STATE_CHANGED: - // Update the internal state set and fire the appropriate PropertyChangedEvent - handleStateChangedEvent(event.OldValue, event.NewValue); - break; - case AccessibleEventId.CHILD: - if (AnyConverter.isObject(event.OldValue)) { - AccessibleObjectFactory.removeChild(Dialog.this, event.OldValue); - } else if (AnyConverter.isObject(event.NewValue)) { - AccessibleObjectFactory.addChild(Dialog.this, event.NewValue); - } - break; - case AccessibleEventId.VISIBLE_DATA_CHANGED: - case AccessibleEventId.BOUNDRECT_CHANGED: - handleVisibleDataEvent(); - break; - default: - // Warn about unhandled events - if(Build.DEBUG) { - System.out.println(this + ": unhandled accessibility event id=" + event.EventId); - } - } - } - - /** Called by OpenOffice process to notify that the UNO component is disposing */ - public void disposing(com.sun.star.lang.EventObject eventObject) { - } - } - - javax.accessibility.AccessibleContext accessibleContext = null; - - /** Returns the AccessibleContext associated with this object */ - public javax.accessibility.AccessibleContext getAccessibleContext() { - if (accessibleContext == null) { - accessibleContext = new AccessibleDialog(); - accessibleContext.setAccessibleName(getTitle()); - } - return accessibleContext; - } - - protected class AccessibleDialog extends java.awt.Dialog.AccessibleAWTDialog { - protected AccessibleDialog() { - super(); - } - - protected java.awt.event.ComponentListener accessibleComponentHandler = null; - - /** - * Fire PropertyChange listener, if one is registered, - * when shown/hidden.. - */ - protected class AccessibleComponentHandler implements java.awt.event.ComponentListener { - public void componentHidden(java.awt.event.ComponentEvent e) { - AccessibleDialog.this.firePropertyChange( - javax.accessibility.AccessibleContext.ACCESSIBLE_STATE_PROPERTY, - javax.accessibility.AccessibleState.VISIBLE, null); - } - - public void componentShown(java.awt.event.ComponentEvent e) { - AccessibleDialog.this.firePropertyChange( - javax.accessibility.AccessibleContext.ACCESSIBLE_STATE_PROPERTY, - null, javax.accessibility.AccessibleState.VISIBLE); - } - - public void componentMoved(java.awt.event.ComponentEvent e) { - } - - public void componentResized(java.awt.event.ComponentEvent e) { - } - } // inner class AccessibleComponentHandler - - protected java.awt.event.WindowListener accessibleWindowHandler = null; - - /** - * Fire PropertyChange listener, if one is registered, - * when window events happen - */ - protected class AccessibleWindowHandler implements java.awt.event.WindowListener { - /** Invoked when the Window is set to be the active Window. */ - public void windowActivated(java.awt.event.WindowEvent e) { - AccessibleDialog.this.firePropertyChange( - javax.accessibility.AccessibleContext.ACCESSIBLE_STATE_PROPERTY, - null, javax.accessibility.AccessibleState.ACTIVE); - if (Build.DEBUG) { - System.err.println("[Dialog] " + getTitle() + " is now active"); - } - } - - /** Invoked when a window has been closed as the result of calling dispose on the window. */ - public void windowClosed(java.awt.event.WindowEvent e) { - if (Build.DEBUG) { - System.err.println("[Dialog] " + getTitle() + " has been closed"); - } - } - - /** Invoked when the user attempts to close the window from the window's system menu. */ - public void windowClosing(java.awt.event.WindowEvent e) { - if (Build.DEBUG) { - System.err.println("[Dialog] " + getTitle() + " is closing"); - } - } - - /** Invoked when a Window is no longer the active Window. */ - public void windowDeactivated(java.awt.event.WindowEvent e) { - AccessibleDialog.this.firePropertyChange( - javax.accessibility.AccessibleContext.ACCESSIBLE_STATE_PROPERTY, - javax.accessibility.AccessibleState.ACTIVE, null); - if (Build.DEBUG) { - System.err.println("[Dialog] " + getTitle() + " is no longer active"); - } - } - - /** Invoked when a window is changed from a minimized to a normal state. */ - public void windowDeiconified(java.awt.event.WindowEvent e) { - if (Build.DEBUG) { - System.err.println("[Dialog] " + getTitle() + " has been deiconified"); - } - } - - /** Invoked when a window is changed from a normal to a minimized state. */ - public void windowIconified(java.awt.event.WindowEvent e) { - if (Build.DEBUG) { - System.err.println("[Dialog] " + getTitle() + " has been iconified"); - } - } - - /** Invoked the first time a window is made visible. */ - public void windowOpened(java.awt.event.WindowEvent e) { - if (Build.DEBUG) { - System.err.println("[Dialog] " + getTitle() + " has been opened"); - } - } - - } // inner class AccessibleWindowHandler - - protected java.awt.event.ContainerListener accessibleContainerHandler = null; - - /** - * Fire PropertyChange listener, if one is registered, - * when children added/removed. - */ - - protected class AccessibleContainerHandler implements java.awt.event.ContainerListener { - public void componentAdded(java.awt.event.ContainerEvent e) { - java.awt.Component c = e.getChild(); - if (c != null && c instanceof javax.accessibility.Accessible) { - AccessibleDialog.this.firePropertyChange( - javax.accessibility.AccessibleContext.ACCESSIBLE_CHILD_PROPERTY, - null, ((javax.accessibility.Accessible) c).getAccessibleContext()); - } - } - public void componentRemoved(java.awt.event.ContainerEvent e) { - java.awt.Component c = e.getChild(); - if (c != null && c instanceof javax.accessibility.Accessible) { - AccessibleDialog.this.firePropertyChange( - javax.accessibility.AccessibleContext.ACCESSIBLE_CHILD_PROPERTY, - ((javax.accessibility.Accessible) c).getAccessibleContext(), null); - } - } - } - - protected int propertyChangeListenerCount = 0; - - /** - * Add a PropertyChangeListener to the listener list. - * - * @param listener The PropertyChangeListener to be added - */ - public void addPropertyChangeListener(java.beans.PropertyChangeListener listener) { - if (propertyChangeListenerCount++ == 0) { - accessibleWindowHandler = new AccessibleWindowHandler(); - Dialog.this.addWindowListener(accessibleWindowHandler); - - accessibleContainerHandler = new AccessibleContainerHandler(); - Dialog.this.addContainerListener(accessibleContainerHandler); - - accessibleComponentHandler = new AccessibleComponentHandler(); - Dialog.this.addComponentListener(accessibleComponentHandler); - } - super.addPropertyChangeListener(listener); - } - - /** - * Remove a PropertyChangeListener from the listener list. - * This removes a PropertyChangeListener that was registered - * for all properties. - * - * @param listener The PropertyChangeListener to be removed - */ - public void removePropertyChangeListener(java.beans.PropertyChangeListener listener) { - if (--propertyChangeListenerCount == 0) { - Dialog.this.removeComponentListener(accessibleComponentHandler); - accessibleComponentHandler = null; - - Dialog.this.removeContainerListener(accessibleContainerHandler); - accessibleContainerHandler = null; - - Dialog.this.removeWindowListener(accessibleWindowHandler); - accessibleWindowHandler = null; - } - super.removePropertyChangeListener(listener); - } - - /* - * AccessibleComponent - */ - - /** Returns the background color of the object */ - public java.awt.Color getBackground() { - try { - return new java.awt.Color(unoAccessibleComponent.getBackground()); - } catch (com.sun.star.uno.RuntimeException e) { - return null; - } - } - - public void setBackground(java.awt.Color c) { - // Not supported by UNO accessibility API - } - - /** Returns the foreground color of the object */ - public java.awt.Color getForeground() { - try { - return new java.awt.Color(unoAccessibleComponent.getForeground()); - } catch (com.sun.star.uno.RuntimeException e) { - return null; - } - } - - public void setForeground(java.awt.Color c) { - // Not supported by UNO accessibility API - } - - public java.awt.Cursor getCursor() { - // Not supported by UNO accessibility API - return null; - } - - public void setCursor(java.awt.Cursor cursor) { - // Not supported by UNO accessibility API - } - - public java.awt.Font getFont() { - // FIXME - return null; - } - - public void setFont(java.awt.Font f) { - // Not supported by UNO accessibility API - } - - public java.awt.FontMetrics getFontMetrics(java.awt.Font f) { - // FIXME - return null; - } - - public boolean isEnabled() { - return Dialog.this.isEnabled(); - } - - public void setEnabled(boolean b) { - // Not supported by UNO accessibility API - } - - public boolean isVisible() { - return Dialog.this.isVisible(); - } - - public void setVisible(boolean b) { - // Not supported by UNO accessibility API - } - - public boolean isShowing() { - return Dialog.this.isShowing(); - } - - public boolean contains(java.awt.Point p) { - try { - return unoAccessibleComponent.containsPoint(new com.sun.star.awt.Point(p.x, p.y)); - } catch (com.sun.star.uno.RuntimeException e) { - return false; - } - } - - /** Returns the location of the object on the screen. */ - public java.awt.Point getLocationOnScreen() { - try { - com.sun.star.awt.Point unoPoint = unoAccessibleComponent.getLocationOnScreen(); - return new java.awt.Point(unoPoint.X, unoPoint.Y); - } catch (com.sun.star.uno.RuntimeException e) { - return null; - } - } - - /** Gets the location of this component in the form of a point specifying the component's top-left corner */ - public java.awt.Point getLocation() { - try { - com.sun.star.awt.Point unoPoint = unoAccessibleComponent.getLocation(); - return new java.awt.Point( unoPoint.X, unoPoint.Y ); - } catch (com.sun.star.uno.RuntimeException e) { - return null; - } - } - - /** Moves this component to a new location */ - public void setLocation(java.awt.Point p) { - // Not supported by UNO accessibility API - } - - /** Gets the bounds of this component in the form of a Rectangle object */ - public java.awt.Rectangle getBounds() { - try { - com.sun.star.awt.Rectangle unoRect = unoAccessibleComponent.getBounds(); - return new java.awt.Rectangle(unoRect.X, unoRect.Y, unoRect.Width, unoRect.Height); - } catch (com.sun.star.uno.RuntimeException e) { - return null; - } - } - - /** Moves and resizes this component to conform to the new bounding rectangle r */ - public void setBounds(java.awt.Rectangle r) { - // Not supported by UNO accessibility API - } - - /** Returns the size of this component in the form of a Dimension object */ - public java.awt.Dimension getSize() { - try { - com.sun.star.awt.Size unoSize = unoAccessibleComponent.getSize(); - return new java.awt.Dimension(unoSize.Width, unoSize.Height); - } catch (com.sun.star.uno.RuntimeException e) { - return null; - } - } - - /** Resizes this component so that it has width d.width and height d.height */ - public void setSize(java.awt.Dimension d) { - // Not supported by UNO accessibility API - } - - /** Returns the Accessible child, if one exists, contained at the local coordinate Point */ - public javax.accessibility.Accessible getAccessibleAt(java.awt.Point p) { - try { - java.awt.Component c = AccessibleObjectFactory.getAccessibleComponent( - unoAccessibleComponent.getAccessibleAtPoint(new com.sun.star.awt.Point(p.x, p.y))); - - return (javax.accessibility.Accessible) c; - } catch (com.sun.star.uno.RuntimeException e) { - return null; - } - } - - public boolean isFocusTraversable() { - return Dialog.this.isFocusable(); - } - - public void requestFocus() { - unoAccessibleComponent.grabFocus(); - } - } -} - diff --git a/accessibility/bridge/org/openoffice/java/accessibility/FocusTraversalPolicy.java b/accessibility/bridge/org/openoffice/java/accessibility/FocusTraversalPolicy.java deleted file mode 100644 index 5da2803fab45..000000000000 --- a/accessibility/bridge/org/openoffice/java/accessibility/FocusTraversalPolicy.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * 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 . - */ - -package org.openoffice.java.accessibility; - - -public class FocusTraversalPolicy extends java.awt.FocusTraversalPolicy { - - protected javax.accessibility.Accessible getSelectedAccessibleChild(javax.accessibility.Accessible a) { - javax.accessibility.AccessibleContext ac = a.getAccessibleContext(); - if (ac != null) { - javax.accessibility.AccessibleSelection as = ac.getAccessibleSelection(); - if (as != null) { - return as.getAccessibleSelection(0); - } - } - return null; - } - - /** Returns the Component that should receive the focus after aComponent */ - public java.awt.Component getComponentAfter(java.awt.Container focusCycleRoot, - java.awt.Component aComponent) { - return null; - } - - /** Returns the Component that should receive the focus before aComponent */ - public java.awt.Component getComponentBefore(java.awt.Container focusCycleRoot, - java.awt.Component aComponent) { - return null; - } - - /** Returns the default Component to focus */ - public java.awt.Component getDefaultComponent(java.awt.Container focusCycleRoot) { - // getDefaultComponent must not return null for Windows to make them focusable. - if (focusCycleRoot instanceof NativeFrame) { - java.awt.Component c = ((NativeFrame) focusCycleRoot).getInitialComponent(); - if (c != null) { - return c; - } - } - - if (focusCycleRoot instanceof javax.accessibility.Accessible) { - return (java.awt.Component) getSelectedAccessibleChild((javax.accessibility.Accessible) focusCycleRoot); - } - return null; - } - - /** Returns the first Component in the traversal cycle */ - public java.awt.Component getFirstComponent(java.awt.Container focusCycleRoot) { - return null; - } - - /** Returns the Component that should receive the focus when a Window is made visible for the first time */ - public java.awt.Component getInitialComponent(java.awt.Window window) { - if (window instanceof NativeFrame) { - return ((NativeFrame) window).getInitialComponent(); - } - return null; - } - - /** Returns the last Component in the traversal cycle */ - public java.awt.Component getLastComponent(java.awt.Container focusCycleRoot) { - return null; - } -} diff --git a/accessibility/bridge/org/openoffice/java/accessibility/Frame.java b/accessibility/bridge/org/openoffice/java/accessibility/Frame.java deleted file mode 100644 index fe927cbc1670..000000000000 --- a/accessibility/bridge/org/openoffice/java/accessibility/Frame.java +++ /dev/null @@ -1,659 +0,0 @@ -/* - * 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 . - */ - -package org.openoffice.java.accessibility; - -import com.sun.star.uno.*; -import com.sun.star.accessibility.*; - -public class Frame extends java.awt.Frame implements javax.accessibility.Accessible, NativeFrame { - protected XAccessibleComponent unoAccessibleComponent; - - boolean opened = false; - boolean visible = false; - boolean active = false; - - java.awt.EventQueue eventQueue = null; - - protected Frame(XAccessibleComponent xAccessibleComponent) { - initialize(xAccessibleComponent); - } - - protected Frame(String name, XAccessibleComponent xAccessibleComponent) { - super(name); - initialize(xAccessibleComponent); - } - - private void initialize(XAccessibleComponent xAccessibleComponent) { - unoAccessibleComponent = xAccessibleComponent; - eventQueue = java.awt.Toolkit.getDefaultToolkit().getSystemEventQueue(); - XAccessibleEventBroadcaster broadcaster = UnoRuntime.queryInterface(XAccessibleEventBroadcaster.class, - unoAccessibleComponent); - if (broadcaster != null) { - broadcaster.addAccessibleEventListener(new AccessibleFrameListener()); - } - } - - java.awt.Component initialComponent = null; - - public java.awt.Component getInitialComponent() { - return initialComponent; - } - - public void setInitialComponent(java.awt.Component c) { - initialComponent = c; - } - - public Integer getHWND() { - return null; - } - - /** - * Determines whether this <code>Component</code> is showing on screen. - * This means that the component must be visible, and it must be in a - * <code>container</code> that is visible and showing. - * @see #addNotify - * @see #removeNotify - * @since JDK1.0 - */ - public boolean isShowing() { - if (isVisible()) { - java.awt.Container parent = getParent(); - return (parent == null) || parent.isShowing(); - } - return false; - } - - /** - * Makes this <code>Component</code> displayable by connecting it to a - * native screen resource. - * This method is called internally by the toolkit and should - * not be called directly by programs. - * @see #isDisplayable - * @see #removeNotify - * @since JDK1.0 - */ - public void addNotify() { -// createHierarchyEvents(0, null, null, 0, false); - } - - /** - * Makes this <code>Component</code> undisplayable by destroying it native - * screen resource. - * This method is called by the toolkit internally and should - * not be called directly by programs. - * @see #isDisplayable - * @see #addNotify - * @since JDK1.0 - */ - public void removeNotify() { - } - - /** - * Determines if the object is visible. Note: this means that the - * object intends to be visible; however, it may not in fact be - * showing on the screen because one of the objects that this object - * is contained by is not visible. To determine if an object is - * showing on the screen, use <code>isShowing</code>. - * - * @return true if object is visible; otherwise, false - */ - public boolean isVisible(){ - return visible; - } - - /** - * Shows or hides this component depending on the value of parameter - * <code>b</code>. - * @param b if <code>true</code>, shows this component; - * otherwise, hides this component - * @see #isVisible - * @since JDK1.1 - */ - public void setVisible(boolean b) { - if (visible != b){ - visible = b; - if (b) { - // If it is the first show, fire WINDOW_OPENED event - if (!opened) { - postWindowEvent(java.awt.event.WindowEvent.WINDOW_OPENED); - opened = true; - } - postComponentEvent(java.awt.event.ComponentEvent.COMPONENT_SHOWN); - } else { - postComponentEvent(java.awt.event.ComponentEvent.COMPONENT_HIDDEN); - } - } - } - - public void dispose() { - setVisible(false); - postWindowEvent(java.awt.event.WindowEvent.WINDOW_CLOSED); - } - - protected void postWindowEvent(int i) { - eventQueue.postEvent(new java.awt.event.WindowEvent(this, i)); - } - - protected void postComponentEvent(int i) { - eventQueue.postEvent(new java.awt.event.ComponentEvent(this, i)); - } - - /** - * Update the proxy objects appropriatly on property change events - */ - protected class AccessibleFrameListener implements XAccessibleEventListener { - - protected AccessibleFrameListener() { - } - - // The only expected state changes are ACTIVE and VISIBLE - protected void setComponentState(short state, boolean enable) { - switch (state) { - case AccessibleStateType.ACTIVE: - active = enable; - if (enable) { - AccessibleObjectFactory.postWindowActivated(Frame.this); - } else { - AccessibleObjectFactory.postWindowLostFocus(Frame.this); - } - break; - case AccessibleStateType.ICONIFIED: - if (Build.DEBUG) { - System.err.println("[frame]" + getTitle() + (enable ? " is now " : " is no longer ") + "iconified"); - } - postWindowEvent(enable ? - java.awt.event.WindowEvent.WINDOW_ICONIFIED : - java.awt.event.WindowEvent.WINDOW_DEICONIFIED); - break; - case AccessibleStateType.VISIBLE: - Frame.this.setVisible(enable); - break; - default: - if (Build.DEBUG) { - System.err.println("[frame]: " + getTitle() + "unexpected state change " + state); - } - break; - } - } - - /** Updates the accessible name and fires the appropriate PropertyChangedEvent */ - protected void handleNameChangedEvent(Object any) { - try { - String title = AnyConverter.toString(any); - setTitle(title); - // This causes the property change event to be fired in the VCL thread - // context. If this causes problems, it has to be deligated to the java - // dispatch thread .. - javax.accessibility.AccessibleContext ac = accessibleContext; - if (ac!= null) { - ac.setAccessibleName(title); - } - } catch (com.sun.star.lang.IllegalArgumentException e) { - } - } - - /** Updates the accessible description and fires the appropriate PropertyChangedEvent */ - protected void handleDescriptionChangedEvent(Object any) { - try { - // This causes the property change event to be fired in the VCL thread - // context. If this causes problems, it has to be deligated to the java - // dispatch thread .. - javax.accessibility.AccessibleContext ac = accessibleContext; - if (ac!= null) { - ac.setAccessibleDescription(AnyConverter.toString(any)); - } - } catch (com.sun.star.lang.IllegalArgumentException e) { - } - } - - /** Updates the internal states and fires the appropriate PropertyChangedEvent */ - protected void handleStateChangedEvent(Object any1, Object any2) { - try { - if (AnyConverter.isShort(any1)) { - setComponentState(AnyConverter.toShort(any1), false); - } - - if (AnyConverter.isShort(any2)) { - setComponentState(AnyConverter.toShort(any2), true); - } - } - - catch (com.sun.star.lang.IllegalArgumentException e) { - } - } - - /** Fires a visible data property change event */ - protected void handleVisibleDataEvent() { - javax.accessibility.AccessibleContext ac = accessibleContext; - if (ac != null) { - ac.firePropertyChange(javax.accessibility.AccessibleContext.ACCESSIBLE_VISIBLE_DATA_PROPERTY, null, null); - } - } - - /** Called by OpenOffice process to notify property changes */ - public void notifyEvent(AccessibleEventObject event) { - switch (event.EventId) { - case AccessibleEventId.NAME_CHANGED: - // Set the accessible name for the corresponding context, which will fire a property - // change event itself - handleNameChangedEvent(event.NewValue); - break; - case AccessibleEventId.DESCRIPTION_CHANGED: - // Set the accessible description for the corresponding context, which will fire a property - // change event itself - so do not set propertyName ! - handleDescriptionChangedEvent(event.NewValue); - break; - case AccessibleEventId.STATE_CHANGED: - // Update the internal state set and fire the appropriate PropertyChangedEvent - handleStateChangedEvent(event.OldValue, event.NewValue); - break; - case AccessibleEventId.CHILD: - if (AnyConverter.isObject(event.OldValue)) { - AccessibleObjectFactory.removeChild(Frame.this, event.OldValue); - } else if (AnyConverter.isObject(event.NewValue)) { - AccessibleObjectFactory.addChild(Frame.this, event.NewValue); - } - break; - case AccessibleEventId.VISIBLE_DATA_CHANGED: - case AccessibleEventId.BOUNDRECT_CHANGED: - handleVisibleDataEvent(); - break; - default: - // Warn about unhandled events - if(Build.DEBUG) { - System.out.println(this + ": unhandled accessibility event id=" + event.EventId); - } - } - } - - /** Called by OpenOffice process to notify that the UNO component is disposing */ - public void disposing(com.sun.star.lang.EventObject eventObject) { - } - } - - protected javax.accessibility.AccessibleContext accessibleContext = null; - - /** Returns the AccessibleContext associated with this object */ - public javax.accessibility.AccessibleContext getAccessibleContext() { - if (accessibleContext == null) { - accessibleContext = new AccessibleFrame(); - accessibleContext.setAccessibleName(getTitle()); - } - return accessibleContext; - } - - protected class AccessibleFrame extends java.awt.Frame.AccessibleAWTFrame { - protected AccessibleFrame() { - super(); - } - - protected java.awt.event.ComponentListener accessibleComponentHandler = null; - - /** - * Fire PropertyChange listener, if one is registered, - * when shown/hidden.. - */ - protected class AccessibleComponentHandler implements java.awt.event.ComponentListener { - public void componentHidden(java.awt.event.ComponentEvent e) { - AccessibleFrame.this.firePropertyChange( - javax.accessibility.AccessibleContext.ACCESSIBLE_STATE_PROPERTY, - javax.accessibility.AccessibleState.VISIBLE, null); - } - - public void componentShown(java.awt.event.ComponentEvent e) { - AccessibleFrame.this.firePropertyChange( - javax.accessibility.AccessibleContext.ACCESSIBLE_STATE_PROPERTY, - null, javax.accessibility.AccessibleState.VISIBLE); - } - - public void componentMoved(java.awt.event.ComponentEvent e) { - } - - public void componentResized(java.awt.event.ComponentEvent e) { - } - } // inner class AccessibleComponentHandler - - protected java.awt.event.WindowListener accessibleWindowHandler = null; - - /** - * Fire PropertyChange listener, if one is registered, - * when window events happen - */ - protected class AccessibleWindowHandler implements java.awt.event.WindowListener { - /** Invoked when the Window is set to be the active Window. */ - public void windowActivated(java.awt.event.WindowEvent e) { - AccessibleFrame.this.firePropertyChange( - javax.accessibility.AccessibleContext.ACCESSIBLE_STATE_PROPERTY, - null, javax.accessibility.AccessibleState.ACTIVE); - if (Build.DEBUG) { - System.err.println("[frame] " + getTitle() + " is now active"); - } - } - - /** Invoked when a window has been closed as the result of calling dispose on the window. */ - public void windowClosed(java.awt.event.WindowEvent e) { - if (Build.DEBUG) { - System.err.println("[frame] " + getTitle() + " has been closed"); - } - } - - /** Invoked when the user attempts to close the window from the window's system menu. */ - public void windowClosing(java.awt.event.WindowEvent e) { - if (Build.DEBUG) { - System.err.println("[frame] " + getTitle() + " is closing"); - } - } - - /** Invoked when a Window is no longer the active Window. */ - public void windowDeactivated(java.awt.event.WindowEvent e) { - AccessibleFrame.this.firePropertyChange( - javax.accessibility.AccessibleContext.ACCESSIBLE_STATE_PROPERTY, - javax.accessibility.AccessibleState.ACTIVE, null); - if (Build.DEBUG) { - System.err.println("[frame] " + getTitle() + " is no longer active"); - } - } - - /** Invoked when a window is changed from a minimized to a normal state. */ - public void windowDeiconified(java.awt.event.WindowEvent e) { - if (Build.DEBUG) { - System.err.println("[frame] " + getTitle() + " is no longer iconified"); - } - } - - /** Invoked when a window is changed from a normal to a minimized state. */ - public void windowIconified(java.awt.event.WindowEvent e) { - if (Build.DEBUG) { - System.err.println("[frame] " + getTitle() + " has been iconified"); - } - } - - /** Invoked the first time a window is made visible. */ - public void windowOpened(java.awt.event.WindowEvent e) { - if (Build.DEBUG) { - System.err.println("[frame] " + getTitle() + " has been opened"); - } - } - - } // inner class AccessibleWindowHandler - - protected java.awt.event.ContainerListener accessibleContainerHandler = null; - - /** - * Fire PropertyChange listener, if one is registered, - * when children added/removed. - */ - - protected class AccessibleContainerHandler implements java.awt.event.ContainerListener { - public void componentAdded(java.awt.event.ContainerEvent e) { - java.awt.Component c = e.getChild(); - if (c != null && c instanceof javax.accessibility.Accessible) { - AccessibleFrame.this.firePropertyChange( - javax.accessibility.AccessibleContext.ACCESSIBLE_CHILD_PROPERTY, - null, ((javax.accessibility.Accessible) c).getAccessibleContext()); - } - } - public void componentRemoved(java.awt.event.ContainerEvent e) { - java.awt.Component c = e.getChild(); - if (c != null && c instanceof javax.accessibility.Accessible) { - AccessibleFrame.this.firePropertyChange( - javax.accessibility.AccessibleContext.ACCESSIBLE_CHILD_PROPERTY, - ((javax.accessibility.Accessible) c).getAccessibleContext(), null); - } - } - } - - protected int propertyChangeListenerCount = 0; - - /** - * Add a PropertyChangeListener to the listener list. - * - * @param listener The PropertyChangeListener to be added - */ - public void addPropertyChangeListener(java.beans.PropertyChangeListener listener) { - if (propertyChangeListenerCount++ == 0) { - accessibleWindowHandler = new AccessibleWindowHandler(); - Frame.this.addWindowListener(accessibleWindowHandler); - - accessibleContainerHandler = new AccessibleContainerHandler(); - Frame.this.addContainerListener(accessibleContainerHandler); - - accessibleComponentHandler = new AccessibleComponentHandler(); - Frame.this.addComponentListener(accessibleComponentHandler); - } - super.addPropertyChangeListener(listener); - } - - /** - * Remove a PropertyChangeListener from the listener list. - * This removes a PropertyChangeListener that was registered - * for all properties. - * - * @param listener The PropertyChangeListener to be removed - */ - public void removePropertyChangeListener(java.beans.PropertyChangeListener listener) { - if (--propertyChangeListenerCount == 0) { - Frame.this.removeComponentListener(accessibleComponentHandler); - accessibleComponentHandler = null; - - Frame.this.removeContainerListener(accessibleContainerHandler); - accessibleContainerHandler = null; - - Frame.this.removeWindowListener(accessibleWindowHandler); - accessibleWindowHandler = null; - } - super.removePropertyChangeListener(listener); - } - - /** - * Get the state set of this object. - * - * @return an instance of AccessibleState containing the current state - * of the object - * @see javax.accessibility.AccessibleState - */ - public javax.accessibility.AccessibleStateSet getAccessibleStateSet() { - javax.accessibility.AccessibleStateSet states = super.getAccessibleStateSet(); - if ((getExtendedState() & java.awt.Frame.ICONIFIED) > 0) { - states.add(javax.accessibility.AccessibleState.ICONIFIED); - } - return states; - } - - /* - * AccessibleComponent - */ - - /** Returns the background color of the object */ - public java.awt.Color getBackground() { - try { - return new java.awt.Color(unoAccessibleComponent.getBackground()); - } catch (com.sun.star.uno.RuntimeException e) { - return null; - } - } - - public void setBackground(java.awt.Color c) { - // Not supported by UNO accessibility API - } - - /** Returns the foreground color of the object */ - public java.awt.Color getForeground() { - try { - return new java.awt.Color(unoAccessibleComponent.getForeground()); - } catch (com.sun.star.uno.RuntimeException e) { - return null; - } - } - - public void setForeground(java.awt.Color c) { - // Not supported by UNO accessibility API - } - - public java.awt.Cursor getCursor() { - // Not supported by UNO accessibility API - return null; - } - - public void setCursor(java.awt.Cursor cursor) { - // Not supported by UNO accessibility API - } - - public java.awt.Font getFont() { - // FIXME - return null; - } - - public void setFont(java.awt.Font f) { - // Not supported by UNO accessibility API - } - - public java.awt.FontMetrics getFontMetrics(java.awt.Font f) { - // FIXME - return null; - } - - public boolean isEnabled() { - return Frame.this.isEnabled(); - } - - public void setEnabled(boolean b) { - // Not supported by UNO accessibility API - } - - public boolean isVisible() { - return Frame.this.isVisible(); - } - - public void setVisible(boolean b) { - // Not supported by UNO accessibility API - } - - public boolean isShowing() { - return Frame.this.isShowing(); - } - - public boolean contains(java.awt.Point p) { - try { - return unoAccessibleComponent.containsPoint(new com.sun.star.awt.Point(p.x, p.y)); - } catch (com.sun.star.uno.RuntimeException e) { - return false; - } - } - - /** Returns the location of the object on the screen. */ - public java.awt.Point getLocationOnScreen() { - try { - com.sun.star.awt.Point unoPoint = unoAccessibleComponent.getLocationOnScreen(); - return new java.awt.Point(unoPoint.X, unoPoint.Y); - } catch (com.sun.star.uno.RuntimeException e) { - return null; - } - } - - /** Gets the location of this component in the form of a point specifying the component's top-left corner */ - public java.awt.Point getLocation() { - try { - com.sun.star.awt.Point unoPoint = unoAccessibleComponent.getLocation(); - return new java.awt.Point( unoPoint.X, unoPoint.Y ); - } catch (com.sun.star.uno.RuntimeException e) { - return null; - } - } - - /** Moves this component to a new location */ - public void setLocation(java.awt.Point p) { - // Not supported by UNO accessibility API - } - - /** Gets the bounds of this component in the form of a Rectangle object */ - public java.awt.Rectangle getBounds() { - try { - com.sun.star.awt.Rectangle unoRect = unoAccessibleComponent.getBounds(); - return new java.awt.Rectangle(unoRect.X, unoRect.Y, unoRect.Width, unoRect.Height); - } catch (com.sun.star.uno.RuntimeException e) { - return null; - } - } - - /** Moves and resizes this component to conform to the new bounding rectangle r */ - public void setBounds(java.awt.Rectangle r) { - // Not supported by UNO accessibility API - } - - /** Returns the size of this component in the form of a Dimension object */ - public java.awt.Dimension getSize() { - try { - com.sun.star.awt.Size unoSize = unoAccessibleComponent.getSize(); - return new java.awt.Dimension(unoSize.Width, unoSize.Height); - } catch (com.sun.star.uno.RuntimeException e) { - return null; - } - } - - /** Resizes this component so that it has width d.width and height d.height */ - public void setSize(java.awt.Dimension d) { - // Not supported by UNO accessibility API - } - - /** Returns the Accessible child, if one exists, contained at the local coordinate Point */ - public javax.accessibility.Accessible getAccessibleAt(java.awt.Point p) { - try { - java.awt.Component c = AccessibleObjectFactory.getAccessibleComponent( - unoAccessibleComponent.getAccessibleAtPoint(new com.sun.star.awt.Point(p.x, p.y))); - - return (javax.accessibility.Accessible) c; - } catch (com.sun.star.uno.RuntimeException e) { - return null; - } - } - - public boolean isFocusTraversable() { - return Frame.this.isFocusable(); - } - - public void requestFocus() { - unoAccessibleComponent.grabFocus(); - } - } - - /** - * Determines whether this component is displayable. A component is - * displayable when it is connected to a native screen resource. - * <p> - * A component is made displayable either when it is added to - * a displayable containment hierarchy or when its containment - * hierarchy is made displayable. - * A containment hierarchy is made displayable when its ancestor - * window is either packed or made visible. - * <p> - * A component is made undisplayable either when it is removed from - * a displayable containment hierarchy or when its containment hierarchy - * is made undisplayable. A containment hierarchy is made - * undisplayable when its ancestor window is disposed. - * - * @return <code>true</code> if the component is displayable - */ - @Override - public boolean isDisplayable() { - return true; - } - -} - diff --git a/accessibility/bridge/org/openoffice/java/accessibility/Icon.java b/accessibility/bridge/org/openoffice/java/accessibility/Icon.java deleted file mode 100644 index 9889fa39091c..000000000000 --- a/accessibility/bridge/org/openoffice/java/accessibility/Icon.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * 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 . - */ -package org.openoffice.java.accessibility; - -import com.sun.star.accessibility.*; -import com.sun.star.uno.*; - - -/** - */ -public class Icon extends Component implements javax.accessibility.Accessible { - protected Icon(XAccessible xAccessible, XAccessibleContext xAccessibleContext) { - super(xAccessible, xAccessibleContext); - } - - /** Creates the AccessibleContext associated with this object */ - public javax.accessibility.AccessibleContext createAccessibleContext() { - return new AccessibleIcon(); - } - - protected class AccessibleIcon extends AccessibleUNOComponent { - /** - * Though the class is abstract, this should be called by all sub-classes - */ - protected AccessibleIcon() { - super(); - } - - /** Gets the AccessibleText associated with this object presenting text on the display */ - public javax.accessibility.AccessibleIcon[] getAccessibleIcon() { - try { - XAccessibleImage unoAccessibleImage = UnoRuntime.queryInterface(XAccessibleImage.class, - unoAccessibleComponent); - - if (unoAccessibleImage != null) { - javax.accessibility.AccessibleIcon[] icons = { - new AccessibleIconImpl(unoAccessibleImage) - }; - - return icons; - } - } catch (com.sun.star.uno.RuntimeException e) { - } - - return null; - } - - } -} diff --git a/accessibility/bridge/org/openoffice/java/accessibility/Label.java b/accessibility/bridge/org/openoffice/java/accessibility/Label.java deleted file mode 100644 index 70e0628e9180..000000000000 --- a/accessibility/bridge/org/openoffice/java/accessibility/Label.java +++ /dev/null @@ -1,118 +0,0 @@ -/* - * 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 . - */ -package org.openoffice.java.accessibility; - -import com.sun.star.accessibility.*; -import com.sun.star.uno.*; - - -/** - */ -public class Label extends Component implements javax.accessibility.Accessible { - protected Label(XAccessible xAccessible, XAccessibleContext xAccessibleContext) { - super(xAccessible, xAccessibleContext); - } - - /** Creates the AccessibleContext associated with this object */ - public javax.accessibility.AccessibleContext createAccessibleContext() { - return new AccessibleLabel(); - } - - protected class AccessibleLabel extends AccessibleUNOComponent { - /** - * Though the class is abstract, this should be called by all sub-classes - */ - protected AccessibleLabel() { - super(); - } - - /* - * AccessibleContext - */ - - /** Gets the role of this object */ - public javax.accessibility.AccessibleRole getAccessibleRole() { - return javax.accessibility.AccessibleRole.LABEL; - } - - /** Gets the AccessibleText associated with this object presenting text on the display */ - public javax.accessibility.AccessibleText getAccessibleText() { - - if (disposed) - return null; - - try { - XAccessibleText unoAccessibleText = UnoRuntime.queryInterface(XAccessibleText.class, - unoAccessibleContext); - - if (unoAccessibleText != null) { - return new AccessibleTextImpl(unoAccessibleText); - } else { - return null; - } - } catch (com.sun.star.uno.RuntimeException e) { - return null; - } - } - - /** Returns the relation set of this object */ - public javax.accessibility.AccessibleRelationSet getAccessibleRelationSet() { - try { - XAccessibleRelationSet unoAccessibleRelationSet = unoAccessibleContext.getAccessibleRelationSet(); - - if (unoAccessibleRelationSet == null) { - return null; - } - - javax.accessibility.AccessibleRelationSet relationSet = new javax.accessibility.AccessibleRelationSet(); - int count = unoAccessibleRelationSet.getRelationCount(); - - for (int i = 0; i < count; i++) { - AccessibleRelation unoAccessibleRelation = unoAccessibleRelationSet.getRelation(i); - - switch (unoAccessibleRelation.RelationType) { - case AccessibleRelationType.LABEL_FOR: - relationSet.add(new javax.accessibility.AccessibleRelation( - javax.accessibility.AccessibleRelation.LABEL_FOR, - getAccessibleComponents( - unoAccessibleRelation.TargetSet))); - - break; - - case AccessibleRelationType.MEMBER_OF: - relationSet.add(new javax.accessibility.AccessibleRelation( - javax.accessibility.AccessibleRelation.MEMBER_OF, - getAccessibleComponents( - unoAccessibleRelation.TargetSet))); - - break; - - default: - break; - } - } - - return relationSet; - } catch (com.sun.star.lang.IndexOutOfBoundsException e) { - return null; - } catch (com.sun.star.uno.RuntimeException e) { - return null; - } - } - } -} diff --git a/accessibility/bridge/org/openoffice/java/accessibility/List.java b/accessibility/bridge/org/openoffice/java/accessibility/List.java deleted file mode 100644 index cfa9e19f3924..000000000000 --- a/accessibility/bridge/org/openoffice/java/accessibility/List.java +++ /dev/null @@ -1,434 +0,0 @@ -/* - * 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 . - */ - -package org.openoffice.java.accessibility; - -import javax.accessibility.AccessibleContext; -import com.sun.star.uno.AnyConverter; -import com.sun.star.uno.UnoRuntime; -import com.sun.star.accessibility.*; - -public class List extends DescendantManager implements javax.accessibility.Accessible { - - protected List(XAccessible xAccessible, XAccessibleContext xAccessibleContext) { - super(xAccessible, xAccessibleContext); - } - - protected void setActiveDescendant(javax.accessibility.Accessible descendant) { - javax.accessibility.Accessible oldAD = activeDescendant; - activeDescendant = descendant; - firePropertyChange(AccessibleContext.ACCESSIBLE_ACTIVE_DESCENDANT_PROPERTY, - oldAD, descendant); - } - - protected void setActiveDescendant(Object any) { - javax.accessibility.Accessible descendant = null; - try { - if (AnyConverter.isObject(any)) { - XAccessible unoAccessible = (XAccessible) AnyConverter.toObject( - AccessibleObjectFactory.XAccessibleType, any); - if (unoAccessible != null) { - // FIXME: have to handle non transient objects here .. - descendant = new ListItem(unoAccessible); - if (Build.DEBUG) { - try { - if (Build.DEBUG) { - System.err.println("[List] retrieved active descendant event: new descendant is " + - unoAccessible.getAccessibleContext().getAccessibleName()); - } - } catch (java.lang.NullPointerException e) { - System.err.println("*** ERROR *** new active descendant not accessible"); - } - } - } - } - setActiveDescendant(descendant); - } catch (com.sun.star.lang.IllegalArgumentException e) { - } - } - - protected void add(XAccessible unoAccessible) { - if (unoAccessible != null) { - ListItem item = new ListItem(unoAccessible); - // The AccessBridge for Windows expects an instance of AccessibleContext - // as parameters - firePropertyChange(AccessibleContext.ACCESSIBLE_CHILD_PROPERTY, - null, item.getAccessibleContext()); - } - } - - protected void remove(XAccessible unoAccessible) { - if (unoAccessible != null) { - ListItem item = new ListItem(unoAccessible); - // The AccessBridge for Windows expects an instance of AccessibleContext - // as parameters - firePropertyChange(AccessibleContext.ACCESSIBLE_CHILD_PROPERTY, - item.getAccessibleContext(), null); - } - } - - protected void add(Object any) { - try { - add((XAccessible) AnyConverter.toObject(AccessibleObjectFactory.XAccessibleType, any)); - } catch (com.sun.star.lang.IllegalArgumentException e) { - } - } - - protected void remove(Object any) { - try { - remove((XAccessible) AnyConverter.toObject(AccessibleObjectFactory.XAccessibleType, any)); - } catch (com.sun.star.lang.IllegalArgumentException e) { - } - } - - /** - * Update the proxy objects appropriatly on property change events - */ - protected class AccessibleListListener extends AccessibleDescendantManagerListener { - - protected AccessibleListListener() { - super(); - } - - /** Called by OpenOffice process to notify property changes */ - public void notifyEvent(AccessibleEventObject event) { - switch (event.EventId) { - case AccessibleEventId.ACTIVE_DESCENDANT_CHANGED: - setActiveDescendant(event.NewValue); - break; - case AccessibleEventId.CHILD: - if (AnyConverter.isObject(event.OldValue)) { - remove(event.OldValue); - } - if (AnyConverter.isObject(event.NewValue)) { - add(event.NewValue); - } - break; - case AccessibleEventId.INVALIDATE_ALL_CHILDREN: - // Since List items a transient a child events are mostly used - // to attach/detach listeners, it is save to ignore it here - break; - default: - super.notifyEvent(event); - } - } - } - - protected XAccessibleEventListener createEventListener() { - return new AccessibleListListener(); - } - - /** Creates the AccessibleContext associated with this object */ - public javax.accessibility.AccessibleContext createAccessibleContext() { - return new AccessibleList(); - } - - protected class AccessibleList extends AccessibleDescendantManager { - - /** Gets the role of this object */ - public javax.accessibility.AccessibleRole getAccessibleRole() { - return javax.accessibility.AccessibleRole.LIST; - } - - /** Returns the specified Accessible child of the object */ - public javax.accessibility.Accessible getAccessibleChild(int i) { - javax.accessibility.Accessible child = null; - try { - XAccessible xAccessible = unoAccessibleContext.getAccessibleChild(i); - if (xAccessible != null) { - // Re-use the active descandant wrapper if possible - javax.accessibility.Accessible activeDescendant = List.this.activeDescendant; - if ((activeDescendant instanceof ListItem) && xAccessible.equals(((ListItem) activeDescendant).unoAccessible)) { - child = activeDescendant; - } else { - child = new ListItem(xAccessible); - } - } - } catch (com.sun.star.lang.IndexOutOfBoundsException e) { - } catch (com.sun.star.uno.RuntimeException e) { - } - return child; - } - - /* - * AccessibleComponent - */ - - /** Returns the Accessible child, if one exists, contained at the local coordinate Point */ - public javax.accessibility.Accessible getAccessibleAt(java.awt.Point p) { - javax.accessibility.Accessible child = null; - try { - XAccessible xAccessible = unoAccessibleComponent.getAccessibleAtPoint(new com.sun.star.awt.Point(p.x, p.y)); - if (xAccessible != null) { - // Re-use the active descandant wrapper if possible - javax.accessibility.Accessible activeDescendant = List.this.activeDescendant; - if ((activeDescendant instanceof ListItem) && xAccessible.equals(((ListItem) activeDescendant).unoAccessible)) { - child = activeDescendant; - } else { - child = new ListItem(xAccessible); - } - } - return child; - } catch (com.sun.star.uno.RuntimeException e) { - return null; - } - } - - /* - * AccessibleSelection - */ - - /** Returns an Accessible representing the specified selected child of the object */ - public javax.accessibility.Accessible getAccessibleSelection(int i) { - javax.accessibility.Accessible child = null; - try { - XAccessible xAccessible = unoAccessibleSelection.getSelectedAccessibleChild(i); - if (xAccessible != null) { - // Re-use the active descandant wrapper if possible - javax.accessibility.Accessible activeDescendant = List.this.activeDescendant; - if ((activeDescendant instanceof ListItem) && xAccessible.equals(((ListItem) activeDescendant).unoAccessible)) { - child = activeDescendant; - } else { - child = new ListItem(xAccessible); - } - } else if (Build.DEBUG) { - System.out.println(i + "th selected child is not accessible"); - } - } catch (com.sun.star.lang.IndexOutOfBoundsException e) { - if (Build.DEBUG) { - System.err.println("IndexOutOfBoundsException caught for AccessibleList.getAccessibleSelection(" + i + ")"); - } - } catch (com.sun.star.uno.RuntimeException e) { - } - return child; - } - } - - class ListItem extends java.awt.Component implements javax.accessibility.Accessible { - - protected XAccessible unoAccessible; - - public ListItem(XAccessible xAccessible) { - unoAccessible = xAccessible; - } - - public Object[] create(Object[] targetSet) { - try { - java.util.ArrayList<ListItem> list = new java.util.ArrayList<ListItem>(targetSet.length); - for (int i=0; i < targetSet.length; i++) { - XAccessible xAccessible = UnoRuntime.queryInterface( - XAccessible.class, targetSet[i]); - if (xAccessible != null) { - list.add(new ListItem(xAccessible)); - } - } - list.trimToSize(); - return list.toArray(); - } catch (com.sun.star.uno.RuntimeException e) { - return null; - } - } - - javax.accessibility.AccessibleContext accessibleContext = null; - - /** Returns the AccessibleContext associated with this object */ - public javax.accessibility.AccessibleContext getAccessibleContext() { - if (accessibleContext == null) { - try { - XAccessibleContext xAccessibleContext = unoAccessible.getAccessibleContext(); - if (xAccessibleContext != null) { - javax.accessibility.AccessibleContext ac = new AccessibleListItem(xAccessibleContext); - ac.setAccessibleParent(List.this); - accessibleContext = ac; - AccessibleStateAdapter.setComponentState(this, xAccessibleContext.getAccessibleStateSet()); - } - } catch (com.sun.star.uno.RuntimeException e) { - } - } - return accessibleContext; - } - - protected class AccessibleListItem extends javax.accessibility.AccessibleContext { - - XAccessibleContext unoAccessibleContext; - - public AccessibleListItem(XAccessibleContext xAccessibleContext) { - unoAccessibleContext = xAccessibleContext; - } - - /** Returns the accessible name of this object */ - public String getAccessibleName() { - try { - return unoAccessibleContext.getAccessibleName(); - } catch (com.sun.star.uno.RuntimeException e) { - return null; - } - } - - /** Sets the accessible name of this object */ - public void setAccessibleName(String name) { - // Not supported - } - - /** Returns the accessible name of this object */ - public String getAccessibleDescription() { - try { - return unoAccessibleContext.getAccessibleDescription(); - } catch (com.sun.star.uno.RuntimeException e) { - return null; - } - } - - /** Sets the accessible name of this object */ - public void setAccessibleDescription(String name) { - // Not supported - } - - /** Returns the accessible role of this object */ - public javax.accessibility.AccessibleRole getAccessibleRole() { - try { - javax.accessibility.AccessibleRole role = AccessibleRoleAdapter.getAccessibleRole( - unoAccessibleContext.getAccessibleRole()); - return (role != null) ? role : javax.accessibility.AccessibleRole.LABEL; - } catch(com.sun.star.uno.RuntimeException e) { - return null; - } - } - - /** Gets the locale of the component */ - public java.util.Locale getLocale() throws java.awt.IllegalComponentStateException { - try { - com.sun.star.lang.Locale unoLocale = unoAccessibleContext.getLocale(); - return new java.util.Locale(unoLocale.Language, unoLocale.Country); - } catch (IllegalAccessibleComponentStateException e) { - throw new java.awt.IllegalComponentStateException(e.getMessage()); - } catch (com.sun.star.uno.RuntimeException e) { - return List.this.getLocale(); - } - } - - /** Gets the 0-based index of this object in its accessible parent */ - public int getAccessibleIndexInParent() { - try { - return unoAccessibleContext.getAccessibleIndexInParent(); - } catch (com.sun.star.uno.RuntimeException e) { - return -1; - } - } - - /** Returns the number of accessible children of the object. */ - public int getAccessibleChildrenCount() { - try { - return unoAccessibleContext.getAccessibleChildCount(); - } catch (com.sun.star.uno.RuntimeException e) { - return 0; - } - } - - /** Returns the specified Accessible child of the object. */ - public javax.accessibility.Accessible getAccessibleChild(int i) { - javax.accessibility.Accessible child = null; - try { - XAccessible xAccessible = unoAccessibleContext.getAccessibleChild(i); - // Re-use the active descandant wrapper if possible - javax.accessibility.Accessible activeDescendant = List.this.activeDescendant; - if ((activeDescendant instanceof ListItem) && ((ListItem) activeDescendant).unoAccessible.equals(xAccessible)) { - child = activeDescendant; - } else if (xAccessible != null) { - child = new ListItem(xAccessible); - } - } catch (com.sun.star.lang.IndexOutOfBoundsException e) { - } catch (com.sun.star.uno.RuntimeException e) { - } - return child; - } - - /** Returns the state set of this object */ - public javax.accessibility.AccessibleStateSet getAccessibleStateSet() { - try { - return AccessibleStateAdapter.getAccessibleStateSet(ListItem.this, - unoAccessibleContext.getAccessibleStateSet()); - } catch (com.sun.star.uno.RuntimeException e) { - return AccessibleStateAdapter.getDefunctStateSet(); - } - } - - /** Gets the AccessibleComponent associated with this object that has a graphical representation */ - public javax.accessibility.AccessibleComponent getAccessibleComponent() { - try { - XAccessibleComponent unoAccessibleComponent = UnoRuntime.queryInterface(XAccessibleComponent.class, unoAccessibleContext); - return (unoAccessibleComponent != null) ? - new AccessibleComponentImpl(unoAccessibleComponent) : null; - } catch (com.sun.star.uno.RuntimeException e) { - return null; - } - } - - /** Gets the AccessibleAction associated with this object that has a graphical representation */ - public javax.accessibility.AccessibleAction getAccessibleAction() { - try { - XAccessibleAction unoAccessibleAction = UnoRuntime.queryInterface(XAccessibleAction.class, unoAccessibleContext); - return (unoAccessibleAction != null) ? - new AccessibleActionImpl(unoAccessibleAction) : null; - } catch (com.sun.star.uno.RuntimeException e) { - return null; - } - } - - /** Gets the AccessibleText associated with this object that has a graphical representation */ - public javax.accessibility.AccessibleText getAccessibleText() { - - if (disposed) - return null; - - try { - XAccessibleText unoAccessibleText = UnoRuntime.queryInterface(XAccessibleText.class, unoAccessibleContext); - return (unoAccessibleText != null) ? - new AccessibleTextImpl(unoAccessibleText) : null; - } catch (com.sun.star.uno.RuntimeException e) { - return null; - } - } - - /** Gets the AccessibleValue associated with this object that has a graphical representation */ - public javax.accessibility.AccessibleValue getAccessibleValue() { - try { - XAccessibleValue unoAccessibleValue = UnoRuntime.queryInterface(XAccessibleValue.class, unoAccessibleContext); - return (unoAccessibleValue != null) ? - new AccessibleValueImpl(unoAccessibleValue) : null; - } catch (com.sun.star.uno.RuntimeException e) { - return null; - } - } - - /** Gets the AccessibleText associated with this object presenting text on the display */ - public javax.accessibility.AccessibleIcon[] getAccessibleIcon() { - try { - XAccessibleImage unoAccessibleImage = UnoRuntime.queryInterface(XAccessibleImage.class, unoAccessibleContext); - if (unoAccessibleImage != null) { - javax.accessibility.AccessibleIcon[] icons = { new AccessibleIconImpl(unoAccessibleImage) }; - return icons; - } - } catch (com.sun.star.uno.RuntimeException e) { - } - return null; - } - } - } -} - diff --git a/accessibility/bridge/org/openoffice/java/accessibility/Menu.java b/accessibility/bridge/org/openoffice/java/accessibility/Menu.java deleted file mode 100644 index 005657172b1d..000000000000 --- a/accessibility/bridge/org/openoffice/java/accessibility/Menu.java +++ /dev/null @@ -1,321 +0,0 @@ -/* - * 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 . - */ -package org.openoffice.java.accessibility; - -import java.awt.Component; - -import com.sun.star.accessibility.*; -import com.sun.star.uno.AnyConverter; -import com.sun.star.uno.UnoRuntime; - - -public class Menu extends AbstractButton - implements javax.accessibility.Accessible { - private java.util.ArrayList<Component> children; - protected XAccessibleSelection unoAccessibleSelection = null; - - protected Menu(XAccessible xAccessible, - XAccessibleContext xAccessibleContext) { - super(xAccessible, xAccessibleContext); - - try { - // Create a vector with the correct initial capacity - int count = unoAccessibleContext.getAccessibleChildCount(); - children = new java.util.ArrayList<Component>(count); - - // Fill the vector with objects - for (int i = 0; i < count; i++) { - java.awt.Component c = getComponent(unoAccessibleContext.getAccessibleChild(i)); - - if (c != null) { - children.add(c); - } - } - } catch (com.sun.star.uno.RuntimeException e) { - if (Build.DEBUG) { - System.err.println( - "RuntimeException caught during menu initialization: " + - e.getMessage()); - } - - if (children == null) { - children = new java.util.ArrayList<Component>(0); - } - } catch (com.sun.star.lang.IndexOutOfBoundsException e) { - } - } - - protected synchronized void add(XAccessible unoAccessible) { - // The AccessBridge for Windows expects an instance of AccessibleContext - // as parameters - java.awt.Component c = getComponent(unoAccessible); - - if (c != null) { - try { - children.add(unoAccessible.getAccessibleContext() - .getAccessibleIndexInParent(), c); - firePropertyChange(javax.accessibility.AccessibleContext.ACCESSIBLE_CHILD_PROPERTY, - null, - ((javax.accessibility.Accessible) c).getAccessibleContext()); - } catch (com.sun.star.uno.RuntimeException e) { - } - } - } - - protected synchronized void remove(XAccessible unoAccessible) { - // The AccessBridge for Windows expects an instance of AccessibleContext - // as parameters - java.awt.Component c = getComponent(unoAccessible); - - if (c != null) { - try { - children.remove(c); - firePropertyChange(javax.accessibility.AccessibleContext.ACCESSIBLE_CHILD_PROPERTY, - ((javax.accessibility.Accessible) c).getAccessibleContext(), - null); - } catch (com.sun.star.uno.RuntimeException e) { - } - } - } - - protected void add(Object any) { - try { - add((XAccessible) AnyConverter.toObject( - AccessibleObjectFactory.XAccessibleType, any)); - } catch (com.sun.star.lang.IllegalArgumentException e) { - } - } - - protected void remove(Object any) { - try { - remove((XAccessible) AnyConverter.toObject( - AccessibleObjectFactory.XAccessibleType, any)); - } catch (com.sun.star.lang.IllegalArgumentException e) { - } - } - - protected synchronized int indexOf(Object child) { - return children.indexOf(child); - } - - protected java.awt.Component getComponent(XAccessible unoAccessible) { - java.awt.Component c = AccessibleObjectFactory.getAccessibleComponent(unoAccessible); - - if (c == null) { - c = AccessibleObjectFactory.createAccessibleComponent(unoAccessible); - - if (c instanceof javax.accessibility.Accessible) { - ((javax.accessibility.Accessible) c).getAccessibleContext() - .setAccessibleParent(this); - } - } - - return c; - } - - protected XAccessibleEventListener createEventListener() { - return new AccessibleMenuListener(); - } - - /** Creates the AccessibleContext associated with this object */ - public javax.accessibility.AccessibleContext createAccessibleContext() { - return new AccessibleMenu(); - } - - /** - * Update the proxy objects appropriatly on property change events - */ - protected class AccessibleMenuListener - extends AccessibleUNOComponentListener { - protected AccessibleMenuListener() { - super(); - } - - /** Called by OpenOffice process to notify property changes */ - public void notifyEvent(AccessibleEventObject event) { - switch (event.EventId) { - case AccessibleEventId.CHILD: - - if (AnyConverter.isObject(event.OldValue)) { - remove(event.OldValue); - } - - if (AnyConverter.isObject(event.NewValue)) { - add(event.NewValue); - } - - break; - - // #i56539# Java 1.5 does not fire ACCESSIBLE_SELECTION_PROPERTY for menus - case AccessibleEventId.SELECTION_CHANGED: - break; - - default: - super.notifyEvent(event); - } - } - } - - protected class AccessibleMenu extends AccessibleAbstractButton - implements javax.accessibility.AccessibleSelection { - protected AccessibleMenu() { - unoAccessibleSelection = UnoRuntime.queryInterface(XAccessibleSelection.class, - unoAccessibleContext); - } - - /** Gets the role of this object */ - public javax.accessibility.AccessibleRole getAccessibleRole() { - return javax.accessibility.AccessibleRole.MENU; - } - - /** Gets the 0-based index of this object in its accessible parent */ - public int getAccessibleIndexInParent() { - if (getAccessibleParent() instanceof Menu) { - return ((Menu) getAccessibleParent()).indexOf(Menu.this); - } else { - return super.getAccessibleIndexInParent(); - } - } - - /** Returns the number of accessible children of the object */ - public synchronized int getAccessibleChildrenCount() { - return children.size(); - } - - /** Returns the specified Accessible child of the object */ - public synchronized javax.accessibility.Accessible getAccessibleChild( - int i) { - try { - if (i < children.size()) { - return (javax.accessibility.Accessible) children.get(i); - } else { - return null; - } - } catch (ArrayIndexOutOfBoundsException e) { - return null; - } - } - - /** Returns the AccessibleSelection interface for this object */ - public javax.accessibility.AccessibleSelection getAccessibleSelection() { - // This method is called to determine the SELECTABLE state of every - // child, so don't do the query interface here. - return this; - } - - /* - * AccessibleComponent - */ - - /** Returns the Accessible child, if one exists, contained at the local coordinate Point */ - public javax.accessibility.Accessible getAccessibleAt(java.awt.Point p) { - try { - java.awt.Component c = AccessibleObjectFactory.getAccessibleComponent(unoAccessibleComponent.getAccessibleAtPoint( - new com.sun.star.awt.Point(p.x, p.y))); - - return (javax.accessibility.Accessible) c; - } catch (com.sun.star.uno.RuntimeException e) { - return null; - } - } - - /* - * AccessibleSelection - */ - - /** Returns an Accessible representing the specified selected child of the object */ - public javax.accessibility.Accessible getAccessibleSelection(int i) { - try { - return (javax.accessibility.Accessible) getComponent(unoAccessibleSelection.getSelectedAccessibleChild( - i)); - } catch (java.lang.Exception e) { - /* - * Possible exceptions are: - * java.lang.NullPointerException - * com.sun.star.uno.RuntimeException - * com.sun.star.lang.IndexOutOfBoundsException - */ - return null; - } - } - - /** Adds the specified Accessible child of the object to the object's selection */ - public void addAccessibleSelection(int i) { - try { - javax.accessibility.Accessible a = getAccessibleChild(i); - - // selecting menu items invokes the click action in Java 1.5 - if( a instanceof MenuItem ) - a.getAccessibleContext().getAccessibleAction().doAccessibleAction(0); - else - unoAccessibleSelection.selectAccessibleChild(i); - } catch (java.lang.Exception e) { - /* - * Possible exceptions are: - * java.lang.NullPointerException - * com.sun.star.uno.RuntimeException - * com.sun.star.lang.IndexOutOfBoundsException - */ - } - } - - /** Clears the selection in the object, so that no children in the object are selected */ - public void clearAccessibleSelection() { - try { - unoAccessibleSelection.clearAccessibleSelection(); - } catch (com.sun.star.uno.RuntimeException e) { - } - } - - /** Returns the number of Accessible children currently selected */ - public int getAccessibleSelectionCount() { - try { - return unoAccessibleSelection.getSelectedAccessibleChildCount(); - } catch (com.sun.star.uno.RuntimeException e) { - return 0; - } - } - - /** Determines if the current child of this object is selected */ - public boolean isAccessibleChildSelected(int i) { - try { - return unoAccessibleSelection.isAccessibleChildSelected(i); - } catch (java.lang.Exception e) { - /* - * Possible exceptions are: - * java.lang.NullPointerException - * com.sun.star.uno.RuntimeException - * com.sun.star.lang.IndexOutOfBoundsException - */ - return false; - } - } - - /** Removes the specified child of the object from the object's selection */ - public void removeAccessibleSelection(int i) { - if (isAccessibleChildSelected(i)) { - clearAccessibleSelection(); - } - } - - /** Causes every child of the object to be selected if the object supports multiple selection */ - public void selectAllAccessibleSelection() { - // not supported - } - } -} diff --git a/accessibility/bridge/org/openoffice/java/accessibility/MenuContainer.java b/accessibility/bridge/org/openoffice/java/accessibility/MenuContainer.java deleted file mode 100644 index 946ad27db9d6..000000000000 --- a/accessibility/bridge/org/openoffice/java/accessibility/MenuContainer.java +++ /dev/null @@ -1,156 +0,0 @@ -/* - * 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 . - */ - -package org.openoffice.java.accessibility; - -import com.sun.star.uno.*; -import com.sun.star.accessibility.*; - -/** - * Specialized container for MenuBar and Popup-Menu(s) - * FIXME: join with Menu ? - */ -public class MenuContainer extends Container implements javax.accessibility.Accessible { - - protected XAccessibleSelection unoAccessibleSelection = null; - - protected MenuContainer(javax.accessibility.AccessibleRole role, XAccessible xAccessible, XAccessibleContext xAccessibleContext) { - super(role, xAccessible, xAccessibleContext); - } - - protected class AccessibleMenuContainerListener extends AccessibleContainerListener { - - protected AccessibleMenuContainerListener() { - super(); - } - - /** Called by OpenOffice process to notify property changes */ - public void notifyEvent(AccessibleEventObject event) { - switch (event.EventId) { - - // #i56539# Java 1.5 does not fire ACCESSIBLE_SELECTION_PROPERTY for menus - case AccessibleEventId.SELECTION_CHANGED: - break; - - default: - super.notifyEvent(event); - } - } - } - - protected XAccessibleEventListener createEventListener() { - return new AccessibleMenuContainerListener(); - } - - /** Creates the AccessibleContext associated with this object */ - public javax.accessibility.AccessibleContext createAccessibleContext() { - return new AccessibleMenuContainer(); - } - - protected class AccessibleMenuContainer extends AccessibleContainer implements javax.accessibility.AccessibleSelection { - - protected AccessibleMenuContainer() { - unoAccessibleSelection = UnoRuntime.queryInterface(XAccessibleSelection.class, - unoAccessibleContext); - } - - /** Returns the AccessibleSelection interface for this object */ - public javax.accessibility.AccessibleSelection getAccessibleSelection() { - return this; - } - - /* - * AccessibleSelection - */ - - /** Returns an Accessible representing the specified selected child of the object */ - public javax.accessibility.Accessible getAccessibleSelection(int i) { - try { - return (javax.accessibility.Accessible) AccessibleObjectFactory.getAccessibleComponent( - unoAccessibleSelection.getSelectedAccessibleChild(i)); - } catch (com.sun.star.uno.Exception e) { - return null; - } - } - - /** Adds the specified Accessible child of the object to the object's selection */ - public void addAccessibleSelection(int i) { - try { - javax.accessibility.Accessible a = getAccessibleChild(i); - - // selecting menu items invokes the click action in Java 1.5 - if( a instanceof MenuItem ) - a.getAccessibleContext().getAccessibleAction().doAccessibleAction(0); - else - unoAccessibleSelection.selectAccessibleChild(i); - } catch (java.lang.Exception e) { - /* - * Possible exceptions are: - * java.lang.NullPointerException - * com.sun.star.uno.RuntimeException - * com.sun.star.lang.IndexOutOfBoundsException - */ - } - } - - /** Clears the selection in the object, so that no children in the object are selected */ - public void clearAccessibleSelection() { - try { - unoAccessibleSelection.clearAccessibleSelection(); - } catch (com.sun.star.uno.RuntimeException e) { - } - } - - /** Returns the number of Accessible children currently selected */ - public int getAccessibleSelectionCount() { - try { - return unoAccessibleSelection.getSelectedAccessibleChildCount(); - } catch (com.sun.star.uno.RuntimeException e) { - return 0; - } - } - - /** Determines if the current child of this object is selected */ - public boolean isAccessibleChildSelected(int i) { - try { - return unoAccessibleSelection.isAccessibleChildSelected(i); - } catch (java.lang.Exception e) { - /* - * Possible exceptions are: - * java.lang.NullPointerException - * com.sun.star.uno.RuntimeException - * com.sun.star.lang.IndexOutOfBoundsException - */ - return false; - } - } - - /** Removes the specified child of the object from the object's selection */ - public void removeAccessibleSelection(int i) { - if (isAccessibleChildSelected(i)) { - clearAccessibleSelection(); - } - } - - /** Causes every child of the object to be selected if the object supports multiple selection */ - public void selectAllAccessibleSelection() { - // not supported - } - } -} - diff --git a/accessibility/bridge/org/openoffice/java/accessibility/MenuItem.java b/accessibility/bridge/org/openoffice/java/accessibility/MenuItem.java deleted file mode 100644 index 6e68b634fc3f..000000000000 --- a/accessibility/bridge/org/openoffice/java/accessibility/MenuItem.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * 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 . - */ -package org.openoffice.java.accessibility; - -import com.sun.star.accessibility.XAccessible; -import com.sun.star.accessibility.XAccessibleContext; -import com.sun.star.accessibility.XAccessibleEventListener; - - -class MenuItem extends ToggleButton { - public MenuItem(XAccessible xAccessible, XAccessibleContext xAccessibleContext) { - super(xAccessible, xAccessibleContext); - } - - protected class AccessibleMenuItemListener extends AccessibleUNOComponentListener { - - protected AccessibleMenuItemListener() { - } - - protected void setComponentState(short state, boolean enable) { - - // #i56538# menu items in Java 1.5 are ARMED, not SELECTED - if( state == com.sun.star.accessibility.AccessibleStateType.SELECTED ) - fireStatePropertyChange(javax.accessibility.AccessibleState.ARMED, enable); - else - super.setComponentState(state, enable); - } - } - - protected XAccessibleEventListener createEventListener() { - return new AccessibleMenuItemListener(); - } - - /** Creates the AccessibleContext associated with this object */ - public javax.accessibility.AccessibleContext createAccessibleContext() { - return new AccessibleMenuItem(); - } - - protected class AccessibleMenuItem extends AccessibleToggleButton { - /** Gets the role of this object */ - public javax.accessibility.AccessibleRole getAccessibleRole() { - return javax.accessibility.AccessibleRole.MENU_ITEM; - } - - /** Gets the 0-based index of this object in its accessible parent */ - public int getAccessibleIndexInParent() { - if (getAccessibleParent() instanceof Menu) { - return ((Menu) getAccessibleParent()).indexOf(MenuItem.this); - } else { - return super.getAccessibleIndexInParent(); - } - } - - /** - * Gets the current state set of this object. - * - * @return an instance of <code>AccessibleStateSet</code> - * containing the current state set of the object - * @see javax.accessibility.AccessibleState - */ - public javax.accessibility.AccessibleStateSet getAccessibleStateSet() { - javax.accessibility.AccessibleStateSet stateSet = super.getAccessibleStateSet(); - - // #i56538# menu items in Java do not have SELECTABLE .. - stateSet.remove(javax.accessibility.AccessibleState.SELECTABLE); - - // .. and also ARMED instead of SELECTED - if( stateSet.remove(javax.accessibility.AccessibleState.SELECTED) ) - stateSet.add(javax.accessibility.AccessibleState.ARMED); - - return stateSet; - } - - } -} diff --git a/accessibility/bridge/org/openoffice/java/accessibility/NativeFrame.java b/accessibility/bridge/org/openoffice/java/accessibility/NativeFrame.java deleted file mode 100644 index d8e9d29cdbc0..000000000000 --- a/accessibility/bridge/org/openoffice/java/accessibility/NativeFrame.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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 . - */ - -package org.openoffice.java.accessibility; - -public interface NativeFrame { - public java.awt.Component getInitialComponent(); - public void setInitialComponent(java.awt.Component c); -// public Integer getHWND(); -} - diff --git a/accessibility/bridge/org/openoffice/java/accessibility/Paragraph.java b/accessibility/bridge/org/openoffice/java/accessibility/Paragraph.java deleted file mode 100644 index d339d751469a..000000000000 --- a/accessibility/bridge/org/openoffice/java/accessibility/Paragraph.java +++ /dev/null @@ -1,211 +0,0 @@ -/* - * 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 . - */ - -package org.openoffice.java.accessibility; - -import javax.accessibility.AccessibleContext; -import javax.accessibility.AccessibleText; - -import com.sun.star.uno.*; -import com.sun.star.accessibility.*; - -/** - */ -public class Paragraph extends Container implements javax.accessibility.Accessible { - - protected Paragraph(XAccessible xAccessible, XAccessibleContext xAccessibleContext) { - super(javax.accessibility.AccessibleRole.TEXT, xAccessible, xAccessibleContext); - } - - protected class AccessibleParagraphListener extends AccessibleContainerListener { - - protected AccessibleParagraphListener() { - super(); - } - - protected void setComponentState(short state, boolean enable) { - switch (state) { - case AccessibleStateType.EDITABLE: - fireStatePropertyChange(javax.accessibility.AccessibleState.EDITABLE, enable); - break; - case AccessibleStateType.MULTI_LINE: - fireStatePropertyChange(javax.accessibility.AccessibleState.MULTI_LINE, enable); - break; - case AccessibleStateType.SINGLE_LINE: - break; - default: - super.setComponentState(state, enable); - break; - } - } - - - protected void handleVisibleDataChanged() { - if (Paragraph.this.isFocusOwner()) { - AccessibleContext ac = accessibleContext; - if (ac != null) { - AccessibleText at = ac.getAccessibleText(); - if (at != null) { - int pos = at.getCaretPosition(); - // Simulating a caret event here should help at tools - // that re not aware of the paragraph approach of OOo. - firePropertyChange(AccessibleContext.ACCESSIBLE_CARET_PROPERTY, - new Integer(-1), new Integer(pos)); - } - } - } - } - - /** Called by OpenOffice process to notify property changes */ - public void notifyEvent(AccessibleEventObject event) { - switch (event.EventId) { - case AccessibleEventId.CARET_CHANGED: - firePropertyChange(AccessibleContext.ACCESSIBLE_CARET_PROPERTY, - Component.toNumber(event.OldValue), - Component.toNumber(event.NewValue)); - break; - case AccessibleEventId.VISIBLE_DATA_CHANGED: - case AccessibleEventId.BOUNDRECT_CHANGED: - // Whenever a paragraph gets inserted above the currently - // focused one, this is the only event that will occur for. - handleVisibleDataChanged(); - default: - super.notifyEvent(event); - break; - } - } - } - - protected XAccessibleEventListener createEventListener() { - return new AccessibleParagraphListener(); - } - - /** Creates the AccessibleContext associated with this object */ - public javax.accessibility.AccessibleContext createAccessibleContext() { - return new AccessibleParagraph(); - } - - protected class AccessibleParagraph extends AccessibleContainer { - - protected AccessibleParagraph() { - // Don't do the queryInterface on XAccessibleText already .. - super(false); - /* Since getAccessibleText() is heavily used by the java access - * bridge for gnome and the gnome at-tools, we do a query interface - * here and remember the result. - */ - accessibleText = AccessibleHypertextImpl.get(unoAccessibleContext); - } - - /* - * AccessibleContext - */ - - /** Gets the role of this object */ - public javax.accessibility.AccessibleRole getAccessibleRole() { - return javax.accessibility.AccessibleRole.TEXT; - } - - /** Gets the AccessibleEditableText associated with this object presenting text on the display */ - public javax.accessibility.AccessibleEditableText getAccessibleEditableText() { - - if (disposed) - return null; - - try { - XAccessibleEditableText unoAccessibleText = UnoRuntime.queryInterface(XAccessibleEditableText.class, - unoAccessibleComponent); - if (unoAccessibleText != null) { - return new AccessibleEditableTextImpl(unoAccessibleText); - } else { - return null; - } - } catch (com.sun.star.uno.RuntimeException e) { - return null; - } - } - - /** Gets the AccessibleAction associated with this object that has a graphical representation */ - public javax.accessibility.AccessibleAction getAccessibleAction() { - try { - XAccessibleAction unoAccessibleAction = UnoRuntime.queryInterface(XAccessibleAction.class, unoAccessibleComponent); - return (unoAccessibleAction != null) ? - new AccessibleActionImpl(unoAccessibleAction) : null; - } catch (com.sun.star.uno.RuntimeException e) { - return null; - } - } - - /** Returns the relation set of this object */ - public javax.accessibility.AccessibleRelationSet getAccessibleRelationSet() { - try { - XAccessibleRelationSet unoAccessibleRelationSet = - unoAccessible.getAccessibleContext().getAccessibleRelationSet(); - if (unoAccessibleRelationSet == null) { - return super.getAccessibleRelationSet(); - } - - javax.accessibility.AccessibleRelationSet relationSet = new javax.accessibility.AccessibleRelationSet(); - int count = unoAccessibleRelationSet.getRelationCount(); - for (int i = 0; i < count; i++) { - AccessibleRelation unoAccessibleRelation = unoAccessibleRelationSet.getRelation(i); - switch (unoAccessibleRelation.RelationType) { - case AccessibleRelationType.CONTROLLED_BY: - relationSet.add(new javax.accessibility.AccessibleRelation( - javax.accessibility.AccessibleRelation.CONTROLLED_BY, - getAccessibleComponents(unoAccessibleRelation.TargetSet))); - break; - case AccessibleRelationType.CONTROLLER_FOR: - relationSet.add(new javax.accessibility.AccessibleRelation( - javax.accessibility.AccessibleRelation.CONTROLLER_FOR, - getAccessibleComponents(unoAccessibleRelation.TargetSet))); - break; - case AccessibleRelationType.LABELED_BY: - relationSet.add(new javax.accessibility.AccessibleRelation( - javax.accessibility.AccessibleRelation.LABELED_BY, - getAccessibleComponents(unoAccessibleRelation.TargetSet))); - break; - case AccessibleRelationType.MEMBER_OF: - relationSet.add(new javax.accessibility.AccessibleRelation( - javax.accessibility.AccessibleRelation.MEMBER_OF, - getAccessibleComponents(unoAccessibleRelation.TargetSet))); - break; - case AccessibleRelationType.CONTENT_FLOWS_TO: - relationSet.add(new javax.accessibility.AccessibleRelation( - "flowsTo", - getAccessibleComponents(unoAccessibleRelation.TargetSet))); - break; - case AccessibleRelationType.CONTENT_FLOWS_FROM: - relationSet.add(new javax.accessibility.AccessibleRelation( - "flowsFrom", - getAccessibleComponents(unoAccessibleRelation.TargetSet))); - break; - default: - break; - } - } - return relationSet; - } catch (com.sun.star.lang.IndexOutOfBoundsException e) { - return super.getAccessibleRelationSet(); - } catch (com.sun.star.uno.RuntimeException e) { - return super.getAccessibleRelationSet(); - } - } - } -} - diff --git a/accessibility/bridge/org/openoffice/java/accessibility/RadioButton.java b/accessibility/bridge/org/openoffice/java/accessibility/RadioButton.java deleted file mode 100644 index 2b07576ee03b..000000000000 --- a/accessibility/bridge/org/openoffice/java/accessibility/RadioButton.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * 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 . - */ -package org.openoffice.java.accessibility; - -import com.sun.star.accessibility.*; - - -class RadioButton extends ToggleButton { - public RadioButton(XAccessible xAccessible, - XAccessibleContext xAccessibleContext) { - super(xAccessible, xAccessibleContext); - } - - /** Creates the AccessibleContext associated with this object */ - public javax.accessibility.AccessibleContext createAccessibleContext() { - return new AccessibleRadioButton(); - } - - protected class AccessibleRadioButton extends AccessibleToggleButton { - /** Gets the role of this object */ - public javax.accessibility.AccessibleRole getAccessibleRole() { - return javax.accessibility.AccessibleRole.RADIO_BUTTON; - } - } -} diff --git a/accessibility/bridge/org/openoffice/java/accessibility/ScrollBar.java b/accessibility/bridge/org/openoffice/java/accessibility/ScrollBar.java deleted file mode 100644 index 31f475876c4b..000000000000 --- a/accessibility/bridge/org/openoffice/java/accessibility/ScrollBar.java +++ /dev/null @@ -1,114 +0,0 @@ -/* - * 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 . - */ - -package org.openoffice.java.accessibility; - -import javax.swing.SwingConstants; - -import com.sun.star.uno.*; -import com.sun.star.accessibility.*; - -/** - */ -public class ScrollBar extends Component implements SwingConstants, javax.accessibility.Accessible { - - public ScrollBar(XAccessible xAccessible, XAccessibleContext xAccessibleContext) { - super(xAccessible, xAccessibleContext); - } - - /** Creates the AccessibleContext associated with this object */ - public javax.accessibility.AccessibleContext createAccessibleContext() { - return new AccessibleScrollBar(); - } - - protected class AccessibleScrollBar extends AccessibleUNOComponent implements - javax.accessibility.AccessibleAction { - - protected XAccessibleAction unoAccessibleAction; - protected int actionCount = 0; - - /** - * Though the class is abstract, this should be called by all sub-classes - */ - protected AccessibleScrollBar() { - super(); - unoAccessibleAction = UnoRuntime.queryInterface( - XAccessibleAction.class, unoAccessibleContext); - if (unoAccessibleAction != null) { - actionCount = unoAccessibleAction.getAccessibleActionCount(); - } - } - - /* - * AccessibleContext - */ - - /** Gets the role of this object */ - public javax.accessibility.AccessibleRole getAccessibleRole() { - return javax.accessibility.AccessibleRole.SCROLL_BAR; - } - - /** Gets the AccessibleValue associated with this object that has a graphical representation */ - public javax.accessibility.AccessibleValue getAccessibleValue() { - try { - XAccessibleValue unoAccessibleValue = UnoRuntime.queryInterface(XAccessibleValue.class, unoAccessibleContext); - return (unoAccessibleValue != null) ? - new AccessibleValueImpl(unoAccessibleValue) : null; - } catch (com.sun.star.uno.RuntimeException e) { - return null; - } - } - - /** Gets the AccessibleAction associated with this object that supports one or more actions */ - public javax.accessibility.AccessibleAction getAccessibleAction() { - return this; - } - - /* - * AccessibleAction - */ - - /** Performs the specified Action on the object */ - public boolean doAccessibleAction(int param) { - if (param < actionCount) { - try { - return unoAccessibleAction.doAccessibleAction(param); - } catch(com.sun.star.lang.IndexOutOfBoundsException e) { - } - } - return false; - } - - /** Returns a description of the specified action of the object */ - public java.lang.String getAccessibleActionDescription(int param) { - if(param < actionCount) { - try { - return unoAccessibleAction.getAccessibleActionDescription(param); - } catch(com.sun.star.lang.IndexOutOfBoundsException e) { - } - } - return null; - } - - /** Returns the number of accessible actions available in this object */ - public int getAccessibleActionCount() { - return actionCount; - } - } -} - diff --git a/accessibility/bridge/org/openoffice/java/accessibility/Separator.java b/accessibility/bridge/org/openoffice/java/accessibility/Separator.java deleted file mode 100644 index 4c92fed807c6..000000000000 --- a/accessibility/bridge/org/openoffice/java/accessibility/Separator.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * 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 . - */ -package org.openoffice.java.accessibility; - -import com.sun.star.accessibility.*; -import javax.swing.SwingConstants; - - -/** - */ -public class Separator extends Component implements SwingConstants, - javax.accessibility.Accessible { - - public Separator(XAccessible xAccessible, - XAccessibleContext xAccessibleContext) { - super(xAccessible, xAccessibleContext); - setFocusable(false); - } - - /** Creates the AccessibleContext associated with this object */ - public javax.accessibility.AccessibleContext createAccessibleContext() { - return new AccessibleSeparator(); - } - - protected class AccessibleSeparator extends AccessibleUNOComponent { - /** - * Though the class is abstract, this should be called by all sub-classes - */ - protected AccessibleSeparator() { - super(); - } - - /* - * AccessibleContext - */ - - /** Gets the role of this object */ - public javax.accessibility.AccessibleRole getAccessibleRole() { - return javax.accessibility.AccessibleRole.SEPARATOR; - } - } -} diff --git a/accessibility/bridge/org/openoffice/java/accessibility/Table.java b/accessibility/bridge/org/openoffice/java/accessibility/Table.java deleted file mode 100644 index 5896082287b8..000000000000 --- a/accessibility/bridge/org/openoffice/java/accessibility/Table.java +++ /dev/null @@ -1,709 +0,0 @@ -/* - * 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 . - */ - -package org.openoffice.java.accessibility; - -import com.sun.star.uno.AnyConverter; -import com.sun.star.uno.UnoRuntime; -import com.sun.star.accessibility.*; - -public class Table extends DescendantManager implements javax.accessibility.Accessible { - - protected Table(XAccessible xAccessible, XAccessibleContext xAccessibleContext, boolean multiselectable) { - super(xAccessible, xAccessibleContext, multiselectable); - } - - protected void setActiveDescendant(javax.accessibility.Accessible descendant) { - javax.accessibility.Accessible oldAD = activeDescendant; - activeDescendant = descendant; - firePropertyChange(javax.accessibility.AccessibleContext.ACCESSIBLE_ACTIVE_DESCENDANT_PROPERTY, - oldAD, descendant); - } - - protected void setActiveDescendant(Object any) { - javax.accessibility.Accessible descendant = null; - try { - if (AnyConverter.isObject(any)) { - XAccessible unoAccessible = (XAccessible) AnyConverter.toObject( - AccessibleObjectFactory.XAccessibleType, any); - if (unoAccessible != null) { - // FIXME: have to handle non transient objects here .. - descendant = new TableCell(unoAccessible); - } - } - setActiveDescendant(descendant); - } catch (com.sun.star.lang.IllegalArgumentException e) { - } - } - - protected void add(XAccessible unoAccessible) { - if (unoAccessible != null) { - TableCell cell = new TableCell(unoAccessible); - // The AccessBridge for Windows expects an instance of AccessibleContext - // as parameters - firePropertyChange(javax.accessibility.AccessibleContext.ACCESSIBLE_CHILD_PROPERTY, - null, cell.getAccessibleContext()); - } - } - - protected void remove(XAccessible unoAccessible) { - if (unoAccessible != null) { - TableCell cell = new TableCell(unoAccessible); - // The AccessBridge for Windows expects an instance of AccessibleContext - // as parameters - firePropertyChange(javax.accessibility.AccessibleContext.ACCESSIBLE_CHILD_PROPERTY, - cell.getAccessibleContext(), null); - } - } - - protected void add(Object any) { - try { - add((XAccessible) AnyConverter.toObject(AccessibleObjectFactory.XAccessibleType, any)); - } catch (com.sun.star.lang.IllegalArgumentException e) { - } - } - - protected void remove(Object any) { - try { - remove((XAccessible) AnyConverter.toObject(AccessibleObjectFactory.XAccessibleType, any)); - } catch (com.sun.star.lang.IllegalArgumentException e) { - } - } - - /** - * Update the proxy objects appropriatly on property change events - */ - protected class AccessibleTableListener extends AccessibleDescendantManagerListener { - - protected AccessibleTableListener() { - super(); - } - - /** Called by OpenOffice process to notify property changes */ - public void notifyEvent(AccessibleEventObject event) { - switch (event.EventId) { - case AccessibleEventId.ACTIVE_DESCENDANT_CHANGED: - setActiveDescendant(event.NewValue); - break; - case AccessibleEventId.CHILD: - if (AnyConverter.isObject(event.OldValue)) { - remove(event.OldValue); - } - if (AnyConverter.isObject(event.NewValue)) { - add(event.NewValue); - } - break; - default: - super.notifyEvent(event); - } - } - } - - protected XAccessibleEventListener createEventListener() { - return new AccessibleTableListener(); - } - - /** Creates the AccessibleContext associated with this object */ - public javax.accessibility.AccessibleContext createAccessibleContext() { - return new AccessibleTable(); - } - - protected class AccessibleTable extends AccessibleDescendantManager implements javax.accessibility.AccessibleExtendedTable { - - protected XAccessibleTable unoAccessibleTable; - - public AccessibleTable() { - unoAccessibleTable = UnoRuntime.queryInterface(XAccessibleTable.class, unoAccessibleContext); - } - - /** Gets the role of this object */ - public javax.accessibility.AccessibleRole getAccessibleRole() { - return javax.accessibility.AccessibleRole.TABLE; - } - - /** Returns the AccessibleTable interface of this object */ - public javax.accessibility.AccessibleTable getAccessibleTable() { - return this; - } - - /** Returns the specified Accessible child of the object */ - public javax.accessibility.Accessible getAccessibleChild(int i) { - javax.accessibility.Accessible child = null; - try { - XAccessible xAccessible = unoAccessibleContext.getAccessibleChild(i); - if (xAccessible != null) { - // Re-use the active descandant wrapper if possible - javax.accessibility.Accessible activeDescendant = Table.this.activeDescendant; - if ((activeDescendant instanceof TableCell) && xAccessible.equals(((TableCell) activeDescendant).unoAccessible)) { - child = activeDescendant; - } else { - child = new TableCell(xAccessible); - } - } - } catch (com.sun.star.lang.IndexOutOfBoundsException e) { - } catch (com.sun.star.uno.RuntimeException e) { - } - return child; - } - - /* - * AccessibleComponent - */ - - /** Returns the Accessible child, if one exists, contained at the local coordinate Point */ - public javax.accessibility.Accessible getAccessibleAt(java.awt.Point p) { - javax.accessibility.Accessible child = null; - try { - XAccessible xAccessible = unoAccessibleComponent.getAccessibleAtPoint( - new com.sun.star.awt.Point(p.x, p.y)); - if (xAccessible != null) { - // Re-use the active descandant wrapper if possible - javax.accessibility.Accessible activeDescendant = Table.this.activeDescendant; - if ((activeDescendant instanceof TableCell) && xAccessible.equals(((TableCell) activeDescendant).unoAccessible)) { - child = activeDescendant; - } else { - child = new TableCell(xAccessible); - } - } - } catch (com.sun.star.uno.RuntimeException e) { - } - return child; - } - - /* - * AccessibleSelection - */ - - /** Returns an Accessible representing the specified selected child of the object */ - public javax.accessibility.Accessible getAccessibleSelection(int i) { - javax.accessibility.Accessible child = null; - try { - XAccessible xAccessible = unoAccessibleSelection.getSelectedAccessibleChild(i); - if (xAccessible != null) { - // Re-use the active descandant wrapper if possible - javax.accessibility.Accessible activeDescendant = Table.this.activeDescendant; - if ((activeDescendant instanceof TableCell) && xAccessible.equals(((TableCell) activeDescendant).unoAccessible)) { - child = activeDescendant; - } else { - child = new TableCell(xAccessible); - } - } - } catch (com.sun.star.lang.IndexOutOfBoundsException e) { - } catch (com.sun.star.uno.RuntimeException e) { - } - return child; - } - - /* - * AccessibleTable - */ - - /** Returns the Accessible at a specified row and column in the table. */ - public javax.accessibility.Accessible getAccessibleAt(int r, int c) { - javax.accessibility.Accessible child = null; - try { - XAccessible xAccessible = unoAccessibleTable.getAccessibleCellAt(r,c); - if (xAccessible != null) { - // Re-use the active descandant wrapper if possible - javax.accessibility.Accessible activeDescendant = Table.this.activeDescendant; - if ((activeDescendant instanceof TableCell) && xAccessible.equals(((TableCell) activeDescendant).unoAccessible)) { - child = activeDescendant; - } else { - child = new TableCell(xAccessible); - } - } - } catch (com.sun.star.lang.IndexOutOfBoundsException e) { - } catch (com.sun.star.uno.RuntimeException e) { - } - return child; - } - - /** Returns the caption for the table. */ - public javax.accessibility.Accessible getAccessibleCaption() { - // Not yet supported. - return null; - } - - /** Returns the number of columns in the table. */ - public int getAccessibleColumnCount() { - try { - return unoAccessibleTable.getAccessibleColumnCount(); - } catch (com.sun.star.uno.RuntimeException e) { - return 0; - } - } - - /** Returns the description text of the specified column in the table. */ - public javax.accessibility.Accessible getAccessibleColumnDescription(int c) { - try { - return new javax.swing.JLabel( - unoAccessibleTable.getAccessibleColumnDescription(c)); - } catch (com.sun.star.lang.IndexOutOfBoundsException e) { - return null; - } catch (com.sun.star.uno.RuntimeException e) { - return null; - } - } - - /** - * Returns the number of columns occupied by the Accessible - * at a specified row and column in the table. - */ - public int getAccessibleColumnExtentAt(int r, int c) { - try { - return unoAccessibleTable.getAccessibleColumnExtentAt(r,c); - } catch (com.sun.star.lang.IndexOutOfBoundsException e) { - return 0; - } catch (com.sun.star.uno.RuntimeException e) { - return 0; - } - } - - /** Returns the column headers as an AccessibleTable. */ - public javax.accessibility.AccessibleTable getAccessibleColumnHeader() { - // Not yet supported - return null; - } - - /** Returns the number of rows in the table. */ - public int getAccessibleRowCount() { - try { - return unoAccessibleTable.getAccessibleRowCount(); - } catch (com.sun.star.uno.RuntimeException e) { - return 0; - } - } - - /** Returns the description of the specified row in the table. */ - public javax.accessibility.Accessible getAccessibleRowDescription(int r) { - try { - return new javax.swing.JLabel( - unoAccessibleTable.getAccessibleRowDescription(r)); - } catch (com.sun.star.lang.IndexOutOfBoundsException e) { - return null; - } catch (com.sun.star.uno.RuntimeException e) { - return null; - } - } - - /** - * Returns the number of rows occupied by the Accessible - * at a specified row and column in the table. - */ - public int getAccessibleRowExtentAt(int r, int c) { - try { - return unoAccessibleTable.getAccessibleRowExtentAt(r,c); - } catch (com.sun.star.lang.IndexOutOfBoundsException e) { - return 0; - } catch (com.sun.star.uno.RuntimeException e) { - return 0; - } - } - - /** Returns the row headers as an AccessibleTable. */ - public javax.accessibility.AccessibleTable getAccessibleRowHeader() { - // Not yet supported - return null; - } - - /** Returns the summary description of the table. */ - public javax.accessibility.Accessible getAccessibleSummary() { - // Not yet supported. - return null; - } - - /** Returns the selected columns in a table. */ - public int[] getSelectedAccessibleColumns() { - try { - return unoAccessibleTable.getSelectedAccessibleColumns(); - } catch (com.sun.star.uno.RuntimeException e) { - return null; - } - } - - /** Returns the selected rows in a table. */ - public int[] getSelectedAccessibleRows() { - try { - return unoAccessibleTable.getSelectedAccessibleRows(); - } catch (com.sun.star.uno.RuntimeException e) { - return null; - } - } - - /** Returns a boolean value indicating whether the specified column is selected. */ - public boolean isAccessibleColumnSelected(int c) { - try { - return unoAccessibleTable.isAccessibleColumnSelected(c); - } catch (com.sun.star.lang.IndexOutOfBoundsException e) { - return false; - } catch (com.sun.star.uno.RuntimeException e) { - return false; - } - } - - /** Returns a boolean value indicating whether the specified row is selected. */ - public boolean isAccessibleRowSelected(int r) { - try { - return unoAccessibleTable.isAccessibleRowSelected(r); - } catch (com.sun.star.lang.IndexOutOfBoundsException e) { - return false; - } catch (com.sun.star.uno.RuntimeException e) { - return false; - } - } - - /** - * Returns a boolean value indicating whether the accessible - * at a specified row and column is selected. - */ - public boolean isAccessibleSelected(int r, int c) { - try { - return unoAccessibleTable.isAccessibleSelected(r,c); - } catch (com.sun.star.lang.IndexOutOfBoundsException e) { - return false; - } catch (com.sun.star.uno.RuntimeException e) { - return false; - } - } - - /** Sets the caption for the table. */ - public void setAccessibleCaption(javax.accessibility.Accessible accessible) { - // Not supported by the UNO Accessibility API - } - - /** Sets the description text of the specified column in the table. */ - public void setAccessibleColumnDescription(int param, javax.accessibility.Accessible accessible) { - // Not supported by the UNO Accessibility API - } - - /** Sets the column headers. */ - public void setAccessibleColumnHeader(javax.accessibility.AccessibleTable accessibleTable) { - // Not supported by the UNO Accessibility API - } - - /** Sets the description text of the specified row of the table. */ - public void setAccessibleRowDescription(int param, javax.accessibility.Accessible accessible) { - // Not supported by the UNO Accessibility API - } - - /** Sets the row headers. */ - public void setAccessibleRowHeader(javax.accessibility.AccessibleTable accessibleTable) { - // Not supported by the UNO Accessibility API - } - - /** Sets the summary description of the table */ - public void setAccessibleSummary(javax.accessibility.Accessible accessible) { - // Not supported by the UNO Accessibility API - } - - /** Returns the column number of an index in the table */ - public int getAccessibleColumn(int index) { - try { - return unoAccessibleTable.getAccessibleColumn(index); - } catch (com.sun.star.lang.IndexOutOfBoundsException e) { - return -1; - } catch (com.sun.star.uno.RuntimeException e) { - return -1; - } - } - - /** Returns the index of a specified row and column in the table. */ - public int getAccessibleIndex(int r, int c) { - try { - return unoAccessibleTable.getAccessibleIndex(r,c); - } catch (com.sun.star.lang.IndexOutOfBoundsException e) { - return -1; - } catch (com.sun.star.uno.RuntimeException e) { - return -1; - } - } - - /** Returns the row number of an index in the table */ - public int getAccessibleRow(int index) { - try { - return unoAccessibleTable.getAccessibleRow(index); - } catch (com.sun.star.lang.IndexOutOfBoundsException e) { - return -1; - } catch (com.sun.star.uno.RuntimeException e) { - return -1; - } - } - } - - class TableCell extends java.awt.Component implements javax.accessibility.Accessible { - - protected XAccessible unoAccessible; - - public TableCell(XAccessible xAccessible) { - unoAccessible = xAccessible; - } - - public Object[] create(Object[] targetSet) { - try { - java.util.ArrayList<TableCell> list = new java.util.ArrayList<TableCell>(targetSet.length); - for (int i=0; i < targetSet.length; i++) { - XAccessible xAccessible = UnoRuntime.queryInterface( - XAccessible.class, targetSet[i]); - if (xAccessible != null) { - list.add(new TableCell(xAccessible)); - } - } - list.trimToSize(); - return list.toArray(); - } catch (com.sun.star.uno.RuntimeException e) { - return null; - } - } - - javax.accessibility.AccessibleContext accessibleContext = null; - - /** Returns the AccessibleContext associated with this object */ - public javax.accessibility.AccessibleContext getAccessibleContext() { - if (accessibleContext == null) { - try { - XAccessibleContext xAccessibleContext = unoAccessible.getAccessibleContext(); - if (xAccessibleContext != null) { - javax.accessibility.AccessibleContext ac = new AccessibleTableCell(xAccessibleContext); - ac.setAccessibleParent(Table.this); - accessibleContext = ac; - } - } catch (com.sun.star.uno.RuntimeException e) { - } - } - return accessibleContext; - } - - protected class AccessibleTableCell extends javax.accessibility.AccessibleContext { - - XAccessibleContext unoAccessibleContext; - - public AccessibleTableCell(XAccessibleContext xAccessibleContext) { - unoAccessibleContext = xAccessibleContext; - } - - /** Returns the accessible name of this object */ - public String getAccessibleName() { - try { - return unoAccessibleContext.getAccessibleName(); - } catch (com.sun.star.uno.RuntimeException e) { - return null; - } - } - - /** Sets the accessible name of this object */ - public void setAccessibleName(String name) { - // Not supported - } - - /** Returns the accessible name of this object */ - public String getAccessibleDescription() { - try { - return unoAccessibleContext.getAccessibleDescription(); - } catch (com.sun.star.uno.RuntimeException e) { - return null; - } - } - - /** Sets the accessible name of this object */ - public void setAccessibleDescription(String name) { - // Not supported - } - - /** Returns the accessible role of this object */ - public javax.accessibility.AccessibleRole getAccessibleRole() { - try { - javax.accessibility.AccessibleRole role = AccessibleRoleAdapter.getAccessibleRole( - unoAccessibleContext.getAccessibleRole()); - return (role != null) ? role : javax.accessibility.AccessibleRole.LABEL; - } catch(com.sun.star.uno.RuntimeException e) { - return null; - } - } - - /** Gets the locale of the component */ - public java.util.Locale getLocale() throws java.awt.IllegalComponentStateException { - try { - com.sun.star.lang.Locale unoLocale = unoAccessibleContext.getLocale(); - return new java.util.Locale(unoLocale.Language, unoLocale.Country); - } catch (IllegalAccessibleComponentStateException e) { - throw new java.awt.IllegalComponentStateException(e.getMessage()); - } catch (com.sun.star.uno.RuntimeException e) { - return Table.this.getLocale(); - } - } - - /** Gets the 0-based index of this object in its accessible parent */ - public int getAccessibleIndexInParent() { - try { - return unoAccessibleContext.getAccessibleIndexInParent(); - } catch (com.sun.star.uno.RuntimeException e) { - return -1; - } - } - - /** Returns the number of accessible children of the object. */ - public int getAccessibleChildrenCount() { - try { - return unoAccessibleContext.getAccessibleChildCount(); - } catch (com.sun.star.uno.RuntimeException e) { - return 0; - } - } - - /** Returns the specified Accessible child of the object. */ - public javax.accessibility.Accessible getAccessibleChild(int i) { - javax.accessibility.Accessible child = null; - try { - XAccessible xAccessible = unoAccessibleContext.getAccessibleChild(i); - // Re-use the active descandant wrapper if possible - javax.accessibility.Accessible activeDescendant = Table.this.activeDescendant; - if ((activeDescendant instanceof TableCell) && ((TableCell) activeDescendant).unoAccessible.equals(xAccessible)) { - child = activeDescendant; - } else if (xAccessible != null) { - child = new TableCell(xAccessible); - } - } catch (com.sun.star.lang.IndexOutOfBoundsException e) { - } catch (com.sun.star.uno.RuntimeException e) { - } - return child; - } - - /** Returns the state set of this object */ - public javax.accessibility.AccessibleStateSet getAccessibleStateSet() { - try { - return AccessibleStateAdapter.getAccessibleStateSet(TableCell.this, - unoAccessibleContext.getAccessibleStateSet()); - } catch (com.sun.star.uno.RuntimeException e) { - return AccessibleStateAdapter.getDefunctStateSet(); - } - } - - /** Returns the relation set of this object */ - public javax.accessibility.AccessibleRelationSet getAccessibleRelationSet() { - try { - XAccessibleRelationSet unoAccessibleRelationSet = unoAccessibleContext.getAccessibleRelationSet(); - if (unoAccessibleRelationSet == null) { - return null; - } - - javax.accessibility.AccessibleRelationSet relationSet = new javax.accessibility.AccessibleRelationSet(); - int count = unoAccessibleRelationSet.getRelationCount(); - for (int i = 0; i < count; i++) { - AccessibleRelation unoAccessibleRelation = unoAccessibleRelationSet.getRelation(i); - switch (unoAccessibleRelation.RelationType) { - case AccessibleRelationType.CONTROLLED_BY: - relationSet.add(new javax.accessibility.AccessibleRelation( - javax.accessibility.AccessibleRelation.CONTROLLED_BY, - create(unoAccessibleRelation.TargetSet))); - break; - case AccessibleRelationType.CONTROLLER_FOR: - relationSet.add(new javax.accessibility.AccessibleRelation( - javax.accessibility.AccessibleRelation.CONTROLLER_FOR, - create(unoAccessibleRelation.TargetSet))); - break; - case AccessibleRelationType.LABELED_BY: - relationSet.add(new javax.accessibility.AccessibleRelation( - javax.accessibility.AccessibleRelation.LABELED_BY, - create(unoAccessibleRelation.TargetSet))); - break; - case AccessibleRelationType.LABEL_FOR: - relationSet.add(new javax.accessibility.AccessibleRelation( - javax.accessibility.AccessibleRelation.LABEL_FOR, - create(unoAccessibleRelation.TargetSet))); - break; - case AccessibleRelationType.MEMBER_OF: - relationSet.add(new javax.accessibility.AccessibleRelation( - javax.accessibility.AccessibleRelation.MEMBER_OF, - create(unoAccessibleRelation.TargetSet))); - break; - default: - break; - } - } - return relationSet; - } catch (com.sun.star.lang.IndexOutOfBoundsException e) { - return null; - } catch (com.sun.star.uno.RuntimeException e) { - return null; - } - } - - /** Gets the AccessibleComponent associated with this object that has a graphical representation */ - public javax.accessibility.AccessibleComponent getAccessibleComponent() { - try { - XAccessibleComponent unoAccessibleComponent = UnoRuntime.queryInterface(XAccessibleComponent.class, unoAccessibleContext); - return (unoAccessibleComponent != null) ? - new AccessibleComponentImpl(unoAccessibleComponent) : null; - } catch (com.sun.star.uno.RuntimeException e) { - return null; - } - } - - /** Gets the AccessibleAction associated with this object that has a graphical representation */ - public javax.accessibility.AccessibleAction getAccessibleAction() { - try { - XAccessibleAction unoAccessibleAction = UnoRuntime.queryInterface(XAccessibleAction.class, unoAccessibleContext); - return (unoAccessibleAction != null) ? - new AccessibleActionImpl(unoAccessibleAction) : null; - } catch (com.sun.star.uno.RuntimeException e) { - return null; - } - } - - /** Gets the AccessibleText associated with this object that has a graphical representation */ - public javax.accessibility.AccessibleText getAccessibleText() { - - if (disposed) - return null; - - try { - XAccessibleText unoAccessibleText = UnoRuntime.queryInterface(XAccessibleText.class, unoAccessibleContext); - return (unoAccessibleText != null) ? - new AccessibleTextImpl(unoAccessibleText) : null; - } catch (com.sun.star.uno.RuntimeException e) { - return null; - } - } - - /** Gets the AccessibleValue associated with this object that has a graphical representation */ - public javax.accessibility.AccessibleValue getAccessibleValue() { - try { - XAccessibleValue unoAccessibleValue = UnoRuntime.queryInterface(XAccessibleValue.class, unoAccessibleContext); - return (unoAccessibleValue != null) ? - new AccessibleValueImpl(unoAccessibleValue) : null; - } catch (com.sun.star.uno.RuntimeException e) { - return null; - } - } - - /** Gets the AccessibleText associated with this object presenting text on the display */ - public javax.accessibility.AccessibleIcon[] getAccessibleIcon() { - try { - XAccessibleImage unoAccessibleImage = UnoRuntime.queryInterface(XAccessibleImage.class, unoAccessibleContext); - if (unoAccessibleImage != null) { - javax.accessibility.AccessibleIcon[] icons = { new AccessibleIconImpl(unoAccessibleImage) }; - return icons; - } - } catch (com.sun.star.uno.RuntimeException e) { - } - return null; - } - } - } -} - diff --git a/accessibility/bridge/org/openoffice/java/accessibility/TextComponent.java b/accessibility/bridge/org/openoffice/java/accessibility/TextComponent.java deleted file mode 100644 index a9c27d280772..000000000000 --- a/accessibility/bridge/org/openoffice/java/accessibility/TextComponent.java +++ /dev/null @@ -1,182 +0,0 @@ -/* - * 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 . - */ - -package org.openoffice.java.accessibility; - -import com.sun.star.uno.UnoRuntime; -import com.sun.star.accessibility.*; - -/** - */ -public class TextComponent extends Component implements javax.accessibility.Accessible { - - protected TextComponent(XAccessible xAccessible, XAccessibleContext xAccessibleContext) { - super(xAccessible, xAccessibleContext); - } - - protected class AccessibleTextComponentListener extends AccessibleUNOComponentListener { - - protected AccessibleTextComponentListener() { - super(); - } - - protected void setComponentState(short state, boolean enable) { - switch (state) { - case AccessibleStateType.EDITABLE: - fireStatePropertyChange(javax.accessibility.AccessibleState.EDITABLE, enable); - break; - case AccessibleStateType.MULTI_LINE: - fireStatePropertyChange(javax.accessibility.AccessibleState.MULTI_LINE, enable); - break; - case AccessibleStateType.SINGLE_LINE: - break; - default: - super.setComponentState(state, enable); - break; - } - } - } - - protected XAccessibleEventListener createEventListener() { - return new AccessibleTextComponentListener(); - } - - /** Creates the AccessibleContext associated with this object */ - public javax.accessibility.AccessibleContext createAccessibleContext() { - return new AccessibleTextComponent(); - } - - protected class AccessibleTextComponent extends AccessibleUNOComponent { - - /** - * Though the class is abstract, this should be called by all sub-classes - */ - protected AccessibleTextComponent() { - super(); - } - - /* - * AccessibleContext - */ - - /** Gets the role of this object */ - public javax.accessibility.AccessibleRole getAccessibleRole() { - return javax.accessibility.AccessibleRole.TEXT; - } - - /** Gets the AccessibleText associated with this object presenting text on the display */ - public javax.accessibility.AccessibleText getAccessibleText() { - - if (disposed) - return null; - - try { - XAccessibleText unoAccessibleText = UnoRuntime.queryInterface(XAccessibleText.class,unoAccessibleComponent); - if (unoAccessibleText != null) { - return new AccessibleTextImpl(unoAccessibleText); - } else { - return null; - } - } catch (com.sun.star.uno.RuntimeException e) { - return null; - } - } - - /** Gets the AccessibleEditableText associated with this object presenting text on the display */ - public javax.accessibility.AccessibleEditableText getAccessibleEditableText() { - try { - XAccessibleEditableText unoAccessibleText = UnoRuntime.queryInterface(XAccessibleEditableText.class,unoAccessibleComponent); - if (unoAccessibleText != null) { - return new AccessibleEditableTextImpl(unoAccessibleText); - } else { - return null; - } - } catch (com.sun.star.uno.RuntimeException e) { - return null; - } - } - - /** Gets the AccessibleAction associated with this object that has a graphical representation */ - public javax.accessibility.AccessibleAction getAccessibleAction() { - try { - XAccessibleAction unoAccessibleAction = UnoRuntime.queryInterface(XAccessibleAction.class, unoAccessibleComponent); - return (unoAccessibleAction != null) ? - new AccessibleActionImpl(unoAccessibleAction) : null; - } catch (com.sun.star.uno.RuntimeException e) { - return null; - } - } - - /** Returns the relation set of this object */ - public javax.accessibility.AccessibleRelationSet getAccessibleRelationSet() { - try { - XAccessibleRelationSet unoAccessibleRelationSet = - unoAccessible.getAccessibleContext().getAccessibleRelationSet(); - if (unoAccessibleRelationSet == null) { - return super.getAccessibleRelationSet(); - } - - javax.accessibility.AccessibleRelationSet relationSet = new javax.accessibility.AccessibleRelationSet(); - int count = unoAccessibleRelationSet.getRelationCount(); - for (int i = 0; i < count; i++) { - AccessibleRelation unoAccessibleRelation = unoAccessibleRelationSet.getRelation(i); - switch (unoAccessibleRelation.RelationType) { - case AccessibleRelationType.CONTROLLED_BY: - relationSet.add(new javax.accessibility.AccessibleRelation( - javax.accessibility.AccessibleRelation.CONTROLLED_BY, - getAccessibleComponents(unoAccessibleRelation.TargetSet))); - break; - case AccessibleRelationType.CONTROLLER_FOR: - relationSet.add(new javax.accessibility.AccessibleRelation( - javax.accessibility.AccessibleRelation.CONTROLLER_FOR, - getAccessibleComponents(unoAccessibleRelation.TargetSet))); - break; - case AccessibleRelationType.LABELED_BY: - relationSet.add(new javax.accessibility.AccessibleRelation( - javax.accessibility.AccessibleRelation.LABELED_BY, - getAccessibleComponents(unoAccessibleRelation.TargetSet))); - break; - case AccessibleRelationType.MEMBER_OF: - relationSet.add(new javax.accessibility.AccessibleRelation( - javax.accessibility.AccessibleRelation.MEMBER_OF, - getAccessibleComponents(unoAccessibleRelation.TargetSet))); - break; - case AccessibleRelationType.CONTENT_FLOWS_TO: - relationSet.add(new javax.accessibility.AccessibleRelation( - "flowsTo", - getAccessibleComponents(unoAccessibleRelation.TargetSet))); - break; - case AccessibleRelationType.CONTENT_FLOWS_FROM: - relationSet.add(new javax.accessibility.AccessibleRelation( - "flowsFrom", - getAccessibleComponents(unoAccessibleRelation.TargetSet))); - break; - default: - break; - } - } - return relationSet; - } catch (com.sun.star.lang.IndexOutOfBoundsException e) { - return super.getAccessibleRelationSet(); - } catch (com.sun.star.uno.RuntimeException e) { - return super.getAccessibleRelationSet(); - } - } - } -} - diff --git a/accessibility/bridge/org/openoffice/java/accessibility/ToggleButton.java b/accessibility/bridge/org/openoffice/java/accessibility/ToggleButton.java deleted file mode 100644 index c433315665ff..000000000000 --- a/accessibility/bridge/org/openoffice/java/accessibility/ToggleButton.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * 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 . - */ -package org.openoffice.java.accessibility; - -import com.sun.star.accessibility.*; -import com.sun.star.uno.*; - - -class ToggleButton extends AbstractButton implements javax.accessibility.Accessible { - public ToggleButton(XAccessible xAccessible, XAccessibleContext xAccessibleContext) { - super(xAccessible, xAccessibleContext); - } - - /** Creates the AccessibleContext associated with this object */ - public javax.accessibility.AccessibleContext createAccessibleContext() { - return new AccessibleToggleButton(); - } - - protected class AccessibleToggleButton extends AccessibleAbstractButton { - /** Gets the role of this object */ - public javax.accessibility.AccessibleRole getAccessibleRole() { - return javax.accessibility.AccessibleRole.TOGGLE_BUTTON; - } - - /** Gets the AccessibleValue associated with this object that has a graphical representation */ - public javax.accessibility.AccessibleValue getAccessibleValue() { - try { - XAccessibleValue unoAccessibleValue = UnoRuntime.queryInterface(XAccessibleValue.class, - unoAccessibleContext); - - return (unoAccessibleValue != null) - ? new AccessibleValueImpl(unoAccessibleValue) : null; - } catch (com.sun.star.uno.RuntimeException e) { - return null; - } - } - } -} diff --git a/accessibility/bridge/org/openoffice/java/accessibility/ToolTip.java b/accessibility/bridge/org/openoffice/java/accessibility/ToolTip.java deleted file mode 100644 index 1264619b1b7d..000000000000 --- a/accessibility/bridge/org/openoffice/java/accessibility/ToolTip.java +++ /dev/null @@ -1,105 +0,0 @@ -/* - * 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 . - */ -package org.openoffice.java.accessibility; - -import com.sun.star.accessibility.*; -import com.sun.star.uno.*; - - -/** - */ -public class ToolTip extends Component implements javax.accessibility.Accessible { - protected ToolTip(XAccessible xAccessible, XAccessibleContext xAccessibleContext) { - super(xAccessible, xAccessibleContext); - } - - /** Creates the AccessibleContext associated with this object */ - public javax.accessibility.AccessibleContext createAccessibleContext() { - return new AccessibleToolTip(); - } - - protected class AccessibleToolTip extends AccessibleUNOComponent { - - /* - * AccessibleContext - */ - - /** Gets the role of this object */ - public javax.accessibility.AccessibleRole getAccessibleRole() { - return javax.accessibility.AccessibleRole.TOOL_TIP; - } - - /** Gets the AccessibleText associated with this object presenting text on the display */ - public javax.accessibility.AccessibleText getAccessibleText() { - - if (disposed) - return null; - - try { - XAccessibleText unoAccessibleText = UnoRuntime.queryInterface(XAccessibleText.class, - unoAccessibleComponent); - - if (unoAccessibleText != null) { - return new AccessibleTextImpl(unoAccessibleText); - } else { - return null; - } - } catch (com.sun.star.uno.RuntimeException e) { - return null; - } - } - - /** Returns the relation set of this object */ - - /* - public javax.accessibility.AccessibleRelationSet getAccessibleRelationSet() { - try { - XAccessibleRelationSet unoAccessibleRelationSet = unoAccessibleContext.getAccessibleRelationSet(); - if (unoAccessibleRelationSet == null) { - return null; - } - - javax.accessibility.AccessibleRelationSet relationSet = new javax.accessibility.AccessibleRelationSet(); - int count = unoAccessibleRelationSet.getRelationCount(); - for (int i = 0; i < count; i++) { - AccessibleRelation unoAccessibleRelation = unoAccessibleRelationSet.getRelation(i); - switch (unoAccessibleRelation.RelationType) { - case AccessibleRelationType.LABEL_FOR: - relationSet.add(new javax.accessibility.AccessibleRelation( - javax.accessibility.AccessibleRelation.LABEL_FOR, - getAccessibleComponents(unoAccessibleRelation.TargetSet))); - break; - case AccessibleRelationType.MEMBER_OF: - relationSet.add(new javax.accessibility.AccessibleRelation( - javax.accessibility.AccessibleRelation.MEMBER_OF, - getAccessibleComponents(unoAccessibleRelation.TargetSet))); - break; - default: - break; - } - } - return relationSet; - } catch (com.sun.star.lang.IndexOutOfBoundsException e) { - return null; - } catch (com.sun.star.uno.RuntimeException e) { - return null; - } - } - */ - } -} diff --git a/accessibility/bridge/org/openoffice/java/accessibility/Tree.java b/accessibility/bridge/org/openoffice/java/accessibility/Tree.java deleted file mode 100644 index a0a59c91694e..000000000000 --- a/accessibility/bridge/org/openoffice/java/accessibility/Tree.java +++ /dev/null @@ -1,751 +0,0 @@ -/* - * 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 . - */ - -package org.openoffice.java.accessibility; - -import javax.accessibility.AccessibleContext; -import javax.accessibility.AccessibleState; - -import com.sun.star.uno.AnyConverter; -import com.sun.star.uno.UnoRuntime; -import com.sun.star.accessibility.*; - -public class Tree extends DescendantManager implements javax.accessibility.Accessible { - - protected Tree(XAccessible xAccessible, XAccessibleContext xAccessibleContext) { - super(xAccessible, xAccessibleContext); - } - - protected void setActiveDescendant(javax.accessibility.Accessible descendant) { - javax.accessibility.Accessible oldAD = activeDescendant; - activeDescendant = descendant; - firePropertyChange(AccessibleContext.ACCESSIBLE_ACTIVE_DESCENDANT_PROPERTY, - oldAD, descendant); - } - - protected void setActiveDescendant(Object any) { - javax.accessibility.Accessible descendant = null; - try { - if (AnyConverter.isObject(any)) { - XAccessible unoAccessible = (XAccessible) AnyConverter.toObject( - AccessibleObjectFactory.XAccessibleType, any); - if (unoAccessible != null) { - // FIXME: have to handle non transient objects here .. - descendant = new TreeItem(unoAccessible); - } - } - setActiveDescendant(descendant); - } catch (com.sun.star.lang.IllegalArgumentException e) { - } - } - - protected void add(XAccessible unoAccessible) { - if (unoAccessible != null) { - firePropertyChange(AccessibleContext.ACCESSIBLE_CHILD_PROPERTY, - null, new TreeItem(unoAccessible)); - } - } - - protected void remove(XAccessible unoAccessible) { - if (unoAccessible != null) { - firePropertyChange(AccessibleContext.ACCESSIBLE_CHILD_PROPERTY, - new TreeItem(unoAccessible), null); - } - } - - protected void add(Object any) { - try { - add((XAccessible) AnyConverter.toObject(AccessibleObjectFactory.XAccessibleType, any)); - } catch (com.sun.star.lang.IllegalArgumentException e) { - } - } - - protected void remove(Object any) { - try { - remove((XAccessible) AnyConverter.toObject(AccessibleObjectFactory.XAccessibleType, any)); - } catch (com.sun.star.lang.IllegalArgumentException e) { - } - } - - /** - * Update the proxy objects appropriatly on property change events - */ - protected class AccessibleTreeListener extends AccessibleDescendantManagerListener { - - protected AccessibleTreeListener() { - super(); - } - - /** Called by OpenOffice process to notify property changes */ - public void notifyEvent(AccessibleEventObject event) { - switch (event.EventId) { - case AccessibleEventId.ACTIVE_DESCENDANT_CHANGED: - setActiveDescendant(event.NewValue); - break; - case AccessibleEventId.CHILD: - if (AnyConverter.isObject(event.OldValue)) { - remove(event.OldValue); - } - if (AnyConverter.isObject(event.NewValue)) { - add(event.NewValue); - } - break; - - case AccessibleEventId.LISTBOX_ENTRY_EXPANDED: - firePropertyChange(AccessibleContext.ACCESSIBLE_STATE_PROPERTY, - AccessibleState.COLLAPSED, AccessibleState.EXPANDED); - break; - - case AccessibleEventId.LISTBOX_ENTRY_COLLAPSED: - firePropertyChange(AccessibleContext.ACCESSIBLE_STATE_PROPERTY, - AccessibleState.EXPANDED, AccessibleState.COLLAPSED); - break; - - default: - super.notifyEvent(event); - } - } - } - - protected XAccessibleEventListener createEventListener() { - return new AccessibleTreeListener(); - } - - /** Creates the AccessibleContext associated with this object */ - public javax.accessibility.AccessibleContext createAccessibleContext() { - return new AccessibleTree(); - } - - protected class AccessibleTree extends AccessibleDescendantManager implements javax.accessibility.AccessibleExtendedTable { - - protected XAccessibleTable unoAccessibleTable; - - public AccessibleTree() { - unoAccessibleTable = UnoRuntime.queryInterface(XAccessibleTable.class, unoAccessibleContext); - } - - /* - * AccessibleContext - */ - - /** Gets the role of this object */ - public javax.accessibility.AccessibleRole getAccessibleRole() { - return javax.accessibility.AccessibleRole.TREE; - } - - /** Returns the AccessibleTable interface of this object */ - public javax.accessibility.AccessibleTable getAccessibleTable() { - return ( unoAccessibleTable != null ) ? this : null; - } - - /** Returns the specified Accessible child of the object */ - public javax.accessibility.Accessible getAccessibleChild(int i) { - javax.accessibility.Accessible child = null; - try { - XAccessible xAccessible = unoAccessibleContext.getAccessibleChild(i); - if (xAccessible != null) { - // Re-use the active descandant wrapper if possible - javax.accessibility.Accessible activeDescendant = Tree.this.activeDescendant; - if ((activeDescendant instanceof TreeItem) && xAccessible.equals(((TreeItem) activeDescendant).unoAccessible)) { - child = activeDescendant; - } else { - child = new TreeItem(xAccessible); - } - } - } catch (com.sun.star.lang.IndexOutOfBoundsException e) { - } catch (com.sun.star.uno.RuntimeException e) { - } - return child; - } - - /* - * AccessibleComponent - */ - - /** Returns the Accessible child, if one exists, contained at the local coordinate Point */ - public javax.accessibility.Accessible getAccessibleAt(java.awt.Point p) { - javax.accessibility.Accessible child = null; - try { - XAccessible xAccessible = unoAccessibleComponent.getAccessibleAtPoint( - new com.sun.star.awt.Point(p.x, p.y)); - if (xAccessible != null) { - // Re-use the active descandant wrapper if possible - javax.accessibility.Accessible activeDescendant = Tree.this.activeDescendant; - if ((activeDescendant instanceof TreeItem) && xAccessible.equals(((TreeItem) activeDescendant).unoAccessible)) { - child = activeDescendant; - } else { - child = new TreeItem(xAccessible); - } - } - } catch (com.sun.star.uno.RuntimeException e) { - } - return child; - } - - /* - * AccessibleSelection - */ - - /** Returns an Accessible representing the specified selected child of the object */ - public javax.accessibility.Accessible getAccessibleSelection(int i) { - javax.accessibility.Accessible child = null; - try { - XAccessible xAccessible = unoAccessibleContext.getAccessibleChild(i); - if (xAccessible != null) { - // Re-use the active descandant wrapper if possible - javax.accessibility.Accessible activeDescendant = Tree.this.activeDescendant; - if ((activeDescendant instanceof TreeItem) && xAccessible.equals(((TreeItem) activeDescendant).unoAccessible)) { - child = activeDescendant; - } else { - child = new TreeItem(xAccessible); - } - } - } catch (com.sun.star.lang.IndexOutOfBoundsException e) { - } catch (com.sun.star.uno.RuntimeException e) { - } - return child; - } - - /* - * AccessibleTable - */ - - /** Returns the Accessible at a specified row and column in the table. */ - public javax.accessibility.Accessible getAccessibleAt(int r, int c) { - javax.accessibility.Accessible child = null; - try { - XAccessible xAccessible = unoAccessibleTable.getAccessibleCellAt(r,c); - if (xAccessible != null) { - // Re-use the active descandant wrapper if possible - javax.accessibility.Accessible activeDescendant = Tree.this.activeDescendant; - if ((activeDescendant instanceof TreeItem) && xAccessible.equals(((TreeItem) activeDescendant).unoAccessible)) { - child = activeDescendant; - } else { - child = new TreeItem(xAccessible); - } - } - } catch (com.sun.star.lang.IndexOutOfBoundsException e) { - } catch (com.sun.star.uno.RuntimeException e) { - } - return child; - } - - /** Returns the caption for the table. */ - public javax.accessibility.Accessible getAccessibleCaption() { - // Not yet supported. - return null; - } - - /** Returns the number of columns in the table. */ - public int getAccessibleColumnCount() { - try { - return unoAccessibleTable.getAccessibleColumnCount(); - } catch (com.sun.star.uno.RuntimeException e) { - return 0; - } - } - - /** Returns the description text of the specified column in the table. */ - public javax.accessibility.Accessible getAccessibleColumnDescription(int c) { - try { - return new javax.swing.JLabel( - unoAccessibleTable.getAccessibleColumnDescription(c)); - } catch (com.sun.star.lang.IndexOutOfBoundsException e) { - return null; - } catch (com.sun.star.uno.RuntimeException e) { - return null; - } - } - - /** - * Returns the number of columns occupied by the Accessible - * at a specified row and column in the table. - */ - public int getAccessibleColumnExtentAt(int r, int c) { - try { - return unoAccessibleTable.getAccessibleColumnExtentAt(r,c); - } catch (com.sun.star.lang.IndexOutOfBoundsException e) { - return 0; - } catch (com.sun.star.uno.RuntimeException e) { - return 0; - } - } - - /** Returns the column headers as an AccessibleTable. */ - public javax.accessibility.AccessibleTable getAccessibleColumnHeader() { - // Not yet supported - return null; - } - - /** Returns the number of rows in the table. */ - public int getAccessibleRowCount() { - try { - return unoAccessibleTable.getAccessibleRowCount(); - } catch (com.sun.star.uno.RuntimeException e) { - return 0; - } - } - - /** Returns the description of the specified row in the table. */ - public javax.accessibility.Accessible getAccessibleRowDescription(int r) { - try { - return new javax.swing.JLabel( - unoAccessibleTable.getAccessibleRowDescription(r)); - } catch (com.sun.star.lang.IndexOutOfBoundsException e) { - return null; - } catch (com.sun.star.uno.RuntimeException e) { - return null; - } - } - - /** - * Returns the number of rows occupied by the Accessible - * at a specified row and column in the table. - */ - public int getAccessibleRowExtentAt(int r, int c) { - try { - return unoAccessibleTable.getAccessibleRowExtentAt(r,c); - } catch (com.sun.star.lang.IndexOutOfBoundsException e) { - return 0; - } catch (com.sun.star.uno.RuntimeException e) { - return 0; - } - } - - /** Returns the row headers as an AccessibleTable. */ - public javax.accessibility.AccessibleTable getAccessibleRowHeader() { - // Not yet supported - return null; - } - - /** Returns the summary description of the table. */ - public javax.accessibility.Accessible getAccessibleSummary() { - // Not yet supported. - return null; - } - - /** Returns the selected columns in a table. */ - public int[] getSelectedAccessibleColumns() { - try { - return unoAccessibleTable.getSelectedAccessibleColumns(); - } catch (com.sun.star.uno.RuntimeException e) { - return null; - } - } - - /** Returns the selected rows in a table. */ - public int[] getSelectedAccessibleRows() { - try { - return unoAccessibleTable.getSelectedAccessibleRows(); - } catch (com.sun.star.uno.RuntimeException e) { - return null; - } - } - - /** Returns a boolean value indicating whether the specified column is selected. */ - public boolean isAccessibleColumnSelected(int c) { - try { - return unoAccessibleTable.isAccessibleColumnSelected(c); - } catch (com.sun.star.lang.IndexOutOfBoundsException e) { - return false; - } catch (com.sun.star.uno.RuntimeException e) { - return false; - } - } - - /** Returns a boolean value indicating whether the specified row is selected. */ - public boolean isAccessibleRowSelected(int r) { - try { - return unoAccessibleTable.isAccessibleRowSelected(r); - } catch (com.sun.star.lang.IndexOutOfBoundsException e) { - return false; - } catch (com.sun.star.uno.RuntimeException e) { - return false; - } - } - - /** - * Returns a boolean value indicating whether the accessible - * at a specified row and column is selected. - */ - public boolean isAccessibleSelected(int r, int c) { - try { - return unoAccessibleTable.isAccessibleSelected(r,c); - } catch (com.sun.star.lang.IndexOutOfBoundsException e) { - return false; - } catch (com.sun.star.uno.RuntimeException e) { - return false; - } - } - - /** Sets the caption for the table. */ - public void setAccessibleCaption(javax.accessibility.Accessible accessible) { - // Not supported by the UNO Accessibility API - } - - /** Sets the description text of the specified column in the table. */ - public void setAccessibleColumnDescription(int param, javax.accessibility.Accessible accessible) { - // Not supported by the UNO Accessibility API - } - - /** Sets the column headers. */ - public void setAccessibleColumnHeader(javax.accessibility.AccessibleTable accessibleTable) { - // Not supported by the UNO Accessibility API - } - - /** Sets the description text of the specified row of the table. */ - public void setAccessibleRowDescription(int param, javax.accessibility.Accessible accessible) { - // Not supported by the UNO Accessibility API - } - - /** Sets the row headers. */ - public void setAccessibleRowHeader(javax.accessibility.AccessibleTable accessibleTable) { - // Not supported by the UNO Accessibility API - } - - /** Sets the summary description of the table */ - public void setAccessibleSummary(javax.accessibility.Accessible accessible) { - // Not supported by the UNO Accessibility API - } - - /** Returns the column number of an index in the table */ - public int getAccessibleColumn(int index) { - try { - return unoAccessibleTable.getAccessibleColumn(index); - } catch (com.sun.star.lang.IndexOutOfBoundsException e) { - return -1; - } catch (com.sun.star.uno.RuntimeException e) { - return -1; - } - } - - /** Returns the index of a specified row and column in the table. */ - public int getAccessibleIndex(int r, int c) { - try { - return unoAccessibleTable.getAccessibleIndex(r,c); - } catch (com.sun.star.lang.IndexOutOfBoundsException e) { - return -1; - } catch (com.sun.star.uno.RuntimeException e) { - return -1; - } - } - - /** Returns the row number of an index in the table */ - public int getAccessibleRow(int index) { - try { - return unoAccessibleTable.getAccessibleRow(index); - } catch (com.sun.star.lang.IndexOutOfBoundsException e) { - return -1; - } catch (com.sun.star.uno.RuntimeException e) { - return -1; - } - } - } - - class TreeItem extends java.awt.Component implements javax.accessibility.Accessible { - - protected XAccessible unoAccessible; - - public TreeItem(XAccessible xAccessible) { - unoAccessible = xAccessible; - } - - public Object[] create(Object[] targetSet) { - try { - java.util.ArrayList<TreeItem> list = new java.util.ArrayList<TreeItem>(targetSet.length); - for (int i=0; i < targetSet.length; i++) { - XAccessible xAccessible = UnoRuntime.queryInterface( - XAccessible.class, targetSet[i]); - if (xAccessible != null) { - list.add(new TreeItem(xAccessible)); - } - } - list.trimToSize(); - return list.toArray(); - } catch (com.sun.star.uno.RuntimeException e) { - return null; - } - } - - javax.accessibility.AccessibleContext accessibleContext = null; - - /** Returns the AccessibleContext associated with this object */ - public javax.accessibility.AccessibleContext getAccessibleContext() { - if (accessibleContext == null) { - try { - XAccessibleContext xAccessibleContext = unoAccessible.getAccessibleContext(); - if (xAccessibleContext != null) { - javax.accessibility.AccessibleContext ac = new AccessibleTreeItem(xAccessibleContext); - ac.setAccessibleParent(Tree.this); - accessibleContext = ac; - } - } catch (com.sun.star.uno.RuntimeException e) { - } - } - return accessibleContext; - } - - protected class AccessibleTreeItem extends javax.accessibility.AccessibleContext - implements javax.accessibility.AccessibleSelection { - - XAccessibleContext unoAccessibleContext; - XAccessibleSelection unoAccessibleSelection; - - public AccessibleTreeItem(XAccessibleContext xAccessibleContext) { - unoAccessibleContext = xAccessibleContext; - unoAccessibleSelection = UnoRuntime.queryInterface(XAccessibleSelection.class, xAccessibleContext); - } - - /** Returns the accessible name of this object */ - public String getAccessibleName() { - try { - return unoAccessibleContext.getAccessibleName(); - } catch (com.sun.star.uno.RuntimeException e) { - return null; - } - } - - /** Sets the accessible name of this object */ - public void setAccessibleName(String name) { - // Not supported - } - - /** Returns the accessible name of this object */ - public String getAccessibleDescription() { - try { - return unoAccessibleContext.getAccessibleDescription(); - } catch (com.sun.star.uno.RuntimeException e) { - return null; - } - } - - /** Sets the accessible name of this object */ - public void setAccessibleDescription(String name) { - // Not supported - } - - /** Returns the accessible role of this object */ - public javax.accessibility.AccessibleRole getAccessibleRole() { - try { - javax.accessibility.AccessibleRole role = AccessibleRoleAdapter.getAccessibleRole( - unoAccessibleContext.getAccessibleRole()); - return (role != null) ? role : javax.accessibility.AccessibleRole.LABEL; - } catch(com.sun.star.uno.RuntimeException e) { - return null; - } - } - - /** Gets the locale of the component */ - public java.util.Locale getLocale() throws java.awt.IllegalComponentStateException { - try { - com.sun.star.lang.Locale unoLocale = unoAccessibleContext.getLocale(); - return new java.util.Locale(unoLocale.Language, unoLocale.Country); - } catch (IllegalAccessibleComponentStateException e) { - throw new java.awt.IllegalComponentStateException(e.getMessage()); - } catch (com.sun.star.uno.RuntimeException e) { - return Tree.this.getLocale(); - } - } - - /** Gets the 0-based index of this object in its accessible parent */ - public int getAccessibleIndexInParent() { - try { - return unoAccessibleContext.getAccessibleIndexInParent(); - } catch (com.sun.star.uno.RuntimeException e) { - return -1; - } - } - - /** Returns the number of accessible children of the object. */ - public int getAccessibleChildrenCount() { - try { - return unoAccessibleContext.getAccessibleChildCount(); - } catch (com.sun.star.uno.RuntimeException e) { - return 0; - } - } - - /** Returns the specified Accessible child of the object. */ - public javax.accessibility.Accessible getAccessibleChild(int i) { - javax.accessibility.Accessible child = null; - try { - XAccessible xAccessible = unoAccessibleContext.getAccessibleChild(i); - // Re-use the active descandant wrapper if possible - javax.accessibility.Accessible activeDescendant = Tree.this.activeDescendant; - if ((activeDescendant instanceof TreeItem) && ((TreeItem) activeDescendant).unoAccessible.equals(xAccessible)) { - child = activeDescendant; - } else if (xAccessible != null) { - child = new TreeItem(xAccessible); - } - } catch (com.sun.star.lang.IndexOutOfBoundsException e) { - } catch (com.sun.star.uno.RuntimeException e) { - } - return child; - } - - /** Returns the state set of this object */ - public javax.accessibility.AccessibleStateSet getAccessibleStateSet() { - try { - return AccessibleStateAdapter.getAccessibleStateSet(TreeItem.this, - unoAccessibleContext.getAccessibleStateSet()); - } catch (com.sun.star.uno.RuntimeException e) { - return AccessibleStateAdapter.getDefunctStateSet(); - } - } - - /** Gets the AccessibleComponent associated with this object that has a graphical representation */ - public javax.accessibility.AccessibleComponent getAccessibleComponent() { - try { - XAccessibleComponent unoAccessibleComponent = UnoRuntime.queryInterface(XAccessibleComponent.class, unoAccessibleContext); - return (unoAccessibleComponent != null) ? - new AccessibleComponentImpl(unoAccessibleComponent) : null; - } catch (com.sun.star.uno.RuntimeException e) { - return null; - } - } - - /** Returns the AccessibleSelection interface for this object */ - public javax.accessibility.AccessibleSelection getAccessibleSelection() { - return (unoAccessibleSelection != null) ? this : null; - } - - /** Gets the AccessibleAction associated with this object that has a graphical representation */ - public javax.accessibility.AccessibleAction getAccessibleAction() { - try { - XAccessibleAction unoAccessibleAction = UnoRuntime.queryInterface(XAccessibleAction.class, unoAccessibleContext); - return (unoAccessibleAction != null) ? - new AccessibleActionImpl(unoAccessibleAction) : null; - } catch (com.sun.star.uno.RuntimeException e) { - return null; - } - } - - /** Gets the AccessibleText associated with this object that has a graphical representation */ - public javax.accessibility.AccessibleText getAccessibleText() { - - if (disposed) - return null; - - try { - XAccessibleText unoAccessibleText = UnoRuntime.queryInterface(XAccessibleText.class, unoAccessibleContext); - return (unoAccessibleText != null) ? - new AccessibleTextImpl(unoAccessibleText) : null; - } catch (com.sun.star.uno.RuntimeException e) { - return null; - } - } - - /** Gets the AccessibleValue associated with this object that has a graphical representation */ - public javax.accessibility.AccessibleValue getAccessibleValue() { - try { - XAccessibleValue unoAccessibleValue = UnoRuntime.queryInterface(XAccessibleValue.class, unoAccessibleContext); - return (unoAccessibleValue != null) ? - new AccessibleValueImpl(unoAccessibleValue) : null; - } catch (com.sun.star.uno.RuntimeException e) { - return null; - } - } - - /** Gets the AccessibleText associated with this object presenting text on the display */ - public javax.accessibility.AccessibleIcon[] getAccessibleIcon() { - try { - XAccessibleImage unoAccessibleImage = UnoRuntime.queryInterface(XAccessibleImage.class, unoAccessibleContext); - if (unoAccessibleImage != null) { - javax.accessibility.AccessibleIcon[] icons = { new AccessibleIconImpl(unoAccessibleImage) }; - return icons; - } - } catch (com.sun.star.uno.RuntimeException e) { - } - return null; - } - - /* - * AccessibleSelection - */ - - /** Returns an Accessible representing the specified selected child of the object */ - public javax.accessibility.Accessible getAccessibleSelection(int i) { - javax.accessibility.Accessible child = null; - try { - XAccessible xAccessible = unoAccessibleContext.getAccessibleChild(i); - if (xAccessible != null) { - child = new TreeItem(xAccessible); - } - } catch (com.sun.star.lang.IndexOutOfBoundsException e) { - } catch (com.sun.star.uno.RuntimeException e) { - } - return child; - } - - /** Adds the specified Accessible child of the object to the object's selection */ - public void addAccessibleSelection(int i) { - try { - unoAccessibleSelection.selectAccessibleChild(i); - } catch (com.sun.star.lang.IndexOutOfBoundsException e) { - } catch (com.sun.star.uno.RuntimeException e) { - } - } - - /** Clears the selection in the object, so that no children in the object are selected */ - public void clearAccessibleSelection() { - try { - unoAccessibleSelection.clearAccessibleSelection(); - } catch (com.sun.star.uno.RuntimeException e) { - } - } - - /** Returns the number of Accessible children currently selected */ - public int getAccessibleSelectionCount() { - try { - return unoAccessibleSelection.getSelectedAccessibleChildCount(); - } catch (com.sun.star.uno.RuntimeException e) { - return 0; - } - } - - /** Determines if the current child of this object is selected */ - public boolean isAccessibleChildSelected(int i) { - try { - return unoAccessibleSelection.isAccessibleChildSelected(i); - } catch (com.sun.star.lang.IndexOutOfBoundsException e) { - return false; - } catch (com.sun.star.uno.RuntimeException e) { - return false; - } - } - - /** Removes the specified child of the object from the object's selection */ - public void removeAccessibleSelection(int i) { - try { - unoAccessibleSelection.deselectAccessibleChild(i); - } catch (com.sun.star.lang.IndexOutOfBoundsException e) { - } catch (com.sun.star.uno.RuntimeException e) { - } - } - - /** Causes every child of the object to be selected if the object supports multiple selection */ - public void selectAllAccessibleSelection() { - try { - unoAccessibleSelection.selectAllAccessibleChildren(); - } catch (com.sun.star.uno.RuntimeException e) { - } - } - } - } -} - diff --git a/accessibility/bridge/org/openoffice/java/accessibility/Window.java b/accessibility/bridge/org/openoffice/java/accessibility/Window.java deleted file mode 100644 index 137818ec10d5..000000000000 --- a/accessibility/bridge/org/openoffice/java/accessibility/Window.java +++ /dev/null @@ -1,564 +0,0 @@ -/* - * 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 . - */ - -package org.openoffice.java.accessibility; - -import com.sun.star.uno.*; -import com.sun.star.accessibility.*; - -public class Window extends java.awt.Window implements javax.accessibility.Accessible, NativeFrame { - protected XAccessibleComponent unoAccessibleComponent; - - boolean opened = false; - boolean visible = false; - - java.awt.EventQueue eventQueue = null; - - public Window(java.awt.Window owner, XAccessibleComponent xAccessibleComponent) { - super(owner); - initialize(xAccessibleComponent); - } - - private void initialize(XAccessibleComponent xAccessibleComponent) { - unoAccessibleComponent = xAccessibleComponent; - eventQueue = java.awt.Toolkit.getDefaultToolkit().getSystemEventQueue(); - XAccessibleEventBroadcaster broadcaster = UnoRuntime.queryInterface(XAccessibleEventBroadcaster.class, - unoAccessibleComponent); - if (broadcaster != null) { - broadcaster.addAccessibleEventListener(new AccessibleWindowListener()); - } - } - - java.awt.Component initialComponent = null; - - public java.awt.Component getInitialComponent() { - if (Build.DEBUG) { - System.err.println("returning initial component object of class: " + initialComponent.getClass().getName()); - } - return initialComponent; - } - - public void setInitialComponent(java.awt.Component c) { - initialComponent = c; - } - - public Integer getHWND() { - return null; - } - - /** - * Determines whether this <code>Component</code> is showing on screen. - * This means that the component must be visible, and it must be in a - * <code>container</code> that is visible and showing. - * @see #addNotify - * @see #removeNotify - * @since JDK1.0 - */ - public boolean isShowing() { - if (isVisible()) { - java.awt.Container parent = getParent(); - return (parent == null) || parent.isShowing(); - } - return false; - } - - /** - * Makes this <code>Component</code> displayable by connecting it to a - * native screen resource. - * This method is called internally by the toolkit and should - * not be called directly by programs. - * @see #isDisplayable - * @see #removeNotify - * @since JDK1.0 - */ - public void addNotify() { -// createHierarchyEvents(0, null, null, 0, false); - } - - /** - * Makes this <code>Component</code> undisplayable by destroying it native - * screen resource. - * This method is called by the toolkit internally and should - * not be called directly by programs. - * @see #isDisplayable - * @see #addNotify - * @since JDK1.0 - */ - public void removeNotify() { - } - - /** - * Determines if the object is visible. Note: this means that the - * object intends to be visible; however, it may not in fact be - * showing on the screen because one of the objects that this object - * is contained by is not visible. To determine if an object is - * showing on the screen, use <code>isShowing</code>. - * - * @return true if object is visible; otherwise, false - */ - public boolean isVisible(){ - return visible; - } - - /** - * Shows or hides this component depending on the value of parameter - * <code>b</code>. - * @param b if <code>true</code>, shows this component; - * otherwise, hides this component - * @see #isVisible - * @since JDK1.1 - */ - public void setVisible(boolean b) { - if (visible != b){ - visible = b; - if (b) { - // If it is the first show, fire WINDOW_OPENED event - if (!opened) { - postWindowEvent(java.awt.event.WindowEvent.WINDOW_OPENED); - opened = true; - } - postComponentEvent(java.awt.event.ComponentEvent.COMPONENT_SHOWN); - } else { - postComponentEvent(java.awt.event.ComponentEvent.COMPONENT_HIDDEN); - } - } - } - - public void dispose() { - setVisible(false); - postWindowEvent(java.awt.event.WindowEvent.WINDOW_CLOSED); - - // Transfer window focus back to the owner window if it is still the active frame - if ((getOwner() instanceof Frame && ((Frame) getOwner()).active) || - (getOwner() instanceof Dialog && ((Dialog) getOwner()).active)) { - eventQueue.postEvent(new java.awt.event.WindowEvent(getOwner(), - java.awt.event.WindowEvent.WINDOW_GAINED_FOCUS)); - } - } - - protected void postWindowEvent(int i) { - eventQueue.postEvent(new java.awt.event.WindowEvent(this, i)); - } - - protected void postComponentEvent(int i) { - eventQueue.postEvent(new java.awt.event.ComponentEvent(this, i)); - } - - /** - * Update the proxy objects appropriatly on property change events - */ - protected class AccessibleWindowListener implements XAccessibleEventListener { - - protected AccessibleWindowListener() { - } - - // The only expected state changes are ACTIVE and VISIBLE - protected void setComponentState(short state, boolean enable) { - switch (state) { - case AccessibleStateType.ICONIFIED: - postWindowEvent(enable ? - java.awt.event.WindowEvent.WINDOW_ICONIFIED : - java.awt.event.WindowEvent.WINDOW_DEICONIFIED); - break; - case AccessibleStateType.SHOWING: - case AccessibleStateType.VISIBLE: - setVisible(enable); - break; - default: - if (Build.DEBUG) { -// System.err.println("[frame]: " + getTitle() + "unexpected state change " + state); - } - break; - } - } - - /** Updates the accessible name and fires the appropriate PropertyChangedEvent */ - protected void handleNameChangedEvent(Object any) { - try { - // This causes the property change event to be fired in the VCL thread - // context. If this causes problems, it has to be deligated to the java - // dispatch thread .. - javax.accessibility.AccessibleContext ac = accessibleContext; - if (ac!= null) { - ac.setAccessibleName(AnyConverter.toString(any)); - } - } catch (com.sun.star.lang.IllegalArgumentException e) { - } - } - - /** Updates the accessible description and fires the appropriate PropertyChangedEvent */ - protected void handleDescriptionChangedEvent(Object any) { - try { - // This causes the property change event to be fired in the VCL thread - // context. If this causes problems, it has to be deligated to the java - // dispatch thread .. - if (accessibleContext != null) { - accessibleContext.setAccessibleDescription(AnyConverter.toString(any)); - } - } catch (com.sun.star.lang.IllegalArgumentException e) { - } - } - - /** Updates the internal states and fires the appropriate PropertyChangedEvent */ - protected void handleStateChangedEvent(Object any1, Object any2) { - try { - if (AnyConverter.isShort(any1)) { - setComponentState(AnyConverter.toShort(any1), false); - } - - if (AnyConverter.isShort(any2)) { - setComponentState(AnyConverter.toShort(any2), true); - } - } catch (com.sun.star.lang.IllegalArgumentException e) { - } - } - - /** Fires a visible data property change event */ - protected void handleVisibleDataEvent() { - javax.accessibility.AccessibleContext ac = accessibleContext; - if (ac != null) { - ac.firePropertyChange(javax.accessibility.AccessibleContext.ACCESSIBLE_VISIBLE_DATA_PROPERTY, null, null); - } - } - - /** Called by OpenOffice process to notify property changes */ - public void notifyEvent(AccessibleEventObject event) { - switch (event.EventId) { - case AccessibleEventId.NAME_CHANGED: - // Set the accessible name for the corresponding context, which will fire a property - // change event itself - handleNameChangedEvent(event.NewValue); - break; - case AccessibleEventId.DESCRIPTION_CHANGED: - // Set the accessible description for the corresponding context, which will fire a property - // change event itself - so do not set propertyName ! - handleDescriptionChangedEvent(event.NewValue); - break; - case AccessibleEventId.STATE_CHANGED: - // Update the internal state set and fire the appropriate PropertyChangedEvent - handleStateChangedEvent(event.OldValue, event.NewValue); - break; - case AccessibleEventId.CHILD: - if (AnyConverter.isObject(event.OldValue)) { - AccessibleObjectFactory.removeChild(Window.this, event.OldValue); - } else if (AnyConverter.isObject(event.NewValue)) { - AccessibleObjectFactory.addChild(Window.this, event.NewValue); - } - break; - case AccessibleEventId.VISIBLE_DATA_CHANGED: - case AccessibleEventId.BOUNDRECT_CHANGED: - handleVisibleDataEvent(); - break; - default: - // Warn about unhandled events - if(Build.DEBUG) { - System.out.println(this + ": unhandled accessibility event id=" + event.EventId); - } - } - } - - /** Called by OpenOffice process to notify that the UNO component is disposing */ - public void disposing(com.sun.star.lang.EventObject eventObject) { - } - } - - protected javax.accessibility.AccessibleContext accessibleContext = null; - - /** Returns the AccessibleContext associated with this object */ - public javax.accessibility.AccessibleContext getAccessibleContext() { - if (accessibleContext == null) { - accessibleContext = new AccessibleWindow(); -// accessibleContext.setAccessibleName(getTitle()); - } - return accessibleContext; - } - - protected class AccessibleWindow extends java.awt.Window.AccessibleAWTWindow { - protected AccessibleWindow() { - super(); - } - - protected java.awt.event.ComponentListener accessibleComponentHandler = null; - - /** - * Fire PropertyChange listener, if one is registered, - * when shown/hidden.. - */ - protected class AccessibleComponentHandler implements java.awt.event.ComponentListener { - public void componentHidden(java.awt.event.ComponentEvent e) { - AccessibleWindow.this.firePropertyChange( - javax.accessibility.AccessibleContext.ACCESSIBLE_STATE_PROPERTY, - javax.accessibility.AccessibleState.VISIBLE, null); - } - - public void componentShown(java.awt.event.ComponentEvent e) { - AccessibleWindow.this.firePropertyChange( - javax.accessibility.AccessibleContext.ACCESSIBLE_STATE_PROPERTY, - null, javax.accessibility.AccessibleState.VISIBLE); - } - - public void componentMoved(java.awt.event.ComponentEvent e) { - } - - public void componentResized(java.awt.event.ComponentEvent e) { - } - } // inner class AccessibleComponentHandler - - protected java.awt.event.ContainerListener accessibleContainerHandler = null; - - /** - * Fire PropertyChange listener, if one is registered, - * when children added/removed. - */ - - protected class AccessibleContainerHandler implements java.awt.event.ContainerListener { - public void componentAdded(java.awt.event.ContainerEvent e) { - java.awt.Component c = e.getChild(); - if (c != null && c instanceof javax.accessibility.Accessible) { - AccessibleWindow.this.firePropertyChange( - javax.accessibility.AccessibleContext.ACCESSIBLE_CHILD_PROPERTY, - null, ((javax.accessibility.Accessible) c).getAccessibleContext()); - } - } - public void componentRemoved(java.awt.event.ContainerEvent e) { - java.awt.Component c = e.getChild(); - if (c != null && c instanceof javax.accessibility.Accessible) { - AccessibleWindow.this.firePropertyChange( - javax.accessibility.AccessibleContext.ACCESSIBLE_CHILD_PROPERTY, - ((javax.accessibility.Accessible) c).getAccessibleContext(), null); - } - } - } - - protected int propertyChangeListenerCount = 0; - - /** - * Add a PropertyChangeListener to the listener list. - * - * @param listener The PropertyChangeListener to be added - */ - public void addPropertyChangeListener(java.beans.PropertyChangeListener listener) { - if (propertyChangeListenerCount++ == 0) { - accessibleContainerHandler = new AccessibleContainerHandler(); - Window.this.addContainerListener(accessibleContainerHandler); - - accessibleComponentHandler = new AccessibleComponentHandler(); - Window.this.addComponentListener(accessibleComponentHandler); - } - super.addPropertyChangeListener(listener); - } - - /** - * Remove a PropertyChangeListener from the listener list. - * This removes a PropertyChangeListener that was registered - * for all properties. - * - * @param listener The PropertyChangeListener to be removed - */ - public void removePropertyChangeListener(java.beans.PropertyChangeListener listener) { - if (--propertyChangeListenerCount == 0) { - Window.this.removeComponentListener(accessibleComponentHandler); - accessibleComponentHandler = null; - - Window.this.removeContainerListener(accessibleContainerHandler); - accessibleContainerHandler = null; - } - super.removePropertyChangeListener(listener); - } - - /* - * AccessibleComponent - */ - - /** Returns the background color of the object */ - public java.awt.Color getBackground() { - try { - return new java.awt.Color(unoAccessibleComponent.getBackground()); - } catch (com.sun.star.uno.RuntimeException e) { - return null; - } - } - - public void setBackground(java.awt.Color c) { - // Not supported by UNO accessibility API - } - - /** Returns the foreground color of the object */ - public java.awt.Color getForeground() { - try { - return new java.awt.Color(unoAccessibleComponent.getForeground()); - } catch (com.sun.star.uno.RuntimeException e) { - return null; - } - } - - public void setForeground(java.awt.Color c) { - // Not supported by UNO accessibility API - } - - public java.awt.Cursor getCursor() { - // Not supported by UNO accessibility API - return null; - } - - public void setCursor(java.awt.Cursor cursor) { - // Not supported by UNO accessibility API - } - - public java.awt.Font getFont() { - // FIXME - return null; - } - - public void setFont(java.awt.Font f) { - // Not supported by UNO accessibility API - } - - public java.awt.FontMetrics getFontMetrics(java.awt.Font f) { - // FIXME - return null; - } - - public boolean isEnabled() { - return Window.this.isEnabled(); - } - - public void setEnabled(boolean b) { - // Not supported by UNO accessibility API - } - - public boolean isVisible() { - return Window.this.isVisible(); - } - - public void setVisible(boolean b) { - // Not supported by UNO accessibility API - } - - public boolean isShowing() { - return Window.this.isShowing(); - } - - public boolean contains(java.awt.Point p) { - try { - return unoAccessibleComponent.containsPoint(new com.sun.star.awt.Point(p.x, p.y)); - } catch (com.sun.star.uno.RuntimeException e) { - return false; - } - } - - /** Returns the location of the object on the screen. */ - public java.awt.Point getLocationOnScreen() { - try { - com.sun.star.awt.Point unoPoint = unoAccessibleComponent.getLocationOnScreen(); - return new java.awt.Point(unoPoint.X, unoPoint.Y); - } catch (com.sun.star.uno.RuntimeException e) { - return null; - } - } - - /** Gets the location of this component in the form of a point specifying the component's top-left corner */ - public java.awt.Point getLocation() { - try { - com.sun.star.awt.Point unoPoint = unoAccessibleComponent.getLocationOnScreen(); - return new java.awt.Point( unoPoint.X, unoPoint.Y ); - } catch (com.sun.star.uno.RuntimeException e) { - return null; - } - } - - /** Moves this component to a new location */ - public void setLocation(java.awt.Point p) { - // Not supported by UNO accessibility API - } - - /** Gets the bounds of this component in the form of a Rectangle object */ - public java.awt.Rectangle getBounds() { - try { - com.sun.star.awt.Rectangle unoRect = unoAccessibleComponent.getBounds(); - return new java.awt.Rectangle(unoRect.X, unoRect.Y, unoRect.Width, unoRect.Height); - } catch (com.sun.star.uno.RuntimeException e) { - return null; - } - } - - /** Moves and resizes this component to conform to the new bounding rectangle r */ - public void setBounds(java.awt.Rectangle r) { - // Not supported by UNO accessibility API - } - - /** Returns the size of this component in the form of a Dimension object */ - public java.awt.Dimension getSize() { - try { - com.sun.star.awt.Size unoSize = unoAccessibleComponent.getSize(); - return new java.awt.Dimension(unoSize.Width, unoSize.Height); - } catch (com.sun.star.uno.RuntimeException e) { - return null; - } - } - - /** Resizes this component so that it has width d.width and height d.height */ - public void setSize(java.awt.Dimension d) { - // Not supported by UNO accessibility API - } - - /** Returns the Accessible child, if one exists, contained at the local coordinate Point */ - public javax.accessibility.Accessible getAccessibleAt(java.awt.Point p) { - try { - java.awt.Component c = AccessibleObjectFactory.getAccessibleComponent( - unoAccessibleComponent.getAccessibleAtPoint(new com.sun.star.awt.Point(p.x, p.y))); - - return (javax.accessibility.Accessible) c; - } catch (com.sun.star.uno.RuntimeException e) { - return null; - } - } - - public boolean isFocusTraversable() { - return Window.this.isFocusable(); - } - - public void requestFocus() { - unoAccessibleComponent.grabFocus(); - } - } - - /** - * Determines whether this component is displayable. A component is - * displayable when it is connected to a native screen resource. - * <p> - * A component is made displayable either when it is added to - * a displayable containment hierarchy or when its containment - * hierarchy is made displayable. - * A containment hierarchy is made displayable when its ancestor - * window is either packed or made visible. - * <p> - * A component is made undisplayable either when it is removed from - * a displayable containment hierarchy or when its containment hierarchy - * is made undisplayable. A containment hierarchy is made - * undisplayable when its ancestor window is disposed. - * - * @return <code>true</code> if the component is displayable - */ - @Override - public boolean isDisplayable() { - return true; - } - -} - diff --git a/accessibility/bridge/org/openoffice/java/accessibility/logging/XAccessibleEventLog.java b/accessibility/bridge/org/openoffice/java/accessibility/logging/XAccessibleEventLog.java deleted file mode 100644 index b0d1d7e80d94..000000000000 --- a/accessibility/bridge/org/openoffice/java/accessibility/logging/XAccessibleEventLog.java +++ /dev/null @@ -1,178 +0,0 @@ -/* - * 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 . - */ - -package org.openoffice.java.accessibility.logging; - -import java.awt.Component; - -import com.sun.star.accessibility.*; -import com.sun.star.uno.*; - -/** - * - */ -public class XAccessibleEventLog implements XAccessibleEventListener { - - private static XAccessibleEventLog theEventListener = null; - - private static java.util.Hashtable<String, Component> proxyList = new java.util.Hashtable<String, Component>(); - - /** Creates a new instance of UNOAccessibleEventListener */ - public XAccessibleEventLog() { - } - - private static XAccessibleEventListener get() { - if (theEventListener == null) { - theEventListener = new XAccessibleEventLog(); - } - return theEventListener; - } - - public static void addEventListener(XAccessibleContext xac, java.awt.Component c) { - XAccessibleEventBroadcaster broadcaster = UnoRuntime.queryInterface(XAccessibleEventBroadcaster.class, xac); - if (broadcaster != null) { - broadcaster.addAccessibleEventListener(XAccessibleEventLog.get()); - - // remember the proxy objects - synchronized (proxyList) { -// proxyList.put(UnoRuntime.generateOid(xac), new WeakReference(c)); - proxyList.put(UnoRuntime.generateOid(xac), c); - } - } - } - - public void disposing(com.sun.star.lang.EventObject eventObject) { - } - - public void notifyEvent(com.sun.star.accessibility.AccessibleEventObject accessibleEventObject) { - switch (accessibleEventObject.EventId) { - case AccessibleEventId.ACTIVE_DESCENDANT_CHANGED: - logMessage(accessibleEventObject.Source, "Retrieved active descendant event."); - break; - case AccessibleEventId.STATE_CHANGED: - logStateChange(accessibleEventObject.Source, - accessibleEventObject.OldValue, - accessibleEventObject.NewValue); - break; - case AccessibleEventId.CHILD: - logMessage(accessibleEventObject.Source, "Retrieved children event."); - break; - case AccessibleEventId.BOUNDRECT_CHANGED: - logMessage(accessibleEventObject.Source, "Retrieved boundrect changed event."); - break; - case AccessibleEventId.VISIBLE_DATA_CHANGED: - logMessage(accessibleEventObject.Source, "Retrieved visible data changed event."); - break; - case AccessibleEventId.INVALIDATE_ALL_CHILDREN: - logMessage(accessibleEventObject.Source, "Retrieved invalidate children event."); - break; - default: - break; - } - } - - public void logStateChange(Object o, Object any1, Object any2) { - try { - if (AnyConverter.isShort(any1)) { - logStateChange(o, AnyConverter.toShort(any1), " is no longer "); - } - - if (AnyConverter.isShort(any2)) { - logStateChange(o, AnyConverter.toShort(any2), " is now "); - } - } catch (com.sun.star.lang.IllegalArgumentException e) { - } - } - - public void logStateChange(Object o, short n, String s) { - switch(n) { - case AccessibleStateType.ACTIVE: - logMessage(o, s + javax.accessibility.AccessibleState.ACTIVE); - break; - case AccessibleStateType.ARMED: - logMessage(o, s + javax.accessibility.AccessibleState.ARMED); - break; - case AccessibleStateType.CHECKED: - logMessage(o, s + javax.accessibility.AccessibleState.CHECKED); - break; - case AccessibleStateType.ENABLED: - logMessage(o, s + javax.accessibility.AccessibleState.ENABLED); - break; - case AccessibleStateType.FOCUSED: - logMessage(o, s + javax.accessibility.AccessibleState.FOCUSED); - break; - case AccessibleStateType.PRESSED: - logMessage(o, s + javax.accessibility.AccessibleState.PRESSED); - break; - case AccessibleStateType.SELECTED: - logMessage(o, s + javax.accessibility.AccessibleState.SELECTED); - break; - case AccessibleStateType.SENSITIVE: - logMessage(o, s + "sensitive"); - break; - case AccessibleStateType.SHOWING: - logMessage(o, s + javax.accessibility.AccessibleState.SHOWING); - break; - case AccessibleStateType.VISIBLE: - logMessage(o, s + javax.accessibility.AccessibleState.VISIBLE); - break; - default: - logMessage(o, s + "??? (FIXME)"); - break; - } - } - - protected static void logMessage(Object o, String s) { - XAccessibleContext xac = UnoRuntime.queryInterface(XAccessibleContext.class, o); - if( xac != null ) { - String oid = UnoRuntime.generateOid(xac); - synchronized (proxyList) { - logMessage( (javax.accessibility.Accessible) proxyList.get( oid ), s ); -// WeakReference r = (WeakReference) proxyList.get( oid ); -// if(r != null) { -// System.err.println( "*** Warning *** event is " + r.get() ); -// logMessage( (javax.accessibility.Accessible) r.get(), s ); -// } else { -// System.err.println( "*** Warning *** event source not found in broadcaster list" ); -// } - } - } else - System.err.println( "*** Warning *** event source does not implement XAccessibleContext" ); - } - - protected static void logMessage(javax.accessibility.Accessible a, String s) { - if (a != null) { - logMessage(a.getAccessibleContext(), s); - } else { - logMessage(s); - } - } - - protected static void logMessage(javax.accessibility.AccessibleContext ac, String s) { - if (ac != null) { - logMessage("[" + ac.getAccessibleRole() + "] " - + ac.getAccessibleName() + ": " + s); - } else { - logMessage(s); - } - } - - protected static void logMessage(String s) { - System.err.println(s); - } -} diff --git a/accessibility/bridge/org/openoffice/java/accessibility/logging/XAccessibleHypertextLog.java b/accessibility/bridge/org/openoffice/java/accessibility/logging/XAccessibleHypertextLog.java deleted file mode 100644 index 88764d651cd5..000000000000 --- a/accessibility/bridge/org/openoffice/java/accessibility/logging/XAccessibleHypertextLog.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * 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 . - */ - -package org.openoffice.java.accessibility.logging; - -import com.sun.star.accessibility.*; - -/** The AccessibleHypertextImpl mapps all calls to the java AccessibleHypertext - * interface to the corresponding methods of the UNO XAccessibleHypertext - * interface. - */ -public class XAccessibleHypertextLog extends XAccessibleTextLog - implements com.sun.star.accessibility.XAccessibleHypertext { - - private com.sun.star.accessibility.XAccessibleHypertext unoObject; - - /** Creates a new instance of XAccessibleTextLog */ - public XAccessibleHypertextLog(XAccessibleHypertext xAccessibleHypertext) { - super(xAccessibleHypertext); - unoObject = xAccessibleHypertext; - } - - public XAccessibleHyperlink getHyperLink(int param) - throws com.sun.star.lang.IndexOutOfBoundsException { - return unoObject.getHyperLink(param); - } - - public int getHyperLinkCount() { - return unoObject.getHyperLinkCount(); - } - - public int getHyperLinkIndex(int param) - throws com.sun.star.lang.IndexOutOfBoundsException { - return unoObject.getHyperLinkIndex(param); - } -} diff --git a/accessibility/bridge/org/openoffice/java/accessibility/logging/XAccessibleTextLog.java b/accessibility/bridge/org/openoffice/java/accessibility/logging/XAccessibleTextLog.java deleted file mode 100644 index 7b3527bd278a..000000000000 --- a/accessibility/bridge/org/openoffice/java/accessibility/logging/XAccessibleTextLog.java +++ /dev/null @@ -1,261 +0,0 @@ -/* - * 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 . - */ -package org.openoffice.java.accessibility.logging; - -import org.openoffice.java.accessibility.*; - - -/** - * - */ -public class XAccessibleTextLog - implements com.sun.star.accessibility.XAccessibleText { - private com.sun.star.accessibility.XAccessibleText unoObject; - private String name = "[Unknown] NoName"; - - /** Creates a new instance of XAccessibleTextLog */ - public XAccessibleTextLog( - com.sun.star.accessibility.XAccessibleText xAccessibleText) { - unoObject = xAccessibleText; - setName(xAccessibleText); - } - - private void setName( - com.sun.star.accessibility.XAccessibleText xAccessibleText) { - try { - com.sun.star.accessibility.XAccessibleContext unoAccessibleContext = com.sun.star.uno.UnoRuntime.queryInterface(com.sun.star.accessibility.XAccessibleContext.class, - xAccessibleText); - - if (unoAccessibleContext != null) { - name = "[" + - AccessibleRoleAdapter.getAccessibleRole(unoAccessibleContext.getAccessibleRole()) + - "] " + unoAccessibleContext.getAccessibleName() + ": "; - } - } catch (com.sun.star.uno.RuntimeException e) { - } - } - - private String getPartString(short s) { - String part = "INVALID"; - - switch (s) { - case com.sun.star.accessibility.AccessibleTextType.CHARACTER: - part = "CHARACTER"; - - break; - - case com.sun.star.accessibility.AccessibleTextType.WORD: - part = "WORD"; - - break; - - case com.sun.star.accessibility.AccessibleTextType.SENTENCE: - part = "SENTENCE"; - - break; - - case com.sun.star.accessibility.AccessibleTextType.LINE: - part = "LINE"; - - break; - - case com.sun.star.accessibility.AccessibleTextType.ATTRIBUTE_RUN: - part = "ATTRIBUTE_RUN"; - - break; - - default: - break; - } - - return part; - } - - private String dumpTextSegment(com.sun.star.accessibility.TextSegment ts) { - if (ts != null) { - return "(" + ts.SegmentStart + "," + ts.SegmentEnd + "," + - ts.SegmentText + ")"; - } - - return "NULL"; - } - - public boolean copyText(int param, int param1) - throws com.sun.star.lang.IndexOutOfBoundsException { - return unoObject.copyText(param, param1); - } - - public int getCaretPosition() { - int pos = unoObject.getCaretPosition(); - System.err.println(name + "getCaretPosition() returns " + pos); - - return pos; - } - - public char getCharacter(int param) - throws com.sun.star.lang.IndexOutOfBoundsException { - return unoObject.getCharacter(param); - } - - public com.sun.star.beans.PropertyValue[] getCharacterAttributes( - int param, String[] str) - throws com.sun.star.lang.IndexOutOfBoundsException { - return unoObject.getCharacterAttributes(param, str); - } - - public com.sun.star.awt.Rectangle getCharacterBounds(int param) - throws com.sun.star.lang.IndexOutOfBoundsException { - try { - com.sun.star.awt.Rectangle r = unoObject.getCharacterBounds(param); - System.err.println(name + "getCharacterBounds(" + param + - ") returns (" + r.X + "," + r.Y + "," + r.Width + "," + - r.Height + ")"); - - return r; - } catch (com.sun.star.lang.IndexOutOfBoundsException e) { - System.err.println("IndexOutOufBoundsException caught for " + name + - "getCharacterBounds(" + param + ")"); - throw e; - } - } - - public int getCharacterCount() { - return unoObject.getCharacterCount(); - } - - public int getIndexAtPoint(com.sun.star.awt.Point point) { - try { - int index = unoObject.getIndexAtPoint(point); - System.err.println(name + "getIndexAtPoint(" + point.X + ", " + - point.Y + ") returns " + index); - - return index; - } catch (com.sun.star.uno.RuntimeException e) { - System.err.println(name + - "RuntimeException caught for getIndexAtPoint(" + point.X + - ", " + point.Y + ")"); - System.err.println(e.getMessage()); - throw e; - } - } - - public String getSelectedText() { - return unoObject.getSelectedText(); - } - - public int getSelectionEnd() { - return unoObject.getSelectionEnd(); - } - - public int getSelectionStart() { - return unoObject.getSelectionStart(); - } - - public String getText() { - return unoObject.getText(); - } - - public com.sun.star.accessibility.TextSegment getTextAtIndex(int param, - short param1) - throws com.sun.star.lang.IndexOutOfBoundsException, - com.sun.star.lang.IllegalArgumentException { - try { - com.sun.star.accessibility.TextSegment ts = unoObject.getTextAtIndex(param, - param1); - System.err.println(name + "getTextAtIndex(" + - getPartString(param1) + "," + param + ") returns " + - dumpTextSegment(ts)); - - return ts; - } catch (com.sun.star.lang.IndexOutOfBoundsException e) { - System.err.println("IndexOutOufBoundsException caught for " + name + - " getTextAtIndex(" + getPartString(param1) + "," + param1 + - ")"); - throw e; - } catch (com.sun.star.lang.IllegalArgumentException e) { - System.err.println("IllegalArgumentException caught for " + name + - " getTextAtIndex(" + getPartString(param1) + "," + param + ")"); - throw e; - } - } - - public com.sun.star.accessibility.TextSegment getTextBeforeIndex( - int param, short param1) - throws com.sun.star.lang.IndexOutOfBoundsException, - com.sun.star.lang.IllegalArgumentException { - try { - com.sun.star.accessibility.TextSegment ts = unoObject.getTextBeforeIndex(param, - param1); - System.err.println(name + " getTextBeforeIndex(" + - getPartString(param1) + "," + param + ") returns " + - dumpTextSegment(ts)); - - return ts; - } catch (com.sun.star.lang.IndexOutOfBoundsException e) { - System.err.println("IndexOutOufBoundsException caught for " + name + - " getTextBeforeIndex(" + getPartString(param1) + "," + param1 + - ")"); - throw e; - } catch (com.sun.star.lang.IllegalArgumentException e) { - System.err.println("IllegalArgumentException caught for " + name + - " getTextBeforeIndex(" + getPartString(param1) + "," + param + - ")"); - throw e; - } - } - - public com.sun.star.accessibility.TextSegment getTextBehindIndex( - int param, short param1) - throws com.sun.star.lang.IndexOutOfBoundsException, - com.sun.star.lang.IllegalArgumentException { - try { - com.sun.star.accessibility.TextSegment ts = unoObject.getTextBehindIndex(param, - param1); - System.err.println(name + " getTextBehindIndex(" + - getPartString(param1) + "," + param + ") returns " + - dumpTextSegment(ts)); - - return ts; - } catch (com.sun.star.lang.IndexOutOfBoundsException e) { - System.err.println("IndexOutOufBoundsException caught for " + name + - " getTextBehindIndex(" + getPartString(param1) + "," + param1 + - ")"); - throw e; - } catch (com.sun.star.lang.IllegalArgumentException e) { - System.err.println("IllegalArgumentException caught for " + name + - " getTextBehindIndex(" + getPartString(param1) + "," + param + - ")"); - throw e; - } - } - - public String getTextRange(int param, int param1) - throws com.sun.star.lang.IndexOutOfBoundsException { - return unoObject.getTextRange(param, param1); - } - - public boolean setCaretPosition(int param) - throws com.sun.star.lang.IndexOutOfBoundsException { - return unoObject.setCaretPosition(param); - } - - public boolean setSelection(int param, int param1) - throws com.sun.star.lang.IndexOutOfBoundsException { - return unoObject.setSelection(param, param1); - } -} diff --git a/accessibility/bridge/source/java/WindowsAccessBridgeAdapter.cxx b/accessibility/bridge/source/java/WindowsAccessBridgeAdapter.cxx deleted file mode 100644 index e99d51c2a446..000000000000 --- a/accessibility/bridge/source/java/WindowsAccessBridgeAdapter.cxx +++ /dev/null @@ -1,300 +0,0 @@ -/* -*- 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 . - */ - -#ifdef WNT -#include <prewin.h> -#include <postwin.h> -#endif - -#include <WindowsAccessBridgeAdapter.h> - -#include <wtypes.h> -#include <rtl/process.h> -#include <tools/link.hxx> - -#include <vcl/svapp.hxx> -#include <vcl/window.hxx> -#include <vcl/sysdata.hxx> -#include <uno/current_context.hxx> -#include <uno/environment.h> -#include <uno/mapping.hxx> -#include <com/sun/star/accessibility/AccessibleRole.hpp> -#include <com/sun/star/accessibility/XAccessible.hpp> - -#include "jvmaccess/unovirtualmachine.hxx" - -#include "jvmaccess/virtualmachine.hxx" - -#include <osl/diagnose.h> - -using ::com::sun::star::uno::Mapping; -using ::com::sun::star::uno::Reference; -using ::com::sun::star::uno::RuntimeException; -using namespace ::com::sun::star::accessibility; - -long VCLEventListenerLinkFunc(void * pInst, void * pData); - -//------------------------------------------------------------------------ -// global vatiables -//------------------------------------------------------------------------ - -Link g_aEventListenerLink(NULL, VCLEventListenerLinkFunc); - -rtl::Reference< jvmaccess::UnoVirtualMachine > g_xUnoVirtualMachine; -typelib_InterfaceTypeDescription * g_pTypeDescription = NULL; -Mapping g_unoMapping; - -jclass g_jcWindowsAccessBridgeAdapter = NULL; -jmethodID g_jmRegisterTopWindow = 0; -jmethodID g_jmRevokeTopWindow = 0; - -//------------------------------------------------------------------------ -// functions -//------------------------------------------------------------------------ - -SAL_DLLPUBLIC_EXPORT jint JNICALL JNI_OnLoad(JavaVM *, void *) -{ - return JNI_VERSION_1_2; -} - -SAL_DLLPUBLIC_EXPORT jbyteArray JNICALL -Java_org_openoffice_accessibility_WindowsAccessBridgeAdapter_getProcessID(JNIEnv *pJNIEnv, jclass clazz) -{ - // Initialize global class and method references - g_jcWindowsAccessBridgeAdapter = - static_cast< jclass > (pJNIEnv->NewGlobalRef(clazz)); - if (NULL == g_jcWindowsAccessBridgeAdapter) { - return 0; /* jni error occurred */ - } - g_jmRegisterTopWindow = - pJNIEnv->GetStaticMethodID(clazz, "registerTopWindow", "(ILcom/sun/star/accessibility/XAccessible;)V"); - if (0 == g_jmRegisterTopWindow) { - return 0; /* jni error occurred */ - } - g_jmRevokeTopWindow = - pJNIEnv->GetStaticMethodID(clazz, "revokeTopWindow", "(ILcom/sun/star/accessibility/XAccessible;)V"); - if (0 == g_jmRevokeTopWindow) { - return 0; /* jni error occurred */ - } - - // Use the special protocol of XJavaVM.getJavaVM: If the passed in - // process ID has an extra 17th byte of value one, the returned any - // contains a pointer to a jvmaccess::UnoVirtualMachine, instead of - // the underlying JavaVM pointer: - jbyte processID[17]; - rtl_getGlobalProcessId(reinterpret_cast<sal_uInt8 *> (processID)); - // #i51265# we need a jvmaccess::UnoVirtualMachine pointer for the - // uno_getEnvironment() call later. - processID[16] = 1; - - // Copy the result into a java byte[] and return. - jbyteArray jbaProcessID = pJNIEnv->NewByteArray(17); - pJNIEnv->SetByteArrayRegion(jbaProcessID, 0, 17, processID); - return jbaProcessID; -} - -SAL_DLLPUBLIC_EXPORT jboolean JNICALL -Java_org_openoffice_accessibility_WindowsAccessBridgeAdapter_createMapping(JNIEnv *, jclass, jlong pointer) -{ - uno_Environment * pJava_environment = NULL; - uno_Environment * pUno_environment = NULL; - - try { - // We get a non-refcounted pointer to a jvmaccess::VirtualMachine - // from the XJavaVM service (the pointer is guaranteed to be valid - // as long as our reference to the XJavaVM service lasts), and - // convert the non-refcounted pointer into a refcounted one - // immediately: - g_xUnoVirtualMachine = reinterpret_cast< jvmaccess::UnoVirtualMachine * >(pointer); - - if ( g_xUnoVirtualMachine.is() ) - { - OUString sJava("java"); - uno_getEnvironment(&pJava_environment, sJava.pData, g_xUnoVirtualMachine.get()); - - OUString sCppu_current_lb_name(CPPU_CURRENT_LANGUAGE_BINDING_NAME); - uno_getEnvironment(&pUno_environment, sCppu_current_lb_name.pData, NULL); - - if ( pJava_environment && pUno_environment ) - { - g_unoMapping = Mapping(pUno_environment, pJava_environment); - getCppuType((::com::sun::star::uno::Reference< XAccessible > *) 0).getDescription((typelib_TypeDescription **) & g_pTypeDescription); - } - - if ( pJava_environment ) - { - // release java environment - pJava_environment->release(pJava_environment); - pJava_environment = NULL; - } - - if ( pUno_environment ) - { - // release uno environment - pUno_environment->release(pUno_environment); - pUno_environment = NULL; - } - } - } - - catch (const RuntimeException &) - { - OSL_TRACE("RuntimeException caught while initializing the mapping"); - } - - if ( (0 != g_jmRegisterTopWindow) && (0 != g_jmRevokeTopWindow) ) - { - ::Application::AddEventListener(g_aEventListenerLink); - } - return JNI_TRUE; -} - -SAL_DLLPUBLIC_EXPORT void JNICALL JNI_OnUnload(JavaVM *jvm, void *) -{ - ::Application::RemoveEventListener(g_aEventListenerLink); - - if ( NULL != g_jcWindowsAccessBridgeAdapter ) - { - JNIEnv * pJNIEnv; - if ( ! jvm->GetEnv((void **) &pJNIEnv, JNI_VERSION_1_2) ) - { - pJNIEnv->DeleteGlobalRef(g_jcWindowsAccessBridgeAdapter); - g_jcWindowsAccessBridgeAdapter = NULL; - } - } - - if ( NULL != g_pTypeDescription ) - { - typelib_typedescription_release( reinterpret_cast< typelib_TypeDescription * > (g_pTypeDescription) ); - g_pTypeDescription = NULL; - } - - g_unoMapping.clear(); - g_xUnoVirtualMachine.clear(); -} - -HWND GetHWND(Window * pWindow) -{ - const SystemEnvData * pEnvData = pWindow->GetSystemData(); - if (pEnvData != NULL) - { - return pEnvData->hWnd; - } - return (HWND) -1; -} - -void handleWindowEvent(Window * pWindow, bool bShow) -{ - if ( pWindow && pWindow->IsTopWindow() ) - { - ::com::sun::star::uno::Reference< XAccessible > xAccessible; - - // Test for combo box - drop down floating windows first - Window * pParentWindow = pWindow->GetParent(); - - if ( pParentWindow ) - { - try - { - // The parent window of a combo box floating window should have the role COMBO_BOX - ::com::sun::star::uno::Reference< XAccessible > xParentAccessible(pParentWindow->GetAccessible()); - if ( xParentAccessible.is() ) - { - ::com::sun::star::uno::Reference< XAccessibleContext > xParentAC(xParentAccessible->getAccessibleContext()); - if ( xParentAC.is() && (AccessibleRole::COMBO_BOX == xParentAC->getAccessibleRole()) ) - { - // O.k. - this is a combo box floating window corresponding to the child of role LIST of the parent. - // Let's not rely on a specific child order, just search for the child with the role LIST - sal_Int32 nCount = xParentAC->getAccessibleChildCount(); - for ( sal_Int32 n = 0; (n < nCount) && !xAccessible.is(); n++) - { - ::com::sun::star::uno::Reference< XAccessible > xChild = xParentAC->getAccessibleChild(n); - if ( xChild.is() ) - { - ::com::sun::star::uno::Reference< XAccessibleContext > xChildAC = xChild->getAccessibleContext(); - if ( xChildAC.is() && (AccessibleRole::LIST == xChildAC->getAccessibleRole()) ) - { - xAccessible = xChild; - } - } - } - } - } - } - catch (const ::com::sun::star::uno::RuntimeException &) - { - // Ignore show events that throw DisposedExceptions in getAccessibleContext(), - // but keep revoking these windows in hide(s). - if (bShow) - return; - } - } - - // We have to rely on the fact that Window::GetAccessible()->getAccessibleContext() returns a valid XAccessibleContext - // also for other menus than menubar or toplevel popup window. Otherwise we had to traverse the hierarchy to find the - // context object to this menu floater. This makes the call to Window->IsMenuFloatingWindow() obsolete. - if ( ! xAccessible.is() ) - xAccessible = pWindow->GetAccessible(); - - if ( xAccessible.is() && g_unoMapping.is() ) - { - jobject * joXAccessible = reinterpret_cast < jobject * > (g_unoMapping.mapInterface( - xAccessible.get(), g_pTypeDescription)); - - if ( NULL != joXAccessible ) - { - jvmaccess::VirtualMachine::AttachGuard aGuard(g_xUnoVirtualMachine->getVirtualMachine()); - JNIEnv * pJNIEnv = aGuard.getEnvironment(); - - if ( NULL != pJNIEnv ) - { - // g_jmRegisterTopWindow and g_jmRevokeTopWindow are ensured to be != 0 - otherwise - // the event listener would not have been attached. - pJNIEnv->CallStaticVoidMethod(g_jcWindowsAccessBridgeAdapter, - (bShow) ? g_jmRegisterTopWindow : g_jmRevokeTopWindow, - (jclass) GetHWND(pWindow), joXAccessible ); - - // Clear any exception that might have been occurred. - if (pJNIEnv->ExceptionCheck()) { - pJNIEnv->ExceptionClear(); - } - } - } - } - } -} - -long VCLEventListenerLinkFunc(void *, void * pData) -{ - ::VclSimpleEvent const * pEvent = (::VclSimpleEvent const *) pData; - - switch (pEvent->GetId()) - { - case VCLEVENT_WINDOW_SHOW: - handleWindowEvent(((::VclWindowEvent const *) pEvent)->GetWindow(), true); - break; - case VCLEVENT_WINDOW_HIDE: - handleWindowEvent(((::VclWindowEvent const *) pEvent)->GetWindow(), false); - break; - } - - return 0; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/config_host.mk.in b/config_host.mk.in index e1f0226fd492..2263d400bfab 100644 --- a/config_host.mk.in +++ b/config_host.mk.in @@ -123,7 +123,6 @@ export ENABLE_GNOMEVFS=@ENABLE_GNOMEVFS@ export ENABLE_GRAPHITE=@ENABLE_GRAPHITE@ export ENABLE_ORCUS=@ENABLE_ORCUS@ export ENABLE_HARFBUZZ=@ENABLE_HARFBUZZ@ -export ENABLE_IA2=@ENABLE_IA2@ export ENABLE_GSTREAMER=@ENABLE_GSTREAMER@ export ENABLE_GSTREAMER_0_10=@ENABLE_GSTREAMER_0_10@ export ENABLE_GTK3=@ENABLE_GTK3@ diff --git a/configure.ac b/configure.ac index c3ffe0560b31..a47217e7a358 100644 --- a/configure.ac +++ b/configure.ac @@ -1312,11 +1312,6 @@ AC_ARG_ENABLE(library-bin-tar, for the next time.]), ) -AC_ARG_ENABLE(ia2, - AS_HELP_STRING([--enable-ia2], - [Enable the Windows IAccessibility2. Disables Java Accessibility Bridge.]), -,) - dnl =================================================================== dnl Optional Packages (--with/without-) dnl =================================================================== @@ -11560,21 +11555,6 @@ fi AC_SUBST(ENABLE_ONLINE_UPDATE) dnl =================================================================== -dnl Test whether to enable ia2 -dnl =================================================================== -AC_MSG_CHECKING([whether to enable IA2]) -ENABLE_IA2= -if test "$enable_ia2" = "yes"; then - if test "$_os" = "WINNT"; then - AC_MSG_RESULT([yes]) - ENABLE_IA2="TRUE" - else - AC_MSG_RESULT([no]) - fi -fi -AC_SUBST(ENABLE_IA2) - -dnl =================================================================== dnl Test whether to create MSI with LIMITUI=1 (silent install) dnl =================================================================== AC_MSG_CHECKING([whether to create MSI with LIMITUI=1 (silent install)]) diff --git a/desktop/source/app/app.cxx b/desktop/source/app/app.cxx index 79fdc5048b4e..79eabdb69ad6 100644 --- a/desktop/source/app/app.cxx +++ b/desktop/source/app/app.cxx @@ -1467,11 +1467,8 @@ int Desktop::Main() SAL_INFO( "desktop.app", "{ GetEnableATToolSupport" ); if( Application::GetSettings().GetMiscSettings().GetEnableATToolSupport() ) { - bool bQuitApp; - - if( !InitAccessBridge( true, bQuitApp ) ) - if( bQuitApp ) - return EXIT_FAILURE; + if( !InitAccessBridge() ) + return EXIT_FAILURE; } SAL_INFO( "desktop.app", "} GetEnableATToolSupport" ); #endif diff --git a/include/vcl/svapp.hxx b/include/vcl/svapp.hxx index 385cedbca305..1620efa9f806 100755 --- a/include/vcl/svapp.hxx +++ b/include/vcl/svapp.hxx @@ -538,7 +538,7 @@ VCL_DLLPUBLIC Application* GetpApp(); VCL_DLLPUBLIC bool InitVCL(); VCL_DLLPUBLIC void DeInitVCL(); -VCL_DLLPUBLIC bool InitAccessBridge( bool bAllowCancel, bool &rCancelled ); +VCL_DLLPUBLIC bool InitAccessBridge(); // only allowed to call, if no thread is running. You must call JoinMainLoopThread to free all memory. VCL_DLLPUBLIC void CreateMainLoopThread( oslWorkerFunction pWorker, void * pThreadData ); diff --git a/offapi/UnoApi_offapi.mk b/offapi/UnoApi_offapi.mk index 41e8ea6d834d..ccee74136520 100755 --- a/offapi/UnoApi_offapi.mk +++ b/offapi/UnoApi_offapi.mk @@ -26,9 +26,6 @@ $(eval $(call gb_UnoApi_use_api,offapi,\ )) -$(eval $(call gb_UnoApi_add_idlfiles_nohdl,offapi,com/sun/star/accessibility,\ - AccessBridge \ -)) $(eval $(call gb_UnoApi_add_idlfiles_nohdl,offapi,com/sun/star/animations,\ AnimateColor \ AnimateMotion \ diff --git a/offapi/com/sun/star/accessibility/AccessBridge.idl b/offapi/com/sun/star/accessibility/AccessBridge.idl deleted file mode 100644 index f9205c03f55a..000000000000 --- a/offapi/com/sun/star/accessibility/AccessBridge.idl +++ /dev/null @@ -1,47 +0,0 @@ -/* -*- 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 . - */ -#ifndef __com_sun_star_accessibility_AccessBridge_idl__ -#define __com_sun_star_accessibility_AccessBridge_idl__ - -#include <com/sun/star/lang/XComponent.idl> -#include <com/sun/star/awt/XExtendedToolkit.idl> - - -module com { module sun { module star { module accessibility { - -/** The UNO <-> Java Access Bridge allows any native frame window - to become accessible by implementing the XAccessible interface. - - <p>Therefor the UNO <-> Java Access Bridge utilizes the Java <-> Windows - and Java <-> GNOME access bridge by registering the native frames as - Java windows.</p> - - @since OOo 1.1.2 -*/ - -service AccessBridge : com::sun::star::lang::XComponent -{ - createWithToolkit([in] com::sun::star::awt::XExtendedToolkit toolkit); -}; - -}; }; }; }; - -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/padmin/source/pamain.cxx b/padmin/source/pamain.cxx index bbccadf032c1..4d2cad2d1092 100644 --- a/padmin/source/pamain.cxx +++ b/padmin/source/pamain.cxx @@ -115,15 +115,13 @@ int MyApp::Main() com::sun::star::ucb::UniversalContentBroker::create(xCtx); /* - * Initialize the Java UNO AccessBridge if accessibility is turned on + * Initialize the MSAA UNO AccessBridge if accessibility is turned on */ if( Application::GetSettings().GetMiscSettings().GetEnableATToolSupport() ) { - bool bQuitApp; - if( !InitAccessBridge( true, bQuitApp ) ) - if( bQuitApp ) - return EXIT_FAILURE; + if( !InitAccessBridge() ) + return EXIT_FAILURE; } ResMgr::SetReadStringHook( MyApp::ReadStringHook ); diff --git a/postprocess/Rdb_services.mk b/postprocess/Rdb_services.mk index c044e14a7be4..c3a4d0f041fa 100755 --- a/postprocess/Rdb_services.mk +++ b/postprocess/Rdb_services.mk @@ -136,12 +136,7 @@ $(eval $(call gb_Rdb_add_components,services,\ shell/source/win32/simplemail/smplmail \ shell/source/win32/syssh \ vcl/vcl.windows \ - $(if $(ENABLE_IA2), \ - winaccessibility/source/service/winaccessibility, \ - $(if $(ENABLE_JAVA), \ - accessibility/bridge/org/openoffice/accessibility/java_uno_accessbridge \ - ) \ - ) \ + winaccessibility/source/service/winaccessibility \ ) \ $(if $(ENABLE_HEADLESS), \ vcl/vcl.headless \ diff --git a/scp2/source/ooo/file_ooo.scp b/scp2/source/ooo/file_ooo.scp index 08ed086f2ccc..965c89fa9709 100644 --- a/scp2/source/ooo/file_ooo.scp +++ b/scp2/source/ooo/file_ooo.scp @@ -315,10 +315,6 @@ STD_JAR_FILE( gid_File_Jar_Xmerge, xmerge ) STD_JAR_FILE( gid_File_Jar_Xmergebridge, XMergeBridge ) #endif -#if defined ENABLE_JAVA && defined WNT -STD_JAR_FILE( gid_File_Jar_Accessbridge, java_uno_accessbridge ) -#endif - #ifdef ENABLE_JAVA #ifndef SYSTEM_HSQLDB STD_JAR_FILE( gid_File_Jar_Hsqldb, hsqldb ) diff --git a/vcl/inc/pch/precompiled_vcl.hxx b/vcl/inc/pch/precompiled_vcl.hxx index f1eb6530a497..263a40a67032 100644 --- a/vcl/inc/pch/precompiled_vcl.hxx +++ b/vcl/inc/pch/precompiled_vcl.hxx @@ -18,7 +18,6 @@ #include "basegfx/polygon/b2dpolygon.hxx" #include "basegfx/polygon/b2dpolygontools.hxx" #include "basegfx/polygon/b2dpolypolygon.hxx" -#include "com/sun/star/accessibility/AccessBridge.hpp" #include "com/sun/star/accessibility/AccessibleRole.hpp" #include "com/sun/star/accessibility/XAccessible.hpp" #include "com/sun/star/awt/Size.hpp" diff --git a/vcl/inc/svdata.hxx b/vcl/inc/svdata.hxx index 8648eda56d3a..3f2ad238c84d 100644 --- a/vcl/inc/svdata.hxx +++ b/vcl/inc/svdata.hxx @@ -367,7 +367,7 @@ extern VCL_PLUGIN_PUBLIC ImplSVData* pImplSVData; inline VCL_PLUGIN_PUBLIC ImplSVData* ImplGetSVData() { return pImplSVData; } VCL_PLUGIN_PUBLIC void ImplHideSplash(); -bool ImplInitAccessBridge( bool bAllowCancel, bool &rCancelled ); +bool ImplInitAccessBridge(); FieldUnitStringList* ImplGetFieldUnits(); FieldUnitStringList* ImplGetCleanedFieldUnits(); diff --git a/vcl/inc/svids.hrc b/vcl/inc/svids.hrc index e9ff357db7fe..eb16740cd38e 100644 --- a/vcl/inc/svids.hrc +++ b/vcl/inc/svids.hrc @@ -198,16 +198,6 @@ #define STR_FPICKER_SAVE 10317 #define STR_FPICKER_TYPE 10318 -#define SV_ACCESSERROR_WRONG_VERSION 10500 -#define SV_ACCESSERROR_BRIDGE_MSG 10501 -#define SV_ACCESSERROR_OK_CANCEL_MSG 10502 -#define SV_ACCESSERROR_MISSING_BRIDGE 10503 -#define SV_ACCESSERROR_FAULTY_JAVA 10504 -#define SV_ACCESSERROR_JAVA_MSG 10505 -#define SV_ACCESSERROR_MISSING_JAVA 10506 -#define SV_ACCESSERROR_JAVA_NOT_CONFIGURED 10507 -#define SV_ACCESSERROR_JAVA_DISABLED 10508 -#define SV_ACCESSERROR_TURNAROUND_MSG 10509 #define SV_ACCESSERROR_NO_FONTS 10510 #define SV_SHORTCUT_HELP 10600 diff --git a/vcl/source/app/settings.cxx b/vcl/source/app/settings.cxx index 4995e6d0570f..8f2d0c17f90f 100644 --- a/vcl/source/app/settings.cxx +++ b/vcl/source/app/settings.cxx @@ -1178,8 +1178,7 @@ void MiscSettings::SetEnableATToolSupport( sal_Bool bEnable ) { if ( bEnable != mpData->mnEnableATT ) { - bool bDummy; - if( bEnable && !ImplInitAccessBridge(false, bDummy) ) + if( bEnable && !ImplInitAccessBridge() ) return; HKEY hkey; diff --git a/vcl/source/app/svapp.cxx b/vcl/source/app/svapp.cxx index 987db604dce2..4474e2066cc8 100644 --- a/vcl/source/app/svapp.cxx +++ b/vcl/source/app/svapp.cxx @@ -1614,17 +1614,15 @@ void Application::AddToRecentDocumentList(const OUString& rFileUrl, const OUStri pSVData->mpDefInst->AddToRecentDocumentList(rFileUrl, rMimeType, rDocumentService); } -bool InitAccessBridge( bool bShowCancel, bool &rCancelled ) +bool InitAccessBridge() { -// Disable Java bridge on UNIX +// Disable MSAA bridge on UNIX #if defined UNX - (void) bShowCancel; // unused - (void) rCancelled; // unused return true; #else - bool bRet = ImplInitAccessBridge( bShowCancel, rCancelled ); + bool bRet = ImplInitAccessBridge(); - if( !bRet && bShowCancel && !rCancelled ) + if( !bRet ) { // disable accessibility if the user chooses to continue AllSettings aSettings = Application::GetSettings(); diff --git a/vcl/source/app/svdata.cxx b/vcl/source/app/svdata.cxx index aa58484fb872..500e18d90476 100644 --- a/vcl/source/app/svdata.cxx +++ b/vcl/source/app/svdata.cxx @@ -45,13 +45,7 @@ #include "salsys.hxx" #include "svids.hrc" -#include "com/sun/star/accessibility/AccessBridge.hpp" #include "com/sun/star/accessibility/MSAAService.hpp" -#include "com/sun/star/awt/XExtendedToolkit.hpp" -#include "com/sun/star/java/JavaNotConfiguredException.hpp" -#include "com/sun/star/java/JavaVMCreationFailureException.hpp" -#include "com/sun/star/java/MissingJavaRuntimeException.hpp" -#include "com/sun/star/java/JavaDisabledException.hpp" #include "officecfg/Office/Common.hxx" @@ -80,14 +74,6 @@ SalSystem* ImplGetSalSystem() return pSVData->mpSalSystem; } - -static OUString ReplaceJavaErrorMessages( const OUString& rString ) -{ - return rString.replaceAll("%OK", Button::GetStandardText(BUTTON_OK)). - replaceAll("%IGNORE", Button::GetStandardText(BUTTON_IGNORE)). - replaceAll("%CANCEL", Button::GetStandardText(BUTTON_CANCEL)); -} - // ======================================================================= void ImplInitSVData() @@ -301,236 +287,37 @@ com::sun::star::uno::Any AccessBridgeCurrentContext::getValueByName( const OUStr bool HasAtHook(); #endif -bool ImplInitAccessBridge(bool bAllowCancel, bool &rCancelled) +bool ImplInitAccessBridge() { - rCancelled = false; - - bool bErrorMessage = true; - - // Note: - // if bAllowCancel is sal_True we were called from application startup - // where we will disable any Java errorboxes and show our own accessibility dialog if Java throws an exception - // if bAllowCancel is sal_False we were called from Tools->Options - // where we will see Java errorboxes, se we do not show our dialogs in addition to Java's - - try + ImplSVData* pSVData = ImplGetSVData(); + if( ! pSVData->mxAccessBridge.is() ) { - // No error messages when env var is set .. - static const char* pEnv = getenv("SAL_ACCESSIBILITY_ENABLED" ); - if( pEnv && *pEnv ) - { - bErrorMessage = false; - } - - ImplSVData* pSVData = ImplGetSVData(); - if( ! pSVData->mxAccessBridge.is() ) - { - css::uno::Reference< XComponentContext > xContext(comphelper::getProcessComponentContext()); + css::uno::Reference< XComponentContext > xContext(comphelper::getProcessComponentContext()); #ifdef _WIN32 - bool bTryIAcc2 = ( officecfg::Office::Common::Misc::ExperimentalMode::get( xContext ) && - !getenv ("SAL_DISABLE_IACCESSIBLE2") ); - - if ( bTryIAcc2 ) // Windows only really - { - if (!HasAtHook() && !getenv("SAL_FORCE_IACCESSIBLE2")) - { - SAL_INFO("vcl", "Apparently no running AT -> " - "not enabling IAccessible2 integration"); - } - else - { - try { - pSVData->mxAccessBridge - = css::accessibility::MSAAService::create(xContext); - SAL_INFO("vcl", "got IAccessible2 bridge"); - return true; - } catch (css::uno::DeploymentException & e) { - SAL_INFO( - "vcl", - "got no IAccessible2 bridge, \"" << e.Message - << "\", falling back to java"); - } - } - } - else - SAL_INFO( "vcl", "IAccessible2 disabled, falling back to java" ); -#endif - - css::uno::Reference< XExtendedToolkit > xToolkit = - css::uno::Reference< XExtendedToolkit >(Application::GetVCLToolkit(), UNO_QUERY); - - // Disable default java error messages on startup, because they were probably unreadable - // for a disabled user. Use native message boxes which are accessible without java support. - // No need to do this when activated by Tools-Options dialog .. - if( bAllowCancel ) - { - // customize the java-not-available-interaction-handler entry within the - // current context when called at startup. - com::sun::star::uno::ContextLayer layer( - new AccessBridgeCurrentContext( com::sun::star::uno::getCurrentContext() ) ); - - pSVData->mxAccessBridge - = css::accessibility::AccessBridge::createWithToolkit( - xContext, xToolkit); - } - else - { - pSVData->mxAccessBridge - = css::accessibility::AccessBridge::createWithToolkit( - xContext, xToolkit); - } - } - - return true; - } - catch (const ::com::sun::star::java::JavaNotConfiguredException&) - { - ResMgr *pResMgr = ImplGetResMgr(); - if( bErrorMessage && bAllowCancel && pResMgr ) + if (!HasAtHook() && !getenv("SAL_DISABLE_IACCESSIBLE2")) { - OUString aTitle(ResId(SV_ACCESSERROR_JAVA_NOT_CONFIGURED, *pResMgr).toString()); - OUStringBuffer aMessage((ResId(SV_ACCESSERROR_JAVA_MSG, *pResMgr)).toString()); - - aMessage.append(' ').append(ResId(SV_ACCESSERROR_OK_CANCEL_MSG, *pResMgr).toString()); - - int ret = ImplGetSalSystem()->ShowNativeMessageBox( - aTitle, - ReplaceJavaErrorMessages(aMessage.makeStringAndClear()), - SALSYSTEM_SHOWNATIVEMSGBOX_BTNCOMBI_OK_CANCEL, - SALSYSTEM_SHOWNATIVEMSGBOX_BTN_CANCEL, true); - - // Do not change the setting in case the user chooses to cancel - if( SALSYSTEM_SHOWNATIVEMSGBOX_BTN_CANCEL == ret ) - rCancelled = true; + SAL_INFO("vcl", "Apparently no running AT -> " + "not enabling IAccessible2 integration"); } - - return false; - } - catch (const ::com::sun::star::java::JavaVMCreationFailureException&) - { - ResMgr *pResMgr = ImplGetResMgr(); - if( bErrorMessage && bAllowCancel && pResMgr ) + else { - OUString aTitle(ResId(SV_ACCESSERROR_FAULTY_JAVA, *pResMgr).toString()); - OUStringBuffer aMessage(ResId(SV_ACCESSERROR_JAVA_MSG, *pResMgr).toString()); - - aMessage.append(' ').append(ResId(SV_ACCESSERROR_OK_CANCEL_MSG, *pResMgr).toString()); - - int ret = ImplGetSalSystem()->ShowNativeMessageBox( - aTitle, - ReplaceJavaErrorMessages(aMessage.makeStringAndClear()), - SALSYSTEM_SHOWNATIVEMSGBOX_BTNCOMBI_OK_CANCEL, - SALSYSTEM_SHOWNATIVEMSGBOX_BTN_CANCEL, true); - - // Do not change the setting in case the user chooses to cancel - if( SALSYSTEM_SHOWNATIVEMSGBOX_BTN_CANCEL == ret ) - rCancelled = true; - } - - return false; - } - catch (const ::com::sun::star::java::MissingJavaRuntimeException&) - { - ResMgr *pResMgr = ImplGetResMgr(); - if( bErrorMessage && bAllowCancel && pResMgr ) - { - OUString aTitle(ResId(SV_ACCESSERROR_MISSING_JAVA, *pResMgr).toString()); - OUStringBuffer aMessage(ResId(SV_ACCESSERROR_JAVA_MSG, *pResMgr).toString()); - - aMessage.append(' ').append(ResId(SV_ACCESSERROR_OK_CANCEL_MSG, *pResMgr).toString()); - - int ret = ImplGetSalSystem()->ShowNativeMessageBox( - aTitle, - ReplaceJavaErrorMessages(aMessage.makeStringAndClear()), - SALSYSTEM_SHOWNATIVEMSGBOX_BTNCOMBI_OK_CANCEL, - SALSYSTEM_SHOWNATIVEMSGBOX_BTN_CANCEL, true); - - // Do not change the setting in case the user chooses to cancel - if( SALSYSTEM_SHOWNATIVEMSGBOX_BTN_CANCEL == ret ) - rCancelled = true; - } - - return false; - } - catch (const ::com::sun::star::java::JavaDisabledException&) - { - ResMgr *pResMgr = ImplGetResMgr(); - if( bErrorMessage && bAllowCancel && pResMgr ) - { - OUString aTitle(ResId(SV_ACCESSERROR_JAVA_DISABLED, *pResMgr).toString()); - OUStringBuffer aMessage(ResId(SV_ACCESSERROR_JAVA_MSG, *pResMgr).toString()); - - aMessage.append(' ').append(ResId(SV_ACCESSERROR_OK_CANCEL_MSG, *pResMgr).toString()); - - int ret = ImplGetSalSystem()->ShowNativeMessageBox( - aTitle, - ReplaceJavaErrorMessages(aMessage.makeStringAndClear()), - SALSYSTEM_SHOWNATIVEMSGBOX_BTNCOMBI_OK_CANCEL, - SALSYSTEM_SHOWNATIVEMSGBOX_BTN_CANCEL, true); - - // Do not change the setting in case the user chooses to cancel - if( SALSYSTEM_SHOWNATIVEMSGBOX_BTN_CANCEL == ret ) - rCancelled = true; + try { + pSVData->mxAccessBridge + = css::accessibility::MSAAService::create(xContext); + SAL_INFO("vcl", "got IAccessible2 bridge"); + return true; + } catch (css::uno::DeploymentException & e) { + SAL_WARN( + "vcl", + "got no IAccessible2 bridge" << e.Message); + return false; + } } - - return false; +#endif } - catch (const ::com::sun::star::uno::RuntimeException& e) - { - ResMgr *pResMgr = ImplGetResMgr(); - if( bErrorMessage && pResMgr ) - { - OUString aTitle; - OUStringBuffer aMessage(ResId(SV_ACCESSERROR_BRIDGE_MSG, *pResMgr).toString()); - - if( e.Message.startsWith("ClassNotFound") ) - { - aTitle = ResId(SV_ACCESSERROR_MISSING_BRIDGE, *pResMgr).toString(); - } - else if( e.Message.startsWith("NoSuchMethod") ) - { - aTitle = ResId(SV_ACCESSERROR_WRONG_VERSION, *pResMgr).toString(); - } - - if (!aTitle.isEmpty()) - { - if( bAllowCancel ) - { - // Something went wrong initializing the Java AccessBridge (on Windows) during the - // startup. Since the office will be probably unusable for a disabled user, we offer - // to terminate directly. - aMessage.append(' ').append(ResId(SV_ACCESSERROR_OK_CANCEL_MSG, *pResMgr).toString()); - - int ret = ImplGetSalSystem()->ShowNativeMessageBox( - aTitle, - ReplaceJavaErrorMessages(aMessage.makeStringAndClear()), - SALSYSTEM_SHOWNATIVEMSGBOX_BTNCOMBI_OK_CANCEL, - SALSYSTEM_SHOWNATIVEMSGBOX_BTN_CANCEL, true); - - // Do not change the setting in case the user chooses to cancel - if( SALSYSTEM_SHOWNATIVEMSGBOX_BTN_CANCEL == ret ) - rCancelled = sal_True; - } - else - { - // The user tried to activate accessibility support using Tools-Options dialog, - // so we don't offer to terminate here ! - ImplGetSalSystem()->ShowNativeMessageBox( - aTitle, - ReplaceJavaErrorMessages(aMessage.makeStringAndClear()), - SALSYSTEM_SHOWNATIVEMSGBOX_BTNCOMBI_OK, - SALSYSTEM_SHOWNATIVEMSGBOX_BTN_OK, true); - } - } - } - return false; - } - catch (...) - { - return false; - } + return true; } // ----------------------------------------------------------------------- diff --git a/vcl/source/src/stdtext.src b/vcl/source/src/stdtext.src index 9a169acafe06..1a33cfa6b9bb 100644 --- a/vcl/source/src/stdtext.src +++ b/vcl/source/src/stdtext.src @@ -34,56 +34,6 @@ String SV_STDTEXT_DONTWARNAGAIN Text [ en-US ] = "Do not show warning again."; }; -String SV_ACCESSERROR_WRONG_VERSION -{ - Text [ en-US ] = "Wrong Version"; -}; - -String SV_ACCESSERROR_BRIDGE_MSG -{ - Text [ en-US ] = "%PRODUCTNAME %PRODUCTVERSION requires a Java Access Bridge 1.0.3 or later version to support accessibility."; -}; - -String SV_ACCESSERROR_OK_CANCEL_MSG -{ - Text [ en-US ] = "Click '%OK' to start %PRODUCTNAME %PRODUCTVERSION without accessibility support, or click '%CANCEL' to exit %PRODUCTNAME %PRODUCTVERSION."; -}; - -String SV_ACCESSERROR_MISSING_BRIDGE -{ - Text [ en-US ] = "No Java Access Bridge"; -}; - -String SV_ACCESSERROR_FAULTY_JAVA -{ - Text [ en-US ] = "Faulty Java Installation"; -}; - -String SV_ACCESSERROR_JAVA_MSG -{ - Text [ en-US ] = "%PRODUCTNAME %PRODUCTVERSION requires Java 1.4.0_02 or later version to support accessibility."; -}; - -String SV_ACCESSERROR_MISSING_JAVA -{ - Text [ en-US ] = "No Java Installation"; -}; - -String SV_ACCESSERROR_JAVA_NOT_CONFIGURED -{ - Text [ en-US ] = "Missing Java Configuration"; -}; - -String SV_ACCESSERROR_JAVA_DISABLED -{ - Text [ en-US ] = "Java Disabled"; -}; - -String SV_ACCESSERROR_TURNAROUND_MSG -{ - Text [ en-US ] = "The Java Access Bridge could not be started."; -}; - String SV_ACCESSERROR_NO_FONTS { Text [ en-US ] = "No fonts could be found on the system."; diff --git a/vcl/win/source/window/salframe.cxx b/vcl/win/source/window/salframe.cxx index f7c30865002c..3602c83f0907 100644 --- a/vcl/win/source/window/salframe.cxx +++ b/vcl/win/source/window/salframe.cxx @@ -5503,9 +5503,7 @@ ImplHandleGetObject(HWND hWnd, LPARAM lParam, WPARAM wParam, LRESULT & nRet) // to avoid RFT interrupts regular accessibility processing if ( !pSVData->mxAccessBridge.is() ) { - bool bCancelled = false; - InitAccessBridge( false, bCancelled ); - if( bCancelled ) + if( !InitAccessBridge() ) return false; } diff --git a/winaccessibility/Module_winaccessibility.mk b/winaccessibility/Module_winaccessibility.mk index b4945cfa93fa..2421164b34bd 100644 --- a/winaccessibility/Module_winaccessibility.mk +++ b/winaccessibility/Module_winaccessibility.mk @@ -11,14 +11,12 @@ $(eval $(call gb_Module_Module,winaccessibility)) ifeq ($(OS),WNT) ifeq ($(COM),MSC) -ifneq ($(ENABLE_IA2),) $(eval $(call gb_Module_add_targets,winaccessibility,\ WinResTarget_uacccom \ CustomTarget_ia2_idl \ Library_uacccom \ Library_winaccessibility \ )) -endif # ENABLE_IA2 endif # COM=MSC endif # WNT |