pptx-templates 0.3.9 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (294) hide show
  1. package/AI-INSTRUCTOR.md +46 -3
  2. package/CHANGELOG.md +236 -1
  3. package/README.md +61 -168
  4. package/dist/automizer.d.ts +7 -0
  5. package/dist/automizer.js +168 -176
  6. package/dist/automizer.js.map +1 -1
  7. package/dist/classes/content-type-registry.js +23 -36
  8. package/dist/classes/content-type-registry.js.map +1 -1
  9. package/dist/classes/element-importer.js +130 -148
  10. package/dist/classes/element-importer.js.map +1 -1
  11. package/dist/classes/has-shapes.js +81 -126
  12. package/dist/classes/has-shapes.js.map +1 -1
  13. package/dist/classes/layout.js +47 -67
  14. package/dist/classes/layout.js.map +1 -1
  15. package/dist/classes/master.js +70 -89
  16. package/dist/classes/master.js.map +1 -1
  17. package/dist/classes/placeholder-normalizer.js +48 -37
  18. package/dist/classes/placeholder-normalizer.js.map +1 -1
  19. package/dist/classes/related-content-copier.js +65 -86
  20. package/dist/classes/related-content-copier.js.map +1 -1
  21. package/dist/classes/shape.js +79 -110
  22. package/dist/classes/shape.js.map +1 -1
  23. package/dist/classes/slide-master-remover.js +108 -130
  24. package/dist/classes/slide-master-remover.js.map +1 -1
  25. package/dist/classes/slide-notes-copier.js +24 -41
  26. package/dist/classes/slide-notes-copier.js.map +1 -1
  27. package/dist/classes/slide.js +112 -141
  28. package/dist/classes/slide.js.map +1 -1
  29. package/dist/classes/template.js +82 -117
  30. package/dist/classes/template.js.map +1 -1
  31. package/dist/constants/constants.js.map +1 -1
  32. package/dist/enums/chart-type.js.map +1 -1
  33. package/dist/enums/content-type-map.js.map +1 -1
  34. package/dist/enums/element-type.js.map +1 -1
  35. package/dist/errors.js +5 -5
  36. package/dist/errors.js.map +1 -1
  37. package/dist/extensions/cli/index.js +3 -13
  38. package/dist/extensions/cli/index.js.map +1 -1
  39. package/dist/extensions/hide-slide/index.js +48 -46
  40. package/dist/extensions/hide-slide/index.js.map +1 -1
  41. package/dist/extensions/index.d.ts +13 -3
  42. package/dist/extensions/index.js +3 -1
  43. package/dist/extensions/index.js.map +1 -1
  44. package/dist/extensions/link-scheme/index.d.ts +12 -0
  45. package/dist/extensions/link-scheme/index.js +40 -0
  46. package/dist/extensions/link-scheme/index.js.map +1 -0
  47. package/dist/extensions/master-parts/index.js +36 -49
  48. package/dist/extensions/master-parts/index.js.map +1 -1
  49. package/dist/extensions/pptxgenjs-compat/img-broken-png.js.map +1 -1
  50. package/dist/extensions/pptxgenjs-compat/index.js.map +1 -1
  51. package/dist/extensions/pptxgenjs-compat/svg-fallback.js +56 -70
  52. package/dist/extensions/pptxgenjs-compat/svg-fallback.js.map +1 -1
  53. package/dist/extensions/regexp-escape/index.d.ts +10 -0
  54. package/dist/extensions/regexp-escape/index.js +15 -0
  55. package/dist/extensions/regexp-escape/index.js.map +1 -0
  56. package/dist/extensions/run-merge/index.js +4 -5
  57. package/dist/extensions/run-merge/index.js.map +1 -1
  58. package/dist/extensions/shape-geometry/index.js +33 -11
  59. package/dist/extensions/shape-geometry/index.js.map +1 -1
  60. package/dist/extensions/shape-geometry/presets.d.ts +1 -1
  61. package/dist/extensions/shape-geometry/presets.js.map +1 -1
  62. package/dist/extensions/shape-geometry/types.js.map +1 -1
  63. package/dist/extensions/template-lint/cli.js +71 -49
  64. package/dist/extensions/template-lint/cli.js.map +1 -1
  65. package/dist/extensions/template-lint/config.js +29 -13
  66. package/dist/extensions/template-lint/config.js.map +1 -1
  67. package/dist/extensions/template-lint/data-model.js +17 -20
  68. package/dist/extensions/template-lint/data-model.js.map +1 -1
  69. package/dist/extensions/template-lint/hints.js.map +1 -1
  70. package/dist/extensions/template-lint/index.js.map +1 -1
  71. package/dist/extensions/template-lint/init-cli.d.ts +2 -0
  72. package/dist/extensions/template-lint/init-cli.js +33 -23
  73. package/dist/extensions/template-lint/init-cli.js.map +1 -1
  74. package/dist/extensions/template-lint/lint.d.ts +1 -1
  75. package/dist/extensions/template-lint/lint.js +83 -64
  76. package/dist/extensions/template-lint/lint.js.map +1 -1
  77. package/dist/extensions/template-lint/skeleton.js +5 -6
  78. package/dist/extensions/template-lint/skeleton.js.map +1 -1
  79. package/dist/extensions/template-lint/types.js.map +1 -1
  80. package/dist/extensions/template-lint/usage-cli.js +17 -18
  81. package/dist/extensions/template-lint/usage-cli.js.map +1 -1
  82. package/dist/extensions/template-lint/usage.js +8 -9
  83. package/dist/extensions/template-lint/usage.js.map +1 -1
  84. package/dist/extensions/template-lint/watch.d.ts +2 -0
  85. package/dist/extensions/template-lint/watch.js +52 -7
  86. package/dist/extensions/template-lint/watch.js.map +1 -1
  87. package/dist/extensions/template-logic/clone.d.ts +2 -16
  88. package/dist/extensions/template-logic/clone.js +15 -90
  89. package/dist/extensions/template-logic/clone.js.map +1 -1
  90. package/dist/extensions/template-logic/commands.d.ts +1 -1
  91. package/dist/extensions/template-logic/commands.js +12 -11
  92. package/dist/extensions/template-logic/commands.js.map +1 -1
  93. package/dist/extensions/template-logic/expression.d.ts +15 -2
  94. package/dist/extensions/template-logic/expression.js +143 -63
  95. package/dist/extensions/template-logic/expression.js.map +1 -1
  96. package/dist/extensions/template-logic/images.js +58 -55
  97. package/dist/extensions/template-logic/images.js.map +1 -1
  98. package/dist/extensions/template-logic/index.js +16 -24
  99. package/dist/extensions/template-logic/index.js.map +1 -1
  100. package/dist/extensions/template-logic/list-commands.js +8 -19
  101. package/dist/extensions/template-logic/list-commands.js.map +1 -1
  102. package/dist/extensions/template-logic/renderer.d.ts +9 -0
  103. package/dist/extensions/template-logic/renderer.js +480 -477
  104. package/dist/extensions/template-logic/renderer.js.map +1 -1
  105. package/dist/extensions/template-logic/types.d.ts +8 -1
  106. package/dist/extensions/template-logic/types.js.map +1 -1
  107. package/dist/extensions/template-render/cli.js +34 -22
  108. package/dist/extensions/template-render/cli.js.map +1 -1
  109. package/dist/extensions/template-render/index.js +152 -107
  110. package/dist/extensions/template-render/index.js.map +1 -1
  111. package/dist/extensions/template-render/prune.d.ts +14 -0
  112. package/dist/extensions/template-render/prune.js +131 -0
  113. package/dist/extensions/template-render/prune.js.map +1 -0
  114. package/dist/extensions/template-render/zip-text.d.ts +9 -0
  115. package/dist/extensions/template-render/zip-text.js +27 -0
  116. package/dist/extensions/template-render/zip-text.js.map +1 -0
  117. package/dist/extensions/template-render/zip-writer.d.ts +16 -0
  118. package/dist/extensions/template-render/zip-writer.js +151 -0
  119. package/dist/extensions/template-render/zip-writer.js.map +1 -0
  120. package/dist/extensions/text-flow/flow.js +183 -207
  121. package/dist/extensions/text-flow/flow.js.map +1 -1
  122. package/dist/extensions/text-flow/font-file.d.ts +9 -0
  123. package/dist/extensions/text-flow/font-file.js +40 -22
  124. package/dist/extensions/text-flow/font-file.js.map +1 -1
  125. package/dist/extensions/text-flow/fonts.d.ts +4 -0
  126. package/dist/extensions/text-flow/fonts.js +67 -23
  127. package/dist/extensions/text-flow/fonts.js.map +1 -1
  128. package/dist/extensions/text-flow/index.js.map +1 -1
  129. package/dist/extensions/text-flow/layout.js +8 -9
  130. package/dist/extensions/text-flow/layout.js.map +1 -1
  131. package/dist/extensions/text-flow/slide-styles.js +18 -22
  132. package/dist/extensions/text-flow/slide-styles.js.map +1 -1
  133. package/dist/extensions/text-flow/styles.d.ts +7 -1
  134. package/dist/extensions/text-flow/styles.js +108 -64
  135. package/dist/extensions/text-flow/styles.js.map +1 -1
  136. package/dist/helper/archive/archive-fs.d.ts +11 -0
  137. package/dist/helper/archive/archive-fs.js +195 -142
  138. package/dist/helper/archive/archive-fs.js.map +1 -1
  139. package/dist/helper/archive/archive-jszip.js +101 -125
  140. package/dist/helper/archive/archive-jszip.js.map +1 -1
  141. package/dist/helper/archive/archive.d.ts +6 -0
  142. package/dist/helper/archive/archive.js +21 -30
  143. package/dist/helper/archive/archive.js.map +1 -1
  144. package/dist/helper/archive/jszip-fast-read.d.ts +26 -0
  145. package/dist/helper/archive/jszip-fast-read.js +166 -0
  146. package/dist/helper/archive/jszip-fast-read.js.map +1 -0
  147. package/dist/helper/cell-id-helper.d.ts +1 -0
  148. package/dist/helper/cell-id-helper.js +6 -2
  149. package/dist/helper/cell-id-helper.js.map +1 -1
  150. package/dist/helper/compute-src-rect.js +4 -5
  151. package/dist/helper/compute-src-rect.js.map +1 -1
  152. package/dist/helper/content-tracker.js +86 -114
  153. package/dist/helper/content-tracker.js.map +1 -1
  154. package/dist/helper/count-helper.js +48 -78
  155. package/dist/helper/count-helper.js.map +1 -1
  156. package/dist/helper/css-style-parser.d.ts +1 -1
  157. package/dist/helper/css-style-parser.js +1 -2
  158. package/dist/helper/css-style-parser.js.map +1 -1
  159. package/dist/helper/file-helper.js +30 -48
  160. package/dist/helper/file-helper.js.map +1 -1
  161. package/dist/helper/general-helper.js.map +1 -1
  162. package/dist/helper/generate/generate-pptxgenjs.js +36 -48
  163. package/dist/helper/generate/generate-pptxgenjs.js.map +1 -1
  164. package/dist/helper/html-to-multitext-helper.d.ts +4 -4
  165. package/dist/helper/html-to-multitext-helper.js +46 -23
  166. package/dist/helper/html-to-multitext-helper.js.map +1 -1
  167. package/dist/helper/hyperlink-processor.js +125 -139
  168. package/dist/helper/hyperlink-processor.js.map +1 -1
  169. package/dist/helper/image-dimensions.js.map +1 -1
  170. package/dist/helper/jszip-helper.d.ts +1 -1
  171. package/dist/helper/jszip-helper.js +40 -33
  172. package/dist/helper/jszip-helper.js.map +1 -1
  173. package/dist/helper/layout-index.js +51 -71
  174. package/dist/helper/layout-index.js.map +1 -1
  175. package/dist/helper/logger.js +4 -4
  176. package/dist/helper/logger.js.map +1 -1
  177. package/dist/helper/media-deduplicator.d.ts +24 -0
  178. package/dist/helper/media-deduplicator.js +81 -34
  179. package/dist/helper/media-deduplicator.js.map +1 -1
  180. package/dist/helper/modify-background-helper.js +46 -46
  181. package/dist/helper/modify-background-helper.js.map +1 -1
  182. package/dist/helper/modify-chart-helper.d.ts +1 -1
  183. package/dist/helper/modify-chart-helper.js +597 -591
  184. package/dist/helper/modify-chart-helper.js.map +1 -1
  185. package/dist/helper/modify-cleanup-helper.js +112 -112
  186. package/dist/helper/modify-cleanup-helper.js.map +1 -1
  187. package/dist/helper/modify-color-helper.d.ts +1 -1
  188. package/dist/helper/modify-color-helper.js +53 -53
  189. package/dist/helper/modify-color-helper.js.map +1 -1
  190. package/dist/helper/modify-helper.js +25 -25
  191. package/dist/helper/modify-helper.js.map +1 -1
  192. package/dist/helper/modify-hyperlink-element.js.map +1 -1
  193. package/dist/helper/modify-hyperlink-helper.js +152 -158
  194. package/dist/helper/modify-hyperlink-helper.js.map +1 -1
  195. package/dist/helper/modify-image-helper.d.ts +1 -1
  196. package/dist/helper/modify-image-helper.js +121 -132
  197. package/dist/helper/modify-image-helper.js.map +1 -1
  198. package/dist/helper/modify-presentation-helper.js +137 -154
  199. package/dist/helper/modify-presentation-helper.js.map +1 -1
  200. package/dist/helper/modify-shape-helper.js +262 -262
  201. package/dist/helper/modify-shape-helper.js.map +1 -1
  202. package/dist/helper/modify-table-helper.js +95 -84
  203. package/dist/helper/modify-table-helper.js.map +1 -1
  204. package/dist/helper/modify-text-helper.d.ts +8 -0
  205. package/dist/helper/modify-text-helper.js +202 -190
  206. package/dist/helper/modify-text-helper.js.map +1 -1
  207. package/dist/helper/modify-xml-helper.js +36 -36
  208. package/dist/helper/modify-xml-helper.js.map +1 -1
  209. package/dist/helper/multitext-helper.js +13 -9
  210. package/dist/helper/multitext-helper.js.map +1 -1
  211. package/dist/helper/ppt-paths.js +17 -17
  212. package/dist/helper/ppt-paths.js.map +1 -1
  213. package/dist/helper/shape-type-detector.js +18 -29
  214. package/dist/helper/shape-type-detector.js.map +1 -1
  215. package/dist/helper/text-replace-helper.js +8 -8
  216. package/dist/helper/text-replace-helper.js.map +1 -1
  217. package/dist/helper/xml/lnLRTB.js.map +1 -1
  218. package/dist/helper/xml/prstGeom.js.map +1 -1
  219. package/dist/helper/xml-clone.d.ts +24 -0
  220. package/dist/helper/xml-clone.js +269 -0
  221. package/dist/helper/xml-clone.js.map +1 -0
  222. package/dist/helper/xml-elements.js +17 -20
  223. package/dist/helper/xml-elements.js.map +1 -1
  224. package/dist/helper/xml-find.d.ts +4 -0
  225. package/dist/helper/xml-find.js +48 -0
  226. package/dist/helper/xml-find.js.map +1 -0
  227. package/dist/helper/xml-helper.js +102 -135
  228. package/dist/helper/xml-helper.js.map +1 -1
  229. package/dist/helper/xml-parse-cache.d.ts +31 -0
  230. package/dist/helper/xml-parse-cache.js +71 -0
  231. package/dist/helper/xml-parse-cache.js.map +1 -0
  232. package/dist/helper/xml-placeholder-helper.js +10 -10
  233. package/dist/helper/xml-placeholder-helper.js.map +1 -1
  234. package/dist/helper/xml-pretty-print.js.map +1 -1
  235. package/dist/helper/xml-relationship-helper.js +132 -147
  236. package/dist/helper/xml-relationship-helper.js.map +1 -1
  237. package/dist/helper/xml-serializer.d.ts +2 -0
  238. package/dist/helper/xml-serializer.js +192 -0
  239. package/dist/helper/xml-serializer.js.map +1 -0
  240. package/dist/helper/xml-slide-helper.js +109 -129
  241. package/dist/helper/xml-slide-helper.js.map +1 -1
  242. package/dist/helper/xml-template-helper.js +120 -144
  243. package/dist/helper/xml-template-helper.js.map +1 -1
  244. package/dist/helper/xmldom-sax-patch.js +52 -2
  245. package/dist/helper/xmldom-sax-patch.js.map +1 -1
  246. package/dist/index.d.ts +4 -4
  247. package/dist/index.js +4 -2
  248. package/dist/index.js.map +1 -1
  249. package/dist/interfaces/iarchive.js.map +1 -1
  250. package/dist/interfaces/ichart.js.map +1 -1
  251. package/dist/interfaces/icounter.js.map +1 -1
  252. package/dist/interfaces/igenerator.js.map +1 -1
  253. package/dist/interfaces/iimage.js.map +1 -1
  254. package/dist/interfaces/ilayout.js.map +1 -1
  255. package/dist/interfaces/imaster.js.map +1 -1
  256. package/dist/interfaces/imulti-text.js.map +1 -1
  257. package/dist/interfaces/ipptxgenjs-slide.js.map +1 -1
  258. package/dist/interfaces/ipresentation-props.js.map +1 -1
  259. package/dist/interfaces/ishape-action.js.map +1 -1
  260. package/dist/interfaces/ishape.js.map +1 -1
  261. package/dist/interfaces/islide.js.map +1 -1
  262. package/dist/interfaces/itemplate.js.map +1 -1
  263. package/dist/interfaces/pres-template.js.map +1 -1
  264. package/dist/interfaces/root-pres-template.js.map +1 -1
  265. package/dist/modify/modify-chart.d.ts +4 -4
  266. package/dist/modify/modify-chart.js +35 -23
  267. package/dist/modify/modify-chart.js.map +1 -1
  268. package/dist/modify/modify-table.d.ts +0 -1
  269. package/dist/modify/modify-table.js +19 -27
  270. package/dist/modify/modify-table.js.map +1 -1
  271. package/dist/shapes/chart.js +238 -287
  272. package/dist/shapes/chart.js.map +1 -1
  273. package/dist/shapes/diagram.d.ts +14 -0
  274. package/dist/shapes/diagram.js +167 -103
  275. package/dist/shapes/diagram.js.map +1 -1
  276. package/dist/shapes/generic.js +62 -83
  277. package/dist/shapes/generic.js.map +1 -1
  278. package/dist/shapes/hyperlink.d.ts +0 -1
  279. package/dist/shapes/hyperlink.js +84 -124
  280. package/dist/shapes/hyperlink.js.map +1 -1
  281. package/dist/shapes/image.js +118 -149
  282. package/dist/shapes/image.js.map +1 -1
  283. package/dist/shapes/ole.js +148 -188
  284. package/dist/shapes/ole.js.map +1 -1
  285. package/dist/types/chart-types.js.map +1 -1
  286. package/dist/types/modify-types.js.map +1 -1
  287. package/dist/types/shape-types.js.map +1 -1
  288. package/dist/types/table-types.js.map +1 -1
  289. package/dist/types/types.d.ts +7 -0
  290. package/dist/types/types.js.map +1 -1
  291. package/dist/types/xml-types.js.map +1 -1
  292. package/dist/vendor/pptxgenjs/README.md +8 -3
  293. package/dist/vendor/pptxgenjs/index.js +19 -2
  294. package/package.json +13 -16
