Date
1 - 4 of 4
Getting UIA TextInfo object from Word
Noelia Ruiz
Thanks as always, Alberto. I"ll look at this when I can.
toggle quoted message
Show quoted text
Enviado desde mi iPhone El 13 ene 2023, a las 16:55, Alberto Buffolino <a.buffolino@...> escribió: |
|
Alberto Buffolino
Noelia Ruiz, il 13/1/2023, ha scritto:
Hi Alberto: I suppose you have tried with git grep, right? Or searching pull requests based on changes for developers, and then seeing with files changed.Alberto: Hi Noelia, I searched in sources using Everything (it's the software name), being not interested to feature history. I still don't understand current mechanism in its whole process, nevertheless I finally found a feasible way. To recap, I was searching a way to switch from a non-UIA situation (no UIAElement present) to one with UIA during TextInfo elaboration, to query a specific text formatting/formatField attribute provided only via UIA (background-color). Just for documentation... 1. open a document with Word; 2. from document content area, open NVDA Python console; 3. submit line per line: *** import UIAHandler cl = UIAHandler.handler.clientObject UIAElement = cl.ElementFromHandleBuildCache(nav.windowHandle, UIAHandler.handler.baseCacheRequest) # get UIA version of nav from NVDAObjects.UIA import UIA obj = UIA(windowHandle=nav.windowHandle, UIAElement=UIAElement) # get UIA version of nav TextInfo # (but you could use obj.UIATextPattern, # even if it's more difficult) from NVDAObjects.UIA import UIATextInfo uti = UIATextInfo(obj=obj, position=textInfos.POSITION_CARET) # now it's as usual uti.expand(textInfos.UNIT_LINE) # build formatConfig formatConfig=config.conf["documentFormatting"].dict() for k,v in formatConfig.items(): if v is True: formatConfig[k] = False formatConfig["reportColor"] = True fields=uti.getTextWithFields(formatConfig) for field in fields: if isinstance(field, textInfos.FieldCommand) and field.command == "formatChange" and field.field.get("background-color", None): color = field.field["background-color"] color.name *** Alberto |
|
Noelia Ruiz
Hi Alberto: I suppose you have tried with git grep, right? Or searching pull requests based on changes for developers, and then seeing with files changed. For now it"s what I think without a PC here, visitting a friend. Hope someone has more suggestions.u
toggle quoted message
Show quoted text
Enviado desde mi iPhone El 13 ene 2023, a las 0:40, Alberto Buffolino <a.buffolino@...> escribió: |
|
Alberto Buffolino
Hi all,
I'm searching and searching in sources, but without success. I know that using of UIA in Word is controlled by config.AllowUiaInMSWord, that you can modify via relative Advanced setting. Because this can be, among others, "when appropiate" and "always", I suppose that in some circumstances an UIA object is built at runtime and used to retrieve specific attribute, like annotation, comment, etc (as is my case with background color, retrievable only in "always" mode). But I was not able to find the point in code where this switch happens. Any suggestions? Thanks. Alberto |
|