office-viewer 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (318) hide show
  1. package/README.md +23 -0
  2. package/esm/OpenXML.d.ts +21 -0
  3. package/esm/OpenXML.js +60 -0
  4. package/esm/Word.d.ts +208 -0
  5. package/esm/Word.js +370 -0
  6. package/esm/index.d.ts +6 -0
  7. package/esm/index.js +6 -0
  8. package/esm/node_modules/tslib/tslib.es6.js +120 -0
  9. package/esm/openxml/ContentType.d.ts +12 -0
  10. package/esm/openxml/ContentType.js +15 -0
  11. package/esm/openxml/Style.d.ts +41 -0
  12. package/esm/openxml/Style.js +156 -0
  13. package/esm/openxml/Theme.d.ts +26 -0
  14. package/esm/openxml/Theme.js +69 -0
  15. package/esm/openxml/Types.d.ts +2512 -0
  16. package/esm/openxml/Types.js +1003 -0
  17. package/esm/openxml/word/Background.d.ts +11 -0
  18. package/esm/openxml/word/Body.d.ts +18 -0
  19. package/esm/openxml/word/Body.js +67 -0
  20. package/esm/openxml/word/Bookmark.d.ts +6 -0
  21. package/esm/openxml/word/Bookmark.js +18 -0
  22. package/esm/openxml/word/Border.d.ts +10 -0
  23. package/esm/openxml/word/Break.d.ts +13 -0
  24. package/esm/openxml/word/Break.js +19 -0
  25. package/esm/openxml/word/CustomXml.d.ts +8 -0
  26. package/esm/openxml/word/FldSimple.d.ts +7 -0
  27. package/esm/openxml/word/FldSimple.js +15 -0
  28. package/esm/openxml/word/FrameProperties.d.ts +18 -0
  29. package/esm/openxml/word/Hyperlink.d.ts +13 -0
  30. package/esm/openxml/word/Hyperlink.js +53 -0
  31. package/esm/openxml/word/Indent.d.ts +8 -0
  32. package/esm/openxml/word/InlineText.d.ts +14 -0
  33. package/esm/openxml/word/InlineText.js +62 -0
  34. package/esm/openxml/word/InstrText.d.ts +4 -0
  35. package/esm/openxml/word/InstrText.js +8 -0
  36. package/esm/openxml/word/Paragraph.d.ts +34 -0
  37. package/esm/openxml/word/Paragraph.js +133 -0
  38. package/esm/openxml/word/Pict.d.ts +6 -0
  39. package/esm/openxml/word/Pict.js +19 -0
  40. package/esm/openxml/word/Ruby.d.ts +20 -0
  41. package/esm/openxml/word/Ruby.js +87 -0
  42. package/esm/openxml/word/Run.d.ts +31 -0
  43. package/esm/openxml/word/Run.js +98 -0
  44. package/esm/openxml/word/Section.d.ts +38 -0
  45. package/esm/openxml/word/Section.js +59 -0
  46. package/esm/openxml/word/Shading.d.ts +9 -0
  47. package/esm/openxml/word/SmartTag.d.ts +8 -0
  48. package/esm/openxml/word/SmartTag.js +18 -0
  49. package/esm/openxml/word/Spacing.d.ts +9 -0
  50. package/esm/openxml/word/Sym.d.ts +8 -0
  51. package/esm/openxml/word/Sym.js +16 -0
  52. package/esm/openxml/word/Tab.d.ts +8 -0
  53. package/esm/openxml/word/Tab.js +17 -0
  54. package/esm/openxml/word/Table.d.ts +49 -0
  55. package/esm/openxml/word/Table.js +248 -0
  56. package/esm/openxml/word/VerticalAlign.d.ts +6 -0
  57. package/esm/openxml/word/WDocument.d.ts +13 -0
  58. package/esm/openxml/word/WDocument.js +58 -0
  59. package/esm/openxml/word/drawing/Blip.d.ts +6 -0
  60. package/esm/openxml/word/drawing/Blip.js +17 -0
  61. package/esm/openxml/word/drawing/BlipFill.d.ts +9 -0
  62. package/esm/openxml/word/drawing/BlipFill.js +20 -0
  63. package/esm/openxml/word/drawing/Drawing.d.ts +6 -0
  64. package/esm/openxml/word/drawing/Drawing.js +15 -0
  65. package/esm/openxml/word/drawing/Pic.d.ts +8 -0
  66. package/esm/openxml/word/drawing/Pic.js +16 -0
  67. package/esm/openxml/word/drawing/ShapeProperties.d.ts +9 -0
  68. package/esm/openxml/word/drawing/ShapeProperties.js +20 -0
  69. package/esm/openxml/word/drawing/Transform.d.ts +17 -0
  70. package/esm/openxml/word/drawing/Transform.js +30 -0
  71. package/esm/openxml/word/numbering/AbstractNum.d.ts +13 -0
  72. package/esm/openxml/word/numbering/AbstractNum.js +42 -0
  73. package/esm/openxml/word/numbering/Lvl.d.ts +16 -0
  74. package/esm/openxml/word/numbering/Lvl.js +62 -0
  75. package/esm/openxml/word/numbering/Num.d.ts +10 -0
  76. package/esm/openxml/word/numbering/Num.js +46 -0
  77. package/esm/openxml/word/numbering/NumberProperties.d.ts +6 -0
  78. package/esm/openxml/word/numbering/NumberProperties.js +21 -0
  79. package/esm/openxml/word/numbering/Numbering.d.ts +9 -0
  80. package/esm/openxml/word/numbering/Numbering.js +50 -0
  81. package/esm/openxml/word/properties/Properties.d.ts +12 -0
  82. package/esm/openxml/word/table/Tc.d.ts +46 -0
  83. package/esm/openxml/word/table/Tc.js +234 -0
  84. package/esm/openxml/word/table/Tr.d.ts +18 -0
  85. package/esm/openxml/word/table/Tr.js +106 -0
  86. package/esm/package/PackageParser.d.ts +26 -0
  87. package/esm/package/XMLPackageParser.d.ts +31 -0
  88. package/esm/package/ZipPackageParser.d.ts +29 -0
  89. package/esm/package/ZipPackageParser.js +70 -0
  90. package/esm/parse/jcToTextAlign.d.ts +5 -0
  91. package/esm/parse/jcToTextAlign.js +21 -0
  92. package/esm/parse/parseBorder.d.ts +13 -0
  93. package/esm/parse/parseBorder.js +78 -0
  94. package/esm/parse/parseColor.d.ts +22 -0
  95. package/esm/parse/parseColor.js +131 -0
  96. package/esm/parse/parseFont.d.ts +7 -0
  97. package/esm/parse/parseFont.js +54 -0
  98. package/esm/parse/parseInd.d.ts +5 -0
  99. package/esm/parse/parseInd.js +27 -0
  100. package/esm/parse/parsePr.d.ts +8 -0
  101. package/esm/parse/parsePr.js +325 -0
  102. package/esm/parse/parseRelationship.d.ts +12 -0
  103. package/esm/parse/parseRelationship.js +40 -0
  104. package/esm/parse/parseSize.d.ts +27 -0
  105. package/esm/parse/parseSize.js +38 -0
  106. package/esm/parse/parseSpacing.d.ts +7 -0
  107. package/esm/parse/parseSpacing.js +43 -0
  108. package/esm/parse/parseTextDirection.d.ts +2 -0
  109. package/esm/parse/parseTextDirection.js +25 -0
  110. package/esm/parse/parseTrHeight.d.ts +2 -0
  111. package/esm/parse/parseTrHeight.js +17 -0
  112. package/esm/render/renderBody.d.ts +6 -0
  113. package/esm/render/renderBody.js +53 -0
  114. package/esm/render/renderBookmark.d.ts +6 -0
  115. package/esm/render/renderBookmark.js +17 -0
  116. package/esm/render/renderBr.d.ts +7 -0
  117. package/esm/render/renderBr.js +13 -0
  118. package/esm/render/renderDocument.d.ts +7 -0
  119. package/esm/render/renderDocument.js +14 -0
  120. package/esm/render/renderDrawing.d.ts +8 -0
  121. package/esm/render/renderDrawing.js +38 -0
  122. package/esm/render/renderHyperLink.d.ts +7 -0
  123. package/esm/render/renderHyperLink.js +41 -0
  124. package/esm/render/renderInlineText.d.ts +6 -0
  125. package/esm/render/renderInlineText.js +39 -0
  126. package/esm/render/renderInstrText.d.ts +8 -0
  127. package/esm/render/renderInstrText.js +40 -0
  128. package/esm/render/renderNumbering.d.ts +7 -0
  129. package/esm/render/renderNumbering.js +161 -0
  130. package/esm/render/renderParagraph.d.ts +7 -0
  131. package/esm/render/renderParagraph.js +78 -0
  132. package/esm/render/renderPict.d.ts +6 -0
  133. package/esm/render/renderPict.js +19 -0
  134. package/esm/render/renderRuby.d.ts +6 -0
  135. package/esm/render/renderRuby.js +53 -0
  136. package/esm/render/renderRun.d.ts +14 -0
  137. package/esm/render/renderRun.js +116 -0
  138. package/esm/render/renderSection.d.ts +6 -0
  139. package/esm/render/renderSection.js +36 -0
  140. package/esm/render/renderStyle.d.ts +13 -0
  141. package/esm/render/renderStyle.js +194 -0
  142. package/esm/render/renderSym.d.ts +3 -0
  143. package/esm/render/renderSym.js +10 -0
  144. package/esm/render/renderTab.d.ts +7 -0
  145. package/esm/render/renderTab.js +19 -0
  146. package/esm/render/renderTable.d.ts +6 -0
  147. package/esm/render/renderTable.js +186 -0
  148. package/esm/render/setElementStyle.d.ts +6 -0
  149. package/esm/render/setElementStyle.js +21 -0
  150. package/esm/util/autoSpace.d.ts +5 -0
  151. package/esm/util/autoSpace.js +33 -0
  152. package/esm/util/blob.d.ts +9 -0
  153. package/esm/util/blob.js +39 -0
  154. package/esm/util/dom.d.ts +36 -0
  155. package/esm/util/dom.js +63 -0
  156. package/esm/util/mergeRun.d.ts +17 -0
  157. package/esm/util/mergeRun.js +134 -0
  158. package/esm/util/xml.d.ts +8 -0
  159. package/esm/util/xml.js +12 -0
  160. package/lib/OpenXML.d.ts +21 -0
  161. package/lib/OpenXML.js +69 -0
  162. package/lib/Word.d.ts +208 -0
  163. package/lib/Word.js +374 -0
  164. package/lib/index.d.ts +6 -0
  165. package/lib/index.js +10 -0
  166. package/lib/node_modules/tslib/tslib.es6.js +129 -0
  167. package/lib/openxml/ContentType.d.ts +12 -0
  168. package/lib/openxml/ContentType.js +19 -0
  169. package/lib/openxml/Style.d.ts +41 -0
  170. package/lib/openxml/Style.js +160 -0
  171. package/lib/openxml/Theme.d.ts +26 -0
  172. package/lib/openxml/Theme.js +73 -0
  173. package/lib/openxml/Types.d.ts +2512 -0
  174. package/lib/openxml/Types.js +1005 -0
  175. package/lib/openxml/word/Background.d.ts +11 -0
  176. package/lib/openxml/word/Body.d.ts +18 -0
  177. package/lib/openxml/word/Body.js +71 -0
  178. package/lib/openxml/word/Bookmark.d.ts +6 -0
  179. package/lib/openxml/word/Bookmark.js +22 -0
  180. package/lib/openxml/word/Border.d.ts +10 -0
  181. package/lib/openxml/word/Break.d.ts +13 -0
  182. package/lib/openxml/word/Break.js +23 -0
  183. package/lib/openxml/word/CustomXml.d.ts +8 -0
  184. package/lib/openxml/word/FldSimple.d.ts +7 -0
  185. package/lib/openxml/word/FldSimple.js +19 -0
  186. package/lib/openxml/word/FrameProperties.d.ts +18 -0
  187. package/lib/openxml/word/Hyperlink.d.ts +13 -0
  188. package/lib/openxml/word/Hyperlink.js +57 -0
  189. package/lib/openxml/word/Indent.d.ts +8 -0
  190. package/lib/openxml/word/InlineText.d.ts +14 -0
  191. package/lib/openxml/word/InlineText.js +66 -0
  192. package/lib/openxml/word/InstrText.d.ts +4 -0
  193. package/lib/openxml/word/InstrText.js +12 -0
  194. package/lib/openxml/word/Paragraph.d.ts +34 -0
  195. package/lib/openxml/word/Paragraph.js +137 -0
  196. package/lib/openxml/word/Pict.d.ts +6 -0
  197. package/lib/openxml/word/Pict.js +23 -0
  198. package/lib/openxml/word/Ruby.d.ts +20 -0
  199. package/lib/openxml/word/Ruby.js +91 -0
  200. package/lib/openxml/word/Run.d.ts +31 -0
  201. package/lib/openxml/word/Run.js +103 -0
  202. package/lib/openxml/word/Section.d.ts +38 -0
  203. package/lib/openxml/word/Section.js +63 -0
  204. package/lib/openxml/word/Shading.d.ts +9 -0
  205. package/lib/openxml/word/SmartTag.d.ts +8 -0
  206. package/lib/openxml/word/SmartTag.js +22 -0
  207. package/lib/openxml/word/Spacing.d.ts +9 -0
  208. package/lib/openxml/word/Sym.d.ts +8 -0
  209. package/lib/openxml/word/Sym.js +20 -0
  210. package/lib/openxml/word/Tab.d.ts +8 -0
  211. package/lib/openxml/word/Tab.js +21 -0
  212. package/lib/openxml/word/Table.d.ts +49 -0
  213. package/lib/openxml/word/Table.js +252 -0
  214. package/lib/openxml/word/VerticalAlign.d.ts +6 -0
  215. package/lib/openxml/word/WDocument.d.ts +13 -0
  216. package/lib/openxml/word/WDocument.js +62 -0
  217. package/lib/openxml/word/drawing/Blip.d.ts +6 -0
  218. package/lib/openxml/word/drawing/Blip.js +21 -0
  219. package/lib/openxml/word/drawing/BlipFill.d.ts +9 -0
  220. package/lib/openxml/word/drawing/BlipFill.js +24 -0
  221. package/lib/openxml/word/drawing/Drawing.d.ts +6 -0
  222. package/lib/openxml/word/drawing/Drawing.js +19 -0
  223. package/lib/openxml/word/drawing/Pic.d.ts +8 -0
  224. package/lib/openxml/word/drawing/Pic.js +20 -0
  225. package/lib/openxml/word/drawing/ShapeProperties.d.ts +9 -0
  226. package/lib/openxml/word/drawing/ShapeProperties.js +24 -0
  227. package/lib/openxml/word/drawing/Transform.d.ts +17 -0
  228. package/lib/openxml/word/drawing/Transform.js +34 -0
  229. package/lib/openxml/word/numbering/AbstractNum.d.ts +13 -0
  230. package/lib/openxml/word/numbering/AbstractNum.js +46 -0
  231. package/lib/openxml/word/numbering/Lvl.d.ts +16 -0
  232. package/lib/openxml/word/numbering/Lvl.js +66 -0
  233. package/lib/openxml/word/numbering/Num.d.ts +10 -0
  234. package/lib/openxml/word/numbering/Num.js +50 -0
  235. package/lib/openxml/word/numbering/NumberProperties.d.ts +6 -0
  236. package/lib/openxml/word/numbering/NumberProperties.js +25 -0
  237. package/lib/openxml/word/numbering/Numbering.d.ts +9 -0
  238. package/lib/openxml/word/numbering/Numbering.js +54 -0
  239. package/lib/openxml/word/properties/Properties.d.ts +12 -0
  240. package/lib/openxml/word/table/Tc.d.ts +46 -0
  241. package/lib/openxml/word/table/Tc.js +242 -0
  242. package/lib/openxml/word/table/Tr.d.ts +18 -0
  243. package/lib/openxml/word/table/Tr.js +110 -0
  244. package/lib/package/PackageParser.d.ts +26 -0
  245. package/lib/package/XMLPackageParser.d.ts +31 -0
  246. package/lib/package/ZipPackageParser.d.ts +29 -0
  247. package/lib/package/ZipPackageParser.js +74 -0
  248. package/lib/parse/jcToTextAlign.d.ts +5 -0
  249. package/lib/parse/jcToTextAlign.js +25 -0
  250. package/lib/parse/parseBorder.d.ts +13 -0
  251. package/lib/parse/parseBorder.js +83 -0
  252. package/lib/parse/parseColor.d.ts +22 -0
  253. package/lib/parse/parseColor.js +137 -0
  254. package/lib/parse/parseFont.d.ts +7 -0
  255. package/lib/parse/parseFont.js +58 -0
  256. package/lib/parse/parseInd.d.ts +5 -0
  257. package/lib/parse/parseInd.js +31 -0
  258. package/lib/parse/parsePr.d.ts +8 -0
  259. package/lib/parse/parsePr.js +329 -0
  260. package/lib/parse/parseRelationship.d.ts +12 -0
  261. package/lib/parse/parseRelationship.js +45 -0
  262. package/lib/parse/parseSize.d.ts +27 -0
  263. package/lib/parse/parseSize.js +44 -0
  264. package/lib/parse/parseSpacing.d.ts +7 -0
  265. package/lib/parse/parseSpacing.js +47 -0
  266. package/lib/parse/parseTextDirection.d.ts +2 -0
  267. package/lib/parse/parseTextDirection.js +29 -0
  268. package/lib/parse/parseTrHeight.d.ts +2 -0
  269. package/lib/parse/parseTrHeight.js +21 -0
  270. package/lib/render/renderBody.d.ts +6 -0
  271. package/lib/render/renderBody.js +57 -0
  272. package/lib/render/renderBookmark.d.ts +6 -0
  273. package/lib/render/renderBookmark.js +21 -0
  274. package/lib/render/renderBr.d.ts +7 -0
  275. package/lib/render/renderBr.js +17 -0
  276. package/lib/render/renderDocument.d.ts +7 -0
  277. package/lib/render/renderDocument.js +18 -0
  278. package/lib/render/renderDrawing.d.ts +8 -0
  279. package/lib/render/renderDrawing.js +42 -0
  280. package/lib/render/renderHyperLink.d.ts +7 -0
  281. package/lib/render/renderHyperLink.js +45 -0
  282. package/lib/render/renderInlineText.d.ts +6 -0
  283. package/lib/render/renderInlineText.js +43 -0
  284. package/lib/render/renderInstrText.d.ts +8 -0
  285. package/lib/render/renderInstrText.js +44 -0
  286. package/lib/render/renderNumbering.d.ts +7 -0
  287. package/lib/render/renderNumbering.js +165 -0
  288. package/lib/render/renderParagraph.d.ts +7 -0
  289. package/lib/render/renderParagraph.js +82 -0
  290. package/lib/render/renderPict.d.ts +6 -0
  291. package/lib/render/renderPict.js +23 -0
  292. package/lib/render/renderRuby.d.ts +6 -0
  293. package/lib/render/renderRuby.js +57 -0
  294. package/lib/render/renderRun.d.ts +14 -0
  295. package/lib/render/renderRun.js +121 -0
  296. package/lib/render/renderSection.d.ts +6 -0
  297. package/lib/render/renderSection.js +40 -0
  298. package/lib/render/renderStyle.d.ts +13 -0
  299. package/lib/render/renderStyle.js +199 -0
  300. package/lib/render/renderSym.d.ts +3 -0
  301. package/lib/render/renderSym.js +14 -0
  302. package/lib/render/renderTab.d.ts +7 -0
  303. package/lib/render/renderTab.js +23 -0
  304. package/lib/render/renderTable.d.ts +6 -0
  305. package/lib/render/renderTable.js +190 -0
  306. package/lib/render/setElementStyle.d.ts +6 -0
  307. package/lib/render/setElementStyle.js +25 -0
  308. package/lib/util/autoSpace.d.ts +5 -0
  309. package/lib/util/autoSpace.js +37 -0
  310. package/lib/util/blob.d.ts +9 -0
  311. package/lib/util/blob.js +44 -0
  312. package/lib/util/dom.d.ts +36 -0
  313. package/lib/util/dom.js +72 -0
  314. package/lib/util/mergeRun.d.ts +17 -0
  315. package/lib/util/mergeRun.js +140 -0
  316. package/lib/util/xml.d.ts +8 -0
  317. package/lib/util/xml.js +16 -0
  318. package/package.json +91 -0
