
    ~Zi5                        S r SSKJr  SSKJr  SSKJrJr  SSKJ	r	  SSK
Jr  SSKJr  SSKJrJr  SS	KJr  SS
KJr  SSKJr  SSKJr  \(       a  SSKJrJrJr  SSKJr  SSKJr   " S S5      r  " S S5      r! " S S5      r" " S S\5      r#g)z7Autoshape-related objects such as Shape and Adjustment.    )annotations)Number)TYPE_CHECKINGIterable)saxutils)
FillFormat
LineFormat)MSO_AUTO_SHAPE_TYPEMSO_SHAPE_TYPE)	BaseShapeautoshape_types)	TextFrame)lazyproperty)CT_GeomGuideCT_PresetGeometry2DCT_Shape)AdjustmentValue)ProvidesPartc                     ^  \ rS rSrSrS
SU 4S jjjr\SS j5       r\R                  SS j5       r\	SS j5       r
\	SS j5       r\SS j5       rS	rU =r$ )
Adjustment   a  An adjustment value for an autoshape.

An adjustment value corresponds to the position of an adjustment handle on an auto shape.
Adjustment handles are the small yellow diamond-shaped handles that appear on certain auto
shapes and allow the outline of the shape to be adjusted. For example, a rounded rectangle has
an adjustment handle that allows the radius of its corner rounding to be adjusted.

Values are |float| and generally range from 0.0 to 1.0, although the value can be negative or
greater than 1.0 in certain circumstances.
c                N   > [         [        U ]  5         Xl        X l        X0l        g N)superr   __init__namedef_valactual)selfr   r   r    	__class__s       o/var/www/eduai.edurigo.com/question_generate/ques_gen_env/lib/python3.13/site-packages/pptx/shapes/autoshape.pyr   Adjustment.__init__#   s    j$(*	    c                n    U R                   b  U R                   OU R                  nU R                  U5      $ )a  Read/write |float| representing normalized adjustment value for this adjustment.

Actual values are a large-ish integer expressed in shape coordinates, nominally between 0
and 100,000. The effective value is normalized to a corresponding value nominally between
0.0 and 1.0. Intuitively this represents the proportion of the width or height of the shape
at which the adjustment value is located from its starting point. For simple shapes such as
a rounded rectangle, this intuitive correspondence holds. For more complicated shapes and
at more extreme shape proportions (e.g. width is much greater than height), the value can
become negative or greater than 1.0.
)r    r   
_normalize)r!   	raw_values     r#   effective_valueAdjustment.effective_value)   s+     $(;;#:DKK	y))r%   c                    [        U[        5      (       d  [        S[        U5       35      eU R	                  U5      U l        g )Nz&adjustment value must be numeric, got )
isinstancer   
ValueErrorrepr_denormalizer    )r!   values     r#   r)   r*   8   s8    %((Ed5k]STT''.r%   c                    [        U S-  5      $ )zReturn integer corresponding to normalized `raw_value` on unit basis of 100,000.

See Adjustment.normalize for additional details.
     j@)int)r0   s    r#   r/   Adjustment._denormalize>   s     58#$$r%   c                    U S-  $ )a  Return normalized value for `raw_value`.

A normalized value is a |float| between 0.0 and 1.0 for nominal raw values between 0 and
100,000. Raw values less than 0 and greater than 100,000 are valid and return values
calculated on the same unit basis of 100,000.
r2    )r(   s    r#   r'   Adjustment._normalizeF   s     8##r%   c                L    U R                   b  U R                   $ U R                  $ )zfDenormalized effective value.

Expressed in shape coordinates, this is suitable for using in the XML.
)r    r   r!   s    r#   valAdjustment.valP   s      #kk5t{{G4<<Gr%   )r    r   r   r   )r   strr   r3   r    z
int | None)returnfloat)r0   r>   )r0   r>   r=   r3   )r(   r3   r=   r>   )r=   r3   )__name__
__module____qualname____firstlineno____doc__r   propertyr)   setterstaticmethodr/   r'   r:   __static_attributes____classcell__r"   s   @r#   r   r      s~    	  * * / /
 % % $ $ H Hr%   r   c                     ^  \ rS rSrSrSU 4S jjrSS jrSS jrSS jrS r	\
    SS j5       r\SS	 j5       rS
 rSrU =r$ )AdjustmentCollectionY   zSequence of |Adjustment| instances for an auto shape.

