/// <summary>Resolves a counter.</summary> /// <param name="counterName">the counter name</param> /// <param name="listSymbolType">the list symbol type</param> /// <param name="scope">the scope</param> /// <returns> /// the counter value as a /// <see cref="System.String"/> /// </returns> public virtual String ResolveCounter(String counterName, String listSymbolType, INode scope) { IDictionary <String, int?> scopeCounters = FindSuitableScopeMap(scope, counterName); int?counterValue = scopeCounters != null?scopeCounters.Get(counterName) : null; if (counterValue == null) { return(null); } else { // TODO we do that to print a logger message. We might want to reconsider and silently reset to 0 in the future if (listSymbolType == null) { return(counterValue.ToString()); } else { if (CssConstants.NONE.Equals(listSymbolType)) { return(""); } else { if (CssConstants.DISC.Equals(listSymbolType)) { return(DISC_SYMBOL); } else { if (CssConstants.SQUARE.Equals(listSymbolType)) { return(SQUARE_SYMBOL); } else { if (CssConstants.CIRCLE.Equals(listSymbolType)) { return(CIRCLE_SYMBOL); } else { if (CssConstants.UPPER_ALPHA.Equals(listSymbolType) || CssConstants.UPPER_LATIN.Equals(listSymbolType)) { return(EnglishAlphabetNumbering.ToLatinAlphabetNumberUpperCase((int)counterValue)); } else { if (CssConstants.LOWER_ALPHA.Equals(listSymbolType) || CssConstants.LOWER_LATIN.Equals(listSymbolType)) { return(EnglishAlphabetNumbering.ToLatinAlphabetNumberLowerCase((int)counterValue)); } else { if (CssConstants.LOWER_ROMAN.Equals(listSymbolType)) { return(counterValue <= MAX_ROMAN_NUMBER?RomanNumbering.ToRomanLowerCase((int)counterValue) : counterValue .ToString()); } else { if (CssConstants.UPPER_ROMAN.Equals(listSymbolType)) { return(counterValue <= MAX_ROMAN_NUMBER?RomanNumbering.ToRomanUpperCase((int)counterValue) : counterValue .ToString()); } else { if (CssConstants.DECIMAL_LEADING_ZERO.Equals(listSymbolType)) { return((counterValue < 10 ? "0" : "") + counterValue.ToString()); } else { if (CssConstants.LOWER_GREEK.Equals(listSymbolType)) { return(GreekAlphabetNumbering.ToGreekAlphabetNumberLowerCase((int)counterValue)); } else { if (CssConstants.GEORGIAN.Equals(listSymbolType)) { return(GeorgianNumbering.ToGeorgian((int)counterValue)); } else { if (CssConstants.ARMENIAN.Equals(listSymbolType)) { return(ArmenianNumbering.ToArmenian((int)counterValue)); } else { return(counterValue.ToString()); } } } } } } } } } } } } } } }
/// <summary>Converts number according to given glyph style.</summary> /// <param name="glyphStyle">style of the glyphs</param> /// <param name="number">number to be converted</param> /// <returns>converted number</returns> public static String ConvertNumberAccordingToGlyphStyle(CounterDigitsGlyphStyle glyphStyle, int number) { if (glyphStyle == null) { return(number.ToString()); } switch (glyphStyle) { case CounterDigitsGlyphStyle.NONE: { return(""); } case CounterDigitsGlyphStyle.DISC: { return(DISC_SYMBOL); } case CounterDigitsGlyphStyle.SQUARE: { return(SQUARE_SYMBOL); } case CounterDigitsGlyphStyle.CIRCLE: { return(CIRCLE_SYMBOL); } case CounterDigitsGlyphStyle.UPPER_ALPHA_AND_LATIN: { return(number > 0 ? EnglishAlphabetNumbering.ToLatinAlphabetNumberUpperCase(number) : number.ToString()); } case CounterDigitsGlyphStyle.LOWER_ALPHA_AND_LATIN: { return(number > 0 ? EnglishAlphabetNumbering.ToLatinAlphabetNumberLowerCase(number) : number.ToString()); } case CounterDigitsGlyphStyle.LOWER_GREEK: { return(number > 0 ? GreekAlphabetNumbering.ToGreekAlphabetNumberLowerCase(number) : number.ToString()); } case CounterDigitsGlyphStyle.LOWER_ROMAN: { return(number <= MAX_ROMAN_NUMBER?RomanNumbering.ToRomanLowerCase(number) : number.ToString()); } case CounterDigitsGlyphStyle.UPPER_ROMAN: { return(number <= MAX_ROMAN_NUMBER?RomanNumbering.ToRomanUpperCase(number) : number.ToString()); } case CounterDigitsGlyphStyle.DECIMAL_LEADING_ZERO: { return((number < 10 ? "0" : "") + number.ToString()); } case CounterDigitsGlyphStyle.GEORGIAN: { return(GeorgianNumbering.ToGeorgian(number)); } case CounterDigitsGlyphStyle.ARMENIAN: { return(ArmenianNumbering.ToArmenian(number)); } default: { return(number.ToString()); } } }