commit
This commit is contained in:
@ -11,6 +11,8 @@ export interface IPropertiesOptions {
|
||||
lastModifiedBy?: string;
|
||||
revision?: string;
|
||||
externalStyles?: string;
|
||||
|
||||
templateHeader? : XmlComponent;
|
||||
}
|
||||
|
||||
export class CoreProperties extends XmlComponent {
|
||||
|
@ -14,6 +14,7 @@ import { Styles } from "./styles";
|
||||
import { ExternalStylesFactory } from "./styles/external-styles-factory";
|
||||
import { DefaultStylesFactory } from "./styles/factory";
|
||||
import { Table } from "./table";
|
||||
import { XmlComponent } from "./xml-components";
|
||||
|
||||
export class File {
|
||||
private readonly document: Document;
|
||||
@ -71,7 +72,7 @@ export class File {
|
||||
);
|
||||
this.media = new Media();
|
||||
|
||||
const header = this.createHeader();
|
||||
const header = this.createHeader(options.templateHeader);
|
||||
const footer = this.createFooter();
|
||||
|
||||
this.fileRelationships = new Relationships();
|
||||
@ -169,8 +170,10 @@ export class File {
|
||||
this.footNotes.createFootNote(paragraph);
|
||||
}
|
||||
|
||||
public createHeader(): HeaderWrapper {
|
||||
const header = new HeaderWrapper(this.media, this.currentRelationshipId++);
|
||||
public createHeader(templateHeader? : XmlComponent): HeaderWrapper {
|
||||
const header = new HeaderWrapper(this.media, this.currentRelationshipId++, templateHeader);
|
||||
console.log('\n\n-------\n\n');
|
||||
console.log('header', JSON.stringify(header.Header, null, 2));
|
||||
this.headerWrapper.push(header);
|
||||
this.docRelationships.createRelationship(
|
||||
header.Header.ReferenceId,
|
||||
|
@ -5,12 +5,13 @@ import { ImageParagraph, Paragraph } from "./paragraph";
|
||||
import { Relationships } from "./relationships";
|
||||
import { Table } from "./table";
|
||||
|
||||
|
||||
export class HeaderWrapper {
|
||||
private readonly header: Header;
|
||||
private readonly relationships: Relationships;
|
||||
|
||||
constructor(private readonly media: Media, referenceId: number) {
|
||||
this.header = new Header(referenceId);
|
||||
constructor(private readonly media: Media, referenceId: number, initContent? : XmlComponent) {
|
||||
this.header = new Header(referenceId, initContent);
|
||||
this.relationships = new Relationships();
|
||||
}
|
||||
|
||||
|
@ -7,10 +7,11 @@ import { HeaderAttributes } from "./header-attributes";
|
||||
export class Header extends XmlComponent {
|
||||
private readonly refId: number;
|
||||
|
||||
constructor(referenceNumber: number) {
|
||||
super("w:hdr");
|
||||
constructor(referenceNumber: number, initContent? : XmlComponent) {
|
||||
super("w:hdr", initContent);
|
||||
|
||||
this.refId = referenceNumber;
|
||||
|
||||
this.root.push(
|
||||
new HeaderAttributes({
|
||||
wpc: "http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas",
|
||||
|
@ -3,11 +3,17 @@ import { IXmlableObject } from "./xmlable-object";
|
||||
export { BaseXmlComponent };
|
||||
|
||||
export abstract class XmlComponent extends BaseXmlComponent {
|
||||
protected root: Array<BaseXmlComponent | string>;
|
||||
public root: Array<BaseXmlComponent | string>;
|
||||
|
||||
constructor(rootKey: string) {
|
||||
constructor(rootKey: string, initContent? : XmlComponent) {
|
||||
super(rootKey);
|
||||
this.root = new Array<BaseXmlComponent>();
|
||||
this.root = initContent ? initContent.root : new Array<BaseXmlComponent>();
|
||||
if (initContent) {
|
||||
console.log('\n\n-------\n\n');
|
||||
console.log('new root', JSON.stringify(initContent, null,2));
|
||||
console.log('\n\n-------\n\n');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public prepForXml(): IXmlableObject {
|
||||
|
Reference in New Issue
Block a user