/// ------------------------------------------------------------------------------------ /// <summary> /// Create a paragraph from a format string, and append it to the given section's /// content. /// </summary> /// <param name="testBase">in-memory test base</param> /// <param name="book">book to use</param> /// <param name="section">section to append to</param> /// <param name="format">(See CreateText for the definition of the format string)</param> /// <param name="ws">writing system to use</param> /// <param name="paraStyle">paragraph style name</param> /// <returns>the new paragraph</returns> /// ------------------------------------------------------------------------------------ internal static IScrTxtPara AppendParagraph(ScrInMemoryFdoTestBase testBase, IScrBook book, IScrSection section, string format, int ws, string paraStyle) { // insert a new para in the section content IScrTxtPara para = testBase.Cache.ServiceLocator.GetInstance <IScrTxtParaFactory>().CreateWithStyle( section.ContentOA, paraStyle); // set the para's fields testBase.AddFormatTextToMockedPara(book, para, format, ws); return(para); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Create a title paragrpaph for the given book. /// </summary> /// <param name="testBase">in-memory test base</param> /// <param name="book">The book</param>param> /// <param name="sTitle">The text of the title. Can be a simple string or a format /// string. </param> /// ------------------------------------------------------------------------------------ internal static void SetTitle(ScrInMemoryFdoTestBase testBase, IScrBook book, string sTitle) { book.TitleOA = testBase.Cache.ServiceLocator.GetInstance <IStTextFactory>().Create(); if (sTitle[0] != '\\') { testBase.AddTitleToMockedBook(book, sTitle); } else { // Create a more complex title from the given format string // insert a new para in the title IScrTxtPara para = testBase.Cache.ServiceLocator.GetInstance <IScrTxtParaFactory>().CreateWithStyle( book.TitleOA, ScrStyleNames.MainBookTitle); // set the para's fields testBase.AddFormatTextToMockedPara(book, para, sTitle, testBase.Cache.DefaultVernWs); } }
/// ------------------------------------------------------------------------------------ /// <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="testBase">in-memory test base 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 IScrSection CreateSection(ScrInMemoryFdoTestBase testBase, IScrBook book, string sSectionHead, string paraStyleName) { // Create a section bool fIsIntro = (paraStyleName.Equals(ScrStyleNames.IntroSectionHead)); IScrSection section = testBase.AddSectionToMockedBook(book, fIsIntro); // Create a heading paragraph with text string styleName = !string.IsNullOrEmpty(paraStyleName) ? paraStyleName : ScrStyleNames.SectionHead; IStTxtPara para = section.HeadingOA.AddNewTextPara(styleName); if (!string.IsNullOrEmpty(sSectionHead) && sSectionHead[0] == '\\') { // Text is formatted so add it as a formatted string. testBase.AddFormatTextToMockedPara(book, para, sSectionHead, testBase.Cache.DefaultVernWs); } else { testBase.AddRunToMockedPara(para, sSectionHead, testBase.Cache.DefaultVernWs); } return(section); }