Mini Shell

Direktori : /usr/lib/python3.6/site-packages/orca/__pycache__/
Upload File :
Current File : //usr/lib/python3.6/site-packages/orca/__pycache__/structural_navigation.cpython-36.pyc

3

�p5[���@s�dZdZdZdZdZdZddlZdd	lmZdd
lm	Z	ddlm
Z
ddlmZdd
lmZddlm
Z
ddlmZddlmZddlmZddlmZddlmZddlmZddlmZej�ZGdd�d�ZGdd�d�ZGdd�d�ZdS)z!Implements structural navigation.z$Id$z
$Revision$z$Date$zRCopyright (c) 2005-2009 Sun Microsystems Inc.Copyright (c) 2010-2013 The Orca TeamZLGPL�N�)�cmdnames)�debug)�	guilabels)�input_event)�keybindings)�messages)�object_properties)�orca)�orca_gui_navlist)�
orca_state)�settings)�settings_manager)�speechc
@s.eZdZdZgdgdgdddddf
dd�ZdS)�
MatchCriteriaa�Contains the criteria which will be used to generate a collection
    matchRule.  We don't want to create the rule until we need it and
    are ready to use it. In addition, the creation of an AT-SPI match
    rule requires you specify quite a few things (see the __init__),
    most of which are irrelevant to the search at hand.  This class
    makes it possible for the StructuralNavigationObject creator to just
    specify the few criteria that actually matter.
    N�Fc
Cs|||_|p|j|_||_|p |j|_||_|p2|j|_||_|	pD|j|_	|
|_
||_tj
�|_x|D]}|jj|�qdWdS)a�Creates a new match criteria object.

        Arguments:
        - collection: the collection interface for the document in
          which the accessible objects can be found.
        - states: a list of pyatspi states of interest
        - matchStates: whether an object must have all of the states
          in the states list, any of the states in the list, or none
          of the states in the list.  Must be one of the collection
          interface MatchTypes if provided.
        - objAttrs: a list of object attributes (not text attributes)
        - matchObjAttrs: whether an object must have all of the
          attributes in the objAttrs list, any of the attributes in
          the list, or none of the attributes in the list.  Must be
          one of the collection interface MatchTypes if provided.
        - interfaces: (We aren't using this.  According to the at-spi
          idl, it is a string.)
        - matchInterfaces: The collection MatchType for matching by
          interface.
        - invert: If true the match rule will find objects that don't
          match. We always use False.
        - applyPredicate: whether or not a predicate should be applied
          as an additional check to see if an item is indeed a match.
          This is necessary, for instance, when one of the things we
          care about is a text attribute, something the collection
          interface doesn't include in its criteria.
        N)�
collection�	MATCH_ANY�matchStates�objAttrs�
matchObjAttrs�roles�
matchRoles�
interfaces�	MATCH_ALL�matchInterfaces�invert�applyPredicate�pyatspiZStateSet�states�add)
�selfrrrrrrrrrrr�state�r#�+/usr/lib/python3.6/structural_navigation.py�__init__?s)

zMatchCriteria.__init__)�__name__�
__module__�__qualname__�__doc__r%r#r#r#r$r5src@s`eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dS)�StructuralNavigationObjectatRepresents a document object which has identifiable characteristics
    which can be used for the purpose of navigation to and among instances
    of that object. These characteristics may be something as simple as a
    role and/or a state of interest. Or they may be something more complex
    such as character counts, text attributes, and other object attributes.
    cCsL||_||_||_||_||_||_||_i|_tj	�|_
g|_|j�dS)a	Creates a new structural navigation object.

        Arguments:
        - structuralNavigation: the StructuralNavigation class associated
          with this object.
        - objType: the type (e.g. BLOCKQUOTE) associated with this object.
        - bindings: a dictionary of all of the possible bindings for this
          object.  In the case of all but the "atLevel" bindings, each
          binding takes the form of [keysymstring, modifiers, description].
          The goPreviousAtLevel and goNextAtLevel bindings are each a list
          of bindings in that form.
        - predicate: the predicate to use to determine if a given accessible
          matches this structural navigation object. Used when a search via
          collection is not possible or practical.
        - criteria: a method which returns a MatchCriteria object which
          can in turn be used to locate the next/previous matching accessible
          via collection.
        - presentation: the method which should be called after performing
          the search for the structural navigation object.
        - dialogData: the method which returns the title, column headers,
          and row data which should be included in the "list of" dialog for
          the structural navigation object.
        N)
�structuralNavigation�objType�bindings�	predicate�criteria�present�_dialogData�inputEventHandlersr�KeyBindings�keyBindings�	functions�_setUpHandlersAndBindings)r!r+r,r-r.r/�presentation�
dialogDatar#r#r$r%�s
z#StructuralNavigationObject.__init__cCs�|jjd�}|rf|\}}}d|j}tj|j|�|j|<|jjt	j
|t	j||j|��|jj
|j�|jjd�}|r�|\}}}d|j}tj|j|�|j|<|jjt	j
|t	j||j|��|jj
|j�|jjd�}|�r4|\}}}d|j}tj|j|�|j|<|jjt	j
|t	j||j|��|jj
|j�|jjd��pDg}x~t|�D]r\}	}
|	d}|j|�}d	|j|f}|
\}}}tj||�|j|<|jjt	j
|t	j||j|��|jj
|��qPW|jjd
��p�g}
x~t|
�D]r\}	}
|	d}|j|�}d|j|f}|
\}}}tj||�|j|<|jjt	j
|t	j||j|��|jj
|��q�W|jjd��phg}x~t|�D]r\}	}
|	d}|j|�}d
|j|f}|
\}}}tj||�|j|<|jjt	j
|t	j||j|��|jj
|��qtWi}|jjd�|d<|jjd�|d<|jjd�|d<|jjd�|d<|jjd�|d<|jjd�|d<|jjd�|d<|jjd�|d<x�|D]z}|j|�}
|
�s��qt|j|�}d|j|f}|
\}}}tj||�|j|<|jjt	j
|t	j||j|��|jj
|��qtWdS) z<Adds the inputEventHandlers and keyBindings for this object.�previousz%sGoPrevious�nextz%sGoNext�listz
%sShowList�previousAtLevelrz%sGoPreviousLevel%dHandler�nextAtLevelz%sGoNextLevel%dHandler�listAtLevelz%sShowListAtLevel%dHandler�left�Left�right�Right�up�Up�down�Down�first�First�last�Last�start�Start�end�Endz%sGo%sN)r-�getr,r�InputEventHandler�
goPreviousr2r4r r�
KeyBinding�defaultModifierMaskr5�append�goNext�showList�	enumerate�goPreviousAtLevelFactory�goNextAtLevelFactory�showListAtLevelFactory�goDirectionFactory)r!ZpreviousBinding�keysymstring�	modifiers�description�handlerNameZnextBindingZlistBindingr<�i�binding�level�handlerr=r>Z
directions�	directionr#r#r$r6�s�















z4StructuralNavigationObject._setUpHandlersAndBindingsc	Csv|\}}}tj||�}tj|tj||�}||j|<||jj|<|jj|�|jjj|�|j	j
|�|jj	j
|�dS)a�Adds a custom inputEventHandler and keybinding to the object's
        handlers and bindings.  Right now this is unused, but here in
        case a creator of a StructuralNavigationObject had some other
        desired functionality in mind.

        Arguments:
        - binding: [keysymstring, modifiers, description]
        - handlerName: a string uniquely identifying the handler
        - function: the function associated with the binding
        N)rrPrrRrSr2r+r5rTr4r )	r!rar_Zfunctionr\r]r^rcZ
keyBindingr#r#r$�addHandlerAndBindingBs

z/StructuralNavigationObject.addHandlerAndBindingcCs|jj|d�dS)zGo to the previous object.FN)r+�goObject)r!�script�
inputEventr#r#r$rQ_sz%StructuralNavigationObject.goPreviouscCs|jj|d�dS)zGo to the next object.TN)r+rf)r!rgrhr#r#r$rUcsz!StructuralNavigationObject.goNextc
s�y|jj|�\}}Wn�jtj�dS�fdd�}tt||��}|jr\tt|j|��}|j	�\}}�t
|�}d|tj|�f}|s��j|�dS�jj
�\}	}
y|j|	�}Wnd}YnX�fdd�|D�}tj||||�dS)z3Show a list of all the items with this object type.Ncs*�jj|�rdS�jj|�p&�jj|�S)NF)�	utilities�isDead�isHidden�isEmpty)�x)rgr#r$�
_isValidMatchpsz:StructuralNavigationObject.showList.<locals>._isValidMatchz%s: %srcsg|]}|dg�|��qS)r���r#)�.0�obj)�rowDatar#r$�
<listcomp>�sz7StructuralNavigationObject.showList.<locals>.<listcomp>)r+�_getAll�presentMessager�NAVIGATION_DIALOG_ERRORr;�filterrr.r1�len�
itemsFoundri�getCaretContext�indexr�showUI)
r!rgrh�objectsr/rn�title�
columnHeaders�count�
currentObject�offsetr{�rowsr#)rrrgr$rVgs,

z#StructuralNavigationObject.showListcs��fdd�}|S)a[Generates a goPrevious method for the specified level. Right
        now, this is just for headings, but it may have applicability
        for other objects such as list items (i.e. for level-based
        navigation in an outline or other multi-tiered list.

        Arguments:
        - level: the desired level of the object as an int.
        cs�jj�d�d�dS)NF)�arg)r+rf)rgrh)rbr!r#r$�goPreviousAtLevel�szNStructuralNavigationObject.goPreviousAtLevelFactory.<locals>.goPreviousAtLevelr#)r!rbr�r#)rbr!r$rX�s
z3StructuralNavigationObject.goPreviousAtLevelFactorycs��fdd�}|S)aXGenerates a goNext method for the specified level. Right
        now, this is just for headings, but it may have applicability
        for other objects such as list items (i.e. for level-based
        navigation in an outline or other multi-tiered list.

        Arguments:
        - level: the desired level of the object as an int.

        cs�jj�d�d�dS)NT)r�)r+rf)rgrh)rbr!r#r$�
