
    ,hp                     t   d Z ddlZddl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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&m'Z'm(Z(m)Z)m*Z*m+Z+m,Z,m-Z-m.Z. ddl/m0Z0 ddl1m2Z2m3Z3  G d de0      Z4 G d de4      Z5 G d de5      Z6 G d de5      Z7 G d de4      Z8 G d d e4      Z9 G d! d"e4      Z: G d# d$e4      Z; G d% d&e;      Z< G d' d(e;      Z= G d) d*e=      Z> G d+ d,e0      Z?d- Z@d. ZAd/ ZBd0 ZCd1 ZDd2 ZE G d3 d4eF      ZG G d5 d6eF      ZHy)7z:The shape tree, the structure that holds a slide's shapes.    N)BytesIO)PP_PLACEHOLDERPROG_ID)SPEAKER_IMAGE_BYTESVideo)CONTENT_TYPE)qn)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lazypropertyc                        e Zd ZdZ fdZd Zd Zd Zd Zd Z	e
d        Zej                  d	        Zed
        Zd Zd Ze
d        Zd Z xZS )_BaseShapesz
    Base class for a shape collection appearing in a slide-type object,
    include Slide, SlideLayout, and SlideMaster, providing common methods.
    c                 J    t         t        |   ||       || _        d | _        y N)superr#   __init___spTree_cached_max_shape_id)selfspTreeparent	__class__s      W/var/www/html/Resume-Scraper/venv/lib/python3.12/site-packages/pptx/shapes/shapetree.pyr'   z_BaseShapes.__init__C   s#    k4)&&9$(!    c                     t        | j                               }	 ||   }| j                  |      S # t        $ r t        d      w xY w)zH
        Return 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       r.   __getitem__z_BaseShapes.__getitem__H   sU     $0023
	9"3I ""9--  	9788	9s	   1 Ac              #   \   K   | j                         D ]  }| j                  |        yw)zT
        Generate a reference to each shape in the collection, in sequence.
        N)r2   r4   r*   r7   s     r.   __iter__z_BaseShapes.__iter__S   s1      //1 	1I%%i00	1s   *,c                 J    t        | j                               }t        |      S )z
        Return 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.
        )r1   r2   len)r*   r6   s     r.   __len__z_BaseShapes.__len__Z   s!     $0023
:r/   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sprA   orientszr5   id_names	            r.   clone_placeholderz_BaseShapes.clone_placeholderc   so      $&JJbhh		#R S!!!!'37$$S$SIr/   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*   rA   s     r.   ph_basenamez_BaseShapes.ph_basenamek   s     !!#8!3''  "5!3!!#7!!#7%%':!!#8$$&<""$9'')C##Z  "5  '
  ! 	r/   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    r.   turbo_add_enabledz_BaseShapes.turbo_add_enabled   s    , ((44r/   c                 d    t        |      }|r| j                  j                  | _        y d | _        y r%   )boolr(   max_shape_idr)   )r*   valueenables      r.   ri   z_BaseShapes.turbo_add_enabled   s&    eAGDLL$=$=!T!r/   c                      y)zm
        Return true if *shape_elm* represents a member of this collection,
        False otherwise.
        T r7   s    r.   _is_member_elmz_BaseShapes._is_member_elm   s     r/   c              #   v   K   | j                   j                         D ]  }| j                  |      s|  yw)z
        Generate each child of the ``<p:spTree>`` element that corresponds to
        a shape, in the sequence they appear in the XML.
        N)r(   iter_shape_elmsrr   r:   s     r.   r2   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*,
        with id number *id* and orientation *orient*. 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)rf   r   VERTr(   xpath)r*   rA   idrJ   basenamenumpartnamesrM   s           r.   rF   z_BaseShapes._next_ph_name   s     ##G, \&&&$x/H q&""#45h00D5   qLG	 r/   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".
        rv   )r)   r(   rl   rh   s    r.   rE   z_BaseShapes._next_shape_id   sB     $$0%%*%,,,||((1,,r/   c                     t        ||       S zb
        Return an instance of the appropriate shape proxy class for
        *shape_elm*.
        )BaseShapeFactoryr:   s     r.   r4   z_BaseShapes._shape_factory   s    
  	400r/   )__name__
__module____qualname____doc__r'   r8   r;   r>   rN   rf   propertyri   setterstaticmethodrr   r2   rF   rE   r4   __classcell__r-   s   @r.   r#   r#   =   s    
)
	.1J2 5 5. R R   6 - -1r/   r#   c                        e Zd ZdZ fdZd Zd Zg fdZ	 	 	 	 	 ddZddZ	d Z
