Merge from master

This commit is contained in:
Dolan
2018-09-25 23:46:55 +01:00
40 changed files with 1036 additions and 140 deletions

View File

@ -11,10 +11,12 @@ import { Image, Media } from "./media";
import { Numbering } from "./numbering";
import { Bookmark, Hyperlink, Paragraph } from "./paragraph";
import { Relationships } from "./relationships";
import { Settings } from "./settings";
import { Styles } from "./styles";
import { ExternalStylesFactory } from "./styles/external-styles-factory";
import { DefaultStylesFactory } from "./styles/factory";
import { Table } from "./table";
import { TableOfContents } from "./table-of-contents";
export class File {
private currentRelationshipId: number = 1;
@ -28,6 +30,7 @@ export class File {
private readonly media: Media;
private readonly fileRelationships: Relationships;
private readonly footNotes: FootNotes;
private readonly settings: Settings;
private readonly contentTypes: ContentTypes;
private readonly appProperties: AppProperties;
private styles: Styles;
@ -93,6 +96,11 @@ export class File {
};
this.document = new Document(sectionPropertiesOptions);
this.settings = new Settings();
}
public addTableOfContents(toc: TableOfContents): void {
this.document.addTableOfContents(toc);
}
public addParagraph(paragraph: Paragraph): File {
@ -199,6 +207,12 @@ export class File {
throw new Error(`There is no header with given reference id ${refId}`);
}
public verifyUpdateFields(): void {
if (this.document.getTablesOfContents().length) {
this.settings.addUpdateFields();
}
}
protected addHeaderToDocument(header: HeaderWrapper, type: HeaderReferenceType = HeaderReferenceType.DEFAULT): void {
this.headers.push({ header, type });
this.docRelationships.createRelationship(
@ -296,4 +310,8 @@ export class File {
public get FootNotes(): FootNotes {
return this.footNotes;
}
public get Settings(): Settings {
return this.settings;
}
}