row-breaks-xform.js 888 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. 'use strict';
  2. const PageBreaksXform = require('./page-breaks-xform');
  3. const ListXform = require('../list-xform');
  4. class RowBreaksXform extends ListXform {
  5. constructor() {
  6. const options = {
  7. tag: 'rowBreaks',
  8. count: true,
  9. childXform: new PageBreaksXform(),
  10. };
  11. super(options);
  12. }
  13. // get tag() { return 'rowBreaks'; }
  14. render(xmlStream, model) {
  15. if (model && model.length) {
  16. xmlStream.openNode(this.tag, this.$);
  17. if (this.count) {
  18. xmlStream.addAttribute(this.$count, model.length);
  19. xmlStream.addAttribute('manualBreakCount', model.length);
  20. }
  21. const {childXform} = this;
  22. model.forEach(childModel => {
  23. childXform.render(xmlStream, childModel);
  24. });
  25. xmlStream.closeNode();
  26. } else if (this.empty) {
  27. xmlStream.leafNode(this.tag);
  28. }
  29. }
  30. }
  31. module.exports = RowBreaksXform;