2018-08-31 10:22:40 -03:00
|
|
|
// import { TableOfContentsProperties } from "./properties";
|
2018-09-18 05:24:19 -03:00
|
|
|
import { Paragraph, ParagraphProperties } from "file/paragraph";
|
2018-09-04 18:22:08 -03:00
|
|
|
import { Run } from "file/paragraph/run";
|
2018-09-03 11:20:36 -03:00
|
|
|
import { Begin, End, Separate } from "file/paragraph/run/field";
|
2018-09-10 10:01:26 -03:00
|
|
|
import { XmlComponent } from "file/xml-components";
|
2018-09-18 05:24:19 -03:00
|
|
|
import { TableOfContentsInstruction } from "./table-of-contents-instruction";
|
2018-08-21 07:19:46 -03:00
|
|
|
|
2018-09-10 10:01:26 -03:00
|
|
|
export class TableOfContents extends XmlComponent {
|
2018-08-31 10:22:40 -03:00
|
|
|
// private readonly tocProperties: TableOfContentsProperties;
|
2018-09-10 10:01:26 -03:00
|
|
|
private readonly properties: ParagraphProperties;
|
2018-08-29 12:06:01 -03:00
|
|
|
|
2018-09-18 05:24:19 -03:00
|
|
|
private readonly instruction: TableOfContentsInstruction;
|
|
|
|
|
2018-08-31 10:22:40 -03:00
|
|
|
constructor(/*tocProperties?: TableOfContentsProperties*/) {
|
2018-09-18 05:24:19 -03:00
|
|
|
super("w:sdt");
|
2018-09-10 10:01:26 -03:00
|
|
|
this.properties = new ParagraphProperties();
|
2018-09-18 05:24:19 -03:00
|
|
|
this.instruction = new TableOfContentsInstruction();
|
2018-09-10 10:01:26 -03:00
|
|
|
this.root.push(this.properties);
|
2018-08-31 10:22:40 -03:00
|
|
|
// this.tocProperties = tocProperties || new TableOfContentsProperties();
|
2018-09-18 05:24:19 -03:00
|
|
|
const beginParagraph = new Paragraph();
|
|
|
|
const beginRun = new Run();
|
|
|
|
beginRun.addChildElement(new Begin());
|
|
|
|
beginRun.addChildElement(this.instruction);
|
|
|
|
beginRun.addChildElement(new Separate());
|
|
|
|
beginParagraph.addRun(beginRun);
|
|
|
|
this.root.push(beginParagraph);
|
|
|
|
|
|
|
|
const endParagraph = new Paragraph();
|
|
|
|
const endRun = new Run();
|
|
|
|
endRun.addChildElement(new End());
|
|
|
|
endParagraph.addRun(endRun);
|
|
|
|
this.root.push(endParagraph);
|
|
|
|
}
|
|
|
|
|
|
|
|
public getHeaderRange(): string {
|
|
|
|
return this.instruction.getHeaderRange();
|
|
|
|
}
|
2018-09-04 18:22:08 -03:00
|
|
|
|
2018-09-18 05:24:19 -03:00
|
|
|
public addGeneratedContent(paragraph: Paragraph): void {
|
|
|
|
this.root.splice(this.root.length - 1, 0, paragraph);
|
2018-08-29 12:06:01 -03:00
|
|
|
}
|
|
|
|
}
|