2019-06-25 12:02:53 +02:00
|
|
|
import { HeightRule } from "file/table/table-row/table-row-height";
|
2018-10-23 23:44:50 +01:00
|
|
|
import { XmlComponent } from "file/xml-components";
|
|
|
|
import { TableCell } from "../table-cell";
|
|
|
|
import { TableRowProperties } from "./table-row-properties";
|
|
|
|
|
2019-09-13 00:51:20 +01:00
|
|
|
export interface ITableRowOptions {
|
|
|
|
readonly cantSplit?: boolean;
|
|
|
|
readonly tableHeader?: boolean;
|
|
|
|
readonly height?: {
|
|
|
|
readonly height: number;
|
|
|
|
readonly rule: HeightRule;
|
|
|
|
};
|
|
|
|
readonly children: TableCell[];
|
|
|
|
}
|
|
|
|
|
2018-10-23 23:44:50 +01:00
|
|
|
export class TableRow extends XmlComponent {
|
|
|
|
private readonly properties: TableRowProperties;
|
|
|
|
|
2019-09-13 00:51:20 +01:00
|
|
|
constructor(private readonly options: ITableRowOptions) {
|
2018-10-23 23:44:50 +01:00
|
|
|
super("w:tr");
|
|
|
|
this.properties = new TableRowProperties();
|
|
|
|
this.root.push(this.properties);
|
|
|
|
|
2019-09-13 00:51:20 +01:00
|
|
|
for (const child of options.children) {
|
|
|
|
this.root.push(child);
|
2018-10-23 23:44:50 +01:00
|
|
|
}
|
|
|
|
|
2019-09-13 00:51:20 +01:00
|
|
|
if (options.cantSplit) {
|
|
|
|
this.properties.setCantSplit();
|
|
|
|
}
|
2018-10-23 23:44:50 +01:00
|
|
|
|
2019-09-13 00:51:20 +01:00
|
|
|
if (options.tableHeader) {
|
|
|
|
this.properties.setTableHeader();
|
|
|
|
}
|
2018-10-23 23:44:50 +01:00
|
|
|
|
2019-09-13 00:51:20 +01:00
|
|
|
if (options.height) {
|
|
|
|
this.properties.setHeight(options.height.height, options.height.rule);
|
|
|
|
}
|
2018-10-23 23:44:50 +01:00
|
|
|
}
|
2019-02-05 15:47:09 +01:00
|
|
|
|
2019-09-13 00:51:20 +01:00
|
|
|
public get CellCount(): number {
|
|
|
|
return this.options.children.length;
|
2019-02-05 15:47:09 +01:00
|
|
|
}
|
|
|
|
|
2019-09-22 02:39:38 +01:00
|
|
|
public get Children(): TableCell[] {
|
|
|
|
return this.options.children;
|
|
|
|
}
|
2018-10-23 23:44:50 +01:00
|
|
|
}
|