
    ,hG                    J   d Z ddlmZ ddlmZmZ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 er&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"  G d d      Z# G d dee#         Z$ G d de
      Z% G d de%      Z& G d de%      Z'y)z/The |Section| object and related proxy classes.    )annotations)TYPE_CHECKINGIteratorListSequenceoverload)BlockItemContainer)WD_HEADER_FOOTER)CT_P)
FooterPart
HeaderPart)lazyproperty)Table)	Paragraph)WD_ORIENTATIONWD_SECTION_START)CT_Document)	CT_SectPr)DocumentPart)	StoryPart)Lengthc                  J    e Zd ZdZd# fdZed$d       Zej                  d%d       Zed&d       Zej                  d'd       Zed(d       Z	ed)d       Z
ed(d	       Zed)d
       Zed(d       Zed$d       Zej                  d%d       Zed$d       Zej                  d%d       Zed)d       Zed$d       Zej                  d%d       Zd*dZed$d       Zej                  d%d       Zed+d       Zej                  d,d       Zed$d       Zej                  d-d       Zed$d       Zej                  d-d       Zed.d       Zed$d       Zej                  d-d       Zed/d       Zej                  d0d        Zed$d!       Zej                  d-d"       Z xZS )1Sectionz}Document section, providing access to section and page setup settings.

    Also provides access to headers and footers.
    c                F    t         t        |           || _        || _        y N)superr   __init___sectPr_document_part)selfsectPrdocument_part	__class__s      N/var/www/html/Resume-Scraper/venv/lib/python3.12/site-packages/docx/section.pyr   zSection.__init__   s    gt%'+    c                .    | j                   j                  S )zRead/write. Bottom margin for pages in this section, in EMU.

        `None` when no bottom margin has been specified. Assigning |None| removes any
        bottom-margin setting.
        r   bottom_marginr    s    r$   r(   zSection.bottom_margin#   s     ||)))r%   c                &    || j                   _        y r   r'   r    values     r$   r(   zSection.bottom_margin,   s    %*"r%   c                .    | j                   j                  S )zTrue if this section displays a distinct first-page header and footer.

        Read/write. The definition of the first-page header and footer are accessed
        using :attr:`.first_page_header` and :attr:`.first_page_footer` respectively.
        r   titlePg_valr)   s    r$   "different_first_page_header_footerz*Section.different_first_page_header_footer0   s     ||'''r%   c                &    || j                   _        y r   r.   r+   s     r$   r0   z*Section.different_first_page_header_footer9       #( r%   c                `    t        | j                  | j                  t        j                        S )z|_Footer| object defining footer content for even pages.

        The content of this footer definition is ignored unless the document setting
        :attr:`~.Settings.odd_and_even_pages_header_footer` is set True.
        )_Footerr   r   r
   	EVEN_PAGEr)   s    r$   even_page_footerzSection.even_page_footer=   $     t||T%8%8:J:T:TUUr%   c                `    t        | j                  | j                  t        j                        S )z|_Header| object defining header content for even pages.

        The content of this header definition is ignored unless the document setting
        :attr:`~.Settings.odd_and_even_pages_header_footer` is set True.
        )_Headerr   r   r
   r5   r)   s    r$   even_page_headerzSection.even_page_headerF   r7   r%   c                `    t        | j                  | j                  t        j                        S )z|_Footer| object defining footer content for the first page of this section.

        The content of this footer definition is ignored unless the property
        :attr:`.different_first_page_header_footer` is set True.
        )r4   r   r   r
   
