Skip to content

Commit 6cd7cd8

Browse files
author
Steve Canny
committed
oxml: convert CT_TblGrid to xmlchemy
1 parent a6e6d46 commit 6cd7cd8

File tree

1 file changed

+1
-43
lines changed

1 file changed

+1
-43
lines changed

docx/oxml/table.py

Lines changed: 1 addition & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -50,21 +50,7 @@ class CT_TblGrid(BaseOxmlElement):
5050
``<w:tblGrid>`` element, child of ``<w:tbl>``, holds ``<w:gridCol>``
5151
elements that define column count, width, etc.
5252
"""
53-
def add_gridCol(self):
54-
"""
55-
Return a new <w:gridCol> element that has been added at the end of
56-
any existing gridCol elements.
57-
"""
58-
gridCol = CT_TblGridCol.new()
59-
return self._append_gridCol(gridCol)
60-
61-
@property
62-
def gridCol_lst(self):
63-
"""
64-
Sequence containing the ``<w:gridCol>`` child elements in this
65-
``<w:tblGrid>``.
66-
"""
67-
return self.findall(qn('w:gridCol'))
53+
gridCol = ZeroOrMore('w:gridCol', successors=('w:tblGridChange',))
6854

6955
@classmethod
7056
def new(cls):
@@ -73,40 +59,12 @@ def new(cls):
7359
"""
7460
return OxmlElement('w:tblGrid')
7561

76-
def _append_gridCol(self, gridCol):
77-
"""
78-
Return *gridCol* after appending it to end of gridCol sequence.
79-
"""
80-
successor = self.first_child_found_in('w:tblGridChange')
81-
if successor is not None:
82-
successor.addprevious(gridCol)
83-
else:
84-
self.append(gridCol)
85-
return gridCol
86-
87-
def first_child_found_in(self, *tagnames):
88-
"""
89-
Return the first child found with tag in *tagnames*, or None if
90-
not found.
91-
"""
92-
for tagname in tagnames:
93-
child = self.find(qn(tagname))
94-
if child is not None:
95-
return child
96-
return None
97-
9862

9963
class CT_TblGridCol(BaseOxmlElement):
10064
"""
10165
``<w:gridCol>`` element, child of ``<w:tblGrid>``, defines a table
10266
column.
10367
"""
104-
@classmethod
105-
def new(cls):
106-
"""
107-
Return a new ``<w:gridCol>`` element.
108-
"""
109-
return OxmlElement('w:gridCol')
11068

11169

11270
class CT_TblPr(BaseOxmlElement):

0 commit comments

Comments
 (0)