
    hi9                    2   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/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                  X    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/var/www/development/aibuddy-work/election-extract/venv/lib/python3.11/site-packages/pptx/oxml/shapes/autoshape.pyr   r   &   sT         &&!!#}55A5555!!#}55A555555r&   r   c                  V    e Zd ZU dZded<   dZ ede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   r0   r%   r&   r'   r)   r)   -   sd         ,,3333SH$-I% % %G      r&   r)   c                  X    e Zd ZU dZ ede          Zded<    ede          Zded<   dS )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   sZ          
 "!&)44D4444!!&)44D444444r&   r3   c                  >    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'   r8   r8   B   s=         ))''''	F		BBBr&   r8   c                  L    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   spLocksr   r   r?   r$   r%   r&   r'   r>   r>   L   sV         ++i$$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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                *    |                                  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&   r   r   r   CT_Path2DLineToc                t    |                                  }|                                }||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   )rL   r   r   lnTopts        r'   add_lnTozCT_Path2D.add_lnTom   s4    
 ~~\\^^
bdr&   c                t    |                                  }|                                }||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   rP   r   r   )rL   r   r   moveTorR   s        r'   
add_moveTozCT_Path2D.add_moveTow   s8    
 !!##^^
bdr&   N)rH   rI   )r   r   r   r   rH   rN   )r   r   r   r   )r    r!   r"   r#   r$   r   closerQ   rU   r   r   rF   rG   rM   rS   rV   r%   r&   r'   rB   rB   U   s        ((,,,,,,,,....JyR000E:h2...DZ
r222F((" A     )(" A    ! ! ! !        r&   rB   c                      e Zd ZdZdS )rI   z`a:close` custom element class.N)r    r!   r"   r#   r%   r&   r'   rI   rI      s        ))))r&   rI   c                  8    e Zd ZU dZded<    edd          ZdS )rN   z`a:lnTo` custom element class.Callable[[], CT_AdjPoint2D]rP   a:ptr%   r.   Nr    r!   r"   r#   r$   r   rR   r%   r&   r'   rN   rN      s6         ((((((	6b	)	)	)BBBr&   rN   c                  @    e Zd ZU dZded<    edd          Zdd
ZdS )CT_Path2DListz!`a:pathLst` custom element class.zCallable[[], CT_Path2D]	_add_pathza:pathr%   r.   rF   r   rG   c                L    |                                  }||c|_        |_        |S )z.Return a newly created `a:path` child element.)r_   rF   rG   )rL   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^      sP         ++&&&&:h2...D     r&   r^   c                  8    e Zd ZU dZded<    edd          ZdS )CT_Path2DMoveToz `a:moveTo` custom element class.rZ   rP   r[   r%   r.   Nr\   r%   r&   r'   rd   rd      s6         **((((	6b	)	)	)BBBr&   rd   c                      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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   rH   r:   c                &    | j         }|g S |j        S )zLSequence of `a:gd` element children of `a:avLst`. Empty if none are present.)ri   r;   )rL   ri   s     r'   r;   zCT_PresetGeometry2D.gd_lst   s     
=I|r&   guideslist[tuple[str, int]]c                    |                                   |                                 }|D ]*\  }}|                                }||_        d|z  |_        +dS )zOReplace any `a:gd` element children of `a:avLst` with ones forme from `guides`.zval %dN)rh   rg   r9   r4   r6   )rL   rl   ri   r4   valr<   s         r'   rewrite_guidesz"CT_PresetGeometry2D.rewrite_guides   sa    !! 	% 	%ID#BBGnBGG	% 	%r&   N)rH   r:   )rl   rm   )r    r!   r"   r#   r$   r   ri   r   r   rj   propertyr;   rp   r%   r&   r'   rf   rf      s         ,,....%%%%%.Yy%9%9E9999 1 1#! !D        X% % % % % %r&   rf   c                     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<   d5dZ
d Zed             Zed             Zed             Zed             Zed6d#            Zed7d)            Zed8d-            Zed.             Zed/             Zed9d1            Zd2 Zed3             Zd4S ):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txBodyrF   r   rG   rH   rB   c                    | j         j        }|t          d          |                                }|                    ||          S )Nzshape must be freeform)rF   rG   )rw   custGeom
ValueErrorr*   rb   )rL   rF   rG   rz   r0   s        r'   rb   zCT_Shape.add_path   sK    9%5666--//!q)))r&   c                4    | j                                         S )zAReturn the `a:ln` grandchild element, newly added if not present.)rw   get_or_add_lnrK   s    r'   r}   zCT_Shape.get_or_add_ln   s    y&&(((r&   c                    | 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)rw   rz   rK   s    r'   has_custom_geometryzCT_Shape.has_custom_geometry   s     y!--r&   c                >    | j         }|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)prstGeomrv   cNvSpPrr?   rL   r   s     r'   is_autoshapezCT_Shape.is_autoshape   s)     =5{"(44r&   c                (    | 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)rv   r   r?   rK   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.)rw   lnrK   s    r'   r   zCT_Shape.ln   s     y|r&   id_intr4   r5   rj   lefttopwidthheightc                    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   rs   r	   )r   r4   rj   r   r   r   r   xmls           r'   new_autoshape_spzCT_Shape.new_autoshape_sp   s     T !c****DDD$$$dddDDD$$$PTPTPTI$VJ $c5&$7M&8N Hinn---r&   shape_idr   r   cxcyc                    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   )r   r4   r   r   r   r   r   s          r'   new_freeform_spzCT_Shape.new_freeform_sp&  sy     b !c****DDD$$$dddDDD$$$S)PT tQ2r*W++X Hinn---r&   ph_typer   orientc                   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%          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   rs   r	   r   rv   nvPrget_or_add_phtypeidxr   szr   TITLECENTER_TITLESUBTITLEBODYOBJECTappendr   new)	r   r4   r   r   r   r   spph(placeholder_types_that_have_a_text_frames	            r'   new_placeholder_spzCT_Shape.new_placeholder_sp[  s    
 	c** 	 	$'	 	15	 	 	 
 
  Y^))++	  '#!4
