Skip to content

Commit

Permalink
[se] Fix bug 69612
Browse files Browse the repository at this point in the history
  • Loading branch information
GoshaZotov committed Feb 14, 2025
1 parent 0beab04 commit 74c947f
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 0 deletions.
42 changes: 42 additions & 0 deletions cell/model/FormulaObjects/parserFormula.js
Original file line number Diff line number Diff line change
Expand Up @@ -5079,6 +5079,47 @@ parserHelp.setDigitSeparator(AscCommon.g_oDefaultCultureInfo.NumberDecimalSepara
return ranges;
}


function getRangeByName(sName, ws) {
// Early validation
if (!sName || !ws) {
return [];
}

// Initialize arrays
const ranges = [];
const activeCell = ws.getSelection().activeCell;
const bbox = new Asc.Range(activeCell.col, activeCell.row, activeCell.col, activeCell.row);

// Helper function to process names
const processName = function(item) {
if (item.oper.type === cElementType.name) {
const nameRef = item.oper.toRef(bbox);

// Skip if reference is error
if (nameRef instanceof AscCommonExcel.cError) {
return;
}

// Get range from valid reference
if (nameRef.getRange && nameRef.getWS && nameRef.getWS() === ws) {
ranges.push(nameRef.getRange());
}
}
};

// Parse formula and get references
const parseResult = new AscCommonExcel.ParseResult([]);
const parsed = new AscCommonExcel.parserFormula(sName, null, ws);

if (parsed.parse(undefined, undefined, parseResult)) {
// Process only name type references
parseResult.refPos.forEach(processName);
}

return ranges;
}

/*--------------------------------------------------------------------------*/


Expand Down Expand Up @@ -11574,6 +11615,7 @@ function parserFormula( formula, parent, _ws ) {
window['AscCommonExcel'].getRangeByRef = getRangeByRef;
window['AscCommonExcel'].addNewFunction = addNewFunction;
window['AscCommonExcel'].removeCustomFunction = removeCustomFunction;
window['AscCommonExcel'].getRangeByName = getRangeByName;

window['AscCommonExcel']._func = _func;

Expand Down
6 changes: 6 additions & 0 deletions cell/model/autofilters.js
Original file line number Diff line number Diff line change
Expand Up @@ -1555,6 +1555,12 @@

if (userRange) {
activeCells = AscCommonExcel.g_oRangeCache.getAscRange(userRange);
if (!activeCells) {
let aRanges = AscCommonExcel.getRangeByName(userRange, this.worksheet);
if (aRanges && aRanges.length === 1) {
activeCells = aRanges[0] && aRanges[0].bbox;
}
}
}

//данная функция возвращает false в двух случаях - при смене стиля ф/т или при поптыке добавить ф/т к части а/ф
Expand Down
6 changes: 6 additions & 0 deletions common/editorscommon.js
Original file line number Diff line number Diff line change
Expand Up @@ -4104,6 +4104,12 @@
else
{
range = AscCommonExcel.g_oRangeCache.getAscRange(dataRange);
if (!range && model && cDialogType.FormatTable === dialogType && AscCommon.rx_defName.test(dataRange)) {
let aRanges = AscCommonExcel.getRangeByName(dataRange, model.getActiveWs());
if (aRanges && aRanges.length === 1) {
range = aRanges[0] && aRanges[0].bbox;
}
}
}

if (!range && cDialogType.DataValidation !== dialogType && cDialogType.ConditionalFormattingRule !== dialogType && cDialogType.GoalSeek_Cell !== dialogType &&
Expand Down

0 comments on commit 74c947f

Please sign in to comment.