o
    7 h%                     @  s   d 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 erPd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 G dd deZG dd deZdS )zDObjects related to mouse click and hover actions on a shape or text.    )annotations)TYPE_CHECKINGcast)	PP_ACTION)RELATIONSHIP_TYPE)Subshape)lazyproperty)CT_Hyperlink)CT_NonVisualDrawingProps)CT_TextCharacterProperties)	SlidePart)	BaseShape)SlideSlidesc                      s   e Zd ZdZ	d"d# fd	d
Zedd Zed$ddZed%ddZ	e	j
d&ddZ	dd Zed'ddZedd Zedd Zed(d d!Z  ZS ))ActionSettingzAProperties specifying how a shape or run reacts to mouse actions.FxPr5CT_NonVisualDrawingProps | CT_TextCharacterPropertiesparentr   hoverboolc                       t t| | || _|| _d S N)superr   __init___element_hoverselfr   r   r   	__class__ S/var/www/html/figdemos/bartoux_crm/venv/lib/python3.10/site-packages/pptx/action.pyr         
zActionSetting.__init__c              	   C  s~   | j }|du r
tjS |j}|dkr'|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|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.
        NZhlinkshowjumpZjump)Z
firstslideZ	lastslideZlastslideviewedZ	nextslideZpreviousslideZendshow)NZhlinksldjumpZ	hlinkpresZ	hlinkfileZ
customshowZolemacroprogram)_hlinkr   NONEaction_verbaction_fieldsFIRST_SLIDE
LAST_SLIDEZLAST_SLIDE_VIEWED
NEXT_SLIDEPREVIOUS_SLIDEZEND_SHOW	HYPERLINKNAMED_SLIDEZPLAYZ	OPEN_FILEZNAMED_SLIDE_SHOWZOLE_VERBZ	RUN_MACROZRUN_PROGRAMget)r   hlinkr'   Zrelative_targetr    r    r!   action'   s4   


	zActionSetting.actionreturn	Hyperlinkc                 C  s   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.
        )r3   r   _parentr   r   r    r    r!   	hyperlinkO   s   zActionSetting.hyperlinkSlide | Nonec                 C  s   t jt jt jt jt jf}| j|vrdS | jt jkr| jd S | jt jkr)| jd S | jt jkrD| jd }|t	| jkr?t
d| j| S | jt jkr\| jd }|dk rWt
d| j| S | jt jkry| jdusiJ | jj}td| j|}|jS dS )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 slider   )r   r)   r*   r+   r,   r.   r1   _slides_slide_indexlen
ValueErrorr%   rIdr   partrelated_partslide)r   Zslide_jump_actionsZnext_slide_idxZprev_slide_idxr>   
slide_partr    r    r!   target_slideX   s8   






zActionSetting.target_sliderA   c                 C  s<   |    |d u r
d S | j }d|_| j|jtj|_d S )Nzppaction://hlinksldjump)	_clear_click_actionr   get_or_add_hlinkClickr1   r?   	relate_toRTSLIDEr>   )r   rA   r0   r    r    r!   rC      s   
c                 C  8   | j }|du r	dS |j}|r| j| | j| dS )z!Remove any existing click action.Nr%   r>   r?   drop_relr   remover   r0   r>   r    r    r!   rD      s   z!ActionSetting._clear_click_actionCT_Hyperlink | Nonec                 C  s&   | j rt| jtsJ | jjS | jjS )z
        Reference to the `a:hlinkClick` or `a:hlinkHover` element for this
        click action. Returns |None| if the element is not present.
        )r   
isinstancer   r
   
hlinkHover
hlinkClickr5   r    r    r!   r%      s   zActionSetting._hlinkc                 C  s   | j jS )zW
        Reference to the slide containing the shape having this click action.
        )r?   rA   r5   r    r    r!   _slide   s   zActionSetting._slidec                 C  s   | j | jS )zv
        Position in the slide collection of the slide containing the shape
        having this click action.
        )r:   indexrR   r5   r    r    r!   r;      s   zActionSetting._slide_indexr   c                 C  s   | j jjjjS )zJ
        Reference to the slide collection for this presentation.
        )r?   packagepresentation_partpresentationslidesr5   r    r    r!   r:      s   zActionSetting._slidesFr   r   r   r   r   r   )r2   r3   )r2   r7   )rA   r7   r2   rN   )r2   r   )__name__
__module____qualname____doc__r   propertyr1   r   r6   rC   setterrD   r%   rR   r;   r:   __classcell__r    r    r   r!   r      s*    	
'3



r   c                      sd   e Zd ZdZ	dd fd	d
ZedddZejdddZdddZedddZ	dd Z
  ZS )r3   z5Represents a hyperlink action on a shape or text run.Fr   r   r   r   r   r   c                   r   r   )r   r3   r   r   r   r   r   r    r!   r      r"   zHyperlink.__init__r2   
str | Nonec                 C  s,   | j }|du r	dS |j}|sdS | j|S )an  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%   r>   r?   
target_refrM   r    r    r!   address   s   	zHyperlink.addressurlc                 C  s6   |    |r| jj|tjdd}|  }||_d S d S )NT)is_external)_remove_hlinkr?   rF   rG   r-   _get_or_add_hlinkr>   )r   re   r>   r0   r    r    r!   rd      s   
r	   c                 C  s    | j rtd| j S | j S )zGet the `a:hlinkClick` or `a:hlinkHover` element for the Hyperlink object.

        The actual element depends on the value of `self._hover`. Create the element if not present.
        r
   )r   r   r   get_or_add_hlinkHoverrE   r5   r    r    r!   rh      s   
zHyperlink._get_or_add_hlinkrN   c                 C  s   | j r
td| jjS | jjS )zReference to the `a:hlinkClick` or `h:hlinkHover` element for this click action.

        Returns |None| if the element is not present.
        r
   )r   r   r   rP   rQ   r5   r    r    r!   r%      s   zHyperlink._hlinkc                 C  rI   )zmRemove the a:hlinkClick or a:hlinkHover element.

        Also drops any relationship it might have.
        NrJ   rM   r    r    r!   rg     s   zHyperlink._remove_hlinkrX   rY   )r2   rb   )re   rb   )r2   r	   rZ   )r[   r\   r]   r^   r   r_   rd   r`   rh   r%   rg   ra   r    r    r   r!   r3      s    
			r3   N)r^   
__future__r   typingr   r   Zpptx.enum.actionr   pptx.opc.constantsr   rG   pptx.shapesr   	pptx.utilr   pptx.oxml.actionr	   pptx.oxml.shapes.sharedr
   pptx.oxml.textr   pptx.parts.slider   pptx.shapes.baser   
pptx.slider   r   r   r3   r    r    r    r!   <module>   s"     -