Skip to content

Commit 7c017fd

Browse files
authored
Merge 1ead7a5 into e8f14f9
2 parents e8f14f9 + 1ead7a5 commit 7c017fd

2 files changed

Lines changed: 167 additions & 12 deletions

File tree

source/NVDAObjects/window/winword.py

Lines changed: 161 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,27 @@
7373
wdMaximumNumberOfRows=15
7474
wdStartOfRangeColumnNumber=16
7575
wdMaximumNumberOfColumns=18
76+
77+
# Underline style
78+
wdUnderlineNone = 0
79+
wdUnderlineSingle = 1
80+
wdUnderlineWords = 2
81+
wdUnderlineDouble = 3
82+
wdUnderlineDotted = 4
83+
wdUnderlineThick = 6
84+
wdUnderlineDash = 7
85+
wdUnderlineDotDash = 9
86+
wdUnderlineDotDotDash = 10
87+
wdUnderlineWavy = 11
88+
wdUnderlineDottedHeavy = 20
89+
wdUnderlineDashHeavy = 23
90+
wdUnderlineDotDashHeavy = 25
91+
wdUnderlineDotDotDashHeavy = 26
92+
wdUnderlineWavyHeavy = 27
93+
wdUnderlineDashLong = 39
94+
wdUnderlineWavyDouble = 43
95+
wdUnderlineDashLongHeavy = 55
96+
7697
#Horizontal alignment
7798
wdAlignParagraphLeft=0
7899
wdAlignParagraphCenter=1
@@ -195,6 +216,18 @@
195216
wdThemeColorText1=13
196217
wdThemeColorText2=15
197218

219+
# WdCharacterCase enumeration
220+
wdNextCase = -1
221+
wdLowerCase = 0
222+
wdUpperCase = 1
223+
wdTitleWord = 2
224+
wdTitleSentence = 4
225+
wdToggleCase = 5
226+
wdHalfWidth = 6
227+
wdFullWidth = 7
228+
wdKatakana = 8
229+
wdHiragana = 9
230+
198231
# Word Field types
199232
FIELD_TYPE_REF = 3 # cross reference field
200233
FIELD_TYPE_HYPERLINK = 88 # hyperlink field
@@ -258,6 +291,43 @@
258291
wdRevisionCellMerge:_("cell merge"),
259292
}
260293

294+
wdUnderlineTypeDescriptions = {
295+
# Translators: an underline style in Microsoft Word as announced in the font window.
296+
wdUnderlineSingle: _("Single"),
297+
# Translators: an underline style in Microsoft Word as announced in the font window.
298+
wdUnderlineWords: _("Words only"),
299+
# Translators: an underline style in Microsoft Word as announced in the font window.
300+
wdUnderlineDouble: _("Double"),
301+
# Translators: an underline style in Microsoft Word as announced in the font window.
302+
wdUnderlineDotted: _("Dotted"),
303+
# Translators: an underline style in Microsoft Word as announced in the font window.
304+
wdUnderlineThick: _("Thick"),
305+
# Translators: an underline style in Microsoft Word as announced in the font window.
306+
wdUnderlineDash: _("Dash"),
307+
# Translators: an underline style in Microsoft Word as announced in the font window.
308+
wdUnderlineDotDash: _("Dot dash"),
309+
# Translators: an underline style in Microsoft Word as announced in the font window.
310+
wdUnderlineDotDotDash: _("Dot dot dash"),
311+
# Translators: an underline style in Microsoft Word as announced in the font window.
312+
wdUnderlineWavy: _("Wave"),
313+
# Translators: an underline style in Microsoft Word as announced in the font window.
314+
wdUnderlineDottedHeavy: _("Dotted heavy"),
315+
# Translators: an underline style in Microsoft Word as announced in the font window.
316+
wdUnderlineDashHeavy: _("Dashed heavy"),
317+
# Translators: an underline style in Microsoft Word as announced in the font window.
318+
wdUnderlineDotDashHeavy: _("Dot dash heavy"),
319+
# Translators: an underline style in Microsoft Word as announced in the font window.
320+
wdUnderlineDotDotDashHeavy: _("Dot dot dash heavy"),
321+
# Translators: an underline style in Microsoft Word as announced in the font window.
322+
wdUnderlineWavyHeavy: _("Wave heavy"),
323+
# Translators: an underline style in Microsoft Word as announced in the font window.
324+
wdUnderlineDashLong: _("Dashed long"),
325+
# Translators: an underline style in Microsoft Word as announced in the font window.
326+
wdUnderlineWavyDouble: _("Wave double"),
327+
# Translators: an underline style in Microsoft Word as announced in the font window.
328+
wdUnderlineDashLongHeavy: _("Dashed long heavy"),
329+
}
330+
261331
storyTypeLocalizedLabels={
262332
wdCommentsStory:_("Comments"),
263333
wdEndnotesStory:_("Endnotes"),
@@ -271,6 +341,29 @@
271341
wdTextFrameStory:_("Text frame"),
272342
}
273343

