%PDF- %PDF-
Mini Shell

Mini Shell

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

�

g
f26����dZdZdZdZdZdZddlZejdd	�dd
lm	Z	ddl
mZddlm
Z
ddlmZddlmZddlmZdd
lmZddlmZddlmZGd�dej4�Zy)z,Custom script for StarOffice and OpenOffice.z$Id$z
$Revision$z$Date$z-Copyright (c) 2005-2009 Sun Microsystems Inc.�LGPL�N�Atspiz2.0)r)�AXComponent)�AXObject)�AXTable)�AXText)�AXUtilitiesc���eZdZd�Zd�Z�fd�Z�fd�Z�fd�Zd�Zd�Z	�fd�Z
d	�Zd
�Zd�Z
�fd�Z�fd
�Z�fd�Z�fd�Z�fd�Z�fd�Z�xZS)�SpeechGeneratorc�D�tjj||�y�N)�speech_generatorr�__init__)�self�scripts  �L/usr/lib/python3/dist-packages/orca/scripts/apps/soffice/speech_generator.pyrzSpeechGenerator.__init__+s���(�(�1�1�$��?�c�~�g}|jjj|�xsd}|s<|jjjtj|��xsd}|rQ|j|j
��|j|jtjfd|i|���|S)aReturns the label for an object as an array of strings (and
        possibly voice and audio specifications).  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.
        ��obj)�_script�	utilities�displayedLabelr�
get_parent�append�strip�extend�voicer�DEFAULT)rr�args�result�labels     r�_generateLabelzSpeechGenerator._generateLabel.s��������&�&�5�5�c�:�@�b����L�L�*�*�9�9�(�:M�:M�c�:R�S�Y�WY�E���M�M�%�+�+�-�(��M�M�*�$�*�*�%5�%=�%=�O�3�O�$�O�P��
rc����tj|�rJtj|�g}|j|jtj
fd|i|���|St
�|�|fi|��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.
        r)r�get_namerrrr�super�
_generateName)rrr r!�	__class__s    �rr'zSpeechGenerator._generateName=sh������S�!��'�'��,�-�F��M�M�*�$�*�*�%5�%=�%=�O�3�O�$�O�P��M��w�$�S�1�D�1�1rc����tj|�tjjk7rt�|�|fi|��Sg}|jjj|�xstj|�}|rC|j|�|j|jtjfd|i|���tj|�}||k(s|s?|jjj!|�}|rtj|d�}|rC|j|�|j|jtjfd|i|���|S)Nrr)r�get_roler�Role�	COMBO_BOXr&�_generateLabelAndNamerrrr%rrrrr�selectedChildren)rrr r!r"�name�selectedr(s       �rr-z%SpeechGenerator._generateLabelAndNameQs$������S�!�U�Z�Z�%9�%9�9��7�0��=��=�=������&�&�5�5�c�:�T�h�>O�>O�PS�>T����M�M�%� ��M�M�*�$�*�*�%5�%=�%=�O�3�O�$�O�P�� � ��%���D�=���|�|�-�-�>�>�s�C�H���(�(��!��5����M�M�$���M�M�*�$�*�*�%5�%=�%=�O�3�O�$�O�P��
rc���|jjj|�}|rt�|�|�St�|�|fi|��Sr
)rr�getEntryForEditableComboBoxr&�_generateAnyTextSelection)rrr �
comboBoxEntryr(s    �rr3z)SpeechGenerator._generateAnyTextSelectionisE������.�.�J�J�3�O�
���7�4�]�C�C��w�0��=��=�=rc��g}|jjj|�s0|jt	j
j||fi|���|S)aReturns an array of strings for use by speech and braille that
        represent the grayed/sensitivity/availability state of the
        object, but only if it is insensitive (i.e., grayed out and
        inactive).  Otherwise, and empty array will be returned.
        )rr�isSpreadSheetCellrrr�_generateAvailability)rrr r!s    rr7z%SpeechGenerator._generateAvailabilitypsT�����|�|�%�%�7�7��<��M�M�*�:�:�%�%�d�C�9�37�9�
:��
rc���tj�jd�rgStj�jd�sgS|jdd�j	d�sgSg}tj|�}|r�|jjj|�xsd}|j|d�}tj|�j�D]}|j|d�}�|j�D]%}|j�s�|j|�n|r2|j!|j"t$j&fd|i|���|S)z�Returns an array of strings (and possibly voice and audio
        specifications) that represent the description of the object,
        if that description is different from that of the name and
        label.
        �onlySpeakDisplayedText�speakDescription�
formatTyper�WhereAmIr)�settings_manager�
getManager�
getSetting�get�endswithr�get_descriptionrr�
displayedText�replacer%�splitr�isalnumrrrr�SYSTEM)	rrr r!�description�text�desc�item�chars	         r�_generateDescriptionz$SpeechGenerator._generateDescription~s9���&�&�(�3�3�4L�M��I��*�*�,�7�7�8J�K��I��x�x��b�)�2�2�:�>��I����.�.�s�3���
�<�<�)�)�7�7��<�B��D��&�&�t�R�0�D� �)�)�#�.�4�4�6�
.���|�|�D�"�-��
.��
�
��
���<�<�>��M�M�+�.��
�
��M�M�*�$�*�*�%5�%<�%<�N�#�N��N�O��
rc���tj|�tjjk(r8|j
jj|�}|rt�|�%|�SgS|j
j|�\}}}|s7tjg}|j|jd||d�|���|St�|�$|fi|��S)N)�stringr�)rr*rr+r,rrr2r&�_generateCurrentLineText�getTextLineAtCaret�messages�BLANKrr)	rrr �entryrI�caretOffset�startOffsetr!r(s	        �rrQz(SpeechGenerator._generateCurrentLineText�s�������S�!�U�Z�Z�%9�%9�9��L�L�*�*�F�F�s�K�E���w�7��>�>��I�
,0�<�<�+J�+J�3�+O�(��{�K���n�n�%�F��M�M�*�$�*�*�B�D�c�B�T�B�C��M��w�/��<�t�<�<rc��g}|jdtj|��}|tjj
k(r�tjtj|��tjjk(r�tj|�r |jtj�n|jtj�|j|jt j"fd|i|���|S|tjj
k(r0|jt!j$j&||fi|���|S)z�Treat toggle buttons in the toolbar specially. This is so we can
        have more natural sounding speech such as "bold on", "bold off", etc.�roler)r@rr*rr+�
TOGGLE_BUTTONr�TOOL_BARr	�
is_checkedrrS�ON�OFFrrrrGr�_generateToggleState)rrr r!rYs     rr_z$SpeechGenerator._generateToggleState�s�����x�x��� 1� 1�#� 6�7���5�:�:�+�+�+�� � ��!4�!4�S�!9�:�e�j�j�>Q�>Q�Q��%�%�c�*��
�
�h�k�k�*��
�
�h�l�l�+��M�M�*�$�*�*�%5�%<�%<�N�#�N��N�O��
��U�Z�Z�-�-�
-��M�M�*�:�:�O�O��c�#�!�#�
$��
rc�N�tj�jd�rgSg}tj|�}d}tj|�}t|�D]t}tj||�}|j|jkr|dz
}�8|j|jz|j|jzkDs�l|||z
z
}n|dkDrtj|�g}|r2|j|jtj fd|i|���|S)aZIf there is text in this spread sheet cell, compare the size of
        the text within the table cell with the size of the actual table
        cell and report back to the user if it is larger.

        Returns an indication of how many characters are greater than the size
        of the spread sheet cell, or None if the message fits.
        r9r�r)r=r>r?r�get_character_countr�get_rect�range�get_character_rect�x�widthrS�charactersTooLongrrrrG)	rrr r!�length�tooLongCount�extents�i�rects	         r�_generateTooLongz SpeechGenerator._generateTooLong�s���&�&�(�3�3�4L�M��I����+�+�C�0�����&�&�s�+���v��	�A��,�,�S�!�4�D��v�v��	�	�!���!�����$�*�*�$�w�y�y�7�=�=�'@�@����
�*���
	��!���0�0��>�?�F���M�M�*�$�*�*�%5�%<�%<�N�#�N��N�O��
rc��tj|�}|sgS|jd�dk(rtj�d|��g}ntjg}|j|jtjfd|i|���|S)Nr;�
basicWhereAmIz. r)	r�get_cell_formular@rS�HAS_FORMULArrrrG)rrr �formular!s     r�_generateHasFormulaz#SpeechGenerator._generateHasFormula�s����*�*�3�/����I��8�8�L�!�_�4�!�-�-�.�b��	�:�;�F��*�*�+�F��
�
�j�d�j�j�!1�!8�!8�J�c�J�T�J�K��
rc�$��|jj�rgSt�	|�|fi|��}|jjj|�ss|jj
�j�r|Stj�jd�r$|jtj|��|S|jd�dk(}tj�jd�}|s|rMtj |�xs%|jjj#|�}|j|�|jjj%||jd��r'|jjj'|�r|S|j(|fi|��}|r3|j+|j,|fi|���|j+|�|j.|fi|��}|r3|j+|j,|fi|���|j+|�|t0j2k(rCt4j6g}|j+|j8t0j:fd|i|���|S)a!Get the speech for a table cell. If this isn't inside a
        spread sheet, just return the utterances returned by the default
        table cell speech handler.

        Arguments:
        - obj: the table cell

        Returns a list of utterances to be spoken for the object.
        �speakCellCoordinatesr;rp�speakSpreadsheetCoordinates�priorObjr)r�inSayAllr&�_generateRealTableCellrr6�getTableNavigator�'last_input_event_was_navigation_commandr=r>r?rrr%r@r�get_label_for_cell_coordinates�spreadSheetCellName�shouldReadFullRow�cellRowChangedrnr�_generatePausertr�PAUSErSrTrr)
