2022-06-26 23:26:42 +01:00
|
|
|
import { XmlAttributeComponent, XmlComponent } from "@file/xml-components";
|
|
|
|
import { decimalNumber } from "@util/values";
|
2021-05-25 03:41:12 +03:00
|
|
|
|
|
|
|
// not implemented
|
|
|
|
// <xsd:simpleType name="ST_DocGrid">
|
|
|
|
// <xsd:restriction base="xsd:string">
|
|
|
|
// <xsd:enumeration value="default"/>
|
|
|
|
// <xsd:enumeration value="lines"/>
|
|
|
|
// <xsd:enumeration value="linesAndChars"/>
|
|
|
|
// <xsd:enumeration value="snapToChars"/>
|
|
|
|
// </xsd:restriction>
|
|
|
|
// </xsd:simpleType>
|
|
|
|
|
|
|
|
// <xsd:complexType name="CT_DocGrid">
|
|
|
|
// <xsd:attribute name="type" type="ST_DocGrid"/>
|
|
|
|
// <xsd:attribute name="linePitch" type="ST_DecimalNumber"/>
|
|
|
|
// <xsd:attribute name="charSpace" type="ST_DecimalNumber"/>
|
|
|
|
// </xsd:complexType>
|
2021-11-30 21:11:06 +09:00
|
|
|
|
2023-12-22 10:25:00 +09:00
|
|
|
/* eslint-disable @typescript-eslint/naming-convention */
|
|
|
|
export const DocumentGridType = {
|
|
|
|
DEFAULT: "default",
|
|
|
|
LINES: "lines",
|
|
|
|
LINES_AND_CHARS: "linesAndChars",
|
|
|
|
SNAP_TO_CHARS: "snapToChars",
|
|
|
|
} as const;
|
|
|
|
|
|
|
|
/* eslint-enable */
|
2021-05-25 03:41:12 +03:00
|
|
|
export interface IDocGridAttributesProperties {
|
2023-12-22 10:25:00 +09:00
|
|
|
readonly type?: (typeof DocumentGridType)[keyof typeof DocumentGridType];
|
2021-05-25 03:41:12 +03:00
|
|
|
readonly linePitch?: number;
|
2021-11-30 21:11:06 +09:00
|
|
|
readonly charSpace?: number;
|
2021-05-25 03:41:12 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
export class DocGridAttributes extends XmlAttributeComponent<IDocGridAttributesProperties> {
|
|
|
|
protected readonly xmlKeys = {
|
2021-11-30 21:11:06 +09:00
|
|
|
type: "w:type",
|
2021-05-25 03:41:12 +03:00
|
|
|
linePitch: "w:linePitch",
|
2021-11-30 21:11:06 +09:00
|
|
|
charSpace: "w:charSpace",
|
2021-05-25 03:41:12 +03:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
export class DocumentGrid extends XmlComponent {
|
2023-12-22 10:25:00 +09:00
|
|
|
public constructor(linePitch: number, charSpace?: number, type?: (typeof DocumentGridType)[keyof typeof DocumentGridType]) {
|
2021-05-25 03:41:12 +03:00
|
|
|
super("w:docGrid");
|
2021-11-30 21:11:06 +09:00
|
|
|
|
2021-05-25 03:41:12 +03:00
|
|
|
this.root.push(
|
|
|
|
new DocGridAttributes({
|
2021-11-30 21:11:06 +09:00
|
|
|
type: type,
|
2021-05-25 03:41:12 +03:00
|
|
|
linePitch: decimalNumber(linePitch),
|
2021-11-30 21:11:06 +09:00
|
|
|
charSpace: charSpace ? decimalNumber(charSpace) : undefined,
|
2021-05-25 03:41:12 +03:00
|
|
|
}),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|