Skip to content

Report background and highlighting colors in Microsoft Word #5866

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

Closed
LeonarddeR opened this issue Apr 7, 2016 · 6 comments · Fixed by #14610
Closed

Report background and highlighting colors in Microsoft Word #5866

LeonarddeR opened this issue Apr 7, 2016 · 6 comments · Fixed by #14610
Labels
app/microsoft-office enhancement needs-technical-investigation A technical investigation is required to progress the issue. p4 https://github.com/nvaccess/nvda/blob/master/projectDocs/issues/triage.md#priority triaged Has been triaged, issue is waiting for implementation.
Milestone

Comments

@LeonarddeR
Copy link
Collaborator

I noticed that NVDA is unable to report background and highlighting color changes in Microsoft Word. Check the attachment for an example.

Steps to reproduce

  1. Type a two lines of text in an empty document
  2. Select the second line of text
  3. Press alt+h,i and select a highlighting color
  4. Select again, press alt+h,h and select a differenc background color
  5. Arrow up and down in the document with color reporting enabled

Actual result: NVDA reports no difference
Proposed result: NVDA reports both background and highlighting color changes

@LeonarddeR
Copy link
Collaborator Author

Given the recent work that has been done to improve MS Word support (#2961, #5800, #5946), I'd like to bring this ticket under attention again.

@feerrenrut, mind assigning a priority to this?

@feerrenrut feerrenrut added enhancement app/microsoft-office p4 https://github.com/nvaccess/nvda/blob/master/projectDocs/issues/triage.md#priority labels Mar 13, 2017
@nishimotz
Copy link
Contributor

Requested the enhancement in Japan, regarding Microsoft Outlook as well.

@Adriani90
Copy link
Collaborator

This would be really helpful. I hope it will come any time in the future into NVDA.

@ABuffEr
Copy link
Contributor

ABuffEr commented Jan 15, 2023

Hi @LeonarddeR ,

I heavily played with UIA and VBA in recent days, around this situation.

Imho, it's very confused even API side.

Had you find a reliable way to distinguish between background and highlight color?

I found only this property useful to be sure whether there is an highlighting and what's the color applied...

@seanbudd seanbudd added the triaged Has been triaged, issue is waiting for implementation. label Jan 16, 2023
@LeonarddeR
Copy link
Collaborator Author

I haven't played with this for years, so I have no idea honestly.

@seanbudd seanbudd added the needs-technical-investigation A technical investigation is required to progress the issue. label Jan 16, 2023
@ABuffEr
Copy link
Contributor

ABuffEr commented Jan 16, 2023

Meanwhile I encountered problems with attached document, so i suspect the situation is changed from 2016, even in current Word support of these formatting in documents made with previous versions.

However, Range.Shading.BackgroundPatternColor seems a good candidate to query for background.

I'll continue to investigate, these seem to be things quite important in school, for teachers and students.

seanbudd pushed a commit that referenced this issue Apr 4, 2023
Fixes #5866, fixes #7396, fixes #12101

Summary of the issue:
In these years, Microsoft Word users working without UIA had no feedback about background and highlighting colors, often used by colleagues, teachers and students.

UIA has provided a partial solution when available, but its support for these features is far from perfect (see later).

Description of user facing changes
Assuming UIA is not available/forcibly enabled:

when color reporting is enabled in formatting preferences, users will hear background colors too;
when marked/highlighted text reporting is enabled in formatting preferences, users will hear highlighting colors ("highlighted in {color}" and "no highlighting"), regardless of color reporting.
Description of development approach
It was very difficult to find a way, so I'll add some details.

Initially, I used VBA objects approach, querying Paragraph.Shading.BackgroundPatternColor and Range.HighlightColorIndex over a winwordDocument.Range to calculate each time, so it was very slow.

Then I found this document and, after having understood what I needed and how to find the required wdDISPID_ constants, I was able to move all work on the C++ component of nvdaHelperRemote related to winword, that appears very much faster.

In window/winword.py, to take advantage of winwordColorToNVDAColor work, I added also a dict that collects indexes from wdColorIndex and decimal values from wdColor.

About speech, I had to introduce a new format field, highlight-color.

Now, UIA: sure, it already covers background and highlight colors, but expose them as the same attribute, via UIA_BackgroundColorAttributeId (and no, I asked, even visually they are distinct). There is an AnnotationType_Highlighted identifier, but it seems to not be used in this scenario.

Locally I have a possible workaround, based on the fact that, as you see in Word Home menu, highlighting color is applied to characters, background color to paragraphs; so, if textRange has a background-color, I compare it to that retrieved from paragraph and, if I receive IUnknown/MixedAttributeValue, I assume the initial one is an highlighting color and try to get the real background color from "\r" EOL.

But I'm not totally convinced, so I not included it in this PR for now.
@nvaccessAuto nvaccessAuto added this to the 2023.2 milestone Apr 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
app/microsoft-office enhancement needs-technical-investigation A technical investigation is required to progress the issue. p4 https://github.com/nvaccess/nvda/blob/master/projectDocs/issues/triage.md#priority triaged Has been triaged, issue is waiting for implementation.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants