
    li%                        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r&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  G d de      Z G d de      Zy)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                       e Zd ZdZ	 d	 	 	 	 	 d fdZed        Zedd       Zedd       Z	e	j                  dd       Z	d Zedd       Zed	        Zed
        Zed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       I/var/www/html/eduruby.in/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   hlinkr3   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.hyperlinkO   s     dkkBBr    c                   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(  rU| j                  J | j                  j                  }t        d| 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 slider   )r   r5   r6   r8   r9   r<   rF   _slides_slide_indexlen
ValueErrorr1   rIdr   partrelated_partslide)r   slide_jump_actionsnext_slide_idxprev_slide_idxrS   
slide_parts         r   target_slidezActionSetting.target_slideX   sy   , !!    $$!!
 ;;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k499+A+A#+FGJ###	 2r    c                    | j                          |y | j                  j                         }d|_        | j                  j                  |j                  t        j                        |_        y )Nzppaction://hlinksldjump)	_clear_click_actionr   get_or_add_hlinkClickrF   rT   	relate_toRTSLIDErS   )r   rV   rD   s      r   r[   zActionSetting.target_slide   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r1   rS   rT   drop_relr   remover   rD   rS   s      r   r]   z!ActionSetting._clear_click_action   sC    =iiIIs#U#r    c                    | j                   r2t        | 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
hlinkClickrJ   s    r   r1   zActionSetting._hlink   s@     ;;dmm-EFFF==+++}}'''r    c                .    | j                   j                  S )zW
        Reference to the slide containing the shape having this click action.
        )rT   rV   rJ   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.
        )rO   indexrl   rJ   s    r   rP   zActionSetting._slide_index   s     ||!!$++..r    c                j    | j                   j                  j                  j                  j                  S )zJ
        Reference to the slide collection for this presentation.
        )rT   packagepresentation_partpresentationslidesrJ   s    r   rO   zActionSetting._slides   s&    
 yy  22??FFFr    Fr   z5CT_NonVisualDrawingProps | CT_TextCharacterPropertiesr   r   r   bool)returnrH   )rw   Slide | None)rV   rx   rw   zCT_Hyperlink | None)rw   r   )__name__
__module____qualname____doc__r   propertyrF   r	   rK   r[   setterr]   r1   rl   rP   rO   __classcell__r   s   @r   r   r      s    K 	
B
 
 	
 %+ %+N C C 1$ 1$f > >$ ( (   / / G Gr    r   c                       e Zd ZdZ	 d	 	 	 	 	 d	 fdZed
d       Zej                  dd       ZddZedd       Z	d Z
 xZS )rH   z5Represents a hyperlink action on a shape or text run.c                H    t         t        |   |       || _        || _        y r   )r   rH   r   r   r   r   s       r   r   zHyperlink.__init__   s"     	i'/r    c                t    | j                   }|y|j                  }|sy| j                  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)r1   rS   rT   
target_refrf   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_hlinkrT   r_   r`   r;   _get_or_add_hlinkrS   )r   urlrS   rD   s       r   r   zHyperlink.address   sL     	))%%c2<<T%JC**,EEI r    c                    | j                   r$t        d| j                        j                         S | j                  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_hlinkHoverr^   rJ   s    r   r   zHyperlink._get_or_add_hlink   s9    
 ;;2DMMBXXZZ}}2244r    c                    | 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   ri   rj   rJ   s    r   r1   zHyperlink._hlink   s3     ;;2DMMBMMM}}'''r    c                    | j                   }|y|j                  }|r| j                  j                  |       | j                  j                  |       y)zmRemove the a:hlinkClick or a:hlinkHover element.

        Also drops any relationship it might have.
        Nrc   rf   s      r   r   zHyperlink._remove_hlink  sE    
 =iiIIs#U#r    rt   ru   )rw   
str | None)r   r   )rw   r
   ry   )rz   r{   r|   r}   r   r~   r   r   r   r1   r   r   r   s   @r   rH   rH      sv    ? 	
B
 
 	
 ) )* ^^ 5 ( ($r    rH   N)r}   
__future__r   typingr   r   pptx.enum.actionr   pptx.opc.constantsr   r`   pptx.shapesr   	pptx.utilr	   pptx.oxml.actionr
   pptx.oxml.shapes.sharedr   pptx.oxml.textr   pptx.parts.slider   pptx.shapes.baser   
pptx.slider   r   r   rH    r    r   <module>r      sN    J " & & 6   "-@9**(iGH iGXM$ M$r    