pptxgenjs-plus 4.1.20 → 4.2.1
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.
- package/dist/pptxgen.bundle.js +68 -56
- package/dist/pptxgen.cjs.js +2341 -304
- package/dist/pptxgen.es.js +2335 -303
- package/dist/pptxgen.min.js +65 -53
- package/package.json +1 -1
- package/types/index.d.ts +1393 -27
package/dist/pptxgen.cjs.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* PptxGenJS 4.1
|
|
1
|
+
/* PptxGenJS 4.2.1 @ 2026-08-24T13:58:39.969Z */
|
|
2
2
|
|
|
3
3
|
"use strict";
|
|
4
4
|
const __rslib_import_meta_url__ = /*#__PURE__*/ (function () {
|
|
@@ -50,6 +50,34 @@ const ONEPT = 12700 // One (1) point (pt)
|
|
|
50
50
|
const CRLF = '\r\n' // AKA: Chr(13) & Chr(10)
|
|
51
51
|
;
|
|
52
52
|
const LAYOUT_IDX_SERIES_BASE = 2147483649;
|
|
53
|
+
/** ECMA-376 20.1.10.55 ST_RectAlignment — where a tiled picture fill starts */ const TILE_ALIGNMENTS = new Set([
|
|
54
|
+
'tl',
|
|
55
|
+
't',
|
|
56
|
+
'tr',
|
|
57
|
+
'l',
|
|
58
|
+
'ctr',
|
|
59
|
+
'r',
|
|
60
|
+
'bl',
|
|
61
|
+
'b',
|
|
62
|
+
'br'
|
|
63
|
+
]);
|
|
64
|
+
/**
|
|
65
|
+
* ECMA-376 20.1.6.2 CT_ColorMapping - the identity map, which is what `a:masterClrMapping` means
|
|
66
|
+
* - all twelve attributes are required, so a partial `colorMapOverride` is filled from this
|
|
67
|
+
*/ const DEF_COLOR_MAP = Object.freeze({
|
|
68
|
+
bg1: 'lt1',
|
|
69
|
+
tx1: 'dk1',
|
|
70
|
+
bg2: 'lt2',
|
|
71
|
+
tx2: 'dk2',
|
|
72
|
+
accent1: 'accent1',
|
|
73
|
+
accent2: 'accent2',
|
|
74
|
+
accent3: 'accent3',
|
|
75
|
+
accent4: 'accent4',
|
|
76
|
+
accent5: 'accent5',
|
|
77
|
+
accent6: 'accent6',
|
|
78
|
+
hlink: 'hlink',
|
|
79
|
+
folHlink: 'folHlink'
|
|
80
|
+
});
|
|
53
81
|
const REGEX_HEX_COLOR = /^[0-9a-fA-F]{6}$/;
|
|
54
82
|
const LINEH_MODIFIER = 1.67 // AKA: Golden Ratio Typography
|
|
55
83
|
;
|
|
@@ -125,6 +153,306 @@ const AXIS_ID_VALUE_SECONDARY = '2094734553';
|
|
|
125
153
|
const AXIS_ID_CATEGORY_PRIMARY = '2094734554';
|
|
126
154
|
const AXIS_ID_CATEGORY_SECONDARY = '2094734555';
|
|
127
155
|
const AXIS_ID_SERIES_PRIMARY = '2094734556';
|
|
156
|
+
/** ECMA-376 20.1.10.51 ST_SchemeColorVal - every slot `a:schemeClr@val` accepts */ const SCHEME_COLOR_VALUES = new Set([
|
|
157
|
+
'bg1',
|
|
158
|
+
'tx1',
|
|
159
|
+
'bg2',
|
|
160
|
+
'tx2',
|
|
161
|
+
'dk1',
|
|
162
|
+
'lt1',
|
|
163
|
+
'dk2',
|
|
164
|
+
'lt2',
|
|
165
|
+
'accent1',
|
|
166
|
+
'accent2',
|
|
167
|
+
'accent3',
|
|
168
|
+
'accent4',
|
|
169
|
+
'accent5',
|
|
170
|
+
'accent6',
|
|
171
|
+
'hlink',
|
|
172
|
+
'folHlink',
|
|
173
|
+
'phClr'
|
|
174
|
+
]);
|
|
175
|
+
/** ECMA-376 20.1.10.58 ST_SystemColorVal - `a:sysClr@val` */ const SYSTEM_COLOR_VALUES = new Set([
|
|
176
|
+
'scrollBar',
|
|
177
|
+
'background',
|
|
178
|
+
'activeCaption',
|
|
179
|
+
'inactiveCaption',
|
|
180
|
+
'menu',
|
|
181
|
+
'window',
|
|
182
|
+
'windowFrame',
|
|
183
|
+
'menuText',
|
|
184
|
+
'windowText',
|
|
185
|
+
'captionText',
|
|
186
|
+
'activeBorder',
|
|
187
|
+
'inactiveBorder',
|
|
188
|
+
'appWorkspace',
|
|
189
|
+
'highlight',
|
|
190
|
+
'highlightText',
|
|
191
|
+
'btnFace',
|
|
192
|
+
'btnShadow',
|
|
193
|
+
'grayText',
|
|
194
|
+
'btnText',
|
|
195
|
+
'inactiveCaptionText',
|
|
196
|
+
'btnHighlight',
|
|
197
|
+
'3dDkShadow',
|
|
198
|
+
'3dLight',
|
|
199
|
+
'infoText',
|
|
200
|
+
'infoBk',
|
|
201
|
+
'hotLight',
|
|
202
|
+
'gradientActiveCaption',
|
|
203
|
+
'gradientInactiveCaption',
|
|
204
|
+
'menuHighlight',
|
|
205
|
+
'menuBar'
|
|
206
|
+
]);
|
|
207
|
+
/** ECMA-376 20.1.10.48 ST_PresetColorVal - the 140 named preset colors for `a:prstClr@val` */ const PRESET_COLOR_VALUES = new Set([
|
|
208
|
+
'aliceBlue',
|
|
209
|
+
'antiqueWhite',
|
|
210
|
+
'aqua',
|
|
211
|
+
'aquamarine',
|
|
212
|
+
'azure',
|
|
213
|
+
'beige',
|
|
214
|
+
'bisque',
|
|
215
|
+
'black',
|
|
216
|
+
'blanchedAlmond',
|
|
217
|
+
'blue',
|
|
218
|
+
'blueViolet',
|
|
219
|
+
'brown',
|
|
220
|
+
'burlyWood',
|
|
221
|
+
'cadetBlue',
|
|
222
|
+
'chartreuse',
|
|
223
|
+
'chocolate',
|
|
224
|
+
'coral',
|
|
225
|
+
'cornflowerBlue',
|
|
226
|
+
'cornsilk',
|
|
227
|
+
'crimson',
|
|
228
|
+
'cyan',
|
|
229
|
+
'darkBlue',
|
|
230
|
+
'darkCyan',
|
|
231
|
+
'darkGoldenrod',
|
|
232
|
+
'darkGray',
|
|
233
|
+
'darkGrey',
|
|
234
|
+
'darkGreen',
|
|
235
|
+
'darkKhaki',
|
|
236
|
+
'darkMagenta',
|
|
237
|
+
'darkOliveGreen',
|
|
238
|
+
'darkOrange',
|
|
239
|
+
'darkOrchid',
|
|
240
|
+
'darkRed',
|
|
241
|
+
'darkSalmon',
|
|
242
|
+
'darkSeaGreen',
|
|
243
|
+
'darkSlateBlue',
|
|
244
|
+
'darkSlateGray',
|
|
245
|
+
'darkSlateGrey',
|
|
246
|
+
'darkTurquoise',
|
|
247
|
+
'darkViolet',
|
|
248
|
+
'deepPink',
|
|
249
|
+
'deepSkyBlue',
|
|
250
|
+
'dimGray',
|
|
251
|
+
'dimGrey',
|
|
252
|
+
'dkBlue',
|
|
253
|
+
'dkCyan',
|
|
254
|
+
'dkGoldenrod',
|
|
255
|
+
'dkGray',
|
|
256
|
+
'dkGrey',
|
|
257
|
+
'dkGreen',
|
|
258
|
+
'dkKhaki',
|
|
259
|
+
'dkMagenta',
|
|
260
|
+
'dkOliveGreen',
|
|
261
|
+
'dkOrange',
|
|
262
|
+
'dkOrchid',
|
|
263
|
+
'dkRed',
|
|
264
|
+
'dkSalmon',
|
|
265
|
+
'dkSeaGreen',
|
|
266
|
+
'dkSlateBlue',
|
|
267
|
+
'dkSlateGray',
|
|
268
|
+
'dkSlateGrey',
|
|
269
|
+
'dkTurquoise',
|
|
270
|
+
'dkViolet',
|
|
271
|
+
'dodgerBlue',
|
|
272
|
+
'firebrick',
|
|
273
|
+
'floralWhite',
|
|
274
|
+
'forestGreen',
|
|
275
|
+
'fuchsia',
|
|
276
|
+
'gainsboro',
|
|
277
|
+
'ghostWhite',
|
|
278
|
+
'gold',
|
|
279
|
+
'goldenrod',
|
|
280
|
+
'gray',
|
|
281
|
+
'grey',
|
|
282
|
+
'green',
|
|
283
|
+
'greenYellow',
|
|
284
|
+
'honeydew',
|
|
285
|
+
'hotPink',
|
|
286
|
+
'indianRed',
|
|
287
|
+
'indigo',
|
|
288
|
+
'ivory',
|
|
289
|
+
'khaki',
|
|
290
|
+
'lavender',
|
|
291
|
+
'lavenderBlush',
|
|
292
|
+
'lawnGreen',
|
|
293
|
+
'lemonChiffon',
|
|
294
|
+
'lightBlue',
|
|
295
|
+
'lightCoral',
|
|
296
|
+
'lightCyan',
|
|
297
|
+
'lightGoldenrodYellow',
|
|
298
|
+
'lightGray',
|
|
299
|
+
'lightGrey',
|
|
300
|
+
'lightGreen',
|
|
301
|
+
'lightPink',
|
|
302
|
+
'lightSalmon',
|
|
303
|
+
'lightSeaGreen',
|
|
304
|
+
'lightSkyBlue',
|
|
305
|
+
'lightSlateGray',
|
|
306
|
+
'lightSlateGrey',
|
|
307
|
+
'lightSteelBlue',
|
|
308
|
+
'lightYellow',
|
|
309
|
+
'lime',
|
|
310
|
+
'limeGreen',
|
|
311
|
+
'linen',
|
|
312
|
+
'ltBlue',
|
|
313
|
+
'ltCoral',
|
|
314
|
+
'ltCyan',
|
|
315
|
+
'ltGoldenrodYellow',
|
|
316
|
+
'ltGray',
|
|
317
|
+
'ltGrey',
|
|
318
|
+
'ltGreen',
|
|
319
|
+
'ltPink',
|
|
320
|
+
'ltSalmon',
|
|
321
|
+
'ltSeaGreen',
|
|
322
|
+
'ltSkyBlue',
|
|
323
|
+
'ltSlateGray',
|
|
324
|
+
'ltSlateGrey',
|
|
325
|
+
'ltSteelBlue',
|
|
326
|
+
'ltYellow',
|
|
327
|
+
'magenta',
|
|
328
|
+
'maroon',
|
|
329
|
+
'medAquamarine',
|
|
330
|
+
'medBlue',
|
|
331
|
+
'medOrchid',
|
|
332
|
+
'medPurple',
|
|
333
|
+
'medSeaGreen',
|
|
334
|
+
'medSlateBlue',
|
|
335
|
+
'medSpringGreen',
|
|
336
|
+
'medTurquoise',
|
|
337
|
+
'medVioletRed',
|
|
338
|
+
'mediumAquamarine',
|
|
339
|
+
'mediumBlue',
|
|
340
|
+
'mediumOrchid',
|
|
341
|
+
'mediumPurple',
|
|
342
|
+
'mediumSeaGreen',
|
|
343
|
+
'mediumSlateBlue',
|
|
344
|
+
'mediumSpringGreen',
|
|
345
|
+
'mediumTurquoise',
|
|
346
|
+
'mediumVioletRed',
|
|
347
|
+
'midnightBlue',
|
|
348
|
+
'mintCream',
|
|
349
|
+
'mistyRose',
|
|
350
|
+
'moccasin',
|
|
351
|
+
'navajoWhite',
|
|
352
|
+
'navy',
|
|
353
|
+
'oldLace',
|
|
354
|
+
'olive',
|
|
355
|
+
'oliveDrab',
|
|
356
|
+
'orange',
|
|
357
|
+
'orangeRed',
|
|
358
|
+
'orchid',
|
|
359
|
+
'paleGoldenrod',
|
|
360
|
+
'paleGreen',
|
|
361
|
+
'paleTurquoise',
|
|
362
|
+
'paleVioletRed',
|
|
363
|
+
'papayaWhip',
|
|
364
|
+
'peachPuff',
|
|
365
|
+
'peru',
|
|
366
|
+
'pink',
|
|
367
|
+
'plum',
|
|
368
|
+
'powderBlue',
|
|
369
|
+
'purple',
|
|
370
|
+
'red',
|
|
371
|
+
'rosyBrown',
|
|
372
|
+
'royalBlue',
|
|
373
|
+
'saddleBrown',
|
|
374
|
+
'salmon',
|
|
375
|
+
'sandyBrown',
|
|
376
|
+
'seaGreen',
|
|
377
|
+
'seaShell',
|
|
378
|
+
'sienna',
|
|
379
|
+
'silver',
|
|
380
|
+
'skyBlue',
|
|
381
|
+
'slateBlue',
|
|
382
|
+
'slateGray',
|
|
383
|
+
'slateGrey',
|
|
384
|
+
'snow',
|
|
385
|
+
'springGreen',
|
|
386
|
+
'steelBlue',
|
|
387
|
+
'tan',
|
|
388
|
+
'teal',
|
|
389
|
+
'thistle',
|
|
390
|
+
'tomato',
|
|
391
|
+
'turquoise',
|
|
392
|
+
'violet',
|
|
393
|
+
'wheat',
|
|
394
|
+
'white',
|
|
395
|
+
'whiteSmoke',
|
|
396
|
+
'yellow',
|
|
397
|
+
'yellowGreen'
|
|
398
|
+
]);
|
|
399
|
+
/** ECMA-376 20.1.10.23 ST_CompoundLine - `a:ln@cmpd` */ const COMPOUND_TYPES = new Set([
|
|
400
|
+
'sng',
|
|
401
|
+
'dbl',
|
|
402
|
+
'thickThin',
|
|
403
|
+
'thinThick',
|
|
404
|
+
'tri'
|
|
405
|
+
]);
|
|
406
|
+
/** ECMA-376 20.1.10.34/35 ST_LineEndWidth and ST_LineEndLength - arrow sizing */ const ARROW_SIZES = new Set([
|
|
407
|
+
'sm',
|
|
408
|
+
'med',
|
|
409
|
+
'lg'
|
|
410
|
+
]);
|
|
411
|
+
/**
|
|
412
|
+
* Chart style and chart colour-style parts (MS-ODRAWXML)
|
|
413
|
+
* - verified against Microsoft's own `ChartStylePart`/`ChartColorStylePart` definitions in
|
|
414
|
+
* dotnet/Open-XML-SDK, cross-checked against LibreOffice, rubyXL and OpenXLSX
|
|
415
|
+
* - note the asymmetry: the namespace is dated 2012, the relationships 2011. That is correct.
|
|
416
|
+
*/ const CHART_STYLE = Object.freeze({
|
|
417
|
+
ns: 'http://schemas.microsoft.com/office/drawing/2012/chartStyle',
|
|
418
|
+
styleContentType: 'application/vnd.ms-office.chartstyle+xml',
|
|
419
|
+
colorsContentType: 'application/vnd.ms-office.chartcolorstyle+xml',
|
|
420
|
+
styleRelType: 'http://schemas.microsoft.com/office/2011/relationships/chartStyle',
|
|
421
|
+
colorsRelType: 'http://schemas.microsoft.com/office/2011/relationships/chartColorStyle'
|
|
422
|
+
});
|
|
423
|
+
/**
|
|
424
|
+
* ChartEx (PowerPoint 2016+) package contract - MS-ODRAWXML 2.1.
|
|
425
|
+
*
|
|
426
|
+
* These chart types have no ECMA-376 representation: they live in their own `cx:chartSpace` part with a
|
|
427
|
+
* Microsoft content type and relationship type, and the slide-level `p:graphicFrame` must sit inside an
|
|
428
|
+
* `mc:AlternateContent` so consumers that predate them still get a fallback.
|
|
429
|
+
*
|
|
430
|
+
* The `requires` namespace is the schema generation a consumer must understand before it may take the
|
|
431
|
+
* `mc:Choice`; funnel arrived a revision after the 2016 launch set, so it gates on a later one.
|
|
432
|
+
*/ const OOXML_CHARTEX = {
|
|
433
|
+
/** `cx` - the chartex part's own namespace, and the `a:graphicData@uri` that identifies the frame */ ns: 'http://schemas.microsoft.com/office/drawing/2014/chartex',
|
|
434
|
+
partContentType: 'application/vnd.ms-office.chartex+xml',
|
|
435
|
+
relType: 'http://schemas.microsoft.com/office/2014/relationships/chartEx',
|
|
436
|
+
/** `mc:Choice@Requires` namespace for the Office 2016 launch layouts */ requires2016: 'http://schemas.microsoft.com/office/drawing/2015/9/8/chartex',
|
|
437
|
+
/** `mc:Choice@Requires` namespace for funnel, which shipped a schema revision later */ requiresFunnel: 'http://schemas.microsoft.com/office/drawing/2015/10/21/chartex'
|
|
438
|
+
};
|
|
439
|
+
/** `cx:series@layoutId` per chart type - a histogram is a `clusteredColumn` layout carrying `cx:binning` */ const CHARTEX_LAYOUT_ID = {
|
|
440
|
+
boxWhisker: 'boxWhisker',
|
|
441
|
+
funnel: 'funnel',
|
|
442
|
+
histogram: 'clusteredColumn',
|
|
443
|
+
sunburst: 'sunburst',
|
|
444
|
+
treemap: 'treemap',
|
|
445
|
+
waterfall: 'waterfall'
|
|
446
|
+
};
|
|
447
|
+
/**
|
|
448
|
+
* `mc:Choice@Requires` namespace gating a chartex chart type
|
|
449
|
+
* - funnel arrived a schema revision after the 2016 launch layouts, so it gates on a later generation
|
|
450
|
+
*/ function chartExRequiresNs(chartType) {
|
|
451
|
+
return chartType === 'funnel' ? OOXML_CHARTEX.requiresFunnel : OOXML_CHARTEX.requires2016;
|
|
452
|
+
}
|
|
453
|
+
/** True when `type` is emitted through the chartex pipeline rather than the ECMA-376 one */ function isChartexType(type) {
|
|
454
|
+
return typeof type === 'string' && Object.prototype.hasOwnProperty.call(CHARTEX_LAYOUT_ID, type);
|
|
455
|
+
}
|
|
128
456
|
/**
|
|
129
457
|
* Slide transition type.
|
|
130
458
|
* Base set is ECMA-376 §19.3.1.50; the rest are MS-PPTX §2.2.1 modern transitions (emitted via mc:AlternateContent).
|
|
@@ -241,6 +569,27 @@ var core_enums_TEXT_VALIGN = /*#__PURE__*/ function(TEXT_VALIGN) {
|
|
|
241
569
|
return TEXT_VALIGN;
|
|
242
570
|
}({});
|
|
243
571
|
const SLDNUMFLDID = '{F7021451-1387-4CA6-816F-3879F97B5CBC}';
|
|
572
|
+
/** ECMA-376 21.1.2.2.4 — `a:fld@type` values PowerPoint refreshes */ const TEXT_FIELD_TYPES = new Set([
|
|
573
|
+
'slidenum',
|
|
574
|
+
'datetime',
|
|
575
|
+
'datetimeFigureOut',
|
|
576
|
+
'datetime1',
|
|
577
|
+
'datetime2',
|
|
578
|
+
'datetime3',
|
|
579
|
+
'datetime4',
|
|
580
|
+
'datetime5',
|
|
581
|
+
'datetime6',
|
|
582
|
+
'datetime7',
|
|
583
|
+
'datetime8',
|
|
584
|
+
'datetime9',
|
|
585
|
+
'datetime10',
|
|
586
|
+
'datetime11',
|
|
587
|
+
'datetime12',
|
|
588
|
+
'datetime13',
|
|
589
|
+
'headerfooter',
|
|
590
|
+
'hdr',
|
|
591
|
+
'ftr'
|
|
592
|
+
]);
|
|
244
593
|
// ENUM
|
|
245
594
|
// TODO: 3.5 or v4.0: rationalize ts-def exported enum names/case!
|
|
246
595
|
// NOTE: First tsdef enum named correctly (shapes -> 'Shape', colors -> 'Color'), etc.
|
|
@@ -264,6 +613,12 @@ var core_enums_ChartType = /*#__PURE__*/ function(ChartType) {
|
|
|
264
613
|
ChartType["pie"] = "pie";
|
|
265
614
|
ChartType["radar"] = "radar";
|
|
266
615
|
ChartType["scatter"] = "scatter";
|
|
616
|
+
ChartType["boxWhisker"] = "boxWhisker";
|
|
617
|
+
ChartType["funnel"] = "funnel";
|
|
618
|
+
ChartType["histogram"] = "histogram";
|
|
619
|
+
ChartType["sunburst"] = "sunburst";
|
|
620
|
+
ChartType["treemap"] = "treemap";
|
|
621
|
+
ChartType["waterfall"] = "waterfall";
|
|
267
622
|
return ChartType;
|
|
268
623
|
}({});
|
|
269
624
|
var core_enums_ShapeType = /*#__PURE__*/ function(ShapeType) {
|
|
@@ -291,6 +646,10 @@ var core_enums_ShapeType = /*#__PURE__*/ function(ShapeType) {
|
|
|
291
646
|
ShapeType["actionButtonSound"] = "actionButtonSound";
|
|
292
647
|
ShapeType["arc"] = "arc";
|
|
293
648
|
ShapeType["bentArrow"] = "bentArrow";
|
|
649
|
+
ShapeType["bentConnector2"] = "bentConnector2";
|
|
650
|
+
ShapeType["bentConnector3"] = "bentConnector3";
|
|
651
|
+
ShapeType["bentConnector4"] = "bentConnector4";
|
|
652
|
+
ShapeType["bentConnector5"] = "bentConnector5";
|
|
294
653
|
ShapeType["bentUpArrow"] = "bentUpArrow";
|
|
295
654
|
ShapeType["bevel"] = "bevel";
|
|
296
655
|
ShapeType["blockArc"] = "blockArc";
|
|
@@ -314,6 +673,10 @@ var core_enums_ShapeType = /*#__PURE__*/ function(ShapeType) {
|
|
|
314
673
|
ShapeType["corner"] = "corner";
|
|
315
674
|
ShapeType["cornerTabs"] = "cornerTabs";
|
|
316
675
|
ShapeType["cube"] = "cube";
|
|
676
|
+
ShapeType["curvedConnector2"] = "curvedConnector2";
|
|
677
|
+
ShapeType["curvedConnector3"] = "curvedConnector3";
|
|
678
|
+
ShapeType["curvedConnector4"] = "curvedConnector4";
|
|
679
|
+
ShapeType["curvedConnector5"] = "curvedConnector5";
|
|
317
680
|
ShapeType["curvedDownArrow"] = "curvedDownArrow";
|
|
318
681
|
ShapeType["curvedLeftArrow"] = "curvedLeftArrow";
|
|
319
682
|
ShapeType["curvedRightArrow"] = "curvedRightArrow";
|
|
@@ -434,6 +797,7 @@ var core_enums_ShapeType = /*#__PURE__*/ function(ShapeType) {
|
|
|
434
797
|
ShapeType["star6"] = "star6";
|
|
435
798
|
ShapeType["star7"] = "star7";
|
|
436
799
|
ShapeType["star8"] = "star8";
|
|
800
|
+
ShapeType["straightConnector1"] = "straightConnector1";
|
|
437
801
|
ShapeType["stripedRightArrow"] = "stripedRightArrow";
|
|
438
802
|
ShapeType["sun"] = "sun";
|
|
439
803
|
ShapeType["swooshArrow"] = "swooshArrow";
|
|
@@ -465,6 +829,13 @@ var core_enums_ShapeType = /*#__PURE__*/ function(ShapeType) {
|
|
|
465
829
|
SchemeColor["accent4"] = "accent4";
|
|
466
830
|
SchemeColor["accent5"] = "accent5";
|
|
467
831
|
SchemeColor["accent6"] = "accent6";
|
|
832
|
+
SchemeColor["dk1"] = "dk1";
|
|
833
|
+
SchemeColor["lt1"] = "lt1";
|
|
834
|
+
SchemeColor["dk2"] = "dk2";
|
|
835
|
+
SchemeColor["lt2"] = "lt2";
|
|
836
|
+
SchemeColor["hlink"] = "hlink";
|
|
837
|
+
SchemeColor["folHlink"] = "folHlink";
|
|
838
|
+
SchemeColor["phClr"] = "phClr";
|
|
468
839
|
return SchemeColor;
|
|
469
840
|
}({});
|
|
470
841
|
var core_enums_AlignH = /*#__PURE__*/ function(AlignH) {
|
|
@@ -507,6 +878,10 @@ var core_enums_SHAPE_TYPE = /*#__PURE__*/ function(SHAPE_TYPE) {
|
|
|
507
878
|
SHAPE_TYPE["ARC"] = "arc";
|
|
508
879
|
SHAPE_TYPE["BALLOON"] = "wedgeRoundRectCallout";
|
|
509
880
|
SHAPE_TYPE["BENT_ARROW"] = "bentArrow";
|
|
881
|
+
SHAPE_TYPE["BENT_CONNECTOR_2"] = "bentConnector2";
|
|
882
|
+
SHAPE_TYPE["BENT_CONNECTOR_3"] = "bentConnector3";
|
|
883
|
+
SHAPE_TYPE["BENT_CONNECTOR_4"] = "bentConnector4";
|
|
884
|
+
SHAPE_TYPE["BENT_CONNECTOR_5"] = "bentConnector5";
|
|
510
885
|
SHAPE_TYPE["BENT_UP_ARROW"] = "bentUpArrow";
|
|
511
886
|
SHAPE_TYPE["BEVEL"] = "bevel";
|
|
512
887
|
SHAPE_TYPE["BLOCK_ARC"] = "blockArc";
|
|
@@ -523,6 +898,10 @@ var core_enums_SHAPE_TYPE = /*#__PURE__*/ function(SHAPE_TYPE) {
|
|
|
523
898
|
SHAPE_TYPE["CORNER_TABS"] = "cornerTabs";
|
|
524
899
|
SHAPE_TYPE["CROSS"] = "plus";
|
|
525
900
|
SHAPE_TYPE["CUBE"] = "cube";
|
|
901
|
+
SHAPE_TYPE["CURVED_CONNECTOR_2"] = "curvedConnector2";
|
|
902
|
+
SHAPE_TYPE["CURVED_CONNECTOR_3"] = "curvedConnector3";
|
|
903
|
+
SHAPE_TYPE["CURVED_CONNECTOR_4"] = "curvedConnector4";
|
|
904
|
+
SHAPE_TYPE["CURVED_CONNECTOR_5"] = "curvedConnector5";
|
|
526
905
|
SHAPE_TYPE["CURVED_DOWN_ARROW"] = "curvedDownArrow";
|
|
527
906
|
SHAPE_TYPE["CURVED_DOWN_RIBBON"] = "ellipseRibbon";
|
|
528
907
|
SHAPE_TYPE["CURVED_LEFT_ARROW"] = "curvedLeftArrow";
|
|
@@ -664,6 +1043,7 @@ var core_enums_SHAPE_TYPE = /*#__PURE__*/ function(SHAPE_TYPE) {
|
|
|
664
1043
|
SHAPE_TYPE["STAR_6_POINT"] = "star6";
|
|
665
1044
|
SHAPE_TYPE["STAR_7_POINT"] = "star7";
|
|
666
1045
|
SHAPE_TYPE["STAR_8_POINT"] = "star8";
|
|
1046
|
+
SHAPE_TYPE["STRAIGHT_CONNECTOR_1"] = "straightConnector1";
|
|
667
1047
|
SHAPE_TYPE["STRIPED_RIGHT_ARROW"] = "stripedRightArrow";
|
|
668
1048
|
SHAPE_TYPE["SUN"] = "sun";
|
|
669
1049
|
SHAPE_TYPE["SWOOSH_ARROW"] = "swooshArrow";
|
|
@@ -683,13 +1063,19 @@ var core_enums_CHART_TYPE = /*#__PURE__*/ function(CHART_TYPE) {
|
|
|
683
1063
|
CHART_TYPE["AREA"] = "area";
|
|
684
1064
|
CHART_TYPE["BAR"] = "bar";
|
|
685
1065
|
CHART_TYPE["BAR3D"] = "bar3D";
|
|
1066
|
+
CHART_TYPE["BOX_WHISKER"] = "boxWhisker";
|
|
686
1067
|
CHART_TYPE["BUBBLE"] = "bubble";
|
|
687
1068
|
CHART_TYPE["BUBBLE3D"] = "bubble3D";
|
|
688
1069
|
CHART_TYPE["DOUGHNUT"] = "doughnut";
|
|
1070
|
+
CHART_TYPE["FUNNEL"] = "funnel";
|
|
1071
|
+
CHART_TYPE["HISTOGRAM"] = "histogram";
|
|
689
1072
|
CHART_TYPE["LINE"] = "line";
|
|
690
1073
|
CHART_TYPE["PIE"] = "pie";
|
|
691
1074
|
CHART_TYPE["RADAR"] = "radar";
|
|
692
1075
|
CHART_TYPE["SCATTER"] = "scatter";
|
|
1076
|
+
CHART_TYPE["SUNBURST"] = "sunburst";
|
|
1077
|
+
CHART_TYPE["TREEMAP"] = "treemap";
|
|
1078
|
+
CHART_TYPE["WATERFALL"] = "waterfall";
|
|
693
1079
|
return CHART_TYPE;
|
|
694
1080
|
}({});
|
|
695
1081
|
var core_enums_SCHEME_COLOR_NAMES = /*#__PURE__*/ function(SCHEME_COLOR_NAMES) {
|
|
@@ -991,13 +1377,37 @@ function _object_spread_props(target, source) {
|
|
|
991
1377
|
}
|
|
992
1378
|
return code;
|
|
993
1379
|
}
|
|
1380
|
+
/** Units per inch, for the length suffixes accepted on `x`/`y`/`w`/`h` and the other inch-valued options */ const UNITS_PER_INCH = {
|
|
1381
|
+
in: 1,
|
|
1382
|
+
cm: 2.54,
|
|
1383
|
+
mm: 25.4,
|
|
1384
|
+
pt: 72
|
|
1385
|
+
};
|
|
1386
|
+
/**
|
|
1387
|
+
* A number with a length suffix - `'2.5cm'`, `'-4mm'`, `'18pt'`, `'5in'`
|
|
1388
|
+
* - the mantissa alternates rather than using `\d*\.?\d+`: that form lets the two digit runs
|
|
1389
|
+
* split a plain integer many ways, so a long non-matching digit string backtracks quadratically
|
|
1390
|
+
*/ const REGEX_UNIT_LENGTH = /^\s*(-?(?:\d+(?:\.\d+)?|\.\d+))\s*(in|cm|mm|pt)\s*$/i;
|
|
1391
|
+
/**
|
|
1392
|
+
* Parse a unit-suffixed length into inches
|
|
1393
|
+
* - a suffixed value carries its own unit, so it bypasses the inches-vs-EMU magnitude heuristic entirely
|
|
1394
|
+
* @param {string} value - ex: `'2.5cm'`, `'18pt'`
|
|
1395
|
+
* @returns {number|undefined} inches, or `undefined` when `value` is not a suffixed length
|
|
1396
|
+
*/ function parseUnitLength(value) {
|
|
1397
|
+
const match = REGEX_UNIT_LENGTH.exec(value);
|
|
1398
|
+
if (!match) return undefined;
|
|
1399
|
+
const num = Number(match[1]);
|
|
1400
|
+
if (!Number.isFinite(num)) return undefined;
|
|
1401
|
+
return num / UNITS_PER_INCH[match[2].toLowerCase()];
|
|
1402
|
+
}
|
|
994
1403
|
/**
|
|
995
1404
|
* Translates any type of `x`/`y`/`w`/`h` prop to EMU
|
|
996
1405
|
* - guaranteed to return a result regardless of undefined, null, etc. (0)
|
|
997
1406
|
* - {number} - 12800 (EMU)
|
|
998
1407
|
* - {number} - 0.5 (inches)
|
|
999
1408
|
* - {string} - "75%"
|
|
1000
|
-
*
|
|
1409
|
+
* - {string} - "2.5cm" (also in/mm/pt)
|
|
1410
|
+
* @param {number|string} size - numeric ("5.5"), unit-suffixed ("2.5cm") or percentage ("90%")
|
|
1001
1411
|
* @param {'X' | 'Y'} xyDir - direction
|
|
1002
1412
|
* @param {PresLayout} layout - presentation layout
|
|
1003
1413
|
* @returns {number} calculated size
|
|
@@ -1010,7 +1420,12 @@ function _object_spread_props(target, source) {
|
|
|
1010
1420
|
// CASE 2: Number is already converted to something other than inches
|
|
1011
1421
|
// Assume any number whose absolute value is 100+ is EMU already.
|
|
1012
1422
|
if (typeof size === 'number' && Math.abs(size) >= 100) return size;
|
|
1013
|
-
// CASE 3:
|
|
1423
|
+
// CASE 3: Unit-suffixed length (ex: '2.5cm') - unambiguous, so no magnitude heuristic
|
|
1424
|
+
if (typeof size === 'string') {
|
|
1425
|
+
const inches = parseUnitLength(size);
|
|
1426
|
+
if (inches !== undefined) return Math.round((/* inlined export .EMU */914400) * inches);
|
|
1427
|
+
}
|
|
1428
|
+
// CASE 4: Percentage (ex: '50%')
|
|
1014
1429
|
if (typeof size === 'string' && size.includes('%')) {
|
|
1015
1430
|
if (xyDir && xyDir === 'X') return Math.round(parseFloat(size) / 100 * layout.width);
|
|
1016
1431
|
if (xyDir && xyDir === 'Y') return Math.round(parseFloat(size) / 100 * layout.height);
|
|
@@ -1074,6 +1489,11 @@ function _object_spread_props(target, source) {
|
|
|
1074
1489
|
* @param {number|string} inches - as string or number
|
|
1075
1490
|
* @returns {number} EMU value
|
|
1076
1491
|
*/ function inch2Emu(inches) {
|
|
1492
|
+
// A unit-suffixed string states its own unit - convert it before any inches assumption
|
|
1493
|
+
if (typeof inches === 'string') {
|
|
1494
|
+
const parsed = parseUnitLength(inches);
|
|
1495
|
+
if (parsed !== undefined) return Math.round((/* inlined export .EMU */914400) * parsed);
|
|
1496
|
+
}
|
|
1077
1497
|
// NOTE: Provide Caller Safety: Numbers may get conv<->conv during flight, so be kind and do some simple checks to ensure inches were passed
|
|
1078
1498
|
// Any absolute value over 100 is not inches (negative EMU is off-slide), so return it unchanged
|
|
1079
1499
|
if (typeof inches === 'number' && Math.abs(inches) > 100) return inches;
|
|
@@ -1174,6 +1594,20 @@ function _object_spread_props(target, source) {
|
|
|
1174
1594
|
function isModifiedThemeColor(value) {
|
|
1175
1595
|
return typeof value === 'object' && value !== null && 'baseColor' in value;
|
|
1176
1596
|
}
|
|
1597
|
+
/**
|
|
1598
|
+
* Whether a value is a DrawingML color object rather than a fill object
|
|
1599
|
+
* - the six specification fields are unique to `ColorProps`
|
|
1600
|
+
*/ function isColorProps(value) {
|
|
1601
|
+
if (!value || typeof value !== 'object') return false;
|
|
1602
|
+
return [
|
|
1603
|
+
'hex',
|
|
1604
|
+
'scheme',
|
|
1605
|
+
'system',
|
|
1606
|
+
'preset',
|
|
1607
|
+
'hsl',
|
|
1608
|
+
'scrgb'
|
|
1609
|
+
].some((key)=>key in value);
|
|
1610
|
+
}
|
|
1177
1611
|
/** Percent-based OOXML color transforms (0-100 → val*1000) */ const PERCENT_COLOR_MODIFIERS = [
|
|
1178
1612
|
'alpha',
|
|
1179
1613
|
'alphaMod',
|
|
@@ -1235,11 +1669,86 @@ const FLAG_COLOR_MODIFIERS = [
|
|
|
1235
1669
|
* @example [gen-charts.tx] `strXml += '<a:solidFill>' + createColorElement(seriesColor, `<a:alpha val="${Math.round(opts.chartColorsOpacity * 1000)}"/>`) + '</a:solidFill>'`
|
|
1236
1670
|
* Thi sis wrong. We s/b calling `genXmlColorSelection()` instead as it returns `<a:solidfill>BLAH</a:solidFill>`!!
|
|
1237
1671
|
*/ /**
|
|
1672
|
+
* DrawingML stores percentages in 1000ths of a percent
|
|
1673
|
+
* - `CT_PositiveFixedPercentage` (tint, shade, alpha) is 0-100
|
|
1674
|
+
* - `CT_FixedPercentage` (the `*Off` transforms) is -100 to 100
|
|
1675
|
+
* - `CT_PositivePercentage` (the `*Mod` transforms) is a *scale* and is unbounded above
|
|
1676
|
+
*/ function gen_utils_pct(value, min = 0, max = 100) {
|
|
1677
|
+
const clamped = Math.min(max, Math.max(min, isFinite(value) ? value : 0));
|
|
1678
|
+
return String(Math.round(clamped * 1000));
|
|
1679
|
+
}
|
|
1680
|
+
/**
|
|
1681
|
+
* Create the color transform children shared by every ColorProps element (ECMA-376 20.1.2.3)
|
|
1682
|
+
*/ function createColorTransforms(props) {
|
|
1683
|
+
let xml = '';
|
|
1684
|
+
if (typeof props.tint === 'number') xml += `<a:tint val="${gen_utils_pct(props.tint)}"/>`;
|
|
1685
|
+
if (typeof props.shade === 'number') xml += `<a:shade val="${gen_utils_pct(props.shade)}"/>`;
|
|
1686
|
+
if (props.inverse === true) xml += '<a:inv/>';
|
|
1687
|
+
if (props.grayscale === true) xml += '<a:gray/>';
|
|
1688
|
+
if (typeof props.alpha === 'number') xml += `<a:alpha val="${gen_utils_pct(props.alpha)}"/>`;
|
|
1689
|
+
if (typeof props.alphaOff === 'number') xml += `<a:alphaOff val="${gen_utils_pct(props.alphaOff, -100, 100)}"/>`;
|
|
1690
|
+
if (typeof props.alphaMod === 'number') xml += `<a:alphaMod val="${gen_utils_pct(props.alphaMod, 0, Number.MAX_SAFE_INTEGER)}"/>`;
|
|
1691
|
+
if (typeof props.hueMod === 'number') xml += `<a:hueMod val="${gen_utils_pct(props.hueMod, 0, Number.MAX_SAFE_INTEGER)}"/>`;
|
|
1692
|
+
if (typeof props.hueOff === 'number') xml += `<a:hueOff val="${Math.round(Math.min(360, Math.max(-360, isFinite(props.hueOff) ? props.hueOff : 0)) * 60000)}"/>`;
|
|
1693
|
+
if (typeof props.satMod === 'number') xml += `<a:satMod val="${gen_utils_pct(props.satMod, 0, Number.MAX_SAFE_INTEGER)}"/>`;
|
|
1694
|
+
if (typeof props.satOff === 'number') xml += `<a:satOff val="${gen_utils_pct(props.satOff, -100, 100)}"/>`;
|
|
1695
|
+
if (typeof props.lumMod === 'number') xml += `<a:lumMod val="${gen_utils_pct(props.lumMod, 0, Number.MAX_SAFE_INTEGER)}"/>`;
|
|
1696
|
+
if (typeof props.lumOff === 'number') xml += `<a:lumOff val="${gen_utils_pct(props.lumOff, -100, 100)}"/>`;
|
|
1697
|
+
if (props.complement === true) xml += '<a:comp/>';
|
|
1698
|
+
if (props.gamma === true) xml += '<a:gamma/>';
|
|
1699
|
+
if (props.inverseGamma === true) xml += '<a:invGamma/>';
|
|
1700
|
+
return xml;
|
|
1701
|
+
}
|
|
1702
|
+
/**
|
|
1703
|
+
* Create the color element for a `ColorProps` object
|
|
1704
|
+
*/ function createColorPropsElement(props, extra) {
|
|
1705
|
+
const inner = createColorTransforms(props) + extra;
|
|
1706
|
+
const wrap = (tag, attrs)=>inner ? `<a:${tag} ${attrs}>${inner}</a:${tag}>` : `<a:${tag} ${attrs}/>`;
|
|
1707
|
+
if ('hex' in props) {
|
|
1708
|
+
var _props_hex;
|
|
1709
|
+
const hex = String((_props_hex = props.hex) !== null && _props_hex !== void 0 ? _props_hex : '').replace('#', '');
|
|
1710
|
+
if (!REGEX_HEX_COLOR.test(hex)) {
|
|
1711
|
+
console.warn(`[pptxgenjs] "${hex}" is not a 6-digit hex color - "${(/* inlined export .DEF_FONT_COLOR */"000000")}" used instead`);
|
|
1712
|
+
return wrap('srgbClr', `val="${(/* inlined export .DEF_FONT_COLOR */"000000")}"`);
|
|
1713
|
+
}
|
|
1714
|
+
return wrap('srgbClr', `val="${hex.toUpperCase()}"`);
|
|
1715
|
+
}
|
|
1716
|
+
if ('scheme' in props) {
|
|
1717
|
+
if (!SCHEME_COLOR_VALUES.has(props.scheme)) {
|
|
1718
|
+
console.warn(`[pptxgenjs] "${String(props.scheme)}" is not a theme color slot - "${(/* inlined export .DEF_FONT_COLOR */"000000")}" used instead`);
|
|
1719
|
+
return wrap('srgbClr', `val="${(/* inlined export .DEF_FONT_COLOR */"000000")}"`);
|
|
1720
|
+
}
|
|
1721
|
+
return wrap('schemeClr', `val="${props.scheme}"`);
|
|
1722
|
+
}
|
|
1723
|
+
if ('system' in props) {
|
|
1724
|
+
if (!SYSTEM_COLOR_VALUES.has(props.system)) {
|
|
1725
|
+
console.warn(`[pptxgenjs] "${String(props.system)}" is not a system color - "${(/* inlined export .DEF_FONT_COLOR */"000000")}" used instead`);
|
|
1726
|
+
return wrap('srgbClr', `val="${(/* inlined export .DEF_FONT_COLOR */"000000")}"`);
|
|
1727
|
+
}
|
|
1728
|
+
const last = props.lastColor && REGEX_HEX_COLOR.test(props.lastColor.replace('#', '')) ? ` lastClr="${props.lastColor.replace('#', '').toUpperCase()}"` : '';
|
|
1729
|
+
return wrap('sysClr', `val="${props.system}"${last}`);
|
|
1730
|
+
}
|
|
1731
|
+
if ('preset' in props) {
|
|
1732
|
+
if (!PRESET_COLOR_VALUES.has(props.preset)) {
|
|
1733
|
+
console.warn(`[pptxgenjs] "${String(props.preset)}" is not a preset color name - "${(/* inlined export .DEF_FONT_COLOR */"000000")}" used instead`);
|
|
1734
|
+
return wrap('srgbClr', `val="${(/* inlined export .DEF_FONT_COLOR */"000000")}"`);
|
|
1735
|
+
}
|
|
1736
|
+
return wrap('prstClr', `val="${props.preset}"`);
|
|
1737
|
+
}
|
|
1738
|
+
if ('hsl' in props) {
|
|
1739
|
+
const hue = Math.round(((props.hsl.hue % 360 + 360) % 360 || 0) * 60000);
|
|
1740
|
+
return wrap('hslClr', `hue="${isFinite(hue) ? hue : 0}" sat="${gen_utils_pct(props.hsl.sat)}" lum="${gen_utils_pct(props.hsl.lum)}"`);
|
|
1741
|
+
}
|
|
1742
|
+
return wrap('scrgbClr', `r="${gen_utils_pct(props.scrgb.r)}" g="${gen_utils_pct(props.scrgb.g)}" b="${gen_utils_pct(props.scrgb.b)}"`);
|
|
1743
|
+
}
|
|
1744
|
+
/**
|
|
1238
1745
|
* Create either a `a:schemeClr` - (scheme color) or `a:srgbClr` (hexa representation).
|
|
1239
|
-
*
|
|
1746
|
+
* Object forms (`ColorProps`, `ModifiedThemeColor`) reach the rest of the DrawingML color model.
|
|
1747
|
+
* @param {Color|SCHEME_COLORS} colorInput - hex, scheme token, ModifiedThemeColor, or ColorProps
|
|
1240
1748
|
* @param {string} innerElements - additional elements that adjust the color and are enclosed by the color element
|
|
1241
1749
|
* @returns {string} XML string
|
|
1242
1750
|
*/ function createColorElement(colorInput, innerElements) {
|
|
1751
|
+
if (isColorProps(colorInput)) return createColorPropsElement(colorInput, innerElements !== null && innerElements !== void 0 ? innerElements : '');
|
|
1243
1752
|
const base = isModifiedThemeColor(colorInput) ? colorInput.baseColor : colorInput;
|
|
1244
1753
|
const colorStr = typeof base === 'string' ? base : (/* inlined export .DEF_FONT_COLOR */"000000");
|
|
1245
1754
|
let colorVal = (colorStr || '').replace('#', '');
|
|
@@ -1247,7 +1756,7 @@ const FLAG_COLOR_MODIFIERS = [
|
|
|
1247
1756
|
if (isModifiedThemeColor(colorInput)) {
|
|
1248
1757
|
kids += handleModifiedColorProps(colorInput);
|
|
1249
1758
|
}
|
|
1250
|
-
if (!REGEX_HEX_COLOR.test(colorVal) &&
|
|
1759
|
+
if (!REGEX_HEX_COLOR.test(colorVal) && !SCHEME_COLOR_VALUES.has(colorVal)) {
|
|
1251
1760
|
console.warn(`"${colorVal}" is not a valid scheme color or hex RGB! "${(/* inlined export .DEF_FONT_COLOR */"000000")}" used instead. Only provide 6-digit RGB or 'pptx.SchemeColor' values!`);
|
|
1252
1761
|
colorVal = (/* inlined export .DEF_FONT_COLOR */"000000");
|
|
1253
1762
|
}
|
|
@@ -1367,6 +1876,23 @@ function createGlowElement(glow) {
|
|
|
1367
1876
|
const bg = String((pattern === null || pattern === void 0 ? void 0 : pattern.bgColor) || 'FFFFFF');
|
|
1368
1877
|
return `<a:pattFill prst="${prst}"><a:bgClr>${createColorElement(bg)}</a:bgClr><a:fgClr>${createColorElement(fg)}</a:fgClr></a:pattFill>`;
|
|
1369
1878
|
}
|
|
1879
|
+
/**
|
|
1880
|
+
* Create a DrawingML `a:blipFill` for a picture fill (ECMA-376 20.1.8.14)
|
|
1881
|
+
* - the image relationship is resolved when the object is created
|
|
1882
|
+
*/ function createImageFillElement(image, rId) {
|
|
1883
|
+
let mode = '<a:stretch><a:fillRect/></a:stretch>';
|
|
1884
|
+
if (image.sizing === 'tile') {
|
|
1885
|
+
var _image_alignment;
|
|
1886
|
+
const scale = typeof image.scale === 'number' && isFinite(image.scale) && image.scale > 0 ? Math.round(image.scale * 1000) : 100000;
|
|
1887
|
+
const rawAlgn = (_image_alignment = image.alignment) !== null && _image_alignment !== void 0 ? _image_alignment : 'tl';
|
|
1888
|
+
const algn = TILE_ALIGNMENTS.has(rawAlgn) ? rawAlgn : 'tl';
|
|
1889
|
+
if (image.alignment && !TILE_ALIGNMENTS.has(image.alignment)) {
|
|
1890
|
+
console.warn(`[pptxgenjs] unknown tile alignment "${String(image.alignment)}" - "tl" used instead`);
|
|
1891
|
+
}
|
|
1892
|
+
mode = `<a:tile tx="0" ty="0" sx="${scale}" sy="${scale}" flip="none" algn="${algn}"/>`;
|
|
1893
|
+
}
|
|
1894
|
+
return `<a:blipFill rotWithShape="${image.rotateWithShape === false ? '0' : '1'}"><a:blip r:embed="rId${rId}"/>${mode}</a:blipFill>`;
|
|
1895
|
+
}
|
|
1370
1896
|
/**
|
|
1371
1897
|
* Create color selection
|
|
1372
1898
|
* @param {Color | ShapeFillProps | ShapeLineProps} props fill props
|
|
@@ -1377,27 +1903,45 @@ function createGlowElement(glow) {
|
|
|
1377
1903
|
let internalElements = '';
|
|
1378
1904
|
let outText = '';
|
|
1379
1905
|
if (props) {
|
|
1380
|
-
// ModifiedThemeColor
|
|
1906
|
+
// A bare color - string, ModifiedThemeColor, or ColorProps - is a solid fill of that color
|
|
1381
1907
|
if (typeof props === 'string') {
|
|
1382
1908
|
colorVal = props;
|
|
1383
|
-
} else if (isModifiedThemeColor(props)) {
|
|
1909
|
+
} else if (isModifiedThemeColor(props) || isColorProps(props)) {
|
|
1384
1910
|
colorVal = props;
|
|
1385
1911
|
} else {
|
|
1912
|
+
var _props_image;
|
|
1386
1913
|
if (props.type) fillType = props.type;
|
|
1914
|
+
else if (((_props_image = props.image) === null || _props_image === void 0 ? void 0 : _props_image._rId) || props._rId) fillType = 'image';
|
|
1387
1915
|
if (props.color) colorVal = props.color;
|
|
1388
1916
|
if (props.alpha) internalElements += `<a:alpha val="${Math.round((100 - props.alpha) * 1000)}"/>`; // DEPRECATED: @deprecated v3.3.0
|
|
1389
1917
|
if (props.transparency) internalElements += `<a:alpha val="${Math.round((100 - props.transparency) * 1000)}"/>`;
|
|
1390
1918
|
}
|
|
1919
|
+
const isBareColor = typeof props === 'string' || isModifiedThemeColor(props) || isColorProps(props);
|
|
1391
1920
|
switch(fillType){
|
|
1392
1921
|
case 'solid':
|
|
1393
1922
|
outText += `<a:solidFill>${createColorElement(colorVal, internalElements)}</a:solidFill>`;
|
|
1394
1923
|
break;
|
|
1395
1924
|
case 'gradient':
|
|
1396
1925
|
case 'linearGradient':
|
|
1397
|
-
outText += createGradientFillElement(
|
|
1926
|
+
outText += createGradientFillElement(isBareColor ? undefined : resolveGradientProps(props), colorVal || '', internalElements);
|
|
1398
1927
|
break;
|
|
1399
1928
|
case 'pattern':
|
|
1400
|
-
outText += createPatternFillElement(
|
|
1929
|
+
outText += createPatternFillElement(isBareColor ? undefined : props.pattern, typeof colorVal === 'string' ? colorVal : isModifiedThemeColor(colorVal) ? String(colorVal.baseColor) : (/* inlined export .DEF_FONT_COLOR */"000000"));
|
|
1930
|
+
break;
|
|
1931
|
+
case 'image':
|
|
1932
|
+
{
|
|
1933
|
+
var _ref;
|
|
1934
|
+
const image = isBareColor ? undefined : props.image;
|
|
1935
|
+
const rId = (_ref = image === null || image === void 0 ? void 0 : image._rId) !== null && _ref !== void 0 ? _ref : isBareColor ? undefined : props._rId;
|
|
1936
|
+
if (rId) {
|
|
1937
|
+
outText += createImageFillElement(image !== null && image !== void 0 ? image : {}, rId);
|
|
1938
|
+
} else {
|
|
1939
|
+
console.warn('[pptxgenjs] `fill.type:"image"` requires `fill.image.data` or `fill.image.path` - fill omitted');
|
|
1940
|
+
}
|
|
1941
|
+
break;
|
|
1942
|
+
}
|
|
1943
|
+
case 'group':
|
|
1944
|
+
outText += '<a:grpFill/>';
|
|
1401
1945
|
break;
|
|
1402
1946
|
case 'none':
|
|
1403
1947
|
outText += '<a:noFill/>';
|
|
@@ -1427,8 +1971,8 @@ function createGlowElement(glow) {
|
|
|
1427
1971
|
// Work on a copy - never mutate the caller's options object
|
|
1428
1972
|
ShadowProps = _object_spread({}, ShadowProps);
|
|
1429
1973
|
// OPT: `type`
|
|
1430
|
-
if (ShadowProps.type !== 'outer' && ShadowProps.type !== 'inner' && ShadowProps.type !== 'none') {
|
|
1431
|
-
console.warn('Warning: shadow.type options are `outer`, `inner` or `none`.');
|
|
1974
|
+
if (ShadowProps.type !== 'outer' && ShadowProps.type !== 'inner' && ShadowProps.type !== 'none' && ShadowProps.type !== 'preset') {
|
|
1975
|
+
console.warn('Warning: shadow.type options are `outer`, `inner`, `preset` or `none`.');
|
|
1432
1976
|
ShadowProps.type = 'outer';
|
|
1433
1977
|
}
|
|
1434
1978
|
// OPT: `angle`
|
|
@@ -2323,6 +2867,190 @@ function gen_tables_object_spread(target) {
|
|
|
2323
2867
|
});
|
|
2324
2868
|
}
|
|
2325
2869
|
|
|
2870
|
+
;// CONCATENATED MODULE: ./src/xml/hyperlink.ts
|
|
2871
|
+
/**
|
|
2872
|
+
* Hyperlinks and mouse-over actions.
|
|
2873
|
+
*
|
|
2874
|
+
* DrawingML gives the same concept two element names depending on where it appears:
|
|
2875
|
+
*
|
|
2876
|
+
* | host | click | mouse-over |
|
|
2877
|
+
* | :-- | :-- | :-- |
|
|
2878
|
+
* | `p:cNvPr` (shapes, pictures) | `a:hlinkClick` (20.1.2.2.22) | `a:hlinkHover` (20.1.2.2.23) |
|
|
2879
|
+
* | `a:rPr` (text runs) | `a:hlinkClick` | `a:hlinkMouseOver` (21.1.2.3.6) |
|
|
2880
|
+
*
|
|
2881
|
+
* Emitting `a:hlinkHover` inside `a:rPr` — or `a:hlinkMouseOver` inside `p:cNvPr` — produces markup
|
|
2882
|
+
* PowerPoint cannot parse, so the host decides the element name here rather than at each call site.
|
|
2883
|
+
*/
|
|
2884
|
+
/**
|
|
2885
|
+
* Build one `a:hlinkClick` / mouse-over element
|
|
2886
|
+
* @param {HyperlinkProps} link - link props
|
|
2887
|
+
* @param {'click' | 'hover'} trigger - which interaction this element describes
|
|
2888
|
+
* @param {HyperlinkHost} host - the element the link is attached to
|
|
2889
|
+
* @param {string} children - child elements (`a:snd`, `a:extLst`); self-closes when empty
|
|
2890
|
+
* @returns {string} XML string
|
|
2891
|
+
*/ function genXmlHyperlink(link, trigger, host, children = '') {
|
|
2892
|
+
var _link__rId;
|
|
2893
|
+
const tag = trigger === 'click' ? 'a:hlinkClick' : host === 'run' ? 'a:hlinkMouseOver' : 'a:hlinkHover';
|
|
2894
|
+
let attrs = `r:id="rId${(_link__rId = link._rId) !== null && _link__rId !== void 0 ? _link__rId : 0}"`;
|
|
2895
|
+
if (link.slide) {
|
|
2896
|
+
// an internal jump has no URL; the action attribute names the target kind
|
|
2897
|
+
attrs += ' action="ppaction://hlinksldjump"';
|
|
2898
|
+
} else {
|
|
2899
|
+
attrs += ' invalidUrl="" action="" tgtFrame=""';
|
|
2900
|
+
}
|
|
2901
|
+
attrs += ` tooltip="${link.tooltip ? encodeXmlEntities(link.tooltip) : ''}"`;
|
|
2902
|
+
if (!link.slide) attrs += ' history="1"';
|
|
2903
|
+
// both default to false in the schema, so only write them when turned on
|
|
2904
|
+
if (link.highlightClick === true) attrs += ' highlightClick="1"';
|
|
2905
|
+
if (link.stopSoundsOnClick === true) attrs += ' endSnd="1"';
|
|
2906
|
+
const sound = genXmlHyperlinkSound(link);
|
|
2907
|
+
const inner = sound + children;
|
|
2908
|
+
return inner ? `<${tag} ${attrs}>${inner}</${tag}>` : `<${tag} ${attrs}/>`;
|
|
2909
|
+
}
|
|
2910
|
+
/**
|
|
2911
|
+
* Build the `a:snd` action sound (ECMA-376 20.1.2.2.32 `CT_EmbeddedWAVAudioFile`)
|
|
2912
|
+
* - the relationship is resolved when the object is created, so `_sndRId` is set by then
|
|
2913
|
+
* @param {HyperlinkProps} link - link props
|
|
2914
|
+
* @returns {string} XML string
|
|
2915
|
+
*/ function genXmlHyperlinkSound(link) {
|
|
2916
|
+
var _link_sound_name;
|
|
2917
|
+
var _link_sound;
|
|
2918
|
+
if (!((_link_sound = link.sound) === null || _link_sound === void 0 ? void 0 : _link_sound._sndRId)) return '';
|
|
2919
|
+
return `<a:snd r:embed="rId${link.sound._sndRId}" name="${encodeXmlEntities((_link_sound_name = link.sound.name) !== null && _link_sound_name !== void 0 ? _link_sound_name : 'sound.wav')}"/>`;
|
|
2920
|
+
}
|
|
2921
|
+
|
|
2922
|
+
;// CONCATENATED MODULE: ./src/xml/line.ts
|
|
2923
|
+
function line_define_property(obj, key, value) {
|
|
2924
|
+
if (key in obj) {
|
|
2925
|
+
Object.defineProperty(obj, key, {
|
|
2926
|
+
value: value,
|
|
2927
|
+
enumerable: true,
|
|
2928
|
+
configurable: true,
|
|
2929
|
+
writable: true
|
|
2930
|
+
});
|
|
2931
|
+
} else obj[key] = value;
|
|
2932
|
+
return obj;
|
|
2933
|
+
}
|
|
2934
|
+
function line_object_spread(target) {
|
|
2935
|
+
for(var i = 1; i < arguments.length; i++){
|
|
2936
|
+
var source = arguments[i] != null ? arguments[i] : {};
|
|
2937
|
+
var ownKeys = Object.keys(source);
|
|
2938
|
+
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
2939
|
+
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
2940
|
+
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
2941
|
+
}));
|
|
2942
|
+
}
|
|
2943
|
+
ownKeys.forEach(function(key) {
|
|
2944
|
+
line_define_property(target, key, source[key]);
|
|
2945
|
+
});
|
|
2946
|
+
}
|
|
2947
|
+
return target;
|
|
2948
|
+
}
|
|
2949
|
+
function line_ownKeys(object, enumerableOnly) {
|
|
2950
|
+
var keys = Object.keys(object);
|
|
2951
|
+
if (Object.getOwnPropertySymbols) {
|
|
2952
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
2953
|
+
if (enumerableOnly) {
|
|
2954
|
+
symbols = symbols.filter(function(sym) {
|
|
2955
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
2956
|
+
});
|
|
2957
|
+
}
|
|
2958
|
+
keys.push.apply(keys, symbols);
|
|
2959
|
+
}
|
|
2960
|
+
return keys;
|
|
2961
|
+
}
|
|
2962
|
+
function line_object_spread_props(target, source) {
|
|
2963
|
+
source = source != null ? source : {};
|
|
2964
|
+
if (Object.getOwnPropertyDescriptors) Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
2965
|
+
else {
|
|
2966
|
+
line_ownKeys(Object(source)).forEach(function(key) {
|
|
2967
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
2968
|
+
});
|
|
2969
|
+
}
|
|
2970
|
+
return target;
|
|
2971
|
+
}
|
|
2972
|
+
/**
|
|
2973
|
+
* PptxGenJS: Line properties (`a:ln` and its aliases)
|
|
2974
|
+
*
|
|
2975
|
+
* The same `CT_LineProperties` content model is used by shape outlines (`a:ln`), underlines
|
|
2976
|
+
* (`a:uLn`), and table cell borders, so the element name is a parameter rather than baked in.
|
|
2977
|
+
*/
|
|
2978
|
+
|
|
2979
|
+
/**
|
|
2980
|
+
* Create a line element
|
|
2981
|
+
* @param {ShapeLineProps} line - line options
|
|
2982
|
+
* @param {string} tag - element name; `a:ln` for a shape outline, `a:uLn` for an underline
|
|
2983
|
+
* @return {string} XML
|
|
2984
|
+
*/ function genXmlLine(line, tag = 'a:ln') {
|
|
2985
|
+
// ECMA-376 §5.1.2.1.34: `<a:ln>` carries `w`, `cap`, and `cmpd` attributes
|
|
2986
|
+
const cap = line.cap && [
|
|
2987
|
+
'flat',
|
|
2988
|
+
'sq',
|
|
2989
|
+
'rnd'
|
|
2990
|
+
].includes(line.cap) ? ` cap="${line.cap}"` : '';
|
|
2991
|
+
const compound = COMPOUND_TYPES.has(String(line.compound)) ? ` cmpd="${String(line.compound)}"` : '';
|
|
2992
|
+
if (line.compound && !COMPOUND_TYPES.has(String(line.compound))) {
|
|
2993
|
+
console.warn(`[pptxgenjs] line \`compound\` must be one of ${[
|
|
2994
|
+
...COMPOUND_TYPES
|
|
2995
|
+
].join(', ')} - "${String(line.compound)}" ignored`);
|
|
2996
|
+
}
|
|
2997
|
+
const attrs = (line.width ? ` w="${valToPts(line.width)}"` : '') + cap + compound;
|
|
2998
|
+
let xml = `<${tag}${attrs}>`;
|
|
2999
|
+
const hasGrad = !!(line.gradient || line.type === 'gradient' || line.type === 'linearGradient');
|
|
3000
|
+
if (line.type !== 'none' && (line.color || hasGrad)) {
|
|
3001
|
+
xml += genXmlColorSelection(hasGrad && !line.type ? line_object_spread_props(line_object_spread({}, line), {
|
|
3002
|
+
type: 'gradient'
|
|
3003
|
+
}) : line);
|
|
3004
|
+
}
|
|
3005
|
+
// CT_LineProperties sequence: fill, dash, join, headEnd, tailEnd. A custom pattern replaces
|
|
3006
|
+
// the preset one - emitting both would be ambiguous, since `a:custDash` is the same choice.
|
|
3007
|
+
xml += genXmlDash(line);
|
|
3008
|
+
xml += genXmlJoin(line);
|
|
3009
|
+
xml += genXmlArrow('a:headEnd', line.beginArrowType, line.beginArrowSize);
|
|
3010
|
+
xml += genXmlArrow('a:tailEnd', line.endArrowType, line.endArrowSize);
|
|
3011
|
+
xml += `</${tag}>`;
|
|
3012
|
+
return xml;
|
|
3013
|
+
}
|
|
3014
|
+
/** The dash choice: a custom pattern when given, otherwise the preset */ function genXmlDash(line) {
|
|
3015
|
+
var _line_custDash;
|
|
3016
|
+
const stops = ((_line_custDash = line.custDash) !== null && _line_custDash !== void 0 ? _line_custDash : []).filter((stop)=>{
|
|
3017
|
+
const ok = typeof (stop === null || stop === void 0 ? void 0 : stop.dash) === 'number' && isFinite(stop.dash) && stop.dash > 0 && typeof stop.space === 'number' && isFinite(stop.space) && stop.space >= 0;
|
|
3018
|
+
if (!ok) console.warn('[pptxgenjs] each `custDash` stop needs a positive `dash` and a non-negative `space` (percent of line width) - stop ignored');
|
|
3019
|
+
return ok;
|
|
3020
|
+
});
|
|
3021
|
+
if (stops.length > 0) {
|
|
3022
|
+
const items = stops.map((stop)=>`<a:ds d="${Math.round(stop.dash * 1000)}" sp="${Math.round(stop.space * 1000)}"/>`).join('');
|
|
3023
|
+
return `<a:custDash>${items}</a:custDash>`;
|
|
3024
|
+
}
|
|
3025
|
+
return line.dashType ? `<a:prstDash val="${line.dashType}"/>` : '';
|
|
3026
|
+
}
|
|
3027
|
+
/** The join choice: `a:round`, `a:bevel`, or `a:miter` with its limit */ function genXmlJoin(line) {
|
|
3028
|
+
if (!line.join) return '';
|
|
3029
|
+
if (line.join === 'round') return '<a:round/>';
|
|
3030
|
+
if (line.join === 'bevel') return '<a:bevel/>';
|
|
3031
|
+
if (line.join === 'miter') {
|
|
3032
|
+
const lim = typeof line.miterLimit === 'number' && isFinite(line.miterLimit) && line.miterLimit >= 0 ? line.miterLimit : 800;
|
|
3033
|
+
return `<a:miter lim="${Math.round(lim * 1000)}"/>`;
|
|
3034
|
+
}
|
|
3035
|
+
console.warn(`[pptxgenjs] line \`join\` must be 'round' | 'bevel' | 'miter' - "${String(line.join)}" ignored`);
|
|
3036
|
+
return '';
|
|
3037
|
+
}
|
|
3038
|
+
function resolveArrowSize(size) {
|
|
3039
|
+
if (!size) return undefined;
|
|
3040
|
+
if (typeof size === 'string') return {
|
|
3041
|
+
width: size,
|
|
3042
|
+
length: size
|
|
3043
|
+
};
|
|
3044
|
+
return size;
|
|
3045
|
+
}
|
|
3046
|
+
/** An arrow end with its optional sizing */ function genXmlArrow(tag, type, size) {
|
|
3047
|
+
if (!type) return '';
|
|
3048
|
+
const resolved = resolveArrowSize(size);
|
|
3049
|
+
const w = ARROW_SIZES.has(String(resolved === null || resolved === void 0 ? void 0 : resolved.width)) ? ` w="${String(resolved === null || resolved === void 0 ? void 0 : resolved.width)}"` : '';
|
|
3050
|
+
const len = ARROW_SIZES.has(String(resolved === null || resolved === void 0 ? void 0 : resolved.length)) ? ` len="${String(resolved === null || resolved === void 0 ? void 0 : resolved.length)}"` : '';
|
|
3051
|
+
return `<${tag} type="${type}"${w}${len}/>`;
|
|
3052
|
+
}
|
|
3053
|
+
|
|
2326
3054
|
;// CONCATENATED MODULE: ./src/xml/text.ts
|
|
2327
3055
|
function text_define_property(obj, key, value) {
|
|
2328
3056
|
if (key in obj) {
|
|
@@ -2376,6 +3104,7 @@ function text_object_spread_props(target, source) {
|
|
|
2376
3104
|
/**
|
|
2377
3105
|
* Text-body, run, and placeholder rendering.
|
|
2378
3106
|
*/
|
|
3107
|
+
|
|
2379
3108
|
/** ECMA-376 §5.1.12.76 `ST_TextShapeType` — used to validate `a:prstTxWarp@prst`. */ const TEXT_SHAPE_TYPES = new Set([
|
|
2380
3109
|
'textNoShape',
|
|
2381
3110
|
'textPlain',
|
|
@@ -2420,6 +3149,26 @@ function text_object_spread_props(target, source) {
|
|
|
2420
3149
|
'textCascadeDown'
|
|
2421
3150
|
]);
|
|
2422
3151
|
|
|
3152
|
+
|
|
3153
|
+
/**
|
|
3154
|
+
* Build the `a:buClr` / `a:buSzPct` / `a:buSzPts` / `a:buFont` prefix shared by every bullet kind
|
|
3155
|
+
* - the size defaults to 100% because that is what every branch emitted before
|
|
3156
|
+
*/ function genXmlBulletPrefix(bullet) {
|
|
3157
|
+
let xml = '';
|
|
3158
|
+
if (bullet.color) xml += `<a:buClr>${createColorElement(bullet.color)}</a:buClr>`;
|
|
3159
|
+
// `a:buSzPct` and `a:buSzPts` are the same choice, so only one may appear
|
|
3160
|
+
if (typeof bullet.sizePts === 'number' && isFinite(bullet.sizePts) && bullet.sizePts > 0) {
|
|
3161
|
+
xml += `<a:buSzPts val="${Math.round(bullet.sizePts * 100)}"/>`;
|
|
3162
|
+
} else {
|
|
3163
|
+
const pct = typeof bullet.size === 'number' && isFinite(bullet.size) ? Math.min(400, Math.max(25, bullet.size)) : 100;
|
|
3164
|
+
if (typeof bullet.size === 'number' && (bullet.size < 25 || bullet.size > 400)) {
|
|
3165
|
+
console.warn(`[pptxgenjs] bullet \`size\` must be between 25 and 400 percent - "${String(bullet.size)}" clamped`);
|
|
3166
|
+
}
|
|
3167
|
+
xml += `<a:buSzPct val="${Math.round(pct * 1000)}"/>`;
|
|
3168
|
+
}
|
|
3169
|
+
if (bullet.fontFace) xml += `<a:buFont typeface="${encodeXmlEntities(bullet.fontFace)}"/>`;
|
|
3170
|
+
return xml;
|
|
3171
|
+
}
|
|
2423
3172
|
/**
|
|
2424
3173
|
* Generate XML Paragraph Properties
|
|
2425
3174
|
* @param {ISlideObject|TextProps} textObj - text object
|
|
@@ -2428,7 +3177,6 @@ function text_object_spread_props(target, source) {
|
|
|
2428
3177
|
*/ function genXmlParagraphProperties(textObj, isDefault) {
|
|
2429
3178
|
var _textObj_options;
|
|
2430
3179
|
let strXmlBullet = '';
|
|
2431
|
-
let strXmlBulletColor = '';
|
|
2432
3180
|
let strXmlLnSpc = '';
|
|
2433
3181
|
let strXmlParaSpc = '';
|
|
2434
3182
|
let strXmlTabStops = '';
|
|
@@ -2467,6 +3215,21 @@ function text_object_spread_props(target, source) {
|
|
|
2467
3215
|
if (options.indentLevel && !isNaN(Number(options.indentLevel)) && options.indentLevel > 0) {
|
|
2468
3216
|
paragraphPropXml += ` lvl="${options.indentLevel}"`;
|
|
2469
3217
|
}
|
|
3218
|
+
// Remaining CT_TextParagraphProperties attributes - omitted unless set
|
|
3219
|
+
const para = options;
|
|
3220
|
+
if (typeof para.marR === 'number' && isFinite(para.marR) && para.marR >= 0) paragraphPropXml += ` marR="${inch2Emu(para.marR)}"`;
|
|
3221
|
+
if (typeof para.defTabSz === 'number' && isFinite(para.defTabSz) && para.defTabSz > 0) paragraphPropXml += ` defTabSz="${inch2Emu(para.defTabSz)}"`;
|
|
3222
|
+
if ([
|
|
3223
|
+
'auto',
|
|
3224
|
+
't',
|
|
3225
|
+
'ctr',
|
|
3226
|
+
'base',
|
|
3227
|
+
'b'
|
|
3228
|
+
].includes(String(para.fontAlgn))) paragraphPropXml += ` fontAlgn="${String(para.fontAlgn)}"`;
|
|
3229
|
+
// these three default to true in the schema, so only write them when turned off
|
|
3230
|
+
if (para.eaLnBrk === false) paragraphPropXml += ' eaLnBrk="0"';
|
|
3231
|
+
if (para.latinLnBrk === false) paragraphPropXml += ' latinLnBrk="0"';
|
|
3232
|
+
if (para.hangingPunct === false) paragraphPropXml += ' hangingPunct="0"';
|
|
2470
3233
|
// OPTION: Paragraph Spacing: Before/After
|
|
2471
3234
|
if (options.paraSpaceBefore && !isNaN(Number(options.paraSpaceBefore)) && options.paraSpaceBefore > 0) {
|
|
2472
3235
|
strXmlParaSpc += `<a:spcBef><a:spcPts val="${Math.round(options.paraSpaceBefore * 100)}"/></a:spcBef>`;
|
|
@@ -2480,10 +3243,17 @@ function text_object_spread_props(target, source) {
|
|
|
2480
3243
|
if (typeof options.bullet === 'object') {
|
|
2481
3244
|
var _options_bullet;
|
|
2482
3245
|
if ((_options_bullet = options.bullet) === null || _options_bullet === void 0 ? void 0 : _options_bullet.indent) bulletMarL = valToPts(options.bullet.indent);
|
|
2483
|
-
|
|
3246
|
+
const buPrefix = genXmlBulletPrefix(options.bullet);
|
|
3247
|
+
const buIndent = ` marL="${options.indentLevel && options.indentLevel > 0 ? bulletMarL + bulletMarL * options.indentLevel : bulletMarL}" indent="-${bulletMarL}"`;
|
|
3248
|
+
if (options.bullet.image && options.bullet._imageRId) {
|
|
3249
|
+
// `a:buBlip` replaces the character or number bullet entirely
|
|
3250
|
+
paragraphPropXml += buIndent;
|
|
3251
|
+
strXmlBullet = `${buPrefix}<a:buBlip><a:blip r:embed="rId${options.bullet._imageRId}"/></a:buBlip>`;
|
|
3252
|
+
} else if (options.bullet.type && options.bullet.type.toString().toLowerCase() === 'number') {
|
|
2484
3253
|
// NOTE: only `type: 'number'` is a distinct branch; any other `type` (e.g. 'bullet') falls through to the char-bullet cases below (issue #1432)
|
|
2485
|
-
paragraphPropXml +=
|
|
2486
|
-
|
|
3254
|
+
paragraphPropXml += buIndent;
|
|
3255
|
+
// auto-numbered bullets fall back to the major latin face when none is given
|
|
3256
|
+
strXmlBullet = `${buPrefix}${options.bullet.fontFace ? '' : '<a:buFont typeface="+mj-lt"/>'}<a:buAutoNum type="${options.bullet.numberType || options.bullet.style || 'arabicPeriod'}" startAt="${options.bullet.numberStartAt || options.bullet.startAt || '1'}"/>`;
|
|
2487
3257
|
} else if (options.bullet.characterCode) {
|
|
2488
3258
|
let bulletCode = `&#x${options.bullet.characterCode};`;
|
|
2489
3259
|
// Check value for hex-ness (s/b 4 char hex)
|
|
@@ -2491,8 +3261,8 @@ function text_object_spread_props(target, source) {
|
|
|
2491
3261
|
console.warn('Warning: `bullet.characterCode should be a 4-digit unicode charatcer (ex: 22AB)`!');
|
|
2492
3262
|
bulletCode = (/* inlined export .BULLET_TYPES.DEFAULT */"•");
|
|
2493
3263
|
}
|
|
2494
|
-
paragraphPropXml +=
|
|
2495
|
-
strXmlBullet =
|
|
3264
|
+
paragraphPropXml += buIndent;
|
|
3265
|
+
strXmlBullet = `${buPrefix}<a:buChar char="${bulletCode}"/>`;
|
|
2496
3266
|
} else if (options.bullet.code) {
|
|
2497
3267
|
// @deprecated `bullet.code` v3.3.0
|
|
2498
3268
|
let bulletCode = `&#x${options.bullet.code};`;
|
|
@@ -2501,15 +3271,11 @@ function text_object_spread_props(target, source) {
|
|
|
2501
3271
|
console.warn('Warning: `bullet.code should be a 4-digit hex code (ex: 22AB)`!');
|
|
2502
3272
|
bulletCode = (/* inlined export .BULLET_TYPES.DEFAULT */"•");
|
|
2503
3273
|
}
|
|
2504
|
-
paragraphPropXml +=
|
|
2505
|
-
strXmlBullet =
|
|
3274
|
+
paragraphPropXml += buIndent;
|
|
3275
|
+
strXmlBullet = `${buPrefix}<a:buChar char="${bulletCode}"/>`;
|
|
2506
3276
|
} else {
|
|
2507
|
-
paragraphPropXml +=
|
|
2508
|
-
strXmlBullet =
|
|
2509
|
-
}
|
|
2510
|
-
// mikemeerschaert/add-color-option-to-bullets — buClr must precede buSz*/buChar (OOXML order)
|
|
2511
|
-
if (options.bullet.color) {
|
|
2512
|
-
strXmlBulletColor = `<a:buClr>${createColorElement(options.bullet.color)}</a:buClr>`;
|
|
3277
|
+
paragraphPropXml += buIndent;
|
|
3278
|
+
strXmlBullet = `${buPrefix}<a:buChar char="${(/* inlined export .BULLET_TYPES.DEFAULT */"•")}"/>`;
|
|
2513
3279
|
}
|
|
2514
3280
|
} else if (options.bullet) {
|
|
2515
3281
|
paragraphPropXml += ` marL="${options.indentLevel && options.indentLevel > 0 ? bulletMarL + bulletMarL * options.indentLevel : bulletMarL}" indent="-${bulletMarL}"`;
|
|
@@ -2526,7 +3292,7 @@ function text_object_spread_props(target, source) {
|
|
|
2526
3292
|
}
|
|
2527
3293
|
// B: Close Paragraph-Properties
|
|
2528
3294
|
// IMPORTANT: strXmlLnSpc, strXmlParaSpc, buClr, and strXmlBullet require strict ordering - anything out of order is ignored. (PPT-Online, PPT for Mac)
|
|
2529
|
-
paragraphPropXml += '>' + strXmlLnSpc + strXmlParaSpc +
|
|
3295
|
+
paragraphPropXml += '>' + strXmlLnSpc + strXmlParaSpc + strXmlBullet + strXmlTabStops;
|
|
2530
3296
|
if (isDefault) paragraphPropXml += genXmlTextRunProperties(options, true);
|
|
2531
3297
|
paragraphPropXml += '</' + tag + '>';
|
|
2532
3298
|
}
|
|
@@ -2538,7 +3304,7 @@ function text_object_spread_props(target, source) {
|
|
|
2538
3304
|
* @param {boolean} isDefault - whether these are the default text run properties
|
|
2539
3305
|
* @return {string} XML
|
|
2540
3306
|
*/ function genXmlTextRunProperties(opts, isDefault) {
|
|
2541
|
-
var _opts_underline;
|
|
3307
|
+
var _opts_underline, _opts_hyperlinkHover;
|
|
2542
3308
|
let runProps = '';
|
|
2543
3309
|
const runPropsTag = isDefault ? 'a:defRPr' : 'a:rPr';
|
|
2544
3310
|
// BEGIN runProperties (ex: `<a:rPr lang="en-US" sz="1600" b="1" dirty="0">`)
|
|
@@ -2570,9 +3336,14 @@ function text_object_spread_props(target, source) {
|
|
|
2570
3336
|
'small',
|
|
2571
3337
|
'all'
|
|
2572
3338
|
].includes(opts.caps) ? ` cap="${opts.caps}"` : '';
|
|
2573
|
-
runProps += '
|
|
2574
|
-
|
|
2575
|
-
if (
|
|
3339
|
+
if (opts.kumimoji === true) runProps += ' kumimoji="1"';
|
|
3340
|
+
const run = opts;
|
|
3341
|
+
if (run.normalizeH === true) runProps += ' normalizeH="1"';
|
|
3342
|
+
if (run.noProof === true) runProps += ' noProof="1"';
|
|
3343
|
+
// `dirty` was hardcoded to 0; it stays the default so existing output does not change
|
|
3344
|
+
runProps += ` dirty="${run.dirty === true ? '1' : '0'}">`;
|
|
3345
|
+
// CT_TextCharacterProperties child order: ln, fill, effect, highlight, uLn, uFill, latin, ea, cs, sym
|
|
3346
|
+
if (opts.color || opts.gradient || opts.fontFace || opts.fontFaceEa || opts.fontFaceCs || opts.fontFaceSym || opts.outline || opts.glow || opts.highlight || run.underlineLine || typeof opts.underline === 'object' && opts.underline.color) {
|
|
2576
3347
|
if (opts.outline && typeof opts.outline === 'object') {
|
|
2577
3348
|
runProps += `<a:ln w="${valToPts(opts.outline.size || 0.75)}">${genXmlColorSelection({
|
|
2578
3349
|
color: opts.outline.color || 'FFFFFF',
|
|
@@ -2589,10 +3360,12 @@ function text_object_spread_props(target, source) {
|
|
|
2589
3360
|
color: opts.color,
|
|
2590
3361
|
transparency: opts.transparency
|
|
2591
3362
|
});
|
|
2592
|
-
if (opts.highlight) runProps += `<a:highlight>${createColorElement(opts.highlight)}</a:highlight>`;
|
|
2593
|
-
if (typeof opts.underline === 'object' && opts.underline.color) runProps += `<a:uFill>${genXmlColorSelection(opts.underline.color)}</a:uFill>`;
|
|
2594
3363
|
const resolvedGlow = resolveGlowOptions(opts.glow);
|
|
2595
3364
|
if (resolvedGlow) runProps += `<a:effectLst>${createGlowElement(resolvedGlow)}</a:effectLst>`;
|
|
3365
|
+
if (opts.highlight) runProps += `<a:highlight>${createColorElement(opts.highlight)}</a:highlight>`;
|
|
3366
|
+
if (run.underlineLine === 'text') runProps += '<a:uLnTx/>';
|
|
3367
|
+
else if (run.underlineLine && typeof run.underlineLine === 'object') runProps += genXmlLine(run.underlineLine, 'a:uLn');
|
|
3368
|
+
if (typeof opts.underline === 'object' && opts.underline.color) runProps += `<a:uFill>${genXmlColorSelection(opts.underline.color)}</a:uFill>`;
|
|
2596
3369
|
const latin = opts.fontFace;
|
|
2597
3370
|
const ea = opts.fontFaceEa || opts.fontFace;
|
|
2598
3371
|
const cs = opts.fontFaceCs || opts.fontFace;
|
|
@@ -2602,26 +3375,19 @@ function text_object_spread_props(target, source) {
|
|
|
2602
3375
|
if (ea) runProps += `<a:ea typeface="${encodeXmlEntities(ea)}" pitchFamily="34" charset="-122"/>`;
|
|
2603
3376
|
if (cs) runProps += `<a:cs typeface="${encodeXmlEntities(cs)}" pitchFamily="34" charset="-120"/>`;
|
|
2604
3377
|
}
|
|
3378
|
+
if (opts.fontFaceSym) runProps += `<a:sym typeface="${encodeXmlEntities(opts.fontFaceSym)}"/>`;
|
|
2605
3379
|
}
|
|
2606
3380
|
// Hyperlink support
|
|
2607
3381
|
if (opts.hyperlink) {
|
|
2608
3382
|
if (typeof opts.hyperlink !== 'object') throw new Error('ERROR: text `hyperlink` option should be an object. Ex: `hyperlink:{url:\'https://github.com\'}` ');
|
|
2609
3383
|
else if (!opts.hyperlink.url && !opts.hyperlink.slide) throw new Error('ERROR: \'hyperlink requires either `url` or `slide`\'');
|
|
2610
|
-
|
|
2611
|
-
|
|
2612
|
-
|
|
2613
|
-
|
|
2614
|
-
runProps += `<a:hlinkClick r:id="rId${opts.hyperlink._rId}" action="ppaction://hlinksldjump" tooltip="${opts.hyperlink.tooltip ? encodeXmlEntities(opts.hyperlink.tooltip) : ''}"${opts.color ? '>' : '/>'}`;
|
|
2615
|
-
}
|
|
2616
|
-
if (opts.color) {
|
|
2617
|
-
runProps += ' <a:extLst>';
|
|
2618
|
-
runProps += ' <a:ext uri="{A12FA001-AC4F-418D-AE19-62706E023703}">';
|
|
2619
|
-
runProps += ' <ahyp:hlinkClr xmlns:ahyp="http://schemas.microsoft.com/office/drawing/2018/hyperlinkcolor" val="tx"/>';
|
|
2620
|
-
runProps += ' </a:ext>';
|
|
2621
|
-
runProps += ' </a:extLst>';
|
|
2622
|
-
runProps += '</a:hlinkClick>';
|
|
2623
|
-
}
|
|
3384
|
+
// A colored link keeps its run color instead of the theme's hyperlink color (issue #74: an
|
|
3385
|
+
// `a:uFill` here breaks PPT2010, so the extension is used rather than an underline fill)
|
|
3386
|
+
const linkColorExt = opts.color ? '<a:extLst><a:ext uri="{A12FA001-AC4F-418D-AE19-62706E023703}"><ahyp:hlinkClr xmlns:ahyp="http://schemas.microsoft.com/office/drawing/2018/hyperlinkcolor" val="tx"/></a:ext></a:extLst>' : '';
|
|
3387
|
+
runProps += genXmlHyperlink(opts.hyperlink, 'click', 'run', linkColorExt);
|
|
2624
3388
|
}
|
|
3389
|
+
// `a:hlinkMouseOver` follows `a:hlinkClick` in CT_TextCharacterProperties
|
|
3390
|
+
if ((_opts_hyperlinkHover = opts.hyperlinkHover) === null || _opts_hyperlinkHover === void 0 ? void 0 : _opts_hyperlinkHover._rId) runProps += genXmlHyperlink(opts.hyperlinkHover, 'hover', 'run');
|
|
2625
3391
|
// END runProperties
|
|
2626
3392
|
runProps += `</${runPropsTag}>`;
|
|
2627
3393
|
return runProps;
|
|
@@ -2660,6 +3426,15 @@ const P1710_NS = 'http://schemas.microsoft.com/office/powerpoint/2017/10/main';
|
|
|
2660
3426
|
}
|
|
2661
3427
|
return `<a14:m xmlns:a14="${A14_NS}">${trimmed}</a14:m>`;
|
|
2662
3428
|
}
|
|
3429
|
+
/**
|
|
3430
|
+
* A stable GUID for a field, derived from its type and cached value
|
|
3431
|
+
* - `a:fld@id` must be a GUID; deriving it keeps repeated exports byte-identical
|
|
3432
|
+
*/ function fieldGuid(type, cached) {
|
|
3433
|
+
let hash = 0;
|
|
3434
|
+
for (const char of `${type}:${cached}`)hash = hash * 31 + char.charCodeAt(0) >>> 0;
|
|
3435
|
+
const hex = hash.toString(16).padStart(8, '0');
|
|
3436
|
+
return `{${hex}-0000-0000-0000-${hex}0000}`;
|
|
3437
|
+
}
|
|
2663
3438
|
function textRunsHaveOmml(text) {
|
|
2664
3439
|
if (!Array.isArray(text)) return false;
|
|
2665
3440
|
return text.some((t)=>{
|
|
@@ -2669,7 +3444,7 @@ function textRunsHaveOmml(text) {
|
|
|
2669
3444
|
}
|
|
2670
3445
|
function genXmlTextRun(textObj) {
|
|
2671
3446
|
var _textObj_options;
|
|
2672
|
-
var _textObj_options1;
|
|
3447
|
+
var _textObj_options1, _textObj_options2;
|
|
2673
3448
|
// Native Office Math run — editable in PowerPoint (not an image).
|
|
2674
3449
|
const omml = (_textObj_options1 = textObj.options) === null || _textObj_options1 === void 0 ? void 0 : _textObj_options1.omml;
|
|
2675
3450
|
if (typeof omml === 'string' && omml.trim()) {
|
|
@@ -2700,7 +3475,18 @@ function genXmlTextRun(textObj) {
|
|
|
2700
3475
|
</a:r>
|
|
2701
3476
|
<a:endParaRPr lang="en-US" dirty="0"/>
|
|
2702
3477
|
</a:p>
|
|
2703
|
-
*/
|
|
3478
|
+
*/ /* A field is a run the consumer refreshes on open (ECMA-376 21.1.2.2.4). The `a:t` child holds
|
|
3479
|
+
* the cached value so a consumer that does not refresh still renders something. `id` must be a
|
|
3480
|
+
* GUID; it is derived from the field type and text so repeated exports stay reproducible. */ const field = (_textObj_options2 = textObj.options) === null || _textObj_options2 === void 0 ? void 0 : _textObj_options2.field;
|
|
3481
|
+
if (field) {
|
|
3482
|
+
if (!TEXT_FIELD_TYPES.has(field)) {
|
|
3483
|
+
console.warn(`[pptxgenjs] unknown text field "${String(field)}" - run emitted as plain text instead`);
|
|
3484
|
+
} else {
|
|
3485
|
+
var _textObj_text, _textObj_options3, _textObj_text1;
|
|
3486
|
+
return `<a:fld id="${fieldGuid(field, (_textObj_text = textObj.text) !== null && _textObj_text !== void 0 ? _textObj_text : '')}" type="${field}">` + genXmlTextRunProperties((_textObj_options3 = textObj.options) !== null && _textObj_options3 !== void 0 ? _textObj_options3 : {}, false) + `<a:t>${encodeXmlEntities((_textObj_text1 = textObj.text) !== null && _textObj_text1 !== void 0 ? _textObj_text1 : '')}</a:t>` + '</a:fld>';
|
|
3487
|
+
}
|
|
3488
|
+
}
|
|
3489
|
+
// Return paragraph with text run
|
|
2704
3490
|
return textObj.text ? `<a:r>${genXmlTextRunProperties((_textObj_options = textObj.options) !== null && _textObj_options !== void 0 ? _textObj_options : {}, false)}<a:t>${encodeXmlEntities(textObj.text)}</a:t></a:r>` : '';
|
|
2705
3491
|
}
|
|
2706
3492
|
/**
|
|
@@ -2722,13 +3508,22 @@ function genXmlTextRun(textObj) {
|
|
|
2722
3508
|
if (slideObject.options._bodyProp.tIns || slideObject.options._bodyProp.tIns === 0) bodyProperties += ` tIns="${slideObject.options._bodyProp.tIns}"`;
|
|
2723
3509
|
if (slideObject.options._bodyProp.rIns || slideObject.options._bodyProp.rIns === 0) bodyProperties += ` rIns="${slideObject.options._bodyProp.rIns}"`;
|
|
2724
3510
|
if (slideObject.options._bodyProp.bIns || slideObject.options._bodyProp.bIns === 0) bodyProperties += ` bIns="${slideObject.options._bodyProp.bIns}"`;
|
|
2725
|
-
//
|
|
2726
|
-
|
|
3511
|
+
// Remaining CT_TextBodyProperties attributes - each omitted unless asked for
|
|
3512
|
+
const body = slideObject.options;
|
|
3513
|
+
if (body.upright === true) bodyProperties += ' upright="1"';
|
|
3514
|
+
if (typeof body.textRotate === 'number' && isFinite(body.textRotate)) bodyProperties += ` rot="${convertRotationDegrees(body.textRotate)}"`;
|
|
3515
|
+
if (body.anchorCtr === true) bodyProperties += ' anchorCtr="1"';
|
|
3516
|
+
if (body.spcFirstLastPara === true) bodyProperties += ' spcFirstLastPara="1"';
|
|
3517
|
+
if (body.compatLnSpc === true) bodyProperties += ' compatLnSpc="1"';
|
|
3518
|
+
if (body.forceAA === true) bodyProperties += ' forceAA="1"';
|
|
2727
3519
|
// Text columns — ECMA-376 §5.1.5.1.4 CT_TextBodyProperties@numCol/@spcCol (issue #1320)
|
|
2728
3520
|
if (slideObject.options._bodyProp.numCol && slideObject.options._bodyProp.numCol > 1) {
|
|
2729
3521
|
bodyProperties += ` numCol="${slideObject.options._bodyProp.numCol}"`;
|
|
2730
3522
|
if (slideObject.options._bodyProp.spcCol) bodyProperties += ` spcCol="${slideObject.options._bodyProp.spcCol}"`;
|
|
2731
3523
|
}
|
|
3524
|
+
// `rtlCol` follows the text box's RTL mode unless overridden, so RTL columns flow correctly
|
|
3525
|
+
const rtlCols = typeof slideObject.options.rtlColumns === 'boolean' ? slideObject.options.rtlColumns : slideObject.options.rtlMode === true;
|
|
3526
|
+
bodyProperties += ` rtlCol="${rtlCols ? '1' : '0'}"`;
|
|
2732
3527
|
// D: Add anchorPoints
|
|
2733
3528
|
if (slideObject.options._bodyProp.anchor) bodyProperties += ' anchor="' + slideObject.options._bodyProp.anchor + '"'; // VALS: [t,ctr,b]
|
|
2734
3529
|
if (slideObject.options._bodyProp.vert) bodyProperties += ' vert="' + slideObject.options._bodyProp.vert + '"'; // VALS: [eaVert,horz,mongolianVert,vert,vert270,wordArtVert,wordArtVertRtl]
|
|
@@ -2764,7 +3559,9 @@ function genXmlTextRun(textObj) {
|
|
|
2764
3559
|
bodyProperties += '</a:bodyPr>';
|
|
2765
3560
|
} else {
|
|
2766
3561
|
// DEFAULT:
|
|
2767
|
-
|
|
3562
|
+
const opts = slideObject.options;
|
|
3563
|
+
const rtlCols = typeof (opts === null || opts === void 0 ? void 0 : opts.rtlColumns) === 'boolean' ? opts.rtlColumns : (opts === null || opts === void 0 ? void 0 : opts.rtlMode) === true;
|
|
3564
|
+
bodyProperties += ` wrap="square" rtlCol="${rtlCols ? '1' : '0'}">`;
|
|
2768
3565
|
bodyProperties += '</a:bodyPr>';
|
|
2769
3566
|
}
|
|
2770
3567
|
// LAST: Return Close _bodyProp
|
|
@@ -2851,6 +3648,8 @@ function genXmlTextRun(textObj) {
|
|
|
2851
3648
|
delete runOpts.softEdge;
|
|
2852
3649
|
delete runOpts.reflection;
|
|
2853
3650
|
delete runOpts.shadow;
|
|
3651
|
+
delete runOpts.fillOverlay;
|
|
3652
|
+
delete runOpts.effectDag;
|
|
2854
3653
|
itext.options = runOpts;
|
|
2855
3654
|
}
|
|
2856
3655
|
if (idx === 0 && itext.options && !itext.options.bullet && opts.bullet) itext.options.bullet = opts.bullet;
|
|
@@ -2966,7 +3765,7 @@ function genXmlTextRun(textObj) {
|
|
|
2966
3765
|
// NOTE: This loop will pick up unecessary keys (`x`, etc.), but it doesnt hurt anything
|
|
2967
3766
|
// `glow` / softEdge / reflection belong on the shape effectLst (not per-run), unless set on the run itself
|
|
2968
3767
|
// `omml` is a run-level math payload — inheriting it would replace sibling plain-text runs
|
|
2969
|
-
if (key === 'glow' || key === 'softEdge' || key === 'reflection' || key === 'shadow' || key === 'blur' || key === 'omml') return;
|
|
3768
|
+
if (key === 'glow' || key === 'softEdge' || key === 'reflection' || key === 'shadow' || key === 'blur' || key === 'fillOverlay' || key === 'effectDag' || key === 'omml') return;
|
|
2970
3769
|
if (key !== 'bullet' && !textOpts[key]) textOpts[key] = val;
|
|
2971
3770
|
});
|
|
2972
3771
|
// D: Add formatted textrun
|
|
@@ -3089,12 +3888,15 @@ const NS_P232 = 'http://schemas.microsoft.com/office/powerpoint/2023/02/main';
|
|
|
3089
3888
|
* @returns XML
|
|
3090
3889
|
*/ function genXmlPlaceholder(placeholderObj, extraOpts) {
|
|
3091
3890
|
var _ref;
|
|
3092
|
-
var _placeholderObj_options, _placeholderObj_options1, _placeholderObj_options2;
|
|
3891
|
+
var _placeholderObj_options, _placeholderObj_options1, _placeholderObj_options2, _placeholderObj_options3, _placeholderObj_options4, _placeholderObj_options5;
|
|
3093
3892
|
if (!placeholderObj) return '';
|
|
3094
3893
|
const placeholderIdx = ((_placeholderObj_options = placeholderObj.options) === null || _placeholderObj_options === void 0 ? void 0 : _placeholderObj_options._placeholderIdx) ? placeholderObj.options._placeholderIdx : '';
|
|
3095
3894
|
const placeholderType = resolvePlaceholderType((_placeholderObj_options1 = placeholderObj.options) === null || _placeholderObj_options1 === void 0 ? void 0 : _placeholderObj_options1._placeholderType);
|
|
3096
|
-
|
|
3097
|
-
const
|
|
3895
|
+
// `orient` and `sz` default to horz/full in the schema, so only a non-default is written
|
|
3896
|
+
const placeholderOrient = ((_placeholderObj_options2 = placeholderObj.options) === null || _placeholderObj_options2 === void 0 ? void 0 : _placeholderObj_options2.orient) === 'vert' ? ' orient="vert"' : '';
|
|
3897
|
+
const placeholderSize = ((_placeholderObj_options3 = placeholderObj.options) === null || _placeholderObj_options3 === void 0 ? void 0 : _placeholderObj_options3.sz) === 'half' || ((_placeholderObj_options4 = placeholderObj.options) === null || _placeholderObj_options4 === void 0 ? void 0 : _placeholderObj_options4.sz) === 'quarter' ? ` sz="${placeholderObj.options.sz}"` : '';
|
|
3898
|
+
const attrs = `${placeholderIdx ? ' idx="' + placeholderIdx.toString() + '"' : ''}` + `${placeholderType ? ` type="${placeholderType}"` : ''}` + placeholderOrient + placeholderSize + `${placeholderObj.text && placeholderObj.text.length > 0 ? ' hasCustomPrompt="1"' : ''}`;
|
|
3899
|
+
const phTypeExt = (_ref = extraOpts === null || extraOpts === void 0 ? void 0 : extraOpts.phTypeExt) !== null && _ref !== void 0 ? _ref : (_placeholderObj_options5 = placeholderObj.options) === null || _placeholderObj_options5 === void 0 ? void 0 : _placeholderObj_options5.phTypeExt;
|
|
3098
3900
|
if (phTypeExt === 'cameo' || phTypeExt === 'unknown') {
|
|
3099
3901
|
return `<p:ph${attrs}>` + `<p:extLst><p:ext uri="${URI_PH_TYPE_EXT}">` + `<p232:phTypeExt xmlns:p232="${NS_P232}"><p232:type><p232:${phTypeExt}/></p232:type></p232:phTypeExt>` + '</p:ext></p:extLst></p:ph>';
|
|
3100
3902
|
}
|
|
@@ -3440,6 +4242,10 @@ function _object_without_properties_loose(source, excluded) {
|
|
|
3440
4242
|
let tmpOpt;
|
|
3441
4243
|
let tmpData = [];
|
|
3442
4244
|
if (Array.isArray(type)) {
|
|
4245
|
+
// A chartex layout owns the whole `cx:plotArea` and cannot share one with an ECMA-376 chart type,
|
|
4246
|
+
// so a multi-type spec that names one would silently render as an empty frame
|
|
4247
|
+
const chartexSpec = type.find((obj)=>isChartexType(obj.type));
|
|
4248
|
+
if (chartexSpec) throw new Error(`pptxgenjs: chart type "${String(chartexSpec.type)}" cannot be combined in a multi-type chart`);
|
|
3443
4249
|
// For multi-type charts there needs to be data for each type,
|
|
3444
4250
|
// as well as a single data source for non-series operations.
|
|
3445
4251
|
// The data is indexed below to keep the data in order when segmented
|
|
@@ -3527,8 +4333,21 @@ function _object_without_properties_loose(source, excluded) {
|
|
|
3527
4333
|
// NOTE: a multi-type chart has no single type to validate against, so only the name translation applies there
|
|
3528
4334
|
if (options.dataLabelPosition) {
|
|
3529
4335
|
const chartType = Array.isArray(options._type) ? undefined : options._type;
|
|
3530
|
-
|
|
3531
|
-
|
|
4336
|
+
if (isChartexType(chartType)) {
|
|
4337
|
+
// `cx:dataLabels@pos` is its own vocabulary, not `c:dLblPos`; these three are the values the
|
|
4338
|
+
// shipped chartex writers emit, so anything else falls back to the layout's own default
|
|
4339
|
+
if (![
|
|
4340
|
+
'ctr',
|
|
4341
|
+
'inEnd',
|
|
4342
|
+
'outEnd'
|
|
4343
|
+
].includes(options.dataLabelPosition)) {
|
|
4344
|
+
console.warn(`[pptxgenjs] dataLabelPosition '${options.dataLabelPosition}' is not valid for a '${chartType}' chart - ignoring it (valid: ctr, inEnd, outEnd)`);
|
|
4345
|
+
delete options.dataLabelPosition;
|
|
4346
|
+
}
|
|
4347
|
+
} else {
|
|
4348
|
+
options.dataLabelPosition = resolveDataLabelPosition(options.dataLabelPosition, chartType, options.barGrouping);
|
|
4349
|
+
if (!options.dataLabelPosition) delete options.dataLabelPosition;
|
|
4350
|
+
}
|
|
3532
4351
|
}
|
|
3533
4352
|
options.dataLabelBkgrdColors = options.dataLabelBkgrdColors || !options.dataLabelBkgrdColors ? options.dataLabelBkgrdColors : false;
|
|
3534
4353
|
if (![
|
|
@@ -3700,6 +4519,59 @@ function _object_without_properties_loose(source, excluded) {
|
|
|
3700
4519
|
} else {
|
|
3701
4520
|
delete options.catAxisMultiLevelLabels;
|
|
3702
4521
|
}
|
|
4522
|
+
// ChartEx: reject values PowerPoint would reject, so a bad option degrades to the layout default
|
|
4523
|
+
// rather than to the repair dialog
|
|
4524
|
+
if (isChartexType(options._type)) {
|
|
4525
|
+
// Only box & whisker plots more than one distribution; the other layouts own the whole plot area
|
|
4526
|
+
// and a second `cx:series` is either dropped or flagged for repair
|
|
4527
|
+
if (options._type !== core_enums_CHART_TYPE.BOX_WHISKER && tmpData.length > 1) {
|
|
4528
|
+
console.warn(`Warning: a ${options._type} chart plots one series - ignoring ${tmpData.length - 1} extra series.`);
|
|
4529
|
+
tmpData = tmpData.slice(0, 1);
|
|
4530
|
+
}
|
|
4531
|
+
tmpData.forEach((item)=>{
|
|
4532
|
+
var _item_values;
|
|
4533
|
+
var _item_labels;
|
|
4534
|
+
// ChartEx cell references assume one label column; the multi-level worksheet layout shifts the
|
|
4535
|
+
// series columns right, so the extra levels are dropped rather than silently misaddressed
|
|
4536
|
+
if (item.labels && item.labels.length > 1) {
|
|
4537
|
+
console.warn('Warning: chartex charts take single-level category labels - using the first level.');
|
|
4538
|
+
item.labels = [
|
|
4539
|
+
item.labels[0]
|
|
4540
|
+
];
|
|
4541
|
+
}
|
|
4542
|
+
// A histogram bins raw values and needs no categories, but the embedded worksheet still writes a
|
|
4543
|
+
// row per label, so a label-less series is padded rather than left to fail during write()
|
|
4544
|
+
const labels = (_item_labels = item.labels) === null || _item_labels === void 0 ? void 0 : _item_labels[0];
|
|
4545
|
+
if (!labels || labels.length === 0) item.labels = [
|
|
4546
|
+
Array(((_item_values = item.values) !== null && _item_values !== void 0 ? _item_values : []).length).fill('')
|
|
4547
|
+
];
|
|
4548
|
+
});
|
|
4549
|
+
const pointCount = Math.max(...tmpData.map((item)=>{
|
|
4550
|
+
var _item_values;
|
|
4551
|
+
return ((_item_values = item.values) !== null && _item_values !== void 0 ? _item_values : []).length;
|
|
4552
|
+
}), 0);
|
|
4553
|
+
if (options.chartExSubtotals) {
|
|
4554
|
+
const valid = options.chartExSubtotals.filter((idx)=>Number.isInteger(idx) && idx >= 0 && idx < pointCount);
|
|
4555
|
+
if (valid.length !== options.chartExSubtotals.length) console.warn(`Warning: chart.chartExSubtotals must be data point indexes 0-${pointCount - 1}.`);
|
|
4556
|
+
options.chartExSubtotals = valid;
|
|
4557
|
+
}
|
|
4558
|
+
if (options.chartExBinCount !== undefined && (!Number.isInteger(options.chartExBinCount) || options.chartExBinCount < 1)) {
|
|
4559
|
+
console.warn('Warning: chart.chartExBinCount must be a positive integer.');
|
|
4560
|
+
delete options.chartExBinCount;
|
|
4561
|
+
}
|
|
4562
|
+
if (options.chartExBinSize !== undefined && (isNaN(options.chartExBinSize) || options.chartExBinSize <= 0)) {
|
|
4563
|
+
console.warn('Warning: chart.chartExBinSize must be greater than 0.');
|
|
4564
|
+
delete options.chartExBinSize;
|
|
4565
|
+
}
|
|
4566
|
+
if (options.chartExParentLabels && ![
|
|
4567
|
+
'none',
|
|
4568
|
+
'overlapping',
|
|
4569
|
+
'banner'
|
|
4570
|
+
].includes(options.chartExParentLabels)) {
|
|
4571
|
+
console.warn('Warning: chart.chartExParentLabels options: `none`, `overlapping`, `banner`.');
|
|
4572
|
+
delete options.chartExParentLabels;
|
|
4573
|
+
}
|
|
4574
|
+
}
|
|
3703
4575
|
// STEP 4: Set props (_type already set to chart on the literal above).
|
|
3704
4576
|
// The chart object stores the position/placeholder that gen-xml reads; chart `fill`
|
|
3705
4577
|
// is a color string (vs ObjectOptions' ShapeFillProps) and is never read here, so it
|
|
@@ -3713,14 +4585,17 @@ function _object_without_properties_loose(source, excluded) {
|
|
|
3713
4585
|
});
|
|
3714
4586
|
resultObject.chartRid = getNewRelId(target);
|
|
3715
4587
|
// STEP 5: Add this chart to this Slide Rels (rId/rels count spans all slides! Count all images to get next rId)
|
|
4588
|
+
// ChartEx charts are a separate part type with their own content type and relationship type,
|
|
4589
|
+
// so the file name is what every downstream emitter keys off (see `xml/package.ts`)
|
|
4590
|
+
const fileName = isChartexType(options._type) ? `chartEx${chartId}.xml` : `chart${chartId}.xml`;
|
|
3716
4591
|
target._relsChart.push({
|
|
3717
4592
|
rId: getNewRelId(target),
|
|
3718
4593
|
data: tmpData,
|
|
3719
4594
|
opts: options,
|
|
3720
4595
|
type: options._type,
|
|
3721
4596
|
globalId: chartId,
|
|
3722
|
-
fileName
|
|
3723
|
-
Target: `/ppt/charts
|
|
4597
|
+
fileName,
|
|
4598
|
+
Target: `/ppt/charts/${fileName}`
|
|
3724
4599
|
});
|
|
3725
4600
|
target._slideObjects.push(resultObject);
|
|
3726
4601
|
return resultObject;
|
|
@@ -3806,8 +4681,45 @@ function isSvgFillSource(data, path) {
|
|
|
3806
4681
|
});
|
|
3807
4682
|
return rId;
|
|
3808
4683
|
}
|
|
4684
|
+
function isStructuredImageFill(fill) {
|
|
4685
|
+
return !!fill && (fill.type === 'image' || !!fill.image);
|
|
4686
|
+
}
|
|
4687
|
+
/**
|
|
4688
|
+
* Resolve a picture fill's image into a slide relationship.
|
|
4689
|
+
* `genXmlColorSelection` is pure, so the rId has to be attached before XML is generated.
|
|
4690
|
+
*/ function resolveImageFill(target, fill) {
|
|
4691
|
+
var _ref, _ref1, _ref2, _ref3;
|
|
4692
|
+
var _fill_image, _fill_image1;
|
|
4693
|
+
if (!fill || typeof fill !== 'object') return;
|
|
4694
|
+
if (!isStructuredImageFill(fill) && !(fill.data || fill.path)) return;
|
|
4695
|
+
if (!isStructuredImageFill(fill) && (fill.color || fill.type && fill.type !== 'image')) return;
|
|
4696
|
+
const data = (_ref = (_ref1 = (_fill_image = fill.image) === null || _fill_image === void 0 ? void 0 : _fill_image.data) !== null && _ref1 !== void 0 ? _ref1 : fill.data) !== null && _ref !== void 0 ? _ref : '';
|
|
4697
|
+
const path = (_ref2 = (_ref3 = (_fill_image1 = fill.image) === null || _fill_image1 === void 0 ? void 0 : _fill_image1.path) !== null && _ref3 !== void 0 ? _ref3 : fill.path) !== null && _ref2 !== void 0 ? _ref2 : '';
|
|
4698
|
+
if (!data && !path) {
|
|
4699
|
+
console.warn('[pptxgenjs] `fill.type:"image"` requires `fill.image.data` or `fill.image.path` - fill ignored');
|
|
4700
|
+
return;
|
|
4701
|
+
}
|
|
4702
|
+
if (data && !data.toLowerCase().includes('base64,')) {
|
|
4703
|
+
console.warn('[pptxgenjs] `fill.image.data` lacks a base64 header (ex: \'image/png;base64,iV[...]\') - fill ignored');
|
|
4704
|
+
return;
|
|
4705
|
+
}
|
|
4706
|
+
const rId = registerTableCellImageFill(target, {
|
|
4707
|
+
data,
|
|
4708
|
+
path
|
|
4709
|
+
});
|
|
4710
|
+
if (!rId) return;
|
|
4711
|
+
if (fill.image) fill.image._rId = rId;
|
|
4712
|
+
else fill._rId = rId;
|
|
4713
|
+
}
|
|
4714
|
+
function resolveObjectImageFills(target, options) {
|
|
4715
|
+
var _options_fillOverlay;
|
|
4716
|
+
if (!options) return;
|
|
4717
|
+
if (options.fill) resolveImageFill(target, options.fill);
|
|
4718
|
+
if ((_options_fillOverlay = options.fillOverlay) === null || _options_fillOverlay === void 0 ? void 0 : _options_fillOverlay.fill) resolveImageFill(target, options.fillOverlay.fill);
|
|
4719
|
+
}
|
|
3809
4720
|
function addImageDefinition(target, opt) {
|
|
3810
|
-
var _strImagePath_substring_split__split_pop;
|
|
4721
|
+
var _opt_fillOverlay, _strImagePath_substring_split__split_pop;
|
|
4722
|
+
if ((_opt_fillOverlay = opt.fillOverlay) === null || _opt_fillOverlay === void 0 ? void 0 : _opt_fillOverlay.fill) resolveImageFill(target, opt.fillOverlay.fill);
|
|
3811
4723
|
const newObject = {
|
|
3812
4724
|
_type: (/* inlined export .SLIDE_OBJECT_TYPES.image */"image"),
|
|
3813
4725
|
text: undefined,
|
|
@@ -3877,7 +4789,16 @@ function addImageDefinition(target, opt) {
|
|
|
3877
4789
|
softEdge: opt.softEdge,
|
|
3878
4790
|
reflection: opt.reflection,
|
|
3879
4791
|
blur: opt.blur,
|
|
4792
|
+
fillOverlay: opt.fillOverlay,
|
|
4793
|
+
effectDag: opt.effectDag,
|
|
4794
|
+
alphaEffects: opt.alphaEffects,
|
|
4795
|
+
recolor: opt.recolor,
|
|
4796
|
+
styleRef: opt.styleRef,
|
|
3880
4797
|
line: opt.line || imageBorderToLine(opt.border),
|
|
4798
|
+
// non-visual props and locks are part of the object's identity, not its geometry
|
|
4799
|
+
title: opt.title,
|
|
4800
|
+
hidden: opt.hidden,
|
|
4801
|
+
lock: opt.lock,
|
|
3881
4802
|
_sizeFromImage: !intWidth && !intHeight,
|
|
3882
4803
|
// addImage always writes x/y/w/h defaults, so remember which axes the caller actually set
|
|
3883
4804
|
// (placeholder geometry must not overwrite explicit placement; fujita-h d7e3e93 / #996).
|
|
@@ -3957,8 +4878,14 @@ function addImageDefinition(target, opt) {
|
|
|
3957
4878
|
});
|
|
3958
4879
|
objHyperlink._rId = imageRelId;
|
|
3959
4880
|
newObject.hyperlink = objHyperlink;
|
|
4881
|
+
// the action sound (if any) needs its own relationship
|
|
4882
|
+
resolveHyperlinkRels(target, objHyperlink);
|
|
3960
4883
|
}
|
|
3961
4884
|
}
|
|
4885
|
+
if (typeof opt.hyperlinkHover === 'object') {
|
|
4886
|
+
resolveHyperlinkRels(target, opt.hyperlinkHover);
|
|
4887
|
+
newObject.hyperlinkHover = opt.hyperlinkHover;
|
|
4888
|
+
}
|
|
3962
4889
|
// STEP 6: Add object to slide
|
|
3963
4890
|
target._slideObjects.push(newObject);
|
|
3964
4891
|
}
|
|
@@ -3981,12 +4908,25 @@ function addImageDefinition(target, opt) {
|
|
|
3981
4908
|
const slideData = {
|
|
3982
4909
|
_type: (/* inlined export .SLIDE_OBJECT_TYPES.media */"media")
|
|
3983
4910
|
};
|
|
3984
|
-
//
|
|
3985
|
-
|
|
4911
|
+
// `link` with no `path`/`data` used to throw, so treating it as "reference, do not embed" cannot
|
|
4912
|
+
// change any deck that works today
|
|
4913
|
+
const isLinked = !!strLink && !strPath && !strData && (strType === 'audio' || strType === 'video');
|
|
4914
|
+
if (strLink && (strPath || strData) && strType !== 'online') {
|
|
4915
|
+
console.warn('[pptxgenjs] addMedia: `link` is ignored when `path` or `data` is given - the media is embedded');
|
|
4916
|
+
}
|
|
4917
|
+
// STEP 1: REALITY-CHECK - what each media kind needs, rather than one chain of conditions
|
|
4918
|
+
if (strType === 'audioCd') {
|
|
4919
|
+
var _opt_audioCd_start, _opt_audioCd, _opt_audioCd_end, _opt_audioCd1;
|
|
4920
|
+
// `a:st`/`a:end` and their `@track` are all required by CT_AudioCD
|
|
4921
|
+
if (typeof ((_opt_audioCd = opt.audioCd) === null || _opt_audioCd === void 0 ? void 0 : (_opt_audioCd_start = _opt_audioCd.start) === null || _opt_audioCd_start === void 0 ? void 0 : _opt_audioCd_start.track) !== 'number' || typeof ((_opt_audioCd1 = opt.audioCd) === null || _opt_audioCd1 === void 0 ? void 0 : (_opt_audioCd_end = _opt_audioCd1.end) === null || _opt_audioCd_end === void 0 ? void 0 : _opt_audioCd_end.track) !== 'number') {
|
|
4922
|
+
throw new Error('addMedia() error: `type:"audioCd"` requires `audioCd.start.track` and `audioCd.end.track`');
|
|
4923
|
+
}
|
|
4924
|
+
} else if (!strPath && !strData && strType !== 'online' && !isLinked) {
|
|
3986
4925
|
throw new Error('addMedia() error: either `data` or `path` are required!');
|
|
3987
4926
|
} else if (strData && !strData.toLowerCase().includes('base64,')) {
|
|
3988
4927
|
throw new Error('addMedia() error: `data` value lacks a base64 header! Ex: \'video/mpeg;base64,NMP[...]\')');
|
|
3989
|
-
}
|
|
4928
|
+
}
|
|
4929
|
+
if (strCover && !strCover.toLowerCase().includes('base64,')) {
|
|
3990
4930
|
throw new Error('addMedia() error: `cover` value lacks a base64 header! Ex: \'data:image/png;base64,iV[...]\')');
|
|
3991
4931
|
}
|
|
3992
4932
|
// Online Video: requires `link`
|
|
@@ -3995,7 +4935,7 @@ function addImageDefinition(target, opt) {
|
|
|
3995
4935
|
}
|
|
3996
4936
|
// Timing-tree playback (ECMA-376 §19.5 CT_TLMediaNode): no silent fallbacks.
|
|
3997
4937
|
// `fullScrn` exists only on CT_TLMediaNodeVideo; linked `online` media has no embedded media node.
|
|
3998
|
-
if (strType
|
|
4938
|
+
if (opt.fullScreen && strType !== 'video') {
|
|
3999
4939
|
throw new Error('addMedia() error: `fullScreen` is only valid on type "video"');
|
|
4000
4940
|
}
|
|
4001
4941
|
if (strType === 'online' && (opt.autoplay || opt.loop || opt.fullScreen || opt.mute)) {
|
|
@@ -4003,7 +4943,7 @@ function addImageDefinition(target, opt) {
|
|
|
4003
4943
|
}
|
|
4004
4944
|
// FIXME: 20190707
|
|
4005
4945
|
// strType = strData ? strData.split(';')[0].split('/')[0] : strType
|
|
4006
|
-
strExtn = opt.extn || (strData ? strData.split(';')[0].split('/')[1] : strPath.split('.').pop()) || 'mp3';
|
|
4946
|
+
strExtn = opt.extn || (strType === 'wav' ? 'wav' : strData ? strData.split(';')[0].split('/')[1] : (strPath || strLink).split('.').pop()) || 'mp3';
|
|
4007
4947
|
// STEP 2: Set type, media
|
|
4008
4948
|
slideData.mtype = strType;
|
|
4009
4949
|
slideData.media = strPath || 'preencoded.mov';
|
|
@@ -4030,6 +4970,11 @@ function addImageDefinition(target, opt) {
|
|
|
4030
4970
|
slideData.options.loop = opt.loop;
|
|
4031
4971
|
slideData.options.fullScreen = opt.fullScreen;
|
|
4032
4972
|
slideData.options.mute = opt.mute;
|
|
4973
|
+
slideData.options.contentType = opt.contentType;
|
|
4974
|
+
slideData.options.audioCd = opt.audioCd;
|
|
4975
|
+
slideData.options.isPhoto = opt.isPhoto;
|
|
4976
|
+
slideData.options.userDrawn = opt.userDrawn;
|
|
4977
|
+
slideData.options.isLinked = isLinked;
|
|
4033
4978
|
// STEP 4: Add this media to this Slide Rels (rId/rels count spans all slides! Count all media to get next rId)
|
|
4034
4979
|
/**
|
|
4035
4980
|
* NOTE:
|
|
@@ -4039,7 +4984,41 @@ function addImageDefinition(target, opt) {
|
|
|
4039
4984
|
* - Audio/Video files consume *TWO* rId's:
|
|
4040
4985
|
* <Relationship Id="rId2" Target="../media/media1.mov" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/video"/>
|
|
4041
4986
|
* <Relationship Id="rId3" Target="../media/media1.mov" Type="http://schemas.microsoft.com/office/2007/relationships/media"/>
|
|
4042
|
-
*/ if (strType === '
|
|
4987
|
+
*/ if (strType === 'audioCd') {
|
|
4988
|
+
// CD audio references the listener's drive: no media part, no media relationship, cover only
|
|
4989
|
+
const coverRid = getNewRelId(target);
|
|
4990
|
+
target._relsMedia.push({
|
|
4991
|
+
path: 'preencoded.png',
|
|
4992
|
+
type: 'image/png',
|
|
4993
|
+
extn: 'png',
|
|
4994
|
+
data: strCover,
|
|
4995
|
+
rId: coverRid,
|
|
4996
|
+
Target: `../media/${imageTargetStem(target)}.png`
|
|
4997
|
+
});
|
|
4998
|
+
slideData._coverRid = coverRid;
|
|
4999
|
+
} else if (strType === 'wav') {
|
|
5000
|
+
// `a:wavAudioFile` is the legacy embedded-WAV element: one audio relationship, no `p14:media`
|
|
5001
|
+
const relId1 = getNewRelId(target);
|
|
5002
|
+
target._relsMedia.push({
|
|
5003
|
+
path: strPath || 'preencoded.wav',
|
|
5004
|
+
type: 'audio/wav',
|
|
5005
|
+
extn: 'wav',
|
|
5006
|
+
data: strData || '',
|
|
5007
|
+
rId: relId1,
|
|
5008
|
+
Target: `../media/media-${target._slideNum}-${target._relsMedia.length + 1}.wav`
|
|
5009
|
+
});
|
|
5010
|
+
slideData.mediaRid = relId1;
|
|
5011
|
+
const coverRid = getNewRelId(target);
|
|
5012
|
+
target._relsMedia.push({
|
|
5013
|
+
path: 'preencoded.png',
|
|
5014
|
+
type: 'image/png',
|
|
5015
|
+
extn: 'png',
|
|
5016
|
+
data: strCover,
|
|
5017
|
+
rId: coverRid,
|
|
5018
|
+
Target: `../media/${imageTargetStem(target)}.png`
|
|
5019
|
+
});
|
|
5020
|
+
slideData._coverRid = coverRid;
|
|
5021
|
+
} else if (strType === 'online') {
|
|
4043
5022
|
const relId1 = getNewRelId(target);
|
|
4044
5023
|
// A: Add video
|
|
4045
5024
|
target._relsMedia.push({
|
|
@@ -4064,6 +5043,8 @@ function addImageDefinition(target, opt) {
|
|
|
4064
5043
|
// PERF: Duplicate media should reuse existing `Target` value and not create an additional copy
|
|
4065
5044
|
const dupeItem = target._relsMedia.filter((item)=>item.path && item.path === strPath && item.type === strType + '/' + strExtn && !item.isDuplicate)[0];
|
|
4066
5045
|
// A: "relationships/video"
|
|
5046
|
+
// Linked media keeps this exact three-relationship shape - the rIds the emitter derives from
|
|
5047
|
+
// `mediaRid` stay valid - and only points the targets outside the package
|
|
4067
5048
|
const relId1 = getNewRelId(target);
|
|
4068
5049
|
target._relsMedia.push({
|
|
4069
5050
|
path: strPath || 'preencoded' + strExtn,
|
|
@@ -4072,7 +5053,8 @@ function addImageDefinition(target, opt) {
|
|
|
4072
5053
|
data: strData || '',
|
|
4073
5054
|
rId: relId1,
|
|
4074
5055
|
isDuplicate: !!(dupeItem === null || dupeItem === void 0 ? void 0 : dupeItem.Target),
|
|
4075
|
-
|
|
5056
|
+
isLinked,
|
|
5057
|
+
Target: isLinked ? strLink : (dupeItem === null || dupeItem === void 0 ? void 0 : dupeItem.Target) ? dupeItem.Target : `../media/media-${target._slideNum}-${target._relsMedia.length + 1}.${strExtn}`
|
|
4076
5058
|
});
|
|
4077
5059
|
slideData.mediaRid = relId1;
|
|
4078
5060
|
// B: "relationships/media"
|
|
@@ -4083,7 +5065,8 @@ function addImageDefinition(target, opt) {
|
|
|
4083
5065
|
data: strData || '',
|
|
4084
5066
|
rId: getNewRelId(target),
|
|
4085
5067
|
isDuplicate: !!(dupeItem === null || dupeItem === void 0 ? void 0 : dupeItem.Target),
|
|
4086
|
-
|
|
5068
|
+
isLinked,
|
|
5069
|
+
Target: isLinked ? strLink : (dupeItem === null || dupeItem === void 0 ? void 0 : dupeItem.Target) ? dupeItem.Target : `../media/media-${target._slideNum}-${target._relsMedia.length + 0}.${strExtn}`
|
|
4087
5070
|
});
|
|
4088
5071
|
// C: Add cover (preview/overlay) image
|
|
4089
5072
|
target._relsMedia.push({
|
|
@@ -4319,11 +5302,107 @@ function nextExtPartName(target, prefix, extn) {
|
|
|
4319
5302
|
opts.line.endArrowType = opts.lineTail;
|
|
4320
5303
|
}
|
|
4321
5304
|
}
|
|
5305
|
+
/**
|
|
5306
|
+
* Create the relationships a hyperlink needs: the link target, and its action sound when set
|
|
5307
|
+
* - `genXmlHyperlink` is pure, so both ids have to exist before the XML is generated
|
|
5308
|
+
*/ function resolveHyperlinkRels(target, link) {
|
|
5309
|
+
if (!link || typeof link !== 'object') return;
|
|
5310
|
+
if (!link._rId) {
|
|
5311
|
+
var _link_url;
|
|
5312
|
+
var _link_slide;
|
|
5313
|
+
if (!link.url && !link.slide) {
|
|
5314
|
+
console.warn('[pptxgenjs] a hyperlink requires either `url` or `slide` - link ignored');
|
|
5315
|
+
return;
|
|
5316
|
+
}
|
|
5317
|
+
const relId = getNewRelId(target);
|
|
5318
|
+
target._rels.push({
|
|
5319
|
+
type: (/* inlined export .SLIDE_OBJECT_TYPES.hyperlink */"hyperlink"),
|
|
5320
|
+
data: link.slide ? 'slide' : 'dummy',
|
|
5321
|
+
rId: relId,
|
|
5322
|
+
Target: encodeXmlEntities((_link_url = link.url) !== null && _link_url !== void 0 ? _link_url : '') || ((_link_slide = link.slide) === null || _link_slide === void 0 ? void 0 : _link_slide.toString()) || ''
|
|
5323
|
+
});
|
|
5324
|
+
link._rId = relId;
|
|
5325
|
+
} else if (target._rels.filter((rel)=>rel.rId === link._rId).length === 0) {
|
|
5326
|
+
var _link_url1;
|
|
5327
|
+
var _link_slide1;
|
|
5328
|
+
target._rels.push({
|
|
5329
|
+
type: (/* inlined export .SLIDE_OBJECT_TYPES.hyperlink */"hyperlink"),
|
|
5330
|
+
data: link.slide ? 'slide' : 'dummy',
|
|
5331
|
+
rId: link._rId,
|
|
5332
|
+
Target: encodeXmlEntities((_link_url1 = link.url) !== null && _link_url1 !== void 0 ? _link_url1 : '') || ((_link_slide1 = link.slide) === null || _link_slide1 === void 0 ? void 0 : _link_slide1.toString()) || ''
|
|
5333
|
+
});
|
|
5334
|
+
}
|
|
5335
|
+
// ECMA-376 20.1.2.2.32 allows only WAV here, so anything else is dropped rather than linked
|
|
5336
|
+
const sound = link.sound;
|
|
5337
|
+
if (!sound) return;
|
|
5338
|
+
if (!sound._sndRId) {
|
|
5339
|
+
var _sound_data, _sound_path;
|
|
5340
|
+
const data = (_sound_data = sound.data) !== null && _sound_data !== void 0 ? _sound_data : '';
|
|
5341
|
+
const path = (_sound_path = sound.path) !== null && _sound_path !== void 0 ? _sound_path : '';
|
|
5342
|
+
if (!data && !path) {
|
|
5343
|
+
console.warn('[pptxgenjs] hyperlink `sound` requires `data` or `path` - sound ignored');
|
|
5344
|
+
link.sound = undefined;
|
|
5345
|
+
return;
|
|
5346
|
+
}
|
|
5347
|
+
if (data && !data.toLowerCase().includes('base64,')) {
|
|
5348
|
+
console.warn('[pptxgenjs] hyperlink `sound.data` lacks a base64 header - sound ignored');
|
|
5349
|
+
link.sound = undefined;
|
|
5350
|
+
return;
|
|
5351
|
+
}
|
|
5352
|
+
const rId = getNewRelId(target);
|
|
5353
|
+
target._relsMedia.push({
|
|
5354
|
+
path: path || 'preencoded.wav',
|
|
5355
|
+
type: 'audio/wav',
|
|
5356
|
+
extn: 'wav',
|
|
5357
|
+
data,
|
|
5358
|
+
rId,
|
|
5359
|
+
Target: `../media/audio-${target._slideNum}-${target._relsMedia.length + 1}.wav`
|
|
5360
|
+
});
|
|
5361
|
+
sound._sndRId = rId;
|
|
5362
|
+
} else if (!target._relsMedia.some((rel)=>rel.rId === sound._sndRId)) {
|
|
5363
|
+
target._relsMedia.push({
|
|
5364
|
+
path: sound.path || 'preencoded.wav',
|
|
5365
|
+
type: 'audio/wav',
|
|
5366
|
+
extn: 'wav',
|
|
5367
|
+
data: sound.data,
|
|
5368
|
+
rId: sound._sndRId,
|
|
5369
|
+
Target: `../media/audio-${target._slideNum}-${target._relsMedia.length + 1}.wav`
|
|
5370
|
+
});
|
|
5371
|
+
}
|
|
5372
|
+
}
|
|
5373
|
+
/**
|
|
5374
|
+
* Resolve a picture bullet's image into a slide relationship
|
|
5375
|
+
* - the paragraph emitter is pure, so the rId has to exist before the XML is generated
|
|
5376
|
+
*/ function resolveBulletImage(target, opts) {
|
|
5377
|
+
var _ref;
|
|
5378
|
+
var _exec;
|
|
5379
|
+
const bullet = typeof (opts === null || opts === void 0 ? void 0 : opts.bullet) === 'object' ? opts.bullet : undefined;
|
|
5380
|
+
if (!(bullet === null || bullet === void 0 ? void 0 : bullet.image) || bullet._imageRId) return;
|
|
5381
|
+
if (!bullet.image.toLowerCase().includes('base64,')) {
|
|
5382
|
+
console.warn('[pptxgenjs] `bullet.image` must be base64 image data (ex: \'image/png;base64,iV[...]\') - picture bullet ignored');
|
|
5383
|
+
bullet.image = undefined;
|
|
5384
|
+
return;
|
|
5385
|
+
}
|
|
5386
|
+
const extn = (_ref = (_exec = /image\/(\w+);/.exec(bullet.image)) === null || _exec === void 0 ? void 0 : _exec[1]) !== null && _ref !== void 0 ? _ref : 'png';
|
|
5387
|
+
const rId = getNewRelId(target);
|
|
5388
|
+
target._relsMedia.push({
|
|
5389
|
+
path: `preencoded.${extn}`,
|
|
5390
|
+
type: `image/${extn}`,
|
|
5391
|
+
extn,
|
|
5392
|
+
data: bullet.image,
|
|
5393
|
+
rId,
|
|
5394
|
+
Target: `../media/${imageTargetStem(target)}.${extn}`
|
|
5395
|
+
});
|
|
5396
|
+
bullet._imageRId = rId;
|
|
5397
|
+
}
|
|
4322
5398
|
function addShapeDefinition(target, shapeName, opts) {
|
|
4323
5399
|
const options = typeof opts === 'object' ? opts : {};
|
|
4324
5400
|
options.line = options.line || {
|
|
4325
5401
|
type: 'none'
|
|
4326
5402
|
};
|
|
5403
|
+
resolveHyperlinkRels(target, options.hyperlink);
|
|
5404
|
+
resolveHyperlinkRels(target, options.hyperlinkHover);
|
|
5405
|
+
resolveObjectImageFills(target, options);
|
|
4327
5406
|
const newObject = {
|
|
4328
5407
|
_type: (/* inlined export .SLIDE_OBJECT_TYPES.text */"text"),
|
|
4329
5408
|
shape: shapeName || core_enums_SHAPE_TYPE.RECTANGLE,
|
|
@@ -4340,7 +5419,7 @@ function addShapeDefinition(target, shapeName, opts) {
|
|
|
4340
5419
|
}
|
|
4341
5420
|
// 1: ShapeLineProps defaults
|
|
4342
5421
|
const hasConnectorEnds = options.line.sourceId != null || options.line.targetId != null;
|
|
4343
|
-
const newLineOpts = {
|
|
5422
|
+
const newLineOpts = gen_objects_object_spread_props(gen_objects_object_spread({}, options.line), {
|
|
4344
5423
|
type: options.line.type || (options.line.gradient ? 'gradient' : 'solid'),
|
|
4345
5424
|
color: options.line.color || (/* inlined export .DEF_SHAPE_LINE_COLOR */"333333"),
|
|
4346
5425
|
transparency: options.line.transparency || 0,
|
|
@@ -4356,8 +5435,10 @@ function addShapeDefinition(target, shapeName, opts) {
|
|
|
4356
5435
|
sourceAnchorPos: options.line.sourceAnchorPos,
|
|
4357
5436
|
targetAnchorPos: options.line.targetAnchorPos,
|
|
4358
5437
|
isConnector: options.line.isConnector || hasConnectorEnds,
|
|
4359
|
-
curveadjust: options.line.curveadjust
|
|
4360
|
-
|
|
5438
|
+
curveadjust: options.line.curveadjust,
|
|
5439
|
+
_sourceName: options.line._sourceName,
|
|
5440
|
+
_targetName: options.line._targetName
|
|
5441
|
+
});
|
|
4361
5442
|
if (typeof options.line === 'object' && options.line.type !== 'none') options.line = newLineOpts;
|
|
4362
5443
|
// 2: Set options defaults
|
|
4363
5444
|
const shapeOpts = options;
|
|
@@ -4413,12 +5494,13 @@ function addShapeDefinition(target, shapeName, opts) {
|
|
|
4413
5494
|
// STEP 2: Transform `tableRows` into well-formatted TableCell's
|
|
4414
5495
|
// tableRows can be object or plain text array: `[{text:'cell 1'}, {text:'cell 2', options:{color:'ff0000'}}]` | `["cell 1", "cell 2"]`
|
|
4415
5496
|
const arrRows = [];
|
|
4416
|
-
|
|
5497
|
+
if (isStructuredImageFill(opt.fill)) resolveImageFill(target, opt.fill);
|
|
5498
|
+
const tableFillRid = isStructuredImageFill(opt.fill) ? undefined : registerTableCellImageFill(target, opt.fill);
|
|
4417
5499
|
tableRows.forEach((row)=>{
|
|
4418
5500
|
const newRow = [];
|
|
4419
5501
|
if (Array.isArray(row)) {
|
|
4420
5502
|
row.forEach((cell)=>{
|
|
4421
|
-
var _newCell_options
|
|
5503
|
+
var _newCell_options;
|
|
4422
5504
|
// A:
|
|
4423
5505
|
const newCell = {
|
|
4424
5506
|
_type: (/* inlined export .SLIDE_OBJECT_TYPES.tablecell */"tablecell"),
|
|
@@ -4488,8 +5570,13 @@ function addShapeDefinition(target, shapeName, opts) {
|
|
|
4488
5570
|
transparency: typeof cellBorder[idx].transparency === 'number' ? cellBorder[idx].transparency : undefined
|
|
4489
5571
|
};
|
|
4490
5572
|
});
|
|
4491
|
-
|
|
4492
|
-
|
|
5573
|
+
if (isStructuredImageFill(cellOpts.fill)) {
|
|
5574
|
+
resolveImageFill(target, cellOpts.fill);
|
|
5575
|
+
} else {
|
|
5576
|
+
var _registerTableCellImageFill;
|
|
5577
|
+
const fillRid = (_registerTableCellImageFill = registerTableCellImageFill(target, cellOpts.fill)) !== null && _registerTableCellImageFill !== void 0 ? _registerTableCellImageFill : cellOpts.fill ? undefined : tableFillRid;
|
|
5578
|
+
if (fillRid) cellOpts._fillRid = fillRid;
|
|
5579
|
+
}
|
|
4493
5580
|
// LAST:
|
|
4494
5581
|
newRow.push(newCell);
|
|
4495
5582
|
});
|
|
@@ -4696,7 +5783,8 @@ function addShapeDefinition(target, shapeName, opts) {
|
|
|
4696
5783
|
*/ function addTextDefinition(target, text, opts, isPlaceholder) {
|
|
4697
5784
|
var _newObject_options;
|
|
4698
5785
|
var // STEP 2: Create/Clean text options
|
|
4699
|
-
_newObject_text;
|
|
5786
|
+
_newObject_text, _newObject_options1, _newObject_options2, _newObject_text1;
|
|
5787
|
+
resolveObjectImageFills(target, opts);
|
|
4700
5788
|
const newObject = {
|
|
4701
5789
|
_type: isPlaceholder ? (/* inlined export .SLIDE_OBJECT_TYPES.placeholder */"placeholder") : (/* inlined export .SLIDE_OBJECT_TYPES.text */"text"),
|
|
4702
5790
|
shape: (opts === null || opts === void 0 ? void 0 : opts.shape) || core_enums_SHAPE_TYPE.RECTANGLE,
|
|
@@ -4743,7 +5831,7 @@ function addShapeDefinition(target, shapeName, opts) {
|
|
|
4743
5831
|
if (itemOpts.shape === core_enums_SHAPE_TYPE.LINE) {
|
|
4744
5832
|
var _itemOpts_line, _itemOpts_line1, _itemOpts_line2, _itemOpts_line3, _itemOpts_line4, _itemOpts_line5, _itemOpts_line6, _itemOpts_line7, _itemOpts_line8, _itemOpts_line9;
|
|
4745
5833
|
// ShapeLineProps defaults
|
|
4746
|
-
const newLineOpts = {
|
|
5834
|
+
const newLineOpts = gen_objects_object_spread_props(gen_objects_object_spread({}, itemOpts.line), {
|
|
4747
5835
|
type: ((_itemOpts_line = itemOpts.line) === null || _itemOpts_line === void 0 ? void 0 : _itemOpts_line.type) || (((_itemOpts_line1 = itemOpts.line) === null || _itemOpts_line1 === void 0 ? void 0 : _itemOpts_line1.gradient) ? 'gradient' : 'solid'),
|
|
4748
5836
|
color: ((_itemOpts_line2 = itemOpts.line) === null || _itemOpts_line2 === void 0 ? void 0 : _itemOpts_line2.color) || (/* inlined export .DEF_SHAPE_LINE_COLOR */"333333"),
|
|
4749
5837
|
transparency: ((_itemOpts_line3 = itemOpts.line) === null || _itemOpts_line3 === void 0 ? void 0 : _itemOpts_line3.transparency) || 0,
|
|
@@ -4753,7 +5841,7 @@ function addShapeDefinition(target, shapeName, opts) {
|
|
|
4753
5841
|
cap: (_itemOpts_line7 = itemOpts.line) === null || _itemOpts_line7 === void 0 ? void 0 : _itemOpts_line7.cap,
|
|
4754
5842
|
beginArrowType: ((_itemOpts_line8 = itemOpts.line) === null || _itemOpts_line8 === void 0 ? void 0 : _itemOpts_line8.beginArrowType) || undefined,
|
|
4755
5843
|
endArrowType: ((_itemOpts_line9 = itemOpts.line) === null || _itemOpts_line9 === void 0 ? void 0 : _itemOpts_line9.endArrowType) || undefined
|
|
4756
|
-
};
|
|
5844
|
+
});
|
|
4757
5845
|
if (typeof itemOpts.line === 'object') itemOpts.line = newLineOpts;
|
|
4758
5846
|
// 3: Handle line (lots of deprecated opts)
|
|
4759
5847
|
normalizeDeprecatedLineProps(itemOpts, newLineOpts);
|
|
@@ -4827,8 +5915,18 @@ function addShapeDefinition(target, shapeName, opts) {
|
|
|
4827
5915
|
// STEP 1: Create/Clean object options
|
|
4828
5916
|
newObject.options = cleanOpts((_newObject_options = newObject.options) !== null && _newObject_options !== void 0 ? _newObject_options : {});
|
|
4829
5917
|
(_newObject_text = newObject.text) === null || _newObject_text === void 0 ? void 0 : _newObject_text.forEach((item)=>item.options = cleanOpts(item.options || {}));
|
|
4830
|
-
// STEP 3: Create hyperlinks
|
|
5918
|
+
// STEP 3: Create hyperlinks, hover actions, and any picture-bullet relationships
|
|
4831
5919
|
createHyperlinkRels(target, newObject.text || '');
|
|
5920
|
+
resolveHyperlinkRels(target, (_newObject_options1 = newObject.options) === null || _newObject_options1 === void 0 ? void 0 : _newObject_options1.hyperlink);
|
|
5921
|
+
resolveHyperlinkRels(target, (_newObject_options2 = newObject.options) === null || _newObject_options2 === void 0 ? void 0 : _newObject_options2.hyperlinkHover);
|
|
5922
|
+
resolveBulletImage(target, newObject.options);
|
|
5923
|
+
(_newObject_text1 = newObject.text) === null || _newObject_text1 === void 0 ? void 0 : _newObject_text1.forEach((item)=>{
|
|
5924
|
+
var _item_options, _item_options_hyperlink, _item_options1;
|
|
5925
|
+
resolveHyperlinkRels(target, (_item_options = item.options) === null || _item_options === void 0 ? void 0 : _item_options.hyperlinkHover);
|
|
5926
|
+
// a click link already has its target rel; this adds its action sound
|
|
5927
|
+
if ((_item_options1 = item.options) === null || _item_options1 === void 0 ? void 0 : (_item_options_hyperlink = _item_options1.hyperlink) === null || _item_options_hyperlink === void 0 ? void 0 : _item_options_hyperlink.sound) resolveHyperlinkRels(target, item.options.hyperlink);
|
|
5928
|
+
resolveBulletImage(target, item.options);
|
|
5929
|
+
});
|
|
4832
5930
|
// LAST: Add object to Slide
|
|
4833
5931
|
target._slideObjects.push(newObject);
|
|
4834
5932
|
}
|
|
@@ -4956,6 +6054,11 @@ function addShapeDefinition(target, shapeName, opts) {
|
|
|
4956
6054
|
});
|
|
4957
6055
|
}
|
|
4958
6056
|
}
|
|
6057
|
+
if (text && typeof text === 'object' && !Array.isArray(text) && text.options) {
|
|
6058
|
+
var _text_options_hyperlink;
|
|
6059
|
+
resolveHyperlinkRels(target, text.options.hyperlinkHover);
|
|
6060
|
+
if ((_text_options_hyperlink = text.options.hyperlink) === null || _text_options_hyperlink === void 0 ? void 0 : _text_options_hyperlink.sound) resolveHyperlinkRels(target, text.options.hyperlink);
|
|
6061
|
+
}
|
|
4959
6062
|
});
|
|
4960
6063
|
}
|
|
4961
6064
|
function makeGroupCollector(parent) {
|
|
@@ -4975,6 +6078,7 @@ function makeGroupCollector(parent) {
|
|
|
4975
6078
|
* Child coordinates are relative to the group origin (`chOff` 0,0 / `chExt` = group size).
|
|
4976
6079
|
*/ function addGroupDefinition(target, opts, objects) {
|
|
4977
6080
|
var _opts_x, _opts_y, _opts_w, _opts_h, _opts_rotate;
|
|
6081
|
+
if (opts.fill) resolveImageFill(target, opts.fill);
|
|
4978
6082
|
const groupCount = target._slideObjects.filter((obj)=>obj._type === (/* inlined export .SLIDE_OBJECT_TYPES.group */"group")).length;
|
|
4979
6083
|
const newObject = {
|
|
4980
6084
|
_type: (/* inlined export .SLIDE_OBJECT_TYPES.group */"group"),
|
|
@@ -4985,7 +6089,11 @@ function makeGroupCollector(parent) {
|
|
|
4985
6089
|
h: (_opts_h = opts.h) !== null && _opts_h !== void 0 ? _opts_h : 1,
|
|
4986
6090
|
rotate: (_opts_rotate = opts.rotate) !== null && _opts_rotate !== void 0 ? _opts_rotate : 0,
|
|
4987
6091
|
shadow: opts.shadow ? correctShadowOptions(opts.shadow) : undefined,
|
|
4988
|
-
|
|
6092
|
+
fill: opts.fill,
|
|
6093
|
+
objectName: opts.objectName ? encodeXmlEntities(opts.objectName) : `Group ${groupCount + 1}`,
|
|
6094
|
+
title: opts.title,
|
|
6095
|
+
hidden: opts.hidden,
|
|
6096
|
+
lock: opts.lock
|
|
4989
6097
|
},
|
|
4990
6098
|
_objects: objects
|
|
4991
6099
|
};
|
|
@@ -5025,10 +6133,60 @@ function createGroupBuilder(parent, objects) {
|
|
|
5025
6133
|
addGroupDefinition(collector, options, children);
|
|
5026
6134
|
objects.push(...collector._slideObjects);
|
|
5027
6135
|
return builder;
|
|
6136
|
+
},
|
|
6137
|
+
addConnector (options) {
|
|
6138
|
+
const collector = makeGroupCollector(parent);
|
|
6139
|
+
addConnectorDefinition(collector, options !== null && options !== void 0 ? options : {});
|
|
6140
|
+
objects.push(...collector._slideObjects);
|
|
6141
|
+
return builder;
|
|
5028
6142
|
}
|
|
5029
6143
|
};
|
|
5030
6144
|
return builder;
|
|
5031
6145
|
}
|
|
6146
|
+
const CONNECTOR_PRESETS = new Set([
|
|
6147
|
+
'line',
|
|
6148
|
+
'straightConnector1',
|
|
6149
|
+
'bentConnector2',
|
|
6150
|
+
'bentConnector3',
|
|
6151
|
+
'bentConnector4',
|
|
6152
|
+
'bentConnector5',
|
|
6153
|
+
'curvedConnector2',
|
|
6154
|
+
'curvedConnector3',
|
|
6155
|
+
'curvedConnector4',
|
|
6156
|
+
'curvedConnector5'
|
|
6157
|
+
]);
|
|
6158
|
+
/**
|
|
6159
|
+
* Additive connector convenience: maps onto `addShape` + `line.isConnector`.
|
|
6160
|
+
* `start`/`end` `objectName`s are resolved to `sourceId`/`targetId` at emit time.
|
|
6161
|
+
*/ function addConnectorDefinition(target, opt) {
|
|
6162
|
+
var _opt_line, _ref, _ref1;
|
|
6163
|
+
var _opt_line1, _opt_line2, _opt_start, _opt_line3, _opt_end, _opt_line4, _opt_start1, _opt_end1;
|
|
6164
|
+
const requested = opt.type && CONNECTOR_PRESETS.has(opt.type) ? opt.type : 'straightConnector1';
|
|
6165
|
+
const shapeName = requested === 'line' ? core_enums_SHAPE_TYPE.LINE : requested;
|
|
6166
|
+
const line = gen_objects_object_spread_props(gen_objects_object_spread({}, (_opt_line = opt.line) !== null && _opt_line !== void 0 ? _opt_line : {}), {
|
|
6167
|
+
isConnector: true,
|
|
6168
|
+
sourceId: (_opt_line1 = opt.line) === null || _opt_line1 === void 0 ? void 0 : _opt_line1.sourceId,
|
|
6169
|
+
targetId: (_opt_line2 = opt.line) === null || _opt_line2 === void 0 ? void 0 : _opt_line2.targetId,
|
|
6170
|
+
sourceAnchorPos: (_ref = (_opt_start = opt.start) === null || _opt_start === void 0 ? void 0 : _opt_start.site) !== null && _ref !== void 0 ? _ref : (_opt_line3 = opt.line) === null || _opt_line3 === void 0 ? void 0 : _opt_line3.sourceAnchorPos,
|
|
6171
|
+
targetAnchorPos: (_ref1 = (_opt_end = opt.end) === null || _opt_end === void 0 ? void 0 : _opt_end.site) !== null && _ref1 !== void 0 ? _ref1 : (_opt_line4 = opt.line) === null || _opt_line4 === void 0 ? void 0 : _opt_line4.targetAnchorPos,
|
|
6172
|
+
_sourceName: (_opt_start1 = opt.start) === null || _opt_start1 === void 0 ? void 0 : _opt_start1.shape,
|
|
6173
|
+
_targetName: (_opt_end1 = opt.end) === null || _opt_end1 === void 0 ? void 0 : _opt_end1.shape
|
|
6174
|
+
});
|
|
6175
|
+
addShapeDefinition(target, shapeName, {
|
|
6176
|
+
x: opt.x,
|
|
6177
|
+
y: opt.y,
|
|
6178
|
+
w: opt.w,
|
|
6179
|
+
h: opt.h,
|
|
6180
|
+
objectName: opt.objectName,
|
|
6181
|
+
rotate: opt.rotate,
|
|
6182
|
+
flipH: opt.flipH,
|
|
6183
|
+
flipV: opt.flipV,
|
|
6184
|
+
fill: opt.fill,
|
|
6185
|
+
shadow: opt.shadow,
|
|
6186
|
+
styleRef: opt.styleRef,
|
|
6187
|
+
line
|
|
6188
|
+
});
|
|
6189
|
+
}
|
|
5032
6190
|
|
|
5033
6191
|
;// CONCATENATED MODULE: ./src/slide.ts
|
|
5034
6192
|
/**
|
|
@@ -5074,6 +6232,8 @@ function slide_object_spread(target) {
|
|
|
5074
6232
|
delete runOpts.reflection;
|
|
5075
6233
|
delete runOpts.shadow;
|
|
5076
6234
|
delete runOpts.blur;
|
|
6235
|
+
delete runOpts.fillOverlay;
|
|
6236
|
+
delete runOpts.effectDag;
|
|
5077
6237
|
return runOpts;
|
|
5078
6238
|
}
|
|
5079
6239
|
class Slide {
|
|
@@ -5168,6 +6328,14 @@ class Slide {
|
|
|
5168
6328
|
addGroupDefinition(this, cloneOpts(options), children);
|
|
5169
6329
|
return this;
|
|
5170
6330
|
}
|
|
6331
|
+
/**
|
|
6332
|
+
* Add a connector (`p:cxnSp`). Additive convenience over `line.isConnector`.
|
|
6333
|
+
* Glue with `start`/`end` `objectName`s, or pass numeric `line.sourceId`/`targetId`.
|
|
6334
|
+
* @example slide.addConnector({ type: 'straightConnector1', start: { shape: 'BoxA', site: 3 }, end: { shape: 'BoxB', site: 1 } })
|
|
6335
|
+
*/ addConnector(options) {
|
|
6336
|
+
addConnectorDefinition(this, cloneOpts(options !== null && options !== void 0 ? options : {}));
|
|
6337
|
+
return this;
|
|
6338
|
+
}
|
|
5171
6339
|
/**
|
|
5172
6340
|
* Add a slide transition (`<p:transition>`, ECMA-376 §19.3.1.50 / MS-PPTX §2.2.1)
|
|
5173
6341
|
* @param {SlideTransitionProps} options - transition options
|
|
@@ -5380,65 +6548,6 @@ class Slide {
|
|
|
5380
6548
|
}
|
|
5381
6549
|
|
|
5382
6550
|
|
|
5383
|
-
;// CONCATENATED MODULE: ./src/charts/title.ts
|
|
5384
|
-
/**
|
|
5385
|
-
* Chart title rendering.
|
|
5386
|
-
*/
|
|
5387
|
-
|
|
5388
|
-
/**
|
|
5389
|
-
* Create char title elements
|
|
5390
|
-
* @param {IChartPropsTitle} opts - options
|
|
5391
|
-
* @return {string} XML `<c:title>`
|
|
5392
|
-
*/ function genXmlTitle(opts, chartX, chartY) {
|
|
5393
|
-
const align = opts.titleAlign === 'left' || opts.titleAlign === 'right' ? `<a:pPr algn="${opts.titleAlign.substring(0, 1)}">` : '<a:pPr>';
|
|
5394
|
-
const rotate = opts.titleRotate ? `<a:bodyPr rot="${convertRotationDegrees(opts.titleRotate)}"/>` : '<a:bodyPr/>' // don't specify rotation to get default (ex. vertical for cat axis)
|
|
5395
|
-
;
|
|
5396
|
-
const sizeAttr = opts.fontSize ? `sz="${Math.round(opts.fontSize * 100)}"` : '' // only set the font size if specified. Powerpoint will handle the default size
|
|
5397
|
-
;
|
|
5398
|
-
const titleBold = opts.titleBold ? 1 : 0;
|
|
5399
|
-
const titleItalic = opts.titleItalic ? 1 : 0;
|
|
5400
|
-
let layout = '<c:layout/>';
|
|
5401
|
-
if (opts.titlePos && typeof opts.titlePos.x === 'number' && typeof opts.titlePos.y === 'number') {
|
|
5402
|
-
// NOTE: manualLayout x/y vals are *relative to entire slide*
|
|
5403
|
-
const totalX = opts.titlePos.x + (chartX !== null && chartX !== void 0 ? chartX : 0);
|
|
5404
|
-
const totalY = opts.titlePos.y + (chartY !== null && chartY !== void 0 ? chartY : 0);
|
|
5405
|
-
let valX = totalX === 0 ? 0 : totalX * (totalX / 5) / 10;
|
|
5406
|
-
if (valX >= 1) valX = valX / 10;
|
|
5407
|
-
if (valX >= 0.1) valX = valX / 10;
|
|
5408
|
-
let valY = totalY === 0 ? 0 : totalY * (totalY / 5) / 10;
|
|
5409
|
-
if (valY >= 1) valY = valY / 10;
|
|
5410
|
-
if (valY >= 0.1) valY = valY / 10;
|
|
5411
|
-
layout = `<c:layout><c:manualLayout><c:xMode val="edge"/><c:yMode val="edge"/><c:x val="${valX}"/><c:y val="${valY}"/></c:manualLayout></c:layout>`;
|
|
5412
|
-
}
|
|
5413
|
-
return `<c:title>
|
|
5414
|
-
<c:tx>
|
|
5415
|
-
<c:rich>
|
|
5416
|
-
${rotate}
|
|
5417
|
-
<a:lstStyle/>
|
|
5418
|
-
<a:p>
|
|
5419
|
-
${align}
|
|
5420
|
-
<a:defRPr ${sizeAttr} b="${titleBold}" i="${titleItalic}" u="none" strike="noStrike">
|
|
5421
|
-
<a:solidFill>${createColorElement(opts.color || (/* inlined export .DEF_FONT_COLOR */"000000"))}</a:solidFill>
|
|
5422
|
-
<a:latin typeface="${encodeXmlEntities(opts.fontFace) || 'Arial'}"/>
|
|
5423
|
-
<a:ea typeface="${encodeXmlEntities(opts.fontFace) || 'Arial'}"/>
|
|
5424
|
-
</a:defRPr>
|
|
5425
|
-
</a:pPr>
|
|
5426
|
-
<a:r>
|
|
5427
|
-
<a:rPr ${sizeAttr} b="${titleBold}" i="${titleItalic}" u="none" strike="noStrike">
|
|
5428
|
-
<a:solidFill>${createColorElement(opts.color || (/* inlined export .DEF_FONT_COLOR */"000000"))}</a:solidFill>
|
|
5429
|
-
<a:latin typeface="${encodeXmlEntities(opts.fontFace) || 'Arial'}"/>
|
|
5430
|
-
<a:ea typeface="${encodeXmlEntities(opts.fontFace) || 'Arial'}"/>
|
|
5431
|
-
</a:rPr>
|
|
5432
|
-
<a:t>${encodeXmlEntities(opts.title) || ''}</a:t>
|
|
5433
|
-
</a:r>
|
|
5434
|
-
</a:p>
|
|
5435
|
-
</c:rich>
|
|
5436
|
-
</c:tx>
|
|
5437
|
-
${layout}
|
|
5438
|
-
<c:overlay val="0"/>
|
|
5439
|
-
</c:title>`;
|
|
5440
|
-
}
|
|
5441
|
-
|
|
5442
6551
|
;// CONCATENATED MODULE: ./src/charts/utils.ts
|
|
5443
6552
|
function utils_define_property(obj, key, value) {
|
|
5444
6553
|
if (key in obj) {
|
|
@@ -5618,21 +6727,320 @@ function createLineCap(lineCap) {
|
|
|
5618
6727
|
'sysDot'
|
|
5619
6728
|
];
|
|
5620
6729
|
/**
|
|
5621
|
-
* Per-series dash wins over chart-level `lineDash`. Unknown values fall back so we never
|
|
5622
|
-
* emit an illegal ST_PresetLineDashVal.
|
|
5623
|
-
*/ function resolveSeriesLineDash(seriesDash, chartDash) {
|
|
5624
|
-
if (seriesDash && CHART_LINE_DASH_TYPES.includes(seriesDash)) return seriesDash;
|
|
5625
|
-
if (chartDash && CHART_LINE_DASH_TYPES.includes(chartDash)) return chartDash;
|
|
5626
|
-
return 'solid';
|
|
6730
|
+
* Per-series dash wins over chart-level `lineDash`. Unknown values fall back so we never
|
|
6731
|
+
* emit an illegal ST_PresetLineDashVal.
|
|
6732
|
+
*/ function resolveSeriesLineDash(seriesDash, chartDash) {
|
|
6733
|
+
if (seriesDash && CHART_LINE_DASH_TYPES.includes(seriesDash)) return seriesDash;
|
|
6734
|
+
if (chartDash && CHART_LINE_DASH_TYPES.includes(chartDash)) return chartDash;
|
|
6735
|
+
return 'solid';
|
|
6736
|
+
}
|
|
6737
|
+
/** Area charts use `c:grouping` / ST_Grouping (standard|stacked|percentStacked), not ST_BarGrouping. */ const AREA_GROUPING = [
|
|
6738
|
+
'standard',
|
|
6739
|
+
'stacked',
|
|
6740
|
+
'percentStacked'
|
|
6741
|
+
];
|
|
6742
|
+
function resolveAreaGrouping(barGrouping) {
|
|
6743
|
+
if (barGrouping && AREA_GROUPING.includes(barGrouping)) return barGrouping;
|
|
6744
|
+
return 'standard';
|
|
6745
|
+
}
|
|
6746
|
+
|
|
6747
|
+
;// CONCATENATED MODULE: ./src/charts/chartex.ts
|
|
6748
|
+
/**
|
|
6749
|
+
* ChartEx (`cx:chartSpace`) rendering - MS-ODRAWXML 2.1.
|
|
6750
|
+
*
|
|
6751
|
+
* PowerPoint 2016 introduced chart layouts that ECMA-376 has no markup for. They are written to their
|
|
6752
|
+
* own part, in the `cx` namespace, and share nothing with the `c:` emitter in `xml.ts` beyond the
|
|
6753
|
+
* embedded workbook: the data lives in `cx:chartData` (one `cx:data` per series) and the layout is
|
|
6754
|
+
* selected by `cx:series@layoutId` rather than by the element name.
|
|
6755
|
+
*
|
|
6756
|
+
* The cell references point at the same worksheet `workbook.ts` writes for classic charts - column A
|
|
6757
|
+
* holds the category labels, columns B.. hold one series each, row 1 holds the series names - so no
|
|
6758
|
+
* chartex-specific workbook layout is needed.
|
|
6759
|
+
*/
|
|
6760
|
+
|
|
6761
|
+
|
|
6762
|
+
/** Sheet name written by `workbook.ts`; chartex cell references are absolute and always single-sheet */ const SHEET = 'Sheet1';
|
|
6763
|
+
/**
|
|
6764
|
+
* Category-axis gap width per layout, matching what PowerPoint writes for a freshly inserted chart.
|
|
6765
|
+
* A layout absent here (treemap, sunburst) draws no axes at all.
|
|
6766
|
+
*/ const CAT_GAP_WIDTH = {
|
|
6767
|
+
boxWhisker: '1',
|
|
6768
|
+
funnel: '0.0599999987',
|
|
6769
|
+
histogram: '0',
|
|
6770
|
+
waterfall: '0.5'
|
|
6771
|
+
};
|
|
6772
|
+
function firstLabelLevel(data) {
|
|
6773
|
+
var _data_;
|
|
6774
|
+
const labels = (_data_ = data[0]) === null || _data_ === void 0 ? void 0 : _data_.labels;
|
|
6775
|
+
if (!labels || labels.length === 0) return [];
|
|
6776
|
+
const level = labels[0];
|
|
6777
|
+
return Array.isArray(level) ? level : [];
|
|
6778
|
+
}
|
|
6779
|
+
/**
|
|
6780
|
+
* `<cx:pt idx="N">value</cx:pt>` for every point of one dimension
|
|
6781
|
+
* - a missing point is written empty: `cx:pt` inside a `cx:numDim` must be a number, so the string
|
|
6782
|
+
* "null" would be a schema violation (the ECMA-376 emitter blanks the same case)
|
|
6783
|
+
*/ function makePoints(values) {
|
|
6784
|
+
return values.map((value, idx)=>`<cx:pt idx="${idx}">${value === null || value === undefined ? '' : encodeXmlEntities(String(value))}</cx:pt>`).join('');
|
|
6785
|
+
}
|
|
6786
|
+
/**
|
|
6787
|
+
* Absolute A1 reference for one column of the embedded worksheet, excluding the header row.
|
|
6788
|
+
* The range length must equal the dimension's own `ptCount`, so each dimension passes its own.
|
|
6789
|
+
*/ function columnRef(colIdx, pointCount) {
|
|
6790
|
+
const col = getExcelColName(colIdx);
|
|
6791
|
+
return `${SHEET}!$${col}$2:$${col}$${pointCount + 1}`;
|
|
6792
|
+
}
|
|
6793
|
+
/**
|
|
6794
|
+
* One `cx:data` block per series.
|
|
6795
|
+
* - hierarchical layouts (treemap, sunburst) size their segments through a `size` dimension
|
|
6796
|
+
* - a histogram bins raw values itself, so it carries no category dimension at all
|
|
6797
|
+
*/ function makeChartData(rel, chartType) {
|
|
6798
|
+
const labels = firstLabelLevel(rel.data);
|
|
6799
|
+
const dimType = chartType === 'treemap' || chartType === 'sunburst' ? 'size' : 'val';
|
|
6800
|
+
return rel.data.map((series, seriesIdx)=>{
|
|
6801
|
+
var _series_values;
|
|
6802
|
+
const values = (_series_values = series.values) !== null && _series_values !== void 0 ? _series_values : [];
|
|
6803
|
+
const catDim = chartType === 'histogram' || labels.length === 0 ? '' : `<cx:strDim type="cat"><cx:f>${columnRef(1, labels.length)}</cx:f><cx:lvl ptCount="${labels.length}">${makePoints(labels)}</cx:lvl></cx:strDim>`;
|
|
6804
|
+
const valDim = `<cx:numDim type="${dimType}"><cx:f>${columnRef(seriesIdx + 2, values.length)}</cx:f>` + `<cx:lvl ptCount="${values.length}" formatCode="General">${makePoints(values)}</cx:lvl></cx:numDim>`;
|
|
6805
|
+
return `<cx:data id="${seriesIdx}">${catDim}${valDim}</cx:data>`;
|
|
6806
|
+
}).join('');
|
|
6807
|
+
}
|
|
6808
|
+
/** `cx:dataLabels` - chartex has no `c:dLbls`, visibility is a single element with three flags */ function makeDataLabels(opts, chartType) {
|
|
6809
|
+
var _opts_showValue, _opts_showLabel, _opts_dataLabelPosition;
|
|
6810
|
+
const showValue = (_opts_showValue = opts.showValue) !== null && _opts_showValue !== void 0 ? _opts_showValue : false;
|
|
6811
|
+
const showCategory = (_opts_showLabel = opts.showLabel) !== null && _opts_showLabel !== void 0 ? _opts_showLabel : false;
|
|
6812
|
+
if (!showValue && !showCategory) return '';
|
|
6813
|
+
// `outEnd` is invalid on the layouts that draw labels inside their segments
|
|
6814
|
+
const defaultPos = chartType === 'treemap' || chartType === 'sunburst' || chartType === 'funnel' ? 'ctr' : 'outEnd';
|
|
6815
|
+
const pos = (_opts_dataLabelPosition = opts.dataLabelPosition) !== null && _opts_dataLabelPosition !== void 0 ? _opts_dataLabelPosition : defaultPos;
|
|
6816
|
+
const size = Math.round((opts.dataLabelFontSize || (/* inlined export .DEF_FONT_SIZE */12)) * 100);
|
|
6817
|
+
const txPr = '<cx:txPr><a:bodyPr/><a:lstStyle/><a:p><a:pPr>' + `<a:defRPr sz="${size}" b="${opts.dataLabelFontBold ? 1 : 0}" i="${opts.dataLabelFontItalic ? 1 : 0}">` + `<a:solidFill>${createColorElement(opts.dataLabelColor || (/* inlined export .DEF_FONT_COLOR */"000000"))}</a:solidFill>` + `<a:latin typeface="${encodeXmlEntities(opts.dataLabelFontFace || 'Arial')}"/>` + '</a:defRPr></a:pPr></a:p></cx:txPr>';
|
|
6818
|
+
const numFmt = opts.dataLabelFormatCode ? `<cx:numFmt formatCode="${encodeXmlEntities(opts.dataLabelFormatCode)}" sourceLinked="0"/>` : '';
|
|
6819
|
+
return `<cx:dataLabels pos="${pos}">` + `<cx:visibility seriesName="0" categoryName="${showCategory ? 1 : 0}" value="${showValue ? 1 : 0}"/>` + numFmt + txPr + '</cx:dataLabels>';
|
|
6820
|
+
}
|
|
6821
|
+
/**
|
|
6822
|
+
* `cx:layoutPr` carries everything that is layout-specific rather than series-generic.
|
|
6823
|
+
* Anything absent here is left to PowerPoint's own default for that layout.
|
|
6824
|
+
*/ function makeLayoutProps(opts, chartType) {
|
|
6825
|
+
switch(chartType){
|
|
6826
|
+
case 'waterfall':
|
|
6827
|
+
{
|
|
6828
|
+
var _opts_chartExSubtotals;
|
|
6829
|
+
const subtotals = (_opts_chartExSubtotals = opts.chartExSubtotals) !== null && _opts_chartExSubtotals !== void 0 ? _opts_chartExSubtotals : [];
|
|
6830
|
+
if (subtotals.length === 0) return '';
|
|
6831
|
+
return `<cx:layoutPr><cx:subtotals>${subtotals.map((idx)=>`<cx:idx val="${idx}"/>`).join('')}</cx:subtotals></cx:layoutPr>`;
|
|
6832
|
+
}
|
|
6833
|
+
case 'histogram':
|
|
6834
|
+
{
|
|
6835
|
+
const binSize = opts.chartExBinSize;
|
|
6836
|
+
const binCount = opts.chartExBinCount;
|
|
6837
|
+
// PowerPoint accepts exactly one binning rule; an explicit size wins over a count, and neither
|
|
6838
|
+
// means "let PowerPoint choose" (its automatic Scott's-rule binning)
|
|
6839
|
+
const rule = binSize !== undefined ? `<cx:binSize val="${binSize}"/>` : binCount !== undefined ? `<cx:binCount val="${binCount}"/>` : '';
|
|
6840
|
+
const binning = rule ? `<cx:binning intervalClosed="r">${rule}</cx:binning>` : '<cx:binning intervalClosed="r"/>';
|
|
6841
|
+
return `<cx:layoutPr>${binning}</cx:layoutPr>`;
|
|
6842
|
+
}
|
|
6843
|
+
case 'boxWhisker':
|
|
6844
|
+
return '<cx:layoutPr>' + `<cx:visibility meanLine="${opts.chartExMeanLine ? 1 : 0}" meanMarker="1" nonoutliers="0" outliers="1"/>` + '<cx:statistics quartileMethod="exclusive"/>' + '</cx:layoutPr>';
|
|
6845
|
+
case 'treemap':
|
|
6846
|
+
var _opts_chartExParentLabels;
|
|
6847
|
+
return `<cx:layoutPr><cx:parentLabelLayout val="${(_opts_chartExParentLabels = opts.chartExParentLabels) !== null && _opts_chartExParentLabels !== void 0 ? _opts_chartExParentLabels : 'overlapping'}"/></cx:layoutPr>`;
|
|
6848
|
+
default:
|
|
6849
|
+
return '';
|
|
6850
|
+
}
|
|
6851
|
+
}
|
|
6852
|
+
/** One `cx:series` per data row. Order follows CT_Series: tx, spPr, dataLabels, dataId, layoutPr, axisId. */ function makeSeries(rel, chartType) {
|
|
6853
|
+
const layoutId = CHARTEX_LAYOUT_ID[chartType];
|
|
6854
|
+
const dataLabels = makeDataLabels(rel.opts, chartType);
|
|
6855
|
+
const layoutPr = makeLayoutProps(rel.opts, chartType);
|
|
6856
|
+
return rel.data.map((series, idx)=>{
|
|
6857
|
+
var _series_name;
|
|
6858
|
+
const nameCell = `${SHEET}!$${getExcelColName(idx + 2)}$1`;
|
|
6859
|
+
// These layouts color each data point from the chart color style, so `chartColors` does not
|
|
6860
|
+
// apply - a series-level fill would flatten a treemap to one color. Only `color` overrides it.
|
|
6861
|
+
const spPr = series.color && series.color !== 'transparent' ? `<cx:spPr><a:solidFill>${createColorElement(series.color)}</a:solidFill></cx:spPr>` : '';
|
|
6862
|
+
return `<cx:series layoutId="${layoutId}" uniqueId="{${getUuid('xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx').toUpperCase()}}">` + `<cx:tx><cx:txData><cx:f>${nameCell}</cx:f><cx:v>${encodeXmlEntities((_series_name = series.name) !== null && _series_name !== void 0 ? _series_name : `Series ${idx + 1}`)}</cx:v></cx:txData></cx:tx>` + spPr + dataLabels + `<cx:dataId val="${idx}"/>` + layoutPr + '</cx:series>';
|
|
6863
|
+
}).join('');
|
|
6864
|
+
}
|
|
6865
|
+
/**
|
|
6866
|
+
* `cx:axis` elements for the layouts that have axes. CT_Axis order: scaling, gridlines, tickLabels.
|
|
6867
|
+
* - a funnel is drawn along a single category axis, which PowerPoint numbers `1`
|
|
6868
|
+
* - treemap and sunburst have no axes; the series carries no `cx:axisId` in either case
|
|
6869
|
+
*/ function makeAxes(rel, chartType) {
|
|
6870
|
+
var _rel_opts_valGridLine;
|
|
6871
|
+
const gapWidth = CAT_GAP_WIDTH[chartType];
|
|
6872
|
+
if (gapWidth === undefined) return '';
|
|
6873
|
+
if (chartType === 'funnel') return `<cx:axis id="1"><cx:catScaling gapWidth="${gapWidth}"/><cx:tickLabels/></cx:axis>`;
|
|
6874
|
+
const valGridlines = ((_rel_opts_valGridLine = rel.opts.valGridLine) === null || _rel_opts_valGridLine === void 0 ? void 0 : _rel_opts_valGridLine.style) === 'none' ? '' : '<cx:majorGridlines/>';
|
|
6875
|
+
return `<cx:axis id="0"><cx:catScaling gapWidth="${gapWidth}"/><cx:tickLabels/></cx:axis>` + `<cx:axis id="1"><cx:valScaling/>${valGridlines}<cx:tickLabels/></cx:axis>`;
|
|
6876
|
+
}
|
|
6877
|
+
function makeTitle(opts) {
|
|
6878
|
+
if (!opts.showTitle) return '';
|
|
6879
|
+
const size = Math.round((opts.titleFontSize || (/* inlined export .DEF_FONT_TITLE_SIZE */18)) * 100);
|
|
6880
|
+
const color = opts.titleColor ? `<a:solidFill>${createColorElement(opts.titleColor)}</a:solidFill>` : '';
|
|
6881
|
+
const face = opts.titleFontFace ? `<a:latin typeface="${encodeXmlEntities(opts.titleFontFace)}"/>` : '';
|
|
6882
|
+
return '<cx:title pos="t" align="ctr" overlay="0"><cx:tx><cx:rich><a:bodyPr/><a:lstStyle/><a:p><a:pPr algn="ctr"/><a:r>' + `<a:rPr lang="${opts.lang || 'en-US'}" sz="${size}" b="${opts.titleBold ? 1 : 0}">${color}${face}</a:rPr>` + `<a:t>${encodeXmlEntities(opts.title || 'Chart Title')}</a:t>` + '</a:r></a:p></cx:rich></cx:tx></cx:title>';
|
|
6883
|
+
}
|
|
6884
|
+
function makeLegend(opts) {
|
|
6885
|
+
if (!opts.showLegend) return '';
|
|
6886
|
+
// `cx:legend@pos` takes l/r/t/b only; PowerPoint stores the library's `tr` as a top-aligned right legend
|
|
6887
|
+
const isTopRight = opts.legendPos === 'tr';
|
|
6888
|
+
return `<cx:legend pos="${isTopRight ? 'r' : opts.legendPos || 'r'}" align="${isTopRight ? 'min' : 'ctr'}" overlay="0"/>`;
|
|
6889
|
+
}
|
|
6890
|
+
/**
|
|
6891
|
+
* Build the `cx:chartSpace` part for one chartex chart.
|
|
6892
|
+
* @param {ISlideRelChart} rel - chart relationship, with `opts._type` narrowed to a chartex type
|
|
6893
|
+
* @returns {string} chartex part XML
|
|
6894
|
+
*/ function makeXmlChartEx(rel) {
|
|
6895
|
+
const type = rel.opts._type;
|
|
6896
|
+
if (!isChartexType(type)) throw new Error(`pptxgenjs: "${String(type)}" is not a chartex chart type`);
|
|
6897
|
+
return '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>' + '<cx:chartSpace xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main"' + ' xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"' + ` xmlns:cx="${OOXML_CHARTEX.ns}">` + '<cx:chartData>' + '<cx:externalData r:id="rId1" cx:autoUpdate="0"/>' + makeChartData(rel, type) + '</cx:chartData>' + '<cx:chart>' + makeTitle(rel.opts) + '<cx:plotArea>' + `<cx:plotAreaRegion>${makeSeries(rel, type)}</cx:plotAreaRegion>` + makeAxes(rel, type) + '</cx:plotArea>' + makeLegend(rel.opts) + '</cx:chart>' + '</cx:chartSpace>';
|
|
6898
|
+
}
|
|
6899
|
+
|
|
6900
|
+
;// CONCATENATED MODULE: ./src/charts/style.ts
|
|
6901
|
+
/**
|
|
6902
|
+
* Chart style and chart colour-style parts (`ppt/charts/styleN.xml`, `ppt/charts/colorsN.xml`).
|
|
6903
|
+
*
|
|
6904
|
+
* Classic `c:chart` parts write these only when `chartStyle` or `chartColorStyle` is set.
|
|
6905
|
+
* ChartEx layouts always need both: PowerPoint resolves their visual properties through them.
|
|
6906
|
+
*
|
|
6907
|
+
* PowerPoint finds both parts by relationship type from the chart's own `.rels` - nothing inside
|
|
6908
|
+
* `chartN.xml` points at them.
|
|
6909
|
+
*/
|
|
6910
|
+
|
|
6911
|
+
const XML_HEADER = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>';
|
|
6912
|
+
const NS_ATTRS = `xmlns:cs="${CHART_STYLE.ns}" xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main"`;
|
|
6913
|
+
/** The luminance variations Office writes for a six-colour cycling palette */ const DEF_VARIATIONS = [
|
|
6914
|
+
'',
|
|
6915
|
+
'<a:lumMod val="60000"/>',
|
|
6916
|
+
'<a:lumMod val="80000"/><a:lumOff val="20000"/>',
|
|
6917
|
+
'<a:lumMod val="80000"/>',
|
|
6918
|
+
'<a:lumMod val="60000"/><a:lumOff val="40000"/>',
|
|
6919
|
+
'<a:lumMod val="50000"/>',
|
|
6920
|
+
'<a:lumMod val="70000"/><a:lumOff val="30000"/>',
|
|
6921
|
+
'<a:lumMod val="70000"/>',
|
|
6922
|
+
'<a:lumMod val="50000"/><a:lumOff val="50000"/>'
|
|
6923
|
+
];
|
|
6924
|
+
/** The six theme accents, which is what Office's default colour style cycles through */ const DEF_ACCENTS = [
|
|
6925
|
+
'accent1',
|
|
6926
|
+
'accent2',
|
|
6927
|
+
'accent3',
|
|
6928
|
+
'accent4',
|
|
6929
|
+
'accent5',
|
|
6930
|
+
'accent6'
|
|
6931
|
+
];
|
|
6932
|
+
/**
|
|
6933
|
+
* Whether this chart should write `styleN.xml` / `colorsN.xml`.
|
|
6934
|
+
* ChartEx always needs them; classic charts only write them when the caller opts in.
|
|
6935
|
+
*/ function wantsChartStyleParts(opts) {
|
|
6936
|
+
if (!opts) return false;
|
|
6937
|
+
if (isChartexType(opts._type)) return true;
|
|
6938
|
+
return opts.chartStyle !== undefined || opts.chartColorStyle !== undefined;
|
|
6939
|
+
}
|
|
6940
|
+
/**
|
|
6941
|
+
* Part name for a chart's colour style, matching the chart's own number
|
|
6942
|
+
* @param {number} chartNum - the N in `chartN.xml`
|
|
6943
|
+
* @returns {string} part name
|
|
6944
|
+
*/ function chartColorsPartName(chartNum) {
|
|
6945
|
+
return `ppt/charts/colors${chartNum}.xml`;
|
|
6946
|
+
}
|
|
6947
|
+
/**
|
|
6948
|
+
* Part name for a chart's style, matching the chart's own number
|
|
6949
|
+
* @param {number} chartNum - the N in `chartN.xml`
|
|
6950
|
+
* @returns {string} part name
|
|
6951
|
+
*/ function chartStylePartName(chartNum) {
|
|
6952
|
+
return `ppt/charts/style${chartNum}.xml`;
|
|
6953
|
+
}
|
|
6954
|
+
/**
|
|
6955
|
+
* Creates a chart's colour-style part (`cs:colorStyle`).
|
|
6956
|
+
* @param {ChartColorStyleProps} [props] - colour style options
|
|
6957
|
+
* @returns {string} XML
|
|
6958
|
+
*/ function makeXmlChartColors(props) {
|
|
6959
|
+
const methods = [
|
|
6960
|
+
'cycle',
|
|
6961
|
+
'withinLinear',
|
|
6962
|
+
'acrossLinear',
|
|
6963
|
+
'withinLinearReversed',
|
|
6964
|
+
'acrossLinearReversed'
|
|
6965
|
+
];
|
|
6966
|
+
const method = (props === null || props === void 0 ? void 0 : props.method) && methods.includes(props.method) ? props.method : 'cycle';
|
|
6967
|
+
const id = typeof (props === null || props === void 0 ? void 0 : props.id) === 'number' && isFinite(props.id) && props.id > 0 ? Math.round(props.id) : 10;
|
|
6968
|
+
const colors = Array.isArray(props === null || props === void 0 ? void 0 : props.colors) && props.colors.length > 0 ? props.colors.map((color)=>createColorElement(color)).join('') : DEF_ACCENTS.map((accent)=>`<a:schemeClr val="${accent}"/>`).join('');
|
|
6969
|
+
return `${XML_HEADER}<cs:colorStyle ${NS_ATTRS} meth="${method}" id="${id}">` + colors + DEF_VARIATIONS.map((variation)=>variation ? `<cs:variation>${variation}</cs:variation>` : '<cs:variation/>').join('') + '</cs:colorStyle>';
|
|
6970
|
+
}
|
|
6971
|
+
/**
|
|
6972
|
+
* Office's default chart style definitions, verbatim.
|
|
6973
|
+
*
|
|
6974
|
+
* The `@id` names which entry of PowerPoint's gallery is selected; the ~30 `cs:*` children are the
|
|
6975
|
+
* definitions themselves. Only this one set is shipped - reproducing every gallery entry would mean
|
|
6976
|
+
* ~150 more, none of which can be verified from a published schema.
|
|
6977
|
+
*/ const DEF_CHART_STYLE = '<cs:chartStyle xmlns:cs="http://schemas.microsoft.com/office/drawing/2012/chartStyle" xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" id="201"><cs:axisTitle><cs:lnRef idx="0"/><cs:fillRef idx="0"/><cs:effectRef idx="0"/><cs:fontRef idx="minor"><a:schemeClr val="tx1"><a:lumMod val="65000"/><a:lumOff val="35000"/></a:schemeClr></cs:fontRef><cs:defRPr sz="1330" kern="1200"/></cs:axisTitle><cs:categoryAxis><cs:lnRef idx="0"/><cs:fillRef idx="0"/><cs:effectRef idx="0"/><cs:fontRef idx="minor"><a:schemeClr val="tx1"><a:lumMod val="65000"/><a:lumOff val="35000"/></a:schemeClr></cs:fontRef><cs:spPr><a:ln w="9525" cap="flat" cmpd="sng" algn="ctr"><a:solidFill><a:schemeClr val="tx1"><a:lumMod val="15000"/><a:lumOff val="85000"/></a:schemeClr></a:solidFill><a:round/></a:ln></cs:spPr><cs:defRPr sz="1197" kern="1200"/></cs:categoryAxis><cs:chartArea mods="allowNoFillOverride allowNoLineOverride"><cs:lnRef idx="0"/><cs:fillRef idx="0"/><cs:effectRef idx="0"/><cs:fontRef idx="minor"><a:schemeClr val="tx1"/></cs:fontRef><cs:spPr><a:solidFill><a:schemeClr val="bg1"/></a:solidFill><a:ln w="9525" cap="flat" cmpd="sng" algn="ctr"><a:solidFill><a:schemeClr val="tx1"><a:lumMod val="15000"/><a:lumOff val="85000"/></a:schemeClr></a:solidFill><a:round/></a:ln></cs:spPr><cs:defRPr sz="1330" kern="1200"/></cs:chartArea><cs:dataLabel><cs:lnRef idx="0"/><cs:fillRef idx="0"/><cs:effectRef idx="0"/><cs:fontRef idx="minor"><a:schemeClr val="tx1"><a:lumMod val="75000"/><a:lumOff val="25000"/></a:schemeClr></cs:fontRef><cs:defRPr sz="1197" kern="1200"/></cs:dataLabel><cs:dataLabelCallout><cs:lnRef idx="0"/><cs:fillRef idx="0"/><cs:effectRef idx="0"/><cs:fontRef idx="minor"><a:schemeClr val="dk1"><a:lumMod val="65000"/><a:lumOff val="35000"/></a:schemeClr></cs:fontRef><cs:spPr><a:solidFill><a:schemeClr val="lt1"/></a:solidFill><a:ln><a:solidFill><a:schemeClr val="dk1"><a:lumMod val="25000"/><a:lumOff val="75000"/></a:schemeClr></a:solidFill></a:ln></cs:spPr><cs:defRPr sz="1197" kern="1200"/><cs:bodyPr rot="0" spcFirstLastPara="1" vertOverflow="clip" horzOverflow="clip" vert="horz" wrap="square" lIns="36576" tIns="18288" rIns="36576" bIns="18288" anchor="ctr" anchorCtr="1"><a:spAutoFit/></cs:bodyPr></cs:dataLabelCallout><cs:dataPoint><cs:lnRef idx="0"/><cs:fillRef idx="1"><cs:styleClr val="auto"/></cs:fillRef><cs:effectRef idx="0"/><cs:fontRef idx="minor"><a:schemeClr val="tx1"/></cs:fontRef></cs:dataPoint><cs:dataPoint3D><cs:lnRef idx="0"/><cs:fillRef idx="1"><cs:styleClr val="auto"/></cs:fillRef><cs:effectRef idx="0"/><cs:fontRef idx="minor"><a:schemeClr val="tx1"/></cs:fontRef></cs:dataPoint3D><cs:dataPointLine><cs:lnRef idx="0"><cs:styleClr val="auto"/></cs:lnRef><cs:fillRef idx="1"/><cs:effectRef idx="0"/><cs:fontRef idx="minor"><a:schemeClr val="tx1"/></cs:fontRef><cs:spPr><a:ln w="28575" cap="rnd"><a:solidFill><a:schemeClr val="phClr"/></a:solidFill><a:round/></a:ln></cs:spPr></cs:dataPointLine><cs:dataPointMarker><cs:lnRef idx="0"><cs:styleClr val="auto"/></cs:lnRef><cs:fillRef idx="1"><cs:styleClr val="auto"/></cs:fillRef><cs:effectRef idx="0"/><cs:fontRef idx="minor"><a:schemeClr val="tx1"/></cs:fontRef><cs:spPr><a:ln w="9525"><a:solidFill><a:schemeClr val="phClr"/></a:solidFill></a:ln></cs:spPr></cs:dataPointMarker><cs:dataPointMarkerLayout symbol="circle" size="5"/><cs:dataPointWireframe><cs:lnRef idx="0"><cs:styleClr val="auto"/></cs:lnRef><cs:fillRef idx="1"/><cs:effectRef idx="0"/><cs:fontRef idx="minor"><a:schemeClr val="tx1"/></cs:fontRef><cs:spPr><a:ln w="9525" cap="rnd"><a:solidFill><a:schemeClr val="phClr"/></a:solidFill><a:round/></a:ln></cs:spPr></cs:dataPointWireframe><cs:dataTable><cs:lnRef idx="0"/><cs:fillRef idx="0"/><cs:effectRef idx="0"/><cs:fontRef idx="minor"><a:schemeClr val="tx1"><a:lumMod val="65000"/><a:lumOff val="35000"/></a:schemeClr></cs:fontRef><cs:spPr><a:noFill/><a:ln w="9525" cap="flat" cmpd="sng" algn="ctr"><a:solidFill><a:schemeClr val="tx1"><a:lumMod val="15000"/><a:lumOff val="85000"/></a:schemeClr></a:solidFill><a:round/></a:ln></cs:spPr><cs:defRPr sz="1197" kern="1200"/></cs:dataTable><cs:downBar><cs:lnRef idx="0"/><cs:fillRef idx="0"/><cs:effectRef idx="0"/><cs:fontRef idx="minor"><a:schemeClr val="dk1"/></cs:fontRef><cs:spPr><a:solidFill><a:schemeClr val="dk1"><a:lumMod val="65000"/><a:lumOff val="35000"/></a:schemeClr></a:solidFill><a:ln w="9525"><a:solidFill><a:schemeClr val="tx1"><a:lumMod val="65000"/><a:lumOff val="35000"/></a:schemeClr></a:solidFill></a:ln></cs:spPr></cs:downBar><cs:dropLine><cs:lnRef idx="0"/><cs:fillRef idx="0"/><cs:effectRef idx="0"/><cs:fontRef idx="minor"><a:schemeClr val="tx1"/></cs:fontRef><cs:spPr><a:ln w="9525" cap="flat" cmpd="sng" algn="ctr"><a:solidFill><a:schemeClr val="tx1"><a:lumMod val="35000"/><a:lumOff val="65000"/></a:schemeClr></a:solidFill><a:round/></a:ln></cs:spPr></cs:dropLine><cs:errorBar><cs:lnRef idx="0"/><cs:fillRef idx="0"/><cs:effectRef idx="0"/><cs:fontRef idx="minor"><a:schemeClr val="tx1"/></cs:fontRef><cs:spPr><a:ln w="9525" cap="flat" cmpd="sng" algn="ctr"><a:solidFill><a:schemeClr val="tx1"><a:lumMod val="65000"/><a:lumOff val="35000"/></a:schemeClr></a:solidFill><a:round/></a:ln></cs:spPr></cs:errorBar><cs:floor><cs:lnRef idx="0"/><cs:fillRef idx="0"/><cs:effectRef idx="0"/><cs:fontRef idx="minor"><a:schemeClr val="tx1"/></cs:fontRef><cs:spPr><a:noFill/><a:ln><a:noFill/></a:ln></cs:spPr></cs:floor><cs:gridlineMajor><cs:lnRef idx="0"/><cs:fillRef idx="0"/><cs:effectRef idx="0"/><cs:fontRef idx="minor"><a:schemeClr val="tx1"/></cs:fontRef><cs:spPr><a:ln w="9525" cap="flat" cmpd="sng" algn="ctr"><a:solidFill><a:schemeClr val="tx1"><a:lumMod val="15000"/><a:lumOff val="85000"/></a:schemeClr></a:solidFill><a:round/></a:ln></cs:spPr></cs:gridlineMajor><cs:gridlineMinor><cs:lnRef idx="0"/><cs:fillRef idx="0"/><cs:effectRef idx="0"/><cs:fontRef idx="minor"><a:schemeClr val="tx1"/></cs:fontRef><cs:spPr><a:ln w="9525" cap="flat" cmpd="sng" algn="ctr"><a:solidFill><a:schemeClr val="tx1"><a:lumMod val="5000"/><a:lumOff val="95000"/></a:schemeClr></a:solidFill><a:round/></a:ln></cs:spPr></cs:gridlineMinor><cs:hiLoLine><cs:lnRef idx="0"/><cs:fillRef idx="0"/><cs:effectRef idx="0"/><cs:fontRef idx="minor"><a:schemeClr val="tx1"/></cs:fontRef><cs:spPr><a:ln w="9525" cap="flat" cmpd="sng" algn="ctr"><a:solidFill><a:schemeClr val="tx1"><a:lumMod val="75000"/><a:lumOff val="25000"/></a:schemeClr></a:solidFill><a:round/></a:ln></cs:spPr></cs:hiLoLine><cs:leaderLine><cs:lnRef idx="0"/><cs:fillRef idx="0"/><cs:effectRef idx="0"/><cs:fontRef idx="minor"><a:schemeClr val="tx1"/></cs:fontRef><cs:spPr><a:ln w="9525" cap="flat" cmpd="sng" algn="ctr"><a:solidFill><a:schemeClr val="tx1"><a:lumMod val="35000"/><a:lumOff val="65000"/></a:schemeClr></a:solidFill><a:round/></a:ln></cs:spPr></cs:leaderLine><cs:legend><cs:lnRef idx="0"/><cs:fillRef idx="0"/><cs:effectRef idx="0"/><cs:fontRef idx="minor"><a:schemeClr val="tx1"><a:lumMod val="65000"/><a:lumOff val="35000"/></a:schemeClr></cs:fontRef><cs:defRPr sz="1197" kern="1200"/></cs:legend><cs:plotArea mods="allowNoFillOverride allowNoLineOverride"><cs:lnRef idx="0"/><cs:fillRef idx="0"/><cs:effectRef idx="0"/><cs:fontRef idx="minor"><a:schemeClr val="tx1"/></cs:fontRef></cs:plotArea><cs:plotArea3D mods="allowNoFillOverride allowNoLineOverride"><cs:lnRef idx="0"/><cs:fillRef idx="0"/><cs:effectRef idx="0"/><cs:fontRef idx="minor"><a:schemeClr val="tx1"/></cs:fontRef></cs:plotArea3D><cs:seriesAxis><cs:lnRef idx="0"/><cs:fillRef idx="0"/><cs:effectRef idx="0"/><cs:fontRef idx="minor"><a:schemeClr val="tx1"><a:lumMod val="65000"/><a:lumOff val="35000"/></a:schemeClr></cs:fontRef><cs:defRPr sz="1197" kern="1200"/></cs:seriesAxis><cs:seriesLine><cs:lnRef idx="0"/><cs:fillRef idx="0"/><cs:effectRef idx="0"/><cs:fontRef idx="minor"><a:schemeClr val="tx1"/></cs:fontRef><cs:spPr><a:ln w="9525" cap="flat" cmpd="sng" algn="ctr"><a:solidFill><a:schemeClr val="tx1"><a:lumMod val="35000"/><a:lumOff val="65000"/></a:schemeClr></a:solidFill><a:round/></a:ln></cs:spPr></cs:seriesLine><cs:title><cs:lnRef idx="0"/><cs:fillRef idx="0"/><cs:effectRef idx="0"/><cs:fontRef idx="minor"><a:schemeClr val="tx1"><a:lumMod val="65000"/><a:lumOff val="35000"/></a:schemeClr></cs:fontRef><cs:defRPr sz="1862" b="0" kern="1200" spc="0" baseline="0"/></cs:title><cs:trendline><cs:lnRef idx="0"><cs:styleClr val="auto"/></cs:lnRef><cs:fillRef idx="0"/><cs:effectRef idx="0"/><cs:fontRef idx="minor"><a:schemeClr val="tx1"/></cs:fontRef><cs:spPr><a:ln w="19050" cap="rnd"><a:solidFill><a:schemeClr val="phClr"/></a:solidFill><a:prstDash val="sysDot"/></a:ln></cs:spPr></cs:trendline><cs:trendlineLabel><cs:lnRef idx="0"/><cs:fillRef idx="0"/><cs:effectRef idx="0"/><cs:fontRef idx="minor"><a:schemeClr val="tx1"><a:lumMod val="65000"/><a:lumOff val="35000"/></a:schemeClr></cs:fontRef><cs:defRPr sz="1197" kern="1200"/></cs:trendlineLabel><cs:upBar><cs:lnRef idx="0"/><cs:fillRef idx="0"/><cs:effectRef idx="0"/><cs:fontRef idx="minor"><a:schemeClr val="dk1"/></cs:fontRef><cs:spPr><a:solidFill><a:schemeClr val="lt1"/></a:solidFill><a:ln w="9525"><a:solidFill><a:schemeClr val="tx1"><a:lumMod val="15000"/><a:lumOff val="85000"/></a:schemeClr></a:solidFill></a:ln></cs:spPr></cs:upBar><cs:valueAxis><cs:lnRef idx="0"/><cs:fillRef idx="0"/><cs:effectRef idx="0"/><cs:fontRef idx="minor"><a:schemeClr val="tx1"><a:lumMod val="65000"/><a:lumOff val="35000"/></a:schemeClr></cs:fontRef><cs:defRPr sz="1197" kern="1200"/></cs:valueAxis><cs:wall><cs:lnRef idx="0"/><cs:fillRef idx="0"/><cs:effectRef idx="0"/><cs:fontRef idx="minor"><a:schemeClr val="tx1"/></cs:fontRef><cs:spPr><a:noFill/><a:ln><a:noFill/></a:ln></cs:spPr></cs:wall></cs:chartStyle>';
|
|
6978
|
+
/**
|
|
6979
|
+
* Creates a chart's style part (`cs:chartStyle`).
|
|
6980
|
+
* @param {number} [styleId] - which gallery entry is selected; the definitions are Office's defaults
|
|
6981
|
+
* @returns {string} XML
|
|
6982
|
+
*/ function makeXmlChartStyle(styleId) {
|
|
6983
|
+
const body = typeof styleId === 'number' && isFinite(styleId) && styleId > 0 ? DEF_CHART_STYLE.replace(/ id="\d+">/, ` id="${Math.round(styleId)}">`) : DEF_CHART_STYLE;
|
|
6984
|
+
return XML_HEADER + body;
|
|
5627
6985
|
}
|
|
5628
|
-
|
|
5629
|
-
|
|
5630
|
-
|
|
5631
|
-
|
|
5632
|
-
|
|
5633
|
-
|
|
5634
|
-
|
|
5635
|
-
|
|
6986
|
+
|
|
6987
|
+
;// CONCATENATED MODULE: ./src/charts/title.ts
|
|
6988
|
+
/**
|
|
6989
|
+
* Chart title rendering.
|
|
6990
|
+
*/
|
|
6991
|
+
|
|
6992
|
+
/**
|
|
6993
|
+
* Create char title elements
|
|
6994
|
+
* @param {IChartPropsTitle} opts - options
|
|
6995
|
+
* @return {string} XML `<c:title>`
|
|
6996
|
+
*/ function genXmlTitle(opts, chartX, chartY) {
|
|
6997
|
+
const align = opts.titleAlign === 'left' || opts.titleAlign === 'right' ? `<a:pPr algn="${opts.titleAlign.substring(0, 1)}">` : '<a:pPr>';
|
|
6998
|
+
const rotate = opts.titleRotate ? `<a:bodyPr rot="${convertRotationDegrees(opts.titleRotate)}"/>` : '<a:bodyPr/>' // don't specify rotation to get default (ex. vertical for cat axis)
|
|
6999
|
+
;
|
|
7000
|
+
const sizeAttr = opts.fontSize ? `sz="${Math.round(opts.fontSize * 100)}"` : '' // only set the font size if specified. Powerpoint will handle the default size
|
|
7001
|
+
;
|
|
7002
|
+
const titleBold = opts.titleBold ? 1 : 0;
|
|
7003
|
+
const titleItalic = opts.titleItalic ? 1 : 0;
|
|
7004
|
+
let layout = '<c:layout/>';
|
|
7005
|
+
if (opts.titlePos && typeof opts.titlePos.x === 'number' && typeof opts.titlePos.y === 'number') {
|
|
7006
|
+
// NOTE: manualLayout x/y vals are *relative to entire slide*
|
|
7007
|
+
const totalX = opts.titlePos.x + (chartX !== null && chartX !== void 0 ? chartX : 0);
|
|
7008
|
+
const totalY = opts.titlePos.y + (chartY !== null && chartY !== void 0 ? chartY : 0);
|
|
7009
|
+
let valX = totalX === 0 ? 0 : totalX * (totalX / 5) / 10;
|
|
7010
|
+
if (valX >= 1) valX = valX / 10;
|
|
7011
|
+
if (valX >= 0.1) valX = valX / 10;
|
|
7012
|
+
let valY = totalY === 0 ? 0 : totalY * (totalY / 5) / 10;
|
|
7013
|
+
if (valY >= 1) valY = valY / 10;
|
|
7014
|
+
if (valY >= 0.1) valY = valY / 10;
|
|
7015
|
+
layout = `<c:layout><c:manualLayout><c:xMode val="edge"/><c:yMode val="edge"/><c:x val="${valX}"/><c:y val="${valY}"/></c:manualLayout></c:layout>`;
|
|
7016
|
+
}
|
|
7017
|
+
return `<c:title>
|
|
7018
|
+
<c:tx>
|
|
7019
|
+
<c:rich>
|
|
7020
|
+
${rotate}
|
|
7021
|
+
<a:lstStyle/>
|
|
7022
|
+
<a:p>
|
|
7023
|
+
${align}
|
|
7024
|
+
<a:defRPr ${sizeAttr} b="${titleBold}" i="${titleItalic}" u="none" strike="noStrike">
|
|
7025
|
+
<a:solidFill>${createColorElement(opts.color || (/* inlined export .DEF_FONT_COLOR */"000000"))}</a:solidFill>
|
|
7026
|
+
<a:latin typeface="${encodeXmlEntities(opts.fontFace) || 'Arial'}"/>
|
|
7027
|
+
<a:ea typeface="${encodeXmlEntities(opts.fontFace) || 'Arial'}"/>
|
|
7028
|
+
</a:defRPr>
|
|
7029
|
+
</a:pPr>
|
|
7030
|
+
<a:r>
|
|
7031
|
+
<a:rPr ${sizeAttr} b="${titleBold}" i="${titleItalic}" u="none" strike="noStrike">
|
|
7032
|
+
<a:solidFill>${createColorElement(opts.color || (/* inlined export .DEF_FONT_COLOR */"000000"))}</a:solidFill>
|
|
7033
|
+
<a:latin typeface="${encodeXmlEntities(opts.fontFace) || 'Arial'}"/>
|
|
7034
|
+
<a:ea typeface="${encodeXmlEntities(opts.fontFace) || 'Arial'}"/>
|
|
7035
|
+
</a:rPr>
|
|
7036
|
+
<a:t>${encodeXmlEntities(opts.title) || ''}</a:t>
|
|
7037
|
+
</a:r>
|
|
7038
|
+
</a:p>
|
|
7039
|
+
</c:rich>
|
|
7040
|
+
</c:tx>
|
|
7041
|
+
${layout}
|
|
7042
|
+
<c:overlay val="0"/>
|
|
7043
|
+
</c:title>`;
|
|
5636
7044
|
}
|
|
5637
7045
|
|
|
5638
7046
|
;// CONCATENATED MODULE: ./src/charts/axes.ts
|
|
@@ -6057,7 +7465,7 @@ function xml_object_spread_props(target, source) {
|
|
|
6057
7465
|
usesSecondaryValAxis = usesSecondaryValAxis || ((_options_secondaryValAxis = options.secondaryValAxis) !== null && _options_secondaryValAxis !== void 0 ? _options_secondaryValAxis : false);
|
|
6058
7466
|
strXml += makeChartType(type.type, type.data, options, valAxisId, catAxisId, true, rel.data);
|
|
6059
7467
|
});
|
|
6060
|
-
} else if (rel.opts._type) {
|
|
7468
|
+
} else if (rel.opts._type && !isChartexType(rel.opts._type)) {
|
|
6061
7469
|
strXml += makeChartType(rel.opts._type, rel.data, rel.opts, AXIS_ID_VALUE_PRIMARY, AXIS_ID_CATEGORY_PRIMARY, false, rel.data);
|
|
6062
7470
|
}
|
|
6063
7471
|
// B: Axes -----------------------------------------------------------
|
|
@@ -7103,6 +8511,8 @@ function _async_to_generator(fn) {
|
|
|
7103
8511
|
|
|
7104
8512
|
|
|
7105
8513
|
|
|
8514
|
+
|
|
8515
|
+
|
|
7106
8516
|
function getDataTableStyles(chartObject) {
|
|
7107
8517
|
const dataTableFormats = Array.isArray(chartObject.opts._type) ? chartObject.opts._type.flatMap((type)=>{
|
|
7108
8518
|
var _ref;
|
|
@@ -7607,8 +9017,19 @@ function makeNumberStyles(formats) {
|
|
|
7607
9017
|
base64: true
|
|
7608
9018
|
});
|
|
7609
9019
|
// 2: Create the chart.xml and rel files
|
|
7610
|
-
|
|
7611
|
-
|
|
9020
|
+
// PowerPoint finds the style and colour-style parts by relationship type, so they are
|
|
9021
|
+
// declared here rather than referenced from inside `chartN.xml`.
|
|
9022
|
+
// Classic charts write them only when requested; ChartEx layouts always need them.
|
|
9023
|
+
const isChartex = isChartexType(chartObject.opts._type);
|
|
9024
|
+
const writeStyleParts = wantsChartStyleParts(chartObject.opts);
|
|
9025
|
+
const styleRels = writeStyleParts ? `<Relationship Id="rId2" Type="${CHART_STYLE.colorsRelType}" Target="colors${chartObject.globalId}.xml"/>` + `<Relationship Id="rId3" Type="${CHART_STYLE.styleRelType}" Target="style${chartObject.globalId}.xml"/>` : '';
|
|
9026
|
+
zip.file('ppt/charts/_rels/' + chartObject.fileName + '.rels', '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>' + '<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">' + `<Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/package" Target="../embeddings/Microsoft_Excel_Worksheet${chartObject.globalId}.xlsx"/>` + styleRels + '</Relationships>');
|
|
9027
|
+
zip.file(`ppt/charts/${chartObject.fileName}`, isChartex ? makeXmlChartEx(chartObject) : makeXmlCharts(chartObject));
|
|
9028
|
+
if (writeStyleParts) {
|
|
9029
|
+
var _chartObject_opts, _chartObject_opts1;
|
|
9030
|
+
zip.file(chartColorsPartName(chartObject.globalId), makeXmlChartColors((_chartObject_opts = chartObject.opts) === null || _chartObject_opts === void 0 ? void 0 : _chartObject_opts.chartColorStyle));
|
|
9031
|
+
zip.file(chartStylePartName(chartObject.globalId), makeXmlChartStyle((_chartObject_opts1 = chartObject.opts) === null || _chartObject_opts1 === void 0 ? void 0 : _chartObject_opts1.chartStyle));
|
|
9032
|
+
}
|
|
7612
9033
|
// 3: Done
|
|
7613
9034
|
resolve('');
|
|
7614
9035
|
}).catch((strErr)=>{
|
|
@@ -7621,6 +9042,8 @@ function makeNumberStyles(formats) {
|
|
|
7621
9042
|
|
|
7622
9043
|
|
|
7623
9044
|
|
|
9045
|
+
|
|
9046
|
+
|
|
7624
9047
|
;// CONCATENATED MODULE: ./src/vendor/fonteditor-core/common/lang.js
|
|
7625
9048
|
/**
|
|
7626
9049
|
* @file 语言相关函数
|
|
@@ -15922,7 +17345,7 @@ function imageDimensions(bytes) {
|
|
|
15922
17345
|
});
|
|
15923
17346
|
}
|
|
15924
17347
|
/** Select relations that still need their local or remote media encoded. */ function getMediaCandidates(layout) {
|
|
15925
|
-
return layout._relsMedia.filter((rel)
|
|
17348
|
+
return layout._relsMedia.filter((rel)=>!rel.isLinked && rel.type !== 'online' && !rel.data && (!rel.path || rel.path && !rel.path.includes('preencoded')));
|
|
15926
17349
|
}
|
|
15927
17350
|
/**
|
|
15928
17351
|
* Mark repeated source paths so only the first relation performs I/O.
|
|
@@ -19215,7 +20638,8 @@ function replyXml(reply, authors, fallbackDate) {
|
|
|
19215
20638
|
// is the absolute `/ppt/charts/chartN.xml` form reused as Content_Types PartName.
|
|
19216
20639
|
// PowerPoint writes the relative `../charts/chartN.xml`; absolute targets are valid but
|
|
19217
20640
|
// non-idiomatic and break stricter consumers (PR 1465 / eliasaronson).
|
|
19218
|
-
|
|
20641
|
+
const relType = isChartexType(rel.opts._type) ? OOXML_CHARTEX.relType : 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart';
|
|
20642
|
+
strXml += `<Relationship Id="rId${rel.rId}" Type="${relType}" Target="${rel.Target.replace(/^\/ppt\//, '../')}"/>`;
|
|
19219
20643
|
});
|
|
19220
20644
|
(slide._relsMedia || []).forEach((rel)=>{
|
|
19221
20645
|
const relRid = rel.rId.toString();
|
|
@@ -19224,17 +20648,19 @@ function replyXml(reply, authors, fallbackDate) {
|
|
|
19224
20648
|
strXml += '<Relationship Id="rId' + relRid + '" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/image" Target="' + rel.Target + '"/>';
|
|
19225
20649
|
} else if (rel.type.toLowerCase().includes('audio')) {
|
|
19226
20650
|
// As media has *TWO* rel entries per item, check for first one, if found add second rel with alt style
|
|
20651
|
+
const externalAttr = rel.isLinked ? ' TargetMode="External"' : '';
|
|
19227
20652
|
if (strXml.includes(' Target="' + rel.Target + '"')) {
|
|
19228
|
-
strXml += '<Relationship Id="rId' + relRid + '" Type="http://schemas.microsoft.com/office/2007/relationships/media" Target="' + rel.Target + '"/>';
|
|
20653
|
+
strXml += '<Relationship Id="rId' + relRid + '" Type="http://schemas.microsoft.com/office/2007/relationships/media" Target="' + rel.Target + '"' + externalAttr + '/>';
|
|
19229
20654
|
} else {
|
|
19230
|
-
strXml += '<Relationship Id="rId' + relRid + '" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/audio" Target="' + rel.Target + '"/>';
|
|
20655
|
+
strXml += '<Relationship Id="rId' + relRid + '" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/audio" Target="' + rel.Target + '"' + externalAttr + '/>';
|
|
19231
20656
|
}
|
|
19232
20657
|
} else if (rel.type.toLowerCase().includes('video')) {
|
|
19233
20658
|
// As media has *TWO* rel entries per item, check for first one, if found add second rel with alt style
|
|
20659
|
+
const externalAttr = rel.isLinked ? ' TargetMode="External"' : '';
|
|
19234
20660
|
if (strXml.includes(' Target="' + rel.Target + '"')) {
|
|
19235
|
-
strXml += '<Relationship Id="rId' + relRid + '" Type="http://schemas.microsoft.com/office/2007/relationships/media" Target="' + rel.Target + '"/>';
|
|
20661
|
+
strXml += '<Relationship Id="rId' + relRid + '" Type="http://schemas.microsoft.com/office/2007/relationships/media" Target="' + rel.Target + '"' + externalAttr + '/>';
|
|
19236
20662
|
} else {
|
|
19237
|
-
strXml += '<Relationship Id="rId' + relRid + '" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/video" Target="' + rel.Target + '"/>';
|
|
20663
|
+
strXml += '<Relationship Id="rId' + relRid + '" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/video" Target="' + rel.Target + '"' + externalAttr + '/>';
|
|
19238
20664
|
}
|
|
19239
20665
|
} else if (rel.type.toLowerCase().includes('online')) {
|
|
19240
20666
|
// As media has *TWO* rel entries per item, check for first one, if found add second rel with alt style
|
|
@@ -19441,6 +20867,171 @@ function unsignedInt(value) {
|
|
|
19441
20867
|
return `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\r\n<pc:chgInfo xmlns:pc="${CHANGES_INFO_NS}"/>`;
|
|
19442
20868
|
}
|
|
19443
20869
|
|
|
20870
|
+
;// CONCATENATED MODULE: ./src/xml/non-visual.ts
|
|
20871
|
+
/**
|
|
20872
|
+
* PptxGenJS: Non-visual drawing properties (`p:cNvPr`) and editing locks
|
|
20873
|
+
*
|
|
20874
|
+
* Every drawable object carries a `p:cNvPr` with its id, name, and alt text, and a sibling
|
|
20875
|
+
* `p:cNv*Pr` holding the lock element for its kind - `a:spLocks` for shapes, `a:picLocks` for
|
|
20876
|
+
* pictures, `a:graphicFrameLocks` for frames, `a:grpSpLocks` for groups, `a:cxnSpLocks` for
|
|
20877
|
+
* connectors. The lock attributes are shared, so one emitter serves all five.
|
|
20878
|
+
*/
|
|
20879
|
+
/** Lock attribute names, in the order the schema declares them */ const LOCK_ATTRS = [
|
|
20880
|
+
[
|
|
20881
|
+
'noGroup',
|
|
20882
|
+
'noGrp'
|
|
20883
|
+
],
|
|
20884
|
+
[
|
|
20885
|
+
'noSelect',
|
|
20886
|
+
'noSelect'
|
|
20887
|
+
],
|
|
20888
|
+
[
|
|
20889
|
+
'noRotate',
|
|
20890
|
+
'noRot'
|
|
20891
|
+
],
|
|
20892
|
+
[
|
|
20893
|
+
'noChangeAspect',
|
|
20894
|
+
'noChangeAspect'
|
|
20895
|
+
],
|
|
20896
|
+
[
|
|
20897
|
+
'noMove',
|
|
20898
|
+
'noMove'
|
|
20899
|
+
],
|
|
20900
|
+
[
|
|
20901
|
+
'noResize',
|
|
20902
|
+
'noResize'
|
|
20903
|
+
],
|
|
20904
|
+
[
|
|
20905
|
+
'noEditPoints',
|
|
20906
|
+
'noEditPoints'
|
|
20907
|
+
],
|
|
20908
|
+
[
|
|
20909
|
+
'noAdjustHandles',
|
|
20910
|
+
'noAdjustHandles'
|
|
20911
|
+
],
|
|
20912
|
+
[
|
|
20913
|
+
'noChangeArrowheads',
|
|
20914
|
+
'noChangeArrowheads'
|
|
20915
|
+
],
|
|
20916
|
+
[
|
|
20917
|
+
'noChangeShapeType',
|
|
20918
|
+
'noChangeShapeType'
|
|
20919
|
+
],
|
|
20920
|
+
[
|
|
20921
|
+
'noTextEdit',
|
|
20922
|
+
'noTextEdit'
|
|
20923
|
+
],
|
|
20924
|
+
[
|
|
20925
|
+
'noCrop',
|
|
20926
|
+
'noCrop'
|
|
20927
|
+
]
|
|
20928
|
+
];
|
|
20929
|
+
/** Which lock attributes each element actually permits */ const ALLOWED = {
|
|
20930
|
+
'a:spLocks': new Set([
|
|
20931
|
+
'noGrp',
|
|
20932
|
+
'noSelect',
|
|
20933
|
+
'noRot',
|
|
20934
|
+
'noChangeAspect',
|
|
20935
|
+
'noMove',
|
|
20936
|
+
'noResize',
|
|
20937
|
+
'noEditPoints',
|
|
20938
|
+
'noAdjustHandles',
|
|
20939
|
+
'noChangeArrowheads',
|
|
20940
|
+
'noChangeShapeType',
|
|
20941
|
+
'noTextEdit'
|
|
20942
|
+
]),
|
|
20943
|
+
'a:picLocks': new Set([
|
|
20944
|
+
'noGrp',
|
|
20945
|
+
'noSelect',
|
|
20946
|
+
'noRot',
|
|
20947
|
+
'noChangeAspect',
|
|
20948
|
+
'noMove',
|
|
20949
|
+
'noResize',
|
|
20950
|
+
'noEditPoints',
|
|
20951
|
+
'noAdjustHandles',
|
|
20952
|
+
'noChangeArrowheads',
|
|
20953
|
+
'noChangeShapeType',
|
|
20954
|
+
'noCrop'
|
|
20955
|
+
]),
|
|
20956
|
+
'a:graphicFrameLocks': new Set([
|
|
20957
|
+
'noGrp',
|
|
20958
|
+
'noSelect',
|
|
20959
|
+
'noChangeAspect',
|
|
20960
|
+
'noMove',
|
|
20961
|
+
'noResize',
|
|
20962
|
+
'noDrilldown'
|
|
20963
|
+
]),
|
|
20964
|
+
'a:grpSpLocks': new Set([
|
|
20965
|
+
'noGrp',
|
|
20966
|
+
'noSelect',
|
|
20967
|
+
'noRot',
|
|
20968
|
+
'noChangeAspect',
|
|
20969
|
+
'noMove',
|
|
20970
|
+
'noResize',
|
|
20971
|
+
'noUngrp'
|
|
20972
|
+
]),
|
|
20973
|
+
'a:cxnSpLocks': new Set([
|
|
20974
|
+
'noGrp',
|
|
20975
|
+
'noSelect',
|
|
20976
|
+
'noRot',
|
|
20977
|
+
'noChangeAspect',
|
|
20978
|
+
'noMove',
|
|
20979
|
+
'noResize',
|
|
20980
|
+
'noEditPoints',
|
|
20981
|
+
'noAdjustHandles',
|
|
20982
|
+
'noChangeArrowheads',
|
|
20983
|
+
'noChangeShapeType'
|
|
20984
|
+
])
|
|
20985
|
+
};
|
|
20986
|
+
/**
|
|
20987
|
+
* Create a lock element, or `''` when nothing is locked
|
|
20988
|
+
* - attributes the element does not permit are dropped: an unexpected one is a schema violation
|
|
20989
|
+
* @param {string} tag - lock element name for the object's kind
|
|
20990
|
+
* @param {ShapeLockProps} lock - lock props
|
|
20991
|
+
* @param {string} defaults - attributes the library already emits for this object
|
|
20992
|
+
* @returns {string} XML string
|
|
20993
|
+
*/ function genXmlLocks(tag, lock, defaults = '') {
|
|
20994
|
+
var _ALLOWED_tag;
|
|
20995
|
+
const allowed = (_ALLOWED_tag = ALLOWED[tag]) !== null && _ALLOWED_tag !== void 0 ? _ALLOWED_tag : new Set();
|
|
20996
|
+
let attrs = defaults;
|
|
20997
|
+
LOCK_ATTRS.forEach(([prop, attr])=>{
|
|
20998
|
+
if ((lock === null || lock === void 0 ? void 0 : lock[prop]) !== true) return;
|
|
20999
|
+
if (!allowed.has(attr)) {
|
|
21000
|
+
console.warn(`[pptxgenjs] \`${String(prop)}\` does not apply to this object type - ignored`);
|
|
21001
|
+
return;
|
|
21002
|
+
}
|
|
21003
|
+
// do not repeat an attribute the caller already gets by default
|
|
21004
|
+
if (defaults.includes(`${attr}="`)) return;
|
|
21005
|
+
attrs += ` ${attr}="1"`;
|
|
21006
|
+
});
|
|
21007
|
+
return attrs ? `<${tag}${attrs}/>` : '';
|
|
21008
|
+
}
|
|
21009
|
+
/**
|
|
21010
|
+
* Create the `p:cNvPr` element
|
|
21011
|
+
* @param {number} id - shape id, unique on the slide
|
|
21012
|
+
* @param {string} name - shape name shown in the selection pane (already XML-escaped by callers)
|
|
21013
|
+
* @param {NonVisualProps} props - non-visual options
|
|
21014
|
+
* @param {string} descr - alt-text description
|
|
21015
|
+
* @param {string} children - child elements (ex: hyperlinks); self-closes when empty
|
|
21016
|
+
* @returns {string} XML string
|
|
21017
|
+
*/ function genXmlCNvPr(id, name, props, descr = '', children = '') {
|
|
21018
|
+
let attrs = `id="${id}" name="${name}"`;
|
|
21019
|
+
// `descr` is the alt-text description; `title` is the separate alt-text title
|
|
21020
|
+
if (descr) attrs += ` descr="${encodeXmlEntities(descr)}"`;
|
|
21021
|
+
if (props === null || props === void 0 ? void 0 : props.title) attrs += ` title="${encodeXmlEntities(props.title)}"`;
|
|
21022
|
+
if ((props === null || props === void 0 ? void 0 : props.hidden) === true) attrs += ' hidden="1"';
|
|
21023
|
+
return children ? `<p:cNvPr ${attrs}>${children}</p:cNvPr>` : `<p:cNvPr ${attrs}/>`;
|
|
21024
|
+
}
|
|
21025
|
+
/**
|
|
21026
|
+
* Create `p:cNvSpPr`, carrying the text-box flag and any shape locks
|
|
21027
|
+
* @param {object} options - shape options
|
|
21028
|
+
* @returns {string} XML string
|
|
21029
|
+
*/ function genXmlCNvSpPr(options) {
|
|
21030
|
+
const txBox = (options === null || options === void 0 ? void 0 : options.isTextBox) ? ' txBox="1"' : '';
|
|
21031
|
+
const locks = genXmlLocks('a:spLocks', options === null || options === void 0 ? void 0 : options.lock);
|
|
21032
|
+
return locks ? `<p:cNvSpPr${txBox}>${locks}</p:cNvSpPr>` : `<p:cNvSpPr${txBox}/>`;
|
|
21033
|
+
}
|
|
21034
|
+
|
|
19444
21035
|
;// CONCATENATED MODULE: ./src/xml/slide.ts
|
|
19445
21036
|
function xml_slide_define_property(obj, key, value) {
|
|
19446
21037
|
if (key in obj) {
|
|
@@ -19499,11 +21090,34 @@ function slide_object_spread_props(target, source) {
|
|
|
19499
21090
|
|
|
19500
21091
|
|
|
19501
21092
|
|
|
21093
|
+
|
|
21094
|
+
|
|
21095
|
+
|
|
19502
21096
|
function nvPrModIdExt(modId) {
|
|
19503
21097
|
return genXmlModIdExt(modId).replace(/^<p:extLst>|<\/p:extLst>$/g, '');
|
|
19504
21098
|
}
|
|
19505
21099
|
function genXmlNvPr(options, phXml = '', extraExts = []) {
|
|
19506
|
-
|
|
21100
|
+
const attrs = ((options === null || options === void 0 ? void 0 : options.isPhoto) === true ? ' isPhoto="1"' : '') + ((options === null || options === void 0 ? void 0 : options.userDrawn) === true ? ' userDrawn="1"' : '');
|
|
21101
|
+
return `<p:nvPr${attrs}>${phXml}${genXmlNvPrExtLst(options, extraExts)}</p:nvPr>`;
|
|
21102
|
+
}
|
|
21103
|
+
/**
|
|
21104
|
+
* Fallback shape for a chartex graphic frame (`mc:Fallback`).
|
|
21105
|
+
*
|
|
21106
|
+
* PowerPoint writes a rendered preview picture here, which this library cannot produce without a
|
|
21107
|
+
* rasterizer. A locked, non-editable text shape occupying the same box is the closest honest
|
|
21108
|
+
* substitute: a consumer that rejects the `mc:Choice` still sees where the chart is and why it is
|
|
21109
|
+
* not drawn, and cannot silently edit it into something that no longer matches the chart part.
|
|
21110
|
+
*/ function genXmlChartExFallback(shapeId, slideItemObj, box) {
|
|
21111
|
+
var _slideItemObj_options, _options_objectName, _options_altText;
|
|
21112
|
+
const options = (_slideItemObj_options = slideItemObj.options) !== null && _slideItemObj_options !== void 0 ? _slideItemObj_options : {};
|
|
21113
|
+
const name = (_options_objectName = options.objectName) !== null && _options_objectName !== void 0 ? _options_objectName : 'Chart';
|
|
21114
|
+
const message = 'This chart is not available in your version of PowerPoint. Editing this shape or saving this file in a different format will permanently break the chart.';
|
|
21115
|
+
// A chart's `title` is the chart title, not the alt-text title `p:cNvPr@title` carries.
|
|
21116
|
+
// `noTextEdit` is not optional: an edited fallback would no longer match the chart part.
|
|
21117
|
+
return '<p:sp>' + '<p:nvSpPr>' + `<p:cNvPr id="${shapeId}" name="${encodeXmlEntities(name)}" descr="${encodeXmlEntities((_options_altText = options.altText) !== null && _options_altText !== void 0 ? _options_altText : message)}"/>` + '<p:cNvSpPr><a:spLocks noTextEdit="1"/></p:cNvSpPr>' + '<p:nvPr/>' + '</p:nvSpPr>' + `<p:spPr><a:xfrm><a:off x="${box.x}" y="${box.y}"/><a:ext cx="${box.cx}" cy="${box.cy}"/></a:xfrm>` + '<a:prstGeom prst="rect"><a:avLst/></a:prstGeom>' + '<a:solidFill><a:prstClr val="white"/></a:solidFill>' + '<a:ln><a:solidFill><a:prstClr val="black"/></a:solidFill></a:ln></p:spPr>' + '<p:txBody><a:bodyPr vertOverflow="clip" horzOverflow="clip" wrap="square"><a:normAutofit/></a:bodyPr><a:lstStyle/>' + `<a:p><a:r><a:rPr lang="en-US" sz="1100"/><a:t>${encodeXmlEntities(message)}</a:t></a:r></a:p>` + '</p:txBody>' + '</p:sp>';
|
|
21118
|
+
}
|
|
21119
|
+
function genXmlCNvPrLinks(click, hover) {
|
|
21120
|
+
return ((click === null || click === void 0 ? void 0 : click._rId) ? genXmlHyperlink(click, 'click', 'shape') : '') + ((hover === null || hover === void 0 ? void 0 : hover._rId) ? genXmlHyperlink(hover, 'hover', 'shape') : '');
|
|
19507
21121
|
}
|
|
19508
21122
|
const ImageSizingXml = {
|
|
19509
21123
|
cover: function(imgSize, boxDim) {
|
|
@@ -19584,10 +21198,6 @@ const ImageSizingXml = {
|
|
|
19584
21198
|
return opts.tableStyleId ? `<a:tblPr${attrs}><a:tableStyleId>${encodeXmlEntities(opts.tableStyleId)}</a:tableStyleId></a:tblPr>` : `<a:tblPr${attrs}/>`;
|
|
19585
21199
|
}
|
|
19586
21200
|
/**
|
|
19587
|
-
* Create the `a:ln` outline block for a shape/image
|
|
19588
|
-
* @param {ShapeLineProps} line - line options
|
|
19589
|
-
* @return {string} XML
|
|
19590
|
-
*/ /**
|
|
19591
21201
|
* Builds `<p14:trim>` / `<p14:fade>` / `<p14:bmkLst>` children of `<p14:media>` (MS-PPTX §2.3.3.14).
|
|
19592
21202
|
* Times are ST_UniversalTimeOffset (ms).
|
|
19593
21203
|
*/ function genXmlMediaExtras(opts) {
|
|
@@ -19597,40 +21207,47 @@ const ImageSizingXml = {
|
|
|
19597
21207
|
if (opts.bookmarks && opts.bookmarks.length > 0) xml += `<p14:bmkLst>${opts.bookmarks.map((b)=>`<p14:bmk name="${encodeXmlEntities(b.name)}" time="${Math.round(b.time)}"/>`).join('')}</p14:bmkLst>`;
|
|
19598
21208
|
return xml;
|
|
19599
21209
|
}
|
|
19600
|
-
|
|
19601
|
-
|
|
19602
|
-
|
|
19603
|
-
|
|
19604
|
-
|
|
19605
|
-
|
|
19606
|
-
|
|
19607
|
-
|
|
19608
|
-
|
|
19609
|
-
|
|
19610
|
-
|
|
19611
|
-
|
|
19612
|
-
|
|
19613
|
-
|
|
19614
|
-
|
|
19615
|
-
|
|
19616
|
-
|
|
19617
|
-
|
|
19618
|
-
|
|
19619
|
-
|
|
21210
|
+
/**
|
|
21211
|
+
* One `a:tcPr` border line (`a:lnL`, `a:lnTlToBr`, ...)
|
|
21212
|
+
* - the four edges and the two diagonals share CT_LineProperties, so they share this emitter
|
|
21213
|
+
* @param {string} name - element name without the `a:` prefix
|
|
21214
|
+
* @param {BorderProps} border - border definition
|
|
21215
|
+
* @returns {string} XML
|
|
21216
|
+
*/ function genXmlCellBorder(name, border) {
|
|
21217
|
+
var _ref, _border_width, _border_color;
|
|
21218
|
+
if (border.type === 'none') return `<a:${name} w="0" cap="flat" cmpd="sng" algn="ctr"><a:noFill/></a:${name}>`;
|
|
21219
|
+
const width = (_ref = (_border_width = border.width) !== null && _border_width !== void 0 ? _border_width : border.pt) !== null && _ref !== void 0 ? _ref : DEF_CELL_BORDER.pt;
|
|
21220
|
+
const borderTransparency = border.transparency;
|
|
21221
|
+
const borderAlpha = typeof borderTransparency === 'number' ? `<a:alpha val="${Math.round((100 - Math.min(100, Math.max(0, borderTransparency))) * 1000)}"/>` : '';
|
|
21222
|
+
return `<a:${name} w="${valToPts(width)}" cap="flat" cmpd="sng" algn="ctr">` + `<a:solidFill>${createColorElement((_border_color = border.color) !== null && _border_color !== void 0 ? _border_color : DEF_CELL_BORDER.color, borderAlpha)}</a:solidFill>` + `<a:prstDash val="${border.type === 'dash' ? 'sysDash' : 'solid'}"/><a:round/>` + '<a:headEnd type="none" w="med" len="med"/><a:tailEnd type="none" w="med" len="med"/>' + `</a:${name}>`;
|
|
21223
|
+
}
|
|
21224
|
+
/**
|
|
21225
|
+
* One `a:audioCd` endpoint (`a:st` or `a:end`).
|
|
21226
|
+
* - `@track` is required and is an `xsd:unsignedByte`, so it is clamped; `@time` defaults to 0
|
|
21227
|
+
*/ function genXmlAudioCdTime(tag, point) {
|
|
21228
|
+
var _ref;
|
|
21229
|
+
const track = Math.min(255, Math.max(0, Math.round((_ref = point === null || point === void 0 ? void 0 : point.track) !== null && _ref !== void 0 ? _ref : 0)));
|
|
21230
|
+
const time = typeof (point === null || point === void 0 ? void 0 : point.time) === 'number' && isFinite(point.time) && point.time > 0 ? ` time="${Math.round(point.time)}"` : '';
|
|
21231
|
+
return `<${tag} track="${track}"${time}/>`;
|
|
19620
21232
|
}
|
|
19621
21233
|
/**
|
|
19622
21234
|
* Create a single `a:outerShdw` / `a:innerShdw` element (no `effectLst` wrapper).
|
|
19623
21235
|
* @note pure - unit conversion must NOT mutate the caller's options (issue #20)
|
|
19624
21236
|
*/ function genXmlShadowElement(shadow) {
|
|
19625
|
-
var
|
|
19626
|
-
const type = shadow.type === 'inner' ? 'inner' : 'outer';
|
|
19627
|
-
const blur = valToPts((_shadow_blur = shadow.blur) !== null && _shadow_blur !== void 0 ? _shadow_blur : 8);
|
|
21237
|
+
var _shadow_offset, _shadow_angle, _shadow_opacity, _shadow_blur;
|
|
19628
21238
|
const offset = valToPts((_shadow_offset = shadow.offset) !== null && _shadow_offset !== void 0 ? _shadow_offset : 4);
|
|
19629
21239
|
const angle = Math.round(((_shadow_angle = shadow.angle) !== null && _shadow_angle !== void 0 ? _shadow_angle : 270) * 60000);
|
|
19630
21240
|
const opacity = Math.round(((_shadow_opacity = shadow.opacity) !== null && _shadow_opacity !== void 0 ? _shadow_opacity : 0.75) * 100000);
|
|
19631
21241
|
const color = shadow.color || DEF_TEXT_SHADOW.color;
|
|
21242
|
+
const colorXml = `<a:srgbClr val="${color}"><a:alpha val="${opacity}"/></a:srgbClr>`;
|
|
21243
|
+
if (shadow.type === 'preset') {
|
|
21244
|
+
if (!shadow.preset) return '';
|
|
21245
|
+
return `<a:prstShdw prst="${shadow.preset}" dist="${offset}" dir="${angle}">${colorXml}</a:prstShdw>`;
|
|
21246
|
+
}
|
|
21247
|
+
const type = shadow.type === 'inner' ? 'inner' : 'outer';
|
|
21248
|
+
const blur = valToPts((_shadow_blur = shadow.blur) !== null && _shadow_blur !== void 0 ? _shadow_blur : 8);
|
|
19632
21249
|
const attrs = type === 'outer' ? 'sx="100000" sy="100000" kx="0" ky="0" algn="bl" rotWithShape="0"' : '';
|
|
19633
|
-
return `<a:${type}Shdw ${attrs} blurRad="${blur}" dist="${offset}" dir="${angle}"
|
|
21250
|
+
return `<a:${type}Shdw ${attrs} blurRad="${blur}" dist="${offset}" dir="${angle}">${colorXml}</a:${type}Shdw>`;
|
|
19634
21251
|
}
|
|
19635
21252
|
/**
|
|
19636
21253
|
* Create `a:softEdge` element
|
|
@@ -19658,22 +21275,98 @@ function genXmlLine(line) {
|
|
|
19658
21275
|
return `<a:blur rad="${rad}"${grow}/>`;
|
|
19659
21276
|
}
|
|
19660
21277
|
/**
|
|
19661
|
-
* Create
|
|
19662
|
-
|
|
21278
|
+
* Create `a:fillOverlay` (CT_FillOverlayEffect). `@blend` and a fill are both required.
|
|
21279
|
+
*/ function genXmlFillOverlayElement(overlay) {
|
|
21280
|
+
if (!overlay.blend || !overlay.fill) return '';
|
|
21281
|
+
const fill = genXmlColorSelection(overlay.fill);
|
|
21282
|
+
return fill ? `<a:fillOverlay blend="${overlay.blend}">${fill}</a:fillOverlay>` : '';
|
|
21283
|
+
}
|
|
21284
|
+
/**
|
|
21285
|
+
* Create the shape/image effect block (blur + fillOverlay + glow + shadow + reflection + softEdge).
|
|
21286
|
+
* Child order follows ECMA-376 `CT_EffectList`: blur, fillOverlay, glow, innerShdw, outerShdw,
|
|
21287
|
+
* prstShdw, reflection, softEdge. `effectDag` replaces `effectLst` (EG_EffectProperties choice).
|
|
19663
21288
|
* @note pure - unit conversion must NOT be written back to the caller's options object (issue #20)
|
|
19664
21289
|
*/ function genXmlEffectLst(opts) {
|
|
19665
21290
|
const parts = [];
|
|
19666
21291
|
if (opts.blur && typeof opts.blur.radius === 'number') parts.push(genXmlBlurElement(opts.blur));
|
|
21292
|
+
if (opts.fillOverlay) {
|
|
21293
|
+
const overlay = genXmlFillOverlayElement(opts.fillOverlay);
|
|
21294
|
+
if (overlay) parts.push(overlay);
|
|
21295
|
+
}
|
|
19667
21296
|
const resolvedGlow = resolveGlowOptions(opts.glow);
|
|
19668
21297
|
if (resolvedGlow) parts.push(createGlowElement(resolvedGlow));
|
|
19669
21298
|
const shadow = opts.shadow;
|
|
19670
21299
|
if (shadow && shadow.type !== 'none') {
|
|
19671
|
-
|
|
21300
|
+
const shadowXml = genXmlShadowElement(shadow);
|
|
21301
|
+
if (shadowXml) parts.push(shadowXml);
|
|
19672
21302
|
}
|
|
19673
21303
|
if (opts.reflection) parts.push(genXmlReflectionElement(opts.reflection));
|
|
19674
21304
|
if (opts.softEdge) parts.push(genXmlSoftEdgeElement(opts.softEdge));
|
|
19675
21305
|
if (!parts.length) return '';
|
|
19676
|
-
|
|
21306
|
+
const xml = parts.join('');
|
|
21307
|
+
if (opts.effectDag) return `<a:effectDag type="${opts.effectDag.type === 'tree' ? 'tree' : 'sib'}">${xml}</a:effectDag>`;
|
|
21308
|
+
return `<a:effectLst>${xml}</a:effectLst>`;
|
|
21309
|
+
}
|
|
21310
|
+
/**
|
|
21311
|
+
* Theme style references for a shape (`p:style`).
|
|
21312
|
+
* CT_ShapeStyle requires all four children; an unset property references nothing (`idx="0"` / `none`).
|
|
21313
|
+
*/ function genXmlShapeStyle(style) {
|
|
21314
|
+
var _style_color;
|
|
21315
|
+
if (!style) return '';
|
|
21316
|
+
let color = (_style_color = style.color) !== null && _style_color !== void 0 ? _style_color : 'accent1';
|
|
21317
|
+
if (color === 'phClr') {
|
|
21318
|
+
console.warn('[pptxgenjs] `styleRef.color` cannot be `phClr` - it is the placeholder a theme reference resolves, not a color. Using `accent1`.');
|
|
21319
|
+
color = 'accent1';
|
|
21320
|
+
}
|
|
21321
|
+
let fontColor = style.fontColor;
|
|
21322
|
+
if (fontColor === 'phClr') {
|
|
21323
|
+
console.warn('[pptxgenjs] `styleRef.fontColor` cannot be `phClr` - using `lt1`.');
|
|
21324
|
+
fontColor = undefined;
|
|
21325
|
+
}
|
|
21326
|
+
const idx = (value)=>typeof value === 'number' && isFinite(value) && value > 0 ? Math.round(value) : 0;
|
|
21327
|
+
const matrixColor = createColorElement(color);
|
|
21328
|
+
const fontColorXml = fontColor ? createColorElement(fontColor) : '<a:schemeClr val="lt1"/>';
|
|
21329
|
+
return '<p:style>' + `<a:lnRef idx="${idx(style.line)}">${matrixColor}</a:lnRef>` + `<a:fillRef idx="${idx(style.fill)}">${matrixColor}</a:fillRef>` + `<a:effectRef idx="${idx(style.effect)}">${matrixColor}</a:effectRef>` + `<a:fontRef idx="${style.font === 'major' || style.font === 'minor' ? style.font : 'none'}">${fontColorXml}</a:fontRef>` + '</p:style>';
|
|
21330
|
+
}
|
|
21331
|
+
/**
|
|
21332
|
+
* Recolor and correction effects for an image's `a:blip`.
|
|
21333
|
+
*/ function genXmlBlipRecolor(recolor) {
|
|
21334
|
+
if (!recolor) return '';
|
|
21335
|
+
let xml = '';
|
|
21336
|
+
if (Array.isArray(recolor.duotone)) {
|
|
21337
|
+
if (recolor.duotone.length === 2) xml += `<a:duotone>${recolor.duotone.map((color)=>createColorElement(color)).join('')}</a:duotone>`;
|
|
21338
|
+
else console.warn(`[pptxgenjs] image \`recolor.duotone\` needs exactly two colors - ${recolor.duotone.length} given, effect omitted`);
|
|
21339
|
+
}
|
|
21340
|
+
if (recolor.grayscale === true) xml += '<a:grayscl/>';
|
|
21341
|
+
const bright = typeof recolor.brightness === 'number' && isFinite(recolor.brightness) ? Math.round(Math.min(100, Math.max(-100, recolor.brightness)) * 1000) : undefined;
|
|
21342
|
+
const contrast = typeof recolor.contrast === 'number' && isFinite(recolor.contrast) ? Math.round(Math.min(100, Math.max(-100, recolor.contrast)) * 1000) : undefined;
|
|
21343
|
+
if (bright !== undefined || contrast !== undefined) {
|
|
21344
|
+
xml += `<a:lum${bright !== undefined ? ` bright="${bright}"` : ''}${contrast !== undefined ? ` contrast="${contrast}"` : ''}/>`;
|
|
21345
|
+
}
|
|
21346
|
+
if (typeof recolor.blackWhiteThreshold === 'number' && isFinite(recolor.blackWhiteThreshold)) {
|
|
21347
|
+
xml += `<a:biLevel thresh="${Math.round(Math.min(100, Math.max(0, recolor.blackWhiteThreshold)) * 1000)}"/>`;
|
|
21348
|
+
}
|
|
21349
|
+
if (recolor.colorChange) {
|
|
21350
|
+
if (recolor.colorChange.from && recolor.colorChange.to) {
|
|
21351
|
+
const useA = recolor.colorChange.useAlpha === false ? ' useA="0"' : '';
|
|
21352
|
+
xml += `<a:clrChange${useA}><a:clrFrom>${createColorElement(recolor.colorChange.from)}</a:clrFrom><a:clrTo>${createColorElement(recolor.colorChange.to)}</a:clrTo></a:clrChange>`;
|
|
21353
|
+
} else {
|
|
21354
|
+
console.warn('[pptxgenjs] image `recolor.colorChange` needs both `from` and `to` - effect omitted');
|
|
21355
|
+
}
|
|
21356
|
+
}
|
|
21357
|
+
return xml;
|
|
21358
|
+
}
|
|
21359
|
+
/**
|
|
21360
|
+
* Alpha + recolor effects for an image's `a:blip`.
|
|
21361
|
+
*/ function genXmlBlipEffects(transparency, alpha, recolor) {
|
|
21362
|
+
let xml = transparency ? `<a:alphaModFix amt="${Math.round((100 - transparency) * 1000)}"/>` : '';
|
|
21363
|
+
xml += genXmlBlipRecolor(recolor);
|
|
21364
|
+
if (!alpha) return xml;
|
|
21365
|
+
if (typeof alpha.replace === 'number' && isFinite(alpha.replace)) xml += `<a:alphaRepl a="${Math.round(Math.min(100, Math.max(0, alpha.replace)) * 1000)}"/>`;
|
|
21366
|
+
if (alpha.invert === true) xml += '<a:alphaInv/>';
|
|
21367
|
+
if (alpha.floor === true) xml += '<a:alphaFloor/>';
|
|
21368
|
+
if (alpha.ceiling === true) xml += '<a:alphaCeiling/>';
|
|
21369
|
+
return xml;
|
|
19677
21370
|
}
|
|
19678
21371
|
function findShapeCoord(list, id) {
|
|
19679
21372
|
if (id == null) return undefined;
|
|
@@ -19718,7 +21411,19 @@ function findShapeCoord(list, id) {
|
|
|
19718
21411
|
/**
|
|
19719
21412
|
* When a connector references shapes with numeric inch positions + rect anchors,
|
|
19720
21413
|
* compute the line's x/y/w/h and flip flags (ZentoSoft auto-layout).
|
|
19721
|
-
*/ function
|
|
21414
|
+
*/ function resolveConnectorObjectNames(line, coordinates) {
|
|
21415
|
+
if (line._sourceName) {
|
|
21416
|
+
const found = coordinates.find((item)=>item.objectName === line._sourceName);
|
|
21417
|
+
if (found) line.sourceId = found.id;
|
|
21418
|
+
else console.warn(`[pptxgenjs] connector start shape "${line._sourceName}" not found - attachment omitted`);
|
|
21419
|
+
}
|
|
21420
|
+
if (line._targetName) {
|
|
21421
|
+
const found = coordinates.find((item)=>item.objectName === line._targetName);
|
|
21422
|
+
if (found) line.targetId = found.id;
|
|
21423
|
+
else console.warn(`[pptxgenjs] connector end shape "${line._targetName}" not found - attachment omitted`);
|
|
21424
|
+
}
|
|
21425
|
+
}
|
|
21426
|
+
function applyConnectorAutoLayout(line, coordinates, presLayout) {
|
|
19722
21427
|
const source = findShapeCoord(coordinates, line.sourceId);
|
|
19723
21428
|
const target = findShapeCoord(coordinates, line.targetId);
|
|
19724
21429
|
if (!source || !target) return undefined;
|
|
@@ -19875,7 +21580,9 @@ function slideObjectToXml(slide) {
|
|
|
19875
21580
|
let intTableNum = 1;
|
|
19876
21581
|
// STEP 1: Add background color/image (ensure only a single `<p:bg>` tag is created, ex: when master-baskground has both `color` and `path`)
|
|
19877
21582
|
if (slide._bkgdImgRid) {
|
|
19878
|
-
|
|
21583
|
+
var _slide_background3;
|
|
21584
|
+
const bkgdEffects = genXmlBlipRecolor((_slide_background3 = slide.background) === null || _slide_background3 === void 0 ? void 0 : _slide_background3.recolor);
|
|
21585
|
+
strSlideXml += `<p:bg><p:bgPr><a:blipFill dpi="0" rotWithShape="1"><a:blip r:embed="rId${slide._bkgdImgRid}">${bkgdEffects || '<a:lum/>'}</a:blip><a:srcRect/><a:stretch><a:fillRect/></a:stretch></a:blipFill><a:effectLst/></p:bgPr></p:bg>`;
|
|
19879
21586
|
} else if (((_slide_background = slide.background) === null || _slide_background === void 0 ? void 0 : _slide_background.color) || ((_slide_background1 = slide.background) === null || _slide_background1 === void 0 ? void 0 : _slide_background1.type) === 'gradient' && slide.background.gradient || ((_slide_background2 = slide.background) === null || _slide_background2 === void 0 ? void 0 : _slide_background2.type) === 'linearGradient' && ((_ref = (_slide_background_stops = slide.background.stops) === null || _slide_background_stops === void 0 ? void 0 : _slide_background_stops.length) !== null && _ref !== void 0 ? _ref : 0) >= 2) {
|
|
19880
21587
|
// NOTE: `<a:effectLst/>` is required by PowerPoint (matches image-bg path above); omitting it triggers the repair dialog
|
|
19881
21588
|
strSlideXml += `<p:bg><p:bgPr>${genXmlColorSelection(slide.background)}<a:effectLst/></p:bgPr></p:bg>`;
|
|
@@ -19893,7 +21600,7 @@ function slideObjectToXml(slide) {
|
|
|
19893
21600
|
const shapeCoordinates = [];
|
|
19894
21601
|
const renderObjectList = (objects)=>{
|
|
19895
21602
|
objects.forEach((slideItemObj, idx)=>{
|
|
19896
|
-
var _slideItemObj_options, _slideItemObj_options1, _slide__slideLayout, _slideItemObj_options_line, _slideItemObj_options_sizing, _slideItemObj_options2;
|
|
21603
|
+
var _slideItemObj_options, _slideItemObj_options1, _slide__slideLayout, _slideItemObj_options_line, _slideItemObj_options_line1, _slideItemObj_options_sizing, _slideItemObj_options2;
|
|
19897
21604
|
let x = 0;
|
|
19898
21605
|
let y = 0;
|
|
19899
21606
|
let cx = getSmartParseNumber('75%', 'X', slide._presLayout);
|
|
@@ -19908,6 +21615,7 @@ function slideObjectToXml(slide) {
|
|
|
19908
21615
|
slideItemObj.options.sId = shapeId;
|
|
19909
21616
|
shapeCoordinates.push({
|
|
19910
21617
|
id: shapeId,
|
|
21618
|
+
objectName: slideItemObj.options.objectName,
|
|
19911
21619
|
position: {
|
|
19912
21620
|
x: slideItemObj.options.x,
|
|
19913
21621
|
y: slideItemObj.options.y,
|
|
@@ -19927,7 +21635,10 @@ function slideObjectToXml(slide) {
|
|
|
19927
21635
|
})[0];
|
|
19928
21636
|
}
|
|
19929
21637
|
// A: Geometry — connectors may auto-size from source/target shape boxes (ZentoSoft)
|
|
19930
|
-
|
|
21638
|
+
if ((_slideItemObj_options_line = slideItemObj.options.line) === null || _slideItemObj_options_line === void 0 ? void 0 : _slideItemObj_options_line.isConnector) {
|
|
21639
|
+
resolveConnectorObjectNames(slideItemObj.options.line, shapeCoordinates);
|
|
21640
|
+
}
|
|
21641
|
+
const connectorLayout = ((_slideItemObj_options_line1 = slideItemObj.options.line) === null || _slideItemObj_options_line1 === void 0 ? void 0 : _slideItemObj_options_line1.isConnector) ? applyConnectorAutoLayout(slideItemObj.options.line, shapeCoordinates, slide._presLayout) : undefined;
|
|
19931
21642
|
if (connectorLayout) {
|
|
19932
21643
|
x = connectorLayout.x;
|
|
19933
21644
|
y = connectorLayout.y;
|
|
@@ -19987,7 +21698,7 @@ function slideObjectToXml(slide) {
|
|
|
19987
21698
|
switch(slideItemObj._type){
|
|
19988
21699
|
case (/* inlined export .SLIDE_OBJECT_TYPES.table */"table"):
|
|
19989
21700
|
{
|
|
19990
|
-
var _slideItemObj_arrTabRows, _slide__slideNum;
|
|
21701
|
+
var _slideItemObj_arrTabRows, _slide__slideNum, _slideItemObj_options_objectName;
|
|
19991
21702
|
arrTabRows = (_slideItemObj_arrTabRows = slideItemObj.arrTabRows) !== null && _slideItemObj_arrTabRows !== void 0 ? _slideItemObj_arrTabRows : [];
|
|
19992
21703
|
objTabOpts = slideItemObj.options;
|
|
19993
21704
|
intColCnt = 0;
|
|
@@ -20000,12 +21711,12 @@ function slideObjectToXml(slide) {
|
|
|
20000
21711
|
});
|
|
20001
21712
|
// STEP 1: Start Table XML
|
|
20002
21713
|
// NOTE: Non-numeric cNvPr id values will trigger "presentation needs repair" type warning in MS-PPT-2013
|
|
20003
|
-
strXml =
|
|
21714
|
+
strXml = '<p:graphicFrame><p:nvGraphicFramePr>' + genXmlCNvPr(intTableNum * ((_slide__slideNum = slide._slideNum) !== null && _slide__slideNum !== void 0 ? _slide__slideNum : 0) + 1, String((_slideItemObj_options_objectName = slideItemObj.options.objectName) !== null && _slideItemObj_options_objectName !== void 0 ? _slideItemObj_options_objectName : ''), slideItemObj.options);
|
|
20004
21715
|
// When the table binds to a master/layout placeholder, emit `<p:ph type="tbl"/>` (ECMA-376 §4.4.1.33, issue #856)
|
|
20005
21716
|
const tblPh = placeholderObj ? genXmlPlaceholder(placeholderObj, slideItemObj.options) : '';
|
|
20006
21717
|
// MS-PPTX §2.3.1.19: each p14:modId must be unique on the slide (not a constant).
|
|
20007
21718
|
const tableModId = typeof slideItemObj.options.modId === 'number' ? slideItemObj.options.modId : TABLE_MOD_ID_BASE + idx;
|
|
20008
|
-
strXml +=
|
|
21719
|
+
strXml += `<p:cNvGraphicFramePr>${genXmlLocks('a:graphicFrameLocks', slideItemObj.options.lock, ' noGrp="1"')}</p:cNvGraphicFramePr>` + ` ${genXmlNvPr(slideItemObj.options, tblPh, [
|
|
20009
21720
|
nvPrModIdExt(tableModId)
|
|
20010
21721
|
])}` + '</p:nvGraphicFramePr>';
|
|
20011
21722
|
strXml += `<p:xfrm><a:off x="${x || (x === 0 ? 0 : (/* inlined export .EMU */914400))}" y="${y || (y === 0 ? 0 : (/* inlined export .EMU */914400))}"/><a:ext cx="${cx || (cx === 0 ? 0 : (/* inlined export .EMU */914400))}" cy="${cy || (/* inlined export .EMU */914400)}"/></p:xfrm>`;
|
|
@@ -20101,8 +21812,10 @@ function slideObjectToXml(slide) {
|
|
|
20101
21812
|
// A: Table Height provided without rowH? Then distribute rows
|
|
20102
21813
|
let intRowH = 0 // IMPORTANT: Default must be zero for auto-sizing to work
|
|
20103
21814
|
;
|
|
20104
|
-
|
|
20105
|
-
|
|
21815
|
+
// `rowH` is either one value for every row or a per-row array; `inch2Emu` resolves inches, EMU and unit-suffixed strings alike
|
|
21816
|
+
const rowHOpt = Array.isArray(objTabOpts.rowH) ? objTabOpts.rowH[rIdx] : objTabOpts.rowH;
|
|
21817
|
+
const rowHEmu = rowHOpt ? inch2Emu(rowHOpt) : NaN;
|
|
21818
|
+
if (!isNaN(rowHEmu)) intRowH = rowHEmu;
|
|
20106
21819
|
else if (itemOpts.cy || itemOpts.h) {
|
|
20107
21820
|
intRowH = Math.round((itemOpts.h ? inch2Emu(itemOpts.h) : typeof itemOpts.cy === 'number' ? itemOpts.cy : 1) / arrTabRows.length);
|
|
20108
21821
|
}
|
|
@@ -20181,9 +21894,10 @@ function slideObjectToXml(slide) {
|
|
|
20181
21894
|
* - Backwards-Compat: Oops! Discovered we were still using points for cell margin before v3.8.0 (UGH!)
|
|
20182
21895
|
* - We cant introduce a breaking change before v4.0, so...
|
|
20183
21896
|
*/ const cellMarginXml = cellMargin[0] >= 1 ? ` marL="${valToPts(cellMargin[3])}" marR="${valToPts(cellMargin[1])}" marT="${valToPts(cellMargin[0])}" marB="${valToPts(cellMargin[2])}"` : ` marL="${inch2Emu(cellMargin[3])}" marR="${inch2Emu(cellMargin[1])}" marT="${inch2Emu(cellMargin[0])}" marB="${inch2Emu(cellMargin[2])}"`;
|
|
20184
|
-
|
|
21897
|
+
const cellOverflow = cellOpts.horzOverflow === 'overflow' || cellOpts.horzOverflow === 'clip' ? ` horzOverflow="${cellOpts.horzOverflow}"` : '';
|
|
21898
|
+
const cellAnchorCtr = cellOpts.anchorCtr === true ? ' anchorCtr="1"' : '';
|
|
20185
21899
|
// 4: Set CELL content and properties ==================================
|
|
20186
|
-
strXml += `<a:tc${cellSpanAttrStr}>${genXmlTextBody(cell)}<a:tcPr${cellMarginXml}${cellValign}${cellTextDir}>`;
|
|
21900
|
+
strXml += `<a:tc${cellSpanAttrStr}>${genXmlTextBody(cell)}<a:tcPr${cellMarginXml}${cellValign}${cellTextDir}${cellAnchorCtr}${cellOverflow}>`;
|
|
20187
21901
|
// strXml += `<a:tc${cellColspan}${cellRowspan}>${genXmlTextBody(cell)}<a:tcPr${cellMarginXml}${cellValign}${cellTextDir}>`
|
|
20188
21902
|
// FIXME: 20200525: ^^^
|
|
20189
21903
|
// <a:tcPr marL="38100" marR="38100" marT="38100" marB="38100" vert="vert270">
|
|
@@ -20208,18 +21922,29 @@ function slideObjectToXml(slide) {
|
|
|
20208
21922
|
name: 'lnB'
|
|
20209
21923
|
}
|
|
20210
21924
|
].forEach((obj)=>{
|
|
20211
|
-
|
|
20212
|
-
const borderTransparency = border[obj.idx].transparency;
|
|
20213
|
-
const borderAlpha = typeof borderTransparency === 'number' ? `<a:alpha val="${Math.round((100 - Math.min(100, Math.max(0, borderTransparency))) * 1000)}"/>` : '';
|
|
20214
|
-
strXml += `<a:${obj.name} w="${valToPts(border[obj.idx].pt)}" cap="flat" cmpd="sng" algn="ctr">`;
|
|
20215
|
-
strXml += `<a:solidFill>${createColorElement(border[obj.idx].color, borderAlpha)}</a:solidFill>`;
|
|
20216
|
-
strXml += `<a:prstDash val="${border[obj.idx].type === 'dash' ? 'sysDash' : 'solid'}"/><a:round/><a:headEnd type="none" w="med" len="med"/><a:tailEnd type="none" w="med" len="med"/>`;
|
|
20217
|
-
strXml += `</a:${obj.name}>`;
|
|
20218
|
-
} else {
|
|
20219
|
-
strXml += `<a:${obj.name} w="0" cap="flat" cmpd="sng" algn="ctr"><a:noFill/></a:${obj.name}>`;
|
|
20220
|
-
}
|
|
21925
|
+
strXml += genXmlCellBorder(obj.name, border[obj.idx]);
|
|
20221
21926
|
});
|
|
20222
21927
|
}
|
|
21928
|
+
// 5b: Diagonals follow the four edges in the CT_TableCellProperties sequence, and are
|
|
21929
|
+
// written only when asked for - unlike the edges, which are always emitted as a set
|
|
21930
|
+
if (cellOpts.borderDiagonalDown) strXml += genXmlCellBorder('lnTlToBr', cellOpts.borderDiagonalDown);
|
|
21931
|
+
if (cellOpts.borderDiagonalUp) strXml += genXmlCellBorder('lnBlToTr', cellOpts.borderDiagonalUp);
|
|
21932
|
+
// 5c: `a:cell3D` follows the diagonals and precedes the fill
|
|
21933
|
+
if (cellOpts.cell3D) {
|
|
21934
|
+
var _cell3D_bevel;
|
|
21935
|
+
var _cell3D_lightRig;
|
|
21936
|
+
const cell3D = cellOpts.cell3D;
|
|
21937
|
+
const bevel = (_cell3D_bevel = cell3D.bevel) !== null && _cell3D_bevel !== void 0 ? _cell3D_bevel : {};
|
|
21938
|
+
let bevelAttrs = '';
|
|
21939
|
+
if (typeof bevel.width === 'number' && isFinite(bevel.width) && bevel.width >= 0) bevelAttrs += ` w="${inch2Emu(bevel.width)}"`;
|
|
21940
|
+
if (typeof bevel.height === 'number' && isFinite(bevel.height) && bevel.height >= 0) bevelAttrs += ` h="${inch2Emu(bevel.height)}"`;
|
|
21941
|
+
if (bevel.preset) bevelAttrs += ` prst="${bevel.preset}"`;
|
|
21942
|
+
// `rig` and `dir` are both required on CT_LightRig, so a partial rig is dropped rather
|
|
21943
|
+
// than emitted as an element PowerPoint would refuse to open
|
|
21944
|
+
const lightRig = ((_cell3D_lightRig = cell3D.lightRig) === null || _cell3D_lightRig === void 0 ? void 0 : _cell3D_lightRig.rig) && cell3D.lightRig.dir ? `<a:lightRig rig="${cell3D.lightRig.rig}" dir="${cell3D.lightRig.dir}"/>` : '';
|
|
21945
|
+
// `a:bevel` is required by the schema, so it is always written
|
|
21946
|
+
strXml += `<a:cell3D${cell3D.material ? ` prstMaterial="${cell3D.material}"` : ''}><a:bevel${bevelAttrs}/>${lightRig}</a:cell3D>`;
|
|
21947
|
+
}
|
|
20223
21948
|
// 6: Close cell Properties & Cell
|
|
20224
21949
|
strXml += cellFill;
|
|
20225
21950
|
strXml += ' </a:tcPr>';
|
|
@@ -20242,38 +21967,38 @@ function slideObjectToXml(slide) {
|
|
|
20242
21967
|
case (/* inlined export .SLIDE_OBJECT_TYPES.text */"text"):
|
|
20243
21968
|
case (/* inlined export .SLIDE_OBJECT_TYPES.placeholder */"placeholder"):
|
|
20244
21969
|
{
|
|
20245
|
-
var
|
|
20246
|
-
const isConnector = !!((
|
|
21970
|
+
var _slideItemObj_options_line2, _slideItemObj_options_styleRef;
|
|
21971
|
+
const isConnector = !!((_slideItemObj_options_line2 = slideItemObj.options.line) === null || _slideItemObj_options_line2 === void 0 ? void 0 : _slideItemObj_options_line2.isConnector);
|
|
20247
21972
|
// Lines can have zero cy, but text should not
|
|
20248
21973
|
if (!slideItemObj.options.line && cy === 0) cy = (/* inlined export .EMU */914400) * 0.3;
|
|
20249
21974
|
// Text margins are applied in addTextDefinition → `_bodyProp` (TRBL)
|
|
20250
21975
|
// A: Start SHAPE / CONNECTOR ============================================
|
|
20251
21976
|
if (isConnector) {
|
|
20252
|
-
var _ref, _ref1;
|
|
20253
|
-
var
|
|
21977
|
+
var _slideItemObj_options_objectName1, _ref, _ref1;
|
|
21978
|
+
var _slideItemObj_options_line3, _slideItemObj_options_line4, _slideItemObj_options_line5, _slideItemObj_options_line6;
|
|
20254
21979
|
strSlideXml += '<p:cxnSp>';
|
|
20255
|
-
strSlideXml += `<p:nvCxnSpPr
|
|
20256
|
-
|
|
21980
|
+
strSlideXml += `<p:nvCxnSpPr>${genXmlCNvPr(shapeId, String((_slideItemObj_options_objectName1 = slideItemObj.options.objectName) !== null && _slideItemObj_options_objectName1 !== void 0 ? _slideItemObj_options_objectName1 : ''), slideItemObj.options)}`;
|
|
21981
|
+
const cxnLocks = genXmlLocks('a:cxnSpLocks', slideItemObj.options.lock);
|
|
21982
|
+
const stId = (_slideItemObj_options_line3 = slideItemObj.options.line) === null || _slideItemObj_options_line3 === void 0 ? void 0 : _slideItemObj_options_line3.sourceId;
|
|
21983
|
+
const endId = (_slideItemObj_options_line4 = slideItemObj.options.line) === null || _slideItemObj_options_line4 === void 0 ? void 0 : _slideItemObj_options_line4.targetId;
|
|
21984
|
+
strSlideXml += `<p:cNvCxnSpPr>${cxnLocks}`;
|
|
21985
|
+
if (stId != null) strSlideXml += `<a:stCxn id="${stId}" idx="${(_ref = (_slideItemObj_options_line5 = slideItemObj.options.line) === null || _slideItemObj_options_line5 === void 0 ? void 0 : _slideItemObj_options_line5.sourceAnchorPos) !== null && _ref !== void 0 ? _ref : 0}"/>`;
|
|
21986
|
+
if (endId != null) strSlideXml += `<a:endCxn id="${endId}" idx="${(_ref1 = (_slideItemObj_options_line6 = slideItemObj.options.line) === null || _slideItemObj_options_line6 === void 0 ? void 0 : _slideItemObj_options_line6.targetAnchorPos) !== null && _ref1 !== void 0 ? _ref1 : 0}"/>`;
|
|
21987
|
+
strSlideXml += '</p:cNvCxnSpPr>';
|
|
20257
21988
|
strSlideXml += `${genXmlNvPr(slideItemObj.options, '', [
|
|
20258
21989
|
nvPrModIdExt(slideItemObj.options.modId)
|
|
20259
21990
|
])}</p:nvCxnSpPr><p:spPr>`;
|
|
20260
21991
|
} else {
|
|
20261
|
-
var
|
|
21992
|
+
var _slideItemObj_options_objectName2;
|
|
21993
|
+
var _slideItemObj_options3;
|
|
20262
21994
|
strSlideXml += '<p:sp>';
|
|
20263
21995
|
// B: The addition of the "txBox" attribute is the sole determiner of if an object is a shape or textbox
|
|
20264
|
-
strSlideXml +=
|
|
20265
|
-
// <Hyperlink>
|
|
20266
|
-
if ((_slideItemObj_options_hyperlink = slideItemObj.options.hyperlink) === null || _slideItemObj_options_hyperlink === void 0 ? void 0 : _slideItemObj_options_hyperlink.url) {
|
|
20267
|
-
strSlideXml += `<a:hlinkClick r:id="rId${slideItemObj.options.hyperlink._rId}" tooltip="${slideItemObj.options.hyperlink.tooltip ? encodeXmlEntities(slideItemObj.options.hyperlink.tooltip) : ''}"/>`;
|
|
20268
|
-
}
|
|
20269
|
-
if ((_slideItemObj_options_hyperlink1 = slideItemObj.options.hyperlink) === null || _slideItemObj_options_hyperlink1 === void 0 ? void 0 : _slideItemObj_options_hyperlink1.slide) {
|
|
20270
|
-
strSlideXml += `<a:hlinkClick r:id="rId${slideItemObj.options.hyperlink._rId}" tooltip="${slideItemObj.options.hyperlink.tooltip ? encodeXmlEntities(slideItemObj.options.hyperlink.tooltip) : ''}" action="ppaction://hlinksldjump"/>`;
|
|
20271
|
-
}
|
|
20272
|
-
// </Hyperlink>
|
|
20273
|
-
strSlideXml += '</p:cNvPr>';
|
|
21996
|
+
strSlideXml += '<p:nvSpPr>' + genXmlCNvPr(shapeId, String((_slideItemObj_options_objectName2 = slideItemObj.options.objectName) !== null && _slideItemObj_options_objectName2 !== void 0 ? _slideItemObj_options_objectName2 : ''), slideItemObj.options, '', genXmlCNvPrLinks(slideItemObj.options.hyperlink, slideItemObj.options.hyperlinkHover));
|
|
20274
21997
|
// PowerPoint math zones are authored in text boxes; force txBox when OMML is present
|
|
20275
21998
|
const useTxBox = Boolean((_slideItemObj_options3 = slideItemObj.options) === null || _slideItemObj_options3 === void 0 ? void 0 : _slideItemObj_options3.isTextBox) || textRunsHaveOmml(slideItemObj.text);
|
|
20276
|
-
strSlideXml +=
|
|
21999
|
+
strSlideXml += genXmlCNvSpPr(slide_object_spread_props(xml_slide_object_spread({}, slideItemObj.options), {
|
|
22000
|
+
isTextBox: useTxBox
|
|
22001
|
+
}));
|
|
20277
22002
|
strSlideXml += genXmlNvPr(slideItemObj.options, slideItemObj._type === 'placeholder' ? genXmlPlaceholder(slideItemObj, slideItemObj.options) : genXmlPlaceholder(placeholderObj, slideItemObj.options), [
|
|
20278
22003
|
nvPrModIdExt(slideItemObj.options.modId)
|
|
20279
22004
|
]);
|
|
@@ -20285,7 +22010,7 @@ function slideObjectToXml(slide) {
|
|
|
20285
22010
|
if (!isConnector && slideItemObj.shape === 'custGeom') {
|
|
20286
22011
|
strSlideXml += genCustGeomXml(slideItemObj, cx, cy, slide);
|
|
20287
22012
|
} else {
|
|
20288
|
-
var _slideItemObj_options_line_curveadjust,
|
|
22013
|
+
var _slideItemObj_options_line_curveadjust, _slideItemObj_options_line7;
|
|
20289
22014
|
strSlideXml += '<a:prstGeom prst="' + slideItemObj.shape + '"><a:avLst>';
|
|
20290
22015
|
// `rectRadius: 0` is a valid sharp-corner adj (ECMA-376 §5.1.11 preset geom `gd name="adj"`).
|
|
20291
22016
|
if (typeof slideItemObj.options.rectRadius === 'number' && Number.isFinite(slideItemObj.options.rectRadius) && slideItemObj.options.rectRadius >= 0) {
|
|
@@ -20299,7 +22024,7 @@ function slideObjectToXml(slide) {
|
|
|
20299
22024
|
strSlideXml += `<a:gd name="adj3" fmla="val ${Math.round(slideItemObj.options.arcThicknessRatio * 50000)}" />`;
|
|
20300
22025
|
}
|
|
20301
22026
|
}
|
|
20302
|
-
if (isConnector && ((
|
|
22027
|
+
if (isConnector && ((_slideItemObj_options_line7 = slideItemObj.options.line) === null || _slideItemObj_options_line7 === void 0 ? void 0 : (_slideItemObj_options_line_curveadjust = _slideItemObj_options_line7.curveadjust) === null || _slideItemObj_options_line_curveadjust === void 0 ? void 0 : _slideItemObj_options_line_curveadjust.length)) {
|
|
20303
22028
|
slideItemObj.options.line.curveadjust.forEach((adj, i)=>{
|
|
20304
22029
|
strSlideXml += `<a:gd name="adj${i + 1}" fmla="val ${Math.round(Number(adj))}"/>`;
|
|
20305
22030
|
});
|
|
@@ -20307,20 +22032,26 @@ function slideObjectToXml(slide) {
|
|
|
20307
22032
|
strSlideXml += '</a:avLst></a:prstGeom>';
|
|
20308
22033
|
}
|
|
20309
22034
|
// Option: FILL
|
|
20310
|
-
|
|
22035
|
+
// With a fillRef and no explicit fill, omit the fill element so the theme inherits
|
|
22036
|
+
if (slideItemObj.options.fill) strSlideXml += genXmlColorSelection(slideItemObj.options.fill);
|
|
22037
|
+
else if (!((_slideItemObj_options_styleRef = slideItemObj.options.styleRef) === null || _slideItemObj_options_styleRef === void 0 ? void 0 : _slideItemObj_options_styleRef.fill)) strSlideXml += '<a:noFill/>';
|
|
20311
22038
|
// shape Type: LINE: line color
|
|
20312
22039
|
if (slideItemObj.options.line) strSlideXml += genXmlLine(slideItemObj.options.line);
|
|
20313
|
-
// EFFECTS: shadow / glow / softEdge / reflection
|
|
22040
|
+
// EFFECTS: shadow / glow / softEdge / reflection / fillOverlay / blur
|
|
20314
22041
|
// REF: @see http://officeopenxml.com/drwSp-effects.php
|
|
20315
22042
|
strSlideXml += genXmlEffectLst({
|
|
20316
22043
|
shadow: slideItemObj.options.shadow,
|
|
20317
22044
|
glow: slideItemObj.options.glow,
|
|
20318
22045
|
softEdge: slideItemObj.options.softEdge,
|
|
20319
22046
|
reflection: slideItemObj.options.reflection,
|
|
20320
|
-
blur: slideItemObj.options.blur
|
|
22047
|
+
blur: slideItemObj.options.blur,
|
|
22048
|
+
fillOverlay: slideItemObj.options.fillOverlay,
|
|
22049
|
+
effectDag: slideItemObj.options.effectDag
|
|
20321
22050
|
});
|
|
20322
22051
|
// B: Close shape Properties
|
|
20323
22052
|
strSlideXml += '</p:spPr>';
|
|
22053
|
+
// `p:style` follows `p:spPr` in CT_Shape / CT_Connector
|
|
22054
|
+
strSlideXml += genXmlShapeStyle(slideItemObj.options.styleRef);
|
|
20324
22055
|
if (isConnector) {
|
|
20325
22056
|
// Connectors have no text body
|
|
20326
22057
|
strSlideXml += '</p:cxnSp>';
|
|
@@ -20333,18 +22064,13 @@ function slideObjectToXml(slide) {
|
|
|
20333
22064
|
break;
|
|
20334
22065
|
}
|
|
20335
22066
|
case (/* inlined export .SLIDE_OBJECT_TYPES.image */"image"):
|
|
20336
|
-
var
|
|
22067
|
+
var _slideItemObj_options_objectName3;
|
|
22068
|
+
var _slideItemObj_options_lock;
|
|
20337
22069
|
strSlideXml += '<p:pic>';
|
|
20338
22070
|
strSlideXml += ' <p:nvPicPr>';
|
|
20339
|
-
strSlideXml +=
|
|
20340
|
-
|
|
20341
|
-
|
|
20342
|
-
}
|
|
20343
|
-
if ((_slideItemObj_hyperlink1 = slideItemObj.hyperlink) === null || _slideItemObj_hyperlink1 === void 0 ? void 0 : _slideItemObj_hyperlink1.slide) {
|
|
20344
|
-
strSlideXml += `<a:hlinkClick r:id="rId${slideItemObj.hyperlink._rId}" tooltip="${slideItemObj.hyperlink.tooltip ? encodeXmlEntities(slideItemObj.hyperlink.tooltip) : ''}" action="ppaction://hlinksldjump"/>`;
|
|
20345
|
-
}
|
|
20346
|
-
strSlideXml += ' </p:cNvPr>';
|
|
20347
|
-
strSlideXml += ' <p:cNvPicPr><a:picLocks noChangeAspect="1"/></p:cNvPicPr>';
|
|
22071
|
+
strSlideXml += genXmlCNvPr(shapeId, String((_slideItemObj_options_objectName3 = slideItemObj.options.objectName) !== null && _slideItemObj_options_objectName3 !== void 0 ? _slideItemObj_options_objectName3 : ''), slideItemObj.options, slideItemObj.options.altText || slideItemObj.image, genXmlCNvPrLinks(slideItemObj.hyperlink, slideItemObj.hyperlinkHover));
|
|
22072
|
+
// `noChangeAspect` has always been emitted here; caller locks are added to it
|
|
22073
|
+
strSlideXml += ` <p:cNvPicPr${((_slideItemObj_options_lock = slideItemObj.options.lock) === null || _slideItemObj_options_lock === void 0 ? void 0 : _slideItemObj_options_lock.preferRelativeResize) === true ? ' preferRelativeResize="1"' : ''}>${genXmlLocks('a:picLocks', slideItemObj.options.lock, ' noChangeAspect="1"')}</p:cNvPicPr>`;
|
|
20348
22074
|
strSlideXml += genXmlNvPr(slideItemObj.options, genXmlPlaceholder(placeholderObj, slideItemObj.options), [
|
|
20349
22075
|
nvPrModIdExt(slideItemObj.options.modId)
|
|
20350
22076
|
]);
|
|
@@ -20354,7 +22080,7 @@ function slideObjectToXml(slide) {
|
|
|
20354
22080
|
if ((slide._relsMedia || []).filter((rel)=>rel.rId === slideItemObj.imageRid)[0] && (slide._relsMedia || []).filter((rel)=>rel.rId === slideItemObj.imageRid)[0].extn === 'svg') {
|
|
20355
22081
|
var _slideItemObj_imageRid;
|
|
20356
22082
|
strSlideXml += `<a:blip r:embed="rId${((_slideItemObj_imageRid = slideItemObj.imageRid) !== null && _slideItemObj_imageRid !== void 0 ? _slideItemObj_imageRid : 0) - 1}">`;
|
|
20357
|
-
strSlideXml += slideItemObj.options.transparency
|
|
22083
|
+
strSlideXml += genXmlBlipEffects(slideItemObj.options.transparency, slideItemObj.options.alphaEffects, slideItemObj.options.recolor);
|
|
20358
22084
|
strSlideXml += ' <a:extLst>';
|
|
20359
22085
|
strSlideXml += ' <a:ext uri="{96DAC541-7B7A-43D3-8B79-37D633B846F1}">';
|
|
20360
22086
|
strSlideXml += ` <asvg:svgBlip xmlns:asvg="http://schemas.microsoft.com/office/drawing/2016/SVG/main" r:embed="rId${slideItemObj.imageRid}"/>`;
|
|
@@ -20363,7 +22089,7 @@ function slideObjectToXml(slide) {
|
|
|
20363
22089
|
strSlideXml += '</a:blip>';
|
|
20364
22090
|
} else {
|
|
20365
22091
|
strSlideXml += `<a:blip r:embed="rId${slideItemObj.imageRid}">`;
|
|
20366
|
-
strSlideXml += slideItemObj.options.transparency
|
|
22092
|
+
strSlideXml += genXmlBlipEffects(slideItemObj.options.transparency, slideItemObj.options.alphaEffects, slideItemObj.options.recolor);
|
|
20367
22093
|
strSlideXml += '</a:blip>';
|
|
20368
22094
|
}
|
|
20369
22095
|
if (sizing === null || sizing === void 0 ? void 0 : sizing.type) {
|
|
@@ -20423,26 +22149,53 @@ function slideObjectToXml(slide) {
|
|
|
20423
22149
|
}
|
|
20424
22150
|
// OUTLINE: picture border/frame (issue #35)
|
|
20425
22151
|
if (slideItemObj.options.line) strSlideXml += genXmlLine(slideItemObj.options.line);
|
|
20426
|
-
// EFFECTS: shadow / glow / softEdge / reflection
|
|
22152
|
+
// EFFECTS: shadow / glow / softEdge / reflection / fillOverlay / blur
|
|
20427
22153
|
strSlideXml += genXmlEffectLst({
|
|
20428
22154
|
shadow: slideItemObj.options.shadow,
|
|
20429
22155
|
glow: slideItemObj.options.glow,
|
|
20430
22156
|
softEdge: slideItemObj.options.softEdge,
|
|
20431
22157
|
reflection: slideItemObj.options.reflection,
|
|
20432
|
-
blur: slideItemObj.options.blur
|
|
22158
|
+
blur: slideItemObj.options.blur,
|
|
22159
|
+
fillOverlay: slideItemObj.options.fillOverlay,
|
|
22160
|
+
effectDag: slideItemObj.options.effectDag
|
|
20433
22161
|
});
|
|
20434
22162
|
strSlideXml += '</p:spPr>';
|
|
22163
|
+
strSlideXml += genXmlShapeStyle(slideItemObj.options.styleRef);
|
|
20435
22164
|
strSlideXml += '</p:pic>';
|
|
20436
22165
|
break;
|
|
20437
22166
|
case (/* inlined export .SLIDE_OBJECT_TYPES.media */"media"):
|
|
20438
|
-
if (slideItemObj.mtype === '
|
|
22167
|
+
if (slideItemObj.mtype === 'audioCd' || slideItemObj.mtype === 'wav') {
|
|
22168
|
+
var _slideItemObj__coverRid;
|
|
22169
|
+
// EG_Media is a choice, so these carry exactly one media element and no `p14:media`:
|
|
22170
|
+
// `a:audioCd` references the listener's drive and `a:wavAudioFile` is the legacy
|
|
22171
|
+
// embedded-WAV element, so neither has an embedded media part to point at
|
|
22172
|
+
const coverRid = (_slideItemObj__coverRid = slideItemObj._coverRid) !== null && _slideItemObj__coverRid !== void 0 ? _slideItemObj__coverRid : 2;
|
|
22173
|
+
strSlideXml += '<p:pic>';
|
|
22174
|
+
strSlideXml += ' <p:nvPicPr>';
|
|
22175
|
+
strSlideXml += `<p:cNvPr id="${coverRid}" name="${slideItemObj.options.objectName}"><a:hlinkClick r:id="" action="ppaction://media"/></p:cNvPr>`;
|
|
22176
|
+
strSlideXml += ' <p:cNvPicPr><a:picLocks noChangeAspect="1"/></p:cNvPicPr>';
|
|
22177
|
+
if (slideItemObj.mtype === 'audioCd') {
|
|
22178
|
+
const cd = slideItemObj.options.audioCd;
|
|
22179
|
+
strSlideXml += genXmlNvPr(slideItemObj.options, `<a:audioCd>${genXmlAudioCdTime('a:st', cd === null || cd === void 0 ? void 0 : cd.start)}${genXmlAudioCdTime('a:end', cd === null || cd === void 0 ? void 0 : cd.end)}</a:audioCd>`);
|
|
22180
|
+
} else {
|
|
22181
|
+
strSlideXml += genXmlNvPr(slideItemObj.options, `<a:wavAudioFile r:embed="rId${slideItemObj.mediaRid}"${slideItemObj.options.objectName ? ` name="${slideItemObj.options.objectName}"` : ''}/>`);
|
|
22182
|
+
}
|
|
22183
|
+
strSlideXml += ' </p:nvPicPr>';
|
|
22184
|
+
strSlideXml += ` <p:blipFill><a:blip r:embed="rId${coverRid}"/><a:stretch><a:fillRect/></a:stretch></p:blipFill>`;
|
|
22185
|
+
strSlideXml += ' <p:spPr>';
|
|
22186
|
+
strSlideXml += ` <a:xfrm${locationAttr}><a:off x="${x}" y="${y}"/><a:ext cx="${cx}" cy="${cy}"/></a:xfrm>`;
|
|
22187
|
+
strSlideXml += ' <a:prstGeom prst="rect"><a:avLst/></a:prstGeom>';
|
|
22188
|
+
strSlideXml += ' </p:spPr>';
|
|
22189
|
+
strSlideXml += '</p:pic>';
|
|
22190
|
+
} else if (slideItemObj.mtype === 'online') {
|
|
20439
22191
|
var _slideItemObj_mediaRid, _slideItemObj_mediaRid1;
|
|
22192
|
+
const contentType = slideItemObj.options.contentType ? ` contentType="${encodeXmlEntities(slideItemObj.options.contentType)}"` : '';
|
|
20440
22193
|
strSlideXml += '<p:pic>';
|
|
20441
22194
|
strSlideXml += ' <p:nvPicPr>';
|
|
20442
22195
|
// IMPORTANT: <p:cNvPr id="" value is critical - if its not the same number as preview image `rId`, PowerPoint throws error!
|
|
20443
22196
|
strSlideXml += `<p:cNvPr id="${((_slideItemObj_mediaRid = slideItemObj.mediaRid) !== null && _slideItemObj_mediaRid !== void 0 ? _slideItemObj_mediaRid : 0) + 2}" name="${slideItemObj.options.objectName}"/>`;
|
|
20444
22197
|
strSlideXml += ' <p:cNvPicPr/>';
|
|
20445
|
-
strSlideXml += genXmlNvPr(slideItemObj.options, `<a:videoFile r:link="rId${slideItemObj.mediaRid}"/>`);
|
|
22198
|
+
strSlideXml += genXmlNvPr(slideItemObj.options, `<a:videoFile r:link="rId${slideItemObj.mediaRid}"${contentType}/>`);
|
|
20446
22199
|
strSlideXml += ' </p:nvPicPr>';
|
|
20447
22200
|
// NOTE: `blip` is diferent than videos; also there's no preview "p:extLst" above but exists in videos
|
|
20448
22201
|
strSlideXml += ` <p:blipFill><a:blip r:embed="rId${((_slideItemObj_mediaRid1 = slideItemObj.mediaRid) !== null && _slideItemObj_mediaRid1 !== void 0 ? _slideItemObj_mediaRid1 : 0) + 1}"/><a:stretch><a:fillRect/></a:stretch></p:blipFill>`; // NOTE: Preview image is required!
|
|
@@ -20455,6 +22208,7 @@ function slideObjectToXml(slide) {
|
|
|
20455
22208
|
var _slideItemObj_mediaRid2, _slideItemObj_mediaRid3, _slideItemObj_mediaRid4, _slideItemObj_mediaRid5;
|
|
20456
22209
|
// ECMA-376: audio uses `<a:audioFile>`, video uses `<a:videoFile>` under nvPr.
|
|
20457
22210
|
const mediaFileTag = slideItemObj.mtype === 'audio' ? 'a:audioFile' : 'a:videoFile';
|
|
22211
|
+
const contentType = slideItemObj.options.contentType ? ` contentType="${encodeXmlEntities(slideItemObj.options.contentType)}"` : '';
|
|
20458
22212
|
strSlideXml += '<p:pic>';
|
|
20459
22213
|
strSlideXml += ' <p:nvPicPr>';
|
|
20460
22214
|
// IMPORTANT: <p:cNvPr id="" value is critical - if not the same number as preiew image rId, PowerPoint throws error!
|
|
@@ -20463,7 +22217,7 @@ function slideObjectToXml(slide) {
|
|
|
20463
22217
|
const mediaExtras = genXmlMediaExtras(slideItemObj.options);
|
|
20464
22218
|
const mediaExt = '<p:ext uri="{DAA4B4D4-6D71-4841-9C94-3DE7FCFB9230}">' + (mediaExtras ? ` <p14:media xmlns:p14="http://schemas.microsoft.com/office/powerpoint/2010/main" r:embed="rId${((_slideItemObj_mediaRid3 = slideItemObj.mediaRid) !== null && _slideItemObj_mediaRid3 !== void 0 ? _slideItemObj_mediaRid3 : 0) + 1}">${mediaExtras} </p14:media>` : ` <p14:media xmlns:p14="http://schemas.microsoft.com/office/powerpoint/2010/main" r:embed="rId${((_slideItemObj_mediaRid4 = slideItemObj.mediaRid) !== null && _slideItemObj_mediaRid4 !== void 0 ? _slideItemObj_mediaRid4 : 0) + 1}"/>`) + '</p:ext>';
|
|
20465
22219
|
const narrationExt = slideItemObj.options.isNarration ? '<p:ext uri="{42D2F446-02D8-4167-A562-619A0277C38B}"><p15:isNarration xmlns:p15="http://schemas.microsoft.com/office/powerpoint/2012/main" val="1"/></p:ext>' : '';
|
|
20466
|
-
strSlideXml += genXmlNvPr(slideItemObj.options, `<${mediaFileTag} r:link="rId${slideItemObj.mediaRid}"/>`, narrationExt ? [
|
|
22220
|
+
strSlideXml += genXmlNvPr(slideItemObj.options, `<${mediaFileTag} r:link="rId${slideItemObj.mediaRid}"${contentType}/>`, narrationExt ? [
|
|
20467
22221
|
mediaExt,
|
|
20468
22222
|
narrationExt
|
|
20469
22223
|
] : [
|
|
@@ -20570,41 +22324,64 @@ function slideObjectToXml(slide) {
|
|
|
20570
22324
|
break;
|
|
20571
22325
|
}
|
|
20572
22326
|
case (/* inlined export .SLIDE_OBJECT_TYPES.chart */"chart"):
|
|
20573
|
-
|
|
20574
|
-
|
|
20575
|
-
|
|
20576
|
-
|
|
20577
|
-
|
|
20578
|
-
|
|
20579
|
-
|
|
20580
|
-
|
|
20581
|
-
|
|
20582
|
-
|
|
20583
|
-
|
|
20584
|
-
|
|
20585
|
-
|
|
20586
|
-
|
|
20587
|
-
|
|
20588
|
-
|
|
22327
|
+
{
|
|
22328
|
+
var _slideItemObj_options_objectName4;
|
|
22329
|
+
var _slideItemObj_options4;
|
|
22330
|
+
const chartType = (_slideItemObj_options4 = slideItemObj.options) === null || _slideItemObj_options4 === void 0 ? void 0 : _slideItemObj_options4._type;
|
|
22331
|
+
const isChartex = isChartexType(chartType);
|
|
22332
|
+
const graphicDataUri = isChartex ? OOXML_CHARTEX.ns : 'http://schemas.openxmlformats.org/drawingml/2006/chart';
|
|
22333
|
+
const chartRef = isChartex ? `<cx:chart xmlns:cx="${OOXML_CHARTEX.ns}" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" r:id="rId${slideItemObj.chartRid}"/>` : `<c:chart r:id="rId${slideItemObj.chartRid}" xmlns:c="http://schemas.openxmlformats.org/drawingml/2006/chart"/>`;
|
|
22334
|
+
const chartLocks = genXmlLocks('a:graphicFrameLocks', slideItemObj.options.lock);
|
|
22335
|
+
let frameXml = '<p:graphicFrame>';
|
|
22336
|
+
frameXml += ' <p:nvGraphicFramePr>';
|
|
22337
|
+
frameXml += genXmlCNvPr(shapeId, String((_slideItemObj_options_objectName4 = slideItemObj.options.objectName) !== null && _slideItemObj_options_objectName4 !== void 0 ? _slideItemObj_options_objectName4 : ''), slideItemObj.options, slideItemObj.options.altText || '');
|
|
22338
|
+
frameXml += chartLocks ? ` <p:cNvGraphicFramePr>${chartLocks}</p:cNvGraphicFramePr>` : ' <p:cNvGraphicFramePr/>';
|
|
22339
|
+
frameXml += genXmlNvPr(slideItemObj.options, genXmlPlaceholder(placeholderObj, slideItemObj.options), [
|
|
22340
|
+
nvPrModIdExt(slideItemObj.options.modId)
|
|
22341
|
+
]);
|
|
22342
|
+
frameXml += ' </p:nvGraphicFramePr>';
|
|
22343
|
+
frameXml += ` <p:xfrm><a:off x="${x}" y="${y}"/><a:ext cx="${cx}" cy="${cy}"/></p:xfrm>`;
|
|
22344
|
+
frameXml += ' <a:graphic xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main">';
|
|
22345
|
+
frameXml += ` <a:graphicData uri="${graphicDataUri}">`;
|
|
22346
|
+
frameXml += ` ${chartRef}`;
|
|
22347
|
+
frameXml += ' </a:graphicData>';
|
|
22348
|
+
frameXml += ' </a:graphic>';
|
|
22349
|
+
frameXml += '</p:graphicFrame>';
|
|
22350
|
+
// A chartex frame replaces a standard graphic frame, so MS-PPTX 2.2 requires it be offered
|
|
22351
|
+
// through `mc:AlternateContent`. PowerPoint's own fallback is a rendered preview image, which
|
|
22352
|
+
// cannot be produced here - a locked text shape carrying the same message is the honest
|
|
22353
|
+
// equivalent for a consumer that does not understand the chartex namespace.
|
|
22354
|
+
strSlideXml += isChartex ? `<mc:AlternateContent xmlns:mc="${MC_NS}">` + `<mc:Choice xmlns:cx1="${chartExRequiresNs(chartType)}" Requires="cx1">` + frameXml + '</mc:Choice>' + `<mc:Fallback>${genXmlChartExFallback(shapeId, slideItemObj, {
|
|
22355
|
+
x,
|
|
22356
|
+
y,
|
|
22357
|
+
cx,
|
|
22358
|
+
cy
|
|
22359
|
+
})}</mc:Fallback>` + '</mc:AlternateContent>' : frameXml;
|
|
22360
|
+
break;
|
|
22361
|
+
}
|
|
20589
22362
|
case (/* inlined export .SLIDE_OBJECT_TYPES.group */"group"):
|
|
20590
22363
|
{
|
|
20591
22364
|
var _slideItemObj__objects;
|
|
20592
22365
|
// PresentationML `p:grpSp` (ECMA-376 §19.3.1.22): nvGrpSpPr + grpSpPr + children.
|
|
20593
22366
|
// Child coords are group-relative; chOff is 0,0 and chExt matches the group size.
|
|
20594
22367
|
strSlideXml += '<p:grpSp>';
|
|
20595
|
-
strSlideXml += `<p:nvGrpSpPr
|
|
20596
|
-
|
|
22368
|
+
strSlideXml += `<p:nvGrpSpPr>${genXmlCNvPr(shapeId, slideItemObj.options.objectName || `Group ${shapeId}`, slideItemObj.options)}`;
|
|
22369
|
+
const grpLocks = genXmlLocks('a:grpSpLocks', slideItemObj.options.lock);
|
|
22370
|
+
strSlideXml += (grpLocks ? `<p:cNvGrpSpPr>${grpLocks}</p:cNvGrpSpPr>` : '<p:cNvGrpSpPr/>') + `${genXmlNvPr(slideItemObj.options)}</p:nvGrpSpPr>`;
|
|
20597
22371
|
strSlideXml += '<p:grpSpPr>';
|
|
20598
22372
|
strSlideXml += `<a:xfrm${locationAttr}>`;
|
|
20599
22373
|
strSlideXml += `<a:off x="${x}" y="${y}"/><a:ext cx="${cx}" cy="${cy}"/>`;
|
|
20600
22374
|
strSlideXml += `<a:chOff x="0" y="0"/><a:chExt cx="${cx}" cy="${cy}"/>`;
|
|
20601
22375
|
strSlideXml += '</a:xfrm>';
|
|
22376
|
+
if (slideItemObj.options.fill) strSlideXml += genXmlColorSelection(slideItemObj.options.fill);
|
|
20602
22377
|
strSlideXml += genXmlEffectLst({
|
|
20603
22378
|
shadow: slideItemObj.options.shadow,
|
|
20604
22379
|
glow: slideItemObj.options.glow,
|
|
20605
22380
|
softEdge: slideItemObj.options.softEdge,
|
|
20606
22381
|
reflection: slideItemObj.options.reflection,
|
|
20607
|
-
blur: slideItemObj.options.blur
|
|
22382
|
+
blur: slideItemObj.options.blur,
|
|
22383
|
+
fillOverlay: slideItemObj.options.fillOverlay,
|
|
22384
|
+
effectDag: slideItemObj.options.effectDag
|
|
20608
22385
|
});
|
|
20609
22386
|
strSlideXml += '</p:grpSpPr>';
|
|
20610
22387
|
renderObjectList((_slideItemObj__objects = slideItemObj._objects) !== null && _slideItemObj__objects !== void 0 ? _slideItemObj__objects : []);
|
|
@@ -20713,6 +22490,21 @@ function package_object_spread(target) {
|
|
|
20713
22490
|
|
|
20714
22491
|
|
|
20715
22492
|
|
|
22493
|
+
|
|
22494
|
+
|
|
22495
|
+
/**
|
|
22496
|
+
* Content-type overrides a chart needs: the chart itself plus, when requested, its style and colour-style parts.
|
|
22497
|
+
* - one helper because charts appear on slides, layouts and the master, and a part with no declared
|
|
22498
|
+
* content type is a repair-dialog cause
|
|
22499
|
+
*/ function chartContentTypes(rel) {
|
|
22500
|
+
const partContentType = isChartexType(rel.opts._type) ? OOXML_CHARTEX.partContentType : 'application/vnd.openxmlformats-officedocument.drawingml.chart+xml';
|
|
22501
|
+
let xml = `<Override PartName="${rel.Target}" ContentType="${partContentType}"/>`;
|
|
22502
|
+
if (wantsChartStyleParts(rel.opts)) {
|
|
22503
|
+
xml += `<Override PartName="/${chartColorsPartName(rel.globalId)}" ContentType="${CHART_STYLE.colorsContentType}"/>`;
|
|
22504
|
+
xml += `<Override PartName="/${chartStylePartName(rel.globalId)}" ContentType="${CHART_STYLE.styleContentType}"/>`;
|
|
22505
|
+
}
|
|
22506
|
+
return xml;
|
|
22507
|
+
}
|
|
20716
22508
|
/** MS-PPTX §2.2.6 showPr browseMode */ const URI_BROWSE_MODE = '{F99C55AA-B7CB-42B0-86F8-08522FDF87E8}';
|
|
20717
22509
|
/** MS-PPTX §2.2.6 showPr laserClr */ const URI_LASER_CLR = '{EC167BDD-8182-4AB7-AECC-EB403E3ABB37}';
|
|
20718
22510
|
/** MS-PPTX §2.2.6 sld laserTraceLst */ const URI_LASER_TRACE_LST = '{3A86A75C-4F4B-4683-9AE1-C65F6400EC91}';
|
|
@@ -20778,7 +22570,7 @@ function slideShowExtLst(slide) {
|
|
|
20778
22570
|
strXml += '<Default Extension="mp4" ContentType="video/mp4"/>'; // NOTE: Hard-Code this extension as it wont be created in loop below (as extn !== type)
|
|
20779
22571
|
slides.forEach((slide)=>{
|
|
20780
22572
|
(slide._relsMedia || []).forEach((rel)=>{
|
|
20781
|
-
if (rel.type !== 'image' && rel.type !== 'online' && rel.type !== 'chart' && rel.extn !== 'm4v' && !strXml.includes(rel.type)) {
|
|
22573
|
+
if (!rel.isLinked && rel.type !== 'image' && rel.type !== 'online' && rel.type !== 'chart' && rel.extn !== 'm4v' && !strXml.includes(rel.type)) {
|
|
20782
22574
|
strXml += '<Default Extension="' + rel.extn + '" ContentType="' + rel.type + '"/>';
|
|
20783
22575
|
}
|
|
20784
22576
|
});
|
|
@@ -20799,7 +22591,7 @@ function slideShowExtLst(slide) {
|
|
|
20799
22591
|
strXml += `<Override PartName="/ppt/slides/slide${idx + 1}.xml" ContentType="application/vnd.openxmlformats-officedocument.presentationml.slide+xml"/>`;
|
|
20800
22592
|
// Add charts if any
|
|
20801
22593
|
slide._relsChart.forEach((rel)=>{
|
|
20802
|
-
strXml +=
|
|
22594
|
+
strXml += chartContentTypes(rel);
|
|
20803
22595
|
});
|
|
20804
22596
|
});
|
|
20805
22597
|
// STEP 3: Core PPT
|
|
@@ -20812,7 +22604,7 @@ function slideShowExtLst(slide) {
|
|
|
20812
22604
|
slideLayouts.forEach((layout, idx)=>{
|
|
20813
22605
|
strXml += `<Override PartName="/ppt/slideLayouts/slideLayout${idx + 1}.xml" ContentType="application/vnd.openxmlformats-officedocument.presentationml.slideLayout+xml"/>`;
|
|
20814
22606
|
(layout._relsChart || []).forEach((rel)=>{
|
|
20815
|
-
strXml +=
|
|
22607
|
+
strXml += chartContentTypes(rel);
|
|
20816
22608
|
});
|
|
20817
22609
|
});
|
|
20818
22610
|
// STEP 5: Add notes slide(s)
|
|
@@ -20841,10 +22633,10 @@ function slideShowExtLst(slide) {
|
|
|
20841
22633
|
if (tracking === null || tracking === void 0 ? void 0 : tracking.revisionInfo) strXml += `<Override PartName="/ppt/revisionInfo.xml" ContentType="${REVISION_INFO_CONTENT_TYPE}"/>`;
|
|
20842
22634
|
if (tracking === null || tracking === void 0 ? void 0 : tracking.changesInfo) strXml += `<Override PartName="/ppt/changesInfo.xml" ContentType="${CHANGES_INFO_CONTENT_TYPE}"/>`;
|
|
20843
22635
|
((_ref = masterSlide === null || masterSlide === void 0 ? void 0 : masterSlide._relsChart) !== null && _ref !== void 0 ? _ref : []).forEach((rel)=>{
|
|
20844
|
-
strXml +=
|
|
22636
|
+
strXml += chartContentTypes(rel);
|
|
20845
22637
|
});
|
|
20846
22638
|
((_ref1 = masterSlide === null || masterSlide === void 0 ? void 0 : masterSlide._relsMedia) !== null && _ref1 !== void 0 ? _ref1 : []).forEach((rel)=>{
|
|
20847
|
-
if (rel.type !== 'image' && rel.type !== 'online' && rel.type !== 'chart' && rel.extn !== 'm4v' && !strXml.includes(rel.type)) {
|
|
22639
|
+
if (!rel.isLinked && rel.type !== 'image' && rel.type !== 'online' && rel.type !== 'chart' && rel.extn !== 'm4v' && !strXml.includes(rel.type)) {
|
|
20848
22640
|
strXml += ' <Default Extension="' + rel.extn + '" ContentType="' + rel.type + '"/>';
|
|
20849
22641
|
}
|
|
20850
22642
|
});
|
|
@@ -20864,22 +22656,46 @@ function slideShowExtLst(slide) {
|
|
|
20864
22656
|
<Relationship Id="rId3" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" Target="ppt/presentation.xml"/>
|
|
20865
22657
|
</Relationships>`;
|
|
20866
22658
|
}
|
|
22659
|
+
/**
|
|
22660
|
+
* Count text paragraphs across the deck for `app.xml`
|
|
22661
|
+
* - derived rather than exposed: the value is a fact about the deck, not a caller preference
|
|
22662
|
+
* @param {PresSlide[]} slides - presentation slides
|
|
22663
|
+
* @returns {number} paragraph count
|
|
22664
|
+
*/ function countParagraphs(slides) {
|
|
22665
|
+
return slides.reduce((total, slide)=>{
|
|
22666
|
+
var _slide__slideObjects;
|
|
22667
|
+
return total + ((_slide__slideObjects = slide._slideObjects) !== null && _slide__slideObjects !== void 0 ? _slide__slideObjects : []).reduce((count, obj)=>{
|
|
22668
|
+
var _obj_text;
|
|
22669
|
+
if (obj._type !== (/* inlined export .SLIDE_OBJECT_TYPES.text */"text") && obj._type !== (/* inlined export .SLIDE_OBJECT_TYPES.placeholder */"placeholder")) return count;
|
|
22670
|
+
return count + Math.max(1, ((_obj_text = obj.text) !== null && _obj_text !== void 0 ? _obj_text : []).length);
|
|
22671
|
+
}, 0);
|
|
22672
|
+
}, 0);
|
|
22673
|
+
}
|
|
20867
22674
|
/**
|
|
20868
22675
|
* Creates `docProps/app.xml`
|
|
20869
22676
|
* @param {PresSlide[]} slides - Presenation Slides
|
|
20870
22677
|
* @param {string} company - "Company" metadata
|
|
22678
|
+
* @param {DocumentProps} [props] - optional extended properties
|
|
20871
22679
|
* @returns XML
|
|
20872
|
-
*/ function makeXmlApp(slides, company) {
|
|
22680
|
+
*/ function makeXmlApp(slides, company, props) {
|
|
20873
22681
|
return `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>${(/* inlined export .CRLF */"\r\n")}<Properties xmlns="http://schemas.openxmlformats.org/officeDocument/2006/extended-properties" xmlns:vt="http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes">
|
|
20874
|
-
|
|
22682
|
+
${(props === null || props === void 0 ? void 0 : props.template) ? `<Template>${encodeXmlEntities(props.template)}</Template>` : ''}
|
|
22683
|
+
${(props === null || props === void 0 ? void 0 : props.manager) ? `<Manager>${encodeXmlEntities(props.manager)}</Manager>` : ''}
|
|
22684
|
+
<TotalTime>${typeof (props === null || props === void 0 ? void 0 : props.totalEditTime) === 'number' && isFinite(props.totalEditTime) && props.totalEditTime >= 0 ? Math.round(props.totalEditTime) : 0}</TotalTime>
|
|
20875
22685
|
<Words>0</Words>
|
|
20876
22686
|
<Application>Microsoft Office PowerPoint</Application>
|
|
20877
22687
|
<PresentationFormat>On-screen Show (16:9)</PresentationFormat>
|
|
20878
|
-
<Paragraphs
|
|
22688
|
+
<Paragraphs>${countParagraphs(slides)}</Paragraphs>
|
|
20879
22689
|
<Slides>${slides.length}</Slides>
|
|
20880
|
-
<Notes>${slides.
|
|
20881
|
-
|
|
20882
|
-
|
|
22690
|
+
<Notes>${slides.filter((slide)=>{
|
|
22691
|
+
var _slide__slideObjects;
|
|
22692
|
+
return ((_slide__slideObjects = slide._slideObjects) !== null && _slide__slideObjects !== void 0 ? _slide__slideObjects : []).some((obj)=>obj._type === (/* inlined export .SLIDE_OBJECT_TYPES.notes */"notes"));
|
|
22693
|
+
}).length}</Notes>
|
|
22694
|
+
<HiddenSlides>${slides.filter((slide)=>slide.hidden).length}</HiddenSlides>
|
|
22695
|
+
<MMClips>${slides.reduce((sum, slide)=>{
|
|
22696
|
+
var _slide__slideObjects;
|
|
22697
|
+
return sum + ((_slide__slideObjects = slide._slideObjects) !== null && _slide__slideObjects !== void 0 ? _slide__slideObjects : []).filter((obj)=>obj._type === (/* inlined export .SLIDE_OBJECT_TYPES.media */"media")).length;
|
|
22698
|
+
}, 0)}</MMClips>
|
|
20883
22699
|
<ScaleCrop>false</ScaleCrop>
|
|
20884
22700
|
<HeadingPairs>
|
|
20885
22701
|
<vt:vector size="6" baseType="variant">
|
|
@@ -20902,6 +22718,7 @@ function slideShowExtLst(slide) {
|
|
|
20902
22718
|
<Company>${encodeXmlEntities(company)}</Company>
|
|
20903
22719
|
<LinksUpToDate>false</LinksUpToDate>
|
|
20904
22720
|
<SharedDoc>false</SharedDoc>
|
|
22721
|
+
${(props === null || props === void 0 ? void 0 : props.hyperlinkBase) ? `<HyperlinkBase>${encodeXmlEntities(props.hyperlinkBase)}</HyperlinkBase>` : ''}
|
|
20905
22722
|
<HyperlinksChanged>false</HyperlinksChanged>
|
|
20906
22723
|
<AppVersion>16.0000</AppVersion>
|
|
20907
22724
|
</Properties>`;
|
|
@@ -20914,14 +22731,23 @@ function slideShowExtLst(slide) {
|
|
|
20914
22731
|
* @param {string} revision - metadata value
|
|
20915
22732
|
* @param {Date} [created] - OPC `dcterms:created` (defaults to now)
|
|
20916
22733
|
* @param {Date} [modified] - OPC `dcterms:modified` (defaults to now)
|
|
22734
|
+
* @param {DocumentProps} [props] - optional extra core properties
|
|
20917
22735
|
* @returns XML
|
|
20918
|
-
*/ function makeXmlCore(title, subject, author, revision, created, modified) {
|
|
22736
|
+
*/ function makeXmlCore(title, subject, author, revision, created, modified, props) {
|
|
20919
22737
|
const createdAt = (created !== null && created !== void 0 ? created : new Date()).toISOString().replace(/\.\d\d\dZ/, 'Z');
|
|
20920
22738
|
const modifiedAt = (modified !== null && modified !== void 0 ? modified : new Date()).toISOString().replace(/\.\d\d\dZ/, 'Z');
|
|
20921
22739
|
return `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
20922
22740
|
<cp:coreProperties xmlns:cp="http://schemas.openxmlformats.org/package/2006/metadata/core-properties" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:dcmitype="http://purl.org/dc/dcmitype/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
|
20923
22741
|
<dc:title>${encodeXmlEntities(title)}</dc:title>
|
|
20924
22742
|
<dc:subject>${encodeXmlEntities(subject)}</dc:subject>
|
|
22743
|
+
${(props === null || props === void 0 ? void 0 : props.description) ? `<dc:description>${encodeXmlEntities(props.description)}</dc:description>` : ''}
|
|
22744
|
+
${(props === null || props === void 0 ? void 0 : props.keywords) ? `<cp:keywords>${encodeXmlEntities(props.keywords)}</cp:keywords>` : ''}
|
|
22745
|
+
${(props === null || props === void 0 ? void 0 : props.category) ? `<cp:category>${encodeXmlEntities(props.category)}</cp:category>` : ''}
|
|
22746
|
+
${(props === null || props === void 0 ? void 0 : props.contentStatus) ? `<cp:contentStatus>${encodeXmlEntities(props.contentStatus)}</cp:contentStatus>` : ''}
|
|
22747
|
+
${(props === null || props === void 0 ? void 0 : props.version) ? `<cp:version>${encodeXmlEntities(props.version)}</cp:version>` : ''}
|
|
22748
|
+
${(props === null || props === void 0 ? void 0 : props.language) ? `<dc:language>${encodeXmlEntities(props.language)}</dc:language>` : ''}
|
|
22749
|
+
${(props === null || props === void 0 ? void 0 : props.identifier) ? `<dc:identifier>${encodeXmlEntities(props.identifier)}</dc:identifier>` : ''}
|
|
22750
|
+
${(props === null || props === void 0 ? void 0 : props.lastPrinted) ? `<cp:lastPrinted>${encodeXmlEntities(props.lastPrinted)}</cp:lastPrinted>` : ''}
|
|
20925
22751
|
<dc:creator>${encodeXmlEntities(author)}</dc:creator>
|
|
20926
22752
|
<cp:lastModifiedBy>${encodeXmlEntities(author)}</cp:lastModifiedBy>
|
|
20927
22753
|
<cp:revision>${revision}</cp:revision>
|
|
@@ -20970,7 +22796,7 @@ function slideShowExtLst(slide) {
|
|
|
20970
22796
|
const entries = [];
|
|
20971
22797
|
((_slide__slideObjects = slide._slideObjects) !== null && _slide__slideObjects !== void 0 ? _slide__slideObjects : []).forEach((obj)=>{
|
|
20972
22798
|
var _obj_mediaRid;
|
|
20973
|
-
if (obj._type !== (/* inlined export .SLIDE_OBJECT_TYPES.media */"media") || obj.mtype
|
|
22799
|
+
if (obj._type !== (/* inlined export .SLIDE_OBJECT_TYPES.media */"media") || obj.mtype !== 'audio' && obj.mtype !== 'video') return;
|
|
20974
22800
|
const o = obj.options;
|
|
20975
22801
|
// Defaults are all false: no timing node unless at least one playback flag is set.
|
|
20976
22802
|
if (!o || !(o.autoplay || o.loop || o.fullScreen || o.mute)) return;
|
|
@@ -21105,10 +22931,29 @@ function collectSlideAnimations(slide) {
|
|
|
21105
22931
|
* @param {SlideLayout} layout - slide layout (master)
|
|
21106
22932
|
* @return {string} XML
|
|
21107
22933
|
*/ function makeXmlLayout(layout) {
|
|
22934
|
+
// `preserve` has always been written as "1", so it stays on unless the caller turns it off
|
|
22935
|
+
let attrs = layout.preserve === false ? '' : ' preserve="1"';
|
|
22936
|
+
if (layout.layoutType) attrs += ` type="${layout.layoutType}"`;
|
|
22937
|
+
if (layout.matchingName) attrs += ` matchingName="${encodeXmlEntities(layout.matchingName)}"`;
|
|
22938
|
+
// both default to true in the schema, so only the "off" case is written
|
|
22939
|
+
if (layout.showMasterShapes === false) attrs += ' showMasterSp="0"';
|
|
22940
|
+
if (layout.showMasterPlaceholderAnimation === false) attrs += ' showMasterPhAnim="0"';
|
|
22941
|
+
if (layout.userDrawn === true) attrs += ' userDrawn="1"';
|
|
22942
|
+
// CT_ColorMapping requires all twelve attributes, so a partial override is filled from the
|
|
22943
|
+
// identity map - which is exactly what inheriting `a:masterClrMapping` means
|
|
22944
|
+
const clrMapOvr = layout.colorMapOverride ? `<p:clrMapOvr><a:overrideClrMapping${Object.entries(DEF_COLOR_MAP).map(([slot, fallback])=>{
|
|
22945
|
+
var _ref;
|
|
22946
|
+
var _layout_colorMapOverride;
|
|
22947
|
+
return ` ${slot}="${(_ref = (_layout_colorMapOverride = layout.colorMapOverride) === null || _layout_colorMapOverride === void 0 ? void 0 : _layout_colorMapOverride[slot]) !== null && _ref !== void 0 ? _ref : fallback}"`;
|
|
22948
|
+
}).join('')}/></p:clrMapOvr>` : '<p:clrMapOvr><a:masterClrMapping/></p:clrMapOvr>';
|
|
22949
|
+
const transitionXml = genXmlTransition(layout);
|
|
22950
|
+
const hasP14 = transitionXml.includes('p14:') || transitionXml.includes('xmlns:p14');
|
|
22951
|
+
const ns = hasP14 ? ` xmlns:p14="${P14_NS}"` : '';
|
|
22952
|
+
// CT_SlideLayout sequence: cSld, clrMapOvr, transition, timing, hf, extLst
|
|
21108
22953
|
return `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
21109
|
-
<p:sldLayout xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:p="http://schemas.openxmlformats.org/presentationml/2006/main"
|
|
22954
|
+
<p:sldLayout xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:p="http://schemas.openxmlformats.org/presentationml/2006/main"${ns}${attrs}>
|
|
21110
22955
|
${slideObjectToXml(layout)}
|
|
21111
|
-
|
|
22956
|
+
${clrMapOvr}${transitionXml}</p:sldLayout>`;
|
|
21112
22957
|
}
|
|
21113
22958
|
/**
|
|
21114
22959
|
* Creates Slide Master 1 (`ppt/slideMasters/slideMaster1.xml`)
|
|
@@ -21179,6 +23024,7 @@ const NOTES_GUIDE_URI = '{2D200454-40CA-4A62-9FC3-DE9A4176ACB9}';
|
|
|
21179
23024
|
* @param {IPresentationProps} pres - presentation
|
|
21180
23025
|
* @return {string} XML
|
|
21181
23026
|
*/ function makeXmlPresentation(pres) {
|
|
23027
|
+
var _pres_kinsoku;
|
|
21182
23028
|
let strXml = `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>${(/* inlined export .CRLF */"\r\n")}` + '<p:presentation xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" ' + `xmlns:p="http://schemas.openxmlformats.org/presentationml/2006/main" firstSlideNum="${pres.firstSlideNum}" ${pres.rtlMode ? 'rtl="1"' : ''} saveSubsetFonts="1" autoCompressPictures="0">`;
|
|
21183
23029
|
// STEP 1: Add slide master (SPEC: tag 1 under <presentation>)
|
|
21184
23030
|
strXml += '<p:sldMasterIdLst><p:sldMasterId id="2147483648" r:id="rId1"/></p:sldMasterIdLst>';
|
|
@@ -21202,8 +23048,26 @@ const NOTES_GUIDE_URI = '{2D200454-40CA-4A62-9FC3-DE9A4176ACB9}';
|
|
|
21202
23048
|
// Presentations open without warning without this line, but then they aren't previewed in Finder or viewable on iOS.
|
|
21203
23049
|
strXml += `<p:notesMasterIdLst><p:notesMasterId r:id="rId${pres.slides.length + 2}"/></p:notesMasterIdLst>`;
|
|
21204
23050
|
// STEP 4: Add sizes
|
|
21205
|
-
|
|
23051
|
+
// `@type` records which preset the dimensions match; omitted when the caller does not say
|
|
23052
|
+
strXml += `<p:sldSz cx="${pres.presLayout.width}" cy="${pres.presLayout.height}"${pres.slideSizeType ? ` type="${pres.slideSizeType}"` : ''}/>`;
|
|
21206
23053
|
strXml += `<p:notesSz cx="${pres.presLayout.height}" cy="${pres.presLayout.width}"/>`;
|
|
23054
|
+
// CT_Presentation sequence puts these between `notesSz` and `defaultTextStyle` (photoAlbum, kinsoku)
|
|
23055
|
+
if (pres.photoAlbum) {
|
|
23056
|
+
const album = pres.photoAlbum;
|
|
23057
|
+
let attrs = '';
|
|
23058
|
+
if (album.blackWhite === true) attrs += ' bw="1"';
|
|
23059
|
+
if (album.showCaptions === true) attrs += ' showCaptions="1"';
|
|
23060
|
+
if (album.layout) attrs += ` layout="${album.layout}"`;
|
|
23061
|
+
if (album.frame) attrs += ` frame="${album.frame}"`;
|
|
23062
|
+
strXml += `<p:photoAlbum${attrs}/>`;
|
|
23063
|
+
}
|
|
23064
|
+
// `invalStChars` and `invalEndChars` are required on CT_Kinsoku, so a partial value is dropped
|
|
23065
|
+
// rather than emitted as an element PowerPoint would refuse to open
|
|
23066
|
+
if (((_pres_kinsoku = pres.kinsoku) === null || _pres_kinsoku === void 0 ? void 0 : _pres_kinsoku.invalidStartChars) && pres.kinsoku.invalidEndChars) {
|
|
23067
|
+
const kin = pres.kinsoku;
|
|
23068
|
+
const lang = kin.lang ? ` lang="${encodeXmlEntities(kin.lang)}"` : '';
|
|
23069
|
+
strXml += `<p:kinsoku${lang} invalStChars="${encodeXmlEntities(kin.invalidStartChars)}" invalEndChars="${encodeXmlEntities(kin.invalidEndChars)}"/>`;
|
|
23070
|
+
}
|
|
21207
23071
|
// STEP 5: Add text styles
|
|
21208
23072
|
strXml += '<p:defaultTextStyle>';
|
|
21209
23073
|
for(let idy = 1; idy < 10; idy++){
|
|
@@ -21243,10 +23107,28 @@ const NOTES_GUIDE_URI = '{2D200454-40CA-4A62-9FC3-DE9A4176ACB9}';
|
|
|
21243
23107
|
* Create `ppt/presProps.xml`
|
|
21244
23108
|
* @return {string} XML
|
|
21245
23109
|
*/ function makeXmlPresProps(pres) {
|
|
21246
|
-
// CT_PresentationProperties sequence:
|
|
23110
|
+
// CT_PresentationProperties sequence: htmlPubPr, webPr, prnPr, showPr, clrMru, extLst.
|
|
23111
|
+
// Opt-in: emit nothing extra unless set. prnPr/clrMru live here (not on CT_Presentation).
|
|
23112
|
+
const prnPr = makeXmlPrnPr(pres);
|
|
21247
23113
|
const showPr = makeXmlShowPr(pres);
|
|
23114
|
+
const clrMru = makeXmlClrMru(pres);
|
|
21248
23115
|
const extLst = makeXmlPresPropsExtLst(pres);
|
|
21249
|
-
return `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>${(/* inlined export .CRLF */"\r\n")}` + '<p:presentationPr xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:p="http://schemas.openxmlformats.org/presentationml/2006/main">' + `${showPr}${extLst}</p:presentationPr>`;
|
|
23116
|
+
return `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>${(/* inlined export .CRLF */"\r\n")}` + '<p:presentationPr xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:p="http://schemas.openxmlformats.org/presentationml/2006/main">' + `${prnPr}${showPr}${clrMru}${extLst}</p:presentationPr>`;
|
|
23117
|
+
}
|
|
23118
|
+
function makeXmlPrnPr(pres) {
|
|
23119
|
+
if (!(pres === null || pres === void 0 ? void 0 : pres.printProps)) return '';
|
|
23120
|
+
const prn = pres.printProps;
|
|
23121
|
+
let attrs = '';
|
|
23122
|
+
if (prn.what) attrs += ` prnWhat="${prn.what}"`;
|
|
23123
|
+
if (prn.colorMode) attrs += ` clrMode="${prn.colorMode}"`;
|
|
23124
|
+
if (prn.hiddenSlides === true) attrs += ' hiddenSlides="1"';
|
|
23125
|
+
if (prn.scaleToFitPaper === true) attrs += ' scaleToFitPaper="1"';
|
|
23126
|
+
if (prn.frameSlides === true) attrs += ' frameSlides="1"';
|
|
23127
|
+
return `<p:prnPr${attrs}/>`;
|
|
23128
|
+
}
|
|
23129
|
+
function makeXmlClrMru(pres) {
|
|
23130
|
+
if (!Array.isArray(pres === null || pres === void 0 ? void 0 : pres.recentColors) || pres.recentColors.length === 0) return '';
|
|
23131
|
+
return `<p:clrMru>${pres.recentColors.map((color)=>createColorElement(color)).join('')}</p:clrMru>`;
|
|
21250
23132
|
}
|
|
21251
23133
|
/**
|
|
21252
23134
|
* `p:showPr` for slide-show options, or '' when none are set.
|
|
@@ -21295,14 +23177,144 @@ function makeXmlPresPropsExtLst(pres) {
|
|
|
21295
23177
|
* Create `ppt/tableStyles.xml`
|
|
21296
23178
|
* @see: http://openxmldeveloper.org/discussions/formats/f/13/p/2398/8107.aspx
|
|
21297
23179
|
* @return {string} XML
|
|
21298
|
-
*/
|
|
21299
|
-
|
|
23180
|
+
*/ /**
|
|
23181
|
+
* The GUID `a:tblStyleLst@def` has always carried - PowerPoint's "Medium Style 2 - Accent 1"
|
|
23182
|
+
*/ const DEF_TABLE_STYLE_ID = '{5C22544A-7EE6-4342-B048-85BDC9FD1C3A}';
|
|
23183
|
+
/**
|
|
23184
|
+
* CT_TableStyle fixes this child order, and it is neither alphabetical nor the intuitive one:
|
|
23185
|
+
* `lastCol` precedes `firstCol`, and `firstRow` sits between `swCell` and `neCell`.
|
|
23186
|
+
*/ const TABLE_STYLE_PARTS = [
|
|
23187
|
+
[
|
|
23188
|
+
'wholeTable',
|
|
23189
|
+
'wholeTbl'
|
|
23190
|
+
],
|
|
23191
|
+
[
|
|
23192
|
+
'band1H',
|
|
23193
|
+
'band1H'
|
|
23194
|
+
],
|
|
23195
|
+
[
|
|
23196
|
+
'band2H',
|
|
23197
|
+
'band2H'
|
|
23198
|
+
],
|
|
23199
|
+
[
|
|
23200
|
+
'band1V',
|
|
23201
|
+
'band1V'
|
|
23202
|
+
],
|
|
23203
|
+
[
|
|
23204
|
+
'band2V',
|
|
23205
|
+
'band2V'
|
|
23206
|
+
],
|
|
23207
|
+
[
|
|
23208
|
+
'lastCol',
|
|
23209
|
+
'lastCol'
|
|
23210
|
+
],
|
|
23211
|
+
[
|
|
23212
|
+
'firstCol',
|
|
23213
|
+
'firstCol'
|
|
23214
|
+
],
|
|
23215
|
+
[
|
|
23216
|
+
'lastRow',
|
|
23217
|
+
'lastRow'
|
|
23218
|
+
],
|
|
23219
|
+
[
|
|
23220
|
+
'seCell',
|
|
23221
|
+
'seCell'
|
|
23222
|
+
],
|
|
23223
|
+
[
|
|
23224
|
+
'swCell',
|
|
23225
|
+
'swCell'
|
|
23226
|
+
],
|
|
23227
|
+
[
|
|
23228
|
+
'firstRow',
|
|
23229
|
+
'firstRow'
|
|
23230
|
+
],
|
|
23231
|
+
[
|
|
23232
|
+
'neCell',
|
|
23233
|
+
'neCell'
|
|
23234
|
+
],
|
|
23235
|
+
[
|
|
23236
|
+
'nwCell',
|
|
23237
|
+
'nwCell'
|
|
23238
|
+
]
|
|
23239
|
+
];
|
|
23240
|
+
/** CT_TableCellBorderStyle child order */ const TABLE_STYLE_BORDERS = [
|
|
23241
|
+
'left',
|
|
23242
|
+
'right',
|
|
23243
|
+
'top',
|
|
23244
|
+
'bottom',
|
|
23245
|
+
'insideH',
|
|
23246
|
+
'insideV'
|
|
23247
|
+
];
|
|
23248
|
+
/**
|
|
23249
|
+
* One part of a table style (`a:wholeTbl`, `a:band1H`, ...).
|
|
23250
|
+
* - `a:tcTxStyle` precedes `a:tcStyle`; inside the cell style, `a:tcBdr` precedes the fill
|
|
23251
|
+
*/ function genXmlTableStylePart(tag, part) {
|
|
23252
|
+
// `b`/`i` are ST_OnOffStyleType: an unset property means "def", i.e. leave it to the theme
|
|
23253
|
+
const bold = typeof part.bold === 'boolean' ? ` b="${part.bold ? 'on' : 'off'}"` : '';
|
|
23254
|
+
const italic = typeof part.italic === 'boolean' ? ` i="${part.italic ? 'on' : 'off'}"` : '';
|
|
23255
|
+
const txStyle = bold || italic || part.color ? `<a:tcTxStyle${bold}${italic}>${part.color ? createColorElement(part.color) : ''}</a:tcTxStyle>` : '';
|
|
23256
|
+
const borders = TABLE_STYLE_BORDERS.filter((edge)=>{
|
|
23257
|
+
var _part_borders;
|
|
23258
|
+
return (_part_borders = part.borders) === null || _part_borders === void 0 ? void 0 : _part_borders[edge];
|
|
23259
|
+
}).map((edge)=>{
|
|
23260
|
+
var _part_borders;
|
|
23261
|
+
const line = (_part_borders = part.borders) === null || _part_borders === void 0 ? void 0 : _part_borders[edge];
|
|
23262
|
+
return line ? `<a:${edge}>${genXmlLine(line)}</a:${edge}>` : '';
|
|
23263
|
+
}).join('');
|
|
23264
|
+
const fill = part.fill ? `<a:fill>${genXmlColorSelection(part.fill)}</a:fill>` : '';
|
|
23265
|
+
const cellStyle = borders || fill ? `<a:tcStyle>${borders ? `<a:tcBdr>${borders}</a:tcBdr>` : ''}${fill}</a:tcStyle>` : '';
|
|
23266
|
+
return txStyle || cellStyle ? `<a:${tag}>${txStyle}${cellStyle}</a:${tag}>` : '';
|
|
23267
|
+
}
|
|
23268
|
+
/**
|
|
23269
|
+
* Creates `ppt/tableStyles.xml`
|
|
23270
|
+
* - with no custom styles this is the same self-closing stub earlier versions wrote
|
|
23271
|
+
* @param {TableStyleProps[]} [styles] - custom table style definitions
|
|
23272
|
+
* @return {string} XML
|
|
23273
|
+
*/ function makeXmlTableStyles(styles) {
|
|
23274
|
+
const valid = (styles !== null && styles !== void 0 ? styles : []).filter((style)=>{
|
|
23275
|
+
var _ref;
|
|
23276
|
+
// `@styleId` is an ST_Guid and `@styleName` is required; a malformed id would be rejected on open
|
|
23277
|
+
if (!/^\{[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12}\}$/.test((_ref = style === null || style === void 0 ? void 0 : style.id) !== null && _ref !== void 0 ? _ref : '')) {
|
|
23278
|
+
console.warn(`[pptxgenjs] table style \`id\` must be a braced GUID, e.g. '{5C22544A-7EE6-4342-B048-85BDC9FD1C3A}' - "${String(style === null || style === void 0 ? void 0 : style.id)}" ignored`);
|
|
23279
|
+
return false;
|
|
23280
|
+
}
|
|
23281
|
+
if (!style.name) {
|
|
23282
|
+
console.warn(`[pptxgenjs] table style ${style.id} has no \`name\` - ignored`);
|
|
23283
|
+
return false;
|
|
23284
|
+
}
|
|
23285
|
+
return true;
|
|
23286
|
+
});
|
|
23287
|
+
const head = `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>${(/* inlined export .CRLF */"\r\n")}<a:tblStyleLst xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" def="${DEF_TABLE_STYLE_ID}"`;
|
|
23288
|
+
if (valid.length === 0) return `${head}/>`;
|
|
23289
|
+
const body = valid.map((style)=>{
|
|
23290
|
+
const parts = TABLE_STYLE_PARTS.map(([prop, tag])=>{
|
|
23291
|
+
const part = style[prop];
|
|
23292
|
+
return part && typeof part === 'object' ? genXmlTableStylePart(tag, part) : '';
|
|
23293
|
+
}).join('');
|
|
23294
|
+
return `<a:tblStyle styleId="${style.id}" styleName="${encodeXmlEntities(style.name)}">${parts}</a:tblStyle>`;
|
|
23295
|
+
}).join('');
|
|
23296
|
+
return `${head}>${body}</a:tblStyleLst>`;
|
|
21300
23297
|
}
|
|
21301
23298
|
/**
|
|
21302
23299
|
* Creates `ppt/viewProps.xml`
|
|
23300
|
+
* - the hardcoded literal is kept when the caller sets no `viewProps`, so default packages stay byte-identical
|
|
21303
23301
|
* @return {string} XML
|
|
21304
|
-
*/ function makeXmlViewProps() {
|
|
21305
|
-
|
|
23302
|
+
*/ function makeXmlViewProps(pres) {
|
|
23303
|
+
var _view_guides;
|
|
23304
|
+
if (!(pres === null || pres === void 0 ? void 0 : pres.viewProps)) {
|
|
23305
|
+
return `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>${(/* inlined export .CRLF */"\r\n")}<p:viewPr xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:p="http://schemas.openxmlformats.org/presentationml/2006/main"><p:normalViewPr horzBarState="maximized"><p:restoredLeft sz="15611"/><p:restoredTop sz="94610"/></p:normalViewPr><p:slideViewPr><p:cSldViewPr snapToGrid="0" snapToObjects="1"><p:cViewPr varScale="1"><p:scale><a:sx n="136" d="100"/><a:sy n="136" d="100"/></p:scale><p:origin x="216" y="312"/></p:cViewPr><p:guideLst/></p:cSldViewPr></p:slideViewPr><p:notesTextViewPr><p:cViewPr><p:scale><a:sx n="1" d="1"/><a:sy n="1" d="1"/></p:scale><p:origin x="0" y="0"/></p:cViewPr></p:notesTextViewPr><p:gridSpacing cx="76200" cy="76200"/></p:viewPr>`;
|
|
23306
|
+
}
|
|
23307
|
+
const view = pres.viewProps;
|
|
23308
|
+
const zoom = typeof view.zoom === 'number' && isFinite(view.zoom) && view.zoom > 0 ? Math.round(view.zoom) : 136;
|
|
23309
|
+
const grid = typeof view.gridSpacing === 'number' && isFinite(view.gridSpacing) && view.gridSpacing > 0 ? inch2Emu(view.gridSpacing) : 76200;
|
|
23310
|
+
const snapGrid = view.snapToGrid === true ? '1' : '0';
|
|
23311
|
+
const snapObj = view.snapToObjects === false ? '0' : '1';
|
|
23312
|
+
const showGuides = view.showGuides === true ? ' showGuides="1"' : '';
|
|
23313
|
+
const showComments = view.showComments === false ? ' showComments="0"' : '';
|
|
23314
|
+
const lastView = view.lastView ? ` lastView="${view.lastView}"` : '';
|
|
23315
|
+
// `p:guideLst` is the classic guide list, distinct from the MS-PPTX `p15:sldGuideLst` extension
|
|
23316
|
+
const guides = ((_view_guides = view.guides) !== null && _view_guides !== void 0 ? _view_guides : []).filter((guide)=>typeof guide.pos === 'number' && isFinite(guide.pos) && guide.pos >= 0).map((guide)=>`<p:guide${guide.orient === 'vert' ? ' orient="vert"' : ''} pos="${Math.round(guide.pos * 96)}"/>`).join('');
|
|
23317
|
+
return `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>${(/* inlined export .CRLF */"\r\n")}` + `<p:viewPr xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:p="http://schemas.openxmlformats.org/presentationml/2006/main"${lastView}${showComments}>` + '<p:normalViewPr horzBarState="maximized"><p:restoredLeft sz="15611"/><p:restoredTop sz="94610"/></p:normalViewPr>' + `<p:slideViewPr><p:cSldViewPr snapToGrid="${snapGrid}" snapToObjects="${snapObj}"${showGuides}>` + `<p:cViewPr varScale="1"><p:scale><a:sx n="${zoom}" d="100"/><a:sy n="${zoom}" d="100"/></p:scale><p:origin x="216" y="312"/></p:cViewPr>` + (guides ? `<p:guideLst>${guides}</p:guideLst>` : '<p:guideLst/>') + '</p:cSldViewPr></p:slideViewPr>' + '<p:notesTextViewPr><p:cViewPr><p:scale><a:sx n="1" d="1"/><a:sy n="1" d="1"/></p:scale><p:origin x="0" y="0"/></p:cViewPr></p:notesTextViewPr>' + `<p:gridSpacing cx="${grid}" cy="${grid}"/>` + '</p:viewPr>';
|
|
21306
23318
|
}
|
|
21307
23319
|
|
|
21308
23320
|
;// CONCATENATED MODULE: ./src/xml/index.ts
|
|
@@ -21312,6 +23324,8 @@ function makeXmlPresPropsExtLst(pres) {
|
|
|
21312
23324
|
|
|
21313
23325
|
|
|
21314
23326
|
|
|
23327
|
+
|
|
23328
|
+
|
|
21315
23329
|
;// CONCATENATED MODULE: ./src/pptxgen.ts
|
|
21316
23330
|
function pptxgen_asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
21317
23331
|
try {
|
|
@@ -21495,6 +23509,12 @@ class PptxGenJS {
|
|
|
21495
23509
|
get rtlMode() {
|
|
21496
23510
|
return this._rtlMode;
|
|
21497
23511
|
}
|
|
23512
|
+
set tableStyles(value) {
|
|
23513
|
+
this._tableStyles = value;
|
|
23514
|
+
}
|
|
23515
|
+
get tableStyles() {
|
|
23516
|
+
return this._tableStyles;
|
|
23517
|
+
}
|
|
21498
23518
|
get firstSlideNum() {
|
|
21499
23519
|
return this._firstSlideNum;
|
|
21500
23520
|
}
|
|
@@ -21790,7 +23810,15 @@ class PptxGenJS {
|
|
|
21790
23810
|
_slideNumberProps: propsClone.slideNumber || null,
|
|
21791
23811
|
_slideObjects: [],
|
|
21792
23812
|
background: propsClone.background || null,
|
|
21793
|
-
bkgd: propsClone.bkgd || null
|
|
23813
|
+
bkgd: propsClone.bkgd || null,
|
|
23814
|
+
layoutType: propsClone.layoutType,
|
|
23815
|
+
matchingName: propsClone.matchingName,
|
|
23816
|
+
preserve: propsClone.preserve,
|
|
23817
|
+
showMasterShapes: propsClone.showMasterShapes,
|
|
23818
|
+
showMasterPlaceholderAnimation: propsClone.showMasterPlaceholderAnimation,
|
|
23819
|
+
userDrawn: propsClone.userDrawn,
|
|
23820
|
+
colorMapOverride: propsClone.colorMapOverride,
|
|
23821
|
+
transition: propsClone.transition
|
|
21794
23822
|
};
|
|
21795
23823
|
// STEP 1: Create the Slide Master/Layout
|
|
21796
23824
|
createSlideMaster(propsClone, newLayout);
|
|
@@ -21826,7 +23854,7 @@ class PptxGenJS {
|
|
|
21826
23854
|
*/ pptxgen_define_property(this, "_layout", void 0);
|
|
21827
23855
|
/**
|
|
21828
23856
|
* PptxGenJS Library Version
|
|
21829
|
-
*/ pptxgen_define_property(this, "_version", (/* inlined export .VERSION */"4.1
|
|
23857
|
+
*/ pptxgen_define_property(this, "_version", (/* inlined export .VERSION */"4.2.1"));
|
|
21830
23858
|
/**
|
|
21831
23859
|
* @type {string}
|
|
21832
23860
|
*/ pptxgen_define_property(this, "_author", void 0);
|
|
@@ -21859,6 +23887,7 @@ class PptxGenJS {
|
|
|
21859
23887
|
* Whether Right-to-Left (RTL) mode is enabled
|
|
21860
23888
|
* @type {boolean}
|
|
21861
23889
|
*/ pptxgen_define_property(this, "_rtlMode", void 0);
|
|
23890
|
+
/** tableStyles - custom table style definitions written into `ppt/tableStyles.xml` */ pptxgen_define_property(this, "_tableStyles", void 0);
|
|
21862
23891
|
/**
|
|
21863
23892
|
* Starting slide number (`p:presentation@firstSlideNum`)
|
|
21864
23893
|
* @default 1
|
|
@@ -21894,6 +23923,13 @@ class PptxGenJS {
|
|
|
21894
23923
|
* Notes-page alignment guides (MS-PPTX §2.4.1.3). Emitted as `p15:notesGuideLst`.
|
|
21895
23924
|
* @example pptx.notesGuides = [{ orient: 'horz', pos: 2 }]
|
|
21896
23925
|
*/ pptxgen_define_property(this, "notesGuides", []);
|
|
23926
|
+
/** Additional document properties written to `docProps`. */ pptxgen_define_property(this, "documentProps", void 0);
|
|
23927
|
+
/** Slide-size preset (`p:sldSz@type`). */ pptxgen_define_property(this, "slideSizeType", void 0);
|
|
23928
|
+
/** Photo-album mode (`p:photoAlbum`). */ pptxgen_define_property(this, "photoAlbum", void 0);
|
|
23929
|
+
/** East Asian line-breaking rules (`p:kinsoku`). */ pptxgen_define_property(this, "kinsoku", void 0);
|
|
23930
|
+
/** Print defaults (`p:prnPr` on `presentationPr`). */ pptxgen_define_property(this, "printProps", void 0);
|
|
23931
|
+
/** Recently-used colours (`p:clrMru` on `presentationPr`). */ pptxgen_define_property(this, "recentColors", void 0);
|
|
23932
|
+
/** View properties (`ppt/viewProps.xml`). Unset keeps the previous hardcoded viewPr. */ pptxgen_define_property(this, "viewProps", void 0);
|
|
21897
23933
|
/**
|
|
21898
23934
|
* Modern comment authors (MS-PPTX §2.16). Emitted to `ppt/authors.xml`.
|
|
21899
23935
|
* Auto-populated from slide `addComment` author names if left empty.
|
|
@@ -21975,7 +24011,7 @@ class PptxGenJS {
|
|
|
21975
24011
|
*/ pptxgen_define_property(this, "createChartMediaRels", (slide, zip, chartPromises, mediaPaths)=>{
|
|
21976
24012
|
slide._relsChart.forEach((rel)=>chartPromises.push(createExcelWorksheet(rel, zip)));
|
|
21977
24013
|
slide._relsMedia.forEach((rel)=>{
|
|
21978
|
-
if (rel.type !== 'online' && rel.type !== 'hyperlink') {
|
|
24014
|
+
if (!rel.isLinked && rel.type !== 'online' && rel.type !== 'hyperlink') {
|
|
21979
24015
|
var _data_split_pop;
|
|
21980
24016
|
// A: Loop vars
|
|
21981
24017
|
let data = rel.data && typeof rel.data === 'string' ? rel.data : '';
|
|
@@ -22077,16 +24113,16 @@ class PptxGenJS {
|
|
|
22077
24113
|
};
|
|
22078
24114
|
zip.file('[Content_Types].xml', makeXmlContTypes(this.slides, this.slideLayouts, this.masterSlide, trackingParts)); // TODO: pass only `this` like below! 20200206
|
|
22079
24115
|
zip.file('_rels/.rels', makeXmlRootRels());
|
|
22080
|
-
zip.file('docProps/app.xml', makeXmlApp(this.slides, this.company)); // TODO: pass only `this` like below! 20200206
|
|
22081
|
-
zip.file('docProps/core.xml', makeXmlCore(this.title, this.subject, this.author, this.revision, this.created, this.modified)); // TODO: pass only `this` like below! 20200206
|
|
24116
|
+
zip.file('docProps/app.xml', makeXmlApp(this.slides, this.company, this.documentProps)); // TODO: pass only `this` like below! 20200206
|
|
24117
|
+
zip.file('docProps/core.xml', makeXmlCore(this.title, this.subject, this.author, this.revision, this.created, this.modified, this.documentProps)); // TODO: pass only `this` like below! 20200206
|
|
22082
24118
|
zip.file('ppt/_rels/presentation.xml.rels', makeXmlPresentationRels(this.slides, trackingParts));
|
|
22083
24119
|
zip.file('ppt/theme/theme1.xml', makeXmlTheme(this));
|
|
22084
24120
|
// notesMaster gets its own theme part (Office repair creates theme2 when notesMaster shares theme1; Juliussssssss 9bdfe09).
|
|
22085
24121
|
zip.file('ppt/theme/theme2.xml', makeXmlTheme(this, 'notes'));
|
|
22086
24122
|
zip.file('ppt/presentation.xml', makeXmlPresentation(this));
|
|
22087
24123
|
zip.file('ppt/presProps.xml', makeXmlPresProps(this));
|
|
22088
|
-
zip.file('ppt/tableStyles.xml', makeXmlTableStyles());
|
|
22089
|
-
zip.file('ppt/viewProps.xml', makeXmlViewProps());
|
|
24124
|
+
zip.file('ppt/tableStyles.xml', makeXmlTableStyles(this._tableStyles));
|
|
24125
|
+
zip.file('ppt/viewProps.xml', makeXmlViewProps(this));
|
|
22090
24126
|
// C: Create a Layout/Master/Rel/Slide file for each SlideLayout and Slide
|
|
22091
24127
|
this.slideLayouts.forEach((layout, idx)=>{
|
|
22092
24128
|
zip.file(`ppt/slideLayouts/slideLayout${idx + 1}.xml`, makeXmlLayout(layout));
|
|
@@ -22253,6 +24289,7 @@ class PptxGenJS {
|
|
|
22253
24289
|
addTable: notOnMaster,
|
|
22254
24290
|
addText: notOnMaster,
|
|
22255
24291
|
addGroup: notOnMaster,
|
|
24292
|
+
addConnector: notOnMaster,
|
|
22256
24293
|
addWordArt: notOnMaster,
|
|
22257
24294
|
addTransition: notOnMaster,
|
|
22258
24295
|
addAnimation: notOnMaster,
|