@@ -1,13 +1,4 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
12
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
4
  };
@@ -45,120 +36,98 @@ class Chart extends shape_1.Shape {
45
36
  this.styleRelationFiles = {};
46
37
  this.hasWorkbook = true;
47
38
  }
48
- modify(targetTemplate, targetSlideNumber) {
49
- return __awaiter(this, void 0, void 0, function* () {
50
- yield this.prepare(targetTemplate, targetSlideNumber);
51
- yield this.clone();
52
- yield this.replaceIntoSlideTree();
53
- return this;
54
- });
39
+ async modify(targetTemplate, targetSlideNumber) {
40
+ await this.prepare(targetTemplate, targetSlideNumber);
41
+ await this.clone();
42
+ await this.replaceIntoSlideTree();
43
+ return this;
55
44
  }
56
- append(targetTemplate, targetSlideNumber) {
57
- return __awaiter(this, void 0, void 0, function* () {
58
- yield this.prepare(targetTemplate, targetSlideNumber);
59
- yield this.clone();
60
- yield this.appendToSlideTree();
61
- return this;
62
- });
45
+ async append(targetTemplate, targetSlideNumber) {
46
+ await this.prepare(targetTemplate, targetSlideNumber);
47
+ await this.clone();
48
+ await this.appendToSlideTree();
49
+ return this;
63
50
  }
64
- remove(targetTemplate, targetSlideNumber) {
65
- return __awaiter(this, void 0, void 0, function* () {
66
- yield this.prepare(targetTemplate, targetSlideNumber);
67
- yield this.removeFromSlideTree();
68
- return this;
69
- });
51
+ async remove(targetTemplate, targetSlideNumber) {
52
+ await this.prepare(targetTemplate, targetSlideNumber);
53
+ await this.removeFromSlideTree();
54
+ return this;
70
55
  }
71
- modifyOnAddedSlide(targetTemplate, targetSlideNumber) {
72
- return __awaiter(this, void 0, void 0, function* () {
73
- yield this.prepare(targetTemplate, targetSlideNumber);
74
- yield this.updateElementsRelId();
75
- return this;
76
- });
56
+ async modifyOnAddedSlide(targetTemplate, targetSlideNumber) {
57
+ await this.prepare(targetTemplate, targetSlideNumber);
58
+ await this.updateElementsRelId();
59
+ return this;
77
60
  }
78
- prepare(targetTemplate, targetSlideNumber) {
79
- return __awaiter(this, void 0, void 0, function* () {
80
- yield this.setTarget(targetTemplate, targetSlideNumber);
81
- this.targetNumber = this.targetTemplate.incrementCounter('charts');
82
- this.wbRelsPath = ppt_paths_1.PptPaths.chartPartRels(this.subtype, this.sourceNumber);
83
- yield this.copyFiles();
84
- yield this.copyChartStyleFiles();
85
- yield this.appendTypes();
86
- yield this.appendToSlideRels();
87
- });
61
+ async prepare(targetTemplate, targetSlideNumber) {
62
+ await this.setTarget(targetTemplate, targetSlideNumber);
63
+ this.targetNumber = this.targetTemplate.incrementCounter('charts');
64
+ this.wbRelsPath = ppt_paths_1.PptPaths.chartPartRels(this.subtype, this.sourceNumber);
65
+ await this.copyFiles();
66
+ await this.copyChartStyleFiles();
67
+ await this.appendTypes();
68
+ await this.appendToSlideRels();
88
69
  }
89
- clone() {
90
- return __awaiter(this, void 0, void 0, function* () {
91
- yield this.setTargetElement();
92
- yield this.modifyChartData();
93
- yield this.updateTargetElementRelId();
94
- });
70
+ async clone() {
71
+ await this.setTargetElement();
72
+ await this.modifyChartData();
73
+ await this.updateTargetElementRelId();
95
74
  }
96
- modifyChartData() {
97
- return __awaiter(this, void 0, void 0, function* () {
98
- if (!this.hasWorkbook) {
99
- return;
100
- }
101
- const chartXml = yield xml_helper_1.XmlHelper.getXmlFromArchive(this.targetArchive, ppt_paths_1.PptPaths.chartPart(this.subtype, this.targetNumber));
102
- const workbook = yield this.readWorkbook();
103
- this.applyChartCallbacks(this.callbacks, this.targetElement, chartXml, workbook);
104
- xml_helper_1.XmlHelper.writeXmlToArchive(this.targetArchive, ppt_paths_1.PptPaths.chartPart(this.subtype, this.targetNumber), chartXml);
105
- yield this.writeWorkbook(workbook);
106
- });
75
+ async modifyChartData() {
76
+ if (!this.hasWorkbook) {
77
+ return;
78
+ }
79
+ const chartXml = await xml_helper_1.XmlHelper.getXmlFromArchive(this.targetArchive, ppt_paths_1.PptPaths.chartPart(this.subtype, this.targetNumber));
80
+ const workbook = await this.readWorkbook();
81
+ this.applyChartCallbacks(this.callbacks, this.targetElement, chartXml, workbook);
82
+ xml_helper_1.XmlHelper.writeXmlToArchive(this.targetArchive, ppt_paths_1.PptPaths.chartPart(this.subtype, this.targetNumber), chartXml);
83
+ await this.writeWorkbook(workbook);
107
84
  }
108
- readWorkbook() {
109
- return __awaiter(this, void 0, void 0, function* () {
110
- const workbookFilename = ppt_paths_1.PptPaths.embedding(`${this.worksheetFilePrefix}${this.targetWorksheet}${this.wbExtension}`);
111
- const archive = yield this.targetArchive.extract(workbookFilename);
112
- const sheet = yield xml_helper_1.XmlHelper.getXmlFromArchive(archive, 'xl/worksheets/sheet1.xml');
113
- const table = file_helper_1.FileHelper.fileExistsInArchive(archive, 'xl/tables/table1.xml')
114
- ? yield xml_helper_1.XmlHelper.getXmlFromArchive(archive, 'xl/tables/table1.xml')
115
- : undefined;
116
- const sharedStrings = yield xml_helper_1.XmlHelper.getXmlFromArchive(archive, 'xl/sharedStrings.xml');
117
- return {
118
- archive,
119
- sheet,
120
- sharedStrings,
121
- table,
122
- };
123
- });
85
+ async readWorkbook() {
86
+ const workbookFilename = ppt_paths_1.PptPaths.embedding(`${this.worksheetFilePrefix}${this.targetWorksheet}${this.wbExtension}`);
87
+ const archive = await this.targetArchive.extract(workbookFilename);
88
+ const sheet = await xml_helper_1.XmlHelper.getXmlFromArchive(archive, 'xl/worksheets/sheet1.xml');
89
+ const table = file_helper_1.FileHelper.fileExistsInArchive(archive, 'xl/tables/table1.xml')
90
+ ? await xml_helper_1.XmlHelper.getXmlFromArchive(archive, 'xl/tables/table1.xml')
91
+ : undefined;
92
+ const sharedStrings = await xml_helper_1.XmlHelper.getXmlFromArchive(archive, 'xl/sharedStrings.xml');
93
+ return {
94
+ archive,
95
+ sheet,
96
+ sharedStrings,
97
+ table,
98
+ };
124
99
  }
125
- writeWorkbook(workbook) {
126
- return __awaiter(this, void 0, void 0, function* () {
127
- xml_helper_1.XmlHelper.writeXmlToArchive(workbook.archive, 'xl/worksheets/sheet1.xml', workbook.sheet);
128
- if (workbook.table) {
129
- xml_helper_1.XmlHelper.writeXmlToArchive(workbook.archive, 'xl/tables/table1.xml', workbook.table);
130
- }
131
- xml_helper_1.XmlHelper.writeXmlToArchive(workbook.archive, 'xl/sharedStrings.xml', workbook.sharedStrings);
132
- const worksheet = yield workbook.archive.getContent({});
133
- yield this.targetArchive.write(ppt_paths_1.PptPaths.embedding(`${this.worksheetFilePrefix}${this.targetWorksheet}${this.wbExtension}`), worksheet);
134
- });
100
+ async writeWorkbook(workbook) {
101
+ xml_helper_1.XmlHelper.writeXmlToArchive(workbook.archive, 'xl/worksheets/sheet1.xml', workbook.sheet);
102
+ if (workbook.table) {
103
+ xml_helper_1.XmlHelper.writeXmlToArchive(workbook.archive, 'xl/tables/table1.xml', workbook.table);
104
+ }
105
+ xml_helper_1.XmlHelper.writeXmlToArchive(workbook.archive, 'xl/sharedStrings.xml', workbook.sharedStrings);
106
+ const worksheet = await workbook.archive.getContent({});
107
+ await this.targetArchive.write(ppt_paths_1.PptPaths.embedding(`${this.worksheetFilePrefix}${this.targetWorksheet}${this.wbExtension}`), worksheet);
135
108
  }
136
- copyFiles() {
137
- return __awaiter(this, void 0, void 0, function* () {
138
- yield this.copyChartFiles();
139
- this.worksheetFilePrefix = yield this.getWorksheetFilePrefix(this.wbRelsPath);
140
- if (this.hasWorkbook) {
141
- const worksheets = yield xml_relationship_helper_1.XmlRelationshipHelper.getRelationshipTargetsByPrefix(this.sourceArchive, this.wbRelsPath, `${this.wbEmbeddingsPath}${this.worksheetFilePrefix}`);
142
- const worksheet = worksheets[0];
143
- this.sourceWorksheet = worksheet.number === 0 ? '' : worksheet.number;
144
- this.targetWorksheet = '-created-' + this.targetNumber;
145
- yield this.copyWorksheetFile();
146
- }
147
- else {
148
- logger_1.log.info('Chart has no worksheet: ' + this.wbRelsPath);
149
- }
150
- yield this.editTargetWorksheetRel();
151
- });
109
+ async copyFiles() {
110
+ await this.copyChartFiles();
111
+ this.worksheetFilePrefix = await this.getWorksheetFilePrefix(this.wbRelsPath);
112
+ if (this.hasWorkbook) {
113
+ const worksheets = await xml_relationship_helper_1.XmlRelationshipHelper.getRelationshipTargetsByPrefix(this.sourceArchive, this.wbRelsPath, `${this.wbEmbeddingsPath}${this.worksheetFilePrefix}`);
114
+ const worksheet = worksheets[0];
115
+ this.sourceWorksheet = worksheet.number === 0 ? '' : worksheet.number;
116
+ this.targetWorksheet = '-created-' + this.targetNumber;
117
+ await this.copyWorksheetFile();
118
+ }
119
+ else {
120
+ logger_1.log.info('Chart has no worksheet: ' + this.wbRelsPath);
121
+ }
122
+ await this.editTargetWorksheetRel();
152
123
  }
153
- getWorksheetFilePrefix(targetRelFile) {
154
- return __awaiter(this, void 0, void 0, function* () {
155
- const relationTargets = yield xml_relationship_helper_1.XmlRelationshipHelper.getRelationshipTargetsByPrefix(this.sourceArchive, targetRelFile, this.wbEmbeddingsPath);
156
- if (!relationTargets[0]) {
157
- this.hasWorkbook = false;
158
- return '';
159
- }
160
- return relationTargets[0].filenameBase;
161
- });
124
+ async getWorksheetFilePrefix(targetRelFile) {
125
+ const relationTargets = await xml_relationship_helper_1.XmlRelationshipHelper.getRelationshipTargetsByPrefix(this.sourceArchive, targetRelFile, this.wbEmbeddingsPath);
126
+ if (!relationTargets[0]) {
127
+ this.hasWorkbook = false;
128
+ return '';
129
+ }
130
+ return relationTargets[0].filenameBase;
162
131
  }
163
132
  /**
164
133
  * Registers the copied chart parts in `[Content_Types].xml`.
@@ -170,65 +139,57 @@ class Chart extends shape_1.Shape {
170
139
  * orphan. `prepare` runs `copyChartStyleFiles` first, so the relations are
171
140
  * known here.
172
141
  */
173
- appendTypes() {
174
- return __awaiter(this, void 0, void 0, function* () {
175
- if (this.hasWorkbook) {
176
- yield this.appendChartExtensionToContentType();
177
- }
178
- yield this.appendChartToContentType();
179
- if (this.hasStyleRelation('relTypeChartUserShapes')) {
180
- yield this.appendChartUserShapesToContentType();
181
- }
182
- if (this.hasStyleRelation('relTypeChartColorStyle')) {
183
- yield this.appendColorToContentType();
184
- }
185
- if (this.hasStyleRelation('relTypeChartStyle')) {
186
- yield this.appendStyleToContentType();
187
- }
188
- if (this.hasStyleRelation('relTypeChartThemeOverride')) {
189
- yield this.appendThemeOverrideToContentType();
190
- }
191
- });
142
+ async appendTypes() {
143
+ if (this.hasWorkbook) {
144
+ await this.appendChartExtensionToContentType();
145
+ }
146
+ await this.appendChartToContentType();
147
+ if (this.hasStyleRelation('relTypeChartUserShapes')) {
148
+ await this.appendChartUserShapesToContentType();
149
+ }
150
+ if (this.hasStyleRelation('relTypeChartColorStyle')) {
151
+ await this.appendColorToContentType();
152
+ }
153
+ if (this.hasStyleRelation('relTypeChartStyle')) {
154
+ await this.appendStyleToContentType();
155
+ }
156
+ if (this.hasStyleRelation('relTypeChartThemeOverride')) {
157
+ await this.appendThemeOverrideToContentType();
158
+ }
192
159
  }
193
160
  hasStyleRelation(styleType) {
194
- var _a;
195
- return ((_a = this.styleRelationFiles[styleType]) === null || _a === void 0 ? void 0 : _a.length) > 0;
161
+ return this.styleRelationFiles[styleType]?.length > 0;
196
162
  }
197
- copyChartFiles() {
198
- return __awaiter(this, void 0, void 0, function* () {
199
- yield file_helper_1.FileHelper.zipCopy(this.sourceArchive, ppt_paths_1.PptPaths.chartPart(this.subtype, this.sourceNumber), this.targetArchive, ppt_paths_1.PptPaths.chartPart(this.subtype, this.targetNumber));
200
- yield file_helper_1.FileHelper.zipCopy(this.sourceArchive, ppt_paths_1.PptPaths.chartPartRels(this.subtype, this.sourceNumber), this.targetArchive, ppt_paths_1.PptPaths.chartPartRels(this.subtype, this.targetNumber));
201
- });
163
+ async copyChartFiles() {
164
+ await file_helper_1.FileHelper.zipCopy(this.sourceArchive, ppt_paths_1.PptPaths.chartPart(this.subtype, this.sourceNumber), this.targetArchive, ppt_paths_1.PptPaths.chartPart(this.subtype, this.targetNumber));
165
+ await file_helper_1.FileHelper.zipCopy(this.sourceArchive, ppt_paths_1.PptPaths.chartPartRels(this.subtype, this.sourceNumber), this.targetArchive, ppt_paths_1.PptPaths.chartPartRels(this.subtype, this.targetNumber));
202
166
  }
203
- copyChartStyleFiles() {
204
- return __awaiter(this, void 0, void 0, function* () {
205
- var _a, _b, _c, _d;
206
- yield this.getChartStyles();
207
- if ((_a = this.styleRelationFiles.relTypeChartStyle) === null || _a === void 0 ? void 0 : _a.length) {
208
- yield file_helper_1.FileHelper.zipCopy(this.sourceArchive, `ppt/charts/${this.styleRelationFiles.relTypeChartStyle[0]}`, this.targetArchive, ppt_paths_1.PptPaths.chartPart('style', this.targetNumber));
209
- }
210
- if ((_b = this.styleRelationFiles.relTypeChartColorStyle) === null || _b === void 0 ? void 0 : _b.length) {
211
- yield file_helper_1.FileHelper.zipCopy(this.sourceArchive, `ppt/charts/${this.styleRelationFiles.relTypeChartColorStyle[0]}`, this.targetArchive, ppt_paths_1.PptPaths.chartPart('colors', this.targetNumber));
212
- }
213
- if (this.styleRelationFiles.relTypeChartImage) {
214
- for (const relTypeChartImage of this.styleRelationFiles
215
- .relTypeChartImage) {
216
- const imageInfo = this.getTargetChartImageUri(relTypeChartImage);
217
- yield this.appendImageExtensionToContentType(imageInfo.extension);
218
- yield file_helper_1.FileHelper.zipCopy(this.sourceArchive, imageInfo.source, this.targetArchive, imageInfo.target);
219
- }
220
- }
221
- if ((_c = this.styleRelationFiles.relTypeChartUserShapes) === null || _c === void 0 ? void 0 : _c.length) {
222
- const sourceFile = this.styleRelationFiles.relTypeChartUserShapes[0].replace('../drawings/', '');
223
- const sourceDrawing = `${ppt_paths_1.PptPaths.drawingsDir}/${sourceFile}`;
224
- yield file_helper_1.FileHelper.zipCopy(this.sourceArchive, sourceDrawing, this.targetArchive, ppt_paths_1.PptPaths.drawing(this.targetNumber));
225
- yield this.copyChartUserShapesRels(sourceDrawing);
167
+ async copyChartStyleFiles() {
168
+ await this.getChartStyles();
169
+ if (this.styleRelationFiles.relTypeChartStyle?.length) {
170
+ await file_helper_1.FileHelper.zipCopy(this.sourceArchive, `ppt/charts/${this.styleRelationFiles.relTypeChartStyle[0]}`, this.targetArchive, ppt_paths_1.PptPaths.chartPart('style', this.targetNumber));
171
+ }
172
+ if (this.styleRelationFiles.relTypeChartColorStyle?.length) {
173
+ await file_helper_1.FileHelper.zipCopy(this.sourceArchive, `ppt/charts/${this.styleRelationFiles.relTypeChartColorStyle[0]}`, this.targetArchive, ppt_paths_1.PptPaths.chartPart('colors', this.targetNumber));
174
+ }
175
+ if (this.styleRelationFiles.relTypeChartImage) {
176
+ for (const relTypeChartImage of this.styleRelationFiles
177
+ .relTypeChartImage) {
178
+ const imageInfo = this.getTargetChartImageUri(relTypeChartImage);
179
+ await this.appendImageExtensionToContentType(imageInfo.extension);
180
+ await file_helper_1.FileHelper.zipCopy(this.sourceArchive, imageInfo.source, this.targetArchive, imageInfo.target);
226
181
  }
227
- if ((_d = this.styleRelationFiles.relTypeChartThemeOverride) === null || _d === void 0 ? void 0 : _d.length) {
228
- const sourceFile = this.styleRelationFiles.relTypeChartThemeOverride[0].replace('../theme/', '');
229
- yield file_helper_1.FileHelper.zipCopy(this.sourceArchive, `ppt/theme/${sourceFile}`, this.targetArchive, `ppt/theme/themeOverride${this.targetNumber}.xml`);
230
- }
231
- });
182
+ }
183
+ if (this.styleRelationFiles.relTypeChartUserShapes?.length) {
184
+ const sourceFile = this.styleRelationFiles.relTypeChartUserShapes[0].replace('../drawings/', '');
185
+ const sourceDrawing = `${ppt_paths_1.PptPaths.drawingsDir}/${sourceFile}`;
186
+ await file_helper_1.FileHelper.zipCopy(this.sourceArchive, sourceDrawing, this.targetArchive, ppt_paths_1.PptPaths.drawing(this.targetNumber));
187
+ await this.copyChartUserShapesRels(sourceDrawing);
188
+ }
189
+ if (this.styleRelationFiles.relTypeChartThemeOverride?.length) {
190
+ const sourceFile = this.styleRelationFiles.relTypeChartThemeOverride[0].replace('../theme/', '');
191
+ await file_helper_1.FileHelper.zipCopy(this.sourceArchive, `ppt/theme/${sourceFile}`, this.targetArchive, `ppt/theme/themeOverride${this.targetNumber}.xml`);
192
+ }
232
193
  }
233
194
  /**
234
195
  * Copies the `_rels` file of a chart's `chartUserShapes` drawing, if it has
@@ -250,116 +211,106 @@ class Chart extends shape_1.Shape {
250
211
  *
251
212
  * @param sourceDrawing Path of the drawing part inside the source archive
252
213
  */
253
- copyChartUserShapesRels(sourceDrawing) {
254
- return __awaiter(this, void 0, void 0, function* () {
255
- var _a;
256
- const sourceRels = ppt_paths_1.PptPaths.relsOf(sourceDrawing);
257
- if (!file_helper_1.FileHelper.fileExistsInArchive(this.sourceArchive, sourceRels)) {
258
- return;
214
+ async copyChartUserShapesRels(sourceDrawing) {
215
+ const sourceRels = ppt_paths_1.PptPaths.relsOf(sourceDrawing);
216
+ if (!file_helper_1.FileHelper.fileExistsInArchive(this.sourceArchive, sourceRels)) {
217
+ return;
218
+ }
219
+ const targetRels = ppt_paths_1.PptPaths.drawingRels(this.targetNumber);
220
+ await file_helper_1.FileHelper.zipCopy(this.sourceArchive, sourceRels, this.targetArchive, targetRels);
221
+ const relsXml = await xml_helper_1.XmlHelper.getXmlFromArchive(this.targetArchive, targetRels);
222
+ const relationships = relsXml.getElementsByTagName('Relationship');
223
+ for (let i = 0; i < relationships.length; i++) {
224
+ const relationship = relationships[i];
225
+ const type = relationship.getAttribute('Type');
226
+ const isExternal = relationship.getAttribute('TargetMode') === 'External';
227
+ if (!isExternal && type === this.relTypeChartImage) {
228
+ const imageInfo = this.getTargetChartImageUri(relationship.getAttribute('Target'));
229
+ await this.appendImageExtensionToContentType(imageInfo.extension);
230
+ await file_helper_1.FileHelper.zipCopy(this.sourceArchive, imageInfo.source, this.targetArchive, imageInfo.target);
231
+ relationship.setAttribute('Target', imageInfo.rel);
259
232
  }
260
- const targetRels = ppt_paths_1.PptPaths.drawingRels(this.targetNumber);
261
- yield file_helper_1.FileHelper.zipCopy(this.sourceArchive, sourceRels, this.targetArchive, targetRels);
262
- const relsXml = yield xml_helper_1.XmlHelper.getXmlFromArchive(this.targetArchive, targetRels);
263
- const relationships = relsXml.getElementsByTagName('Relationship');
264
- for (let i = 0; i < relationships.length; i++) {
265
- const relationship = relationships[i];
266
- const type = relationship.getAttribute('Type');
267
- const isExternal = relationship.getAttribute('TargetMode') === 'External';
268
- if (!isExternal && type === this.relTypeChartImage) {
269
- const imageInfo = this.getTargetChartImageUri(relationship.getAttribute('Target'));
270
- yield this.appendImageExtensionToContentType(imageInfo.extension);
271
- yield file_helper_1.FileHelper.zipCopy(this.sourceArchive, imageInfo.source, this.targetArchive, imageInfo.target);
272
- relationship.setAttribute('Target', imageInfo.rel);
273
- }
274
- else if (!isExternal) {
275
- logger_1.log.warn(`Chart user shapes drawing ${sourceDrawing} relates to ` +
276
- `${relationship.getAttribute('Target')} (${type}); this ` +
277
- `relationship type is copied unchanged and may not resolve in the output.`);
278
- }
279
- (_a = this.targetArchive.contentTracker) === null || _a === void 0 ? void 0 : _a.trackRelation(targetRels, {
280
- Id: relationship.getAttribute('Id'),
281
- Target: relationship.getAttribute('Target'),
282
- Type: type,
283
- });
233
+ else if (!isExternal) {
234
+ logger_1.log.warn(`Chart user shapes drawing ${sourceDrawing} relates to ` +
235
+ `${relationship.getAttribute('Target')} (${type}); this ` +
236
+ `relationship type is copied unchanged and may not resolve in the output.`);
284
237
  }
285
- xml_helper_1.XmlHelper.writeXmlToArchive(this.targetArchive, targetRels, relsXml);
286
- });
238
+ this.targetArchive.contentTracker?.trackRelation(targetRels, {
239
+ Id: relationship.getAttribute('Id'),
240
+ Target: relationship.getAttribute('Target'),
241
+ Type: type,
242
+ });
243
+ }
244
+ xml_helper_1.XmlHelper.writeXmlToArchive(this.targetArchive, targetRels, relsXml);
287
245
  }
288
- getChartStyles() {
289
- return __awaiter(this, void 0, void 0, function* () {
290
- const styleTypes = [
291
- 'relTypeChartStyle',
292
- 'relTypeChartColorStyle',
293
- 'relTypeChartImage',
294
- 'relTypeChartThemeOverride',
295
- 'relTypeChartUserShapes',
296
- ];
297
- for (const i in styleTypes) {
298
- const styleType = styleTypes[i];
299
- const styleRelation = yield xml_relationship_helper_1.XmlRelationshipHelper.getTargetsByRelationshipType(this.sourceArchive, this.wbRelsPath, this[styleType]);
300
- this.styleRelationFiles[styleType] =
301
- this.styleRelationFiles[styleType] || [];
302
- if (styleRelation.length) {
303
- styleRelation.forEach((styleRelation) => {
304
- this.styleRelationFiles[styleType].push(styleRelation.file);
305
- });
306
- }
246
+ async getChartStyles() {
247
+ const styleTypes = [
248
+ 'relTypeChartStyle',
249
+ 'relTypeChartColorStyle',
250
+ 'relTypeChartImage',
251
+ 'relTypeChartThemeOverride',
252
+ 'relTypeChartUserShapes',
253
+ ];
254
+ for (const i in styleTypes) {
255
+ const styleType = styleTypes[i];
256
+ const styleRelation = await xml_relationship_helper_1.XmlRelationshipHelper.getTargetsByRelationshipType(this.sourceArchive, this.wbRelsPath, this[styleType]);
257
+ this.styleRelationFiles[styleType] =
258
+ this.styleRelationFiles[styleType] || [];
259
+ if (styleRelation.length) {
260
+ styleRelation.forEach((styleRelation) => {
261
+ this.styleRelationFiles[styleType].push(styleRelation.file);
262
+ });
307
263
  }
308
- });
264
+ }
309
265
  }
310
- appendToSlideRels() {
311
- return __awaiter(this, void 0, void 0, function* () {
312
- this.createdRid = yield xml_relationship_helper_1.XmlRelationshipHelper.getNextRelId(this.targetArchive, this.targetSlideRelFile);
313
- const type = this.subtype === 'chart'
314
- ? 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart'
315
- : 'http://schemas.microsoft.com/office/2014/relationships/chartEx';
316
- const attributes = {
317
- Id: this.createdRid,
318
- Type: type,
319
- Target: `../charts/${this.subtype}${this.targetNumber}.xml`,
320
- };
321
- return xml_helper_1.XmlHelper.append(xml_relationship_helper_1.XmlRelationshipHelper.createRelationshipChild(this.targetArchive, this.targetSlideRelFile, attributes));
322
- });
266
+ async appendToSlideRels() {
267
+ this.createdRid = await xml_relationship_helper_1.XmlRelationshipHelper.getNextRelId(this.targetArchive, this.targetSlideRelFile);
268
+ const type = this.subtype === 'chart'
269
+ ? 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart'
270
+ : 'http://schemas.microsoft.com/office/2014/relationships/chartEx';
271
+ const attributes = {
272
+ Id: this.createdRid,
273
+ Type: type,
274
+ Target: `../charts/${this.subtype}${this.targetNumber}.xml`,
275
+ };
276
+ return xml_helper_1.XmlHelper.append(xml_relationship_helper_1.XmlRelationshipHelper.createRelationshipChild(this.targetArchive, this.targetSlideRelFile, attributes));
323
277
  }
324
- editTargetWorksheetRel() {
325
- return __awaiter(this, void 0, void 0, function* () {
326
- const targetRelFile = ppt_paths_1.PptPaths.chartPartRels(this.subtype, this.targetNumber);
327
- const relXml = yield xml_helper_1.XmlHelper.getXmlFromArchive(this.targetArchive, targetRelFile);
328
- const relations = relXml.getElementsByTagName('Relationship');
329
- Object.keys(relations)
330
- .map((key) => relations[Number(key)])
331
- .filter((element) => element && element.getAttribute)
332
- .forEach((element) => {
333
- var _a;
334
- const type = element.getAttribute('Type');
335
- switch (type) {
336
- case 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/package':
337
- this.updateTargetWorksheetRelation(targetRelFile, element, 'Target', `${this.wbEmbeddingsPath}${this.worksheetFilePrefix}${this.targetWorksheet}${this.wbExtension}`);
338
- break;
339
- case this.relTypeChartColorStyle:
340
- this.updateTargetWorksheetRelation(targetRelFile, element, 'Target', `colors${this.targetNumber}.xml`);
341
- break;
342
- case this.relTypeChartStyle:
343
- this.updateTargetWorksheetRelation(targetRelFile, element, 'Target', `style${this.targetNumber}.xml`);
344
- break;
345
- case this.relTypeChartImage:
346
- this.updateTargetWorksheetRelation(targetRelFile, element, 'Target', this.getTargetChartImageUri(element.getAttribute('Target')).rel);
347
- break;
348
- case this.relTypeChartThemeOverride:
349
- this.updateTargetWorksheetRelation(targetRelFile, element, 'Target', `../theme/themeOverride${this.targetNumber}.xml`);
350
- break;
351
- case this.relTypeChartUserShapes:
352
- this.updateTargetWorksheetRelation(targetRelFile, element, 'Target', ppt_paths_1.PptPaths.relative.drawing(this.targetNumber));
353
- break;
354
- }
355
- (_a = this.targetArchive.contentTracker) === null || _a === void 0 ? void 0 : _a.trackRelation(targetRelFile, {
356
- Id: element.getAttribute('Id'),
357
- Target: element.getAttribute('Target'),
358
- Type: element.getAttribute('Type'),
359
- });
278
+ async editTargetWorksheetRel() {
279
+ const targetRelFile = ppt_paths_1.PptPaths.chartPartRels(this.subtype, this.targetNumber);
280
+ const relXml = await xml_helper_1.XmlHelper.getXmlFromArchive(this.targetArchive, targetRelFile);
281
+ const relations = relXml.getElementsByTagName('Relationship');
282
+ Object.keys(relations)
283
+ .map((key) => relations[Number(key)])
284
+ .filter((element) => element && element.getAttribute)
285
+ .forEach((element) => {
286
+ const type = element.getAttribute('Type');
287
+ switch (type) {
288
+ case 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/package':
289
+ this.updateTargetWorksheetRelation(targetRelFile, element, 'Target', `${this.wbEmbeddingsPath}${this.worksheetFilePrefix}${this.targetWorksheet}${this.wbExtension}`);
290
+ break;
291
+ case this.relTypeChartColorStyle:
292
+ this.updateTargetWorksheetRelation(targetRelFile, element, 'Target', `colors${this.targetNumber}.xml`);
293
+ break;
294
+ case this.relTypeChartStyle:
295
+ this.updateTargetWorksheetRelation(targetRelFile, element, 'Target', `style${this.targetNumber}.xml`);
296
+ break;
297
+ case this.relTypeChartImage:
298
+ this.updateTargetWorksheetRelation(targetRelFile, element, 'Target', this.getTargetChartImageUri(element.getAttribute('Target')).rel);
299
+ break;
300
+ case this.relTypeChartThemeOverride:
301
+ this.updateTargetWorksheetRelation(targetRelFile, element, 'Target', `../theme/themeOverride${this.targetNumber}.xml`);
302
+ break;
303
+ case this.relTypeChartUserShapes:
304
+ this.updateTargetWorksheetRelation(targetRelFile, element, 'Target', ppt_paths_1.PptPaths.relative.drawing(this.targetNumber));
305
+ break;
306
+ }
307
+ this.targetArchive.contentTracker?.trackRelation(targetRelFile, {
308
+ Id: element.getAttribute('Id'),
309
+ Target: element.getAttribute('Target'),
310
+ Type: element.getAttribute('Type'),
360
311
  });
361
- xml_helper_1.XmlHelper.writeXmlToArchive(this.targetArchive, targetRelFile, relXml);
362
312
  });
313
+ xml_helper_1.XmlHelper.writeXmlToArchive(this.targetArchive, targetRelFile, relXml);
363
314
  }
364
315
  updateTargetWorksheetRelation(targetRelFile, element, attribute, value) {
365
316
  element.setAttribute(attribute, value);
@@ -376,20 +327,22 @@ class Chart extends shape_1.Shape {
376
327
  extension: extension,
377
328
  };
378
329
  }
379
- copyWorksheetFile() {
380
- return __awaiter(this, void 0, void 0, function* () {
381
- const sourceFile = ppt_paths_1.PptPaths.embedding(`${this.worksheetFilePrefix}${this.sourceWorksheet}${this.wbExtension}`);
382
- const targetFile = ppt_paths_1.PptPaths.embedding(`${this.worksheetFilePrefix}${this.targetWorksheet}${this.wbExtension}`);
383
- yield file_helper_1.FileHelper.zipCopy(this.sourceArchive, sourceFile, this.targetArchive, targetFile).catch((e) => {
384
- logger_1.log.warn(e);
385
- });
330
+ async copyWorksheetFile() {
331
+ const sourceFile = ppt_paths_1.PptPaths.embedding(`${this.worksheetFilePrefix}${this.sourceWorksheet}${this.wbExtension}`);
332
+ const targetFile = ppt_paths_1.PptPaths.embedding(`${this.worksheetFilePrefix}${this.targetWorksheet}${this.wbExtension}`);
333
+ await file_helper_1.FileHelper.zipCopy(this.sourceArchive, sourceFile, this.targetArchive, targetFile).catch((e) => {
334
+ logger_1.log.warn(e);
386
335
  });
387
336
  }
388
337
  appendChartExtensionToContentType() {
389
- return xml_helper_1.XmlHelper.appendIf(Object.assign(Object.assign({}, xml_helper_1.XmlHelper.createContentTypeChild(this.targetArchive, {
390
- Extension: `xlsx`,
391
- ContentType: `application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`,
392
- })), { tag: 'Default', clause: (xml) => !xml_helper_1.XmlHelper.findByAttribute(xml, 'Default', 'Extension', 'xlsx') }));
338
+ return xml_helper_1.XmlHelper.appendIf({
339
+ ...xml_helper_1.XmlHelper.createContentTypeChild(this.targetArchive, {
340
+ Extension: `xlsx`,
341
+ ContentType: `application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`,
342
+ }),
343
+ tag: 'Default',
344
+ clause: (xml) => !xml_helper_1.XmlHelper.findByAttribute(xml, 'Default', 'Extension', 'xlsx'),
345
+ });
393
346
  }
394
347
  appendChartToContentType() {
395
348
  const contentType = this.subtype === 'chart'
@@ -424,13 +377,11 @@ class Chart extends shape_1.Shape {
424
377
  ContentType: `application/vnd.openxmlformats-officedocument.drawingml.chartshapes+xml`,
425
378
  }));
426
379
  }
427
- static getAllOnSlide(archive, relsPath) {
428
- return __awaiter(this, void 0, void 0, function* () {
429
- return yield xml_relationship_helper_1.XmlRelationshipHelper.getRelationshipTargetsByPrefix(archive, relsPath, [
430
- '../charts/chart',
431
- '../charts/chartEx',
432
- ]);
433
- });
380
+ static async getAllOnSlide(archive, relsPath) {
381
+ return await xml_relationship_helper_1.XmlRelationshipHelper.getRelationshipTargetsByPrefix(archive, relsPath, [
382
+ '../charts/chart',
383
+ '../charts/chartEx',
384
+ ]);
434
385
  }
435
386
  }
436
387
  exports.Chart = Chart;