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

56 lines
1.8 KiB
TypeScript
Raw Normal View History

2019-11-24 03:22:50 +00:00
// http://officeopenxml.com/WPtableProperties.php
import { IgnoreIfEmptyXmlComponent } 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";
2019-03-21 01:06:07 +00:00
import { ITableShadingAttributesProperties, TableShading } from "../shading";
2018-10-23 23:44:50 +01:00
import { WidthType } from "../table-cell";
2019-11-18 01:04:31 +00:00
import { ITableBordersOptions, TableBorders } from "./table-borders";
2018-10-23 23:44:50 +01:00
import { TableCellMargin } from "./table-cell-margin";
import { ITableFloatOptions, TableFloatProperties } from "./table-float-properties";
import { TableLayout, TableLayoutType } from "./table-layout";
import { PreferredTableWidth } from "./table-width";
export class TableProperties extends IgnoreIfEmptyXmlComponent {
2018-10-23 23:44:50 +01:00
private readonly cellMargin: TableCellMargin;
constructor() {
super("w:tblPr");
this.cellMargin = new TableCellMargin();
this.root.push(this.cellMargin);
}
2019-03-04 22:50:04 +00:00
public setWidth(width: number, type: WidthType = WidthType.AUTO): TableProperties {
this.root.push(new PreferredTableWidth(type, width));
2018-10-23 23:44:50 +01:00
return this;
}
2019-06-25 20:57:46 +01:00
public setLayout(type: TableLayoutType): void {
this.root.push(new TableLayout(type));
2018-10-23 23:44:50 +01:00
}
2019-11-18 01:04:31 +00:00
public setBorder(borderOptions: ITableBordersOptions): TableProperties {
this.root.push(new TableBorders(borderOptions));
2018-10-23 23:44:50 +01:00
return this;
}
public get CellMargin(): TableCellMargin {
return this.cellMargin;
}
public setTableFloatProperties(tableFloatOptions: ITableFloatOptions): TableProperties {
this.root.push(new TableFloatProperties(tableFloatOptions));
return this;
}
2019-03-21 01:06:07 +00:00
public setShading(attrs: ITableShadingAttributesProperties): TableProperties {
this.root.push(new TableShading(attrs));
return this;
}
2019-11-24 01:22:17 +00:00
public setAlignment(type: AlignmentType): void {
this.root.push(new Alignment(type));
}
2018-10-23 23:44:50 +01:00
}