Skip to content

Commit

Permalink
CompoundTextInfo:
Browse files Browse the repository at this point in the history
	* move(): Fix movement of end so that it doesn't skip blank paragraphs.
	* collapse(): When collapsing to end, move to the start of the next object if there is one, as the end of one object is equivalent to the start of the next.

soffice app module (Symphony): SymphonyTextInfo: Make _getStoryLength() account for the character faked in _getLineOffsets().

These changes fix two bugs with say all in Symphony:
	* It no longer skips blank paragraphs which contain list item prefixes.
	* It now moves the cursor to the start of the line being spoken instead of the end of the last spoken line.
  • Loading branch information
jcsteh committed Aug 18, 2010
1 parent 2729476 commit 34e25f1
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
4 changes: 4 additions & 0 deletions source/appModules/soffice.py
Expand Up @@ -96,6 +96,10 @@ def _getLineOffsets(self, offset):
return (0, 1)
return start, end

def _getStoryLength(self):
# HACK: Account for the character faked in _getLineOffsets() so that move() will work.
return max(super(SymphonyTextInfo, self)._getStoryLength(), 1)

class SymphonyText(IAccessible, EditableText):
TextInfo = SymphonyTextInfo

Expand Down
20 changes: 16 additions & 4 deletions source/compoundDocuments.py
Expand Up @@ -88,7 +88,15 @@ def setEndPoint(self, other, which):

def collapse(self, end=False):
if end:
self._end.collapse(end=True)
# The end of this object is equivalent to the start of the next.
# As well as being silly, collapsing to the end of this object causes say all to move the caret to the end of paragraphs.
# Therefore, collapse to the start of the next instead.
obj = self._endObj.flowsTo
if obj:
self._endObj = obj
self._end = obj.makeTextInfo(textInfos.POSITION_FIRST)
else:
self._end.collapse(end=True)
self._start = self._end
self._startObj = self._endObj
else:
Expand Down Expand Up @@ -317,9 +325,13 @@ def move(self, unit, direction, endPoint=None):
count0MoveAs = -1
else:
moveTi = moveObj.makeTextInfo(textInfos.POSITION_FIRST)
# If we're moving the end, the previous move would have taken us to the end of the previous object,
# which is equivalent to the start of this object (where we are now).
if endPoint != "end":
if endPoint == "end":
# If we're moving the end, the previous move would have taken us to the end of the previous object,
# which is equivalent to the start of this object (where we are now).
# Therefore, moving to this new object shouldn't be counted as a move.
# However, ensure that blank objects will still be counted as 1 step.
count0MoveAs = 1
else:
# We've moved to the start of the next unit.
remainingMovement -= 1
if remainingMovement == 0:
Expand Down

0 comments on commit 34e25f1

Please sign in to comment.