
    hG                    T   S r SSKJr  SSKJrJrJr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  \(       a&  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!  SSKJ"r"   " S S5      r# " S S\\#   5      r$ " S S\
5      r% " S S\%5      r& " S S\%5      r'g)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                    ^  \ rS rSrSrS%U 4S jjr\S&S j5       r\R                  S'S j5       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+S j5       r\S*S j5       r\S&S j5       r\R                  S'S j5       r\S&S j5       r\R                  S'S j5       r\S+S j5       r\S&S j5       r\R                  S'S j5       rS,S jr\S&S j5       r\R                  S'S j5       r\S-S j5       r\R                  S.S j5       r\S&S j5       r\R                  S/S j5       r\S&S j5       r\R                  S/S j5       r\S0S j5       r\S&S j5       r\R                  S/S j5       r\S1S  j5       r\R                  S2S! j5       r\S&S" j5       r\R                  S/S# j5       rS$rU =r$ )3Section   zuDocument section, providing access to section and page setup settings.

Also provides access to headers and footers.
c                B   > [         [        U ]  5         Xl        X l        g N)superr   __init___sectPr_document_part)selfsectPrdocument_part	__class__s      >/var/www/html/env/lib/python3.13/site-packages/docx/section.pyr   Section.__init__   s    gt%'+    c                .    U R                   R                  $ )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*   Section.bottom_margin#   s     ||)))r'   c                $    XR                   l        g r   r)   r!   values     r%   r*   r,   ,   s    %*"r'   c                .    U R                   R                  $ )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_footer*Section.different_first_page_header_footer0   s     ||'''r'   c                $    XR                   l        g r   r1   r.   s     r%   r3   r4   9       #( r'   c                `    [        U R                  U R                  [        R                  5      $ )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_footerSection.even_page_footer=   $     t||T%8%8:J:T:TUUr'   c                `    [        U R                  U R                  [        R                  5      $ )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
   r9   r+   s    r%   even_page_headerSection.even_page_headerF   r<   r'   c                `    [        U R                  U R                  [        R                  5      $ )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.
)r8   r   r    r
   
FIRST_PAGEr+   s    r%   first_page_footerSection.first_page_footerO   $     t||T%8%8:J:U:UVVr'   c                `    [        U R                  U R                  [        R                  5      $ )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.
)r>   r   r    r
   rB   r+   s    r%   first_page_headerSection.first_page_headerX   rE   r'   c                `    [        U R                  U R                  [        R                  5      $ )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.
)r8   r   r    r
   PRIMARYr+   s    r%   footerSection.footera   $     t||T%8%8:J:R:RSSr'   c                .    U R                   R                  $ )zyDistance from bottom edge of page to bottom edge of the footer.

