From c378280e344dd6209ec41975b4c879d297ad76f9 Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Fri, 3 Nov 2017 16:19:28 +0000 Subject: Read table style applied to tables --- lib/docx/body-reader.js | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'lib/docx') diff --git a/lib/docx/body-reader.js b/lib/docx/body-reader.js index c612e5c..e21b422 100644 --- a/lib/docx/body-reader.js +++ b/lib/docx/body-reader.js @@ -81,6 +81,10 @@ function BodyReader(options) { return readStyle(element, "w:rStyle", "Run", styles.findCharacterStyleById); } + function readTableStyle(element) { + return readStyle(element, "w:tblStyle", "Table", styles.findTableStyleById); + } + function readStyle(element, styleTagName, styleType, findStyleById) { var messages = []; var styleElement = element.first(styleTagName); @@ -293,9 +297,23 @@ function BodyReader(options) { function readTable(element) { + var propertiesResult = readTableProperties(element.firstOrEmpty("w:tblPr")); return readXmlElements(element.children) .flatMap(calculateRowSpans) - .map(documents.Table); + .flatMap(function(children) { + return propertiesResult.map(function(properties) { + return documents.Table(children, properties); + }); + }); + } + + function readTableProperties(element) { + return readTableStyle(element).map(function(style) { + return { + styleId: style.styleId, + styleName: style.name + }; + }); } function readTableRow(element) { -- cgit v1.2.3