* True when an sp is a visible "box" — has an explicit fill or a visible border * (either directly in spPr or via a non-zero p:style fillRef/lnRef). Such a box * whose only label is an inline formula (e.g. slide 26 的彩色 x / W₁ / σ 方框, * 标签是 a14:m 公式而非文本 run) must be parsed as a SHAPE so its背景色/边框得
(sp: SafeXmlNode)
| 338 | * 无边框)仍走 parseMathNode 以获得正确的块级排版与缩放。 |
| 339 | */ |
| 340 | function spHasVisibleFillOrLine(sp: SafeXmlNode): boolean { |
| 341 | const spPr = sp.child('spPr'); |
| 342 | const spPrHasNoFill = spPr.exists() && spPr.child('noFill').exists(); |
| 343 | if (spPr.exists()) { |
| 344 | for (const tag of ['solidFill', 'gradFill', 'blipFill', 'pattFill']) { |
| 345 | if (spPr.child(tag).exists()) return true; |
| 346 | } |
| 347 | const ln = spPr.child('ln'); |
| 348 | if (ln.exists() && !ln.child('noFill').exists()) { |
| 349 | for (const tag of ['solidFill', 'gradFill', 'pattFill']) { |
| 350 | if (ln.child(tag).exists()) return true; |
| 351 | } |
| 352 | } |
| 353 | } |
| 354 | const style = sp.child('style'); |
| 355 | if (style.exists()) { |
| 356 | if (!spPrHasNoFill) { |
| 357 | const fillRef = style.child('fillRef'); |
| 358 | if (fillRef.exists() && (fillRef.attr('idx') ?? '0') !== '0') return true; |
| 359 | } |
| 360 | const lnRef = style.child('lnRef'); |
| 361 | if (lnRef.exists() && (lnRef.attr('idx') ?? '0') !== '0') return true; |
| 362 | } |
| 363 | return false; |
| 364 | } |
| 365 | |
| 366 | /** |
| 367 | * Parse a single child node from spTree, dispatching to the appropriate parser. |
no test coverage detected