@fileverse-dev/fortune-core 1.0.4 → 1.0.6

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 (346) hide show
  1. package/{dist/packages/core/src → es}/api/cell.d.ts +10 -10
  2. package/es/api/cell.js +204 -0
  3. package/{dist/packages/core/src → es}/api/common.d.ts +66 -66
  4. package/es/api/common.js +79 -0
  5. package/{dist/packages/core/src → es}/api/errors.d.ts +2 -2
  6. package/es/api/errors.js +2 -0
  7. package/{dist/packages/core/src → es}/api/index.d.ts +9 -9
  8. package/es/api/index.js +8 -0
  9. package/{dist/packages/core/src → es}/api/merge.d.ts +5 -5
  10. package/es/api/merge.js +15 -0
  11. package/{dist/packages/core/src → es}/api/range.d.ts +22 -22
  12. package/es/api/range.js +123 -0
  13. package/{dist/packages/core/src → es}/api/rowcol.d.ts +14 -14
  14. package/es/api/rowcol.js +207 -0
  15. package/{dist/packages/core/src → es}/api/sheet.d.ts +10 -10
  16. package/es/api/sheet.js +128 -0
  17. package/{dist/packages/core/src → es}/api/workbook.d.ts +15 -15
  18. package/es/api/workbook.js +85 -0
  19. package/{dist/packages/core/src → es}/canvas.d.ts +46 -46
  20. package/es/canvas.js +1350 -0
  21. package/{dist/packages/core/src → es}/context.d.ts +197 -197
  22. package/es/context.js +380 -0
  23. package/{dist/packages/core/src → es}/events/copy.d.ts +2 -2
  24. package/es/events/copy.js +78 -0
  25. package/{dist/packages/core/src → es}/events/index.d.ts +4 -4
  26. package/es/events/index.js +4 -0
  27. package/{dist/packages/core/src → es}/events/keyboard.d.ts +6 -6
  28. package/es/events/keyboard.js +332 -0
  29. package/{dist/packages/core/src → es}/events/mouse.d.ts +22 -22
  30. package/es/events/mouse.js +1725 -0
  31. package/{dist/packages/core/src → es}/events/paste.d.ts +3 -3
  32. package/es/events/paste.js +1358 -0
  33. package/{dist/packages/core/src → es}/index.d.ts +10 -10
  34. package/es/index.js +10 -0
  35. package/{dist/packages/core/src → es}/locale/en.d.ts +992 -992
  36. package/es/locale/en.js +10564 -0
  37. package/{dist/packages/core/src → es}/locale/es.d.ts +1134 -1134
  38. package/es/locale/es.js +10010 -0
  39. package/{dist/packages/core/src → es}/locale/hi.d.ts +1030 -1030
  40. package/es/locale/hi.js +10550 -0
  41. package/{dist/packages/core/src → es}/locale/index.d.ts +1049 -1049
  42. package/es/locale/index.js +23 -0
  43. package/{dist/packages/core/src → es}/locale/zh.d.ts +1048 -1048
  44. package/es/locale/zh.js +10568 -0
  45. package/{dist/packages/core/src → es}/locale/zh_tw.d.ts +1187 -1187
  46. package/es/locale/zh_tw.js +10072 -0
  47. package/{dist/packages/core/src → es}/modules/ConditionFormat.d.ts +17 -17
  48. package/es/modules/ConditionFormat.js +1258 -0
  49. package/{dist/packages/core/src → es}/modules/border.d.ts +3 -3
  50. package/es/modules/border.js +1240 -0
  51. package/{dist/packages/core/src → es}/modules/cell.d.ts +32 -32
  52. package/es/modules/cell.js +1055 -0
  53. package/{dist/packages/core/src → es}/modules/clipboard.d.ts +3 -3
  54. package/es/modules/clipboard.js +36 -0
  55. package/{dist/packages/core/src → es}/modules/color.d.ts +1 -1
  56. package/es/modules/color.js +1 -0
  57. package/{dist/packages/core/src → es}/modules/comment.d.ts +97 -97
  58. package/es/modules/comment.js +597 -0
  59. package/{dist/packages/core/src → es}/modules/conditionalFormat.d.ts +2 -2
  60. package/es/modules/conditionalFormat.js +441 -0
  61. package/{dist/packages/core/src → es}/modules/cursor.d.ts +3 -3
  62. package/es/modules/cursor.js +62 -0
  63. package/{dist/packages/core/src → es}/modules/dataVerification.d.ts +11 -11
  64. package/es/modules/dataVerification.js +700 -0
  65. package/{dist/packages/core/src → es}/modules/dropCell.d.ts +10 -10
  66. package/es/modules/dropCell.js +2266 -0
  67. package/{dist/packages/core/src → es}/modules/filter.d.ts +45 -45
  68. package/es/modules/filter.js +434 -0
  69. package/{dist/packages/core/src → es}/modules/format.d.ts +6 -6
  70. package/es/modules/format.js +323 -0
  71. package/{dist/packages/core/src → es}/modules/formula.d.ts +54 -54
  72. package/es/modules/formula.js +2301 -0
  73. package/{dist/packages/core/src → es}/modules/freeze.d.ts +5 -5
  74. package/es/modules/freeze.js +148 -0
  75. package/{dist/packages/core/src → es}/modules/hyperlink.d.ts +21 -21
  76. package/es/modules/hyperlink.js +216 -0
  77. package/{dist/packages/core/src → es}/modules/iframe.d.ts +12 -12
  78. package/es/modules/iframe.js +220 -0
  79. package/{dist/packages/core/src → es}/modules/image.d.ts +31 -31
  80. package/es/modules/image.js +253 -0
  81. package/{dist/packages/core/src → es}/modules/index.d.ts +36 -36
  82. package/es/modules/index.js +36 -0
  83. package/{dist/packages/core/src → es}/modules/inline-string.d.ts +36 -36
  84. package/es/modules/inline-string.js +437 -0
  85. package/{dist/packages/core/src → es}/modules/location.d.ts +6 -6
  86. package/es/modules/location.js +46 -0
  87. package/{dist/packages/core/src → es}/modules/locationCondition.d.ts +21 -21
  88. package/es/modules/locationCondition.js +218 -0
  89. package/{dist/packages/core/src → es}/modules/merge.d.ts +3 -3
  90. package/es/modules/merge.js +216 -0
  91. package/{dist/packages/core/src → es}/modules/mobile.d.ts +5 -5
  92. package/es/modules/mobile.js +33 -0
  93. package/{dist/packages/core/src → es}/modules/moveCells.d.ts +5 -5
  94. package/es/modules/moveCells.js +348 -0
  95. package/{dist/packages/core/src → es}/modules/protection.d.ts +5 -5
  96. package/es/modules/protection.js +96 -0
  97. package/{dist/packages/core/src → es}/modules/refresh.d.ts +3 -3
  98. package/es/modules/refresh.js +34 -0
  99. package/{dist/packages/core/src → es}/modules/rowcol.d.ts +19 -19
  100. package/es/modules/rowcol.js +1922 -0
  101. package/{dist/packages/core/src → es}/modules/screenshot.d.ts +2 -2
  102. package/es/modules/screenshot.js +90 -0
  103. package/{dist/packages/core/src → es}/modules/searchReplace.d.ts +36 -36
  104. package/es/modules/searchReplace.js +388 -0
  105. package/{dist/packages/core/src → es}/modules/selection.d.ts +46 -46
  106. package/es/modules/selection.js +1674 -0
  107. package/{dist/packages/core/src → es}/modules/sheet.d.ts +10 -10
  108. package/es/modules/sheet.js +237 -0
  109. package/{dist/packages/core/src → es}/modules/sort.d.ts +7 -7
  110. package/es/modules/sort.js +150 -0
  111. package/{dist/packages/core/src → es}/modules/splitColumn.d.ts +5 -5
  112. package/es/modules/splitColumn.js +126 -0
  113. package/es/modules/ssf.js +1533 -0
  114. package/{dist/packages/core/src → es}/modules/text.d.ts +10 -10
  115. package/es/modules/text.js +1207 -0
  116. package/{dist/packages/core/src → es}/modules/toolbar.d.ts +32 -32
  117. package/es/modules/toolbar.js +970 -0
  118. package/{dist/packages/core/src → es}/modules/validation.d.ts +19 -19
  119. package/es/modules/validation.js +190 -0
  120. package/{dist/packages/core/src → es}/modules/zoom.d.ts +3 -3
  121. package/es/modules/zoom.js +29 -0
  122. package/{dist/packages/core/src → es}/settings.d.ts +100 -100
  123. package/es/settings.js +36 -0
  124. package/{dist/packages/core/src → es}/types.d.ts +371 -371
  125. package/es/types.js +1 -0
  126. package/{dist/packages/core/src → es}/utils/freeze.d.ts +7 -7
  127. package/es/utils/freeze.js +86 -0
  128. package/{dist/packages/core/src → es}/utils/index.d.ts +18 -18
  129. package/es/utils/index.js +173 -0
  130. package/{dist/packages/core/src → es}/utils/patch.d.ts +37 -37
  131. package/es/utils/patch.js +381 -0
  132. package/lib/api/cell.d.ts +10 -0
  133. package/lib/api/cell.js +215 -0
  134. package/lib/api/common.d.ts +66 -0
  135. package/lib/api/common.js +88 -0
  136. package/lib/api/errors.d.ts +2 -0
  137. package/lib/api/errors.js +8 -0
  138. package/lib/api/index.d.ts +9 -0
  139. package/lib/api/index.js +101 -0
  140. package/lib/api/merge.d.ts +5 -0
  141. package/lib/api/merge.js +22 -0
  142. package/lib/api/range.d.ts +22 -0
  143. package/lib/api/range.js +138 -0
  144. package/lib/api/rowcol.d.ts +14 -0
  145. package/lib/api/rowcol.js +222 -0
  146. package/lib/api/sheet.d.ts +10 -0
  147. package/lib/api/sheet.js +145 -0
  148. package/lib/api/workbook.d.ts +15 -0
  149. package/lib/api/workbook.js +98 -0
  150. package/lib/canvas.d.ts +46 -0
  151. package/lib/canvas.js +1356 -0
  152. package/lib/context.d.ts +197 -0
  153. package/lib/context.js +392 -0
  154. package/lib/events/copy.d.ts +2 -0
  155. package/lib/events/copy.js +85 -0
  156. package/lib/events/index.d.ts +4 -0
  157. package/lib/events/index.js +49 -0
  158. package/lib/events/keyboard.d.ts +6 -0
  159. package/lib/events/keyboard.js +342 -0
  160. package/lib/events/mouse.d.ts +22 -0
  161. package/lib/events/mouse.js +1744 -0
  162. package/lib/events/paste.d.ts +3 -0
  163. package/lib/events/paste.js +1366 -0
  164. package/lib/index.d.ts +10 -0
  165. package/lib/index.js +109 -0
  166. package/lib/locale/en.d.ts +992 -0
  167. package/lib/locale/en.js +10570 -0
  168. package/lib/locale/es.d.ts +1134 -0
  169. package/lib/locale/es.js +10016 -0
  170. package/lib/locale/hi.d.ts +1030 -0
  171. package/lib/locale/hi.js +10556 -0
  172. package/lib/locale/index.d.ts +1049 -0
  173. package/lib/locale/index.js +29 -0
  174. package/lib/locale/zh.d.ts +1048 -0
  175. package/lib/locale/zh.js +10574 -0
  176. package/lib/locale/zh_tw.d.ts +1187 -0
  177. package/lib/locale/zh_tw.js +10078 -0
  178. package/lib/modules/ConditionFormat.d.ts +17 -0
  179. package/lib/modules/ConditionFormat.js +1273 -0
  180. package/lib/modules/border.d.ts +3 -0
  181. package/lib/modules/border.js +1248 -0
  182. package/lib/modules/cell.d.ts +32 -0
  183. package/lib/modules/cell.js +1085 -0
  184. package/lib/modules/clipboard.d.ts +3 -0
  185. package/lib/modules/clipboard.js +42 -0
  186. package/lib/modules/color.d.ts +1 -0
  187. package/lib/modules/color.js +7 -0
  188. package/lib/modules/comment.d.ts +97 -0
  189. package/lib/modules/comment.js +625 -0
  190. package/lib/modules/conditionalFormat.d.ts +2 -0
  191. package/lib/modules/conditionalFormat.js +447 -0
  192. package/lib/modules/cursor.d.ts +3 -0
  193. package/lib/modules/cursor.js +70 -0
  194. package/lib/modules/dataVerification.d.ts +11 -0
  195. package/lib/modules/dataVerification.js +715 -0
  196. package/lib/modules/dropCell.d.ts +10 -0
  197. package/lib/modules/dropCell.js +2282 -0
  198. package/lib/modules/filter.d.ts +45 -0
  199. package/lib/modules/filter.js +448 -0
  200. package/lib/modules/format.d.ts +6 -0
  201. package/lib/modules/format.js +334 -0
  202. package/lib/modules/formula.d.ts +54 -0
  203. package/lib/modules/formula.js +2330 -0
  204. package/lib/modules/freeze.d.ts +5 -0
  205. package/lib/modules/freeze.js +158 -0
  206. package/lib/modules/hyperlink.d.ts +21 -0
  207. package/lib/modules/hyperlink.js +232 -0
  208. package/lib/modules/iframe.d.ts +12 -0
  209. package/lib/modules/iframe.js +236 -0
  210. package/lib/modules/image.d.ts +31 -0
  211. package/lib/modules/image.js +272 -0
  212. package/lib/modules/index.d.ts +36 -0
  213. package/lib/modules/index.js +401 -0
  214. package/lib/modules/inline-string.d.ts +36 -0
  215. package/lib/modules/inline-string.js +452 -0
  216. package/lib/modules/location.d.ts +6 -0
  217. package/lib/modules/location.js +57 -0
  218. package/lib/modules/locationCondition.d.ts +21 -0
  219. package/lib/modules/locationCondition.js +229 -0
  220. package/lib/modules/merge.d.ts +3 -0
  221. package/lib/modules/merge.js +223 -0
  222. package/lib/modules/mobile.d.ts +5 -0
  223. package/lib/modules/mobile.js +41 -0
  224. package/lib/modules/moveCells.d.ts +5 -0
  225. package/lib/modules/moveCells.js +357 -0
  226. package/lib/modules/protection.d.ts +5 -0
  227. package/lib/modules/protection.js +106 -0
  228. package/lib/modules/refresh.d.ts +3 -0
  229. package/lib/modules/refresh.js +40 -0
  230. package/lib/modules/rowcol.d.ts +19 -0
  231. package/lib/modules/rowcol.js +1935 -0
  232. package/lib/modules/screenshot.d.ts +2 -0
  233. package/lib/modules/screenshot.js +96 -0
  234. package/lib/modules/searchReplace.d.ts +36 -0
  235. package/lib/modules/searchReplace.js +402 -0
  236. package/lib/modules/selection.d.ts +46 -0
  237. package/lib/modules/selection.js +1703 -0
  238. package/lib/modules/sheet.d.ts +10 -0
  239. package/lib/modules/sheet.js +250 -0
  240. package/lib/modules/sort.d.ts +7 -0
  241. package/lib/modules/sort.js +159 -0
  242. package/lib/modules/splitColumn.d.ts +5 -0
  243. package/lib/modules/splitColumn.js +136 -0
  244. package/lib/modules/ssf.js +1539 -0
  245. package/lib/modules/text.d.ts +10 -0
  246. package/lib/modules/text.js +1221 -0
  247. package/lib/modules/toolbar.d.ts +32 -0
  248. package/lib/modules/toolbar.js +1003 -0
  249. package/lib/modules/validation.d.ts +19 -0
  250. package/lib/modules/validation.js +205 -0
  251. package/lib/modules/zoom.d.ts +3 -0
  252. package/lib/modules/zoom.js +36 -0
  253. package/lib/settings.d.ts +100 -0
  254. package/lib/settings.js +42 -0
  255. package/lib/types.d.ts +371 -0
  256. package/lib/types.js +5 -0
  257. package/lib/utils/freeze.d.ts +7 -0
  258. package/lib/utils/freeze.js +92 -0
  259. package/lib/utils/index.d.ts +18 -0
  260. package/lib/utils/index.js +231 -0
  261. package/lib/utils/patch.d.ts +37 -0
  262. package/lib/utils/patch.js +392 -0
  263. package/package.json +7 -6
  264. package/dist/index.esm.js +0 -80255
  265. package/dist/index.js +0 -80601
  266. package/dist/packages/react/src/components/ChangeColor/index.d.ts +0 -7
  267. package/dist/packages/react/src/components/ConditionFormat/ConditionRules.d.ts +0 -6
  268. package/dist/packages/react/src/components/ConditionFormat/index.d.ts +0 -7
  269. package/dist/packages/react/src/components/ContextMenu/Divider.d.ts +0 -3
  270. package/dist/packages/react/src/components/ContextMenu/FilterMenu.d.ts +0 -3
  271. package/dist/packages/react/src/components/ContextMenu/Menu.d.ts +0 -8
  272. package/dist/packages/react/src/components/ContextMenu/SheetTab.d.ts +0 -4
  273. package/dist/packages/react/src/components/ContextMenu/index.d.ts +0 -5
  274. package/dist/packages/react/src/components/CustomSort/index.d.ts +0 -4
  275. package/dist/packages/react/src/components/DataVerification/DropdownList.d.ts +0 -4
  276. package/dist/packages/react/src/components/DataVerification/RangeDialog.d.ts +0 -4
  277. package/dist/packages/react/src/components/DataVerification/getDisplayedRangeTxt.d.ts +0 -2
  278. package/dist/packages/react/src/components/DataVerification/index.d.ts +0 -4
  279. package/dist/packages/react/src/components/Dialog/index.d.ts +0 -15
  280. package/dist/packages/react/src/components/DuneChartsInputModal/DuneChartsInputModal.d.ts +0 -11
  281. package/dist/packages/react/src/components/DunePreview/DunePreview.d.ts +0 -13
  282. package/dist/packages/react/src/components/FilterOption/index.d.ts +0 -5
  283. package/dist/packages/react/src/components/FormatSearch/index.d.ts +0 -6
  284. package/dist/packages/react/src/components/FormulaSearch/index.d.ts +0 -5
  285. package/dist/packages/react/src/components/FxEditor/NameBox.d.ts +0 -3
  286. package/dist/packages/react/src/components/FxEditor/index.d.ts +0 -4
  287. package/dist/packages/react/src/components/IFrameBoxs/iFrameBoxs.d.ts +0 -4
  288. package/dist/packages/react/src/components/ImgBoxs/index.d.ts +0 -3
  289. package/dist/packages/react/src/components/LinkEidtCard/index.d.ts +0 -5
  290. package/dist/packages/react/src/components/LocationCondition/index.d.ts +0 -3
  291. package/dist/packages/react/src/components/MessageBox/index.d.ts +0 -9
  292. package/dist/packages/react/src/components/NotationBoxes/index.d.ts +0 -3
  293. package/dist/packages/react/src/components/ResetColumnWidth/index.d.ts +0 -2
  294. package/dist/packages/react/src/components/SVGDefines.d.ts +0 -5
  295. package/dist/packages/react/src/components/SVGIcon.d.ts +0 -9
  296. package/dist/packages/react/src/components/SearchReplace/index.d.ts +0 -6
  297. package/dist/packages/react/src/components/Sheet/index.d.ts +0 -8
  298. package/dist/packages/react/src/components/SheetList/SheetHiddenButton.d.ts +0 -8
  299. package/dist/packages/react/src/components/SheetList/SheetListItem.d.ts +0 -9
  300. package/dist/packages/react/src/components/SheetList/index.d.ts +0 -4
  301. package/dist/packages/react/src/components/SheetOverlay/ColumnHeader.d.ts +0 -3
  302. package/dist/packages/react/src/components/SheetOverlay/ContentEditable.d.ts +0 -11
  303. package/dist/packages/react/src/components/SheetOverlay/FormulaHint/index.d.ts +0 -4
  304. package/dist/packages/react/src/components/SheetOverlay/FormulaSearch/constant.d.ts +0 -63
  305. package/dist/packages/react/src/components/SheetOverlay/FormulaSearch/index.d.ts +0 -4
  306. package/dist/packages/react/src/components/SheetOverlay/InputBox.d.ts +0 -3
  307. package/dist/packages/react/src/components/SheetOverlay/RowHeader.d.ts +0 -3
  308. package/dist/packages/react/src/components/SheetOverlay/ScrollBar/index.d.ts +0 -7
  309. package/dist/packages/react/src/components/SheetOverlay/index.d.ts +0 -4
  310. package/dist/packages/react/src/components/SheetTab/SheetItem.d.ts +0 -8
  311. package/dist/packages/react/src/components/SheetTab/index.d.ts +0 -4
  312. package/dist/packages/react/src/components/SplitColumn/index.d.ts +0 -3
  313. package/dist/packages/react/src/components/Toolbar/Button.d.ts +0 -12
  314. package/dist/packages/react/src/components/Toolbar/ColorPicker.d.ts +0 -6
  315. package/dist/packages/react/src/components/Toolbar/Combo.d.ts +0 -12
  316. package/dist/packages/react/src/components/Toolbar/CustomBorder.d.ts +0 -7
  317. package/dist/packages/react/src/components/Toolbar/CustomButton.d.ts +0 -11
  318. package/dist/packages/react/src/components/Toolbar/CustomColor.d.ts +0 -8
  319. package/dist/packages/react/src/components/Toolbar/CustomIcon.d.ts +0 -9
  320. package/dist/packages/react/src/components/Toolbar/Divider.d.ts +0 -4
  321. package/dist/packages/react/src/components/Toolbar/MoreItemsContainer.d.ts +0 -6
  322. package/dist/packages/react/src/components/Toolbar/Select.d.ts +0 -14
  323. package/dist/packages/react/src/components/Toolbar/index.d.ts +0 -10
  324. package/dist/packages/react/src/components/Workbook/api.d.ts +0 -1177
  325. package/dist/packages/react/src/components/Workbook/index.d.ts +0 -1185
  326. package/dist/packages/react/src/components/ZoomControl/index.d.ts +0 -4
  327. package/dist/packages/react/src/components/index.d.ts +0 -4
  328. package/dist/packages/react/src/constants.d.ts +0 -1
  329. package/dist/packages/react/src/context/index.d.ts +0 -25
  330. package/dist/packages/react/src/context/modal.d.ts +0 -10
  331. package/dist/packages/react/src/hooks/useAlert.d.ts +0 -4
  332. package/dist/packages/react/src/hooks/useDialog.d.ts +0 -5
  333. package/dist/packages/react/src/hooks/useOutsideClick.d.ts +0 -2
  334. package/dist/packages/react/src/hooks/usePrevious.d.ts +0 -2
  335. package/dist/packages/react/src/index.d.ts +0 -1
  336. package/dist/packages/react/src/utils/datepickerStyles.d.ts +0 -2
  337. package/dist/stories/API.stories.d.ts +0 -1210
  338. package/dist/stories/Collabration.stories.d.ts +0 -2359
  339. package/dist/stories/Features.stories.d.ts +0 -9430
  340. package/dist/stories/data/cell.d.ts +0 -983
  341. package/dist/stories/data/dataVerification.d.ts +0 -131
  342. package/dist/stories/data/empty.d.ts +0 -10
  343. package/dist/stories/data/formula.d.ts +0 -362
  344. package/dist/stories/data/freeze.d.ts +0 -34
  345. package/dist/stories/data/protected.d.ts +0 -40
  346. package/dist/stories/utils.d.ts +0 -1
