From fd9bfbf28e045362c83620dd888c5edbb6f39a89 Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Fri, 26 Jan 2018 23:43:06 +0000 Subject: Find parts related to main document using main document relationships --- lib/docx/docx-reader.js | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) (limited to 'lib') diff --git a/lib/docx/docx-reader.js b/lib/docx/docx-reader.js index e6dd798..e0d4a13 100644 --- a/lib/docx/docx-reader.js +++ b/lib/docx/docx-reader.js @@ -100,26 +100,23 @@ function findPartPaths(docxFile) { readElement: relationshipsReader.readRelationships, defaultValue: relationshipsReader.defaultValue })(docxFile).then(function(documentRelationships) { - function findPartRelatedToMainDocument(options) { + function findPartRelatedToMainDocument(name) { return findPartPath({ docxFile: docxFile, relationships: documentRelationships, - relationshipType: options.relationshipType, + relationshipType: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/" + name, basePath: zipfile.splitPath(mainDocumentPath).dirname, - fallbackPath: options.fallbackPath + fallbackPath: "word/" + name + ".xml" }); } return { mainDocument: mainDocumentPath, - comments: findPartRelatedToMainDocument({ - relationshipType: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments", - fallbackPath: "word/comments.xml" - }), - endnotes: "word/endnotes.xml", - footnotes: "word/footnotes.xml", - numbering: "word/numbering.xml", - styles: "word/styles.xml" + comments: findPartRelatedToMainDocument("comments"), + endnotes: findPartRelatedToMainDocument("endnotes"), + footnotes: findPartRelatedToMainDocument("footnotes"), + numbering: findPartRelatedToMainDocument("numbering"), + styles: findPartRelatedToMainDocument("styles") }; }); }); -- cgit v1.2.3