/// ------------------------------------------------------------------------------------ /// <summary> /// Sanity check to ensure the scripture texts are valid. /// </summary> /// ------------------------------------------------------------------------------------ protected void EnsureScriptureTextsValid() { foreach (IScrBook book in m_scr.ScriptureBooksOS) { if (book.SectionsOS.Count == 0) { continue; } ContextValues sectionContext; foreach (IScrSection section in book.SectionsOS) { // Check the heading paragraphs. if (section.HeadingOA == null) { section.HeadingOA = m_cache.ServiceLocator.GetInstance <IStTextFactory>().Create(); } if (section.HeadingOA.ParagraphsOS.Count == 0) { IStTxtPara para = m_cache.ServiceLocator.GetInstance <IScrTxtParaFactory>().CreateWithStyle( section.HeadingOA, ScrStyleNames.SectionHead); sectionContext = ContextValues.Text; } else { IStStyle style = m_scr.FindStyle(section.HeadingOA.ParagraphsOS[0].StyleRules); // style could be null. set default context if possible sectionContext = style == null ? ContextValues.Text : style.Context; } // Check the content paragraphs. if (section.ContentOA == null) { section.ContentOA = m_cache.ServiceLocator.GetInstance <IStTextFactory>().Create(); } if (section.ContentOA.ParagraphsOS.Count == 0) { IStTxtPara para = m_cache.ServiceLocator.GetInstance <IScrTxtParaFactory>().CreateWithStyle( section.ContentOA, TeStylesXmlAccessor.GetDefaultStyleForContext(sectionContext, false)); } } } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Gets the style name that is the default style to use for the given context /// </summary> /// <param name="nContext">the context</param> /// <param name="fCharStyle">set to <c>true</c> for character styles; otherwise /// <c>false</c>.</param> /// <returns> /// Name of the style that is the default for the context /// </returns> /// ------------------------------------------------------------------------------------ public override string GetDefaultStyleForContext(int nContext, bool fCharStyle) { return(TeStylesXmlAccessor.GetDefaultStyleForContext((ContextValues)nContext, fCharStyle)); }