Exemple #1
0
	def _normalizeControlField(self,attrs):
		stdName = attrs.get("acrobat::stdname", "")
		try:
			role, level = normalizeStdName(stdName)
		except LookupError:
			role, level = None, None

		if not role:
			accRole=attrs['IAccessible::role']
			if accRole.isdigit():
				accRole=int(accRole)
			else:
				accRole = accRole.lower()
			role=IAccessibleHandler.IAccessibleRolesToNVDARoles.get(accRole,controlTypes.ROLE_UNKNOWN)

		states=set(IAccessibleHandler.IAccessibleStatesToNVDAStates[x] for x in [1<<y for y in xrange(32)] if int(attrs.get('IAccessible::state_%s'%x,0)) and x in IAccessibleHandler.IAccessibleStatesToNVDAStates)

		if role == controlTypes.ROLE_EDITABLETEXT and {controlTypes.STATE_READONLY, controlTypes.STATE_FOCUSABLE, controlTypes.STATE_LINKED} <= states:
			# HACK: Acrobat sets focus states on text nodes beneath links,
			# making them appear as read only editable text fields.
			states.difference_update({controlTypes.STATE_FOCUSABLE, controlTypes.STATE_FOCUSED})

		attrs['role']=role
		attrs['states']=states
		if level:
			attrs["level"] = level
		return super(AdobeAcrobat_TextInfo, self)._normalizeControlField(attrs)
    def _normalizeControlField(self, attrs):
        stdName = attrs.get("acrobat::stdname", "")
        try:
            role, level = normalizeStdName(stdName)
        except LookupError:
            role, level = None, None

        if not role:
            accRole = attrs['IAccessible::role']
            if accRole.isdigit():
                accRole = int(accRole)
            else:
                accRole = accRole.lower()
            role = IAccessibleHandler.IAccessibleRolesToNVDARoles.get(
                accRole, controlTypes.ROLE_UNKNOWN)

        states = set(IAccessibleHandler.IAccessibleStatesToNVDAStates[x]
                     for x in [1 << y for y in range(32)]
                     if int(attrs.get('IAccessible::state_%s' % x, 0))
                     and x in IAccessibleHandler.IAccessibleStatesToNVDAStates)

        if role == controlTypes.ROLE_EDITABLETEXT and {
                controlTypes.STATE_READONLY, controlTypes.STATE_FOCUSABLE,
                controlTypes.STATE_LINKED
        } <= states:
            # HACK: Acrobat sets focus states on text nodes beneath links,
            # making them appear as read only editable text fields.
            states.difference_update(
                {controlTypes.STATE_FOCUSABLE, controlTypes.STATE_FOCUSED})

        attrs['role'] = role
        attrs['states'] = states
        if level:
            attrs["level"] = level
        return super(AdobeAcrobat_TextInfo, self)._normalizeControlField(attrs)
Exemple #3
0
    def _normalizeControlField(self, attrs):
        stdName = attrs.get("acrobat::stdname", "")
        try:
            role, level = normalizeStdName(stdName)
        except LookupError:
            role, level = None, None

        if not role:
            role = IAccessibleHandler.NVDARoleFromAttr(
                attrs['IAccessible::role'])
        states = IAccessibleHandler.getStatesSetFromIAccessibleAttrs(attrs)
        role, states = controlTypes.transformRoleStates(role, states)

        if (role == controlTypes.Role.EDITABLETEXT and states.issuperset({
                controlTypes.State.READONLY, controlTypes.State.FOCUSABLE,
                controlTypes.State.LINKED
        })):
            # HACK: Acrobat sets focus states on text nodes beneath links,
            # making them appear as read only editable text fields.
            states.difference_update(
                {controlTypes.State.FOCUSABLE, controlTypes.State.FOCUSED})

        attrs['role'] = role
        attrs['states'] = states
        if level:
            attrs["level"] = level
        return super(AdobeAcrobat_TextInfo, self)._normalizeControlField(attrs)