o
    7 h9                     @  s  d Z ddlmZ ddlmZmZ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 dd	lmZ dd
lmZmZmZmZmZmZ er`ddlmZ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+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;lxml custom element classes for shape-related XML elements.    )annotations)TYPE_CHECKINGCallablecast)MSO_AUTO_SHAPE_TYPEPP_PLACEHOLDER)	parse_xmlnsdecls)BaseShapeElement)ST_CoordinateST_PositiveCoordinate
XsdBoolean	XsdString)CT_TextBody)BaseOxmlElementOneAndOnlyOneOptionalAttributeRequiredAttribute
ZeroOrMore	ZeroOrOne)#CT_ApplicationNonVisualDrawingPropsCT_NonVisualDrawingPropsCT_ShapeProperties)Lengthc                   @  6   e Zd ZU dZedeZded< edeZded< dS )CT_AdjPoint2Dz`a:pt` custom element class.xr   yN)	__name__
__module____qualname____doc__r   r   r   __annotations__r    r$   r$   b/var/www/html/figdemos/bartoux_crm/venv/lib/python3.10/site-packages/pptx/oxml/shapes/autoshape.pyr   &   s   
 r   c                   @  s:   e Zd ZU dZded< dZededd dZd	ed
< dS )CT_CustomGeometry2Dz"`a:custGeom` custom element class.zCallable[[], CT_Path2DList]get_or_add_pathLst)a:avLstza:gdLstza:ahLstza:cxnLstza:rect	a:pathLstr)      N
successorszCT_Path2DList | NonepathLst)r   r    r!   r"   r#   _tag_seqr   r-   r$   r$   r$   r%   r&   -   s   
 r&   c                   @  r   )CT_GeomGuidezz`a:gd` custom element class.

    Defines a "guide", corresponding to a yellow diamond-shaped handle on an autoshape.
    namestrfmlaN)	r   r    r!   r"   r   r   r0   r#   r2   r$   r$   r$   r%   r/   8   s   
 r/   c                   @  s*   e Zd ZU dZded< ded< edZdS )CT_GeomGuideListz`a:avLst` custom element class.zCallable[[], CT_GeomGuide]_add_gdlist[CT_GeomGuide]gd_lstza:gdN)r   r    r!   r"   r#   r   gdr$   r$   r$   r%   r3   B   s
   
 r3   c                   @  s,   e Zd ZU dZedZedeZde	d< dS )CT_NonVisualDrawingShapePropsz!`p:cNvSpPr` custom element class.z	a:spLockstxBoxzbool | NoneN)
r   r    r!   r"   r   ZspLocksr   r   r9   r#   r$   r$   r$   r%   r8   L   s   
 r8   c                   @  s   e Zd ZU dZded< ded< ded< edd	d
Zedd	d
Zedd	d
Ze	de
Zded< e	de
Zded< dddZdddZdddZdS ) 	CT_Path2Dz`a:path` custom element class.zCallable[[], CT_Path2DClose]
_add_closezCallable[[], CT_Path2DLineTo]	_add_lnTozCallable[[], CT_Path2DMoveTo]_add_moveToza:closer$   r+   za:lnToza:moveTowzLength | NonehreturnCT_Path2DClosec                 C  s   |   S )z{Return a newly created `a:close` element.

        The new `a:close` element is appended to this `a:path` element.
        )r;   selfr$   r$   r%   	add_closef   s   zCT_Path2D.add_closer   r   r   CT_Path2DLineToc                 C  "   |   }| }|||_|_|S )zReturn a newly created `a:lnTo` subtree with end point *(x, y)*.

        The new `a:lnTo` element is appended to this `a:path` element.
        )r<   _add_ptr   r   )rC   r   r   lnToptr$   r$   r%   add_lnTom      zCT_Path2D.add_lnToc                 C  rF   )zReturn a newly created `a:moveTo` subtree with point `(x, y)`.

        The new `a:moveTo` element is appended to this `a:path` element.
        )r=   rG   r   r   )rC   r   r   moveTorI   r$   r$   r%   
add_moveTow   rK   zCT_Path2D.add_moveToN)r@   rA   )r   r   r   r   r@   rE   )r   r   r   r   )r   r    r!   r"   r#   r   closerH   rL   r   r   r>   r?   rD   rJ   rM   r$   r$   r$   r%   r:   U   s"   
 


r:   c                   @  s   e Zd ZdZdS )rA   z`a:close` custom element class.N)r   r    r!   r"   r$   r$   r$   r%   rA      s    rA   c                   @  &   e Zd ZU dZded< edddZdS )rE   z`a:lnTo` custom element class.Callable[[], CT_AdjPoint2D]rG   a:ptr$   r+   Nr   r    r!   r"   r#   r   rI   r$   r$   r$   r%   rE         
 rE   c                   @  s0   e Zd ZU dZded< edddZdd
dZdS )CT_Path2DListz!`a:pathLst` custom element class.zCallable[[], CT_Path2D]	_add_pathza:pathr$   r+   r>   r   r?   c                 C  s   |   }|||_|_|S )z.Return a newly created `a:path` child element.)rU   r>   r?   )rC   r>   r?   pathr$   r$   r%   add_path   s   zCT_Path2DList.add_pathN)r>   r   r?   r   )r   r    r!   r"   r#   r   rV   rW   r$   r$   r$   r%   rT      s
   
 rT   c                   @  rO   )CT_Path2DMoveToz `a:moveTo` custom element class.rP   rG   rQ   r$   r+   NrR   r$   r$   r$   r%   rX      rS   rX   c                   @  s\   e Zd ZU dZded< ded< edZded< ed	eZ	d
ed	< e
dddZdddZdS )CT_PresetGeometry2Dz"`a:prstGeom` custom element class.zCallable[[], CT_GeomGuideList]
_add_avLstzCallable[[], None]_remove_avLstr(   zCT_GeomGuideList | NoneavLstprstr   r@   r5   c                 C  s   | j }|du r	g S |jS )zLSequence of `a:gd` element children of `a:avLst`. Empty if none are present.N)r\   r6   )rC   r\   r$   r$   r%   r6         zCT_PresetGeometry2D.gd_lstguideslist[tuple[str, int]]c                 C  s:   |    |  }|D ]\}}| }||_d| |_q
dS )zOReplace any `a:gd` element children of `a:avLst` with ones forme from `guides`.zval %dN)r[   rZ   r4   r0   r2   )rC   r_   r\   r0   valr7   r$   r$   r%   rewrite_guides   s   z"CT_PresetGeometry2D.rewrite_guidesN)r@   r5   )r_   r`   )r   r    r!   r"   r#   r   r\   r   r   r]   propertyr6   rb   r$   r$   r$   r%   rY      s   
 rY   c                   @  s   e Zd ZU dZded< edZded< edZded	< ed