@@ -0,0 +1,1207 @@
1
+ import _ from "lodash";
2
+ import { isdatatypemulti } from ".";
3
+ import { locale } from "../locale";
4
+ import { normalizedCellAttr } from "./cell";
5
+ import { isInlineStringCell } from "./inline-string";
6
+ function checkWordByteLength(value) {
7
+ return Math.ceil(value.charCodeAt(0).toString(2).length / 8);
8
+ }
9
+ export function hasChinaword(s) {
10
+ var patrn = /[\u4E00-\u9FA5]|[\uFE30-\uFFA0]/gi;
11
+ if (!patrn.exec(s)) {
12
+ return false;
13
+ }
14
+ return true;
15
+ }
16
+ var textHeightCache = {};
17
+ var measureTextCache = {};
18
+ var measureTextCellInfoCache = {};
19
+ export function clearMeasureTextCache() {
20
+ measureTextCache = {};
21
+ measureTextCellInfoCache = {};
22
+ }
23
+ function getTextSize(text, font) {
24
+ if (font in textHeightCache) {
25
+ return textHeightCache[font];
26
+ }
27
+ var ele = document.createElement("span");
28
+ ele.style.float = "left";
29
+ ele.style.whiteSpace = "nowrap";
30
+ ele.style.visibility = "hidden";
31
+ ele.style.margin = "0";
32
+ ele.style.padding = "0";
33
+ ele.innerHTML = text;
34
+ document.body.append(ele);
35
+ var w = Math.max(ele.scrollWidth, ele.offsetWidth, ele.clientWidth);
36
+ var h = Math.max(ele.scrollHeight, ele.offsetHeight, ele.clientHeight);
37
+ textHeightCache[font] = [w, h];
38
+ ele.remove();
39
+ return [w, h];
40
+ }
41
+ export function defaultFont(defaultFontSize) {
42
+ return "normal normal normal ".concat(defaultFontSize, "pt \"Helvetica Neue\", Helvetica, Arial, \"PingFang SC\", \"Hiragino Sans GB\", \"Heiti SC\", \"WenQuanYi Micro Hei\", sans-serif");
43
+ }
44
+ export function getFontSet(format, defaultFontSize, ctx) {
45
+ if (_.isPlainObject(format)) {
46
+ var fontAttr = [];
47
+ if (format.it === "0" || format.it === 0 || _.isNil(format.it)) {
48
+ fontAttr.push("normal");
49
+ } else {
50
+ fontAttr.push("italic");
51
+ }
52
+ fontAttr.push("normal");
53
+ if (format.bl === "0" || format.bl === 0 || _.isNil(format.bl)) {
54
+ fontAttr.push("normal");
55
+ } else {
56
+ fontAttr.push("bold");
57
+ }
58
+ if (!format.fs) {
59
+ fontAttr.push("".concat(defaultFontSize, "pt"));
60
+ } else {
61
+ fontAttr.push("".concat(Math.ceil(format.fs), "pt"));
62
+ }
63
+ var fontSet = "\"Helvetica Neue\", Helvetica, Arial, \"PingFang SC\", \"Hiragino Sans GB\", \"Heiti SC\", \"Microsoft YaHei\", \"WenQuanYi Micro Hei\", sans-serif";
64
+ if (ctx) {
65
+ var fontarray = locale(ctx).fontarray;
66
+ if (!format.ff) {
67
+ fontSet = "".concat(fontarray[0], ",").concat(fontSet);
68
+ } else {
69
+ var fontfamily = null;
70
+ if (ctx) {
71
+ if (isdatatypemulti(format.ff).num) {
72
+ fontfamily = fontarray[parseInt(format.ff, 10)];
73
+ } else {
74
+ fontfamily = format.ff;
75
+ fontfamily = fontfamily.replace(/"/g, "").replace(/'/g, "");
76
+ if (fontfamily.indexOf(" ") > -1) {
77
+ fontfamily = "\"".concat(fontfamily, "\"");
78
+ }
79
+ }
80
+ }
81
+ fontSet = "".concat(fontfamily, ",").concat(fontSet);
82
+ }
83
+ }
84
+ return "".concat(fontAttr.join(" "), " ").concat(fontSet);
85
+ }
86
+ return defaultFont(defaultFontSize);
87
+ }
88
+ export function getMeasureText(value, renderCtx, sheetCtx, fontset) {
89
+ var mtc = measureTextCache["".concat(value, "_").concat(renderCtx.font)];
90
+ if (fontset) {
91
+ mtc = measureTextCache["".concat(value, "_").concat(fontset)];
92
+ }
93
+ if (mtc != null) {
94
+ return mtc;
95
+ }
96
+ if (fontset) {
97
+ renderCtx.font = fontset;
98
+ }
99
+ var measureText = renderCtx.measureText(value);
100
+ var cache = {};
101
+ cache.width = measureText.width;
102
+ if (fontset) {
103
+ renderCtx.font = fontset;
104
+ }
105
+ cache.actualBoundingBoxDescent = measureText.actualBoundingBoxDescent;
106
+ cache.actualBoundingBoxAscent = measureText.actualBoundingBoxAscent;
107
+ if (cache.actualBoundingBoxDescent == null || cache.actualBoundingBoxAscent == null || Number.isNaN(cache.actualBoundingBoxDescent) || Number.isNaN(cache.actualBoundingBoxAscent)) {
108
+ var commonWord = "M";
109
+ if (hasChinaword(value)) {
110
+ commonWord = "田";
111
+ }
112
+ var oneLineTextHeight = getTextSize(commonWord, renderCtx.font)[1] * 0.8;
113
+ if (renderCtx.textBaseline === "top") {
114
+ cache.actualBoundingBoxDescent = oneLineTextHeight;
115
+ cache.actualBoundingBoxAscent = 0;
116
+ } else if (renderCtx.textBaseline === "middle") {
117
+ cache.actualBoundingBoxDescent = oneLineTextHeight / 2;
118
+ cache.actualBoundingBoxAscent = oneLineTextHeight / 2;
119
+ } else {
120
+ cache.actualBoundingBoxDescent = 0;
121
+ cache.actualBoundingBoxAscent = oneLineTextHeight;
122
+ }
123
+ }
124
+ if (renderCtx.textBaseline === "alphabetic") {
125
+ var descText = "gjpqy";
126
+ var matchText = "abcdABCD";
127
+ var descTextMeasure = measureTextCache["".concat(descText, "_").concat(renderCtx.font)];
128
+ if (fontset) {
129
+ descTextMeasure = measureTextCache["".concat(descText, "_").concat(fontset)];
130
+ }
131
+ var matchTextMeasure = measureTextCache["".concat(matchText, "_").concat(renderCtx.font)];
132
+ if (fontset) {
133
+ matchTextMeasure = measureTextCache["".concat(matchText, "_").concat(fontset)];
134
+ }
135
+ if (descTextMeasure == null) {
136
+ descTextMeasure = renderCtx.measureText(descText);
137
+ }
138
+ if (matchTextMeasure == null) {
139
+ matchTextMeasure = renderCtx.measureText(matchText);
140
+ }
141
+ if (cache.actualBoundingBoxDescent <= matchTextMeasure.actualBoundingBoxDescent) {
142
+ cache.actualBoundingBoxDescent = descTextMeasure.actualBoundingBoxDescent;
143
+ if (!cache.actualBoundingBoxDescent) {
144
+ cache.actualBoundingBoxDescent = 0;
145
+ }
146
+ }
147
+ }
148
+ cache.width *= sheetCtx.zoomRatio;
149
+ cache.actualBoundingBoxDescent *= sheetCtx.zoomRatio;
150
+ cache.actualBoundingBoxAscent *= sheetCtx.zoomRatio;
151
+ measureTextCache["".concat(value, "_").concat(sheetCtx.zoomRatio, "_").concat(renderCtx.font)] = cache;
152
+ return cache;
153
+ }
154
+ export function isSupportBoundingBox(ctx) {
155
+ var measureText = ctx.measureText("田");
156
+ if (_.isNil(measureText.actualBoundingBoxAscent)) {
157
+ return false;
158
+ }
159
+ return true;
160
+ }
161
+ export function drawLineInfo(wordGroup, cancelLine, underLine, option) {
162
+ var left = option.left;
163
+ var top = option.top;
164
+ var width = option.width;
165
+ var asc = option.asc;
166
+ var desc = option.desc;
167
+ var fs = option.fs;
168
+ if (wordGroup.wrap === true) {
169
+ return;
170
+ }
171
+ if (wordGroup.inline === true && !_.isNil(wordGroup.style)) {
172
+ cancelLine = wordGroup.style.cl;
173
+ underLine = wordGroup.style.un;
174
+ }
175
+ if (Number(cancelLine) !== 0) {
176
+ wordGroup.cancelLine = {};
177
+ wordGroup.cancelLine.startX = left;
178
+ wordGroup.cancelLine.startY = top - asc / 2 + 1;
179
+ wordGroup.cancelLine.endX = left + width;
180
+ wordGroup.cancelLine.endY = top - asc / 2 + 1;
181
+ wordGroup.cancelLine.fs = fs;
182
+ }
183
+ var nUnderline = Number(underLine);
184
+ if (nUnderline !== 0) {
185
+ wordGroup.underLine = [];
186
+ if (nUnderline === 1 || nUnderline === 2) {
187
+ var item = {};
188
+ item.startX = left;
189
+ item.startY = top + 3;
190
+ item.endX = left + width;
191
+ item.endY = top + 3;
192
+ item.fs = fs;
193
+ wordGroup.underLine.push(item);
194
+ }
195
+ if (nUnderline === 2) {
196
+ var item = {};
197
+ item.startX = left;
198
+ item.startY = top + desc;
199
+ item.endX = left + width;
200
+ item.endY = top + desc;
201
+ item.fs = fs;
202
+ wordGroup.underLine.push(item);
203
+ }
204
+ if (nUnderline === 3 || nUnderline === 4) {
205
+ var item = {};
206
+ item.startX = left;
207
+ item.startY = top + desc;
208
+ item.endX = left + width;
209
+ item.endY = top + desc;
210
+ item.fs = fs;
211
+ wordGroup.underLine.push(item);
212
+ }
213
+ if (nUnderline === 4) {
214
+ var item = {};
215
+ item.startX = left;
216
+ item.startY = top + desc + 2;
217
+ item.endX = left + width;
218
+ item.endY = top + desc + 2;
219
+ item.fs = fs;
220
+ wordGroup.underLine.push(item);
221
+ }
222
+ }
223
+ }
224
+ export function getCellTextInfo(cell, renderCtx, sheetCtx, option, ctx) {
225
+ var cellWidth = option.cellWidth;
226
+ var cellHeight = option.cellHeight;
227
+ var isMode = "";
228
+ var isModeSplit = "";
229
+ if (cellWidth == null) {
230
+ isMode = "onlyWidth";
231
+ isModeSplit = "_";
232
+ }
233
+ var textInfo = measureTextCellInfoCache["".concat(option.r, "_").concat(option.c).concat(isModeSplit).concat(isMode)];
234
+ if (textInfo) {
235
+ return textInfo;
236
+ }
237
+ var space_width = option.space_width;
238
+ var space_height = option.space_height;
239
+ if (space_width === undefined) {
240
+ space_width = 2;
241
+ }
242
+ if (space_height === undefined) {
243
+ space_height = 2;
244
+ }
245
+ var horizonAlign = normalizedCellAttr(cell, "ht");
246
+ var verticalAlign = normalizedCellAttr(cell, "vt");
247
+ var tb = normalizedCellAttr(cell, "tb");
248
+ var tr = normalizedCellAttr(cell, "tr");
249
+ var rt = normalizedCellAttr(cell, "rt");
250
+ var isRotateUp = 1;
251
+ if (_.isNil(rt)) {
252
+ if (tr === "0") {
253
+ rt = 0;
254
+ } else if (tr === "1") {
255
+ rt = 45;
256
+ } else if (tr === "4") {
257
+ rt = 90;
258
+ } else if (tr === "2") {
259
+ rt = 135;
260
+ } else if (tr === "5") {
261
+ rt = 180;
262
+ }
263
+ if (_.isNil(rt)) {
264
+ rt = 0;
265
+ }
266
+ }
267
+ if (rt > 180 || rt < 0) {
268
+ rt = 0;
269
+ }
270
+ rt = parseInt(rt, 10);
271
+ if (rt > 90) {
272
+ rt = 90 - rt;
273
+ isRotateUp = 0;
274
+ }
275
+ renderCtx.textAlign = "start";
276
+ var textContent = {};
277
+ textContent.values = [];
278
+ var fontset;
279
+ var cancelLine = "0";
280
+ var underLine = "0";
281
+ var fontSize = 11;
282
+ var isInline = false;
283
+ var value;
284
+ var inlineStringArr = [];
285
+ if (isInlineStringCell(cell)) {
286
+ var sharedStrings = cell.ct.s;
287
+ var similarIndex = 0;
288
+ for (var i = 0; i < sharedStrings.length; i += 1) {
289
+ var shareCell = sharedStrings[i];
290
+ var scfontset = getFontSet(shareCell, sheetCtx.defaultFontSize, ctx);
291
+ var fc = shareCell.fc;
292
+ var cl = shareCell.cl;
293
+ var un = shareCell.un;
294
+ var v = shareCell.v;
295
+ var fs = shareCell.fs;
296
+ v = v.replace(/\r\n/g, "_x000D_").replace(/&#13;&#10;/g, "_x000D_").replace(/\r/g, "_x000D_").replace(/\n/g, "_x000D_");
297
+ var splitArr = v.split("_x000D_");
298
+ for (var x = 0; x < splitArr.length; x += 1) {
299
+ var newValue = splitArr[x];
300
+ if (newValue === "" && x !== splitArr.length - 1) {
301
+ inlineStringArr.push({
302
+ fontset: scfontset,
303
+ fc: !fc ? "#000" : fc,
304
+ cl: !cl ? 0 : cl,
305
+ un: !un ? 0 : un,
306
+ wrap: true,
307
+ fs: !fs ? 11 : fs
308
+ });
309
+ similarIndex += 1;
310
+ } else {
311
+ inlineStringArr.push({
312
+ fontset: scfontset,
313
+ fc: !fc ? "#000" : fc,
314
+ cl: !cl ? 0 : cl,
315
+ un: !un ? 0 : un,
316
+ v: newValue,
317
+ si: similarIndex,
318
+ fs: !fs ? 11 : fs
319
+ });
320
+ if (x !== splitArr.length - 1) {
321
+ inlineStringArr.push({
322
+ fontset: scfontset,
323
+ fc: !fc ? "#000" : fc,
324
+ cl: !cl ? 0 : cl,
325
+ un: !un ? 0 : un,
326
+ wrap: true,
327
+ fs: !fs ? 11 : fs
328
+ });
329
+ similarIndex += 1;
330
+ }
331
+ }
332
+ }
333
+ similarIndex += 1;
334
+ }
335
+ isInline = true;
336
+ } else {
337
+ fontset = getFontSet(cell, sheetCtx.defaultFontSize, ctx);
338
+ renderCtx.font = fontset;
339
+ cancelLine = normalizedCellAttr(cell, "cl");
340
+ underLine = normalizedCellAttr(cell, "un");
341
+ fontSize = normalizedCellAttr(cell, "fs");
342
+ if (cell instanceof Object) {
343
+ value = cell.m;
344
+ if (_.isNil(value)) {
345
+ value = cell.v;
346
+ }
347
+ } else {
348
+ value = cell;
349
+ }
350
+ if (_.isEmpty(value)) {
351
+ return null;
352
+ }
353
+ }
354
+ if (tr === "3") {
355
+ renderCtx.textBaseline = "top";
356
+ var textW_all = 0;
357
+ var textH_all = 0;
358
+ var colIndex = 0;
359
+ var textH_all_cache = 0;
360
+ var textH_all_Column = {};
361
+ var textH_all_ColumnHeight = [];
362
+ if (isInline) {
363
+ var preShareCell = null;
364
+ for (var i = 0; i < inlineStringArr.length; i += 1) {
365
+ var shareCell = inlineStringArr[i];
366
+ var value1 = shareCell.v;
367
+ var showValue = shareCell.v;
368
+ if (shareCell.wrap === true) {
369
+ value1 = "M";
370
+ showValue = "";
371
+ if (!_.isNil(preShareCell) && preShareCell.wrap !== true && i < inlineStringArr.length - 1) {
372
+ textH_all_ColumnHeight.push(textH_all_cache);
373
+ textH_all_cache = 0;
374
+ colIndex += 1;
375
+ preShareCell = shareCell;
376
+ continue;
377
+ }
378
+ }
379
+ var measureText = getMeasureText(value1, renderCtx, sheetCtx, shareCell.fontset);
380
+ var textW = measureText.width + space_width;
381
+ var textH = measureText.actualBoundingBoxAscent + measureText.actualBoundingBoxDescent + space_height;
382
+ textH_all_cache += textH;
383
+ if (tb === "2" && !shareCell.wrap) {
384
+ if (textH_all_cache > cellHeight && !_.isNil(textH_all_Column[colIndex])) {
385
+ textH_all_ColumnHeight.push(textH_all_cache - textH);
386
+ textH_all_cache = textH;
387
+ colIndex += 1;
388
+ }
389
+ }
390
+ if (i === inlineStringArr.length - 1) {
391
+ textH_all_ColumnHeight.push(textH_all_cache);
392
+ }
393
+ if (_.isNil(textH_all_Column[colIndex])) {
394
+ textH_all_Column[colIndex] = [];
395
+ }
396
+ var item = {
397
+ content: showValue,
398
+ style: shareCell,
399
+ width: textW,
400
+ height: textH,
401
+ left: 0,
402
+ top: 0,
403
+ colIndex: colIndex,
404
+ asc: measureText.actualBoundingBoxAscent,
405
+ desc: measureText.actualBoundingBoxDescent,
406
+ inline: true,
407
+ wrap: false
408
+ };
409
+ if (shareCell.wrap === true) {
410
+ item.wrap = true;
411
+ }
412
+ textH_all_Column[colIndex].push(item);
413
+ preShareCell = shareCell;
414
+ }
415
+ } else {
416
+ var measureText = getMeasureText(value, renderCtx, sheetCtx);
417
+ var textHeight = measureText.actualBoundingBoxDescent + measureText.actualBoundingBoxAscent;
418
+ value = value.toString();
419
+ var vArr = [];
420
+ if (value.length > 1) {
421
+ vArr = value.split("");
422
+ } else {
423
+ vArr.push(value);
424
+ }
425
+ var oneWordWidth = getMeasureText(vArr[0], renderCtx, sheetCtx).width;
426
+ for (var i = 0; i < vArr.length; i += 1) {
427
+ var textW = oneWordWidth + space_width;
428
+ var textH = textHeight + space_height;
429
+ textH_all_cache += textH;
430
+ if (tb === "2") {
431
+ if (textH_all_cache > cellHeight && !_.isNil(textH_all_Column[colIndex])) {
432
+ textH_all_ColumnHeight.push(textH_all_cache - textH);
433
+ textH_all_cache = textH;
434
+ colIndex += 1;
435
+ }
436
+ }
437
+ if (i === vArr.length - 1) {
438
+ textH_all_ColumnHeight.push(textH_all_cache);
439
+ }
440
+ if (_.isNil(textH_all_Column[colIndex])) {
441
+ textH_all_Column[colIndex] = [];
442
+ }
443
+ textH_all_Column[colIndex].push({
444
+ content: vArr[i],
445
+ style: fontset,
446
+ width: textW,
447
+ height: textH,
448
+ left: 0,
449
+ top: 0,
450
+ colIndex: colIndex,
451
+ asc: measureText.actualBoundingBoxAscent,
452
+ desc: measureText.actualBoundingBoxDescent
453
+ });
454
+ }
455
+ }
456
+ var textH_all_ColumWidth = [];
457
+ for (var i = 0; i < textH_all_ColumnHeight.length; i += 1) {
458
+ var columnHeight = textH_all_ColumnHeight[i];
459
+ var col = textH_all_Column[i];
460
+ var colMaxW = 0;
461
+ for (var c = 0; c < col.length; c += 1) {
462
+ var word = col[c];
463
+ colMaxW = Math.max(colMaxW, word.width);
464
+ }
465
+ textH_all_ColumWidth.push(colMaxW);
466
+ textW_all += colMaxW;
467
+ textH_all = Math.max(textH_all, columnHeight);
468
+ }
469
+ textContent.type = "verticalWrap";
470
+ textContent.textWidthAll = textW_all;
471
+ textContent.textHeightAll = textH_all;
472
+ if (isMode === "onlyWidth") {
473
+ return textContent;
474
+ }
475
+ var cumColumnWidth = 0;
476
+ for (var i = 0; i < textH_all_ColumnHeight.length; i += 1) {
477
+ var columnHeight = textH_all_ColumnHeight[i];
478
+ var columnWidth = textH_all_ColumWidth[i];
479
+ var col = textH_all_Column[i];
480
+ var cumWordHeight = 0;
481
+ for (var c = 0; c < col.length; c += 1) {
482
+ var word = col[c];
483
+ var left = space_width + cumColumnWidth;
484
+ if (horizonAlign === "0") {
485
+ left = cellWidth / 2 + cumColumnWidth - textW_all / 2 + space_width * textH_all_ColumnHeight.length;
486
+ } else if (horizonAlign === "2") {
487
+ left = cellWidth + cumColumnWidth - textW_all + space_width;
488
+ }
489
+ var top_1 = cellHeight - space_height + cumWordHeight - columnHeight;
490
+ if (verticalAlign === "0") {
491
+ top_1 = cellHeight / 2 + cumWordHeight - columnHeight / 2;
492
+ } else if (verticalAlign === "1") {
493
+ top_1 = space_height + cumWordHeight;
494
+ }
495
+ cumWordHeight += word.height;
496
+ word.left = left;
497
+ word.top = top_1;
498
+ drawLineInfo(word, cancelLine, underLine, {
499
+ width: columnWidth,
500
+ height: word.height,
501
+ left: left,
502
+ top: top_1 + word.height - space_height,
503
+ asc: word.height,
504
+ desc: 0,
505
+ fs: fontSize
506
+ });
507
+ textContent.values.push(word);
508
+ }
509
+ cumColumnWidth += columnWidth;
510
+ }
511
+ } else {
512
+ var supportBoundBox = isSupportBoundingBox(renderCtx);
513
+ if (supportBoundBox) {
514
+ renderCtx.textBaseline = "alphabetic";
515
+ } else {
516
+ renderCtx.textBaseline = "bottom";
517
+ }
518
+ if (tb === "2" || isInline) {
519
+ var textW_all = 0;
520
+ var textH_all = 0;
521
+ var textW_all_inner = 0;
522
+ var splitIndex = 0;
523
+ var text_all_split = {};
524
+ textContent.rotate = rt;
525
+ rt = Math.abs(rt);
526
+ var anchor = 0;
527
+ var preStr = void 0;
528
+ var preTextHeight = void 0;
529
+ var preTextWidth = void 0;
530
+ var preMeasureText = void 0;
531
+ var i = 1;
532
+ var spaceOrTwoByte = null;
533
+ var spaceOrTwoByteIndex = null;
534
+ if (isInline) {
535
+ while (i <= inlineStringArr.length) {
536
+ var shareCells = inlineStringArr.slice(anchor, i);
537
+ if (shareCells[shareCells.length - 1].wrap === true) {
538
+ anchor = i;
539
+ if (shareCells.length > 1) {
540
+ for (var s = 0; s < shareCells.length - 1; s += 1) {
541
+ var sc = shareCells[s];
542
+ var item = {
543
+ content: sc.v,
544
+ style: sc,
545
+ width: sc.measureText.width,
546
+ height: sc.measureText.actualBoundingBoxAscent + sc.measureText.actualBoundingBoxDescent,
547
+ left: 0,
548
+ top: 0,
549
+ splitIndex: splitIndex,
550
+ asc: sc.measureText.actualBoundingBoxAscent,
551
+ desc: sc.measureText.actualBoundingBoxDescent,
552
+ inline: true,
553
+ fs: sc.fs
554
+ };
555
+ text_all_split[splitIndex].push(item);
556
+ }
557
+ }
558
+ if (shareCells.length === 1) {
559
+ var sc = shareCells[0];
560
+ var measureText = getMeasureText("M", renderCtx, sheetCtx, sc.fontset);
561
+ if (_.isNil(text_all_split[splitIndex])) {
562
+ text_all_split[splitIndex] = [];
563
+ }
564
+ text_all_split[splitIndex].push({
565
+ content: "",
566
+ style: sc,
567
+ width: measureText.width,
568
+ height: measureText.actualBoundingBoxAscent + measureText.actualBoundingBoxDescent,
569
+ left: 0,
570
+ top: 0,
571
+ splitIndex: splitIndex,
572
+ asc: measureText.actualBoundingBoxAscent,
573
+ desc: measureText.actualBoundingBoxDescent,
574
+ inline: true,
575
+ wrap: true,
576
+ fs: sc.fs
577
+ });
578
+ }
579
+ splitIndex += 1;
580
+ i += 1;
581
+ continue;
582
+ }
583
+ var textWidth = 0;
584
+ var textHeight = 0;
585
+ for (var s = 0; s < shareCells.length; s += 1) {
586
+ var sc = shareCells[s];
587
+ if (_.isNil(sc.measureText)) {
588
+ sc.measureText = getMeasureText(sc.v, renderCtx, sheetCtx, sc.fontset);
589
+ }
590
+ textWidth += sc.measureText.width;
591
+ textHeight = Math.max(sc.measureText.actualBoundingBoxAscent + sc.measureText.actualBoundingBoxDescent);
592
+ }
593
+ var width = textWidth * Math.cos(rt * Math.PI / 180) + textHeight * Math.sin(rt * Math.PI / 180);
594
+ var height = textWidth * Math.sin(rt * Math.PI / 180) + textHeight * Math.cos(rt * Math.PI / 180);
595
+ var lastWord = shareCells[shareCells.length - 1];
596
+ if (lastWord.v === " " || checkWordByteLength(lastWord.v) === 2) {
597
+ spaceOrTwoByteIndex = i;
598
+ }
599
+ if (rt !== 0) {
600
+ if (height + space_height > cellHeight && !_.isNil(text_all_split[splitIndex]) && tb === "2") {
601
+ if (!_.isNil(spaceOrTwoByteIndex) && spaceOrTwoByteIndex < i) {
602
+ for (var s = 0; s < spaceOrTwoByteIndex - anchor; s += 1) {
603
+ var sc = shareCells[s];
604
+ text_all_split[splitIndex].push({
605
+ content: sc.v,
606
+ style: sc,
607
+ width: sc.measureText.width,
608
+ height: sc.measureText.actualBoundingBoxAscent + sc.measureText.actualBoundingBoxDescent,
609
+ left: 0,
610
+ top: 0,
611
+ splitIndex: splitIndex,
612
+ asc: sc.measureText.actualBoundingBoxAscent,
613
+ desc: sc.measureText.actualBoundingBoxDescent,
614
+ inline: true,
615
+ fs: sc.fs
616
+ });
617
+ }
618
+ anchor = spaceOrTwoByteIndex;
619
+ i = spaceOrTwoByteIndex + 1;
620
+ splitIndex += 1;
621
+ spaceOrTwoByteIndex = null;
622
+ } else {
623
+ anchor = i - 1;
624
+ for (var s = 0; s < shareCells.length - 1; s += 1) {
625
+ var sc = shareCells[s];
626
+ text_all_split[splitIndex].push({
627
+ content: sc.v,
628
+ style: sc,
629
+ width: sc.measureText.width,
630
+ height: sc.measureText.actualBoundingBoxAscent + sc.measureText.actualBoundingBoxDescent,
631
+ left: 0,
632
+ top: 0,
633
+ splitIndex: splitIndex,
634
+ asc: sc.measureText.actualBoundingBoxAscent,
635
+ desc: sc.measureText.actualBoundingBoxDescent,
636
+ inline: true,
637
+ fs: sc.fs
638
+ });
639
+ }
640
+ splitIndex += 1;
641
+ }
642
+ } else if (i === inlineStringArr.length) {
643
+ if (_.isNil(text_all_split[splitIndex])) {
644
+ text_all_split[splitIndex] = [];
645
+ }
646
+ for (var s = 0; s < shareCells.length; s += 1) {
647
+ var sc = shareCells[s];
648
+ text_all_split[splitIndex].push({
649
+ content: sc.v,
650
+ style: sc,
651
+ width: sc.measureText.width,
652
+ height: sc.measureText.actualBoundingBoxAscent + sc.measureText.actualBoundingBoxDescent,
653
+ left: 0,
654
+ top: 0,
655
+ splitIndex: splitIndex,
656
+ asc: sc.measureText.actualBoundingBoxAscent,
657
+ desc: sc.measureText.actualBoundingBoxDescent,
658
+ inline: true,
659
+ fs: sc.fs
660
+ });
661
+ }
662
+ break;
663
+ } else {
664
+ if (_.isNil(text_all_split[splitIndex])) {
665
+ text_all_split[splitIndex] = [];
666
+ }
667
+ i += 1;
668
+ }
669
+ } else {
670
+ if (width + space_width > cellWidth && !_.isNil(text_all_split[splitIndex]) && tb === "2") {
671
+ if (!_.isNil(spaceOrTwoByteIndex) && spaceOrTwoByteIndex < i) {
672
+ for (var s = 0; s < spaceOrTwoByteIndex - anchor; s += 1) {
673
+ var sc = shareCells[s];
674
+ text_all_split[splitIndex].push({
675
+ content: sc.v,
676
+ style: sc,
677
+ width: sc.measureText.width,
678
+ height: sc.measureText.actualBoundingBoxAscent + sc.measureText.actualBoundingBoxDescent,
679
+ left: 0,
680
+ top: 0,
681
+ splitIndex: splitIndex,
682
+ asc: sc.measureText.actualBoundingBoxAscent,
683
+ desc: sc.measureText.actualBoundingBoxDescent,
684
+ inline: true,
685
+ fs: sc.fs
686
+ });
687
+ }
688
+ anchor = spaceOrTwoByteIndex;
689
+ i = spaceOrTwoByteIndex + 1;
690
+ splitIndex += 1;
691
+ spaceOrTwoByteIndex = null;
692
+ } else {
693
+ anchor = i - 1;
694
+ for (var s = 0; s < shareCells.length - 1; s += 1) {
695
+ var sc = shareCells[s];
696
+ text_all_split[splitIndex].push({
697
+ content: sc.v,
698
+ style: sc,
699
+ width: sc.measureText.width,
700
+ height: sc.measureText.actualBoundingBoxAscent + sc.measureText.actualBoundingBoxDescent,
701
+ left: 0,
702
+ top: 0,
703
+ splitIndex: splitIndex,
704
+ asc: sc.measureText.actualBoundingBoxAscent,
705
+ desc: sc.measureText.actualBoundingBoxDescent,
706
+ inline: true,
707
+ fs: sc.fs
708
+ });
709
+ }
710
+ splitIndex += 1;
711
+ }
712
+ } else if (i === inlineStringArr.length) {
713
+ if (_.isNil(text_all_split[splitIndex])) {
714
+ text_all_split[splitIndex] = [];
715
+ }
716
+ for (var s = 0; s < shareCells.length; s += 1) {
717
+ var sc = shareCells[s];
718
+ text_all_split[splitIndex].push({
719
+ content: sc.v,
720
+ style: sc,
721
+ width: sc.measureText.width,
722
+ height: sc.measureText.actualBoundingBoxAscent + sc.measureText.actualBoundingBoxDescent,
723
+ left: 0,
724
+ top: 0,
725
+ splitIndex: splitIndex,
726
+ asc: sc.measureText.actualBoundingBoxAscent,
727
+ desc: sc.measureText.actualBoundingBoxDescent,
728
+ inline: true,
729
+ fs: sc.fs
730
+ });
731
+ }
732
+ break;
733
+ } else {
734
+ if (_.isNil(text_all_split[splitIndex])) {
735
+ text_all_split[splitIndex] = [];
736
+ }
737
+ i += 1;
738
+ }
739
+ }
740
+ }
741
+ } else {
742
+ value = value.toString();
743
+ while (i <= value.length) {
744
+ var str = value.substring(anchor, i);
745
+ var measureText = getMeasureText(str, renderCtx, sheetCtx);
746
+ var textWidth = measureText.width;
747
+ var textHeight = measureText.actualBoundingBoxAscent + measureText.actualBoundingBoxDescent;
748
+ var width = textWidth * Math.cos(rt * Math.PI / 180) + textHeight * Math.sin(rt * Math.PI / 180);
749
+ var height = textWidth * Math.sin(rt * Math.PI / 180) + textHeight * Math.cos(rt * Math.PI / 180);
750
+ var lastWord = str.substr(str.length - 1, 1);
751
+ if (lastWord === " " || checkWordByteLength(lastWord) === 2) {
752
+ spaceOrTwoByte = {
753
+ index: i,
754
+ str: str,
755
+ width: width,
756
+ height: height,
757
+ asc: measureText.actualBoundingBoxAscent,
758
+ desc: measureText.actualBoundingBoxDescent
759
+ };
760
+ }
761
+ if (rt !== 0) {
762
+ if (height + space_height > cellHeight && !_.isNil(text_all_split[splitIndex])) {
763
+ if (!_.isNil(spaceOrTwoByte) && spaceOrTwoByte.index < i) {
764
+ anchor = spaceOrTwoByte.index;
765
+ i = spaceOrTwoByte.index + 1;
766
+ text_all_split[splitIndex].push({
767
+ content: spaceOrTwoByte.str,
768
+ style: fontset,
769
+ width: spaceOrTwoByte.width,
770
+ height: spaceOrTwoByte.height,
771
+ left: 0,
772
+ top: 0,
773
+ splitIndex: splitIndex,
774
+ asc: spaceOrTwoByte.asc,
775
+ desc: spaceOrTwoByte.desc,
776
+ fs: fontSize
777
+ });
778
+ splitIndex += 1;
779
+ spaceOrTwoByte = null;
780
+ } else {
781
+ anchor = i - 1;
782
+ text_all_split[splitIndex].push({
783
+ content: preStr,
784
+ style: fontset,
785
+ left: 0,
786
+ top: 0,
787
+ splitIndex: splitIndex,
788
+ height: preTextHeight,
789
+ width: preTextWidth,
790
+ asc: measureText.actualBoundingBoxAscent,
791
+ desc: measureText.actualBoundingBoxDescent,
792
+ fs: fontSize
793
+ });
794
+ splitIndex += 1;
795
+ }
796
+ } else if (i === value.length) {
797
+ if (_.isNil(text_all_split[splitIndex])) {
798
+ text_all_split[splitIndex] = [];
799
+ }
800
+ text_all_split[splitIndex].push({
801
+ content: str,
802
+ style: fontset,
803
+ left: 0,
804
+ top: 0,
805
+ splitIndex: splitIndex,
806
+ height: textHeight,
807
+ width: textWidth,
808
+ asc: measureText.actualBoundingBoxAscent,
809
+ desc: measureText.actualBoundingBoxDescent,
810
+ fs: fontSize
811
+ });
812
+ break;
813
+ } else {
814
+ if (_.isNil(text_all_split[splitIndex])) {
815
+ text_all_split[splitIndex] = [];
816
+ }
817
+ i += 1;
818
+ }
819
+ } else {
820
+ if (width + space_width > cellWidth && !_.isNil(text_all_split[splitIndex])) {
821
+ if (!_.isNil(spaceOrTwoByte) && spaceOrTwoByte.index < i) {
822
+ anchor = spaceOrTwoByte.index;
823
+ i = spaceOrTwoByte.index + 1;
824
+ text_all_split[splitIndex].push({
825
+ content: spaceOrTwoByte.str,
826
+ style: fontset,
827
+ width: spaceOrTwoByte.width,
828
+ height: spaceOrTwoByte.height,
829
+ left: 0,
830
+ top: 0,
831
+ splitIndex: splitIndex,
832
+ asc: spaceOrTwoByte.asc,
833
+ desc: spaceOrTwoByte.desc,
834
+ fs: fontSize
835
+ });
836
+ splitIndex += 1;
837
+ spaceOrTwoByte = null;
838
+ } else {
839
+ spaceOrTwoByte = null;
840
+ anchor = i - 1;
841
+ text_all_split[splitIndex].push({
842
+ content: preStr,
843
+ style: fontset,
844
+ width: preTextWidth,
845
+ height: preTextHeight,
846
+ left: 0,
847
+ top: 0,
848
+ splitIndex: splitIndex,
849
+ asc: preMeasureText.actualBoundingBoxAscent,
850
+ desc: preMeasureText.actualBoundingBoxDescent,
851
+ fs: fontSize
852
+ });
853
+ splitIndex += 1;
854
+ }
855
+ } else if (i === value.length) {
856
+ if (_.isNil(text_all_split[splitIndex])) {
857
+ text_all_split[splitIndex] = [];
858
+ }
859
+ text_all_split[splitIndex].push({
860
+ content: str,
861
+ style: fontset,
862
+ width: textWidth,
863
+ height: textHeight,
864
+ left: 0,
865
+ top: 0,
866
+ splitIndex: splitIndex,
867
+ asc: measureText.actualBoundingBoxAscent,
868
+ desc: measureText.actualBoundingBoxDescent,
869
+ fs: fontSize
870
+ });
871
+ break;
872
+ } else {
873
+ if (_.isNil(text_all_split[splitIndex])) {
874
+ text_all_split[splitIndex] = [];
875
+ }
876
+ i += 1;
877
+ }
878
+ }
879
+ preStr = str;
880
+ preTextHeight = textHeight;
881
+ preTextWidth = textWidth;
882
+ preMeasureText = measureText;
883
+ }
884
+ }
885
+ var split_all_size = [];
886
+ var oneLinemaxWordCount = 0;
887
+ var splitLen = Object.keys(text_all_split).length;
888
+ if (splitLen === 0) return textContent;
889
+ for (var j = 0; j < splitLen; j += 1) {
890
+ var splitLists = text_all_split[j];
891
+ if (_.isNil(splitLists)) {
892
+ continue;
893
+ }
894
+ var sWidth = 0;
895
+ var sHeight = 0;
896
+ var maxDesc = 0;
897
+ var maxAsc = 0;
898
+ var lineHeight = 0;
899
+ var maxWordCount = 0;
900
+ for (var s = 0; s < splitLists.length; s += 1) {
901
+ var sp = splitLists[s];
902
+ if (rt !== 0) {
903
+ sWidth += sp.width;
904
+ sHeight = Math.max(sHeight, sp.height - (supportBoundBox ? sp.desc : 0));
905
+ } else {
906
+ sWidth += sp.width;
907
+ sHeight = Math.max(sHeight, sp.height - (supportBoundBox ? sp.desc : 0));
908
+ }
909
+ maxDesc = Math.max(maxDesc, supportBoundBox ? sp.desc : 0);
910
+ maxAsc = Math.max(maxAsc, sp.asc);
911
+ maxWordCount += 1;
912
+ }
913
+ lineHeight = sHeight / 2;
914
+ oneLinemaxWordCount = Math.max(oneLinemaxWordCount, maxWordCount);
915
+ if (rt !== 0) {
916
+ sHeight += lineHeight;
917
+ textW_all_inner = Math.max(textW_all_inner, sWidth);
918
+ textH_all += sHeight;
919
+ } else {
920
+ sHeight += lineHeight;
921
+ textW_all = Math.max(textW_all, sWidth);
922
+ textH_all += sHeight;
923
+ }
924
+ split_all_size.push({
925
+ width: sWidth,
926
+ height: sHeight,
927
+ desc: maxDesc,
928
+ asc: maxAsc,
929
+ lineHeight: lineHeight,
930
+ wordCount: maxWordCount
931
+ });
932
+ }
933
+ var cumWordHeight = 0;
934
+ var cumColumnWidth = 0;
935
+ var rtPI = rt * Math.PI / 180;
936
+ var lastLine = split_all_size[splitLen - 1];
937
+ var lastLineSpaceHeight = lastLine.lineHeight;
938
+ textH_all = textH_all - lastLineSpaceHeight + lastLine.desc;
939
+ var rw = textH_all / Math.sin(rtPI) + textW_all_inner * Math.cos(rtPI);
940
+ var rh = textW_all_inner * Math.sin(rtPI);
941
+ var fixOneLineLeft = 0;
942
+ if (rt !== 0) {
943
+ if (splitLen === 1) {
944
+ textW_all = textW_all_inner + 2 * (textH_all / Math.tan(rtPI));
945
+ fixOneLineLeft = textH_all / Math.tan(rtPI);
946
+ } else {
947
+ textW_all = textW_all_inner + textH_all / Math.tan(rtPI);
948
+ }
949
+ textContent.textWidthAll = rw;
950
+ textContent.textHeightAll = rh;
951
+ } else {
952
+ textContent.textWidthAll = textW_all;
953
+ textContent.textHeightAll = textH_all;
954
+ }
955
+ if (isMode === "onlyWidth") {
956
+ return textContent;
957
+ }
958
+ if (rt !== 0 && Number(isRotateUp) === 1) {
959
+ renderCtx.textAlign = "end";
960
+ for (var j = 0; j < splitLen; j += 1) {
961
+ var splitLists = text_all_split[j];
962
+ if (_.isNil(splitLists)) {
963
+ continue;
964
+ }
965
+ var size = split_all_size[j];
966
+ cumColumnWidth = 0;
967
+ for (var c = splitLists.length - 1; c >= 0; c -= 1) {
968
+ var wordGroup = splitLists[c];
969
+ var left = void 0;
970
+ var top_2 = void 0;
971
+ if (rt !== 0) {
972
+ var y = cumWordHeight + size.asc;
973
+ var x = cumWordHeight / Math.tan(rtPI) - cumColumnWidth + textW_all_inner;
974
+ if (horizonAlign === "0") {
975
+ if (verticalAlign === "0") {
976
+ left = x + cellWidth / 2 - textW_all / 2 + lastLineSpaceHeight * Math.cos(rtPI) / 2;
977
+ top_2 = y + cellHeight / 2 - textH_all / 2 - lastLineSpaceHeight * Math.cos(rtPI) / 2;
978
+ } else if (verticalAlign === "1") {
979
+ left = x + cellWidth / 2 - textW_all / 2;
980
+ top_2 = y - (textH_all / 2 - rh / 2);
981
+ } else if (verticalAlign === "2") {
982
+ left = x + cellWidth / 2 - textW_all / 2 + lastLineSpaceHeight * Math.cos(rtPI);
983
+ top_2 = y + cellHeight - rh / 2 - textH_all / 2 - lastLineSpaceHeight * Math.cos(rtPI);
984
+ }
985
+ } else if (horizonAlign === "1") {
986
+ if (verticalAlign === "0") {
987
+ left = x - rh * Math.sin(rtPI) / 2 + lastLineSpaceHeight * Math.cos(rtPI) / 2;
988
+ top_2 = y + cellHeight / 2 + rh * Math.cos(rtPI) / 2 - lastLineSpaceHeight * Math.cos(rtPI) / 2;
989
+ } else if (verticalAlign === "1") {
990
+ left = x - rh * Math.sin(rtPI);
991
+ top_2 = y + rh * Math.cos(rtPI);
992
+ } else if (verticalAlign === "2") {
993
+ left = x + lastLineSpaceHeight * Math.cos(rtPI);
994
+ top_2 = y + cellHeight - lastLineSpaceHeight * Math.cos(rtPI);
995
+ }
996
+ } else if (horizonAlign === "2") {
997
+ if (verticalAlign === "0") {
998
+ left = x + cellWidth - rw / 2 - (textW_all_inner / 2 + textH_all / 2 / Math.tan(rtPI)) + lastLineSpaceHeight * Math.cos(rtPI) / 2;
999
+ top_2 = y + cellHeight / 2 - textH_all / 2 - lastLineSpaceHeight * Math.cos(rtPI) / 2;
1000
+ } else if (verticalAlign === "1") {
1001
+ left = x + cellWidth - textW_all + fixOneLineLeft;
1002
+ top_2 = y - textH_all;
1003
+ } else if (verticalAlign === "2") {
1004
+ left = x + cellWidth - rw * Math.cos(rtPI) + lastLineSpaceHeight * Math.cos(rtPI);
1005
+ top_2 = y + cellHeight - rw * Math.sin(rtPI) - lastLineSpaceHeight * Math.cos(rtPI);
1006
+ }
1007
+ }
1008
+ }
1009
+ wordGroup.left = left;
1010
+ wordGroup.top = top_2;
1011
+ drawLineInfo(wordGroup, cancelLine, underLine, {
1012
+ width: wordGroup.width,
1013
+ height: wordGroup.height,
1014
+ left: (left || 0) - wordGroup.width,
1015
+ top: top_2,
1016
+ asc: size.asc,
1017
+ desc: size.desc,
1018
+ fs: wordGroup.fs
1019
+ });
1020
+ textContent.values.push(wordGroup);
1021
+ cumColumnWidth += wordGroup.width;
1022
+ }
1023
+ cumWordHeight += size.height;
1024
+ }
1025
+ } else {
1026
+ for (var j = 0; j < splitLen; j += 1) {
1027
+ var splitLists = text_all_split[j];
1028
+ if (_.isNil(splitLists)) {
1029
+ continue;
1030
+ }
1031
+ var size = split_all_size[j];
1032
+ cumColumnWidth = 0;
1033
+ for (var c = 0; c < splitLists.length; c += 1) {
1034
+ var wordGroup = splitLists[c];
1035
+ var left = void 0;
1036
+ var top_3 = void 0;
1037
+ if (rt !== 0) {
1038
+ var y = cumWordHeight + size.asc;
1039
+ var x = (textH_all - cumWordHeight) / Math.tan(rtPI) + cumColumnWidth;
1040
+ if (horizonAlign === "0") {
1041
+ if (verticalAlign === "0") {
1042
+ left = x + cellWidth / 2 - textW_all / 2 - lastLineSpaceHeight * Math.cos(rtPI) / 2;
1043
+ top_3 = y + cellHeight / 2 - textH_all / 2 + lastLineSpaceHeight * Math.cos(rtPI) / 2;
1044
+ } else if (verticalAlign === "1") {
1045
+ left = x + cellWidth / 2 - textW_all / 2 - lastLineSpaceHeight * Math.cos(rtPI) / 2;
1046
+ top_3 = y - (textH_all / 2 - rh / 2) + lastLineSpaceHeight * Math.cos(rtPI) / 2;
1047
+ } else if (verticalAlign === "2") {
1048
+ left = x + cellWidth / 2 - textW_all / 2 - lastLineSpaceHeight * Math.cos(rtPI);
1049
+ top_3 = y + cellHeight - rh / 2 - textH_all / 2 - lastLineSpaceHeight * Math.cos(rtPI);
1050
+ }
1051
+ } else if (horizonAlign === "1") {
1052
+ if (verticalAlign === "0") {
1053
+ left = x - rh * Math.sin(rtPI) / 2 - lastLineSpaceHeight * Math.cos(rtPI) / 2;
1054
+ top_3 = y - textH_all + cellHeight / 2 - rh * Math.cos(rtPI) / 2 - lastLineSpaceHeight * Math.cos(rtPI) / 2;
1055
+ } else if (verticalAlign === "1") {
1056
+ left = x;
1057
+ top_3 = y - textH_all;
1058
+ } else if (verticalAlign === "2") {
1059
+ left = x - rh * Math.sin(rtPI) - lastLineSpaceHeight * Math.cos(rtPI);
1060
+ top_3 = y - textH_all + cellHeight - rh * Math.cos(rtPI) - lastLineSpaceHeight * Math.cos(rtPI);
1061
+ }
1062
+ } else if (horizonAlign === "2") {
1063
+ if (verticalAlign === "0") {
1064
+ left = x + cellWidth - rw / 2 - textW_all / 2 - lastLineSpaceHeight * Math.cos(rtPI) / 2;
1065
+ top_3 = y + cellHeight / 2 - textH_all / 2 - lastLineSpaceHeight * Math.cos(rtPI) / 2;
1066
+ } else if (verticalAlign === "1") {
1067
+ left = x + cellWidth - rw * Math.cos(rtPI);
1068
+ top_3 = y + rh * Math.cos(rtPI);
1069
+ } else if (verticalAlign === "2") {
1070
+ left = x + cellWidth - textW_all - lastLineSpaceHeight * Math.cos(rtPI) + fixOneLineLeft;
1071
+ top_3 = y + cellHeight - lastLineSpaceHeight * Math.cos(rtPI);
1072
+ }
1073
+ }
1074
+ drawLineInfo(wordGroup, cancelLine, underLine, {
1075
+ width: wordGroup.width,
1076
+ height: wordGroup.height,
1077
+ left: left,
1078
+ top: top_3,
1079
+ asc: size.asc,
1080
+ desc: size.desc,
1081
+ fs: wordGroup.fs
1082
+ });
1083
+ } else {
1084
+ left = space_width + cumColumnWidth;
1085
+ if (horizonAlign === "0") {
1086
+ left = cellWidth / 2 + cumColumnWidth - size.width / 2;
1087
+ } else if (horizonAlign === "2") {
1088
+ left = cellWidth + cumColumnWidth - size.width;
1089
+ }
1090
+ top_3 = cellHeight - space_height + cumWordHeight + size.asc - textH_all;
1091
+ if (verticalAlign === "0") {
1092
+ top_3 = cellHeight / 2 + cumWordHeight - textH_all / 2 + size.asc;
1093
+ } else if (verticalAlign === "1") {
1094
+ top_3 = space_height + cumWordHeight + size.asc;
1095
+ }
1096
+ drawLineInfo(wordGroup, cancelLine, underLine, {
1097
+ width: wordGroup.width,
1098
+ height: wordGroup.height,
1099
+ left: left,
1100
+ top: top_3,
1101
+ asc: size.asc,
1102
+ desc: size.desc,
1103
+ fs: wordGroup.fs
1104
+ });
1105
+ }
1106
+ wordGroup.left = left;
1107
+ wordGroup.top = top_3;
1108
+ textContent.values.push(wordGroup);
1109
+ cumColumnWidth += wordGroup.width;
1110
+ }
1111
+ cumWordHeight += size.height;
1112
+ }
1113
+ }
1114
+ textContent.type = "plainWrap";
1115
+ if (rt !== 0) {
1116
+ if (horizonAlign === "0") {
1117
+ textContent.textLeftAll = cellWidth / 2;
1118
+ if (verticalAlign === "0") {
1119
+ textContent.textTopAll = cellHeight / 2;
1120
+ } else if (verticalAlign === "1") {
1121
+ textContent.textTopAll = rh / 2;
1122
+ } else if (verticalAlign === "2") {
1123
+ textContent.textTopAll = cellHeight - rh / 2;
1124
+ }
1125
+ } else if (horizonAlign === "1") {
1126
+ if (verticalAlign === "0") {
1127
+ textContent.textLeftAll = 0;
1128
+ textContent.textTopAll = cellHeight / 2;
1129
+ } else if (verticalAlign === "1") {
1130
+ textContent.textLeftAll = 0;
1131
+ textContent.textTopAll = 0;
1132
+ } else if (verticalAlign === "2") {
1133
+ textContent.textLeftAll = 0;
1134
+ textContent.textTopAll = cellHeight;
1135
+ }
1136
+ } else if (horizonAlign === "2") {
1137
+ if (verticalAlign === "0") {
1138
+ textContent.textLeftAll = cellWidth - rw / 2;
1139
+ textContent.textTopAll = cellHeight / 2;
1140
+ } else if (verticalAlign === "1") {
1141
+ textContent.textLeftAll = cellWidth;
1142
+ textContent.textTopAll = 0;
1143
+ } else if (verticalAlign === "2") {
1144
+ textContent.textLeftAll = cellWidth;
1145
+ textContent.textTopAll = cellHeight;
1146
+ }
1147
+ }
1148
+ }
1149
+ } else {
1150
+ var measureText = getMeasureText(value, renderCtx, sheetCtx);
1151
+ var textWidth = measureText.width;
1152
+ var textHeight = measureText.actualBoundingBoxDescent + measureText.actualBoundingBoxAscent;
1153
+ textContent.rotate = rt;
1154
+ rt = Math.abs(rt);
1155
+ var rtPI = rt * Math.PI / 180;
1156
+ var textWidthAll = textWidth * Math.cos(rtPI) + textHeight * Math.sin(rtPI);
1157
+ var textHeightAll = textWidth * Math.sin(rtPI) + textHeight * Math.cos(rtPI);
1158
+ if (rt !== 0) {
1159
+ textContent.textHeightAll = textHeightAll;
1160
+ } else {
1161
+ textContent.textHeightAll = textHeightAll + textHeight / 2 - measureText.actualBoundingBoxDescent - space_height;
1162
+ }
1163
+ textContent.textWidthAll = textWidthAll;
1164
+ if (isMode === "onlyWidth") {
1165
+ return textContent;
1166
+ }
1167
+ var width = textWidthAll;
1168
+ var height = textHeightAll;
1169
+ var left = space_width + textHeight * Math.sin(rtPI) * isRotateUp;
1170
+ if (horizonAlign === "0") {
1171
+ left = cellWidth / 2 - width / 2 + textHeight * Math.sin(rtPI) * isRotateUp;
1172
+ } else if (horizonAlign === "2") {
1173
+ left = cellWidth - space_width - width + textHeight * Math.sin(rtPI) * isRotateUp;
1174
+ }
1175
+ var top_4 = cellHeight - space_height - height + measureText.actualBoundingBoxAscent * Math.cos(rtPI) + textWidth * Math.sin(rtPI) * isRotateUp;
1176
+ if (verticalAlign === "0") {
1177
+ top_4 = cellHeight / 2 - height / 2 + measureText.actualBoundingBoxAscent * Math.cos(rtPI) + textWidth * Math.sin(rtPI) * isRotateUp;
1178
+ } else if (verticalAlign === "1") {
1179
+ top_4 = space_height + measureText.actualBoundingBoxAscent * Math.cos(rtPI) + textWidth * Math.sin(rtPI) * isRotateUp;
1180
+ }
1181
+ textContent.type = "plain";
1182
+ var wordGroup = {
1183
+ content: value,
1184
+ style: fontset,
1185
+ width: width,
1186
+ height: height,
1187
+ left: left,
1188
+ top: top_4
1189
+ };
1190
+ drawLineInfo(wordGroup, cancelLine, underLine, {
1191
+ width: textWidth,
1192
+ height: textHeight,
1193
+ left: left,
1194
+ top: top_4,
1195
+ asc: measureText.actualBoundingBoxAscent,
1196
+ desc: measureText.actualBoundingBoxDescent,
1197
+ fs: fontSize
1198
+ });
1199
+ textContent.values.push(wordGroup);
1200
+ textContent.textLeftAll = left;
1201
+ textContent.textTopAll = top_4;
1202
+ textContent.asc = measureText.actualBoundingBoxAscent;
1203
+ textContent.desc = measureText.actualBoundingBoxDescent;
1204
+ }
1205
+ }
1206
+ return textContent;
1207
+ }