@aixa-transformation/pptx-viewer 2.0.27 → 2.0.30

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.
@@ -10190,6 +10190,9 @@ function drawingChild(node, requestedName) {
10190
10190
  continue;
10191
10191
  }
10192
10192
  const child20 = Array.isArray(value) ? value[0] : value;
10193
+ if (child20 === "" || child20 === null || child20 === void 0) {
10194
+ return {};
10195
+ }
10193
10196
  if (child20 && typeof child20 === "object" && !Array.isArray(child20)) {
10194
10197
  return child20;
10195
10198
  }
@@ -12567,6 +12570,13 @@ var PptxShapeStyleExtractor = class {
12567
12570
  if (earlyReturn) {
12568
12571
  return style;
12569
12572
  }
12573
+ if (!style.strokeColor && styleNode?.["a:lnRef"]) {
12574
+ const explicitWidth = style.strokeWidth;
12575
+ this.context.resolveThemeLineRef(styleNode["a:lnRef"], style);
12576
+ if (explicitWidth !== void 0) {
12577
+ style.strokeWidth = explicitWidth;
12578
+ }
12579
+ }
12570
12580
  } else if (styleNode?.["a:lnRef"]) {
12571
12581
  this.context.resolveThemeLineRef(styleNode["a:lnRef"], style);
12572
12582
  }
@@ -13549,6 +13559,20 @@ function ensureArrayLike(value) {
13549
13559
  }
13550
13560
  return Array.isArray(value) ? value : [value];
13551
13561
  }