d	 Zdd
Zd Zd Zd Zd Zd Zd Zd Z xZS )_BaseGroupShapesz/Base class for shape-trees that can add shapes.c                 <    t         t        |   ||       || _        y r%   )r&   r   r'   _grpSp)r*   grpSpr,   r-   s      r.   r'   z_BaseGroupShapes.__init__   s    .uf=r/   c                     | j                   j                  ||      }| j                  |||||      }| j                          | j	                  |      S )aR  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.
        )partadd_chart_part_add_chart_graphicFrame_recalculate_extentsr4   )	r*   
chart_typexycxcy
chart_datarIdgraphicFrames	            r.   	add_chartz_BaseGroupShapes.add_chart   sO     ii&&z:>33CAr2F!!#""<00r/   c                 n    | j                  |||||      }| j                          | j                  |      S )aH  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   r4   )r*   connector_typebegin_xbegin_yend_xend_ycxnSps          r.   add_connectorz_BaseGroupShapes.add_connector   s7     %O!!#""5))r/   c                     | j                   j                         }|D ]  }|j                  |j                   d         |r|j                          | 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)_element	add_grpSpinsert_element_beforerecalculate_extentsr4   )r*   shapesr   shapes       r.   add_group_shapez _BaseGroupShapes.add_group_shape	  s[     '') 	DE''
C	D%%'""5))r/   c
                     t         j                  | | j                  |||||||||	      }
| j                  j	                  |
       | j                          | j                  |
      S )a  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   rE   r(   appendr   r4   )r*   object_fileprog_idlefttopwidthheight	icon_file
icon_widthicon_heightr   s              r.   add_ole_objectz_BaseGroupShapes.add_ole_object  sm    T 0<<
 	L)!!#""<00r/   c                     | j                   j                  |      \  }}| j                  ||||||      }| j                          | j	                  |      S )a;  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   r4   )	r*   
image_filer   r   r   r   
image_partr   pics	            r.   add_picturez_BaseGroupShapes.add_pictureT  sS     ))99*E
C++JT3vV!!#""3''r/   c                     t        |      }| j                  |||||      }| j                          | 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   r4   )r*   autoshape_type_idr   r   r   r   autoshape_typerI   s           r.   	add_shapez_BaseGroupShapes.add_shaped  sB     ''89\\.$UFC!!#""2&&r/   c                 l    | j                  ||||      }| j                          | 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   r4   )r*   r   r   r   r   rI   s         r.   add_textboxz_BaseGroupShapes.add_textboxp  s7     !!$UF;!!#""2&&r/   c                 f    	 |\  }}t        j                  | ||||      S # t         $ r |x}}Y (w xY w)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.
        )	TypeErrorr   new)r*   start_xstart_yscalex_scaley_scales         r.   build_freeformz_BaseGroupShapes.build_freeformz  sG    &	&$GW ""4'7GLL  	& %%Gg	&s     00c                 ~    t        | j                  j                               }|j                  |j                        S )zxReturn the index of *shape* in this sequence.

        Raises |ValueError| if *shape* is not in the collection.
        )r1   r   rt   indexr@   )r*   r   r6   s      r.   r   z_BaseGroupShapes.index  s0    
 $--779:
..r/   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 %drv   )rE   r
   new_chart_graphicFramer(   r   )	r*   r   r   r   r   r   shape_idrM   r   s	            r.   r   z(_BaseGroupShapes._add_chart_graphicFrame  sV     &&X\*.EEdCAr2
 	L)r/   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 %drv   )rE   minabsr   	add_cxnSp)r*   r   r   r   r   r   rL   rM   flipHflipVr   r   r   r   s                 r.   r   z_BaseGroupShapes._add_cxnSp  s     !!q)%u7E"C$71UW_%s57?';B}}&&~q!RUE
 	
r/   c           
          | j                   }|j                  ||      \  }}	d|dz
  z  }
