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;
} }
......
...@@ -1018,33 +1018,118 @@ function Num(val) ...@@ -1018,33 +1018,118 @@ function Num(val)
val = g_oDefaultFormat.NumAbs; val = g_oDefaultFormat.NumAbs;
this.Properties = g_oNumProperties; this.Properties = g_oNumProperties;
this.f = val.f; this.f = val.f;
this.id = val.id;
} }
Num.prototype = Num.prototype =
{ {
setFormat: function(f, opt_id) {
this.f = f;
this.id = opt_id;
},
getFormat: function() {
var res = this.f;
if (null != this.id) {
if (15 <= this.id && this.id <= 17) {
var separator;
if ('/' == AscCommon.g_oDefaultCultureInfo.DateSeparator) {
separator = '-';
} else {
separator = '/';
}
switch (this.id) {
case 15:
res = 'd' + separator + 'mmm' + separator + 'yy';
break;
case 16:
res = 'd' + separator + 'mmm';
break;
case 17:
res = 'mmm' + separator + 'yy';
break;
}
} else {
switch (this.id) {
case 5:
res = AscCommonExcel.getCurrencyFormatSimple(null, false, true, false);
break;
case 6:
res = AscCommonExcel.getCurrencyFormatSimple(null, false, true, true);
break;
case 7:
res = AscCommonExcel.getCurrencyFormatSimple(null, true, true, false);
break;
case 8:
res = AscCommonExcel.getCurrencyFormatSimple(null, true, true, true);
break;
case 37:
res = AscCommonExcel.getCurrencyFormatSimple(null, false, false, false);
break;
case 38:
res = AscCommonExcel.getCurrencyFormatSimple(null, false, false, true);
break;
case 39:
res = AscCommonExcel.getCurrencyFormatSimple(null, true, false, false);
break;
case 40:
res = AscCommonExcel.getCurrencyFormatSimple(null, true, false, true);
break;
case 41:
res = AscCommonExcel.getCurrencyFormat(null, false, false, false);
break;
case 42:
res = AscCommonExcel.getCurrencyFormat(null, false, true, false);
break;
case 43:
res = AscCommonExcel.getCurrencyFormat(null, true, false, false);
break;
case 44:
res = AscCommonExcel.getCurrencyFormat(null, true, true, false);
break;
}
}
}
return res;
},
_mergeProperty : function(first, second, def)
{
if(def != first)
return first;
else
return second;
},
merge : function(num) merge : function(num)
{ {
var oRes = new Num(); var oRes = new Num();
if(g_oDefaultFormat.Num.f != this.f) oRes.f = this._mergeProperty(this.f, num.f, g_oDefaultFormat.Num.f);
oRes.f = this.f; oRes.id = this._mergeProperty(this.id, num.id, g_oDefaultFormat.Num.id);
else
oRes.f = num.f;
return oRes; return oRes;
}, },
getDif : function(val) getDif: function(val) {
{
var oRes = new Num(this); var oRes = new Num(this);
var bEmpty = true; var bEmpty = true;
if(this.f == val.f) if (this.f == val.f) {
oRes.f = null; oRes.f = null;
else } else {
bEmpty = false; bEmpty = false;
if(bEmpty) }
if (this.id == val.id) {
oRes.id = null;
} else {
bEmpty = false;
}
if (bEmpty) {
oRes = null; oRes = null;
}
return oRes; return oRes;
}, },
isEqual : function(val) isEqual: function(val) {
{ if (null != this.id && null != val.id) {
return this.id == val.id;
} else if (null != this.id || null != val.id) {
return false;
} else {
return this.f == val.f; return this.f == val.f;
}
}, },
clone : function() clone : function()
{ {
...@@ -1062,14 +1147,14 @@ Num.prototype = ...@@ -1062,14 +1147,14 @@ Num.prototype =
{ {
switch(nType) switch(nType)
{ {
case this.Properties.f: return this.f;break; case this.Properties.f: return this.getFormat();break;
} }
}, },
setProperty : function(nType, value) setProperty : function(nType, value)
{ {
switch(nType) switch(nType)
{ {
case this.Properties.f: this.f = value;break; case this.Properties.f: this.setFormat(value);break;
} }
} }
}; };
...@@ -1514,8 +1599,8 @@ CCellStyle.prototype.getBorder = function () { ...@@ -1514,8 +1599,8 @@ CCellStyle.prototype.getBorder = function () {
}; };
CCellStyle.prototype.getNumFormatStr = function () { CCellStyle.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();
}; };
/** @constructor */ /** @constructor */
function StyleManager(){ function StyleManager(){
...@@ -1607,9 +1692,9 @@ StyleManager.prototype = ...@@ -1607,9 +1692,9 @@ StyleManager.prototype =
var xfs = oItemWithXfs.xfs; var xfs = oItemWithXfs.xfs;
var oRes = {newVal: val, oldVal: null}; var oRes = {newVal: val, oldVal: null};
if(null != xfs && null != xfs.num) if(null != xfs && null != xfs.num)
oRes.oldVal = xfs.num.f; oRes.oldVal = xfs.num.getFormat();
else else
oRes.oldVal = g_oDefaultFormat.Num.f; oRes.oldVal = g_oDefaultFormat.Num.getFormat();
if(null == val) if(null == val)
{ {
if(null != xfs) { if(null != xfs) {
...@@ -1622,7 +1707,7 @@ StyleManager.prototype = ...@@ -1622,7 +1707,7 @@ StyleManager.prototype =
xfs = this._prepareSet(oItemWithXfs); xfs = this._prepareSet(oItemWithXfs);
if(null == xfs.num) if(null == xfs.num)
xfs.num = g_oDefaultFormat.Num.clone(); xfs.num = g_oDefaultFormat.Num.clone();
xfs.num.f = val; xfs.num.setFormat(val);
} }
return oRes; return oRes;
}, },
...@@ -2927,9 +3012,9 @@ CCellValue.prototype = ...@@ -2927,9 +3012,9 @@ CCellValue.prototype =
var oNumFormat; var oNumFormat;
var xfs = cell.getCompiledStyle(); var xfs = cell.getCompiledStyle();
if(null != xfs && null != xfs.num) if(null != xfs && null != xfs.num)
oNumFormat = oNumFormatCache.get(xfs.num.f); oNumFormat = oNumFormatCache.get(xfs.num.getFormat());
else else
oNumFormat = oNumFormatCache.get(g_oDefaultFormat.Num.f); oNumFormat = oNumFormatCache.get(g_oDefaultFormat.Num.getFormat());
if(false == oNumFormat.isGeneralFormat()) if(false == oNumFormat.isGeneralFormat())
{ {
var oAdditionalResult = {}; var oAdditionalResult = {};
...@@ -3063,9 +3148,9 @@ CCellValue.prototype = ...@@ -3063,9 +3148,9 @@ CCellValue.prototype =
{ {
var oNumFormat; var oNumFormat;
if(null != xfs && null != xfs.num) if(null != xfs && null != xfs.num)
oNumFormat = oNumFormatCache.get(xfs.num.f); oNumFormat = oNumFormatCache.get(xfs.num.getFormat());
else else
oNumFormat = oNumFormatCache.get(g_oDefaultFormat.Num.f); oNumFormat = oNumFormatCache.get(g_oDefaultFormat.Num.getFormat());
if(CellValueType.String != this.type && null != oNumFormat && null != this.number) if(CellValueType.String != this.type && null != oNumFormat && null != this.number)
{ {
var nValue = this.number; var nValue = this.number;
...@@ -3247,9 +3332,9 @@ CCellValue.prototype = ...@@ -3247,9 +3332,9 @@ CCellValue.prototype =
var oNumFormat; var oNumFormat;
var xfs = cell.getCompiledStyle(); var xfs = cell.getCompiledStyle();
if(null != xfs && null != xfs.num) if(null != xfs && null != xfs.num)
oNumFormat = oNumFormatCache.get(xfs.num.f); oNumFormat = oNumFormatCache.get(xfs.num.getFormat());
else else
oNumFormat = oNumFormatCache.get(g_oDefaultFormat.Num.f); oNumFormat = oNumFormatCache.get(g_oDefaultFormat.Num.getFormat());
if(oNumFormat.isTextFormat()) if(oNumFormat.isTextFormat())
{ {
this.type = CellValueType.String; this.type = CellValueType.String;
...@@ -5854,6 +5939,222 @@ AutoFilterDateElem.prototype.convertDateGroupItemToRange = function(oDateGroupIt ...@@ -5854,6 +5939,222 @@ AutoFilterDateElem.prototype.convertDateGroupItemToRange = function(oDateGroupIt
this.dateTimeGrouping = oDateGroupItem.DateTimeGrouping; this.dateTimeGrouping = oDateGroupItem.DateTimeGrouping;
}; };
function getCurrencyFormatSimple(opt_cultureInfo, opt_fraction, opt_currency, opt_red) {
var cultureInfo = opt_cultureInfo ? opt_cultureInfo : AscCommon.g_oDefaultCultureInfo;
var numberFormat = opt_fraction ? '#,##0.00' : '#,##0';
var signCurrencyFormat;
var signCurrencyFormatEnd;
if (opt_currency) {
signCurrencyFormat = signCurrencyFormatEnd = '"' + cultureInfo.CurrencySymbol + '"';
} else {
signCurrencyFormatEnd = signCurrencyFormat = '';
for (var i = 0; i < cultureInfo.CurrencySymbol.length; ++i) {
signCurrencyFormatEnd += '_' + cultureInfo.CurrencySymbol[i];
}
}
var red = opt_red ? '[Red]' : '';
var prefixs = ['_ ', '_-', '_(', '_)'];
var postfix = '';
var positiveFormat;
var negativeFormat;
switch (cultureInfo.CurrencyNegativePattern) {
case 0:
postfix = prefixs[3];
negativeFormat = '\\(' + signCurrencyFormat + numberFormat + '\\)';
break;
case 1:
negativeFormat = '\\-' + signCurrencyFormat + numberFormat;
break;
case 2:
negativeFormat = signCurrencyFormat + '\\ \\-' + numberFormat;
break;
case 3:
postfix = prefixs[1];
negativeFormat = signCurrencyFormat + '\\ ' + numberFormat + '\\-';
break;
case 4:
postfix = prefixs[3];
negativeFormat = '\\(' + numberFormat + signCurrencyFormatEnd + '\\)';
break;
case 5:
negativeFormat = '\\-' + numberFormat + signCurrencyFormatEnd;
break;
case 6:
negativeFormat = numberFormat + '\\-' + signCurrencyFormatEnd;
break;
case 7:
postfix = prefixs[1];
negativeFormat = numberFormat + signCurrencyFormatEnd + '\\-';
break;
case 8:
negativeFormat = '\\-' + numberFormat + '\\ ' + signCurrencyFormatEnd;
break;
case 9:
negativeFormat = '\\-' + signCurrencyFormat + '\\ ' + numberFormat;
break;
case 10:
postfix = prefixs[1];
negativeFormat = numberFormat + '\\ ' + signCurrencyFormatEnd + '\\-';
break;
case 11:
postfix = prefixs[1];
negativeFormat = signCurrencyFormat + '\\ ' + numberFormat + '\\-';
break;
case 12:
negativeFormat = signCurrencyFormat + '\\ \\-' + numberFormat;
break;
case 13:
negativeFormat = numberFormat + '\\-\\ ' + signCurrencyFormatEnd;
break;
case 14:
postfix = prefixs[3];
negativeFormat = '(' + signCurrencyFormat + numberFormat + '\\)';
break;
case 15:
postfix = prefixs[3];
negativeFormat = '\\(' + numberFormat + signCurrencyFormatEnd + '\\)';
break;
}
switch (cultureInfo.CurrencyPositivePattern) {
case 0:
positiveFormat = signCurrencyFormat + numberFormat;
break;
case 1:
positiveFormat = numberFormat + signCurrencyFormatEnd;
break;
case 2:
positiveFormat = signCurrencyFormat + '\\ ' + numberFormat;
break;
case 3:
positiveFormat = numberFormat + '\\ ' + signCurrencyFormatEnd;
break;
}
positiveFormat = positiveFormat + postfix;
return positiveFormat + ';' + red + negativeFormat;
}
function getCurrencyFormat(opt_cultureInfo, opt_fraction, opt_currency, opt_currencyLocale) {
var cultureInfo = opt_cultureInfo ? opt_cultureInfo : AscCommon.g_oDefaultCultureInfo;
var numberFormat;
var nullSignFormat;
if (opt_fraction) {
numberFormat = '#,##0.00';
nullSignFormat = '* "-"??';
} else {
numberFormat = '#,##0';
nullSignFormat = '* "-"';
}
var signCurrencyFormat;
var signCurrencyFormatEnd;
if (opt_currency) {
if (opt_currencyLocale) {
signCurrencyFormat = '[$' + cultureInfo.CurrencySymbol + '-' + cultureInfo.LCID.toString(16).toUpperCase() + ']';
} else {
signCurrencyFormat = '"' + cultureInfo.CurrencySymbol + '"';
}
signCurrencyFormatEnd = signCurrencyFormat;
} else {
signCurrencyFormatEnd = signCurrencyFormat = '';
for (var i = 0; i < cultureInfo.CurrencySymbol.length; ++i) {
signCurrencyFormatEnd += '_' + cultureInfo.CurrencySymbol[i];
}
}
var prefixs = ['_ ', '_-', '_(', '_)'];
var prefix = prefixs[0];
var postfix = prefixs[0];
var positiveNumberFormat = '* ' + numberFormat;
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 + '\\)' + signCurrencyFormatEnd + postfix;
break;
case 5:
prefix = postfix = prefixs[1];
negativeFormat = '\\-* ' + numberFormat + signCurrencyFormatEnd + postfix;
break;
case 6:
negativeFormat = prefix + '* ' + numberFormat + '\\-' + signCurrencyFormatEnd + postfix;
break;
case 7:
negativeFormat = prefix + '* ' + numberFormat + signCurrencyFormatEnd + '\\-';
break;
case 8:
prefix = postfix = prefixs[1];
negativeFormat = '\\-* ' + numberFormat + '\\ ' + signCurrencyFormatEnd + postfix;
break;
case 9:
prefix = postfix = prefixs[1];
negativeFormat = '\\-' + signCurrencyFormat + '\\ * ' + numberFormat + postfix;
break;
case 10:
negativeFormat = prefix + '* ' + numberFormat + '\\ ' + signCurrencyFormatEnd + '\\-';
break;
case 11:
negativeFormat = prefix + signCurrencyFormat + '\\ * ' + numberFormat + '\\-';
break;
case 12:
negativeFormat = prefix + signCurrencyFormat + '\\ * \\-' + numberFormat + postfix;
break;
case 13:
negativeFormat = prefix + '* ' + numberFormat + '\\-\\ ' + signCurrencyFormatEnd + 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 + '\\)\\ ' + signCurrencyFormatEnd + postfix;
break;
}
switch (cultureInfo.CurrencyPositivePattern) {
case 0:
positiveFormat = signCurrencyFormat + positiveNumberFormat;
nullFormat = signCurrencyFormat + nullSignFormat;
break;
case 1:
positiveFormat = positiveNumberFormat + signCurrencyFormatEnd;
nullFormat = nullSignFormat + signCurrencyFormatEnd;
break;
case 2:
positiveFormat = signCurrencyFormat + '\\ ' + positiveNumberFormat;
nullFormat = signCurrencyFormat + '\\ ' + nullSignFormat;
break;
case 3:
positiveFormat = positiveNumberFormat + '\\ ' + signCurrencyFormatEnd;
nullFormat = nullSignFormat + '\\ ' + signCurrencyFormatEnd;
break;
}
positiveFormat = prefix + positiveFormat + postfix;
nullFormat = prefix + nullFormat + postfix;
var textFormat = prefix + '@' + postfix;
return positiveFormat + ';' + negativeFormat + ';' + nullFormat + ';' + textFormat;
}
//----------------------------------------------------------export---------------------------------------------------- //----------------------------------------------------------export----------------------------------------------------
var prot; var prot;
window['Asc'] = window['Asc'] || {}; window['Asc'] = window['Asc'] || {};
...@@ -5905,6 +6206,8 @@ AutoFilterDateElem.prototype.convertDateGroupItemToRange = function(oDateGroupIt ...@@ -5905,6 +6206,8 @@ AutoFilterDateElem.prototype.convertDateGroupItemToRange = function(oDateGroupIt
window['AscCommonExcel'].DateGroupItem = DateGroupItem; window['AscCommonExcel'].DateGroupItem = DateGroupItem;
window['AscCommonExcel'].SortCondition = SortCondition; window['AscCommonExcel'].SortCondition = SortCondition;
window['AscCommonExcel'].AutoFilterDateElem = AutoFilterDateElem; window['AscCommonExcel'].AutoFilterDateElem = AutoFilterDateElem;
window['AscCommonExcel'].getCurrencyFormatSimple = getCurrencyFormatSimple;
window['AscCommonExcel'].getCurrencyFormat = getCurrencyFormat;
window["Asc"]["CustomFilters"] = window["Asc"].CustomFilters = CustomFilters; window["Asc"]["CustomFilters"] = window["Asc"].CustomFilters = CustomFilters;
prot = CustomFilters.prototype; prot = CustomFilters.prototype;
......
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