Skip to content

Commit

Permalink
Merge branch hotfix/v8.2.1 into master
Browse files Browse the repository at this point in the history
  • Loading branch information
papacarlo committed Nov 12, 2024
2 parents ad6d546 + 16ed522 commit e37d97e
Show file tree
Hide file tree
Showing 121 changed files with 24,355 additions and 21,792 deletions.
15 changes: 0 additions & 15 deletions cell/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -484,20 +484,10 @@ var editor;
};

spreadsheet_api.prototype.asc_Copy = function() {
if (window["AscDesktopEditor"])
{
window["asc_desktop_copypaste"](this, "Copy");
return true;
}
return AscCommon.g_clipboardBase.Button_Copy();
};

spreadsheet_api.prototype.asc_Paste = function() {
if (window["AscDesktopEditor"])
{
window["asc_desktop_copypaste"](this, "Paste");
return true;
}
if (!AscCommon.g_clipboardBase.IsWorking()) {
return AscCommon.g_clipboardBase.Button_Paste();
}
Expand Down Expand Up @@ -930,11 +920,6 @@ var editor;
};

spreadsheet_api.prototype.asc_Cut = function() {
if (window["AscDesktopEditor"])
{
window["asc_desktop_copypaste"](this, "Cut");
return true;
}
return AscCommon.g_clipboardBase.Button_Cut();
};

Expand Down
1,119 changes: 666 additions & 453 deletions cell/apiBuilder.js

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion cell/apiDefines.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,8 @@ var c_oAscSelectionDialogType = {

var c_oAscScrollType = {
ScrollVertical: 1,
ScrollHorizontal: 2
ScrollHorizontal: 2,
ScrollInitRowsColsCount: 4
};

var c_oAscHyperlinkType = {
Expand Down
63 changes: 57 additions & 6 deletions cell/model/CellComment.js
Original file line number Diff line number Diff line change
Expand Up @@ -634,6 +634,9 @@ CCellCommentator.prototype.isLockedComment = function(oComment, callbackFunc) {
return;
}


this.worksheet._startRtlRendering(this.drawingCtx);

this.drawingCtx.setFillStyle(this.commentIconColor);
var commentCell, mergedRange, nCol, nRow, x, y, metrics;
var aComments = this.model.aComments;
Expand All @@ -654,15 +657,27 @@ CCellCommentator.prototype.isLockedComment = function(oComment, callbackFunc) {
if (0 === metrics.width || 0 === metrics.height) {
continue;
}

let isClip = false;
if (this.worksheet._clipDrawingRect(this.drawingCtx, new Asc.Range(nCol, nRow, nCol, nRow))) {
isClip = true;
}

x = metrics.left + metrics.width;
y = metrics.top;
this.drawingCtx.beginPath();
this.drawingCtx.moveTo(x - (size + borderW), y);
this.drawingCtx.lineTo(x - borderW, y);
this.drawingCtx.lineTo(x - borderW, y + size);
this.drawingCtx.fill();

if (isClip) {
this.drawingCtx.RemoveClipRect();
}
}
}

this.worksheet._endRtlRendering();
};

CCellCommentator.prototype.updateActiveComment = function () {
Expand Down Expand Up @@ -848,7 +863,14 @@ CCellCommentator.prototype.cleanLastSelection = function() {
var lastComment = this.findComment(this.lastSelectedId);
if (lastComment && (metrics = this.worksheet.getCellMetrics(lastComment.nCol, lastComment.nRow, true))) {
var extraOffset = 1;
this.overlayCtx.clearRect(metrics.left, metrics.top, metrics.width - extraOffset, metrics.height - extraOffset);
let x = this.worksheet.checkRtl(metrics.left);
let y = metrics.top;
let width = metrics.width - extraOffset;
if (this.worksheet.getRightToLeft()) {
x -= width;
}
let height = metrics.height - extraOffset;
this.overlayCtx.clearRect(x, y, width, height);
}
}
};
Expand Down Expand Up @@ -918,24 +940,28 @@ CCellCommentator.prototype.cleanLastSelection = function() {
var left = mergedRange ? mergedRange.c2 : comment.nCol;
var top = mergedRange ? mergedRange.r1 : comment.nRow;

let scrollCorrectX = this.worksheet.getHorizontalScrollCorrect();
let scrollCorrectY = this.worksheet.getScrollCorrect();
var frozenOffset = this.worksheet.getFrozenPaneOffset();
if (this.worksheet.topLeftFrozenCell) {
if (comment.nCol < fvc) {
frozenOffset.offsetX = 0;
fvc = 0;
scrollCorrectX = 0;
}
if (comment.nRow < fvr) {
frozenOffset.offsetY = 0;
fvr = 0;
scrollCorrectY = 0;
}
}

pos.dReverseLeftPX = this.worksheet.checkRtl(this.worksheet._getColLeft(left) - this.worksheet._getColLeft(fvc) +
headerCellsOffset.left + frozenOffset.offsetX);
headerCellsOffset.left + frozenOffset.offsetX - scrollCorrectX);
let colWidth = (this.worksheet.getRightToLeft() ? -1 : 1) * this.worksheet.getColumnWidth(left, 0);
pos.dLeftPX = pos.dReverseLeftPX + colWidth;
pos.dTopPX = this.worksheet._getRowTop(top) + ((this.worksheet._getRowHeight(top) / 2) | 0) -
this.worksheet._getRowTop(fvr) + headerCellsOffset.top + frozenOffset.offsetY;
this.worksheet._getRowTop(fvr) + headerCellsOffset.top + frozenOffset.offsetY - scrollCorrectY;

