Skip to content
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

Replaced messages, items and dialog title relating to comments in excel to refer to notes, plus some userguide work #11311

Merged
merged 15 commits into from Jul 6, 2020
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
176 changes: 104 additions & 72 deletions source/NVDAObjects/window/excel.py
Expand Up @@ -33,6 +33,7 @@
from . import Window
from .. import NVDAObjectTextInfo
import scriptHandler
from scriptHandler import script
import browseMode
import inputCore
import ctypes
Expand Down Expand Up @@ -322,7 +323,8 @@ def __init__( self , nodeType , document , formulaObject , formulaCollection ):

class ExcelQuicknavIterator(object):
"""
Allows iterating over an MS excel collection (e.g. Comments, Formulas or charts) emitting L{QuickNavItem} objects.
Allows iterating over an MS excel collection
(e.g. notes, Formulas or charts) emitting L{QuickNavItem} objects.
"""

def __init__(self, itemType , document , direction , includeCurrent):
Expand All @@ -338,7 +340,8 @@ def __init__(self, itemType , document , direction , includeCurrent):

def collectionFromWorksheet(self,worksheetObject):
"""
Fetches a Microsoft Excel collection object from a Microsoft excel worksheet object. E.g. charts, comments, or formula.
Fetches a Microsoft Excel collection object from a Microsoft excel worksheet object.
E.g. charts, notes, or formula.
@param worksheetObject: a Microsoft excel worksheet object.
@return: a Microsoft excel collection object.
"""
Expand Down Expand Up @@ -505,27 +508,51 @@ def navigationHelper(self,direction):
cellPosition.Activate()
eventHandler.executeEvent('gainFocus',obj)

@script(
gesture="kb:leftArrow"
feerrenrut marked this conversation as resolved.
Show resolved Hide resolved
)
def script_moveLeft(self,gesture):
self.navigationHelper("left")

@script(
gesture="kb:rightArrow"
)
def script_moveRight(self,gesture):
self.navigationHelper("right")

@script(
gesture="kb:upArrow"
)
def script_moveUp(self,gesture):
self.navigationHelper("up")

@script(
gesture="kb:downArrow"
)
def script_moveDown(self,gesture):
self.navigationHelper("down")

@script(
gesture="kb:control+upArrow"
)
def script_startOfColumn(self,gesture):
self.navigationHelper("startcol")

@script(
gesture="kb:control+leftArrow"
)
def script_startOfRow(self,gesture):
self.navigationHelper("startrow")

@script(
gesture="kb:control+rightArrow"
)
def script_endOfRow(self,gesture):
self.navigationHelper("endrow")

@script(
gesture="kb:control+downArrow"
)
def script_endOfColumn(self,gesture):
self.navigationHelper("endcol")

Expand Down Expand Up @@ -563,17 +590,6 @@ def script_elementsList(self,gesture):
script_elementsList.__doc__ = _("Lists various types of elements in this spreadsheet")
script_elementsList.ignoreTreeInterceptorPassThrough=True

__gestures = {
"kb:upArrow": "moveUp",
"kb:downArrow":"moveDown",
"kb:leftArrow":"moveLeft",
"kb:rightArrow":"moveRight",
"kb:control+upArrow":"startOfColumn",
"kb:control+downArrow":"endOfColumn",
"kb:control+leftArrow":"startOfRow",
"kb:control+rightArrow":"endOfRow",
}

class ElementsListDialog(browseMode.ElementsListDialog):

ELEMENT_TYPES=(
Expand All @@ -582,7 +598,7 @@ class ElementsListDialog(browseMode.ElementsListDialog):
("chart", _("&Charts")),
# Translators: The label of a radio button to select the type of element
# in the browse mode Elements List dialog.
("comment", _("C&omments")),
("comment", _("N&otes")),
# Translators: The label of a radio button to select the type of element
# in the browse mode Elements List dialog.
("formula", _("Fo&rmulas")),
Expand Down Expand Up @@ -931,6 +947,7 @@ def _get_states(self):
"kb:control+v",
"kb:shift+f11",
), canPropagate=True)

def script_changeSelection(self,gesture):
oldSelection=api.getFocusObject()
gesture.send()
Expand Down Expand Up @@ -1177,6 +1194,11 @@ def _get_columnHeaderText(self):
def _get_rowHeaderText(self):
return self.parent.fetchAssociatedHeaderCellText(self,columnHeader=False)

@script(
# Translators: the description for a script for Excel
description=_("opens a dropdown item at the current cell"),
gesture="kb:alt+downArrow"
)
def script_openDropdown(self,gesture):
gesture.send()
d=None
Expand All @@ -1199,6 +1221,11 @@ def script_openDropdown(self,gesture):
d.parent=self
eventHandler.queueEvent("gainFocus",d)

