diff options
author | Jens-Heiner Rechtien <hr@openoffice.org> | 2010-01-28 19:03:55 +0000 |
---|---|---|
committer | Jens-Heiner Rechtien <hr@openoffice.org> | 2010-01-28 19:03:55 +0000 |
commit | 14a24d0d60d55612e56c22408fd52c73afd54889 (patch) | |
tree | a31fef8fb256f7f83ab9a4e6ce038f1b3dbd04ac /accessibility | |
parent | 9ef6125e16b8f0b539da93fa7acf8b2df6427408 (diff) | |
parent | 99066b04d3454e18785b34ebb5df93c5e1478a8f (diff) |
koheidatapilot03: merge with DEV300_m57
Diffstat (limited to 'accessibility')
70 files changed, 10419 insertions, 4 deletions
diff --git a/accessibility/prj/build.lst b/accessibility/prj/build.lst index 2288410ff..351473e38 100755 --- a/accessibility/prj/build.lst +++ b/accessibility/prj/build.lst @@ -9,3 +9,9 @@ ac accessibility\source\helper nmake - all ac_h ac accessibility\source\standard nmake - all ac_standard ac_helper ac_inc NULL ac accessibility\source\extended nmake - all ac_extended ac_inc NULL ac accessibility\util nmake - all ac_util ac_helper ac_standard ac_extended NULL +ac accessibility\workben\org\openoffice\accessibility\awb nmake - all ac_awb_main ac_awb_misc ac_awb_canvas ac_awb_view ac_awb_tree NULL +ac accessibility\workben\org\openoffice\accessibility\misc nmake - all ac_awb_misc NULL +ac accessibility\workben\org\openoffice\accessibility\awb\canvas nmake - all ac_awb_canvas ac_awb_tree NULL +ac accessibility\workben\org\openoffice\accessibility\awb\tree nmake - all ac_awb_tree ac_awb_misc NULL +ac accessibility\workben\org\openoffice\accessibility\awb\view nmake - all ac_awb_view ac_awb_view_text NULL +ac accessibility\workben\org\openoffice\accessibility\awb\view\text nmake - all ac_awb_view_text NULL diff --git a/accessibility/source/extended/accessiblelistbox.cxx b/accessibility/source/extended/accessiblelistbox.cxx index b3b7e00e3..c9a460dc9 100644 --- a/accessibility/source/extended/accessiblelistbox.cxx +++ b/accessibility/source/extended/accessiblelistbox.cxx @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2008 by Sun Microsystems, Inc. * * OpenOffice.org - a multi-platform office productivity suite @@ -132,6 +132,32 @@ namespace accessibility } } break; + + // --> OD 2009-04-01 #i92103# + case VCLEVENT_LISTBOX_ENTRY_EXPANDED : + case VCLEVENT_LISTBOX_ENTRY_COLLAPSED : + { + SvLBoxEntry* pEntry = static_cast< SvLBoxEntry* >( rVclWindowEvent.GetData() ); + if ( pEntry ) + { + AccessibleListBoxEntry* pAccListBoxEntry = + new AccessibleListBoxEntry( *getListBox(), pEntry, this ); + Reference< XAccessible > xChild = pAccListBoxEntry; + const short nAccEvent = + ( rVclWindowEvent.GetId() == VCLEVENT_LISTBOX_ENTRY_EXPANDED ) + ? AccessibleEventId::LISTBOX_ENTRY_EXPANDED + : AccessibleEventId::LISTBOX_ENTRY_COLLAPSED; + uno::Any aListBoxEntry; + aListBoxEntry <<= xChild; + NotifyAccessibleEvent( nAccEvent, Any(), aListBoxEntry ); + if ( getListBox() && getListBox()->HasFocus() ) + { + NotifyAccessibleEvent( AccessibleEventId::ACTIVE_DESCENDANT_CHANGED, Any(), aListBoxEntry ); + } + } + break; + } + // <-- } default: VCLXAccessibleComponent::ProcessWindowEvent (rVclWindowEvent); diff --git a/accessibility/source/standard/vclxaccessiblebox.cxx b/accessibility/source/standard/vclxaccessiblebox.cxx index 0a1eb20b5..93f654323 100644 --- a/accessibility/source/standard/vclxaccessiblebox.cxx +++ b/accessibility/source/standard/vclxaccessiblebox.cxx @@ -155,7 +155,7 @@ void VCLXAccessibleBox::ProcessWindowEvent (const VclWindowEvent& rVclWindowEven // combobox, however, we have to help the list with providing // the text of the currently selected item. VCLXAccessibleList* pList = static_cast<VCLXAccessibleList*>(m_xList.get()); - if (pList != NULL) + if (pList != NULL && m_xText.is()) { Reference<XAccessibleText> xText (m_xText->getAccessibleContext(), UNO_QUERY); if ( xText.is() ) diff --git a/accessibility/source/standard/vclxaccessibletoolboxitem.cxx b/accessibility/source/standard/vclxaccessibletoolboxitem.cxx index 4536f6360..2227c8585 100644 --- a/accessibility/source/standard/vclxaccessibletoolboxitem.cxx +++ b/accessibility/source/standard/vclxaccessibletoolboxitem.cxx @@ -47,6 +47,7 @@ #include <vcl/svapp.hxx> #include <vcl/toolbox.hxx> #include <vcl/unohelp2.hxx> +#include <vcl/help.hxx> #include <toolkit/awt/vclxwindow.hxx> #include <toolkit/helper/externallock.hxx> #include <unotools/accessiblestatesethelper.hxx> @@ -618,9 +619,12 @@ awt::FontDescriptor SAL_CALL VCLXAccessibleToolBoxItem::getFontMetrics( const Re ::rtl::OUString sRet; if ( m_pToolBox ) { - sRet = m_pToolBox->GetQuickHelpText( m_nItemId ); + if ( Help::IsExtHelpEnabled() ) + sRet = m_pToolBox->GetHelpText( m_nItemId ); + else + sRet = m_pToolBox->GetQuickHelpText( m_nItemId ); if ( !sRet.getLength() ) - // no quick help text set, so use item text + // no help text set, so use item text sRet = m_pToolBox->GetItemText( m_nItemId ); } return sRet; diff --git a/accessibility/workben/TODO b/accessibility/workben/TODO new file mode 100644 index 000000000..6fdfd5cb8 --- /dev/null +++ b/accessibility/workben/TODO @@ -0,0 +1,13 @@ +This is a unsorted list of TODO's and idea regarding the Accessibility Workbench + +* increase repaint performance +* fix paint problems in ObjectViewContainer for e.g. File menu +* change package structure to be flat (apps don't need deep package names) +* add ant build script(s) +* evaluate TreeTable as enhanced overview +* add error panel and a bunch of consistency checks +* add focus tracking mode +* evaluate drawing transparent frames at screen coordinates of an object +* enhance text view (colors) +* add table view +* more generic view loading (Class.forName()) diff --git a/accessibility/workben/makefile b/accessibility/workben/makefile new file mode 100644 index 000000000..4bd7c05e4 --- /dev/null +++ b/accessibility/workben/makefile @@ -0,0 +1,9 @@ +all: + cd source/org/openoffice/accessibility ; $(MAKE) all + +ROOT=source +SUBDIRS=source/org/openoffice/accessibility +include source/makefile.in + +run: all + $(JAVA) -classpath $(CLASSPATH) org.openoffice.accessibility.awb.AccessibilityWorkBench diff --git a/accessibility/workben/makefile.in b/accessibility/workben/makefile.in new file mode 100644 index 000000000..ad97448e7 --- /dev/null +++ b/accessibility/workben/makefile.in @@ -0,0 +1,32 @@ +PRJ=$(ROOT)/.. +SETTINGS=$(OO_SDK_HOME)/settings +include $(SETTINGS)/settings.mk +include $(SETTINGS)/std.mk +include $(SETTINGS)/dk.mk + +OUT_COMP_JAVA = $(OUT_CLASS)/$(patsubst .,/,$(PACKAGE)) +JAVAC=$(JAVA_HOME)/bin/javac +JAVA=$(JAVA_HOME)/bin/java +CLASS_FILES = $(patsubst %.java, %.class, $(JAVAFILES)) +CLASSPATH = $(subst $(EMPTYSTRING) $(PATH_SEPARATOR),$(PATH_SEPARATOR),$(OFFICE_CLASSES_DIR)/jurt.jar\ + $(PATH_SEPARATOR)$(OFFICE_CLASSES_DIR)/unoil.jar\ + $(PATH_SEPARATOR)$(OFFICE_CLASSES_DIR)/ridl.jar\ + $(PATH_SEPARATOR)$(OFFICE_CLASSES_DIR)/sandbox.jar\ + $(PATH_SEPARATOR)$(OFFICE_CLASSES_DIR)/juh.jar\ + $(PATH_SEPARATOR)$(OUT_COMP_JAVA)\ + $(PATH_SEPARATOR).\ + $(PATH_SEPARATOR)$(ROOT)\ + ) + +subdirs: + $(foreach dir,$(SUBDIRS), cd $(dir);$(MAKE);cd ..;) + +clean: + -rm *.class *.jar + $(foreach dir,$(SUBDIRS), cd $(dir);$(MAKE) clean ; cd ..;) + + +%.class : %.java + $(JAVAC) -classpath $(CLASSPATH) $< + +.PHONY: all package clean subdirs diff --git a/accessibility/workben/makefile.mk b/accessibility/workben/makefile.mk new file mode 100644 index 000000000..33c1e2a0e --- /dev/null +++ b/accessibility/workben/makefile.mk @@ -0,0 +1,40 @@ +# copied from settings.mk +SOLARBINDIR=$(SOLARVERSION)$/$(INPATH)$/bin$(UPDMINOREXT) + +# Please modify the following lines to match your environment: +# If you use the run: target at the end of the file, then adapt pipe name +PIPE_NAME = $(USER) + +# The following variables probably don't need to be changed. +JAVA = java +# The JAR_PATH points to the jar files of your local office installation. +JAR_PATH = $(SOLARBINDIR)$/ + + +# The rest of this makefile should not need to be touched. + +JAR_FILES = \ + unoil.jar \ + sandbox.jar \ + ridl.jar \ + jurt.jar \ + juh.jar \ + java_uno.jar + + +JAVA_CLASSPATHS := \ + ..$/$(INPATH)$/class \ + $(foreach,i,$(JAR_FILES) $(JAR_PATH)$i) \ + $(CLASSPATH) + +CLASSPATH !:=$(JAVA_CLASSPATHS:t$(PATH_SEPERATOR)) + +all: + build + +# Example of how to run the work bench. +run: + +$(JAVA) -classpath "$(CLASSPATH)" org/openoffice/accessibility/awb/AccessibilityWorkBench -p $(PIPE_NAME) + +runjar: + +$(JAVA) -classpath "$(CLASSPATH)" -jar AccessibilityWorkBench.jar -p $(PIPE_NAME) diff --git a/accessibility/workben/org/openoffice/accessibility/Makefile b/accessibility/workben/org/openoffice/accessibility/Makefile new file mode 100644 index 000000000..a6db6a05a --- /dev/null +++ b/accessibility/workben/org/openoffice/accessibility/Makefile @@ -0,0 +1,6 @@ +all : subdirs + +ROOT=../../../ +SUBDIRS=misc awb +include $(ROOT)/makefile.in + diff --git a/accessibility/workben/org/openoffice/accessibility/awb/AccessibilityWorkBench.java b/accessibility/workben/org/openoffice/accessibility/awb/AccessibilityWorkBench.java new file mode 100644 index 000000000..fd653abbe --- /dev/null +++ b/accessibility/workben/org/openoffice/accessibility/awb/AccessibilityWorkBench.java @@ -0,0 +1,724 @@ +/************************************************************************* + * + * $RCSfile: AccessibilityWorkBench.java,v $ + * + * $Revision: 1.3 $ + * + * last change: $Author: obr $ $Date: 2008/05/14 13:21:34 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +package org.openoffice.accessibility.awb; + +import java.awt.Cursor; +import java.awt.GridBagConstraints; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import javax.swing.ButtonGroup; +import javax.swing.JButton; +import javax.swing.JCheckBoxMenuItem; +import javax.swing.JComponent; +import javax.swing.JFrame; +import javax.swing.JMenu; +import javax.swing.JMenuBar; +import javax.swing.JMenuItem; +import javax.swing.JPanel; +import javax.swing.JRadioButtonMenuItem; +import javax.swing.JScrollPane; +import javax.swing.JSplitPane; +import javax.swing.event.TreeSelectionListener; +import javax.swing.event.TreeSelectionEvent; +import javax.swing.event.TreeExpansionListener; +import javax.swing.event.TreeWillExpandListener; +import javax.swing.tree.TreeNode; +import javax.swing.tree.TreePath; + +import com.sun.star.accessibility.XAccessible; +import com.sun.star.awt.XExtendedToolkit; +import com.sun.star.frame.XFrame; +import com.sun.star.frame.XTerminateListener; +import com.sun.star.lang.EventObject; +import com.sun.star.uno.UnoRuntime; + +import org.openoffice.accessibility.misc.MessageArea; +import org.openoffice.accessibility.misc.Options; +import org.openoffice.accessibility.misc.OfficeConnection; +import org.openoffice.accessibility.misc.SimpleOffice; +import org.openoffice.accessibility.awb.canvas.Canvas; +import org.openoffice.accessibility.awb.tree.AccessibilityTree; +import org.openoffice.accessibility.awb.tree.AccessibilityModel; +import org.openoffice.accessibility.awb.tree.DynamicAccessibilityModel; +import org.openoffice.accessibility.awb.view.ObjectViewContainer; +import org.openoffice.accessibility.awb.view.ObjectViewContainerWindow; + + + +/** This class manages the GUI of the work bench. + @see AccessibilityTreeModel + for the implementation of the tree view on the left side which also + manages the registration of accessibility listeners. + @see Canvas + for the graphical view of the accessible objects. +*/ +public class AccessibilityWorkBench + extends JFrame + implements XTerminateListener, + ActionListener, + TreeSelectionListener +{ + public static final String msVersion = "v1.9"; + public String msOptionsFileName = ".AWBrc"; + + public static void main (String args[]) + { + String sPipeName = System.getenv( "USER" ); + + for (int i=0; i<args.length; i++) + { + if (args[i].equals ("-h") || args[i].equals ("--help") || args[i].equals ("-?")) + { + System.out.println ("usage: AccessibilityWorkBench <option>*"); + System.out.println ("options:"); + System.out.println (" -p <pipe-name> name of the pipe to use to connect to OpenOffice.org."); + System.out.println (" Defaults to $USER."); + System.exit (0); + } + else if (args[i].equals ("-p")) + { + sPipeName = args[++i]; + } + } + + saWorkBench = new AccessibilityWorkBench (sPipeName); + } + + + + + /** Return the one instance of the AccessibilityWorkBench + @return + Returns null when the AccessibilityWorkBench could not be + created successfully. + */ + public static AccessibilityWorkBench Instance () + { + return saWorkBench; + } + + + + /** Create an accessibility work bench that listens at the specified + port to Office applications. + */ + private AccessibilityWorkBench (String sPipeName) + { + mbInitialized = false; + + OfficeConnection.SetPipeName (sPipeName); + Options.Instance().Load (msOptionsFileName); + Layout (); + + MessageArea.println (System.getProperty ("os.name") + " / " + + System.getProperty ("os.arch") + " / " + + System.getProperty ("os.version")); + MessageArea.println ("Using pipe name " + sPipeName); + + maTree.addTreeSelectionListener (this); + + addWindowListener (new WindowAdapter () + { public void windowClosing (WindowEvent e) {Quit();} } + ); + + OfficeConnection.Instance().AddConnectionListener (this); + Initialize (); + } + + + + + /** Create and arrange the widgets of the GUI. + */ + public void Layout () + { + setSize (new java.awt.Dimension (800,600)); + + JScrollPane aScrollPane; + GridBagConstraints constraints; + + // Create new layout. + java.awt.GridBagLayout aLayout = new java.awt.GridBagLayout (); + getContentPane().setLayout (aLayout); + + // Accessible Tree. + javax.swing.tree.TreeModel treeModel = new DynamicAccessibilityModel(); + maTree = new AccessibilityTree(treeModel); + // Add the model as tree listeners to be able to populate/clear the + // child lists on demand. + maTree.addTreeExpansionListener((TreeExpansionListener) treeModel); + maTree.addTreeWillExpandListener((TreeWillExpandListener) treeModel); + + JScrollPane aTreeScrollPane = new JScrollPane( + maTree, + JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, + JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); + aTreeScrollPane.setPreferredSize (new java.awt.Dimension (400,300)); + + // Object view shows details about the currently selected accessible + // object. + maObjectViewContainer = new ObjectViewContainer (); + JScrollPane aObjectViewContainerScrollPane = new JScrollPane( + maObjectViewContainer, + JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, + JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); + aObjectViewContainerScrollPane.setPreferredSize ( + new java.awt.Dimension (400,300)); + JButton aCornerButton = new JButton ("CreateNewViewWindow"); + aCornerButton.addActionListener (this); + aObjectViewContainerScrollPane.setCorner ( + JScrollPane.LOWER_RIGHT_CORNER, + aCornerButton); + + // Split pane for tree view and object view. + JSplitPane aLeftViewSplitPane = new JSplitPane ( + JSplitPane.VERTICAL_SPLIT, + aTreeScrollPane, + aObjectViewContainerScrollPane + ); + aLeftViewSplitPane.setDividerLocation (300); + aLeftViewSplitPane.setContinuousLayout (true); + + // Canvas. + maCanvas = new Canvas (); + maCanvas.SetTree (maTree); + JScrollPane aScrolledCanvas = new JScrollPane(maCanvas, + JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, + JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); + aScrolledCanvas.getViewport().setBackground (java.awt.Color.RED); + aScrolledCanvas.setPreferredSize (new java.awt.Dimension(600,400)); + + // Split pane for tree view and canvas. + JSplitPane aViewSplitPane = new JSplitPane ( + JSplitPane.HORIZONTAL_SPLIT, + aLeftViewSplitPane, + aScrolledCanvas + ); + aViewSplitPane.setOneTouchExpandable(true); + aViewSplitPane.setDividerLocation (400); + aViewSplitPane.setContinuousLayout (true); + + // Split pane for the three views at the top and the message area. + MessageArea.Instance().setPreferredSize (new java.awt.Dimension(600,50)); + JSplitPane aSplitPane = new JSplitPane ( + JSplitPane.VERTICAL_SPLIT, + aViewSplitPane, + MessageArea.Instance()); + aSplitPane.setOneTouchExpandable(true); + aSplitPane.setContinuousLayout (true); + addGridElement (aSplitPane, 0,0, 2,1, 3,3, + GridBagConstraints.CENTER, GridBagConstraints.BOTH); + + // Button bar. + maButtonBar = new javax.swing.JPanel(); + java.awt.GridBagLayout aButtonLayout = new java.awt.GridBagLayout (); + maButtonBar.setLayout (new java.awt.FlowLayout()); + addGridElement (maButtonBar, 0,3, 2,1, 1,0, + GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL); + + // Buttons. + // maConnectButton = createButton ("Connect", "connect"); + // maUpdateButton = createButton ("Update", "update"); + // maShapesButton = createButton ("Expand Shapes", "shapes"); + maExpandButton = createButton ("Expand All", "expand"); + maQuitButton = createButton ("Quit", "quit"); + UpdateButtonStates (); + + setJMenuBar (CreateMenuBar ()); + + setTitle("Accessibility Workbench " + msVersion); + + setVisible (true); + pack (); + aSplitPane.setDividerLocation (1.0); + validate (); + repaint(); + } + + + + + /** Shortcut method for adding an object to a GridBagLayout. + */ + void addGridElement (JComponent object, + int x, int y, + int width, int height, + int weightx, int weighty, + int anchor, int fill) + { + GridBagConstraints constraints = new GridBagConstraints (); + constraints.gridx = x; + constraints.gridy = y; + constraints.gridwidth = width; + constraints.gridheight = height; + constraints.weightx = weightx; + constraints.weighty = weighty; + constraints.anchor = anchor; + constraints.fill = fill; + getContentPane().add (object, constraints); + } + + + + + /** Create a new button and place at the right most position into the + button bar. + */ + public JButton createButton (String title, String command) + { + JButton aButton = new JButton (title); + aButton.setEnabled (false); + aButton.setActionCommand (command); + aButton.addActionListener (this); + + maButtonBar.add (aButton); + return aButton; + } + + + + + /** Create a menu bar for the application. + @return + Returns the new menu bar. The returned reference is also + remembered in the data member <member>maMenuBar</member>. + */ + javax.swing.JMenuBar CreateMenuBar() + { + // Menu bar. + maMenuBar = new JMenuBar (); + + // File menu. + JMenu aFileMenu = new JMenu ("File"); + maMenuBar.add (aFileMenu); + JMenuItem aItem; + aItem = new JMenuItem ("Quit"); + aFileMenu.add (aItem); + aItem.addActionListener (this); + + // View menu. + JMenu aViewMenu = new JMenu ("View"); + maMenuBar.add (aViewMenu); + ButtonGroup aGroup = new ButtonGroup (); + int nZoomMode = Options.GetInteger ("ZoomMode", Canvas.WHOLE_SCREEN); + JRadioButtonMenuItem aRadioButton = new JRadioButtonMenuItem ( + "Whole Screen", nZoomMode==Canvas.WHOLE_SCREEN); + aGroup.add (aRadioButton); + aViewMenu.add (aRadioButton); + aRadioButton.addActionListener (this); + aRadioButton = new JRadioButtonMenuItem ("200%", nZoomMode==200); + aGroup.add (aRadioButton); + aViewMenu.add (aRadioButton); + aRadioButton.addActionListener (this); + aRadioButton = new JRadioButtonMenuItem ("100%", nZoomMode==100); + aGroup.add (aRadioButton); + aViewMenu.add (aRadioButton); + aRadioButton.addActionListener (this); + aRadioButton = new JRadioButtonMenuItem ("50%", nZoomMode==50); + aGroup.add (aRadioButton); + aViewMenu.add (aRadioButton); + aRadioButton.addActionListener (this); + aRadioButton = new JRadioButtonMenuItem ("25%", nZoomMode==25); + aGroup.add (aRadioButton); + aViewMenu.add (aRadioButton); + aRadioButton.addActionListener (this); + aRadioButton = new JRadioButtonMenuItem ("10%", nZoomMode==10); + aGroup.add (aRadioButton); + aViewMenu.add (aRadioButton); + aRadioButton.addActionListener (this); + + // Options menu. + JMenu aOptionsMenu = new JMenu ("Options"); + maMenuBar.add (aOptionsMenu); + JCheckBoxMenuItem aCBItem; + aCBItem = new JCheckBoxMenuItem ("Show Descriptions", + Options.GetBoolean("ShowDescriptions")); + aOptionsMenu.add (aCBItem); + aCBItem.addActionListener (this); + + aCBItem = new JCheckBoxMenuItem ("Show Names", + Options.GetBoolean ("ShowNames")); + aOptionsMenu.add (aCBItem); + aCBItem.addActionListener (this); + + aCBItem = new JCheckBoxMenuItem ("Show Text", + Options.GetBoolean ("ShowText")); + aOptionsMenu.add (aCBItem); + aCBItem.addActionListener (this); + + aCBItem = new JCheckBoxMenuItem ("Antialiased Rendering", + Options.GetBoolean ("Antialiasing")); + aOptionsMenu.add (aCBItem); + aCBItem.addActionListener (this); + + // Help menu. + JMenu aHelpMenu = new JMenu ("Help"); + maMenuBar.add (aHelpMenu); + + aItem = new JMenuItem ("Help"); + aHelpMenu.add (aItem); + aItem.addActionListener (this); + + aItem = new JMenuItem ("News"); + aHelpMenu.add (aItem); + aItem.addActionListener (this); + + aItem = new JMenuItem ("About"); + aHelpMenu.add (aItem); + aItem.addActionListener (this); + + return maMenuBar; + } + + + + + /** Initialize the AWB. This includes clearing the canvas, add + listeners, creation of a new tree model for the tree list box and + the update of the button states. + + This method may be called any number of times. Note that all + actions will be carried out every time. The main purpose of a + second call is that of a re-initialization after a reconnect. + */ + protected void Initialize () + { + maCanvas.SetTree (maTree); + + SimpleOffice aOffice = SimpleOffice.Instance (); + if (aOffice != null) + { + // Add terminate listener. + if (aOffice.GetDesktop() != null) + aOffice.GetDesktop().addTerminateListener (this); + + } + + mbInitialized = true; + UpdateButtonStates (); + } + + + + + /** Update the states of the buttons according to the internal state of + the AWB. + */ + protected void UpdateButtonStates () + { + // maConnectButton.setEnabled (mbInitialized); + maQuitButton.setEnabled (true); + // maUpdateButton.setEnabled (mbInitialized); + maExpandButton.setEnabled (mbInitialized); + // maShapesButton.setEnabled (mbInitialized); + } + + + + /** Callback for GUI actions from the buttons. + */ + public void actionPerformed (ActionEvent aEvent) + { + String sCommand = aEvent.getActionCommand(); + if (sCommand.equals("connect")) + { + SimpleOffice.Clear(); + Initialize (); + } + else if (sCommand.equals("quit")) + { + Quit (); + } + else if (sCommand.equals("update")) + { +// maTree.Dispose(); + Initialize (); + } + else if (sCommand.equals("shapes")) + { + Cursor aCursor = getCursor(); + setCursor (new Cursor (Cursor.WAIT_CURSOR)); + // maTree.expandShapes(); + setCursor (aCursor); + } + else if (sCommand.equals("expand")) + { + Cursor aCursor = getCursor(); + setCursor (new Cursor (Cursor.WAIT_CURSOR)); + + for (int i=0; i<maTree.getRowCount(); i++) + maTree.expandRow (i); + // maAccessibilityTree.expandAll(); + setCursor (aCursor); + } + else if (sCommand.equals ("Quit")) + { + System.out.println ("exiting"); + System.exit (0); + } + else if (sCommand.equals ("Show Descriptions")) + { + Options.SetBoolean ("ShowDescriptions", + ((JCheckBoxMenuItem)aEvent.getSource()).getState()); + maCanvas.repaint(); + } + else if (sCommand.equals ("Show Names")) + { + Options.SetBoolean ("ShowNames", + ((JCheckBoxMenuItem)aEvent.getSource()).getState()); + maCanvas.repaint(); + } + else if (sCommand.equals ("Show Text")) + { + Options.SetBoolean ("ShowText", + ((JCheckBoxMenuItem)aEvent.getSource()).getState()); + maCanvas.repaint(); + } + else if (sCommand.equals ("Antialiased Rendering")) + { + Options.SetBoolean ("Antialiasing", + ((JCheckBoxMenuItem)aEvent.getSource()).getState()); + maCanvas.repaint(); + } + else if (sCommand.equals ("Help")) + { + HelpWindow.Instance().loadFile ("help.html"); + } + else if (sCommand.equals ("News")) + { + try{ + HelpWindow.Instance().loadFile ("news.html"); + } catch (Exception ex) {} + } + else if (sCommand.equals ("About")) + { + HelpWindow.Instance().loadFile ("about.html"); + } + else if (sCommand.equals ("Whole Screen")) + { + Options.SetInteger ("ZoomMode", Canvas.WHOLE_SCREEN); + maCanvas.repaint(); + } + else if (sCommand.equals ("200%")) + { + Options.SetInteger ("ZoomMode", 200); + maCanvas.repaint(); + } + else if (sCommand.equals ("100%")) + { + Options.SetInteger ("ZoomMode", 100); + maCanvas.repaint(); + } + else if (sCommand.equals ("50%")) + { + Options.SetInteger ("ZoomMode", 50); + maCanvas.repaint(); + } + else if (sCommand.equals ("25%")) + { + Options.SetInteger ("ZoomMode", 25); + maCanvas.repaint(); + } + else if (sCommand.equals ("10%")) + { + Options.SetInteger ("ZoomMode", 10); + maCanvas.repaint(); + } + else if (sCommand.equals ("<connected>")) + { + Connected (); + } + else if (sCommand.equals ("CreateNewViewWindow")) + { + TreePath aSelectionPath = maTree.getSelectionPath(); + if (aSelectionPath != null) + { + javax.swing.tree.TreeNode aSelectedNode = + (javax.swing.tree.TreeNode)aSelectionPath.getLastPathComponent(); + if (aSelectedNode instanceof XAccessible) { + new ObjectViewContainerWindow (((XAccessible) aSelectedNode).getAccessibleContext()); + } + } + } + else + { + System.err.println("unknown command " + sCommand); + } + } + + + + + /** TreeSelectionListener + Tell the object view and the canvas about the selected object. + */ + public void valueChanged (TreeSelectionEvent aEvent) { + + if (aEvent.isAddedPath()) { + Cursor aCursor = getCursor(); + setCursor (new Cursor (Cursor.WAIT_CURSOR)); + + javax.swing.tree.TreePath aPath = aEvent.getPath(); + maTree.scrollPathToVisible (aPath); + Object aObject = aPath.getLastPathComponent(); + if (aObject instanceof XAccessible) { + XAccessible xAccessible = (XAccessible) aObject; + if (maObjectViewContainer != null) { + ((AccessibilityModel) maTree.getModel()).addEventListener((TreeNode) aObject, maObjectViewContainer); + maObjectViewContainer.SetObject (xAccessible.getAccessibleContext()); + } + } + if (maCanvas != null) + maCanvas.SelectObject ((TreeNode) aObject); + setCursor (aCursor); + } else { + if (maObjectViewContainer != null) { + ((AccessibilityModel) maTree.getModel()).removeEventListener((TreeNode) aEvent.getPath().getLastPathComponent(), maObjectViewContainer); + maObjectViewContainer.SetObject (null); + } + if (maCanvas != null) + maCanvas.SelectObject (null); + } + } + + + + + // XEventListener + public void disposing (EventObject aSourceObj) + { + XFrame xFrame = (XFrame)UnoRuntime.queryInterface( + XFrame.class, aSourceObj.Source); + + if( xFrame != null ) + System.out.println("frame disposed"); + else + System.out.println("controller disposed"); + } + + + + + // XTerminateListener + public void queryTermination(final EventObject aEvent) throws com.sun.star.frame.TerminationVetoException + { + System.out.println ("Terminate Event : " + aEvent); + } + + + + + // XTerminateListener + public void notifyTermination(final EventObject aEvent) + { + System.out.println ("Notifiy Termination Event : " + aEvent); + } + + + /** Called after the AWB is connected to an Office application. + */ + private void Connected () + { + // Clear the tree and by expanding the root node initiate the + // scanning and insertion of nodes for the top-level windows. +// maTree.Clear(); +// maTree.collapseRow (0); +// maTree.expandRow (0); + + // Register the top window listener. + XExtendedToolkit xToolkit = + SimpleOffice.Instance().GetExtendedToolkit(); + if (xToolkit != null) + { + maTree.setToolkit(xToolkit); + } + } + + + /** Called when shutting down the AWB tool. + */ + private void Quit () + { +// maTree.Dispose(); + System.exit (0); + } + + /// The Singleton Workbench object. + private static AccessibilityWorkBench + saWorkBench = null; + + private JPanel maMainPanel; + private JPanel maButtonBar; + private Canvas maCanvas; + private AccessibilityTree maTree; + private ObjectViewContainer maObjectViewContainer; + private JButton + maConnectButton, + maQuitButton, + maUpdateButton, + maExpandButton, + maShapesButton; + private JMenuBar maMenuBar; + private boolean mbInitialized; +} diff --git a/accessibility/workben/org/openoffice/accessibility/awb/HelpWindow.java b/accessibility/workben/org/openoffice/accessibility/awb/HelpWindow.java new file mode 100644 index 000000000..9aae024ff --- /dev/null +++ b/accessibility/workben/org/openoffice/accessibility/awb/HelpWindow.java @@ -0,0 +1,187 @@ +package org.openoffice.accessibility.awb; + +import javax.swing.JFrame; +import javax.swing.JScrollPane; +import javax.swing.JEditorPane; +import javax.swing.JButton; +import java.net.URL; +import javax.swing.event.HyperlinkListener; +import javax.swing.event.HyperlinkEvent; +import java.net.MalformedURLException; +import java.io.IOException; +import java.io.File; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.awt.GridBagLayout; +import java.awt.GridBagConstraints; +import java.awt.event.ActionListener; +import java.util.LinkedList; + +public class HelpWindow + implements ActionListener +{ + public static synchronized HelpWindow Instance () + { + if (maInstance == null) + maInstance = new HelpWindow(); + return maInstance; + } + + public void loadFile (String sFilename) + { + File aFile = new File (sFilename); + try + { + loadURL (aFile.toURL()); + } + catch (MalformedURLException e) + { + e.printStackTrace (System.err); + } + } + public void loadURL (String sURL) + { + try + { + loadURL (new URL (sURL)); + } + catch (MalformedURLException e) + { + e.printStackTrace (System.err); + } + } + + + + + public void loadURL (URL aURL) + { + maHistory.addLast (aURL); + selectHistoryPage (maHistory.size()-1); + maFrame.toFront (); + } + + + + + private HelpWindow () + { + try + { + maCurrentHistoryEntry = -1; + maHistory = new LinkedList(); + + maFrame = new JFrame (); + maFrame.addWindowListener (new WindowAdapter () + { + public void windowClosing (WindowEvent e) + { + maInstance = null; + } + }); + maContent = createContentWidget(); + + maFrame.getContentPane().setLayout (new GridBagLayout()); + GridBagConstraints aConstraints = new GridBagConstraints (); + aConstraints.gridx = 0; + aConstraints.gridy = 0; + aConstraints.gridwidth = 3; + aConstraints.weightx = 1; + aConstraints.weighty = 1; + aConstraints.fill = GridBagConstraints.BOTH; + maFrame.getContentPane().add (new JScrollPane (maContent), aConstraints); + + aConstraints = new GridBagConstraints(); + aConstraints.gridx = 0; + aConstraints.gridy = 1; + maPrevButton = new JButton ("Prev"); + maFrame.getContentPane().add (maPrevButton, aConstraints); + maPrevButton.addActionListener (this); + + aConstraints = new GridBagConstraints(); + aConstraints.gridx = 1; + aConstraints.gridy = 1; + maNextButton = new JButton ("Next"); + maFrame.getContentPane().add (maNextButton, aConstraints); + maNextButton.addActionListener (this); + + aConstraints = new GridBagConstraints(); + aConstraints.gridx = 2; + aConstraints.gridy = 1; + aConstraints.anchor = GridBagConstraints.EAST; + JButton aButton = new JButton ("Close"); + maFrame.getContentPane().add (aButton, aConstraints); + aButton.addActionListener (this); + + maFrame.setSize (600,400); + maFrame.setVisible (true); + } + catch (Exception e) + {} + } + + public void actionPerformed (java.awt.event.ActionEvent e) + { + if (e.getActionCommand().equals("Prev")) + { + selectHistoryPage (maCurrentHistoryEntry - 1); + } + else if (e.getActionCommand().equals("Next")) + { + selectHistoryPage (maCurrentHistoryEntry + 1); + } + else if (e.getActionCommand().equals("Close")) + { + maFrame.dispose (); + maInstance = null; + } + } + + private JEditorPane createContentWidget () + { + JEditorPane aContent = new JEditorPane (); + aContent.setEditable (false); + aContent.addHyperlinkListener (new HyperlinkListener() + { + public void hyperlinkUpdate (HyperlinkEvent e) + { + if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) + HelpWindow.Instance().loadURL (e.getURL()); + } + }); + return aContent; + } + + private void selectHistoryPage (int i) + { + if (i < 0) + i = 0; + else if (i >= maHistory.size()-1) + i = maHistory.size()-1; + if (i != maCurrentHistoryEntry) + { + URL aURL = (URL)maHistory.get (i); + try + { + maContent.setPage (aURL); + } + catch (java.io.IOException ex) + { + ex.printStackTrace(System.err); + } + + maCurrentHistoryEntry = i; + } + + maPrevButton.setEnabled (maCurrentHistoryEntry > 0); + maNextButton.setEnabled (maCurrentHistoryEntry < maHistory.size()-1); + } + + private static HelpWindow maInstance = null; + private JFrame maFrame; + private JEditorPane maContent; + private LinkedList maHistory; + private int maCurrentHistoryEntry; + private JButton maPrevButton; + private JButton maNextButton; +} diff --git a/accessibility/workben/org/openoffice/accessibility/awb/Makefile b/accessibility/workben/org/openoffice/accessibility/awb/Makefile new file mode 100644 index 000000000..d38799bed --- /dev/null +++ b/accessibility/workben/org/openoffice/accessibility/awb/Makefile @@ -0,0 +1,13 @@ +# $Id: Makefile,v 1.1 2003/06/13 16:30:18 af Exp $ + +all : package + +ROOT=../../../.. +PACKAGE = org.openoffice.accessibility.awb +SUBDIRS = canvas event tree view + +include makefile.common + +include $(ROOT)/makefile.in + +package: subdirs $(CLASS_FILES) diff --git a/accessibility/workben/org/openoffice/accessibility/awb/canvas/Canvas.java b/accessibility/workben/org/openoffice/accessibility/awb/canvas/Canvas.java new file mode 100644 index 000000000..fc09d4366 --- /dev/null +++ b/accessibility/workben/org/openoffice/accessibility/awb/canvas/Canvas.java @@ -0,0 +1,356 @@ +/************************************************************************* + * + * $RCSfile: Canvas.java,v $ + * + * $Revision: 1.2 $ + * + * last change: $Author: obr $ $Date: 2003/09/19 09:21:35 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +package org.openoffice.accessibility.awb.canvas; + +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.Rectangle; +import java.awt.RenderingHints; +import java.awt.Toolkit; +import java.awt.geom.Rectangle2D; +import java.util.Iterator; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JViewport; +import javax.swing.event.TreeSelectionEvent; +import javax.swing.tree.TreePath; + +import com.sun.star.accessibility.XAccessible; +import com.sun.star.accessibility.XAccessibleContext; +import com.sun.star.accessibility.XAccessibleComponent; + +import org.openoffice.accessibility.misc.Options; + +/** This canvas displays accessible objects graphically. Each accessible + object with graphical representation is represented by an + CanvasShape object and has to be added by the + <member>addAccessible</member> member function. + + <p>The canvas listens to selection events of the associated JTree and + highlights the first selected node of that tree.</p> +*/ +public class Canvas + extends JPanel +{ + // This constant can be passed to SetZoomMode to always show the whole screen. + public static final int WHOLE_SCREEN = -1; + + public Canvas () + { + super (true); + maShapeList = new ShapeContainer (this); + maMouseObserver = new MouseObserver (this); + maTree = null; + mnHOffset = 0; + mnVOffset = 0; + mnScale = 1; + maLastWidgetSize = new Dimension (0,0); + } + + + + /** Tell the canvas which tree to use to highlight accessible + objects and to observe for changes in the tree structure. + */ + public void SetTree (javax.swing.JTree aTree) + { + if (aTree != maTree) + { + maTree = aTree; + maShapeList.SetTree (maTree); + maMouseObserver.SetTree (maTree); + } + } + + + + + private void Clear () + { + maShapeList.Clear(); + } + + + + + public Iterator GetShapeIterator () + { + return maShapeList.GetIterator(); + } + + + + + public void paintComponent (Graphics g) + { + synchronized (g) + { + super.paintComponent (g); + + Graphics2D g2 = (Graphics2D)g; + if (Options.GetBoolean("Antialiasing")) + g2.setRenderingHint (RenderingHints.KEY_ANTIALIASING, + RenderingHints.VALUE_ANTIALIAS_ON); + else + g2.setRenderingHint (RenderingHints.KEY_ANTIALIASING, + RenderingHints.VALUE_ANTIALIAS_OFF); + + setupTransformation (); + g2.translate (mnHOffset, mnVOffset); + g2.scale (mnScale, mnScale); + + // Draw the screen representation to give a hint of the location of the + // accessible object on the screen. + Dimension aScreenSize = Toolkit.getDefaultToolkit().getScreenSize(); + Rectangle2D.Double aScreen = new Rectangle2D.Double ( + 0, + 0, + aScreenSize.getWidth(), + aScreenSize.getHeight()); + // Fill the screen rectangle and draw a frame arround it to increase its visibility. + g2.setColor (new Color (250,240,230)); + g2.fill (aScreen); + g2.setColor (Color.BLACK); + g2.draw (aScreen); + + synchronized (maShapeList) + { + Iterator aShapeIterator = maShapeList.GetIterator(); + boolean bShowDescriptions = Options.GetBoolean ("ShowDescriptions"); + boolean bShowNames = Options.GetBoolean ("ShowNames"); + boolean bShowText = Options.GetBoolean ("ShowText"); + while (aShapeIterator.hasNext()) + { + CanvasShape aCanvasShape = + (CanvasShape)aShapeIterator.next(); + try + { + aCanvasShape.paint ( + g2, + bShowDescriptions, bShowNames, bShowText); + } + catch (Exception aException) + { + System.err.println ("caught exception while painting a shape:" + + aException); + aException.printStackTrace (System.err); + } + } + } + + // Paint highlighted frame around active object as the last thing. + if (maActiveObject != null) + maActiveObject.paint_highlight (g2); + } + } + + + + + /** Set up the transformation so that the graphical display can show a + centered representation of the whole screen. + */ + private void setupTransformation () + { + // Turn off scrollbars when showing the whole screen. Otherwise show them when needed. + JViewport aViewport = (JViewport)getParent(); + JScrollPane aScrollPane = (JScrollPane)aViewport.getParent(); + int nZoomMode = Options.GetInteger ("ZoomMode", WHOLE_SCREEN); + if (nZoomMode == WHOLE_SCREEN) + { + if (aScrollPane.getHorizontalScrollBarPolicy() + != JScrollPane.HORIZONTAL_SCROLLBAR_NEVER) + aScrollPane.setHorizontalScrollBarPolicy ( + JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); + if (aScrollPane.getVerticalScrollBarPolicy() + != JScrollPane.VERTICAL_SCROLLBAR_NEVER) + aScrollPane.setVerticalScrollBarPolicy ( + JScrollPane.VERTICAL_SCROLLBAR_NEVER); + } + else + { + if (aScrollPane.getHorizontalScrollBarPolicy() + != JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED) + aScrollPane.setHorizontalScrollBarPolicy ( + JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); + if (aScrollPane.getVerticalScrollBarPolicy() + != JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED) + aScrollPane.setVerticalScrollBarPolicy ( + JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); + } + + Dimension aScreenSize = Toolkit.getDefaultToolkit().getScreenSize(); + Dimension aWidgetSize = aViewport.getSize(); + { + if ((aScreenSize.getWidth() > 0) && (aScreenSize.getHeight() > 0)) + { + if (nZoomMode == WHOLE_SCREEN) + { + // Calculate the scales that would map the screen onto the + // widget in both of the coordinate axes and select the + // smaller + // of the two: it maps the screen onto the widget in both + // axes at the same time. + double nHScale = (aWidgetSize.getWidth() - 10) + / aScreenSize.getWidth(); + double nVScale = (aWidgetSize.getHeight() - 10) + / aScreenSize.getHeight(); + if (nHScale < nVScale) + mnScale = nHScale; + else + mnScale = nVScale; + } + else + { + mnScale = nZoomMode / 100.0; + } + + // Calculate offsets that center the scaled screen inside + // the widget. + mnHOffset = (aWidgetSize.getWidth() + - mnScale*aScreenSize.getWidth()) / 2.0; + mnVOffset = (aWidgetSize.getHeight() + - mnScale*aScreenSize.getHeight()) / 2.0; + if (mnHOffset < 0) + mnHOffset = 0; + if (mnVOffset < 0) + mnVOffset = 0; + + setPreferredSize (new Dimension ( + (int)(2*mnHOffset + mnScale * aScreenSize.getWidth()), + (int)(2*mnVOffset + mnScale * aScreenSize.getHeight()))); + revalidate (); + } + else + { + // In case of a degenerate (not yet initialized?) screen size + // use some meaningless default values. + mnScale = 1; + mnHOffset = 0; + mnVOffset = 0; + } + } + maLastWidgetSize = aWidgetSize; + } + + + + protected boolean HighlightObject (CanvasShape aNewActiveObject) + { + if (aNewActiveObject != maActiveObject) + { + if (maActiveObject != null) + maActiveObject.Highlight (false); + + maActiveObject = aNewActiveObject; + if (maActiveObject != null) + { + /* if (maTree != null) + { + TreePath aPath = new TreePath ( + maActiveObject.GetNode().GetPath()); + maTree.scrollPathToVisible (aPath); + maTree.setSelectionPath (aPath); + maTree.repaint (); + } + */ + maActiveObject.Highlight (true); + } + repaint (); + return true; + } + else + return false; + } + + + + + /** Called when the selection of the tree changes. Highlight the + corresponding graphical representation of the object. + */ + public void SelectObject (javax.swing.tree.TreeNode aNode) + { + CanvasShape aCanvasShape = maShapeList.Get (aNode); + HighlightObject (aCanvasShape); + } + + + + + private int + mnXAnchor, + mnYAnchor, + maResizeFlag; + private double + mnHOffset, + mnVOffset, + mnScale; + private CanvasShape maActiveObject; + private javax.swing.JTree maTree; + // The size of the widget at the last call of setupTransformation() + private Dimension maLastWidgetSize; + private ShapeContainer maShapeList; + private MouseObserver maMouseObserver; +} diff --git a/accessibility/workben/org/openoffice/accessibility/awb/canvas/CanvasShape.java b/accessibility/workben/org/openoffice/accessibility/awb/canvas/CanvasShape.java new file mode 100644 index 000000000..74e9ce014 --- /dev/null +++ b/accessibility/workben/org/openoffice/accessibility/awb/canvas/CanvasShape.java @@ -0,0 +1,446 @@ +/************************************************************************* + * + * $RCSfile: CanvasShape.java,v $ + * + * $Revision: 1.2 $ + * + * last change: $Author: obr $ $Date: 2003/09/19 09:21:35 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +package org.openoffice.accessibility.awb.canvas; + +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Graphics2D; +import java.awt.Point; +import java.awt.Rectangle; +import java.awt.geom.Point2D; +import java.awt.geom.Rectangle2D; +import java.awt.geom.AffineTransform; +import java.awt.geom.NoninvertibleTransformException; + + +import com.sun.star.accessibility.*; +import com.sun.star.lang.EventObject; +import com.sun.star.uno.UnoRuntime; + + +class CanvasShape implements XAccessibleEventListener +{ + public final Color maHighlightColor = Color.red; + public final Color maSelectionColor = Color.green; + public final Color maFocusColor = Color.blue; + + public CanvasShape (javax.swing.tree.TreeNode aNode, Canvas aCanvas) + { + maNode = aNode; + msName = "<no name>"; + msDescription = "<no description>"; + maShape = new Rectangle2D.Double (-10,-10,10,10); + maPosition = new Point (-10,-10); + maSize = new Dimension (10,10); + maFgColor = java.awt.Color.black; + maBgColor = Color.blue; + mnRole = -1; + mbHighlighted = false; + mbSelected = false; + mbFocused = false; + maCanvas = aCanvas; + + Update (); + } + + + + + public javax.swing.tree.TreePath getNodePath (javax.swing.tree.TreeNode node) + { + javax.swing.tree.TreeNode parent = node.getParent(); + return (parent != null) ? + getNodePath(parent).pathByAddingChild(node) : + new javax.swing.tree.TreePath(node); + } + + public javax.swing.tree.TreePath getNodePath () + { + return getNodePath(maNode); + } + + + + /** Update the data obtained from the <type>AccessibilityNode</type> + object. + */ + public void Update () + { + if (maNode instanceof XAccessible) { + mxContext = ((XAccessible) maNode).getAccessibleContext(); + mxComponent = (XAccessibleComponent)UnoRuntime.queryInterface( + XAccessibleComponent.class, mxContext); + } + + if (mxContext != null) + { + msName = mxContext.getAccessibleName(); + msDescription = mxContext.getAccessibleDescription(); + mnRole = mxContext.getAccessibleRole(); + + // Extract the selected and focused flag. + XAccessibleStateSet xStateSet = mxContext.getAccessibleStateSet (); + if (xStateSet != null) + { + mbSelected = xStateSet.contains (AccessibleStateType.SELECTED); + mbFocused = xStateSet.contains (AccessibleStateType.FOCUSED); + } + } + + UpdateGeometry (); + + if (mxComponent != null) + { + // Note: alpha values in office 0..255 have to be mapped to + // 255..0 in Java + Color aCol = new Color (mxComponent.getForeground(), true); + maFgColor = new Color (aCol.getRed (), + aCol.getGreen (), + aCol.getBlue (), + 0xff - aCol.getAlpha ()); + aCol = new Color (mxComponent.getBackground(), true); + maBgColor = new Color (aCol.getRed (), + aCol.getGreen (), + aCol.getBlue (), + 0xff - aCol.getAlpha ()); + } + } + + + + public void UpdateGeometry () + { + if (mxComponent != null) + { + com.sun.star.awt.Point aLocationOnScreen = + mxComponent.getLocationOnScreen(); + com.sun.star.awt.Size aSizeOnScreen = mxComponent.getSize(); + maPosition = new Point ( + aLocationOnScreen.X, + aLocationOnScreen.Y); + maSize = new Dimension ( + aSizeOnScreen.Width, + aSizeOnScreen.Height); + } + } + + + + /** Paint the object into the specified canvas. It is transformed + according to the specified offset and scale. + */ + public void paint ( + Graphics2D g, + boolean bShowDescription, + boolean bShowName, + boolean bShowText) + { + try{ + // Transform the object's position and size according to the + // specified offset and scale. + Point aLocation = new Point(); + maShape = new Rectangle2D.Double ( + maPosition.x, + maPosition.y, + maSize.width, + maSize.height); + maTransformation = g.getTransform(); + + // Fill the object's bounding box with its background color if it + // has no children. + if (mxContext.getAccessibleChildCount() == 0) + { + g.setColor (maBgColor); + g.fill (maShape); + } + + // Remove alpha channel from color before drawing the frame. + Color color = maFgColor; + if (maFgColor.getAlpha()<128) + color = new Color (maFgColor.getRed(), maFgColor.getGreen(), maFgColor.getBlue()); + g.setColor (color); + g.draw (maShape); + + if (mbFocused) + { + g.setColor (maFocusColor); + for (int x=0; x<=2; x++) + for (int y=0; y<=2; y++) + g.fill ( + new Rectangle2D.Double ( + maShape.x + x/2.0 * maShape.width-3, + maShape.y + y/2.0 * maShape.height-3, + 6, + 6)); + } + if (mbSelected) + { + g.setColor (maSelectionColor); + for (int x=0; x<=2; x++) + for (int y=0; y<=2; y++) + g.draw ( + new Rectangle2D.Double ( + maShape.x + x/2.0 * maShape.width-2, + maShape.y + y/2.0 * maShape.height-2, + 4, + 4)); + } + + // Write the object's text OR name and description. + g.setColor (maFgColor); + if (bShowName) + paintName (g); + if (bShowDescription) + paintDescription (g); + if (bShowText) + paintText (g); + } + catch (Exception e) + { // don't care + } + } + + + public void paint_highlight (Graphics2D g) + { + if (mbHighlighted) + g.setColor (maHighlightColor); + else + g.setColor (maFgColor); + g.draw (maShape); + } + + + + + private void paintName (Graphics2D g) + { + g.drawString ("Name: " + msName, + (float)maShape.x+5, + (float)maShape.y+15); + } + + + + private void paintDescription (Graphics2D g) + { + g.drawString ("Description: " + msDescription, + (float)maShape.x+5, + (float)maShape.y+35); + } + + + + + private void paintText (Graphics2D g) + { + XAccessibleText xText = null; + // get XAccessibleText + xText = (XAccessibleText)UnoRuntime.queryInterface( + XAccessibleText.class, mxContext); + + // Draw every character in the text string. + if (xText != null) + { + String sText = xText.getText(); + try + { + for(int i = 0; i < sText.length(); i++) + { + com.sun.star.awt.Rectangle aRect = + xText.getCharacterBounds(i); + + double x = maShape.x + aRect.X; + double y = maShape.y + aRect.Y + aRect.Height; + + g.drawString (sText.substring(i, i+1), (float)x, (float)y); + } + } + catch (com.sun.star.lang.IndexOutOfBoundsException e) + {} + } + } + + + /** Compute whether the specified point lies inside the object's + bounding box. + */ + public boolean Contains (int x, int y) + { + Point2D aPosition = new Point2D.Double (x,y); + try + { + maTransformation.inverseTransform (aPosition, aPosition); + // System.out.println ("transformed "+x+","+y+" to "+aPosition); + } + catch (NoninvertibleTransformException aException) + { + return false; + } + return (maShape.contains (aPosition)); + } + + public void Highlight (boolean bFlag) + { + mbHighlighted = bFlag; + } + + public boolean IsHighlighted () + { + return mbHighlighted; + } + + public Rectangle GetBBox () + { + return new Rectangle (maPosition, maSize); + } + + public Point getOrigin () + { + return maPosition; + } + + public Dimension GetSize () + { + return maSize; + } + + public int getRole () + { + return mnRole; + } + + public XAccessibleContext getContext () + { + return mxContext; + } + + public XAccessibleComponent getComponent () + { + return mxComponent; + } + + public String toString () + { + return ">"+msName+", "+msDescription+" +"+maPosition.x+"+"+maPosition.y + +"x"+maSize.width+"x"+maSize.height+"<"; + } + + /** */ + public void notifyEvent(com.sun.star.accessibility.AccessibleEventObject aEvent) { + try { + switch (aEvent.EventId) { + case AccessibleEventId.BOUNDRECT_CHANGED: + case AccessibleEventId.VISIBLE_DATA_CHANGED: + UpdateGeometry (); + maCanvas.repaint(); + break; + default: + break; + } + } catch (Exception aException) { + System.err.println ("caught exception while updating a shape:" + + aException); + aException.printStackTrace (System.err); + } + } + + /** Callback for disposing events. + */ + public void disposing (com.sun.star.lang.EventObject e) + { + System.out.println ("Disposing"); + } + + + + + private Canvas + maCanvas; + private javax.swing.tree.TreeNode + maNode; + private XAccessibleContext + mxContext; + private XAccessibleComponent + mxComponent; + private String + msDescription, + msName; + private Rectangle2D.Double maShape; + private AffineTransform maTransformation; + private Point maPosition; + private Dimension + maTransformedSize, + maSize; + private Color + maFgColor, + maBgColor; + private boolean + // Highlighting objects is an internal concept. Corresponds to selection in the tree view. + mbHighlighted, + // Set when the accessible object is selected. + mbSelected, + // Set when the accessible object is focused. + mbFocused; + private int + mnRole; +} diff --git a/accessibility/workben/org/openoffice/accessibility/awb/canvas/Makefile b/accessibility/workben/org/openoffice/accessibility/awb/canvas/Makefile new file mode 100644 index 000000000..8d9688433 --- /dev/null +++ b/accessibility/workben/org/openoffice/accessibility/awb/canvas/Makefile @@ -0,0 +1,15 @@ +# $Id: Makefile,v 1.1 2003/06/13 16:30:21 af Exp $ + +all : package + +ROOT=../../../../.. +PACKAGE = org.openoffice.accessibility.awb.canvas +SUBDIRS = +include makefile.common + +include $(ROOT)/makefile.in + + +package : $(CLASS_FILES) + + diff --git a/accessibility/workben/org/openoffice/accessibility/awb/canvas/MouseObserver.java b/accessibility/workben/org/openoffice/accessibility/awb/canvas/MouseObserver.java new file mode 100644 index 000000000..c2468ec38 --- /dev/null +++ b/accessibility/workben/org/openoffice/accessibility/awb/canvas/MouseObserver.java @@ -0,0 +1,104 @@ +package org.openoffice.accessibility.awb.canvas; + +import java.awt.Dimension; +import java.awt.event.InputEvent; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; +import java.awt.event.MouseMotionListener; +import java.util.Iterator; +import javax.swing.tree.TreePath; + + +/** Observe the mouse and highlight shapes of the canvas when clicked. +*/ +public class MouseObserver + implements MouseListener, + MouseMotionListener +{ + public MouseObserver (Canvas aCanvas) + { + maCanvas = aCanvas; + maCanvas.addMouseListener (this); + maCanvas.addMouseMotionListener (this); + } + + + public void SetTree (javax.swing.JTree aTree) + { + maTree = aTree; + } + + public void mouseClicked (MouseEvent e) + {} + + public void mousePressed (MouseEvent e) + { + CanvasShape aObjectUnderMouse = FindCanvasShapeUnderMouse (e); + maTree.clearSelection(); + if (aObjectUnderMouse != null) + { + TreePath aPath = aObjectUnderMouse.getNodePath(); + if ((e.getModifiers() & InputEvent.CTRL_MASK) != 0) + maTree.expandPath (aPath); + // Selecting the entry will eventually highlight the shape. + maTree.setSelectionPath (aPath); + maTree.makeVisible (aPath); + } + } + + public void mouseReleased (MouseEvent e) + {} + + public void mouseEntered (MouseEvent e) + {} + + public void mouseExited (MouseEvent e) + {} + + public void mouseDragged (MouseEvent e) + { + } + + public void mouseMoved (MouseEvent e) + { + if ((e.getModifiers() & InputEvent.SHIFT_MASK) != 0) + maCanvas.HighlightObject (FindCanvasShapeUnderMouse (e)); + } + + + /** Search for the smallest shape that contains the mouse position. + */ + protected CanvasShape FindCanvasShapeUnderMouse (MouseEvent e) + { + Dimension aSmallestSize = null; + Iterator maShapeIterator = maCanvas.GetShapeIterator(); + CanvasShape aShapeUnderMouse = null; + while (maShapeIterator.hasNext()) + { + CanvasShape aShape = (CanvasShape)maShapeIterator.next(); + if (aShape != null) + if (aShape.Contains (e.getX(),e.getY())) + { + if (aShapeUnderMouse == null) + { + aSmallestSize = aShape.GetSize(); + aShapeUnderMouse = aShape; + } + else + { + Dimension aSize = aShape.GetSize(); + if (aSize.getWidth()<aSmallestSize.getWidth() + || aSize.getHeight()<aSmallestSize.getHeight()) + { + aSmallestSize = aSize; + aShapeUnderMouse = aShape; + } + } + } + } + return aShapeUnderMouse; + } + + private Canvas maCanvas; + private javax.swing.JTree maTree; +} diff --git a/accessibility/workben/org/openoffice/accessibility/awb/canvas/ShapeContainer.java b/accessibility/workben/org/openoffice/accessibility/awb/canvas/ShapeContainer.java new file mode 100644 index 000000000..d98bad4e3 --- /dev/null +++ b/accessibility/workben/org/openoffice/accessibility/awb/canvas/ShapeContainer.java @@ -0,0 +1,271 @@ +/************************************************************************* + * + * $RCSfile: ShapeContainer.java,v $ + * + * $Revision: 1.2 $ + * + * last change: $Author: obr $ $Date: 2003/09/19 09:21:35 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +package org.openoffice.accessibility.awb.canvas; + +import java.awt.Rectangle; +import java.util.Iterator; +import javax.swing.event.TreeModelListener; +import javax.swing.event.TreeExpansionListener; +import javax.swing.event.TreeWillExpandListener; +import javax.swing.event.TreeExpansionEvent; +import javax.swing.event.TreeModelEvent; +import javax.swing.tree.TreeNode; + +import com.sun.star.accessibility.XAccessibleEventBroadcaster; + +/** Each canvas has a shape container that is responsible for maintaining + a collection of shapes that are displayed by the canvas. +*/ +public class ShapeContainer + implements TreeModelListener, + TreeExpansionListener, + TreeWillExpandListener +{ + public ShapeContainer (Canvas aCanvas) + { + maShapeList = new java.util.Hashtable(); + maBoundingBox = new Rectangle (0,0,100,100); + maCanvas = aCanvas; + maTree = null; + } + + + + + public synchronized void SetTree (javax.swing.JTree aTree) + { + if (aTree != maTree) + { + if (maTree != null) + { + maTree.getModel().removeTreeModelListener (this); + maTree.removeTreeExpansionListener (this); + maTree.removeTreeWillExpandListener (this); + } + + Clear(); + + maTree = aTree; + + maTree.getModel().addTreeModelListener (this); + maTree.addTreeExpansionListener (this); + maTree.addTreeWillExpandListener (this); + } + } + + + + + public synchronized boolean AddNode (TreeNode aNode) + { + CanvasShape aShape = (CanvasShape)maShapeList.get (aNode); + if (aShape == null) + { + aShape = new CanvasShape (aNode, maCanvas); + + if (aNode instanceof XAccessibleEventBroadcaster) + ((XAccessibleEventBroadcaster) aNode).addEventListener(aShape); + + // Update bounding box that includes all objects. + if (maShapeList.size() == 0) + maBoundingBox = aShape.GetBBox(); + else + maBoundingBox = maBoundingBox.union (aShape.GetBBox()); + + maShapeList.put (aNode, aShape); + + maCanvas.repaint(); + + return true; + } + else + return false; + } + + + /** + */ + public synchronized boolean RemoveNode (TreeNode aNode) + { + CanvasShape aShape = (CanvasShape)maShapeList.get (aNode); + if (aShape != null) + { + if (aNode instanceof XAccessibleEventBroadcaster) + ((XAccessibleEventBroadcaster) aNode).removeEventListener(aShape); + + maShapeList.remove (aNode); + maCanvas.SelectObject (null); + maCanvas.repaint (); + return true; + } + else + return false; + } + + + + + public synchronized void Clear () + { + maShapeList.clear (); + } + + + + + public Iterator GetIterator () + { + return maShapeList.values().iterator (); + } + + + + + public CanvasShape Get (TreeNode aNode) + { + if (aNode != null) { + return (CanvasShape)maShapeList.get (aNode); + } + return null; + } + + + private void PrintMessage (String aMessage, java.util.EventObject aEvent) + { + // System.out.println ("ShapeContainer: " + aMessage + ": " + aEvent); + } + + public void treeNodesChanged (TreeModelEvent aEvent) + { + PrintMessage ("treeNodesChanged", aEvent); + } + public void treeNodesInserted (TreeModelEvent aEvent) + { + PrintMessage ("treeNodesInserted", aEvent); + Object[] aNewNodes = aEvent.getChildren(); + for (int i=0; i<aNewNodes.length; i++) + AddNode ((TreeNode)aNewNodes[i]); + } + public void treeNodesRemoved (TreeModelEvent aEvent) + { + PrintMessage ("treeNodesRemoved", aEvent); + Object[] aOldNodes = aEvent.getChildren(); + for (int i=0; i<aOldNodes.length; i++) + RemoveNode ((TreeNode)aOldNodes[i]); + } + public void treeStructureChanged (TreeModelEvent aEvent) + { + PrintMessage ("treeStructureChanged", aEvent); + TreeNode aNode = (TreeNode)aEvent.getTreePath().getLastPathComponent(); + RemoveAllChildren(aNode); + AddAllChildren(aNode); + } + + public void treeWillExpand (TreeExpansionEvent aEvent) + { + PrintMessage ("treeWillExpand", aEvent); + } + public void treeWillCollapse (TreeExpansionEvent aEvent) + { + PrintMessage ("treeWillCollapse", aEvent); + TreeNode aNode = (TreeNode)aEvent.getPath().getLastPathComponent(); + RemoveAllChildren (aNode); + } + public void treeExpanded (TreeExpansionEvent aEvent) + { + PrintMessage ("treeExpanded", aEvent); + TreeNode aNode = (TreeNode)aEvent.getPath().getLastPathComponent(); + AddAllChildren (aNode); + } + public void treeCollapsed (TreeExpansionEvent aEvent) + { + PrintMessage ("treeCollapsed", aEvent); + } + + private void AddAllChildren (TreeNode aNode) { + java.util.Enumeration aChildList = aNode.children(); + while (aChildList.hasMoreElements()) { + TreeNode aChild = (TreeNode) aChildList.nextElement(); + if (aChild != null) { + AddAllChildren (aChild); + AddNode (aChild); + } + } + } + + private void RemoveAllChildren (TreeNode aNode) { + java.util.Enumeration aChildList = aNode.children(); + while (aChildList.hasMoreElements()) { + TreeNode aChild = (TreeNode) aChildList.nextElement(); + if (aChild != null) { + RemoveAllChildren (aChild); + RemoveNode (aChild); + } + } + } + + + private java.util.Hashtable maShapeList; + private Rectangle maBoundingBox; + private Canvas maCanvas; + private javax.swing.JTree maTree; +} diff --git a/accessibility/workben/org/openoffice/accessibility/awb/canvas/makefile.common b/accessibility/workben/org/openoffice/accessibility/awb/canvas/makefile.common new file mode 100644 index 000000000..3b7262a84 --- /dev/null +++ b/accessibility/workben/org/openoffice/accessibility/awb/canvas/makefile.common @@ -0,0 +1,65 @@ +#************************************************************************* +# +# $RCSfile: makefile.common,v $ +# +# The Contents of this file are made available subject to the terms of +# either of the following licenses +# +# - GNU Lesser General Public License Version 2.1 +# - Sun Industry Standards Source License Version 1.1 +# +# Sun Microsystems Inc., October, 2000 +# +# GNU Lesser General Public License Version 2.1 +# ============================================= +# Copyright 2000 by Sun Microsystems, Inc. +# 901 San Antonio Road, Palo Alto, CA 94303, USA +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License version 2.1, as published by the Free Software Foundation. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, +# MA 02111-1307 USA +# +# +# Sun Industry Standards Source License Version 1.1 +# ================================================= +# The contents of this file are subject to the Sun Industry Standards +# Source License Version 1.1 (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.openoffice.org/license.html. +# +# Software provided under this License is provided on an "AS IS" basis, +# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, +# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, +# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. +# See the License for the specific provisions governing your rights and +# obligations concerning the Software. +# +# The Initial Developer of the Original Code is: Sun Microsystems, Inc. +# +# Copyright: 2000 by Sun Microsystems, Inc. +# +# All Rights Reserved. +# +# Contributor(s): _______________________________________ +# +# +# +#************************************************************************* + +JARFILES = sandbox.jar jurt.jar unoil.jar ridl.jar +JAVAFILES = \ + CanvasShape.java \ + Canvas.java \ + MouseObserver.java \ + ShapeContainer.java + diff --git a/accessibility/workben/org/openoffice/accessibility/awb/canvas/makefile.mk b/accessibility/workben/org/openoffice/accessibility/awb/canvas/makefile.mk new file mode 100644 index 000000000..6e3ef06aa --- /dev/null +++ b/accessibility/workben/org/openoffice/accessibility/awb/canvas/makefile.mk @@ -0,0 +1,86 @@ +#************************************************************************* +# +# $RCSfile: makefile.mk,v $ +# +# The Contents of this file are made available subject to the terms of +# either of the following licenses +# +# - GNU Lesser General Public License Version 2.1 +# - Sun Industry Standards Source License Version 1.1 +# +# Sun Microsystems Inc., October, 2000 +# +# GNU Lesser General Public License Version 2.1 +# ============================================= +# Copyright 2000 by Sun Microsystems, Inc. +# 901 San Antonio Road, Palo Alto, CA 94303, USA +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License version 2.1, as published by the Free Software Foundation. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, +# MA 02111-1307 USA +# +# +# Sun Industry Standards Source License Version 1.1 +# ================================================= +# The contents of this file are subject to the Sun Industry Standards +# Source License Version 1.1 (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.openoffice.org/license.html. +# +# Software provided under this License is provided on an "AS IS" basis, +# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, +# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, +# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. +# See the License for the specific provisions governing your rights and +# obligations concerning the Software. +# +# The Initial Developer of the Original Code is: Sun Microsystems, Inc. +# +# Copyright: 2000 by Sun Microsystems, Inc. +# +# All Rights Reserved. +# +# Contributor(s): _______________________________________ +# +# +# +#************************************************************************* + +PRJNAME = awb +PRJ = ..$/..$/..$/..$/..$/.. +TARGET = awb_canvas +PACKAGE = org$/openoffice$/accessibility$/awb$/canvas + +USE_JAVAVER:=TRUE + +# --- Settings ----------------------------------------------------- + +.INCLUDE : settings.mk + +.IF "$(JAVAVER:s/.//)" >= "140" + +.INCLUDE : makefile.common + +JAVACLASSFILES= $(foreach,i,$(JAVAFILES) $(CLASSDIR)$/$(PACKAGE)$/$(i:b).class) + +#JARTARGET = $(TARGET).jar +#JARCOMPRESS = TRUE +JARCLASSDIRS = $(PACKAGE) org/openoffice/java/accessibility/awb +#CUSTOMMANIFESTFILE = manifest +.ENDIF + +# --- Targets ------------------------------------------------------ + + +.INCLUDE : target.mk + diff --git a/accessibility/workben/org/openoffice/accessibility/awb/makefile.common b/accessibility/workben/org/openoffice/accessibility/awb/makefile.common new file mode 100644 index 000000000..80633d7e6 --- /dev/null +++ b/accessibility/workben/org/openoffice/accessibility/awb/makefile.common @@ -0,0 +1,3 @@ +JAVAFILES = \ + AccessibilityWorkBench.java \ + HelpWindow.java diff --git a/accessibility/workben/org/openoffice/accessibility/awb/makefile.mk b/accessibility/workben/org/openoffice/accessibility/awb/makefile.mk new file mode 100644 index 000000000..eb744d465 --- /dev/null +++ b/accessibility/workben/org/openoffice/accessibility/awb/makefile.mk @@ -0,0 +1,88 @@ +#************************************************************************* +# +# $RCSfile: makefile.mk,v $ +# +# The Contents of this file are made available subject to the terms of +# either of the following licenses +# +# - GNU Lesser General Public License Version 2.1 +# - Sun Industry Standards Source License Version 1.1 +# +# Sun Microsystems Inc., October, 2000 +# +# GNU Lesser General Public License Version 2.1 +# ============================================= +# Copyright 2000 by Sun Microsystems, Inc. +# 901 San Antonio Road, Palo Alto, CA 94303, USA +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License version 2.1, as published by the Free Software Foundation. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, +# MA 02111-1307 USA +# +# +# Sun Industry Standards Source License Version 1.1 +# ================================================= +# The contents of this file are subject to the Sun Industry Standards +# Source License Version 1.1 (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.openoffice.org/license.html. +# +# Software provided under this License is provided on an "AS IS" basis, +# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, +# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, +# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. +# See the License for the specific provisions governing your rights and +# obligations concerning the Software. +# +# The Initial Developer of the Original Code is: Sun Microsystems, Inc. +# +# Copyright: 2000 by Sun Microsystems, Inc. +# +# All Rights Reserved. +# +# Contributor(s): _______________________________________ +# +# +# +#************************************************************************* + +PRJNAME = awb +PRJ = ..$/..$/..$/..$/.. +TARGET = java_awb +PACKAGE = org$/openoffice$/accessibility$/awb + +USE_JAVAVER:=TRUE + +# --- Settings ----------------------------------------------------- + +.INCLUDE : settings.mk + +.IF "$(JAVAVER:s/.//)" >= "140" +JARFILES = sandbox.jar jurt.jar unoil.jar ridl.jar + +.INCLUDE : makefile.common + +JAVACLASSFILES= $(foreach,i,$(JAVAFILES) $(CLASSDIR)$/$(PACKAGE)$/$(i:b).class) + +JARTARGET = $(TARGET).jar +JARCOMPRESS = TRUE +JARCLASSDIRS = $(PACKAGE) \ + org$/openoffice$/accessibility$/misc +CUSTOMMANIFESTFILE = manifest +.ENDIF + +# --- Targets ------------------------------------------------------ + + +.INCLUDE : target.mk + diff --git a/accessibility/workben/org/openoffice/accessibility/awb/manifest b/accessibility/workben/org/openoffice/accessibility/awb/manifest new file mode 100644 index 000000000..951f9ec31 --- /dev/null +++ b/accessibility/workben/org/openoffice/accessibility/awb/manifest @@ -0,0 +1,3 @@ +Manifest-Version: 1.0 +Main-Class: org.openoffice.accessibility.awb.AccessibilityWorkBench +Class-Path: classes.jar sandbox.jar ridl.jar unoil.jar jurt.jar juh.jar java_uno.jar xt.jar jaxp.jar diff --git a/accessibility/workben/org/openoffice/accessibility/awb/tree/AccessibilityModel.java b/accessibility/workben/org/openoffice/accessibility/awb/tree/AccessibilityModel.java new file mode 100644 index 000000000..3b7c9aa48 --- /dev/null +++ b/accessibility/workben/org/openoffice/accessibility/awb/tree/AccessibilityModel.java @@ -0,0 +1,188 @@ +/************************************************************************* + * + * $RCSfile: AccessibilityModel.java,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: obr $ $Date: 2003/09/19 09:21:39 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +package org.openoffice.accessibility.awb.tree; + +import javax.swing.SwingUtilities; +import javax.swing.tree.TreeNode; +import javax.swing.tree.MutableTreeNode; +import javax.swing.tree.DefaultMutableTreeNode; + +import com.sun.star.uno.UnoRuntime; +import com.sun.star.awt.XExtendedToolkit; +import com.sun.star.awt.XTopWindow; +import com.sun.star.awt.XTopWindowListener; +import com.sun.star.accessibility.AccessibleRole; +import com.sun.star.accessibility.XAccessible; +import com.sun.star.accessibility.XAccessibleContext; +import com.sun.star.accessibility.XAccessibleEventBroadcaster; +import com.sun.star.accessibility.XAccessibleEventListener; + +/** + * + */ +public abstract class AccessibilityModel extends javax.swing.tree.DefaultTreeModel { + + protected java.util.Hashtable nodeList; + protected static DefaultMutableTreeNode disconnectedRootNode = + new DefaultMutableTreeNode("<not connected>"); + + /** Creates a new instance of AccessibilityModel */ + public AccessibilityModel() { + super(disconnectedRootNode, false); + nodeList = new java.util.Hashtable(); + } + + /* Convenience method that creates a new Toolkit node from xToolkit + * and sets as the new root object of the tree. + */ + public synchronized void setRoot(XExtendedToolkit xToolkit) { + if (xToolkit != null) { + try { + // remove old root node as topwindow listener + if (getRoot() instanceof ToolkitNode) { + ToolkitNode tn = (ToolkitNode) getRoot(); + if (tn.xToolkit != null) { + tn.xToolkit.removeTopWindowListener(tn); + } + } + nodeList.clear(); + setRoot(new ToolkitNode(xToolkit, this)); + xToolkit.addTopWindowListener((ToolkitNode) getRoot()); + } catch (com.sun.star.uno.RuntimeException e) { + // FIXME: error message ! + } + } + } + + /* Appends the new child to parent's child list */ + public void addNodeInto(MutableTreeNode newChild, MutableTreeNode parent) { + int index = parent.getChildCount(); + if (newChild != null && newChild.getParent() == parent) { + index -= 1; + } + insertNodeInto(newChild, parent, index); + } + + /** Adds listener to the listener chain of node */ + public static void addEventListener(TreeNode node, XAccessibleEventListener listener) { + if (node instanceof AccessibilityNode) { + ((AccessibilityNode) node).addEventListener(listener); + } + } + + /** Removes listener from the listener chain of node */ + public static void removeEventListener(TreeNode node, XAccessibleEventListener listener) { + if (node instanceof AccessibilityNode) { + ((AccessibilityNode) node).removeEventListener(listener); + } + } + + protected abstract AccessibilityNode createWindowNode(XAccessible xAccessible, + XAccessibleContext xAccessibleContext); + protected abstract AccessibilityNode createNode(XAccessible xAccessible); + + /** Adds xAccessible,node to the internal hashtable */ + public AccessibilityNode putNode(XAccessible xAccessible, AccessibilityNode node) { + if (xAccessible != null) { + String oid = UnoRuntime.generateOid(xAccessible); + java.lang.ref.WeakReference ref = (java.lang.ref.WeakReference) + nodeList.put(oid, new java.lang.ref.WeakReference(node)); + if (ref != null) { + return (AccessibilityNode) ref.get(); + } + } + return null; + } + + /** Returns the AccessibilityNode for xAccessible */ + public AccessibilityNode findNode(XAccessible xAccessible) { + if (xAccessible != null) { + String oid = UnoRuntime.generateOid(xAccessible); + java.lang.ref.WeakReference ref = + (java.lang.ref.WeakReference) nodeList.get(oid); + if (ref != null) { + return (AccessibilityNode) ref.get(); + } + } + return null; + } + + /** Removes the AccessibilityNode for xAccessible from the internal hashtable */ + public AccessibilityNode removeNode(XAccessible xAccessible) { + if (xAccessible != null) { + String oid = UnoRuntime.generateOid(xAccessible); + java.lang.ref.WeakReference ref = + (java.lang.ref.WeakReference) nodeList.remove(oid); + if (ref != null) { + return (AccessibilityNode) ref.get(); + } + } + return null; + } + + public AccessibilityNode removeNode(Object o) { + if (o instanceof XAccessible) { + return removeNode((XAccessible) o); + } + return null; + } +} diff --git a/accessibility/workben/org/openoffice/accessibility/awb/tree/AccessibilityNode.java b/accessibility/workben/org/openoffice/accessibility/awb/tree/AccessibilityNode.java new file mode 100644 index 000000000..f9ac963e2 --- /dev/null +++ b/accessibility/workben/org/openoffice/accessibility/awb/tree/AccessibilityNode.java @@ -0,0 +1,200 @@ +/************************************************************************* + * + * $RCSfile: AccessibilityNode.java,v $ + * + * $Revision: 1.2 $ + * + * last change: $Author: obr $ $Date: 2003/09/19 09:21:39 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +package org.openoffice.accessibility.awb.tree; + +import org.openoffice.accessibility.misc.AccessibleEventMulticaster; + +import javax.swing.tree.DefaultMutableTreeNode; +import javax.swing.SwingUtilities; + +import com.sun.star.accessibility.AccessibleEventId; +import com.sun.star.accessibility.AccessibleEventObject; +import com.sun.star.accessibility.XAccessible; +import com.sun.star.accessibility.XAccessibleContext; +import com.sun.star.accessibility.XAccessibleEventBroadcaster; +import com.sun.star.accessibility.XAccessibleEventListener; + +import com.sun.star.uno.UnoRuntime; + +class AccessibilityNode extends DefaultMutableTreeNode implements XAccessible, + XAccessibleEventListener, XAccessibleEventBroadcaster { + + protected AccessibilityModel treeModel; + protected XAccessibleContext unoAccessibleContext; + + private XAccessibleEventListener listener; + + public AccessibilityNode(AccessibilityModel treeModel) { + this.treeModel = treeModel; + } + + protected void finalize() throws java.lang.Throwable { + if (userObject != null) { + treeModel.removeNode(userObject); + } + } + + /** Sets the XAccessibleContext object of this node */ + public void setAccessibleContext(XAccessibleContext xAccessibleContext) { + unoAccessibleContext = xAccessibleContext; + } + + /** Returns the XAccessibleContext object of this node */ + public XAccessibleContext getAccessibleContext() { + return unoAccessibleContext; + } + + /** Attaches or Detaches the itself as listener to unoAccessibleContext */ + protected void setAttached(boolean attach) { + XAccessibleContext xAccessibleContext = unoAccessibleContext; + if (xAccessibleContext != null) { + try { + XAccessibleEventBroadcaster xAccessibleEventBroadcaster = + (XAccessibleEventBroadcaster) UnoRuntime.queryInterface( + XAccessibleEventBroadcaster.class, xAccessibleContext); + if (xAccessibleEventBroadcaster != null) { + if (attach) { + xAccessibleEventBroadcaster.addEventListener(this); + } else { + xAccessibleEventBroadcaster.removeEventListener(this); + } + } + } catch (com.sun.star.uno.RuntimeException e) { + // FIXME: error message ! + } + } + } + + public void disposing(com.sun.star.lang.EventObject eventObject) { + XAccessibleEventListener listener = this.listener; + if (listener != null) { + listener.disposing(eventObject); + } + + treeModel.removeNode(userObject); + userObject = null; + unoAccessibleContext = null; + // FIXME: mark the object as being disposed in the tree view ! + } + + protected void handleChildRemoved(XAccessible xAccessible) { + final AccessibilityNode node = treeModel.findNode(xAccessible); + if (node != null) { + SwingUtilities.invokeLater(new java.lang.Runnable() { + public void run() { + treeModel.removeNodeFromParent(node); + } + }); + } + } + + protected void handleChildAdded(XAccessible xAccessible) { + final AccessibilityNode parent = this; + final AccessibilityNode node = treeModel.createNode(xAccessible); + if (node != null) { + SwingUtilities.invokeLater(new java.lang.Runnable() { + public void run() { + try { + XAccessibleContext xAC = node.getAccessibleContext(); + if (xAC != null) { + treeModel.insertNodeInto(node, parent, + xAC.getAccessibleIndexInParent()); + } + } catch (com.sun.star.uno.RuntimeException e) { + // FIXME: output + } + } + }); + } + } + + public void notifyEvent(AccessibleEventObject accessibleEventObject) { + if (accessibleEventObject.EventId == AccessibleEventId.CHILD) { + XAccessible xAccessible = (XAccessible) UnoRuntime.queryInterface( + XAccessible.class, accessibleEventObject.OldValue); + if (xAccessible != null) { + handleChildRemoved(xAccessible); + } + + xAccessible = (XAccessible) UnoRuntime.queryInterface( + XAccessible.class, accessibleEventObject.NewValue); + if (xAccessible != null) { + handleChildAdded(xAccessible); + } + } + + XAccessibleEventListener listener = this.listener; + if (listener != null) { + listener.notifyEvent(accessibleEventObject); + } + } + + public synchronized void addEventListener(com.sun.star.accessibility.XAccessibleEventListener xAccessibleEventListener) { + listener = AccessibleEventMulticaster.add(listener, xAccessibleEventListener); + } + + public synchronized void removeEventListener(com.sun.star.accessibility.XAccessibleEventListener xAccessibleEventListener) { + listener = AccessibleEventMulticaster.remove(listener, xAccessibleEventListener); + } +} + + diff --git a/accessibility/workben/org/openoffice/accessibility/awb/tree/AccessibilityTree.java b/accessibility/workben/org/openoffice/accessibility/awb/tree/AccessibilityTree.java new file mode 100644 index 000000000..86086822f --- /dev/null +++ b/accessibility/workben/org/openoffice/accessibility/awb/tree/AccessibilityTree.java @@ -0,0 +1,123 @@ +/************************************************************************* + * + * $RCSfile: AccessibilityTree.java,v $ + * + * $Revision: 1.2 $ + * + * last change: $Author: obr $ $Date: 2003/09/19 09:21:39 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +package org.openoffice.accessibility.awb.tree; + +import org.openoffice.accessibility.misc.NameProvider; + +import javax.swing.tree.DefaultTreeModel; +import javax.swing.tree.DefaultMutableTreeNode; + +import com.sun.star.awt.XExtendedToolkit; +import com.sun.star.accessibility.XAccessible; +import com.sun.star.accessibility.XAccessibleContext; + +/** + * + */ +public class AccessibilityTree extends javax.swing.JTree { + + /** Creates a new instance of AccessibilityTree */ + public AccessibilityTree(javax.swing.tree.TreeModel model) { + super(model); + // always show handles to indicate expandable / collapsable + showsRootHandles = true; + } + + public void setToolkit(XExtendedToolkit xToolkit) { + AccessibilityModel model = (AccessibilityModel) getModel(); + if (model != null) { + // hide the root node when connected + setRootVisible(xToolkit == null); + // update the root node + model.setRoot(xToolkit); + model.reload(); + } + } + + public String convertValueToText(Object value, boolean selected, + boolean expanded, boolean leaf, int row, boolean hasFocus) { + + if (value instanceof DefaultMutableTreeNode) { + DefaultMutableTreeNode node = (DefaultMutableTreeNode) value; + + Object userObject = node.getUserObject(); + if (userObject != null && userObject instanceof XAccessible) { + XAccessible xAccessible = (XAccessible) userObject; + try { + XAccessibleContext xAC = xAccessible.getAccessibleContext(); + if (xAC != null) { + String name = xAC.getAccessibleName(); + if (name.length() == 0) { + name = new String ("<no name>"); + } + value = name + " / " + NameProvider.getRoleName(xAC.getAccessibleRole()); + } + } catch (com.sun.star.uno.RuntimeException e) { + value = "???"; + } + } + } + + return super.convertValueToText(value, selected, expanded, leaf, row, hasFocus); + } + +} diff --git a/accessibility/workben/org/openoffice/accessibility/awb/tree/AccessibilityTreeModel.java b/accessibility/workben/org/openoffice/accessibility/awb/tree/AccessibilityTreeModel.java new file mode 100644 index 000000000..3bbd1b93e --- /dev/null +++ b/accessibility/workben/org/openoffice/accessibility/awb/tree/AccessibilityTreeModel.java @@ -0,0 +1,251 @@ +/************************************************************************* + * + * $RCSfile: AccessibilityTreeModel.java,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: af $ $Date: 2003/06/13 16:30:28 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc.,y October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +package org.openoffice.accessibility.awb.tree; + +import com.sun.star.accessibility.XAccessible; +import com.sun.star.awt.XExtendedToolkit; +import com.sun.star.lang.DisposedException; +import com.sun.star.lang.IndexOutOfBoundsException; + +import org.openoffice.accessibility.misc.OfficeConnection; +import org.openoffice.accessibility.awb.event.EventQueue; + +import javax.swing.tree.DefaultTreeModel; +import javax.swing.tree.TreeNode; + + +public class AccessibilityTreeModel + extends DefaultTreeModel +{ + public AccessibilityTreeModel () + { + super (null); + setAsksAllowsChildren (false); + + SetRootNode(); + } + + + + /** Release all resources. + */ + synchronized public void Dispose () + { + Clear (); + } + + + + /** Calls to this method are dispatched to the given node but are + observed for exceptions. + */ + synchronized public boolean isLeaf (Object aObject) + { + boolean bIsLeaf = true; + + if (aObject != null) + { + AccessibilityNode aNode = (AccessibilityNode)aObject; + try + { + bIsLeaf = aNode.isLeaf(); + } + catch (DisposedException aException) + { + System.out.println ("node is disposed. removing it"); + /* TreeNode aParent = aNode.GetParent(); + int nIndexInParent = aParent.getIndex (aNode); + aNode.removeFromParent (); + System.out.println ("" + aParent + " # " + aNode + " # "+ nIndexInParent); + nodesWereRemoved ( + aParent, new int[]{nIndexInParent}, new + Object[]{aNode}); + */ + } + catch (Exception aException) + { + System.err.println ("caught exception in AccessibilityTreeModel.isLeaf():" + + aException); + aException.printStackTrace (System.err); + } + } + + return bIsLeaf; + } + + + + + synchronized public int getChildCount (Object aObject) + { + AccessibilityNode aNode = (AccessibilityNode)aObject; + return aNode.getChildCount(); + } + + + + + /** Return the requested child of aParent. If that child is not yet + known to the parent then try to create it. + */ + synchronized public Object getChild (Object aParent, final int nIndex) + { + AccessibilityNode aChild = null; + + final AccessibilityNode aParentNode = (AccessibilityNode)aParent; + + // Try to get an existing child from the super class object. + aChild = aParentNode.GetChildNoCreate (nIndex); + + // When the requested child does not yet exist and this node is not a + // special node then create a new node. + if (aChild == null) + { + aChild = aParentNode.CreateChild (nIndex); + aParentNode.SetChild ((AccessibilityNode)aChild, nIndex); + /* EventQueue.Instance().AddEvent (new Runnable() { public void run() { + AccessibilityTreeModel.this.nodeWasInserted ( + aParentNode, nIndex); + }}); + */ } + + return aChild; + } + + + synchronized public void nodeWasInserted (AccessibilityNode aParent, int nIndex) + { + nodesWereInserted (aParent, new int[]{nIndex}); + nodeStructureChanged (aParent); + + } + + + + + /** Clear the tree so that afterwards it has only the root node. + */ + public void Clear () + { + AccessibilityNode aRoot = (AccessibilityNode)getRoot(); + aRoot.RemoveAllChildren(); + SetRootNode(); + nodeStructureChanged (aRoot); + } + + + + + private void SetRootNode () + { + OfficeConnection aConnection = OfficeConnection.Instance(); + AccessibilityNode aRoot; + if (aConnection!=null && aConnection.IsValid()) + aRoot = new AccessibilityNode ("<connected>"); + else + aRoot = new AccessibilityNode ("<not connected>"); + setRoot (aRoot); + } + + + + + /** Add a new child to the root node. + */ + public synchronized void AddTopLevelNode (AccessibilityNode aNode) + { + if (aNode != null) + { + if ( ! OfficeConnection.Instance().IsValid()) + { + setRoot (null); + } + + AccessibilityNode aRoot = (AccessibilityNode)getRoot(); + if (aRoot == null) + { + aRoot = new AccessibilityNode ("<connected>"); + setRoot (aRoot); + } + + aNode.SetParent (aRoot); + aRoot.Append (aNode); + nodesWereInserted (aRoot, new int[]{aRoot.getIndex (aNode)}); + } + } + + + + + /** Remove a node that is a direct child of the root. + */ + public synchronized void RemoveTopLevelNode (AccessibilityNode aNode) + { + AccessibilityNode aRoot = (AccessibilityNode)getRoot(); + if (aRoot != null) + { + int nIndex = aRoot.getIndex (aNode); + aRoot.Remove (aNode); + nodesWereRemoved (aRoot, new int[]{nIndex}, new Object[]{aNode}); + } + } +} diff --git a/accessibility/workben/org/openoffice/accessibility/awb/tree/DynamicAccessibilityModel.java b/accessibility/workben/org/openoffice/accessibility/awb/tree/DynamicAccessibilityModel.java new file mode 100644 index 000000000..d699ee04c --- /dev/null +++ b/accessibility/workben/org/openoffice/accessibility/awb/tree/DynamicAccessibilityModel.java @@ -0,0 +1,157 @@ +/************************************************************************* + * + * $RCSfile: DynamicAccessibilityModel.java,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: obr $ $Date: 2003/09/19 09:21:39 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +package org.openoffice.accessibility.awb.tree; + +import javax.swing.tree.TreeNode; +import javax.swing.tree.MutableTreeNode; +import javax.swing.tree.DefaultMutableTreeNode; +import javax.swing.event.TreeExpansionListener; +import javax.swing.event.TreeWillExpandListener; + +import com.sun.star.accessibility.AccessibleRole; +import com.sun.star.accessibility.XAccessible; +import com.sun.star.accessibility.XAccessibleContext; + +/** + * + */ +public class DynamicAccessibilityModel extends AccessibilityModel implements TreeExpansionListener, TreeWillExpandListener { + + /* Creates a AccessibilityNode object for a window */ + protected AccessibilityNode createWindowNode(XAccessible xAccessible, + XAccessibleContext xAccessibleContext) { + if (xAccessible != null) { + // Some objects inherit XAccessible, but should not appear in + // the hierarchy as toplevels (like sub-menus), so they don't + // return an accessible context. + if (xAccessibleContext != null) { + AccessibilityNode node = new AccessibilityNode(this); + node.setUserObject(xAccessible); + node.setAccessibleContext(xAccessibleContext); + putNode(xAccessible, node); + return node; + } + } + return null; + } + + /* Creates a DynamicAccessibilityNode object */ + protected AccessibilityNode createNode(XAccessible xAccessible) { + if (xAccessible != null) { + try { + // Some objects inherit XAccessible, but should not appear in + // the hierarchy as toplevels (like sub-menus), so they don't + // return an accessible context. + XAccessibleContext xAccessibleContext = xAccessible.getAccessibleContext(); + if (xAccessibleContext != null) { + AccessibilityNode node = new DynamicAccessibilityNode(this); + node.setUserObject(xAccessible); + node.setAccessibleContext(xAccessibleContext); + putNode(xAccessible, node); + return node; + } + } catch (com.sun.star.uno.RuntimeException e) { + } + } + return null; + } + + public void treeCollapsed(javax.swing.event.TreeExpansionEvent treeExpansionEvent) { + TreeNode node = (TreeNode) treeExpansionEvent.getPath().getLastPathComponent(); + if (node instanceof DynamicAccessibilityNode) { + DynamicAccessibilityNode dynode = (DynamicAccessibilityNode) node; + dynode.clear(); + } + } + + public void treeExpanded(javax.swing.event.TreeExpansionEvent treeExpansionEvent) { + TreeNode node = (TreeNode) treeExpansionEvent.getPath().getLastPathComponent(); + if (node instanceof AccessibilityNode) { + // Calling oneway methods from an UNO thread may cause + // deadlocks, so adding the listeners here. + for (java.util.Enumeration e = node.children(); e.hasMoreElements(); ) { + ((AccessibilityNode) e.nextElement()).setAttached(true); + } + } + } + + public void treeWillCollapse(javax.swing.event.TreeExpansionEvent treeExpansionEvent) + throws javax.swing.tree.ExpandVetoException { + TreeNode node = (TreeNode) treeExpansionEvent.getPath().getLastPathComponent(); + if (node instanceof AccessibilityNode) { + // Calling oneway methods from an UNO thread may cause + // deadlocks, so adding the listeners here. + for (java.util.Enumeration e = node.children(); e.hasMoreElements(); ) { + ((AccessibilityNode) e.nextElement()).setAttached(false); + } + } + } + + public void treeWillExpand(javax.swing.event.TreeExpansionEvent treeExpansionEvent) + throws javax.swing.tree.ExpandVetoException { + TreeNode node = (TreeNode) treeExpansionEvent.getPath().getLastPathComponent(); + if (node instanceof DynamicAccessibilityNode) { + DynamicAccessibilityNode dynode = (DynamicAccessibilityNode) node; + dynode.populate(); + } + } +} diff --git a/accessibility/workben/org/openoffice/accessibility/awb/tree/DynamicAccessibilityNode.java b/accessibility/workben/org/openoffice/accessibility/awb/tree/DynamicAccessibilityNode.java new file mode 100644 index 000000000..5c984e4c7 --- /dev/null +++ b/accessibility/workben/org/openoffice/accessibility/awb/tree/DynamicAccessibilityNode.java @@ -0,0 +1,126 @@ +/************************************************************************* + * + * $RCSfile: DynamicAccessibilityNode.java,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: obr $ $Date: 2003/09/19 09:21:40 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +package org.openoffice.accessibility.awb.tree; + +import com.sun.star.uno.UnoRuntime; +import com.sun.star.accessibility.XAccessible; +import com.sun.star.accessibility.XAccessibleContext; + +/* + * This class is dynamic in the way that it does not contain any children + * until the node is going to be expanded. It also releases all children + * as soon as the node is collapsed again. + */ +class DynamicAccessibilityNode extends AccessibilityNode { + + public DynamicAccessibilityNode(AccessibilityModel treeModel) { + super(treeModel); + } + + // Populates the child list. Called by AccessibilityMode.treeWillExpand(). + protected void populate() { + try { + XAccessibleContext xAC = getAccessibleContext(); + if (xAC != null) { + int n = xAC.getAccessibleChildCount(); + for (int i=0; i<n; i++) { + XAccessible xAccessible = xAC.getAccessibleChild(i); + AccessibilityNode node = treeModel.findNode(xAccessible); + if (node == null) { + node = treeModel.createNode(xAccessible); + } + if (node != null) { + // NOTE: do not send any tree notifications here ! + add(node); + } + } + } + } catch (com.sun.star.lang.IndexOutOfBoundsException e) { + // This should never happen since we previously checked the child + // count. + // FIXME: error message + } catch (com.sun.star.uno.RuntimeException e) { + // FIXME: error message + } + } + + // Clears the child list. Called by AccessibilityModel.treeCollapsed(). + protected void clear() { + removeAllChildren(); + } + + /* This is called whenever the node is painted, no matter if collapsed + * or expanded. Making this a "life" value seems to be appropriate. + */ + public boolean isLeaf() { + try { + XAccessibleContext xAC = getAccessibleContext(); + if (xAC != null) { + return xAC.getAccessibleChildCount() == 0; + } + return true; + } catch (com.sun.star.uno.RuntimeException e) { + return true; + } + } + +} diff --git a/accessibility/workben/org/openoffice/accessibility/awb/tree/Makefile b/accessibility/workben/org/openoffice/accessibility/awb/tree/Makefile new file mode 100644 index 000000000..8166c0b91 --- /dev/null +++ b/accessibility/workben/org/openoffice/accessibility/awb/tree/Makefile @@ -0,0 +1,71 @@ +#************************************************************************* +# +# $RCSfile: Makefile,v $ +# +# The Contents of this file are made available subject to the terms of +# either of the following licenses +# +# - GNU Lesser General Public License Version 2.1 +# - Sun Industry Standards Source License Version 1.1 +# +# Sun Microsystems Inc., October, 2000 +# +# GNU Lesser General Public License Version 2.1 +# ============================================= +# Copyright 2000 by Sun Microsystems, Inc. +# 901 San Antonio Road, Palo Alto, CA 94303, USA +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License version 2.1, as published by the Free Software Foundation. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, +# MA 02111-1307 USA +# +# +# Sun Industry Standards Source License Version 1.1 +# ================================================= +# The contents of this file are subject to the Sun Industry Standards +# Source License Version 1.1 (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.openoffice.org/license.html. +# +# Software provided under this License is provided on an "AS IS" basis, +# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, +# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, +# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. +# See the License for the specific provisions governing your rights and +# obligations concerning the Software. +# +# The Initial Developer of the Original Code is: Sun Microsystems, Inc. +# +# Copyright: 2000 by Sun Microsystems, Inc. +# +# All Rights Reserved. +# +# Contributor(s): _______________________________________ +# +# +# +#************************************************************************* + +all : package + +ROOT=../../../../.. +PACKAGE = org.openoffice.accessibility.awb.tree +SUBDIRS = +include makefile.common + +include $(ROOT)/makefile.in + + +package : $(CLASS_FILES) + + diff --git a/accessibility/workben/org/openoffice/accessibility/awb/tree/ToolkitNode.java b/accessibility/workben/org/openoffice/accessibility/awb/tree/ToolkitNode.java new file mode 100644 index 000000000..aa5188991 --- /dev/null +++ b/accessibility/workben/org/openoffice/accessibility/awb/tree/ToolkitNode.java @@ -0,0 +1,249 @@ +/************************************************************************* + * + * $RCSfile: ToolkitNode.java,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: obr $ $Date: 2003/09/19 09:21:41 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +package org.openoffice.accessibility.awb.tree; + +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.XTopWindow; + +import com.sun.star.uno.UnoRuntime; + +import javax.swing.SwingUtilities; +import javax.swing.tree.DefaultMutableTreeNode; + +/** + * + */ +public class ToolkitNode extends DefaultMutableTreeNode + implements com.sun.star.awt.XTopWindowListener { + + protected XExtendedToolkit xToolkit; + + private AccessibilityModel treeModel; + + /** Creates a new instance of TopWindowListener */ + public ToolkitNode(XExtendedToolkit xToolkit, AccessibilityModel treeModel) { + super("<connected>"); + this.xToolkit = xToolkit; + this.treeModel = treeModel; + + // Initially fill the child list + try { + for (int i=0,j=xToolkit.getTopWindowCount(); i<j; i++) { + XTopWindow xTopWindow = xToolkit.getTopWindow(i); + if (xTopWindow != null) { + AccessibilityNode an = getTopWindowNode(xTopWindow); + if (an != null) { + add(an); + // Calling oneway methods from an UNO thread may cause + // deadlocks, so adding the listeners here. + an.setAttached(true); + } + } + } + } catch (com.sun.star.lang.IndexOutOfBoundsException e) { + // This should never happen since we properly check the count + // before - anyway returning what we got so far. + } + } + + /** Returns an AccessibilityNode if xAccessible has a valid toplevel */ + private AccessibilityNode getTopWindowNode(XAccessible xAccessible) { + XAccessibleContext xAC = xAccessible.getAccessibleContext(); + if (xAC != null) { + short role = xAC.getAccessibleRole(); + if ((role == AccessibleRole.FRAME) || (role == AccessibleRole.DIALOG) || (role == AccessibleRole.WINDOW)) { + return treeModel.createWindowNode(xAccessible, xAC); + } + } + return null; + } + + /** Returns an AccessibilityNode if xAccessible has a valid toplevel */ + private AccessibilityNode getTopWindowNode(XAccessible xAccessible, XAccessibleContext xAC) { + if (xAC != null) { + short role = xAC.getAccessibleRole(); + if ((role == AccessibleRole.FRAME) || (role == AccessibleRole.DIALOG) || (role == AccessibleRole.WINDOW)) { + AccessibilityNode parent = treeModel.createWindowNode(xAccessible, xAC); + if (parent != null) { + try { + int n = xAC.getAccessibleChildCount(); + for (int i=0; i<n; i++) { + AccessibilityNode child = treeModel.createNode(xAC.getAccessibleChild(i)); + if (child != null) { + parent.add(child); + } + } + } catch (com.sun.star.lang.IndexOutOfBoundsException e) { + + } + } + return parent; + } + } + return null; + } + + /** Returns the XAccessible interface corresponding to the toplevel window */ + private AccessibilityNode getTopWindowNode(XTopWindow w) { + XAccessible xAccessible = (XAccessible) + UnoRuntime.queryInterface(XAccessible.class, w); + if (xAccessible != null) { + // XTopWindows usually have an accessible parent, which is the + // native container window .. + XAccessibleContext xAC = xAccessible.getAccessibleContext(); + if (xAC != null) { + XAccessible xParent = xAC.getAccessibleParent(); + if (xParent != null) { + AccessibilityNode parent = getTopWindowNode(xParent); + AccessibilityNode child = treeModel.createNode(xAccessible); + if (parent != null && child != null) { + parent.add(child); + } + return parent; + } else { + return getTopWindowNode(xAccessible, xAC); + } + } + } + return null; + } + + public void disposing(com.sun.star.lang.EventObject eventObject) { + // FIXME : message + // prevent setRoot from removing this as event listener + xToolkit = null; + treeModel.setRoot(treeModel.disconnectedRootNode); + } + + public void windowActivated(com.sun.star.lang.EventObject eventObject) { + } + + public void windowClosed(com.sun.star.lang.EventObject eventObject) { + XAccessible xAccessible = (XAccessible) UnoRuntime.queryInterface( + XAccessible.class, eventObject.Source); + if (xAccessible != null) { + AccessibilityNode node = treeModel.findNode(xAccessible); + + // The object implementing XTopWindow is often not the toplevel + // accessible object. + if (node != null && node.getParent() != this) { + node = (AccessibilityNode) node.getParent(); + } + + if (node != null) { + final AccessibilityNode an = node; + Runnable removeRun = new Runnable() { + public void run() { + try { + treeModel.removeNodeFromParent(an); + // Calling oneway methods from an UNO thread may cause + // deadlocks, so removing the listeners here. + an.setAttached(false); + } catch (IllegalArgumentException e) { + // for some toplevel we get more than one event - + // ignoring + } + } + }; + SwingUtilities.invokeLater(removeRun); + } + } + } + + public void windowClosing(com.sun.star.lang.EventObject eventObject) { + } + + public void windowDeactivated(com.sun.star.lang.EventObject eventObject) { + } + + public void windowMinimized(com.sun.star.lang.EventObject eventObject) { + } + + public void windowNormalized(com.sun.star.lang.EventObject eventObject) { + } + + public void windowOpened(com.sun.star.lang.EventObject eventObject) { + final XTopWindow xTopWindow = (XTopWindow) UnoRuntime.queryInterface( + XTopWindow.class, eventObject.Source); + if (xTopWindow != null) { + final ToolkitNode tn = this; + Runnable addNodeRun = new Runnable() { + public void run() { + // Note: UNO does not allow to make synchronous callbacks + // to oneway calls, so we have to fetch the node here. + AccessibilityNode an = getTopWindowNode(xTopWindow); + if (an != null) { + treeModel.addNodeInto(an, tn); + // Calling oneway methods from an UNO thread may cause + // deadlocks, so adding the listeners here. + an.setAttached(true); + } + } + }; + SwingUtilities.invokeLater(addNodeRun); + } + } +} diff --git a/accessibility/workben/org/openoffice/accessibility/awb/tree/makefile.common b/accessibility/workben/org/openoffice/accessibility/awb/tree/makefile.common new file mode 100644 index 000000000..7a0813b09 --- /dev/null +++ b/accessibility/workben/org/openoffice/accessibility/awb/tree/makefile.common @@ -0,0 +1,66 @@ +#************************************************************************* +# +# $RCSfile: makefile.common,v $ +# +# The Contents of this file are made available subject to the terms of +# either of the following licenses +# +# - GNU Lesser General Public License Version 2.1 +# - Sun Industry Standards Source License Version 1.1 +# +# Sun Microsystems Inc., October, 2000 +# +# GNU Lesser General Public License Version 2.1 +# ============================================= +# Copyright 2000 by Sun Microsystems, Inc. +# 901 San Antonio Road, Palo Alto, CA 94303, USA +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License version 2.1, as published by the Free Software Foundation. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, +# MA 02111-1307 USA +# +# +# Sun Industry Standards Source License Version 1.1 +# ================================================= +# The contents of this file are subject to the Sun Industry Standards +# Source License Version 1.1 (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.openoffice.org/license.html. +# +# Software provided under this License is provided on an "AS IS" basis, +# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, +# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, +# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. +# See the License for the specific provisions governing your rights and +# obligations concerning the Software. +# +# The Initial Developer of the Original Code is: Sun Microsystems, Inc. +# +# Copyright: 2000 by Sun Microsystems, Inc. +# +# All Rights Reserved. +# +# Contributor(s): _______________________________________ +# +# +# +#************************************************************************* + +JARFILES = sandbox.jar jurt.jar unoil.jar ridl.jar +JAVAFILES = \ + AccessibilityModel.java \ + AccessibilityNode.java \ + AccessibilityTree.java \ + DynamicAccessibilityModel.java \ + DynamicAccessibilityNode.java \ + ToolkitNode.java diff --git a/accessibility/workben/org/openoffice/accessibility/awb/tree/makefile.mk b/accessibility/workben/org/openoffice/accessibility/awb/tree/makefile.mk new file mode 100644 index 000000000..7867cf1cc --- /dev/null +++ b/accessibility/workben/org/openoffice/accessibility/awb/tree/makefile.mk @@ -0,0 +1,82 @@ +#************************************************************************* +# +# $RCSfile: makefile.mk,v $ +# +# The Contents of this file are made available subject to the terms of +# either of the following licenses +# +# - GNU Lesser General Public License Version 2.1 +# - Sun Industry Standards Source License Version 1.1 +# +# Sun Microsystems Inc., October, 2000 +# +# GNU Lesser General Public License Version 2.1 +# ============================================= +# Copyright 2000 by Sun Microsystems, Inc. +# 901 San Antonio Road, Palo Alto, CA 94303, USA +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License version 2.1, as published by the Free Software Foundation. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, +# MA 02111-1307 USA +# +# +# Sun Industry Standards Source License Version 1.1 +# ================================================= +# The contents of this file are subject to the Sun Industry Standards +# Source License Version 1.1 (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.openoffice.org/license.html. +# +# Software provided under this License is provided on an "AS IS" basis, +# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, +# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, +# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. +# See the License for the specific provisions governing your rights and +# obligations concerning the Software. +# +# The Initial Developer of the Original Code is: Sun Microsystems, Inc. +# +# Copyright: 2000 by Sun Microsystems, Inc. +# +# All Rights Reserved. +# +# Contributor(s): _______________________________________ +# +# +# +#************************************************************************* + +PRJNAME = awb +PRJ = ..$/..$/..$/..$/..$/.. +TARGET = java_tree +PACKAGE = org$/openoffice$/accessibility$/awb$/tree + +USE_JAVAVER:=TRUE + +# --- Settings ----------------------------------------------------- + +.INCLUDE : settings.mk + +.IF "$(JAVAVER:s/.//)" >= "140" + +.INCLUDE : makefile.common + +JAVACLASSFILES= $(foreach,i,$(JAVAFILES) $(CLASSDIR)$/$(PACKAGE)$/$(i:b).class) + +.ENDIF + +# --- Targets ------------------------------------------------------ + + +.INCLUDE : target.mk + diff --git a/accessibility/workben/org/openoffice/accessibility/awb/view/ComponentView.java b/accessibility/workben/org/openoffice/accessibility/awb/view/ComponentView.java new file mode 100644 index 000000000..dfb4fcb1a --- /dev/null +++ b/accessibility/workben/org/openoffice/accessibility/awb/view/ComponentView.java @@ -0,0 +1,229 @@ +/************************************************************************* + * + * $RCSfile: ComponentView.java,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: af $ $Date: 2003/06/13 16:30:32 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +package org.openoffice.accessibility.awb.view; + +import java.awt.Color; +import java.awt.Dimension; + +import java.awt.event.ActionListener; +import java.awt.event.ActionEvent; + +import javax.swing.JLabel; + +import com.sun.star.accessibility.AccessibleEventId; +import com.sun.star.accessibility.AccessibleEventObject; +import com.sun.star.accessibility.XAccessible; +import com.sun.star.accessibility.XAccessibleComponent; +import com.sun.star.accessibility.XAccessibleContext; +import com.sun.star.uno.UnoRuntime; + +import org.openoffice.accessibility.misc.NameProvider; + +/** The <type>ContextView</type> class displays information accessible over + the <type>XAccessibleContext</type> interface. This includes name, + description, and role. +*/ +public class ComponentView + extends ObjectView +{ + static public ObjectView Create ( + ObjectViewContainer aContainer, + XAccessibleContext xContext) + { + if (UnoRuntime.queryInterface( + XAccessibleComponent.class, xContext) != null) + return new ComponentView (aContainer); + else + return null; + } + + public ComponentView (ObjectViewContainer aContainer) + { + super (aContainer); + + ViewGridLayout aLayout = new ViewGridLayout (this); + + maRelativeLocationLabel = aLayout.AddLabeledEntry ("Relative Location: "); + maAbsoluteLocationLabel = aLayout.AddLabeledEntry ("Location on Screen: "); + maSizeLabel = aLayout.AddLabeledEntry ("Size"); + maBoundingBoxLabel = aLayout.AddLabeledEntry ("Bounding Box: "); + maConsistencyLabel = aLayout.AddLabeledEntry ("Consistent: "); + maForegroundColorLabel = aLayout.AddLabeledEntry ("Foreground Color: "); + maBackgroundColorLabel = aLayout.AddLabeledEntry ("Background Color: "); + } + + + public void SetObject (XAccessibleContext xContext) + { + mxComponent = (XAccessibleComponent)UnoRuntime.queryInterface( + XAccessibleComponent.class, xContext); + super.SetObject (xContext); + } + + public void Update () + { + if (mxContext == null) + { + maRelativeLocationLabel.setText ("<null object>"); + maAbsoluteLocationLabel.setText ("<null object>"); + maSizeLabel.setText ("<null object>"); + maBoundingBoxLabel.setText ("<null object>"); + maConsistencyLabel.setText ("<null object>"); + maForegroundColorLabel.setText ("<null object>"); + maBackgroundColorLabel.setText ("<null object>"); + } + else + { + com.sun.star.awt.Point aLocation = mxComponent.getLocation(); + maRelativeLocationLabel.setText ( + aLocation.X + ", " + aLocation.Y); + com.sun.star.awt.Point aLocationOnScreen = + mxComponent.getLocationOnScreen(); + maAbsoluteLocationLabel.setText ( + aLocationOnScreen.X + ", " + aLocationOnScreen.Y); + com.sun.star.awt.Size aSize = mxComponent.getSize(); + maSizeLabel.setText ( + aSize.Width + ", " + aSize.Height); + com.sun.star.awt.Rectangle aBBox = mxComponent.getBounds(); + maBoundingBoxLabel.setText ( + aBBox.X + ", " + aBBox.Y + "," + + aBBox.Width + ", " + aBBox.Height); + int nColor = mxComponent.getForeground(); + maForegroundColorLabel.setText ( + "R"+ (nColor>>16&0xff) + + "G" + (nColor>>8&0xff) + + "B" + (nColor>>0&0xff) + + "A" + (nColor>>24&0xff)); + nColor = mxComponent.getBackground(); + maBackgroundColorLabel.setText ( + "R"+ (nColor>>16&0xff) + + "G" + (nColor>>8&0xff) + + "B" + (nColor>>0&0xff) + + "A" + (nColor>>24&0xff)); + + // Check consistency of coordinates. + String sConsistency = new String (); + if (aBBox.X!=aLocation.X || aBBox.Y!=aLocation.Y) + sConsistency += (sConsistency.length()!=0?", ":"") + + "Bounding box conflicts with relative location"; + if (aBBox.Width!=aSize.Width || aBBox.Height!=aSize.Height) + sConsistency += (sConsistency.length()!=0?", ":"") + + "Bounding box conflicts with size"; + XAccessible xParent = mxContext.getAccessibleParent(); + XAccessibleComponent xParentComponent = + (XAccessibleComponent)UnoRuntime.queryInterface( + XAccessibleComponent.class, xParent); + if (xParentComponent == null) + { + if (aLocation.X != aLocationOnScreen.X + || aLocation.Y != aLocationOnScreen.Y) + sConsistency += (sConsistency.length()!=0?", ":"") + + "location on screen does not equal " + + "relative location without parent"; + } + else + { + com.sun.star.awt.Point aParentLocationOnScreen = + xParentComponent.getLocationOnScreen(); + if (aLocation.X+aParentLocationOnScreen.X + != aLocationOnScreen.X + || aLocation.Y+aParentLocationOnScreen.Y + != aLocationOnScreen.Y) + sConsistency += (sConsistency.length()!=0?", ":"") + + "location on screen does not match " + + "relative location"; + } + if (sConsistency.length() == 0) + sConsistency += "yes"; + else + maConsistencyLabel.setBackground (GetContainer().GetErrorColor()); + maConsistencyLabel.setText (sConsistency); + } + } + + public String GetTitle () + { + return ("Component"); + } + + /** Listen for changes regarding displayed values. + */ + public void notifyEvent (AccessibleEventObject aEvent) + { + switch (aEvent.EventId) + { + case AccessibleEventId.BOUNDRECT_CHANGED : + case AccessibleEventId.VISIBLE_DATA_CHANGED : + Update (); + } + } + + private XAccessibleComponent mxComponent; + private JLabel + maRelativeLocationLabel, + maAbsoluteLocationLabel, + maSizeLabel, + maBoundingBoxLabel, + maConsistencyLabel, + maForegroundColorLabel, + maBackgroundColorLabel; +} diff --git a/accessibility/workben/org/openoffice/accessibility/awb/view/ContextView.java b/accessibility/workben/org/openoffice/accessibility/awb/view/ContextView.java new file mode 100644 index 000000000..f67d4134e --- /dev/null +++ b/accessibility/workben/org/openoffice/accessibility/awb/view/ContextView.java @@ -0,0 +1,149 @@ +/************************************************************************* + * + * $RCSfile: ContextView.java,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: af $ $Date: 2003/06/13 16:30:32 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +package org.openoffice.accessibility.awb.view; + +import java.awt.Color; +import java.awt.Dimension; + +import java.awt.event.ActionListener; +import java.awt.event.ActionEvent; + +import javax.swing.JLabel; +import javax.swing.JTextField; + +import com.sun.star.accessibility.AccessibleEventId; +import com.sun.star.accessibility.AccessibleEventObject; +import com.sun.star.accessibility.XAccessibleContext; + +import org.openoffice.accessibility.misc.NameProvider; + +/** The <type>ContextView</type> class displays information accessible over + the <type>XAccessibleContext</type> interface. This includes name, + description, and role. +*/ +public class ContextView + extends ObjectView + implements ActionListener +{ + static public ObjectView Create ( + ObjectViewContainer aContainer, + XAccessibleContext xContext) + { + if (xContext != null) + return new ContextView (aContainer); + else + return null; + } + + public ContextView (ObjectViewContainer aContainer) + { + super (aContainer); + + ViewGridLayout aLayout = new ViewGridLayout (this); + maNameLabel = aLayout.AddLabeledString ("Name:"); + maDescriptionLabel = aLayout.AddLabeledString ("Description:"); + maRoleLabel = aLayout.AddLabeledEntry ("Role:"); + } + + public void Update () + { + if (mxContext == null) + { + maNameLabel.setText ("<null object>"); + maDescriptionLabel.setText ("<null object>"); + maRoleLabel.setText ("<null object>"); + } + else + { + maNameLabel.setText (mxContext.getAccessibleName()); + maDescriptionLabel.setText (mxContext.getAccessibleDescription()); + maRoleLabel.setText (NameProvider.getRoleName (mxContext.getAccessibleRole())); + } + } + + public String GetTitle () + { + return ("Context"); + } + + /** Listen for changes regarding displayed values. + */ + public void notifyEvent (AccessibleEventObject aEvent) + { + switch (aEvent.EventId) + { + case AccessibleEventId.NAME_CHANGED : + case AccessibleEventId.DESCRIPTION_CHANGED : + Update (); + } + } + + public void actionPerformed (ActionEvent aEvent) + { + } + + + private JLabel + maNameLabel, + maDescriptionLabel, + maRoleLabel; +} diff --git a/accessibility/workben/org/openoffice/accessibility/awb/view/EditableTextView.java b/accessibility/workben/org/openoffice/accessibility/awb/view/EditableTextView.java new file mode 100644 index 000000000..c8bade57d --- /dev/null +++ b/accessibility/workben/org/openoffice/accessibility/awb/view/EditableTextView.java @@ -0,0 +1,153 @@ +/************************************************************************* + * + * $RCSfile: EditableTextView.java,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: af $ $Date: 2003/06/13 16:30:33 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +package org.openoffice.accessibility.awb.view; + +import java.awt.event.ActionListener; +import java.awt.event.ActionEvent; +import javax.swing.JButton; + +import com.sun.star.accessibility.XAccessibleContext; +import com.sun.star.accessibility.XAccessibleEditableText; +import com.sun.star.uno.UnoRuntime; + +import org.openoffice.accessibility.awb.view.text.TextDialogFactory; + + +public class EditableTextView + extends ObjectView + implements ActionListener +{ + /** Create a EditableTextView when the given object supports the + XAccessibleEditableText interface. + */ + static public ObjectView Create ( + ObjectViewContainer aContainer, + XAccessibleContext xContext) + { + XAccessibleEditableText xEditableText = + (XAccessibleEditableText)UnoRuntime.queryInterface( + XAccessibleEditableText.class, xContext); + if (xEditableText != null) + return new EditableTextView (aContainer); + else + return null; + } + + public EditableTextView (ObjectViewContainer aContainer) + { + super (aContainer); + + JButton aButton = new JButton ("cut..."); + aButton.setFont (ViewGridLayout.GetFont()); + aButton.addActionListener (this); + add (aButton); + aButton = new JButton ("paste..."); + aButton.setFont (ViewGridLayout.GetFont()); + aButton.addActionListener (this); + add (aButton); + aButton = new JButton ("edit..."); + aButton.setFont (ViewGridLayout.GetFont()); + aButton.addActionListener (this); + add (aButton); + aButton = new JButton ("format..."); + aButton.setFont (ViewGridLayout.GetFont()); + aButton.addActionListener (this); + add (aButton); + } + + + /** Additionally to the context store a reference to the + XAccessibleEditableText interface. + */ + public void SetObject (XAccessibleContext xObject) + { + mxEditableText = (XAccessibleEditableText)UnoRuntime.queryInterface( + XAccessibleEditableText.class, xObject); + super.SetObject (xObject); + } + + public String GetTitle () + { + return ("Editable Text"); + } + + synchronized public void Destroy () + { + mxEditableText = null; + super.Destroy(); + } + + public void actionPerformed (ActionEvent aEvent) + { + String sCommand = aEvent.getActionCommand(); + if (sCommand.equals ("cut...")) + TextDialogFactory.CreateCutDialog (mxContext); + else if (sCommand.equals ("past...")) + TextDialogFactory.CreatePasteDialog (mxContext); + else if (sCommand.equals ("edit...")) + TextDialogFactory.CreateEditDialog (mxContext); + else if (sCommand.equals ("format...")) + TextDialogFactory.CreateFormatDialog (mxContext); + } + + private XAccessibleEditableText mxEditableText; +} diff --git a/accessibility/workben/org/openoffice/accessibility/awb/view/EventMonitorView.java b/accessibility/workben/org/openoffice/accessibility/awb/view/EventMonitorView.java new file mode 100644 index 000000000..e01f665b5 --- /dev/null +++ b/accessibility/workben/org/openoffice/accessibility/awb/view/EventMonitorView.java @@ -0,0 +1,158 @@ +/************************************************************************* + * + * $RCSfile: EventMonitorView.java,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: af $ $Date: 2003/06/13 16:30:33 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +package org.openoffice.accessibility.awb.view; + +import java.awt.BorderLayout; +import java.awt.GridBagLayout; +import java.awt.GridBagConstraints; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Font; +import java.awt.Graphics; +import javax.swing.JScrollBar; +import javax.swing.JScrollPane; +import javax.swing.JTextArea; + +import com.sun.star.accessibility.AccessibleEventId; +import com.sun.star.accessibility.AccessibleEventObject; +import com.sun.star.accessibility.XAccessibleContext; + +import org.openoffice.accessibility.misc.NameProvider; + + +/** A simple event monitor that shows all events sent to one accessible + object. +*/ +class EventMonitorView + extends ObjectView +{ + static public ObjectView Create ( + ObjectViewContainer aContainer, + XAccessibleContext xContext) + { + if (xContext != null) + return new EventMonitorView (aContainer); + else + return null; + } + + public EventMonitorView (ObjectViewContainer aContainer) + { + super (aContainer); + Layout(); + } + + public String GetTitle () + { + return "Event Monitor"; + } + + /** Create and arrange the widgets for this view. + */ + private void Layout () + { + setLayout (new GridBagLayout ()); + + maText = new JTextArea(); + maText.setBackground (new Color (255,250,240)); + maText.setFont (new Font ("Helvetica", Font.PLAIN, 9)); + + maScrollPane = new JScrollPane (maText, + JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, + JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); + maScrollPane.setPreferredSize (new Dimension (300,80)); + + GridBagConstraints aConstraints = new GridBagConstraints (); + aConstraints.weightx = 1; + aConstraints.fill = GridBagConstraints.HORIZONTAL; + add (maScrollPane, aConstraints); + } + + + public void Update () + { + } + + + private void UpdateVerticalScrollBar () + { + JScrollBar sb = maScrollPane.getVerticalScrollBar(); + if (sb != null) + { + int nScrollBarValue = sb.getMaximum() - sb.getVisibleAmount() - 1; + sb.setValue (nScrollBarValue); + } + } + + + public void notifyEvent (AccessibleEventObject aEvent) + { + maText.append (NameProvider.getEventName (aEvent.EventId) + " : " + + aEvent.OldValue.toString() + + " -> " + + aEvent.NewValue.toString() + "\n"); + UpdateVerticalScrollBar(); + } + + private JTextArea maText; + private JScrollPane maScrollPane; +} diff --git a/accessibility/workben/org/openoffice/accessibility/awb/view/FocusView.java b/accessibility/workben/org/openoffice/accessibility/awb/view/FocusView.java new file mode 100644 index 000000000..6f3f850ae --- /dev/null +++ b/accessibility/workben/org/openoffice/accessibility/awb/view/FocusView.java @@ -0,0 +1,182 @@ +/************************************************************************* + * + * $RCSfile: FocusView.java,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: af $ $Date: 2003/06/13 16:30:34 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +package org.openoffice.accessibility.awb.view; + +import java.awt.Font; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.event.ActionListener; +import java.awt.event.ActionEvent; + +import javax.swing.JButton; +import javax.swing.JLabel; + +import com.sun.star.accessibility.AccessibleEventId; +import com.sun.star.accessibility.AccessibleEventObject; +import com.sun.star.accessibility.AccessibleStateType; +import com.sun.star.accessibility.XAccessibleComponent; +import com.sun.star.accessibility.XAccessibleContext; +import com.sun.star.accessibility.XAccessibleStateSet; +import com.sun.star.uno.UnoRuntime; + +public class FocusView + extends ObjectView + implements ActionListener +{ + /** Create a FocusView when the given object supports the + XAccessibleComponent interface. + */ + static public ObjectView Create ( + ObjectViewContainer aContainer, + XAccessibleContext xContext) + { + XAccessibleComponent xComponent = (XAccessibleComponent)UnoRuntime.queryInterface( + XAccessibleComponent.class, xContext); + if (xComponent != null) + return new FocusView (aContainer); + else + return null; + } + + public FocusView (ObjectViewContainer aContainer) + { + super (aContainer); + + setLayout (new GridBagLayout()); + GridBagConstraints aConstraints = new GridBagConstraints (); + + maFocused = new JLabel (); + maFocused.setFont (GetContainer().GetViewFont()); + aConstraints.gridy = 0; + aConstraints.weightx = 1; + aConstraints.fill = GridBagConstraints.HORIZONTAL; + add (maFocused, aConstraints); + + maGrabFocus = new JButton ("grabFocus"); + maGrabFocus.setFont (GetContainer().GetViewFont()); + aConstraints.gridy = 1; + aConstraints.fill = GridBagConstraints.NONE; + aConstraints.anchor = GridBagConstraints.WEST; + add (maGrabFocus, aConstraints); + + maGrabFocus.addActionListener (this); + } + + /** Additionally to the context store a reference to the + XAccessibleComponent interface. + */ + public void SetObject (XAccessibleContext xObject) + { + mxComponent = (XAccessibleComponent)UnoRuntime.queryInterface( + XAccessibleComponent.class, xObject); + super.SetObject (xObject); + } + + synchronized public void Destroy () + { + super.Destroy(); + maGrabFocus.removeActionListener (this); + } + + synchronized public void Update () + { + if (mxContext == null) + { + maFocused.setText ("<null object>"); + maGrabFocus.setEnabled (false); + } + else + { + XAccessibleStateSet aStateSet = mxContext.getAccessibleStateSet(); + if (aStateSet.contains(AccessibleStateType.FOCUSED)) + maFocused.setText ("focused"); + else + maFocused.setText ("not focused"); + if (maGrabFocus != null) + maGrabFocus.setEnabled (true); + } + } + + public String GetTitle () + { + return ("Focus"); + } + + synchronized public void actionPerformed (ActionEvent aEvent) + { + if (aEvent.getActionCommand().equals("grabFocus")) + { + mxComponent.grabFocus(); + } + } + + public void notifyEvent (AccessibleEventObject aEvent) + { + System.out.println (aEvent); + if (aEvent.EventId == AccessibleEventId.STATE_CHANGED) + Update (); + } + + private JLabel maFocused; + private JButton maGrabFocus; + private XAccessibleComponent mxComponent; +} diff --git a/accessibility/workben/org/openoffice/accessibility/awb/view/LayoutManager.java b/accessibility/workben/org/openoffice/accessibility/awb/view/LayoutManager.java new file mode 100644 index 000000000..590d17c94 --- /dev/null +++ b/accessibility/workben/org/openoffice/accessibility/awb/view/LayoutManager.java @@ -0,0 +1,194 @@ +/************************************************************************* + * + * $RCSfile: LayoutManager.java,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: af $ $Date: 2003/06/13 16:30:34 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +package org.openoffice.accessibility.awb.view; + +import java.awt.Component; +import java.awt.Cursor; +import java.awt.GridBagLayout; +import java.awt.GridBagConstraints; +import java.awt.Point; +import java.awt.event.MouseListener; +import java.awt.event.MouseMotionListener; +import java.awt.event.MouseEvent; +import javax.swing.JComponent; + +class LayoutManager + implements MouseListener, + MouseMotionListener +{ + public LayoutManager (JComponent aLayoutedComponent) + { + maLayoutedComponent = aLayoutedComponent; + maDraggedView = null; + mbInsertionPending = false; + } + + public void mouseClicked (MouseEvent aEvent) + { + System.out.println (aEvent); + } + public void mousePressed (MouseEvent aEvent) + { + mnOldY = aEvent.getPoint().y; + } + public void mouseReleased (MouseEvent aEvent) + { + if (mbInsertionPending) + { + InsertView (maDraggedView, aEvent.getPoint().y); + mbInsertionPending = false; + maDraggedView = null; + } + } + public void mouseEntered (MouseEvent aEvent) + { + } + public void mouseExited (MouseEvent aEvent) + { + if (mbInsertionPending) + { + InsertView (maDraggedView, mnOldY); + mbInsertionPending = false; + maDraggedView = null; + } + } + public void mouseDragged (MouseEvent aEvent) + { + int dy = mnOldY - aEvent.getPoint().y; + GridBagLayout aLayout = (GridBagLayout)maLayoutedComponent.getLayout(); + if ( ! mbInsertionPending && dy != 0) + { + maDraggedView = RemoveView (mnOldY); + if (maDraggedView != null) + mbInsertionPending = true; + } + } + public void mouseMoved (MouseEvent aEvent) + { + } + + + + + private ObjectView RemoveView (int y) + { + ObjectView aView = null; + GridBagLayout aLayout = (GridBagLayout)maLayoutedComponent.getLayout(); + + Point aGridLocation = aLayout.location (10,y); + Component[] aComponentList = maLayoutedComponent.getComponents(); + System.out.println ("removing view at " + aGridLocation); + for (int i=0; i<aComponentList.length && aView==null; i++) + { + GridBagConstraints aConstraints = aLayout.getConstraints ( + aComponentList[i]); + if (aConstraints.gridy == aGridLocation.y) + aView = (ObjectView)aComponentList[i]; + } + maNormalCursor = maLayoutedComponent.getCursor(); + if (aView != null) + { + System.out.println ("removing view at " + aGridLocation.y); + maLayoutedComponent.setCursor (new Cursor (Cursor.MOVE_CURSOR)); + maLayoutedComponent.remove (aView); + maLayoutedComponent.validate(); + maLayoutedComponent.repaint(); + } + + return aView; + } + + private void InsertView (ObjectView aView, int y) + { + if (aView != null) + { + GridBagLayout aLayout = (GridBagLayout)maLayoutedComponent.getLayout(); + Point aGridLocation = aLayout.location (0,y); + Component[] aComponentList = maLayoutedComponent.getComponents(); + System.out.println ("new position is " + aGridLocation.y); + for (int i=0; i<aComponentList.length; i++) + { + GridBagConstraints aConstraints = aLayout.getConstraints ( + aComponentList[i]); + if (aConstraints.gridy >= aGridLocation.y) + { + if (aConstraints.gridy == aGridLocation.y) + maLayoutedComponent.add (maDraggedView, aConstraints); + aConstraints.gridy += 1; + aLayout.setConstraints (aComponentList[i], aConstraints); + } + } + maLayoutedComponent.validate(); + maLayoutedComponent.repaint(); + } + maLayoutedComponent.setCursor (maNormalCursor); + } + + + + + private JComponent maLayoutedComponent; + private ObjectView maDraggedView; + private int mnOldY; + private boolean mbInsertionPending; + private Cursor maNormalCursor; +} diff --git a/accessibility/workben/org/openoffice/accessibility/awb/view/Makefile b/accessibility/workben/org/openoffice/accessibility/awb/view/Makefile new file mode 100644 index 000000000..2e4eb1566 --- /dev/null +++ b/accessibility/workben/org/openoffice/accessibility/awb/view/Makefile @@ -0,0 +1,13 @@ +# $Id: Makefile,v 1.1 2003/06/13 16:30:34 af Exp $ + +all : package + +ROOT=../../../../.. +PACKAGE = org.openoffice.accessibility.awb.view +SUBDIRS = text +include makefile.common + +include $(ROOT)/makefile.in + + +package : $(CLASS_FILES) diff --git a/accessibility/workben/org/openoffice/accessibility/awb/view/ObjectView.java b/accessibility/workben/org/openoffice/accessibility/awb/view/ObjectView.java new file mode 100644 index 000000000..ada74f6db --- /dev/null +++ b/accessibility/workben/org/openoffice/accessibility/awb/view/ObjectView.java @@ -0,0 +1,90 @@ +package org.openoffice.accessibility.awb.view; + +import javax.swing.JPanel; + +import com.sun.star.accessibility.AccessibleEventObject; +import com.sun.star.accessibility.XAccessibleContext; + +/** This is the base class for all object views that can be placed inside an + object view container. + + <p>When provided with a new accessible object the container will call + the Create method to create a new instance when certain conditions are + met. It then calls SetObject to pass the object to the instance. + Finally it calls Update.</p> + + <p>The SetObject and Update methods may be called for a new object + without calling Create first. In this way an existing instance is + recycled.</p> +*/ +abstract public class ObjectView + extends JPanel +{ + /** This factory method creates a new instance of the (derived) class + when the given accessible object supports all necessary features. + In the ususal case this will be the support of a specific + accessibility interface. + */ + static public ObjectView Create ( + ObjectViewContainer aContainer, + XAccessibleContext xContext) + { + return null; + } + + public ObjectView (ObjectViewContainer aContainer) + { + maContainer = aContainer; + mxContext = null; + } + + /** Call this when you want the object to be destroyed. Release all + resources when called. + */ + public void Destroy () + { + } + + /** Tell the view to display information for a new accessible object. + @param xObject + The given object may be null. A typical behaviour in this case + would be to display a blank area. But is also possible to show + information about the last object. + */ + public void SetObject (XAccessibleContext xContext) + { + mxContext = xContext; + Update (); + } + + + /** This is a request of a repaint with the current state of the current + object. The current object may or may not be the same as the one + when Update() was called the last time. + */ + public void Update () + { + } + + + /** Return a string that is used as a title of an enclosing frame. + */ + abstract public String GetTitle (); + + + public ObjectViewContainer GetContainer () + { + return maContainer; + } + + + /** Implement this method if you are interested in accessible events. + */ + public void notifyEvent (AccessibleEventObject aEvent) + {} + + /// Reference to the current object to display information about. + protected XAccessibleContext mxContext; + + protected ObjectViewContainer maContainer; +} diff --git a/accessibility/workben/org/openoffice/accessibility/awb/view/ObjectViewContainer.java b/accessibility/workben/org/openoffice/accessibility/awb/view/ObjectViewContainer.java new file mode 100644 index 000000000..157025b72 --- /dev/null +++ b/accessibility/workben/org/openoffice/accessibility/awb/view/ObjectViewContainer.java @@ -0,0 +1,344 @@ +/************************************************************************* + * + * $RCSfile: ObjectViewContainer.java,v $ + * + * $Revision: 1.2 $ + * + * last change: $Author: obr $ $Date: 2003/09/19 09:21:42 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +package org.openoffice.accessibility.awb.view; + +import java.awt.Color; +import java.awt.Component; +import java.awt.Font; +import java.awt.GridBagLayout; +import java.awt.GridBagConstraints; +import java.awt.Insets; + +import java.util.Vector; + +import java.lang.reflect.Method; +import java.lang.NoSuchMethodException; +import java.lang.IllegalAccessException; +import java.lang.reflect.InvocationTargetException; + +import javax.swing.JPanel; +import javax.swing.JTree; +import javax.swing.BorderFactory; +import javax.swing.border.Border; +import javax.swing.border.BevelBorder; +import javax.swing.SwingUtilities; + +import com.sun.star.accessibility.AccessibleEventObject; +import com.sun.star.accessibility.XAccessibleContext; +import com.sun.star.accessibility.XAccessibleComponent; +import com.sun.star.accessibility.XAccessibleEventBroadcaster; +import com.sun.star.accessibility.XAccessibleEventListener; +import com.sun.star.accessibility.XAccessibleSelection; +import com.sun.star.lang.EventObject; +import com.sun.star.uno.UnoRuntime; + +import org.openoffice.accessibility.awb.view.ObjectView; + + + +/** This container of specialized object views displays information about + one accessible object. + In this it plays several roles: + 1. Object container. + 2. Accessibility event dispatcher. + 3. Object view class registration manager. + 4. Swing widget. +*/ +public class ObjectViewContainer + extends JPanel + implements XAccessibleEventListener +{ + public ObjectViewContainer () + { + maFont = new Font ("Dialog", Font.PLAIN, 11); + maViewTemplates = new Vector (); + maViewBorder = BorderFactory.createBevelBorder (BevelBorder.RAISED); + GridBagLayout aLayout = new GridBagLayout (); + setLayout (aLayout); + // maLayoutManager = new LayoutManager (this); + maLayoutManager = null; + + RegisterView (ContextView.class); + RegisterView (ComponentView.class); + RegisterView (ParentView.class); + RegisterView (StateSetView.class); + RegisterView (FocusView.class); + RegisterView (TextView.class); + RegisterView (EditableTextView.class); + RegisterView (TableView.class); + RegisterView (SelectionView.class); + RegisterView (ServiceInterfaceView.class); + RegisterView (EventMonitorView.class); + + mxContext = null; + + // addMouseListener (maLayoutManager); + // addMouseMotionListener (maLayoutManager); + } + + + + /** Remove all existing views and create new ones according to the + interfaces supported by the given object. + */ + public synchronized void SetObject (XAccessibleContext xContext) + { + // Call Destroy at all views to give them a chance to release their + // resources. + int n = getComponentCount(); + for (int i=0; i<n; i++) + ((ObjectView)getComponent(i)).Destroy(); + // Remove existing views. + removeAll (); + + mxContext = xContext; + + // Add new views. + for (int i=0; i<maViewTemplates.size(); i++) + { + try + { + Class aViewClass = (Class)maViewTemplates.elementAt (i); + Method aCreateMethod = aViewClass.getDeclaredMethod ( + "Create", new Class[] { + ObjectViewContainer.class, + XAccessibleContext.class}); + if (aCreateMethod != null) + { + ObjectView aView = (ObjectView) + aCreateMethod.invoke ( + null, new Object[] {this, xContext}); + Add (aView); + } + } + catch (NoSuchMethodException e) + {System.err.println ("Caught exception while creating view " + + i + " : " + e);} + catch (IllegalAccessException e) + {System.err.println ("Caught exception while creating view " + + i + " : " + e);} + catch (InvocationTargetException e) + {System.err.println ("Caught exception while creating view " + + i + " : " + e);} + } + + UpdateLayoutManager (); + + // Now set the object at all views. + n = getComponentCount(); + for (int i=0; i<n; i++) + ((ObjectView)getComponent(i)).SetObject (xContext); + + setPreferredSize (getLayout().preferredLayoutSize (this)); + ((GridBagLayout) getLayout()).invalidateLayout(this); + validate(); + } + + + + + /** Add the given class to the list of classes which will be + instantiated the next time an accessible object is set. + */ + public void RegisterView (Class aObjectViewClass) + { + maViewTemplates.addElement (aObjectViewClass); + } + + + + + /** Replace one view class with another. + */ + public void ReplaceView (Class aObjectViewClass, Class aSubstitution) + { + int nIndex = maViewTemplates.indexOf (aObjectViewClass); + if (nIndex >= 0) + maViewTemplates.setElementAt (aSubstitution, nIndex); + } + + + /** Return a font that should be used for widgets in the views. + */ + public Font GetViewFont () + { + return maFont; + } + + public Color GetErrorColor () + { + return new Color (255,80,50); + } + + /** Add an object view and place it below all previously added views. + @param aView + This argument may be null. In this case nothing happens. + */ + private void Add (ObjectView aView) + { + if (aView != null) + { + GridBagConstraints constraints = new GridBagConstraints (); + constraints.gridx = 0; + constraints.gridy = getComponentCount(); + constraints.gridwidth = 1; + constraints.gridheight = 1; + constraints.weightx = 1; + constraints.weighty = 0; + constraints.ipadx = 2; + constraints.ipady = 5; + constraints.insets = new Insets (5,5,5,5); + constraints.anchor = GridBagConstraints.NORTH; + constraints.fill = GridBagConstraints.HORIZONTAL; + + aView.setBorder ( + BorderFactory.createTitledBorder ( + maViewBorder, aView.GetTitle())); + + add (aView, constraints); + } + } + + /** Update the layout manager by setting the vertical weight of the + bottom entry to 1 and so make it strech to over the available + space. + + */ + private void UpdateLayoutManager () + { + // Adapt the layout manager. + if (getComponentCount() > 1000) + { + Component aComponent = getComponent (getComponentCount()-1); + GridBagLayout aLayout = (GridBagLayout)getLayout(); + GridBagConstraints aConstraints = aLayout.getConstraints (aComponent); + aConstraints.weighty = 1; + aLayout.setConstraints (aComponent, aConstraints); + } + } + + + + + /** Put the event just received into the event queue which will deliver + it soon asynchronuously to the DispatchEvent method. + */ + public void notifyEvent (final AccessibleEventObject aEvent) + { + SwingUtilities.invokeLater( + new Runnable() + { + public void run() + { + DispatchEvent (aEvent); + } + } + ); + } + + + + + /** Forward accessibility events to all views without them being + registered as event listeners each on their own. + */ + private void DispatchEvent (AccessibleEventObject aEvent) + { + int n = getComponentCount(); + for (int i=0; i<n; i++) + ((ObjectView)getComponent(i)).notifyEvent (aEvent); + } + + + + /** When the object is disposed that is displayed by the views of this + container then tell all views about this. + */ + public void disposing (EventObject aEvent) + { + mxContext = null; + SwingUtilities.invokeLater( + new Runnable() + { + public void run() + { + SetObject (null); + } + } + ); + } + + + + + /// The current accessible context display by the views. + private XAccessibleContext mxContext; + + /// Observe this tree for selection changes and notify them to all + /// children. + private JTree maTree; + private Border maViewBorder; + /// List of view templates which are instantiated when new object is set. + private Vector maViewTemplates; + private Font maFont; + private LayoutManager maLayoutManager; +} diff --git a/accessibility/workben/org/openoffice/accessibility/awb/view/ObjectViewContainerWindow.java b/accessibility/workben/org/openoffice/accessibility/awb/view/ObjectViewContainerWindow.java new file mode 100644 index 000000000..8db9af4f4 --- /dev/null +++ b/accessibility/workben/org/openoffice/accessibility/awb/view/ObjectViewContainerWindow.java @@ -0,0 +1,35 @@ +package org.openoffice.accessibility.awb.view; + +import java.awt.BorderLayout; +import javax.swing.JFrame; +import com.sun.star.accessibility.XAccessibleContext; + + +/** Top level window that creates a single object view container. This + container shows information about a specific accessible object and is + not affected by the selection of the accessbility tree widget. +*/ +public class ObjectViewContainerWindow + extends JFrame +{ + public ObjectViewContainerWindow (XAccessibleContext xContext) + { + setSize (new java.awt.Dimension (300,600)); + + maContainer = new ObjectViewContainer (); + maContainer.SetObject (xContext); + getContentPane().add (maContainer, BorderLayout.CENTER); + + pack (); + setVisible (true); + } + + /** Set the object that is displayed in this window. + */ + public void SetObject (XAccessibleContext xContext) + { + maContainer.SetObject (xContext); + } + + private ObjectViewContainer maContainer; +} diff --git a/accessibility/workben/org/openoffice/accessibility/awb/view/ParentView.java b/accessibility/workben/org/openoffice/accessibility/awb/view/ParentView.java new file mode 100644 index 000000000..bb0784324 --- /dev/null +++ b/accessibility/workben/org/openoffice/accessibility/awb/view/ParentView.java @@ -0,0 +1,181 @@ +/************************************************************************* + * + * $RCSfile: ParentView.java,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: af $ $Date: 2003/06/13 16:30:36 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +package org.openoffice.accessibility.awb.view; + +import java.awt.Color; +import java.awt.Dimension; +import java.awt.GridBagLayout; +import java.awt.GridBagConstraints; +import java.lang.Integer; +import javax.swing.JLabel; +import javax.swing.JTextField; + +import com.sun.star.accessibility.AccessibleEventId; +import com.sun.star.accessibility.AccessibleEventObject; +import com.sun.star.accessibility.XAccessible; +import com.sun.star.accessibility.XAccessibleContext; +import com.sun.star.lang.IndexOutOfBoundsException; + +import org.openoffice.accessibility.misc.NameProvider; + + +/** Show informations related to the parent/child relationship. +*/ +public class ParentView + extends ObjectView +{ + static public ObjectView Create ( + ObjectViewContainer aContainer, + XAccessibleContext xContext) + { + if (xContext != null) + return new ParentView (aContainer); + else + return null; + } + + public ParentView (ObjectViewContainer aContainer) + { + super (aContainer); + + ViewGridLayout aLayout = new ViewGridLayout (this); + maParentLabel = aLayout.AddLabeledEntry ("Has parent: "); + maIndexLabel = aLayout.AddLabeledEntry ("Index in parent: "); + maValidLabel = aLayout.AddLabeledEntry ("Parent/Child relationship valid: "); + maChildrenLabel = aLayout.AddLabeledEntry ("Child count: "); + } + + public void Update () + { + if (mxContext == null) + { + maParentLabel.setText ("<null object>"); + maIndexLabel.setText ("<null object>"); + maValidLabel.setText ("<null object>"); + maChildrenLabel.setText ("<null object>"); + } + else + { + XAccessible xParent = mxContext.getAccessibleParent(); + int nIndex = mxContext.getAccessibleIndexInParent(); + maIndexLabel.setText (Integer.toString(nIndex)); + if (xParent != null) + { + maParentLabel.setText ("yes"); + XAccessibleContext xParentContext = + xParent.getAccessibleContext(); + if (xParentContext != null) + { + try + { + XAccessible xChild = + xParentContext.getAccessibleChild(nIndex); + if (xChild != mxContext) + maValidLabel.setText ("yes"); + else + { + maValidLabel.setText ("no"); + maValidLabel.setBackground (GetContainer().GetErrorColor()); + } + } + catch (IndexOutOfBoundsException e) + { + maValidLabel.setText ("no: invalid index in parent"); + maValidLabel.setBackground (GetContainer().GetErrorColor()); + } + } + else + { + maValidLabel.setText ("no: parent has no context"); + maValidLabel.setBackground (GetContainer().GetErrorColor()); + } + } + else + maParentLabel.setText ("no"); + maChildrenLabel.setText (Integer.toString(mxContext.getAccessibleChildCount())); + } + } + + public String GetTitle () + { + return ("Parent"); + } + + + /** Listen for changes regarding displayed values. + */ + public void notifyEvent (AccessibleEventObject aEvent) + { + switch (aEvent.EventId) + { + default: + Update (); + } + } + + + private JLabel + maParentLabel, + maIndexLabel, + maValidLabel, + maChildrenLabel; +} diff --git a/accessibility/workben/org/openoffice/accessibility/awb/view/SelectionView.java b/accessibility/workben/org/openoffice/accessibility/awb/view/SelectionView.java new file mode 100644 index 000000000..318db97f5 --- /dev/null +++ b/accessibility/workben/org/openoffice/accessibility/awb/view/SelectionView.java @@ -0,0 +1,301 @@ +/************************************************************************* + * + * $RCSfile: SelectionView.java,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: af $ $Date: 2003/06/13 16:30:36 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +package org.openoffice.accessibility.awb.view; + +import java.util.Vector; + +import java.awt.event.ActionListener; +import java.awt.event.ActionEvent; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.GridBagLayout; +import java.awt.GridBagConstraints; + +import javax.swing.BoxLayout; +import javax.swing.ButtonGroup; +import javax.swing.JButton; +import javax.swing.JCheckBox; +import javax.swing.JLabel; +import javax.swing.JList; +import javax.swing.JPanel; +import javax.swing.JOptionPane; +import javax.swing.JRadioButton; +import javax.swing.JScrollPane; +import javax.swing.JToggleButton; +import javax.swing.ListSelectionModel; + + +import com.sun.star.accessibility.AccessibleEventId; +import com.sun.star.accessibility.AccessibleEventObject; +import com.sun.star.accessibility.AccessibleRole; +import com.sun.star.accessibility.AccessibleStateType; +import com.sun.star.accessibility.XAccessible; +import com.sun.star.accessibility.XAccessibleContext; +import com.sun.star.accessibility.XAccessibleSelection; +import com.sun.star.accessibility.XAccessibleStateSet; + +import com.sun.star.uno.UnoRuntime; +import com.sun.star.lang.IndexOutOfBoundsException; + + +/** Display a list of children and select/deselect buttons +*/ +class SelectionView + extends ObjectView + implements ActionListener +{ + static public ObjectView Create ( + ObjectViewContainer aContainer, + XAccessibleContext xContext) + { + XAccessibleSelection xSelection = (XAccessibleSelection)UnoRuntime.queryInterface( + XAccessibleSelection.class, xContext); + if (xSelection != null) + return new SelectionView(aContainer); + else + return null; + } + + public SelectionView (ObjectViewContainer aContainer) + { + super (aContainer); + Layout(); + } + + public String GetTitle () + { + return "Selection"; + } + + /** Create and arrange the widgets for this view. + */ + private void Layout () + { + setLayout (new GridBagLayout()); + + GridBagConstraints aConstraints = new GridBagConstraints(); + + // Label that shows whether the selection is multi selectable. + aConstraints.gridx = 0; + aConstraints.gridy = 0; + aConstraints.anchor = GridBagConstraints.WEST; + maTypeLabel = new JLabel (); + maTypeLabel.setFont (maContainer.GetViewFont()); + add (maTypeLabel, aConstraints); + + // the JListBox + maChildrenSelector = new JPanel (); + maChildrenSelector.setPreferredSize (new Dimension (100,100)); + maChildrenSelector.setLayout ( + new BoxLayout (maChildrenSelector, BoxLayout.Y_AXIS)); + + aConstraints.gridx = 0; + aConstraints.gridwidth = 4; + aConstraints.gridy = 1; + aConstraints.fill = GridBagConstraints.HORIZONTAL; + add (new JScrollPane (maChildrenSelector, + JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, + JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED), + aConstraints); + + JButton aButton; + aButton = new JButton( "Select all" ); + aButton.setFont (maContainer.GetViewFont()); + aButton.setActionCommand( "Select all" ); + aButton.addActionListener( this ); + aConstraints.gridx = 0; + aConstraints.gridwidth = 1; + aConstraints.gridy = 2; + aConstraints.fill = GridBagConstraints.NONE; + aConstraints.anchor = GridBagConstraints.WEST; + add (aButton, aConstraints); + + aButton = new JButton( "Clear Selection" ); + aButton.setFont (maContainer.GetViewFont()); + aButton.setActionCommand( "Clear Selection" ); + aButton.addActionListener( this ); + aConstraints.gridx = 1; + aConstraints.gridy = 2; + aConstraints.weightx = 1; + add (aButton, aConstraints); + + setSize (getPreferredSize()); + } + + + public void SetObject (XAccessibleContext xContext) + { + mxSelection = (XAccessibleSelection)UnoRuntime.queryInterface( + XAccessibleSelection.class, xContext); + super.SetObject (xContext); + } + + + public void Update () + { + maChildrenSelector.removeAll (); + + // Determine whether multi selection is possible. + XAccessibleStateSet aStateSet = mxContext.getAccessibleStateSet(); + boolean bMultiSelectable = false; + if (aStateSet!=null && aStateSet.contains( + AccessibleStateType.MULTI_SELECTABLE)) + { + bMultiSelectable = true; + maTypeLabel.setText ("multi selectable"); + } + else + { + maTypeLabel.setText ("single selectable"); + } + + if (mxContext.getAccessibleRole() != AccessibleRole.TABLE) + { + int nCount = mxContext.getAccessibleChildCount(); + for (int i=0; i<nCount; i++) + { + try + { + XAccessible xChild = mxContext.getAccessibleChild(i); + XAccessibleContext xChildContext = xChild.getAccessibleContext(); + + String sName = i + " " + xChildContext.getAccessibleName(); + JToggleButton aChild; + aChild = new JCheckBox (sName); + aChild.setFont (maContainer.GetViewFont()); + + XAccessibleStateSet aChildStateSet = + mxContext.getAccessibleStateSet(); + aChild.setSelected (aChildStateSet!=null + && aChildStateSet.contains(AccessibleStateType.SELECTED)); + + aChild.addActionListener (this); + maChildrenSelector.add (aChild); + + } + catch (IndexOutOfBoundsException e) + { + } + } + } + } + + + void SelectAll() + { + mxSelection.selectAllAccessibleChildren(); + } + + void ClearSelection() + { + mxSelection.clearAccessibleSelection(); + } + + + + /** Call the function associated with the pressed button. + */ + public void actionPerformed (ActionEvent aEvent) + { + String sCommand = aEvent.getActionCommand(); + + if (sCommand.equals ("Clear Selection")) + ClearSelection(); + else if (sCommand.equals ("Select all")) + SelectAll(); + else + { + // Extract the child index from the widget text. + String[] aWords = sCommand.split (" "); + int nIndex = Integer.parseInt(aWords[0]); + try + { + if (((JToggleButton)aEvent.getSource()).isSelected()) + mxSelection.selectAccessibleChild (nIndex); + else + mxSelection.deselectAccessibleChild (nIndex); + } + catch (IndexOutOfBoundsException e) + { + System.err.println ( + "caught exception while changing selection: " + e); + } + } + } + + + public void notifyEvent (AccessibleEventObject aEvent) + { + switch (aEvent.EventId) + { + case AccessibleEventId.SELECTION_CHANGED: + case AccessibleEventId.STATE_CHANGED: + case AccessibleEventId.CHILD: + Update (); + } + } + + private JPanel maChildrenSelector; + private XAccessibleSelection mxSelection; + private JLabel maTypeLabel; +} diff --git a/accessibility/workben/org/openoffice/accessibility/awb/view/ServiceInterfaceView.java b/accessibility/workben/org/openoffice/accessibility/awb/view/ServiceInterfaceView.java new file mode 100644 index 000000000..a6292d00b --- /dev/null +++ b/accessibility/workben/org/openoffice/accessibility/awb/view/ServiceInterfaceView.java @@ -0,0 +1,150 @@ +package org.openoffice.accessibility.awb.view; + +import java.awt.GridLayout; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.GridBagLayout; +import java.awt.GridBagConstraints; +import java.lang.Integer; +import javax.swing.JScrollPane; +import javax.swing.JTree; +import javax.swing.tree.DefaultMutableTreeNode; +import javax.swing.tree.DefaultTreeModel; + +import com.sun.star.accessibility.AccessibleEventId; +import com.sun.star.accessibility.AccessibleEventObject; +import com.sun.star.accessibility.XAccessible; +import com.sun.star.accessibility.XAccessibleContext; +import com.sun.star.lang.IndexOutOfBoundsException; +import com.sun.star.lang.XServiceInfo; +import com.sun.star.lang.XTypeProvider; +import com.sun.star.uno.Type; +import com.sun.star.uno.UnoRuntime; + +import org.openoffice.accessibility.misc.NameProvider; + + +/** Show all supported services and interfaces. +*/ +public class ServiceInterfaceView + extends ObjectView +{ + static public ObjectView Create ( + ObjectViewContainer aContainer, + XAccessibleContext xContext) + { + if (xContext != null) + return new ServiceInterfaceView (aContainer); + else + return null; + } + + + + + public ServiceInterfaceView (ObjectViewContainer aContainer) + { + super (aContainer); + + maImplementationNameRoot = new DefaultMutableTreeNode ("Implementation Name"); + maServiceRoot = new DefaultMutableTreeNode ("Supported Services"); + maInterfaceRoot = new DefaultMutableTreeNode ("Supported Interfaces"); + maTree = new JTree (new DefaultMutableTreeNode[] + {maServiceRoot,maInterfaceRoot}); + JScrollPane aScrollPane = new JScrollPane ( + maTree, + JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, + JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); + + setMinimumSize (new Dimension(300,200)); + setLayout (new GridLayout (1,1)); + add (aScrollPane); + } + + + + + public void Update () + { + DefaultTreeModel aModel = (DefaultTreeModel)maTree.getModel(); + + // Clear old tree. + DefaultMutableTreeNode aRoot =(DefaultMutableTreeNode)aModel.getRoot(); + aRoot.removeAllChildren(); + + // Create the new tree. + CreateImplementationNameTree (); + CreateServiceTree (); + CreateInterfaceTree (); + aRoot.add (maImplementationNameRoot); + aRoot.add (maServiceRoot); + aRoot.add (maInterfaceRoot); + aModel.setRoot (aRoot); + + // Expand whole tree. + for (int i=0; i<maTree.getRowCount(); i++) + maTree.expandRow (i); + } + + private void CreateImplementationNameTree () + { + XServiceInfo xServiceInfo = (XServiceInfo)UnoRuntime.queryInterface( + XServiceInfo.class, mxContext); + maImplementationNameRoot.removeAllChildren(); + if (xServiceInfo != null) + { + maImplementationNameRoot.add ( + new DefaultMutableTreeNode ( + (xServiceInfo!=null + ? xServiceInfo.getImplementationName() + : "<XServiceInfo not supported>"))); + } + } + + private void CreateServiceTree () + { + XServiceInfo xServiceInfo = (XServiceInfo)UnoRuntime.queryInterface( + XServiceInfo.class, mxContext); + maServiceRoot.removeAllChildren(); + if (xServiceInfo != null) + { + String[] aServiceNames = xServiceInfo.getSupportedServiceNames(); + int nCount = aServiceNames.length; + for (int i=0; i<nCount; i++) + maServiceRoot.add ( + new DefaultMutableTreeNode (aServiceNames[i])); + } + else + maServiceRoot.add ( + new DefaultMutableTreeNode("XServiceInfo not supported")); + } + + private void CreateInterfaceTree () + { + XTypeProvider xTypeProvider = (XTypeProvider)UnoRuntime.queryInterface( + XTypeProvider.class, mxContext); + maInterfaceRoot.removeAllChildren(); + if (xTypeProvider != null) + { + Type[] aTypes = xTypeProvider.getTypes(); + int nCount = aTypes.length; + for (int i=0; i<nCount; i++) + maInterfaceRoot.add ( + new DefaultMutableTreeNode (aTypes[i].getTypeName())); + } + else + maInterfaceRoot.add ( + new DefaultMutableTreeNode("XTypeProvider not supported")); + } + + public String GetTitle () + { + return ("Supported Services and Interfaces"); + } + + + private JTree maTree; + private DefaultMutableTreeNode maImplementationNameRoot; + private DefaultMutableTreeNode maServiceRoot; + private DefaultMutableTreeNode maInterfaceRoot; +} diff --git a/accessibility/workben/org/openoffice/accessibility/awb/view/StateSetView.java b/accessibility/workben/org/openoffice/accessibility/awb/view/StateSetView.java new file mode 100644 index 000000000..438bd58e8 --- /dev/null +++ b/accessibility/workben/org/openoffice/accessibility/awb/view/StateSetView.java @@ -0,0 +1,233 @@ +/************************************************************************* + * + * $RCSfile: StateSetView.java,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: af $ $Date: 2003/06/13 16:30:37 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +package org.openoffice.accessibility.awb.view; + +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.Insets; +import java.awt.Rectangle; +import java.awt.RenderingHints; +import java.awt.geom.AffineTransform; + + + +import com.sun.star.accessibility.AccessibleEventObject; +import com.sun.star.accessibility.AccessibleEventId; +import com.sun.star.accessibility.AccessibleStateType; +import com.sun.star.accessibility.XAccessibleContext; +import com.sun.star.accessibility.XAccessibleStateSet; + +import org.openoffice.accessibility.misc.NameProvider; + +public class StateSetView + extends ObjectView +{ + /** Create a FocusView when the given object supports the + XAccessibleComponent interface. + */ + static public ObjectView Create ( + ObjectViewContainer aContainer, + XAccessibleContext xContext) + { + ObjectView aView = null; + if (xContext != null) + aView = new StateSetView (aContainer); + + return aView; + } + + public StateSetView (ObjectViewContainer aContainer) + { + super (aContainer); + setPreferredSize (new Dimension(300,110)); + setMinimumSize (new Dimension(200,80)); + } + + public String GetTitle () + { + return ("StateSet"); + } + + public void notifyEvent (AccessibleEventObject aEvent) + { + if (aEvent.EventId == AccessibleEventId.STATE_CHANGED) + Update(); + } + + + public void Update () + { + repaint (); + } + + public void paintChildren (Graphics g) + { + if (g != null) + synchronized (g) + { + super.paintChildren (g); + + // Calculcate the are inside the border. + Insets aInsets = getInsets (); + Dimension aSize = getSize(); + Rectangle aWidgetArea = new Rectangle ( + aInsets.left, + aInsets.top, + aSize.width-aInsets.left-aInsets.right, + aSize.height-aInsets.top-aInsets.bottom); + + PaintAllStates ((Graphics2D)g, aWidgetArea); + } + } + + private void PaintAllStates (Graphics2D g, Rectangle aWidgetArea) + { + Color aTextColor = g.getColor(); + + g.setRenderingHint ( + RenderingHints.KEY_ANTIALIASING, + RenderingHints.VALUE_ANTIALIAS_ON); + + XAccessibleStateSet xStateSet = ( mxContext != null ) ? mxContext.getAccessibleStateSet() : null; + if (xStateSet != null) + { + short aStates[] = xStateSet.getStates (); + final int nMaxStateIndex = AccessibleStateType.VISIBLE;//MANAGES_DESCENDANTS; + int nStateWidth = (aWidgetArea.width-12) / (nMaxStateIndex+1); + AffineTransform aTransform = g.getTransform (); + g.setColor (aTextColor); + int y = aWidgetArea.y+aWidgetArea.height - 25; + double nTextRotation = -0.9;//-java.lang.Math.PI/2; + double nScale = 0.6; + + // Create a shape for the boxes. + int nBoxWidth = 8; + Rectangle aCheckBox = new Rectangle (-nBoxWidth/2,0,nBoxWidth,nBoxWidth); + + // For each state draw a box, fill it appropriately, and draw + // thre states name. + for (short i=0; i<=nMaxStateIndex; i++) + { + int x = nStateWidth + i * nStateWidth; + String sStateName = NameProvider.getStateName (i); + if (sStateName == null) + sStateName = new String ("<unknown state " + i + ">"); + boolean bStateSet = xStateSet.contains (i); + g.setTransform (aTransform); + g.translate (x,y); + if (bStateSet) + { + switch (i) + { + case AccessibleStateType.INVALID: + case AccessibleStateType.DEFUNC: + g.setColor (saInvalidColor); + break; + case AccessibleStateType.FOCUSED: + g.setColor (saFocusColor); + break; + case AccessibleStateType.SELECTED: + g.setColor (saSelectionColor); + break; + case AccessibleStateType.EDITABLE: + g.setColor (saEditColor); + break; + default: + g.setColor (saDefaultColor); + break; + } + g.fill (aCheckBox); + g.setColor (aTextColor); + } + g.draw (aCheckBox); + g.rotate (nTextRotation); + g.scale (nScale, nScale); + g.translate (2,-2); + g.drawString (sStateName, 0,0); + } + + // Draw string of set states. + String sStates = new String (); + for (int i=0; i<aStates.length; i++) + { + if (i > 0) + sStates = sStates + ", "; + sStates = sStates + NameProvider.getStateName(aStates[i]); + } + g.setTransform (aTransform); + g.translate (10,aWidgetArea.y+aWidgetArea.height-3); + g.scale (0.9,0.9); + g.drawString (sStates,0,0); + } + } + + static private Color + saInvalidColor = new Color (255,0,255), + saFocusColor = new Color (100,100,255), + saSelectionColor = Color.GREEN, + saDefaultColor = new Color (90,90,90), + saEditColor = new Color (240,240,0); +} + + diff --git a/accessibility/workben/org/openoffice/accessibility/awb/view/TableView.java b/accessibility/workben/org/openoffice/accessibility/awb/view/TableView.java new file mode 100644 index 000000000..8d5e430dd --- /dev/null +++ b/accessibility/workben/org/openoffice/accessibility/awb/view/TableView.java @@ -0,0 +1,195 @@ +/************************************************************************* + * + * $RCSfile: TableView.java,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: af $ $Date: 2003/06/13 16:30:37 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +package org.openoffice.accessibility.awb.view; + +import java.lang.Integer; +import java.lang.StringBuffer; + +import javax.swing.JLabel; + +import com.sun.star.accessibility.AccessibleEventId; +import com.sun.star.accessibility.AccessibleEventObject; +import com.sun.star.accessibility.XAccessible; +import com.sun.star.accessibility.XAccessibleContext; +import com.sun.star.accessibility.XAccessibleTable; +import com.sun.star.uno.UnoRuntime; + + + +/** The <type>ContextView</type> class displays information accessible over + the <type>XAccessibleContext</type> interface. This includes name, + description, and role. +*/ +public class TableView + extends ObjectView +{ + static public ObjectView Create ( + ObjectViewContainer aContainer, + XAccessibleContext xContext) + { + if (UnoRuntime.queryInterface( + XAccessibleTable.class, xContext) != null) + return new TableView (aContainer); + else + return null; + } + + public TableView (ObjectViewContainer aContainer) + { + super (aContainer); + + ViewGridLayout aLayout = new ViewGridLayout (this); + + maRowCountLabel = aLayout.AddLabeledEntry ("Row Count: "); + maColumnCountLabel = aLayout.AddLabeledEntry ("Column Count: "); + maCellCountLabel = aLayout.AddLabeledEntry ("Cell Count: "); + maSelectedRowsLabel = aLayout.AddLabeledEntry ("Selected Rows: "); + maSelectedColumnsLabel = aLayout.AddLabeledEntry ("Selected Columns: "); + } + + + public void SetObject (XAccessibleContext xContext) + { + mxTable = (XAccessibleTable)UnoRuntime.queryInterface( + XAccessibleTable.class, xContext); + super.SetObject (xContext); + } + + + public void Update () + { + if (mxTable == null) + { + maRowCountLabel.setText ("<null object>"); + maColumnCountLabel.setText ("<null object>"); + maCellCountLabel.setText ("<null object>"); + maSelectedRowsLabel.setText ("<null object>"); + maSelectedColumnsLabel.setText ("<null object>"); + } + else + { + int nRowCount = mxTable.getAccessibleRowCount(); + int nColumnCount = mxTable.getAccessibleColumnCount(); + maRowCountLabel.setText (Integer.toString (nRowCount)); + maColumnCountLabel.setText (Integer.toString (nColumnCount)); + maCellCountLabel.setText (Integer.toString (nRowCount*nColumnCount)); + + StringBuffer sList = new StringBuffer(); + int[] aSelected = mxTable.getSelectedAccessibleRows(); + boolean bFirst = true; + for (int i=0; i<aSelected.length; i++) + { + if ( ! bFirst) + { + sList.append (", "); + bFirst = false; + } + sList.append (Integer.toString(aSelected[i])); + } + maSelectedRowsLabel.setText (sList.toString()); + sList = new StringBuffer(); + aSelected = mxTable.getSelectedAccessibleColumns(); + bFirst = true; + for (int i=0; i<aSelected.length; i++) + { + if ( ! bFirst) + { + sList.append (", "); + bFirst = false; + } + sList.append (Integer.toString(aSelected[i])); + } + maSelectedColumnsLabel.setText (sList.toString()); + } + } + + + + + public String GetTitle () + { + return ("Table"); + } + + + + + /** Listen for changes regarding displayed values. + */ + public void notifyEvent (AccessibleEventObject aEvent) + { + switch (aEvent.EventId) + { + case AccessibleEventId.TABLE_MODEL_CHANGED : + case AccessibleEventId.SELECTION_CHANGED: + Update (); + } + } + + private XAccessibleTable mxTable; + private JLabel + maRowCountLabel, + maColumnCountLabel, + maCellCountLabel, + maSelectedRowsLabel, + maSelectedColumnsLabel; +} diff --git a/accessibility/workben/org/openoffice/accessibility/awb/view/TextView.java b/accessibility/workben/org/openoffice/accessibility/awb/view/TextView.java new file mode 100644 index 000000000..e829a9e34 --- /dev/null +++ b/accessibility/workben/org/openoffice/accessibility/awb/view/TextView.java @@ -0,0 +1,501 @@ +/************************************************************************* + * + * $RCSfile: TextView.java,v $ + * + * $Revision: 1.2 $ + * + * last change: $Author: obr $ $Date: 2008/05/14 13:21:35 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +package org.openoffice.accessibility.awb.view; + +import java.awt.Color; +import java.awt.Dimension; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.event.ActionListener; +import java.awt.event.ActionEvent; + +import javax.swing.JButton; +import javax.swing.JComponent; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JSpinner; +import javax.swing.JTree; +import javax.swing.tree.TreeNode; +import javax.swing.tree.DefaultMutableTreeNode; +import javax.swing.tree.DefaultTreeModel; +import javax.swing.tree.MutableTreeNode; + +import com.sun.star.accessibility.AccessibleEventId; +import com.sun.star.accessibility.AccessibleEventObject; +import com.sun.star.accessibility.AccessibleTextType; +import com.sun.star.accessibility.AccessibleStateType; +import com.sun.star.accessibility.TextSegment; +import com.sun.star.accessibility.XAccessibleText; +import com.sun.star.accessibility.XAccessibleContext; +import com.sun.star.accessibility.XAccessibleMultiLineText; +import com.sun.star.accessibility.XAccessibleStateSet; +import com.sun.star.awt.Point; +import com.sun.star.awt.Rectangle; +import com.sun.star.beans.PropertyValue; +import com.sun.star.lang.IndexOutOfBoundsException; +import com.sun.star.lang.IllegalArgumentException; +import com.sun.star.uno.UnoRuntime; + +import org.openoffice.accessibility.awb.view.text.CaretSpinnerModel; +import org.openoffice.accessibility.awb.view.text.TextDialogFactory; + + +public class TextView + extends ObjectView + implements ActionListener +{ + + /** Create a TextView when the given object supports the + XAccessibleText interface. + */ + static public ObjectView Create ( + ObjectViewContainer aContainer, + XAccessibleContext xContext) + { + XAccessibleText xText = (XAccessibleText)UnoRuntime.queryInterface( + XAccessibleText.class, xContext); + if (xText != null) + return new TextView (aContainer); + else + return null; + } + + + public TextView (ObjectViewContainer aContainer) + { + super (aContainer); + + ViewGridLayout aLayout = new ViewGridLayout (this); + + maTextLabel = aLayout.AddLabeledString ("Text: "); + maCharacterArrayLabel = aLayout.AddLabeledEntry ("Characters: "); + maCharacterCountLabel = aLayout.AddLabeledEntry ("Character Count: "); + maSelectionLabel = aLayout.AddLabeledEntry ("Selection: "); + maBoundsLabel = aLayout.AddLabeledEntry ("Bounds Test: "); + maCaretPositionSpinner = (JSpinner)aLayout.AddLabeledComponent ( + "Caret position:", new JSpinner()); + Dimension aSize = maCaretPositionSpinner.getSize(); + maCaretPositionSpinner.setPreferredSize (new Dimension (100,20)); + maCaretLineNoLabel = aLayout.AddLabeledEntry ("Line number at caret: "); + maCaretLineTextLabel = aLayout.AddLabeledEntry ("Text of line at caret: "); + maLineNoFromCaretPosLabel = aLayout.AddLabeledEntry ("Line number at index of caret: "); + maLineTextFromCaretPosLabel = aLayout.AddLabeledEntry ("Text of line at index of caret: "); + + JPanel aButtonPanel = new JPanel (); + aLayout.AddComponent (aButtonPanel); + + JButton aButton = new JButton ("select..."); + aButton.setFont (aLayout.GetFont()); + aButton.addActionListener (this); + aButtonPanel.add (aButton); + + aButton = new JButton ("copy..."); + aButton.setFont (aLayout.GetFont()); + aButton.addActionListener (this); + aButtonPanel.add (aButton); + + // A tree that holds the text broken down into various segments. + maTree = new JTree (); + aLayout.AddComponent (new JScrollPane ( + maTree, + JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, + JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED)); + } + + + /** Additionally to the context store a reference to the + XAccessibleText interface. + */ + public void SetObject (XAccessibleContext xObject) + { + mxText = (XAccessibleText)UnoRuntime.queryInterface( + XAccessibleText.class, xObject); + maCaretSpinnerModel = new CaretSpinnerModel(mxText); + maCaretPositionSpinner.setModel (maCaretSpinnerModel); + super.SetObject (xObject); + } + + synchronized public void Destroy () + { + mxText = null; + super.Destroy(); + } + + synchronized public void Update () + { + maCaretPositionSpinner.setEnabled (mxText != null); + DefaultMutableTreeNode aRoot = new DefaultMutableTreeNode ("Text Segments"); + if (mxText == null) + { + maTextLabel.setText ("<null object>"); + maCharacterArrayLabel.setText ("<null object>"); + maCharacterCountLabel.setText ("<null object>"); + maSelectionLabel.setText ("<null object>"); + maBoundsLabel.setText ("<null object>"); + maCaretLineNoLabel.setText ("<null object>"); + maCaretLineTextLabel.setText ("<null object>"); + maLineNoFromCaretPosLabel.setText ("<null object>"); + maLineTextFromCaretPosLabel.setText ("<null object>"); + } + else + { + maTextLabel.setText (mxText.getText()); + maCharacterArrayLabel.setText (GetCharacterArray()); + maCharacterCountLabel.setText ( + Integer.toString(mxText.getCharacterCount())); + // Selection. + maSelectionLabel.setText ( + "[" + mxText.getSelectionStart() + + "," + mxText.getSelectionEnd() + + "] \"" + mxText.getSelectedText() + "\""); + + // Character bounds. + maBoundsLabel.setText (GetTextBoundsString()); + + // Caret position. + maCaretPositionSpinner.setValue (new Integer (mxText.getCaretPosition())); + + // Multi line methods. + XAccessibleMultiLineText xMultiText = (XAccessibleMultiLineText) + UnoRuntime.queryInterface( XAccessibleMultiLineText.class, mxText ); + + if( null != xMultiText ) { + try { + maCaretLineNoLabel.setText ( Integer.toString( xMultiText.getNumberOfLineWithCaret() ) ); + TextSegment ts = xMultiText.getTextAtLineWithCaret(); + maCaretLineTextLabel.setText ( "[" + ts.SegmentStart + + "," + ts.SegmentEnd + + "] \"" + ts.SegmentText + "\""); + maLineNoFromCaretPosLabel.setText ( Integer.toString( xMultiText.getLineNumberAtIndex( mxText.getCaretPosition() ) ) ); + ts = xMultiText.getTextAtLineNumber(xMultiText.getLineNumberAtIndex( mxText.getCaretPosition() ) ); + maLineTextFromCaretPosLabel.setText ( "[" + ts.SegmentStart + + "," + ts.SegmentEnd + + "] \"" + ts.SegmentText + "\""); + } catch( IndexOutOfBoundsException e) { + } + } + + // Text segments. + aRoot.add (CreateNode ("Character", AccessibleTextType.CHARACTER)); + aRoot.add (CreateNode ("Word", AccessibleTextType.WORD)); + aRoot.add (CreateNode ("Sentence", AccessibleTextType.SENTENCE)); + aRoot.add (CreateNode ("Paragraph", AccessibleTextType.PARAGRAPH)); + aRoot.add (CreateNode ("Line", AccessibleTextType.LINE)); + aRoot.add (CreateNode ("Attribute", AccessibleTextType.ATTRIBUTE_RUN)); + aRoot.add (CreateNode ("Glyph", AccessibleTextType.GLYPH)); + } + ((DefaultTreeModel)maTree.getModel()).setRoot (aRoot); + } + + public String GetTitle () + { + return ("Text"); + } + + public void notifyEvent (AccessibleEventObject aEvent) + { + System.out.println (aEvent); + switch (aEvent.EventId) + { + case AccessibleEventId.CARET_CHANGED : + maCaretSpinnerModel.Update(); + Update (); + break; + + case AccessibleEventId.TEXT_CHANGED : + case AccessibleEventId.TEXT_SELECTION_CHANGED: + Update (); + break; + } + } + + public void actionPerformed (ActionEvent aEvent) + { + String sCommand = aEvent.getActionCommand(); + if (sCommand.equals ("select...")) + TextDialogFactory.CreateSelectionDialog (mxContext); + else if (sCommand.equals ("copy...")) + TextDialogFactory.CreateCopyDialog (mxContext); + } + + + + /** Create a string that is a list of all characters returned by the + getCharacter() method. + */ + private String GetCharacterArray () + { + // Do not show more than 30 characters. + int nCharacterCount = mxText.getCharacterCount(); + int nMaxDisplayCount = 30; + + // build up string + StringBuffer aCharacterArray = new StringBuffer(); + int nIndex = 0; + try + { + while (nIndex<nCharacterCount && nIndex<nMaxDisplayCount) + { + aCharacterArray.append (mxText.getCharacter (nIndex)); + if (nIndex < nCharacterCount-1) + aCharacterArray.append (","); + nIndex ++; + } + if (nMaxDisplayCount < nCharacterCount) + aCharacterArray.append (", ..."); + } + catch (IndexOutOfBoundsException e) + { + aCharacterArray.append ("; Index Out Of Bounds at index " + nIndex); + } + + return aCharacterArray.toString(); + } + + + + /** Iterate over all characters and translate their positions + back and forth. + */ + private String GetTextBoundsString () + { + StringBuffer aBuffer = new StringBuffer (); + try + { + // Iterate over all characters in the text. + int nCount = mxText.getCharacterCount(); + for (int i=0; i<nCount; i++) + { + // Get bounds for this character. + Rectangle aBBox = mxText.getCharacterBounds (i); + + // get the character by 'clicking' into the middle of + // the bounds + Point aMiddle = new Point(); + aMiddle.X = aBBox.X + (aBBox.Width / 2) - 1; + aMiddle.Y = aBBox.Y + (aBBox.Height / 2) - 1; + int nIndex = mxText.getIndexAtPoint (aMiddle); + + // get the character, or a '#' for an illegal index + if ((nIndex >= 0) && (nIndex < mxText.getCharacter(i))) + aBuffer.append (mxText.getCharacter(nIndex)); + else + aBuffer.append ('#'); + } + } + catch (IndexOutOfBoundsException aEvent) + { + // Ignore errors. + } + + return aBuffer.toString(); + } + + + + + private final static int BEFORE = -1; + private final static int AT = 0; + private final static int BEHIND = +1; + + private MutableTreeNode CreateNode (String sTitle, short nTextType) + { + DefaultMutableTreeNode aNode = new DefaultMutableTreeNode (sTitle); + + aNode.add (CreateSegmentNode ("Before", nTextType, BEFORE)); + aNode.add (CreateSegmentNode ("At", nTextType, AT)); + aNode.add (CreateSegmentNode ("Behind", nTextType, BEHIND)); + + return aNode; + } + + private MutableTreeNode CreateSegmentNode (String sTitle, short nTextType, int nWhere) + { + TextSegment aSegment; + int nTextLength = mxText.getCharacterCount(); + DefaultMutableTreeNode aNode = new DefaultMutableTreeNode (sTitle); + for (int nIndex=0; nIndex<=nTextLength; /* empty */) + { + aSegment = GetTextSegment (nIndex, nTextType, nWhere); + DefaultMutableTreeNode aSegmentNode = new DefaultMutableTreeNode ( + new StringBuffer ( + Integer.toString (nIndex) + " -> " + + Integer.toString (aSegment.SegmentStart) + " - " + + Integer.toString (aSegment.SegmentEnd) + " : " + + aSegment.SegmentText.toString())); + aNode.add (aSegmentNode); + if (nTextType == AccessibleTextType.ATTRIBUTE_RUN) + AddAttributeNodes (aSegmentNode, aSegment); + if (aSegment.SegmentEnd > nIndex) + nIndex = aSegment.SegmentEnd; + else + nIndex ++; + } + + return aNode; + } + + + private TextSegment GetTextSegment (int nIndex, short nTextType, int nWhere) + { + TextSegment aSegment; + + try + { + switch (nWhere) + { + case BEFORE: + aSegment = mxText.getTextBeforeIndex (nIndex, nTextType); + break; + + case AT: + aSegment = mxText.getTextAtIndex (nIndex, nTextType); + break; + + case BEHIND: + aSegment = mxText.getTextBehindIndex (nIndex, nTextType); + break; + + default: + aSegment = new TextSegment(); + aSegment.SegmentText = new String ("unknown position " + nWhere); + aSegment.SegmentStart = nIndex; + aSegment.SegmentStart = nIndex+1; + break; + } + } + catch (IndexOutOfBoundsException aException) + { + aSegment = new TextSegment (); + aSegment.SegmentText = new String ("Invalid index at ") + nIndex + " : " + + aException.toString(); + aSegment.SegmentStart = nIndex; + aSegment.SegmentEnd = nIndex+1; + } + catch (IllegalArgumentException aException) + { + aSegment = new TextSegment (); + aSegment.SegmentText = new String ("Illegal argument at ") + nIndex + " : " + + aException.toString(); + aSegment.SegmentStart = nIndex; + aSegment.SegmentEnd = nIndex+1; + } + + return aSegment; + } + + + /** Add to the given node one node for every attribute of the given segment. + */ + private void AddAttributeNodes ( + DefaultMutableTreeNode aNode, + TextSegment aSegment) + { + try + { + PropertyValue[] aValues = mxText.getCharacterAttributes ( + aSegment.SegmentStart, aAttributeList); + for (int i=0; i<aValues.length; i++) + aNode.add (new DefaultMutableTreeNode ( + aValues[i].Name + ": " + aValues[i].Value)); + } + catch (IndexOutOfBoundsException aException) + { + aNode.add (new DefaultMutableTreeNode ( + "caught IndexOutOfBoundsException while retrieveing attributes")); + } + } + + private XAccessibleText mxText; + private JLabel + maTextLabel, + maCharacterArrayLabel, + maCharacterCountLabel, + maSelectionLabel, + maBoundsLabel, + maCaretLineNoLabel, + maCaretLineTextLabel, + maLineNoFromCaretPosLabel, + maLineTextFromCaretPosLabel; + + private JSpinner maCaretPositionSpinner; + private JTree maTree; + private CaretSpinnerModel maCaretSpinnerModel; + + private static String[] aAttributeList = new String[] { + "CharBackColor", + "CharColor", + "CharEscapement", + "CharHeight", + "CharPosture", + "CharStrikeout", + "CharUnderline", + "CharWeight", + "ParaAdjust", + "ParaBottomMargin", + "ParaFirstLineIndent", + "ParaLeftMargin", + "ParaLineSpacing", + "ParaRightMargin", + "ParaTabStops"}; +} diff --git a/accessibility/workben/org/openoffice/accessibility/awb/view/ViewGridLayout.java b/accessibility/workben/org/openoffice/accessibility/awb/view/ViewGridLayout.java new file mode 100644 index 000000000..c9f9f3ab0 --- /dev/null +++ b/accessibility/workben/org/openoffice/accessibility/awb/view/ViewGridLayout.java @@ -0,0 +1,151 @@ +/************************************************************************* + * + * $RCSfile: ViewGridLayout.java,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: af $ $Date: 2003/06/13 16:30:38 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +package org.openoffice.accessibility.awb.view; + +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Font; +import java.awt.GridBagLayout; +import java.awt.GridBagConstraints; +import javax.swing.JComponent; +import javax.swing.JLabel; + + +/** This class is a convenience class for views to use the GridBagLayout. +*/ +class ViewGridLayout +{ + public ViewGridLayout (JComponent aComponent) + { + maComponent = aComponent; + maComponent.setLayout (new GridBagLayout()); + maComponent.setMinimumSize (new Dimension (300,30)); + maComponent.setMaximumSize (new Dimension (300,1000)); + mnCurrentLine = 0; + } + + public JLabel AddLabeledEntry (String sTitle) + { + return (JLabel)AddLabeledComponent (sTitle, new JLabel ("")); + } + + public JLabel AddLabeledString (String sTitle) + { + JLabel aLabel = AddLabeledEntry (sTitle); + aLabel.setBackground (new Color(220,220,220)); + aLabel.setOpaque (true); + return aLabel; + } + + public JComponent AddLabeledComponent (String sTitle, JComponent aComponent) + { + GridBagConstraints constraints = new GridBagConstraints (); + constraints.gridx = 0; + constraints.anchor = GridBagConstraints.WEST; + constraints.fill = GridBagConstraints.NONE; + constraints.gridy = mnCurrentLine; + + JLabel aLabel = new JLabel(sTitle); + aLabel.setFont (saFont); + maComponent.add (aLabel, constraints); + constraints.gridx = 1; + constraints.weightx = 1; + constraints.fill = GridBagConstraints.NONE; + aComponent.setFont (saFont); + maComponent.add (aComponent, constraints); + + mnCurrentLine += 1; + + return aComponent; + } + + public JComponent AddComponent (JComponent aComponent) + { + GridBagConstraints constraints = new GridBagConstraints (); + constraints.gridx = 0; + constraints.gridwidth = 2; + constraints.weightx = 1; + constraints.anchor = GridBagConstraints.WEST; + constraints.fill = GridBagConstraints.HORIZONTAL; + constraints.gridy = mnCurrentLine; + + maComponent.add (aComponent, constraints); + + mnCurrentLine += 1; + + return aComponent; + } + + static public Font GetFont () + { + return saFont; + } + + static private Font saFont; + private int mnCurrentLine; + private JComponent maComponent; + + static + { + saFont = new Font ("Dialog", Font.PLAIN, 11); + } +} diff --git a/accessibility/workben/org/openoffice/accessibility/awb/view/makefile.common b/accessibility/workben/org/openoffice/accessibility/awb/view/makefile.common new file mode 100644 index 000000000..d4929e3f1 --- /dev/null +++ b/accessibility/workben/org/openoffice/accessibility/awb/view/makefile.common @@ -0,0 +1,76 @@ +#************************************************************************* +# +# $RCSfile: makefile.common,v $ +# +# The Contents of this file are made available subject to the terms of +# either of the following licenses +# +# - GNU Lesser General Public License Version 2.1 +# - Sun Industry Standards Source License Version 1.1 +# +# Sun Microsystems Inc., October, 2000 +# +# GNU Lesser General Public License Version 2.1 +# ============================================= +# Copyright 2000 by Sun Microsystems, Inc. +# 901 San Antonio Road, Palo Alto, CA 94303, USA +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License version 2.1, as published by the Free Software Foundation. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, +# MA 02111-1307 USA +# +# +# Sun Industry Standards Source License Version 1.1 +# ================================================= +# The contents of this file are subject to the Sun Industry Standards +# Source License Version 1.1 (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.openoffice.org/license.html. +# +# Software provided under this License is provided on an "AS IS" basis, +# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, +# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, +# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. +# See the License for the specific provisions governing your rights and +# obligations concerning the Software. +# +# The Initial Developer of the Original Code is: Sun Microsystems, Inc. +# +# Copyright: 2000 by Sun Microsystems, Inc. +# +# All Rights Reserved. +# +# Contributor(s): _______________________________________ +# +# +# +#************************************************************************* + +JARFILES = sandbox.jar jurt.jar unoil.jar ridl.jar +JAVAFILES = \ + ComponentView.java \ + ContextView.java \ + EditableTextView.java \ + EventMonitorView.java \ + FocusView.java \ + LayoutManager.java \ + ObjectView.java \ + ObjectViewContainer.java \ + ObjectViewContainerWindow.java \ + ParentView.java \ + SelectionView.java \ + ServiceInterfaceView.java \ + StateSetView.java \ + TableView.java \ + TextView.java \ + ViewGridLayout.java diff --git a/accessibility/workben/org/openoffice/accessibility/awb/view/makefile.mk b/accessibility/workben/org/openoffice/accessibility/awb/view/makefile.mk new file mode 100644 index 000000000..c8ddd5876 --- /dev/null +++ b/accessibility/workben/org/openoffice/accessibility/awb/view/makefile.mk @@ -0,0 +1,82 @@ +#************************************************************************* +# +# $RCSfile: makefile.mk,v $ +# +# The Contents of this file are made available subject to the terms of +# either of the following licenses +# +# - GNU Lesser General Public License Version 2.1 +# - Sun Industry Standards Source License Version 1.1 +# +# Sun Microsystems Inc., October, 2000 +# +# GNU Lesser General Public License Version 2.1 +# ============================================= +# Copyright 2000 by Sun Microsystems, Inc. +# 901 San Antonio Road, Palo Alto, CA 94303, USA +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License version 2.1, as published by the Free Software Foundation. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, +# MA 02111-1307 USA +# +# +# Sun Industry Standards Source License Version 1.1 +# ================================================= +# The contents of this file are subject to the Sun Industry Standards +# Source License Version 1.1 (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.openoffice.org/license.html. +# +# Software provided under this License is provided on an "AS IS" basis, +# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, +# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, +# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. +# See the License for the specific provisions governing your rights and +# obligations concerning the Software. +# +# The Initial Developer of the Original Code is: Sun Microsystems, Inc. +# +# Copyright: 2000 by Sun Microsystems, Inc. +# +# All Rights Reserved. +# +# Contributor(s): _______________________________________ +# +# +# +#************************************************************************* + +PRJNAME = awb +PRJ = ..$/..$/..$/..$/..$/.. +TARGET = awb_view +PACKAGE = org$/openoffice$/accessibility$/awb$/view + +USE_JAVAVER:=TRUE + +# --- Settings ----------------------------------------------------- + +.INCLUDE : settings.mk + +.IF "$(JAVAVER:s/.//)" >= "140" + +.INCLUDE : makefile.common + +JAVACLASSFILES= $(foreach,i,$(JAVAFILES) $(CLASSDIR)$/$(PACKAGE)$/$(i:b).class) + +.ENDIF + +# --- Targets ------------------------------------------------------ + + +.INCLUDE : target.mk + diff --git a/accessibility/workben/org/openoffice/accessibility/awb/view/text/CaretSpinnerModel.java b/accessibility/workben/org/openoffice/accessibility/awb/view/text/CaretSpinnerModel.java new file mode 100644 index 000000000..f49168229 --- /dev/null +++ b/accessibility/workben/org/openoffice/accessibility/awb/view/text/CaretSpinnerModel.java @@ -0,0 +1,156 @@ +/************************************************************************* + * + * $RCSfile: CaretSpinnerModel.java,v $ + * + * $Revision: 1.2 $ + * + * last change: $Author: obr $ $Date: 2008/05/14 13:21:37 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +package org.openoffice.accessibility.awb.view.text; + +import java.lang.Integer; +import java.util.Vector; +import javax.swing.SpinnerModel; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; + +import com.sun.star.accessibility.XAccessibleText; +import com.sun.star.lang.IndexOutOfBoundsException; + + +/** A simple model for JSpinner objects that clips the spinner values to valid + text indices. +*/ +public class CaretSpinnerModel + implements SpinnerModel +{ + public CaretSpinnerModel (XAccessibleText xText) + { + mxText = xText; + maListeners = new Vector (); + } + + public void addChangeListener (ChangeListener aListener) + { + if (aListener != null) + maListeners.add (aListener); + } + + public void removeChangeListener (ChangeListener aListener) + { + maListeners.removeElement (aListener); + } + + public Object getNextValue () + { + if (mxText != null) + { + int nPosition = mxText.getCaretPosition(); + if (nPosition+1 <= mxText.getCharacterCount()) + return new Integer (nPosition+1); + } + return null; + } + + public Object getPreviousValue () + { + if (mxText != null) + { + int nPosition = mxText.getCaretPosition(); + if (nPosition > 0) + return new Integer (nPosition-1); + } + return null; + } + + public Object getValue () + { + if (mxText != null) + return new Integer (mxText.getCaretPosition()); + else + return null; + } + + public void setValue (Object aValue) + { + if (mxText != null) + if (aValue instanceof Integer) + { + try + { + if( ((Integer)aValue).intValue() != mxText.getCaretPosition() ) + mxText.setCaretPosition (((Integer)aValue).intValue()); + } + catch (IndexOutOfBoundsException aException) + { + } + } + } + + /** Call this method when the caret position has changes so that the model + can inform its listeners about it. + */ + public void Update () + { + ChangeEvent aEvent = new ChangeEvent (this); + for (int i=0; i<maListeners.size(); i++) + ((ChangeListener)maListeners.elementAt(i)).stateChanged (aEvent); + } + + private XAccessibleText mxText; + private Integer maValue; + private Vector maListeners; +} diff --git a/accessibility/workben/org/openoffice/accessibility/awb/view/text/Makefile b/accessibility/workben/org/openoffice/accessibility/awb/view/text/Makefile new file mode 100644 index 000000000..c58899a09 --- /dev/null +++ b/accessibility/workben/org/openoffice/accessibility/awb/view/text/Makefile @@ -0,0 +1,13 @@ +# $Id: Makefile,v 1.1 2003/06/13 16:30:41 af Exp $ + +all : package + +ROOT=../../../../.. +PACKAGE = org.openoffice.accessibility.awb.view.text +SUBDIRS = +include makefile.common + +include $(ROOT)/makefile.in + + +package : $(CLASS_FILES) diff --git a/accessibility/workben/org/openoffice/accessibility/awb/view/text/TextActionDialog.java b/accessibility/workben/org/openoffice/accessibility/awb/view/text/TextActionDialog.java new file mode 100644 index 000000000..7cf2d01ed --- /dev/null +++ b/accessibility/workben/org/openoffice/accessibility/awb/view/text/TextActionDialog.java @@ -0,0 +1,242 @@ +/************************************************************************* + * + * $RCSfile: TextActionDialog.java,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: af $ $Date: 2003/06/13 16:30:42 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +package org.openoffice.accessibility.awb.view.text; + +import java.awt.BorderLayout; +import java.awt.Container; +import java.awt.FlowLayout; +import java.awt.event.ActionListener; +import java.awt.event.ActionEvent; +import javax.swing.JButton; +import javax.swing.JCheckBox; +import javax.swing.JDialog; +import javax.swing.JLabel; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JTextArea; +import javax.swing.text.JTextComponent; + +import com.sun.star.accessibility.XAccessibleContext; +import com.sun.star.accessibility.XAccessibleText; +import com.sun.star.accessibility.XAccessibleEditableText; +import com.sun.star.lang.IndexOutOfBoundsException; +import com.sun.star.uno.UnoRuntime; + + +/** + * Display a dialog with a text field and a pair of cancel/do-it buttons + */ +class TextActionDialog + extends JDialog + implements ActionListener +{ + public TextActionDialog ( + XAccessibleContext xContext, + String sExplanation, + String sTitle) + { + super();// AccessibilityWorkBench.Instance() ); + + mxContext = xContext; + msTitle = sTitle; + msExplanation = sExplanation; + Layout (); + setSize (350, 225); + + } + + + /** build dialog */ + protected void Layout() + { + setTitle (msTitle); + + // vertical stacking of the elements + Container aContent = getContentPane(); + // aContent.setLayout( new BorderLayout() ); + + // Label with explanation. + if (msExplanation.length() > 0) + aContent.add (new JLabel (msExplanation), BorderLayout.NORTH); + + // the text field + maText = new JTextArea(); + maText.setLineWrap (true); + maText.setEditable (false); + aContent.add (maText, BorderLayout.CENTER); + + XAccessibleText xText = (XAccessibleText)UnoRuntime.queryInterface( + XAccessibleText.class, mxContext); + String sText = xText.getText(); + maText.setText (sText); + maText.setRows (sText.length() / 40 + 1); + maText.setColumns (Math.min (Math.max (40, sText.length()), 20)); + + JPanel aButtons = new JPanel(); + aButtons.setLayout (new FlowLayout()); + maIndexToggle = new JCheckBox ("reverse selection"); + aButtons.add (maIndexToggle); + + JButton aActionButton = new JButton (msTitle); + aActionButton.setActionCommand ("Action"); + aActionButton.addActionListener (this); + aButtons.add (aActionButton); + + JButton aCancelButton = new JButton ("cancel"); + aCancelButton.setActionCommand ("Cancel"); + aCancelButton.addActionListener (this); + aButtons.add (aCancelButton); + + // add Panel with buttons + aContent.add (aButtons, BorderLayout.SOUTH); + } + + protected void Cancel() + { + hide(); + dispose(); + } + + public void actionPerformed(ActionEvent e) + { + String sCommand = e.getActionCommand(); + + if( "Cancel".equals( sCommand ) ) + Cancel(); + else if( "Action".equals( sCommand ) ) + Action(); + } + + + protected int GetSelectionStart() + { + return GetSelection(true); + } + protected int GetSelectionEnd() + { + return GetSelection(false); + } + private int GetSelection (boolean bStart) + { + if (bStart ^ maIndexToggle.isSelected()) + return maText.getSelectionStart(); + else + return maText.getSelectionEnd(); + } + + + + protected void Action () + { + String sError = null; + boolean bSuccess = true; + try + { + XAccessibleText xText = + (XAccessibleText)UnoRuntime.queryInterface( + XAccessibleText.class, mxContext); + if (xText != null) + bSuccess = bSuccess && TextAction (xText); + + XAccessibleEditableText xEditableText = + (XAccessibleEditableText)UnoRuntime.queryInterface( + XAccessibleEditableText.class, mxContext); + if (xEditableText != null) + bSuccess = bSuccess && EditableTextAction (xEditableText); + + if ( ! bSuccess) + sError = "Can't execute"; + } + catch (IndexOutOfBoundsException e) + { + sError = "Index out of bounds"; + } + + if (sError != null) + JOptionPane.showMessageDialog ( + this,// AccessibilityWorkBench.Instance(), + sError, + msTitle, + JOptionPane.ERROR_MESSAGE); + + Cancel(); + } + + /** override this for dialog-specific action */ + boolean TextAction (XAccessibleText xText) + throws IndexOutOfBoundsException + { + return true; + } + + boolean EditableTextAction (XAccessibleEditableText xText) + throws IndexOutOfBoundsException + { + return true; + } + + private XAccessibleContext mxContext; + protected JTextArea maText; + private String msTitle; + private String msExplanation; + private JCheckBox maIndexToggle; +} diff --git a/accessibility/workben/org/openoffice/accessibility/awb/view/text/TextAttributeDialog.java b/accessibility/workben/org/openoffice/accessibility/awb/view/text/TextAttributeDialog.java new file mode 100644 index 000000000..3491c3c89 --- /dev/null +++ b/accessibility/workben/org/openoffice/accessibility/awb/view/text/TextAttributeDialog.java @@ -0,0 +1,213 @@ +/************************************************************************* + * + * $RCSfile: TextAttributeDialog.java,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: af $ $Date: 2003/06/13 16:30:42 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +package org.openoffice.accessibility.awb.view.text; + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Component; +import java.awt.Graphics; +import java.awt.event.ActionListener; +import java.awt.event.ActionEvent; +import javax.swing.BoxLayout; +import javax.swing.Icon; +import javax.swing.JButton; +import javax.swing.JCheckBox; +import javax.swing.JColorChooser; +import javax.swing.JPanel; +import javax.swing.text.JTextComponent; + +import com.sun.star.accessibility.XAccessibleContext; +import com.sun.star.accessibility.XAccessibleEditableText; +import com.sun.star.beans.PropertyValue; +import com.sun.star.lang.IndexOutOfBoundsException; +import com.sun.star.uno.UnoRuntime; + + +class TextAttributeDialog + extends TextActionDialog +{ + public TextAttributeDialog (XAccessibleContext xContext) + { + super (xContext, + "Choose attributes, select text, and press 'Set':", + "set"); + } + + protected void Layout () + { + super.Layout (); + + maForeground = Color.black; + maBackground = Color.white; + + JPanel aPanel = new JPanel(); + aPanel.setLayout (new BoxLayout (aPanel, BoxLayout.Y_AXIS)); + + maBoldCheckBox = new JCheckBox ("bold"); + maUnderlineCheckBox = new JCheckBox ("underline"); + maItalicsCheckBox = new JCheckBox ("italics"); + + JButton aForegroundButton = new JButton ("Foreground", + new TextAttributeDialog.ColorIcon(true)); + aForegroundButton.addActionListener (new ActionListener() + { + public void actionPerformed (ActionEvent aEvent) + { + maForeground = JColorChooser.showDialog ( + TextAttributeDialog.this, + "Select Foreground Color", + maForeground); + } + } ); + + JButton aBackgroundButton = new JButton("Background", + new TextAttributeDialog.ColorIcon(false)); + aBackgroundButton.addActionListener (new ActionListener() + { + public void actionPerformed (ActionEvent eEvent) + { + maBackground = JColorChooser.showDialog( + TextAttributeDialog.this, + "Select Background Color", + maBackground); + } + } ); + + aPanel.add (maBoldCheckBox); + aPanel.add (maUnderlineCheckBox); + aPanel.add (maItalicsCheckBox); + aPanel.add (aForegroundButton); + aPanel.add (aBackgroundButton); + + getContentPane().add (aPanel, BorderLayout.WEST); + } + + + /** edit the text */ + boolean EditableTextAction (XAccessibleEditableText xText) + throws IndexOutOfBoundsException + { + PropertyValue[] aSequence = new PropertyValue[6]; + aSequence[0] = new PropertyValue(); + aSequence[0].Name = "CharWeight"; + aSequence[0].Value = new Integer (maBoldCheckBox.isSelected() ? 150 : 100); + aSequence[1] = new PropertyValue(); + aSequence[1].Name = "CharUnderline"; + aSequence[1].Value = new Integer (maUnderlineCheckBox.isSelected() ? 1 : 0); + aSequence[2] = new PropertyValue(); + aSequence[2].Name = "CharBackColor"; + aSequence[2].Value = new Integer (maBackground.getRGB()); + aSequence[3] = new PropertyValue(); + aSequence[3].Name = "CharColor"; + aSequence[3].Value = new Integer (maForeground.getRGB()); + aSequence[4] = new PropertyValue(); + aSequence[4].Name = "CharPosture"; + aSequence[4].Value = new Integer (maItalicsCheckBox.isSelected() ? 1 : 0); + aSequence[5] = new PropertyValue(); + aSequence[5].Name = "CharBackTransparent"; + aSequence[5].Value = new Boolean (false); + + return xText.setAttributes ( + GetSelectionStart(), + GetSelectionEnd(), + aSequence); + } + + class ColorIcon + implements Icon + { + public ColorIcon(boolean bWhich) { bForeground = bWhich; } + public int getIconHeight() { return nHeight; } + public int getIconWidth() { return nWidth; } + public void paintIcon (Component c, Graphics g, int x, int y) + { + g.setColor( getColor() ); + g.fillRect( x, y, nHeight, nWidth ); + g.setColor( c.getForeground() ); + g.drawRect( x, y, nHeight, nWidth ); + } + Color getColor() + { + if (bForeground) + return maForeground; + else + return maBackground; + } + + private static final int nHeight = 16; + private static final int nWidth = 16; + private boolean bForeground; + } + + + + + private JCheckBox + maBoldCheckBox, + maUnderlineCheckBox, + maItalicsCheckBox; + private Color + maForeground, + maBackground; + +} + diff --git a/accessibility/workben/org/openoffice/accessibility/awb/view/text/TextDialogFactory.java b/accessibility/workben/org/openoffice/accessibility/awb/view/text/TextDialogFactory.java new file mode 100644 index 000000000..668297874 --- /dev/null +++ b/accessibility/workben/org/openoffice/accessibility/awb/view/text/TextDialogFactory.java @@ -0,0 +1,170 @@ +/************************************************************************* + * + * $RCSfile: TextDialogFactory.java,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: af $ $Date: 2003/06/13 16:30:43 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +package org.openoffice.accessibility.awb.view.text; + +import javax.swing.JDialog; +import javax.swing.text.JTextComponent; + +import com.sun.star.accessibility.XAccessibleContext; +import com.sun.star.accessibility.XAccessibleEditableText; +import com.sun.star.accessibility.XAccessibleText; +import com.sun.star.lang.IndexOutOfBoundsException; +import com.sun.star.uno.UnoRuntime; + + +/** Factory for dialogs of the text views. +*/ +public class TextDialogFactory +{ + static public JDialog CreateSelectionDialog (XAccessibleContext xContext) + { + JDialog aDialog = new TextActionDialog( + xContext, + "Select range:", + "select") + { + boolean TextAction (XAccessibleText xText) + throws IndexOutOfBoundsException + { + return xText.setSelection( + GetSelectionStart(), + GetSelectionEnd() ); + } + }; + if (aDialog != null) + aDialog.show(); + return aDialog; + } + + static public JDialog CreateCopyDialog (XAccessibleContext xContext) + { + JDialog aDialog = new TextActionDialog( + xContext, + "Select range and copy:", + "copy") + { + boolean TextAction (XAccessibleText xText) + throws IndexOutOfBoundsException + { + return xText.copyText( + GetSelectionStart(), + GetSelectionEnd()); + } + }; + if (aDialog != null) + aDialog.show(); + return aDialog; + } + static public JDialog CreateCutDialog (XAccessibleContext xContext) + { + JDialog aDialog = new TextActionDialog( + xContext, + "Select range and cut:", + "cut") + { + boolean EditableTextAction (XAccessibleEditableText xText) + throws IndexOutOfBoundsException + { + return xText.cutText( + GetSelectionStart(), + GetSelectionEnd() ); + } + }; + if (aDialog != null) + aDialog.show(); + return aDialog; + } + static public JDialog CreatePasteDialog (XAccessibleContext xContext) + { + JDialog aDialog = new TextActionDialog ( + xContext, + "Place Caret and paste:", + "paste") + { + boolean EditableTextAction (XAccessibleEditableText xText) + throws IndexOutOfBoundsException + { + return xText.pasteText(maText.getCaretPosition()); + } + }; + if (aDialog != null) + aDialog.show(); + return aDialog; + } + static public JDialog CreateEditDialog (XAccessibleContext xContext) + { + JDialog aDialog = new TextEditDialog ( + xContext, + "Edit text:", + "edit"); + if (aDialog != null) + aDialog.show(); + return aDialog; + } + static public JDialog CreateFormatDialog (XAccessibleContext xContext) + { + JDialog aDialog = new TextAttributeDialog (xContext); + if (aDialog != null) + aDialog.show(); + return aDialog; + } +} diff --git a/accessibility/workben/org/openoffice/accessibility/awb/view/text/TextEditDialog.java b/accessibility/workben/org/openoffice/accessibility/awb/view/text/TextEditDialog.java new file mode 100644 index 000000000..fc943370f --- /dev/null +++ b/accessibility/workben/org/openoffice/accessibility/awb/view/text/TextEditDialog.java @@ -0,0 +1,156 @@ +/************************************************************************* + * + * $RCSfile: TextEditDialog.java,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: af $ $Date: 2003/06/13 16:30:43 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +package org.openoffice.accessibility.awb.view.text; + +import javax.swing.text.JTextComponent; + +import com.sun.star.accessibility.XAccessibleContext; +import com.sun.star.accessibility.XAccessibleEditableText; +import com.sun.star.lang.IndexOutOfBoundsException; +import com.sun.star.uno.UnoRuntime; + + +class TextEditDialog + extends TextActionDialog +{ + public TextEditDialog ( + XAccessibleContext xContext, + String sExplanation, + String sTitle ) + { + super (xContext, sExplanation, sTitle); + } + + protected void Layout() + { + super.Layout(); + maText.setEditable (true); + } + + + /** edit the text */ + boolean EditableTextAction (XAccessibleEditableText xText) + { + return UpdateText (xText, maText.getText()); + } + + + /** update the text */ + boolean UpdateText (XAccessibleEditableText xText, String sNew) + { + boolean bResult = false; + + String sOld = xText.getText(); + + // false alarm? Early out if no change was done! + if ( ! sOld.equals (sNew)) + { + + // Get the minimum length of both strings. + int nMinLength = sOld.length(); + if (sNew.length() < nMinLength) + nMinLength = sNew.length(); + + // Count equal characters from front and end. + int nFront = 0; + while ((nFront < nMinLength) && + (sNew.charAt(nFront) == sOld.charAt(nFront))) + nFront++; + int nBack = 0; + while ((nBack < nMinLength) && + (sNew.charAt(sNew.length()-nBack-1) == + sOld.charAt(sOld.length()-nBack-1) )) + nBack++; + if (nFront + nBack > nMinLength) + nBack = nMinLength - nFront; + + // so... the first nFront and the last nBack characters are the + // same. Change the others! + String sDel = sOld.substring (nFront, sOld.length() - nBack); + String sIns = sNew.substring (nFront, sNew.length() - nBack); + + System.out.println ("edit text: " + + sOld.substring(0, nFront) + + " [ " + sDel + " -> " + sIns + " ] " + + sOld.substring(sOld.length() - nBack)); + + try + { + // edit the text, and use + // (set|insert|delete|replace)Text as needed + if( nFront+nBack == 0 ) + bResult = xText.setText( sIns ); + else if( sDel.length() == 0 ) + bResult = xText.insertText( sIns, nFront ); + else if( sIns.length() == 0 ) + bResult = xText.deleteText( nFront, sOld.length()-nBack ); + else + bResult = xText.replaceText(nFront, sOld.length()-nBack,sIns); + } + catch( IndexOutOfBoundsException aException) + { + } + } + + return bResult; + } +} diff --git a/accessibility/workben/org/openoffice/accessibility/awb/view/text/makefile.common b/accessibility/workben/org/openoffice/accessibility/awb/view/text/makefile.common new file mode 100644 index 000000000..32655a0c6 --- /dev/null +++ b/accessibility/workben/org/openoffice/accessibility/awb/view/text/makefile.common @@ -0,0 +1,65 @@ +#************************************************************************* +# +# $RCSfile: makefile.common,v $ +# +# The Contents of this file are made available subject to the terms of +# either of the following licenses +# +# - GNU Lesser General Public License Version 2.1 +# - Sun Industry Standards Source License Version 1.1 +# +# Sun Microsystems Inc., October, 2000 +# +# GNU Lesser General Public License Version 2.1 +# ============================================= +# Copyright 2000 by Sun Microsystems, Inc. +# 901 San Antonio Road, Palo Alto, CA 94303, USA +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License version 2.1, as published by the Free Software Foundation. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, +# MA 02111-1307 USA +# +# +# Sun Industry Standards Source License Version 1.1 +# ================================================= +# The contents of this file are subject to the Sun Industry Standards +# Source License Version 1.1 (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.openoffice.org/license.html. +# +# Software provided under this License is provided on an "AS IS" basis, +# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, +# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, +# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. +# See the License for the specific provisions governing your rights and +# obligations concerning the Software. +# +# The Initial Developer of the Original Code is: Sun Microsystems, Inc. +# +# Copyright: 2000 by Sun Microsystems, Inc. +# +# All Rights Reserved. +# +# Contributor(s): _______________________________________ +# +# +# +#************************************************************************* + +JARFILES = sandbox.jar jurt.jar unoil.jar ridl.jar +JAVAFILES = \ + CaretSpinnerModel.java \ + TextActionDialog.java \ + TextEditDialog.java \ + TextAttributeDialog.java \ + TextDialogFactory.java diff --git a/accessibility/workben/org/openoffice/accessibility/awb/view/text/makefile.mk b/accessibility/workben/org/openoffice/accessibility/awb/view/text/makefile.mk new file mode 100644 index 000000000..05f5b3a99 --- /dev/null +++ b/accessibility/workben/org/openoffice/accessibility/awb/view/text/makefile.mk @@ -0,0 +1,82 @@ +#************************************************************************* +# +# $RCSfile: makefile.mk,v $ +# +# The Contents of this file are made available subject to the terms of +# either of the following licenses +# +# - GNU Lesser General Public License Version 2.1 +# - Sun Industry Standards Source License Version 1.1 +# +# Sun Microsystems Inc., October, 2000 +# +# GNU Lesser General Public License Version 2.1 +# ============================================= +# Copyright 2000 by Sun Microsystems, Inc. +# 901 San Antonio Road, Palo Alto, CA 94303, USA +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License version 2.1, as published by the Free Software Foundation. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, +# MA 02111-1307 USA +# +# +# Sun Industry Standards Source License Version 1.1 +# ================================================= +# The contents of this file are subject to the Sun Industry Standards +# Source License Version 1.1 (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.openoffice.org/license.html. +# +# Software provided under this License is provided on an "AS IS" basis, +# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, +# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, +# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. +# See the License for the specific provisions governing your rights and +# obligations concerning the Software. +# +# The Initial Developer of the Original Code is: Sun Microsystems, Inc. +# +# Copyright: 2000 by Sun Microsystems, Inc. +# +# All Rights Reserved. +# +# Contributor(s): _______________________________________ +# +# +# +#************************************************************************* + +PRJNAME = awb +PRJ = ..$/..$/..$/..$/..$/..$/.. +TARGET = awb_view_text +PACKAGE = org$/openoffice$/accessibility$/awb$/view$/text + +USE_JAVAVER:=TRUE + +# --- Settings ----------------------------------------------------- + +.INCLUDE : settings.mk + +.IF "$(JAVAVER:s/.//)" >= "140" + +.INCLUDE : makefile.common + +JAVACLASSFILES= $(foreach,i,$(JAVAFILES) $(CLASSDIR)$/$(PACKAGE)$/$(i:b).class) + +.ENDIF + +# --- Targets ------------------------------------------------------ + + +.INCLUDE : target.mk + diff --git a/accessibility/workben/org/openoffice/accessibility/misc/AccessibleEventMulticaster.java b/accessibility/workben/org/openoffice/accessibility/misc/AccessibleEventMulticaster.java new file mode 100644 index 000000000..1bcc09b9f --- /dev/null +++ b/accessibility/workben/org/openoffice/accessibility/misc/AccessibleEventMulticaster.java @@ -0,0 +1,122 @@ +/************************************************************************* + * + * $RCSfile: AccessibleEventMulticaster.java,v $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +package org.openoffice.accessibility.misc; + +import com.sun.star.lang.EventObject; + +import com.sun.star.accessibility.AccessibleEventObject; +import com.sun.star.accessibility.XAccessibleEventBroadcaster; +import com.sun.star.accessibility.XAccessibleEventListener; + +/** + * + */ +public class AccessibleEventMulticaster implements XAccessibleEventListener { + + private final XAccessibleEventListener a; + private final XAccessibleEventListener b; + + /** Creates a new instance of AccessibleEventMulticaster */ + protected AccessibleEventMulticaster(XAccessibleEventListener a, + XAccessibleEventListener b) { + this.a = a; + this.b = b; + } + + protected XAccessibleEventListener remove(XAccessibleEventListener l) { + if (l == a) + return b; + if (l == b) + return a; + XAccessibleEventListener a2 = remove(a, l); + XAccessibleEventListener b2 = remove(b, l); + if (a2 == a && b2 == b) { + return this; // not found + } + return add(a2, b2); + } + + public void notifyEvent(AccessibleEventObject accessibleEventObject) { + a.notifyEvent(accessibleEventObject); + b.notifyEvent(accessibleEventObject); + } + + public void disposing(EventObject eventObject) { + a.disposing(eventObject); + b.disposing(eventObject); + } + + public static XAccessibleEventListener add(XAccessibleEventListener a, XAccessibleEventListener b) { + if (a == null) + return b; + if (b == null) + return a; + return new AccessibleEventMulticaster(a,b); + } + + public static XAccessibleEventListener remove(XAccessibleEventListener l, XAccessibleEventListener oldl) { + if (l == oldl || l == null) { + return null; + } else if (l instanceof AccessibleEventMulticaster) { + return ((AccessibleEventMulticaster) l).remove(oldl); + } else { + return l; + } + } + +} diff --git a/accessibility/workben/org/openoffice/accessibility/misc/Connector.java b/accessibility/workben/org/openoffice/accessibility/misc/Connector.java new file mode 100644 index 000000000..de188676e --- /dev/null +++ b/accessibility/workben/org/openoffice/accessibility/misc/Connector.java @@ -0,0 +1,50 @@ +package org.openoffice.accessibility.misc; + +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.Timer; +import java.util.TimerTask; +import java.util.Vector; + + +/** Wait for an Office application and connect to it. +*/ +public class Connector + extends TimerTask +{ + final public static long snDelay = 3000; + + public Connector () + { + maTimer = new Timer (true); + maListeners = new Vector(); + run (); + } + + public void AddConnectionListener (ActionListener aListener) + { + SimpleOffice aOffice = SimpleOffice.Instance(); + if (aOffice!=null && aOffice.IsConnected()) + aListener.actionPerformed ( + new ActionEvent (aOffice,0,"<connected>")); + maListeners.add (aListener); + } + + public void run () + { + SimpleOffice aOffice = SimpleOffice.Instance(); + if (aOffice!=null && !aOffice.IsConnected()) + if ( ! aOffice.Connect()) + maTimer.schedule (this, snDelay); + else + { + ActionEvent aEvent = new ActionEvent (aOffice,0,"<connected>"); + for (int i=0; i<maListeners.size(); i++) + ((ActionListener)maListeners.elementAt(i)).actionPerformed( + aEvent); + } + } + + Timer maTimer; + Vector maListeners; +} diff --git a/accessibility/workben/org/openoffice/accessibility/misc/InformationWriter.java b/accessibility/workben/org/openoffice/accessibility/misc/InformationWriter.java new file mode 100644 index 000000000..f6cf042d9 --- /dev/null +++ b/accessibility/workben/org/openoffice/accessibility/misc/InformationWriter.java @@ -0,0 +1,421 @@ +package org.openoffice.accessibility.misc; + +import java.lang.Thread; +import java.io.PrintStream; + +import com.sun.star.awt.Rectangle; +import com.sun.star.awt.XWindow; + +import com.sun.star.beans.Property; +import com.sun.star.beans.PropertyValue; +import com.sun.star.beans.XPropertySet; +import com.sun.star.beans.XPropertySetInfo; + +import com.sun.star.container.XIndexAccess; +import com.sun.star.container.XChild; +import com.sun.star.container.XEnumerationAccess; +import com.sun.star.container.XEnumeration; + +import com.sun.star.frame.XComponentLoader; +import com.sun.star.frame.XController; +import com.sun.star.frame.XDesktop; +import com.sun.star.frame.XFrame; +import com.sun.star.frame.XTasksSupplier; +import com.sun.star.frame.XTask; + +import com.sun.star.lang.XComponent; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.lang.XServiceInfo; +import com.sun.star.lang.XServiceName; +import com.sun.star.lang.XTypeProvider; + +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.uno.Type; + +import com.sun.star.drawing.XDrawView; +import com.sun.star.drawing.XDrawPage; +import com.sun.star.drawing.XShapes; +import com.sun.star.drawing.XShape; +import com.sun.star.drawing.XShapeDescriptor; + +import com.sun.star.accessibility.XAccessible; +import com.sun.star.accessibility.XAccessibleContext; +import com.sun.star.accessibility.XAccessibleComponent; +import com.sun.star.accessibility.XAccessibleRelationSet; +import com.sun.star.accessibility.XAccessibleStateSet; + +public class InformationWriter +{ + public InformationWriter (PrintStream aOut) + { + maOut = aOut; + } + + public void drawPageTest (XInterface xPage) + { + try + { + printProperty (xPage, "BorderBottom ", "BorderBottom"); + printProperty (xPage, "BorderLeft ", "BorderLeft"); + printProperty (xPage, "BorderRight ", "BorderRight"); + printProperty (xPage, "BorderTop ", "BorderTop"); + printProperty (xPage, "Height ", "Height"); + printProperty (xPage, "Width ", "Width"); + printProperty (xPage, "Number ", "Number"); + } + catch (Exception e) + { + System.out.println ("caught exception while testing draw page:" + e); + } + } + + public void printProperty (XInterface xObject, String prefix, String name) + { + try + { + XPropertySet xPropertySet = (XPropertySet) UnoRuntime.queryInterface( + XPropertySet.class, xObject); + maOut.println (prefix + + xPropertySet.getPropertyValue (name)); + } + catch (Exception e) + { + maOut.println ("caught exception while getting property " + + name + " : " + e); + } + } + + + + public void showShapes (XDrawPage xPage) + { + try + { + XIndexAccess xShapeList = (XIndexAccess) UnoRuntime.queryInterface( + XIndexAccess.class, xPage); + + maOut.println ("There are " + xShapeList.getCount() + + " shapes"); + for (int i=0; i<xShapeList.getCount(); i++) + { + XShape xShape = (XShape) UnoRuntime.queryInterface( + XShape.class, xShapeList.getByIndex (i)); + + XShapeDescriptor xShapeDescriptor = + (XShapeDescriptor) UnoRuntime.queryInterface( + XShapeDescriptor.class, xShape); + String sName = xShapeDescriptor.getShapeType (); + maOut.println (" shape " + i + " : " + sName); + + XPropertySet xPropertySet = + (XPropertySet) UnoRuntime.queryInterface( + XPropertySet.class, xShape); + Integer nZOrder = + (Integer) xPropertySet.getPropertyValue ("ZOrder"); + maOut.println (" zorder = " + nZOrder); + } + } + catch (Exception e) + { + maOut.println ("caught exception in showShapes: " + e); + } + } + + + + + /** @descr Print all available services of the given object to the + standard output. + */ + public void showServices (XInterface xObject) + { + try + { + maOut.println ("Services:"); + XMultiServiceFactory xMSF = (XMultiServiceFactory) UnoRuntime.queryInterface ( + XMultiServiceFactory.class, + xObject + ); + if (xMSF == null) + maOut.println (" object does not support interface XMultiServiceFactory"); + else + { + String[] sServiceNames = xMSF.getAvailableServiceNames (); + maOut.println (" object can create " + + sServiceNames.length + " services"); + for (int i=0; i<sServiceNames.length; i++) + maOut.println (" service " + i + " : " + sServiceNames[i]); + } + } + catch (Exception e) + { + maOut.println ("caught exception in showServices : " + e); + } + } + + /** @descr Print the service and implementation name of the given + object. + */ + public void showInfo (XInterface xObject) + { + try + { + System.out.println ("Info:"); + // Use interface XServiceName to retrieve name of (main) service. + XServiceName xSN = (XServiceName) UnoRuntime.queryInterface ( + XServiceName.class, xObject); + if (xSN == null) + maOut.println (" interface XServiceName not supported"); + else + { + maOut.println (" Service name : " + xSN.getServiceName ()); + } + + // Use interface XServiceInfo to retrieve information about + // supported services. + XServiceInfo xSI = (XServiceInfo) UnoRuntime.queryInterface ( + XServiceInfo.class, xObject); + if (xSI == null) + maOut.println (" interface XServiceInfo not supported"); + else + { + maOut.println (" Implementation name : " + + xSI.getImplementationName ()); + } + } + catch (Exception e) + { + maOut.println ("caught exception in showInfo : " + e); + } + } + + + + + /** @descr Print information about supported interfaces. + */ + public void showInterfaces (XInterface xObject) + { + try + { + maOut.println ("Interfaces:"); + // Use interface XTypeProvider to retrieve a list of supported + // interfaces. + XTypeProvider xTP = (XTypeProvider) UnoRuntime.queryInterface ( + XTypeProvider.class, xObject); + if (xTP == null) + maOut.println (" interface XTypeProvider not supported"); + else + { + Type[] aTypeList = xTP.getTypes (); + maOut.println (" object supports " + aTypeList.length + + " interfaces"); + for (int i=0; i<aTypeList.length; i++) + maOut.println (" " + i + " : " + + aTypeList[i].getTypeName()); + } + } + catch (Exception e) + { + maOut.println ("caught exception in showInterfaces : " + e); + } + } + + + /** @descr Print information concerning the accessibility of the given + object. + */ + public boolean showAccessibility (XInterface xObject, int depth) + { + try + { + // Create indentation string. + String sIndent = ""; + while (depth-- > 0) + sIndent += " "; + + // Get XAccessibleContext object if given object does not + // already support this interface. + XAccessibleContext xContext + = (XAccessibleContext) UnoRuntime.queryInterface ( + XAccessibleContext.class, xObject); + if (xContext == null) + { + XAccessible xAccessible + = (XAccessible) UnoRuntime.queryInterface ( + XAccessible.class, xObject); + if (xAccessible == null) + { + maOut.println (sIndent + "given object " + xObject + + " is not accessible"); + return false; + } + else + xContext = xAccessible.getAccessibleContext(); + } + + // Print information about the accessible context. + if (xContext != null) + { + maOut.println (sIndent + "Name : " + + xContext.getAccessibleName()); + maOut.println (sIndent + "Description : " + + xContext.getAccessibleDescription()); + maOut.println (sIndent + "Role : " + + xContext.getAccessibleRole()); + String sHasParent; + if (xContext.getAccessibleParent() != null) + { + maOut.println (sIndent + "Has parent : yes"); + maOut.println (sIndent + "Parent index : " + + xContext.getAccessibleIndexInParent()); + } + else + maOut.println (sIndent + "Has parent : no"); + maOut.println (sIndent + "Child count : " + + xContext.getAccessibleChildCount()); + maOut.print (sIndent + "Relation set : "); + XAccessibleRelationSet xRelationSet + = xContext.getAccessibleRelationSet(); + if (xRelationSet != null) + { + maOut.print (xRelationSet.getRelationCount() + " ("); + for (int i=0; i<xRelationSet.getRelationCount(); i++) + { + if (i > 0) + maOut.print (", "); + maOut.print (xRelationSet.getRelation(i).toString()); + } + maOut.println (")"); + } + else + maOut.println ("no relation set"); + + maOut.print (sIndent + "State set : "); + XAccessibleStateSet xStateSet = + xContext.getAccessibleStateSet(); + if (xStateSet != null) + { + XIndexAccess xStates = + (XIndexAccess) UnoRuntime.queryInterface ( + XIndexAccess.class, xStateSet); + maOut.print (xStates.getCount() + " ("); + for (int i=0; i<xStates.getCount(); i++) + { + if (i > 0) + maOut.print (", "); + maOut.print (xStates.getByIndex(i).toString()); + } + maOut.println (")"); + } + else + maOut.println ("no state set"); + + showAccessibleComponent (xContext, sIndent); + } + else + maOut.println ("object has no accessible context."); + + // showInfo (xContext); + // showServices (xContext); + // showInterfaces (xContext); + } + catch (Exception e) + { + System.out.println ("caught exception in showAccessibility :" + e); + } + return true; + } + + + + + /** @descr Print information about the given accessible component. + */ + public void showAccessibleComponent (XInterface xObject, String sIndent) + { + try + { + XAccessibleComponent xComponent = + (XAccessibleComponent) UnoRuntime.queryInterface ( + XAccessibleComponent.class, xObject); + + // Print information about the accessible context. + if (xComponent != null) + { + maOut.println (sIndent + "Position : " + + xComponent.getLocation().X+", " + + xComponent.getLocation().Y); + maOut.println (sIndent + "Screen position : " + + xComponent.getLocationOnScreen().X+", " + + xComponent.getLocationOnScreen().Y); + maOut.println (sIndent + "Size : " + + xComponent.getSize().Width+", " + + xComponent.getSize().Height); + } + } + catch (Exception e) + { + System.out.println ( + "caught exception in showAccessibleComponent : " + e); + } + } + + + /** Show a textual representation of the accessibility subtree rooted in + xRoot. + */ + public boolean showAccessibilityTree (XAccessible xRoot, int depth) + { + try + { + if ( ! showAccessibility (xRoot, depth)) + return false; + + String sIndent = ""; + for (int i=0; i<depth; i++) + sIndent += " "; + + // Iterate over children and show them. + XAccessibleContext xContext = xRoot.getAccessibleContext(); + if (xContext != null) + { + int n = xContext.getAccessibleChildCount(); + for (int i=0; i<n; i++) + { + maOut.println (sIndent + "child " + i + " :"); + showAccessibilityTree (xContext.getAccessibleChild(i),depth+1); + } + } + else + maOut.println ("Accessible object has no context"); + } + catch (Exception e) + { + System.out.println ( + "caught exception in showAccessibleTree : " + e); + return false; + } + + return true; + } + + public void showProperties (XInterface xObject) + { + XPropertySet xSet = (XPropertySet) UnoRuntime.queryInterface ( + XPropertySet.class, xObject); + if (xSet == null) + maOut.println ("object does not support XPropertySet"); + else + { + XPropertySetInfo xInfo = xSet.getPropertySetInfo (); + Property[] aProperties = xInfo.getProperties (); + int n = aProperties.length; + for (int i=0; i<n; i++) + maOut.println (i + " : " + aProperties[i].Name +", " + aProperties[i].Type); + } + } + + private PrintStream maOut; +} diff --git a/accessibility/workben/org/openoffice/accessibility/misc/Makefile b/accessibility/workben/org/openoffice/accessibility/misc/Makefile new file mode 100644 index 000000000..a33a430c0 --- /dev/null +++ b/accessibility/workben/org/openoffice/accessibility/misc/Makefile @@ -0,0 +1,69 @@ +#************************************************************************* +# +# $RCSfile: Makefile,v $ +# +# The Contents of this file are made available subject to the terms of +# either of the following licenses +# +# - GNU Lesser General Public License Version 2.1 +# - Sun Industry Standards Source License Version 1.1 +# +# Sun Microsystems Inc., October, 2000 +# +# GNU Lesser General Public License Version 2.1 +# ============================================= +# Copyright 2000 by Sun Microsystems, Inc. +# 901 San Antonio Road, Palo Alto, CA 94303, USA +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License version 2.1, as published by the Free Software Foundation. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, +# MA 02111-1307 USA +# +# +# Sun Industry Standards Source License Version 1.1 +# ================================================= +# The contents of this file are subject to the Sun Industry Standards +# Source License Version 1.1 (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.openoffice.org/license.html. +# +# Software provided under this License is provided on an "AS IS" basis, +# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, +# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, +# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. +# See the License for the specific provisions governing your rights and +# obligations concerning the Software. +# +# The Initial Developer of the Original Code is: Sun Microsystems, Inc. +# +# Copyright: 2000 by Sun Microsystems, Inc. +# +# All Rights Reserved. +# +# Contributor(s): _______________________________________ +# +# +# +#************************************************************************* + +all : package + +ROOT=../../../.. +PACKAGE = org.openoffice.accessibility.misc +SUBDIRS = + +include makefile.common + +include $(ROOT)/makefile.in + +package: subdirs $(CLASS_FILES) diff --git a/accessibility/workben/org/openoffice/accessibility/misc/MessageArea.java b/accessibility/workben/org/openoffice/accessibility/misc/MessageArea.java new file mode 100644 index 000000000..1060d91eb --- /dev/null +++ b/accessibility/workben/org/openoffice/accessibility/misc/MessageArea.java @@ -0,0 +1,125 @@ +package org.openoffice.accessibility.misc; + +import java.awt.Font; +import java.awt.Rectangle; +import java.awt.Color; +import java.awt.Graphics; +import javax.swing.JScrollPane; +import javax.swing.JTextArea; +import javax.swing.JScrollBar; + + + +/** A message area displays text in a scrollable text widget. It is a + singleton. Other objects can access it directly to display messages. +*/ +public class MessageArea + extends JScrollPane +{ + public static synchronized MessageArea Instance () + { + if (saInstance == null) + saInstance = new MessageArea (); + return saInstance; + } + + + + + /** Create a new message area. This method is private because the class is + a singleton and may therefore not be instanciated from the outside. + */ + private MessageArea () + { + maText = new JTextArea(); + maText.setBackground (new Color (255,250,240)); + maText.setFont (new Font ("Helvetica", Font.PLAIN, 9)); + setViewportView (maText); + setVerticalScrollBarPolicy (JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); + setHorizontalScrollBarPolicy (JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); + + printMessage ( + "class path is " + System.getProperty ("java.class.path") + "\n"); + } + + + + + /** Show the given string at the end of the message area and scroll to make + it visible. + */ + public static synchronized void print (String aMessage) + { + print (0, aMessage); + } + + + + + /** Show the given string at the end of the message area and scroll to make + it visible. Indent the string as requested. + */ + public static synchronized void print (int nIndentation, String aMessage) + { + while (nIndentation-- > 0) + aMessage = " " + aMessage; + Instance().printMessage(aMessage); + } + + + + + /** Show the given string at the end of the message area and scroll to make + it visible. + */ + public static void println (String aMessage) + { + println (0, aMessage); + } + + + + + /** Show the given string at the end of the message area and scroll to make + it visible. + */ + public static void println (int nIndentation, String aMessage) + { + print (nIndentation, aMessage+"\n"); + } + + + + + public void paintComponent (Graphics g) + { + synchronized (g) + { + JScrollBar sb = getVerticalScrollBar(); + if (sb != null) + { + int nScrollBarValue = sb.getMaximum() - sb.getVisibleAmount() - 1; + sb.setValue (nScrollBarValue); + } + super.paintComponent (g); + } + } + + + + + /** Append the given string to the end of the text and scroll so that it + becomes visible. This is an internal method. Use one of the static + and public ones. + */ + private synchronized void printMessage (String aMessage) + { + maText.append (aMessage); + } + + + + + private static MessageArea saInstance = null; + private JTextArea maText; +} diff --git a/accessibility/workben/org/openoffice/accessibility/misc/NameProvider.java b/accessibility/workben/org/openoffice/accessibility/misc/NameProvider.java new file mode 100644 index 000000000..db8d2b0ab --- /dev/null +++ b/accessibility/workben/org/openoffice/accessibility/misc/NameProvider.java @@ -0,0 +1,263 @@ +package org.openoffice.accessibility.misc; + +import java.util.HashMap; +import com.sun.star.accessibility.AccessibleStateType; +import com.sun.star.accessibility.AccessibleEventId; +import com.sun.star.accessibility.AccessibleRole; +import com.sun.star.accessibility.AccessibleRelationType; + + +/** Provide names for several accessibility constants groups. +*/ +public class NameProvider +{ + /** Return the name of the specified state. + @param nStateId + Id of the state for which to return its name. This is one of + the ids listed in the <type>AccessibleStateType</const> + constants group. + @return + Returns the name of the specified state. When an invalid or + unknown state id is given then a special string is returned that + says that the state does not exist. + */ + public static String getStateName (int nStateId) + { + String sStateName = (String)maStateMap.get (new Integer(nStateId)); + if (sStateName == null) + sStateName = new String ("<unknown state " + nStateId + ">"); + return sStateName; + } + + + /** Return the name of the specified event. + @param nEventId + Id of the event type for which to return its name. This is one + of the ids listed in the <type>AccessibleEventId</const> + constants group. + @return + Returns the name of the specified event type or an empty string + if an invalid / unknown event id was given. + */ + public static String getEventName (int nEventId) + { + return (String)maEventMap.get (new Integer(nEventId)); + } + + + /** Return the name of the specified role. + @param nRole + Id of the role for which to return its name. This is one of + the ids listed in the <type>AccessibleRole</const> + constants group. + @return + Returns the name of the specified role or an empty string if an + invalid / unknown role id was given. + */ + public static String getRoleName (int nRole) + { + return (String)maRoleMap.get (new Integer(nRole)); + } + + + /** Return the name of the specified relation. + @param nRelation + Id of the relation for which to return its name. This is one of + the ids listed in the <type>AccessibleRelationType</const> + constants group. + @return + Returns the name of the specified relation type or an empty + string if an invalid / unknown role id was given. + */ + public static String getRelationName (int nRelation) + { + return (String)maRelationMap.get (new Integer(nRelation)); + } + + + private static HashMap maStateMap = new HashMap(); + private static HashMap maEventMap = new HashMap(); + private static HashMap maRoleMap = new HashMap(); + private static HashMap maRelationMap = new HashMap(); + + static { + maStateMap.put (new Integer (AccessibleStateType.INVALID), "INVALID"); + maStateMap.put (new Integer (AccessibleStateType.ACTIVE), "ACTIVE"); + maStateMap.put (new Integer (AccessibleStateType.ARMED), "ARMED"); + maStateMap.put (new Integer (AccessibleStateType.BUSY), "BUSY"); + maStateMap.put (new Integer (AccessibleStateType.CHECKED), "CHECKED"); + // maStateMap.put (new Integer (AccessibleStateType.COLLAPSED), "COLLAPSED"); + maStateMap.put (new Integer (AccessibleStateType.DEFUNC), "DEFUNC"); + maStateMap.put (new Integer (AccessibleStateType.EDITABLE), "EDITABLE"); + maStateMap.put (new Integer (AccessibleStateType.ENABLED), "ENABLED"); + maStateMap.put (new Integer (AccessibleStateType.EXPANDABLE), "EXPANDABLE"); + maStateMap.put (new Integer (AccessibleStateType.EXPANDED), "EXPANDED"); + maStateMap.put (new Integer (AccessibleStateType.FOCUSABLE), "FOCUSABLE"); + maStateMap.put (new Integer (AccessibleStateType.FOCUSED), "FOCUSED"); + maStateMap.put (new Integer (AccessibleStateType.HORIZONTAL), "HORIZONTAL"); + maStateMap.put (new Integer (AccessibleStateType.ICONIFIED), "ICONIFIED"); + maStateMap.put (new Integer (AccessibleStateType.MODAL), "MODAL"); + maStateMap.put (new Integer (AccessibleStateType.MULTI_LINE), "MULTI_LINE"); + maStateMap.put (new Integer (AccessibleStateType.MULTI_SELECTABLE), "MULTI_SELECTABLE"); + maStateMap.put (new Integer (AccessibleStateType.OPAQUE), "OPAQUE"); + maStateMap.put (new Integer (AccessibleStateType.PRESSED), "PRESSED"); + maStateMap.put (new Integer (AccessibleStateType.RESIZABLE), "RESIZABLE"); + maStateMap.put (new Integer (AccessibleStateType.SELECTABLE), "SELECTABLE"); + maStateMap.put (new Integer (AccessibleStateType.SELECTED), "SELECTED"); + maStateMap.put (new Integer (AccessibleStateType.SENSITIVE), "SENSITIVE"); + maStateMap.put (new Integer (AccessibleStateType.SHOWING), "SHOWING"); + maStateMap.put (new Integer (AccessibleStateType.SINGLE_LINE), "SINGLE_LINE"); + maStateMap.put (new Integer (AccessibleStateType.STALE), "STALE"); + maStateMap.put (new Integer (AccessibleStateType.TRANSIENT), "TRANSIENT"); + maStateMap.put (new Integer (AccessibleStateType.VERTICAL), "VERTICAL"); + maStateMap.put (new Integer (AccessibleStateType.VISIBLE), "VISIBLE"); + maStateMap.put (new Integer (AccessibleStateType.MANAGES_DESCENDANTS), + "MANAGES_DESCENDANTS"); + //maStateMap.put (new Integer (AccessibleStateType.INCONSISTENT),"INCONSISTENT"); + + + maEventMap.put (new Integer (0), + "[UNKNOWN]"); + maEventMap.put (new Integer (AccessibleEventId.NAME_CHANGED), + "NAME_CHANGED"); + maEventMap.put (new Integer (AccessibleEventId.DESCRIPTION_CHANGED), + "DESCRIPTION_CHANGED"); + maEventMap.put (new Integer (AccessibleEventId.ACTION_CHANGED), + "ACTION_CHANGED"); + maEventMap.put (new Integer (AccessibleEventId.STATE_CHANGED), + "STATE_CHANGED"); + maEventMap.put (new Integer (AccessibleEventId.ACTIVE_DESCENDANT_CHANGED), + "ACTIVE_DESCENDANT_CHANGED"); + maEventMap.put (new Integer (AccessibleEventId.BOUNDRECT_CHANGED), + "BOUNDRECT_CHANGED"); + maEventMap.put (new Integer (AccessibleEventId.CHILD), + "CHILD"); + maEventMap.put (new Integer (AccessibleEventId.INVALIDATE_ALL_CHILDREN), + "INVALIDATE_ALL_CHILDREN"); + maEventMap.put (new Integer (AccessibleEventId.SELECTION_CHANGED), + "SELECTION_CHANGED"); + maEventMap.put (new Integer (AccessibleEventId.VISIBLE_DATA_CHANGED), + "VISIBLE_DATA_CHANGED"); + maEventMap.put (new Integer (AccessibleEventId.VALUE_CHANGED), + "VALUE_CHANGED"); + maEventMap.put (new Integer (AccessibleEventId.CONTENT_FLOWS_FROM_RELATION_CHANGED), + "CONTENT_FLOWS_FROM_RELATION_CHANGED"); + maEventMap.put (new Integer (AccessibleEventId.CONTENT_FLOWS_TO_RELATION_CHANGED), + "CONTENT_FLOWS_TO_RELATION_CHANGED"); + maEventMap.put (new Integer (AccessibleEventId.CONTROLLED_BY_RELATION_CHANGED), + "CONTROLLED_BY_RELATION_CHANGED"); + maEventMap.put (new Integer (AccessibleEventId.CONTROLLER_FOR_RELATION_CHANGED), + "CONTROLLER_FOR_RELATION_CHANGED"); + maEventMap.put (new Integer (AccessibleEventId.LABEL_FOR_RELATION_CHANGED), + "LABEL_FOR_RELATION_CHANGED"); + maEventMap.put (new Integer (AccessibleEventId.LABELED_BY_RELATION_CHANGED), + "LABELED_BY_RELATION_CHANGED"); + maEventMap.put (new Integer (AccessibleEventId.MEMBER_OF_RELATION_CHANGED), + "MEMBER_OF_RELATION_CHANGED"); + maEventMap.put (new Integer (AccessibleEventId.SUB_WINDOW_OF_RELATION_CHANGED), + "SUB_WINDOW_OF_RELATION_CHANGED"); + maEventMap.put (new Integer (AccessibleEventId.CARET_CHANGED), + "CARET_CHANGED"); + maEventMap.put (new Integer (AccessibleEventId.TEXT_SELECTION_CHANGED), + "TEXT_SELECTION_CHANGED"); + maEventMap.put (new Integer (AccessibleEventId.TEXT_CHANGED), + "TEXT_CHANGED"); + maEventMap.put (new Integer (AccessibleEventId.TEXT_ATTRIBUTE_CHANGED), + "TEXT_ATTRIBUTE_CHANGED"); + maEventMap.put (new Integer (AccessibleEventId.HYPERTEXT_CHANGED), + "HYPERTEXT_CHANGED"); + maEventMap.put (new Integer (AccessibleEventId.TABLE_CAPTION_CHANGED), + "TABLE_CAPTION_CHANGED"); + maEventMap.put (new Integer (AccessibleEventId.TABLE_COLUMN_DESCRIPTION_CHANGED), + "TABLE_COLUMN_DESCRIPTION_CHANGED"); + maEventMap.put (new Integer (AccessibleEventId.TABLE_COLUMN_HEADER_CHANGED), + "TABLE_COLUMN_HEADER_CHANGED"); + maEventMap.put (new Integer (AccessibleEventId.TABLE_MODEL_CHANGED), + "TABLE_MODEL_CHANGED"); + maEventMap.put (new Integer (AccessibleEventId.TABLE_ROW_DESCRIPTION_CHANGED), + "TABLE_ROW_DESCRIPTION_CHANGED"); + maEventMap.put (new Integer (AccessibleEventId.TABLE_ROW_HEADER_CHANGED), + "TABLE_ROW_HEADER_CHANGED"); + maEventMap.put (new Integer (AccessibleEventId.TABLE_SUMMARY_CHANGED), + "TABLE_SUMMARY_CHANGED"); + + maRoleMap.put (new Integer(AccessibleRole.UNKNOWN), "UNKNOWN"); + maRoleMap.put (new Integer (AccessibleRole.UNKNOWN), "UNKNOWN"); + maRoleMap.put (new Integer (AccessibleRole.ALERT), "ALERT"); + maRoleMap.put (new Integer (AccessibleRole.COLUMN_HEADER), "COLUMN_HEADER"); + maRoleMap.put (new Integer (AccessibleRole.CANVAS), "CANVAS"); + maRoleMap.put (new Integer (AccessibleRole.CHECK_BOX), "CHECK_BOX"); + maRoleMap.put (new Integer (AccessibleRole.CHECK_MENU_ITEM), "CHECK_MENU_ITEM"); + maRoleMap.put (new Integer (AccessibleRole.COLOR_CHOOSER), "COLOR_CHOOSER"); + maRoleMap.put (new Integer (AccessibleRole.COMBO_BOX), "COMBO_BOX"); + maRoleMap.put (new Integer (AccessibleRole.DESKTOP_ICON), "DESKTOP_ICON"); + maRoleMap.put (new Integer (AccessibleRole.DESKTOP_PANE), "DESKTOP_PANE"); + maRoleMap.put (new Integer (AccessibleRole.DIRECTORY_PANE), "DIRECTORY_PANE"); + maRoleMap.put (new Integer (AccessibleRole.DIALOG), "DIALOG"); + maRoleMap.put (new Integer (AccessibleRole.DOCUMENT), "DOCUMENT"); + maRoleMap.put (new Integer (AccessibleRole.EMBEDDED_OBJECT), "EMBEDDED_OBJECT"); + maRoleMap.put (new Integer (AccessibleRole.END_NOTE), "END_NOTE"); + maRoleMap.put (new Integer (AccessibleRole.FILE_CHOOSER), "FILE_CHOOSER"); + maRoleMap.put (new Integer (AccessibleRole.FILLER), "FILLER"); + maRoleMap.put (new Integer (AccessibleRole.FONT_CHOOSER), "FONT_CHOOSER"); + maRoleMap.put (new Integer (AccessibleRole.FOOTER), "FOOTER"); + maRoleMap.put (new Integer (AccessibleRole.FOOTNOTE), "FOOTNOTE"); + maRoleMap.put (new Integer (AccessibleRole.FRAME), "FRAME"); + maRoleMap.put (new Integer (AccessibleRole.GLASS_PANE), "GLASS_PANE"); + maRoleMap.put (new Integer (AccessibleRole.GRAPHIC), "GRAPHIC"); + maRoleMap.put (new Integer (AccessibleRole.GROUP_BOX), "GROUP_BOX"); + maRoleMap.put (new Integer (AccessibleRole.HEADER), "HEADER"); + maRoleMap.put (new Integer (AccessibleRole.HEADING), "HEADING"); + maRoleMap.put (new Integer (AccessibleRole.HYPER_LINK), "HYPER_LINK"); + maRoleMap.put (new Integer (AccessibleRole.ICON), "ICON"); + maRoleMap.put (new Integer (AccessibleRole.INTERNAL_FRAME), "INTERNAL_FRAME"); + maRoleMap.put (new Integer (AccessibleRole.LABEL), "LABEL"); + maRoleMap.put (new Integer (AccessibleRole.LAYERED_PANE), "LAYERED_PANE"); + maRoleMap.put (new Integer (AccessibleRole.LIST), "LIST"); + maRoleMap.put (new Integer (AccessibleRole.LIST_ITEM), "LIST_ITEM"); + maRoleMap.put (new Integer (AccessibleRole.MENU), "MENU"); + maRoleMap.put (new Integer (AccessibleRole.MENU_BAR), "MENU_BAR"); + maRoleMap.put (new Integer (AccessibleRole.MENU_ITEM), "MENU_ITEM"); + maRoleMap.put (new Integer (AccessibleRole.OPTION_PANE), "OPTION_PANE"); + maRoleMap.put (new Integer (AccessibleRole.PAGE_TAB), "PAGE_TAB"); + maRoleMap.put (new Integer (AccessibleRole.PAGE_TAB_LIST), "PAGE_TAB_LIST"); + maRoleMap.put (new Integer (AccessibleRole.PANEL), "PANEL"); + maRoleMap.put (new Integer (AccessibleRole.PARAGRAPH), "PARAGRAPH"); + maRoleMap.put (new Integer (AccessibleRole.PASSWORD_TEXT), "PASSWORD_TEXT"); + maRoleMap.put (new Integer (AccessibleRole.POPUP_MENU), "POPUP_MENU"); + maRoleMap.put (new Integer (AccessibleRole.PUSH_BUTTON), "PUSH_BUTTON"); + maRoleMap.put (new Integer (AccessibleRole.PROGRESS_BAR), "PROGRESS_BAR"); + maRoleMap.put (new Integer (AccessibleRole.RADIO_BUTTON), "RADIO_BUTTON"); + maRoleMap.put (new Integer (AccessibleRole.RADIO_MENU_ITEM), "RADIO_MENU_ITEM"); + maRoleMap.put (new Integer (AccessibleRole.ROW_HEADER), "ROW_HEADER"); + maRoleMap.put (new Integer (AccessibleRole.ROOT_PANE), "ROOT_PANE"); + maRoleMap.put (new Integer (AccessibleRole.SCROLL_BAR), "SCROLL_BAR"); + maRoleMap.put (new Integer (AccessibleRole.SCROLL_PANE), "SCROLL_PANE"); + maRoleMap.put (new Integer (AccessibleRole.SHAPE), "SHAPE"); + maRoleMap.put (new Integer (AccessibleRole.SEPARATOR), "SEPARATOR"); + maRoleMap.put (new Integer (AccessibleRole.SLIDER), "SLIDER"); + maRoleMap.put (new Integer (AccessibleRole.SPIN_BOX), "SPIN_BOX"); + maRoleMap.put (new Integer (AccessibleRole.SPLIT_PANE), "SPLIT_PANE"); + maRoleMap.put (new Integer (AccessibleRole.STATUS_BAR), "STATUS_BAR"); + maRoleMap.put (new Integer (AccessibleRole.TABLE), "TABLE"); + maRoleMap.put (new Integer (AccessibleRole.TABLE_CELL), "TABLE_CELL"); + maRoleMap.put (new Integer (AccessibleRole.TEXT), "TEXT"); + maRoleMap.put (new Integer (AccessibleRole.TEXT_FRAME), "TEXT_FRAME"); + maRoleMap.put (new Integer (AccessibleRole.TOGGLE_BUTTON), "TOGGLE_BUTTON"); + maRoleMap.put (new Integer (AccessibleRole.TOOL_BAR), "TOOL_BAR"); + maRoleMap.put (new Integer (AccessibleRole.TOOL_TIP), "TOOL_TIP"); + maRoleMap.put (new Integer (AccessibleRole.TREE), "TREE"); + maRoleMap.put (new Integer (AccessibleRole.VIEW_PORT), "VIEW_PORT"); + maRoleMap.put (new Integer (AccessibleRole.WINDOW), "WINDOW"); + + maRelationMap.put (new Integer (AccessibleRelationType.INVALID), "INVALID"); + maRelationMap.put (new Integer (AccessibleRelationType.CONTENT_FLOWS_FROM), "CONTENT_FLOWS_FROM"); + maRelationMap.put (new Integer (AccessibleRelationType.CONTENT_FLOWS_TO), "CONTENT_FLOWS_TO"); + maRelationMap.put (new Integer (AccessibleRelationType.CONTROLLED_BY), "CONTROLLED_BY"); + maRelationMap.put (new Integer (AccessibleRelationType.CONTROLLER_FOR), "CONTROLLER_FOR"); + maRelationMap.put (new Integer (AccessibleRelationType.LABEL_FOR), "LABEL_FOR"); + maRelationMap.put (new Integer (AccessibleRelationType.LABELED_BY), "LABELED_BY"); + maRelationMap.put (new Integer (AccessibleRelationType.MEMBER_OF), "MEMBER_OF"); + maRelationMap.put (new Integer (AccessibleRelationType.SUB_WINDOW_OF), "SUB_WINDOW_OF"); + } +} diff --git a/accessibility/workben/org/openoffice/accessibility/misc/OfficeConnection.java b/accessibility/workben/org/openoffice/accessibility/misc/OfficeConnection.java new file mode 100644 index 000000000..03e086f1d --- /dev/null +++ b/accessibility/workben/org/openoffice/accessibility/misc/OfficeConnection.java @@ -0,0 +1,169 @@ +package org.openoffice.accessibility.misc; + +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.io.PrintStream; +import java.util.Timer; +import java.util.TimerTask; +import java.util.Vector; + +import com.sun.star.uno.UnoRuntime; +import com.sun.star.bridge.XUnoUrlResolver; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.comp.helper.Bootstrap; + +/** This class establishes a connection to a StarOffice application. + */ +public class OfficeConnection + extends TimerTask +{ + final public static long snDelay = 3000; + + public static synchronized OfficeConnection Instance () + { + if (saInstance == null) + saInstance = new OfficeConnection (); + return saInstance; + } + + + + + static public void SetPipeName (String sPipeName) + { + ssDefaultPipeName = sPipeName; + } + + + + + public void AddConnectionListener (ActionListener aListener) + { + SimpleOffice aOffice = SimpleOffice.Instance(); + if (IsValid()) + aListener.actionPerformed ( + new ActionEvent (aOffice,0,"<connected>")); + maListeners.add (aListener); + } + + + + /** @descr Return the service manager that represents the connected + StarOffice application + */ + public XMultiServiceFactory GetServiceManager () + { + return maServiceManager; + } + + + + + /** Return a flag that indicates if the constructor has been able to + establish a valid connection. + */ + public boolean IsValid () + { + return (maServiceManager != null); + } + + + + + /** Connect to a already running StarOffice application that has + been started with a command line argument like + "-accept=pipe,name=<username>;urp;" + */ + private boolean Connect () + { + mbInitialized = true; + // Set up connection string. + String sConnectString = "uno:pipe,name=" + msPipeName + + ";urp;StarOffice.ServiceManager"; + + // connect to a running office and get the ServiceManager + try + { + // Create a URL Resolver. + XMultiServiceFactory aLocalServiceManager = + Bootstrap.createSimpleServiceManager(); + XUnoUrlResolver aURLResolver = + (XUnoUrlResolver) UnoRuntime.queryInterface ( + XUnoUrlResolver.class, + aLocalServiceManager.createInstance ( + "com.sun.star.bridge.UnoUrlResolver") + ); + + maServiceManager = + (XMultiServiceFactory) UnoRuntime.queryInterface ( + XMultiServiceFactory.class, + aURLResolver.resolve (sConnectString) + ); + } + + catch (Exception e) + { + if (maOut != null) + { + maOut.println ("Could not connect with " + + sConnectString + " : " + e); + maOut.println ("Please start OpenOffice/StarOffice with " + + "\"-accept=pipe,name=" + msPipeName + ";urp;\""); + } + } + + return maServiceManager != null; + } + + + public void run () + { + if ( ! IsValid()) + { + MessageArea.println ("trying to connect"); + if (Connect()) + { + // Stop the timer. + cancel (); + + ActionEvent aEvent = new ActionEvent (this,0,"<connected>"); + for (int i=0; i<maListeners.size(); i++) + ((ActionListener)maListeners.elementAt(i)).actionPerformed(aEvent); + } + } + } + + private OfficeConnection () + { + this (null); + } + + + private OfficeConnection (PrintStream aOut) + { + msPipeName = ssDefaultPipeName; + maOut = aOut; + maListeners = new Vector(); + maServiceManager = null; + + maTimer = new Timer (true); + maTimer.schedule (this, 0, snDelay); + } + + + private static OfficeConnection saInstance = null; + private static String ssDefaultPipeName = System.getenv( "USER" ); + + private XMultiServiceFactory maServiceManager; + String msPipeName; + + /** A value of true just indicates that it has been tried to establish a connection, + not that that has been successfull. + */ + private boolean mbInitialized = false; + + /// Stream used to print messages. + private PrintStream maOut; + private Timer maTimer; + private Vector maListeners; +} diff --git a/accessibility/workben/org/openoffice/accessibility/misc/Options.java b/accessibility/workben/org/openoffice/accessibility/misc/Options.java new file mode 100644 index 000000000..a40031156 --- /dev/null +++ b/accessibility/workben/org/openoffice/accessibility/misc/Options.java @@ -0,0 +1,106 @@ +package org.openoffice.accessibility.misc; + +import java.io.File; +import java.io.FileReader; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.util.Properties; + + +/** Load from and save options into a file. +*/ +public class Options + extends Properties +{ + static public Options Instance () + { + if (saOptions == null) + saOptions = new Options (); + return saOptions; + } + + static public void SetString (String sName, String sValue) + { + Instance().setProperty (sName, sValue); + Instance().Save (); + } + + static public String GetString (String sName) + { + return Instance().getProperty (sName); + } + + static public void SetBoolean (String sName, boolean bValue) + { + Instance().setProperty (sName, Boolean.toString(bValue)); + Instance().Save (); + } + + static public boolean GetBoolean (String sName) + { + return Boolean.valueOf(Instance().getProperty (sName)).booleanValue(); + } + + static public void SetInteger (String sName, int nValue) + { + Instance().setProperty (sName, Integer.toString(nValue)); + Instance().Save (); + } + + static public int GetInteger (String sName, int nDefault) + { + String sValue = Instance().getProperty (sName); + if (sValue == null) + return nDefault; + else + return Integer.parseInt (sValue); + } + + public void Load (String sBaseName) + { + try + { + load (new FileInputStream (ProvideFile(sBaseName))); + } + catch (java.io.IOException e) + { + // Ignore a non-existing options file. + } + } + + public void Save (String sBaseName) + { + ProvideFile(sBaseName); + Save (); + } + + public void Save () + { + if (maFile != null) + { + try + { + store (new FileOutputStream (maFile), null); + } + catch (java.io.IOException e) + { + } + } + } + + private Options () + { + maFile = null; + } + + private File ProvideFile (String sBaseName) + { + maFile = new File ( + System.getProperty ("user.home"), + sBaseName); + return maFile; + } + + static private Options saOptions = null; + private File maFile; +} diff --git a/accessibility/workben/org/openoffice/accessibility/misc/SimpleOffice.java b/accessibility/workben/org/openoffice/accessibility/misc/SimpleOffice.java new file mode 100644 index 000000000..343ccfc40 --- /dev/null +++ b/accessibility/workben/org/openoffice/accessibility/misc/SimpleOffice.java @@ -0,0 +1,413 @@ +package org.openoffice.accessibility.misc; + +import java.lang.Thread; + +import com.sun.star.awt.Rectangle; +import com.sun.star.awt.XExtendedToolkit; +import com.sun.star.awt.XWindow; + +import com.sun.star.beans.PropertyValue; +import com.sun.star.beans.XPropertySet; + +import com.sun.star.container.XIndexAccess; +import com.sun.star.container.XChild; +import com.sun.star.container.XEnumerationAccess; +import com.sun.star.container.XEnumeration; + +import com.sun.star.frame.XComponentLoader; +import com.sun.star.frame.XController; +import com.sun.star.frame.XDesktop; +import com.sun.star.frame.XFrame; +import com.sun.star.frame.XModel; +import com.sun.star.frame.XTasksSupplier; +import com.sun.star.frame.XTask; + +import com.sun.star.lang.XComponent; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.lang.XServiceInfo; +import com.sun.star.lang.XServiceName; +import com.sun.star.lang.XTypeProvider; + +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.uno.Type; + +import com.sun.star.drawing.XDrawView; +import com.sun.star.drawing.XDrawPage; +import com.sun.star.drawing.XShapes; +import com.sun.star.drawing.XShape; +import com.sun.star.drawing.XShapeDescriptor; + +import com.sun.star.accessibility.XAccessible; +import com.sun.star.accessibility.XAccessibleContext; +import com.sun.star.accessibility.XAccessibleComponent; +import com.sun.star.accessibility.XAccessibleRelationSet; +import com.sun.star.accessibility.XAccessibleStateSet; + + +/** This singleton class tries to simplify some tasks like loading a document + or getting various objects. +*/ +public class SimpleOffice +{ + synchronized static public SimpleOffice Instance () + { + if (saInstance == null) + saInstance = new SimpleOffice (); + + return saInstance; + } + + synchronized static public void Clear () + { + saInstance = null; + } + + + public XModel LoadDocument (String URL) + { + XModel xModel = null; + try + { + // Load the document from the specified URL. + XComponentLoader xLoader = + (XComponentLoader)UnoRuntime.queryInterface( + XComponentLoader.class, mxDesktop); + + XComponent xComponent = xLoader.loadComponentFromURL ( + URL, + "_blank", + 0, + new PropertyValue[0] + ); + + xModel = (XModel) UnoRuntime.queryInterface( + XModel.class, xComponent); + } + catch (java.lang.NullPointerException e) + { + MessageArea.println ("caught exception while loading " + + URL + " : " + e); + } + catch (Exception e) + { + MessageArea.println ("caught exception while loading " + + URL + " : " + e); + } + return xModel; + } + + + + + public XModel GetModel (String name) + { + XModel xModel = null; + try + { + XTasksSupplier xTasksSupplier = + (XTasksSupplier) UnoRuntime.queryInterface( + XTasksSupplier.class, mxDesktop); + XEnumerationAccess xEA = xTasksSupplier.getTasks(); + XEnumeration xE = xEA.createEnumeration(); + while (xE.hasMoreElements()) + { + XTask xTask = (XTask) UnoRuntime.queryInterface( + XTask.class, xE.nextElement()); + MessageArea.print (xTask.getName()); + } + } + catch (Exception e) + { + MessageArea.println ("caught exception while getting Model " + name + + ": " + e); + } + return xModel; + } + + + public XModel GetModel (XDrawView xView) + { + XController xController = (XController) UnoRuntime.queryInterface( + XController.class, xView); + if (xController != null) + return xController.getModel(); + else + { + MessageArea.println ("can't cast view to controller"); + return null; + } + } + + + + + public XDesktop GetDesktop () + { + if (mxDesktop != null) + return mxDesktop; + try + { + // Get the factory of the connected office. + XMultiServiceFactory xMSF = + OfficeConnection.Instance().GetServiceManager (); + if (xMSF == null) + { + MessageArea.println ("can't connect to office"); + return null; + } + else + MessageArea.println ("Connected successfully."); + + // Create a new desktop. + mxDesktop = (XDesktop) UnoRuntime.queryInterface( + XDesktop.class, + xMSF.createInstance ("com.sun.star.frame.Desktop") + ); + } + catch (Exception e) + { + MessageArea.println ("caught exception while creating desktop: " + + e); + } + + return mxDesktop; + } + + + /** Return a reference to the extended toolkit which is a broadcaster of + top window, key, and focus events. + */ + public XExtendedToolkit GetExtendedToolkit () + { + XExtendedToolkit xToolkit = null; + if (this != null) + try + { + // Get the factory of the connected office. + XMultiServiceFactory xMSF = + OfficeConnection.Instance().GetServiceManager (); + if (xMSF != null) + { + xToolkit = (XExtendedToolkit) UnoRuntime.queryInterface( + XExtendedToolkit.class, + xMSF.createInstance ("stardiv.Toolkit.VCLXToolkit") + ); + } + } + catch (Exception e) + { + MessageArea.println ( + "caught exception while creating extended toolkit: " + e); + } + + return xToolkit; + } + + + + static public XAccessible GetAccessibleObject (XInterface xObject) + { + XAccessible xAccessible = null; + try + { + xAccessible = (XAccessible) UnoRuntime.queryInterface( + XAccessible.class, xObject); + } + catch (Exception e) + { + System.err.println ( + "caught exception while getting accessible object" + e); + e.printStackTrace (System.err); + } + return xAccessible; + } + + static public XAccessibleContext GetAccessibleContext (XInterface xObject) + { + XAccessible xAccessible = GetAccessibleObject (xObject); + if (xAccessible != null) + return xAccessible.getAccessibleContext(); + else + return null; + } + + /** Return the root object of the accessibility hierarchy. + */ + public XAccessible GetAccessibleRoot (XAccessible xAccessible) + { + try + { + XAccessible xParent = null; + do + { + XAccessibleContext xContext = xAccessible.getAccessibleContext(); + if (xContext != null) + xParent = xContext.getAccessibleParent(); + if (xParent != null) + xAccessible = xParent; + } + while (xParent != null); + } + catch (Exception e) + { + MessageArea.println ( + "caught exception while getting accessible root" + e); + e.printStackTrace(); + } + return xAccessible; + } + + + + + /** @descr Return the current window associated with the given + model. + */ + public XWindow GetCurrentWindow () + { + return GetCurrentWindow ((XModel) UnoRuntime.queryInterface( + XModel.class, GetDesktop())); + } + + + + + + public XWindow GetCurrentWindow (XModel xModel) + { + XWindow xWindow = null; + try + { + if (xModel == null) + MessageArea.println ("invalid model (==null)"); + XController xController = xModel.getCurrentController(); + if (xController == null) + MessageArea.println ("can't get controller from model"); + XFrame xFrame = xController.getFrame(); + if (xFrame == null) + MessageArea.println ("can't get frame from controller"); + xWindow = xFrame.getComponentWindow (); + if (xWindow == null) + MessageArea.println ("can't get window from frame"); + } + catch (Exception e) + { + MessageArea.println ("caught exception while getting current window" + e); + } + + return xWindow; + } + + + /** @descr Return the current draw page of the given desktop. + */ + public XDrawPage GetCurrentDrawPage () + { + return GetCurrentDrawPage ( + (XDrawView) UnoRuntime.queryInterface( + XDrawView.class, + GetCurrentView())); + } + + + + + public XDrawPage GetCurrentDrawPage (XDrawView xView) + { + XDrawPage xPage = null; + try + { + if (xView == null) + MessageArea.println ("can't get current draw page from null view"); + else + xPage = xView.getCurrentPage(); + } + catch (Exception e) + { + MessageArea.println ("caught exception while getting current draw page : " + e); + } + + return xPage; + } + + + + + /** @descr Return the current view of the given desktop. + */ + public XDrawView GetCurrentView () + { + return GetCurrentView (GetDesktop()); + } + + public XDrawView GetCurrentView (XDesktop xDesktop) + { + if (xDesktop == null) + MessageArea.println ("can't get desktop to retrieve current view"); + + XDrawView xView = null; + try + { + XComponent xComponent = xDesktop.getCurrentComponent(); + if (xComponent == null) + MessageArea.println ("can't get component to retrieve current view"); + + XFrame xFrame = xDesktop.getCurrentFrame(); + if (xFrame == null) + MessageArea.println ("can't get frame to retrieve current view"); + + XController xController = xFrame.getController(); + if (xController == null) + MessageArea.println ("can't get controller to retrieve current view"); + + xView = (XDrawView) UnoRuntime.queryInterface( + XDrawView.class, xController); + if (xView == null) + MessageArea.println ("could not cast controller into view"); + } + catch (Exception e) + { + MessageArea.println ("caught exception while getting current view : " + e); + } + + return xView; + } + + + + + // Return the accessible object of the document window. + public static XAccessible GetAccessibleDocumentWindow (XDrawPage xPage) + { + XIndexAccess xShapeList = (XIndexAccess) UnoRuntime.queryInterface( + XIndexAccess.class, xPage); + if (xShapeList.getCount() > 0) + { + // All shapes return as accessible object the document window's + // accessible object. This is, of course, a hack and will be + // removed as soon as the missing infrastructure for obtaining + // the object directly is implemented. + XShape xShape = null; + try{ + xShape = (XShape) UnoRuntime.queryInterface( + XShape.class, xShapeList.getByIndex (0)); + } catch (Exception e) + {} + XAccessible xAccessible = (XAccessible) UnoRuntime.queryInterface ( + XAccessible.class, xShape); + return xAccessible; + } + else + return null; + } + + private SimpleOffice () + { + } + + + + private XDesktop mxDesktop; + private static SimpleOffice saInstance = null; +} diff --git a/accessibility/workben/org/openoffice/accessibility/misc/makefile.common b/accessibility/workben/org/openoffice/accessibility/misc/makefile.common new file mode 100644 index 000000000..d06336e12 --- /dev/null +++ b/accessibility/workben/org/openoffice/accessibility/misc/makefile.common @@ -0,0 +1,67 @@ +#************************************************************************* +# +# $RCSfile: makefile.common,v $ +# +# The Contents of this file are made available subject to the terms of +# either of the following licenses +# +# - GNU Lesser General Public License Version 2.1 +# - Sun Industry Standards Source License Version 1.1 +# +# Sun Microsystems Inc., October, 2000 +# +# GNU Lesser General Public License Version 2.1 +# ============================================= +# Copyright 2000 by Sun Microsystems, Inc. +# 901 San Antonio Road, Palo Alto, CA 94303, USA +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License version 2.1, as published by the Free Software Foundation. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, +# MA 02111-1307 USA +# +# +# Sun Industry Standards Source License Version 1.1 +# ================================================= +# The contents of this file are subject to the Sun Industry Standards +# Source License Version 1.1 (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.openoffice.org/license.html. +# +# Software provided under this License is provided on an "AS IS" basis, +# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, +# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, +# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. +# See the License for the specific provisions governing your rights and +# obligations concerning the Software. +# +# The Initial Developer of the Original Code is: Sun Microsystems, Inc. +# +# Copyright: 2000 by Sun Microsystems, Inc. +# +# All Rights Reserved. +# +# Contributor(s): _______________________________________ +# +# +# +#************************************************************************* + +JARFILES = sandbox.jar jurt.jar unoil.jar ridl.jar juh.jar java_uno.jar +JAVAFILES = \ + AccessibleEventMulticaster.java \ + InformationWriter.java \ + MessageArea.java \ + NameProvider.java \ + OfficeConnection.java \ + Options.java \ + SimpleOffice.java diff --git a/accessibility/workben/org/openoffice/accessibility/misc/makefile.mk b/accessibility/workben/org/openoffice/accessibility/misc/makefile.mk new file mode 100644 index 000000000..f0b71f860 --- /dev/null +++ b/accessibility/workben/org/openoffice/accessibility/misc/makefile.mk @@ -0,0 +1,86 @@ +#************************************************************************* +# +# $RCSfile: makefile.mk,v $ +# +# The Contents of this file are made available subject to the terms of +# either of the following licenses +# +# - GNU Lesser General Public License Version 2.1 +# - Sun Industry Standards Source License Version 1.1 +# +# Sun Microsystems Inc., October, 2000 +# +# GNU Lesser General Public License Version 2.1 +# ============================================= +# Copyright 2000 by Sun Microsystems, Inc. +# 901 San Antonio Road, Palo Alto, CA 94303, USA +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License version 2.1, as published by the Free Software Foundation. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, +# MA 02111-1307 USA +# +# +# Sun Industry Standards Source License Version 1.1 +# ================================================= +# The contents of this file are subject to the Sun Industry Standards +# Source License Version 1.1 (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.openoffice.org/license.html. +# +# Software provided under this License is provided on an "AS IS" basis, +# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, +# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, +# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. +# See the License for the specific provisions governing your rights and +# obligations concerning the Software. +# +# The Initial Developer of the Original Code is: Sun Microsystems, Inc. +# +# Copyright: 2000 by Sun Microsystems, Inc. +# +# All Rights Reserved. +# +# Contributor(s): _______________________________________ +# +# +# +#************************************************************************* + +PRJNAME = awb +PRJ = ..$/..$/..$/..$/.. +TARGET = java_misc +PACKAGE = org$/openoffice$/accessibility$/misc + +USE_JAVAVER:=TRUE + +# --- Settings ----------------------------------------------------- + +.INCLUDE : settings.mk + +.IF "$(JAVAVER:s/.//)" >= "140" + +.INCLUDE : makefile.common + +JAVACLASSFILES= $(foreach,i,$(JAVAFILES) $(CLASSDIR)$/$(PACKAGE)$/$(i:b).class) + +#JARTARGET = $(TARGET).jar +#JARCOMPRESS = TRUE +#JARCLASSDIRS = $(PACKAGE) org/openoffice/java/accessibility/awb +#CUSTOMMANIFESTFILE = manifest +.ENDIF + +# --- Targets ------------------------------------------------------ + + +.INCLUDE : target.mk + |