
    li4                    P   d Z ddlmZ ddlZddlZddlmZmZmZm	Z	m
Z
mZ ddl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 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. ddl/m0Z0m1Z1m2Z2m3Z3m4Z4m5Z5m6Z6m7Z7m8Z8 ddl9m:Z: ddl;m<Z<m=Z= erLddl>m?Z? ddl@mAZA ddlBmCZC ddlmDZDmEZE ddlFmGZG ddlHmIZI ddlJmKZK ddlLmMZM ddlNmOZO dd lPmQZQmRZR dd!lSmTZT dd"l;mUZU  G d# d$e:      ZV G d% d&eV      ZW G d' d(eW      ZX G d) d*eW      ZY G d+ d,eV      ZZ G d- d.eV      Z[ G d/ d0eV      Z\ G d1 d2eV      Z] G d3 d4e]      Z^ G d5 d6e]      Z_ G d7 d8e_      Z` G d9 d:e:      ZadEd;ZbdEd<ZcdEd=ZddEd>ZedFd?ZfdEd@Zg G dA dBeh      Zi G dC dDeh      Zjy)Gz:The shape tree, the structure that holds a slide's shapes.    )annotationsN)IOTYPE_CHECKINGCallableIterableIteratorcast)PP_PLACEHOLDERPROG_ID)SPEAKER_IMAGE_BYTESVideo)CONTENT_TYPE)qn)CT_Shape)CT_GraphicalObjectFrame)
CT_Picture)ST_Direction)AutoShapeTypeShape)	BaseShape)	Connector)FreeformBuilder)GraphicFrame)
GroupShape)MoviePicture)	ChartPlaceholderLayoutPlaceholderMasterPlaceholderNotesSlidePlaceholderPicturePlaceholderPlaceholderGraphicFramePlaceholderPictureSlidePlaceholderTablePlaceholder)ParentedElementProxy)Emulazyproperty)Chart)	ChartData)XL_CHART_TYPE)MSO_CONNECTOR_TYPE	MSO_SHAPE)ShapeElement)CT_Connector)CT_GroupShape)	ImagePart)	SlidePart)SlideSlideLayout)ProvidesPart)Lengthc                       e Zd ZdZd fdZddZddZddZddZddZ	e
dd       Zej                  dd	       Zedd
       ZddZddZe
dd       ZddZ xZS )_BaseShapeszBase class for a shape collection appearing in a slide-type object.

    Subclasses include Slide, SlideLayout, and SlideMaster. Provides common methods.
    c                J    t         t        |   ||       || _        d | _        y N)superr8   __init___spTree_cached_max_shape_id)selfspTreeparent	__class__s      S/var/www/html/eduruby.in/venv/lib/python3.12/site-packages/pptx/shapes/shapetree.pyr<   z_BaseShapes.__init__S   s#    k4)&&9$(!    c                    t        | j                               }	 ||   }| j                  |      S # t        $ r t        d      w xY w)z4Return shape at `idx` in sequence, e.g. `shapes[2]`.zshape index out of range)list_iter_member_elms
IndexError_shape_factory)r?   idx
shape_elms	shape_elms       rC   __getitem__z_BaseShapes.__getitem__X   sS    $0023
	9"3I ""9--  	9788	9s	   1 Ac              #  \   K   | j                         D ]  }| j                  |        yw)zBGenerate a reference to each shape in the collection, in sequence.N)rG   rI   r?   rL   s     rC   __iter__z_BaseShapes.__iter__a   s/     //1 	1I%%i00	1s   *,c                J    t        | j                               }t        |      S )zReturn count of shapes in this shape tree.

        A group shape contributes 1 to the total, without regard to the number of shapes contained
        in the group.
        )rF   rG   len)r?   rK   s     rC   __len__z_BaseShapes.__len__f   s!     $0023
:rD   c                    |j                   }|j                  |j                  |j                  |j                  f\  }}}}| j
                  }| j                  |||      }| j                  j                  ||||||       y)z3Add a new placeholder shape based on `placeholder`.N)	elementph_type	ph_orientph_szph_idx_next_shape_id_next_ph_namer=   add_placeholder)	r?   placeholdersprV   orientszrJ   id_names	            rC   clone_placeholderz_BaseShapes.clone_placeholdero   so      $&JJbhh		#R S!!!!'37$$S$SIrD   c                   t         j                  dt         j                  dt         j                  dt         j                  dt         j
                  dt         j                  dt         j                  dt         j                  dt         j                  d	t         j                  d
t         j                  dt         j                  dt         j                  dt         j                  dt         j                  di|   S )a  Return the base name for a placeholder of `ph_type` in this shape collection.

        There is some variance between slide types, for example a notes slide uses a different
        name for the body placeholder, so this method can be overriden by subclasses.
        zClipArt PlaceholderzText PlaceholderTitlezChart PlaceholderDate PlaceholderFooter PlaceholderHeader PlaceholderzMedia PlaceholderzContent PlaceholderzSmartArt PlaceholderzPicture PlaceholderSlide Number PlaceholderSubtitlezTable Placeholder)r
   BITMAPBODYCENTER_TITLECHARTDATEFOOTERHEADER
