* Apply fill from a table style tcStyle node. * Structure: ... or ...
(td: HTMLElement, tcStyle: SafeXmlNode, ctx: RenderContext)
| 221 | * Structure: <a:tcStyle> <a:fill> <a:solidFill>... or <a:fillRef>... |
| 222 | */ |
| 223 | function applyStyleFill(td: HTMLElement, tcStyle: SafeXmlNode, ctx: RenderContext): boolean { |
| 224 | const fill = tcStyle.child('fill') |
| 225 | if (!fill.exists()) return false |
| 226 | |
| 227 | // solidFill |
| 228 | const solidFill = fill.child('solidFill') |
| 229 | if (solidFill.exists()) { |
| 230 | const { color, alpha } = resolveColor(solidFill, ctx) |
| 231 | const hex = color.startsWith('#') ? color : `#${color}` |
| 232 | if (alpha < 1) { |
| 233 | const { r, g, b } = hexToRgb(hex) |
| 234 | td.style.backgroundColor = `rgba(${r},${g},${b},${alpha.toFixed(3)})` |
| 235 | } else { |
| 236 | td.style.backgroundColor = hex |
| 237 | } |
| 238 | return true |
| 239 | } |
| 240 | |
| 241 | // fillRef (theme fill reference) |
| 242 | const fillRef = fill.child('fillRef') |
| 243 | if (fillRef.exists()) { |
| 244 | // fillRef contains a color child + idx attribute |
| 245 | const { color, alpha } = resolveColor(fillRef, ctx) |
| 246 | const hex = color.startsWith('#') ? color : `#${color}` |
| 247 | if (alpha < 1) { |
| 248 | const { r, g, b } = hexToRgb(hex) |
| 249 | td.style.backgroundColor = `rgba(${r},${g},${b},${alpha.toFixed(3)})` |
| 250 | } else { |
| 251 | td.style.backgroundColor = hex |
| 252 | } |
| 253 | return true |
| 254 | } |
| 255 | |
| 256 | // noFill |
| 257 | const noFill = fill.child('noFill') |
| 258 | if (noFill.exists()) return true // explicitly no fill |
| 259 | |
| 260 | return false |
| 261 | } |
| 262 | |
| 263 | /** |
| 264 | * Apply borders from a table style tcStyle node. |
no test coverage detected