
    h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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                       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.FxPr5CT_NonVisualDrawingProps | CT_TextCharacterPropertiesparentr   hoverboolc                t    t          t          |                               |           || _        || _        d S N)superr   __init___element_hoverselfr   r   r   	__class__s       c/var/www/development/aibuddy-work/election-extract/venv/lib/python3.11/site-packages/pptx/action.pyr   zActionSetting.__init__   s5     	mT""++F333    c           	        | j         }|t          j        S |j        }|dk    rX|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.
        N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   hlinkr5   relative_targets       r!   actionzActionSetting.action'   s     =>!'/))#1&9O'3&1#,#>&1!*!9$-    %%1"",#4%( ,	
 	
 #k9>
*
*		+r"   return	Hyperlinkc                B    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.
        )rJ   r   _parentr   r   s    r!   	hyperlinkzActionSetting.hyperlinkO   s     dkBBBr"   Slide | Nonec                   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    r>| 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    rD| j        J | 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   r7   r8   r:   r;   r>   rH   _slides_slide_indexlen
ValueErrorr3   rIdr   partrelated_partslide)r   slide_jump_actionsnext_slide_idxprev_slide_idxrW   
slide_parts         r!   target_slidezActionSetting.target_slideX   s`   , !  $!
 ;0004;)///<?"[I000<##[I000!.2NT\!2!222 111<//[I444!.2N!! !4555<//[I111;***+/Ck49+A+A#+F+FGGJ##	 21r"   rZ   c                    |                                   |d S | j                                        }d|_        | j                            |j        t          j                  |_        d S )Nzppaction://hlinksldjump)	_clear_click_actionr   get_or_add_hlinkClickrH   rX   	relate_toRTSLIDErW   )r   rZ   rF   s      r!   r_   zActionSetting.target_slide   sY      """=F33550I''
BH==			r"   c                    | j         }|dS |j        }|r| j                            |           | j                            |           dS )z!Remove any existing click action.Nr3   rW   rX   drop_relr   remover   rF   rW   s      r!   ra   z!ActionSetting._clear_click_action   sT    =Fi 	$Is###U#####r"   CT_Hyperlink | Nonec                x    | 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
hlinkClickrM   s    r!   r3   zActionSetting._hlink   s=     ; 	,dm-EFFFFF=++}''r"   c                    | j         j        S )zW
        Reference to the slide containing the shape having this click action.
        )rX   rZ   rM   s    r!   _slidezActionSetting._slide   s    
 yr"   c                @    | j                             | j                  S )zv
        Position in the slide collection of the slide containing the shape
        having this click action.
        )rS   indexrq   rM   s    r!   rT   zActionSetting._slide_index   s     |!!$+...r"   r   c                8    | j         j        j        j        j        S )zJ
        Reference to the slide collection for this presentation.
        )rX   packagepresentation_partpresentationslidesrM   s    r!   rS   zActionSetting._slides   s    
 y 2?FFr"   Fr   r   r   r   r   r   )rI   rJ   )rI   rO   )rZ   rO   rI   rk   )rI   r   )__name__
__module____qualname____doc__r   propertyrH   r	   rN   r_   setterra   r3   rq   rT   rS   __classcell__r    s   @r!   r   r      s_       KK 	
 
 
 
 
 
 
 %+ %+ X%+N C C C \C 1$ 1$ 1$ X1$f > > > >$ $ $ ( ( ( X(   \ / / \/ G G G \G G G 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 )rJ   z5Represents a hyperlink action on a shape or text run.Fr   r   r   r   r   r   c                t    t          t          |                               |           || _        || _        d S r   )r   rJ   r   r   r   r   s       r!   r   zHyperlink.__init__   s5     	i''///r"   rI   
str | Nonec                b    | j         }|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)r3   rW   rX   
target_refrj   s      r!   addresszHyperlink.address   sC      =4 i 	4y##C(((r"   urlc                    |                                   |rD| j                            |t          j        d          }|                                 }||_        d S d S )NT)is_external)_remove_hlinkrX   rc   rd   r=   _get_or_add_hlinkrW   )r   r   rW   rF   s       r!   r   zHyperlink.address   sb     	 	)%%c2<T%JJC**,,EEIII	 	r"   r
   c                    | 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_hlinkHoverrb   rM   s    r!   r   zHyperlink._get_or_add_hlink   sB    
 ; 	[2DMBBXXZZZ}22444r"   rk   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   rn   ro   rM   s    r!   r3   zHyperlink._hlink   s0     ; 	N2DMBBMM}''r"   c                    | j         }|dS |j        }|r| j                            |           | j                            |           dS )zmRemove the a:hlinkClick or a:hlinkHover element.

        Also drops any relationship it might have.
        Nrg   rj   s      r!   r   zHyperlink._remove_hlink  sV    
 =Fi 	$Is###U#####r"   ry   rz   )rI   r   )r   r   )rI   r
   r{   )r|   r}   r~   r   r   r   r   r   r   r3   r   r   r   s   @r!   rJ   rJ      s        ?? 	
 
 
 
 
 
 
 ) ) ) X)* ^   ^5 5 5 5 ( ( ( X($ $ $ $ $ $ $r"   rJ   N)r   
__future__r   typingr   r   pptx.enum.actionr   pptx.opc.constantsr   rd   pptx.shapesr   	pptx.utilr	   pptx.oxml.actionr
   pptx.oxml.shapes.sharedr   pptx.oxml.textr   pptx.parts.slider   pptx.shapes.baser   
pptx.slider   r   r   rJ    r"   r!   <module>r      sp   J J " " " " " " & & & & & & & & & & & & & & 6 6 6 6 6 6             " " " " " " )------@@@@@@999999************((((((((iG iG iG iG iGH iG iG iGXM$ M$ M$ M$ M$ M$ M$ M$ M$ M$r"   