// http://officeopenxml.com/WPtableProperties.php // // // // // // // // // // // // // // // // // // // // // // import { IgnoreIfEmptyXmlComponent, OnOffElement, StringValueElement } from "@file/xml-components"; import { Alignment, AlignmentType } from "../../paragraph"; import { IShadingAttributesProperties, Shading } from "../../shading"; import { ITableWidthProperties, TableWidthElement } from "../table-width"; import { ITableBordersOptions, TableBorders } from "./table-borders"; import { ITableCellMarginOptions, TableCellMargin, TableCellMarginElementType } from "./table-cell-margin"; import { ITableFloatOptions, TableFloatProperties } from "./table-float-properties"; import { TableLayout, TableLayoutType } from "./table-layout"; export interface ITablePropertiesOptions { readonly width?: ITableWidthProperties; readonly indent?: ITableWidthProperties; readonly layout?: (typeof TableLayoutType)[keyof typeof TableLayoutType]; readonly borders?: ITableBordersOptions; readonly float?: ITableFloatOptions; readonly shading?: IShadingAttributesProperties; readonly style?: string; readonly alignment?: (typeof AlignmentType)[keyof typeof AlignmentType]; readonly cellMargin?: ITableCellMarginOptions; readonly visuallyRightToLeft?: boolean; } export class TableProperties extends IgnoreIfEmptyXmlComponent { public constructor(options: ITablePropertiesOptions) { super("w:tblPr"); if (options.style) { this.root.push(new StringValueElement("w:tblStyle", options.style)); } if (options.float) { this.root.push(new TableFloatProperties(options.float)); } if (options.visuallyRightToLeft !== undefined) { this.root.push(new OnOffElement("w:bidiVisual", options.visuallyRightToLeft)); } if (options.width) { this.root.push(new TableWidthElement("w:tblW", options.width)); } if (options.alignment) { this.root.push(new Alignment(options.alignment)); } if (options.indent) { this.root.push(new TableWidthElement("w:tblInd", options.indent)); } if (options.borders) { this.root.push(new TableBorders(options.borders)); } if (options.shading) { this.root.push(new Shading(options.shading)); } if (options.layout) { this.root.push(new TableLayout(options.layout)); } if (options.cellMargin) { this.root.push(new TableCellMargin(TableCellMarginElementType.TABLE, options.cellMargin)); } } }