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

add RangeCache.getActiveRange

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@56069 954022d7-b5bf-4e40-9824-e11837661b57
parent f01a6ad3
...@@ -526,13 +526,17 @@ ...@@ -526,13 +526,17 @@
RangeCache.prototype = { RangeCache.prototype = {
getAscRange : function(sRange) getAscRange : function(sRange)
{ {
return this._getRange(sRange, true); return this._getRange(sRange, 1);
},
getActiveRange : function(sRange)
{
return this._getRange(sRange, 2);
}, },
getFormulaRange : function(sRange) getFormulaRange : function(sRange)
{ {
return this._getRange(sRange, false); return this._getRange(sRange, 3);
}, },
_getRange : function(sRange, bAscRange) _getRange : function(sRange, type)
{ {
var oRes = null; var oRes = null;
var oCacheVal = this.oCache[sRange]; var oCacheVal = this.oCache[sRange];
...@@ -544,45 +548,79 @@ ...@@ -544,45 +548,79 @@
{ {
oFirstAddr = g_oCellAddressUtils.getCellAddress(sRange.substring(0, nIndex)); oFirstAddr = g_oCellAddressUtils.getCellAddress(sRange.substring(0, nIndex));
oLastAddr = g_oCellAddressUtils.getCellAddress(sRange.substring(nIndex + 1)); oLastAddr = g_oCellAddressUtils.getCellAddress(sRange.substring(nIndex + 1));
if(oFirstAddr.getIsRow() && oLastAddr.getIsRow())
{
oFirstAddr.setCol(1);
oLastAddr.setCol(gc_nMaxCol);
}
if(oFirstAddr.getIsCol() && oLastAddr.getIsCol())
{
oFirstAddr.setRow(1);
oLastAddr.setRow(gc_nMaxRow);
}
} }
else else
oFirstAddr = oLastAddr = g_oCellAddressUtils.getCellAddress(sRange); oFirstAddr = oLastAddr = g_oCellAddressUtils.getCellAddress(sRange);
oCacheVal = {first: null, last: null, ascRange: null, formulaRange: null}; oCacheVal = {first: null, last: null, ascRange: null, formulaRange: null, activeRange: null};
if(oFirstAddr.isValid() && oLastAddr.isValid()) if(oFirstAddr.isValid() && oLastAddr.isValid())
{ {
oCacheVal.first = oFirstAddr; oCacheVal.first = oFirstAddr;
oCacheVal.last = oLastAddr; oCacheVal.last = oLastAddr;
} }
this.oCache[sRange] = oCacheVal; this.oCache[sRange] = oCacheVal;
} }
if(bAscRange) if (1 == type)
{ oRes = oCacheVal.ascRange;
if(null == oCacheVal.ascRange && null != oCacheVal.first && null != oCacheVal.last) else if (2 == type)
oCacheVal.ascRange = new Asc.Range(oCacheVal.first.getCol0(), oCacheVal.first.getRow0(), oCacheVal.last.getCol0(), oCacheVal.last.getRow0()); oRes = oCacheVal.activeRange;
oRes = oCacheVal.ascRange;
}
else else
{ oRes = oCacheVal.formulaRange;
if(null == oCacheVal.formulaRange && null != oCacheVal.first && null != oCacheVal.last) if (null == oRes && null != oCacheVal.first && null != oCacheVal.last) {
{ var r1 = oCacheVal.first.getRow0(), r2 = oCacheVal.last.getRow0(), c1 = oCacheVal.first.getCol0(), c2 = oCacheVal.last.getCol0();
var oFormulaRange = new Asc.FormulaRange(oCacheVal.first.getCol0(), oCacheVal.first.getRow0(), oCacheVal.last.getCol0(), oCacheVal.last.getRow0()); if (oFirstAddr.getIsRow() && oLastAddr.getIsRow()) {
oFormulaRange.r1Abs = oCacheVal.first.getRowAbs(); c1 = 0;
oFormulaRange.c1Abs = oCacheVal.first.getColAbs(); c2 = gc_nMaxCol0;
oFormulaRange.r2Abs = oCacheVal.last.getRowAbs(); }
oFormulaRange.c2Abs = oCacheVal.last.getColAbs(); if (oFirstAddr.getIsCol() && oLastAddr.getIsCol()) {
oCacheVal.formulaRange = oFormulaRange; r1 = 0;
} r2 = gc_nMaxRow0;
oRes = oCacheVal.formulaRange; }
if (r1 > r2) {
var temp = r1;
r1 = r2;
r2 = temp;
}
if (c1 > c2) {
var temp = c1;
c1 = c2;
c2 = temp;
}
if (1 == type) {
if (null == oCacheVal.ascRange)
oCacheVal.ascRange = new Asc.Range(c1, r1, c2, r2);
oRes = oCacheVal.ascRange;
}
else if (2 == type) {
if (null == oCacheVal.activeRange) {
var oActiveRange = new Asc.ActiveRange(c1, r1, c2, r2);
var bCol = 0 == r1 && gc_nMaxRow0 == r2;
var bRow = 0 == c1 && gc_nMaxCol0 == c2;
if (bCol && bRow)
oActiveRange.type = c_oAscSelectionType.RangeMax;
else if (bCol)
oActiveRange.type = c_oAscSelectionType.RangeCol;
else if (bRow)
oActiveRange.type = c_oAscSelectionType.RangeRow;
else
oActiveRange.type = c_oAscSelectionType.RangeCells;
oActiveRange.startCol = oActiveRange.c1;
oActiveRange.startRow = oActiveRange.r1;
oCacheVal.activeRange = oActiveRange;
}
oRes = oCacheVal.activeRange;
}
else {
if (null == oCacheVal.formulaRange) {
var oFormulaRange = new Asc.FormulaRange(c1, r1, c2, r2);
oFormulaRange.r1Abs = oCacheVal.first.getRowAbs();
oFormulaRange.c1Abs = oCacheVal.first.getColAbs();
oFormulaRange.r2Abs = oCacheVal.last.getRowAbs();
oFormulaRange.c2Abs = oCacheVal.last.getColAbs();
oCacheVal.formulaRange = oFormulaRange;
}
oRes = oCacheVal.formulaRange;
}
} }
return oRes; return oRes;
} }
......
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