UNPKG

hy_excelize

Version:

买菜用。感谢:https://github.com/zurmokeeper/excelize.git

71 lines (61 loc) 2 kB
const BaseXform = require('../base-xform'); const XdrNvPicPrXform = require('./xdr-nvPicPr-xform'); const XdrBlipFillXform = require('./xdr-blipFill-xform'); const XdrSpPrXform = require('./xdr-spPr-xform'); class XdrPicXform extends BaseXform { constructor() { super(); this.map = { 'xdr:nvPicPr': new XdrNvPicPrXform(), 'xdr:blipFill': new XdrBlipFillXform(), 'xdr:spPr': new XdrSpPrXform(), }; } render(xmlStream, model) { xmlStream.openNode('xdr:pic'); this.map['xdr:nvPicPr'].render(xmlStream, model.nvPicPr); this.map['xdr:blipFill'].render(xmlStream, model.blipFill); this.map['xdr:spPr'].render(xmlStream, model.spPr); xmlStream.closeNode(); } parseOpen(node) { if (this.parser) { this.parser.parseOpen(node); return true; } switch (node.name) { case 'xdr:pic': this.model = {}; return true; default: this.parser = this.map[node.name]; if (this.parser) { this.parser.parseOpen(node); return true; } throw new Error(`Unexpected xml node in parseOpen: ${JSON.stringify(node)}`); } } parseText() {} parseClose(name) { if (this.parser) { if (!this.parser.parseClose(name)) { this.parser = undefined; } return true; } switch (name) { case 'xdr:pic': this.model = { nvPicPr: this.map['xdr:nvPicPr'].model, blipFill: this.map['xdr:blipFill'].model, spPr: this.map['xdr:spPr'].model, }; return false; default: // not quite sure how we get here! return true; } } } module.exports = XdrPicXform;