[orca] Fix for bug #627498 - Orca should explicitly present the insertion and deletion of the last row in a



commit fb2cb2e9427fcc232c94de845f9dca879840b6b2
Author: Joanmarie Diggs <joanmarie diggs gmail com>
Date:   Fri Aug 20 09:35:38 2010 -0400

    Fix for bug #627498 - Orca should explicitly present the insertion and deletion of the last row in an OOo Writer table

 src/orca/scripts/apps/soffice/script.py  |   54 +++++++++++++
 test/keystrokes/oowriter/row_inserted.py |  121 ++++++++++++++++++++++++++++++
 2 files changed, 175 insertions(+), 0 deletions(-)
---
diff --git a/src/orca/scripts/apps/soffice/script.py b/src/orca/scripts/apps/soffice/script.py
index 75526bd..6fea213 100644
--- a/src/orca/scripts/apps/soffice/script.py
+++ b/src/orca/scripts/apps/soffice/script.py
@@ -175,6 +175,8 @@ class Script(default.Script):
             self.onStateChanged
         listeners["object:state-changed:checked"]           = \
             self.onStateChanged
+        listeners["object:children-changed"]                = \
+            self.onChildrenChanged
 
         return listeners
 
@@ -1834,6 +1836,58 @@ class Script(default.Script):
 
         default.Script.onActiveDescendantChanged(self, event)
 
