
    g
f                    l   d Z dZdZdZdZdZddlZddlZ ej                  dd	       dd
l	m
Z
 ddlZddlZddlZddlZddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddl m!Z! ddl"m#Z# ddl$m%Z% ddl&m'Z'  G d d      Z( e(       gZ) G d d       Z* e*       gZ+d!Z,d"Z-d#Z.d$Z/d%Z0d&Z1d'Z2e-ejf                  e.ejh                  e/ejj                  e0ejl                  e1ejl                  e2ejl                  iZ7 G d( d)ejp                        Z9y)*z6Utilities for obtaining speech utterances for objects.z$Id:$z$Revision:$z$Date:$z-Copyright (c) 2005-2009 Sun Microsystems Inc.LGPL    NAtspiz2.0)r      )acss)debug)	generator)mathsymbols)messages)object_properties)settings)settings_manager)speech)text_attribute_names)
AXDocument)AXHypertext)AXObject)AXTable)AXText)AXUtilities)AXValuec                       e Zd ZdZd Zd Zy)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__zPause.__init__;           c                      y)NPAUSEr   r   s    r   __str__zPause.__str__>   s    r!   N__name__
__module____qualname____doc__r   r$   r   r!   r   r   r   8   s    r!   r   c                       e Zd ZdZd Zd Zy)	LineBreakzYA dummy class to indicate we want to break an utterance into
    separate calls to speak.c                      y r   r   r   s    r   r   zLineBreak.__init__F   r    r!   c                      y)Nz
LINE BREAKr   r   s    r   r$   zLineBreak.__str__I   s    r!   Nr%   r   r!   r   r+   r+   C   s     r!   r+   	_generatedefault	uppercase	hyperlinksystemstatevaluec                   |    e Zd ZdZd Zd Zd Zd fd	Zd Zd Z	d Z
d	 Zd
 Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Z d Z!d  Z"d! Z# fd"Z$d# Z%d$ Z&d% Z' fd&Z(d' Z) fd(Z*d) Z+d* Z,d+ Z-d, Z.d- Z/d. Z0d/ Z1 fd0Z2 fd1Z3 fd2Z4d3 Z5d4 Z6d5 Z7d6 Z8d7 Z9d8 Z:d9 Z;d: Z<d; Z=d< Z>d= Z?d> Z@d? ZAd@ ZBdA ZCg dBfdCZDdD ZEdE ZFdF ZG fdGZHdH ZI fdIZJdJ ZK fdKZLdL ZM fdM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 fdcZd fdd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~ Zd Zd Zd Zd Zd Zd Zd Zd ZddZd Z xZS )SpeechGeneratorzTakes 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    t         j                  j                  | |d       y )Nr   )r   	Generatorr   )r   scripts     r   r   zSpeechGenerator.__init__m   s    $$T68<r!   c                 b    t         j                  j                  | |       | j                  |d<   y)zCOther things to make available from the formatting string.
        voiceN)r   r8   _addGlobalsr;   )r   globalsDicts     r   r<   zSpeechGenerator._addGlobalsp   s(     	''k:#zzGr!   c                      | j                   |fi |}|rBt        t        d |            s,d|dg}t        j                  t        j
                  |d       g }|S )Nc                 $    t        | t               S r   )
isinstancer   xs    r   <lambda>z0SpeechGenerator.generateSpeech.<locals>.<lambda>x   s    
1e0D,D r!   zSPEECH GENERATOR: Results forzare pauses onlyT)generatelistfilterr   printTokens
LEVEL_INFO)r   objargsrvtokenss        r   generateSpeechzSpeechGenerator.generateSpeechv   sX    T]]3'$'d6"DbIJ5s<MNFe..=B	r!   c                     t        |t        j                        r|syt        |t              r;|D cg c]  }| j	                  ||       }}dj                  t        d |            S t        |   ||      S c c}w )N  c                     | S r   r   rA   s    r   rC   z8SpeechGenerator._resultElementToString.<locals>.<lambda>   s    Q r!   )r@   r   ACSSrE   _resultElementToStringjoinrF   super)r   element
includeAllrB   rK   	__class__s        r   rS   z&SpeechGenerator._resultElementToString   sn    gtyy)*gt$FMN$--a<NBN88F;344w-gzBB Os   A:c                    |j                  dt        j                  |            }|t        j                  j
                  k(  r%t        j                         j                  d      rg S t        j                  j                  | |fi |}|ro|t        j                  j
                  k(  r*|j                   | j                  t        fd|i|       |S |j                   | j                  t        fd|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
getSettingr   r8   _generateNameextendr;   SYSTEMDEFAULT)r   rI   rJ   rZ   results        r   rb   zSpeechGenerator._generateName   s     xx 1 1# 675::*****,778PQI$$224EEuzz...jdjjASADAB  jdjjBcBTBCr!   c                     t        j                  j                  | |fi |}|r(|j                   | j                  t
        fd|i|       |S )a  Returns 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   )r   r8   _generateLabelrc   r;   re   r   rI   rJ   rf   s       r   rh   zSpeechGenerator._generateLabel   sJ     $$33D#FFMM*$**W>#>>?r!   c                    |j                  dt        j                  |            }|t        j                  j
                  k(  rQ| j                  j                  j                  |      r,d|dg}t        j                  t        j                  |d       g S g }|j                   | j                  |fi |       |sPt        j                  |      }|r9|j                  |       |j                   | j                   t"        fd|i|       |r|S t        j$                  |      }t'        j(                  |      r | j*                  |fi |}|S )zReturns 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.
        rZ   zSPEECH GENERATOR:zis popup menu for current item.TrI   )r\   r   r]   r   r^   MENU_script	utilitiesisPopupMenuForCurrentItemr   rG   rH   rc   rh   get_nameappendr;   re   
get_parentr   is_autocomplete_generateLabelOrName)r   rI   rJ   rZ   rL   rf   nameparents           r   rs   z$SpeechGenerator._generateLabelOrName   s    xx 1 1# 675::??"t||'='='W'WX['\)30QRFe..=I)d))#667$$S)Dd#jdjjBcBTBCM$$S)&&v..T..v>>Fr!   c                     t        j                  j                  | |fi |}|r(|j                   | j                  t
        fd|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   )r   r8   _generatePlaceholderTextrc   r;   re   ri   s       r   rw   z(SpeechGenerator._generatePlaceholderText   sJ     $$==dCP4PMM*$**W>#>>?r!   c                      | j                   |fi |xs  | j                  |fi |}|rd| j                  j                  d<   |S d|d<    | j                  |fi |}|rd| j                  j                  d<   |S )NFusedDescriptionForAlertT	alerttext)_generateExpandedEOCs_generateUnrelatedLabelsrl   pointOfReference_generateDescriptionri   s       r   _generateAlertTextz"SpeechGenerator._generateAlertText   s    +++C848 ?1D11#>> 	GLDLL))*CDM [***37$7GKDLL))*CDr!   c                    d}|j                  dt        j                  |            }|t        j                  j
                  k(  r'	 | j                  j                  j                  d      }n&	 | j                  j                  j                  d      }|rg S t        j                         j                  d      rg S t        j                         j                  d      s|j                  d      sg S |j                  d      r%t        j                         j                  d	      sg S |j                  d
      }t        j                  |      rg S ||k(  rg S t        j                   j"                  | |fi |}|r(|j%                   | j&                  t(        fd|i|       |S # t        $ r Y w xY w# t        $ r Y -w xY w)zReturns 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.
        FrZ   ry   !usedDescriptionForUnrelatedLabelsr[   speakDescriptionrz   inMouseReviewpresentToolTipspriorObjrI   )r\   r   r]   r   r^   ALERTrl   r}   pop	Exceptionr   r`   ra   r   is_tool_tipr   r8   r~   rc   r;   rd   )r   rI   rJ   alreadyUsedrZ   r   rf   s          r   r~   z$SpeechGenerator._generateDescription   s    xx 1 1# 675::###"ll;;??@YZ"ll;;??@cd I&&(334LMI**,778JK88K(I88O$#..0;;<MNI88J'""8,Is?I$$99$LtLMM*$**V===>A  
  s$   %F# -%F3 #	F0/F03	G ?G c                 0   t        j                         j                  d      rg S t        j                         j                  d      sg S t        j                  j
                  | |fi |}|r(|j                   | j                  t        fd|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`   ra   r   r8   _generateImageDescriptionrc   r;   rd   ri   s       r   r   z)SpeechGenerator._generateImageDescription  s     &&(334LMI**,778JKI$$>>tSQDQMM*$**V===>r!   c                     t        j                  j                  | |fi |}|r(|j                   | j                  t
        fd|i|       |S )zReturns 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   )r   r8   _generateReadOnlyrc   r;   rd   ri   s       r   r   z!SpeechGenerator._generateReadOnly,  sJ     $$66tSIDIMM*$**V===>r!   c                 x   t        j                         j                  d      s4t        j                         j                  d      t        j                  k(  rg S g }t        j                  |      r|j                  t        j                         |r(|j                   | j                  t        fd|i|       |S Nr[   speechVerbosityLevelrI   )r   r`   ra   r   VERBOSITY_LEVEL_BRIEFr   	has_popuprp   r
   	HAS_POPUPrc   r;   rd   ri   s       r   _generateHasPopupz!SpeechGenerator._generateHasPopup7  s    &&(334LM))+667MN001I  %MM(,,-MM*$**V===>r!   c                 N   t        j                         j                  d      s4t        j                         j                  d      t        j                  k(  rg S t        j                  j                  | |fi |}|r(|j                   | j                  t        fd|i|       |S r   )r   r`   ra   r   r   r   r8   _generateClickablerc   r;   rd   ri   s       r   r   z"SpeechGenerator._generateClickableD  s    &&(334LM))+667MN001I$$77cJTJMM*$**V===>r!   c                     t        j                         j                  d      rg S t        j                  j
                  | |fi |}|r(|j                   | j                  t        fd|i|       |S Nr[   rI   )	r   r`   ra   r   r8   _generateHasLongDescrc   r;   rd   ri   s       r   r   z$SpeechGenerator._generateHasLongDescO  se    &&(334LMI$$99$LtLMM*$**V===>r!   c                     t        j                         j                  d      rg S t        j                  j
                  | |fi |}|r(|j                   | j                  t        fd|i|       |S r   )	r   r`   ra   r   r8   _generateHasDetailsrc   r;   rd   ri   s       r   r   z#SpeechGenerator._generateHasDetailsX  e    &&(334LMI$$88sKdKMM*$**V===>r!   c                     t        j                         j                  d      rg S t        j                  j
                  | |fi |}|r(|j                   | j                  t        fd|i|       |S r   )	r   r`   ra   r   r8   _generateDetailsForrc   r;   rd   ri   s       r   r   z#SpeechGenerator._generateDetailsFora  r   r!   c                     t        j                         j                  d      rg S t        j                  j
                  | |fi |}|r(|j                   | j                  t        fd|i|       |S r   )	r   r`   ra   r   r8   _generateAllDetailsrc   r;   rd   ri   s       r   r   z#SpeechGenerator._generateAllDetailsj  r   r!   c                 4   t        j                         j                  d      rg S |j                  dd      }|dk7  rg S g }| j                  j
                  j                  |      rj|j                  t        j                  g       |j                   | j                  t        fd|i|       |j                   | j                  |fi |       |j                  t        j                  g       |j                   | j                  t        fd|i|       |S Nr[   startOffsetr   rI   )r   r`   ra   r\   rl   rm   $isFirstItemInInlineContentSuggestionrc   r   ROLE_CONTENT_SUGGESTIONr;   rd   _generatePauser
   CONTENT_DELETION_STARTr   rI   rJ   r   rf   s        r   _generateDeletionStartz&SpeechGenerator._generateDeletionStarts  s    &&(334LMIhh}a0!I<<!!FFsKMM,DDEFMM*$**V===>MM-$--c:T:;x6678jdjj9S9D9:r!   c                    t        j                         j                  d      rg S |j                  d      }|t	        j
                  |      }|r||k7  rg S t        j                  g}|j                   | j                  t        fd|i|       | j                  j                  j                  |      r|j                   | j                  |fi |       |j                  t        j                  g       |j                   | j                  t        fd|i|       t!        j"                  || j                  j                  j$                        }| j                  j                  j'                  |      rS|j                   | j                  |fi |       |j                  | j)                  ||j                  d                   |S Nr[   	endOffsetrI   mode)r   )r   r`   ra   r\   r   get_character_countr
   CONTENT_DELETION_ENDrc   r;   rd   rl   rm   #isLastItemInInlineContentSuggestionr   CONTENT_SUGGESTION_ENDr   find_ancestor
