
    ,h8                     p   d 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  G d	 d
e      Z G d dee	      Z G d de	      Z G d dee	      Z G d de      Z G d dee	      Z G d de      Z G d de      Z G d de      Z G d de      Z G d dee      Z G d d e      Zy!)"zPlaceholder-related objects.

Specific to shapes having a `p:ph` element. A placeholder has distinct behaviors
depending on whether it appears on a slide, layout, or master. Hence there is a
non-trivial class inheritance structure.
    )MSO_SHAPE_TYPEPP_PLACEHOLDER)CT_GraphicalObjectFrame)
CT_Picture)Shape)GraphicFrame)Picture)Emuc                       e Zd ZdZed        Zej                  d        Zed        Zej                  d        Zed        Zed        Z	e	j                  d        Z	ed	        Z
e
j                  d
        Z
ed        Z fdZd Z xZS )_InheritsDimensionsa  
    Mixin class that provides inherited dimension behavior. Specifically,
    left, top, width, and height report the value from the layout placeholder
    where they would have otherwise reported |None|. This behavior is
    distinctive to placeholders. :meth:`_base_placeholder` must be overridden
    by all subclasses to provide lookup of the appropriate base placeholder
    to inherit from.
    c                 $    | j                  d      S )z
        The effective height of this placeholder shape; its directly-applied
        height if it has one, otherwise the height of its parent layout
        placeholder.
        height_effective_valueselfs    Y/var/www/html/Resume-Scraper/venv/lib/python3.12/site-packages/pptx/shapes/placeholder.pyr   z_InheritsDimensions.height   s     $$X..    c                 &    || j                   _        y N)_elementcyr   values     r   r   z_InheritsDimensions.height&        r   c                 $    | j                  d      S )z
        The effective left of this placeholder shape; its directly-applied
        left if it has one, otherwise the left of its parent layout
        placeholder.
        leftr   r   s    r   r   z_InheritsDimensions.left*   s     $$V,,r   c                 &    || j                   _        y r   )r   xr   s     r   r   z_InheritsDimensions.left3       r   c                 "    t         j                  S z
        Member of :ref:`MsoShapeType` specifying the type of this shape.
        Unconditionally ``MSO_SHAPE_TYPE.PLACEHOLDER`` in this case.
        Read-only.
        r   PLACEHOLDERr   s    r   
shape_typez_InheritsDimensions.shape_type7        )))r   c                 $    | j                  d      S )z
        The effective top of this placeholder shape; its directly-applied
        top if it has one, otherwise the top of its parent layout
        placeholder.
        topr   r   s    r   r(   z_InheritsDimensions.top@   s     $$U++r   c                 &    || j                   _        y r   )r   yr   s     r   r(   z_InheritsDimensions.topI   r    r   c                 $    | j                  d      S )z
        The effective width of this placeholder shape; its directly-applied
        width if it has one, otherwise the width of its parent layout
        placeholder.
        widthr   r   s    r   r,   z_InheritsDimensions.widthM   s     $$W--r   c                 &    || j                   _        y r   )r   cxr   s     r   r,   z_InheritsDimensions.widthV   r   r   c                     t        d      )z
        Return the layout or master placeholder shape this placeholder
        inherits from. Not to be confused with an instance of
        |BasePlaceholder| (necessarily).
        z&Must be implemented by all subclasses.)NotImplementedErrorr   s    r   _base_placeholderz%_InheritsDimensions._base_placeholderZ   s     ""JKKr   c                 b    t        t        t        |       |      }||S | j                  |      S )z
        The effective value of *attr_name* on this placeholder shape; its
        directly-applied value if it has one, otherwise the value on the
        layout placeholder it inherits from.
        )getattrsuperr   _inherited_value)r   	attr_namedirectly_applied_value	__class__s      r   r   z$_InheritsDimensions._effective_valuec   s7     ")/BD)I9!U!-))$$Y//r   c                 <    | j                   }|yt        ||      }|S )zz
        Return the attribute value, e.g. 'width' of the base placeholder this
        placeholder inherits from.
        N)r1   r3   )r   r6   base_placeholderinherited_values       r   r5   z$_InheritsDimensions._inherited_valuen   s,    
  11#!"2I>r   )__name__
