;i0dZddlmZddlZddlmZmZmZddl m Z ddl m Z ddl mZmZmZddlmZmZmZmZer dd lmZdd lmZGd d eZGd deZdS)z4Custom element classes related to document comments.) annotationsN) TYPE_CHECKINGCallablecast)nsdecls) parse_xml) ST_DateTimeST_DecimalNumber ST_String)BaseOxmlElementOptionalAttributeRequiredAttribute ZeroOrMore)CT_Tbl)CT_PcLeZdZUdZded<edZddZdd Zdd Z d S) CT_Commentsa`w:comments` element, the root element for the comments part. Simply contains a collection of `w:comment` elements, each representing a single comment. Each contained comment is identified by a unique `w:id` attribute, used to reference the comment from the document text. The offset of the comment in this collection is arbitrary; it is essentially a _set_ implemented as a list. zlist[CT_Comment] comment_lstz w:commentreturn CT_Commentc |}tttdt dd|d}|||S)aReturn newly added `w:comment` child of this `w:comments`. The returned `w:comment` element is the minimum valid value, having a `w:id` value unique within the existing comments and the required `w:author` attribute present but set to the empty string. It's content is limited to a single run containing the necessary annotation reference but no text. Content is added by adding runs to this first paragraph and by adding additional paragraphs as needed. z )_next_available_comment_idrrrrappend)selfnext_idcomments FC:\PYTHON\MyICR_Workspace\venv\Lib\site-packages\docx/oxml/comments.py add_commentzCT_Comments.add_comment su1133    gcll   7        $ G comment_idintCT_Comment | NonecL|d|d}|r|dndS)zRReturn the `w:comment` element identified by `comment_id`, or |None| if not found.z(./w:comment[@w:id='z'])[1]rNxpath)rr! comment_elmss rget_comment_by_idzCT_Comments.get_comment_by_id?s2zz"K"K"K"KLL ".8|AD8r cd|dD}t|ddz}|dkr|Stt|D]\}}||kr|cSt |S)anThe next available comment id. According to the schema, this can be any positive integer, as big as you like, and the default mechanism is to use `max() + 1`. However, if that yields a value larger than will fit in a 32-bit signed integer, we take a more deliberate approach to use the first ununsed integer starting from 0. c,g|]}t|S)r").0xs r z:CT_Comments._next_available_comment_id..LsDDDqCFFDDDr z./w:comment/@w:id)defaulti)r&max enumeratesortedlen)rused_idsrexpectedactuals rrz&CT_Comments._next_available_comment_idDsEDDJJ/B$C$CDDDh+++a/ i  N!*&*:*: ; ;  Hf6!!"8}}r N)rr)r!r"rr#)rr") __name__ __module__ __qualname____doc____annotations__rrrr(rr+r rrrsy"!!!j%%G>9999 r rceZdZUdZedeZded<edeZ ded<e deZ d ed <e d e Z d ed <eddZeddZded<ded<ded<ded<eddZdS)raQ`w:comment` element, representing a single comment. A comment is a so-called "story" and can contain paragraphs and tables much like a table-cell. While probably most often used for a single sentence or phrase, a comment can contain rich content, including multiple rich-text paragraphs, hyperlinks, images, and tables. zw:idr"idzw:authorstrauthorz w:initialsz str | Noneinitialszw:datezdt.datetime | Nonedatezw:pr+) successorszw:tblzCallable[[], CT_P]add_pz list[CT_P]p_lstz list[CT_Tbl]tbl_lstzCallable[[CT_Tbl], CT_Tbl] _insert_tblrlist[CT_P | CT_Tbl]c,|dS)z8Generate all `w:p` and `w:tbl` elements in this comment.z./w:p | ./w:tblr%)rs rinner_content_elementsz!CT_Comment.inner_content_elementsyszz+,,,r N)rrI)r9r:r;r<rr r?r=r rAr rBr rCrptblpropertyrKr+r rrr[s1 (899B9999##J ::F::::,,iH 10+  D  5R(((A *W , , ,C++++ ---X---r r)r< __future__rdatetimedttypingrrr docx.oxml.nsrdocx.oxml.parserrdocx.oxml.simpletypesr r r docx.oxml.xmlchemyr r rrdocx.oxml.tablerdocx.oxml.text.paragraphrrrr+r rrYs@::""""""0000000000 &&&&&&JJJJJJJJJJ````````````.&&&&&&------FFFFF/FFFR!-!-!-!-!-!-!-!-!-!-r