def _getControlFieldForObject(self, obj, ignoreEditableText=True): if ignoreEditableText and self._isObjectEditableText(obj): # This is basically just a text node. return None role = obj.role states = obj.states if role == controlTypes.ROLE_LINK and controlTypes.STATE_LINKED not in states: # Named link destination, not a link that can be activated. return None field = textInfos.ControlField() field["role"] = role # The user doesn't care about certain states, as they are obvious. states.discard(controlTypes.STATE_EDITABLE) states.discard(controlTypes.STATE_MULTILINE) states.discard(controlTypes.STATE_FOCUSED) field["states"] = states field["_childcount"] = obj.childCount field["level"] = obj.positionInfo.get("level") if role == controlTypes.ROLE_TABLE: field["table-id"] = 1 # FIXME field["table-rowcount"] = obj.rowCount field["table-columncount"] = obj.columnCount if role in (controlTypes.ROLE_TABLECELL, controlTypes.ROLE_TABLECOLUMNHEADER, controlTypes.ROLE_TABLEROWHEADER): field["table-id"] = 1 # FIXME field["table-rownumber"] = obj.rowNumber field["table-columnnumber"] = obj.columnNumber return field
def _startElementHandler(self, tagName, attrs): if tagName == 'unich': data = attrs.get('value', None) if data is not None: try: data = chr(int(data)) except ValueError: data = textUtils.REPLACEMENT_CHAR self._CharacterDataHandler( data, processBufferedSurrogates=isLowSurrogate(data)) return elif tagName == 'control': newAttrs = textInfos.ControlField(attrs) self._commandList.append( textInfos.FieldCommand("controlStart", newAttrs)) elif tagName == 'text': newAttrs = textInfos.FormatField(attrs) self._commandList.append( textInfos.FieldCommand("formatChange", newAttrs)) else: raise ValueError("Unknown tag name: %s" % tagName) # Normalise attributes common to both field types. try: newAttrs["_startOfNode"] = newAttrs["_startOfNode"] == "1" except KeyError: pass try: newAttrs["_endOfNode"] = newAttrs["_endOfNode"] == "1" except KeyError: pass
def _getControlFieldForObject(self, obj, ignoreEditableText=True): role = obj.role if ignoreEditableText and role in (controlTypes.ROLE_PARAGRAPH, controlTypes.ROLE_EDITABLETEXT): # This is basically just a text node. return None field = textInfos.ControlField() field["role"] = obj.role states = obj.states # The user doesn't care about certain states, as they are obvious. states.discard(controlTypes.STATE_EDITABLE) states.discard(controlTypes.STATE_MULTILINE) states.discard(controlTypes.STATE_FOCUSED) field["states"] = states field["name"] = obj.name field["_childcount"] = obj.childCount field["level"] = obj.positionInfo.get("level") if role == controlTypes.ROLE_TABLE: field["table-id"] = 1 # FIXME field["table-rowcount"] = obj.rowCount field["table-columncount"] = obj.columnCount if role in (controlTypes.ROLE_TABLECELL, controlTypes.ROLE_TABLECOLUMNHEADER, controlTypes.ROLE_TABLEROWHEADER): field["table-id"] = 1 # FIXME field["table-rownumber"] = obj.rowNumber field["table-columnnumber"] = obj.columnNumber return field
def _getControlFieldForObject(self, obj: NVDAObject): role = obj.role states = obj.states field = textInfos.ControlField() field["role"] = role field['roleText'] = obj.roleText field['description'] = obj.description field['_description-from'] = obj.descriptionFrom # The user doesn't care about certain states, as they are obvious. states.discard(controlTypes.State.EDITABLE) states.discard(controlTypes.State.MULTILINE) states.discard(controlTypes.State.FOCUSED) field["states"] = states field["_childcount"] = obj.childCount field["level"] = obj.positionInfo.get("level") if role == controlTypes.Role.TABLE: field["table-id"] = 1 # FIXME field["table-rowcount"] = obj.rowCount field["table-columncount"] = obj.columnCount if role in (controlTypes.Role.TABLECELL, controlTypes.Role.TABLECOLUMNHEADER, controlTypes.Role.TABLEROWHEADER): field["table-id"] = 1 # FIXME field["table-rownumber"] = obj.rowNumber field["table-columnnumber"] = obj.columnNumber # Row/column span is not supported by all implementations (e.g. LibreOffice) try: field['table-rowsspanned']=obj.rowSpan except NotImplementedError: log.debug("Row span not supported") pass try: field['table-columnsspanned']=obj.columnSpan except NotImplementedError: log.debug("Column span not supported") pass return field
def _getControlFieldForObject(self, obj): role = obj.role field = textInfos.ControlField() field["role"] = obj.role states = obj.states # The user doesn't care about certain states, as they are obvious. states.discard(controlTypes.STATE_EDITABLE) states.discard(controlTypes.STATE_MULTILINE) states.discard(controlTypes.STATE_FOCUSED) field["states"] = states # Only include name if the object's inner text is empty. # could be unperformant. text=self.obj.makeTextInfo(obj).text if not text or text.isspace(): field["name"] = obj.name #field["_childcount"] = obj.childCount field["level"] = obj.positionInfo.get("level") if role == controlTypes.ROLE_TABLE: field["table-id"] = 1 # FIXME try: field["table-rowcount"] = obj.rowCount field["table-columncount"] = obj.columnCount except NotImplementedError: pass if role in (controlTypes.ROLE_TABLECELL, controlTypes.ROLE_DATAITEM,controlTypes.ROLE_TABLECOLUMNHEADER, controlTypes.ROLE_TABLEROWHEADER,controlTypes.ROLE_HEADERITEM): try: field["table-rownumber"] = obj.rowNumber field["table-columnnumber"] = obj.columnNumber field["table-id"] = 1 # FIXME field['role']=controlTypes.ROLE_TABLECELL field['table-columnheadertext']=obj.columnHeaderText field['table-rowheadertext']=obj.rowHeaderText except NotImplementedError: pass return field
def _getControlFieldForObject(self, obj: NVDAObject, ignoreEditableText=True): if ignoreEditableText and self._isObjectEditableText(obj): # This is basically just a text node. return None role = obj.role states = obj.states if role == controlTypes.Role.LINK and controlTypes.State.LINKED not in states: # Named link destination, not a link that can be activated. return None field = textInfos.ControlField() field["role"] = role field['roleText'] = obj.roleText field['description'] = obj.description field['_description-from'] = obj.descriptionFrom field['hasDetails'] = obj.hasDetails field["detailsRole"] = obj.detailsRole # The user doesn't care about certain states, as they are obvious. states.discard(controlTypes.State.EDITABLE) states.discard(controlTypes.State.MULTILINE) states.discard(controlTypes.State.FOCUSED) field["states"] = states field["_childcount"] = obj.childCount field["level"] = obj.positionInfo.get("level") if role == controlTypes.Role.TABLE: field["table-id"] = 1 # FIXME field["table-rowcount"] = obj.rowCount field["table-columncount"] = obj.columnCount if role in (controlTypes.Role.TABLECELL, controlTypes.Role.TABLECOLUMNHEADER, controlTypes.Role.TABLEROWHEADER): field["table-id"] = 1 # FIXME field["table-rownumber"] = obj.rowNumber field["table-columnnumber"] = obj.columnNumber # Row/column span is not supported by all implementations (e.g. LibreOffice) try: field['table-rowsspanned'] = obj.rowSpan except NotImplementedError: log.debug("Row span not supported") pass try: field['table-columnsspanned'] = obj.columnSpan except NotImplementedError: log.debug("Column span not supported") pass return field