(spNode: SafeXmlNode)
| 116 | * Returns everything except `nodeType`, which the caller must set. |
| 117 | */ |
| 118 | export function parseBaseProps(spNode: SafeXmlNode): Omit<BaseNodeData, 'nodeType'> { |
| 119 | const { cNvPr, nvPr } = findNvProps(spNode) |
| 120 | |
| 121 | const id = cNvPr.attr('id') ?? '' |
| 122 | const name = cNvPr.attr('name') ?? '' |
| 123 | |
| 124 | // --- Transform --- |
| 125 | const xfrm = findXfrm(spNode) |
| 126 | const off = xfrm.child('off') |
| 127 | const ext = xfrm.child('ext') |
| 128 | |
| 129 | const position: Position = { |
| 130 | x: emuToPx(off.numAttr('x') ?? 0), |
| 131 | y: emuToPx(off.numAttr('y') ?? 0), |
| 132 | } |
| 133 | |
| 134 | const size: Size = { |
| 135 | w: emuToPx(ext.numAttr('cx') ?? 0), |
| 136 | h: emuToPx(ext.numAttr('cy') ?? 0), |
| 137 | } |
| 138 | |
| 139 | const rotation = angleToDeg(xfrm.numAttr('rot') ?? 0) |
| 140 | const flipH = xfrm.attr('flipH') === '1' || xfrm.attr('flipH') === 'true' |
| 141 | const flipV = xfrm.attr('flipV') === '1' || xfrm.attr('flipV') === 'true' |
| 142 | |
| 143 | // --- Placeholder --- |
| 144 | const placeholder = parsePlaceholder(nvPr) |
| 145 | |
| 146 | // --- Shape-level hyperlink action (cNvPr > a:hlinkClick) --- |
| 147 | let hlinkClick: HlinkAction | undefined |
| 148 | const hlinkNode = cNvPr.child('hlinkClick') |
| 149 | if (hlinkNode.exists()) { |
| 150 | hlinkClick = { |
| 151 | action: hlinkNode.attr('action') ?? undefined, |
| 152 | rId: hlinkNode.attr('id') ?? hlinkNode.attr('r:id') ?? undefined, |
| 153 | tooltip: hlinkNode.attr('tooltip') ?? undefined, |
| 154 | } |
| 155 | } |
| 156 | |
| 157 | return { |
| 158 | id, |
| 159 | name, |
| 160 | position, |
| 161 | size, |
| 162 | rotation, |
| 163 | flipH, |
| 164 | flipV, |
| 165 | placeholder, |
| 166 | hlinkClick, |
| 167 | source: spNode, |
| 168 | } |
| 169 | } |
no test coverage detected