Files
docx-js/src/file/table/table-row/table-row-properties.ts

60 lines
2.5 KiB
TypeScript
Raw Normal View History

2020-10-24 21:38:20 +01:00
// http://officeopenxml.com/WPtableRowProperties.php
// <xsd:complexType name="CT_TrPrBase">
// <xsd:choice maxOccurs="unbounded">
// <xsd:element name="cnfStyle" type="CT_Cnf" minOccurs="0" maxOccurs="1"/>
// <xsd:element name="divId" type="CT_DecimalNumber" minOccurs="0"/>
// <xsd:element name="gridBefore" type="CT_DecimalNumber" minOccurs="0"/>
// <xsd:element name="gridAfter" type="CT_DecimalNumber" minOccurs="0"/>
// <xsd:element name="wBefore" type="CT_TblWidth" minOccurs="0" maxOccurs="1"/>
// <xsd:element name="wAfter" type="CT_TblWidth" minOccurs="0" maxOccurs="1"/>
// <xsd:element name="cantSplit" type="CT_OnOff" minOccurs="0"/>
// <xsd:element name="trHeight" type="CT_Height" minOccurs="0"/>
// <xsd:element name="tblHeader" type="CT_OnOff" minOccurs="0"/>
// <xsd:element name="tblCellSpacing" type="CT_TblWidth" minOccurs="0" maxOccurs="1"/>
// <xsd:element name="jc" type="CT_JcTable" minOccurs="0" maxOccurs="1"/>
// <xsd:element name="hidden" type="CT_OnOff" minOccurs="0"/>
// </xsd:choice>
// </xsd:complexType>
// <xsd:complexType name="CT_TrPr">
// <xsd:complexContent>
// <xsd:extension base="CT_TrPrBase">
// <xsd:sequence>
// <xsd:element name="ins" type="CT_TrackChange" minOccurs="0"/>
// <xsd:element name="del" type="CT_TrackChange" minOccurs="0"/>
// <xsd:element name="trPrChange" type="CT_TrPrChange" minOccurs="0"/>
// </xsd:sequence>
// </xsd:extension>
// </xsd:complexContent>
// </xsd:complexType>
import { IgnoreIfEmptyXmlComponent, OnOffElement } from "@file/xml-components";
2018-10-23 23:44:50 +01:00
2020-10-24 21:38:20 +01:00
import { HeightRule, TableRowHeight } from "./table-row-height";
export interface ITableRowPropertiesOptions {
readonly cantSplit?: boolean;
readonly tableHeader?: boolean;
readonly height?: {
readonly value: number | string;
readonly rule: HeightRule;
};
}
export class TableRowProperties extends IgnoreIfEmptyXmlComponent {
constructor(options: ITableRowPropertiesOptions) {
2018-10-23 23:44:50 +01:00
super("w:trPr");
if (options.cantSplit !== undefined) {
this.root.push(new OnOffElement("w:cantSplit", options.cantSplit));
}
2019-06-25 12:02:53 +02:00
if (options.tableHeader !== undefined) {
this.root.push(new OnOffElement("w:tblHeader", options.tableHeader));
}
2019-06-25 12:02:53 +02:00
if (options.height) {
this.root.push(new TableRowHeight(options.height.value, options.height.rule));
}
2019-06-25 12:02:53 +02:00
}
}