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

Function findOleFallbackPic

apps/sim/lib/pptx-renderer/model/slide.ts:52–72  ·  view source on GitHub ↗

* Find p:pic inside OLE graphicData (mc:AlternateContent > mc:Fallback or mc:Choice > p:oleObj > p:pic). * Returns the pic node if it has blipFill with embed (so we can render the preview image).

(graphicFrame: SafeXmlNode)

Source from the content-addressed store, hash-verified

50 * Returns the pic node if it has blipFill with embed (so we can render the preview image).
51 */
52function findOleFallbackPic(graphicFrame: SafeXmlNode): SafeXmlNode | null {
53 const graphic = graphicFrame.child('graphic')
54 const graphicData = graphic.child('graphicData')
55 const uri = graphicData.attr('uri') || ''
56 if (!uri.includes('ole')) return null
57
58 const altContent = graphicData.child('AlternateContent')
59 if (!altContent.exists()) return null
60
61 for (const branch of ['Fallback', 'Choice'] as const) {
62 const oleObj = altContent.child(branch).child('oleObj')
63 if (!oleObj.exists()) continue
64 const pic = oleObj.child('pic')
65 if (!pic.exists()) continue
66 const blipFill = pic.child('blipFill')
67 const blip = blipFill.child('blip')
68 const embed = blip.attr('embed') ?? blip.attr('r:embed')
69 if (embed) return pic
70 }
71 return null
72}
73
74/**
75 * Parse a graphicFrame that contains an OLE object with a fallback picture (preview image).

Callers 1

parseOleFrameAsPictureFunction · 0.85

Calls 3

childMethod · 0.80
attrMethod · 0.80
existsMethod · 0.80

Tested by

no test coverage detected