public void CreateTwoParagraphs() { CheckDisposed(); // Build First StTxtPara StTxtParaBldr bldr = new StTxtParaBldr(Cache); IParaStylePropsProxy proxy = new DummyProxy("MyParaStyle"); bldr.ParaStylePropsProxy = proxy; ITsTextProps textProps = StyleUtils.CharStyleTextProps(null, m_wsArbitrary); bldr.AppendRun("Para 1", textProps); StText text = new StText(Cache, m_text.Hvo); int iPara = text.ParagraphsOS.Count; StTxtPara para1 = bldr.CreateParagraph(text.Hvo, iPara); // verify paragraph 1 AssertEx.RunIsCorrect(para1.Contents.UnderlyingTsString, 0, "Para 1", null, m_wsArbitrary); // Build Second StTxtPara -- Builder should have been cleared textProps = StyleUtils.CharStyleTextProps("BringBrangBrung", m_wsArbitrary); bldr.AppendRun("Para 2", textProps); StTxtPara para2 = bldr.CreateParagraph(text.Hvo, iPara + 1); Assert.AreEqual(text.ParagraphsOS[iPara].Hvo, para1.Hvo); Assert.AreEqual(text.ParagraphsOS[iPara + 1].Hvo, para2.Hvo); // Re-verify paragraph 1 AssertEx.RunIsCorrect(para1.Contents.UnderlyingTsString, 0, "Para 1", null, m_wsArbitrary); // verify paragraph 2 AssertEx.RunIsCorrect(para2.Contents.UnderlyingTsString, 0, "Para 2", "BringBrangBrung", m_wsArbitrary); }
public void AppendTwoRuns_WithAndWithoutNamedCharStyles() { CheckDisposed(); // Build an StTxtPara StTxtParaBldr bldr = new StTxtParaBldr(Cache); IParaStylePropsProxy proxy = new DummyProxy("Para Meister"); bldr.ParaStylePropsProxy = proxy; ITsTextProps textProps = StyleUtils.CharStyleTextProps(null, m_wsArbitrary); bldr.AppendRun("Run 1 ", textProps); textProps = StyleUtils.CharStyleTextProps("Italic Run", m_wsArbitrary); // verify its length Assert.AreEqual(6, bldr.Length); // add another run bldr.AppendRun("Run 2", textProps); StTxtPara para = bldr.CreateParagraph(m_text.Hvo, 1); // verify paragraph's state Assert.IsNotNull(para); Assert.AreEqual(proxy.Props, para.StyleRules); AssertEx.RunIsCorrect(para.Contents.UnderlyingTsString, 0, "Run 1 ", null, m_wsArbitrary); AssertEx.RunIsCorrect(para.Contents.UnderlyingTsString, 1, "Run 2", "Italic Run", m_wsArbitrary); // Builder should now be cleared Assert.AreEqual(0, bldr.Length); }
/// ------------------------------------------------------------------------------------ /// <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); }
/// <summary> /// attach an annotation describing this failure to the object. *Does Not* remove previous annotations! /// </summary> /// <remarks> I say it does not remove previous annotations because I haven't thought about how much smarts /// it would take to only remove once associated with this particular failure. So I am stipulating for now that /// the caller should first remove all of the kinds of indications which it might create.</remarks> /// <returns></returns> protected ICmBaseAnnotation MakeAnnotation() { // callar should do something like this:CmBaseAnnotation.RemoveAnnotationsForObject(m_object.Cache, m_object.Hvo); ICmBaseAnnotation annotation = (ICmBaseAnnotation)m_cache.LangProject.AnnotationsOC.Add(new CmBaseAnnotation()); annotation.CompDetails = m_xmlDescription; annotation.TextOA = new StText(); using (StTxtParaBldr paraBldr = new StTxtParaBldr(m_cache)) { //review: I have no idea what this is as to be paraBldr.ParaProps = StyleUtils.ParaStyleTextProps("Paragraph"); //todo: this pretends that the default analysis writing system is also the user // interface 1. but I don't really know what's the right thing to do. paraBldr.AppendRun(m_explanation, StyleUtils.CharStyleTextProps(null, m_cache.DefaultAnalWs)); paraBldr.CreateParagraph(annotation.TextOAHvo); } // Dispose() frees ICU resources. annotation.BeginObjectRA = m_object; annotation.Flid = m_flid; annotation.CompDetails = m_xmlDescription; annotation.SourceRA = m_cache.LangProject.ConstraintCheckerAgent; // Although we generated a PropChanged when we actually created the annotation, we need another // one now that all its properties have been set, as there may be a filter that excludes it // until those properties. Simulate removing and re-adding the new annotation (presumed to be // at the end of the collection). int chvo = m_cache.LangProject.AnnotationsOC.Count; m_cache.PropChanged(null, PropChangeType.kpctNotifyAll, m_cache.LangProject.Hvo, (int)LangProject.LangProjectTags.kflidAnnotations, chvo - 1, 1, 1); return(annotation); }
public void AppendParagraph() { CheckDisposed(); // Build an StTxtPara StTxtParaBldr bldr = new StTxtParaBldr(Cache); IParaStylePropsProxy proxy = new DummyProxy("Para Meister"); bldr.ParaStylePropsProxy = proxy; ITsTextProps textProps = StyleUtils.CharStyleTextProps(null, Cache.LanguageEncodings.Item(0).Hvo); bldr.AppendRun("Run 1", textProps); StText text = new StText(Cache, m_text.Hvo); int iPara = text.ParagraphsOS.Count; StTxtPara para = bldr.CreateParagraph(text.Hvo); // verify paragraph's state Assert.IsNotNull(para); Assert.AreEqual(proxy.Props, para.StyleRules); AssertEx.RunIsCorrect(para.Contents.UnderlyingTsString, 0, "Run 1", null, m_wsArbitrary); Assert.AreEqual(para.Hvo, text.ParagraphsOS[iPara].Hvo); // Builder should now be cleared Assert.AreEqual(0, bldr.Length); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Sets the cited text for checking error annotation. /// </summary> /// <param name="citedText">The cited text.</param> /// <param name="ws">The writing system.</param> /// <returns>Quote for the ScrScriptureNote</returns> /// ------------------------------------------------------------------------------------ private StTxtParaBldr SetCitedText(string citedText, int ws) { StTxtParaBldr quote = new StTxtParaBldr(m_cache); quote.ParaProps = StyleUtils.ParaStyleTextProps(ScrStyleNames.Remark); // ENHANCE: Cache the run props using a hash table for each writing system quote.AppendRun(citedText, StyleUtils.CharStyleTextProps(null, ws)); return(quote); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Sets the error message. /// </summary> /// <param name="formattedMsg">The localized and formatted message.</param> /// <returns>Discussion for the ScrScriptureNote</returns> /// ------------------------------------------------------------------------------------ private StTxtParaBldr SetErrorMessage(string formattedMsg) { StTxtParaBldr discussion = new StTxtParaBldr(m_cache); discussion.ParaProps = StyleUtils.ParaStyleTextProps(ScrStyleNames.Remark); // ENHANCE: Cache the run props for the UI writing system discussion.AppendRun(formattedMsg, StyleUtils.CharStyleTextProps(null, m_cache.DefaultUserWs)); return(discussion); }
public void VerseIterator_InitialText() { // Create section 1 for Genesis. IScrSection section1 = CreateSection(m_genesis, "My aching head!", 01001001, 01001001); // build paragraph for section 1 StTxtParaBldr paraBldr = new StTxtParaBldr(Cache); paraBldr.ParaStyleName = ScrStyleNames.NormalParagraph; paraBldr.AppendRun("Some initial text. ", StyleUtils.CharStyleTextProps(null, Cache.DefaultVernWs)); paraBldr.AppendRun("5-6", StyleUtils.CharStyleTextProps(ScrStyleNames.VerseNumber, Cache.DefaultVernWs)); paraBldr.AppendRun("Verses 5-6.", StyleUtils.CharStyleTextProps(null, Cache.DefaultVernWs)); IScrTxtPara hvoS1Para = (IScrTxtPara)paraBldr.CreateParagraph(section1.ContentOA); // Create an iterator to test m_bookMerger.CreateVerseIteratorForStText(section1.ContentOA); // Verify section 1 content ScrVerse scrVerse = m_bookMerger.NextVerseInStText(); Assert.AreEqual(hvoS1Para, scrVerse.Para); Assert.AreEqual(01001001, scrVerse.StartRef); Assert.AreEqual(01001001, scrVerse.EndRef); Assert.AreEqual("Some initial text. ", scrVerse.Text.Text); Assert.AreEqual(0, scrVerse.VerseStartIndex); scrVerse = m_bookMerger.NextVerseInStText(); Assert.AreEqual(hvoS1Para, scrVerse.Para); Assert.AreEqual(01001005, scrVerse.StartRef); Assert.AreEqual(01001006, scrVerse.EndRef); Assert.AreEqual("5-6Verses 5-6.", scrVerse.Text.Text); Assert.AreEqual(19, scrVerse.VerseStartIndex); Assert.IsNull(m_bookMerger.NextVerseInStText()); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Create a new section, to be owned by the given book. The section will be an intro /// section if the isIntro flag is set to <code>true</code> /// The contents of the first content paragraph are filled with a single run as /// requested. The start and end references for the section are set based on where it's /// being inserted in the book. /// </summary> /// <param name="book">The book where the new section will be created</param> /// <param name="iSection">The zero-based index of the new section</param> /// <param name="contentText">The text to be used as the first para in the new section /// content</param> /// <param name="contentTextProps">The character properties to be applied to the first /// para in the new section content</param> /// <param name="isIntro">True to create an intro section, false to create a /// normal scripture section</param> /// <returns>Created section</returns> /// ------------------------------------------------------------------------------------ public static IScrSection CreateScrSection(IScrBook book, int iSection, string contentText, ITsTextProps contentTextProps, bool isIntro) { Debug.Assert(book != null); IScrSection section = CreateSectionWithHeadingPara(book, iSection, isIntro); // Insert the section contents. using (StTxtParaBldr bldr = new StTxtParaBldr(book.Cache)) { bldr.ParaProps = StyleUtils.ParaStyleTextProps( isIntro ? ScrStyleNames.IntroParagraph : ScrStyleNames.NormalParagraph); bldr.AppendRun(contentText, contentTextProps); bldr.CreateParagraph(section.ContentOAHvo); } // Dispose() frees ICU resources. return(section); }
public void RemoveOwnedObjectsForString_Simple() { CheckDisposed(); StTxtParaBldr paraBldr = new StTxtParaBldr(Cache); paraBldr.ParaProps = StyleUtils.ParaStyleTextProps("Normal"); paraBldr.AppendRun("Test Paragraph", StyleUtils.CharStyleTextProps(null, Cache.DefaultVernWs)); StTxtPara para = paraBldr.CreateParagraph(m_currentText.Hvo); m_inMemoryCache.AddFootnote(m_currentFootnotesOS, para, 10, null); Assert.AreEqual(1, m_currentFootnotesOS.Count); para.RemoveOwnedObjectsForString(5, 12); Assert.AreEqual(0, m_currentFootnotesOS.Count); }
public void TrimTrailingSpaceWithNoSpaceAtEnd() { CheckDisposed(); // Build an StTxtPara using (StTxtParaBldr bldr = new StTxtParaBldr(Cache)) { IParaStylePropsProxy proxy = new DummyProxy("Whatever"); bldr.ParaStylePropsProxy = proxy; ITsTextProps textProps = StyleUtils.CharStyleTextProps(null, m_wsArbitrary); bldr.AppendRun("My run", textProps); Assert.AreEqual(6, bldr.Length); // Attempt to trim the space off the end -- nothing should happen. bldr.TrimTrailingSpaceInPara(); Assert.AreEqual(6, bldr.Length); StTxtPara para = bldr.CreateParagraph(m_text.Hvo, 1); // verify paragraph contents AssertEx.RunIsCorrect(para.Contents.UnderlyingTsString, 0, "My run", null, m_wsArbitrary); } // Dispose() frees ICU resources. }
public void CreateParagraphEmpty() { CheckDisposed(); // create an StTxtPara StTxtParaBldr bldr = new StTxtParaBldr(Cache); IParaStylePropsProxy proxy = new DummyProxy("EmptyPara"); bldr.ParaStylePropsProxy = proxy; ITsTextProps textProps = StyleUtils.CharStyleTextProps(null, m_wsArbitrary); bldr.AppendRun(string.Empty, textProps); Assert.AreEqual(0, bldr.Length); StTxtPara para = bldr.CreateParagraph(m_text.Hvo, 1); // verify paragraph's state Assert.IsNotNull(para); Assert.AreEqual(proxy.Props, para.StyleRules); Assert.AreEqual(1, para.Contents.UnderlyingTsString.RunCount); Assert.IsNull(para.Contents.Text); }
public void AppendRunWithNamedCharStyle() { CheckDisposed(); // create an StTxtPara StTxtParaBldr bldr = new StTxtParaBldr(Cache); IParaStylePropsProxy proxy = new DummyProxy("Whatever"); bldr.ParaStylePropsProxy = proxy; ITsTextProps textProps = StyleUtils.CharStyleTextProps("George's Favorite Char Style", m_wsArbitrary); bldr.AppendRun("My run", textProps); StTxtPara para = bldr.CreateParagraph(m_text.Hvo, 1); // verify paragraph's state Assert.IsNotNull(para); Assert.AreEqual(proxy.Props, para.StyleRules); AssertEx.RunIsCorrect(para.Contents.UnderlyingTsString, 0, "My run", "George's Favorite Char Style", m_wsArbitrary); // Builder should now be cleared Assert.AreEqual(0, bldr.Length); }
public void MoveNext_SpacesInVerses() { CheckDisposed(); ScrSection sectionCur = new ScrSection(); m_genesis.SectionsOS.Append(sectionCur); // Create a section head for this section sectionCur.HeadingOA = new StText(); StTxtParaBldr paraBldr = new StTxtParaBldr(Cache); paraBldr.ParaProps = StyleUtils.ParaStyleTextProps(ScrStyleNames.SectionHead); paraBldr.AppendRun("My aching head!", StyleUtils.CharStyleTextProps(null, Cache.DefaultVernWs)); paraBldr.CreateParagraph(sectionCur.HeadingOAHvo); sectionCur.ContentOA = new StText(); paraBldr = new StTxtParaBldr(Cache); paraBldr.ParaProps = StyleUtils.ParaStyleTextProps(ScrStyleNames.NormalParagraph); paraBldr.AppendRun("1", StyleUtils.CharStyleTextProps(ScrStyleNames.ChapterNumber, Cache.DefaultVernWs)); paraBldr.AppendRun("Verse One. ", StyleUtils.CharStyleTextProps(null, Cache.DefaultVernWs)); paraBldr.AppendRun("2", StyleUtils.CharStyleTextProps(ScrStyleNames.VerseNumber, Cache.DefaultVernWs)); paraBldr.AppendRun(" Verse Two. ", StyleUtils.CharStyleTextProps(null, Cache.DefaultVernWs)); paraBldr.AppendRun("3", StyleUtils.CharStyleTextProps(ScrStyleNames.VerseNumber, Cache.DefaultVernWs)); paraBldr.AppendRun("Verse Three.", StyleUtils.CharStyleTextProps(null, Cache.DefaultVernWs)); paraBldr.AppendRun("4", StyleUtils.CharStyleTextProps(ScrStyleNames.VerseNumber, Cache.DefaultVernWs)); paraBldr.AppendRun(" ", StyleUtils.CharStyleTextProps(null, Cache.DefaultVernWs)); StTxtPara para = paraBldr.CreateParagraph(sectionCur.ContentOA.Hvo); sectionCur.AdjustReferences(); ScrTxtPara stPara = new ScrTxtPara(Cache, para.Hvo); ScrVerseSet verseSet = new ScrVerseSet(stPara); // Iterate through the verses in the paragraph ScrVerse verse; Assert.IsTrue(verseSet.MoveNext()); verse = (ScrVerse)verseSet.Current; Assert.AreEqual("1", verse.Text.Text); Assert.AreEqual(01001001, verse.StartRef); Assert.AreEqual(01001001, verse.EndRef); Assert.IsTrue(verseSet.MoveNext()); verse = (ScrVerse)verseSet.Current; Assert.AreEqual("Verse One. ", verse.Text.Text); Assert.AreEqual(01001001, verse.StartRef); Assert.AreEqual(01001001, verse.EndRef); Assert.IsTrue(verseSet.MoveNext()); verse = (ScrVerse)verseSet.Current; Assert.AreEqual("2 Verse Two. ", verse.Text.Text); Assert.AreEqual(01001002, verse.StartRef); Assert.AreEqual(01001002, verse.EndRef); Assert.IsTrue(verseSet.MoveNext()); verse = (ScrVerse)verseSet.Current; Assert.AreEqual("3Verse Three.", verse.Text.Text); Assert.AreEqual(01001003, verse.StartRef); Assert.AreEqual(01001003, verse.EndRef); Assert.IsTrue(verseSet.MoveNext()); verse = (ScrVerse)verseSet.Current; Assert.AreEqual("4 ", verse.Text.Text); Assert.AreEqual(01001004, verse.StartRef); Assert.AreEqual(01001004, verse.EndRef); Assert.IsFalse(verseSet.MoveNext()); }
public void MoveNext_SpacesInVerses_ChapterNumberSeparate() { IScrSection sectionCur = AddSectionToMockedBook(m_genesis); // Create a section head for this section AddSectionHeadParaToSection(sectionCur, "My aching head!", ScrStyleNames.SectionHead); StTxtParaBldr paraBldr = new StTxtParaBldr(Cache); paraBldr.ParaStyleName = ScrStyleNames.NormalParagraph; paraBldr.AppendRun("1", StyleUtils.CharStyleTextProps(ScrStyleNames.ChapterNumber, Cache.DefaultVernWs)); paraBldr.AppendRun("Verse One. ", StyleUtils.CharStyleTextProps(null, Cache.DefaultVernWs)); paraBldr.AppendRun("2", StyleUtils.CharStyleTextProps(ScrStyleNames.VerseNumber, Cache.DefaultVernWs)); paraBldr.AppendRun(" Verse Two. ", StyleUtils.CharStyleTextProps(null, Cache.DefaultVernWs)); paraBldr.AppendRun("3", StyleUtils.CharStyleTextProps(ScrStyleNames.VerseNumber, Cache.DefaultVernWs)); paraBldr.AppendRun("Verse Three.", StyleUtils.CharStyleTextProps(null, Cache.DefaultVernWs)); paraBldr.AppendRun("4", StyleUtils.CharStyleTextProps(ScrStyleNames.VerseNumber, Cache.DefaultVernWs)); paraBldr.AppendRun(" ", StyleUtils.CharStyleTextProps(null, Cache.DefaultVernWs)); IScrTxtPara para = (IScrTxtPara)paraBldr.CreateParagraph(sectionCur.ContentOA); using (ScrVerseSet verseSet = new ScrVerseSet(para)) { // Iterate through the verses in the paragraph ScrVerse verse; Assert.IsTrue(verseSet.MoveNext()); verse = verseSet.Current; Assert.AreEqual("1", verse.Text.Text); Assert.AreEqual(01001001, verse.StartRef); Assert.AreEqual(01001001, verse.EndRef); Assert.IsTrue(verseSet.MoveNext()); verse = verseSet.Current; Assert.AreEqual("Verse One. ", verse.Text.Text); Assert.AreEqual(01001001, verse.StartRef); Assert.AreEqual(01001001, verse.EndRef); Assert.IsTrue(verseSet.MoveNext()); verse = verseSet.Current; Assert.AreEqual("2 Verse Two. ", verse.Text.Text); Assert.AreEqual(01001002, verse.StartRef); Assert.AreEqual(01001002, verse.EndRef); Assert.IsTrue(verseSet.MoveNext()); verse = verseSet.Current; Assert.AreEqual("3Verse Three.", verse.Text.Text); Assert.AreEqual(01001003, verse.StartRef); Assert.AreEqual(01001003, verse.EndRef); Assert.IsTrue(verseSet.MoveNext()); verse = verseSet.Current; Assert.AreEqual("4 ", verse.Text.Text); Assert.AreEqual(01001004, verse.StartRef); Assert.AreEqual(01001004, verse.EndRef); Assert.IsFalse(verseSet.MoveNext()); } }
public void AppendRunWithNamedCharStyle() { // create an IStTxtPara IParaStylePropsProxy proxy = new DummyProxy("Whatever"); m_bldr.ParaStylePropsProxy = proxy; ITsTextProps textProps = StyleUtils.CharStyleTextProps("George's Favorite Char Style", m_wsArbitrary); m_bldr.AppendRun("My run", textProps); IStTxtPara para = m_bldr.CreateParagraph(m_text, 1); // verify paragraph's state Assert.IsNotNull(para); Assert.AreEqual(proxy.StyleId, para.StyleName); AssertEx.RunIsCorrect(para.Contents, 0, "My run", "George's Favorite Char Style", m_wsArbitrary); // Builder should now be cleared Assert.AreEqual(0, m_bldr.Length); }
public void VerseIterator_ForSetOfStTexts() { // Create section 1 for Genesis. IScrSection section1 = CreateSection(m_genesis, "My aching head!"); // build paragraph for section 1 StTxtParaBldr paraBldr = new StTxtParaBldr(Cache); paraBldr.ParaStyleName = ScrStyleNames.NormalParagraph; paraBldr.AppendRun("2", StyleUtils.CharStyleTextProps(ScrStyleNames.ChapterNumber, Cache.DefaultVernWs)); paraBldr.AppendRun("Verse 1. ", StyleUtils.CharStyleTextProps(null, Cache.DefaultVernWs)); IScrTxtPara para1 = (IScrTxtPara)paraBldr.CreateParagraph(section1.ContentOA); // Create section 2 for Genesis. IScrSection section2 = CreateSection(m_genesis, "My aching behind!"); // build paragraph for section 2 paraBldr.ParaStyleName = ScrStyleNames.NormalParagraph; paraBldr.AppendRun("3", StyleUtils.CharStyleTextProps(ScrStyleNames.ChapterNumber, Cache.DefaultVernWs)); paraBldr.AppendRun("Verse 1. ", StyleUtils.CharStyleTextProps(null, Cache.DefaultVernWs)); IScrTxtPara para2 = (IScrTxtPara)paraBldr.CreateParagraph(section2.ContentOA); // Create section 3 for Genesis. IScrSection section3 = CreateSection(m_genesis, ""); // build paragraph for section 3 paraBldr.ParaStyleName = ScrStyleNames.NormalParagraph; IScrTxtPara para3 = (IScrTxtPara)paraBldr.CreateParagraph(section3.ContentOA); // Create an iterator to test group of StTexts List <IStText> list = new List <IStText>(6); // this is not a typical list for TE, just a bunch of StTexts for this test list.Add(section1.HeadingOA); list.Add(section2.HeadingOA); list.Add(section3.HeadingOA); list.Add(section1.ContentOA); list.Add(section2.ContentOA); list.Add(section3.ContentOA); m_bookMerger.CreateVerseIteratorForSetOfStTexts(list); // Verify section 1 heading ScrVerse scrVerse = m_bookMerger.NextVerseInSet(); DiffTestHelper.VerifyScrVerse(scrVerse, (IScrTxtPara)section1.HeadingOA[0], 01002001, 01002001, "My aching head!", 0, false, true, 0); // Verify section 2 heading scrVerse = m_bookMerger.NextVerseInSet(); DiffTestHelper.VerifyScrVerse(scrVerse, (IScrTxtPara)section2.HeadingOA[0], 01003001, 01003001, "My aching behind!", 0, false, true, 1); // section 3 heading is empty, but returns an empty ScrVerse scrVerse = m_bookMerger.NextVerseInSet(); DiffTestHelper.VerifyScrVerse(scrVerse, (IScrTxtPara)section3.HeadingOA[0], 01003001, 01003001, null, 0, false, true, 2); // Verify section 1 content scrVerse = m_bookMerger.NextVerseInSet(); DiffTestHelper.VerifyScrVerse(scrVerse, (IScrTxtPara)section1.ContentOA[0], 01002001, 01002001, "2Verse 1. ", 0, true, false, 0); // Verify section 2 content scrVerse = m_bookMerger.NextVerseInSet(); DiffTestHelper.VerifyScrVerse(scrVerse, (IScrTxtPara)section2.ContentOA[0], 01003001, 01003001, "3Verse 1. ", 0, true, false, 1); // Verify section 3 content--an empty ScrVerse scrVerse = m_bookMerger.NextVerseInSet(); DiffTestHelper.VerifyScrVerse(scrVerse, (IScrTxtPara)section3.ContentOA[0], 01003001, 01003001, null, 0, false, false, 2); // Verify there are no more scrVerses scrVerse = m_bookMerger.NextVerseInSet(); Assert.IsNull(scrVerse); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Adds to para BLDR. /// </summary> /// ------------------------------------------------------------------------------------ internal virtual void AddToParaBldr(StTxtParaBldr bldr, int ws, FwStyleSheet styleSheet) { bldr.AppendRun(m_text, StyleUtils.CharStyleTextProps(StyleName, ws)); }
public void VerseIterator() { // Create section 1 for Genesis. IScrSection section1 = CreateSection(m_genesis, "My aching head!"); // build paragraph for section 1 StTxtParaBldr paraBldr = new StTxtParaBldr(Cache); paraBldr.ParaStyleName = ScrStyleNames.NormalParagraph; paraBldr.AppendRun("2", StyleUtils.CharStyleTextProps(ScrStyleNames.ChapterNumber, Cache.DefaultVernWs)); paraBldr.AppendRun("Verse 1. ", StyleUtils.CharStyleTextProps(null, Cache.DefaultVernWs)); paraBldr.AppendRun("2", StyleUtils.CharStyleTextProps(ScrStyleNames.VerseNumber, Cache.DefaultVernWs)); paraBldr.AppendRun("Verse 2. ", StyleUtils.CharStyleTextProps(null, Cache.DefaultVernWs)); paraBldr.AppendRun("3-4", StyleUtils.CharStyleTextProps(ScrStyleNames.VerseNumber, Cache.DefaultVernWs)); paraBldr.AppendRun("Verse 3-4.", StyleUtils.CharStyleTextProps(null, Cache.DefaultVernWs)); IScrTxtPara hvoS1Para = (IScrTxtPara)paraBldr.CreateParagraph(section1.ContentOA); // Create an iterator to test heading m_bookMerger.CreateVerseIteratorForStText(section1.HeadingOA); // Verify section 1 heading ScrVerse scrVerse = m_bookMerger.NextVerseInStText(); Assert.AreEqual(section1.HeadingOA[0], scrVerse.Para); Assert.AreEqual(01002001, scrVerse.StartRef); Assert.AreEqual(01002001, scrVerse.EndRef); Assert.AreEqual("My aching head!", scrVerse.Text.Text); Assert.AreEqual(0, scrVerse.VerseStartIndex); // Verify there are no more scrVerses scrVerse = m_bookMerger.NextVerseInStText(); Assert.IsNull(scrVerse); // Create an iterator to test content m_bookMerger.CreateVerseIteratorForStText(section1.ContentOA); // Verify section 1 content scrVerse = m_bookMerger.NextVerseInStText(); Assert.AreEqual(hvoS1Para, scrVerse.Para); Assert.AreEqual(01002001, scrVerse.StartRef); Assert.AreEqual(01002001, scrVerse.EndRef); Assert.AreEqual("2Verse 1. ", scrVerse.Text.Text); Assert.AreEqual(0, scrVerse.VerseStartIndex); Assert.AreEqual(1, scrVerse.TextStartIndex); scrVerse = m_bookMerger.NextVerseInStText(); Assert.AreEqual(01002002, scrVerse.StartRef); Assert.AreEqual(01002002, scrVerse.EndRef); Assert.AreEqual("2Verse 2. ", scrVerse.Text.Text); Assert.AreEqual(10, scrVerse.VerseStartIndex); scrVerse = m_bookMerger.NextVerseInStText(); Assert.AreEqual(01002003, scrVerse.StartRef); Assert.AreEqual(01002004, scrVerse.EndRef); Assert.AreEqual("3-4Verse 3-4.", scrVerse.Text.Text); Assert.AreEqual(20, scrVerse.VerseStartIndex); // Verify there are no more scrVerses scrVerse = m_bookMerger.NextVerseInStText(); Assert.IsNull(scrVerse); }