[orca] Remainder of the fix for bug 574720



commit b86ce40a4093c89628a6fa78b01f11f64065336a
Author: Joanmarie Diggs <joanmarie diggs gmail com>
Date:   Fri Jun 19 16:10:56 2009 -0400

    Remainder of the fix for bug 574720
    
    This is the third and final portion of the implementation of structural
    navigation for OOo Writer tables. This change makes the presentation of
    dynamic headers work consistently with the presentation of headers in
    Gecko tables.

 po/POTFILES.in                                     |    1 +
 src/orca/scripts/apps/soffice/Makefile.am          |    3 +-
 src/orca/scripts/apps/soffice/script.py            |    8 +-
 .../scripts/apps/soffice/structural_navigation.py  |  128 ++++++++++++++++++++
 .../oowriter/table_cells_structural_navigation1.py |   32 ++---
 5 files changed, 149 insertions(+), 23 deletions(-)
---
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 34833b4..b001e5e 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -52,6 +52,7 @@ src/orca/scripts/apps/planner/braille_generator.py
 src/orca/scripts/apps/planner/speech_generator.py
 src/orca/scripts/apps/soffice/script.py
 src/orca/scripts/apps/soffice/speech_generator.py
+src/orca/scripts/apps/soffice/structural_navigation.py
 src/orca/scripts/apps/Thunderbird/script.py
 src/orca/scripts/apps/Thunderbird/speech_generator.py
 src/orca/scripts/apps/gtk-window-decorator.py
diff --git a/src/orca/scripts/apps/soffice/Makefile.am b/src/orca/scripts/apps/soffice/Makefile.am
index dab725c..d17a93d 100644
--- a/src/orca/scripts/apps/soffice/Makefile.am
+++ b/src/orca/scripts/apps/soffice/Makefile.am
@@ -6,7 +6,8 @@ orca_python_PYTHON = \
 	formatting.py \
 	script.py \
 	script_settings.py \
-	speech_generator.py
+	speech_generator.py \
+	structural_navigation.py
 
 orca_pythondir=$(pyexecdir)/orca/scripts/apps/soffice
 
diff --git a/src/orca/scripts/apps/soffice/script.py b/src/orca/scripts/apps/soffice/script.py
index 9ed279d..a8f2714 100644
--- a/src/orca/scripts/apps/soffice/script.py
+++ b/src/orca/scripts/apps/soffice/script.py
@@ -51,11 +51,11 @@ import orca.settings as settings
 import orca.keybindings as keybindings
 
 from orca.orca_i18n import _ # for gettext support
-from orca.structural_navigation import StructuralNavigation
 
 from speech_generator import SpeechGenerator
 from braille_generator import BrailleGenerator
 from formatting import Formatting
+from structural_navigation import StructuralNavigation
 import script_settings
 
 class Script(default.Script):
@@ -200,6 +200,12 @@ class Script(default.Script):
         """Returns the formatting strings for this script."""
         return Formatting(self)
 
