;i*(dZddlmZddlmZmZmZmZddlm Z ddl m Z ddl m Z ddlmZddlmZdd lmZdd lmZdd lmZdd lmZdd lmZerddlmZddl mZddl m!Z!m"Z"ddlm#Z#GddeZ$GddZ%dS)z=Run-related proxy objects for python-docx, Run in particular.) annotations)IO TYPE_CHECKINGIteratorcast)Drawing) WD_STYLE_TYPE)WD_BREAK) CT_Drawing)CT_LastRenderedPageBreak) InlineShape) StoryChild)CharacterStyle)Font)RenderedPageBreakN) WD_UNDERLINE)CT_RCT_Text)LengthceZdZdZd3fd Zejfd4d Z d5d6dZd7dZ d8dZ e d9dZ e j d:dZ dZe d;dZe dd(Ze d?d*Zej d@d-Ze dAd.Zej d8d/Ze dBd1Zej dCd2ZxZS)DRunaIProxy object wrapping `` element. Several of the properties on Run take a tri-state value, |True|, |False|, or |None|. |True| and |False| correspond to on and off respectively. |None| indicates the property is not specified directly on the run and its effective value is taken from the style hierarchy. rrparentt.ProvidesStoryPartctt||x|_x|_|_dSN)super__init___r_elementelement)selfrr __class__s AC:\PYTHON\MyICR_Workspace\venv\Lib\site-packages\docx/text/run.pyrz Run.__init__"s4    1222$-$,,, break_typer c tjdtjdtjdtjdtjdtjdi|\}}|j}|||_ | ||_ dSdS)a Add a break element of `break_type` to this run. `break_type` can take the values `WD_BREAK.LINE`, `WD_BREAK.PAGE`, and `WD_BREAK.COLUMN` where `WD_BREAK` is imported from `docx.enum.text`. `break_type` defaults to `WD_BREAK.LINE`. NN)pageN)columnN) textWrappingleft)r+right)r+allN) r LINEPAGECOLUMNLINE_CLEAR_LEFTLINE_CLEAR_RIGHTLINE_CLEAR_ALLradd_brtypeclear)r"r&type_r7brs r$ add_breakz Run.add_break&s M< M> O-  $&>  %'@  #%<    uW^^    BG  BHHH  r%Nimage_path_or_streamstr | IO[bytes]widthint | Length | Noneheightreturnr c|j|||}|j|t |S)aReturn |InlineShape| containing image identified by `image_path_or_stream`. The picture is added to the end of this run. `image_path_or_stream` can be a path (a string) or a file-like object containing a binary image. If neither width nor height is specified, the picture appears at its native size. If only one is specified, it is used to compute a scaling factor that is then applied to the unspecified dimension, preserving the aspect ratio of the image. The native size of the picture is calculated using the dots- per-inch (dpi) value specified in the image file, defaulting to 72 dpi if no value is specified, as is often the case. )partnew_pic_inliner add_drawingr )r"r;r=r?inlines r$ add_picturezRun.add_picture;sB())*>vNN F###6"""r%Nonec8|jdS)zcAdd a ```` element at the end of the run, which Word interprets as a tab character.N)radd_tabr"s r$rIz Run.add_tabSs r%textstrcT|j|}t|S)zReturns a newly appended |_Text| object (corresponding to a new ```` child element) to the run, containing `text`. Compare with the possibly more friendly approach of assigning text to the :attr:`Run.text` property. )radd_t_Text)r"rKts r$add_textz Run.add_textXs" GMM$  Qxxr% bool | Nonec|jjS)aRead/write tri-state value. When |True|, causes the text of the run to appear in bold face. When |False|, the text unconditionally appears non-bold. When |None| the bold setting for this run is inherited from the style hierarchy. fontboldrJs r$rVzRun.boldbsy~r%valuec||j_dSrrTr"rWs r$rVzRun.boldls r%c8|j|S)zoReturn reference to this run after removing all its content. All run formatting is preserved. )r clear_contentrJs r$r7z Run.clearps  r%boolc4t|jjS)a`True` when one or more rendered page-breaks occur in this run. Note that "hard" page-breaks inserted by the author are not included. A hard page-break gives rise to a rendered page-break in the right position so if those were included that page-break would be "double-counted". It would be very rare for multiple rendered page-breaks to occur in a single run, but it is possible. )r\rlastRenderedPageBreaksrJs r$contains_page_breakzRun.contains_page_breakxsDG2333r%rc*t|jS)z{The |Font| object providing access to the character formatting properties for this run, such as font name and size.)rr rJs r$rUzRun.fontsDM"""r%c|jjS)a Read/write tri-state value. When |True|, causes the text of the run to appear in italics. When |False|, the text unconditionally appears non-italic. When |None| the italic setting for this run is inherited from the style hierarchy. rUitalicrJs r$rcz Run.italicsyr%c||j_dSrrbrYs r$rcz Run.italics  r%+Iterator[str | Drawing | RenderedPageBreak]c#K|jjD]k}t|tr|Vt|trt ||VDt|t rt||VldS)a'Generate the content-items in this run in the order they appear. NOTE: only content-types currently supported by `python-docx` are generated. In this version, that is text and rendered page-breaks. Drawing is included but currently only provides access to its XML element (CT_Drawing) on its `._drawing` attribute. `Drawing` attributes and methods may be expanded in future releases. There are a number of element-types that can appear inside a run, but most of those (w:br, w:cr, w:noBreakHyphen, w:t, w:tab) have a clear plain-text equivalent. Any contiguous range of such elements is generated as a single `str`. Rendered page-break and drawing elements are generated individually. Any other elements are ignored. N)rinner_content_items isinstancerLr rr r)r"items r$iter_inner_contentzRun.iter_inner_contentsG/ * *D$$$ * D":;; *'d333333D*-- *dD)))))  * *r%last_run comment_idintcn|j||j|dS)zMark the range of runs from this run to `last_run` (inclusive) as belonging to a comment. `comment_id` identfies the comment that references this range. N)r insert_comment_range_start_above,insert_comment_range_end_and_reference_below)r"rkrls r$mark_comment_rangezRun.mark_comment_ranges8 00<<<  @@LLLLLr%rc|jj}tt|j|t jS)aaRead/write. A |CharacterStyle| object representing the character style applied to this run. The default character style for the document (often `Default Character Font`) is returned if the run has no directly-applied character style. Setting this property to |None| removes any directly-applied character style. )rstylerrrB get_styler CHARACTER)r"style_ids r$rsz Run.styles27=NDI$7$7-BY$Z$Z[[[r% style_or_namestr | CharacterStyle | Nonech|j|tj}||j_dSr)rB get_style_idr rurrs)r"rwrvs r$rsz Run.styles)9))-9PQQ  r%c|jjS)a"String formed by concatenating the text equivalent of each run. Each `` element adds the text characters it contains. A `` element adds a `\t` character. A `` or `` element each add a `\n` character. Note that a `` element can indicate a page break or column break as well as a line break. Only line-break `` elements translate to a `\n` character. Others are ignored. All other content child elements, such as ``, are ignored. Assigning text to this property has the reverse effect, translating each `\t` character to a `` element and each `\n` or `\r` character to a `` element. Any existing run content is replaced. Run formatting is preserved. rrKrJs r$rKzRun.texts w|r%c||j_dSrr|)r"rKs r$rKzRun.texts r%bool | WD_UNDERLINE | Nonec|jjS)aThe underline style for this |Run|. Value is one of |None|, |True|, |False|, or a member of :ref:`WdUnderline`. A value of |None| indicates the run has no directly-applied underline value and so will inherit the underline value of its containing paragraph. Assigning |None| to this property removes any directly-applied underline value. A value of |False| indicates a directly-applied setting of no underline, overriding any inherited value. A value of |True| indicates single underline. The values from :ref:`WdUnderline` are used to specify other outline styles such as double, wavy, and dotted. rU underlinerJs r$rz Run.underlines$y""r%c||j_dSrrrYs r$rz Run.underlines# r%)rrrr)r&r r()r;r<r=r>r?r>r@r )r@rG)rKrL)r@rR)rWrR)r@r\)r@r)r@re)rkrrlrmr@rG)r@r)rwrx)r@rL)r@r~)rWr~)__name__ __module__ __qualname____doc__rr r/r:rFrIrQpropertyrVsetterr7r_rUrcrjrqrsrKr __classcell__r#s@r$rrs{33333308}0&*&* #####0 X [[ 4 4 4X 4###X#    X  ]!!!]!****. M M M M \ \ \X \ \!!!\!X" [[###X#&$$$$$$$$r%rc$eZdZdZdfd ZxZS)rOz&Proxy object wrapping `` element.t_elmrcdtt|||_dSr)rrOr_t)r"rr#s r$rz_Text.__init__s* eT##%%%r%)rr)rrrrrrrs@r$rOrOsC00r%rO)&r __future__rtypingrrrr docx.drawingrdocx.enum.styler docx.enum.textr docx.oxml.drawingr docx.oxml.text.pagebreakr docx.shaper docx.sharedrdocx.styles.stylerdocx.text.fontrdocx.text.pagebreakr docx.typestypesrPrdocx.oxml.text.runrrrrrOr%r$rsCC""""""444444444444 ))))))######((((((======"""""""""""",,,,,,111111#++++++00000000""""""`$`$`$`$`$*`$`$`$Fr%