
    ,h!                     d    d 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      Zy
)zDObjects related to mouse click and hover actions on a shape or text.    )	PP_ACTION)RELATIONSHIP_TYPE)Subshape)lazypropertyc                        e Zd ZdZd fd	Zed        Zed        Zed        Z	e	j                  d        Z	d Zed        Zed	        Zed
        Zed        Z xZS )ActionSettingzAProperties specifying how a shape or run reacts to mouse actions.c                 H    t         t        |   |       || _        || _        y N)superr   __init___element_hoverselfxPrparenthover	__class__s       M/var/www/html/Resume-Scraper/venv/lib/python3.12/site-packages/pptx/action.pyr   zActionSetting.__init__   s     mT+F3    c           	      p   | j                   }|t        j                  S |j                  }|dk(  ro|j                  d   }t        j
                  t        j                  t        j                  t        j                  t        j                  t        j                  d|   S t        j                  t        j                  t        j                  t        j                  t        j                  t        j                   t        j"                  t        j$                  dj'                  |t        j                        S )a  Member of :ref:`PpActionType` enumeration, such as `PP_ACTION.HYPERLINK`.

        The returned member indicates the type of action that will result when the
        specified shape or text is clicked or the mouse pointer is positioned over the
        shape during a slide show.

        If there is no click-action or the click-action value is not recognized (is not
        one of the official `MsoPpAction` values) then `PP_ACTION.NONE` is returned.
        hlinkshowjumpjump)
firstslide	lastslidelastslideviewed	nextslidepreviousslideendshow)Nhlinksldjump	hlinkpres	hlinkfile
customshowolemacroprogram)_hlinkr   NONEaction_verbaction_fieldsFIRST_SLIDE
LAST_SLIDELAST_SLIDE_VIEWED
NEXT_SLIDEPREVIOUS_SLIDEEND_SHOW	HYPERLINKNAMED_SLIDEPLAY	OPEN_FILENAMED_SLIDE_SHOWOLE_VERB	RUN_MACRORUN_PROGRAMget)r   hlinkr)   relative_targets       r   actionzActionSetting.action   s     =>>!''/)#11&9O'33&11#,#>#>&11!*!9!9$--   %%%11"",,#44%%(( ,,	
 #k9>>
*		+r   c                 X    t        | j                  | j                  | j                        S )z
        A |Hyperlink| object representing the hyperlink action defined on
        this click or hover mouse event. A |Hyperlink| object is always
        returned, even if no hyperlink or other click action is defined.
        )	Hyperlinkr   _parentr   r   s    r   	hyperlinkzActionSetting.hyperlink?   s     dkkBBr   c                 n   t         j                  t         j                  t         j                  t         j                  t         j
                  f}| j                  |vry| j                  t         j                  k(  r| j                  d   S | j                  t         j                  k(  r| j                  d   S | j                  t         j                  k(  rA| j                  dz   }|t        | j                        k\  rt        d      | j                  |   S | j                  t         j                  k(  r.| j                  dz
  }|dk  rt        d      | j                  |   S | j                  t         j
                  k(  r;| j                  j                  }| j                  j                  |      j                  S y)a  
        A reference to the slide in this presentation that is the target of
        the slide jump action in this shape. Slide jump actions include
        `PP_ACTION.FIRST_SLIDE`, `LAST_SLIDE`, `NEXT_SLIDE`,
        `PREVIOUS_SLIDE`, and `NAMED_SLIDE`. Returns |None| for all other
        actions. In particular, the `LAST_SLIDE_VIEWED` action and the `PLAY`
        (start other presentation) actions are not supported.

        A slide object may be assigned to this property, which makes the
        shape an "internal hyperlink" to the assigened slide::

            slide, target_slide = prs.slides[0], prs.slides[1]
            shape = slide.shapes[0]
            shape.target_slide = target_slide

        Assigning |None| removes any slide jump action. Note that this is
        accomplished by removing any action present (such as a hyperlink),
        without first checking that it is a slide jump action.
        Nr      zno next slidezno previous slide)r   r+   r,   r.   r/   r2   r<   _slides_slide_indexlen
