%PDF- %PDF-
Mini Shell

Mini Shell

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

�

g
fI�����dZdZdZdZdZdZddlZddlZddlZejdd	�dd
l
mZddlm
Z
dd
lmZddlmZddlmZGd�d�Zej)�y)a�
Utilities for obtaining information about accessible tables.
These utilities are app-type- and toolkit-agnostic. Utilities that might have
different implementations or results depending on the type of app (e.g. terminal,
chat, web) or toolkit (e.g. Qt, Gtk) should be in script_utilities.py file(s).

N.B. There are currently utilities that should never have custom implementations
that live in script_utilities.py files. These will be moved over time.
z$Id$z
$Revision$z$Date$zGCopyright (c) 2023 Igalia, S.L.Copyright (c) 2023 GNOME Foundation Inc.�LGPL�N�Atspiz2.0)r�)�debug)�messages)�AXObject)�AXUtilitiesc��eZdZdZiZiZiZiZiZiZ	iZ
iZiZiZ
iZiZiZiZiZiZej*�Zed��Zed��ZedCd��ZedCd��Zed��ZedDd��Zed��ZedDd	��Zed
��Z edEd��Z!ed��Z"ed
��Z#ed��Z$ed��Z%ed��Z&ed��Z'ed��Z(edDd��Z)ed��Z*ed��Z+ed��Z,ed��Z-ed��Z.ed��Z/ed��Z0ed��Z1ed��Z2ed��Z3ed��Z4edFd��Z5ed ��Z6ed!��Z7edFd"��Z8edGd#��Z9ed$��Z:ed%��Z;ed&��Z<ed'��Z=ed(��Z>ed)��Z?ed*��Z@ed+��ZAed,��ZBed-��ZCed.��ZDed/��ZEed0��ZFed1��ZGed2��ZHed3��ZIed4��ZJed5��ZKed6��ZLed7��ZMed8��ZNed9��ZOed:��ZPed;��ZQed<��ZRed=��ZSed>��ZTed?��ZUed@��ZVedA��ZWyB)H�AXTablez<Utilities for obtaining information about accessible tables.c�z�tjtj��}d|_|j�y)z3Starts thread to periodically clear cached details.)�targetTN)�	threading�Threadr�_clear_stored_data�daemon�start)�threads �//usr/lib/python3/dist-packages/orca/ax_table.py�start_cache_clearing_threadz#AXTable.start_cache_clearing_threadLs*���!�!��)C�)C�D����
�����c�X�	tjd�tj��*)z*Clears any data we have cached for objects�<)�time�sleepr�_clear_all_dictionaries�rrrzAXTable._clear_stored_dataTs#����J�J�r�N��+�+�-�rc��d}|r|d|��z
}tjtj|d�tj5tj
j
�tjj
�tjj
�tjj
�tjj
�tjj
�tjj
�tjj
�tjj
�tjj
�tj j
�tj"j
�tj$j
�ddd�y#1swYyxYw)NzAXTable: Clearing cache.z	 Reason: T)r�printMessage�
LEVEL_INFOr�_lock�CAPTIONS�clear�PHYSICAL_COORDINATES_FROM_CELL�PHYSICAL_COORDINATES_FROM_TABLE�PHYSICAL_SPANS_FROM_CELL�PHYSICAL_SPANS_FROM_TABLE�PHYSICAL_COLUMN_COUNT�PHYSICAL_ROW_COUNT�PRESENTABLE_COORDINATES�PRESENTABLE_COORDINATES_LABELS�PRESENTABLE_COLUMN_COUNT�PRESENTABLE_ROW_COUNT�COLUMN_HEADERS_FOR_CELL�ROW_HEADERS_FOR_CELL)�reason�msgs  rrzAXTable._clear_all_dictionaries\s9��(����Y�v�h�'�'�C�
���5�+�+�S�$�7�
�]�]�
	1����"�"�$��2�2�8�8�:��3�3�9�9�;��,�,�2�2�4��-�-�3�3�5��)�)�/�/�1��&�&�,�,�.��+�+�1�1�3��2�2�8�8�:��,�,�2�2�4��)�)�/�/�1��+�+�1�1�3��(�(�.�.�0�
	1�
	1�
	1�s
�FG�Gc�.�tj|�y)z*Clears all cached information immediately.N)rr)r/s r�clear_cache_nowzAXTable.clear_cache_nowrs��	�'�'��/rc��tj|�syt|�tjvr(tjjt|��S	tjj|�}d|d|g}tjtj|d�|tjt|�<|S#t$r4}d|��}tjtj|d�Yd}~yd}~wwxYw)z>Returns the accessible object containing the caption of table.Nz#AXTable: Exception in get_caption: TzAXTable: Caption for�is)r�supports_table�hashrr!�getr�Table�get_caption�	Exceptionrrr�printTokens)�table�caption�errorr0�tokenss     rr9zAXTable.get_captionxs����&�&�u�-����;�'�*�*�*��#�#�'�'��U��4�4�	��k�k�-�-�e�4�G�)�%��w�?��
���%�*�*�F�D�9�(/�����e��%�����	�7��w�?�C����u�/�/��d�;���	�s�C�	D�*C;�;Dc��tj|�sy|rtj|�}|�|Stjjt
|��}|�|S	tjj|�}d|d|g}tjtj|d�|tjt
|�<|S#t$r4}d|��}tjtj|d�Yd}~yd}~wwxYw)z"Returns the column count of table.���Nz(AXTable: Exception in get_column_count: TzAXTable: Column count forr4)rr5r� _get_column_count_from_attributer'r7r6rr8�
get_n_columnsr:rrrr;�r<�prefer_attribute�countr>r0r?s      r�get_column_countzAXTable.get_column_count�s����&�&�u�-����<�<�U�C�E�� ����-�-�1�1�$�u�+�>�����L�	��K�K�-�-�e�4�E�.�u�d�E�B��
���%�*�*�F�D�9�5:��%�%�d�5�k�2�����	�<�U�G�D�C����u�/�/��d�;���	���C�	D�*C?�?Dc��t|�tjvr(tjjt|��St	j
|�}|jd�}d}|�t
|�}d|d|g}tjtj|d�|tjt|�<|S)zJReturns the value of the 'colcount' object attribute or None if not found.�colcountNz#AXTable: Column count attribute forr4T)
r6rr+r7r�get_attributes_dict�intrr;r�r<�attrs�attrrFr?s     rrBz(AXTable._get_column_count_from_attribute�s�����;�'�:�:�:��3�3�7�7��U��D�D��,�,�U�3���y�y��$��������I�E�7���e�L��
���%�*�*�F�D�9�8=��(�(��e��5��rc��tj|�sy|rtj|�}|�|Stjjt
|��}|�|S	tjj|�}d|d|g}tjtj|d�|tjt
|�<|S#t$r4}d|��}tjtj|d�Yd}~yd}~wwxYw)zReturns the row count of table.rANz%AXTable: Exception in get_row_count: TzAXTable: Row count forr4)rr5r�_get_row_count_from_attributer(r7r6rr8�
get_n_rowsr:rrrr;rDs      r�
get_row_countzAXTable.get_row_count�s����&�&�u�-����9�9�%�@�E�� ����*�*�.�.�t�E�{�;�����L�	��K�K�*�*�5�1�E�+�E�4��?��
���%�*�*�F�D�9�27��"�"�4��;�/�����	�9�%��A�C����u�/�/��d�;���	�rHc��t|�tjvr(tjjt|��St	j
|�}|jd�}d}|�t
|�}d|d|g}tjtj|d�|tjt|�<|S)zJReturns the value of the 'rowcount' object attribute or None if not found.�rowcountNz AXTable: Row count attribute forr4T)
r6rr,r7rrKrLrr;rrMs     rrQz%AXTable._get_row_count_from_attribute�s�����;�'�7�7�7��0�0�4�4�T�%�[�A�A��,�,�U�3���y�y��$��������I�E�4�e�T�5�I��
���%�*�*�F�D�9�5:��%�%�d�5�k�2��rc
���tt|tj|d���D]}tt|tj	|d���D]Q}	t
jj|||�dkDryt
jj|||�dkDry�S��y#t$r6}d|��}tjtj|d�Yd}~yd}~wwxYw)z<Returns True if table has at least one cell with a span > 1.FrTz,AXTable: Exception in is_non_uniform_table: N)
�range�minrrSrGrr8�get_row_extent_at�get_column_extent_atr:rrr)r<�max_rows�max_cols�row�colr>r0s       r�is_non_uniform_tablezAXTable.is_non_uniform_table�s�����X�w�'<�'<�U�E�'J�K�L�
	!�C��S��7�+C�+C�E�5�+Q�R�S�	