MEDIA_CLIPOBJECT	ORG_CHARTPICTURESLIDE_NUMBERSUBTITLETABLETITLEr?   rV   s     rC   ph_basenamez_BaseShapes.ph_basenamew   s     !!#8!3''  "5!3!!#7!!#7%%':!!#8$$&<""$9'')C##Z  "5  '
  ! 	rD   c                    | j                   duS )a  True if "turbo-add" mode is enabled. Read/Write.

        EXPERIMENTAL: This feature can radically improve performance when adding large numbers
        (hundreds of shapes) to a slide. It works by caching the last shape ID used and
        incrementing that value to assign the next shape id. This avoids repeatedly searching all
        shape ids in the slide each time a new ID is required.

        Performance is not noticeably improved for a slide with a relatively small number of
        shapes, but because the search time rises with the square of the shape count, this option
        can be useful for optimizing generation of a slide composed of many shapes.

        Shape-id collisions can occur (causing a repair error on load) if more than one |Slide|
        object is used to interact with the same slide in the presentation. Note that the |Slides|
        collection creates a new |Slide| object each time a slide is accessed (e.g. `slide =
        prs.slides[0]`, so you must be careful to limit use to a single |Slide| object.
        N)r>   r?   s    rC   turbo_add_enabledz_BaseShapes.turbo_add_enabled   s    $ ((44rD   c                d    t        |      }|r| j                  j                  | _        y d | _        y r:   )boolr=   max_shape_idr>   )r?   valueenables      rC   r~   z_BaseShapes.turbo_add_enabled   s&    eAGDLL$=$=!T!rD   c                     y)zSReturn true if `shape_elm` represents a member of this collection, False otherwise.T rL   s    rC   _is_member_elmz_BaseShapes._is_member_elm   s     rD   c              #  v   K   | j                   j                         D ]  }| j                  |      s|  yw)zGenerate each child of the `p:spTree` element that corresponds to a shape.

        Items appear in XML document order.
        N)r=   iter_shape_elmsr   rO   s     rC   rG   z_BaseShapes._iter_member_elms   s7     
 557 	 I""9-	 s   /99c                    | j                  |      }|t        j                  k(  rd|z  }|dz
  }| j                  j	                  d      }	 d||fz  }||vr	 |S |dz  })a  Next unique placeholder name for placeholder shape of type `ph_type`.

        Usually will be standard placeholder root name suffixed with id-1, e.g.
        _next_ph_name(ST_PlaceholderType.TBL, 4, 'horz') ==> 'Table Placeholder 3'. The number is
        incremented as necessary to make the name unique within the collection. If `orient` is
        `'vert'`, the placeholder name is prefixed with `'Vertical '`.
        zVertical %s   z//p:cNvPr/@name%s %d)r{   r   VERTr=   xpath)r?   rV   idr_   basenamenumpartnamesrb   s           rC   r[   z_BaseShapes._next_ph_name   s     ##G, \&&&$x/H q&""#45h00D5   qLG	 rD   c                    | j                   !| xj                   dz  c_         | j                   S | j                  j                  dz   S )zReturn a unique shape id suitable for use with a new shape.

        The returned id is 1 greater than the maximum shape id used so far. In practice, the
        minimum id is 2 because the spTree element is always assigned id="1".
        r   )r>   r=   r   r}   s    rC   rZ   z_BaseShapes._next_shape_id   sB     $$0%%*%,,,||((1,,rD   c                    t        ||       S HReturn an instance of the appropriate shape proxy class for `shape_elm`.)BaseShapeFactoryrO   s     rC   rI   z_BaseShapes._shape_factory   s    	400rD   )r@   r0   rA   r5   )rJ   intreturnr   )r   zIterator[BaseShape]r   r   )r]   r   r   NonerV   r
   r   str)r   r   )r   r   rL   r.   r   r   )r   zIterator[ShapeElement])rV   r
   r   r   r_   r   r   r   rL   r.   r   r   )__name__
__module____qualname____doc__r<   rM   rP   rS   rc   r{   propertyr~   setterstaticmethodr   rG   r[   rZ   rI   __classcell__rB   s   @rC   r8   r8   M   s    
)
.1
J0 5 5& R R   2 - -1rD   r8   c                      e Zd ZU dZded<   ded<   d fdZ	 	 	 	 	 	 	 	 	 	 	 	 	 	 ddZ	 	 	 	 	 	 	 	 	 	 	 	 ddZddd	Z	 	 	 	 	 d	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dd
Z		 	 d	 	 	 	 	 	 	 	 	 	 	 ddZ
	 	 	 	 	 	 	 	 	 	 	 	 ddZd dZ	 d!	 	 	 	 	 	 	 d"dZd#dZ	 	 	 	 	 	 	 	 	 	 	 	 d$dZ	 	 	 	 	 	 	 	 	 	 	 	 d%dZ	 	 	 	 	 	 	 	 	 	 	 	 	 	 d&dZ	 	 	 	 	 	 	 	 	 	 	 	 d'dZd(dZd)dZ xZS )*_BaseGroupShapesz/Base class for shape-trees that can add shapes.r2   partr0   _elementc                <    t         t        |   ||       || _        y r:   )r;   r   r<   _grpSp)r?   grpSprA   rB   s      rC   r<   z_BaseGroupShapes.__init__   s    .uf=rD   c                    | j                   j                  ||      }| j                  |||||      }| j                          t	        d| j                  |            S )aB  Add a new chart of `chart_type` to the slide.

        The chart is positioned at (`x`, `y`), has size (`cx`, `cy`), and depicts `chart_data`.
        `chart_type` is one of the :ref:`XlChartType` enumeration values. `chart_data` is a
        |ChartData| object populated with the categories and series values for the chart.

        Note that a |GraphicFrame| shape object is returned, not the |Chart| object contained in
        that graphic frame shape. The chart object may be accessed using the :attr:`chart`
        property of the returned |GraphicFrame| object.
        r)   )r   add_chart_part_add_chart_graphicFrame_recalculate_extentsr	   rI   )	r?   
chart_typexycxcy
chart_datarIdgraphicFrames	            rC   	add_chartz_BaseGroupShapes.add_chart   sV    & ii&&z:>33CAr2F!!#GT00>??rD   c                    | j                  |||||      }| j                          t        t        | j	                  |            S )a@  Add a newly created connector shape to the end of this shape tree.

        `connector_type` is a member of the :ref:`MsoConnectorType` enumeration and the end-point
        values are specified as EMU values. The returned connector is of type `connector_type` and
        has begin and end points as specified.
        )
_add_cxnSpr   r	   r   rI   )r?   connector_typebegin_xbegin_yend_xend_ycxnSps          rC   add_connectorz_BaseGroupShapes.add_connector  s>     %O!!#It2259::rD   c                    t        |      }| j                  j                         }|D ]  }|j                  |j                  d         |r|j	                          t        t        | j                  |            S )a  Return a |GroupShape| object newly appended to this shape tree.

        The group shape is empty and must be populated with shapes using methods on its shape
        tree, available on its `.shapes` property. The position and extents of the group shape are
        determined by the shapes it contains; its position and extents are recalculated each time
        a shape is added to it.
        zp:extLst)tupler   	add_grpSpinsert_element_beforerecalculate_extentsr	   r   rI   )r?   shapesr   shapes       rC   add_group_shapez _BaseGroupShapes.add_group_shape  sn     v'') 	E''
	 %%'J 3 3E :;;rD   c
                    t         j                  | | j                  |||||||||	      }
