diff --git a/common/editorscommon.js b/common/editorscommon.js index 807604f8a8..96205d5d4b 100644 --- a/common/editorscommon.js +++ b/common/editorscommon.js @@ -198,6 +198,10 @@ return; } var result = []; + if (number === 0) + { + return [0]; + } while (number > 0) { var remainder = number % base; if (remainder === 0) { @@ -4441,6 +4445,7 @@ { case "bg-BG": alphaBet = { + 0: ['нулевят'], 1: { 'един': 'първият', @@ -4469,6 +4474,7 @@ break; case "cs-CZ": alphaBet = { + 'nula': 'nultý', 'jedna': 'první', 'dva': 'druhý', 'tři': 'třetí', @@ -4511,6 +4517,7 @@ break; case "de-DE": alphaBet = { + 'null': 'nullte', 'eins': 'erste', 'zwei': 'zweite', 'drei': 'dritte', @@ -4534,6 +4541,7 @@ break; case "el-GR": alphaBet = { + 0: ['μηδενικό'], 1: [ 'πρώτο', 'δεύτερο', @@ -4602,6 +4610,7 @@ break; case "es-ES": alphaBet = { + 'cero': 'cero', 'uno': 'primero', 'dos': 'segundo', 'tres': 'tercero', @@ -4649,6 +4658,7 @@ break; case "it-IT": alphaBet = { + 'zero': 'zero', 'uno': 'primo', 'due': 'secondo', 'tre': 'terzo', @@ -4663,6 +4673,7 @@ break; case "lv-LV": alphaBet = { + 'nulle': 'nultais', 'viens': 'pirmais', 'divi': 'otrais', 'trīs': 'trešais', @@ -4703,6 +4714,7 @@ }, 'numbers': { + 'zero': 'zerowy', 'jeden': 'pierwszy', 'dwa': 'drugi', 'trzy': 'trzeci', @@ -4791,6 +4803,7 @@ case "pt-BR": case "pt-PT": alphaBet = { + 'zero': 'zero', 'um': 'primeiro', 'dois': 'segundo', 'três': 'terceiro', @@ -4835,6 +4848,7 @@ alphaBet = { 'numbers': { + 'ноль': 'нулевой', 'один': 'первый', 'два': 'второй', 'три': 'третий', @@ -4923,6 +4937,7 @@ break; case "sk-SK": alphaBet = { + 'nula': 'nultý', 'jeden': 'prvý', 'dva': 'druhý', 'tri': 'tretí', @@ -4987,6 +5002,7 @@ break; case "sv-SE": alphaBet = { + 'noll': 'nollte', 'ett': 'första', 'två': 'andra', 'tre': 'tredje', @@ -5005,6 +5021,7 @@ alphaBet = { 'numbers': { + "нуль": "нульовий", "один": "перший", "два": "другий", "три": "третій", @@ -5125,6 +5142,7 @@ { case"bg-BG": alphaBet = { + 0: ['нула'], 1: [ 'един', 'два', @@ -5180,6 +5198,7 @@ break; case"cs-CZ": alphaBet = { + 0: ['nula'], 1: [ 'jedna', 'dva', @@ -5235,6 +5254,7 @@ break; case"de-DE": alphaBet = { + 0: ['null'], 1: [ 'eins', 'zwei', @@ -5270,6 +5290,7 @@ break; case"el-GR": alphaBet = { + 0: ['μηδέν'], 1: [ 'ένα', 'δύο', @@ -5325,6 +5346,7 @@ break; case"es-ES": alphaBet = { + 0: ['cero'], 1: [ 'uno', 'dos', @@ -5377,6 +5399,7 @@ break; case"fr-FR": alphaBet = { + 0: ['zéro'], 1: [ 'un', 'deux', @@ -5412,6 +5435,7 @@ break; case"it-IT": alphaBet = { + 0: ['zero'], 1: [ 'uno', 'due', @@ -5447,6 +5471,7 @@ break; case"lv-LV": alphaBet = { + 0: ['nulle'], 1: [ 'viens', 'divi', @@ -5502,6 +5527,7 @@ break; case"nl-NL": alphaBet = { + 0: ['nul'], 1: [ 'één', 'twee', @@ -5537,6 +5563,7 @@ break; case"pl-PL": alphaBet = { + 0: ['zero'], 1: [ 'jeden', 'dwa', @@ -5593,6 +5620,7 @@ case"pt-BR": case"pt-PT": alphaBet = { + 0: ['zero'], 1: [ 'um', 'dois', @@ -5639,6 +5667,7 @@ break; case"ru-RU": alphaBet = { + 0: ['ноль'], 1: [ 'один', 'два', @@ -5694,6 +5723,7 @@ break; case"sk-SK": alphaBet = { + 0: ['nula'], 1: [ 'jeden', 'dva', @@ -5729,6 +5759,7 @@ break; case"sv-SE": alphaBet = { + 0: ['noll'], 1: [ 'ett', 'två', @@ -5764,6 +5795,7 @@ break; case"uk-UA": alphaBet = { + 0: ['нуль'], 1: [ "один", "два", @@ -5826,6 +5858,7 @@ case 'ko-KR': default: alphaBet = { + 0: ['zero'], 1: [ 'one', 'two', @@ -5872,6 +5905,11 @@ return array.join(' '); } + if (nValue === 0) + { + return {arrAnswer: [alphaBet[0][0]], getConcatStringByRule: getConcatStringByRule}; + } + switch (lang) { case 'ru-RU': @@ -6875,6 +6913,10 @@ var addFirstDegreeSymbol = true; if (nFormat === Asc.c_oAscNumberingFormat.KoreanCounting) { + if (nValue === 0) + { + return String.fromCharCode(0xC601); + } addFirstDegreeSymbol = false; var digits = [ String.fromCharCode(0xC77C), @@ -6895,6 +6937,10 @@ ]; } else if (nFormat === Asc.c_oAscNumberingFormat.JapaneseLegal) { + if (nValue === 0) + { + return String.fromCharCode(0x3007); + } digits = [ String.fromCharCode(0x58F1), String.fromCharCode(0x5F10), @@ -6914,6 +6960,10 @@ ]; } else if (nFormat === Asc.c_oAscNumberingFormat.JapaneseCounting) { + if (nValue === 0) + { + return String.fromCharCode(0x3007); + } addFirstDegreeSymbol = false; digits = [ String.fromCharCode(0x4E00), @@ -7065,6 +7115,10 @@ function IntToAiueo(nValue) { + if (nValue === 0) + { + return '0'; + } var sResult = ''; var count = 1, numberOfLetters = 46; nValue = repeatNumberingLvl(nValue, 46); @@ -7092,34 +7146,47 @@ ++count; nValue -= numberOfLetters; } - if (nValue >= 1 && nValue <= 5) + if (nValue === 0) + { + letter = 0x0030; + } + else if (nValue >= 1 && nValue <= 5) { letter = 0x30A2 + (nValue - 1) * 2; - } else if (nValue >= 6 && nValue <= 17) + } + else if (nValue >= 6 && nValue <= 17) { letter = 0x30AB + (nValue - 6) * 2; - } else if (nValue >= 18 && nValue <= 21) + } + else if (nValue >= 18 && nValue <= 21) { letter = 0x30C4 + (nValue - 18) * 2; - } else if (nValue >= 22 && nValue <= 26) + } + else if (nValue >= 22 && nValue <= 26) { letter = 0x30CB + nValue - 22; - } else if (nValue >= 27 && nValue <= 31) + } + else if (nValue >= 27 && nValue <= 31) { letter = 0x30D2 + (nValue - 27) * 3; - } else if (nValue >= 32 && nValue <= 35) + } + else if (nValue >= 32 && nValue <= 35) { letter = 0x30DF + nValue - 32; - } else if (nValue >= 36 && nValue <= 38) + } + else if (nValue >= 36 && nValue <= 38) { letter = 0x30E4 + nValue - 36; - } else if (nValue >= 39 && nValue <= 43) + } + else if (nValue >= 39 && nValue <= 43) { letter = 0x30E9 + nValue - 39; - } else if (nValue === 44) + } + else if (nValue === 44) { letter = 0x30EF + nValue - 44; - } else if (nValue >= 45 && nValue <= 46) + } + else if (nValue >= 45 && nValue <= 46) { letter = 0x30F2 + nValue - 45; } @@ -7165,6 +7232,10 @@ charArr = [0x002A, 0x2020, 0x2021, 0x00A7] } else if(nFormat === Asc.c_oAscNumberingFormat.Chosung) { + if (nValue === 0) + { + return '0'; + } nValue = repeatNumberingLvl(nValue, 14); charArr = [ 0x3131, 0x3134, 0x3137, 0x3139, @@ -7174,6 +7245,10 @@ ] } else if (nFormat === Asc.c_oAscNumberingFormat.Ganada) { + if (nValue === 0) + { + return '0'; + } nValue = repeatNumberingLvl(nValue, 14); charArr = [ 0xAC00, 0xB098, 0xB2E4, 0xB77C, @@ -7333,12 +7408,16 @@ 0x7533, 0x9149, 0x620C, 0x4EA5 ]; - sResult += nValue <= digits.length ? String.fromCharCode(digits[nValue - 1]) : nValue; + sResult += (nValue >= 1 && nValue <= digits.length) ? String.fromCharCode(digits[nValue - 1]) : nValue; return sResult; } function IntToIdeographZodiacTraditional(nValue) { + if (nValue === 0) + { + return '0'; + } var sResult = ''; var digits = [ 0x7532, 0x5B50, 0x4E59, 0x4E11, 0x4E19, 0x5BC5, @@ -7374,6 +7453,10 @@ function IntToIroha(nValue, nFormat) { + if (nValue === 0) + { + return '0'; + } var sResult = ''; var digits = []; if (nFormat === Asc.c_oAscNumberingFormat.Iroha) @@ -7485,7 +7568,11 @@ 1000 : String.fromCharCode(0x5343), 10000 : String.fromCharCode(0x4E07) }; - if (nValue < 1000000) + if (nValue === 0) + { + sResult += arrChinese[0]; + } + else if (nValue < 1000000) { var nRemValue = nValue; @@ -7610,7 +7697,11 @@ 1000 : String.fromCharCode(0x4EDF), 10000 : String.fromCharCode(0x842C) }; - if (nValue < 1000000) + if (nValue === 0) + { + sResult += arrChinese[0]; + } + else if (nValue < 1000000) { var nRemValue = nValue; @@ -7790,7 +7881,11 @@ '拾' ]; - if (nValue < 10000) + if (nValue === 0) + { + sResult = String.fromCharCode(0x96F6); + } + else if (nValue < 10000) { sResult = IdeographLegalTraditionalSplitting(digits, degrees, nValue).join(''); } else { @@ -7879,7 +7974,7 @@ String.fromCharCode(0x4E5D) ]; var conv = decimalNumberConversion(nValue, digits.length); - if(nValue >= digits.length * 10) + if(nValue >= digits.length * 10 || nValue === 0) { digits[0] = String.fromCharCode(0x25CB); sResult = conv.map(function (num) @@ -8030,7 +8125,7 @@ if (nValue === 1) { sResult += 'er'; - } else { + } else if (nValue !== 0) { sResult += 'e'; } break; @@ -8202,8 +8297,11 @@ '百', '十' ]; - - if (nValue < 100000) + if (nValue === 0) + { + return String.fromCharCode(0x96F6); + } + else if (nValue < 100000) { sResult = taiwaneseCountingSplitting(digits, degrees, nValue).join(''); } else if (nValue >= 100000 && nValue < 1000000) @@ -8216,7 +8314,11 @@ function IntToKoreanLegal(nValue, nFormat) { var sResult = ''; - if (nValue < 100) + if (nValue === 0) + { + return '0'; + } + else if (nValue < 100) { var answer = []; var digits = { @@ -8261,8 +8363,15 @@ function IntToOrdinalText(nValue, nLang) { var textLang = languages[nLang]; - var ordinalText = getCardinalTextFromValue(textLang, nValue); var alphaBet = getAlphaBetForOrdinalText(textLang); + if (nValue === 0) + { + if (alphaBet[0] && alphaBet[0][0]) + { + return alphaBet[0][0].sentenceCase(); + } + } + var ordinalText = getCardinalTextFromValue(textLang, nValue); switch (textLang) { case 'de-DE': @@ -8406,7 +8515,7 @@ { switchingValue[switchingValue.length - 1] = lastWord.slice(0, lastWord.length - 1); } - if (switchingValue[switchingValue.length - 1] !== 'premier') + if (lastWord !== 'premier' && lastWord !== 'zéro') { switchingValue[switchingValue.length - 1] += 'ième'; } @@ -8742,6 +8851,10 @@ function IntToHindiCounting(nValue) { + if (nValue === 0) + { + return "शून्य"; + } var alphaBet = [ "एक","दो","तीन","चार","पांच","छह","सात","आठ","नौ","दस","ग्यारह", "बारह","तेरह","चौदह","पंद्रह","सोलह","सत्रह","अठारह","उन्नीस","बीस", @@ -8815,7 +8928,7 @@ function splitThaiCounting(num, digits) { - if (num >= 1000000000) + if (num >= 1000000000 || num === 0) { return ['ศูนย์']; } @@ -8945,6 +9058,10 @@ function IntToVietnameseCounting(nValue) { + if (nValue === 0) + { + return 'không'; + } var digits = ['một', 'hai', 'ba', 'bốn', 'năm', 'sáu', 'bảy', 'tám', 'chín', 'mười']; return vietnameseCounting(nValue, digits).join(' '); @@ -8974,6 +9091,67 @@ return sResult.join(''); } + + function IsLessMinimumNumberingFormat(nFormat, nValue) + { + switch (nFormat) + { + case Asc.c_oAscNumberingFormat.Decimal: + case Asc.c_oAscNumberingFormat.CustomDecimalFourZero: + case Asc.c_oAscNumberingFormat.CustomDecimalThreeZero: + case Asc.c_oAscNumberingFormat.CustomDecimalTwoZero: + case Asc.c_oAscNumberingFormat.DecimalZero: + case Asc.c_oAscNumberingFormat.DecimalEnclosedCircleChinese: + case Asc.c_oAscNumberingFormat.DecimalEnclosedCircle: + case Asc.c_oAscNumberingFormat.Aiueo: + case Asc.c_oAscNumberingFormat.AiueoFullWidth: + case Asc.c_oAscNumberingFormat.Chosung: + case Asc.c_oAscNumberingFormat.Ganada: + case Asc.c_oAscNumberingFormat.DecimalEnclosedFullstop: + case Asc.c_oAscNumberingFormat.DecimalEnclosedParen: + case Asc.c_oAscNumberingFormat.DecimalFullWidth: + case Asc.c_oAscNumberingFormat.DecimalFullWidth2: + case Asc.c_oAscNumberingFormat.DecimalHalfWidth: + case Asc.c_oAscNumberingFormat.Hex: + case Asc.c_oAscNumberingFormat.HindiNumbers: + case Asc.c_oAscNumberingFormat.IdeographDigital: + case Asc.c_oAscNumberingFormat.JapaneseDigitalTenThousand: + case Asc.c_oAscNumberingFormat.IdeographEnclosedCircle: + case Asc.c_oAscNumberingFormat.IdeographTraditional: + case Asc.c_oAscNumberingFormat.IdeographZodiac: + case Asc.c_oAscNumberingFormat.IdeographZodiacTraditional: + case Asc.c_oAscNumberingFormat.Iroha: + case Asc.c_oAscNumberingFormat.IrohaFullWidth: + case Asc.c_oAscNumberingFormat.ChineseCounting: + case Asc.c_oAscNumberingFormat.ChineseCountingThousand: + case Asc.c_oAscNumberingFormat.ChineseLegalSimplified: + case Asc.c_oAscNumberingFormat.IdeographLegalTraditional: + case Asc.c_oAscNumberingFormat.JapaneseLegal: + case Asc.c_oAscNumberingFormat.KoreanCounting: + case Asc.c_oAscNumberingFormat.JapaneseCounting: + case Asc.c_oAscNumberingFormat.KoreanDigital: + case Asc.c_oAscNumberingFormat.ThaiNumbers: + case Asc.c_oAscNumberingFormat.KoreanDigital2: + case Asc.c_oAscNumberingFormat.TaiwaneseDigital: + case Asc.c_oAscNumberingFormat.None: + case Asc.c_oAscNumberingFormat.NumberInDash: + case Asc.c_oAscNumberingFormat.TaiwaneseCounting: + case Asc.c_oAscNumberingFormat.CardinalText: + case Asc.c_oAscNumberingFormat.Custom: + case Asc.c_oAscNumberingFormat.Ordinal: + case Asc.c_oAscNumberingFormat.TaiwaneseCountingThousand: + case Asc.c_oAscNumberingFormat.KoreanLegal: + case Asc.c_oAscNumberingFormat.OrdinalText: + case Asc.c_oAscNumberingFormat.HindiCounting: + case Asc.c_oAscNumberingFormat.ThaiCounting: + case Asc.c_oAscNumberingFormat.DollarText: + case Asc.c_oAscNumberingFormat.BahtText: + case Asc.c_oAscNumberingFormat.VietnameseCounting: + return nValue < 0; + default: + return nValue < 1; + } + } /** * Переводим числовое значение в строку с заданным форматом нумерации @@ -8997,6 +9175,10 @@ } } var sResult = ""; + if (IsLessMinimumNumberingFormat(nFormat, nValue)) + { + return sResult; + } switch (nFormat) { @@ -9049,7 +9231,7 @@ case Asc.c_oAscNumberingFormat.DecimalEnclosedCircleChinese: { - if (nValue <= 10) + if (nValue >= 1 && nValue <= 10) { sResult = String.fromCharCode(0x2460 + nValue - 1); } @@ -9062,7 +9244,7 @@ case Asc.c_oAscNumberingFormat.DecimalEnclosedCircle: { - if (nValue <= 20) + if (nValue >= 1 && nValue <= 20) { sResult = String.fromCharCode(0x2460 + nValue - 1); } @@ -9133,11 +9315,11 @@ case Asc.c_oAscNumberingFormat.DecimalFullWidth2: case Asc.c_oAscNumberingFormat.DecimalHalfWidth: { - var zeroInHex = nFormat === Asc.c_oAscNumberingFormat.DecimalFullWidth ? 0xFF10 : 0x0030; + var zero = (nFormat === Asc.c_oAscNumberingFormat.DecimalFullWidth || nFormat === Asc.c_oAscNumberingFormat.DecimalFullWidth2) ? 0xFF10 : 0x0030; var strValue = String(nValue); for(var i = 0; i < strValue.length; i++) { - sResult += String.fromCharCode(zeroInHex + parseInt(strValue[i])); + sResult += String.fromCharCode(zero + parseInt(strValue[i])); } break; } @@ -9150,7 +9332,11 @@ case Asc.c_oAscNumberingFormat.Hex: { - if (nValue <= 0xFFFF) + if (nValue === 0) + { + sResult = '0'; + } + else if (nValue <= 0xFFFF) { sResult = (nValue+0x10000).toString(16).substr(-4).toUpperCase(); sResult = sResult.replace(/^0+/, ''); @@ -9180,7 +9366,7 @@ case Asc.c_oAscNumberingFormat.IdeographEnclosedCircle: { - sResult += nValue <= 10 ? String.fromCharCode(0x3220 + nValue - 1) : nValue; + sResult += (nValue >= 1 && nValue <= 10) ? String.fromCharCode(0x3220 + nValue - 1) : nValue; break; } diff --git a/common/wordcopypaste.js b/common/wordcopypaste.js index 0a588d61ac..4c0338e358 100644 --- a/common/wordcopypaste.js +++ b/common/wordcopypaste.js @@ -7937,6 +7937,7 @@ PasteProcessor.prototype = }; res = this.oLogicDocument.GetNumbering().CreateNum(); + res.CreateDefault(); for (var i = 1; i < aNumbering.length; i++) { var curNumbering = aNumbering[i]; if (!curNumbering) { diff --git a/word/Editor/Numbering/AbstractNum.js b/word/Editor/Numbering/AbstractNum.js index 42e8b76d6e..4d4b58e0fc 100644 --- a/word/Editor/Numbering/AbstractNum.js +++ b/word/Editor/Numbering/AbstractNum.js @@ -59,7 +59,6 @@ function CAbstractNum() for (var nLvl = 0; nLvl < 9; ++nLvl) { this.Lvl[nLvl] = new CNumberingLvl(); - this.Lvl[nLvl].InitDefault(nLvl); } this.MultiLvlType = Asc.c_oAbstractNumMultiLvlTypes.MultiLevel; diff --git a/word/Editor/Numbering/NumberingLvl.js b/word/Editor/Numbering/NumberingLvl.js index 82a8c4b1ee..265e4de7e6 100644 --- a/word/Editor/Numbering/NumberingLvl.js +++ b/word/Editor/Numbering/NumberingLvl.js @@ -37,7 +37,7 @@ function CNumberingLvl() this.Jc = AscCommon.align_Left; this.Format = Asc.c_oAscNumberingFormat.Bullet; this.PStyle = undefined; - this.Start = 1; + this.Start = 0; this.Restart = -1; // -1 - делаем нумерацию сначала всегда, 0 - никогда не начинаем нумерацию заново this.Suff = Asc.c_oAscNumberingSuff.Tab; this.TextPr = new CTextPr(); diff --git a/word/Editor/Serialize2.js b/word/Editor/Serialize2.js index b9158ba484..abe1c85155 100644 --- a/word/Editor/Serialize2.js +++ b/word/Editor/Serialize2.js @@ -10991,11 +10991,7 @@ function Binary_NumberingTableReader(doc, oReadResult, stream) { if(nLevelNum < oNewNum.Lvl.length) { - var oOldLvl = oNewNum.Lvl[nLevelNum]; - var oNewLvl = oOldLvl.Copy(); - //сбрасываем свойства - oNewLvl.ParaPr = new CParaPr(); - oNewLvl.TextPr = new CTextPr(); + var oNewLvl = new CNumberingLvl(); var tmp = {nLevelNum: nLevelNum}; res = this.bcr.Read2(length, function(t, l){ return oThis.ReadLevel(t, l, oNewLvl, tmp);