c-nv-pr-xform.js 1.3 KB

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