Each represents an available adjustment for a shape of its type. Supports `len()` and indexed
access, e.g. `shape.adjustments[1] = 0.15`.
c                b   > [         [        U ]  5         U R                  U5      U l        Xl        g r   )r   rK   r   _initialized_adjustments_adjustments_	_prstGeom)r!   prstGeomr"   s     r#   r   AdjustmentCollection.__init__`   s)    "D24!::8D!r%   c                4    U R                   U   R                  $ )z1Provides indexed access, (e.g. 'adjustments[9]').)rO   r)   )r!   idxs     r#   __getitem__ AdjustmentCollection.__getitem__e   s    !!#&666r%   c                J    X R                   U   l        U R                  5         g)zProvides item assignment via an indexed expression, e.g. `adjustments[9] = 999.9`.

Causes all adjustment values in collection to be written to the XML.
N)rO   r)   _rewrite_guides)r!   rT   r0   s      r#   __setitem__ AdjustmentCollection.__setitem__i   s!    
 383/r%   c                    Uc  / $ [         R                  UR                  5      nU VVs/ s H  u  p4[        X45      PM     nnnU R	                  XQR
                  5        U$ s  snnf )zTReturn an initialized list of adjustment values based on the contents of `prstGeom`.)AutoShapeTypedefault_adjustment_valuesprstr    _update_adjustments_with_actualsgd_lst)r!   rQ   davsr   r   adjustmentss         r#   rN   -AdjustmentCollection._initialized_adjustmentsq   sZ    I66x}}EFJKd]Tz$0dK--k??K Ls   A!c                    U R                    Vs/ s H  oR                  UR                  4PM     nnU R                  R	                  U5        gs  snf )zoWrite `a:gd` elements to the XML, one for each adjustment value.

Any existing guide elements are overwritten.
N)rO   r   r:   rP   rewrite_guides)r!   adjguidess      r#   rX   $AdjustmentCollection._rewrite_guidesz   sC    
 261C1CD1C#88SWW%1CD%%f- Es   !Ac                    [        S U  5       5      nU H2  nUR                  n[        UR                  SS 5      n X$   nXVl        M4     g! [         a     MD  f = f)zUpdate |Adjustment| instances in `adjustments` with actual values held in `guides`.

`guides` is a list of `a:gd` elements. Guides with a name that does not match an adjustment
object are skipped.
c              3  <   #    U  H  oR                   U4v   M     g 7fr   )r   ).0rf   s     r#   	<genexpr>HAdjustmentCollection._update_adjustments_with_actuals.<locals>.<genexpr>   s     "JksHHc?ks      N)dictr   r3   fmlaKeyErrorr    )rb   rg   adjustments_by_namegdr   r    
adjustments          r#   r_   5AdjustmentCollection._update_adjustments_with_actuals   sj     #"Jk"JJB77D%F06
 !'  	  s   A
AAc                ,    [        U R                  5      $ )z9Sequence of |Adjustment| objects contained in collection.)tuplerO   r9   s    r#   _adjustments!AdjustmentCollection._adjustments   s     T''((r%   c                ,    [        U R                  5      $ )z!Implement built-in function len())lenrO   r9   s    r#   __len__AdjustmentCollection.__len__   s    4%%&&r%   )rO   rP   )rQ   r   )rT   r3   r=   r>   )rT   r3   r0   r>   )rQ   zCT_PresetGeometry2D | Noner=   zlist[Adjustment])rb   zIterable[Adjustment]rg   zIterable[CT_GeomGuide])r=   ztuple[Adjustment, ...])r?   r@   rA   rB   rC   r   rU   rY   rN   rX   rF   r_   rD   rx   r|   rG   rH   rI   s   @r#   rK   rK   Y   sc    "
7. )3I & ) )' 'r%   rK   c                     ^  \ rS rSr% Sr0 rS\S'   SU 4S jjrSS jr\	SS j5       r
\	SS j5       r\SS	 j5       r\SS
 j5       r\	S 5       rSrU =r$ )r\      a  Provides access to metadata for an auto-shape of type identified by `autoshape_type_id`.