| j                  j	                  |
       | j                          t        t        | j                  |
            S )aq  Return newly-created GraphicFrame shape embedding `object_file`.

        The returned graphic-frame shape contains `object_file` as an embedded OLE object. It is
        displayed as an icon at `left`, `top` with size `width`, `height`. `width` and `height`
        may be omitted when `prog_id` is a member of `PROG_ID`, in which case the default icon
        size is used. This is advised for best appearance where applicable because it avoids an
        icon with a "stretched" appearance.

        `object_file` may either be a str path to a file or file-like object (such as
        `io.BytesIO`) containing the bytes of the object to be embedded (such as an Excel file).

        `prog_id` can be either a member of `pptx.enum.shapes.PROG_ID` or a str value like
        `"Adobe.Exchange.7"` determined by inspecting the XML generated by PowerPoint for an
        object of the desired type.

        `icon_file` may either be a str path to an image file or a file-like object containing the
        image. The image provided will be displayed in lieu of the OLE object; double-clicking on
        the image opens the object (subject to operating-system limitations). The image file can
        be any supported image file. Those produced by PowerPoint itself are generally EMF and can
        be harvested from a PPTX package that embeds such an object. PNG and JPG also work fine.

        `icon_width` and `icon_height` are `Length` values (e.g. Emu() or Inches()) that describe
        the size of the icon image within the shape. These should be omitted unless a custom
        `icon_file` is provided. The dimensions must be discovered by inspecting the XML.
        Automatic resizing of the OLE-object shape can occur when the icon is double-clicked if
        these values are not as set by PowerPoint. This behavior may only manifest in the Windows
        version of PowerPoint.
        )	_OleObjectElementCreatorr   rZ   r=   appendr   r	   r   rI   )r?   object_fileprog_idlefttopwidthheight	icon_file
icon_widthicon_heightr   s              rC   add_ole_objectz_BaseGroupShapes.add_ole_object(  st    P 0<<
 	L)!!#L$"5"5l"CDDrD   c                    | j                   j                  |      \  }}| j                  ||||||      }| j                          t	        t
        | j                  |            S )a3  Add picture shape displaying image in `image_file`.

        `image_file` can be either a path to a file (a string) or a file-like object. The picture
        is positioned with its top-left corner at (`top`, `left`). If `width` and `height` are
        both |None|, the native size of the image is used. If only one of `width` or `height` is
        used, the unspecified dimension is calculated to preserve the aspect ratio of the image.
        If both are specified, the picture is stretched to fit, without regard to its native
        aspect ratio.
        )r   get_or_add_image_part_add_pic_from_image_partr   r	   r   rI   )	r?   
image_filer   r   r   r   
image_partr   pics	            rC   add_picturez_BaseGroupShapes.add_picturea  sZ    " ))99*E
C++JT3vV!!#GT00566rD   c                    t        |      }| j                  |||||      }| j                          t        t        | j                  |            S )a  Return new |Shape| object appended to this shape tree.

        `autoshape_type_id` is a member of :ref:`MsoAutoShapeType` e.g. `MSO_SHAPE.RECTANGLE`
        specifying the type of shape to be added. The remaining arguments specify the new shape's
        position and size.
        )r   _add_spr   r	   r   rI   )r?   autoshape_type_idr   r   r   r   autoshape_typer^   s           rC   	add_shapez_BaseGroupShapes.add_shapew  sI     ''89\\.$UFC!!#E4..r233rD   c                    | j                  ||||      }| j                          t        t        | j	                  |            S )zReturn newly added text box shape appended to this shape tree.

        The text box is of the specified size, located at the specified position on the slide.
        )_add_textbox_spr   r	   r   rI   )r?   r   r   r   r   r^   s         rC   add_textboxz_BaseGroupShapes.add_textbox  s>    
 !!$UF;!!#E4..r233rD   c                f    t        |t              r|n||f\  }}t        j                  | ||||      S )a  Return |FreeformBuilder| object to specify a freeform shape.

        The optional `start_x` and `start_y` arguments specify the starting pen position in local
        coordinates. They will be rounded to the nearest integer before use and each default to
        zero.

        The optional `scale` argument specifies the size of local coordinates proportional to
        slide coordinates (EMU). If the vertical scale is different than the horizontal scale
        (local coordinate units are "rectangular"), a pair of numeric values can be provided as
        the `scale` argument, e.g. `scale=(1.0, 2.0)`. In this case the first number is
        interpreted as the horizontal (X) scale and the second as the vertical (Y) scale.

        A convenient method for calculating scale is to divide a |Length| object by an equivalent
        count of local coordinate units, e.g. `scale = Inches(1)/1000` for 1000 local units per
        inch.
        )
isinstancer   r   new)r?   start_xstart_yscalex_scaley_scales         rC   build_freeformz_BaseGroupShapes.build_freeform  s6    & %/ue$<55%.""4'7GLLrD   c                ~    t        | j                  j                               }|j                  |j                        S )zxReturn the index of `shape` in this sequence.

        Raises |ValueError| if `shape` is not in the collection.
        )rF   r   r   indexrU   )r?   r   rK   s      rC   r   z_BaseGroupShapes.index  s0    
 $--779:
..rD   c           	         | j                   }d|dz
  z  }t        j                  |||||||      }| j                  j	                  |       |S )zReturn new `p:graphicFrame` element appended to this shape tree.

        The `p:graphicFrame` element has the specified position and size and refers to the chart
        part identified by `rId`.
        zChart %dr   )rZ   r   new_chart_graphicFramer=   r   )	r?   r   r   r   r   r   shape_idrb   r   s	            rC   r   z(_BaseGroupShapes._add_chart_graphicFrame  sV     &&X\*.EEdCAr2
 	L)rD   c                    | j                   }d|dz
  z  }||kD  ||kD  }	}t        ||      t        ||      }}
t        ||z
        t        ||z
        }}| j                  j	                  ||||
