
    ,h                        d Z ddlmZ ddlmZmZmZ ddlmZ ddl	m
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 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"  G d de      Z#y)z+|DocumentPart| and closely related objects.    )annotations)IOTYPE_CHECKINGcast)Document)WD_STYLE_TYPE)RELATIONSHIP_TYPE)
FooterPart
HeaderPart)NumberingPart)SettingsPart)	StoryPart)
StylesPart)InlineShapes)lazyproperty)CoreProperties)Settings)	BaseStylec                      e Zd ZdZd Zd Zedd       Zed        ZddZ	ddZ
ddZd	 Zdd
Zed        Zed        ZddZedd       Zed        Zedd       Zedd       Zy)DocumentParta  Main document part of a WordprocessingML (WML) package, aka a .docx file.

    Acts as broker to other parts such as image, core properties, and style parts. It
    also acts as a convenient delegate when a mid-document object needs a service
    involving a remote ancestor. The `Parented.part` property inherited by many content
    objects provides access to this part object for that purpose.
    c                    t        j                  | j                        }| j                  |t        j
                        }||fS )z=Return (footer_part, rId) pair for newly-created footer part.)r
   newpackage	relate_toRTFOOTER)selffooter_partrIds      U/var/www/html/Resume-Scraper/venv/lib/python3.12/site-packages/docx/parts/document.pyadd_footer_partzDocumentPart.add_footer_part!   3     nnT\\2nn["))4C    c                    t        j                  | j                        }| j                  |t        j
                        }||fS )z=Return (header_part, rId) pair for newly-created header part.)r   r   r   r   r   HEADER)r   header_partr   s      r    add_header_partzDocumentPart.add_header_part'   r"   r#   c                .    | j                   j                  S )zfA |CoreProperties| object providing read/write access to the core properties
        of this document.)r   core_propertiesr   s    r    r)   zDocumentPart.core_properties-   s     ||+++r#   c                .    t        | j                  |       S )zEA |Document| object providing access to the content of this document.)r   _elementr*   s    r    documentzDocumentPart.document3   s     t,,r#   c                &    | j                  |       y)z/Remove related header part identified by `rId`.N)drop_relr   r   s     r    drop_header_partzDocumentPart.drop_header_part8   s    cr#   c                     | j                   |   S )z%Return |FooterPart| related by `rId`.related_partsr0   s     r    r   zDocumentPart.footer_part<       !!#&&r#   c                :    | j                   j                  ||      S )zReturn 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`.
        )styles	get_by_id)r   style_id
style_types      r    	get_stylezDocumentPart.get_style@   s     {{$$Xz::r#   c                :    | j                   j                  ||      S )aT  Return the style_id (|str|) of the style of `style_type` matching
        `style_or_name`.

        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.
        )r7   get_style_id)r   style_or_namer:   s      r    r=   zDocumentPart.get_style_idH   s     {{''zBBr#   c                     | j                   |   S )z%Return |HeaderPart| related by `rId`.r3   r0   s     r    r&   zDocumentPart.header_partR   r5   r#   c                B    t        | j                  j                  |       S )zIThe |InlineShapes| instance containing the inline shapes in the document.)r   r,   bodyr*   s    r    inline_shapeszDocumentPart.inline_shapesV   s     DMM..55r#   c                    	 | j                  t        j                        S # t        $ r9 t	        j
                         }| j                  |t        j                         |cY S w xY w)zA |NumberingPart| object providing access to the numbering definitions for
        this document.

        Creates an empty numbering part if one is not present.
        )part_related_byr   	NUMBERINGKeyErrorr   r   r   )r   numbering_parts     r    rG   zDocumentPart.numbering_part[   sQ    	"''55 	"*..0NNN>2<<8!!	"s   ! ?A#"A#c                :    | j                   j                  |       y)zSave this document to `path_or_stream`, which can be either a path to a
        filesystem location (a string) or a file-like object.N)r   save)r   path_or_streams     r    rI   zDocumentPart.savei   s     	.)r#   c                .    | j                   j                  S )zcA |Settings| object providing access to the settings in the settings part of
        this document.)_settings_partsettingsr*   s    r    rM   zDocumentPart.settingsn   s     ""+++r#   c                .    | j                   j                  S )z]A |Styles| object providing access to the styles in the styles part of this
        document.)_styles_partr7   r*   s    r    r7   zDocumentPart.stylest   s       '''r#   c                    	 t        t        | j                  t        j                              S # t
        $ rD t        j                  | j                        }| j                  |t        j                         |cY S w xY w)zA |SettingsPart| object providing access to the document-level settings for
        this document.

        Creates a default settings part if one is not present.
        )	r   r   rD   r   SETTINGSrF   defaultr   r   )r   settings_parts     r    rL   zDocumentPart._settings_partz   s^    	!d&:&:2;;&GHH 	!(00>MNN="++6  	!s   ,/ A
A<;A<c                
   	 t        t        | j                  t        j                              S # t
        $ rJ | j                  }|J t        j                  |      }| j                  |t        j                         |cY S w xY w)zqInstance of |StylesPart| for this document.

        Creates an empty styles part if one is not present.
        )	r   r   rD   r   STYLESrF   r   rR   r   )r   r   styles_parts      r    rO   zDocumentPart._styles_part   sl    	
D$8$8$CDD 	llG&&$,,W5KNN;		2	s   ,/ ABBN)returnr   )r   strrW   None)r   rX   )r9   z
str | Noner:   r   rW   r   )rJ   zstr | IO[bytes])rW   r   )rW   r   )rW   r   )__name__
__module____qualname____doc__r!   r'   propertyr)   r-   r1   r   r;   r=   r&   r   rB   rG   rI   rM   r7   rL   rO    r#   r    r   r      s       , ,
 - -';C' 6 6 " "*
 , ,
 ( (
 ! !  r#   r   N)$r]   
__future__r   typingr   r   r   docx.documentr   docx.enum.styler   docx.opc.constantsr	   r   docx.parts.hdrftrr
   r   docx.parts.numberingr   docx.parts.settingsr   docx.parts.storyr   docx.parts.stylesr   
docx.shaper   docx.sharedr   docx.opc.corepropsr   docx.settingsr   docx.styles.styler   r   r_   r#   r    <module>ro      sI    1 " * * " ) 6 4 . , & ( # $1&+}9 }r#   