+    def onChildrenChanged(self, event):
+        """Called when a child node has changed.
+
+        Arguments:
+        - event: the Event
+        """
+
+        if not event.any_data or not orca_state.locusOfFocus:
+            return
+
+        if event.type.startswith('object:children-changed:add') \
+           and event.any_data.getRole() == pyatspi.ROLE_TABLE_CELL:
+            activeRow = self.pointOfReference.get('lastRow', -1)
+            activeCol = self.pointOfReference.get('lastColumn', -1)
+            if activeRow < 0 or activeCol < 0:
+                return
+
+            try:
+                itable = event.source.queryTable()
+            except NotImplementedError:
+                return
+
+            index = self.utilities.cellIndex(event.any_data)
+            eventRow = itable.getRowAtIndex(index)
+            eventCol = itable.getColumnAtIndex(index)
+
+            if eventRow == itable.nRows - 1 and eventCol == itable.nColumns - 1:
+                fullMessage = briefMessage = ""
+                voice = self.voices.get(settings.SYSTEM_VOICE)
+                if activeRow == itable.nRows:
+                    # Translators: This message is to inform the user that
+                    # the last row of a table in a document was just deleted.
+                    #
+                    fullMessage = _("Last row deleted.")
+                    # Translators: This message is to inform the user that
+                    # a row in a table was just deleted.
+                    #
+                    briefMessage = _("Row deleted.")
+                else:
+                    # Translators: This message is to inform the user that a
+                    # new table row was inserted at the end of the existing
+                    # table. This typically happens when the user presses Tab
+                    # from within the last cell of the table.
+                    #
+                    fullMessage = _("Row inserted at the end of the table.")
+                    # Translators: This message is to inform the user that
+                    # a row in a table was just inserted.
+                    #
+                    briefMessage = _("Row inserted.")
+                if fullMessage:
+                    self.presentMessage(fullMessage, briefMessage, voice)
+
     def onStateChanged(self, event):
         """Called whenever an object's state changes.
 
diff --git a/test/keystrokes/oowriter/row_inserted.py b/test/keystrokes/oowriter/row_inserted.py
new file mode 100644
index 0000000..23372ca
--- /dev/null
+++ b/test/keystrokes/oowriter/row_inserted.py
@@ -0,0 +1,121 @@
+#!/usr/bin/python
+
+"""Test to verify we announce the (likely accidental) addition and
+   subsequent removal of a row at the end of a table."""
+
+from macaroon.playback import *
+import utils
+
+sequence = MacroSequence()
+
+######################################################################
+# Start oowriter.
+#
+sequence.append(WaitForWindowActivate("Untitled 1 - " + utils.getOOoName("Writer"),None))
+sequence.append(WaitForFocus("", acc_role=pyatspi.ROLE_PARAGRAPH))
+
+######################################################################
+# Create a new document.
+#
+sequence.append(KeyComboAction("<Ctrl>n"))
+sequence.append(WaitForFocus("", acc_role=pyatspi.ROLE_PARAGRAPH))
+sequence.append(PauseAction(3000))
+
+######################################################################
+# Ctrl+F12, Return to create a new table
+#
+sequence.append(KeyComboAction("<Ctrl>F12"))
+sequence.append(KeyComboAction("Return"))
+sequence.append(WaitForFocus("", acc_role=pyatspi.ROLE_PARAGRAPH))
+sequence.append(PauseAction(3000))
+
+######################################################################
+# Tab to move through the cells and, eventually create a new row.
+#
+sequence.append(utils.StartRecordingAction())
+sequence.append(KeyComboAction("Tab"))
+sequence.append(WaitForFocus("", acc_role=pyatspi.ROLE_PARAGRAPH))
+sequence.append(utils.AssertPresentationAction(
+    "1. Tab",
+    ["BRAILLE LINE:  'soffice Application Untitled 2 - " + utils.getOOoName("Writer") + " Frame Untitled 2 - " + utils.getOOoName("Writer") + " RootPane ScrollPane Document view Table1-1 Table Paragraph'",
+     "     VISIBLE:  'Paragraph', cursor=1",
+     "SPEECH OUTPUT: 'blank'",
+     "SPEECH OUTPUT: 'Cell B1"]))
+
+sequence.append(utils.StartRecordingAction())
+sequence.append(KeyComboAction("Tab"))
+sequence.append(WaitForFocus("", acc_role=pyatspi.ROLE_PARAGRAPH))
+sequence.append(utils.AssertPresentationAction(
+    "2. Tab",
+    ["BRAILLE LINE:  'soffice Application Untitled 2 - " + utils.getOOoName("Writer") + " Frame Untitled 2 - " + utils.getOOoName("Writer") + " RootPane ScrollPane Document view Table1-1 Table Paragraph'",
+     "     VISIBLE:  'Paragraph', cursor=1",
+     "SPEECH OUTPUT: 'blank'",
+     "SPEECH OUTPUT: 'Cell A2"]))
+
+sequence.append(utils.StartRecordingAction())
+sequence.append(KeyComboAction("Tab"))
+sequence.append(WaitForFocus("", acc_role=pyatspi.ROLE_PARAGRAPH))
+sequence.append(utils.AssertPresentationAction(
+    "3. Tab",
+    ["BRAILLE LINE:  'soffice Application Untitled 2 - " + utils.getOOoName("Writer") + " Frame Untitled 2 - " + utils.getOOoName("Writer") + " RootPane ScrollPane Document view Table1-1 Table Paragraph'",
+     "     VISIBLE:  'Paragraph', cursor=1",
+     "SPEECH OUTPUT: 'End of table blank'",
+     "SPEECH OUTPUT: 'Cell B2"]))
+
+sequence.append(utils.StartRecordingAction())
+sequence.append(KeyComboAction("Tab"))
+sequence.append(WaitForFocus("", acc_role=pyatspi.ROLE_PARAGRAPH))
+sequence.append(utils.AssertPresentationAction(
+    "4. Tab",
+    ["BRAILLE LINE:  'Row inserted at the end of the table.'",
+     "     VISIBLE:  'Row inserted at the end of the t', cursor=0",
+     "BRAILLE LINE:  'soffice Application Untitled 2 - " + utils.getOOoName("Writer") + " Frame Untitled 2 - " + utils.getOOoName("Writer") + " RootPane ScrollPane Document view Table1-1 Table Paragraph'",
+     "     VISIBLE:  'Paragraph', cursor=1",
+     "SPEECH OUTPUT: 'Row inserted at the end of the table.'",
+     "SPEECH OUTPUT: 'blank'",
+     "SPEECH OUTPUT: 'Cell A3"]))
+
+######################################################################
+# Ctrl+Z to undo the creation of the new row.
+#
+sequence.append(utils.StartRecordingAction())
+sequence.append(KeyComboAction("<Ctrl>z"))
+sequence.append(WaitForFocus("", acc_role=pyatspi.ROLE_PARAGRAPH))
+sequence.append(utils.AssertPresentationAction(
+    "Ctrl+Z",
+    ["BRAILLE LINE:  'Last row deleted.'",
+     "     VISIBLE:  'Last row deleted.', cursor=0",
+     "BRAILLE LINE:  'soffice Application Untitled 2 - " + utils.getOOoName("Writer") + " Frame Untitled 2 - " + utils.getOOoName("Writer") + " RootPane ScrollPane Document view Table1-1 Table Paragraph'",
+     "     VISIBLE:  'Paragraph', cursor=1",
+     "SPEECH OUTPUT: 'Last row deleted.'",
+     "SPEECH OUTPUT: 'End of table blank'",
+     "SPEECH OUTPUT: 'Cell B2"]))
+
+######################################################################
+#  Alt-f, Alt-c to close the Writer application.
+#  A save dialog will appear.
+#
+sequence.append(KeyComboAction("<Alt>f"))
+sequence.append(WaitForFocus("New", acc_role=pyatspi.ROLE_MENU))
+
+sequence.append(KeyComboAction("<Alt>c"))
+sequence.append(WaitForFocus("Save", acc_role=pyatspi.ROLE_PUSH_BUTTON))
+
+######################################################################
+#  Tab and Return to discard the current changes.
+#
+sequence.append(KeyComboAction("Tab"))
+sequence.append(WaitForFocus("Discard", acc_role=pyatspi.ROLE_PUSH_BUTTON))
+
+sequence.append(KeyComboAction("Return"))
+
+######################################################################
+# Wait for things to get back to normal.
+#
+sequence.append(WaitForWindowActivate("Untitled 1 - " + utils.getOOoName("Writer"), None))
+sequence.append(WaitForFocus("", acc_role=pyatspi.ROLE_PARAGRAPH))
+sequence.append(PauseAction(3000))
+
+sequence.append(utils.AssertionSummaryAction())
+
+sequence.start()



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]