-
-
Notifications
You must be signed in to change notification settings - Fork 651
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MS Word documents: report when headings are collapsed in both speech and braille. #17499
base: master
Are you sure you want to change the base?
Conversation
Co-authored-by: Sascha Cowley <[email protected]>
For the feature to be complete, the following could be added to this PR:
If you prefer have this development merged as is, at least, document these missing points in "Known issues" sections and open new issues to track these missing points. Thanks. |
expandCollapseState = UIARemote.msWord_getCustomAttributeValue( | ||
docElement, | ||
textRange, | ||
UIACustomAttributeID.EXPAND_COLLAPSE_STATE, | ||
) | ||
if expandCollapseState == EXPAND_COLLAPSE_STATE.COLLAPSED: | ||
formatField.field["collapsed"] = True | ||
elif expandCollapseState == EXPAND_COLLAPSE_STATE.EXPANDED: | ||
formatField.field["collapsed"] = False |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I get the following error with an older Word version:
UnboundLocalError: cannot access local variable 'docElement' where it is not associated with a value
You should indent this code to execute it in the "if" branch where docElement
is defined.
expandCollapseState = UIARemote.msWord_getCustomAttributeValue( | |
docElement, | |
textRange, | |
UIACustomAttributeID.EXPAND_COLLAPSE_STATE, | |
) | |
if expandCollapseState == EXPAND_COLLAPSE_STATE.COLLAPSED: | |
formatField.field["collapsed"] = True | |
elif expandCollapseState == EXPAND_COLLAPSE_STATE.EXPANDED: | |
formatField.field["collapsed"] = False | |
expandCollapseState = UIARemote.msWord_getCustomAttributeValue( | |
docElement, | |
textRange, | |
UIACustomAttributeID.EXPAND_COLLAPSE_STATE, | |
) | |
if expandCollapseState == EXPAND_COLLAPSE_STATE.COLLAPSED: | |
formatField.field["collapsed"] = True | |
elif expandCollapseState == EXPAND_COLLAPSE_STATE.EXPANDED: | |
formatField.field["collapsed"] = False |
@CyrilleB79 I have addressed the docElement issue pre Windows 11, and also exposed collapsed for headings in Word with the object model. |
source/braille.py
Outdated
collapsed = field.get("collapsed") | ||
if collapsed: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why does this need to be assigned to a variable?
collapsed = field.get("collapsed") | |
if collapsed: | |
if field.get("collapsed"): |
user_docs/en/changes.md
Outdated
@@ -27,7 +27,7 @@ To use this feature, "allow NVDA to control the volume of other applications" mu | |||
* Automatic language switching is now supported when using Microsoft Speech API version 5 (SAPI5) and Microsoft Speech Platform voices. (#17146, @gexgd0419) | |||
* NVDA can now be configured to speak the current line or paragraph when navigating with braille navigation keys. (#17053, @nvdaes) | |||
* In Word, the selection update is now reported when using Word commands to extend or reduce the selection (`f8` or `shift+f8`). (#3293, @CyrilleB79) | |||
* In Word 16.0.18226 and higher, NVDA will now report if a heading is collapsed in both speech and braille. (#17499) | |||
* In Microsoft Word 16.0.18226 and higher, NVDA will now report if a heading is collapsed in both speech and braille. (#17499) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the version of Word applicable now that this has been added to the object model too?
I have just tested this PR, launching the installer (nvda_snapshot_pr17499-34747,bb1e29a1.exe) and running the temporary version.
I am with:
|
@CyrilleB79 This is expected because Windows 10 doesn't have remote ops support in UIA core. |
I can't reproduce the crash.
I'll need a crash dump if you can get one. However, if this is hard to
get / or we can not trace the reason, then I'll need to remove the
object model support for reporting collapsed from this PR, as I cannot
hold back the UIA part (which works fine on win11) - it is a request
from Microsoft.
|
I have not been able to get a crash dump for Word. I have tried both methods described in NVDA wiki:
In both cases, I cannot get any dumpfile. I have also tried to force a dumpfile, killing winword process from task manager without success, so I am probably doing something wrong when trying to get the dumpfile. Word crashes, actually disappears, when arrowing in text heading formatted, or when trying to use expand / collapse commands. When I move the caret in normal (body) text, there is no problem. It would be nice to be able to fix this. @Adriani90 would you be able to reproduce the crash described here with object model (legacy, i.e. "Only when necessary" in advanced settings)? But if it is not possible to fix the issue with Word Object model, nor reproducible on your side, I understand that you may want to merge the UIA part, what is already an improvement. |
@michaelDCurran, I have found why it crashes on my end and tested that it does not crash anymore with the fix, running from source. Strange that you have not experimented this crash; maybe you were not really testing Word object model due to 13704? |
I was definitely testing with the object model. Perhaps you are using
32 bit MS Word and I am using 64 bit, or you have tighter execution /
memory policies set in Windows?
Either way, I'm glad you found the cause.
|
Co-authored-by: Cyrille Bougot <[email protected]>
Yes, I am running Office 2016 32 bits. |
Co-authored-by: Sascha Cowley <[email protected]> Co-authored-by: Cyrille Bougot <[email protected]>
Link to issue number:
None.
Summary of the issue:
In Microsoft Word, it is possible to collapse a heading, so that all the paragraphs directly following the heading are hidden. As of MS Word 16.0.18226, a new UIA text range custom attribute was added, to convey the expand collapse state of headings. NVDA should report when a heading is collapsed based on this value.
Description of user facing changes
In Microsoft Word, If a heading is collapsed, NVDA will now report this in speech and braille.
Description of development approach
Testing strategy:
Tested with MS Word 16.0.18331.
Known issues with pull request:
None known.
This implementation only reports when a heading is collapsed, and not explicitly when expanded. However, as expanded headings will far outweigh collapsed, I think it would be way too noisy to report expanded, when that is going to be the norm.
Code Review Checklist:
@coderabbitai summary