(root: SafeXmlNode)
| 61 | * Parse a theme XML root (`a:theme`) into ThemeData. |
| 62 | */ |
| 63 | export function parseTheme(root: SafeXmlNode): ThemeData { |
| 64 | const themeElements = root.child('themeElements') |
| 65 | |
| 66 | // --- Color scheme --- |
| 67 | const clrScheme = themeElements.child('clrScheme') |
| 68 | const colorScheme = new Map<string, string>() |
| 69 | |
| 70 | for (const slot of COLOR_SLOTS) { |
| 71 | const slotNode = clrScheme.child(slot) |
| 72 | if (slotNode.exists()) { |
| 73 | const hex = extractColor(slotNode) |
| 74 | if (hex !== undefined) { |
| 75 | colorScheme.set(slot, hex) |
| 76 | } |
| 77 | } |
| 78 | } |
| 79 | |
| 80 | // --- Font scheme --- |
| 81 | const fontScheme = themeElements.child('fontScheme') |
| 82 | const majorFont = parseFontInfo(fontScheme.child('majorFont')) |
| 83 | const minorFont = parseFontInfo(fontScheme.child('minorFont')) |
| 84 | |
| 85 | // --- Format scheme --- |
| 86 | const fmtScheme = themeElements.child('fmtScheme') |
| 87 | const fillStyleLst = fmtScheme.child('fillStyleLst') |
| 88 | const fillStyles: SafeXmlNode[] = fillStyleLst.allChildren() |
| 89 | const lnStyleLst = fmtScheme.child('lnStyleLst') |
| 90 | const lineStyles: SafeXmlNode[] = lnStyleLst.allChildren() |
| 91 | const effectStyleLst = fmtScheme.child('effectStyleLst') |
| 92 | const effectStyles: SafeXmlNode[] = effectStyleLst.allChildren() |
| 93 | |
| 94 | return { colorScheme, majorFont, minorFont, fillStyles, lineStyles, effectStyles } |
| 95 | } |
no test coverage detected