[Nvda-dev] commit r3415 - in trunk/source: . NVDAObjects/window

NVDA Subversion svn at nvda-project.org
Mon Dec 7 00:09:03 UTC 2009


Author: bzr
Date: Mon Dec  7 00:09:03 2009
New Revision: 3415

Log:
These changes try to fix the issue where NVDA will not show a new blank line on a braille display when pressing enter in a Microsoft Word document or MSHTML edit control.
      Specific changes:
	* braille.TextInfoRegion.update: TextInfo implementations such as for MS Word and MSHTML can only expand to line if dealing with the caret. So rather then making a copy of the caret TextInfo and then expanding to line, use the copy as the caret reference and expand the original TextInfo to line.
        * Microsoft Word document TextInfo: remove _expandToLine method and replace it with a better implementation (calling it _expandToLineFromCaret, for better readability). This method uses caret and window coordinates and sets it to the line containing the caret. I.e. from the left edge of the window at the height of the caret to the right side of the window at the height of the caret.
      The advantage of this new way is that we no longer fiddle with MS Word's actual selection, which means no flickering, and it also will stop possible typing errors if typing fast when using braille, due to the above braille change.
      The one disadvantage is that now when arrowing by line in a table, NVDA will report the line relative to the document, rather than relative to the current
 table cell (i.e. it will read the entire row).
      We may be able to fix this in the future by not allowing the use of this way when in a table, though finding this out is quite costly.

      Please test Microsoft Word cursoring a lot, and report any bugs created by this change.


Modified:
   trunk/source/NVDAObjects/window/winword.py
   trunk/source/braille.py

Modified: trunk/source/NVDAObjects/window/winword.py
==============================================================================
--- trunk/source/NVDAObjects/window/winword.py	(original)
+++ trunk/source/NVDAObjects/window/winword.py	Mon Dec  7 00:09:03 2009
@@ -97,13 +97,16 @@
 
 
 
-	def _expandToLine(self,rangeObj):
-		sel=self.obj.WinwordSelectionObject
-		oldSel=sel.range
-		sel.SetRange(rangeObj.start,rangeObj.end)
-		sel.Expand(wdLine)
-		rangeObj.SetRange(sel.Start,sel.End)
-		sel.SetRange(oldSel.Start,oldSel.End)
+	def _expandToLineFromCaret(self):
+		info=winUser.getGUIThreadInfo(self.obj.windowThreadID)
+		caretPoint=ctypes.wintypes.POINT(info.rcCaret.left,info.rcCaret.top)
+		ctypes.windll.user32.ClientToScreen(self.obj.windowHandle,ctypes.byref(caretPoint))
+		caretY=caretPoint.y
+		clientLeft,clientTop,clientWidth,clientHeight=self.obj.location
+		tempRange=self.obj.WinwordDocumentObject.application.activeWindow.rangeFromPoint(clientLeft,caretY)
+		self._rangeObj.Start=tempRange.Start
+		tempRange=self.obj.WinwordDocumentObject.application.activeWindow.rangeFromPoint(clientLeft+clientWidth,caretY)
+		self._rangeObj.End=tempRange.Start
 
 	def _getFormatFieldAtRange(self,range,formatConfig):
 		formatField=textInfos.FormatField()
@@ -221,7 +224,7 @@
 		if unit==textInfos.UNIT_LINE and self.basePosition not in (textInfos.POSITION_CARET,textInfos.POSITION_SELECTION):
 			unit=textInfos.UNIT_SENTENCE
 		if unit==textInfos.UNIT_LINE:
-			self._expandToLine(self._rangeObj)
+			self._expandToLineFromCaret()
 		elif unit==textInfos.UNIT_CHARACTER:
 			self._rangeObj.moveEnd(wdCharacter,1)
 		elif unit in NVDAUnitsToWordUnits:

Modified: trunk/source/braille.py
==============================================================================
--- trunk/source/braille.py	(original)
+++ trunk/source/braille.py	Mon Dec  7 00:09:03 2009
@@ -297,10 +297,12 @@
 			log.debugWarning("", exc_info=True)
 
 	def update(self):
-		caret = self._getSelection()
-		caret.collapse()
+		# HACK: Some TextInfos only support UNIT_LINE properly if they are based on POSITION_CARET,
+		# so use the original caret TextInfo for line and copy for caret.
+		self._line = line = self._getSelection()
+		line.collapse()
+		caret = line.copy()
 		# Get the line at the caret.
-		self._line = line = caret.copy()
 		line.expand(textInfos.UNIT_LINE)
 		# Not all text APIs support offsets, so we can't always get the offset of the caret relative to the start of the line.
 		# Therefore, grab the line in two parts.



More information about the Nvda-dev mailing list