|||||		      S )zReturn a newly-added `p:cxnSp` element as specified.

        The `p:cxnSp` element is for a connector of `connector_type` beginning at (`begin_x`,
        `begin_y`) and extending to (`end_x`, `end_y`).
        zConnector %dr   )rZ   minabsr   	add_cxnSp)r?   r   r   r   r   r   ra   rb   flipHflipVr   r   r   r   s                 rC   r   z_BaseGroupShapes._add_cxnSp  s     !!q)%u7E"C$71UW_%s57?';B}}&&sD.!QBPUW\]]rD   c           
         | j                   }|j                  ||      \  }}	d|dz
  z  }
|j                  }| j                  j	                  ||
||||||	      }|S )a1  Return a newly appended `p:pic` element as specified.

        The `p:pic` element displays the image in `image_part` with size and position specified by
        `x`, `y`, `cx`, and `cy`. The element is appended to the shape tree, causing it to be
        displayed first in z-order on the slide.
        z
Picture %dr   )rZ   r   descr   add_pic)r?   r   r   r   r   r   r   ra   	scaled_cx	scaled_cyrb   r   r   s                rC   r   z)_BaseGroupShapes._add_pic_from_image_part  sd     !!)//B7	9sQw'kk!!#tT31iS
rD   c           	         | j                   }d|j                  |dz
  fz  }| j                  j                  |||j                  ||||      }|S )zReturn newly-added `p:sp` element as specified.

        `p:sp` element is of `autoshape_type` at position (`x`, `y`) and of size (`cx`, `cy`).
        r   r   )rZ   r   r   add_autoshapeprst)	r?   r   r   r   r   r   ra   rb   r^   s	            rC   r   z_BaseGroupShapes._add_sp  sT     !!.1137;;[[&&sD.2E2Eq!RQST	rD   c                n    | j                   }d|dz
  z  }| j                  j                  ||||||      }|S )zvReturn newly-appended textbox `p:sp` element.

        Element has position (`x`, `y`) and size (`cx`, `cy`).
        z
TextBox %dr   )rZ   r=   r   )r?   r   r   r   r   ra   rb   r^   s           rC   r   z _BaseGroupShapes._add_textbox_sp  s@    
 !!sQw'\\%%c4Ar2>	rD   c                     yzAdjust position and size to incorporate all contained shapes.

        This would typically be called when a contained shape is added, removed, or its position
        or size updated.
        Nr   r}   s    rC   r   z%_BaseGroupShapes._recalculate_extents  s     	rD   )r   r0   rA   r5   )r   r+   r   r6   r   r6   r   r6   r   r6   r   r*   r   r)   )r   r,   r   r6   r   r6   r   r6   r   r6   r   r   )r   )r   zIterable[BaseShape]r   r   )NNNNN)r   str | IO[bytes]r   r   r   r6   r   r6   r   Length | Noner   r
  r   str | IO[bytes] | Noner   r
  r   r
  r   r   )NN)r   r	  r   r6   r   r6   r   r
  r   r
  r   r   )r   r-   r   r6   r   r6   r   r6   r   r6   r   r   )
r   r6   r   r6   r   r6   r   r6   r   r   )r   r   g      ?)r   floatr   r  r   ztuple[float, float] | floatr   r   )r   r   r   r   )r   r   r   r6   r   r6   r   r6   r   r6   r   r   )r   r,   r   r6   r   r6   r   r6   r   r6   r   r/   )r   r1   r   r   r   r6   r   r6   r   r
  r   r
  r   r   )r   r   r   r6   r   r6   r   r6   r   r6   r   r   )
r   r6   r   r6   r   r6   r   r6   r   r   r   r   )r   r   r   r   __annotations__r<   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   s   @rC   r   r      s   9
O@!@ @ 	@
 @ @ @ 
@0;*; ; 	;
 ; ; 
;$<0  $ $,0$(%)7E$7E 7E 	7E
 7E 7E 7E *7E "7E #7E 
7E|  $ $7#7 7 	7
 7 7 
7,4!*4284?E4NT4^d4	44 \_MM+0M=XM	M./!&,28>D	  ^*^ ^ 	^
 ^ ^ 
^,  	
    
,
+
06
;A
GM
SY
	
rD   r   c                      e Zd ZdZddZy)GroupShapeszThe sequence of child shapes belonging to a group shape.

    Note that this collection can itself contain a group shape, making this part of a recursive,
    tree data structure (acyclic graph).
    c                8    | j                   j                          yr  )r   r   r}   s    rC   r   z GroupShapes._recalculate_extents  s     	'')rD   Nr  )r   r   r   r   r   r   rD   rC   r  r  
  s    *rD   r  c                      e Zd ZU dZded<   dej                  f	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 ddZ	 	 	 	 	 	 	 	 	 	 	 	 	 	 ddZddZ	e
dd       Ze
dd	       Z	 	 	 	 	 	 	 	 	 	 	 	 	 	 dd
ZddZddZy)SlideShapeszSequence of shapes appearing on a slide.

    The first shape in the sequence is the backmost in z-order and the last shape is topmost.
    Supports indexed access, len(), index(), and iteration.
    r3   rA   Nc                    t         j                  | | j                  |||||||	      }| j                  j	                  |       | j                  |       t        t        | j                  |            S )a  Return newly added movie shape displaying video in `movie_file`.

        **EXPERIMENTAL.** This method has important limitations:

        * The size must be specified; no auto-scaling such as that provided by :meth:`add_picture`
          is performed.
        * The MIME type of the video file should be specified, e.g. 'video/mp4'. The provided
          video file is not interrogated for its type. The MIME type `video/unknown` is used by
          default (and works fine in tests as of this writing).
        * A poster frame image must be provided, it cannot be automatically extracted from the
          video file. If no poster frame is provided, the default "media loudspeaker" image will
          be used.

        Return a newly added movie shape to the slide, positioned at (`left`, `top`), having size
        (`width`, `height`), and containing `movie_file`. Before the video is started,
        `poster_frame_image` is displayed as a placeholder for the video.
        )	_MoviePicElementCreatornew_movie_picrZ   r=   r   _add_video_timingr	   r   rI   )	r?   
