18622218dSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 38622218dSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 48622218dSAndrew Rist * or more contributor license agreements. See the NOTICE file 58622218dSAndrew Rist * distributed with this work for additional information 68622218dSAndrew Rist * regarding copyright ownership. The ASF licenses this file 78622218dSAndrew Rist * to you under the Apache License, Version 2.0 (the 88622218dSAndrew Rist * "License"); you may not use this file except in compliance 98622218dSAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 118622218dSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 138622218dSAndrew Rist * Unless required by applicable law or agreed to in writing, 148622218dSAndrew Rist * software distributed under the License is distributed on an 158622218dSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 168622218dSAndrew Rist * KIND, either express or implied. See the License for the 178622218dSAndrew Rist * specific language governing permissions and limitations 188622218dSAndrew Rist * under the License. 19cdf0e10cSrcweir * 208622218dSAndrew Rist *************************************************************/ 218622218dSAndrew Rist 228622218dSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir package org.openoffice.java.accessibility; 25cdf0e10cSrcweir 26cdf0e10cSrcweir import com.sun.star.uno.*; 27cdf0e10cSrcweir import com.sun.star.accessibility.*; 28cdf0e10cSrcweir 29cdf0e10cSrcweir public class Window extends java.awt.Window implements javax.accessibility.Accessible, NativeFrame { 30cdf0e10cSrcweir protected XAccessibleComponent unoAccessibleComponent; 31cdf0e10cSrcweir 32cdf0e10cSrcweir boolean opened = false; 33cdf0e10cSrcweir boolean visible = false; 34cdf0e10cSrcweir 35cdf0e10cSrcweir java.awt.EventQueue eventQueue = null; 36cdf0e10cSrcweir Window(java.awt.Window owner, XAccessibleComponent xAccessibleComponent)37cdf0e10cSrcweir public Window(java.awt.Window owner, XAccessibleComponent xAccessibleComponent) { 38cdf0e10cSrcweir super(owner); 39cdf0e10cSrcweir initialize(xAccessibleComponent); 40cdf0e10cSrcweir } 41cdf0e10cSrcweir initialize(XAccessibleComponent xAccessibleComponent)42cdf0e10cSrcweir private void initialize(XAccessibleComponent xAccessibleComponent) { 43cdf0e10cSrcweir unoAccessibleComponent = xAccessibleComponent; 44cdf0e10cSrcweir eventQueue = java.awt.Toolkit.getDefaultToolkit().getSystemEventQueue(); 45cdf0e10cSrcweir XAccessibleEventBroadcaster broadcaster = (XAccessibleEventBroadcaster) 46cdf0e10cSrcweir UnoRuntime.queryInterface(XAccessibleEventBroadcaster.class, 47cdf0e10cSrcweir unoAccessibleComponent); 48cdf0e10cSrcweir if (broadcaster != null) { 49cdf0e10cSrcweir broadcaster.addEventListener(new AccessibleWindowListener()); 50cdf0e10cSrcweir } 51cdf0e10cSrcweir } 52cdf0e10cSrcweir 53cdf0e10cSrcweir java.awt.Component initialComponent = null; 54cdf0e10cSrcweir getInitialComponent()55cdf0e10cSrcweir public java.awt.Component getInitialComponent() { 56cdf0e10cSrcweir if (Build.DEBUG) { 57cdf0e10cSrcweir System.err.println("returning initial component object of class: " + initialComponent.getClass().getName()); 58cdf0e10cSrcweir } 59cdf0e10cSrcweir return initialComponent; 60cdf0e10cSrcweir } 61cdf0e10cSrcweir setInitialComponent(java.awt.Component c)62cdf0e10cSrcweir public void setInitialComponent(java.awt.Component c) { 63cdf0e10cSrcweir initialComponent = c; 64cdf0e10cSrcweir } 65cdf0e10cSrcweir getHWND()66cdf0e10cSrcweir public Integer getHWND() { 67cdf0e10cSrcweir return null; 68cdf0e10cSrcweir } 69cdf0e10cSrcweir 70cdf0e10cSrcweir /** 71cdf0e10cSrcweir * Determines whether this <code>Component</code> is showing on screen. 72cdf0e10cSrcweir * This means that the component must be visible, and it must be in a 73cdf0e10cSrcweir * <code>container</code> that is visible and showing. 74cdf0e10cSrcweir * @see #addNotify 75cdf0e10cSrcweir * @see #removeNotify 76cdf0e10cSrcweir * @since JDK1.0 77cdf0e10cSrcweir */ isShowing()78cdf0e10cSrcweir public boolean isShowing() { 79cdf0e10cSrcweir if (isVisible()) { 80cdf0e10cSrcweir java.awt.Container parent = getParent(); 81cdf0e10cSrcweir return (parent == null) || parent.isShowing(); 82cdf0e10cSrcweir } 83cdf0e10cSrcweir return false; 84cdf0e10cSrcweir } 85cdf0e10cSrcweir 86cdf0e10cSrcweir /** 87cdf0e10cSrcweir * Makes this <code>Component</code> displayable by connecting it to a 88cdf0e10cSrcweir * native screen resource. 89cdf0e10cSrcweir * This method is called internally by the toolkit and should 90cdf0e10cSrcweir * not be called directly by programs. 91cdf0e10cSrcweir * @see #isDisplayable 92cdf0e10cSrcweir * @see #removeNotify 93cdf0e10cSrcweir * @since JDK1.0 94cdf0e10cSrcweir */ addNotify()95cdf0e10cSrcweir public void addNotify() { 96cdf0e10cSrcweir // createHierarchyEvents(0, null, null, 0, false); 97cdf0e10cSrcweir } 98cdf0e10cSrcweir 99cdf0e10cSrcweir /** 100cdf0e10cSrcweir * Makes this <code>Component</code> undisplayable by destroying it native 101cdf0e10cSrcweir * screen resource. 102cdf0e10cSrcweir * This method is called by the toolkit internally and should 103cdf0e10cSrcweir * not be called directly by programs. 104cdf0e10cSrcweir * @see #isDisplayable 105cdf0e10cSrcweir * @see #addNotify 106cdf0e10cSrcweir * @since JDK1.0 107cdf0e10cSrcweir */ removeNotify()108cdf0e10cSrcweir public void removeNotify() { 109cdf0e10cSrcweir } 110cdf0e10cSrcweir 111cdf0e10cSrcweir /** 112cdf0e10cSrcweir * Determines if the object is visible. Note: this means that the 113cdf0e10cSrcweir * object intends to be visible; however, it may not in fact be 114cdf0e10cSrcweir * showing on the screen because one of the objects that this object 115cdf0e10cSrcweir * is contained by is not visible. To determine if an object is 116cdf0e10cSrcweir * showing on the screen, use <code>isShowing</code>. 117cdf0e10cSrcweir * 118cdf0e10cSrcweir * @return true if object is visible; otherwise, false 119cdf0e10cSrcweir */ isVisible()120cdf0e10cSrcweir public boolean isVisible(){ 121cdf0e10cSrcweir return visible; 122cdf0e10cSrcweir } 123cdf0e10cSrcweir 124cdf0e10cSrcweir /** 125cdf0e10cSrcweir * Shows or hides this component depending on the value of parameter 126cdf0e10cSrcweir * <code>b</code>. 127cdf0e10cSrcweir * @param b if <code>true</code>, shows this component; 128cdf0e10cSrcweir * otherwise, hides this component 129cdf0e10cSrcweir * @see #isVisible 130cdf0e10cSrcweir * @since JDK1.1 131cdf0e10cSrcweir */ setVisible(boolean b)132cdf0e10cSrcweir public void setVisible(boolean b) { 133cdf0e10cSrcweir if (visible != b){ 134cdf0e10cSrcweir visible = b; 135cdf0e10cSrcweir if (b) { 136cdf0e10cSrcweir // If it is the first show, fire WINDOW_OPENED event 137cdf0e10cSrcweir if (!opened) { 138cdf0e10cSrcweir postWindowEvent(java.awt.event.WindowEvent.WINDOW_OPENED); 139cdf0e10cSrcweir opened = true; 140cdf0e10cSrcweir } 141cdf0e10cSrcweir postComponentEvent(java.awt.event.ComponentEvent.COMPONENT_SHOWN); 142cdf0e10cSrcweir } else { 143cdf0e10cSrcweir postComponentEvent(java.awt.event.ComponentEvent.COMPONENT_HIDDEN); 144cdf0e10cSrcweir } 145cdf0e10cSrcweir } 146cdf0e10cSrcweir } 147cdf0e10cSrcweir dispose()148cdf0e10cSrcweir public void dispose() { 149cdf0e10cSrcweir setVisible(false); 150cdf0e10cSrcweir postWindowEvent(java.awt.event.WindowEvent.WINDOW_CLOSED); 151cdf0e10cSrcweir 152cdf0e10cSrcweir // Transfer window focus back to the owner window if it is still the active frame 153cdf0e10cSrcweir if ((getOwner() instanceof Frame && ((Frame) getOwner()).active) || 154cdf0e10cSrcweir (getOwner() instanceof Dialog && ((Dialog) getOwner()).active)) { 155cdf0e10cSrcweir eventQueue.postEvent(new java.awt.event.WindowEvent(getOwner(), 156cdf0e10cSrcweir java.awt.event.WindowEvent.WINDOW_GAINED_FOCUS)); 157cdf0e10cSrcweir } 158cdf0e10cSrcweir } 159cdf0e10cSrcweir postWindowEvent(int i)160cdf0e10cSrcweir protected void postWindowEvent(int i) { 161cdf0e10cSrcweir eventQueue.postEvent(new java.awt.event.WindowEvent(this, i)); 162cdf0e10cSrcweir } 163cdf0e10cSrcweir postComponentEvent(int i)164cdf0e10cSrcweir protected void postComponentEvent(int i) { 165cdf0e10cSrcweir eventQueue.postEvent(new java.awt.event.ComponentEvent(this, i)); 166cdf0e10cSrcweir } 167cdf0e10cSrcweir 168cdf0e10cSrcweir /** 169cdf0e10cSrcweir * Update the proxy objects appropriatly on property change events 170cdf0e10cSrcweir */ 171cdf0e10cSrcweir protected class AccessibleWindowListener implements XAccessibleEventListener { 172cdf0e10cSrcweir AccessibleWindowListener()173cdf0e10cSrcweir protected AccessibleWindowListener() { 174cdf0e10cSrcweir } 175cdf0e10cSrcweir 176cdf0e10cSrcweir // The only expected state changes are ACTIVE and VISIBLE setComponentState(short state, boolean enable)177cdf0e10cSrcweir protected void setComponentState(short state, boolean enable) { 178cdf0e10cSrcweir switch (state) { 179cdf0e10cSrcweir case AccessibleStateType.ICONIFIED: 180cdf0e10cSrcweir postWindowEvent(enable ? 181cdf0e10cSrcweir java.awt.event.WindowEvent.WINDOW_ICONIFIED : 182cdf0e10cSrcweir java.awt.event.WindowEvent.WINDOW_DEICONIFIED); 183cdf0e10cSrcweir break; 184cdf0e10cSrcweir case AccessibleStateType.SHOWING: 185cdf0e10cSrcweir case AccessibleStateType.VISIBLE: 186cdf0e10cSrcweir setVisible(enable); 187cdf0e10cSrcweir break; 188cdf0e10cSrcweir default: 189cdf0e10cSrcweir if (Build.DEBUG) { 190cdf0e10cSrcweir // System.err.println("[frame]: " + getTitle() + "unexpected state change " + state); 191cdf0e10cSrcweir } 192cdf0e10cSrcweir break; 193cdf0e10cSrcweir } 194cdf0e10cSrcweir } 195cdf0e10cSrcweir 196cdf0e10cSrcweir /** Updates the accessible name and fires the appropriate PropertyChangedEvent */ handleNameChangedEvent(Object any)197cdf0e10cSrcweir protected void handleNameChangedEvent(Object any) { 198cdf0e10cSrcweir try { 199cdf0e10cSrcweir // This causes the property change event to be fired in the VCL thread 200cdf0e10cSrcweir // context. If this causes problems, it has to be deligated to the java 201cdf0e10cSrcweir // dispatch thread .. 202cdf0e10cSrcweir javax.accessibility.AccessibleContext ac = accessibleContext; 203cdf0e10cSrcweir if (ac!= null) { 204cdf0e10cSrcweir ac.setAccessibleName(AnyConverter.toString(any)); 205cdf0e10cSrcweir } 206cdf0e10cSrcweir } catch (com.sun.star.lang.IllegalArgumentException e) { 207cdf0e10cSrcweir } 208cdf0e10cSrcweir } 209cdf0e10cSrcweir 210cdf0e10cSrcweir /** Updates the accessible description and fires the appropriate PropertyChangedEvent */ handleDescriptionChangedEvent(Object any)211cdf0e10cSrcweir protected void handleDescriptionChangedEvent(Object any) { 212cdf0e10cSrcweir try { 213cdf0e10cSrcweir // This causes the property change event to be fired in the VCL thread 214cdf0e10cSrcweir // context. If this causes problems, it has to be deligated to the java 215cdf0e10cSrcweir // dispatch thread .. 216cdf0e10cSrcweir if (accessibleContext != null) { 217cdf0e10cSrcweir accessibleContext.setAccessibleDescription(AnyConverter.toString(any)); 218cdf0e10cSrcweir } 219cdf0e10cSrcweir } catch (com.sun.star.lang.IllegalArgumentException e) { 220cdf0e10cSrcweir } 221cdf0e10cSrcweir } 222cdf0e10cSrcweir 223cdf0e10cSrcweir /** Updates the internal states and fires the appropriate PropertyChangedEvent */ handleStateChangedEvent(Object any1, Object any2)224cdf0e10cSrcweir protected void handleStateChangedEvent(Object any1, Object any2) { 225cdf0e10cSrcweir try { 226cdf0e10cSrcweir if (AnyConverter.isShort(any1)) { 227cdf0e10cSrcweir setComponentState(AnyConverter.toShort(any1), false); 228cdf0e10cSrcweir } 229cdf0e10cSrcweir 230cdf0e10cSrcweir if (AnyConverter.isShort(any2)) { 231cdf0e10cSrcweir setComponentState(AnyConverter.toShort(any2), true); 232cdf0e10cSrcweir } 233cdf0e10cSrcweir } catch (com.sun.star.lang.IllegalArgumentException e) { 234cdf0e10cSrcweir } 235cdf0e10cSrcweir } 236cdf0e10cSrcweir 237cdf0e10cSrcweir /** Fires a visible data property change event */ handleVisibleDataEvent()238cdf0e10cSrcweir protected void handleVisibleDataEvent() { 239cdf0e10cSrcweir javax.accessibility.AccessibleContext ac = accessibleContext; 240cdf0e10cSrcweir if (ac != null) { 241cdf0e10cSrcweir ac.firePropertyChange(javax.accessibility.AccessibleContext.ACCESSIBLE_VISIBLE_DATA_PROPERTY, null, null); 242cdf0e10cSrcweir } 243cdf0e10cSrcweir } 244cdf0e10cSrcweir 245cdf0e10cSrcweir /** Called by OpenOffice process to notify property changes */ notifyEvent(AccessibleEventObject event)246cdf0e10cSrcweir public void notifyEvent(AccessibleEventObject event) { 247cdf0e10cSrcweir switch (event.EventId) { 248cdf0e10cSrcweir case AccessibleEventId.NAME_CHANGED: 249cdf0e10cSrcweir // Set the accessible name for the corresponding context, which will fire a property 250cdf0e10cSrcweir // change event itself 251cdf0e10cSrcweir handleNameChangedEvent(event.NewValue); 252cdf0e10cSrcweir break; 253cdf0e10cSrcweir case AccessibleEventId.DESCRIPTION_CHANGED: 254cdf0e10cSrcweir // Set the accessible description for the corresponding context, which will fire a property 255cdf0e10cSrcweir // change event itself - so do not set propertyName ! 256cdf0e10cSrcweir handleDescriptionChangedEvent(event.NewValue); 257cdf0e10cSrcweir break; 258cdf0e10cSrcweir case AccessibleEventId.STATE_CHANGED: 259cdf0e10cSrcweir // Update the internal state set and fire the appropriate PropertyChangedEvent 260cdf0e10cSrcweir handleStateChangedEvent(event.OldValue, event.NewValue); 261cdf0e10cSrcweir break; 262cdf0e10cSrcweir case AccessibleEventId.CHILD: 263cdf0e10cSrcweir if (AnyConverter.isObject(event.OldValue)) { 264cdf0e10cSrcweir AccessibleObjectFactory.removeChild(Window.this, event.OldValue); 265cdf0e10cSrcweir } else if (AnyConverter.isObject(event.NewValue)) { 266cdf0e10cSrcweir AccessibleObjectFactory.addChild(Window.this, event.NewValue); 267cdf0e10cSrcweir } 268cdf0e10cSrcweir break; 269cdf0e10cSrcweir case AccessibleEventId.VISIBLE_DATA_CHANGED: 270cdf0e10cSrcweir case AccessibleEventId.BOUNDRECT_CHANGED: 271cdf0e10cSrcweir handleVisibleDataEvent(); 272cdf0e10cSrcweir break; 273cdf0e10cSrcweir default: 274cdf0e10cSrcweir // Warn about unhandled events 275cdf0e10cSrcweir if(Build.DEBUG) { 276cdf0e10cSrcweir System.out.println(this + ": unhandled accessibility event id=" + event.EventId); 277cdf0e10cSrcweir } 278cdf0e10cSrcweir } 279cdf0e10cSrcweir } 280cdf0e10cSrcweir 281cdf0e10cSrcweir /** Called by OpenOffice process to notify that the UNO component is disposing */ disposing(com.sun.star.lang.EventObject eventObject)282cdf0e10cSrcweir public void disposing(com.sun.star.lang.EventObject eventObject) { 283cdf0e10cSrcweir } 284cdf0e10cSrcweir } 285cdf0e10cSrcweir 286cdf0e10cSrcweir protected javax.accessibility.AccessibleContext accessibleContext = null; 287cdf0e10cSrcweir 288cdf0e10cSrcweir /** Returns the AccessibleContext associated with this object */ getAccessibleContext()289cdf0e10cSrcweir public javax.accessibility.AccessibleContext getAccessibleContext() { 290cdf0e10cSrcweir if (accessibleContext == null) { 291cdf0e10cSrcweir accessibleContext = new AccessibleWindow(); 292cdf0e10cSrcweir // accessibleContext.setAccessibleName(getTitle()); 293cdf0e10cSrcweir } 294cdf0e10cSrcweir return accessibleContext; 295cdf0e10cSrcweir } 296cdf0e10cSrcweir 297cdf0e10cSrcweir protected class AccessibleWindow extends java.awt.Window.AccessibleAWTWindow { AccessibleWindow()298cdf0e10cSrcweir protected AccessibleWindow() { 299cdf0e10cSrcweir super(); 300cdf0e10cSrcweir } 301cdf0e10cSrcweir 302cdf0e10cSrcweir protected java.awt.event.ComponentListener accessibleComponentHandler = null; 303cdf0e10cSrcweir 304cdf0e10cSrcweir /** 305cdf0e10cSrcweir * Fire PropertyChange listener, if one is registered, 306cdf0e10cSrcweir * when shown/hidden.. 307cdf0e10cSrcweir */ 308cdf0e10cSrcweir protected class AccessibleComponentHandler implements java.awt.event.ComponentListener { componentHidden(java.awt.event.ComponentEvent e)309cdf0e10cSrcweir public void componentHidden(java.awt.event.ComponentEvent e) { 310cdf0e10cSrcweir AccessibleWindow.this.firePropertyChange( 311cdf0e10cSrcweir javax.accessibility.AccessibleContext.ACCESSIBLE_STATE_PROPERTY, 312cdf0e10cSrcweir javax.accessibility.AccessibleState.VISIBLE, null); 313cdf0e10cSrcweir } 314cdf0e10cSrcweir componentShown(java.awt.event.ComponentEvent e)315cdf0e10cSrcweir public void componentShown(java.awt.event.ComponentEvent e) { 316cdf0e10cSrcweir AccessibleWindow.this.firePropertyChange( 317cdf0e10cSrcweir javax.accessibility.AccessibleContext.ACCESSIBLE_STATE_PROPERTY, 318cdf0e10cSrcweir null, javax.accessibility.AccessibleState.VISIBLE); 319cdf0e10cSrcweir } 320cdf0e10cSrcweir componentMoved(java.awt.event.ComponentEvent e)321cdf0e10cSrcweir public void componentMoved(java.awt.event.ComponentEvent e) { 322cdf0e10cSrcweir } 323cdf0e10cSrcweir componentResized(java.awt.event.ComponentEvent e)324cdf0e10cSrcweir public void componentResized(java.awt.event.ComponentEvent e) { 325cdf0e10cSrcweir } 326cdf0e10cSrcweir } // inner class AccessibleComponentHandler 327cdf0e10cSrcweir 328cdf0e10cSrcweir protected java.awt.event.ContainerListener accessibleContainerHandler = null; 329cdf0e10cSrcweir 330cdf0e10cSrcweir /** 331cdf0e10cSrcweir * Fire PropertyChange listener, if one is registered, 332cdf0e10cSrcweir * when children added/removed. 333cdf0e10cSrcweir */ 334cdf0e10cSrcweir 335cdf0e10cSrcweir protected class AccessibleContainerHandler implements java.awt.event.ContainerListener { componentAdded(java.awt.event.ContainerEvent e)336cdf0e10cSrcweir public void componentAdded(java.awt.event.ContainerEvent e) { 337cdf0e10cSrcweir java.awt.Component c = e.getChild(); 338cdf0e10cSrcweir if (c != null && c instanceof javax.accessibility.Accessible) { 339cdf0e10cSrcweir AccessibleWindow.this.firePropertyChange( 340cdf0e10cSrcweir javax.accessibility.AccessibleContext.ACCESSIBLE_CHILD_PROPERTY, 341cdf0e10cSrcweir null, ((javax.accessibility.Accessible) c).getAccessibleContext()); 342cdf0e10cSrcweir } 343cdf0e10cSrcweir } componentRemoved(java.awt.event.ContainerEvent e)344cdf0e10cSrcweir public void componentRemoved(java.awt.event.ContainerEvent e) { 345cdf0e10cSrcweir java.awt.Component c = e.getChild(); 346cdf0e10cSrcweir if (c != null && c instanceof javax.accessibility.Accessible) { 347cdf0e10cSrcweir AccessibleWindow.this.firePropertyChange( 348cdf0e10cSrcweir javax.accessibility.AccessibleContext.ACCESSIBLE_CHILD_PROPERTY, 349cdf0e10cSrcweir ((javax.accessibility.Accessible) c).getAccessibleContext(), null); 350cdf0e10cSrcweir } 351cdf0e10cSrcweir } 352cdf0e10cSrcweir } 353cdf0e10cSrcweir 354cdf0e10cSrcweir protected int propertyChangeListenerCount = 0; 355cdf0e10cSrcweir 356cdf0e10cSrcweir /** 357cdf0e10cSrcweir * Add a PropertyChangeListener to the listener list. 358cdf0e10cSrcweir * 359cdf0e10cSrcweir * @param listener The PropertyChangeListener to be added 360cdf0e10cSrcweir */ addPropertyChangeListener(java.beans.PropertyChangeListener listener)361cdf0e10cSrcweir public void addPropertyChangeListener(java.beans.PropertyChangeListener listener) { 362cdf0e10cSrcweir if (propertyChangeListenerCount++ == 0) { 363cdf0e10cSrcweir accessibleContainerHandler = new AccessibleContainerHandler(); 364cdf0e10cSrcweir Window.this.addContainerListener(accessibleContainerHandler); 365cdf0e10cSrcweir 366cdf0e10cSrcweir accessibleComponentHandler = new AccessibleComponentHandler(); 367cdf0e10cSrcweir Window.this.addComponentListener(accessibleComponentHandler); 368cdf0e10cSrcweir } 369cdf0e10cSrcweir super.addPropertyChangeListener(listener); 370cdf0e10cSrcweir } 371cdf0e10cSrcweir 372cdf0e10cSrcweir /** 373cdf0e10cSrcweir * Remove a PropertyChangeListener from the listener list. 374cdf0e10cSrcweir * This removes a PropertyChangeListener that was registered 375cdf0e10cSrcweir * for all properties. 376cdf0e10cSrcweir * 377cdf0e10cSrcweir * @param listener The PropertyChangeListener to be removed 378cdf0e10cSrcweir */ removePropertyChangeListener(java.beans.PropertyChangeListener listener)379cdf0e10cSrcweir public void removePropertyChangeListener(java.beans.PropertyChangeListener listener) { 380cdf0e10cSrcweir if (--propertyChangeListenerCount == 0) { 381cdf0e10cSrcweir Window.this.removeComponentListener(accessibleComponentHandler); 382cdf0e10cSrcweir accessibleComponentHandler = null; 383cdf0e10cSrcweir 384cdf0e10cSrcweir Window.this.removeContainerListener(accessibleContainerHandler); 385cdf0e10cSrcweir accessibleContainerHandler = null; 386cdf0e10cSrcweir } 387cdf0e10cSrcweir super.removePropertyChangeListener(listener); 388cdf0e10cSrcweir } 389cdf0e10cSrcweir 390cdf0e10cSrcweir /* 391cdf0e10cSrcweir * AccessibleComponent 392cdf0e10cSrcweir */ 393cdf0e10cSrcweir 394cdf0e10cSrcweir /** Returns the background color of the object */ getBackground()395cdf0e10cSrcweir public java.awt.Color getBackground() { 396cdf0e10cSrcweir try { 397cdf0e10cSrcweir return new java.awt.Color(unoAccessibleComponent.getBackground()); 398cdf0e10cSrcweir } catch (com.sun.star.uno.RuntimeException e) { 399cdf0e10cSrcweir return null; 400cdf0e10cSrcweir } 401cdf0e10cSrcweir } 402cdf0e10cSrcweir setBackground(java.awt.Color c)403cdf0e10cSrcweir public void setBackground(java.awt.Color c) { 404cdf0e10cSrcweir // Not supported by UNO accessibility API 405cdf0e10cSrcweir } 406cdf0e10cSrcweir 407cdf0e10cSrcweir /** Returns the foreground color of the object */ getForeground()408cdf0e10cSrcweir public java.awt.Color getForeground() { 409cdf0e10cSrcweir try { 410cdf0e10cSrcweir return new java.awt.Color(unoAccessibleComponent.getForeground()); 411cdf0e10cSrcweir } catch (com.sun.star.uno.RuntimeException e) { 412cdf0e10cSrcweir return null; 413cdf0e10cSrcweir } 414cdf0e10cSrcweir } 415cdf0e10cSrcweir setForeground(java.awt.Color c)416cdf0e10cSrcweir public void setForeground(java.awt.Color c) { 417cdf0e10cSrcweir // Not supported by UNO accessibility API 418cdf0e10cSrcweir } 419cdf0e10cSrcweir getCursor()420cdf0e10cSrcweir public java.awt.Cursor getCursor() { 421cdf0e10cSrcweir // Not supported by UNO accessibility API 422cdf0e10cSrcweir return null; 423cdf0e10cSrcweir } 424cdf0e10cSrcweir setCursor(java.awt.Cursor cursor)425cdf0e10cSrcweir public void setCursor(java.awt.Cursor cursor) { 426cdf0e10cSrcweir // Not supported by UNO accessibility API 427cdf0e10cSrcweir } 428cdf0e10cSrcweir getFont()429cdf0e10cSrcweir public java.awt.Font getFont() { 430cdf0e10cSrcweir // FIXME 431cdf0e10cSrcweir return null; 432cdf0e10cSrcweir } 433cdf0e10cSrcweir setFont(java.awt.Font f)434cdf0e10cSrcweir public void setFont(java.awt.Font f) { 435cdf0e10cSrcweir // Not supported by UNO accessibility API 436cdf0e10cSrcweir } 437cdf0e10cSrcweir getFontMetrics(java.awt.Font f)438cdf0e10cSrcweir public java.awt.FontMetrics getFontMetrics(java.awt.Font f) { 439cdf0e10cSrcweir // FIXME 440cdf0e10cSrcweir return null; 441cdf0e10cSrcweir } 442cdf0e10cSrcweir isEnabled()443cdf0e10cSrcweir public boolean isEnabled() { 444cdf0e10cSrcweir return Window.this.isEnabled(); 445cdf0e10cSrcweir } 446cdf0e10cSrcweir setEnabled(boolean b)447cdf0e10cSrcweir public void setEnabled(boolean b) { 448cdf0e10cSrcweir // Not supported by UNO accessibility API 449cdf0e10cSrcweir } 450cdf0e10cSrcweir isVisible()451cdf0e10cSrcweir public boolean isVisible() { 452cdf0e10cSrcweir return Window.this.isVisible(); 453cdf0e10cSrcweir } 454cdf0e10cSrcweir setVisible(boolean b)455cdf0e10cSrcweir public void setVisible(boolean b) { 456cdf0e10cSrcweir // Not supported by UNO accessibility API 457cdf0e10cSrcweir } 458cdf0e10cSrcweir isShowing()459cdf0e10cSrcweir public boolean isShowing() { 460cdf0e10cSrcweir return Window.this.isShowing(); 461cdf0e10cSrcweir } 462cdf0e10cSrcweir contains(java.awt.Point p)463cdf0e10cSrcweir public boolean contains(java.awt.Point p) { 464cdf0e10cSrcweir try { 465cdf0e10cSrcweir return unoAccessibleComponent.containsPoint(new com.sun.star.awt.Point(p.x, p.y)); 466cdf0e10cSrcweir } catch (com.sun.star.uno.RuntimeException e) { 467cdf0e10cSrcweir return false; 468cdf0e10cSrcweir } 469cdf0e10cSrcweir } 470cdf0e10cSrcweir 471cdf0e10cSrcweir /** Returns the location of the object on the screen. */ getLocationOnScreen()472cdf0e10cSrcweir public java.awt.Point getLocationOnScreen() { 473cdf0e10cSrcweir try { 474cdf0e10cSrcweir com.sun.star.awt.Point unoPoint = unoAccessibleComponent.getLocationOnScreen(); 475cdf0e10cSrcweir return new java.awt.Point(unoPoint.X, unoPoint.Y); 476cdf0e10cSrcweir } catch (com.sun.star.uno.RuntimeException e) { 477cdf0e10cSrcweir return null; 478cdf0e10cSrcweir } 479cdf0e10cSrcweir } 480cdf0e10cSrcweir 481cdf0e10cSrcweir /** Gets the location of this component in the form of a point specifying the component's top-left corner */ getLocation()482cdf0e10cSrcweir public java.awt.Point getLocation() { 483cdf0e10cSrcweir try { 484cdf0e10cSrcweir com.sun.star.awt.Point unoPoint = unoAccessibleComponent.getLocationOnScreen(); 485cdf0e10cSrcweir return new java.awt.Point( unoPoint.X, unoPoint.Y ); 486cdf0e10cSrcweir } catch (com.sun.star.uno.RuntimeException e) { 487cdf0e10cSrcweir return null; 488cdf0e10cSrcweir } 489cdf0e10cSrcweir } 490cdf0e10cSrcweir 491cdf0e10cSrcweir /** Moves this component to a new location */ setLocation(java.awt.Point p)492cdf0e10cSrcweir public void setLocation(java.awt.Point p) { 493cdf0e10cSrcweir // Not supported by UNO accessibility API 494cdf0e10cSrcweir } 495cdf0e10cSrcweir 496cdf0e10cSrcweir /** Gets the bounds of this component in the form of a Rectangle object */ getBounds()497cdf0e10cSrcweir public java.awt.Rectangle getBounds() { 498cdf0e10cSrcweir try { 499cdf0e10cSrcweir com.sun.star.awt.Rectangle unoRect = unoAccessibleComponent.getBounds(); 500cdf0e10cSrcweir return new java.awt.Rectangle(unoRect.X, unoRect.Y, unoRect.Width, unoRect.Height); 501cdf0e10cSrcweir } catch (com.sun.star.uno.RuntimeException e) { 502cdf0e10cSrcweir return null; 503cdf0e10cSrcweir } 504cdf0e10cSrcweir } 505cdf0e10cSrcweir 506cdf0e10cSrcweir /** Moves and resizes this component to conform to the new bounding rectangle r */ setBounds(java.awt.Rectangle r)507cdf0e10cSrcweir public void setBounds(java.awt.Rectangle r) { 508cdf0e10cSrcweir // Not supported by UNO accessibility API 509cdf0e10cSrcweir } 510cdf0e10cSrcweir 511cdf0e10cSrcweir /** Returns the size of this component in the form of a Dimension object */ getSize()512cdf0e10cSrcweir public java.awt.Dimension getSize() { 513cdf0e10cSrcweir try { 514cdf0e10cSrcweir com.sun.star.awt.Size unoSize = unoAccessibleComponent.getSize(); 515cdf0e10cSrcweir return new java.awt.Dimension(unoSize.Width, unoSize.Height); 516cdf0e10cSrcweir } catch (com.sun.star.uno.RuntimeException e) { 517cdf0e10cSrcweir return null; 518cdf0e10cSrcweir } 519cdf0e10cSrcweir } 520cdf0e10cSrcweir 521cdf0e10cSrcweir /** Resizes this component so that it has width d.width and height d.height */ setSize(java.awt.Dimension d)522cdf0e10cSrcweir public void setSize(java.awt.Dimension d) { 523cdf0e10cSrcweir // Not supported by UNO accessibility API 524cdf0e10cSrcweir } 525cdf0e10cSrcweir 526cdf0e10cSrcweir /** Returns the Accessible child, if one exists, contained at the local coordinate Point */ getAccessibleAt(java.awt.Point p)527cdf0e10cSrcweir public javax.accessibility.Accessible getAccessibleAt(java.awt.Point p) { 528cdf0e10cSrcweir try { 529cdf0e10cSrcweir java.awt.Component c = AccessibleObjectFactory.getAccessibleComponent( 530cdf0e10cSrcweir unoAccessibleComponent.getAccessibleAtPoint(new com.sun.star.awt.Point(p.x, p.y))); 531cdf0e10cSrcweir 532cdf0e10cSrcweir return (javax.accessibility.Accessible) c; 533cdf0e10cSrcweir } catch (com.sun.star.uno.RuntimeException e) { 534cdf0e10cSrcweir return null; 535cdf0e10cSrcweir } 536cdf0e10cSrcweir } 537cdf0e10cSrcweir isFocusTraversable()538cdf0e10cSrcweir public boolean isFocusTraversable() { 539cdf0e10cSrcweir return Window.this.isFocusable(); 540cdf0e10cSrcweir } 541cdf0e10cSrcweir requestFocus()542cdf0e10cSrcweir public void requestFocus() { 543cdf0e10cSrcweir unoAccessibleComponent.grabFocus(); 544cdf0e10cSrcweir } 545cdf0e10cSrcweir } 546*31239e44SJürgen Schmidt 547*31239e44SJürgen Schmidt /** 548*31239e44SJürgen Schmidt * Determines whether this component is displayable. A component is 549*31239e44SJürgen Schmidt * displayable when it is connected to a native screen resource. 550*31239e44SJürgen Schmidt * <p> 551*31239e44SJürgen Schmidt * A component is made displayable either when it is added to 552*31239e44SJürgen Schmidt * a displayable containment hierarchy or when its containment 553*31239e44SJürgen Schmidt * hierarchy is made displayable. 554*31239e44SJürgen Schmidt * A containment hierarchy is made displayable when its ancestor 555*31239e44SJürgen Schmidt * window is either packed or made visible. 556*31239e44SJürgen Schmidt * <p> 557*31239e44SJürgen Schmidt * A component is made undisplayable either when it is removed from 558*31239e44SJürgen Schmidt * a displayable containment hierarchy or when its containment hierarchy 559*31239e44SJürgen Schmidt * is made undisplayable. A containment hierarchy is made 560*31239e44SJürgen Schmidt * undisplayable when its ancestor window is disposed. 561*31239e44SJürgen Schmidt * 562*31239e44SJürgen Schmidt * @return <code>true</code> if the component is displayable 563*31239e44SJürgen Schmidt */ 564*31239e44SJürgen Schmidt @Override isDisplayable()565*31239e44SJürgen Schmidt public boolean isDisplayable() { 566*31239e44SJürgen Schmidt return true; 567*31239e44SJürgen Schmidt } 568*31239e44SJürgen Schmidt 569cdf0e10cSrcweir } 570cdf0e10cSrcweir 571