ext-lst-xform.js 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /* eslint-disable max-classes-per-file */
  2. const CompositeXform = require('../composite-xform');
  3. const ConditionalFormattingsExt = require('./cf-ext/conditional-formattings-ext-xform');
  4. class ExtXform extends CompositeXform {
  5. constructor() {
  6. super();
  7. this.map = {
  8. 'x14:conditionalFormattings': (this.conditionalFormattings = new ConditionalFormattingsExt()),
  9. };
  10. }
  11. get tag() {
  12. return 'ext';
  13. }
  14. hasContent(model) {
  15. return this.conditionalFormattings.hasContent(model.conditionalFormattings);
  16. }
  17. prepare(model, options) {
  18. this.conditionalFormattings.prepare(model.conditionalFormattings, options);
  19. }
  20. render(xmlStream, model) {
  21. xmlStream.openNode('ext', {
  22. uri: '{78C0D931-6437-407d-A8EE-F0AAD7539E65}',
  23. 'xmlns:x14': 'http://schemas.microsoft.com/office/spreadsheetml/2009/9/main',
  24. });
  25. this.conditionalFormattings.render(xmlStream, model.conditionalFormattings);
  26. xmlStream.closeNode();
  27. }
  28. createNewModel() {
  29. return {};
  30. }
  31. onParserClose(name, parser) {
  32. this.model[name] = parser.model;
  33. }
  34. }
  35. class ExtLstXform extends CompositeXform {
  36. constructor() {
  37. super();
  38. this.map = {
  39. ext: (this.ext = new ExtXform()),
  40. };
  41. }
  42. get tag() {
  43. return 'extLst';
  44. }
  45. prepare(model, options) {
  46. this.ext.prepare(model, options);
  47. }
  48. hasContent(model) {
  49. return this.ext.hasContent(model);
  50. }
  51. render(xmlStream, model) {
  52. if (!this.hasContent(model)) {
  53. return;
  54. }
  55. xmlStream.openNode('extLst');
  56. this.ext.render(xmlStream, model);
  57. xmlStream.closeNode();
  58. }
  59. createNewModel() {
  60. return {};
  61. }
  62. onParserClose(name, parser) {
  63. Object.assign(this.model, parser.model);
  64. }
  65. }
  66. module.exports = ExtLstXform;