o
    e                     @   s`   d 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 G d
d deZdS )z>Collection of :py:class:`~pdf2docx.layout.Section` instances.
    )
WD_SECTION)Pt   )BaseCollection)reset_paragraph_format   )Section)	constantsc                   @   s2   e Zd ZdefddZdd Zdd Zdd	 Zd
S )Sectionsrawsc                 C   s,   |    |D ]}t |}| | q| S )z#Restore sections from source dicts.)resetr   restoreappend)selfr   rawsection r   HD:\Projects\ConvertPro\env\Lib\site-packages\pdf2docx/layout/Sections.pyr      s
   zSections.restorec                 K   s   | D ]
}|j di | q| S )z!Parse layout under section level.Nr   )parse)r   settingsr   r   r   r   r      s   zSections.parsec                    s   | sdS t  j} fdd}| d }|jtjkr|| |jdkr( tj |	  | dd D ]+} tj  jd }|j
 sPd|jjv rP jd	 }|j}t|j|_|	  q3| jjD ]
}|	 j|  qcdS )
zCreate sections in docx.Nc                    s8      }t| jd}t|t|d}t| j| |_d S )N   )Zline_spacing)Zadd_paragraphminbefore_spacer   r   space_after)r   pline_heightpfdocr   r   "create_dummy_paragraph_for_section&   s   z>Sections.make_docx.<locals>.create_dummy_paragraph_for_sectionr   r   r   ZgraphicData)lenZ
paragraphsr   r	   Z
MINOR_DISTZnum_colsadd_sectionr   Z
CONTINUOUS	make_docxtextstrip_pxmlZparagraph_formatr   r   parentZfloat_images)r   r   nr   r   r   r   imager   r   r   r$      s(   





zSections.make_docxc                 C   s4   | D ]}|D ]}|j |ddd |j | qqdS )z*Plot all section blocks for debug purpose.)r   r   r   g      ?)strokewidthN)plotblocks)r   pager   columnr   r   r   r.   V   s   zSections.plotN)__name__
__module____qualname__listr   r   r$   r.   r   r   r   r   r
      s
    	7r
   N)__doc__Zdocx.enum.sectionr   Zdocx.sharedr   Zcommon.Collectionr   Zcommon.docxr   r   commonr	   r
   r   r   r   r   <module>   s   