From db60270e1f4036eb694bb2383392651204e83ded Mon Sep 17 00:00:00 2001 From: fmuscolino Date: Fri, 1 Mar 2019 16:12:15 +0100 Subject: [PATCH] fix: relationship and content type for settings --- src/file/content-types/content-types.spec.ts | 28 +++++++++++++++++--- src/file/content-types/content-types.ts | 1 + src/file/file.ts | 5 ++++ 3 files changed, 30 insertions(+), 4 deletions(-) diff --git a/src/file/content-types/content-types.spec.ts b/src/file/content-types/content-types.spec.ts index e3cd62b984..d88eb4a858 100644 --- a/src/file/content-types/content-types.spec.ts +++ b/src/file/content-types/content-types.spec.ts @@ -79,6 +79,26 @@ describe("ContentTypes", () => { }, ], }); + expect(tree["Types"][13]).to.deep.equal({ + Override: [ + { + _attr: { + ContentType: "application/vnd.openxmlformats-officedocument.wordprocessingml.footnotes+xml", + PartName: "/word/footnotes.xml", + }, + }, + ], + }); + expect(tree["Types"][14]).to.deep.equal({ + Override: [ + { + _attr: { + ContentType: "application/vnd.openxmlformats-officedocument.wordprocessingml.settings+xml", + PartName: "/word/settings.xml", + }, + }, + ], + }); }); }); @@ -88,7 +108,7 @@ describe("ContentTypes", () => { contentTypes.addFooter(102); const tree = new Formatter().format(contentTypes); - expect(tree["Types"][14]).to.deep.equal({ + expect(tree["Types"][15]).to.deep.equal({ Override: [ { _attr: { @@ -99,7 +119,7 @@ describe("ContentTypes", () => { ], }); - expect(tree["Types"][15]).to.deep.equal({ + expect(tree["Types"][16]).to.deep.equal({ Override: [ { _attr: { @@ -118,7 +138,7 @@ describe("ContentTypes", () => { contentTypes.addHeader(202); const tree = new Formatter().format(contentTypes); - expect(tree["Types"][14]).to.deep.equal({ + expect(tree["Types"][15]).to.deep.equal({ Override: [ { _attr: { @@ -129,7 +149,7 @@ describe("ContentTypes", () => { ], }); - expect(tree["Types"][15]).to.deep.equal({ + expect(tree["Types"][16]).to.deep.equal({ Override: [ { _attr: { diff --git a/src/file/content-types/content-types.ts b/src/file/content-types/content-types.ts index 8735d3d9e2..86307724fc 100644 --- a/src/file/content-types/content-types.ts +++ b/src/file/content-types/content-types.ts @@ -30,6 +30,7 @@ export class ContentTypes extends XmlComponent { this.root.push(new Override("application/vnd.openxmlformats-officedocument.extended-properties+xml", "/docProps/app.xml")); this.root.push(new Override("application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml", "/word/numbering.xml")); this.root.push(new Override("application/vnd.openxmlformats-officedocument.wordprocessingml.footnotes+xml", "/word/footnotes.xml")); + this.root.push(new Override("application/vnd.openxmlformats-officedocument.wordprocessingml.settings+xml", "/word/settings.xml")); } public addFooter(index: number): void { diff --git a/src/file/file.ts b/src/file/file.ts index 2a11737279..0d8a6a0b3d 100644 --- a/src/file/file.ts +++ b/src/file/file.ts @@ -324,6 +324,11 @@ export class File { "http://schemas.openxmlformats.org/officeDocument/2006/relationships/footnotes", "footnotes.xml", ); + this.docRelationships.createRelationship( + this.currentRelationshipId++, + "http://schemas.openxmlformats.org/officeDocument/2006/relationships/settings", + "settings.xml", + ); } private groupHeaders(headers: IDocumentHeader[], group: IHeaderFooterGroup = {}): IHeaderFooterGroup {