Skip to content

Commit

Permalink
Changed where the string is processed to get the table column
Browse files Browse the repository at this point in the history
Added string changes when clicking on a range inside the table
  • Loading branch information
DimitryOrlov committed Aug 29, 2024
1 parent 459a382 commit 328209a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 12 deletions.
16 changes: 6 additions & 10 deletions cell/model/FormulaObjects/parserFormula.js
Original file line number Diff line number Diff line change
Expand Up @@ -2369,11 +2369,9 @@ parserHelp.setDigitSeparator(AscCommon.g_oDefaultCultureInfo.NumberDecimalSepara
if (this.hdtIndexes.length > 0 && this.isDynamic && isLocal && this.hdtIndexes[0] === AscCommon.FormulaTablePartInfo.thisRow) {
let hdtcstart = this.hdtcstartIndex ? this.hdtcstartIndex.name.replace(/([#[\]])/g, "'$1") : null;
let hdtcend = this.hdtcendIndex ? this.hdtcendIndex.name.replace(/([#[\]])/g, "'$1") : null;
// TODO вместо replace, попоробовать изменять строку ТОЛЬКО при получении столбца при первом парсинге

// replace all single quotes with double-single quote
hdtcstart = hdtcstart ? hdtcstart.replace(/'/g, "''") : hdtcstart;

// replace all single quotes with double-single quote
hdtcend = hdtcend ? hdtcend.replace(/'/g, "''") : hdtcend;

tblStr += "@";
Expand Down Expand Up @@ -2434,7 +2432,7 @@ parserHelp.setDigitSeparator(AscCommon.g_oDefaultCultureInfo.NumberDecimalSepara
startCol = val['oneColumn'].replace(/'([#[\]])/g, '$1');

// replace all double-single quotes with single quote
startCol = startCol.replace(/''/g, "'");
// startCol = startCol.replace(/''/g, "'");

if (startCol[0] === "@") {
this.isDynamic = true;
Expand All @@ -2447,10 +2445,8 @@ parserHelp.setDigitSeparator(AscCommon.g_oDefaultCultureInfo.NumberDecimalSepara
endCol = val['colEnd'].replace(/'([#[\]])/g, '$1');

// replace all double-single quotes with single quote
startCol = startCol.replace(/''/g, "'");

// replace all double-single quotes with single quote
endCol = endCol ? endCol.replace(/''/g, "'") : startCol;
// startCol = startCol.replace(/''/g, "'");
// endCol = endCol ? endCol.replace(/''/g, "'") : startCol;

if (!endCol) {
endCol = startCol;
Expand Down Expand Up @@ -2489,15 +2485,15 @@ parserHelp.setDigitSeparator(AscCommon.g_oDefaultCultureInfo.NumberDecimalSepara
startCol = hdtcstart.replace(/'([#[\]])/g, '$1');

// replace all double-single quotes with single quote
startCol = startCol.replace(/''/g, "'");
// startCol = startCol.replace(/''/g, "'");

this.hdtcstartIndex = this.wb.getTableIndexColumnByName(this.tableName, startCol);
bRes = !!this.hdtcstartIndex;
if (bRes && hdtcend) {
endCol = hdtcend.replace(/'([#[\]])/g, '$1');

// replace all double-single quotes with single quote
startCol = startCol.replace(/''/g, "'");
// endCol = endCol.replace(/''/g, "'");

this.hdtcendIndex = this.wb.getTableIndexColumnByName(this.tableName, endCol);
bRes = !!this.hdtcendIndex;
Expand Down
3 changes: 1 addition & 2 deletions cell/model/Workbook.js
Original file line number Diff line number Diff line change
Expand Up @@ -8492,9 +8492,8 @@
{
if(this.TableParts[i].DisplayName.toLowerCase() === tableName.toLowerCase())
{
// todo при открытии файла можно использовать этот вариант вместо нескольких .replace в _parseVal
// replace all double-single quotes with single quotes
// columnName = columnName.replace(/''/g, "'");
columnName = columnName.replace(/''/g, "'");

res = this.TableParts[i].getTableIndexColumnByName(columnName);
break;
Expand Down
4 changes: 4 additions & 0 deletions cell/model/WorkbookElems.js
Original file line number Diff line number Diff line change
Expand Up @@ -9014,6 +9014,10 @@ function RangeDataManagerElem(bbox, data)
let startCol = this.getTableNameColumnByIndex(handleSelectionRange.c1 - this.Ref.c1);
let endCol = this.getTableNameColumnByIndex(handleSelectionRange.c2 - this.Ref.c1);

// replace single quote with double-single quotes
startCol = startCol.replace(/'/g, "''");
endCol = endCol.replace(/'/g, "''");

if (this.Ref.isEqual(handleSelectionRange)) {
//Table1[#All]
return this.DisplayName + "[" + AscCommon.cStrucTableReservedWords.all + "]";
Expand Down

0 comments on commit 328209a

Please sign in to comment.