ddZ	ded< dCddZ
dd Zedd Zedd Zedd Zedd ZedDd)d*ZedEd0d1ZedFd5d6Zed7d8 Zed9d: ZedGd<d=Zd>d? Zed@dA ZdBS )HCT_Shapez`p:sp` custom element class.zCallable[[], CT_TextBody]Zget_or_add_txBodyzp:nvSpPrCT_ShapeNonVisualnvSpPrzp:spPrr   spPrzp:txBody)zp:extLstr+   zCT_TextBody | NonetxBodyr>   r   r?   r@   r:   c                 C  s.   | j j}|d u rtd| }|j||dS )Nzshape must be freeform)r>   r?   )rg   custGeom
ValueErrorr'   rW   )rC   r>   r?   ri   r-   r$   r$   r%   rW      s
   zCT_Shape.add_pathc                 C  s
   | j  S )zAReturn the `a:ln` grandchild element, newly added if not present.)rg   get_or_add_lnrB   r$   r$   r%   rk      s   
zCT_Shape.get_or_add_lnc                 C  s   | j jduS )zTrue if this shape has custom geometry, i.e. is a freeform shape.

        A shape has custom geometry if it has a `p:spPr/a:custGeom`
        descendant (instead of `p:spPr/a:prstGeom`).
        N)rg   ri   rB   r$   r$   r%   has_custom_geometry   s   zCT_Shape.has_custom_geometryc                 C  s    | j }|du r	dS | jjjduS )zTrue if this shape is an auto shape.

        A shape is an auto shape if it has a `a:prstGeom` element and does not have a txBox="1"
        attribute on cNvSpPr.
        NFT)prstGeomrf   cNvSpPrr9   rC   rm   r$   r$   r%   is_autoshape   s   zCT_Shape.is_autoshapec                 C  s   | j jjdu S )zTrue if this shape is a text box.

        A shape is a text box if it has a `txBox` attribute on cNvSpPr that resolves to |True|.
        The default when the txBox attribute is missing is |False|.
        T)rf   rn   r9   rB   r$   r$   r%   
