@extend-ai/react-xlsx 0.14.1 → 0.15.0
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/README.md +28 -3
- package/dist/duke_sheets_wasm_bg.wasm +0 -0
- package/dist/index.cjs +877 -989
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +67 -37
- package/dist/index.d.ts +67 -37
- package/dist/index.js +877 -989
- package/dist/index.js.map +1 -1
- package/dist/xlsx-worker.js +235 -82
- package/dist/xlsx-worker.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1956,7 +1956,7 @@ function normalizeChartExLegend(raw) {
|
|
|
1956
1956
|
return null;
|
|
1957
1957
|
}
|
|
1958
1958
|
const legend = raw;
|
|
1959
|
-
const position = typeof legend.
|
|
1959
|
+
const position = typeof legend.position === "string" ? normalizeLegendPosition(String(legend.position)) : void 0;
|
|
1960
1960
|
return {
|
|
1961
1961
|
overlay: typeof legend.overlay === "boolean" ? legend.overlay : void 0,
|
|
1962
1962
|
position,
|
|
@@ -2077,11 +2077,11 @@ function buildChartExHistogramBins(values, rawSeries, sortByFrequency) {
|
|
|
2077
2077
|
return [];
|
|
2078
2078
|
}
|
|
2079
2079
|
const rawRecord = rawSeries && typeof rawSeries === "object" ? rawSeries : null;
|
|
2080
|
-
const layoutProperties = rawRecord?.
|
|
2080
|
+
const layoutProperties = rawRecord?.layoutProperties && typeof rawRecord.layoutProperties === "object" ? rawRecord.layoutProperties : null;
|
|
2081
2081
|
const rawBinning = layoutProperties?.binning && typeof layoutProperties.binning === "object" ? layoutProperties.binning : null;
|
|
2082
2082
|
const minValue = Math.min(...values);
|
|
2083
2083
|
const maxValue = Math.max(...values);
|
|
2084
|
-
const explicitWidth = typeof rawBinning?.
|
|
2084
|
+
const explicitWidth = typeof rawBinning?.binSize === "number" && Number.isFinite(rawBinning.binSize) && rawBinning.binSize > 0 ? rawBinning.binSize : void 0;
|
|
2085
2085
|
const explicitCount = typeof rawBinning?.binCount === "number" && Number.isFinite(rawBinning.binCount) && rawBinning.binCount > 0 ? rawBinning.binCount : typeof rawBinning?.count === "number" && Number.isFinite(rawBinning.count) && rawBinning.count > 0 ? rawBinning.count : void 0;
|
|
2086
2086
|
const closedRight = rawBinning?.intervalClosed === "r" || rawBinning?.intervalClosed === "right";
|
|
2087
2087
|
const mean = values.reduce((sum, value) => sum + value, 0) / values.length;
|
|
@@ -2134,7 +2134,7 @@ function buildChartExHistogramSeries(series, rawSeries, sortByFrequency) {
|
|
|
2134
2134
|
const layout = resolveChartExSeriesLayout(rawSeries);
|
|
2135
2135
|
const rawRecord = rawSeries && typeof rawSeries === "object" ? rawSeries : null;
|
|
2136
2136
|
const hasBinning = Boolean(
|
|
2137
|
-
layout === "clusteredColumn" && rawRecord?.
|
|
2137
|
+
layout === "clusteredColumn" && rawRecord?.layoutProperties && typeof rawRecord.layoutProperties === "object" && rawRecord.layoutProperties.binning != null
|
|
2138
2138
|
);
|
|
2139
2139
|
if (!hasBinning) {
|
|
2140
2140
|
return series;
|
|
@@ -2346,7 +2346,8 @@ function collapseChartExPointSeries(chartType, series) {
|
|
|
2346
2346
|
];
|
|
2347
2347
|
}
|
|
2348
2348
|
function normalizeChartExChart(workbook, workbookSheetIndex, visibleSheetIndex, raw, index, themePalette) {
|
|
2349
|
-
const
|
|
2349
|
+
const drawing = raw && typeof raw === "object" ? raw : {};
|
|
2350
|
+
const chart = drawing.chartEx && typeof drawing.chartEx === "object" ? drawing.chartEx : {};
|
|
2350
2351
|
const plotArea = chart.plotArea && typeof chart.plotArea === "object" ? chart.plotArea : {};
|
|
2351
2352
|
const rawSeries = Array.isArray(plotArea.series) ? plotArea.series : [];
|
|
2352
2353
|
const seriesLayouts = rawSeries.map(resolveChartExSeriesLayout);
|
|
@@ -2401,7 +2402,7 @@ function normalizeChartExChart(workbook, workbookSheetIndex, visibleSheetIndex,
|
|
|
2401
2402
|
}
|
|
2402
2403
|
] : [];
|
|
2403
2404
|
const normalizedChart = {
|
|
2404
|
-
anchor: normalizeChartAnchor(
|
|
2405
|
+
anchor: normalizeChartAnchor(drawing.anchor),
|
|
2405
2406
|
autoTitleDeleted: void 0,
|
|
2406
2407
|
axes,
|
|
2407
2408
|
axisLabelColor: void 0,
|
|
@@ -2425,7 +2426,7 @@ function normalizeChartExChart(workbook, workbookSheetIndex, visibleSheetIndex,
|
|
|
2425
2426
|
id: `chart-ex-${workbookSheetIndex}-${index}`,
|
|
2426
2427
|
is3d: void 0,
|
|
2427
2428
|
legend: normalizeChartExLegend(chart.legend),
|
|
2428
|
-
name: chartTitle,
|
|
2429
|
+
name: typeof drawing.name === "string" ? drawing.name : chartTitle,
|
|
2429
2430
|
overlap: void 0,
|
|
2430
2431
|
plotVisibleOnly: void 0,
|
|
2431
2432
|
raw: chart,
|
|
@@ -2453,7 +2454,7 @@ function normalizeChartExChart(workbook, workbookSheetIndex, visibleSheetIndex,
|
|
|
2453
2454
|
view3d: void 0,
|
|
2454
2455
|
wireframe: void 0,
|
|
2455
2456
|
workbookSheetIndex,
|
|
2456
|
-
zIndex: index
|
|
2457
|
+
zIndex: Array.isArray(drawing.drawingPath) && typeof drawing.drawingPath[0] === "number" ? drawing.drawingPath[0] + 1 : index + 1
|
|
2457
2458
|
};
|
|
2458
2459
|
applyBuiltinChartDefaults(normalizedChart, themePalette);
|
|
2459
2460
|
return normalizedChart;
|
|
@@ -2574,10 +2575,11 @@ function normalizeChartReference(raw) {
|
|
|
2574
2575
|
return null;
|
|
2575
2576
|
}
|
|
2576
2577
|
const record = raw;
|
|
2578
|
+
const values = Array.isArray(record.numbers) ? record.numbers : Array.isArray(record.strings) ? record.strings : void 0;
|
|
2577
2579
|
return {
|
|
2578
2580
|
formula: typeof record.formula === "string" ? record.formula : void 0,
|
|
2579
2581
|
refType: typeof record.refType === "string" ? record.refType : void 0,
|
|
2580
|
-
values
|
|
2582
|
+
values
|
|
2581
2583
|
};
|
|
2582
2584
|
}
|
|
2583
2585
|
function normalizeChartAxis(raw) {
|
|
@@ -2597,8 +2599,8 @@ function normalizeChartAxis(raw) {
|
|
|
2597
2599
|
logBase: typeof axis.logBase === "number" ? axis.logBase : void 0,
|
|
2598
2600
|
orientation: typeof axis.orientation === "string" ? axis.orientation : void 0,
|
|
2599
2601
|
majorUnit: typeof axis.majorUnit === "number" ? axis.majorUnit : void 0,
|
|
2600
|
-
max: typeof axis.
|
|
2601
|
-
min: typeof axis.
|
|
2602
|
+
max: typeof axis.maximum === "number" ? axis.maximum : void 0,
|
|
2603
|
+
min: typeof axis.minimum === "number" ? axis.minimum : void 0,
|
|
2602
2604
|
majorGridlines: typeof axis.majorGridlines === "boolean" ? axis.majorGridlines : void 0,
|
|
2603
2605
|
majorTickMark: typeof axis.majorTickMark === "string" ? axis.majorTickMark : void 0,
|
|
2604
2606
|
minorUnit: typeof axis.minorUnit === "number" ? axis.minorUnit : void 0,
|
|
@@ -2721,11 +2723,11 @@ function normalizeChartDataLabels(raw) {
|
|
|
2721
2723
|
pointLabels: pointLabels && pointLabels.length > 0 ? pointLabels : void 0,
|
|
2722
2724
|
raw: labels,
|
|
2723
2725
|
showBubbleSize: typeof labels.showBubbleSize === "boolean" ? labels.showBubbleSize : void 0,
|
|
2724
|
-
showCategoryName: typeof labels.showCategoryName === "boolean" ? labels.showCategoryName : void 0,
|
|
2726
|
+
showCategoryName: typeof (labels.showCategoryName ?? labels.visibilityCategoryName) === "boolean" ? Boolean(labels.showCategoryName ?? labels.visibilityCategoryName) : void 0,
|
|
2725
2727
|
showLegendKey: typeof labels.showLegendKey === "boolean" ? labels.showLegendKey : void 0,
|
|
2726
2728
|
showPercent: typeof labels.showPercent === "boolean" ? labels.showPercent : void 0,
|
|
2727
|
-
showSeriesName: typeof labels.showSeriesName === "boolean" ? labels.showSeriesName : void 0,
|
|
2728
|
-
showValue: typeof labels.showValue === "boolean" ? labels.showValue : void 0
|
|
2729
|
+
showSeriesName: typeof (labels.showSeriesName ?? labels.visibilitySeriesName) === "boolean" ? Boolean(labels.showSeriesName ?? labels.visibilitySeriesName) : void 0,
|
|
2730
|
+
showValue: typeof (labels.showValue ?? labels.visibilityValue) === "boolean" ? Boolean(labels.showValue ?? labels.visibilityValue) : void 0
|
|
2729
2731
|
};
|
|
2730
2732
|
}
|
|
2731
2733
|
function normalizeChartAnchor(raw) {
|
|
@@ -2737,19 +2739,52 @@ function normalizeChartAnchor(raw) {
|
|
|
2737
2739
|
};
|
|
2738
2740
|
}
|
|
2739
2741
|
const anchor = raw;
|
|
2740
|
-
const
|
|
2741
|
-
|
|
2742
|
-
|
|
2743
|
-
|
|
2744
|
-
|
|
2745
|
-
|
|
2746
|
-
|
|
2747
|
-
|
|
2748
|
-
|
|
2749
|
-
|
|
2750
|
-
|
|
2751
|
-
|
|
2752
|
-
|
|
2742
|
+
const from = anchor.from && typeof anchor.from === "object" ? anchor.from : null;
|
|
2743
|
+
if (anchor.type === "oneCell") {
|
|
2744
|
+
return {
|
|
2745
|
+
from: {
|
|
2746
|
+
col: typeof from?.col === "number" ? from.col : 0,
|
|
2747
|
+
colOffsetEmu: typeof from?.colOffsetEmu === "number" ? from.colOffsetEmu : 0,
|
|
2748
|
+
row: typeof from?.row === "number" ? from.row : 0,
|
|
2749
|
+
rowOffsetEmu: typeof from?.rowOffsetEmu === "number" ? from.rowOffsetEmu : 0
|
|
2750
|
+
},
|
|
2751
|
+
kind: "one-cell",
|
|
2752
|
+
sizeEmu: {
|
|
2753
|
+
cx: typeof anchor.widthEmu === "number" ? anchor.widthEmu : 0,
|
|
2754
|
+
cy: typeof anchor.heightEmu === "number" ? anchor.heightEmu : 0
|
|
2755
|
+
}
|
|
2756
|
+
};
|
|
2757
|
+
}
|
|
2758
|
+
if (anchor.type === "absolute") {
|
|
2759
|
+
return {
|
|
2760
|
+
kind: "absolute",
|
|
2761
|
+
positionEmu: {
|
|
2762
|
+
x: typeof anchor.xEmu === "number" ? anchor.xEmu : 0,
|
|
2763
|
+
y: typeof anchor.yEmu === "number" ? anchor.yEmu : 0
|
|
2764
|
+
},
|
|
2765
|
+
sizeEmu: {
|
|
2766
|
+
cx: typeof anchor.widthEmu === "number" ? anchor.widthEmu : 0,
|
|
2767
|
+
cy: typeof anchor.heightEmu === "number" ? anchor.heightEmu : 0
|
|
2768
|
+
}
|
|
2769
|
+
};
|
|
2770
|
+
}
|
|
2771
|
+
const to = anchor.to && typeof anchor.to === "object" ? anchor.to : null;
|
|
2772
|
+
const fromColValue = from?.col;
|
|
2773
|
+
const fromColOffsetValue = from?.colOffsetEmu;
|
|
2774
|
+
const fromRowValue = from?.row;
|
|
2775
|
+
const fromRowOffsetValue = from?.rowOffsetEmu;
|
|
2776
|
+
const toColValue = to?.col;
|
|
2777
|
+
const toColOffsetValue = to?.colOffsetEmu;
|
|
2778
|
+
const toRowValue = to?.row;
|
|
2779
|
+
const toRowOffsetValue = to?.rowOffsetEmu;
|
|
2780
|
+
const fromCol = typeof fromColValue === "number" ? fromColValue : 0;
|
|
2781
|
+
const fromColOffsetEmu = typeof fromColOffsetValue === "number" ? fromColOffsetValue : 0;
|
|
2782
|
+
const fromRow = typeof fromRowValue === "number" ? fromRowValue : 0;
|
|
2783
|
+
const fromRowOffsetEmu = typeof fromRowOffsetValue === "number" ? fromRowOffsetValue : 0;
|
|
2784
|
+
const rawToCol = typeof toColValue === "number" ? toColValue : 0;
|
|
2785
|
+
const rawToColOffsetEmu = typeof toColOffsetValue === "number" ? toColOffsetValue : 0;
|
|
2786
|
+
const rawToRow = typeof toRowValue === "number" ? toRowValue : 0;
|
|
2787
|
+
const rawToRowOffsetEmu = typeof toRowOffsetValue === "number" ? toRowOffsetValue : 0;
|
|
2753
2788
|
return {
|
|
2754
2789
|
kind: "two-cell",
|
|
2755
2790
|
from: {
|
|
@@ -2759,10 +2794,10 @@ function normalizeChartAnchor(raw) {
|
|
|
2759
2794
|
rowOffsetEmu: fromRowOffsetEmu
|
|
2760
2795
|
},
|
|
2761
2796
|
to: {
|
|
2762
|
-
col:
|
|
2763
|
-
colOffsetEmu:
|
|
2764
|
-
row:
|
|
2765
|
-
rowOffsetEmu:
|
|
2797
|
+
col: rawToCol,
|
|
2798
|
+
colOffsetEmu: rawToColOffsetEmu,
|
|
2799
|
+
row: rawToRow,
|
|
2800
|
+
rowOffsetEmu: rawToRowOffsetEmu
|
|
2766
2801
|
}
|
|
2767
2802
|
};
|
|
2768
2803
|
}
|
|
@@ -2876,7 +2911,7 @@ function normalizeChartTypeGroup(workbook, workbookSheetIndex, chartId, raw, ind
|
|
|
2876
2911
|
chartType: typeof group.chartType === "string" ? group.chartType : "ColumnClustered",
|
|
2877
2912
|
dataLabels: normalizeChartDataLabels(group.dataLabels),
|
|
2878
2913
|
gapWidth: typeof group.gapWidth === "number" && Number.isFinite(group.gapWidth) ? group.gapWidth : void 0,
|
|
2879
|
-
is3d: typeof group.
|
|
2914
|
+
is3d: typeof group.is3D === "boolean" ? group.is3D : void 0,
|
|
2880
2915
|
overlap: typeof group.overlap === "number" && Number.isFinite(group.overlap) ? group.overlap : void 0,
|
|
2881
2916
|
raw: group,
|
|
2882
2917
|
series: rawSeries.map((entry, seriesIndex) => normalizeChartSeries(workbook, workbookSheetIndex, `${chartId}-group-${index}`, entry, seriesIndex)),
|
|
@@ -3030,20 +3065,25 @@ function applyChartOrigins(chartsByWorkbookSheetIndex, chartOriginsById, archive
|
|
|
3030
3065
|
}
|
|
3031
3066
|
}
|
|
3032
3067
|
function loadWorkbookChartAssets(workbook, imageAssets, visibleSheetIndexByWorkbookSheetIndex, showHiddenSheets = false) {
|
|
3068
|
+
const excludedChartIds = /* @__PURE__ */ new Set();
|
|
3033
3069
|
const chartsByWorkbookSheetIndex = Array.from({ length: workbook.sheetCount }, (_, workbookSheetIndex) => {
|
|
3034
3070
|
const worksheet = workbook.getSheet(workbookSheetIndex);
|
|
3035
|
-
const rawCharts =
|
|
3036
|
-
const rawChartsEx =
|
|
3071
|
+
const rawCharts = worksheet.charts;
|
|
3072
|
+
const rawChartsEx = worksheet.chartsEx;
|
|
3037
3073
|
const visibleSheetIndex = visibleSheetIndexByWorkbookSheetIndex.get(workbookSheetIndex) ?? workbookSheetIndex;
|
|
3038
3074
|
const classicCharts = rawCharts.map((rawChart, chartIndex) => {
|
|
3039
3075
|
const chartId = `chart-${workbookSheetIndex}-${chartIndex}`;
|
|
3040
|
-
|
|
3041
|
-
|
|
3076
|
+
if (rawChart.hidden || !rawChart.anchor) {
|
|
3077
|
+
excludedChartIds.add(chartId);
|
|
3078
|
+
}
|
|
3079
|
+
const drawing = rawChart && typeof rawChart === "object" ? rawChart : {};
|
|
3080
|
+
const chart = drawing.chart && typeof drawing.chart === "object" ? drawing.chart : {};
|
|
3081
|
+
const rawView3d = chart.view3D && typeof chart.view3D === "object" ? chart.view3D : null;
|
|
3042
3082
|
const rawSeries = Array.isArray(chart.series) ? chart.series : [];
|
|
3043
3083
|
const chartLevelDataLabels = normalizeChartDataLabels(chart.dataLabels);
|
|
3044
3084
|
const firstSeriesDataLabels = rawSeries.length > 0 && rawSeries[0] && typeof rawSeries[0] === "object" ? normalizeChartDataLabels(rawSeries[0].dataLabels) : null;
|
|
3045
3085
|
return {
|
|
3046
|
-
anchor: normalizeChartAnchor(
|
|
3086
|
+
anchor: normalizeChartAnchor(drawing.anchor),
|
|
3047
3087
|
autoTitleDeleted: typeof chart.autoTitleDeleted === "boolean" ? chart.autoTitleDeleted : void 0,
|
|
3048
3088
|
axes: Array.isArray(chart.axes) ? chart.axes.map(normalizeChartAxis).filter((value) => Boolean(value)) : [],
|
|
3049
3089
|
axisLabelColor: void 0,
|
|
@@ -3064,12 +3104,12 @@ function loadWorkbookChartAssets(workbook, imageAssets, visibleSheetIndexByWorkb
|
|
|
3064
3104
|
gapWidth: typeof chart.gapWidth === "number" ? chart.gapWidth : void 0,
|
|
3065
3105
|
holeSize: typeof chart.holeSize === "number" ? chart.holeSize : void 0,
|
|
3066
3106
|
id: chartId,
|
|
3067
|
-
is3d: typeof chart.
|
|
3107
|
+
is3d: typeof chart.is3D === "boolean" ? chart.is3D : void 0,
|
|
3068
3108
|
legend: normalizeLegend(chart.legend) ? {
|
|
3069
3109
|
...normalizeLegend(chart.legend),
|
|
3070
3110
|
position: normalizeLegendPosition(normalizeLegend(chart.legend)?.position)
|
|
3071
3111
|
} : null,
|
|
3072
|
-
name: typeof
|
|
3112
|
+
name: typeof drawing.name === "string" ? drawing.name : void 0,
|
|
3073
3113
|
overlap: typeof chart.overlap === "number" ? chart.overlap : void 0,
|
|
3074
3114
|
plotVisibleOnly: typeof chart.plotVisibleOnly === "boolean" ? chart.plotVisibleOnly : void 0,
|
|
3075
3115
|
raw: chart,
|
|
@@ -3103,17 +3143,23 @@ function loadWorkbookChartAssets(workbook, imageAssets, visibleSheetIndexByWorkb
|
|
|
3103
3143
|
} : void 0,
|
|
3104
3144
|
wireframe: typeof chart.wireframe === "boolean" ? chart.wireframe : void 0,
|
|
3105
3145
|
workbookSheetIndex,
|
|
3106
|
-
zIndex:
|
|
3146
|
+
zIndex: Array.isArray(drawing.drawingPath) && typeof drawing.drawingPath[0] === "number" ? drawing.drawingPath[0] + 1 : chartIndex + 1
|
|
3107
3147
|
};
|
|
3108
3148
|
});
|
|
3109
|
-
const modernCharts = rawChartsEx.map((rawChartEx, chartExIndex) =>
|
|
3110
|
-
|
|
3111
|
-
|
|
3112
|
-
|
|
3113
|
-
|
|
3114
|
-
|
|
3115
|
-
|
|
3116
|
-
|
|
3149
|
+
const modernCharts = rawChartsEx.map((rawChartEx, chartExIndex) => {
|
|
3150
|
+
const chartId = `chart-ex-${workbookSheetIndex}-${chartExIndex}`;
|
|
3151
|
+
if (rawChartEx.hidden || !rawChartEx.anchor) {
|
|
3152
|
+
excludedChartIds.add(chartId);
|
|
3153
|
+
}
|
|
3154
|
+
return normalizeChartExChart(
|
|
3155
|
+
workbook,
|
|
3156
|
+
workbookSheetIndex,
|
|
3157
|
+
visibleSheetIndex,
|
|
3158
|
+
rawChartEx,
|
|
3159
|
+
chartExIndex,
|
|
3160
|
+
imageAssets?.themePalette ?? null
|
|
3161
|
+
);
|
|
3162
|
+
});
|
|
3117
3163
|
return [...classicCharts, ...modernCharts];
|
|
3118
3164
|
});
|
|
3119
3165
|
const chartsheets = Array.isArray(workbook.chartsheets) ? workbook.chartsheets.map((entry, index) => normalizeChartsheet(entry, index)) : [];
|
|
@@ -3121,6 +3167,12 @@ function loadWorkbookChartAssets(workbook, imageAssets, visibleSheetIndexByWorkb
|
|
|
3121
3167
|
const chartOriginsById = /* @__PURE__ */ new Map();
|
|
3122
3168
|
if (imageAssets) {
|
|
3123
3169
|
applyChartOrigins(chartsByWorkbookSheetIndex, chartOriginsById, imageAssets.archive, imageAssets.sheetOrigins);
|
|
3170
|
+
for (let index = 0; index < chartsByWorkbookSheetIndex.length; index += 1) {
|
|
3171
|
+
chartsByWorkbookSheetIndex[index] = (chartsByWorkbookSheetIndex[index] ?? []).filter((chart) => !excludedChartIds.has(chart.id));
|
|
3172
|
+
}
|
|
3173
|
+
for (const id of excludedChartIds) {
|
|
3174
|
+
chartOriginsById.delete(id);
|
|
3175
|
+
}
|
|
3124
3176
|
for (const charts of chartsByWorkbookSheetIndex) {
|
|
3125
3177
|
for (const chart of charts) {
|
|
3126
3178
|
applyChartStyleFromXml(chart, chart.chartPath, imageAssets.archive, imageAssets.themePalette);
|
|
@@ -3128,6 +3180,9 @@ function loadWorkbookChartAssets(workbook, imageAssets, visibleSheetIndexByWorkb
|
|
|
3128
3180
|
}
|
|
3129
3181
|
}
|
|
3130
3182
|
} else {
|
|
3183
|
+
for (let index = 0; index < chartsByWorkbookSheetIndex.length; index += 1) {
|
|
3184
|
+
chartsByWorkbookSheetIndex[index] = (chartsByWorkbookSheetIndex[index] ?? []).filter((chart) => !excludedChartIds.has(chart.id));
|
|
3185
|
+
}
|
|
3131
3186
|
for (const charts of chartsByWorkbookSheetIndex) {
|
|
3132
3187
|
for (const chart of charts) {
|
|
3133
3188
|
applyBuiltinChartDefaults(chart, null);
|
|
@@ -3360,6 +3415,7 @@ function updateWorkbookChartAnchor(imageAssets, chartAssets, chartId, anchor) {
|
|
|
3360
3415
|
}
|
|
3361
3416
|
updateAnchorNode(anchorNode, anchor);
|
|
3362
3417
|
imageAssets.archive[normalizeArchivePath(origin.drawingPath)] = strToU8(serializeXml(drawingDocument));
|
|
3418
|
+
imageAssets.dirtyArchivePaths.add(normalizeArchivePath(origin.drawingPath));
|
|
3363
3419
|
return true;
|
|
3364
3420
|
}
|
|
3365
3421
|
function updateWorkbookChartDefinition(imageAssets, chartAssets, chartId, patch) {
|
|
@@ -3414,6 +3470,7 @@ function updateWorkbookChartDefinition(imageAssets, chartAssets, chartId, patch)
|
|
|
3414
3470
|
);
|
|
3415
3471
|
updateAxisNode(getLocalChildren(plotAreaNode, "valAx")[0] ?? null, patch.valueAxis);
|
|
3416
3472
|
imageAssets.archive[normalizeArchivePath(origin.chartPath)] = strToU8(serializeXml(chartDocument));
|
|
3473
|
+
imageAssets.dirtyArchivePaths.add(normalizeArchivePath(origin.chartPath));
|
|
3417
3474
|
return true;
|
|
3418
3475
|
}
|
|
3419
3476
|
|
|
@@ -3591,7 +3648,6 @@ var PKG_REL_NS = "http://schemas.openxmlformats.org/package/2006/relationships";
|
|
|
3591
3648
|
var SPREADSHEET_NS = "http://schemas.openxmlformats.org/spreadsheetml/2006/main";
|
|
3592
3649
|
var CONTENT_TYPES_NS = "http://schemas.openxmlformats.org/package/2006/content-types";
|
|
3593
3650
|
var DRAWING_REL_TYPE = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/drawing";
|
|
3594
|
-
var VML_DRAWING_REL_TYPE = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/vmlDrawing";
|
|
3595
3651
|
var IMAGE_REL_TYPE = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image";
|
|
3596
3652
|
var DRAWING_CONTENT_TYPE = "application/vnd.openxmlformats-officedocument.drawing+xml";
|
|
3597
3653
|
var EMU_PER_PIXEL2 = 9525;
|
|
@@ -5018,71 +5074,174 @@ function parseMarker(node) {
|
|
|
5018
5074
|
rowOffsetEmu
|
|
5019
5075
|
};
|
|
5020
5076
|
}
|
|
5021
|
-
function
|
|
5022
|
-
if (
|
|
5077
|
+
function dukeDrawingAnchorToXlsxAnchor(anchor) {
|
|
5078
|
+
if (anchor.type === "absolute") {
|
|
5079
|
+
return {
|
|
5080
|
+
kind: "absolute",
|
|
5081
|
+
positionEmu: { x: anchor.xEmu, y: anchor.yEmu },
|
|
5082
|
+
sizeEmu: { cx: anchor.widthEmu, cy: anchor.heightEmu }
|
|
5083
|
+
};
|
|
5084
|
+
}
|
|
5085
|
+
const from = {
|
|
5086
|
+
col: anchor.from.col,
|
|
5087
|
+
colOffsetEmu: anchor.from.colOffsetEmu ?? 0,
|
|
5088
|
+
row: anchor.from.row,
|
|
5089
|
+
rowOffsetEmu: anchor.from.rowOffsetEmu ?? 0
|
|
5090
|
+
};
|
|
5091
|
+
if (anchor.type === "oneCell") {
|
|
5092
|
+
return {
|
|
5093
|
+
from,
|
|
5094
|
+
kind: "one-cell",
|
|
5095
|
+
sizeEmu: { cx: anchor.widthEmu, cy: anchor.heightEmu }
|
|
5096
|
+
};
|
|
5097
|
+
}
|
|
5098
|
+
return {
|
|
5099
|
+
from,
|
|
5100
|
+
kind: "two-cell",
|
|
5101
|
+
to: {
|
|
5102
|
+
col: anchor.to.col,
|
|
5103
|
+
colOffsetEmu: anchor.to.colOffsetEmu ?? 0,
|
|
5104
|
+
row: anchor.to.row,
|
|
5105
|
+
rowOffsetEmu: anchor.to.rowOffsetEmu ?? 0
|
|
5106
|
+
}
|
|
5107
|
+
};
|
|
5108
|
+
}
|
|
5109
|
+
function xlsxAnchorToDukeDrawingAnchor(anchor, editAs) {
|
|
5110
|
+
if (anchor.kind === "absolute") {
|
|
5111
|
+
return {
|
|
5112
|
+
heightEmu: anchor.sizeEmu.cy,
|
|
5113
|
+
type: "absolute",
|
|
5114
|
+
widthEmu: anchor.sizeEmu.cx,
|
|
5115
|
+
xEmu: anchor.positionEmu.x,
|
|
5116
|
+
yEmu: anchor.positionEmu.y
|
|
5117
|
+
};
|
|
5118
|
+
}
|
|
5119
|
+
const from = {
|
|
5120
|
+
col: anchor.from.col,
|
|
5121
|
+
colOffsetEmu: anchor.from.colOffsetEmu,
|
|
5122
|
+
row: anchor.from.row,
|
|
5123
|
+
rowOffsetEmu: anchor.from.rowOffsetEmu
|
|
5124
|
+
};
|
|
5125
|
+
if (anchor.kind === "one-cell") {
|
|
5126
|
+
return {
|
|
5127
|
+
from,
|
|
5128
|
+
heightEmu: anchor.sizeEmu.cy,
|
|
5129
|
+
type: "oneCell",
|
|
5130
|
+
widthEmu: anchor.sizeEmu.cx
|
|
5131
|
+
};
|
|
5132
|
+
}
|
|
5133
|
+
return {
|
|
5134
|
+
editAs,
|
|
5135
|
+
from,
|
|
5136
|
+
to: {
|
|
5137
|
+
col: anchor.to.col,
|
|
5138
|
+
colOffsetEmu: anchor.to.colOffsetEmu,
|
|
5139
|
+
row: anchor.to.row,
|
|
5140
|
+
rowOffsetEmu: anchor.to.rowOffsetEmu
|
|
5141
|
+
},
|
|
5142
|
+
type: "twoCell"
|
|
5143
|
+
};
|
|
5144
|
+
}
|
|
5145
|
+
function mapDukeDrawingColor(color) {
|
|
5146
|
+
if (!color) {
|
|
5023
5147
|
return void 0;
|
|
5024
5148
|
}
|
|
5025
|
-
|
|
5026
|
-
|
|
5027
|
-
|
|
5149
|
+
switch (color.colorType) {
|
|
5150
|
+
case "auto":
|
|
5151
|
+
return { colorType: "auto" };
|
|
5152
|
+
case "rgb":
|
|
5153
|
+
return { b: color.b, colorType: "rgb", g: color.g, r: color.r };
|
|
5154
|
+
case "argb":
|
|
5155
|
+
return { a: color.a, b: color.b, colorType: "argb", g: color.g, r: color.r };
|
|
5156
|
+
case "theme":
|
|
5157
|
+
return { colorType: "theme", themeIndex: color.index, tint: color.tint };
|
|
5158
|
+
case "indexed":
|
|
5159
|
+
return { colorType: "indexed", paletteIndex: color.index };
|
|
5160
|
+
}
|
|
5161
|
+
}
|
|
5162
|
+
function mapDukeDrawingFont(font) {
|
|
5163
|
+
if (!font) {
|
|
5164
|
+
return void 0;
|
|
5028
5165
|
}
|
|
5029
|
-
return
|
|
5166
|
+
return {
|
|
5167
|
+
bold: font.bold,
|
|
5168
|
+
charset: font.charset,
|
|
5169
|
+
color: mapDukeDrawingColor(font.color),
|
|
5170
|
+
family: font.family,
|
|
5171
|
+
italic: font.italic,
|
|
5172
|
+
name: font.name,
|
|
5173
|
+
scheme: font.scheme,
|
|
5174
|
+
size: font.size,
|
|
5175
|
+
strikethrough: font.strikethrough,
|
|
5176
|
+
underline: font.underline,
|
|
5177
|
+
verticalAlign: font.verticalAlign
|
|
5178
|
+
};
|
|
5030
5179
|
}
|
|
5031
|
-
function
|
|
5032
|
-
|
|
5180
|
+
function mapDukeDrawingText(text) {
|
|
5181
|
+
return {
|
|
5182
|
+
horizontalAlignment: text.horizontalAlignment,
|
|
5183
|
+
runs: text.runs.map((run) => ({ font: mapDukeDrawingFont(run.font), text: run.text })),
|
|
5184
|
+
verticalAlignment: text.verticalAlignment
|
|
5185
|
+
};
|
|
5186
|
+
}
|
|
5187
|
+
function resolveDukeDrawingColor(color, themePalette) {
|
|
5188
|
+
if (!color) {
|
|
5033
5189
|
return void 0;
|
|
5034
5190
|
}
|
|
5035
|
-
|
|
5191
|
+
switch (color.colorType) {
|
|
5192
|
+
case "rgb":
|
|
5193
|
+
return resolveWorkbookColor({ rgb: [color.r, color.g, color.b].map((value) => value.toString(16).padStart(2, "0")).join("") }) ?? void 0;
|
|
5194
|
+
case "argb":
|
|
5195
|
+
return resolveWorkbookColor({ argb: [color.a, color.r, color.g, color.b].map((value) => value.toString(16).padStart(2, "0")).join("") }) ?? void 0;
|
|
5196
|
+
case "theme":
|
|
5197
|
+
return resolveWorkbookColor({ theme: color.index, tint: color.tint }, themePalette) ?? void 0;
|
|
5198
|
+
default:
|
|
5199
|
+
return void 0;
|
|
5200
|
+
}
|
|
5036
5201
|
}
|
|
5037
|
-
function
|
|
5202
|
+
function resolveDukeDrawingText(text, themePalette) {
|
|
5203
|
+
const caption = mapDukeDrawingText(text);
|
|
5204
|
+
const label = normalizeControlLabel(text.runs.map((run) => run.text).join(""));
|
|
5205
|
+
const firstStyledRun = text.runs.find((run) => run.font)?.font;
|
|
5206
|
+
const horizontalAlignment = text.horizontalAlignment;
|
|
5038
5207
|
return {
|
|
5039
|
-
|
|
5040
|
-
|
|
5041
|
-
|
|
5042
|
-
|
|
5043
|
-
|
|
5044
|
-
|
|
5045
|
-
kind: "two-cell",
|
|
5046
|
-
to: {
|
|
5047
|
-
col: anchor.toCol,
|
|
5048
|
-
colOffsetEmu: anchor.toColOffset,
|
|
5049
|
-
row: anchor.toRow,
|
|
5050
|
-
rowOffsetEmu: anchor.toRowOffset
|
|
5051
|
-
}
|
|
5208
|
+
caption,
|
|
5209
|
+
fontFamily: firstStyledRun?.name,
|
|
5210
|
+
fontSizePt: firstStyledRun?.size,
|
|
5211
|
+
label,
|
|
5212
|
+
textAlign: horizontalAlignment === "left" || horizontalAlignment === "center" || horizontalAlignment === "right" ? horizontalAlignment : void 0,
|
|
5213
|
+
textColor: resolveDukeDrawingColor(firstStyledRun?.color, themePalette)
|
|
5052
5214
|
};
|
|
5053
5215
|
}
|
|
5054
|
-
function mapDukeFormControlKind(kind) {
|
|
5216
|
+
function mapDukeFormControlKind(kind, themePalette) {
|
|
5055
5217
|
switch (kind.kind) {
|
|
5056
5218
|
case "button":
|
|
5057
|
-
return {
|
|
5219
|
+
return { ...resolveDukeDrawingText(kind.caption, themePalette), kind: "button" };
|
|
5058
5220
|
case "checkbox":
|
|
5059
5221
|
return {
|
|
5060
|
-
|
|
5222
|
+
...resolveDukeDrawingText(kind.caption, themePalette),
|
|
5061
5223
|
checked: kind.state === "checked",
|
|
5062
5224
|
kind: "checkbox",
|
|
5063
|
-
label: normalizeControlLabel(kind.caption),
|
|
5064
5225
|
linkedCell: kind.cellLink,
|
|
5065
5226
|
no3D: kind.no3D,
|
|
5066
5227
|
state: kind.state
|
|
5067
5228
|
};
|
|
5068
5229
|
case "optionButton":
|
|
5069
5230
|
return {
|
|
5070
|
-
|
|
5231
|
+
...resolveDukeDrawingText(kind.caption, themePalette),
|
|
5071
5232
|
checked: kind.state === "checked",
|
|
5072
5233
|
firstInGroup: kind.firstInGroup,
|
|
5073
5234
|
kind: "radio",
|
|
5074
|
-
label: normalizeControlLabel(kind.caption),
|
|
5075
5235
|
linkedCell: kind.cellLink,
|
|
5076
5236
|
no3D: kind.no3D,
|
|
5077
5237
|
state: kind.state
|
|
5078
5238
|
};
|
|
5079
5239
|
case "label":
|
|
5080
|
-
return {
|
|
5240
|
+
return { ...resolveDukeDrawingText(kind.caption, themePalette), kind: "label" };
|
|
5081
5241
|
case "groupBox":
|
|
5082
5242
|
return {
|
|
5083
|
-
|
|
5243
|
+
...resolveDukeDrawingText(kind.caption, themePalette),
|
|
5084
5244
|
kind: "group-box",
|
|
5085
|
-
label: normalizeControlLabel(kind.caption),
|
|
5086
5245
|
no3D: kind.no3D
|
|
5087
5246
|
};
|
|
5088
5247
|
case "listBox":
|
|
@@ -5123,92 +5282,47 @@ function mapDukeFormControlKind(kind) {
|
|
|
5123
5282
|
min: kind.min,
|
|
5124
5283
|
value: kind.value
|
|
5125
5284
|
};
|
|
5285
|
+
case "unknown":
|
|
5286
|
+
return {
|
|
5287
|
+
...resolveDukeDrawingText(kind.caption, themePalette),
|
|
5288
|
+
kind: kind.objectType.toLowerCase() === "editbox" ? "editbox" : "unknown",
|
|
5289
|
+
legacyObjectType: kind.legacyObjectType,
|
|
5290
|
+
objectType: kind.objectType,
|
|
5291
|
+
rawObj: kind.rawObj,
|
|
5292
|
+
rawProperties: kind.rawProperties
|
|
5293
|
+
};
|
|
5126
5294
|
}
|
|
5127
5295
|
}
|
|
5128
|
-
function mapDukeFormControl(control, controlIndex, workbookSheetIndex) {
|
|
5296
|
+
function mapDukeFormControl(control, controlIndex, workbookSheetIndex, themePalette) {
|
|
5129
5297
|
return {
|
|
5130
|
-
|
|
5298
|
+
altText: control.altText,
|
|
5299
|
+
anchor: dukeDrawingAnchorToXlsxAnchor(control.anchor),
|
|
5131
5300
|
controlIndex,
|
|
5132
|
-
|
|
5133
|
-
|
|
5134
|
-
hidden: false,
|
|
5301
|
+
editAs: control.anchor.type === "twoCell" ? control.anchor.editAs : void 0,
|
|
5302
|
+
hidden: control.hidden,
|
|
5135
5303
|
id: `form-control-${workbookSheetIndex}-${controlIndex}`,
|
|
5136
5304
|
locked: control.locked,
|
|
5305
|
+
macroName: control.formControl.macroName,
|
|
5137
5306
|
name: control.name,
|
|
5138
5307
|
printable: control.printable,
|
|
5308
|
+
rawClientData: control.formControl.rawClientData,
|
|
5139
5309
|
sheetIndex: workbookSheetIndex,
|
|
5310
|
+
title: control.title,
|
|
5140
5311
|
workbookSheetIndex,
|
|
5141
|
-
zIndex: controlIndex + 1,
|
|
5142
|
-
...mapDukeFormControlKind(control.kind)
|
|
5312
|
+
zIndex: (control.drawingPath[0] ?? controlIndex) + 1,
|
|
5313
|
+
...mapDukeFormControlKind(control.formControl.kind, themePalette)
|
|
5143
5314
|
};
|
|
5144
5315
|
}
|
|
5145
|
-
function collectWorkbookFormControls(workbook) {
|
|
5316
|
+
function collectWorkbookFormControls(workbook, themePalette) {
|
|
5146
5317
|
return Array.from({ length: workbook.sheetCount }, (_, workbookSheetIndex) => {
|
|
5147
5318
|
try {
|
|
5148
5319
|
const controls = workbook.getSheet(workbookSheetIndex).formControls;
|
|
5149
|
-
return Array.isArray(controls) ? controls.
|
|
5320
|
+
return Array.isArray(controls) ? controls.flatMap((control, controlIndex) => control.anchor ? [mapDukeFormControl(control, controlIndex, workbookSheetIndex, themePalette)] : []) : [];
|
|
5150
5321
|
} catch {
|
|
5151
5322
|
return [];
|
|
5152
5323
|
}
|
|
5153
5324
|
});
|
|
5154
5325
|
}
|
|
5155
|
-
function parseFormControlKind(rawType) {
|
|
5156
|
-
const normalized = (rawType ?? "").trim().toLowerCase();
|
|
5157
|
-
switch (normalized) {
|
|
5158
|
-
case "button":
|
|
5159
|
-
return "button";
|
|
5160
|
-
case "checkbox":
|
|
5161
|
-
return "checkbox";
|
|
5162
|
-
case "drop":
|
|
5163
|
-
return "dropdown";
|
|
5164
|
-
case "editbox":
|
|
5165
|
-
return "editbox";
|
|
5166
|
-
case "gbox":
|
|
5167
|
-
return "group-box";
|
|
5168
|
-
case "label":
|
|
5169
|
-
return "label";
|
|
5170
|
-
case "list":
|
|
5171
|
-
return "listbox";
|
|
5172
|
-
case "radio":
|
|
5173
|
-
return "radio";
|
|
5174
|
-
case "scroll":
|
|
5175
|
-
return "scrollbar";
|
|
5176
|
-
case "spin":
|
|
5177
|
-
return "spinner";
|
|
5178
|
-
default:
|
|
5179
|
-
return "unknown";
|
|
5180
|
-
}
|
|
5181
|
-
}
|
|
5182
|
-
function parseFormControlShapeId(value) {
|
|
5183
|
-
const match = (value ?? "").match(/(\d+)(?!.*\d)/);
|
|
5184
|
-
if (!match) {
|
|
5185
|
-
return null;
|
|
5186
|
-
}
|
|
5187
|
-
const parsed = Number(match[1]);
|
|
5188
|
-
return Number.isFinite(parsed) ? parsed : null;
|
|
5189
|
-
}
|
|
5190
|
-
function parseCssDeclarationValue(styleText, property) {
|
|
5191
|
-
if (!styleText) {
|
|
5192
|
-
return null;
|
|
5193
|
-
}
|
|
5194
|
-
const pattern = new RegExp(`${property}\\s*:\\s*([^;]+)`, "i");
|
|
5195
|
-
const match = pattern.exec(styleText);
|
|
5196
|
-
return match?.[1]?.trim() ?? null;
|
|
5197
|
-
}
|
|
5198
|
-
function parseControlTextAlign(styleText) {
|
|
5199
|
-
const value = parseCssDeclarationValue(styleText, "text-align")?.toLowerCase();
|
|
5200
|
-
if (value === "center" || value === "right") {
|
|
5201
|
-
return value;
|
|
5202
|
-
}
|
|
5203
|
-
return value === "left" ? "left" : void 0;
|
|
5204
|
-
}
|
|
5205
|
-
function parseVmlFontSizePt(value) {
|
|
5206
|
-
const parsed = Number(value ?? Number.NaN);
|
|
5207
|
-
if (!Number.isFinite(parsed) || parsed <= 0) {
|
|
5208
|
-
return void 0;
|
|
5209
|
-
}
|
|
5210
|
-
return parsed > 40 ? parsed / 20 : parsed;
|
|
5211
|
-
}
|
|
5212
5326
|
function normalizeControlLabel(label) {
|
|
5213
5327
|
if (!label) {
|
|
5214
5328
|
return void 0;
|
|
@@ -5216,16 +5330,6 @@ function normalizeControlLabel(label) {
|
|
|
5216
5330
|
const normalized = label.replace(/\u00a0/g, " ").replace(/\s+/g, " ").trim();
|
|
5217
5331
|
return normalized.length > 0 ? normalized : void 0;
|
|
5218
5332
|
}
|
|
5219
|
-
function isPlaceholderFormControlName(name) {
|
|
5220
|
-
const normalized = normalizeControlLabel(name)?.toLowerCase();
|
|
5221
|
-
if (!normalized) {
|
|
5222
|
-
return false;
|
|
5223
|
-
}
|
|
5224
|
-
return /^(option button|group box|check box|drop down|dropdown|list box|edit box|scroll bar|spinner|spin button|button)\s+\d+$/.test(normalized);
|
|
5225
|
-
}
|
|
5226
|
-
function resolveNamedFormControlLabel(name) {
|
|
5227
|
-
return isPlaceholderFormControlName(name) ? void 0 : normalizeControlLabel(name);
|
|
5228
|
-
}
|
|
5229
5333
|
function parseAnchor(anchorNode) {
|
|
5230
5334
|
if (anchorNode.localName === "anchor") {
|
|
5231
5335
|
const from = parseMarker(getFirstChild(anchorNode, "from"));
|
|
@@ -5906,260 +6010,8 @@ function parseDrawingObjects(archive, contentTypes, drawingPath, objectUrls, wor
|
|
|
5906
6010
|
shapes
|
|
5907
6011
|
};
|
|
5908
6012
|
}
|
|
5909
|
-
function
|
|
5910
|
-
|
|
5911
|
-
if (!sheetXml) {
|
|
5912
|
-
return [];
|
|
5913
|
-
}
|
|
5914
|
-
const sheetDocument = parseXml2(sheetXml);
|
|
5915
|
-
if (!sheetDocument) {
|
|
5916
|
-
return [];
|
|
5917
|
-
}
|
|
5918
|
-
return getLocalElements(sheetDocument, "control").map((controlNode) => ({
|
|
5919
|
-
anchor: parseAnchor(getFirstDescendant(controlNode, "anchor") ?? controlNode),
|
|
5920
|
-
name: controlNode.getAttribute("name") ?? void 0,
|
|
5921
|
-
shapeId: parseFormControlShapeId(controlNode.getAttribute("shapeId"))
|
|
5922
|
-
}));
|
|
5923
|
-
}
|
|
5924
|
-
function parseVmlFormControls(archive, vmlDrawingPath) {
|
|
5925
|
-
const xml = readArchiveText2(archive, vmlDrawingPath);
|
|
5926
|
-
if (!xml) {
|
|
5927
|
-
return /* @__PURE__ */ new Map();
|
|
5928
|
-
}
|
|
5929
|
-
const document2 = parseXml2(xml);
|
|
5930
|
-
if (!document2) {
|
|
5931
|
-
return /* @__PURE__ */ new Map();
|
|
5932
|
-
}
|
|
5933
|
-
const controls = /* @__PURE__ */ new Map();
|
|
5934
|
-
for (const shapeNode of getLocalElements(document2, "shape")) {
|
|
5935
|
-
const clientDataNode = getFirstChild(shapeNode, "ClientData");
|
|
5936
|
-
if (!clientDataNode) {
|
|
5937
|
-
continue;
|
|
5938
|
-
}
|
|
5939
|
-
const shapeId = parseFormControlShapeId(
|
|
5940
|
-
shapeNode.getAttributeNS("urn:schemas-microsoft-com:office:office", "spid") ?? shapeNode.getAttribute("o:spid") ?? shapeNode.getAttribute("spid") ?? shapeNode.getAttribute("id")
|
|
5941
|
-
);
|
|
5942
|
-
if (shapeId === null) {
|
|
5943
|
-
continue;
|
|
5944
|
-
}
|
|
5945
|
-
const styleText = shapeNode.getAttribute("style");
|
|
5946
|
-
const textboxNode = getFirstChild(shapeNode, "textbox");
|
|
5947
|
-
const fontNode = textboxNode ? getFirstDescendant(textboxNode, "font") : null;
|
|
5948
|
-
const textContainerNode = textboxNode ? getFirstDescendant(textboxNode, "div") : null;
|
|
5949
|
-
const label = normalizeControlLabel(textboxNode?.textContent);
|
|
5950
|
-
const zIndex = Number(parseCssDeclarationValue(styleText, "z-index") ?? Number.NaN);
|
|
5951
|
-
controls.set(shapeId, {
|
|
5952
|
-
checked: parseSpreadsheetBooleanNode(getFirstChild(clientDataNode, "Checked")),
|
|
5953
|
-
fontFamily: fontNode?.getAttribute("face") ?? void 0,
|
|
5954
|
-
fontSizePt: parseVmlFontSizePt(fontNode?.getAttribute("size")),
|
|
5955
|
-
hidden: (parseCssDeclarationValue(styleText, "visibility") ?? "").toLowerCase() === "hidden",
|
|
5956
|
-
label,
|
|
5957
|
-
linkedCell: normalizeControlLabel(getFirstChild(clientDataNode, "FmlaLink")?.textContent),
|
|
5958
|
-
objectType: clientDataNode.getAttribute("ObjectType") ?? void 0,
|
|
5959
|
-
shapeId,
|
|
5960
|
-
textAlign: parseControlTextAlign(textContainerNode?.getAttribute("style")),
|
|
5961
|
-
textColor: fontNode?.getAttribute("color") ?? void 0,
|
|
5962
|
-
zIndex: Number.isFinite(zIndex) ? zIndex : controls.size + 1
|
|
5963
|
-
});
|
|
5964
|
-
}
|
|
5965
|
-
return controls;
|
|
5966
|
-
}
|
|
5967
|
-
function parseSheetFormControls(archive, sheetPath, sheetRelationships, workbookSheetIndex, zIndexBase) {
|
|
5968
|
-
const controlNodes = parseSheetFormControlNodes(archive, sheetPath);
|
|
5969
|
-
if (controlNodes.length === 0) {
|
|
5970
|
-
return [];
|
|
5971
|
-
}
|
|
5972
|
-
const legacyDrawingRelationship = [...sheetRelationships.values()].find(
|
|
5973
|
-
(relationship) => relationship.type === VML_DRAWING_REL_TYPE
|
|
5974
|
-
);
|
|
5975
|
-
const vmlControlsByShapeId = legacyDrawingRelationship ? parseVmlFormControls(archive, legacyDrawingRelationship.target) : /* @__PURE__ */ new Map();
|
|
5976
|
-
const parsedControls = [];
|
|
5977
|
-
controlNodes.forEach((controlNode, index) => {
|
|
5978
|
-
if (!controlNode.anchor) {
|
|
5979
|
-
return;
|
|
5980
|
-
}
|
|
5981
|
-
const vmlControl = controlNode.shapeId !== null ? vmlControlsByShapeId.get(controlNode.shapeId) ?? null : null;
|
|
5982
|
-
const kind = parseFormControlKind(vmlControl?.objectType);
|
|
5983
|
-
parsedControls.push({
|
|
5984
|
-
anchor: controlNode.anchor,
|
|
5985
|
-
checked: vmlControl?.checked,
|
|
5986
|
-
fontFamily: vmlControl?.fontFamily,
|
|
5987
|
-
fontSizePt: vmlControl?.fontSizePt,
|
|
5988
|
-
hidden: vmlControl?.hidden ?? false,
|
|
5989
|
-
id: `form-control-${workbookSheetIndex}-${index}`,
|
|
5990
|
-
kind,
|
|
5991
|
-
label: vmlControl?.label,
|
|
5992
|
-
linkedCell: vmlControl?.linkedCell,
|
|
5993
|
-
name: controlNode.name,
|
|
5994
|
-
sheetIndex: workbookSheetIndex,
|
|
5995
|
-
textAlign: vmlControl?.textAlign,
|
|
5996
|
-
textColor: vmlControl?.textColor,
|
|
5997
|
-
workbookSheetIndex,
|
|
5998
|
-
zIndex: zIndexBase + (vmlControl?.zIndex ?? index + 1)
|
|
5999
|
-
});
|
|
6000
|
-
});
|
|
6001
|
-
return parsedControls.sort((left, right) => left.zIndex - right.zIndex);
|
|
6002
|
-
}
|
|
6003
|
-
function flattenShapeText(shape) {
|
|
6004
|
-
const text = shape.paragraphs.flatMap((paragraph) => paragraph.runs.map((run) => run.text)).join(" ");
|
|
6005
|
-
return normalizeControlLabel(text);
|
|
6006
|
-
}
|
|
6007
|
-
function rectArea(rect) {
|
|
6008
|
-
return Math.max(0, rect.cx) * Math.max(0, rect.cy);
|
|
6009
|
-
}
|
|
6010
|
-
function rectIntersectionArea(left, right) {
|
|
6011
|
-
const overlapX = Math.max(0, Math.min(left.x + left.cx, right.x + right.cx) - Math.max(left.x, right.x));
|
|
6012
|
-
const overlapY = Math.max(0, Math.min(left.y + left.cy, right.y + right.cy) - Math.max(left.y, right.y));
|
|
6013
|
-
return overlapX * overlapY;
|
|
6014
|
-
}
|
|
6015
|
-
function rectCenterDistance(left, right) {
|
|
6016
|
-
const leftCenterX = left.x + left.cx / 2;
|
|
6017
|
-
const leftCenterY = left.y + left.cy / 2;
|
|
6018
|
-
const rightCenterX = right.x + right.cx / 2;
|
|
6019
|
-
const rightCenterY = right.y + right.cy / 2;
|
|
6020
|
-
return Math.hypot(leftCenterX - rightCenterX, leftCenterY - rightCenterY);
|
|
6021
|
-
}
|
|
6022
|
-
function findHiddenShapeControlMatch(control, shapes, sheetState) {
|
|
6023
|
-
const controlRect = anchorToAbsoluteRect(control.anchor, sheetState);
|
|
6024
|
-
const controlArea = Math.max(1, rectArea(controlRect));
|
|
6025
|
-
const placeholderName = isPlaceholderFormControlName(control.name);
|
|
6026
|
-
let bestMatch = null;
|
|
6027
|
-
let bestScore = Number.NEGATIVE_INFINITY;
|
|
6028
|
-
shapes.forEach((shape) => {
|
|
6029
|
-
if (!shape.hidden) {
|
|
6030
|
-
return;
|
|
6031
|
-
}
|
|
6032
|
-
const shapeRect = anchorToAbsoluteRect(shape.anchor, sheetState);
|
|
6033
|
-
const shapeArea = Math.max(1, rectArea(shapeRect));
|
|
6034
|
-
const intersectionArea = rectIntersectionArea(controlRect, shapeRect);
|
|
6035
|
-
const overlapScore = intersectionArea / Math.min(controlArea, shapeArea);
|
|
6036
|
-
const distance = rectCenterDistance(controlRect, shapeRect);
|
|
6037
|
-
const maxDimension = Math.max(controlRect.cx, controlRect.cy, shapeRect.cx, shapeRect.cy, 1);
|
|
6038
|
-
const distanceScore = distance / maxDimension;
|
|
6039
|
-
const textLabel = flattenShapeText(shape);
|
|
6040
|
-
const sameName = normalizeControlLabel(shape.name)?.toLowerCase() === normalizeControlLabel(control.name)?.toLowerCase();
|
|
6041
|
-
let score = overlapScore * 4 - distanceScore;
|
|
6042
|
-
if (sameName) {
|
|
6043
|
-
score += 1;
|
|
6044
|
-
}
|
|
6045
|
-
if (control.kind === "group-box") {
|
|
6046
|
-
score += textLabel ? -3 : 0.5;
|
|
6047
|
-
score += shape.stroke?.none ? -1.5 : 0.75;
|
|
6048
|
-
} else {
|
|
6049
|
-
score += textLabel ? 2 : -1;
|
|
6050
|
-
score += shape.stroke?.none ? 0.2 : -0.5;
|
|
6051
|
-
}
|
|
6052
|
-
if (!placeholderName && textLabel && textLabel === resolveNamedFormControlLabel(control.name)) {
|
|
6053
|
-
score += 0.5;
|
|
6054
|
-
}
|
|
6055
|
-
if (score > bestScore) {
|
|
6056
|
-
bestMatch = shape;
|
|
6057
|
-
bestScore = score;
|
|
6058
|
-
}
|
|
6059
|
-
});
|
|
6060
|
-
return bestScore >= 0.25 ? bestMatch : null;
|
|
6061
|
-
}
|
|
6062
|
-
function enrichFormControlsWithHiddenShapes(formControls, shapes, sheetState) {
|
|
6063
|
-
return formControls.map((control) => {
|
|
6064
|
-
const matchedShape = findHiddenShapeControlMatch(control, shapes, sheetState);
|
|
6065
|
-
const matchedLabel = matchedShape ? flattenShapeText(matchedShape) : void 0;
|
|
6066
|
-
const fallbackLabel = resolveNamedFormControlLabel(control.name);
|
|
6067
|
-
let resolvedAnchor = control.anchor;
|
|
6068
|
-
if (matchedShape && (control.kind === "group-box" || matchedLabel || isPlaceholderFormControlName(control.name))) {
|
|
6069
|
-
resolvedAnchor = matchedShape.anchor;
|
|
6070
|
-
}
|
|
6071
|
-
return {
|
|
6072
|
-
...control,
|
|
6073
|
-
anchor: resolvedAnchor,
|
|
6074
|
-
label: control.label ?? matchedLabel ?? fallbackLabel
|
|
6075
|
-
};
|
|
6076
|
-
});
|
|
6077
|
-
}
|
|
6078
|
-
function getFormControlAnchorStart(anchor) {
|
|
6079
|
-
return anchor.kind === "absolute" ? null : { col: anchor.from.col, row: anchor.from.row };
|
|
6080
|
-
}
|
|
6081
|
-
function scoreParsedFormControlMatch(dukeControl, parsedControl, parsedIndex) {
|
|
6082
|
-
if (dukeControl.kind !== parsedControl.kind && parsedControl.kind !== "unknown") {
|
|
6083
|
-
return Number.NEGATIVE_INFINITY;
|
|
6084
|
-
}
|
|
6085
|
-
let score = 10;
|
|
6086
|
-
const dukeName = normalizeControlLabel(dukeControl.name)?.toLowerCase();
|
|
6087
|
-
const parsedName = normalizeControlLabel(parsedControl.name)?.toLowerCase();
|
|
6088
|
-
if (dukeName && parsedName) {
|
|
6089
|
-
if (dukeName !== parsedName) {
|
|
6090
|
-
return Number.NEGATIVE_INFINITY;
|
|
6091
|
-
}
|
|
6092
|
-
score += 100;
|
|
6093
|
-
}
|
|
6094
|
-
const dukeStart = getFormControlAnchorStart(dukeControl.anchor);
|
|
6095
|
-
const parsedStart = getFormControlAnchorStart(parsedControl.anchor);
|
|
6096
|
-
if (dukeStart && parsedStart && dukeStart.col === parsedStart.col && dukeStart.row === parsedStart.row) {
|
|
6097
|
-
score += 40;
|
|
6098
|
-
}
|
|
6099
|
-
if (dukeControl.controlIndex === parsedIndex) {
|
|
6100
|
-
score += 5;
|
|
6101
|
-
}
|
|
6102
|
-
return score;
|
|
6103
|
-
}
|
|
6104
|
-
function areDukeFormControlAnchorsEqual(left, right) {
|
|
6105
|
-
if (!left || !right) {
|
|
6106
|
-
return true;
|
|
6107
|
-
}
|
|
6108
|
-
return left.editAs === right.editAs && left.fromCol === right.fromCol && left.fromColOffset === right.fromColOffset && left.fromRow === right.fromRow && left.fromRowOffset === right.fromRowOffset && left.toCol === right.toCol && left.toColOffset === right.toColOffset && left.toRow === right.toRow && left.toRowOffset === right.toRowOffset;
|
|
6109
|
-
}
|
|
6110
|
-
function mergeDukeAndParsedFormControls(dukeControls, parsedControls, keepUnmatchedParsedControl = () => true) {
|
|
6111
|
-
const usedParsedIndexes = /* @__PURE__ */ new Set();
|
|
6112
|
-
const mergedControls = dukeControls.map((dukeControl) => {
|
|
6113
|
-
let bestIndex = -1;
|
|
6114
|
-
let bestScore = Number.NEGATIVE_INFINITY;
|
|
6115
|
-
parsedControls.forEach((parsedControl2, parsedIndex) => {
|
|
6116
|
-
if (usedParsedIndexes.has(parsedIndex)) {
|
|
6117
|
-
return;
|
|
6118
|
-
}
|
|
6119
|
-
const score = scoreParsedFormControlMatch(dukeControl, parsedControl2, parsedIndex);
|
|
6120
|
-
if (score > bestScore) {
|
|
6121
|
-
bestIndex = parsedIndex;
|
|
6122
|
-
bestScore = score;
|
|
6123
|
-
}
|
|
6124
|
-
});
|
|
6125
|
-
const parsedControl = bestIndex >= 0 && bestScore >= 10 ? parsedControls[bestIndex] : null;
|
|
6126
|
-
if (!parsedControl) {
|
|
6127
|
-
return dukeControl;
|
|
6128
|
-
}
|
|
6129
|
-
usedParsedIndexes.add(bestIndex);
|
|
6130
|
-
const dukeAnchorChanged = !areDukeFormControlAnchorsEqual(
|
|
6131
|
-
parsedControl.dukeAnchor,
|
|
6132
|
-
dukeControl.dukeAnchor
|
|
6133
|
-
);
|
|
6134
|
-
return {
|
|
6135
|
-
...parsedControl,
|
|
6136
|
-
...dukeControl,
|
|
6137
|
-
anchor: dukeAnchorChanged ? dukeControl.anchor : parsedControl.anchor,
|
|
6138
|
-
fontFamily: parsedControl.fontFamily,
|
|
6139
|
-
fontSizePt: parsedControl.fontSizePt,
|
|
6140
|
-
hidden: parsedControl.hidden,
|
|
6141
|
-
id: parsedControl.id,
|
|
6142
|
-
label: dukeControl.label ?? parsedControl.label,
|
|
6143
|
-
name: dukeControl.name ?? parsedControl.name,
|
|
6144
|
-
textAlign: parsedControl.textAlign,
|
|
6145
|
-
textColor: parsedControl.textColor,
|
|
6146
|
-
zIndex: parsedControl.zIndex
|
|
6147
|
-
};
|
|
6148
|
-
});
|
|
6149
|
-
parsedControls.forEach((parsedControl, parsedIndex) => {
|
|
6150
|
-
if (!usedParsedIndexes.has(parsedIndex) && keepUnmatchedParsedControl(parsedControl)) {
|
|
6151
|
-
mergedControls.push(parsedControl);
|
|
6152
|
-
}
|
|
6153
|
-
});
|
|
6154
|
-
return mergedControls.sort((left, right) => left.zIndex - right.zIndex);
|
|
6155
|
-
}
|
|
6156
|
-
function refreshWorkbookFormControls(workbook, currentControlsByWorkbookSheetIndex) {
|
|
6157
|
-
const dukeControlsByWorkbookSheetIndex = collectWorkbookFormControls(workbook);
|
|
6158
|
-
return dukeControlsByWorkbookSheetIndex.map((dukeControls, workbookSheetIndex) => mergeDukeAndParsedFormControls(
|
|
6159
|
-
dukeControls,
|
|
6160
|
-
currentControlsByWorkbookSheetIndex[workbookSheetIndex] ?? [],
|
|
6161
|
-
(control) => control.controlIndex === void 0
|
|
6162
|
-
));
|
|
6013
|
+
function refreshWorkbookFormControls(workbook, _currentControlsByWorkbookSheetIndex, themePalette) {
|
|
6014
|
+
return collectWorkbookFormControls(workbook, themePalette);
|
|
6163
6015
|
}
|
|
6164
6016
|
function revokeWorkbookImageAssets(assets) {
|
|
6165
6017
|
if (!assets) {
|
|
@@ -6193,7 +6045,7 @@ function parseWorkbookStructureAssetsFromArchive(archive, options) {
|
|
|
6193
6045
|
workbookSheets
|
|
6194
6046
|
};
|
|
6195
6047
|
}
|
|
6196
|
-
function parseWorkbookImageAssets(bytes,
|
|
6048
|
+
function parseWorkbookImageAssets(bytes, workbook) {
|
|
6197
6049
|
const archive = unzipSync(bytes);
|
|
6198
6050
|
const {
|
|
6199
6051
|
contentTypes,
|
|
@@ -6212,7 +6064,7 @@ function parseWorkbookImageAssets(bytes, workbookOrFormControls) {
|
|
|
6212
6064
|
const shapesByWorkbookSheetIndex = [];
|
|
6213
6065
|
const sheetOrigins = [];
|
|
6214
6066
|
const imageOriginsById = /* @__PURE__ */ new Map();
|
|
6215
|
-
const
|
|
6067
|
+
const formControls = workbook ? collectWorkbookFormControls(workbook, themePalette) : [];
|
|
6216
6068
|
workbookSheets.forEach((sheet, workbookSheetIndex) => {
|
|
6217
6069
|
const sheetRelationships = parseRelationships(archive, relsPathForDocument(sheet.path), sheet.path);
|
|
6218
6070
|
const attachments = [];
|
|
@@ -6245,23 +6097,8 @@ function parseWorkbookImageAssets(bytes, workbookOrFormControls) {
|
|
|
6245
6097
|
mediaPaths: drawingImages.mediaPaths
|
|
6246
6098
|
});
|
|
6247
6099
|
}
|
|
6248
|
-
const formControlList = parseSheetFormControls(
|
|
6249
|
-
archive,
|
|
6250
|
-
sheet.path,
|
|
6251
|
-
sheetRelationships,
|
|
6252
|
-
workbookSheetIndex,
|
|
6253
|
-
zIndexBase
|
|
6254
|
-
);
|
|
6255
6100
|
const visibleShapeList = shapeList.filter((shape) => !shape.hidden);
|
|
6256
|
-
|
|
6257
|
-
formControlList,
|
|
6258
|
-
shapeList,
|
|
6259
|
-
sheetStatesByWorkbookSheetIndex[workbookSheetIndex] ?? null
|
|
6260
|
-
);
|
|
6261
|
-
formControlsByWorkbookSheetIndex[workbookSheetIndex] = mergeDukeAndParsedFormControls(
|
|
6262
|
-
dukeFormControlsByWorkbookSheetIndex[workbookSheetIndex] ?? [],
|
|
6263
|
-
enrichedFormControlList
|
|
6264
|
-
);
|
|
6101
|
+
formControlsByWorkbookSheetIndex[workbookSheetIndex] = formControls[workbookSheetIndex] ?? [];
|
|
6265
6102
|
imagesByWorkbookSheetIndex[workbookSheetIndex] = imageList;
|
|
6266
6103
|
shapesByWorkbookSheetIndex[workbookSheetIndex] = visibleShapeList;
|
|
6267
6104
|
sheetOrigins[workbookSheetIndex] = attachments.length > 0 ? {
|
|
@@ -6271,6 +6108,7 @@ function parseWorkbookImageAssets(bytes, workbookOrFormControls) {
|
|
|
6271
6108
|
});
|
|
6272
6109
|
return {
|
|
6273
6110
|
archive,
|
|
6111
|
+
dirtyArchivePaths: /* @__PURE__ */ new Set(),
|
|
6274
6112
|
formControlsByWorkbookSheetIndex,
|
|
6275
6113
|
imageOriginsById,
|
|
6276
6114
|
imagesByWorkbookSheetIndex,
|
|
@@ -6333,6 +6171,7 @@ function updateWorkbookImageAnchor(assets, imageId, anchor) {
|
|
|
6333
6171
|
}
|
|
6334
6172
|
updateAnchorNode2(anchorNode, anchor);
|
|
6335
6173
|
assets.archive[attachment.drawingPath] = strToU82(serializeXml2(drawingDocument));
|
|
6174
|
+
assets.dirtyArchivePaths.add(normalizeArchivePath2(attachment.drawingPath));
|
|
6336
6175
|
const imageList = assets.imagesByWorkbookSheetIndex[origin.workbookSheetIndex] ?? [];
|
|
6337
6176
|
const imageIndex = imageList.findIndex((image) => image.id === imageId);
|
|
6338
6177
|
if (imageIndex >= 0) {
|
|
@@ -6449,7 +6288,7 @@ function appendSheetDrawingReference(sheetDocument, relationshipId) {
|
|
|
6449
6288
|
worksheet.appendChild(drawingNode);
|
|
6450
6289
|
}
|
|
6451
6290
|
function mergeWorkbookImageAssets(savedBytes, sourceAssets, sheetOrigins) {
|
|
6452
|
-
if (!sourceAssets ||
|
|
6291
|
+
if (!sourceAssets || sourceAssets.dirtyArchivePaths.size === 0) {
|
|
6453
6292
|
return cloneBytes(savedBytes);
|
|
6454
6293
|
}
|
|
6455
6294
|
try {
|
|
@@ -6461,7 +6300,8 @@ function mergeWorkbookImageAssets(savedBytes, sourceAssets, sheetOrigins) {
|
|
|
6461
6300
|
return cloneBytes(savedBytes);
|
|
6462
6301
|
}
|
|
6463
6302
|
sheetOrigins.forEach((origin, workbookSheetIndex) => {
|
|
6464
|
-
|
|
6303
|
+
const hasDirtyAttachment = origin?.attachments.some((attachment) => sourceAssets.dirtyArchivePaths.has(normalizeArchivePath2(attachment.drawingPath)) || attachment.drawingRelsPath && sourceAssets.dirtyArchivePaths.has(normalizeArchivePath2(attachment.drawingRelsPath)) || attachment.mediaPaths.some((path) => sourceAssets.dirtyArchivePaths.has(normalizeArchivePath2(path))));
|
|
6304
|
+
if (!origin?.attachments.length || !hasDirtyAttachment) {
|
|
6465
6305
|
return;
|
|
6466
6306
|
}
|
|
6467
6307
|
const currentSheet = workbookSheets[workbookSheetIndex];
|
|
@@ -6513,6 +6353,14 @@ function mergeWorkbookImageAssets(savedBytes, sourceAssets, sheetOrigins) {
|
|
|
6513
6353
|
archive[relsPath] = strToU82(serializeXml2(relDocument));
|
|
6514
6354
|
mergeContentTypeForPath(targetContentTypesDocument, originalContentTypesDocument, relsPath);
|
|
6515
6355
|
});
|
|
6356
|
+
for (const dirtyPath of sourceAssets.dirtyArchivePaths) {
|
|
6357
|
+
const bytes = sourceAssets.archive[dirtyPath];
|
|
6358
|
+
if (!bytes) {
|
|
6359
|
+
continue;
|
|
6360
|
+
}
|
|
6361
|
+
archive[dirtyPath] = cloneBytes(bytes);
|
|
6362
|
+
mergeContentTypeForPath(targetContentTypesDocument, originalContentTypesDocument, dirtyPath);
|
|
6363
|
+
}
|
|
6516
6364
|
const hasDrawingOverride = getLocalElements(targetContentTypesDocument, "Override").some(
|
|
6517
6365
|
(node) => node.getAttribute("ContentType") === DRAWING_CONTENT_TYPE
|
|
6518
6366
|
);
|
|
@@ -6918,8 +6766,6 @@ var DEFAULT_MAX_FILE_SIZE_BYTES = 25 * 1024 * 1024;
|
|
|
6918
6766
|
var MAX_INTERACTIVE_WORKSHEET_XML_BYTES = 200 * 1024 * 1024;
|
|
6919
6767
|
var MAX_INTERACTIVE_SHARED_STRINGS_BYTES = 50 * 1024 * 1024;
|
|
6920
6768
|
var MAX_INTERACTIVE_TOTAL_XML_BYTES = 256 * 1024 * 1024;
|
|
6921
|
-
var EMU_PER_PIXEL3 = 9525;
|
|
6922
|
-
var IMAGE_BATCH_ROW_COUNT = 256;
|
|
6923
6769
|
var DEFAULT_ZOOM_SCALE = 100;
|
|
6924
6770
|
var MIN_ZOOM_SCALE = 10;
|
|
6925
6771
|
var MAX_ZOOM_SCALE = 400;
|
|
@@ -7374,104 +7220,175 @@ function resolveWorkbookReference(workbook, defaultWorkbookSheetIndex, rawRefere
|
|
|
7374
7220
|
return null;
|
|
7375
7221
|
}
|
|
7376
7222
|
}
|
|
7377
|
-
function
|
|
7378
|
-
|
|
7379
|
-
|
|
7380
|
-
kind: { ...control.kind },
|
|
7381
|
-
locked: control.locked,
|
|
7382
|
-
name: control.name,
|
|
7383
|
-
printable: control.printable
|
|
7384
|
-
};
|
|
7223
|
+
function parseColorHex(hex) {
|
|
7224
|
+
const normalized = hex?.replace(/^#/, "");
|
|
7225
|
+
return normalized && /^[0-9a-f]{6}$/i.test(normalized) ? [0, 2, 4].map((offset) => Number.parseInt(normalized.slice(offset, offset + 2), 16)) : null;
|
|
7385
7226
|
}
|
|
7386
|
-
function
|
|
7387
|
-
|
|
7227
|
+
function xlsxColorToDukeColor(color) {
|
|
7228
|
+
if (!color) {
|
|
7229
|
+
return void 0;
|
|
7230
|
+
}
|
|
7231
|
+
const normalizedHex = color.hex?.replace(/^#/, "");
|
|
7232
|
+
const colorType = color.colorType ?? (normalizedHex?.length === 8 ? "argb" : normalizedHex?.length === 6 ? "rgb" : void 0) ?? (color.r !== void 0 && color.g !== void 0 && color.b !== void 0 ? color.a !== void 0 ? "argb" : "rgb" : void 0) ?? (color.themeIndex !== void 0 ? "theme" : color.paletteIndex !== void 0 ? "indexed" : void 0);
|
|
7233
|
+
switch (colorType) {
|
|
7234
|
+
case "auto":
|
|
7235
|
+
return { colorType: "auto" };
|
|
7236
|
+
case "rgb": {
|
|
7237
|
+
const channels = color.r !== void 0 && color.g !== void 0 && color.b !== void 0 ? [color.r, color.g, color.b] : parseColorHex(color.hex);
|
|
7238
|
+
return channels ? { b: channels[2], colorType: "rgb", g: channels[1], r: channels[0] } : void 0;
|
|
7239
|
+
}
|
|
7240
|
+
case "argb": {
|
|
7241
|
+
const normalized = color.hex?.replace(/^#/, "");
|
|
7242
|
+
const channels = normalized && /^[0-9a-f]{8}$/i.test(normalized) ? [0, 2, 4, 6].map((offset) => Number.parseInt(normalized.slice(offset, offset + 2), 16)) : color.a !== void 0 && color.r !== void 0 && color.g !== void 0 && color.b !== void 0 ? [color.a, color.r, color.g, color.b] : null;
|
|
7243
|
+
return channels ? { a: channels[0], b: channels[3], colorType: "argb", g: channels[2], r: channels[1] } : void 0;
|
|
7244
|
+
}
|
|
7245
|
+
case "theme":
|
|
7246
|
+
return color.themeIndex === void 0 ? void 0 : { colorType: "theme", index: color.themeIndex, tint: color.tint ?? 0 };
|
|
7247
|
+
case "indexed":
|
|
7248
|
+
return color.paletteIndex === void 0 ? void 0 : { colorType: "indexed", index: color.paletteIndex };
|
|
7249
|
+
}
|
|
7388
7250
|
}
|
|
7389
|
-
function
|
|
7390
|
-
|
|
7391
|
-
|
|
7392
|
-
|
|
7251
|
+
function xlsxFontToDukeFont(font) {
|
|
7252
|
+
return {
|
|
7253
|
+
bold: font.bold,
|
|
7254
|
+
charset: font.charset,
|
|
7255
|
+
color: xlsxColorToDukeColor(font.color),
|
|
7256
|
+
family: font.family,
|
|
7257
|
+
italic: font.italic,
|
|
7258
|
+
name: font.name,
|
|
7259
|
+
scheme: font.scheme,
|
|
7260
|
+
size: font.size,
|
|
7261
|
+
strikethrough: font.strikethrough,
|
|
7262
|
+
underline: font.underline,
|
|
7263
|
+
verticalAlign: font.verticalAlign
|
|
7264
|
+
};
|
|
7393
7265
|
}
|
|
7394
|
-
function
|
|
7395
|
-
|
|
7396
|
-
|
|
7397
|
-
return [];
|
|
7398
|
-
}
|
|
7399
|
-
if (target.kind.cellLink) {
|
|
7400
|
-
const targetCellLink = target.kind.cellLink;
|
|
7401
|
-
return controls.flatMap((control, index) => control.kind.kind === "optionButton" && control.kind.cellLink === targetCellLink ? [index] : []);
|
|
7266
|
+
function xlsxCaptionToDukeText(caption) {
|
|
7267
|
+
if (typeof caption === "string") {
|
|
7268
|
+
return { runs: [{ text: caption }] };
|
|
7402
7269
|
}
|
|
7403
|
-
|
|
7404
|
-
|
|
7405
|
-
|
|
7406
|
-
|
|
7407
|
-
|
|
7408
|
-
|
|
7409
|
-
|
|
7410
|
-
|
|
7270
|
+
return {
|
|
7271
|
+
horizontalAlignment: caption.horizontalAlignment,
|
|
7272
|
+
runs: caption.runs.map((run) => ({
|
|
7273
|
+
font: run.font ? xlsxFontToDukeFont(run.font) : void 0,
|
|
7274
|
+
text: run.text
|
|
7275
|
+
})),
|
|
7276
|
+
verticalAlignment: caption.verticalAlignment
|
|
7277
|
+
};
|
|
7278
|
+
}
|
|
7279
|
+
function xlsxFormControlKindToDukeKind(kind) {
|
|
7280
|
+
switch (kind.kind) {
|
|
7281
|
+
case "button":
|
|
7282
|
+
case "label":
|
|
7283
|
+
return { caption: xlsxCaptionToDukeText(kind.caption), kind: kind.kind };
|
|
7284
|
+
case "checkbox":
|
|
7285
|
+
return { ...kind, caption: xlsxCaptionToDukeText(kind.caption) };
|
|
7286
|
+
case "optionButton":
|
|
7287
|
+
return { ...kind, caption: xlsxCaptionToDukeText(kind.caption) };
|
|
7288
|
+
case "groupBox":
|
|
7289
|
+
return { ...kind, caption: xlsxCaptionToDukeText(kind.caption) };
|
|
7290
|
+
case "editbox":
|
|
7291
|
+
return {
|
|
7292
|
+
caption: xlsxCaptionToDukeText(kind.caption),
|
|
7293
|
+
kind: "unknown",
|
|
7294
|
+
legacyObjectType: kind.legacyObjectType,
|
|
7295
|
+
objectType: "EditBox",
|
|
7296
|
+
rawObj: kind.rawObj,
|
|
7297
|
+
rawProperties: kind.rawProperties
|
|
7298
|
+
};
|
|
7299
|
+
case "unknown":
|
|
7300
|
+
return {
|
|
7301
|
+
caption: kind.caption ? xlsxCaptionToDukeText(kind.caption) : void 0,
|
|
7302
|
+
kind: "unknown",
|
|
7303
|
+
legacyObjectType: kind.legacyObjectType,
|
|
7304
|
+
objectType: kind.objectType,
|
|
7305
|
+
rawObj: kind.rawObj,
|
|
7306
|
+
rawProperties: kind.rawProperties
|
|
7307
|
+
};
|
|
7308
|
+
default:
|
|
7309
|
+
return { ...kind };
|
|
7411
7310
|
}
|
|
7412
|
-
|
|
7413
|
-
|
|
7414
|
-
if (
|
|
7415
|
-
return
|
|
7311
|
+
}
|
|
7312
|
+
function dukeFormControlKindToInput(kind) {
|
|
7313
|
+
if (kind.kind === "optionButton") {
|
|
7314
|
+
return { ...kind, state: kind.state === "checked" ? "checked" : "unchecked" };
|
|
7416
7315
|
}
|
|
7417
|
-
|
|
7418
|
-
|
|
7419
|
-
|
|
7420
|
-
|
|
7421
|
-
|
|
7422
|
-
|
|
7423
|
-
|
|
7316
|
+
if (kind.kind === "unknown") {
|
|
7317
|
+
return {
|
|
7318
|
+
caption: kind.caption,
|
|
7319
|
+
kind: "unknown",
|
|
7320
|
+
legacyObjectType: kind.legacyObjectType,
|
|
7321
|
+
objectType: kind.objectType,
|
|
7322
|
+
rawObj: kind.rawObj,
|
|
7323
|
+
rawProperties: kind.rawProperties
|
|
7324
|
+
};
|
|
7424
7325
|
}
|
|
7425
|
-
|
|
7426
|
-
|
|
7427
|
-
|
|
7428
|
-
|
|
7429
|
-
|
|
7326
|
+
return { ...kind };
|
|
7327
|
+
}
|
|
7328
|
+
function formControlInputFromDukeControl(control) {
|
|
7329
|
+
return {
|
|
7330
|
+
altText: control.altText,
|
|
7331
|
+
...control.anchor ? { anchor: control.anchor } : { transform: control.transform },
|
|
7332
|
+
formControl: {
|
|
7333
|
+
kind: dukeFormControlKindToInput(control.formControl.kind),
|
|
7334
|
+
macroName: control.formControl.macroName,
|
|
7335
|
+
rawClientData: control.formControl.rawClientData
|
|
7336
|
+
},
|
|
7337
|
+
hidden: control.hidden,
|
|
7338
|
+
kind: "formControl",
|
|
7339
|
+
locked: control.locked,
|
|
7340
|
+
name: control.name,
|
|
7341
|
+
printable: control.printable,
|
|
7342
|
+
title: control.title
|
|
7343
|
+
};
|
|
7344
|
+
}
|
|
7345
|
+
function xlsxFormControlInputToDukeDrawing(input) {
|
|
7346
|
+
return {
|
|
7347
|
+
altText: input.altText,
|
|
7348
|
+
anchor: xlsxAnchorToDukeDrawingAnchor(input.anchor, input.editAs),
|
|
7349
|
+
formControl: {
|
|
7350
|
+
kind: xlsxFormControlKindToDukeKind(input.kind),
|
|
7351
|
+
macroName: input.macroName,
|
|
7352
|
+
rawClientData: input.rawClientData
|
|
7353
|
+
},
|
|
7354
|
+
hidden: input.hidden,
|
|
7355
|
+
kind: "formControl",
|
|
7356
|
+
locked: input.locked,
|
|
7357
|
+
name: input.name,
|
|
7358
|
+
printable: input.printable,
|
|
7359
|
+
title: input.title
|
|
7360
|
+
};
|
|
7361
|
+
}
|
|
7362
|
+
function reconcileCheckedOptionButtons(worksheet) {
|
|
7363
|
+
const checkedPaths = worksheet.formControls.flatMap((control) => control.formControl.kind.kind === "optionButton" && control.formControl.kind.state === "checked" ? [control.drawingPath] : []);
|
|
7364
|
+
for (const path of checkedPaths) {
|
|
7365
|
+
const current = worksheet.formControls.find((control) => control.drawingPath.length === path.length && control.drawingPath.every((segment, index) => segment === path[index]));
|
|
7366
|
+
if (current?.formControl.kind.kind === "optionButton" && current.formControl.kind.state === "checked") {
|
|
7367
|
+
worksheet.setFormControlCheckState(current.drawingPath, "checked");
|
|
7430
7368
|
}
|
|
7431
|
-
endPosition += 1;
|
|
7432
7369
|
}
|
|
7433
|
-
return optionIndexes.slice(startPosition, endPosition);
|
|
7434
7370
|
}
|
|
7435
|
-
function
|
|
7436
|
-
|
|
7437
|
-
|
|
7438
|
-
|
|
7371
|
+
function formControlInteractionChanged(current, next) {
|
|
7372
|
+
if (current.kind !== next.kind) {
|
|
7373
|
+
return true;
|
|
7374
|
+
}
|
|
7375
|
+
if ("cellLink" in current && "cellLink" in next && current.cellLink !== next.cellLink) {
|
|
7376
|
+
return true;
|
|
7439
7377
|
}
|
|
7440
|
-
switch (
|
|
7378
|
+
switch (current.kind) {
|
|
7441
7379
|
case "checkbox":
|
|
7442
|
-
|
|
7443
|
-
|
|
7444
|
-
const groupIndexes = resolveOptionButtonGroupIndexes(controls, controlIndex);
|
|
7445
|
-
const checkedIndex = groupIndexes.find((index) => controls[index]?.kind.kind === "optionButton" && controls[index]?.kind.state === "checked");
|
|
7446
|
-
const groupPosition = checkedIndex === void 0 ? -1 : groupIndexes.indexOf(checkedIndex);
|
|
7447
|
-
return groupPosition >= 0 ? groupPosition + 1 : "";
|
|
7448
|
-
}
|
|
7380
|
+
case "optionButton":
|
|
7381
|
+
return next.kind === current.kind && current.state !== next.state;
|
|
7449
7382
|
case "dropdown":
|
|
7450
|
-
return
|
|
7383
|
+
return next.kind === "dropdown" && current.selected !== next.selected;
|
|
7451
7384
|
case "listBox":
|
|
7452
|
-
return
|
|
7385
|
+
return next.kind === "listBox" && (current.selection !== next.selection || current.selected.length !== next.selected.length || current.selected.some((value, index) => value !== next.selected[index]));
|
|
7453
7386
|
case "scrollbar":
|
|
7454
7387
|
case "spinner":
|
|
7455
|
-
return
|
|
7388
|
+
return next.kind === current.kind && current.value !== next.value;
|
|
7456
7389
|
default:
|
|
7457
|
-
return
|
|
7458
|
-
}
|
|
7459
|
-
}
|
|
7460
|
-
function syncFormControlLinkedCell(workbook, workbookSheetIndex, controls, controlIndex) {
|
|
7461
|
-
const control = controls[controlIndex];
|
|
7462
|
-
if (!control) {
|
|
7463
|
-
return;
|
|
7464
|
-
}
|
|
7465
|
-
const cellLink = getFormControlCellLink(control.kind);
|
|
7466
|
-
const value = resolveLinkedCellValue(controls, controlIndex);
|
|
7467
|
-
if (!cellLink || value === void 0) {
|
|
7468
|
-
return;
|
|
7469
|
-
}
|
|
7470
|
-
const target = resolveWorkbookReference(workbook, workbookSheetIndex, cellLink);
|
|
7471
|
-
if (!target || target.range.start.row !== target.range.end.row || target.range.start.col !== target.range.end.col) {
|
|
7472
|
-
return;
|
|
7390
|
+
return false;
|
|
7473
7391
|
}
|
|
7474
|
-
target.worksheet.setCell(cellAddressToA1(target.range.start), value);
|
|
7475
7392
|
}
|
|
7476
7393
|
function parseWorksheetFreezePanes(worksheet) {
|
|
7477
7394
|
const rawFreezePanes = worksheet.freezePanes;
|
|
@@ -7805,9 +7722,6 @@ function scheduleLowPriorityTask(task) {
|
|
|
7805
7722
|
const timeoutHandle = window.setTimeout(task, 0);
|
|
7806
7723
|
return () => window.clearTimeout(timeoutHandle);
|
|
7807
7724
|
}
|
|
7808
|
-
function asFiniteNumber(value) {
|
|
7809
|
-
return typeof value === "number" && Number.isFinite(value) ? value : null;
|
|
7810
|
-
}
|
|
7811
7725
|
function inferImageMimeType(source) {
|
|
7812
7726
|
if (source.startsWith("data:")) {
|
|
7813
7727
|
const separatorIndex = source.indexOf(";");
|
|
@@ -7831,18 +7745,27 @@ function inferImageMimeType(source) {
|
|
|
7831
7745
|
return "image/png";
|
|
7832
7746
|
}
|
|
7833
7747
|
function inferWorksheetDirectImageMimeType(info) {
|
|
7834
|
-
const format =
|
|
7748
|
+
const format = info.format;
|
|
7835
7749
|
if (format === "gif") {
|
|
7836
7750
|
return "image/gif";
|
|
7837
7751
|
}
|
|
7838
|
-
if (format === "
|
|
7752
|
+
if (format === "jpeg") {
|
|
7839
7753
|
return "image/jpeg";
|
|
7840
7754
|
}
|
|
7841
7755
|
if (format === "svg") {
|
|
7842
7756
|
return "image/svg+xml";
|
|
7843
7757
|
}
|
|
7844
|
-
if (format === "
|
|
7845
|
-
return "image/
|
|
7758
|
+
if (format === "bmp") {
|
|
7759
|
+
return "image/bmp";
|
|
7760
|
+
}
|
|
7761
|
+
if (format === "tiff") {
|
|
7762
|
+
return "image/tiff";
|
|
7763
|
+
}
|
|
7764
|
+
if (format === "emf") {
|
|
7765
|
+
return "image/emf";
|
|
7766
|
+
}
|
|
7767
|
+
if (format === "wmf") {
|
|
7768
|
+
return "image/wmf";
|
|
7846
7769
|
}
|
|
7847
7770
|
if (format === "png") {
|
|
7848
7771
|
return "image/png";
|
|
@@ -7864,323 +7787,108 @@ function createWorksheetDirectImageSource(data, mimeType, objectUrls) {
|
|
|
7864
7787
|
objectUrls.push(objectUrl);
|
|
7865
7788
|
return objectUrl;
|
|
7866
7789
|
}
|
|
7867
|
-
function
|
|
7868
|
-
const
|
|
7869
|
-
|
|
7870
|
-
|
|
7871
|
-
|
|
7872
|
-
|
|
7873
|
-
|
|
7874
|
-
|
|
7875
|
-
|
|
7876
|
-
|
|
7877
|
-
|
|
7878
|
-
return {
|
|
7879
|
-
from: {
|
|
7880
|
-
col: Math.max(0, Math.round(fromCol)),
|
|
7881
|
-
colOffsetEmu: Math.max(0, Math.round(fromColOffset)),
|
|
7882
|
-
row: Math.max(0, Math.round(fromRow)),
|
|
7883
|
-
rowOffsetEmu: Math.max(0, Math.round(fromRowOffset))
|
|
7884
|
-
},
|
|
7885
|
-
kind: "two-cell",
|
|
7886
|
-
to: {
|
|
7887
|
-
col: Math.max(0, Math.round(toCol)),
|
|
7888
|
-
colOffsetEmu: Math.max(0, Math.round(toColOffset)),
|
|
7889
|
-
row: Math.max(0, Math.round(toRow)),
|
|
7890
|
-
rowOffsetEmu: Math.max(0, Math.round(toRowOffset))
|
|
7891
|
-
}
|
|
7892
|
-
};
|
|
7893
|
-
}
|
|
7894
|
-
return {
|
|
7895
|
-
from: {
|
|
7896
|
-
col: Math.max(0, Math.round(fromCol)),
|
|
7897
|
-
colOffsetEmu: Math.max(0, Math.round(fromColOffset)),
|
|
7898
|
-
row: Math.max(0, Math.round(fromRow)),
|
|
7899
|
-
rowOffsetEmu: Math.max(0, Math.round(fromRowOffset))
|
|
7900
|
-
},
|
|
7901
|
-
kind: "one-cell",
|
|
7902
|
-
sizeEmu: {
|
|
7903
|
-
cx: Math.max(EMU_PER_PIXEL3, Math.round(widthEmu)),
|
|
7904
|
-
cy: Math.max(EMU_PER_PIXEL3, Math.round(heightEmu))
|
|
7905
|
-
}
|
|
7906
|
-
};
|
|
7907
|
-
}
|
|
7908
|
-
function normalizeWorksheetDirectShapeParagraphs(rawParagraphs, fallbackText) {
|
|
7909
|
-
const normalizedParagraphs = [];
|
|
7910
|
-
if (Array.isArray(rawParagraphs)) {
|
|
7911
|
-
for (const entry of rawParagraphs) {
|
|
7912
|
-
const paragraph = entry && typeof entry === "object" ? entry : {};
|
|
7913
|
-
const runs = [];
|
|
7914
|
-
if (Array.isArray(paragraph.runs)) {
|
|
7915
|
-
for (const runEntry of paragraph.runs) {
|
|
7916
|
-
const run = runEntry && typeof runEntry === "object" ? runEntry : {};
|
|
7917
|
-
const text2 = typeof run.text === "string" ? run.text : "";
|
|
7918
|
-
if (!text2) {
|
|
7919
|
-
continue;
|
|
7920
|
-
}
|
|
7921
|
-
runs.push({
|
|
7922
|
-
bold: typeof run.bold === "boolean" ? run.bold : void 0,
|
|
7923
|
-
color: typeof run.color === "string" && run.color.trim() ? run.color : void 0,
|
|
7924
|
-
fontFamily: typeof run.fontFamily === "string" && run.fontFamily.trim() ? run.fontFamily : void 0,
|
|
7925
|
-
fontSizePt: asFiniteNumber(run.fontSizePt) ?? void 0,
|
|
7926
|
-
italic: typeof run.italic === "boolean" ? run.italic : void 0,
|
|
7927
|
-
text: text2,
|
|
7928
|
-
underline: typeof run.underline === "boolean" ? run.underline : void 0
|
|
7929
|
-
});
|
|
7930
|
-
}
|
|
7931
|
-
}
|
|
7932
|
-
if (runs.length === 0) {
|
|
7933
|
-
continue;
|
|
7934
|
-
}
|
|
7935
|
-
const align = paragraph.align;
|
|
7936
|
-
normalizedParagraphs.push({
|
|
7937
|
-
align: align === "center" || align === "justify" || align === "left" || align === "right" ? align : void 0,
|
|
7938
|
-
runs
|
|
7939
|
-
});
|
|
7790
|
+
function buildWorksheetDirectApiImage(worksheet, workbookSheetIndex, drawing, objectUrls) {
|
|
7791
|
+
const hasSvgCompanion = Boolean(drawing.image.svgMediaPath);
|
|
7792
|
+
let mimeType = inferWorksheetDirectImageMimeType(drawing.image);
|
|
7793
|
+
let data;
|
|
7794
|
+
try {
|
|
7795
|
+
const svgData = drawing.image.format === "svg" || hasSvgCompanion ? worksheet.drawingSvgData(drawing.drawingPath) : void 0;
|
|
7796
|
+
if (svgData) {
|
|
7797
|
+
data = svgData;
|
|
7798
|
+
mimeType = "image/svg+xml";
|
|
7799
|
+
} else {
|
|
7800
|
+
data = worksheet.drawingImageData(drawing.drawingPath);
|
|
7940
7801
|
}
|
|
7941
|
-
}
|
|
7942
|
-
if (normalizedParagraphs.length > 0) {
|
|
7943
|
-
return normalizedParagraphs;
|
|
7944
|
-
}
|
|
7945
|
-
const text = typeof fallbackText === "string" ? fallbackText : "";
|
|
7946
|
-
return text ? [{ runs: [{ text }] }] : [];
|
|
7947
|
-
}
|
|
7948
|
-
function buildWorksheetDirectApiShape(workbookSheetIndex, info, zIndex) {
|
|
7949
|
-
const fill = info.fill && typeof info.fill === "object" ? {
|
|
7950
|
-
color: typeof info.fill.color === "string" && info.fill.color.trim() ? info.fill.color : void 0,
|
|
7951
|
-
none: typeof info.fill.none === "boolean" ? info.fill.none : void 0,
|
|
7952
|
-
opacity: asFiniteNumber(info.fill.opacity) ?? void 0
|
|
7953
|
-
} : void 0;
|
|
7954
|
-
const stroke = info.stroke && typeof info.stroke === "object" ? {
|
|
7955
|
-
color: typeof info.stroke.color === "string" && info.stroke.color.trim() ? info.stroke.color : void 0,
|
|
7956
|
-
dash: typeof info.stroke.dash === "string" && info.stroke.dash.trim() ? info.stroke.dash : void 0,
|
|
7957
|
-
headEndType: typeof info.stroke.headEndType === "string" && info.stroke.headEndType.trim() ? info.stroke.headEndType : void 0,
|
|
7958
|
-
none: typeof info.stroke.none === "boolean" ? info.stroke.none : void 0,
|
|
7959
|
-
opacity: asFiniteNumber(info.stroke.opacity) ?? void 0,
|
|
7960
|
-
tailEndType: typeof info.stroke.tailEndType === "string" && info.stroke.tailEndType.trim() ? info.stroke.tailEndType : void 0,
|
|
7961
|
-
widthPx: asFiniteNumber(info.stroke.widthPx) ?? void 0
|
|
7962
|
-
} : void 0;
|
|
7963
|
-
const rawSvgViewBox = info.svgViewBox && typeof info.svgViewBox === "object" ? info.svgViewBox : null;
|
|
7964
|
-
const rawTextBox = info.textBox && typeof info.textBox === "object" ? info.textBox : null;
|
|
7965
|
-
const rawInset = rawTextBox?.insetPx && typeof rawTextBox.insetPx === "object" ? rawTextBox.insetPx : null;
|
|
7966
|
-
return {
|
|
7967
|
-
anchor: buildWorksheetDirectImageAnchor(
|
|
7968
|
-
info.anchor,
|
|
7969
|
-
DEFAULT_COL_WIDTH * EMU_PER_PIXEL3,
|
|
7970
|
-
DEFAULT_ROW_HEIGHT * EMU_PER_PIXEL3
|
|
7971
|
-
),
|
|
7972
|
-
description: typeof info.description === "string" && info.description.trim() ? info.description : void 0,
|
|
7973
|
-
fill,
|
|
7974
|
-
flipH: typeof info.flipH === "boolean" ? info.flipH : void 0,
|
|
7975
|
-
flipV: typeof info.flipV === "boolean" ? info.flipV : void 0,
|
|
7976
|
-
geometry: typeof info.geometry === "string" && info.geometry.trim() ? info.geometry : "rect",
|
|
7977
|
-
geometryAdjustments: info.geometryAdjustments && typeof info.geometryAdjustments === "object" ? Object.fromEntries(
|
|
7978
|
-
Object.entries(info.geometryAdjustments).map(([key, value]) => [key, asFiniteNumber(value)]).filter((entry) => typeof entry[1] === "number")
|
|
7979
|
-
) : void 0,
|
|
7980
|
-
hyperlink: typeof info.hyperlink === "string" && info.hyperlink.trim() ? info.hyperlink : void 0,
|
|
7981
|
-
id: `shape-${workbookSheetIndex}-${String(info.id ?? zIndex)}`,
|
|
7982
|
-
name: typeof info.name === "string" && info.name.trim() ? info.name : void 0,
|
|
7983
|
-
paragraphs: normalizeWorksheetDirectShapeParagraphs(info.paragraphs, info.text),
|
|
7984
|
-
rotationDeg: asFiniteNumber(info.rotationDeg) ?? void 0,
|
|
7985
|
-
scaleX: asFiniteNumber(info.scaleX) ?? void 0,
|
|
7986
|
-
scaleY: asFiniteNumber(info.scaleY) ?? void 0,
|
|
7987
|
-
sheetIndex: workbookSheetIndex,
|
|
7988
|
-
svgPath: typeof info.svgPath === "string" && info.svgPath.trim() ? info.svgPath : void 0,
|
|
7989
|
-
svgViewBox: rawSvgViewBox && asFiniteNumber(rawSvgViewBox.width) !== null && asFiniteNumber(rawSvgViewBox.height) !== null ? {
|
|
7990
|
-
height: asFiniteNumber(rawSvgViewBox.height) ?? 0,
|
|
7991
|
-
width: asFiniteNumber(rawSvgViewBox.width) ?? 0
|
|
7992
|
-
} : void 0,
|
|
7993
|
-
stroke,
|
|
7994
|
-
textBox: rawTextBox ? {
|
|
7995
|
-
horizontalAlign: rawTextBox.horizontalAlign === "center" || rawTextBox.horizontalAlign === "left" ? rawTextBox.horizontalAlign : void 0,
|
|
7996
|
-
insetPx: rawInset ? {
|
|
7997
|
-
bottom: asFiniteNumber(rawInset.bottom) ?? 0,
|
|
7998
|
-
left: asFiniteNumber(rawInset.left) ?? 0,
|
|
7999
|
-
right: asFiniteNumber(rawInset.right) ?? 0,
|
|
8000
|
-
top: asFiniteNumber(rawInset.top) ?? 0
|
|
8001
|
-
} : void 0,
|
|
8002
|
-
verticalAlign: rawTextBox.verticalAlign === "bottom" || rawTextBox.verticalAlign === "middle" || rawTextBox.verticalAlign === "top" ? rawTextBox.verticalAlign : void 0
|
|
8003
|
-
} : void 0,
|
|
8004
|
-
workbookSheetIndex,
|
|
8005
|
-
zIndex
|
|
8006
|
-
};
|
|
8007
|
-
}
|
|
8008
|
-
function buildWorksheetApiImage(workbookSheetIndex, row, col, info, zIndex) {
|
|
8009
|
-
if (typeof info.source !== "string" || !info.source) {
|
|
7802
|
+
} catch {
|
|
8010
7803
|
return null;
|
|
8011
7804
|
}
|
|
8012
|
-
const
|
|
8013
|
-
const height = Math.max(1, Math.round(asFiniteNumber(info.height) ?? DEFAULT_ROW_HEIGHT));
|
|
8014
|
-
const description = typeof info.altText === "string" && info.altText.trim() ? info.altText : void 0;
|
|
8015
|
-
return {
|
|
8016
|
-
anchor: {
|
|
8017
|
-
from: {
|
|
8018
|
-
col,
|
|
8019
|
-
colOffsetEmu: 0,
|
|
8020
|
-
row,
|
|
8021
|
-
rowOffsetEmu: 0
|
|
8022
|
-
},
|
|
8023
|
-
kind: "one-cell",
|
|
8024
|
-
sizeEmu: {
|
|
8025
|
-
cx: width * EMU_PER_PIXEL3,
|
|
8026
|
-
cy: height * EMU_PER_PIXEL3
|
|
8027
|
-
}
|
|
8028
|
-
},
|
|
8029
|
-
description,
|
|
8030
|
-
editable: false,
|
|
8031
|
-
id: `worksheet-image-${workbookSheetIndex}-${row}-${col}-${zIndex}`,
|
|
8032
|
-
mimeType: inferImageMimeType(info.source),
|
|
8033
|
-
sheetIndex: workbookSheetIndex,
|
|
8034
|
-
src: info.source,
|
|
8035
|
-
workbookSheetIndex,
|
|
8036
|
-
zIndex
|
|
8037
|
-
};
|
|
8038
|
-
}
|
|
8039
|
-
function buildWorksheetDirectApiImage(workbookSheetIndex, info, zIndex, objectUrls) {
|
|
8040
|
-
const mimeType = inferWorksheetDirectImageMimeType(info);
|
|
8041
|
-
const src = createWorksheetDirectImageSource(info.data, mimeType, objectUrls);
|
|
7805
|
+
const src = createWorksheetDirectImageSource(data, mimeType, objectUrls);
|
|
8042
7806
|
if (!src) {
|
|
8043
7807
|
return null;
|
|
8044
7808
|
}
|
|
8045
|
-
const
|
|
8046
|
-
const heightEmu = Math.max(EMU_PER_PIXEL3, Math.round(asFiniteNumber(info.heightEmu) ?? DEFAULT_ROW_HEIGHT * EMU_PER_PIXEL3));
|
|
7809
|
+
const zIndex = (drawing.drawingPath[0] ?? 0) + 1;
|
|
8047
7810
|
return {
|
|
8048
|
-
anchor:
|
|
7811
|
+
anchor: dukeDrawingAnchorToXlsxAnchor(drawing.anchor),
|
|
7812
|
+
description: drawing.altText,
|
|
8049
7813
|
editable: false,
|
|
8050
|
-
id: `worksheet-image-${workbookSheetIndex}-${
|
|
8051
|
-
mediaPath:
|
|
7814
|
+
id: `worksheet-image-${workbookSheetIndex}-${drawing.drawingPath.join("-")}`,
|
|
7815
|
+
mediaPath: drawing.image.mediaPath || void 0,
|
|
8052
7816
|
mimeType,
|
|
8053
|
-
name:
|
|
7817
|
+
name: drawing.name,
|
|
8054
7818
|
sheetIndex: workbookSheetIndex,
|
|
8055
7819
|
src,
|
|
8056
7820
|
workbookSheetIndex,
|
|
8057
7821
|
zIndex
|
|
8058
7822
|
};
|
|
8059
7823
|
}
|
|
8060
|
-
function collectWorksheetBatchImages(workbook) {
|
|
8061
|
-
const imagesByWorkbookSheetIndex = Array.from({ length: workbook.sheetCount }, () => []);
|
|
8062
|
-
for (let workbookSheetIndex = 0; workbookSheetIndex < workbook.sheetCount; workbookSheetIndex += 1) {
|
|
8063
|
-
const worksheet = workbook.getSheet(workbookSheetIndex);
|
|
8064
|
-
if (typeof worksheet.getRowsBatch !== "function") {
|
|
8065
|
-
continue;
|
|
8066
|
-
}
|
|
8067
|
-
const usedRange = worksheet.usedRange();
|
|
8068
|
-
const maxRow = usedRange?.[2] ?? -1;
|
|
8069
|
-
if (maxRow < 0) {
|
|
8070
|
-
continue;
|
|
8071
|
-
}
|
|
8072
|
-
let zIndex = 1;
|
|
8073
|
-
let sheetFailed = false;
|
|
8074
|
-
for (let startRow = 0; startRow <= maxRow; startRow += IMAGE_BATCH_ROW_COUNT) {
|
|
8075
|
-
let rows;
|
|
8076
|
-
try {
|
|
8077
|
-
rows = worksheet.getRowsBatch(startRow, IMAGE_BATCH_ROW_COUNT, { includeImages: true });
|
|
8078
|
-
} catch {
|
|
8079
|
-
sheetFailed = true;
|
|
8080
|
-
break;
|
|
8081
|
-
}
|
|
8082
|
-
if (!Array.isArray(rows)) {
|
|
8083
|
-
continue;
|
|
8084
|
-
}
|
|
8085
|
-
for (const rowEntry of rows) {
|
|
8086
|
-
const row = typeof rowEntry.index === "number" ? rowEntry.index : null;
|
|
8087
|
-
if (row === null || !Array.isArray(rowEntry.cells)) {
|
|
8088
|
-
continue;
|
|
8089
|
-
}
|
|
8090
|
-
for (const cellEntry of rowEntry.cells) {
|
|
8091
|
-
const col = typeof cellEntry.col === "number" ? cellEntry.col : null;
|
|
8092
|
-
if (col === null || !cellEntry.image || typeof cellEntry.image !== "object") {
|
|
8093
|
-
continue;
|
|
8094
|
-
}
|
|
8095
|
-
const image = buildWorksheetApiImage(workbookSheetIndex, row, col, cellEntry.image, zIndex);
|
|
8096
|
-
if (!image) {
|
|
8097
|
-
continue;
|
|
8098
|
-
}
|
|
8099
|
-
imagesByWorkbookSheetIndex[workbookSheetIndex].push(image);
|
|
8100
|
-
zIndex += 1;
|
|
8101
|
-
}
|
|
8102
|
-
}
|
|
8103
|
-
}
|
|
8104
|
-
if (sheetFailed) {
|
|
8105
|
-
imagesByWorkbookSheetIndex[workbookSheetIndex] = [];
|
|
8106
|
-
}
|
|
8107
|
-
}
|
|
8108
|
-
return imagesByWorkbookSheetIndex;
|
|
8109
|
-
}
|
|
8110
7824
|
function collectWorksheetApiImages(workbook, objectUrls) {
|
|
8111
7825
|
const directImagesByWorkbookSheetIndex = Array.from({ length: workbook.sheetCount }, () => []);
|
|
8112
|
-
let didUseDirectImages = false;
|
|
8113
7826
|
for (let workbookSheetIndex = 0; workbookSheetIndex < workbook.sheetCount; workbookSheetIndex += 1) {
|
|
8114
7827
|
const worksheet = workbook.getSheet(workbookSheetIndex);
|
|
8115
|
-
const rawImages =
|
|
7828
|
+
const rawImages = worksheet.images;
|
|
8116
7829
|
if (rawImages.length === 0) {
|
|
8117
7830
|
continue;
|
|
8118
7831
|
}
|
|
8119
|
-
const nextImages = rawImages.
|
|
7832
|
+
const nextImages = rawImages.filter((drawing) => !drawing.hidden && Boolean(drawing.anchor)).map((drawing) => buildWorksheetDirectApiImage(worksheet, workbookSheetIndex, drawing, objectUrls)).filter((image) => Boolean(image));
|
|
8120
7833
|
if (nextImages.length > 0) {
|
|
8121
7834
|
directImagesByWorkbookSheetIndex[workbookSheetIndex] = nextImages;
|
|
8122
|
-
didUseDirectImages = true;
|
|
8123
7835
|
}
|
|
8124
7836
|
}
|
|
8125
|
-
|
|
8126
|
-
return directImagesByWorkbookSheetIndex;
|
|
8127
|
-
}
|
|
8128
|
-
return collectWorksheetBatchImages(workbook);
|
|
8129
|
-
}
|
|
8130
|
-
function collectWorksheetApiShapes(workbook) {
|
|
8131
|
-
return Array.from({ length: workbook.sheetCount }, (_, workbookSheetIndex) => {
|
|
8132
|
-
const worksheet = workbook.getSheet(workbookSheetIndex);
|
|
8133
|
-
const rawShapes = Array.isArray(worksheet.shapes) ? worksheet.shapes : [];
|
|
8134
|
-
return rawShapes.map((shape, index) => buildWorksheetDirectApiShape(workbookSheetIndex, shape, index + 1));
|
|
8135
|
-
});
|
|
7837
|
+
return directImagesByWorkbookSheetIndex;
|
|
8136
7838
|
}
|
|
8137
|
-
function
|
|
8138
|
-
if (
|
|
8139
|
-
return
|
|
8140
|
-
|
|
8141
|
-
|
|
8142
|
-
|
|
7839
|
+
function imageAnchorKey(anchor) {
|
|
7840
|
+
if (anchor.kind === "absolute") {
|
|
7841
|
+
return [
|
|
7842
|
+
"absolute",
|
|
7843
|
+
Math.round(anchor.positionEmu.x),
|
|
7844
|
+
Math.round(anchor.positionEmu.y),
|
|
7845
|
+
Math.round(anchor.sizeEmu.cx),
|
|
7846
|
+
Math.round(anchor.sizeEmu.cy)
|
|
7847
|
+
].join(":");
|
|
8143
7848
|
}
|
|
8144
|
-
|
|
8145
|
-
const anchorKey = (anchor) => {
|
|
8146
|
-
if (anchor.kind === "absolute") {
|
|
8147
|
-
return [
|
|
8148
|
-
"absolute",
|
|
8149
|
-
Math.round(anchor.positionEmu.x),
|
|
8150
|
-
Math.round(anchor.positionEmu.y),
|
|
8151
|
-
Math.round(anchor.sizeEmu.cx),
|
|
8152
|
-
Math.round(anchor.sizeEmu.cy)
|
|
8153
|
-
].join(":");
|
|
8154
|
-
}
|
|
8155
|
-
if (anchor.kind === "one-cell") {
|
|
8156
|
-
return [
|
|
8157
|
-
"one",
|
|
8158
|
-
anchor.from.col,
|
|
8159
|
-
anchor.from.row,
|
|
8160
|
-
Math.round(anchor.from.colOffsetEmu),
|
|
8161
|
-
Math.round(anchor.from.rowOffsetEmu),
|
|
8162
|
-
Math.round(anchor.sizeEmu.cx),
|
|
8163
|
-
Math.round(anchor.sizeEmu.cy)
|
|
8164
|
-
].join(":");
|
|
8165
|
-
}
|
|
7849
|
+
if (anchor.kind === "one-cell") {
|
|
8166
7850
|
return [
|
|
8167
|
-
"
|
|
7851
|
+
"one",
|
|
8168
7852
|
anchor.from.col,
|
|
8169
7853
|
anchor.from.row,
|
|
8170
7854
|
Math.round(anchor.from.colOffsetEmu),
|
|
8171
7855
|
Math.round(anchor.from.rowOffsetEmu),
|
|
8172
|
-
anchor.
|
|
8173
|
-
anchor.
|
|
8174
|
-
Math.round(anchor.to.colOffsetEmu),
|
|
8175
|
-
Math.round(anchor.to.rowOffsetEmu)
|
|
7856
|
+
Math.round(anchor.sizeEmu.cx),
|
|
7857
|
+
Math.round(anchor.sizeEmu.cy)
|
|
8176
7858
|
].join(":");
|
|
8177
|
-
}
|
|
7859
|
+
}
|
|
7860
|
+
return [
|
|
7861
|
+
"two",
|
|
7862
|
+
anchor.from.col,
|
|
7863
|
+
anchor.from.row,
|
|
7864
|
+
Math.round(anchor.from.colOffsetEmu),
|
|
7865
|
+
Math.round(anchor.from.rowOffsetEmu),
|
|
7866
|
+
anchor.to.col,
|
|
7867
|
+
anchor.to.row,
|
|
7868
|
+
Math.round(anchor.to.colOffsetEmu),
|
|
7869
|
+
Math.round(anchor.to.rowOffsetEmu)
|
|
7870
|
+
].join(":");
|
|
7871
|
+
}
|
|
7872
|
+
function collectHiddenWorksheetImageAnchors(workbook) {
|
|
7873
|
+
return Array.from({ length: workbook.sheetCount }, (_, workbookSheetIndex) => new Set(
|
|
7874
|
+
workbook.getSheet(workbookSheetIndex).images.flatMap((drawing) => drawing.hidden && drawing.anchor ? [imageAnchorKey(dukeDrawingAnchorToXlsxAnchor(drawing.anchor))] : [])
|
|
7875
|
+
));
|
|
7876
|
+
}
|
|
7877
|
+
function mergeParsedAndApiImages(parsedImages, apiImages, hiddenAnchorKeys) {
|
|
7878
|
+
const visibleParsedImages = parsedImages.filter((image) => !hiddenAnchorKeys.has(imageAnchorKey(image.anchor)));
|
|
7879
|
+
if (visibleParsedImages.length === 0) {
|
|
7880
|
+
return apiImages;
|
|
7881
|
+
}
|
|
7882
|
+
if (apiImages.length === 0) {
|
|
7883
|
+
return visibleParsedImages;
|
|
7884
|
+
}
|
|
7885
|
+
const normalizeTextKey = (value) => value?.trim().toLowerCase() ?? "";
|
|
8178
7886
|
const imageKeys = (image) => {
|
|
8179
7887
|
const keys = [
|
|
8180
|
-
`${normalizeTextKey(image.mediaPath)}|${normalizeTextKey(image.name)}|${
|
|
8181
|
-
`${normalizeTextKey(image.mediaPath)}|${
|
|
8182
|
-
`${normalizeTextKey(image.name)}|${
|
|
8183
|
-
`${
|
|
7888
|
+
`${normalizeTextKey(image.mediaPath)}|${normalizeTextKey(image.name)}|${imageAnchorKey(image.anchor)}`,
|
|
7889
|
+
`${normalizeTextKey(image.mediaPath)}|${imageAnchorKey(image.anchor)}`,
|
|
7890
|
+
`${normalizeTextKey(image.name)}|${imageAnchorKey(image.anchor)}`,
|
|
7891
|
+
`${imageAnchorKey(image.anchor)}`
|
|
8184
7892
|
];
|
|
8185
7893
|
return keys.filter((key, index) => key && keys.indexOf(key) === index);
|
|
8186
7894
|
};
|
|
@@ -8210,7 +7918,7 @@ function mergeParsedAndApiImages(parsedImages, apiImages) {
|
|
|
8210
7918
|
}
|
|
8211
7919
|
return null;
|
|
8212
7920
|
};
|
|
8213
|
-
const merged =
|
|
7921
|
+
const merged = visibleParsedImages.map((image) => {
|
|
8214
7922
|
const apiImage = takeApiMatch(image);
|
|
8215
7923
|
if (!apiImage) {
|
|
8216
7924
|
return image;
|
|
@@ -8221,7 +7929,8 @@ function mergeParsedAndApiImages(parsedImages, apiImages) {
|
|
|
8221
7929
|
mediaPath: apiImage.mediaPath ?? image.mediaPath,
|
|
8222
7930
|
mimeType: apiImage.mimeType,
|
|
8223
7931
|
name: apiImage.name ?? image.name,
|
|
8224
|
-
src: apiImage.src
|
|
7932
|
+
src: apiImage.src,
|
|
7933
|
+
zIndex: apiImage.zIndex
|
|
8225
7934
|
};
|
|
8226
7935
|
});
|
|
8227
7936
|
return merged;
|
|
@@ -8239,12 +7948,13 @@ function createBasicWorkbookAssets(workbook) {
|
|
|
8239
7948
|
const objectUrls = [];
|
|
8240
7949
|
return {
|
|
8241
7950
|
archive: {},
|
|
7951
|
+
dirtyArchivePaths: /* @__PURE__ */ new Set(),
|
|
8242
7952
|
formControlsByWorkbookSheetIndex: collectWorkbookFormControls(workbook),
|
|
8243
7953
|
imageOriginsById: /* @__PURE__ */ new Map(),
|
|
8244
7954
|
imagesByWorkbookSheetIndex: collectWorksheetApiImages(workbook, objectUrls),
|
|
8245
7955
|
namedCellStyleByName: {},
|
|
8246
7956
|
objectUrls,
|
|
8247
|
-
shapesByWorkbookSheetIndex:
|
|
7957
|
+
shapesByWorkbookSheetIndex: Array.from({ length: workbook.sheetCount }, () => []),
|
|
8248
7958
|
sheetOrigins: Array.from({ length: workbook.sheetCount }, () => null),
|
|
8249
7959
|
sheetStatesByWorkbookSheetIndex: Array.from({ length: workbook.sheetCount }, () => null),
|
|
8250
7960
|
styleById: {},
|
|
@@ -8259,12 +7969,17 @@ function loadWorkbookImageAssets(bytes, workbook, skipXmlParsing = false) {
|
|
|
8259
7969
|
}
|
|
8260
7970
|
const parsedAssets = parseWorkbookImageAssets(bytes, workbook);
|
|
8261
7971
|
const apiImagesByWorkbookSheetIndex = collectWorksheetApiImages(workbook, parsedAssets.objectUrls);
|
|
7972
|
+
const hiddenImageAnchorsByWorkbookSheetIndex = collectHiddenWorksheetImageAnchors(workbook);
|
|
8262
7973
|
const imagesByWorkbookSheetIndex = Array.from(
|
|
8263
7974
|
{ length: Math.max(workbook.sheetCount, parsedAssets.imagesByWorkbookSheetIndex.length, apiImagesByWorkbookSheetIndex.length) },
|
|
8264
7975
|
(_, index) => {
|
|
8265
7976
|
const parsedImages = parsedAssets.imagesByWorkbookSheetIndex[index] ?? [];
|
|
8266
7977
|
const apiImages = apiImagesByWorkbookSheetIndex[index] ?? [];
|
|
8267
|
-
return mergeParsedAndApiImages(
|
|
7978
|
+
return mergeParsedAndApiImages(
|
|
7979
|
+
parsedImages,
|
|
7980
|
+
apiImages,
|
|
7981
|
+
hiddenImageAnchorsByWorkbookSheetIndex[index] ?? /* @__PURE__ */ new Set()
|
|
7982
|
+
);
|
|
8268
7983
|
}
|
|
8269
7984
|
);
|
|
8270
7985
|
return {
|
|
@@ -8575,7 +8290,11 @@ function useXlsxViewerController(options) {
|
|
|
8575
8290
|
}, [skipXmlParsing]);
|
|
8576
8291
|
const refreshWorkbookState = React.useCallback((targetWorkbook) => {
|
|
8577
8292
|
const currentFormControls = imageAssetsRef.current?.formControlsByWorkbookSheetIndex ?? [];
|
|
8578
|
-
const nextFormControls = refreshWorkbookFormControls(
|
|
8293
|
+
const nextFormControls = refreshWorkbookFormControls(
|
|
8294
|
+
targetWorkbook,
|
|
8295
|
+
currentFormControls,
|
|
8296
|
+
imageAssetsRef.current?.themePalette
|
|
8297
|
+
);
|
|
8579
8298
|
if (imageAssetsRef.current) {
|
|
8580
8299
|
imageAssetsRef.current.formControlsByWorkbookSheetIndex = nextFormControls;
|
|
8581
8300
|
}
|
|
@@ -8701,24 +8420,19 @@ function useXlsxViewerController(options) {
|
|
|
8701
8420
|
if (!effectiveSkipXmlParsing && hasIncompleteWorkerChartSnapshot(snapshot)) {
|
|
8702
8421
|
throw new Error("Worker chart payload incomplete");
|
|
8703
8422
|
}
|
|
8704
|
-
const workerImageAssets = effectiveSkipXmlParsing ? null : parseWorkbookImageAssets(
|
|
8705
|
-
new Uint8Array(buffer),
|
|
8706
|
-
snapshot.formControlsByWorkbookSheetIndex
|
|
8707
|
-
);
|
|
8423
|
+
const workerImageAssets = effectiveSkipXmlParsing ? null : parseWorkbookImageAssets(new Uint8Array(buffer));
|
|
8708
8424
|
if (!isCurrent || abortController.signal.aborted) {
|
|
8709
8425
|
revokeWorkbookImageAssets(workerImageAssets);
|
|
8710
8426
|
return;
|
|
8711
8427
|
}
|
|
8712
8428
|
setImageAssets(workerImageAssets);
|
|
8429
|
+
setFormControlsByWorkbookSheetIndex(snapshot.formControlsByWorkbookSheetIndex);
|
|
8713
8430
|
setWorkbook(null);
|
|
8714
8431
|
setSheets(snapshot.sheets);
|
|
8715
8432
|
setChartsByWorkbookSheetIndex(snapshot.chartsByWorkbookSheetIndex);
|
|
8716
8433
|
setChartsheets(snapshot.chartsheets);
|
|
8717
8434
|
setTabs(snapshot.tabs);
|
|
8718
8435
|
chartAssetsRef.current = null;
|
|
8719
|
-
if (!workerImageAssets) {
|
|
8720
|
-
setFormControlsByWorkbookSheetIndex(snapshot.formControlsByWorkbookSheetIndex);
|
|
8721
|
-
}
|
|
8722
8436
|
setWorkerTablesByWorkbookSheetIndex(snapshot.tablesByWorkbookSheetIndex);
|
|
8723
8437
|
setShouldAutoCalculate(false);
|
|
8724
8438
|
setIsWorkerBacked(true);
|
|
@@ -9224,7 +8938,8 @@ function useXlsxViewerController(options) {
|
|
|
9224
8938
|
return control2?.items?.slice() ?? [];
|
|
9225
8939
|
}
|
|
9226
8940
|
const control = target.worksheet.formControls[controlIndex];
|
|
9227
|
-
const
|
|
8941
|
+
const kind = control?.formControl.kind;
|
|
8942
|
+
const inputRange = kind?.kind === "listBox" || kind?.kind === "dropdown" ? kind.inputRange : void 0;
|
|
9228
8943
|
if (!inputRange) {
|
|
9229
8944
|
return [];
|
|
9230
8945
|
}
|
|
@@ -9643,30 +9358,17 @@ function useXlsxViewerController(options) {
|
|
|
9643
9358
|
return null;
|
|
9644
9359
|
}
|
|
9645
9360
|
recordHistoryBeforeMutation();
|
|
9646
|
-
|
|
9647
|
-
const
|
|
9648
|
-
const addedControl =
|
|
9649
|
-
|
|
9650
|
-
|
|
9651
|
-
|
|
9652
|
-
|
|
9653
|
-
|
|
9654
|
-
|
|
9655
|
-
|
|
9656
|
-
if (sibling?.kind.kind === "optionButton" && sibling.kind.state !== "unchecked") {
|
|
9657
|
-
target.worksheet.setFormControl(siblingIndex, {
|
|
9658
|
-
...formControlInputFromDukeControl(sibling),
|
|
9659
|
-
kind: { ...sibling.kind, state: "unchecked" }
|
|
9660
|
-
});
|
|
9661
|
-
}
|
|
9662
|
-
}
|
|
9361
|
+
target.worksheet.addDrawing(xlsxFormControlInputToDukeDrawing(input));
|
|
9362
|
+
const controlIndex = target.worksheet.formControlCount - 1;
|
|
9363
|
+
const addedControl = target.worksheet.formControls[controlIndex];
|
|
9364
|
+
const addedKind = addedControl?.formControl.kind;
|
|
9365
|
+
if (addedControl && (addedKind?.kind === "checkbox" || addedKind?.kind === "optionButton")) {
|
|
9366
|
+
target.worksheet.setFormControlCheckState(addedControl.drawingPath, addedKind.state);
|
|
9367
|
+
} else if (addedKind?.kind === "groupBox") {
|
|
9368
|
+
reconcileCheckedOptionButtons(target.worksheet);
|
|
9369
|
+
} else if (addedKind && "cellLink" in addedKind && addedKind.cellLink) {
|
|
9370
|
+
workbook.syncFormControls();
|
|
9663
9371
|
}
|
|
9664
|
-
syncFormControlLinkedCell(
|
|
9665
|
-
workbook,
|
|
9666
|
-
target.workbookSheetIndex,
|
|
9667
|
-
target.worksheet.formControls,
|
|
9668
|
-
controlIndex
|
|
9669
|
-
);
|
|
9670
9372
|
maybeRecalculateWorkbook(workbook);
|
|
9671
9373
|
refreshWorkbookState(workbook);
|
|
9672
9374
|
return controlIndex;
|
|
@@ -9678,34 +9380,51 @@ function useXlsxViewerController(options) {
|
|
|
9678
9380
|
return false;
|
|
9679
9381
|
}
|
|
9680
9382
|
recordHistoryBeforeMutation();
|
|
9383
|
+
const currentInput = formControlInputFromDukeControl(currentControl);
|
|
9384
|
+
if (currentInput.kind !== "formControl" || !currentControl.anchor) {
|
|
9385
|
+
return false;
|
|
9386
|
+
}
|
|
9387
|
+
const nextAnchor = patch.anchor ? xlsxAnchorToDukeDrawingAnchor(
|
|
9388
|
+
patch.anchor,
|
|
9389
|
+
patch.editAs ?? (currentControl.anchor.type === "twoCell" ? currentControl.anchor.editAs : void 0)
|
|
9390
|
+
) : patch.editAs !== void 0 && currentControl.anchor.type === "twoCell" ? { ...currentControl.anchor, editAs: patch.editAs } : currentControl.anchor;
|
|
9391
|
+
let nextKind = patch.kind ? xlsxFormControlKindToDukeKind(patch.kind) : dukeFormControlKindToInput(currentControl.formControl.kind);
|
|
9392
|
+
if (currentControl.formControl.kind.kind === "unknown" && nextKind.kind === "unknown") {
|
|
9393
|
+
nextKind = {
|
|
9394
|
+
...nextKind,
|
|
9395
|
+
legacyObjectType: nextKind.legacyObjectType ?? currentControl.formControl.kind.legacyObjectType,
|
|
9396
|
+
rawObj: nextKind.rawObj ?? currentControl.formControl.kind.rawObj,
|
|
9397
|
+
rawProperties: nextKind.rawProperties ?? currentControl.formControl.kind.rawProperties
|
|
9398
|
+
};
|
|
9399
|
+
}
|
|
9681
9400
|
const nextInput = {
|
|
9682
|
-
|
|
9683
|
-
|
|
9684
|
-
|
|
9685
|
-
|
|
9401
|
+
altText: "altText" in patch ? patch.altText : currentControl.altText,
|
|
9402
|
+
anchor: nextAnchor,
|
|
9403
|
+
formControl: {
|
|
9404
|
+
...currentInput.formControl,
|
|
9405
|
+
kind: nextKind,
|
|
9406
|
+
macroName: "macroName" in patch ? patch.macroName : currentControl.formControl.macroName,
|
|
9407
|
+
rawClientData: "rawClientData" in patch ? patch.rawClientData : currentControl.formControl.rawClientData
|
|
9408
|
+
},
|
|
9409
|
+
hidden: "hidden" in patch ? patch.hidden : currentControl.hidden,
|
|
9410
|
+
kind: "formControl",
|
|
9411
|
+
locked: "locked" in patch ? patch.locked : currentControl.locked,
|
|
9412
|
+
name: "name" in patch ? patch.name : currentControl.name,
|
|
9413
|
+
printable: "printable" in patch ? patch.printable : currentControl.printable,
|
|
9414
|
+
title: "title" in patch ? patch.title : currentControl.title
|
|
9686
9415
|
};
|
|
9687
|
-
|
|
9688
|
-
|
|
9689
|
-
|
|
9690
|
-
|
|
9691
|
-
|
|
9692
|
-
|
|
9693
|
-
|
|
9694
|
-
|
|
9695
|
-
|
|
9696
|
-
|
|
9697
|
-
|
|
9698
|
-
});
|
|
9699
|
-
}
|
|
9700
|
-
}
|
|
9416
|
+
target.worksheet.setDrawing(currentControl.drawingPath, nextInput);
|
|
9417
|
+
const updatedControl = target.worksheet.formControls[controlIndex];
|
|
9418
|
+
const updatedKind = updatedControl?.formControl.kind;
|
|
9419
|
+
const interactionChanged = updatedKind ? formControlInteractionChanged(currentControl.formControl.kind, updatedKind) : false;
|
|
9420
|
+
const groupTopologyChanged = patch.anchor !== void 0 || updatedKind !== void 0 && updatedKind.kind !== currentControl.formControl.kind.kind && (updatedKind.kind === "groupBox" || currentControl.formControl.kind.kind === "groupBox");
|
|
9421
|
+
if (interactionChanged && updatedControl && (updatedKind?.kind === "checkbox" || updatedKind?.kind === "optionButton")) {
|
|
9422
|
+
target.worksheet.setFormControlCheckState(updatedControl.drawingPath, updatedKind.state);
|
|
9423
|
+
} else if (groupTopologyChanged) {
|
|
9424
|
+
reconcileCheckedOptionButtons(target.worksheet);
|
|
9425
|
+
} else if (interactionChanged && updatedKind && "cellLink" in updatedKind && updatedKind.cellLink) {
|
|
9426
|
+
workbook.syncFormControls();
|
|
9701
9427
|
}
|
|
9702
|
-
target.worksheet.setFormControl(controlIndex, nextInput);
|
|
9703
|
-
syncFormControlLinkedCell(
|
|
9704
|
-
workbook,
|
|
9705
|
-
target.workbookSheetIndex,
|
|
9706
|
-
target.worksheet.formControls,
|
|
9707
|
-
controlIndex
|
|
9708
|
-
);
|
|
9709
9428
|
maybeRecalculateWorkbook(workbook);
|
|
9710
9429
|
refreshWorkbookState(workbook);
|
|
9711
9430
|
return true;
|
|
@@ -9716,10 +9435,16 @@ function useXlsxViewerController(options) {
|
|
|
9716
9435
|
return false;
|
|
9717
9436
|
}
|
|
9718
9437
|
recordHistoryBeforeMutation();
|
|
9719
|
-
target.worksheet.
|
|
9438
|
+
const removedControl = target.worksheet.formControls[controlIndex];
|
|
9439
|
+
const removedKind = removedControl.formControl.kind.kind;
|
|
9440
|
+
target.worksheet.removeDrawing(removedControl.drawingPath);
|
|
9441
|
+
if (removedKind === "groupBox" || removedKind === "optionButton") {
|
|
9442
|
+
reconcileCheckedOptionButtons(target.worksheet);
|
|
9443
|
+
maybeRecalculateWorkbook(workbook);
|
|
9444
|
+
}
|
|
9720
9445
|
refreshWorkbookState(workbook);
|
|
9721
9446
|
return true;
|
|
9722
|
-
}, [activeSheetIndex, getFormControlWorksheet, readOnly, recordHistoryBeforeMutation, refreshWorkbookState, workbook]);
|
|
9447
|
+
}, [activeSheetIndex, getFormControlWorksheet, maybeRecalculateWorkbook, readOnly, recordHistoryBeforeMutation, refreshWorkbookState, workbook]);
|
|
9723
9448
|
const recordCellEditHistory = React.useCallback((cell, before, after) => {
|
|
9724
9449
|
if (!activeSheet || isApplyingHistoryRef.current) {
|
|
9725
9450
|
return;
|
|
@@ -17914,7 +17639,7 @@ var THUMBNAIL_MAX_COLS = 80;
|
|
|
17914
17639
|
var THUMBNAIL_MAX_SOURCE_HEIGHT_PX = 900;
|
|
17915
17640
|
var THUMBNAIL_MAX_SOURCE_WIDTH_PX = 1440;
|
|
17916
17641
|
var LIVE_ZOOM_COMMIT_IDLE_MS = 48;
|
|
17917
|
-
var WHEEL_ZOOM_SENSITIVITY = 25e-
|
|
17642
|
+
var WHEEL_ZOOM_SENSITIVITY = 25e-4;
|
|
17918
17643
|
var WHEEL_LINE_DELTA_PX = 16;
|
|
17919
17644
|
var CHART_SOURCE_HIGHLIGHT_COLORS = ["#2563eb", "#dc2626", "#7c3aed", "#059669", "#ea580c", "#db2777"];
|
|
17920
17645
|
var CHART_SOURCE_HIGHLIGHT_COLOR_BY_ROLE = {
|
|
@@ -18957,6 +18682,7 @@ function resolveAxisStartOffset(actualIndex, actualIndices, sizes, indexByActual
|
|
|
18957
18682
|
function resolveAnchoredRect(anchor, visibleRows, visibleCols, rowHeights, colWidths, options) {
|
|
18958
18683
|
const headerHeight = options?.headerHeight ?? HEADER_HEIGHT;
|
|
18959
18684
|
const rowHeaderWidth = options?.rowHeaderWidth ?? ROW_HEADER_WIDTH;
|
|
18685
|
+
const anchorZoomFactor = options?.zoomFactor ?? 1;
|
|
18960
18686
|
const resolveMarkerLeft = (col, colOffsetEmu) => rowHeaderWidth + resolveAxisStartOffset(
|
|
18961
18687
|
col,
|
|
18962
18688
|
visibleCols,
|
|
@@ -18964,7 +18690,7 @@ function resolveAnchoredRect(anchor, visibleRows, visibleCols, rowHeights, colWi
|
|
|
18964
18690
|
options?.colIndexByActual,
|
|
18965
18691
|
options?.colPrefixSums,
|
|
18966
18692
|
options?.actualColPrefixSums
|
|
18967
|
-
) + emuToPixels(colOffsetEmu);
|
|
18693
|
+
) + emuToPixels(colOffsetEmu) * anchorZoomFactor;
|
|
18968
18694
|
const resolveMarkerTop = (row, rowOffsetEmu) => headerHeight + resolveAxisStartOffset(
|
|
18969
18695
|
row,
|
|
18970
18696
|
visibleRows,
|
|
@@ -18972,21 +18698,21 @@ function resolveAnchoredRect(anchor, visibleRows, visibleCols, rowHeights, colWi
|
|
|
18972
18698
|
options?.rowIndexByActual,
|
|
18973
18699
|
options?.rowPrefixSums,
|
|
18974
18700
|
options?.actualRowPrefixSums
|
|
18975
|
-
) + emuToPixels(rowOffsetEmu);
|
|
18701
|
+
) + emuToPixels(rowOffsetEmu) * anchorZoomFactor;
|
|
18976
18702
|
if (anchor.kind === "absolute") {
|
|
18977
18703
|
return {
|
|
18978
|
-
height: Math.max(1, emuToPixels(anchor.sizeEmu.cy)),
|
|
18979
|
-
left: rowHeaderWidth + emuToPixels(anchor.positionEmu.x),
|
|
18980
|
-
top: headerHeight + emuToPixels(anchor.positionEmu.y),
|
|
18981
|
-
width: Math.max(1, emuToPixels(anchor.sizeEmu.cx))
|
|
18704
|
+
height: Math.max(1, emuToPixels(anchor.sizeEmu.cy) * anchorZoomFactor),
|
|
18705
|
+
left: rowHeaderWidth + emuToPixels(anchor.positionEmu.x) * anchorZoomFactor,
|
|
18706
|
+
top: headerHeight + emuToPixels(anchor.positionEmu.y) * anchorZoomFactor,
|
|
18707
|
+
width: Math.max(1, emuToPixels(anchor.sizeEmu.cx) * anchorZoomFactor)
|
|
18982
18708
|
};
|
|
18983
18709
|
}
|
|
18984
18710
|
if (anchor.kind === "one-cell") {
|
|
18985
18711
|
return {
|
|
18986
|
-
height: Math.max(1, emuToPixels(anchor.sizeEmu.cy)),
|
|
18712
|
+
height: Math.max(1, emuToPixels(anchor.sizeEmu.cy) * anchorZoomFactor),
|
|
18987
18713
|
left: resolveMarkerLeft(anchor.from.col, anchor.from.colOffsetEmu),
|
|
18988
18714
|
top: resolveMarkerTop(anchor.from.row, anchor.from.rowOffsetEmu),
|
|
18989
|
-
width: Math.max(1, emuToPixels(anchor.sizeEmu.cx))
|
|
18715
|
+
width: Math.max(1, emuToPixels(anchor.sizeEmu.cx) * anchorZoomFactor)
|
|
18990
18716
|
};
|
|
18991
18717
|
}
|
|
18992
18718
|
const left = resolveMarkerLeft(anchor.from.col, anchor.from.colOffsetEmu);
|
|
@@ -22146,7 +21872,6 @@ function buildFormControlKindInput(control) {
|
|
|
22146
21872
|
return {
|
|
22147
21873
|
caption: control.caption ?? control.label ?? "",
|
|
22148
21874
|
cellLink: control.linkedCell,
|
|
22149
|
-
firstInGroup: control.firstInGroup,
|
|
22150
21875
|
kind: "optionButton",
|
|
22151
21876
|
no3D: control.no3D ?? false,
|
|
22152
21877
|
state: control.state === "checked" ? "checked" : "unchecked"
|
|
@@ -23192,6 +22917,7 @@ function XlsxGrid({
|
|
|
23192
22917
|
const canvasCornerOverlayContentRef = React4.useRef(null);
|
|
23193
22918
|
const canvasImageCacheRef = React4.useRef(/* @__PURE__ */ new Map());
|
|
23194
22919
|
const selectionOverlayRef = React4.useRef(null);
|
|
22920
|
+
const canvasSelectionLayerRef = React4.useRef(null);
|
|
23195
22921
|
const activeValidationOverlayRef = React4.useRef(null);
|
|
23196
22922
|
const fillHandleRef = React4.useRef(null);
|
|
23197
22923
|
const tableMenuRef = React4.useRef(null);
|
|
@@ -23217,9 +22943,11 @@ function XlsxGrid({
|
|
|
23217
22943
|
const liveGestureZoomRef = React4.useRef(null);
|
|
23218
22944
|
const pendingLiveGestureZoomStateRef = React4.useRef(null);
|
|
23219
22945
|
const liveGestureZoomFrameRef = React4.useRef(null);
|
|
22946
|
+
const liveGestureZoomTransformFrameRef = React4.useRef(null);
|
|
23220
22947
|
const pendingZoomAnchorRef = React4.useRef(null);
|
|
23221
22948
|
const liveZoomCommitTimerRef = React4.useRef(null);
|
|
23222
22949
|
const pendingLiveZoomCommitRef = React4.useRef(null);
|
|
22950
|
+
const gestureScrollerRectRef = React4.useRef(null);
|
|
23223
22951
|
const touchPinchStateRef = React4.useRef(null);
|
|
23224
22952
|
const safariPinchStartZoomRef = React4.useRef(null);
|
|
23225
22953
|
const canvasTransformStyleCacheRef = React4.useRef(/* @__PURE__ */ new WeakMap());
|
|
@@ -23303,7 +23031,10 @@ function XlsxGrid({
|
|
|
23303
23031
|
const setInteractionMode = React4.useCallback((mode) => {
|
|
23304
23032
|
interactionModeRef.current = mode;
|
|
23305
23033
|
}, []);
|
|
23306
|
-
const worksheet =
|
|
23034
|
+
const worksheet = React4.useMemo(
|
|
23035
|
+
() => getActiveWorksheet(),
|
|
23036
|
+
[activeSheetIndex, getActiveWorksheet, revision]
|
|
23037
|
+
);
|
|
23307
23038
|
const mergedRegions = React4.useMemo(() => {
|
|
23308
23039
|
const regions = [];
|
|
23309
23040
|
const rawMergedRegions = Array.isArray(worksheet?.mergedRegions) ? worksheet.mergedRegions : [];
|
|
@@ -23383,8 +23114,31 @@ function XlsxGrid({
|
|
|
23383
23114
|
const liveZoomScale2 = isLiveZooming2 ? Math.max(0.1, currentLiveGestureZoom.targetZoomScale / currentLiveGestureZoom.baseZoomScale) : 1;
|
|
23384
23115
|
const scrollDeltaX = paintedViewport.left - nextLiveViewport.left;
|
|
23385
23116
|
const scrollDeltaY = paintedViewport.top - nextLiveViewport.top;
|
|
23386
|
-
const
|
|
23387
|
-
|
|
23117
|
+
const resolveClampedLiveZoomAnchor = (scrollOffset, viewportSize, scrollExtent, gestureAnchor) => {
|
|
23118
|
+
if (!isLiveZooming2 || liveZoomScale2 === 1) {
|
|
23119
|
+
return gestureAnchor;
|
|
23120
|
+
}
|
|
23121
|
+
const targetScrollExtent = Math.max(viewportSize, scrollExtent * liveZoomScale2);
|
|
23122
|
+
const targetScrollOffset = clampValue(
|
|
23123
|
+
(scrollOffset + gestureAnchor) * liveZoomScale2 - gestureAnchor,
|
|
23124
|
+
0,
|
|
23125
|
+
Math.max(0, targetScrollExtent - viewportSize)
|
|
23126
|
+
);
|
|
23127
|
+
return (scrollOffset * liveZoomScale2 - targetScrollOffset) / (1 - liveZoomScale2);
|
|
23128
|
+
};
|
|
23129
|
+
const scroller = scrollRef.current;
|
|
23130
|
+
const liveZoomAnchorX = resolveClampedLiveZoomAnchor(
|
|
23131
|
+
nextLiveViewport.left,
|
|
23132
|
+
nextLiveViewport.width,
|
|
23133
|
+
scroller?.scrollWidth ?? nextLiveViewport.width,
|
|
23134
|
+
currentLiveGestureZoom?.anchor.x ?? 0
|
|
23135
|
+
);
|
|
23136
|
+
const liveZoomAnchorY = resolveClampedLiveZoomAnchor(
|
|
23137
|
+
nextLiveViewport.top,
|
|
23138
|
+
nextLiveViewport.height,
|
|
23139
|
+
scroller?.scrollHeight ?? nextLiveViewport.height,
|
|
23140
|
+
currentLiveGestureZoom?.anchor.y ?? 0
|
|
23141
|
+
);
|
|
23388
23142
|
const applyElementTransform = (element, transform, willChange, transformOrigin = null) => {
|
|
23389
23143
|
if (!element) {
|
|
23390
23144
|
return;
|
|
@@ -23405,7 +23159,10 @@ function XlsxGrid({
|
|
|
23405
23159
|
willChange
|
|
23406
23160
|
});
|
|
23407
23161
|
};
|
|
23408
|
-
const
|
|
23162
|
+
const resolveLiveTranslation = (baseTranslation, anchor, origin) => baseTranslation * liveZoomScale2 + (anchor - origin) * (1 - liveZoomScale2);
|
|
23163
|
+
const applyCanvasTransform = (canvas, baseTranslateX, baseTranslateY, originX, originY, anchorX, anchorY) => {
|
|
23164
|
+
const translateX = resolveLiveTranslation(baseTranslateX, anchorX, originX);
|
|
23165
|
+
const translateY = resolveLiveTranslation(baseTranslateY, anchorY, originY);
|
|
23409
23166
|
const shouldTransform = translateX !== 0 || translateY !== 0 || liveZoomScale2 !== 1;
|
|
23410
23167
|
applyElementTransform(
|
|
23411
23168
|
canvas,
|
|
@@ -23413,85 +23170,169 @@ function XlsxGrid({
|
|
|
23413
23170
|
shouldTransform ? "transform" : ""
|
|
23414
23171
|
);
|
|
23415
23172
|
};
|
|
23416
|
-
const applyOverlayTransform = (element,
|
|
23173
|
+
const applyOverlayTransform = (element, baseTranslateX, baseTranslateY, paneLeft, paneTop, anchorX, anchorY) => {
|
|
23174
|
+
const translateX = resolveLiveTranslation(baseTranslateX, anchorX, paneLeft);
|
|
23175
|
+
const translateY = resolveLiveTranslation(baseTranslateY, anchorY, paneTop);
|
|
23417
23176
|
applyElementTransform(
|
|
23418
23177
|
element,
|
|
23419
|
-
liveZoomScale2 !== 1 ? `translate3d(${translateX
|
|
23178
|
+
liveZoomScale2 !== 1 ? `translate3d(${translateX}px, ${translateY}px, 0) scale(${liveZoomScale2})` : `translate3d(${baseTranslateX}px, ${baseTranslateY}px, 0)`,
|
|
23420
23179
|
"transform",
|
|
23421
23180
|
"0 0"
|
|
23422
23181
|
);
|
|
23423
23182
|
};
|
|
23183
|
+
const liveScrollBodyViewportWidth = Math.max(0, nextLiveViewport.width - liveFrozenPaneRight);
|
|
23184
|
+
const liveScrollBodyViewportHeight = Math.max(0, nextLiveViewport.height - liveFrozenPaneBottom);
|
|
23185
|
+
const liveScrollBodyCanvasLeft = liveFrozenPaneRight - Math.min(CANVAS_SCROLL_BUFFER_PX, liveScrollBodyViewportWidth);
|
|
23186
|
+
const liveScrollBodyCanvasTop = liveFrozenPaneBottom - Math.min(CANVAS_SCROLL_BUFFER_PX, liveScrollBodyViewportHeight);
|
|
23187
|
+
const selectionLayerTranslateX = (nextLiveViewport.left + liveZoomAnchorX) * (1 - liveZoomScale2);
|
|
23188
|
+
const selectionLayerTranslateY = (nextLiveViewport.top + liveZoomAnchorY) * (1 - liveZoomScale2);
|
|
23189
|
+
const shouldTransformSelectionLayer = experimentalCanvas && isLiveZooming2 && liveZoomScale2 !== 1;
|
|
23190
|
+
applyElementTransform(
|
|
23191
|
+
canvasSelectionLayerRef.current,
|
|
23192
|
+
shouldTransformSelectionLayer ? `translate3d(${selectionLayerTranslateX}px, ${selectionLayerTranslateY}px, 0) scale(${liveZoomScale2})` : "",
|
|
23193
|
+
shouldTransformSelectionLayer ? "transform" : "",
|
|
23194
|
+
"0 0"
|
|
23195
|
+
);
|
|
23424
23196
|
applyCanvasTransform(
|
|
23425
23197
|
scrollBodyCanvasRef.current,
|
|
23426
|
-
scrollDeltaX
|
|
23427
|
-
scrollDeltaY
|
|
23198
|
+
scrollDeltaX,
|
|
23199
|
+
scrollDeltaY,
|
|
23200
|
+
liveScrollBodyCanvasLeft,
|
|
23201
|
+
liveScrollBodyCanvasTop,
|
|
23202
|
+
liveZoomAnchorX,
|
|
23203
|
+
liveZoomAnchorY
|
|
23428
23204
|
);
|
|
23429
23205
|
applyCanvasTransform(
|
|
23430
23206
|
topBodyCanvasRef.current,
|
|
23431
|
-
scrollDeltaX
|
|
23432
|
-
|
|
23207
|
+
scrollDeltaX,
|
|
23208
|
+
0,
|
|
23209
|
+
liveScrollBodyCanvasLeft,
|
|
23210
|
+
liveDisplayHeaderHeight,
|
|
23211
|
+
liveZoomAnchorX,
|
|
23212
|
+
0
|
|
23433
23213
|
);
|
|
23434
23214
|
applyCanvasTransform(
|
|
23435
23215
|
leftBodyCanvasRef.current,
|
|
23436
|
-
|
|
23437
|
-
scrollDeltaY
|
|
23216
|
+
0,
|
|
23217
|
+
scrollDeltaY,
|
|
23218
|
+
liveDisplayRowHeaderWidth,
|
|
23219
|
+
liveScrollBodyCanvasTop,
|
|
23220
|
+
0,
|
|
23221
|
+
liveZoomAnchorY
|
|
23438
23222
|
);
|
|
23439
23223
|
applyCanvasTransform(
|
|
23440
23224
|
cornerBodyCanvasRef.current,
|
|
23441
|
-
|
|
23442
|
-
|
|
23225
|
+
0,
|
|
23226
|
+
0,
|
|
23227
|
+
liveDisplayRowHeaderWidth,
|
|
23228
|
+
liveDisplayHeaderHeight,
|
|
23229
|
+
0,
|
|
23230
|
+
0
|
|
23443
23231
|
);
|
|
23444
23232
|
applyCanvasTransform(
|
|
23445
23233
|
topScrollHeaderCanvasRef.current,
|
|
23446
|
-
scrollDeltaX
|
|
23447
|
-
|
|
23234
|
+
scrollDeltaX,
|
|
23235
|
+
0,
|
|
23236
|
+
liveScrollBodyCanvasLeft,
|
|
23237
|
+
0,
|
|
23238
|
+
liveZoomAnchorX,
|
|
23239
|
+
0
|
|
23448
23240
|
);
|
|
23449
23241
|
applyCanvasTransform(
|
|
23450
23242
|
topFrozenHeaderCanvasRef.current,
|
|
23451
|
-
|
|
23452
|
-
|
|
23243
|
+
0,
|
|
23244
|
+
0,
|
|
23245
|
+
liveDisplayRowHeaderWidth,
|
|
23246
|
+
0,
|
|
23247
|
+
0,
|
|
23248
|
+
0
|
|
23453
23249
|
);
|
|
23454
23250
|
applyCanvasTransform(
|
|
23455
23251
|
leftScrollHeaderCanvasRef.current,
|
|
23456
|
-
|
|
23457
|
-
scrollDeltaY
|
|
23252
|
+
0,
|
|
23253
|
+
scrollDeltaY,
|
|
23254
|
+
0,
|
|
23255
|
+
liveScrollBodyCanvasTop,
|
|
23256
|
+
0,
|
|
23257
|
+
liveZoomAnchorY
|
|
23458
23258
|
);
|
|
23459
23259
|
applyCanvasTransform(
|
|
23460
23260
|
leftFrozenHeaderCanvasRef.current,
|
|
23461
|
-
|
|
23462
|
-
|
|
23261
|
+
0,
|
|
23262
|
+
0,
|
|
23263
|
+
0,
|
|
23264
|
+
liveDisplayHeaderHeight,
|
|
23265
|
+
0,
|
|
23266
|
+
0
|
|
23463
23267
|
);
|
|
23464
23268
|
applyCanvasTransform(
|
|
23465
23269
|
cornerHeaderCanvasRef.current,
|
|
23466
|
-
|
|
23467
|
-
|
|
23270
|
+
0,
|
|
23271
|
+
0,
|
|
23272
|
+
0,
|
|
23273
|
+
0,
|
|
23274
|
+
0,
|
|
23275
|
+
0
|
|
23468
23276
|
);
|
|
23469
23277
|
applyOverlayTransform(
|
|
23470
23278
|
canvasScrollOverlayContentRef.current,
|
|
23471
23279
|
-nextLiveViewport.left - liveFrozenPaneRight,
|
|
23472
|
-
-nextLiveViewport.top - liveFrozenPaneBottom
|
|
23280
|
+
-nextLiveViewport.top - liveFrozenPaneBottom,
|
|
23281
|
+
liveFrozenPaneRight,
|
|
23282
|
+
liveFrozenPaneBottom,
|
|
23283
|
+
liveZoomAnchorX,
|
|
23284
|
+
liveZoomAnchorY
|
|
23473
23285
|
);
|
|
23474
23286
|
applyOverlayTransform(
|
|
23475
23287
|
canvasTopOverlayContentRef.current,
|
|
23476
23288
|
-nextLiveViewport.left - liveFrozenPaneRight,
|
|
23477
|
-
-liveDisplayHeaderHeight
|
|
23289
|
+
-liveDisplayHeaderHeight,
|
|
23290
|
+
liveFrozenPaneRight,
|
|
23291
|
+
liveDisplayHeaderHeight,
|
|
23292
|
+
liveZoomAnchorX,
|
|
23293
|
+
0
|
|
23478
23294
|
);
|
|
23479
23295
|
applyOverlayTransform(
|
|
23480
23296
|
canvasLeftOverlayContentRef.current,
|
|
23481
23297
|
-liveDisplayRowHeaderWidth,
|
|
23482
|
-
-nextLiveViewport.top - liveFrozenPaneBottom
|
|
23298
|
+
-nextLiveViewport.top - liveFrozenPaneBottom,
|
|
23299
|
+
liveDisplayRowHeaderWidth,
|
|
23300
|
+
liveFrozenPaneBottom,
|
|
23301
|
+
0,
|
|
23302
|
+
liveZoomAnchorY
|
|
23483
23303
|
);
|
|
23484
23304
|
applyOverlayTransform(
|
|
23485
23305
|
canvasCornerOverlayContentRef.current,
|
|
23486
23306
|
-liveDisplayRowHeaderWidth,
|
|
23487
|
-
-liveDisplayHeaderHeight
|
|
23307
|
+
-liveDisplayHeaderHeight,
|
|
23308
|
+
liveDisplayRowHeaderWidth,
|
|
23309
|
+
liveDisplayHeaderHeight,
|
|
23310
|
+
0,
|
|
23311
|
+
0
|
|
23488
23312
|
);
|
|
23489
|
-
}, [zoomScale]);
|
|
23313
|
+
}, [experimentalCanvas, zoomScale]);
|
|
23490
23314
|
const updateLiveGestureZoomState = React4.useCallback((nextState) => {
|
|
23491
|
-
const
|
|
23315
|
+
const previousState = liveGestureZoomRef.current;
|
|
23316
|
+
const resolvedState = typeof nextState === "function" ? nextState(previousState) : nextState;
|
|
23492
23317
|
liveGestureZoomRef.current = resolvedState;
|
|
23318
|
+
const shouldApplyTransformImmediately = !experimentalCanvas || previousState === null || resolvedState === null;
|
|
23319
|
+
if (shouldApplyTransformImmediately) {
|
|
23320
|
+
if (liveGestureZoomTransformFrameRef.current !== null) {
|
|
23321
|
+
window.cancelAnimationFrame(liveGestureZoomTransformFrameRef.current);
|
|
23322
|
+
liveGestureZoomTransformFrameRef.current = null;
|
|
23323
|
+
}
|
|
23324
|
+
applyCanvasViewportCompensation();
|
|
23325
|
+
} else if (liveGestureZoomTransformFrameRef.current === null) {
|
|
23326
|
+
liveGestureZoomTransformFrameRef.current = window.requestAnimationFrame(() => {
|
|
23327
|
+
liveGestureZoomTransformFrameRef.current = null;
|
|
23328
|
+
applyCanvasViewportCompensation();
|
|
23329
|
+
});
|
|
23330
|
+
}
|
|
23331
|
+
const shouldSyncReactState = !experimentalCanvas || previousState === null !== (resolvedState === null);
|
|
23332
|
+
if (!shouldSyncReactState) {
|
|
23333
|
+
return;
|
|
23334
|
+
}
|
|
23493
23335
|
pendingLiveGestureZoomStateRef.current = resolvedState;
|
|
23494
|
-
applyCanvasViewportCompensation();
|
|
23495
23336
|
if (liveGestureZoomFrameRef.current !== null) {
|
|
23496
23337
|
return;
|
|
23497
23338
|
}
|
|
@@ -23501,7 +23342,7 @@ function XlsxGrid({
|
|
|
23501
23342
|
pendingLiveGestureZoomStateRef.current = null;
|
|
23502
23343
|
setLiveGestureZoom(pendingState);
|
|
23503
23344
|
});
|
|
23504
|
-
}, [applyCanvasViewportCompensation]);
|
|
23345
|
+
}, [applyCanvasViewportCompensation, experimentalCanvas]);
|
|
23505
23346
|
const clearLiveZoomCommitTimer = React4.useCallback(() => {
|
|
23506
23347
|
if (liveZoomCommitTimerRef.current !== null) {
|
|
23507
23348
|
window.clearTimeout(liveZoomCommitTimerRef.current);
|
|
@@ -23514,6 +23355,7 @@ function XlsxGrid({
|
|
|
23514
23355
|
pendingZoomAnchorRef.current = null;
|
|
23515
23356
|
touchPinchStateRef.current = null;
|
|
23516
23357
|
safariPinchStartZoomRef.current = null;
|
|
23358
|
+
gestureScrollerRectRef.current = null;
|
|
23517
23359
|
gestureZoomScaleRef.current = committedZoomScaleRef.current;
|
|
23518
23360
|
updateLiveGestureZoomState(null);
|
|
23519
23361
|
}, [clearLiveZoomCommitTimer, updateLiveGestureZoomState]);
|
|
@@ -24128,6 +23970,10 @@ function XlsxGrid({
|
|
|
24128
23970
|
window.cancelAnimationFrame(liveGestureZoomFrameRef.current);
|
|
24129
23971
|
liveGestureZoomFrameRef.current = null;
|
|
24130
23972
|
}
|
|
23973
|
+
if (liveGestureZoomTransformFrameRef.current !== null) {
|
|
23974
|
+
window.cancelAnimationFrame(liveGestureZoomTransformFrameRef.current);
|
|
23975
|
+
liveGestureZoomTransformFrameRef.current = null;
|
|
23976
|
+
}
|
|
24131
23977
|
if (drawingViewportFrameRef.current !== null) {
|
|
24132
23978
|
window.cancelAnimationFrame(drawingViewportFrameRef.current);
|
|
24133
23979
|
drawingViewportFrameRef.current = null;
|
|
@@ -24391,6 +24237,7 @@ function XlsxGrid({
|
|
|
24391
24237
|
const handleScrollerScroll = React4.useCallback((event) => {
|
|
24392
24238
|
const currentScroller = event.currentTarget;
|
|
24393
24239
|
cachedScrollerRectRef.current = null;
|
|
24240
|
+
gestureScrollerRectRef.current = null;
|
|
24394
24241
|
const paintedViewport = paintedDrawingViewportRef.current;
|
|
24395
24242
|
const shouldSyncDrawingViewportImmediately = Math.abs(currentScroller.scrollLeft - paintedViewport.left) > CANVAS_IMMEDIATE_VIEWPORT_SYNC_THRESHOLD_PX || Math.abs(currentScroller.scrollTop - paintedViewport.top) > CANVAS_IMMEDIATE_VIEWPORT_SYNC_THRESHOLD_PX;
|
|
24396
24243
|
syncDrawingViewport(currentScroller, { immediate: shouldSyncDrawingViewportImmediately });
|
|
@@ -24425,7 +24272,9 @@ function XlsxGrid({
|
|
|
24425
24272
|
return;
|
|
24426
24273
|
}
|
|
24427
24274
|
event.preventDefault();
|
|
24428
|
-
const
|
|
24275
|
+
const scrollerRect = gestureScrollerRectRef.current ?? scroller.getBoundingClientRect();
|
|
24276
|
+
gestureScrollerRectRef.current = scrollerRect;
|
|
24277
|
+
const anchor = resolveEventAnchor(event.clientX, event.clientY, scrollerRect);
|
|
24429
24278
|
updateLiveGestureZoomTarget(
|
|
24430
24279
|
gestureZoomScaleRef.current * Math.exp(-delta * WHEEL_ZOOM_SENSITIVITY),
|
|
24431
24280
|
anchor
|
|
@@ -24445,10 +24294,12 @@ function XlsxGrid({
|
|
|
24445
24294
|
return;
|
|
24446
24295
|
}
|
|
24447
24296
|
event.preventDefault();
|
|
24297
|
+
const scrollerRect = scroller.getBoundingClientRect();
|
|
24298
|
+
gestureScrollerRectRef.current = scrollerRect;
|
|
24448
24299
|
const anchor = resolveEventAnchor(
|
|
24449
24300
|
(firstTouch.clientX + secondTouch.clientX) / 2,
|
|
24450
24301
|
(firstTouch.clientY + secondTouch.clientY) / 2,
|
|
24451
|
-
|
|
24302
|
+
scrollerRect
|
|
24452
24303
|
);
|
|
24453
24304
|
clearLiveZoomCommitTimer();
|
|
24454
24305
|
updateLiveGestureZoomState({
|
|
@@ -24476,10 +24327,12 @@ function XlsxGrid({
|
|
|
24476
24327
|
return;
|
|
24477
24328
|
}
|
|
24478
24329
|
event.preventDefault();
|
|
24330
|
+
const scrollerRect = gestureScrollerRectRef.current ?? scroller.getBoundingClientRect();
|
|
24331
|
+
gestureScrollerRectRef.current = scrollerRect;
|
|
24479
24332
|
const anchor = resolveEventAnchor(
|
|
24480
24333
|
(firstTouch.clientX + secondTouch.clientX) / 2,
|
|
24481
24334
|
(firstTouch.clientY + secondTouch.clientY) / 2,
|
|
24482
|
-
|
|
24335
|
+
scrollerRect
|
|
24483
24336
|
);
|
|
24484
24337
|
updateLiveGestureZoomTarget(
|
|
24485
24338
|
pinchState.startZoomScale * distance / pinchState.startDistance,
|
|
@@ -24500,10 +24353,12 @@ function XlsxGrid({
|
|
|
24500
24353
|
const handleGestureStart = (event) => {
|
|
24501
24354
|
const gestureEvent = event;
|
|
24502
24355
|
event.preventDefault();
|
|
24356
|
+
const scrollerRect = scroller.getBoundingClientRect();
|
|
24357
|
+
gestureScrollerRectRef.current = scrollerRect;
|
|
24503
24358
|
const anchor = resolveEventAnchor(
|
|
24504
24359
|
gestureEvent.clientX,
|
|
24505
24360
|
gestureEvent.clientY,
|
|
24506
|
-
|
|
24361
|
+
scrollerRect
|
|
24507
24362
|
);
|
|
24508
24363
|
clearLiveZoomCommitTimer();
|
|
24509
24364
|
safariPinchStartZoomRef.current = committedZoomScaleRef.current;
|
|
@@ -24521,10 +24376,12 @@ function XlsxGrid({
|
|
|
24521
24376
|
return;
|
|
24522
24377
|
}
|
|
24523
24378
|
event.preventDefault();
|
|
24379
|
+
const scrollerRect = gestureScrollerRectRef.current ?? scroller.getBoundingClientRect();
|
|
24380
|
+
gestureScrollerRectRef.current = scrollerRect;
|
|
24524
24381
|
const anchor = resolveEventAnchor(
|
|
24525
24382
|
gestureEvent.clientX,
|
|
24526
24383
|
gestureEvent.clientY,
|
|
24527
|
-
|
|
24384
|
+
scrollerRect
|
|
24528
24385
|
);
|
|
24529
24386
|
updateLiveGestureZoomTarget(startZoomScale * gestureEvent.scale, anchor);
|
|
24530
24387
|
};
|
|
@@ -25518,7 +25375,8 @@ function XlsxGrid({
|
|
|
25518
25375
|
headerHeight: displayHeaderHeight,
|
|
25519
25376
|
rowIndexByActual,
|
|
25520
25377
|
rowHeaderWidth: displayRowHeaderWidth,
|
|
25521
|
-
rowPrefixSums
|
|
25378
|
+
rowPrefixSums,
|
|
25379
|
+
zoomFactor
|
|
25522
25380
|
})
|
|
25523
25381
|
})) : [],
|
|
25524
25382
|
[
|
|
@@ -25536,7 +25394,8 @@ function XlsxGrid({
|
|
|
25536
25394
|
rowPrefixSums,
|
|
25537
25395
|
showImages,
|
|
25538
25396
|
visibleCols,
|
|
25539
|
-
visibleRows
|
|
25397
|
+
visibleRows,
|
|
25398
|
+
zoomFactor
|
|
25540
25399
|
]
|
|
25541
25400
|
);
|
|
25542
25401
|
const shapeRects = React4.useMemo(
|
|
@@ -25549,7 +25408,8 @@ function XlsxGrid({
|
|
|
25549
25408
|
headerHeight: displayHeaderHeight,
|
|
25550
25409
|
rowIndexByActual,
|
|
25551
25410
|
rowHeaderWidth: displayRowHeaderWidth,
|
|
25552
|
-
rowPrefixSums
|
|
25411
|
+
rowPrefixSums,
|
|
25412
|
+
zoomFactor
|
|
25553
25413
|
}),
|
|
25554
25414
|
shape
|
|
25555
25415
|
})) : [],
|
|
@@ -25567,7 +25427,8 @@ function XlsxGrid({
|
|
|
25567
25427
|
shapes,
|
|
25568
25428
|
showImages,
|
|
25569
25429
|
visibleCols,
|
|
25570
|
-
visibleRows
|
|
25430
|
+
visibleRows,
|
|
25431
|
+
zoomFactor
|
|
25571
25432
|
]
|
|
25572
25433
|
);
|
|
25573
25434
|
const formControlRects = React4.useMemo(
|
|
@@ -25581,7 +25442,8 @@ function XlsxGrid({
|
|
|
25581
25442
|
headerHeight: displayHeaderHeight,
|
|
25582
25443
|
rowIndexByActual,
|
|
25583
25444
|
rowHeaderWidth: displayRowHeaderWidth,
|
|
25584
|
-
rowPrefixSums
|
|
25445
|
+
rowPrefixSums,
|
|
25446
|
+
zoomFactor
|
|
25585
25447
|
})
|
|
25586
25448
|
})) : [],
|
|
25587
25449
|
[
|
|
@@ -25598,7 +25460,8 @@ function XlsxGrid({
|
|
|
25598
25460
|
rowPrefixSums,
|
|
25599
25461
|
showImages,
|
|
25600
25462
|
visibleCols,
|
|
25601
|
-
visibleRows
|
|
25463
|
+
visibleRows,
|
|
25464
|
+
zoomFactor
|
|
25602
25465
|
]
|
|
25603
25466
|
);
|
|
25604
25467
|
const chartRects = React4.useMemo(
|
|
@@ -25612,7 +25475,8 @@ function XlsxGrid({
|
|
|
25612
25475
|
headerHeight: displayHeaderHeight,
|
|
25613
25476
|
rowIndexByActual,
|
|
25614
25477
|
rowHeaderWidth: displayRowHeaderWidth,
|
|
25615
|
-
rowPrefixSums
|
|
25478
|
+
rowPrefixSums,
|
|
25479
|
+
zoomFactor
|
|
25616
25480
|
})
|
|
25617
25481
|
})) : [],
|
|
25618
25482
|
[
|
|
@@ -25630,7 +25494,8 @@ function XlsxGrid({
|
|
|
25630
25494
|
rowPrefixSums,
|
|
25631
25495
|
showImages,
|
|
25632
25496
|
visibleCols,
|
|
25633
|
-
visibleRows
|
|
25497
|
+
visibleRows,
|
|
25498
|
+
zoomFactor
|
|
25634
25499
|
]
|
|
25635
25500
|
);
|
|
25636
25501
|
const shouldBakeCanvasStaticDrawings = Boolean(experimentalCanvas && readOnly && showImages);
|
|
@@ -27086,6 +26951,8 @@ function XlsxGrid({
|
|
|
27086
26951
|
palette,
|
|
27087
26952
|
rowHeaderWidth,
|
|
27088
26953
|
rowSignature: buildRenderedAxisSignature(canvasVisibleRowItems, (item) => item.index),
|
|
26954
|
+
viewportLeft: drawingViewport.left,
|
|
26955
|
+
viewportTop: drawingViewport.top,
|
|
27089
26956
|
zoomFactor
|
|
27090
26957
|
};
|
|
27091
26958
|
const nextHeaderCanvasSignature = {
|
|
@@ -27105,7 +26972,7 @@ function XlsxGrid({
|
|
|
27105
26972
|
const previousBodyCanvasSignature = paintedBodyCanvasSignatureRef.current;
|
|
27106
26973
|
const previousHeaderCanvasSignature = paintedHeaderCanvasSignatureRef.current;
|
|
27107
26974
|
const previousPaintedViewport = paintedDrawingViewportRef.current;
|
|
27108
|
-
const shouldRepaintBody = !(previousBodyCanvasSignature && previousBodyCanvasSignature.activeSheet === nextBodyCanvasSignature.activeSheet && previousBodyCanvasSignature.bakedDrawingSignature === nextBodyCanvasSignature.bakedDrawingSignature && previousBodyCanvasSignature.bodyHeight === nextBodyCanvasSignature.bodyHeight && previousBodyCanvasSignature.bodyWidth === nextBodyCanvasSignature.bodyWidth && previousBodyCanvasSignature.colSignature === nextBodyCanvasSignature.colSignature && previousBodyCanvasSignature.getCellData === nextBodyCanvasSignature.getCellData && previousBodyCanvasSignature.headerHeight === nextBodyCanvasSignature.headerHeight && previousBodyCanvasSignature.palette === nextBodyCanvasSignature.palette && previousBodyCanvasSignature.rowHeaderWidth === nextBodyCanvasSignature.rowHeaderWidth && previousBodyCanvasSignature.rowSignature === nextBodyCanvasSignature.rowSignature && previousBodyCanvasSignature.zoomFactor === nextBodyCanvasSignature.zoomFactor);
|
|
26975
|
+
const shouldRepaintBody = !(previousBodyCanvasSignature && previousBodyCanvasSignature.activeSheet === nextBodyCanvasSignature.activeSheet && previousBodyCanvasSignature.bakedDrawingSignature === nextBodyCanvasSignature.bakedDrawingSignature && previousBodyCanvasSignature.bodyHeight === nextBodyCanvasSignature.bodyHeight && previousBodyCanvasSignature.bodyWidth === nextBodyCanvasSignature.bodyWidth && previousBodyCanvasSignature.colSignature === nextBodyCanvasSignature.colSignature && previousBodyCanvasSignature.getCellData === nextBodyCanvasSignature.getCellData && previousBodyCanvasSignature.headerHeight === nextBodyCanvasSignature.headerHeight && previousBodyCanvasSignature.palette === nextBodyCanvasSignature.palette && previousBodyCanvasSignature.rowHeaderWidth === nextBodyCanvasSignature.rowHeaderWidth && previousBodyCanvasSignature.rowSignature === nextBodyCanvasSignature.rowSignature && previousBodyCanvasSignature.viewportLeft === nextBodyCanvasSignature.viewportLeft && previousBodyCanvasSignature.viewportTop === nextBodyCanvasSignature.viewportTop && previousBodyCanvasSignature.zoomFactor === nextBodyCanvasSignature.zoomFactor);
|
|
27109
26976
|
const shouldRepaintHeaders = !(previousHeaderCanvasSignature && previousHeaderCanvasSignature.activeSheet === nextHeaderCanvasSignature.activeSheet && previousHeaderCanvasSignature.bodyHeight === nextHeaderCanvasSignature.bodyHeight && previousHeaderCanvasSignature.bodyWidth === nextHeaderCanvasSignature.bodyWidth && previousHeaderCanvasSignature.colSignature === nextHeaderCanvasSignature.colSignature && previousHeaderCanvasSignature.headerHeight === nextHeaderCanvasSignature.headerHeight && previousHeaderCanvasSignature.palette === nextHeaderCanvasSignature.palette && previousHeaderCanvasSignature.rangeSignature === nextHeaderCanvasSignature.rangeSignature && previousHeaderCanvasSignature.rowHeaderWidth === nextHeaderCanvasSignature.rowHeaderWidth && previousHeaderCanvasSignature.rowSignature === nextHeaderCanvasSignature.rowSignature && previousHeaderCanvasSignature.viewportLeft === nextHeaderCanvasSignature.viewportLeft && previousHeaderCanvasSignature.viewportTop === nextHeaderCanvasSignature.viewportTop && previousHeaderCanvasSignature.zoomFactor === nextHeaderCanvasSignature.zoomFactor);
|
|
27110
26977
|
const canBlitBody = Boolean(
|
|
27111
26978
|
shouldRepaintBody && previousBodyCanvasSignature && previousBodyCanvasSignature.activeSheet === nextBodyCanvasSignature.activeSheet && previousBodyCanvasSignature.bakedDrawingSignature === nextBodyCanvasSignature.bakedDrawingSignature && previousBodyCanvasSignature.bodyHeight === nextBodyCanvasSignature.bodyHeight && previousBodyCanvasSignature.bodyWidth === nextBodyCanvasSignature.bodyWidth && previousBodyCanvasSignature.getCellData === nextBodyCanvasSignature.getCellData && previousBodyCanvasSignature.headerHeight === nextBodyCanvasSignature.headerHeight && previousBodyCanvasSignature.palette === nextBodyCanvasSignature.palette && previousBodyCanvasSignature.rowHeaderWidth === nextBodyCanvasSignature.rowHeaderWidth && previousBodyCanvasSignature.zoomFactor === nextBodyCanvasSignature.zoomFactor
|
|
@@ -28332,7 +28199,8 @@ function XlsxGrid({
|
|
|
28332
28199
|
const headerLabelLiveScale = isLiveZooming ? liveZoomScale : 1;
|
|
28333
28200
|
const selectionBorderWidth = Math.max(1, zoomFactor);
|
|
28334
28201
|
const shouldAnimateCanvasSelection = experimentalCanvas && enableCanvasSelectionAnimation;
|
|
28335
|
-
const
|
|
28202
|
+
const shouldAnimateCanvasSelectionGeometry = shouldAnimateCanvasSelection && liveGestureZoom === null;
|
|
28203
|
+
const canvasSelectionTransition = shouldAnimateCanvasSelectionGeometry ? "left 120ms cubic-bezier(0.22, 1, 0.36, 1), top 120ms cubic-bezier(0.22, 1, 0.36, 1), width 120ms cubic-bezier(0.22, 1, 0.36, 1), height 120ms cubic-bezier(0.22, 1, 0.36, 1), opacity 100ms linear" : "none";
|
|
28336
28204
|
const rowColSpan = renderedCols.length + 1 + (leadingColumnSpacerWidth > 0 ? 1 : 0) + (trailingColumnSpacerWidth > 0 ? 1 : 0);
|
|
28337
28205
|
const gutterSeparatorShadow = `inset -1px 0 0 ${palette.border}, inset 0 -1px 0 ${palette.border}`;
|
|
28338
28206
|
const maxDrawingOverlayZIndex = Math.max(
|
|
@@ -30451,81 +30319,101 @@ function XlsxGrid({
|
|
|
30451
30319
|
]
|
|
30452
30320
|
}
|
|
30453
30321
|
),
|
|
30454
|
-
/* @__PURE__ */
|
|
30322
|
+
/* @__PURE__ */ jsxs3(
|
|
30455
30323
|
"div",
|
|
30456
30324
|
{
|
|
30457
|
-
ref:
|
|
30325
|
+
ref: canvasSelectionLayerRef,
|
|
30458
30326
|
style: {
|
|
30459
|
-
|
|
30460
|
-
|
|
30461
|
-
|
|
30462
|
-
contain: "layout paint",
|
|
30463
|
-
height: resolvedSelectionOverlay?.height ?? 0,
|
|
30464
|
-
left: resolvedSelectionOverlay?.left ?? 0,
|
|
30465
|
-
opacity: resolvedSelectionOverlay ? 1 : 0,
|
|
30327
|
+
height: 0,
|
|
30328
|
+
left: 0,
|
|
30329
|
+
overflow: "visible",
|
|
30466
30330
|
pointerEvents: "none",
|
|
30467
30331
|
position: "absolute",
|
|
30468
|
-
top:
|
|
30469
|
-
|
|
30470
|
-
|
|
30471
|
-
|
|
30472
|
-
width: resolvedSelectionOverlay?.width ?? 0,
|
|
30332
|
+
top: 0,
|
|
30333
|
+
transformOrigin: "0 0",
|
|
30334
|
+
transition: "none",
|
|
30335
|
+
width: 0,
|
|
30473
30336
|
zIndex: 24
|
|
30474
|
-
}
|
|
30475
|
-
}
|
|
30476
|
-
),
|
|
30477
|
-
/* @__PURE__ */ jsx3(
|
|
30478
|
-
"div",
|
|
30479
|
-
{
|
|
30480
|
-
ref: activeValidationOverlayRef,
|
|
30481
|
-
"aria-hidden": "true",
|
|
30482
|
-
style: {
|
|
30483
|
-
alignItems: "center",
|
|
30484
|
-
color: palette.mutedText,
|
|
30485
|
-
display: "inline-flex",
|
|
30486
|
-
fontSize: 10 * zoomFactor,
|
|
30487
|
-
fontWeight: 700,
|
|
30488
|
-
height: 16 * zoomFactor,
|
|
30489
|
-
justifyContent: "center",
|
|
30490
|
-
opacity: 0,
|
|
30491
|
-
pointerEvents: "none",
|
|
30492
|
-
position: "absolute",
|
|
30493
|
-
transform: "translateY(-50%)",
|
|
30494
|
-
visibility: "hidden",
|
|
30495
|
-
width: 12 * zoomFactor,
|
|
30496
|
-
zIndex: 26
|
|
30497
|
-
},
|
|
30498
|
-
children: "\u25BE"
|
|
30499
|
-
}
|
|
30500
|
-
),
|
|
30501
|
-
/* @__PURE__ */ jsx3(
|
|
30502
|
-
"div",
|
|
30503
|
-
{
|
|
30504
|
-
ref: fillHandleRef,
|
|
30505
|
-
onPointerDown: (event) => {
|
|
30506
|
-
if (readOnly || event.button !== 0 || !normalizedSelection || !resolvedSelectionOverlay) {
|
|
30507
|
-
return;
|
|
30508
|
-
}
|
|
30509
|
-
event.preventDefault();
|
|
30510
|
-
event.stopPropagation();
|
|
30511
|
-
startFillDrag(event.pointerId, normalizedSelection);
|
|
30512
30337
|
},
|
|
30513
|
-
|
|
30514
|
-
|
|
30515
|
-
|
|
30516
|
-
|
|
30517
|
-
|
|
30518
|
-
|
|
30519
|
-
|
|
30520
|
-
|
|
30521
|
-
|
|
30522
|
-
|
|
30523
|
-
|
|
30524
|
-
|
|
30525
|
-
|
|
30526
|
-
|
|
30527
|
-
|
|
30528
|
-
|
|
30338
|
+
children: [
|
|
30339
|
+
/* @__PURE__ */ jsx3(
|
|
30340
|
+
"div",
|
|
30341
|
+
{
|
|
30342
|
+
ref: selectionOverlayRef,
|
|
30343
|
+
style: {
|
|
30344
|
+
backgroundColor: selectionFill,
|
|
30345
|
+
boxSizing: "border-box",
|
|
30346
|
+
boxShadow: `inset 0 0 0 ${selectionBorderWidth}px ${selectionStroke}`,
|
|
30347
|
+
contain: "layout paint",
|
|
30348
|
+
height: resolvedSelectionOverlay?.height ?? 0,
|
|
30349
|
+
left: resolvedSelectionOverlay?.left ?? 0,
|
|
30350
|
+
opacity: resolvedSelectionOverlay ? 1 : 0,
|
|
30351
|
+
pointerEvents: "none",
|
|
30352
|
+
position: "absolute",
|
|
30353
|
+
top: resolvedSelectionOverlay?.top ?? 0,
|
|
30354
|
+
transition: canvasSelectionTransition,
|
|
30355
|
+
visibility: resolvedSelectionOverlay ? "visible" : "hidden",
|
|
30356
|
+
willChange: shouldAnimateCanvasSelectionGeometry ? "left, top, width, height" : void 0,
|
|
30357
|
+
width: resolvedSelectionOverlay?.width ?? 0,
|
|
30358
|
+
zIndex: 24
|
|
30359
|
+
}
|
|
30360
|
+
}
|
|
30361
|
+
),
|
|
30362
|
+
/* @__PURE__ */ jsx3(
|
|
30363
|
+
"div",
|
|
30364
|
+
{
|
|
30365
|
+
ref: activeValidationOverlayRef,
|
|
30366
|
+
"aria-hidden": "true",
|
|
30367
|
+
style: {
|
|
30368
|
+
alignItems: "center",
|
|
30369
|
+
color: palette.mutedText,
|
|
30370
|
+
display: "inline-flex",
|
|
30371
|
+
fontSize: 10 * zoomFactor,
|
|
30372
|
+
fontWeight: 700,
|
|
30373
|
+
height: 16 * zoomFactor,
|
|
30374
|
+
justifyContent: "center",
|
|
30375
|
+
opacity: 0,
|
|
30376
|
+
pointerEvents: "none",
|
|
30377
|
+
position: "absolute",
|
|
30378
|
+
transform: "translateY(-50%)",
|
|
30379
|
+
visibility: "hidden",
|
|
30380
|
+
width: 12 * zoomFactor,
|
|
30381
|
+
zIndex: 26
|
|
30382
|
+
},
|
|
30383
|
+
children: "\u25BE"
|
|
30384
|
+
}
|
|
30385
|
+
),
|
|
30386
|
+
/* @__PURE__ */ jsx3(
|
|
30387
|
+
"div",
|
|
30388
|
+
{
|
|
30389
|
+
ref: fillHandleRef,
|
|
30390
|
+
onPointerDown: (event) => {
|
|
30391
|
+
if (readOnly || event.button !== 0 || !normalizedSelection || !resolvedSelectionOverlay) {
|
|
30392
|
+
return;
|
|
30393
|
+
}
|
|
30394
|
+
event.preventDefault();
|
|
30395
|
+
event.stopPropagation();
|
|
30396
|
+
startFillDrag(event.pointerId, normalizedSelection);
|
|
30397
|
+
},
|
|
30398
|
+
style: {
|
|
30399
|
+
backgroundColor: selectionStroke,
|
|
30400
|
+
border: `${Math.max(1, zoomFactor)}px solid ${palette.surface}`,
|
|
30401
|
+
contain: "layout paint",
|
|
30402
|
+
cursor: "crosshair",
|
|
30403
|
+
display: !readOnly && resolvedSelectionOverlay ? "block" : "none",
|
|
30404
|
+
height: 8 * zoomFactor,
|
|
30405
|
+
left: resolvedSelectionOverlay ? resolvedSelectionOverlay.left + resolvedSelectionOverlay.width - 4 * zoomFactor : 0,
|
|
30406
|
+
pointerEvents: "auto",
|
|
30407
|
+
position: "absolute",
|
|
30408
|
+
top: resolvedSelectionOverlay ? resolvedSelectionOverlay.top + resolvedSelectionOverlay.height - 4 * zoomFactor : 0,
|
|
30409
|
+
transition: shouldAnimateCanvasSelectionGeometry ? "left 120ms cubic-bezier(0.22, 1, 0.36, 1), top 120ms cubic-bezier(0.22, 1, 0.36, 1)" : "none",
|
|
30410
|
+
willChange: shouldAnimateCanvasSelectionGeometry ? "left, top" : void 0,
|
|
30411
|
+
width: 8 * zoomFactor,
|
|
30412
|
+
zIndex: 25
|
|
30413
|
+
}
|
|
30414
|
+
}
|
|
30415
|
+
)
|
|
30416
|
+
]
|
|
30529
30417
|
}
|
|
30530
30418
|
),
|
|
30531
30419
|
resizeGuide ? /* @__PURE__ */ jsx3(
|