blip-fill-xform.js 1.3 KB

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