is_textbox   s   zCT_Shape.is_textboxc                 C     | j jS )z4`a:ln` grand-child element or |None| if not present.)rg   lnrB   r$   r$   r%   rs      s   zCT_Shape.lnid_intr0   r1   r]   lefttopwidthheightc              	   C  s>   dt dddddddddf | ||||||f }ttt|S )zAReturn a new `p:sp` element tree configured as a base auto shape.a  <p:sp %s>
  <p:nvSpPr>
    <p:cNvPr id="%s" name="%s"/>
    <p:cNvSpPr/>
    <p:nvPr/>
  </p:nvSpPr>
  <p:spPr>
    <a:xfrm>
      <a:off x="%s" y="%s"/>
      <a:ext cx="%s" cy="%s"/>
    </a:xfrm>
    <a:prstGeom prst="%s">
      <a:avLst/>
    </a:prstGeom>
  </p:spPr>
  <p:style>
    <a:lnRef idx="1">
      <a:schemeClr val="accent1"/>
    </a:lnRef>
    <a:fillRef idx="3">
      <a:schemeClr val="accent1"/>
    </a:fillRef>
    <a:effectRef idx="2">
      <a:schemeClr val="accent1"/>
    </a:effectRef>
    <a:fontRef idx="minor">
      <a:schemeClr val="lt1"/>
    </a:fontRef>
  </p:style>
  <p:txBody>
    <a:bodyPr rtlCol="0" anchor="ctr"/>
    <a:lstStyle/>
    <a:p>
      <a:pPr algn="ctr"/>
    </a:p>
  </p:txBody>
</p:sp>ap%d%sr
   r   rd   r   )rt   r0   r]   rv   rw   rx   ry   xmlr$   r$   r%   new_autoshape_sp   s   $%'zCT_Shape.new_autoshape_spshape_idr   r   cxcyc                 C  s:   dt ddddddddf | |||||f }ttt|S )zReturn new `p:sp` element tree configured as freeform shape.

        The returned shape has a `a:custGeom` subtree but no paths in its
        path list.
        aJ  <p:sp %s>
  <p:nvSpPr>
    <p:cNvPr id="%s" name="%s"/>
    <p:cNvSpPr/>
    <p:nvPr/>
  </p:nvSpPr>
  <p:spPr>
    <a:xfrm>
      <a:off x="%s" y="%s"/>
      <a:ext cx="%s" cy="%s"/>
    </a:xfrm>
    <a:custGeom>
      <a:avLst/>
      <a:gdLst/>
      <a:ahLst/>
      <a:cxnLst/>
      <a:rect l="l" t="t" r="r" b="b"/>
      <a:pathLst/>
    </a:custGeom>
  </p:spPr>
  <p:style>
    <a:lnRef idx="1">
      <a:schemeClr val="accent1"/>
    </a:lnRef>
    <a:fillRef idx="3">
      <a:schemeClr val="accent1"/>
    </a:fillRef>
    <a:effectRef idx="2">
      <a:schemeClr val="accent1"/>
    </a:effectRef>
    <a:fontRef idx="minor">
      <a:schemeClr val="lt1"/>
    </a:fontRef>
  </p:style>
  <p:txBody>
    <a:bodyPr rtlCol="0" anchor="ctr"/>
    <a:lstStyle/>
    <a:p>
      <a:pPr algn="ctr"/>
    </a:p>
  </p:txBody>
</p:sp>rz   r{   r|   r}   r~   )r   r0   r   r   r   r   r   r$   r$   r%   new_freeform_sp&  s   )*,zCT_Shape.new_freeform_spph_typer   orientc           	   
   C  s~   t ttdtdd d|  d| d}|jj }||_||_||_	||_
