`` `` element, the root element of a numbering part, i.e. numbering.xml.
| 76 | |
| 77 | |
| 78 | class CT_Numbering(BaseOxmlElement): |
| 79 | """``<w:numbering>`` element, the root element of a numbering part, i.e. |
| 80 | numbering.xml.""" |
| 81 | |
| 82 | num = ZeroOrMore("w:num", successors=("w:numIdMacAtCleanup",)) |
| 83 | |
| 84 | def add_num(self, abstractNum_id): |
| 85 | """Return a newly added CT_Num (<w:num>) element referencing the abstract |
| 86 | numbering definition identified by `abstractNum_id`.""" |
| 87 | next_num_id = self._next_numId |
| 88 | num = CT_Num.new(next_num_id, abstractNum_id) |
| 89 | return self._insert_num(num) |
| 90 | |
| 91 | def num_having_numId(self, numId): |
| 92 | """Return the ``<w:num>`` child element having ``numId`` attribute matching |
| 93 | `numId`.""" |
| 94 | xpath = './w:num[@w:numId="%d"]' % numId |
| 95 | try: |
| 96 | return self.xpath(xpath)[0] |
| 97 | except IndexError: |
| 98 | raise KeyError("no <w:num> element with numId %d" % numId) |
| 99 | |
| 100 | @property |
| 101 | def _next_numId(self): |
| 102 | """The first ``numId`` unused by a ``<w:num>`` element, starting at 1 and |
| 103 | filling any gaps in numbering between existing ``<w:num>`` elements.""" |
| 104 | numId_strs = self.xpath("./w:num/@w:numId") |
| 105 | num_ids = [int(numId_str) for numId_str in numId_strs] |
| 106 | for num in range(1, len(num_ids) + 2): |
| 107 | if num not in num_ids: |
| 108 | break |
| 109 | return num |
nothing calls this directly
no test coverage detected
searching dependent graphs…