0 >>>IIko''(((	r&   c                l    t                                           }|| |||||fz  }t          |          }|S )zDReturn a new `p:sp` element tree configured as a base textbox shape.)rs   _textbox_sp_tmplr	   )	r   r4   r   r   r   r   tmplr   r   s	            r'   new_textbox_spzCT_Shape.new_textbox_sp  s<     ((**c4sE6::s^^	r&   c                &    | j         }|dS |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     =4}r&   rf   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.
        )rw   r   rK   s    r'   r   zCT_Shape.prstGeom  s     y!!r&   c                (    t          j                    S )N)r   new_p_txBodyrK   s    r'   _new_txBodyzCT_Shape._new_txBody  s    ')))r&   c                 N    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  sH     4 !c****DDD$$$dddDDD$$$/P	
r&   N)rF   r   rG   r   rH   rB   )r   r   r4   r5   rj   r5   r   r   r   r   r   r   r   r   rH   rs   )r   r   r4   r5   r   r   r   r   r   r   r   r   )
r   r   r4   r5   r   r   r   r5   rH   rs   )rH   rf   )r    r!   r"   r#   r$   r   rv   rw   r   rx   rb   r}   rq   r   r   r   r   staticmethodr   r   r   r   rj   r   r   r   r%   r&   r'   rs   rs      s        &&0000 -j 9 9F9999,}X66D6666!*:-!P!P!PFPPPP* * * *) ) ) . . X. 	5 	5 X	5 1 1 X1   X +. +. +. \+.Z 2. 2. 2. \2.h % % % \%N   \   X " " " X"* * * 
 
 \
 
 
r&   rs   c                  t    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 )ru   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'   ru   ru     s         **&3m' 'E     .;]. .G     	h 	      r&   ru   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   rI   rN   r^   rd   rf   rs   ru   r%   r&   r'   <module>r      s   B A " " " " " " 0 0 0 0 0 0 0 0 0 0 @ @ @ @ @ @ @ @                   4 4 4 4 4 4            ' & & & & &                 !         
 !     6 6 6 6 6O 6 6 6    /   5 5 5 5 5? 5 5 5           $4   * * * * * * * *Z* * * * *_ * * ** * * * *o * * *    O   * * * * *o * * *% % % % %/ % % %:x
 x
 x
 x
 x
 x
 x
 x
v    (     r&   