Package appModules :: Module winword
[hide private]
[frames] | no frames]

Source Code for Module appModules.winword

 1  #appModules/winword.py 
 2  #A part of NonVisual Desktop Access (NVDA) 
 3  #Copyright (C) 2006-2010 NVDA Contributors <http://www.nvda-project.org/> 
 4  #This file is covered by the GNU General Public License. 
 5  #See the file COPYING for more details. 
 6   
 7  import comtypes.client 
 8  import comtypes.automation 
 9  import controlTypes 
10  import textInfos 
11  import winUser 
12  import speech 
13  import appModuleHandler 
14  from NVDAObjects.window.winword import WordDocument 
15   
16 -class AppModule(appModuleHandler.AppModule):
17
18 - def chooseNVDAObjectOverlayClasses(self, obj, clsList):
19 if obj.windowClassName in ("_WwN","_WwO") and obj.role==controlTypes.ROLE_EDITABLETEXT: 20 #Word 2003 and above 21 clsList.insert(0, SpellCheckErrorField)
22
23 -class SpellCheckErrorField(WordDocument):
24 25 parentSDMCanOverrideName=False 26
28 if not hasattr(self,'_WinwordWindowObject'): 29 try: 30 self._WinwordWindowObject=comtypes.client.dynamic.Dispatch(comtypes.client.GetActiveObject('word.application',interface=comtypes.automation.IDispatch)).activeWindow.activePane 31 except: 32 return None 33 return self._WinwordWindowObject
34
35 - def _get_name(self):
36 return super(SpellCheckErrorField,self).description
37
38 - def _get_description(self):
39 return ""
40
41 - def reportFocus(self):
42 speech.speakObjectProperties(self,name=True,role=True) 43 info=self.makeTextInfo(textInfos.POSITION_CARET) 44 info.move(textInfos.UNIT_WORD,-1,endPoint="start") 45 try: 46 error=info._rangeObj.spellingErrors[1].text 47 except: 48 info.expand(textInfos.UNIT_STORY) 49 speech.speakText(info.text) 50 return 51 speech.speakText(error) 52 speech.speakSpelling(error)
53