@trebco/treb 29.1.2 → 29.1.5

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trebco/treb",
3
- "version": "29.1.2",
3
+ "version": "29.1.5",
4
4
  "license": "LGPL-3.0-or-later",
5
5
  "homepage": "https://treb.app",
6
6
  "repository": {
@@ -65,6 +65,8 @@ export interface ImportedSheetData {
65
65
  sheet_style?: number;
66
66
  column_styles?: number[];
67
67
 
68
+ row_styles?: number[];
69
+
68
70
  // new
69
71
  annotations?: AnchoredAnnotation[];
70
72
 
@@ -46,6 +46,13 @@ export enum TextPartFlag {
46
46
  italic = 7,
47
47
  */
48
48
 
49
+ /**
50
+ * this is an indent component. we want to keep track of this
51
+ * so we don't add it more than once if we're indenting dynamically.
52
+ * maybe this is not the way to indent.
53
+ */
54
+ indent = 8,
55
+
49
56
  }
50
57
 
51
58
  export interface TextPart {
@@ -2834,6 +2834,16 @@ export class Sheet {
2834
2834
  }
2835
2835
  }
2836
2836
 
2837
+ // and row styles...
2838
+
2839
+ if (data.row_styles) {
2840
+ for (const [row, style] of data.row_styles.entries()) {
2841
+ if (style) {
2842
+ this.UpdateAreaStyle(new Area({ row, column: Infinity }), styles[style]);
2843
+ }
2844
+ }
2845
+ }
2846
+
2837
2847
  // this.cells.FromJSON(cell_data);
2838
2848
  this.cells.FromJSON(data.cells);
2839
2849
  if (data.name) {
@@ -506,6 +506,7 @@ export class Importer {
506
506
  const merges: RangeType[] = [];
507
507
  const conditional_formats: ConditionalFormat[] = [];
508
508
  const links: HyperlinkType[] = [];
509
+ const row_styles: number[] = []; // may be sparse
509
510
  const validations: Array<{
510
511
  address: ICellAddress,
511
512
  validation: DataValidation,
@@ -696,6 +697,13 @@ export class Importer {
696
697
  }
697
698
  }
698
699
 
700
+ if (row.a$?.s) {
701
+ const style_reference = Number(row.a$?.s);
702
+ if (!isNaN(style_reference)) {
703
+ row_styles[row_index - 1] = style_reference;
704
+ }
705
+ }
706
+
699
707
  // if there's a height which is not === default height, but
700
708
  // the customHeight attribute is not set, then it's been auto-sized.
701
709
  // not sure that's something we need to care about necessarily...
@@ -1162,6 +1170,7 @@ export class Importer {
1162
1170
  default_column_width,
1163
1171
  column_widths,
1164
1172
  row_heights,
1173
+ row_styles,
1165
1174
  annotations,
1166
1175
  conditional_formats,
1167
1176
  styles: this.workbook?.style_cache?.CellXfToStyles() || [],
@@ -735,11 +735,17 @@ export class TileRenderer {
735
735
  let override_formatting: string | undefined;
736
736
  let formatted = cell.editing ? '' : cell.formatted; // <-- empty on editing, to remove overflows
737
737
 
738
+ // remove existing indent, if any
739
+
740
+ if (Array.isArray(formatted)) {
741
+ formatted = formatted.filter(test => test.flag !== TextPartFlag.indent);
742
+ }
743
+
738
744
  // precalculate indent as string so we can use layout
739
745
 
740
746
  let indent = '';
741
747
  let align: HorizontalAlign|undefined;
742
-
748
+
743
749
  if (style.indent) {
744
750
 
745
751
  for (let i = 0; i < style.indent; i++) {
@@ -751,9 +757,14 @@ export class TileRenderer {
751
757
  // default might be left or right based on type
752
758
 
753
759
  if (!align) {
754
- align = (cell.type === ValueType.number || cell.calculated_type === ValueType.number) ? 'right' : 'left';
760
+ align = (
761
+ cell.type === ValueType.number ||
762
+ cell.calculated_type === ValueType.number ||
763
+ cell.type === ValueType.complex ||
764
+ cell.calculated_type === ValueType.complex
765
+ ) ? 'right' : 'left';
755
766
  }
756
-
767
+
757
768
  }
758
769
 
759
770
  if (Array.isArray(formatted)) {
@@ -767,12 +778,11 @@ export class TileRenderer {
767
778
  // this is a single line, with number formatting
768
779
 
769
780
  if (indent) {
770
-
771
781
  if (align === 'right') {
772
- formatted.push({ text: indent });
782
+ formatted.push({ text: indent, flag: TextPartFlag.indent });
773
783
  }
774
- else if (align === 'left') {
775
- formatted.unshift({ text: indent });
784
+ else if (align === 'left' || typeof align === 'undefined') {
785
+ formatted.unshift({ text: indent, flag: TextPartFlag.indent });
776
786
  }
777
787
  }
778
788
 
@@ -2081,7 +2081,7 @@ export class Grid extends GridBase {
2081
2081
 
2082
2082
  if (!area) {
2083
2083
  if (this.primary_selection.empty) { return; }
2084
- area = this.primary_selection.area;
2084
+ area = this.active_sheet.RealArea(this.primary_selection.area);
2085
2085
  }
2086
2086
 
2087
2087
  this.ExecCommand({