+    def getStructuralNavigation(self):
+        """Returns the 'structural navigation' class for this script.
+        """
+        types = self.getEnabledStructuralNavigationTypes()
+        return StructuralNavigation(self, types, enabled=False)
+
     def getEnabledStructuralNavigationTypes(self):
         """Returns a list of the structural navigation object types
         enabled in this script.
diff --git a/src/orca/scripts/apps/soffice/structural_navigation.py b/src/orca/scripts/apps/soffice/structural_navigation.py
new file mode 100644
index 0000000..75ed8b5
--- /dev/null
+++ b/src/orca/scripts/apps/soffice/structural_navigation.py
@@ -0,0 +1,128 @@
+# Orca
+#
+# Copyright 2005-2009 Sun Microsystems Inc.
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Library General Public
+# License as published by the Free Software Foundation; either
+# version 2 of the License, or (at your option) any later version.
+#
+# 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
+# Library General Public License for more details.
+#
+# You should have received a copy of the GNU Library General Public
+# License along with this library; if not, write to the
+# Free Software Foundation, Inc., Franklin Street, Fifth Floor,
+# Boston MA  02110-1301 USA.
+
+"""Custom structural navigation for the StarOffice/OpenOffice."""
+
+__id__ = "$Id$"
+__version__   = "$Revision$"
+__date__      = "$Date$"
+__copyright__ = "Copyright (c) 2005-2009 Sun Microsystems Inc."
+__license__   = "LGPL"
+
+import pyatspi
+
+import orca.structural_navigation as structural_navigation
+import orca.settings as settings
+import orca.speech as speech
+
+from orca.orca_i18n import _
+
+########################################################################
+#                                                                      #
+# Custom Structural Navigation                                         #
+#                                                                      #
+########################################################################
+
+class StructuralNavigation(structural_navigation.StructuralNavigation):
+
+    def __init__(self, script, enabledTypes, enabled):
+        """StarOffice/OpenOffice specific Structural Navigation."""
+        structural_navigation.StructuralNavigation.__init__(self,
+                                                            script,
+                                                            enabledTypes,
+                                                            enabled)
+
+    def _isHeader(self, obj):
+        """Returns True if the table cell is a header.
+
+        Arguments:
+        - obj: the accessible table cell to examine.
+        """
+
+        if not obj:
+            return False
+
+        if obj.getRole() in [pyatspi.ROLE_TABLE_COLUMN_HEADER,
+                             pyatspi.ROLE_TABLE_ROW_HEADER]:
+            return True
+
+        # Check for dynamic row and column headers.
+        #
+        try:
+            table = obj.parent.queryTable()
+        except:
+            return False
+
+        # Make sure we're in the correct table first.
+        #
+        if not (table in self._script.dynamicRowHeaders or
+                table in self._script.dynamicColumnHeaders):
+            return False
+
+        [row, col] = self.getCellCoordinates(obj)
+        return (row == self._script.dynamicColumnHeaders.get(table) \
+                or col == self._script.dynamicRowHeaders.get(table))
+
+    def _tableCellPresentation(self, cell, arg):
+        """Presents the table cell or indicates that one was not found.
+        Overridden here to avoid the double-speaking of the dynamic
+        headers.
+
+        Arguments:
+        - obj: the accessible object under consideration.
+        - arg: an optional argument which may need to be included in
+          the criteria (e.g. the level of a heading).
+        """
+
+        # TODO - JD: This really should be dealt with via a formatting
+        # string, once we work out how to implement formatting strings
+        # throughout the Gecko code. In the meantime, this method will
+        # result in a consistent user experience between applications.
+        #
+        if not cell:
+            return
+
+        if settings.speakCellHeaders:
+            self._presentCellHeaders(cell, arg)
+
+        [obj, characterOffset] = self._getCaretPosition(cell)
+        self._setCaretPosition(obj, characterOffset)
+        self._script.updateBraille(obj)
+
+        blank = self._isBlankCell(cell)
+        if not blank:
+            for child in cell:
+                speech.speak(self._script.getDisplayedText(child))
+        else:
+            # Translators: "blank" is a short word to mean the
+            # user has navigated to an empty line.
+            #
+            speech.speak(_("blank"))
+
+        if settings.speakCellCoordinates:
+            [row, col] = self.getCellCoordinates(cell)
+            # Translators: this represents the (row, col) position of
+            # a cell in a table.
+            #
+            speech.speak(_("Row %(row)d, column %(column)d.") \
+                         % {"row" : row + 1, "column" : col + 1})
+
+        spanString = self._getCellSpanInfo(cell)
+        if spanString and settings.speakCellSpan:
+            speech.speak(spanString)
diff --git a/test/keystrokes/oowriter/table_cells_structural_navigation1.py b/test/keystrokes/oowriter/table_cells_structural_navigation1.py
index da87432..a255210 100644
--- a/test/keystrokes/oowriter/table_cells_structural_navigation1.py
+++ b/test/keystrokes/oowriter/table_cells_structural_navigation1.py
@@ -84,10 +84,8 @@ sequence.append(utils.AssertPresentationAction(
     "1. Alt Shift Left.",
     ["BRAILLE LINE:  '" + utils.getOOoBrailleLine("Writer", "table-sample2(.odt|)", "Calendar-1 Table 3 Paragraph") + "'",
      "     VISIBLE:  '3 Paragraph', cursor=1",
-     "BRAILLE LINE:  '" + utils.getOOoBrailleLine("Writer", "table-sample2(.odt|)", "Calendar-1 Table 3 Paragraph") + "'",
-     "     VISIBLE:  '3 Paragraph', cursor=1",
      "SPEECH OUTPUT: '3'",
-     "SPEECH OUTPUT: 'Row 3, column 1."]))
+     "SPEECH OUTPUT: 'Row 3, column 1.'"]))
 
 sequence.append(utils.StartRecordingAction())
 sequence.append(KeyComboAction("<Alt><Shift>Left"))
@@ -102,9 +100,8 @@ sequence.append(utils.AssertPresentationAction(
     "3. Alt Shift Right.",
     ["BRAILLE LINE:  '" + utils.getOOoBrailleLine("Writer", "table-sample2(.odt|)", "Calendar-1 Table 4 Paragraph") + "'",
      "     VISIBLE:  '4 Paragraph', cursor=1",
-     "BRAILLE LINE:  '" + utils.getOOoBrailleLine("Writer", "table-sample2(.odt|)", "Calendar-1 Table 4 Paragraph") + "'",
-     "     VISIBLE:  '4 Paragraph', cursor=1","SPEECH OUTPUT: '4'",
-     "SPEECH OUTPUT: 'Row 3, column 2."]))
+     "SPEECH OUTPUT: '4'",
+     "SPEECH OUTPUT: 'Row 3, column 2.'"]))
 
 sequence.append(utils.StartRecordingAction())
 sequence.append(KeyComboAction("<Alt><Shift>Right"))
@@ -113,10 +110,8 @@ sequence.append(utils.AssertPresentationAction(
     "4. Alt Shift Right.",
     ["BRAILLE LINE:  '" + utils.getOOoBrailleLine("Writer", "table-sample2(.odt|)", "Calendar-1 Table 5 Paragraph") + "'",
      "     VISIBLE:  '5 Paragraph', cursor=1",
-     "BRAILLE LINE:  '" + utils.getOOoBrailleLine("Writer", "table-sample2(.odt|)", "Calendar-1 Table 5 Paragraph") + "'",
-     "     VISIBLE:  '5 Paragraph', cursor=1",
      "SPEECH OUTPUT: '5'",
-     "SPEECH OUTPUT: 'Row 3, column 3."]))
+     "SPEECH OUTPUT: 'Row 3, column 3.'"]))
 
 sequence.append(utils.StartRecordingAction())
 sequence.append(KeyComboAction("<Alt><Shift>Right"))
@@ -125,10 +120,9 @@ sequence.append(utils.AssertPresentationAction(
     "5. Alt Shift Right.",
     ["BRAILLE LINE:  '" + utils.getOOoBrailleLine("Writer", "table-sample2(.odt|)", "Calendar-1 Table 6 Paragraph7 Paragraph") + "'",
      "     VISIBLE:  '7 Paragraph', cursor=1",
-     "BRAILLE LINE:  '" + utils.getOOoBrailleLine("Writer", "table-sample2(.odt|)", "Calendar-1 Table 6 Paragraph7 Paragraph") + "'",
-     "     VISIBLE:  '7 Paragraph', cursor=1",
-     "SPEECH OUTPUT: '6 7'",
-     "SPEECH OUTPUT: 'Row 3, column 4.",
+     "SPEECH OUTPUT: '6'",
+     "SPEECH OUTPUT: '7'",
+     "SPEECH OUTPUT: 'Row 3, column 4.'",
      "SPEECH OUTPUT: 'Cell spans 2 columns'"]))
 
 sequence.append(utils.StartRecordingAction())
@@ -139,7 +133,7 @@ sequence.append(utils.AssertPresentationAction(
     ["BRAILLE LINE:  '" + utils.getOOoBrailleLine("Writer", "table-sample2(.odt|)", "Calendar-1 Table Paragraph") + "'",
      "     VISIBLE:  'Paragraph', cursor=1",
      "SPEECH OUTPUT: 'blank'",
-     "SPEECH OUTPUT: 'Row 2, column 4."]))
+     "SPEECH OUTPUT: 'Row 2, column 4.'"]))
 
 sequence.append(utils.StartRecordingAction())
 sequence.append(KeyComboAction("<Alt><Shift>Up"))
@@ -148,10 +142,8 @@ sequence.append(utils.AssertPresentationAction(
     "7. Alt Shift Up.",
     ["BRAILLE LINE:  '" + utils.getOOoBrailleLine("Writer", "table-sample2(.odt|)", "Calendar-1 Table Wed Paragraph") + "'",
      "     VISIBLE:  'Wed Paragraph', cursor=1",
-     "BRAILLE LINE:  '" + utils.getOOoBrailleLine("Writer", "table-sample2(.odt|)", "Calendar-1 Table Wed Paragraph") + "'",
-     "     VISIBLE:  'Wed Paragraph', cursor=1",
      "SPEECH OUTPUT: 'Wed'",
-     "SPEECH OUTPUT: 'Row 1, column 4."]))
+     "SPEECH OUTPUT: 'Row 1, column 4.'"]))
 
 sequence.append(utils.StartRecordingAction())
 sequence.append(KeyComboAction("<Alt><Shift>Up"))
@@ -167,7 +159,7 @@ sequence.append(utils.AssertPresentationAction(
     ["BRAILLE LINE:  '" + utils.getOOoBrailleLine("Writer", "table-sample2(.odt|)", "Calendar-1 Table Paragraph") + "'",
      "     VISIBLE:  'Paragraph', cursor=1",
      "SPEECH OUTPUT: 'blank'",
-     "SPEECH OUTPUT: 'Row 7, column 7."]))
+     "SPEECH OUTPUT: 'Row 7, column 7.'"]))
 
 sequence.append(utils.StartRecordingAction())
 sequence.append(KeyComboAction("<Alt><Shift>Down"))
@@ -188,10 +180,8 @@ sequence.append(utils.AssertPresentationAction(
     "12. Alt Shift Home.",
     ["BRAILLE LINE:  '" + utils.getOOoBrailleLine("Writer", "table-sample2(.odt|)", "Calendar-1 Table Sun Paragraph") + "'",
      "     VISIBLE:  'Sun Paragraph', cursor=1",
-     "BRAILLE LINE:  '" + utils.getOOoBrailleLine("Writer", "table-sample2(.odt|)", "Calendar-1 Table Sun Paragraph") + "'",
-     "     VISIBLE:  'Sun Paragraph', cursor=1",
      "SPEECH OUTPUT: 'Sun'",
-     "SPEECH OUTPUT: 'Row 1, column 1."]))
+     "SPEECH OUTPUT: 'Row 1, column 1.'"]))
 
 sequence.append(utils.StartRecordingAction())
 sequence.append(KeyComboAction("<Alt><Shift>Up"))



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