2019-04-09 05:27:18 -04:00
|
|
|
import { IgnoreIfEmptyXmlComponent } from "file/xml-components";
|
2018-10-23 23:44:50 +01:00
|
|
|
|
2019-03-21 01:06:07 +00:00
|
|
|
import { ITableShadingAttributesProperties, TableShading } from "../shading";
|
2019-04-18 13:55:18 +10:00
|
|
|
import { ITableCellMarginOptions, TableCellMargin } from "./cell-margin/table-cell-margins";
|
2019-09-26 02:03:17 +01:00
|
|
|
import {
|
|
|
|
GridSpan,
|
|
|
|
TableCellBorders,
|
|
|
|
TableCellWidth,
|
|
|
|
VAlign,
|
|
|
|
VerticalAlign,
|
|
|
|
VerticalMerge,
|
|
|
|
VerticalMergeType,
|
|
|
|
WidthType,
|
|
|
|
} from "./table-cell-components";
|
2018-10-23 23:44:50 +01:00
|
|
|
|
2019-04-09 05:27:18 -04:00
|
|
|
export class TableCellProperties extends IgnoreIfEmptyXmlComponent {
|
2018-10-23 23:44:50 +01:00
|
|
|
private readonly cellBorder: TableCellBorders;
|
|
|
|
|
|
|
|
constructor() {
|
|
|
|
super("w:tcPr");
|
|
|
|
this.cellBorder = new TableCellBorders();
|
|
|
|
this.root.push(this.cellBorder);
|
|
|
|
}
|
|
|
|
|
|
|
|
public get Borders(): TableCellBorders {
|
|
|
|
return this.cellBorder;
|
|
|
|
}
|
|
|
|
|
|
|
|
public addGridSpan(cellSpan: number): TableCellProperties {
|
|
|
|
this.root.push(new GridSpan(cellSpan));
|
|
|
|
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2019-09-26 02:03:17 +01:00
|
|
|
public addVerticalMerge(type: VerticalMergeType): TableCellProperties {
|
|
|
|
this.root.push(new VerticalMerge(type));
|
2018-10-23 23:44:50 +01:00
|
|
|
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public setVerticalAlign(type: VerticalAlign): TableCellProperties {
|
|
|
|
this.root.push(new VAlign(type));
|
|
|
|
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2018-11-15 03:00:26 +00:00
|
|
|
public setWidth(width: string | number, type: WidthType = WidthType.AUTO): TableCellProperties {
|
2018-10-23 23:44:50 +01:00
|
|
|
this.root.push(new TableCellWidth(width, type));
|
|
|
|
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2019-03-21 01:06:07 +00:00
|
|
|
public setShading(attrs: ITableShadingAttributesProperties): TableCellProperties {
|
|
|
|
this.root.push(new TableShading(attrs));
|
2018-10-23 23:44:50 +01:00
|
|
|
|
|
|
|
return this;
|
|
|
|
}
|
2019-03-18 23:50:21 +00:00
|
|
|
|
2019-04-18 13:55:18 +10:00
|
|
|
public addMargins(options: ITableCellMarginOptions): TableCellProperties {
|
|
|
|
this.root.push(new TableCellMargin(options));
|
2019-03-18 23:50:21 +00:00
|
|
|
|
|
|
|
return this;
|
|
|
|
}
|
2018-10-23 23:44:50 +01:00
|
|
|
}
|