ValueErrorr'   rIdpartrelated_partslide)r   slide_jump_actionsnext_slide_idxprev_slide_idxrI   s        r   target_slidezActionSetting.target_slideH   s]   , !!    $$!!
 ;;00;;)///<<?"[[I000<<##[[I000!..2NT\\!22 11<<//[[I444!..2N! !455<<//[[I111++//C99))#.444 2r   c                     | j                          |y | j                  j                         }d|_        | j                  j                  |j                  t        j                        |_        y )Nzppaction://hlinksldjump)	_clear_click_actionr   get_or_add_hlinkClickr<   rJ   	relate_toRTSLIDErI   )r   rL   r:   s      r   rP   zActionSetting.target_slidez   sO      "=3350II''

BHH=	r   c                     | j                   }|y|j                  }|r| j                  j                  |       | j                  j                  |       y)z!Remove any existing click action.Nr'   rI   rJ   drop_relr   remover   r:   rI   s      r   rR   z!ActionSetting._clear_click_action   sC    =iiIIs#U#r   c                 r    | j                   r| j                  j                  S | j                  j                  S z
        Reference to the `a:hlinkClick` or `h:hlinkHover` element for this
        click action. Returns |None| if the element is not present.
        r   r   
hlinkHover
hlinkClickr@   s    r   r'   zActionSetting._hlink   +     ;;==+++}}'''r   c                 .    | j                   j                  S )zW
        Reference to the slide containing the shape having this click action.
        )rJ   rL   r@   s    r   _slidezActionSetting._slide   s    
 yyr   c                 L    | j                   j                  | j                        S )zv
        Position in the slide collection of the slide containing the shape
        having this click action.
        )rE   indexrc   r@   s    r   rF   zActionSetting._slide_index   s     ||!!$++..r   c                 j    | j                   j                  j                  j                  j                  S )zJ
        Reference to the slide collection for this presentation.
        )rJ   packagepresentation_partpresentationslidesr@   s    r   rE   zActionSetting._slides   s&    
 yy  22??FFFr   F)__name__
__module____qualname____doc__r   propertyr<   r   rA   rP   setterrR   r'   rc   rF   rE   __classcell__r   s   @r   r   r      s    K %+ %+N C C /5 /5b > >$ ( (   / / G Gr   r   c                   t     e Zd ZdZd fd	Zed        Zej                  d        Zd Zed        Z	d Z
 xZS )	r>   z?
    Represents a hyperlink action on a shape or text run.
    c                 H    t         t        |   |       || _        || _        y r
   )r   r>   r   r   r   r   s       r   r   zHyperlink.__init__   s     i'/r   c                 t    | j                   }|y|j                  }|sy| j                  j                  |      S )a~  
        Read/write. The URL of the hyperlink. URL can be on http, https,
        mailto, or file scheme; others may work. Returns |None| if no
        hyperlink is defined, including when another action such as
        `RUN_MACRO` is defined on the object. Assigning |None| removes any
        action defined on the object, whether it is a hyperlink action or
        not.
        N)r'   rI   rJ   
target_refr[   s      r   addresszHyperlink.address   s=      = iiyy##C((r   c                     | j                          |rD| j                  j                  |t        j                  d      }| j                         }||_        y y )NT)is_external)_remove_hlinkrJ   rT   rU   r1   _get_or_add_hlinkrI   )r   urlrI   r:   s       r   rx   zHyperlink.address   sL     	))%%c2<<T%JC**,EEI r   c                     | j                   r| j                  j                         S | j                  j                         S )z
        Get the `a:hlinkClick` or `a:hlinkHover` element for the Hyperlink
        object, depending on the value of `self._hover`. Create one if not
        present.
        )r   r   get_or_add_hlinkHoverrS   r@   s    r   r|   zHyperlink._get_or_add_hlink   s1     ;;==6688}}2244r   c                 r    | j                   r| j                  j                  S | j                  j                  S r]   r^   r@   s    r   r'   zHyperlink._hlink   ra   r   c                     | j                   }|y|j                  }|r| j                  j                  |       | j                  j                  |       y)z}
        Remove the a:hlinkClick or a:hlinkHover element, including dropping
        any relationship it might have.
        NrX   r[   s      r   r{   zHyperlink._remove_hlink   sE    
 =iiIIs#U#r   rk   )rl   rm   rn   ro   r   rp   rx   rq   r|   r'   r{   rr   rs   s   @r   r>   r>      sW     ) ), ^^ 5 ( ($r   r>   N)ro   pptx.enum.actionr   pptx.opc.constantsr   rU   pptx.shapesr   	pptx.utilr   r   r>    r   r   <module>r      s6    K & 6   "`GH `GFL$ L$r   