Index: ChangeLog
===================================================================
--- ChangeLog	(revision 2288)
+++ ChangeLog	(working copy)
@@ -1,3 +1,17 @@
+2007-04-17  Rich Burridge <rich.burridge@sun.com>
+
+        * src/orca/settings.py:
+          src/orca/orca-setup.glade:
+          src/orca/orca_prefs.py:
+          src/orca/orca_gui_prefs.py:
+          src/orca/scripts/gedit.py:
+          src/orca/scripts/Evolution.py:
+          More work on bug #400716 – sayAll should be done by sentences.
+          Added a "Say All By" combo box to the speech pane of the Orca
+          Preferences dialog (accelerator is Alt-y). Current valid choices 
+          are "Line" and "Sentence". Adjusted the existing textLines() 
+          routines to use it.
+
 2007-04-13  Willie Walker <william.walker@sun.com>
 
         * src/orca/scripts/StarOffice.py: minor bug fix and pychecker
Index: src/orca/scripts/gedit.py
===================================================================
--- src/orca/scripts/gedit.py	(revision 2288)
+++ src/orca/scripts/gedit.py	(working copy)
@@ -160,19 +160,28 @@
         textObjs.append(obj)
         startOffset = obj.text.caretOffset
 
+        # Determine the correct "say all by" mode to use.
+        #        
+        if settings.sayAllStyle == settings.SAYALL_STYLE_SENTENCE:
+            mode = atspi.Accessibility.TEXT_BOUNDARY_SENTENCE_END
+        elif settings.sayAllStyle == settings.SAYALL_STYLE_LINE:
+            mode = atspi.Accessibility.TEXT_BOUNDARY_LINE_START
+        else:
+            mode = atspi.Accessibility.TEXT_BOUNDARY_LINE_START
+
         # Get the next line of text to read
         #
         done = False
         while not done:
             lastEndOffset = -1
             while offset < length:
-                [mystr, start, end] = text.getTextAtOffset(offset,
-                          atspi.Accessibility.TEXT_BOUNDARY_SENTENCE_END)
+                [mystr, start, end] = text.getTextAtOffset(offset, mode)
 
                 if len(mystr) != 0:
                     string += mystr
 
-                if len(mystr) == 0 or mystr[len(mystr)-1] in '.?!':
+                if mode == atspi.Accessibility.TEXT_BOUNDARY_LINE_START or \
+                   len(mystr) == 0 or mystr[len(mystr)-1] in '.?!':
                     endOffset = end
 
                     string = self.adjustForRepeats(string)
Index: src/orca/scripts/Evolution.py
===================================================================
--- src/orca/scripts/Evolution.py	(revision 2288)
+++ src/orca/scripts/Evolution.py	(working copy)
@@ -358,6 +358,15 @@
         string = ""
         done = False
 
+        # Determine the correct "say all by" mode to use.
+        #
+        if settings.sayAllStyle == settings.SAYALL_STYLE_SENTENCE:
+            mode = atspi.Accessibility.TEXT_BOUNDARY_SENTENCE_END
+        elif settings.sayAllStyle == settings.SAYALL_STYLE_LINE:
+            mode = atspi.Accessibility.TEXT_BOUNDARY_LINE_START
+        else:
+            mode = atspi.Accessibility.TEXT_BOUNDARY_LINE_START
+
         while not done:
             accPanel = htmlPanel.accessible.getChildAtIndex(i)
             panel = atspi.Accessible.makeAccessible(accPanel)
@@ -371,11 +380,13 @@
 
             while offset <= length:
                 [mystr, start, end] = textObj.text.getTextAtOffset(offset,
-                               atspi.Accessibility.TEXT_BOUNDARY_SENTENCE_END)
+                                                                   mode)
+
                 if len(mystr) != 0:
                     string += mystr
 
-                if len(mystr) == 0 or mystr[len(mystr)-1] in '.?!':
+                if mode == atspi.Accessibility.TEXT_BOUNDARY_LINE_START or \
+                   len(mystr) == 0 or mystr[len(mystr)-1] in '.?!':
                     endOffset = end
 
                     string = self.adjustForRepeats(string)
