Exemplo n.º 1
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Append a new section to the given book, having the specified text as the section
        /// head. The new section will have an empty content text created also.
        /// </summary>
        /// <param name="scrInMemoryCache">in-memory cache to use for testing</param>
        /// <param name="book">The book to which the section is to be appended</param>
        /// <param name="sSectionHead">The text of the new section head. Can be a simple string
        /// or a format string. (See CreateText for the definition of the format string)</param>
        /// <param name="paraStyleName">paragraph style to apply to the section head</param>
        /// <returns>The newly created section</returns>
        /// ------------------------------------------------------------------------------------
        internal static ScrSection CreateSection(ScrInMemoryFdoCache scrInMemoryCache, IScrBook book,
                                                 string sSectionHead, string paraStyleName)
        {
            // Create a section
            ScrSection section = new ScrSection();

            book.SectionsOS.Append(section);

            // Create a section head for this section
            section.HeadingOA = new StText();

            if (sSectionHead.Length == 0 || sSectionHead[0] != '\\')
            {
                // create a simple section head with no character style
                StTxtParaBldr paraBldr = new StTxtParaBldr(scrInMemoryCache.Cache);
                paraBldr.ParaProps = StyleUtils.ParaStyleTextProps(paraStyleName);
                paraBldr.AppendRun(sSectionHead,
                                   StyleUtils.CharStyleTextProps(null, scrInMemoryCache.Cache.DefaultVernWs));
                paraBldr.CreateParagraph(section.HeadingOAHvo);
            }
            else
            {
                // Create a more complex section head from the given format string
                // insert a new para in the title
                StTxtPara para = new StTxtPara();
                section.HeadingOA.ParagraphsOS.Append(para);
                // set the para's fields
                scrInMemoryCache.AddFormatTextToMockedPara(book, para, sSectionHead, scrInMemoryCache.Cache.DefaultVernWs);
                para.StyleRules = StyleUtils.ParaStyleTextProps(paraStyleName);
            }

            section.ContentOA = new StText();
            section.AdjustReferences();
            return(section);
        }
Exemplo n.º 2
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Adjust section refs if needed.
        /// Called by a ChangeWatcher if any paras in StText.ParagraphsOS are added, deleted,
        /// or moved.
        /// </summary>
        /// <param name="text">the StText whose Paragraphs collection was changed</param>
        /// <param name="ivMin">index of the first para inserted or deleted in the StText</param>
        /// ------------------------------------------------------------------------------------
        public static void AdjustSectionRefsForStTextParaChg(IStText text, int ivMin)
        {
            // We expect that this StText is part of ScrSection.Content
            Debug.Assert(text.Cache.GetOwningFlidOfObject(text.Hvo) ==
                         (int)ScrSection.ScrSectionTags.kflidContent);

            ScrSection section = new ScrSection(text.Cache, text.Cache.GetOwnerOfObject(text.Hvo));

            section.AdjustReferences();
        }
Exemplo n.º 3
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Append a new section to the given book, having the specified text as the section
        /// head. The general section head paragraph style is used.
        /// </summary>
        /// <param name="scrInMemoryCache">in-memory cache to use for testing</param>
        /// <param name="book">The book to which the section is to be appended</param>
        /// <param name="sSectionHead">The text of the new section head</param>
        /// <returns>The newly created section</returns>
        /// ------------------------------------------------------------------------------------
        internal static ScrSection CreateSection(ScrInMemoryFdoCache scrInMemoryCache, IScrBook book,
                                                 string sSectionHead)
        {
            ScrSection section = CreateSection(scrInMemoryCache, book, sSectionHead, ScrStyleNames.SectionHead);
            // this should be a scripture section and not an intro section
            bool isIntro = false;

            section.VerseRefEnd = book.CanonicalNum * 1000000 + 1000 + ((isIntro) ? 0 : 1);
            section.AdjustReferences();
            return(section);
        }
Exemplo n.º 4
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Adjust section refs for the edited paragraph.
        /// Called by a ChangeWatcher if any StTxtPara.Contents is modified.
        /// </summary>
        /// <param name="ivMin">Character index where text was added and/or deleted</param>
        /// <param name="cvIns">Count of characters inserted</param>
        /// <param name="cvDel">Count of characters deleted</param>
        /// ------------------------------------------------------------------------------------
        public void ProcessChapterVerseNums(int ivMin, int cvIns, int cvDel)
        {
            // We expect that our para is part of a ScrSection.Content
            Debug.Assert(m_cache.GetOwningFlidOfObject(OwnerHVO) ==
                         (int)ScrSection.ScrSectionTags.kflidContent);

            // If we join a paragraph with an empty paragraph, there's nothing for us to do.
            if (cvIns == 0 && cvDel == 0)
            {
                return;
            }

            // Now adjust our section refs if necessary
            ScrSection section = new ScrSection(m_cache, m_cache.GetOwnerOfObject(OwnerHVO));

            section.AdjustReferences();
        }