added stdPr and stdContent to table of contents

This commit is contained in:
Sergio Mendonça
2018-09-19 11:01:07 -03:00
parent baf0f17bd6
commit 7cd8864fb9
6 changed files with 49 additions and 8 deletions

View File

@ -1,21 +1,27 @@
// import { TableOfContentsProperties } from "./properties";
import { Paragraph, ParagraphProperties } from "file/paragraph";
import { Paragraph } from "file/paragraph";
import { Run } from "file/paragraph/run";
import { Begin, End, Separate } from "file/paragraph/run/field";
import { XmlComponent } from "file/xml-components";
import { StdContent } from "./std-content";
import { StdProperties } from "./std-properties";
import { TableOfContentsInstruction } from "./table-of-contents-instruction";
export class TableOfContents extends XmlComponent {
// private readonly tocProperties: TableOfContentsProperties;
private readonly properties: ParagraphProperties;
private readonly properties: StdProperties;
private readonly content: StdContent;
private readonly instruction: TableOfContentsInstruction;
constructor(/*tocProperties?: TableOfContentsProperties*/) {
super("w:sdt");
this.properties = new ParagraphProperties();
this.properties = new StdProperties("Table of Contents");
this.content = new StdContent();
this.instruction = new TableOfContentsInstruction();
this.root.push(this.properties);
this.root.push(this.content);
// this.tocProperties = tocProperties || new TableOfContentsProperties();
const beginParagraph = new Paragraph();
const beginRun = new Run();
@ -23,13 +29,13 @@ export class TableOfContents extends XmlComponent {
beginRun.addChildElement(this.instruction);
beginRun.addChildElement(new Separate());
beginParagraph.addRun(beginRun);
this.root.push(beginParagraph);
this.content.addChildElement(beginParagraph);
const endParagraph = new Paragraph();
const endRun = new Run();
endRun.addChildElement(new End());
endParagraph.addRun(endRun);
this.root.push(endParagraph);
this.content.addChildElement(endParagraph);
}
public getHeaderRange(): string {
@ -37,6 +43,6 @@ export class TableOfContents extends XmlComponent {
}
public addGeneratedContent(paragraph: Paragraph): void {
this.root.splice(this.root.length - 1, 0, paragraph);
this.content.addGeneratedContent(paragraph);
}
}