hasDetailsisContentSuggestionr   r   rI   rJ   r   lengthrf   	containers          r   _generateDeletionEndz$SpeechGenerator._generateDeletionEnd  sr   &&(334LMIHH[)	 //4F&I-	//0jdjj9S9D9:<<!!EEcJMM-$--c:T:;MM8::;<MM*$**V===> ..sDLL4J4J4U4UVI||%%99)D1d11#>>?d66ytxxPVGW6XYr!   c                 4   t        j                         j                  d      rg S |j                  dd      }|dk7  rg S g }| j                  j
                  j                  |      rj|j                  t        j                  g       |j                   | j                  t        fd|i|       |j                   | j                  |fi |       |j                  t        j                  g       |j                   | j                  t        fd|i|       |S r   )r   r`   ra   r\   rl   rm   r   rc   r   r   r;   rd   r   r
   CONTENT_INSERTION_STARTr   s        r   _generateInsertionStartz'SpeechGenerator._generateInsertionStart  s    &&(334LMIhh}a0!I<<!!FFsKMM,DDEFMM*$**V===>MM-$--c:T:;x7789jdjj9S9D9:r!   c                    t        j                         j                  d      rg S |j                  d      }|t	        j
                  |      }|r||k7  rg S t        j                  g}|j                   | j                  t        fd|i|       | j                  j                  j                  |      r|j                   | j                  |fi |       |j                  t        j                  g       |j                   | j                  t        fd|i|       t!        j"                  || j                  j                  j$                        }| j                  j                  j'                  |      rS|j                   | j                  |fi |       |j                  | j)                  ||j                  d                   |S r   )r   r`   ra   r\   r   r   r
   CONTENT_INSERTION_ENDrc   r;   rd   rl   rm   r   r   r   r   r   r   r   r   r   s          r   _generateInsertionEndz%SpeechGenerator._generateInsertionEnd  sr   &&(334LMIHH[)	 //4F&I-	001jdjj9S9D9:<<!!EEcJMM-$--c:T:;MM8::;<MM*$**V===> ..sDLL4J4J4U4UVI||%%99)D1d11#>>?d66ytxxPVGW6XYr!   c                    t        j                         j                  d      rg S |j                  dd      }|dk7  rg S g }| j                  j
                  j                  |      }|r[|j                  |       |j                   | j                  t        fd|i|       |j                   | j                  |fi |       |j                  t        j                         |j                   | j                  t        fd|i|       |S r   )r   r`   ra   r\   rl   rm   getRoleDescriptionrp   rc   r;   rd   r   r
   CONTENT_MARK_START)r   rI   rJ   r   rf   roledescriptions         r   _generateMarkStartz"SpeechGenerator._generateMarkStart  s    &&(334LMIhh}a0!I,,00CCCHMM/*MM*$**V===>MM-$--c:T:;h112jdjj9S9D9:r!   c                 $   t        j                         j                  d      rg S |j                  d      }|t	        j
                  |      }|r||k7  rg S t        j                  g}|j                   | j                  t        fd|i|       |S )Nr[   r   rI   )r   r`   ra   r\   r   r   r
   CONTENT_MARK_ENDrc   r;   rd   )r   rI   rJ   r   r   rf   s         r   _generateMarkEndz SpeechGenerator._generateMarkEnd  s    &&(334LMIHH[)	 //4F&I-	++,jdjj9S9D9:r!   c                     t        j                         j                  d      rg S t        j                  j
                  | |fi |}|r(|j                   | j                  t        fd|i|       |S r   )	r   r`   ra   r   r8   _generateAvailabilityrc   r;   rd   ri   s       r   r   z%SpeechGenerator._generateAvailability  se    &&(334LMI$$::4MMMM*$**V===>r!   c                     t        j                         j                  d      rg S t        j                  j
                  | |fi |}|r(|j                   | j                  t        fd|i|       |S r   )	r   r`   ra   r   r8   _generateInvalidrc   r;   rd   ri   s       r   r   z SpeechGenerator._generateInvalid  se    &&(334LMI$$55dCH4HMM*$**V===>r!   c                     t        j                         j                  d      rg S t        j                  j
                  | |fi |}|r(|j                   | j                  t        fd|i|       |S r   )	r   r`   ra   r   r8   _generateRequiredrc   r;   rd   ri   s       r   r   z!SpeechGenerator._generateRequired  se    &&(334LMI$$66tSIDIMM*$**V===>r!   c                 `   t        j                         j                  d      rg S |j                  d      rg S | j                  j
                  j                  |      r>|j                  dt        j                  |            }| j                         \  }}||v rg S t        j                         j                  d      t        j                  k(  r | j                  |fi |S t        j                  j                  | |fi |}|r(|j!                   | j"                  t$        fd|i|       |S )Nr[   leavingrZ   r   rI   )r   r`   ra   r\   rl   rm   isTextDocumentTabler   r]   "_getEnabledAndDisabledContextRolesr   r   _generateRoleNamer   r8   _generateTablerc   r;   rd   )r   rI   rJ   rZ   enableddisabledrf   s          r   r   zSpeechGenerator._generateTable  s   &&(334LMI88II<<!!55c:88FH$5$5c$:;D $ G G IGXx	&&(334JK,,-)4))#666$$33D#FFMM*$**V===>r!   c                    t        j                         j                  d      rg S g }|j                  dt	        j
                  |            }|t        j                  j                  k7  r"|j                   | j                  |fi |       |S )as  A 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`   ra   r\   r   r]   r   r^   	PARAGRAPHrc   r   )r   rI   rJ   rf   rZ   s        r   _generateTextRolez!SpeechGenerator._generateTextRole  sw     &&(334LMIxx 1 1# 675::'''MM0$00==>r!   c                 ^   t        j                         j                  d      rg S | j                  j                  j                  |      rg S | j                  j                  j                  |      rg S | j                  j                  j                  |      rg S g }|j                  dt        j                  |            }t        j                  j                  t        j                  j                  t        j                  j                  t        j                  j                   g}t        j"                  |      }|t        j                  j$                  k(  r&t'        j(                  |      r| j+                  |      S | j                  j                  j-                  |      rd|j/                  | j1                  |t        j                  j2                               |j5                   | j6                  t8        fd|i|       |S |t        j                  j:                  k(  rt'        j<                  |      rg S t'        j>                  |      r$|j/                  t        j                  |             | j                  j                  jA                  |      r)|j/                  t        j                  jB                         t        j                         j                  d      tD        jF                  k(  rC|j5                  t        j                  jH                  t        j                  jJ                  g       |t        j                  jL                  k(  r| j                  j                  jO                  |      }|r^|j/                  tP        jR                   | j0                  |fi ||dz         |j5                   | j6                  t8        fd|i|       ||vrL|sJ|j/                   | j0                  |fi |       |j5                   | j6                  t8        fd|i|       |S )a5  Returns 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   rZ   rI   r   )rZ   level)*r   r`   ra   rl   rm   isStatusBarNotification	isDesktopisDockedFramer\   r   r]   r   r^   UNKNOWNREDUNDANT_OBJECTFILLEREXTENDEDrq   rk   r   is_combo_boxr   isSingleLineAutocompleteEntryrp   getLocalizedRoleNameAUTOCOMPLETErc   r;   rd   PANELis_selectedis_list_boxisStatusBarDescendantLABELr   r   ICONCANVASHEADINGheadingLevelr   ROLE_HEADING_LEVEL_SPEECH)r   rI   rJ   rf   rZ   doNotPresentru   r   s           r   r   z!SpeechGenerator._generateRoleName0  s    &&(334LMI<<!!99#>I<<!!++C0I<<!!//4Ixx 1 1# 67

**

33

))

++-
 $$S)5::??"{'?'?'G))&11<<!!??DMM$33Cejj>U>U3VWMM*$**V===>M5::###&&s+I ""6* 1 1# 67<<!!77<

 0 01&&(334JK112%**2C2C DE5::%%%LL**77<E/II5D55cBTB"M$ $ % jdjjASADAB|#FMM3$33C@4@AMM*$**V===>r!   c                 8     | j                   |fi |}|r|d   S y)aw  Returns 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.
        r   rO   )r   r   rI   rJ   	generateds       r   getRoleNamezSpeechGenerator.getRoleNamep  s+     +D**37$7	Q<r!   c                 8     | j                   |fi |}|r|d   S y)Nr   rO   )rb   r   s       r   getNamezSpeechGenerator.getName~  s)    &D&&s3d3	Q<r!   c                    | j                   j                  j                  |      s%| j                   j                  j                  |      rt        j
                  S |j                  dt        j                  |            }|t        j                  j                  k(  r%t        j                  |      rt        j                  S t        | @  |fi |S )zReturns the localized name of the given Accessible object; the name
        is suitable to be spoken.

        Arguments:
        - obj: an Accessible object
        rZ   )rl   rm   isEditableComboBoxisEditableDescendantOfComboBoxr   ROLE_EDITABLE_COMBO_BOXr\   r   r]   r   r^   LINKr   
