// http://officeopenxml.com/WPsectionLineNumbering.php
import { BuilderElement, XmlComponent } from "@file/xml-components";
import { PositiveUniversalMeasure, decimalNumber, twipsMeasureValue } from "@util/values";
//
//
//
//
//
//
//
export const LineNumberRestartFormat = {
NEW_PAGE: "newPage",
NEW_SECTION: "newSection",
CONTINUOUS: "continuous",
} as const;
//
//
//
//
//
//
export type ILineNumberAttributes = {
readonly countBy?: number;
readonly start?: number;
readonly restart?: (typeof LineNumberRestartFormat)[keyof typeof LineNumberRestartFormat];
readonly distance?: number | PositiveUniversalMeasure;
};
export const createLineNumberType = ({ countBy, start, restart, distance }: ILineNumberAttributes): XmlComponent =>
new BuilderElement({
name: "w:lnNumType",
attributes: {
countBy: { key: "w:countBy", value: countBy === undefined ? undefined : decimalNumber(countBy) },
start: { key: "w:start", value: start === undefined ? undefined : decimalNumber(start) },
restart: { key: "w:restart", value: restart },
distance: {
key: "w:distance",
value: distance === undefined ? undefined : twipsMeasureValue(distance),
},
},
});