UNPKG

@difftim/excelize

Version:

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

79 lines (66 loc) 1.7 kB
const BaseXform = require('../base-xform'); const StaticXform = require('../static-xform'); const AGraphXform = require('./a-graph-xform'); const NvGraphicFramePr = require('./nv-graph-xform'); // const NvPicPrXform = require('./nv-pic-pr-xform'); const xfrmJSON = require('./xfrm'); class ChartXform extends BaseXform { constructor() { super(); // todo 这里需要调整 this.map = { 'a:graphic': new AGraphXform(), 'xdr:nvGraphicFramePr': new NvGraphicFramePr(), 'xdr:xfrm': new StaticXform(xfrmJSON), }; } get tag() { return 'xdr:graphicFrame'; } prepare(model, options) { model.index = options.index + 1; } render(xmlStream, model) { xmlStream.openNode(this.tag); this.map['a:graphic'].render(xmlStream, model); this.map['xdr:nvGraphicFramePr'].render(xmlStream, model); this.map['xdr:xfrm'].render(xmlStream, model); xmlStream.closeNode(); } parseOpen(node) { if (this.parser) { this.parser.parseOpen(node); return true; } switch (node.name) { case this.tag: this.reset(); break; default: this.parser = this.map[node.name]; if (this.parser) { this.parser.parseOpen(node); } break; } return true; } parseText() {} parseClose(name) { if (this.parser) { if (!this.parser.parseClose(name)) { this.mergeModel(this.parser.model); this.parser = undefined; } return true; } switch (name) { case this.tag: return false; default: // not quite sure how we get here! return true; } } } module.exports = ChartXform;