FIRST_PAGEr)   s    r$   first_page_footerzSection.first_page_footerO   $     t||T%8%8:J:U:UVVr%   c                `    t        | j                  | j                  t        j                        S )z|_Header| object defining header content for the first page of this section.

        The content of this header definition is ignored unless the property
        :attr:`.different_first_page_header_footer` is set True.
        )r9   r   r   r
   r<   r)   s    r$   first_page_headerzSection.first_page_headerX   r>   r%   c                `    t        | j                  | j                  t        j                        S )z|_Footer| object representing default page footer for this section.

        The default footer is used for odd-numbered pages when separate odd/even footers
        are enabled. It is used for both odd and even-numbered pages otherwise.
        )r4   r   r   r
   PRIMARYr)   s    r$   footerzSection.footera   $     t||T%8%8:J:R:RSSr%   c                .    | j                   j                  S )zDistance from bottom edge of page to bottom edge of the footer.

        Read/write. |None| if no setting is present in the XML.
        r   rC   r)   s    r$   footer_distancezSection.footer_distancej   s     ||"""r%   c                &    || j                   _        y r   rF   r+   s     r$   rG   zSection.footer_distancer       #r%   c                .    | j                   j                  S )ai  |Length| object representing page gutter size in English Metric Units.

        Read/write. The page gutter is extra spacing added to the `inner` margin to
        ensure even margins after page binding. Generally only used in book-bound
        documents with double-sided and facing pages.

        This setting applies to all pages in this section.

        r   gutterr)   s    r$   rL   zSection.gutterv   s     ||"""r%   c                &    || j                   _        y r   rK   r+   s     r$   rL   zSection.gutter   rI   r%   c                `    t        | j                  | j                  t        j                        S )z|_Header| object representing default page header for this section.

        The default header is used for odd-numbered pages when separate odd/even headers
        are enabled. It is used for both odd and even-numbered pages otherwise.
        )r9   r   r   r
   rB   r)   s    r$   headerzSection.header   rD   r%   c                .    | j                   j                  S )zDistance from top edge of page to top edge of header.

        Read/write. |None| if no setting is present in the XML. Assigning |None| causes
        default value to be used.
        r   rO   r)   s    r$   header_distancezSection.header_distance   s     ||"""r%   c                &    || j                   _        y r   rQ   r+   s     r$   rR   zSection.header_distance   rI   r%   c              #     K   | j                   j                         D ],  }t        |t              rt	        ||       nt        ||        . yw)zlGenerate each Paragraph or Table object in this `section`.

        Items appear in document order.
        N)r   iter_inner_content
isinstancer   r   r   )r    elements     r$   rU   zSection.iter_inner_content   sG     
 ||668 	dG/9'4/H9Wd+eT[]aNbc	ds   AAc                .    | j                   j                  S )zk|Length| object representing the left margin for all pages in this section in
        English Metric Units.r   left_marginr)   s    r$   rZ   zSection.left_margin   s     ||'''r%   c                &    || j                   _        y r   rY   r+   s     r$   rZ   zSection.left_margin   r2   r%   c                .    | j                   j                  S )z:ref:`WdOrientation` member specifying page orientation for this section.

        One of ``WD_ORIENT.PORTRAIT`` or ``WD_ORIENT.LANDSCAPE``.
        r   orientationr)   s    r$   r^   zSection.orientation   s     ||'''r%   c                &    || j                   _        y r   r]   r+   s     r$   r^   zSection.orientation   r2   r%   c                .    | j                   j                  S )a)  Total page height used for this section.

        This value is inclusive of all edge spacing values such as margins.

        Page orientation is taken into account, so for example, its expected value
        would be ``Inches(8.5)`` for letter-sized paper when orientation is landscape.
        r   page_heightr)   s    r$   rb   zSection.page_height   s     ||'''r%   c                &    || j                   _        y r   ra   r+   s     r$   rb   zSection.page_height   r2   r%   c                .    | j                   j                  S )aA  Total page width used for this section.

        This value is like "paper size" and includes all edge spacing values such as
        margins.

        Page orientation is taken into account, so for example, its expected value
        would be ``Inches(11)`` for letter-sized paper when orientation is landscape.
        r   
page_widthr)   s    r$   rf   zSection.page_width   s     ||&&&r%   c                &    || j                   _        y r   re   r+   s     r$   rf   zSection.page_width       "'r%   c                    | j                   S r   )r   r)   s    r$   partzSection.part   s    """r%   c                .    | j                   j                  S )zl|Length| object representing the right margin for all pages in this section
        in English Metric Units.r   right_marginr)   s    r$   rm   zSection.right_margin   s     ||(((r%   c                &    || j                   _        y r   rl   r+   s     r$   rm   zSection.right_margin   s    $)!r%   c                .    | j                   j                  S )zType of page-break (if any) inserted at the start of this section.

        For exmple, ``WD_SECTION_START.ODD_PAGE`` if the section should begin on the
        next odd page, possibly inserting two page-breaks instead of one.
        r   
start_typer)   s    r$   rq   zSection.start_type   s     ||&&&r%   c                &    || j                   _        y r   rp   r+   s     r$   rq   zSection.start_type   rh   r%   c                .    | j                   j                  S )zj|Length| object representing the top margin for all pages in this section in
        English Metric Units.r   
top_marginr)   s    r$   ru   zSection.top_margin   s     ||&&&r%   c                &    || j                   _        y r   rt   r+   s     r$   ru   zSection.top_margin   rh   r%   )r!   r   r"   r   )returnLength | None)r,   zint | Length | Nonerw   bool)r,   rz   )rw   r4   )rw   r9   )rw   zIterator[Paragraph | Table])rw   r   )r,   zWD_ORIENTATION | None)r,   rx   )rw   r   )rw   r   )r,   zWD_SECTION_START | None)__name__
__module____qualname____doc__r   propertyr(   setterr0   r6   r:   r=   r@   r   rC   rG   rL   rO   rR   rU   rZ   r^   rb   rf   rj   rm   rq   ru   __classcell__r#   s   @r$   r   r      s   
,
 * * + + ( ( (..) /) V V V V W W W W T T # # $ $ 
# 
# ]]$ $ T T # # $ $d ( (
 ) ) ( ( ) ) ( ( ) ) 	' 	' ( ( # # ) )
 * * ' ' ( ( ' '
 ( (r%   r   c                  `     e Zd ZdZd fdZed	d       Zed
