2018-09-26 02:17:39 +01:00
|
|
|
// http://officeopenxml.com/WPtableOfContents.php
|
|
|
|
// http://www.datypic.com/sc/ooxml/e-w_sdt-1.html
|
2018-09-19 11:01:07 -03:00
|
|
|
import { Paragraph } 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-26 02:17:39 +01:00
|
|
|
import { FieldInstruction } from "./field-instruction";
|
|
|
|
import { StructuredDocumentTagContent } from "./sdt-content";
|
|
|
|
import { StructuredDocumentTagProperties } from "./sdt-properties";
|
2018-09-25 21:09:30 +01:00
|
|
|
import { ITableOfContentsOptions } from "./table-of-contents-properties";
|
2018-08-21 07:19:46 -03:00
|
|
|
|
2018-09-10 10:01:26 -03:00
|
|
|
export class TableOfContents extends XmlComponent {
|
2018-09-25 21:09:30 +01:00
|
|
|
constructor(alias: string = "Table of Contents", properties?: ITableOfContentsOptions) {
|
2018-09-21 11:16:14 -03:00
|
|
|
super("w:sdt");
|
2018-09-26 02:17:39 +01:00
|
|
|
this.root.push(new StructuredDocumentTagProperties(alias));
|
2018-08-29 12:06:01 -03:00
|
|
|
|
2018-09-26 02:17:39 +01:00
|
|
|
const content = new StructuredDocumentTagContent();
|
2018-09-18 05:24:19 -03:00
|
|
|
|
|
|
|
const beginParagraph = new Paragraph();
|
|
|
|
const beginRun = new Run();
|
2018-09-21 10:26:28 -03:00
|
|
|
beginRun.addChildElement(new Begin(true));
|
2018-09-26 02:17:39 +01:00
|
|
|
beginRun.addChildElement(new FieldInstruction(properties));
|
2018-09-18 05:24:19 -03:00
|
|
|
beginRun.addChildElement(new Separate());
|
|
|
|
beginParagraph.addRun(beginRun);
|
2018-09-21 11:16:14 -03:00
|
|
|
content.addChildElement(beginParagraph);
|
2018-09-18 05:24:19 -03:00
|
|
|
|
|
|
|
const endParagraph = new Paragraph();
|
|
|
|
const endRun = new Run();
|
|
|
|
endRun.addChildElement(new End());
|
|
|
|
endParagraph.addRun(endRun);
|
2018-09-21 11:16:14 -03:00
|
|
|
content.addChildElement(endParagraph);
|
2018-09-04 18:22:08 -03:00
|
|
|
|
2018-09-21 11:16:14 -03:00
|
|
|
this.root.push(content);
|
2018-08-29 12:06:01 -03:00
|
|
|
}
|
|
|
|
}
|