Commit 84c1aa29 authored by konovalovsergey's avatar konovalovsergey Committed by Alexander.Trofimov

fix bug 31395

parent a4417d30
...@@ -341,101 +341,7 @@ var editor; ...@@ -341,101 +341,7 @@ var editor;
if (!cultureInfo) { if (!cultureInfo) {
cultureInfo = AscCommon.g_aCultureInfos[1033]; cultureInfo = AscCommon.g_aCultureInfos[1033];
} }
var prefixs = ['_ ', '_-', '_(', '_)']; return AscCommonExcel.getCurrencyFormat(cultureInfo, true, true, true);
var prefix = prefixs[0];
var postfix = prefixs[0];
var numberFormat = '#,##0.00';
var nullSignFormat = '* "-"??';
var positiveNumberFormat = '* ' + numberFormat;
var signCurrencyFormat = '[$' + cultureInfo.CurrencySymbol + '-' + cultureInfo.LCID.toString(16).toUpperCase() + ']';
var positiveFormat;
var negativeFormat;
var nullFormat;
switch (cultureInfo.CurrencyNegativePattern) {
case 0:
prefix = prefixs[2];
postfix = prefixs[3];
negativeFormat = prefix + signCurrencyFormat + '* \\(' + numberFormat + '\\)';
break;
case 1:
prefix = postfix = prefixs[1];
negativeFormat = '\\-' + signCurrencyFormat + '* ' + numberFormat + postfix;
break;
case 2:
negativeFormat = prefix + signCurrencyFormat + '\\ * \\-' + numberFormat + postfix;
break;
case 3:
prefix = postfix = prefixs[1];
negativeFormat = prefix + signCurrencyFormat + '\\ * ' + numberFormat + '\\-';
break;
case 4:
prefix = prefixs[2];
postfix = prefixs[3];
negativeFormat = prefix + '* \\(' + numberFormat + '\\)' + signCurrencyFormat + postfix;
break;
case 5:
prefix = postfix = prefixs[1];
negativeFormat = '\\-* ' + numberFormat + signCurrencyFormat + postfix;
break;
case 6:
negativeFormat = prefix + '* ' + numberFormat + '\\-' + signCurrencyFormat + postfix;
break;
case 7:
negativeFormat = prefix + '* ' + numberFormat + signCurrencyFormat + '\\-';
break;
case 8:
prefix = postfix = prefixs[1];
negativeFormat = '\\-* ' + numberFormat + '\\ ' + signCurrencyFormat + postfix;
break;
case 9:
prefix = postfix = prefixs[1];
negativeFormat = '\\-' + signCurrencyFormat + '\\ * ' + numberFormat + postfix;
break;
case 10:
negativeFormat = prefix + '* ' + numberFormat + '\\ ' + signCurrencyFormat + '\\-';
break;
case 11:
negativeFormat = prefix + signCurrencyFormat + '\\ * ' + numberFormat + '\\-';
break;
case 12:
negativeFormat = prefix + signCurrencyFormat + '\\ * \\-' + numberFormat + postfix;
break;
case 13:
negativeFormat = prefix + '* ' + numberFormat + '\\-\\ ' + signCurrencyFormat + postfix;
break;
case 14:
prefix = prefixs[2];
postfix = prefixs[3];
negativeFormat = prefix + signCurrencyFormat + '\\ * \\(' + numberFormat + '\\)';
break;
case 15:
prefix = prefixs[2];
postfix = prefixs[3];
negativeFormat = prefix + '* \\(' + numberFormat + '\\)\\ ' + signCurrencyFormat + postfix;
break;
}
switch (cultureInfo.CurrencyPositivePattern) {
case 0:
positiveFormat = signCurrencyFormat + positiveNumberFormat;
nullFormat = signCurrencyFormat + nullSignFormat;
break;
case 1:
positiveFormat = positiveNumberFormat + signCurrencyFormat;
nullFormat = nullSignFormat + signCurrencyFormat;
break;
case 2:
positiveFormat = signCurrencyFormat + '\\ ' + positiveNumberFormat;
nullFormat = signCurrencyFormat + '\\ ' + nullSignFormat;
break;
case 3:
positiveFormat = positiveNumberFormat + '\\ ' + signCurrencyFormat;
nullFormat = nullSignFormat + '\\ ' + signCurrencyFormat;
break;
}
positiveFormat = prefix + positiveFormat + postfix;
nullFormat = prefix + nullFormat + postfix;
var textFormat = prefix + '@' + postfix;
return positiveFormat + ';' + negativeFormat + ';' + nullFormat + ';' + textFormat;
}; };
spreadsheet_api.prototype.asc_setLocale = function(val) { spreadsheet_api.prototype.asc_setLocale = function(val) {
if (!this.isLoadFullApi) { if (!this.isLoadFullApi) {
......
...@@ -1610,7 +1610,7 @@ ...@@ -1610,7 +1610,7 @@
{ {
var dxf = this.aDxfs[i]; var dxf = this.aDxfs[i];
if(dxf && dxf.num) if(dxf && dxf.num)
oDxfsNumFormatToId[dxf.num.f] = this.oBinaryWorksheetsTableWriter.getNumIdByFormat(dxf.num); oDxfsNumFormatToId[dxf.num.getFormat()] = this.oBinaryWorksheetsTableWriter.getNumIdByFormat(dxf.num);
} }
this.bs.WriteItem(c_oSerStylesTypes.Dxfs, function(){oThis.WriteDxfs(oThis.aDxfs, oDxfsNumFormatToId);}); this.bs.WriteItem(c_oSerStylesTypes.Dxfs, function(){oThis.WriteDxfs(oThis.aDxfs, oDxfsNumFormatToId);});
} }
...@@ -1826,7 +1826,7 @@ ...@@ -1826,7 +1826,7 @@
{ {
var num = this.oNumMap[i]; var num = this.oNumMap[i];
if(false == num.val.isEqual(g_oDefaultFormat.NumAbs)) if(false == num.val.isEqual(g_oDefaultFormat.NumAbs))
this.bs.WriteItem(c_oSerStylesTypes.NumFmt, function(){oThis.WriteNum({id: num.index, f: num.val.f});}); this.bs.WriteItem(c_oSerStylesTypes.NumFmt, function(){oThis.WriteNum({id: num.index, f: num.val.getFormat()});});
} }
}; };
this.WriteNum = function(num) this.WriteNum = function(num)
...@@ -2028,9 +2028,9 @@ ...@@ -2028,9 +2028,9 @@
this.bs.WriteItem(c_oSer_Dxf.Font, function(){oThis.WriteFont(Dxf.font);}); this.bs.WriteItem(c_oSer_Dxf.Font, function(){oThis.WriteFont(Dxf.font);});
if(null != Dxf.num && null != oDxfsNumFormatToId) if(null != Dxf.num && null != oDxfsNumFormatToId)
{ {
var numId = oDxfsNumFormatToId[Dxf.num.f]; var numId = oDxfsNumFormatToId[Dxf.num.getFormat()];
if(null != numId) if(null != numId)
this.bs.WriteItem(c_oSer_Dxf.NumFmt, function(){oThis.WriteNum({id: numId, f: Dxf.num.f});}); this.bs.WriteItem(c_oSer_Dxf.NumFmt, function(){oThis.WriteNum({id: numId, f: Dxf.num.getFormat()});});
} }
}; };
this.WriteCellStyles = function (cellStyles) { this.WriteCellStyles = function (cellStyles) {
...@@ -3167,25 +3167,28 @@ ...@@ -3167,25 +3167,28 @@
return sStyle; return sStyle;
}; };
this.getNumIdByFormat = function(num) this.getNumIdByFormat = function(num) {
{
var numid = null; var numid = null;
//стандартные форматы не записываем в map, на них можно ссылаться по id //стандартные форматы не записываем в map, на них можно ссылаться по id
var nStandartId = AscCommonExcel.aStandartNumFormatsId[num.f]; var nStandartId;
if(null == nStandartId) if (null != num.id) {
{ nStandartId = num.id;
} else {
nStandartId = AscCommonExcel.aStandartNumFormatsId[num.getFormat()];
}
if (null == nStandartId) {
var sHash = this._getStringFromObjWithProperty(num); var sHash = this._getStringFromObjWithProperty(num);
var elem = this.oNumMap[sHash]; var elem = this.oNumMap[sHash];
if(null == elem) if (null == elem) {
{
numid = this.nNumMapIndex++; numid = this.nNumMapIndex++;
this.oNumMap[sHash] = {index: numid, val: num}; this.oNumMap[sHash] = {index: numid, val: num};
} } else {
else
numid = elem.index; numid = elem.index;
} }
else } else {
numid = nStandartId; numid = nStandartId;
}
return numid; return numid;
}; };
this.prepareXfs = function(xfs) this.prepareXfs = function(xfs)
...@@ -4658,41 +4661,29 @@ ...@@ -4658,41 +4661,29 @@
if(null != xfs.align && g_oDefaultFormat.AlignAbs.isEqual(xfs.align)) if(null != xfs.align && g_oDefaultFormat.AlignAbs.isEqual(xfs.align))
xfs.align = null; xfs.align = null;
}; };
this.ParseNum = function(oNum, oNumFmts) this.ParseNum = function(oNum, oNumFmts) {
{
var oRes = null; var oRes = null;
var sFormat = null; var sFormat = null;
if(null != oNum && null != oNum.f) if (null != oNum && null != oNum.f) {
sFormat = oNum.f; sFormat = oNum.f;
else } else {
{
if(5 <= oNum.id && oNum.id <= 8)
{
//В спецификации нет стилей для чисел 5-8, экспериментально установлено, что это денежный формат, зависящий от локали.
//Устанавливаем как в Engilsh(US)
switch(oNum.id)
{
case 5: sFormat = "$#,##0_);($#,##0)";break;
case 6: sFormat = "$#,##0_);[Red]($#,##0)";break;
case 7: sFormat = "$#,##0.00_);($#,##0.00)";break;
case 8: sFormat = "$#,##0.00_);[Red]($#,##0.00)";break;
}
}
else
{
var sStandartNumFormat = AscCommonExcel.aStandartNumFormats[oNum.id]; var sStandartNumFormat = AscCommonExcel.aStandartNumFormats[oNum.id];
if(null != sStandartNumFormat) if (null != sStandartNumFormat) {
sFormat = sStandartNumFormat; sFormat = sStandartNumFormat;
} }
if(null == sFormat) if (null == sFormat) {
sFormat = "General"; sFormat = "General";
if(null != oNumFmts)
oNumFmts[oNum.id] = {id:oNum.id, f: sFormat};
} }
if(null != sFormat) if (null != oNumFmts) {
{ oNumFmts[oNum.id] = {id: oNum.id, f: sFormat};
}
}
if (null != sFormat) {
oRes = new AscCommonExcel.Num(); oRes = new AscCommonExcel.Num();
oRes.f = sFormat; oRes.f = sFormat;
if ((5 <= oNum.id && oNum.id <= 8) || (15 <= oNum.id && oNum.id <= 17) || (37 <= oNum.id && oNum.id <= 44)) {
oRes.id = oNum.id;
}
} }
return oRes; return oRes;
}; };
......
...@@ -5204,7 +5204,7 @@ Woorksheet.prototype._RecalculatedFunctions=function(cell,bad,setCellFormat){ ...@@ -5204,7 +5204,7 @@ Woorksheet.prototype._RecalculatedFunctions=function(cell,bad,setCellFormat){
r = r[0]; r = r[0];
if ( r && r.getNumFormatStr ) { if ( r && r.getNumFormatStr ) {
var sCurFormat = c.getNumFormatStr(); var sCurFormat = c.getNumFormatStr();
if ( g_oDefaultFormat.Num.f == sCurFormat ) { if ( g_oDefaultFormat.Num.getFormat() == sCurFormat ) {
var sNewFormat = r.getNumFormatStr(); var sNewFormat = r.getNumFormatStr();
if ( sCurFormat != sNewFormat ) if ( sCurFormat != sNewFormat )
c.setNumFormat( sNewFormat ); c.setNumFormat( sNewFormat );
...@@ -5493,9 +5493,9 @@ Cell.prototype.setValue=function(val,callback, isCopyPaste){ ...@@ -5493,9 +5493,9 @@ Cell.prototype.setValue=function(val,callback, isCopyPaste){
if(!isCopyPaste){ if(!isCopyPaste){
var sNumFormat; var sNumFormat;
if(null != this.xfs && null != this.xfs.num) if(null != this.xfs && null != this.xfs.num)
sNumFormat = this.xfs.num.f; sNumFormat = this.xfs.num.getFormat();
else else
sNumFormat = g_oDefaultFormat.Num.f; sNumFormat = g_oDefaultFormat.Num.getFormat();
var numFormat = oNumFormatCache.get(sNumFormat); var numFormat = oNumFormatCache.get(sNumFormat);
bIsTextFormat = numFormat.isTextFormat(); bIsTextFormat = numFormat.isTextFormat();
} }
...@@ -5675,9 +5675,9 @@ Cell.prototype.shiftNumFormat=function(nShift, dDigitsCount){ ...@@ -5675,9 +5675,9 @@ Cell.prototype.shiftNumFormat=function(nShift, dDigitsCount){
var bGeneral = true; var bGeneral = true;
var sNumFormat; var sNumFormat;
if(null != this.xfs && null != this.xfs.num) if(null != this.xfs && null != this.xfs.num)
sNumFormat = this.xfs.num.f; sNumFormat = this.xfs.num.getFormat();
else else
sNumFormat = g_oDefaultFormat.Num.f; sNumFormat = g_oDefaultFormat.Num.getFormat();
if("General" != sNumFormat) if("General" != sNumFormat)
{ {
var oCurNumFormat = oNumFormatCache.get(sNumFormat); var oCurNumFormat = oNumFormatCache.get(sNumFormat);
...@@ -5929,8 +5929,8 @@ Cell.prototype.getValue2=function(dDigitsCount, fIsFitMeasurer){ ...@@ -5929,8 +5929,8 @@ Cell.prototype.getValue2=function(dDigitsCount, fIsFitMeasurer){
}; };
Cell.prototype.getNumFormatStr=function(){ Cell.prototype.getNumFormatStr=function(){
if(null != this.xfs && null != this.xfs.num) if(null != this.xfs && null != this.xfs.num)
return this.xfs.num.f; return this.xfs.num.getFormat();
return g_oDefaultFormat.Num.f; return g_oDefaultFormat.Num.getFormat();
}; };
Cell.prototype.getNumFormat=function(){ Cell.prototype.getNumFormat=function(){
return oNumFormatCache.get(this.getNumFormatStr()); return oNumFormatCache.get(this.getNumFormatStr());
...@@ -7160,19 +7160,19 @@ Range.prototype.getNumFormatStr=function(){ ...@@ -7160,19 +7160,19 @@ Range.prototype.getNumFormatStr=function(){
{ {
var xfs = cell.getCompiledStyle(); var xfs = cell.getCompiledStyle();
if(null != xfs && null != xfs.num) if(null != xfs && null != xfs.num)
return xfs.num.f; return xfs.num.getFormat();
} }
else else
{ {
//стили столбов и колонок //стили столбов и колонок
var row = this.worksheet._getRowNoEmpty(nRow); var row = this.worksheet._getRowNoEmpty(nRow);
if(null != row && null != row.xfs && null != row.xfs.num) if(null != row && null != row.xfs && null != row.xfs.num)
return row.xfs.num.f; return row.xfs.num.getFormat();
var col = this.worksheet._getColNoEmptyWithAll(nCol); var col = this.worksheet._getColNoEmptyWithAll(nCol);
if(null != col && null != col.xfs && null != col.xfs.num) if(null != col && null != col.xfs && null != col.xfs.num)
return col.xfs.num.f; return col.xfs.num.getFormat();
} }
return g_oDefaultFormat.Num.f; return g_oDefaultFormat.Num.getFormat();
}; };
Range.prototype.getNumFormatType=function(){ Range.prototype.getNumFormatType=function(){
return this.getNumFormat().getType(); return this.getNumFormat().getType();
...@@ -9156,8 +9156,8 @@ function _promoteFromTo(from, wsFrom, to, wsTo, bIsPromote, oCanPromote, bCtrl, ...@@ -9156,8 +9156,8 @@ function _promoteFromTo(from, wsFrom, to, wsTo, bIsPromote, oCanPromote, bCtrl,
} }
} }
} }
if(null != oCell.xfs && null != oCell.xfs.num && null != oCell.xfs.num.f){ if(null != oCell.xfs && null != oCell.xfs.num && null != oCell.xfs.num.getFormat()){
var numFormat = oNumFormatCache.get(oCell.xfs.num.f); var numFormat = oNumFormatCache.get(oCell.xfs.num.getFormat());
if(numFormat.isDateTimeFormat()) if(numFormat.isDateTimeFormat())
bDate = true; bDate = true;
} }
......
This diff is collapsed.
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