2021-05-23 21:17:20 +03:00
|
|
|
import { IgnoreIfEmptyXmlComponent } from "file/xml-components";
|
|
|
|
import { TableWidthElement, WidthType } from "../table-width";
|
2018-10-23 23:44:50 +01:00
|
|
|
|
2021-05-23 21:17:20 +03:00
|
|
|
export interface ITableCellMarginOptions {
|
|
|
|
readonly marginUnitType?: WidthType;
|
|
|
|
readonly top?: number;
|
|
|
|
readonly bottom?: number;
|
|
|
|
readonly left?: number;
|
|
|
|
readonly right?: number;
|
2018-08-23 00:55:33 +01:00
|
|
|
}
|
|
|
|
|
2021-05-23 21:17:20 +03:00
|
|
|
// Technically two different types, but they're identical
|
|
|
|
//
|
|
|
|
// <xsd:complexType name="CT_TcMar">
|
|
|
|
// <xsd:sequence>
|
|
|
|
// <xsd:element name="top" type="CT_TblWidth" minOccurs="0" maxOccurs="1"/>
|
|
|
|
// <xsd:element name="start" type="CT_TblWidth" minOccurs="0" maxOccurs="1"/>
|
|
|
|
// <xsd:element name="left" type="CT_TblWidth" minOccurs="0"/>
|
|
|
|
// <xsd:element name="bottom" type="CT_TblWidth" minOccurs="0" maxOccurs="1"/>
|
|
|
|
// <xsd:element name="end" type="CT_TblWidth" minOccurs="0" maxOccurs="1"/>
|
|
|
|
// <xsd:element name="right" type="CT_TblWidth" minOccurs="0"/>
|
|
|
|
// </xsd:sequence>
|
|
|
|
// </xsd:complexType>
|
|
|
|
|
|
|
|
// <xsd:complexType name="CT_TblCellMar">
|
|
|
|
// <xsd:sequence>
|
|
|
|
// <xsd:element name="top" type="CT_TblWidth" minOccurs="0" maxOccurs="1"/>
|
|
|
|
// <xsd:element name="start" type="CT_TblWidth" minOccurs="0" maxOccurs="1"/>
|
|
|
|
// <xsd:element name="left" type="CT_TblWidth" minOccurs="0"/>
|
|
|
|
// <xsd:element name="bottom" type="CT_TblWidth" minOccurs="0" maxOccurs="1"/>
|
|
|
|
// <xsd:element name="end" type="CT_TblWidth" minOccurs="0" maxOccurs="1"/>
|
|
|
|
// <xsd:element name="right" type="CT_TblWidth" minOccurs="0"/>
|
|
|
|
// </xsd:sequence>
|
|
|
|
// </xsd:complexType>
|
|
|
|
|
|
|
|
export enum TableCellMarginElementType {
|
|
|
|
TABLE = "w:tblCellMar",
|
|
|
|
TABLE_CELL = "w:tcMar",
|
2021-03-04 01:42:58 +00:00
|
|
|
}
|
|
|
|
|
2019-04-09 05:27:18 -04:00
|
|
|
export class TableCellMargin extends IgnoreIfEmptyXmlComponent {
|
2021-05-23 21:17:20 +03:00
|
|
|
constructor(type: TableCellMarginElementType, { marginUnitType = WidthType.DXA, top, left, bottom, right }: ITableCellMarginOptions) {
|
|
|
|
super(type);
|
2018-08-23 00:55:33 +01:00
|
|
|
|
2021-05-23 21:17:20 +03:00
|
|
|
if (top !== undefined) {
|
|
|
|
this.root.push(new TableWidthElement("w:top", { type: marginUnitType, size: top }));
|
2021-03-04 01:42:58 +00:00
|
|
|
}
|
2018-08-23 00:55:33 +01:00
|
|
|
|
2021-05-23 21:17:20 +03:00
|
|
|
if (left !== undefined) {
|
|
|
|
this.root.push(new TableWidthElement("w:left", { type: marginUnitType, size: left }));
|
2021-03-04 01:42:58 +00:00
|
|
|
}
|
2018-08-23 00:55:33 +01:00
|
|
|
|
2021-05-23 21:17:20 +03:00
|
|
|
if (bottom !== undefined) {
|
|
|
|
this.root.push(new TableWidthElement("w:bottom", { type: marginUnitType, size: bottom }));
|
2021-05-20 01:03:09 +03:00
|
|
|
}
|
|
|
|
|
2021-05-23 21:17:20 +03:00
|
|
|
if (right !== undefined) {
|
|
|
|
this.root.push(new TableWidthElement("w:right", { type: marginUnitType, size: right }));
|
2021-03-04 01:42:58 +00:00
|
|
|
}
|
2018-08-23 00:55:33 +01:00
|
|
|
}
|
|
|
|
}
|