44#See the file COPYING for more details.
55
66from comtypes import COMError
7- import comtypes .automation
8- import comtypes .client
97import ctypes
10- import NVDAHelper
8+ import operator
9+ import uuid
1110from logHandler import log
12- import oleacc
1311import winUser
1412import speech
13+ import braille
1514import controlTypes
15+ import config
16+ import tableUtils
1617import textInfos
1718import eventHandler
1819import scriptHandler
20+ import ui
1921from . import IAccessible
2022from displayModel import EditableTextDisplayModelTextInfo
21- from NVDAObjects .window import DisplayModelEditableText
2223from ..behaviors import EditableTextWithoutAutoSelectDetection
23- from NVDAObjects .window .winword import *
24- from NVDAObjects .window .winword import WordDocumentTreeInterceptor
24+ import NVDAObjects .window .winword as winWordWindowModule
2525from speech import sayAll
2626
2727
28- class WordDocument (IAccessible ,EditableTextWithoutAutoSelectDetection ,WordDocument ):
29-
30- treeInterceptorClass = WordDocumentTreeInterceptor
28+ class WordDocument (IAccessible , EditableTextWithoutAutoSelectDetection , winWordWindowModule . WordDocument ):
29+
30+ treeInterceptorClass = winWordWindowModule . WordDocumentTreeInterceptor
3131 shouldCreateTreeInterceptor = False
32- TextInfo = WordDocumentTextInfo
32+ TextInfo = winWordWindowModule . WordDocumentTextInfo
3333
3434 def _get_ignoreEditorRevisions (self ):
3535 try :
@@ -112,7 +112,7 @@ def getHeaderCellTrackerForTable(self,table):
112112 except (COMError , AttributeError ):
113113 tableRangesEqual = False
114114 if not tableRangesEqual :
115- self ._curHeaderCellTracker = HeaderCellTracker ()
115+ self ._curHeaderCellTracker = tableUtils . HeaderCellTracker ()
116116 self .populateHeaderCellTrackerFromBookmarks (self ._curHeaderCellTracker ,tableRange .bookmarks )
117117 self .populateHeaderCellTrackerFromHeaderRows (self ._curHeaderCellTracker ,table )
118118 self ._curHeaderCellTrackerTable = table
@@ -140,7 +140,7 @@ def setAsHeaderCell(self,cell,isColumnHeader=False,isRowHeader=False):
140140 name = "ColumnTitle_"
141141 else :
142142 raise ValueError ("One or both of isColumnHeader or isRowHeader must be True" )
143- name += uuid .uuid4 ().hex
143+ name += uuid .uuid4 ().hex
144144 if oldInfo :
145145 self .WinwordDocumentObject .bookmarks [oldInfo .name ].delete ()
146146 oldInfo .name = name
@@ -323,8 +323,8 @@ def _moveInTable(self,row=True,forward=True):
323323 thisIndex = rowNumber if row else columnNumber
324324 otherIndex = columnNumber if row else rowNumber
325325 thisLimit = (rowCount if row else columnCount ) if forward else 1
326- limitOp = operator .le if forward else operator .ge
327- incdecFunc = operator .add if forward else operator .sub
326+ limitOp = operator .le if forward else operator .ge
327+ incdecFunc = operator .add if forward else operator .sub
328328 foundCell = None
329329 curOtherIndex = otherIndex
330330 while curOtherIndex > 0 :
@@ -341,7 +341,9 @@ def _moveInTable(self,row=True,forward=True):
341341 if not foundCell :
342342 ui .message (_ ("Edge of table" ))
343343 return False
344- newInfo = WordDocumentTextInfo (self ,textInfos .POSITION_CARET ,_rangeObj = foundCell )
344+ newInfo = winWordWindowModule .WordDocumentTextInfo (
345+ self , textInfos .POSITION_CARET , _rangeObj = foundCell
346+ )
345347 speech .speakTextInfo (newInfo , reason = controlTypes .OutputReason .CARET , unit = textInfos .UNIT_CELL )
346348 newInfo .collapse ()
347349 newInfo .updateCaret ()
@@ -362,15 +364,15 @@ def script_previousColumn(self,gesture):
362364 def script_nextParagraph (self ,gesture ):
363365 info = self .makeTextInfo (textInfos .POSITION_CARET )
364366 # #4375: can't use self.move here as it may check document.chracters.count which can take for ever on large documents.
365- info ._rangeObj .move (wdParagraph ,1 )
367+ info ._rangeObj .move (winWordWindowModule . wdParagraph , 1 )
366368 info .updateCaret ()
367369 self ._caretScriptPostMovedHelper (textInfos .UNIT_PARAGRAPH ,gesture ,None )
368370 script_nextParagraph .resumeSayAllMode = sayAll .CURSOR .CARET
369371
370372 def script_previousParagraph (self ,gesture ):
371373 info = self .makeTextInfo (textInfos .POSITION_CARET )
372- # #4375: keeping cemetrical with nextParagraph script.
373- info ._rangeObj .move (wdParagraph ,- 1 )
374+ # #4375: keeping symmetrical with nextParagraph script.
375+ info ._rangeObj .move (winWordWindowModule . wdParagraph , - 1 )
374376 info .updateCaret ()
375377 self ._caretScriptPostMovedHelper (textInfos .UNIT_PARAGRAPH ,gesture ,None )
376378 script_previousParagraph .resumeSayAllMode = sayAll .CURSOR .CARET
@@ -398,7 +400,8 @@ def focusOnActiveDocument(self, officeChartObject):
398400 "kb:NVDA+alt+c" :"reportCurrentComment" ,
399401 }
400402
401- class SpellCheckErrorField (IAccessible ,WordDocument_WwN ):
403+
404+ class SpellCheckErrorField (IAccessible , winWordWindowModule .WordDocument_WwN ):
402405
403406 parentSDMCanOverrideName = False
404407 ignoreFormatting = True
@@ -460,8 +463,8 @@ def event_gainFocus(self):
460463 document = next ((x for x in self .children if isinstance (x ,WordDocument )), None )
461464 if document :
462465 curThreadID = ctypes .windll .kernel32 .GetCurrentThreadId ()
463- ctypes . windll . user32 .AttachThreadInput (curThreadID ,document .windowThreadID ,True )
464- ctypes . windll .user32 .SetFocus (document .windowHandle )
465- ctypes . windll . user32 .AttachThreadInput (curThreadID ,document .windowThreadID ,False )
466+ winUser . user32 .AttachThreadInput (curThreadID , document .windowThreadID , True )
467+ winUser .user32 .SetFocus (document .windowHandle )
468+ winUser . user32 .AttachThreadInput (curThreadID , document .windowThreadID , False )
466469 if not document .WinwordWindowObject .active :
467470 document .WinwordWindowObject .activate ()
0 commit comments