
    li9                       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e      Z# G d de      Z$ G d de      Z% G d de      Z& G d de      Z' G d de      Z( G d de      Z) G d de      Z* G d de      Z+ G d d e      Z, G d! d"e      Z- G d# d$e      Z. G d% d&e      Z/y')(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                  J    e Zd ZU dZ ede      Zded<    ede      Zded<   y)CT_AdjPoint2Dz`a:pt` custom element class.xr   yN)	__name__
__module____qualname____doc__r   r   r   __annotations__r        X/var/www/html/eduruby.in/venv/lib/python3.12/site-packages/pptx/oxml/shapes/autoshape.pyr   r   &   s'    &!#}5Av5!#}5Av5r&   r   c                  D    e Zd ZU dZded<   dZ ededd       Zd	ed
<   y)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   r0   r%   r&   r'   r)   r)   -   s-    ,33SH$-%G! r&   r)   c                  J    e Zd ZU dZ ede      Zded<    ede      Zded<   y)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   r4   r$   r6   r%   r&   r'   r3   r3   8   s+    
 "&)4D#4!&)4D#4r&   r3   c                  6    e Zd ZU dZded<   ded<    ed      Zy)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'   r8   r8   B   s    )''	F	Br&   r8   c                  >    e Zd ZU dZ ed      Z ede      Zde	d<   y)CT_NonVisualDrawingShapePropsz!`p:cNvSpPr` custom element class.z	a:spLockstxBoxzbool | NoneN)
r    r!   r"   r#   r   spLocksr   r   r?   r$   r%   r&   r'   r>   r>   L   s%    +$G*E; r&   r>   c                      e Zd ZU dZded<   ded<   ded<    edd	
      Z edd	
      Z edd	
      Z e	de
      Zded<    e	de
      Zded<   ddZddZddZy)	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hc                "    | j                         S )z{Return a newly created `a:close` element.

        The new `a:close` element is appended to this `a:path` element.
        )rC   selfs    r'   	add_closezCT_Path2D.add_closef   s    
   r&   c                d    | j                         }|j                         }||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.
        )rD   _add_ptr   r   )rJ   r   r   lnTopts        r'   add_lnTozCT_Path2D.add_lnTom   s/    
 ~~\\^
bdr&   c                d    | j                         }|j                         }||c|_        |_        |S )zReturn a newly created `a:moveTo` subtree with point `(x, y)`.

        The new `a:moveTo` element is appended to this `a:path` element.
        )rE   rM   r   r   )rJ   r   r   moveTorO   s        r'   
add_moveTozCT_Path2D.add_moveTow   s2    
 !!#^^
bdr&   N)returnCT_Path2DClose)r   r   r   r   rT   CT_Path2DLineTo)r   r   r   r   )r    r!   r"   r#   r$   r   closerN   rR   r   r   rF   rG   rK   rP   rS   r%   r&   r'   rB   rB   U   sz    (,,,,..yR0Eh2.D
r2F("A}  )"A} !r&   rB   c                      e Zd ZdZy)rU   z`a:close` custom element class.N)r    r!   r"   r#   r%   r&   r'   rU   rU      s    )r&   rU   c                  0    e Zd ZU dZded<    edd      Zy)rV   z`a:lnTo` custom element class.Callable[[], CT_AdjPoint2D]rM   a:ptr%   r.   Nr    r!   r"   r#   r$   r   rO   r%   r&   r'   rV   rV      s    (((	6b	)Br&   rV   c                  8    e Zd ZU dZded<    edd      Zd	dZy)
CT_Path2DListz!`a:pathLst` custom element class.zCallable[[], CT_Path2D]	_add_pathza:pathr%   r.   c                D    | j                         }||c|_        |_        |S )z.Return a newly created `a:path` child element.)r_   rF   rG   )rJ   rF   rG   paths       r'   add_pathzCT_Path2DList.add_path   s"    ~~Ar&   N)rF   r   rG   r   )r    r!   r"   r#   r$   r   ra   rb   r%   r&   r'   r^   r^      s    +&&h2.Dr&   r^   c                  0    e Zd ZU dZded<    edd      Zy)CT_Path2DMoveToz `a:moveTo` custom element class.rZ   rM   r[   r%   r.   Nr\   r%   r&   r'   rd   rd      s    *((	6b	)Br&   rd   c                  v    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       ZddZy)CT_PresetGeometry2Dz"`a:prstGeom` custom element class.zCallable[[], CT_GeomGuideList]
_add_avLstzCallable[[], None]_remove_avLstr+   zCT_GeomGuideList | NoneavLstprstr   c                :    | j                   }|g S |j                  S )zLSequence of `a:gd` element children of `a:avLst`. Empty if none are present.)ri   r;   )rJ   ri   s     r'   r;   zCT_PresetGeometry2D.gd_lst   s!     

