3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
7 * \author Lars Gullik Bjønnes
9 * Full author contact details are available in file CREDITS.
14 #include "support/counter_reps.h"
16 #include "support/convert.h"
17 #include "support/docstring.h"
18 #include "support/lstrings.h"
24 char loweralphaCounter(int const n)
32 char alphaCounter(int const n)
40 char hebrewCounter(int const n)
42 static const char hebrew[22] = {
43 '\xe0', '\xe1', '\xe2', '\xe3', '\xe4', '\xe5', '\xe6', '\xe7', '\xe8',
44 '\xe9', '\xeb', '\xec', '\xee', '\xf0', '\xf1', '\xf2', '\xf4', '\xf6',
45 '\xf7', '\xf8', '\xf9', '\xfa'
54 // On the special cases, see http://mathworld.wolfram.com/RomanNumerals.html
55 // and for a list of roman numerals up to and including 3999, see
56 // http://www.research.att.com/~njas/sequences/a006968.txt. (Thanks to Joost
58 docstring const romanCounter(int const n)
60 static char const * const ones[9] = {
61 "I", "II", "III", "IV", "V",
62 "VI", "VII", "VIII", "IX"
65 static char const * const tens[9] = {
66 "X", "XX", "XXX", "XL", "L",
67 "LX", "LXX", "LXXX", "XC"
70 static char const * const hunds[9] = {
71 "C", "CC", "CCC", "CD", "D",
72 "DC", "DCC", "DCCC", "CM"
75 if (n >= 1000 || n < 1)
76 return from_ascii("??");
90 int hundreds = val / 100;
91 roman = hunds[hundreds - 1];
102 int tensnum = val / 10;
103 roman = roman + tens[tensnum - 1];
108 roman = roman + ones[val -1];
110 return from_ascii(roman);
114 docstring const lowerromanCounter(int const n)
116 return support::lowercase(romanCounter(n));
120 docstring const fnsymbolCounter(int const n)
123 case 1: return docstring(1, 0x002a); //*
124 case 2: return docstring(1, 0x2020); // dagger
125 case 3: return docstring(1, 0x2021); // double dagger
126 case 4: return docstring(1, 0x00A7); // section sign
127 case 5: return docstring(1, 0x00B6); // pilcrow sign
128 case 6: return docstring(1, 0x2016); // vertical bar
129 case 7: return docstring(2, 0x002a); // two *
130 case 8: return docstring(2, 0x2020); // two daggers
131 case 9: return docstring(2, 0x2021); // two double daggers
133 return from_ascii("?");
138 docstring const superarabicCounter(int const n)
140 docstring superarabic = convert<docstring>(n);
141 static char_type map[] = {0x2070, 0x00b9, 0x00b2, 0x00b3, 0x2074,
142 0x2075, 0x2076, 0x2077, 0x2078, 0x2079 };
143 for (char_type & c : superarabic)
144 c = map[c - char_type('0')];