@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.
@@ -10184,6 +10184,9 @@ function drawingChild(node, requestedName) {
10184
10184
  continue;
10185
10185
  }
10186
10186
  const child20 = Array.isArray(value) ? value[0] : value;
10187
+ if (child20 === "" || child20 === null || child20 === void 0) {
10188
+ return {};
10189
+ }
10187
10190
  if (child20 && typeof child20 === "object" && !Array.isArray(child20)) {
10188
10191
  return child20;
10189
10192
  }
@@ -12561,6 +12564,13 @@ var PptxShapeStyleExtractor = class {
12561
12564
  if (earlyReturn) {
12562
12565
  return style;
12563
12566
  }
12567
+ if (!style.strokeColor && styleNode?.["a:lnRef"]) {
12568
+ const explicitWidth = style.strokeWidth;
12569
+ this.context.resolveThemeLineRef(styleNode["a:lnRef"], style);
12570
+ if (explicitWidth !== void 0) {
12571
+ style.strokeWidth = explicitWidth;
12572
+ }
12573
+ }
12564
12574
  } else if (styleNode?.["a:lnRef"]) {
12565
12575
  this.context.resolveThemeLineRef(styleNode["a:lnRef"], style);
12566
12576
  }
@@ -13543,6 +13553,20 @@ function ensureArrayLike(value) {
13543
13553
  }
13544
13554
  return Array.isArray(value) ? value : [value];
13545
13555
  }
