Skip to content

Commit

Permalink
Merge branch 'develop' into feature/up-and-down-bars
Browse files Browse the repository at this point in the history
  • Loading branch information
ansaraidarbek committed Feb 11, 2025
2 parents e90670d + 5c3ecc4 commit ca8d24b
Show file tree
Hide file tree
Showing 16 changed files with 1,253 additions and 114 deletions.
40 changes: 20 additions & 20 deletions build/Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -365,22 +365,22 @@ module.exports = function(grunt) {
}
]
},
// visio: {
// files: [
// {
// expand: true,
// cwd: visio,
// src: [
// 'sdk-all-min.js.map',
// 'sdk-all.js.map',
// ],
// dest: 'maps',
// rename: function (dest, src) {
// return path.join(dest , src.replace('sdk', 'visio'));
// }
// }
// ]
// }
visio: {
files: [
{
expand: true,
cwd: visio,
src: [
'sdk-all-min.js.map',
'sdk-all.js.map',
],
dest: 'maps',
rename: function (dest, src) {
return path.join(dest , src.replace('sdk', 'visio'));
}
}
]
}
},
clean: {
deploy: {
Expand All @@ -394,15 +394,15 @@ module.exports = function(grunt) {
path.join(cell, 'sdk-all.js.map'),
path.join(slide, 'sdk-all-min.js.map'),
path.join(slide, 'sdk-all.js.map'),
// path.join(visio, 'sdk-all-min.js.map'),
// path.join(visio, 'sdk-all.js.map'),
path.join(visio, 'sdk-all-min.js.map'),
path.join(visio, 'sdk-all.js.map'),
]
}
}
});
grunt.task.run('copy', 'clean');
});
grunt.registerTask('compile-sdk', ['compile-word', 'compile-cell', 'compile-slide'/* , 'compile-visio' */]);
grunt.registerTask('compile-sdk', ['compile-word', 'compile-cell', 'compile-slide', 'compile-visio']);
grunt.registerTask('clean-deploy', 'Clean deploy folder before deploying', function () {
grunt.initConfig({
clean: {
Expand Down Expand Up @@ -521,7 +521,7 @@ module.exports = function(grunt) {
writeScripts(configs.word['sdk'], 'word');
writeScripts(configs.cell['sdk'], 'cell');
writeScripts(configs.slide['sdk'], 'slide');
// writeScripts(configs.visio['sdk'], 'visio');
writeScripts(configs.visio['sdk'], 'visio');
});
const defaultTasks = ['clean-deploy', 'compile-sdk', 'copy-other'];
if (grunt.option('map')) {
Expand Down
18 changes: 11 additions & 7 deletions cell/model/FormulaObjects/mathematicFunctions.js
Original file line number Diff line number Diff line change
Expand Up @@ -4069,7 +4069,7 @@ function (window, undefined) {
return truncate(quotient + nolpiat) * significance;
}

function roundHelper(number, num_digits) {
function roundHelper(number, decimals) {
if (num_digits > AscCommonExcel.cExcelMaxExponent) {
if (Math.abs(number) < 1 || num_digits < 1e10) // The values are obtained experimentally
{
Expand All @@ -4084,16 +4084,20 @@ function (window, undefined) {
return new cNumber(0);
}

var significance = SignZeroPositive(number) * Math.pow(10, -truncate(num_digits));
const EPSILON = 1e-14;

number += significance / 2;
// ->integer
decimals = decimals >> 0;

if (number / significance == Infinity) {
return new cNumber(number);
}
const multiplier = Math.pow(10, decimals);
const shifted = Math.abs(number) * multiplier;

return new cNumber(Floor(number, significance));
// Add epsilon to handle floating point precision issues (1.005 case)
const compensated = shifted + EPSILON;
const rounded = Math.floor(compensated + 0.5);

let result = (Math.sign(number) * rounded) / multiplier;
return new cNumber(result);
}

var arg0 = arg[0], arg1 = arg[1];
Expand Down
14 changes: 9 additions & 5 deletions cell/view/CellEditorView.js
Original file line number Diff line number Diff line change
Expand Up @@ -1679,11 +1679,11 @@ function (window, undefined) {
this.cursorStyle.display = "none";
};

CellEditor.prototype._updateCursorPosition = function (redrawText, isExpand) {
CellEditor.prototype._updateCursorPosition = function (redrawText, isExpand, lineIndex) {
// ToDo стоит переправить данную функцию
let h = this.canvas.height;
let y = -this.textRender.calcLineOffset(this.topLineIndex);
let cur = this.textRender.calcCharOffset(this.cursorPos);
let cur = this.textRender.calcCharOffset(this.cursorPos, lineIndex);
let charsCount = this.textRender.getCharsCount();
let textAlign = this.textFlags && this.textFlags.textAlign;
let curLeft = asc_round(
Expand Down Expand Up @@ -1759,7 +1759,7 @@ function (window, undefined) {
this._updateSelectionInfo();
};

CellEditor.prototype._moveCursor = function (kind, pos) {
CellEditor.prototype._moveCursor = function (kind, pos, lineIndex) {
this.newTextFormat = null;
var t = this;
this.sAutoComplete = null;
Expand Down Expand Up @@ -1807,14 +1807,18 @@ function (window, undefined) {
t.selectionBegin = t.selectionEnd = -1;
t._cleanSelection();
}
t._updateCursorPosition();
t._updateCursorPosition(null, null, lineIndex);
t._updateCursor();
};

CellEditor.prototype._findCursorPosition = function (coord) {
return this.textRender.getCharPosByXY(coord.x, coord.y, this.topLineIndex, this.getZoom());
};

CellEditor.prototype._findLineIndex = function (coord) {
return this.textRender.getLineByY(coord.y, this.topLineIndex, this.getZoom());
};

CellEditor.prototype._updateTopLineCurPos = function () {
if (this.loadFonts) {
return;
Expand Down Expand Up @@ -3012,7 +3016,7 @@ function (window, undefined) {
this._updateCursor();
pos = this._findCursorPosition(coord);
if (pos !== undefined) {
pos >= 0 ? this._moveCursor(kPosition, pos) : this._moveCursor(pos);
pos >= 0 ? this._moveCursor(kPosition, pos, this._findLineIndex(coord)) : this._moveCursor(pos, null, this._findLineIndex(coord));
}
} else {
this._changeSelection(coord);
Expand Down
7 changes: 5 additions & 2 deletions cell/view/CellTextRender.js
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@
h * zoom), Asc.round(li.th * zoom), lineIndex);
};

CellTextRender.prototype.calcCharOffset = function (pos) {
CellTextRender.prototype.calcCharOffset = function (pos, lineIndex) {
var t = this, l = t.lines, i, h, co;

if (l.length < 1) {
Expand All @@ -249,7 +249,10 @@

for (i = 0, h = 0; i < l.length; ++i) {
if (pos >= l[i].beg && pos <= l[i].end) {
return this.charOffset(pos, i, h);
//end of line and start of line can have same index
if (!(lineIndex != null && (pos === l[i].end/* || pos === l[i].beg*/) && lineIndex !== i)) {
return this.charOffset(pos, i, h);
}
}
if (i !== l.length - 1) {
h += l[i].th;
Expand Down
11 changes: 6 additions & 5 deletions cell/view/WorkbookView.js
Original file line number Diff line number Diff line change
Expand Up @@ -3244,16 +3244,17 @@
this.cellEditor.changeCellText(sArguments);

if (name) {

var res = new AscCommonExcel.CFunctionInfo(name);
let res = new AscCommonExcel.CFunctionInfo(name);
if (needChange) {
res.asc_setArguments(args);
}
res.argumentsResult = [];
var argCalc = ws.calculateWizardFormula(args[argNum], argType);
let argCalc = ws.calculateWizardFormula(args[argNum], argType);
res.argumentsResult[argNum] = argCalc.str;
if (argCalc.obj && argCalc.obj.type !== AscCommonExcel.cElementType.error) {
var funcCalc = ws.calculateWizardFormula(name + '(' + sArguments + ')');
//second condition: if we haven't received the formulaResult, calculate with those arguments that exist in the array
if ((argCalc.obj && argCalc.obj.type !== AscCommonExcel.cElementType.error) ||
(argCalc.obj === null && res && !res.functionResult && args && sArguments)) {
let funcCalc = ws.calculateWizardFormula(name + '(' + sArguments + ')');
res.functionResult = funcCalc.str;
if (funcCalc.obj && funcCalc.obj.type !== AscCommonExcel.cElementType.error) {
res.formulaResult = ws.calculateWizardFormula(this.cellEditor.getText().substring(1)).str;
Expand Down
30 changes: 25 additions & 5 deletions cell/view/WorksheetView.js
Original file line number Diff line number Diff line change
Expand Up @@ -2240,6 +2240,9 @@
for (i = 0; i < hasNumber.arrCols.length; ++i) {
c = hasNumber.arrCols[i];
cell = t._getVisibleCell(c, arCopy.r2);
if (cell.hasMerged()) {
continue;
}
text = (new asc_Range(c, arCopy.r1, c, arCopy.r2 - 1)).getName();
val = t.generateAutoCompleteFormula(functionName, text);
// ToDo - при вводе формулы в заголовок автофильтра надо писать "0"
Expand All @@ -2249,15 +2252,20 @@
for (i = 0; i < hasNumber.arrRows.length; ++i) {
r = hasNumber.arrRows[i];
cell = t._getVisibleCell(arCopy.c2, r);
if (cell.hasMerged()) {
continue;
}
text = (new asc_Range(arCopy.c1, r, arCopy.c2 - 1, r)).getName();
val = t.generateAutoCompleteFormula(functionName, text);
cell.setValue(val);
}
// Значение в правой нижней ячейке
cell = t._getVisibleCell(arCopy.c2, arCopy.r2);
text = (new asc_Range(arCopy.c1, arCopy.r2, arCopy.c2 - 1, arCopy.r2)).getName();
val = t.generateAutoCompleteFormula(functionName, text);
cell.setValue(val);
if (!cell.hasMerged()) {
text = (new asc_Range(arCopy.c1, arCopy.r2, arCopy.c2 - 1, arCopy.r2)).getName();
val = t.generateAutoCompleteFormula(functionName, text);
cell.setValue(val);
}
};
} else if (true === hasNumberInLastRow && false === hasNumberInLastColumn) {
// Есть значения только в последней строке (значит нужно заполнить только последнюю колонку)
Expand All @@ -2269,6 +2277,9 @@
for (i = 0; i < hasNumber.arrRows.length; ++i) {
r = hasNumber.arrRows[i];
cell = t._getVisibleCell(arCopy.c2, r);
if (cell.hasMerged()) {
continue;
}
text = (new asc_Range(arCopy.c1, r, arCopy.c2 - 1, r)).getName();
val = t.generateAutoCompleteFormula(functionName, text);
cell.setValue(val);
Expand All @@ -2284,6 +2295,9 @@
for (i = 0; i < hasNumber.arrCols.length; ++i) {
c = hasNumber.arrCols[i];
cell = t._getVisibleCell(c, arCopy.r2);
if (cell.hasMerged()) {
continue;
}
text = (new asc_Range(c, arCopy.r1, c, arCopy.r2 - 1)).getName();
val = t.generateAutoCompleteFormula(functionName, text);
cell.setValue(val);
Expand Down Expand Up @@ -2356,9 +2370,15 @@
return result;
}
} else {
// change selection to the last cell if the values ​​in the range are not valid in the autocomplete formula
if (!result.text && !result.notEditCell) {
selection.setActiveCell(ar.r2, ar.c2);
let supposedCell = this.model.getCell3(activeCell.row, activeCell.col);
let merged = supposedCell && supposedCell.hasMerged();
if (merged) {
selection.setActiveCell(merged.r1, merged.c1);
} else if (firstCell && (firstCell.cellType === CellValueType.String) && lastCell && (lastCell.cellType === CellValueType.String)) {
// change selection to the last cell if the values ​​in the range are not valid in the autocomplete formula
selection.setActiveCell(ar.r2, ar.c2);
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion common/AdvancedOptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
this.delimiter = delimiter;
this.delimiterChar = delimiterChar;

this.textQualifier = null;
this.textQualifier = '"';

this.numberDecimalSeparator = null;
this.numberGroupSeparator = null;
Expand Down
6 changes: 5 additions & 1 deletion common/apiBase.js
Original file line number Diff line number Diff line change
Expand Up @@ -4859,17 +4859,21 @@
if (!this.internalEvents.hasOwnProperty(name))
this.internalEvents[name] = {};
this.internalEvents[name]["" + ((undefined === listenerId) ? 0 : listenerId)] = callback;

return true;
};
baseEditorsApi.prototype.detachEvent = function(name, listenerId)
{
if (!this.internalEvents.hasOwnProperty(name))
return;
return false;
var obj = this.internalEvents[name];
var prop = "" + ((undefined === listenerId) ? 0 : listenerId);
if (obj[prop])
delete obj[prop];
if (0 === Object.getOwnPropertyNames(obj).length)
delete this.internalEvents[name];

return true;
};
baseEditorsApi.prototype.sendInternalEvent = function()
{
Expand Down
Loading

0 comments on commit ca8d24b

Please sign in to comment.