%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/orca/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/orca/__pycache__/speech_generator.cpython-312.pyc

�

g
f����l�dZdZdZdZdZdZddlZddlZejdd	�dd
l	m
Z
ddlZddl
ZddlZddlZddlmZdd
lmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddl m!Z!ddl"m#Z#ddl$m%Z%ddl&m'Z'Gd�d�Z(e(�gZ)Gd�d �Z*e*�gZ+d!Z,d"Z-d#Z.d$Z/d%Z0d&Z1d'Z2e-ejfe.ejhe/ejje0ejle1ejle2ejliZ7Gd(�d)ejp�Z9y)*z6Utilities for obtaining speech utterances for objects.z$Id:$z$Revision:$z$Date:$z-Copyright (c) 2005-2009 Sun Microsystems Inc.�LGPL�N�Atspiz2.0)r�)�acss)�debug)�	generator)�mathsymbols)�messages)�object_properties)�settings)�settings_manager)�speech)�text_attribute_names)�
AXDocument)�AXHypertext)�AXObject)�AXTable)�AXText)�AXUtilities)�AXValuec��eZdZdZd�Zd�Zy)�PausezJA dummy class to indicate we want to insert a pause into an
    utterance.c��y�N���selfs �7/usr/lib/python3/dist-packages/orca/speech_generator.py�__init__zPause.__init__;����c��y)N�PAUSErrs r�__str__z
Pause.__str__>s��r!N��__name__�
__module__�__qualname__�__doc__rr$rr!rrr8s���
�r!rc��eZdZdZd�Zd�Zy)�	LineBreakzYA dummy class to indicate we want to break an utterance into
    separate calls to speak.c��yrrrs rrzLineBreak.__init__Fr r!c��y)Nz
LINE BREAKrrs rr$zLineBreak.__str__Is��r!Nr%rr!rr+r+Cs�� �
�r!r+�	_generate�default�	uppercase�	hyperlink�system�state�valuec�|��eZdZdZd�Zd�Zd�Zd��fd�	Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z d�Z!d �Z"d!�Z#�fd"�Z$d#�Z%d$�Z&d%�Z'�fd&�Z(d'�Z)�fd(�Z*d)�Z+d*�Z,d+�Z-d,�Z.d-�Z/d.�Z0d/�Z1�fd0�Z2�fd1�Z3�fd2�Z4d3�Z5d4�Z6d5�Z7d6�Z8d7�Z9d8�Z:d9�Z;d:�Z<d;�Z=d<�Z>d=�Z?d>�Z@d?�ZAd@�ZBdA�ZCgdB�fdC�ZDdD�ZEdE�ZFdF�ZG�fdG�ZHdH�ZI�fdI�ZJdJ�ZK�fdK�ZLdL�ZM�fdM�ZNdN�ZOdO�ZPdP�ZQdQ�ZRdR�ZSdS�ZTdT�ZUdU�ZVdV�ZWdW�ZXdX�ZYdY�ZZdZ�Z[d[�Z\d\�Z]d]�Z^d^�Z_d_�Z`d`�Zada�Zbdb�Zc�fdc�Zd�fdd�Zede�Zfdf�Zgdg�Zhdh�Zidi�Zjdj�Zkdk�Zldl�Zmdm�Zndn�Zodo�Zpdp�Zqdq�Zrdr�Zsds�Ztdt�Zudu�Zvdv�Zwdw�Zxdx�Zydy�Zzdz�Z{d{�Z|d|�Z}d}�Z~d~�Zd�Z�d��Z�d��Z�d��Z�d��Z�d��Z�d��Z�d��Z�d�d��Z�d��Z��xZ�S)��SpeechGeneratorz�Takes accessible objects and produces a string to speak for
    those objects.  See the generateSpeech method, which is the primary
    entry point.  Subclasses can feel free to override/extend the
    speechGenerators instance field as they see fit.c�F�tjj||d�y)Nr)r�	Generatorr)r�scripts  rrzSpeechGenerator.__init__ms�����$�$�T�6�8�<r!c�b�tjj||�|j|d<y)zCOther things to make available from the formatting string.
        �voiceN)rr8�_addGlobalsr;)r�globalsDicts  rr<zSpeechGenerator._addGlobalsps(��	���'�'��k�:�#�z�z��G�r!c��|j|fi|��}|rBttd�|��s,d|dg}tjtj
|d�g}|S)Nc�$�t|t�Sr)�
isinstancer��xs r�<lambda>z0SpeechGenerator.generateSpeech.<locals>.<lambda>xs��
�1�e�0D�,D�r!zSPEECH GENERATOR: Results forzare pauses onlyT)�generate�list�filterr�printTokens�
LEVEL_INFO)r�obj�args�rv�tokenss     r�generateSpeechzSpeechGenerator.generateSpeechvsX��
�T�]�]�3�
'�$�
'��
�d�6�"D�b�I�J�5�s�<M�N�F����e�.�.���=��B��	r!c���t|tj�r|syt|t�r;|D�cgc]}|j	||���}}djt
d�|��St�|�||�Scc}w)N�� c��|SrrrAs rrCz8SpeechGenerator._resultElementToString.<locals>.<lambda>�s��Q�r!)r@r�ACSSrE�_resultElementToString�joinrF�super)r�element�
includeAllrBrK�	__class__s     �rrSz&SpeechGenerator._resultElementToStringsn����g�t�y�y�)�*���g�t�$�FM�N��$�-�-�a��<�N�B�N��8�8�F�;��3�4�4��w�-�g�z�B�B��Os�A:c��|jdtj|��}|tjj
k(r%t
j�jd�rgStjj||fi|��}|ro|tjj
k(r*|j|jtfd|i|���|S|j|jtfd|i|���|S)a Returns an array of strings for use by speech and braille that
        represent the name of the object.  If the object is directly
        displaying any text, that text will be treated as the name.
        Otherwise, the accessible name of the object will be used.  If
        there is no accessible name, then the description of the
        object will be used.  This method will return an empty array
        if nothing can be found.  [[[WDW - I wonder if we should just
        have _generateName, _generateDescription,
        _generateDisplayedText, etc., that don't do any fallback.
        Then, we can allow the formatting to do the fallback (e.g.,
        'displayedText or name or description'). [[[JD to WDW - I
        needed a _generateDescription for whereAmI. :-) See below.
        �role�onlySpeakDisplayedTextrI)�getr�get_roler�Role�LAYERED_PANEr
�
getManager�
getSettingrr8�
_generateName�extendr;�SYSTEM�DEFAULT)rrIrJrZ�results     rrbzSpeechGenerator._generateName�s����x�x��� 1� 1�#� 6�7���5�:�:�*�*�*��*�*�,�7�7�8P�Q��I��$�$�2�2�4��E��E����u�z�z�.�.�.��
�
�j�d�j�j��A�S�A�D�A�B��
��
�
�j�d�j�j��B�c�B�T�B�C��
r!c��tjj||fi|��}|r(|j|jt
fd|i|���|S)aReturns the label for an object as an array of strings for use by
        speech and braille.  The label is determined by the displayedLabel
        method of the script utility, and an empty array will be returned if
        no label can be found.
        rI)rr8�_generateLabelrcr;re�rrIrJrfs    rrhzSpeechGenerator._generateLabel�sJ���$�$�3�3�D�#�F��F����M�M�*�$�*�*�W�>�#�>��>�?��
r!c��|jdtj|��}|tjj
k(rQ|jjj|�r,d|dg}tjtj|d�gSg}|j|j|fi|���|sPtj|�}|r9|j|�|j|j t"fd|i|���|r|Stj$|�}t'j(|�r|j*|fi|��}|S)z�Returns the label as an array of strings for speech and braille.
        If the label cannot be found, the name will be used instead.
        If the name cannot be found, an empty array will be returned.
        rZzSPEECH GENERATOR:zis popup menu for current item.TrI)r\rr]rr^�MENU�_script�	utilities�isPopupMenuForCurrentItemrrGrHrcrh�get_name�appendr;re�
get_parentr�is_autocomplete�_generateLabelOrName)rrIrJrZrLrf�name�parents        rrsz$SpeechGenerator._generateLabelOrName�s���x�x��� 1� 1�#� 6�7���5�:�:�?�?�"�t�|�|�'=�'=�'W�'W�X[�'\�)�3�0Q�R�F����e�.�.���=��I����
�
�)�d�)�)�#�6��6�7���$�$�S�)�D���
�
�d�#��
�
�j�d�j�j��B�c�B�T�B�C���M��$�$�S�)���&�&�v�.�.�T�.�.�v�>��>�F��
r!c��tjj||fi|��}|r(|j|jt
fd|i|���|S)a�Returns an array of strings for use by speech and braille that
        represent the 'placeholder' text. This is typically text that
        serves as a functional label and is found in a text widget until
        that widget is given focus at which point the text is removed,
        the assumption being that the user was able to see the text prior
        to giving the widget focus.
        rI)rr8�_generatePlaceholderTextrcr;reris    rrwz(SpeechGenerator._generatePlaceholderText�sJ���$�$�=�=�d�C�P�4�P����M�M�*�$�*�*�W�>�#�>��>�?��
r!c��|j|fi|��xs|j|fi|��}|rd|jjd<|Sd|d<|j|fi|��}|rd|jjd<|S)NF�usedDescriptionForAlertT�	alerttext)�_generateExpandedEOCs�_generateUnrelatedLabelsrl�pointOfReference�_generateDescriptionris    r�_generateAlertTextz"SpeechGenerator._generateAlertText�s���+��+�+�C�8�4�8�?�1�D�1�1�#�>��>�	��GL�D�L�L�)�)�*C�D��M� ��[��*��*�*�3�7�$�7���GK�D�L�L�)�)�*C�D��
r!c��d}|jdtj|��}|tjj
k(r'	|jjjd�}n&	|jjjd�}|rgStj�jd�rgStj�jd�s|jd�sgS|jd�r%tj�jd	�sgS|jd
�}tj|�rgS||k(rgStj j"||fi|��}|r(|j%|j&t(fd|i|���|S#t$rY��wxYw#t$rY��-wxYw)z�Returns an array of strings fo use by speech and braille that
        represent the description of the object, if that description
        is different from that of the name and label.
        FrZry�!usedDescriptionForUnrelatedLabelsr[�speakDescriptionrz�
inMouseReview�presentToolTips�priorObjrI)r\rr]rr^�ALERTrlr}�pop�	Exceptionr
r`rar�is_tool_tiprr8r~rcr;rd)rrIrJ�alreadyUsedrZr�rfs       rr~z$SpeechGenerator._generateDescription�s������x�x��� 1� 1�#� 6�7���5�:�:�#�#�#�
�"�l�l�;�;�?�?�@Y�Z��
�"�l�l�;�;�?�?�@c�d����I��&�&�(�3�3�4L�M��I��*�*�,�7�7�8J�K��8�8�K�(��I��8�8�O�$�#�.�.�0�;�;�<M�N��I��8�8�J�'���"�"�8�,��I��s�?��I��$�$�9�9�$��L�t�L����M�M�*�$�*�*�V�=��=��=�>��
��A�
��
��
�
��
�s$�%F#�-%F3�#	F0�/F0�3	G�?Gc�0�tj�jd�rgStj�jd�sgStjj
||fi|��}|r(|j
|jtfd|i|���|S)z|Returns an array of strings for use by speech and braille that
        represent the description of the image on the object.r[r�rI)	r
r`rarr8�_generateImageDescriptionrcr;rdris    rr�z)SpeechGenerator._generateImageDescriptions����&�&�(�3�3�4L�M��I��*�*�,�7�7�8J�K��I��$�$�>�>�t�S�Q�D�Q����M�M�*�$�*�*�V�=��=��=�>��
r!c��tjj||fi|��}|r(|j|jt
fd|i|���|S)z�Returns an array of strings for use by speech and braille that
        represent the read only state of this object, but only if it
        is read only (i.e., it is a text area that cannot be edited).
        rI)rr8�_generateReadOnlyrcr;rdris    rr�z!SpeechGenerator._generateReadOnly,sJ���$�$�6�6�t�S�I�D�I����M�M�*�$�*�*�V�=��=��=�>��
r!c�x�tj�jd�s4tj�jd�tjk(rgSg}tj|�r|jtj�|r(|j|jtfd|i|���|S�Nr[�speechVerbosityLevelrI)
r
r`rar�VERBOSITY_LEVEL_BRIEFr�	has_popuprpr
�	HAS_POPUPrcr;rdris    r�_generateHasPopupz!SpeechGenerator._generateHasPopup7s����&�&�(�3�3�4L�M��)�)�+�6�6�7M�N��0�0�1��I���� � ��%��M�M�(�,�,�-���M�M�*�$�*�*�V�=��=��=�>��
r!c�N�tj�jd�s4tj�jd�tjk(rgStjj||fi|��}|r(|j|jtfd|i|���|Sr�)r
r`rarr�rr8�_generateClickablercr;rdris    rr�z"SpeechGenerator._generateClickableDs����&�&�(�3�3�4L�M��)�)�+�6�6�7M�N��0�0�1��I��$�$�7�7��c�J�T�J����M�M�*�$�*�*�V�=��=��=�>��
r!c���tj�jd�rgStjj
||fi|��}|r(|j
|jtfd|i|���|S�Nr[rI)	r
r`rarr8�_generateHasLongDescrcr;rdris    rr�z$SpeechGenerator._generateHasLongDescOse���&�&�(�3�3�4L�M��I��$�$�9�9�$��L�t�L����M�M�*�$�*�*�V�=��=��=�>��
r!c���tj�jd�rgStjj
||fi|��}|r(|j
|jtfd|i|���|Sr�)	r
r`rarr8�_generateHasDetailsrcr;rdris    rr�z#SpeechGenerator._generateHasDetailsX�e���&�&�(�3�3�4L�M��I��$�$�8�8��s�K�d�K����M�M�*�$�*�*�V�=��=��=�>��
r!c���tj�jd�rgStjj
||fi|��}|r(|j
|jtfd|i|���|Sr�)	r
r`rarr8�_generateDetailsForrcr;rdris    rr�z#SpeechGenerator._generateDetailsForar�r!c���tj�jd�rgStjj
||fi|��}|r(|j
|jtfd|i|���|Sr�)	r
r`rarr8�_generateAllDetailsrcr;rdris    rr�z#SpeechGenerator._generateAllDetailsjr�r!c�4�tj�jd�rgS|jdd�}|dk7rgSg}|jj
j
|�rj|jtjg�|j|jtfd|i|���|j|j|fi|���|jtjg�|j|jtfd|i|���|S�Nr[�startOffsetrrI)r
r`rar\rlrm�$isFirstItemInInlineContentSuggestionrcr�ROLE_CONTENT_SUGGESTIONr;rd�_generatePauser
�CONTENT_DELETION_START�rrIrJr�rfs     r�_generateDeletionStartz&SpeechGenerator._generateDeletionStartss����&�&�(�3�3�4L�M��I��h�h�}�a�0���!���I����<�<�!�!�F�F�s�K��M�M�,�D�D�E�F��M�M�*�$�*�*�V�=��=��=�>��M�M�-�$�-�-�c�:�T�:�;��
�
�x�6�6�7�8��
�
�j�d�j�j��9�S�9�D�9�:��
r!c��tj�jd�rgS|jd�}|�t	j
|�}|r||k7rgStjg}|j|jtfd|i|���|jjj|��r|j|j|fi|���|jtjg�|j|jtfd|i|���t!j"||jjj$�}|jjj'|�rS|j|j|fi|���|j|j)||jd����|S�Nr[�	endOffsetrI�mode)r�)r
r`rar\r�get_character_countr
�CONTENT_DELETION_ENDrcr;rdrlrm�#isLastItemInInlineContentSuggestionr��CONTENT_SUGGESTION_ENDr�
find_ancestor�
hasDetails�isContentSuggestionr��rrIrJr��lengthrf�	containers       r�_generateDeletionEndz$SpeechGenerator._generateDeletionEnd�sr���&�&�(�3�3�4L�M��I��H�H�[�)�	�� ��/�/��4�F��&�I�-��	��/�/�0���
�
�j�d�j�j��9�S�9�D�9�:��<�<�!�!�E�E�c�J��M�M�-�$�-�-�c�:�T�:�;��M�M�8�:�:�;�<��M�M�*�$�*�*�V�=��=��=�>� �.�.�s�D�L�L�4J�4J�4U�4U�V�I��|�|�%�%�9�9�)�D��
�
�1�d�1�1�#�>��>�?��
�
�d�6�6�y�t�x�x�PV�GW�6�X�Y��
r!c�4�tj�jd�rgS|jdd�}|dk7rgSg}|jj
j
|�rj|jtjg�|j|jtfd|i|���|j|j|fi|���|jtjg�|j|jtfd|i|���|Sr�)r
r`rar\rlrmr�rcrr�r;rdr�r
�CONTENT_INSERTION_STARTr�s     r�_generateInsertionStartz'SpeechGenerator._generateInsertionStart�s����&�&�(�3�3�4L�M��I��h�h�}�a�0���!���I����<�<�!�!�F�F�s�K��M�M�,�D�D�E�F��M�M�*�$�*�*�V�=��=��=�>��M�M�-�$�-�-�c�:�T�:�;��
�
�x�7�7�8�9��
�
�j�d�j�j��9�S�9�D�9�:��
r!c��tj�jd�rgS|jd�}|�t	j
|�}|r||k7rgStjg}|j|jtfd|i|���|jjj|��r|j|j|fi|���|jtjg�|j|jtfd|i|���t!j"||jjj$�}|jjj'|�rS|j|j|fi|���|j|j)||jd����|Sr�)r
r`rar\rr�r
�CONTENT_INSERTION_ENDrcr;rdrlrmr�r�r�rr�r�r�r�r�s       r�_generateInsertionEndz%SpeechGenerator._generateInsertionEnd�sr���&�&�(�3�3�4L�M��I��H�H�[�)�	�� ��/�/��4�F��&�I�-��	��0�0�1���
�
�j�d�j�j��9�S�9�D�9�:��<�<�!�!�E�E�c�J��M�M�-�$�-�-�c�:�T�:�;��M�M�8�:�:�;�<��M�M�*�$�*�*�V�=��=��=�>� �.�.�s�D�L�L�4J�4J�4U�4U�V�I��|�|�%�%�9�9�)�D��
�
�1�d�1�1�#�>��>�?��
�
�d�6�6�y�t�x�x�PV�GW�6�X�Y��
r!c��tj�jd�rgS|jdd�}|dk7rgSg}|jj
j
|�}|r[|j|�|j|jtfd|i|���|j|j|fi|���|jtj�|j|jtfd|i|���|Sr�)r
r`rar\rlrm�getRoleDescriptionrprcr;rdr�r
�CONTENT_MARK_START)rrIrJr�rf�roledescriptions      r�_generateMarkStartz"SpeechGenerator._generateMarkStart�s����&�&�(�3�3�4L�M��I��h�h�}�a�0���!���I����,�,�0�0�C�C�C�H����M�M�/�*��M�M�*�$�*�*�V�=��=��=�>��M�M�-�$�-�-�c�:�T�:�;��
�
�h�1�1�2��
�
�j�d�j�j��9�S�9�D�9�:��
r!c�$�tj�jd�rgS|jd�}|�t	j
|�}|r||k7rgStjg}|j|jtfd|i|���|S)Nr[r�rI)r
r`rar\rr�r
�CONTENT_MARK_ENDrcr;rd)rrIrJr�r�rfs      r�_generateMarkEndz SpeechGenerator._generateMarkEnd�s����&�&�(�3�3�4L�M��I��H�H�[�)�	�� ��/�/��4�F��&�I�-��	��+�+�,���
�
�j�d�j�j��9�S�9�D�9�:��
r!c���tj�jd�rgStjj
||fi|��}|r(|j
|jtfd|i|���|Sr�)	r
r`rarr8�_generateAvailabilityrcr;rdris    rr�z%SpeechGenerator._generateAvailability�se���&�&�(�3�3�4L�M��I��$�$�:�:�4��M��M����M�M�*�$�*�*�V�=��=��=�>��
r!c���tj�jd�rgStjj
||fi|��}|r(|j
|jtfd|i|���|Sr�)	r
r`rarr8�_generateInvalidrcr;rdris    rr�z SpeechGenerator._generateInvalid�se���&�&�(�3�3�4L�M��I��$�$�5�5�d�C�H�4�H����M�M�*�$�*�*�V�=��=��=�>��
r!c���tj�jd�rgStjj
||fi|��}|r(|j
|jtfd|i|���|Sr�)	r
r`rarr8�_generateRequiredrcr;rdris    rr�z!SpeechGenerator._generateRequired�se���&�&�(�3�3�4L�M��I��$�$�6�6�t�S�I�D�I����M�M�*�$�*�*�V�=��=��=�>��
r!c�`�tj�jd�rgS|jd�rgS|jj
j
|�r>|jdtj|��}|j�\}}||vrgStj�jd�tjk(r|j|fi|��Stjj||fi|��}|r(|j!|j"t$fd|i|���|S)Nr[�leavingrZr�rI)r
r`rar\rlrm�isTextDocumentTablerr]�"_getEnabledAndDisabledContextRolesrr��_generateRoleNamerr8�_generateTablercr;rd)rrIrJrZ�enabled�disabledrfs       rr�zSpeechGenerator._generateTables���&�&�(�3�3�4L�M��I��8�8�I���I��<�<�!�!�5�5�c�:��8�8�F�H�$5�$5�c�$:�;�D� $� G� G� I��G�X��x���	��&�&�(�3�3�4J�K��,�,�-�)�4�)�)�#�6��6�6��$�$�3�3�D�#�F��F����M�M�*�$�*�*�V�=��=��=�>��
r!c��tj�jd�rgSg}|jdt	j
|��}|tjjk7r"|j|j|fi|���|S)asA convenience method to prevent the Atspi.Role.PARAGRAPH role
        from being spoken. In the case of a Atspi.Role.PARAGRAPH
        role, an empty array will be returned. In all other cases, the
        role name will be returned as an array of strings (and
        possibly voice and audio specifications).  Note that a 'role'
        attribute in args will override the accessible role of the
        obj. [[[WDW - I wonder if this should be moved to
        _generateRoleName.  Or, maybe make a 'do not speak roles' attribute
        of a speech generator that we can update and the user can
        override.]]]
        r[rZ)r
r`rar\rr]rr^�	PARAGRAPHrcr�)rrIrJrfrZs     r�_generateTextRolez!SpeechGenerator._generateTextRolesw���&�&�(�3�3�4L�M��I����x�x��� 1� 1�#� 6�7���5�:�:�'�'�'��M�M�0�$�0�0��=��=�>��
r!c�^�tj�jd�rgS|jjj|�rgS|jjj
|�rgS|jjj|�rgSg}|jdtj|��}tjjtjjtjjtjj g}tj"|�}|tjj$k(r&t'j(|�r|j+|�S|jjj-|�rd|j/|j1|tjj2���|j5|j6t8fd|i|���|S|tjj:k(rt'j<|�rgSt'j>|�r$|j/tj|��|jjjA|�r)|j/tjjB�tj�jd�tDjFk(rC|j5tjjHtjjJg�|tjjLk(r�|jjjO|�}|r^|j/tPjR|j0|fi|��|d�z�|j5|j6t8fd|i|���||vrL|sJ|j/|j0|fi|���|j5|j6t8fd|i|���|S)a5Returns the role name for the object in an array of strings (and
        possibly voice and audio specifications), with the exception
        that the Atspi.Role.UNKNOWN role will yield an empty array.
        Note that a 'role' attribute in args will override the
        accessible role of the obj.
        r[rZ�rZrIr�)rZ�level)*r
r`rarlrm�isStatusBarNotification�	isDesktop�
isDockedFramer\rr]rr^�UNKNOWN�REDUNDANT_OBJECT�FILLER�EXTENDEDrqrkr�is_combo_boxr��isSingleLineAutocompleteEntryrp�getLocalizedRoleName�AUTOCOMPLETErcr;rd�PANEL�is_selected�is_list_box�isStatusBarDescendant�LABELrr��ICON�CANVAS�HEADING�headingLevelr�ROLE_HEADING_LEVEL_SPEECH)rrIrJrfrZ�doNotPresentrur�s        rr�z!SpeechGenerator._generateRoleName0s���&�&�(�3�3�4L�M��I��<�<�!�!�9�9�#�>��I��<�<�!�!�+�+�C�0��I��<�<�!�!�/�/��4��I����x�x��� 1� 1�#� 6�7���
�
�*�*��
�
�3�3��
�
�)�)��
�
�+�+�-��
�$�$�S�)���5�:�:�?�?�"�{�'?�'?��'G��)�)�&�1�1��<�<�!�!�?�?��D��M�M�$�3�3�C�e�j�j�>U�>U�3�V�W��M�M�*�$�*�*�V�=��=��=�>��M��5�:�:�#�#�#��&�&�s�+��I��"�"�6�*����� 1� 1�#� 6�7��<�<�!�!�7�7��<�����
�
� 0� 0�1��&�&�(�3�3�4J�K��1�1�2���������%�*�*�2C�2C� D�E��5�:�:�%�%�%��L�L�*�*�7�7��<�E���
�
�/�I�I�5�D�5�5�c�B�T�B�"�M$�$�%��
�
�j�d�j�j��A�S�A�D�A�B��|�#�F��M�M�3�$�3�3�C�@�4�@�A��M�M�*�$�*�*�V�=��=��=�>��
r!c�8�|j|fi|��}|r|dSy)awReturns the role name for the object in an array of strings (and
        possibly voice and audio specifications), with the exception
        that the Atspi.Role.UNKNOWN role will yield an empty array.
        Note that a 'role' attribute in args will override the
        accessible role of the obj.  This is provided mostly as a
        method for scripts to call.
        rrO)r��rrIrJ�	generateds    r�getRoleNamezSpeechGenerator.getRoleNameps+��+�D�*�*�3�7�$�7�	���Q�<��r!c�8�|j|fi|��}|r|dSy)NrrO)rbr�s    r�getNamezSpeechGenerator.getName~s)��&�D�&�&�s�3�d�3�	���Q�<��r!c���|jjj|�s%|jjj|�rtj
S|j
dtj|��}|tjjk(r%tj|�rtjSt�|�@|fi|��S)z�Returns the localized name of the given Accessible object; the name
        is suitable to be spoken.

        Arguments:
        - obj: an Accessible object
        rZ)rlrm�isEditableComboBox�isEditableDescendantOfComboBoxr�ROLE_EDITABLE_COMBO_BOXr\rr]rr^�LINKr�
is_visited�ROLE_VISITED_LINKrUr�)rrIrJrZrXs    �rr�z$SpeechGenerator.getLocalizedRoleName�s�����<�<�!�!�4�4�S�9��l�l�$�$�C�C�C�H�$�<�<�<��x�x��� 1� 1�#� 6�7���5�:�:�?�?�"�{�'=�'=�c�'B�$�6�6�6��w�+�C�8�4�8�8r!c���g}|jjj|�}d}|jdt	j
|��}|tjjk(s2|tjjk(rtj|�sd}|jjj|||�}|D]}}|j|fi|��}	|	rUt|	d�dk(rD|jjj|�rt!j"|	d�}
|
r|
|	d<|j%|	��|r(|j%|j&t(fd|i|���|S)z�Returns, as an array of strings (and possibly voice
        specifications), all the labels which are underneath the obj's
        hierarchy and which are not in a label for or labelled by
        relation.
        rrZ�rrI)rlrmr�r\rr]rr^r��DIALOGr�is_message_dialog�unrelatedLabelsrb�len�isMathr	�getCharacterNamercr;re)rrIrJrf�visibleOnly�minimumWordsrZ�labels�labelrt�charnames           rr|z(SpeechGenerator._generateUnrelatedLabels�s@�����,�,�0�0�H�H��M�M�����x�x��� 1� 1�#� 6�7���5�:�:�#�#�#��E�J�J�%�%�%�k�.K�.K�C�.P��L����'�'�7�7��[�,�W���	 �E�%�4�%�%�e�4�t�4�D���D��G���)�d�l�l�.D�.D�.K�.K�C�.P�&�7�7��Q��@���&�D��G��M�M�$��
	 ���M�M�*�$�*�*�W�>�#�>��>�?��
r!c���tj�jd�rgStjj
||fi|��}|r(|j
|jtfd|i|���|S�aReturns an array of strings for use by speech and braille that
        represent the checked state of the object.  This is typically
        for check boxes. [[[WDW - should we return an empty array if
        we can guarantee we know this thing is not checkable?]]]
        r[rI)	r
r`rarr8�_generateCheckedStatercr;�STATEris    rrz%SpeechGenerator._generateCheckedState�sg���&�&�(�3�3�4L�M��I��$�$�:�:�4��M��M����M�M�*�$�*�*�U�<��<�t�<�=��
r!c���tj�jd�rgStjj
||fi|��}|r(|j
|jtfd|i|���|S)z�Returns an array of strings for use by speech and braille that
        represent the expanded/collapsed state of an object, such as a
        tree node. If the object is not expandable, an empty array
        will be returned.
        r[rI)	r