13562
+ function readPositiveInteger(value) {
13563
+ const parsed = Number.parseInt(String(value ?? ""), 10);
13564
+ return Number.isFinite(parsed) && parsed > 0 ? parsed : 0;
13565
+ }
13566
+ function getTableGridExtent(graphicData) {
13567
+ const table = graphicData?.["a:tbl"];
13568
+ if (!table) {
13569
+ return void 0;
13570
+ }
13571
+ const grid = table["a:tblGrid"];
13572
+ const widthEmu = ensureArrayLike(grid?.["a:gridCol"]).reduce((sum, column) => sum + readPositiveInteger(column?.["@_w"]), 0);
13573
+ const heightEmu = ensureArrayLike(table["a:tr"]).reduce((sum, row) => sum + readPositiveInteger(row?.["@_h"]), 0);
13574
+ return widthEmu > 0 && heightEmu > 0 ? { widthEmu, heightEmu } : void 0;
13575
+ }
13552
13576
  function collectGraphicFrameExtensions(graphicData) {
13553
13577
  if (!graphicData) {
13554
13578
  return [];
@@ -13764,8 +13788,13 @@ var PptxGraphicFrameParser = class {
13764
13788
  const extensionXml = collectGraphicFrameExtensions(graphicData);
13765
13789
  if (type === "table" && graphicData) {
13766
13790
  const tableData = this.context.parseTableData(graphicData);
13791
+ const tableGridExtent = getTableGridExtent(graphicData);
13767
13792
  return {
13768
13793
  ...baseElement,
13794
+ ...tableGridExtent ? {
13795
+ width: Math.round(tableGridExtent.widthEmu / this.context.emuPerPx),
13796
+ height: Math.round(tableGridExtent.heightEmu / this.context.emuPerPx)
13797
+ } : {},
13769
13798
  tableData,
13770
13799
  ...extensionXml.length > 0 ? { extensionXml } : {}
13771
13800
  };
@@ -36846,6 +36875,12 @@ function parseAlignmentAttr2(algn) {
36846
36875
  }
36847
36876
  return ALIGN_MAP[algn] || void 0;
36848
36877
  }
36878
+ function resolveParagraphAlignment(authoredAlignment, placeholderAlignment, paragraphRtl) {
36879
+ if (authoredAlignment !== void 0 && authoredAlignment !== null) {
36880
+ return parseAlignmentAttr2(String(authoredAlignment)) ?? "left";
36881
+ }
36882
+ return placeholderAlignment ?? (paragraphRtl ? "right" : "left");
36883
+ }
36849
36884
  function parseParagraphSpacingPx(spacingNode) {
36850
36885
  if (!spacingNode) {
36851
36886
  return void 0;
@@ -58172,7 +58207,7 @@ var PptxHandlerRuntime21 = class extends PptxHandlerRuntime20 {
58172
58207
  * Extract all placeholders from a layout's `p:spTree`, returning
58173
58208
  * their placeholder info and their transform (position/size in EMU).
58174
58209
  */
58175
- extractLayoutPlaceholders(layoutXml) {
58210
+ extractLayoutPlaceholders(layoutXml, layoutPath) {
58176
58211
  const spTree = xmlPath(layoutXml, "p:sldLayout", "p:cSld", "p:spTree");
58177
58212
  if (!spTree) {
58178
58213
  return [];
@@ -58189,7 +58224,14 @@ var PptxHandlerRuntime21 = class extends PptxHandlerRuntime20 {
58189
58224
  if (!phInfo) {
58190
58225
  continue;
58191
58226
  }
58192
- const spPr = shape["p:spPr"];
58227
+ const masterPath = layoutPath ? this.resolveMasterPathForLayout(layoutPath) : void 0;
58228
+ const masterContext = masterPath ? this.findPlaceholderInShapeTree(
58229
+ xmlPath(this.masterXmlMap.get(masterPath), "p:sldMaster", "p:cSld", "p:spTree"),
58230
+ phInfo
58231
+ ) : void 0;
58232
+ const inheritedShape = masterContext?.shape ?? masterContext?.picture;
58233
+ const resolvedShape = inheritedShape ? this.mergeXmlObjects(inheritedShape, shape) ?? shape : shape;
58234
+ const spPr = resolvedShape["p:spPr"];
58193
58235
  const xfrm = spPr?.["a:xfrm"];
58194
58236
  const off = xfrm?.["a:off"];
58195
58237
  const ext = xfrm?.["a:ext"];
@@ -58197,7 +58239,7 @@ var PptxHandlerRuntime21 = class extends PptxHandlerRuntime20 {
58197
58239
  const yEmu = off ? Number(off["@_y"] || 0) : 0;
58198
58240
  const cxEmu = ext ? Number(ext["@_cx"] || 0) : 0;
58199
58241
  const cyEmu = ext ? Number(ext["@_cy"] || 0) : 0;
58200
- result.push({ phInfo, xEmu, yEmu, cxEmu, cyEmu, shapeXml: shape });
58242
+ result.push({ phInfo, xEmu, yEmu, cxEmu, cyEmu, shapeXml: resolvedShape });
58201
58243
  }
58202
58244
  return result;
58203
58245
  }
@@ -58268,16 +58310,31 @@ var PptxHandlerRuntime21 = class extends PptxHandlerRuntime20 {
58268
58310
  * @returns The updated elements array.
58269
58311
  */
58270
58312
  remapElementsToNewLayout(elements2, newLayoutXml, newLayoutPath) {
58271
- const layoutPlaceholders = this.extractLayoutPlaceholders(newLayoutXml);
58313
+ const layoutPlaceholders = this.extractLayoutPlaceholders(newLayoutXml, newLayoutPath);
58272
58314
  const targetPlaceholders = [];
58273
58315
  for (const lp of layoutPlaceholders) {
58274
58316
  targetPlaceholders.push({ ...lp, matched: false });
58275
58317
  }
58276
58318
  const resultElements = [];
58277
58319
  for (const element of elements2) {
58278
- const phInfo = this.getElementPlaceholderInfo(element);
58320
+ const metadata = element;
58321
+ if (metadata._layoutSwitchGenerated) continue;
58322
+ const original = metadata._layoutSwitchOriginal ?? element;
58323
+ const originalPhInfo = this.getElementPlaceholderInfo(original);
58324
+ const baseElement = {
58325
+ // Keep all current content and styling edits. Only placeholder geometry
58326
+ // and identity come from the canonical pre-switch element.
58327
+ ...element,
58328
+ ...originalPhInfo ? { x: original.x, y: original.y, width: original.width, height: original.height } : {},
58329
+ rawXml: element.rawXml ? cloneXmlObject(element.rawXml) : element.rawXml
58330
+ };
58331
+ baseElement._layoutSwitchOriginal = metadata._layoutSwitchOriginal ?? {
58332
+ ...element,
58333
+ rawXml: element.rawXml ? cloneXmlObject(element.rawXml) : element.rawXml
58334
+ };
58335
+ const phInfo = originalPhInfo ?? this.getElementPlaceholderInfo(baseElement);
58279
58336
  if (!phInfo) {
58280
- resultElements.push(element);
58337
+ resultElements.push(baseElement);
58281
58338
  continue;
58282
58339
  }
58283
58340
  let resolvedLayoutPh;
@@ -58293,8 +58350,8 @@ var PptxHandlerRuntime21 = class extends PptxHandlerRuntime20 {
58293
58350
  if (resolvedLayoutPh) {
58294
58351
  resolvedLayoutPh.matched = true;
58295
58352
  const updatedElement = {
58296
- ...element,
58297
- rawXml: element.rawXml ? cloneXmlObject(element.rawXml) : element.rawXml
58353
+ ...baseElement,
58354
+ rawXml: baseElement.rawXml ? cloneXmlObject(baseElement.rawXml) : baseElement.rawXml
58298
58355
  };
58299
58356
  if (resolvedLayoutPh.cxEmu > 0 && resolvedLayoutPh.cyEmu > 0) {
58300
58357
  updatedElement.x = Math.round(resolvedLayoutPh.xEmu / EMU_PER_PX);
@@ -58316,7 +58373,7 @@ var PptxHandlerRuntime21 = class extends PptxHandlerRuntime20 {
58316
58373
  }
58317
58374
  resultElements.push(updatedElement);
58318
58375
  } else {
58319
- resultElements.push(element);
58376
+ resultElements.push(baseElement);
58320
58377
  }
58321
58378
  }
58322
58379
  for (const lp of targetPlaceholders) {
@@ -58442,6 +58499,7 @@ var PptxHandlerRuntime21 = class extends PptxHandlerRuntime20 {
58442
58499
  text: "",
58443
58500
  rawXml
58444
58501
  };
58502
+ element._layoutSwitchGenerated = true;
58445
58503
  return element;
58446
58504
  }
58447
58505
  };
@@ -67358,6 +67416,10 @@ var PptxHandlerRuntime52 = class _PptxHandlerRuntime19 extends PptxHandlerRuntim
67358
67416
  if (sourceIdx !== targetIdx) {
67359
67417
  return false;
67360
67418
  }
67419
+ const specialTypes = /* @__PURE__ */ new Set(["dt", "ftr", "hdr", "sldnum"]);
67420
+ if (source.type === void 0 && target.type !== void 0 && specialTypes.has(target.type) || target.type === void 0 && source.type !== void 0 && specialTypes.has(source.type)) {
67421
+ return false;
67422
+ }
67361
67423
  if (source.type && target.type && !typesMatch) {
67362
67424
  return false;
67363
67425
  }
@@ -69121,19 +69183,15 @@ var PptxHandlerRuntime62 = class _PptxHandlerRuntime26 extends PptxHandlerRuntim
69121
69183
  if (paragraphRtl !== void 0 && textStyle.rtl === void 0) {
69122
69184
  textStyle.rtl = paragraphRtl;
69123
69185
  }
69124
- let paraAlign = paragraphRtl ? "right" : "left";
69186
+ const level = pPr?.["@_lvl"] === void 0 ? -1 : Number.parseInt(String(pPr["@_lvl"]), 10);
69187
+ const normalizedLevel = level === -1 ? -1 : Number.isFinite(level) ? Math.min(Math.max(level, 0), 8) : 0;
69188
+ const placeholderLevelStyle = ctx.effectiveLevelStyles ? ctx.effectiveLevelStyles[normalizedLevel] ?? ctx.effectiveLevelStyles[-1] ?? (normalizedLevel === -1 ? ctx.effectiveLevelStyles[0] : void 0) : void 0;
69189
+ const paraAlign = resolveParagraphAlignment(
69190
+ pPr?.["@_algn"],
69191
+ placeholderLevelStyle?.alignment,
69192
+ paragraphRtl
69193
+ );
69125
69194
  if (pPr?.["@_algn"]) {
69126
- const alignMap = {
69127
- l: "left",
69128
- ctr: "center",
69129
- r: "right",
69130
- just: "justify",
69131
- justify: "justify",
69132
- justLow: "justLow",
69133
- dist: "dist",
69134
- thaiDist: "thaiDist"
69135
- };
69136
- paraAlign = alignMap[pPr["@_algn"]] || "left";
69137
69195
  if (!textStyle.align) {
69138
69196
  textStyle.align = paraAlign;
69139
69197
  }
@@ -69240,7 +69298,6 @@ var PptxHandlerRuntime62 = class _PptxHandlerRuntime26 extends PptxHandlerRuntim
69240
69298
  ctx.slideRelationshipMap,
69241
69299
  false
69242
69300
  );
69243
- const level = pPr?.["@_lvl"] === void 0 ? -1 : Number.parseInt(String(pPr["@_lvl"]), 10);
69244
69301
  const levelKey = level === -1 ? "a:defPPr" : `a:lvl${Number.isFinite(level) ? Math.min(Math.max(level + 1, 1), 9) : 1}pPr`;
69245
69302
  const inheritedLevelStyle = this.extractTextRunStyle(
69246
69303
  ctx.inheritedTxBody?.["a:lstStyle"]?.[levelKey]?.["a:defRPr"],
@@ -69267,31 +69324,20 @@ var PptxHandlerRuntime62 = class _PptxHandlerRuntime26 extends PptxHandlerRuntim
69267
69324
  ...endParagraphStyle,
69268
69325
  ...defaultRunStyle
69269
69326
  };
69270
- if (ctx.effectiveLevelStyles) {
69271
- const normalizedLevel = level === -1 ? -1 : Number.isFinite(level) ? Math.min(Math.max(level, 0), 8) : 0;
69272
- const phLevel = ctx.effectiveLevelStyles[normalizedLevel] ?? ctx.effectiveLevelStyles[-1] ?? (normalizedLevel === -1 ? ctx.effectiveLevelStyles[0] : void 0);
69273
- if (phLevel) {
69274
- this.applyPlaceholderLevelDefaults(mergedDefaultRunStyle, phLevel);
69275
- this.applyPlaceholderLevelDefaults(textStyle, phLevel);
69276
- }
69277
- }
69278
- if (pPr?.["@_algn"] === void 0 && textStyle.align !== void 0) {
69279
- paraAlign = textStyle.align;
69327
+ if (placeholderLevelStyle) {
69328
+ this.applyPlaceholderLevelDefaults(mergedDefaultRunStyle, placeholderLevelStyle);
69329
+ this.applyPlaceholderLevelDefaults(textStyle, placeholderLevelStyle);
69280
69330
  }
69281
69331
  const parMarginLeft = pPr?.["@_marL"] !== void 0 ? Number.parseInt(String(pPr["@_marL"]), 10) / _PptxHandlerRuntime26.EMU_PER_PX : void 0;
69282
69332
  const parIndent = pPr?.["@_indent"] !== void 0 ? Number.parseInt(String(pPr["@_indent"]), 10) / _PptxHandlerRuntime26.EMU_PER_PX : void 0;
69283
69333
  let effectiveMarginLeft = parMarginLeft;
69284
69334
  let effectiveIndent = parIndent;
69285
- if (ctx.effectiveLevelStyles) {
69286
- const normalizedLevel = level === -1 ? -1 : Number.isFinite(level) ? Math.min(Math.max(level, 0), 8) : 0;
69287
- const phLevel = ctx.effectiveLevelStyles[normalizedLevel] ?? ctx.effectiveLevelStyles[-1] ?? (normalizedLevel === -1 ? ctx.effectiveLevelStyles[0] : void 0);
69288
- if (phLevel) {
69289
- if (effectiveMarginLeft === void 0 && phLevel.marginLeft !== void 0) {
69290
- effectiveMarginLeft = phLevel.marginLeft;
69291
- }
69292
- if (effectiveIndent === void 0 && phLevel.indent !== void 0) {
69293
- effectiveIndent = phLevel.indent;
69294
- }
69335
+ if (placeholderLevelStyle) {
69336
+ if (effectiveMarginLeft === void 0 && placeholderLevelStyle.marginLeft !== void 0) {
69337
+ effectiveMarginLeft = placeholderLevelStyle.marginLeft;
69338
+ }
69339
+ if (effectiveIndent === void 0 && placeholderLevelStyle.indent !== void 0) {
69340
+ effectiveIndent = placeholderLevelStyle.indent;
69295
69341
  }
69296
69342
  }
69297
69343
  return {
@@ -69484,72 +69530,49 @@ var PptxHandlerRuntime63 = class extends PptxHandlerRuntime62 {
69484
69530
  "mc:AlternateContent",
69485
69531
  "a:br"
69486
69532
  ]);
69487
- const paragraphRuns = this.ensureArray(p["a:r"]);
69488
- const paragraphBreaks = this.ensureArray(p["a:br"]);
69489
- const hasCollapsedRunBreakOrder = paragraphRuns.length > 1 && paragraphBreaks.length > 0;
69490
- for (const key of Object.keys(p)) {
69533
+ for (const [key, item] of orderedSmartArtTextEntries(p)) {
69491
69534
  if (!contentTagSet.has(key)) {
69492
69535
  continue;
69493
69536
  }
69494
- const items = this.ensureArray(p[key]);
69495
- const breakCount = paragraphBreaks.length;
69496
- const insertCollapsedBreaks = key === "a:r" && hasCollapsedRunBreakOrder;
69497
- for (const [itemIndex, item] of items.entries()) {
69498
- switch (key) {
69499
- case "a:r": {
69500
- processRun(item);
69501
- if (insertCollapsedBreaks && itemIndex < items.length - 1) {
69502
- const gapCount = items.length - 1;
69503
- const breaksHere = Math.floor(breakCount / gapCount) + (itemIndex < breakCount % gapCount ? 1 : 0);
69504
- for (let breakIndex = 0; breakIndex < breaksHere; breakIndex++) {
69505
- parts.push("\n");
69506
- segments.push({
69507
- text: "\n",
69508
- style: { ...mergedDefaultRunStyle },
69509
- isLineBreak: true
69510
- });
69511
- }
69512
- }
69513
- break;
69514
- }
69515
- case "a:fld":
69516
- processField(item);
69517
- break;
69518
- case "a:t": {
69519
- const directText2 = typeof item === "string" ? item : item !== void 0 ? String(item) : "";
69520
- appendRun(directText2, p["a:rPr"]);
69521
- break;
69522
- }
69523
- case "a14:m":
69524
- case "m:oMathPara":
69525
- case "m:oMath":
69526
- processMathElement(item);
69527
- break;
69528
- case "mc:AlternateContent":
69529
- processAlternateContent(item);
69530
- break;
69531
- case "a:br": {
69532
- if (hasCollapsedRunBreakOrder) {
69533
- break;
69534
- }
69535
- const brNode = item ?? {};
69536
- const brRunProps = brNode["a:rPr"];
69537
- const brStyle = {
69538
- ...mergedDefaultRunStyle,
69539
- ...this.extractTextRunStyle(brRunProps, paraAlign, ctx.slideRelationshipMap)
69540
- };
69541
- parts.push("\n");
69542
- const brSegment = {
69543
- text: "\n",
69544
- style: brStyle,
69545
- isLineBreak: true
69546
- };
69547
- if (brRunProps && typeof brRunProps === "object") {
69548
- brSegment.breakRunProperties = { ...brRunProps };
69549
- }
69550
- segments.push(brSegment);
69551
- break;
69537
+ switch (key) {
69538
+ case "a:r": {
69539
+ processRun(item);
69540
+ break;
69541
+ }
69542
+ case "a:fld":
69543
+ processField(item);
69544
+ break;
69545
+ case "a:t": {
69546
+ const directText2 = typeof item === "string" ? item : item !== void 0 ? String(item) : "";
69547
+ appendRun(directText2, p["a:rPr"]);
69548
+ break;
69549
+ }
69550
+ case "a14:m":
69551
+ case "m:oMathPara":
69552
+ case "m:oMath":
69553
+ processMathElement(item);
69554
+ break;
69555
+ case "mc:AlternateContent":
69556
+ processAlternateContent(item);
69557
+ break;
69558
+ case "a:br": {
69559
+ const brNode = item ?? {};
69560
+ const brRunProps = brNode["a:rPr"];
69561
+ const brStyle = {
69562
+ ...mergedDefaultRunStyle,
69563
+ ...this.extractTextRunStyle(brRunProps, paraAlign, ctx.slideRelationshipMap)
69564
+ };
69565
+ parts.push("\n");
69566
+ const brSegment = {
69567
+ text: "\n",
69568
+ style: brStyle,
69569
+ isLineBreak: true
69570
+ };
69571
+ if (brRunProps && typeof brRunProps === "object") {
69572
+ brSegment.breakRunProperties = { ...brRunProps };
69552
69573
  }
69574
+ segments.push(brSegment);
69575
+ break;
69553
69576
  }
69554
69577
  }
69555
69578
  }