movie_filer   r   r   r   poster_frame_image	mime_type	movie_pics	            rC   	add_moviezSlideShapes.add_movie#  so    6 ,99

	 	I&y)L$"5"5i"@AArD   c                l    | j                  ||||||      }t        t        | j                  |            S )a  Add a |GraphicFrame| object containing a table.

        The table has the specified number of `rows` and `cols` and the specified position and
        size. `width` is evenly distributed between the columns of the new table. Likewise,
        `height` is evenly distributed between the rows. Note that the `.table` property on the
        returned |GraphicFrame| shape must be used to access the enclosed |Table| object.
        )"_add_graphicFrame_containing_tabler	   r   rI   )r?   rowscolsr   r   r   r   r   s           rC   	add_tablezSlideShapes.add_tableM  s9     >>tT4QTV[]cdL$"5"5l"CDDrD   c                P    |j                         D ]  }| j                  |        y)zAdd placeholder shapes based on those in `slide_layout`.

        Z-order of placeholders is preserved. Latent placeholders (date, slide number, and footer)
        are not cloned.
        N)iter_cloneable_placeholdersrc   )r?   slide_layoutr]   s      rC   clone_layout_placeholdersz%SlideShapes.clone_layout_placeholdersZ  s*     (CCE 	0K"";/	0rD   c                .    | j                   j                  S )z-Sequence of placeholder shapes in this slide.)rA   placeholdersr}   s    rC   r'  zSlideShapes.placeholdersc  s     {{'''rD   c                    | j                   j                         D ]2  }|j                  dk(  st        t        | j                  |            c S  y)ziThe title placeholder shape on the slide.

        |None| if the slide has no title placeholder.
        r   N)r=   iter_ph_elmsrY   r	   r   rI   )r?   elms     rC   titlezSlideShapes.titleh  sH     <<,,. 	=CzzQE4#6#6s#;<<	= rD   c           
     r    | j                   }d|dz
  z  }| j                  j                  ||||||||      }	|	S )zNReturn a newly added `p:graphicFrame` element containing a table as specified.zTable %dr   )rZ   r=   r!  )
r?   r  r   r   r   r   r   _idrb   r   s
             rC   r  z.SlideShapes._add_graphicFrame_containing_tables  sE     !!S1W%||--c4tQ2rRrD   c                    | j                   j                  d      d   }|j                         }|j                  |j                         y)zAdd a `p:video` element under `p:sld/p:timing`.

        The element will refer to the specified `pic` element by its shape id, and cause the video
        play controls to appear for that video.
        z/p:sldr   N)r=   r   get_or_add_childTnLst	add_videor   )r?   r   sld
