remove more duplicate classes; add additional values functions; clean up tests

This commit is contained in:
Tom Hunkapiller
2021-05-24 11:28:10 +03:00
parent a56119e7cd
commit ce2a0fb864
38 changed files with 311 additions and 362 deletions

View File

@ -1,5 +1,33 @@
// http://officeopenxml.com/WPtableRowProperties.php
import { IgnoreIfEmptyXmlComponent, XmlAttributeComponent, XmlComponent } from "file/xml-components";
// <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";
import { HeightRule, TableRowHeight } from "./table-row-height";
@ -7,7 +35,7 @@ export interface ITableRowPropertiesOptions {
readonly cantSplit?: boolean;
readonly tableHeader?: boolean;
readonly height?: {
readonly value: number;
readonly value: number | string;
readonly rule: HeightRule;
};
}
@ -16,12 +44,12 @@ export class TableRowProperties extends IgnoreIfEmptyXmlComponent {
constructor(options: ITableRowPropertiesOptions) {
super("w:trPr");
if (options.cantSplit) {
this.root.push(new CantSplit());
if (options.cantSplit !== undefined) {
this.root.push(new OnOffElement("w:cantSplit", options.cantSplit));
}
if (options.tableHeader) {
this.root.push(new TableHeader());
if (options.tableHeader !== undefined) {
this.root.push(new OnOffElement("w:tblHeader", options.tableHeader));
}
if (options.height) {
@ -29,25 +57,3 @@ export class TableRowProperties extends IgnoreIfEmptyXmlComponent {
}
}
}
class CantSplitAttributes extends XmlAttributeComponent<{ readonly val: boolean }> {
protected readonly xmlKeys = { val: "w:val" };
}
export class CantSplit extends XmlComponent {
constructor() {
super("w:cantSplit");
this.root.push(new CantSplitAttributes({ val: true }));
}
}
class TableHeaderAttributes extends XmlAttributeComponent<{ readonly val: boolean }> {
protected readonly xmlKeys = { val: "w:val" };
}
export class TableHeader extends XmlComponent {
constructor() {
super("w:tblHeader");
this.root.push(new TableHeaderAttributes({ val: true }));
}
}