!��!��{�{�4�4�U�C��E��I�#��{�{�7�7��s�C�H�1�L�#�M�		
!�
	!���!�!�H���P�C��&�&�u�'7�'7��d�C� ��!�s�$B-�$B-�-	C,�6*C'�'C,c�N�tj|�sgS	tjj	|�}d|d|g}t
jtj|d�|S#t
$r6}d|��}t
jtj|d�gcYd}~Sd}~wwxYw)z0Returns the number of selected columns in table.z0AXTable: Exception in get_selected_column_count TNz"AXTable: Selected column count forr4)
rr5rr8�get_n_selected_columnsr:rrrr;�r<rFr>r0r?s     r�get_selected_column_countz!AXTable.get_selected_column_count�s����&�&�u�-��I�	��K�K�6�6�u�=�E�7��t�U�K��
���%�*�*�F�D�9�����	�D�U�G�L�C����u�/�/��d�;��I��	���A%�%	B$�.+B�B$�B$c�N�tj|�sgS	tjj	|�}d|d|g}t
jtj|d�|S#t
$r6}d|��}t
jtj|d�gcYd}~Sd}~wwxYw)zCReturns a list of column indices for the selected columns in table.z,AXTable: Exception in get_selected_columns: TNzAXTable: Selected columns for�are)
rr5rr8�get_selected_columnsr:rrrr;)r<�columnsr>r0r?s     rrgzAXTable.get_selected_columnss����&�&�u�-��I�	��k�k�6�6�u�=�G�2�5�%��I��
���%�*�*�F�D�9�����	�@���H�C����u�/�/��d�;��I��	�rdc�N�tj|�sgS	tjj	|�}d|d|g}t
jtj|d�|S#t
$r6}d|��}t
jtj|d�gcYd}~Sd}~wwxYw)z-Returns the number of selected rows in table.z-AXTable: Exception in get_selected_row_count TNzAXTable: Selected row count forr4)
rr5rr8�get_n_selected_rowsr:rrrr;rbs     r�get_selected_row_countzAXTable.get_selected_row_count s����&�&�u�-��I�	��K�K�3�3�E�:�E�4�U�D�%�H��
���%�*�*�F�D�9�����	�A�%��I�C����u�/�/��d�;��I��	�rdc�N�tj|�sgS	tjj	|�}d|d|g}t
jtj|d�|S#t
$r6}d|��}t
jtj|d�gcYd}~Sd}~wwxYw)z=Returns a list of row indices for the selected rows in table.z)AXTable: Exception in get_selected_rows: TNzAXTable: Selected rows forrf)
rr5rr8�get_selected_rowsr:rrrr;)r<�rowsr>r0r?s     rrmzAXTable.get_selected_rows2s����&�&�u�-��I�	��;�;�0�0��7�D�/��u�d�C��
���%�*�*�F�D�9�����	�=�e�W�E�C����u�/�/��d�;��I��	�rdc��tj|�sytj|d��}|dkrytj	|�|k(rytj|d��}tj
|�|k(S)z0Returns True if all cells in table are selected.F�rErT)rr5rrSrkrGrc)r<rn�colss   r�all_cells_are_selectedzAXTable.all_cells_are_selectedDsu���&�&�u�-���$�$�U�U�$�C���1�9���)�)�%�0�D�8���'�'���'�F���0�0��7�4�?�?rc�j�tj|�sy	tjj	|||�}d|�d|�d�|d|g}t
jtj|d�|S#t
$r<}d|�d|�d�|d|g}t
jtj|d�Yd}~yd}~wwxYw)	z1Returns the cell at the 0-indexed row and column.Nz(AXTable: Exception getting cell at row: z col: z in�:TzAXTable: Cell at row: r4)	rr5rr8�get_accessible_atr:rr;r)r<r]�column�cellr>r?s      r�get_cell_atzAXTable.get_cell_atUs����&�&�u�-��	��;�;�0�0���V�D�D�+�3�%�v�f�X�S�A�5�$�PT�U��
���%�*�*�F�D�9�����	�@���V�F�8�SV�W�Y^��5�"�F����e�.�.���=���		�s�!A-�-	B2�62B-�-B2c�
�tj|d�}|�|dk7rt|�Stj|�}tj|�t
jjk(r|}tj|�S)z>Returns the index of cell to be used with the table interface.ztable-cell-index�)	r�
get_attributerL�
get_parent�get_roler�Role�
TABLE_CELL�get_index_in_parent)rw�index�parents   r�_get_cell_indexzAXTable._get_cell_indexhsr���&�&�t�-?�@�����"���u�:��
�$�$�T�*�����V�$��
�
�(=�(=�=��D��+�+�D�1�1rc�2�tj|�sytj|�rtj|�\}}ntj
|�\}}|s||fStj|�\}}|�t|�}|�t|�}||fS)z!Returns the row and column spans.�rArA)	r	�is_table_cell_or_headerr�supports_table_cellr�_get_cell_spans_from_table_cell�_get_cell_spans_from_table�_get_cell_spans_from_attributerL)rwrE�row_span�col_span�rowspan_attr�colspan_attrs      r�get_cell_spanszAXTable.get_cell_spansys����2�2�4�8���'�'��-�!(�!H�!H��!N��H�h�!(�!C�!C�D�!I��H�h���X�%�%�%,�%K�%K�D�%Q�"��l��#��<�(�H��#��<�(�H���!�!rc��t|�tjvr(tjjt|��St	j
|�}|jd�}|jd�}d|d|d|g}t
jtj|d�||ftjt|�<||fS)zMReturns the row and column spans exposed via object attribute, or None, None.�rowspan�colspanz(AXTable: Row and col span attributes forrt�,T)	r6r�PRESENTABLE_SPANSr7rrKrr;r)rwrNr�r�r?s     rr�z&AXTable._get_cell_spans_from_attribute�s�����:��2�2�2��,�,�0�0��d��<�<��,�,�T�2���9�9�Y�'���9�9�Y�'��<�d�C��SV�X`�a��
���%�*�*�F�D�9�08�(�0B��!�!�$�t�*�-���!�!rc��t|�tjvr(tjjt|��Stj	|�}|dkrytj|�}|�yt
j|�sytj|�ry	tjj||�}|dsy|j"}tj%|d�}||kDr1d||�d	|��g}tj&tj |d�d
}|j(}	tj+|d�}
|	|
kDr1d||	�d|
��g}tj&tj |d�d
}	d
|d|�d|	��g}tj&tj |d�||	ftjt|�<||	fS#t$r4}d|��}tjtj |d�Yd}~yd}~wwxYw)zAReturns the row and column spans of cell via the table interface.rr�N)rrz2AXTable: Exception in _get_cell_spans_from_table: TFz!AXTable: Table iface row span forz is greater than row count: rz!AXTable: Table iface col span forz is greater than col count: zAXTable: Table iface spans for�
are rowspan: �, colspan: )r6rr&r7r��	get_tablerr5r	�is_treerr8�get_row_column_extents_at_indexr:rrr�row_extentsrSr;�col_extentsrG)rwr�r<�resultr>r0r��	row_countr?r��	col_counts           rr�z"AXTable._get_cell_spans_from_table�s�����:��:�:�:��4�4�8�8��d��D�D��'�'��-���1�9���!�!�$�'���=���&�&�u�-�����u�%��	��[�[�@�@���N�F��a�y���%�%���)�)�%��7�	��i��9�4�!�
�">�y�k�J�L�F����e�.�.���=��H��%�%���,�,�U�E�:�	��i��9�4�!�
�">�y�k�J�L�F����e�.�.���=��H�2�D�!�(��;�x�j�A�C��
���%�*�*�F�D�9�8@�(�8J��)�)�$�t�*�5���!�!��9�	�F�u�g�N�C����u�/�/��d�;���	�s�$ G�	H	�*H�H	c�V�t|�tjvr(tjjt|��St	j
|�sy	tjj|�}tjj|�}d|d|�d|��g}tjtj|d�||ftjt|�<||fS#t$r4}d|��}tjtj|d�Yd}~yd}~wwxYw)zFReturns the row and column spans of cell via the table cell interface.r�z7AXTable: Exception in _get_cell_spans_from_table_cell: TNz"AXTable: TableCell iface spans forr�r�)r6rr%r7rr�r�	TableCell�get_row_span�get_column_spanr:rrrr;)rwr�r�r>r0r?s      rr�z'AXTable._get_cell_spans_from_table_cell�s����:��9�9�9��3�3�7�7��T�
�C�C��+�+�D�1��	����3�3�D�9�H����6�6�t�<�H�7��!�(��;�x�j�A�C��
���%�*�*�F�D�9�7?��7I��(�(��d��4���!�!���	�K�E�7�S�C����u�/�/��d�;���	�s�>C+�+	D(�4*D#�#D(c�p�tj|�sgS|dkrgS	tjj	||�}d|�d�|d|g}t
jtj|d�|�|gSgS#t
$r6}d|��}t
jtj|d�gcYd}~Sd}~wwxYw)zIReturns the column headers of the indexed column via the table interface.rz6AXTable: Exception in _get_column_headers_from_table: TNz'AXTable: Table iface header for column � ofr4)
rr5rr8�get_column_headerr:rrrr;)r<rv�headerr>r0r?s      r�_get_column_headers_from_tablez&AXTable._get_column_headers_from_table�s����&�&�u�-��I��A�:��I�	��[�[�2�2�5�&�A�F�<�F�8�3�G��PT�V\�]��
���%�*�*�F�D�9����8�O��	���	�J�5�'�R�C����u�/�/��d�;��I��	��� A6�6	B5�?+B0�*B5�0B5c�J�tj|�sgS	tjj	|�}d|g}t
jtj|d�|S#t
$r6}d|��}t
jtj|d�gcYd}~Sd}~wwxYw)zAReturns the column headers for cell via the table cell interface.z;AXTable: Exception in _get_column_headers_from_table_cell: TNz5AXTable: TableCell iface column headers for cell are:)
rr�rr��get_column_header_cellsr:rrrr;�rw�headersr>r0r?s     r�#_get_column_headers_from_table_cellz+AXTable._get_column_headers_from_table_cell	s����+�+�D�1��I�	��o�o�=�=�d�C�G�J�7�S��
���%�*�*�F�D�9�����	�O�PU�w�W�C����u�/�/��d�;��I��	���A#�#	B"�,+B�B"�B"c�p�tj|�sgS|dkrgS	tjj	||�}d|�d�|d|g}t
jtj|d�|�|gSgS#t
$r6}d|��}t
jtj|d�gcYd}~Sd}~wwxYw)zCReturns the row headers of the indexed row via the table interface.rz3AXTable: Exception in _get_row_headers_from_table: TNz$AXTable: Table iface header for row r�r4)
rr5rr8�get_row_headerr:rrrr;)r<r]r�r>r0r?s      r�_get_row_headers_from_tablez#AXTable._get_row_headers_from_tables����&�&�u�-��I���7��I�	��[�[�/�/��s�;�F�9���S�A�5�$�PV�W��
���%�*�*�F�D�9����8�O��	���	�G��w�O�C����u�/�/��d�;��I��	�r�c�J�tj|�sgS	tjj	|�}d|g}t
jtj|d�|S#t
$r6}d|��}t
jtj|d�gcYd}~Sd}~wwxYw)z>Returns the row headers for cell via the table cell interface.z8AXTable: Exception in _get_row_headers_from_table_cell: TNz2AXTable: TableCell iface row headers for cell are:)
rr�rr��get_row_header_cellsr:rrrr;r�s     r� _get_row_headers_from_table_cellz(AXTable._get_row_headers_from_table_cell3s����+�+�D�1��I�	��o�o�:�:�4�@�G�G��P��
���%�*�*�F�D�9�����	�L�U�G�T�C����u�/�/��d�;��I��	�r�c��tj|�}|�|Stj|�}tt|�j	t|���S)zCReturns row headers of cell that are not also headers of old_cell. )r�get_row_headers�list�set�
difference�rw�old_cellr��old_headerss    r�get_new_row_headerszAXTable.get_new_row_headersEsN���)�)�$�/�����N��-�-�h�7���C��L�+�+�C��,<�=�>�>rc��tj|�}|�|Stj|�}tt|�j	t|���S)zFReturns column headers of cell that are not also headers of old_cell. )r�get_column_headersr�r�r�r�s    r�get_new_column_headerszAXTable.get_new_column_headersPsN���,�,�T�2�����N��0�0��:���C��L�+�+�C��,<�=�>�>rc�Z�tj|�sgStj|�}|�|gStjjt
|��}|�|Stj|�}t|�dk7r|tjt
|�<|Stj|d�}t|�dk(rJ|d|vrC|jd|d�tj|d�}t|�dk(r|d|vr�C|tjt
|�<|S)zNReturns the row headers for cell, doing extra work to ensure we have them all.rr)
r	�
is_table_cellr�get_dynamic_row_headerr.r7r6�_get_row_headers�len�insert�rw�dynamic_headerr��otherss    rr�zAXTable.get_row_headers[s���(�(��.��I� �7�7��=���%�"�#�#��-�-�1�1�$�t�*�=�����M��)�)�$�/���v�;�!��7=�G�(�(��d��4��M��)�)�&��)�4���&�k�Q��6�!�9�F�#:��M�M�!�V�A�Y�'��-�-�f�Q�i�8�F��&�k�Q��6�!�9�F�#:�4:��$�$�T�$�Z�0��
rc�z�tj|�rtj|�Stj	|�\}}|dks|dkrgStj|�}|�gSg}tj
|�d}t|||z�D]'}|jtj||���)|S)z!Returns the row headers for cell.r)
rr�rr�� _get_cell_coordinates_from_tabler�r�rW�extendr�)rwr]rvr<r�r�r�s       rr�zAXTable._get_row_headers�s����'�'��-��;�;�D�A�A��>�>�t�D���V���7�f�q�j��I��!�!�$�'���=��I����4�4�T�:�1�=���3��g�
�.�	N�E��N�N�7�>�>�u�e�L�M�	N��rc���tj|�syt|dztj	|��}t|�D]}tj
||�s�yy)z<Returns True if table has any headers for rows 0-stop_after.FrT)rr5rXrrSrWr��r<�
stop_after�is   r�has_row_headerszAXTable.has_row_headers�s\���&�&�u�-����a���)>�)>�u�)E�F�
��z�"�	�A��2�2�5�!�<��	�rc�Z�tj|�sgStj|�}|�|gStjjt
|��}|�|Stj|�}t|�dk7r|tjt
|�<|Stj|d�}t|�dk(rJ|d|vrC|jd|d�tj|d�}t|�dk(r|d|vr�C|tjt
|�<|S)zQReturns the column headers for cell, doing extra work to ensure we have them all.rr)
r	r�r�get_dynamic_column_headerr-r7r6�_get_column_headersr�r�r�s    rr�zAXTable.get_column_headers�s���(�(��.��I� �:�:�4�@���%�"�#�#��0�0�4�4�T�$�Z�@�����M��,�,�T�2���v�;�!��:@�G�+�+�D��J�7��M��,�,�V�A�Y�7���&�k�Q��6�!�9�F�#:��M�M�!�V�A�Y�'��0�0����;�F��&�k�Q��6�!�9�F�#:�7=��'�'��T�
�3��
rc�z�tj|�rtj|�Stj	|�\}}|dks|dkrgStj|�}|�gSg}tj
|�d}t|||z�D]'}|jtj||���)|S)z$Returns the column headers for cell.rr)
rr�rr�r�r�r�rWr�r�)rwr]rvr<r�r�r�s       rr�zAXTable._get_column_headers�s����'�'��-��>�>�t�D�D��>�>�t�D���V���7�f�q�j��I��!�!�$�'���=��I����4�4�T�:�1�=���6�6�G�#3�4�	Q�E��N�N�7�A�A�%��O�P�	Q��rc���tj|�syt|dztj	|��}t|�D]}tj
||�s�yy)z?Returns True if table has any headers for columns 0-stop_after.FrT)rr5rXrrGrWr�r�s   r�has_column_headerszAXTable.has_column_headers�s\���&�&�u�-����a���)A�)A�%�)H�I�
��z�"�	�A��5�5�e�Q�?��	�rc��tj|�s&|r$tj|tj�}tj|�sytj|�rt
j
|�\}}nt
j|�\}}|s||fSt
j|�\}}|�t|�dz
}|�t|�dz
}||fS)z+Returns the 0-based row and column indices.r�r)
r	r�r�
find_ancestorr�r�%_get_cell_coordinates_from_table_cellr��$_get_cell_coordinates_from_attributerL)rwrE�	find_cellr]r^�	row_index�	col_indexs       r�get_cell_coordinateszAXTable.get_cell_coordinates�s����2�2�4�8�Y��)�)�$��0S�0S�T�D��2�2�4�8���'�'��-��D�D�T�J�H�C���?�?��E�H�C�����8�O�&�K�K�D�Q��	�9�� ��i�.�1�$�C�� ��i�.�1�$�C��C�x�rc���t|�tjvr(tjjt|��Stj	|�}|dkrytj|�}|�*d|g}t
jtj|d�y	tjj||�}tjj||�}d|d|�d	|��g}t
jtj|d�||ftjt|�<||fS#t$r4}d|��}t
jtj|d�Yd}~yd}~wwxYw)
zCReturns the row and column indices of cell via the table interface.rr�Nz6AXTable: Couldn't find table-implementing ancestor forTz8AXTable: Exception in _get_cell_coordinates_from_table: zAXTable: Table iface coords for�	are row: �, col: )r6rr$r7r�r�rr;rrr8�get_row_at_index�get_column_at_indexr:r)rwr�r<r?r]rvr>r0s        rr�z(AXTable._get_cell_coordinates_from_tablesG����:��@�@�@��:�:�>�>�t�D�z�J�J��'�'��-���1�9���!�!�$�'���=�N�PT�U�F����e�.�.���=��	��+�+�.�.�u�e�<�C��[�[�4�4�U�E�B�F�4�T�Y�s�e�7�SY�RZ�;[�\��
���%�*�*�F�D�9�>A�6�k��/�/��T�
�;��F�{����	�L�U�G�T�C����u�/�/��d�;���	�s�!AD3�3	E0�<*E+�+E0c�&�t|�tjvr(tjjt|��St	j
|�sy	tjj|�\}}}|syd|d|�d|��g}tjtj|d�||ftjt|�<||fS#t$r4}d|��}tjtj|d�Yd}~yd}~wwxYw)zHReturns the row and column indices of cell via the table cell interface.r�z=AXTable: Exception in _get_cell_coordinates_from_table_cell: TNz#AXTable: TableCell iface coords forr�r�)r6rr#r7rr�rr��get_positionr:rrrr;)rw�successr]rvr>r0r?s       rr�z-AXTable._get_cell_coordinates_from_table_cell-s�����:��?�?�?��9�9�=�=�d�4�j�I�I��+�+�D�1��	�#(�?�?�#?�#?��#E� �G�S�&���7���3�%�w�W]�V^�?_�`��
���%�*�*�F�D�9�=@�&�[��.�.�t�D�z�:��F�{����	�Q�RW�QX�Y�C����u�/�/��d�;���	�s�#C�	D�*D�Dc��|�yt|�tjvr(tjjt|��St	j
|�}|jd�}|jd�}d|d|d|g}t
jtj|d�||ftjt|�<|�|�||fSt	j|tj�}|�||fSt	j
|�}|jd|�}|jd|�}d|d||g}t
jtj|d�||ftjt|�<||fS)	zQReturns the 1-based indices for cell exposed via object attribute, or None, None.)NN�rowindex�colindexz)AXTable: Row and col index attributes forrtr�Tz$AXTable: Updated attributes based on)r6rr)r7rrKrr;rr�r	�is_table_row)rwrNr�r�r?r]s      rr�z,AXTable._get_cell_coordinates_from_attributeFsd���<����:��8�8�8��2�2�6�6�t�D�z�B�B��,�,�T�2���I�I�j�)�	��I�I�j�)�	�=�t�S�)�UX�Zc�d��
���%�*�*�F�D�9�6?��6J��'�'��T�
�3�� �Y�%:��i�'�'��$�$�T�;�+C�+C�D���;��i�'�'��,�,�S�1���I�I�j�)�4�	��I�I�j�)�4�	�8�#�s�I�y�Y��
���%�*�*�F�D�9�6?��6J��'�'��T�
�3��)�#�#rc�f�|�ytj|�r7	tjj	|�}tj
|�r|Sd�}||�r|Stj||�S#t$r4}d|��}tjtj|d�Yd}~�[d}~wwxYw)zJReturns obj if it is a table, otherwise returns the ancestor table of obj.Nz!AXTable: Exception in get_table: Tc��tj|�s*tj|�stj|�rt	j
|�Sy)NF)r	�is_table�
is_tree_tabler�rr5)�xs rr�z#AXTable.get_table.<locals>.is_tablexs?���#�#�A�&�+�*C�*C�A�*F�+�J]�J]�^_�J`��.�.�q�1�1�r)rr�rr�r�r5r:rrrr�)�objr<r>r0r�s     rr�zAXTable.get_tablegs����;���'�'��,�
!����1�1�#�6��
�*�*�5�1� �L�	�
�C�=��J��%�%�c�8�4�4���
@�9�%��A���"�"�5�#3�#3�S�$�?�?��
@�s�A3�3	B0�<*B+�+B0c��tj|�sytjtj|�tj
|��}tj|�rtj�d|��}|S)z@Returns an end-user-consumable string which describes the table.rz� )	rr5r�	tableSizerrSrGr_�TABLE_NON_UNIFORM)r<r�s  r�&get_table_description_for_presentationz.AXTable.get_table_description_for_presentation�sh���&�&�u�-���#�#�G�$9�$9�%�$@�'�BZ�BZ�[`�Ba�b���'�'��.� �2�2�3�1�V�H�=�F��
rc�:�d\}}tj|||�S)z Returns the first cell in table.)rr)rrx�r<r]r^s   r�get_first_cellzAXTable.get_first_cell�s"�����S��"�"�5�#�s�3�3rc��tj|�dz
tj|�dz
}}tj|||�S)zReturns the last cell in table.r)rrSrGrxr�s   r�
get_last_cellzAXTable.get_last_cell�sC���(�(��/�!�3�W�5M�5M�e�5T�WX�5X�S���"�"�5�#�s�3�3rc��tj|d��\}}|dz}tjtj|�||�S)z%Returns the cell above cell in table.Frpr�rr�rxr��rwr]r^s   r�get_cell_abovezAXTable.get_cell_above��F���/�/��u�/�M���S��q����"�"�7�#4�#4�T�#:�C��E�Erc���tj|d��\}}|tj|d��dz
}tjtj	|�||�S)z%Returns the cell below cell in table.Frpr�rr�r�rxr�r�s   r�get_cell_belowzAXTable.get_cell_below��\���/�/��u�/�M���S��w�%�%�d�U�%�C�A�F�F���"�"�7�#4�#4�T�#:�C��E�Erc��tj|d��\}}|dz}tjtj|�||�S)zReturns the cell to the left.Frprr�r�s   r�get_cell_on_leftzAXTable.get_cell_on_left�rrc���tj|d��\}}|tj|d��dz
}tjtj	|�||�S)zReturns the cell to the right.Frprrr�s   r�get_cell_on_rightzAXTable.get_cell_on_right�rrc��tj|d��d}tjtj|�|d�S)z,Returns the cell at the start of cell's row.Frprr��rwr]s  r�get_start_of_rowzAXTable.get_start_of_row�s>���*�*�4�%�*�H��K���"�"�7�#4�#4�T�#:�C��C�Crc���tj|d��d}tj|�}tj|�dz
}tj	tj|�||�S)z*Returns the cell at the end of cell's row.Frprr)rr�r�rGrx)rwr]r<r^s    r�get_end_of_rowzAXTable.get_end_of_row�sc���*�*�4�%�*�H��K���!�!�$�'���&�&�u�-��1���"�"�7�#4�#4�T�#:�C��E�Erc��tj|d��d}tjtj|�d|�S)z-Returns the cell at the top of cell's column.Frprrr��rwr^s  r�get_top_of_columnzAXTable.get_top_of_column�s>���*�*�4�%�*�H��K���"�"�7�#4�#4�T�#:�A�s�C�Crc���tj|d��d}tj|�}tj|�dz
}tj	tj|�||�S)z0Returns the cell at the bottom of cell's column.Frpr)rr�r�rSrx)rwr^r<r]s    r�get_bottom_of_columnzAXTable.get_bottom_of_column�sc���*�*�4�%�*�H��K���!�!�$�'���#�#�E�*�Q�.���"�"�7�#4�#4�T�#:�C��E�Erc�r�tj|d��}|jd|jd��S)z.Returns the formula associated with this cell.F)�	use_cache�formula�Formula)rrKr7)rwrNs  r�get_cell_formulazAXTable.get_cell_formula�s0���,�,�T�U�C���y�y��E�I�I�i�$8�9�9rc�N�tj|d��\}}|dk(xr|dk(S)z4Returns True if this is the first cell in its table.Frpr�rr�r�s   r�
is_first_cellzAXTable.is_first_cell�s0���/�/��u�/�M���S��a�x�$�C�1�H�$rc���tj|d��\}}|dks|dkrytj|�}|�y|dztj|d��k(xr|dztj	|d��k(S)z3Returns True if this is the last cell in its table.Frprr)rr�r�rSrG)rwr]r^r<s    r�is_last_cellzAXTable.is_last_cell�s����/�/��u�/�M���S���7�c�A�g���!�!�$�'���=���Q�w�'�/�/���/�N�N�S��a��7�3�3�E�E�3�R�R�	Src�@�tj|d��d}|dk(S)z2Returns True if this is the first cell in its row.Frprrrrs  r�is_start_of_rowzAXTable.is_start_of_row��'���*�*�4�%�*�H��K���a�x�rc��tj|d��d}|dkrytj|�}|�y|dztj|d��k(S)z1Returns True if this is the last cell in its row.Frprr)rr�r�rG)rwr^r<s   r�
is_end_of_rowzAXTable.is_end_of_rows_���*�*�4�%�*�H��K����7���!�!�$�'���=���Q�w�'�2�2�5�5�2�Q�Q�Qrc�@�tj|d��d}|dk(S)z5Returns True if this is the first cell in its column.Frprrrs  r�is_top_of_columnzAXTable.is_top_of_columnr rc��tj|d��d}|dkrytj|�}|�y|dztj|d��k(S)z4Returns True if this is the last cell in its column.Frprr)rr�r�rS)rwr]r<s   r�is_bottom_of_columnzAXTable.is_bottom_of_columns_���*�*�4�%�*�H��K����7���!�!�$�'���=���Q�w�'�/�/���/�N�N�Nrc��d\}}tj|�}tj|�r�|j	d�dk(rd\}}n�tj
|�sd\}}n�|j	d�dk(s|j	d�dk(rd	\}}nztj|�stj|�rd
\}}nJtj|�stj|�rd\}}ntj|�rd\}}d
|d|�d|�d�g}tjtj|d�|S)z<Returns True if this table should be treated as layout only.)FzNot enough informationzlayout-guess�true)Tz#The layout-guess attribute is true.)Tz Doesn't support table interface.z	xml-rolesr<�tag)Fz0Is a web table without layout-guess set to true.)FzHas headers)FzHas name or description)FzHas captionzAXTable:zis layout only: z (�)T)rrKr	r�r7r5rr�r��get_name�get_descriptionr9rr;r)r<r�r/rNr?s     r�is_layout_tablezAXTable.is_layout_table#s��9�����,�,�U�3������&��y�y��(�F�2�!L�����,�,�U�3�!I�������;�'�7�2�e�i�i��6F�'�6Q�!Z�����+�+�E�2�g�6M�6M�e�6T�!5�����"�"�5�)�X�-E�-E�e�-L�!A�����$�$�U�+�!5�����e�'7��x�r�&���%K�L��
���%�*�*�F�D�9��
rc��t|�tjvr(tjjt|��St	j
|�}d}|jd|jd��}|jd|jd��}|�|�|�|��}d|d|��g}t
jtj|d�|tjt|�<|r|St	j|tj�}|�|St	j
|�}|jd|jd|��}|jd|jd|��}|�|�|�|��}d	|d|��g}t
jtj|d�|tjt|�<|S)
zDReturns the text that should be used instead of the numeric indices.rz�colindextext�coltext�rowindextext�rowtextzAXTable: Coordinates label forz: Tz+AXTable: Updated coordinates label based on)r6rr*r7rrKrr;rr�r	r�)rwrNr��	col_label�	row_labelr?r]s       r�get_label_for_cell_coordinatesz&AXTable.get_label_for_cell_coordinates;s�����:��?�?�?��9�9�=�=�d�4�j�I�I��,�,�T�2�����I�I�n�e�i�i�	�.B�C�	��I�I�n�e�i�i�	�.B�C�	�� �Y�%:�!�{�9�+�.�F�2�D�B�v�h�-�H��
���%�*�*�F�D�9�=C��.�.�t�D�z�:���M��$�$�T�;�+C�+C�D���;��M��,�,�S�1���I�I�n�e�i�i�	�9�.M�N�	��I�I�n�e�i�i�	�9�.M�N�	�� �Y�%:�!�{�9�+�.�F�?���6�(�m�T��
���%�*�*�F�D�9�=C��.�.�t�D�z�:��
rc���tj|�}tjjt	|��}|�ytj|�\}}||k(rytj
|||�S)z)Returns the user-set row header for cell.N)rr��DYNAMIC_ROW_HEADERS_COLUMNr7r6r�rx)rwr<�headers_column�cell_row�cell_columns     rr�zAXTable.get_dynamic_row_headerasl���!�!�$�'�� �;�;�?�?��U��L���!�� '� <� <�T� B���+��.�(���"�"�5�(�N�C�Crc���tj|�}tjjt	|��}|�ytj|�\}}||k(rytj
|||�S)z,Returns the user-set column header for cell.N)rr��DYNAMIC_COLUMN_HEADERS_ROWr7r6r�rx)rwr<�headers_rowr9r:s     rr�z!AXTable.get_dynamic_column_headerpsl���!�!�$�'���8�8�<�<�T�%�[�I����� '� <� <�T� B���+��{�"���"�"�5�+�{�C�Crc�<�|tjt|�<y)z7Sets the dynamic row headers column of table to column.N)rr7r6)r<rvs  r�set_dynamic_row_headers_columnz&AXTable.set_dynamic_row_headers_columns��;A��*�*�4��;�7rc�<�|tjt|�<y)z4Sets the dynamic column headers row of table to row.N)rr<r6)r<r]s  r�set_dynamic_column_headers_rowz&AXTable.set_dynamic_column_headers_row�s��;>��*�*�4��;�7rc��t|�tjvrytjjt|��y)z/Clears the dynamic row headers column of table.N)r6rr7�pop�r<s r� clear_dynamic_row_headers_columnz(AXTable.clear_dynamic_row_headers_column��1����;�g�@�@�@���*�*�.�.�t�E�{�;rc��t|�tjvrytjjt|��y)z/Clears the dynamic column headers row of table.N)r6rr<rCrDs r� clear_dynamic_column_headers_rowz(AXTable.clear_dynamic_column_headers_row�rFrN)rz)T)�rI)�
)TF)X�__name__�
__module__�__qualname__�__doc__r!r#r$r%r&r'r(r)r*r�r+r,r-r.r<r7r�Lockr �staticmethodrrrr2r9rGrBrSrQr_rcrgrkrmrrrxr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrr	rrrrrrrrr"r$r&r-r5r�r�r?rArErHrrrrr3s���F��H�%'�"�&(�#�!�� "������ ��%'�"���!���� ����"$��!#���I�N�N��E������.��.��1��1�*�0��0�
����*����6����"����6����"����"����"����"����"����"�@��@� ����$�2��2� �"��"�,�
"��
"��4"��4"�l�"��"�2����.����"����.����"�?��?��?��?��&��&�P����*�����&��&�P����*��������2����:����0�$��$�@�5��5�4�	��	��4��4��4��4��F��F��F��F��F��F��F��F��D��D��F��F��D��D��F��F��:��:��%��%��S��S������R��R������O��O�����.�#��#�J�D��D��D��D��A��A�
�>��>�
�<��<��<��<rr)rN�__id__�__version__�__date__�
__copyright__�__license__rr�gi�require_version�
gi.repositoryrrzrr�	ax_objectr�ax_utilitiesr	rrrrr�<module>r[sl��,�������;�
�����	�����7�E�"�����%�h<�h<�V#�#�#�%r

Zerion Mini Shell 1.0