is_visitedROLE_VISITED_LINKrU   r   )r   rI   rJ   rZ   rX   s       r   r   z$SpeechGenerator.getLocalizedRoleName  s     <<!!44S9ll$$CCCH$<<<xx 1 1# 675::??"{'='=c'B$666w+C8488r!   c                    g }| j                   j                  j                  |       }d}|j                  dt	        j
                  |            }|t        j                  j                  k(  s2|t        j                  j                  k(  rt        j                  |      sd}| j                   j                  j                  |||      }|D ]}  } | j                  |fi |}	|	rUt        |	d         dk(  rD| j                   j                  j                  |      rt!        j"                  |	d         }
|
r|
|	d<   |j%                  |	        |r(|j%                   | j&                  t(        fd|i|       |S )zReturns, 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.
        r   rZ      r   rI   )rl   rm   r   r\   r   r]   r   r^   r   DIALOGr   is_message_dialogunrelatedLabelsrb   lenisMathr	   getCharacterNamerc   r;   re   )r   rI   rJ   rf   visibleOnlyminimumWordsrZ   labelslabelrt   charnames              r   r|   z(SpeechGenerator._generateUnrelatedLabels  s@    ,,00HHMMxx 1 1# 675::###EJJ%%%k.K.KC.PL''77[,W 	 E%4%%e4t4DDG)dll.D.D.K.KC.P&77Q@&DGMM$	  MM*$**W>#>>?r!   c                     t        j                         j                  d      rg S t        j                  j
                  | |fi |}|r(|j                   | j                  t        fd|i|       |S a  Returns 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`   ra   r   r8   _generateCheckedStaterc   r;   STATEri   s       r   r  z%SpeechGenerator._generateCheckedState  sg     &&(334LMI$$::4MMMM*$**U<<t<=r!   c                     t        j                         j                  d      rg S t        j                  j
                  | |fi |}|r(|j                   | j                  t        fd|i|       |S )zReturns 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`   ra   r   r8   _generateExpandableStaterc   r;   r  ri   s       r   r  z(SpeechGenerator._generateExpandableState  sg     &&(334LMI$$==dCP4PMM*$**U<<t<=r!   c                     t        j                         j                  d      rg S t        |   |fi |}|r(|j                   | j                  t        fd|i|       |S r   )r   r`   ra   rU    _generateCheckedStateIfCheckablerc   r;   r  r   rI   rJ   rf   rX   s       r   r  z0SpeechGenerator._generateCheckedStateIfCheckable  s]    &&(334LMI9#FFMM*$**U<<t<=r!   c                     t        j                         j                  d      rg S t        j                  j
                  | |fi |}|r(|j                   | j                  t        fd|i|       |S )zReturns 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`   ra   r   r8   _generateMenuItemCheckedStaterc   r;   r  ri   s       r   r  z-SpeechGenerator._generateMenuItemCheckedState  sl    
 &&(334LMI$$))$=7;=MM*$**U<<t<=r!   c                     t        j                         j                  d      rg S t        |   |fi |}|r(|j                   | j                  t        fd|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`   ra   rU   _generateMultiselectableStaterc   r;   r  r  s       r   r  z-SpeechGenerator._generateMultiselectableState  s_     &&(334LMI6sCdCMM*$**U<<t<=r!   c                     t        j                         j                  d      rg S t        j                  j
                  | |fi |}|r(|j                   | j                  t        fd|i|       |S r  )	r   r`   ra   r   r8   _generateRadioStaterc   r;   r  ri   s       r   r  z#SpeechGenerator._generateRadioState  sg     &&(334LMI$$88sKdKMM*$**U<<t<=r!   c                     t        j                         j                  d      rg S t        j                  j
                  | |fi |}|r(|j                   | j                  t        fd|i|       |S )z?Returns an array of strings indicating the on/off state of obj.r[   rI   )	r   r`   ra   r   r8   _generateSwitchStaterc   r;   r  ri   s       r   r  z$SpeechGenerator._generateSwitchState  se    &&(334LMI$$99$LtLMM*$**U<<t<=r!   c                     t        j                         j                  d      rg S t        j                  j
                  | |fi |}|r(|j                   | j                  t        fd|i|       |S r  )	r   r`   ra   r   r8   _generateToggleStaterc   r;   r  ri   s       r   r  z$SpeechGenerator._generateToggleState  sg     &&(334LMI$$99$LtLMM*$**U<<t<=r!   c                 <   g }t        j                  |      }|sv|j                  | j                  |             |j                  | j	                  |             |j                  | j                  j                  j                  |             nbt        j                  j                  |      }|d   dv r@|d   j                  d      }|j                  t        j                  |d   |d   dz         nt        j                  |d   z  }| j                  j                  j                  |      }t!        j"                  |      }	|	st        j                  |d   z  }nt        j$                  |d   z  }|st        j&                  |      }|r|d|z   z  }|j                  |       t)        j*                  |d      }
t!        j,                  |
      r |j                  | j	                  |
             |r(|j                   | j.                  t0        fd|i|       |S )	zReturns 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"  rP   rI   )r   get_link_urirc   rh   r   rp   rl   rm   displayedTexturllibparseurlparsesplitr
   LINK_TO_FILELINK_WITH_PROTOCOLr   r   LINK_WITH_PROTOCOL_VISITEDget_link_basenamer   	get_childis_imager;   rd   )r   rI   rJ   rf   link_urilink_uri_infofileName
linkOutputtext	isVisitedchilds              r   _generateLinkInfoz!SpeechGenerator._generateLinkInfo%  s   
 
 ++C0 MM$--c23MM$0056MM$,,00>>sCD"LL11(;MQ#::(+11#6h33)6q)9*22,!88 9 &88=;KK
||--;;C@'2237	 !)!<!<}Q?O!OJ!)!D!D}UVGW!WJ '88=D#*,Jj) **32''.MM$"8"8"?@MM*$**V===>r!   c                    | j                   j                  j                  |      sg S t        j                  |      }|sg S t
        j                  j                  |      }t        j                  | j                   j                  j                               }|sg S g }t
        j                  j                  |      }|d   |d   k(  rK|d   |d   k(  r |j                  t        j                         n|j                  t        j                         n|d   j                  d      }|d   j                  d      }	t!        |      dkD  rDt!        |	      dkD  r6|d   |	d   k(  r+|d   |	d   k(  r |j                  t        j                         n|j                  t        j"                         |r(|j%                   | j&                  t(        fd|i|       |S )Nr   r#  .r%  rI   )rl   rm   inDocumentContentr   r'  r)  r*  r+  r   get_uridocumentFramerp   r
   LINK_SAME_PAGELINK_SAME_SITEr,  r  LINK_DIFFERENT_SITErc   r;   rd   )
r   rI   rJ   r3  r4  doc_urirf   doc_uri_info
linkdomain	docdomains
             r   _generateSiteDescriptionz(SpeechGenerator._generateSiteDescriptionY  s   ||%%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)//4J$Q--c2I:"s9~'9b>Yr]2b>Yr]2h556h::;MM*$**V===>r!   c                    g }d}t        j                  |      }|s|S 	 t        j                  j	                  |      }	 |j                         d   }|rt        |      }|dk  r%|j                  t        j                  |             ng|dk  r/|j                  t        j                  t!        |      dz  z         n3|dk\  r.|j                  t        j"                  t!        |      dz  z         |r(|j%                   | j&                  t(        fd|i|       |S # t        $ r Y w xY w# t        t        j                  j                  t        f$ r Y w xY w)zReturns 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.
        rO   zContent-lengthi'  i@B gMbP?gư>rI   )r   r'  r)  requesturlopeninfoKeyError
ValueErrorerrorURLErrorOSErrorintrp   r
   fileSizeBytesFILE_SIZE_KBfloatFILE_SIZE_MBrc   r;   rd   )r   rI   rJ   rf   
sizeStringr&  rB   sizes           r   _generateFileSizez!SpeechGenerator._generateFileSize|  s.    
&&s+M	&&s+AVVX&67

 z?De|h44T:;h33uT{T7IJKh33uT{W7LMNMM*$**V===>  FLL117; 		s.   D+ D 	D(%D+ 'D((D+ +(EEc                     t        j                  |      sg S t        j                  j                  |d<    | j
                  |fi |S )zReturns 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_imager   r^   IMAGErD   r   rI   rJ   s      r   _generateImagezSpeechGenerator._generateImage  s@     &&s+Izz''Vt}}S)D))r!   c                     | j                   j                         rg S t        |   |fi |}|r(|j	                   | j
                  t        fd|i|       |S NrI   )rl   inSayAllrU   _generateColumnHeaderrc   r;   re   r  s       r   rb  z%SpeechGenerator._generateColumnHeader  sU    <<  "I.s;d;MM*$**W>#>>?r!   c                     | j                   j                         rg S t        |   |fi |}|r(|j	                   | j
                  t        fd|i|       |S r`  )rl   ra  rU   _generateRowHeaderrc   r;   re   r  s       r   rd  z"SpeechGenerator._generateRowHeader  sU    <<  "I+C848MM*$**W>#>>?r!   c                 |    t        |   |fi |}|r(|j                   | j                  t        fd|i|       |S r`  )rU   _generateSortOrderrc   r;   rd   r  s       r   rf  z"SpeechGenerator._generateSortOrder  s@    +C848MM*$**V===>r!   c                    | j                   j                  j                  ||j                  d            sg S |j                  d      rg S t	        j
                         j                  d      sg S d|d<    | j                  |fi |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)rl   rm   cellRowChangedr\   r   r`   ra   rd  r]  s      r   _generateNewRowHeaderz%SpeechGenerator._generateNewRowHeader  s{     ||%%44S$((::NOI88L!I**,778JKIY&t&&s3d33r!   c                    | j                   j                  j                  ||j                  d            sg S |j                  d      rg S t	        j
                         j                  d      sg S d|d<    | j                  |fi |S )a  Returns 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   rh  ri  Trj  )rl   rm   cellColumnChangedr\   r   r`   ra   rb  r]  s      r   _generateNewColumnHeaderz(SpeechGenerator._generateNewColumnHeader  s{     ||%%77TXXj=QRI88L!I**,778JKIY)t))#666r!   c                    g }| j                  d|      }|j                   | j                  |fi |       | j                  ||       |r|d   st	        j
                         j                  d      ro|j                  dd      s]|j                  d      dk7  rI|j                  t        j                         |r(|j                   | j                  t        fd|i|       |S )	ah  Orca 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   speakBlankLinesrh  F
