[orca/570658] Add braille formatting for ROLE_TABLE_CELL



commit 02d960749c120d4642ef775d2bf3726195fd0f78
Author: Willie Walker <william walker sun com>
Date:   Thu Jun 25 18:10:46 2009 -0400

    Add braille formatting for ROLE_TABLE_CELL
    
    This was a substantial change and I moved a lot of code up into
    generator.py.  The benefit is that we now share a ton of logic
    between braille and speech when it comes to tables.  I need to
    figure out how to get rid of the CheckBox role when brailling
    table lines with checkboxes, though, and I'm now hearing some
    double-speaking of the header name when arrowing left to right
    across a row of checkboxes.  The test example is the "Tree Store"
    demo of gtk-demo.

 src/orca/braille_generator.py |    5 +-
 src/orca/formatting.py        |   17 ++-
 src/orca/generator.py         |  343 ++++++++++++++++++++++++++++++++++++++++-
 src/orca/speech_generator.py  |  291 +----------------------------------
 4 files changed, 362 insertions(+), 294 deletions(-)
---
diff --git a/src/orca/braille_generator.py b/src/orca/braille_generator.py
index 7abc906..e3814bd 100644
--- a/src/orca/braille_generator.py
+++ b/src/orca/braille_generator.py
@@ -72,9 +72,12 @@ class BrailleGenerator(generator.Generator):
            and not args.get('formatType', None):
             args['formatType'] = 'focused'
         result = self.generate(obj, **args)
+        print "RESULT", result
         for element in result:
             if isinstance(element, braille.Region):
-                print "FOO", element.string, element.cursorOffset
+                print "   '%s', %d" % (element.string, element.cursorOffset)
+            else:
+                print "   ", element
         return result
 
     #####################################################################
