summaryrefslogtreecommitdiff
path: root/accessibility/workben/org/openoffice/accessibility/awb/view/text
diff options
context:
space:
mode:
Diffstat (limited to 'accessibility/workben/org/openoffice/accessibility/awb/view/text')
-rw-r--r--accessibility/workben/org/openoffice/accessibility/awb/view/text/CaretSpinnerModel.java122
-rw-r--r--accessibility/workben/org/openoffice/accessibility/awb/view/text/Makefile13
-rw-r--r--accessibility/workben/org/openoffice/accessibility/awb/view/text/TextActionDialog.java208
-rw-r--r--accessibility/workben/org/openoffice/accessibility/awb/view/text/TextAttributeDialog.java179
-rw-r--r--accessibility/workben/org/openoffice/accessibility/awb/view/text/TextDialogFactory.java136
-rw-r--r--accessibility/workben/org/openoffice/accessibility/awb/view/text/TextEditDialog.java122
-rw-r--r--accessibility/workben/org/openoffice/accessibility/awb/view/text/makefile.common34
-rw-r--r--accessibility/workben/org/openoffice/accessibility/awb/view/text/makefile.mk51
8 files changed, 865 insertions, 0 deletions
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 000000000000..c210b0eff086
--- /dev/null
+++ b/accessibility/workben/org/openoffice/accessibility/awb/view/text/CaretSpinnerModel.java
@@ -0,0 +1,122 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+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 000000000000..c58899a09f6e
--- /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 000000000000..f37969d5ee59
--- /dev/null
+++ b/accessibility/workben/org/openoffice/accessibility/awb/view/text/TextActionDialog.java
@@ -0,0 +1,208 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+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 000000000000..dad548ca730e
--- /dev/null
+++ b/accessibility/workben/org/openoffice/accessibility/awb/view/text/TextAttributeDialog.java
@@ -0,0 +1,179 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+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 000000000000..cdb3f26b5e55
--- /dev/null
+++ b/accessibility/workben/org/openoffice/accessibility/awb/view/text/TextDialogFactory.java
@@ -0,0 +1,136 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+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 000000000000..a8710cbad7cc
--- /dev/null
+++ b/accessibility/workben/org/openoffice/accessibility/awb/view/text/TextEditDialog.java
@@ -0,0 +1,122 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+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 000000000000..7d9a5e8febfa
--- /dev/null
+++ b/accessibility/workben/org/openoffice/accessibility/awb/view/text/makefile.common
@@ -0,0 +1,34 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org 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 version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+JARFILES = 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 000000000000..1ec7da26619b
--- /dev/null
+++ b/accessibility/workben/org/openoffice/accessibility/awb/view/text/makefile.mk
@@ -0,0 +1,51 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org 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 version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+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
+