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.es.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* PptxGenJS 4.
|
|
1
|
+
/* PptxGenJS 4.2.0 @ 2026-08-24T12:56:09.653Z */
|
|
2
2
|
|
|
3
3
|
import { JSZip } from "@node-projects/jszip";
|
|
4
4
|
import { parseXml } from "@rgrove/parse-xml";
|
|
@@ -15,6 +15,34 @@ const ONEPT = 12700 // One (1) point (pt)
|
|
|
15
15
|
const CRLF = '\r\n' // AKA: Chr(13) & Chr(10)
|
|
16
16
|
;
|
|
17
17
|
const LAYOUT_IDX_SERIES_BASE = 2147483649;
|
|
18
|
+
/** ECMA-376 20.1.10.55 ST_RectAlignment — where a tiled picture fill starts */ const TILE_ALIGNMENTS = new Set([
|
|
19
|
+
'tl',
|
|
20
|
+
't',
|
|
21
|
+
'tr',
|
|
22
|
+
'l',
|
|
23
|
+
'ctr',
|
|
24
|
+
'r',
|
|
25
|
+
'bl',
|
|
26
|
+
'b',
|
|
27
|
+
'br'
|
|
28
|
+
]);
|
|
29
|
+
/**
|
|
30
|
+
* ECMA-376 20.1.6.2 CT_ColorMapping - the identity map, which is what `a:masterClrMapping` means
|
|
31
|
+
* - all twelve attributes are required, so a partial `colorMapOverride` is filled from this
|
|
32
|
+
*/ const DEF_COLOR_MAP = Object.freeze({
|
|
33
|
+
bg1: 'lt1',
|
|
34
|
+
tx1: 'dk1',
|
|
35
|
+
bg2: 'lt2',
|
|
36
|
+
tx2: 'dk2',
|
|
37
|
+
accent1: 'accent1',
|
|
38
|
+
accent2: 'accent2',
|
|
39
|
+
accent3: 'accent3',
|
|
40
|
+
accent4: 'accent4',
|
|
41
|
+
accent5: 'accent5',
|
|
42
|
+
accent6: 'accent6',
|
|
43
|
+
hlink: 'hlink',
|
|
44
|
+
folHlink: 'folHlink'
|
|
45
|
+
});
|
|
18
46
|
const REGEX_HEX_COLOR = /^[0-9a-fA-F]{6}$/;
|
|
19
47
|
const LINEH_MODIFIER = 1.67 // AKA: Golden Ratio Typography
|
|
20
48
|
;
|
|
@@ -90,6 +118,51 @@ const AXIS_ID_VALUE_SECONDARY = '2094734553';
|
|
|
90
118
|
const AXIS_ID_CATEGORY_PRIMARY = '2094734554';
|
|
91
119
|
const AXIS_ID_CATEGORY_SECONDARY = '2094734555';
|
|
92
120
|
const AXIS_ID_SERIES_PRIMARY = '2094734556';
|
|
121
|
+
/**
|
|
122
|
+
* Chart style and chart colour-style parts (MS-ODRAWXML)
|
|
123
|
+
* - verified against Microsoft's own `ChartStylePart`/`ChartColorStylePart` definitions in
|
|
124
|
+
* dotnet/Open-XML-SDK, cross-checked against LibreOffice, rubyXL and OpenXLSX
|
|
125
|
+
* - note the asymmetry: the namespace is dated 2012, the relationships 2011. That is correct.
|
|
126
|
+
*/ const CHART_STYLE = Object.freeze({
|
|
127
|
+
ns: 'http://schemas.microsoft.com/office/drawing/2012/chartStyle',
|
|
128
|
+
styleContentType: 'application/vnd.ms-office.chartstyle+xml',
|
|
129
|
+
colorsContentType: 'application/vnd.ms-office.chartcolorstyle+xml',
|
|
130
|
+
styleRelType: 'http://schemas.microsoft.com/office/2011/relationships/chartStyle',
|
|
131
|
+
colorsRelType: 'http://schemas.microsoft.com/office/2011/relationships/chartColorStyle'
|
|
132
|
+
});
|
|
133
|
+
/**
|
|
134
|
+
* ChartEx (PowerPoint 2016+) package contract - MS-ODRAWXML 2.1.
|
|
135
|
+
*
|
|
136
|
+
* These chart types have no ECMA-376 representation: they live in their own `cx:chartSpace` part with a
|
|
137
|
+
* Microsoft content type and relationship type, and the slide-level `p:graphicFrame` must sit inside an
|
|
138
|
+
* `mc:AlternateContent` so consumers that predate them still get a fallback.
|
|
139
|
+
*
|
|
140
|
+
* The `requires` namespace is the schema generation a consumer must understand before it may take the
|
|
141
|
+
* `mc:Choice`; funnel arrived a revision after the 2016 launch set, so it gates on a later one.
|
|
142
|
+
*/ const OOXML_CHARTEX = {
|
|
143
|
+
/** `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',
|
|
144
|
+
partContentType: 'application/vnd.ms-office.chartex+xml',
|
|
145
|
+
relType: 'http://schemas.microsoft.com/office/2014/relationships/chartEx',
|
|
146
|
+
/** `mc:Choice@Requires` namespace for the Office 2016 launch layouts */ requires2016: 'http://schemas.microsoft.com/office/drawing/2015/9/8/chartex',
|
|
147
|
+
/** `mc:Choice@Requires` namespace for funnel, which shipped a schema revision later */ requiresFunnel: 'http://schemas.microsoft.com/office/drawing/2015/10/21/chartex'
|
|
148
|
+
};
|
|
149
|
+
/** `cx:series@layoutId` per chart type - a histogram is a `clusteredColumn` layout carrying `cx:binning` */ const CHARTEX_LAYOUT_ID = {
|
|
150
|
+
boxWhisker: 'boxWhisker',
|
|
151
|
+
funnel: 'funnel',
|
|
152
|
+
histogram: 'clusteredColumn',
|
|
153
|
+
sunburst: 'sunburst',
|
|
154
|
+
treemap: 'treemap',
|
|
155
|
+
waterfall: 'waterfall'
|
|
156
|
+
};
|
|
157
|
+
/**
|
|
158
|
+
* `mc:Choice@Requires` namespace gating a chartex chart type
|
|
159
|
+
* - funnel arrived a schema revision after the 2016 launch layouts, so it gates on a later generation
|
|
160
|
+
*/ function chartExRequiresNs(chartType) {
|
|
161
|
+
return chartType === 'funnel' ? OOXML_CHARTEX.requiresFunnel : OOXML_CHARTEX.requires2016;
|
|
162
|
+
}
|
|
163
|
+
/** True when `type` is emitted through the chartex pipeline rather than the ECMA-376 one */ function isChartexType(type) {
|
|
164
|
+
return typeof type === 'string' && Object.prototype.hasOwnProperty.call(CHARTEX_LAYOUT_ID, type);
|
|
165
|
+
}
|
|
93
166
|
/**
|
|
94
167
|
* Slide transition type.
|
|
95
168
|
* Base set is ECMA-376 §19.3.1.50; the rest are MS-PPTX §2.2.1 modern transitions (emitted via mc:AlternateContent).
|
|
@@ -206,6 +279,27 @@ var core_enums_TEXT_VALIGN = /*#__PURE__*/ function(TEXT_VALIGN) {
|
|
|
206
279
|
return TEXT_VALIGN;
|
|
207
280
|
}({});
|
|
208
281
|
const SLDNUMFLDID = '{F7021451-1387-4CA6-816F-3879F97B5CBC}';
|
|
282
|
+
/** ECMA-376 21.1.2.2.4 — `a:fld@type` values PowerPoint refreshes */ const TEXT_FIELD_TYPES = new Set([
|
|
283
|
+
'slidenum',
|
|
284
|
+
'datetime',
|
|
285
|
+
'datetimeFigureOut',
|
|
286
|
+
'datetime1',
|
|
287
|
+
'datetime2',
|
|
288
|
+
'datetime3',
|
|
289
|
+
'datetime4',
|
|
290
|
+
'datetime5',
|
|
291
|
+
'datetime6',
|
|
292
|
+
'datetime7',
|
|
293
|
+
'datetime8',
|
|
294
|
+
'datetime9',
|
|
295
|
+
'datetime10',
|
|
296
|
+
'datetime11',
|
|
297
|
+
'datetime12',
|
|
298
|
+
'datetime13',
|
|
299
|
+
'headerfooter',
|
|
300
|
+
'hdr',
|
|
301
|
+
'ftr'
|
|
302
|
+
]);
|
|
209
303
|
// ENUM
|
|
210
304
|
// TODO: 3.5 or v4.0: rationalize ts-def exported enum names/case!
|
|
211
305
|
// NOTE: First tsdef enum named correctly (shapes -> 'Shape', colors -> 'Color'), etc.
|
|
@@ -229,6 +323,12 @@ var core_enums_ChartType = /*#__PURE__*/ function(ChartType) {
|
|
|
229
323
|
ChartType["pie"] = "pie";
|
|
230
324
|
ChartType["radar"] = "radar";
|
|
231
325
|
ChartType["scatter"] = "scatter";
|
|
326
|
+
ChartType["boxWhisker"] = "boxWhisker";
|
|
327
|
+
ChartType["funnel"] = "funnel";
|
|
328
|
+
ChartType["histogram"] = "histogram";
|
|
329
|
+
ChartType["sunburst"] = "sunburst";
|
|
330
|
+
ChartType["treemap"] = "treemap";
|
|
331
|
+
ChartType["waterfall"] = "waterfall";
|
|
232
332
|
return ChartType;
|
|
233
333
|
}({});
|
|
234
334
|
var core_enums_ShapeType = /*#__PURE__*/ function(ShapeType) {
|
|
@@ -256,6 +356,10 @@ var core_enums_ShapeType = /*#__PURE__*/ function(ShapeType) {
|
|
|
256
356
|
ShapeType["actionButtonSound"] = "actionButtonSound";
|
|
257
357
|
ShapeType["arc"] = "arc";
|
|
258
358
|
ShapeType["bentArrow"] = "bentArrow";
|
|
359
|
+
ShapeType["bentConnector2"] = "bentConnector2";
|
|
360
|
+
ShapeType["bentConnector3"] = "bentConnector3";
|
|
361
|
+
ShapeType["bentConnector4"] = "bentConnector4";
|
|
362
|
+
ShapeType["bentConnector5"] = "bentConnector5";
|
|
259
363
|
ShapeType["bentUpArrow"] = "bentUpArrow";
|
|
260
364
|
ShapeType["bevel"] = "bevel";
|
|
261
365
|
ShapeType["blockArc"] = "blockArc";
|
|
@@ -279,6 +383,10 @@ var core_enums_ShapeType = /*#__PURE__*/ function(ShapeType) {
|
|
|
279
383
|
ShapeType["corner"] = "corner";
|
|
280
384
|
ShapeType["cornerTabs"] = "cornerTabs";
|
|
281
385
|
ShapeType["cube"] = "cube";
|
|
386
|
+
ShapeType["curvedConnector2"] = "curvedConnector2";
|
|
387
|
+
ShapeType["curvedConnector3"] = "curvedConnector3";
|
|
388
|
+
ShapeType["curvedConnector4"] = "curvedConnector4";
|
|
389
|
+
ShapeType["curvedConnector5"] = "curvedConnector5";
|
|
282
390
|
ShapeType["curvedDownArrow"] = "curvedDownArrow";
|
|
283
391
|
ShapeType["curvedLeftArrow"] = "curvedLeftArrow";
|
|
284
392
|
ShapeType["curvedRightArrow"] = "curvedRightArrow";
|
|
@@ -399,6 +507,7 @@ var core_enums_ShapeType = /*#__PURE__*/ function(ShapeType) {
|
|
|
399
507
|
ShapeType["star6"] = "star6";
|
|
400
508
|
ShapeType["star7"] = "star7";
|
|
401
509
|
ShapeType["star8"] = "star8";
|
|
510
|
+
ShapeType["straightConnector1"] = "straightConnector1";
|
|
402
511
|
ShapeType["stripedRightArrow"] = "stripedRightArrow";
|
|
403
512
|
ShapeType["sun"] = "sun";
|
|
404
513
|
ShapeType["swooshArrow"] = "swooshArrow";
|
|
@@ -472,6 +581,10 @@ var core_enums_SHAPE_TYPE = /*#__PURE__*/ function(SHAPE_TYPE) {
|
|
|
472
581
|
SHAPE_TYPE["ARC"] = "arc";
|
|
473
582
|
SHAPE_TYPE["BALLOON"] = "wedgeRoundRectCallout";
|
|
474
583
|
SHAPE_TYPE["BENT_ARROW"] = "bentArrow";
|
|
584
|
+
SHAPE_TYPE["BENT_CONNECTOR_2"] = "bentConnector2";
|
|
585
|
+
SHAPE_TYPE["BENT_CONNECTOR_3"] = "bentConnector3";
|
|
586
|
+
SHAPE_TYPE["BENT_CONNECTOR_4"] = "bentConnector4";
|
|
587
|
+
SHAPE_TYPE["BENT_CONNECTOR_5"] = "bentConnector5";
|
|
475
588
|
SHAPE_TYPE["BENT_UP_ARROW"] = "bentUpArrow";
|
|
476
589
|
SHAPE_TYPE["BEVEL"] = "bevel";
|
|
477
590
|
SHAPE_TYPE["BLOCK_ARC"] = "blockArc";
|
|
@@ -488,6 +601,10 @@ var core_enums_SHAPE_TYPE = /*#__PURE__*/ function(SHAPE_TYPE) {
|
|
|
488
601
|
SHAPE_TYPE["CORNER_TABS"] = "cornerTabs";
|
|
489
602
|
SHAPE_TYPE["CROSS"] = "plus";
|
|
490
603
|
SHAPE_TYPE["CUBE"] = "cube";
|
|
604
|
+
SHAPE_TYPE["CURVED_CONNECTOR_2"] = "curvedConnector2";
|
|
605
|
+
SHAPE_TYPE["CURVED_CONNECTOR_3"] = "curvedConnector3";
|
|
606
|
+
SHAPE_TYPE["CURVED_CONNECTOR_4"] = "curvedConnector4";
|
|
607
|
+
SHAPE_TYPE["CURVED_CONNECTOR_5"] = "curvedConnector5";
|
|
491
608
|
SHAPE_TYPE["CURVED_DOWN_ARROW"] = "curvedDownArrow";
|
|
492
609
|
SHAPE_TYPE["CURVED_DOWN_RIBBON"] = "ellipseRibbon";
|
|
493
610
|
SHAPE_TYPE["CURVED_LEFT_ARROW"] = "curvedLeftArrow";
|
|
@@ -629,6 +746,7 @@ var core_enums_SHAPE_TYPE = /*#__PURE__*/ function(SHAPE_TYPE) {
|
|
|
629
746
|
SHAPE_TYPE["STAR_6_POINT"] = "star6";
|
|
630
747
|
SHAPE_TYPE["STAR_7_POINT"] = "star7";
|
|
631
748
|
SHAPE_TYPE["STAR_8_POINT"] = "star8";
|
|
749
|
+
SHAPE_TYPE["STRAIGHT_CONNECTOR_1"] = "straightConnector1";
|
|
632
750
|
SHAPE_TYPE["STRIPED_RIGHT_ARROW"] = "stripedRightArrow";
|
|
633
751
|
SHAPE_TYPE["SUN"] = "sun";
|
|
634
752
|
SHAPE_TYPE["SWOOSH_ARROW"] = "swooshArrow";
|
|
@@ -648,13 +766,19 @@ var core_enums_CHART_TYPE = /*#__PURE__*/ function(CHART_TYPE) {
|
|
|
648
766
|
CHART_TYPE["AREA"] = "area";
|
|
649
767
|
CHART_TYPE["BAR"] = "bar";
|
|
650
768
|
CHART_TYPE["BAR3D"] = "bar3D";
|
|
769
|
+
CHART_TYPE["BOX_WHISKER"] = "boxWhisker";
|
|
651
770
|
CHART_TYPE["BUBBLE"] = "bubble";
|
|
652
771
|
CHART_TYPE["BUBBLE3D"] = "bubble3D";
|
|
653
772
|
CHART_TYPE["DOUGHNUT"] = "doughnut";
|
|
773
|
+
CHART_TYPE["FUNNEL"] = "funnel";
|
|
774
|
+
CHART_TYPE["HISTOGRAM"] = "histogram";
|
|
654
775
|
CHART_TYPE["LINE"] = "line";
|
|
655
776
|
CHART_TYPE["PIE"] = "pie";
|
|
656
777
|
CHART_TYPE["RADAR"] = "radar";
|
|
657
778
|
CHART_TYPE["SCATTER"] = "scatter";
|
|
779
|
+
CHART_TYPE["SUNBURST"] = "sunburst";
|
|
780
|
+
CHART_TYPE["TREEMAP"] = "treemap";
|
|
781
|
+
CHART_TYPE["WATERFALL"] = "waterfall";
|
|
658
782
|
return CHART_TYPE;
|
|
659
783
|
}({});
|
|
660
784
|
var core_enums_SCHEME_COLOR_NAMES = /*#__PURE__*/ function(SCHEME_COLOR_NAMES) {
|
|
@@ -954,13 +1078,37 @@ function _object_spread_props(target, source) {
|
|
|
954
1078
|
}
|
|
955
1079
|
return code;
|
|
956
1080
|
}
|
|
1081
|
+
/** Units per inch, for the length suffixes accepted on `x`/`y`/`w`/`h` and the other inch-valued options */ const UNITS_PER_INCH = {
|
|
1082
|
+
in: 1,
|
|
1083
|
+
cm: 2.54,
|
|
1084
|
+
mm: 25.4,
|
|
1085
|
+
pt: 72
|
|
1086
|
+
};
|
|
1087
|
+
/**
|
|
1088
|
+
* A number with a length suffix - `'2.5cm'`, `'-4mm'`, `'18pt'`, `'5in'`
|
|
1089
|
+
* - the mantissa alternates rather than using `\d*\.?\d+`: that form lets the two digit runs
|
|
1090
|
+
* split a plain integer many ways, so a long non-matching digit string backtracks quadratically
|
|
1091
|
+
*/ const REGEX_UNIT_LENGTH = /^\s*(-?(?:\d+(?:\.\d+)?|\.\d+))\s*(in|cm|mm|pt)\s*$/i;
|
|
1092
|
+
/**
|
|
1093
|
+
* Parse a unit-suffixed length into inches
|
|
1094
|
+
* - a suffixed value carries its own unit, so it bypasses the inches-vs-EMU magnitude heuristic entirely
|
|
1095
|
+
* @param {string} value - ex: `'2.5cm'`, `'18pt'`
|
|
1096
|
+
* @returns {number|undefined} inches, or `undefined` when `value` is not a suffixed length
|
|
1097
|
+
*/ function parseUnitLength(value) {
|
|
1098
|
+
const match = REGEX_UNIT_LENGTH.exec(value);
|
|
1099
|
+
if (!match) return undefined;
|
|
1100
|
+
const num = Number(match[1]);
|
|
1101
|
+
if (!Number.isFinite(num)) return undefined;
|
|
1102
|
+
return num / UNITS_PER_INCH[match[2].toLowerCase()];
|
|
1103
|
+
}
|
|
957
1104
|
/**
|
|
958
1105
|
* Translates any type of `x`/`y`/`w`/`h` prop to EMU
|
|
959
1106
|
* - guaranteed to return a result regardless of undefined, null, etc. (0)
|
|
960
1107
|
* - {number} - 12800 (EMU)
|
|
961
1108
|
* - {number} - 0.5 (inches)
|
|
962
1109
|
* - {string} - "75%"
|
|
963
|
-
*
|
|
1110
|
+
* - {string} - "2.5cm" (also in/mm/pt)
|
|
1111
|
+
* @param {number|string} size - numeric ("5.5"), unit-suffixed ("2.5cm") or percentage ("90%")
|
|
964
1112
|
* @param {'X' | 'Y'} xyDir - direction
|
|
965
1113
|
* @param {PresLayout} layout - presentation layout
|
|
966
1114
|
* @returns {number} calculated size
|
|
@@ -973,7 +1121,12 @@ function _object_spread_props(target, source) {
|
|
|
973
1121
|
// CASE 2: Number is already converted to something other than inches
|
|
974
1122
|
// Assume any number whose absolute value is 100+ is EMU already.
|
|
975
1123
|
if (typeof size === 'number' && Math.abs(size) >= 100) return size;
|
|
976
|
-
// CASE 3:
|
|
1124
|
+
// CASE 3: Unit-suffixed length (ex: '2.5cm') - unambiguous, so no magnitude heuristic
|
|
1125
|
+
if (typeof size === 'string') {
|
|
1126
|
+
const inches = parseUnitLength(size);
|
|
1127
|
+
if (inches !== undefined) return Math.round((/* inlined export .EMU */914400) * inches);
|
|
1128
|
+
}
|
|
1129
|
+
// CASE 4: Percentage (ex: '50%')
|
|
977
1130
|
if (typeof size === 'string' && size.includes('%')) {
|
|
978
1131
|
if (xyDir && xyDir === 'X') return Math.round(parseFloat(size) / 100 * layout.width);
|
|
979
1132
|
if (xyDir && xyDir === 'Y') return Math.round(parseFloat(size) / 100 * layout.height);
|
|
@@ -1037,6 +1190,11 @@ function _object_spread_props(target, source) {
|
|
|
1037
1190
|
* @param {number|string} inches - as string or number
|
|
1038
1191
|
* @returns {number} EMU value
|
|
1039
1192
|
*/ function inch2Emu(inches) {
|
|
1193
|
+
// A unit-suffixed string states its own unit - convert it before any inches assumption
|
|
1194
|
+
if (typeof inches === 'string') {
|
|
1195
|
+
const parsed = parseUnitLength(inches);
|
|
1196
|
+
if (parsed !== undefined) return Math.round((/* inlined export .EMU */914400) * parsed);
|
|
1197
|
+
}
|
|
1040
1198
|
// NOTE: Provide Caller Safety: Numbers may get conv<->conv during flight, so be kind and do some simple checks to ensure inches were passed
|
|
1041
1199
|
// Any absolute value over 100 is not inches (negative EMU is off-slide), so return it unchanged
|
|
1042
1200
|
if (typeof inches === 'number' && Math.abs(inches) > 100) return inches;
|
|
@@ -1330,6 +1488,23 @@ function createGlowElement(glow) {
|
|
|
1330
1488
|
const bg = String((pattern === null || pattern === void 0 ? void 0 : pattern.bgColor) || 'FFFFFF');
|
|
1331
1489
|
return `<a:pattFill prst="${prst}"><a:bgClr>${createColorElement(bg)}</a:bgClr><a:fgClr>${createColorElement(fg)}</a:fgClr></a:pattFill>`;
|
|
1332
1490
|
}
|
|
1491
|
+
/**
|
|
1492
|
+
* Create a DrawingML `a:blipFill` for a picture fill (ECMA-376 20.1.8.14)
|
|
1493
|
+
* - the image relationship is resolved when the object is created
|
|
1494
|
+
*/ function createImageFillElement(image, rId) {
|
|
1495
|
+
let mode = '<a:stretch><a:fillRect/></a:stretch>';
|
|
1496
|
+
if (image.sizing === 'tile') {
|
|
1497
|
+
var _image_alignment;
|
|
1498
|
+
const scale = typeof image.scale === 'number' && isFinite(image.scale) && image.scale > 0 ? Math.round(image.scale * 1000) : 100000;
|
|
1499
|
+
const rawAlgn = (_image_alignment = image.alignment) !== null && _image_alignment !== void 0 ? _image_alignment : 'tl';
|
|
1500
|
+
const algn = TILE_ALIGNMENTS.has(rawAlgn) ? rawAlgn : 'tl';
|
|
1501
|
+
if (image.alignment && !TILE_ALIGNMENTS.has(image.alignment)) {
|
|
1502
|
+
console.warn(`[pptxgenjs] unknown tile alignment "${String(image.alignment)}" - "tl" used instead`);
|
|
1503
|
+
}
|
|
1504
|
+
mode = `<a:tile tx="0" ty="0" sx="${scale}" sy="${scale}" flip="none" algn="${algn}"/>`;
|
|
1505
|
+
}
|
|
1506
|
+
return `<a:blipFill rotWithShape="${image.rotateWithShape === false ? '0' : '1'}"><a:blip r:embed="rId${rId}"/>${mode}</a:blipFill>`;
|
|
1507
|
+
}
|
|
1333
1508
|
/**
|
|
1334
1509
|
* Create color selection
|
|
1335
1510
|
* @param {Color | ShapeFillProps | ShapeLineProps} props fill props
|
|
@@ -1346,7 +1521,9 @@ function createGlowElement(glow) {
|
|
|
1346
1521
|
} else if (isModifiedThemeColor(props)) {
|
|
1347
1522
|
colorVal = props;
|
|
1348
1523
|
} else {
|
|
1524
|
+
var _props_image;
|
|
1349
1525
|
if (props.type) fillType = props.type;
|
|
1526
|
+
else if (((_props_image = props.image) === null || _props_image === void 0 ? void 0 : _props_image._rId) || props._rId) fillType = 'image';
|
|
1350
1527
|
if (props.color) colorVal = props.color;
|
|
1351
1528
|
if (props.alpha) internalElements += `<a:alpha val="${Math.round((100 - props.alpha) * 1000)}"/>`; // DEPRECATED: @deprecated v3.3.0
|
|
1352
1529
|
if (props.transparency) internalElements += `<a:alpha val="${Math.round((100 - props.transparency) * 1000)}"/>`;
|
|
@@ -1362,6 +1539,21 @@ function createGlowElement(glow) {
|
|
|
1362
1539
|
case 'pattern':
|
|
1363
1540
|
outText += createPatternFillElement(typeof props === 'string' || isModifiedThemeColor(props) ? undefined : props.pattern, typeof colorVal === 'string' ? colorVal : String(colorVal.baseColor));
|
|
1364
1541
|
break;
|
|
1542
|
+
case 'image':
|
|
1543
|
+
{
|
|
1544
|
+
var _ref;
|
|
1545
|
+
const image = typeof props === 'string' || isModifiedThemeColor(props) ? undefined : props.image;
|
|
1546
|
+
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;
|
|
1547
|
+
if (rId) {
|
|
1548
|
+
outText += createImageFillElement(image !== null && image !== void 0 ? image : {}, rId);
|
|
1549
|
+
} else {
|
|
1550
|
+
console.warn('[pptxgenjs] `fill.type:"image"` requires `fill.image.data` or `fill.image.path` - fill omitted');
|
|
1551
|
+
}
|
|
1552
|
+
break;
|
|
1553
|
+
}
|
|
1554
|
+
case 'group':
|
|
1555
|
+
outText += '<a:grpFill/>';
|
|
1556
|
+
break;
|
|
1365
1557
|
case 'none':
|
|
1366
1558
|
outText += '<a:noFill/>';
|
|
1367
1559
|
break;
|
|
@@ -1390,8 +1582,8 @@ function createGlowElement(glow) {
|
|
|
1390
1582
|
// Work on a copy - never mutate the caller's options object
|
|
1391
1583
|
ShadowProps = _object_spread({}, ShadowProps);
|
|
1392
1584
|
// OPT: `type`
|
|
1393
|
-
if (ShadowProps.type !== 'outer' && ShadowProps.type !== 'inner' && ShadowProps.type !== 'none') {
|
|
1394
|
-
console.warn('Warning: shadow.type options are `outer`, `inner` or `none`.');
|
|
1585
|
+
if (ShadowProps.type !== 'outer' && ShadowProps.type !== 'inner' && ShadowProps.type !== 'none' && ShadowProps.type !== 'preset') {
|
|
1586
|
+
console.warn('Warning: shadow.type options are `outer`, `inner`, `preset` or `none`.');
|
|
1395
1587
|
ShadowProps.type = 'outer';
|
|
1396
1588
|
}
|
|
1397
1589
|
// OPT: `angle`
|
|
@@ -2285,6 +2477,57 @@ function gen_tables_object_spread(target) {
|
|
|
2285
2477
|
});
|
|
2286
2478
|
}
|
|
2287
2479
|
|
|
2480
|
+
/**
|
|
2481
|
+
* Hyperlinks and mouse-over actions.
|
|
2482
|
+
*
|
|
2483
|
+
* DrawingML gives the same concept two element names depending on where it appears:
|
|
2484
|
+
*
|
|
2485
|
+
* | host | click | mouse-over |
|
|
2486
|
+
* | :-- | :-- | :-- |
|
|
2487
|
+
* | `p:cNvPr` (shapes, pictures) | `a:hlinkClick` (20.1.2.2.22) | `a:hlinkHover` (20.1.2.2.23) |
|
|
2488
|
+
* | `a:rPr` (text runs) | `a:hlinkClick` | `a:hlinkMouseOver` (21.1.2.3.6) |
|
|
2489
|
+
*
|
|
2490
|
+
* Emitting `a:hlinkHover` inside `a:rPr` — or `a:hlinkMouseOver` inside `p:cNvPr` — produces markup
|
|
2491
|
+
* PowerPoint cannot parse, so the host decides the element name here rather than at each call site.
|
|
2492
|
+
*/
|
|
2493
|
+
/**
|
|
2494
|
+
* Build one `a:hlinkClick` / mouse-over element
|
|
2495
|
+
* @param {HyperlinkProps} link - link props
|
|
2496
|
+
* @param {'click' | 'hover'} trigger - which interaction this element describes
|
|
2497
|
+
* @param {HyperlinkHost} host - the element the link is attached to
|
|
2498
|
+
* @param {string} children - child elements (`a:snd`, `a:extLst`); self-closes when empty
|
|
2499
|
+
* @returns {string} XML string
|
|
2500
|
+
*/ function genXmlHyperlink(link, trigger, host, children = '') {
|
|
2501
|
+
var _link__rId;
|
|
2502
|
+
const tag = trigger === 'click' ? 'a:hlinkClick' : host === 'run' ? 'a:hlinkMouseOver' : 'a:hlinkHover';
|
|
2503
|
+
let attrs = `r:id="rId${(_link__rId = link._rId) !== null && _link__rId !== void 0 ? _link__rId : 0}"`;
|
|
2504
|
+
if (link.slide) {
|
|
2505
|
+
// an internal jump has no URL; the action attribute names the target kind
|
|
2506
|
+
attrs += ' action="ppaction://hlinksldjump"';
|
|
2507
|
+
} else {
|
|
2508
|
+
attrs += ' invalidUrl="" action="" tgtFrame=""';
|
|
2509
|
+
}
|
|
2510
|
+
attrs += ` tooltip="${link.tooltip ? encodeXmlEntities(link.tooltip) : ''}"`;
|
|
2511
|
+
if (!link.slide) attrs += ' history="1"';
|
|
2512
|
+
// both default to false in the schema, so only write them when turned on
|
|
2513
|
+
if (link.highlightClick === true) attrs += ' highlightClick="1"';
|
|
2514
|
+
if (link.stopSoundsOnClick === true) attrs += ' endSnd="1"';
|
|
2515
|
+
const sound = genXmlHyperlinkSound(link);
|
|
2516
|
+
const inner = sound + children;
|
|
2517
|
+
return inner ? `<${tag} ${attrs}>${inner}</${tag}>` : `<${tag} ${attrs}/>`;
|
|
2518
|
+
}
|
|
2519
|
+
/**
|
|
2520
|
+
* Build the `a:snd` action sound (ECMA-376 20.1.2.2.32 `CT_EmbeddedWAVAudioFile`)
|
|
2521
|
+
* - the relationship is resolved when the object is created, so `_sndRId` is set by then
|
|
2522
|
+
* @param {HyperlinkProps} link - link props
|
|
2523
|
+
* @returns {string} XML string
|
|
2524
|
+
*/ function genXmlHyperlinkSound(link) {
|
|
2525
|
+
var _link_sound_name;
|
|
2526
|
+
var _link_sound;
|
|
2527
|
+
if (!((_link_sound = link.sound) === null || _link_sound === void 0 ? void 0 : _link_sound._sndRId)) return '';
|
|
2528
|
+
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')}"/>`;
|
|
2529
|
+
}
|
|
2530
|
+
|
|
2288
2531
|
function text_define_property(obj, key, value) {
|
|
2289
2532
|
if (key in obj) {
|
|
2290
2533
|
Object.defineProperty(obj, key, {
|
|
@@ -2337,6 +2580,7 @@ function text_object_spread_props(target, source) {
|
|
|
2337
2580
|
/**
|
|
2338
2581
|
* Text-body, run, and placeholder rendering.
|
|
2339
2582
|
*/
|
|
2583
|
+
|
|
2340
2584
|
/** ECMA-376 §5.1.12.76 `ST_TextShapeType` — used to validate `a:prstTxWarp@prst`. */ const TEXT_SHAPE_TYPES = new Set([
|
|
2341
2585
|
'textNoShape',
|
|
2342
2586
|
'textPlain',
|
|
@@ -2381,6 +2625,25 @@ function text_object_spread_props(target, source) {
|
|
|
2381
2625
|
'textCascadeDown'
|
|
2382
2626
|
]);
|
|
2383
2627
|
|
|
2628
|
+
/**
|
|
2629
|
+
* Build the `a:buClr` / `a:buSzPct` / `a:buSzPts` / `a:buFont` prefix shared by every bullet kind
|
|
2630
|
+
* - the size defaults to 100% because that is what every branch emitted before
|
|
2631
|
+
*/ function genXmlBulletPrefix(bullet) {
|
|
2632
|
+
let xml = '';
|
|
2633
|
+
if (bullet.color) xml += `<a:buClr>${createColorElement(bullet.color)}</a:buClr>`;
|
|
2634
|
+
// `a:buSzPct` and `a:buSzPts` are the same choice, so only one may appear
|
|
2635
|
+
if (typeof bullet.sizePts === 'number' && isFinite(bullet.sizePts) && bullet.sizePts > 0) {
|
|
2636
|
+
xml += `<a:buSzPts val="${Math.round(bullet.sizePts * 100)}"/>`;
|
|
2637
|
+
} else {
|
|
2638
|
+
const pct = typeof bullet.size === 'number' && isFinite(bullet.size) ? Math.min(400, Math.max(25, bullet.size)) : 100;
|
|
2639
|
+
if (typeof bullet.size === 'number' && (bullet.size < 25 || bullet.size > 400)) {
|
|
2640
|
+
console.warn(`[pptxgenjs] bullet \`size\` must be between 25 and 400 percent - "${String(bullet.size)}" clamped`);
|
|
2641
|
+
}
|
|
2642
|
+
xml += `<a:buSzPct val="${Math.round(pct * 1000)}"/>`;
|
|
2643
|
+
}
|
|
2644
|
+
if (bullet.fontFace) xml += `<a:buFont typeface="${encodeXmlEntities(bullet.fontFace)}"/>`;
|
|
2645
|
+
return xml;
|
|
2646
|
+
}
|
|
2384
2647
|
/**
|
|
2385
2648
|
* Generate XML Paragraph Properties
|
|
2386
2649
|
* @param {ISlideObject|TextProps} textObj - text object
|
|
@@ -2389,7 +2652,6 @@ function text_object_spread_props(target, source) {
|
|
|
2389
2652
|
*/ function genXmlParagraphProperties(textObj, isDefault) {
|
|
2390
2653
|
var _textObj_options;
|
|
2391
2654
|
let strXmlBullet = '';
|
|
2392
|
-
let strXmlBulletColor = '';
|
|
2393
2655
|
let strXmlLnSpc = '';
|
|
2394
2656
|
let strXmlParaSpc = '';
|
|
2395
2657
|
let strXmlTabStops = '';
|
|
@@ -2441,10 +2703,17 @@ function text_object_spread_props(target, source) {
|
|
|
2441
2703
|
if (typeof options.bullet === 'object') {
|
|
2442
2704
|
var _options_bullet;
|
|
2443
2705
|
if ((_options_bullet = options.bullet) === null || _options_bullet === void 0 ? void 0 : _options_bullet.indent) bulletMarL = valToPts(options.bullet.indent);
|
|
2444
|
-
|
|
2706
|
+
const buPrefix = genXmlBulletPrefix(options.bullet);
|
|
2707
|
+
const buIndent = ` marL="${options.indentLevel && options.indentLevel > 0 ? bulletMarL + bulletMarL * options.indentLevel : bulletMarL}" indent="-${bulletMarL}"`;
|
|
2708
|
+
if (options.bullet.image && options.bullet._imageRId) {
|
|
2709
|
+
// `a:buBlip` replaces the character or number bullet entirely
|
|
2710
|
+
paragraphPropXml += buIndent;
|
|
2711
|
+
strXmlBullet = `${buPrefix}<a:buBlip><a:blip r:embed="rId${options.bullet._imageRId}"/></a:buBlip>`;
|
|
2712
|
+
} else if (options.bullet.type && options.bullet.type.toString().toLowerCase() === 'number') {
|
|
2445
2713
|
// NOTE: only `type: 'number'` is a distinct branch; any other `type` (e.g. 'bullet') falls through to the char-bullet cases below (issue #1432)
|
|
2446
|
-
paragraphPropXml +=
|
|
2447
|
-
|
|
2714
|
+
paragraphPropXml += buIndent;
|
|
2715
|
+
// auto-numbered bullets fall back to the major latin face when none is given
|
|
2716
|
+
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'}"/>`;
|
|
2448
2717
|
} else if (options.bullet.characterCode) {
|
|
2449
2718
|
let bulletCode = `&#x${options.bullet.characterCode};`;
|
|
2450
2719
|
// Check value for hex-ness (s/b 4 char hex)
|
|
@@ -2452,8 +2721,8 @@ function text_object_spread_props(target, source) {
|
|
|
2452
2721
|
console.warn('Warning: `bullet.characterCode should be a 4-digit unicode charatcer (ex: 22AB)`!');
|
|
2453
2722
|
bulletCode = (/* inlined export .BULLET_TYPES.DEFAULT */"•");
|
|
2454
2723
|
}
|
|
2455
|
-
paragraphPropXml +=
|
|
2456
|
-
strXmlBullet =
|
|
2724
|
+
paragraphPropXml += buIndent;
|
|
2725
|
+
strXmlBullet = `${buPrefix}<a:buChar char="${bulletCode}"/>`;
|
|
2457
2726
|
} else if (options.bullet.code) {
|
|
2458
2727
|
// @deprecated `bullet.code` v3.3.0
|
|
2459
2728
|
let bulletCode = `&#x${options.bullet.code};`;
|
|
@@ -2462,15 +2731,11 @@ function text_object_spread_props(target, source) {
|
|
|
2462
2731
|
console.warn('Warning: `bullet.code should be a 4-digit hex code (ex: 22AB)`!');
|
|
2463
2732
|
bulletCode = (/* inlined export .BULLET_TYPES.DEFAULT */"•");
|
|
2464
2733
|
}
|
|
2465
|
-
paragraphPropXml +=
|
|
2466
|
-
strXmlBullet =
|
|
2734
|
+
paragraphPropXml += buIndent;
|
|
2735
|
+
strXmlBullet = `${buPrefix}<a:buChar char="${bulletCode}"/>`;
|
|
2467
2736
|
} else {
|
|
2468
|
-
paragraphPropXml +=
|
|
2469
|
-
strXmlBullet =
|
|
2470
|
-
}
|
|
2471
|
-
// mikemeerschaert/add-color-option-to-bullets — buClr must precede buSz*/buChar (OOXML order)
|
|
2472
|
-
if (options.bullet.color) {
|
|
2473
|
-
strXmlBulletColor = `<a:buClr>${createColorElement(options.bullet.color)}</a:buClr>`;
|
|
2737
|
+
paragraphPropXml += buIndent;
|
|
2738
|
+
strXmlBullet = `${buPrefix}<a:buChar char="${(/* inlined export .BULLET_TYPES.DEFAULT */"•")}"/>`;
|
|
2474
2739
|
}
|
|
2475
2740
|
} else if (options.bullet) {
|
|
2476
2741
|
paragraphPropXml += ` marL="${options.indentLevel && options.indentLevel > 0 ? bulletMarL + bulletMarL * options.indentLevel : bulletMarL}" indent="-${bulletMarL}"`;
|
|
@@ -2487,7 +2752,7 @@ function text_object_spread_props(target, source) {
|
|
|
2487
2752
|
}
|
|
2488
2753
|
// B: Close Paragraph-Properties
|
|
2489
2754
|
// IMPORTANT: strXmlLnSpc, strXmlParaSpc, buClr, and strXmlBullet require strict ordering - anything out of order is ignored. (PPT-Online, PPT for Mac)
|
|
2490
|
-
paragraphPropXml += '>' + strXmlLnSpc + strXmlParaSpc +
|
|
2755
|
+
paragraphPropXml += '>' + strXmlLnSpc + strXmlParaSpc + strXmlBullet + strXmlTabStops;
|
|
2491
2756
|
if (isDefault) paragraphPropXml += genXmlTextRunProperties(options, true);
|
|
2492
2757
|
paragraphPropXml += '</' + tag + '>';
|
|
2493
2758
|
}
|
|
@@ -2499,7 +2764,7 @@ function text_object_spread_props(target, source) {
|
|
|
2499
2764
|
* @param {boolean} isDefault - whether these are the default text run properties
|
|
2500
2765
|
* @return {string} XML
|
|
2501
2766
|
*/ function genXmlTextRunProperties(opts, isDefault) {
|
|
2502
|
-
var _opts_underline;
|
|
2767
|
+
var _opts_underline, _opts_hyperlinkHover;
|
|
2503
2768
|
let runProps = '';
|
|
2504
2769
|
const runPropsTag = isDefault ? 'a:defRPr' : 'a:rPr';
|
|
2505
2770
|
// BEGIN runProperties (ex: `<a:rPr lang="en-US" sz="1600" b="1" dirty="0">`)
|
|
@@ -2531,6 +2796,7 @@ function text_object_spread_props(target, source) {
|
|
|
2531
2796
|
'small',
|
|
2532
2797
|
'all'
|
|
2533
2798
|
].includes(opts.caps) ? ` cap="${opts.caps}"` : '';
|
|
2799
|
+
if (opts.kumimoji === true) runProps += ' kumimoji="1"';
|
|
2534
2800
|
runProps += ' dirty="0">';
|
|
2535
2801
|
// Color / Font / Highlight / Outline are children of <a:rPr>, so add them now before closing the runProperties tag
|
|
2536
2802
|
if (opts.color || opts.gradient || opts.fontFace || opts.fontFaceEa || opts.fontFaceCs || opts.outline || typeof opts.underline === 'object' && opts.underline.color) {
|
|
@@ -2568,21 +2834,13 @@ function text_object_spread_props(target, source) {
|
|
|
2568
2834
|
if (opts.hyperlink) {
|
|
2569
2835
|
if (typeof opts.hyperlink !== 'object') throw new Error('ERROR: text `hyperlink` option should be an object. Ex: `hyperlink:{url:\'https://github.com\'}` ');
|
|
2570
2836
|
else if (!opts.hyperlink.url && !opts.hyperlink.slide) throw new Error('ERROR: \'hyperlink requires either `url` or `slide`\'');
|
|
2571
|
-
|
|
2572
|
-
|
|
2573
|
-
|
|
2574
|
-
|
|
2575
|
-
runProps += `<a:hlinkClick r:id="rId${opts.hyperlink._rId}" action="ppaction://hlinksldjump" tooltip="${opts.hyperlink.tooltip ? encodeXmlEntities(opts.hyperlink.tooltip) : ''}"${opts.color ? '>' : '/>'}`;
|
|
2576
|
-
}
|
|
2577
|
-
if (opts.color) {
|
|
2578
|
-
runProps += ' <a:extLst>';
|
|
2579
|
-
runProps += ' <a:ext uri="{A12FA001-AC4F-418D-AE19-62706E023703}">';
|
|
2580
|
-
runProps += ' <ahyp:hlinkClr xmlns:ahyp="http://schemas.microsoft.com/office/drawing/2018/hyperlinkcolor" val="tx"/>';
|
|
2581
|
-
runProps += ' </a:ext>';
|
|
2582
|
-
runProps += ' </a:extLst>';
|
|
2583
|
-
runProps += '</a:hlinkClick>';
|
|
2584
|
-
}
|
|
2837
|
+
// A colored link keeps its run color instead of the theme's hyperlink color (issue #74: an
|
|
2838
|
+
// `a:uFill` here breaks PPT2010, so the extension is used rather than an underline fill)
|
|
2839
|
+
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>' : '';
|
|
2840
|
+
runProps += genXmlHyperlink(opts.hyperlink, 'click', 'run', linkColorExt);
|
|
2585
2841
|
}
|
|
2842
|
+
// `a:hlinkMouseOver` follows `a:hlinkClick` in CT_TextCharacterProperties
|
|
2843
|
+
if ((_opts_hyperlinkHover = opts.hyperlinkHover) === null || _opts_hyperlinkHover === void 0 ? void 0 : _opts_hyperlinkHover._rId) runProps += genXmlHyperlink(opts.hyperlinkHover, 'hover', 'run');
|
|
2586
2844
|
// END runProperties
|
|
2587
2845
|
runProps += `</${runPropsTag}>`;
|
|
2588
2846
|
return runProps;
|
|
@@ -2621,6 +2879,15 @@ const P1710_NS = 'http://schemas.microsoft.com/office/powerpoint/2017/10/main';
|
|
|
2621
2879
|
}
|
|
2622
2880
|
return `<a14:m xmlns:a14="${A14_NS}">${trimmed}</a14:m>`;
|
|
2623
2881
|
}
|
|
2882
|
+
/**
|
|
2883
|
+
* A stable GUID for a field, derived from its type and cached value
|
|
2884
|
+
* - `a:fld@id` must be a GUID; deriving it keeps repeated exports byte-identical
|
|
2885
|
+
*/ function fieldGuid(type, cached) {
|
|
2886
|
+
let hash = 0;
|
|
2887
|
+
for (const char of `${type}:${cached}`)hash = hash * 31 + char.charCodeAt(0) >>> 0;
|
|
2888
|
+
const hex = hash.toString(16).padStart(8, '0');
|
|
2889
|
+
return `{${hex}-0000-0000-0000-${hex}0000}`;
|
|
2890
|
+
}
|
|
2624
2891
|
function textRunsHaveOmml(text) {
|
|
2625
2892
|
if (!Array.isArray(text)) return false;
|
|
2626
2893
|
return text.some((t)=>{
|
|
@@ -2630,7 +2897,7 @@ function textRunsHaveOmml(text) {
|
|
|
2630
2897
|
}
|
|
2631
2898
|
function genXmlTextRun(textObj) {
|
|
2632
2899
|
var _textObj_options;
|
|
2633
|
-
var _textObj_options1;
|
|
2900
|
+
var _textObj_options1, _textObj_options2;
|
|
2634
2901
|
// Native Office Math run — editable in PowerPoint (not an image).
|
|
2635
2902
|
const omml = (_textObj_options1 = textObj.options) === null || _textObj_options1 === void 0 ? void 0 : _textObj_options1.omml;
|
|
2636
2903
|
if (typeof omml === 'string' && omml.trim()) {
|
|
@@ -2661,7 +2928,18 @@ function genXmlTextRun(textObj) {
|
|
|
2661
2928
|
</a:r>
|
|
2662
2929
|
<a:endParaRPr lang="en-US" dirty="0"/>
|
|
2663
2930
|
</a:p>
|
|
2664
|
-
*/
|
|
2931
|
+
*/ /* A field is a run the consumer refreshes on open (ECMA-376 21.1.2.2.4). The `a:t` child holds
|
|
2932
|
+
* the cached value so a consumer that does not refresh still renders something. `id` must be a
|
|
2933
|
+
* 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;
|
|
2934
|
+
if (field) {
|
|
2935
|
+
if (!TEXT_FIELD_TYPES.has(field)) {
|
|
2936
|
+
console.warn(`[pptxgenjs] unknown text field "${String(field)}" - run emitted as plain text instead`);
|
|
2937
|
+
} else {
|
|
2938
|
+
var _textObj_text, _textObj_options3, _textObj_text1;
|
|
2939
|
+
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>';
|
|
2940
|
+
}
|
|
2941
|
+
}
|
|
2942
|
+
// Return paragraph with text run
|
|
2665
2943
|
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>` : '';
|
|
2666
2944
|
}
|
|
2667
2945
|
/**
|
|
@@ -2683,13 +2961,14 @@ function genXmlTextRun(textObj) {
|
|
|
2683
2961
|
if (slideObject.options._bodyProp.tIns || slideObject.options._bodyProp.tIns === 0) bodyProperties += ` tIns="${slideObject.options._bodyProp.tIns}"`;
|
|
2684
2962
|
if (slideObject.options._bodyProp.rIns || slideObject.options._bodyProp.rIns === 0) bodyProperties += ` rIns="${slideObject.options._bodyProp.rIns}"`;
|
|
2685
2963
|
if (slideObject.options._bodyProp.bIns || slideObject.options._bodyProp.bIns === 0) bodyProperties += ` bIns="${slideObject.options._bodyProp.bIns}"`;
|
|
2686
|
-
// C: Add rtl after margins
|
|
2687
|
-
bodyProperties += ' rtlCol="0"';
|
|
2688
2964
|
// Text columns — ECMA-376 §5.1.5.1.4 CT_TextBodyProperties@numCol/@spcCol (issue #1320)
|
|
2689
2965
|
if (slideObject.options._bodyProp.numCol && slideObject.options._bodyProp.numCol > 1) {
|
|
2690
2966
|
bodyProperties += ` numCol="${slideObject.options._bodyProp.numCol}"`;
|
|
2691
2967
|
if (slideObject.options._bodyProp.spcCol) bodyProperties += ` spcCol="${slideObject.options._bodyProp.spcCol}"`;
|
|
2692
2968
|
}
|
|
2969
|
+
// `rtlCol` follows the text box's RTL mode unless overridden, so RTL columns flow correctly
|
|
2970
|
+
const rtlCols = typeof slideObject.options.rtlColumns === 'boolean' ? slideObject.options.rtlColumns : slideObject.options.rtlMode === true;
|
|
2971
|
+
bodyProperties += ` rtlCol="${rtlCols ? '1' : '0'}"`;
|
|
2693
2972
|
// D: Add anchorPoints
|
|
2694
2973
|
if (slideObject.options._bodyProp.anchor) bodyProperties += ' anchor="' + slideObject.options._bodyProp.anchor + '"'; // VALS: [t,ctr,b]
|
|
2695
2974
|
if (slideObject.options._bodyProp.vert) bodyProperties += ' vert="' + slideObject.options._bodyProp.vert + '"'; // VALS: [eaVert,horz,mongolianVert,vert,vert270,wordArtVert,wordArtVertRtl]
|
|
@@ -2725,7 +3004,9 @@ function genXmlTextRun(textObj) {
|
|
|
2725
3004
|
bodyProperties += '</a:bodyPr>';
|
|
2726
3005
|
} else {
|
|
2727
3006
|
// DEFAULT:
|
|
2728
|
-
|
|
3007
|
+
const opts = slideObject.options;
|
|
3008
|
+
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;
|
|
3009
|
+
bodyProperties += ` wrap="square" rtlCol="${rtlCols ? '1' : '0'}">`;
|
|
2729
3010
|
bodyProperties += '</a:bodyPr>';
|
|
2730
3011
|
}
|
|
2731
3012
|
// LAST: Return Close _bodyProp
|
|
@@ -2812,6 +3093,8 @@ function genXmlTextRun(textObj) {
|
|
|
2812
3093
|
delete runOpts.softEdge;
|
|
2813
3094
|
delete runOpts.reflection;
|
|
2814
3095
|
delete runOpts.shadow;
|
|
3096
|
+
delete runOpts.fillOverlay;
|
|
3097
|
+
delete runOpts.effectDag;
|
|
2815
3098
|
itext.options = runOpts;
|
|
2816
3099
|
}
|
|
2817
3100
|
if (idx === 0 && itext.options && !itext.options.bullet && opts.bullet) itext.options.bullet = opts.bullet;
|
|
@@ -2927,7 +3210,7 @@ function genXmlTextRun(textObj) {
|
|
|
2927
3210
|
// NOTE: This loop will pick up unecessary keys (`x`, etc.), but it doesnt hurt anything
|
|
2928
3211
|
// `glow` / softEdge / reflection belong on the shape effectLst (not per-run), unless set on the run itself
|
|
2929
3212
|
// `omml` is a run-level math payload — inheriting it would replace sibling plain-text runs
|
|
2930
|
-
if (key === 'glow' || key === 'softEdge' || key === 'reflection' || key === 'shadow' || key === 'blur' || key === 'omml') return;
|
|
3213
|
+
if (key === 'glow' || key === 'softEdge' || key === 'reflection' || key === 'shadow' || key === 'blur' || key === 'fillOverlay' || key === 'effectDag' || key === 'omml') return;
|
|
2931
3214
|
if (key !== 'bullet' && !textOpts[key]) textOpts[key] = val;
|
|
2932
3215
|
});
|
|
2933
3216
|
// D: Add formatted textrun
|
|
@@ -3050,12 +3333,15 @@ const NS_P232 = 'http://schemas.microsoft.com/office/powerpoint/2023/02/main';
|
|
|
3050
3333
|
* @returns XML
|
|
3051
3334
|
*/ function genXmlPlaceholder(placeholderObj, extraOpts) {
|
|
3052
3335
|
var _ref;
|
|
3053
|
-
var _placeholderObj_options, _placeholderObj_options1, _placeholderObj_options2;
|
|
3336
|
+
var _placeholderObj_options, _placeholderObj_options1, _placeholderObj_options2, _placeholderObj_options3, _placeholderObj_options4, _placeholderObj_options5;
|
|
3054
3337
|
if (!placeholderObj) return '';
|
|
3055
3338
|
const placeholderIdx = ((_placeholderObj_options = placeholderObj.options) === null || _placeholderObj_options === void 0 ? void 0 : _placeholderObj_options._placeholderIdx) ? placeholderObj.options._placeholderIdx : '';
|
|
3056
3339
|
const placeholderType = resolvePlaceholderType((_placeholderObj_options1 = placeholderObj.options) === null || _placeholderObj_options1 === void 0 ? void 0 : _placeholderObj_options1._placeholderType);
|
|
3057
|
-
|
|
3058
|
-
const
|
|
3340
|
+
// `orient` and `sz` default to horz/full in the schema, so only a non-default is written
|
|
3341
|
+
const placeholderOrient = ((_placeholderObj_options2 = placeholderObj.options) === null || _placeholderObj_options2 === void 0 ? void 0 : _placeholderObj_options2.orient) === 'vert' ? ' orient="vert"' : '';
|
|
3342
|
+
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}"` : '';
|
|
3343
|
+
const attrs = `${placeholderIdx ? ' idx="' + placeholderIdx.toString() + '"' : ''}` + `${placeholderType ? ` type="${placeholderType}"` : ''}` + placeholderOrient + placeholderSize + `${placeholderObj.text && placeholderObj.text.length > 0 ? ' hasCustomPrompt="1"' : ''}`;
|
|
3344
|
+
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;
|
|
3059
3345
|
if (phTypeExt === 'cameo' || phTypeExt === 'unknown') {
|
|
3060
3346
|
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>';
|
|
3061
3347
|
}
|
|
@@ -3399,6 +3685,10 @@ function _object_without_properties_loose(source, excluded) {
|
|
|
3399
3685
|
let tmpOpt;
|
|
3400
3686
|
let tmpData = [];
|
|
3401
3687
|
if (Array.isArray(type)) {
|
|
3688
|
+
// A chartex layout owns the whole `cx:plotArea` and cannot share one with an ECMA-376 chart type,
|
|
3689
|
+
// so a multi-type spec that names one would silently render as an empty frame
|
|
3690
|
+
const chartexSpec = type.find((obj)=>isChartexType(obj.type));
|
|
3691
|
+
if (chartexSpec) throw new Error(`pptxgenjs: chart type "${String(chartexSpec.type)}" cannot be combined in a multi-type chart`);
|
|
3402
3692
|
// For multi-type charts there needs to be data for each type,
|
|
3403
3693
|
// as well as a single data source for non-series operations.
|
|
3404
3694
|
// The data is indexed below to keep the data in order when segmented
|
|
@@ -3486,8 +3776,21 @@ function _object_without_properties_loose(source, excluded) {
|
|
|
3486
3776
|
// NOTE: a multi-type chart has no single type to validate against, so only the name translation applies there
|
|
3487
3777
|
if (options.dataLabelPosition) {
|
|
3488
3778
|
const chartType = Array.isArray(options._type) ? undefined : options._type;
|
|
3489
|
-
|
|
3490
|
-
|
|
3779
|
+
if (isChartexType(chartType)) {
|
|
3780
|
+
// `cx:dataLabels@pos` is its own vocabulary, not `c:dLblPos`; these three are the values the
|
|
3781
|
+
// shipped chartex writers emit, so anything else falls back to the layout's own default
|
|
3782
|
+
if (![
|
|
3783
|
+
'ctr',
|
|
3784
|
+
'inEnd',
|
|
3785
|
+
'outEnd'
|
|
3786
|
+
].includes(options.dataLabelPosition)) {
|
|
3787
|
+
console.warn(`[pptxgenjs] dataLabelPosition '${options.dataLabelPosition}' is not valid for a '${chartType}' chart - ignoring it (valid: ctr, inEnd, outEnd)`);
|
|
3788
|
+
delete options.dataLabelPosition;
|
|
3789
|
+
}
|
|
3790
|
+
} else {
|
|
3791
|
+
options.dataLabelPosition = resolveDataLabelPosition(options.dataLabelPosition, chartType, options.barGrouping);
|
|
3792
|
+
if (!options.dataLabelPosition) delete options.dataLabelPosition;
|
|
3793
|
+
}
|
|
3491
3794
|
}
|
|
3492
3795
|
options.dataLabelBkgrdColors = options.dataLabelBkgrdColors || !options.dataLabelBkgrdColors ? options.dataLabelBkgrdColors : false;
|
|
3493
3796
|
if (![
|
|
@@ -3659,6 +3962,59 @@ function _object_without_properties_loose(source, excluded) {
|
|
|
3659
3962
|
} else {
|
|
3660
3963
|
delete options.catAxisMultiLevelLabels;
|
|
3661
3964
|
}
|
|
3965
|
+
// ChartEx: reject values PowerPoint would reject, so a bad option degrades to the layout default
|
|
3966
|
+
// rather than to the repair dialog
|
|
3967
|
+
if (isChartexType(options._type)) {
|
|
3968
|
+
// Only box & whisker plots more than one distribution; the other layouts own the whole plot area
|
|
3969
|
+
// and a second `cx:series` is either dropped or flagged for repair
|
|
3970
|
+
if (options._type !== core_enums_CHART_TYPE.BOX_WHISKER && tmpData.length > 1) {
|
|
3971
|
+
console.warn(`Warning: a ${options._type} chart plots one series - ignoring ${tmpData.length - 1} extra series.`);
|
|
3972
|
+
tmpData = tmpData.slice(0, 1);
|
|
3973
|
+
}
|
|
3974
|
+
tmpData.forEach((item)=>{
|
|
3975
|
+
var _item_values;
|
|
3976
|
+
var _item_labels;
|
|
3977
|
+
// ChartEx cell references assume one label column; the multi-level worksheet layout shifts the
|
|
3978
|
+
// series columns right, so the extra levels are dropped rather than silently misaddressed
|
|
3979
|
+
if (item.labels && item.labels.length > 1) {
|
|
3980
|
+
console.warn('Warning: chartex charts take single-level category labels - using the first level.');
|
|
3981
|
+
item.labels = [
|
|
3982
|
+
item.labels[0]
|
|
3983
|
+
];
|
|
3984
|
+
}
|
|
3985
|
+
// A histogram bins raw values and needs no categories, but the embedded worksheet still writes a
|
|
3986
|
+
// row per label, so a label-less series is padded rather than left to fail during write()
|
|
3987
|
+
const labels = (_item_labels = item.labels) === null || _item_labels === void 0 ? void 0 : _item_labels[0];
|
|
3988
|
+
if (!labels || labels.length === 0) item.labels = [
|
|
3989
|
+
Array(((_item_values = item.values) !== null && _item_values !== void 0 ? _item_values : []).length).fill('')
|
|
3990
|
+
];
|
|
3991
|
+
});
|
|
3992
|
+
const pointCount = Math.max(...tmpData.map((item)=>{
|
|
3993
|
+
var _item_values;
|
|
3994
|
+
return ((_item_values = item.values) !== null && _item_values !== void 0 ? _item_values : []).length;
|
|
3995
|
+
}), 0);
|
|
3996
|
+
if (options.chartExSubtotals) {
|
|
3997
|
+
const valid = options.chartExSubtotals.filter((idx)=>Number.isInteger(idx) && idx >= 0 && idx < pointCount);
|
|
3998
|
+
if (valid.length !== options.chartExSubtotals.length) console.warn(`Warning: chart.chartExSubtotals must be data point indexes 0-${pointCount - 1}.`);
|
|
3999
|
+
options.chartExSubtotals = valid;
|
|
4000
|
+
}
|
|
4001
|
+
if (options.chartExBinCount !== undefined && (!Number.isInteger(options.chartExBinCount) || options.chartExBinCount < 1)) {
|
|
4002
|
+
console.warn('Warning: chart.chartExBinCount must be a positive integer.');
|
|
4003
|
+
delete options.chartExBinCount;
|
|
4004
|
+
}
|
|
4005
|
+
if (options.chartExBinSize !== undefined && (isNaN(options.chartExBinSize) || options.chartExBinSize <= 0)) {
|
|
4006
|
+
console.warn('Warning: chart.chartExBinSize must be greater than 0.');
|
|
4007
|
+
delete options.chartExBinSize;
|
|
4008
|
+
}
|
|
4009
|
+
if (options.chartExParentLabels && ![
|
|
4010
|
+
'none',
|
|
4011
|
+
'overlapping',
|
|
4012
|
+
'banner'
|
|
4013
|
+
].includes(options.chartExParentLabels)) {
|
|
4014
|
+
console.warn('Warning: chart.chartExParentLabels options: `none`, `overlapping`, `banner`.');
|
|
4015
|
+
delete options.chartExParentLabels;
|
|
4016
|
+
}
|
|
4017
|
+
}
|
|
3662
4018
|
// STEP 4: Set props (_type already set to chart on the literal above).
|
|
3663
4019
|
// The chart object stores the position/placeholder that gen-xml reads; chart `fill`
|
|
3664
4020
|
// is a color string (vs ObjectOptions' ShapeFillProps) and is never read here, so it
|
|
@@ -3672,14 +4028,17 @@ function _object_without_properties_loose(source, excluded) {
|
|
|
3672
4028
|
});
|
|
3673
4029
|
resultObject.chartRid = getNewRelId(target);
|
|
3674
4030
|
// STEP 5: Add this chart to this Slide Rels (rId/rels count spans all slides! Count all images to get next rId)
|
|
4031
|
+
// ChartEx charts are a separate part type with their own content type and relationship type,
|
|
4032
|
+
// so the file name is what every downstream emitter keys off (see `xml/package.ts`)
|
|
4033
|
+
const fileName = isChartexType(options._type) ? `chartEx${chartId}.xml` : `chart${chartId}.xml`;
|
|
3675
4034
|
target._relsChart.push({
|
|
3676
4035
|
rId: getNewRelId(target),
|
|
3677
4036
|
data: tmpData,
|
|
3678
4037
|
opts: options,
|
|
3679
4038
|
type: options._type,
|
|
3680
4039
|
globalId: chartId,
|
|
3681
|
-
fileName
|
|
3682
|
-
Target: `/ppt/charts
|
|
4040
|
+
fileName,
|
|
4041
|
+
Target: `/ppt/charts/${fileName}`
|
|
3683
4042
|
});
|
|
3684
4043
|
target._slideObjects.push(resultObject);
|
|
3685
4044
|
return resultObject;
|
|
@@ -3765,8 +4124,45 @@ function isSvgFillSource(data, path) {
|
|
|
3765
4124
|
});
|
|
3766
4125
|
return rId;
|
|
3767
4126
|
}
|
|
4127
|
+
function isStructuredImageFill(fill) {
|
|
4128
|
+
return !!fill && (fill.type === 'image' || !!fill.image);
|
|
4129
|
+
}
|
|
4130
|
+
/**
|
|
4131
|
+
* Resolve a picture fill's image into a slide relationship.
|
|
4132
|
+
* `genXmlColorSelection` is pure, so the rId has to be attached before XML is generated.
|
|
4133
|
+
*/ function resolveImageFill(target, fill) {
|
|
4134
|
+
var _ref, _ref1, _ref2, _ref3;
|
|
4135
|
+
var _fill_image, _fill_image1;
|
|
4136
|
+
if (!fill || typeof fill !== 'object') return;
|
|
4137
|
+
if (!isStructuredImageFill(fill) && !(fill.data || fill.path)) return;
|
|
4138
|
+
if (!isStructuredImageFill(fill) && (fill.color || fill.type && fill.type !== 'image')) return;
|
|
4139
|
+
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 : '';
|
|
4140
|
+
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 : '';
|
|
4141
|
+
if (!data && !path) {
|
|
4142
|
+
console.warn('[pptxgenjs] `fill.type:"image"` requires `fill.image.data` or `fill.image.path` - fill ignored');
|
|
4143
|
+
return;
|
|
4144
|
+
}
|
|
4145
|
+
if (data && !data.toLowerCase().includes('base64,')) {
|
|
4146
|
+
console.warn('[pptxgenjs] `fill.image.data` lacks a base64 header (ex: \'image/png;base64,iV[...]\') - fill ignored');
|
|
4147
|
+
return;
|
|
4148
|
+
}
|
|
4149
|
+
const rId = registerTableCellImageFill(target, {
|
|
4150
|
+
data,
|
|
4151
|
+
path
|
|
4152
|
+
});
|
|
4153
|
+
if (!rId) return;
|
|
4154
|
+
if (fill.image) fill.image._rId = rId;
|
|
4155
|
+
else fill._rId = rId;
|
|
4156
|
+
}
|
|
4157
|
+
function resolveObjectImageFills(target, options) {
|
|
4158
|
+
var _options_fillOverlay;
|
|
4159
|
+
if (!options) return;
|
|
4160
|
+
if (options.fill) resolveImageFill(target, options.fill);
|
|
4161
|
+
if ((_options_fillOverlay = options.fillOverlay) === null || _options_fillOverlay === void 0 ? void 0 : _options_fillOverlay.fill) resolveImageFill(target, options.fillOverlay.fill);
|
|
4162
|
+
}
|
|
3768
4163
|
function addImageDefinition(target, opt) {
|
|
3769
|
-
var _strImagePath_substring_split__split_pop;
|
|
4164
|
+
var _opt_fillOverlay, _strImagePath_substring_split__split_pop;
|
|
4165
|
+
if ((_opt_fillOverlay = opt.fillOverlay) === null || _opt_fillOverlay === void 0 ? void 0 : _opt_fillOverlay.fill) resolveImageFill(target, opt.fillOverlay.fill);
|
|
3770
4166
|
const newObject = {
|
|
3771
4167
|
_type: (/* inlined export .SLIDE_OBJECT_TYPES.image */"image"),
|
|
3772
4168
|
text: undefined,
|
|
@@ -3836,7 +4232,16 @@ function addImageDefinition(target, opt) {
|
|
|
3836
4232
|
softEdge: opt.softEdge,
|
|
3837
4233
|
reflection: opt.reflection,
|
|
3838
4234
|
blur: opt.blur,
|
|
4235
|
+
fillOverlay: opt.fillOverlay,
|
|
4236
|
+
effectDag: opt.effectDag,
|
|
4237
|
+
alphaEffects: opt.alphaEffects,
|
|
4238
|
+
recolor: opt.recolor,
|
|
4239
|
+
styleRef: opt.styleRef,
|
|
3839
4240
|
line: opt.line || imageBorderToLine(opt.border),
|
|
4241
|
+
// non-visual props and locks are part of the object's identity, not its geometry
|
|
4242
|
+
title: opt.title,
|
|
4243
|
+
hidden: opt.hidden,
|
|
4244
|
+
lock: opt.lock,
|
|
3840
4245
|
_sizeFromImage: !intWidth && !intHeight,
|
|
3841
4246
|
// addImage always writes x/y/w/h defaults, so remember which axes the caller actually set
|
|
3842
4247
|
// (placeholder geometry must not overwrite explicit placement; fujita-h d7e3e93 / #996).
|
|
@@ -3916,8 +4321,14 @@ function addImageDefinition(target, opt) {
|
|
|
3916
4321
|
});
|
|
3917
4322
|
objHyperlink._rId = imageRelId;
|
|
3918
4323
|
newObject.hyperlink = objHyperlink;
|
|
4324
|
+
// the action sound (if any) needs its own relationship
|
|
4325
|
+
resolveHyperlinkRels(target, objHyperlink);
|
|
3919
4326
|
}
|
|
3920
4327
|
}
|
|
4328
|
+
if (typeof opt.hyperlinkHover === 'object') {
|
|
4329
|
+
resolveHyperlinkRels(target, opt.hyperlinkHover);
|
|
4330
|
+
newObject.hyperlinkHover = opt.hyperlinkHover;
|
|
4331
|
+
}
|
|
3921
4332
|
// STEP 6: Add object to slide
|
|
3922
4333
|
target._slideObjects.push(newObject);
|
|
3923
4334
|
}
|
|
@@ -3940,12 +4351,25 @@ function addImageDefinition(target, opt) {
|
|
|
3940
4351
|
const slideData = {
|
|
3941
4352
|
_type: (/* inlined export .SLIDE_OBJECT_TYPES.media */"media")
|
|
3942
4353
|
};
|
|
3943
|
-
//
|
|
3944
|
-
|
|
4354
|
+
// `link` with no `path`/`data` used to throw, so treating it as "reference, do not embed" cannot
|
|
4355
|
+
// change any deck that works today
|
|
4356
|
+
const isLinked = !!strLink && !strPath && !strData && (strType === 'audio' || strType === 'video');
|
|
4357
|
+
if (strLink && (strPath || strData) && strType !== 'online') {
|
|
4358
|
+
console.warn('[pptxgenjs] addMedia: `link` is ignored when `path` or `data` is given - the media is embedded');
|
|
4359
|
+
}
|
|
4360
|
+
// STEP 1: REALITY-CHECK - what each media kind needs, rather than one chain of conditions
|
|
4361
|
+
if (strType === 'audioCd') {
|
|
4362
|
+
var _opt_audioCd_start, _opt_audioCd, _opt_audioCd_end, _opt_audioCd1;
|
|
4363
|
+
// `a:st`/`a:end` and their `@track` are all required by CT_AudioCD
|
|
4364
|
+
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') {
|
|
4365
|
+
throw new Error('addMedia() error: `type:"audioCd"` requires `audioCd.start.track` and `audioCd.end.track`');
|
|
4366
|
+
}
|
|
4367
|
+
} else if (!strPath && !strData && strType !== 'online' && !isLinked) {
|
|
3945
4368
|
throw new Error('addMedia() error: either `data` or `path` are required!');
|
|
3946
4369
|
} else if (strData && !strData.toLowerCase().includes('base64,')) {
|
|
3947
4370
|
throw new Error('addMedia() error: `data` value lacks a base64 header! Ex: \'video/mpeg;base64,NMP[...]\')');
|
|
3948
|
-
}
|
|
4371
|
+
}
|
|
4372
|
+
if (strCover && !strCover.toLowerCase().includes('base64,')) {
|
|
3949
4373
|
throw new Error('addMedia() error: `cover` value lacks a base64 header! Ex: \'data:image/png;base64,iV[...]\')');
|
|
3950
4374
|
}
|
|
3951
4375
|
// Online Video: requires `link`
|
|
@@ -3954,7 +4378,7 @@ function addImageDefinition(target, opt) {
|
|
|
3954
4378
|
}
|
|
3955
4379
|
// Timing-tree playback (ECMA-376 §19.5 CT_TLMediaNode): no silent fallbacks.
|
|
3956
4380
|
// `fullScrn` exists only on CT_TLMediaNodeVideo; linked `online` media has no embedded media node.
|
|
3957
|
-
if (strType
|
|
4381
|
+
if (opt.fullScreen && strType !== 'video') {
|
|
3958
4382
|
throw new Error('addMedia() error: `fullScreen` is only valid on type "video"');
|
|
3959
4383
|
}
|
|
3960
4384
|
if (strType === 'online' && (opt.autoplay || opt.loop || opt.fullScreen || opt.mute)) {
|
|
@@ -3962,7 +4386,7 @@ function addImageDefinition(target, opt) {
|
|
|
3962
4386
|
}
|
|
3963
4387
|
// FIXME: 20190707
|
|
3964
4388
|
// strType = strData ? strData.split(';')[0].split('/')[0] : strType
|
|
3965
|
-
strExtn = opt.extn || (strData ? strData.split(';')[0].split('/')[1] : strPath.split('.').pop()) || 'mp3';
|
|
4389
|
+
strExtn = opt.extn || (strType === 'wav' ? 'wav' : strData ? strData.split(';')[0].split('/')[1] : (strPath || strLink).split('.').pop()) || 'mp3';
|
|
3966
4390
|
// STEP 2: Set type, media
|
|
3967
4391
|
slideData.mtype = strType;
|
|
3968
4392
|
slideData.media = strPath || 'preencoded.mov';
|
|
@@ -3989,6 +4413,11 @@ function addImageDefinition(target, opt) {
|
|
|
3989
4413
|
slideData.options.loop = opt.loop;
|
|
3990
4414
|
slideData.options.fullScreen = opt.fullScreen;
|
|
3991
4415
|
slideData.options.mute = opt.mute;
|
|
4416
|
+
slideData.options.contentType = opt.contentType;
|
|
4417
|
+
slideData.options.audioCd = opt.audioCd;
|
|
4418
|
+
slideData.options.isPhoto = opt.isPhoto;
|
|
4419
|
+
slideData.options.userDrawn = opt.userDrawn;
|
|
4420
|
+
slideData.options.isLinked = isLinked;
|
|
3992
4421
|
// STEP 4: Add this media to this Slide Rels (rId/rels count spans all slides! Count all media to get next rId)
|
|
3993
4422
|
/**
|
|
3994
4423
|
* NOTE:
|
|
@@ -3998,7 +4427,41 @@ function addImageDefinition(target, opt) {
|
|
|
3998
4427
|
* - Audio/Video files consume *TWO* rId's:
|
|
3999
4428
|
* <Relationship Id="rId2" Target="../media/media1.mov" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/video"/>
|
|
4000
4429
|
* <Relationship Id="rId3" Target="../media/media1.mov" Type="http://schemas.microsoft.com/office/2007/relationships/media"/>
|
|
4001
|
-
*/ if (strType === '
|
|
4430
|
+
*/ if (strType === 'audioCd') {
|
|
4431
|
+
// CD audio references the listener's drive: no media part, no media relationship, cover only
|
|
4432
|
+
const coverRid = getNewRelId(target);
|
|
4433
|
+
target._relsMedia.push({
|
|
4434
|
+
path: 'preencoded.png',
|
|
4435
|
+
type: 'image/png',
|
|
4436
|
+
extn: 'png',
|
|
4437
|
+
data: strCover,
|
|
4438
|
+
rId: coverRid,
|
|
4439
|
+
Target: `../media/${imageTargetStem(target)}.png`
|
|
4440
|
+
});
|
|
4441
|
+
slideData._coverRid = coverRid;
|
|
4442
|
+
} else if (strType === 'wav') {
|
|
4443
|
+
// `a:wavAudioFile` is the legacy embedded-WAV element: one audio relationship, no `p14:media`
|
|
4444
|
+
const relId1 = getNewRelId(target);
|
|
4445
|
+
target._relsMedia.push({
|
|
4446
|
+
path: strPath || 'preencoded.wav',
|
|
4447
|
+
type: 'audio/wav',
|
|
4448
|
+
extn: 'wav',
|
|
4449
|
+
data: strData || '',
|
|
4450
|
+
rId: relId1,
|
|
4451
|
+
Target: `../media/media-${target._slideNum}-${target._relsMedia.length + 1}.wav`
|
|
4452
|
+
});
|
|
4453
|
+
slideData.mediaRid = relId1;
|
|
4454
|
+
const coverRid = getNewRelId(target);
|
|
4455
|
+
target._relsMedia.push({
|
|
4456
|
+
path: 'preencoded.png',
|
|
4457
|
+
type: 'image/png',
|
|
4458
|
+
extn: 'png',
|
|
4459
|
+
data: strCover,
|
|
4460
|
+
rId: coverRid,
|
|
4461
|
+
Target: `../media/${imageTargetStem(target)}.png`
|
|
4462
|
+
});
|
|
4463
|
+
slideData._coverRid = coverRid;
|
|
4464
|
+
} else if (strType === 'online') {
|
|
4002
4465
|
const relId1 = getNewRelId(target);
|
|
4003
4466
|
// A: Add video
|
|
4004
4467
|
target._relsMedia.push({
|
|
@@ -4023,6 +4486,8 @@ function addImageDefinition(target, opt) {
|
|
|
4023
4486
|
// PERF: Duplicate media should reuse existing `Target` value and not create an additional copy
|
|
4024
4487
|
const dupeItem = target._relsMedia.filter((item)=>item.path && item.path === strPath && item.type === strType + '/' + strExtn && !item.isDuplicate)[0];
|
|
4025
4488
|
// A: "relationships/video"
|
|
4489
|
+
// Linked media keeps this exact three-relationship shape - the rIds the emitter derives from
|
|
4490
|
+
// `mediaRid` stay valid - and only points the targets outside the package
|
|
4026
4491
|
const relId1 = getNewRelId(target);
|
|
4027
4492
|
target._relsMedia.push({
|
|
4028
4493
|
path: strPath || 'preencoded' + strExtn,
|
|
@@ -4031,7 +4496,8 @@ function addImageDefinition(target, opt) {
|
|
|
4031
4496
|
data: strData || '',
|
|
4032
4497
|
rId: relId1,
|
|
4033
4498
|
isDuplicate: !!(dupeItem === null || dupeItem === void 0 ? void 0 : dupeItem.Target),
|
|
4034
|
-
|
|
4499
|
+
isLinked,
|
|
4500
|
+
Target: isLinked ? strLink : (dupeItem === null || dupeItem === void 0 ? void 0 : dupeItem.Target) ? dupeItem.Target : `../media/media-${target._slideNum}-${target._relsMedia.length + 1}.${strExtn}`
|
|
4035
4501
|
});
|
|
4036
4502
|
slideData.mediaRid = relId1;
|
|
4037
4503
|
// B: "relationships/media"
|
|
@@ -4042,7 +4508,8 @@ function addImageDefinition(target, opt) {
|
|
|
4042
4508
|
data: strData || '',
|
|
4043
4509
|
rId: getNewRelId(target),
|
|
4044
4510
|
isDuplicate: !!(dupeItem === null || dupeItem === void 0 ? void 0 : dupeItem.Target),
|
|
4045
|
-
|
|
4511
|
+
isLinked,
|
|
4512
|
+
Target: isLinked ? strLink : (dupeItem === null || dupeItem === void 0 ? void 0 : dupeItem.Target) ? dupeItem.Target : `../media/media-${target._slideNum}-${target._relsMedia.length + 0}.${strExtn}`
|
|
4046
4513
|
});
|
|
4047
4514
|
// C: Add cover (preview/overlay) image
|
|
4048
4515
|
target._relsMedia.push({
|
|
@@ -4278,11 +4745,107 @@ function nextExtPartName(target, prefix, extn) {
|
|
|
4278
4745
|
opts.line.endArrowType = opts.lineTail;
|
|
4279
4746
|
}
|
|
4280
4747
|
}
|
|
4748
|
+
/**
|
|
4749
|
+
* Create the relationships a hyperlink needs: the link target, and its action sound when set
|
|
4750
|
+
* - `genXmlHyperlink` is pure, so both ids have to exist before the XML is generated
|
|
4751
|
+
*/ function resolveHyperlinkRels(target, link) {
|
|
4752
|
+
if (!link || typeof link !== 'object') return;
|
|
4753
|
+
if (!link._rId) {
|
|
4754
|
+
var _link_url;
|
|
4755
|
+
var _link_slide;
|
|
4756
|
+
if (!link.url && !link.slide) {
|
|
4757
|
+
console.warn('[pptxgenjs] a hyperlink requires either `url` or `slide` - link ignored');
|
|
4758
|
+
return;
|
|
4759
|
+
}
|
|
4760
|
+
const relId = getNewRelId(target);
|
|
4761
|
+
target._rels.push({
|
|
4762
|
+
type: (/* inlined export .SLIDE_OBJECT_TYPES.hyperlink */"hyperlink"),
|
|
4763
|
+
data: link.slide ? 'slide' : 'dummy',
|
|
4764
|
+
rId: relId,
|
|
4765
|
+
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()) || ''
|
|
4766
|
+
});
|
|
4767
|
+
link._rId = relId;
|
|
4768
|
+
} else if (target._rels.filter((rel)=>rel.rId === link._rId).length === 0) {
|
|
4769
|
+
var _link_url1;
|
|
4770
|
+
var _link_slide1;
|
|
4771
|
+
target._rels.push({
|
|
4772
|
+
type: (/* inlined export .SLIDE_OBJECT_TYPES.hyperlink */"hyperlink"),
|
|
4773
|
+
data: link.slide ? 'slide' : 'dummy',
|
|
4774
|
+
rId: link._rId,
|
|
4775
|
+
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()) || ''
|
|
4776
|
+
});
|
|
4777
|
+
}
|
|
4778
|
+
// ECMA-376 20.1.2.2.32 allows only WAV here, so anything else is dropped rather than linked
|
|
4779
|
+
const sound = link.sound;
|
|
4780
|
+
if (!sound) return;
|
|
4781
|
+
if (!sound._sndRId) {
|
|
4782
|
+
var _sound_data, _sound_path;
|
|
4783
|
+
const data = (_sound_data = sound.data) !== null && _sound_data !== void 0 ? _sound_data : '';
|
|
4784
|
+
const path = (_sound_path = sound.path) !== null && _sound_path !== void 0 ? _sound_path : '';
|
|
4785
|
+
if (!data && !path) {
|
|
4786
|
+
console.warn('[pptxgenjs] hyperlink `sound` requires `data` or `path` - sound ignored');
|
|
4787
|
+
link.sound = undefined;
|
|
4788
|
+
return;
|
|
4789
|
+
}
|
|
4790
|
+
if (data && !data.toLowerCase().includes('base64,')) {
|
|
4791
|
+
console.warn('[pptxgenjs] hyperlink `sound.data` lacks a base64 header - sound ignored');
|
|
4792
|
+
link.sound = undefined;
|
|
4793
|
+
return;
|
|
4794
|
+
}
|
|
4795
|
+
const rId = getNewRelId(target);
|
|
4796
|
+
target._relsMedia.push({
|
|
4797
|
+
path: path || 'preencoded.wav',
|
|
4798
|
+
type: 'audio/wav',
|
|
4799
|
+
extn: 'wav',
|
|
4800
|
+
data,
|
|
4801
|
+
rId,
|
|
4802
|
+
Target: `../media/audio-${target._slideNum}-${target._relsMedia.length + 1}.wav`
|
|
4803
|
+
});
|
|
4804
|
+
sound._sndRId = rId;
|
|
4805
|
+
} else if (!target._relsMedia.some((rel)=>rel.rId === sound._sndRId)) {
|
|
4806
|
+
target._relsMedia.push({
|
|
4807
|
+
path: sound.path || 'preencoded.wav',
|
|
4808
|
+
type: 'audio/wav',
|
|
4809
|
+
extn: 'wav',
|
|
4810
|
+
data: sound.data,
|
|
4811
|
+
rId: sound._sndRId,
|
|
4812
|
+
Target: `../media/audio-${target._slideNum}-${target._relsMedia.length + 1}.wav`
|
|
4813
|
+
});
|
|
4814
|
+
}
|
|
4815
|
+
}
|
|
4816
|
+
/**
|
|
4817
|
+
* Resolve a picture bullet's image into a slide relationship
|
|
4818
|
+
* - the paragraph emitter is pure, so the rId has to exist before the XML is generated
|
|
4819
|
+
*/ function resolveBulletImage(target, opts) {
|
|
4820
|
+
var _ref;
|
|
4821
|
+
var _exec;
|
|
4822
|
+
const bullet = typeof (opts === null || opts === void 0 ? void 0 : opts.bullet) === 'object' ? opts.bullet : undefined;
|
|
4823
|
+
if (!(bullet === null || bullet === void 0 ? void 0 : bullet.image) || bullet._imageRId) return;
|
|
4824
|
+
if (!bullet.image.toLowerCase().includes('base64,')) {
|
|
4825
|
+
console.warn('[pptxgenjs] `bullet.image` must be base64 image data (ex: \'image/png;base64,iV[...]\') - picture bullet ignored');
|
|
4826
|
+
bullet.image = undefined;
|
|
4827
|
+
return;
|
|
4828
|
+
}
|
|
4829
|
+
const extn = (_ref = (_exec = /image\/(\w+);/.exec(bullet.image)) === null || _exec === void 0 ? void 0 : _exec[1]) !== null && _ref !== void 0 ? _ref : 'png';
|
|
4830
|
+
const rId = getNewRelId(target);
|
|
4831
|
+
target._relsMedia.push({
|
|
4832
|
+
path: `preencoded.${extn}`,
|
|
4833
|
+
type: `image/${extn}`,
|
|
4834
|
+
extn,
|
|
4835
|
+
data: bullet.image,
|
|
4836
|
+
rId,
|
|
4837
|
+
Target: `../media/${imageTargetStem(target)}.${extn}`
|
|
4838
|
+
});
|
|
4839
|
+
bullet._imageRId = rId;
|
|
4840
|
+
}
|
|
4281
4841
|
function addShapeDefinition(target, shapeName, opts) {
|
|
4282
4842
|
const options = typeof opts === 'object' ? opts : {};
|
|
4283
4843
|
options.line = options.line || {
|
|
4284
4844
|
type: 'none'
|
|
4285
4845
|
};
|
|
4846
|
+
resolveHyperlinkRels(target, options.hyperlink);
|
|
4847
|
+
resolveHyperlinkRels(target, options.hyperlinkHover);
|
|
4848
|
+
resolveObjectImageFills(target, options);
|
|
4286
4849
|
const newObject = {
|
|
4287
4850
|
_type: (/* inlined export .SLIDE_OBJECT_TYPES.text */"text"),
|
|
4288
4851
|
shape: shapeName || core_enums_SHAPE_TYPE.RECTANGLE,
|
|
@@ -4315,7 +4878,9 @@ function addShapeDefinition(target, shapeName, opts) {
|
|
|
4315
4878
|
sourceAnchorPos: options.line.sourceAnchorPos,
|
|
4316
4879
|
targetAnchorPos: options.line.targetAnchorPos,
|
|
4317
4880
|
isConnector: options.line.isConnector || hasConnectorEnds,
|
|
4318
|
-
curveadjust: options.line.curveadjust
|
|
4881
|
+
curveadjust: options.line.curveadjust,
|
|
4882
|
+
_sourceName: options.line._sourceName,
|
|
4883
|
+
_targetName: options.line._targetName
|
|
4319
4884
|
};
|
|
4320
4885
|
if (typeof options.line === 'object' && options.line.type !== 'none') options.line = newLineOpts;
|
|
4321
4886
|
// 2: Set options defaults
|
|
@@ -4372,12 +4937,13 @@ function addShapeDefinition(target, shapeName, opts) {
|
|
|
4372
4937
|
// STEP 2: Transform `tableRows` into well-formatted TableCell's
|
|
4373
4938
|
// tableRows can be object or plain text array: `[{text:'cell 1'}, {text:'cell 2', options:{color:'ff0000'}}]` | `["cell 1", "cell 2"]`
|
|
4374
4939
|
const arrRows = [];
|
|
4375
|
-
|
|
4940
|
+
if (isStructuredImageFill(opt.fill)) resolveImageFill(target, opt.fill);
|
|
4941
|
+
const tableFillRid = isStructuredImageFill(opt.fill) ? undefined : registerTableCellImageFill(target, opt.fill);
|
|
4376
4942
|
tableRows.forEach((row)=>{
|
|
4377
4943
|
const newRow = [];
|
|
4378
4944
|
if (Array.isArray(row)) {
|
|
4379
4945
|
row.forEach((cell)=>{
|
|
4380
|
-
var _newCell_options
|
|
4946
|
+
var _newCell_options;
|
|
4381
4947
|
// A:
|
|
4382
4948
|
const newCell = {
|
|
4383
4949
|
_type: (/* inlined export .SLIDE_OBJECT_TYPES.tablecell */"tablecell"),
|
|
@@ -4447,8 +5013,13 @@ function addShapeDefinition(target, shapeName, opts) {
|
|
|
4447
5013
|
transparency: typeof cellBorder[idx].transparency === 'number' ? cellBorder[idx].transparency : undefined
|
|
4448
5014
|
};
|
|
4449
5015
|
});
|
|
4450
|
-
|
|
4451
|
-
|
|
5016
|
+
if (isStructuredImageFill(cellOpts.fill)) {
|
|
5017
|
+
resolveImageFill(target, cellOpts.fill);
|
|
5018
|
+
} else {
|
|
5019
|
+
var _registerTableCellImageFill;
|
|
5020
|
+
const fillRid = (_registerTableCellImageFill = registerTableCellImageFill(target, cellOpts.fill)) !== null && _registerTableCellImageFill !== void 0 ? _registerTableCellImageFill : cellOpts.fill ? undefined : tableFillRid;
|
|
5021
|
+
if (fillRid) cellOpts._fillRid = fillRid;
|
|
5022
|
+
}
|
|
4452
5023
|
// LAST:
|
|
4453
5024
|
newRow.push(newCell);
|
|
4454
5025
|
});
|
|
@@ -4655,7 +5226,8 @@ function addShapeDefinition(target, shapeName, opts) {
|
|
|
4655
5226
|
*/ function addTextDefinition(target, text, opts, isPlaceholder) {
|
|
4656
5227
|
var _newObject_options;
|
|
4657
5228
|
var // STEP 2: Create/Clean text options
|
|
4658
|
-
_newObject_text;
|
|
5229
|
+
_newObject_text, _newObject_options1, _newObject_options2, _newObject_text1;
|
|
5230
|
+
resolveObjectImageFills(target, opts);
|
|
4659
5231
|
const newObject = {
|
|
4660
5232
|
_type: isPlaceholder ? (/* inlined export .SLIDE_OBJECT_TYPES.placeholder */"placeholder") : (/* inlined export .SLIDE_OBJECT_TYPES.text */"text"),
|
|
4661
5233
|
shape: (opts === null || opts === void 0 ? void 0 : opts.shape) || core_enums_SHAPE_TYPE.RECTANGLE,
|
|
@@ -4786,8 +5358,18 @@ function addShapeDefinition(target, shapeName, opts) {
|
|
|
4786
5358
|
// STEP 1: Create/Clean object options
|
|
4787
5359
|
newObject.options = cleanOpts((_newObject_options = newObject.options) !== null && _newObject_options !== void 0 ? _newObject_options : {});
|
|
4788
5360
|
(_newObject_text = newObject.text) === null || _newObject_text === void 0 ? void 0 : _newObject_text.forEach((item)=>item.options = cleanOpts(item.options || {}));
|
|
4789
|
-
// STEP 3: Create hyperlinks
|
|
5361
|
+
// STEP 3: Create hyperlinks, hover actions, and any picture-bullet relationships
|
|
4790
5362
|
createHyperlinkRels(target, newObject.text || '');
|
|
5363
|
+
resolveHyperlinkRels(target, (_newObject_options1 = newObject.options) === null || _newObject_options1 === void 0 ? void 0 : _newObject_options1.hyperlink);
|
|
5364
|
+
resolveHyperlinkRels(target, (_newObject_options2 = newObject.options) === null || _newObject_options2 === void 0 ? void 0 : _newObject_options2.hyperlinkHover);
|
|
5365
|
+
resolveBulletImage(target, newObject.options);
|
|
5366
|
+
(_newObject_text1 = newObject.text) === null || _newObject_text1 === void 0 ? void 0 : _newObject_text1.forEach((item)=>{
|
|
5367
|
+
var _item_options, _item_options_hyperlink, _item_options1;
|
|
5368
|
+
resolveHyperlinkRels(target, (_item_options = item.options) === null || _item_options === void 0 ? void 0 : _item_options.hyperlinkHover);
|
|
5369
|
+
// a click link already has its target rel; this adds its action sound
|
|
5370
|
+
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);
|
|
5371
|
+
resolveBulletImage(target, item.options);
|
|
5372
|
+
});
|
|
4791
5373
|
// LAST: Add object to Slide
|
|
4792
5374
|
target._slideObjects.push(newObject);
|
|
4793
5375
|
}
|
|
@@ -4915,6 +5497,11 @@ function addShapeDefinition(target, shapeName, opts) {
|
|
|
4915
5497
|
});
|
|
4916
5498
|
}
|
|
4917
5499
|
}
|
|
5500
|
+
if (text && typeof text === 'object' && !Array.isArray(text) && text.options) {
|
|
5501
|
+
var _text_options_hyperlink;
|
|
5502
|
+
resolveHyperlinkRels(target, text.options.hyperlinkHover);
|
|
5503
|
+
if ((_text_options_hyperlink = text.options.hyperlink) === null || _text_options_hyperlink === void 0 ? void 0 : _text_options_hyperlink.sound) resolveHyperlinkRels(target, text.options.hyperlink);
|
|
5504
|
+
}
|
|
4918
5505
|
});
|
|
4919
5506
|
}
|
|
4920
5507
|
function makeGroupCollector(parent) {
|
|
@@ -4934,6 +5521,7 @@ function makeGroupCollector(parent) {
|
|
|
4934
5521
|
* Child coordinates are relative to the group origin (`chOff` 0,0 / `chExt` = group size).
|
|
4935
5522
|
*/ function addGroupDefinition(target, opts, objects) {
|
|
4936
5523
|
var _opts_x, _opts_y, _opts_w, _opts_h, _opts_rotate;
|
|
5524
|
+
if (opts.fill) resolveImageFill(target, opts.fill);
|
|
4937
5525
|
const groupCount = target._slideObjects.filter((obj)=>obj._type === (/* inlined export .SLIDE_OBJECT_TYPES.group */"group")).length;
|
|
4938
5526
|
const newObject = {
|
|
4939
5527
|
_type: (/* inlined export .SLIDE_OBJECT_TYPES.group */"group"),
|
|
@@ -4944,7 +5532,11 @@ function makeGroupCollector(parent) {
|
|
|
4944
5532
|
h: (_opts_h = opts.h) !== null && _opts_h !== void 0 ? _opts_h : 1,
|
|
4945
5533
|
rotate: (_opts_rotate = opts.rotate) !== null && _opts_rotate !== void 0 ? _opts_rotate : 0,
|
|
4946
5534
|
shadow: opts.shadow ? correctShadowOptions(opts.shadow) : undefined,
|
|
4947
|
-
|
|
5535
|
+
fill: opts.fill,
|
|
5536
|
+
objectName: opts.objectName ? encodeXmlEntities(opts.objectName) : `Group ${groupCount + 1}`,
|
|
5537
|
+
title: opts.title,
|
|
5538
|
+
hidden: opts.hidden,
|
|
5539
|
+
lock: opts.lock
|
|
4948
5540
|
},
|
|
4949
5541
|
_objects: objects
|
|
4950
5542
|
};
|
|
@@ -4984,10 +5576,60 @@ function createGroupBuilder(parent, objects) {
|
|
|
4984
5576
|
addGroupDefinition(collector, options, children);
|
|
4985
5577
|
objects.push(...collector._slideObjects);
|
|
4986
5578
|
return builder;
|
|
5579
|
+
},
|
|
5580
|
+
addConnector (options) {
|
|
5581
|
+
const collector = makeGroupCollector(parent);
|
|
5582
|
+
addConnectorDefinition(collector, options !== null && options !== void 0 ? options : {});
|
|
5583
|
+
objects.push(...collector._slideObjects);
|
|
5584
|
+
return builder;
|
|
4987
5585
|
}
|
|
4988
5586
|
};
|
|
4989
5587
|
return builder;
|
|
4990
5588
|
}
|
|
5589
|
+
const CONNECTOR_PRESETS = new Set([
|
|
5590
|
+
'line',
|
|
5591
|
+
'straightConnector1',
|
|
5592
|
+
'bentConnector2',
|
|
5593
|
+
'bentConnector3',
|
|
5594
|
+
'bentConnector4',
|
|
5595
|
+
'bentConnector5',
|
|
5596
|
+
'curvedConnector2',
|
|
5597
|
+
'curvedConnector3',
|
|
5598
|
+
'curvedConnector4',
|
|
5599
|
+
'curvedConnector5'
|
|
5600
|
+
]);
|
|
5601
|
+
/**
|
|
5602
|
+
* Additive connector convenience: maps onto `addShape` + `line.isConnector`.
|
|
5603
|
+
* `start`/`end` `objectName`s are resolved to `sourceId`/`targetId` at emit time.
|
|
5604
|
+
*/ function addConnectorDefinition(target, opt) {
|
|
5605
|
+
var _opt_line, _ref, _ref1;
|
|
5606
|
+
var _opt_line1, _opt_line2, _opt_start, _opt_line3, _opt_end, _opt_line4, _opt_start1, _opt_end1;
|
|
5607
|
+
const requested = opt.type && CONNECTOR_PRESETS.has(opt.type) ? opt.type : 'straightConnector1';
|
|
5608
|
+
const shapeName = requested === 'line' ? core_enums_SHAPE_TYPE.LINE : requested;
|
|
5609
|
+
const line = gen_objects_object_spread_props(gen_objects_object_spread({}, (_opt_line = opt.line) !== null && _opt_line !== void 0 ? _opt_line : {}), {
|
|
5610
|
+
isConnector: true,
|
|
5611
|
+
sourceId: (_opt_line1 = opt.line) === null || _opt_line1 === void 0 ? void 0 : _opt_line1.sourceId,
|
|
5612
|
+
targetId: (_opt_line2 = opt.line) === null || _opt_line2 === void 0 ? void 0 : _opt_line2.targetId,
|
|
5613
|
+
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,
|
|
5614
|
+
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,
|
|
5615
|
+
_sourceName: (_opt_start1 = opt.start) === null || _opt_start1 === void 0 ? void 0 : _opt_start1.shape,
|
|
5616
|
+
_targetName: (_opt_end1 = opt.end) === null || _opt_end1 === void 0 ? void 0 : _opt_end1.shape
|
|
5617
|
+
});
|
|
5618
|
+
addShapeDefinition(target, shapeName, {
|
|
5619
|
+
x: opt.x,
|
|
5620
|
+
y: opt.y,
|
|
5621
|
+
w: opt.w,
|
|
5622
|
+
h: opt.h,
|
|
5623
|
+
objectName: opt.objectName,
|
|
5624
|
+
rotate: opt.rotate,
|
|
5625
|
+
flipH: opt.flipH,
|
|
5626
|
+
flipV: opt.flipV,
|
|
5627
|
+
fill: opt.fill,
|
|
5628
|
+
shadow: opt.shadow,
|
|
5629
|
+
styleRef: opt.styleRef,
|
|
5630
|
+
line
|
|
5631
|
+
});
|
|
5632
|
+
}
|
|
4991
5633
|
|
|
4992
5634
|
/**
|
|
4993
5635
|
* PptxGenJS: Slide Class
|
|
@@ -5032,6 +5674,8 @@ function slide_object_spread(target) {
|
|
|
5032
5674
|
delete runOpts.reflection;
|
|
5033
5675
|
delete runOpts.shadow;
|
|
5034
5676
|
delete runOpts.blur;
|
|
5677
|
+
delete runOpts.fillOverlay;
|
|
5678
|
+
delete runOpts.effectDag;
|
|
5035
5679
|
return runOpts;
|
|
5036
5680
|
}
|
|
5037
5681
|
class Slide {
|
|
@@ -5126,6 +5770,14 @@ class Slide {
|
|
|
5126
5770
|
addGroupDefinition(this, cloneOpts(options), children);
|
|
5127
5771
|
return this;
|
|
5128
5772
|
}
|
|
5773
|
+
/**
|
|
5774
|
+
* Add a connector (`p:cxnSp`). Additive convenience over `line.isConnector`.
|
|
5775
|
+
* Glue with `start`/`end` `objectName`s, or pass numeric `line.sourceId`/`targetId`.
|
|
5776
|
+
* @example slide.addConnector({ type: 'straightConnector1', start: { shape: 'BoxA', site: 3 }, end: { shape: 'BoxB', site: 1 } })
|
|
5777
|
+
*/ addConnector(options) {
|
|
5778
|
+
addConnectorDefinition(this, cloneOpts(options !== null && options !== void 0 ? options : {}));
|
|
5779
|
+
return this;
|
|
5780
|
+
}
|
|
5129
5781
|
/**
|
|
5130
5782
|
* Add a slide transition (`<p:transition>`, ECMA-376 §19.3.1.50 / MS-PPTX §2.2.1)
|
|
5131
5783
|
* @param {SlideTransitionProps} options - transition options
|
|
@@ -5339,64 +5991,6 @@ class Slide {
|
|
|
5339
5991
|
|
|
5340
5992
|
|
|
5341
5993
|
|
|
5342
|
-
/**
|
|
5343
|
-
* Chart title rendering.
|
|
5344
|
-
*/
|
|
5345
|
-
|
|
5346
|
-
/**
|
|
5347
|
-
* Create char title elements
|
|
5348
|
-
* @param {IChartPropsTitle} opts - options
|
|
5349
|
-
* @return {string} XML `<c:title>`
|
|
5350
|
-
*/ function genXmlTitle(opts, chartX, chartY) {
|
|
5351
|
-
const align = opts.titleAlign === 'left' || opts.titleAlign === 'right' ? `<a:pPr algn="${opts.titleAlign.substring(0, 1)}">` : '<a:pPr>';
|
|
5352
|
-
const rotate = opts.titleRotate ? `<a:bodyPr rot="${convertRotationDegrees(opts.titleRotate)}"/>` : '<a:bodyPr/>' // don't specify rotation to get default (ex. vertical for cat axis)
|
|
5353
|
-
;
|
|
5354
|
-
const sizeAttr = opts.fontSize ? `sz="${Math.round(opts.fontSize * 100)}"` : '' // only set the font size if specified. Powerpoint will handle the default size
|
|
5355
|
-
;
|
|
5356
|
-
const titleBold = opts.titleBold ? 1 : 0;
|
|
5357
|
-
const titleItalic = opts.titleItalic ? 1 : 0;
|
|
5358
|
-
let layout = '<c:layout/>';
|
|
5359
|
-
if (opts.titlePos && typeof opts.titlePos.x === 'number' && typeof opts.titlePos.y === 'number') {
|
|
5360
|
-
// NOTE: manualLayout x/y vals are *relative to entire slide*
|
|
5361
|
-
const totalX = opts.titlePos.x + (chartX !== null && chartX !== void 0 ? chartX : 0);
|
|
5362
|
-
const totalY = opts.titlePos.y + (chartY !== null && chartY !== void 0 ? chartY : 0);
|
|
5363
|
-
let valX = totalX === 0 ? 0 : totalX * (totalX / 5) / 10;
|
|
5364
|
-
if (valX >= 1) valX = valX / 10;
|
|
5365
|
-
if (valX >= 0.1) valX = valX / 10;
|
|
5366
|
-
let valY = totalY === 0 ? 0 : totalY * (totalY / 5) / 10;
|
|
5367
|
-
if (valY >= 1) valY = valY / 10;
|
|
5368
|
-
if (valY >= 0.1) valY = valY / 10;
|
|
5369
|
-
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>`;
|
|
5370
|
-
}
|
|
5371
|
-
return `<c:title>
|
|
5372
|
-
<c:tx>
|
|
5373
|
-
<c:rich>
|
|
5374
|
-
${rotate}
|
|
5375
|
-
<a:lstStyle/>
|
|
5376
|
-
<a:p>
|
|
5377
|
-
${align}
|
|
5378
|
-
<a:defRPr ${sizeAttr} b="${titleBold}" i="${titleItalic}" u="none" strike="noStrike">
|
|
5379
|
-
<a:solidFill>${createColorElement(opts.color || (/* inlined export .DEF_FONT_COLOR */"000000"))}</a:solidFill>
|
|
5380
|
-
<a:latin typeface="${encodeXmlEntities(opts.fontFace) || 'Arial'}"/>
|
|
5381
|
-
<a:ea typeface="${encodeXmlEntities(opts.fontFace) || 'Arial'}"/>
|
|
5382
|
-
</a:defRPr>
|
|
5383
|
-
</a:pPr>
|
|
5384
|
-
<a:r>
|
|
5385
|
-
<a:rPr ${sizeAttr} b="${titleBold}" i="${titleItalic}" u="none" strike="noStrike">
|
|
5386
|
-
<a:solidFill>${createColorElement(opts.color || (/* inlined export .DEF_FONT_COLOR */"000000"))}</a:solidFill>
|
|
5387
|
-
<a:latin typeface="${encodeXmlEntities(opts.fontFace) || 'Arial'}"/>
|
|
5388
|
-
<a:ea typeface="${encodeXmlEntities(opts.fontFace) || 'Arial'}"/>
|
|
5389
|
-
</a:rPr>
|
|
5390
|
-
<a:t>${encodeXmlEntities(opts.title) || ''}</a:t>
|
|
5391
|
-
</a:r>
|
|
5392
|
-
</a:p>
|
|
5393
|
-
</c:rich>
|
|
5394
|
-
</c:tx>
|
|
5395
|
-
${layout}
|
|
5396
|
-
<c:overlay val="0"/>
|
|
5397
|
-
</c:title>`;
|
|
5398
|
-
}
|
|
5399
|
-
|
|
5400
5994
|
function utils_define_property(obj, key, value) {
|
|
5401
5995
|
if (key in obj) {
|
|
5402
5996
|
Object.defineProperty(obj, key, {
|
|
@@ -5592,6 +6186,302 @@ function resolveAreaGrouping(barGrouping) {
|
|
|
5592
6186
|
return 'standard';
|
|
5593
6187
|
}
|
|
5594
6188
|
|
|
6189
|
+
/**
|
|
6190
|
+
* ChartEx (`cx:chartSpace`) rendering - MS-ODRAWXML 2.1.
|
|
6191
|
+
*
|
|
6192
|
+
* PowerPoint 2016 introduced chart layouts that ECMA-376 has no markup for. They are written to their
|
|
6193
|
+
* own part, in the `cx` namespace, and share nothing with the `c:` emitter in `xml.ts` beyond the
|
|
6194
|
+
* embedded workbook: the data lives in `cx:chartData` (one `cx:data` per series) and the layout is
|
|
6195
|
+
* selected by `cx:series@layoutId` rather than by the element name.
|
|
6196
|
+
*
|
|
6197
|
+
* The cell references point at the same worksheet `workbook.ts` writes for classic charts - column A
|
|
6198
|
+
* holds the category labels, columns B.. hold one series each, row 1 holds the series names - so no
|
|
6199
|
+
* chartex-specific workbook layout is needed.
|
|
6200
|
+
*/
|
|
6201
|
+
|
|
6202
|
+
|
|
6203
|
+
/** Sheet name written by `workbook.ts`; chartex cell references are absolute and always single-sheet */ const SHEET = 'Sheet1';
|
|
6204
|
+
/**
|
|
6205
|
+
* Category-axis gap width per layout, matching what PowerPoint writes for a freshly inserted chart.
|
|
6206
|
+
* A layout absent here (treemap, sunburst) draws no axes at all.
|
|
6207
|
+
*/ const CAT_GAP_WIDTH = {
|
|
6208
|
+
boxWhisker: '1',
|
|
6209
|
+
funnel: '0.0599999987',
|
|
6210
|
+
histogram: '0',
|
|
6211
|
+
waterfall: '0.5'
|
|
6212
|
+
};
|
|
6213
|
+
function firstLabelLevel(data) {
|
|
6214
|
+
var _data_;
|
|
6215
|
+
const labels = (_data_ = data[0]) === null || _data_ === void 0 ? void 0 : _data_.labels;
|
|
6216
|
+
if (!labels || labels.length === 0) return [];
|
|
6217
|
+
const level = labels[0];
|
|
6218
|
+
return Array.isArray(level) ? level : [];
|
|
6219
|
+
}
|
|
6220
|
+
/**
|
|
6221
|
+
* `<cx:pt idx="N">value</cx:pt>` for every point of one dimension
|
|
6222
|
+
* - a missing point is written empty: `cx:pt` inside a `cx:numDim` must be a number, so the string
|
|
6223
|
+
* "null" would be a schema violation (the ECMA-376 emitter blanks the same case)
|
|
6224
|
+
*/ function makePoints(values) {
|
|
6225
|
+
return values.map((value, idx)=>`<cx:pt idx="${idx}">${value === null || value === undefined ? '' : encodeXmlEntities(String(value))}</cx:pt>`).join('');
|
|
6226
|
+
}
|
|
6227
|
+
/**
|
|
6228
|
+
* Absolute A1 reference for one column of the embedded worksheet, excluding the header row.
|
|
6229
|
+
* The range length must equal the dimension's own `ptCount`, so each dimension passes its own.
|
|
6230
|
+
*/ function columnRef(colIdx, pointCount) {
|
|
6231
|
+
const col = getExcelColName(colIdx);
|
|
6232
|
+
return `${SHEET}!$${col}$2:$${col}$${pointCount + 1}`;
|
|
6233
|
+
}
|
|
6234
|
+
/**
|
|
6235
|
+
* One `cx:data` block per series.
|
|
6236
|
+
* - hierarchical layouts (treemap, sunburst) size their segments through a `size` dimension
|
|
6237
|
+
* - a histogram bins raw values itself, so it carries no category dimension at all
|
|
6238
|
+
*/ function makeChartData(rel, chartType) {
|
|
6239
|
+
const labels = firstLabelLevel(rel.data);
|
|
6240
|
+
const dimType = chartType === 'treemap' || chartType === 'sunburst' ? 'size' : 'val';
|
|
6241
|
+
return rel.data.map((series, seriesIdx)=>{
|
|
6242
|
+
var _series_values;
|
|
6243
|
+
const values = (_series_values = series.values) !== null && _series_values !== void 0 ? _series_values : [];
|
|
6244
|
+
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>`;
|
|
6245
|
+
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>`;
|
|
6246
|
+
return `<cx:data id="${seriesIdx}">${catDim}${valDim}</cx:data>`;
|
|
6247
|
+
}).join('');
|
|
6248
|
+
}
|
|
6249
|
+
/** `cx:dataLabels` - chartex has no `c:dLbls`, visibility is a single element with three flags */ function makeDataLabels(opts, chartType) {
|
|
6250
|
+
var _opts_showValue, _opts_showLabel, _opts_dataLabelPosition;
|
|
6251
|
+
const showValue = (_opts_showValue = opts.showValue) !== null && _opts_showValue !== void 0 ? _opts_showValue : false;
|
|
6252
|
+
const showCategory = (_opts_showLabel = opts.showLabel) !== null && _opts_showLabel !== void 0 ? _opts_showLabel : false;
|
|
6253
|
+
if (!showValue && !showCategory) return '';
|
|
6254
|
+
// `outEnd` is invalid on the layouts that draw labels inside their segments
|
|
6255
|
+
const defaultPos = chartType === 'treemap' || chartType === 'sunburst' || chartType === 'funnel' ? 'ctr' : 'outEnd';
|
|
6256
|
+
const pos = (_opts_dataLabelPosition = opts.dataLabelPosition) !== null && _opts_dataLabelPosition !== void 0 ? _opts_dataLabelPosition : defaultPos;
|
|
6257
|
+
const size = Math.round((opts.dataLabelFontSize || (/* inlined export .DEF_FONT_SIZE */12)) * 100);
|
|
6258
|
+
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>';
|
|
6259
|
+
const numFmt = opts.dataLabelFormatCode ? `<cx:numFmt formatCode="${encodeXmlEntities(opts.dataLabelFormatCode)}" sourceLinked="0"/>` : '';
|
|
6260
|
+
return `<cx:dataLabels pos="${pos}">` + `<cx:visibility seriesName="0" categoryName="${showCategory ? 1 : 0}" value="${showValue ? 1 : 0}"/>` + numFmt + txPr + '</cx:dataLabels>';
|
|
6261
|
+
}
|
|
6262
|
+
/**
|
|
6263
|
+
* `cx:layoutPr` carries everything that is layout-specific rather than series-generic.
|
|
6264
|
+
* Anything absent here is left to PowerPoint's own default for that layout.
|
|
6265
|
+
*/ function makeLayoutProps(opts, chartType) {
|
|
6266
|
+
switch(chartType){
|
|
6267
|
+
case 'waterfall':
|
|
6268
|
+
{
|
|
6269
|
+
var _opts_chartExSubtotals;
|
|
6270
|
+
const subtotals = (_opts_chartExSubtotals = opts.chartExSubtotals) !== null && _opts_chartExSubtotals !== void 0 ? _opts_chartExSubtotals : [];
|
|
6271
|
+
if (subtotals.length === 0) return '';
|
|
6272
|
+
return `<cx:layoutPr><cx:subtotals>${subtotals.map((idx)=>`<cx:idx val="${idx}"/>`).join('')}</cx:subtotals></cx:layoutPr>`;
|
|
6273
|
+
}
|
|
6274
|
+
case 'histogram':
|
|
6275
|
+
{
|
|
6276
|
+
const binSize = opts.chartExBinSize;
|
|
6277
|
+
const binCount = opts.chartExBinCount;
|
|
6278
|
+
// PowerPoint accepts exactly one binning rule; an explicit size wins over a count, and neither
|
|
6279
|
+
// means "let PowerPoint choose" (its automatic Scott's-rule binning)
|
|
6280
|
+
const rule = binSize !== undefined ? `<cx:binSize val="${binSize}"/>` : binCount !== undefined ? `<cx:binCount val="${binCount}"/>` : '';
|
|
6281
|
+
const binning = rule ? `<cx:binning intervalClosed="r">${rule}</cx:binning>` : '<cx:binning intervalClosed="r"/>';
|
|
6282
|
+
return `<cx:layoutPr>${binning}</cx:layoutPr>`;
|
|
6283
|
+
}
|
|
6284
|
+
case 'boxWhisker':
|
|
6285
|
+
return '<cx:layoutPr>' + `<cx:visibility meanLine="${opts.chartExMeanLine ? 1 : 0}" meanMarker="1" nonoutliers="0" outliers="1"/>` + '<cx:statistics quartileMethod="exclusive"/>' + '</cx:layoutPr>';
|
|
6286
|
+
case 'treemap':
|
|
6287
|
+
var _opts_chartExParentLabels;
|
|
6288
|
+
return `<cx:layoutPr><cx:parentLabelLayout val="${(_opts_chartExParentLabels = opts.chartExParentLabels) !== null && _opts_chartExParentLabels !== void 0 ? _opts_chartExParentLabels : 'overlapping'}"/></cx:layoutPr>`;
|
|
6289
|
+
default:
|
|
6290
|
+
return '';
|
|
6291
|
+
}
|
|
6292
|
+
}
|
|
6293
|
+
/** One `cx:series` per data row. Order follows CT_Series: tx, spPr, dataLabels, dataId, layoutPr, axisId. */ function makeSeries(rel, chartType) {
|
|
6294
|
+
const layoutId = CHARTEX_LAYOUT_ID[chartType];
|
|
6295
|
+
const dataLabels = makeDataLabels(rel.opts, chartType);
|
|
6296
|
+
const layoutPr = makeLayoutProps(rel.opts, chartType);
|
|
6297
|
+
return rel.data.map((series, idx)=>{
|
|
6298
|
+
var _series_name;
|
|
6299
|
+
const nameCell = `${SHEET}!$${getExcelColName(idx + 2)}$1`;
|
|
6300
|
+
// These layouts color each data point from the chart color style, so `chartColors` does not
|
|
6301
|
+
// apply - a series-level fill would flatten a treemap to one color. Only `color` overrides it.
|
|
6302
|
+
const spPr = series.color && series.color !== 'transparent' ? `<cx:spPr><a:solidFill>${createColorElement(series.color)}</a:solidFill></cx:spPr>` : '';
|
|
6303
|
+
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>';
|
|
6304
|
+
}).join('');
|
|
6305
|
+
}
|
|
6306
|
+
/**
|
|
6307
|
+
* `cx:axis` elements for the layouts that have axes. CT_Axis order: scaling, gridlines, tickLabels.
|
|
6308
|
+
* - a funnel is drawn along a single category axis, which PowerPoint numbers `1`
|
|
6309
|
+
* - treemap and sunburst have no axes; the series carries no `cx:axisId` in either case
|
|
6310
|
+
*/ function makeAxes(rel, chartType) {
|
|
6311
|
+
var _rel_opts_valGridLine;
|
|
6312
|
+
const gapWidth = CAT_GAP_WIDTH[chartType];
|
|
6313
|
+
if (gapWidth === undefined) return '';
|
|
6314
|
+
if (chartType === 'funnel') return `<cx:axis id="1"><cx:catScaling gapWidth="${gapWidth}"/><cx:tickLabels/></cx:axis>`;
|
|
6315
|
+
const valGridlines = ((_rel_opts_valGridLine = rel.opts.valGridLine) === null || _rel_opts_valGridLine === void 0 ? void 0 : _rel_opts_valGridLine.style) === 'none' ? '' : '<cx:majorGridlines/>';
|
|
6316
|
+
return `<cx:axis id="0"><cx:catScaling gapWidth="${gapWidth}"/><cx:tickLabels/></cx:axis>` + `<cx:axis id="1"><cx:valScaling/>${valGridlines}<cx:tickLabels/></cx:axis>`;
|
|
6317
|
+
}
|
|
6318
|
+
function makeTitle(opts) {
|
|
6319
|
+
if (!opts.showTitle) return '';
|
|
6320
|
+
const size = Math.round((opts.titleFontSize || (/* inlined export .DEF_FONT_TITLE_SIZE */18)) * 100);
|
|
6321
|
+
const color = opts.titleColor ? `<a:solidFill>${createColorElement(opts.titleColor)}</a:solidFill>` : '';
|
|
6322
|
+
const face = opts.titleFontFace ? `<a:latin typeface="${encodeXmlEntities(opts.titleFontFace)}"/>` : '';
|
|
6323
|
+
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>';
|
|
6324
|
+
}
|
|
6325
|
+
function makeLegend(opts) {
|
|
6326
|
+
if (!opts.showLegend) return '';
|
|
6327
|
+
// `cx:legend@pos` takes l/r/t/b only; PowerPoint stores the library's `tr` as a top-aligned right legend
|
|
6328
|
+
const isTopRight = opts.legendPos === 'tr';
|
|
6329
|
+
return `<cx:legend pos="${isTopRight ? 'r' : opts.legendPos || 'r'}" align="${isTopRight ? 'min' : 'ctr'}" overlay="0"/>`;
|
|
6330
|
+
}
|
|
6331
|
+
/**
|
|
6332
|
+
* Build the `cx:chartSpace` part for one chartex chart.
|
|
6333
|
+
* @param {ISlideRelChart} rel - chart relationship, with `opts._type` narrowed to a chartex type
|
|
6334
|
+
* @returns {string} chartex part XML
|
|
6335
|
+
*/ function makeXmlChartEx(rel) {
|
|
6336
|
+
const type = rel.opts._type;
|
|
6337
|
+
if (!isChartexType(type)) throw new Error(`pptxgenjs: "${String(type)}" is not a chartex chart type`);
|
|
6338
|
+
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>';
|
|
6339
|
+
}
|
|
6340
|
+
|
|
6341
|
+
/**
|
|
6342
|
+
* Chart style and chart colour-style parts (`ppt/charts/styleN.xml`, `ppt/charts/colorsN.xml`).
|
|
6343
|
+
*
|
|
6344
|
+
* Classic `c:chart` parts write these only when `chartStyle` or `chartColorStyle` is set.
|
|
6345
|
+
* ChartEx layouts always need both: PowerPoint resolves their visual properties through them.
|
|
6346
|
+
*
|
|
6347
|
+
* PowerPoint finds both parts by relationship type from the chart's own `.rels` - nothing inside
|
|
6348
|
+
* `chartN.xml` points at them.
|
|
6349
|
+
*/
|
|
6350
|
+
|
|
6351
|
+
const XML_HEADER = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>';
|
|
6352
|
+
const NS_ATTRS = `xmlns:cs="${CHART_STYLE.ns}" xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main"`;
|
|
6353
|
+
/** The luminance variations Office writes for a six-colour cycling palette */ const DEF_VARIATIONS = [
|
|
6354
|
+
'',
|
|
6355
|
+
'<a:lumMod val="60000"/>',
|
|
6356
|
+
'<a:lumMod val="80000"/><a:lumOff val="20000"/>',
|
|
6357
|
+
'<a:lumMod val="80000"/>',
|
|
6358
|
+
'<a:lumMod val="60000"/><a:lumOff val="40000"/>',
|
|
6359
|
+
'<a:lumMod val="50000"/>',
|
|
6360
|
+
'<a:lumMod val="70000"/><a:lumOff val="30000"/>',
|
|
6361
|
+
'<a:lumMod val="70000"/>',
|
|
6362
|
+
'<a:lumMod val="50000"/><a:lumOff val="50000"/>'
|
|
6363
|
+
];
|
|
6364
|
+
/** The six theme accents, which is what Office's default colour style cycles through */ const DEF_ACCENTS = [
|
|
6365
|
+
'accent1',
|
|
6366
|
+
'accent2',
|
|
6367
|
+
'accent3',
|
|
6368
|
+
'accent4',
|
|
6369
|
+
'accent5',
|
|
6370
|
+
'accent6'
|
|
6371
|
+
];
|
|
6372
|
+
/**
|
|
6373
|
+
* Whether this chart should write `styleN.xml` / `colorsN.xml`.
|
|
6374
|
+
* ChartEx always needs them; classic charts only write them when the caller opts in.
|
|
6375
|
+
*/ function wantsChartStyleParts(opts) {
|
|
6376
|
+
if (!opts) return false;
|
|
6377
|
+
if (isChartexType(opts._type)) return true;
|
|
6378
|
+
return opts.chartStyle !== undefined || opts.chartColorStyle !== undefined;
|
|
6379
|
+
}
|
|
6380
|
+
/**
|
|
6381
|
+
* Part name for a chart's colour style, matching the chart's own number
|
|
6382
|
+
* @param {number} chartNum - the N in `chartN.xml`
|
|
6383
|
+
* @returns {string} part name
|
|
6384
|
+
*/ function chartColorsPartName(chartNum) {
|
|
6385
|
+
return `ppt/charts/colors${chartNum}.xml`;
|
|
6386
|
+
}
|
|
6387
|
+
/**
|
|
6388
|
+
* Part name for a chart's style, matching the chart's own number
|
|
6389
|
+
* @param {number} chartNum - the N in `chartN.xml`
|
|
6390
|
+
* @returns {string} part name
|
|
6391
|
+
*/ function chartStylePartName(chartNum) {
|
|
6392
|
+
return `ppt/charts/style${chartNum}.xml`;
|
|
6393
|
+
}
|
|
6394
|
+
/**
|
|
6395
|
+
* Creates a chart's colour-style part (`cs:colorStyle`).
|
|
6396
|
+
* @param {ChartColorStyleProps} [props] - colour style options
|
|
6397
|
+
* @returns {string} XML
|
|
6398
|
+
*/ function makeXmlChartColors(props) {
|
|
6399
|
+
const methods = [
|
|
6400
|
+
'cycle',
|
|
6401
|
+
'withinLinear',
|
|
6402
|
+
'acrossLinear',
|
|
6403
|
+
'withinLinearReversed',
|
|
6404
|
+
'acrossLinearReversed'
|
|
6405
|
+
];
|
|
6406
|
+
const method = (props === null || props === void 0 ? void 0 : props.method) && methods.includes(props.method) ? props.method : 'cycle';
|
|
6407
|
+
const id = typeof (props === null || props === void 0 ? void 0 : props.id) === 'number' && isFinite(props.id) && props.id > 0 ? Math.round(props.id) : 10;
|
|
6408
|
+
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('');
|
|
6409
|
+
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>';
|
|
6410
|
+
}
|
|
6411
|
+
/**
|
|
6412
|
+
* Office's default chart style definitions, verbatim.
|
|
6413
|
+
*
|
|
6414
|
+
* The `@id` names which entry of PowerPoint's gallery is selected; the ~30 `cs:*` children are the
|
|
6415
|
+
* definitions themselves. Only this one set is shipped - reproducing every gallery entry would mean
|
|
6416
|
+
* ~150 more, none of which can be verified from a published schema.
|
|
6417
|
+
*/ 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>';
|
|
6418
|
+
/**
|
|
6419
|
+
* Creates a chart's style part (`cs:chartStyle`).
|
|
6420
|
+
* @param {number} [styleId] - which gallery entry is selected; the definitions are Office's defaults
|
|
6421
|
+
* @returns {string} XML
|
|
6422
|
+
*/ function makeXmlChartStyle(styleId) {
|
|
6423
|
+
const body = typeof styleId === 'number' && isFinite(styleId) && styleId > 0 ? DEF_CHART_STYLE.replace(/ id="\d+">/, ` id="${Math.round(styleId)}">`) : DEF_CHART_STYLE;
|
|
6424
|
+
return XML_HEADER + body;
|
|
6425
|
+
}
|
|
6426
|
+
|
|
6427
|
+
/**
|
|
6428
|
+
* Chart title rendering.
|
|
6429
|
+
*/
|
|
6430
|
+
|
|
6431
|
+
/**
|
|
6432
|
+
* Create char title elements
|
|
6433
|
+
* @param {IChartPropsTitle} opts - options
|
|
6434
|
+
* @return {string} XML `<c:title>`
|
|
6435
|
+
*/ function genXmlTitle(opts, chartX, chartY) {
|
|
6436
|
+
const align = opts.titleAlign === 'left' || opts.titleAlign === 'right' ? `<a:pPr algn="${opts.titleAlign.substring(0, 1)}">` : '<a:pPr>';
|
|
6437
|
+
const rotate = opts.titleRotate ? `<a:bodyPr rot="${convertRotationDegrees(opts.titleRotate)}"/>` : '<a:bodyPr/>' // don't specify rotation to get default (ex. vertical for cat axis)
|
|
6438
|
+
;
|
|
6439
|
+
const sizeAttr = opts.fontSize ? `sz="${Math.round(opts.fontSize * 100)}"` : '' // only set the font size if specified. Powerpoint will handle the default size
|
|
6440
|
+
;
|
|
6441
|
+
const titleBold = opts.titleBold ? 1 : 0;
|
|
6442
|
+
const titleItalic = opts.titleItalic ? 1 : 0;
|
|
6443
|
+
let layout = '<c:layout/>';
|
|
6444
|
+
if (opts.titlePos && typeof opts.titlePos.x === 'number' && typeof opts.titlePos.y === 'number') {
|
|
6445
|
+
// NOTE: manualLayout x/y vals are *relative to entire slide*
|
|
6446
|
+
const totalX = opts.titlePos.x + (chartX !== null && chartX !== void 0 ? chartX : 0);
|
|
6447
|
+
const totalY = opts.titlePos.y + (chartY !== null && chartY !== void 0 ? chartY : 0);
|
|
6448
|
+
let valX = totalX === 0 ? 0 : totalX * (totalX / 5) / 10;
|
|
6449
|
+
if (valX >= 1) valX = valX / 10;
|
|
6450
|
+
if (valX >= 0.1) valX = valX / 10;
|
|
6451
|
+
let valY = totalY === 0 ? 0 : totalY * (totalY / 5) / 10;
|
|
6452
|
+
if (valY >= 1) valY = valY / 10;
|
|
6453
|
+
if (valY >= 0.1) valY = valY / 10;
|
|
6454
|
+
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>`;
|
|
6455
|
+
}
|
|
6456
|
+
return `<c:title>
|
|
6457
|
+
<c:tx>
|
|
6458
|
+
<c:rich>
|
|
6459
|
+
${rotate}
|
|
6460
|
+
<a:lstStyle/>
|
|
6461
|
+
<a:p>
|
|
6462
|
+
${align}
|
|
6463
|
+
<a:defRPr ${sizeAttr} b="${titleBold}" i="${titleItalic}" u="none" strike="noStrike">
|
|
6464
|
+
<a:solidFill>${createColorElement(opts.color || (/* inlined export .DEF_FONT_COLOR */"000000"))}</a:solidFill>
|
|
6465
|
+
<a:latin typeface="${encodeXmlEntities(opts.fontFace) || 'Arial'}"/>
|
|
6466
|
+
<a:ea typeface="${encodeXmlEntities(opts.fontFace) || 'Arial'}"/>
|
|
6467
|
+
</a:defRPr>
|
|
6468
|
+
</a:pPr>
|
|
6469
|
+
<a:r>
|
|
6470
|
+
<a:rPr ${sizeAttr} b="${titleBold}" i="${titleItalic}" u="none" strike="noStrike">
|
|
6471
|
+
<a:solidFill>${createColorElement(opts.color || (/* inlined export .DEF_FONT_COLOR */"000000"))}</a:solidFill>
|
|
6472
|
+
<a:latin typeface="${encodeXmlEntities(opts.fontFace) || 'Arial'}"/>
|
|
6473
|
+
<a:ea typeface="${encodeXmlEntities(opts.fontFace) || 'Arial'}"/>
|
|
6474
|
+
</a:rPr>
|
|
6475
|
+
<a:t>${encodeXmlEntities(opts.title) || ''}</a:t>
|
|
6476
|
+
</a:r>
|
|
6477
|
+
</a:p>
|
|
6478
|
+
</c:rich>
|
|
6479
|
+
</c:tx>
|
|
6480
|
+
${layout}
|
|
6481
|
+
<c:overlay val="0"/>
|
|
6482
|
+
</c:title>`;
|
|
6483
|
+
}
|
|
6484
|
+
|
|
5595
6485
|
/**
|
|
5596
6486
|
* Chart axis rendering.
|
|
5597
6487
|
*/
|
|
@@ -6012,7 +6902,7 @@ function xml_object_spread_props(target, source) {
|
|
|
6012
6902
|
usesSecondaryValAxis = usesSecondaryValAxis || ((_options_secondaryValAxis = options.secondaryValAxis) !== null && _options_secondaryValAxis !== void 0 ? _options_secondaryValAxis : false);
|
|
6013
6903
|
strXml += makeChartType(type.type, type.data, options, valAxisId, catAxisId, true, rel.data);
|
|
6014
6904
|
});
|
|
6015
|
-
} else if (rel.opts._type) {
|
|
6905
|
+
} else if (rel.opts._type && !isChartexType(rel.opts._type)) {
|
|
6016
6906
|
strXml += makeChartType(rel.opts._type, rel.data, rel.opts, AXIS_ID_VALUE_PRIMARY, AXIS_ID_CATEGORY_PRIMARY, false, rel.data);
|
|
6017
6907
|
}
|
|
6018
6908
|
// B: Axes -----------------------------------------------------------
|
|
@@ -7057,6 +7947,8 @@ function _async_to_generator(fn) {
|
|
|
7057
7947
|
|
|
7058
7948
|
|
|
7059
7949
|
|
|
7950
|
+
|
|
7951
|
+
|
|
7060
7952
|
function getDataTableStyles(chartObject) {
|
|
7061
7953
|
const dataTableFormats = Array.isArray(chartObject.opts._type) ? chartObject.opts._type.flatMap((type)=>{
|
|
7062
7954
|
var _ref;
|
|
@@ -7561,8 +8453,19 @@ function makeNumberStyles(formats) {
|
|
|
7561
8453
|
base64: true
|
|
7562
8454
|
});
|
|
7563
8455
|
// 2: Create the chart.xml and rel files
|
|
7564
|
-
|
|
7565
|
-
|
|
8456
|
+
// PowerPoint finds the style and colour-style parts by relationship type, so they are
|
|
8457
|
+
// declared here rather than referenced from inside `chartN.xml`.
|
|
8458
|
+
// Classic charts write them only when requested; ChartEx layouts always need them.
|
|
8459
|
+
const isChartex = isChartexType(chartObject.opts._type);
|
|
8460
|
+
const writeStyleParts = wantsChartStyleParts(chartObject.opts);
|
|
8461
|
+
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"/>` : '';
|
|
8462
|
+
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>');
|
|
8463
|
+
zip.file(`ppt/charts/${chartObject.fileName}`, isChartex ? makeXmlChartEx(chartObject) : makeXmlCharts(chartObject));
|
|
8464
|
+
if (writeStyleParts) {
|
|
8465
|
+
var _chartObject_opts, _chartObject_opts1;
|
|
8466
|
+
zip.file(chartColorsPartName(chartObject.globalId), makeXmlChartColors((_chartObject_opts = chartObject.opts) === null || _chartObject_opts === void 0 ? void 0 : _chartObject_opts.chartColorStyle));
|
|
8467
|
+
zip.file(chartStylePartName(chartObject.globalId), makeXmlChartStyle((_chartObject_opts1 = chartObject.opts) === null || _chartObject_opts1 === void 0 ? void 0 : _chartObject_opts1.chartStyle));
|
|
8468
|
+
}
|
|
7566
8469
|
// 3: Done
|
|
7567
8470
|
resolve('');
|
|
7568
8471
|
}).catch((strErr)=>{
|
|
@@ -7574,6 +8477,8 @@ function makeNumberStyles(formats) {
|
|
|
7574
8477
|
|
|
7575
8478
|
|
|
7576
8479
|
|
|
8480
|
+
|
|
8481
|
+
|
|
7577
8482
|
/**
|
|
7578
8483
|
* @file 语言相关函数
|
|
7579
8484
|
* @author mengke01(kekee000@gmail.com)
|
|
@@ -15805,7 +16710,7 @@ function imageDimensions(bytes) {
|
|
|
15805
16710
|
});
|
|
15806
16711
|
}
|
|
15807
16712
|
/** Select relations that still need their local or remote media encoded. */ function getMediaCandidates(layout) {
|
|
15808
|
-
return layout._relsMedia.filter((rel)
|
|
16713
|
+
return layout._relsMedia.filter((rel)=>!rel.isLinked && rel.type !== 'online' && !rel.data && (!rel.path || rel.path && !rel.path.includes('preencoded')));
|
|
15809
16714
|
}
|
|
15810
16715
|
/**
|
|
15811
16716
|
* Mark repeated source paths so only the first relation performs I/O.
|
|
@@ -19094,7 +19999,8 @@ function replyXml(reply, authors, fallbackDate) {
|
|
|
19094
19999
|
// is the absolute `/ppt/charts/chartN.xml` form reused as Content_Types PartName.
|
|
19095
20000
|
// PowerPoint writes the relative `../charts/chartN.xml`; absolute targets are valid but
|
|
19096
20001
|
// non-idiomatic and break stricter consumers (PR 1465 / eliasaronson).
|
|
19097
|
-
|
|
20002
|
+
const relType = isChartexType(rel.opts._type) ? OOXML_CHARTEX.relType : 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart';
|
|
20003
|
+
strXml += `<Relationship Id="rId${rel.rId}" Type="${relType}" Target="${rel.Target.replace(/^\/ppt\//, '../')}"/>`;
|
|
19098
20004
|
});
|
|
19099
20005
|
(slide._relsMedia || []).forEach((rel)=>{
|
|
19100
20006
|
const relRid = rel.rId.toString();
|
|
@@ -19103,17 +20009,19 @@ function replyXml(reply, authors, fallbackDate) {
|
|
|
19103
20009
|
strXml += '<Relationship Id="rId' + relRid + '" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/image" Target="' + rel.Target + '"/>';
|
|
19104
20010
|
} else if (rel.type.toLowerCase().includes('audio')) {
|
|
19105
20011
|
// As media has *TWO* rel entries per item, check for first one, if found add second rel with alt style
|
|
20012
|
+
const externalAttr = rel.isLinked ? ' TargetMode="External"' : '';
|
|
19106
20013
|
if (strXml.includes(' Target="' + rel.Target + '"')) {
|
|
19107
|
-
strXml += '<Relationship Id="rId' + relRid + '" Type="http://schemas.microsoft.com/office/2007/relationships/media" Target="' + rel.Target + '"/>';
|
|
20014
|
+
strXml += '<Relationship Id="rId' + relRid + '" Type="http://schemas.microsoft.com/office/2007/relationships/media" Target="' + rel.Target + '"' + externalAttr + '/>';
|
|
19108
20015
|
} else {
|
|
19109
|
-
strXml += '<Relationship Id="rId' + relRid + '" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/audio" Target="' + rel.Target + '"/>';
|
|
20016
|
+
strXml += '<Relationship Id="rId' + relRid + '" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/audio" Target="' + rel.Target + '"' + externalAttr + '/>';
|
|
19110
20017
|
}
|
|
19111
20018
|
} else if (rel.type.toLowerCase().includes('video')) {
|
|
19112
20019
|
// As media has *TWO* rel entries per item, check for first one, if found add second rel with alt style
|
|
20020
|
+
const externalAttr = rel.isLinked ? ' TargetMode="External"' : '';
|
|
19113
20021
|
if (strXml.includes(' Target="' + rel.Target + '"')) {
|
|
19114
|
-
strXml += '<Relationship Id="rId' + relRid + '" Type="http://schemas.microsoft.com/office/2007/relationships/media" Target="' + rel.Target + '"/>';
|
|
20022
|
+
strXml += '<Relationship Id="rId' + relRid + '" Type="http://schemas.microsoft.com/office/2007/relationships/media" Target="' + rel.Target + '"' + externalAttr + '/>';
|
|
19115
20023
|
} else {
|
|
19116
|
-
strXml += '<Relationship Id="rId' + relRid + '" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/video" Target="' + rel.Target + '"/>';
|
|
20024
|
+
strXml += '<Relationship Id="rId' + relRid + '" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/video" Target="' + rel.Target + '"' + externalAttr + '/>';
|
|
19117
20025
|
}
|
|
19118
20026
|
} else if (rel.type.toLowerCase().includes('online')) {
|
|
19119
20027
|
// As media has *TWO* rel entries per item, check for first one, if found add second rel with alt style
|
|
@@ -19319,6 +20227,170 @@ function unsignedInt(value) {
|
|
|
19319
20227
|
return `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\r\n<pc:chgInfo xmlns:pc="${CHANGES_INFO_NS}"/>`;
|
|
19320
20228
|
}
|
|
19321
20229
|
|
|
20230
|
+
/**
|
|
20231
|
+
* PptxGenJS: Non-visual drawing properties (`p:cNvPr`) and editing locks
|
|
20232
|
+
*
|
|
20233
|
+
* Every drawable object carries a `p:cNvPr` with its id, name, and alt text, and a sibling
|
|
20234
|
+
* `p:cNv*Pr` holding the lock element for its kind - `a:spLocks` for shapes, `a:picLocks` for
|
|
20235
|
+
* pictures, `a:graphicFrameLocks` for frames, `a:grpSpLocks` for groups, `a:cxnSpLocks` for
|
|
20236
|
+
* connectors. The lock attributes are shared, so one emitter serves all five.
|
|
20237
|
+
*/
|
|
20238
|
+
/** Lock attribute names, in the order the schema declares them */ const LOCK_ATTRS = [
|
|
20239
|
+
[
|
|
20240
|
+
'noGroup',
|
|
20241
|
+
'noGrp'
|
|
20242
|
+
],
|
|
20243
|
+
[
|
|
20244
|
+
'noSelect',
|
|
20245
|
+
'noSelect'
|
|
20246
|
+
],
|
|
20247
|
+
[
|
|
20248
|
+
'noRotate',
|
|
20249
|
+
'noRot'
|
|
20250
|
+
],
|
|
20251
|
+
[
|
|
20252
|
+
'noChangeAspect',
|
|
20253
|
+
'noChangeAspect'
|
|
20254
|
+
],
|
|
20255
|
+
[
|
|
20256
|
+
'noMove',
|
|
20257
|
+
'noMove'
|
|
20258
|
+
],
|
|
20259
|
+
[
|
|
20260
|
+
'noResize',
|
|
20261
|
+
'noResize'
|
|
20262
|
+
],
|
|
20263
|
+
[
|
|
20264
|
+
'noEditPoints',
|
|
20265
|
+
'noEditPoints'
|
|
20266
|
+
],
|
|
20267
|
+
[
|
|
20268
|
+
'noAdjustHandles',
|
|
20269
|
+
'noAdjustHandles'
|
|
20270
|
+
],
|
|
20271
|
+
[
|
|
20272
|
+
'noChangeArrowheads',
|
|
20273
|
+
'noChangeArrowheads'
|
|
20274
|
+
],
|
|
20275
|
+
[
|
|
20276
|
+
'noChangeShapeType',
|
|
20277
|
+
'noChangeShapeType'
|
|
20278
|
+
],
|
|
20279
|
+
[
|
|
20280
|
+
'noTextEdit',
|
|
20281
|
+
'noTextEdit'
|
|
20282
|
+
],
|
|
20283
|
+
[
|
|
20284
|
+
'noCrop',
|
|
20285
|
+
'noCrop'
|
|
20286
|
+
]
|
|
20287
|
+
];
|
|
20288
|
+
/** Which lock attributes each element actually permits */ const ALLOWED = {
|
|
20289
|
+
'a:spLocks': new Set([
|
|
20290
|
+
'noGrp',
|
|
20291
|
+
'noSelect',
|
|
20292
|
+
'noRot',
|
|
20293
|
+
'noChangeAspect',
|
|
20294
|
+
'noMove',
|
|
20295
|
+
'noResize',
|
|
20296
|
+
'noEditPoints',
|
|
20297
|
+
'noAdjustHandles',
|
|
20298
|
+
'noChangeArrowheads',
|
|
20299
|
+
'noChangeShapeType',
|
|
20300
|
+
'noTextEdit'
|
|
20301
|
+
]),
|
|
20302
|
+
'a:picLocks': new Set([
|
|
20303
|
+
'noGrp',
|
|
20304
|
+
'noSelect',
|
|
20305
|
+
'noRot',
|
|
20306
|
+
'noChangeAspect',
|
|
20307
|
+
'noMove',
|
|
20308
|
+
'noResize',
|
|
20309
|
+
'noEditPoints',
|
|
20310
|
+
'noAdjustHandles',
|
|
20311
|
+
'noChangeArrowheads',
|
|
20312
|
+
'noChangeShapeType',
|
|
20313
|
+
'noCrop'
|
|
20314
|
+
]),
|
|
20315
|
+
'a:graphicFrameLocks': new Set([
|
|
20316
|
+
'noGrp',
|
|
20317
|
+
'noSelect',
|
|
20318
|
+
'noChangeAspect',
|
|
20319
|
+
'noMove',
|
|
20320
|
+
'noResize',
|
|
20321
|
+
'noDrilldown'
|
|
20322
|
+
]),
|
|
20323
|
+
'a:grpSpLocks': new Set([
|
|
20324
|
+
'noGrp',
|
|
20325
|
+
'noSelect',
|
|
20326
|
+
'noRot',
|
|
20327
|
+
'noChangeAspect',
|
|
20328
|
+
'noMove',
|
|
20329
|
+
'noResize',
|
|
20330
|
+
'noUngrp'
|
|
20331
|
+
]),
|
|
20332
|
+
'a:cxnSpLocks': new Set([
|
|
20333
|
+
'noGrp',
|
|
20334
|
+
'noSelect',
|
|
20335
|
+
'noRot',
|
|
20336
|
+
'noChangeAspect',
|
|
20337
|
+
'noMove',
|
|
20338
|
+
'noResize',
|
|
20339
|
+
'noEditPoints',
|
|
20340
|
+
'noAdjustHandles',
|
|
20341
|
+
'noChangeArrowheads',
|
|
20342
|
+
'noChangeShapeType'
|
|
20343
|
+
])
|
|
20344
|
+
};
|
|
20345
|
+
/**
|
|
20346
|
+
* Create a lock element, or `''` when nothing is locked
|
|
20347
|
+
* - attributes the element does not permit are dropped: an unexpected one is a schema violation
|
|
20348
|
+
* @param {string} tag - lock element name for the object's kind
|
|
20349
|
+
* @param {ShapeLockProps} lock - lock props
|
|
20350
|
+
* @param {string} defaults - attributes the library already emits for this object
|
|
20351
|
+
* @returns {string} XML string
|
|
20352
|
+
*/ function genXmlLocks(tag, lock, defaults = '') {
|
|
20353
|
+
var _ALLOWED_tag;
|
|
20354
|
+
const allowed = (_ALLOWED_tag = ALLOWED[tag]) !== null && _ALLOWED_tag !== void 0 ? _ALLOWED_tag : new Set();
|
|
20355
|
+
let attrs = defaults;
|
|
20356
|
+
LOCK_ATTRS.forEach(([prop, attr])=>{
|
|
20357
|
+
if ((lock === null || lock === void 0 ? void 0 : lock[prop]) !== true) return;
|
|
20358
|
+
if (!allowed.has(attr)) {
|
|
20359
|
+
console.warn(`[pptxgenjs] \`${String(prop)}\` does not apply to this object type - ignored`);
|
|
20360
|
+
return;
|
|
20361
|
+
}
|
|
20362
|
+
// do not repeat an attribute the caller already gets by default
|
|
20363
|
+
if (defaults.includes(`${attr}="`)) return;
|
|
20364
|
+
attrs += ` ${attr}="1"`;
|
|
20365
|
+
});
|
|
20366
|
+
return attrs ? `<${tag}${attrs}/>` : '';
|
|
20367
|
+
}
|
|
20368
|
+
/**
|
|
20369
|
+
* Create the `p:cNvPr` element
|
|
20370
|
+
* @param {number} id - shape id, unique on the slide
|
|
20371
|
+
* @param {string} name - shape name shown in the selection pane (already XML-escaped by callers)
|
|
20372
|
+
* @param {NonVisualProps} props - non-visual options
|
|
20373
|
+
* @param {string} descr - alt-text description
|
|
20374
|
+
* @param {string} children - child elements (ex: hyperlinks); self-closes when empty
|
|
20375
|
+
* @returns {string} XML string
|
|
20376
|
+
*/ function genXmlCNvPr(id, name, props, descr = '', children = '') {
|
|
20377
|
+
let attrs = `id="${id}" name="${name}"`;
|
|
20378
|
+
// `descr` is the alt-text description; `title` is the separate alt-text title
|
|
20379
|
+
if (descr) attrs += ` descr="${encodeXmlEntities(descr)}"`;
|
|
20380
|
+
if (props === null || props === void 0 ? void 0 : props.title) attrs += ` title="${encodeXmlEntities(props.title)}"`;
|
|
20381
|
+
if ((props === null || props === void 0 ? void 0 : props.hidden) === true) attrs += ' hidden="1"';
|
|
20382
|
+
return children ? `<p:cNvPr ${attrs}>${children}</p:cNvPr>` : `<p:cNvPr ${attrs}/>`;
|
|
20383
|
+
}
|
|
20384
|
+
/**
|
|
20385
|
+
* Create `p:cNvSpPr`, carrying the text-box flag and any shape locks
|
|
20386
|
+
* @param {object} options - shape options
|
|
20387
|
+
* @returns {string} XML string
|
|
20388
|
+
*/ function genXmlCNvSpPr(options) {
|
|
20389
|
+
const txBox = (options === null || options === void 0 ? void 0 : options.isTextBox) ? ' txBox="1"' : '';
|
|
20390
|
+
const locks = genXmlLocks('a:spLocks', options === null || options === void 0 ? void 0 : options.lock);
|
|
20391
|
+
return locks ? `<p:cNvSpPr${txBox}>${locks}</p:cNvSpPr>` : `<p:cNvSpPr${txBox}/>`;
|
|
20392
|
+
}
|
|
20393
|
+
|
|
19322
20394
|
function xml_slide_define_property(obj, key, value) {
|
|
19323
20395
|
if (key in obj) {
|
|
19324
20396
|
Object.defineProperty(obj, key, {
|
|
@@ -19376,11 +20448,33 @@ function slide_object_spread_props(target, source) {
|
|
|
19376
20448
|
|
|
19377
20449
|
|
|
19378
20450
|
|
|
20451
|
+
|
|
20452
|
+
|
|
19379
20453
|
function nvPrModIdExt(modId) {
|
|
19380
20454
|
return genXmlModIdExt(modId).replace(/^<p:extLst>|<\/p:extLst>$/g, '');
|
|
19381
20455
|
}
|
|
19382
20456
|
function genXmlNvPr(options, phXml = '', extraExts = []) {
|
|
19383
|
-
|
|
20457
|
+
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"' : '');
|
|
20458
|
+
return `<p:nvPr${attrs}>${phXml}${genXmlNvPrExtLst(options, extraExts)}</p:nvPr>`;
|
|
20459
|
+
}
|
|
20460
|
+
/**
|
|
20461
|
+
* Fallback shape for a chartex graphic frame (`mc:Fallback`).
|
|
20462
|
+
*
|
|
20463
|
+
* PowerPoint writes a rendered preview picture here, which this library cannot produce without a
|
|
20464
|
+
* rasterizer. A locked, non-editable text shape occupying the same box is the closest honest
|
|
20465
|
+
* substitute: a consumer that rejects the `mc:Choice` still sees where the chart is and why it is
|
|
20466
|
+
* not drawn, and cannot silently edit it into something that no longer matches the chart part.
|
|
20467
|
+
*/ function genXmlChartExFallback(shapeId, slideItemObj, box) {
|
|
20468
|
+
var _slideItemObj_options, _options_objectName, _options_altText;
|
|
20469
|
+
const options = (_slideItemObj_options = slideItemObj.options) !== null && _slideItemObj_options !== void 0 ? _slideItemObj_options : {};
|
|
20470
|
+
const name = (_options_objectName = options.objectName) !== null && _options_objectName !== void 0 ? _options_objectName : 'Chart';
|
|
20471
|
+
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.';
|
|
20472
|
+
// A chart's `title` is the chart title, not the alt-text title `p:cNvPr@title` carries.
|
|
20473
|
+
// `noTextEdit` is not optional: an edited fallback would no longer match the chart part.
|
|
20474
|
+
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>';
|
|
20475
|
+
}
|
|
20476
|
+
function genXmlCNvPrLinks(click, hover) {
|
|
20477
|
+
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') : '');
|
|
19384
20478
|
}
|
|
19385
20479
|
const ImageSizingXml = {
|
|
19386
20480
|
cover: function(imgSize, boxDim) {
|
|
@@ -19461,10 +20555,6 @@ const ImageSizingXml = {
|
|
|
19461
20555
|
return opts.tableStyleId ? `<a:tblPr${attrs}><a:tableStyleId>${encodeXmlEntities(opts.tableStyleId)}</a:tableStyleId></a:tblPr>` : `<a:tblPr${attrs}/>`;
|
|
19462
20556
|
}
|
|
19463
20557
|
/**
|
|
19464
|
-
* Create the `a:ln` outline block for a shape/image
|
|
19465
|
-
* @param {ShapeLineProps} line - line options
|
|
19466
|
-
* @return {string} XML
|
|
19467
|
-
*/ /**
|
|
19468
20558
|
* Builds `<p14:trim>` / `<p14:fade>` / `<p14:bmkLst>` children of `<p14:media>` (MS-PPTX §2.3.3.14).
|
|
19469
20559
|
* Times are ST_UniversalTimeOffset (ms).
|
|
19470
20560
|
*/ function genXmlMediaExtras(opts) {
|
|
@@ -19474,7 +20564,34 @@ const ImageSizingXml = {
|
|
|
19474
20564
|
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>`;
|
|
19475
20565
|
return xml;
|
|
19476
20566
|
}
|
|
19477
|
-
|
|
20567
|
+
/**
|
|
20568
|
+
* One `a:tcPr` border line (`a:lnL`, `a:lnTlToBr`, ...)
|
|
20569
|
+
* - the four edges and the two diagonals share CT_LineProperties, so they share this emitter
|
|
20570
|
+
* @param {string} name - element name without the `a:` prefix
|
|
20571
|
+
* @param {BorderProps} border - border definition
|
|
20572
|
+
* @returns {string} XML
|
|
20573
|
+
*/ function genXmlCellBorder(name, border) {
|
|
20574
|
+
var _ref, _border_width, _border_color;
|
|
20575
|
+
if (border.type === 'none') return `<a:${name} w="0" cap="flat" cmpd="sng" algn="ctr"><a:noFill/></a:${name}>`;
|
|
20576
|
+
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;
|
|
20577
|
+
const borderTransparency = border.transparency;
|
|
20578
|
+
const borderAlpha = typeof borderTransparency === 'number' ? `<a:alpha val="${Math.round((100 - Math.min(100, Math.max(0, borderTransparency))) * 1000)}"/>` : '';
|
|
20579
|
+
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}>`;
|
|
20580
|
+
}
|
|
20581
|
+
/**
|
|
20582
|
+
* One `a:audioCd` endpoint (`a:st` or `a:end`).
|
|
20583
|
+
* - `@track` is required and is an `xsd:unsignedByte`, so it is clamped; `@time` defaults to 0
|
|
20584
|
+
*/ function genXmlAudioCdTime(tag, point) {
|
|
20585
|
+
var _ref;
|
|
20586
|
+
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)));
|
|
20587
|
+
const time = typeof (point === null || point === void 0 ? void 0 : point.time) === 'number' && isFinite(point.time) && point.time > 0 ? ` time="${Math.round(point.time)}"` : '';
|
|
20588
|
+
return `<${tag} track="${track}"${time}/>`;
|
|
20589
|
+
}
|
|
20590
|
+
/**
|
|
20591
|
+
* Create the `a:ln` outline block for a shape/image
|
|
20592
|
+
* @param {ShapeLineProps} line - line options
|
|
20593
|
+
* @return {string} XML
|
|
20594
|
+
*/ function genXmlLine(line) {
|
|
19478
20595
|
// ECMA-376 §5.1.2.1.34: `<a:ln>` carries `w` and `cap` attributes (cap = line ending style, issue #782)
|
|
19479
20596
|
const attrs = (line.width ? ` w="${valToPts(line.width)}"` : '') + (line.cap && [
|
|
19480
20597
|
'flat',
|
|
@@ -19499,15 +20616,20 @@ function genXmlLine(line) {
|
|
|
19499
20616
|
* Create a single `a:outerShdw` / `a:innerShdw` element (no `effectLst` wrapper).
|
|
19500
20617
|
* @note pure - unit conversion must NOT mutate the caller's options (issue #20)
|
|
19501
20618
|
*/ function genXmlShadowElement(shadow) {
|
|
19502
|
-
var
|
|
19503
|
-
const type = shadow.type === 'inner' ? 'inner' : 'outer';
|
|
19504
|
-
const blur = valToPts((_shadow_blur = shadow.blur) !== null && _shadow_blur !== void 0 ? _shadow_blur : 8);
|
|
20619
|
+
var _shadow_offset, _shadow_angle, _shadow_opacity, _shadow_blur;
|
|
19505
20620
|
const offset = valToPts((_shadow_offset = shadow.offset) !== null && _shadow_offset !== void 0 ? _shadow_offset : 4);
|
|
19506
20621
|
const angle = Math.round(((_shadow_angle = shadow.angle) !== null && _shadow_angle !== void 0 ? _shadow_angle : 270) * 60000);
|
|
19507
20622
|
const opacity = Math.round(((_shadow_opacity = shadow.opacity) !== null && _shadow_opacity !== void 0 ? _shadow_opacity : 0.75) * 100000);
|
|
19508
20623
|
const color = shadow.color || DEF_TEXT_SHADOW.color;
|
|
20624
|
+
const colorXml = `<a:srgbClr val="${color}"><a:alpha val="${opacity}"/></a:srgbClr>`;
|
|
20625
|
+
if (shadow.type === 'preset') {
|
|
20626
|
+
if (!shadow.preset) return '';
|
|
20627
|
+
return `<a:prstShdw prst="${shadow.preset}" dist="${offset}" dir="${angle}">${colorXml}</a:prstShdw>`;
|
|
20628
|
+
}
|
|
20629
|
+
const type = shadow.type === 'inner' ? 'inner' : 'outer';
|
|
20630
|
+
const blur = valToPts((_shadow_blur = shadow.blur) !== null && _shadow_blur !== void 0 ? _shadow_blur : 8);
|
|
19509
20631
|
const attrs = type === 'outer' ? 'sx="100000" sy="100000" kx="0" ky="0" algn="bl" rotWithShape="0"' : '';
|
|
19510
|
-
return `<a:${type}Shdw ${attrs} blurRad="${blur}" dist="${offset}" dir="${angle}"
|
|
20632
|
+
return `<a:${type}Shdw ${attrs} blurRad="${blur}" dist="${offset}" dir="${angle}">${colorXml}</a:${type}Shdw>`;
|
|
19511
20633
|
}
|
|
19512
20634
|
/**
|
|
19513
20635
|
* Create `a:softEdge` element
|
|
@@ -19535,22 +20657,98 @@ function genXmlLine(line) {
|
|
|
19535
20657
|
return `<a:blur rad="${rad}"${grow}/>`;
|
|
19536
20658
|
}
|
|
19537
20659
|
/**
|
|
19538
|
-
* Create
|
|
19539
|
-
|
|
20660
|
+
* Create `a:fillOverlay` (CT_FillOverlayEffect). `@blend` and a fill are both required.
|
|
20661
|
+
*/ function genXmlFillOverlayElement(overlay) {
|
|
20662
|
+
if (!overlay.blend || !overlay.fill) return '';
|
|
20663
|
+
const fill = genXmlColorSelection(overlay.fill);
|
|
20664
|
+
return fill ? `<a:fillOverlay blend="${overlay.blend}">${fill}</a:fillOverlay>` : '';
|
|
20665
|
+
}
|
|
20666
|
+
/**
|
|
20667
|
+
* Create the shape/image effect block (blur + fillOverlay + glow + shadow + reflection + softEdge).
|
|
20668
|
+
* Child order follows ECMA-376 `CT_EffectList`: blur, fillOverlay, glow, innerShdw, outerShdw,
|
|
20669
|
+
* prstShdw, reflection, softEdge. `effectDag` replaces `effectLst` (EG_EffectProperties choice).
|
|
19540
20670
|
* @note pure - unit conversion must NOT be written back to the caller's options object (issue #20)
|
|
19541
20671
|
*/ function genXmlEffectLst(opts) {
|
|
19542
20672
|
const parts = [];
|
|
19543
20673
|
if (opts.blur && typeof opts.blur.radius === 'number') parts.push(genXmlBlurElement(opts.blur));
|
|
20674
|
+
if (opts.fillOverlay) {
|
|
20675
|
+
const overlay = genXmlFillOverlayElement(opts.fillOverlay);
|
|
20676
|
+
if (overlay) parts.push(overlay);
|
|
20677
|
+
}
|
|
19544
20678
|
const resolvedGlow = resolveGlowOptions(opts.glow);
|
|
19545
20679
|
if (resolvedGlow) parts.push(createGlowElement(resolvedGlow));
|
|
19546
20680
|
const shadow = opts.shadow;
|
|
19547
20681
|
if (shadow && shadow.type !== 'none') {
|
|
19548
|
-
|
|
20682
|
+
const shadowXml = genXmlShadowElement(shadow);
|
|
20683
|
+
if (shadowXml) parts.push(shadowXml);
|
|
19549
20684
|
}
|
|
19550
20685
|
if (opts.reflection) parts.push(genXmlReflectionElement(opts.reflection));
|
|
19551
20686
|
if (opts.softEdge) parts.push(genXmlSoftEdgeElement(opts.softEdge));
|
|
19552
20687
|
if (!parts.length) return '';
|
|
19553
|
-
|
|
20688
|
+
const xml = parts.join('');
|
|
20689
|
+
if (opts.effectDag) return `<a:effectDag type="${opts.effectDag.type === 'tree' ? 'tree' : 'sib'}">${xml}</a:effectDag>`;
|
|
20690
|
+
return `<a:effectLst>${xml}</a:effectLst>`;
|
|
20691
|
+
}
|
|
20692
|
+
/**
|
|
20693
|
+
* Theme style references for a shape (`p:style`).
|
|
20694
|
+
* CT_ShapeStyle requires all four children; an unset property references nothing (`idx="0"` / `none`).
|
|
20695
|
+
*/ function genXmlShapeStyle(style) {
|
|
20696
|
+
var _style_color;
|
|
20697
|
+
if (!style) return '';
|
|
20698
|
+
let color = (_style_color = style.color) !== null && _style_color !== void 0 ? _style_color : 'accent1';
|
|
20699
|
+
if (color === 'phClr') {
|
|
20700
|
+
console.warn('[pptxgenjs] `styleRef.color` cannot be `phClr` - it is the placeholder a theme reference resolves, not a color. Using `accent1`.');
|
|
20701
|
+
color = 'accent1';
|
|
20702
|
+
}
|
|
20703
|
+
let fontColor = style.fontColor;
|
|
20704
|
+
if (fontColor === 'phClr') {
|
|
20705
|
+
console.warn('[pptxgenjs] `styleRef.fontColor` cannot be `phClr` - using `lt1`.');
|
|
20706
|
+
fontColor = undefined;
|
|
20707
|
+
}
|
|
20708
|
+
const idx = (value)=>typeof value === 'number' && isFinite(value) && value > 0 ? Math.round(value) : 0;
|
|
20709
|
+
const matrixColor = createColorElement(color);
|
|
20710
|
+
const fontColorXml = fontColor ? createColorElement(fontColor) : '<a:schemeClr val="lt1"/>';
|
|
20711
|
+
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>';
|
|
20712
|
+
}
|
|
20713
|
+
/**
|
|
20714
|
+
* Recolor and correction effects for an image's `a:blip`.
|
|
20715
|
+
*/ function genXmlBlipRecolor(recolor) {
|
|
20716
|
+
if (!recolor) return '';
|
|
20717
|
+
let xml = '';
|
|
20718
|
+
if (Array.isArray(recolor.duotone)) {
|
|
20719
|
+
if (recolor.duotone.length === 2) xml += `<a:duotone>${recolor.duotone.map((color)=>createColorElement(color)).join('')}</a:duotone>`;
|
|
20720
|
+
else console.warn(`[pptxgenjs] image \`recolor.duotone\` needs exactly two colors - ${recolor.duotone.length} given, effect omitted`);
|
|
20721
|
+
}
|
|
20722
|
+
if (recolor.grayscale === true) xml += '<a:grayscl/>';
|
|
20723
|
+
const bright = typeof recolor.brightness === 'number' && isFinite(recolor.brightness) ? Math.round(Math.min(100, Math.max(-100, recolor.brightness)) * 1000) : undefined;
|
|
20724
|
+
const contrast = typeof recolor.contrast === 'number' && isFinite(recolor.contrast) ? Math.round(Math.min(100, Math.max(-100, recolor.contrast)) * 1000) : undefined;
|
|
20725
|
+
if (bright !== undefined || contrast !== undefined) {
|
|
20726
|
+
xml += `<a:lum${bright !== undefined ? ` bright="${bright}"` : ''}${contrast !== undefined ? ` contrast="${contrast}"` : ''}/>`;
|
|
20727
|
+
}
|
|
20728
|
+
if (typeof recolor.blackWhiteThreshold === 'number' && isFinite(recolor.blackWhiteThreshold)) {
|
|
20729
|
+
xml += `<a:biLevel thresh="${Math.round(Math.min(100, Math.max(0, recolor.blackWhiteThreshold)) * 1000)}"/>`;
|
|
20730
|
+
}
|
|
20731
|
+
if (recolor.colorChange) {
|
|
20732
|
+
if (recolor.colorChange.from && recolor.colorChange.to) {
|
|
20733
|
+
const useA = recolor.colorChange.useAlpha === false ? ' useA="0"' : '';
|
|
20734
|
+
xml += `<a:clrChange${useA}><a:clrFrom>${createColorElement(recolor.colorChange.from)}</a:clrFrom><a:clrTo>${createColorElement(recolor.colorChange.to)}</a:clrTo></a:clrChange>`;
|
|
20735
|
+
} else {
|
|
20736
|
+
console.warn('[pptxgenjs] image `recolor.colorChange` needs both `from` and `to` - effect omitted');
|
|
20737
|
+
}
|
|
20738
|
+
}
|
|
20739
|
+
return xml;
|
|
20740
|
+
}
|
|
20741
|
+
/**
|
|
20742
|
+
* Alpha + recolor effects for an image's `a:blip`.
|
|
20743
|
+
*/ function genXmlBlipEffects(transparency, alpha, recolor) {
|
|
20744
|
+
let xml = transparency ? `<a:alphaModFix amt="${Math.round((100 - transparency) * 1000)}"/>` : '';
|
|
20745
|
+
xml += genXmlBlipRecolor(recolor);
|
|
20746
|
+
if (!alpha) return xml;
|
|
20747
|
+
if (typeof alpha.replace === 'number' && isFinite(alpha.replace)) xml += `<a:alphaRepl a="${Math.round(Math.min(100, Math.max(0, alpha.replace)) * 1000)}"/>`;
|
|
20748
|
+
if (alpha.invert === true) xml += '<a:alphaInv/>';
|
|
20749
|
+
if (alpha.floor === true) xml += '<a:alphaFloor/>';
|
|
20750
|
+
if (alpha.ceiling === true) xml += '<a:alphaCeiling/>';
|
|
20751
|
+
return xml;
|
|
19554
20752
|
}
|
|
19555
20753
|
function findShapeCoord(list, id) {
|
|
19556
20754
|
if (id == null) return undefined;
|
|
@@ -19595,7 +20793,19 @@ function findShapeCoord(list, id) {
|
|
|
19595
20793
|
/**
|
|
19596
20794
|
* When a connector references shapes with numeric inch positions + rect anchors,
|
|
19597
20795
|
* compute the line's x/y/w/h and flip flags (ZentoSoft auto-layout).
|
|
19598
|
-
*/ function
|
|
20796
|
+
*/ function resolveConnectorObjectNames(line, coordinates) {
|
|
20797
|
+
if (line._sourceName) {
|
|
20798
|
+
const found = coordinates.find((item)=>item.objectName === line._sourceName);
|
|
20799
|
+
if (found) line.sourceId = found.id;
|
|
20800
|
+
else console.warn(`[pptxgenjs] connector start shape "${line._sourceName}" not found - attachment omitted`);
|
|
20801
|
+
}
|
|
20802
|
+
if (line._targetName) {
|
|
20803
|
+
const found = coordinates.find((item)=>item.objectName === line._targetName);
|
|
20804
|
+
if (found) line.targetId = found.id;
|
|
20805
|
+
else console.warn(`[pptxgenjs] connector end shape "${line._targetName}" not found - attachment omitted`);
|
|
20806
|
+
}
|
|
20807
|
+
}
|
|
20808
|
+
function applyConnectorAutoLayout(line, coordinates, presLayout) {
|
|
19599
20809
|
const source = findShapeCoord(coordinates, line.sourceId);
|
|
19600
20810
|
const target = findShapeCoord(coordinates, line.targetId);
|
|
19601
20811
|
if (!source || !target) return undefined;
|
|
@@ -19752,7 +20962,9 @@ function slideObjectToXml(slide) {
|
|
|
19752
20962
|
let intTableNum = 1;
|
|
19753
20963
|
// STEP 1: Add background color/image (ensure only a single `<p:bg>` tag is created, ex: when master-baskground has both `color` and `path`)
|
|
19754
20964
|
if (slide._bkgdImgRid) {
|
|
19755
|
-
|
|
20965
|
+
var _slide_background3;
|
|
20966
|
+
const bkgdEffects = genXmlBlipRecolor((_slide_background3 = slide.background) === null || _slide_background3 === void 0 ? void 0 : _slide_background3.recolor);
|
|
20967
|
+
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>`;
|
|
19756
20968
|
} 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) {
|
|
19757
20969
|
// NOTE: `<a:effectLst/>` is required by PowerPoint (matches image-bg path above); omitting it triggers the repair dialog
|
|
19758
20970
|
strSlideXml += `<p:bg><p:bgPr>${genXmlColorSelection(slide.background)}<a:effectLst/></p:bgPr></p:bg>`;
|
|
@@ -19770,7 +20982,7 @@ function slideObjectToXml(slide) {
|
|
|
19770
20982
|
const shapeCoordinates = [];
|
|
19771
20983
|
const renderObjectList = (objects)=>{
|
|
19772
20984
|
objects.forEach((slideItemObj, idx)=>{
|
|
19773
|
-
var _slideItemObj_options, _slideItemObj_options1, _slide__slideLayout, _slideItemObj_options_line, _slideItemObj_options_sizing, _slideItemObj_options2;
|
|
20985
|
+
var _slideItemObj_options, _slideItemObj_options1, _slide__slideLayout, _slideItemObj_options_line, _slideItemObj_options_line1, _slideItemObj_options_sizing, _slideItemObj_options2;
|
|
19774
20986
|
let x = 0;
|
|
19775
20987
|
let y = 0;
|
|
19776
20988
|
let cx = getSmartParseNumber('75%', 'X', slide._presLayout);
|
|
@@ -19785,6 +20997,7 @@ function slideObjectToXml(slide) {
|
|
|
19785
20997
|
slideItemObj.options.sId = shapeId;
|
|
19786
20998
|
shapeCoordinates.push({
|
|
19787
20999
|
id: shapeId,
|
|
21000
|
+
objectName: slideItemObj.options.objectName,
|
|
19788
21001
|
position: {
|
|
19789
21002
|
x: slideItemObj.options.x,
|
|
19790
21003
|
y: slideItemObj.options.y,
|
|
@@ -19804,7 +21017,10 @@ function slideObjectToXml(slide) {
|
|
|
19804
21017
|
})[0];
|
|
19805
21018
|
}
|
|
19806
21019
|
// A: Geometry — connectors may auto-size from source/target shape boxes (ZentoSoft)
|
|
19807
|
-
|
|
21020
|
+
if ((_slideItemObj_options_line = slideItemObj.options.line) === null || _slideItemObj_options_line === void 0 ? void 0 : _slideItemObj_options_line.isConnector) {
|
|
21021
|
+
resolveConnectorObjectNames(slideItemObj.options.line, shapeCoordinates);
|
|
21022
|
+
}
|
|
21023
|
+
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;
|
|
19808
21024
|
if (connectorLayout) {
|
|
19809
21025
|
x = connectorLayout.x;
|
|
19810
21026
|
y = connectorLayout.y;
|
|
@@ -19864,7 +21080,7 @@ function slideObjectToXml(slide) {
|
|
|
19864
21080
|
switch(slideItemObj._type){
|
|
19865
21081
|
case (/* inlined export .SLIDE_OBJECT_TYPES.table */"table"):
|
|
19866
21082
|
{
|
|
19867
|
-
var _slideItemObj_arrTabRows, _slide__slideNum;
|
|
21083
|
+
var _slideItemObj_arrTabRows, _slide__slideNum, _slideItemObj_options_objectName;
|
|
19868
21084
|
arrTabRows = (_slideItemObj_arrTabRows = slideItemObj.arrTabRows) !== null && _slideItemObj_arrTabRows !== void 0 ? _slideItemObj_arrTabRows : [];
|
|
19869
21085
|
objTabOpts = slideItemObj.options;
|
|
19870
21086
|
intColCnt = 0;
|
|
@@ -19877,12 +21093,12 @@ function slideObjectToXml(slide) {
|
|
|
19877
21093
|
});
|
|
19878
21094
|
// STEP 1: Start Table XML
|
|
19879
21095
|
// NOTE: Non-numeric cNvPr id values will trigger "presentation needs repair" type warning in MS-PPT-2013
|
|
19880
|
-
strXml =
|
|
21096
|
+
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);
|
|
19881
21097
|
// When the table binds to a master/layout placeholder, emit `<p:ph type="tbl"/>` (ECMA-376 §4.4.1.33, issue #856)
|
|
19882
21098
|
const tblPh = placeholderObj ? genXmlPlaceholder(placeholderObj, slideItemObj.options) : '';
|
|
19883
21099
|
// MS-PPTX §2.3.1.19: each p14:modId must be unique on the slide (not a constant).
|
|
19884
21100
|
const tableModId = typeof slideItemObj.options.modId === 'number' ? slideItemObj.options.modId : TABLE_MOD_ID_BASE + idx;
|
|
19885
|
-
strXml +=
|
|
21101
|
+
strXml += `<p:cNvGraphicFramePr>${genXmlLocks('a:graphicFrameLocks', slideItemObj.options.lock, ' noGrp="1"')}</p:cNvGraphicFramePr>` + ` ${genXmlNvPr(slideItemObj.options, tblPh, [
|
|
19886
21102
|
nvPrModIdExt(tableModId)
|
|
19887
21103
|
])}` + '</p:nvGraphicFramePr>';
|
|
19888
21104
|
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>`;
|
|
@@ -19978,8 +21194,10 @@ function slideObjectToXml(slide) {
|
|
|
19978
21194
|
// A: Table Height provided without rowH? Then distribute rows
|
|
19979
21195
|
let intRowH = 0 // IMPORTANT: Default must be zero for auto-sizing to work
|
|
19980
21196
|
;
|
|
19981
|
-
|
|
19982
|
-
|
|
21197
|
+
// `rowH` is either one value for every row or a per-row array; `inch2Emu` resolves inches, EMU and unit-suffixed strings alike
|
|
21198
|
+
const rowHOpt = Array.isArray(objTabOpts.rowH) ? objTabOpts.rowH[rIdx] : objTabOpts.rowH;
|
|
21199
|
+
const rowHEmu = rowHOpt ? inch2Emu(rowHOpt) : NaN;
|
|
21200
|
+
if (!isNaN(rowHEmu)) intRowH = rowHEmu;
|
|
19983
21201
|
else if (itemOpts.cy || itemOpts.h) {
|
|
19984
21202
|
intRowH = Math.round((itemOpts.h ? inch2Emu(itemOpts.h) : typeof itemOpts.cy === 'number' ? itemOpts.cy : 1) / arrTabRows.length);
|
|
19985
21203
|
}
|
|
@@ -20058,9 +21276,10 @@ function slideObjectToXml(slide) {
|
|
|
20058
21276
|
* - Backwards-Compat: Oops! Discovered we were still using points for cell margin before v3.8.0 (UGH!)
|
|
20059
21277
|
* - We cant introduce a breaking change before v4.0, so...
|
|
20060
21278
|
*/ 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])}"`;
|
|
20061
|
-
|
|
21279
|
+
const cellOverflow = cellOpts.horzOverflow === 'overflow' || cellOpts.horzOverflow === 'clip' ? ` horzOverflow="${cellOpts.horzOverflow}"` : '';
|
|
21280
|
+
const cellAnchorCtr = cellOpts.anchorCtr === true ? ' anchorCtr="1"' : '';
|
|
20062
21281
|
// 4: Set CELL content and properties ==================================
|
|
20063
|
-
strXml += `<a:tc${cellSpanAttrStr}>${genXmlTextBody(cell)}<a:tcPr${cellMarginXml}${cellValign}${cellTextDir}>`;
|
|
21282
|
+
strXml += `<a:tc${cellSpanAttrStr}>${genXmlTextBody(cell)}<a:tcPr${cellMarginXml}${cellValign}${cellTextDir}${cellAnchorCtr}${cellOverflow}>`;
|
|
20064
21283
|
// strXml += `<a:tc${cellColspan}${cellRowspan}>${genXmlTextBody(cell)}<a:tcPr${cellMarginXml}${cellValign}${cellTextDir}>`
|
|
20065
21284
|
// FIXME: 20200525: ^^^
|
|
20066
21285
|
// <a:tcPr marL="38100" marR="38100" marT="38100" marB="38100" vert="vert270">
|
|
@@ -20085,18 +21304,29 @@ function slideObjectToXml(slide) {
|
|
|
20085
21304
|
name: 'lnB'
|
|
20086
21305
|
}
|
|
20087
21306
|
].forEach((obj)=>{
|
|
20088
|
-
|
|
20089
|
-
const borderTransparency = border[obj.idx].transparency;
|
|
20090
|
-
const borderAlpha = typeof borderTransparency === 'number' ? `<a:alpha val="${Math.round((100 - Math.min(100, Math.max(0, borderTransparency))) * 1000)}"/>` : '';
|
|
20091
|
-
strXml += `<a:${obj.name} w="${valToPts(border[obj.idx].pt)}" cap="flat" cmpd="sng" algn="ctr">`;
|
|
20092
|
-
strXml += `<a:solidFill>${createColorElement(border[obj.idx].color, borderAlpha)}</a:solidFill>`;
|
|
20093
|
-
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"/>`;
|
|
20094
|
-
strXml += `</a:${obj.name}>`;
|
|
20095
|
-
} else {
|
|
20096
|
-
strXml += `<a:${obj.name} w="0" cap="flat" cmpd="sng" algn="ctr"><a:noFill/></a:${obj.name}>`;
|
|
20097
|
-
}
|
|
21307
|
+
strXml += genXmlCellBorder(obj.name, border[obj.idx]);
|
|
20098
21308
|
});
|
|
20099
21309
|
}
|
|
21310
|
+
// 5b: Diagonals follow the four edges in the CT_TableCellProperties sequence, and are
|
|
21311
|
+
// written only when asked for - unlike the edges, which are always emitted as a set
|
|
21312
|
+
if (cellOpts.borderDiagonalDown) strXml += genXmlCellBorder('lnTlToBr', cellOpts.borderDiagonalDown);
|
|
21313
|
+
if (cellOpts.borderDiagonalUp) strXml += genXmlCellBorder('lnBlToTr', cellOpts.borderDiagonalUp);
|
|
21314
|
+
// 5c: `a:cell3D` follows the diagonals and precedes the fill
|
|
21315
|
+
if (cellOpts.cell3D) {
|
|
21316
|
+
var _cell3D_bevel;
|
|
21317
|
+
var _cell3D_lightRig;
|
|
21318
|
+
const cell3D = cellOpts.cell3D;
|
|
21319
|
+
const bevel = (_cell3D_bevel = cell3D.bevel) !== null && _cell3D_bevel !== void 0 ? _cell3D_bevel : {};
|
|
21320
|
+
let bevelAttrs = '';
|
|
21321
|
+
if (typeof bevel.width === 'number' && isFinite(bevel.width) && bevel.width >= 0) bevelAttrs += ` w="${inch2Emu(bevel.width)}"`;
|
|
21322
|
+
if (typeof bevel.height === 'number' && isFinite(bevel.height) && bevel.height >= 0) bevelAttrs += ` h="${inch2Emu(bevel.height)}"`;
|
|
21323
|
+
if (bevel.preset) bevelAttrs += ` prst="${bevel.preset}"`;
|
|
21324
|
+
// `rig` and `dir` are both required on CT_LightRig, so a partial rig is dropped rather
|
|
21325
|
+
// than emitted as an element PowerPoint would refuse to open
|
|
21326
|
+
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}"/>` : '';
|
|
21327
|
+
// `a:bevel` is required by the schema, so it is always written
|
|
21328
|
+
strXml += `<a:cell3D${cell3D.material ? ` prstMaterial="${cell3D.material}"` : ''}><a:bevel${bevelAttrs}/>${lightRig}</a:cell3D>`;
|
|
21329
|
+
}
|
|
20100
21330
|
// 6: Close cell Properties & Cell
|
|
20101
21331
|
strXml += cellFill;
|
|
20102
21332
|
strXml += ' </a:tcPr>';
|
|
@@ -20119,38 +21349,38 @@ function slideObjectToXml(slide) {
|
|
|
20119
21349
|
case (/* inlined export .SLIDE_OBJECT_TYPES.text */"text"):
|
|
20120
21350
|
case (/* inlined export .SLIDE_OBJECT_TYPES.placeholder */"placeholder"):
|
|
20121
21351
|
{
|
|
20122
|
-
var
|
|
20123
|
-
const isConnector = !!((
|
|
21352
|
+
var _slideItemObj_options_line2, _slideItemObj_options_styleRef;
|
|
21353
|
+
const isConnector = !!((_slideItemObj_options_line2 = slideItemObj.options.line) === null || _slideItemObj_options_line2 === void 0 ? void 0 : _slideItemObj_options_line2.isConnector);
|
|
20124
21354
|
// Lines can have zero cy, but text should not
|
|
20125
21355
|
if (!slideItemObj.options.line && cy === 0) cy = (/* inlined export .EMU */914400) * 0.3;
|
|
20126
21356
|
// Text margins are applied in addTextDefinition → `_bodyProp` (TRBL)
|
|
20127
21357
|
// A: Start SHAPE / CONNECTOR ============================================
|
|
20128
21358
|
if (isConnector) {
|
|
20129
|
-
var _ref, _ref1;
|
|
20130
|
-
var
|
|
21359
|
+
var _slideItemObj_options_objectName1, _ref, _ref1;
|
|
21360
|
+
var _slideItemObj_options_line3, _slideItemObj_options_line4, _slideItemObj_options_line5, _slideItemObj_options_line6;
|
|
20131
21361
|
strSlideXml += '<p:cxnSp>';
|
|
20132
|
-
strSlideXml += `<p:nvCxnSpPr
|
|
20133
|
-
|
|
21362
|
+
strSlideXml += `<p:nvCxnSpPr>${genXmlCNvPr(shapeId, String((_slideItemObj_options_objectName1 = slideItemObj.options.objectName) !== null && _slideItemObj_options_objectName1 !== void 0 ? _slideItemObj_options_objectName1 : ''), slideItemObj.options)}`;
|
|
21363
|
+
const cxnLocks = genXmlLocks('a:cxnSpLocks', slideItemObj.options.lock);
|
|
21364
|
+
const stId = (_slideItemObj_options_line3 = slideItemObj.options.line) === null || _slideItemObj_options_line3 === void 0 ? void 0 : _slideItemObj_options_line3.sourceId;
|
|
21365
|
+
const endId = (_slideItemObj_options_line4 = slideItemObj.options.line) === null || _slideItemObj_options_line4 === void 0 ? void 0 : _slideItemObj_options_line4.targetId;
|
|
21366
|
+
strSlideXml += `<p:cNvCxnSpPr>${cxnLocks}`;
|
|
21367
|
+
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}"/>`;
|
|
21368
|
+
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}"/>`;
|
|
21369
|
+
strSlideXml += '</p:cNvCxnSpPr>';
|
|
20134
21370
|
strSlideXml += `${genXmlNvPr(slideItemObj.options, '', [
|
|
20135
21371
|
nvPrModIdExt(slideItemObj.options.modId)
|
|
20136
21372
|
])}</p:nvCxnSpPr><p:spPr>`;
|
|
20137
21373
|
} else {
|
|
20138
|
-
var
|
|
21374
|
+
var _slideItemObj_options_objectName2;
|
|
21375
|
+
var _slideItemObj_options3;
|
|
20139
21376
|
strSlideXml += '<p:sp>';
|
|
20140
21377
|
// B: The addition of the "txBox" attribute is the sole determiner of if an object is a shape or textbox
|
|
20141
|
-
strSlideXml +=
|
|
20142
|
-
// <Hyperlink>
|
|
20143
|
-
if ((_slideItemObj_options_hyperlink = slideItemObj.options.hyperlink) === null || _slideItemObj_options_hyperlink === void 0 ? void 0 : _slideItemObj_options_hyperlink.url) {
|
|
20144
|
-
strSlideXml += `<a:hlinkClick r:id="rId${slideItemObj.options.hyperlink._rId}" tooltip="${slideItemObj.options.hyperlink.tooltip ? encodeXmlEntities(slideItemObj.options.hyperlink.tooltip) : ''}"/>`;
|
|
20145
|
-
}
|
|
20146
|
-
if ((_slideItemObj_options_hyperlink1 = slideItemObj.options.hyperlink) === null || _slideItemObj_options_hyperlink1 === void 0 ? void 0 : _slideItemObj_options_hyperlink1.slide) {
|
|
20147
|
-
strSlideXml += `<a:hlinkClick r:id="rId${slideItemObj.options.hyperlink._rId}" tooltip="${slideItemObj.options.hyperlink.tooltip ? encodeXmlEntities(slideItemObj.options.hyperlink.tooltip) : ''}" action="ppaction://hlinksldjump"/>`;
|
|
20148
|
-
}
|
|
20149
|
-
// </Hyperlink>
|
|
20150
|
-
strSlideXml += '</p:cNvPr>';
|
|
21378
|
+
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));
|
|
20151
21379
|
// PowerPoint math zones are authored in text boxes; force txBox when OMML is present
|
|
20152
21380
|
const useTxBox = Boolean((_slideItemObj_options3 = slideItemObj.options) === null || _slideItemObj_options3 === void 0 ? void 0 : _slideItemObj_options3.isTextBox) || textRunsHaveOmml(slideItemObj.text);
|
|
20153
|
-
strSlideXml +=
|
|
21381
|
+
strSlideXml += genXmlCNvSpPr(slide_object_spread_props(xml_slide_object_spread({}, slideItemObj.options), {
|
|
21382
|
+
isTextBox: useTxBox
|
|
21383
|
+
}));
|
|
20154
21384
|
strSlideXml += genXmlNvPr(slideItemObj.options, slideItemObj._type === 'placeholder' ? genXmlPlaceholder(slideItemObj, slideItemObj.options) : genXmlPlaceholder(placeholderObj, slideItemObj.options), [
|
|
20155
21385
|
nvPrModIdExt(slideItemObj.options.modId)
|
|
20156
21386
|
]);
|
|
@@ -20162,7 +21392,7 @@ function slideObjectToXml(slide) {
|
|
|
20162
21392
|
if (!isConnector && slideItemObj.shape === 'custGeom') {
|
|
20163
21393
|
strSlideXml += genCustGeomXml(slideItemObj, cx, cy, slide);
|
|
20164
21394
|
} else {
|
|
20165
|
-
var _slideItemObj_options_line_curveadjust,
|
|
21395
|
+
var _slideItemObj_options_line_curveadjust, _slideItemObj_options_line7;
|
|
20166
21396
|
strSlideXml += '<a:prstGeom prst="' + slideItemObj.shape + '"><a:avLst>';
|
|
20167
21397
|
// `rectRadius: 0` is a valid sharp-corner adj (ECMA-376 §5.1.11 preset geom `gd name="adj"`).
|
|
20168
21398
|
if (typeof slideItemObj.options.rectRadius === 'number' && Number.isFinite(slideItemObj.options.rectRadius) && slideItemObj.options.rectRadius >= 0) {
|
|
@@ -20176,7 +21406,7 @@ function slideObjectToXml(slide) {
|
|
|
20176
21406
|
strSlideXml += `<a:gd name="adj3" fmla="val ${Math.round(slideItemObj.options.arcThicknessRatio * 50000)}" />`;
|
|
20177
21407
|
}
|
|
20178
21408
|
}
|
|
20179
|
-
if (isConnector && ((
|
|
21409
|
+
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)) {
|
|
20180
21410
|
slideItemObj.options.line.curveadjust.forEach((adj, i)=>{
|
|
20181
21411
|
strSlideXml += `<a:gd name="adj${i + 1}" fmla="val ${Math.round(Number(adj))}"/>`;
|
|
20182
21412
|
});
|
|
@@ -20184,20 +21414,26 @@ function slideObjectToXml(slide) {
|
|
|
20184
21414
|
strSlideXml += '</a:avLst></a:prstGeom>';
|
|
20185
21415
|
}
|
|
20186
21416
|
// Option: FILL
|
|
20187
|
-
|
|
21417
|
+
// With a fillRef and no explicit fill, omit the fill element so the theme inherits
|
|
21418
|
+
if (slideItemObj.options.fill) strSlideXml += genXmlColorSelection(slideItemObj.options.fill);
|
|
21419
|
+
else if (!((_slideItemObj_options_styleRef = slideItemObj.options.styleRef) === null || _slideItemObj_options_styleRef === void 0 ? void 0 : _slideItemObj_options_styleRef.fill)) strSlideXml += '<a:noFill/>';
|
|
20188
21420
|
// shape Type: LINE: line color
|
|
20189
21421
|
if (slideItemObj.options.line) strSlideXml += genXmlLine(slideItemObj.options.line);
|
|
20190
|
-
// EFFECTS: shadow / glow / softEdge / reflection
|
|
21422
|
+
// EFFECTS: shadow / glow / softEdge / reflection / fillOverlay / blur
|
|
20191
21423
|
// REF: @see http://officeopenxml.com/drwSp-effects.php
|
|
20192
21424
|
strSlideXml += genXmlEffectLst({
|
|
20193
21425
|
shadow: slideItemObj.options.shadow,
|
|
20194
21426
|
glow: slideItemObj.options.glow,
|
|
20195
21427
|
softEdge: slideItemObj.options.softEdge,
|
|
20196
21428
|
reflection: slideItemObj.options.reflection,
|
|
20197
|
-
blur: slideItemObj.options.blur
|
|
21429
|
+
blur: slideItemObj.options.blur,
|
|
21430
|
+
fillOverlay: slideItemObj.options.fillOverlay,
|
|
21431
|
+
effectDag: slideItemObj.options.effectDag
|
|
20198
21432
|
});
|
|
20199
21433
|
// B: Close shape Properties
|
|
20200
21434
|
strSlideXml += '</p:spPr>';
|
|
21435
|
+
// `p:style` follows `p:spPr` in CT_Shape / CT_Connector
|
|
21436
|
+
strSlideXml += genXmlShapeStyle(slideItemObj.options.styleRef);
|
|
20201
21437
|
if (isConnector) {
|
|
20202
21438
|
// Connectors have no text body
|
|
20203
21439
|
strSlideXml += '</p:cxnSp>';
|
|
@@ -20210,18 +21446,13 @@ function slideObjectToXml(slide) {
|
|
|
20210
21446
|
break;
|
|
20211
21447
|
}
|
|
20212
21448
|
case (/* inlined export .SLIDE_OBJECT_TYPES.image */"image"):
|
|
20213
|
-
var
|
|
21449
|
+
var _slideItemObj_options_objectName3;
|
|
21450
|
+
var _slideItemObj_options_lock;
|
|
20214
21451
|
strSlideXml += '<p:pic>';
|
|
20215
21452
|
strSlideXml += ' <p:nvPicPr>';
|
|
20216
|
-
strSlideXml +=
|
|
20217
|
-
|
|
20218
|
-
|
|
20219
|
-
}
|
|
20220
|
-
if ((_slideItemObj_hyperlink1 = slideItemObj.hyperlink) === null || _slideItemObj_hyperlink1 === void 0 ? void 0 : _slideItemObj_hyperlink1.slide) {
|
|
20221
|
-
strSlideXml += `<a:hlinkClick r:id="rId${slideItemObj.hyperlink._rId}" tooltip="${slideItemObj.hyperlink.tooltip ? encodeXmlEntities(slideItemObj.hyperlink.tooltip) : ''}" action="ppaction://hlinksldjump"/>`;
|
|
20222
|
-
}
|
|
20223
|
-
strSlideXml += ' </p:cNvPr>';
|
|
20224
|
-
strSlideXml += ' <p:cNvPicPr><a:picLocks noChangeAspect="1"/></p:cNvPicPr>';
|
|
21453
|
+
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));
|
|
21454
|
+
// `noChangeAspect` has always been emitted here; caller locks are added to it
|
|
21455
|
+
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>`;
|
|
20225
21456
|
strSlideXml += genXmlNvPr(slideItemObj.options, genXmlPlaceholder(placeholderObj, slideItemObj.options), [
|
|
20226
21457
|
nvPrModIdExt(slideItemObj.options.modId)
|
|
20227
21458
|
]);
|
|
@@ -20231,7 +21462,7 @@ function slideObjectToXml(slide) {
|
|
|
20231
21462
|
if ((slide._relsMedia || []).filter((rel)=>rel.rId === slideItemObj.imageRid)[0] && (slide._relsMedia || []).filter((rel)=>rel.rId === slideItemObj.imageRid)[0].extn === 'svg') {
|
|
20232
21463
|
var _slideItemObj_imageRid;
|
|
20233
21464
|
strSlideXml += `<a:blip r:embed="rId${((_slideItemObj_imageRid = slideItemObj.imageRid) !== null && _slideItemObj_imageRid !== void 0 ? _slideItemObj_imageRid : 0) - 1}">`;
|
|
20234
|
-
strSlideXml += slideItemObj.options.transparency
|
|
21465
|
+
strSlideXml += genXmlBlipEffects(slideItemObj.options.transparency, slideItemObj.options.alphaEffects, slideItemObj.options.recolor);
|
|
20235
21466
|
strSlideXml += ' <a:extLst>';
|
|
20236
21467
|
strSlideXml += ' <a:ext uri="{96DAC541-7B7A-43D3-8B79-37D633B846F1}">';
|
|
20237
21468
|
strSlideXml += ` <asvg:svgBlip xmlns:asvg="http://schemas.microsoft.com/office/drawing/2016/SVG/main" r:embed="rId${slideItemObj.imageRid}"/>`;
|
|
@@ -20240,7 +21471,7 @@ function slideObjectToXml(slide) {
|
|
|
20240
21471
|
strSlideXml += '</a:blip>';
|
|
20241
21472
|
} else {
|
|
20242
21473
|
strSlideXml += `<a:blip r:embed="rId${slideItemObj.imageRid}">`;
|
|
20243
|
-
strSlideXml += slideItemObj.options.transparency
|
|
21474
|
+
strSlideXml += genXmlBlipEffects(slideItemObj.options.transparency, slideItemObj.options.alphaEffects, slideItemObj.options.recolor);
|
|
20244
21475
|
strSlideXml += '</a:blip>';
|
|
20245
21476
|
}
|
|
20246
21477
|
if (sizing === null || sizing === void 0 ? void 0 : sizing.type) {
|
|
@@ -20300,26 +21531,53 @@ function slideObjectToXml(slide) {
|
|
|
20300
21531
|
}
|
|
20301
21532
|
// OUTLINE: picture border/frame (issue #35)
|
|
20302
21533
|
if (slideItemObj.options.line) strSlideXml += genXmlLine(slideItemObj.options.line);
|
|
20303
|
-
// EFFECTS: shadow / glow / softEdge / reflection
|
|
21534
|
+
// EFFECTS: shadow / glow / softEdge / reflection / fillOverlay / blur
|
|
20304
21535
|
strSlideXml += genXmlEffectLst({
|
|
20305
21536
|
shadow: slideItemObj.options.shadow,
|
|
20306
21537
|
glow: slideItemObj.options.glow,
|
|
20307
21538
|
softEdge: slideItemObj.options.softEdge,
|
|
20308
21539
|
reflection: slideItemObj.options.reflection,
|
|
20309
|
-
blur: slideItemObj.options.blur
|
|
21540
|
+
blur: slideItemObj.options.blur,
|
|
21541
|
+
fillOverlay: slideItemObj.options.fillOverlay,
|
|
21542
|
+
effectDag: slideItemObj.options.effectDag
|
|
20310
21543
|
});
|
|
20311
21544
|
strSlideXml += '</p:spPr>';
|
|
21545
|
+
strSlideXml += genXmlShapeStyle(slideItemObj.options.styleRef);
|
|
20312
21546
|
strSlideXml += '</p:pic>';
|
|
20313
21547
|
break;
|
|
20314
21548
|
case (/* inlined export .SLIDE_OBJECT_TYPES.media */"media"):
|
|
20315
|
-
if (slideItemObj.mtype === '
|
|
21549
|
+
if (slideItemObj.mtype === 'audioCd' || slideItemObj.mtype === 'wav') {
|
|
21550
|
+
var _slideItemObj__coverRid;
|
|
21551
|
+
// EG_Media is a choice, so these carry exactly one media element and no `p14:media`:
|
|
21552
|
+
// `a:audioCd` references the listener's drive and `a:wavAudioFile` is the legacy
|
|
21553
|
+
// embedded-WAV element, so neither has an embedded media part to point at
|
|
21554
|
+
const coverRid = (_slideItemObj__coverRid = slideItemObj._coverRid) !== null && _slideItemObj__coverRid !== void 0 ? _slideItemObj__coverRid : 2;
|
|
21555
|
+
strSlideXml += '<p:pic>';
|
|
21556
|
+
strSlideXml += ' <p:nvPicPr>';
|
|
21557
|
+
strSlideXml += `<p:cNvPr id="${coverRid}" name="${slideItemObj.options.objectName}"><a:hlinkClick r:id="" action="ppaction://media"/></p:cNvPr>`;
|
|
21558
|
+
strSlideXml += ' <p:cNvPicPr><a:picLocks noChangeAspect="1"/></p:cNvPicPr>';
|
|
21559
|
+
if (slideItemObj.mtype === 'audioCd') {
|
|
21560
|
+
const cd = slideItemObj.options.audioCd;
|
|
21561
|
+
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>`);
|
|
21562
|
+
} else {
|
|
21563
|
+
strSlideXml += genXmlNvPr(slideItemObj.options, `<a:wavAudioFile r:embed="rId${slideItemObj.mediaRid}"${slideItemObj.options.objectName ? ` name="${slideItemObj.options.objectName}"` : ''}/>`);
|
|
21564
|
+
}
|
|
21565
|
+
strSlideXml += ' </p:nvPicPr>';
|
|
21566
|
+
strSlideXml += ` <p:blipFill><a:blip r:embed="rId${coverRid}"/><a:stretch><a:fillRect/></a:stretch></p:blipFill>`;
|
|
21567
|
+
strSlideXml += ' <p:spPr>';
|
|
21568
|
+
strSlideXml += ` <a:xfrm${locationAttr}><a:off x="${x}" y="${y}"/><a:ext cx="${cx}" cy="${cy}"/></a:xfrm>`;
|
|
21569
|
+
strSlideXml += ' <a:prstGeom prst="rect"><a:avLst/></a:prstGeom>';
|
|
21570
|
+
strSlideXml += ' </p:spPr>';
|
|
21571
|
+
strSlideXml += '</p:pic>';
|
|
21572
|
+
} else if (slideItemObj.mtype === 'online') {
|
|
20316
21573
|
var _slideItemObj_mediaRid, _slideItemObj_mediaRid1;
|
|
21574
|
+
const contentType = slideItemObj.options.contentType ? ` contentType="${encodeXmlEntities(slideItemObj.options.contentType)}"` : '';
|
|
20317
21575
|
strSlideXml += '<p:pic>';
|
|
20318
21576
|
strSlideXml += ' <p:nvPicPr>';
|
|
20319
21577
|
// IMPORTANT: <p:cNvPr id="" value is critical - if its not the same number as preview image `rId`, PowerPoint throws error!
|
|
20320
21578
|
strSlideXml += `<p:cNvPr id="${((_slideItemObj_mediaRid = slideItemObj.mediaRid) !== null && _slideItemObj_mediaRid !== void 0 ? _slideItemObj_mediaRid : 0) + 2}" name="${slideItemObj.options.objectName}"/>`;
|
|
20321
21579
|
strSlideXml += ' <p:cNvPicPr/>';
|
|
20322
|
-
strSlideXml += genXmlNvPr(slideItemObj.options, `<a:videoFile r:link="rId${slideItemObj.mediaRid}"/>`);
|
|
21580
|
+
strSlideXml += genXmlNvPr(slideItemObj.options, `<a:videoFile r:link="rId${slideItemObj.mediaRid}"${contentType}/>`);
|
|
20323
21581
|
strSlideXml += ' </p:nvPicPr>';
|
|
20324
21582
|
// NOTE: `blip` is diferent than videos; also there's no preview "p:extLst" above but exists in videos
|
|
20325
21583
|
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!
|
|
@@ -20332,6 +21590,7 @@ function slideObjectToXml(slide) {
|
|
|
20332
21590
|
var _slideItemObj_mediaRid2, _slideItemObj_mediaRid3, _slideItemObj_mediaRid4, _slideItemObj_mediaRid5;
|
|
20333
21591
|
// ECMA-376: audio uses `<a:audioFile>`, video uses `<a:videoFile>` under nvPr.
|
|
20334
21592
|
const mediaFileTag = slideItemObj.mtype === 'audio' ? 'a:audioFile' : 'a:videoFile';
|
|
21593
|
+
const contentType = slideItemObj.options.contentType ? ` contentType="${encodeXmlEntities(slideItemObj.options.contentType)}"` : '';
|
|
20335
21594
|
strSlideXml += '<p:pic>';
|
|
20336
21595
|
strSlideXml += ' <p:nvPicPr>';
|
|
20337
21596
|
// IMPORTANT: <p:cNvPr id="" value is critical - if not the same number as preiew image rId, PowerPoint throws error!
|
|
@@ -20340,7 +21599,7 @@ function slideObjectToXml(slide) {
|
|
|
20340
21599
|
const mediaExtras = genXmlMediaExtras(slideItemObj.options);
|
|
20341
21600
|
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>';
|
|
20342
21601
|
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>' : '';
|
|
20343
|
-
strSlideXml += genXmlNvPr(slideItemObj.options, `<${mediaFileTag} r:link="rId${slideItemObj.mediaRid}"/>`, narrationExt ? [
|
|
21602
|
+
strSlideXml += genXmlNvPr(slideItemObj.options, `<${mediaFileTag} r:link="rId${slideItemObj.mediaRid}"${contentType}/>`, narrationExt ? [
|
|
20344
21603
|
mediaExt,
|
|
20345
21604
|
narrationExt
|
|
20346
21605
|
] : [
|
|
@@ -20447,41 +21706,64 @@ function slideObjectToXml(slide) {
|
|
|
20447
21706
|
break;
|
|
20448
21707
|
}
|
|
20449
21708
|
case (/* inlined export .SLIDE_OBJECT_TYPES.chart */"chart"):
|
|
20450
|
-
|
|
20451
|
-
|
|
20452
|
-
|
|
20453
|
-
|
|
20454
|
-
|
|
20455
|
-
|
|
20456
|
-
|
|
20457
|
-
|
|
20458
|
-
|
|
20459
|
-
|
|
20460
|
-
|
|
20461
|
-
|
|
20462
|
-
|
|
20463
|
-
|
|
20464
|
-
|
|
20465
|
-
|
|
21709
|
+
{
|
|
21710
|
+
var _slideItemObj_options_objectName4;
|
|
21711
|
+
var _slideItemObj_options4;
|
|
21712
|
+
const chartType = (_slideItemObj_options4 = slideItemObj.options) === null || _slideItemObj_options4 === void 0 ? void 0 : _slideItemObj_options4._type;
|
|
21713
|
+
const isChartex = isChartexType(chartType);
|
|
21714
|
+
const graphicDataUri = isChartex ? OOXML_CHARTEX.ns : 'http://schemas.openxmlformats.org/drawingml/2006/chart';
|
|
21715
|
+
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"/>`;
|
|
21716
|
+
const chartLocks = genXmlLocks('a:graphicFrameLocks', slideItemObj.options.lock);
|
|
21717
|
+
let frameXml = '<p:graphicFrame>';
|
|
21718
|
+
frameXml += ' <p:nvGraphicFramePr>';
|
|
21719
|
+
frameXml += genXmlCNvPr(shapeId, String((_slideItemObj_options_objectName4 = slideItemObj.options.objectName) !== null && _slideItemObj_options_objectName4 !== void 0 ? _slideItemObj_options_objectName4 : ''), slideItemObj.options, slideItemObj.options.altText || '');
|
|
21720
|
+
frameXml += chartLocks ? ` <p:cNvGraphicFramePr>${chartLocks}</p:cNvGraphicFramePr>` : ' <p:cNvGraphicFramePr/>';
|
|
21721
|
+
frameXml += genXmlNvPr(slideItemObj.options, genXmlPlaceholder(placeholderObj, slideItemObj.options), [
|
|
21722
|
+
nvPrModIdExt(slideItemObj.options.modId)
|
|
21723
|
+
]);
|
|
21724
|
+
frameXml += ' </p:nvGraphicFramePr>';
|
|
21725
|
+
frameXml += ` <p:xfrm><a:off x="${x}" y="${y}"/><a:ext cx="${cx}" cy="${cy}"/></p:xfrm>`;
|
|
21726
|
+
frameXml += ' <a:graphic xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main">';
|
|
21727
|
+
frameXml += ` <a:graphicData uri="${graphicDataUri}">`;
|
|
21728
|
+
frameXml += ` ${chartRef}`;
|
|
21729
|
+
frameXml += ' </a:graphicData>';
|
|
21730
|
+
frameXml += ' </a:graphic>';
|
|
21731
|
+
frameXml += '</p:graphicFrame>';
|
|
21732
|
+
// A chartex frame replaces a standard graphic frame, so MS-PPTX 2.2 requires it be offered
|
|
21733
|
+
// through `mc:AlternateContent`. PowerPoint's own fallback is a rendered preview image, which
|
|
21734
|
+
// cannot be produced here - a locked text shape carrying the same message is the honest
|
|
21735
|
+
// equivalent for a consumer that does not understand the chartex namespace.
|
|
21736
|
+
strSlideXml += isChartex ? `<mc:AlternateContent xmlns:mc="${MC_NS}">` + `<mc:Choice xmlns:cx1="${chartExRequiresNs(chartType)}" Requires="cx1">` + frameXml + '</mc:Choice>' + `<mc:Fallback>${genXmlChartExFallback(shapeId, slideItemObj, {
|
|
21737
|
+
x,
|
|
21738
|
+
y,
|
|
21739
|
+
cx,
|
|
21740
|
+
cy
|
|
21741
|
+
})}</mc:Fallback>` + '</mc:AlternateContent>' : frameXml;
|
|
21742
|
+
break;
|
|
21743
|
+
}
|
|
20466
21744
|
case (/* inlined export .SLIDE_OBJECT_TYPES.group */"group"):
|
|
20467
21745
|
{
|
|
20468
21746
|
var _slideItemObj__objects;
|
|
20469
21747
|
// PresentationML `p:grpSp` (ECMA-376 §19.3.1.22): nvGrpSpPr + grpSpPr + children.
|
|
20470
21748
|
// Child coords are group-relative; chOff is 0,0 and chExt matches the group size.
|
|
20471
21749
|
strSlideXml += '<p:grpSp>';
|
|
20472
|
-
strSlideXml += `<p:nvGrpSpPr
|
|
20473
|
-
|
|
21750
|
+
strSlideXml += `<p:nvGrpSpPr>${genXmlCNvPr(shapeId, slideItemObj.options.objectName || `Group ${shapeId}`, slideItemObj.options)}`;
|
|
21751
|
+
const grpLocks = genXmlLocks('a:grpSpLocks', slideItemObj.options.lock);
|
|
21752
|
+
strSlideXml += (grpLocks ? `<p:cNvGrpSpPr>${grpLocks}</p:cNvGrpSpPr>` : '<p:cNvGrpSpPr/>') + `${genXmlNvPr(slideItemObj.options)}</p:nvGrpSpPr>`;
|
|
20474
21753
|
strSlideXml += '<p:grpSpPr>';
|
|
20475
21754
|
strSlideXml += `<a:xfrm${locationAttr}>`;
|
|
20476
21755
|
strSlideXml += `<a:off x="${x}" y="${y}"/><a:ext cx="${cx}" cy="${cy}"/>`;
|
|
20477
21756
|
strSlideXml += `<a:chOff x="0" y="0"/><a:chExt cx="${cx}" cy="${cy}"/>`;
|
|
20478
21757
|
strSlideXml += '</a:xfrm>';
|
|
21758
|
+
if (slideItemObj.options.fill) strSlideXml += genXmlColorSelection(slideItemObj.options.fill);
|
|
20479
21759
|
strSlideXml += genXmlEffectLst({
|
|
20480
21760
|
shadow: slideItemObj.options.shadow,
|
|
20481
21761
|
glow: slideItemObj.options.glow,
|
|
20482
21762
|
softEdge: slideItemObj.options.softEdge,
|
|
20483
21763
|
reflection: slideItemObj.options.reflection,
|
|
20484
|
-
blur: slideItemObj.options.blur
|
|
21764
|
+
blur: slideItemObj.options.blur,
|
|
21765
|
+
fillOverlay: slideItemObj.options.fillOverlay,
|
|
21766
|
+
effectDag: slideItemObj.options.effectDag
|
|
20485
21767
|
});
|
|
20486
21768
|
strSlideXml += '</p:grpSpPr>';
|
|
20487
21769
|
renderObjectList((_slideItemObj__objects = slideItemObj._objects) !== null && _slideItemObj__objects !== void 0 ? _slideItemObj__objects : []);
|
|
@@ -20589,6 +21871,20 @@ function package_object_spread(target) {
|
|
|
20589
21871
|
|
|
20590
21872
|
|
|
20591
21873
|
|
|
21874
|
+
|
|
21875
|
+
/**
|
|
21876
|
+
* Content-type overrides a chart needs: the chart itself plus, when requested, its style and colour-style parts.
|
|
21877
|
+
* - one helper because charts appear on slides, layouts and the master, and a part with no declared
|
|
21878
|
+
* content type is a repair-dialog cause
|
|
21879
|
+
*/ function chartContentTypes(rel) {
|
|
21880
|
+
const partContentType = isChartexType(rel.opts._type) ? OOXML_CHARTEX.partContentType : 'application/vnd.openxmlformats-officedocument.drawingml.chart+xml';
|
|
21881
|
+
let xml = `<Override PartName="${rel.Target}" ContentType="${partContentType}"/>`;
|
|
21882
|
+
if (wantsChartStyleParts(rel.opts)) {
|
|
21883
|
+
xml += `<Override PartName="/${chartColorsPartName(rel.globalId)}" ContentType="${CHART_STYLE.colorsContentType}"/>`;
|
|
21884
|
+
xml += `<Override PartName="/${chartStylePartName(rel.globalId)}" ContentType="${CHART_STYLE.styleContentType}"/>`;
|
|
21885
|
+
}
|
|
21886
|
+
return xml;
|
|
21887
|
+
}
|
|
20592
21888
|
/** MS-PPTX §2.2.6 showPr browseMode */ const URI_BROWSE_MODE = '{F99C55AA-B7CB-42B0-86F8-08522FDF87E8}';
|
|
20593
21889
|
/** MS-PPTX §2.2.6 showPr laserClr */ const URI_LASER_CLR = '{EC167BDD-8182-4AB7-AECC-EB403E3ABB37}';
|
|
20594
21890
|
/** MS-PPTX §2.2.6 sld laserTraceLst */ const URI_LASER_TRACE_LST = '{3A86A75C-4F4B-4683-9AE1-C65F6400EC91}';
|
|
@@ -20654,7 +21950,7 @@ function slideShowExtLst(slide) {
|
|
|
20654
21950
|
strXml += '<Default Extension="mp4" ContentType="video/mp4"/>'; // NOTE: Hard-Code this extension as it wont be created in loop below (as extn !== type)
|
|
20655
21951
|
slides.forEach((slide)=>{
|
|
20656
21952
|
(slide._relsMedia || []).forEach((rel)=>{
|
|
20657
|
-
if (rel.type !== 'image' && rel.type !== 'online' && rel.type !== 'chart' && rel.extn !== 'm4v' && !strXml.includes(rel.type)) {
|
|
21953
|
+
if (!rel.isLinked && rel.type !== 'image' && rel.type !== 'online' && rel.type !== 'chart' && rel.extn !== 'm4v' && !strXml.includes(rel.type)) {
|
|
20658
21954
|
strXml += '<Default Extension="' + rel.extn + '" ContentType="' + rel.type + '"/>';
|
|
20659
21955
|
}
|
|
20660
21956
|
});
|
|
@@ -20675,7 +21971,7 @@ function slideShowExtLst(slide) {
|
|
|
20675
21971
|
strXml += `<Override PartName="/ppt/slides/slide${idx + 1}.xml" ContentType="application/vnd.openxmlformats-officedocument.presentationml.slide+xml"/>`;
|
|
20676
21972
|
// Add charts if any
|
|
20677
21973
|
slide._relsChart.forEach((rel)=>{
|
|
20678
|
-
strXml +=
|
|
21974
|
+
strXml += chartContentTypes(rel);
|
|
20679
21975
|
});
|
|
20680
21976
|
});
|
|
20681
21977
|
// STEP 3: Core PPT
|
|
@@ -20688,7 +21984,7 @@ function slideShowExtLst(slide) {
|
|
|
20688
21984
|
slideLayouts.forEach((layout, idx)=>{
|
|
20689
21985
|
strXml += `<Override PartName="/ppt/slideLayouts/slideLayout${idx + 1}.xml" ContentType="application/vnd.openxmlformats-officedocument.presentationml.slideLayout+xml"/>`;
|
|
20690
21986
|
(layout._relsChart || []).forEach((rel)=>{
|
|
20691
|
-
strXml +=
|
|
21987
|
+
strXml += chartContentTypes(rel);
|
|
20692
21988
|
});
|
|
20693
21989
|
});
|
|
20694
21990
|
// STEP 5: Add notes slide(s)
|
|
@@ -20717,10 +22013,10 @@ function slideShowExtLst(slide) {
|
|
|
20717
22013
|
if (tracking === null || tracking === void 0 ? void 0 : tracking.revisionInfo) strXml += `<Override PartName="/ppt/revisionInfo.xml" ContentType="${REVISION_INFO_CONTENT_TYPE}"/>`;
|
|
20718
22014
|
if (tracking === null || tracking === void 0 ? void 0 : tracking.changesInfo) strXml += `<Override PartName="/ppt/changesInfo.xml" ContentType="${CHANGES_INFO_CONTENT_TYPE}"/>`;
|
|
20719
22015
|
((_ref = masterSlide === null || masterSlide === void 0 ? void 0 : masterSlide._relsChart) !== null && _ref !== void 0 ? _ref : []).forEach((rel)=>{
|
|
20720
|
-
strXml +=
|
|
22016
|
+
strXml += chartContentTypes(rel);
|
|
20721
22017
|
});
|
|
20722
22018
|
((_ref1 = masterSlide === null || masterSlide === void 0 ? void 0 : masterSlide._relsMedia) !== null && _ref1 !== void 0 ? _ref1 : []).forEach((rel)=>{
|
|
20723
|
-
if (rel.type !== 'image' && rel.type !== 'online' && rel.type !== 'chart' && rel.extn !== 'm4v' && !strXml.includes(rel.type)) {
|
|
22019
|
+
if (!rel.isLinked && rel.type !== 'image' && rel.type !== 'online' && rel.type !== 'chart' && rel.extn !== 'm4v' && !strXml.includes(rel.type)) {
|
|
20724
22020
|
strXml += ' <Default Extension="' + rel.extn + '" ContentType="' + rel.type + '"/>';
|
|
20725
22021
|
}
|
|
20726
22022
|
});
|
|
@@ -20740,22 +22036,46 @@ function slideShowExtLst(slide) {
|
|
|
20740
22036
|
<Relationship Id="rId3" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" Target="ppt/presentation.xml"/>
|
|
20741
22037
|
</Relationships>`;
|
|
20742
22038
|
}
|
|
22039
|
+
/**
|
|
22040
|
+
* Count text paragraphs across the deck for `app.xml`
|
|
22041
|
+
* - derived rather than exposed: the value is a fact about the deck, not a caller preference
|
|
22042
|
+
* @param {PresSlide[]} slides - presentation slides
|
|
22043
|
+
* @returns {number} paragraph count
|
|
22044
|
+
*/ function countParagraphs(slides) {
|
|
22045
|
+
return slides.reduce((total, slide)=>{
|
|
22046
|
+
var _slide__slideObjects;
|
|
22047
|
+
return total + ((_slide__slideObjects = slide._slideObjects) !== null && _slide__slideObjects !== void 0 ? _slide__slideObjects : []).reduce((count, obj)=>{
|
|
22048
|
+
var _obj_text;
|
|
22049
|
+
if (obj._type !== (/* inlined export .SLIDE_OBJECT_TYPES.text */"text") && obj._type !== (/* inlined export .SLIDE_OBJECT_TYPES.placeholder */"placeholder")) return count;
|
|
22050
|
+
return count + Math.max(1, ((_obj_text = obj.text) !== null && _obj_text !== void 0 ? _obj_text : []).length);
|
|
22051
|
+
}, 0);
|
|
22052
|
+
}, 0);
|
|
22053
|
+
}
|
|
20743
22054
|
/**
|
|
20744
22055
|
* Creates `docProps/app.xml`
|
|
20745
22056
|
* @param {PresSlide[]} slides - Presenation Slides
|
|
20746
22057
|
* @param {string} company - "Company" metadata
|
|
22058
|
+
* @param {DocumentProps} [props] - optional extended properties
|
|
20747
22059
|
* @returns XML
|
|
20748
|
-
*/ function makeXmlApp(slides, company) {
|
|
22060
|
+
*/ function makeXmlApp(slides, company, props) {
|
|
20749
22061
|
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">
|
|
20750
|
-
|
|
22062
|
+
${(props === null || props === void 0 ? void 0 : props.template) ? `<Template>${encodeXmlEntities(props.template)}</Template>` : ''}
|
|
22063
|
+
${(props === null || props === void 0 ? void 0 : props.manager) ? `<Manager>${encodeXmlEntities(props.manager)}</Manager>` : ''}
|
|
22064
|
+
<TotalTime>${typeof (props === null || props === void 0 ? void 0 : props.totalEditTime) === 'number' && isFinite(props.totalEditTime) && props.totalEditTime >= 0 ? Math.round(props.totalEditTime) : 0}</TotalTime>
|
|
20751
22065
|
<Words>0</Words>
|
|
20752
22066
|
<Application>Microsoft Office PowerPoint</Application>
|
|
20753
22067
|
<PresentationFormat>On-screen Show (16:9)</PresentationFormat>
|
|
20754
|
-
<Paragraphs
|
|
22068
|
+
<Paragraphs>${countParagraphs(slides)}</Paragraphs>
|
|
20755
22069
|
<Slides>${slides.length}</Slides>
|
|
20756
|
-
<Notes>${slides.
|
|
20757
|
-
|
|
20758
|
-
|
|
22070
|
+
<Notes>${slides.filter((slide)=>{
|
|
22071
|
+
var _slide__slideObjects;
|
|
22072
|
+
return ((_slide__slideObjects = slide._slideObjects) !== null && _slide__slideObjects !== void 0 ? _slide__slideObjects : []).some((obj)=>obj._type === (/* inlined export .SLIDE_OBJECT_TYPES.notes */"notes"));
|
|
22073
|
+
}).length}</Notes>
|
|
22074
|
+
<HiddenSlides>${slides.filter((slide)=>slide.hidden).length}</HiddenSlides>
|
|
22075
|
+
<MMClips>${slides.reduce((sum, slide)=>{
|
|
22076
|
+
var _slide__slideObjects;
|
|
22077
|
+
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;
|
|
22078
|
+
}, 0)}</MMClips>
|
|
20759
22079
|
<ScaleCrop>false</ScaleCrop>
|
|
20760
22080
|
<HeadingPairs>
|
|
20761
22081
|
<vt:vector size="6" baseType="variant">
|
|
@@ -20778,6 +22098,7 @@ function slideShowExtLst(slide) {
|
|
|
20778
22098
|
<Company>${encodeXmlEntities(company)}</Company>
|
|
20779
22099
|
<LinksUpToDate>false</LinksUpToDate>
|
|
20780
22100
|
<SharedDoc>false</SharedDoc>
|
|
22101
|
+
${(props === null || props === void 0 ? void 0 : props.hyperlinkBase) ? `<HyperlinkBase>${encodeXmlEntities(props.hyperlinkBase)}</HyperlinkBase>` : ''}
|
|
20781
22102
|
<HyperlinksChanged>false</HyperlinksChanged>
|
|
20782
22103
|
<AppVersion>16.0000</AppVersion>
|
|
20783
22104
|
</Properties>`;
|
|
@@ -20790,14 +22111,23 @@ function slideShowExtLst(slide) {
|
|
|
20790
22111
|
* @param {string} revision - metadata value
|
|
20791
22112
|
* @param {Date} [created] - OPC `dcterms:created` (defaults to now)
|
|
20792
22113
|
* @param {Date} [modified] - OPC `dcterms:modified` (defaults to now)
|
|
22114
|
+
* @param {DocumentProps} [props] - optional extra core properties
|
|
20793
22115
|
* @returns XML
|
|
20794
|
-
*/ function makeXmlCore(title, subject, author, revision, created, modified) {
|
|
22116
|
+
*/ function makeXmlCore(title, subject, author, revision, created, modified, props) {
|
|
20795
22117
|
const createdAt = (created !== null && created !== void 0 ? created : new Date()).toISOString().replace(/\.\d\d\dZ/, 'Z');
|
|
20796
22118
|
const modifiedAt = (modified !== null && modified !== void 0 ? modified : new Date()).toISOString().replace(/\.\d\d\dZ/, 'Z');
|
|
20797
22119
|
return `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
20798
22120
|
<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">
|
|
20799
22121
|
<dc:title>${encodeXmlEntities(title)}</dc:title>
|
|
20800
22122
|
<dc:subject>${encodeXmlEntities(subject)}</dc:subject>
|
|
22123
|
+
${(props === null || props === void 0 ? void 0 : props.description) ? `<dc:description>${encodeXmlEntities(props.description)}</dc:description>` : ''}
|
|
22124
|
+
${(props === null || props === void 0 ? void 0 : props.keywords) ? `<cp:keywords>${encodeXmlEntities(props.keywords)}</cp:keywords>` : ''}
|
|
22125
|
+
${(props === null || props === void 0 ? void 0 : props.category) ? `<cp:category>${encodeXmlEntities(props.category)}</cp:category>` : ''}
|
|
22126
|
+
${(props === null || props === void 0 ? void 0 : props.contentStatus) ? `<cp:contentStatus>${encodeXmlEntities(props.contentStatus)}</cp:contentStatus>` : ''}
|
|
22127
|
+
${(props === null || props === void 0 ? void 0 : props.version) ? `<cp:version>${encodeXmlEntities(props.version)}</cp:version>` : ''}
|
|
22128
|
+
${(props === null || props === void 0 ? void 0 : props.language) ? `<dc:language>${encodeXmlEntities(props.language)}</dc:language>` : ''}
|
|
22129
|
+
${(props === null || props === void 0 ? void 0 : props.identifier) ? `<dc:identifier>${encodeXmlEntities(props.identifier)}</dc:identifier>` : ''}
|
|
22130
|
+
${(props === null || props === void 0 ? void 0 : props.lastPrinted) ? `<cp:lastPrinted>${encodeXmlEntities(props.lastPrinted)}</cp:lastPrinted>` : ''}
|
|
20801
22131
|
<dc:creator>${encodeXmlEntities(author)}</dc:creator>
|
|
20802
22132
|
<cp:lastModifiedBy>${encodeXmlEntities(author)}</cp:lastModifiedBy>
|
|
20803
22133
|
<cp:revision>${revision}</cp:revision>
|
|
@@ -20846,7 +22176,7 @@ function slideShowExtLst(slide) {
|
|
|
20846
22176
|
const entries = [];
|
|
20847
22177
|
((_slide__slideObjects = slide._slideObjects) !== null && _slide__slideObjects !== void 0 ? _slide__slideObjects : []).forEach((obj)=>{
|
|
20848
22178
|
var _obj_mediaRid;
|
|
20849
|
-
if (obj._type !== (/* inlined export .SLIDE_OBJECT_TYPES.media */"media") || obj.mtype
|
|
22179
|
+
if (obj._type !== (/* inlined export .SLIDE_OBJECT_TYPES.media */"media") || obj.mtype !== 'audio' && obj.mtype !== 'video') return;
|
|
20850
22180
|
const o = obj.options;
|
|
20851
22181
|
// Defaults are all false: no timing node unless at least one playback flag is set.
|
|
20852
22182
|
if (!o || !(o.autoplay || o.loop || o.fullScreen || o.mute)) return;
|
|
@@ -20981,10 +22311,29 @@ function collectSlideAnimations(slide) {
|
|
|
20981
22311
|
* @param {SlideLayout} layout - slide layout (master)
|
|
20982
22312
|
* @return {string} XML
|
|
20983
22313
|
*/ function makeXmlLayout(layout) {
|
|
22314
|
+
// `preserve` has always been written as "1", so it stays on unless the caller turns it off
|
|
22315
|
+
let attrs = layout.preserve === false ? '' : ' preserve="1"';
|
|
22316
|
+
if (layout.layoutType) attrs += ` type="${layout.layoutType}"`;
|
|
22317
|
+
if (layout.matchingName) attrs += ` matchingName="${encodeXmlEntities(layout.matchingName)}"`;
|
|
22318
|
+
// both default to true in the schema, so only the "off" case is written
|
|
22319
|
+
if (layout.showMasterShapes === false) attrs += ' showMasterSp="0"';
|
|
22320
|
+
if (layout.showMasterPlaceholderAnimation === false) attrs += ' showMasterPhAnim="0"';
|
|
22321
|
+
if (layout.userDrawn === true) attrs += ' userDrawn="1"';
|
|
22322
|
+
// CT_ColorMapping requires all twelve attributes, so a partial override is filled from the
|
|
22323
|
+
// identity map - which is exactly what inheriting `a:masterClrMapping` means
|
|
22324
|
+
const clrMapOvr = layout.colorMapOverride ? `<p:clrMapOvr><a:overrideClrMapping${Object.entries(DEF_COLOR_MAP).map(([slot, fallback])=>{
|
|
22325
|
+
var _ref;
|
|
22326
|
+
var _layout_colorMapOverride;
|
|
22327
|
+
return ` ${slot}="${(_ref = (_layout_colorMapOverride = layout.colorMapOverride) === null || _layout_colorMapOverride === void 0 ? void 0 : _layout_colorMapOverride[slot]) !== null && _ref !== void 0 ? _ref : fallback}"`;
|
|
22328
|
+
}).join('')}/></p:clrMapOvr>` : '<p:clrMapOvr><a:masterClrMapping/></p:clrMapOvr>';
|
|
22329
|
+
const transitionXml = genXmlTransition(layout);
|
|
22330
|
+
const hasP14 = transitionXml.includes('p14:') || transitionXml.includes('xmlns:p14');
|
|
22331
|
+
const ns = hasP14 ? ` xmlns:p14="${P14_NS}"` : '';
|
|
22332
|
+
// CT_SlideLayout sequence: cSld, clrMapOvr, transition, timing, hf, extLst
|
|
20984
22333
|
return `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
20985
|
-
<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"
|
|
22334
|
+
<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}>
|
|
20986
22335
|
${slideObjectToXml(layout)}
|
|
20987
|
-
|
|
22336
|
+
${clrMapOvr}${transitionXml}</p:sldLayout>`;
|
|
20988
22337
|
}
|
|
20989
22338
|
/**
|
|
20990
22339
|
* Creates Slide Master 1 (`ppt/slideMasters/slideMaster1.xml`)
|
|
@@ -21055,6 +22404,7 @@ const NOTES_GUIDE_URI = '{2D200454-40CA-4A62-9FC3-DE9A4176ACB9}';
|
|
|
21055
22404
|
* @param {IPresentationProps} pres - presentation
|
|
21056
22405
|
* @return {string} XML
|
|
21057
22406
|
*/ function makeXmlPresentation(pres) {
|
|
22407
|
+
var _pres_kinsoku;
|
|
21058
22408
|
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">`;
|
|
21059
22409
|
// STEP 1: Add slide master (SPEC: tag 1 under <presentation>)
|
|
21060
22410
|
strXml += '<p:sldMasterIdLst><p:sldMasterId id="2147483648" r:id="rId1"/></p:sldMasterIdLst>';
|
|
@@ -21078,8 +22428,26 @@ const NOTES_GUIDE_URI = '{2D200454-40CA-4A62-9FC3-DE9A4176ACB9}';
|
|
|
21078
22428
|
// Presentations open without warning without this line, but then they aren't previewed in Finder or viewable on iOS.
|
|
21079
22429
|
strXml += `<p:notesMasterIdLst><p:notesMasterId r:id="rId${pres.slides.length + 2}"/></p:notesMasterIdLst>`;
|
|
21080
22430
|
// STEP 4: Add sizes
|
|
21081
|
-
|
|
22431
|
+
// `@type` records which preset the dimensions match; omitted when the caller does not say
|
|
22432
|
+
strXml += `<p:sldSz cx="${pres.presLayout.width}" cy="${pres.presLayout.height}"${pres.slideSizeType ? ` type="${pres.slideSizeType}"` : ''}/>`;
|
|
21082
22433
|
strXml += `<p:notesSz cx="${pres.presLayout.height}" cy="${pres.presLayout.width}"/>`;
|
|
22434
|
+
// CT_Presentation sequence puts these between `notesSz` and `defaultTextStyle` (photoAlbum, kinsoku)
|
|
22435
|
+
if (pres.photoAlbum) {
|
|
22436
|
+
const album = pres.photoAlbum;
|
|
22437
|
+
let attrs = '';
|
|
22438
|
+
if (album.blackWhite === true) attrs += ' bw="1"';
|
|
22439
|
+
if (album.showCaptions === true) attrs += ' showCaptions="1"';
|
|
22440
|
+
if (album.layout) attrs += ` layout="${album.layout}"`;
|
|
22441
|
+
if (album.frame) attrs += ` frame="${album.frame}"`;
|
|
22442
|
+
strXml += `<p:photoAlbum${attrs}/>`;
|
|
22443
|
+
}
|
|
22444
|
+
// `invalStChars` and `invalEndChars` are required on CT_Kinsoku, so a partial value is dropped
|
|
22445
|
+
// rather than emitted as an element PowerPoint would refuse to open
|
|
22446
|
+
if (((_pres_kinsoku = pres.kinsoku) === null || _pres_kinsoku === void 0 ? void 0 : _pres_kinsoku.invalidStartChars) && pres.kinsoku.invalidEndChars) {
|
|
22447
|
+
const kin = pres.kinsoku;
|
|
22448
|
+
const lang = kin.lang ? ` lang="${encodeXmlEntities(kin.lang)}"` : '';
|
|
22449
|
+
strXml += `<p:kinsoku${lang} invalStChars="${encodeXmlEntities(kin.invalidStartChars)}" invalEndChars="${encodeXmlEntities(kin.invalidEndChars)}"/>`;
|
|
22450
|
+
}
|
|
21083
22451
|
// STEP 5: Add text styles
|
|
21084
22452
|
strXml += '<p:defaultTextStyle>';
|
|
21085
22453
|
for(let idy = 1; idy < 10; idy++){
|
|
@@ -21119,10 +22487,28 @@ const NOTES_GUIDE_URI = '{2D200454-40CA-4A62-9FC3-DE9A4176ACB9}';
|
|
|
21119
22487
|
* Create `ppt/presProps.xml`
|
|
21120
22488
|
* @return {string} XML
|
|
21121
22489
|
*/ function makeXmlPresProps(pres) {
|
|
21122
|
-
// CT_PresentationProperties sequence:
|
|
22490
|
+
// CT_PresentationProperties sequence: htmlPubPr, webPr, prnPr, showPr, clrMru, extLst.
|
|
22491
|
+
// Opt-in: emit nothing extra unless set. prnPr/clrMru live here (not on CT_Presentation).
|
|
22492
|
+
const prnPr = makeXmlPrnPr(pres);
|
|
21123
22493
|
const showPr = makeXmlShowPr(pres);
|
|
22494
|
+
const clrMru = makeXmlClrMru(pres);
|
|
21124
22495
|
const extLst = makeXmlPresPropsExtLst(pres);
|
|
21125
|
-
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>`;
|
|
22496
|
+
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>`;
|
|
22497
|
+
}
|
|
22498
|
+
function makeXmlPrnPr(pres) {
|
|
22499
|
+
if (!(pres === null || pres === void 0 ? void 0 : pres.printProps)) return '';
|
|
22500
|
+
const prn = pres.printProps;
|
|
22501
|
+
let attrs = '';
|
|
22502
|
+
if (prn.what) attrs += ` prnWhat="${prn.what}"`;
|
|
22503
|
+
if (prn.colorMode) attrs += ` clrMode="${prn.colorMode}"`;
|
|
22504
|
+
if (prn.hiddenSlides === true) attrs += ' hiddenSlides="1"';
|
|
22505
|
+
if (prn.scaleToFitPaper === true) attrs += ' scaleToFitPaper="1"';
|
|
22506
|
+
if (prn.frameSlides === true) attrs += ' frameSlides="1"';
|
|
22507
|
+
return `<p:prnPr${attrs}/>`;
|
|
22508
|
+
}
|
|
22509
|
+
function makeXmlClrMru(pres) {
|
|
22510
|
+
if (!Array.isArray(pres === null || pres === void 0 ? void 0 : pres.recentColors) || pres.recentColors.length === 0) return '';
|
|
22511
|
+
return `<p:clrMru>${pres.recentColors.map((color)=>createColorElement(color)).join('')}</p:clrMru>`;
|
|
21126
22512
|
}
|
|
21127
22513
|
/**
|
|
21128
22514
|
* `p:showPr` for slide-show options, or '' when none are set.
|
|
@@ -21171,14 +22557,144 @@ function makeXmlPresPropsExtLst(pres) {
|
|
|
21171
22557
|
* Create `ppt/tableStyles.xml`
|
|
21172
22558
|
* @see: http://openxmldeveloper.org/discussions/formats/f/13/p/2398/8107.aspx
|
|
21173
22559
|
* @return {string} XML
|
|
21174
|
-
*/
|
|
21175
|
-
|
|
22560
|
+
*/ /**
|
|
22561
|
+
* The GUID `a:tblStyleLst@def` has always carried - PowerPoint's "Medium Style 2 - Accent 1"
|
|
22562
|
+
*/ const DEF_TABLE_STYLE_ID = '{5C22544A-7EE6-4342-B048-85BDC9FD1C3A}';
|
|
22563
|
+
/**
|
|
22564
|
+
* CT_TableStyle fixes this child order, and it is neither alphabetical nor the intuitive one:
|
|
22565
|
+
* `lastCol` precedes `firstCol`, and `firstRow` sits between `swCell` and `neCell`.
|
|
22566
|
+
*/ const TABLE_STYLE_PARTS = [
|
|
22567
|
+
[
|
|
22568
|
+
'wholeTable',
|
|
22569
|
+
'wholeTbl'
|
|
22570
|
+
],
|
|
22571
|
+
[
|
|
22572
|
+
'band1H',
|
|
22573
|
+
'band1H'
|
|
22574
|
+
],
|
|
22575
|
+
[
|
|
22576
|
+
'band2H',
|
|
22577
|
+
'band2H'
|
|
22578
|
+
],
|
|
22579
|
+
[
|
|
22580
|
+
'band1V',
|
|
22581
|
+
'band1V'
|
|
22582
|
+
],
|
|
22583
|
+
[
|
|
22584
|
+
'band2V',
|
|
22585
|
+
'band2V'
|
|
22586
|
+
],
|
|
22587
|
+
[
|
|
22588
|
+
'lastCol',
|
|
22589
|
+
'lastCol'
|
|
22590
|
+
],
|
|
22591
|
+
[
|
|
22592
|
+
'firstCol',
|
|
22593
|
+
'firstCol'
|
|
22594
|
+
],
|
|
22595
|
+
[
|
|
22596
|
+
'lastRow',
|
|
22597
|
+
'lastRow'
|
|
22598
|
+
],
|
|
22599
|
+
[
|
|
22600
|
+
'seCell',
|
|
22601
|
+
'seCell'
|
|
22602
|
+
],
|
|
22603
|
+
[
|
|
22604
|
+
'swCell',
|
|
22605
|
+
'swCell'
|
|
22606
|
+
],
|
|
22607
|
+
[
|
|
22608
|
+
'firstRow',
|
|
22609
|
+
'firstRow'
|
|
22610
|
+
],
|
|
22611
|
+
[
|
|
22612
|
+
'neCell',
|
|
22613
|
+
'neCell'
|
|
22614
|
+
],
|
|
22615
|
+
[
|
|
22616
|
+
'nwCell',
|
|
22617
|
+
'nwCell'
|
|
22618
|
+
]
|
|
22619
|
+
];
|
|
22620
|
+
/** CT_TableCellBorderStyle child order */ const TABLE_STYLE_BORDERS = [
|
|
22621
|
+
'left',
|
|
22622
|
+
'right',
|
|
22623
|
+
'top',
|
|
22624
|
+
'bottom',
|
|
22625
|
+
'insideH',
|
|
22626
|
+
'insideV'
|
|
22627
|
+
];
|
|
22628
|
+
/**
|
|
22629
|
+
* One part of a table style (`a:wholeTbl`, `a:band1H`, ...).
|
|
22630
|
+
* - `a:tcTxStyle` precedes `a:tcStyle`; inside the cell style, `a:tcBdr` precedes the fill
|
|
22631
|
+
*/ function genXmlTableStylePart(tag, part) {
|
|
22632
|
+
// `b`/`i` are ST_OnOffStyleType: an unset property means "def", i.e. leave it to the theme
|
|
22633
|
+
const bold = typeof part.bold === 'boolean' ? ` b="${part.bold ? 'on' : 'off'}"` : '';
|
|
22634
|
+
const italic = typeof part.italic === 'boolean' ? ` i="${part.italic ? 'on' : 'off'}"` : '';
|
|
22635
|
+
const txStyle = bold || italic || part.color ? `<a:tcTxStyle${bold}${italic}>${part.color ? createColorElement(part.color) : ''}</a:tcTxStyle>` : '';
|
|
22636
|
+
const borders = TABLE_STYLE_BORDERS.filter((edge)=>{
|
|
22637
|
+
var _part_borders;
|
|
22638
|
+
return (_part_borders = part.borders) === null || _part_borders === void 0 ? void 0 : _part_borders[edge];
|
|
22639
|
+
}).map((edge)=>{
|
|
22640
|
+
var _part_borders;
|
|
22641
|
+
const line = (_part_borders = part.borders) === null || _part_borders === void 0 ? void 0 : _part_borders[edge];
|
|
22642
|
+
return line ? `<a:${edge}>${genXmlLine(line)}</a:${edge}>` : '';
|
|
22643
|
+
}).join('');
|
|
22644
|
+
const fill = part.fill ? `<a:fill>${genXmlColorSelection(part.fill)}</a:fill>` : '';
|
|
22645
|
+
const cellStyle = borders || fill ? `<a:tcStyle>${borders ? `<a:tcBdr>${borders}</a:tcBdr>` : ''}${fill}</a:tcStyle>` : '';
|
|
22646
|
+
return txStyle || cellStyle ? `<a:${tag}>${txStyle}${cellStyle}</a:${tag}>` : '';
|
|
22647
|
+
}
|
|
22648
|
+
/**
|
|
22649
|
+
* Creates `ppt/tableStyles.xml`
|
|
22650
|
+
* - with no custom styles this is the same self-closing stub earlier versions wrote
|
|
22651
|
+
* @param {TableStyleProps[]} [styles] - custom table style definitions
|
|
22652
|
+
* @return {string} XML
|
|
22653
|
+
*/ function makeXmlTableStyles(styles) {
|
|
22654
|
+
const valid = (styles !== null && styles !== void 0 ? styles : []).filter((style)=>{
|
|
22655
|
+
var _ref;
|
|
22656
|
+
// `@styleId` is an ST_Guid and `@styleName` is required; a malformed id would be rejected on open
|
|
22657
|
+
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 : '')) {
|
|
22658
|
+
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`);
|
|
22659
|
+
return false;
|
|
22660
|
+
}
|
|
22661
|
+
if (!style.name) {
|
|
22662
|
+
console.warn(`[pptxgenjs] table style ${style.id} has no \`name\` - ignored`);
|
|
22663
|
+
return false;
|
|
22664
|
+
}
|
|
22665
|
+
return true;
|
|
22666
|
+
});
|
|
22667
|
+
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}"`;
|
|
22668
|
+
if (valid.length === 0) return `${head}/>`;
|
|
22669
|
+
const body = valid.map((style)=>{
|
|
22670
|
+
const parts = TABLE_STYLE_PARTS.map(([prop, tag])=>{
|
|
22671
|
+
const part = style[prop];
|
|
22672
|
+
return part && typeof part === 'object' ? genXmlTableStylePart(tag, part) : '';
|
|
22673
|
+
}).join('');
|
|
22674
|
+
return `<a:tblStyle styleId="${style.id}" styleName="${encodeXmlEntities(style.name)}">${parts}</a:tblStyle>`;
|
|
22675
|
+
}).join('');
|
|
22676
|
+
return `${head}>${body}</a:tblStyleLst>`;
|
|
21176
22677
|
}
|
|
21177
22678
|
/**
|
|
21178
22679
|
* Creates `ppt/viewProps.xml`
|
|
22680
|
+
* - the hardcoded literal is kept when the caller sets no `viewProps`, so default packages stay byte-identical
|
|
21179
22681
|
* @return {string} XML
|
|
21180
|
-
*/ function makeXmlViewProps() {
|
|
21181
|
-
|
|
22682
|
+
*/ function makeXmlViewProps(pres) {
|
|
22683
|
+
var _view_guides;
|
|
22684
|
+
if (!(pres === null || pres === void 0 ? void 0 : pres.viewProps)) {
|
|
22685
|
+
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>`;
|
|
22686
|
+
}
|
|
22687
|
+
const view = pres.viewProps;
|
|
22688
|
+
const zoom = typeof view.zoom === 'number' && isFinite(view.zoom) && view.zoom > 0 ? Math.round(view.zoom) : 136;
|
|
22689
|
+
const grid = typeof view.gridSpacing === 'number' && isFinite(view.gridSpacing) && view.gridSpacing > 0 ? inch2Emu(view.gridSpacing) : 76200;
|
|
22690
|
+
const snapGrid = view.snapToGrid === true ? '1' : '0';
|
|
22691
|
+
const snapObj = view.snapToObjects === false ? '0' : '1';
|
|
22692
|
+
const showGuides = view.showGuides === true ? ' showGuides="1"' : '';
|
|
22693
|
+
const showComments = view.showComments === false ? ' showComments="0"' : '';
|
|
22694
|
+
const lastView = view.lastView ? ` lastView="${view.lastView}"` : '';
|
|
22695
|
+
// `p:guideLst` is the classic guide list, distinct from the MS-PPTX `p15:sldGuideLst` extension
|
|
22696
|
+
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('');
|
|
22697
|
+
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>';
|
|
21182
22698
|
}
|
|
21183
22699
|
|
|
21184
22700
|
|
|
@@ -21187,6 +22703,7 @@ function makeXmlPresPropsExtLst(pres) {
|
|
|
21187
22703
|
|
|
21188
22704
|
|
|
21189
22705
|
|
|
22706
|
+
|
|
21190
22707
|
function pptxgen_asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
21191
22708
|
try {
|
|
21192
22709
|
var info = gen[key](arg);
|
|
@@ -21369,6 +22886,12 @@ class PptxGenJS {
|
|
|
21369
22886
|
get rtlMode() {
|
|
21370
22887
|
return this._rtlMode;
|
|
21371
22888
|
}
|
|
22889
|
+
set tableStyles(value) {
|
|
22890
|
+
this._tableStyles = value;
|
|
22891
|
+
}
|
|
22892
|
+
get tableStyles() {
|
|
22893
|
+
return this._tableStyles;
|
|
22894
|
+
}
|
|
21372
22895
|
get firstSlideNum() {
|
|
21373
22896
|
return this._firstSlideNum;
|
|
21374
22897
|
}
|
|
@@ -21664,7 +23187,15 @@ class PptxGenJS {
|
|
|
21664
23187
|
_slideNumberProps: propsClone.slideNumber || null,
|
|
21665
23188
|
_slideObjects: [],
|
|
21666
23189
|
background: propsClone.background || null,
|
|
21667
|
-
bkgd: propsClone.bkgd || null
|
|
23190
|
+
bkgd: propsClone.bkgd || null,
|
|
23191
|
+
layoutType: propsClone.layoutType,
|
|
23192
|
+
matchingName: propsClone.matchingName,
|
|
23193
|
+
preserve: propsClone.preserve,
|
|
23194
|
+
showMasterShapes: propsClone.showMasterShapes,
|
|
23195
|
+
showMasterPlaceholderAnimation: propsClone.showMasterPlaceholderAnimation,
|
|
23196
|
+
userDrawn: propsClone.userDrawn,
|
|
23197
|
+
colorMapOverride: propsClone.colorMapOverride,
|
|
23198
|
+
transition: propsClone.transition
|
|
21668
23199
|
};
|
|
21669
23200
|
// STEP 1: Create the Slide Master/Layout
|
|
21670
23201
|
createSlideMaster(propsClone, newLayout);
|
|
@@ -21700,7 +23231,7 @@ class PptxGenJS {
|
|
|
21700
23231
|
*/ pptxgen_define_property(this, "_layout", void 0);
|
|
21701
23232
|
/**
|
|
21702
23233
|
* PptxGenJS Library Version
|
|
21703
|
-
*/ pptxgen_define_property(this, "_version", (/* inlined export .VERSION */"4.
|
|
23234
|
+
*/ pptxgen_define_property(this, "_version", (/* inlined export .VERSION */"4.2.0"));
|
|
21704
23235
|
/**
|
|
21705
23236
|
* @type {string}
|
|
21706
23237
|
*/ pptxgen_define_property(this, "_author", void 0);
|
|
@@ -21733,6 +23264,7 @@ class PptxGenJS {
|
|
|
21733
23264
|
* Whether Right-to-Left (RTL) mode is enabled
|
|
21734
23265
|
* @type {boolean}
|
|
21735
23266
|
*/ pptxgen_define_property(this, "_rtlMode", void 0);
|
|
23267
|
+
/** tableStyles - custom table style definitions written into `ppt/tableStyles.xml` */ pptxgen_define_property(this, "_tableStyles", void 0);
|
|
21736
23268
|
/**
|
|
21737
23269
|
* Starting slide number (`p:presentation@firstSlideNum`)
|
|
21738
23270
|
* @default 1
|
|
@@ -21768,6 +23300,13 @@ class PptxGenJS {
|
|
|
21768
23300
|
* Notes-page alignment guides (MS-PPTX §2.4.1.3). Emitted as `p15:notesGuideLst`.
|
|
21769
23301
|
* @example pptx.notesGuides = [{ orient: 'horz', pos: 2 }]
|
|
21770
23302
|
*/ pptxgen_define_property(this, "notesGuides", []);
|
|
23303
|
+
/** Additional document properties written to `docProps`. */ pptxgen_define_property(this, "documentProps", void 0);
|
|
23304
|
+
/** Slide-size preset (`p:sldSz@type`). */ pptxgen_define_property(this, "slideSizeType", void 0);
|
|
23305
|
+
/** Photo-album mode (`p:photoAlbum`). */ pptxgen_define_property(this, "photoAlbum", void 0);
|
|
23306
|
+
/** East Asian line-breaking rules (`p:kinsoku`). */ pptxgen_define_property(this, "kinsoku", void 0);
|
|
23307
|
+
/** Print defaults (`p:prnPr` on `presentationPr`). */ pptxgen_define_property(this, "printProps", void 0);
|
|
23308
|
+
/** Recently-used colours (`p:clrMru` on `presentationPr`). */ pptxgen_define_property(this, "recentColors", void 0);
|
|
23309
|
+
/** View properties (`ppt/viewProps.xml`). Unset keeps the previous hardcoded viewPr. */ pptxgen_define_property(this, "viewProps", void 0);
|
|
21771
23310
|
/**
|
|
21772
23311
|
* Modern comment authors (MS-PPTX §2.16). Emitted to `ppt/authors.xml`.
|
|
21773
23312
|
* Auto-populated from slide `addComment` author names if left empty.
|
|
@@ -21849,7 +23388,7 @@ class PptxGenJS {
|
|
|
21849
23388
|
*/ pptxgen_define_property(this, "createChartMediaRels", (slide, zip, chartPromises, mediaPaths)=>{
|
|
21850
23389
|
slide._relsChart.forEach((rel)=>chartPromises.push(createExcelWorksheet(rel, zip)));
|
|
21851
23390
|
slide._relsMedia.forEach((rel)=>{
|
|
21852
|
-
if (rel.type !== 'online' && rel.type !== 'hyperlink') {
|
|
23391
|
+
if (!rel.isLinked && rel.type !== 'online' && rel.type !== 'hyperlink') {
|
|
21853
23392
|
var _data_split_pop;
|
|
21854
23393
|
// A: Loop vars
|
|
21855
23394
|
let data = rel.data && typeof rel.data === 'string' ? rel.data : '';
|
|
@@ -21951,16 +23490,16 @@ class PptxGenJS {
|
|
|
21951
23490
|
};
|
|
21952
23491
|
zip.file('[Content_Types].xml', makeXmlContTypes(this.slides, this.slideLayouts, this.masterSlide, trackingParts)); // TODO: pass only `this` like below! 20200206
|
|
21953
23492
|
zip.file('_rels/.rels', makeXmlRootRels());
|
|
21954
|
-
zip.file('docProps/app.xml', makeXmlApp(this.slides, this.company)); // TODO: pass only `this` like below! 20200206
|
|
21955
|
-
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
|
|
23493
|
+
zip.file('docProps/app.xml', makeXmlApp(this.slides, this.company, this.documentProps)); // TODO: pass only `this` like below! 20200206
|
|
23494
|
+
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
|
|
21956
23495
|
zip.file('ppt/_rels/presentation.xml.rels', makeXmlPresentationRels(this.slides, trackingParts));
|
|
21957
23496
|
zip.file('ppt/theme/theme1.xml', makeXmlTheme(this));
|
|
21958
23497
|
// notesMaster gets its own theme part (Office repair creates theme2 when notesMaster shares theme1; Juliussssssss 9bdfe09).
|
|
21959
23498
|
zip.file('ppt/theme/theme2.xml', makeXmlTheme(this, 'notes'));
|
|
21960
23499
|
zip.file('ppt/presentation.xml', makeXmlPresentation(this));
|
|
21961
23500
|
zip.file('ppt/presProps.xml', makeXmlPresProps(this));
|
|
21962
|
-
zip.file('ppt/tableStyles.xml', makeXmlTableStyles());
|
|
21963
|
-
zip.file('ppt/viewProps.xml', makeXmlViewProps());
|
|
23501
|
+
zip.file('ppt/tableStyles.xml', makeXmlTableStyles(this._tableStyles));
|
|
23502
|
+
zip.file('ppt/viewProps.xml', makeXmlViewProps(this));
|
|
21964
23503
|
// C: Create a Layout/Master/Rel/Slide file for each SlideLayout and Slide
|
|
21965
23504
|
this.slideLayouts.forEach((layout, idx)=>{
|
|
21966
23505
|
zip.file(`ppt/slideLayouts/slideLayout${idx + 1}.xml`, makeXmlLayout(layout));
|
|
@@ -22127,6 +23666,7 @@ class PptxGenJS {
|
|
|
22127
23666
|
addTable: notOnMaster,
|
|
22128
23667
|
addText: notOnMaster,
|
|
22129
23668
|
addGroup: notOnMaster,
|
|
23669
|
+
addConnector: notOnMaster,
|
|
22130
23670
|
addWordArt: notOnMaster,
|
|
22131
23671
|
addTransition: notOnMaster,
|
|
22132
23672
|
addAnimation: notOnMaster,
|