`a:tc` custom element class
| 174 | |
| 175 | |
| 176 | class CT_TableCell(BaseOxmlElement): |
| 177 | """`a:tc` custom element class""" |
| 178 | |
| 179 | get_or_add_tcPr: Callable[[], CT_TableCellProperties] |
| 180 | get_or_add_txBody: Callable[[], CT_TextBody] |
| 181 | |
| 182 | _tag_seq = ("a:txBody", "a:tcPr", "a:extLst") |
| 183 | txBody: CT_TextBody | None = ZeroOrOne( # pyright: ignore[reportAssignmentType] |
| 184 | "a:txBody", successors=_tag_seq[1:] |
| 185 | ) |
| 186 | tcPr: CT_TableCellProperties | None = ZeroOrOne( # pyright: ignore[reportAssignmentType] |
| 187 | "a:tcPr", successors=_tag_seq[2:] |
| 188 | ) |
| 189 | del _tag_seq |
| 190 | |
| 191 | gridSpan: int = OptionalAttribute( # pyright: ignore[reportAssignmentType] |
| 192 | "gridSpan", XsdInt, default=1 |
| 193 | ) |
| 194 | rowSpan: int = OptionalAttribute( # pyright: ignore[reportAssignmentType] |
| 195 | "rowSpan", XsdInt, default=1 |
| 196 | ) |
| 197 | hMerge: bool = OptionalAttribute( # pyright: ignore[reportAssignmentType] |
| 198 | "hMerge", XsdBoolean, default=False |
| 199 | ) |
| 200 | vMerge: bool = OptionalAttribute( # pyright: ignore[reportAssignmentType] |
| 201 | "vMerge", XsdBoolean, default=False |
| 202 | ) |
| 203 | |
| 204 | @property |
| 205 | def anchor(self) -> MSO_VERTICAL_ANCHOR | None: |
| 206 | """String held in `anchor` attribute of `a:tcPr` child element of this `a:tc` element.""" |
| 207 | if self.tcPr is None: |
| 208 | return None |
| 209 | return self.tcPr.anchor |
| 210 | |
| 211 | @anchor.setter |
| 212 | def anchor(self, anchor_enum_idx: MSO_VERTICAL_ANCHOR | None): |
| 213 | """Set value of anchor attribute on `a:tcPr` child element.""" |
| 214 | if anchor_enum_idx is None and self.tcPr is None: |
| 215 | return |
| 216 | tcPr = self.get_or_add_tcPr() |
| 217 | tcPr.anchor = anchor_enum_idx |
| 218 | |
| 219 | def append_ps_from(self, spanned_tc: CT_TableCell): |
| 220 | """Append `a:p` elements taken from `spanned_tc`. |
| 221 | |
| 222 | Any non-empty paragraph elements in `spanned_tc` are removed and appended to the |
| 223 | text-frame of this cell. If `spanned_tc` is left with no content after this process, a |
| 224 | single empty `a:p` element is added to ensure the cell is compliant with the spec. |
| 225 | """ |
| 226 | source_txBody = spanned_tc.get_or_add_txBody() |
| 227 | target_txBody = self.get_or_add_txBody() |
| 228 | |
| 229 | # ---if source is empty, there's nothing to do--- |
| 230 | if source_txBody.is_empty: |
| 231 | return |
| 232 | |
| 233 | # ---a single empty paragraph in target is overwritten--- |
nothing calls this directly
no test coverage detected
searching dependent graphs…