goNextAtLevel�szFStructuralNavigationObject.goNextAtLevelFactory.<locals>.goNextAtLevelr#)r!rbr�r#)rbr!r$rY�sz/StructuralNavigationObject.goNextAtLevelFactorycs��fdd�}|S)aYGenerates a showList method for the specified level. Right
        now, this is just for headings, but it may have applicability
        for other objects such as list items (i.e. for level-based
        navigation in an outline or other multi-tiered list.

        Arguments:
        - level: the desired level of the object as an int.
        cs�y�jj��d�\}}Wn�jtj�dS�fdd�}tt||��}|jr`tt�j|��}�j	�d�\}}�t
|�}d|tj|�f}|s��j|�dS�jj
�\}}	y|j|�}
Wnd}
YnX�fdd�|D�}tj||||
�dS)N)r�cs�jj|�p�jj|�S)N)rirkrl)rm)rgr#r$rn�szaStructuralNavigationObject.showListAtLevelFactory.<locals>.showListAtLevel.<locals>._isValidMatchz%s: %srcsg|]}|dg�|��qS)rror#)rprq)rrr#r$rs�sz^StructuralNavigationObject.showListAtLevelFactory.<locals>.showListAtLevel.<locals>.<listcomp>)r+rtrurrvr;rwrr.r1rxryrirzr{rr|)rgrhr}r/rnr~rr�r�r�r{r�)rbr!)rrrgr$�showListAtLevel�s,

zJStructuralNavigationObject.showListAtLevelFactory.<locals>.showListAtLevelr#)r!rbr�r#)rbr!r$rZ�s
z1StructuralNavigationObject.showListAtLevelFactorycs`��fdd�}dd�}��fdd�}�jtjkr4|S�jtjkrD|S�jtjkr\�dkr\|SdS)	a�Generates the methods for navigation in a particular direction
        (i.e. left, right, up, down, first, last).  Right now, this is
        primarily for table cells, but it may have applicability for other
        objects.  For example, when navigating in an outline, one might
        want the ability to navigate to the next item at a given level,
        but then work his/her way up/down in the hierarchy.

        Arguments:
        - direction: the direction in which to navigate as a string.
        cs|jj�\}}�jj|�}�jj|�}�dkrD|d|ddg}n��dkrb|d|ddg}n��dkr�|dd|dg}nl�dkr�|dd|dg}nN�dkr�ddg}n<dd	g}�jj|�}|r�|j�}|jd}	|jd}
|	|
g}�jj	�|||�dS)
Nr@rrrBrDrFrHroro)
rirzr+�
getCellForObj�getCellCoordinates�getTableForCell�
queryTable�nRows�nColumns�goCell)rgrhrqr��thisCell�currentCoordinates�desiredCoordinates�table�iTable�lastRow�lastCol)rdr!r#r$r��s8




z=StructuralNavigationObject.goDirectionFactory.<locals>.goCellcSs"tjr|jj�n|jtj�dS)zGo to the last liveRegion.N)r
ZinferLiveRegions�liveRegionManager�goLastLiveRegionrurZLIVE_REGIONS_OFF)rgrhr#r#r$r��szGStructuralNavigationObject.goDirectionFactory.<locals>.goLastLiveRegioncs�dk}�jj�|�dS)NrL)r+�goEdge)rgrh�isStart)rdr!r#r$�goContainerEdgeszFStructuralNavigationObject.goDirectionFactory.<locals>.goContainerEdgerJN)r,�StructuralNavigation�	CONTAINER�
TABLE_CELL�LIVE_REGION)r!rdr�r�r�r#)rdr!r$r[�s z-StructuralNavigationObject.goDirectionFactoryN)r&r'r(r)r%r6rerQrUrVrXrYrZr[r#r#r#r$r*}s("*r*c@sdeZdZdZdZdZdZdZdZdZ	dZ
d	Zd
ZdZ
dZd
ZdZdZdZdZdZdZdZdZdZdZdZejejejejej ej!ej"ej#ej$ej%ej&gZ'ej(ej)ej*ej+ej,ej-ej.ej/ej0ej&ej1ej2ej3ej4ej5ejej6ej7ej8ej9gZ:ej;ej<ej=ej>ej?ej@ejAej ejBejCej1ejDgZEejFejGgZH�d>dd�ZI�d?dd�ZJdd �ZKd!d"�ZLd#d$�ZMd%d&�ZN�d@d(d)�ZOd*d+�ZP�dAd,d-�ZQ�dBd.d/�ZR�dCd0d1�ZSd2d3�ZTd4d5�ZUd6d7�ZVd8d9�ZWd:d;�ZXd<d=�ZYd>d?�ZZd@dA�Z[dBdC�Z\dDdE�Z]dFdG�Z^dHdI�Z_dJdK�Z`dLdM�Za�dDdNdO�ZbdPdQ�ZcdRdS�ZddTdU�ZedVdW�ZfdXdY�ZgdZd[�Zhd\d]�Zid^d_�Zj�dEd`da�Zk�dFdbdc�Zl�dGddde�Zmdfdg�Zndhdi�Zo�dHdjdk�Zp�dIdldm�Zq�dJdndo�Zrdpdq�Zsdrds�Zt�dKdtdu�Zu�dLdvdw�Zv�dMdxdy�Zwdzd{�Zxd|d}�Zy�dNd~d�Zz�dOd�d��Z{�dPd�d��Z|d�d��Z}d�d��Z~�dQd�d��Z�dRd�d��Z��dSd�d��Z�d�d��Z�d�d��Z��dTd�d��Z��dUd�d��Z��dVd�d��Z�d�d��Z�d�d��Z��dWd�d��Z��dXd�d��Z��dYd�d��Z�d�d��Z�d�d��Z�d�d��Z��dZd�d��Z��d[d�d��Z��d\d�d��Z��d]d�d��Z�d�d��Z��d^d�d��Z��d_d�d��Z��d`d�d��Z�d�d��Z�d�d��Z��dad�d��Z��dbd�d��Z��dcd�d��Z�d�dÄZ�d�dńZ��ddd�dDŽZ��ded�dɄZ��dfd�d˄Z�d�d̈́Z�d�dτZ��dgd�dфZ��dhd�dӄZ��did�dՄZ�d�dׄZ�d�dلZ��djd�dۄZ��dkd�d݄Z��dld�d߄Z�d�d�Z��dmd�d�Z��dnd�d�Z��dod�d�Z�d�d�Z�d�d�Z��dpd�d�Z��dqd�d�Z��drd�d�Z�d�d�Z�d�d��Z��dsd�d��Z��dtd�d��Z��dud�d��Z�d�d��Z��dvd�d��Z��dw�d�d�Z��dx�d�d�Z��d�d�Z��d�d�Z��dy�d�d	�Z��dz�d
�d�Z��d�d
�Z��d�d�Zd{�d�d�ZÐd|�d�d�ZĐd}�d�d�ZŐd�d�ZƐd�d�Zǐd~�d�d�ZȐd�d�d�Zɐd��d�d�Zʐd �d!�Zːd"�d#�Z̐d��d$�d%�Z͐d��d&�d'�Zΐd��d(�d)�Zϐd*�d+�ZАd,�d-�Zѐd��d.�d/�ZҐd��d0�d1�ZӐd��d2�d3�ZԐd4�d5�ZՐd6�d7�Z֐d��d8�d9�Zאd��d:�d;�Zؐd��d<�d=�Z�dS(�r�a1This class implements the structural navigation functionality which
    is available to scripts. Scripts interested in implementing structural
    navigation need to override getEnabledStructuralNavigationTypes() and
    return a list of StructuralNavigation object types which should be
    enabled.
    Z
blockquoteZbuttonZcheckBox�chunkZ	clickableZcomboBox�	container�entryZ	formFieldZheading�image�landmark�linkr;ZlistItemZ
liveRegionZ	paragraphZradioButtonZ	separatorr�Z	tableCellZ
unvisitedLinkZvisitedLinkFcCsb||_||_i|_x|D]}|j|�|j|<qWg|_i|_|j�|j�|_ddg|_	i|_
dS)a4Creates an instance of the StructuralNavigation class.

        Arguments:
        - script: the script which which this instance is associated.
        - enabledTypes: a list of StructuralNavigation object types
          which the script is interested in supporting.
        - enabled: Whether structural navigation should start out
          enabled.  For instance, in Gecko by default we do what it
          enabled; in soffice, we would want to start out with it
          disabled and have the user enable it via a keystroke when
          desired.
        rNroro)�_script�enabled�enabledObjects�!structuralNavigationObjectCreatorr5r2�setupInputEventHandlers�getKeyBindingsr4�
lastTableCell�_objectCache)r!rgZenabledTypesr�r,r#r#r$r%|s


zStructuralNavigation.__init__NcCs|ri|jt|�<ni|_dS)N)r��hash)r!�documentr#r#r$�
clearCache�szStructuralNavigation.clearCachecCsftd|�}td|�}td|�}td|�}ytd|�}Wnd}YnXt|||||||�S)a�This convenience method creates a StructuralNavigationObject
        with the specified name and associated characteristics. (See the
        "Objects" section of code near the end of this class. Creators
        of StructuralNavigationObject's can still do things the old
        fashioned way should they so choose, by creating the instance
        and then adding it via addObject().

        Arguments:
        - name: the name/objType associated with this object.
        zself._%sBindings()zself._%sCriteriazself._%sPredicatezself._%sPresentationzself._%sDialogDataN)�evalr*)r!�namer-r/r.r7r8r#r#r$r��s

z6StructuralNavigation.structuralNavigationObjectCreatorcCs||j|<dS)aAdds structuralNavigationObject to the dictionary of enabled
        objects.

        Arguments:
        - objType: the name/object type of the StructuralNavigationObject.
        - structuralNavigationObject: the StructuralNavigationObject to
          add.
        N)r�)r!r,�structuralNavigationObjectr#r#r$�	addObject�s
zStructuralNavigation.addObjectcCsXt|j�sdStj|jtj�|jd<x.|jj�D] }|jj	|j�|j
j|j
�q0WdS)z.Defines InputEventHandler fields for a script.N�!toggleStructuralNavigationHandler)rxr�rrP�toggleStructuralNavigationrZSTRUCTURAL_NAVIGATION_TOGGLEr2�values�updater5�extend)r!r�r#r#r$r��s
z,StructuralNavigation.setupInputEventHandlerscCsntj�}t|j�s|S|jtjdtjtj|jd��x2|jj	�D]$}|j
j
}x|D]}|j|�qTWqBW|S)zDefines the structural navigation key bindings for a script.

        Returns: an instance of keybindings.KeyBindings.
        �zr�)rr3rxr�r rRrS�ORCA_MODIFIER_MASKr2r�r4)r!r4r�r-Z
keybindingr#r#r$r��s

z#StructuralNavigation.getKeyBindingsTcCs@|j|_|jrtj}ntj}tjtj|�|r<|jj|�dS)z#Toggles structural navigation keys.N)	r�rZSTRUCTURAL_NAVIGATION_KEYS_ONZSTRUCTURAL_NAVIGATION_KEYS_OFFr�printlnZLEVEL_CONFIGURATIONr�ru)r!rgrhru�stringr#r#r$r�s
z/StructuralNavigation.toggleStructuralNavigationcCs|j|�}y|j�}WnRtk
rDd|}tjtj|�d}Yn&d|}tjtj|�d}YnX|s�|jjtj	�dS|\}}	|\}
}|
|}||	}
|jj
j|�}|jj
j|�}|}�x|�r�|j
|
|�}|�sh|dkr�|jjtj�d}n(||jdk�r |jjtj�|jd}|
dk�r>|jjtj�d}
n(|
|jdk�r�|jjtj�|jd}
q�||k�s�tj�r�|j|��r�|
dk�r�|d8}n|
dk�r�|d7}|dk�r�|
d8}
n|dk�r�|
d7}
q�Pq�W|
|g|_|�r||
||g}|j||�dS)a_The method used for navigation among cells in a table.

        Arguments:
        - structuralNavigationObject: the StructuralNavigationObject which
          represents the table cell.
        - thisCell: the pyatspi accessible TABLE_CELL we're currently in
        - currentCoordinates: the [row, column] of thisCell.  Note, we
          cannot just get the coordinates because in table cells which
          span multiple rows and/or columns, the value returned by 
          table.getRowAtIndex() is the first row the cell spans. Likewise,
          the value returned by table.getColumnAtIndex() is the left-most
          column.  Therefore, we keep track of the row and column from
          our perspective to ensure we stay in the correct row and column.
        - desiredCoordinates: the [row, column] where we think we'd like to
          be.
        z2ERROR: Table %s does not implement table interfaceNz/ERROR: Exception querying table interface of %srr)r�r��NotImplementedErrorrr��
LEVEL_INFOr�rurZTABLE_NOT_IN_Ari�rowHeadersForCell�columnHeadersForCell�getAccessibleAtZTABLE_ROW_BEGINNINGr�Z
TABLE_ROW_ENDZTABLE_COLUMN_TOPr�ZTABLE_COLUMN_BOTTOMr
ZskipBlankCells�_isBlankCellr�r0)r!r�r�r�r�r�r��msgZ
currentRowZ
currentColZ
desiredRowZ
desiredCol�rowDiff�colDiff�
oldRowHeaders�
oldColHeaders�cellr�r#r#r$r�sd












zStructuralNavigation.goCellc
Cs�|jsgdfS|jjj�}|jjt|�i�}d|j|f}|j|gdf�\}}|r^|j�|fS|j	�}|j||�}|j
|jj�|j
|j|j|j|j|j|j|j�	}	|j|	|jdd�}|j|	�|j�|f}
||f||<||jt|�<|
S)z8Returns all the instances of structuralNavigationObject.Nz%s:%srT)r/r�riZ
documentFramer�rOr�r,�copyZqueryCollectionZcreateMatchRuler�rawrrrrrrrrZ
getMatchesZSORT_ORDER_CANONICALZ
freeMatchRule)r!r�r�r��cache�key�matchesr/�colZrule�rvr#r#r$rtbs2
zStructuralNavigation._getAllc
s,|dkr"|jjj�\}}|j|�}|dks8|jjj|�rH|jd|�dS|rp|jjj|d�\}}|j||�dS|jjj|�\}}|jjj||�\�}�s�|jjj|�}|jjj	||��n(t
j|�fdd��r�|jjj�|�\�}|j��}	�o�|	|k�r|j��dS||k�r|d}|j|dd�dS)Nrcs|�kS)Nr#)rm)�newObjr#r$�<lambda>�sz-StructuralNavigation.goEdge.<locals>.<lambda>T)�
sameContainerroro)r�rirz�getContainerForObjectrjr0ZnextContextZlastContextZgetDocumentForObjectZgetNextObjectInDocumentr�findAncestor)
r!r�r�r�r�rqr�Z	newOffsetr�ZnewContainerr#)r�r$r��s0



zStructuralNavigation.goEdgecs�t�j�|��\���s(�jd|�dS|s4�j����fdd�}�fdd�}|sd�jjj�\}}||�\}}	|r��|	d��|}tjj	|�}
x�t
��D]x\}}||�s�q�|j|krʈjjj|�|}
ntjj	|�}�jjj
||
�}
|
dkr�|�s|
dkr�|r��j||�dSq�Wtj�s.�jd|�dS|�sD�jjtj�n�jjtj�t�j�|��\��|�st�j�x(�D] }||��rz�j||�dS�qzW�jd|�dS)aThe method used for navigation among StructuralNavigationObjects
        which are not table cells.

        Arguments:
        - structuralNavigationObject: the StructuralNavigationObject which
          represents the object of interest.
        - isNext: If True, we're interested in the next accessible object
          which matches structuralNavigationObject.  If False, we're 
          interested in the previous accessible object which matches.
        - obj: the current object (typically the locusOfFocus).
        - arg: optional arguments which may need to be passed along to
          the predicate, presentation method, etc. For instance, in the
          case of navigating amongst headings at a given level, the level
          is needed and passed in as arg.
        Ncs4�jjj|�s�jjj|�r dS�js*dS�j|�S)NFT)r�rirkrlrr.)rq)r/r!r�r#r$rn�s
z4StructuralNavigation.goObject.<locals>._isValidMatchcs*x$|r$|�kr|�j|�fS|j}qWdS)Nrro)Nro)r{�parent)rq)r�r#r$�_getMatchingObjAndIndex�s

z>StructuralNavigation.goObject.<locals>._getMatchingObjAndIndexr)r;rtr0�reverser�rirzr�utilsZgetPathrWr�ZcharacterOffsetInParentZpathComparisonr
ZwrappedStructuralNavigationrurZWRAPPING_TO_BOTTOMZWRAPPING_TO_TOP)r!r�ZisNextrqr�rnr�r�ZthisObjr{ZcurrentPathr`�matchZ
comparison�pathr#)r/r�r!r�r$rf�sN



zStructuralNavigation.goObjectcCs$dd�|D�}|sdStjt|��S)NcSsg|]}|j�tjkr|�qSr#)�getRoler�ROLE_LIST_ITEM)rprmr#r#r$rs�sz<StructuralNavigation._getListDescription.<locals>.<listcomp>r)rZ
listItemCountrx)r!rq�childrenr#r#r$�_getListDescription�sz(StructuralNavigation._getListDescriptionc	Cs4|j�j}y|j�Wn
dS|jjj|�SdS)z�Returns a string which contains the table caption, or
        None if a caption could not be found.

        Arguments:
        - obj: the accessible table whose caption we want.
        N)r��caption�	queryTextr�ri�
displayedText)r!rqr�r#r#r$�_getTableCaption�s
z%StructuralNavigation._getTableCaptioncCs@d}|jjj|�}|r tjd}|j�}tj|j|j�}||S)z+Returns a string which describes the table.r� )	r�riZisNonUniformTablerZTABLE_NON_UNIFORMr�Z	tableSizer�r�)r!rqZnonUniformStringZ
nonUniformr�Z
sizeStringr#r#r$�_getTableDescriptions
z)StructuralNavigation._getTableDescriptioncs<tjtjtjg��fdd�}|r8||�r8tjj||�}|S)z�Looks for a table cell in the ancestry of obj, if obj is not a
        table cell.

        Arguments:
        - obj: the accessible object of interest.
        cs|o|j��kS)N)r�)rm)�	cellRolesr#r$r�&sz4StructuralNavigation.getCellForObj.<locals>.<lambda>)r�ROLE_TABLE_CELL�ROLE_COLUMN_HEADER�ROLE_ROW_HEADERr�r�)r!rqZisCellr#)r�r$r�sz"StructuralNavigation.getCellForObjc	Csby|j�}Wn
dS||jkr&dS|tjkrT|jjj|�rT|jjj|�rTdS|jjj|�S)NF)	r��CONTAINER_ROLESr�ROLE_SECTIONr�ri�
isLandmark�isBlockquoteZinDocumentContent)r!rq�roler#r#r$�_isContainer,s

z!StructuralNavigation._isContainercCs&|sdS|j|�r|Stjj||j�S)N)r�rr�r�)r!rqr#r#r$r�<s

z*StructuralNavigation.getContainerForObjectcCs(dd�}|r$||�r$tjj||�}|S)z�Looks for a table in the ancestry of obj, if obj is not a table.

        Arguments:
        - obj: the accessible object of interest.
        cSs|o|j�tjkS)N)r�r�
ROLE_TABLE)rmr#r#r$r�Lsz6StructuralNavigation.getTableForCell.<locals>.<lambda>)rr�r�)r!rqZisTabler#r#r$r�Esz$StructuralNavigation.getTableForCellc	CsF|r|js|jrdSy|j�}WnYnX|jdd�j�rBdSdS)z�Returns True if the table cell is empty or consists of whitespace.

        Arguments:
        - obj: the accessible table cell to examime
        FrrTro)r��
childCountr��getText�strip)r!rq�textr#r#r$r�Rsz!StructuralNavigation._isBlankCellcCsPd}|r |jr |jjj|�}n,x*|D]"}|jjj|�}|jjj||�}q&W|S)z�Looks at the table cell and tries to get its text.

        Arguments:
        - obj: the accessible table cell to examime
        r)r�r�rir�ZappendString)r!rqr�ZchildZ	childTextr#r#r$�_getCellTextfs
z!StructuralNavigation._getCellTextcCs�|s|rdS|\}}}}|p"|s(dS|rd|jjj|�}x(|D] }||kr@|j|�}	tj|	�q@W|r�|jjj|�}
x(|
D] }||kr||j|�}	tj|	�q|WdS)z�Speaks the headers of the accessible table cell, cell.

        Arguments:
        - cell: the accessible table cell whose headers we wish to
          present.
        - oldCellInfo: [rowDiff, colDiff, oldRowHeaders, oldColHeaders]
        N)r�rir�r�r�speakr�)r!r�ZoldCellInfor�r�r�r�Z
rowHeaders�headerr�Z
colHeadersr#r#r$�_presentCellHeadersws"	



z(StructuralNavigation._presentCellHeadersc	CsZ|j|�}|j|�}|jjj|�\}}|j\}}|jjj|||�}||krR||fS||fS)z�Returns the [row, col] of a ROLE_TABLE_CELL or [-1, -1]
        if the coordinates cannot be found.

        Arguments:
        - obj: the accessible table cell whose coordinates we want.
        )r�r�r�riZcoordinatesForCellr�ZcellForCoordinates)	r!rqr�r�ZthisRowZthisColr�r�ZlastCellr#r#r$r��s


z'StructuralNavigation.getCellCoordinatescCs|jjj|�S)a@Returns the [obj, characterOffset] where the caret should be
        positioned. For most scripts, the object should not change and
        the offset should be 0.  That's not always the case with Gecko.

        Arguments:
        - obj: the accessible object in which the caret should be
          positioned.
        )r�riZgetFirstCaretPosition)r!rqr#r#r$�_getCaretPosition�s
z&StructuralNavigation._getCaretPositioncCs|jjj||�dS)z2Sets the caret at the specified offset within obj.N)r�riZsetCaretPosition)r!rq�characterOffsetr#r#r$�_setCaretPosition�sz&StructuralNavigation._setCaretPositioncCs4|sdS|j||�rdS|jj|�|jj|�dS)z�Presents the first line of the object to the user.

        Arguments:
        - obj: the accessible object to be presented.
        - offset: the character offset within obj.
        N)�_presentWithSayAllr��
updateBrailleZsayLine)r!rqr�r#r#r$�_presentLine�sz!StructuralNavigation._presentLinecCs.|sdS|j||�rdS|jj|||d�dS)z�Presents the entire object to the user.

        Arguments:
        - obj: the accessible object to be presented.
        - offset: the character offset within obj.
        N)r��includeContext)r�r�Z
presentObject)r!rqr�r�r#r#r$�_presentObject�s
z#StructuralNavigation._presentObjectcCs*|jj�r&tjd�r&|jj||�dSdS)NZstructNavInSayAllTF)r�ZinSayAll�_settingsManagerZ
getSettingZsayAll)r!rqr�r#r#r$r��s


z'StructuralNavigation._presentWithSayAllcCs|jjj|�S)N)r�ZspeechGeneratorZgetLocalizedRoleName)r!rqr#r#r$�_getRoleName�sz!StructuralNavigation._getRoleNamecCsB|j�tjkr|d}y|j�}Wntk
r6dSX|jd�S)Nr)r�r�ROLE_COMBO_BOXZquerySelectionr�ZgetSelectedChild)r!rqZ	selectionr#r#r$�_getSelectedItem�sz%StructuralNavigation._getSelectedItemcCs�|jjj|�}|s |jjj|�}|s8|j|�}|r8|j}|r�|j�tjkr�y|j	�}Wn|j
}YnX|jpv|j
}|r�|jj�tj
kr�|jjj|j�}|r�|j�tjkr�dd�|D�}djtt|j|���}|S)NcSsg|]}|j�tjkr|�qSr#)r�rr�)rprmr#r#r$rs
sz1StructuralNavigation._getText.<locals>.<listcomp>r�)r�rir�Z
expandEOCsrr�r�r�
ROLE_IMAGEZ
queryImager^ZimageDescriptionr��	ROLE_LINKZlinkBasename�	ROLE_LIST�joinr;�map�_getText)r!rqr��itemr�r�r#r#r$r	�s&
zStructuralNavigation._getTextcCs,|jjj|�}|s(|jjj|dd�\}}|S)NF)ZfocusedOnly)r�riZdisplayedLabelZlabelInferenceZinfer)r!rqZlabelr}r#r#r$�	_getLabels
zStructuralNavigation._getLabelc	Cs�y|j�}|j�}Wntk
r(dSX|tjkrdtj\}}}|jtj�rP|S|jtj	�r`|S|S|tj
kr�tj\}}|jtj	�r�|S|S|tjkr�|jtj
�r�tj
StjSdS)Nr)�getStater��RuntimeErrorr�ROLE_CHECK_BOXr	ZCHECK_BOX_INDICATORS_SPEECH�containsZSTATE_INDETERMINATEZ
STATE_CHECKED�ROLE_RADIO_BUTTONZRADIO_BUTTON_INDICATORS_SPEECHr�
STATE_VISITEDZSTATE_UNVISITED)	r!rqr"r�Z	uncheckedZcheckedZ	partiallyZ
unselectedZselectedr#r#r$�	_getStates,



zStructuralNavigation._getStatecCs|j|�p|j|�S)N)rr	)r!rqr#r#r$�	_getValue=szStructuralNavigation._getValuecCsJi}tj}dtj|g|d<tj}dtj|g|d<tj}dtj|g|d<|S)zwReturns a dictionary of [keysymstring, modifiers, description]
        lists for navigating among blockquotes.
        �qr9r:r;)rZBLOCKQUOTE_PREVr�SHIFT_MODIFIER_MASKZBLOCKQUOTE_NEXT�NO_MODIFIER_MASKZBLOCKQUOTE_LIST�SHIFT_ALT_MODIFIER_MASK)r!r-�prevDesc�nextDesc�listDescr#r#r$�_blockquoteBindingsfsz(StructuralNavigation._blockquoteBindingscCsdg}t||d�S)a,Returns the MatchCriteria to be used for locating blockquotes
        by collection.

        Arguments:
        - collection: the collection interface for the document
        - arg: an optional argument which may need to be included in
          the criteria (e.g. the level of a heading).
        ztag:BLOCKQUOTE)r)r)r!rr��attrsr#r#r$�_blockquoteCriteriavs
z(StructuralNavigation._blockquoteCriteriacCs|jjj|�S)a%The predicate to be used for verifying that the object
        obj is a blockquote.

        Arguments:
        - obj: the accessible object under consideration.
        - arg: an optional argument which may need to be included in
          the criteria (e.g. the level of a heading).
        )r�rir�)r!rqr�r#r#r$�_blockquotePredicate�s
z)StructuralNavigation._blockquotePredicatecCsJ|r,|j|�\}}|j||�|j||�ntj}tj}|jj||�dS)aPresents the blockquote or indicates that one was not found.

        Arguments:
        - obj: the accessible object under consideration.
        - arg: an optional argument which may need to be included in
          the criteria (e.g. the level of a heading).
        N)r�r�r�rZNO_MORE_BLOCKQUOTES�STRUCTURAL_NAVIGATION_NOT_FOUNDr�ru)r!rqr�r��full�briefr#r#r$�_blockquotePresentation�s	z,StructuralNavigation._blockquotePresentationcs tjg}�fdd�}tj||fS)Ncs�j|�gS)N)r	)rq)r!r#r$rr�sz;StructuralNavigation._blockquoteDialogData.<locals>.rowData)rZSN_HEADER_BLOCKQUOTEZSN_TITLE_BLOCKQUOTE)r!rrrr#)r!r$�_blockquoteDialogData�sz*StructuralNavigation._blockquoteDialogDatacCsJi}tj}dtj|g|d<tj}dtj|g|d<tj}dtj|g|d<|S)zuReturns a dictionary of [keysymstring, modifiers, description]
        lists for navigating amongst buttons.
        �br9r:r;)rZBUTTON_PREVrrZBUTTON_NEXTrZBUTTON_LISTr)r!r-rrrr#r#r$�_buttonBindings�sz$StructuralNavigation._buttonBindingscCs*tjg}tjtjg}|j}t||||d�S)a(Returns the MatchCriteria to be used for locating buttons
        by collection.

        Arguments:
        - collection: the collection interface for the document
        - arg: an optional argument which may need to be included in
          the criteria (e.g. the level of a heading).
        )rrr)r�ROLE_PUSH_BUTTON�STATE_FOCUSABLE�STATE_SENSITIVErr)r!rr�r�r"�
stateMatchr#r#r$�_buttonCriteria�s
z$StructuralNavigation._buttonCriteriacCs:d}|r6|j�tjkr6|j�}|jtj�o4|jtj�}|S)a!The predicate to be used for verifying that the object
        obj is a button.

        Arguments:
        - obj: the accessible object under consideration.
        - arg: an optional argument which may need to be included in
          the criteria (e.g. the level of a heading).
        F)r�rr&rrr'r()r!rqr��isMatchr"r#r#r$�_buttonPredicate�s
z%StructuralNavigation._buttonPredicatecCsJ|r,|j|�\}}|j||�|j||�ntj}tj}|jj||�dS)a
Presents the button or indicates that one was not found.

        Arguments:
        - obj: the accessible object under consideration.
        - arg: an optional argument which may need to be included in
          the criteria (e.g. the level of a heading).
        N)r�r�r�rZNO_MORE_BUTTONSrr�ru)r!rqr�r�r r!r#r#r$�_buttonPresentation�s	z(StructuralNavigation._buttonPresentationcs tjg}�fdd�}tj||fS)Ncs�j|�gS)N)r	)rq)r!r#r$rr�sz7StructuralNavigation._buttonDialogData.<locals>.rowData)rZSN_HEADER_BUTTONZSN_TITLE_BUTTON)r!rrrr#)r!r$�_buttonDialogData�sz&StructuralNavigation._buttonDialogDatacCsJi}tj}dtj|g|d<tj}dtj|g|d<tj}dtj|g|d<|S)zyReturns a dictionary of [keysymstring, modifiers, description]
        lists for navigating amongst check boxes.
        rmr9r:r;)rZCHECK_BOX_PREVrrZCHECK_BOX_NEXTrZCHECK_BOX_LISTr)r!r-rrrr#r#r$�_checkBoxBindingssz&StructuralNavigation._checkBoxBindingscCs*tjg}tjtjg}|j}t||||d�S)a,Returns the MatchCriteria to be used for locating check boxes
        by collection.

        Arguments:
        - collection: the collection interface for the document
        - arg: an optional argument which may need to be included in
          the criteria (e.g. the level of a heading).
        )rrr)rrr'r(rr)r!rr�r�r"r)r#r#r$�_checkBoxCriterias
z&StructuralNavigation._checkBoxCriteriacCs:d}|r6|j�tjkr6|j�}|jtj�o4|jtj�}|S)a$The predicate to be used for verifying that the object
        obj is a check box.

        Arguments:
        - obj: the accessible object under consideration.
        - arg: an optional argument which may need to be included in
          the criteria (e.g. the level of a heading).
        F)r�rrrrr'r()r!rqr�r+r"r#r#r$�_checkBoxPredicate%s
z'StructuralNavigation._checkBoxPredicatecCsJ|r,|j|�\}}|j||�|j||�ntj}tj}|jj||�dS)a
Presents the check box or indicates that one was not found.

        Arguments:
        - obj: the accessible object under consideration.
        - arg: an optional argument which may need to be included in
          the criteria (e.g. the level of a heading).
        N)r�r�r�rZNO_MORE_CHECK_BOXESrr�ru)r!rqr�r�r r!r#r#r$�_checkBoxPresentation7s	z*StructuralNavigation._checkBoxPresentationcs,tjg}|jtj��fdd�}tj||fS)Ncs�j|��j|�gS)N)rr)rq)r!r#r$rrMsz9StructuralNavigation._checkBoxDialogData.<locals>.rowData)rZSN_HEADER_CHECK_BOXrT�SN_HEADER_STATEZSN_TITLE_CHECK_BOX)r!rrrr#)r!r$�_checkBoxDialogDataIsz(StructuralNavigation._checkBoxDialogDatacCsJi}tj}dtj|g|d<tj}dtj|g|d<tj}dtj|g|d<|S)z�Returns a dictionary of [keysymstring, modifiers, description]
        lists for navigating amongst chunks/large objects.
        �or9r:r;)rZLARGE_OBJECT_PREVrrZLARGE_OBJECT_NEXTrZLARGE_OBJECT_LISTr)r!r-rrrr#r#r$�_chunkBindingsXsz#StructuralNavigation._chunkBindingscCs"|j|j}|j}t|||dd�S)a6Returns the MatchCriteria to be used for locating chunks/
        large objects by collection.

        Arguments:
        - collection: the collection interface for the document
        - arg: an optional argument which may need to be included in
          the criteria (e.g. the level of a heading).
        T)rrr)�OBJECT_ROLESr�rr)r!rr�r��	roleMatchr#r#r$�_chunkCriteriahs
z#StructuralNavigation._chunkCriteriacCs~|sdS|j�}||jkrdS|tjkr,dS|jjj|�}|oH|jtj	ksNdS|j
dd�}|j|jj�}||jdkrzdSdS)a The predicate to be used for verifying that the object
        obj is a chunk.

        Arguments:
        - obj: the accessible object under consideration.
        - arg: an optional argument which may need to be included in
          the criteria (e.g. the level of a heading).
        FTrrg�������?ro)
r�r7r�ROLE_ARTICLEr�riZqueryNonEmptyText�characterCountr
ZlargeObjectTextLengthr�r�ZEMBEDDED_OBJECT_CHARACTER)r!rqr�r�r�r�Zeocsr#r#r$�_chunkPredicateys


z$StructuralNavigation._chunkPredicatecCsJ|r,|j|�\}}|j||�|j|d�ntj}tj}|jj||�dS)a	Presents the chunk or indicates that one was not found.

        Arguments:
        - obj: the accessible object under consideration.
        - arg: an optional argument which may need to be included in
          the criteria (e.g. the level of a heading).
        rN)r�r�r�rZNO_MORE_CHUNKSrr�ru)r!rqr�r�r�r r!r#r#r$�_chunkPresentation�s	z'StructuralNavigation._chunkPresentationcs,tjg}|jtj��fdd�}tj||fS)Ncs�j|��j|�gS)N)r	r)rq)r!r#r$rr�sz6StructuralNavigation._chunkDialogData.<locals>.rowData)rZSN_HEADER_OBJECTrT�SN_HEADER_ROLEZSN_TITLE_LARGE_OBJECT)r!rrrr#)r!r$�_chunkDialogData�sz%StructuralNavigation._chunkDialogDatacCsJi}tj}dtj|g|d<tj}dtj|g|d<tj}dtj|g|d<|S)zyReturns a dictionary of [keysymstring, modifiers, description]
        lists for navigating amongst combo boxes.
        �cr9r:r;)rZCOMBO_BOX_PREVrrZCOMBO_BOX_NEXTrZCOMBO_BOX_LISTr)r!r-rrrr#r#r$�_comboBoxBindings�sz&StructuralNavigation._comboBoxBindingscCs*tjg}tjtjg}|j}t||||d�S)a,Returns the MatchCriteria to be used for locating combo boxes
        by collection.

        Arguments:
        - collection: the collection interface for the document
        - arg: an optional argument which may need to be included in
          the criteria (e.g. the level of a heading).
        )rrr)rrr'r(rr)r!rr�r�r"r)r#r#r$�_comboBoxCriteria�s
z&StructuralNavigation._comboBoxCriteriacCs:d}|r6|j�tjkr6|j�}|jtj�o4|jtj�}|S)a$The predicate to be used for verifying that the object
        obj is a combo box.

        Arguments:
        - obj: the accessible object under consideration.
        - arg: an optional argument which may need to be included in
          the criteria (e.g. the level of a heading).
        F)r�rrrrr'r()r!rqr�r+r"r#r#r$�_comboBoxPredicate�s
z'StructuralNavigation._comboBoxPredicatecCsJ|r,|j|�\}}|j||�|j||�ntj}tj}|jj||�dS)a
Presents the combo box or indicates that one was not found.

        Arguments:
        - obj: the accessible object under consideration.
        - arg: an optional argument which may need to be included in
          the criteria (e.g. the level of a heading).
        N)r�r�r�rZNO_MORE_COMBO_BOXESrr�ru)r!rqr�r�r r!r#r#r$�_comboBoxPresentation�s	z*StructuralNavigation._comboBoxPresentationcs,tjg}|jtj��fdd�}tj||fS)Ncs�j|��j|�gS)N)rr	)rq)r!r#r$rrsz9StructuralNavigation._comboBoxDialogData.<locals>.rowData)rZSN_HEADER_COMBO_BOXrTZSN_HEADER_SELECTED_ITEMZSN_TITLE_COMBO_BOX)r!rrrr#)r!r$�_comboBoxDialogData�sz(StructuralNavigation._comboBoxDialogDatacCsJi}tj}dtj|g|d<tj}dtj|g|d<tj}dtj|g|d<|S)zuReturns a dictionary of [keysymstring, modifiers, description]
        lists for navigating amongst entries.
        �er9r:r;)rZ
ENTRY_PREVrrZ
ENTRY_NEXTrZ
ENTRY_LISTr)r!r-rrrr#r#r$�_entryBindingssz#StructuralNavigation._entryBindingscCs&tjtjtjg}|j}t|||dd�S)a(Returns the MatchCriteria to be used for locating entries
        by collection.

        Arguments:
        - collection: the collection interface for the document
        - arg: an optional argument which may need to be included in
          the criteria (e.g. the level of a heading).
        T)rrr)rr'r(�STATE_EDITABLErr)r!rr�r"r)r#r#r$�_entryCriterias
z#StructuralNavigation._entryCriteriacCs$|r|jrdS|jj�jtj�S)a!The predicate to be used for verifying that the object
        obj is an entry.

        Arguments:
        - obj: the accessible object under consideration.
        - arg: an optional argument which may need to be included in
          the criteria (e.g. the level of a heading).
        F)r�rrrrH)r!rqr�r#r#r$�_entryPredicate1s
z$StructuralNavigation._entryPredicatecCsJ|r,|j|�\}}|j||�|j||�ntj}tj}|jj||�dS)a	Presents the entry or indicates that one was not found.

        Arguments:
        - obj: the accessible object under consideration.
        - arg: an optional argument which may need to be included in
          the criteria (e.g. the level of a heading).
        N)r�r�r�rZNO_MORE_ENTRIESrr�ru)r!rqr�r�r r!r#r#r$�_entryPresentation@s	z'StructuralNavigation._entryPresentationcs,tjg}|jtj��fdd�}tj||fS)Ncs�j|��j|�gS)N)rr	)rq)r!r#r$rrVsz6StructuralNavigation._entryDialogData.<locals>.rowData)r�SN_HEADER_LABELrTZSN_HEADER_TEXTZSN_TITLE_ENTRY)r!rrrr#)r!r$�_entryDialogDataRsz%StructuralNavigation._entryDialogDatacCsJi}tj}dtj|g|d<tj}dtj|g|d<tj}dtj|g|d<|S)zyReturns a dictionary of [keysymstring, modifiers, description]
        lists for navigating amongst form fields.
        ZTabr9r:�fr;)rZFORM_FIELD_PREVrZORCA_SHIFT_MODIFIER_MASKZFORM_FIELD_NEXTr�ZFORM_FIELD_LISTr)r!r-rrrr#r#r$�_formFieldBindingsas
z'StructuralNavigation._formFieldBindingscCs2|j}|j}tjtjg}|j}t|||||dd�S)a,Returns the MatchCriteria to be used for locating form fields
        by collection.

        Arguments:
        - collection: the collection interface for the document
        - arg: an optional argument which may need to be included in
          the criteria (e.g. the level of a heading).
        T)rrrrr)�
FORM_ROLESrrr'r(rr)r!rr�r�r8r"r)r#r#r$�_formFieldCriteriass
z'StructuralNavigation._formFieldCriteriacCs\|sdS|j�}||jkrdS|j�}|jtj�o<|jtj�}|tjkrX|oV|jtj�}|S)a%The predicate to be used for verifying that the object
        obj is a form field.

        Arguments:
        - obj: the accessible object under consideration.
        - arg: an optional argument which may need to be included in
          the criteria (e.g. the level of a heading).
        F)	r�rPrrrr'r(�ROLE_DOCUMENT_FRAMErH)r!rqr�r�r"r+r#r#r$�_formFieldPredicate�s


z(StructuralNavigation._formFieldPredicatecCsf|rH|j�tjkr |jr |d}|j|�\}}|j||�|j||�ntj}tj	}|j
j||�dS)aPresents the form field or indicates that one was not found.

        Arguments:
        - obj: the accessible object under consideration.
        - arg: an optional argument which may need to be included in
          the criteria (e.g. the level of a heading).
        rN)r�r�	ROLE_TEXTr�r�r�r�rZNO_MORE_FORM_FIELDSrr�ru)r!rqr�r�r r!r#r#r$�_formFieldPresentation�s	z+StructuralNavigation._formFieldPresentationcs8tjg}|jtj�|jtj��fdd�}tj||fS)Ncs�j|��j|��j|�gS)N)rrr)rq)r!r#r$rr�sz:StructuralNavigation._formFieldDialogData.<locals>.rowData)rrLrTr>ZSN_HEADER_VALUEZSN_TITLE_FORM_FIELD)r!rrrr#)r!r$�_formFieldDialogData�s
