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

Bug 31394 - Изменить пример для настройки Regional Settings

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@67605 954022d7-b5bf-4e40-9824-e11837661b57
parent 19a84754
...@@ -2208,30 +2208,23 @@ CellFormat.prototype = ...@@ -2208,30 +2208,23 @@ CellFormat.prototype =
} }
return oRes; return oRes;
}, },
format : function(number, nValType, dDigitsCount, oAdditionalResult, bChart) format : function(number, nValType, dDigitsCount, oAdditionalResult, bChart, cultureInfo)
{ {
var res = null; var res = null;
if (null == bChart) if (null == bChart)
bChart = false; bChart = false;
var cacheVal = this.formatCache[number]; var lcid = cultureInfo ? cultureInfo.LCID : 0;
var cacheType = null; var cacheKey = number + '-' + nValType + '-' + dDigitsCount + '-' + lcid;
var cacheRes = null; var cacheVal = this.formatCache[cacheKey];
if(null != cacheVal) if(null != cacheVal)
{ {
cacheType = cacheVal[nValType];
if (null != cacheType)
{
cacheRes = cacheType[dDigitsCount];
if (null != cacheRes) {
if (bChart) if (bChart)
res = cacheRes.chart; res = cacheVal.chart;
else else
res = cacheRes.nochart; res = cacheVal.nochart;
if (null != res) if (null != res)
return res; return res;
} }
}
}
res = [{text: number.toString()}]; res = [{text: number.toString()}];
var dNumber = number - 0; var dNumber = number - 0;
var oFormat = null; var oFormat = null;
...@@ -2239,7 +2232,7 @@ CellFormat.prototype = ...@@ -2239,7 +2232,7 @@ CellFormat.prototype =
{ {
oFormat = this.getFormatByValue(dNumber); oFormat = this.getFormatByValue(dNumber);
if(null != oFormat) if(null != oFormat)
res = oFormat.format(number, nValType, dDigitsCount, oAdditionalResult, null, bChart); res = oFormat.format(number, nValType, dDigitsCount, oAdditionalResult, cultureInfo, bChart);
else if(null != this.aComporationFormats) else if(null != this.aComporationFormats)
{ {
var oNewFont = new NumFormatFont(); var oNewFont = new NumFormatFont();
...@@ -2252,32 +2245,23 @@ CellFormat.prototype = ...@@ -2252,32 +2245,23 @@ CellFormat.prototype =
//text //text
if (null != this.oTextFormat) { if (null != this.oTextFormat) {
oFormat = this.oTextFormat; oFormat = this.oTextFormat;
res = oFormat.format(number, nValType, dDigitsCount, oAdditionalResult, null, bChart); res = oFormat.format(number, nValType, dDigitsCount, oAdditionalResult, cultureInfo, bChart);
} }
} }
if(null == cacheVal) if(null == cacheVal)
{ {
cacheVal = {}; cacheVal = { chart: null, nochart: null };
this.formatCache[number] = cacheVal; this.formatCache[cacheKey] = cacheVal;
}
if(null == cacheType)
{
cacheType = {};
cacheVal[nValType] = cacheType;
}
if (null == cacheRes) {
cacheRes = { chart: null, nochart: null };
cacheType[dDigitsCount] = cacheRes;
} }
if (null != oFormat && oFormat.bGeneralChart) { if (null != oFormat && oFormat.bGeneralChart) {
if (bChart) if (bChart)
cacheRes.chart = res; cacheVal.chart = res;
else else
cacheRes.nochart = res; cacheVal.nochart = res;
} }
else { else {
cacheRes.chart = res; cacheVal.chart = res;
cacheRes.nochart = res; cacheVal.nochart = res;
} }
return res; return res;
}, },
...@@ -2346,14 +2330,14 @@ CellFormat.prototype = ...@@ -2346,14 +2330,14 @@ CellFormat.prototype =
{ {
return this._formatToText(number, nValType, dDigitsCount, false); return this._formatToText(number, nValType, dDigitsCount, false);
}, },
formatToChart : function(number) formatToChart : function(number, cultureInfo)
{ {
return this._formatToText(number, CellValueType.Number, gc_nMaxDigCount, true); return this._formatToText(number, CellValueType.Number, gc_nMaxDigCount, true, cultureInfo);
}, },
_formatToText : function(number, nValType, dDigitsCount, bChart) _formatToText : function(number, nValType, dDigitsCount, bChart, cultureInfo)
{ {
var result = ""; var result = "";
var arrFormat = this.format(number, nValType, dDigitsCount, null, bChart); var arrFormat = this.format(number, nValType, dDigitsCount, null, bChart, cultureInfo);
for (var i = 0, item; i < arrFormat.length; ++i) { for (var i = 0, item; i < arrFormat.length; ++i) {
item = arrFormat[i]; item = arrFormat[i];
if (item.format) { if (item.format) {
......
...@@ -287,16 +287,7 @@ var editor; ...@@ -287,16 +287,7 @@ var editor;
var res = ''; var res = '';
var cultureInfo = g_aCultureInfos[val]; var cultureInfo = g_aCultureInfos[val];
if (cultureInfo) { if (cultureInfo) {
var prefixIndex = [0, 1, 2, 3, 9, 11, 12, 14]; var numFormatDigit = oNumFormatCache.get('#,##0.00');
var formatCurrency;
var formatCurrencyNumber = '#,##0.00';
var formatCurrencySymbol = '\"' + cultureInfo.CurrencySymbol + '\"';
if (-1 != prefixIndex.indexOf(cultureInfo.CurrencyNegativePattern)) {
formatCurrency = formatCurrencySymbol + formatCurrencyNumber;
} else {
formatCurrency = formatCurrencyNumber + formatCurrencySymbol;
}
var numFormatCurrency = oNumFormatCache.get(formatCurrency);
var dateElems = []; var dateElems = [];
for (var i = 0; i < cultureInfo.ShortDatePattern.length; ++i) { for (var i = 0; i < cultureInfo.ShortDatePattern.length; ++i) {
...@@ -319,9 +310,9 @@ var editor; ...@@ -319,9 +310,9 @@ var editor;
} }
var numFormatDate = oNumFormatCache.get(formatDate); var numFormatDate = oNumFormatCache.get(formatDate);
res += numFormatCurrency.formatToChart(number); res += numFormatDigit.formatToChart(number, cultureInfo);
res += '; '; res += '; ';
res += numFormatDate.formatToChart(date.getExcelDateWithTime()); res += numFormatDate.formatToChart(date.getExcelDateWithTime(), cultureInfo);
} }
return res; return res;
}; };
......
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