d       ZddZddZddZ xZ	S )SectionszSequence of |Section| objects corresponding to the sections in the document.

    Supports ``len()``, iteration, and indexed access.
    c                F    t         t        |           || _        || _        y r   )r   r   r   _document_elmr   )r    document_elmr"   r#   s      r$   r   zSections.__init__  s     h&()+r%   c                     y r    r    keys     r$   __getitem__zSections.__getitem__  s    03r%   c                     y r   r   r   s     r$   r   zSections.__getitem__  s    8;r%   c                    t        |t              r;| j                  j                  |   D cg c]  }t	        || j
                         c}S t	        | j                  j                  |   | j
                        S c c}w r   )rV   slicer   
sectPr_lstr   r   )r    r   r!   s      r$   r   zSections.__getitem__  sr    c5! #00;;C@  3 34  t))44S94;N;NOO	s   A9c              #  r   K   | j                   j                  D ]  }t        || j                          y wr   )r   r   r   r   )r    r!   s     r$   __iter__zSections.__iter__  s4     ((33 	7F&$"5"566	7s   57c                @    t        | j                  j                        S r   )lenr   r   r)   s    r$   __len__zSections.__len__  s    4%%0011r%   )r   r   r"   r   )r   intrw   r   )r   r   rw   zList[Section])r   zint | slicerw   zSection | List[Section])rw   zIterator[Section])rw   r   )
r{   r|   r}   r~   r   r   r   r   r   r   r   s   @r$   r   r      s;    
,
 3 3; ;P72r%   r   c                      e Zd ZdZ	 	 	 	 	 	 ddZedd       Zej                  dd       Zedd       ZddZ	edd       Z