z)StructuralNavigation._formFieldDialogDatacCs�i}tj}dtj|g|d<tj}dtj|g|d<tj}dtj|g|d<g}g}g}|j�\}}	xvt	||	d�D]d}
tj
|
}|jt|
�tj|g�tj
|
}|jt|
�tj|g�tj|
}|jt|
�tj|g�qnW||d<||d<||d<|S)	zvReturns a dictionary of [keysymstring, modifiers, description]
        lists for navigating amongst headings.
        �hr9r:r;rr<r=r>)rZHEADING_PREVrrZHEADING_NEXTrZHEADING_LISTr�_headingLevels�rangeZHEADING_AT_LEVEL_PREVrT�strZHEADING_AT_LEVEL_NEXTZHEADING_AT_LEVEL_LIST)r!r-rrrZprevAtLevelBindingsZnextAtLevelBindingsZlistAtLevelBindingsZminLevelZmaxLevelr`r#r#r$�_headingBindings�s8





z%StructuralNavigation._headingBindingscCsddgS)z�Returns the [minimum heading level, maximum heading level]
        which should be navigable via structural navigation.
        r�r#)r!r#r#r$rX�sz#StructuralNavigation._headingLevelscCs,tjg}g}|r|jd|�t|||d�S)a)Returns the MatchCriteria to be used for locating headings
        by collection.

        Arguments:
        - collection: the collection interface for the document
        - arg: an optional argument which may need to be included in
          the criteria (e.g. the level of a heading).
        zlevel:%d)rr)r�ROLE_HEADINGrTr)r!rr�r�rr#r#r$�_headingCriteria�s
z%StructuralNavigation._headingCriteriacCs6d}|r2|j�tjkr2|r.||jjj|�k}nd}|S)a"The predicate to be used for verifying that the object
        obj is a heading.

        Arguments:
        - obj: the accessible object under consideration.
        - arg: an optional argument which may need to be included in
          the criteria (e.g. the level of a heading).
        FT)r�rr]r�ri�headingLevel)r!rqr�r+r#r#r$�_headingPredicates
z&StructuralNavigation._headingPredicatecCsn|r,|j|�\}}|j||�|j||�n>|sLtj}tj}|jj||�ntj|}tj}|jj||�dS)aPresents the heading or indicates that one was not found.

        Arguments:
        - obj: the accessible object under consideration.
        - arg: an optional argument which may need to be included in
          the criteria (e.g. the level of a heading).
        N)	r�r�r�rZNO_MORE_HEADINGSrr�ruZNO_MORE_HEADINGS_AT_LEVEL)r!rqr�r�r r!r#r#r$�_headingPresentations	
z)StructuralNavigation._headingPresentationcsLtjg}|s,tj}|jtj��fdd�}ntj|}�fdd�}|||fS)Ncs�j|�t�jjj|��gS)N)r	rZr�rir_)rq)r!r#r$rr;sz8StructuralNavigation._headingDialogData.<locals>.rowDatacs�j|�gS)N)r	)rq)r!r#r$rrBs)rZSN_HEADER_HEADINGZSN_TITLE_HEADINGrTZSN_HEADER_LEVELZSN_TITLE_HEADING_AT_LEVEL)r!r�rr~rrr#)r!r$�_headingDialogData4s
z'StructuralNavigation._headingDialogDatacCsJi}tj}dtj|g|d<tj}dtj|g|d<tj}dtj|g|d<|S)zkReturns a dictionary of [keysymstring, modifiers, description]
        lists for navigating amongst images.�gr9r:r;)rZ
IMAGE_PREVrrZ
IMAGE_NEXTrZ
IMAGE_LISTr)r!r-rrrr#r#r$�_imageBindingsMsz#StructuralNavigation._imageBindingscCst||jd�S)a'Returns the MatchCriteria to be used for locating images
        by collection.

        Arguments:
        - collection: the collection interface for the document
        - arg: an optional argument which may need to be included in
          the criteria (e.g. the level of a heading).
        )r)r�IMAGE_ROLES)r!rr�r#r#r$�_imageCriteria\s
z#StructuralNavigation._imageCriteriacCs|o|j�|jkS)a!The predicate to be used for verifying that the object
        obj is an image.

        Arguments:
        - obj: the accessible object under consideration.
        - arg: an optional argument which may need to be included in
          the criteria (e.g. the level of a heading).
        )r�re)r!rqr�r#r#r$�_imagePredicatehs
z$StructuralNavigation._imagePredicatecCsJ|r,|j|�\}}|j||�|j|d�ntj}tj}|jj||�dS)aPresents the image/graphic or indicates that one was not found.

        Arguments:
        - obj: the accessible object under consideration.
        - arg: an optional argument which may need to be included in
          the criteria (e.g. the level of a heading).
        rN)r�r�r�rZNO_MORE_IMAGESrr�ru)r!rqr�r�r�r r!r#r#r$�_imagePresentationts	z'StructuralNavigation._imagePresentationcs tjg}�fdd�}tj||fS)Ncs�j|�p�j|�gS)N)r	r)rq)r!r#r$rr�sz6StructuralNavigation._imageDialogData.<locals>.rowData)rZSN_HEADER_IMAGEZSN_TITLE_IMAGE)r!rrrr#)r!r$�_imageDialogData�sz%StructuralNavigation._imageDialogDatacCsJi}tj}dtj|g|d<tj}dtj|g|d<tj}dtj|g|d<|S)zwReturns a dictionary of [keysymstring, modifiers, description]
        lists for navigating amongst landmarks.
        �mr9r:r;)rZ
LANDMARK_PREVrrZ
LANDMARK_NEXTrZ
LANDMARK_LISTr)r!r-rrrr#r#r$�_landmarkBindings�sz&StructuralNavigation._landmarkBindingscCs8g}|jjj�}x|D]}|jd|�qWt||d�S)a*Returns the MatchCriteria to be used for locating landmarks
        by collection.

        Arguments:
        - collection: the collection interface for the document
        - arg: an optional argument which may need to be included in
          the criteria (e.g. the level of a heading).
        z
xml-roles:)r)r�riZgetLandmarkTypesrTr)r!rr�rZ
landmarkTypesr�r#r#r$�_landmarkCriteria�s

z&StructuralNavigation._landmarkCriteriacCs|jjj|�S)a#The predicate to be used for verifying that the object
        obj is a landmark.

        Arguments:
        - obj: the accessible object under consideration.
        - arg: an optional argument which may need to be included in
          the criteria (e.g. the level of a heading).
        )r�rir�)r!rqr�r#r#r$�_landmarkPredicate�s
z'StructuralNavigation._landmarkPredicatecCs`|rB|jj|j|��|}|j|�\}}|j||�|j||�ntj}tj}|jj	||�dS)aPresents the landmark or indicates that one was not found.

        Arguments:
        - obj: the accessible object under consideration.
        - arg: an optional argument which may need to be included in
          the criteria (e.g. the level of a heading).
        N)
r��speakMessagerr�r�r�rZNO_LANDMARK_FOUNDrru)r!rqr�r�r�r r!r#r#r$�_landmarkPresentation�s	z*StructuralNavigation._landmarkPresentationcs,tjg}|jtj��fdd�}tj||fS)Ncs|j�j|�gS)N)r�r)rq)r!r#r$rr�sz9StructuralNavigation._landmarkDialogData.<locals>.rowData)rZSN_HEADER_LANDMARKrTr>ZSN_TITLE_LANDMARK)r!rrrr#)r!r$�_landmarkDialogData�sz(StructuralNavigation._landmarkDialogDatacCsJi}tj}dtj|g|d<tj}dtj|g|d<tj}dtj|g|d<|S)zReturns a dictionary of [keysymstring, modifiers, description]
        lists for navigating amongst (un)ordered lists.
        �lr9r:r;)rZ	LIST_PREVrrZ	LIST_NEXTrZ	LIST_LISTr)r!r-rrrr#r#r$�
_listBindings�sz"StructuralNavigation._listBindingscCs&tjg}tjg}|j}t||||d�S)a2Returns the MatchCriteria to be used for locating (un)ordered
        lists by collection.

        Arguments:
        - collection: the collection interface for the document
        - arg: an optional argument which may need to be included in
          the criteria (e.g. the level of a heading).
        )rrr)rrr'�
MATCH_NONEr)r!rr�r�r"r)r#r#r$�
_listCriteria�s
z"StructuralNavigation._listCriteriacCs,d}|r(|j�tjkr(|j�jtj�}|S)a,The predicate to be used for verifying that the object
        obj is an (un)ordered list.

        Arguments:
        - obj: the accessible object under consideration.
        - arg: an optional argument which may need to be included in
          the criteria (e.g. the level of a heading).
        F)r�rrrrr')r!rqr�r+r#r#r$�_listPredicate	s
z#StructuralNavigation._listPredicatecCs\|r>|jj|j|��|j|�\}}|j||�|j||�ntj}tj}|jj	||�dS)aPresents the (un)ordered list or indicates that one was not
        found.

        Arguments:
        - obj: the accessible object under consideration.
        - arg: an optional argument which may need to be included in
          the criteria (e.g. the level of a heading).
        N)