__module____qualname____doc__propertyr   setterr   r%   r(   r,   r1   r   r5   __classcell__)r8   s   @r   r   r      s     / / ]]! ! - - 
[[    * * , , 	ZZ    . . \\! ! L L	0	r   r   c                   F    e Zd ZdZed        Zed        Zed        Zd Zy)_BaseSlidePlaceholderzhBase class for placeholders on slides.

    Provides common behaviors such as inherited dimensions.
    c                      yzv
        Boolean indicating whether this shape is a placeholder.
        Unconditionally |True| in this case.
        T r   s    r   is_placeholderz$_BaseSlidePlaceholder.is_placeholder        r   c                 "    t         j                  S r"   r#   r   s    r   r%   z _BaseSlidePlaceholder.shape_type   r&   r   c                     | j                   j                  | j                  j                  }}|j                  j                  |      S )z
        Return the layout placeholder this slide placeholder inherits from.
        Not to be confused with an instance of |BasePlaceholder|
        (necessarily).
        idxpartslide_layoutr   ph_idxplaceholdersgetr   layoutrM   s      r   r1   z'_BaseSlidePlaceholder._base_placeholder   s;     ii,,dmm.B.B""&&3&//r   c                     |j                   j                  j                  | j                  j                         | j                  j                  |       | j                  j                         j                  | j                         d| _        y)aT  
        Substitute *element* for this placeholder element in the shapetree.
        This placeholder's `._element` attribute is set to |None| and its
        original element is free for garbage collection. Any attribute access
        (including a method call) on this placeholder after this call raises
        |AttributeError|.
        N)_nvXxPrnvPr
_insert_phr   phaddprevious	getparentremove)r   elements     r   _replace_placeholder_withz/_BaseSlidePlaceholder._replace_placeholder_with   s^     	''(8(89!!'*!((7r   N)	r<   r=   r>   r?   r@   rH   r%   r1   r_   rG   r   r   rD   rD   z   sH    
   * * 0 0r   rD   c                   P    e Zd ZdZed        Zed        Zed        Zed        Zy)BasePlaceholdera  
    NOTE: This class is deprecated and will be removed from a future release
    along with the properties *idx*, *orient*, *ph_type*, and *sz*. The *idx*
    property will be available via the .placeholder_format property. The
    others will be accessed directly from the oxml layer as they are only
    used for internal purposes.

    Base class for placeholder subclasses that differentiate the varying
    behaviors of placeholders on a master, layout, and slide.
    c                 .    | j                   j                  S )z=
        Integer placeholder 'idx' attribute, e.g. 0
        )_sprQ   r   s    r   rM   zBasePlaceholder.idx   s    
 xxr   c                 .    | j                   j                  S )zA
        Placeholder orientation, e.g. ST_Direction.HORZ
        )rc   	ph_orientr   s    r   orientzBasePlaceholder.orient   s    
 xx!!!r   c                 .    | j                   j                  S )zD
        Placeholder type, e.g. PP_PLACEHOLDER.CENTER_TITLE
        )rc   ph_typer   s    r   rh   zBasePlaceholder.ph_type   s    
 xxr   c                 .    | j                   j                  S )zJ
        Placeholder 'sz' attribute, e.g. ST_PlaceholderSize.FULL
        )rc   ph_szr   s    r   szzBasePlaceholder.sz   s    
 xx~~r   N)	r<   r=   r>   r?   r@   rM   rf   rh   rk   rG   r   r   ra   ra      sW    	   " "      r   ra   c                        e Zd ZdZed        Zy)LayoutPlaceholderz
    Placeholder shape on a slide layout, providing differentiated behavior
    for slide layout placeholders, in particular, inheriting shape properties
    from the master placeholder having the same type, when a matching one
    exists.
    c                    t         j                  t         j                  t         j                  t         j                  t         j                  t         j                  t         j                  t         j
                  t         j                  t         j                  t         j                  t         j                  t         j                  t         j                  t         j                  t         j                  t         j                  t         j                  t         j                  t         j                  t         j                  t         j                  t         j                  t         j                  t         j                  t         j                  t         j
                  t         j
                  i| j                  j                      }| j"                  j$                  }|j&                  j)                  |d      S )zV
        Return the master placeholder this layout placeholder inherits from.
        N)r   BODYCHARTBITMAPCENTER_TITLETITLE	ORG_CHARTDATEFOOTER