|j                  }| j                  j	                  ||
||||||	      }|S )a9  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 %drv   )rE   r   descr   add_pic)r*   r   r   r   r   r   r   rL   	scaled_cx	scaled_cyrM   r   r   s                r.   r   z)_BaseGroupShapes._add_pic_from_image_part  sd     !!)//B7	9sQw'kk!!#tT31iS
r/   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*).
        rw   rv   )rE   r{   r   add_autoshapeprst)	r*   r   r   r   r   r   rL   rM   rI   s	            r.   r   z_BaseGroupShapes._add_sp  sT     !!.1137;;[[&&sD.2E2Eq!RQST	r/   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 %drv   )rE   r(   r   )r*   r   r   r   r   rL   rM   rI   s           r.   r   z _BaseGroupShapes._add_textbox_sp  s@    
 !!sQw'\\%%c4Ar2>	r/   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.
        Nrp   rh   s    r.   r   z%_BaseGroupShapes._recalculate_extents  s     	r/   )NNNNN)NN)r   r   g      ?)r   r   r   r   r'   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   s   @r.   r   r      sn    91$
* &( *, 91v( 
''M4/
$	r/   r   c                       e Zd ZdZ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   rh   s    r.   r   z GroupShapes._recalculate_extents  s     	'')r/   N)r   r   r   r   r   rp   r/   r.   r   r     s    *r/   r   c                   n    e Zd ZdZdej
                  fdZd Zd Ze	d        Z
e	d        Zd Zd	 Z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.
    Nc                     t         j                  | | j                  |||||||	      }| j                  j	                  |       | j                  |       | 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_picrE   r(   r   _add_video_timingr4   )	r*   
