o
    ýÞh™  ã                   @  s–   d 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
 er:ddlmZ ddlmZ dd	lmZ dd
l	mZ G dd„ de
ƒZG dd„ dƒZdS )zhObjects related to shapes.

A shape is a visual object that appears on the drawing layer of a document.
é    )Úannotations)ÚTYPE_CHECKING)ÚWD_INLINE_SHAPE)Únsmap)ÚParented)ÚCT_Body)Ú	CT_Inline)Ú	StoryPart)ÚLengthc                      sH   e Zd ZdZd‡ fdd„Zdd
d„Zdd„ Zdd„ Zedd„ ƒZ	‡  Z
S )ÚInlineShapeszUSequence of |InlineShape| instances, supporting len(), iteration, and indexed access.Úbody_elmr   Úparentr	   c                   s   t t| ƒ |¡ || _d S ©N)Úsuperr   Ú__init__Ú_body)Úselfr   r   ©Ú	__class__© úJ/var/www/html/premium_crap/venv/lib/python3.10/site-packages/docx/shape.pyr      s   
zInlineShapes.__init__ÚidxÚintc                 C  s4   z
| j | }W t|ƒS  ty   d| }t|ƒ‚w )z2Provide indexed access, e.g. 'inline_shapes[idx]'.z$inline shape index [%d] out of range)Ú_inline_lstÚ
IndexErrorÚInlineShape)r   r   ÚinlineÚmsgr   r   r   Ú__getitem__   s   üþzInlineShapes.__getitem__c                 C  s   dd„ | j D ƒS )Nc                 s  s   � | ]}t |ƒV  qd S r   )r   )Ú.0r   r   r   r   Ú	<genexpr>'   s   € z(InlineShapes.__iter__.<locals>.<genexpr>)r   ©r   r   r   r   Ú__iter__&   s   zInlineShapes.__iter__c                 C  s
   t | jƒS r   )Úlenr   r!   r   r   r   Ú__len__)   s   
zInlineShapes.__len__c                 C  s   | j }d}| |¡S )Nz//w:p/w:r/w:drawing/wp:inline)r   Úxpath)r   Úbodyr%   r   r   r   r   ,   s   
zInlineShapes._inline_lst)r   r   r   r	   )r   r   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r"   r$   Úpropertyr   Ú__classcell__r   r   r   r   r      s    

r   c                      sh   e Zd ZdZd‡ fdd„Zeddd	„ƒZejddd	„ƒZedd„ ƒZedd„ ƒZ	e	jddd„ƒZ	‡  Z
S )r   zdProxy for an ``<wp:inline>`` element, representing the container for an inline
    graphical object.r   r   c                   s   t t| ƒ ¡  || _d S r   )r   r   r   Ú_inline)r   r   r   r   r   r   7   s   
zInlineShape.__init__Úreturnr
   c                 C  ó
   | j jjS )z[Read/write.

        The display height of this inline shape as an |Emu| instance.
        )r-   ÚextentÚcyr!   r   r   r   Úheight;   ó   
zInlineShape.heightr1   c                 C  ó   || j j_|| j jjjj_d S r   )r-   r0   r1   ÚgraphicÚgraphicDataÚpicÚspPr)r   r1   r   r   r   r2   C   ó   
c                 C  sf   | j jj}|j}|td kr|jjj}|jdurt	j
S t	jS |td kr't	jS |td kr0t	jS t	jS )z�The type of this inline shape as a member of
        ``docx.enum.shape.WD_INLINE_SHAPE``, e.g. ``LINKED_PICTURE``.

        Read-only.
        r7   NÚcÚdgm)r-   r5   r6   Úurir   r7   ÚblipFillÚblipÚlinkr   ÚLINKED_PICTUREÚPICTUREÚCHARTÚ	SMART_ARTÚNOT_IMPLEMENTED)r   r6   r<   r>   r   r   r   ÚtypeH   s   


zInlineShape.typec                 C  r/   )zZRead/write.

        The display width of this inline shape as an |Emu| instance.
        )r-   r0   Úcxr!   r   r   r   Úwidth\   r3   zInlineShape.widthrF   c                 C  r4   r   )r-   r0   rF   r5   r6   r7   r8   )r   rF   r   r   r   rG   d   r9   )r   r   )r.   r
   )r1   r
   )rF   r
   )r'   r(   r)   r*   r   r+   r2   ÚsetterrE   rG   r,   r   r   r   r   r   3   s    

r   N)r*   Ú
__future__r   Útypingr   Údocx.enum.shaper   Údocx.oxml.nsr   Údocx.sharedr   Údocx.oxml.documentr   Údocx.oxml.shaper   Údocx.parts.storyr	   r
   r   r   r   r   r   r   Ú<module>   s    