Read/write. |None| if no setting is present in the XML.
r   rK   r+   s    r%   footer_distanceSection.footer_distancej   s     ||"""r'   c                $    XR                   l        g r   rO   r.   s     r%   rP   rQ   r       #r'   c                .    U R                   R                  $ )aA  |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%   rV   Section.gutterv   s     ||"""r'   c                $    XR                   l        g r   rU   r.   s     r%   rV   rW      rS   r'   c                `    [        U R                  U R                  [        R                  5      $ )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.
)r>   r   r    r
   rJ   r+   s    r%   headerSection.header   rM   r'   c                .    U R                   R                  $ )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   rZ   r+   s    r%   header_distanceSection.header_distance   s     ||"""r'   c                $    XR                   l        g r   r]   r.   s     r%   r^   r_      rS   r'   c              #     #    U R                   R                  5        H0  n[        U[        5      (       a  [	        X5      O
[        X5      v   M2     g7f)z\Generate each Paragraph or Table object in this `section`.

Items appear in document order.
N)r   iter_inner_content
isinstancer   r   r   )r!   elements     r%   rb   Section.iter_inner_content   s=     
 ||668G/9'4/H/H9W+eT[Nbc 9s   AAc                .    U R                   R                  $ )zc|Length| object representing the left margin for all pages in this section in
English Metric Units.r   left_marginr+   s    r%   rh   Section.left_margin   s     ||'''r'   c                $    XR                   l        g r   rg   r.   s     r%   rh   ri      r6   r'   c                .    U R                   R                  $ )z:ref:`WdOrientation` member specifying page orientation for this section.

One of ``WD_ORIENT.PORTRAIT`` or ``WD_ORIENT.LANDSCAPE``.
r   orientationr+   s    r%   rm   Section.orientation   s     ||'''r'   c                $    XR                   l        g r   rl   r.   s     r%   rm   rn      r6   r'   c                .    U R                   R                  $ )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%   rr   Section.page_height   s     ||'''r'   c                $    XR                   l        g r   rq   r.   s     r%   rr   rs      r6   r'   c                .    U R                   R                  $ )a  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%   rw   Section.page_width   s     ||&&&r'   c                $    XR                   l        g r   rv   r.   s     r%   rw   rx          "'r'   c                    U R                   $ r   )r    r+   s    r%   partSection.part   s    """r'   c                .    U R                   R                  $ )zd|Length| object representing the right margin for all pages in this section
in English Metric Units.r   right_marginr+   s    r%   r   Section.right_margin   s     ||(((r'   c                $    XR                   l        g r   r   r.   s     r%   r   r      s    $)!r'   c                .    U R                   R                  $ )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%   r   Section.start_type   s     ||&&&r'   c                $    XR                   l        g r   r   r.   s     r%   r   r      rz   r'   c                .    U R                   R                  $ )zb|Length| object representing the top margin for all pages in this section in
English Metric Units.r   
top_marginr+   s    r%   r   Section.top_margin   s     ||&&&r'   c                $    XR                   l        g r   r   r.   s     r%   r   r      rz   r'   )r    r   )r"   r   r#   r   )returnLength | None)r/   zint | Length | Noner   bool)r/   r   )r   r8   )r   r>   )r   zIterator[Paragraph | Table])r   r   )r/   zWD_ORIENTATION | None)r/   r   )r   r   )r   r   )r/   zWD_SECTION_START | None)__name__
__module____qualname____firstlineno____doc__r   propertyr*   setterr3   r:   r?   rC   rG   r   rK   rP   rV   rZ   r^   rb   rh   rm   rr   rw   r|   r   r   r   __static_attributes____classcell__r$   s   @r%   r   r      s   
,
 * * + + ( ( (..) /) V V V V W W W W T T # # $ $ 
# 
# ]]$ $ T T # # $ $d ( (
 ) ) ( ( ) ) ( ( ) ) 	' 	' ( ( # # ) )
 * * ' ' ( ( ' '
 ( (r'   r   c                  v   ^  \ rS rSrSrS
U 4S jjr\SS j5       r\SS j5       rSS jrSS jrSS jr	S	r
U =r$ )Sections   zSequence of |Section| objects corresponding to the sections in the document.

Supports ``len()``, iteration, and indexed access.
c                B   > [         [        U ]  5         Xl        X l        g r   )r   r   r   _document_elmr    )r!   document_elmr#   r$   s      r%   r   Sections.__init__  s    h&()+r'   c                    g r    r!   keys     r%   __getitem__Sections.__getitem__  s    03r'   c                    g r   r   r   s     r%   r   r     s    8;r'   c                
   [        U[        5      (       a=  U R                  R                  U    Vs/ s H  n[	        X R
                  5      PM     sn$ [	        U R                  R                  U   U R
                  5      $ s  snf r   )rc   slicer   
sectPr_lstr   r    )r!   r   r"   s      r%   r   r     sx    c5!! #00;;C@@F  3 34@  t))44S94;N;NOO	s   B c              #  t   #    U R                   R                   H  n[        XR                  5      v   M     g 7fr   )r   r   r   r    )r!   r"   s     r%   __iter__Sections.__iter__  s,     ((33F&"5"566 4s   68c                @    [        U R                  R                  5      $ r   )lenr   r   r+   s    r%   __len__Sections.__len__  s    4%%0011r'   )r   r    )r   r   r#   r   )r   intr   r   )r   r   r   zList[Section])r   zint | slicer   zSection | List[Section])r   zIterator[Section])r   r   )r   r   r   r   r   r   r   r   r   r   r   r   r   s   @r%   r   r      s@    
,
 3 3; ;P72 2r'   r   c                      \ rS rSrSr      SS jr\SS j5       r\R                  SS j5       r\SS j5       r	SS jr
\SS j5       rSS	 jr\S
 5       rSS jr\SS j5       r\SS j5       rSrg)_BaseHeaderFooteri!  z)Base class for header and footer classes.c                (    Xl         X l        X0l        g r   )r   r    _hdrftr_index)r!   r"   r#   header_footer_indexs       r%   r   _BaseHeaderFooter.__init__$  s     +0r'   c                $    U R                   (       + $ )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_previous'_BaseHeaderFooter.is_linked_to_previous.  s     ''''r'   c                    [        U5      nX R                  :X  a  g USL a  U R                  5         g U R                  5         g )NT)r   r   _drop_definition_add_definition)r!   r/   	new_states      r%   r   r   <  s:    K	222!!#  "r'   c                "    U R                  5       $ )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%   r|   _BaseHeaderFooter.partG  s     **,,r'   c                    [        S5      e)z&Return newly-added header/footer part.$must be implemented by each subclassNotImplementedErrorr+   s    r%   r   !_BaseHeaderFooter._add_definitionR      !"HIIr'   c                    [        S5      e)zE|HeaderPart| or |FooterPart| object containing header/footer content.r   r   r+   s    r%   _definition_BaseHeaderFooter._definitionV       ""HIIr'   c                    [        S5      e)zJRemove header/footer part containing the definition of this header/footer.r   r   r+   s    r%   r   "_BaseHeaderFooter._drop_definition[  r   r'   c                6    U R                  5       R                  $ )z7`w:hdr` or `w:ftr` element, root of header/footer part.)r   rd   r+   s    r%   _element_BaseHeaderFooter._element_  s     **,444r'   c                    U R                   (       a  U R                  $ U R                  nU(       a  UR                  5       $ U R	                  5       $ )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   (_BaseHeaderFooter._get_or_add_definitiond  sF     ###!55%<<>>##%%r'   c                    [        S5      e)zHTrue if this header/footer has a related part containing its definition.r   r   r+   s    r%   r   !_BaseHeaderFooter._has_definitionx  r   r'   c                    [        S5      e)z^|_Header| or |_Footer| proxy on prior sectPr element.

Returns None if this is first section.
r   r   r+   s    r%   r   %_BaseHeaderFooter._prior_headerfooter}  s     ""HIIr'   )r    r   r   N)r"   r   r#   r   r   r
   r   )r/   r   r   None)r   zHeaderPart | FooterPart)r   r   )r   z_Header | _Footer | None)r   r   r   r   r   r   r   r   r   r|   r   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                  \    \ rS rSrSrS
S jr\S 5       rS r\SS j5       r	\S 5       r
Srg	)r8   i  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                    U R                   R                  5       u  pU R                  R                  U R                  U5        U$ )zReturn newly-added footer part.)r    add_footer_partr   add_footerReferencer   )r!   footer_partrIds      r%   r   _Footer._add_definition  9    ..>>@((););SAr'   c                    U R                   R                  U R                  5      nUc   eU R                  R	                  UR
                  5      $ )z6|FooterPart| object containing content of this footer.)r   get_footerReferencer   r    r   r   r!   footerReferences     r%   r   _Footer._definition  G     ,,::4;M;MN***""../B/BCCr'   c                    U R                   R                  U R                  5      nU R                  R	                  U5        g)zDRemove footer definition (footer part) associated with this section.N)r   remove_footerReferencer   r    drop_relr!   r   s     r%   r   _Footer._drop_definition  s0    ll11$2D2DE$$S)r'   c                T    U R                   R                  U R                  5      nUSL$ )z-True if a footer is defined for this section.N)r   r   r   r   s     r%   r   _Footer._has_definition  )     ,,::4;M;MNd**r'   c                x    U R                   R                  nUc  S$ [        XR                  U R                  5      $ )zI|_Footer| proxy on prior sectPr element or None if this is first section.N)r   preceding_sectPrr8   r    r   r!   r   s     r%   r   _Footer._prior_headerfooter  D      <<88  ' 	
 )+>+>@R@RS	
r'   r   N)r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r'   r%   r8   r8     sO     D D*
 + +
 
 
r'   r8   c                  X    \ rS rSrSrS r\S 5       rS r\S
S j5       r	\S 5       r
Srg	)r>   i  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                    U R                   R                  5       u  pU R                  R                  U R                  U5        U$ )zReturn newly-added header part.)r    add_header_partr   add_headerReferencer   )r!   header_partr   s      r%   r   _Header._add_definition  r   r'   c                    U R                   R                  U R                  5      nUc   eU R                  R	                  UR
                  5      $ )z6|HeaderPart| object containing content of this header.)r   get_headerReferencer   r    r   r   r!   headerReferences     r%   r   _Header._definition  r   r'   c                    U R                   R                  U R                  5      nU R                  R	                  U5        g)z6Remove header definition associated with this section.N)r   remove_headerReferencer   r    drop_header_partr   s     r%   r   _Header._drop_definition  s0    ll11$2D2DE,,S1r'   c                T    U R                   R                  U R                  5      nUSL$ )z8True if a header is explicitly defined for this section.N)r   r   r   r  s     r%   r   _Header._has_definition  r   r'   c                x    U R                   R                  nUc  S$ [        XR                  U R                  5      $ )zI|_Header| proxy on prior sectPr element or None if this is first section.N)r   r   r>   r    r   r   s     r%   r   _Header._prior_headerfooter  r   r'   r   Nr   r   r   r'   r%   r>   r>     sO     D D2
 + +
 
 
r'   r>   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   r8   r>   r   r'   r%   <module>r     s    5 " D D , . ) 4 $  )B.+0*"e( e(P2x  2BbJ* bJJ+
 +
\+
 +
r'   