@difftim/excelize
Version:
Excel Workbook Manager - Read and Write xlsx and csv Files.
59 lines (57 loc) • 1.35 kB
JavaScript
const ATextXform = require('./a-t-xform');
const BaseXform = require('../../base-xform');
class APXform extends BaseXform {
get tag() {
return 'a:r';
}
// todo 这里只支持了 文本 富文本的需要单独处理 换行后获取不到标题
get textXform() {
return this._textXform || (this._textXform = new ATextXform());
}
render(xmlStream, model) {
xmlStream.openNode(this.tag);
this.textXform.render(xmlStream, model.text);
xmlStream.closeNode();
}
parseOpen(node) {
if (this.parser) {
this.parser.parseOpen(node);
return true;
}
switch (node.name) {
case this.tag:
this.model = {};
return true;
case 'a:t':
this.parser = this.textXform;
this.parser.parseOpen(node);
return true;
default:
return false;
}
}
parseText(text) {
if (this.parser) {
this.parser.parseText(text);
}
}
parseClose(name) {
switch (name) {
case this.tag:
return false;
case 'a:t':
this.model = {
title: this.parser.model
};
this.parser = undefined;
return true;
default:
if (this.parser) {
this.parser.parseClose(name);
}
return true;
}
}
}
module.exports = APXform;
//# sourceMappingURL=a-r-xform.js.map