MCPcopy Index your code
hub / github.com/simstudioai/sim / extractPlaceholdersRecursive

Function extractPlaceholdersRecursive

apps/sim/lib/pptx-renderer/model/layout.ts:89–146  ·  view source on GitHub ↗

* Recursively collect placeholders; when inside a group, compute position/size in slide space.

(
  spTree: SafeXmlNode,
  groupTransform: { offX: number; offY: number; scaleX: number; scaleY: number } | null
)

Source from the content-addressed store, hash-verified

87 * Recursively collect placeholders; when inside a group, compute position/size in slide space.
88 */
89function extractPlaceholdersRecursive(
90 spTree: SafeXmlNode,
91 groupTransform: { offX: number; offY: number; scaleX: number; scaleY: number } | null
92): PlaceholderEntry[] {
93 const out: PlaceholderEntry[] = []
94 for (const child of spTree.allChildren()) {
95 if (child.localName === 'grpSp') {
96 const gx = getGroupXfrmInEmu(child)
97 if (gx && gx.chExtCx > 0 && gx.chExtCy > 0) {
98 const scaleX = gx.cx / gx.chExtCx
99 const scaleY = gx.cy / gx.chExtCy
100 const baseOffX = gx.offX - gx.chOffX * scaleX
101 const baseOffY = gx.offY - gx.chOffY * scaleY
102 const nextTransform = groupTransform
103 ? {
104 offX: groupTransform.offX + baseOffX * groupTransform.scaleX,
105 offY: groupTransform.offY + baseOffY * groupTransform.scaleY,
106 scaleX: groupTransform.scaleX * scaleX,
107 scaleY: groupTransform.scaleY * scaleY,
108 }
109 : { offX: baseOffX, offY: baseOffY, scaleX, scaleY }
110 const nested = extractPlaceholdersRecursive(child, nextTransform)
111 out.push(...nested)
112 } else {
113 out.push(...extractPlaceholdersRecursive(child, groupTransform))
114 }
115 continue
116 }
117 if (!isPlaceholder(child)) continue
118 const sx = getShapeXfrmInEmu(child)
119 if (!sx) {
120 out.push({ node: child })
121 continue
122 }
123 if (groupTransform) {
124 const absOffX = groupTransform.offX + sx.offX * groupTransform.scaleX
125 const absOffY = groupTransform.offY + sx.offY * groupTransform.scaleY
126 const absCx = sx.cx * groupTransform.scaleX
127 const absCy = sx.cy * groupTransform.scaleY
128 out.push({
129 node: child,
130 absoluteXfrm: {
131 position: { x: emuToPx(absOffX), y: emuToPx(absOffY) },
132 size: { w: emuToPx(absCx), h: emuToPx(absCy) },
133 },
134 })
135 } else {
136 out.push({
137 node: child,
138 absoluteXfrm: {
139 position: { x: emuToPx(sx.offX), y: emuToPx(sx.offY) },
140 size: { w: emuToPx(sx.cx), h: emuToPx(sx.cy) },
141 },
142 })
143 }
144 }
145 return out
146}

Callers 1

parseLayoutFunction · 0.85

Calls 6

isPlaceholderFunction · 0.90
emuToPxFunction · 0.90
getGroupXfrmInEmuFunction · 0.85
getShapeXfrmInEmuFunction · 0.85
allChildrenMethod · 0.80
pushMethod · 0.45

Tested by

no test coverage detected