childTnLsts       rC   r  zSlideShapes._add_video_timing|  s=     ll  *1-..0
S\\*rD   c                    t        ||       S r   SlideShapeFactoryrO   s     rC   rI   zSlideShapes._shape_factory  s     D11rD   )r  r	  r   r6   r   r6   r   r6   r   r6   r  r  r  r   r   r   )r  r   r   r   r   r6   r   r6   r   r6   r   r6   r   r   )r$  r4   r   r   )r   SlidePlaceholders)r   zShape | None)r  r   r   r   r   r6   r   r6   r   r6   r   r6   r   r   )r   r   r   r   r   )r   r   r   r   r  CTVIDEOr  r!  r%  r   r'  r+  r  r  rI   r   rD   rC   r  r    s0    M 6:(B#(B (B 	(B
 (B (B 3(B (B 
(BTEE"E*0E7=EFLEV\E	E0 ( (  "'-28>DJP	 +2rD   r  c                      e Zd ZdZddZy)LayoutShapeszSequence of shapes appearing on a slide layout.

    The first shape in the sequence is the backmost in z-order and the last shape is topmost.
    Supports indexed access, len(), index(), and iteration.
    c                    t        ||       S r   _LayoutShapeFactoryrO   s     rC   rI   zLayoutShapes._shape_factory      "9d33rD   Nr   r   r   r   r   rI   r   rD   rC   r:  r:        4rD   r:  c                      e Zd ZdZddZy)MasterShapeszSequence of shapes appearing on a slide master.

    The first shape in the sequence is the backmost in z-order and the last shape is topmost.
    Supports indexed access, len(), and iteration.
    c                    t        ||       S r   )_MasterShapeFactoryrO   s     rC   rI   zMasterShapes._shape_factory  r>  rD   Nr   r?  r   rD   rC   rB  rB    r@  rD   rB  c                       e Zd ZdZddZddZy)NotesSlideShapeszSequence of shapes appearing on a notes slide.

    The first shape in the sequence is the backmost in z-order and the last shape is topmost.
    Supports indexed access, len(), index(), and iteration.
    c                    t         j                  dt         j                  dt         j                  dt         j                  dt         j
                  dt         j                  di|   S )a  Return the base name for a placeholder of `ph_type` in this shape collection.

        A notes slide uses a different name for the body placeholder and has some unique
        placeholder types, so this method overrides the default in the base class.
        zNotes Placeholderrf   rg   rh   zSlide Image Placeholderri   )r
   rl   ro   rp   rq   SLIDE_IMAGErv   rz   s     rC   r{   zNotesSlideShapes.ph_basename  s`     !4!3!!#7!!#7&&(A'')C
  	rD   c                    t        ||       S )zKReturn appropriate shape object for `shape_elm` appearing on a notes slide.)_NotesSlideShapeFactoryrO   s     rC   rI   zNotesSlideShapes._shape_factory  s    &y$77rD   Nr   r   )r   r   r   r   r{   rI   r   rD   rC   rF  rF    s    8rD   rF  c                  "    e Zd ZdZedd       Zy)BasePlaceholdersa  Base class for placeholder collections.

    Subclasses differentiate behaviors for a master, layout, and slide. By default, placeholder
    shapes are constructed using |BaseShapeFactory|. Subclasses should override
    :method:`_shape_factory` to use custom placeholder classes.
    c                    | j                   S )z<True if `shape_elm` is a placeholder shape, False otherwise.)
has_ph_elmr   s    rC   r   zBasePlaceholders._is_member_elm  s     ###rD   Nr   )r   r   r   r   r   r   r   rD   rC   rL  rL    s     $ $rD   rL  c                  .    e Zd ZU dZded<   dddZd	dZy)
LayoutPlaceholderszVSequence of |LayoutPlaceholder| instance for each placeholder shape on a slide layout.z)Callable[[], Iterator[LayoutPlaceholder]]rP   Nc                N    | D ]  }|j                   j                  |k(  s|c S  |S )zQThe first placeholder shape with matching `idx` value, or `default` if not found.)rU   rY   )r?   rJ   defaultr]   s       rC   getzLayoutPlaceholders.get  s2     	#K""))S0""	# rD   c                    t        ||       S r   r<  rO   s     rC   rI   z!LayoutPlaceholders._shape_factory  r>  rD   r:   )rJ   r   rR  LayoutPlaceholder | Noner   rU  r   r   r   r   r   r  rS  rI   r   rD   rC   rP  rP    s    ` 4rD   rP  c                  6    e Zd ZU dZded<   dddZ	 	 	 	 d	dZy)
MasterPlaceholderszTSequence of MasterPlaceholder representing the placeholder shapes on a slide master.z)Callable[[], Iterator[MasterPlaceholder]]rP   Nc                :    | D ]  }|j                   |k(  s|c S  |S )zReturn the first placeholder shape with type `ph_type` (e.g. 'body').

        Returns `default` if no such placeholder shape is present in the collection.
        )rV   )r?   rV   rR  r]   s       rC   rS  zMasterPlaceholders.get  s.    
   	#K""g-""	# rD   c                6    t        t        t        ||             S r   )r	   r   rD  r?   placeholder_elms     rC   rI   z!MasterPlaceholders._shape_factory  s     %':?D'QRRrD   r:   )rV   r
   rR  zMasterPlaceholder | None)r\  r   r   r   rV  r   rD   rC   rX  rX    s,    ^ S'S	SrD   rX  c                  ,    e Zd ZU dZded<   	 	 	 	 ddZy)NotesSlidePlaceholdersz0Sequence of placeholder shapes on a notes slide.z-Callable[[], Iterator[NotesSlidePlaceholder]]rP   c                6    t        t        t        ||             S )zTReturn an instance of the appropriate placeholder proxy class for `placeholder_elm`.)r	   r    rJ  r[  s     rC   rI   z%NotesSlidePlaceholders._shape_factory  s     )+B?TX+YZZrD   N)r\  r   r   r    )r   r   r   r   r  rI   r   rD   rC   r^  r^    s'    : ['[	[rD   r^  c                  2    e Zd ZU dZded<   ddZd Zd	dZy)
r6  zCollection of placeholder shapes on a slide.

    Supports iteration, :func:`len`, and dictionary-style lookup on the `idx` value of the
    placeholders it contains.
    r0   r   c                    | j                   j                         D ]  }|j                  |k(  st        ||       c S  t	        d|z        )zAccess placeholder shape having `idx`.

        Note that while this looks like list access, idx is actually a dictionary key and will
        raise |KeyError| if no placeholder with that idx value is in the collection.
        z+no placeholder on this slide with idx == %d)r   r)  rY   r5  KeyError)r?   rJ   es      rC   rM   zSlidePlaceholders.__getitem__  sK     ++- 	2Axx3(D11	2 DsJKKrD   c                     t         j                  j                         D cg c]  }| c}d       } fd|D        S c c}w )z+Generate placeholder shapes in `idx` order.c                    | j                   S r:   )rY   )rc  s    rC   <lambda>z,SlidePlaceholders.__iter__.<locals>.<lambda>  s    RSRZRZ rD   )keyc              3  6   K   | ]  }t        |        y wr:   r4  ).0rc  r?   s     rC   	<genexpr>z-SlidePlaceholders.__iter__.<locals>.<genexpr>  s     <q!!T*<s   )sortedr   r)  )r?   rc  ph_elmss   `  rC   rP   zSlidePlaceholders.__iter__  s9    T]]%?%?%AB!BHZ[<G<< Cs   	Ac                Z    t        t        | j                  j                                     S )z#Return count of placeholder shapes.)rR   rF   r   r)  r}   s    rC   rS   zSlidePlaceholders.__len__  s    4224566rD   N)rJ   r   r   )r   r   r   r   r  rM   rP   rS   r   rD   rC   r6  r6    s     	L=
7rD   r6  c           	     F   | j                   }t        | t              r+| j                  d      }|rt	        | |      S t        | |      S t        d      t        t        d      t        t        d      t        t        d      t        ij                  |t              } || |      S )r   z./p:nvPicPr/p:nvPr/a:videoFilezp:cxnSpzp:grpSpp:spp:graphicFrame)tagr   r   r   r   r   r   r   r   r   r   rS  r   )rL   rA   rq  
videoFiles	shape_clss        rC   r   r   #  s    
--C)Z(__%EF
F++y&)) 	9y
9z
6
E
l	
 
c#y  Y''rD   c                j    t        | t              r| j                  rt        | |      S t	        | |      S )zBReturn appropriate shape object for `shape_elm` on a slide layout.)r   r   rN  r   r   rL   rA   s     rC   r=  r=  7  .    )X&9+?+? F33Iv..rD   c                j    t        | t              r| j                  rt        | |      S t	        | |      S )zBReturn appropriate shape object for `shape_elm` on a slide master.)r   r   rN  r   r   ru  s     rC   rD  rD  >  rv  rD   c                j    t        | t              r| j                  rt        | |      S t	        | |      S )zAReturn appropriate shape object for `shape_elm` on a notes slide.)r   r   rN  r    r   ru  s     rC   rJ  rJ  E  s.    )X&9+?+?$Y77Iv..rD   c                   | j                   }|t        d      k(  rqt        j                  t        t        j
                  t        t        j                  t        t        j                  t        ij                  | j                  t              }n0|t        d      k(  rt        }n|t        d      k(  rt        }nt        } || |      S )zCReturn a placeholder shape of the appropriate type for `shape_elm`.ro  rp  zp:pic)rq  r   r
   rk   r!   rn   r   ru   rx   r%   rS  rV   r$   r"   r#   r   )rL   rA   rq  Constructors       rC   _SlidePlaceholderFactoryr{  L  s    
--C
bj!!#5  "2""$6  "2	

 #i!1
2 	 
#$	$-	7	(&y&))rD   c                J    | j                   rt        | |      S t        | |      S )z;Return appropriate shape object for `shape_elm` on a slide.)rN  r{  r   ru  s     rC   r5  r5  _  s%    '	6::Iv..rD   c                  $    e Zd ZdZ	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d fdZe	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dd       Zedd       Ze	dd       Z
e	dd       Ze	dd       Zedd       Zedd	       Ze	dd
       Ze	dd       Zedd       Z xZS )r  a  Functional service object for creating a new movie p:pic element.

    It's entire external interface is its :meth:`new_movie_pic` class method that returns a new
    `p:pic` element containing the specified video. This class is not intended to be constructed
    or an instance of it retained by the caller; it is a "one-shot" object, really a function
    wrapped in a object such that its helper methods can be organized here.
    c
                    t         t        |           || _        || _        || _        ||||f\  | _        | _        | _        | _	        || _
        |	| _        y r:   )r;   r  r<   _shapes	_shape_id_movie_file_x_y_cx_cy_poster_frame_file
_mime_type)r?   r   r   r  r   r   r   r   poster_frame_filer  rB   s             rC   r<   z _MoviePicElementCreator.__init__o  sV     	%t57!%/0!R|,$(DH"3#rD   c
                6     | |||||||||		      j                   S )zReturn a new `p:pic` element containing video in `movie_file`.

        If `mime_type` is None, 'video/unknown' is used. If `poster_frame_file` is None, the
        default "media loudspeaker" image is used.
        )_pic)
clsr   r   r  r   r   r   r   r  r  s
             rC   r  z%_MoviePicElementCreator.new_movie_pic  s'    $ 68ZAr2?QS\]bbbrD   c                     | j                   d   S )zReturn the rId of RT.MEDIA relationship to video part.

        For historical reasons, there are two relationships to the same part; one is the video rId
        and the other is the media rId.
        r   _video_part_rIdsr}   s    rC   
_media_rIdz"_MoviePicElementCreator._media_rId       $$Q''rD   c                    t        j                  | j                  | j                  | j                  | j
                  | j                  | j                  | j                  | j                  | j                  	      S )z5Return the new `p:pic` element referencing the video.)r   new_video_picr  _shape_name
_video_rIdr  _poster_frame_rIdr  r  r  r  r}   s    rC   r  z_MoviePicElementCreator._pic  sZ     ''NNOOOO""GGGGHHHH

 
	
rD   c                T    | j                   }|t        j                  t              S |S )zReturn the image file for video placeholder image.

        If no poster frame file is provided, the default "media loudspeaker" image is used.
        )r  ioBytesIOr   )r?   r  s     rC   _poster_frame_image_filez0_MoviePicElementCreator._poster_frame_image_file  s,     !33$::122  rD   c                V    | j                   j                  | j                        \  }}|S )zReturn the rId of relationship to poster frame image.

        The poster frame is the image used to represent the video before it's played.
        )_slide_partr   r  )r?   _poster_frame_rIds      rC   r  z)_MoviePicElementCreator._poster_frame_rId  s,     #..DDTEbEbcrD   c                .    | j                   j                  S )zReturn the appropriate shape name for the p:pic shape.

        A movie shape is named with the base filename of the video.
        )_videofilenamer}   s    rC   r  z#_MoviePicElementCreator._shape_name  s     {{###rD   c                .    | j                   j                  S )z8Return SlidePart object for slide containing this movie.r  r   r}   s    rC   r  z#_MoviePicElementCreator._slide_part       ||   rD   c                V    t        j                  | j                  | j                        S )z2Return a |Video| object containing the movie file.)r   from_path_or_file_liker  r  r}   s    rC   r  z_MoviePicElementCreator._video  s!     ++D,<,<dooNNrD   c                Z    | j                   j                  | j                        \  }}||fS )zReturn the rIds for relationships to media part for video.

        This is where the media part and its relationships to the slide are actually created.
        )r  get_or_add_video_media_partr  )r?   	media_rId	video_rIds      rC   r  z(_MoviePicElementCreator._video_part_rIds  s.      $//KKDKKX	9)##rD   c                     | j                   d   S )zReturn the rId of RT.VIDEO relationship to video part.

        For historical reasons, there are two relationships to the same part; one is the video rId
        and the other is the media rId.
        r   r  r}   s    rC   r  z"_MoviePicElementCreator._video_rId  r  rD   )r   r  r   r   r  r	  r   r6   r   r6   r   r6   r   r6   r  r  r  
str | None)r   r  r   r   r  r	  r   r6   r   r6   r   r6   r   r6   r  r  r  r  r   r   r   r   )r   r   r   r	  r   r2   )r   r   )r   ztuple[str, str])r   r   r   r   r<   classmethodr  r   r  r(   r  r  r  r  r  r  r  r  r   r   s   @rC   r  r  f  s   $$ $ $	$
 $ $ $ $ 2$ $( cc c $	c
 c c c c 3c c 
c c& ( ( 
 
 ! !     $ $ ! ! O O $ $ ( (rD   r  c                  L   e Zd ZdZ	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 ddZe	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dd       Zedd       Zedd       Z	edd       Z
edd       Zedd       Zedd	       Zedd
       Zedd       Zedd       Zedd       Zedd       Zy)r   a  Functional service object for creating a new OLE-object p:graphicFrame element.

    It's entire external interface is its :meth:`graphicFrame` class method that returns a new
    `p:graphicFrame` element containing the specified embedded OLE-object shape. This class is not
    intended to be constructed or an instance of it retained by the caller; it is a "one-shot"
    object, really a function wrapped in a object such that its helper methods can be organized
    here.
    c                    || _         || _        || _        || _        || _        || _        || _        || _        |	| _        |
| _	        || _
        y r:   )r  r  _ole_object_file_prog_id_argr  r  _cx_arg_cy_arg_icon_file_arg_icon_width_arg_icon_height_arg)r?   r   r   ole_object_filer   r   r   r   r   r   r   r   s               rC   r<   z!_OleObjectElementCreator.__init__  sV     ! /#') +rD   c                :     | |||||||||	|
|      j                   S )zJReturn new `p:graphicFrame` element containing embedded `ole_object_file`.)_graphicFrame)r  r   r   r  r   r   r   r   r   r   r   r   s               rC   r   z%_OleObjectElementCreator.graphicFrame  s9      
 -	rD   c                   t        j                  | j                  | j                  | j                  | j
                  | j                  | j                  | j                  | j                  | j                  | j                  | j                        S )zGNewly-created `p:graphicFrame` element referencing embedded OLE-object.)r   new_ole_object_graphicFramer  r  _ole_object_rId_progId	_icon_rIdr  r  r  r  _icon_width_icon_heightr}   s    rC   r  z&_OleObjectElementCreator._graphicFrame*  sl     'BBNN  LLNNGGGGHHHH
 	
rD   c                    | j                   | j                   S t        | j                  t              rt	        | j                  j
                        S t	        d      S )zBEmu object specifying width of "show-as-icon" image for OLE shape.P )r  r   r  r   r'   r   r}   s    rC   r  z_OleObjectElementCreator._cx;  sP     <<#<<
 -7t7H7H',RC!!''(	
X[\bXc	
rD   c                    | j                   | j                   S t        | j                  t              rt	        | j                  j
                        S t	        d      S )zCEmu object specifying height of "show-as-icon" image for OLE shape.@M	 )r  r   r  r   r'   r   r}   s    rC   r  z_OleObjectElementCreator._cyH  sP     <<#<<
 .88I8I7-SC!!(()	
Y\]cYd	
rD   c                H    | j                   | j                   S t        d      S )a  Vertical size of enclosed EMF icon within the OLE graphic-frame.

        This must be specified when a custom icon is used, to avoid stretching of the image and
        possible undesired resizing by PowerPoint when the OLE shape is double-clicked to open it.

        The correct size can be determined by creating an example PPTX using PowerPoint and then
        inspecting the XML of the OLE graphics-frame (p:oleObj.imgH).
        r  )r  r'   r}   s    rC   r  z%_OleObjectElementCreator._icon_heightU  s%     )-(=(=(It$$ZsSY{ZrD   c                `   | j                   | j                   S t        | j                  t              r| j                  j                  nd}t
        j                  j                  t              d   }t
        j                  j                  t
        j                  j                  |dd|            S )zReference to image file containing icon to show in lieu of this object.

        This can be either a str path or a file-like object (io.BytesIO typically).
        zgeneric-icon.emfr   z..	templates)r  r   r  r   icon_filenameospathsplit__file__abspathjoin)r?   r  _thisdirs      rC   _icon_image_filez)_OleObjectElementCreator._icon_image_filea  s     *&&& $++W5 ++# 	 77==*1-wwrww||HdKWXXrD   c                V    | j                   j                  | j                        \  }}|S )zHstr rId like "rId7" of rel to icon (image) representing OLE-object part.)r  r   r  )r?   r  r   s      rC   r  z"_OleObjectElementCreator._icon_rIdv  s)     !!778M8MN3