rrr r!�isBasicWhereAmI�speakCoordinatesr"�tooLong�
hasFormular(s
         �rrzz&SpeechGenerator._generateRealTableCell�s����<�<� � �"��I���/��<�t�<���|�|�%�%�7�7��<��|�|�-�-�/�W�W�Y��
��*�*�,�7�7�8N�O��
�
�h�/�/��4�5��M��(�(�<�0�O�C��+�6�6�8�C�C�Da�b�����:�:�3�?�C��<�<�)�)�=�=�c�B�
��M�M�%� ��<�<�!�!�3�3�C����*�9M�N��|�|�%�%�4�4�S�9��
�'�$�'�'��4�t�4����M�M�-�$�-�-�c�:�T�:�;��M�M�'�"�-�T�-�-�c�:�T�:�
���M�M�-�$�-�-�c�:�T�:�;��M�M�*�%��%�+�+�+��n�n�%�F��M�M�*�$�*�*�%5�%=�%=�O�3�O�$�O�P��
rc���|jjj||jd��s|j|fi|��S|jjj|�st
�|�|fi|��S|jjj|�}|sgSg}|D]$}|j|j|fi|����&|S)Nrx)
rrrr@rzr6r&�_generateTableCellRow�getShowingCellsInSameRowr)rrr �cellsr!�cellr(s      �rr�z%SpeechGenerator._generateTableCellRow!s�����|�|�%�%�7�7��T�X�X�j�=Q�R�.�4�.�.�s�;�d�;�;��|�|�%�%�7�7��<��7�0��=��=�=����&�&�?�?��D����I����	E�D��M�M�5�$�5�5�d�C�d�C�D�	E��
rc�^��|jj�j�s|jj�rgS|jjj|�}|r2t
j|�tjjk(rgSt�|�0|fi|��S)a Returns an array of strings (and possibly voice and audio
        specifications) indicating that this cell is the last cell
        in the table. Overridden here because Orca keeps saying "end
        of table" in certain lists (e.g. the Templates and Documents
        dialog).
        )
rr{r|ryr�topLevelObjectrr*rr+�DIALOGr&�_generateEndOfTableIndicator)rrr �topLevelr(s    �rr�z,SpeechGenerator._generateEndOfTableIndicator2s�����<�<�)�)�+�S�S�U��l�l�#�#�%��I��<�<�)�)�8�8��=����)�)�(�3�u�z�z�7H�7H�H��I��w�3�C�@�4�@�@rc�>��|jdd�}|rtj|�dk(rgS|jjj|�r:|jjj
tj|��rgSt�|�$|fi|��S)Nrx�
text frame)
r@r�
get_role_namerrr6�isDocumentPanelrr&�_generateNewAncestors�rrr rxr(s    �rr�z%SpeechGenerator._generateNewAncestorsDs�����8�8�J��-���8�1�1�(�;�|�K��I��<�<�!�!�3�3�C�8��|�|�%�%�5�5�h�6I�6I�(�6S�T��I��w�,�S�9�D�9�9rc����tj|�dk(rgS|jdd�}|jjj|�rgSt
�|�|fi|��S)z�Returns an array of strings (and possibly voice and audio
        specifications) that represent the text of the ancestors for
        the object being left.r�rxN)rr�r@rrr6r&�_generateOldAncestorsr�s    �rr�z%SpeechGenerator._generateOldAncestorsOs_���
�!�!�#�&�,�6��I��8�8�J��-���<�<�!�!�3�3�H�=��I��w�,�S�9�D�9�9rc�r��|jjj|�sgSt�|�|fi|��Sr
)rr�	isGUICellr&�_generateUnselectedCell)rrr r(s   �rr�z'SpeechGenerator._generateUnselectedCell]s5����|�|�%�%�/�/��4��I��w�.�s�;�d�;�;r)�__name__�
__module__�__qualname__rr#r'r-r3r7rMrQr_rnrtrzr�r�r�r�r��
__classcell__)r(s@rrr*sa���@�
�2�(�0>��!�F=�$�"�:�1�f�"A�$	:�:�<�<rr)�__doc__�__id__�__version__�__date__�
__copyright__�__license__�gi�require_version�
gi.repositoryr�
orca.messagesrS�orca.settings_managerr=�orca.speech_generatorr�orca.ax_componentr�orca.ax_objectr�
orca.ax_tabler�orca.ax_textr�orca.ax_utilitiesr	rrPrr�<module>r�sh��(3�������?�
���	�����7�E�"�� �0�0�)�#�!��)�w<�&�6�6�w<r

Zerion Mini Shell 1.0