Exemplo n.º 1
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Sanity check to ensure the scripture texts are valid.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        protected void EnsureScriptureTextsValid()
        {
            foreach (ScrBook book in m_scr.ScriptureBooksOS)
            {
                int[] sectionHvos = book.SectionsOS.HvoArray;
                // Don't crash if we don't have any sections (TE-5380)
                if (sectionHvos.Length == 0)
                {
                    continue;
                }

                ContextValues sectionContext;
                foreach (ScrSection section in book.SectionsOS)
                {
                    // Check the heading paragraphs.
                    if (section.HeadingOA == null)
                    {
                        m_cache.CreateObject(StText.kClassId, section.Hvo,
                                             (int)ScrSection.ScrSectionTags.kflidHeading, 0);
                    }
                    if (section.HeadingOA.ParagraphsOS.Count == 0)
                    {
                        StTxtPara para = new StTxtPara();
                        section.HeadingOA.ParagraphsOS.Append(para);
                        para.StyleRules = StyleUtils.ParaStyleTextProps(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)
                    {
                        m_cache.CreateObject(StText.kClassId, section.Hvo,
                                             (int)ScrSection.ScrSectionTags.kflidContent, 0);
                    }
                    if (section.ContentOA.ParagraphsOS.Count == 0)
                    {
                        StTxtPara para = new StTxtPara();
                        section.ContentOA.ParagraphsOS.Append(para);
                        para.StyleRules = StyleUtils.ParaStyleTextProps(
                            TeEditingHelper.GetDefaultStyleForContext(sectionContext, false));
                        section.AdjustReferences();
                    }
                }
            }
        }
Exemplo n.º 2
0
 /// ------------------------------------------------------------------------------------
 /// <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(TeEditingHelper.GetDefaultStyleForContext((ContextValues)nContext, fCharStyle));
 }