2019-11-24 03:22:50 +00:00
|
|
|
// http://officeopenxml.com/WPtableProperties.php
|
2021-05-23 21:17:20 +03:00
|
|
|
//
|
|
|
|
// <xsd:complexType name="CT_TblPrBase">
|
|
|
|
// <xsd:sequence>
|
|
|
|
// <xsd:element name="tblStyle" type="CT_String" minOccurs="0"/>
|
|
|
|
// <xsd:element name="tblpPr" type="CT_TblPPr" minOccurs="0" maxOccurs="1"/>
|
|
|
|
// <xsd:element name="tblOverlap" type="CT_TblOverlap" minOccurs="0" maxOccurs="1"/>
|
|
|
|
// <xsd:element name="bidiVisual" type="CT_OnOff" minOccurs="0" maxOccurs="1"/>
|
|
|
|
// <xsd:element name="tblStyleRowBandSize" type="CT_DecimalNumber" minOccurs="0" maxOccurs="1"/>
|
|
|
|
// <xsd:element name="tblStyleColBandSize" type="CT_DecimalNumber" minOccurs="0" maxOccurs="1"/>
|
|
|
|
// <xsd:element name="tblW" type="CT_TblWidth" minOccurs="0" maxOccurs="1"/>
|
|
|
|
// <xsd:element name="jc" type="CT_JcTable" minOccurs="0" maxOccurs="1"/>
|
|
|
|
// <xsd:element name="tblCellSpacing" type="CT_TblWidth" minOccurs="0" maxOccurs="1"/>
|
|
|
|
// <xsd:element name="tblInd" type="CT_TblWidth" minOccurs="0" maxOccurs="1"/>
|
|
|
|
// <xsd:element name="tblBorders" type="CT_TblBorders" minOccurs="0" maxOccurs="1"/>
|
|
|
|
// <xsd:element name="shd" type="CT_Shd" minOccurs="0" maxOccurs="1"/>
|
|
|
|
// <xsd:element name="tblLayout" type="CT_TblLayoutType" minOccurs="0" maxOccurs="1"/>
|
|
|
|
// <xsd:element name="tblCellMar" type="CT_TblCellMar" minOccurs="0" maxOccurs="1"/>
|
|
|
|
// <xsd:element name="tblLook" type="CT_TblLook" minOccurs="0" maxOccurs="1"/>
|
|
|
|
// <xsd:element name="tblCaption" type="CT_String" minOccurs="0" maxOccurs="1"/>
|
|
|
|
// <xsd:element name="tblDescription" type="CT_String" minOccurs="0" maxOccurs="1"/>
|
|
|
|
// </xsd:sequence>
|
|
|
|
// </xsd:complexType>
|
2022-06-26 23:26:42 +01:00
|
|
|
import { IgnoreIfEmptyXmlComponent, OnOffElement, StringValueElement } from "@file/xml-components";
|
2018-10-23 23:44:50 +01:00
|
|
|
|
2019-11-24 01:22:17 +00:00
|
|
|
import { Alignment, AlignmentType } from "../../paragraph";
|
2021-05-23 04:25:07 +03:00
|
|
|
import { IShadingAttributesProperties, Shading } from "../../shading";
|
2021-05-23 21:17:20 +03:00
|
|
|
import { ITableWidthProperties, TableWidthElement } from "../table-width";
|
2019-11-18 01:04:31 +00:00
|
|
|
import { ITableBordersOptions, TableBorders } from "./table-borders";
|
2021-05-23 21:17:20 +03:00
|
|
|
import { ITableCellMarginOptions, TableCellMargin, TableCellMarginElementType } from "./table-cell-margin";
|
2018-10-23 23:44:50 +01:00
|
|
|
import { ITableFloatOptions, TableFloatProperties } from "./table-float-properties";
|
|
|
|
import { TableLayout, TableLayoutType } from "./table-layout";
|
|
|
|
|
2021-03-04 01:42:58 +00:00
|
|
|
export interface ITablePropertiesOptions {
|
2021-05-23 21:17:20 +03:00
|
|
|
readonly width?: ITableWidthProperties;
|
|
|
|
readonly indent?: ITableWidthProperties;
|
2023-12-22 10:25:00 +09:00
|
|
|
readonly layout?: (typeof TableLayoutType)[keyof typeof TableLayoutType];
|
2021-03-04 01:42:58 +00:00
|
|
|
readonly borders?: ITableBordersOptions;
|
|
|
|
readonly float?: ITableFloatOptions;
|
2021-05-23 04:25:07 +03:00
|
|
|
readonly shading?: IShadingAttributesProperties;
|
2021-03-07 21:40:42 +00:00
|
|
|
readonly style?: string;
|
2023-12-22 10:25:00 +09:00
|
|
|
readonly alignment?: (typeof AlignmentType)[keyof typeof AlignmentType];
|
2021-03-04 01:42:58 +00:00
|
|
|
readonly cellMargin?: ITableCellMarginOptions;
|
2021-03-04 02:02:28 +00:00
|
|
|
readonly visuallyRightToLeft?: boolean;
|
2021-03-04 01:42:58 +00:00
|
|
|
}
|
2018-10-23 23:44:50 +01:00
|
|
|
|
2021-03-04 01:42:58 +00:00
|
|
|
export class TableProperties extends IgnoreIfEmptyXmlComponent {
|
2022-08-31 07:52:27 +01:00
|
|
|
public constructor(options: ITablePropertiesOptions) {
|
2018-10-23 23:44:50 +01:00
|
|
|
super("w:tblPr");
|
|
|
|
|
2021-03-22 05:54:48 +00:00
|
|
|
if (options.style) {
|
2021-05-24 11:28:10 +03:00
|
|
|
this.root.push(new StringValueElement("w:tblStyle", options.style));
|
2021-03-22 05:54:48 +00:00
|
|
|
}
|
|
|
|
|
2021-05-20 01:03:09 +03:00
|
|
|
if (options.float) {
|
|
|
|
this.root.push(new TableFloatProperties(options.float));
|
|
|
|
}
|
2018-10-23 23:44:50 +01:00
|
|
|
|
2021-05-24 11:28:10 +03:00
|
|
|
if (options.visuallyRightToLeft !== undefined) {
|
|
|
|
this.root.push(new OnOffElement("w:bidiVisual", options.visuallyRightToLeft));
|
2021-03-04 01:42:58 +00:00
|
|
|
}
|
2018-10-23 23:44:50 +01:00
|
|
|
|
2021-03-04 01:42:58 +00:00
|
|
|
if (options.width) {
|
2021-05-23 21:17:20 +03:00
|
|
|
this.root.push(new TableWidthElement("w:tblW", options.width));
|
2021-03-04 01:42:58 +00:00
|
|
|
}
|
2018-10-23 23:44:50 +01:00
|
|
|
|
2021-03-04 01:42:58 +00:00
|
|
|
if (options.alignment) {
|
|
|
|
this.root.push(new Alignment(options.alignment));
|
|
|
|
}
|
2019-03-21 01:06:07 +00:00
|
|
|
|
2021-05-23 21:17:20 +03:00
|
|
|
if (options.indent) {
|
|
|
|
this.root.push(new TableWidthElement("w:tblInd", options.indent));
|
|
|
|
}
|
|
|
|
|
2021-05-20 01:03:09 +03:00
|
|
|
if (options.borders) {
|
|
|
|
this.root.push(new TableBorders(options.borders));
|
|
|
|
}
|
|
|
|
|
2021-03-04 01:42:58 +00:00
|
|
|
if (options.shading) {
|
2021-05-23 04:25:07 +03:00
|
|
|
this.root.push(new Shading(options.shading));
|
2021-03-04 01:42:58 +00:00
|
|
|
}
|
2019-03-21 01:06:07 +00:00
|
|
|
|
2021-05-20 01:03:09 +03:00
|
|
|
if (options.layout) {
|
|
|
|
this.root.push(new TableLayout(options.layout));
|
2021-03-04 02:02:28 +00:00
|
|
|
}
|
2021-05-20 01:03:09 +03:00
|
|
|
|
2021-05-23 21:17:20 +03:00
|
|
|
if (options.cellMargin) {
|
|
|
|
this.root.push(new TableCellMargin(TableCellMarginElementType.TABLE, options.cellMargin));
|
|
|
|
}
|
2019-10-21 11:40:05 -05:00
|
|
|
}
|
2018-10-23 23:44:50 +01:00
|
|
|
}
|