;ic(^dZddlmZddlmZmZmZmZmZm Z ddl m Z GddeZ dS)zParagraph-related proxy types.)WD_LINE_SPACING) ElementProxyEmuLengthPtTwips lazyproperty)TabStopsceZdZdZedZejdZedZejdZedZejdZedZ e jd Z ed Z e jd Z ed Z e jd Z edZ e jdZ edZ e jdZ edZejdZedZejdZedZejdZedZedZejdZedZedZdS)ParagraphFormatzProvides access to paragraph formatting such as justification, indentation, line spacing, space before and after, and widow/orphan control.c0|jj}|dS|jS)zA member of the :ref:`WdParagraphAlignment` enumeration specifying the justification setting for this paragraph. A value of |None| indicates paragraph alignment is inherited from the style hierarchy. N)_elementpPrjc_valselfrs DC:\PYTHON\MyICR_Workspace\venv\Lib\site-packages\docx/text/parfmt.py alignmentzParagraphFormat.alignment s m ;4zcF|j}||_dSN)rget_or_add_pPrrrvaluers rrzParagraphFormat.alignments m**,, rc0|jj}|dS|jS)aA|Length| value specifying the relative difference in indentation for the first line of the paragraph. A positive value causes the first line to be indented. A negative value produces a hanging indent. |None| indicates first line indentation is inherited from the style hierarchy. N)rrfirst_line_indentrs rrz!ParagraphFormat.first_line_indents!m ;4$$rcF|j}||_dSr)rrrrs rrz!ParagraphFormat.first_line_indent,s#m**,, %rc0|jj}|dS|jS)z|True| if the paragraph should be kept "in one piece" and not broken across a page boundary when the document is rendered. |None| indicates its effective value is inherited from the style hierarchy. N)rr keepLines_valrs r keep_togetherzParagraphFormat.keep_together1s!m ;4  rcB||j_dSr)rrrrrs rr zParagraphFormat.keep_together=7< $$&&444rc0|jj}|dS|jS)aT|True| if the paragraph should be kept on the same page as the subsequent paragraph when the document is rendered. For example, this property could be used to keep a section heading on the same page as its first paragraph. |None| indicates its effective value is inherited from the style hierarchy. N)rr keepNext_valrs rkeep_with_nextzParagraphFormat.keep_with_nextAs!m ;4rcB||j_dSr)rrr%r"s rr&zParagraphFormat.keep_with_nextOs6; $$&&333rc0|jj}|dS|jS)a1|Length| value specifying the space between the left margin and the left side of the paragraph. |None| indicates the left indent value is inherited from the style hierarchy. Use an |Inches| value object as a convenient way to apply indentation in units of inches. N)rrind_leftrs r left_indentzParagraphFormat.left_indentSs m ;4|rcF|j}||_dSr)rrr)rs rr*zParagraphFormat.left_indentas m**,, rcb|jj}|dS||j|jS)aB|float| or |Length| value specifying the space between baselines in successive lines of the paragraph. A value of |None| indicates line spacing is inherited from the style hierarchy. A float value, e.g. ``2.0`` or ``1.75``, indicates spacing is applied in multiples of line heights. A |Length| value such as ``Pt(12)`` indicates spacing is a fixed height. The |Pt| value class is a convenient way to apply line spacing in units of points. Assigning |None| resets line spacing to inherit from the style hierarchy. N)rr _line_spacing spacing_linespacing_lineRulers r line_spacingzParagraphFormat.line_spacingfs4m ;4!!#"2C4HIIIrcR|j}|d|_d|_dSt |t r1||_|jt jkrt j|_dSdSt|tdz|_t j |_dS)N) rrr.r/ isinstancerrAT_LEASTEXACTLYrrMULTIPLErs rr0zParagraphFormat.line_spacingwsm**,, =#C #'C v & & <$C #'???'6'>$$$@? #55::#566C #2#;C rcb|jj}|dS||j|jS)atA member of the :ref:`WdLineSpacing` enumeration indicating how the value of :attr:`line_spacing` should be interpreted. Assigning any of the :ref:`WdLineSpacing` members :attr:`SINGLE`, :attr:`DOUBLE`, or :attr:`ONE_POINT_FIVE` will cause the value of :attr:`line_spacing` to be updated to produce the corresponding line spacing. N)rr_line_spacing_ruler.r/rs rline_spacing_rulez!ParagraphFormat.line_spacing_rules4m ;4&&s'79MNNNrc|j}|tjkr't d|_tj|_dS|tjkr't d|_tj|_dS|tj kr't d|_tj|_dS||_dS)Nr2h) rrrSINGLErr.r6r/ONE_POINT_FIVEDOUBLErs rr9z!ParagraphFormat.line_spacing_rulesm**,, O* * *$SzzC #2#;C o4 4 4$SzzC #2#;C o, , ,$SzzC #2#;C #(C rc0|jj}|dS|jS)z|True| if the paragraph should appear at the top of the page following the prior paragraph. |None| indicates its effective value is inherited from the style hierarchy. N)rrpageBreakBefore_valrs rpage_break_beforez!ParagraphFormat.page_break_befores!m ;4&&rcB||j_dSr)rrrAr"s rrBz!ParagraphFormat.page_break_befores=B $$&&:::rc0|jj}|dS|jS)a4|Length| value specifying the space between the right margin and the right side of the paragraph. |None| indicates the right indent value is inherited from the style hierarchy. Use a |Cm| value object as a convenient way to apply indentation in units of centimeters. N)rr ind_rightrs r right_indentzParagraphFormat.right_indents m ;4}rcF|j}||_dSr)rrrErs rrFzParagraphFormat.right_indents m**,, rc0|jj}|dS|jS)ao|Length| value specifying the spacing to appear between this paragraph and the subsequent paragraph. |None| indicates this value is inherited from the style hierarchy. |Length| objects provide convenience properties, such as :attr:`~.Length.pt` and :attr:`~.Length.inches`, that allow easy conversion to various length units. N)rr spacing_afterrs r space_afterzParagraphFormat.space_afters!m ;4  rcB||j_dSr)rrrIr"s rrJzParagraphFormat.space_afterr#rc0|jj}|dS|jS)af|Length| value specifying the spacing to appear between this paragraph and the prior paragraph. |None| indicates this value is inherited from the style hierarchy. |Length| objects provide convenience properties, such as :attr:`~.Length.pt` and :attr:`~.Length.cm`, that allow easy conversion to various length units. N)rrspacing_beforers r space_beforezParagraphFormat.space_befores!m ;4!!rcB||j_dSr)rrrMr"s rrNzParagraphFormat.space_befores8= $$&&555rcR|j}t|S)z^|TabStops| object providing access to the tab stops defined for this paragraph format.)rrr rs r tab_stopszParagraphFormat.tab_stopss#m**,,}}rc0|jj}|dS|jS)z|True| if the first and last lines in the paragraph remain on the same page as the rest of the paragraph when Word repaginates the document. |None| indicates its effective value is inherited from the style hierarchy. N)rrwidowControl_valrs r widow_controlzParagraphFormat.widow_controls!m ;4##rcB||j_dSr)rrrSr"s rrTzParagraphFormat.widow_controls:? $$&&777rcR|dS|tjkr|tdz S|S)a[Return the line spacing value calculated from the combination of `spacing_line` and `spacing_lineRule`. Returns a |float| number of lines when `spacing_lineRule` is ``WD_LINE_SPACING.MULTIPLE``, otherwise a |Length| object of absolute line height is returned. Returns |None| when `spacing_line` is |None|. N )rr6r)r.r/s rr-zParagraphFormat._line_spacings4  4 7 7 7"R&&( (rc|tjkr]|tdkr tjS|tdkr tjS|tdkr tjS|S)zReturn the line spacing rule value calculated from the combination of `line` and `lineRule`. Returns special members of the :ref:`WdLineSpacing` enumeration when line spacing is single, double, or 1.5 lines. r2r;r<)rr6rr=r>r?)linelineRules rr8z"ParagraphFormat._line_spacing_rulese / / /uSzz!!&--uSzz!!&55uSzz!!&--rN)__name__ __module__ __qualname____doc__propertyrsetterrr r&r*r0r9rBrFrJrNr rQrT staticmethodr-r8rrr r s5BB  X  % %X %&&& ! !X !===   X  <<<  X JJXJ  < < < O OX O ) ) ) ' 'X 'CCC  X  ! !X !=== " "X ">>>\  $ $X $@@@  \ \rr N) r^docx.enum.textr docx.sharedrrrrrr docx.text.tabstopsr r rbrrrfs$$******JJJJJJJJJJJJJJJJ''''''VVVVVlVVVVVr