Commit 7720c0a5 authored by Sergey.Konovalov's avatar Sergey.Konovalov Committed by Alexander.Trofimov

функция распознавания адреса из строки сделана более строгой.

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@57595 954022d7-b5bf-4e40-9824-e11837661b57
parent 29e5ae03
......@@ -787,42 +787,60 @@ CellAddress.prototype._recalculate=function(bCoord, bId){
if(bCoord && this._invalidCoord){
this._invalidCoord = false;
var sId = this.id;
var nSymIndex = sId.indexOf("$");
if(-1 != nSymIndex)
{
if(0 == nSymIndex)
{
nSymIndex = sId.indexOf("$", nSymIndex + 1);
this.bColAbs = true;
}
if(-1 != nSymIndex)
this.bRowAbs = true;
sId = sId.replace(/\$/g,"");
}
var nIndex = 0;
var nIdLength = sId.length;
while(this._isAlpha(sId.charAt(nIndex)) && nIndex < nIdLength)
nIndex++;
if(0 == nIndex){
// (1,Infinity)
this.bIsRow = true;
this.col = 1;
this.colLetter = g_oCellAddressUtils.colnumToColstr(this.col);
this.row = sId.substring(nIndex) - 0;
//this.id = this.colLetter + this.row;
}
else if(nIndex == nIdLength){
// (Infinity,1)
this.bIsCol = true;
this.colLetter = sId;
this.col = g_oCellAddressUtils.colstrToColnum(this.colLetter);
this.row = 1;
//this.id = this.colLetter + this.row;
this.row = this.col = 0;//выставляем невалидные значения, чтобы не присваивать их при каждом else
var indexes = {}, i = -1, indexesCount = 0;
while ((i = sId.indexOf("$", i + 1)) != -1) {
indexes[i - indexesCount++] = 1;//отнимаем количество, чтобы индексы указывали на следующий после них символ после удаления $
}
else{
this.colLetter = sId.substring(0, nIndex);
this.col = g_oCellAddressUtils.colstrToColnum(this.colLetter);
this.row = sId.substring(nIndex) - 0;
if (indexesCount <= 2) {
if (indexesCount > 0)
sId = sId.replace(/\$/g, "");
var nIdLength = sId.length;
if (nIdLength > 0) {
var nIndex = 0;
while (this._isAlpha(sId.charAt(nIndex)) && nIndex < nIdLength)
nIndex++;
if (0 == nIndex) {
// (1,Infinity)
this.bIsRow = true;
this.col = 1;
this.colLetter = g_oCellAddressUtils.colnumToColstr(this.col);
this.row = sId.substring(nIndex) - 0;
//this.id = this.colLetter + this.row;
if (null != indexes[0]) {
this.bRowAbs = true;
indexesCount--;
}
}
else if (nIndex == nIdLength) {
// (Infinity,1)
this.bIsCol = true;
this.colLetter = sId;
this.col = g_oCellAddressUtils.colstrToColnum(this.colLetter);
this.row = 1;
//this.id = this.colLetter + this.row;
if (null != indexes[0]) {
this.bColAbs = true;
indexesCount--;
}
}
else {
this.colLetter = sId.substring(0, nIndex);
this.col = g_oCellAddressUtils.colstrToColnum(this.colLetter);
this.row = sId.substring(nIndex) - 0;
if (null != indexes[0]) {
this.bColAbs = true;
indexesCount--;
}
if (null != indexes[nIndex]) {
this.bRowAbs = true;
indexesCount--;
}
}
if (indexesCount > 0) {
this.row = this.col = 0;
}
}
}
}
else if(bId && this._invalidId){
......
......@@ -593,17 +593,20 @@
var oCacheVal = this.oCache[sRange];
if(null == oCacheVal)
{
var oFirstAddr, oLastAddr;
var oFirstAddr, oLastAddr;
var bIsSingle = true;
var nIndex = sRange.indexOf(":");
if(-1 != nIndex)
{
bIsSingle = false;
oFirstAddr = g_oCellAddressUtils.getCellAddress(sRange.substring(0, nIndex));
oLastAddr = g_oCellAddressUtils.getCellAddress(sRange.substring(nIndex + 1));
}
else
oFirstAddr = oLastAddr = g_oCellAddressUtils.getCellAddress(sRange);
oCacheVal = {first: null, last: null, ascRange: null, formulaRange: null, activeRange: null};
if(oFirstAddr.isValid() && oLastAddr.isValid())
oCacheVal = { first: null, last: null, ascRange: null, formulaRange: null, activeRange: null };
//последнее условие, чтобы не распознавалось "A", "1"(должно быть "A:A", "1:1")
if (oFirstAddr.isValid() && oLastAddr.isValid() && (!bIsSingle || (!oFirstAddr.getIsRow() && !oFirstAddr.getIsCol())))
{
oCacheVal.first = oFirstAddr;
oCacheVal.last = oLastAddr;
......
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