=I||r&   c                    | j                          | j                         }|D ]&  \  }}|j                         }||_        d|z  |_        ( y)zOReplace any `a:gd` element children of `a:avLst` with ones forme from `guides`.zval %dN)rh   rg   r9   r4   r6   )rJ   guidesri   r4   valr<   s         r'   rewrite_guidesz"CT_PresetGeometry2D.rewrite_guides   sJ    ! 	%ID#BBGnBG	%r&   N)rT   r:   )rm   zlist[tuple[str, int]])r    r!   r"   r#   r$   r   ri   r   r   rj   propertyr;   ro   r%   r&   r'   rf   rf      sR    ,..%%%.y%9E"9 1#!D
   %r&   rf   c                  n   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      Z	ded<   ddZ
d Zed        Zed        Zed        Zed        Ze	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dd       Zed d       Ze	 	 	 	 	 	 	 	 	 	 d!d       Zed        Zed        Zed"d       Zd Zed        Zy)#CT_Shapez`p:sp` custom element class.zCallable[[], CT_TextBody]get_or_add_txBodyzp:nvSpPrCT_ShapeNonVisualnvSpPrzp:spPrr   spPrzp:txBody)zp:extLstr.   zCT_TextBody | NonetxBodyc                    | j                   j                  }|t        d      |j                         }|j	                  ||      S )Nzshape must be freeform)rF   rG   )rv   custGeom
ValueErrorr*   rb   )rJ   rF   rG   ry   r0   s        r'   rb   zCT_Shape.add_path   sG    99%%566--/!q))r&   c                6    | j                   j                         S )zAReturn the `a:ln` grandchild element, newly added if not present.)rv   get_or_add_lnrI   s    r'   r|   zCT_Shape.get_or_add_ln   s    yy&&((r&   c                2    | 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)rv   ry   rI   s    r'   has_custom_geometryzCT_Shape.has_custom_geometry   s     yy!!--r&   c                d    | j                   }|y| 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.
        FT)prstGeomru   cNvSpPrr?   rJ   r   s     r'   is_autoshapezCT_Shape.is_autoshape   s1     =={{""((44r&   c                F    | 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)ru   r   r?   rI   s    r'   
is_textboxzCT_Shape.is_textbox   s     {{""((D00r&   c                .    | j                   j                  S )z4`a:ln` grand-child element or |None| if not present.)rv   lnrI   s    r'   r   zCT_Shape.ln   s     yy||r&   c                    dt        dd      ddddddd	dd
dddddd| ||||||fz  }t        t        t        |            S )zAReturn a new `p:sp` element tree configured as a base auto shape.<p:sp ap >
  <p:nvSpPr>
    <p:cNvPr id="%d" name="%sY"/>
    <p:cNvSpPr/>
    <p:nvPr/>
  </p:nvSpPr>
  <p:spPr>
    <a:xfrm>
      <a:off x="" y=""/>
      <a:ext cx="" cy="z("/>
    </a:xfrm>
    <a:prstGeom prst="a  ">
      <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>r   r   rr   r	   )id_r4   rj   lefttopwidthheightxmls           r'   new_autoshape_spzCT_Shape.new_autoshape_sp   sV    T !c*D$dD$PTI$VJ $c5&$7M&8N Hin--r&   c                    dt        dd      ddddddd	dd