movie_filer   r   r   r   poster_frame_image	mime_type	movie_pics	            r.   	add_moviezSlideShapes.add_movie  sh    : ,99

	 	I&y)""9--r/   c                 T    | j                  ||||||      }| j                  |      }|S )a  
        Add a |GraphicFrame| object containing a table with 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_tabler4   )	r*   rowscolsr   r   r   r   r   graphic_frames	            r.   	add_tablezSlideShapes.add_table.  s9     >>$c5&
 ++L9r/   c                 P    |j                         D ]  }| j                  |        y)z
        Add 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_placeholdersrN   )r*   slide_layoutrH   s      r.   clone_layout_placeholdersz%SlideShapes.clone_layout_placeholders=  s*     (CCE 	0K"";/	0r/   c                 .    | j                   j                  S )zr
        Instance of |SlidePlaceholders| containing sequence of placeholder
        shapes in this slide.
        )r,   placeholdersrh   s    r.   r  zSlideShapes.placeholdersF  s     {{'''r/   c                     | j                   j                         D ]$  }|j                  dk(  s| j                  |      c S  y)zs
        The title placeholder shape on the slide or |None| if the slide has
        no title placeholder.
        r   N)r(   iter_ph_elmsrD   r4   )r*   elms     r.   titlezSlideShapes.titleN  sA     <<,,. 	0CzzQ**3//	0 r/   c           
      r    | j                   }d|dz
  z  }| j                  j                  ||||||||      }	|	S )z~
        Return a newly added ``<p:graphicFrame>`` element containing a table
        as specified by the parameters.
        zTable %drv   )rE   r(   r   )
r*   r   r   r   r   r   r   _idrM   r   s
             r.   r   z.SlideShapes._add_graphicFrame_containing_tableY  sE    
 !!S1W%||--c4tQ2rRr/   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(   ry   get_or_add_childTnLst	add_videor   )r*   r   sld
childTnLsts       r.   r   zSlideShapes._add_video_timingc  s=     ll  *1-..0
S\\*r/   c                     t        ||       S r   SlideShapeFactoryr:   s     r.   r4   zSlideShapes._shape_factorym  s    
 !D11r/   )r   r   r   r   CTVIDEOr   r   r  r   r  r  r   r   r4   rp   r/   r.   r   r     sZ      ((*.X0 ( (  +2r/   r   c                       e Zd ZdZd Zy)LayoutShapesz
    Sequence 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   _LayoutShapeFactoryr:   s     r.   r4   zLayoutShapes._shape_factory|      
 #9d33r/   Nr   r   r   r   r4   rp   r/   r.   r  r  u      4r/   r  c                       e Zd ZdZd Zy)MasterShapesz
    Sequence 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   _MasterShapeFactoryr:   s     r.   r4   zMasterShapes._shape_factory  r  r/   Nr  rp   r/   r.   r  r    r  r/   r  c                       e Zd ZdZd Zd Zy)NotesSlideShapesz
    Sequence 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 PlaceholderrQ   rR   rS   zSlide Image PlaceholderrT   )r   rW   rZ   r[   r\   SLIDE_IMAGEra   re   s     r.   rf   zNotesSlideShapes.ph_basename  s`     !4!3!!#7!!#7&&(A'')C
  	r/   c                     t        ||       S )z}
        Return an instance of the appropriate shape proxy class for
        *shape_elm* appearing on a notes slide.
        _NotesSlideShapeFactoryr:   s     r.   r4   zNotesSlideShapes._shape_factory  s    
 'y$77r/   N)r   r   r   r   rf   r4   rp   r/   r.   r"  r"    s     8r/   r"  c                        e Zd ZdZed        Zy)BasePlaceholdersa  
    Base class for placeholder collections that 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 )zN
        True if *shape_elm* is a placeholder shape, False otherwise.
        )
has_ph_elmrq   s    r.   rr   zBasePlaceholders._is_member_elm  s    
 ###r/   N)r   r   r   r   r   rr   rp   r/   r.   r)  r)    s     $ $r/   r)  c                       e Zd ZdZddZd Zy)LayoutPlaceholderszn
    Sequence of |LayoutPlaceholder| instances representing the placeholder
    shapes on a slide layout.
    Nc                 N    | D ]  }|j                   j                  |k(  s|c S  |S )zr
        Return the first placeholder shape with matching *idx* value, or
        *default* if not found.
        )r@   rD   )r*   r5   defaultrH   s       r.   getzLayoutPlaceholders.get  s4    
   	#K""))S0""	# r/   c                     t        ||       S r   r  r:   s     r.   r4   z!LayoutPlaceholders._shape_factory  r  r/   r%   r   r   r   r   r0  r4   rp   r/   r.   r-  r-    s    
4r/   r-  c                       e Zd ZdZddZd Zy)MasterPlaceholderszm
    Sequence of _MasterPlaceholder instances representing the placeholder
    shapes on a slide master.
    Nc                 :    | D ]  }|j                   |k(  s|c S  |S )z
        Return the first placeholder shape with type *ph_type* (e.g. 'body'),
        or *default* if no such placeholder shape is present in the
        collection.
        )rA   )r*   rA   r/  rH   s       r.   r0  zMasterPlaceholders.get  s.       	#K""g-""	# r/   c                     t        ||       S r   r  r:   s     r.   r4   z!MasterPlaceholders._shape_factory  r  r/   r%   r2  rp   r/   r.   r4  r4    s    
	4r/   r4  c                       e Zd ZdZd Zy)NotesSlidePlaceholdersz:
    Sequence of placeholder shapes on a notes slide.
    c                     t        ||       S )zn
        Return an instance of the appropriate placeholder proxy class for
        *placeholder_elm*.
        r&  )r*   placeholder_elms     r.   r4   z%NotesSlidePlaceholders._shape_factory  s    
 '==r/   Nr  rp   r/   r.   r8  r8    s    >r/   r8  c                   "    e Zd ZdZd Zd Zd Zy)SlidePlaceholdersz
    Collection of placeholder shapes on a slide. Supports iteration,
    :func:`len`, and dictionary-style lookup on the `idx` value of the
    placeholders it contains.
    c                     | j                   j                         D ]  }|j                  |k(  st        ||       c S  t	        d|z        )z
        Access 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  rD   r  KeyError)r*   r5   es      r.   r8   zSlidePlaceholders.__getitem__  sK     ++- 	2Axx3(D11	2 DsJKKr/   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%   )rD   )r?  s    r.   <lambda>z,SlidePlaceholders.__iter__.<locals>.<lambda>  s
    QXX r/   )keyc              3   6   K   | ]  }t        |        y wr%   r  ).0r?  r*   s     r.   	<genexpr>z-SlidePlaceholders.__iter__.<locals>.<genexpr>  s     <q!!T*<s   )sortedr   r  )r*   r?  ph_elmss   `  r.   r;   zSlidePlaceholders.__iter__  s?     22451Q5;M
 =G<< 6s   	Ac                 Z    t        t        | j                  j                                     S )z5
        Return count of placeholder shapes.
        )r=   r1   r   r  rh   s    r.   r>   zSlidePlaceholders.__len__  s!     4224566r/   N)r   r   r   r   r8   r;   r>   rp   r/   r.   r<  r<     s    
L=7r/   r<  c           	      B   | j                   }|t        d      k(  r+| j                  d      }|rt        | |      S t	        | |      S t        d      t
        t        d      t        t        d      t        t        d      t        ij                  |t              } || |      S )zR
    Return an instance of the appropriate shape proxy class for *shape_elm*.
    p:picz./p:nvPicPr/p:nvPr/a:videoFilezp:cxnSpzp:grpSpp:spp:graphicFrame)tagr	   ry   r   r   r   r   r   r   r0  r   )r7   r,   rN  
videoFiles	shape_clss        r.   r   r   #  s     --C
bk__%EF
F++y&)) 	9y
9z
6
E
l	
 
c#y  Y''r/   c                 ~    | j                   }|t        d      k(  r| j                  rt        | |      S t	        | |      S )zh
    Return an instance of the appropriate shape proxy class for *shape_elm*
    on a slide layout.
    rL  )rN  r	   r+  r   r   r7   r,   tag_names      r.   r  r  9  ;    
 }}H2f:)"6"6 F33Iv..r/   c                 ~    | j                   }|t        d      k(  r| j                  rt        | |      S t	        | |      S )zh
    Return an instance of the appropriate shape proxy class for *shape_elm*
    on a slide master.
    rL  )rN  r	   r+  r   r   rR  s      r.   r   r   D  rT  r/   c                 ~    | j                   }|t        d      k(  r| j                  rt        | |      S t	        | |      S )zg
    Return an instance of the appropriate shape proxy class for *shape_elm*
    on a notes slide.
    rL  )rN  r	   r+  r   r   rR  s      r.   r'  r'  O  s;    
 }}H2f:)"6"6$Y77Iv..r/   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 )zM
    Return a placeholder shape of the appropriate type for *shape_elm*.
    rL  rM  rK  )rN  r	   r   rV   r   rY   r   r`   rc   r   r0  rA   r   r   r   r   )r7   r,   rN  Constructors       r.   _SlidePlaceholderFactoryrY  Z  s     --C
bj!!#5  "2""$6  "2	

 #i!1
2 	 
#$	$-	7	(&y&))r/   c                 J    | j                   rt        | |      S t        | |      S )za
    Return an instance of the appropriate shape proxy class for *shape_elm*
    on a slide.
    )r+  rY  r   )r7   r,   s     r.   r  r  o  s'    
 '	6::Iv..r/   c                        e Zd ZdZ fdZed        Zed        Ze	d        Z
e	d        Ze	d        Zed        Zed	        Ze	d
        Ze	d        Ze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   r-   s             r.   r'   z _MoviePicElementCreator.__init__  sV     	%t57!%/0!R|,$(DH"3#r/   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
             r.   r   z%_MoviePicElementCreator.new_movie_pic  s*     Hj!QB8JI

$	r/   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_rIdsrh   s    r.   
_media_rIdz"_MoviePicElementCreator._media_rId       $$Q''r/   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_rIdrm  _poster_frame_rIdr`  ra  rb  rc  rh   s    r.   rh  z_MoviePicElementCreator._pic  sZ     ''NNOOOO""GGGGHHHH

 
	
r/   c                 @    | j                   }|t        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.
        )rd  r   r   )r*   rf  s     r.   _poster_frame_image_filez0_MoviePicElementCreator._poster_frame_image_file  s(     !33$.//  r/   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   ru  )r*   _poster_frame_rIds      r.   rs  z)_MoviePicElementCreator._poster_frame_rId  s1     #..DD))
  r/   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filenamerh   s    r.   rq  z#_MoviePicElementCreator._shape_name  s     {{###r/   c                 .    | j                   j                  S )z8Return SlidePart object for slide containing this movie.r]  r   rh   s    r.   rw  z#_MoviePicElementCreator._slide_part       ||   r/   c                 V    t        j                  | j                  | j                        S )z2Return a |Video| object containing the movie file.)r   from_path_or_file_liker_  re  rh   s    r.   r{  z_MoviePicElementCreator._video  s!     ++D,<,<dooNNr/   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.
        )rw  get_or_add_video_media_partr{  )r*   	media_rId	video_rIds      r.   rl  z(_MoviePicElementCreator._video_part_rIds  s.      $//KKDKKX	9)##r/   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.
        rv   rk  rh   s    r.   rr  z"_MoviePicElementCreator._video_rId  rn  r/   )r   r   r   r   r'   classmethodr   r   rm  r!   rh  ru  rs  rq  rw  r{  rl  rr  r   r   s   @r.   r   r   y  s    	$   ( ( 
 
 	! 	! 	  	  $ $ ! ! O O $ $ ( (r/   r   c                       e Zd ZdZd Zed        Zed        Zed        Z	ed        Z
ed        Zed        Zed	        Zed
        Zed        Zed        Zed        Ze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`  ra  _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               r.   r'   z!_OleObjectElementCreator.__init__  sV     ! /#') +r/   c                 :     | |||||||||	|
|      j                   S )zJReturn new `p:graphicFrame` element containing embedded `ole_object_file`.)_graphicFrame)ri  r   r   r  r   r   r   r   r   r   r   r   s               r.   r   z%_OleObjectElementCreator.graphicFrame  s9      
 -	r/   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^  rq  _ole_object_rId_progId	_icon_rIdr`  ra  rb  rc  _icon_width_icon_heightrh   s    r.   r  z&_OleObjectElementCreator._graphicFrame5  sl     'BBNN  LLNNGGGGHHHH
 	
r/   c                     | j                   | j                   S | j                  t        v 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   rh   s    r.   rb  z_OleObjectElementCreator._cxF  sQ     <<#<<   G+ !!''(	
 V	
r/   c                     | j                   | j                   S | j                  t        v 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   rh   s    r.   rc  z_OleObjectElementCreator._cyU  sQ     <<#<<   G+ !!(()	
 V	
r/   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    rh   s    r.   r  z%_OleObjectElementCreator._icon_heightd  s*     &*%:%:%FD!!	
LOPVK	
r/   c                 P   | j                   | j                   S | j                  t        v 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   icon_filenameospathsplit__file__abspathjoin)r*   r  _thisdirs      r.   _icon_image_filez)_OleObjectElementCreator._icon_image_files  s     *&&&   G+ ++# 	 77==*1-wwrww||HdKWXXr/   c                 V    | j                   j                  | j                        \  }}|S )zHstr rId like "rId7" of rel to icon (image) representing OLE-object part.)rw  r   r  )r*   rx  r   s      r.   r  z"_OleObjectElementCreator._icon_rId  s)     !!778M8MN3
r/   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    rh   s    r.   r  z$_OleObjectElementCreator._icon_width  s%     (,';';'Gt##XSQW[Xr/   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.
        )rw  add_embedded_ole_object_partr  r  rh   s    r.   r  z(_OleObjectElementCreator._ole_object_rId  s.     <<t44
 	
r/   c                 F    | j                   }|t        v 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   progId)r*   prog_id_args     r.   r  z _OleObjectElementCreator._progId  s)     '' &1G%;{!!LLr/   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 %drv   )r^  rh   s    r.   rq  z$_OleObjectElementCreator._shape_name  s     dnnq011r/   c                 .    | j                   j                  S )z SlidePart object for this slide.r~  rh   s    r.   rw  z$_OleObjectElementCreator._slide_part  r  r/   N)r   r   r   r   r'   r  r   r!   r  rb  rc  r  r  r  r  r  r  rq  rw  rp   r/   r.   r   r     s   ,4  : 
 
  
 
 
 
 
 
 Y Y(  
 Y Y 
 
 
M 
M 2 2 ! !r/   r   )Ir   r  pptx.compatr   pptx.enum.shapesr   r   
pptx.mediar   r   pptx.opc.constantsr   r  pptx.oxml.nsr	   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!   r#   r   r   r   r  r  r"  r)  r-  r4  r8  r<  r   r  r   r'  rY  r  objectr   r   rp   r/   r.   <module>r     s.   A 	  4 1 1  = / . 6 & + 0 - ( .
 
 
 - '6d1& d1ND{ DN*" * w2" w2t4; 44; 48{ 8>${ $ 4) 404) 42
>/ 
> 7,  7F(,///**/w(f w(tH!v H!r/   