Index: src/orca/settings.py
===================================================================
--- src/orca/settings.py	(revision 2288)
+++ src/orca/settings.py	(working copy)
@@ -125,6 +125,7 @@
     "verbalizePunctuationStyle",
     "showMainWindow",
     "quitOrcaNoConfirmation",
+    "sayAllStyle",
     "keyboardLayout",
     "speakBlankLines",
 ]
@@ -193,6 +194,12 @@
 PUNCTUATION_STYLE_ALL  = 0
 verbalizePunctuationStyle = PUNCTUATION_STYLE_MOST
 
+# Say All styles (see sayAllStyle).
+#
+SAYALL_STYLE_LINE     = 0
+SAYALL_STYLE_SENTENCE = 1
+sayAllStyle = SAYALL_STYLE_SENTENCE
+
 # The absolue amount to change the speech rate when
 # increasing or decreasing speech.  This is a numerical
 # value that represents an ACSS rate value.
Index: src/orca/orca-setup.glade
===================================================================
--- src/orca/orca-setup.glade	(revision 2288)
+++ src/orca/orca-setup.glade	(working copy)
@@ -1212,6 +1212,67 @@
 		      <property name="fill">False</property>
 		    </packing>
 		  </child>
+
+		  <child>
+		    <widget class="GtkHBox" id="hbox39">
+		      <property name="visible">True</property>
+		      <property name="homogeneous">False</property>
+		      <property name="spacing">3</property>
+
+		      <child>
+			<widget class="GtkLabel" id="sayAllLabel">
+			  <property name="visible">True</property>
+			  <property name="label" translatable="yes">Say All B_y:</property>
+			  <property name="use_underline">True</property>
+			  <property name="use_markup">False</property>
+			  <property name="justify">GTK_JUSTIFY_LEFT</property>
+			  <property name="wrap">False</property>
+			  <property name="selectable">False</property>
+			  <property name="xalign">0.5</property>
+			  <property name="yalign">0.5</property>
+			  <property name="xpad">0</property>
+			  <property name="ypad">0</property>
+			  <property name="mnemonic_widget">sayAllStyle</property>
+			  <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+			  <property name="width_chars">-1</property>
+			  <property name="single_line_mode">False</property>
+			  <property name="angle">0</property>
+			  <accessibility>
+			    <atkrelation target="sayAllStyle" type="label-for"/>
+			  </accessibility>
+			</widget>
+			<packing>
+			  <property name="padding">0</property>
+			  <property name="expand">False</property>
+			  <property name="fill">False</property>
+			</packing>
+		      </child>
+
+		      <child>
+			<widget class="GtkComboBox" id="sayAllStyle">
+			  <property name="visible">True</property>
+			  <property name="items" translatable="yes">Line
+Sentence</property>
+			  <property name="add_tearoffs">False</property>
+			  <property name="focus_on_click">True</property>
+			  <accessibility>
+			    <atkrelation target="sayAllLabel" type="labelled-by"/>
+			  </accessibility>
+			  <signal name="changed" handler="sayAllStyleChanged" last_modification_time="Mon, 16 Apr 2007 17:10:02 GMT"/>
+			</widget>
+			<packing>
+			  <property name="padding">3</property>
+			  <property name="expand">False</property>
+			  <property name="fill">False</property>
+			</packing>
+		      </child>
+		    </widget>
+		    <packing>
+		      <property name="padding">3</property>
+		      <property name="expand">False</property>
+		      <property name="fill">False</property>
+		    </packing>
+		  </child>
 		</widget>
 		<packing>
 		  <property name="tab_expand">False</property>
Index: src/orca/orca_prefs.py
===================================================================
--- src/orca/orca_prefs.py	(revision 2288)
+++ src/orca/orca_prefs.py	(working copy)
@@ -233,6 +233,13 @@
     else:
         return "orca.settings.PUNCTUATION_STYLE_ALL"
 