@@ -0,0 +1,252 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var tslib_es6 = require('../../node_modules/tslib/tslib.es6.js');
6
+ var OpenXML = require('../../OpenXML.js');
7
+ var parseBorder = require('../../parse/parseBorder.js');
8
+ var parseColor = require('../../parse/parseColor.js');
9
+ var parseSize = require('../../parse/parseSize.js');
10
+ var Types = require('../Types.js');
11
+ var Tc = require('./table/Tc.js');
12
+ var Tr = require('./table/Tr.js');
13
+
14
+ /**
15
+ * http://officeopenxml.com/WPtable.php
16
+ */
17
+ /**
18
+ * 表格的 jc 需要使用 float 来实现
19
+ * http://officeopenxml.com/WPtableAlignment.php
20
+ */
21
+ function parseTblJc(element, cssStyle) {
22
+ var val = OpenXML.getVal(element);
23
+ switch (val) {
24
+ case 'left':
25
+ case 'start':
26
+ // TODO: 会导致前面的文字掉下去,感觉还是不能支持这个功能
27
+ // cssStyle['float'] = 'left';
28
+ break;
29
+ case 'right':
30
+ case 'end':
31
+ cssStyle['float'] = 'right';
32
+ }
33
+ }
34
+ /**
35
+ * 这个其实分左右,但目前只支持左,右可能是阿拉伯语?
36
+ * http://webapp.docx4java.org/OnlineDemo/ecma376/WordML/tblInd_2.html
37
+ */
38
+ function parseTblInd(element, style) {
39
+ var width = Tc.parseTblWidth(element);
40
+ if (width) {
41
+ style['margin-left'] = width;
42
+ }
43
+ }
44
+ function parseTblW(element, style) {
45
+ var width = Tc.parseTblWidth(element);
46
+ if (width) {
47
+ style['width'] = width;
48
+ }
49
+ }
50
+ /**
51
+ * http://officeopenxml.com/WPtableLayout.php
52
+ */
53
+ function parseTblLayout(element, style) {
54
+ var type = element.getAttribute('w:type');
55
+ if (type === Types.ST_TblLayoutType.fixed) {
56
+ style['table-layout'] = 'fixed';
57
+ }
58
+ }
59
+ function parseTblGrid(element) {
60
+ var e_1, _a;
61
+ var gridCol = [];
62
+ var gridColElements = element.getElementsByTagName('w:gridCol');
63
+ try {
64
+ for (var gridColElements_1 = tslib_es6.__values(gridColElements), gridColElements_1_1 = gridColElements_1.next(); !gridColElements_1_1.done; gridColElements_1_1 = gridColElements_1.next()) {
65
+ var gridColElement = gridColElements_1_1.value;
66
+ var w = parseSize.parseSize(gridColElement, 'w:w');
67
+ gridCol.push({ w: w });
68
+ }
69
+ }
70
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
71
+ finally {
72
+ try {
73
+ if (gridColElements_1_1 && !gridColElements_1_1.done && (_a = gridColElements_1.return)) _a.call(gridColElements_1);
74
+ }
75
+ finally { if (e_1) throw e_1.error; }
76
+ }
77
+ return gridCol;
78
+ }
79
+ // http://webapp.docx4java.org/OnlineDemo/ecma376/WordML/ST_TblStyleOverrideType.html
80
+ // val 是旧的格式
81
+ function parseTblLook(child) {
82
+ var tblLook = {};
83
+ var tblLookVal = OpenXML.getValHex(child);
84
+ if (OpenXML.getAttrBoolean(child, 'firstRow', false) || tblLookVal & 0x0020) {
85
+ tblLook['firstRow'] = true;
86
+ }
87
+ if (OpenXML.getAttrBoolean(child, 'lastRow', false) || tblLookVal & 0x0040) {
88
+ tblLook['lastRow'] = true;
89
+ }
90
+ if (OpenXML.getAttrBoolean(child, 'firstColumn', false) || tblLookVal & 0x0080) {
91
+ tblLook['firstColumn'] = true;
92
+ }
93
+ if (OpenXML.getAttrBoolean(child, 'lastColumn', false) || tblLookVal & 0x0100) {
94
+ tblLook['lastColumn'] = true;
95
+ }
96
+ if (OpenXML.getAttrBoolean(child, 'noHBand', false) || tblLookVal & 0x0200) {
97
+ tblLook['noHBand'] = true;
98
+ }
99
+ else {
100
+ tblLook['noHBand'] = false;
101
+ }
102
+ if (OpenXML.getAttrBoolean(child, 'noVBand', false) || tblLookVal & 0x0400) {
103
+ tblLook['noVBand'] = true;
104
+ }
105
+ else {
106
+ tblLook['noVBand'] = false;
107
+ }
108
+ return tblLook;
109
+ }
110
+ /**
111
+ * http://webapp.docx4java.org/OnlineDemo/ecma376/WordML/tblpPr.html
112
+ * 只支持部分
113
+ */
114
+ function parsetTlpPr(word, child, style) {
115
+ // 如果设置 padding 会导致绝对定位不准确,所以一旦设置就不支持
116
+ if (typeof word.renderOptions.padding === 'undefined') {
117
+ var tplpX = parseSize.parseSize(child, 'w:tblpX');
118
+ var tplpY = parseSize.parseSize(child, 'w:tblpY');
119
+ style.position = 'absolute';
120
+ style.top = tplpY;
121
+ style.left = tplpX;
122
+ }
123
+ // 之前想用 float 来实现,但是会导致文字掉下去
124
+ // const topFromText = parseSize(child, 'w:topFromText');
125
+ // const bottomFromText = parseSize(child, 'w:bottomFromText');
126
+ // const rightFromText = parseSize(child, 'w:rightFromText');
127
+ // const leftFromText = parseSize(child, 'w:leftFromText');
128
+ // style['float'] = 'left';
129
+ // style['margin-bottom'] = addSize(style['margin-bottom'], bottomFromText);
130
+ // style['margin-left'] = addSize(style['margin-left'], leftFromText);
131
+ // style['margin-right'] = addSize(style['margin-right'], rightFromText);
132
+ // style['margin-top'] = addSize(style['margin-top'], topFromText);
133
+ }
134
+ var Table = /** @class */ (function () {
135
+ function Table() {
136
+ this.properties = {};
137
+ this.tblGrid = [];
138
+ this.trs = [];
139
+ }
140
+ Table.parseTablePr = function (word, element) {
141
+ var e_2, _a;
142
+ var properties = {};
143
+ var tableStyle = {};
144
+ var tcStyle = {};
145
+ properties.tblLook = {};
146
+ properties.cssStyle = tableStyle;
147
+ properties.tcCSSStyle = tcStyle;
148
+ try {
149
+ for (var _b = tslib_es6.__values(element.children), _c = _b.next(); !_c.done; _c = _b.next()) {
150
+ var child = _c.value;
151
+ var tagName = child.tagName;
152
+ switch (tagName) {
153
+ case 'w:tblBorders':
154
+ parseBorder.parseBorders(word, child, tableStyle);
155
+ properties.insideBorder = Tc.parseInsideBorders(word, child);
156
+ break;
157
+ case 'w:tcBorders':
158
+ parseBorder.parseBorders(word, child, tableStyle);
159
+ break;
160
+ case 'w:tblInd':
161
+ parseTblInd(child, tableStyle);
162
+ break;
163
+ case 'w:jc':
164
+ parseTblJc(child, tableStyle);
165
+ break;
166
+ case 'w:tblCellMar':
167
+ case 'w:tcMar':
168
+ // http://webapp.docx4java.org/OnlineDemo/ecma376/WordML/tblCellMar_1.html
169
+ Tc.parseCellMargin(child, tcStyle);
170
+ break;
171
+ case 'w:tblStyle':
172
+ properties.pStyle = OpenXML.getVal(child);
173
+ break;
174
+ case 'w:tblW':
175
+ parseTblW(child, tableStyle);
176
+ break;
177
+ case 'w:shd':
178
+ // http://officeopenxml.com/WPtableShading.php
179
+ tableStyle['background-color'] = parseColor.parseShdColor(word, child);
180
+ break;
181
+ case 'w:tblCaption':
182
+ properties.tblCaption = OpenXML.getVal(child);
183
+ break;
184
+ case 'w:tblCellSpacing':
185
+ Tc.parseTblCellSpacing(child, tableStyle);
186
+ break;
187
+ case 'w:tblLayout':
188
+ parseTblLayout(child, tableStyle);
189
+ break;
190
+ case 'w:tblLook':
191
+ properties.tblLook = parseTblLook(child);
192
+ break;
193
+ case 'w:tblStyleRowBandSize':
194
+ properties.rowBandSize = OpenXML.getValNumber(child);
195
+ break;
196
+ case 'w:tblStyleColBandSize':
197
+ properties.colBandSize = OpenXML.getValNumber(child);
198
+ break;
199
+ case 'w:tblpPr':
200
+ parsetTlpPr(word, child, tableStyle);
201
+ break;
202
+ default:
203
+ console.warn('parseTableProperties unknown tag', tagName, child);
204
+ }
205
+ }
206
+ }
207
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
208
+ finally {
209
+ try {
210
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
211
+ }
212
+ finally { if (e_2) throw e_2.error; }
213
+ }
214
+ return properties;
215
+ };
216
+ Table.fromXML = function (word, element) {
217
+ var e_3, _a;
218
+ var table = new Table();
219
+ // 用于计算列的跨行,这里记下前面的跨行情况
220
+ var rowSpanMap = {};
221
+ try {
222
+ for (var _b = tslib_es6.__values(element.children), _c = _b.next(); !_c.done; _c = _b.next()) {
223
+ var child = _c.value;
224
+ var tagName = child.tagName;
225
+ switch (tagName) {
226
+ case 'w:tblPr':
227
+ table.properties = Table.parseTablePr(word, child);
228
+ break;
229
+ case 'w:tr':
230
+ table.trs.push(Tr.Tr.fromXML(word, child, rowSpanMap));
231
+ break;
232
+ case 'w:tblGrid':
233
+ table.tblGrid = parseTblGrid(child);
234
+ break;
235
+ default:
236
+ console.warn('Table.fromXML unknown tag', tagName, child);
237
+ }
238
+ }
239
+ }
240
+ catch (e_3_1) { e_3 = { error: e_3_1 }; }
241
+ finally {
242
+ try {
243
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
244
+ }
245
+ finally { if (e_3) throw e_3.error; }
246
+ }
247
+ return table;
248
+ };
249
+ return Table;
250
+ }());
251
+
252
+ exports.Table = Table;
@@ -0,0 +1,6 @@
1
+ export interface VerticalAlign {
2
+ }
3
+ export interface SuperScript extends VerticalAlign {
4
+ }
5
+ export interface SubScript extends VerticalAlign {
6
+ }
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Document 解析及类型定义
3
+ * http://webapp.docx4java.org/OnlineDemo/ecma376/WordML/document.html
4
+ * http://webapp.docx4java.org/OnlineDemo/ecma376/WordML/Main%20Document%20Story.html
5
+ */
6
+ import Word from '../../Word';
7
+ import { DocumentBackground } from './Background';
8
+ import { Body } from './Body';
9
+ export declare class WDocument {
10
+ body: Body;
11
+ documentBackground?: DocumentBackground;
12
+ static fromXML(word: Word, element: Document): WDocument;
13
+ }
@@ -0,0 +1,62 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var tslib_es6 = require('../../node_modules/tslib/tslib.es6.js');
6
+ var parseColor = require('../../parse/parseColor.js');
7
+ var Body = require('./Body.js');
8
+
9
+ /**
10
+ * Document 解析及类型定义
11
+ * http://webapp.docx4java.org/OnlineDemo/ecma376/WordML/document.html
12
+ * http://webapp.docx4java.org/OnlineDemo/ecma376/WordML/Main%20Document%20Story.html
13
+ */
14
+ var WDocument = /** @class */ (function () {
15
+ function WDocument() {
16
+ }
17
+ WDocument.fromXML = function (word, element) {
18
+ var e_1, _a;
19
+ var doc = new WDocument();
20
+ var body = element.querySelector('body');
21
+ if (body) {
22
+ doc.body = Body.Body.fromXML(word, body);
23
+ }
24
+ var background = element.querySelector('background');
25
+ if (background) {
26
+ var documentBackground = {};
27
+ try {
28
+ for (var _b = tslib_es6.__values(background.attributes), _c = _b.next(); !_c.done; _c = _b.next()) {
29
+ var attr = _c.value;
30
+ var name_1 = attr.name;
31
+ switch (name_1) {
32
+ case 'w:color':
33
+ documentBackground.color = parseColor.parseColorAttr(word, background, 'w:color');
34
+ break;
35
+ case 'w:themeColor':
36
+ documentBackground.themeColor = parseColor.parseColorAttr(word, background, 'w:themeColor');
37
+ break;
38
+ case 'w:themeShade':
39
+ documentBackground.themeShade = parseColor.parseColorAttr(word, background, 'w:themeShade');
40
+ break;
41
+ case 'w:themeTint':
42
+ documentBackground.themeTint = parseColor.parseColorAttr(word, background, 'w:themeTint');
43
+ break;
44
+ default:
45
+ break;
46
+ }
47
+ }
48
+ }
49
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
50
+ finally {
51
+ try {
52
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
53
+ }
54
+ finally { if (e_1) throw e_1.error; }
55
+ }
56
+ }
57
+ return doc;
58
+ };
59
+ return WDocument;
60
+ }());
61
+
62
+ exports.WDocument = WDocument;
@@ -0,0 +1,6 @@
1
+ import { Relationship } from '../../../parse/parseRelationship';
2
+ import Word from '../../../Word';
3
+ export declare class Blip {
4
+ embled?: Relationship;
5
+ static fromXML(word: Word, element: Element): Blip;
6
+ }
@@ -0,0 +1,21 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var Blip = /** @class */ (function () {
6
+ function Blip() {
7
+ }
8
+ Blip.fromXML = function (word, element) {
9
+ var blip = new Blip();
10
+ // 目前值支持 embed 这一种
11
+ var embedId = element.getAttribute('r:embed') || '';
12
+ var rel = word.getRelationship(embedId);
13
+ if (rel) {
14
+ blip.embled = rel;
15
+ }
16
+ return blip;
17
+ };
18
+ return Blip;
19
+ }());
20
+
21
+ exports.Blip = Blip;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * http://webapp.docx4java.org/OnlineDemo/ecma376/DrawingML/blipFill_2.html
3
+ */
4
+ import Word from '../../../Word';
5
+ import { Blip } from './Blip';
6
+ export declare class BlipFill {
7
+ blip?: Blip;
8
+ static fromXML(word: Word, element?: Element | null): BlipFill;
9
+ }
@@ -0,0 +1,24 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var Blip = require('./Blip.js');
6
+
7
+ /**
8
+ * http://webapp.docx4java.org/OnlineDemo/ecma376/DrawingML/blipFill_2.html
9
+ */
10
+ var BlipFill = /** @class */ (function () {
11
+ function BlipFill() {
12
+ }
13
+ BlipFill.fromXML = function (word, element) {
14
+ var blipFill = new BlipFill();
15
+ var blip = element === null || element === void 0 ? void 0 : element.querySelector('blip');
16
+ if (blip) {
17
+ blipFill.blip = Blip.Blip.fromXML(word, blip);
18
+ }
19
+ return blipFill;
20
+ };
21
+ return BlipFill;
22
+ }());
23
+
24
+ exports.BlipFill = BlipFill;
@@ -0,0 +1,6 @@
1
+ import Word from '../../../Word';
2
+ import { Pic } from './Pic';
3
+ export declare class Drawing {
4
+ pic: Pic;
5
+ static fromXML(word: Word, element: Element): Drawing | null;
6
+ }
@@ -0,0 +1,19 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var Pic = require('./Pic.js');
6
+
7
+ var Drawing = /** @class */ (function () {
8
+ function Drawing() {
9
+ }
10
+ Drawing.fromXML = function (word, element) {
11
+ var drawing = new Drawing();
12
+ var pic = element.querySelector('pic');
13
+ drawing.pic = Pic.Pic.fromXML(word, pic);
14
+ return drawing;
15
+ };
16
+ return Drawing;
17
+ }());
18
+
19
+ exports.Drawing = Drawing;
@@ -0,0 +1,8 @@
1
+ import Word from '../../../Word';
2
+ import { BlipFill } from './BlipFill';
3
+ import { ShapePr } from './ShapeProperties';
4
+ export declare class Pic {
5
+ blipFill: BlipFill;
6
+ spPr: ShapePr;
7
+ static fromXML(word: Word, element?: Element | null): Pic;
8
+ }
@@ -0,0 +1,20 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var BlipFill = require('./BlipFill.js');
6
+ var ShapeProperties = require('./ShapeProperties.js');
7
+
8
+ var Pic = /** @class */ (function () {
9
+ function Pic() {
10
+ }
11
+ Pic.fromXML = function (word, element) {
12
+ var pic = new Pic();
13
+ pic.blipFill = BlipFill.BlipFill.fromXML(word, element === null || element === void 0 ? void 0 : element.querySelector('blipFill'));
14
+ pic.spPr = ShapeProperties.ShapePr.fromXML(word, element === null || element === void 0 ? void 0 : element.querySelector('spPr'));
15
+ return pic;
16
+ };
17
+ return Pic;
18
+ }());
19
+
20
+ exports.Pic = Pic;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * http://webapp.docx4java.org/OnlineDemo/ecma376/DrawingML/spPr_2.html
3
+ */
4
+ import Word from '../../../Word';
5
+ import { Transform } from './Transform';
6
+ export declare class ShapePr {
7
+ xfrm?: Transform;
8
+ static fromXML(word: Word, element?: Element | null): ShapePr;
9
+ }
@@ -0,0 +1,24 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var Transform = require('./Transform.js');
6
+
7
+ /**
8
+ * http://webapp.docx4java.org/OnlineDemo/ecma376/DrawingML/spPr_2.html
9
+ */
10
+ var ShapePr = /** @class */ (function () {
11
+ function ShapePr() {
12
+ }
13
+ ShapePr.fromXML = function (word, element) {
14
+ var shapePr = new ShapePr();
15
+ var xfrm = element === null || element === void 0 ? void 0 : element.querySelector('xfrm');
16
+ if (xfrm) {
17
+ shapePr.xfrm = Transform.Transform.fromXML(word, xfrm);
18
+ }
19
+ return shapePr;
20
+ };
21
+ return ShapePr;
22
+ }());
23
+
24
+ exports.ShapePr = ShapePr;
@@ -0,0 +1,17 @@
1
+ /**
2
+ * http://webapp.docx4java.org/OnlineDemo/ecma376/DrawingML/xfrm_2.html
3
+ */
4
+ import Word from '../../../Word';
5
+ export interface Off {
6
+ x: string;
7
+ y: string;
8
+ }
9
+ export interface Ext {
10
+ cx: string;
11
+ cy: string;
12
+ }
13
+ export declare class Transform {
14
+ off?: Off;
15
+ ext?: Ext;
16
+ static fromXML(word: Word, element: Element): Transform;
17
+ }
@@ -0,0 +1,34 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var parseSize = require('../../../parse/parseSize.js');
6
+
7
+ /**
8
+ * http://webapp.docx4java.org/OnlineDemo/ecma376/DrawingML/xfrm_2.html
9
+ */
10
+ var Transform = /** @class */ (function () {
11
+ function Transform() {
12
+ }
13
+ Transform.fromXML = function (word, element) {
14
+ var transform = new Transform();
15
+ var off = element.querySelector('off');
16
+ if (off) {
17
+ transform.off = {
18
+ x: parseSize.parseSize(off, 'x', parseSize.LengthUsage.Emu),
19
+ y: parseSize.parseSize(off, 'y', parseSize.LengthUsage.Emu)
20
+ };
21
+ }
22
+ var ext = element.querySelector('ext');
23
+ if (ext) {
24
+ transform.ext = {
25
+ cx: parseSize.parseSize(ext, 'cx', parseSize.LengthUsage.Emu),
26
+ cy: parseSize.parseSize(ext, 'cy', parseSize.LengthUsage.Emu)
27
+ };
28
+ }
29
+ return transform;
30
+ };
31
+ return Transform;
32
+ }());
33
+
34
+ exports.Transform = Transform;
@@ -0,0 +1,13 @@
1
+ /**
2
+ * lvl 的解析,只支持部分
3
+ * http://webapp.docx4java.org/OnlineDemo/ecma376/WordML/abstractNum.html
4
+ */
5
+ import { ST_MultiLevelType } from '../../Types';
6
+ import { Lvl } from './Lvl';
7
+ import Word from '../../../Word';
8
+ export declare class AbstractNum {
9
+ abstractNumId: string;
10
+ multiLevelType?: ST_MultiLevelType;
11
+ lvls: Record<string, Lvl>;
12
+ static fromXML(word: Word, element: Element): AbstractNum;
13
+ }
@@ -0,0 +1,46 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var tslib_es6 = require('../../../node_modules/tslib/tslib.es6.js');
6
+ var Lvl = require('./Lvl.js');
7
+ var OpenXML = require('../../../OpenXML.js');
8
+
9
+ /**
10
+ * lvl 的解析,只支持部分
11
+ * http://webapp.docx4java.org/OnlineDemo/ecma376/WordML/abstractNum.html
12
+ */
13
+ var AbstractNum = /** @class */ (function () {
14
+ function AbstractNum() {
15
+ this.lvls = {};
16
+ }
17
+ AbstractNum.fromXML = function (word, element) {
18
+ var e_1, _a;
19
+ var abstractNum = new AbstractNum();
20
+ abstractNum.abstractNumId = element.getAttribute('w:abstractNumId') || '';
21
+ abstractNum.multiLevelType = element.getAttribute('w:multiLevelType');
22
+ var lvls = element.getElementsByTagName('w:lvl');
23
+ try {
24
+ for (var lvls_1 = tslib_es6.__values(lvls), lvls_1_1 = lvls_1.next(); !lvls_1_1.done; lvls_1_1 = lvls_1.next()) {
25
+ var child = lvls_1_1.value;
26
+ var lvlId = child.getAttribute('w:ilvl') || '';
27
+ abstractNum.lvls[lvlId] = Lvl.Lvl.fromXML(word, child);
28
+ }
29
+ }
30
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
31
+ finally {
32
+ try {
33
+ if (lvls_1_1 && !lvls_1_1.done && (_a = lvls_1.return)) _a.call(lvls_1);
34
+ }
35
+ finally { if (e_1) throw e_1.error; }
36
+ }
37
+ var multiLevelType = element.querySelector('multiLevelType');
38
+ if (multiLevelType) {
39
+ abstractNum.multiLevelType = OpenXML.getVal(multiLevelType);
40
+ }
41
+ return abstractNum;
42
+ };
43
+ return AbstractNum;
44
+ }());
45
+
46
+ exports.AbstractNum = AbstractNum;
@@ -0,0 +1,16 @@
1
+ import { RunPr } from './../Run';
2
+ import { ST_Jc, ST_LevelSuffix, ST_NumberFormat } from '../../Types';
3
+ import { ParagraphPr } from '../Paragraph';
4
+ import Word from '../../../Word';
5
+ export declare class Lvl {
6
+ ilvl: string;
7
+ start: number;
8
+ numFmt: ST_NumberFormat;
9
+ lvlText: string;
10
+ isLgl: boolean;
11
+ lvlJc: ST_Jc;
12
+ suff: ST_LevelSuffix;
13
+ pPr?: ParagraphPr;
14
+ rPr?: RunPr;
15
+ static fromXML(word: Word, element: Element): Lvl;
16
+ }