formatTypeancestorrI   )_overrideRolerc   rD   _restoreRoler   r`   ra   r\   rp   r
   BLANKr;   re   )r   rI   rJ   rf   oldRoles        r   _generateRealTableCellz&SpeechGenerator._generateRealTableCell  s     $$%;TBmdmmC0401'4(6!9**,778IJ88L%0xx%3MM(..)jdjjBcBTBCr!   c                 r   t        j                         j                  d      rg S |j                  d      rg S |sg S t	        j
                  t	        j                  |            sg S t        j                  |      rg S t        j                  g}|j                   | j                  t        fd|i|       |S )Nr[   r   rI   )r   r`   ra   r\   r   supports_selectionrq   r   r   r   STATE_UNSELECTED_LIST_ITEMrc   r;   r  ri   s       r   $_generateUnselectedStateIfSelectablez4SpeechGenerator._generateUnselectedStateIfSelectable  s    &&(334LMI88O$II**8+>+>s+CDI""3'I#>>?jdjj8C8489r!   c                    t        j                         j                  d      rg S |j                  d      rg S |sg S t	        j
                  |      }t	        j                  |      sg S t        j                  |      rg S t        j                  |      rg S t        j                  |      }|rT| j                  j                  j                         \  }}|dv rg S | j                  j                  j                  |      rBg S t        j                   |      r)|| j                  j                  j#                  |      v rg S g S t$        j&                  g}|j)                   | j*                  t,        fd|i|       |S )aj  Returns 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`   ra   r\   r   rq   r{  r   r   is_textr   	get_tablerl   rm   lastKeyAndModifiersisLayoutOnlyis_layered_paneselectedChildrenr   STATE_UNSELECTED_TABLE_CELLrc   r;   r  )r   rI   rJ   ru   tablelastKeymodsrf   s           r   _generateUnselectedCellz'SpeechGenerator._generateUnselectedCell&  sF    &&(334LMI88O$II$$S)**62I""3'Is#I!!#& LL22FFHMGT++	||%%2259	((0dll,,==fEE	I#??@jdjj8C8489r!   c                     | j                   j                  j                  |      sg S |j                  d      rg S t	        j
                         j                  d      sg S  | j                  |fi |S Nrh  speakCellCoordinates)rl   rm   rn  r\   r   r`   ra   _generateColumnr]  s      r   _generateNewColumnz"SpeechGenerator._generateNewColumnS  se    ||%%77<I88L!I**,778NOI#t##C0400r!   c                    t        j                         j                  d      rg S t        j                  |d      d   }|dk(  rg S t
        j                  |dz   z  g}|j                   | j                  t        fd|i|       |S )zReturns an array of strings (and possibly voice and audio
        specifications) reflecting the column number of a cell.
        r[   T	find_cellr   r%  rI   )
r   r`   ra   r   get_cell_coordinatesr
   TABLE_COLUMNrc   r;   rd   )r   rI   rJ   colrf   s        r   r  zSpeechGenerator._generateColumn_  s     &&(334LMI**3$?B"9I''3734jdjj9S9D9:r!   c                     | j                   j                  j                  |      sg S |j                  d      rg S t	        j
                         j                  d      sg S  | j                  |fi |S r  )rl   rm   rk  r\   r   r`   ra   _generateRowr]  s      r   _generateNewRowzSpeechGenerator._generateNewRown  se    ||%%44S9I88L!I**,778NOI t  ---r!   c                    t        j                         j                  d      rg S t        j                  |d      d   }|dk(  rg S t
        j                  |dz   z  g}|j                   | j                  t        fd|i|       |S )zReturns an array of strings (and possibly voice and audio
        specifications) reflecting the row number of a cell.
        r[   Tr  r   r%  r   rI   )
r   r`   ra   r   r  r
   	TABLE_ROWrc   r;   rd   )r   rI   rJ   rowrf   s        r   r  zSpeechGenerator._generateRowz  s     &&(334LMI**3$?B"9I$$a01jdjj9S9D9:r!   c                    t        j                         j                  d      rg S t        j                  |d      \  }}|dk(  s|dk(  rg S t        j
                  |      }|g S g }t        j                  |      }t        j                  |      }|j                  t        j                  |dz   |dz         |j                  t        j                  |dz   |dz         |j                   | j                  t        fd|i|       |S )zReturns 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`   ra   r   r  r  get_row_countget_column_countrp   r
   TABLE_COLUMN_DETAILEDTABLE_ROW_DETAILEDrc   r;   rd   )	r   rI   rJ   r  r  r  rf   rowscolumnss	            r   _generateColumnAndRowz%SpeechGenerator._generateColumnAndRow  s     &&(334LMI//tDS"9r	I!!#&=I$$U+**51h4437W^7__`h11aTX4YYZjdjj9S9D9:r!   c                 \   t        j                         j                  d      rg S t        j                         j                  d      t        j                  k7  rg S t        j                  |      r;t        j                  g}|j                   | j                  t        fd|i|       |S g S )zReturns 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`   ra   r   VERBOSITY_LEVEL_VERBOSEr   is_last_cellr
   	TABLE_ENDrc   r;   rd   ri   s       r   _generateEndOfTableIndicatorz,SpeechGenerator._generateEndOfTableIndicator  s    
 &&(334LMI&&(334JK../I$(()FMM*$**V===>M	r!   c                    |j                  d      rt        j                  |      rg S  | j                  |fi |}|r|d   r|S | j                  j                  |      \  }}}|dk(  rt        j                         j                  d      rz| j                  j                         s`|j                  dd      dk(  rK|j                  d      dk7  r7t        j                  g}|j                   | j                  d||d	|       |S g }|t        |      z   }| j                  j                  j!                  |||      }|D ]  \  }	}
}}}|j#                  | j                  j$                  d
      }|s3||c|d<   |d<   d|v rNd|j                  d       d| d}t'        j(                  t&        j*                  |d       |j-                  d        | j                  d||d	|}| j                  j                  j/                  |||	      }| j                  j                  j1                  |      g}|j                  |       |j                  |        |S )zReturns 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   
rr  r  r   rs  rt  )stringrI   rO   languagedialectr  zINFO: Found existing string 'z
'; using ''Tr   )r\   r   is_editable_generateSubstringrl   getTextLineAtCaretr   r`   ra   ra  r
   rw  rc   r;   r  rm   splitSubstringByLanguagereplaceEMBEDDED_OBJECT_CHARACTERr   printMessagerH   r   adjustForLinksadjustForRepeats)r   rI   rJ   rf   r7  caretOffsetr   r   r,  startendr  r  r  msgr;   rK   s                    r   _generateCurrentLineTextz(SpeechGenerator._generateCurrentLineText  s+    88O$&&s+I(((55fQiM+/<<+J+J3+O({K4<,779DDEVW<<((*txx/Cq/Hxx%3nn%FMM*$**BDcBTBCM#d)+	&&??[R[\5: 	1E3'^^DLL$J$JBOF08'-Dd9o45dhhx6H5ITZS[[\]""5#3#3S$?"DJJ>f#>>E\\++::3NF,,((99&ABBIIe MM"'	* r!   c                     | j                   |fi |}|r|d   r|S t        j                  j                  | |fi |}|r|d   sg S |d   j	                         }t        |      dk(  rD| j                  j                  j                  |      rt        j                  |      }||k7  r||d<   |j                   | j                  t        fd|i|       |S )Nr   r   rI   )r  r   r8   _generateDisplayedTextstripr  rl   rm   r  r	   r  rc   r;   re   )r   rI   rJ   rf   r  r  s         r   r  z&SpeechGenerator._generateDisplayedText  s    (((55fQiM$$;;D#NN6!9I"v;! 6 6 = =c B"33F;H6!$q	jdjj:c:T:;r!   c                 x   	 | j                   j                  d   S # t        $ r Y nw xY w| j                   j                  j	                  |      \  }}}|dk7  }|sbt        j                  |      \  }}}|r(| j                   j                  j                  |      }|}nt        j                  |      d   }|dk(  r|}| j                   j                  j                  |      r%| j                   j                  j                  |      }||||g| j                   j                  d<   | j                   j                  d   S )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.
        textInformationrO   r   r  )rl   generatorCacher   rm   allSelectedTextr   get_line_at_offsetr  get_character_at_offsetshouldVerbalizeAllPunctuationverbalizeAllPunctuation)r   rI   textContentsr   r   selectedlinechars           r   _getTextInformationz#SpeechGenerator._getTextInformation  s'   	<<../@AA 		 04||/E/E/U/UVY/Z,k92%+1+D+DS+I(D+y||-->>tD#55c:1=4<#'L<<!!??D<<11II,WL ;	8< 	##$56 ||**+<==s    	''c                      | j                   |fi |}|r|S | j                  |      d   }|sg S |g}|j                   | j                  t        fd|i|       |S )zReturns 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.
        r   rI   )r  r  rc   r;   re   )r   rI   rJ   rf   r  s        r   _generateTextContentz$SpeechGenerator._generateTextContent&  sm     )((55M'',Q/Ijdjj:c:T:;r!   )styleweight	underlinec                 &   t        j                  ||      \  }}}|syd}|D ]  }|j                  |      }	|	st        j                  || j
                        }
t        j                  |	| j
                        }|dk(  r&t        |	      dkD  sk|dt        j                   z  }|dk(  r|	dk7  s|d|
 z  }|dk(  r|	dk7  s|d| z  }|dz  }||
dz   |z   z  } t        j                  |||d	z         r|dt        j                   z  }|||fS )
NrO   r  i  rP   r  noner  normalr   )r   get_text_attributes_at_offsetr\   r   getTextAttributeNamerl   rR  r
   BOLDr   get_all_links_in_ranger   )r   rI   offsetkeysattrsr  r  rf   key	attributelocalizedKeylocalizedValues               r   _getAttributesStringAndOffsetsz.SpeechGenerator._getAttributesStringAndOffsets8  s:   "@@fMuc 	@C		#I/DDS$,,WL1FFyRVR^R^_Nhy>C'(--11F#&,00F(.!122F#<#->?%	@( --c66A:F(--))Fuc!!r!   c           	      X   | j                  |      \  }}}}d}|}||k  r>| j                  ||      \  }	}
}|d|	 dt        j                  ||
|       z  }|}||k  r>| j                  ||dg      d   }	|	r|d|	 z  }|g}|j	                   | j
                  t        fd|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.
        rO   rP   zparagraph-styler   rI   )r  r  r   get_substringrc   r;   re   )r   rI   rJ   r  r   r   r  newLine
textOffsetattribsr  r  rf   s                r   "_generateTextContentWithAttributesz2SpeechGenerator._generateTextContentWithAttributesW  s     483K3KC3P0{Ix 
9$"&"E"Ec:"VGUC7)1V%9%9#uc%J$KLLGJ 9$
 55c;IZH[\]^_7)}$Gjdjj:c:T:;r!   c                     t        j                         j                  d      rg S t        j                  |      sg S t
        j                  g}|j                   | j                  t        fd|i|       |S )zReturns 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`   ra   r   has_selected_textr
   TEXT_SELECTEDrc   r;   rd   ri   s       r   _generateAnyTextSelectionz)SpeechGenerator._generateAnyTextSelectiono  sh     &&(334LMI'',I(()jdjj9S9D9:r!   c                     t        j                         j                  d      rg S t        j                  |      sg S t
        j                  g}|j                   | j                  t        fd|i|       |S )zReturns 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`   ra   r   is_all_text_selectedr
   r  rc   r;   rd   ri   s       r   _generateAllTextSelectionz)SpeechGenerator._generateAllTextSelection  sh     &&(334LMI**3/I(()jdjj9S9D9:r!   c                 *   t        |   |fi |}|r|d   sg S |j                   | j                  t        fd|i|       |d   dv ryt        j                         j                  d      rV| j                  j                         s<|j                  dd      dk(  r'|j                  d      dk7  rt        j                  |d<   | j                  j                  j                  |      r+| j                  j                  j                  |d         |d<   |S )	Nr   rI   )r  rO   rr  r  r   rs  rt  )rU   r  rc   r;   re   r   r`   ra   rl   ra  r\   r
   rw  rm   r  r  r  s       r   r  z"SpeechGenerator._generateSubstring  s    +C8486!9Ijdjj:c:T:;!9
"'7'B'B'D'O'OPa'b<<((*txx/Cq/Hxx%3 F1I<<!!??D..FFvayQF1Ir!   c                 6   t        j                         j                  d      sg S | j                  j	                  |      \  }}}| j                  j
                  j                  |      }|sg S |g}|j                   | j                  t        fd|i|       |S )zSpeaks 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`   ra   rl   r  rm   indentationDescriptionrc   r;   rd   )r   rI   rJ   r  r  r   descriptionrf   s           r   _generateTextIndentationz(SpeechGenerator._generateTextIndentation  s      **,778QRI)-)H)H)M&k;ll,,CCDIIjdjj9S9D9:r!   c                 |    t        |   |fi |}|r(|j                   | j                  t        fd|i|       |S r`  )rU   _generateNestingLevelrc   r;   rd   r  s       r   r  z%SpeechGenerator._generateNestingLevel  s@    .s;d;MM*$**V===>r!   c                    t        j                         j                  d      rg S g }| j                  j                  j                  |j                  dd            }| j                  j                  j                  |      }||k7  rO|dk\  rJ|j                   | j                  |fi |       |j                   | j                  t        fd|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   Nr   rI   )r   r`   ra   rl   rm   	nodeLevelr\   rc   _generateNodeLevelr;   rd   )r   rI   rJ   rf   oldLevelnewLevels         r   _generateNewNodeLevelz%SpeechGenerator._generateNewNodeLevel  s     &&(334LMI<<))33DHHZ4NO<<))33C8 x1}MM1$11#>>?MM*$**V===>r!   c                 |    t        |   |fi |}|r(|j                   | j                  t        fd|i|       |S r`  )rU   _generateValuerc   r;   re   r  s       r   r  zSpeechGenerator._generateValue  s@    '4t4MM*$**W>#>>?r!   c                     t        j                         j                  d      rg S t        j                  |      }|@t        j                  |      g}|j                   | j                  t        fd|i|       |S g S )a  Returns 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`   ra   r   get_value_as_percentr
   
