
    hi                       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" ddl#m$Z$ ddl%m&Z&  G d de          Z'dS )z+|DocumentPart| and closely related objects.    )annotations)IOTYPE_CHECKINGcast)Document)RELATIONSHIP_TYPE)CommentsPart)
FooterPart
HeaderPart)NumberingPart)SettingsPart)	StoryPart)
StylesPart)InlineShapes)lazyproperty)Comments)WD_STYLE_TYPE)CoreProperties)Settings)	BaseStylec                  6   e Zd ZdZd Zd Zed'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,d            Zd-dZed.d            Zed             Zed/d!            Zed0d#            Zed1d%            Zd&S )2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                  }|                     |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      k/var/www/development/aibuddy-work/election-extract/venv/lib/python3.11/site-packages/docx/parts/document.pyadd_footer_partzDocumentPart.add_footer_part#   3     nT\22nn[")44C    c                |    t          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%   returnr   c                    | j         j        S )zJ|Comments| object providing access to the comments added to this document.)_comments_partcommentsr   s    r"   r-   zDocumentPart.comments/   s     "++r%   r   c                    | j         j        S )zfA |CoreProperties| object providing read/write access to the core properties
        of this document.)r   core_propertiesr.   s    r"   r0   zDocumentPart.core_properties4   s     |++r%   c                ,    t          | j        |           S )zEA |Document| object providing access to the content of this document.)r   _elementr.   s    r"   documentzDocumentPart.document:   s     t,,,r%   r!   strNonec                0    |                      |           dS )z/Remove related header part identified by `rId`.N)drop_relr   r!   s     r"   drop_header_partzDocumentPart.drop_header_part?   s    cr%   c                    | j         |         S )z%Return |FooterPart| related by `rId`.related_partsr8   s     r"   r    zDocumentPart.footer_partC       !#&&r%   style_id
str | None
style_typer   r   c                8    | 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   r>   r@   s      r"   	get_stylezDocumentPart.get_styleG   s     {$$Xz:::r%   c                8    | 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.
        )rB   get_style_id)r   style_or_namer@   s      r"   rF   zDocumentPart.get_style_idO   s     {''zBBBr%   c                    | j         |         S )z%Return |HeaderPart| related by `rId`.r;   r8   s     r"   r(   zDocumentPart.header_partY   r=   r%   c                6    t          | j        j        |           S )zIThe |InlineShapes| instance containing the inline shapes in the document.)r   r2   bodyr.   s    r"   inline_shapeszDocumentPart.inline_shapes]   s     DM.555r%   r   c                    	 t          t          |                     t          j                            S # t
          $ r8 t          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.
        )r   r   part_related_byr   	NUMBERINGKeyErrorr   r   )r   numbering_parts     r"   rP   zDocumentPart.numbering_partb   sr    	"t';';BL'I'IJJJ 	" 	" 	"*.00NNN>2<888!!!!	"s   14 ?A65A6path_or_streamstr | IO[bytes]c                :    | j                             |           dS )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   rQ   s     r"   rT   zDocumentPart.saveo   s      	.)))))r%   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"   rW   zDocumentPart.settingst   s     "++r%   c                    | j         j        S )z]A |Styles| object providing access to the styles in the styles part of this
        document.)_styles_partrB   r.   s    r"   rB   zDocumentPart.stylesz   s      ''r%   r	   c                   	 t          t          |                     t          j                            S # t
          $ rG | j        J t          j        | j                  }|                     |t          j                   |cY S w xY w)zA |CommentsPart| object providing access to the comments added to this document.

        Creates a default comments part if one is not present.
        )	r   r	   rM   r   COMMENTSrO   r   defaultr   )r   comments_parts     r"   r,   zDocumentPart._comments_part   s    	!d&:&:2;&G&GHHH 	! 	! 	!<+++(0>>MNN="+666    		!s   14 ABBr   c                    	 t          t          |                     t          j                            S # t
          $ r> t          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   rM   r   SETTINGSrO   r\   r   r   )r   settings_parts     r"   rV   zDocumentPart._settings_part   sv    	!d&:&:2;&G&GHHH 	! 	! 	!(0>>MNN="+666    	!s   14 AA<;A<r   c                
   	 t          t          |                     t          j                            S # t
          $ rD | j        }|J t          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   rM   r   STYLESrO   r   r\   r   )r   r   styles_parts      r"   rY   zDocumentPart._styles_part   s    	
D$8$8$C$CDDD 	 	 	lG&&&$,W55KNN;	222	s   14 ABBN)r*   r   )r*   r   )r!   r4   r*   r5   )r!   r4   )r>   r?   r@   r   r*   r   )r*   r   )rQ   rR   )r*   r   )r*   r	   )r*   r   )r*   r   )__name__
__module____qualname____doc__r#   r)   propertyr-   r0   r3   r9   r    rD   rF   r(   r   rK   rP   rT   rW   rB   r,   rV   rY    r%   r"   r   r      s                   , , , X, , , , X,
 - - X-   ' ' ' '; ; ; ;C C C' ' ' ' 6 6 \6 
" 
" 
" \
"* * * *
 , , , X,
 ( ( X(
 ! ! ! X! ! ! ! X!    X  r%   r   N)(rg   
__future__r   typingr   r   r   docx.documentr   docx.opc.constantsr   r   docx.parts.commentsr	   docx.parts.hdrftrr
   r   docx.parts.numberingr   docx.parts.settingsr   docx.parts.storyr   docx.parts.stylesr   
docx.shaper   docx.sharedr   docx.commentsr   docx.enum.styler   docx.opc.corepropsr   docx.settingsr   docx.styles.styler   r   ri   r%   r"   <module>r{      s   1 1 " " " " " " * * * * * * * * * * " " " " " " 6 6 6 6 6 6 , , , , , , 4 4 4 4 4 4 4 4 . . . . . . , , , , , , & & & & & & ( ( ( ( ( ( # # # # # # $ $ $ $ $ $ ,&&&&&&------111111&&&&&&++++++O O O O O9 O O O O Or%   