UNPKG

@difftim/excelize

Version:

Excel Workbook Manager - Read and Write xlsx and csv Files.

57 lines (47 loc) 1.23 kB
const BaseXform = require('../base-xform'); class ThemeXform extends BaseXform { get tag() { return 'a:theme'; } render() { // 在这里实现XML数据的生成(如果需要) } parseOpen(node) { if (node.name === this.tag) { this.model = { colors: [], }; this.parsingState = { inTheme: true, inColorScheme: false, }; } if (this.parsingState.inTheme && node.name === 'a:clrScheme') { this.parsingState.inColorScheme = true; } if (this.parsingState.inColorScheme && node.name === 'a:srgbClr') { this.model.colors.push({ type: 'srgbClr', value: node.attributes.val, }); } if (this.parsingState.inColorScheme && node.name === 'a:sysClr') { this.model.colors.push({ type: 'sysClr', value: node.attributes.lastClr, }); } return true; } parseClose(name) { if (name === this.tag) { this.parsingState.inTheme = false; } else if (name === 'a:clrScheme') { this.parsingState.inColorScheme = false; } else if (this.parsingState.inColor) { this.parsingState.inColor = false; } return true; } } module.exports = ThemeXform;