@script(
# Translators: the description for a script for Excel
description=_("Sets the current cell as start of column header"),
gesture="kb:NVDA+shift+c"
)
def script_setColumnHeader(self,gesture):
scriptCount=scriptHandler.getLastScriptRepeatCount()
if not config.conf['documentFormatting']['reportTableHeaders']:
Expand All @@ -1221,6 +1248,11 @@ def script_setColumnHeader(self,gesture):
ui.message(_("Cannot find {address} in column headers").format(address=self.cellCoordsText))
script_setColumnHeader.__doc__=_("Pressing once will set this cell as the first column header for any cells lower and to the right of it within this region. Pressing twice will forget the current column header for this cell.")

@script(
# Translators: the description for a script for Excel
description=_("sets the current cell as start of row header"),
gesture="kb:NVDA+shift+r"
)
def script_setRowHeader(self,gesture):
scriptCount=scriptHandler.getLastScriptRepeatCount()
if not config.conf['documentFormatting']['reportTableHeaders']:
Expand Down Expand Up @@ -1400,24 +1432,34 @@ def _get_positionInfo(self):
level=max(self.excelCellInfo.outlineLevel-1,0) or None
return {'level':level}

# In Office 2016, 365 and newer, comments are now called notes.
# Thus, messages dialog title and so on should refer to notes.
@script(
# Translators: the description for a script for Excel
description=_("Reports the note on the current cell"),
gesture="kb:NVDA+alt+c"
)
def script_reportComment(self,gesture):
commentObj=self.excelCellObject.comment
text=commentObj.text() if commentObj else None
if text:
ui.message(text)
else:
# Translators: A message in Excel when there is no comment
ui.message(_("Not on a comment"))
# Translators: the description for a script for Excel
script_reportComment.__doc__=_("Reports the comment on the current cell")
feerrenrut marked this conversation as resolved.
Show resolved Hide resolved
# Translators: A message in Excel when there is no note
ui.message(_("Not on a note"))

@script(
# Translators: the description for a script for Excel
description=_("Opens the note editing dialog"),
gesture="kb:shift+f2"
)
def script_editComment(self,gesture):
commentObj=self.excelCellObject.comment
d = wx.TextEntryDialog(gui.mainFrame,
feerrenrut marked this conversation as resolved.
Show resolved Hide resolved
# Translators: Dialog text for
_("Editing comment for cell {address}").format(address=self.cellCoordsText),
# Translators: Title of a dialog edit an Excel comment
_("Comment"),
# Translators: Dialog text for the note editing dialog
_("Editing note for cell {address}").format(address=self.cellCoordsText),
# Translators: Title for the note editing dialog
_("Note"),
value=commentObj.text() if commentObj else u"",
style=wx.TE_MULTILINE|wx.OK|wx.CANCEL)
def callback(result):
Expand Down Expand Up @@ -1448,14 +1490,6 @@ def reportFocus(self):
speech.speak(sequence)
super(ExcelCell,self).reportFocus()

__gestures = {
"kb:NVDA+shift+c": "setColumnHeader",
"kb:NVDA+shift+r": "setRowHeader",
"kb:shift+f2":"editComment",
"kb:alt+downArrow":"openDropdown",
"kb:NVDA+alt+c":"reportComment",
}

class ExcelSelection(ExcelBase):

role=controlTypes.ROLE_TABLECELL
Expand Down Expand Up @@ -1573,29 +1607,23 @@ def _get_selection(self):
if controlTypes.STATE_SELECTED in child.states:
return child

@script(
gestures=("kb:downArrow", "kb:upArrow", "kb:leftArrow", "kb:rightArrow", "kb:home", "kb:end")
)
def script_selectionChange(self,gesture):
gesture.send()
newFocus=self.selection or self
if eventHandler.lastQueuedFocusObject is newFocus: return
eventHandler.queueEvent("gainFocus",newFocus)
script_selectionChange.canPropagate=True
script_selectionChange.canPropagate = True
feerrenrut marked this conversation as resolved.
Show resolved Hide resolved

@script(
gestures=("kb:escape", "kb:enter", "kb:space")
)
def script_closeDropdown(self,gesture):
gesture.send()
eventHandler.queueEvent("gainFocus",self.parent)
script_closeDropdown.canPropagate=True

__gestures={
"kb:downArrow":"selectionChange",
"kb:upArrow":"selectionChange",
"kb:leftArrow":"selectionChange",
"kb:rightArrow":"selectionChange",
"kb:home":"selectionChange",
"kb:end":"selectionChange",
"kb:escape":"closeDropdown",
"kb:enter":"closeDropdown",
"kb:space":"closeDropdown",
}
script_closeDropdown.canPropagate = True

def event_gainFocus(self):
child=self.selection
Expand Down Expand Up @@ -1724,9 +1752,12 @@ def _getFormControlScreenCoordinates(self):
screenBottomRightY=int(Y + (bottomRightCellHeight/2+ bottomRightAddress.Top) * zoomRatio * py / pointsPerInch)
return (int(0.5*(screenTopLeftX+screenBottomRightX)), int(0.5*(screenTopLeftY+screenBottomRightY)))

@script(
gestures=("kb:enter", "kb:space", "kb(desktop):numpadEnter")
)
def script_doAction(self,gesture):
self.doAction()
script_doAction.canPropagate=True
script_doAction.canPropagate = True