13556
+ function readPositiveInteger(value) {
13557
+ const parsed = Number.parseInt(String(value ?? ""), 10);
13558
+ return Number.isFinite(parsed) && parsed > 0 ? parsed : 0;
13559
+ }
13560
+ function getTableGridExtent(graphicData) {
13561
+ const table = graphicData?.["a:tbl"];
13562
+ if (!table) {
13563
+ return void 0;
13564
+ }
13565
+ const grid = table["a:tblGrid"];
13566
+ const widthEmu = ensureArrayLike(grid?.["a:gridCol"]).reduce((sum, column) => sum + readPositiveInteger(column?.["@_w"]), 0);
13567
+ const heightEmu = ensureArrayLike(table["a:tr"]).reduce((sum, row) => sum + readPositiveInteger(row?.["@_h"]), 0);
13568
+ return widthEmu > 0 && heightEmu > 0 ? { widthEmu, heightEmu } : void 0;
13569
+ }
13546
13570
  function collectGraphicFrameExtensions(graphicData) {
13547
13571
  if (!graphicData) {
13548
13572
  return [];
@@ -13758,8 +13782,13 @@ var PptxGraphicFrameParser = class {
13758
13782
  const extensionXml = collectGraphicFrameExtensions(graphicData);
13759
13783
  if (type === "table" && graphicData) {
13760
13784
  const tableData = this.context.parseTableData(graphicData);
13785
+ const tableGridExtent = getTableGridExtent(graphicData);
13761
13786
  return {
13762
13787
  ...baseElement,
13788
+ ...tableGridExtent ? {
13789
+ width: Math.round(tableGridExtent.widthEmu / this.context.emuPerPx),
13790
+ height: Math.round(tableGridExtent.heightEmu / this.context.emuPerPx)
13791
+ } : {},
13763
13792
  tableData,
13764
13793
  ...extensionXml.length > 0 ? { extensionXml } : {}
13765
13794
  };
@@ -36840,6 +36869,12 @@ function parseAlignmentAttr2(algn) {
36840
36869
  }
36841
36870
  return ALIGN_MAP[algn] || void 0;
36842
36871
  }
36872
+ function resolveParagraphAlignment(authoredAlignment, placeholderAlignment, paragraphRtl) {
36873
+ if (authoredAlignment !== void 0 && authoredAlignment !== null) {
36874
+ return parseAlignmentAttr2(String(authoredAlignment)) ?? "left";
36875
+ }
36876
+ return placeholderAlignment ?? (paragraphRtl ? "right" : "left");
36877
+ }
36843
36878
  function parseParagraphSpacingPx(spacingNode) {
36844
36879
  if (!spacingNode) {
36845
36880
  return void 0;
@@ -58166,7 +58201,7 @@ var PptxHandlerRuntime21 = class extends PptxHandlerRuntime20 {
58166
58201
  * Extract all placeholders from a layout's `p:spTree`, returning
58167
58202
  * their placeholder info and their transform (position/size in EMU).
58168
58203
  */
58169
- extractLayoutPlaceholders(layoutXml) {
58204
+ extractLayoutPlaceholders(layoutXml, layoutPath) {
58170
58205
  const spTree = xmlPath(layoutXml, "p:sldLayout", "p:cSld", "p:spTree");
58171
58206
  if (!spTree) {
58172
58207
  return [];
@@ -58183,7 +58218,14 @@ var PptxHandlerRuntime21 = class extends PptxHandlerRuntime20 {
58183
58218
  if (!phInfo) {
58184
58219
  continue;
58185
58220
  }
58186
- const spPr = shape["p:spPr"];
58221
+ const masterPath = layoutPath ? this.resolveMasterPathForLayout(layoutPath) : void 0;
58222
+ const masterContext = masterPath ? this.findPlaceholderInShapeTree(
58223
+ xmlPath(this.masterXmlMap.get(masterPath), "p:sldMaster", "p:cSld", "p:spTree"),
58224
+ phInfo
58225
+ ) : void 0;
58226
+ const inheritedShape = masterContext?.shape ?? masterContext?.picture;
58227
+ const resolvedShape = inheritedShape ? this.mergeXmlObjects(inheritedShape, shape) ?? shape : shape;
58228
+ const spPr = resolvedShape["p:spPr"];
58187
58229
  const xfrm = spPr?.["a:xfrm"];
58188
58230
  const off = xfrm?.["a:off"];
58189
58231
  const ext = xfrm?.["a:ext"];
@@ -58191,7 +58233,7 @@ var PptxHandlerRuntime21 = class extends PptxHandlerRuntime20 {
58191
58233
  const yEmu = off ? Number(off["@_y"] || 0) : 0;
58192
58234
  const cxEmu = ext ? Number(ext["@_cx"] || 0) : 0;
58193
58235
  const cyEmu = ext ? Number(ext["@_cy"] || 0) : 0;
58194
- result.push({ phInfo, xEmu, yEmu, cxEmu, cyEmu, shapeXml: shape });
58236
+ result.push({ phInfo, xEmu, yEmu, cxEmu, cyEmu, shapeXml: resolvedShape });
58195
58237
  }
58196
58238
  return result;
58197
58239
  }
@@ -58262,16 +58304,31 @@ var PptxHandlerRuntime21 = class extends PptxHandlerRuntime20 {
58262
58304
  * @returns The updated elements array.
58263
58305
  */
58264
58306
  remapElementsToNewLayout(elements2, newLayoutXml, newLayoutPath) {
58265
- const layoutPlaceholders = this.extractLayoutPlaceholders(newLayoutXml);
58307
+ const layoutPlaceholders = this.extractLayoutPlaceholders(newLayoutXml, newLayoutPath);
58266
58308
  const targetPlaceholders = [];
58267
58309
  for (const lp of layoutPlaceholders) {
58268
58310
  targetPlaceholders.push({ ...lp, matched: false });
58269
58311
  }
58270
58312
  const resultElements = [];
58271
58313
  for (const element of elements2) {
58272
- const phInfo = this.getElementPlaceholderInfo(element);
58314
+ const metadata = element;
58315
+ if (metadata._layoutSwitchGenerated) continue;
58316
+ const original = metadata._layoutSwitchOriginal ?? element;
58317
+ const originalPhInfo = this.getElementPlaceholderInfo(original);
58318
+ const baseElement = {
58319
+ // Keep all current content and styling edits. Only placeholder geometry
58320
+ // and identity come from the canonical pre-switch element.
58321
+ ...element,
58322
+ ...originalPhInfo ? { x: original.x, y: original.y, width: original.width, height: original.height } : {},
58323
+ rawXml: element.rawXml ? cloneXmlObject(element.rawXml) : element.rawXml
58324
+ };
58325
+ baseElement._layoutSwitchOriginal = metadata._layoutSwitchOriginal ?? {
58326
+ ...element,
58327
+ rawXml: element.rawXml ? cloneXmlObject(element.rawXml) : element.rawXml
58328
+ };
58329
+ const phInfo = originalPhInfo ?? this.getElementPlaceholderInfo(baseElement);
58273
58330
  if (!phInfo) {
58274
- resultElements.push(element);
58331
+ resultElements.push(baseElement);
58275
58332
  continue;
58276
58333
  }
58277
58334
  let resolvedLayoutPh;
@@ -58287,8 +58344,8 @@ var PptxHandlerRuntime21 = class extends PptxHandlerRuntime20 {
58287
58344
  if (resolvedLayoutPh) {
58288
58345
  resolvedLayoutPh.matched = true;
58289
58346
  const updatedElement = {
58290
- ...element,
58291
- rawXml: element.rawXml ? cloneXmlObject(element.rawXml) : element.rawXml
58347
+ ...baseElement,
58348
+ rawXml: baseElement.rawXml ? cloneXmlObject(baseElement.rawXml) : baseElement.rawXml
58292
58349
  };
58293
58350
  if (resolvedLayoutPh.cxEmu > 0 && resolvedLayoutPh.cyEmu > 0) {
58294
58351
  updatedElement.x = Math.round(resolvedLayoutPh.xEmu / EMU_PER_PX);
@@ -58310,7 +58367,7 @@ var PptxHandlerRuntime21 = class extends PptxHandlerRuntime20 {
58310
58367
  }
58311
58368
  resultElements.push(updatedElement);
58312
58369
  } else {
58313
- resultElements.push(element);
58370
+ resultElements.push(baseElement);
58314
58371
  }
58315
58372
  }
58316
58373
  for (const lp of targetPlaceholders) {
@@ -58436,6 +58493,7 @@ var PptxHandlerRuntime21 = class extends PptxHandlerRuntime20 {
58436
58493
  text: "",
58437
58494
  rawXml
58438
58495
  };
58496
+ element._layoutSwitchGenerated = true;
58439
58497
  return element;
58440
58498
  }
58441
58499
  };
@@ -67352,6 +67410,10 @@ var PptxHandlerRuntime52 = class _PptxHandlerRuntime19 extends PptxHandlerRuntim
67352
67410
  if (sourceIdx !== targetIdx) {
67353
67411
  return false;
67354
67412
  }
67413
+ const specialTypes = /* @__PURE__ */ new Set(["dt", "ftr", "hdr", "sldnum"]);
67414
+ 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)) {
67415
+ return false;
67416
+ }
67355
67417
  if (source.type && target.type && !typesMatch) {
67356
67418
  return false;
67357
67419
  }
@@ -69115,19 +69177,15 @@ var PptxHandlerRuntime62 = class _PptxHandlerRuntime26 extends PptxHandlerRuntim
69115
69177
  if (paragraphRtl !== void 0 && textStyle.rtl === void 0) {
69116
69178
  textStyle.rtl = paragraphRtl;
69117
69179
  }
69118
- let paraAlign = paragraphRtl ? "right" : "left";
69180
+ const level = pPr?.["@_lvl"] === void 0 ? -1 : Number.parseInt(String(pPr["@_lvl"]), 10);
69181
+ const normalizedLevel = level === -1 ? -1 : Number.isFinite(level) ? Math.min(Math.max(level, 0), 8) : 0;
69182
+ const placeholderLevelStyle = ctx.effectiveLevelStyles ? ctx.effectiveLevelStyles[normalizedLevel] ?? ctx.effectiveLevelStyles[-1] ?? (normalizedLevel === -1 ? ctx.effectiveLevelStyles[0] : void 0) : void 0;
69183
+ const paraAlign = resolveParagraphAlignment(
69184
+ pPr?.["@_algn"],
69185
+ placeholderLevelStyle?.alignment,
69186
+ paragraphRtl
69187
+ );
69119
69188
  if (pPr?.["@_algn"]) {
69120
- const alignMap = {
69121
- l: "left",
69122
- ctr: "center",
69123
- r: "right",
69124
- just: "justify",
69125
- justify: "justify",
69126
- justLow: "justLow",
69127
- dist: "dist",
69128
- thaiDist: "thaiDist"
69129
- };
69130
- paraAlign = alignMap[pPr["@_algn"]] || "left";
69131
69189
  if (!textStyle.align) {
69132
69190
  textStyle.align = paraAlign;
69133
69191
  }
@@ -69234,7 +69292,6 @@ var PptxHandlerRuntime62 = class _PptxHandlerRuntime26 extends PptxHandlerRuntim
69234
69292
  ctx.slideRelationshipMap,
69235
69293
  false
69236
69294
  );
69237
- const level = pPr?.["@_lvl"] === void 0 ? -1 : Number.parseInt(String(pPr["@_lvl"]), 10);
69238
69295
  const levelKey = level === -1 ? "a:defPPr" : `a:lvl${Number.isFinite(level) ? Math.min(Math.max(level + 1, 1), 9) : 1}pPr`;
69239
69296
  const inheritedLevelStyle = this.extractTextRunStyle(
69240
69297
  ctx.inheritedTxBody?.["a:lstStyle"]?.[levelKey]?.["a:defRPr"],
@@ -69261,31 +69318,20 @@ var PptxHandlerRuntime62 = class _PptxHandlerRuntime26 extends PptxHandlerRuntim
69261
69318
  ...endParagraphStyle,
69262
69319
  ...defaultRunStyle
69263
69320
  };
69264
- if (ctx.effectiveLevelStyles) {
69265
- const normalizedLevel = level === -1 ? -1 : Number.isFinite(level) ? Math.min(Math.max(level, 0), 8) : 0;
69266
- const phLevel = ctx.effectiveLevelStyles[normalizedLevel] ?? ctx.effectiveLevelStyles[-1] ?? (normalizedLevel === -1 ? ctx.effectiveLevelStyles[0] : void 0);
69267
- if (phLevel) {
69268
- this.applyPlaceholderLevelDefaults(mergedDefaultRunStyle, phLevel);
69269
- this.applyPlaceholderLevelDefaults(textStyle, phLevel);
69270
- }
69271
- }
69272
- if (pPr?.["@_algn"] === void 0 && textStyle.align !== void 0) {
69273
- paraAlign = textStyle.align;
69321
+ if (placeholderLevelStyle) {
69322
+ this.applyPlaceholderLevelDefaults(mergedDefaultRunStyle, placeholderLevelStyle);
69323
+ this.applyPlaceholderLevelDefaults(textStyle, placeholderLevelStyle);
69274
69324
  }
69275
69325
  const parMarginLeft = pPr?.["@_marL"] !== void 0 ? Number.parseInt(String(pPr["@_marL"]), 10) / _PptxHandlerRuntime26.EMU_PER_PX : void 0;
69276
69326
  const parIndent = pPr?.["@_indent"] !== void 0 ? Number.parseInt(String(pPr["@_indent"]), 10) / _PptxHandlerRuntime26.EMU_PER_PX : void 0;
69277
69327
  let effectiveMarginLeft = parMarginLeft;
69278
69328
  let effectiveIndent = parIndent;
69279
- if (ctx.effectiveLevelStyles) {
69280
- const normalizedLevel = level === -1 ? -1 : Number.isFinite(level) ? Math.min(Math.max(level, 0), 8) : 0;
69281
- const phLevel = ctx.effectiveLevelStyles[normalizedLevel] ?? ctx.effectiveLevelStyles[-1] ?? (normalizedLevel === -1 ? ctx.effectiveLevelStyles[0] : void 0);
69282
- if (phLevel) {
69283
- if (effectiveMarginLeft === void 0 && phLevel.marginLeft !== void 0) {
69284
- effectiveMarginLeft = phLevel.marginLeft;
69285
- }
69286
- if (effectiveIndent === void 0 && phLevel.indent !== void 0) {
69287
- effectiveIndent = phLevel.indent;
69288
- }
69329
+ if (placeholderLevelStyle) {
69330
+ if (effectiveMarginLeft === void 0 && placeholderLevelStyle.marginLeft !== void 0) {
69331
+ effectiveMarginLeft = placeholderLevelStyle.marginLeft;
69332
+ }
69333
+ if (effectiveIndent === void 0 && placeholderLevelStyle.indent !== void 0) {
69334
+ effectiveIndent = placeholderLevelStyle.indent;
69289
69335
  }
69290
69336
  }
69291
69337
  return {
@@ -69478,72 +69524,49 @@ var PptxHandlerRuntime63 = class extends PptxHandlerRuntime62 {
69478
69524
  "mc:AlternateContent",
69479
69525
  "a:br"
69480
69526
  ]);
69481
- const paragraphRuns = this.ensureArray(p["a:r"]);
69482
- const paragraphBreaks = this.ensureArray(p["a:br"]);
69483
- const hasCollapsedRunBreakOrder = paragraphRuns.length > 1 && paragraphBreaks.length > 0;
69484
- for (const key of Object.keys(p)) {
69527
+ for (const [key, item] of orderedSmartArtTextEntries(p)) {
69485
69528
  if (!contentTagSet.has(key)) {
69486
69529
  continue;
69487
69530
  }
69488
- const items = this.ensureArray(p[key]);
69489
- const breakCount = paragraphBreaks.length;
69490
- const insertCollapsedBreaks = key === "a:r" && hasCollapsedRunBreakOrder;
69491
- for (const [itemIndex, item] of items.entries()) {
69492
- switch (key) {
69493
- case "a:r": {
69494
- processRun(item);
69495
- if (insertCollapsedBreaks && itemIndex < items.length - 1) {
69496
- const gapCount = items.length - 1;
69497
- const breaksHere = Math.floor(breakCount / gapCount) + (itemIndex < breakCount % gapCount ? 1 : 0);
69498
- for (let breakIndex = 0; breakIndex < breaksHere; breakIndex++) {
69499
- parts.push("\n");
69500
- segments.push({
69501
- text: "\n",
69502
- style: { ...mergedDefaultRunStyle },
69503
- isLineBreak: true
69504
- });
69505
- }
69506
- }
69507
- break;
69508
- }
69509
- case "a:fld":
69510
- processField(item);
69511
- break;
69512
- case "a:t": {
69513
- const directText2 = typeof item === "string" ? item : item !== void 0 ? String(item) : "";
69514
- appendRun(directText2, p["a:rPr"]);
69515
- break;
69516
- }
69517
- case "a14:m":
69518
- case "m:oMathPara":
69519
- case "m:oMath":
69520
- processMathElement(item);
69521
- break;
69522
- case "mc:AlternateContent":
69523
- processAlternateContent(item);
69524
- break;
69525
- case "a:br": {
69526
- if (hasCollapsedRunBreakOrder) {
69527
- break;
69528
- }
69529
- const brNode = item ?? {};
69530
- const brRunProps = brNode["a:rPr"];
69531
- const brStyle = {
69532
- ...mergedDefaultRunStyle,
69533
- ...this.extractTextRunStyle(brRunProps, paraAlign, ctx.slideRelationshipMap)
69534
- };
69535
- parts.push("\n");
69536
- const brSegment = {
69537
- text: "\n",
69538
- style: brStyle,
69539
- isLineBreak: true
69540
- };
69541
- if (brRunProps && typeof brRunProps === "object") {
69542
- brSegment.breakRunProperties = { ...brRunProps };
69543
- }
69544
- segments.push(brSegment);
69545
- break;
69531
+ switch (key) {
69532
+ case "a:r": {
69533
+ processRun(item);
69534
+ break;
69535
+ }
69536
+ case "a:fld":
69537
+ processField(item);
69538
+ break;
69539
+ case "a:t": {
69540
+ const directText2 = typeof item === "string" ? item : item !== void 0 ? String(item) : "";
69541
+ appendRun(directText2, p["a:rPr"]);
69542
+ break;
69543
+ }
69544
+ case "a14:m":
69545
+ case "m:oMathPara":
69546
+ case "m:oMath":
69547
+ processMathElement(item);
69548
+ break;
69549
+ case "mc:AlternateContent":
69550
+ processAlternateContent(item);
69551
+ break;
69552
+ case "a:br": {
69553
+ const brNode = item ?? {};
69554
+ const brRunProps = brNode["a:rPr"];
69555
+ const brStyle = {
69556
+ ...mergedDefaultRunStyle,
69557
+ ...this.extractTextRunStyle(brRunProps, paraAlign, ctx.slideRelationshipMap)
69558
+ };
69559
+ parts.push("\n");
69560
+ const brSegment = {
69561
+ text: "\n",
69562
+ style: brStyle,
69563
+ isLineBreak: true
69564
+ };
69565
+ if (brRunProps && typeof brRunProps === "object") {
69566
+ brSegment.breakRunProperties = { ...brRunProps };
69546
69567
  }
69568
+ segments.push(brSegment);
69569
+ break;
69547
69570
  }
69548
69571
  }
69549
69572
  }