rD   c                H    | j                   | j                   S t        d      S )a  Width of enclosed EMF icon within the OLE graphic-frame.

        This must be specified when a custom icon is used, to avoid stretching of the image and
        possible undesired resizing by PowerPoint when the OLE shape is double-clicked to open it.
        r  )r  r'   r}   s    rC   r  z$_OleObjectElementCreator._icon_width|  s%     (,';';'Gt##XSQW[XrD   c                b    | j                   j                  | j                  | j                        S )zstr rId like "rId6" of relationship to embedded ole_object part.

        This is where the ole_object part and its relationship to the slide are actually created.
        )r  add_embedded_ole_object_partr  r  r}   s    rC   r  z(_OleObjectElementCreator._ole_object_rId  s.     <<t44
 	
rD   c                V    | j                   }t        |t              r|j                  S |S )zstr like "Excel.Sheet.12" identifying program used to open object.

        This value appears in the `progId` attribute of the `p:oleObj` element for the object.
        )r  r   r   progId)r?   prog_id_args     rC   r  z _OleObjectElementCreator._progId  s+     '' &0W%E{!!V;VrD   c                &    d| j                   dz
  z  S )zstr name like "Object 1" for the embedded ole_object shape.

        The name is formed from the prefix "Object " and the shape-id decremented by 1.
        z	Object %dr   )r  r}   s    rC   r  z$_OleObjectElementCreator._shape_name  s     dnnq011rD   c                .    | j                   j                  S )z SlidePart object for this slide.r  r}   s    rC   r  z$_OleObjectElementCreator._slide_part  r  rD   N)r   r   r   r   r  r	  r   PROG_ID | strr   r6   r   r6   r   r
  r   r
  r   r  r   r
  r   r
  )r   r   r   r   r  r	  r   r  r   r6   r   r6   r   r
  r   r
  r   r  r   r
  r   r
  r   r   )r   r   )r   r6   r  r  r  )r   r   r   r   r<   r  r   r(   r  r  r  r  r  r  r  r  r  r  r  r   rD   rC   r   r     s   , , , )	,
 , , , , , *, ", #,4    )	
      * " # 
