add an ability to specify charSpace and type for DocumentGrid

This commit is contained in:
Katz Sakai
2021-11-30 21:11:06 +09:00
parent 75d62723b6
commit e08ad990a8
4 changed files with 50 additions and 4 deletions

View File

@ -16,22 +16,36 @@ import { XmlAttributeComponent, XmlComponent } from "file/xml-components";
// <xsd:attribute name="linePitch" type="ST_DecimalNumber"/>
// <xsd:attribute name="charSpace" type="ST_DecimalNumber"/>
// </xsd:complexType>
export enum DocumentGridType {
DEFAULT = "default",
LINES = "lines",
LINES_AND_CHARS = "linesAndChars",
SNAP_TO_CHARS = "snapToChars",
}
export interface IDocGridAttributesProperties {
readonly type?: DocumentGridType;
readonly linePitch?: number;
readonly charSpace?: number;
}
export class DocGridAttributes extends XmlAttributeComponent<IDocGridAttributesProperties> {
protected readonly xmlKeys = {
type: "w:type",
linePitch: "w:linePitch",
charSpace: "w:charSpace",
};
}
export class DocumentGrid extends XmlComponent {
constructor(linePitch: number) {
constructor(linePitch: number, charSpace?: number, type?: DocumentGridType) {
super("w:docGrid");
this.root.push(
new DocGridAttributes({
type: type,
linePitch: decimalNumber(linePitch),
charSpace: charSpace ? decimalNumber(charSpace) : undefined,
}),
);
}