office-viewer 0.1.0 → 0.1.4

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 (446) hide show
  1. package/README.md +6 -1
  2. package/esm/OpenXML.d.ts +19 -0
  3. package/esm/OpenXML.js +43 -2
  4. package/esm/Word.d.ts +132 -15
  5. package/esm/Word.js +239 -54
  6. package/esm/openxml/ContentType.js +20 -6
  7. package/esm/openxml/Settings.d.ts +10 -0
  8. package/esm/openxml/Settings.js +93 -0
  9. package/esm/openxml/Style.d.ts +1 -1
  10. package/esm/openxml/Style.js +12 -12
  11. package/esm/openxml/Theme.js +30 -6
  12. package/esm/openxml/Types.d.ts +179 -2472
  13. package/esm/openxml/drawing/Blip.d.ts +7 -0
  14. package/esm/openxml/{word/drawing → drawing}/Blip.js +2 -1
  15. package/{lib/openxml/word → esm/openxml}/drawing/BlipFill.d.ts +1 -1
  16. package/esm/openxml/{word/drawing → drawing}/BlipFill.js +1 -1
  17. package/esm/openxml/drawing/CustomGeom.d.ts +9 -0
  18. package/esm/openxml/drawing/CustomGeom.js +17 -0
  19. package/esm/openxml/drawing/Drawing.d.ts +37 -0
  20. package/esm/openxml/drawing/Drawing.js +173 -0
  21. package/esm/openxml/drawing/Geom.d.ts +11 -0
  22. package/esm/openxml/drawing/Geom.js +34 -0
  23. package/esm/openxml/drawing/Path.d.ts +37 -0
  24. package/esm/openxml/drawing/Pic.d.ts +16 -0
  25. package/esm/openxml/drawing/Pic.js +26 -0
  26. package/esm/openxml/drawing/Shape.d.ts +20 -0
  27. package/esm/openxml/drawing/ShapeProperties.d.ts +22 -0
  28. package/esm/openxml/drawing/ShapeProperties.js +119 -0
  29. package/{lib/openxml/word → esm/openxml}/drawing/Transform.d.ts +4 -1
  30. package/esm/openxml/drawing/Transform.js +63 -0
  31. package/esm/openxml/drawing/diagram/Diagram.d.ts +7 -0
  32. package/esm/openxml/drawing/diagram/Diagram.js +24 -0
  33. package/esm/openxml/drawing/diagram/Sp.d.ts +2 -0
  34. package/esm/openxml/drawing/diagram/SpTree.d.ts +5 -0
  35. package/esm/openxml/drawing/presetShape.d.ts +3 -0
  36. package/esm/openxml/drawing/presetShape.js +38785 -0
  37. package/esm/openxml/drawing/svg/arcToA.d.ts +13 -0
  38. package/esm/openxml/drawing/svg/arcToA.js +88 -0
  39. package/esm/openxml/drawing/svg/formulas.d.ts +29 -0
  40. package/esm/openxml/drawing/svg/formulas.js +103 -0
  41. package/esm/openxml/drawing/svg/generateDefines.d.ts +12 -0
  42. package/esm/openxml/drawing/svg/generateDefines.js +144 -0
  43. package/esm/openxml/drawing/svg/presetVal.d.ts +43 -0
  44. package/esm/openxml/drawing/svg/presetVal.js +53 -0
  45. package/esm/openxml/drawing/svg/shapeToSVG.d.ts +9 -0
  46. package/esm/openxml/drawing/svg/shapeToSVG.js +151 -0
  47. package/esm/openxml/math/OMath.d.ts +5 -0
  48. package/esm/openxml/math/OMath.js +12 -0
  49. package/esm/openxml/math/convertOOML.d.ts +4 -0
  50. package/esm/openxml/math/convertOOML.js +13 -0
  51. package/esm/openxml/math/xsl.d.ts +4 -0
  52. package/esm/openxml/math/xsl.js +8 -0
  53. package/esm/openxml/word/Body.js +11 -7
  54. package/esm/openxml/word/Break.js +1 -3
  55. package/esm/openxml/word/Font.d.ts +16 -0
  56. package/esm/openxml/word/Font.js +78 -0
  57. package/esm/openxml/word/FontTable.d.ts +9 -0
  58. package/esm/openxml/word/FontTable.js +34 -0
  59. package/esm/openxml/word/Header.d.ts +11 -0
  60. package/esm/openxml/word/Header.js +54 -0
  61. package/esm/openxml/word/Hyperlink.d.ts +1 -0
  62. package/esm/openxml/word/Hyperlink.js +7 -3
  63. package/esm/openxml/word/InlineText.js +1 -1
  64. package/esm/openxml/word/NoBreakHyphen.d.ts +2 -0
  65. package/esm/openxml/word/NoBreakHyphen.js +7 -0
  66. package/esm/openxml/word/Note.d.ts +12 -0
  67. package/esm/openxml/word/Note.js +48 -0
  68. package/esm/openxml/word/Paragraph.d.ts +2 -2
  69. package/esm/openxml/word/Paragraph.js +10 -9
  70. package/esm/openxml/word/Pict.d.ts +1 -2
  71. package/esm/openxml/word/Pict.js +5 -3
  72. package/esm/openxml/word/Ruby.js +1 -1
  73. package/esm/openxml/word/Run.d.ts +7 -3
  74. package/esm/openxml/word/Run.js +28 -4
  75. package/esm/openxml/word/Section.d.ts +18 -5
  76. package/esm/openxml/word/Section.js +46 -2
  77. package/esm/openxml/word/Separator.d.ts +5 -0
  78. package/esm/openxml/word/Separator.js +10 -0
  79. package/esm/openxml/word/SoftHyphen.d.ts +5 -0
  80. package/esm/openxml/word/SoftHyphen.js +10 -0
  81. package/esm/openxml/word/Tab.d.ts +1 -1
  82. package/esm/openxml/word/Table.d.ts +4 -9
  83. package/esm/openxml/word/Table.js +0 -235
  84. package/esm/openxml/word/WDocument.d.ts +1 -2
  85. package/esm/openxml/word/WDocument.js +53 -7
  86. package/esm/openxml/word/numbering/AbstractNum.js +4 -2
  87. package/esm/openxml/word/numbering/Lvl.js +10 -4
  88. package/esm/openxml/word/numbering/Num.js +12 -4
  89. package/esm/openxml/word/numbering/NumberProperties.js +2 -2
  90. package/esm/openxml/word/numbering/Numbering.js +1 -1
  91. package/esm/openxml/word/table/Tc.d.ts +1 -22
  92. package/esm/openxml/word/table/Tc.js +1 -221
  93. package/esm/openxml/word/table/Tr.d.ts +0 -5
  94. package/esm/openxml/word/table/Tr.js +0 -97
  95. package/esm/openxml/word/wps/WPG.d.ts +14 -0
  96. package/esm/openxml/word/wps/WPG.js +56 -0
  97. package/esm/openxml/word/wps/WPS.d.ts +18 -0
  98. package/esm/openxml/word/wps/WPS.js +148 -0
  99. package/esm/openxml/word/wps/WPSStyle.d.ts +10 -0
  100. package/esm/openxml/word/wps/WPSStyle.js +42 -0
  101. package/esm/package/PackageParser.d.ts +1 -1
  102. package/esm/package/XMLPackageParser.d.ts +3 -3
  103. package/esm/package/ZipPackageParser.d.ts +1 -1
  104. package/esm/package/ZipPackageParser.js +7 -8
  105. package/esm/parse/Footnotes.d.ts +3 -0
  106. package/esm/parse/Footnotes.js +25 -0
  107. package/esm/parse/colorNameMap.d.ts +6 -0
  108. package/esm/parse/colorNameMap.js +201 -0
  109. package/esm/parse/jcToTextAlign.js +1 -0
  110. package/esm/parse/mergeSdt.d.ts +4 -0
  111. package/esm/parse/mergeSdt.js +57 -0
  112. package/esm/parse/modifyColor.d.ts +1 -0
  113. package/esm/parse/modifyColor.js +106 -0
  114. package/esm/parse/parseBorder.js +2 -21
  115. package/esm/parse/parseCellMargin.d.ts +2 -0
  116. package/esm/parse/parseCellMargin.js +38 -0
  117. package/esm/parse/parseChildColor.d.ts +5 -0
  118. package/esm/parse/parseChildColor.js +66 -0
  119. package/esm/parse/parseColor.d.ts +4 -0
  120. package/esm/parse/parseColor.js +41 -46
  121. package/esm/parse/parseEndnotes.d.ts +3 -0
  122. package/esm/parse/parseEndnotes.js +25 -0
  123. package/esm/parse/parseFont.js +1 -1
  124. package/esm/parse/parseInsideBorders.d.ts +9 -0
  125. package/esm/parse/parseInsideBorders.js +24 -0
  126. package/esm/parse/parsePr.d.ts +3 -0
  127. package/esm/parse/parsePr.js +108 -11
  128. package/esm/parse/parseRelationship.js +1 -1
  129. package/esm/parse/parseSdt.d.ts +5 -0
  130. package/esm/parse/parseShape.d.ts +10 -0
  131. package/esm/parse/parseShape.js +239 -0
  132. package/esm/parse/parseSize.d.ts +2 -1
  133. package/esm/parse/parseSize.js +7 -1
  134. package/esm/parse/parseSpacing.js +1 -1
  135. package/esm/parse/parseTable.d.ts +3 -0
  136. package/esm/parse/parseTable.js +62 -0
  137. package/esm/parse/parseTablePr.d.ts +3 -0
  138. package/esm/parse/parseTablePr.js +185 -0
  139. package/esm/parse/parseTblWidth.d.ts +4 -0
  140. package/esm/parse/parseTblWidth.js +23 -0
  141. package/esm/parse/parseTc.d.ts +10 -0
  142. package/esm/parse/parseTc.js +64 -0
  143. package/esm/parse/parseTcPr.d.ts +5 -0
  144. package/esm/parse/parseTcPr.js +99 -0
  145. package/esm/parse/parseTextDirection.js +4 -6
  146. package/esm/parse/parseTr.d.ts +6 -0
  147. package/esm/parse/parseTr.js +49 -0
  148. package/esm/parse/parseTrPr.d.ts +3 -0
  149. package/esm/parse/parseTrPr.js +59 -0
  150. package/esm/render/fixAbsolutePosition.d.ts +8 -0
  151. package/esm/render/renderBody.d.ts +6 -2
  152. package/esm/render/renderBody.js +184 -30
  153. package/esm/render/renderBr.d.ts +2 -1
  154. package/esm/render/renderBr.js +4 -1
  155. package/esm/render/renderCustGeom.d.ts +4 -0
  156. package/esm/render/renderCustGeom.js +10 -0
  157. package/esm/render/renderDocument.d.ts +2 -2
  158. package/esm/render/renderDocument.js +2 -2
  159. package/esm/render/renderDrawing.d.ts +3 -2
  160. package/esm/render/renderDrawing.js +238 -21
  161. package/esm/render/renderFont.d.ts +5 -0
  162. package/esm/render/renderFont.js +39 -0
  163. package/esm/render/renderGeom.d.ts +4 -0
  164. package/esm/render/renderGeom.js +14 -0
  165. package/esm/render/renderHeader.d.ts +6 -0
  166. package/esm/render/renderHeader.js +40 -0
  167. package/esm/render/renderHyperLink.js +4 -1
  168. package/esm/render/renderInlineText.js +1 -1
  169. package/esm/render/renderInstrText.js +1 -1
  170. package/esm/render/renderMath.d.ts +3 -0
  171. package/esm/render/renderMath.js +7 -0
  172. package/esm/render/renderNoBreakHyphen.d.ts +1 -0
  173. package/esm/render/renderNoBreakHyphen.js +9 -0
  174. package/esm/render/renderNotes.d.ts +5 -0
  175. package/esm/render/renderNotes.js +77 -0
  176. package/esm/render/renderNumbering.js +8 -10
  177. package/esm/render/renderParagraph.d.ts +1 -1
  178. package/esm/render/renderParagraph.js +58 -18
  179. package/esm/render/renderPict.js +5 -10
  180. package/esm/render/renderRuby.js +1 -1
  181. package/esm/render/renderRun.d.ts +4 -2
  182. package/esm/render/renderRun.js +42 -12
  183. package/esm/render/renderSection.d.ts +3 -2
  184. package/esm/render/renderSection.js +79 -5
  185. package/esm/render/renderSeparator.d.ts +1 -0
  186. package/esm/render/renderSeparator.js +9 -0
  187. package/esm/render/renderSoftHyphen.d.ts +1 -0
  188. package/esm/render/renderSoftHyphen.js +9 -0
  189. package/esm/render/renderStyle.js +36 -35
  190. package/esm/render/renderTab.d.ts +2 -1
  191. package/esm/render/renderTab.js +10 -6
  192. package/esm/render/renderTable.js +23 -20
  193. package/esm/render/setElementStyle.js +7 -2
  194. package/esm/render/zindex.d.ts +1 -0
  195. package/esm/util/blob.js +1 -10
  196. package/esm/util/color.d.ts +48 -0
  197. package/esm/util/color.js +211 -0
  198. package/esm/util/createObject.d.ts +10 -0
  199. package/esm/util/createObject.js +48 -0
  200. package/esm/util/dom.d.ts +8 -4
  201. package/esm/util/dom.js +21 -4
  202. package/esm/util/get.d.ts +4 -0
  203. package/esm/util/get.js +18 -0
  204. package/esm/util/mergeRun.js +1 -1
  205. package/esm/util/parseSides.d.ts +11 -0
  206. package/esm/util/print.d.ts +5 -0
  207. package/esm/util/print.js +54 -0
  208. package/esm/util/replaceVar.d.ts +10 -0
  209. package/esm/util/replaceVar.js +215 -0
  210. package/esm/util/xml.js +4 -1
  211. package/lib/OpenXML.d.ts +19 -0
  212. package/lib/OpenXML.js +44 -1
  213. package/lib/Word.d.ts +132 -15
  214. package/lib/Word.js +244 -59
  215. package/lib/openxml/ContentType.js +20 -6
  216. package/lib/openxml/Settings.d.ts +10 -0
  217. package/lib/openxml/Settings.js +97 -0
  218. package/lib/openxml/Style.d.ts +1 -1
  219. package/lib/openxml/Style.js +15 -15
  220. package/lib/openxml/Theme.js +31 -7
  221. package/lib/openxml/Types.d.ts +179 -2472
  222. package/lib/openxml/drawing/Blip.d.ts +7 -0
  223. package/lib/openxml/{word/drawing → drawing}/Blip.js +2 -1
  224. package/{esm/openxml/word → lib/openxml}/drawing/BlipFill.d.ts +1 -1
  225. package/lib/openxml/{word/drawing → drawing}/BlipFill.js +1 -1
  226. package/lib/openxml/drawing/CustomGeom.d.ts +9 -0
  227. package/lib/openxml/drawing/CustomGeom.js +21 -0
  228. package/lib/openxml/drawing/Drawing.d.ts +37 -0
  229. package/lib/openxml/drawing/Drawing.js +177 -0
  230. package/lib/openxml/drawing/Geom.d.ts +11 -0
  231. package/lib/openxml/drawing/Geom.js +38 -0
  232. package/lib/openxml/drawing/Path.d.ts +37 -0
  233. package/lib/openxml/drawing/Pic.d.ts +16 -0
  234. package/lib/openxml/drawing/Pic.js +30 -0
  235. package/lib/openxml/drawing/Shape.d.ts +20 -0
  236. package/lib/openxml/drawing/ShapeProperties.d.ts +22 -0
  237. package/lib/openxml/drawing/ShapeProperties.js +123 -0
  238. package/{esm/openxml/word → lib/openxml}/drawing/Transform.d.ts +4 -1
  239. package/lib/openxml/drawing/Transform.js +67 -0
  240. package/lib/openxml/drawing/diagram/Diagram.d.ts +7 -0
  241. package/lib/openxml/drawing/diagram/Diagram.js +28 -0
  242. package/lib/openxml/drawing/diagram/Sp.d.ts +2 -0
  243. package/lib/openxml/drawing/diagram/SpTree.d.ts +5 -0
  244. package/lib/openxml/drawing/presetShape.d.ts +3 -0
  245. package/lib/openxml/drawing/presetShape.js +38789 -0
  246. package/lib/openxml/drawing/svg/arcToA.d.ts +13 -0
  247. package/lib/openxml/drawing/svg/arcToA.js +92 -0
  248. package/lib/openxml/drawing/svg/formulas.d.ts +29 -0
  249. package/lib/openxml/drawing/svg/formulas.js +108 -0
  250. package/lib/openxml/drawing/svg/generateDefines.d.ts +12 -0
  251. package/lib/openxml/drawing/svg/generateDefines.js +148 -0
  252. package/lib/openxml/drawing/svg/presetVal.d.ts +43 -0
  253. package/lib/openxml/drawing/svg/presetVal.js +57 -0
  254. package/lib/openxml/drawing/svg/shapeToSVG.d.ts +9 -0
  255. package/lib/openxml/drawing/svg/shapeToSVG.js +155 -0
  256. package/lib/openxml/math/OMath.d.ts +5 -0
  257. package/lib/openxml/math/OMath.js +16 -0
  258. package/lib/openxml/math/convertOOML.d.ts +4 -0
  259. package/lib/openxml/math/convertOOML.js +17 -0
  260. package/lib/openxml/math/xsl.d.ts +4 -0
  261. package/lib/openxml/math/xsl.js +12 -0
  262. package/lib/openxml/word/Body.js +11 -7
  263. package/lib/openxml/word/Break.js +1 -3
  264. package/lib/openxml/word/Font.d.ts +16 -0
  265. package/lib/openxml/word/Font.js +83 -0
  266. package/lib/openxml/word/FontTable.d.ts +9 -0
  267. package/lib/openxml/word/FontTable.js +38 -0
  268. package/lib/openxml/word/Header.d.ts +11 -0
  269. package/lib/openxml/word/Header.js +58 -0
  270. package/lib/openxml/word/Hyperlink.d.ts +1 -0
  271. package/lib/openxml/word/Hyperlink.js +8 -4
  272. package/lib/openxml/word/InlineText.js +2 -2
  273. package/lib/openxml/word/NoBreakHyphen.d.ts +2 -0
  274. package/lib/openxml/word/NoBreakHyphen.js +11 -0
  275. package/lib/openxml/word/Note.d.ts +12 -0
  276. package/lib/openxml/word/Note.js +52 -0
  277. package/lib/openxml/word/Paragraph.d.ts +2 -2
  278. package/lib/openxml/word/Paragraph.js +11 -10
  279. package/lib/openxml/word/Pict.d.ts +1 -2
  280. package/lib/openxml/word/Pict.js +5 -3
  281. package/lib/openxml/word/Ruby.js +4 -4
  282. package/lib/openxml/word/Run.d.ts +7 -3
  283. package/lib/openxml/word/Run.js +29 -5
  284. package/lib/openxml/word/Section.d.ts +18 -5
  285. package/lib/openxml/word/Section.js +47 -3
  286. package/lib/openxml/word/Separator.d.ts +5 -0
  287. package/lib/openxml/word/Separator.js +14 -0
  288. package/lib/openxml/word/SoftHyphen.d.ts +5 -0
  289. package/lib/openxml/word/SoftHyphen.js +14 -0
  290. package/lib/openxml/word/Tab.d.ts +1 -1
  291. package/lib/openxml/word/Table.d.ts +4 -9
  292. package/lib/openxml/word/Table.js +0 -235
  293. package/lib/openxml/word/WDocument.d.ts +1 -2
  294. package/lib/openxml/word/WDocument.js +53 -7
  295. package/lib/openxml/word/numbering/AbstractNum.js +5 -3
  296. package/lib/openxml/word/numbering/Lvl.js +11 -5
  297. package/lib/openxml/word/numbering/Num.js +12 -4
  298. package/lib/openxml/word/numbering/NumberProperties.js +2 -2
  299. package/lib/openxml/word/numbering/Numbering.js +3 -3
  300. package/lib/openxml/word/table/Tc.d.ts +1 -22
  301. package/lib/openxml/word/table/Tc.js +0 -224
  302. package/lib/openxml/word/table/Tr.d.ts +0 -5
  303. package/lib/openxml/word/table/Tr.js +0 -97
  304. package/lib/openxml/word/wps/WPG.d.ts +14 -0
  305. package/lib/openxml/word/wps/WPG.js +60 -0
  306. package/lib/openxml/word/wps/WPS.d.ts +18 -0
  307. package/lib/openxml/word/wps/WPS.js +152 -0
  308. package/lib/openxml/word/wps/WPSStyle.d.ts +10 -0
  309. package/lib/openxml/word/wps/WPSStyle.js +46 -0
  310. package/lib/package/PackageParser.d.ts +1 -1
  311. package/lib/package/XMLPackageParser.d.ts +3 -3
  312. package/lib/package/ZipPackageParser.d.ts +1 -1
  313. package/lib/package/ZipPackageParser.js +7 -8
  314. package/lib/parse/Footnotes.d.ts +3 -0
  315. package/lib/parse/Footnotes.js +29 -0
  316. package/lib/parse/colorNameMap.d.ts +6 -0
  317. package/lib/parse/colorNameMap.js +205 -0
  318. package/lib/parse/jcToTextAlign.js +1 -0
  319. package/lib/parse/mergeSdt.d.ts +4 -0
  320. package/lib/parse/mergeSdt.js +61 -0
  321. package/lib/parse/modifyColor.d.ts +1 -0
  322. package/lib/parse/modifyColor.js +110 -0
  323. package/lib/parse/parseBorder.js +3 -22
  324. package/lib/parse/parseCellMargin.d.ts +2 -0
  325. package/lib/parse/parseCellMargin.js +42 -0
  326. package/lib/parse/parseChildColor.d.ts +5 -0
  327. package/lib/parse/parseChildColor.js +70 -0
  328. package/lib/parse/parseColor.d.ts +4 -0
  329. package/lib/parse/parseColor.js +41 -45
  330. package/lib/parse/parseEndnotes.d.ts +3 -0
  331. package/lib/parse/parseEndnotes.js +29 -0
  332. package/lib/parse/parseFont.js +2 -2
  333. package/lib/parse/parseInsideBorders.d.ts +9 -0
  334. package/lib/parse/parseInsideBorders.js +28 -0
  335. package/lib/parse/parsePr.d.ts +3 -0
  336. package/lib/parse/parsePr.js +109 -12
  337. package/lib/parse/parseRelationship.js +2 -2
  338. package/lib/parse/parseSdt.d.ts +5 -0
  339. package/lib/parse/parseShape.d.ts +10 -0
  340. package/lib/parse/parseShape.js +247 -0
  341. package/lib/parse/parseSize.d.ts +2 -1
  342. package/lib/parse/parseSize.js +7 -0
  343. package/lib/parse/parseSpacing.js +1 -1
  344. package/lib/parse/parseTable.d.ts +3 -0
  345. package/lib/parse/parseTable.js +66 -0
  346. package/lib/parse/parseTablePr.d.ts +3 -0
  347. package/lib/parse/parseTablePr.js +189 -0
  348. package/lib/parse/parseTblWidth.d.ts +4 -0
  349. package/lib/parse/parseTblWidth.js +27 -0
  350. package/lib/parse/parseTc.d.ts +10 -0
  351. package/lib/parse/parseTc.js +68 -0
  352. package/lib/parse/parseTcPr.d.ts +5 -0
  353. package/lib/parse/parseTcPr.js +104 -0
  354. package/lib/parse/parseTextDirection.js +4 -6
  355. package/lib/parse/parseTr.d.ts +6 -0
  356. package/lib/parse/parseTr.js +53 -0
  357. package/lib/parse/parseTrPr.d.ts +3 -0
  358. package/lib/parse/parseTrPr.js +63 -0
  359. package/lib/render/fixAbsolutePosition.d.ts +8 -0
  360. package/lib/render/renderBody.d.ts +6 -2
  361. package/lib/render/renderBody.js +183 -29
  362. package/lib/render/renderBr.d.ts +2 -1
  363. package/lib/render/renderBr.js +4 -1
  364. package/lib/render/renderCustGeom.d.ts +4 -0
  365. package/lib/render/renderCustGeom.js +14 -0
  366. package/lib/render/renderDocument.d.ts +2 -2
  367. package/lib/render/renderDocument.js +2 -2
  368. package/lib/render/renderDrawing.d.ts +3 -2
  369. package/lib/render/renderDrawing.js +238 -21
  370. package/lib/render/renderFont.d.ts +5 -0
  371. package/lib/render/renderFont.js +43 -0
  372. package/lib/render/renderGeom.d.ts +4 -0
  373. package/lib/render/renderGeom.js +18 -0
  374. package/lib/render/renderHeader.d.ts +6 -0
  375. package/lib/render/renderHeader.js +44 -0
  376. package/lib/render/renderHyperLink.js +5 -2
  377. package/lib/render/renderInlineText.js +2 -2
  378. package/lib/render/renderInstrText.js +2 -2
  379. package/lib/render/renderMath.d.ts +3 -0
  380. package/lib/render/renderMath.js +11 -0
  381. package/lib/render/renderNoBreakHyphen.d.ts +1 -0
  382. package/lib/render/renderNoBreakHyphen.js +13 -0
  383. package/lib/render/renderNotes.d.ts +5 -0
  384. package/lib/render/renderNotes.js +81 -0
  385. package/lib/render/renderNumbering.js +9 -11
  386. package/lib/render/renderParagraph.d.ts +1 -1
  387. package/lib/render/renderParagraph.js +58 -18
  388. package/lib/render/renderPict.js +5 -10
  389. package/lib/render/renderRuby.js +3 -3
  390. package/lib/render/renderRun.d.ts +4 -2
  391. package/lib/render/renderRun.js +41 -11
  392. package/lib/render/renderSection.d.ts +3 -2
  393. package/lib/render/renderSection.js +79 -5
  394. package/lib/render/renderSeparator.d.ts +1 -0
  395. package/lib/render/renderSeparator.js +13 -0
  396. package/lib/render/renderSoftHyphen.d.ts +1 -0
  397. package/lib/render/renderSoftHyphen.js +13 -0
  398. package/lib/render/renderStyle.js +37 -36
  399. package/lib/render/renderTab.d.ts +2 -1
  400. package/lib/render/renderTab.js +10 -6
  401. package/lib/render/renderTable.js +25 -22
  402. package/lib/render/setElementStyle.js +6 -1
  403. package/lib/render/zindex.d.ts +1 -0
  404. package/lib/util/blob.js +0 -10
  405. package/lib/util/color.d.ts +48 -0
  406. package/lib/util/color.js +215 -0
  407. package/lib/util/createObject.d.ts +10 -0
  408. package/lib/util/createObject.js +54 -0
  409. package/lib/util/dom.d.ts +8 -4
  410. package/lib/util/dom.js +24 -5
  411. package/lib/util/get.d.ts +4 -0
  412. package/lib/util/get.js +22 -0
  413. package/lib/util/mergeRun.js +5 -5
  414. package/lib/util/parseSides.d.ts +11 -0
  415. package/lib/util/print.d.ts +5 -0
  416. package/lib/util/print.js +58 -0
  417. package/lib/util/replaceVar.d.ts +10 -0
  418. package/lib/util/replaceVar.js +220 -0
  419. package/lib/util/xml.js +4 -0
  420. package/package.json +17 -7
  421. package/esm/node_modules/tslib/tslib.es6.js +0 -120
  422. package/esm/openxml/Types.js +0 -1003
  423. package/esm/openxml/word/CustomXml.d.ts +0 -8
  424. package/esm/openxml/word/SmartTag.d.ts +0 -8
  425. package/esm/openxml/word/SmartTag.js +0 -18
  426. package/esm/openxml/word/drawing/Blip.d.ts +0 -6
  427. package/esm/openxml/word/drawing/Drawing.d.ts +0 -6
  428. package/esm/openxml/word/drawing/Drawing.js +0 -15
  429. package/esm/openxml/word/drawing/Pic.d.ts +0 -8
  430. package/esm/openxml/word/drawing/Pic.js +0 -16
  431. package/esm/openxml/word/drawing/ShapeProperties.d.ts +0 -9
  432. package/esm/openxml/word/drawing/ShapeProperties.js +0 -20
  433. package/esm/openxml/word/drawing/Transform.js +0 -30
  434. package/lib/node_modules/tslib/tslib.es6.js +0 -129
  435. package/lib/openxml/Types.js +0 -1005
  436. package/lib/openxml/word/CustomXml.d.ts +0 -8
  437. package/lib/openxml/word/SmartTag.d.ts +0 -8
  438. package/lib/openxml/word/SmartTag.js +0 -22
  439. package/lib/openxml/word/drawing/Blip.d.ts +0 -6
  440. package/lib/openxml/word/drawing/Drawing.d.ts +0 -6
  441. package/lib/openxml/word/drawing/Drawing.js +0 -19
  442. package/lib/openxml/word/drawing/Pic.d.ts +0 -8
  443. package/lib/openxml/word/drawing/Pic.js +0 -20
  444. package/lib/openxml/word/drawing/ShapeProperties.d.ts +0 -9
  445. package/lib/openxml/word/drawing/ShapeProperties.js +0 -24
  446. package/lib/openxml/word/drawing/Transform.js +0 -34