r�rnr�r�r�r�rZ
NO_MORE_LISTSrru)r!rqr�r�r r!r#r#r$�_listPresentation!	s
z&StructuralNavigation._listPresentationcs tjg}�fdd�}tj||fS)Ncs�j|�gS)N)r	)rq)r!r#r$rr8	sz5StructuralNavigation._listDialogData.<locals>.rowData)rZSN_HEADER_LISTZ
SN_TITLE_LIST)r!rrrr#)r!r$�_listDialogData5	sz$StructuralNavigation._listDialogDatacCsJi}tj}dtj|g|d<tj}dtj|g|d<tj}dtj|g|d<|S)z�Returns a dictionary of [keysymstring, modifiers, description]
        lists for navigating amongst items in an (un)ordered list.
        r`r9r:r;)rZLIST_ITEM_PREVrrZLIST_ITEM_NEXTrZLIST_ITEM_LISTr)r!r-rrrr#r#r$�_listItemBindingsC	sz&StructuralNavigation._listItemBindingscCs&tjg}tjg}|j}t||||d�S)a=Returns the MatchCriteria to be used for locating items in an
        (un)ordered list by collection.

        Arguments:
        - collection: the collection interface for the document
        - arg: an optional argument which may need to be included in
          the criteria (e.g. the level of a heading).
        )rrr)rr�r'rsr)r!rr�r�r"r)r#r#r$�_listItemCriteriaS	s
z&StructuralNavigation._listItemCriteriacCs,d}|r(|j�tjkr(|j�jtj�}|S)a7The predicate to be used for verifying that the object
        obj is an item in an (un)ordered list.

        Arguments:
        - obj: the accessible object under consideration.
        - arg: an optional argument which may need to be included in
          the criteria (e.g. the level of a heading).
        F)r�rr�rrr')r!rqr�r+r#r#r$�_listItemPredicatee	s
z'StructuralNavigation._listItemPredicatecCsJ|r,|j|�\}}|j||�|j||�ntj}tj}|jj||�dS)a!Presents the (un)ordered list item or indicates that one was not
        found.

        Arguments:
        - obj: the accessible object under consideration.
        - arg: an optional argument which may need to be included in
          the criteria (e.g. the level of a heading).
        N)r�r�r�rZNO_MORE_LIST_ITEMSrr�ru)r!rqr�r�r r!r#r#r$�_listItemPresentationv	s
z*StructuralNavigation._listItemPresentationcs tjg}�fdd�}tj||fS)Ncs�j|�gS)N)r	)rq)r!r#r$rr�	sz9StructuralNavigation._listItemDialogData.<locals>.rowData)rZSN_HEADER_LIST_ITEMZSN_TITLE_LIST_ITEM)r!rrrr#)r!r$�_listItemDialogData�	sz(StructuralNavigation._listItemDialogDatacCsJi}tj}dtj|g|d<tj}dtj|g|d<tj}dtj|g|d<|S)zzReturns a dictionary of [keysymstring, modifiers, description]
        lists for navigating amongst live regions.
        �dr9r:�yrI)rZLIVE_REGION_PREVrrZLIVE_REGION_NEXTrZLIVE_REGION_LAST)r!r-rr�descr#r#r$�_liveRegionBindings�	sz(StructuralNavigation._liveRegionBindingscCst|dd�S)a-Returns the MatchCriteria to be used for locating live regions
        by collection.

        Arguments:
        - collection: the collection interface for the document
        - arg: an optional argument which may need to be included in
          the criteria (e.g. the level of a heading).
        T)r)r)r!rr�r#r#r$�_liveRegionCriteria�	sz(StructuralNavigation._liveRegionCriteriacCs.d}|jjj�}|jjj|�s&||kr*d}|S)a&The predicate to be used for verifying that the object
        obj is a live region.

        Arguments:
        - obj: the accessible object under consideration.
        - arg: an optional argument which may need to be included in
          the criteria (e.g. the level of a heading).
        FT)r�r�ZgetLiveNoneObjectsZmatchLiveRegion)r!rqr�r+Zregobjsr#r#r$�_liveRegionPredicate�	s

z)StructuralNavigation._liveRegionPredicatecCsJ|r,|j|�\}}|j||�|j||�ntj}tj}|jj||�dS)aPresents the live region or indicates that one was not found.

        Arguments:
        - obj: the accessible object under consideration.
        - arg: an optional argument which may need to be included in
          the criteria (e.g. the level of a heading).
        N)r�r�r�rZNO_MORE_LIVE_REGIONSrr�ru)r!rqr�r�r r!r#r#r$�_liveRegionPresentation�	s	z,StructuralNavigation._liveRegionPresentationcCsJi}tj}dtj|g|d<tj}dtj|g|d<tj}dtj|g|d<|S)zxReturns a dictionary of [keysymstring, modifiers, description]
        lists for navigating amongst paragraphs.
        �pr9r:r;)rZPARAGRAPH_PREVrrZPARAGRAPH_NEXTrZPARAGRAPH_LISTr)r!r-rrrr#r#r$�_paragraphBindings�	sz'StructuralNavigation._paragraphBindingscCstjg}t||dd�S)a+Returns the MatchCriteria to be used for locating paragraphs
        by collection.

        Arguments:
        - collection: the collection interface for the document
        - arg: an optional argument which may need to be included in
          the criteria (e.g. the level of a heading).
        T)rr)r�ROLE_PARAGRAPHr)r!rr�r�r#r#r$�_paragraphCriteria�	s
z'StructuralNavigation._paragraphCriteriac	Cs>d}|r:|j�tjkr:y|j�}|jdk}WnYnX|S)a$The predicate to be used for verifying that the object
        obj is a paragraph.

        Arguments:
        - obj: the accessible object under consideration.
        - arg: an optional argument which may need to be included in
          the criteria (e.g. the level of a heading).
        F�)r�rr�r�r;)r!rqr�r+r�r#r#r$�_paragraphPredicate�	s
z(StructuralNavigation._paragraphPredicatecCsJ|r,|j|�\}}|j||�|j|d�ntj}tj}|jj||�dS)a
Presents the paragraph or indicates that one was not found.

        Arguments:
        - obj: the accessible object under consideration.
        - arg: an optional argument which may need to be included in
          the criteria (e.g. the level of a heading).
        rN)r�r�r�rZNO_MORE_PARAGRAPHSrr�ru)r!rqr�r�r�r r!r#r#r$�_paragraphPresentation
s	z+StructuralNavigation._paragraphPresentationcs tjg}�fdd�}tj||fS)Ncs�j|�gS)N)r	)rq)r!r#r$rr,
sz:StructuralNavigation._paragraphDialogData.<locals>.rowData)rZSN_HEADER_PARAGRAPHZSN_TITLE_PARAGRAPH)r!rrrr#)r!r$�_paragraphDialogData)
sz)StructuralNavigation._paragraphDialogDatacCsJi}tj}dtj|g|d<tj}dtj|g|d<tj}dtj|g|d<|S)z{Returns a dictionary of [keysymstring, modifiers, description]
        lists for navigating amongst radio buttons.
        �rr9r:r;)rZRADIO_BUTTON_PREVrrZRADIO_BUTTON_NEXTrZRADIO_BUTTON_LISTr)r!r-rrrr#r#r$�_radioButtonBindings7
sz)StructuralNavigation._radioButtonBindingscCs*tjg}tjtjg}|j}t||||d�S)a.Returns the MatchCriteria to be used for locating radio buttons
        by collection.

        Arguments:
        - collection: the collection interface for the document
        - arg: an optional argument which may need to be included in
          the criteria (e.g. the level of a heading).
        )rrr)rrr'r(rr)r!rr�r�r"r)r#r#r$�_radioButtonCriteriaG
s
z)StructuralNavigation._radioButtonCriteriacCs:d}|r6|j�tjkr6|j�}|jtj�o4|jtj�}|S)a'The predicate to be used for verifying that the object
        obj is a radio button.

        Arguments:
        - obj: the accessible object under consideration.
        - arg: an optional argument which may need to be included in
          the criteria (e.g. the level of a heading).
        F)r�rrrrr'r()r!rqr�r+r"r#r#r$�_radioButtonPredicateY
s
z*StructuralNavigation._radioButtonPredicatecCsJ|r,|j|�\}}|j||�|j||�ntj}tj}|jj||�dS)aPresents the radio button or indicates that one was not found.

        Arguments:
        - obj: the accessible object under consideration.
        - arg: an optional argument which may need to be included in
          the criteria (e.g. the level of a heading).
        N)r�r�r�rZNO_MORE_RADIO_BUTTONSrr�ru)r!rqr�r�r r!r#r#r$�_radioButtonPresentationk
s	z-StructuralNavigation._radioButtonPresentationcs,tjg}|jtj��fdd�}tj||fS)Ncs�j|��j|�gS)N)rr)rq)r!r#r$rr�
sz<StructuralNavigation._radioButtonDialogData.<locals>.rowData)rZSN_HEADER_RADIO_BUTTONrTr3ZSN_TITLE_RADIO_BUTTON)r!rrrr#)r!r$�_radioButtonDialogData}
sz+StructuralNavigation._radioButtonDialogDatacCs4i}tj}dtj|g|d<tj}dtj|g|d<|S)zxReturns a dictionary of [keysymstring, modifiers, description]
        lists for navigating amongst separators.
        �sr9r:)rZSEPARATOR_PREVrrZSEPARATOR_NEXTr)r!r-rrr#r#r$�_separatorBindings�
sz'StructuralNavigation._separatorBindingscCstjg}t||dd�S)a+Returns the MatchCriteria to be used for locating separators
        by collection.

        Arguments:
        - collection: the collection interface for the document
        - arg: an optional argument which may need to be included in
          the criteria (e.g. the level of a heading).
        F)rr)r�ROLE_SEPARATORr)r!rr�r�r#r#r$�_separatorCriteria�
s
z'StructuralNavigation._separatorCriteriacCs|o|j�tjkS)a$The predicate to be used for verifying that the object
        obj is a separator.

        Arguments:
        - obj: the accessible object under consideration.
        - arg: an optional argument which may need to be included in
          the criteria (e.g. the level of a heading).
        )r�rr�)r!rqr�r#r#r$�_separatorPredicate�
s
z(StructuralNavigation._separatorPredicatecCsJ|r,|j|�\}}|j||�|j|d�ntj}tj}|jj||�dS)a
Presents the separator or indicates that one was not found.

        Arguments:
        - obj: the accessible object under consideration.
        - arg: an optional argument which may need to be included in
          the criteria (e.g. the level of a heading).
        rN)r�r�r�rZNO_MORE_SEPARATORSrr�ru)r!rqr�r�r�r r!r#r#r$�_separatorPresentation�
s	z+StructuralNavigation._separatorPresentationcCsJi}tj}dtj|g|d<tj}dtj|g|d<tj}dtj|g|d<|S)ztReturns a dictionary of [keysymstring, modifiers, description]
        lists for navigating amongst tables.
        �tr9r:r;)rZ
TABLE_PREVrrZ
TABLE_NEXTrZ
TABLE_LISTr)r!r-rrrr#r#r$�_tableBindings�
sz#StructuralNavigation._tableBindingscCstjg}t||dd�S)a'Returns the MatchCriteria to be used for locating tables
        by collection.

        Arguments:
        - collection: the collection interface for the document
        - arg: an optional argument which may need to be included in
          the criteria (e.g. the level of a heading).
        T)rr)rr�r)r!rr�r�r#r#r$�_tableCriteria�
s
z#StructuralNavigation._tableCriteriacCst|o|jo|j�tjksdSytdd�|j�D��}Wn
dS|jd�dkrTdSy|j�jdkSYnXdS)a The predicate to be used for verifying that the object
        obj is a table.

        Arguments:
        - obj: the accessible object under consideration.
        - arg: an optional argument which may need to be included in
          the criteria (e.g. the level of a heading).
        FcSsg|]}|jdd��qS)�:r)�split)rp�attrr#r#r$rs�
sz8StructuralNavigation._tablePredicate.<locals>.<listcomp>zlayout-guess�truer)	r�r�rr��dictZ
getAttributesrOr�r�)r!rqr�rr#r#r$�_tablePredicate�
s
z$StructuralNavigation._tablePredicatec	Cs�|r�|j|�}|r|jj|�|jj|j|��|j�jdd�}|s�d|}tjtj|�t	j
||j�}|r�d|}tjtj|�ddg|_|j
|d�|j|�\}}|j||�ntj}tj}|jj||�dS)a	Presents the table or indicates that one was not found.

        Arguments:
        - obj: the accessible object under consideration.
        - arg: an optional argument which may need to be included in
          the criteria (e.g. the level of a heading).
        rz$ERROR: Broken table interface for %szHACK: Located %s for first cellN)r�r�rur�r�r�rr�r�rZfindDescendant�_tableCellPredicater�r�r�r�rZNO_MORE_TABLESr)	r!rqr�r�r�r�r�r r!r#r#r$�_tablePresentations(	

z'StructuralNavigation._tablePresentationcs,tjg}|jtj��fdd�}tj||fS)Ncs�j|�pd�j|�gS)Nr)r�r�)rq)r!r#r$rr&sz6StructuralNavigation._tableDialogData.<locals>.rowData)rZSN_HEADER_CAPTIONrTZSN_HEADER_DESCRIPTIONZSN_TITLE_TABLE)r!rrrr#)r!r$�_tableDialogData"sz%StructuralNavigation._tableDialogDatacCs�i}tj}dtj|g|d<tj}dtj|g|d<tj}dtj|g|d<tj}dtj|g|d<tj}d	tj|g|d
<tj}dtj|g|d<|S)
z�Returns a dictionary of [keysymstring, modifiers, description]
        lists for navigating spatially amongst table cells.
        r@r?rBrArDrCrFrEZHomerGrNrI)	rZTABLE_CELL_LEFTrrZTABLE_CELL_RIGHTZ
TABLE_CELL_UPZTABLE_CELL_DOWNZTABLE_CELL_FIRSTZTABLE_CELL_LAST)r!r-rr#r#r$�_tableCellBindings2sz'StructuralNavigation._tableCellBindingscCstjtjtjg}t||d�S)a,Returns the MatchCriteria to be used for locating table cells
        by collection.

        Arguments:
        - collection: the collection interface for the document
        - arg: an optional argument which may need to be included in
          the criteria (e.g. the level of a heading).
        )r)rr�r�r�r)r!rr�r�r#r#r$�_tableCellCriteriaKs
z'StructuralNavigation._tableCellCriteriacCs|o|j�tjtjtjgkS)a%The predicate to be used for verifying that the object
        obj is a table cell.

        Arguments:
        - obj: the accessible object under consideration.
        - arg: an optional argument which may need to be included in
          the criteria (e.g. the level of a heading).
        )r�rr�r�r�)r!rqr�r#r#r$r�Zs
z(StructuralNavigation._tableCellPredicatecCs�|sdStjr|j||�|j|�\}}|j||�|jj|�|j|�}|s\|j|d�nt	j
tj�tj
r�|j|�\}}|jjtj|d|dd��|jjj|�\}}	tj||	�}
|
r�tjr�|jj|
�dS)aPresents the table cell or indicates that one was not found.

        Arguments:
        - obj: the accessible object under consideration.
        - arg: an optional argument which may need to be included in
          the criteria (e.g. the level of a heading).
        Nrr)�row�column)r
ZspeakCellHeadersr�r�r�r�r�r�r�rr�rZBLANKZspeakCellCoordinatesr�ruZTABLE_CELL_COORDINATESriZrowAndColumnSpanZcellSpanZ
speakCellSpan)r!r�r�rqr�Zblankr�r�ZrowspanZcolspanZ
spanStringr#r#r$�_tableCellPresentationhs&	


z+StructuralNavigation._tableCellPresentationcCsJi}tj}dtj|g|d<tj}dtj|g|d<tj}dtj|g|d<|S)z}Returns a dictionary of [keysymstring, modifiers, description]
        lists for navigating amongst unvisited links.
        �ur9r:r;)rZUNVISITED_LINK_PREVrrZUNVISITED_LINK_NEXTrZUNVISITED_LINK_LISTr)r!r-rrrr#r#r$�_unvisitedLinkBindings�sz+StructuralNavigation._unvisitedLinkBindingscCs(tjg}tjg}|j}t||||dd�S)a0Returns the MatchCriteria to be used for locating unvisited links
        by collection.

        Arguments:
        - collection: the collection interface for the document
        - arg: an optional argument which may need to be included in
          the criteria (e.g. the level of a heading).
        T)rrrr)rrrrsr)r!rr�r�r"r)r#r#r$�_unvisitedLinkCriteria�s
z+StructuralNavigation._unvisitedLinkCriteriacCs<d}|r8|j�tjkr8|j�}|jtj�o6|jtj�}|S)a*The predicate to be used for verifying that the object
        obj is an unvisited link.

        Arguments:
        - obj: the accessible object under consideration.
        - arg: an optional argument which may need to be included in
          the criteria (e.g. the level of a heading).
        F)r�rrrrrr')r!rqr�r+r"r#r#r$�_unvisitedLinkPredicate�s
z,StructuralNavigation._unvisitedLinkPredicatecCsJ|r,|j|�\}}|j||�|j||�ntj}tj}|jj||�dS)aPresents the unvisited link or indicates that one was not
        found.

        Arguments:
        - obj: the accessible object under consideration.
        - arg: an optional argument which may need to be included in
          the criteria (e.g. the level of a heading).
        N)r�r�r�rZNO_MORE_UNVISITED_LINKSrr�ru)r!rqr�r�r r!r#r#r$�_unvisitedLinkPresentation�s
z/StructuralNavigation._unvisitedLinkPresentationcs,tjg}|jtj��fdd�}tj||fS)Ncs�j|��jjj|�gS)N)r	r�ri�uri)rq)r!r#r$rr�sz>StructuralNavigation._unvisitedLinkDialogData.<locals>.rowData)r�SN_HEADER_LINKrT�
SN_HEADER_URIZSN_TITLE_UNVISITED_LINK)r!rrrr#)r!r$�_unvisitedLinkDialogData�sz-StructuralNavigation._unvisitedLinkDialogDatacCsJi}tj}dtj|g|d<tj}dtj|g|d<tj}dtj|g|d<|S)z{Returns a dictionary of [keysymstring, modifiers, description]
        lists for navigating amongst visited links.
        �vr9r:r;)rZVISITED_LINK_PREVrrZVISITED_LINK_NEXTrZVISITED_LINK_LISTr)r!r-rrrr#r#r$�_visitedLinkBindings�sz)StructuralNavigation._visitedLinkBindingscCs*tjg}tjtjg}|j}t||||d�S)a.Returns the MatchCriteria to be used for locating visited links
        by collection.

        Arguments:
        - collection: the collection interface for the document
        - arg: an optional argument which may need to be included in
          the criteria (e.g. the level of a heading).
        )rrr)rrrr'rr)r!rr�r�r"r)r#r#r$�_visitedLinkCriteria�s
z)StructuralNavigation._visitedLinkCriteriacCs:d}|r6|j�tjkr6|j�}|jtj�o4|jtj�}|S)a'The predicate to be used for verifying that the object
        obj is a visited link.

        Arguments:
        - obj: the accessible object under consideration.
        - arg: an optional argument which may need to be included in
          the criteria (e.g. the level of a heading).
        F)r�rrrrrr')r!rqr�r+r"r#r#r$�_visitedLinkPredicate
s
z*StructuralNavigation._visitedLinkPredicatecCsJ|r,|j|�\}}|j||�|j||�ntj}tj}|jj||�dS)aPresents the visited link or indicates that one was not
        found.

        Arguments:
        - obj: the accessible object under consideration.
        - arg: an optional argument which may need to be included in
          the criteria (e.g. the level of a heading).
        N)r�r�r�rZNO_MORE_VISITED_LINKSrr�ru)r!rqr�r�r r!r#r#r$�_visitedLinkPresentation s
z-StructuralNavigation._visitedLinkPresentationcs,tjg}|jtj��fdd�}tj||fS)Ncs�j|��jjj|�gS)N)r	r�rir�)rq)r!r#r$rr7sz<StructuralNavigation._visitedLinkDialogData.<locals>.rowData)rr�rTr�ZSN_TITLE_VISITED_LINK)r!rrrr#)r!r$�_visitedLinkDialogData3sz+StructuralNavigation._visitedLinkDialogDatacCsJi}tj}dtj|g|d<tj}dtj|g|d<tj}dtj|g|d<|S)zsReturns a dictionary of [keysymstring, modifiers, description]
        lists for navigating amongst links.
        �kr9r:r;)rZ	LINK_PREVrrZ	LINK_NEXTrZ	LINK_LISTr)r!r-rrrr#r#r$�
_linkBindingsBsz"StructuralNavigation._linkBindingscCs&tjg}tjg}|j}t||||d�S)a0Returns the MatchCriteria to be used for locating unvisited links
        by collection.

        Arguments:
        - collection: the collection interface for the document
        - arg: an optional argument which may need to be included in
          the criteria (e.g. the level of a heading).
        )rrr)rrr'rr)r!rr�r�r"r)r#r#r$�
_linkCriteriaRs
z"StructuralNavigation._linkCriteriacCs0d}|r,|j�tjkr,|j�}|jtj�}|S)a The predicate to be used for verifying that the object
        obj is an link.

        Arguments:
        - obj: the accessible object under consideration.
        - arg: an optional argument which may need to be included in
          the criteria (e.g. the level of a heading).
        F)r�rrrrr')r!rqr�r+r"r#r#r$�_linkPredicateds

z#StructuralNavigation._linkPredicatecCsJ|r,|j|�\}}|j||�|j||�ntj}tj}|jj||�dS)aPresents the link or indicates that one was not found.

        Arguments:
        - obj: the accessible object under consideration.
        - arg: an optional argument which may need to be included in
          the criteria (e.g. the level of a heading).
        N)r�r�r�rZ
NO_MORE_LINKSrr�ru)r!rqr�r�r r!r#r#r$�_linkPresentationts	z&StructuralNavigation._linkPresentationcs8tjg}|jtj�|jtj��fdd�}tj||fS)Ncs �j|��j|��jjj|�gS)N)r	rr�rir�)rq)r!r#r$rr�sz5StructuralNavigation._linkDialogData.<locals>.rowData)rr�rTr3r�Z
SN_TITLE_LINK)r!rrrr#)r!r$�_linkDialogData�s
z$StructuralNavigation._linkDialogDatacCsJi}tj}dtj|g|d<tj}dtj|g|d<tj}dtj|g|d<|S)zxReturns a dictionary of [keysymstring, modifiers, description]
        lists for navigating amongst "clickable" objects.�ar9r:r;)rZCLICKABLE_PREVrrZCLICKABLE_NEXTrZCLICKABLE_LISTr)r!r-rrrr#r#r$�_clickableBindings�sz'StructuralNavigation._clickableBindingscCst|dd�S)a+Returns the MatchCriteria to be used for locating clickables
        by collection.

        Arguments:
        - collection: the collection interface for the document
        - arg: an optional argument which may need to be included in
          the criteria (e.g. the level of a heading).
        T)r)r)r!rr�r#r#r$�_clickableCriteria�s
z'StructuralNavigation._clickableCriteriacCs|jjj|�S)a$The predicate to be used for verifying that the object
        obj is a clickable.

        Arguments:
        - obj: the accessible object under consideration.
        - arg: an optional argument which may need to be included in
          the criteria (e.g. the level of a heading).
        )r�riZisClickableElement)r!rqr�r#r#r$�_clickablePredicate�s
z(StructuralNavigation._clickablePredicatecCsN|r,|j|�\}}|j||�|j||�n|sJtj}tj}|jj||�dS)a
Presents the clickable or indicates that one was not found.

        Arguments:
        - obj: the accessible object under consideration.
        - arg: an optional argument which may need to be included in
          the criteria (e.g. the level of a heading).
        N)r�r�r�rZNO_MORE_CLICKABLESrr�ru)r!rqr�r�r r!r#r#r$�_clickablePresentation�s	z+StructuralNavigation._clickablePresentationcs,tjg}|jtj��fdd�}tj||fS)Ncs�j|��j|�gS)N)r	r)rq)r!r#r$rr�sz:StructuralNavigation._clickableDialogData.<locals>.rowData)rZSN_HEADER_CLICKABLErTr>ZSN_TITLE_CLICKABLE)r!rrrr#)r!r$�_clickableDialogData�sz)StructuralNavigation._clickableDialogDatacCs4i}tj}dtj|g|d<tj}dtj|g|d<|S)NZcommarKrM)rZCONTAINER_STARTrr�
CONTAINER_ENDr)r!r-rr#r#r$�_containerBindings�sz'StructuralNavigation._containerBindingscCst||jdd�S)NT)rr)rr�)r!rr�r#r#r$�_containerCriteria�sz'StructuralNavigation._containerCriteriacCs
|j|�S)N)r�)r!rqr�r#r#r$�_containerPredicate�sz(StructuralNavigation._containerPredicatecKsf|s|jjtj�dS|jd�r.|jjtj�|}|dkrH|j|�\}}|j||�|j||d�dS)Nr�T)	r�rurZCONTAINER_NOT_IN_ArOr�r�r�r�)r!rqr��kwargsr�r#r#r$�_containerPresentation�s
z+StructuralNavigation._containerPresentation)F)N)T)N)NN)NN)F)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)�r&r'r(r)Z
BLOCKQUOTEZBUTTONZ	CHECK_BOXZCHUNKZ	CLICKABLEZ	COMBO_BOXr�ZENTRYZ
FORM_FIELDZHEADINGZIMAGEZLANDMARKZLINKZLISTZ	LIST_ITEMr�Z	PARAGRAPHZRADIO_BUTTONZ	SEPARATORZTABLEr�ZUNVISITED_LINKZVISITED_LINKrrrrrRrZ
ROLE_LIST_BOXZ
ROLE_ENTRYZROLE_PASSWORD_TEXTr&ZROLE_SPIN_BUTTONrTrPr]r�Z	ROLE_MATHr�ZROLE_STATICr�r�r�ZROLE_TABLE_ROWr�r:ZROLE_DESCRIPTION_TERMZROLE_DESCRIPTION_VALUEZROLE_DOCUMENT_EMAILZROLE_DOCUMENT_PRESENTATIONZROLE_DOCUMENT_SPREADSHEETZROLE_DOCUMENT_TEXTZROLE_DOCUMENT_WEBr7ZROLE_BLOCK_QUOTEZROLE_DESCRIPTION_LISTZ	ROLE_FORMZROLE_FOOTERZROLE_HEADERZ
ROLE_LANDMARKZROLE_LOGZROLE_MARQUEEZ
ROLE_PANELr�r�rZROLE_IMAGE_MAPrer%r�r�r�r�r�r�r�rtr�rfr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrr	rrrrrrr"r#r%r*r,r-r.r/r0r1r2r4r6r9r<r=r?rArBrCrDrErGrIrJrKrMrOrQrSrUrVr[rXr^r`rarbrdrfrgrhrirkrlrmrorprrrtrurvrwrxryrzr{r|r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r#r#r#r$r�s�( I W	

!)
)



 )
r�)r)Z__id__�__version__Z__date__Z
__copyright__Z__license__rrrrrrrrr	r
rrr
rrZ
getManagerrrr*r�r#r#r#r$�<module>s4H