def doAction(self):
(x,y)=self._getFormControlScreenCoordinates()
Expand All @@ -1737,12 +1768,6 @@ def doAction(self):
self.invalidateCache()
wx.CallLater(100,eventHandler.executeEvent,"stateChange",self)

__gestures= {
"kb:enter":"doAction",
"kb:space":"doAction",
"kb(desktop):numpadEnter":"doAction",
}

class ExcelFormControlQuickNavItem(ExcelQuickNavItem):

def __init__( self , nodeType , document , formControlObject , formControlCollection, treeInterceptorObj ):
Expand Down Expand Up @@ -1893,6 +1918,9 @@ def _get_lastChild(self):
if self.listSize>0:
return self.getChildAtIndex(self.listSize-1)

@script(
gesture="kb:upArrow"
)
def script_moveUp(self, gesture):
if self.selectedItemIndex > 1:
self.selectedItemIndex= self.selectedItemIndex - 1
Expand All @@ -1904,8 +1932,11 @@ def script_moveUp(self, gesture):
child=self.getChildAtIndex(self.selectedItemIndex-1)
if child:
eventHandler.queueEvent("gainFocus",child)
script_moveUp.canPropagate=True
script_moveUp.canPropagate = True

@script(
gesture="kb:downArrow"
)
def script_moveDown(self, gesture):
if self.selectedItemIndex < self.listSize:
self.selectedItemIndex= self.selectedItemIndex + 1
Expand All @@ -1917,7 +1948,7 @@ def script_moveDown(self, gesture):
child=self.getChildAtIndex(self.selectedItemIndex-1)
if child:
eventHandler.queueEvent("gainFocus",child)
script_moveDown.canPropagate=True
script_moveDown.canPropagate = True

def doAction(self):
if self.isMultiSelectable:
Expand All @@ -1929,11 +1960,6 @@ def doAction(self):
child=self.getChildAtIndex(self.selectedItemIndex-1)
eventHandler.queueEvent("gainFocus",child)

__gestures= {
"kb:upArrow": "moveUp",
"kb:downArrow":"moveDown",
}

class ExcelFormControlDropDown(ExcelFormControl):

def __init__(self,windowHandle=None,parent=None,excelFormControlObject=None):
Expand All @@ -1947,29 +1973,30 @@ def __init__(self,windowHandle=None,parent=None,excelFormControlObject=None):
except:
self.selectedItemIndex=0

@script(
gesture="kb:upArrow"
)
def script_moveUp(self, gesture):
if self.selectedItemIndex > 1:
self.selectedItemIndex= self.selectedItemIndex - 1
self.excelOLEFormatObject.Selected[self.selectedItemIndex] = True
eventHandler.queueEvent("valueChange",self)
script_moveUp.canPropagate=True
script_moveUp.canPropagate = True

@script(
gesture="kb:downArrow"
)
def script_moveDown(self, gesture):
if self.selectedItemIndex < self.listSize:
self.selectedItemIndex= self.selectedItemIndex + 1
self.excelOLEFormatObject.Selected[self.selectedItemIndex] = True
eventHandler.queueEvent("valueChange",self)
script_moveDown.canPropagate=True
script_moveDown.canPropagate = True

def _get_value(self):
if self.selectedItemIndex < self.listSize:
return str(self.excelOLEFormatObject.List(self.selectedItemIndex))

__gestures= {
"kb:upArrow": "moveUp",
"kb:downArrow":"moveDown",
}

class ExcelFormControlScrollBar(ExcelFormControl):

def __init__(self,windowHandle=None,parent=None,excelFormControlObject=None):
Expand Down Expand Up @@ -2009,21 +2036,26 @@ def moveValue(self,up=False,large=False):
self.excelControlFormatObject.value=newValue
eventHandler.queueEvent("valueChange",self)

@script(
gesture="kb:upArrow"
)
def script_moveUpSmall(self,gesture):
self.moveValue(True,False)

@script(
gesture="kb:downArrow"
)
def script_moveDownSmall(self,gesture):
self.moveValue(False,False)

@script(
gesture="kb:pageUp"
)
def script_moveUpLarge(self,gesture):
self.moveValue(True,True)

@script(
gesture="kb:pageDown"
)
def script_moveDownLarge(self,gesture):
self.moveValue(False,True)

__gestures={
"kb:upArrow":"moveUpSmall",
"kb:downArrow":"moveDownSmall",
"kb:pageUp":"moveUpLarge",
"kb:pageDown":"moveDownLarge",
}
2 changes: 1 addition & 1 deletion source/gui/settingsDialogs.py
Expand Up @@ -2011,7 +2011,7 @@ def makeSettings(self, settingsSizer):

# Translators: This is the label for a checkbox in the
# document formatting settings panel.
commentsText = _("Co&mments")
commentsText = _("No&tes and comments")
self.commentsCheckBox=docInfoGroup.addItem(wx.CheckBox(self,label=commentsText))
self.commentsCheckBox.SetValue(config.conf["documentFormatting"]["reportComments"])

Expand Down