percentagerc   r;   rd   )r   rI   rJ   percentValuerf   s        r   _generatePercentagez#SpeechGenerator._generatePercentage  su     &&(334LMI33C8#)),78FMM*$**V===>M	r!   c                 h   t        j                  |      sg S t        |   |fi |}|sg S |j	                   | j
                  t        fd|i|       |j                  dd      }t        j                  |      s|S t        j                  |t        j                  j                        }||vr|S g S )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.
        rI   r   N)r   is_radio_buttonrU   _generateRadioButtonGrouprc   r;   re   r\   r   get_relation_targetsr   RelationType	MEMBER_OF)r   rI   rJ   rf   r   membersrX   s         r   _generateNewRadioButtonGroupz,SpeechGenerator._generateNewRadioButtonGroup  s     **3/I23?$?Ijdjj:c:T:;88J-**84M //U5G5G5Q5QR7"M	r!   c                     | j                   j                  j                  |      }|dv rg S t        j                  |      g}|j                   | j                  t        fd|i|       |S )N)r%  r   rI   )rl   rm   getValueCountForTermr
   valueCountForTermrc   r;   rd   )r   rI   rJ   countrf   s        r   _generateTermValueCountz'SpeechGenerator._generateTermValueCount  sb    &&;;C@GI,,U34jdjj9S9D9:r!   c                 x   t        j                         j                  d      s4t        j                         j                  d      t        j                  k(  rg S g }| j
                  j                  j                  |      }t        |      }|rN|j                  t        j                  |             |j                   | j                  t        fd|i|       |S |j                  dt!        j"                  |            }|t$        j&                  j(                  t$        j&                  j*                  fv r~t!        j,                  |t.        j0                        D cg c]  }| }}t        |      }|sg S t        j2                  |      g}|j                   | j                  t        fd|i|       |S c c}w )a5  Returns 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   rI   rZ   )r   r`   ra   r   r   rl   rm   
childNodesr  rp   r
   	itemCountrc   r;   rd   r\   r   r]   r   r^   LISTLIST_BOXiter_childrenr   is_list_itemlistItemCount)	r   rI   rJ   rf   r  childrenrZ   rB   setsizes	            r   _generateNumberOfChildrenz)SpeechGenerator._generateNumberOfChildren   s_    &&(334LM))+667MN001I\\++66s;
z?MM(,,X67MM*$**V===>Mxx 1 1# 67EJJOOUZZ%8%899#+#9#9#{?W?W#XYaYHY(mG	,,W56FMM*$**V===> Zs   	F7c                 N   t        j                         j                  d      rg S g }t        d t	        j
                  |t        j                        D              }|sG|j                  t        j                         |j                   | j                  t        fd|i|       |S )ah  Returns 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[   c              3       K   | ]  }d   yw)TNr   ).0_s     r   	<genexpr>z=SpeechGenerator._generateNoShowingChildren.<locals>.<genexpr>M  s     YtYs   rI   )r   r`   ra   anyr   r  r   
is_showingrp   r
   
ZERO_ITEMSrc   r;   rd   )r   rI   rJ   rf   hasItemss        r   _generateNoShowingChildrenz*SpeechGenerator._generateNoShowingChildrenA  s     &&(334LMIYX%;%;CAWAW%XYYMM(--.MM*$**V===>r!   c                    t        j                         j                  d      rg S g }t        j                  |      sG|j                  t        j                         |j                   | j                  t        fd|i|       |S )ah  Returns 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`   ra   r   get_child_countrp   r
   r&  rc   r;   rd   ri   s       r   _generateNoChildrenz#SpeechGenerator._generateNoChildrenS  sl     &&(334LMI'',MM(--.MM*$**V===>r!   c                    g }|j                  dt        j                  |            }|t        j                  j
                  t        j                  j                  fvr|S t        j                  |      r&| j                  j                  j                  |      }nt        j                  |      g}|r|d   s|S t        | j                  |      D ]  }|j                  |        |S )NrZ   r   )r\   r   r]   r   r^   r  r  r{  rl   rm   r  r   get_focused_objectmaprb   rc   )r   rI   rJ   rf   rZ   itemsitems          r   _generateFocusedItemz$SpeechGenerator._generateFocusedItemd  s    xx 1 1# 67

)<)<==M&&s+LL**;;C@E 33C89E%(M**E2 	 DMM$	  r!   c                    t        j                         j                  d      rg S |}t        j                  |      s,t        j
                  |      }t        j                  |      sg S g }t        j                  |      }t        | j                  j                  j                  |            }|j                  t        j                  ||             |j                   | j                  t         fd|i|       |j                  | j                  j"                  j%                  dd      t        j&                  |      dz   |dz         |j                   | j                  t         fd|i|       |S )zReturns 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[   rI   r   	iconindexr   