r`rarr8�_generateExpandableStatercr;rris    rrz(SpeechGenerator._generateExpandableState�sg���&�&�(�3�3�4L�M��I��$�$�=�=�d�C�P�4�P����M�M�*�$�*�*�U�<��<�t�<�=��
r!c����tj�jd�rgSt�|�|fi|��}|r(|j|jtfd|i|���|Sr�)r
r`rarU� _generateCheckedStateIfCheckablercr;r�rrIrJrfrXs    �rrz0SpeechGenerator._generateCheckedStateIfCheckable�s]����&�&�(�3�3�4L�M��I���9�#�F��F����M�M�*�$�*�*�U�<��<�t�<�=��
r!c���tj�jd�rgStjj
||fi|��}|r(|j
|jtfd|i|���|S)z�Returns an array of strings for use by speech and braille that
        represent the checked state of the menu item, only if it is
        checked. Otherwise, and empty array will be returned.
        r[rI)	r
r`rarr8�_generateMenuItemCheckedStatercr;rris    rrz-SpeechGenerator._generateMenuItemCheckedState�sl��
�&�&�(�3�3�4L�M��I��$�$�)�)�$��=�7;�=����M�M�*�$�*�*�U�<��<�t�<�=��
r!c����tj�jd�rgSt�|�|fi|��}|r(|j|jtfd|i|���|S)aReturns an array of strings (and possibly voice and audio
        specifications) that represent the multiselectable state of
        the object.  This is typically for list boxes. If the object
        is not multiselectable, an empty array will be returned.
        r[rI)r
r`rarU�_generateMultiselectableStatercr;rrs    �rrz-SpeechGenerator._generateMultiselectableState�s_����&�&�(�3�3�4L�M��I���6�s�C�d�C����M�M�*�$�*�*�U�<��<�t�<�=��
r!c���tj�jd�rgStjj
||fi|��}|r(|j
|jtfd|i|���|Sr
)	r
r`rarr8�_generateRadioStatercr;rris    rrz#SpeechGenerator._generateRadioState�sg���&�&�(�3�3�4L�M��I��$�$�8�8��s�K�d�K����M�M�*�$�*�*�U�<��<�t�<�=��
r!c���tj�jd�rgStjj
||fi|��}|r(|j
|jtfd|i|���|S)z?Returns an array of strings indicating the on/off state of obj.r[rI)	r
r`rarr8�_generateSwitchStatercr;rris    rrz$SpeechGenerator._generateSwitchStatese���&�&�(�3�3�4L�M��I��$�$�9�9�$��L�t�L����M�M�*�$�*�*�U�<��<�t�<�=��
r!c���tj�jd�rgStjj
||fi|��}|r(|j
|jtfd|i|���|Sr
)	r
r`rarr8�_generateToggleStatercr;rris    rrz$SpeechGenerator._generateToggleStatesg���&�&�(�3�3�4L�M��I��$�$�9�9�$��L�t�L����M�M�*�$�*�*�U�<��<�t�<�=��
r!c�<�g}tj|�}|sv|j|j|��|j|j	|��|j|jjj|���nbtjj|�}|ddvr@|djd�}|jtj|d|dd�z�n�tj|dz}|jjj|�}t!j"|�}	|	stj|dz}ntj$|dz}|stj&|�}|r|d|zz
}|j|�t)j*|d�}
t!j,|
�r |j|j	|
��|r(|j|j.t0fd|i|���|S)	z�Returns an array of strings (and possibly voice and audio
        specifications) that represent the protocol of the URI of
        the link associated with obj.
        r)�ftp�ftps�file��/���)�urir"rPrI)r�get_link_urircrhr�rprlrm�
displayedText�urllib�parse�urlparse�splitr
�LINK_TO_FILE�LINK_WITH_PROTOCOLrr��LINK_WITH_PROTOCOL_VISITED�get_link_basenamer�	get_child�is_imager;rd)rrIrJrf�link_uri�
link_uri_info�fileName�
linkOutput�text�	isVisited�childs           r�_generateLinkInfoz!SpeechGenerator._generateLinkInfo%s���
��
�+�+�C�0���
�M�M�$�-�-�c�2�3��M�M�$�0�0��5�6��M�M�$�,�,�0�0�>�>�s�C�D�"�L�L�1�1�(�;�M��Q��#:�:�(��+�1�1�#�6���
�
�h�3�3�)6�q�)9�*2�2�,�!8�8�9�&�8�8�=��;K�K�
��|�|�-�-�;�;�C�@��'�2�2�3�7�	� �!)�!<�!<�}�Q�?O�!O�J�!)�!D�!D�}�UV�GW�!W�J��'�8�8��=�D���#��*�,�J��
�
�j�)� �*�*�3��2���'�'��.��M�M�$�"8�"8��"?�@���M�M�*�$�*�*�V�=��=��=�>��
r!c��|jjj|�sgStj|�}|sgSt
jj|�}tj|jjj��}|sgSg}t
jj|�}|d|dk(rK|d|dk(r |jtj�n�|jtj�n�|djd�}|djd�}	t!|�dkDrDt!|	�dkDr6|d|	dk(r+|d|	dk(r |jtj�n|jtj"�|r(|j%|j&t(fd|i|���|S)Nrr#�.r%���rI)rlrm�inDocumentContentrr'r)r*r+r�get_uri�
documentFramerpr
�LINK_SAME_PAGE�LINK_SAME_SITEr,r�LINK_DIFFERENT_SITErcr;rd)
rrIrJr3r4�doc_urirf�doc_uri_info�
linkdomain�	docdomains
          r�_generateSiteDescriptionz(SpeechGenerator._generateSiteDescriptionYs����|�|�%�%�7�7��<��I��+�+�C�0����I����-�-�h�7�
��$�$�T�\�\�%;�%;�%I�%I�%K�L����I����|�|�,�,�W�5�����|�A��.��Q��<��?�2��
�
�h�5�5�6��
�
�h�5�5�6�&�q�)�/�/��4�J�$�Q��-�-�c�2�I��:���"�s�9�~��'9��b�>�Y�r�]�2��b�>�Y�r�]�2��
�
�h�5�5�6��
�
�h�:�:�;���M�M�*�$�*�*�V�=��=��=�>��
r!c��g}d}tj|�}|s|S	tjj	|�}	|j�d}|r�t|�}|dkr%|jtj|��ng|dkr/|jtjt!|�dzz�n3|dk\r.|jtj"t!|�dzz�|r(|j%|j&t(fd|i|���|S#t$rY��wxYw#ttjjtf$rY��wxYw)z�Returns an array of strings (and possibly voice and audio
        specifications) that represent the size (Content-length) of
        the file pointed to by the URI of the link associated with
        obj.
        rOzContent-lengthi'i@Bg����MbP?g���ư>rI)rr'r)�request�urlopen�info�KeyError�
ValueError�error�URLError�OSError�intrpr
�
fileSizeBytes�FILE_SIZE_KB�float�FILE_SIZE_MBrcr;rd)rrIrJrf�
sizeStringr&rB�sizes        r�_generateFileSizez!SpeechGenerator._generateFileSize|s.�����
��&�&�s�+����M�	����&�&�s�+�A�
��V�V�X�&6�7�
�
��z�?�D��e�|��
�
�h�4�4�T�:�;�����
�
�h�3�3�u�T�{�T�7I�J�K�����
�
�h�3�3�u�T�{�W�7L�M�N���M�M�*�$�*�*�V�=��=��=�>��
���
��
���F�L�L�1�1�7�;�	��	�s.�D+�D�	D(�%D+�'D(�(D+�+(E�Ec��tj|�sgStjj|d<|j
|fi|��S)z�Returns an array of strings (and possibly voice and audio
        specifications) that represent the image on the object, if
        it exists.  Otherwise, an empty array is returned.
        rZ)r�supports_imagerr^�IMAGErD�rrIrJs   r�_generateImagezSpeechGenerator._generateImage�s@���&�&�s�+��I��z�z�'�'��V���t�}�}�S�)�D�)�)r!c���|jj�rgSt�|�|fi|��}|r(|j	|j
tfd|i|���|S�NrI)rl�inSayAllrU�_generateColumnHeaderrcr;rers    �rrbz%SpeechGenerator._generateColumnHeader�sU����<�<� � �"��I���.�s�;�d�;����M�M�*�$�*�*�W�>�#�>��>�?��
r!c���|jj�rgSt�|�|fi|��}|r(|j	|j
tfd|i|���|Sr`)rlrarU�_generateRowHeaderrcr;rers    �rrdz"SpeechGenerator._generateRowHeader�sU����<�<� � �"��I���+�C�8�4�8����M�M�*�$�*�*�W�>�#�>��>�?��
r!c�|��t�|�|fi|��}|r(|j|jtfd|i|���|Sr`)rU�_generateSortOrderrcr;rdrs    �rrfz"SpeechGenerator._generateSortOrder�s@�����+�C�8�4�8����M�M�*�$�*�*�V�=��=��=�>��
r!c��|jjj||jd��sgS|jd�rgSt	j
�j
d�sgSd|d<|j|fi|��S)a�Returns an array of strings (and possibly voice and audio
        specifications) that represent the row header for an object
        that is in a table, if it exists and if it is different from
        the previous row header.  Otherwise, an empty array is
        returned.  The previous row header is determined by looking at
        the row header for the 'priorObj' attribute of the args
        dictionary.  The 'priorObj' is typically set by Orca to be the
        previous object with focus.
        r��
readingRow�speakCellHeadersT�newOnly)rlrm�cellRowChangedr\r
r`rardr]s   r�_generateNewRowHeaderz%SpeechGenerator._generateNewRowHeader�s{���|�|�%�%�4�4�S�$�(�(�:�:N�O��I��8�8�L�!��I��*�*�,�7�7�8J�K��I���Y��&�t�&�&�s�3�d�3�3r!c��|jjj||jd��sgS|jd�rgSt	j
�j
d�sgSd|d<|j|fi|��S)aReturns an array of strings (and possibly voice and audio
        specifications) that represent the column header for an object
        that is in a table, if it exists and if it is different from
        the previous column header.  Otherwise, an empty array is
        returned.  The previous column header is determined by looking
        at the column header for the 'priorObj' attribute of the args
        dictionary.  The 'priorObj' is typically set by Orca to be the
        previous object with focus.
        r�rhriTrj)rlrm�cellColumnChangedr\r
r`rarbr]s   r�_generateNewColumnHeaderz(SpeechGenerator._generateNewColumnHeader�s{���|�|�%�%�7�7��T�X�X�j�=Q�R��I��8�8�L�!��I��*�*�,�7�7�8J�K��I���Y��)�t�)�)�#�6��6�6r!c���g}|jd|�}|j|j|fi|���|j||�|r|ds�t	j
�j
d�ro|jdd�s]|jd�dk7rI|jtj�|r(|j|jtfd|i|���|S)	ahOrca has a feature to automatically read an entire row of a table
        as the user arrows up/down the roles.  This leads to complexity in
        the code.  This method is used to return an array of strings
        (and possibly voice and audio specifications) for a single table
        cell itself.  The string, 'blank', is added for empty cells.
        �REAL_ROLE_TABLE_CELLr�speakBlankLinesrhF�
formatType�ancestorrI)
�
_overrideRolercrD�_restoreRoler
r`rar\rpr
�BLANKr;re)rrIrJrf�oldRoles     r�_generateRealTableCellz&SpeechGenerator._generateRealTableCell�s������$�$�%;�T�B���
�
�m�d�m�m�C�0�4�0�1����'�4�(��6�!�9��*�*�,�7�7�8I�J��8�8�L�%�0��x�x��%��3��M�M�(�.�.�)���
�
�j�d�j�j��B�c�B�T�B�C��
r!c�r�tj�jd�rgS|jd�rgS|sgSt	j
t	j|��sgStj|�rgStjg}|j|jtfd|i|���|S)Nr[r�rI)r
r`rar\r�supports_selectionrqrr�r�STATE_UNSELECTED_LIST_ITEMrcr;rris    r�$_generateUnselectedStateIfSelectablez4SpeechGenerator._generateUnselectedStateIfSelectables����&�&�(�3�3�4L�M��I��8�8�O�$��I���I��*�*�8�+>�+>�s�+C�D��I��"�"�3�'��I�#�>�>�?���
�
�j�d�j�j��8�C�8�4�8�9��
r!c��tj�jd�rgS|jd�rgS|sgSt	j
|�}t	j|�sgStj|�rgStj|�rgStj|�}|rT|jjj�\}}|dvrgS|jjj|�rBgStj |�r)||jjj#|�vrgSgSt$j&g}|j)|j*t,fd|i|���|S)ajReturns an array of strings (and possibly voice and audio
        specifications) if this is an icon within an layered pane or a
        table cell within a table or a tree table and the item is
        focused but not selected.  Otherwise, an empty array is
        returned.  [[[WDW - I wonder if this string should be moved to
        settings.py.]]]
        r[r�)�Left�RightrI)r
r`rar\rrqr{rr��is_textr�	get_tablerlrm�lastKeyAndModifiers�isLayoutOnly�is_layered_pane�selectedChildrenr�STATE_UNSELECTED_TABLE_CELLrcr;r)rrIrJru�table�lastKey�modsrfs        r�_generateUnselectedCellz'SpeechGenerator._generateUnselectedCell&sF���&�&�(�3�3�4L�M��I��8�8�O�$��I���I��$�$�S�)���*�*�6�2��I��"�"�3�'��I����s�#��I��!�!�#�&��� �L�L�2�2�F�F�H�M�G�T��+�+��	��|�|�%�%�2�2�5�9��	�
�
(�
(��
0��d�l�l�,�,�=�=�f�E�E��	��I�#�?�?�@���
�
�j�d�j�j��8�C�8�4�8�9��
r!c���|jjj|�sgS|jd�rgSt	j
�j
d�sgS|j|fi|��S�Nrh�speakCellCoordinates)rlrmrnr\r
r`ra�_generateColumnr]s   r�_generateNewColumnz"SpeechGenerator._generateNewColumnSse���|�|�%�%�7�7��<��I��8�8�L�!��I��*�*�,�7�7�8N�O��I�#�t�#�#�C�0�4�0�0r!c��tj�jd�rgStj|d��d}|dk(rgSt
j|dzzg}|j|jtfd|i|���|S)z�Returns an array of strings (and possibly voice and audio
        specifications) reflecting the column number of a cell.
        r[T��	find_cellrr%rI)
r
r`rar�get_cell_coordinatesr
�TABLE_COLUMNrcr;rd)rrIrJ�colrfs     rr�zSpeechGenerator._generateColumn_s����&�&�(�3�3�4L�M��I��*�*�3�$�?��B���"�9��I��'�'�3��7�3�4���
�
�j�d�j�j��9�S�9�D�9�:��
r!c���|jjj|�sgS|jd�rgSt	j
�j
d�sgS|j|fi|��Sr�)rlrmrkr\r
r`ra�_generateRowr]s   r�_generateNewRowzSpeechGenerator._generateNewRownse���|�|�%�%�4�4�S�9��I��8�8�L�!��I��*�*�,�7�7�8N�O��I� �t� � ��-��-�-r!c��tj�jd�rgStj|d��d}|dk(rgSt
j|dzzg}|j|jtfd|i|���|S)zReturns an array of strings (and possibly voice and audio
        specifications) reflecting the row number of a cell.
        r[Tr�rr%rrI)
r
r`rarr�r
�	TABLE_ROWrcr;rd)rrIrJ�rowrfs     rr�zSpeechGenerator._generateRowzs����&�&�(�3�3�4L�M��I��*�*�3�$�?��B���"�9��I��$�$��a��0�1���
�
�j�d�j�j��9�S�9�D�9�:��
r!c��tj�jd�rgStj|d��\}}|dk(s|dk(rgStj
|�}|�gSg}tj|�}tj|�}|jtj|dz|d�z�|jtj|dz|d�z�|j|jtfd|i|���|S)z�Returns an array of strings (and possibly voice and audio
        specifications) reflecting the position of the cell in terms
        of its column number, the total number of columns, its row,
        and the total number of rows.
        r[Tr�r%r��index�totalrI)r
