o
    7 h6                     @  sd  d Z ddlmZ ddlmZmZ ddlmZ ddlm	Z	 ddl
mZ ddlmZmZmZmZmZmZmZmZmZmZ ddlmZmZmZmZmZmZmZ dd	lm Z  erhdd
l!m"Z" ddl#m$Z$m%Z% ddlm&Z& G dd deZ'G dd deZ(G dd deZ)G dd deZ*G dd deZ+G dd deZ,G dd deZ-G dd deZ.G dd deZ/dS ) z"Common shape-related oxml objects.    )annotations)TYPE_CHECKINGCallable)CT_GradientFillProperties)PP_PLACEHOLDER)qn)
ST_AngleST_CoordinateST_DirectionST_DrawingElementIdST_LineWidthST_PlaceholderSizeST_PositiveCoordinate
XsdBoolean	XsdStringXsdUnsignedInt)BaseOxmlElementChoiceOptionalAttributeOxmlElementRequiredAttribute	ZeroOrOneZeroOrOneChoice)Emu)CT_Hyperlink)CT_CustomGeometry2DCT_PresetGeometry2D)Lengthc                   @  s  e Zd ZU dZded< ed?ddZejdd Zed?d	d
Zejdd
 Zedd Z	e	jdd Z	edd Z
e
jdd Z
dd Zedd Zed@ddZedAddZedBddZedBdd Zed!d" ZedCd$d%ZejdDd'd%Zed(d) Zed*d+ Zed,d- Zed?d.d/Zejd0d/ Zed1d2 Zed?d3d4Zejd5d4 Zed6d7 ZdEd:d;Zd<d= Zd>S )FBaseShapeElementzRProvides common behavior for shape element classes like CT_Shape, CT_Picture, etc.CT_ShapePropertiesspPrreturnr   c                 C  
   |  dS Ncx_get_xfrm_attrself r)   _/var/www/html/figdemos/bartoux_crm/venv/lib/python3.10/site-packages/pptx/oxml/shapes/shared.pyr$   ,      
zBaseShapeElement.cxc                 C     |  d| d S r#   _set_xfrm_attrr(   valuer)   r)   r*   r$   0      c                 C  r"   Ncyr%   r'   r)   r)   r*   r3   4   r+   zBaseShapeElement.cyc                 C  r,   r2   r-   r/   r)   r)   r*   r3   8   r1   c                 C     t | dS NflipHboolr&   r'   r)   r)   r*   r6   <      zBaseShapeElement.flipHc                 C  r,   r5   r-   r/   r)   r)   r*   r6   @   r1   c                 C  r4   NflipVr7   r'   r)   r)   r*   r;   D   r9   zBaseShapeElement.flipVc                 C  r,   r:   r-   r/   r)   r)   r*   r;   H   r1   c                 C  s
   | j  S )zReturn the `a:xfrm` grandchild element, newly-added if not present.

        This version works for `p:sp`, `p:cxnSp`, and `p:pic` elements, others will need to
        override.
        )r    get_or_add_xfrmr'   r)   r)   r*   r<   L      
z BaseShapeElement.get_or_add_xfrmc                 C  s
   | j duS )z
        True if this shape element has a `p:ph` descendant, indicating it
        is a placeholder shape. False otherwise.
        N)phr'   r)   r)   r*   
has_ph_elmT   r=   zBaseShapeElement.has_ph_elmCT_Placeholder | Nonec                 C  s"   |  d}t|dkrdS |d S )z>The `p:ph` descendant element if there is one, None otherwise.z./*[1]/p:nvPr/p:phr   N)xpathlen)r(   Zph_elmsr)   r)   r*   r>   \   s   
zBaseShapeElement.phintc                 C     | j }|du rtd|jS )zpInteger value of placeholder idx attribute.

        Raises |ValueError| if shape is not a placeholder.
        Nnot a placeholder shape)r>   
ValueErroridxr(   r>   r)   r)   r*   ph_idxd      zBaseShapeElement.ph_idxstrc                 C  rD   )zjPlaceholder orientation, e.g. 'vert'.

        Raises |ValueError| if shape is not a placeholder.
        NrE   )r>   rF   orientrH   r)   r)   r*   	ph_oriento   rJ   zBaseShapeElement.ph_orientc                 C  rD   )ztPlaceholder size, e.g. ST_PlaceholderSize.HALF.

        Raises `ValueError` if shape is not a placeholder.
        NrE   )r>   rF   szrH   r)   r)   r*   ph_szz   rJ   zBaseShapeElement.ph_szc                 C  rD   )zPlaceholder type, e.g. ST_PlaceholderType.TITLE ('title').

        Raises `ValueError` if shape is not a placeholder.
        NrE   )r>   rF   typerH   r)   r)   r*   ph_type   rJ   zBaseShapeElement.ph_typefloatc                 C  s"   | j }|du s|jdu rdS |jS )z;Float representing degrees this shape is rotated clockwise.N        )xfrmrot)r(   rT   r)   r)   r*   rU      s   zBaseShapeElement.rotr0   c                 C  s   ||   _d S N)r<   rU   r/   r)   r)   r*   rU      r9   c                 C  
   | j jjS )z*
        Integer id of this shape
        )_nvXxPrcNvPridr'   r)   r)   r*   shape_id      
zBaseShapeElement.shape_idc                 C  rW   )z$
        Name of this shape
        )rX   rY   namer'   r)   r)   r*   
