Commit d6ccb000 authored by Alexander.Trofimov's avatar Alexander.Trofimov

Добавил функцию formatToMathInfo

Добавил ограничение на число знаков в математической информации (http://bugzserver/show_bug.cgi?id=24172)
Статистическая информация выводится теперь в формате активной ячейки (http://bugzserver/show_bug.cgi?id=24114)

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@56148 954022d7-b5bf-4e40-9824-e11837661b57
parent a9e66c61
...@@ -90,27 +90,27 @@ function FormatObj(type, val) ...@@ -90,27 +90,27 @@ function FormatObj(type, val)
{ {
this.type = type; this.type = type;
this.val = val;//что здесь лежит определяется типом this.val = val;//что здесь лежит определяется типом
}; }
function FormatObjScientific(val, format, sign) function FormatObjScientific(val, format, sign)
{ {
this.type = numFormat_Scientific; this.type = numFormat_Scientific;
this.val = val;//E или e this.val = val;//E или e
this.format = format;//array формата this.format = format;//array формата
this.sign = sign; this.sign = sign;
}; }
function FormatObjDecimalFrac(aLeft, aRight) function FormatObjDecimalFrac(aLeft, aRight)
{ {
this.type = numFormat_DecimalFrac; this.type = numFormat_DecimalFrac;
this.aLeft = aLeft;//array формата левой части this.aLeft = aLeft;//array формата левой части
this.aRight = aRight;//array формата правой части this.aRight = aRight;//array формата правой части
this.bNumRight = false; this.bNumRight = false;
}; }
function FormatObjDateVal(type, nCount, bElapsed) function FormatObjDateVal(type, nCount, bElapsed)
{ {
this.type = type; this.type = type;
this.val = nCount;//Количество знаков подряд this.val = nCount;//Количество знаков подряд
this.bElapsed = bElapsed;//true == [hhh]; в квадратных скобках this.bElapsed = bElapsed;//true == [hhh]; в квадратных скобках
}; }
function FormatObjBracket(sData) function FormatObjBracket(sData)
{ {
this.type = numFormat_Bracket; this.type = numFormat_Bracket;
...@@ -214,7 +214,7 @@ function FormatObjBracket(sData) ...@@ -214,7 +214,7 @@ function FormatObjBracket(sData)
} }
}; };
this.parse(sData); this.parse(sData);
}; }
function NumFormat(bAddMinusIfNes) function NumFormat(bAddMinusIfNes)
{ {
//Stream чтения формата //Stream чтения формата
...@@ -249,7 +249,7 @@ function NumFormat(bAddMinusIfNes) ...@@ -249,7 +249,7 @@ function NumFormat(bAddMinusIfNes)
this.bGeneralChart = false;//если в формате только один текст(например в chart "Основной") this.bGeneralChart = false;//если в формате только один текст(например в chart "Основной")
this.bGeneral = false;//Форматирование не задано this.bGeneral = false;//Форматирование не задано
this.bAddMinusIfNes = bAddMinusIfNes;//когда не задано форматирование для отрицательных чисел иногда надо вставлять минус this.bAddMinusIfNes = bAddMinusIfNes;//когда не задано форматирование для отрицательных чисел иногда надо вставлять минус
}; }
NumFormat.prototype = NumFormat.prototype =
{ {
_getChar : function() _getChar : function()
...@@ -1938,7 +1938,7 @@ NumFormat.prototype = ...@@ -1938,7 +1938,7 @@ NumFormat.prototype =
function NumFormatCache() function NumFormatCache()
{ {
this.oNumFormats = {}; this.oNumFormats = {};
}; }
NumFormatCache.prototype = NumFormatCache.prototype =
{ {
get : function(format) get : function(format)
...@@ -2085,7 +2085,7 @@ function CellFormat(format) ...@@ -2085,7 +2085,7 @@ function CellFormat(format)
} }
} }
this.formatCache = {}; this.formatCache = {};
}; }
CellFormat.prototype = CellFormat.prototype =
{ {
isTextFormat : function() isTextFormat : function()
...@@ -2289,6 +2289,25 @@ CellFormat.prototype = ...@@ -2289,6 +2289,25 @@ CellFormat.prototype =
} }
} }
return bRes; return bRes;
},
formatToMathInfo : function(number, nValType, dDigitsCount)
{
var result = "";
var arrFormat = this.format(number, nValType, dDigitsCount, null, false);
for (var i = 0, item; i < arrFormat.length; ++i) {
item = arrFormat[i];
if (item.format) {
if (item.format.repeat)
continue;
if (item.format.skip) {
result += " ";
continue;
}
}
if (item.text)
result += item.text;
}
return result;
}, },
getType: function() getType: function()
{ {
...@@ -2502,7 +2521,7 @@ function DecodeGeneralFormat_Raw(val, nValType, dDigitsCount) ...@@ -2502,7 +2521,7 @@ function DecodeGeneralFormat_Raw(val, nValType, dDigitsCount)
function GeneralEditFormatCache() function GeneralEditFormatCache()
{ {
this.oCache = {}; this.oCache = {};
}; }
GeneralEditFormatCache.prototype = GeneralEditFormatCache.prototype =
{ {
format: function (number, cultureInfo) format: function (number, cultureInfo)
...@@ -2621,7 +2640,7 @@ function FormatParser() ...@@ -2621,7 +2640,7 @@ function FormatParser()
this.days = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]; this.days = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
this.daysLeap = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]; this.daysLeap = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
this.bFormatMonthFirst = true; this.bFormatMonthFirst = true;
}; }
FormatParser.prototype = FormatParser.prototype =
{ {
isLocaleNumber: function (val, cultureInfo) { isLocaleNumber: function (val, cultureInfo) {
...@@ -3452,7 +3471,7 @@ FormatParser.prototype = ...@@ -3452,7 +3471,7 @@ FormatParser.prototype =
{ {
return (0 == (year % 4)) && (0 != (year % 100) || 0 == (year % 400)) return (0 == (year % 4)) && (0 != (year % 100) || 0 == (year % 400))
} }
} };
var g_oFormatParser = new FormatParser(); var g_oFormatParser = new FormatParser();
function escapeRegExp(string) { function escapeRegExp(string) {
return string.replace(/([.*+?^=!:${}()|\[\]\/\\])/g, "\\$1"); return string.replace(/([.*+?^=!:${}()|\[\]\/\\])/g, "\\$1");
...@@ -3810,5 +3829,5 @@ var g_aCultureInfos = { ...@@ -3810,5 +3829,5 @@ var g_aCultureInfos = {
31837: { LCID: 31837, Name: "iu-Latn", CurrencyNegativePattern: 0, CurrencySymbol: "$", NumberDecimalSeparator: ".", NumberGroupSeparator: ",", NumberGroupSizes: [3, 0], DayNames: ["Naattiinguja", "Naggajjau", "Aippiq", "Pingatsiq", "Sitammiq", "Tallirmiq", "Sivataarvik"], AbbreviatedDayNames: ["Nat", "Nag", "Aip", "Pi", "Sit", "Tal", "Siv"], MonthNames: ["Jaannuari", "Viivvuari", "Maatsi", "Iipuri", "Mai", "Juuni", "Julai", "Aaggiisi", "Sitipiri", "Utupiri", "Nuvipiri", "Tisipiri", ""], AbbreviatedMonthNames: ["Jan", "Viv", "Mas", "Ipu", "Mai", "Jun", "Jul", "Agi", "Sii", "Uut", "Nuv", "Tis", ""], MonthGenitiveNames: [], AbbreviatedMonthGenitiveNames: [], AMDesignator: "AM", PMDesignator: "PM", DateSeparator: "/", TimeSeparator: ":", ShortDatePattern: "012" }, 31837: { LCID: 31837, Name: "iu-Latn", CurrencyNegativePattern: 0, CurrencySymbol: "$", NumberDecimalSeparator: ".", NumberGroupSeparator: ",", NumberGroupSizes: [3, 0], DayNames: ["Naattiinguja", "Naggajjau", "Aippiq", "Pingatsiq", "Sitammiq", "Tallirmiq", "Sivataarvik"], AbbreviatedDayNames: ["Nat", "Nag", "Aip", "Pi", "Sit", "Tal", "Siv"], MonthNames: ["Jaannuari", "Viivvuari", "Maatsi", "Iipuri", "Mai", "Juuni", "Julai", "Aaggiisi", "Sitipiri", "Utupiri", "Nuvipiri", "Tisipiri", ""], AbbreviatedMonthNames: ["Jan", "Viv", "Mas", "Ipu", "Mai", "Jun", "Jul", "Agi", "Sii", "Uut", "Nuv", "Tis", ""], MonthGenitiveNames: [], AbbreviatedMonthGenitiveNames: [], AMDesignator: "AM", PMDesignator: "PM", DateSeparator: "/", TimeSeparator: ":", ShortDatePattern: "012" },
31839: { LCID: 31839, Name: "tzm-Latn", CurrencyNegativePattern: 8, CurrencySymbol: "DZD", NumberDecimalSeparator: ",", NumberGroupSeparator: ".", NumberGroupSizes: [3], DayNames: ["Acer", "Arime", "Aram", "Ahad", "Amhadh", "Sem", "Sedh"], AbbreviatedDayNames: ["Ace", "Ari", "Ara", "Aha", "Amh", "Sem", "Sed"], MonthNames: ["Yenayer", "Furar", "Maghres", "Yebrir", "Mayu", "Yunyu", "Yulyu", "Ghuct", "Cutenber", "Ktuber", "Wambir", "Dujanbir", ""], AbbreviatedMonthNames: ["Yen", "Fur", "Mag", "Yeb", "May", "Yun", "Yul", "Ghu", "Cut", "Ktu", "Wam", "Duj", ""], MonthGenitiveNames: [], AbbreviatedMonthGenitiveNames: [], AMDesignator: "", PMDesignator: "", DateSeparator: "-", TimeSeparator: ":", ShortDatePattern: "012" }, 31839: { LCID: 31839, Name: "tzm-Latn", CurrencyNegativePattern: 8, CurrencySymbol: "DZD", NumberDecimalSeparator: ",", NumberGroupSeparator: ".", NumberGroupSizes: [3], DayNames: ["Acer", "Arime", "Aram", "Ahad", "Amhadh", "Sem", "Sedh"], AbbreviatedDayNames: ["Ace", "Ari", "Ara", "Aha", "Amh", "Sem", "Sed"], MonthNames: ["Yenayer", "Furar", "Maghres", "Yebrir", "Mayu", "Yunyu", "Yulyu", "Ghuct", "Cutenber", "Ktuber", "Wambir", "Dujanbir", ""], AbbreviatedMonthNames: ["Yen", "Fur", "Mag", "Yeb", "May", "Yun", "Yul", "Ghu", "Cut", "Ktu", "Wam", "Duj", ""], MonthGenitiveNames: [], AbbreviatedMonthGenitiveNames: [], AMDesignator: "", PMDesignator: "", DateSeparator: "-", TimeSeparator: ":", ShortDatePattern: "012" },
31848: { LCID: 31848, Name: "ha-Latn", CurrencyNegativePattern: 2, CurrencySymbol: "N", NumberDecimalSeparator: ".", NumberGroupSeparator: ",", NumberGroupSizes: [3], DayNames: ["Lahadi", "Litinin", "Talata", "Laraba", "Alhamis", "Juma'a", "Asabar"], AbbreviatedDayNames: ["Lah", "Lit", "Tal", "Lar", "Alh", "Jum", "Asa"], MonthNames: ["Januwaru", "Febreru", "Maris", "Afrilu", "Mayu", "Yuni", "Yuli", "Agusta", "Satumba", "Oktocba", "Nuwamba", "Disamba", ""], AbbreviatedMonthNames: ["Jan", "Feb", "Mar", "Afr", "May", "Yun", "Yul", "Agu", "Sat", "Okt", "Nuw", "Dis", ""], MonthGenitiveNames: [], AbbreviatedMonthGenitiveNames: [], AMDesignator: "Safe", PMDesignator: "Yamma", DateSeparator: "/", TimeSeparator: ":", ShortDatePattern: "012" } 31848: { LCID: 31848, Name: "ha-Latn", CurrencyNegativePattern: 2, CurrencySymbol: "N", NumberDecimalSeparator: ".", NumberGroupSeparator: ",", NumberGroupSizes: [3], DayNames: ["Lahadi", "Litinin", "Talata", "Laraba", "Alhamis", "Juma'a", "Asabar"], AbbreviatedDayNames: ["Lah", "Lit", "Tal", "Lar", "Alh", "Jum", "Asa"], MonthNames: ["Januwaru", "Febreru", "Maris", "Afrilu", "Mayu", "Yuni", "Yuli", "Agusta", "Satumba", "Oktocba", "Nuwamba", "Disamba", ""], AbbreviatedMonthNames: ["Jan", "Feb", "Mar", "Afr", "May", "Yun", "Yul", "Agu", "Sat", "Okt", "Nuw", "Dis", ""], MonthGenitiveNames: [], AbbreviatedMonthGenitiveNames: [], AMDesignator: "Safe", PMDesignator: "Yamma", DateSeparator: "/", TimeSeparator: ":", ShortDatePattern: "012" }
} };
var g_oDefaultCultureInfo = g_aCultureInfos[1033];//en-US//1033//fr-FR//1036//basq//1069//ru-Ru//1049//hindi//1081 var g_oDefaultCultureInfo = g_aCultureInfos[1033];//en-US//1033//fr-FR//1036//basq//1069//ru-Ru//1049//hindi//1081
\ No newline at end of file
...@@ -227,6 +227,9 @@ ...@@ -227,6 +227,9 @@
// Цвет закрепленных областей // Цвет закрепленных областей
this.frozenColor = new CColor(105, 119, 62, 1); this.frozenColor = new CColor(105, 119, 62, 1);
// Число знаков для математической информации
this.mathMaxDigCount = 9;
return this; return this;
} }
...@@ -6154,8 +6157,17 @@ ...@@ -6154,8 +6157,17 @@
} }
}); });
if (0 !== oSelectionMathInfo.countNumbers) { if (0 !== oSelectionMathInfo.countNumbers) {
oSelectionMathInfo.sum = sum; // Мы должны отдавать в формате активной ячейки
oSelectionMathInfo.average = sum / oSelectionMathInfo.countNumbers; var numFormat = range.getNumFormat();
oSelectionMathInfo.sum = numFormat.formatToMathInfo(sum, CellValueType.Number, this.mathMaxDigCount);
oSelectionMathInfo.average = numFormat.formatToMathInfo(sum / oSelectionMathInfo.countNumbers,
CellValueType.Number, this.mathMaxDigCount);
oSelectionMathInfo.min = numFormat.formatToMathInfo(oSelectionMathInfo.min, CellValueType.Number,
this.mathMaxDigCount);
oSelectionMathInfo.max = numFormat.formatToMathInfo(oSelectionMathInfo.max, CellValueType.Number,
this.mathMaxDigCount);
} }
return oSelectionMathInfo; return oSelectionMathInfo;
}; };
......
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