! : 
 
  

 

 

 

 	[ 	[ Y Y(  
 Y Y 
 
 	W 	W 2 2 ! !rD   r   )rL   r.   rA   r5   r   r   )rL   r.   rA   r5   )kr   
__future__r   r  r  typingr   r   r   r   r   r	   pptx.enum.shapesr
   r   
pptx.mediar   r   pptx.opc.constantsr   r7  pptx.oxml.nsr   pptx.oxml.shapes.autoshaper   pptx.oxml.shapes.graphfrmr   pptx.oxml.shapes.picturer   pptx.oxml.simpletypesr   pptx.shapes.autoshaper   r   pptx.shapes.baser   pptx.shapes.connectorr   pptx.shapes.freeformr   pptx.shapes.graphfrmr   pptx.shapes.groupr   pptx.shapes.picturer   r   pptx.shapes.placeholderr   r   r   r    r!   r"   r#   r$   r%   pptx.sharedr&   	pptx.utilr'   r(   pptx.chart.chartr)   pptx.chart.datar*   pptx.enum.chartr+   r,   r-   pptx.oxml.shapesr.   pptx.oxml.shapes.connectorr/   pptx.oxml.shapes.groupshaper0   pptx.parts.imager1   pptx.parts.slider2   
pptx.slider3   r4   
pptx.typesr5   r6   r8   r   r  r  r:  rB  rF  rL  rP  rX  r^  r6  r   r=  rD  rJ  r{  r5  objectr  r   r   rD   rC   <module>r     sa   @ " 	 	 H H 4 1 1  / = / . 6 & + 0 - ( .
 
 
 - '&)->-79**-' 6R1& R1je{ eP	*" * n2" n2b	4; 	4	4; 	48{ 86${ $4) 4&S) S0[/ [7, 7<((///*&/(f (D~!v ~!rD   