r`rarr�r��
get_row_count�get_column_countrpr
�TABLE_COLUMN_DETAILED�TABLE_ROW_DETAILEDrcr;rd)	rrIrJr�r�r�rf�rows�columnss	         r�_generateColumnAndRowz%SpeechGenerator._generateColumnAndRow�s����&�&�(�3�3�4L�M��I��/�/��t�D���S��"�9��r�	��I��!�!�#�&���=��I����$�$�U�+���*�*�5�1���
�
�h�4�4�3��7�W^�7_�_�`��
�
�h�1�1��a��TX�4Y�Y�Z��
�
�j�d�j�j��9�S�9�D�9�:��
r!c�\�tj�jd�rgStj�jd�tjk7rgStj|�r;tjg}|j|jtfd|i|���|SgS)z�Returns an array of strings (and possibly voice and audio
        specifications) indicating that this cell is the last cell
        in the table.
        r[r�rI)r
r`rar�VERBOSITY_LEVEL_VERBOSEr�is_last_cellr
�	TABLE_ENDrcr;rdris    r�_generateEndOfTableIndicatorz,SpeechGenerator._generateEndOfTableIndicator�s���
�&�&�(�3�3�4L�M��I��&�&�(�3�3�4J�K��.�.�/��I�����$��(�(�)�F��M�M�*�$�*�*�V�=��=��=�>��M��	r!c��|jd�rtj|�rgS|j|fi|��}|r|dr|S|jj|�\}}}|dk(r�t
j�jd�rz|jj�s`|jdd�dk(rK|jd�dk7r7tjg}|j|jd||d	�|���|Sg}|t|�z}|jjj!|||�}|D�]\}	}
}}}
|j#|jj$d
�}|s�3||
c|d<|d<d
|vrNd|jd
��d|�d�}t'j(t&j*|d�|j-d
�|jd||d	�|��}|jjj/|||	�}|jjj1|�g}|j|�|j|���|S)z�Returns an array of strings for use by speech and braille
        that represents the current line of text, if
        this is a text object.  [[[WDW - consider returning an empty
        array if this is not a text object.]]]
        r�r�
rrr�rrsrt)�stringrIrO�language�dialectr�zINFO: Found existing string 'z
'; using '�'Tr)r\r�is_editable�_generateSubstringrl�getTextLineAtCaretr
r`rarar
rwrcr;rrm�splitSubstringByLanguage�replace�EMBEDDED_OBJECT_CHARACTERr�printMessagerHr��adjustForLinks�adjustForRepeats)rrIrJrfr7�caretOffsetr�r�r,�start�endr�r�r��msgr;rKs                 r�_generateCurrentLineTextz(SpeechGenerator._generateCurrentLineText�s+���8�8�O�$��&�&�s�+��I�(��(�(��5��5���f�Q�i��M�+/�<�<�+J�+J�3�+O�(��{�K��4�<�,�7�7�9�D�D�EV�W��<�<�(�(�*�t�x�x���/C�q�/H��x�x��%��3��n�n�%�F��M�M�*�$�*�*�B�D�c�B�T�B�C��M����#�d�)�+�	����&�&�?�?��[�R[�\��5:�	�1�E�3���'��^�^�D�L�L�$J�$J�B�O�F���08�'�-�D���d�9�o��4��5�d�h�h�x�6H�5I��TZ�S[�[\�]���"�"�5�#3�#3�S�$�?�����"��D�J�J�>�f�#�>��>�E��\�\�+�+�:�:�3���N�F��,�,�(�(�9�9�&�A�B�B��I�I�e��
�M�M�"��'	�*�
r!c��|j|fi|��}|r|dr|Stjj||fi|��}|r|dsgS|dj	�}t|�dk(rD|jjj|�rtj|�}||k7r||d<|j|jtfd|i|���|S)NrrrI)r�rr8�_generateDisplayedText�striprrlrmrr	rrcr;re)rrIrJrfr�rs      rr�z&SpeechGenerator._generateDisplayedText�s���(��(�(��5��5���f�Q�i��M��$�$�;�;�D�#�N��N���6�!�9��I������"���v�;�!����� 6� 6� =� =�c� B�"�3�3�F�;�H��6�!�$��q�	��
�
�j�d�j�j��:�c�:�T�:�;��
r!c�x�	|jjdS#t$rYnwxYw|jjj	|�\}}}|dk7}|sbtj|�\}}}|r(|jjj|�}|}ntj|�d}|dk(r|}|jjj|�r%|jjj|�}||||g|jjd<|jjdS)a�Returns [textContents, startOffset, endOffset, selected] as
        follows:

        A. if no text on the current line is selected, the current line
        B. if text is selected, the selected text
        C. if the current line is blank/empty, 'blank'

        Also sets up a 'textInformation' attribute in
        self._script.generatorCache to prevent computing this
        information repeatedly while processing a single event.
        �textInformationrOrr�)rl�generatorCacher�rm�allSelectedTextr�get_line_at_offsetr��get_character_at_offset�shouldVerbalizeAllPunctuation�verbalizeAllPunctuation)rrI�textContentsr�r��selected�line�chars        r�_getTextInformationz#SpeechGenerator._getTextInformation�s'��	��<�<�.�.�/@�A�A���	��	��04�|�|�/E�/E�/U�/U�VY�/Z�,��k�9��2�%���+1�+D�+D�S�+I�(�D�+�y���|�|�-�-�>�>�t�D��#���5�5�c�:�1�=���4�<�#'�L��<�<�!�!�?�?��D��<�<�1�1�I�I�,�W�L��;�	�8�<�	
���#�#�$5�6��|�|�*�*�+<�=�=s��	'�'c��|j|fi|��}|r|S|j|�d}|sgS|g}|j|jtfd|i|���|S)z�Returns an array of strings (and possibly voice and audio
        specifications) containing the text content.  This requires
        _generateTextInformation to have been called prior to this method.
        rrI)r�r�rcr;re)rrIrJrfr�s     r�_generateTextContentz$SpeechGenerator._generateTextContent&sm��)��(�(��5��5����M��'�'��,�Q�/����I�����
�
�j�d�j�j��:�c�:�T�:�;��
r!)�style�weight�	underlinec�&�tj||�\}}}|syd}|D]�}|j|�}	|	s�tj||j
�}
tj|	|j
�}|dk(r&t
|	�dkDs�k|dtj��z
}��|dk(r|	dk7s��|d|
��z
}��|dk(r|	dk7s��|d|��z
}��|dz
}||
dz|zz
}��tj|||d	z�r|dtj��z
}|||fS)
NrOr�i�rPr��noner��normalr)r�get_text_attributes_at_offsetr\r�getTextAttributeNamerlrRr
�BOLDr�get_all_links_in_ranger�)rrI�offset�keys�attrsr�r�rf�key�	attribute�localizedKey�localizedValues            r�_getAttributesStringAndOffsetsz.SpeechGenerator._getAttributesStringAndOffsets8s:��"�@�@��f�M���u�c������	@�C��	�	�#��I���/�D�D�S�$�,�,�W�L�1�F�F�y�RV�R^�R^�_�N��h���y�>�C�'���(�-�-��1�1�F���#���&���,��0�0�F������(���.�!1�2�2�F��#�
���<�#�-��>�?��%	@�(�-�-�c�6�6�A�:�F���(�-�-��)�)�F��u�c�!�!r!c	�X�|j|�\}}}}d}|}||kr>|j||�\}	}
}|d|	�dtj||
|���z
}|}||kr�>|j||dg�d}	|	r|d|	��z
}|g}|j	|j
tfd|i|���|S)a;Returns an array of strings (and possibly voice and audio
        specifications) containing the text content, obtained from the
        'textInformation' value, with character attribute information
        mixed in.  This requires _generateTextInformation to have been
        called prior to this method.
        rOrPzparagraph-stylerrI)r�r�r�
get_substringrcr;re)
rrIrJr�r�r�r��newLine�
textOffset�attribsr�r�rfs
             r�"_generateTextContentWithAttributesz2SpeechGenerator._generateTextContentWithAttributesWs���48�3K�3K�C�3P�0��{�I�x��� �
��9�$�"&�"E�"E�c�:�"V��G�U�C���7�)�1�V�%9�%9�#�u�c�%J�$K�L�L�G��J��9�$�
�5�5�c�;�IZ�H[�\�]^�_�����7�)�}�$�G�����
�
�j�d�j�j��:�c�:�T�:�;��
r!c���tj�jd�rgStj|�sgSt
jg}|j|jtfd|i|���|S)z�Returns an array of strings (and possibly voice and audio
        specifications) that says if any of the text for the entire
        object is selected. [[[WDW - I wonder if this string should be
        moved to settings.py.]]]
        r[rI)
r
r`rar�has_selected_textr
�
TEXT_SELECTEDrcr;rdris    r�_generateAnyTextSelectionz)SpeechGenerator._generateAnyTextSelectionosh���&�&�(�3�3�4L�M��I��'�'��,��I��(�(�)���
�
�j�d�j�j��9�S�9�D�9�:��
r!c���tj�jd�rgStj|�sgSt
jg}|j|jtfd|i|���|S)z�Returns an array of strings (and possibly voice and audio
        specifications) that says if all the text for the entire
        object is selected. [[[WDW - I wonder if this string should be
        moved to settings.py.]]]
        r[rI)
r
r`rar�is_all_text_selectedr
r�rcr;rdris    r�_generateAllTextSelectionz)SpeechGenerator._generateAllTextSelectionsh���&�&�(�3�3�4L�M��I��*�*�3�/��I��(�(�)���
�
�j�d�j�j��9�S�9�D�9�:��
r!c�*��t�|�|fi|��}|r|dsgS|j|jtfd|i|���|ddvrytj�jd�rV|jj�s<|jdd�dk(r'|jd�dk7rtj|d<|jjj|�r+|jjj|d�|d<|S)	NrrI)r�rOrrr�rrsrt)rUr�rcr;rer
r`rarlrar\r
rwrmr�r�rs    �rr�z"SpeechGenerator._generateSubstring�s������+�C�8�4�8���6�!�9��I��
�
�j�d�j�j��:�c�:�T�:�;��!�9�
�"�'7�'B�'B�'D�'O�'O�Pa�'b��<�<�(�(�*�t�x�x���/C�q�/H��x�x��%��3� ���F�1�I��<�<�!�!�?�?��D����.�.�F�F�v�a�y�Q�F�1�I��
r!c�6�tj�jd�sgS|jj	|�\}}}|jj
j
|�}|sgS|g}|j|jtfd|i|���|S)z�Speaks a summary of the number of spaces and/or tabs at the
        beginning of the given line.

        Arguments:
        - obj: the text object.
        �enableSpeechIndentationrI)
r
r`rarlr�rm�indentationDescriptionrcr;rd)rrIrJr�r�r��descriptionrfs        r�_generateTextIndentationz(SpeechGenerator._generateTextIndentation�s��� �*�*�,�7�7�8Q�R��I�)-���)H�)H��)M�&��k�;��l�l�,�,�C�C�D�I����I�����
�
�j�d�j�j��9�S�9�D�9�:��
r!c�|��t�|�|fi|��}|r(|j|jtfd|i|���|Sr`)rU�_generateNestingLevelrcr;rdrs    �rr�z%SpeechGenerator._generateNestingLevel�s@�����.�s�;�d�;����M�M�*�$�*�*�V�=��=��=�>��
r!c��tj�jd�rgSg}|jjj|j
dd��}|jjj|�}||k7rO|dk\rJ|j|j|fi|���|j|jtfd|i|���|S)a�Returns an array of strings (and possibly voice and audio
        specifications) that represents the tree node level of the
        object, or an empty array if the object is not a tree node or
        if the node level is not different from the 'priorObj'
        'priorObj' attribute of the args dictionary.  The 'priorObj'
        is typically set by Orca to be the previous object with
        focus.
        r[r�NrrI)r
