UNPKG

@difftim/excelize

Version:

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

98 lines (86 loc) 2.33 kB
const BaseXform = require('../base-xform'); const CChartXform = require('./c-chart-xform'); // const Date1904Xform = require('./date1904-xform'); // const CLangXform = require('./c-lang-xform'); class ChartXform extends BaseXform { constructor() { super(); this.map = { 'c:chart': new CChartXform(), // 'c:date1904': new Date1904Xform(), // 'c:lang': new CLangXform(), // 'c:roundedCorners': new CChartXform(), // 'mc:AlternateContent': new CChartXform(), // 'c:spPr': new CChartXform(), }; } prepare(model) { // model.anchors.forEach((item, index) => { // item.anchorType = getAnchorType(item); // const anchor = this.map[item.anchorType]; // anchor.prepare(item, {index}); // }); } get tag() { return 'c:chartSpace'; } // prepare(model, options) { // model.index = options.index + 1; // } render(xmlStream, model) { xmlStream.openNode(this.tag); this.map['c:chart'].render(xmlStream, model); // this.map['c:date1904'].render(xmlStream, model); // this.map['c:lang'].render(xmlStream, model); // this.map['c:roundedCorners'].render(xmlStream, model); // this.map['c:spPr'].render(xmlStream, model); // this.map['mc:AlternateContent'].render(xmlStream, model); xmlStream.closeNode(); } parseText(text) { if (this.parser) { this.parser.parseText(text); } } parseOpen(node) { if (this.parser) { this.parser.parseOpen(node); return true; } switch (node.name) { case this.tag: this.reset(); this.model = []; break; default: // 当前的标签 this.parser = this.map[node.name]; if (this.parser) { this.parser.parseOpen(node); } break; } return true; } parseClose(name) { if (this.parser) { if (!this.parser.parseClose(name)) { this.parser = undefined; } return true; } switch (name) { case this.tag: this.model = this.map['c:chart'].model; return false; default: return true; } } // reconcile(model, options) { // model.anchors.forEach(anchor => { // this.map['c:chart'].reconcile(anchor, options); // }); // } } module.exports = ChartXform;