(docxFile)
| 1611 | } |
| 1612 | |
| 1613 | function findPartPaths(docxFile) { |
| 1614 | return readPackageRelationships(docxFile).then(function(packageRelationships) { |
| 1615 | var mainDocumentPath = findPartPath({ |
| 1616 | docxFile: docxFile, |
| 1617 | relationships: packageRelationships, |
| 1618 | relationshipType: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument", |
| 1619 | basePath: "", |
| 1620 | fallbackPath: "word/document.xml" |
| 1621 | }); |
| 1622 | |
| 1623 | if (!docxFile.exists(mainDocumentPath)) { |
| 1624 | throw new Error("Could not find main document part. Are you sure this is a valid .docx file?"); |
| 1625 | } |
| 1626 | |
| 1627 | return xmlFileReader({ |
| 1628 | filename: relationshipsFilename(mainDocumentPath), |
| 1629 | readElement: relationshipsReader.readRelationships, |
| 1630 | defaultValue: relationshipsReader.defaultValue |
| 1631 | })(docxFile).then(function(documentRelationships) { |
| 1632 | function findPartRelatedToMainDocument(name) { |
| 1633 | return findPartPath({ |
| 1634 | docxFile: docxFile, |
| 1635 | relationships: documentRelationships, |
| 1636 | relationshipType: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/" + name, |
| 1637 | basePath: zipfile.splitPath(mainDocumentPath).dirname, |
| 1638 | fallbackPath: "word/" + name + ".xml" |
| 1639 | }); |
| 1640 | } |
| 1641 | |
| 1642 | return { |
| 1643 | mainDocument: mainDocumentPath, |
| 1644 | comments: findPartRelatedToMainDocument("comments"), |
| 1645 | endnotes: findPartRelatedToMainDocument("endnotes"), |
| 1646 | footnotes: findPartRelatedToMainDocument("footnotes"), |
| 1647 | numbering: findPartRelatedToMainDocument("numbering"), |
| 1648 | styles: findPartRelatedToMainDocument("styles") |
| 1649 | }; |
| 1650 | }); |
| 1651 | }); |
| 1652 | } |
| 1653 | |
| 1654 | function findPartPath(options) { |
| 1655 | var docxFile = options.docxFile; |
no test coverage detected