r`rarlrm�	nodeLevelr\rc�_generateNodeLevelr;rd)rrIrJrf�oldLevel�newLevels      r�_generateNewNodeLevelz%SpeechGenerator._generateNewNodeLevel�s����&�&�(�3�3�4L�M��I����<�<�)�)�3�3�D�H�H�Z��4N�O���<�<�)�)�3�3�C�8���� �x�1�}��M�M�1�$�1�1�#�>��>�?��M�M�*�$�*�*�V�=��=��=�>��
r!c�|��t�|�|fi|��}|r(|j|jtfd|i|���|Sr`)rU�_generateValuercr;rers    �rrzSpeechGenerator._generateValue�s@�����'��4�t�4����M�M�*�$�*�*�W�>�#�>��>�?��
r!c��tj�jd�rgStj|�}|�@tj|�g}|j|jtfd|i|���|SgS)aReturns an array of strings (and possibly voice and audio
        specifications) that represents the percentage value of the
        object.  This is typically for progress bars. [[[WDW - we
        should consider returning an empty array if there is no value.
        r[rI)
r
r`rar�get_value_as_percentr
�
percentagercr;rd)rrIrJ�percentValuerfs     r�_generatePercentagez#SpeechGenerator._generatePercentage�su���&�&�(�3�3�4L�M��I��3�3�C�8���#��)�)�,�7�8�F��M�M�*�$�*�*�V�=��=��=�>��M��	r!c�h��tj|�sgSt�|�|fi|��}|sgS|j	|j
tfd|i|���|jdd�}tj|�s|Stj|tjj�}||vr|SgS)a�Returns an array of strings (and possibly voice and audio
        specifications) that represents the radio button group label
        of the object, or an empty array if the object has no such
        label or if the radio button group is not different from the
        'priorObj' 'priorObj' attribute of the args dictionary.  The
        'priorObj' is typically set by Orca to be the previous object
        with focus.
        rIr�N)
r�is_radio_buttonrU�_generateRadioButtonGrouprcr;rer\r�get_relation_targetsr�RelationType�	MEMBER_OF)rrIrJrfr��membersrXs      �r�_generateNewRadioButtonGroupz,SpeechGenerator._generateNewRadioButtonGroup�s�����*�*�3�/��I���2�3�?�$�?����I��
�
�j�d�j�j��:�c�:�T�:�;��8�8�J��-���*�*�8�4��M��/�/��U�5G�5G�5Q�5Q�R���7�"��M��	r!c���|jjj|�}|dvrgStj|�g}|j|jtfd|i|���|S)N)r%rrI)rlrm�getValueCountForTermr
�valueCountForTermrcr;rd)rrIrJ�countrfs     r�_generateTermValueCountz'SpeechGenerator._generateTermValueCountsb�����&�&�;�;�C�@���G���I��,�,�U�3�4���
�
�j�d�j�j��9�S�9�D�9�:��
r!c�x�tj�jd�s4tj�jd�tjk(rgSg}|j
jj|�}t|�}|rN|jtj|��|j|jtfd|i|���|S|jdt!j"|��}|t$j&j(t$j&j*fvr~t!j,|t.j0�D�cgc]}|��}}t|�}|sgStj2|�g}|j|jtfd|i|���|Scc}w)a5Returns an array of strings (and possibly voice and audio
        specifications) that represents the number of children the
        object has.  [[[WDW - can we always return an empty array if
        this doesn't apply?]]] [[[WDW - I wonder if this string should
        be moved to settings.py.]]]
        r[r�rIrZ)r
r`rarr�rlrm�
childNodesrrpr
�	itemCountrcr;rdr\rr]rr^�LIST�LIST_BOX�
iter_childrenr�is_list_item�
listItemCount)	rrIrJrfr�childrenrZrB�setsizes	         r�_generateNumberOfChildrenz)SpeechGenerator._generateNumberOfChildren s_���&�&�(�3�3�4L�M��)�)�+�6�6�7M�N��0�0�1��I����\�\�+�+�6�6�s�;�
��z�?����M�M�(�,�,�X�6�7��M�M�*�$�*�*�V�=��=��=�>��M��x�x��� 1� 1�#� 6�7���E�J�J�O�O�U�Z�Z�%8�%8�9�9�#+�#9�#9�#�{�?W�?W�#X�Y�a��Y�H�Y��(�m�G���	��,�,�W�5�6�F��M�M�*�$�*�*�V�=��=��=�>��
��Zs�	F7c�N�tj�jd�rgSg}td�t	j
|tj�D��}|sG|jtj�|j|jtfd|i|���|S)ahReturns an array of strings (and possibly voice and audio
        specifications) that says if this object has no showing
        children (e.g., it's an empty table or list).  object has.
        [[[WDW - can we always return an empty array if this doesn't
        apply?]]] [[[WDW - I wonder if this string should be moved to
        settings.py.]]]
        r[c3� K�|]}d���y�w)TNr)�.0�_s  r�	<genexpr>z=SpeechGenerator._generateNoShowingChildren.<locals>.<genexpr>Ms����Y��t�Y�s�rI)r
r`ra�anyrrr�
is_showingrpr
�
ZERO_ITEMSrcr;rd)rrIrJrf�hasItemss     r�_generateNoShowingChildrenz*SpeechGenerator._generateNoShowingChildrenAs����&�&�(�3�3�4L�M��I����Y�X�%;�%;�C��AW�AW�%X�Y�Y����M�M�(�-�-�.��M�M�*�$�*�*�V�=��=��=�>��
r!c��tj�jd�rgSg}tj|�sG|jtj�|j|jtfd|i|���|S)ahReturns an array of strings (and possibly voice and audio
        specifications) that says if this object has no children at
        all (e.g., it's an empty table or list).  object has.  [[[WDW
        - can we always return an empty array if this doesn't
        apply?]]] [[[WDW - I wonder if this string should be moved to
        settings.py.]]]
        r[rI)r
r`rar�get_child_countrpr
r&rcr;rdris    r�_generateNoChildrenz#SpeechGenerator._generateNoChildrenSsl���&�&�(�3�3�4L�M��I����'�'��,��M�M�(�-�-�.��M�M�*�$�*�*�V�=��=��=�>��
r!c���g}|jdtj|��}|tjj
tjjfvr|Stj|�r&|jjj|�}ntj|�g}|r|ds|St|j|�D]}|j|��|S)NrZr)r\rr]rr^rrr{rlrmr�r�get_focused_object�maprbrc)rrIrJrfrZ�items�items       r�_generateFocusedItemz$SpeechGenerator._generateFocusedItemds������x�x��� 1� 1�#� 6�7����
�
������)<�)<�=�=��M��&�&�s�+��L�L�*�*�;�;�C�@�E� �3�3�C�8�9�E��%��(��M���*�*�E�2�	 �D��M�M�$��	 ��
r!c���tj�jd�rgS|}tj|�s,tj
|�}tj|�sgSg}tj|�}t|jjj|��}|jtj||��|j|jt fd|i|���|j|jj"j%dd��tj&|�dz|d�z�|j|jt fd|i|���|S)z�Returns an array of strings (and possibly voice and audio
        specifications) indicating how many items are selected in this
        and the position of the current item. This object will be an icon
        panel or a layered pane.
        r[rIr�	iconindex�r��
stringTyperr�)r
r`rarr{rqr*rrlrmr�rpr
�selectedItemsCountrcr;rd�
formatting�	getString�get_index_in_parent)rrIrJr�rf�
childCount�
selectedCounts       r�_generateSelectedItemCountz*SpeechGenerator._generateSelectedItemCountvs=���&�&�(�3�3�4L�M��I��	��*�*�9�5� �+�+�C�0�I��.�.�y�9��	����-�-�i�8�
��D�L�L�2�2�C�C�I�N�O�
��
�
�h�1�1�-��L�M��
�
�j�d�j�j��9�S�9�D�9�:��
�
�d�l�l�-�-�7�7�'�%0�8�2�$,�#?�#?��#D�q�#H�#-�/�/�	0�
	�
�
�j�d�j�j��9�S�9�D�9�:��
r!c�Z�tj�jd�rgS|}tj|�s,tj
|�}tj|�sgS|jjj|�}tt|j|��S)z�Returns an array of strings (and possibly voice and audio
        specifications) containing the names of all the selected items.
        This object will be an icon panel or a layered pane.
        r[)r
r`rarr{rqrlrmr�rEr.�_generateLabelAndName)rrIrJr��
selectedItemss     r�_generateSelectedItemsz&SpeechGenerator._generateSelectedItems�s����&�&�(�3�3�4L�M��I��	��*�*�9�5� �+�+�C�0�I��.�.�y�9��	����.�.�?�?�	�J�
��C��2�2�M�B�C�Cr!c�(�|j|fi|��Sr)r@r]s   r�generateSelectedItemsz%SpeechGenerator.generateSelectedItems�s��*�t�*�*�3�7�$�7�7r!c�d�tj�jd�rgSg}	|jjj|�}|dkDrL|jtj|��|j|jtfd|i|���|S#t$rd}Y�`wxYw)aReturns an array of strings (and possibly voice and audio
        specifications) that says how many unfocused alerts and
        dialogs are associated with the application for this object.
        [[[WDW - I wonder if this string should be moved to
        settings.py.]]]
        r[rrI)