344+
wdCharacterCaseTypeLabels = {
345+
# Translators: a Microsoft Word character case type
346+
wdNextCase: _("No case"), # Returned when selection range contains only case-insensitive characters
347+
# Translators: a Microsoft Word character case type
348+
wdLowerCase: _("Lowercase"),
349+
# Translators: a Microsoft Word character case type
350+
wdUpperCase: _("Uppercase"),
351+
# Translators: a Microsoft Word character case type
352+
wdTitleWord: _("Each word capitalized"),
353+
# Translators: a Microsoft Word character case type
354+
wdTitleSentence: _("Sentence case"),
355+
# Translators: a Microsoft Word character case type
356+
wdToggleCase: _("Mixed case"),
357+
# Translators: a Microsoft Word character case type
358+
wdHalfWidth: _("Half width:"),
359+
# Translators: a Microsoft Word character case type
360+
wdFullWidth: _("Full width"),
361+
# Translators: a Microsoft Word character case type
362+
wdKatakana: _("Katakana"),
363+
# Translators: a Microsoft Word character case type
364+
wdHiragana: _("Hiragana"),
365+
}
366+
274367
wdFieldTypesToNVDARoles={
275368
wdFieldFormTextInput:controlTypes.ROLE_EDITABLETEXT,
276369
wdFieldFormCheckBox:controlTypes.ROLE_CHECKBOX,
@@ -1243,6 +1336,7 @@ def _WaitForValueChangeForAction(self,action,fetcher,timeout=0.15):
12431336
curTime=time.time()
12441337
return curVal
12451338

1339+
@script(gestures=["kb:control+b", "kb:control+shift+b"])
12461340
def script_toggleBold(self,gesture):
12471341
if not self.WinwordSelectionObject:
12481342
# We cannot fetch the Word object model, so we therefore cannot report the format change.
@@ -1257,6 +1351,7 @@ def script_toggleBold(self,gesture):
12571351
# Translators: a message when toggling formatting in Microsoft word
12581352
ui.message(_("Bold off"))
12591353

1354+
@script(gestures=["kb:control+i", "kb:control+shift+i"])
12601355
def script_toggleItalic(self,gesture):
12611356
if not self.WinwordSelectionObject:
12621357
# We cannot fetch the Word object model, so we therefore cannot report the format change.
@@ -1271,16 +1366,24 @@ def script_toggleItalic(self,gesture):
12711366
# Translators: a message when toggling formatting in Microsoft word
12721367
ui.message(_("Italic off"))
12731368

1274-
def script_toggleUnderline(self,gesture):
1369+
@script(gestures=["kb:control+u", "kb:control+shift+u", "kb:control+shift+d", "kb:control+shift+w"])
1370+
def script_toggleUnderline(self, gesture):
12751371
if not self.WinwordSelectionObject:
12761372
# We cannot fetch the Word object model, so we therefore cannot report the format change.
1277-
# The object model may be unavailable because this is a pure UIA implementation such as Windows 10 Mail, or its within Windows Defender Application Guard.
1278-
# Eventually UIA will have its own way of detecting format changes at the cursor. For now, just let the gesture through and don't erport anything.
1373+
# The object model may be unavailable because this is a pure UIA implementation such as Windows 10 Mail,
1374+
# or its within Windows Defender Application Guard.
1375+
# Eventually UIA will have its own way of detecting format changes at the cursor.
1376+
# For now, just let the gesture through and don't report anything.
12791377
return gesture.send()
1280-
val=self._WaitForValueChangeForAction(lambda: gesture.send(),lambda: self.WinwordSelectionObject.font.underline)
1281-
if val:
1282-
# Translators: a message when toggling formatting in Microsoft word
1283-
ui.message(_("Underline on"))
1378+
val = self._WaitForValueChangeForAction(
1379+
lambda: gesture.send(),
1380+
lambda: self.WinwordSelectionObject.font.underline
1381+
)
1382+
if val != wdUnderlineNone:
1383+
msg = wdUnderlineTypeDescriptions.get(val)
1384+
if msg:
1385+
# Translators: a message when toggling formatting in Microsoft word
1386+
ui.message(_("Underline {style}").format(style=msg))
12841387
else:
12851388
# Translators: a message when toggling formatting in Microsoft word
12861389
ui.message(_("Underline off"))
@@ -1306,6 +1409,57 @@ def script_toggleAlignment(self,gesture):
13061409
if msg:
13071410
ui.message(msg)
13081411

1412+
@script(gestures=["kb:control+shift+a", "kb:control+shift+k"])
1413+
def script_toggleCaps(self, gesture):
1414+
if not self.WinwordSelectionObject:
1415+
# We cannot fetch the Word object model, so we therefore cannot report the format change.
1416+
# The object model may be unavailable because this is a pure UIA implementation such as Windows 10 Mail,
1417+
# or its within Windows Defender Application Guard.
1418+
# Eventually UIA will have its own way of detecting format changes at the cursor.
1419+
# For now, just let the gesture through and don't report anything.
1420+
return gesture.send()
1421+
val = self._WaitForValueChangeForAction(
1422+
lambda: gesture.send(),
1423+
lambda: (self.WinwordSelectionObject.font.allcaps, self.WinwordSelectionObject.font.smallcaps)
1424+
)
1425+
if val[0]:
1426+
# Translators: a message when toggling formatting to 'all capital' in Microsoft word
1427+
ui.message(_("All caps on"))
1428+
elif val[1]:
1429+
# Translators: a message when toggling formatting to 'small capital' in Microsoft word
1430+
ui.message(_("Small caps on"))
1431+
else:
1432+
# Translators: a message when toggling formatting to 'No capital' in Microsoft word
1433+
ui.message(_("Caps off"))
1434+
1435+
@script(gesture="kb:shift+f3")
1436+
def script_changeCase(self, gesture):
1437+
if not self.WinwordSelectionObject:
1438+
# We cannot fetch the Word object model, so we therefore cannot report the format change.
1439+
# The object model may be unavailable because this is a pure UIA implementation such as Windows 10 Mail,
1440+
# or its within Windows Defender Application Guard.
1441+
# For now, just let the gesture through and don't report anything.
1442+
return gesture.send()
1443+
val = self._WaitForValueChangeForAction(
1444+
lambda: gesture.send(),
1445+
lambda: self.WinwordSelectionObject.Range.Case
1446+
)
1447+
# Under Outlook, calling the script quickly a second time gives strange results.
1448+
# Case value passes sometimes through an intermediate value.
1449+
# So poll the value a second time.
1450+
val = self._WaitForValueChangeForAction(
1451+
lambda: None,
1452+
lambda: self.WinwordSelectionObject.Range.Case
1453+
)
1454+
# Translators: a message when changing case in Microsoft Word
1455+
ui.message(wdCharacterCaseTypeLabels.get(val))
1456+
1457+
@script(gestures=[
1458+
"kb:control+=",
1459+
"kb:control+shift+=",
1460+
"kb:control+plus",
1461+
"kb:control+shift+plus",
1462+
])
13091463
def script_toggleSuperscriptSubscript(self,gesture):
13101464
if not self.WinwordSelectionObject:
13111465
# We cannot fetch the Word object model, so we therefore cannot report the format change.
@@ -1482,11 +1636,6 @@ def initOverlayClass(self):
14821636
"kb:control+]":"increaseDecreaseFontSize",
14831637
"kb:control+shift+,":"increaseDecreaseFontSize",
14841638
"kb:control+shift+.":"increaseDecreaseFontSize",
1485-
"kb:control+b":"toggleBold",
1486-
"kb:control+i":"toggleItalic",
1487-
"kb:control+u":"toggleUnderline",
1488-
"kb:control+=":"toggleSuperscriptSubscript",
1489-
"kb:control+shift+=":"toggleSuperscriptSubscript",
14901639
"kb:control+l":"toggleAlignment",
14911640
"kb:control+e":"toggleAlignment",
14921641
"kb:control+r":"toggleAlignment",

source/appModules/outlook.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -565,6 +565,12 @@ def script_tab(self, gesture):
565565
if not caretMoved:
566566
return
567567
self.reportTab()
568+
569+
__gestures = {
570+
"kb:control+shift+w": None, # Shortcut existing in Word but not in Outlook
571+
"kb:control+shift+b": None, # Shortcut existing in Word but opens address book in Outlook
572+
"kb:control+shift+a": "changeCase", # In Outlook Ctrl+Shift+A is equivalent to Shift+F3
573+
}
568574

569575

570576
class OutlookWordDocument(WordDocument, BaseOutlookWordDocument):

0 commit comments

Comments
 (0)