pptxgenjs-plus 4.1.20 → 4.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/pptxgen.bundle.js +68 -56
- package/dist/pptxgen.cjs.js +1800 -256
- package/dist/pptxgen.es.js +1795 -255
- package/dist/pptxgen.min.js +63 -51
- package/package.json +1 -1
- package/types/index.d.ts +1120 -21
package/dist/pptxgen.cjs.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* PptxGenJS 4.
|
|
1
|
+
/* PptxGenJS 4.2.0 @ 2026-08-24T12:56:09.653Z */
|
|
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,51 @@ 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
|
+
/**
|
|
157
|
+
* Chart style and chart colour-style parts (MS-ODRAWXML)
|
|
158
|
+
* - verified against Microsoft's own `ChartStylePart`/`ChartColorStylePart` definitions in
|
|
159
|
+
* dotnet/Open-XML-SDK, cross-checked against LibreOffice, rubyXL and OpenXLSX
|
|
160
|
+
* - note the asymmetry: the namespace is dated 2012, the relationships 2011. That is correct.
|
|
161
|
+
*/ const CHART_STYLE = Object.freeze({
|
|
162
|
+
ns: 'http://schemas.microsoft.com/office/drawing/2012/chartStyle',
|
|
163
|
+
styleContentType: 'application/vnd.ms-office.chartstyle+xml',
|
|
164
|
+
colorsContentType: 'application/vnd.ms-office.chartcolorstyle+xml',
|
|
165
|
+
styleRelType: 'http://schemas.microsoft.com/office/2011/relationships/chartStyle',
|
|
166
|
+
colorsRelType: 'http://schemas.microsoft.com/office/2011/relationships/chartColorStyle'
|
|
167
|
+
});
|
|
168
|
+
/**
|
|
169
|
+
* ChartEx (PowerPoint 2016+) package contract - MS-ODRAWXML 2.1.
|
|
170
|
+
*
|
|
171
|
+
* These chart types have no ECMA-376 representation: they live in their own `cx:chartSpace` part with a
|
|
172
|
+
* Microsoft content type and relationship type, and the slide-level `p:graphicFrame` must sit inside an
|
|
173
|
+
* `mc:AlternateContent` so consumers that predate them still get a fallback.
|
|
174
|
+
*
|
|
175
|
+
* The `requires` namespace is the schema generation a consumer must understand before it may take the
|
|
176
|
+
* `mc:Choice`; funnel arrived a revision after the 2016 launch set, so it gates on a later one.
|
|
177
|
+
*/ const OOXML_CHARTEX = {
|
|
178
|
+
/** `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',
|
|
179
|
+
partContentType: 'application/vnd.ms-office.chartex+xml',
|
|
180
|
+
relType: 'http://schemas.microsoft.com/office/2014/relationships/chartEx',
|
|
181
|
+
/** `mc:Choice@Requires` namespace for the Office 2016 launch layouts */ requires2016: 'http://schemas.microsoft.com/office/drawing/2015/9/8/chartex',
|
|
182
|
+
/** `mc:Choice@Requires` namespace for funnel, which shipped a schema revision later */ requiresFunnel: 'http://schemas.microsoft.com/office/drawing/2015/10/21/chartex'
|
|
183
|
+
};
|
|
184
|
+
/** `cx:series@layoutId` per chart type - a histogram is a `clusteredColumn` layout carrying `cx:binning` */ const CHARTEX_LAYOUT_ID = {
|
|
185
|
+
boxWhisker: 'boxWhisker',
|
|
186
|
+
funnel: 'funnel',
|
|
187
|
+
histogram: 'clusteredColumn',
|
|
188
|
+
sunburst: 'sunburst',
|
|
189
|
+
treemap: 'treemap',
|
|
190
|
+
waterfall: 'waterfall'
|
|
191
|
+
};
|
|
192
|
+
/**
|
|
193
|
+
* `mc:Choice@Requires` namespace gating a chartex chart type
|
|
194
|
+
* - funnel arrived a schema revision after the 2016 launch layouts, so it gates on a later generation
|
|
195
|
+
*/ function chartExRequiresNs(chartType) {
|
|
196
|
+
return chartType === 'funnel' ? OOXML_CHARTEX.requiresFunnel : OOXML_CHARTEX.requires2016;
|
|
197
|
+
}
|
|
198
|
+
/** True when `type` is emitted through the chartex pipeline rather than the ECMA-376 one */ function isChartexType(type) {
|
|
199
|
+
return typeof type === 'string' && Object.prototype.hasOwnProperty.call(CHARTEX_LAYOUT_ID, type);
|
|
200
|
+
}
|
|
128
201
|
/**
|
|
129
202
|
* Slide transition type.
|
|
130
203
|
* 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 +314,27 @@ var core_enums_TEXT_VALIGN = /*#__PURE__*/ function(TEXT_VALIGN) {
|
|
|
241
314
|
return TEXT_VALIGN;
|
|
242
315
|
}({});
|
|
243
316
|
const SLDNUMFLDID = '{F7021451-1387-4CA6-816F-3879F97B5CBC}';
|
|
317
|
+
/** ECMA-376 21.1.2.2.4 — `a:fld@type` values PowerPoint refreshes */ const TEXT_FIELD_TYPES = new Set([
|
|
318
|
+
'slidenum',
|
|
319
|
+
'datetime',
|
|
320
|
+
'datetimeFigureOut',
|
|
321
|
+
'datetime1',
|
|
322
|
+
'datetime2',
|
|
323
|
+
'datetime3',
|
|
324
|
+
'datetime4',
|
|
325
|
+
'datetime5',
|
|
326
|
+
'datetime6',
|
|
327
|
+
'datetime7',
|
|
328
|
+
'datetime8',
|
|
329
|
+
'datetime9',
|
|
330
|
+
'datetime10',
|
|
331
|
+
'datetime11',
|
|
332
|
+
'datetime12',
|
|
333
|
+
'datetime13',
|
|
334
|
+
'headerfooter',
|
|
335
|
+
'hdr',
|
|
336
|
+
'ftr'
|
|
337
|
+
]);
|
|
244
338
|
// ENUM
|
|
245
339
|
// TODO: 3.5 or v4.0: rationalize ts-def exported enum names/case!
|
|
246
340
|
// NOTE: First tsdef enum named correctly (shapes -> 'Shape', colors -> 'Color'), etc.
|
|
@@ -264,6 +358,12 @@ var core_enums_ChartType = /*#__PURE__*/ function(ChartType) {
|
|
|
264
358
|
ChartType["pie"] = "pie";
|
|
265
359
|
ChartType["radar"] = "radar";
|
|
266
360
|
ChartType["scatter"] = "scatter";
|
|
361
|
+
ChartType["boxWhisker"] = "boxWhisker";
|
|
362
|
+
ChartType["funnel"] = "funnel";
|
|
363
|
+
ChartType["histogram"] = "histogram";
|
|
364
|
+
ChartType["sunburst"] = "sunburst";
|
|
365
|
+
ChartType["treemap"] = "treemap";
|
|
366
|
+
ChartType["waterfall"] = "waterfall";
|
|
267
367
|
return ChartType;
|
|
268
368
|
}({});
|
|
269
369
|
var core_enums_ShapeType = /*#__PURE__*/ function(ShapeType) {
|
|
@@ -291,6 +391,10 @@ var core_enums_ShapeType = /*#__PURE__*/ function(ShapeType) {
|
|
|
291
391
|
ShapeType["actionButtonSound"] = "actionButtonSound";
|
|
292
392
|
ShapeType["arc"] = "arc";
|
|
293
393
|
ShapeType["bentArrow"] = "bentArrow";
|
|
394
|
+
ShapeType["bentConnector2"] = "bentConnector2";
|
|
395
|
+
ShapeType["bentConnector3"] = "bentConnector3";
|
|
396
|
+
ShapeType["bentConnector4"] = "bentConnector4";
|
|
397
|
+
ShapeType["bentConnector5"] = "bentConnector5";
|
|
294
398
|
ShapeType["bentUpArrow"] = "bentUpArrow";
|
|
295
399
|
ShapeType["bevel"] = "bevel";
|
|
296
400
|
ShapeType["blockArc"] = "blockArc";
|
|
@@ -314,6 +418,10 @@ var core_enums_ShapeType = /*#__PURE__*/ function(ShapeType) {
|
|
|
314
418
|
ShapeType["corner"] = "corner";
|
|
315
419
|
ShapeType["cornerTabs"] = "cornerTabs";
|
|
316
420
|
ShapeType["cube"] = "cube";
|
|
421
|
+
ShapeType["curvedConnector2"] = "curvedConnector2";
|
|
422
|
+
ShapeType["curvedConnector3"] = "curvedConnector3";
|
|
423
|
+
ShapeType["curvedConnector4"] = "curvedConnector4";
|
|
424
|
+
ShapeType["curvedConnector5"] = "curvedConnector5";
|
|
317
425
|
ShapeType["curvedDownArrow"] = "curvedDownArrow";
|
|
318
426
|
ShapeType["curvedLeftArrow"] = "curvedLeftArrow";
|
|
319
427
|
ShapeType["curvedRightArrow"] = "curvedRightArrow";
|
|
@@ -434,6 +542,7 @@ var core_enums_ShapeType = /*#__PURE__*/ function(ShapeType) {
|
|
|
434
542
|
ShapeType["star6"] = "star6";
|
|
435
543
|
ShapeType["star7"] = "star7";
|
|
436
544
|
ShapeType["star8"] = "star8";
|
|
545
|
+
ShapeType["straightConnector1"] = "straightConnector1";
|
|
437
546
|
ShapeType["stripedRightArrow"] = "stripedRightArrow";
|
|
438
547
|
ShapeType["sun"] = "sun";
|
|
439
548
|
ShapeType["swooshArrow"] = "swooshArrow";
|
|
@@ -507,6 +616,10 @@ var core_enums_SHAPE_TYPE = /*#__PURE__*/ function(SHAPE_TYPE) {
|
|
|
507
616
|
SHAPE_TYPE["ARC"] = "arc";
|
|
508
617
|
SHAPE_TYPE["BALLOON"] = "wedgeRoundRectCallout";
|
|
509
618
|
SHAPE_TYPE["BENT_ARROW"] = "bentArrow";
|
|
619
|
+
SHAPE_TYPE["BENT_CONNECTOR_2"] = "bentConnector2";
|
|
620
|
+
SHAPE_TYPE["BENT_CONNECTOR_3"] = "bentConnector3";
|
|
621
|
+
SHAPE_TYPE["BENT_CONNECTOR_4"] = "bentConnector4";
|
|
622
|
+
SHAPE_TYPE["BENT_CONNECTOR_5"] = "bentConnector5";
|
|
510
623
|
SHAPE_TYPE["BENT_UP_ARROW"] = "bentUpArrow";
|
|
511
624
|
SHAPE_TYPE["BEVEL"] = "bevel";
|
|
512
625
|
SHAPE_TYPE["BLOCK_ARC"] = "blockArc";
|
|
@@ -523,6 +636,10 @@ var core_enums_SHAPE_TYPE = /*#__PURE__*/ function(SHAPE_TYPE) {
|
|
|
523
636
|
SHAPE_TYPE["CORNER_TABS"] = "cornerTabs";
|
|
524
637
|
SHAPE_TYPE["CROSS"] = "plus";
|
|
525
638
|
SHAPE_TYPE["CUBE"] = "cube";
|
|
639
|
+
SHAPE_TYPE["CURVED_CONNECTOR_2"] = "curvedConnector2";
|
|
640
|
+
SHAPE_TYPE["CURVED_CONNECTOR_3"] = "curvedConnector3";
|
|
641
|
+
SHAPE_TYPE["CURVED_CONNECTOR_4"] = "curvedConnector4";
|
|
642
|
+
SHAPE_TYPE["CURVED_CONNECTOR_5"] = "curvedConnector5";
|
|
526
643
|
SHAPE_TYPE["CURVED_DOWN_ARROW"] = "curvedDownArrow";
|
|
527
644
|
SHAPE_TYPE["CURVED_DOWN_RIBBON"] = "ellipseRibbon";
|
|
528
645
|
SHAPE_TYPE["CURVED_LEFT_ARROW"] = "curvedLeftArrow";
|
|
@@ -664,6 +781,7 @@ var core_enums_SHAPE_TYPE = /*#__PURE__*/ function(SHAPE_TYPE) {
|
|
|
664
781
|
SHAPE_TYPE["STAR_6_POINT"] = "star6";
|
|
665
782
|
SHAPE_TYPE["STAR_7_POINT"] = "star7";
|
|
666
783
|
SHAPE_TYPE["STAR_8_POINT"] = "star8";
|
|
784
|
+
SHAPE_TYPE["STRAIGHT_CONNECTOR_1"] = "straightConnector1";
|
|
667
785
|
SHAPE_TYPE["STRIPED_RIGHT_ARROW"] = "stripedRightArrow";
|
|
668
786
|
SHAPE_TYPE["SUN"] = "sun";
|
|
669
787
|
SHAPE_TYPE["SWOOSH_ARROW"] = "swooshArrow";
|
|
@@ -683,13 +801,19 @@ var core_enums_CHART_TYPE = /*#__PURE__*/ function(CHART_TYPE) {
|
|
|
683
801
|
CHART_TYPE["AREA"] = "area";
|
|
684
802
|
CHART_TYPE["BAR"] = "bar";
|
|
685
803
|
CHART_TYPE["BAR3D"] = "bar3D";
|
|
804
|
+
CHART_TYPE["BOX_WHISKER"] = "boxWhisker";
|
|
686
805
|
CHART_TYPE["BUBBLE"] = "bubble";
|
|
687
806
|
CHART_TYPE["BUBBLE3D"] = "bubble3D";
|
|
688
807
|
CHART_TYPE["DOUGHNUT"] = "doughnut";
|
|
808
|
+
CHART_TYPE["FUNNEL"] = "funnel";
|
|
809
|
+
CHART_TYPE["HISTOGRAM"] = "histogram";
|
|
689
810
|
CHART_TYPE["LINE"] = "line";
|
|
690
811
|
CHART_TYPE["PIE"] = "pie";
|
|
691
812
|
CHART_TYPE["RADAR"] = "radar";
|
|
692
813
|
CHART_TYPE["SCATTER"] = "scatter";
|
|
814
|
+
CHART_TYPE["SUNBURST"] = "sunburst";
|
|
815
|
+
CHART_TYPE["TREEMAP"] = "treemap";
|
|
816
|
+
CHART_TYPE["WATERFALL"] = "waterfall";
|
|
693
817
|
return CHART_TYPE;
|
|
694
818
|
}({});
|
|
695
819
|
var core_enums_SCHEME_COLOR_NAMES = /*#__PURE__*/ function(SCHEME_COLOR_NAMES) {
|
|
@@ -991,13 +1115,37 @@ function _object_spread_props(target, source) {
|
|
|
991
1115
|
}
|
|
992
1116
|
return code;
|
|
993
1117
|
}
|
|
1118
|
+
/** Units per inch, for the length suffixes accepted on `x`/`y`/`w`/`h` and the other inch-valued options */ const UNITS_PER_INCH = {
|
|
1119
|
+
in: 1,
|
|
1120
|
+
cm: 2.54,
|
|
1121
|
+
mm: 25.4,
|
|
1122
|
+
pt: 72
|
|
1123
|
+
};
|
|
1124
|
+
/**
|
|
1125
|
+
* A number with a length suffix - `'2.5cm'`, `'-4mm'`, `'18pt'`, `'5in'`
|
|
1126
|
+
* - the mantissa alternates rather than using `\d*\.?\d+`: that form lets the two digit runs
|
|
1127
|
+
* split a plain integer many ways, so a long non-matching digit string backtracks quadratically
|
|
1128
|
+
*/ const REGEX_UNIT_LENGTH = /^\s*(-?(?:\d+(?:\.\d+)?|\.\d+))\s*(in|cm|mm|pt)\s*$/i;
|
|
1129
|
+
/**
|
|
1130
|
+
* Parse a unit-suffixed length into inches
|
|
1131
|
+
* - a suffixed value carries its own unit, so it bypasses the inches-vs-EMU magnitude heuristic entirely
|
|
1132
|
+
* @param {string} value - ex: `'2.5cm'`, `'18pt'`
|
|
1133
|
+
* @returns {number|undefined} inches, or `undefined` when `value` is not a suffixed length
|
|
1134
|
+
*/ function parseUnitLength(value) {
|
|
1135
|
+
const match = REGEX_UNIT_LENGTH.exec(value);
|
|
1136
|
+
if (!match) return undefined;
|
|
1137
|
+
const num = Number(match[1]);
|
|
1138
|
+
if (!Number.isFinite(num)) return undefined;
|
|
1139
|
+
return num / UNITS_PER_INCH[match[2].toLowerCase()];
|
|
1140
|
+
}
|
|
994
1141
|
/**
|
|
995
1142
|
* Translates any type of `x`/`y`/`w`/`h` prop to EMU
|
|
996
1143
|
* - guaranteed to return a result regardless of undefined, null, etc. (0)
|
|
997
1144
|
* - {number} - 12800 (EMU)
|
|
998
1145
|
* - {number} - 0.5 (inches)
|
|
999
1146
|
* - {string} - "75%"
|
|
1000
|
-
*
|
|
1147
|
+
* - {string} - "2.5cm" (also in/mm/pt)
|
|
1148
|
+
* @param {number|string} size - numeric ("5.5"), unit-suffixed ("2.5cm") or percentage ("90%")
|
|
1001
1149
|
* @param {'X' | 'Y'} xyDir - direction
|
|
1002
1150
|
* @param {PresLayout} layout - presentation layout
|
|
1003
1151
|
* @returns {number} calculated size
|
|
@@ -1010,7 +1158,12 @@ function _object_spread_props(target, source) {
|
|
|
1010
1158
|
// CASE 2: Number is already converted to something other than inches
|
|
1011
1159
|
// Assume any number whose absolute value is 100+ is EMU already.
|
|
1012
1160
|
if (typeof size === 'number' && Math.abs(size) >= 100) return size;
|
|
1013
|
-
// CASE 3:
|
|
1161
|
+
// CASE 3: Unit-suffixed length (ex: '2.5cm') - unambiguous, so no magnitude heuristic
|
|
1162
|
+
if (typeof size === 'string') {
|
|
1163
|
+
const inches = parseUnitLength(size);
|
|
1164
|
+
if (inches !== undefined) return Math.round((/* inlined export .EMU */914400) * inches);
|
|
1165
|
+
}
|
|
1166
|
+
// CASE 4: Percentage (ex: '50%')
|
|
1014
1167
|
if (typeof size === 'string' && size.includes('%')) {
|
|
1015
1168
|
if (xyDir && xyDir === 'X') return Math.round(parseFloat(size) / 100 * layout.width);
|
|
1016
1169
|
if (xyDir && xyDir === 'Y') return Math.round(parseFloat(size) / 100 * layout.height);
|
|
@@ -1074,6 +1227,11 @@ function _object_spread_props(target, source) {
|
|
|
1074
1227
|
* @param {number|string} inches - as string or number
|
|
1075
1228
|
* @returns {number} EMU value
|
|
1076
1229
|
*/ function inch2Emu(inches) {
|
|
1230
|
+
// A unit-suffixed string states its own unit - convert it before any inches assumption
|
|
1231
|
+
if (typeof inches === 'string') {
|
|
1232
|
+
const parsed = parseUnitLength(inches);
|
|
1233
|
+
if (parsed !== undefined) return Math.round((/* inlined export .EMU */914400) * parsed);
|
|
1234
|
+
}
|
|
1077
1235
|
// 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
1236
|
// Any absolute value over 100 is not inches (negative EMU is off-slide), so return it unchanged
|
|
1079
1237
|
if (typeof inches === 'number' && Math.abs(inches) > 100) return inches;
|
|
@@ -1367,6 +1525,23 @@ function createGlowElement(glow) {
|
|
|
1367
1525
|
const bg = String((pattern === null || pattern === void 0 ? void 0 : pattern.bgColor) || 'FFFFFF');
|
|
1368
1526
|
return `<a:pattFill prst="${prst}"><a:bgClr>${createColorElement(bg)}</a:bgClr><a:fgClr>${createColorElement(fg)}</a:fgClr></a:pattFill>`;
|
|
1369
1527
|
}
|
|
1528
|
+
/**
|
|
1529
|
+
* Create a DrawingML `a:blipFill` for a picture fill (ECMA-376 20.1.8.14)
|
|
1530
|
+
* - the image relationship is resolved when the object is created
|
|
1531
|
+
*/ function createImageFillElement(image, rId) {
|
|
1532
|
+
let mode = '<a:stretch><a:fillRect/></a:stretch>';
|
|
1533
|
+
if (image.sizing === 'tile') {
|
|
1534
|
+
var _image_alignment;
|
|
1535
|
+
const scale = typeof image.scale === 'number' && isFinite(image.scale) && image.scale > 0 ? Math.round(image.scale * 1000) : 100000;
|
|
1536
|
+
const rawAlgn = (_image_alignment = image.alignment) !== null && _image_alignment !== void 0 ? _image_alignment : 'tl';
|
|
1537
|
+
const algn = TILE_ALIGNMENTS.has(rawAlgn) ? rawAlgn : 'tl';
|
|
1538
|
+
if (image.alignment && !TILE_ALIGNMENTS.has(image.alignment)) {
|
|
1539
|
+
console.warn(`[pptxgenjs] unknown tile alignment "${String(image.alignment)}" - "tl" used instead`);
|
|
1540
|
+
}
|
|
1541
|
+
mode = `<a:tile tx="0" ty="0" sx="${scale}" sy="${scale}" flip="none" algn="${algn}"/>`;
|
|
1542
|
+
}
|
|
1543
|
+
return `<a:blipFill rotWithShape="${image.rotateWithShape === false ? '0' : '1'}"><a:blip r:embed="rId${rId}"/>${mode}</a:blipFill>`;
|
|
1544
|
+
}
|
|
1370
1545
|
/**
|
|
1371
1546
|
* Create color selection
|
|
1372
1547
|
* @param {Color | ShapeFillProps | ShapeLineProps} props fill props
|
|
@@ -1383,7 +1558,9 @@ function createGlowElement(glow) {
|
|
|
1383
1558
|
} else if (isModifiedThemeColor(props)) {
|
|
1384
1559
|
colorVal = props;
|
|
1385
1560
|
} else {
|
|
1561
|
+
var _props_image;
|
|
1386
1562
|
if (props.type) fillType = props.type;
|
|
1563
|
+
else if (((_props_image = props.image) === null || _props_image === void 0 ? void 0 : _props_image._rId) || props._rId) fillType = 'image';
|
|
1387
1564
|
if (props.color) colorVal = props.color;
|
|
1388
1565
|
if (props.alpha) internalElements += `<a:alpha val="${Math.round((100 - props.alpha) * 1000)}"/>`; // DEPRECATED: @deprecated v3.3.0
|
|
1389
1566
|
if (props.transparency) internalElements += `<a:alpha val="${Math.round((100 - props.transparency) * 1000)}"/>`;
|
|
@@ -1399,6 +1576,21 @@ function createGlowElement(glow) {
|
|
|
1399
1576
|
case 'pattern':
|
|
1400
1577
|
outText += createPatternFillElement(typeof props === 'string' || isModifiedThemeColor(props) ? undefined : props.pattern, typeof colorVal === 'string' ? colorVal : String(colorVal.baseColor));
|
|
1401
1578
|
break;
|
|
1579
|
+
case 'image':
|
|
1580
|
+
{
|
|
1581
|
+
var _ref;
|
|
1582
|
+
const image = typeof props === 'string' || isModifiedThemeColor(props) ? undefined : props.image;
|
|
1583
|
+
const rId = (_ref = image === null || image === void 0 ? void 0 : image._rId) !== null && _ref !== void 0 ? _ref : typeof props === 'string' || isModifiedThemeColor(props) ? undefined : props._rId;
|
|
1584
|
+
if (rId) {
|
|
1585
|
+
outText += createImageFillElement(image !== null && image !== void 0 ? image : {}, rId);
|
|
1586
|
+
} else {
|
|
1587
|
+
console.warn('[pptxgenjs] `fill.type:"image"` requires `fill.image.data` or `fill.image.path` - fill omitted');
|
|
1588
|
+
}
|
|
1589
|
+
break;
|
|
1590
|
+
}
|
|
1591
|
+
case 'group':
|
|
1592
|
+
outText += '<a:grpFill/>';
|
|
1593
|
+
break;
|
|
1402
1594
|
case 'none':
|
|
1403
1595
|
outText += '<a:noFill/>';
|
|
1404
1596
|
break;
|
|
@@ -1427,8 +1619,8 @@ function createGlowElement(glow) {
|
|
|
1427
1619
|
// Work on a copy - never mutate the caller's options object
|
|
1428
1620
|
ShadowProps = _object_spread({}, ShadowProps);
|
|
1429
1621
|
// 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`.');
|
|
1622
|
+
if (ShadowProps.type !== 'outer' && ShadowProps.type !== 'inner' && ShadowProps.type !== 'none' && ShadowProps.type !== 'preset') {
|
|
1623
|
+
console.warn('Warning: shadow.type options are `outer`, `inner`, `preset` or `none`.');
|
|
1432
1624
|
ShadowProps.type = 'outer';
|
|
1433
1625
|
}
|
|
1434
1626
|
// OPT: `angle`
|
|
@@ -2323,6 +2515,58 @@ function gen_tables_object_spread(target) {
|
|
|
2323
2515
|
});
|
|
2324
2516
|
}
|
|
2325
2517
|
|
|
2518
|
+
;// CONCATENATED MODULE: ./src/xml/hyperlink.ts
|
|
2519
|
+
/**
|
|
2520
|
+
* Hyperlinks and mouse-over actions.
|
|
2521
|
+
*
|
|
2522
|
+
* DrawingML gives the same concept two element names depending on where it appears:
|
|
2523
|
+
*
|
|
2524
|
+
* | host | click | mouse-over |
|
|
2525
|
+
* | :-- | :-- | :-- |
|
|
2526
|
+
* | `p:cNvPr` (shapes, pictures) | `a:hlinkClick` (20.1.2.2.22) | `a:hlinkHover` (20.1.2.2.23) |
|
|
2527
|
+
* | `a:rPr` (text runs) | `a:hlinkClick` | `a:hlinkMouseOver` (21.1.2.3.6) |
|
|
2528
|
+
*
|
|
2529
|
+
* Emitting `a:hlinkHover` inside `a:rPr` — or `a:hlinkMouseOver` inside `p:cNvPr` — produces markup
|
|
2530
|
+
* PowerPoint cannot parse, so the host decides the element name here rather than at each call site.
|
|
2531
|
+
*/
|
|
2532
|
+
/**
|
|
2533
|
+
* Build one `a:hlinkClick` / mouse-over element
|
|
2534
|
+
* @param {HyperlinkProps} link - link props
|
|
2535
|
+
* @param {'click' | 'hover'} trigger - which interaction this element describes
|
|
2536
|
+
* @param {HyperlinkHost} host - the element the link is attached to
|
|
2537
|
+
* @param {string} children - child elements (`a:snd`, `a:extLst`); self-closes when empty
|
|
2538
|
+
* @returns {string} XML string
|
|
2539
|
+
*/ function genXmlHyperlink(link, trigger, host, children = '') {
|
|
2540
|
+
var _link__rId;
|
|
2541
|
+
const tag = trigger === 'click' ? 'a:hlinkClick' : host === 'run' ? 'a:hlinkMouseOver' : 'a:hlinkHover';
|
|
2542
|
+
let attrs = `r:id="rId${(_link__rId = link._rId) !== null && _link__rId !== void 0 ? _link__rId : 0}"`;
|
|
2543
|
+
if (link.slide) {
|
|
2544
|
+
// an internal jump has no URL; the action attribute names the target kind
|
|
2545
|
+
attrs += ' action="ppaction://hlinksldjump"';
|
|
2546
|
+
} else {
|
|
2547
|
+
attrs += ' invalidUrl="" action="" tgtFrame=""';
|
|
2548
|
+
}
|
|
2549
|
+
attrs += ` tooltip="${link.tooltip ? encodeXmlEntities(link.tooltip) : ''}"`;
|
|
2550
|
+
if (!link.slide) attrs += ' history="1"';
|
|
2551
|
+
// both default to false in the schema, so only write them when turned on
|
|
2552
|
+
if (link.highlightClick === true) attrs += ' highlightClick="1"';
|
|
2553
|
+
if (link.stopSoundsOnClick === true) attrs += ' endSnd="1"';
|
|
2554
|
+
const sound = genXmlHyperlinkSound(link);
|
|
2555
|
+
const inner = sound + children;
|
|
2556
|
+
return inner ? `<${tag} ${attrs}>${inner}</${tag}>` : `<${tag} ${attrs}/>`;
|
|
2557
|
+
}
|
|
2558
|
+
/**
|
|
2559
|
+
* Build the `a:snd` action sound (ECMA-376 20.1.2.2.32 `CT_EmbeddedWAVAudioFile`)
|
|
2560
|
+
* - the relationship is resolved when the object is created, so `_sndRId` is set by then
|
|
2561
|
+
* @param {HyperlinkProps} link - link props
|
|
2562
|
+
* @returns {string} XML string
|
|
2563
|
+
*/ function genXmlHyperlinkSound(link) {
|
|
2564
|
+
var _link_sound_name;
|
|
2565
|
+
var _link_sound;
|
|
2566
|
+
if (!((_link_sound = link.sound) === null || _link_sound === void 0 ? void 0 : _link_sound._sndRId)) return '';
|
|
2567
|
+
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')}"/>`;
|
|
2568
|
+
}
|
|
2569
|
+
|
|
2326
2570
|
;// CONCATENATED MODULE: ./src/xml/text.ts
|
|
2327
2571
|
function text_define_property(obj, key, value) {
|
|
2328
2572
|
if (key in obj) {
|
|
@@ -2376,6 +2620,7 @@ function text_object_spread_props(target, source) {
|
|
|
2376
2620
|
/**
|
|
2377
2621
|
* Text-body, run, and placeholder rendering.
|
|
2378
2622
|
*/
|
|
2623
|
+
|
|
2379
2624
|
/** ECMA-376 §5.1.12.76 `ST_TextShapeType` — used to validate `a:prstTxWarp@prst`. */ const TEXT_SHAPE_TYPES = new Set([
|
|
2380
2625
|
'textNoShape',
|
|
2381
2626
|
'textPlain',
|
|
@@ -2420,6 +2665,25 @@ function text_object_spread_props(target, source) {
|
|
|
2420
2665
|
'textCascadeDown'
|
|
2421
2666
|
]);
|
|
2422
2667
|
|
|
2668
|
+
/**
|
|
2669
|
+
* Build the `a:buClr` / `a:buSzPct` / `a:buSzPts` / `a:buFont` prefix shared by every bullet kind
|
|
2670
|
+
* - the size defaults to 100% because that is what every branch emitted before
|
|
2671
|
+
*/ function genXmlBulletPrefix(bullet) {
|
|
2672
|
+
let xml = '';
|
|
2673
|
+
if (bullet.color) xml += `<a:buClr>${createColorElement(bullet.color)}</a:buClr>`;
|
|
2674
|
+
// `a:buSzPct` and `a:buSzPts` are the same choice, so only one may appear
|
|
2675
|
+
if (typeof bullet.sizePts === 'number' && isFinite(bullet.sizePts) && bullet.sizePts > 0) {
|
|
2676
|
+
xml += `<a:buSzPts val="${Math.round(bullet.sizePts * 100)}"/>`;
|
|
2677
|
+
} else {
|
|
2678
|
+
const pct = typeof bullet.size === 'number' && isFinite(bullet.size) ? Math.min(400, Math.max(25, bullet.size)) : 100;
|
|
2679
|
+
if (typeof bullet.size === 'number' && (bullet.size < 25 || bullet.size > 400)) {
|
|
2680
|
+
console.warn(`[pptxgenjs] bullet \`size\` must be between 25 and 400 percent - "${String(bullet.size)}" clamped`);
|
|
2681
|
+
}
|
|
2682
|
+
xml += `<a:buSzPct val="${Math.round(pct * 1000)}"/>`;
|
|
2683
|
+
}
|
|
2684
|
+
if (bullet.fontFace) xml += `<a:buFont typeface="${encodeXmlEntities(bullet.fontFace)}"/>`;
|
|
2685
|
+
return xml;
|
|
2686
|
+
}
|
|
2423
2687
|
/**
|
|
2424
2688
|
* Generate XML Paragraph Properties
|
|
2425
2689
|
* @param {ISlideObject|TextProps} textObj - text object
|
|
@@ -2428,7 +2692,6 @@ function text_object_spread_props(target, source) {
|
|
|
2428
2692
|
*/ function genXmlParagraphProperties(textObj, isDefault) {
|
|
2429
2693
|
var _textObj_options;
|
|
2430
2694
|
let strXmlBullet = '';
|
|
2431
|
-
let strXmlBulletColor = '';
|
|
2432
2695
|
let strXmlLnSpc = '';
|
|
2433
2696
|
let strXmlParaSpc = '';
|
|
2434
2697
|
let strXmlTabStops = '';
|
|
@@ -2480,10 +2743,17 @@ function text_object_spread_props(target, source) {
|
|
|
2480
2743
|
if (typeof options.bullet === 'object') {
|
|
2481
2744
|
var _options_bullet;
|
|
2482
2745
|
if ((_options_bullet = options.bullet) === null || _options_bullet === void 0 ? void 0 : _options_bullet.indent) bulletMarL = valToPts(options.bullet.indent);
|
|
2483
|
-
|
|
2746
|
+
const buPrefix = genXmlBulletPrefix(options.bullet);
|
|
2747
|
+
const buIndent = ` marL="${options.indentLevel && options.indentLevel > 0 ? bulletMarL + bulletMarL * options.indentLevel : bulletMarL}" indent="-${bulletMarL}"`;
|
|
2748
|
+
if (options.bullet.image && options.bullet._imageRId) {
|
|
2749
|
+
// `a:buBlip` replaces the character or number bullet entirely
|
|
2750
|
+
paragraphPropXml += buIndent;
|
|
2751
|
+
strXmlBullet = `${buPrefix}<a:buBlip><a:blip r:embed="rId${options.bullet._imageRId}"/></a:buBlip>`;
|
|
2752
|
+
} else if (options.bullet.type && options.bullet.type.toString().toLowerCase() === 'number') {
|
|
2484
2753
|
// 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
|
-
|
|
2754
|
+
paragraphPropXml += buIndent;
|
|
2755
|
+
// auto-numbered bullets fall back to the major latin face when none is given
|
|
2756
|
+
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
2757
|
} else if (options.bullet.characterCode) {
|
|
2488
2758
|
let bulletCode = `&#x${options.bullet.characterCode};`;
|
|
2489
2759
|
// Check value for hex-ness (s/b 4 char hex)
|
|
@@ -2491,8 +2761,8 @@ function text_object_spread_props(target, source) {
|
|
|
2491
2761
|
console.warn('Warning: `bullet.characterCode should be a 4-digit unicode charatcer (ex: 22AB)`!');
|
|
2492
2762
|
bulletCode = (/* inlined export .BULLET_TYPES.DEFAULT */"•");
|
|
2493
2763
|
}
|
|
2494
|
-
paragraphPropXml +=
|
|
2495
|
-
strXmlBullet =
|
|
2764
|
+
paragraphPropXml += buIndent;
|
|
2765
|
+
strXmlBullet = `${buPrefix}<a:buChar char="${bulletCode}"/>`;
|
|
2496
2766
|
} else if (options.bullet.code) {
|
|
2497
2767
|
// @deprecated `bullet.code` v3.3.0
|
|
2498
2768
|
let bulletCode = `&#x${options.bullet.code};`;
|
|
@@ -2501,15 +2771,11 @@ function text_object_spread_props(target, source) {
|
|
|
2501
2771
|
console.warn('Warning: `bullet.code should be a 4-digit hex code (ex: 22AB)`!');
|
|
2502
2772
|
bulletCode = (/* inlined export .BULLET_TYPES.DEFAULT */"•");
|
|
2503
2773
|
}
|
|
2504
|
-
paragraphPropXml +=
|
|
2505
|
-
strXmlBullet =
|
|
2774
|
+
paragraphPropXml += buIndent;
|
|
2775
|
+
strXmlBullet = `${buPrefix}<a:buChar char="${bulletCode}"/>`;
|
|
2506
2776
|
} 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>`;
|
|
2777
|
+
paragraphPropXml += buIndent;
|
|
2778
|
+
strXmlBullet = `${buPrefix}<a:buChar char="${(/* inlined export .BULLET_TYPES.DEFAULT */"•")}"/>`;
|
|
2513
2779
|
}
|
|
2514
2780
|
} else if (options.bullet) {
|
|
2515
2781
|
paragraphPropXml += ` marL="${options.indentLevel && options.indentLevel > 0 ? bulletMarL + bulletMarL * options.indentLevel : bulletMarL}" indent="-${bulletMarL}"`;
|
|
@@ -2526,7 +2792,7 @@ function text_object_spread_props(target, source) {
|
|
|
2526
2792
|
}
|
|
2527
2793
|
// B: Close Paragraph-Properties
|
|
2528
2794
|
// IMPORTANT: strXmlLnSpc, strXmlParaSpc, buClr, and strXmlBullet require strict ordering - anything out of order is ignored. (PPT-Online, PPT for Mac)
|
|
2529
|
-
paragraphPropXml += '>' + strXmlLnSpc + strXmlParaSpc +
|
|
2795
|
+
paragraphPropXml += '>' + strXmlLnSpc + strXmlParaSpc + strXmlBullet + strXmlTabStops;
|
|
2530
2796
|
if (isDefault) paragraphPropXml += genXmlTextRunProperties(options, true);
|
|
2531
2797
|
paragraphPropXml += '</' + tag + '>';
|
|
2532
2798
|
}
|
|
@@ -2538,7 +2804,7 @@ function text_object_spread_props(target, source) {
|
|
|
2538
2804
|
* @param {boolean} isDefault - whether these are the default text run properties
|
|
2539
2805
|
* @return {string} XML
|
|
2540
2806
|
*/ function genXmlTextRunProperties(opts, isDefault) {
|
|
2541
|
-
var _opts_underline;
|
|
2807
|
+
var _opts_underline, _opts_hyperlinkHover;
|
|
2542
2808
|
let runProps = '';
|
|
2543
2809
|
const runPropsTag = isDefault ? 'a:defRPr' : 'a:rPr';
|
|
2544
2810
|
// BEGIN runProperties (ex: `<a:rPr lang="en-US" sz="1600" b="1" dirty="0">`)
|
|
@@ -2570,6 +2836,7 @@ function text_object_spread_props(target, source) {
|
|
|
2570
2836
|
'small',
|
|
2571
2837
|
'all'
|
|
2572
2838
|
].includes(opts.caps) ? ` cap="${opts.caps}"` : '';
|
|
2839
|
+
if (opts.kumimoji === true) runProps += ' kumimoji="1"';
|
|
2573
2840
|
runProps += ' dirty="0">';
|
|
2574
2841
|
// Color / Font / Highlight / Outline are children of <a:rPr>, so add them now before closing the runProperties tag
|
|
2575
2842
|
if (opts.color || opts.gradient || opts.fontFace || opts.fontFaceEa || opts.fontFaceCs || opts.outline || typeof opts.underline === 'object' && opts.underline.color) {
|
|
@@ -2607,21 +2874,13 @@ function text_object_spread_props(target, source) {
|
|
|
2607
2874
|
if (opts.hyperlink) {
|
|
2608
2875
|
if (typeof opts.hyperlink !== 'object') throw new Error('ERROR: text `hyperlink` option should be an object. Ex: `hyperlink:{url:\'https://github.com\'}` ');
|
|
2609
2876
|
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
|
-
}
|
|
2877
|
+
// A colored link keeps its run color instead of the theme's hyperlink color (issue #74: an
|
|
2878
|
+
// `a:uFill` here breaks PPT2010, so the extension is used rather than an underline fill)
|
|
2879
|
+
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>' : '';
|
|
2880
|
+
runProps += genXmlHyperlink(opts.hyperlink, 'click', 'run', linkColorExt);
|
|
2624
2881
|
}
|
|
2882
|
+
// `a:hlinkMouseOver` follows `a:hlinkClick` in CT_TextCharacterProperties
|
|
2883
|
+
if ((_opts_hyperlinkHover = opts.hyperlinkHover) === null || _opts_hyperlinkHover === void 0 ? void 0 : _opts_hyperlinkHover._rId) runProps += genXmlHyperlink(opts.hyperlinkHover, 'hover', 'run');
|
|
2625
2884
|
// END runProperties
|
|
2626
2885
|
runProps += `</${runPropsTag}>`;
|
|
2627
2886
|
return runProps;
|
|
@@ -2660,6 +2919,15 @@ const P1710_NS = 'http://schemas.microsoft.com/office/powerpoint/2017/10/main';
|
|
|
2660
2919
|
}
|
|
2661
2920
|
return `<a14:m xmlns:a14="${A14_NS}">${trimmed}</a14:m>`;
|
|
2662
2921
|
}
|
|
2922
|
+
/**
|
|
2923
|
+
* A stable GUID for a field, derived from its type and cached value
|
|
2924
|
+
* - `a:fld@id` must be a GUID; deriving it keeps repeated exports byte-identical
|
|
2925
|
+
*/ function fieldGuid(type, cached) {
|
|
2926
|
+
let hash = 0;
|
|
2927
|
+
for (const char of `${type}:${cached}`)hash = hash * 31 + char.charCodeAt(0) >>> 0;
|
|
2928
|
+
const hex = hash.toString(16).padStart(8, '0');
|
|
2929
|
+
return `{${hex}-0000-0000-0000-${hex}0000}`;
|
|
2930
|
+
}
|
|
2663
2931
|
function textRunsHaveOmml(text) {
|
|
2664
2932
|
if (!Array.isArray(text)) return false;
|
|
2665
2933
|
return text.some((t)=>{
|
|
@@ -2669,7 +2937,7 @@ function textRunsHaveOmml(text) {
|
|
|
2669
2937
|
}
|
|
2670
2938
|
function genXmlTextRun(textObj) {
|
|
2671
2939
|
var _textObj_options;
|
|
2672
|
-
var _textObj_options1;
|
|
2940
|
+
var _textObj_options1, _textObj_options2;
|
|
2673
2941
|
// Native Office Math run — editable in PowerPoint (not an image).
|
|
2674
2942
|
const omml = (_textObj_options1 = textObj.options) === null || _textObj_options1 === void 0 ? void 0 : _textObj_options1.omml;
|
|
2675
2943
|
if (typeof omml === 'string' && omml.trim()) {
|
|
@@ -2700,7 +2968,18 @@ function genXmlTextRun(textObj) {
|
|
|
2700
2968
|
</a:r>
|
|
2701
2969
|
<a:endParaRPr lang="en-US" dirty="0"/>
|
|
2702
2970
|
</a:p>
|
|
2703
|
-
*/
|
|
2971
|
+
*/ /* A field is a run the consumer refreshes on open (ECMA-376 21.1.2.2.4). The `a:t` child holds
|
|
2972
|
+
* the cached value so a consumer that does not refresh still renders something. `id` must be a
|
|
2973
|
+
* 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;
|
|
2974
|
+
if (field) {
|
|
2975
|
+
if (!TEXT_FIELD_TYPES.has(field)) {
|
|
2976
|
+
console.warn(`[pptxgenjs] unknown text field "${String(field)}" - run emitted as plain text instead`);
|
|
2977
|
+
} else {
|
|
2978
|
+
var _textObj_text, _textObj_options3, _textObj_text1;
|
|
2979
|
+
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>';
|
|
2980
|
+
}
|
|
2981
|
+
}
|
|
2982
|
+
// Return paragraph with text run
|
|
2704
2983
|
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
2984
|
}
|
|
2706
2985
|
/**
|
|
@@ -2722,13 +3001,14 @@ function genXmlTextRun(textObj) {
|
|
|
2722
3001
|
if (slideObject.options._bodyProp.tIns || slideObject.options._bodyProp.tIns === 0) bodyProperties += ` tIns="${slideObject.options._bodyProp.tIns}"`;
|
|
2723
3002
|
if (slideObject.options._bodyProp.rIns || slideObject.options._bodyProp.rIns === 0) bodyProperties += ` rIns="${slideObject.options._bodyProp.rIns}"`;
|
|
2724
3003
|
if (slideObject.options._bodyProp.bIns || slideObject.options._bodyProp.bIns === 0) bodyProperties += ` bIns="${slideObject.options._bodyProp.bIns}"`;
|
|
2725
|
-
// C: Add rtl after margins
|
|
2726
|
-
bodyProperties += ' rtlCol="0"';
|
|
2727
3004
|
// Text columns — ECMA-376 §5.1.5.1.4 CT_TextBodyProperties@numCol/@spcCol (issue #1320)
|
|
2728
3005
|
if (slideObject.options._bodyProp.numCol && slideObject.options._bodyProp.numCol > 1) {
|
|
2729
3006
|
bodyProperties += ` numCol="${slideObject.options._bodyProp.numCol}"`;
|
|
2730
3007
|
if (slideObject.options._bodyProp.spcCol) bodyProperties += ` spcCol="${slideObject.options._bodyProp.spcCol}"`;
|
|
2731
3008
|
}
|
|
3009
|
+
// `rtlCol` follows the text box's RTL mode unless overridden, so RTL columns flow correctly
|
|
3010
|
+
const rtlCols = typeof slideObject.options.rtlColumns === 'boolean' ? slideObject.options.rtlColumns : slideObject.options.rtlMode === true;
|
|
3011
|
+
bodyProperties += ` rtlCol="${rtlCols ? '1' : '0'}"`;
|
|
2732
3012
|
// D: Add anchorPoints
|
|
2733
3013
|
if (slideObject.options._bodyProp.anchor) bodyProperties += ' anchor="' + slideObject.options._bodyProp.anchor + '"'; // VALS: [t,ctr,b]
|
|
2734
3014
|
if (slideObject.options._bodyProp.vert) bodyProperties += ' vert="' + slideObject.options._bodyProp.vert + '"'; // VALS: [eaVert,horz,mongolianVert,vert,vert270,wordArtVert,wordArtVertRtl]
|
|
@@ -2764,7 +3044,9 @@ function genXmlTextRun(textObj) {
|
|
|
2764
3044
|
bodyProperties += '</a:bodyPr>';
|
|
2765
3045
|
} else {
|
|
2766
3046
|
// DEFAULT:
|
|
2767
|
-
|
|
3047
|
+
const opts = slideObject.options;
|
|
3048
|
+
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;
|
|
3049
|
+
bodyProperties += ` wrap="square" rtlCol="${rtlCols ? '1' : '0'}">`;
|
|
2768
3050
|
bodyProperties += '</a:bodyPr>';
|
|
2769
3051
|
}
|
|
2770
3052
|
// LAST: Return Close _bodyProp
|
|
@@ -2851,6 +3133,8 @@ function genXmlTextRun(textObj) {
|
|
|
2851
3133
|
delete runOpts.softEdge;
|
|
2852
3134
|
delete runOpts.reflection;
|
|
2853
3135
|
delete runOpts.shadow;
|
|
3136
|
+
delete runOpts.fillOverlay;
|
|
3137
|
+
delete runOpts.effectDag;
|
|
2854
3138
|
itext.options = runOpts;
|
|
2855
3139
|
}
|
|
2856
3140
|
if (idx === 0 && itext.options && !itext.options.bullet && opts.bullet) itext.options.bullet = opts.bullet;
|
|
@@ -2966,7 +3250,7 @@ function genXmlTextRun(textObj) {
|
|
|
2966
3250
|
// NOTE: This loop will pick up unecessary keys (`x`, etc.), but it doesnt hurt anything
|
|
2967
3251
|
// `glow` / softEdge / reflection belong on the shape effectLst (not per-run), unless set on the run itself
|
|
2968
3252
|
// `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;
|
|
3253
|
+
if (key === 'glow' || key === 'softEdge' || key === 'reflection' || key === 'shadow' || key === 'blur' || key === 'fillOverlay' || key === 'effectDag' || key === 'omml') return;
|
|
2970
3254
|
if (key !== 'bullet' && !textOpts[key]) textOpts[key] = val;
|
|
2971
3255
|
});
|
|
2972
3256
|
// D: Add formatted textrun
|
|
@@ -3089,12 +3373,15 @@ const NS_P232 = 'http://schemas.microsoft.com/office/powerpoint/2023/02/main';
|
|
|
3089
3373
|
* @returns XML
|
|
3090
3374
|
*/ function genXmlPlaceholder(placeholderObj, extraOpts) {
|
|
3091
3375
|
var _ref;
|
|
3092
|
-
var _placeholderObj_options, _placeholderObj_options1, _placeholderObj_options2;
|
|
3376
|
+
var _placeholderObj_options, _placeholderObj_options1, _placeholderObj_options2, _placeholderObj_options3, _placeholderObj_options4, _placeholderObj_options5;
|
|
3093
3377
|
if (!placeholderObj) return '';
|
|
3094
3378
|
const placeholderIdx = ((_placeholderObj_options = placeholderObj.options) === null || _placeholderObj_options === void 0 ? void 0 : _placeholderObj_options._placeholderIdx) ? placeholderObj.options._placeholderIdx : '';
|
|
3095
3379
|
const placeholderType = resolvePlaceholderType((_placeholderObj_options1 = placeholderObj.options) === null || _placeholderObj_options1 === void 0 ? void 0 : _placeholderObj_options1._placeholderType);
|
|
3096
|
-
|
|
3097
|
-
const
|
|
3380
|
+
// `orient` and `sz` default to horz/full in the schema, so only a non-default is written
|
|
3381
|
+
const placeholderOrient = ((_placeholderObj_options2 = placeholderObj.options) === null || _placeholderObj_options2 === void 0 ? void 0 : _placeholderObj_options2.orient) === 'vert' ? ' orient="vert"' : '';
|
|
3382
|
+
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}"` : '';
|
|
3383
|
+
const attrs = `${placeholderIdx ? ' idx="' + placeholderIdx.toString() + '"' : ''}` + `${placeholderType ? ` type="${placeholderType}"` : ''}` + placeholderOrient + placeholderSize + `${placeholderObj.text && placeholderObj.text.length > 0 ? ' hasCustomPrompt="1"' : ''}`;
|
|
3384
|
+
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
3385
|
if (phTypeExt === 'cameo' || phTypeExt === 'unknown') {
|
|
3099
3386
|
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
3387
|
}
|
|
@@ -3440,6 +3727,10 @@ function _object_without_properties_loose(source, excluded) {
|
|
|
3440
3727
|
let tmpOpt;
|
|
3441
3728
|
let tmpData = [];
|
|
3442
3729
|
if (Array.isArray(type)) {
|
|
3730
|
+
// A chartex layout owns the whole `cx:plotArea` and cannot share one with an ECMA-376 chart type,
|
|
3731
|
+
// so a multi-type spec that names one would silently render as an empty frame
|
|
3732
|
+
const chartexSpec = type.find((obj)=>isChartexType(obj.type));
|
|
3733
|
+
if (chartexSpec) throw new Error(`pptxgenjs: chart type "${String(chartexSpec.type)}" cannot be combined in a multi-type chart`);
|
|
3443
3734
|
// For multi-type charts there needs to be data for each type,
|
|
3444
3735
|
// as well as a single data source for non-series operations.
|
|
3445
3736
|
// The data is indexed below to keep the data in order when segmented
|
|
@@ -3527,8 +3818,21 @@ function _object_without_properties_loose(source, excluded) {
|
|
|
3527
3818
|
// NOTE: a multi-type chart has no single type to validate against, so only the name translation applies there
|
|
3528
3819
|
if (options.dataLabelPosition) {
|
|
3529
3820
|
const chartType = Array.isArray(options._type) ? undefined : options._type;
|
|
3530
|
-
|
|
3531
|
-
|
|
3821
|
+
if (isChartexType(chartType)) {
|
|
3822
|
+
// `cx:dataLabels@pos` is its own vocabulary, not `c:dLblPos`; these three are the values the
|
|
3823
|
+
// shipped chartex writers emit, so anything else falls back to the layout's own default
|
|
3824
|
+
if (![
|
|
3825
|
+
'ctr',
|
|
3826
|
+
'inEnd',
|
|
3827
|
+
'outEnd'
|
|
3828
|
+
].includes(options.dataLabelPosition)) {
|
|
3829
|
+
console.warn(`[pptxgenjs] dataLabelPosition '${options.dataLabelPosition}' is not valid for a '${chartType}' chart - ignoring it (valid: ctr, inEnd, outEnd)`);
|
|
3830
|
+
delete options.dataLabelPosition;
|
|
3831
|
+
}
|
|
3832
|
+
} else {
|
|
3833
|
+
options.dataLabelPosition = resolveDataLabelPosition(options.dataLabelPosition, chartType, options.barGrouping);
|
|
3834
|
+
if (!options.dataLabelPosition) delete options.dataLabelPosition;
|
|
3835
|
+
}
|
|
3532
3836
|
}
|
|
3533
3837
|
options.dataLabelBkgrdColors = options.dataLabelBkgrdColors || !options.dataLabelBkgrdColors ? options.dataLabelBkgrdColors : false;
|
|
3534
3838
|
if (![
|
|
@@ -3700,6 +4004,59 @@ function _object_without_properties_loose(source, excluded) {
|
|
|
3700
4004
|
} else {
|
|
3701
4005
|
delete options.catAxisMultiLevelLabels;
|
|
3702
4006
|
}
|
|
4007
|
+
// ChartEx: reject values PowerPoint would reject, so a bad option degrades to the layout default
|
|
4008
|
+
// rather than to the repair dialog
|
|
4009
|
+
if (isChartexType(options._type)) {
|
|
4010
|
+
// Only box & whisker plots more than one distribution; the other layouts own the whole plot area
|
|
4011
|
+
// and a second `cx:series` is either dropped or flagged for repair
|
|
4012
|
+
if (options._type !== core_enums_CHART_TYPE.BOX_WHISKER && tmpData.length > 1) {
|
|
4013
|
+
console.warn(`Warning: a ${options._type} chart plots one series - ignoring ${tmpData.length - 1} extra series.`);
|
|
4014
|
+
tmpData = tmpData.slice(0, 1);
|
|
4015
|
+
}
|
|
4016
|
+
tmpData.forEach((item)=>{
|
|
4017
|
+
var _item_values;
|
|
4018
|
+
var _item_labels;
|
|
4019
|
+
// ChartEx cell references assume one label column; the multi-level worksheet layout shifts the
|
|
4020
|
+
// series columns right, so the extra levels are dropped rather than silently misaddressed
|
|
4021
|
+
if (item.labels && item.labels.length > 1) {
|
|
4022
|
+
console.warn('Warning: chartex charts take single-level category labels - using the first level.');
|
|
4023
|
+
item.labels = [
|
|
4024
|
+
item.labels[0]
|
|
4025
|
+
];
|
|
4026
|
+
}
|
|
4027
|
+
// A histogram bins raw values and needs no categories, but the embedded worksheet still writes a
|
|
4028
|
+
// row per label, so a label-less series is padded rather than left to fail during write()
|
|
4029
|
+
const labels = (_item_labels = item.labels) === null || _item_labels === void 0 ? void 0 : _item_labels[0];
|
|
4030
|
+
if (!labels || labels.length === 0) item.labels = [
|
|
4031
|
+
Array(((_item_values = item.values) !== null && _item_values !== void 0 ? _item_values : []).length).fill('')
|
|
4032
|
+
];
|
|
4033
|
+
});
|
|
4034
|
+
const pointCount = Math.max(...tmpData.map((item)=>{
|
|
4035
|
+
var _item_values;
|
|
4036
|
+
return ((_item_values = item.values) !== null && _item_values !== void 0 ? _item_values : []).length;
|
|
4037
|
+
}), 0);
|
|
4038
|
+
if (options.chartExSubtotals) {
|
|
4039
|
+
const valid = options.chartExSubtotals.filter((idx)=>Number.isInteger(idx) && idx >= 0 && idx < pointCount);
|
|
4040
|
+
if (valid.length !== options.chartExSubtotals.length) console.warn(`Warning: chart.chartExSubtotals must be data point indexes 0-${pointCount - 1}.`);
|
|
4041
|
+
options.chartExSubtotals = valid;
|
|
4042
|
+
}
|
|
4043
|
+
if (options.chartExBinCount !== undefined && (!Number.isInteger(options.chartExBinCount) || options.chartExBinCount < 1)) {
|
|
4044
|
+
console.warn('Warning: chart.chartExBinCount must be a positive integer.');
|
|
4045
|
+
delete options.chartExBinCount;
|
|
4046
|
+
}
|
|
4047
|
+
if (options.chartExBinSize !== undefined && (isNaN(options.chartExBinSize) || options.chartExBinSize <= 0)) {
|
|
4048
|
+
console.warn('Warning: chart.chartExBinSize must be greater than 0.');
|
|
4049
|
+
delete options.chartExBinSize;
|
|
4050
|
+
}
|
|
4051
|
+
if (options.chartExParentLabels && ![
|
|
4052
|
+
'none',
|
|
4053
|
+
'overlapping',
|
|
4054
|
+
'banner'
|
|
4055
|
+
].includes(options.chartExParentLabels)) {
|
|
4056
|
+
console.warn('Warning: chart.chartExParentLabels options: `none`, `overlapping`, `banner`.');
|
|
4057
|
+
delete options.chartExParentLabels;
|
|
4058
|
+
}
|
|
4059
|
+
}
|
|
3703
4060
|
// STEP 4: Set props (_type already set to chart on the literal above).
|
|
3704
4061
|
// The chart object stores the position/placeholder that gen-xml reads; chart `fill`
|
|
3705
4062
|
// is a color string (vs ObjectOptions' ShapeFillProps) and is never read here, so it
|
|
@@ -3713,14 +4070,17 @@ function _object_without_properties_loose(source, excluded) {
|
|
|
3713
4070
|
});
|
|
3714
4071
|
resultObject.chartRid = getNewRelId(target);
|
|
3715
4072
|
// STEP 5: Add this chart to this Slide Rels (rId/rels count spans all slides! Count all images to get next rId)
|
|
4073
|
+
// ChartEx charts are a separate part type with their own content type and relationship type,
|
|
4074
|
+
// so the file name is what every downstream emitter keys off (see `xml/package.ts`)
|
|
4075
|
+
const fileName = isChartexType(options._type) ? `chartEx${chartId}.xml` : `chart${chartId}.xml`;
|
|
3716
4076
|
target._relsChart.push({
|
|
3717
4077
|
rId: getNewRelId(target),
|
|
3718
4078
|
data: tmpData,
|
|
3719
4079
|
opts: options,
|
|
3720
4080
|
type: options._type,
|
|
3721
4081
|
globalId: chartId,
|
|
3722
|
-
fileName
|
|
3723
|
-
Target: `/ppt/charts
|
|
4082
|
+
fileName,
|
|
4083
|
+
Target: `/ppt/charts/${fileName}`
|
|
3724
4084
|
});
|
|
3725
4085
|
target._slideObjects.push(resultObject);
|
|
3726
4086
|
return resultObject;
|
|
@@ -3806,8 +4166,45 @@ function isSvgFillSource(data, path) {
|
|
|
3806
4166
|
});
|
|
3807
4167
|
return rId;
|
|
3808
4168
|
}
|
|
4169
|
+
function isStructuredImageFill(fill) {
|
|
4170
|
+
return !!fill && (fill.type === 'image' || !!fill.image);
|
|
4171
|
+
}
|
|
4172
|
+
/**
|
|
4173
|
+
* Resolve a picture fill's image into a slide relationship.
|
|
4174
|
+
* `genXmlColorSelection` is pure, so the rId has to be attached before XML is generated.
|
|
4175
|
+
*/ function resolveImageFill(target, fill) {
|
|
4176
|
+
var _ref, _ref1, _ref2, _ref3;
|
|
4177
|
+
var _fill_image, _fill_image1;
|
|
4178
|
+
if (!fill || typeof fill !== 'object') return;
|
|
4179
|
+
if (!isStructuredImageFill(fill) && !(fill.data || fill.path)) return;
|
|
4180
|
+
if (!isStructuredImageFill(fill) && (fill.color || fill.type && fill.type !== 'image')) return;
|
|
4181
|
+
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 : '';
|
|
4182
|
+
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 : '';
|
|
4183
|
+
if (!data && !path) {
|
|
4184
|
+
console.warn('[pptxgenjs] `fill.type:"image"` requires `fill.image.data` or `fill.image.path` - fill ignored');
|
|
4185
|
+
return;
|
|
4186
|
+
}
|
|
4187
|
+
if (data && !data.toLowerCase().includes('base64,')) {
|
|
4188
|
+
console.warn('[pptxgenjs] `fill.image.data` lacks a base64 header (ex: \'image/png;base64,iV[...]\') - fill ignored');
|
|
4189
|
+
return;
|
|
4190
|
+
}
|
|
4191
|
+
const rId = registerTableCellImageFill(target, {
|
|
4192
|
+
data,
|
|
4193
|
+
path
|
|
4194
|
+
});
|
|
4195
|
+
if (!rId) return;
|
|
4196
|
+
if (fill.image) fill.image._rId = rId;
|
|
4197
|
+
else fill._rId = rId;
|
|
4198
|
+
}
|
|
4199
|
+
function resolveObjectImageFills(target, options) {
|
|
4200
|
+
var _options_fillOverlay;
|
|
4201
|
+
if (!options) return;
|
|
4202
|
+
if (options.fill) resolveImageFill(target, options.fill);
|
|
4203
|
+
if ((_options_fillOverlay = options.fillOverlay) === null || _options_fillOverlay === void 0 ? void 0 : _options_fillOverlay.fill) resolveImageFill(target, options.fillOverlay.fill);
|
|
4204
|
+
}
|
|
3809
4205
|
function addImageDefinition(target, opt) {
|
|
3810
|
-
var _strImagePath_substring_split__split_pop;
|
|
4206
|
+
var _opt_fillOverlay, _strImagePath_substring_split__split_pop;
|
|
4207
|
+
if ((_opt_fillOverlay = opt.fillOverlay) === null || _opt_fillOverlay === void 0 ? void 0 : _opt_fillOverlay.fill) resolveImageFill(target, opt.fillOverlay.fill);
|
|
3811
4208
|
const newObject = {
|
|
3812
4209
|
_type: (/* inlined export .SLIDE_OBJECT_TYPES.image */"image"),
|
|
3813
4210
|
text: undefined,
|
|
@@ -3877,7 +4274,16 @@ function addImageDefinition(target, opt) {
|
|
|
3877
4274
|
softEdge: opt.softEdge,
|
|
3878
4275
|
reflection: opt.reflection,
|
|
3879
4276
|
blur: opt.blur,
|
|
4277
|
+
fillOverlay: opt.fillOverlay,
|
|
4278
|
+
effectDag: opt.effectDag,
|
|
4279
|
+
alphaEffects: opt.alphaEffects,
|
|
4280
|
+
recolor: opt.recolor,
|
|
4281
|
+
styleRef: opt.styleRef,
|
|
3880
4282
|
line: opt.line || imageBorderToLine(opt.border),
|
|
4283
|
+
// non-visual props and locks are part of the object's identity, not its geometry
|
|
4284
|
+
title: opt.title,
|
|
4285
|
+
hidden: opt.hidden,
|
|
4286
|
+
lock: opt.lock,
|
|
3881
4287
|
_sizeFromImage: !intWidth && !intHeight,
|
|
3882
4288
|
// addImage always writes x/y/w/h defaults, so remember which axes the caller actually set
|
|
3883
4289
|
// (placeholder geometry must not overwrite explicit placement; fujita-h d7e3e93 / #996).
|
|
@@ -3957,8 +4363,14 @@ function addImageDefinition(target, opt) {
|
|
|
3957
4363
|
});
|
|
3958
4364
|
objHyperlink._rId = imageRelId;
|
|
3959
4365
|
newObject.hyperlink = objHyperlink;
|
|
4366
|
+
// the action sound (if any) needs its own relationship
|
|
4367
|
+
resolveHyperlinkRels(target, objHyperlink);
|
|
3960
4368
|
}
|
|
3961
4369
|
}
|
|
4370
|
+
if (typeof opt.hyperlinkHover === 'object') {
|
|
4371
|
+
resolveHyperlinkRels(target, opt.hyperlinkHover);
|
|
4372
|
+
newObject.hyperlinkHover = opt.hyperlinkHover;
|
|
4373
|
+
}
|
|
3962
4374
|
// STEP 6: Add object to slide
|
|
3963
4375
|
target._slideObjects.push(newObject);
|
|
3964
4376
|
}
|
|
@@ -3981,12 +4393,25 @@ function addImageDefinition(target, opt) {
|
|
|
3981
4393
|
const slideData = {
|
|
3982
4394
|
_type: (/* inlined export .SLIDE_OBJECT_TYPES.media */"media")
|
|
3983
4395
|
};
|
|
3984
|
-
//
|
|
3985
|
-
|
|
4396
|
+
// `link` with no `path`/`data` used to throw, so treating it as "reference, do not embed" cannot
|
|
4397
|
+
// change any deck that works today
|
|
4398
|
+
const isLinked = !!strLink && !strPath && !strData && (strType === 'audio' || strType === 'video');
|
|
4399
|
+
if (strLink && (strPath || strData) && strType !== 'online') {
|
|
4400
|
+
console.warn('[pptxgenjs] addMedia: `link` is ignored when `path` or `data` is given - the media is embedded');
|
|
4401
|
+
}
|
|
4402
|
+
// STEP 1: REALITY-CHECK - what each media kind needs, rather than one chain of conditions
|
|
4403
|
+
if (strType === 'audioCd') {
|
|
4404
|
+
var _opt_audioCd_start, _opt_audioCd, _opt_audioCd_end, _opt_audioCd1;
|
|
4405
|
+
// `a:st`/`a:end` and their `@track` are all required by CT_AudioCD
|
|
4406
|
+
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') {
|
|
4407
|
+
throw new Error('addMedia() error: `type:"audioCd"` requires `audioCd.start.track` and `audioCd.end.track`');
|
|
4408
|
+
}
|
|
4409
|
+
} else if (!strPath && !strData && strType !== 'online' && !isLinked) {
|
|
3986
4410
|
throw new Error('addMedia() error: either `data` or `path` are required!');
|
|
3987
4411
|
} else if (strData && !strData.toLowerCase().includes('base64,')) {
|
|
3988
4412
|
throw new Error('addMedia() error: `data` value lacks a base64 header! Ex: \'video/mpeg;base64,NMP[...]\')');
|
|
3989
|
-
}
|
|
4413
|
+
}
|
|
4414
|
+
if (strCover && !strCover.toLowerCase().includes('base64,')) {
|
|
3990
4415
|
throw new Error('addMedia() error: `cover` value lacks a base64 header! Ex: \'data:image/png;base64,iV[...]\')');
|
|
3991
4416
|
}
|
|
3992
4417
|
// Online Video: requires `link`
|
|
@@ -3995,7 +4420,7 @@ function addImageDefinition(target, opt) {
|
|
|
3995
4420
|
}
|
|
3996
4421
|
// Timing-tree playback (ECMA-376 §19.5 CT_TLMediaNode): no silent fallbacks.
|
|
3997
4422
|
// `fullScrn` exists only on CT_TLMediaNodeVideo; linked `online` media has no embedded media node.
|
|
3998
|
-
if (strType
|
|
4423
|
+
if (opt.fullScreen && strType !== 'video') {
|
|
3999
4424
|
throw new Error('addMedia() error: `fullScreen` is only valid on type "video"');
|
|
4000
4425
|
}
|
|
4001
4426
|
if (strType === 'online' && (opt.autoplay || opt.loop || opt.fullScreen || opt.mute)) {
|
|
@@ -4003,7 +4428,7 @@ function addImageDefinition(target, opt) {
|
|
|
4003
4428
|
}
|
|
4004
4429
|
// FIXME: 20190707
|
|
4005
4430
|
// strType = strData ? strData.split(';')[0].split('/')[0] : strType
|
|
4006
|
-
strExtn = opt.extn || (strData ? strData.split(';')[0].split('/')[1] : strPath.split('.').pop()) || 'mp3';
|
|
4431
|
+
strExtn = opt.extn || (strType === 'wav' ? 'wav' : strData ? strData.split(';')[0].split('/')[1] : (strPath || strLink).split('.').pop()) || 'mp3';
|
|
4007
4432
|
// STEP 2: Set type, media
|
|
4008
4433
|
slideData.mtype = strType;
|
|
4009
4434
|
slideData.media = strPath || 'preencoded.mov';
|
|
@@ -4030,6 +4455,11 @@ function addImageDefinition(target, opt) {
|
|
|
4030
4455
|
slideData.options.loop = opt.loop;
|
|
4031
4456
|
slideData.options.fullScreen = opt.fullScreen;
|
|
4032
4457
|
slideData.options.mute = opt.mute;
|
|
4458
|
+
slideData.options.contentType = opt.contentType;
|
|
4459
|
+
slideData.options.audioCd = opt.audioCd;
|
|
4460
|
+
slideData.options.isPhoto = opt.isPhoto;
|
|
4461
|
+
slideData.options.userDrawn = opt.userDrawn;
|
|
4462
|
+
slideData.options.isLinked = isLinked;
|
|
4033
4463
|
// STEP 4: Add this media to this Slide Rels (rId/rels count spans all slides! Count all media to get next rId)
|
|
4034
4464
|
/**
|
|
4035
4465
|
* NOTE:
|
|
@@ -4039,7 +4469,41 @@ function addImageDefinition(target, opt) {
|
|
|
4039
4469
|
* - Audio/Video files consume *TWO* rId's:
|
|
4040
4470
|
* <Relationship Id="rId2" Target="../media/media1.mov" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/video"/>
|
|
4041
4471
|
* <Relationship Id="rId3" Target="../media/media1.mov" Type="http://schemas.microsoft.com/office/2007/relationships/media"/>
|
|
4042
|
-
*/ if (strType === '
|
|
4472
|
+
*/ if (strType === 'audioCd') {
|
|
4473
|
+
// CD audio references the listener's drive: no media part, no media relationship, cover only
|
|
4474
|
+
const coverRid = getNewRelId(target);
|
|
4475
|
+
target._relsMedia.push({
|
|
4476
|
+
path: 'preencoded.png',
|
|
4477
|
+
type: 'image/png',
|
|
4478
|
+
extn: 'png',
|
|
4479
|
+
data: strCover,
|
|
4480
|
+
rId: coverRid,
|
|
4481
|
+
Target: `../media/${imageTargetStem(target)}.png`
|
|
4482
|
+
});
|
|
4483
|
+
slideData._coverRid = coverRid;
|
|
4484
|
+
} else if (strType === 'wav') {
|
|
4485
|
+
// `a:wavAudioFile` is the legacy embedded-WAV element: one audio relationship, no `p14:media`
|
|
4486
|
+
const relId1 = getNewRelId(target);
|
|
4487
|
+
target._relsMedia.push({
|
|
4488
|
+
path: strPath || 'preencoded.wav',
|
|
4489
|
+
type: 'audio/wav',
|
|
4490
|
+
extn: 'wav',
|
|
4491
|
+
data: strData || '',
|
|
4492
|
+
rId: relId1,
|
|
4493
|
+
Target: `../media/media-${target._slideNum}-${target._relsMedia.length + 1}.wav`
|
|
4494
|
+
});
|
|
4495
|
+
slideData.mediaRid = relId1;
|
|
4496
|
+
const coverRid = getNewRelId(target);
|
|
4497
|
+
target._relsMedia.push({
|
|
4498
|
+
path: 'preencoded.png',
|
|
4499
|
+
type: 'image/png',
|
|
4500
|
+
extn: 'png',
|
|
4501
|
+
data: strCover,
|
|
4502
|
+
rId: coverRid,
|
|
4503
|
+
Target: `../media/${imageTargetStem(target)}.png`
|
|
4504
|
+
});
|
|
4505
|
+
slideData._coverRid = coverRid;
|
|
4506
|
+
} else if (strType === 'online') {
|
|
4043
4507
|
const relId1 = getNewRelId(target);
|
|
4044
4508
|
// A: Add video
|
|
4045
4509
|
target._relsMedia.push({
|
|
@@ -4064,6 +4528,8 @@ function addImageDefinition(target, opt) {
|
|
|
4064
4528
|
// PERF: Duplicate media should reuse existing `Target` value and not create an additional copy
|
|
4065
4529
|
const dupeItem = target._relsMedia.filter((item)=>item.path && item.path === strPath && item.type === strType + '/' + strExtn && !item.isDuplicate)[0];
|
|
4066
4530
|
// A: "relationships/video"
|
|
4531
|
+
// Linked media keeps this exact three-relationship shape - the rIds the emitter derives from
|
|
4532
|
+
// `mediaRid` stay valid - and only points the targets outside the package
|
|
4067
4533
|
const relId1 = getNewRelId(target);
|
|
4068
4534
|
target._relsMedia.push({
|
|
4069
4535
|
path: strPath || 'preencoded' + strExtn,
|
|
@@ -4072,7 +4538,8 @@ function addImageDefinition(target, opt) {
|
|
|
4072
4538
|
data: strData || '',
|
|
4073
4539
|
rId: relId1,
|
|
4074
4540
|
isDuplicate: !!(dupeItem === null || dupeItem === void 0 ? void 0 : dupeItem.Target),
|
|
4075
|
-
|
|
4541
|
+
isLinked,
|
|
4542
|
+
Target: isLinked ? strLink : (dupeItem === null || dupeItem === void 0 ? void 0 : dupeItem.Target) ? dupeItem.Target : `../media/media-${target._slideNum}-${target._relsMedia.length + 1}.${strExtn}`
|
|
4076
4543
|
});
|
|
4077
4544
|
slideData.mediaRid = relId1;
|
|
4078
4545
|
// B: "relationships/media"
|
|
@@ -4083,7 +4550,8 @@ function addImageDefinition(target, opt) {
|
|
|
4083
4550
|
data: strData || '',
|
|
4084
4551
|
rId: getNewRelId(target),
|
|
4085
4552
|
isDuplicate: !!(dupeItem === null || dupeItem === void 0 ? void 0 : dupeItem.Target),
|
|
4086
|
-
|
|
4553
|
+
isLinked,
|
|
4554
|
+
Target: isLinked ? strLink : (dupeItem === null || dupeItem === void 0 ? void 0 : dupeItem.Target) ? dupeItem.Target : `../media/media-${target._slideNum}-${target._relsMedia.length + 0}.${strExtn}`
|
|
4087
4555
|
});
|
|
4088
4556
|
// C: Add cover (preview/overlay) image
|
|
4089
4557
|
target._relsMedia.push({
|
|
@@ -4319,11 +4787,107 @@ function nextExtPartName(target, prefix, extn) {
|
|
|
4319
4787
|
opts.line.endArrowType = opts.lineTail;
|
|
4320
4788
|
}
|
|
4321
4789
|
}
|
|
4790
|
+
/**
|
|
4791
|
+
* Create the relationships a hyperlink needs: the link target, and its action sound when set
|
|
4792
|
+
* - `genXmlHyperlink` is pure, so both ids have to exist before the XML is generated
|
|
4793
|
+
*/ function resolveHyperlinkRels(target, link) {
|
|
4794
|
+
if (!link || typeof link !== 'object') return;
|
|
4795
|
+
if (!link._rId) {
|
|
4796
|
+
var _link_url;
|
|
4797
|
+
var _link_slide;
|
|
4798
|
+
if (!link.url && !link.slide) {
|
|
4799
|
+
console.warn('[pptxgenjs] a hyperlink requires either `url` or `slide` - link ignored');
|
|
4800
|
+
return;
|
|
4801
|
+
}
|
|
4802
|
+
const relId = getNewRelId(target);
|
|
4803
|
+
target._rels.push({
|
|
4804
|
+
type: (/* inlined export .SLIDE_OBJECT_TYPES.hyperlink */"hyperlink"),
|
|
4805
|
+
data: link.slide ? 'slide' : 'dummy',
|
|
4806
|
+
rId: relId,
|
|
4807
|
+
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()) || ''
|
|
4808
|
+
});
|
|
4809
|
+
link._rId = relId;
|
|
4810
|
+
} else if (target._rels.filter((rel)=>rel.rId === link._rId).length === 0) {
|
|
4811
|
+
var _link_url1;
|
|
4812
|
+
var _link_slide1;
|
|
4813
|
+
target._rels.push({
|
|
4814
|
+
type: (/* inlined export .SLIDE_OBJECT_TYPES.hyperlink */"hyperlink"),
|
|
4815
|
+
data: link.slide ? 'slide' : 'dummy',
|
|
4816
|
+
rId: link._rId,
|
|
4817
|
+
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()) || ''
|
|
4818
|
+
});
|
|
4819
|
+
}
|
|
4820
|
+
// ECMA-376 20.1.2.2.32 allows only WAV here, so anything else is dropped rather than linked
|
|
4821
|
+
const sound = link.sound;
|
|
4822
|
+
if (!sound) return;
|
|
4823
|
+
if (!sound._sndRId) {
|
|
4824
|
+
var _sound_data, _sound_path;
|
|
4825
|
+
const data = (_sound_data = sound.data) !== null && _sound_data !== void 0 ? _sound_data : '';
|
|
4826
|
+
const path = (_sound_path = sound.path) !== null && _sound_path !== void 0 ? _sound_path : '';
|
|
4827
|
+
if (!data && !path) {
|
|
4828
|
+
console.warn('[pptxgenjs] hyperlink `sound` requires `data` or `path` - sound ignored');
|
|
4829
|
+
link.sound = undefined;
|
|
4830
|
+
return;
|
|
4831
|
+
}
|
|
4832
|
+
if (data && !data.toLowerCase().includes('base64,')) {
|
|
4833
|
+
console.warn('[pptxgenjs] hyperlink `sound.data` lacks a base64 header - sound ignored');
|
|
4834
|
+
link.sound = undefined;
|
|
4835
|
+
return;
|
|
4836
|
+
}
|
|
4837
|
+
const rId = getNewRelId(target);
|
|
4838
|
+
target._relsMedia.push({
|
|
4839
|
+
path: path || 'preencoded.wav',
|
|
4840
|
+
type: 'audio/wav',
|
|
4841
|
+
extn: 'wav',
|
|
4842
|
+
data,
|
|
4843
|
+
rId,
|
|
4844
|
+
Target: `../media/audio-${target._slideNum}-${target._relsMedia.length + 1}.wav`
|
|
4845
|
+
});
|
|
4846
|
+
sound._sndRId = rId;
|
|
4847
|
+
} else if (!target._relsMedia.some((rel)=>rel.rId === sound._sndRId)) {
|
|
4848
|
+
target._relsMedia.push({
|
|
4849
|
+
path: sound.path || 'preencoded.wav',
|
|
4850
|
+
type: 'audio/wav',
|
|
4851
|
+
extn: 'wav',
|
|
4852
|
+
data: sound.data,
|
|
4853
|
+
rId: sound._sndRId,
|
|
4854
|
+
Target: `../media/audio-${target._slideNum}-${target._relsMedia.length + 1}.wav`
|
|
4855
|
+
});
|
|
4856
|
+
}
|
|
4857
|
+
}
|
|
4858
|
+
/**
|
|
4859
|
+
* Resolve a picture bullet's image into a slide relationship
|
|
4860
|
+
* - the paragraph emitter is pure, so the rId has to exist before the XML is generated
|
|
4861
|
+
*/ function resolveBulletImage(target, opts) {
|
|
4862
|
+
var _ref;
|
|
4863
|
+
var _exec;
|
|
4864
|
+
const bullet = typeof (opts === null || opts === void 0 ? void 0 : opts.bullet) === 'object' ? opts.bullet : undefined;
|
|
4865
|
+
if (!(bullet === null || bullet === void 0 ? void 0 : bullet.image) || bullet._imageRId) return;
|
|
4866
|
+
if (!bullet.image.toLowerCase().includes('base64,')) {
|
|
4867
|
+
console.warn('[pptxgenjs] `bullet.image` must be base64 image data (ex: \'image/png;base64,iV[...]\') - picture bullet ignored');
|
|
4868
|
+
bullet.image = undefined;
|
|
4869
|
+
return;
|
|
4870
|
+
}
|
|
4871
|
+
const extn = (_ref = (_exec = /image\/(\w+);/.exec(bullet.image)) === null || _exec === void 0 ? void 0 : _exec[1]) !== null && _ref !== void 0 ? _ref : 'png';
|
|
4872
|
+
const rId = getNewRelId(target);
|
|
4873
|
+
target._relsMedia.push({
|
|
4874
|
+
path: `preencoded.${extn}`,
|
|
4875
|
+
type: `image/${extn}`,
|
|
4876
|
+
extn,
|
|
4877
|
+
data: bullet.image,
|
|
4878
|
+
rId,
|
|
4879
|
+
Target: `../media/${imageTargetStem(target)}.${extn}`
|
|
4880
|
+
});
|
|
4881
|
+
bullet._imageRId = rId;
|
|
4882
|
+
}
|
|
4322
4883
|
function addShapeDefinition(target, shapeName, opts) {
|
|
4323
4884
|
const options = typeof opts === 'object' ? opts : {};
|
|
4324
4885
|
options.line = options.line || {
|
|
4325
4886
|
type: 'none'
|
|
4326
4887
|
};
|
|
4888
|
+
resolveHyperlinkRels(target, options.hyperlink);
|
|
4889
|
+
resolveHyperlinkRels(target, options.hyperlinkHover);
|
|
4890
|
+
resolveObjectImageFills(target, options);
|
|
4327
4891
|
const newObject = {
|
|
4328
4892
|
_type: (/* inlined export .SLIDE_OBJECT_TYPES.text */"text"),
|
|
4329
4893
|
shape: shapeName || core_enums_SHAPE_TYPE.RECTANGLE,
|
|
@@ -4356,7 +4920,9 @@ function addShapeDefinition(target, shapeName, opts) {
|
|
|
4356
4920
|
sourceAnchorPos: options.line.sourceAnchorPos,
|
|
4357
4921
|
targetAnchorPos: options.line.targetAnchorPos,
|
|
4358
4922
|
isConnector: options.line.isConnector || hasConnectorEnds,
|
|
4359
|
-
curveadjust: options.line.curveadjust
|
|
4923
|
+
curveadjust: options.line.curveadjust,
|
|
4924
|
+
_sourceName: options.line._sourceName,
|
|
4925
|
+
_targetName: options.line._targetName
|
|
4360
4926
|
};
|
|
4361
4927
|
if (typeof options.line === 'object' && options.line.type !== 'none') options.line = newLineOpts;
|
|
4362
4928
|
// 2: Set options defaults
|
|
@@ -4413,12 +4979,13 @@ function addShapeDefinition(target, shapeName, opts) {
|
|
|
4413
4979
|
// STEP 2: Transform `tableRows` into well-formatted TableCell's
|
|
4414
4980
|
// tableRows can be object or plain text array: `[{text:'cell 1'}, {text:'cell 2', options:{color:'ff0000'}}]` | `["cell 1", "cell 2"]`
|
|
4415
4981
|
const arrRows = [];
|
|
4416
|
-
|
|
4982
|
+
if (isStructuredImageFill(opt.fill)) resolveImageFill(target, opt.fill);
|
|
4983
|
+
const tableFillRid = isStructuredImageFill(opt.fill) ? undefined : registerTableCellImageFill(target, opt.fill);
|
|
4417
4984
|
tableRows.forEach((row)=>{
|
|
4418
4985
|
const newRow = [];
|
|
4419
4986
|
if (Array.isArray(row)) {
|
|
4420
4987
|
row.forEach((cell)=>{
|
|
4421
|
-
var _newCell_options
|
|
4988
|
+
var _newCell_options;
|
|
4422
4989
|
// A:
|
|
4423
4990
|
const newCell = {
|
|
4424
4991
|
_type: (/* inlined export .SLIDE_OBJECT_TYPES.tablecell */"tablecell"),
|
|
@@ -4488,8 +5055,13 @@ function addShapeDefinition(target, shapeName, opts) {
|
|
|
4488
5055
|
transparency: typeof cellBorder[idx].transparency === 'number' ? cellBorder[idx].transparency : undefined
|
|
4489
5056
|
};
|
|
4490
5057
|
});
|
|
4491
|
-
|
|
4492
|
-
|
|
5058
|
+
if (isStructuredImageFill(cellOpts.fill)) {
|
|
5059
|
+
resolveImageFill(target, cellOpts.fill);
|
|
5060
|
+
} else {
|
|
5061
|
+
var _registerTableCellImageFill;
|
|
5062
|
+
const fillRid = (_registerTableCellImageFill = registerTableCellImageFill(target, cellOpts.fill)) !== null && _registerTableCellImageFill !== void 0 ? _registerTableCellImageFill : cellOpts.fill ? undefined : tableFillRid;
|
|
5063
|
+
if (fillRid) cellOpts._fillRid = fillRid;
|
|
5064
|
+
}
|
|
4493
5065
|
// LAST:
|
|
4494
5066
|
newRow.push(newCell);
|
|
4495
5067
|
});
|
|
@@ -4696,7 +5268,8 @@ function addShapeDefinition(target, shapeName, opts) {
|
|
|
4696
5268
|
*/ function addTextDefinition(target, text, opts, isPlaceholder) {
|
|
4697
5269
|
var _newObject_options;
|
|
4698
5270
|
var // STEP 2: Create/Clean text options
|
|
4699
|
-
_newObject_text;
|
|
5271
|
+
_newObject_text, _newObject_options1, _newObject_options2, _newObject_text1;
|
|
5272
|
+
resolveObjectImageFills(target, opts);
|
|
4700
5273
|
const newObject = {
|
|
4701
5274
|
_type: isPlaceholder ? (/* inlined export .SLIDE_OBJECT_TYPES.placeholder */"placeholder") : (/* inlined export .SLIDE_OBJECT_TYPES.text */"text"),
|
|
4702
5275
|
shape: (opts === null || opts === void 0 ? void 0 : opts.shape) || core_enums_SHAPE_TYPE.RECTANGLE,
|
|
@@ -4827,8 +5400,18 @@ function addShapeDefinition(target, shapeName, opts) {
|
|
|
4827
5400
|
// STEP 1: Create/Clean object options
|
|
4828
5401
|
newObject.options = cleanOpts((_newObject_options = newObject.options) !== null && _newObject_options !== void 0 ? _newObject_options : {});
|
|
4829
5402
|
(_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
|
|
5403
|
+
// STEP 3: Create hyperlinks, hover actions, and any picture-bullet relationships
|
|
4831
5404
|
createHyperlinkRels(target, newObject.text || '');
|
|
5405
|
+
resolveHyperlinkRels(target, (_newObject_options1 = newObject.options) === null || _newObject_options1 === void 0 ? void 0 : _newObject_options1.hyperlink);
|
|
5406
|
+
resolveHyperlinkRels(target, (_newObject_options2 = newObject.options) === null || _newObject_options2 === void 0 ? void 0 : _newObject_options2.hyperlinkHover);
|
|
5407
|
+
resolveBulletImage(target, newObject.options);
|
|
5408
|
+
(_newObject_text1 = newObject.text) === null || _newObject_text1 === void 0 ? void 0 : _newObject_text1.forEach((item)=>{
|
|
5409
|
+
var _item_options, _item_options_hyperlink, _item_options1;
|
|
5410
|
+
resolveHyperlinkRels(target, (_item_options = item.options) === null || _item_options === void 0 ? void 0 : _item_options.hyperlinkHover);
|
|
5411
|
+
// a click link already has its target rel; this adds its action sound
|
|
5412
|
+
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);
|
|
5413
|
+
resolveBulletImage(target, item.options);
|
|
5414
|
+
});
|
|
4832
5415
|
// LAST: Add object to Slide
|
|
4833
5416
|
target._slideObjects.push(newObject);
|
|
4834
5417
|
}
|
|
@@ -4956,6 +5539,11 @@ function addShapeDefinition(target, shapeName, opts) {
|
|
|
4956
5539
|
});
|
|
4957
5540
|
}
|
|
4958
5541
|
}
|
|
5542
|
+
if (text && typeof text === 'object' && !Array.isArray(text) && text.options) {
|
|
5543
|
+
var _text_options_hyperlink;
|
|
5544
|
+
resolveHyperlinkRels(target, text.options.hyperlinkHover);
|
|
5545
|
+
if ((_text_options_hyperlink = text.options.hyperlink) === null || _text_options_hyperlink === void 0 ? void 0 : _text_options_hyperlink.sound) resolveHyperlinkRels(target, text.options.hyperlink);
|
|
5546
|
+
}
|
|
4959
5547
|
});
|
|
4960
5548
|
}
|
|
4961
5549
|
function makeGroupCollector(parent) {
|
|
@@ -4975,6 +5563,7 @@ function makeGroupCollector(parent) {
|
|
|
4975
5563
|
* Child coordinates are relative to the group origin (`chOff` 0,0 / `chExt` = group size).
|
|
4976
5564
|
*/ function addGroupDefinition(target, opts, objects) {
|
|
4977
5565
|
var _opts_x, _opts_y, _opts_w, _opts_h, _opts_rotate;
|
|
5566
|
+
if (opts.fill) resolveImageFill(target, opts.fill);
|
|
4978
5567
|
const groupCount = target._slideObjects.filter((obj)=>obj._type === (/* inlined export .SLIDE_OBJECT_TYPES.group */"group")).length;
|
|
4979
5568
|
const newObject = {
|
|
4980
5569
|
_type: (/* inlined export .SLIDE_OBJECT_TYPES.group */"group"),
|
|
@@ -4985,7 +5574,11 @@ function makeGroupCollector(parent) {
|
|
|
4985
5574
|
h: (_opts_h = opts.h) !== null && _opts_h !== void 0 ? _opts_h : 1,
|
|
4986
5575
|
rotate: (_opts_rotate = opts.rotate) !== null && _opts_rotate !== void 0 ? _opts_rotate : 0,
|
|
4987
5576
|
shadow: opts.shadow ? correctShadowOptions(opts.shadow) : undefined,
|
|
4988
|
-
|
|
5577
|
+
fill: opts.fill,
|
|
5578
|
+
objectName: opts.objectName ? encodeXmlEntities(opts.objectName) : `Group ${groupCount + 1}`,
|
|
5579
|
+
title: opts.title,
|
|
5580
|
+
hidden: opts.hidden,
|
|
5581
|
+
lock: opts.lock
|
|
4989
5582
|
},
|
|
4990
5583
|
_objects: objects
|
|
4991
5584
|
};
|
|
@@ -5025,10 +5618,60 @@ function createGroupBuilder(parent, objects) {
|
|
|
5025
5618
|
addGroupDefinition(collector, options, children);
|
|
5026
5619
|
objects.push(...collector._slideObjects);
|
|
5027
5620
|
return builder;
|
|
5621
|
+
},
|
|
5622
|
+
addConnector (options) {
|
|
5623
|
+
const collector = makeGroupCollector(parent);
|
|
5624
|
+
addConnectorDefinition(collector, options !== null && options !== void 0 ? options : {});
|
|
5625
|
+
objects.push(...collector._slideObjects);
|
|
5626
|
+
return builder;
|
|
5028
5627
|
}
|
|
5029
5628
|
};
|
|
5030
5629
|
return builder;
|
|
5031
5630
|
}
|
|
5631
|
+
const CONNECTOR_PRESETS = new Set([
|
|
5632
|
+
'line',
|
|
5633
|
+
'straightConnector1',
|
|
5634
|
+
'bentConnector2',
|
|
5635
|
+
'bentConnector3',
|
|
5636
|
+
'bentConnector4',
|
|
5637
|
+
'bentConnector5',
|
|
5638
|
+
'curvedConnector2',
|
|
5639
|
+
'curvedConnector3',
|
|
5640
|
+
'curvedConnector4',
|
|
5641
|
+
'curvedConnector5'
|
|
5642
|
+
]);
|
|
5643
|
+
/**
|
|
5644
|
+
* Additive connector convenience: maps onto `addShape` + `line.isConnector`.
|
|
5645
|
+
* `start`/`end` `objectName`s are resolved to `sourceId`/`targetId` at emit time.
|
|
5646
|
+
*/ function addConnectorDefinition(target, opt) {
|
|
5647
|
+
var _opt_line, _ref, _ref1;
|
|
5648
|
+
var _opt_line1, _opt_line2, _opt_start, _opt_line3, _opt_end, _opt_line4, _opt_start1, _opt_end1;
|
|
5649
|
+
const requested = opt.type && CONNECTOR_PRESETS.has(opt.type) ? opt.type : 'straightConnector1';
|
|
5650
|
+
const shapeName = requested === 'line' ? core_enums_SHAPE_TYPE.LINE : requested;
|
|
5651
|
+
const line = gen_objects_object_spread_props(gen_objects_object_spread({}, (_opt_line = opt.line) !== null && _opt_line !== void 0 ? _opt_line : {}), {
|
|
5652
|
+
isConnector: true,
|
|
5653
|
+
sourceId: (_opt_line1 = opt.line) === null || _opt_line1 === void 0 ? void 0 : _opt_line1.sourceId,
|
|
5654
|
+
targetId: (_opt_line2 = opt.line) === null || _opt_line2 === void 0 ? void 0 : _opt_line2.targetId,
|
|
5655
|
+
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,
|
|
5656
|
+
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,
|
|
5657
|
+
_sourceName: (_opt_start1 = opt.start) === null || _opt_start1 === void 0 ? void 0 : _opt_start1.shape,
|
|
5658
|
+
_targetName: (_opt_end1 = opt.end) === null || _opt_end1 === void 0 ? void 0 : _opt_end1.shape
|
|
5659
|
+
});
|
|
5660
|
+
addShapeDefinition(target, shapeName, {
|
|
5661
|
+
x: opt.x,
|
|
5662
|
+
y: opt.y,
|
|
5663
|
+
w: opt.w,
|
|
5664
|
+
h: opt.h,
|
|
5665
|
+
objectName: opt.objectName,
|
|
5666
|
+
rotate: opt.rotate,
|
|
5667
|
+
flipH: opt.flipH,
|
|
5668
|
+
flipV: opt.flipV,
|
|
5669
|
+
fill: opt.fill,
|
|
5670
|
+
shadow: opt.shadow,
|
|
5671
|
+
styleRef: opt.styleRef,
|
|
5672
|
+
line
|
|
5673
|
+
});
|
|
5674
|
+
}
|
|
5032
5675
|
|
|
5033
5676
|
;// CONCATENATED MODULE: ./src/slide.ts
|
|
5034
5677
|
/**
|
|
@@ -5074,6 +5717,8 @@ function slide_object_spread(target) {
|
|
|
5074
5717
|
delete runOpts.reflection;
|
|
5075
5718
|
delete runOpts.shadow;
|
|
5076
5719
|
delete runOpts.blur;
|
|
5720
|
+
delete runOpts.fillOverlay;
|
|
5721
|
+
delete runOpts.effectDag;
|
|
5077
5722
|
return runOpts;
|
|
5078
5723
|
}
|
|
5079
5724
|
class Slide {
|
|
@@ -5168,6 +5813,14 @@ class Slide {
|
|
|
5168
5813
|
addGroupDefinition(this, cloneOpts(options), children);
|
|
5169
5814
|
return this;
|
|
5170
5815
|
}
|
|
5816
|
+
/**
|
|
5817
|
+
* Add a connector (`p:cxnSp`). Additive convenience over `line.isConnector`.
|
|
5818
|
+
* Glue with `start`/`end` `objectName`s, or pass numeric `line.sourceId`/`targetId`.
|
|
5819
|
+
* @example slide.addConnector({ type: 'straightConnector1', start: { shape: 'BoxA', site: 3 }, end: { shape: 'BoxB', site: 1 } })
|
|
5820
|
+
*/ addConnector(options) {
|
|
5821
|
+
addConnectorDefinition(this, cloneOpts(options !== null && options !== void 0 ? options : {}));
|
|
5822
|
+
return this;
|
|
5823
|
+
}
|
|
5171
5824
|
/**
|
|
5172
5825
|
* Add a slide transition (`<p:transition>`, ECMA-376 §19.3.1.50 / MS-PPTX §2.2.1)
|
|
5173
5826
|
* @param {SlideTransitionProps} options - transition options
|
|
@@ -5380,65 +6033,6 @@ class Slide {
|
|
|
5380
6033
|
}
|
|
5381
6034
|
|
|
5382
6035
|
|
|
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
6036
|
;// CONCATENATED MODULE: ./src/charts/utils.ts
|
|
5443
6037
|
function utils_define_property(obj, key, value) {
|
|
5444
6038
|
if (key in obj) {
|
|
@@ -5635,6 +6229,305 @@ function resolveAreaGrouping(barGrouping) {
|
|
|
5635
6229
|
return 'standard';
|
|
5636
6230
|
}
|
|
5637
6231
|
|
|
6232
|
+
;// CONCATENATED MODULE: ./src/charts/chartex.ts
|
|
6233
|
+
/**
|
|
6234
|
+
* ChartEx (`cx:chartSpace`) rendering - MS-ODRAWXML 2.1.
|
|
6235
|
+
*
|
|
6236
|
+
* PowerPoint 2016 introduced chart layouts that ECMA-376 has no markup for. They are written to their
|
|
6237
|
+
* own part, in the `cx` namespace, and share nothing with the `c:` emitter in `xml.ts` beyond the
|
|
6238
|
+
* embedded workbook: the data lives in `cx:chartData` (one `cx:data` per series) and the layout is
|
|
6239
|
+
* selected by `cx:series@layoutId` rather than by the element name.
|
|
6240
|
+
*
|
|
6241
|
+
* The cell references point at the same worksheet `workbook.ts` writes for classic charts - column A
|
|
6242
|
+
* holds the category labels, columns B.. hold one series each, row 1 holds the series names - so no
|
|
6243
|
+
* chartex-specific workbook layout is needed.
|
|
6244
|
+
*/
|
|
6245
|
+
|
|
6246
|
+
|
|
6247
|
+
/** Sheet name written by `workbook.ts`; chartex cell references are absolute and always single-sheet */ const SHEET = 'Sheet1';
|
|
6248
|
+
/**
|
|
6249
|
+
* Category-axis gap width per layout, matching what PowerPoint writes for a freshly inserted chart.
|
|
6250
|
+
* A layout absent here (treemap, sunburst) draws no axes at all.
|
|
6251
|
+
*/ const CAT_GAP_WIDTH = {
|
|
6252
|
+
boxWhisker: '1',
|
|
6253
|
+
funnel: '0.0599999987',
|
|
6254
|
+
histogram: '0',
|
|
6255
|
+
waterfall: '0.5'
|
|
6256
|
+
};
|
|
6257
|
+
function firstLabelLevel(data) {
|
|
6258
|
+
var _data_;
|
|
6259
|
+
const labels = (_data_ = data[0]) === null || _data_ === void 0 ? void 0 : _data_.labels;
|
|
6260
|
+
if (!labels || labels.length === 0) return [];
|
|
6261
|
+
const level = labels[0];
|
|
6262
|
+
return Array.isArray(level) ? level : [];
|
|
6263
|
+
}
|
|
6264
|
+
/**
|
|
6265
|
+
* `<cx:pt idx="N">value</cx:pt>` for every point of one dimension
|
|
6266
|
+
* - a missing point is written empty: `cx:pt` inside a `cx:numDim` must be a number, so the string
|
|
6267
|
+
* "null" would be a schema violation (the ECMA-376 emitter blanks the same case)
|
|
6268
|
+
*/ function makePoints(values) {
|
|
6269
|
+
return values.map((value, idx)=>`<cx:pt idx="${idx}">${value === null || value === undefined ? '' : encodeXmlEntities(String(value))}</cx:pt>`).join('');
|
|
6270
|
+
}
|
|
6271
|
+
/**
|
|
6272
|
+
* Absolute A1 reference for one column of the embedded worksheet, excluding the header row.
|
|
6273
|
+
* The range length must equal the dimension's own `ptCount`, so each dimension passes its own.
|
|
6274
|
+
*/ function columnRef(colIdx, pointCount) {
|
|
6275
|
+
const col = getExcelColName(colIdx);
|
|
6276
|
+
return `${SHEET}!$${col}$2:$${col}$${pointCount + 1}`;
|
|
6277
|
+
}
|
|
6278
|
+
/**
|
|
6279
|
+
* One `cx:data` block per series.
|
|
6280
|
+
* - hierarchical layouts (treemap, sunburst) size their segments through a `size` dimension
|
|
6281
|
+
* - a histogram bins raw values itself, so it carries no category dimension at all
|
|
6282
|
+
*/ function makeChartData(rel, chartType) {
|
|
6283
|
+
const labels = firstLabelLevel(rel.data);
|
|
6284
|
+
const dimType = chartType === 'treemap' || chartType === 'sunburst' ? 'size' : 'val';
|
|
6285
|
+
return rel.data.map((series, seriesIdx)=>{
|
|
6286
|
+
var _series_values;
|
|
6287
|
+
const values = (_series_values = series.values) !== null && _series_values !== void 0 ? _series_values : [];
|
|
6288
|
+
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>`;
|
|
6289
|
+
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>`;
|
|
6290
|
+
return `<cx:data id="${seriesIdx}">${catDim}${valDim}</cx:data>`;
|
|
6291
|
+
}).join('');
|
|
6292
|
+
}
|
|
6293
|
+
/** `cx:dataLabels` - chartex has no `c:dLbls`, visibility is a single element with three flags */ function makeDataLabels(opts, chartType) {
|
|
6294
|
+
var _opts_showValue, _opts_showLabel, _opts_dataLabelPosition;
|
|
6295
|
+
const showValue = (_opts_showValue = opts.showValue) !== null && _opts_showValue !== void 0 ? _opts_showValue : false;
|
|
6296
|
+
const showCategory = (_opts_showLabel = opts.showLabel) !== null && _opts_showLabel !== void 0 ? _opts_showLabel : false;
|
|
6297
|
+
if (!showValue && !showCategory) return '';
|
|
6298
|
+
// `outEnd` is invalid on the layouts that draw labels inside their segments
|
|
6299
|
+
const defaultPos = chartType === 'treemap' || chartType === 'sunburst' || chartType === 'funnel' ? 'ctr' : 'outEnd';
|
|
6300
|
+
const pos = (_opts_dataLabelPosition = opts.dataLabelPosition) !== null && _opts_dataLabelPosition !== void 0 ? _opts_dataLabelPosition : defaultPos;
|
|
6301
|
+
const size = Math.round((opts.dataLabelFontSize || (/* inlined export .DEF_FONT_SIZE */12)) * 100);
|
|
6302
|
+
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>';
|
|
6303
|
+
const numFmt = opts.dataLabelFormatCode ? `<cx:numFmt formatCode="${encodeXmlEntities(opts.dataLabelFormatCode)}" sourceLinked="0"/>` : '';
|
|
6304
|
+
return `<cx:dataLabels pos="${pos}">` + `<cx:visibility seriesName="0" categoryName="${showCategory ? 1 : 0}" value="${showValue ? 1 : 0}"/>` + numFmt + txPr + '</cx:dataLabels>';
|
|
6305
|
+
}
|
|
6306
|
+
/**
|
|
6307
|
+
* `cx:layoutPr` carries everything that is layout-specific rather than series-generic.
|
|
6308
|
+
* Anything absent here is left to PowerPoint's own default for that layout.
|
|
6309
|
+
*/ function makeLayoutProps(opts, chartType) {
|
|
6310
|
+
switch(chartType){
|
|
6311
|
+
case 'waterfall':
|
|
6312
|
+
{
|
|
6313
|
+
var _opts_chartExSubtotals;
|
|
6314
|
+
const subtotals = (_opts_chartExSubtotals = opts.chartExSubtotals) !== null && _opts_chartExSubtotals !== void 0 ? _opts_chartExSubtotals : [];
|
|
6315
|
+
if (subtotals.length === 0) return '';
|
|
6316
|
+
return `<cx:layoutPr><cx:subtotals>${subtotals.map((idx)=>`<cx:idx val="${idx}"/>`).join('')}</cx:subtotals></cx:layoutPr>`;
|
|
6317
|
+
}
|
|
6318
|
+
case 'histogram':
|
|
6319
|
+
{
|
|
6320
|
+
const binSize = opts.chartExBinSize;
|
|
6321
|
+
const binCount = opts.chartExBinCount;
|
|
6322
|
+
// PowerPoint accepts exactly one binning rule; an explicit size wins over a count, and neither
|
|
6323
|
+
// means "let PowerPoint choose" (its automatic Scott's-rule binning)
|
|
6324
|
+
const rule = binSize !== undefined ? `<cx:binSize val="${binSize}"/>` : binCount !== undefined ? `<cx:binCount val="${binCount}"/>` : '';
|
|
6325
|
+
const binning = rule ? `<cx:binning intervalClosed="r">${rule}</cx:binning>` : '<cx:binning intervalClosed="r"/>';
|
|
6326
|
+
return `<cx:layoutPr>${binning}</cx:layoutPr>`;
|
|
6327
|
+
}
|
|
6328
|
+
case 'boxWhisker':
|
|
6329
|
+
return '<cx:layoutPr>' + `<cx:visibility meanLine="${opts.chartExMeanLine ? 1 : 0}" meanMarker="1" nonoutliers="0" outliers="1"/>` + '<cx:statistics quartileMethod="exclusive"/>' + '</cx:layoutPr>';
|
|
6330
|
+
case 'treemap':
|
|
6331
|
+
var _opts_chartExParentLabels;
|
|
6332
|
+
return `<cx:layoutPr><cx:parentLabelLayout val="${(_opts_chartExParentLabels = opts.chartExParentLabels) !== null && _opts_chartExParentLabels !== void 0 ? _opts_chartExParentLabels : 'overlapping'}"/></cx:layoutPr>`;
|
|
6333
|
+
default:
|
|
6334
|
+
return '';
|
|
6335
|
+
}
|
|
6336
|
+
}
|
|
6337
|
+
/** One `cx:series` per data row. Order follows CT_Series: tx, spPr, dataLabels, dataId, layoutPr, axisId. */ function makeSeries(rel, chartType) {
|
|
6338
|
+
const layoutId = CHARTEX_LAYOUT_ID[chartType];
|
|
6339
|
+
const dataLabels = makeDataLabels(rel.opts, chartType);
|
|
6340
|
+
const layoutPr = makeLayoutProps(rel.opts, chartType);
|
|
6341
|
+
return rel.data.map((series, idx)=>{
|
|
6342
|
+
var _series_name;
|
|
6343
|
+
const nameCell = `${SHEET}!$${getExcelColName(idx + 2)}$1`;
|
|
6344
|
+
// These layouts color each data point from the chart color style, so `chartColors` does not
|
|
6345
|
+
// apply - a series-level fill would flatten a treemap to one color. Only `color` overrides it.
|
|
6346
|
+
const spPr = series.color && series.color !== 'transparent' ? `<cx:spPr><a:solidFill>${createColorElement(series.color)}</a:solidFill></cx:spPr>` : '';
|
|
6347
|
+
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>';
|
|
6348
|
+
}).join('');
|
|
6349
|
+
}
|
|
6350
|
+
/**
|
|
6351
|
+
* `cx:axis` elements for the layouts that have axes. CT_Axis order: scaling, gridlines, tickLabels.
|
|
6352
|
+
* - a funnel is drawn along a single category axis, which PowerPoint numbers `1`
|
|
6353
|
+
* - treemap and sunburst have no axes; the series carries no `cx:axisId` in either case
|
|
6354
|
+
*/ function makeAxes(rel, chartType) {
|
|
6355
|
+
var _rel_opts_valGridLine;
|
|
6356
|
+
const gapWidth = CAT_GAP_WIDTH[chartType];
|
|
6357
|
+
if (gapWidth === undefined) return '';
|
|
6358
|
+
if (chartType === 'funnel') return `<cx:axis id="1"><cx:catScaling gapWidth="${gapWidth}"/><cx:tickLabels/></cx:axis>`;
|
|
6359
|
+
const valGridlines = ((_rel_opts_valGridLine = rel.opts.valGridLine) === null || _rel_opts_valGridLine === void 0 ? void 0 : _rel_opts_valGridLine.style) === 'none' ? '' : '<cx:majorGridlines/>';
|
|
6360
|
+
return `<cx:axis id="0"><cx:catScaling gapWidth="${gapWidth}"/><cx:tickLabels/></cx:axis>` + `<cx:axis id="1"><cx:valScaling/>${valGridlines}<cx:tickLabels/></cx:axis>`;
|
|
6361
|
+
}
|
|
6362
|
+
function makeTitle(opts) {
|
|
6363
|
+
if (!opts.showTitle) return '';
|
|
6364
|
+
const size = Math.round((opts.titleFontSize || (/* inlined export .DEF_FONT_TITLE_SIZE */18)) * 100);
|
|
6365
|
+
const color = opts.titleColor ? `<a:solidFill>${createColorElement(opts.titleColor)}</a:solidFill>` : '';
|
|
6366
|
+
const face = opts.titleFontFace ? `<a:latin typeface="${encodeXmlEntities(opts.titleFontFace)}"/>` : '';
|
|
6367
|
+
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>';
|
|
6368
|
+
}
|
|
6369
|
+
function makeLegend(opts) {
|
|
6370
|
+
if (!opts.showLegend) return '';
|
|
6371
|
+
// `cx:legend@pos` takes l/r/t/b only; PowerPoint stores the library's `tr` as a top-aligned right legend
|
|
6372
|
+
const isTopRight = opts.legendPos === 'tr';
|
|
6373
|
+
return `<cx:legend pos="${isTopRight ? 'r' : opts.legendPos || 'r'}" align="${isTopRight ? 'min' : 'ctr'}" overlay="0"/>`;
|
|
6374
|
+
}
|
|
6375
|
+
/**
|
|
6376
|
+
* Build the `cx:chartSpace` part for one chartex chart.
|
|
6377
|
+
* @param {ISlideRelChart} rel - chart relationship, with `opts._type` narrowed to a chartex type
|
|
6378
|
+
* @returns {string} chartex part XML
|
|
6379
|
+
*/ function makeXmlChartEx(rel) {
|
|
6380
|
+
const type = rel.opts._type;
|
|
6381
|
+
if (!isChartexType(type)) throw new Error(`pptxgenjs: "${String(type)}" is not a chartex chart type`);
|
|
6382
|
+
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>';
|
|
6383
|
+
}
|
|
6384
|
+
|
|
6385
|
+
;// CONCATENATED MODULE: ./src/charts/style.ts
|
|
6386
|
+
/**
|
|
6387
|
+
* Chart style and chart colour-style parts (`ppt/charts/styleN.xml`, `ppt/charts/colorsN.xml`).
|
|
6388
|
+
*
|
|
6389
|
+
* Classic `c:chart` parts write these only when `chartStyle` or `chartColorStyle` is set.
|
|
6390
|
+
* ChartEx layouts always need both: PowerPoint resolves their visual properties through them.
|
|
6391
|
+
*
|
|
6392
|
+
* PowerPoint finds both parts by relationship type from the chart's own `.rels` - nothing inside
|
|
6393
|
+
* `chartN.xml` points at them.
|
|
6394
|
+
*/
|
|
6395
|
+
|
|
6396
|
+
const XML_HEADER = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>';
|
|
6397
|
+
const NS_ATTRS = `xmlns:cs="${CHART_STYLE.ns}" xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main"`;
|
|
6398
|
+
/** The luminance variations Office writes for a six-colour cycling palette */ const DEF_VARIATIONS = [
|
|
6399
|
+
'',
|
|
6400
|
+
'<a:lumMod val="60000"/>',
|
|
6401
|
+
'<a:lumMod val="80000"/><a:lumOff val="20000"/>',
|
|
6402
|
+
'<a:lumMod val="80000"/>',
|
|
6403
|
+
'<a:lumMod val="60000"/><a:lumOff val="40000"/>',
|
|
6404
|
+
'<a:lumMod val="50000"/>',
|
|
6405
|
+
'<a:lumMod val="70000"/><a:lumOff val="30000"/>',
|
|
6406
|
+
'<a:lumMod val="70000"/>',
|
|
6407
|
+
'<a:lumMod val="50000"/><a:lumOff val="50000"/>'
|
|
6408
|
+
];
|
|
6409
|
+
/** The six theme accents, which is what Office's default colour style cycles through */ const DEF_ACCENTS = [
|
|
6410
|
+
'accent1',
|
|
6411
|
+
'accent2',
|
|
6412
|
+
'accent3',
|
|
6413
|
+
'accent4',
|
|
6414
|
+
'accent5',
|
|
6415
|
+
'accent6'
|
|
6416
|
+
];
|
|
6417
|
+
/**
|
|
6418
|
+
* Whether this chart should write `styleN.xml` / `colorsN.xml`.
|
|
6419
|
+
* ChartEx always needs them; classic charts only write them when the caller opts in.
|
|
6420
|
+
*/ function wantsChartStyleParts(opts) {
|
|
6421
|
+
if (!opts) return false;
|
|
6422
|
+
if (isChartexType(opts._type)) return true;
|
|
6423
|
+
return opts.chartStyle !== undefined || opts.chartColorStyle !== undefined;
|
|
6424
|
+
}
|
|
6425
|
+
/**
|
|
6426
|
+
* Part name for a chart's colour style, matching the chart's own number
|
|
6427
|
+
* @param {number} chartNum - the N in `chartN.xml`
|
|
6428
|
+
* @returns {string} part name
|
|
6429
|
+
*/ function chartColorsPartName(chartNum) {
|
|
6430
|
+
return `ppt/charts/colors${chartNum}.xml`;
|
|
6431
|
+
}
|
|
6432
|
+
/**
|
|
6433
|
+
* Part name for a chart's style, matching the chart's own number
|
|
6434
|
+
* @param {number} chartNum - the N in `chartN.xml`
|
|
6435
|
+
* @returns {string} part name
|
|
6436
|
+
*/ function chartStylePartName(chartNum) {
|
|
6437
|
+
return `ppt/charts/style${chartNum}.xml`;
|
|
6438
|
+
}
|
|
6439
|
+
/**
|
|
6440
|
+
* Creates a chart's colour-style part (`cs:colorStyle`).
|
|
6441
|
+
* @param {ChartColorStyleProps} [props] - colour style options
|
|
6442
|
+
* @returns {string} XML
|
|
6443
|
+
*/ function makeXmlChartColors(props) {
|
|
6444
|
+
const methods = [
|
|
6445
|
+
'cycle',
|
|
6446
|
+
'withinLinear',
|
|
6447
|
+
'acrossLinear',
|
|
6448
|
+
'withinLinearReversed',
|
|
6449
|
+
'acrossLinearReversed'
|
|
6450
|
+
];
|
|
6451
|
+
const method = (props === null || props === void 0 ? void 0 : props.method) && methods.includes(props.method) ? props.method : 'cycle';
|
|
6452
|
+
const id = typeof (props === null || props === void 0 ? void 0 : props.id) === 'number' && isFinite(props.id) && props.id > 0 ? Math.round(props.id) : 10;
|
|
6453
|
+
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('');
|
|
6454
|
+
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>';
|
|
6455
|
+
}
|
|
6456
|
+
/**
|
|
6457
|
+
* Office's default chart style definitions, verbatim.
|
|
6458
|
+
*
|
|
6459
|
+
* The `@id` names which entry of PowerPoint's gallery is selected; the ~30 `cs:*` children are the
|
|
6460
|
+
* definitions themselves. Only this one set is shipped - reproducing every gallery entry would mean
|
|
6461
|
+
* ~150 more, none of which can be verified from a published schema.
|
|
6462
|
+
*/ 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>';
|
|
6463
|
+
/**
|
|
6464
|
+
* Creates a chart's style part (`cs:chartStyle`).
|
|
6465
|
+
* @param {number} [styleId] - which gallery entry is selected; the definitions are Office's defaults
|
|
6466
|
+
* @returns {string} XML
|
|
6467
|
+
*/ function makeXmlChartStyle(styleId) {
|
|
6468
|
+
const body = typeof styleId === 'number' && isFinite(styleId) && styleId > 0 ? DEF_CHART_STYLE.replace(/ id="\d+">/, ` id="${Math.round(styleId)}">`) : DEF_CHART_STYLE;
|
|
6469
|
+
return XML_HEADER + body;
|
|
6470
|
+
}
|
|
6471
|
+
|
|
6472
|
+
;// CONCATENATED MODULE: ./src/charts/title.ts
|
|
6473
|
+
/**
|
|
6474
|
+
* Chart title rendering.
|
|
6475
|
+
*/
|
|
6476
|
+
|
|
6477
|
+
/**
|
|
6478
|
+
* Create char title elements
|
|
6479
|
+
* @param {IChartPropsTitle} opts - options
|
|
6480
|
+
* @return {string} XML `<c:title>`
|
|
6481
|
+
*/ function genXmlTitle(opts, chartX, chartY) {
|
|
6482
|
+
const align = opts.titleAlign === 'left' || opts.titleAlign === 'right' ? `<a:pPr algn="${opts.titleAlign.substring(0, 1)}">` : '<a:pPr>';
|
|
6483
|
+
const rotate = opts.titleRotate ? `<a:bodyPr rot="${convertRotationDegrees(opts.titleRotate)}"/>` : '<a:bodyPr/>' // don't specify rotation to get default (ex. vertical for cat axis)
|
|
6484
|
+
;
|
|
6485
|
+
const sizeAttr = opts.fontSize ? `sz="${Math.round(opts.fontSize * 100)}"` : '' // only set the font size if specified. Powerpoint will handle the default size
|
|
6486
|
+
;
|
|
6487
|
+
const titleBold = opts.titleBold ? 1 : 0;
|
|
6488
|
+
const titleItalic = opts.titleItalic ? 1 : 0;
|
|
6489
|
+
let layout = '<c:layout/>';
|
|
6490
|
+
if (opts.titlePos && typeof opts.titlePos.x === 'number' && typeof opts.titlePos.y === 'number') {
|
|
6491
|
+
// NOTE: manualLayout x/y vals are *relative to entire slide*
|
|
6492
|
+
const totalX = opts.titlePos.x + (chartX !== null && chartX !== void 0 ? chartX : 0);
|
|
6493
|
+
const totalY = opts.titlePos.y + (chartY !== null && chartY !== void 0 ? chartY : 0);
|
|
6494
|
+
let valX = totalX === 0 ? 0 : totalX * (totalX / 5) / 10;
|
|
6495
|
+
if (valX >= 1) valX = valX / 10;
|
|
6496
|
+
if (valX >= 0.1) valX = valX / 10;
|
|
6497
|
+
let valY = totalY === 0 ? 0 : totalY * (totalY / 5) / 10;
|
|
6498
|
+
if (valY >= 1) valY = valY / 10;
|
|
6499
|
+
if (valY >= 0.1) valY = valY / 10;
|
|
6500
|
+
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>`;
|
|
6501
|
+
}
|
|
6502
|
+
return `<c:title>
|
|
6503
|
+
<c:tx>
|
|
6504
|
+
<c:rich>
|
|
6505
|
+
${rotate}
|
|
6506
|
+
<a:lstStyle/>
|
|
6507
|
+
<a:p>
|
|
6508
|
+
${align}
|
|
6509
|
+
<a:defRPr ${sizeAttr} b="${titleBold}" i="${titleItalic}" u="none" strike="noStrike">
|
|
6510
|
+
<a:solidFill>${createColorElement(opts.color || (/* inlined export .DEF_FONT_COLOR */"000000"))}</a:solidFill>
|
|
6511
|
+
<a:latin typeface="${encodeXmlEntities(opts.fontFace) || 'Arial'}"/>
|
|
6512
|
+
<a:ea typeface="${encodeXmlEntities(opts.fontFace) || 'Arial'}"/>
|
|
6513
|
+
</a:defRPr>
|
|
6514
|
+
</a:pPr>
|
|
6515
|
+
<a:r>
|
|
6516
|
+
<a:rPr ${sizeAttr} b="${titleBold}" i="${titleItalic}" u="none" strike="noStrike">
|
|
6517
|
+
<a:solidFill>${createColorElement(opts.color || (/* inlined export .DEF_FONT_COLOR */"000000"))}</a:solidFill>
|
|
6518
|
+
<a:latin typeface="${encodeXmlEntities(opts.fontFace) || 'Arial'}"/>
|
|
6519
|
+
<a:ea typeface="${encodeXmlEntities(opts.fontFace) || 'Arial'}"/>
|
|
6520
|
+
</a:rPr>
|
|
6521
|
+
<a:t>${encodeXmlEntities(opts.title) || ''}</a:t>
|
|
6522
|
+
</a:r>
|
|
6523
|
+
</a:p>
|
|
6524
|
+
</c:rich>
|
|
6525
|
+
</c:tx>
|
|
6526
|
+
${layout}
|
|
6527
|
+
<c:overlay val="0"/>
|
|
6528
|
+
</c:title>`;
|
|
6529
|
+
}
|
|
6530
|
+
|
|
5638
6531
|
;// CONCATENATED MODULE: ./src/charts/axes.ts
|
|
5639
6532
|
/**
|
|
5640
6533
|
* Chart axis rendering.
|
|
@@ -6057,7 +6950,7 @@ function xml_object_spread_props(target, source) {
|
|
|
6057
6950
|
usesSecondaryValAxis = usesSecondaryValAxis || ((_options_secondaryValAxis = options.secondaryValAxis) !== null && _options_secondaryValAxis !== void 0 ? _options_secondaryValAxis : false);
|
|
6058
6951
|
strXml += makeChartType(type.type, type.data, options, valAxisId, catAxisId, true, rel.data);
|
|
6059
6952
|
});
|
|
6060
|
-
} else if (rel.opts._type) {
|
|
6953
|
+
} else if (rel.opts._type && !isChartexType(rel.opts._type)) {
|
|
6061
6954
|
strXml += makeChartType(rel.opts._type, rel.data, rel.opts, AXIS_ID_VALUE_PRIMARY, AXIS_ID_CATEGORY_PRIMARY, false, rel.data);
|
|
6062
6955
|
}
|
|
6063
6956
|
// B: Axes -----------------------------------------------------------
|
|
@@ -7103,6 +7996,8 @@ function _async_to_generator(fn) {
|
|
|
7103
7996
|
|
|
7104
7997
|
|
|
7105
7998
|
|
|
7999
|
+
|
|
8000
|
+
|
|
7106
8001
|
function getDataTableStyles(chartObject) {
|
|
7107
8002
|
const dataTableFormats = Array.isArray(chartObject.opts._type) ? chartObject.opts._type.flatMap((type)=>{
|
|
7108
8003
|
var _ref;
|
|
@@ -7607,8 +8502,19 @@ function makeNumberStyles(formats) {
|
|
|
7607
8502
|
base64: true
|
|
7608
8503
|
});
|
|
7609
8504
|
// 2: Create the chart.xml and rel files
|
|
7610
|
-
|
|
7611
|
-
|
|
8505
|
+
// PowerPoint finds the style and colour-style parts by relationship type, so they are
|
|
8506
|
+
// declared here rather than referenced from inside `chartN.xml`.
|
|
8507
|
+
// Classic charts write them only when requested; ChartEx layouts always need them.
|
|
8508
|
+
const isChartex = isChartexType(chartObject.opts._type);
|
|
8509
|
+
const writeStyleParts = wantsChartStyleParts(chartObject.opts);
|
|
8510
|
+
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"/>` : '';
|
|
8511
|
+
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>');
|
|
8512
|
+
zip.file(`ppt/charts/${chartObject.fileName}`, isChartex ? makeXmlChartEx(chartObject) : makeXmlCharts(chartObject));
|
|
8513
|
+
if (writeStyleParts) {
|
|
8514
|
+
var _chartObject_opts, _chartObject_opts1;
|
|
8515
|
+
zip.file(chartColorsPartName(chartObject.globalId), makeXmlChartColors((_chartObject_opts = chartObject.opts) === null || _chartObject_opts === void 0 ? void 0 : _chartObject_opts.chartColorStyle));
|
|
8516
|
+
zip.file(chartStylePartName(chartObject.globalId), makeXmlChartStyle((_chartObject_opts1 = chartObject.opts) === null || _chartObject_opts1 === void 0 ? void 0 : _chartObject_opts1.chartStyle));
|
|
8517
|
+
}
|
|
7612
8518
|
// 3: Done
|
|
7613
8519
|
resolve('');
|
|
7614
8520
|
}).catch((strErr)=>{
|
|
@@ -7621,6 +8527,8 @@ function makeNumberStyles(formats) {
|
|
|
7621
8527
|
|
|
7622
8528
|
|
|
7623
8529
|
|
|
8530
|
+
|
|
8531
|
+
|
|
7624
8532
|
;// CONCATENATED MODULE: ./src/vendor/fonteditor-core/common/lang.js
|
|
7625
8533
|
/**
|
|
7626
8534
|
* @file 语言相关函数
|
|
@@ -15922,7 +16830,7 @@ function imageDimensions(bytes) {
|
|
|
15922
16830
|
});
|
|
15923
16831
|
}
|
|
15924
16832
|
/** Select relations that still need their local or remote media encoded. */ function getMediaCandidates(layout) {
|
|
15925
|
-
return layout._relsMedia.filter((rel)
|
|
16833
|
+
return layout._relsMedia.filter((rel)=>!rel.isLinked && rel.type !== 'online' && !rel.data && (!rel.path || rel.path && !rel.path.includes('preencoded')));
|
|
15926
16834
|
}
|
|
15927
16835
|
/**
|
|
15928
16836
|
* Mark repeated source paths so only the first relation performs I/O.
|
|
@@ -19215,7 +20123,8 @@ function replyXml(reply, authors, fallbackDate) {
|
|
|
19215
20123
|
// is the absolute `/ppt/charts/chartN.xml` form reused as Content_Types PartName.
|
|
19216
20124
|
// PowerPoint writes the relative `../charts/chartN.xml`; absolute targets are valid but
|
|
19217
20125
|
// non-idiomatic and break stricter consumers (PR 1465 / eliasaronson).
|
|
19218
|
-
|
|
20126
|
+
const relType = isChartexType(rel.opts._type) ? OOXML_CHARTEX.relType : 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart';
|
|
20127
|
+
strXml += `<Relationship Id="rId${rel.rId}" Type="${relType}" Target="${rel.Target.replace(/^\/ppt\//, '../')}"/>`;
|
|
19219
20128
|
});
|
|
19220
20129
|
(slide._relsMedia || []).forEach((rel)=>{
|
|
19221
20130
|
const relRid = rel.rId.toString();
|
|
@@ -19224,17 +20133,19 @@ function replyXml(reply, authors, fallbackDate) {
|
|
|
19224
20133
|
strXml += '<Relationship Id="rId' + relRid + '" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/image" Target="' + rel.Target + '"/>';
|
|
19225
20134
|
} else if (rel.type.toLowerCase().includes('audio')) {
|
|
19226
20135
|
// As media has *TWO* rel entries per item, check for first one, if found add second rel with alt style
|
|
20136
|
+
const externalAttr = rel.isLinked ? ' TargetMode="External"' : '';
|
|
19227
20137
|
if (strXml.includes(' Target="' + rel.Target + '"')) {
|
|
19228
|
-
strXml += '<Relationship Id="rId' + relRid + '" Type="http://schemas.microsoft.com/office/2007/relationships/media" Target="' + rel.Target + '"/>';
|
|
20138
|
+
strXml += '<Relationship Id="rId' + relRid + '" Type="http://schemas.microsoft.com/office/2007/relationships/media" Target="' + rel.Target + '"' + externalAttr + '/>';
|
|
19229
20139
|
} else {
|
|
19230
|
-
strXml += '<Relationship Id="rId' + relRid + '" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/audio" Target="' + rel.Target + '"/>';
|
|
20140
|
+
strXml += '<Relationship Id="rId' + relRid + '" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/audio" Target="' + rel.Target + '"' + externalAttr + '/>';
|
|
19231
20141
|
}
|
|
19232
20142
|
} else if (rel.type.toLowerCase().includes('video')) {
|
|
19233
20143
|
// As media has *TWO* rel entries per item, check for first one, if found add second rel with alt style
|
|
20144
|
+
const externalAttr = rel.isLinked ? ' TargetMode="External"' : '';
|
|
19234
20145
|
if (strXml.includes(' Target="' + rel.Target + '"')) {
|
|
19235
|
-
strXml += '<Relationship Id="rId' + relRid + '" Type="http://schemas.microsoft.com/office/2007/relationships/media" Target="' + rel.Target + '"/>';
|
|
20146
|
+
strXml += '<Relationship Id="rId' + relRid + '" Type="http://schemas.microsoft.com/office/2007/relationships/media" Target="' + rel.Target + '"' + externalAttr + '/>';
|
|
19236
20147
|
} else {
|
|
19237
|
-
strXml += '<Relationship Id="rId' + relRid + '" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/video" Target="' + rel.Target + '"/>';
|
|
20148
|
+
strXml += '<Relationship Id="rId' + relRid + '" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/video" Target="' + rel.Target + '"' + externalAttr + '/>';
|
|
19238
20149
|
}
|
|
19239
20150
|
} else if (rel.type.toLowerCase().includes('online')) {
|
|
19240
20151
|
// As media has *TWO* rel entries per item, check for first one, if found add second rel with alt style
|
|
@@ -19441,6 +20352,171 @@ function unsignedInt(value) {
|
|
|
19441
20352
|
return `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\r\n<pc:chgInfo xmlns:pc="${CHANGES_INFO_NS}"/>`;
|
|
19442
20353
|
}
|
|
19443
20354
|
|
|
20355
|
+
;// CONCATENATED MODULE: ./src/xml/non-visual.ts
|
|
20356
|
+
/**
|
|
20357
|
+
* PptxGenJS: Non-visual drawing properties (`p:cNvPr`) and editing locks
|
|
20358
|
+
*
|
|
20359
|
+
* Every drawable object carries a `p:cNvPr` with its id, name, and alt text, and a sibling
|
|
20360
|
+
* `p:cNv*Pr` holding the lock element for its kind - `a:spLocks` for shapes, `a:picLocks` for
|
|
20361
|
+
* pictures, `a:graphicFrameLocks` for frames, `a:grpSpLocks` for groups, `a:cxnSpLocks` for
|
|
20362
|
+
* connectors. The lock attributes are shared, so one emitter serves all five.
|
|
20363
|
+
*/
|
|
20364
|
+
/** Lock attribute names, in the order the schema declares them */ const LOCK_ATTRS = [
|
|
20365
|
+
[
|
|
20366
|
+
'noGroup',
|
|
20367
|
+
'noGrp'
|
|
20368
|
+
],
|
|
20369
|
+
[
|
|
20370
|
+
'noSelect',
|
|
20371
|
+
'noSelect'
|
|
20372
|
+
],
|
|
20373
|
+
[
|
|
20374
|
+
'noRotate',
|
|
20375
|
+
'noRot'
|
|
20376
|
+
],
|
|
20377
|
+
[
|
|
20378
|
+
'noChangeAspect',
|
|
20379
|
+
'noChangeAspect'
|
|
20380
|
+
],
|
|
20381
|
+
[
|
|
20382
|
+
'noMove',
|
|
20383
|
+
'noMove'
|
|
20384
|
+
],
|
|
20385
|
+
[
|
|
20386
|
+
'noResize',
|
|
20387
|
+
'noResize'
|
|
20388
|
+
],
|
|
20389
|
+
[
|
|
20390
|
+
'noEditPoints',
|
|
20391
|
+
'noEditPoints'
|
|
20392
|
+
],
|
|
20393
|
+
[
|
|
20394
|
+
'noAdjustHandles',
|
|
20395
|
+
'noAdjustHandles'
|
|
20396
|
+
],
|
|
20397
|
+
[
|
|
20398
|
+
'noChangeArrowheads',
|
|
20399
|
+
'noChangeArrowheads'
|
|
20400
|
+
],
|
|
20401
|
+
[
|
|
20402
|
+
'noChangeShapeType',
|
|
20403
|
+
'noChangeShapeType'
|
|
20404
|
+
],
|
|
20405
|
+
[
|
|
20406
|
+
'noTextEdit',
|
|
20407
|
+
'noTextEdit'
|
|
20408
|
+
],
|
|
20409
|
+
[
|
|
20410
|
+
'noCrop',
|
|
20411
|
+
'noCrop'
|
|
20412
|
+
]
|
|
20413
|
+
];
|
|
20414
|
+
/** Which lock attributes each element actually permits */ const ALLOWED = {
|
|
20415
|
+
'a:spLocks': new Set([
|
|
20416
|
+
'noGrp',
|
|
20417
|
+
'noSelect',
|
|
20418
|
+
'noRot',
|
|
20419
|
+
'noChangeAspect',
|
|
20420
|
+
'noMove',
|
|
20421
|
+
'noResize',
|
|
20422
|
+
'noEditPoints',
|
|
20423
|
+
'noAdjustHandles',
|
|
20424
|
+
'noChangeArrowheads',
|
|
20425
|
+
'noChangeShapeType',
|
|
20426
|
+
'noTextEdit'
|
|
20427
|
+
]),
|
|
20428
|
+
'a:picLocks': new Set([
|
|
20429
|
+
'noGrp',
|
|
20430
|
+
'noSelect',
|
|
20431
|
+
'noRot',
|
|
20432
|
+
'noChangeAspect',
|
|
20433
|
+
'noMove',
|
|
20434
|
+
'noResize',
|
|
20435
|
+
'noEditPoints',
|
|
20436
|
+
'noAdjustHandles',
|
|
20437
|
+
'noChangeArrowheads',
|
|
20438
|
+
'noChangeShapeType',
|
|
20439
|
+
'noCrop'
|
|
20440
|
+
]),
|
|
20441
|
+
'a:graphicFrameLocks': new Set([
|
|
20442
|
+
'noGrp',
|
|
20443
|
+
'noSelect',
|
|
20444
|
+
'noChangeAspect',
|
|
20445
|
+
'noMove',
|
|
20446
|
+
'noResize',
|
|
20447
|
+
'noDrilldown'
|
|
20448
|
+
]),
|
|
20449
|
+
'a:grpSpLocks': new Set([
|
|
20450
|
+
'noGrp',
|
|
20451
|
+
'noSelect',
|
|
20452
|
+
'noRot',
|
|
20453
|
+
'noChangeAspect',
|
|
20454
|
+
'noMove',
|
|
20455
|
+
'noResize',
|
|
20456
|
+
'noUngrp'
|
|
20457
|
+
]),
|
|
20458
|
+
'a:cxnSpLocks': new Set([
|
|
20459
|
+
'noGrp',
|
|
20460
|
+
'noSelect',
|
|
20461
|
+
'noRot',
|
|
20462
|
+
'noChangeAspect',
|
|
20463
|
+
'noMove',
|
|
20464
|
+
'noResize',
|
|
20465
|
+
'noEditPoints',
|
|
20466
|
+
'noAdjustHandles',
|
|
20467
|
+
'noChangeArrowheads',
|
|
20468
|
+
'noChangeShapeType'
|
|
20469
|
+
])
|
|
20470
|
+
};
|
|
20471
|
+
/**
|
|
20472
|
+
* Create a lock element, or `''` when nothing is locked
|
|
20473
|
+
* - attributes the element does not permit are dropped: an unexpected one is a schema violation
|
|
20474
|
+
* @param {string} tag - lock element name for the object's kind
|
|
20475
|
+
* @param {ShapeLockProps} lock - lock props
|
|
20476
|
+
* @param {string} defaults - attributes the library already emits for this object
|
|
20477
|
+
* @returns {string} XML string
|
|
20478
|
+
*/ function genXmlLocks(tag, lock, defaults = '') {
|
|
20479
|
+
var _ALLOWED_tag;
|
|
20480
|
+
const allowed = (_ALLOWED_tag = ALLOWED[tag]) !== null && _ALLOWED_tag !== void 0 ? _ALLOWED_tag : new Set();
|
|
20481
|
+
let attrs = defaults;
|
|
20482
|
+
LOCK_ATTRS.forEach(([prop, attr])=>{
|
|
20483
|
+
if ((lock === null || lock === void 0 ? void 0 : lock[prop]) !== true) return;
|
|
20484
|
+
if (!allowed.has(attr)) {
|
|
20485
|
+
console.warn(`[pptxgenjs] \`${String(prop)}\` does not apply to this object type - ignored`);
|
|
20486
|
+
return;
|
|
20487
|
+
}
|
|
20488
|
+
// do not repeat an attribute the caller already gets by default
|
|
20489
|
+
if (defaults.includes(`${attr}="`)) return;
|
|
20490
|
+
attrs += ` ${attr}="1"`;
|
|
20491
|
+
});
|
|
20492
|
+
return attrs ? `<${tag}${attrs}/>` : '';
|
|
20493
|
+
}
|
|
20494
|
+
/**
|
|
20495
|
+
* Create the `p:cNvPr` element
|
|
20496
|
+
* @param {number} id - shape id, unique on the slide
|
|
20497
|
+
* @param {string} name - shape name shown in the selection pane (already XML-escaped by callers)
|
|
20498
|
+
* @param {NonVisualProps} props - non-visual options
|
|
20499
|
+
* @param {string} descr - alt-text description
|
|
20500
|
+
* @param {string} children - child elements (ex: hyperlinks); self-closes when empty
|
|
20501
|
+
* @returns {string} XML string
|
|
20502
|
+
*/ function genXmlCNvPr(id, name, props, descr = '', children = '') {
|
|
20503
|
+
let attrs = `id="${id}" name="${name}"`;
|
|
20504
|
+
// `descr` is the alt-text description; `title` is the separate alt-text title
|
|
20505
|
+
if (descr) attrs += ` descr="${encodeXmlEntities(descr)}"`;
|
|
20506
|
+
if (props === null || props === void 0 ? void 0 : props.title) attrs += ` title="${encodeXmlEntities(props.title)}"`;
|
|
20507
|
+
if ((props === null || props === void 0 ? void 0 : props.hidden) === true) attrs += ' hidden="1"';
|
|
20508
|
+
return children ? `<p:cNvPr ${attrs}>${children}</p:cNvPr>` : `<p:cNvPr ${attrs}/>`;
|
|
20509
|
+
}
|
|
20510
|
+
/**
|
|
20511
|
+
* Create `p:cNvSpPr`, carrying the text-box flag and any shape locks
|
|
20512
|
+
* @param {object} options - shape options
|
|
20513
|
+
* @returns {string} XML string
|
|
20514
|
+
*/ function genXmlCNvSpPr(options) {
|
|
20515
|
+
const txBox = (options === null || options === void 0 ? void 0 : options.isTextBox) ? ' txBox="1"' : '';
|
|
20516
|
+
const locks = genXmlLocks('a:spLocks', options === null || options === void 0 ? void 0 : options.lock);
|
|
20517
|
+
return locks ? `<p:cNvSpPr${txBox}>${locks}</p:cNvSpPr>` : `<p:cNvSpPr${txBox}/>`;
|
|
20518
|
+
}
|
|
20519
|
+
|
|
19444
20520
|
;// CONCATENATED MODULE: ./src/xml/slide.ts
|
|
19445
20521
|
function xml_slide_define_property(obj, key, value) {
|
|
19446
20522
|
if (key in obj) {
|
|
@@ -19499,11 +20575,33 @@ function slide_object_spread_props(target, source) {
|
|
|
19499
20575
|
|
|
19500
20576
|
|
|
19501
20577
|
|
|
20578
|
+
|
|
20579
|
+
|
|
19502
20580
|
function nvPrModIdExt(modId) {
|
|
19503
20581
|
return genXmlModIdExt(modId).replace(/^<p:extLst>|<\/p:extLst>$/g, '');
|
|
19504
20582
|
}
|
|
19505
20583
|
function genXmlNvPr(options, phXml = '', extraExts = []) {
|
|
19506
|
-
|
|
20584
|
+
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"' : '');
|
|
20585
|
+
return `<p:nvPr${attrs}>${phXml}${genXmlNvPrExtLst(options, extraExts)}</p:nvPr>`;
|
|
20586
|
+
}
|
|
20587
|
+
/**
|
|
20588
|
+
* Fallback shape for a chartex graphic frame (`mc:Fallback`).
|
|
20589
|
+
*
|
|
20590
|
+
* PowerPoint writes a rendered preview picture here, which this library cannot produce without a
|
|
20591
|
+
* rasterizer. A locked, non-editable text shape occupying the same box is the closest honest
|
|
20592
|
+
* substitute: a consumer that rejects the `mc:Choice` still sees where the chart is and why it is
|
|
20593
|
+
* not drawn, and cannot silently edit it into something that no longer matches the chart part.
|
|
20594
|
+
*/ function genXmlChartExFallback(shapeId, slideItemObj, box) {
|
|
20595
|
+
var _slideItemObj_options, _options_objectName, _options_altText;
|
|
20596
|
+
const options = (_slideItemObj_options = slideItemObj.options) !== null && _slideItemObj_options !== void 0 ? _slideItemObj_options : {};
|
|
20597
|
+
const name = (_options_objectName = options.objectName) !== null && _options_objectName !== void 0 ? _options_objectName : 'Chart';
|
|
20598
|
+
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.';
|
|
20599
|
+
// A chart's `title` is the chart title, not the alt-text title `p:cNvPr@title` carries.
|
|
20600
|
+
// `noTextEdit` is not optional: an edited fallback would no longer match the chart part.
|
|
20601
|
+
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>';
|
|
20602
|
+
}
|
|
20603
|
+
function genXmlCNvPrLinks(click, hover) {
|
|
20604
|
+
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
20605
|
}
|
|
19508
20606
|
const ImageSizingXml = {
|
|
19509
20607
|
cover: function(imgSize, boxDim) {
|
|
@@ -19584,10 +20682,6 @@ const ImageSizingXml = {
|
|
|
19584
20682
|
return opts.tableStyleId ? `<a:tblPr${attrs}><a:tableStyleId>${encodeXmlEntities(opts.tableStyleId)}</a:tableStyleId></a:tblPr>` : `<a:tblPr${attrs}/>`;
|
|
19585
20683
|
}
|
|
19586
20684
|
/**
|
|
19587
|
-
* Create the `a:ln` outline block for a shape/image
|
|
19588
|
-
* @param {ShapeLineProps} line - line options
|
|
19589
|
-
* @return {string} XML
|
|
19590
|
-
*/ /**
|
|
19591
20685
|
* Builds `<p14:trim>` / `<p14:fade>` / `<p14:bmkLst>` children of `<p14:media>` (MS-PPTX §2.3.3.14).
|
|
19592
20686
|
* Times are ST_UniversalTimeOffset (ms).
|
|
19593
20687
|
*/ function genXmlMediaExtras(opts) {
|
|
@@ -19597,7 +20691,34 @@ const ImageSizingXml = {
|
|
|
19597
20691
|
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
20692
|
return xml;
|
|
19599
20693
|
}
|
|
19600
|
-
|
|
20694
|
+
/**
|
|
20695
|
+
* One `a:tcPr` border line (`a:lnL`, `a:lnTlToBr`, ...)
|
|
20696
|
+
* - the four edges and the two diagonals share CT_LineProperties, so they share this emitter
|
|
20697
|
+
* @param {string} name - element name without the `a:` prefix
|
|
20698
|
+
* @param {BorderProps} border - border definition
|
|
20699
|
+
* @returns {string} XML
|
|
20700
|
+
*/ function genXmlCellBorder(name, border) {
|
|
20701
|
+
var _ref, _border_width, _border_color;
|
|
20702
|
+
if (border.type === 'none') return `<a:${name} w="0" cap="flat" cmpd="sng" algn="ctr"><a:noFill/></a:${name}>`;
|
|
20703
|
+
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;
|
|
20704
|
+
const borderTransparency = border.transparency;
|
|
20705
|
+
const borderAlpha = typeof borderTransparency === 'number' ? `<a:alpha val="${Math.round((100 - Math.min(100, Math.max(0, borderTransparency))) * 1000)}"/>` : '';
|
|
20706
|
+
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}>`;
|
|
20707
|
+
}
|
|
20708
|
+
/**
|
|
20709
|
+
* One `a:audioCd` endpoint (`a:st` or `a:end`).
|
|
20710
|
+
* - `@track` is required and is an `xsd:unsignedByte`, so it is clamped; `@time` defaults to 0
|
|
20711
|
+
*/ function genXmlAudioCdTime(tag, point) {
|
|
20712
|
+
var _ref;
|
|
20713
|
+
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)));
|
|
20714
|
+
const time = typeof (point === null || point === void 0 ? void 0 : point.time) === 'number' && isFinite(point.time) && point.time > 0 ? ` time="${Math.round(point.time)}"` : '';
|
|
20715
|
+
return `<${tag} track="${track}"${time}/>`;
|
|
20716
|
+
}
|
|
20717
|
+
/**
|
|
20718
|
+
* Create the `a:ln` outline block for a shape/image
|
|
20719
|
+
* @param {ShapeLineProps} line - line options
|
|
20720
|
+
* @return {string} XML
|
|
20721
|
+
*/ function genXmlLine(line) {
|
|
19601
20722
|
// ECMA-376 §5.1.2.1.34: `<a:ln>` carries `w` and `cap` attributes (cap = line ending style, issue #782)
|
|
19602
20723
|
const attrs = (line.width ? ` w="${valToPts(line.width)}"` : '') + (line.cap && [
|
|
19603
20724
|
'flat',
|
|
@@ -19622,15 +20743,20 @@ function genXmlLine(line) {
|
|
|
19622
20743
|
* Create a single `a:outerShdw` / `a:innerShdw` element (no `effectLst` wrapper).
|
|
19623
20744
|
* @note pure - unit conversion must NOT mutate the caller's options (issue #20)
|
|
19624
20745
|
*/ 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);
|
|
20746
|
+
var _shadow_offset, _shadow_angle, _shadow_opacity, _shadow_blur;
|
|
19628
20747
|
const offset = valToPts((_shadow_offset = shadow.offset) !== null && _shadow_offset !== void 0 ? _shadow_offset : 4);
|
|
19629
20748
|
const angle = Math.round(((_shadow_angle = shadow.angle) !== null && _shadow_angle !== void 0 ? _shadow_angle : 270) * 60000);
|
|
19630
20749
|
const opacity = Math.round(((_shadow_opacity = shadow.opacity) !== null && _shadow_opacity !== void 0 ? _shadow_opacity : 0.75) * 100000);
|
|
19631
20750
|
const color = shadow.color || DEF_TEXT_SHADOW.color;
|
|
20751
|
+
const colorXml = `<a:srgbClr val="${color}"><a:alpha val="${opacity}"/></a:srgbClr>`;
|
|
20752
|
+
if (shadow.type === 'preset') {
|
|
20753
|
+
if (!shadow.preset) return '';
|
|
20754
|
+
return `<a:prstShdw prst="${shadow.preset}" dist="${offset}" dir="${angle}">${colorXml}</a:prstShdw>`;
|
|
20755
|
+
}
|
|
20756
|
+
const type = shadow.type === 'inner' ? 'inner' : 'outer';
|
|
20757
|
+
const blur = valToPts((_shadow_blur = shadow.blur) !== null && _shadow_blur !== void 0 ? _shadow_blur : 8);
|
|
19632
20758
|
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}"
|
|
20759
|
+
return `<a:${type}Shdw ${attrs} blurRad="${blur}" dist="${offset}" dir="${angle}">${colorXml}</a:${type}Shdw>`;
|
|
19634
20760
|
}
|
|
19635
20761
|
/**
|
|
19636
20762
|
* Create `a:softEdge` element
|
|
@@ -19658,22 +20784,98 @@ function genXmlLine(line) {
|
|
|
19658
20784
|
return `<a:blur rad="${rad}"${grow}/>`;
|
|
19659
20785
|
}
|
|
19660
20786
|
/**
|
|
19661
|
-
* Create
|
|
19662
|
-
|
|
20787
|
+
* Create `a:fillOverlay` (CT_FillOverlayEffect). `@blend` and a fill are both required.
|
|
20788
|
+
*/ function genXmlFillOverlayElement(overlay) {
|
|
20789
|
+
if (!overlay.blend || !overlay.fill) return '';
|
|
20790
|
+
const fill = genXmlColorSelection(overlay.fill);
|
|
20791
|
+
return fill ? `<a:fillOverlay blend="${overlay.blend}">${fill}</a:fillOverlay>` : '';
|
|
20792
|
+
}
|
|
20793
|
+
/**
|
|
20794
|
+
* Create the shape/image effect block (blur + fillOverlay + glow + shadow + reflection + softEdge).
|
|
20795
|
+
* Child order follows ECMA-376 `CT_EffectList`: blur, fillOverlay, glow, innerShdw, outerShdw,
|
|
20796
|
+
* prstShdw, reflection, softEdge. `effectDag` replaces `effectLst` (EG_EffectProperties choice).
|
|
19663
20797
|
* @note pure - unit conversion must NOT be written back to the caller's options object (issue #20)
|
|
19664
20798
|
*/ function genXmlEffectLst(opts) {
|
|
19665
20799
|
const parts = [];
|
|
19666
20800
|
if (opts.blur && typeof opts.blur.radius === 'number') parts.push(genXmlBlurElement(opts.blur));
|
|
20801
|
+
if (opts.fillOverlay) {
|
|
20802
|
+
const overlay = genXmlFillOverlayElement(opts.fillOverlay);
|
|
20803
|
+
if (overlay) parts.push(overlay);
|
|
20804
|
+
}
|
|
19667
20805
|
const resolvedGlow = resolveGlowOptions(opts.glow);
|
|
19668
20806
|
if (resolvedGlow) parts.push(createGlowElement(resolvedGlow));
|
|
19669
20807
|
const shadow = opts.shadow;
|
|
19670
20808
|
if (shadow && shadow.type !== 'none') {
|
|
19671
|
-
|
|
20809
|
+
const shadowXml = genXmlShadowElement(shadow);
|
|
20810
|
+
if (shadowXml) parts.push(shadowXml);
|
|
19672
20811
|
}
|
|
19673
20812
|
if (opts.reflection) parts.push(genXmlReflectionElement(opts.reflection));
|
|
19674
20813
|
if (opts.softEdge) parts.push(genXmlSoftEdgeElement(opts.softEdge));
|
|
19675
20814
|
if (!parts.length) return '';
|
|
19676
|
-
|
|
20815
|
+
const xml = parts.join('');
|
|
20816
|
+
if (opts.effectDag) return `<a:effectDag type="${opts.effectDag.type === 'tree' ? 'tree' : 'sib'}">${xml}</a:effectDag>`;
|
|
20817
|
+
return `<a:effectLst>${xml}</a:effectLst>`;
|
|
20818
|
+
}
|
|
20819
|
+
/**
|
|
20820
|
+
* Theme style references for a shape (`p:style`).
|
|
20821
|
+
* CT_ShapeStyle requires all four children; an unset property references nothing (`idx="0"` / `none`).
|
|
20822
|
+
*/ function genXmlShapeStyle(style) {
|
|
20823
|
+
var _style_color;
|
|
20824
|
+
if (!style) return '';
|
|
20825
|
+
let color = (_style_color = style.color) !== null && _style_color !== void 0 ? _style_color : 'accent1';
|
|
20826
|
+
if (color === 'phClr') {
|
|
20827
|
+
console.warn('[pptxgenjs] `styleRef.color` cannot be `phClr` - it is the placeholder a theme reference resolves, not a color. Using `accent1`.');
|
|
20828
|
+
color = 'accent1';
|
|
20829
|
+
}
|
|
20830
|
+
let fontColor = style.fontColor;
|
|
20831
|
+
if (fontColor === 'phClr') {
|
|
20832
|
+
console.warn('[pptxgenjs] `styleRef.fontColor` cannot be `phClr` - using `lt1`.');
|
|
20833
|
+
fontColor = undefined;
|
|
20834
|
+
}
|
|
20835
|
+
const idx = (value)=>typeof value === 'number' && isFinite(value) && value > 0 ? Math.round(value) : 0;
|
|
20836
|
+
const matrixColor = createColorElement(color);
|
|
20837
|
+
const fontColorXml = fontColor ? createColorElement(fontColor) : '<a:schemeClr val="lt1"/>';
|
|
20838
|
+
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>';
|
|
20839
|
+
}
|
|
20840
|
+
/**
|
|
20841
|
+
* Recolor and correction effects for an image's `a:blip`.
|
|
20842
|
+
*/ function genXmlBlipRecolor(recolor) {
|
|
20843
|
+
if (!recolor) return '';
|
|
20844
|
+
let xml = '';
|
|
20845
|
+
if (Array.isArray(recolor.duotone)) {
|
|
20846
|
+
if (recolor.duotone.length === 2) xml += `<a:duotone>${recolor.duotone.map((color)=>createColorElement(color)).join('')}</a:duotone>`;
|
|
20847
|
+
else console.warn(`[pptxgenjs] image \`recolor.duotone\` needs exactly two colors - ${recolor.duotone.length} given, effect omitted`);
|
|
20848
|
+
}
|
|
20849
|
+
if (recolor.grayscale === true) xml += '<a:grayscl/>';
|
|
20850
|
+
const bright = typeof recolor.brightness === 'number' && isFinite(recolor.brightness) ? Math.round(Math.min(100, Math.max(-100, recolor.brightness)) * 1000) : undefined;
|
|
20851
|
+
const contrast = typeof recolor.contrast === 'number' && isFinite(recolor.contrast) ? Math.round(Math.min(100, Math.max(-100, recolor.contrast)) * 1000) : undefined;
|
|
20852
|
+
if (bright !== undefined || contrast !== undefined) {
|
|
20853
|
+
xml += `<a:lum${bright !== undefined ? ` bright="${bright}"` : ''}${contrast !== undefined ? ` contrast="${contrast}"` : ''}/>`;
|
|
20854
|
+
}
|
|
20855
|
+
if (typeof recolor.blackWhiteThreshold === 'number' && isFinite(recolor.blackWhiteThreshold)) {
|
|
20856
|
+
xml += `<a:biLevel thresh="${Math.round(Math.min(100, Math.max(0, recolor.blackWhiteThreshold)) * 1000)}"/>`;
|
|
20857
|
+
}
|
|
20858
|
+
if (recolor.colorChange) {
|
|
20859
|
+
if (recolor.colorChange.from && recolor.colorChange.to) {
|
|
20860
|
+
const useA = recolor.colorChange.useAlpha === false ? ' useA="0"' : '';
|
|
20861
|
+
xml += `<a:clrChange${useA}><a:clrFrom>${createColorElement(recolor.colorChange.from)}</a:clrFrom><a:clrTo>${createColorElement(recolor.colorChange.to)}</a:clrTo></a:clrChange>`;
|
|
20862
|
+
} else {
|
|
20863
|
+
console.warn('[pptxgenjs] image `recolor.colorChange` needs both `from` and `to` - effect omitted');
|
|
20864
|
+
}
|
|
20865
|
+
}
|
|
20866
|
+
return xml;
|
|
20867
|
+
}
|
|
20868
|
+
/**
|
|
20869
|
+
* Alpha + recolor effects for an image's `a:blip`.
|
|
20870
|
+
*/ function genXmlBlipEffects(transparency, alpha, recolor) {
|
|
20871
|
+
let xml = transparency ? `<a:alphaModFix amt="${Math.round((100 - transparency) * 1000)}"/>` : '';
|
|
20872
|
+
xml += genXmlBlipRecolor(recolor);
|
|
20873
|
+
if (!alpha) return xml;
|
|
20874
|
+
if (typeof alpha.replace === 'number' && isFinite(alpha.replace)) xml += `<a:alphaRepl a="${Math.round(Math.min(100, Math.max(0, alpha.replace)) * 1000)}"/>`;
|
|
20875
|
+
if (alpha.invert === true) xml += '<a:alphaInv/>';
|
|
20876
|
+
if (alpha.floor === true) xml += '<a:alphaFloor/>';
|
|
20877
|
+
if (alpha.ceiling === true) xml += '<a:alphaCeiling/>';
|
|
20878
|
+
return xml;
|
|
19677
20879
|
}
|
|
19678
20880
|
function findShapeCoord(list, id) {
|
|
19679
20881
|
if (id == null) return undefined;
|
|
@@ -19718,7 +20920,19 @@ function findShapeCoord(list, id) {
|
|
|
19718
20920
|
/**
|
|
19719
20921
|
* When a connector references shapes with numeric inch positions + rect anchors,
|
|
19720
20922
|
* compute the line's x/y/w/h and flip flags (ZentoSoft auto-layout).
|
|
19721
|
-
*/ function
|
|
20923
|
+
*/ function resolveConnectorObjectNames(line, coordinates) {
|
|
20924
|
+
if (line._sourceName) {
|
|
20925
|
+
const found = coordinates.find((item)=>item.objectName === line._sourceName);
|
|
20926
|
+
if (found) line.sourceId = found.id;
|
|
20927
|
+
else console.warn(`[pptxgenjs] connector start shape "${line._sourceName}" not found - attachment omitted`);
|
|
20928
|
+
}
|
|
20929
|
+
if (line._targetName) {
|
|
20930
|
+
const found = coordinates.find((item)=>item.objectName === line._targetName);
|
|
20931
|
+
if (found) line.targetId = found.id;
|
|
20932
|
+
else console.warn(`[pptxgenjs] connector end shape "${line._targetName}" not found - attachment omitted`);
|
|
20933
|
+
}
|
|
20934
|
+
}
|
|
20935
|
+
function applyConnectorAutoLayout(line, coordinates, presLayout) {
|
|
19722
20936
|
const source = findShapeCoord(coordinates, line.sourceId);
|
|
19723
20937
|
const target = findShapeCoord(coordinates, line.targetId);
|
|
19724
20938
|
if (!source || !target) return undefined;
|
|
@@ -19875,7 +21089,9 @@ function slideObjectToXml(slide) {
|
|
|
19875
21089
|
let intTableNum = 1;
|
|
19876
21090
|
// 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
21091
|
if (slide._bkgdImgRid) {
|
|
19878
|
-
|
|
21092
|
+
var _slide_background3;
|
|
21093
|
+
const bkgdEffects = genXmlBlipRecolor((_slide_background3 = slide.background) === null || _slide_background3 === void 0 ? void 0 : _slide_background3.recolor);
|
|
21094
|
+
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
21095
|
} 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
21096
|
// NOTE: `<a:effectLst/>` is required by PowerPoint (matches image-bg path above); omitting it triggers the repair dialog
|
|
19881
21097
|
strSlideXml += `<p:bg><p:bgPr>${genXmlColorSelection(slide.background)}<a:effectLst/></p:bgPr></p:bg>`;
|
|
@@ -19893,7 +21109,7 @@ function slideObjectToXml(slide) {
|
|
|
19893
21109
|
const shapeCoordinates = [];
|
|
19894
21110
|
const renderObjectList = (objects)=>{
|
|
19895
21111
|
objects.forEach((slideItemObj, idx)=>{
|
|
19896
|
-
var _slideItemObj_options, _slideItemObj_options1, _slide__slideLayout, _slideItemObj_options_line, _slideItemObj_options_sizing, _slideItemObj_options2;
|
|
21112
|
+
var _slideItemObj_options, _slideItemObj_options1, _slide__slideLayout, _slideItemObj_options_line, _slideItemObj_options_line1, _slideItemObj_options_sizing, _slideItemObj_options2;
|
|
19897
21113
|
let x = 0;
|
|
19898
21114
|
let y = 0;
|
|
19899
21115
|
let cx = getSmartParseNumber('75%', 'X', slide._presLayout);
|
|
@@ -19908,6 +21124,7 @@ function slideObjectToXml(slide) {
|
|
|
19908
21124
|
slideItemObj.options.sId = shapeId;
|
|
19909
21125
|
shapeCoordinates.push({
|
|
19910
21126
|
id: shapeId,
|
|
21127
|
+
objectName: slideItemObj.options.objectName,
|
|
19911
21128
|
position: {
|
|
19912
21129
|
x: slideItemObj.options.x,
|
|
19913
21130
|
y: slideItemObj.options.y,
|
|
@@ -19927,7 +21144,10 @@ function slideObjectToXml(slide) {
|
|
|
19927
21144
|
})[0];
|
|
19928
21145
|
}
|
|
19929
21146
|
// A: Geometry — connectors may auto-size from source/target shape boxes (ZentoSoft)
|
|
19930
|
-
|
|
21147
|
+
if ((_slideItemObj_options_line = slideItemObj.options.line) === null || _slideItemObj_options_line === void 0 ? void 0 : _slideItemObj_options_line.isConnector) {
|
|
21148
|
+
resolveConnectorObjectNames(slideItemObj.options.line, shapeCoordinates);
|
|
21149
|
+
}
|
|
21150
|
+
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
21151
|
if (connectorLayout) {
|
|
19932
21152
|
x = connectorLayout.x;
|
|
19933
21153
|
y = connectorLayout.y;
|
|
@@ -19987,7 +21207,7 @@ function slideObjectToXml(slide) {
|
|
|
19987
21207
|
switch(slideItemObj._type){
|
|
19988
21208
|
case (/* inlined export .SLIDE_OBJECT_TYPES.table */"table"):
|
|
19989
21209
|
{
|
|
19990
|
-
var _slideItemObj_arrTabRows, _slide__slideNum;
|
|
21210
|
+
var _slideItemObj_arrTabRows, _slide__slideNum, _slideItemObj_options_objectName;
|
|
19991
21211
|
arrTabRows = (_slideItemObj_arrTabRows = slideItemObj.arrTabRows) !== null && _slideItemObj_arrTabRows !== void 0 ? _slideItemObj_arrTabRows : [];
|
|
19992
21212
|
objTabOpts = slideItemObj.options;
|
|
19993
21213
|
intColCnt = 0;
|
|
@@ -20000,12 +21220,12 @@ function slideObjectToXml(slide) {
|
|
|
20000
21220
|
});
|
|
20001
21221
|
// STEP 1: Start Table XML
|
|
20002
21222
|
// NOTE: Non-numeric cNvPr id values will trigger "presentation needs repair" type warning in MS-PPT-2013
|
|
20003
|
-
strXml =
|
|
21223
|
+
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
21224
|
// When the table binds to a master/layout placeholder, emit `<p:ph type="tbl"/>` (ECMA-376 §4.4.1.33, issue #856)
|
|
20005
21225
|
const tblPh = placeholderObj ? genXmlPlaceholder(placeholderObj, slideItemObj.options) : '';
|
|
20006
21226
|
// MS-PPTX §2.3.1.19: each p14:modId must be unique on the slide (not a constant).
|
|
20007
21227
|
const tableModId = typeof slideItemObj.options.modId === 'number' ? slideItemObj.options.modId : TABLE_MOD_ID_BASE + idx;
|
|
20008
|
-
strXml +=
|
|
21228
|
+
strXml += `<p:cNvGraphicFramePr>${genXmlLocks('a:graphicFrameLocks', slideItemObj.options.lock, ' noGrp="1"')}</p:cNvGraphicFramePr>` + ` ${genXmlNvPr(slideItemObj.options, tblPh, [
|
|
20009
21229
|
nvPrModIdExt(tableModId)
|
|
20010
21230
|
])}` + '</p:nvGraphicFramePr>';
|
|
20011
21231
|
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 +21321,10 @@ function slideObjectToXml(slide) {
|
|
|
20101
21321
|
// A: Table Height provided without rowH? Then distribute rows
|
|
20102
21322
|
let intRowH = 0 // IMPORTANT: Default must be zero for auto-sizing to work
|
|
20103
21323
|
;
|
|
20104
|
-
|
|
20105
|
-
|
|
21324
|
+
// `rowH` is either one value for every row or a per-row array; `inch2Emu` resolves inches, EMU and unit-suffixed strings alike
|
|
21325
|
+
const rowHOpt = Array.isArray(objTabOpts.rowH) ? objTabOpts.rowH[rIdx] : objTabOpts.rowH;
|
|
21326
|
+
const rowHEmu = rowHOpt ? inch2Emu(rowHOpt) : NaN;
|
|
21327
|
+
if (!isNaN(rowHEmu)) intRowH = rowHEmu;
|
|
20106
21328
|
else if (itemOpts.cy || itemOpts.h) {
|
|
20107
21329
|
intRowH = Math.round((itemOpts.h ? inch2Emu(itemOpts.h) : typeof itemOpts.cy === 'number' ? itemOpts.cy : 1) / arrTabRows.length);
|
|
20108
21330
|
}
|
|
@@ -20181,9 +21403,10 @@ function slideObjectToXml(slide) {
|
|
|
20181
21403
|
* - Backwards-Compat: Oops! Discovered we were still using points for cell margin before v3.8.0 (UGH!)
|
|
20182
21404
|
* - We cant introduce a breaking change before v4.0, so...
|
|
20183
21405
|
*/ 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
|
-
|
|
21406
|
+
const cellOverflow = cellOpts.horzOverflow === 'overflow' || cellOpts.horzOverflow === 'clip' ? ` horzOverflow="${cellOpts.horzOverflow}"` : '';
|
|
21407
|
+
const cellAnchorCtr = cellOpts.anchorCtr === true ? ' anchorCtr="1"' : '';
|
|
20185
21408
|
// 4: Set CELL content and properties ==================================
|
|
20186
|
-
strXml += `<a:tc${cellSpanAttrStr}>${genXmlTextBody(cell)}<a:tcPr${cellMarginXml}${cellValign}${cellTextDir}>`;
|
|
21409
|
+
strXml += `<a:tc${cellSpanAttrStr}>${genXmlTextBody(cell)}<a:tcPr${cellMarginXml}${cellValign}${cellTextDir}${cellAnchorCtr}${cellOverflow}>`;
|
|
20187
21410
|
// strXml += `<a:tc${cellColspan}${cellRowspan}>${genXmlTextBody(cell)}<a:tcPr${cellMarginXml}${cellValign}${cellTextDir}>`
|
|
20188
21411
|
// FIXME: 20200525: ^^^
|
|
20189
21412
|
// <a:tcPr marL="38100" marR="38100" marT="38100" marB="38100" vert="vert270">
|
|
@@ -20208,18 +21431,29 @@ function slideObjectToXml(slide) {
|
|
|
20208
21431
|
name: 'lnB'
|
|
20209
21432
|
}
|
|
20210
21433
|
].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
|
-
}
|
|
21434
|
+
strXml += genXmlCellBorder(obj.name, border[obj.idx]);
|
|
20221
21435
|
});
|
|
20222
21436
|
}
|
|
21437
|
+
// 5b: Diagonals follow the four edges in the CT_TableCellProperties sequence, and are
|
|
21438
|
+
// written only when asked for - unlike the edges, which are always emitted as a set
|
|
21439
|
+
if (cellOpts.borderDiagonalDown) strXml += genXmlCellBorder('lnTlToBr', cellOpts.borderDiagonalDown);
|
|
21440
|
+
if (cellOpts.borderDiagonalUp) strXml += genXmlCellBorder('lnBlToTr', cellOpts.borderDiagonalUp);
|
|
21441
|
+
// 5c: `a:cell3D` follows the diagonals and precedes the fill
|
|
21442
|
+
if (cellOpts.cell3D) {
|
|
21443
|
+
var _cell3D_bevel;
|
|
21444
|
+
var _cell3D_lightRig;
|
|
21445
|
+
const cell3D = cellOpts.cell3D;
|
|
21446
|
+
const bevel = (_cell3D_bevel = cell3D.bevel) !== null && _cell3D_bevel !== void 0 ? _cell3D_bevel : {};
|
|
21447
|
+
let bevelAttrs = '';
|
|
21448
|
+
if (typeof bevel.width === 'number' && isFinite(bevel.width) && bevel.width >= 0) bevelAttrs += ` w="${inch2Emu(bevel.width)}"`;
|
|
21449
|
+
if (typeof bevel.height === 'number' && isFinite(bevel.height) && bevel.height >= 0) bevelAttrs += ` h="${inch2Emu(bevel.height)}"`;
|
|
21450
|
+
if (bevel.preset) bevelAttrs += ` prst="${bevel.preset}"`;
|
|
21451
|
+
// `rig` and `dir` are both required on CT_LightRig, so a partial rig is dropped rather
|
|
21452
|
+
// than emitted as an element PowerPoint would refuse to open
|
|
21453
|
+
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}"/>` : '';
|
|
21454
|
+
// `a:bevel` is required by the schema, so it is always written
|
|
21455
|
+
strXml += `<a:cell3D${cell3D.material ? ` prstMaterial="${cell3D.material}"` : ''}><a:bevel${bevelAttrs}/>${lightRig}</a:cell3D>`;
|
|
21456
|
+
}
|
|
20223
21457
|
// 6: Close cell Properties & Cell
|
|
20224
21458
|
strXml += cellFill;
|
|
20225
21459
|
strXml += ' </a:tcPr>';
|
|
@@ -20242,38 +21476,38 @@ function slideObjectToXml(slide) {
|
|
|
20242
21476
|
case (/* inlined export .SLIDE_OBJECT_TYPES.text */"text"):
|
|
20243
21477
|
case (/* inlined export .SLIDE_OBJECT_TYPES.placeholder */"placeholder"):
|
|
20244
21478
|
{
|
|
20245
|
-
var
|
|
20246
|
-
const isConnector = !!((
|
|
21479
|
+
var _slideItemObj_options_line2, _slideItemObj_options_styleRef;
|
|
21480
|
+
const isConnector = !!((_slideItemObj_options_line2 = slideItemObj.options.line) === null || _slideItemObj_options_line2 === void 0 ? void 0 : _slideItemObj_options_line2.isConnector);
|
|
20247
21481
|
// Lines can have zero cy, but text should not
|
|
20248
21482
|
if (!slideItemObj.options.line && cy === 0) cy = (/* inlined export .EMU */914400) * 0.3;
|
|
20249
21483
|
// Text margins are applied in addTextDefinition → `_bodyProp` (TRBL)
|
|
20250
21484
|
// A: Start SHAPE / CONNECTOR ============================================
|
|
20251
21485
|
if (isConnector) {
|
|
20252
|
-
var _ref, _ref1;
|
|
20253
|
-
var
|
|
21486
|
+
var _slideItemObj_options_objectName1, _ref, _ref1;
|
|
21487
|
+
var _slideItemObj_options_line3, _slideItemObj_options_line4, _slideItemObj_options_line5, _slideItemObj_options_line6;
|
|
20254
21488
|
strSlideXml += '<p:cxnSp>';
|
|
20255
|
-
strSlideXml += `<p:nvCxnSpPr
|
|
20256
|
-
|
|
21489
|
+
strSlideXml += `<p:nvCxnSpPr>${genXmlCNvPr(shapeId, String((_slideItemObj_options_objectName1 = slideItemObj.options.objectName) !== null && _slideItemObj_options_objectName1 !== void 0 ? _slideItemObj_options_objectName1 : ''), slideItemObj.options)}`;
|
|
21490
|
+
const cxnLocks = genXmlLocks('a:cxnSpLocks', slideItemObj.options.lock);
|
|
21491
|
+
const stId = (_slideItemObj_options_line3 = slideItemObj.options.line) === null || _slideItemObj_options_line3 === void 0 ? void 0 : _slideItemObj_options_line3.sourceId;
|
|
21492
|
+
const endId = (_slideItemObj_options_line4 = slideItemObj.options.line) === null || _slideItemObj_options_line4 === void 0 ? void 0 : _slideItemObj_options_line4.targetId;
|
|
21493
|
+
strSlideXml += `<p:cNvCxnSpPr>${cxnLocks}`;
|
|
21494
|
+
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}"/>`;
|
|
21495
|
+
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}"/>`;
|
|
21496
|
+
strSlideXml += '</p:cNvCxnSpPr>';
|
|
20257
21497
|
strSlideXml += `${genXmlNvPr(slideItemObj.options, '', [
|
|
20258
21498
|
nvPrModIdExt(slideItemObj.options.modId)
|
|
20259
21499
|
])}</p:nvCxnSpPr><p:spPr>`;
|
|
20260
21500
|
} else {
|
|
20261
|
-
var
|
|
21501
|
+
var _slideItemObj_options_objectName2;
|
|
21502
|
+
var _slideItemObj_options3;
|
|
20262
21503
|
strSlideXml += '<p:sp>';
|
|
20263
21504
|
// 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>';
|
|
21505
|
+
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
21506
|
// PowerPoint math zones are authored in text boxes; force txBox when OMML is present
|
|
20275
21507
|
const useTxBox = Boolean((_slideItemObj_options3 = slideItemObj.options) === null || _slideItemObj_options3 === void 0 ? void 0 : _slideItemObj_options3.isTextBox) || textRunsHaveOmml(slideItemObj.text);
|
|
20276
|
-
strSlideXml +=
|
|
21508
|
+
strSlideXml += genXmlCNvSpPr(slide_object_spread_props(xml_slide_object_spread({}, slideItemObj.options), {
|
|
21509
|
+
isTextBox: useTxBox
|
|
21510
|
+
}));
|
|
20277
21511
|
strSlideXml += genXmlNvPr(slideItemObj.options, slideItemObj._type === 'placeholder' ? genXmlPlaceholder(slideItemObj, slideItemObj.options) : genXmlPlaceholder(placeholderObj, slideItemObj.options), [
|
|
20278
21512
|
nvPrModIdExt(slideItemObj.options.modId)
|
|
20279
21513
|
]);
|
|
@@ -20285,7 +21519,7 @@ function slideObjectToXml(slide) {
|
|
|
20285
21519
|
if (!isConnector && slideItemObj.shape === 'custGeom') {
|
|
20286
21520
|
strSlideXml += genCustGeomXml(slideItemObj, cx, cy, slide);
|
|
20287
21521
|
} else {
|
|
20288
|
-
var _slideItemObj_options_line_curveadjust,
|
|
21522
|
+
var _slideItemObj_options_line_curveadjust, _slideItemObj_options_line7;
|
|
20289
21523
|
strSlideXml += '<a:prstGeom prst="' + slideItemObj.shape + '"><a:avLst>';
|
|
20290
21524
|
// `rectRadius: 0` is a valid sharp-corner adj (ECMA-376 §5.1.11 preset geom `gd name="adj"`).
|
|
20291
21525
|
if (typeof slideItemObj.options.rectRadius === 'number' && Number.isFinite(slideItemObj.options.rectRadius) && slideItemObj.options.rectRadius >= 0) {
|
|
@@ -20299,7 +21533,7 @@ function slideObjectToXml(slide) {
|
|
|
20299
21533
|
strSlideXml += `<a:gd name="adj3" fmla="val ${Math.round(slideItemObj.options.arcThicknessRatio * 50000)}" />`;
|
|
20300
21534
|
}
|
|
20301
21535
|
}
|
|
20302
|
-
if (isConnector && ((
|
|
21536
|
+
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
21537
|
slideItemObj.options.line.curveadjust.forEach((adj, i)=>{
|
|
20304
21538
|
strSlideXml += `<a:gd name="adj${i + 1}" fmla="val ${Math.round(Number(adj))}"/>`;
|
|
20305
21539
|
});
|
|
@@ -20307,20 +21541,26 @@ function slideObjectToXml(slide) {
|
|
|
20307
21541
|
strSlideXml += '</a:avLst></a:prstGeom>';
|
|
20308
21542
|
}
|
|
20309
21543
|
// Option: FILL
|
|
20310
|
-
|
|
21544
|
+
// With a fillRef and no explicit fill, omit the fill element so the theme inherits
|
|
21545
|
+
if (slideItemObj.options.fill) strSlideXml += genXmlColorSelection(slideItemObj.options.fill);
|
|
21546
|
+
else if (!((_slideItemObj_options_styleRef = slideItemObj.options.styleRef) === null || _slideItemObj_options_styleRef === void 0 ? void 0 : _slideItemObj_options_styleRef.fill)) strSlideXml += '<a:noFill/>';
|
|
20311
21547
|
// shape Type: LINE: line color
|
|
20312
21548
|
if (slideItemObj.options.line) strSlideXml += genXmlLine(slideItemObj.options.line);
|
|
20313
|
-
// EFFECTS: shadow / glow / softEdge / reflection
|
|
21549
|
+
// EFFECTS: shadow / glow / softEdge / reflection / fillOverlay / blur
|
|
20314
21550
|
// REF: @see http://officeopenxml.com/drwSp-effects.php
|
|
20315
21551
|
strSlideXml += genXmlEffectLst({
|
|
20316
21552
|
shadow: slideItemObj.options.shadow,
|
|
20317
21553
|
glow: slideItemObj.options.glow,
|
|
20318
21554
|
softEdge: slideItemObj.options.softEdge,
|
|
20319
21555
|
reflection: slideItemObj.options.reflection,
|
|
20320
|
-
blur: slideItemObj.options.blur
|
|
21556
|
+
blur: slideItemObj.options.blur,
|
|
21557
|
+
fillOverlay: slideItemObj.options.fillOverlay,
|
|
21558
|
+
effectDag: slideItemObj.options.effectDag
|
|
20321
21559
|
});
|
|
20322
21560
|
// B: Close shape Properties
|
|
20323
21561
|
strSlideXml += '</p:spPr>';
|
|
21562
|
+
// `p:style` follows `p:spPr` in CT_Shape / CT_Connector
|
|
21563
|
+
strSlideXml += genXmlShapeStyle(slideItemObj.options.styleRef);
|
|
20324
21564
|
if (isConnector) {
|
|
20325
21565
|
// Connectors have no text body
|
|
20326
21566
|
strSlideXml += '</p:cxnSp>';
|
|
@@ -20333,18 +21573,13 @@ function slideObjectToXml(slide) {
|
|
|
20333
21573
|
break;
|
|
20334
21574
|
}
|
|
20335
21575
|
case (/* inlined export .SLIDE_OBJECT_TYPES.image */"image"):
|
|
20336
|
-
var
|
|
21576
|
+
var _slideItemObj_options_objectName3;
|
|
21577
|
+
var _slideItemObj_options_lock;
|
|
20337
21578
|
strSlideXml += '<p:pic>';
|
|
20338
21579
|
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>';
|
|
21580
|
+
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));
|
|
21581
|
+
// `noChangeAspect` has always been emitted here; caller locks are added to it
|
|
21582
|
+
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
21583
|
strSlideXml += genXmlNvPr(slideItemObj.options, genXmlPlaceholder(placeholderObj, slideItemObj.options), [
|
|
20349
21584
|
nvPrModIdExt(slideItemObj.options.modId)
|
|
20350
21585
|
]);
|
|
@@ -20354,7 +21589,7 @@ function slideObjectToXml(slide) {
|
|
|
20354
21589
|
if ((slide._relsMedia || []).filter((rel)=>rel.rId === slideItemObj.imageRid)[0] && (slide._relsMedia || []).filter((rel)=>rel.rId === slideItemObj.imageRid)[0].extn === 'svg') {
|
|
20355
21590
|
var _slideItemObj_imageRid;
|
|
20356
21591
|
strSlideXml += `<a:blip r:embed="rId${((_slideItemObj_imageRid = slideItemObj.imageRid) !== null && _slideItemObj_imageRid !== void 0 ? _slideItemObj_imageRid : 0) - 1}">`;
|
|
20357
|
-
strSlideXml += slideItemObj.options.transparency
|
|
21592
|
+
strSlideXml += genXmlBlipEffects(slideItemObj.options.transparency, slideItemObj.options.alphaEffects, slideItemObj.options.recolor);
|
|
20358
21593
|
strSlideXml += ' <a:extLst>';
|
|
20359
21594
|
strSlideXml += ' <a:ext uri="{96DAC541-7B7A-43D3-8B79-37D633B846F1}">';
|
|
20360
21595
|
strSlideXml += ` <asvg:svgBlip xmlns:asvg="http://schemas.microsoft.com/office/drawing/2016/SVG/main" r:embed="rId${slideItemObj.imageRid}"/>`;
|
|
@@ -20363,7 +21598,7 @@ function slideObjectToXml(slide) {
|
|
|
20363
21598
|
strSlideXml += '</a:blip>';
|
|
20364
21599
|
} else {
|
|
20365
21600
|
strSlideXml += `<a:blip r:embed="rId${slideItemObj.imageRid}">`;
|
|
20366
|
-
strSlideXml += slideItemObj.options.transparency
|
|
21601
|
+
strSlideXml += genXmlBlipEffects(slideItemObj.options.transparency, slideItemObj.options.alphaEffects, slideItemObj.options.recolor);
|
|
20367
21602
|
strSlideXml += '</a:blip>';
|
|
20368
21603
|
}
|
|
20369
21604
|
if (sizing === null || sizing === void 0 ? void 0 : sizing.type) {
|
|
@@ -20423,26 +21658,53 @@ function slideObjectToXml(slide) {
|
|
|
20423
21658
|
}
|
|
20424
21659
|
// OUTLINE: picture border/frame (issue #35)
|
|
20425
21660
|
if (slideItemObj.options.line) strSlideXml += genXmlLine(slideItemObj.options.line);
|
|
20426
|
-
// EFFECTS: shadow / glow / softEdge / reflection
|
|
21661
|
+
// EFFECTS: shadow / glow / softEdge / reflection / fillOverlay / blur
|
|
20427
21662
|
strSlideXml += genXmlEffectLst({
|
|
20428
21663
|
shadow: slideItemObj.options.shadow,
|
|
20429
21664
|
glow: slideItemObj.options.glow,
|
|
20430
21665
|
softEdge: slideItemObj.options.softEdge,
|
|
20431
21666
|
reflection: slideItemObj.options.reflection,
|
|
20432
|
-
blur: slideItemObj.options.blur
|
|
21667
|
+
blur: slideItemObj.options.blur,
|
|
21668
|
+
fillOverlay: slideItemObj.options.fillOverlay,
|
|
21669
|
+
effectDag: slideItemObj.options.effectDag
|
|
20433
21670
|
});
|
|
20434
21671
|
strSlideXml += '</p:spPr>';
|
|
21672
|
+
strSlideXml += genXmlShapeStyle(slideItemObj.options.styleRef);
|
|
20435
21673
|
strSlideXml += '</p:pic>';
|
|
20436
21674
|
break;
|
|
20437
21675
|
case (/* inlined export .SLIDE_OBJECT_TYPES.media */"media"):
|
|
20438
|
-
if (slideItemObj.mtype === '
|
|
21676
|
+
if (slideItemObj.mtype === 'audioCd' || slideItemObj.mtype === 'wav') {
|
|
21677
|
+
var _slideItemObj__coverRid;
|
|
21678
|
+
// EG_Media is a choice, so these carry exactly one media element and no `p14:media`:
|
|
21679
|
+
// `a:audioCd` references the listener's drive and `a:wavAudioFile` is the legacy
|
|
21680
|
+
// embedded-WAV element, so neither has an embedded media part to point at
|
|
21681
|
+
const coverRid = (_slideItemObj__coverRid = slideItemObj._coverRid) !== null && _slideItemObj__coverRid !== void 0 ? _slideItemObj__coverRid : 2;
|
|
21682
|
+
strSlideXml += '<p:pic>';
|
|
21683
|
+
strSlideXml += ' <p:nvPicPr>';
|
|
21684
|
+
strSlideXml += `<p:cNvPr id="${coverRid}" name="${slideItemObj.options.objectName}"><a:hlinkClick r:id="" action="ppaction://media"/></p:cNvPr>`;
|
|
21685
|
+
strSlideXml += ' <p:cNvPicPr><a:picLocks noChangeAspect="1"/></p:cNvPicPr>';
|
|
21686
|
+
if (slideItemObj.mtype === 'audioCd') {
|
|
21687
|
+
const cd = slideItemObj.options.audioCd;
|
|
21688
|
+
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>`);
|
|
21689
|
+
} else {
|
|
21690
|
+
strSlideXml += genXmlNvPr(slideItemObj.options, `<a:wavAudioFile r:embed="rId${slideItemObj.mediaRid}"${slideItemObj.options.objectName ? ` name="${slideItemObj.options.objectName}"` : ''}/>`);
|
|
21691
|
+
}
|
|
21692
|
+
strSlideXml += ' </p:nvPicPr>';
|
|
21693
|
+
strSlideXml += ` <p:blipFill><a:blip r:embed="rId${coverRid}"/><a:stretch><a:fillRect/></a:stretch></p:blipFill>`;
|
|
21694
|
+
strSlideXml += ' <p:spPr>';
|
|
21695
|
+
strSlideXml += ` <a:xfrm${locationAttr}><a:off x="${x}" y="${y}"/><a:ext cx="${cx}" cy="${cy}"/></a:xfrm>`;
|
|
21696
|
+
strSlideXml += ' <a:prstGeom prst="rect"><a:avLst/></a:prstGeom>';
|
|
21697
|
+
strSlideXml += ' </p:spPr>';
|
|
21698
|
+
strSlideXml += '</p:pic>';
|
|
21699
|
+
} else if (slideItemObj.mtype === 'online') {
|
|
20439
21700
|
var _slideItemObj_mediaRid, _slideItemObj_mediaRid1;
|
|
21701
|
+
const contentType = slideItemObj.options.contentType ? ` contentType="${encodeXmlEntities(slideItemObj.options.contentType)}"` : '';
|
|
20440
21702
|
strSlideXml += '<p:pic>';
|
|
20441
21703
|
strSlideXml += ' <p:nvPicPr>';
|
|
20442
21704
|
// IMPORTANT: <p:cNvPr id="" value is critical - if its not the same number as preview image `rId`, PowerPoint throws error!
|
|
20443
21705
|
strSlideXml += `<p:cNvPr id="${((_slideItemObj_mediaRid = slideItemObj.mediaRid) !== null && _slideItemObj_mediaRid !== void 0 ? _slideItemObj_mediaRid : 0) + 2}" name="${slideItemObj.options.objectName}"/>`;
|
|
20444
21706
|
strSlideXml += ' <p:cNvPicPr/>';
|
|
20445
|
-
strSlideXml += genXmlNvPr(slideItemObj.options, `<a:videoFile r:link="rId${slideItemObj.mediaRid}"/>`);
|
|
21707
|
+
strSlideXml += genXmlNvPr(slideItemObj.options, `<a:videoFile r:link="rId${slideItemObj.mediaRid}"${contentType}/>`);
|
|
20446
21708
|
strSlideXml += ' </p:nvPicPr>';
|
|
20447
21709
|
// NOTE: `blip` is diferent than videos; also there's no preview "p:extLst" above but exists in videos
|
|
20448
21710
|
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 +21717,7 @@ function slideObjectToXml(slide) {
|
|
|
20455
21717
|
var _slideItemObj_mediaRid2, _slideItemObj_mediaRid3, _slideItemObj_mediaRid4, _slideItemObj_mediaRid5;
|
|
20456
21718
|
// ECMA-376: audio uses `<a:audioFile>`, video uses `<a:videoFile>` under nvPr.
|
|
20457
21719
|
const mediaFileTag = slideItemObj.mtype === 'audio' ? 'a:audioFile' : 'a:videoFile';
|
|
21720
|
+
const contentType = slideItemObj.options.contentType ? ` contentType="${encodeXmlEntities(slideItemObj.options.contentType)}"` : '';
|
|
20458
21721
|
strSlideXml += '<p:pic>';
|
|
20459
21722
|
strSlideXml += ' <p:nvPicPr>';
|
|
20460
21723
|
// IMPORTANT: <p:cNvPr id="" value is critical - if not the same number as preiew image rId, PowerPoint throws error!
|
|
@@ -20463,7 +21726,7 @@ function slideObjectToXml(slide) {
|
|
|
20463
21726
|
const mediaExtras = genXmlMediaExtras(slideItemObj.options);
|
|
20464
21727
|
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
21728
|
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 ? [
|
|
21729
|
+
strSlideXml += genXmlNvPr(slideItemObj.options, `<${mediaFileTag} r:link="rId${slideItemObj.mediaRid}"${contentType}/>`, narrationExt ? [
|
|
20467
21730
|
mediaExt,
|
|
20468
21731
|
narrationExt
|
|
20469
21732
|
] : [
|
|
@@ -20570,41 +21833,64 @@ function slideObjectToXml(slide) {
|
|
|
20570
21833
|
break;
|
|
20571
21834
|
}
|
|
20572
21835
|
case (/* inlined export .SLIDE_OBJECT_TYPES.chart */"chart"):
|
|
20573
|
-
|
|
20574
|
-
|
|
20575
|
-
|
|
20576
|
-
|
|
20577
|
-
|
|
20578
|
-
|
|
20579
|
-
|
|
20580
|
-
|
|
20581
|
-
|
|
20582
|
-
|
|
20583
|
-
|
|
20584
|
-
|
|
20585
|
-
|
|
20586
|
-
|
|
20587
|
-
|
|
20588
|
-
|
|
21836
|
+
{
|
|
21837
|
+
var _slideItemObj_options_objectName4;
|
|
21838
|
+
var _slideItemObj_options4;
|
|
21839
|
+
const chartType = (_slideItemObj_options4 = slideItemObj.options) === null || _slideItemObj_options4 === void 0 ? void 0 : _slideItemObj_options4._type;
|
|
21840
|
+
const isChartex = isChartexType(chartType);
|
|
21841
|
+
const graphicDataUri = isChartex ? OOXML_CHARTEX.ns : 'http://schemas.openxmlformats.org/drawingml/2006/chart';
|
|
21842
|
+
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"/>`;
|
|
21843
|
+
const chartLocks = genXmlLocks('a:graphicFrameLocks', slideItemObj.options.lock);
|
|
21844
|
+
let frameXml = '<p:graphicFrame>';
|
|
21845
|
+
frameXml += ' <p:nvGraphicFramePr>';
|
|
21846
|
+
frameXml += genXmlCNvPr(shapeId, String((_slideItemObj_options_objectName4 = slideItemObj.options.objectName) !== null && _slideItemObj_options_objectName4 !== void 0 ? _slideItemObj_options_objectName4 : ''), slideItemObj.options, slideItemObj.options.altText || '');
|
|
21847
|
+
frameXml += chartLocks ? ` <p:cNvGraphicFramePr>${chartLocks}</p:cNvGraphicFramePr>` : ' <p:cNvGraphicFramePr/>';
|
|
21848
|
+
frameXml += genXmlNvPr(slideItemObj.options, genXmlPlaceholder(placeholderObj, slideItemObj.options), [
|
|
21849
|
+
nvPrModIdExt(slideItemObj.options.modId)
|
|
21850
|
+
]);
|
|
21851
|
+
frameXml += ' </p:nvGraphicFramePr>';
|
|
21852
|
+
frameXml += ` <p:xfrm><a:off x="${x}" y="${y}"/><a:ext cx="${cx}" cy="${cy}"/></p:xfrm>`;
|
|
21853
|
+
frameXml += ' <a:graphic xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main">';
|
|
21854
|
+
frameXml += ` <a:graphicData uri="${graphicDataUri}">`;
|
|
21855
|
+
frameXml += ` ${chartRef}`;
|
|
21856
|
+
frameXml += ' </a:graphicData>';
|
|
21857
|
+
frameXml += ' </a:graphic>';
|
|
21858
|
+
frameXml += '</p:graphicFrame>';
|
|
21859
|
+
// A chartex frame replaces a standard graphic frame, so MS-PPTX 2.2 requires it be offered
|
|
21860
|
+
// through `mc:AlternateContent`. PowerPoint's own fallback is a rendered preview image, which
|
|
21861
|
+
// cannot be produced here - a locked text shape carrying the same message is the honest
|
|
21862
|
+
// equivalent for a consumer that does not understand the chartex namespace.
|
|
21863
|
+
strSlideXml += isChartex ? `<mc:AlternateContent xmlns:mc="${MC_NS}">` + `<mc:Choice xmlns:cx1="${chartExRequiresNs(chartType)}" Requires="cx1">` + frameXml + '</mc:Choice>' + `<mc:Fallback>${genXmlChartExFallback(shapeId, slideItemObj, {
|
|
21864
|
+
x,
|
|
21865
|
+
y,
|
|
21866
|
+
cx,
|
|
21867
|
+
cy
|
|
21868
|
+
})}</mc:Fallback>` + '</mc:AlternateContent>' : frameXml;
|
|
21869
|
+
break;
|
|
21870
|
+
}
|
|
20589
21871
|
case (/* inlined export .SLIDE_OBJECT_TYPES.group */"group"):
|
|
20590
21872
|
{
|
|
20591
21873
|
var _slideItemObj__objects;
|
|
20592
21874
|
// PresentationML `p:grpSp` (ECMA-376 §19.3.1.22): nvGrpSpPr + grpSpPr + children.
|
|
20593
21875
|
// Child coords are group-relative; chOff is 0,0 and chExt matches the group size.
|
|
20594
21876
|
strSlideXml += '<p:grpSp>';
|
|
20595
|
-
strSlideXml += `<p:nvGrpSpPr
|
|
20596
|
-
|
|
21877
|
+
strSlideXml += `<p:nvGrpSpPr>${genXmlCNvPr(shapeId, slideItemObj.options.objectName || `Group ${shapeId}`, slideItemObj.options)}`;
|
|
21878
|
+
const grpLocks = genXmlLocks('a:grpSpLocks', slideItemObj.options.lock);
|
|
21879
|
+
strSlideXml += (grpLocks ? `<p:cNvGrpSpPr>${grpLocks}</p:cNvGrpSpPr>` : '<p:cNvGrpSpPr/>') + `${genXmlNvPr(slideItemObj.options)}</p:nvGrpSpPr>`;
|
|
20597
21880
|
strSlideXml += '<p:grpSpPr>';
|
|
20598
21881
|
strSlideXml += `<a:xfrm${locationAttr}>`;
|
|
20599
21882
|
strSlideXml += `<a:off x="${x}" y="${y}"/><a:ext cx="${cx}" cy="${cy}"/>`;
|
|
20600
21883
|
strSlideXml += `<a:chOff x="0" y="0"/><a:chExt cx="${cx}" cy="${cy}"/>`;
|
|
20601
21884
|
strSlideXml += '</a:xfrm>';
|
|
21885
|
+
if (slideItemObj.options.fill) strSlideXml += genXmlColorSelection(slideItemObj.options.fill);
|
|
20602
21886
|
strSlideXml += genXmlEffectLst({
|
|
20603
21887
|
shadow: slideItemObj.options.shadow,
|
|
20604
21888
|
glow: slideItemObj.options.glow,
|
|
20605
21889
|
softEdge: slideItemObj.options.softEdge,
|
|
20606
21890
|
reflection: slideItemObj.options.reflection,
|
|
20607
|
-
blur: slideItemObj.options.blur
|
|
21891
|
+
blur: slideItemObj.options.blur,
|
|
21892
|
+
fillOverlay: slideItemObj.options.fillOverlay,
|
|
21893
|
+
effectDag: slideItemObj.options.effectDag
|
|
20608
21894
|
});
|
|
20609
21895
|
strSlideXml += '</p:grpSpPr>';
|
|
20610
21896
|
renderObjectList((_slideItemObj__objects = slideItemObj._objects) !== null && _slideItemObj__objects !== void 0 ? _slideItemObj__objects : []);
|
|
@@ -20713,6 +21999,20 @@ function package_object_spread(target) {
|
|
|
20713
21999
|
|
|
20714
22000
|
|
|
20715
22001
|
|
|
22002
|
+
|
|
22003
|
+
/**
|
|
22004
|
+
* Content-type overrides a chart needs: the chart itself plus, when requested, its style and colour-style parts.
|
|
22005
|
+
* - one helper because charts appear on slides, layouts and the master, and a part with no declared
|
|
22006
|
+
* content type is a repair-dialog cause
|
|
22007
|
+
*/ function chartContentTypes(rel) {
|
|
22008
|
+
const partContentType = isChartexType(rel.opts._type) ? OOXML_CHARTEX.partContentType : 'application/vnd.openxmlformats-officedocument.drawingml.chart+xml';
|
|
22009
|
+
let xml = `<Override PartName="${rel.Target}" ContentType="${partContentType}"/>`;
|
|
22010
|
+
if (wantsChartStyleParts(rel.opts)) {
|
|
22011
|
+
xml += `<Override PartName="/${chartColorsPartName(rel.globalId)}" ContentType="${CHART_STYLE.colorsContentType}"/>`;
|
|
22012
|
+
xml += `<Override PartName="/${chartStylePartName(rel.globalId)}" ContentType="${CHART_STYLE.styleContentType}"/>`;
|
|
22013
|
+
}
|
|
22014
|
+
return xml;
|
|
22015
|
+
}
|
|
20716
22016
|
/** MS-PPTX §2.2.6 showPr browseMode */ const URI_BROWSE_MODE = '{F99C55AA-B7CB-42B0-86F8-08522FDF87E8}';
|
|
20717
22017
|
/** MS-PPTX §2.2.6 showPr laserClr */ const URI_LASER_CLR = '{EC167BDD-8182-4AB7-AECC-EB403E3ABB37}';
|
|
20718
22018
|
/** MS-PPTX §2.2.6 sld laserTraceLst */ const URI_LASER_TRACE_LST = '{3A86A75C-4F4B-4683-9AE1-C65F6400EC91}';
|
|
@@ -20778,7 +22078,7 @@ function slideShowExtLst(slide) {
|
|
|
20778
22078
|
strXml += '<Default Extension="mp4" ContentType="video/mp4"/>'; // NOTE: Hard-Code this extension as it wont be created in loop below (as extn !== type)
|
|
20779
22079
|
slides.forEach((slide)=>{
|
|
20780
22080
|
(slide._relsMedia || []).forEach((rel)=>{
|
|
20781
|
-
if (rel.type !== 'image' && rel.type !== 'online' && rel.type !== 'chart' && rel.extn !== 'm4v' && !strXml.includes(rel.type)) {
|
|
22081
|
+
if (!rel.isLinked && rel.type !== 'image' && rel.type !== 'online' && rel.type !== 'chart' && rel.extn !== 'm4v' && !strXml.includes(rel.type)) {
|
|
20782
22082
|
strXml += '<Default Extension="' + rel.extn + '" ContentType="' + rel.type + '"/>';
|
|
20783
22083
|
}
|
|
20784
22084
|
});
|
|
@@ -20799,7 +22099,7 @@ function slideShowExtLst(slide) {
|
|
|
20799
22099
|
strXml += `<Override PartName="/ppt/slides/slide${idx + 1}.xml" ContentType="application/vnd.openxmlformats-officedocument.presentationml.slide+xml"/>`;
|
|
20800
22100
|
// Add charts if any
|
|
20801
22101
|
slide._relsChart.forEach((rel)=>{
|
|
20802
|
-
strXml +=
|
|
22102
|
+
strXml += chartContentTypes(rel);
|
|
20803
22103
|
});
|
|
20804
22104
|
});
|
|
20805
22105
|
// STEP 3: Core PPT
|
|
@@ -20812,7 +22112,7 @@ function slideShowExtLst(slide) {
|
|
|
20812
22112
|
slideLayouts.forEach((layout, idx)=>{
|
|
20813
22113
|
strXml += `<Override PartName="/ppt/slideLayouts/slideLayout${idx + 1}.xml" ContentType="application/vnd.openxmlformats-officedocument.presentationml.slideLayout+xml"/>`;
|
|
20814
22114
|
(layout._relsChart || []).forEach((rel)=>{
|
|
20815
|
-
strXml +=
|
|
22115
|
+
strXml += chartContentTypes(rel);
|
|
20816
22116
|
});
|
|
20817
22117
|
});
|
|
20818
22118
|
// STEP 5: Add notes slide(s)
|
|
@@ -20841,10 +22141,10 @@ function slideShowExtLst(slide) {
|
|
|
20841
22141
|
if (tracking === null || tracking === void 0 ? void 0 : tracking.revisionInfo) strXml += `<Override PartName="/ppt/revisionInfo.xml" ContentType="${REVISION_INFO_CONTENT_TYPE}"/>`;
|
|
20842
22142
|
if (tracking === null || tracking === void 0 ? void 0 : tracking.changesInfo) strXml += `<Override PartName="/ppt/changesInfo.xml" ContentType="${CHANGES_INFO_CONTENT_TYPE}"/>`;
|
|
20843
22143
|
((_ref = masterSlide === null || masterSlide === void 0 ? void 0 : masterSlide._relsChart) !== null && _ref !== void 0 ? _ref : []).forEach((rel)=>{
|
|
20844
|
-
strXml +=
|
|
22144
|
+
strXml += chartContentTypes(rel);
|
|
20845
22145
|
});
|
|
20846
22146
|
((_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)) {
|
|
22147
|
+
if (!rel.isLinked && rel.type !== 'image' && rel.type !== 'online' && rel.type !== 'chart' && rel.extn !== 'm4v' && !strXml.includes(rel.type)) {
|
|
20848
22148
|
strXml += ' <Default Extension="' + rel.extn + '" ContentType="' + rel.type + '"/>';
|
|
20849
22149
|
}
|
|
20850
22150
|
});
|
|
@@ -20864,22 +22164,46 @@ function slideShowExtLst(slide) {
|
|
|
20864
22164
|
<Relationship Id="rId3" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" Target="ppt/presentation.xml"/>
|
|
20865
22165
|
</Relationships>`;
|
|
20866
22166
|
}
|
|
22167
|
+
/**
|
|
22168
|
+
* Count text paragraphs across the deck for `app.xml`
|
|
22169
|
+
* - derived rather than exposed: the value is a fact about the deck, not a caller preference
|
|
22170
|
+
* @param {PresSlide[]} slides - presentation slides
|
|
22171
|
+
* @returns {number} paragraph count
|
|
22172
|
+
*/ function countParagraphs(slides) {
|
|
22173
|
+
return slides.reduce((total, slide)=>{
|
|
22174
|
+
var _slide__slideObjects;
|
|
22175
|
+
return total + ((_slide__slideObjects = slide._slideObjects) !== null && _slide__slideObjects !== void 0 ? _slide__slideObjects : []).reduce((count, obj)=>{
|
|
22176
|
+
var _obj_text;
|
|
22177
|
+
if (obj._type !== (/* inlined export .SLIDE_OBJECT_TYPES.text */"text") && obj._type !== (/* inlined export .SLIDE_OBJECT_TYPES.placeholder */"placeholder")) return count;
|
|
22178
|
+
return count + Math.max(1, ((_obj_text = obj.text) !== null && _obj_text !== void 0 ? _obj_text : []).length);
|
|
22179
|
+
}, 0);
|
|
22180
|
+
}, 0);
|
|
22181
|
+
}
|
|
20867
22182
|
/**
|
|
20868
22183
|
* Creates `docProps/app.xml`
|
|
20869
22184
|
* @param {PresSlide[]} slides - Presenation Slides
|
|
20870
22185
|
* @param {string} company - "Company" metadata
|
|
22186
|
+
* @param {DocumentProps} [props] - optional extended properties
|
|
20871
22187
|
* @returns XML
|
|
20872
|
-
*/ function makeXmlApp(slides, company) {
|
|
22188
|
+
*/ function makeXmlApp(slides, company, props) {
|
|
20873
22189
|
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
|
-
|
|
22190
|
+
${(props === null || props === void 0 ? void 0 : props.template) ? `<Template>${encodeXmlEntities(props.template)}</Template>` : ''}
|
|
22191
|
+
${(props === null || props === void 0 ? void 0 : props.manager) ? `<Manager>${encodeXmlEntities(props.manager)}</Manager>` : ''}
|
|
22192
|
+
<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
22193
|
<Words>0</Words>
|
|
20876
22194
|
<Application>Microsoft Office PowerPoint</Application>
|
|
20877
22195
|
<PresentationFormat>On-screen Show (16:9)</PresentationFormat>
|
|
20878
|
-
<Paragraphs
|
|
22196
|
+
<Paragraphs>${countParagraphs(slides)}</Paragraphs>
|
|
20879
22197
|
<Slides>${slides.length}</Slides>
|
|
20880
|
-
<Notes>${slides.
|
|
20881
|
-
|
|
20882
|
-
|
|
22198
|
+
<Notes>${slides.filter((slide)=>{
|
|
22199
|
+
var _slide__slideObjects;
|
|
22200
|
+
return ((_slide__slideObjects = slide._slideObjects) !== null && _slide__slideObjects !== void 0 ? _slide__slideObjects : []).some((obj)=>obj._type === (/* inlined export .SLIDE_OBJECT_TYPES.notes */"notes"));
|
|
22201
|
+
}).length}</Notes>
|
|
22202
|
+
<HiddenSlides>${slides.filter((slide)=>slide.hidden).length}</HiddenSlides>
|
|
22203
|
+
<MMClips>${slides.reduce((sum, slide)=>{
|
|
22204
|
+
var _slide__slideObjects;
|
|
22205
|
+
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;
|
|
22206
|
+
}, 0)}</MMClips>
|
|
20883
22207
|
<ScaleCrop>false</ScaleCrop>
|
|
20884
22208
|
<HeadingPairs>
|
|
20885
22209
|
<vt:vector size="6" baseType="variant">
|
|
@@ -20902,6 +22226,7 @@ function slideShowExtLst(slide) {
|
|
|
20902
22226
|
<Company>${encodeXmlEntities(company)}</Company>
|
|
20903
22227
|
<LinksUpToDate>false</LinksUpToDate>
|
|
20904
22228
|
<SharedDoc>false</SharedDoc>
|
|
22229
|
+
${(props === null || props === void 0 ? void 0 : props.hyperlinkBase) ? `<HyperlinkBase>${encodeXmlEntities(props.hyperlinkBase)}</HyperlinkBase>` : ''}
|
|
20905
22230
|
<HyperlinksChanged>false</HyperlinksChanged>
|
|
20906
22231
|
<AppVersion>16.0000</AppVersion>
|
|
20907
22232
|
</Properties>`;
|
|
@@ -20914,14 +22239,23 @@ function slideShowExtLst(slide) {
|
|
|
20914
22239
|
* @param {string} revision - metadata value
|
|
20915
22240
|
* @param {Date} [created] - OPC `dcterms:created` (defaults to now)
|
|
20916
22241
|
* @param {Date} [modified] - OPC `dcterms:modified` (defaults to now)
|
|
22242
|
+
* @param {DocumentProps} [props] - optional extra core properties
|
|
20917
22243
|
* @returns XML
|
|
20918
|
-
*/ function makeXmlCore(title, subject, author, revision, created, modified) {
|
|
22244
|
+
*/ function makeXmlCore(title, subject, author, revision, created, modified, props) {
|
|
20919
22245
|
const createdAt = (created !== null && created !== void 0 ? created : new Date()).toISOString().replace(/\.\d\d\dZ/, 'Z');
|
|
20920
22246
|
const modifiedAt = (modified !== null && modified !== void 0 ? modified : new Date()).toISOString().replace(/\.\d\d\dZ/, 'Z');
|
|
20921
22247
|
return `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
20922
22248
|
<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
22249
|
<dc:title>${encodeXmlEntities(title)}</dc:title>
|
|
20924
22250
|
<dc:subject>${encodeXmlEntities(subject)}</dc:subject>
|
|
22251
|
+
${(props === null || props === void 0 ? void 0 : props.description) ? `<dc:description>${encodeXmlEntities(props.description)}</dc:description>` : ''}
|
|
22252
|
+
${(props === null || props === void 0 ? void 0 : props.keywords) ? `<cp:keywords>${encodeXmlEntities(props.keywords)}</cp:keywords>` : ''}
|
|
22253
|
+
${(props === null || props === void 0 ? void 0 : props.category) ? `<cp:category>${encodeXmlEntities(props.category)}</cp:category>` : ''}
|
|
22254
|
+
${(props === null || props === void 0 ? void 0 : props.contentStatus) ? `<cp:contentStatus>${encodeXmlEntities(props.contentStatus)}</cp:contentStatus>` : ''}
|
|
22255
|
+
${(props === null || props === void 0 ? void 0 : props.version) ? `<cp:version>${encodeXmlEntities(props.version)}</cp:version>` : ''}
|
|
22256
|
+
${(props === null || props === void 0 ? void 0 : props.language) ? `<dc:language>${encodeXmlEntities(props.language)}</dc:language>` : ''}
|
|
22257
|
+
${(props === null || props === void 0 ? void 0 : props.identifier) ? `<dc:identifier>${encodeXmlEntities(props.identifier)}</dc:identifier>` : ''}
|
|
22258
|
+
${(props === null || props === void 0 ? void 0 : props.lastPrinted) ? `<cp:lastPrinted>${encodeXmlEntities(props.lastPrinted)}</cp:lastPrinted>` : ''}
|
|
20925
22259
|
<dc:creator>${encodeXmlEntities(author)}</dc:creator>
|
|
20926
22260
|
<cp:lastModifiedBy>${encodeXmlEntities(author)}</cp:lastModifiedBy>
|
|
20927
22261
|
<cp:revision>${revision}</cp:revision>
|
|
@@ -20970,7 +22304,7 @@ function slideShowExtLst(slide) {
|
|
|
20970
22304
|
const entries = [];
|
|
20971
22305
|
((_slide__slideObjects = slide._slideObjects) !== null && _slide__slideObjects !== void 0 ? _slide__slideObjects : []).forEach((obj)=>{
|
|
20972
22306
|
var _obj_mediaRid;
|
|
20973
|
-
if (obj._type !== (/* inlined export .SLIDE_OBJECT_TYPES.media */"media") || obj.mtype
|
|
22307
|
+
if (obj._type !== (/* inlined export .SLIDE_OBJECT_TYPES.media */"media") || obj.mtype !== 'audio' && obj.mtype !== 'video') return;
|
|
20974
22308
|
const o = obj.options;
|
|
20975
22309
|
// Defaults are all false: no timing node unless at least one playback flag is set.
|
|
20976
22310
|
if (!o || !(o.autoplay || o.loop || o.fullScreen || o.mute)) return;
|
|
@@ -21105,10 +22439,29 @@ function collectSlideAnimations(slide) {
|
|
|
21105
22439
|
* @param {SlideLayout} layout - slide layout (master)
|
|
21106
22440
|
* @return {string} XML
|
|
21107
22441
|
*/ function makeXmlLayout(layout) {
|
|
22442
|
+
// `preserve` has always been written as "1", so it stays on unless the caller turns it off
|
|
22443
|
+
let attrs = layout.preserve === false ? '' : ' preserve="1"';
|
|
22444
|
+
if (layout.layoutType) attrs += ` type="${layout.layoutType}"`;
|
|
22445
|
+
if (layout.matchingName) attrs += ` matchingName="${encodeXmlEntities(layout.matchingName)}"`;
|
|
22446
|
+
// both default to true in the schema, so only the "off" case is written
|
|
22447
|
+
if (layout.showMasterShapes === false) attrs += ' showMasterSp="0"';
|
|
22448
|
+
if (layout.showMasterPlaceholderAnimation === false) attrs += ' showMasterPhAnim="0"';
|
|
22449
|
+
if (layout.userDrawn === true) attrs += ' userDrawn="1"';
|
|
22450
|
+
// CT_ColorMapping requires all twelve attributes, so a partial override is filled from the
|
|
22451
|
+
// identity map - which is exactly what inheriting `a:masterClrMapping` means
|
|
22452
|
+
const clrMapOvr = layout.colorMapOverride ? `<p:clrMapOvr><a:overrideClrMapping${Object.entries(DEF_COLOR_MAP).map(([slot, fallback])=>{
|
|
22453
|
+
var _ref;
|
|
22454
|
+
var _layout_colorMapOverride;
|
|
22455
|
+
return ` ${slot}="${(_ref = (_layout_colorMapOverride = layout.colorMapOverride) === null || _layout_colorMapOverride === void 0 ? void 0 : _layout_colorMapOverride[slot]) !== null && _ref !== void 0 ? _ref : fallback}"`;
|
|
22456
|
+
}).join('')}/></p:clrMapOvr>` : '<p:clrMapOvr><a:masterClrMapping/></p:clrMapOvr>';
|
|
22457
|
+
const transitionXml = genXmlTransition(layout);
|
|
22458
|
+
const hasP14 = transitionXml.includes('p14:') || transitionXml.includes('xmlns:p14');
|
|
22459
|
+
const ns = hasP14 ? ` xmlns:p14="${P14_NS}"` : '';
|
|
22460
|
+
// CT_SlideLayout sequence: cSld, clrMapOvr, transition, timing, hf, extLst
|
|
21108
22461
|
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"
|
|
22462
|
+
<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
22463
|
${slideObjectToXml(layout)}
|
|
21111
|
-
|
|
22464
|
+
${clrMapOvr}${transitionXml}</p:sldLayout>`;
|
|
21112
22465
|
}
|
|
21113
22466
|
/**
|
|
21114
22467
|
* Creates Slide Master 1 (`ppt/slideMasters/slideMaster1.xml`)
|
|
@@ -21179,6 +22532,7 @@ const NOTES_GUIDE_URI = '{2D200454-40CA-4A62-9FC3-DE9A4176ACB9}';
|
|
|
21179
22532
|
* @param {IPresentationProps} pres - presentation
|
|
21180
22533
|
* @return {string} XML
|
|
21181
22534
|
*/ function makeXmlPresentation(pres) {
|
|
22535
|
+
var _pres_kinsoku;
|
|
21182
22536
|
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
22537
|
// STEP 1: Add slide master (SPEC: tag 1 under <presentation>)
|
|
21184
22538
|
strXml += '<p:sldMasterIdLst><p:sldMasterId id="2147483648" r:id="rId1"/></p:sldMasterIdLst>';
|
|
@@ -21202,8 +22556,26 @@ const NOTES_GUIDE_URI = '{2D200454-40CA-4A62-9FC3-DE9A4176ACB9}';
|
|
|
21202
22556
|
// Presentations open without warning without this line, but then they aren't previewed in Finder or viewable on iOS.
|
|
21203
22557
|
strXml += `<p:notesMasterIdLst><p:notesMasterId r:id="rId${pres.slides.length + 2}"/></p:notesMasterIdLst>`;
|
|
21204
22558
|
// STEP 4: Add sizes
|
|
21205
|
-
|
|
22559
|
+
// `@type` records which preset the dimensions match; omitted when the caller does not say
|
|
22560
|
+
strXml += `<p:sldSz cx="${pres.presLayout.width}" cy="${pres.presLayout.height}"${pres.slideSizeType ? ` type="${pres.slideSizeType}"` : ''}/>`;
|
|
21206
22561
|
strXml += `<p:notesSz cx="${pres.presLayout.height}" cy="${pres.presLayout.width}"/>`;
|
|
22562
|
+
// CT_Presentation sequence puts these between `notesSz` and `defaultTextStyle` (photoAlbum, kinsoku)
|
|
22563
|
+
if (pres.photoAlbum) {
|
|
22564
|
+
const album = pres.photoAlbum;
|
|
22565
|
+
let attrs = '';
|
|
22566
|
+
if (album.blackWhite === true) attrs += ' bw="1"';
|
|
22567
|
+
if (album.showCaptions === true) attrs += ' showCaptions="1"';
|
|
22568
|
+
if (album.layout) attrs += ` layout="${album.layout}"`;
|
|
22569
|
+
if (album.frame) attrs += ` frame="${album.frame}"`;
|
|
22570
|
+
strXml += `<p:photoAlbum${attrs}/>`;
|
|
22571
|
+
}
|
|
22572
|
+
// `invalStChars` and `invalEndChars` are required on CT_Kinsoku, so a partial value is dropped
|
|
22573
|
+
// rather than emitted as an element PowerPoint would refuse to open
|
|
22574
|
+
if (((_pres_kinsoku = pres.kinsoku) === null || _pres_kinsoku === void 0 ? void 0 : _pres_kinsoku.invalidStartChars) && pres.kinsoku.invalidEndChars) {
|
|
22575
|
+
const kin = pres.kinsoku;
|
|
22576
|
+
const lang = kin.lang ? ` lang="${encodeXmlEntities(kin.lang)}"` : '';
|
|
22577
|
+
strXml += `<p:kinsoku${lang} invalStChars="${encodeXmlEntities(kin.invalidStartChars)}" invalEndChars="${encodeXmlEntities(kin.invalidEndChars)}"/>`;
|
|
22578
|
+
}
|
|
21207
22579
|
// STEP 5: Add text styles
|
|
21208
22580
|
strXml += '<p:defaultTextStyle>';
|
|
21209
22581
|
for(let idy = 1; idy < 10; idy++){
|
|
@@ -21243,10 +22615,28 @@ const NOTES_GUIDE_URI = '{2D200454-40CA-4A62-9FC3-DE9A4176ACB9}';
|
|
|
21243
22615
|
* Create `ppt/presProps.xml`
|
|
21244
22616
|
* @return {string} XML
|
|
21245
22617
|
*/ function makeXmlPresProps(pres) {
|
|
21246
|
-
// CT_PresentationProperties sequence:
|
|
22618
|
+
// CT_PresentationProperties sequence: htmlPubPr, webPr, prnPr, showPr, clrMru, extLst.
|
|
22619
|
+
// Opt-in: emit nothing extra unless set. prnPr/clrMru live here (not on CT_Presentation).
|
|
22620
|
+
const prnPr = makeXmlPrnPr(pres);
|
|
21247
22621
|
const showPr = makeXmlShowPr(pres);
|
|
22622
|
+
const clrMru = makeXmlClrMru(pres);
|
|
21248
22623
|
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>`;
|
|
22624
|
+
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>`;
|
|
22625
|
+
}
|
|
22626
|
+
function makeXmlPrnPr(pres) {
|
|
22627
|
+
if (!(pres === null || pres === void 0 ? void 0 : pres.printProps)) return '';
|
|
22628
|
+
const prn = pres.printProps;
|
|
22629
|
+
let attrs = '';
|
|
22630
|
+
if (prn.what) attrs += ` prnWhat="${prn.what}"`;
|
|
22631
|
+
if (prn.colorMode) attrs += ` clrMode="${prn.colorMode}"`;
|
|
22632
|
+
if (prn.hiddenSlides === true) attrs += ' hiddenSlides="1"';
|
|
22633
|
+
if (prn.scaleToFitPaper === true) attrs += ' scaleToFitPaper="1"';
|
|
22634
|
+
if (prn.frameSlides === true) attrs += ' frameSlides="1"';
|
|
22635
|
+
return `<p:prnPr${attrs}/>`;
|
|
22636
|
+
}
|
|
22637
|
+
function makeXmlClrMru(pres) {
|
|
22638
|
+
if (!Array.isArray(pres === null || pres === void 0 ? void 0 : pres.recentColors) || pres.recentColors.length === 0) return '';
|
|
22639
|
+
return `<p:clrMru>${pres.recentColors.map((color)=>createColorElement(color)).join('')}</p:clrMru>`;
|
|
21250
22640
|
}
|
|
21251
22641
|
/**
|
|
21252
22642
|
* `p:showPr` for slide-show options, or '' when none are set.
|
|
@@ -21295,14 +22685,144 @@ function makeXmlPresPropsExtLst(pres) {
|
|
|
21295
22685
|
* Create `ppt/tableStyles.xml`
|
|
21296
22686
|
* @see: http://openxmldeveloper.org/discussions/formats/f/13/p/2398/8107.aspx
|
|
21297
22687
|
* @return {string} XML
|
|
21298
|
-
*/
|
|
21299
|
-
|
|
22688
|
+
*/ /**
|
|
22689
|
+
* The GUID `a:tblStyleLst@def` has always carried - PowerPoint's "Medium Style 2 - Accent 1"
|
|
22690
|
+
*/ const DEF_TABLE_STYLE_ID = '{5C22544A-7EE6-4342-B048-85BDC9FD1C3A}';
|
|
22691
|
+
/**
|
|
22692
|
+
* CT_TableStyle fixes this child order, and it is neither alphabetical nor the intuitive one:
|
|
22693
|
+
* `lastCol` precedes `firstCol`, and `firstRow` sits between `swCell` and `neCell`.
|
|
22694
|
+
*/ const TABLE_STYLE_PARTS = [
|
|
22695
|
+
[
|
|
22696
|
+
'wholeTable',
|
|
22697
|
+
'wholeTbl'
|
|
22698
|
+
],
|
|
22699
|
+
[
|
|
22700
|
+
'band1H',
|
|
22701
|
+
'band1H'
|
|
22702
|
+
],
|
|
22703
|
+
[
|
|
22704
|
+
'band2H',
|
|
22705
|
+
'band2H'
|
|
22706
|
+
],
|
|
22707
|
+
[
|
|
22708
|
+
'band1V',
|
|
22709
|
+
'band1V'
|
|
22710
|
+
],
|
|
22711
|
+
[
|
|
22712
|
+
'band2V',
|
|
22713
|
+
'band2V'
|
|
22714
|
+
],
|
|
22715
|
+
[
|
|
22716
|
+
'lastCol',
|
|
22717
|
+
'lastCol'
|
|
22718
|
+
],
|
|
22719
|
+
[
|
|
22720
|
+
'firstCol',
|
|
22721
|
+
'firstCol'
|
|
22722
|
+
],
|
|
22723
|
+
[
|
|
22724
|
+
'lastRow',
|
|
22725
|
+
'lastRow'
|
|
22726
|
+
],
|
|
22727
|
+
[
|
|
22728
|
+
'seCell',
|
|
22729
|
+
'seCell'
|
|
22730
|
+
],
|
|
22731
|
+
[
|
|
22732
|
+
'swCell',
|
|
22733
|
+
'swCell'
|
|
22734
|
+
],
|
|
22735
|
+
[
|
|
22736
|
+
'firstRow',
|
|
22737
|
+
'firstRow'
|
|
22738
|
+
],
|
|
22739
|
+
[
|
|
22740
|
+
'neCell',
|
|
22741
|
+
'neCell'
|
|
22742
|
+
],
|
|
22743
|
+
[
|
|
22744
|
+
'nwCell',
|
|
22745
|
+
'nwCell'
|
|
22746
|
+
]
|
|
22747
|
+
];
|
|
22748
|
+
/** CT_TableCellBorderStyle child order */ const TABLE_STYLE_BORDERS = [
|
|
22749
|
+
'left',
|
|
22750
|
+
'right',
|
|
22751
|
+
'top',
|
|
22752
|
+
'bottom',
|
|
22753
|
+
'insideH',
|
|
22754
|
+
'insideV'
|
|
22755
|
+
];
|
|
22756
|
+
/**
|
|
22757
|
+
* One part of a table style (`a:wholeTbl`, `a:band1H`, ...).
|
|
22758
|
+
* - `a:tcTxStyle` precedes `a:tcStyle`; inside the cell style, `a:tcBdr` precedes the fill
|
|
22759
|
+
*/ function genXmlTableStylePart(tag, part) {
|
|
22760
|
+
// `b`/`i` are ST_OnOffStyleType: an unset property means "def", i.e. leave it to the theme
|
|
22761
|
+
const bold = typeof part.bold === 'boolean' ? ` b="${part.bold ? 'on' : 'off'}"` : '';
|
|
22762
|
+
const italic = typeof part.italic === 'boolean' ? ` i="${part.italic ? 'on' : 'off'}"` : '';
|
|
22763
|
+
const txStyle = bold || italic || part.color ? `<a:tcTxStyle${bold}${italic}>${part.color ? createColorElement(part.color) : ''}</a:tcTxStyle>` : '';
|
|
22764
|
+
const borders = TABLE_STYLE_BORDERS.filter((edge)=>{
|
|
22765
|
+
var _part_borders;
|
|
22766
|
+
return (_part_borders = part.borders) === null || _part_borders === void 0 ? void 0 : _part_borders[edge];
|
|
22767
|
+
}).map((edge)=>{
|
|
22768
|
+
var _part_borders;
|
|
22769
|
+
const line = (_part_borders = part.borders) === null || _part_borders === void 0 ? void 0 : _part_borders[edge];
|
|
22770
|
+
return line ? `<a:${edge}>${genXmlLine(line)}</a:${edge}>` : '';
|
|
22771
|
+
}).join('');
|
|
22772
|
+
const fill = part.fill ? `<a:fill>${genXmlColorSelection(part.fill)}</a:fill>` : '';
|
|
22773
|
+
const cellStyle = borders || fill ? `<a:tcStyle>${borders ? `<a:tcBdr>${borders}</a:tcBdr>` : ''}${fill}</a:tcStyle>` : '';
|
|
22774
|
+
return txStyle || cellStyle ? `<a:${tag}>${txStyle}${cellStyle}</a:${tag}>` : '';
|
|
22775
|
+
}
|
|
22776
|
+
/**
|
|
22777
|
+
* Creates `ppt/tableStyles.xml`
|
|
22778
|
+
* - with no custom styles this is the same self-closing stub earlier versions wrote
|
|
22779
|
+
* @param {TableStyleProps[]} [styles] - custom table style definitions
|
|
22780
|
+
* @return {string} XML
|
|
22781
|
+
*/ function makeXmlTableStyles(styles) {
|
|
22782
|
+
const valid = (styles !== null && styles !== void 0 ? styles : []).filter((style)=>{
|
|
22783
|
+
var _ref;
|
|
22784
|
+
// `@styleId` is an ST_Guid and `@styleName` is required; a malformed id would be rejected on open
|
|
22785
|
+
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 : '')) {
|
|
22786
|
+
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`);
|
|
22787
|
+
return false;
|
|
22788
|
+
}
|
|
22789
|
+
if (!style.name) {
|
|
22790
|
+
console.warn(`[pptxgenjs] table style ${style.id} has no \`name\` - ignored`);
|
|
22791
|
+
return false;
|
|
22792
|
+
}
|
|
22793
|
+
return true;
|
|
22794
|
+
});
|
|
22795
|
+
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}"`;
|
|
22796
|
+
if (valid.length === 0) return `${head}/>`;
|
|
22797
|
+
const body = valid.map((style)=>{
|
|
22798
|
+
const parts = TABLE_STYLE_PARTS.map(([prop, tag])=>{
|
|
22799
|
+
const part = style[prop];
|
|
22800
|
+
return part && typeof part === 'object' ? genXmlTableStylePart(tag, part) : '';
|
|
22801
|
+
}).join('');
|
|
22802
|
+
return `<a:tblStyle styleId="${style.id}" styleName="${encodeXmlEntities(style.name)}">${parts}</a:tblStyle>`;
|
|
22803
|
+
}).join('');
|
|
22804
|
+
return `${head}>${body}</a:tblStyleLst>`;
|
|
21300
22805
|
}
|
|
21301
22806
|
/**
|
|
21302
22807
|
* Creates `ppt/viewProps.xml`
|
|
22808
|
+
* - the hardcoded literal is kept when the caller sets no `viewProps`, so default packages stay byte-identical
|
|
21303
22809
|
* @return {string} XML
|
|
21304
|
-
*/ function makeXmlViewProps() {
|
|
21305
|
-
|
|
22810
|
+
*/ function makeXmlViewProps(pres) {
|
|
22811
|
+
var _view_guides;
|
|
22812
|
+
if (!(pres === null || pres === void 0 ? void 0 : pres.viewProps)) {
|
|
22813
|
+
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>`;
|
|
22814
|
+
}
|
|
22815
|
+
const view = pres.viewProps;
|
|
22816
|
+
const zoom = typeof view.zoom === 'number' && isFinite(view.zoom) && view.zoom > 0 ? Math.round(view.zoom) : 136;
|
|
22817
|
+
const grid = typeof view.gridSpacing === 'number' && isFinite(view.gridSpacing) && view.gridSpacing > 0 ? inch2Emu(view.gridSpacing) : 76200;
|
|
22818
|
+
const snapGrid = view.snapToGrid === true ? '1' : '0';
|
|
22819
|
+
const snapObj = view.snapToObjects === false ? '0' : '1';
|
|
22820
|
+
const showGuides = view.showGuides === true ? ' showGuides="1"' : '';
|
|
22821
|
+
const showComments = view.showComments === false ? ' showComments="0"' : '';
|
|
22822
|
+
const lastView = view.lastView ? ` lastView="${view.lastView}"` : '';
|
|
22823
|
+
// `p:guideLst` is the classic guide list, distinct from the MS-PPTX `p15:sldGuideLst` extension
|
|
22824
|
+
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('');
|
|
22825
|
+
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
22826
|
}
|
|
21307
22827
|
|
|
21308
22828
|
;// CONCATENATED MODULE: ./src/xml/index.ts
|
|
@@ -21312,6 +22832,7 @@ function makeXmlPresPropsExtLst(pres) {
|
|
|
21312
22832
|
|
|
21313
22833
|
|
|
21314
22834
|
|
|
22835
|
+
|
|
21315
22836
|
;// CONCATENATED MODULE: ./src/pptxgen.ts
|
|
21316
22837
|
function pptxgen_asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
21317
22838
|
try {
|
|
@@ -21495,6 +23016,12 @@ class PptxGenJS {
|
|
|
21495
23016
|
get rtlMode() {
|
|
21496
23017
|
return this._rtlMode;
|
|
21497
23018
|
}
|
|
23019
|
+
set tableStyles(value) {
|
|
23020
|
+
this._tableStyles = value;
|
|
23021
|
+
}
|
|
23022
|
+
get tableStyles() {
|
|
23023
|
+
return this._tableStyles;
|
|
23024
|
+
}
|
|
21498
23025
|
get firstSlideNum() {
|
|
21499
23026
|
return this._firstSlideNum;
|
|
21500
23027
|
}
|
|
@@ -21790,7 +23317,15 @@ class PptxGenJS {
|
|
|
21790
23317
|
_slideNumberProps: propsClone.slideNumber || null,
|
|
21791
23318
|
_slideObjects: [],
|
|
21792
23319
|
background: propsClone.background || null,
|
|
21793
|
-
bkgd: propsClone.bkgd || null
|
|
23320
|
+
bkgd: propsClone.bkgd || null,
|
|
23321
|
+
layoutType: propsClone.layoutType,
|
|
23322
|
+
matchingName: propsClone.matchingName,
|
|
23323
|
+
preserve: propsClone.preserve,
|
|
23324
|
+
showMasterShapes: propsClone.showMasterShapes,
|
|
23325
|
+
showMasterPlaceholderAnimation: propsClone.showMasterPlaceholderAnimation,
|
|
23326
|
+
userDrawn: propsClone.userDrawn,
|
|
23327
|
+
colorMapOverride: propsClone.colorMapOverride,
|
|
23328
|
+
transition: propsClone.transition
|
|
21794
23329
|
};
|
|
21795
23330
|
// STEP 1: Create the Slide Master/Layout
|
|
21796
23331
|
createSlideMaster(propsClone, newLayout);
|
|
@@ -21826,7 +23361,7 @@ class PptxGenJS {
|
|
|
21826
23361
|
*/ pptxgen_define_property(this, "_layout", void 0);
|
|
21827
23362
|
/**
|
|
21828
23363
|
* PptxGenJS Library Version
|
|
21829
|
-
*/ pptxgen_define_property(this, "_version", (/* inlined export .VERSION */"4.
|
|
23364
|
+
*/ pptxgen_define_property(this, "_version", (/* inlined export .VERSION */"4.2.0"));
|
|
21830
23365
|
/**
|
|
21831
23366
|
* @type {string}
|
|
21832
23367
|
*/ pptxgen_define_property(this, "_author", void 0);
|
|
@@ -21859,6 +23394,7 @@ class PptxGenJS {
|
|
|
21859
23394
|
* Whether Right-to-Left (RTL) mode is enabled
|
|
21860
23395
|
* @type {boolean}
|
|
21861
23396
|
*/ pptxgen_define_property(this, "_rtlMode", void 0);
|
|
23397
|
+
/** tableStyles - custom table style definitions written into `ppt/tableStyles.xml` */ pptxgen_define_property(this, "_tableStyles", void 0);
|
|
21862
23398
|
/**
|
|
21863
23399
|
* Starting slide number (`p:presentation@firstSlideNum`)
|
|
21864
23400
|
* @default 1
|
|
@@ -21894,6 +23430,13 @@ class PptxGenJS {
|
|
|
21894
23430
|
* Notes-page alignment guides (MS-PPTX §2.4.1.3). Emitted as `p15:notesGuideLst`.
|
|
21895
23431
|
* @example pptx.notesGuides = [{ orient: 'horz', pos: 2 }]
|
|
21896
23432
|
*/ pptxgen_define_property(this, "notesGuides", []);
|
|
23433
|
+
/** Additional document properties written to `docProps`. */ pptxgen_define_property(this, "documentProps", void 0);
|
|
23434
|
+
/** Slide-size preset (`p:sldSz@type`). */ pptxgen_define_property(this, "slideSizeType", void 0);
|
|
23435
|
+
/** Photo-album mode (`p:photoAlbum`). */ pptxgen_define_property(this, "photoAlbum", void 0);
|
|
23436
|
+
/** East Asian line-breaking rules (`p:kinsoku`). */ pptxgen_define_property(this, "kinsoku", void 0);
|
|
23437
|
+
/** Print defaults (`p:prnPr` on `presentationPr`). */ pptxgen_define_property(this, "printProps", void 0);
|
|
23438
|
+
/** Recently-used colours (`p:clrMru` on `presentationPr`). */ pptxgen_define_property(this, "recentColors", void 0);
|
|
23439
|
+
/** View properties (`ppt/viewProps.xml`). Unset keeps the previous hardcoded viewPr. */ pptxgen_define_property(this, "viewProps", void 0);
|
|
21897
23440
|
/**
|
|
21898
23441
|
* Modern comment authors (MS-PPTX §2.16). Emitted to `ppt/authors.xml`.
|
|
21899
23442
|
* Auto-populated from slide `addComment` author names if left empty.
|
|
@@ -21975,7 +23518,7 @@ class PptxGenJS {
|
|
|
21975
23518
|
*/ pptxgen_define_property(this, "createChartMediaRels", (slide, zip, chartPromises, mediaPaths)=>{
|
|
21976
23519
|
slide._relsChart.forEach((rel)=>chartPromises.push(createExcelWorksheet(rel, zip)));
|
|
21977
23520
|
slide._relsMedia.forEach((rel)=>{
|
|
21978
|
-
if (rel.type !== 'online' && rel.type !== 'hyperlink') {
|
|
23521
|
+
if (!rel.isLinked && rel.type !== 'online' && rel.type !== 'hyperlink') {
|
|
21979
23522
|
var _data_split_pop;
|
|
21980
23523
|
// A: Loop vars
|
|
21981
23524
|
let data = rel.data && typeof rel.data === 'string' ? rel.data : '';
|
|
@@ -22077,16 +23620,16 @@ class PptxGenJS {
|
|
|
22077
23620
|
};
|
|
22078
23621
|
zip.file('[Content_Types].xml', makeXmlContTypes(this.slides, this.slideLayouts, this.masterSlide, trackingParts)); // TODO: pass only `this` like below! 20200206
|
|
22079
23622
|
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
|
|
23623
|
+
zip.file('docProps/app.xml', makeXmlApp(this.slides, this.company, this.documentProps)); // TODO: pass only `this` like below! 20200206
|
|
23624
|
+
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
23625
|
zip.file('ppt/_rels/presentation.xml.rels', makeXmlPresentationRels(this.slides, trackingParts));
|
|
22083
23626
|
zip.file('ppt/theme/theme1.xml', makeXmlTheme(this));
|
|
22084
23627
|
// notesMaster gets its own theme part (Office repair creates theme2 when notesMaster shares theme1; Juliussssssss 9bdfe09).
|
|
22085
23628
|
zip.file('ppt/theme/theme2.xml', makeXmlTheme(this, 'notes'));
|
|
22086
23629
|
zip.file('ppt/presentation.xml', makeXmlPresentation(this));
|
|
22087
23630
|
zip.file('ppt/presProps.xml', makeXmlPresProps(this));
|
|
22088
|
-
zip.file('ppt/tableStyles.xml', makeXmlTableStyles());
|
|
22089
|
-
zip.file('ppt/viewProps.xml', makeXmlViewProps());
|
|
23631
|
+
zip.file('ppt/tableStyles.xml', makeXmlTableStyles(this._tableStyles));
|
|
23632
|
+
zip.file('ppt/viewProps.xml', makeXmlViewProps(this));
|
|
22090
23633
|
// C: Create a Layout/Master/Rel/Slide file for each SlideLayout and Slide
|
|
22091
23634
|
this.slideLayouts.forEach((layout, idx)=>{
|
|
22092
23635
|
zip.file(`ppt/slideLayouts/slideLayout${idx + 1}.xml`, makeXmlLayout(layout));
|
|
@@ -22253,6 +23796,7 @@ class PptxGenJS {
|
|
|
22253
23796
|
addTable: notOnMaster,
|
|
22254
23797
|
addText: notOnMaster,
|
|
22255
23798
|
addGroup: notOnMaster,
|
|
23799
|
+
addConnector: notOnMaster,
|
|
22256
23800
|
addWordArt: notOnMaster,
|
|
22257
23801
|
addTransition: notOnMaster,
|
|
22258
23802
|
addAnimation: notOnMaster,
|