r
r`rarlrm�unfocusedAlertAndDialogCountr�rpr
�dialogCountSpeechrcr;rd)rrIrJrf�alertAndDialogCounts     r�_generateUnfocusedDialogCountz-SpeechGenerator._generateUnfocusedDialogCount�s����&�&�(�3�3�4L�M��I���
	$����&�&�C�C�C�H�
 ���"��M�M�(�4�4�5H�I�J��M�M�*�$�*�*�V�=��=��=�>��
���	$�"#��	$�s�%B!�!B/�.B/c��
�tjjddddddtjjdtjjtjj
tjjtjjdtjjtjjg}gg}}|jj��r&tj�jd	�r)|jtjj�tj�jd
�r+|j!tjj
dg�tj�jd�rc|jtjj�|jtjj�|jd�tj�jd�rH|j!tjjtjjdddddg�tj�jd
�r)|jtjj�tj�jd��rO|jtjj��n$tj�jd�r)|jtjj�tj�jd�r,|j!tjj
ddg�tj�jd�rc|jtjj�|jtjj�|jd�tj�jd�rH|j!tjjtjjdddddg�tj�jd�r)|jtjj�tj�jd�r)|jtjj�t#t%|�j'|��}||fS)N�ROLE_CONTENT_DELETION�ROLE_CONTENT_INSERTION�ROLE_CONTENT_MARKr��ROLE_DPUB_LANDMARK�ROLE_DPUB_SECTION�	ROLE_FEED�ROLE_REGION�sayAllContextBlockquote�sayAllContextLandmark�sayAllContextList�sayAllContextPanel�sayAllContextNonLandmarkForm�sayAllContextTable�speakContextBlockquote�speakContextLandmark�speakContextList�speakContextPanel�speakContextNonLandmarkForm�speakContextTable)rr^�BLOCK_QUOTE�DESCRIPTION_LIST�FORM�LANDMARKrr��TABLE�TOOL_TIPrlrar
r`rarprcrE�set�symmetric_difference)r�allRolesr�r�s    rr�z2SpeechGenerator._getEnabledAndDisabledContextRoles�s����J�J�*�*�+�,�'�-�(�'��J�J�/�/���J�J�O�O��J�J�'�'��J�J�O�O��J�J�$�$�!��J�J�$�$��J�J�'�'�)��"�����<�<� � �"��*�*�,�7�7�8Q�R����u�z�z�5�5�6��*�*�,�7�7�8O�P�����
�
� 3� 3�5I�J�K��*�*�,�7�7�8K�L����u�z�z���/����u�z�z�:�:�;����{�+��*�*�,�7�7�8L�M�����
�
� 0� 0� %�
�
� 3� 3� 7� 8� 3� 9� 3�
 5�6� �*�*�,�7�7�8V�W����u�z�z���/��*�*�,�7�7�8L�M����u�z�z�/�/�0��*�*�,�7�7�8P�Q����u�z�z�5�5�6��*�*�,�7�7�8N�O�����
�
� 3� 3�5I�=�Y�Z��*�*�,�7�7�8J�K����u�z�z���/����u�z�z�:�:�;����{�+��*�*�,�7�7�8K�L�����
�
� 0� 0� %�
�
� 3� 3� 7� 8� 3� 9� 3�
 5�6� �*�*�,�7�7�8U�V����u�z�z���/��*�*�,�7�7�8K�L����u�z�z�/�/�0���H�
�:�:�7�C�D���� � r!c��|jd�sgS|jdtj|��}|j�\}}||vs'|jj
j
|�sgS|jdd�}g}|jj
j
|�r!|jtj��
nH|tjjk(rL|dkDr&|jtj|���
n|jtj��n�|tjjtjj fvrq|jj
j#|�rL|dkDr&|jtj$|���nY|jtj&��n8|dk(r!|jtj(��n|tjj*k(r�|jj
j-|�r!|jtj.��n�|jj
j1|�r!|jtj2��nidg}�nd|tjj4k(rF|jj
j7|�r!|jtj8��n|dk(�r3|jj
j;|�r!|jtj<��
n�|jj
j?|�r!|jtj@��
no|jj
jC|�r!|jtjD��
n)|jj
jG|�r!|jtjH��	n�|jj
jK|�r!|jtjL��	n�|jj
jO|�r!|jtjP��	nW|jj
jS|�r!|jtjT��	n|jj
jW|�r!|jtjX��n�|jj
j[|�r!|jtj\��n�|jj
j_|�r!|jtj`��n?|jj
jc|�r!|jtjd��n�|jj
jg|�r!|jtjh��n�|jj
jk|�r!|jtjl��nm|jj
jo|�r!|jtjp��n'|jj
js|�r!|jtjt��n�|jj
jw|�r!|jtjx��n�|jj
j{|�r!|jtj|��nU|jj
j|�r!|jtj���n|jj
j�|��r�|jtj���n�|dk(�r1|jj
j�|�r!|jtj���n||jj
j�|�r!|jtj���n6|jj
j�|�r!|jtj���n�|jj
j�|�r!|jtj���n�|jj
j�|�r!|jtj���nd|jj
j�|�r!|jtj���n|jj
j�|�r!|jtj���n�|jj
j�|��r�|jtj���n�|jj
j�|��r5|jj
j�|�r!|jtj���n%|jj
j�|�r!|jtj���n�|jj
j�|�r!|jtj���n�|jj
j�|�r!|jtj���nS|jj
j�|�r!|jtj���n
|jj
j�|�r!|jtj���n�|jj
j�|�r!|jtj���n�|jj
j�|�r!|jtj���n;dg}�n6|tjj�k(r |jtj��n�|tjj�k(r |jtj��n�|d	k(r |jtj��n�|d
k(r |jtj��nr|dk(r |jtj��nM|dk(rE|jj
j�|�s |jtj��ndg}|r(|j�|j�t�fd
|i|���|S)Nr�rZrrrNrOrLrMrIrJrKr�rI)or\rr]r�rlrm�	isDetailsrpr
�LEAVING_DETAILSrr^r\�leavingNBlockquotes�LEAVING_BLOCKQUOTErr]�isDocumentList�
leavingNLists�LEAVING_LIST�LEAVING_FEEDr��isFigure�LEAVING_FIGURE�isDocumentPanel�
LEAVING_PANELr`r��
LEAVING_TABLE�isDPubAcknowledgments�LEAVING_ACKNOWLEDGMENTS�isDPubAfterword�LEAVING_AFTERWORD�isDPubAppendix�LEAVING_APPENDIX�isDPubBibliography�LEAVING_BIBLIOGRAPHY�
isDPubChapter�LEAVING_CHAPTER�isDPubConclusion�LEAVING_CONCLUSION�
isDPubCredits�LEAVING_CREDITS�isDPubEndnotes�LEAVING_ENDNOTES�isDPubEpilogue�LEAVING_EPILOGUE�isDPubErrata�LEAVING_ERRATA�isDPubForeword�LEAVING_FOREWORD�isDPubGlossary�LEAVING_GLOSSARY�isDPubIndex�
LEAVING_INDEX�isDPubIntroduction�LEAVING_INTRODUCTION�isDPubPagelist�LEAVING_PAGELIST�
isDPubPart�LEAVING_PART�
isDPubPreface�LEAVING_PREFACE�isDPubPrologue�LEAVING_PROLOGUE�	isDPubToc�LEAVING_TOC�isDPubAbstract�LEAVING_ABSTRACT�isDPubColophon�LEAVING_COLOPHON�isDPubCredit�LEAVING_CREDIT�isDPubDedication�LEAVING_DEDICATION�isDPubEpigraph�LEAVING_EPIGRAPH�
isDPubExample�LEAVING_EXAMPLE�isDPubPullquote�LEAVING_PULLQUOTE�	isDPubQna�LEAVING_QNA�
isLandmark�isLandmarkBanner�LEAVING_LANDMARK_BANNER�isLandmarkComplementary�LEAVING_LANDMARK_COMPLEMENTARY�isLandmarkContentInfo�LEAVING_LANDMARK_CONTENTINFO�isLandmarkMain�LEAVING_LANDMARK_MAIN�isLandmarkNavigation�LEAVING_LANDMARK_NAVIGATION�isLandmarkRegion�LEAVING_LANDMARK_REGION�isLandmarkSearch�LEAVING_LANDMARK_SEARCH�isLandmarkForm�LEAVING_FORMr^ra�LEAVING_TOOL_TIPr�r�r��isInlineSuggestion�LEAVING_SUGGESTIONrcr;rd)rrIrJrZr�r�rrfs        r�_generateLeavingz SpeechGenerator._generateLeavings����x�x�	�"��I��x�x��� 1� 1�#� 6�7�� �C�C�E�������4�<�<�#9�#9�#C�#C�C�#H��I�����!�$�����<�<�!�!�+�+�C�0��M�M�(�2�2�3�
�U�Z�Z�+�+�
+��q�y��
�
�h�:�:�5�A�B��
�
�h�9�9�:�
�e�j�j�o�o�u�z�z�'B�'B�C�
C����&�&�5�5�c�:��q�y��
�
�h�4�4�U�;�<��
�
�h�3�3�4�
�[�
 ��M�M�(�/�/�0�
�U�Z�Z�%�%�
%��|�|�%�%�.�.�s�3��
�
�h�5�5�6����'�'�7�7��<��
�
�h�4�4�5����
�U�Z�Z�%�%�
%�$�,�,�*@�*@�*T�*T�UX�*Y��M�M�(�0�0�1�
�)�
)��|�|�%�%�;�;�C�@��
�
�h�>�>�?����'�'�7�7��<��
�
�h�8�8�9����'�'�6�6�s�;��
�
�h�7�7�8����'�'�:�:�3�?��
�
�h�;�;�<����'�'�5�5�c�:��
�
�h�6�6�7����'�'�8�8��=��
�
�h�9�9�:����'�'�5�5�c�:��
�
�h�6�6�7����'�'�6�6�s�;��
�
�h�7�7�8����'�'�6�6�s�;��
�
�h�7�7�8����'�'�4�4�S�9��
�
�h�5�5�6����'�'�6�6�s�;��
�
�h�7�7�8����'�'�6�6�s�;��
�
�h�7�7�8����'�'�3�3�C�8��
�
�h�4�4�5����'�'�:�:�3�?��
�
�h�;�;�<����'�'�6�6�s�;��
�
�h�7�7�8����'�'�2�2�3�7��
�
�h�3�3�4����'�'�5�5�c�:��
�
�h�6�6�7����'�'�6�6�s�;��
�
�h�7�7�8����'�'�1�1�#�6��
�
�h�2�2�3�
�(�
(��|�|�%�%�4�4�S�9��
�
�h�7�7�8����'�'�6�6�s�;��
�
�h�7�7�8����'�'�4�4�S�9��
�
�h�5�5�6����'�'�8�8��=��
�
�h�9�9�:����'�'�6�6�s�;��
�
�h�7�7�8����'�'�5�5�c�:��
�
�h�6�6�7����'�'�7�7��<��
�
�h�8�8�9����'�'�1�1�#�6��
�
�h�2�2�3�
�\�\�
#�
#�
.�
.�s�
3��|�|�%�%�6�6�s�;��
�
�h�>�>�?����'�'�?�?��D��
�
�h�E�E�F����'�'�=�=�c�B��
�
�h�C�C�D����'�'�6�6�s�;��
�
�h�<�<�=����'�'�<�<�S�A��
�
�h�B�B�C����'�'�8�8��=��
�
�h�>�>�?����'�'�8�8��=��
�
�h�>�>�?����'�'�6�6�s�;��
�
�h�3�3�4����
�U�Z�Z�_�_�
$��M�M�(�/�/�0�
�U�Z�Z�(�(�
(��M�M�(�3�3�4�
�,�
,��M�M�(�7�7�8�
�-�
-��M�M�(�8�8�9�
�(�
(��M�M�(�3�3�4�
�.�
.��\�\�+�+�>�>�s�C��M�M�(�5�5�6��T�F���M�M�*�$�*�*�V�=��=��=�>��
r!c�<	���g}|jd�}|r%|jd�r|}|jd�}n|jd�}|rtj|�rgStj|�rgS|r-tj
|�tj
|�k(rgS�jjj|�rgStj|�rgStj|�rgS�jjj||�}||k(rgS|jdg�}|jdg�}|jtjj��j�\}	}
|j!|
�|jdg�}|j!tjj"tjj$g�|jdg�}|j!tjj&g�tjj(tjj*g}
d}|r�|s��j-|���|
vr���fd�}tj.||�}tj.||�}�jjj1|�}�jjj1|�}||k7}gg}}tj2|�}|rމj-|�}||vrn�||vr&�jjj5|�sn||r||vrnu�jjj7|�rnO�jjj9|�rn)||k7s|r"|j|�|j|�||k(s||vrntj2|�}|r��g}t;|�D]�\}}||}||
vr||vr�|j|�|j=|�}�j?||�|j�jA|d	|||||�
���jC||���|s|jE�|S)aEReturns an array of strings (and possibly voice and audio
        specifications) that represent the text of the ancestors for
        the object.  This is typically used to present the context for
        an object (e.g., the names of the window, the panels, etc.,
        that the object is contained in).  If the 'priorObj' attribute
        of the args dictionary is set, only the differences in
        ancestry between the 'priorObj' and the current obj will be
        computed.  The 'priorObj' is typically set by Orca to be the
        previous object with focus.
        r�r��includeOnly�	skipRoles�stopAtRoles�stopAfterRolesFc�,���j|��k(Sr)�_getAlternativeRole)rB�
commonRolers ��r�predz0SpeechGenerator._generateAncestors.<locals>.pred�s����3�3�A�6�*�D�Dr!rt)rsrZr�r�
ancestorOfr�)#r\r�is_deadrr�rqrlrm�isTypeahead�is_page_tab�commonAncestorrprr^�	TREE_ITEMr�rc�APPLICATION�MENU_BARrar\rr�r��nestingLevel�get_parent_checked�isSpreadSheetTabler��isButtonWithPopup�	enumeraterrurDrv�reverse)rrIrJrfr�r�r�r�r�r�r�r�r��presentOnce�presentCommonAncestorr��objAncestor�
priorAncestor�objLevel�
priorLevel�	ancestors�
ancestorRolesru�
parentRole�presentedRoles�irB�altRolerr�s`                            @r�_generateAncestorsz"SpeechGenerator._generateAncestors�s������(�(�9�%���t�x�x�
�+��h��H�H�Z�(�c����*�-�h���(�(��2��I��"�"�8�,��I���+�+�H�5��9L�9L�S�9Q�Q��I��<�<�!�!�-�-�h�7��I��"�"�3�'��I��"�"�3�'��I����/�/�>�>�x��M���.� ��I��h�h�}�b�1���H�H�[�"�-�	�������-�-�.� �C�C�E��������"��h�h�}�b�1�����E�J�J�2�2�E�J�J�4G�4G�H�I����"2�B�7�����u�z�z�2�2�3�4��z�z�-�-�u�z�z���?�� %���'��1�1�.�A�J��[�(�E�&�4�4�S�$�?�� (� 6� 6�x�� F�
��<�<�1�1�>�>�{�K��!�\�\�3�3�@�@��O�
�(0�J�(>�%�#%�r�=�	��,�,�S�1����1�1�&�9�J��[�(���Y�&�t�|�|�/E�/E�/X�/X�Y_�/`����;�!>�����'�'�4�4�V�<�����'�'�9�9�&�A���>�)�-B�� � ��(��$�$�Z�0���'�:��+G���0�0��8�F�+�.���i�(�	-�D�A�q�#�A�&�G��+�%�'�^�*C���!�!�'�*�!�'�'��0�E����w��-��M�M��
�
�a�J�W�&-�U�s�U]��_�
`�
���g�t�,�	-���N�N���
r!c�J��tj�jd�rgS|jjj�rgS|j
d���r|�k(stj��sgStj|�rgStj|�tj��k7stj|�fd��rgS|jjj|�\}}|rgSd|d<tjj tjj"tjj$tjj&dddd	d
ddtjj(tjj*d
tjj,tjj.g|d<g}|jjj1��rY|j3��}|j5||�|j7|j9�|dd���|j;||�|j7|j<|fi|���|j?d�|j?d�|S)z�Returns an array of strings (and possibly voice and audio
        specifications) that represent the text of the ancestors for
        the object being left.r[r�c���|�k(Srr)rBr�s �rrCz7SpeechGenerator._generateOldAncestors.<locals>.<lambda>s���A��M�r!Tr�rIrJrKr�rLrMrNrOr��focused)rZrsr�) r
r`rarlrm�inFindContainerr\r�is_validrr��get_applicationr��frameAndDialogrr^r\r]r^r_rr�r`ra�isBlockquoter�rurcrDrvr�r�)rrIrJ�frame�dialogrfrxr�s       @r�_generateOldAncestorsz%SpeechGenerator._generateOldAncestors�s���
�&�&�(�3�3�4L�M��I��<�<�!�!�1�1�3��I��8�8�J�'���3�(�?�(�2C�2C�H�2M��I��"�"�3�'��I��#�#�C�(�H�,D�,D�X�,N�N��$�$�S�*A�B��I����.�.�=�=�c�B�
��v���I���Y��$�z�z�5�5�$�z�z�:�:�$�z�z���$�z�z�2�2�6�7�2�8�3�2�*�$�z�z���$�z�z�/�/�,�$�z�z�/�/�$�z�z�2�2�4��]��"���<�<�!�!�.�.�x�8��.�.�x�8�G����w��-��M�M�$�-�-��w�9�d�(�L�
M����g�t�,��
�
�-�d�-�-�c�:�T�:�;������������
r!c���tj�jd�rgS|jjj�rgS|j
d�}||k(rgS|j
dtj|��}|tjjtjjfvrgS|tjjk(r|rtj|�rgS|�|j |fi|��S|jjj#|�\}}|xs|}tj$|�r|j |fi|��SgS)awReturns an array of strings (and possibly voice and audio
        specifications) that represent the text of the ancestors for
        the object.  This is typically used to present the context for
        an object (e.g., the names of the window, the panels, etc.,
        that the object is contained in).  If the 'priorObj' attribute
        of the args dictionary is set, only the differences in
        ancestry between the 'priorObj' and the current obj will be
        computed.  Otherwise, no ancestry will be computed.  The
        'priorObj' is typically set by Orca to be the previous object
        with focus.
        r[r�rZ)r
r`rarlrmr�r\rr]rr^�FRAME�WINDOW�	MENU_ITEMr�	is_windowr�r��is_dialog_or_alert)rrIrJr�rZr�r��topLevels        r�_generateNewAncestorsz%SpeechGenerator._generateNewAncestors/s.���&�&�(�3�3�4L�M��I��<�<�!�!�1�1�3��I��8�8�J�'���s�?��I��x�x��� 1� 1�#� 6�7���E�J�J�$�$�e�j�j�&7�&7�8�8��I��5�:�:�'�'�'��[�=R�=R�S[�=\��I���*�4�*�*�3�7�$�7�7����.�.�=�=�c�B�
��v��?�U���)�)�(�3�*�4�*�*�3�7�$�7�7��	r!c��|jd�|k(rgS|j|fi|��}|j|j|fi|���|S)Nr�)r\r�rpr�ris    r�generateContextzSpeechGenerator.generateContextWsS���8�8�J��3�&��I�+��+�+�C�8�4�8���
�
�0�d�0�0��=��=�>��
r!c��|jdtj|��tjj
k(r%|jdd�dvrtjgStj|�}tj|�stj|�r|}|jtj|��S)z�Returns an array of strings (and possibly voice and audio
        specifications) containing the role name of the parent of obj.
        rZrsN)�
basicWhereAmI�detailedWhereAmI)
r\rr]rr^r�r�ROLE_ICON_PANELrqr�
is_table_cell�is_menur�)rrIrJrus    r�_generateParentRoleNamez'SpeechGenerator._generateParentRoleName_s����8�8�F�H�-�-�c�2�3�u�z�z���F��x�x��d�+�7�8�%�5�5�6�6��$�$�S�)���$�$�V�,��0C�0C�F�0K��C��%�%�h�&9�&9�#�&>�?�?r!c���g}tj|tj�}|r@|j	|j|��|j	|j
|��|S)z�Returns an array of strings (and possibly voice and audio
        specifications) containing the name and role of the toolbar
        which contains obj.
        )rr�r�is_tool_barrcr>r�)rrIrJrfrts     r�_generateToolbarz SpeechGenerator._generateToolbarmsW��
���)�)�#�{�/F�/F�G����M�M�$�4�4�X�>�?��M�M�$�0�0��:�;��
r!c��tj�jd�rgStj|t
jjtj�}||vrgSg}d�}t|tj|���}|j|jjj!dd��|j#|�dzt%|�d�z�|j'|j(t*fd	|i|���|S)
z�Returns an array of strings (and possibly voice and audio
        specifications) that represent the relative position of an
        object in a group.
        r[c�X�tj|�tj|�z
Sr)rr9)rB�ys  r�cmpz5SpeechGenerator._generatePositionInGroup.<locals>.cmp�s$���/�/��2�X�5Q�5Q�RS�5T�T�Tr!)r�r�
groupindexr4rr�rI)r
r`rarr
rrrrr%�sorted�	functools�
cmp_to_keyrprlr7r8r�rrcr;rd)rrIrJr
rfrs      r�_generatePositionInGroupz(SpeechGenerator._generatePositionInGroupys���
�&�&�(�3�3�4L�M��I��/�/���#�#�-�-�{�/E�/E�G���g���I���	U���i�&:�&:�3�&?�@���
�
�d�l�l�-�-�7�7�#+�)5�8�7�(/�}�}�S�'9�A�'=�'*�7�|�5�5�	6�
	�
�
�j�d�j�j��9�S�9�D�9�:��
r!c�,�tj�jd�s5tj�jd�s|jdd�sgS|jj
j
|�rgS|jj
j|�rgSg}|jj
j|fi|��\}}|dkrgSd}|dkr,|jj
j|�sgS|dz
}|dk(rtj|�rgS|dz
}|j|jjjd	|�
�||d�z�|j|j t"fd|i|���|S)
z�Returns an array of strings (and possibly voice and audio
        specifications) that represent the relative position of an
        object in a list.
        r[�enablePositionSpeaking�	forceListFrr�totalunknownrrr4r�rI)r
r`rar\rlrm�isTopLevelMenur��getPositionAndSetSize�setSizeUnknownrr�rpr7r8rcr;rd)rrIrJrf�positionr�r5s       r�_generatePositionInListz'SpeechGenerator._generatePositionInList�st���&�&�(�3�3�4L�M�#�.�.�0�;�;�<T�U��h�h�{�E�2��I��<�<�!�!�0�0��5��I��<�<�!�!�4�4�S�9��I���F�$�,�,�0�0�F�F�s�S�d�S���%��a�<��I�!�
��1�9��<�<�)�)�8�8��=��	��.�(�J��A�:�+�-�-�c�2��I��A�
���
�
�d�l�l�-�-�7�7�#+�)3�8�5�(0�',�.�.�	/�
	�
�
�j�d�j�j��9�S�9�D�9�:��
r!c�(�|jd�r|j|fi|��sgSg}|j�\}}}||k7rP|j|�\}}tj
|zg}|j
|jtfd|i|���|S)N�isProgressBarUpdaterI)	r\�_shouldPresentProgressBarUpdate�_getMostRecentProgressBarUpdate�getProgressBarNumberAndCountr
�PROGRESS_BAR_NUMBERrcr;rd)	rrIrJrf�acc�
updateTime�updateValue�numberrs	         r�_generateProgressBarIndexz)SpeechGenerator._generateProgressBarIndex�s����x�x�-�.�6�$�6�6�s�C�d�C��I���'+�'K�'K�'M�$��Z���#�:� �=�=�c�B�M�F�E��2�2�f�=�>�F��M�M�*�$�*�*�V�=��=��=�>��
r!c��|jd�r|j|fi|��sdgSg}tj|�}|�L|j	tj|��|j|jtfd|i|���|S)NrrOrI)
r\rrrrpr
rrcr;rd)rrIrJrf�percents     r�_generateProgressBarValuez)SpeechGenerator._generateProgressBarValue�s����8�8�)�*�7�4�7�7��D�t�D��4�K����.�.�s�3�����M�M�(�-�-�g�6�7��M�M�*�$�*�*�V�=��=��=�>��
r!c���tj�jd�}|�t�|��}t|�S)N�progressBarSpeechInterval)r
r`rarU�_getProgressBarUpdateIntervalrR)r�intervalrXs  �rr#z-SpeechGenerator._getProgressBarUpdateInterval�s:���#�.�.�0�;�;�<W�X�����w�<�>�H��8�}�r!c�l��tj�jd�syt�|�|fi|��S)N�speakProgressBarUpdatesF)r
r`rarUr)rrIrJrXs   �rrz/SpeechGenerator._shouldPresentProgressBarUpdate�s3����*�*�,�7�7�8Q�R���w�6�s�C�d�C�Cr!c�j�tj|�sgS|jjj	|�}|r||gk(rgSg}|D]e}||k(r�	|j|d��}|s�|j
|�t|dt�r�D|j
|j|fi|����g|S)z�Returns an array of strings (and possibly voice and audio
        specifications) that represent the status bar of a window.
        F��includeContextr%)
r�
is_status_barrlrm�statusBarItemsrDrcr@rr�)rrIrJr/rfr9�childResults       r�_generateStatusBarz"SpeechGenerator._generateStatusBar�s���
�(�(��-��I����&�&�5�5�c�:����#����I����	F�E���|���-�-��e�-�D�K���
�
�k�*�!�+�b�/�5�9��M�M�"5�$�"5�"5�e�"D�t�"D�E�	F��
r!c��g}|jjj|�\}}|r5|j|�}|s|j	|�}|j|�|r |j|j|��|jjj
|�}|dkDrOtj|�g}|j|jtfd|i|���|j|�|S)z�Returns an array of strings (and possibly voice and audio
        specifications) that represent the title of the window, obj.
        containing the object, along with information associated with
        any unfocused dialog boxes.
        rrI)rlrmr�r>r�rprDr
rErcr;re)	rrIrJrfr�r��frameResultrF�dialogss	         r�
generateTitlezSpeechGenerator.generateTitle	s��������.�.�=�=�c�B�
��v���4�4�U�;�K��"�4�4�U�;���M�M�+�&���M�M�$�4�4�V�<�=�"�l�l�4�4�Q�Q�RU�V����"��1�1�2E�F�G�G��N�N�:�4�:�:�g�?�3�?�$�?�@��M�M�'�"��
r!c���tjtj|��sgSg}tj|�}|D]$}|j|j
|d����&|S)NFr()rr�rrq�get_all_widgetsrprD)rrIrJrf�widgets�widgets      r�_generateListBoxItemWidgetsz+SpeechGenerator._generateListBoxItemWidgets	sd���&�&�x�':�':�3�'?�@��I����-�-�c�2���	G�F��M�M�$�-�-��u�-�E�F�	G��
r!c��tj�jd�rgSg}|jjj|�\}}}|r9|j
|�|j|jtfd|i|���|S)z�Returns an array of strings (and possibly voice and audio
        specifications) that represent the accelerator for the object,
        or an empty array if no accelerator can be found.
        r[rI)
r
r`rarlrm�mnemonicShortcutAcceleratorrprcr;rd�rrIrJrf�mnemonic�shortcut�accelerators       r�_generateAcceleratorz$SpeechGenerator._generateAccelerator,	s~��
�&�&�(�3�3�4L�M��I����L�L�"�"�>�>�s�C�	*��8�[���M�M�+�&��M�M�*�$�*�*�V�=��=��=�>��
r!c��tj�jd�rgSg}tj�jd�s|jdd�rc|jj
j
|�\}}}|r|d}|s|r|}|r+|g}|j|jtfd|i|���|S)z�Returns an array of strings (and possibly voice and audio
        specifications) that represent the mnemonic for the object, or
        an empty array if no mnemonic can be found.
        r[�enableMnemonicSpeaking�
forceMnemonicFr%rI)
r
r`rar\rlrmr8rcr;rdr9s       r�_generateMnemonicz!SpeechGenerator._generateMnemonic=	s���
�&�&�(�3�3�4L�M��I����&�&�(�3�3�4L�M��h�h���.����&�&�B�B�3�G�
.�X�x���#�B�<����#���"����
�
�j�d�j�j��A�S�A�D�A�B��
r!c��tj�jd�s#|jdd�j	d�sgStj|�}|sgS||jtfd|i|��gS)z}Returns an array of strings (and possibly voice and audio
        specifications) that represent the tutorial for the object.�enableTutorialMessagesrsrO�WhereAmIrI)	r