diff --git a/src/orca/formatting.py b/src/orca/formatting.py
index 16f363b..68da149 100644
--- a/src/orca/formatting.py
+++ b/src/orca/formatting.py
@@ -257,8 +257,8 @@ formatting = {
             # read a whole row. It calls REAL_ROLE_TABLE_CELL internally.
             # maybe it can be done in a cleaner way?
             #
-            'focused': '(tableCell2ChildLabel + tableCell2ChildToggle) or cellCheckedState + (expandableState and (expandableState + numberOfChildren))',
-            'unfocused': '(tableCell2ChildLabel + tableCell2ChildToggle) or cellCheckedState + (realActiveDescendantDisplayedText or imageDescription + image) + (expandableState and (expandableState + numberOfChildren)) + required'
+            'focused': '(tableCell2ChildLabel + tableCell2ChildToggle) or (cellCheckedState + (expandableState and (expandableState + numberOfChildren)))',
+            'unfocused': '(tableCell2ChildLabel + tableCell2ChildToggle) or (columnHeaderIfToggleAndNoText + cellCheckedState + (realActiveDescendantDisplayedText or imageDescription + image) + (expandableState and (expandableState + numberOfChildren)) + required)'
             },
         pyatspi.ROLE_TEAROFF_MENU_ITEM: {
             'focused': '[]',
@@ -437,7 +437,18 @@ formatting = {
             },
         #pyatspi.ROLE_SPLIT_PANE: 'default'
         #pyatspi.ROLE_TABLE: 'default'
-        #pyatspi.ROLE_TABLE_CELL: [[[TODO: WDW - needs to be done]]]
+        pyatspi.ROLE_TABLE_CELL: {
+            'unfocused': 'tableCellRow',
+            },
+        'REAL_ROLE_TABLE_CELL' : {
+            'unfocused': '(tableCell2ChildToggle + tableCell2ChildLabel)\
+                          or (cellCheckedState\
+                              + (columnHeaderIfToggleAndNoText and [Region(" " + asString(columnHeaderIfToggleAndNoText))])\
+                              + ((realActiveDescendantDisplayedText and [Region(asString(realActiveDescendantDisplayedText))])\
+                                 or (imageDescription and [Region(" " + asString(imageDescription))]))\
+                              + (expandableState and Region(" " + asString(expandableState)))\
+                              + (required and Region(" " + asString(required))))'
+            },
         #pyatspi.ROLE_TABLE_COLUMN_HEADER: 'default'
         #pyatspi.ROLE_TABLE_ROW_HEADER: 'default'
         pyatspi.ROLE_TEAROFF_MENU_ITEM: {
diff --git a/src/orca/generator.py b/src/orca/generator.py
index 602d609..fe3cf68 100644
--- a/src/orca/generator.py
+++ b/src/orca/generator.py
@@ -28,10 +28,14 @@ __license__   = "LGPL"
 import sys
 import traceback
 
-import debug
 import pyatspi
+
+import debug
+import rolenames
 import settings
 
+from orca_i18n import _         # for gettext support
+
 def _formatExceptionInfo(maxTBlevel=5):
     cla, exc, trbk = sys.exc_info()
     excName = cla.__name__
@@ -367,6 +371,30 @@ class Generator:
             result.append(self._script.formatting.getString(**args))
         return result
 
+    def _generateCellCheckedState(self, obj, **args):
+        """Returns an array of strings for use by speech and braille that
+        represent the checked state of the object.  This is typically
+        for check boxes that are in a table. An empty array will be
+        returned if this is not a checkable cell.
+        """
+        result = []
+        try:
+            action = obj.queryAction()
+        except NotImplementedError:
+            action = None
+        if action:
+            for i in range(0, action.nActions):
+                # Translators: this is the action name for
+                # the 'toggle' action. It must be the same
+                # string used in the *.po file for gail.
+                #
+                if action.getName(i) in ["toggle", _("toggle")]:
+                    oldRole = self._overrideRole(pyatspi.ROLE_CHECK_BOX,
+                                            args)
+                    result.extend(self.generate(obj, **args))
+                    self._restoreRole(oldRole, args)
+        return result
+
     def _generateCheckedState(self, obj, **args):
         """Returns an array of strings for use by speech and braille that
         represent the checked state of the object.  This is typically
@@ -461,6 +489,305 @@ class Generator:
 
     #####################################################################
     #                                                                   #
+    # Table interface information                                       #
+    #                                                                   #
+    #####################################################################
+
+    def _generateRowHeader(self, obj, **args):
+        """Returns an array of strings to be used in speech and braille that
+        represent the row header for an object that is in a table, if
+        it exists.  Otherwise, an empty array is returned.
+        """
+        result = []
+        if not args.get('mode', None):
+            args['mode'] = self._mode
+        try:
+            table = obj.parent.queryTable()
+        except:
+            pass
+        else:
+            index = self._script.getCellIndex(obj)
+            rowIndex = table.getRowAtIndex(index)
+            if rowIndex >= 0:
+                # Get the header information.  In Java Swing, the
+                # information is not exposed via the description
+                # but is instead a header object, so we fall back
+                # to that if it exists.
+                #
+                # [[[TODO: WDW - the more correct thing to do, I
+                # think, is to look at the row header object.
+                # We've been looking at the description for so
+                # long, though, that we'll give the description
+                # preference for now.]]]
+                #
+                desc = table.getRowDescription(rowIndex)
+                if not desc:
+                    header = table.getRowHeader(rowIndex)
+                    if header:
+                        desc = self._script.getDisplayedText(header)
+                if desc and len(desc):
+                    text = desc
+                    if args['mode'] == 'speech':
+                        if settings.speechVerbosityLevel \
+                           == settings.VERBOSITY_LEVEL_VERBOSE \
+                           and not args.get('formatType', None) \
+                                   in ['basicWhereAmI', 'detailedWhereAmI']:
+                            text += " " + rolenames.rolenames[\
+                                    pyatspi.ROLE_ROW_HEADER].speech
+                    elif args['mode'] == 'braille':
+                        if settings.brailleVerbosityLevel \
+                           == settings.VERBOSITY_LEVEL_VERBOSE:
+                            if settings.brailleRolenameStyle \
+                               == settings.BRAILLE_ROLENAME_STYLE_LONG:
+                                text = desc + " " + rolenames.rolenames[\
+                                       pyatspi.ROLE_ROW_HEADER].brailleLong
+                            else:
+                                text = desc + " " + rolenames.rolenames[\
+                                       pyatspi.ROLE_ROW_HEADER].brailleShort
+                    result.append(text)
+        return result
+
+    def _generateColumnHeader(self, obj, **args):
+        """Returns an array of strings (and possibly voice and audio
+        specifications) that represent the column header for an object
+        that is in a table, if it exists.  Otherwise, an empty array
+        is returned.
+        """
+        result = []
+        try:
+            table = obj.parent.queryTable()
+        except:
+            pass
+        else:
+            index = self._script.getCellIndex(obj)
+            columnIndex = table.getColumnAtIndex(index)
+            if columnIndex >= 0:
+                # Get the header information.  In Java Swing, the
+                # information is not exposed via the description
+                # but is instead a header object, so we fall back
+                # to that if it exists.
+                #
+                # [[[TODO: WDW - the more correct thing to do, I
+                # think, is to look at the column header object.
+                # We've been looking at the description for so
+                # long, though, that we'll give the description
+                # preference for now.]]]
+                #
+                desc = table.getColumnDescription(columnIndex)
+                if not desc:
+                    header = table.getColumnHeader(columnIndex)
+                    if header:
+                        desc = self._script.getDisplayedText(header)
+                if desc and len(desc):
+                    text = desc
+                    if args['mode'] == 'speech':
+                        if settings.speechVerbosityLevel \
+                           == settings.VERBOSITY_LEVEL_VERBOSE \
+                           and not args.get('formatType', None) \
+                                   in ['basicWhereAmI', 'detailedWhereAmI']:
+                            text += " " + rolenames.rolenames[\
+                                    pyatspi.ROLE_COLUMN_HEADER].speech
+                    elif args['mode'] == 'braille':
+                        if settings.brailleVerbosityLevel \
+                           == settings.VERBOSITY_LEVEL_VERBOSE:
+                            if settings.brailleRolenameStyle \
+                               == settings.BRAILLE_ROLENAME_STYLE_LONG:
+                                text = desc + " " + rolenames.rolenames[\
+                                       pyatspi.ROLE_COLUMN_HEADER].brailleLong
+                            else:
+                                text = desc + " " + rolenames.rolenames[\
+                                       pyatspi.ROLE_COLUMN_HEADER].brailleShort
+                    result.append(text)
+        return result
+
+    def _generateTableCell2ChildLabel(self, obj, **args):
+        """Returns an array of strings for use by speech and braille for the
+        label of a toggle in a table cell that has a special 2 child
+        pattern that we run into.  Otherwise, an empty array is
+        returned.
+        """
+        result = []
+
+        # If this table cell has 2 children and one of them has a
+        # 'toggle' action and the other does not, then present this
+        # as a checkbox where:
+        # 1) we get the checked state from the cell with the 'toggle' action
+        # 2) we get the label from the other cell.
+        # See Orca bug #376015 for more details.
+        #
+        if obj.childCount == 2:
+            cellOrder = []
+            hasToggle = [False, False]
+            for i, child in enumerate(obj):
+                try:
+                    action = child.queryAction()
+                except NotImplementedError:
+                    continue
+                else:
+                    for j in range(0, action.nActions):
+                        # Translators: this is the action name for
+                        # the 'toggle' action. It must be the same
+                        # string used in the *.po file for gail.
+                        #
+                        if action.getName(j) in ["toggle", _("toggle")]:
+                            hasToggle[i] = True
+                            break
+            if hasToggle[0] and not hasToggle[1]:
+                cellOrder = [ 1, 0 ]
+            elif not hasToggle[0] and hasToggle[1]:
+                cellOrder = [ 0, 1 ]
+            if cellOrder:
+                for i in cellOrder:
+                    if not hasToggle[i]:
+                        result.extend(self.generate(obj[i], **args))
+        return result
+
+    def _generateTableCell2ChildToggle(self, obj, **args):
+        """Returns an array of strings for use by speech and braille for the
+        toggle value of a toggle in a table cell that has a special 2
+        child pattern that we run into.  Otherwise, an empty array is
+        returned.
+        """
+        result = []
+
+        # If this table cell has 2 children and one of them has a
+        # 'toggle' action and the other does not, then present this
+        # as a checkbox where:
+        # 1) we get the checked state from the cell with the 'toggle' action
+        # 2) we get the label from the other cell.
+        # See Orca bug #376015 for more details.
+        #
+        if obj.childCount == 2:
+            cellOrder = []
+            hasToggle = [False, False]
+            for i, child in enumerate(obj):
+                try:
+                    action = child.queryAction()
+                except NotImplementedError:
+                    continue
+                else:
+                    for j in range(0, action.nActions):
+                        # Translators: this is the action name for
+                        # the 'toggle' action. It must be the same
+                        # string used in the *.po file for gail.
+                        #
+                        if action.getName(j) in ["toggle", _("toggle")]:
+                            hasToggle[i] = True
+                            break
+
+            if hasToggle[0] and not hasToggle[1]:
+                cellOrder = [ 1, 0 ]
+            elif not hasToggle[0] and hasToggle[1]:
+                cellOrder = [ 0, 1 ]
+            if cellOrder:
+                for i in cellOrder:
+                    if hasToggle[i]:
+                        result.extend(self.generate(obj[i], **args))
+        return result
+
+    def _generateColumnHeaderIfToggleAndNoText(self, obj, **args):
+        """If this table cell has a "toggle" action, and doesn't have any
+        label associated with it then also speak the table column
+        header.  See Orca bug #455230 for more details.
+        """
+        result = []
+        try:
+            parentTable = obj.parent.queryTable()
+        except:
+            return result
+        try:
+            action = obj.queryAction()
+            label = self._script.getDisplayedText(
+                        self._script.getRealActiveDescendant(obj))
+        except NotImplementedError:
+            action = None
+            label = None
+        if action and (label == None or len(label) == 0):
+            index = self._script.getCellIndex(obj)
+            column = parentTable.getColumnAtIndex(index)
+            for j in range(0, action.nActions):
+                # Translators: this is the action name for
+                # the 'toggle' action. It must be the same
+                # string used in the *.po file for gail.
+                #
+                if action.getName(j) in ["toggle",
+                                         _("toggle")]:
+                    accHeader = \
+                        parentTable.getColumnHeader(column)
+                    result.append(accHeader.name)
+        return result
+
+    def _generateRealTableCell(self, obj, **args):
+        """Orca has a feature to automatically read an entire row of a table
+        as the user arrows up/down the roles.  This leads to
+        complexity in the code.  This method is used to return an
+        array of strings for use by speech and braille for a single
+        table cell itself.  The string, 'blank', is added for empty
+        cells.
+        """
+        result = []
+        oldRole = self._overrideRole('REAL_ROLE_TABLE_CELL', args)
+        result.extend(self.generate(obj, **args))
+        self._restoreRole(oldRole, args)
+        return result
+
+    def _generateTableCellRow(self, obj, **args):
+        """Orca has a feature to automatically read an entire row of a table
+        as the user arrows up/down the roles.  This leads to complexity in
+        the code.  This method is used to return an array of strings
+        (and possibly voice and audio specifications) for an entire row
+        in a table if that's what the user has requested and if the row
+        has changed.  Otherwise, it will return an array for just the
+        current cell.
+        """
+        result = []
+
+        try:
+            parentTable = obj.parent.queryTable()
+        except NotImplementedError:
+            parentTable = None
+        isDetailedWhereAmI = args.get('formatType', None) == 'detailedWhereAmI'
+        if (settings.readTableCellRow or isDetailedWhereAmI) and parentTable \
+           and (not self._script.isLayoutOnly(obj.parent)):
+            parent = obj.parent
+            index = self._script.getCellIndex(obj)
+            row = parentTable.getRowAtIndex(index)
+            column = parentTable.getColumnAtIndex(index)
+
+            # This is an indication of whether we should speak all the
+            # table cells (the user has moved focus up or down a row),
+            # or just the current one (focus has moved left or right in
+            # the same row).
+            #
+            speakAll = True
+            if isDetailedWhereAmI:
+                if parentTable.nColumns <= 1:
+                    return result
+            elif "lastRow" in self._script.pointOfReference \
+               and "lastColumn" in self._script.pointOfReference:
+                pointOfReference = self._script.pointOfReference
+                speakAll = \
+                    (pointOfReference["lastRow"] != row) \
+                     or ((row == 0 or row == parentTable.nRows-1) \
+                     and pointOfReference["lastColumn"] == column)
+            if speakAll:
+                args['readingRow'] = True
+                for i in range(0, parentTable.nColumns):
+                    cell = parentTable.getAccessibleAt(row, i)
+                    if not cell:
+                        continue
+                    state = cell.getState()
+                    showing = state.contains(pyatspi.STATE_SHOWING)
+                    if showing:
+                        result.extend(self._generateRealTableCell(cell, **args))
+            else:
+                result.extend(self._generateRealTableCell(obj, **args))
+        else:
+            result.extend(self._generateRealTableCell(obj, **args))
+        return result
+
+    #####################################################################
+    #                                                                   #
     # Text interface information                                        #
     #                                                                   #
     #####################################################################
@@ -525,3 +852,17 @@ class Generator:
         except:
             pass
         return result
+
+    def _generateRealActiveDescendantDisplayedText(self, obj, **args ):
+        """Objects, such as tables and trees, can represent individual cells
+        via a complicated nested hierarchy.  This method returns an
+        array of strings (and possibly voice and audio specifications)
+        that represents the text actually being painted in the cell,
+        if it can be found.  Otherwise, an empty array is returned.
+        """
+        result = []
+        text = self._script.getDisplayedText(
+          self._script.getRealActiveDescendant(obj))
+        if text:
+            result = [text]
+        return result
diff --git a/src/orca/speech_generator.py b/src/orca/speech_generator.py
index f86ce56..7d7695a 100644
--- a/src/orca/speech_generator.py
+++ b/src/orca/speech_generator.py
@@ -191,31 +191,6 @@ class SpeechGenerator(generator.Generator):
     #                                                                   #
     #####################################################################
 
-    def _generateCellCheckedState(self, obj, **args):
-        """Returns an array of strings (and possibly voice and audio
-        specifications) that represent the checked state of the
-        object.  This is typically for check boxes that are in a
-        table. An empty array will be returned if this is not a
-        checkable cell.
-        """
-        result = []
-        try:
-            action = obj.queryAction()
-        except NotImplementedError:
-            action = None
-        if action:
-            for i in range(0, action.nActions):
-                # Translators: this is the action name for
-                # the 'toggle' action. It must be the same
-                # string used in the *.po file for gail.
-                #
-                if action.getName(i) in ["toggle", _("toggle")]:
-                    oldRole = self._overrideRole(pyatspi.ROLE_CHECK_BOX,
-                                            args)
-                    result.extend(self.generateSpeech(obj, **args))
-                    self._restoreRole(oldRole, args)
-        return result
-
     def _generateMultiselectableState(self, obj, **args):
         """Returns an array of strings (and possibly voice and audio
         specifications) that represent the multiselectable state of
@@ -389,7 +364,7 @@ class SpeechGenerator(generator.Generator):
             pass
         else:
             role = pyatspi.ROLE_IMAGE
-            result.extend(self.generateSpeech(obj, role=role))
+            result.extend(self.generate(obj, role=role))
         return result
 
     #####################################################################
@@ -398,49 +373,6 @@ class SpeechGenerator(generator.Generator):
     #                                                                   #
     #####################################################################
 
-    def _generateRowHeader(self, obj, **args):
-        """Returns an array of strings (and possibly voice and audio
-        specifications) that represent the row header for an object
-        that is in a table, if it exists.  Otherwise, an empty array
-        is returned.
-        """
-        result = []
-        try:
-            table = obj.parent.queryTable()
-        except:
-            pass
-        else:
-            index = self._script.getCellIndex(obj)
-            rowIndex = table.getRowAtIndex(index)
-            if rowIndex >= 0:
-                # Get the header information.  In Java Swing, the
-                # information is not exposed via the description
-                # but is instead a header object, so we fall back
-                # to that if it exists.
-                #
-                # [[[TODO: WDW - the more correct thing to do, I
-                # think, is to look at the row header object.
-                # We've been looking at the description for so
-                # long, though, that we'll give the description
-                # preference for now.]]]
-                #
-                desc = table.getRowDescription(rowIndex)
-                if not desc:
-                    header = table.getRowHeader(rowIndex)
-                    if header:
-                        desc = self._script.getDisplayedText(header)
-                if desc and len(desc):
-                    text = desc
-                    if settings.speechVerbosityLevel \
-                            == settings.VERBOSITY_LEVEL_VERBOSE \
-                       and not args.get('formatType', None) \
-                           in ['basicWhereAmI', 'detailedWhereAmI']:
-                        text += " " \
-                            + rolenames.rolenames[\
-                            pyatspi.ROLE_ROW_HEADER].speech
-                    result.append(text)
-        return result
-
     def _generateNewRowHeader(self, obj, **args):
         """Returns an array of strings (and possibly voice and audio
         specifications) that represent the row header for an object
@@ -487,49 +419,6 @@ class SpeechGenerator(generator.Generator):
                         result = self._generateRowHeader(obj, **args)
         return result
 
-    def _generateColumnHeader(self, obj, **args):
-        """Returns an array of strings (and possibly voice and audio
-        specifications) that represent the column header for an object
-        that is in a table, if it exists.  Otherwise, an empty array
-        is returned.
-        """
-        result = []
-        try:
-            table = obj.parent.queryTable()
-        except:
-            pass
-        else:
-            index = self._script.getCellIndex(obj)
-            columnIndex = table.getColumnAtIndex(index)
-            if columnIndex >= 0:
-                # Get the header information.  In Java Swing, the
-                # information is not exposed via the description
-                # but is instead a header object, so we fall back
-                # to that if it exists.
-                #
-                # [[[TODO: WDW - the more correct thing to do, I
-                # think, is to look at the row header object.
-                # We've been looking at the description for so
-                # long, though, that we'll give the description
-                # preference for now.]]]
-                #
-                desc = table.getColumnDescription(columnIndex)
-                if not desc:
-                    header = table.getColumnHeader(columnIndex)
-                    if header:
-                        desc = self._script.getDisplayedText(header)
-                if desc and len(desc):
-                    text = desc
-                    if settings.speechVerbosityLevel \
-                            == settings.VERBOSITY_LEVEL_VERBOSE \
-                       and not args.get('formatType', None) \
-                           in ['basicWhereAmI', 'detailedWhereAmI']:
-                        text += " " \
-                            + rolenames.rolenames[\
-                            pyatspi.ROLE_COLUMN_HEADER].speech
-                    result.append(text)
-        return result
-
     def _generateNewColumnHeader(self, obj, **args):
         """Returns an array of strings (and possibly voice and audio
         specifications) that represent the column header for an object
@@ -576,91 +465,6 @@ class SpeechGenerator(generator.Generator):
                         result = self._generateColumnHeader(obj, **args)
         return result
 
-    def _generateTableCell2ChildLabel(self, obj, **args):
-        """Returns an array of strings (and possibly voice and audio
-        specifications) for the label of a toggle in a table cell that
-        has a special 2 child pattern that we run into.  Otherwise, an
-        empty array is returned.
-        """
-        result = []
-
-        # If this table cell has 2 children and one of them has a
-        # 'toggle' action and the other does not, then present this
-        # as a checkbox where:
-        # 1) we get the checked state from the cell with the 'toggle' action
-        # 2) we get the label from the other cell.
-        # See Orca bug #376015 for more details.
-        #
-        if obj.childCount == 2:
-            cellOrder = []
-            hasToggle = [False, False]
-            for i, child in enumerate(obj):
-                try:
-                    action = child.queryAction()
-                except NotImplementedError:
-                    continue
-                else:
-                    for j in range(0, action.nActions):
-                        # Translators: this is the action name for
-                        # the 'toggle' action. It must be the same
-                        # string used in the *.po file for gail.
-                        #
-                        if action.getName(j) in ["toggle", _("toggle")]:
-                            hasToggle[i] = True
-                            break
-            if hasToggle[0] and not hasToggle[1]:
-                cellOrder = [ 1, 0 ]
-            elif not hasToggle[0] and hasToggle[1]:
-                cellOrder = [ 0, 1 ]
-            if cellOrder:
-                for i in cellOrder:
-                    if not hasToggle[i]:
-                        result.extend(self.generateSpeech(obj[i], **args))
-        return result
-
-    def _generateTableCell2ChildToggle(self, obj, **args):
-        """Returns an array of strings (and possinly voice and audio
-        specifications) for the toggle value of a toggle in a table
-        cell that has a special 2 child pattern that we run into.
-        Otherwise, an empty array is returned.
-        """
-        result = []
-
-        # If this table cell has 2 children and one of them has a
-        # 'toggle' action and the other does not, then present this
-        # as a checkbox where:
-        # 1) we get the checked state from the cell with the 'toggle' action
-        # 2) we get the label from the other cell.
-        # See Orca bug #376015 for more details.
-        #
-        if obj.childCount == 2:
-            cellOrder = []
-            hasToggle = [False, False]
-            for i, child in enumerate(obj):
-                try:
-                    action = child.queryAction()
-                except NotImplementedError:
-                    continue
-                else:
-                    for j in range(0, action.nActions):
-                        # Translators: this is the action name for
-                        # the 'toggle' action. It must be the same
-                        # string used in the *.po file for gail.
-                        #
-                        if action.getName(j) in ["toggle", _("toggle")]:
-                            hasToggle[i] = True
-                            break
-
-            if hasToggle[0] and not hasToggle[1]:
-                cellOrder = [ 1, 0 ]
-            elif not hasToggle[0] and hasToggle[1]:
-                cellOrder = [ 0, 1 ]
-            if cellOrder:
-                for i in cellOrder:
-                    if hasToggle[i]:
-                        result.extend(self.generateSpeech(obj[i], **args))
-        return result
-
     def _generateRealTableCell(self, obj, **args):
         """Orca has a feature to automatically read an entire row of a table
         as the user arrows up/down the roles.  This leads to complexity in
@@ -670,7 +474,7 @@ class SpeechGenerator(generator.Generator):
         """
         result = []
         oldRole = self._overrideRole('REAL_ROLE_TABLE_CELL', args)
-        result.extend(self.generateSpeech(obj, **args))
+        result.extend(self.generate(obj, **args))
         self._restoreRole(oldRole, args)
         if not result and settings.speakBlankLines \
            and not args.get('readingRow', False):
@@ -680,83 +484,6 @@ class SpeechGenerator(generator.Generator):
             result.append(_("blank"))
         return result
 
-    def _generateTableCellRow(self, obj, **args):
-        """Orca has a feature to automatically read an entire row of a table
-        as the user arrows up/down the roles.  This leads to complexity in
-        the code.  This method is used to return an array of strings
-        (and possibly voice and audio specifications) for an entire row
-        in a table if that's what the user has requested and if the row
-        has changed.  Otherwise, it will return an array for just the
-        current cell.
-        """
-        result = []
-
-        try:
-            parentTable = obj.parent.queryTable()
-        except NotImplementedError:
-            parentTable = None
-        isDetailedWhereAmI = args.get('formatType', None) == 'detailedWhereAmI'
-        if (settings.readTableCellRow or isDetailedWhereAmI) and parentTable \
-           and (not self._script.isLayoutOnly(obj.parent)):
-            parent = obj.parent
-            index = self._script.getCellIndex(obj)
-            row = parentTable.getRowAtIndex(index)
-            column = parentTable.getColumnAtIndex(index)
-
-            # This is an indication of whether we should speak all the
-            # table cells (the user has moved focus up or down a row),
-            # or just the current one (focus has moved left or right in
-            # the same row).
-            #
-            speakAll = True
-            if isDetailedWhereAmI:
-                if parentTable.nColumns <= 1:
-                    return result
-            elif "lastRow" in self._script.pointOfReference \
-               and "lastColumn" in self._script.pointOfReference:
-                pointOfReference = self._script.pointOfReference
-                speakAll = \
-                    (pointOfReference["lastRow"] != row) \
-                     or ((row == 0 or row == parentTable.nRows-1) \
-                     and pointOfReference["lastColumn"] == column)
-            if speakAll:
-                args['readingRow'] = True
-                for i in range(0, parentTable.nColumns):
-                    cell = parentTable.getAccessibleAt(row, i)
-                    if not cell:
-                        continue
-                    state = cell.getState()
-                    showing = state.contains(pyatspi.STATE_SHOWING)
-                    if showing:
-                        # If this table cell has a "toggle" action, and
-                        # doesn't have any label associated with it then
-                        # also speak the table column header.
-                        # See Orca bug #455230 for more details.
-                        #
-                        label = self._script.getDisplayedText(
-                            self._script.getRealActiveDescendant(cell))
-                        try:
-                            action = cell.queryAction()
-                        except NotImplementedError:
-                            action = None
-                        if action and (label == None or len(label) == 0):
-                            for j in range(0, action.nActions):
-                                # Translators: this is the action name for
-                                # the 'toggle' action. It must be the same
-                                # string used in the *.po file for gail.
-                                #
-                                if action.getName(j) in ["toggle",
-                                                         _("toggle")]:
-                                    accHeader = \
-                                        parentTable.getColumnHeader(i)
-                                    result.append(accHeader.name)
-                        result.extend(self._generateRealTableCell(cell, **args))
-            else:
-                result.extend(self._generateRealTableCell(obj, **args))
-        else:
-            result.extend(self._generateRealTableCell(obj, **args))
-        return result
-
     def _generateUnselectedCell(self, obj, **args):
         """Returns an array of strings (and possibly voice and audio
         specifications) if this is an icon within an layered pane or a
@@ -1302,20 +1029,6 @@ class SpeechGenerator(generator.Generator):
                 result.append(self._script.getDisplayedText(radioGroupLabel))
         return result
 
-    def _generateRealActiveDescendantDisplayedText(self, obj, **args ):
-        """Objects, such as tables and trees, can represent individual cells
-        via a complicated nested hierarchy.  This method returns an
-        array of strings (and possibly voice and audio specifications)
-        that represents the text actually being painted in the cell,
-        if it can be found.  Otherwise, an empty array is returned.
-        """
-        result = []
-        text = self._script.getDisplayedText(
-          self._script.getRealActiveDescendant(obj))
-        if text:
-            result = [text]
-        return result
-
     def _generateNumberOfChildren(self, obj, **args):
         """Returns an array of strings (and possibly voice and audio
         specifications) that represents the number of children the



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