HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //home/arjun/projects/env/lib/python3.10/site-packages/docx/parts/__pycache__/story.cpython-310.pyc
o

$we��@s�dZddlmZddlmZmZmZddlmZ	ddl
mZddlm
Z
ddlmZmZerFddlmZdd	lmZdd
lmZddlmZGdd
�d
e�ZdS)z |StoryPart| and related objects.�)�annotations)�IO�
TYPE_CHECKING�Tuple)�RELATIONSHIP_TYPE)�XmlPart)�	CT_Inline)�Length�lazyproperty)�
WD_STYLE_TYPE)�Image)�DocumentPart)�	BaseStylec@sZeZdZdZd dd�Zd!d
d�Zd"dd�Z		d#d$dd�Zed%dd��Z	e
d&dd��ZdS)'�	StoryPartz�Base class for story parts.

    A story part is one that can contain textual content, such as the document-part and
    header or footer parts. These all share content behaviors like `.paragraphs`,
    `.add_paragraph()`, `.add_table()` etc.
    �image_descriptor�str | IO[bytes]�return�Tuple[str, Image]cCs4|j}|dus	J�|�|�}|�|tj�}||jfS)a|Return (rId, image) pair for image identified by `image_descriptor`.

        `rId` is the str key (often like "rId7") for the relationship between this story
        part and the image part, reused if already present, newly created if not.
        `image` is an |Image| instance providing access to the properties of the image,
        such as dimensions and image type.
        N)�_package�get_or_add_image_part�	relate_to�RT�IMAGE�image)�selfr�package�
image_part�rId�r�I/home/arjun/projects/env/lib/python3.10/site-packages/docx/parts/story.py�get_or_add_images


zStoryPart.get_or_add_image�style_id�
str | None�
style_typerrcC�|j�||�S)z�Return the style in this document matching `style_id`.

        Returns the default style for `style_type` if `style_id` is |None| or does not
        match a defined style of `style_type`.
        )�_document_part�	get_style)rr!r#rrrr&)szStoryPart.get_style�
style_or_name�BaseStyle | str | NonecCr$)a2Return str style_id for `style_or_name` of `style_type`.

        Returns |None| if the style resolves to the default style for `style_type` or if
        `style_or_name` is itself |None|. Raises if `style_or_name` is a style of the
        wrong type or names a style not present in the document.
        )r%�get_style_id)rr'r#rrrr)1s	zStoryPart.get_style_idN�width�
Length | None�heightrc
Cs>|�|�\}}|�||�\}}|j|j}}	t�|||	||�S)z�Return a newly-created `w:inline` element.

        The element contains the image specified by `image_descriptor` and is scaled
        based on the values of `width` and `height`.
        )r �scaled_dimensions�next_id�filenamer�new_pic_inline)
rrr*r,rr�cx�cy�shape_idr/rrrr0<szStoryPart.new_pic_inline�intcCs.|j�d�}dd�|D�}|sdSt|�dS)aBNext available positive integer id value in this story XML document.

        The value is determined by incrementing the maximum existing id value. Gaps in
        the existing id sequence are not filled. The id attribute value is unique in the
        document, without regard to the element type it appears on.
        z//@idcSsg|]
}|��rt|��qSr)�isdigitr4)�.0�id_strrrr�
<listcomp>Usz%StoryPart.next_id.<locals>.<listcomp>�)�_element�xpath�max)r�
id_str_lst�used_idsrrrr.Ls
zStoryPart.next_idr
cCs|j}|dus	J�|jS)z'|DocumentPart| object for this package.N)r�main_document_part)rrrrrr%ZszStoryPart._document_part)rrrr)r!r"r#rrr)r'r(r#rrr")NN)rrr*r+r,r+rr)rr4)rr
)�__name__�
__module__�__qualname__�__doc__r r&r)r0�propertyr.r
r%rrrrrs


�
rN)rC�
__future__r�typingrrr�docx.opc.constantsrr�
docx.opc.partr�docx.oxml.shaper�docx.sharedr	r
�docx.enum.styler�docx.image.imager�docx.parts.documentr
�docx.styles.stylerrrrrr�<module>s