Support math content in MS Word build 14326+ via UIA#12977
Support math content in MS Word build 14326+ via UIA#12977michaelDCurran merged 7 commits intomasterfrom
Conversation
|
Assuming that we keep accessing UIA by default in recent builds of MS Word for NvDA 2021.4, it is necessary for this pr to be also included, otherwise users will loose access to mathematical content. |
See test results for failed build of commit 44ef7b49e4 |
| class WordBrowseModeDocument(UIABrowseModeDocument): | ||
|
|
||
| def shouldSetFocusToObj(self,obj): | ||
| def _shouldSetFocusToObj(self, obj: NVDAObject) -> bool: |
There was a problem hiding this comment.
Is changing the name of this function an API breaking change?
There was a problem hiding this comment.
No, it was actually incorrectly named in the first place. It should be an override for BrowseModeDocumentTreeInterceptor._shouldSetfocusToObj. In other words, that code never actually ran. It correctly does now.
There was a problem hiding this comment.
However, there may be add-ons that are calling shouldSetFocusToObj directly. If this is going into 2021.3 then I think there should be an alias (then removed in 2022.1)
def _shouldSetFocusToObj(self, obj: NVDAObject) -> bool:
...
if nvdaversion.year < 2022:
shouldSetFocusToObj = _shouldSetFocusToObj # deprecated to be removed in 2022.1
Qchristensen
left a comment
There was a problem hiding this comment.
This is good and will be appreciated by users, great work :)
|
Oh, cool! |
| elif obj.role == controlTypes.Role.MATH: | ||
| # Don't set focus to math equations otherwise they cannot be interacted with mathPlayer. | ||
| return False | ||
| return super(WordBrowseModeDocument,self).shouldSetFocusToObj(obj) |
There was a problem hiding this comment.
Don't forget this one
| return super(WordBrowseModeDocument,self).shouldSetFocusToObj(obj) | |
| return super()._shouldSetFocusToObj(obj) |
|
|
||
| def shouldSetFocusToObj(self,obj): | ||
| def _shouldSetFocusToObj(self, obj: NVDAObject) -> bool: | ||
| # Ignore strange editable text fields surrounding most inner fields (links, table cells etc) |
There was a problem hiding this comment.
Could you move the below lines into a helper function and call that in both _shouldSetFocusToObj and shouldPassThrough? That way it's easier to see equal logic is used.
There was a problem hiding this comment.
I don't think this is worth doing as it is really just two lines in each. An elif and a return False. Also, just because the lines do seem to look the same, they are of course representing slightly different questions.
| try: | ||
| return self._getUIACacheablePropertyValue(self._UIACustomProps.word_mathml.id) | ||
| except COMError: | ||
| pass |
There was a problem hiding this comment.
Rather than passing (i.e. returning None implicitly), I think it's nicer to return None explicitly here.
| Note however that any previously created MathType equations must be first converted to Office Math by selecting each and choosing Equation Options -> Convert to Office Math in the context menu. Ensure your version of MathType is the latest version before doing this. | ||
| Microsoft Word also now provides linea symbol-based navigation through the equations itself, and supports inputting math using several syntaxes, including LateX. For further details, please see [Linear format equations using UnicodeMath and LaTeX in Word https://support.microsoft.com/en-us/office/linear-format-equations-using-unicodemath-and-latex-in-word-2e00618d-b1fd-49d8-8cb4-8d17f25754f8] | ||
| - Microsoft Powerpoint, and older versions of Microsoft Word: | ||
| NVDA can read and navigate MathType equations in both Microsoft Powerpoint and Microsoft word. |
There was a problem hiding this comment.
Just to make sure, have you verified that this is formatted nicely?
bda90f2
6fc89e3 to
bda90f2
Compare
… should have always been _shouldSetFocusToObj
Co-authored-by: Sean Budd <sean@nvaccess.org>
4ae3b10 to
80606f4
Compare
|
This has been rebased to master and will be not in NVDA 2021.3. |
|
It's a shame not to include this pr in 2021.3. |
|
@cary-rowen please note also that UIA will not be forced by default in 2021.3 according to #12989. So this shouldn't be a problem not to have this PR included. |
|
This PR is still listed under 2021.3 changes. Is this a mistake? |
…21.3 to 2022.1; the PR (nvaccess#12977) has been retargetted from beta to master but the change log item has been forgotten.
|
Yes it's a mistake due to retargetting from beta to master. Good catch! |
Link to issue number:
Fixes #12946
Fixes #12941
Summary of the issue:
NVDA was able to provide rich support of mathematical content in Microsoft Word by making use of MathPlayer, MathType and the MS Word object model.
However, when NVDA only relies on UI Automation to access MS Word docuents, it is no longer possible to fetch mathMl from MathType equations via the MS Word object model.
However, Microsoft very recently added a new UI Automation custom property for fetching raw mathMl from an Office Equation node, thus if NVDa were to fetch this mathMl, then it could pass it along to mathPlayer as usual, then providing rich reading / navigation of math content in MS word again.
Description of how this pull request fixes the issue:
Note that MS Word also provides a basic form of linea symbol navigation in equations, so we make sure that the mathMl is exposed to mathPlayer when moving by line, replacing MS Word's own inner math content. But if moving by word/character, then MS Word's own inner math content is left in tact.
Testing strategy:
x^2+x+1and pressed enter.Known issues with pull request:
Users / authors will have to convert any old MathType equations to Office Equations by selecting each equation, and then choosing Equation Options -> Convert to Office math in the context menu.
The experience for typing math equations is now slightly different in that the user needs to now use Microsoft Word's own math input feature. I.e. pressing alt+= and typing the equation. However, MS Word does now support several input syntaxes, including LateX similar to MathType.
Change log entries:
New features
In Microsoft Word accessed via UI Automation, NVDA will now make use of mathPlayer to read and navigate Office math equations. (#12946)
- For this to work, you must be running Microsoft Word 365/2016 build 14326 or later.
- MathType equations must also be manually converted to Office Math by selecting each and choosing Equation options -> Convert to Office Math in the context menu.
Changes
Bug fixes
For Developers
Code Review Checklist: