nv-pic-pr-xform.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. const BaseXform = require('../base-xform');
  2. const CNvPrXform = require('./c-nv-pr-xform');
  3. const CNvPicPrXform = require('./c-nv-pic-pr-xform');
  4. class NvPicPrXform extends BaseXform {
  5. constructor() {
  6. super();
  7. this.map = {
  8. 'xdr:cNvPr': new CNvPrXform(),
  9. 'xdr:cNvPicPr': new CNvPicPrXform(),
  10. };
  11. }
  12. get tag() {
  13. return 'xdr:nvPicPr';
  14. }
  15. render(xmlStream, model) {
  16. xmlStream.openNode(this.tag);
  17. this.map['xdr:cNvPr'].render(xmlStream, model);
  18. this.map['xdr:cNvPicPr'].render(xmlStream, model);
  19. xmlStream.closeNode();
  20. }
  21. parseOpen(node) {
  22. if (this.parser) {
  23. this.parser.parseOpen(node);
  24. return true;
  25. }
  26. switch (node.name) {
  27. case this.tag:
  28. this.reset();
  29. break;
  30. default:
  31. this.parser = this.map[node.name];
  32. if (this.parser) {
  33. this.parser.parseOpen(node);
  34. }
  35. break;
  36. }
  37. return true;
  38. }
  39. parseText() {}
  40. parseClose(name) {
  41. if (this.parser) {
  42. if (!this.parser.parseClose(name)) {
  43. this.parser = undefined;
  44. }
  45. return true;
  46. }
  47. switch (name) {
  48. case this.tag:
  49. this.model = this.map['xdr:cNvPr'].model;
  50. return false;
  51. default:
  52. return true;
  53. }
  54. }
  55. }
  56. module.exports = NvPicPrXform;