dddd| |||||fz  }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.
        r   r   r   r   r   r   r   r   r   r   r   a  "/>
    </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>r   )shape_idr4   r   r   cxcyr   s          r'   new_freeform_spzCT_Shape.new_freeform_sp&  sQ    b !c*D$dD$S)PT tQ2r*W++X Hin--r&   c                   t        t        t        dt        dd       d|  d| d            }|j                  j
                  j                         }||_        ||_        ||_	        ||_
        t        j                  t        j                  t        j                  t        j                  t        j                   f}||v r#|j#                  t%        j&                                |S )zCReturn a new `p:sp` element tree configured as a placeholder shape.r   r   r   r   r   zq"/>
    <p:cNvSpPr>
      <a:spLocks noGrp="1"/>
    </p:cNvSpPr>
    <p:nvPr/>
  </p:nvSpPr>
  <p:spPr/>
</p:sp>)r   rr   r	   r   ru   nvPrget_or_add_phtypeidxorientszr   TITLECENTER_TITLESUBTITLEBODYOBJECTappendr   new)	r   r4   ph_typer   r   r   spph(placeholder_types_that_have_a_text_frames	            r'   new_placeholder_spzCT_Shape.new_placeholder_sp[  s    
 c*+ ,$$'5 7	
  YY^^))+	   ''##!!4
0 >>IIkoo'(	r&   c                Z    t         j                         }|| |||||fz  }t        |      }|S )zDReturn a new `p:sp` element tree configured as a base textbox shape.)rr   _textbox_sp_tmplr	   )	r   r4   r   r   r   r   tmplr   r   s	            r'   new_textbox_spzCT_Shape.new_textbox_sp  s7     ((*c4sE6::s^	r&   c                8    | j                   }|y|j                  S )zKValue of `prst` attribute of `a:prstGeom` element or |None| if not present.N)r   rj   r   s     r'   rj   zCT_Shape.prst  s      ==}}r&   c                .    | j                   j                  S )zReference to `a:prstGeom` child element.

        |None| if this shape doesn't have one, for example, if it's a placeholder shape.
        )rv   r   rI   s    r'   r   zCT_Shape.prstGeom  s     yy!!!r&   c                *    t        j                         S )N)r   new_p_txBodyrI   s    r'   _new_txBodyzCT_Shape._new_txBody  s    ''))r&   c                 F    dt        dd      ddddddd	dd
ddddS )Nr   r   r   r   r   r   r   zc"/>
    <p:cNvSpPr txBox="1"/>
    <p:nvPr/>
  </p:nvSpPr>
  <p:spPr>
    <a:xfrm>
      <a:off x="r   r   r   z"/>
    </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>r
   r%   r&   r'   r   zCT_Shape._textbox_sp_tmpl  s%    4 !c*D$dD$/P	
r&   N)rF   r   rG   r   rT   rB   )r   intr4   r5   rj   r5   r   r   r   r   r   r   r   r   rT   rr   )r   r   r4   r5   r   r   r   r   r   r   r   r   )
r   r   r4   r5   r   r   r   r5   rT   rr   )rT   rf   )r    r!   r"   r#   r$   r   ru   rv   r   rw   rb   r|   rp   r~   r   r   r   staticmethodr   r   r   r   rj   r   r   r   r%   r&   r'   rr   rr      s   &00 -j 9F9,X6D
6!*:-!PFP*) . . 	5 	5 1 1   +.+.+.#&+..1+.8;+.DG+.QT+.	+. +.Z 2. 2.h %%%&4%>A%	% %N     " "* 
 
r&   rr   c                  `    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
<   y)rt   z `p:nvSpPr` custom element class.zp:cNvPrr   cNvPrz	p:cNvSpPrr>   r   zp:nvPrr   r   N)	r    r!   r"   r#   r   r   r$   r   r   r%   r&   r'   rt   rt     sH    *&3'E#  .;.G*  	h 	
- r&   rt   N)0r#   
__future__r   typingr   r   r   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)   r3   r8   r>   rB   rU   rV   r^   rd   rf   rr   rt   r%   r&   r'   <module>r      s    B " 0 0 @    4  '   
 !6O 6/ 5? 5 $4 * *Z*_ **o *O *o *%/ %:x
 x
v( r&   