* 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)
| 50 | * Returns the pic node if it has blipFill with embed (so we can render the preview image). |
| 51 | */ |
| 52 | function 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). |
no test coverage detected