docxmlater 10.3.4 → 10.3.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -6,13 +6,27 @@ const TableCell_1 = require("./TableCell");
6
6
  const Revision_1 = require("./Revision");
7
7
  const XMLBuilder_1 = require("../xml/XMLBuilder");
8
8
  const deepClone_1 = require("../utils/deepClone");
9
+ const TableGridChange_1 = require("./TableGridChange");
9
10
  const CommonTypes_1 = require("./CommonTypes");
11
+ function buildTblLookAttributes(hex) {
12
+ const value = parseInt(hex, 16) || 0;
13
+ return {
14
+ 'w:val': hex,
15
+ 'w:firstRow': (value & 0x0020) !== 0 ? '1' : '0',
16
+ 'w:lastRow': (value & 0x0040) !== 0 ? '1' : '0',
17
+ 'w:firstColumn': (value & 0x0080) !== 0 ? '1' : '0',
18
+ 'w:lastColumn': (value & 0x0100) !== 0 ? '1' : '0',
19
+ 'w:noHBand': (value & 0x0200) !== 0 ? '1' : '0',
20
+ 'w:noVBand': (value & 0x0400) !== 0 ? '1' : '0',
21
+ };
22
+ }
10
23
  class Table {
11
24
  rows = [];
12
25
  formatting;
13
26
  _stylesManager;
14
27
  trackingContext;
15
28
  tblPrChange;
29
+ tblGridChange;
16
30
  constructor(rows, columns, formatting = {}) {
17
31
  if (formatting.width === undefined) {
18
32
  formatting.width = 9360;
@@ -38,6 +52,12 @@ class Table {
38
52
  clearTblPrChange() {
39
53
  this.tblPrChange = undefined;
40
54
  }
55
+ getTblGridChange() {
56
+ return this.tblGridChange;
57
+ }
58
+ setTblGridChange(change) {
59
+ this.tblGridChange = change;
60
+ }
41
61
  addRow(row) {
42
62
  this.rows.push(row);
43
63
  row._setParentTable(this);
@@ -352,8 +372,11 @@ class Table {
352
372
  setTableGrid(widths) {
353
373
  const prev = this.formatting.tableGrid;
354
374
  this.formatting.tableGrid = widths;
355
- if (this.trackingContext?.isEnabled()) {
356
- this.trackingContext.trackTableChange(this, 'tableGrid', prev, widths);
375
+ if (this.trackingContext?.isEnabled() && prev) {
376
+ if (!this.tblGridChange) {
377
+ const revisionManager = this.trackingContext.getRevisionManager();
378
+ this.tblGridChange = TableGridChange_1.TableGridChange.create(revisionManager.consumeNextId(), prev.map((w) => ({ width: w })), this.trackingContext.getAuthor(), new Date());
379
+ }
357
380
  }
358
381
  return this;
359
382
  }
@@ -615,7 +638,7 @@ class Table {
615
638
  }
616
639
  }
617
640
  if (this.formatting.tblLook) {
618
- tblPrChildren.push(XMLBuilder_1.XMLBuilder.wSelf('tblLook', { 'w:val': this.formatting.tblLook }));
641
+ tblPrChildren.push(XMLBuilder_1.XMLBuilder.wSelf('tblLook', buildTblLookAttributes(this.formatting.tblLook)));
619
642
  }
620
643
  if (this.formatting.caption) {
621
644
  tblPrChildren.push(XMLBuilder_1.XMLBuilder.wSelf('tblCaption', { 'w:val': this.formatting.caption }));
@@ -701,7 +724,7 @@ class Table {
701
724
  }
702
725
  }
703
726
  if (prev.tblLook) {
704
- prevTblPrChildren.push(XMLBuilder_1.XMLBuilder.wSelf('tblLook', { 'w:val': prev.tblLook }));
727
+ prevTblPrChildren.push(XMLBuilder_1.XMLBuilder.wSelf('tblLook', buildTblLookAttributes(prev.tblLook)));
705
728
  }
706
729
  if (prev.tblStyleRowBandSize !== undefined) {
707
730
  prevTblPrChildren.push(XMLBuilder_1.XMLBuilder.wSelf('tblStyleRowBandSize', { 'w:val': prev.tblStyleRowBandSize }));
@@ -738,6 +761,9 @@ class Table {
738
761
  tblGridChildren.push(XMLBuilder_1.XMLBuilder.wSelf('gridCol', { 'w:w': 2880 }));
739
762
  }
740
763
  }
764
+ if (this.tblGridChange) {
765
+ tblGridChildren.push(this.tblGridChange.toXML());
766
+ }
741
767
  tableChildren.push(XMLBuilder_1.XMLBuilder.w('tblGrid', undefined, tblGridChildren));
742
768
  for (const row of this.rows) {
743
769
  tableChildren.push(row.toXML());