
    ,h#                         d Z ddlmZmZmZmZ ddlm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 dd
lmZ 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y)z@lxml custom element classes for shape-tree-related XML elements.    )absolute_importdivisionprint_functionunicode_literals)MSO_CONNECTOR_TYPE)	parse_xml)nsdeclsqn)CT_Shape)CT_Connector)CT_GraphicalObjectFrame)
CT_Picture)BaseShapeElement)BaseOxmlElementOneAndOnlyOne	ZeroOrOne)Emuc                   @   e Zd ZdZ ed      Z ed      Z ed       ed       ed       ed       ed       ed	      fZd
 Z	d Z
d Zd Zd Zd Zd Zd Zed        Zed        Zd Zd Zd Zed        Zed        Zd Zed        Zed        Zed        Zy)CT_GroupShapezr
    Used for the shape tree (``<p:spTree>``) element as well as the group
    shape (``<p:grpSp>``) element.
    zp:nvGrpSpPrz	p:grpSpPrzp:spp:grpSpzp:graphicFramezp:cxnSpzp:piczp:contentPartc           	      `    t        j                  |||||||      }| j                  |d       |S )zw
        Append a new ``<p:sp>`` shape to the group/shapetree having the
        properties specified in call.
        p:extLst)r   new_autoshape_spinsert_element_before)	selfid_nameprstxycxcysps	            ]/var/www/html/Resume-Scraper/venv/lib/python3.12/site-packages/pptx/oxml/shapes/groupshape.pyadd_autoshapezCT_GroupShape.add_autoshape%   s5    
 &&sD$1b"E""2z2	    c
                     t        j                  |      }
t        j                  |||
||||||		      }| j	                  |d       |S )zz
        Append a new ``<p:cxnSp>`` shape to the group/shapetree having the
        properties specified in call.
        r   )r   to_xmlr   	new_cxnSpr   )r   r   r   type_memberr   r    r!   r"   flipHflipVr   cxnSps               r$   	add_cxnSpzCT_GroupShape.add_cxnSp.   sI    
 "((5&&sD$1b"eUS""5*5r&   c                     | j                   }d|dz
  fz  }t        j                  ||||||      }| j                  |d       |S )z>Append a new freeform `p:sp` with specified position and size.zFreeform %d   r   )_next_shape_idr   new_freeform_spr   )r   r   r    r!   r"   shape_idr   r#   s           r$   add_freeform_spzCT_GroupShape.add_freeform_sp8   sL    &&1.%%haBC""2z2	r&   c                     | j                   }d|dz
  fz  }t        j                  ||      }| j                  |d       |S )zReturn `p:grpSp` element newly appended to this shape tree.

        The element contains no sub-shapes, is positioned at (0, 0), and has
        width and height of zero.
        zGroup %dr0   r   )r1   r   	new_grpSpr   )r   r3   r   grpSps       r$   	add_grpSpzCT_GroupShape.add_grpSp@   sF     &&X\O+''$7""5*5r&   c	           
      b    t        j                  ||||||||      }	| j                  |	d       |	S )zs
        Append a ``<p:pic>`` shape to the group/shapetree having properties
        as specified in call.
        r   )r   new_picr   )
r   r   r   descrIdr   r    r!   r"   pics
             r$   add_piczCT_GroupShape.add_picL   s7    
   dD#q!RD""3
3
r&   c                 ^    t        j                  ||||||      }| j                  |d       |S )zz
        Append a newly-created placeholder ``<p:sp>`` shape having the
        specified placeholder properties.
        r   )r   new_placeholder_spr   )r   r   r   ph_typeorientszidxr#   s           r$   add_placeholderzCT_GroupShape.add_placeholderU   s3    
 ((dGVRM""2z2	r&   c	           
      b    t        j                  ||||||||      }	| j                  |	d       |	S )zf
        Append a ``<p:graphicFrame>`` shape containing a table as specified
        in call.
        r   )r   new_table_graphicFramer   )
r   r   r   rowscolsr   r    r!   r"   graphicFrames
             r$   	add_tablezCT_GroupShape.add_table^   s=    
 /EEtT1aR
 	""<<r&   c                 ^    t        j                  ||||||      }| j                  |d       |S )zq
        Append a newly-created textbox ``<p:sp>`` shape having the specified
        position and size.
        r   )r   new_textbox_spr   )r   r   r   r   r    r!   r"   r#   s           r$   add_textboxzCT_GroupShape.add_textboxi   s3    
 $$S$1b"=""2z2	r&   c                 R    | j                   j                         j                         S )z.Descendent `p:grpSpPr/a:xfrm/a:chExt` element.)grpSpPrget_or_add_xfrmget_or_add_chExtr   s    r$   chExtzCT_GroupShape.chExtr         ||++->>@@r&   c                 R    | j                   j                         j                         S )z.Descendent `p:grpSpPr/a:xfrm/a:chOff` element.)rP   rQ   get_or_add_chOffrS   s    r$   chOffzCT_GroupShape.chOffw   rU   r&   c                 6    | j                   j                         S )za
        Return the ``<a:xfrm>`` grandchild element, newly-added if not
        present.
        )rP   rQ   rS   s    r$   rQ   zCT_GroupShape.get_or_add_xfrm|   s    
 ||++--r&   c              #   X   K   | j                         D ]  }|j                  s|  yw)zR
        Generate each placeholder shape child element in document order.
        N)iter_shape_elms
has_ph_elm)r   es     r$   iter_ph_elmszCT_GroupShape.iter_ph_elms   s,      %%' 	A||	s    **c              #   p   K   | j                         D ]  }|j                  | j                  v s| ! yw)z
        Generate each child of this ``<p:spTree>`` element that corresponds
        to a shape, in the sequence they appear in the XML.
        N)iterchildrentag_shape_tags)r   elms     r$   r[   zCT_GroupShape.iter_shape_elms   s7     
 $$& 	Cww$***		s   ,66c                     | j                  d      }|D cg c]  }|j                         st        |        }}|rt        |      S dS c c}w )ai  Maximum int value assigned as @id in this slide.

        This is generally a shape-id, but ids can be assigned to other
        objects so we just check all @id values anywhere in the document
        (XML id-values have document scope).

        In practice, its minimum value is 1 because the spTree element itself
        is always assigned id="1".
        //@idr   )xpathisdigitintmax)r   
id_str_lstid_strused_idss       r$   max_shape_idzCT_GroupShape.max_shape_id   sI     ZZ(
.8MFFNN<LCKMM (s8}/a/ Ns
   A
A
c                 F    dt        ddd      z  ||fz  }t        |      }|S )z=Return new "loose" `p:grpSp` element having *id_* and *name*.a)  <p:grpSp %s>
  <p:nvGrpSpPr>
    <p:cNvPr id="%%d" name="%%s"/>
    <p:cNvGrpSpPr/>
    <p:nvPr/>
  </p:nvGrpSpPr>
  <p:grpSpPr>
    <a:xfrm>
      <a:off x="0" y="0"/>
      <a:ext cx="0" cy="0"/>
      <a:chOff x="0" y="0"/>
      <a:chExt cx="0" cy="0"/>
    </a:xfrm>
  </p:grpSpPr>
</p:grpSp>apr)r	   r   )clsr   r   xmlr7   s        r$   r6   zCT_GroupShape.new_grpSp   s:     #3S12 $K!" #r&   c                 T   | j                   t        d      k(  sy| j                  \  }}}}|x| j                  _        | _        |x| j                  _        | _        |x| j                  _        | _        |x| j                  _        | _        | j                         j                          y)aN  Adjust x, y, cx, and cy to incorporate all contained shapes.

        This would typically be called when a contained shape is added,
        removed, or its position or size updated.

        This method is recursive "upwards" since a change in a group shape
        can change the position and size of its containing group.
        r   N)ra   r
   _child_extentsrX   r   r    rT   r!   r"   	getparentrecalculate_extents)r   r   r    r!   r"   s        r$   rw   z!CT_GroupShape.recalculate_extents   s     xx2i=(**1b" !!

tv !!

tv"$$

"$$

,,.r&   c                 .    | j                   j                  S )zL
        The ``<a:xfrm>`` grandchild element or |None| if not found
        )rP   xfrmrS   s    r$   ry   zCT_GroupShape.xfrm   s    
 ||   r&   c                 (   t        | j                               }|s*t        d      t        d      t        d      t        d      fS t        |D cg c]  }|j                   c}      }t        |D cg c]  }|j
                   c}      }t        |D cg c]  }|j                  |j                  z    c}      }t        |D cg c]  }|j
                  |j                  z    c}      }|}|}||z
  }	||z
  }
|||	|
fS c c}w c c}w c c}w c c}w )z(x, y, cx, cy) tuple representing net position and size.

        The values are formed as a composite of the contained child shapes.
        r   )	listr[   r   minr   r    ri   r!   r"   )r   child_shape_elmsxSpmin_xmin_ymax_xmax_yr   r    r!   r"   s              r$   ru   zCT_GroupShape._child_extents   s       4 4 67q63q63q63q611&67sSUU78&67sSUU781AB#ceecffnBC1AB#ceecffnBCU]U]!R| 87BBs   D 2D D
 Dc                     | j                  d      }|D cg c]  }|j                         st        |        }}t        dt	        |      dz         D ]
  }||vs|c S  yc c}w )aZ  Return unique shape id suitable for use with a new shape element.

        The returned id is the next available positive integer drawing object
        id in shape tree, starting from 1 and making use of any gaps in
        numbering. In practice, the minimum id is 2 because the spTree
        element itself is always assigned id="1".
        re   r0      N)rf   rg   rh   rangelen)r   rj   rk   rl   ns        r$   r1   zCT_GroupShape._next_shape_id   sd     ZZ(
.8MFFNN<LCKMMq#h-!+, 	A 	 Ns
   A!A!N)__name__
__module____qualname____doc__r   	nvGrpSpPrrP   r
   rb   r%   r.   r4   r8   r>   rE   rK   rN   propertyrT   rX   rQ   r^   r[   rm   classmethodr6   rw   ry   ru   r1    r&   r$   r   r      s   
 m,IK(G 	6

9

9
7
?K
	 A A A A. 0 0  ,/( ! !  ,  r&   r   c                        e Zd ZdZ ed      Zy)CT_GroupShapeNonVisualz$
    ``<p:nvGrpSpPr>`` element.
    zp:cNvPrN)r   r   r   r   r   cNvPrr   r&   r$   r   r      s     )$Er&   r   c                   J    e Zd ZdZdZ ededd       Z ededd       Z[y)	CT_GroupShapePropertieszp:grpSpPr element )a:xfrmza:noFillza:solidFillz
a:gradFillz
a:blipFillz
a:pattFillz	a:grpFilla:effectLstza:effectDagz	a:scene3dza:extLstr   r0   N)
successorsr      )r   r   r   r   _tag_seqr   ry   	effectLstr   r&   r$   r   r     s5    H X(12,7D-HQRLAIr&   r   N) r   
__future__r   r   r   r   pptx.enum.shapesr   	pptx.oxmlr   pptx.oxml.nsr	   r
   pptx.oxml.shapes.autoshaper   pptx.oxml.shapes.connectorr   pptx.oxml.shapes.graphfrmr   pptx.oxml.shapes.picturer   pptx.oxml.shapes.sharedr   pptx.oxml.xmlchemyr   r   r   	pptx.utilr   r   r   r   r   r&   r$   <module>r      s[    G R R /  $ / 3 = / 4 H H f$ fR%- %o r&   