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 {
|
2016-05-26 15:08:34 +01:00
|
|
|
numId: number;
|
2016-05-21 00:02:46 +01:00
|
|
|
}
|
|
|
|
|
2017-03-10 10:42:24 +01:00
|
|
|
class NumAttributes extends XmlAttributeComponent<INumAttributesProperties> {
|
2018-01-23 01:33:12 +00:00
|
|
|
protected xmlKeys = { numId: "w:numId" };
|
2016-05-21 00:02:46 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
export class Num extends XmlComponent {
|
2017-03-08 17:28:44 +01:00
|
|
|
public id: number;
|
2016-05-26 15:08:34 +01:00
|
|
|
|
2016-05-21 00:02:46 +01:00
|
|
|
constructor(numId: number, abstractNumId: number) {
|
|
|
|
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-01-23 01:33:12 +00:00
|
|
|
class LevelOverrideAttributes extends XmlAttributeComponent<{ ilvl: number }> {
|
|
|
|
protected 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 {
|
2017-04-12 15:54:14 +02:00
|
|
|
private lvl?: LevelForOverride;
|
|
|
|
|
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));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
get level(): LevelForOverride {
|
|
|
|
let lvl: LevelForOverride;
|
|
|
|
if (!this.lvl) {
|
|
|
|
lvl = new LevelForOverride(this.levelNum);
|
|
|
|
this.root.push(lvl);
|
|
|
|
this.lvl = lvl;
|
|
|
|
} else {
|
|
|
|
lvl = this.lvl;
|
|
|
|
}
|
|
|
|
return lvl;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-01-23 01:33:12 +00:00
|
|
|
class StartOverrideAttributes extends XmlAttributeComponent<{ val: number }> {
|
|
|
|
protected 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
|
|
|
}
|