@@ -0,0 +1,13 @@
1
+ /**
2
+ * 将 arc 定义转成 SVG PATH 里的 A 命令
3
+ */
4
+ /**
5
+ * 将 arc 转成 A 指令,但目前看来不太正确,比如 curvedRightArrow 的显示就不对
6
+ */
7
+ export default function arcToPathA(wR: number, hR: number, stAng: number, swAng: number, preX: number, preY: number): {
8
+ path: string;
9
+ end: {
10
+ x: number;
11
+ y: number;
12
+ };
13
+ };
@@ -0,0 +1,92 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ /**
6
+ * 将 arc 定义转成 SVG PATH 里的 A 命令
7
+ */
8
+ function floatEqual(a, b) {
9
+ if (a === b) {
10
+ return true;
11
+ }
12
+ var diff = Math.abs(a - b);
13
+ if (diff < Number.EPSILON) {
14
+ return true;
15
+ }
16
+ return diff <= Number.EPSILON * Math.min(Math.abs(a), Math.abs(b));
17
+ }
18
+ /**
19
+ * 计算角度
20
+ */
21
+ var radians = function (deg) { return Math.PI * (deg / 60000 / 180); };
22
+ /**
23
+ * 将 arc 转成 A 指令,但目前看来不太正确,比如 curvedRightArrow 的显示就不对
24
+ */
25
+ function arcToPathA(wR, hR, stAng, swAng, preX, preY) {
26
+ var startR = radians(stAng);
27
+ var swAngR = radians(swAng);
28
+ var endR = radians(stAng + swAng);
29
+ if (floatEqual(swAng, 60000 * 360)) {
30
+ // 如果是圆会变成点,所以减少一下避免这种情况
31
+ endR = endR - 0.0001;
32
+ }
33
+ var end = getEndPoint(wR, hR, startR, endR, 0, preX, preY);
34
+ // 是否是大弧
35
+ var largeArcFlag = Math.abs(swAngR) > Math.PI ? 1 : 0;
36
+ // 是否是顺时针
37
+ var sweepFlag = swAng > 0 ? 1 : 0;
38
+ var path = "A ".concat(wR, " ").concat(hR, " 0 ").concat(largeArcFlag, " ").concat(sweepFlag, " ").concat(end.x, ",").concat(end.y);
39
+ return {
40
+ path: path,
41
+ end: end
42
+ };
43
+ }
44
+ /**
45
+ * 简单实现的矩阵相乘,只支持一种输入
46
+ */
47
+ function matrixMul(first, second) {
48
+ return [
49
+ first[0][0] * second[0] + first[0][1] * second[1],
50
+ first[1][0] * second[0] + first[1][1] * second[1]
51
+ ];
52
+ }
53
+ /**
54
+ * 算出结束点位置,公式来自
55
+ * https://www.cnblogs.com/ryzen/p/15191386.html
56
+ * https://wiki.documentfoundation.org/Development/Improve_handles_of_DrawingML_shapes
57
+ *
58
+ * @param rx 半长轴半径
59
+ * @param ry 半短轴半径
60
+ * @param stAng 起始角度
61
+ * @param swAng 旋转角度
62
+ * @param rotate 旋转
63
+ * @param x 起始点 x 坐标
64
+ * @param y 起始点 y 坐标
65
+ * @returns 结束点位置
66
+ */
67
+ function getEndPoint(rx, ry, stAng, swAng, rotate, x, y) {
68
+ var startR = stAng;
69
+ var endR = swAng;
70
+ // 起始节点坐标
71
+ var matrixX1Y1 = [x, y];
72
+ var matrix1 = [
73
+ [Math.cos(rotate), -Math.sin(rotate)],
74
+ [Math.sin(rotate), Math.cos(rotate)]
75
+ ];
76
+ var matrix2 = [rx * Math.cos(startR), ry * Math.sin(startR)];
77
+ // 公式第二部分
78
+ var secondPart = matrixMul(matrix1, matrix2);
79
+ var matrixCxCy = [
80
+ matrixX1Y1[0] - secondPart[0],
81
+ matrixX1Y1[1] - secondPart[1]
82
+ ];
83
+ var matrix3 = [rx * Math.cos(endR), ry * Math.sin(endR)];
84
+ var firstPart = matrixMul(matrix1, matrix3);
85
+ var result = [matrixCxCy[0] + firstPart[0], matrixCxCy[1] + firstPart[1]];
86
+ return {
87
+ x: result[0],
88
+ y: result[1]
89
+ };
90
+ }
91
+
92
+ exports["default"] = arcToPathA;
@@ -0,0 +1,29 @@
1
+ /**
2
+ * 计算公式 20.1.9.11
3
+ */
4
+ export declare const formulas: {
5
+ '*/': (x: number, y: number, z: number) => number;
6
+ '+-': (x: number, y: number, z: number) => number;
7
+ '+/': (x: number, y: number, z: number) => number;
8
+ '?:': (x: number, y: number, z: number) => number;
9
+ abs: (x: number) => number;
10
+ at2: (x: number, y: number) => number;
11
+ cat2: (x: number, y: number, z: number) => number;
12
+ cos: (x: number, y: number) => number;
13
+ max: (x: number, y: number) => number;
14
+ min: (x: number, y: number) => number;
15
+ mod: (x: number, y: number, z: number) => number;
16
+ pin: (x: number, y: number, z: number) => number;
17
+ sat2: (x: number, y: number, z: number) => number;
18
+ sin: (x: number, y: number) => number;
19
+ sqrt: (x: number) => number;
20
+ tan: (x: number, y: number) => number;
21
+ val: (a: string) => number;
22
+ };
23
+ /**
24
+ * 执行公式计算并返回结果
25
+ * @param fmla 公式
26
+ * @param vars 变量值
27
+ * @returns
28
+ */
29
+ export declare function evalFmla(name: string, fmla: string, vars: Record<string, number>): number;
@@ -0,0 +1,108 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ /**
6
+ * 计算公式 20.1.9.11
7
+ */
8
+ var angleFactor = (1 / 60000 / 180) * Math.PI;
9
+ var formulas = {
10
+ '*/': function (x, y, z) {
11
+ return (x * y) / z;
12
+ },
13
+ '+-': function (x, y, z) {
14
+ return x + y - z;
15
+ },
16
+ '+/': function (x, y, z) {
17
+ return (x + y) / z;
18
+ },
19
+ '?:': function (x, y, z) {
20
+ return x > 0 ? y : z;
21
+ },
22
+ 'abs': function (x) {
23
+ return Math.abs(x);
24
+ },
25
+ 'at2': function (x, y) {
26
+ // 转回角度,因为后续的计算是基于角度的
27
+ return (Math.atan2(y, x) * 180 * 60000) / Math.PI;
28
+ },
29
+ 'cat2': function (x, y, z) {
30
+ return x * Math.cos(Math.atan2(z, y));
31
+ },
32
+ 'cos': function (x, y) {
33
+ return x * Math.cos(y * angleFactor);
34
+ },
35
+ 'max': function (x, y) {
36
+ return Math.max(x, y);
37
+ },
38
+ 'min': function (x, y) {
39
+ return Math.min(x, y);
40
+ },
41
+ 'mod': function (x, y, z) {
42
+ return Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2) + Math.pow(z, 2));
43
+ },
44
+ 'pin': function (x, y, z) {
45
+ return y < x ? x : y > z ? z : y;
46
+ },
47
+ 'sat2': function (x, y, z) {
48
+ return x * Math.sin(Math.atan2(z, y));
49
+ },
50
+ 'sin': function (x, y) {
51
+ return x * Math.sin(y * angleFactor);
52
+ },
53
+ 'sqrt': function (x) {
54
+ return Math.sqrt(x);
55
+ },
56
+ 'tan': function (x, y) {
57
+ return x * Math.tan(y * angleFactor);
58
+ },
59
+ 'val': function (a) {
60
+ var parse = parseInt(a, 10);
61
+ if (isNaN(parse)) {
62
+ return parse;
63
+ }
64
+ return parse;
65
+ }
66
+ };
67
+ /**
68
+ * 执行公式计算并返回结果
69
+ * @param fmla 公式
70
+ * @param vars 变量值
71
+ * @returns
72
+ */
73
+ function evalFmla(name, fmla, vars) {
74
+ var fmlaArr = fmla.split(/[ ]+/);
75
+ if (fmlaArr.length <= 1) {
76
+ console.warn('fmla format error', fmla);
77
+ }
78
+ var fmlaName = fmlaArr[0];
79
+ var fmlaArgs = fmlaArr.slice(1);
80
+ // 这里要求 gd 定义必须顺序,不然就找不到之前的值了
81
+ var fmlaArgsNum = fmlaArgs.map(function (arg) {
82
+ if (arg in vars) {
83
+ return vars[arg];
84
+ }
85
+ var parse = parseInt(arg, 10);
86
+ if (isNaN(parse)) {
87
+ console.warn('fmla arg error', arg, fmla);
88
+ return 0;
89
+ }
90
+ else {
91
+ return parse;
92
+ }
93
+ });
94
+ if (fmlaName in formulas) {
95
+ var val = formulas[fmlaName].apply(null, fmlaArgsNum);
96
+ if (isNaN(val)) {
97
+ console.warn('fmla eval error', fmla, name);
98
+ return 0;
99
+ }
100
+ else {
101
+ vars[name] = val;
102
+ }
103
+ }
104
+ return 0;
105
+ }
106
+
107
+ exports.evalFmla = evalFmla;
108
+ exports.formulas = formulas;
@@ -0,0 +1,12 @@
1
+ import { Path } from '../Path';
2
+ export type Var = Record<string, number>;
3
+ export type Point = {
4
+ x: number;
5
+ y: number;
6
+ };
7
+ /**
8
+ *
9
+ * 转成 svg path 里的定义
10
+ * https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/d
11
+ */
12
+ export declare function generateDefines(path: Path, vars: Var, prevPoint: Point[]): string;
@@ -0,0 +1,148 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var tslib = require('tslib');
6
+ var arcToA = require('./arcToA.js');
7
+
8
+ function getVal(name, vars, scale) {
9
+ var result = 0;
10
+ if (name in vars) {
11
+ result = vars[name];
12
+ }
13
+ else {
14
+ result = parseInt(name, 10);
15
+ if (isNaN(result)) {
16
+ console.warn('var not found', name);
17
+ return 0;
18
+ }
19
+ }
20
+ if (scale) {
21
+ return result * scale;
22
+ }
23
+ else {
24
+ return result;
25
+ }
26
+ }
27
+ /**
28
+ *
29
+ * 转成 svg path 里的定义
30
+ * https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/d
31
+ */
32
+ function generateDefines(path, vars, prevPoint) {
33
+ var e_1, _a;
34
+ var defines = path.defines;
35
+ var paths = [];
36
+ var w = path.w;
37
+ var h = path.h;
38
+ var wScale = 1;
39
+ var hScale = 1;
40
+ if (w) {
41
+ wScale = vars['w'] / w;
42
+ }
43
+ if (h) {
44
+ hScale = vars['h'] / h;
45
+ }
46
+ try {
47
+ for (var defines_1 = tslib.__values(defines), defines_1_1 = defines_1.next(); !defines_1_1.done; defines_1_1 = defines_1.next()) {
48
+ var def = defines_1_1.value;
49
+ switch (def.type) {
50
+ case 'moveTo': {
51
+ var pt = def.pt;
52
+ var x = getVal(pt.x, vars, wScale);
53
+ var y = getVal(pt.y, vars, hScale);
54
+ paths.push("M ".concat(x, " ").concat(y));
55
+ prevPoint.push({ x: x, y: y });
56
+ break;
57
+ }
58
+ case 'lnTo': {
59
+ var pt = def.pt;
60
+ var x = getVal(pt.x, vars, wScale);
61
+ var y = getVal(pt.y, vars, hScale);
62
+ paths.push("L ".concat(x, " ").concat(y));
63
+ prevPoint.push({ x: x, y: y });
64
+ break;
65
+ }
66
+ case 'arcTo': {
67
+ var arc = def;
68
+ var wR = getVal(arc.wR, vars, wScale);
69
+ var hR = getVal(arc.hR, vars, hScale);
70
+ var stAng = getVal(arc.stAng, vars);
71
+ var swAng = getVal(arc.swAng, vars);
72
+ var prev = {
73
+ x: 0,
74
+ y: 0
75
+ };
76
+ if (prevPoint.length > 0) {
77
+ prev = prevPoint[prevPoint.length - 1];
78
+ }
79
+ var aPath = arcToA["default"](wR, hR, stAng, swAng, prev.x, prev.y);
80
+ paths.push(aPath.path);
81
+ prevPoint.push({ x: aPath.end.x, y: aPath.end.y });
82
+ break;
83
+ }
84
+ case 'quadBezTo': {
85
+ var quadBezTo = def;
86
+ if (quadBezTo.pts.length >= 2) {
87
+ var pt1 = quadBezTo.pts[0];
88
+ var pt2 = quadBezTo.pts[1];
89
+ var x1 = getVal(pt1.x, vars, wScale);
90
+ var y1 = getVal(pt1.y, vars, hScale);
91
+ var x2 = getVal(pt2.x, vars, wScale);
92
+ var y2 = getVal(pt2.y, vars, hScale);
93
+ paths.push("Q ".concat(x1, ",").concat(y1, " ").concat(x2, ",").concat(y2));
94
+ if (quadBezTo.pts.length > 2) {
95
+ var pt3 = quadBezTo.pts[2];
96
+ var x3 = getVal(pt3.x, vars, wScale);
97
+ var y3 = getVal(pt3.y, vars, hScale);
98
+ paths.push("T ".concat(x3, ",").concat(y3));
99
+ prevPoint.push({ x: x3, y: y3 });
100
+ }
101
+ else {
102
+ prevPoint.push({ x: x2, y: y2 });
103
+ }
104
+ }
105
+ else {
106
+ console.warn('quadBezTo pts length must large than 2', def);
107
+ }
108
+ break;
109
+ }
110
+ case 'cubicBezTo': {
111
+ var cubicBezTo = def;
112
+ if (cubicBezTo.pts.length === 3) {
113
+ var pt1 = cubicBezTo.pts[0];
114
+ var pt2 = cubicBezTo.pts[1];
115
+ var pt3 = cubicBezTo.pts[2];
116
+ var x1 = getVal(pt1.x, vars, wScale);
117
+ var y1 = getVal(pt1.y, vars, hScale);
118
+ var x2 = getVal(pt2.x, vars, wScale);
119
+ var y2 = getVal(pt2.y, vars, hScale);
120
+ var x3 = getVal(pt3.x, vars, wScale);
121
+ var y3 = getVal(pt3.y, vars, hScale);
122
+ paths.push("C ".concat(x1, ",").concat(y1, " ").concat(x2, ",").concat(y2, " ").concat(x3, ",").concat(y3));
123
+ prevPoint.push({ x: x3, y: y3 });
124
+ }
125
+ else {
126
+ console.warn('cubicBezTo pts length must be 3', def);
127
+ }
128
+ break;
129
+ }
130
+ case 'close':
131
+ paths.push('Z');
132
+ break;
133
+ default:
134
+ break;
135
+ }
136
+ }
137
+ }
138
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
139
+ finally {
140
+ try {
141
+ if (defines_1_1 && !defines_1_1.done && (_a = defines_1.return)) _a.call(defines_1);
142
+ }
143
+ finally { if (e_1) throw e_1.error; }
144
+ }
145
+ return paths.join(' ');
146
+ }
147
+
148
+ exports.generateDefines = generateDefines;
@@ -0,0 +1,43 @@
1
+ /**
2
+ * 获取默认 val,20.1.10.56
3
+ *
4
+ * @param width
5
+ * @param height
6
+ */
7
+ export declare function presetVal(w: number, h: number): {
8
+ t: number;
9
+ '3cd4': number;
10
+ '3cd8': number;
11
+ '5cd8': number;
12
+ '7cd8': number;
13
+ b: number;
14
+ cd2: number;
15
+ cd4: number;
16
+ cd8: number;
17
+ h: number;
18
+ hd2: number;
19
+ hd3: number;
20
+ hd4: number;
21
+ hd6: number;
22
+ hd8: number;
23
+ l: number;
24
+ ls: number;
25
+ r: number;
26
+ ss: number;
27
+ ssd2: number;
28
+ ssd6: number;
29
+ ssd8: number;
30
+ ssd16: number;
31
+ ssd32: number;
32
+ hc: number;
33
+ vc: number;
34
+ w: number;
35
+ wd2: number;
36
+ wd3: number;
37
+ wd4: number;
38
+ wd6: number;
39
+ wd8: number;
40
+ wd10: number;
41
+ wd16: number;
42
+ wd32: number;
43
+ };
@@ -0,0 +1,57 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ /**
6
+ * 获取默认 val,20.1.10.56
7
+ *
8
+ * @param width
9
+ * @param height
10
+ */
11
+ function presetVal(w, h) {
12
+ var ss = Math.min(w, h);
13
+ var ssd2 = ss / 6;
14
+ var ssd6 = ss / 6;
15
+ var ssd8 = ss / 8;
16
+ var ssd32 = ss / 32;
17
+ var ssd16 = ss / 16;
18
+ return {
19
+ 't': 0,
20
+ '3cd4': 16200000,
21
+ '3cd8': 8100000,
22
+ '5cd8': 13500000,
23
+ '7cd8': 18900000,
24
+ 'b': h,
25
+ 'cd2': 10800000,
26
+ 'cd4': 5400000,
27
+ 'cd8': 2700000,
28
+ h: h,
29
+ 'hd2': h / 2,
30
+ 'hd3': h / 3,
31
+ 'hd4': h / 4,
32
+ 'hd6': h / 6,
33
+ 'hd8': h / 8,
34
+ 'l': 0,
35
+ 'ls': Math.max(w, h),
36
+ 'r': w,
37
+ ss: ss,
38
+ ssd2: ssd2,
39
+ ssd6: ssd6,
40
+ ssd8: ssd8,
41
+ ssd16: ssd16,
42
+ ssd32: ssd32,
43
+ 'hc': w / 2,
44
+ 'vc': h / 2,
45
+ w: w,
46
+ 'wd2': w / 2,
47
+ 'wd3': w / 3,
48
+ 'wd4': w / 4,
49
+ 'wd6': w / 6,
50
+ 'wd8': w / 8,
51
+ 'wd10': w / 10,
52
+ 'wd16': w / 16,
53
+ 'wd32': w / 32
54
+ };
55
+ }
56
+
57
+ exports.presetVal = presetVal;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * 将 shape 转成 svg 格式
3
+ *
4
+ * https://wiki.documentfoundation.org/Development/Improve_handles_of_DrawingML_shapes
5
+ */
6
+ import { WPSStyle } from '../../word/wps/WPSStyle';
7
+ import { Shape, ShapeGuide } from '../Shape';
8
+ import { ShapePr } from '../ShapeProperties';
9
+ export declare function shapeToSVG(shape: Shape, avLst: ShapeGuide[], shapePr: ShapePr, width: number, height: number, wpsStyle?: WPSStyle): SVGElement;
@@ -0,0 +1,155 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var tslib = require('tslib');
6
+ var color = require('../../../util/color.js');
7
+ var dom = require('../../../util/dom.js');
8
+ var formulas = require('./formulas.js');
9
+ var generateDefines = require('./generateDefines.js');
10
+ var presetVal = require('./presetVal.js');
11
+
12
+ /**
13
+ * 将 shape 转成 svg 格式
14
+ *
15
+ * https://wiki.documentfoundation.org/Development/Improve_handles_of_DrawingML_shapes
16
+ */
17
+ function shapeToSVG(shape, avLst, shapePr, width, height, wpsStyle) {
18
+ var e_1, _a, e_2, _b, e_3, _c, e_4, _d;
19
+ var svg = dom.createSVGElement('svg');
20
+ svg.style.display = 'block';
21
+ // 边框有时候会超过
22
+ // block 是为了避免被 text-align 影响
23
+ // z-index 是因为后面可能会有文字,避免遮挡
24
+ svg.setAttribute('style', 'display: block; overflow: visible; position: absolute; z-index: -1');
25
+ svg.setAttribute('width', width.toString() + 'px');
26
+ svg.setAttribute('height', height.toString() + 'px');
27
+ // 变量值
28
+ var vars = presetVal.presetVal(width, height);
29
+ try {
30
+ // 先执行 avLst 定义初始变量
31
+ for (var _e = tslib.__values(shape.avLst || []), _f = _e.next(); !_f.done; _f = _e.next()) {
32
+ var gd = _f.value;
33
+ formulas.evalFmla(gd.n, gd.f, vars);
34
+ }
35
+ }
36
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
37
+ finally {
38
+ try {
39
+ if (_f && !_f.done && (_a = _e.return)) _a.call(_e);
40
+ }
41
+ finally { if (e_1) throw e_1.error; }
42
+ }
43
+ try {
44
+ // 自定义 avLst
45
+ for (var avLst_1 = tslib.__values(avLst), avLst_1_1 = avLst_1.next(); !avLst_1_1.done; avLst_1_1 = avLst_1.next()) {
46
+ var gd = avLst_1_1.value;
47
+ formulas.evalFmla(gd.n, gd.f, vars);
48
+ }
49
+ }
50
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
51
+ finally {
52
+ try {
53
+ if (avLst_1_1 && !avLst_1_1.done && (_b = avLst_1.return)) _b.call(avLst_1);
54
+ }
55
+ finally { if (e_2) throw e_2.error; }
56
+ }
57
+ try {
58
+ // 执行 gdLst
59
+ for (var _g = tslib.__values(shape.gdLst || []), _h = _g.next(); !_h.done; _h = _g.next()) {
60
+ var gd = _h.value;
61
+ formulas.evalFmla(gd.n, gd.f, vars);
62
+ }
63
+ }
64
+ catch (e_3_1) { e_3 = { error: e_3_1 }; }
65
+ finally {
66
+ try {
67
+ if (_h && !_h.done && (_c = _g.return)) _c.call(_g);
68
+ }
69
+ finally { if (e_3) throw e_3.error; }
70
+ }
71
+ var outline = shapePr.outline;
72
+ var prevPoint = [];
73
+ try {
74
+ for (var _j = tslib.__values(shape.pathLst || []), _k = _j.next(); !_k.done; _k = _j.next()) {
75
+ var path = _k.value;
76
+ var pathEl = dom.createSVGElement('path');
77
+ var d = generateDefines.generateDefines(path, vars, prevPoint);
78
+ pathEl.setAttribute('d', d);
79
+ if (shapePr.fillColor) {
80
+ pathEl.setAttribute('fill', shapePr.fillColor);
81
+ }
82
+ else if (wpsStyle && wpsStyle.fillColor) {
83
+ pathEl.setAttribute('fill', wpsStyle.fillColor);
84
+ }
85
+ else {
86
+ pathEl.setAttribute('fill', 'none');
87
+ }
88
+ if (outline) {
89
+ if (outline.color) {
90
+ pathEl.setAttribute('stroke', outline.color);
91
+ }
92
+ if (outline.width) {
93
+ pathEl.setAttribute('stroke-width', outline.width);
94
+ }
95
+ if (outline.style === 'none') {
96
+ pathEl.setAttribute('stroke', 'none');
97
+ }
98
+ }
99
+ else if (wpsStyle && wpsStyle.lineColor) {
100
+ pathEl.setAttribute('stroke', wpsStyle.lineColor);
101
+ }
102
+ else {
103
+ pathEl.setAttribute('stroke', 'none');
104
+ }
105
+ var fillColor = pathEl.getAttribute('fill');
106
+ if (fillColor && fillColor !== 'none') {
107
+ var color$1 = new color.Color(fillColor);
108
+ var fillMode = path.fill;
109
+ var changeColor = '';
110
+ switch (fillMode) {
111
+ // 这些值目前是瞎编的,官方规范里没说
112
+ // http://webapp.docx4java.org/OnlineDemo/ecma376/DrawingML/ST_PathFillMode.html
113
+ case 'darken':
114
+ changeColor = color$1.lumOff(-0.5).toHex();
115
+ break;
116
+ case 'darkenLess':
117
+ changeColor = color$1.lumOff(-0.2).toHex();
118
+ break;
119
+ case 'lighten':
120
+ changeColor = color$1.lumOff(0.5).toHex();
121
+ break;
122
+ case 'lightenLess':
123
+ changeColor = color$1.lumOff(0.2).toHex();
124
+ break;
125
+ }
126
+ if (changeColor) {
127
+ pathEl.setAttribute('fill', changeColor);
128
+ }
129
+ }
130
+ if (path.fill === 'none') {
131
+ pathEl.setAttribute('fill', 'none');
132
+ }
133
+ if (path.stroke === false) {
134
+ pathEl.setAttribute('stroke', 'none');
135
+ if (!path.fill) {
136
+ pathEl.setAttribute('fill', 'none');
137
+ }
138
+ }
139
+ if (shapePr.noFill) {
140
+ pathEl.setAttribute('fill', 'none');
141
+ }
142
+ svg.appendChild(pathEl);
143
+ }
144
+ }
145
+ catch (e_4_1) { e_4 = { error: e_4_1 }; }
146
+ finally {
147
+ try {
148
+ if (_k && !_k.done && (_d = _j.return)) _d.call(_j);
149
+ }
150
+ finally { if (e_4) throw e_4.error; }
151
+ }
152
+ return svg;
153
+ }
154
+
155
+ exports.shapeToSVG = shapeToSVG;
@@ -0,0 +1,5 @@
1
+ import Word from '../../Word';
2
+ export declare class OMath {
3
+ element: Element;
4
+ static fromXML(word: Word, element: Element): OMath;
5
+ }
@@ -0,0 +1,16 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var OMath = /** @class */ (function () {
6
+ function OMath() {
7
+ }
8
+ OMath.fromXML = function (word, element) {
9
+ var math = new OMath();
10
+ math.element = element;
11
+ return math;
12
+ };
13
+ return OMath;
14
+ }());
15
+
16
+ exports.OMath = OMath;