/// ------------------------------------------------------------------------------------ /// <summary> /// Loads the specified XML file. /// </summary> /// <param name="filename">The name of the XML file.</param> /// <returns>information from the stylesheet needed for checking</returns> /// ------------------------------------------------------------------------------------ public static StyleMarkupInfo Load(string filename) { StyleMarkupInfo smi = XmlSerializationHelper.DeserializeFromFile <StyleMarkupInfo>(filename); smi.m_stylePropInfo = new StylePropsInfo(smi); return(smi ?? new StyleMarkupInfo()); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Creates the style lists needed for Scripture checking. /// </summary> /// <param name="smi">information needed for Scripture checking from all styles</param> /// ------------------------------------------------------------------------------------ private void CreateStyleLists(StyleMarkupInfo smi) { foreach (StyleMarkup style in smi.StyleMarkupList) { StyleInfo.StyleTypes styleType = (style.Type == "paragraph") ? StyleInfo.StyleTypes.paragraph : StyleInfo.StyleTypes.character; string styleName = style.Id.Replace("_", " "); // The following uses should begin with a capital letter: // * sentence initial // * proper name // * table // * list // * special (e.g. interlude, closing) // Save them in their own list so that we can report an appropriate error to the user. if (style.Use == "proseSentenceInitial") { StylePropsInfo.s_sentenceInitial.Add(new StyleInfo(styleName, styleType, StyleInfo.UseTypes.prose)); } else if (style.Use == "lineSentenceInitial") { StylePropsInfo.s_sentenceInitial.Add(new StyleInfo(styleName, styleType, StyleInfo.UseTypes.line)); } else if (style.Use == "properNoun") { StylePropsInfo.s_properNoun.Add(new StyleInfo(styleName, styleType, StyleInfo.UseTypes.other)); } else if (style.Use == "table") { StylePropsInfo.s_table.Add(new StyleInfo(styleName, styleType, StyleInfo.UseTypes.other)); } else if (style.Use == "list") { StylePropsInfo.s_list.Add(new StyleInfo(styleName, styleType, StyleInfo.UseTypes.other)); } else if (style.Use == "special") { StylePropsInfo.s_special.Add(new StyleInfo(styleName, styleType, StyleInfo.UseTypes.other)); } else if (style.Use == "stanzabreak") { StylePropsInfo.s_special.Add(new StyleInfo(styleName, styleType, StyleInfo.UseTypes.stanzabreak)); } // Titles should begin with a capital letter. Styles used for titles have a context of "title". if (!string.IsNullOrEmpty(style.Context) && style.Context == "title") { StylePropsInfo.s_title.Add(new StyleInfo(styleName, styleType, StyleInfo.UseTypes.other)); } // Headings should begin with a capital letter. Styles used for headings have a structure of "heading". if (!string.IsNullOrEmpty(style.Structure) && style.Structure == "heading") { StylePropsInfo.s_heading.Add(new StyleInfo(styleName, styleType, StyleInfo.UseTypes.other)); } } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Initializes the <see cref="StylePropsInfo"/> class. /// </summary> /// ------------------------------------------------------------------------------------ public StylePropsInfo(StyleMarkupInfo smi) : this() { CreateStyleLists(smi); }