2021-05-25 03:41:12 +03:00
|
|
|
// http://officeopenxml.com/WPsectionLineNumbering.php
|
2022-06-26 23:26:42 +01:00
|
|
|
import { XmlAttributeComponent, XmlComponent } from "@file/xml-components";
|
|
|
|
import { decimalNumber, twipsMeasureValue } from "@util/values";
|
2021-05-25 03:41:12 +03:00
|
|
|
|
|
|
|
// <xsd:simpleType name="ST_LineNumberRestart">
|
|
|
|
// <xsd:restriction base="xsd:string">
|
|
|
|
// <xsd:enumeration value="newPage"/>
|
|
|
|
// <xsd:enumeration value="newSection"/>
|
|
|
|
// <xsd:enumeration value="continuous"/>
|
|
|
|
// </xsd:restriction>
|
|
|
|
// </xsd:simpleType>
|
|
|
|
export enum LineNumberRestartFormat {
|
|
|
|
NEW_PAGE = "newPage",
|
|
|
|
NEW_SECTION = "newSection",
|
|
|
|
CONTINUOUS = "continuous",
|
|
|
|
}
|
|
|
|
|
|
|
|
// <xsd:complexType name="CT_LineNumber">
|
|
|
|
// <xsd:attribute name="countBy" type="ST_DecimalNumber" use="optional"/>
|
|
|
|
// <xsd:attribute name="start" type="ST_DecimalNumber" use="optional" default="1"/>
|
|
|
|
// <xsd:attribute name="distance" type="s:ST_TwipsMeasure" use="optional"/>
|
|
|
|
// <xsd:attribute name="restart" type="ST_LineNumberRestart" use="optional" default="newPage"/>
|
|
|
|
// </xsd:complexType>
|
|
|
|
|
|
|
|
export interface ILineNumberAttributes {
|
|
|
|
readonly countBy?: number;
|
|
|
|
readonly start?: number;
|
|
|
|
readonly restart?: LineNumberRestartFormat;
|
|
|
|
readonly distance?: number | string;
|
|
|
|
}
|
|
|
|
|
|
|
|
export class LineNumberAttributes extends XmlAttributeComponent<ILineNumberAttributes> {
|
|
|
|
protected readonly xmlKeys = {
|
|
|
|
countBy: "w:countBy",
|
|
|
|
start: "w:start",
|
|
|
|
restart: "w:restart",
|
|
|
|
distance: "w:distance",
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
export class LineNumberType extends XmlComponent {
|
2022-08-31 07:52:27 +01:00
|
|
|
public constructor({ countBy, start, restart, distance }: ILineNumberAttributes) {
|
2021-05-25 03:41:12 +03:00
|
|
|
super("w:lnNumType");
|
|
|
|
this.root.push(
|
|
|
|
new LineNumberAttributes({
|
|
|
|
countBy: countBy === undefined ? undefined : decimalNumber(countBy),
|
|
|
|
start: start === undefined ? undefined : decimalNumber(start),
|
|
|
|
restart,
|
|
|
|
distance: distance === undefined ? undefined : twipsMeasureValue(distance),
|
|
|
|
}),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|