Instances are cached, so no more than one instance for a particular auto shape type is in
memory.

Instances provide the following attributes:

.. attribute:: autoshape_type_id

   Integer uniquely identifying this auto shape type. Corresponds to a
   value in `pptx.constants.MSO` like `MSO_SHAPE.ROUNDED_RECTANGLE`.

.. attribute:: basename

   Base part of shape name for auto shapes of this type, e.g. `Rounded
   Rectangle` becomes `Rounded Rectangle 99` when the distinguishing
   integer is added to the shape name.

.. attribute:: prst

   String identifier for this auto shape type used in the `a:prstGeom`
   element.

z(dict[MSO_AUTO_SHAPE_TYPE, AutoShapeType]
_instancesc                   > XR                   ;  a!  [        [        U ]  U 5      nX R                   U'   U R                   U   $ )z[Only create new instance on first call for content_type.

After that, use cached instance.
)r   r   r\   __new__)clsautoshape_type_idinstr"   s      r#   r   AutoShapeType.__new__   s=     NN24S9D04NN,-~~/00r%   c                    [        U S5      (       a  gU[        ;  a  [        SU-  5      e[        U   nXl        US   U l        SU l        g)z:Initialize attributes from constant values in `pptx.spec`._loadedNz;no autoshape type with id '%s' in pptx.spec.autoshape_typesbasenameT)hasattrr   rq   _autoshape_type_id	_basenamer   )r!   r   autoshape_types      r#   r   AutoShapeType.__init__   sX     4##O3MPaa  )):;"3'
3r%   c                    U R                   $ )zHMSO_AUTO_SHAPE_TYPE enumeration member identifying this auto shape type.)r   r9   s    r#   r   AutoShapeType.autoshape_type_id   s     &&&r%   c                H    [         R                  " U R                  SS05      $ )aO  Base of shape name for this auto shape type.

A shape name is like "Rounded Rectangle 7" and appears as an XML attribute for example at
`p:sp/p:nvSpPr/p:cNvPr{name}`. This basename value is the name less the distinguishing
integer. This value is escaped because at least one autoshape-type name includes double
quotes ('"No" Symbol').
"z&quot;)r   escaper   r9   s    r#   r   AutoShapeType.basename   s     t~~X??r%   c                    [         U   S   $ )zSSequence of (name, value) pair adjustment value defaults for `prst` autoshape-type.avLstr   r   r^   s     r#   r]   'AutoShapeType.default_adjustment_values   s     t$W--r%   c                .    [         R                  " U5      $ )z|Select auto shape type with matching `prst`.

e.g. `MSO_SHAPE.RECTANGLE` corresponding to preset geometry keyword `"rect"`.
)r   from_xmlr   s     r#   id_from_prstAutoShapeType.id_from_prst   s     #++D11r%   c                B    [         R                  " U R                  5      $ )z
Preset geometry identifier string for this auto shape. Used in the
`prst` attribute of `a:prstGeom` element to specify the geometry
to be used in rendering the shape, for example `'roundRect'`.
)r   to_xmlr   r9   s    r#   r^   AutoShapeType.prst   s     #))$*A*ABBr%   )r   r   r   )r   r   r=   r\   )r   r   )r=   r   r=   r<   )r^   r   r=   ztuple[AdjustmentValue, ...])r^   r<   r=   r   )r?   r@   rA   rB   rC   r   __annotations__r   r   rD   r   r   classmethodr]   r   r^   rG   rH   rI   s   @r#   r\   r\      s    2 <>J8=
1  ' ' @ @ . . 2 2 C Cr%   r\   c                     ^  \ rS rSrSrSU 4S jjr\SS j5       r\S 5       r	\S 5       r
S r\SS j5       r\S	 5       r\S
 5       r\SS j5       r\SS j5       r\R"                  SS j5       r\S 5       rSrU =r$ )Shape   zA shape that can appear on a slide.