MEDIA_CLIPOBJECTPICTURESLIDE_NUMBERSUBTITLETABLEr   rh   rO   slide_masterrR   rS   )r   base_ph_typer}   s      r   r1   z#LayoutPlaceholder._base_placeholder   s7    !4!4  ."5"5!!>#6#6'')=)=$$n&9&9!4!4!!>#8#8%%~':':!!>#6#6""N$7$7'')D)D##^%8%8  ."5"5  ."6"6
 --

!  yy--((,,\4@@r   Nr<   r=   r>   r?   r@   r1   rG   r   r   rm   rm      s     A Ar   rm   c                       e Zd ZdZy)MasterPlaceholderz.
    Placeholder shape on a slide master.
    Nr<   r=   r>   r?   rG   r   r   r   r      s    r   r   c                        e Zd ZdZed        Zy)NotesSlidePlaceholderz
    Placeholder shape on a notes slide. Inherits shape properties from the
    placeholder on the notes master that has the same type (e.g. 'body').
    c                     | j                   j                  }| j                  j                  }|j                  j                  |      S )z
        Return the notes master placeholder this notes slide placeholder
        inherits from, or |None| if no placeholder of the matching type is
        present.
        )rh   )rO   notes_masterr^   rh   rR   rS   )r   r   rh   s      r   r1   z'NotesSlidePlaceholder._base_placeholder   s<     yy--,,&&((,,W,==r   Nr   rG   r   r   r   r      s    
 > >r   r   c                       e Zd ZdZy)SlidePlaceholderzv
    Placeholder shape on a slide. Inherits shape properties from its
    corresponding slide layout placeholder.
    Nr   rG   r   r   r   r     s    r   r   c                       e Zd ZdZd Zd Zy)ChartPlaceholderz/Placeholder shape that can only accept a chart.c                    | j                   j                  ||      }| j                  || j                  | j                  | j
                  | j                        }| j                  |       t        || j                        S )ac  
        Return a |PlaceholderGraphicFrame| object containing a new chart of
        *chart_type* depicting *chart_data* and having the same position and
        size as this placeholder. *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 the new |Chart| object is not returned directly. The chart
        object may be accessed using the
        :attr:`~.PlaceholderGraphicFrame.chart` property of the returned
        |PlaceholderGraphicFrame| object.
        )
rO   add_chart_part_new_chart_graphicFramer   r(   r,   r   r_   PlaceholderGraphicFrame_parent)r   
chart_type
chart_datarIdgraphicFrames        r   insert_chartzChartPlaceholder.insert_chart  sf     ii&&z:>33DHHdjj$++
 	&&|4&|T\\BBr   c           	      h    | j                   | j                  }}t        j                  |||||||      S )z
        Return a newly created `p:graphicFrame` element having the specified
        position and size and containing the chart identified by *rId*.
        )shape_idnamer   new_chart_graphicFrame)r   r   r   r*   r.   r   id_r   s           r   r   z(ChartPlaceholder._new_chart_graphicFrame(  s7    
 MM499T&==sAq"b
 	
r   N)r<   r=   r>   r?   r   r   rG   r   r   r   r     s    9C&
r   r   c                   "    e Zd ZdZd Zd Zd Zy)PicturePlaceholderz1Placeholder shape that can only accept a picture.c                 r    | j                  |      }| j                  |       t        || j                        S )a  Return a |PlaceholderPicture| object depicting the image in `image_file`.

        `image_file` may be either a path (string) or a file-like object. The image is
        cropped to fill the entire space of the placeholder. A |PlaceholderPicture|
        object has all the properties and methods of a |Picture| shape except that the
        value of its :attr:`~._BaseSlidePlaceholder.shape_type` property is
        `MSO_SHAPE_TYPE.PLACEHOLDER` instead of `MSO_SHAPE_TYPE.PICTURE`.
        )_new_placeholder_picr_   PlaceholderPicturer   )r   