ddZed	        Zdd
Zedd       Zedd       Zy)_BaseHeaderFooterz)Base class for header and footer classes.c                .    || _         || _        || _        y r   )r   r   _hdrftr_index)r    r!   r"   header_footer_indexs       r$   r   z_BaseHeaderFooter.__init__$  s     +0r%   c                    | j                    S )a  ``True`` if this header/footer uses the definition from the prior section.

        ``False`` if this header/footer has an explicit definition.

        Assigning ``True`` to this property removes the header/footer definition for
        this section, causing it to "inherit" the corresponding definition of the prior
        section. Assigning ``False`` causes a new, empty definition to be added for this
        section, but only if no definition is already present.
        )_has_definitionr)   s    r$   is_linked_to_previousz'_BaseHeaderFooter.is_linked_to_previous.  s     ''''r%   c                    t        |      }|| j                  k(  ry |du r| j                          y | j                          y )NT)rz   r   _drop_definition_add_definition)r    r,   	new_states      r$   r   z'_BaseHeaderFooter.is_linked_to_previous<  s<    K	222!!#  "r%   c                "    | j                         S )zThe |HeaderPart| or |FooterPart| for this header/footer.

        This overrides `BlockItemContainer.part` and is required to support image
        insertion and perhaps other content like hyperlinks.
        )_get_or_add_definitionr)   s    r$   rj   z_BaseHeaderFooter.partG  s     **,,r%   c                    t        d      )z&Return newly-added header/footer part.$must be implemented by each subclassNotImplementedErrorr)   s    r$   r   z!_BaseHeaderFooter._add_definitionR      !"HIIr%   c                    t        d      )zE|HeaderPart| or |FooterPart| object containing header/footer content.r   r   r)   s    r$   _definitionz_BaseHeaderFooter._definitionV       ""HIIr%   c                    t        d      )zJRemove header/footer part containing the definition of this header/footer.r   r   r)   s    r$   r   z"_BaseHeaderFooter._drop_definition[  r   r%   c                6    | j                         j                  S )z7`w:hdr` or `w:ftr` element, root of header/footer part.)r   rW   r)   s    r$   _elementz_BaseHeaderFooter._element_  s     **,444r%   c                    | j                   r| j                  S | j                  }|r|j                         S | j	                         S )a  Return HeaderPart or FooterPart object for this section.

        If this header/footer inherits its content, the part for the prior header/footer
        is returned; this process continue recursively until a definition is found. If
        the definition cannot be inherited (because the header/footer belongs to the
        first section), a new definition is added for that first section and then
        returned.
        )r   r   _prior_headerfooterr   r   )r    prior_headerfooters     r$   r   z(_BaseHeaderFooter._get_or_add_definitiond  sF     ###!55%<<>>##%%r%   c                    t        d      )zHTrue if this header/footer has a related part containing its definition.r   r   r)   s    r$   r   z!_BaseHeaderFooter._has_definitionx  r   r%   c                    t        d      )zn|_Header| or |_Footer| proxy on prior sectPr element.

        Returns None if this is first section.
        r   r   r)   s    r$   r   z%_BaseHeaderFooter._prior_headerfooter}  s     ""HIIr%   N)r!   r   r"   r   r   r
   ry   )r,   rz   rw   None)rw   zHeaderPart | FooterPart)rw   r   )rw   z_Header | _Footer | None)r{   r|   r}   r~   r   r   r   r   rj   r   r   r   r   r   r   r   r   r%   r$   r   r   !  s    311 $1 .	1 ( ( !!# "# - -J J JJ 5 5&( J J J Jr%   r   c                  P    e Zd ZdZddZed        Zd Zed	d       Zed        Z	y)
r4   a  Page footer, used for all three types (default, even-page, and first-page).

    Note that, like a document or table cell, a footer must contain a minimum of one
    paragraph and a new or otherwise "empty" footer contains a single empty paragraph.
    This first paragraph can be accessed as `footer.paragraphs[0]` for purposes of
    adding content to it. Using :meth:`add_paragraph()` by itself to add content will
    leave an empty paragraph above the newly added one.
    c                    | j                   j                         \  }}| j                  j                  | j                  |       |S )zReturn newly-added footer part.)r   add_footer_partr   add_footerReferencer   )r    footer_partrIds      r$   r   z_Footer._add_definition  ;    ..>>@S((););SAr%   c                    | j                   j                  | j                        }|J | j                  j	                  |j
                        S )z6|FooterPart| object containing content of this footer.)r   get_footerReferencer   r   r   r   r    footerReferences     r$   r   z_Footer._definition  D     ,,::4;M;MN**""../B/BCCr%   c                    | j                   j                  | j                        }| j                  j	                  |       y)zDRemove footer definition (footer part) associated with this section.N)r   remove_footerReferencer   r   drop_relr    r   s     r$   r   z_Footer._drop_definition  s0    ll11$2D2DE$$S)r%   c                T    | j                   j                  | j                        }|duS )z-True if a footer is defined for this section.N)r   r   r   r   s     r$   r   z_Footer._has_definition  )     ,,::4;M;MNd**r%   c                x    | j                   j                  }|dS t        || j                  | j                        S )zI|_Footer| proxy on prior sectPr element or None if this is first section.N)r   preceding_sectPrr4   r   r   r    r   s     r$   r   z_Footer._prior_headerfooter  F      <<88  ' 	
 )4+>+>@R@RS	
r%   N)rw   r   ry   
r{   r|   r}   r~   r   r   r   r   r   r   r   r%   r$   r4   r4     sO     D D*
 + +
 
 
r%   r4   c                  N    e Zd ZdZd Zed        Zd Zedd       Zed        Z	y)	r9   a  Page header, used for all three types (default, even-page, and first-page).

    Note that, like a document or table cell, a header must contain a minimum of one
    paragraph and a new or otherwise "empty" header contains a single empty paragraph.
    This first paragraph can be accessed as `header.paragraphs[0]` for purposes of
    adding content to it. Using :meth:`add_paragraph()` by itself to add content will
    leave an empty paragraph above the newly added one.
    c                    | j                   j                         \  }}| j                  j                  | j                  |       |S )zReturn newly-added header part.)r   add_header_partr   add_headerReferencer   )r    header_partr   s      r$   r   z_Header._add_definition  r   r%   c                    | j                   j                  | j                        }|J | j                  j	                  |j
                        S )z6|HeaderPart| object containing content of this header.)r   get_headerReferencer   r   r   r   r    headerReferences     r$   r   z_Header._definition  r   r%   c                    | j                   j                  | j                        }| j                  j	                  |       y)z6Remove header definition associated with this section.N)r   remove_headerReferencer   r   drop_header_partr   s     r$   r   z_Header._drop_definition  s0    ll11$2D2DE,,S1r%   c                T    | j                   j                  | j                        }|duS )z8True if a header is explicitly defined for this section.N)r   r   r   r   s     r$   r   z_Header._has_definition  r   r%   c                x    | j                   j                  }|dS t        || j                  | j                        S )zI|_Header| proxy on prior sectPr element or None if this is first section.N)r   r   r9   r   r   r   s     r$   r   z_Header._prior_headerfooter  r   r%   Nry   r   r   r%   r$   r9   r9     sO     D D2
 + +
 
 
r%   r9   N)(r~   
__future__r   typingr   r   r   r   r   docx.blkcntnrr	   docx.enum.sectionr
   docx.oxml.text.paragraphr   docx.parts.hdrftrr   r   docx.sharedr   
docx.tabler   docx.text.paragraphr   r   r   docx.oxml.documentr   docx.oxml.sectionr   docx.parts.documentr   docx.parts.storyr   r   r   r   r   r4   r9   r   r%   r$   <module>r      s    5 " D D , . ) 4 $  )B.+0*"e( e(P2x  2BbJ* bJJ+
 +
\+
 +
r%   