orca r4164 - in trunk: . src/orca
- From: joanied svn gnome org
- To: svn-commits-list gnome org
- Subject: orca r4164 - in trunk: . src/orca
- Date: Sat, 6 Sep 2008 22:42:12 +0000 (UTC)
Author: joanied
Date: Sat Sep 6 22:42:12 2008
New Revision: 4164
URL: http://svn.gnome.org/viewvc/orca?rev=4164&view=rev
Log:
* src/orca/default.py:
Fix for bug #551159 - Orca says "link" when it shouldn't and
sometimes fails to say it when it should in OOo Writer documents.
Modified:
trunk/ChangeLog
trunk/src/orca/default.py
Modified: trunk/src/orca/default.py
==============================================================================
--- trunk/src/orca/default.py (original)
+++ trunk/src/orca/default.py Sat Sep 6 22:42:12 2008
@@ -2123,7 +2123,7 @@
if settings.enableSpeechIndentation:
self.speakTextIndentation(obj, line)
- line = self.adjustForLinks(obj, line)
+ line = self.adjustForLinks(obj, line, startOffset)
line = self.adjustForRepeats(line)
speech.speak(line, voice)
@@ -6301,17 +6301,20 @@
return line
- def adjustForLinks(self, obj, line):
+ def adjustForLinks(self, obj, line, startOffset):
"""Adjust line to include the word "link" after any hypertext links.
Arguments:
- obj: the accessible object that this line came from.
- line: the string to adjust for links.
+ - startOffset: the caret offset at the start of the line.
- Returns: a new line adjusted for repeat character counts (if enabled).
+ Returns: a new line adjusted to add the speaking of "link" after
+ text which is also a link.
"""
line = line.decode("UTF-8")
+ endOffset = startOffset + len(line)
try:
hyperText = obj.queryHypertext()
@@ -6319,28 +6322,34 @@
except:
nLinks = 0
- n = nLinks
- while n > 0:
- link = hyperText.getLink(n-1)
-
- # If the link was not followed by a whitespace or punctuation
- # character, then add in a space to make it more presentable.
- #
- trailingChar = " "
- if link.endIndex < len(line) and \
- (line[link.endIndex] in self.whitespace or \
- punctuation_settings.getPunctuationInfo(line[link.endIndex])):
- trailingChar = ""
+ adjustedLine = list(line)
+ for n in range(nLinks, 0, -1):
+ link = hyperText.getLink(n - 1)
+
+ # We only care about links in the string, line:
+ #
+ if startOffset < link.endIndex < endOffset:
+ index = link.endIndex - startOffset
+ elif startOffset <= link.startIndex < endOffset:
+ index = len(line) - 1
+ else:
+ continue
# Translators: this indicates that this piece of
# text is a hypertext link.
#
- line = line[0:link.endIndex] + " " + _("link") + \
- trailingChar + line[link.endIndex:]
+ linkString = " " + _("link")
- n -= 1
+ # If the link was not followed by a whitespace or punctuation
+ # character, then add in a space to make it more presentable.
+ #
+ nextChar = adjustedLine[index]
+ if not (nextChar in self.whitespace \
+ or punctuation_settings.getPunctuationInfo(nextChar)):
+ linkString += " "
+ adjustedLine[index:index] = linkString
- return line.encode("UTF-8")
+ return "".join(adjustedLine).encode("UTF-8")
def adjustForRepeats(self, line):
"""Adjust line to include repeat character counts.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]