image_filepics      r   insert_picturez!PicturePlaceholder.insert_picture6  s3     ''
3&&s+!#t||44r   c                     | j                  |      \  }}}| j                  | j                  }}t        j                  ||||      }|j                  || j                  | j                  f       |S )a	  
        Return a new `p:pic` element depicting the image in *image_file*,
        suitable for use as a placeholder. In particular this means not
        having an `a:xfrm` element, allowing its extents to be inherited from
        its layout placeholder.
        )_get_or_add_imager   r   r   
new_ph_piccrop_to_fitr,   r   )r   r   r   desc
image_sizer   r   r   s           r   r   z'PicturePlaceholder._new_placeholder_picC  sb     !% 6 6z BT:		$##HdD#>
TZZ$=>
r   c                 x    | j                   j                  |      \  }}|j                  |j                  }}|||fS )z
        Return an (rId, description, image_size) 3-tuple identifying the
        related image part containing *image_file* and describing the image.
        )rO   get_or_add_image_partr   _px_size)r   r   
image_partr   r   r   s         r   r   z$PicturePlaceholder._get_or_add_imageP  s<    
 ))99*E
C%??J,?,?jD*$$r   N)r<   r=   r>   r?   r   r   r   rG   r   r   r   r   3  s    ;5%r   r   c                        e Zd ZdZed        Zy)r   zH
    Placeholder shape populated with a table, chart, or smart art.
    c                      yrF   rG   r   s    r   rH   z&PlaceholderGraphicFrame.is_placeholder_  rI   r   N)r<   r=   r>   r?   r@   rH   rG   r   r   r   r   Z  s      r   r   c                        e Zd ZdZed        Zy)r   z5
    Placeholder shape populated with a picture.
    c                     | j                   j                  | j                  j                  }}|j                  j                  |      S )zW
        Return the layout placeholder this picture placeholder inherits from.
        rL   rN   rT   s      r   r1   z$PlaceholderPicture._base_placeholderm  s;    
 ii,,dmm.B.B""&&3&//r   Nr   rG   r   r   r   r   h  s     0 0r   r   c                       e Zd ZdZd Zd Zy)TablePlaceholderz/Placeholder shape that can only accept a table.c                 t    | j                  ||      }| j                  |       t        || j                        S )a  Return |PlaceholderGraphicFrame| object containing a `rows` by `cols` table.

        The position and width of the table are those of the placeholder and its height
        is proportional to the number of rows. A |PlaceholderGraphicFrame| object has
        all the properties and methods of a |GraphicFrame| shape except that the value
        of its :attr:`~._BaseSlidePlaceholder.shape_type` property is unconditionally
        `MSO_SHAPE_TYPE.PLACEHOLDER`. Note that the return value is not the new table
        but rather *contains* the new table. The table can be accessed using the
        :attr:`~.PlaceholderGraphicFrame.table` property of the returned
        |PlaceholderGraphicFrame| object.
        )_new_placeholder_tabler_   r   r   )r   rowscolsr   s       r   insert_tablezTablePlaceholder.insert_tabley  s5     224>&&|4&|T\\BBr   c           
          | j                   | j                  t        |dz        }}}t        j                  ||||| j
                  | j                  | j                  |      S )a  
        Return a newly added `p:graphicFrame` element containing an empty
        table with *rows* rows and *cols* columns, positioned at the location
        of this placeholder and having its same width. The table's height is
        determined by the number of rows.
        i )r   r   r
   r   new_table_graphicFramer   r(   r,   )r   r   r   r   r   r   s         r   r   z'TablePlaceholder._new_placeholder_table  sR     "&		3tf};M$&==dD$		488TZZ
 	
r   N)r<   r=   r>   r?   r   r   rG   r   r   r   r   v  s    9C 

r   r   N)r?   pptx.enum.shapesr   r   pptx.oxml.shapes.graphfrmr   pptx.oxml.shapes.picturer   pptx.shapes.autoshaper   pptx.shapes.graphfrmr   pptx.shapes.picturer	   	pptx.utilr
   objectr   rD   ra   rm   r   r   r   r   r   r   r   r   rG   r   r   <module>r      s    < = / ' - ' d& dN,/ ,^&e &RA+U AB >/ >$, 
, 
B$%. $%Nl 0,g 0
, 
r   