2017-12-30 20:25:16 +00:00
|
|
|
import { Attributes, XmlAttributeComponent, XmlComponent } from "file/xml-components";
|
2017-04-12 15:54:14 +02:00
|
|
|
import { LevelForOverride } from "./level";
|
2016-05-21 00:02:46 +01:00
|
|
|
|
|
|
|
class AbstractNumId extends XmlComponent {
|
|
|
|
constructor(value: number) {
|
|
|
|
super("w:abstractNumId");
|
2018-01-23 01:33:12 +00:00
|
|
|
this.root.push(
|
|
|
|
new Attributes({
|
|
|
|
val: value,
|
|
|
|
}),
|
|
|
|
);
|
2016-05-21 00:02:46 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-03-08 17:16:51 +01:00
|
|
|
interface INumAttributesProperties {
|
2018-11-02 02:51:57 +00:00
|
|
|
readonly numId: number;
|
2016-05-21 00:02:46 +01:00
|
|
|
}
|
|
|
|
|
2017-03-10 10:42:24 +01:00
|
|
|
class NumAttributes extends XmlAttributeComponent<INumAttributesProperties> {
|
2018-11-02 02:51:57 +00:00
|
|
|
protected readonly xmlKeys = { numId: "w:numId" };
|
2016-05-21 00:02:46 +01:00
|
|
|
}
|
|
|
|
|
2019-11-01 01:57:01 +00:00
|
|
|
export class ConcreteNumbering extends XmlComponent {
|
2018-11-02 02:51:57 +00:00
|
|
|
public readonly id: number;
|
2016-05-26 15:08:34 +01:00
|
|
|
|
2019-11-08 03:11:19 +00:00
|
|
|
constructor(numId: number, abstractNumId: number, public readonly reference?: string) {
|
2016-05-21 00:02:46 +01:00
|
|
|
super("w:num");
|
2018-01-23 01:33:12 +00:00
|
|
|
this.root.push(
|
|
|
|
new NumAttributes({
|
|
|
|
numId: numId,
|
|
|
|
}),
|
|
|
|
);
|
2016-05-21 00:02:46 +01:00
|
|
|
this.root.push(new AbstractNumId(abstractNumId));
|
2017-03-08 17:28:44 +01:00
|
|
|
this.id = numId;
|
|
|
|
}
|
2017-04-12 15:54:14 +02:00
|
|
|
|
|
|
|
public overrideLevel(num: number, start?: number): LevelOverride {
|
|
|
|
const olvl = new LevelOverride(num, start);
|
|
|
|
this.root.push(olvl);
|
|
|
|
return olvl;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-11-02 02:51:57 +00:00
|
|
|
class LevelOverrideAttributes extends XmlAttributeComponent<{ readonly ilvl: number }> {
|
|
|
|
protected readonly xmlKeys = { ilvl: "w:ilvl" };
|
2017-04-12 15:54:14 +02:00
|
|
|
}
|
|
|
|
|
2017-07-07 14:31:08 +01:00
|
|
|
export class LevelOverride extends XmlComponent {
|
2018-11-02 02:51:57 +00:00
|
|
|
private readonly lvl: LevelForOverride;
|
2017-04-12 15:54:14 +02:00
|
|
|
|
2018-01-29 01:55:25 +00:00
|
|
|
constructor(private readonly levelNum: number, start?: number) {
|
2017-04-12 15:54:14 +02:00
|
|
|
super("w:lvlOverride");
|
2018-01-23 01:33:12 +00:00
|
|
|
this.root.push(new LevelOverrideAttributes({ ilvl: levelNum }));
|
2017-04-12 15:54:14 +02:00
|
|
|
if (start !== undefined) {
|
|
|
|
this.root.push(new StartOverride(start));
|
|
|
|
}
|
2018-11-02 02:51:57 +00:00
|
|
|
|
2019-11-06 20:54:39 +00:00
|
|
|
this.lvl = new LevelForOverride({
|
|
|
|
level: this.levelNum,
|
|
|
|
});
|
2018-11-02 02:51:57 +00:00
|
|
|
this.root.push(this.lvl);
|
2017-04-12 15:54:14 +02:00
|
|
|
}
|
|
|
|
|
2018-08-07 01:25:28 +01:00
|
|
|
public get Level(): LevelForOverride {
|
2018-11-02 02:51:57 +00:00
|
|
|
return this.lvl;
|
2017-04-12 15:54:14 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-11-02 02:51:57 +00:00
|
|
|
class StartOverrideAttributes extends XmlAttributeComponent<{ readonly val: number }> {
|
|
|
|
protected readonly xmlKeys = { val: "w:val" };
|
2017-04-12 15:54:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
class StartOverride extends XmlComponent {
|
|
|
|
constructor(start: number) {
|
|
|
|
super("w:startOverride");
|
2018-01-23 01:33:12 +00:00
|
|
|
this.root.push(new StartOverrideAttributes({ val: start }));
|
2017-04-12 15:54:14 +02:00
|
|
|
}
|
2017-03-08 17:16:51 +01:00
|
|
|
}
|