tjtjtjtjtjf}||v r=|t  |S )zCReturn a new `p:sp` element tree configured as a placeholder shape.z<p:sp rz   r{   z >
  <p:nvSpPr>
    <p:cNvPr id="z" name="zq"/>
    <p:cNvSpPr>
      <a:spLocks noGrp="1"/>
    </p:cNvSpPr>
    <p:nvPr/>
  </p:nvSpPr>
  <p:spPr/>
</p:sp>)r   rd   r   r
   rf   nvPrZget_or_add_phtypeidxr   szr   ZTITLEZCENTER_TITLEZSUBTITLEZBODYOBJECTappendr   new)	rt   r0   r   r   r   r   spphZ(placeholder_types_that_have_a_text_framer$   r$   r%   new_placeholder_sp[  s0   zCT_Shape.new_placeholder_spc           	      C  s(   t  }|| |||||f }t|}|S )zDReturn a new `p:sp` element tree configured as a base textbox shape.)rd   _textbox_sp_tmplr   )	rt   r0   rv   rw   rx   ry   tmplr   r   r$   r$   r%   new_textbox_sp  s   zCT_Shape.new_textbox_spc                 C  s   | j }|du r	dS |jS )zKValue of `prst` attribute of `a:prstGeom` element or |None| if not present.N)rm   r]   ro   r$   r$   r%   r]     r^   zCT_Shape.prstrY   c                 C  rr   )zReference to `a:prstGeom` child element.

        |None| if this shape doesn't have one, for example, if it's a placeholder shape.
        )rg   rm   rB   r$   r$   r%   rm     s   zCT_Shape.prstGeomc                 C  s   t  S )N)r   new_p_txBodyrB   r$   r$   r%   _new_txBody  s   zCT_Shape._new_txBodyc                   C  s   dt ddddddddf S )Na  <p:sp %s>
  <p:nvSpPr>
    <p:cNvPr id="%s" name="%s"/>
    <p:cNvSpPr txBox="1"/>
    <p:nvPr/>
  </p:nvSpPr>
  <p:spPr>
    <a:xfrm>
      <a:off x="%s" y="%s"/>
      <a:ext cx="%s" cy="%s"/>
    </a:xfrm>
    <a:prstGeom prst="rect">
      <a:avLst/>
    </a:prstGeom>
    <a:noFill/>
  </p:spPr>
  <p:txBody>
    <a:bodyPr wrap="none">
      <a:spAutoFit/>
    </a:bodyPr>
    <a:lstStyle/>
    <a:p/>
  </p:txBody>
</p:sp>rz   r{   r|   r}   r	   r$   r$   r$   r%   r     s   zCT_Shape._textbox_sp_tmplN)r>   r   r?   r   r@   r:   )rt   ru   r0   r1   r]   r1   rv   ru   rw   ru   rx   ru   ry   ru   r@   rd   )r   ru   r0   r1   r   ru   r   ru   r   ru   r   ru   )
rt   ru   r0   r1   r   r   r   r1   r@   rd   )r@   rY   )r   r    r!   r"   r#   r   rf   rg   r   rh   rW   rk   rc   rl   rp   rq   rs   staticmethodr   r   r   r   r]   rm   r   r   r$   r$   r$   r%   rd      s>   
 




-4'

rd   c                   @  sB   e Zd ZU dZedZded< edZded< edZd	ed
< dS )re   z `p:nvSpPr` custom element class.zp:cNvPrr   cNvPrz	p:cNvSpPrr8   rn   zp:nvPrr   r   N)	r   r    r!   r"   r   r   r#   rn   r   r$   r$   r$   r%   re     s   
 re   N)0r"   
__future__r   typingr   r   r   Zpptx.enum.shapesr   r   	pptx.oxmlr   pptx.oxml.nsr
   pptx.oxml.shapes.sharedr   pptx.oxml.simpletypesr   r   r   r   pptx.oxml.textr   pptx.oxml.xmlchemyr   r   r   r   r   r   r   r   r   	pptx.utilr   r   r&   r/   r3   r8   r:   rA   rE   rT   rX   rY   rd   re   r$   r$   r$   r%   <module>   s6    	

	- |