MCPcopy Index your code
hub / github.com/python-openxml/python-docx / _grow_to

Method _grow_to

src/docx/oxml/table.py:575–596  ·  view source on GitHub ↗

Grow this cell to `width` grid columns and `height` rows. This is accomplished by expanding horizontal spans and creating continuation cells to form vertical spans.

(self, width: int, height: int, top_tc: CT_Tc | None = None)

Source from the content-addressed store, hash-verified

573 self.width = Length(self.width + other_tc.width)
574
575 def _grow_to(self, width: int, height: int, top_tc: CT_Tc | None = None):
576 """Grow this cell to `width` grid columns and `height` rows.
577
578 This is accomplished by expanding horizontal spans and creating continuation
579 cells to form vertical spans.
580 """
581
582 def vMerge_val(top_tc: CT_Tc):
583 return (
584 ST_Merge.CONTINUE
585 if top_tc is not self
586 else None
587 if height == 1
588 else ST_Merge.RESTART
589 )
590
591 top_tc = self if top_tc is None else top_tc
592 self._span_to_width(width, top_tc, vMerge_val(top_tc))
593 if height > 1:
594 tc_below = self._tc_below
595 assert tc_below is not None
596 tc_below._grow_to(width, height - 1, top_tc)
597
598 def _insert_tcPr(self, tcPr: CT_TcPr) -> CT_TcPr:
599 """Override default `._insert_tcPr()`."""

Callers 2

mergeMethod · 0.80

Calls 1

_span_to_widthMethod · 0.95

Tested by 1