Corresponds to the `p:sp` element that can appear in any of the slide-type parts
(slide, slideLayout, slideMaster, notesPage, notesMaster, handoutMaster).
c                8   > [         [        U ]  X5        Xl        g r   )r   r   r   _sp)r!   spparentr"   s      r#   r   Shape.__init__  s    eT#B/r%   c                @    [        U R                  R                  5      $ )zFRead-only reference to |AdjustmentCollection| instance for this shape.)rK   r   rQ   r9   s    r#   rb   Shape.adjustments
  s     $DHH$5$566r%   c                z    U R                   R                  (       d  [        S5      eU R                   R                  $ )zEnumeration value identifying the type of this auto shape.

Like `MSO_SHAPE.ROUNDED_RECTANGLE`. Raises |ValueError| if this shape is not an auto shape.
zshape is not an auto shape)r   is_autoshaper-   r^   r9   s    r#   auto_shape_typeShape.auto_shape_type  s+     xx$$9::xx}}r%   c                V    [         R                  " U R                  R                  5      $ )z^|FillFormat| instance for this shape.

Provides access to fill properties such as fill color.
)r   from_fill_parentr   spPrr9   s    r#   fill
Shape.fill  s     **488==99r%   c                6    U R                   R                  5       $ )zSReturn the `a:ln` element containing the line format properties XML for this shape.)r   get_or_add_lnr9   s    r#   r   Shape.get_or_add_ln!  s    xx%%''r%   c                    g)zF|True| if this shape can contain text. Always |True| for an AutoShape.Tr6   r9   s    r#   has_text_frameShape.has_text_frame%  s     r%   c                    [        U 5      $ )z^|LineFormat| instance for this shape.

Provides access to line properties such as line color.
r	   r9   s    r#   line
Shape.line*  s     $r%   c                .    U R                   R                  $ )zThe `a:ln` element containing the line format properties such as line color and width.

|None| if no `a:ln` element is present.
)r   lnr9   s    r#   r   Shape.ln2  s     xx{{r%   c                \   U R                   (       a  [        R                  $ U R                  R                  (       a  [        R
                  $ U R                  R                  (       a  [        R                  $ U R                  R                  (       a  [        R                  $ [        S5      e)zRUnique integer identifying the type of this shape, like `MSO_SHAPE_TYPE.TEXT_BOX`.z)Shape instance of unrecognized shape type)is_placeholderr   PLACEHOLDERr   has_custom_geometryFREEFORMr   
AUTO_SHAPE
is_textboxTEXT_BOXNotImplementedErrorr9   s    r#   
shape_typeShape.shape_type:  sp     !---88''!***88  !,,,88!***!"MNNr%   c                .    U R                   R                  $ )a  Read/write. Text in shape as a single string.

The returned string will contain a newline character (`"\n"`) separating each paragraph
and a vertical-tab (`"\v"`) character for each line break (soft carriage return) in the
shape's text.

Assignment to `text` replaces any text previously contained in the shape, along with any
paragraph or font formatting applied to it. A newline character (`"\n"`) in the assigned
text causes a new paragraph to be started. A vertical-tab (`"\v"`) character in the
assigned text causes a line-break (soft carriage-return) to be inserted. (The vertical-tab
character appears in clipboard text copied from PowerPoint as its str encoding of
line-breaks.)

text_frametextr9   s    r#   r   
Shape.textG  s     ###r%   c                $    XR                   l        g r   r   )r!   r   s     r#   r   r   X  s    #r%   c                L    U R                   R                  5       n[        X5      $ )zx|TextFrame| instance for this shape.

Contains the text of the shape and provides access to text formatting properties.
)r   get_or_add_txBodyr   )r!   txBodys     r#   r   Shape.text_frame\  s!     ++-&&r%   )r   )r   r   r   r   )r=   rK   )r=   bool)r=   r   r   )r   r<   )r?   r@   rA   rB   rC   r   r   rb   rD   r   r   r   r   r   r   r   r   rE   r   rG   rH   rI   s   @r#   r   r      s     7 7   : :(         
O 
O $ $  
[[$ $ ' 'r%   r   N)$rC   
__future__r   numbersr   typingr   r   xml.saxr   pptx.dml.fillr   pptx.dml.liner
   pptx.enum.shapesr   r   pptx.shapes.baser   	pptx.specr   pptx.text.textr   	pptx.utilr   pptx.oxml.shapes.autoshaper   r   r   r   
pptx.typesr   r   rK   r\   r   r6   r%   r#   <module>r      so    = "  *  $ $ @ & % $ "VV)'?H ?HDD' D'N\C \C~d'I d'r%   