stringTyper   r  )r   r`   ra   r   r{  rq   r*  r  rl   rm   r  rp   r
   selectedItemsCountrc   r;   rd   
formatting	getStringget_index_in_parent)r   rI   rJ   r   rf   
childCountselectedCounts          r   _generateSelectedItemCountz*SpeechGenerator._generateSelectedItemCountv  s=    &&(334LMI	**95 ++C0I..y9	--i8
DLL22CCINOh11-LMjdjj9S9D9:dll--77'%0 8 2 $,#?#?#Dq#H#-// 	0
 	jdjj9S9D9:r!   c                 Z   t        j                         j                  d      rg S |}t        j                  |      s,t        j
                  |      }t        j                  |      sg S | j                  j                  j                  |      }t        t        | j                  |            S )zReturns 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`   ra   r   r{  rq   rl   rm   r  rE   r.  _generateLabelAndName)r   rI   rJ   r   selectedItemss        r   _generateSelectedItemsz&SpeechGenerator._generateSelectedItems  s     &&(334LMI	**95 ++C0I..y9	..??	JC22MBCCr!   c                 (     | j                   |fi |S r   )r@  r]  s      r   generateSelectedItemsz%SpeechGenerator.generateSelectedItems  s    *t**37$77r!   c                 d   t        j                         j                  d      rg S g }	 | j                  j                  j                  |      }|dkD  rL|j                  t        j                  |             |j                   | j                  t        fd|i|       |S # t        $ r d}Y `w xY w)a  Returns 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[   r   rI   )r   r`   ra   rl   rm   unfocusedAlertAndDialogCountr   rp   r
   dialogCountSpeechrc   r;   rd   )r   rI   rJ   rf   alertAndDialogCounts        r   _generateUnfocusedDialogCountz-SpeechGenerator._generateUnfocusedDialogCount  s     &&(334LMI
	$&&CCCH   "MM(445HIJMM*$**V===>  	$"#	$s   %B! !B/.B/c                 
   t         j                  j                  ddddddt         j                  j                  dt         j                  j                  t         j                  j
                  t         j                  j                  t         j                  j                  dt         j                  j                  t         j                  j                  g}g g }}| j                  j                         r&t        j                         j                  d	      r)|j                  t         j                  j                         t        j                         j                  d
      r+|j!                  t         j                  j
                  dg       t        j                         j                  d      rc|j                  t         j                  j                         |j                  t         j                  j                         |j                  d       t        j                         j                  d      rH|j!                  t         j                  j                  t         j                  j                  dddddg       t        j                         j                  d      r)|j                  t         j                  j                         t        j                         j                  d      rO|j                  t         j                  j                         n$t        j                         j                  d      r)|j                  t         j                  j                         t        j                         j                  d      r,|j!                  t         j                  j
                  ddg       t        j                         j                  d      rc|j                  t         j                  j                         |j                  t         j                  j                         |j                  d       t        j                         j                  d      rH|j!                  t         j                  j                  t         j                  j                  dddddg       t        j                         j                  d      r)|j                  t         j                  j                         t        j                         j                  d      r)|j                  t         j                  j                         t#        t%        |      j'                  |            }||fS )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)r   r^   BLOCK_QUOTEDESCRIPTION_LISTFORMLANDMARKr  r   TABLETOOL_TIPrl   ra  r   r`   ra   rp   rc   rE   setsymmetric_difference)r   allRolesr   r   s       r   r   z2SpeechGenerator._getEnabledAndDisabledContextRoles  s   JJ**+,'-('JJ//JJOOJJ''JJOOJJ$$!JJ$$JJ'')" <<  "**,778QRuzz556**,778OP

 3 35IJK**,778KLuzz/uzz::;{+**,778LM

 0 0 %

 3 3 7 8 3 9 3 5 6  **,778VWuzz/**,778LMuzz//0**,778PQuzz556**,778NO

 3 35I=YZ**,778JKuzz/uzz::;{+**,778KL

 0 0 %

 3 3 7 8 3 9 3 5 6  **,778UVuzz/**,778KLuzz//0H::7CD  r!   c                    |j                  d      sg S |j                  dt        j                  |            }| j                         \  }}||v s'| j                  j
                  j                  |      sg S |j                  dd      }g }| j                  j
                  j                  |      r!|j                  t        j                         nH|t        j                  j                  k(  rL|dkD  r&|j                  t        j                  |             n |j                  t        j                         n|t        j                  j                  t        j                  j                   fv rq| j                  j
                  j#                  |      rL|dkD  r&|j                  t        j$                  |             nY|j                  t        j&                         n8|dk(  r!|j                  t        j(                         n|t        j                  j*                  k(  r| j                  j
                  j-                  |      r!|j                  t        j.                         n| j                  j
                  j1                  |      r!|j                  t        j2                         nidg}nd|t        j                  j4                  k(  rF| j                  j
                  j7                  |      r!|j                  t        j8                         n|dk(  r3| j                  j
                  j;                  |      r!|j                  t        j<                         
n| j                  j
                  j?                  |      r!|j                  t        j@                         
no| j                  j
                  jC                  |      r!|j                  t        jD                         
n)| j                  j
                  jG                  |      r!|j                  t        jH                         	n| j                  j
                  jK                  |      r!|j                  t        jL                         	n| j                  j
                  jO                  |      r!|j                  t        jP                         	nW| j                  j
                  jS                  |      r!|j                  t        jT                         	n| j                  j
                  jW                  |      r!|j                  t        jX                         n| j                  j
                  j[                  |      r!|j                  t        j\                         n| j                  j
                  j_                  |      r!|j                  t        j`                         n?| j                  j
                  jc                  |      r!|j                  t        jd                         n| j                  j
                  jg                  |      r!|j                  t        jh                         n| j                  j
                  jk                  |      r!|j                  t        jl                         nm| j                  j
                  jo                  |      r!|j                  t        jp                         n'| j                  j
                  js                  |      r!|j                  t        jt                         n| j                  j
                  jw                  |      r!|j                  t        jx                         n| j                  j
                  j{                  |      r!|j                  t        j|                         nU| j                  j
                  j                  |      r!|j                  t        j                         n| j                  j
                  j                  |      r|j                  t        j                         n|dk(  r1| j                  j
                  j                  |      r!|j                  t        j                         n|| j                  j
                  j                  |      r!|j                  t        j                         n6| j                  j
                  j                  |      r!|j                  t        j                         n| j                  j
                  j                  |      r!|j                  t        j                         n| j                  j
                  j                  |      r!|j                  t        j                         nd| j                  j
                  j                  |      r!|j                  t        j                         n| j                  j
                  j                  |      r!|j                  t        j                         n| j                  j
                  j                  |      r|j                  t        j                         n| j                  j
                  j                  |      r5| j                  j
                  j                  |      r!|j                  t        j                         n%| j                  j
                  j                  |      r!|j                  t        j                         n| j                  j
                  j                  |      r!|j                  t        j                         n| j                  j
                  j                  |      r!|j                  t        j                         nS| j                  j
                  j                  |      r!|j                  t        j                         n| j                  j
                  j                  |      r!|j                  t        j                         n| j                  j
                  j                  |      r!|j                  t        j                         n| j                  j
                  j                  |      r!|j                  t        j                         n;dg}n6|t        j                  j                  k(  r |j                  t        j                         n|t        j                  j                  k(  r |j                  t        j                         n|d	k(  r |j                  t        j                         n|d
k(  r |j                  t        j                         nr|dk(  r |j                  t        j                         nM|dk(  rE| j                  j
                  j                  |      s |j                  t        j                         ndg}|r(|j                   | j                  t        fd|i|       |S )Nr   rZ   r  r   rN  rO   rL  rM  rI  rJ  rK  r   rI   )or\   r   r]   r   rl   rm   	isDetailsrp   r
   LEAVING_DETAILSr   r^   r\  leavingNBlockquotesLEAVING_BLOCKQUOTEr  r]  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_SUGGESTIONrc   r;   rd   )r   rI   rJ   rZ   r   r   r  rf   s           r   _generateLeavingz SpeechGenerator._generateLeaving  s   xx	"Ixx 1 1# 67 CCE4<<#9#9#C#CC#HI!$<<!!++C0MM(223UZZ+++qyh::5ABh99:ejjoouzz'B'BCC&&55c:qyh44U;<h334[ MM(//0UZZ%%%||%%..s3h556''77<h445UZZ%%%$,,*@*@*T*TUX*YMM(001))||%%;;C@h>>?''77<h889''66s;h778''::3?h;;<''55c:h667''88=h99:''55c:h667''66s;h778''66s;h778''44S9h556''66s;h778''66s;h778''33C8h445''::3?h;;<''66s;h778''2237h334''55c:h667''66s;h778''11#6h223((||%%44S9h778''66s;h778''44S9h556''88=h99:''66s;h778''55c:h667''77<h889''11#6h223\\##..s3||%%66s;h>>?''??DhEEF''==cBhCCD''66s;h<<=''<<SAhBBC''88=h>>?''88=h>>?''66s;h334UZZ__$MM(//0UZZ(((MM(334,,MM(778--MM(889((MM(334..\\++>>sCMM(556TFMM*$**V===>r!   c                 <	    g }|j                  d      }|r%|j                  d      r|}|j                  d      }n|j                  d      }|rt        j                  |      rg S t        j                  |      rg S |r-t        j
                  |      t        j
                  |      k(  rg S  j                  j                  j                  |      rg S t        j                  |      rg S t        j                  |      rg S  j                  j                  j                  ||      }||k(  rg S |j                  dg       }|j                  dg       }|j                  t        j                  j                          j                         \  }	}
|j!                  |
       |j                  dg       }|j!                  t        j                  j"                  t        j                  j$                  g       |j                  dg       }|j!                  t        j                  j&                  g       t        j                  j(                  t        j                  j*                  g}d}|r|s j-                  |      |v r fd}t        j.                  ||      }t        j.                  ||      } j                  j                  j1                  |      } j                  j                  j1                  |      }||k7  }g g }}t        j2                  |      }|rމ j-                  |      }||v rn||v r& j                  j                  j5                  |      sn||r||vrnu j                  j                  j7                  |      rnO j                  j                  j9                  |      rn)||k7  s|r"|j                  |       |j                  |       ||k(  s||v rnt        j2                  |      }|rg }t;        |      D ]  \  }}||   }||v r||v r|j                  |       |j=                  |      } j?                  ||       |j                   jA                  |d	|||||
              jC                  ||        |s|jE                          |S )aE  Returns 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(  S r   )_getAlternativeRole)rB   
commonRoler   s    r   predz0SpeechGenerator._generateAncestors.<locals>.pred  s    33A6*DDr!   rt  )rs  rZ   r   r  
ancestorOfr   )#r\   r   is_deadr   r   rq   rl   rm   isTypeaheadis_page_tabcommonAncestorrp   r   r^   	TREE_ITEMr   rc   APPLICATIONMENU_BARra  r\  r  r  r   nestingLevelget_parent_checkedisSpreadSheetTabler  isButtonWithPopup	enumerater  ru  rD   rv  reverse)r   rI   rJ   rf   r   r   r  r  r  r   r   r  r  presentOncepresentCommonAncestorr  objAncestorpriorAncestorobjLevel
priorLevel	ancestorsancestorRolesru   
parentRolepresentedRolesirB   altRoler  r  s   `                            @r   _generateAncestorsz"SpeechGenerator._generateAncestors  s    ((9%txx
+hHHZ(c*-h((2I""8,I++H59L9LS9QQI<<!!--h7I""3'I""3'I//>>xM. Ihh}b1HH["-	--. CCE"hh}b1EJJ22EJJ4G4GHI"2B7uzz2234zz--uzz? %'11.AJ[(E&44S$? ( 6 6x F<<11>>{K!\\33@@O
(0J(>%#%r=	,,S111&9J[( Y&t||/E/E/X/XY_/`;!>''44V<''99&A>)-B  ($$Z0':+G008F+ . i( 	-DAq#A&G+%'^*C!!'*!''0Ew-MMaJW&-UsU]  _` gt,	- NNr!   c                 J   t        j                         j                  d      rg S | j                  j                  j                         rg S |j                  d      r|k(  st        j                        sg S t        j                  |      rg S t        j                  |      t        j                        k7  st        j                  |fd      rg S | j                  j                  j                  |      \  }}|rg S d|d<   t        j                  j                   t        j                  j"                  t        j                  j$                  t        j                  j&                  dddd	d
ddt        j                  j(                  t        j                  j*                  dt        j                  j,                  t        j                  j.                  g|d<   g }| j                  j                  j1                        rY| j3                        }| j5                  ||       |j7                  | j9                  |dd             | j;                  ||       |j7                   | j<                  |fi |       |j?                  d       |j?                  d       |S )zReturns 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(  S r   r   )rB   r   s    r   rC   z7SpeechGenerator._generateOldAncestors.<locals>.<lambda>  s    AM r!   Tr   rI  rJ  rK  r   rL  rM  rN  rO  r  focused)rZ   rs  r   ) r   r`   ra   rl   rm   inFindContainerr\   r   is_validr   r  get_applicationr   frameAndDialogr   r^   r\  r]  r^  r_  r  r   r`  ra  isBlockquoter  ru  rc   rD   rv  r  r   )r   rI   rJ   framedialogrf   rx  r   s          @r   _generateOldAncestorsz%SpeechGenerator._generateOldAncestors  s   
 &&(334LMI<<!!113I88J'3(?(2C2CH2MI""3'I##C(H,D,DX,NN$$S*ABI..==cBvIY$zz55$zz::$zz$zz22672832*$zz$zz//,$zz//$zz224]" <<!!..x8..x8Gw-MM$--w9d ( L Mgt,-d--c:T:;r!   c                    t        j                         j                  d      rg S | j                  j                  j                         rg S |j                  d      }||k(  rg S |j                  dt        j                  |            }|t        j                  j                  t        j                  j                  fv rg S |t        j                  j                  k(  r|rt        j                  |      rg S | | j                   |fi |S | j                  j                  j#                  |      \  }}|xs |}t        j$                  |      r | j                   |fi |S g S )aw  Returns 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`   ra   rl   rm   r  r\   r   r]   r   r^   FRAMEWINDOW	MENU_ITEMr   	is_windowr  r  is_dialog_or_alert)r   rI   rJ   r   rZ   r  r  topLevels           r   _generateNewAncestorsz%SpeechGenerator._generateNewAncestors/  s.    &&(334LMI<<!!113I88J's?Ixx 1 1# 67EJJ$$ejj&7&788I5::'''[=R=RS[=\I*4**37$77..==cBv?U))(3*4**37$77	r!   c                     |j                  d      |k(  rg S  | j                  |fi |}|j                   | j                  |fi |       |S )Nr   )r\   r  rp   r  ri   s       r   generateContextzSpeechGenerator.generateContextW  sS    88J3&I+++C8480d00==>r!   c                    |j                  dt        j                  |            t        j                  j
                  k(  r%|j                  dd      dv rt        j                  gS t        j                  |      }t        j                  |      st        j                  |      r|}| j                  t        j                  |            S )zReturns an array of strings (and possibly voice and audio
        specifications) containing the role name of the parent of obj.
        rZ   rs  N)basicWhereAmIdetailedWhereAmI)r\   r   r]   r   r^   r   r   ROLE_ICON_PANELrq   r   is_table_cellis_menur   )r   rI   rJ   ru   s       r   _generateParentRoleNamez'SpeechGenerator._generateParentRoleName_  s     88FH--c23uzzFxxd+78%5566$$S)$$V,0C0CF0KC%%h&9&9#&>??r!   c                     g }t        j                  |t        j                        }|r@|j	                  | j                  |             |j	                  | j                  |             |S )zReturns an array of strings (and possibly voice and audio
        specifications) containing the name and role of the toolbar
        which contains obj.
        )r   r   r   is_tool_barrc   r>  r   )r   rI   rJ   rf   rt  s        r   _generateToolbarz SpeechGenerator._generateToolbarm  sW    
 ))#{/F/FGMM$44X>?MM$00:;r!   c                    t        j                         j                  d      rg S t        j                  |t
        j                  j                  t        j                        }||vrg S g }d }t        |t        j                  |            }|j                  | j                  j                  j!                  dd      |j#                  |      dz   t%        |      dz         |j'                   | j(                  t*        fd	|i|       |S )
zReturns an array of strings (and possibly voice and audio
        specifications) that represent the relative position of an
        object in a group.
        r[   c                 X    t        j                  |      t        j                  |       z
  S r   )r   r9  )rB   ys     r   cmpz5SpeechGenerator._generatePositionInGroup.<locals>.cmp  s$    //2X5Q5QRS5TTTr!   )r  r   
groupindexr4  r   r  rI   )r   r`   ra   r   r
  r   r  r  r   r%  sorted	functools
cmp_to_keyrp   rl   r7  r8  r  r  rc   r;   rd   )r   rI   rJ   r  rf   r  s         r   _generatePositionInGroupz(SpeechGenerator._generatePositionInGroupy  s    
 &&(334LMI //##--{/E/EGgI	U i&:&:3&?@dll--77#+)5 8 7 (/}}S'9A'='*7|55 	6
 	jdjj9S9D9:r!   c                 ,   t        j                         j                  d      s5t        j                         j                  d      s|j                  dd      sg S | j                  j
                  j                  |      rg S | j                  j
                  j                  |      rg S g } | j                  j
                  j                  |fi |\  }}|dk  rg S d}|dk  r,| j                  j
                  j                  |      sg S |dz  }|dk(  rt        j                  |      rg S |dz  }|j                  | j                  j                  j                  d	|
      ||dz         |j                   | j                   t"        fd|i|       |S )zReturns an array of strings (and possibly voice and audio
        specifications) that represent the relative position of an
        object in a list.
        r[   enablePositionSpeaking	forceListFr   r  totalunknownr   r   r4  r  rI   )r   r`   ra   r\   rl   rm   isTopLevelMenur   getPositionAndSetSizesetSizeUnknownr   r  rp   r7  r8  rc   r;   rd   )r   rI   rJ   rf   positionr  r5  s          r   _generatePositionInListz'SpeechGenerator._generatePositionInList  st    &&(334LM#..0;;<TUhh{E2I<<!!005I<<!!44S9IF$,,00FFsSdS%a<I!
19<<))88=	.(JA:+--c2IAdll--77#+)3 8 5 (0',.. 	/
 	jdjj9S9D9:r!   c                 (   |j                  d      r | j                  |fi |sg S g }| j                         \  }}}||k7  rP| j                  |      \  }}t        j
                  |z  g}|j                   | j                  t        fd|i|       |S )NisProgressBarUpdaterI   )	r\   _shouldPresentProgressBarUpdate_getMostRecentProgressBarUpdategetProgressBarNumberAndCountr
   PROGRESS_BAR_NUMBERrc   r;   rd   )	r   rI   rJ   rf   acc
updateTimeupdateValuenumberr  s	            r   _generateProgressBarIndexz)SpeechGenerator._generateProgressBarIndex  s    xx-.6$66sCdCI'+'K'K'M$Z#: ==cBMFE22f=>FMM*$**V===>r!   c                    |j                  d      r | j                  |fi |sdgS g }t        j                  |      }|L|j	                  t        j                  |             |j                   | j                  t        fd|i|       |S )Nr  rO   rI   )
r\   r  r   r  rp   r
   r  rc   r;   rd   )r   rI   rJ   rf   percents        r   _generateProgressBarValuez)SpeechGenerator._generateProgressBarValue  s    88)*7477DtD4K..s3MM(--g67MM*$**V===>r!   c                     t        j                         j                  d      }|t        |          }t        |      S )NprogressBarSpeechInterval)r   r`   ra   rU   _getProgressBarUpdateIntervalrR  )r   intervalrX   s     r   r#  z-SpeechGenerator._getProgressBarUpdateInterval  s:    #..0;;<WXw<>H8}r!   c                 l    t        j                         j                  d      syt        |   |fi |S )NspeakProgressBarUpdatesF)r   r`   ra   rU   r  )r   rI   rJ   rX   s      r   r  z/SpeechGenerator._shouldPresentProgressBarUpdate  s3    **,778QRw6sCdCCr!   c                 j   t        j                  |      sg S | j                  j                  j	                  |      }|r||gk(  rg S g }|D ]e  }||k(  r	| j                  |d      }|s|j                  |       t        |d   t              rD|j                   | j                  |fi |       g |S )zReturns an array of strings (and possibly voice and audio
        specifications) that represent the status bar of a window.
        FincludeContextr%  )
r   is_status_barrl   rm   statusBarItemsrD   rc   r@   r   r   )r   rI   rJ   r/  rf   r9  childResults          r   _generateStatusBarz"SpeechGenerator._generateStatusBar  s    
 ((-I&&55c:#I 	FE|--e-DKk*!+b/59MM"5$"5"5e"Dt"DE	F r!   c                    g }| j                   j                  j                  |      \  }}|r5| j                  |      }|s| j	                  |      }|j                  |       |r |j                  | j                  |             | j                   j                  j                  |      }|dkD  rOt        j                  |      g}|j                   | j                  t        fd|i|       |j                  |       |S )zReturns 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.
        r   rI   )rl   rm   r  r>  r   rp   rD  r
   rE  rc   r;   re   )	r   rI   rJ   rf   r  r  frameResultrF  dialogss	            r   generateTitlezSpeechGenerator.generateTitle	  s     ..==cBv44U;K"44U;MM+&MM$44V<="ll44QQRUV"112EFGGNN:4::g?3?$?@MM'"r!   c                     t        j                  t        j                  |            sg S g }t        j                  |      }|D ]$  }|j                  | j                  |d             & |S )NFr(  )r   r   r   rq   get_all_widgetsrp   rD   )r   rI   rJ   rf   widgetswidgets         r   _generateListBoxItemWidgetsz+SpeechGenerator._generateListBoxItemWidgets	  sd    &&x':':3'?@I--c2 	GFMM$--u-EF	Gr!   c                    t        j                         j                  d      rg S g }| j                  j                  j                  |      \  }}}|r9|j                  |       |j                   | j                  t        fd|i|       |S )zReturns 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`   ra   rl   rm   mnemonicShortcutAcceleratorrp   rc   r;   rd   r   rI   rJ   rf   mnemonicshortcutaccelerators          r   _generateAcceleratorz$SpeechGenerator._generateAccelerator,	  s~    
 &&(334LMILL"">>sC 	*8[MM+&MM*$**V===>r!   c                    t        j                         j                  d      rg S g }t        j                         j                  d      s|j                  dd      rc| j                  j
                  j                  |      \  }}}|r|d   }|s|r|}|r+|g}|j                   | j                  t        fd|i|       |S )zReturns 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`   ra   r\   rl   rm   r8  rc   r;   rd   r9  s          r   _generateMnemonicz!SpeechGenerator._generateMnemonic=	  s    
 &&(334LMI&&(334LMhh.&&BB3G .Xx#B<#"jdjjASADABr!   c                     t        j                         j                  d      s#|j                  dd      j	                  d      sg S t        j                  |      }|sg S | | j                  t        fd|i|gS )z}Returns an array of strings (and possibly voice and audio
        specifications) that represent the tutorial for the object.enableTutorialMessagesrs  rO   WhereAmIrI   )	r   r`   ra   r\   endswithr   get_help_textr;   rd   )r   rI   rJ   r7  s       r   _generateTutorialz!SpeechGenerator._generateTutorialT	  sr      **,778PQ88L"-66zBI%%c*Ijdjj9S9D9::r!   c                    g }t        j                  |      D cg c]  }| }}|s(| j                  j                  j	                  |      s|g}|D ]  }| j                  j                  j                  |      r6t        j                  |      r!|j                  | j                  |             ^| j                  |      }| j                  ||       |j                  | j                  ||             | j                  ||        |S c c}w Nr   )r   r  rl   rm   isMathTopLevelisMathLayoutOnlyr*  rc   _generateMathr  ru  rD   rv  )r   rI   rJ   rf   r9  r  rx  s          r   rL  zSpeechGenerator._generateMathd	  s    '/'='=c'BCeECC 6 6 E Ec JuH 	-E||%%66u=(BZBZ[`Bad0078..u5Gw-MM$--G-<=gt,	-  Ds   	D
c                 (     | j                   |fi |S r   )rL  r]  s      r   _generateEnclosedBasez%SpeechGenerator._generateEnclosedBasev	  s    !t!!#...r!   c                    g }| j                   j                  j                  |      }d|v r|j                  t        j
                         d|v r|j                  t        j                         d|v r|j                  t        j                         d|v r|j                  t        j                         d|v r|j                  t        j                         d|v r|j                  t        j                         d|v r|j                  t        j                         d|v r|j                  t        j                         d	|v r|j                  t        j                         d
|v r|j                  t        j                         d|v r|j                  t        j                         d|v r|j                  t        j                          d|v r|j                  t        j"                         d|v r|j                  t        j$                         d|v r|j                  t        j&                         d|v r|j                  t        j(                         d|v r|j                  t        j*                         |s+d|g}t-        j.                  t,        j0                  |d       g S t3        |      dk(  rt        j4                  |d   z  g}nu|j7                  dt        j8                         t3        |      dk(  r$t        j4                  dj;                  |      z  g}n#t        j4                  dj;                  |      z  g}|j=                   | j>                  t@        fd|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 forTr   r   r%  r   rP   z, rI   )!rl   rm   getMathEnclosuresrp   r
   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_MADRUWBr   rG   rH   r  MATH_ENCLOSURE_ENCLOSED_BYinsertMATH_ENCLOSURE_ANDrT   rc   r;   rd   )r   rI   rJ   strings
enclosuresrL   rf   s          r   _generateEnclosedEnclosuresz+SpeechGenerator._generateEnclosedEnclosuresy	  s   \\++==cB
*$NN8<<=JNN8667z!NN899:
"NN8::;
"NN8::;:%NN8==>+NN8CCDz)NN8AAB:-NN8EEF+NN8CCDz)NN8AABz!NN899:ZNN8778j NN8889JNN8667J&NN8??@
"NN8::;MzZFe..=Iw<199GAJFGFNN2x::;7|q "==@QQR"==		'@RRSjdjj9S9D9:r!   c                     | j                   j                  j                  |      \  }}|r@t        j                  |      g}|j                   | j                  t        fd|i|       |S g S r`  rl   rm   getMathFencesr	   r  rc   r;   re   r   rI   rJ   
fenceStartfenceEndrf   s         r   _generateFencedStartz$SpeechGenerator._generateFencedStart	  sb    #||55CCCH
H!22:>?FMM*$**W>#>>?M	r!   c                 z   g }| j                   j                  j                  |      }t        t	        |      t        j                  |      dz
        D ]  }|j                  |d           |j                  d       t        t        j                  |            D ]  \  }}|j                   | j                  |fi |       t        j                  ||         }|j                  |       |j                   | j                  t        fd|i|       |s||j                   | j                   |fi |        |S )Nr   r%  rO   rI   )rl   rm   getMathFencedSeparatorsranger  r   r*  rp   r  r  rc   rL  r	   r  r;   re   r   )	r   rI   rJ   rf   
separatorsrB   r  r9  separatorNames	            r   _generateFencedContentsz'SpeechGenerator._generateFencedContents	  s   \\++CCCH
s:(@(@(Ea(GH 	.Ajn-	."!("8"8"=> 	@HAuMM,$,,U;d;<'88AGMMM-(MM*$**W>#>>?1d11#>>?	@ r!   c                     | j                   j                  j                  |      \  }}|r@t        j                  |      g}|j                   | j                  t        fd|i|       |S g S r`  rz  r|  s         r   _generateFencedEndz"SpeechGenerator._generateFencedEnd	  sb    #||55CCCH
H!228<=FMM*$**W>#>>?M	r!   c                     | j                   j                  j                  |      rt        j                  g}nt        j
                  g}|j                   | j                  t        fd|i|       |S r`  )	rl   rm   isMathFractionWithoutBarr
   MATH_FRACTION_WITHOUT_BAR_STARTMATH_FRACTION_STARTrc   r;   rd   ri   s       r   _generateFractionStartz&SpeechGenerator._generateFractionStart	  s\    <<!!::3?>>?F223Fjdjj9S9D9:r!   c                 L   | j                   j                  j                  |      }| j                   j                  j                  |      r| j	                  |      S | j                  |      }| j                  ||       | j                  ||      }| j                  ||       |S rI  )	rl   rm   getMathNumeratorrK  rL  r  ru  rD   rv  )r   rI   rJ   	numeratorrx  rf   s         r   _generateFractionNumeratorz*SpeechGenerator._generateFractionNumerator	  s    LL**;;C@	<<!!229=%%i00**957D)yw7'4(r!   c                 L   | j                   j                  j                  |      }| j                   j                  j                  |      r| j	                  |      S | j                  |      }| j                  ||       | j                  ||      }| j                  ||       |S rI  )	rl   rm   getMathDenominatorrK  rL  r  ru  rD   rv  )r   rI   rJ   denominatorrx  rf   s         r   _generateFractionDenominatorz,SpeechGenerator._generateFractionDenominator	  s    ll,,??D<<!!22;?%%k22**;77D){9'4(r!   c                 x    t         j                  g}|j                   | j                  t        fd|i|       |S r`  )r
   MATH_FRACTION_LINErc   r;   rd   ri   s       r   _generateFractionLinez%SpeechGenerator._generateFractionLine	  s6    --.jdjj9S9D9:r!   c                 x    t         j                  g}|j                   | j                  t        fd|i|       |S r`  )r
   MATH_FRACTION_ENDrc   r;   rd   ri   s       r   _generateFractionEndz$SpeechGenerator._generateFractionEnd	  s6    ,,-jdjj9S9D9:r!   c                    g }| j                   j                  j                  |      rt        j                  g}nm| j                   j                  j                  |      }| j                   j                  j                  |      }|dk(  rt        j                  g}n|dk(  rt        j                  g}n|r$|g}|j                  t        j                  g       n| j                   j                  j                  |      r2| j                  |      }|j                  t        j                  g       nw| j                  |      }| j                  ||       |j                  | j                  ||             | j                  ||       |j                  t        j                  g       |r(|j                   | j                   t"        fd|i|       |S )N23r   rI   )rl   rm   isMathSquareRootr
   MATH_SQUARE_ROOT_OFgetMathRootIndexr(  MATH_CUBE_ROOT_OFrc   MATH_ROOT_OFrK  rL  r  ru  rD   rv  r;   rd   )r   rI   rJ   rf   r  r  rx  s          r   _generateRootStartz"SpeechGenerator._generateRootStart	  sn   <<!!2237223FLL**;;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259""7D1dmmEm@A!!'40x4456MM*$**V===>r!   c                 .   | j                   j                  j                  |      }|sg S | j                   j                  j                  |      sJ| j                   j                  j	                  |      s%| j                   j                  j                  |      r| j                  |      S  | j                  |fi |g}| j                  |      }| j                  ||       |j                  | j                  ||             | j                  ||       |S rI  )rl   rm   getMathRootBaser  isMathTokenrK  rL  r   r  ru  rc   rD   rv  )r   rI   rJ   baserf   rx  s         r   _generateRootBasez!SpeechGenerator._generateRootBase
  s    ||%%55c:I<<!!2237ll$$006ll$$55d;%%d++%$%%c2T23**407D)dmmDwm78'4(r!   c                 x    t         j                  g}|j                   | j                  t        fd|i|       |S r`  )r
   MATH_ROOT_ENDrc   r;   rd   ri   s       r   _generateRootEndz SpeechGenerator._generateRootEnd)
  s6    (()jdjj9S9D9:r!   c                 v    | j                   j                  j                  |      }|sg S | j                  |      S r   )rl   rm   getMathScriptBaserL  )r   rI   rJ   r  s       r   _generateScriptBasez#SpeechGenerator._generateScriptBase.
  s5    ||%%77<I!!$''r!   c                    | j                   j                  j                  |      r| j                  |      S | j	                  |      }| j                  ||       | j                  ||      }| j                  ||       |S rI  )rl   rm   rK  rL  r  ru  rD   rv  )r   rI   rJ   rx  rf   s        r   _generateScriptScriptz%SpeechGenerator._generateScriptScript5
  sr    <<!!2237%%c****3/7D)s1'4(r!   c                 
   | j                   j                  j                  |      }|sg S t        j                  g}|j                   | j                  t        fd|i|       |j                  | j                  |             |S r`  )	rl   rm   getMathScriptSubscriptr
   MATH_SUBSCRIPTrc   r;   rd   r  )r   rI   rJ   	subscriptrf   s        r   _generateScriptSubscriptz(SpeechGenerator._generateScriptSubscript@
  so    LL**AA#F	I))*jdjj9S9D9:d00;<r!   c                 
   | j                   j                  j                  |      }|sg S t        j                  g}|j                   | j                  t        fd|i|       |j                  | j                  |             |S r`  )	rl   rm   getMathScriptSuperscriptr
   MATH_SUPERSCRIPTrc   r;   rd   r  )r   rI   rJ   superscriptrf   s        r   _generateScriptSuperscriptz*SpeechGenerator._generateScriptSuperscriptK
  o    ll,,EEcJI++,jdjj9S9D9:d00=>r!   c                 
   | j                   j                  j                  |      }|sg S t        j                  g}|j                   | j                  t        fd|i|       |j                  | j                  |             |S r`  )	rl   rm   getMathScriptUnderscriptr
   MATH_UNDERSCRIPTrc   r;   rd   r  )r   rI   rJ   underscriptrf   s        r   _generateScriptUnderscriptz*SpeechGenerator._generateScriptUnderscriptV
  r  r!   c                 
   | j                   j                  j                  |      }|sg S t        j                  g}|j                   | j                  t        fd|i|       |j                  | j                  |             |S r`  )	rl   rm   getMathScriptOverscriptr
   MATH_OVERSCRIPTrc   r;   rd   r  )r   rI   rJ   
overscriptrf   s        r   _generateScriptOverscriptz)SpeechGenerator._generateScriptOverscripta
  so    \\++CCCH
I**+jdjj9S9D9:d00<=r!   c                    g }| j                   j                  j                  |      }t        |      D ]  \  }}| j                   j                  j	                  |      r,|dz  rt
        j                  g}nt
        j                  g}|j                   | j                  t        fd|i|       |j                  | j                  |             |j                  |        |S Nr#  rI   )rl   rm   getMathPrescriptsr  isNoneElementr
   MATH_PRE_SUPERSCRIPTMATH_PRE_SUBSCRIPTrc   r;   rd   r  rp   )r   rI   rJ   rf   
prescriptsr  r9   rK   s           r   _generateScriptPrescriptsz)SpeechGenerator._generateScriptPrescriptsl
  s    \\++==cB
":. 		IAv||%%33F;1u334112IIjdjj9S9D9:IId0089MM"		 r!   c                    g }| j                   j                  j                  |      }t        |      D ]  \  }}| j                   j                  j	                  |      r,|dz  rt
        j                  g}nt
        j                  g}|j                   | j                  t        fd|i|       |j                  | j                  |             |j                  |        |S r  )rl   rm   getMathPostscriptsr  r  r
   r  r  rc   r;   rd   r  rp   )r   rI   rJ   rf   postscriptsr  r9   rK   s           r   _generateScriptPostscriptsz*SpeechGenerator._generateScriptPostscripts|
  s    ll,,??D";/ 		IAv||%%33F;1u//0--.IIjdjj9S9D9:IId0089MM"		 r!   c                    t        j                  |      sg S t        j                  |      }t        j                  |      }| j
                  j                  j                  |      }|dkD  rt        j                  ||      g}nt        j                  ||      g}|j                   | j                  t        fd|i|       |S Nr   rI   )r   supports_tabler   r  r  rl   rm   getMathNestingLevelr
   mathNestedTableSizemathTableSizerc   r;   rd   )r   rI   rJ   r  r  r  rf   s          r   _generateMathTableStartz'SpeechGenerator._generateMathTableStart
  s    &&s+I$$S)**3/||--AA#F!224ABF,,T7;<Fjdjj9S9D9:r!   c                     g }t        j                  |      D ]Y  }| j                  |      }| j                  ||       |j	                  | j                  ||             | j                  ||       [ |S rI  )r   r  r  ru  rc   rD   rv  )r   rI   rJ   rf   r  rx  s         r   _generateMathTableRowsz&SpeechGenerator._generateMathTableRows
  sq    ))#. 	-C..s3Gw-MM$--'-:;gt,		- r!   c                    g }|j                  t        j                  t        j                  |      dz   z         |j                   | j                  t        fd|i|       |j                   | j                  |fi |       t        j                  |      D ]D  }|j                  | j                  |             |j                   | j                  |fi |       F |S )Nr   rI   )rp   r
   r  r   r9  rc   r;   rd   r   r  rL  )r   rI   rJ   rf   r9  s        r   _generateMathRowz SpeechGenerator._generateMathRow
  s    h((H,H,H,MPQ,QRSjdjj9S9D9:)d))#667++C0 	>EMM$,,U34MM-$--e<t<=	> r!   c                     | j                   j                  j                  |      }|dkD  rt        j                  g}nt        j
                  g}|j                   | j                  t        fd|i|       |S r  )	rl   rm   r  r
   MATH_NESTED_TABLE_ENDMATH_TABLE_ENDrc   r;   rd   )r   rI   rJ   r  rf   s        r   _generateMathTableEndz%SpeechGenerator._generateMathTableEnd
  sf    ||--AA#F!445F--.Fjdjj9S9D9:r!   c                     t        j                         j                  d      r|j                  dd      rg S t        j                         j                  d      t        j
                  k(  rg S t        S )NenablePauseBreakseliminatePausesFverbalizePunctuationStyle)r   r`   ra   r\   r   PUNCTUATION_STYLE_ALLr#   r]  s      r   r   zSpeechGenerator._generatePause
  s^    **,778KLhh(%0I&&(334OP))*Ir!   c                     t         S r   )
LINE_BREAKr]  s      r   _generateLineBreakz"SpeechGenerator._generateLineBreak
  s    r!   c                 ~   t         j                  |      xs t         j                  t              }t        j                         j                  d      }t        j                  |j                  t         j                  t              i             }|j                  d      }|j                  dd      }d| d| d| d}t        j                  t        j                  |d	       d
}	|r(|	r&t        j                         }
|
j                  ||       |dt        fv r|j                  dd      }|j                  d      }t        j                  |      r;|j!                  |j                  t         j                  t"              i              |gS t%        |t&              rf|j)                         rV|j+                         j-                         r8|j!                  |j                  t         j                  t.              i              |gS |j                  |      }|r#|j                  dd	      r|j!                  |       |gS )zReturns 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  rO   zSPEECH GENERATOR: z  voice requested with language='z', dialect='r  TFNr  rI   established)	voiceTyper\   re   r   r`   ra   r   rR   r   r  rH   r   getSpeechServershouldChangeVoiceForLanguager   is_linkupdate	HYPERLINKr@   strisupperr  isalpha	UPPERCASE)r   r  rJ   	voicenamer  r;   r  r  r  checkVoicesForLanguageserverr  rI   overrides                 r   r;   zSpeechGenerator.voice
  s    MM#&@)--*@	!,,.99(C		&**Y]]7%;R@A88J'((9b)  &!
,wiq: 	 	5++S$7
 "'.++-F//'B4/!XXh+F((5/C""3'VZZ	i(@"EF w FC(V^^-=&,,.BXBXBZVZZ	i(@"EF w	 zz),HHLL=X&wr!   c                     d}|D ]H  }t        |t              r	|d| z  }t        |t              s-|s0|d   j                         sD|dz  }J |j	                         S )NrO   rP   r%  r<  )r@   r  r   isalnumr  )r   
utterancesr  us       r   utterancesToStringz"SpeechGenerator.utterancesToString
  sb     	A!S!AaS'!Au%&VBZ5G5G5I#		 ||~r!   )Tr   )r&   r'   r(   r)   r   r<   rM   rS   rb   rh   rs   rw   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:  rH  rY  r^  rb  rd  rf  rl  ro  ry  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+  r1  r<  r@  rB  rG  r   r  r  r  r  r  r  r   r	  r  r  r   r#  r  r-  r1  r6  r=  rA  rG  rL  rN  rx  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  __classcell__)rX   s   @r   r6   r6   g   s   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?!BAFn`8t&P@
 D&PD20 ".; $/4l"		

:$
(					  	'Rr!   r6   ):r)   __id____version____date____copyright____license__r  girequire_versiongi.repositoryr   urllib.parser)  urllib.requesturllib.errorrO   r   r   r   r	   r
   r   r   r   r   r   ax_documentr   ax_hypertextr   	ax_objectr   ax_tabler   ax_textr   ax_utilitiesr   ax_valuer   r   r#   r+   r  METHOD_PREFIXre   r  r  rd   r  VALUEDEFAULT_VOICEUPPERCASE_VOICEHYPERLINK_VOICESYSTEM_VOICEr  r8   r6   r   r!   r   <module>r     s+  ( =?  	   7E "               " # %    %   
	  k]
 		 X##x''x''
H!!	8  	8  	X*i)) X*r!   