;idZddlmZddlmZmZmZddlmZddl m Z ddl m Z ddlmZmZddlmZdd lmZdd lmZdd lmZdd lmZdd lmZerddlmZddlm Z ddl!m"Z"ddl#m$Z$ddl%m&Z&GddeZ'dS)z+|DocumentPart| and closely related objects.) annotations)IO TYPE_CHECKINGcast)Document)RELATIONSHIP_TYPE) CommentsPart) FooterPart HeaderPart) NumberingPart) SettingsPart) StoryPart) StylesPart) InlineShapes) lazyproperty)Comments) WD_STYLE_TYPE)CoreProperties)Settings) BaseStylec6eZdZdZdZdZed'dZed(dZed Z d)d Z d*dZ d+dZ dZ d*dZedZed,dZd-dZed.dZedZed/d!Zed0d#Zed1d%Zd&S)2 DocumentPartaMain document part of a WordprocessingML (WML) package, aka a .docx file. Acts as broker to other parts such as image, core properties, and style parts. It also acts as a convenient delegate when a mid-document object needs a service involving a remote ancestor. The `Parented.part` property inherited by many content objects provides access to this part object for that purpose. c|tj|j}||tj}||fS)z=Return (footer_part, rId) pair for newly-created footer part.)r newpackage relate_toRTFOOTER)self footer_partrIds GC:\PYTHON\MyICR_Workspace\venv\Lib\site-packages\docx/parts/document.pyadd_footer_partzDocumentPart.add_footer_part#3 nT\22 nn[")44Cc|tj|j}||tj}||fS)z=Return (header_part, rId) pair for newly-created header part.)r rrrrHEADER)r header_partr!s r"add_header_partzDocumentPart.add_header_part)r$r%returnrc|jjS)zJ|Comments| object providing access to the comments added to this document.)_comments_partcommentsrs r"r-zDocumentPart.comments/s"++r%rc|jjS)zfA |CoreProperties| object providing read/write access to the core properties of this document.)rcore_propertiesr.s r"r0zDocumentPart.core_properties4s|++r%c,t|j|S)zEA |Document| object providing access to the content of this document.)r_elementr.s r"documentzDocumentPart.document:s t,,,r%r!strNonec0||dS)z/Remove related header part identified by `rId`.N)drop_relrr!s r"drop_header_partzDocumentPart.drop_header_part?s cr%c|j|S)z%Return |FooterPart| related by `rId`. related_partsr8s r"r zDocumentPart.footer_partC!#&&r%style_id str | None style_typerrc8|j||S)zReturn the style in this document matching `style_id`. Returns the default style for `style_type` if `style_id` is |None| or does not match a defined style of `style_type`. )styles get_by_id)rr>r@s r" get_stylezDocumentPart.get_styleGs {$$Xz:::r%c8|j||S)aTReturn the style_id (|str|) of the style of `style_type` matching `style_or_name`. Returns |None| if the style resolves to the default style for `style_type` or if `style_or_name` is itself |None|. Raises if `style_or_name` is a style of the wrong type or names a style not present in the document. )rB get_style_id)r style_or_namer@s r"rFzDocumentPart.get_style_idOs{'' zBBBr%c|j|S)z%Return |HeaderPart| related by `rId`.r;r8s r"r(zDocumentPart.header_partYr=r%c6t|jj|S)zIThe |InlineShapes| instance containing the inline shapes in the document.)rr2bodyr.s r" inline_shapeszDocumentPart.inline_shapes]sDM.555r%r c tt|tjS#t $r8tj}||tj|cYSwxYw)zA |NumberingPart| object providing access to the numbering definitions for this document. Creates an empty numbering part if one is not present. )rr part_related_byr NUMBERINGKeyErrorrr)rnumbering_parts r"rPzDocumentPart.numbering_partbsr  " t';';BL'I'IJJ J " " "*.00N NN>2< 8 8 8! ! ! ! "s14?A65A6path_or_streamstr | IO[bytes]c:|j|dS)zSave this document to `path_or_stream`, which can be either a path to a filesystem location (a string) or a file-like object.N)rsave)rrQs r"rTzDocumentPart.saveos  .)))))r%rc|jjS)zcA |Settings| object providing access to the settings in the settings part of this document.)_settings_partsettingsr.s r"rWzDocumentPart.settingsts"++r%c|jjS)z]A |Styles| object providing access to the styles in the styles part of this document.) _styles_partrBr.s r"rBzDocumentPart.styleszs ''r%r c tt|tjS#t $rG|jJtj|j}||tj|cYSwxYw)zA |CommentsPart| object providing access to the comments added to this document. Creates a default comments part if one is not present. ) rr rMrCOMMENTSrOrdefaultr)r comments_parts r"r,zDocumentPart._comments_parts  ! d&:&:2;&G&GHH H ! ! !<+++(0>>M NN="+ 6 6 6  !s14ABBr c tt|tjS#t $r>tj|j}||tj|cYSwxYw)zA |SettingsPart| object providing access to the document-level settings for this document. Creates a default settings part if one is not present. ) rr rMrSETTINGSrOr\rr)r settings_parts r"rVzDocumentPart._settings_partsv ! d&:&:2;&G&GHH H ! ! !(0>>M NN="+ 6 6 6  !s14AA<;A<rc  tt|tjS#t $rD|j}|Jtj|}||tj|cYSwxYw)zqInstance of |StylesPart| for this document. Creates an empty styles part if one is not present. ) rrrMrSTYLESrOrr\r)rr styles_parts r"rYzDocumentPart._styles_parts   D$8$8$C$CDD D   lG&&&$,W55K NN; 2 2 2     s14A BBN)r*r)r*r)r!r4r*r5)r!r4)r>r?r@rr*r)r*r )rQrR)r*r)r*r )r*r )r*r)__name__ __module__ __qualname____doc__r#r)propertyr-r0r3r9r rDrFr(rrKrPrTrWrBr,rVrYr%r"rrs      ,,,X,,,,X, --X-'''';;;;CCC''''66\6 " " "\ "**** ,,,X, ((X(  ! ! !X ! ! ! !X !   X   r%rN)(rg __future__rtypingrrr docx.documentrdocx.opc.constantsrrdocx.parts.commentsr docx.parts.hdrftrr r docx.parts.numberingr docx.parts.settingsr docx.parts.storyrdocx.parts.stylesr docx.shaper docx.sharedr docx.commentsrdocx.enum.stylerdocx.opc.corepropsr docx.settingsrdocx.styles.stylerrrir%r"r{s11""""""**********""""""666666,,,,,,44444444......,,,,,,&&&&&&((((((######$$$$$$,&&&&&&------111111&&&&&&++++++OOOOO9OOOOOr%