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

Function getGroupXfrmInEmu

apps/sim/lib/pptx-renderer/model/layout.ts:47–84  ·  view source on GitHub ↗
(grpSp: SafeXmlNode)

Source from the content-addressed store, hash-verified

45}
46
47function getGroupXfrmInEmu(grpSp: SafeXmlNode): {
48 offX: number
49 offY: number
50 cx: number
51 cy: number
52 chOffX: number
53 chOffY: number
54 chExtCx: number
55 chExtCy: number
56} | null {
57 const grpSpPr = grpSp.child('grpSpPr')
58 if (!grpSpPr.exists()) return null
59 const xfrm = grpSpPr.child('xfrm')
60 if (!xfrm.exists()) return null
61 const off = xfrm.child('off')
62 const ext = xfrm.child('ext')
63 const chOff = xfrm.child('chOff')
64 const chExt = xfrm.child('chExt')
65 const offX = off.numAttr('x') ?? 0
66 const offY = off.numAttr('y') ?? 0
67 const cx = ext.numAttr('cx') ?? 0
68 const cy = ext.numAttr('cy') ?? 0
69 // OOXML: when chOff/chExt omitted, child box equals group box (chOff=0,0 and chExt=ext)
70 const chOffX = chOff.exists() ? (chOff.numAttr('x') ?? 0) : 0
71 const chOffY = chOff.exists() ? (chOff.numAttr('y') ?? 0) : 0
72 const chExtCx = chExt.exists() ? (chExt.numAttr('cx') ?? cx) : cx
73 const chExtCy = chExt.exists() ? (chExt.numAttr('cy') ?? cy) : cy
74 return {
75 offX,
76 offY,
77 cx,
78 cy,
79 chOffX,
80 chOffY,
81 chExtCx: chExtCx > 0 ? chExtCx : 1,
82 chExtCy: chExtCy > 0 ? chExtCy : 1,
83 }
84}
85
86/**
87 * Recursively collect placeholders; when inside a group, compute position/size in slide space.

Callers 1

Calls 3

childMethod · 0.80
existsMethod · 0.80
numAttrMethod · 0.80

Tested by

no test coverage detected