2018-01-31 00:31:54 +00:00
|
|
|
import { Header } from "./header/header";
|
|
|
|
import { IMediaData, Media } from "./media";
|
|
|
|
import { Paragraph } from "./paragraph";
|
|
|
|
import { Relationships } from "./relationships";
|
|
|
|
import { Table } from "./table";
|
2018-05-28 09:15:44 +02:00
|
|
|
import { XmlComponent } from ".";
|
2018-01-31 00:31:54 +00:00
|
|
|
|
2018-05-12 22:22:54 -04:00
|
|
|
export class FirstPageHeaderWrapper {
|
|
|
|
private readonly header: Header;
|
|
|
|
private readonly relationships: Relationships;
|
|
|
|
|
|
|
|
constructor(private readonly media: Media) {
|
|
|
|
this.header = new Header();
|
|
|
|
this.relationships = new Relationships();
|
|
|
|
}
|
|
|
|
|
|
|
|
public addParagraph(paragraph: Paragraph): void {
|
|
|
|
this.header.addParagraph(paragraph);
|
|
|
|
}
|
|
|
|
|
|
|
|
public createParagraph(text?: string): Paragraph {
|
|
|
|
const para = new Paragraph(text);
|
|
|
|
this.addParagraph(para);
|
|
|
|
return para;
|
|
|
|
}
|
|
|
|
|
|
|
|
public addTable(table: Table): void {
|
|
|
|
this.header.addTable(table);
|
|
|
|
}
|
|
|
|
|
|
|
|
public createTable(rows: number, cols: number): Table {
|
|
|
|
return this.header.createTable(rows, cols);
|
|
|
|
}
|
|
|
|
|
|
|
|
public addDrawing(imageData: IMediaData): void {
|
|
|
|
this.header.addDrawing(imageData);
|
|
|
|
}
|
|
|
|
|
|
|
|
public createImage(image: string): void {
|
|
|
|
const mediaData = this.media.addMedia(image, this.relationships.RelationshipCount);
|
|
|
|
this.relationships.createRelationship(
|
|
|
|
mediaData.referenceId,
|
|
|
|
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",
|
|
|
|
`media/${mediaData.fileName}`,
|
|
|
|
);
|
|
|
|
this.addDrawing(mediaData);
|
|
|
|
}
|
|
|
|
|
|
|
|
public get Header(): Header {
|
|
|
|
return this.header;
|
|
|
|
}
|
|
|
|
|
|
|
|
public get Relationships(): Relationships {
|
|
|
|
return this.relationships;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-01-31 00:31:54 +00:00
|
|
|
export class HeaderWrapper {
|
|
|
|
private readonly header: Header;
|
|
|
|
private readonly relationships: Relationships;
|
|
|
|
|
|
|
|
constructor(private readonly media: Media) {
|
|
|
|
this.header = new Header();
|
|
|
|
this.relationships = new Relationships();
|
|
|
|
}
|
|
|
|
|
|
|
|
public addParagraph(paragraph: Paragraph): void {
|
|
|
|
this.header.addParagraph(paragraph);
|
|
|
|
}
|
|
|
|
|
|
|
|
public createParagraph(text?: string): Paragraph {
|
|
|
|
const para = new Paragraph(text);
|
|
|
|
this.addParagraph(para);
|
|
|
|
return para;
|
|
|
|
}
|
|
|
|
|
|
|
|
public addTable(table: Table): void {
|
|
|
|
this.header.addTable(table);
|
|
|
|
}
|
|
|
|
|
|
|
|
public createTable(rows: number, cols: number): Table {
|
|
|
|
return this.header.createTable(rows, cols);
|
|
|
|
}
|
|
|
|
|
|
|
|
public addDrawing(imageData: IMediaData): void {
|
|
|
|
this.header.addDrawing(imageData);
|
|
|
|
}
|
|
|
|
|
2018-05-28 09:15:44 +02:00
|
|
|
public addChildElement(childElement: XmlComponent | string) {
|
|
|
|
this.header.addChildElement(childElement);
|
|
|
|
}
|
|
|
|
|
2018-01-31 00:31:54 +00:00
|
|
|
public createImage(image: string): void {
|
|
|
|
const mediaData = this.media.addMedia(image, this.relationships.RelationshipCount);
|
|
|
|
this.relationships.createRelationship(
|
|
|
|
mediaData.referenceId,
|
|
|
|
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",
|
|
|
|
`media/${mediaData.fileName}`,
|
|
|
|
);
|
|
|
|
this.addDrawing(mediaData);
|
|
|
|
}
|
|
|
|
|
|
|
|
public get Header(): Header {
|
|
|
|
return this.header;
|
|
|
|
}
|
|
|
|
|
|
|
|
public get Relationships(): Relationships {
|
|
|
|
return this.relationships;
|
|
|
|
}
|
|
|
|
}
|