pos.dLeftPX = AscCommon.AscBrowser.convertToRetinaValue(pos.dLeftPX);
pos.dTopPX = AscCommon.AscBrowser.convertToRetinaValue(pos.dTopPX);
Expand All @@ -950,7 +976,14 @@ CCellCommentator.prototype.cleanLastSelection = function() {
var comment = this.findComment(this.lastSelectedId);
if (comment && !this._checkHidden(comment) &&
(metrics = this.worksheet.getCellMetrics(comment.asc_getCol(), comment.asc_getRow(), true))) {
this.overlayCtx.clearRect(metrics.left, metrics.top, metrics.width, metrics.height);
let x = this.worksheet.checkRtl(metrics.left);
let y = metrics.top;
let width = metrics.width;
if (this.worksheet.getRightToLeft()) {
x -= width;
}
let height = metrics.height;
this.overlayCtx.clearRect(x, y, width, height);
}
}
};
Expand Down Expand Up @@ -1005,13 +1038,31 @@ CCellCommentator.prototype.selectComment = function(id) {

metrics = this.worksheet.getCellMetrics(col, row, true);
if (metrics) {

let isClip = false;
let mc = this.model.getMergedByCell(row, col);
if (this.worksheet._clipDrawingRect(this.overlayCtx, mc ? mc : new Asc.Range(col, row, col, row))) {
isClip = true;
}

var extraOffset = 1;
this.overlayCtx.ctx.globalAlpha = 0.2;
this.overlayCtx.beginPath();
this.overlayCtx.clearRect(metrics.left, metrics.top, metrics.width - extraOffset, metrics.height - extraOffset);
let x = this.worksheet.checkRtl(metrics.left);
let y = metrics.top;
let width = metrics.width - extraOffset;
if (this.worksheet.getRightToLeft()) {
x -= width;
}
let height = metrics.height - extraOffset;
this.overlayCtx.clearRect(x, y, width, height);
this.overlayCtx.setFillStyle(this.commentFillColor);
this.overlayCtx.fillRect(metrics.left, metrics.top, metrics.width - extraOffset, metrics.height - extraOffset);
this.overlayCtx.fillRect(x, y, width, height);
this.overlayCtx.ctx.globalAlpha = 1;

if (isClip) {
this.overlayCtx.RemoveClipRect();
}
}
}
};
Expand Down
72 changes: 40 additions & 32 deletions cell/model/FormulaObjects/lookupandreferenceFunctions.js
Original file line number Diff line number Diff line change
Expand Up @@ -1359,19 +1359,9 @@ function (window, undefined) {
cHLOOKUP.prototype.arrayIndexes = {0: 1, 1: 1, 2: 1};
cHLOOKUP.prototype.argumentsType = [argType.any, argType.number, argType.number, argType.logical];
cHLOOKUP.prototype.Calculate = function (arg) {

// if(this.bArrayFormula) {
// //исключение, когда в формуле массива берется из одного аргумента только 1 элемент
// if(cElementType.cellsRange3D === arg[2].type || cElementType.cellsRange === arg[2].type) {
// arg[2] = arg[2].getValue2(0,0);
// } else if(cElementType.array === arg[2].type) {
// arg[2] = arg[2].getValue2(0,0);
// }
// }

let retArr = new cArray();
let error = false;
if (arg[0].type === cElementType.cellsRange || arg[0].type === cElementType.cellsRange3D || arg[0].type === cElementType.array) {
if (arg[0].type === cElementType.array) {
if (arg[2] && arg[2].type === cElementType.cellsRange || arg[2].type === cElementType.cellsRange3D || arg[2].type === cElementType.array) {
arg[2] = arg[2].getValue2(0,0);
}
Expand All @@ -1383,10 +1373,10 @@ function (window, undefined) {
}
}

return retArr
return retArr;
}

if (arg[2] && (arg[2].type === cElementType.cellsRange || arg[2].type === cElementType.cellsRange3D || arg[2].type === cElementType.array)) {
if (arg[2] && (arg[2].type === cElementType.array)) {
let dimension = arg[2].getDimensions();
for (let r = 0; r < dimension.row; r++) {
retArr.addRow();
Expand Down Expand Up @@ -1770,9 +1760,26 @@ function (window, undefined) {
cLOOKUP.prototype.name = 'LOOKUP';
cLOOKUP.prototype.argumentsMin = 2;
cLOOKUP.prototype.argumentsMax = 3;
cLOOKUP.prototype.arrayIndexes = {1: 1, 2: 1};
cLOOKUP.prototype.arrayIndexes = {0: 1, 1: 1, 2: 1};
cLOOKUP.prototype.argumentsType = [argType.any, argType.reference, argType.reference];
cLOOKUP.prototype.Calculate = function (arg) {

if (!AscCommonExcel.bIsSupportDynamicArrays && arg[0].type === cElementType.cellsRange || arg[0].type === cElementType.cellsRange3D) {
arg[0] = arg[0].isOneElement() ? arg[0].getFirstElement() : arg[0].cross(arguments[1]);
} else if (arg[0].type === cElementType.array) {
let retArr = new cArray();
let dimension = arg[0].getDimensions();

for (let r = 0; r < dimension.row; r++) {
retArr.addRow();
for (let c = 0; c < dimension.col; c++) {
retArr.addElement(g_oLOOKUPCache.calculate([arg[0].getValue2(r, c), arg[1], arg[2]], arguments[1]));
}
}
return retArr;
}


return g_oLOOKUPCache.calculate(arg, arguments[1]);
};

Expand Down Expand Up @@ -2879,6 +2886,18 @@ function (window, undefined) {
let t = this, number, valueForSearching, r, c, res = -1, min, regexp, count;

if (!opt_xlookup) {
if (cElementType.cell3D === arg2.type || cElementType.cell === arg2.type) {
arg2 = arg2.getValue();
} else if (cElementType.array === arg2.type) {
arg2 = arg2.getElementRowCol(0, 0);
} else if (cElementType.cellsRange === arg2.type || cElementType.cellsRange3D === arg2.type) {
arg2 = arg2.cross(argument1);
}

if (cElementType.error === arg2.type) {
return arg2;
}

number = arg2.getValue() - 1;

if (isNaN(number)) {
Expand Down Expand Up @@ -4188,26 +4207,15 @@ function (window, undefined) {
cVLOOKUP.prototype.name = 'VLOOKUP';
cVLOOKUP.prototype.argumentsMin = 3;
cVLOOKUP.prototype.argumentsMax = 4;
cVLOOKUP.prototype.arrayIndexes = {0: 1, 1: 1, 2: 1};
cVLOOKUP.prototype.arrayIndexes = {/*0: 1,*/ 1: 1, /*2: 1*/};
cVLOOKUP.prototype.numFormat = AscCommonExcel.cNumFormatNone;
// cVLOOKUP.prototype.returnValueType = AscCommonExcel.cReturnFormulaType.value_replace_area;
cVLOOKUP.prototype.argumentsType = [argType.any, argType.number, argType.number, argType.logical];
cVLOOKUP.prototype.Calculate = function (arg) {

/*
if(this.bArrayFormula) {
//в случае когда первый аргумент - массив
//исключение, когда в формуле массива берется из одного аргумента только 1 элемент
if(cElementType.cellsRange3D === arg[2].type || cElementType.cellsRange === arg[2].type) {
arg[2] = arg[2].getValue2(0,0);
} else if(cElementType.array === arg[2].type) {
arg[2] = arg[2].getValue2(0,0);
}
}
*/
let retArr = new cArray();
let error = false;

if (arg[0].type === cElementType.cellsRange || arg[0].type === cElementType.cellsRange3D || arg[0].type === cElementType.array) {
if (arg[0].type === cElementType.array) {
if (arg[2] && arg[2].type === cElementType.cellsRange || arg[2].type === cElementType.cellsRange3D || arg[2].type === cElementType.array) {
arg[2] = arg[2].getValue2(0,0);
}
Expand All @@ -4219,22 +4227,22 @@ function (window, undefined) {
}
}

return retArr
return retArr;
}

if (arg[2] && (arg[2].type === cElementType.cellsRange || arg[2].type === cElementType.cellsRange3D || arg[2].type === cElementType.array)) {
if (arg[2] && (arg[2].type === cElementType.array)) {
let dimension = arg[2].getDimensions();
for (let r = 0; r < dimension.row; r++) {
retArr.addRow();
for (let c = 0; c < dimension.col; c++) {
if (!error) {
let res = g_oVLOOKUPCache.calculate([arg[0], arg[1], arg[2].getValue2(r, c), arg[3]], arguments[1]);
if (res.type === cElementType.error) {
error = true
error = true;
}
retArr.addElement(res);
} else {
break
break;
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions cell/model/FormulaObjects/mathematicFunctions.js
Original file line number Diff line number Diff line change
Expand Up @@ -4322,6 +4322,8 @@ function (window, undefined) {
cROUNDUP.prototype.argumentsType = [argType.number, argType.number];
cROUNDUP.prototype.Calculate = function (arg) {
function roundupHelper(number, num_digits) {
let fractionalPart = number.toString().split(".")[1];

if (num_digits > AscCommonExcel.cExcelMaxExponent) {
if (Math.abs(number) >= 1e-100 || num_digits <= 98303) {
return new cNumber(number);
Expand All @@ -4332,6 +4334,8 @@ function (window, undefined) {
return new cNumber(number);
}
return new cError(cErrorType.not_numeric);
} else if (fractionalPart && fractionalPart.length === num_digits) {
return new cNumber(number);
}

let sign = number >= 0 ? 1 : -1,
Expand Down
Loading

0 comments on commit e37d97e

Please sign in to comment.