shape_name   r\   zBaseShapeElement.shape_namec                 C  s   |  tdS )z.Child `p:txBody` element, None if not present.zp:txBody)findr   r'   r)   r)   r*   txBody   s   zBaseShapeElement.txBodyc                 C  r"   Nxr%   r'   r)   r)   r*   rb      r+   zBaseShapeElement.xc                 C  r,   ra   r-   r/   r)   r)   r*   rb      r1   c                 C  s   | j jS )zThe `a:xfrm` grandchild element or |None| if not found.

        This version works for `p:sp`, `p:cxnSp`, and `p:pic` elements, others will need to
        override.
        )r    rT   r'   r)   r)   r*   rT      s   zBaseShapeElement.xfrmc                 C  r"   Nyr%   r'   r)   r)   r*   rd      r+   zBaseShapeElement.yc                 C  r,   rc   r-   r/   r)   r)   r*   rd      r1   c                 C  s   |  dd S )z
        Required non-visual shape properties element for this shape. Actual
        name depends on the shape type, e.g. `p:nvPicPr` for picture
        shape.
        z./*[1]r   )rA   r'   r)   r)   r*   rX      s   zBaseShapeElement._nvXxPrr]   Length | Nonec                 C  s   | j }|d u r	d S t||S rV   )rT   getattr)r(   r]   rT   r)   r)   r*   r&      s   
zBaseShapeElement._get_xfrm_attrc                 C  s   |   }t||| d S rV   )r<   setattr)r(   r]   r0   rT   r)   r)   r*   r.      s   zBaseShapeElement._set_xfrm_attrN)r!   r   )r!   r@   )r!   rC   )r!   rK   )r!   rR   )r0   rR   )r]   rK   r!   re   )__name__
__module____qualname____doc____annotations__propertyr$   setterr3   r6   r;   r<   r?   r>   rI   rM   rO   rQ   rU   r[   r^   r`   rb   rT   rd   rX   r&   r.   r)   r)   r)   r*   r   '   sp   
 



















r   c                   @  s&   e Zd ZU dZded< edddZdS )#CT_ApplicationNonVisualDrawingPropsz`p:nvPr` element.zCallable[[], CT_Placeholder]get_or_add_phzp:ph)z	a:audioCdza:wavAudioFileza:audioFileza:videoFileza:quickTimeFilezp:custDataLstzp:extLst
successorsN)rh   ri   rj   rk   rl   r   r>   r)   r)   r)   r*   ro      s   
 
ro   c                   @  s   e Zd ZdZdZeededededfedd d	Zed
edd d	Z	ededd d	Z
[edeeddZedd Zedd Zejdd ZdS )CT_LinePropertiesz'Custom element class for <a:ln> element)a:noFilla:solidFill
a:gradFill
a:pattFill
a:prstDash
a:custDashza:roundza:bevelza:miterz	a:headEndz	a:tailEnda:extLstrt   ru   rv   rw      Nrq   rx      ry      wr   defaultc                 C  s   | j S )zE
        Required to fulfill the interface used by dml.fill.
        )eg_lineFillPropertiesr'   r)   r)   r*   eg_fillProperties  s   z#CT_LineProperties.eg_fillPropertiesc                 C  s   | j }|du r	dS |jS )zfReturn value of `val` attribute of `a:prstDash` child.

        Return |None| if not present.
        N)prstDashval)r(   r   r)   r)   r*   prstDash_val  s   zCT_LineProperties.prstDash_valc                 C  s   |    |  }||_d S rV   )Z_remove_custDashZget_or_add_prstDashr   )r(   r   r   r)   r)   r*   r      s   
)rh   ri   rj   rk   _tag_seqr   r   r   r   r   ZcustDashr   r   r   r~   rm   r   r   rn   r)   r)   r)   r*   rs      s*    
	


rs   c                   @  st   e Zd ZU dZded< ded< dZededd d	Zd
ed< ededd d	Zd
ed< e	de
Ze	deZ[dS )CT_NonVisualDrawingPropsz`p:cNvPr` custom element class.zCallable[[], CT_Hyperlink]get_or_add_hlinkClickZget_or_add_hlinkHover)a:hlinkClicka:hlinkHoverrz   r      Nrq   zCT_Hyperlink | None
hlinkClickr      
hlinkHoverrZ   r]   )rh   ri   rj   rk   rl   r   r   r   r   r   r   rZ   r   r]   r)   r)   r)   r*   r   '  s   
 

r   c                   @  sp   e Zd ZU dZedeejdZded< ede	e	j
dZded< edeejdZded< eded	dZd
ed< dS )CT_Placeholderz`p:ph` custom element class.rP   r   r   rL   rK   rN   rG   r   rC   N)rh   ri   rj   rk   r   r   OBJECTrP   rl   r
   HORZrL   r   FULLrN   r   rG   r)   r)   r)   r*   r   5  s   
 r   c                   @  s6   e Zd ZU dZedeZded< edeZded< dS )
CT_Point2Dz3
    Custom element class for <a:off> element.
    rb   r   rd   N)	rh   ri   rj   rk   r   r	   rb   rl   rd   r)   r)   r)   r*   r   F  s   
 r   c                   @  s$   e Zd ZdZedeZedeZdS )CT_PositiveSize2Dz3
    Custom element class for <a:ext> element.
    r$   r3   N)rh   ri   rj   rk   r   r   r$   r3   r)   r)   r)   r*   r   O  s    
r   c                   @  s.  e Zd ZU dZded< ded< ded< ded	< d
Zededd dZded< ededd dZded< ededd dZ	ded< e
ededededededfedd dZed ed!d dZd"ed#< ed$ed%d dZ[ed&d' Zed(d) Zed2d,d-Zed.d/ Zd0d1 ZdS )3r   zCustom element class for `p:spPr` element.

    Shared by `p:sp`, `p:cxnSp`,  and `p:pic` elements as well as a few more obscure ones.
    zCallable[[], CT_Transform2D]r<   zCallable[[], CT_LineProperties]get_or_add_lnz!Callable[[], CT_PresetGeometry2D]Z_add_prstGeomzCallable[[], None]Z_remove_custGeom)a:xfrm
a:custGeom
a:prstGeomrt   ru   rv   
a:blipFillrw   	a:grpFilla:lna:effectLstza:effectDagz	a:scene3dza:sp3drz   r   r   Nrq   zCT_Transform2D | NonerT   r   r   zCT_CustomGeometry2D | NonecustGeomr      zCT_PresetGeometry2D | NoneprstGeomrt   ru   rv   r   rw   r   	   r   
   zCT_LineProperties | Nonelnr      c                 C     |  d}|s	dS t|d S )zL
        Shape width as an instance of Emu, or None if not present.
        z./a:xfrm/a:ext/@cxNr   rA   r   )r(   Z
cx_str_lstr)   r)   r*   r$        
zCT_ShapeProperties.cxc                 C  r   )zM
        Shape height as an instance of Emu, or None if not present.
        z./a:xfrm/a:ext/@cyNr   r   )r(   Z
cy_str_lstr)   r)   r*   r3     r   zCT_ShapeProperties.cyr!   re   c                 C  r   )zkDistance between the left edge of the slide and left edge of the shape.

        0 if not present.
        z./a:xfrm/a:off/@xNr   r   )r(   Z	x_str_lstr)   r)   r*   rb        
zCT_ShapeProperties.xc                 C  r   )z
        The offset of the top of the shape from the top of the slide, as an
        instance of Emu. None if not present.
        z./a:xfrm/a:off/@yNr   r   )r(   Z	y_str_lstr)   r)   r*   rd     r   zCT_ShapeProperties.yc                 C  s   t  S rV   )r   new_gradFillr'   r)   r)   r*   _new_gradFill  s   z CT_ShapeProperties._new_gradFill)r!   re   )rh   ri   rj   rk   rl   r   r   rT   r   r   r   r   r   r   Z	effectLstrm   r$   r3   rb   rd   r   r)   r)   r)   r*   r   X  sP   
 

	
	


r   c                   @  s  e Zd ZU dZdZededd dZded< ed	ed
d dZededd dZ	ededd dZ
[ededdZded< ededdZededdZedd Zejdd Zedd Zejdd Zedd Zejdd Zedd  Zejd!d  Zd"d# Zd$d% ZdS )&CT_Transform2Dz`a:xfrm` custom element class.

    NOTE: this is a composite including CT_GroupTransform2D, which appears
    with the `a:xfrm` tag in a group shape (including a slide `p:spTree`).
    )a:offa:exta:chOffa:chExtr   r   Nrq   zCT_Point2D | Noneoffr   r   r   r   r   r{   rU   rS   r   zfloat | Noner6   Fr;   c                 C     | j }|d u r	d S |jS rV   )r   rb   r(   r   r)   r)   r*   rb        zCT_Transform2D.xc                 C     |   }||_d S rV   )get_or_add_offrb   r(   r0   r   r)   r)   r*   rb        
c                 C  r   rV   )r   rd   r   r)   r)   r*   rd     r   zCT_Transform2D.yc                 C  r   rV   )r   rd   r   r)   r)   r*   rd     r   c                 C  r   rV   )extr$   r(   r   r)   r)   r*   r$     r   zCT_Transform2D.cxc                 C  r   rV   )get_or_add_extr$   r(   r0   r   r)   r)   r*   r$     r   c                 C  r   rV   )r   r3   r   r)   r)   r*   r3     r   zCT_Transform2D.cyc                 C  r   rV   )r   r3   r   r)   r)   r*   r3     r   c                 C     t d}d|_d|_|S )Nr   r   )r   r$   r3   r   r)   r)   r*   _new_ext     zCT_Transform2D._new_extc                 C  r   )Nr   r   )r   rb   rd   r   r)   r)   r*   _new_off  r   zCT_Transform2D._new_off)rh   ri   rj   rk   r   r   r   rl   r   ZchOffZchExtr   r   rU   r   r6   r;   rm   rb   rn   rd   r$   r3   r   r   r)   r)   r)   r*   r     sB   
 







r   N)0rk   
__future__r   typingr   r   Zpptx.dml.fillr   pptx.enum.shapesr   pptx.oxml.nsr   pptx.oxml.simpletypesr   r	   r
   r   r   r   r   r   r   r   pptx.oxml.xmlchemyr   r   r   r   r   r   r   	pptx.utilr   pptx.oxml.actionr   pptx.oxml.shapes.autoshaper   r   r   r   ro   rs   r   r   r   r   r   r   r)   r)   r)   r*   <module>   s.    0$	 68		d