Commit c6ff0b8b authored by Alexander.Trofimov's avatar Alexander.Trofimov

fix bug 35334

conditional formatting with formula and offset (duplicate variable)
parent 3ecf8837
...@@ -273,16 +273,18 @@ ...@@ -273,16 +273,18 @@
cCOLUMN.prototype.constructor = cCOLUMN; cCOLUMN.prototype.constructor = cCOLUMN;
cCOLUMN.prototype.argumentsMax = 1; cCOLUMN.prototype.argumentsMax = 1;
cCOLUMN.prototype.Calculate = function (arg) { cCOLUMN.prototype.Calculate = function (arg) {
if (this.argumentsCurrent == 0) { var bbox;
return this.value = new cNumber(arguments[1].c1 + 1); if (0 === this.argumentsCurrent) {
} bbox = arguments[1];
} else {
var arg0 = arg[0]; var arg0 = arg[0];
var range;
if (cElementType.cell === arg0.type || cElementType.cell3D === arg0.type || if (cElementType.cell === arg0.type || cElementType.cell3D === arg0.type ||
cElementType.cellsRange === arg0.type || cElementType.cellsRange3D === arg0.type) { cElementType.cellsRange === arg0.type || cElementType.cellsRange3D === arg0.type) {
range = arg0.getRange(); bbox = arg0.getRange();
bbox = bbox && bbox.bbox;
}
} }
return this.value = (range ? new cNumber(range.bbox.c1 + 1) : new cError(cErrorType.bad_reference)); return this.value = (bbox ? new cNumber(bbox.c1 + 1) : new cError(cErrorType.bad_reference));
}; };
/** /**
...@@ -961,16 +963,18 @@ ...@@ -961,16 +963,18 @@
cROW.prototype.constructor = cROW; cROW.prototype.constructor = cROW;
cROW.prototype.argumentsMax = 1; cROW.prototype.argumentsMax = 1;
cROW.prototype.Calculate = function (arg) { cROW.prototype.Calculate = function (arg) {
if (this.argumentsCurrent == 0) { var bbox;
return this.value = new cNumber(arguments[1].r1 + 1); if (0 === this.argumentsCurrent) {
} bbox = arguments[1];
} else {
var arg0 = arg[0]; var arg0 = arg[0];
var range;
if (cElementType.cell === arg0.type || cElementType.cell3D === arg0.type || if (cElementType.cell === arg0.type || cElementType.cell3D === arg0.type ||
cElementType.cellsRange === arg0.type || cElementType.cellsRange3D === arg0.type) { cElementType.cellsRange === arg0.type || cElementType.cellsRange3D === arg0.type) {
range = arg0.getRange(); bbox = arg0.getRange();
bbox = bbox && bbox.bbox;
}
} }
return this.value = (range ? new cNumber(range.bbox.r1 + 1) : new cError(cErrorType.bad_reference)); return this.value = (bbox ? new cNumber(bbox.r1 + 1) : new cError(cErrorType.bad_reference));
}; };
/** /**
......
...@@ -4992,14 +4992,11 @@ parserFormula.prototype.parse = function(local, digitDelim) { ...@@ -4992,14 +4992,11 @@ parserFormula.prototype.parse = function(local, digitDelim) {
this._endCalculate(); this._endCalculate();
return this.value; return this.value;
} }
var bbox = null; if (!opt_bbox && this.parent && this.parent.onFormulaEvent) {
if (opt_bbox) { opt_bbox = this.parent.onFormulaEvent(AscCommon.c_oNotifyParentType.GetRangeCell);
bbox = opt_bbox;
} else if (this.parent && this.parent.onFormulaEvent) {
bbox = this.parent.onFormulaEvent(AscCommon.c_oNotifyParentType.GetRangeCell);
} }
if (!bbox) { if (!opt_bbox) {
bbox = new Asc.Range(0, 0, 0, 0); opt_bbox = new Asc.Range(0, 0, 0, 0);
} }
var elemArr = [], _tmp, numFormat = -1, currentElement = null; var elemArr = [], _tmp, numFormat = -1, currentElement = null;
...@@ -5019,7 +5016,7 @@ parserFormula.prototype.parse = function(local, digitDelim) { ...@@ -5019,7 +5016,7 @@ parserFormula.prototype.parse = function(local, digitDelim) {
for (var ind = 0; ind < currentElement.getArguments(); ind++) { for (var ind = 0; ind < currentElement.getArguments(); ind++) {
arg.unshift(elemArr.pop()); arg.unshift(elemArr.pop());
} }
_tmp = currentElement.Calculate(arg, bbox, opt_defName, this.ws); _tmp = currentElement.Calculate(arg, opt_bbox, opt_defName, this.ws);
if (null != _tmp.numFormat) { if (null != _tmp.numFormat) {
numFormat = _tmp.numFormat; numFormat = _tmp.numFormat;
} else if (0 > numFormat || cNumFormatNone === currentElement.numFormat) { } else if (0 > numFormat || cNumFormatNone === currentElement.numFormat) {
...@@ -5028,9 +5025,9 @@ parserFormula.prototype.parse = function(local, digitDelim) { ...@@ -5028,9 +5025,9 @@ parserFormula.prototype.parse = function(local, digitDelim) {
elemArr.push(_tmp); elemArr.push(_tmp);
} }
} else if (currentElement.type === cElementType.name || currentElement.type === cElementType.name3D) { } else if (currentElement.type === cElementType.name || currentElement.type === cElementType.name3D) {
elemArr.push(currentElement.Calculate(arg, bbox)); elemArr.push(currentElement.Calculate(arg, opt_bbox));
} else if (currentElement.type === cElementType.table) { } else if (currentElement.type === cElementType.table) {
elemArr.push(currentElement.toRef(bbox)); elemArr.push(currentElement.toRef(opt_bbox));
} else if (opt_offset) { } else if (opt_offset) {
var cloneElem = null; var cloneElem = null;
var bbox = null; var bbox = null;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment