Commit adc95892 authored by Alexander.Trofimov's avatar Alexander.Trofimov Committed by Alexander.Trofimov

_getColumnTitle из g_oCellAddressUtils

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@53920 954022d7-b5bf-4e40-9824-e11837661b57
parent c1c90c3c
......@@ -526,16 +526,27 @@ var gc_nMaxCol0 = gc_nMaxCol - 1;
* @constructor
*/
function CellAddressUtils(){
this._oCodeA = 'A'.charCodeAt();
this._oCodeA = 'A'.charCodeAt(0);
this._aColnumToColstr = [];
this.oCellAddressCache = {};
this.colnumToColstrFromWsView = function (col) {
var sResult = this._aColnumToColstr[col];
if (null != sResult)
return sResult;
if(col == 0) return "";
var col0 = col - 1;
var text = String.fromCharCode(65 + (col0 % 26));
return (this._aColnumToColstr[col] = (col0 < 26 ? text : this.colnumToColstrFromWsView(Math.floor(col0 / 26)) + text));
};
this.colnumToColstr = function(num){
var sResult = this._aColnumToColstr[num];
if(!sResult){
// convert 1 to A, 2 to B, ..., 27 to AA etc.
if(num == 0) return "";
var val = "";
var sResult = "";
var val;
sResult = "";
var n = num - 1;
if (n >= 702) {
val = (Math.floor(n / 676) - 1) % 26;
......@@ -555,8 +566,8 @@ function CellAddressUtils(){
var col_num = 0;
for (var i = 0; i < col_str.length; ++i)
col_num = 26 * col_num + (col_str.charCodeAt(i) - this._oCodeA + 1);
return col_num
}
return col_num;
};
this.getCellAddress = function(sId)
{
var oRes = this.oCellAddressCache[sId];
......@@ -566,7 +577,7 @@ function CellAddressUtils(){
this.oCellAddressCache[sId] = oRes;
}
return oRes;
}
};
}
var g_oCellAddressUtils = new CellAddressUtils();
/**
......
......@@ -35,13 +35,6 @@ function cADDRESS() {
cADDRESS.prototype = Object.create( cBaseFunction.prototype )
cADDRESS.prototype.Calculate = function ( arg ) {
function _getColumnTitle( col ) {
var q = col < 26 ? undefined : Asc.floor( col / 26 ) - 1;
var r = col % 26;
var text = String.fromCharCode( ("A").charCodeAt( 0 ) + r );
return col < 26 ? text : _getColumnTitle( q ) + text;
}
function _getRowTitle( row ) {
return "" + (row + 1);
}
......@@ -103,16 +96,16 @@ cADDRESS.prototype.Calculate = function ( arg ) {
var strRef;
switch ( refType.getValue() ) {
case 1:
strRef = "$" + _getColumnTitle( colNumber.getValue() - 1 ) + "$" + _getRowTitle( rowNumber.getValue() - 1 );
strRef = "$" + g_oCellAddressUtils.colnumToColstrFromWsView( colNumber.getValue() - 1 ) + "$" + _getRowTitle( rowNumber.getValue() - 1 );
break;
case 2:
strRef = _getColumnTitle( colNumber.getValue() - 1 ) + "$" + _getRowTitle( rowNumber.getValue() - 1 );
strRef = g_oCellAddressUtils.colnumToColstrFromWsView( colNumber.getValue() - 1 ) + "$" + _getRowTitle( rowNumber.getValue() - 1 );
break;
case 3:
strRef = "$" + _getColumnTitle( colNumber.getValue() - 1 ) + _getRowTitle( rowNumber.getValue() - 1 );
strRef = "$" + g_oCellAddressUtils.colnumToColstrFromWsView( colNumber.getValue() - 1 ) + _getRowTitle( rowNumber.getValue() - 1 );
break;
case 4:
strRef = _getColumnTitle( colNumber.getValue() - 1 ) + _getRowTitle( rowNumber.getValue() - 1 );
strRef = g_oCellAddressUtils.colnumToColstrFromWsView( colNumber.getValue() - 1 ) + _getRowTitle( rowNumber.getValue() - 1 );
break;
}
......
......@@ -4316,10 +4316,11 @@
* @return {String}
*/
WorksheetView.prototype._getColumnTitle = function (col) {
var q = col < 26 ? undefined : asc_floor(col / 26) - 1;
/*var q = col < 26 ? undefined : asc_floor(col / 26) - 1;
var r = col % 26;
var text = String.fromCharCode( ("A").charCodeAt(0) + r );
return col < 26 ? text : this._getColumnTitle(q) + text;
return col < 26 ? text : this._getColumnTitle(q) + text;*/
return g_oCellAddressUtils.colnumToColstrFromWsView(col + 1);
};
/**
......
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