Changeset 2377

Show
Ignore:
Timestamp:
09/11/08 11:48:26 (2 months ago)
Author:
pvagner
Message:

* ITextDocumentTextInfo: Fixed a problem where NVDA was unable to move the review cursor to the bottom line. Added ability to detect strikedthrough font property.
* EditTextInfo? and ITextDocumentTextInfo: Introduced ability to identify links inside a richedit controls. Added _getPoint method which retrieves x and y coordinates for the current textInfo ofsset/range.
* script_moveMouseToNavigatorObject now makes use of the features listed above. When navigator object mouse is being moved to implements _getPoint in its textInfo, mouse is moved to the currently reviewed character. Otherwise mouse is moved into the center of the navigator object.

Location:
trunk/source
Files:
5 modified

Legend:

Unmodified
Added
Removed
  • trunk/source/NVDAObjects/IAccessible/edit.py

    r2374 r2377  
    160160class EditTextInfo(NVDAObjectTextInfo): 
    161161 
     162        def _getPoint(self): 
     163                self.expand(textHandler.UNIT_CHARACTER) 
     164                offset=self._startOffset 
     165                if self.obj.editAPIVersion==1: 
     166                        processHandle=self.obj.editProcessHandle 
     167                        internalP=winKernel.virtualAllocEx(processHandle,None,ctypes.sizeof(PointLStruct),winKernel.MEM_COMMIT,winKernel.PAGE_READWRITE) 
     168                        p=PointLStruct(0,0) 
     169                        winKernel.writeProcessMemory(processHandle,internalP,ctypes.byref(p),ctypes.sizeof(p),None) 
     170                        winUser.sendMessage(self.obj.windowHandle,EM_POSFROMCHAR,internalP,self._startOffset) 
     171                        winKernel.readProcessMemory(processHandle,internalP,ctypes.byref(p),ctypes.sizeof(p),None) 
     172                        winKernel.virtualFreeEx(processHandle,internalP,0,winKernel.MEM_RELEASE) 
     173                        point=textHandler.Point(p.x,p.y) 
     174                else: 
     175                        res=winUser.sendMessage(self.obj.windowHandle,EM_POSFROMCHAR,self._startOffset,None) 
     176                        point=textHandler.Point(winUser.LOWORD(res),winUser.HIWORD(res)) 
     177                (left,top,width,height)=self.obj.location 
     178                if point.x and point.y: 
     179                        point.x=point.x+left 
     180                        point.y=point.y+top 
     181                        return point 
     182                else: 
     183                        return None 
     184 
    162185        def _getOffsetFromPoint(self,x,y): 
    163186                (left,top,width,height)=self.obj.location 
     
    221244                if formatConfig["reportLineNumber"]: 
    222245                        formatField["line-number"]=self._getLineNumFromOffset(offset)+1 
     246                if formatConfig["reportLinks"]: 
     247                        if charFormat is None: charFormat=self._getCharFormat(offset) 
     248                        formatField["link"]=bool(charFormat.dwEffects&CFM_LINK) 
    223249                return formatField,(startOffset,endOffset) 
    224250 
     
    387413class ITextDocumentTextInfo(textHandler.TextInfo): 
    388414 
     415        def _getPoint(self): 
     416                range=self._rangeObj.duplicate 
     417                range.collapse(True) 
     418                range.expand(comInterfaces.tom.tomCharacter) 
     419                p=textHandler.Point(0,0) 
     420                (p.x,p.y)=range.GetPoint(comInterfaces.tom.tomStart) 
     421                if p.x and p.y: 
     422                        return p 
     423                else: 
     424                        return None 
     425 
     426        def _getCharFormat(self,range): 
     427                oldSel=self.obj.ITextSelectionObject.duplicate 
     428                if not (oldSel.start==range.start and oldSel.end==range.end): 
     429                        self.obj.ITextSelectionObject.start=range.start 
     430                        self.obj.ITextSelectionObject.end=range.end 
     431                if self.obj.isWindowUnicode: 
     432                        charFormatStruct=CharFormat2WStruct 
     433                else: 
     434                        charFormatStruct=CharFormat2AStruct 
     435                charFormat=charFormatStruct() 
     436                charFormat.cbSize=ctypes.sizeof(charFormatStruct) 
     437                processHandle=self.obj.editProcessHandle 
     438                internalCharFormat=winKernel.virtualAllocEx(processHandle,None,ctypes.sizeof(charFormat),winKernel.MEM_COMMIT,winKernel.PAGE_READWRITE) 
     439                winKernel.writeProcessMemory(processHandle,internalCharFormat,ctypes.byref(charFormat),ctypes.sizeof(charFormat),None) 
     440                winUser.sendMessage(self.obj.windowHandle,EM_GETCHARFORMAT,SCF_SELECTION, internalCharFormat) 
     441                winKernel.readProcessMemory(processHandle,internalCharFormat,ctypes.byref(charFormat),ctypes.sizeof(charFormat),None) 
     442                winKernel.virtualFreeEx(processHandle,internalCharFormat,0,winKernel.MEM_RELEASE) 
     443                if not (oldSel.start==range.start and oldSel.end==range.end): 
     444                        self.obj.ITextSelectionObject.start=oldSel.start 
     445                        self.obj.ITextSelectionObject.end=oldSel.end 
     446                return charFormat 
     447 
    389448        def _getFormatFieldAtRange(self,range,formatConfig): 
    390449                formatField=textHandler.FormatField() 
    391450                fontObj=None 
    392451                paraFormatObj=None 
     452                charFormat=None 
    393453                if formatConfig["reportAlignment"]: 
    394454                        if not paraFormatObj: paraFormatObj=range.para 
     
    415475                        formatField["italic"]=bool(fontObj.italic) 
    416476                        formatField["underline"]=bool(fontObj.underline) 
     477                        formatField["strikethrough"]=bool(fontObj.StrikeThrough) 
    417478                        if fontObj.superscript: 
    418479                                formatField["text-position"]="super" 
    419480                        elif fontObj.subscript: 
    420481                                formatField["text-position"]="sub" 
     482                if formatConfig["reportLinks"]: 
     483                        if charFormat is None: charFormat=self._getCharFormat(range) 
     484                        formatField["link"]=bool(charFormat.dwEffects&CFM_LINK) 
    421485                return formatField 
    422486 
     
    493557                elif position==textHandler.POSITION_LAST: 
    494558                        self._rangeObj=self.obj.ITextDocumentObject.range(0,0) 
    495                         self._rangeObj.moveEnd(comInterfaces.tom.tomStory,1) 
    496                         self._rangeObj.move(comInterfaces.tom.tomCharacter,-1) 
     559                        self._rangeObj.move(comInterfaces.tom.tomStory,1) 
     560                        self._rangeObj.moveStart(comInterfaces.tom.tomCharacter,-1) 
    497561                elif isinstance(position,textHandler.Offsets): 
    498562                        self._rangeObj=self.obj.ITextDocumentObject.range(position.startOffset,position.endOffset) 
     
    626690                else: 
    627691                        self.TextInfo=EditTextInfo 
    628                 if self.TextInfo is EditTextInfo: 
    629                         self.editProcessHandle=winKernel.openProcess(winKernel.PROCESS_VM_OPERATION|winKernel.PROCESS_VM_READ|winKernel.PROCESS_VM_WRITE,False,self.windowProcessID) 
     692                self.editProcessHandle=winKernel.openProcess(winKernel.PROCESS_VM_OPERATION|winKernel.PROCESS_VM_READ|winKernel.PROCESS_VM_WRITE,False,self.windowProcessID) 
    630693 
    631694        def __del__(self): 
    632                 if self.TextInfo is EditTextInfo: 
    633                         winKernel.closeHandle(self.editProcessHandle) 
     695                winKernel.closeHandle(self.editProcessHandle) 
    634696 
    635697        def _get_TextInfo(self): 
     
    681743        ("ExtendedLeft","moveByCharacter"), 
    682744        ("ExtendedRight","moveByCharacter"), 
     745        ("ExtendedPrior","moveByLine"), 
     746        ("ExtendedNext","moveByLine"), 
    683747        ("Control+ExtendedLeft","moveByWord"), 
    684748        ("Control+ExtendedRight","moveByWord"), 
  • trunk/source/NVDAObjects/__init__.py

    r2356 r2377  
    137137        def _getOffsetAtPoint(self,x,y): 
    138138                raise NotImplementedError 
     139 
     140        def _getPoint(self): 
     141                return None 
    139142 
    140143        def __init__(self,obj,position): 
  • trunk/source/appModules/_default.py

    r2372 r2377  
    162162        def script_moveMouseToNavigatorObject(self,keyPress): 
    163163                speech.speakMessage(_("Move mouse to navigator")) 
    164                 obj=api.getNavigatorObject() 
    165                 try: 
    166                         (left,top,width,height)=obj.location 
    167                 except: 
    168                         speech.speakMessage(_("object has no location")) 
    169                         return 
    170                 winUser.setCursorPos(left+(width/2),top+(height/2)) 
     164                obj=api.getNavigatorObject()  
     165                p=globalVars.reviewPosition.copy()._getPoint() 
     166                if p: 
     167                        winUser.setCursorPos(p.x,p.y) 
     168                else: 
     169                        try: 
     170                                (left,top,width,height)=obj.location 
     171                        except: 
     172                                speech.speakMessage(_("object has no location")) 
     173                                return 
     174                        winUser.setCursorPos(left+(width/2),top+(height/2)) 
    171175        script_moveMouseToNavigatorObject.__doc__=_("Moves the mouse pointer to the current navigator object") 
    172176 
  • trunk/source/speech.py

    r2369 r2377  
    738738                                text=_("align default") 
    739739                        textList.append(text) 
     740        if  formatConfig["reportLinks"]: 
     741                link=attrs.get("link") 
     742                oldLink=attrsCache.get("link") if attrsCache is not None else None 
     743                if (link or oldLink is not None) and link!=oldLink: 
     744                        text=_("link") if link else _("out of %s")%_("link") 
     745                        textList.append(text) 
    740746        if formatConfig["reportSpellingErrors"]: 
    741747                invalidSpelling=attrs.get("invalid-spelling") 
  • trunk/source/textHandler.py

    r2356 r2377  
    127127UNIT_SCREEN="screen" 
    128128UNIT_STORY="story" 
    129 UNIT_READINGCHUNK="readingChunck" 
     129UNIT_READINGCHUNK="readingChunk" 
    130130 
    131131class TextInfo(baseObject.AutoPropertyObject):