+def _getSayAllStyleString(sayAllStyle):
+    """Returns a string that represents the say all style passed in."""
+    if sayAllStyle == settings.SAYALL_STYLE_LINE:
+        return "orca.settings.SAYALL_STYLE_LINE"
+    elif sayAllStyle == settings.SAYALL_STYLE_SENTENCE:
+        return "orca.settings.SAYALL_STYLE_SENTENCE"
+
 def _getMagCursorColorString(cursorColor):
     """Returns a string that represents the magnification cursor color
     passed in.
@@ -421,6 +428,8 @@
                 value = _getBrailleRolenameStyleString(prefsDict[key])
             elif key == "verbalizePunctuationStyle":
                 value = _getVerbalizePunctuationStyleString(prefsDict[key])
+            elif key == "sayAllStyle":
+                value = _getSayAllStyleString(prefsDict[key])
             elif key == "magCursorColor":
                 value = _getMagCursorColorString(prefsDict[key])
             elif key == "magSmoothingMode":
Index: src/orca/default.py
===================================================================
--- src/orca/default.py	(revision 2288)
+++ src/orca/default.py	(working copy)
@@ -4435,6 +4435,15 @@
         length = text.characterCount
         offset = text.caretOffset
 
+        # Determine the correct "say all by" mode to use.
+        #        
+        if settings.sayAllStyle == settings.SAYALL_STYLE_SENTENCE:
+            mode = atspi.Accessibility.TEXT_BOUNDARY_SENTENCE_END
+        elif settings.sayAllStyle == settings.SAYALL_STYLE_LINE:
+            mode = atspi.Accessibility.TEXT_BOUNDARY_LINE_START
+        else:
+            mode = atspi.Accessibility.TEXT_BOUNDARY_LINE_START
+
         # Get the next line of text to read
         #
         done = False
@@ -4442,17 +4451,16 @@
             lastEndOffset = -1
             while offset < length:
                 [string, startOffset, endOffset] = text.getTextAtOffset(
-                    offset,
-                    atspi.Accessibility.TEXT_BOUNDARY_SENTENCE_END)
+                    offset, mode)
 
                 # Some applications that don't support sentence boundaries
                 # will provide the line boundary results instead; others
                 # will return nothing.
                 #
                 if not string:
+                    mode = atspi.Accessibility.TEXT_BOUNDARY_LINE_START
                     [string, startOffset, endOffset] = text.getTextAtOffset(
-                        offset,
-                        atspi.Accessibility.TEXT_BOUNDARY_LINE_START)
+                                                               offset, mode)
 
                 # [[[WDW - HACK: well...gnome-terminal sometimes wants to
                 # give us outrageous values back from getTextAtOffset
Index: src/orca/orca_gui_prefs.py
===================================================================
--- src/orca/orca_gui_prefs.py	(revision 2288)
+++ src/orca/orca_gui_prefs.py	(working copy)
@@ -777,6 +777,8 @@
         self.speakBlankLinesCheckButton.set_active(\
             prefs["speakBlankLines"])
 
+        self.sayAllStyle.set_active(prefs["sayAllStyle"])
+
         # Braille pane.
         #
         self.brailleSupportCheckbutton.set_active(prefs["enableBraille"])
@@ -1581,6 +1583,21 @@
                 self.prefsDict["verbalizePunctuationStyle"] = \
                     settings.PUNCTUATION_STYLE_ALL
 
+    def sayAllStyleChanged(self, widget):
+        """Signal handler for the "changed" signal for the sayAllStyle
+           GtkComboBox widget. Set the 'sayAllStyle' preference to the 
+           new value.
+
+        Arguments:
+        - widget: the component that generated the signal.
+        """
+
+        sayAllStyle = widget.get_active_text()
+        if sayAllStyle == _("Line"):
+            self.prefsDict["sayAllStyle"] = settings.SAYALL_STYLE_LINE
+        elif sayAllStyle == _("Sentence"):
+            self.prefsDict["sayAllStyle"] = settings.SAYALL_STYLE_SENTENCE
+
     def speechVerbosityChanged(self, widget):
         """Signal handler for the "toggled" signal for the speechBriefButton,
            or speechVerboseButton GtkRadioButton widgets. The user has
