import { XmlAttributeComponent, XmlComponent } from "@file/xml-components";
import { decimalNumber, twipsMeasureValue } from "@util/values";
import { Column } from "./column";
//
//
//
//
//
//
//
//
//
export interface IColumnsAttributes {
readonly space?: number | string;
readonly count?: number;
readonly separate?: boolean;
readonly equalWidth?: boolean;
readonly children?: Column[];
}
export class ColumnsAttributes extends XmlAttributeComponent {
protected readonly xmlKeys = {
space: "w:space",
count: "w:num",
separate: "w:sep",
equalWidth: "w:equalWidth",
};
}
export class Columns extends XmlComponent {
public constructor({ space, count, separate, equalWidth, children }: IColumnsAttributes) {
super("w:cols");
this.root.push(
new ColumnsAttributes({
space: space === undefined ? undefined : twipsMeasureValue(space),
count: count === undefined ? undefined : decimalNumber(count),
separate,
equalWidth,
}),
);
if (!equalWidth && children) {
children.forEach((column) => this.addChildElement(column));
}
}
}