@trebco/treb 25.5.0 → 25.6.1
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/dist/treb-spreadsheet.mjs +7 -7
- package/dist/treb.d.ts +3 -2
- package/package.json +1 -1
- package/treb-base-types/src/import.ts +23 -22
- package/treb-base-types/src/table.ts +0 -4
- package/treb-calculator/src/calculator.ts +2 -2
- package/treb-embed/src/embedded-spreadsheet.ts +25 -16
- package/treb-embed/style/layout.scss +4 -4
- package/treb-export/src/export2.ts +16 -10
- package/treb-export/src/import2.ts +2 -1
- package/treb-grid/src/index.ts +2 -1
- package/treb-grid/src/layout/base_layout.ts +16 -13
- package/treb-grid/src/types/annotation.ts +110 -82
- package/treb-grid/src/types/grid.ts +29 -29
- package/treb-grid/src/types/grid_base.ts +47 -47
- package/treb-grid/src/types/sheet.ts +9 -9
- package/treb-grid/src/types/sheet_types.ts +2 -2
|
@@ -79,74 +79,66 @@ export interface ViewData {
|
|
|
79
79
|
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
* have freeze panes. when an annotation crosses a freeze pane, we need
|
|
91
|
-
* two copies of the rendered node so that we can scroll. we use the key
|
|
92
|
-
* to match the frozen/unfrozen instances.
|
|
93
|
-
*/
|
|
94
|
-
public get key(): number { return this.key_; }
|
|
95
|
-
|
|
96
|
-
/** coordinates, in sheet space */
|
|
97
|
-
public rect?: Rectangle;
|
|
82
|
+
export interface ImageAnnotationData {
|
|
83
|
+
src: string;
|
|
84
|
+
scale: string;
|
|
85
|
+
original_size: {
|
|
86
|
+
width: number;
|
|
87
|
+
height: number;
|
|
88
|
+
};
|
|
89
|
+
}
|
|
98
90
|
|
|
99
|
-
|
|
91
|
+
export type AnnotationType = 'treb-chart'|'image'|'external';
|
|
100
92
|
|
|
101
|
-
|
|
102
|
-
|
|
93
|
+
/**
|
|
94
|
+
* splitting persisted data from the annotation class. that class might
|
|
95
|
+
* disappear in the future in favor of just a type. this interface should
|
|
96
|
+
* fully match the old Partial<Annotation> we used before. note that we
|
|
97
|
+
* used to define values for all members, but they may now be undefined
|
|
98
|
+
* because the Annotation class as a Partial instance of this data.
|
|
99
|
+
*
|
|
100
|
+
* conceptually annotation was originally intended to support types other
|
|
101
|
+
* than our own charts and images, but no one ever used it. so we could
|
|
102
|
+
* lock down the `type` field if we wanted to. or perhaps have an `external`
|
|
103
|
+
* type with opaque data. TODO.
|
|
104
|
+
*
|
|
105
|
+
*/
|
|
106
|
+
export interface AnnotationDataBase {
|
|
103
107
|
|
|
104
108
|
/** the new layout, persisted and takes preference over the old one */
|
|
105
|
-
|
|
109
|
+
layout?: AnnotationLayout;
|
|
106
110
|
|
|
107
|
-
/**
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
public type = '';
|
|
115
|
-
|
|
116
|
-
/** also opaque data, but not serialized. */
|
|
117
|
-
public temp: any = {};
|
|
111
|
+
/**
|
|
112
|
+
* the old layout used rectangles, and we need to keep support for
|
|
113
|
+
* that. this is not the layout rectangle. this rectangle is just
|
|
114
|
+
* for serialization/deserialization. the actual rectangle is maintained
|
|
115
|
+
* in the Annotation class.
|
|
116
|
+
*/
|
|
117
|
+
rect?: Partial<Rectangle>;
|
|
118
118
|
|
|
119
119
|
/** annotation can be resized. this is advisory, for UI */
|
|
120
|
-
|
|
120
|
+
resizable: boolean;
|
|
121
121
|
|
|
122
122
|
/** annotation can be moved. this is advisory, for UI */
|
|
123
|
-
|
|
123
|
+
movable: boolean;
|
|
124
124
|
|
|
125
125
|
/** annotation can be removed/deleted. this is advisory, for UI */
|
|
126
|
-
|
|
126
|
+
removable: boolean;
|
|
127
127
|
|
|
128
128
|
/** annotation can be selected. this is advisory, for UI */
|
|
129
|
-
|
|
129
|
+
selectable: boolean;
|
|
130
130
|
|
|
131
131
|
/** move when resizing/inserting rows/columns */
|
|
132
|
-
|
|
132
|
+
move_with_cells: boolean;
|
|
133
133
|
|
|
134
134
|
/** resize when resizing/inserting rows/columns */
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
public view: ViewData[] = [];
|
|
138
|
-
|
|
139
|
-
/**
|
|
140
|
-
* advisory, meaning we probably need an update if there's an opportunity.
|
|
141
|
-
* only advisory and not persisted.
|
|
142
|
-
*/
|
|
143
|
-
public dirty?: boolean;
|
|
135
|
+
resize_with_cells: boolean;
|
|
144
136
|
|
|
145
137
|
/**
|
|
146
138
|
* optional formula. the formula will be updated on structure events
|
|
147
139
|
* (insert/delete row/column).
|
|
148
140
|
*/
|
|
149
|
-
|
|
141
|
+
formula: string;
|
|
150
142
|
|
|
151
143
|
/**
|
|
152
144
|
* extent, useful for exporting. we could probably serialize this,
|
|
@@ -159,54 +151,90 @@ export class Annotation {
|
|
|
159
151
|
* dynamically but since it won't change all that often, we might
|
|
160
152
|
* as well precalculate.
|
|
161
153
|
*/
|
|
162
|
-
|
|
154
|
+
extent: ICellAddress;
|
|
163
155
|
|
|
164
|
-
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
export interface AnnotationImageData extends AnnotationDataBase {
|
|
159
|
+
type: 'image';
|
|
160
|
+
data: ImageAnnotationData;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
export interface AnnotationChartData extends AnnotationDataBase {
|
|
164
|
+
type: 'treb-chart';
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
export interface AnnotationExternalData extends AnnotationDataBase {
|
|
168
|
+
type: 'external';
|
|
169
|
+
data: Record<string, string>;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
export type AnnotationData = AnnotationChartData | AnnotationImageData | AnnotationExternalData;
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* why is this a class? it doesn't do anything.
|
|
176
|
+
* FIXME: -> interface
|
|
177
|
+
*/
|
|
178
|
+
export class Annotation {
|
|
179
|
+
|
|
180
|
+
public data: Partial<AnnotationData> = {};
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* the key field is used to identify and coordinate annotations when we
|
|
184
|
+
* have freeze panes. when an annotation crosses a freeze pane, we need
|
|
185
|
+
* two copies of the rendered node so that we can scroll. we use the key
|
|
186
|
+
* to match the frozen/unfrozen instances.
|
|
187
|
+
*/
|
|
188
|
+
public get key(): number { return this.key_; }
|
|
189
|
+
|
|
190
|
+
/** coordinates, in sheet space */
|
|
191
|
+
public rect?: Rectangle;
|
|
192
|
+
|
|
193
|
+
// public get rect(): Rectangle|undefined { return this.rect_; }
|
|
194
|
+
|
|
195
|
+
/** display coordinates, possibly scaled. not persisted. */
|
|
196
|
+
public scaled_rect?: Rectangle;
|
|
197
|
+
|
|
198
|
+
/** also opaque data, but not serialized. */
|
|
199
|
+
public temp: any = {};
|
|
200
|
+
|
|
201
|
+
public view: ViewData[] = [];
|
|
165
202
|
|
|
166
203
|
/**
|
|
167
|
-
*
|
|
168
|
-
*
|
|
169
|
-
* or the key won't exist.
|
|
204
|
+
* advisory, meaning we probably need an update if there's an opportunity.
|
|
205
|
+
* only advisory and not persisted.
|
|
170
206
|
*/
|
|
171
|
-
|
|
172
|
-
for (const key of Object.keys(this) as Array<keyof Annotation>){
|
|
173
|
-
if (key !== 'layout' // && key !== 'rect'
|
|
174
|
-
&& opts[key]) { // key !== 'cell_address' && opts[key]) {
|
|
175
|
-
(this as any)[key] = opts[key];
|
|
176
|
-
}
|
|
177
|
-
}
|
|
207
|
+
public dirty?: boolean;
|
|
178
208
|
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
209
|
+
private key_ = (key_generator++);
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
* constructor takes persisted data
|
|
213
|
+
*/
|
|
214
|
+
constructor(opts: Partial<AnnotationData> = {}) {
|
|
215
|
+
this.data = JSON.parse(JSON.stringify(opts)); // why clone?
|
|
182
216
|
if (opts.rect) {
|
|
183
217
|
this.rect = Rectangle.Create(opts.rect);
|
|
184
218
|
}
|
|
185
219
|
}
|
|
186
220
|
|
|
187
221
|
/**
|
|
188
|
-
* serialization
|
|
222
|
+
* serialization just returns persisted data, plus we update the
|
|
223
|
+
* rectangle.
|
|
224
|
+
*
|
|
225
|
+
* anyone serializing annotations should just be fetching the data
|
|
226
|
+
* object, but we're leaving this in place because we can't trace
|
|
227
|
+
* it back using tooling. that's a real drawback of toJSON, we
|
|
228
|
+
* should stop using it.
|
|
229
|
+
*
|
|
230
|
+
* although as long as we need to support `rect` here, it's not bad
|
|
231
|
+
* that we do it this way. perhaps change the function name, and
|
|
232
|
+
* call it directly?
|
|
233
|
+
*
|
|
189
234
|
*/
|
|
190
|
-
public toJSON(): Partial<
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
if (this.data) result.data = this.data;
|
|
194
|
-
if (this.formula) result.formula = this.formula;
|
|
195
|
-
if (this.type) result.type = this.type;
|
|
196
|
-
// if (this.class_name) result.class_name = this.class_name;
|
|
197
|
-
|
|
198
|
-
if (!this.resizable) result.resizable = this.resizable;
|
|
199
|
-
if (!this.movable) result.movable = this.movable;
|
|
200
|
-
if (!this.removable) result.removable = this.removable;
|
|
201
|
-
if (!this.selectable) result.selectable = this.selectable;
|
|
202
|
-
|
|
203
|
-
if (!this.move_with_cells) result.move_with_cells = this.move_with_cells;
|
|
204
|
-
if (!this.resize_with_cells) result.resize_with_cells = this.resize_with_cells;
|
|
205
|
-
|
|
206
|
-
if (this.layout) result.layout = this.layout;
|
|
207
|
-
if (this.extent) result.extent = this.extent;
|
|
208
|
-
|
|
209
|
-
return result;
|
|
235
|
+
public toJSON(): Partial<AnnotationData> {
|
|
236
|
+
return {
|
|
237
|
+
...this.data, rect: this.rect };
|
|
210
238
|
}
|
|
211
239
|
|
|
212
240
|
}
|
|
@@ -88,7 +88,7 @@ import type { GridOptions } from './grid_options';
|
|
|
88
88
|
import { BorderConstants } from './border_constants';
|
|
89
89
|
import type { SerializeOptions } from './serialize_options';
|
|
90
90
|
import { UA } from '../util/ua';
|
|
91
|
-
import { Annotation } from './annotation';
|
|
91
|
+
import { Annotation, type AnnotationData } from './annotation';
|
|
92
92
|
import { Autocomplete } from '../editors/autocomplete';
|
|
93
93
|
|
|
94
94
|
import { MouseDrag } from './drag_mask';
|
|
@@ -468,21 +468,21 @@ export class Grid extends GridBase {
|
|
|
468
468
|
* @param target new parameter allows setting annotation as rect or as
|
|
469
469
|
* cell range
|
|
470
470
|
*/
|
|
471
|
-
public CreateAnnotation(properties: Partial<
|
|
472
|
-
const annotation = new Annotation(properties
|
|
471
|
+
public CreateAnnotation(properties: Partial<AnnotationData> = {}, add_to_sheet = true, offset = false, target?: Partial<Area>|IRectangle): Annotation {
|
|
472
|
+
const annotation = new Annotation(properties);
|
|
473
473
|
|
|
474
474
|
if (offset) {
|
|
475
475
|
|
|
476
476
|
// to offset, we have to have layout (or at least scaled rect)
|
|
477
|
-
if (!annotation.layout && annotation.scaled_rect) {
|
|
478
|
-
annotation.layout = this.layout.RectToAnnotationLayout(annotation.scaled_rect);
|
|
477
|
+
if (!annotation.data.layout && annotation.scaled_rect) {
|
|
478
|
+
annotation.data.layout = this.layout.RectToAnnotationLayout(annotation.scaled_rect);
|
|
479
479
|
}
|
|
480
480
|
|
|
481
|
-
if (!annotation.layout) {
|
|
481
|
+
if (!annotation.data.layout) {
|
|
482
482
|
console.warn(`can't offset annotation without layout`);
|
|
483
483
|
}
|
|
484
484
|
else {
|
|
485
|
-
let target_rect = this.layout.AnnotationLayoutToRect(annotation.layout).Shift(20, 20);
|
|
485
|
+
let target_rect = this.layout.AnnotationLayoutToRect(annotation.data.layout).Shift(20, 20);
|
|
486
486
|
let recheck = true;
|
|
487
487
|
while (recheck) {
|
|
488
488
|
recheck = false;
|
|
@@ -495,19 +495,19 @@ export class Grid extends GridBase {
|
|
|
495
495
|
}
|
|
496
496
|
}
|
|
497
497
|
}
|
|
498
|
-
annotation.layout = this.layout.RectToAnnotationLayout(target_rect);
|
|
498
|
+
annotation.data.layout = this.layout.RectToAnnotationLayout(target_rect);
|
|
499
499
|
}
|
|
500
500
|
}
|
|
501
501
|
|
|
502
502
|
if (target) {
|
|
503
503
|
if (Rectangle.IsRectangle(target)) {
|
|
504
504
|
// console.info('creating from rectangle,', target);
|
|
505
|
-
annotation.layout = undefined;
|
|
505
|
+
annotation.data.layout = undefined;
|
|
506
506
|
annotation.rect = Rectangle.Create(target);
|
|
507
507
|
}
|
|
508
508
|
else if (target.start) {
|
|
509
509
|
annotation.rect = undefined;
|
|
510
|
-
annotation.layout = this.layout.AddressToAnnotationLayout(target.start, target.end||target.start);
|
|
510
|
+
annotation.data.layout = this.layout.AddressToAnnotationLayout(target.start, target.end||target.start);
|
|
511
511
|
}
|
|
512
512
|
}
|
|
513
513
|
|
|
@@ -569,8 +569,8 @@ export class Grid extends GridBase {
|
|
|
569
569
|
this.grid_events.Publish(event);
|
|
570
570
|
}
|
|
571
571
|
|
|
572
|
-
if (annotation.layout) {
|
|
573
|
-
this.EnsureAddress(annotation.layout.br.address, 1);
|
|
572
|
+
if (annotation.data.layout) {
|
|
573
|
+
this.EnsureAddress(annotation.data.layout.br.address, 1);
|
|
574
574
|
}
|
|
575
575
|
|
|
576
576
|
});
|
|
@@ -710,11 +710,11 @@ export class Grid extends GridBase {
|
|
|
710
710
|
element.style.left = (rect.left) + 'px';
|
|
711
711
|
}
|
|
712
712
|
|
|
713
|
-
annotation.extent = undefined; // reset
|
|
713
|
+
annotation.data.extent = undefined; // reset
|
|
714
714
|
this.grid_events.Publish({ type: 'annotation', event: 'move', annotation });
|
|
715
715
|
|
|
716
716
|
// annotation.rect = rect.Scale(1/this.layout.scale);
|
|
717
|
-
annotation.layout = this.layout.RectToAnnotationLayout(rect);
|
|
717
|
+
annotation.data.layout = this.layout.RectToAnnotationLayout(rect);
|
|
718
718
|
|
|
719
719
|
}
|
|
720
720
|
|
|
@@ -730,8 +730,8 @@ export class Grid extends GridBase {
|
|
|
730
730
|
|
|
731
731
|
if (add_to_layout) {
|
|
732
732
|
this.layout.AddAnnotation(annotation);
|
|
733
|
-
if (annotation.layout) {
|
|
734
|
-
this.EnsureAddress(annotation.layout.br.address, 1);
|
|
733
|
+
if (annotation.data.layout) {
|
|
734
|
+
this.EnsureAddress(annotation.data.layout.br.address, 1);
|
|
735
735
|
}
|
|
736
736
|
}
|
|
737
737
|
else {
|
|
@@ -2560,7 +2560,7 @@ export class Grid extends GridBase {
|
|
|
2560
2560
|
const annotation = this.editing_annotation;
|
|
2561
2561
|
this.ClearAdditionalSelections();
|
|
2562
2562
|
this.ClearSelection(this.active_selection);
|
|
2563
|
-
annotation.formula = event.value ? this.FixFormula(event.value) : '';
|
|
2563
|
+
annotation.data.formula = event.value ? this.FixFormula(event.value) : '';
|
|
2564
2564
|
const node = this.editing_annotation.view[this.view_index]?.node;
|
|
2565
2565
|
if (node) {
|
|
2566
2566
|
node.focus();
|
|
@@ -2784,10 +2784,10 @@ export class Grid extends GridBase {
|
|
|
2784
2784
|
const start = this.render_tiles.start;
|
|
2785
2785
|
const end = this.render_tiles.end;
|
|
2786
2786
|
|
|
2787
|
-
const row_list = [];
|
|
2787
|
+
const row_list: number[] = [];
|
|
2788
2788
|
for (let row = start.row; row <= end.row; row++) row_list.push(row);
|
|
2789
2789
|
|
|
2790
|
-
const column_list = [];
|
|
2790
|
+
const column_list: number[] = [];
|
|
2791
2791
|
for (let column = start.column; column <= end.column; column++) column_list.push(column);
|
|
2792
2792
|
|
|
2793
2793
|
// FIXME: multiple tiles
|
|
@@ -2959,11 +2959,11 @@ export class Grid extends GridBase {
|
|
|
2959
2959
|
const node = annotation.view[this.view_index]?.node;
|
|
2960
2960
|
if (node) { nodes.push(node); }
|
|
2961
2961
|
|
|
2962
|
-
if (y <= annotation.scaled_rect.top && annotation.move_with_cells) {
|
|
2962
|
+
if (y <= annotation.scaled_rect.top && annotation.data.move_with_cells) {
|
|
2963
2963
|
move_annotation_list.push({ annotation, y: annotation.scaled_rect.top, nodes });
|
|
2964
2964
|
}
|
|
2965
2965
|
|
|
2966
|
-
else if (y > annotation.scaled_rect.top && annotation.resize_with_cells) {
|
|
2966
|
+
else if (y > annotation.scaled_rect.top && annotation.data.resize_with_cells) {
|
|
2967
2967
|
size_annotation_list.push({ annotation, height: annotation.scaled_rect.height, nodes });
|
|
2968
2968
|
}
|
|
2969
2969
|
|
|
@@ -3081,13 +3081,13 @@ export class Grid extends GridBase {
|
|
|
3081
3081
|
|
|
3082
3082
|
for (const { annotation } of move_annotation_list) {
|
|
3083
3083
|
if (annotation.scaled_rect) {
|
|
3084
|
-
annotation.layout = this.layout.RectToAnnotationLayout(annotation.scaled_rect);
|
|
3084
|
+
annotation.data.layout = this.layout.RectToAnnotationLayout(annotation.scaled_rect);
|
|
3085
3085
|
}
|
|
3086
3086
|
}
|
|
3087
3087
|
|
|
3088
3088
|
for (const { annotation } of size_annotation_list) {
|
|
3089
3089
|
if (annotation.scaled_rect) {
|
|
3090
|
-
annotation.layout = this.layout.RectToAnnotationLayout(annotation.scaled_rect);
|
|
3090
|
+
annotation.data.layout = this.layout.RectToAnnotationLayout(annotation.scaled_rect);
|
|
3091
3091
|
}
|
|
3092
3092
|
const view = annotation.view[this.view_index];
|
|
3093
3093
|
if (view && view.resize_callback) {
|
|
@@ -3233,10 +3233,10 @@ export class Grid extends GridBase {
|
|
|
3233
3233
|
const node = annotation.view[this.view_index]?.node;
|
|
3234
3234
|
if (node) { nodes.push(node); }
|
|
3235
3235
|
|
|
3236
|
-
if (x <= annotation.scaled_rect.left && annotation.move_with_cells) {
|
|
3236
|
+
if (x <= annotation.scaled_rect.left && annotation.data.move_with_cells) {
|
|
3237
3237
|
move_annotation_list.push({ annotation, x: annotation.scaled_rect.left, nodes });
|
|
3238
3238
|
}
|
|
3239
|
-
else if (x > annotation.scaled_rect.left && annotation.resize_with_cells) {
|
|
3239
|
+
else if (x > annotation.scaled_rect.left && annotation.data.resize_with_cells) {
|
|
3240
3240
|
size_annotation_list.push({ annotation, width: annotation.scaled_rect.width, nodes });
|
|
3241
3241
|
}
|
|
3242
3242
|
}
|
|
@@ -3345,13 +3345,13 @@ export class Grid extends GridBase {
|
|
|
3345
3345
|
|
|
3346
3346
|
for (const { annotation } of move_annotation_list) {
|
|
3347
3347
|
if (annotation.scaled_rect) {
|
|
3348
|
-
annotation.layout = this.layout.RectToAnnotationLayout(annotation.scaled_rect);
|
|
3348
|
+
annotation.data.layout = this.layout.RectToAnnotationLayout(annotation.scaled_rect);
|
|
3349
3349
|
}
|
|
3350
3350
|
}
|
|
3351
3351
|
|
|
3352
3352
|
for (const { annotation } of size_annotation_list) {
|
|
3353
3353
|
if (annotation.scaled_rect) {
|
|
3354
|
-
annotation.layout = this.layout.RectToAnnotationLayout(annotation.scaled_rect);
|
|
3354
|
+
annotation.data.layout = this.layout.RectToAnnotationLayout(annotation.scaled_rect);
|
|
3355
3355
|
}
|
|
3356
3356
|
const view = annotation.view[this.view_index];
|
|
3357
3357
|
if (view && view.resize_callback) {
|
|
@@ -5868,8 +5868,8 @@ export class Grid extends GridBase {
|
|
|
5868
5868
|
private HideGridSelection() {
|
|
5869
5869
|
this.UpdateAddressLabel(undefined, '');
|
|
5870
5870
|
|
|
5871
|
-
const formula = (this.selected_annotation && this.selected_annotation.formula) ?
|
|
5872
|
-
this.selected_annotation.formula : '';
|
|
5871
|
+
const formula = (this.selected_annotation && this.selected_annotation.data.formula) ?
|
|
5872
|
+
this.selected_annotation.data.formula : '';
|
|
5873
5873
|
|
|
5874
5874
|
this.UpdateFormulaBarFormula(formula);
|
|
5875
5875
|
this.layout.ShowSelections(false);
|
|
@@ -2188,9 +2188,9 @@ export class GridBase {
|
|
|
2188
2188
|
|
|
2189
2189
|
// annotations
|
|
2190
2190
|
for (const annotation of sheet.annotations) {
|
|
2191
|
-
if (annotation.formula) {
|
|
2191
|
+
if (annotation.data.formula) {
|
|
2192
2192
|
let modified = false;
|
|
2193
|
-
const parsed = this.parser.Parse(annotation.formula || '');
|
|
2193
|
+
const parsed = this.parser.Parse(annotation.data.formula || '');
|
|
2194
2194
|
if (parsed.expression) {
|
|
2195
2195
|
this.parser.Walk(parsed.expression, (element: ExpressionUnit) => {
|
|
2196
2196
|
if (element.type === 'address') {
|
|
@@ -2202,7 +2202,7 @@ export class GridBase {
|
|
|
2202
2202
|
return true; // continue walk
|
|
2203
2203
|
});
|
|
2204
2204
|
if (modified) {
|
|
2205
|
-
annotation.formula = '=' + this.parser.Render(parsed.expression, { missing: '' });
|
|
2205
|
+
annotation.data.formula = '=' + this.parser.Render(parsed.expression, { missing: '' });
|
|
2206
2206
|
changes++;
|
|
2207
2207
|
}
|
|
2208
2208
|
}
|
|
@@ -2770,12 +2770,12 @@ export class GridBase {
|
|
|
2770
2770
|
});
|
|
2771
2771
|
|
|
2772
2772
|
for (const annotation of sheet.annotations) {
|
|
2773
|
-
if (annotation.formula) {
|
|
2774
|
-
const modified = this.PatchFormulasInternal(annotation.formula || '',
|
|
2773
|
+
if (annotation.data.formula) {
|
|
2774
|
+
const modified = this.PatchFormulasInternal(annotation.data.formula || '',
|
|
2775
2775
|
command.before_row, command.count, 0, 0,
|
|
2776
2776
|
target_sheet_name, is_target);
|
|
2777
2777
|
if (modified) {
|
|
2778
|
-
annotation.formula = modified;
|
|
2778
|
+
annotation.data.formula = modified;
|
|
2779
2779
|
}
|
|
2780
2780
|
}
|
|
2781
2781
|
}
|
|
@@ -2794,11 +2794,11 @@ export class GridBase {
|
|
|
2794
2794
|
const first = command.before_row;
|
|
2795
2795
|
|
|
2796
2796
|
for (const annotation of target_sheet.annotations) {
|
|
2797
|
-
if (annotation.layout) {
|
|
2797
|
+
if (annotation.data.layout) {
|
|
2798
2798
|
const [start, end, endy] = [
|
|
2799
|
-
annotation.layout.tl.address.row,
|
|
2800
|
-
annotation.layout.br.address.row,
|
|
2801
|
-
annotation.layout.br.offset.y,
|
|
2799
|
+
annotation.data.layout.tl.address.row,
|
|
2800
|
+
annotation.data.layout.br.address.row,
|
|
2801
|
+
annotation.data.layout.br.offset.y,
|
|
2802
2802
|
];
|
|
2803
2803
|
|
|
2804
2804
|
if (first <= start ) {
|
|
@@ -2806,15 +2806,15 @@ export class GridBase {
|
|
|
2806
2806
|
// start case 1: starts above the annotation (including exactly at the top)
|
|
2807
2807
|
|
|
2808
2808
|
// shift
|
|
2809
|
-
annotation.layout.tl.address.row += command.count;
|
|
2810
|
-
annotation.layout.br.address.row += command.count;
|
|
2809
|
+
annotation.data.layout.tl.address.row += command.count;
|
|
2810
|
+
annotation.data.layout.br.address.row += command.count;
|
|
2811
2811
|
|
|
2812
2812
|
}
|
|
2813
2813
|
else if (first < end || first === end && endy > 0) {
|
|
2814
2814
|
|
|
2815
2815
|
// start case 2: starts in the annotation, omitting the first row
|
|
2816
2816
|
|
|
2817
|
-
annotation.layout.br.address.row += command.count;
|
|
2817
|
+
annotation.data.layout.br.address.row += command.count;
|
|
2818
2818
|
|
|
2819
2819
|
// size changing
|
|
2820
2820
|
resize_annotations_list.push(annotation);
|
|
@@ -2839,16 +2839,16 @@ export class GridBase {
|
|
|
2839
2839
|
const last = command.before_row - command.count - 1;
|
|
2840
2840
|
|
|
2841
2841
|
for (const annotation of target_sheet.annotations) {
|
|
2842
|
-
if (annotation.layout) {
|
|
2842
|
+
if (annotation.data.layout) {
|
|
2843
2843
|
|
|
2844
2844
|
// start and end row of the annotation. recall that in
|
|
2845
2845
|
// this layout, the annotation may extend into the (first,last)
|
|
2846
2846
|
// row but not beyond it. the offset is _within_ the row.
|
|
2847
2847
|
|
|
2848
2848
|
const [start, end, endy] = [
|
|
2849
|
-
annotation.layout.tl.address.row,
|
|
2850
|
-
annotation.layout.br.address.row,
|
|
2851
|
-
annotation.layout.br.offset.y,
|
|
2849
|
+
annotation.data.layout.tl.address.row,
|
|
2850
|
+
annotation.data.layout.br.address.row,
|
|
2851
|
+
annotation.data.layout.br.offset.y,
|
|
2852
2852
|
];
|
|
2853
2853
|
|
|
2854
2854
|
if (first <= start ) {
|
|
@@ -2860,8 +2860,8 @@ export class GridBase {
|
|
|
2860
2860
|
// end case 1: ends before the annotation
|
|
2861
2861
|
|
|
2862
2862
|
// shift
|
|
2863
|
-
annotation.layout.tl.address.row += command.count;
|
|
2864
|
-
annotation.layout.br.address.row += command.count;
|
|
2863
|
+
annotation.data.layout.tl.address.row += command.count;
|
|
2864
|
+
annotation.data.layout.br.address.row += command.count;
|
|
2865
2865
|
|
|
2866
2866
|
}
|
|
2867
2867
|
else if (last < end - 1 || (last === end -1 && endy > 0)) {
|
|
@@ -2869,9 +2869,9 @@ export class GridBase {
|
|
|
2869
2869
|
// end case 2: ends before the end of the annotation
|
|
2870
2870
|
|
|
2871
2871
|
// shift + cut
|
|
2872
|
-
annotation.layout.tl.address.row = first;
|
|
2873
|
-
annotation.layout.tl.offset.y = 0;
|
|
2874
|
-
annotation.layout.br.address.row += command.count;
|
|
2872
|
+
annotation.data.layout.tl.address.row = first;
|
|
2873
|
+
annotation.data.layout.tl.offset.y = 0;
|
|
2874
|
+
annotation.data.layout.br.address.row += command.count;
|
|
2875
2875
|
|
|
2876
2876
|
// size changing
|
|
2877
2877
|
resize_annotations_list.push(annotation);
|
|
@@ -2897,7 +2897,7 @@ export class GridBase {
|
|
|
2897
2897
|
// end case 2: ends before the end of the annotation
|
|
2898
2898
|
|
|
2899
2899
|
// shorten
|
|
2900
|
-
annotation.layout.br.address.row += command.count;
|
|
2900
|
+
annotation.data.layout.br.address.row += command.count;
|
|
2901
2901
|
|
|
2902
2902
|
// size changing
|
|
2903
2903
|
resize_annotations_list.push(annotation);
|
|
@@ -2908,8 +2908,8 @@ export class GridBase {
|
|
|
2908
2908
|
// end case 3: ends after the annotation
|
|
2909
2909
|
|
|
2910
2910
|
// clip
|
|
2911
|
-
annotation.layout.br.address.row = first;
|
|
2912
|
-
annotation.layout.br.offset.y = 0;
|
|
2911
|
+
annotation.data.layout.br.address.row = first;
|
|
2912
|
+
annotation.data.layout.br.offset.y = 0;
|
|
2913
2913
|
|
|
2914
2914
|
// size changing
|
|
2915
2915
|
resize_annotations_list.push(annotation);
|
|
@@ -3096,12 +3096,12 @@ export class GridBase {
|
|
|
3096
3096
|
});
|
|
3097
3097
|
|
|
3098
3098
|
for (const annotation of sheet.annotations) {
|
|
3099
|
-
if (annotation.formula) {
|
|
3100
|
-
const modified = this.PatchFormulasInternal(annotation.formula,
|
|
3099
|
+
if (annotation.data.formula) {
|
|
3100
|
+
const modified = this.PatchFormulasInternal(annotation.data.formula,
|
|
3101
3101
|
0, 0, command.before_column, command.count,
|
|
3102
3102
|
target_sheet_name, is_target);
|
|
3103
3103
|
if (modified) {
|
|
3104
|
-
annotation.formula = modified;
|
|
3104
|
+
annotation.data.formula = modified;
|
|
3105
3105
|
}
|
|
3106
3106
|
}
|
|
3107
3107
|
}
|
|
@@ -3119,11 +3119,11 @@ export class GridBase {
|
|
|
3119
3119
|
const first = command.before_column;
|
|
3120
3120
|
|
|
3121
3121
|
for (const annotation of target_sheet.annotations) {
|
|
3122
|
-
if (annotation.layout) {
|
|
3122
|
+
if (annotation.data.layout) {
|
|
3123
3123
|
const [start, end, endx] = [
|
|
3124
|
-
annotation.layout.tl.address.column,
|
|
3125
|
-
annotation.layout.br.address.column,
|
|
3126
|
-
annotation.layout.br.offset.x,
|
|
3124
|
+
annotation.data.layout.tl.address.column,
|
|
3125
|
+
annotation.data.layout.br.address.column,
|
|
3126
|
+
annotation.data.layout.br.offset.x,
|
|
3127
3127
|
];
|
|
3128
3128
|
|
|
3129
3129
|
if (first <= start ) {
|
|
@@ -3131,15 +3131,15 @@ export class GridBase {
|
|
|
3131
3131
|
// start case 1: starts to the left of the annotation (including exactly at the left)
|
|
3132
3132
|
|
|
3133
3133
|
// shift
|
|
3134
|
-
annotation.layout.tl.address.column += command.count;
|
|
3135
|
-
annotation.layout.br.address.column += command.count;
|
|
3134
|
+
annotation.data.layout.tl.address.column += command.count;
|
|
3135
|
+
annotation.data.layout.br.address.column += command.count;
|
|
3136
3136
|
|
|
3137
3137
|
}
|
|
3138
3138
|
else if (first < end || first === end && endx > 0) {
|
|
3139
3139
|
|
|
3140
3140
|
// start case 2: starts in the annotation, omitting the first column
|
|
3141
3141
|
|
|
3142
|
-
annotation.layout.br.address.column += command.count;
|
|
3142
|
+
annotation.data.layout.br.address.column += command.count;
|
|
3143
3143
|
|
|
3144
3144
|
// size changing
|
|
3145
3145
|
resize_annotations_list.push(annotation);
|
|
@@ -3164,16 +3164,16 @@ export class GridBase {
|
|
|
3164
3164
|
const last = command.before_column - command.count - 1;
|
|
3165
3165
|
|
|
3166
3166
|
for (const annotation of target_sheet.annotations) {
|
|
3167
|
-
if (annotation.layout) {
|
|
3167
|
+
if (annotation.data.layout) {
|
|
3168
3168
|
|
|
3169
3169
|
// start and end column of the annotation. recall that in
|
|
3170
3170
|
// this layout, the annotation may extend into the (first,last)
|
|
3171
3171
|
// column but not beyond it. the offset is _within_ the column.
|
|
3172
3172
|
|
|
3173
3173
|
const [start, end, endx] = [
|
|
3174
|
-
annotation.layout.tl.address.column,
|
|
3175
|
-
annotation.layout.br.address.column,
|
|
3176
|
-
annotation.layout.br.offset.x,
|
|
3174
|
+
annotation.data.layout.tl.address.column,
|
|
3175
|
+
annotation.data.layout.br.address.column,
|
|
3176
|
+
annotation.data.layout.br.offset.x,
|
|
3177
3177
|
];
|
|
3178
3178
|
|
|
3179
3179
|
if (first <= start ) {
|
|
@@ -3185,8 +3185,8 @@ export class GridBase {
|
|
|
3185
3185
|
// end case 1: ends before the annotation
|
|
3186
3186
|
|
|
3187
3187
|
// shift
|
|
3188
|
-
annotation.layout.tl.address.column += command.count;
|
|
3189
|
-
annotation.layout.br.address.column += command.count;
|
|
3188
|
+
annotation.data.layout.tl.address.column += command.count;
|
|
3189
|
+
annotation.data.layout.br.address.column += command.count;
|
|
3190
3190
|
|
|
3191
3191
|
}
|
|
3192
3192
|
else if (last < end - 1 || (last === end -1 && endx > 0)) {
|
|
@@ -3194,9 +3194,9 @@ export class GridBase {
|
|
|
3194
3194
|
// end case 2: ends before the end of the annotation
|
|
3195
3195
|
|
|
3196
3196
|
// shift + cut
|
|
3197
|
-
annotation.layout.tl.address.column = first;
|
|
3198
|
-
annotation.layout.tl.offset.x = 0;
|
|
3199
|
-
annotation.layout.br.address.column += command.count;
|
|
3197
|
+
annotation.data.layout.tl.address.column = first;
|
|
3198
|
+
annotation.data.layout.tl.offset.x = 0;
|
|
3199
|
+
annotation.data.layout.br.address.column += command.count;
|
|
3200
3200
|
|
|
3201
3201
|
// size changing
|
|
3202
3202
|
resize_annotations_list.push(annotation);
|
|
@@ -3222,7 +3222,7 @@ export class GridBase {
|
|
|
3222
3222
|
// end case 2: ends before the end of the annotation
|
|
3223
3223
|
|
|
3224
3224
|
// shorten
|
|
3225
|
-
annotation.layout.br.address.column += command.count;
|
|
3225
|
+
annotation.data.layout.br.address.column += command.count;
|
|
3226
3226
|
|
|
3227
3227
|
// size changing
|
|
3228
3228
|
resize_annotations_list.push(annotation);
|
|
@@ -3233,8 +3233,8 @@ export class GridBase {
|
|
|
3233
3233
|
// end case 3: ends after the annotation
|
|
3234
3234
|
|
|
3235
3235
|
// clip
|
|
3236
|
-
annotation.layout.br.address.column = first;
|
|
3237
|
-
annotation.layout.br.offset.x = 0;
|
|
3236
|
+
annotation.data.layout.br.address.column = first;
|
|
3237
|
+
annotation.data.layout.br.offset.x = 0;
|
|
3238
3238
|
|
|
3239
3239
|
// size changing
|
|
3240
3240
|
resize_annotations_list.push(annotation);
|