r`rar\�endswithr�
get_help_textr;rd)rrIrJr7s    r�_generateTutorialz!SpeechGenerator._generateTutorialT	sr�� �*�*�,�7�7�8P�Q��8�8�L�"�-�6�6�z�B��I��%�%�c�*����I��j�d�j�j��9�S�9�D�9�:�:r!c��g}tj|�D�cgc]}|��}}|s(|jjj	|�s|g}|D]�}|jjj|�r6tj|�r!|j|j|���^|j|�}|j||�|j|j||���|j||���|Scc}w�Nr�)
rrrlrm�isMathTopLevel�isMathLayoutOnlyr*rc�
_generateMathr�rurDrv)rrIrJrfr9rrxs       rrLzSpeechGenerator._generateMathd	s�����'/�'=�'=�c�'B�C�e�E�C��C����� 6� 6� E� E�c� J��u�H��	-�E��|�|�%�%�6�6�u�=�(�BZ�BZ�[`�Ba��
�
�d�0�0��7�8���.�.�u�5�G����w��-��M�M�$�-�-��G�-�<�=����g�t�,�	-��
��Ds�	D
c�(�|j|fi|��Sr)rLr]s   r�_generateEnclosedBasez%SpeechGenerator._generateEnclosedBasev	s��!�t�!�!�#�.��.�.r!c���g}|jjj|�}d|vr|jtj
�d|vr|jtj�d|vr|jtj�d|vr|jtj�d|vr|jtj�d|vr|jtj�d|vr|jtj�d|vr|jtj�d	|vr|jtj�d
|vr|jtj�d|vr|jtj�d|vr|jtj �d
|vr|jtj"�d|vr|jtj$�d|vr|jtj&�d|vr|jtj(�d|vr|jtj*�|s+d|g}t-j.t,j0|d�gSt3|�dk(rtj4|dzg}nu|j7dtj8�t3|�dk(r$tj4dj;|�zg}n#tj4dj;|�zg}|j=|j>t@fd|i|���|S)N�	actuarial�box�circle�longdiv�radical�
roundedbox�horizontalstrike�verticalstrike�downdiagonalstrike�updiagonalstrike�northeastarrow�bottom�left�right�top�phasorangle�madruwbz5SPEECH GENERATOR: Could not get enclosure message forTrrr%rrPz, rI)!rlrm�getMathEnclosuresrpr
�MATH_ENCLOSURE_ACTUARIAL�MATH_ENCLOSURE_BOX�MATH_ENCLOSURE_CIRCLE�MATH_ENCLOSURE_LONGDIV�MATH_ENCLOSURE_RADICAL�MATH_ENCLOSURE_ROUNDEDBOX�MATH_ENCLOSURE_HORIZONTALSTRIKE�MATH_ENCLOSURE_VERTICALSTRIKE�!MATH_ENCLOSURE_DOWNDIAGONALSTRIKE�MATH_ENCLOSURE_UPDIAGONALSTRIKE�MATH_ENCLOSURE_NORTHEASTARROW�MATH_ENCLOSURE_BOTTOM�MATH_ENCLOSURE_LEFT�MATH_ENCLOSURE_RIGHT�MATH_ENCLOSURE_TOP�MATH_ENCLOSURE_PHASOR_ANGLE�MATH_ENCLOSURE_MADRUWBrrGrHr�MATH_ENCLOSURE_ENCLOSED_BY�insert�MATH_ENCLOSURE_ANDrTrcr;rd)rrIrJ�strings�
enclosuresrLrfs       r�_generateEnclosedEnclosuresz+SpeechGenerator._generateEnclosedEnclosuresy	s������\�\�+�+�=�=�c�B�
��*�$��N�N�8�<�<�=��J���N�N�8�6�6�7��z�!��N�N�8�9�9�:��
�"��N�N�8�:�:�;��
�"��N�N�8�:�:�;��:�%��N�N�8�=�=�>���+��N�N�8�C�C�D��z�)��N�N�8�A�A�B��:�-��N�N�8�E�E�F���+��N�N�8�C�C�D��z�)��N�N�8�A�A�B��z�!��N�N�8�9�9�:��Z���N�N�8�7�7�8��j� ��N�N�8�8�8�9��J���N�N�8�6�6�7��J�&��N�N�8�?�?�@��
�"��N�N�8�:�:�;��M�z�Z�F����e�.�.���=��I��w�<�1���9�9�G�A�J�F�G�F��N�N�2�x�:�:�;��7�|�q� �"�=�=�����@Q�Q�R��"�=�=��	�	�'�@R�R�S���
�
�j�d�j�j��9�S�9�D�9�:��
r!c���|jjj|�\}}|r@tj|�g}|j|jtfd|i|���|SgSr`�rlrm�
getMathFencesr	rrcr;re�rrIrJ�
fenceStart�fenceEndrfs      r�_generateFencedStartz$SpeechGenerator._generateFencedStart�	sb��#�|�|�5�5�C�C�C�H��
�H��!�2�2�:�>�?�F��M�M�*�$�*�*�W�>�#�>��>�?��M��	r!c�z�g}|jjj|�}tt	|�tj|�dz
�D]}|j|d��|jd�ttj|��D]�\}}|j|j|fi|���tj||�}|j|�|j|jtfd|i|���|s�||j|j |fi|�����|S)Nrr%rOrI)rlrm�getMathFencedSeparators�rangerrr*rpr�rrcrLr	rr;rer�)	rrIrJrf�
separatorsrBr�r9�
separatorNames	         r�_generateFencedContentsz'SpeechGenerator._generateFencedContents�	s�����\�\�+�+�C�C�C�H�
��s�:���(@�(@��(E�a�(G�H�	.�A����j��n�-�	.����"��!�(�"8�"8��"=�>�	@�H�A�u��M�M�,�$�,�,�U�;�d�;�<�'�8�8��A��G�M��M�M�-�(��M�M�*�$�*�*�W�>�#�>��>�?���
�
�1�d�1�1�#�>��>�?�
	@��
r!c���|jjj|�\}}|r@tj|�g}|j|jtfd|i|���|SgSr`rzr|s      r�_generateFencedEndz"SpeechGenerator._generateFencedEnd�	sb��#�|�|�5�5�C�C�C�H��
�H��!�2�2�8�<�=�F��M�M�*�$�*�*�W�>�#�>��>�?��M��	r!c���|jjj|�rtjg}ntj
g}|j
|jtfd|i|���|Sr`)	rlrm�isMathFractionWithoutBarr
�MATH_FRACTION_WITHOUT_BAR_START�MATH_FRACTION_STARTrcr;rdris    r�_generateFractionStartz&SpeechGenerator._generateFractionStart�	s\���<�<�!�!�:�:�3�?��>�>�?�F��2�2�3�F��
�
�j�d�j�j��9�S�9�D�9�:��
r!c�L�|jjj|�}|jjj|�r|j	|�S|j|�}|j
||�|j||��}|j||�|SrI)	rlrm�getMathNumeratorrKrLr�rurDrv)rrIrJ�	numeratorrxrfs      r�_generateFractionNumeratorz*SpeechGenerator._generateFractionNumerator�	s����L�L�*�*�;�;�C�@�	��<�<�!�!�2�2�9�=��%�%�i�0�0��*�*�9�5�����7�D�)����y�w��7�����'�4�(��
r!c�L�|jjj|�}|jjj|�r|j	|�S|j|�}|j
||�|j||��}|j||�|SrI)	rlrm�getMathDenominatorrKrLr�rurDrv)rrIrJ�denominatorrxrfs      r�_generateFractionDenominatorz,SpeechGenerator._generateFractionDenominator�	s����l�l�,�,�?�?��D���<�<�!�!�2�2�;�?��%�%�k�2�2��*�*�;�7�����7�D�)����{���9�����'�4�(��
r!c�x�tjg}|j|jtfd|i|���|Sr`)r
�MATH_FRACTION_LINErcr;rdris    r�_generateFractionLinez%SpeechGenerator._generateFractionLine�	s6���-�-�.���
�
�j�d�j�j��9�S�9�D�9�:��
r!c�x�tjg}|j|jtfd|i|���|Sr`)r
�MATH_FRACTION_ENDrcr;rdris    r�_generateFractionEndz$SpeechGenerator._generateFractionEnd�	s6���,�,�-���
�
�j�d�j�j��9�S�9�D�9�:��
r!c��g}|jjj|�rtjg}�nm|jjj|�}|jjj
|�}|dk(rtjg}�n|dk(rtjg}n�|r$|g}|jtjg�n�|jjj|�r2|j|�}|jtjg�nw|j|�}|j||�|j|j||���|j||�|jtjg�|r(|j|j t"fd|i|���|S)N�2�3r�rI)rlrm�isMathSquareRootr
�MATH_SQUARE_ROOT_OF�getMathRootIndexr(�MATH_CUBE_ROOT_OFrc�MATH_ROOT_OFrKrLr�rurDrvr;rd)rrIrJrfr�r�rxs       r�_generateRootStartz"SpeechGenerator._generateRootStart�	sn�����<�<�!�!�2�2�3�7��2�2�3�F��L�L�*�*�;�;�C�@�E��\�\�+�+�9�9�%�@�F���}�"�6�6�7���3��"�4�4�5��� ����
�
�x�4�4�5�6����'�'�8�8��?��+�+�E�2���
�
�x�4�4�5�6��2�2�5�9���"�"�7�D�1��
�
�d�m�m�E��m�@�A��!�!�'�4�0��
�
�x�4�4�5�6���M�M�*�$�*�*�V�=��=��=�>��
r!c�.�|jjj|�}|sgS|jjj|�sJ|jjj	|�s%|jjj|�r|j
|�S|j|fi|��g}|j|�}|j||�|j|j||���|j||�|SrI)
rlrm�getMathRootBaser��isMathTokenrKrLr�r�rurcrDrv)rrIrJ�baserfrxs      r�_generateRootBasez!SpeechGenerator._generateRootBase
s����|�|�%�%�5�5�c�:����I��<�<�!�!�2�2�3�7��l�l�$�$�0�0��6��l�l�$�$�5�5�d�;��%�%�d�+�+�%�$�%�%�c�2�T�2�3���*�*�4�0�����7�D�)��
�
�d�m�m�D�w�m�7�8����'�4�(��
r!c�x�tjg}|j|jtfd|i|���|Sr`)r
�
MATH_ROOT_ENDrcr;rdris    r�_generateRootEndz SpeechGenerator._generateRootEnd)
s6���(�(�)���
�
�j�d�j�j��9�S�9�D�9�:��
r!c�v�|jjj|�}|sgS|j|�Sr)rlrm�getMathScriptBaserL)rrIrJr�s    r�_generateScriptBasez#SpeechGenerator._generateScriptBase.
s5���|�|�%�%�7�7��<����I��!�!�$�'�'r!c��|jjj|�r|j|�S|j	|�}|j||�|j
||��}|j||�|SrI)rlrmrKrLr�rurDrv)rrIrJrxrfs     r�_generateScriptScriptz%SpeechGenerator._generateScriptScript5
sr���<�<�!�!�2�2�3�7��%�%�c�*�*��*�*�3�/�����7�D�)����s���1�����'�4�(��
r!c�
�|jjj|�}|sgStjg}|j|jtfd|i|���|j|j|��|Sr`)	rlrm�getMathScriptSubscriptr
�MATH_SUBSCRIPTrcr;rdr�)rrIrJ�	subscriptrfs     r�_generateScriptSubscriptz(SpeechGenerator._generateScriptSubscript@
so���L�L�*�*�A�A�#�F�	���I��)�)�*���
�
�j�d�j�j��9�S�9�D�9�:��
�
�d�0�0��;�<��
r!c�
�|jjj|�}|sgStjg}|j|jtfd|i|���|j|j|��|Sr`)	rlrm�getMathScriptSuperscriptr
�MATH_SUPERSCRIPTrcr;rdr�)rrIrJ�superscriptrfs     r�_generateScriptSuperscriptz*SpeechGenerator._generateScriptSuperscriptK
�o���l�l�,�,�E�E�c�J����I��+�+�,���
�
�j�d�j�j��9�S�9�D�9�:��
�
�d�0�0��=�>��
r!c�
�|jjj|�}|sgStjg}|j|jtfd|i|���|j|j|��|Sr`)	rlrm�getMathScriptUnderscriptr
�MATH_UNDERSCRIPTrcr;rdr�)rrIrJ�underscriptrfs     r�_generateScriptUnderscriptz*SpeechGenerator._generateScriptUnderscriptV
r�r!c�
�|jjj|�}|sgStjg}|j|jtfd|i|���|j|j|��|Sr`)	rlrm�getMathScriptOverscriptr
�MATH_OVERSCRIPTrcr;rdr�)rrIrJ�
overscriptrfs     r�_generateScriptOverscriptz)SpeechGenerator._generateScriptOverscripta
so���\�\�+�+�C�C�C�H�
���I��*�*�+���
�
�j�d�j�j��9�S�9�D�9�:��
�
�d�0�0��<�=��
r!c���g}|jjj|�}t|�D]�\}}|jjj	|�r�,|dzrt
jg}nt
jg}|j|jtfd|i|���|j|j|��|j|���|S�Nr#rI)
rlrm�getMathPrescriptsr��
isNoneElementr
�MATH_PRE_SUPERSCRIPT�MATH_PRE_SUBSCRIPTrcr;rdr�rp)rrIrJrf�
prescriptsr�r9rKs        r�_generateScriptPrescriptsz)SpeechGenerator._generateScriptPrescriptsl
s������\�\�+�+�=�=�c�B�
�"�:�.�		�I�A�v��|�|�%�%�3�3�F�;���1�u��3�3�4���1�1�2���I�I�j�d�j�j��9�S�9�D�9�:��I�I�d�0�0��8�9��M�M�"��		��
r!c���g}|jjj|�}t|�D]�\}}|jjj	|�r�,|dzrt
jg}nt
jg}|j|jtfd|i|���|j|j|��|j|���|Sr�)
rlrm�getMathPostscriptsr�r�r
r�r�rcr;rdr�rp)rrIrJrf�postscriptsr�r9rKs        r�_generateScriptPostscriptsz*SpeechGenerator._generateScriptPostscripts|
s������l�l�,�,�?�?��D��"�;�/�		�I�A�v��|�|�%�%�3�3�F�;���1�u��/�/�0���-�-�.���I�I�j�d�j�j��9�S�9�D�9�:��I�I�d�0�0��8�9��M�M�"��		��
r!c��tj|�sgStj|�}tj|�}|j
jj|�}|dkDrtj||�g}ntj||�g}|j|jtfd|i|���|S�NrrI)r�supports_tablerr�r�rlrm�getMathNestingLevelr
�mathNestedTableSize�
mathTableSizercr;rd)rrIrJr�r�r�rfs       r�_generateMathTableStartz'SpeechGenerator._generateMathTableStart�
s����&�&�s�+��I��$�$�S�)���*�*�3�/���|�|�-�-�A�A�#�F���!���2�2�4��A�B�F��,�,�T�7�;�<�F��
�
�j�d�j�j��9�S�9�D�9�:��
r!c���g}tj|�D]Y}|j|�}|j||�|j	|j||���|j
||��[|SrI)rrr�rurcrDrv)rrIrJrfr�rxs      r�_generateMathTableRowsz&SpeechGenerator._generateMathTableRows�
sq�����)�)�#�.�	-�C��.�.�s�3�G����w��-��M�M�$�-�-��'�-�:�;����g�t�,�		-��
r!c���g}|jtjtj|�dzz�|j|jtfd|i|���|j|j|fi|���tj|�D]D}|j|j|��|j|j|fi|����F|S)NrrI)rpr
r�rr9rcr;rdr�rrL)rrIrJrfr9s     r�_generateMathRowz SpeechGenerator._generateMathRow�
s������
�
�h�(�(�H�,H�,H��,M�PQ�,Q�R�S��
�
�j�d�j�j��9�S�9�D�9�:��
�
�)�d�)�)�#�6��6�7��+�+�C�0�	>�E��M�M�$�,�,�U�3�4��M�M�-�$�-�-�e�<�t�<�=�	>��
r!c���|jjj|�}|dkDrtjg}ntj
g}|j
|jtfd|i|���|Sr�)	rlrmr�r
�MATH_NESTED_TABLE_END�MATH_TABLE_ENDrcr;rd)rrIrJr�rfs     r�_generateMathTableEndz%SpeechGenerator._generateMathTableEnd�
sf���|�|�-�-�A�A�#�F���!���4�4�5�F��-�-�.�F��
�
�j�d�j�j��9�S�9�D�9�:��
r!c���tj�jd�r|jdd�rgStj�jd�tj
k(rgStS)N�enablePauseBreaks�eliminatePausesF�verbalizePunctuationStyle)r
r`rar\r�PUNCTUATION_STYLE_ALLr#r]s   rr�zSpeechGenerator._generatePause�
s^���*�*�,�7�7�8K�L��h�h�(�%�0��I��&�&�(�3�3�4O�P��)�)�*��I��r!c��tSr)�
LINE_BREAKr]s   r�_generateLineBreakz"SpeechGenerator._generateLineBreak�
s���r!c�~�tj|�xstjt�}tj�jd�}t
j|jtjt�i��}|jd�}|jdd�}d|�d|�d|�d�}tjtj|d	�d
}	|r(|	r&tj�}
|
j||�|dtfvr�|jdd�}|jd
�}tj|�r;|j!|jtjt"�i��|gSt%|t&�rf|j)�rV|j+�j-�r8|j!|jtjt.�i��|gS|j|�}
|
r#|
jdd	�r|j!|
�|gS)z�Returns an array containing a voice.  The key is a value
        to be used to look up the voice in the settings.py:voices
        dictionary. Other arguments can be passed in for future
        decision making.
        �voicesr�r�rOzSPEECH GENERATOR: z  voice requested with language='z', dialect='r�TFNr�rI�established)�	voiceTyper\rer
r`rarrRrr�rHr�getSpeechServer�shouldChangeVoiceForLanguager�is_link�update�	HYPERLINKr@�str�isupperr��isalpha�	UPPERCASE)rr�rJ�	voicenamer�r;r�r�r��checkVoicesForLanguage�serverr�rI�overrides              rr;zSpeechGenerator.voice�
s����M�M�#�&�@�)�-�-��*@�	�!�,�,�.�9�9�(�C���	�	�&�*�*�Y�]�]�7�%;�R�@�A���8�8�J�'���(�(�9�b�)�� ���&�!�
�,�w�i�q�
:�	�	���5�+�+�S�$�7�
"'���.��+�+�-�F��/�/��'�B��4��/�!��X�X�h��+�F��(�(�5�/�C��"�"�3�'����V�Z�Z�	�
�
�i�(@�"�E�F��w���F�C�(�V�^�^�-=�&�,�,�.�BX�BX�BZ����V�Z�Z�	�
�
�i�(@�"�E�F��w��	�z�z�)�,�H��H�L�L���=����X�&��w�r!c��d}|D]H}t|t�r	|d|��z
}�t|t�s�-|s�0|dj�s�D|dz
}�J|j	�S)NrOrPr%r<)r@r�r�isalnumr�)r�
utterancesr��us    r�utterancesToStringz"SpeechGenerator.utterancesToString�
sb�����	�A��!�S�!��A�a�S�'�!���A�u�%�&�V�B�Z�5G�5G�5I��#�
��		��|�|�~�r!)Tr)�r&r'r(r)rr<rMrSrbrhrsrwrr~r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r|rrrrrrrrr:rHrYr^rbrdrfrlroryr}r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrrr(r+r1r<r@rBrGr�r�r�r�r�r�r�rr	rrr r#rr-r1r6r=rArGrLrNrxrr�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��
__classcell__)rXs@rr6r6gs����8�
=�*��C� �:
��8��+�Z
�	��	������$�2�$�2�&�����,�*>�@��9�$�B��������(2�h!�F�J
*�$���4�.7�.�*�*+�Z
1�
�
.�
��4�2/�b�$%>�N�$@`�"�>�0� � � �(��4��.�<��B�$�"�$�:D�$8��2?!�BA�Fn�`8�t&�P�@�
� �D&�P���D��2�0� �"�.;� �$/�4�l��"��	�	��
�
�:�$�
(�	�	�	�	�	�� � ����	��'�Rr!r6):r)�__id__�__version__�__date__�
__copyright__�__license__r�gi�require_version�
gi.repositoryr�urllib.parser)�urllib.request�urllib.errorrOrrrr	r
rrr
rr�ax_documentr�ax_hypertextr�	ax_objectr�ax_tabler�ax_textr�ax_utilitiesr�ax_valuerrr#r+r��
METHOD_PREFIXrer�r�rdr�VALUE�
DEFAULT_VOICE�UPPERCASE_VOICE�HYPERLINK_VOICE�SYSTEM_VOICEr�r8r6rr!r�<module>rs+��(=�������?�
����	�����7�E�"���������������"�#�%����%����
��	�����k�]�
��
����	��	��������X�
#�
#�
�x�'�'�
�x�'�'�
�H�!�!�	�8� � �	�8� � �

�	�X*�i�)�)�X*r!

Zerion Mini Shell 1.0