Ejemplo n.º 1
0
        /// <summary>
        /// attach an annotation describing this failure to the object. *Does Not* remove previous annotations! Generally call RemoveObsoleteAnnotations first.
        /// </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>
        public ICmBaseAnnotation MakeAnnotation()
        {
            var annotation = m_cache.ServiceLocator.GetInstance <ICmBaseAnnotationFactory>().Create();

            m_cache.LanguageProject.AnnotationsOC.Add(annotation);
            annotation.CompDetails = m_xmlDescription;

            annotation.TextOA = m_cache.ServiceLocator.GetInstance <IStTextFactory>().Create();
            var paraBldr = new StTxtParaBldr(m_cache);

            //review: I have no idea what this has to be.
            paraBldr.ParaStyleName = "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.TextOA);

            annotation.BeginObjectRA = m_object;
            annotation.Flid          = m_flid;
            annotation.CompDetails   = m_xmlDescription;
            annotation.SourceRA      = m_cache.LanguageProject.ConstraintCheckerAgent;
            return(annotation);
        }
Ejemplo n.º 2
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Creates an empty paragraph with the given paragraph style and writing system.
        /// </summary>
        /// <param name="cache"></param>
        /// <param name="owner"></param>
        /// <param name="paraStyle"></param>
        /// <param name="ws"></param>
        /// ------------------------------------------------------------------------------------
        public static void CreateEmptyPara(FdoCache cache, IStText owner, string paraStyle, int ws)
        {
            var bldr = new StTxtParaBldr(cache);

            bldr.ParaStyleName = paraStyle;
            bldr.AppendRun(String.Empty, StyleUtils.CharStyleTextProps(null, ws));
            bldr.CreateParagraph(owner);
        }
Ejemplo n.º 3
0
		public void DetectDifferences_Identical()
		{
			// Create a section for both the current version of Genesis and the stored revision.
			IScrSection sectionCur = CreateSection(m_genesis, "My aching head!");
			IScrSection sectionRev = CreateSection(m_genesisRevision, "My aching head!");

			StTxtParaBldr paraBldr = new StTxtParaBldr(Cache);
			paraBldr.ParaStyleName = ScrStyleNames.NormalParagraph;
			paraBldr.AppendRun("1", StyleUtils.CharStyleTextProps(ScrStyleNames.ChapterNumber,
				Cache.DefaultVernWs));
			paraBldr.AppendRun("In the beginning, God created the heavens and the earth. ",
				StyleUtils.CharStyleTextProps(null, Cache.DefaultVernWs));
			paraBldr.AppendRun("2", StyleUtils.CharStyleTextProps(ScrStyleNames.VerseNumber,
				Cache.DefaultVernWs));
			paraBldr.AppendRun("And the earth was formless and void... ",
				StyleUtils.CharStyleTextProps(null, Cache.DefaultVernWs));
			paraBldr.AppendRun("3", StyleUtils.CharStyleTextProps(ScrStyleNames.VerseNumber,
				Cache.DefaultVernWs));
			paraBldr.AppendRun("And God said, 'Let there be light...' ",
				StyleUtils.CharStyleTextProps(null, Cache.DefaultVernWs));
			paraBldr.CreateParagraph(sectionCur.ContentOA);

			paraBldr.ParaStyleName = ScrStyleNames.NormalParagraph;
			paraBldr.AppendRun("1", StyleUtils.CharStyleTextProps(ScrStyleNames.ChapterNumber,
				Cache.DefaultVernWs));
			paraBldr.AppendRun("In the beginning, God created the heavens and the earth. ",
				StyleUtils.CharStyleTextProps(null, Cache.DefaultVernWs));
			paraBldr.AppendRun("2", StyleUtils.CharStyleTextProps(ScrStyleNames.VerseNumber,
				Cache.DefaultVernWs));
			paraBldr.AppendRun("And the earth was formless and void... ",
				StyleUtils.CharStyleTextProps(null, Cache.DefaultVernWs));
			paraBldr.AppendRun("3", StyleUtils.CharStyleTextProps(ScrStyleNames.VerseNumber,
				Cache.DefaultVernWs));
			paraBldr.AppendRun("And God said, 'Let there be light...' ",
				StyleUtils.CharStyleTextProps(null, Cache.DefaultVernWs));
			paraBldr.CreateParagraph(sectionRev.ContentOA);

			// Find the diffs for Genesis
			m_bookMerger.DetectDifferences(null);

			// MoveFirst should return null because there are no diffs.
			Assert.IsNull(m_bookMerger.Differences.MoveFirst());
		}
		/// ------------------------------------------------------------------------------------
		/// <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="styleName">Style name for section</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>
		/// ------------------------------------------------------------------------------------
		private IScrSection CreateSection(string styleName, IScrBook book,
			params string[] sSectionHead)
		{
			// Create a section
			IScrSection section = AddSectionToMockedBook(book);

			// Create a section head for this section
			section.HeadingOA = Cache.ServiceLocator.GetInstance<IStTextFactory>().Create();
			StTxtParaBldr paraBldr = new StTxtParaBldr(Cache);
			for (int i = 0; i < sSectionHead.Length; i++)
			{
				paraBldr.ParaStyleName = styleName;
				paraBldr.AppendRun(sSectionHead[i],
					StyleUtils.CharStyleTextProps(null, Cache.DefaultVernWs));
				paraBldr.CreateParagraph(section.HeadingOA);
			}

			int verse = (styleName == ScrStyleNames.SectionHead) ? 1 : 0;
			section.ContentOA = Cache.ServiceLocator.GetInstance<IStTextFactory>().Create();
			section.VerseRefEnd = section.VerseRefStart =
				new ScrReference(book.CanonicalNum, 1, verse, m_scr.Versification);
			return section;
		}
Ejemplo n.º 5
0
		public void ParagraphFollowTest_EnterAtSectionHeadEnd_EmptyPara()
		{
			// Create a section
			string sectionHead = "Apples and Oranges";
			IScrSection sectionCur = CreateSection(m_genesis, sectionHead);
			// create an empty paragraph
			StTxtParaBldr paraBldr = new StTxtParaBldr(Cache);
			paraBldr.ParaStyleName = ScrStyleNames.NormalParagraph;
			paraBldr.CreateParagraph(sectionCur.ContentOA);
			// finish the section info
			m_draftView.RefreshDisplay();

			SelectionHelper selHelper = m_draftView.SetInsertionPoint(ScrSectionTags.kflidHeading, 0, 0);
			selHelper.IchAnchor = sectionHead.Length;
			selHelper.SetSelection(true);

			// Set the style follow property to a paragraph style.
			IStStyle styleHead = m_scr.FindStyle(ScrStyleNames.SectionHead);
			IStStyle stylePara = m_scr.FindStyle(ScrStyleNames.NormalParagraph);
			styleHead.NextRA = stylePara;

			// send an Enter key
			m_draftView.TeEditingHelper.OnKeyPress(new KeyPressEventArgs('\r'), Keys.None);

			// Make sure that the book still has one section with the same paragraphs and
			// that the IP is in the first body paragraph
			Assert.AreEqual(1, m_genesis.SectionsOS.Count);
			Assert.AreEqual(1, sectionCur.HeadingOA.ParagraphsOS.Count);
			Assert.AreEqual(1, sectionCur.ContentOA.ParagraphsOS.Count);
			selHelper = m_draftView.EditingHelper.CurrentSelection;
			Assert.AreEqual(4, selHelper.NumberOfLevels);
			Assert.AreEqual(ScrSectionTags.kflidContent, selHelper.LevelInfo[1].tag);
		}
Ejemplo n.º 6
0
		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);
		}
Ejemplo n.º 7
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Finalizes section references and checks if the current section has any heading text
		/// and content. If not, a single blank paragraph is written for whatever is missing.
		/// </summary>
		/// ------------------------------------------------------------------------------------
		protected void FinalizePrevSection()
		{
			if (m_currSection == null || !m_currSection.IsValidObject)
				return;

			int bcvRef = (m_firstImportedRef.IsEmpty) ? m_currSection.VerseRefMin :
				Math.Min(m_firstImportedRef, m_currSection.VerseRefMin);
			m_firstImportedRef = new ScrReference(bcvRef, m_scr.Versification);

			if (InMainImportDomain)
				return;

			// First, check if there is heading content. If not, add a blank paragraph.
			if (m_currSection.HeadingOA.ParagraphsOS.Count == 0)
			{
				StTxtParaBldr paraBldr = new StTxtParaBldr(m_cache);
					paraBldr.ParaStylePropsProxy =
						(m_fInScriptureText ? m_ScrSectionHeadParaProxy : m_DefaultIntroSectionHeadParaProxy);
					paraBldr.StringBuilder.SetIntPropValues(0, 0, (int)FwTextPropType.ktptWs,
						(int)FwTextPropVar.ktpvDefault, m_wsVern);
					paraBldr.CreateParagraph(m_sectionHeading);
				}

			// Now, check if there is content. If not, add a blank paragraph.
			if (m_currSection.ContentOA.ParagraphsOS.Count == 0)
			{
				StTxtParaBldr paraBldr = new StTxtParaBldr(m_cache);
					paraBldr.ParaStylePropsProxy =
						(m_fInScriptureText ? m_DefaultScrParaProxy : m_DefaultIntroParaProxy);
					paraBldr.StringBuilder.SetIntPropValues(0, 0, (int)FwTextPropType.ktptWs,
						(int)FwTextPropVar.ktpvDefault, m_wsVern);
					paraBldr.CreateParagraph(m_sectionContent);
				}

			m_fInScriptureText = !m_fCurrentSectionIsIntro;
		}
Ejemplo n.º 8
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="styleName">Style name for section</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>
		/// ------------------------------------------------------------------------------------
		private IScrSection CreateSection(string styleName, IScrBook book,
			params string[] sSectionHead)
		{
			// Create a section
			IScrSection section = AddSectionToMockedBook(book);

			// Create a section head for this section
			section.HeadingOA = Cache.ServiceLocator.GetInstance<IStTextFactory>().Create();
			StTxtParaBldr paraBldr = new StTxtParaBldr(Cache);
			for (int i = 0; i < sSectionHead.Length; i++)
			{
				paraBldr.ParaStyleName = styleName;
				paraBldr.AppendRun(sSectionHead[i],
					StyleUtils.CharStyleTextProps(null, Cache.DefaultVernWs));
				paraBldr.CreateParagraph(section.HeadingOA);
			}

			section.ContentOA = Cache.ServiceLocator.GetInstance<IStTextFactory>().Create();
			return section;
		}
Ejemplo n.º 9
0
		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());
		}
Ejemplo n.º 10
0
		public void ContentMultipleParasToSectionHead()
		{
			// create a book
			IScrBook book = CreateGenesis();
			// Create a section
			IScrSection sectionCur = CreateSection(book, "My aching head!");
			// create paragraph one holding chapter 1
			StTxtParaBldr paraBldr = new StTxtParaBldr(Cache);
			paraBldr.ParaStyleName = ScrStyleNames.NormalParagraph;
			paraBldr.AppendRun("1", StyleUtils.CharStyleTextProps(ScrStyleNames.ChapterNumber,
				Cache.DefaultVernWs));
			paraBldr.AppendRun("In the beginning, God created the heavens and the earth. ",
				StyleUtils.CharStyleTextProps(null, Cache.DefaultVernWs));
			paraBldr.CreateParagraph(sectionCur.ContentOA);
			// create paragraph that will be changed to a section heading
			paraBldr.ParaStyleName = ScrStyleNames.NormalParagraph;
			paraBldr.AppendRun("My other aching head!",
				StyleUtils.CharStyleTextProps(null, Cache.DefaultVernWs));
			paraBldr.CreateParagraph(sectionCur.ContentOA);
			// create paragraph that will be changed to a section heading
			paraBldr.ParaStyleName = ScrStyleNames.NormalParagraph;
			paraBldr.AppendRun("My third aching head!",
				StyleUtils.CharStyleTextProps(null, Cache.DefaultVernWs));
			paraBldr.CreateParagraph(sectionCur.ContentOA);
			// create paragraph three holding chapter 2
			paraBldr.ParaStyleName = ScrStyleNames.NormalParagraph;
			paraBldr.AppendRun("2", StyleUtils.CharStyleTextProps(ScrStyleNames.ChapterNumber,
				Cache.DefaultVernWs));
			paraBldr.AppendRun("Thus the heavens and the earth were completed in all their vast array. ",
				StyleUtils.CharStyleTextProps(null, Cache.DefaultVernWs));
			paraBldr.CreateParagraph(sectionCur.ContentOA);
			Assert.AreEqual(4, sectionCur.ContentOA.ParagraphsOS.Count);
			// finish the section info

			m_draftView.RefreshDisplay();

			// Create a range selection from paragraph 1 to paragraph 2.
			int iBook = 0; // assume that iBook 0 is Genesis
			int iSectionIP = 0; //section with 1:1 to 2:1
			int iParaIP = 1;
			int ichIP = 0;
			m_draftView.SetInsertionPoint(iBook, iSectionIP, iParaIP, ichIP, true);
			IVwSelection sel0 = m_draftView.RootBox.Selection;
			Assert.IsNotNull(sel0);
			m_draftView.SetInsertionPoint(iBook, iSectionIP, iParaIP + 1, ichIP, true);
			IVwSelection sel1 = m_draftView.RootBox.Selection;
			Assert.IsNotNull(sel1);
			IVwSelection sel = m_draftView.RootBox.MakeRangeSelection(sel0, sel1, true);
			Assert.IsNotNull(sel);

			// InsertSection should add a scripture section
			m_draftView.ApplyStyle(ScrStyleNames.SectionHead);
			Assert.AreEqual(2, book.SectionsOS.Count, "Should add a section");

			// setup variables for testing
			IScrSection existingSection = book.SectionsOS[iSectionIP];
			int iSectionIns = iSectionIP + 1;
			IScrSection createdSection = book.SectionsOS[iSectionIns];

			// Verify verse start and end refs
			Assert.AreEqual(1001001, existingSection.VerseRefMin,
				"Existing section should have same verse start ref");
			Assert.AreEqual(1001001, existingSection.VerseRefMax,
				"Existing section should have new verse end ref");
			Assert.AreEqual(1002001, createdSection.VerseRefMin,
				"New section should have correct verse start ref");
			Assert.AreEqual(1002001, createdSection.VerseRefMax,
				"New section should have correct verse end ref");

			// Verify section head
			Assert.AreEqual(2, createdSection.HeadingOA.ParagraphsOS.Count);
			Assert.AreEqual("My other aching head!",
				createdSection.HeadingOA[0].Contents.Text);
			Assert.AreEqual("My third aching head!",
				createdSection.HeadingOA[1].Contents.Text);
			Assert.AreEqual(1, createdSection.ContentOA.ParagraphsOS.Count);

			// Verify that selection is in heading of the new section
#if WANTTESTPORT // (TE): Need to check for selection at end of UOW
			Assert.IsTrue(m_draftView.TeEditingHelper.InSectionHead, "Should be in section heading");
			Assert.AreEqual(0, m_draftView.TeEditingHelper.BookIndex);
			Assert.AreEqual(iSectionIns, m_draftView.TeEditingHelper.SectionIndex);
			Assert.AreEqual(0, m_draftView.ParagraphIndex);

			// Check that end is in second paragraph of heading
			SelectionHelper helper = SelectionHelper.Create(m_draftView);
			SelLevInfo[] endInfo = helper.GetLevelInfo(SelectionHelper.SelLimitType.End);
			Assert.AreEqual(4, endInfo.Length);
			Assert.AreEqual(iSectionIns, endInfo[2].ihvo);
			Assert.AreEqual(ScrSectionTags.kflidHeading, endInfo[1].tag);
			Assert.AreEqual(1, endInfo[0].ihvo);
#endif
		}
Ejemplo n.º 11
0
		public void ParagraphFollowTest_EnterWithRangeSelection()
		{
			// Create a section
			string sectionHead = "Apples and Oranges";
			IScrSection sectionCur = CreateSection(m_genesis, sectionHead);
			// create an empty paragraph
			StTxtParaBldr paraBldr = new StTxtParaBldr(Cache);
			paraBldr.ParaStyleName = ScrStyleNames.NormalParagraph;
			paraBldr.CreateParagraph(sectionCur.ContentOA);
			// finish the section info
			m_draftView.RefreshDisplay();

			m_draftView.TeEditingHelper.SelectRangeOfChars(0, 0,
				ScrSectionTags.kflidHeading, 0, sectionHead.Length - 3,
				sectionHead.Length, true, true, false);

			// Set the style follow property to a paragraph style.
			IStStyle styleHead = m_scr.FindStyle(ScrStyleNames.SectionHead);
			IStStyle stylePara = m_scr.FindStyle(ScrStyleNames.NormalParagraph);
			styleHead.NextRA = stylePara;

			// send an Enter key
			m_draftView.TeEditingHelper.OnKeyPress(new KeyPressEventArgs('\r'), Keys.None);

			// Make sure that the book still has one section with the same paragraphs and
			// that the IP is in the first body paragraph. Also, the text of the section head
			// should be missing the last three letters that were selected.
			Assert.AreEqual(1, m_genesis.SectionsOS.Count);
			Assert.AreEqual(1, sectionCur.HeadingOA.ParagraphsOS.Count);
			Assert.AreEqual(1, sectionCur.ContentOA.ParagraphsOS.Count);
			SelectionHelper selHelper = m_draftView.EditingHelper.CurrentSelection;
			Assert.AreEqual(4, selHelper.NumberOfLevels);
			Assert.AreEqual(ScrSectionTags.kflidContent, selHelper.LevelInfo[1].tag);
			Assert.AreEqual(sectionHead.Substring(0, sectionHead.Length - 3),
				sectionCur.HeadingOA[0].Contents.Text);
		}
Ejemplo n.º 12
0
		public void ContentAllParasOfLastSectionToSectionHead()
		{
			ITsTextProps textRunProps = StyleUtils.CharStyleTextProps(null, Cache.DefaultVernWs);
			ITsTextProps chapterRunProps =
				StyleUtils.CharStyleTextProps(ScrStyleNames.ChapterNumber, Cache.DefaultVernWs);

			// create a book
			IScrBook book = CreateGenesis();
			// Create section one
			IScrSection section1 = CreateSection(book, "My aching head!");
			// create paragraph one holding chapter 1
			StTxtParaBldr paraBldr = new StTxtParaBldr(Cache);
			paraBldr.ParaStyleName = ScrStyleNames.NormalParagraph;
			paraBldr.AppendRun("1", chapterRunProps);
			paraBldr.AppendRun("In the beginning", textRunProps);
			paraBldr.CreateParagraph(section1.ContentOA);
			// create paragraph two holding text that really belongs in the section head
			paraBldr.ParaStyleName = ScrStyleNames.NormalParagraph;
			paraBldr.AppendRun("Ouch!",
				StyleUtils.CharStyleTextProps(null, Cache.DefaultVernWs));
			paraBldr.CreateParagraph(section1.ContentOA);
			Assert.AreEqual(2, section1.ContentOA.ParagraphsOS.Count);
			// finish the section info

			// Create section two
			IScrSection section2 = CreateSection(book, "My other aching head!");
			// create paragraph three holding chapter 2
			paraBldr.ParaStyleName = ScrStyleNames.NormalParagraph;
			paraBldr.AppendRun("Thus the heavens", textRunProps);
			paraBldr.CreateParagraph(section2.ContentOA);
			paraBldr.AppendRun("were completed", textRunProps);
			paraBldr.CreateParagraph(section2.ContentOA);
			Assert.AreEqual(2, section2.ContentOA.ParagraphsOS.Count);
			// finish the section info

			m_draftView.RefreshDisplay();

			// Set the IP at the beginning of the 2nd paragraph in the 1st section.
			int iBook = 0; // assume that iBook 0 is Genesis
			int iSectionIP = 1; //section with 2:1 to 2:1
			int iParaIP = 0;
			int ichIP = 0;

			// Put the IP in place
			m_draftView.SetInsertionPoint(iBook, iSectionIP, iParaIP, ichIP, true);
			IVwSelection sel0 = m_draftView.RootBox.Selection;
			Assert.IsNotNull(sel0);
			m_draftView.SetInsertionPoint(iBook, iSectionIP, iParaIP + 1, ichIP, true);
			IVwSelection sel1 = m_draftView.RootBox.Selection;
			Assert.IsNotNull(sel1);
			IVwSelection sel = m_draftView.RootBox.MakeRangeSelection(sel0, sel1, true);
			Assert.IsNotNull(sel);

			// ApplyStyle should not create a new section, but should move paragraph
			// from content of section one to heading of section two
			m_draftView.ApplyStyle(ScrStyleNames.SectionHead);
			Assert.AreEqual(2, book.SectionsOS.Count, "Should not be combined sections");

			// Verify verse start and end refs
			Assert.AreEqual(1001001, section2.VerseRefMin,
				"Remaining section should have same verse start ref");
			Assert.AreEqual(1001001, section2.VerseRefMax,
				"Remaining section should have correct verse end ref");

			// Verify paragraph counts of section 1
			Assert.AreEqual(1, section1.HeadingOA.ParagraphsOS.Count);
			Assert.AreEqual(2, section1.ContentOA.ParagraphsOS.Count);

			// Verify section head of section 2
			Assert.AreEqual(3, section2.HeadingOA.ParagraphsOS.Count);
			Assert.AreEqual("My other aching head!",
				section2.HeadingOA[0].Contents.Text);
			ITsTextProps ttp = section2.HeadingOA[0].StyleRules;
			Assert.AreEqual(ScrStyleNames.SectionHead,
				ttp.GetStrPropValue((int)FwTextPropType.ktptNamedStyle));
			Assert.AreEqual("Thus the heavens",
				section2.HeadingOA[1].Contents.Text);
			ttp = section2.HeadingOA[1].StyleRules;
			Assert.AreEqual(ScrStyleNames.SectionHead,
				ttp.GetStrPropValue((int)FwTextPropType.ktptNamedStyle));
			Assert.AreEqual("were completed",
				section2.HeadingOA[2].Contents.Text);

			Assert.AreEqual(1, section2.ContentOA.ParagraphsOS.Count);
			IStTxtPara para = section2.ContentOA[0];
			Assert.AreEqual(0, para.Contents.Length);


			// Verify that selection is in second paragraph of remaining section
#if WANTTESTPORT // (TE): Need to check for selection at end of UOW
			Assert.IsTrue(m_draftView.TeEditingHelper.InSectionHead, "Should be in section heading");
			Assert.AreEqual(0, m_draftView.TeEditingHelper.BookIndex);
			Assert.AreEqual(1, m_draftView.TeEditingHelper.SectionIndex);
			Assert.AreEqual(1, m_draftView.ParagraphIndex);
#endif
		}
Ejemplo n.º 13
0
		public void ContentMidParaToSectionHead()
		{
			// create a book
			IScrBook book = CreateGenesis();
			// Create a section
			IScrSection sectionCur = CreateSection(book, "My aching head!");
			// create paragraph one holding chapter 1
			StTxtParaBldr paraBldr = new StTxtParaBldr(Cache);
			paraBldr.ParaStyleName = ScrStyleNames.NormalParagraph;
			paraBldr.AppendRun("1", StyleUtils.CharStyleTextProps(ScrStyleNames.ChapterNumber,
				Cache.DefaultVernWs));
			paraBldr.AppendRun("In the beginning, God created the heavens and the earth. ",
				StyleUtils.CharStyleTextProps(null, Cache.DefaultVernWs));
			paraBldr.CreateParagraph(sectionCur.ContentOA);
			// create paragraph that will be changed to a section heading
			paraBldr.ParaStyleName = ScrStyleNames.NormalParagraph;
			paraBldr.AppendRun("My other aching head!",
				StyleUtils.CharStyleTextProps(null, Cache.DefaultVernWs));
			paraBldr.CreateParagraph(sectionCur.ContentOA);
			// create paragraph three holding chapter 2
			paraBldr.ParaStyleName = ScrStyleNames.NormalParagraph;
			paraBldr.AppendRun("2", StyleUtils.CharStyleTextProps(ScrStyleNames.ChapterNumber,
				Cache.DefaultVernWs));
			paraBldr.AppendRun("Thus the heavens and the earth were completed in all their vast array. ",
				StyleUtils.CharStyleTextProps(null, Cache.DefaultVernWs));
			paraBldr.CreateParagraph(sectionCur.ContentOA);
			Assert.AreEqual(3, sectionCur.ContentOA.ParagraphsOS.Count);
			// finish the section info

			m_draftView.RefreshDisplay();

			// Set the IP at the beginning of the 2nd paragraph in the 1st section.
			int iBook = 0; // assume that iBook 0 is Genesis
			int iSectionIP = 0; //section with 1:1 to 2:1
			int iParaIP = 1;
			int ichIP = 0;

			// Put the IP in place
			m_draftView.SetInsertionPoint(iBook, iSectionIP, iParaIP, ichIP, true);

			// InsertSection should add a scripture section
			m_draftView.ApplyStyle(ScrStyleNames.SectionHead);
			Assert.AreEqual(2, book.SectionsOS.Count, "Should add a section");

			// setup variables for testing
			IScrSection existingSection = book.SectionsOS[iSectionIP];
			int iSectionIns = iSectionIP + 1;
			IScrSection createdSection = book.SectionsOS[iSectionIns];

			// Verify verse start and end refs
			Assert.AreEqual(1001001, existingSection.VerseRefMin,
				"Existing section should have same verse start ref");
			Assert.AreEqual(1001001, existingSection.VerseRefMax,
				"Existing section should have new verse end ref");
			Assert.AreEqual(1002001, createdSection.VerseRefMin,
				"New section should have correct verse start ref");
			Assert.AreEqual(1002001, createdSection.VerseRefMax,
				"New section should have correct verse end ref");

			// Verify section head
			Assert.AreEqual("My other aching head!",
				createdSection.HeadingOA[0].Contents.Text);
			Assert.AreEqual(1, createdSection.HeadingOA.ParagraphsOS.Count);
			Assert.AreEqual(1, createdSection.ContentOA.ParagraphsOS.Count);

			// Verify that selection is in heading of the new section
#if WANTTESTPORT // (TE): Need to check for selection at end of UOW
			Assert.IsTrue(m_draftView.TeEditingHelper.InSectionHead, "Should be in section heading");
			Assert.AreEqual(0, m_draftView.TeEditingHelper.BookIndex);
			Assert.AreEqual(iSectionIns, m_draftView.TeEditingHelper.SectionIndex);
			Assert.AreEqual(0, m_draftView.ParagraphIndex);
#endif
		}
Ejemplo n.º 14
0
		public void ContentLastIntroParaToIntroSectionHead()
		{
			// create a book
			IScrBook book = CreateGenesis();
			// Create section one - an introduction section
			IScrSection section1 = CreateSection(ScrStyleNames.IntroSectionHead, book,
				"My aching head!");
			// create paragraph one holding chapter 1
			StTxtParaBldr paraBldr = new StTxtParaBldr(Cache);
			paraBldr.ParaStyleName = ScrStyleNames.IntroParagraph;
			paraBldr.AppendRun("This is the first book of the Bible",
				StyleUtils.CharStyleTextProps(null, Cache.DefaultVernWs));
			paraBldr.CreateParagraph(section1.ContentOA);
			// create paragraph two holding text that really belongs in the section head
			paraBldr.ParaStyleName = ScrStyleNames.IntroParagraph;
			paraBldr.AppendRun("Ouch!",
				StyleUtils.CharStyleTextProps(null, Cache.DefaultVernWs));
			paraBldr.CreateParagraph(section1.ContentOA);
			Assert.AreEqual(2, section1.ContentOA.ParagraphsOS.Count);
			// finish the section info

			// Create section two
			IScrSection section2 = CreateSection(book, "My other aching head!");
			// create paragraph three holding chapter 2
			paraBldr.ParaStyleName = ScrStyleNames.NormalParagraph;
			paraBldr.AppendRun("2", StyleUtils.CharStyleTextProps(ScrStyleNames.ChapterNumber,
				Cache.DefaultVernWs));
			paraBldr.AppendRun("Thus the heavens and the earth were completed in all their vast array. ",
				StyleUtils.CharStyleTextProps(null, Cache.DefaultVernWs));
			paraBldr.CreateParagraph(section2.ContentOA);
			Assert.AreEqual(1, section2.ContentOA.ParagraphsOS.Count);
			// finish the section info

			m_draftView.RefreshDisplay();

			// Set the IP at the beginning of the 2nd paragraph in the 1st section.
			int iBook = 0; // assume that iBook 0 is Genesis
			int iSectionIP = 0; //intro section
			int iParaIP = 1;	// last intro para
			int ichIP = 0;

			// Put the IP in place
			m_draftView.SetInsertionPoint(iBook, iSectionIP, iParaIP, ichIP, true);

			// ApplyStyle should create a new section with the intro paragraph as the
			// section head and an empty body.
			m_draftView.ApplyStyle(ScrStyleNames.IntroSectionHead);
			Assert.AreEqual(3, book.SectionsOS.Count, "Should add a section");

			// Verify verse start and end refs
			Assert.AreEqual(1001000, section1.VerseRefMin,
				"Existing section should have same verse start ref");
			Assert.AreEqual(1001000, section1.VerseRefMax,
				"New section should have correct verse end ref");
			section2 = book.SectionsOS[1];
			Assert.AreEqual(1001000, section2.VerseRefMin,
				"Existing section should have same verse start ref");
			Assert.AreEqual(1001000, section2.VerseRefMax,
				"New section should have correct verse end ref");

			// Verify Contents of section 1
			Assert.AreEqual(1, section1.ContentOA.ParagraphsOS.Count);

			// Verify section head of section 2
			Assert.AreEqual(1, section2.HeadingOA.ParagraphsOS.Count);
			Assert.AreEqual("Ouch!",
				section2.HeadingOA[0].Contents.Text);
			ITsTextProps ttp = section2.HeadingOA[0].StyleRules;
			Assert.AreEqual(ScrStyleNames.IntroSectionHead,
				ttp.GetStrPropValue((int)FwTextPropType.ktptNamedStyle));
			Assert.AreEqual(1, section2.ContentOA.ParagraphsOS.Count);
			Assert.IsNull(section2.ContentOA[0].Contents.Text);
			ttp = section2.ContentOA[0].StyleRules;
			Assert.AreEqual(ScrStyleNames.IntroParagraph,
				ttp.GetStrPropValue((int)FwTextPropType.ktptNamedStyle));

			// Verify that selection is in first paragraph of section two heading
#if WANTTESTPORT // (TE): Need to check for selection at end of UOW
			Assert.IsTrue(m_draftView.TeEditingHelper.InSectionHead, "Should be in section heading");
			Assert.AreEqual(0, m_draftView.TeEditingHelper.BookIndex);
			Assert.AreEqual(1, m_draftView.TeEditingHelper.SectionIndex);
			Assert.AreEqual(0, m_draftView.ParagraphIndex);
#endif
		}
Ejemplo n.º 15
0
		public void ContentOnlyParaToSectionHead()
		{
			// create a book
			IScrBook book = CreateGenesis();
			// Create a section
			IScrSection sectionCur = CreateSection(book, "My aching head!");
			// create paragraph one holding text that really belongs in the section head
			StTxtParaBldr paraBldr = new StTxtParaBldr(Cache);
			paraBldr.ParaStyleName = ScrStyleNames.NormalParagraph;
			paraBldr.AppendRun("Ouch!",
				StyleUtils.CharStyleTextProps(null, Cache.DefaultVernWs));
			paraBldr.CreateParagraph(sectionCur.ContentOA);
			Assert.AreEqual(1, sectionCur.ContentOA.ParagraphsOS.Count);

			m_draftView.RefreshDisplay();

			// Set the IP at the beginning of the paragraph in the section.
			int iBook = 0; // assume that iBook 0 is Genesis
			int iSectionIP = 0; //section with content to become section head
			int iParaIP = 0;
			int ichIP = 0;

			// Put the IP in place
			m_draftView.SetInsertionPoint(iBook, iSectionIP, iParaIP, ichIP, true);

			// ApplyStyle should not add a scripture section
			m_draftView.ApplyStyle(ScrStyleNames.SectionHead);
			Assert.AreEqual(1, book.SectionsOS.Count, "Should not add a section");

			// setup variables for testing
			IScrSection section = book.SectionsOS[iSectionIP];

			// Verify verse start and end refs
			Assert.AreEqual(1001001, section.VerseRefMin,
				"Existing section should have same verse start ref");
			Assert.AreEqual(1001001, section.VerseRefMax,
				"New section should have correct verse end ref");

			// Verify section head
			Assert.AreEqual(2, section.HeadingOA.ParagraphsOS.Count, "Should have 2 heading paragraphs");
			Assert.AreEqual("My aching head!",
				section.HeadingOA[0].Contents.Text);
			Assert.AreEqual("Ouch!",
				section.HeadingOA[1].Contents.Text);
			ITsTextProps ttp = section.HeadingOA[1].StyleRules;
			Assert.AreEqual(ScrStyleNames.SectionHead,
				ttp.GetStrPropValue((int)FwTextPropType.ktptNamedStyle));

			// Verify Contents - should now be an empty paragraph
			Assert.AreEqual(1, section.ContentOA.ParagraphsOS.Count, "Should have one content paragraph");
			IStTxtPara para = section.ContentOA[0];
			Assert.AreEqual(0, para.Contents.Length);
			Assert.AreEqual(ScrStyleNames.NormalParagraph,
				para.StyleRules.GetStrPropValue((int)FwTextPropType.ktptNamedStyle));


			// Verify that selection is in second para of the section head
#if WANTTESTPORT // (TE): Need to check for selection at end of UOW
			Assert.IsTrue(m_draftView.TeEditingHelper.InSectionHead, "Should be in section heading");
			Assert.AreEqual(0, m_draftView.TeEditingHelper.BookIndex);
			Assert.AreEqual(0, m_draftView.TeEditingHelper.SectionIndex);
			Assert.AreEqual(1, m_draftView.ParagraphIndex);
#endif
		}
Ejemplo n.º 16
0
		public void ContentParaToLine1()
		{
			// create a book
			IScrBook book = CreateGenesis();
			// Create a section & section head
			IScrSection sectionCur = CreateSection(book, "My aching head!");
			// create content paragraph
			StTxtParaBldr paraBldr = new StTxtParaBldr(Cache);
			paraBldr.ParaStyleName = ScrStyleNames.NormalParagraph;
			paraBldr.AppendRun("Glory!",
				StyleUtils.CharStyleTextProps(null, Cache.DefaultVernWs));
			paraBldr.CreateParagraph(sectionCur.ContentOA);
			Assert.AreEqual(1, sectionCur.ContentOA.ParagraphsOS.Count);

			m_draftView.RefreshDisplay();

			// Set the IP at the beginning of the content paragraph in the section.
			int iBook = 0; // assume that iBook 0 is Genesis
			int iSectionIP = 0; //section with content
			int iParaIP = 0;
			int ichIP = 0;

			// Put the IP in place
			m_draftView.SetInsertionPoint(iBook, iSectionIP, iParaIP, ichIP, true);

			// ApplyStyle
			m_draftView.ApplyStyle(ScrStyleNames.Line1);

			// should not add a scripture section
			Assert.AreEqual(1, book.SectionsOS.Count, "Should not add a section");

			// setup variables for testing
			IScrSection section = book.SectionsOS[iSectionIP];

			// Verify Content paragraph
			Assert.AreEqual(1, section.ContentOA.ParagraphsOS.Count, "Should have one content paragraph");
			IStTxtPara para = section.ContentOA[0];
			Assert.AreEqual("Glory!", para.Contents.Text);
			Assert.AreEqual(ScrStyleNames.Line1,
				para.StyleRules.GetStrPropValue((int)FwTextPropType.ktptNamedStyle));


			// Verify that selection is in the content
#if WANTTESTPORT // (TE): Need to check for selection at end of UOW
			Assert.IsTrue(m_draftView.TeEditingHelper.InContent, "Should be in section content");
			Assert.AreEqual(0, m_draftView.TeEditingHelper.BookIndex);
			Assert.AreEqual(0, m_draftView.TeEditingHelper.SectionIndex);
			Assert.AreEqual(1, m_draftView.ParagraphIndex);
#endif
		}
Ejemplo n.º 17
0
		public void ParagraphFollowTest_EnterAtSectionHeadEnd_NonEmptyPara()
		{
			// Create a section
			string sectionHead = "Apples and Oranges";
			IScrSection sectionCur = CreateSection(m_genesis, sectionHead);
			// create an empty paragraph
			StTxtParaBldr paraBldr = new StTxtParaBldr(Cache);
			paraBldr.ParaStyleName = ScrStyleNames.NormalParagraph;
			paraBldr.AppendRun("A dissertation on the sections of fruit.",
				StyleUtils.CharStyleTextProps(null, Cache.DefaultVernWs));
			paraBldr.CreateParagraph(sectionCur.ContentOA);
			// finish the section info
			m_draftView.RefreshDisplay();

			m_draftView.SetInsertionPoint(ScrSectionTags.kflidHeading, 0, 0);
			SelectionHelper selHelper = m_draftView.EditingHelper.CurrentSelection;
			selHelper.IchAnchor = sectionHead.Length;
			selHelper.SetSelection(true);

			// Set the style follow property to a paragraph style.
			IStStyle styleHead = m_scr.FindStyle(ScrStyleNames.SectionHead);
			IStStyle stylePara = m_scr.FindStyle("Line1");
			styleHead.NextRA = stylePara;

			// send an Enter key
			m_draftView.TeEditingHelper.OnKeyPress(new KeyPressEventArgs('\r'), Keys.None);

			// Make sure that the book has one section with two body paragraphs and
			// that the IP is in the first body paragraph
			Assert.AreEqual(1, m_genesis.SectionsOS.Count);
			Assert.AreEqual(1, sectionCur.HeadingOA.ParagraphsOS.Count);
			Assert.AreEqual(2, sectionCur.ContentOA.ParagraphsOS.Count);
			selHelper = m_draftView.EditingHelper.CurrentSelection;
			Assert.AreEqual(4, selHelper.NumberOfLevels);
			Assert.AreEqual(ScrSectionTags.kflidContent, selHelper.LevelInfo[1].tag);
			Assert.AreEqual(0, selHelper.LevelInfo[0].ihvo);

			// Make sure the first paragraph is empty and that it has the correct follow on style

			IStTxtPara firstPara = (IStTxtPara)sectionCur.ContentOA[0];
			Assert.AreEqual(0, firstPara.Contents.Length);
			Assert.AreEqual(stylePara.Name,
				firstPara.StyleRules.GetStrPropValue((int)FwTextPropType.ktptNamedStyle));
		}
Ejemplo n.º 18
0
		public void SectionHeadAllParasToParagraph()
		{
			// create a book
			IScrBook book = CreateGenesis();
			// Create section 1
			IScrSection sectionCur = CreateSection(book, "My aching head!");
			// create paragraph one holding chapter 1
			StTxtParaBldr paraBldr = new StTxtParaBldr(Cache);
			paraBldr.ParaStyleName = ScrStyleNames.NormalParagraph;
			paraBldr.AppendRun("1", StyleUtils.CharStyleTextProps(ScrStyleNames.ChapterNumber,
				Cache.DefaultVernWs));
			paraBldr.AppendRun("In the beginning, God created the heavens and the earth. ",
				StyleUtils.CharStyleTextProps(null, Cache.DefaultVernWs));
			paraBldr.CreateParagraph(sectionCur.ContentOA);

			// create section 2
			sectionCur = CreateSection(book, "My other aching head!",
				"Second paragraph of heading");
			// create paragraph holding chapter 2
			paraBldr.ParaStyleName = ScrStyleNames.NormalParagraph;
			paraBldr.AppendRun("2", StyleUtils.CharStyleTextProps(ScrStyleNames.ChapterNumber,
				Cache.DefaultVernWs));
			paraBldr.AppendRun("Thus the heavens and the earth were completed in all their vast array. ",
				StyleUtils.CharStyleTextProps(null, Cache.DefaultVernWs));
			paraBldr.CreateParagraph(sectionCur.ContentOA);
			// finish the section info

			m_draftView.RefreshDisplay();

			// Set the IP in the 2nd section.
			int iBook = 0; // assume that iBook 0 is Genesis
			int iSectionIP = 1; //section with 2:1

			// Make a range selection that covers both paragraphs of section heading
			m_draftView.SetInsertionPoint(ScrSectionTags.kflidHeading,
				iBook, iSectionIP);
			SelectionHelper helper = SelectionHelper.Create(m_draftView);
			// adjust end point level info to point to second paragraph
			SelLevInfo[] levInfo = helper.GetLevelInfo(SelectionHelper.SelLimitType.End);
			levInfo[0].ihvo = 1;
			helper.SetLevelInfo(SelectionHelper.SelLimitType.End, levInfo);
			helper.IchEnd = 0;	// needed to make selection a range selection
			helper.SetSelection(true);


			// InsertSection should add a scripture section
			Assert.AreEqual(2, book.SectionsOS.Count, "Two sections before ApplyStyle");
			m_draftView.ApplyStyle(ScrStyleNames.NormalParagraph);
			Assert.AreEqual(1, book.SectionsOS.Count, "Should remove a section");

			// setup variables for testing
			IScrSection section = book.SectionsOS[0];

			// Verify verse start and end refs
			Assert.AreEqual(1001001, section.VerseRefMin,
				"Existing section should have same verse start ref");
			Assert.AreEqual(1002001, section.VerseRefMax,
				"New section should have correct verse end ref");

			// Verify section paragraphs
			Assert.AreEqual(1, section.HeadingOA.ParagraphsOS.Count);
			Assert.AreEqual(4, section.ContentOA.ParagraphsOS.Count);
			IStTxtPara para = section.ContentOA[1];
			Assert.AreEqual("My other aching head!", para.Contents.Text);
			Assert.AreEqual(ScrStyleNames.NormalParagraph,
				para.StyleRules.GetStrPropValue((int)FwTextPropType.ktptNamedStyle));
			para = section.ContentOA[2];
			Assert.AreEqual("Second paragraph of heading", para.Contents.Text);
			Assert.AreEqual(ScrStyleNames.NormalParagraph,
				para.StyleRules.GetStrPropValue((int)FwTextPropType.ktptNamedStyle));

			// Verify that selection is in paragraph that was the heading of the
			// removed section
#if WANTTESTPORT // (TE): Need to check for selection at end of UOW
			Assert.AreEqual(0, m_draftView.TeEditingHelper.BookIndex);
			Assert.AreEqual(0, m_draftView.TeEditingHelper.SectionIndex);
			Assert.AreEqual(1, m_draftView.ParagraphIndex);
#endif
		}
Ejemplo n.º 19
0
		public void ParagraphFollowTest_EnterWithBigRangeSelection()
		{
			// Create a section
			string sectionHead = "Apples and Oranges";
			IScrSection sectionCur = CreateSection(m_genesis, sectionHead);
			// create a paragraph
			StTxtParaBldr paraBldr = new StTxtParaBldr(Cache);
			paraBldr.ParaStyleName = ScrStyleNames.NormalParagraph;
			string bodyText = "A complex dissertation on the sections of fruit.";
			paraBldr.AppendRun(bodyText, StyleUtils.CharStyleTextProps(null, Cache.DefaultVernWs));
			paraBldr.CreateParagraph(sectionCur.ContentOA);
			// finish the section info
			m_draftView.RefreshDisplay();

			// make a selection that goes from the beginning of the section head into the text
			// of the first paragraph.
			m_draftView.SetInsertionPoint(ScrSectionTags.kflidHeading, 0, 0);
			IVwSelection sel1 = m_draftView.TeEditingHelper.CurrentSelection.Selection;
			m_draftView.SetInsertionPoint(m_genesis.OwnOrd, 0, 0, 5, true);
			IVwSelection sel2 = m_draftView.TeEditingHelper.CurrentSelection.Selection;
			IVwSelection sel = m_draftView.RootBox.MakeRangeSelection(sel1, sel2, true);

			// Set the style follow property to a paragraph style.
			IStStyle styleHead = m_scr.FindStyle(ScrStyleNames.SectionHead);
			IStStyle stylePara = m_scr.FindStyle(ScrStyleNames.NormalParagraph);
			styleHead.NextRA = stylePara;

			// send an Enter key
			m_draftView.TeEditingHelper.OnKeyPress(new KeyPressEventArgs('\r'), Keys.None);

			// Make sure that the nothing changed.
			Assert.AreEqual(1, m_genesis.SectionsOS.Count);
			Assert.AreEqual(1, sectionCur.HeadingOA.ParagraphsOS.Count);
			Assert.AreEqual(1, sectionCur.ContentOA.ParagraphsOS.Count);
			sel = m_draftView.TeEditingHelper.CurrentSelection.Selection;
			Assert.IsTrue(sel.IsRange);
		}
Ejemplo n.º 20
0
		public void SectionHeadFirstParaToParagraph()
		{
			// create a book
			IScrBook book = CreateGenesis();
			// Create section 1
			IScrSection sectionCur = CreateSection(book, "My aching head!");
			// create paragraph one holding chapter 1
			StTxtParaBldr paraBldr = new StTxtParaBldr(Cache);
			paraBldr.ParaStyleName = ScrStyleNames.NormalParagraph;
			paraBldr.AppendRun("1", StyleUtils.CharStyleTextProps(ScrStyleNames.ChapterNumber,
				Cache.DefaultVernWs));
			paraBldr.AppendRun("In the beginning, God created the heavens and the earth. ",
				StyleUtils.CharStyleTextProps(null, Cache.DefaultVernWs));
			paraBldr.CreateParagraph(sectionCur.ContentOA);

			// create section 2
			sectionCur = CreateSection(book, "My other aching head!",
				"Second paragraph of heading");
			// create paragraph holding chapter 2
			paraBldr.ParaStyleName = ScrStyleNames.NormalParagraph;
			paraBldr.AppendRun("2", StyleUtils.CharStyleTextProps(ScrStyleNames.ChapterNumber,
				Cache.DefaultVernWs));
			paraBldr.AppendRun("Thus the heavens and the earth were completed in all their vast array. ",
				StyleUtils.CharStyleTextProps(null, Cache.DefaultVernWs));
			paraBldr.CreateParagraph(sectionCur.ContentOA);
			// finish the section info

			m_draftView.RefreshDisplay();

			// Set the IP in the 2nd section.
			int iBook = 0; // assume that iBook 0 is Genesis
			int iSectionIP = 1; //section with 2:1

			// Make a range selection that covers both paragraphs of section heading
			m_draftView.SetInsertionPoint(ScrSectionTags.kflidHeading,
				iBook, iSectionIP);

			// ApplyStyle should move paragraph from heading, but not change number
			// of sections.
			Assert.AreEqual(2, book.SectionsOS.Count, "Two sections before ApplyStyle");
			m_draftView.ApplyStyle(ScrStyleNames.NormalParagraph);
			Assert.AreEqual(2, book.SectionsOS.Count, "Two sections after ApplyStyle");

			// setup variables for testing
			IScrSection section1 = book.SectionsOS[0];
			IScrSection section2 = book.SectionsOS[1];

			// Verify section paragraphs
			Assert.AreEqual(1, section1.HeadingOA.ParagraphsOS.Count);
			Assert.AreEqual(2, section1.ContentOA.ParagraphsOS.Count);
			IStTxtPara para = section1.ContentOA[1];
			Assert.AreEqual("My other aching head!", para.Contents.Text);
			Assert.AreEqual(ScrStyleNames.NormalParagraph,
				para.StyleRules.GetStrPropValue((int)FwTextPropType.ktptNamedStyle));
			para = section2.HeadingOA[0];
			Assert.AreEqual("Second paragraph of heading", para.Contents.Text);
			Assert.AreEqual(ScrStyleNames.SectionHead,
				para.StyleRules.GetStrPropValue((int)FwTextPropType.ktptNamedStyle));
			Assert.AreEqual(1, section2.HeadingOA.ParagraphsOS.Count);
			Assert.AreEqual(1, section2.ContentOA.ParagraphsOS.Count);

			// Verify that selection is in paragraph that was the heading of the
			// second section
#if WANTTESTPORT // (TE): Need to check for selection at end of UOW
			Assert.AreEqual(0, m_draftView.TeEditingHelper.BookIndex);
			Assert.AreEqual(0, m_draftView.TeEditingHelper.SectionIndex);
			Assert.AreEqual(1, m_draftView.ParagraphIndex);
#endif
		}
Ejemplo n.º 21
0
		public void ParagraphFollowTest_EnterBetweenSectionHeadParas()
		{
			// Create a section
			string sectionHead = "Apples and Oranges";
			IScrSection sectionCur = CreateSection(m_genesis, sectionHead);

			// Add a second paragraph to the section head
			StTxtParaBldr paraBldr = new StTxtParaBldr(Cache);
			paraBldr.ParaStyleName = ScrStyleNames.SectionHead;
			paraBldr.AppendRun("Peaches and Bananas",
				StyleUtils.CharStyleTextProps(null, Cache.DefaultVernWs));
			paraBldr.CreateParagraph(sectionCur.HeadingOA);

			// create a paragraph
			paraBldr.ParaStyleName = ScrStyleNames.NormalParagraph;
			string bodyText = "A complex dissertation on the sections of fruit.";
			paraBldr.AppendRun(bodyText, StyleUtils.CharStyleTextProps(null, Cache.DefaultVernWs));
			paraBldr.CreateParagraph(sectionCur.ContentOA);
			// finish the section info
			m_draftView.RefreshDisplay();

			m_draftView.SetInsertionPoint(ScrSectionTags.kflidHeading, 0, 0);
			SelectionHelper selHelper = m_draftView.EditingHelper.CurrentSelection;
			selHelper.IchAnchor = sectionHead.Length;
			selHelper.IchEnd = sectionHead.Length;
			Assert.IsTrue(selHelper.SetSelection(true) != null);

			// Set the style follow property to a paragraph style.
			IStStyle styleHead = m_scr.FindStyle(ScrStyleNames.SectionHead);
			IStStyle stylePara = m_scr.FindStyle("Line1");
			styleHead.NextRA = stylePara;

			// send an Enter key
			m_draftView.TeEditingHelper.OnKeyPress(new KeyPressEventArgs('\r'), Keys.None);

			// Make sure that the book has two sections each with one paragraph. The first section
			// will have a new empty paragraph and the second section will have the old paragraph
			// contents. The IP is in the first body paragraph of the first section.
			Assert.AreEqual(2, m_genesis.SectionsOS.Count);
			IScrSection section1 = m_genesis.SectionsOS[0];
			Assert.AreEqual(1, section1.HeadingOA.ParagraphsOS.Count);
			Assert.AreEqual(1, section1.ContentOA.ParagraphsOS.Count);
			// Make sure the first paragraph is empty and that it has the correct follow on style
			IStTxtPara firstPara = (IStTxtPara)section1.ContentOA[0];
			Assert.AreEqual(0, firstPara.Contents.Length);
			Assert.AreEqual(stylePara.Name,
				firstPara.StyleRules.GetStrPropValue((int)FwTextPropType.ktptNamedStyle));

			// get the second section and check that it has one paragraph and that it has the same content
			IScrSection section2 = m_genesis.SectionsOS[1];
			Assert.AreEqual(1, section2.HeadingOA.ParagraphsOS.Count);
			Assert.AreEqual(1, section2.ContentOA.ParagraphsOS.Count);
			// Make sure the first paragraph is empty and that it has the correct follow on style
			IStTxtPara firstPara2 = (IStTxtPara)section2.ContentOA[0];
			Assert.AreEqual(bodyText, firstPara2.Contents.Text);

			// Verify that selection is in first content paragraph of first section
			selHelper = m_draftView.EditingHelper.CurrentSelection;
			Assert.AreEqual(4, selHelper.NumberOfLevels);
			Assert.AreEqual(0, selHelper.LevelInfo[2].ihvo);
			Assert.AreEqual(ScrSectionTags.kflidContent, selHelper.LevelInfo[1].tag);
			Assert.AreEqual(0, selHelper.LevelInfo[0].ihvo);
		}
Ejemplo n.º 22
0
		/// -----------------------------------------------------------------------------------
		/// <summary>
		/// If user presses Enter and a new style is applied to the following paragraph, we
		/// need to mark that style as being in use. If in a section Head, we might need to fix
		/// the structure.
		/// </summary>
		/// <param name="stuInput">input string</param>
		/// <param name="ss">Status of Shift/Control/Alt key</param>
		/// <param name="modifiers">key modifiers - shift status, etc.</param>
		/// -----------------------------------------------------------------------------------
		protected void HandleEnterKey(string stuInput, VwShiftStatus ss, Keys modifiers)
		{
			if (IsPictureSelected) // Enter should do nothing if a picture or caption is selected.
				return;

			int defVernWs = m_cache.DefaultVernWs;
			SelLevInfo[] levInfo;
			// If we are at the end of a heading paragraph, we need to check the "next" style to
			// see if it is a body type. If it is not, then allow processing to proceed as normal.
			// If it is a body type, then don't create a new paragraph, just move down to the start
			// of the first body paragraph in the section.
			if (InSectionHead)
			{
				// if the selection is a range selection then try to delete the selected text first.
				if (CurrentSelection.Selection.IsRange)
				{
					levInfo = CurrentSelection.GetLevelInfo(SelectionHelper.SelLimitType.Top);
					ITsStrFactory factory = TsStrFactoryClass.Create();
					CurrentSelection.Selection.ReplaceWithTsString(
						factory.MakeString(string.Empty, defVernWs));
					// If selection is still a range selection, the deletion failed and we don't
					// need to do anything else.
					if (CurrentSelection == null || CurrentSelection.Selection.IsRange || !InSectionHead)
						return;
				}

				// If the heading style has a following style that is a body style and we are at the
				// end of the paragraph then move the IP to the beginning of the body paragraph.
				levInfo = CurrentSelection.GetLevelInfo(SelectionHelper.SelLimitType.Anchor);
				// This is the paragraph that was originally selected
				IStTxtPara headPara = m_repoScrTxtPara.GetObject(levInfo[0].hvo);
				IStStyle headParaStyle = m_scr.FindStyle(headPara.StyleName);
				IStStyle followStyle = headParaStyle != null ? headParaStyle.NextRA : null;

				if (followStyle != null && followStyle.Structure == StructureValues.Body &&
					SelectionAtEndParagraph())
				{
					// if there is another section head paragraph, then the section needs to be split
					IScrSection section = ((ITeView)Control).LocationTracker.GetSection(CurrentSelection,
						SelectionHelper.SelLimitType.Anchor);
					// Changes made to text will destroy the selection, so we have to remember
					// the current locations.
					int iBook = BookIndex;
					int iSection = SectionIndex;
					if (CurrentSelection.LevelInfo[0].ihvo < section.HeadingOA.ParagraphsOS.Count - 1)
					{

						// break the section
						// create a new empty paragraph in the first section
						// set the IP to the start of the new paragraph
						IScrSection newSection =
							CreateSection(BCVRef.GetVerseFromBcv(section.VerseRefMin) == 0);
						Debug.Assert(newSection != null, "Failed to create a new section");
						IScrSection origSection = ((IScrBook) newSection.Owner).SectionsOS[iSection];
						IStTxtPara contentPara = origSection.ContentOA[0];
						contentPara.StyleRules = StyleUtils.ParaStyleTextProps(followStyle.Name);
						SetInsertionPoint(iBook, iSection, 0, 0, false);
					}
					else
					{
						SetInsertionPoint(iBook, iSection, 0, 0, false);
						// If the first paragraph is not empty, then insert a new paragraph with the
						// follow-on style of the section head.
						IStTxtPara contentPara = (IStTxtPara) section.ContentOA.ParagraphsOS[0];
						if (contentPara.Contents.Length > 0)
						{
							StTxtParaBldr bldr = new StTxtParaBldr(m_cache);
							bldr.ParaStyleName = followStyle.Name;
							bldr.AppendRun(String.Empty, StyleUtils.CharStyleTextProps(null,
								defVernWs));
							bldr.CreateParagraph((IStText)contentPara.Owner, 0);

							SetInsertionPoint(iBook, iSection, 0, 0, false);
						}
					}
					return;
				}
			}

			// Call the base to handle the key
			base.OnCharAux(stuInput, ss, modifiers);
		}
Ejemplo n.º 23
0
		public void InsertSection_EndFirstHeadingPara()
		{
			int nSectionsExpected = m_exodus.SectionsOS.Count;

			// Create second heading paragraph
			int iSectionIns = 1;
			IScrSection section = m_exodus.SectionsOS[iSectionIns];
			StTxtParaBldr paraBldr = new StTxtParaBldr(Cache);
			paraBldr.ParaStyleName = ScrStyleNames.SectionHead;
			paraBldr.AppendRun("Second Paragraph", StyleUtils.CharStyleTextProps(null,
				Cache.DefaultVernWs));
			paraBldr.CreateParagraph(section.HeadingOA);
			Assert.AreEqual(2, section.HeadingOA.ParagraphsOS.Count);

			// Put the IP into the heading of section 2 at end of first heading paragraph
			SelectionHelper selHelper = new SelectionHelper();
			selHelper.NumberOfLevels = 4;
			selHelper.LevelInfo[0].tag = StTextTags.kflidParagraphs;
			selHelper.LevelInfo[0].ihvo = 0;
			selHelper.LevelInfo[1].tag = ScrSectionTags.kflidHeading;
			selHelper.LevelInfo[1].ihvo = 0;
			selHelper.LevelInfo[2].tag = ScrBookTags.kflidSections;
			selHelper.LevelInfo[2].ihvo = iSectionIns;
			selHelper.LevelInfo[3].tag = m_draftView.BookFilter.Tag;
			selHelper.LevelInfo[3].ihvo = m_exodus.OwnOrd;
			selHelper.IchAnchor = 9; // end of "Heading 2"
			selHelper.TextPropId = StTxtParaTags.kflidContents;
			int cContentParas = section.ContentOA.ParagraphsOS.Count;

			// Now that all the preparation to set the IP is done, set it.
			selHelper.SetSelection(m_draftView, true, true);

			// InsertSection should add a section
			m_draftView.TeEditingHelper.CreateSection(false);
			nSectionsExpected++;
			Assert.AreEqual(nSectionsExpected, m_exodus.SectionsOS.Count, "Should add a section");
			IScrSection newSection = m_exodus.SectionsOS[iSectionIns];
			IScrSection oldSection = m_exodus.SectionsOS[iSectionIns + 1];
			Assert.AreEqual(02001001, newSection.VerseRefMin,
				"Wrong start reference for new section");
			Assert.AreEqual(02001001, newSection.VerseRefMax,
				"Wrong end reference for new section");
			Assert.AreEqual(02001001, oldSection.VerseRefMin,
				"Wrong start reference for existing section");
			Assert.AreEqual(02001005, oldSection.VerseRefMax,
				"Wrong end reference for existing section");

			Assert.AreEqual(1, newSection.HeadingOA.ParagraphsOS.Count);
			Assert.AreEqual("Heading 2",
				newSection.HeadingOA[0].Contents.Text,
				"Wrong heading in new section");
			Assert.IsNull(newSection.ContentOA[0].Contents.Text,
				"Content of new section is not empty");
			Assert.AreEqual(1, oldSection.HeadingOA.ParagraphsOS.Count,
				"Wrong number of paragraphs in old section");
			Assert.AreEqual("Second Paragraph",
				oldSection.HeadingOA[0].Contents.Text,
				"Wrong heading in old section");
			Assert.AreEqual(cContentParas,
				oldSection.ContentOA.ParagraphsOS.Count,
				"Wrong number of paragraphs in old content");
		}
Ejemplo n.º 24
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Inserts one or more paragraphs at the end of a section.  New sections for the book
		/// may also be created.
		/// </summary>
		/// <param name="book"></param>
		/// <param name="section"></param>
		/// <param name="ttpSrcArray">Array of props of each para to be inserted</param>
		/// <param name="tssParas">Array of TsStrings for each para to be inserted</param>
		/// <param name="sectionIndex"></param>
		/// <param name="cAddedSections"></param>
		/// <returns></returns>
		/// -----------------------------------------------------------------------------------
		private bool InsertParagraphsAtSectionEnd(IScrBook book, IScrSection section,
			ITsTextProps[] ttpSrcArray, ITsString[] tssParas, int sectionIndex, out int cAddedSections)
		{
			cAddedSections = 0;
			bool isIntro = false;

			for (int i = 0; i < ttpSrcArray.Length; i++)
			{
				string styleName = ttpSrcArray[i].GetStrPropValue((int)FwTextPropType.ktptNamedStyle);
				IStStyle style = m_scr.FindStyle(styleName);
				if (style.Structure == StructureValues.Heading)
				{
					// If content has been added to section, create a new section.  Otherwise,
					// add the new paragraph to the end of the current section heading.
					if (section.ContentOA.ParagraphsOS.Count == 0)
					{
						// Create heading paragraph at end of section heading
						section.HeadingOA.InsertNewPara(-1, styleName, tssParas[i]);
					}
					else
					{
						isIntro = (style.Context == ContextValues.Intro);
						// Create a new section and add the current paragraph to the heading
						section = m_cache.ServiceLocator.GetInstance<IScrSectionFactory>().CreateEmptySection(
							book, sectionIndex + cAddedSections++);

						section.HeadingOA.InsertNewPara(-1, styleName, tssParas[i]);
					}
				}
				else
				{
					// Create content paragraph for the current section
					section.ContentOA.InsertNewPara(-1, styleName, tssParas[i]);
				}
			}

			// create an empty paragraph if section content is empty
			if (section.ContentOA.ParagraphsOS.Count == 0)
			{
				string styleName = isIntro ? ScrStyleNames.IntroParagraph : ScrStyleNames.NormalParagraph;
				StTxtParaBldr bldr = new StTxtParaBldr(m_cache);
				bldr.ParaStyleName = styleName;
				ITsTextProps charProps = StyleUtils.CharStyleTextProps(styleName,
					m_wsContainer.DefaultVernacularWritingSystem.Handle);
				bldr.AppendRun(string.Empty, charProps);
				bldr.CreateParagraph(section.ContentOA);
			}

			return true;
		}
Ejemplo n.º 25
0
		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);
		}
Ejemplo n.º 26
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Use this method to move a portion of one StText to the same field (i.e. heading or
		/// content) in another section.
		/// </summary>
		/// <param name="field">The field (heading or contents) from and to which contents
		/// will be moved.</param>
		/// <param name="destSection">section to which the contents is moved</param>
		/// <param name="iparaDiv">Index of last partial paragraph to be moved or the first
		/// whole paragraph not moved</param>
		/// <param name="ichDiv">character offset of last character to be moved or zero if
		/// none are to be moved</param>
		/// ------------------------------------------------------------------------------------
		private void MovePartialContentsTo(int field, IScrSection destSection, int iparaDiv,
			int ichDiv)
		{
			IStText srcText = (field == ScrSectionTags.kflidContent) ? ContentOA : HeadingOA;
			IStText destText = (field == ScrSectionTags.kflidContent) ? destSection.ContentOA :
				destSection.HeadingOA;

			int iLastSrcPara = srcText.ParagraphsOS.Count - 1;
			Debug.Assert((iparaDiv >= 0) && (iparaDiv <= iLastSrcPara));

			IStTxtPara divPara = (IStTxtPara)srcText.ParagraphsOS[iparaDiv];
			if (ichDiv > 0 && ichDiv < divPara.Contents.Length)
			{
				divPara.SplitParaAt(ichDiv);
				iLastSrcPara++;
			}

			// Set up parameters for whole paragraph movement based on direction of movement
			//From para following IP to the end, pre-pended
			int iStartAt = (ichDiv > 0) ? iparaDiv + 1 : iparaDiv;
			int iInsertAt = 0;

			// Move the whole paragraphs of srcText to empty destText
			if (iparaDiv != iLastSrcPara || ichDiv == 0)
				MoveWholeParas(this, field, iStartAt, iLastSrcPara, destSection, field, iInsertAt, null);

			if (srcText.ParagraphsOS.Count == 0)
			{
				// We moved all of the paragraphs out of the existing section so we need to
				// create a new paragraph so the user can enter text
				IStTxtPara newSectionFirstPara = destText[0];
				StTxtParaBldr bldr = new StTxtParaBldr(m_cache);
				bldr.ParaStyleName = newSectionFirstPara.StyleName;
				bldr.AppendRun(string.Empty, StyleUtils.CharStyleTextProps(null, m_cache.DefaultVernWs));
				bldr.CreateParagraph(srcText);
			}
		}
Ejemplo n.º 27
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Finalizes the title. If is empty, a single blank paragraph is written for
		/// whatever is missing.
		/// </summary>
		/// ------------------------------------------------------------------------------------
		protected void FinalizePrevTitle()
		{
			if (m_cache == null || m_Title == null)
				return;

			// First, check if there is content. If not, add a blank paragraph.
			if (m_Title.ParagraphsOS.Count == 0)
			{
				StTxtParaBldr titleParaBldr = new StTxtParaBldr(m_cache);
					titleParaBldr.ParaStylePropsProxy = m_BookTitleParaProxy;
					titleParaBldr.CreateParagraph(m_Title);
				}

			m_fInBookTitle = false;
		}
Ejemplo n.º 28
0
		public void SectionHeadAllIntroParasToParagraph()
		{
			// create a book
			IScrBook book = CreateGenesis();
			// Create section 1
			IScrSection sectionCur = CreateSection(ScrStyleNames.IntroSectionHead, book,
				"My aching head!", "Second paragraph of heading");
			// create paragraph in section content
			StTxtParaBldr paraBldr = new StTxtParaBldr(Cache);
			paraBldr.ParaStyleName = ScrStyleNames.IntroParagraph;
			paraBldr.AppendRun("This is Genesis.",
				StyleUtils.CharStyleTextProps(null, Cache.DefaultVernWs));
			paraBldr.CreateParagraph(sectionCur.ContentOA);

			// create section 2
			sectionCur = CreateSection(book, "My other aching head!");
			// create paragraph in content
			paraBldr.ParaStyleName = ScrStyleNames.NormalParagraph;
			paraBldr.AppendRun("2", StyleUtils.CharStyleTextProps(ScrStyleNames.ChapterNumber,
				Cache.DefaultVernWs));
			paraBldr.AppendRun("Thus the heavens and the earth were completed in all their vast array. ",
				StyleUtils.CharStyleTextProps(null, Cache.DefaultVernWs));
			paraBldr.CreateParagraph(sectionCur.ContentOA);
			// finish the section info

			m_draftView.RefreshDisplay();

			// Set the IP in the 2nd section.
			int iBook = 0; // assume that iBook 0 is Genesis
			int iSectionIP = 0; // intro section

			// Make a range selection in for all paragraphs of the intro section heading
			m_draftView.SetInsertionPoint(ScrSectionTags.kflidHeading,
				iBook, iSectionIP);
			IVwSelection sel0 = m_draftView.RootBox.Selection;
			Assert.IsNotNull(sel0);
			m_draftView.SetInsertionPoint(ScrSectionTags.kflidHeading,
				iBook, iSectionIP, 1);
			IVwSelection sel1 = m_draftView.RootBox.Selection;
			Assert.IsNotNull(sel1);
			IVwSelection sel = m_draftView.RootBox.MakeRangeSelection(sel0, sel1, true);
			Assert.IsNotNull(sel);

			// ApplyStyle should move paragraphs from heading, but not change number
			// of sections.
			Assert.AreEqual(2, book.SectionsOS.Count, "Should be two sections before ApplyStyle");
			m_draftView.ApplyStyle(ScrStyleNames.IntroParagraph);
			Assert.AreEqual(2, book.SectionsOS.Count, "Should be two sections after ApplyStyle");

			// setup variables for testing
			IScrSection section1 = book.SectionsOS[0];

			// Verify section paragraphs
			Assert.AreEqual(1, section1.HeadingOA.ParagraphsOS.Count, "Should be one heading para");
			Assert.AreEqual(3, section1.ContentOA.ParagraphsOS.Count, "Should be three body paras");
			IStTxtPara para = section1.HeadingOA[0];
			Assert.IsNull(para.Contents.Text);
			Assert.AreEqual(ScrStyleNames.IntroSectionHead,
				para.StyleRules.GetStrPropValue((int)FwTextPropType.ktptNamedStyle));
			para = section1.ContentOA[0];
			Assert.AreEqual("My aching head!", para.Contents.Text);
			Assert.AreEqual(ScrStyleNames.IntroParagraph,
				para.StyleRules.GetStrPropValue((int)FwTextPropType.ktptNamedStyle));
			para = section1.ContentOA[1];
			Assert.AreEqual("Second paragraph of heading", para.Contents.Text);
			Assert.AreEqual(ScrStyleNames.IntroParagraph,
				para.StyleRules.GetStrPropValue((int)FwTextPropType.ktptNamedStyle));
			para = section1.ContentOA[2];
			Assert.AreEqual("This is Genesis.", para.Contents.Text);
			Assert.AreEqual(ScrStyleNames.IntroParagraph,
				para.StyleRules.GetStrPropValue((int)FwTextPropType.ktptNamedStyle));

			// Verify that selection is in paragraph that was the heading of the
			// second section
#if WANTTESTPORT // (TE): Need to check for selection at end of UOW
			Assert.IsFalse(m_draftView.TeEditingHelper.InSectionHead, "Should be in body");
			Assert.AreEqual(0, m_draftView.TeEditingHelper.BookIndex);
			Assert.AreEqual(0, m_draftView.TeEditingHelper.SectionIndex);
			Assert.AreEqual(0, m_draftView.ParagraphIndex);
#endif
		}
Ejemplo n.º 29
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Creates an empty paragraph with the given paragraph style and writing system.
		/// </summary>
		/// <param name="cache"></param>
		/// <param name="owner"></param>
		/// <param name="paraStyle"></param>
		/// <param name="ws"></param>
		/// ------------------------------------------------------------------------------------
		public static void CreateEmptyPara(FdoCache cache, IStText owner, string paraStyle, int ws)
		{
			var bldr = new StTxtParaBldr(cache);
			bldr.ParaStyleName = paraStyle;
			bldr.AppendRun(String.Empty, StyleUtils.CharStyleTextProps(null, ws));
			bldr.CreateParagraph(owner);
		}
Ejemplo n.º 30
0
		public void SectionHeadMidParaToParagraph()
		{
			// create a book
			IScrBook book = CreateGenesis();
			// Create section 1
			IScrSection sectionCur = CreateSection(book, "My aching head!");
			// create paragraph one holding chapter 1
			StTxtParaBldr paraBldr = new StTxtParaBldr(Cache);
			paraBldr.ParaStyleName = ScrStyleNames.NormalParagraph;
			paraBldr.AppendRun("1", StyleUtils.CharStyleTextProps(ScrStyleNames.ChapterNumber,
				Cache.DefaultVernWs));
			paraBldr.AppendRun("In the beginning, God created the heavens and the earth. ",
				StyleUtils.CharStyleTextProps(null, Cache.DefaultVernWs));
			paraBldr.AppendRun("2", StyleUtils.CharStyleTextProps(ScrStyleNames.VerseNumber,
				Cache.DefaultVernWs));
			paraBldr.AppendRun("And the earth was void.",
				StyleUtils.CharStyleTextProps(null, Cache.DefaultVernWs));
			paraBldr.CreateParagraph(sectionCur.ContentOA);

			// create section 2
			// section head will have four paragraphs
			sectionCur = CreateSection(book, "My other aching head!",
				"Paragraph A", "Paragraph B", "Last para of section head");
			// create content paragraph holding chapter 2
			paraBldr.ParaStyleName = ScrStyleNames.NormalParagraph;
			paraBldr.AppendRun("2", StyleUtils.CharStyleTextProps(ScrStyleNames.ChapterNumber,
				Cache.DefaultVernWs));
			paraBldr.AppendRun("Thus the heavens and the earth were completed in all their vast array. ",
				StyleUtils.CharStyleTextProps(null, Cache.DefaultVernWs));
			paraBldr.CreateParagraph(sectionCur.ContentOA);
			// finish the section info

			m_draftView.RefreshDisplay();

			// Set the IP in the 2nd section.
			int iBook = 0; // assume that iBook 0 is Genesis
			int iSectionIP = 1; //section with 2:1

			// Make a selection in the second paragraph of the heading
			m_draftView.SetInsertionPoint(ScrSectionTags.kflidHeading,
				iBook, iSectionIP, 1);
			SelectionHelper helper = SelectionHelper.Create(m_draftView);
			// adjust end point level info to point to third paragraph
			SelLevInfo[] levInfo = helper.GetLevelInfo(SelectionHelper.SelLimitType.End);
			levInfo[0].ihvo = 2;
			helper.SetLevelInfo(SelectionHelper.SelLimitType.End, levInfo);
			helper.IchEnd = 0;	// needed to make selection a range selection
			helper.SetSelection(true);

			// ApplyStyle should move paragraph from heading, but not change number
			// of sections.
			Assert.AreEqual(2, book.SectionsOS.Count, "Not two sections before ApplyStyle");
			m_draftView.ApplyStyle(ScrStyleNames.NormalParagraph);
			Assert.AreEqual(3, book.SectionsOS.Count, "Not three sections after ApplyStyle");

			// setup variables for testing
			IScrSection section1 = book.SectionsOS[0];
			IScrSection section2 = book.SectionsOS[1];
			IScrSection section3 = book.SectionsOS[2];

			// Verify section paragraphs
			Assert.AreEqual(1, section1.HeadingOA.ParagraphsOS.Count);
			Assert.AreEqual(1, section1.ContentOA.ParagraphsOS.Count);
			Assert.AreEqual(1, section2.HeadingOA.ParagraphsOS.Count);
			Assert.AreEqual(2, section2.ContentOA.ParagraphsOS.Count);
			Assert.AreEqual(1, section3.HeadingOA.ParagraphsOS.Count);
			Assert.AreEqual(1, section3.ContentOA.ParagraphsOS.Count);

			Assert.AreEqual(01001002, section1.VerseRefMax);
			Assert.AreEqual(01001002, section2.VerseRefMin);
			Assert.AreEqual(01001002, section2.VerseRefMax);
			Assert.AreEqual(01002001, section3.VerseRefMin);
			Assert.AreEqual(01002001, section3.VerseRefMax);

			IStTxtPara para = section2.HeadingOA[0];
			Assert.AreEqual("My other aching head!", para.Contents.Text);
			Assert.AreEqual(ScrStyleNames.SectionHead,
				para.StyleRules.GetStrPropValue((int)FwTextPropType.ktptNamedStyle));
			para = section2.ContentOA[0];
			Assert.AreEqual("Paragraph A", para.Contents.Text);
			Assert.AreEqual(ScrStyleNames.NormalParagraph,
				para.StyleRules.GetStrPropValue((int)FwTextPropType.ktptNamedStyle));
			para = section2.ContentOA[1];
			Assert.AreEqual("Paragraph B", para.Contents.Text);
			Assert.AreEqual(ScrStyleNames.NormalParagraph,
				para.StyleRules.GetStrPropValue((int)FwTextPropType.ktptNamedStyle));

			para = section3.HeadingOA[0];
			Assert.AreEqual("Last para of section head", para.Contents.Text);
			Assert.AreEqual(ScrStyleNames.SectionHead,
				para.StyleRules.GetStrPropValue((int)FwTextPropType.ktptNamedStyle));
			para = section3.ContentOA[0];
			Assert.AreEqual("2Thus the heavens and the earth were completed in all their vast array. ",
				para.Contents.Text); // chapter num and words
			Assert.AreEqual(ScrStyleNames.NormalParagraph,
				para.StyleRules.GetStrPropValue((int)FwTextPropType.ktptNamedStyle));

			// Verify that selection is in paragraphs that have become the contents of the
			//  second section
#if WANTTESTPORT // (TE): Need to check for selection at end of UOW
			Assert.AreEqual(0, m_draftView.TeEditingHelper.BookIndex);
			Assert.AreEqual(1, m_draftView.TeEditingHelper.SectionIndex);
			Assert.AreEqual(0, m_draftView.ParagraphIndex);
#endif
		}
Ejemplo n.º 31
0
		/// ------------------------------------------------------------------------------------
		/// <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 IScrSection CreateScrSection(IScrBook book, int iSection, string contentText,
			ITsTextProps contentTextProps, bool isIntro)
		{
			if (book == null)
				throw new ArgumentNullException();

			IScrSection section = CreateSection(book, iSection, isIntro, true, false);

			// Insert the section contents.
			StTxtParaBldr bldr = new StTxtParaBldr(book.Cache);
				bldr.ParaStyleName = isIntro ? ScrStyleNames.IntroParagraph : ScrStyleNames.NormalParagraph;
				bldr.AppendRun(contentText, contentTextProps);
				bldr.CreateParagraph(section.ContentOA);

			return section;
		}
Ejemplo n.º 32
0
		public void InsertSection_InMidSectionAtBeginningOfChapter()
		{
			// Create a section
			IScrSection sectionCur = CreateSection(m_genesis, "My aching head!");
			// create paragraph one holding chapter 1
			StTxtParaBldr paraBldr = new StTxtParaBldr(Cache);
			paraBldr.ParaStyleName = ScrStyleNames.NormalParagraph;
			paraBldr.AppendRun("1", StyleUtils.CharStyleTextProps(ScrStyleNames.ChapterNumber,
				Cache.DefaultVernWs));
			paraBldr.AppendRun("In the beginning, God created the heavens and the earth. ",
				StyleUtils.CharStyleTextProps(null, Cache.DefaultVernWs));
			paraBldr.CreateParagraph(sectionCur.ContentOA);

			// create paragraph two holding chapter 2
			paraBldr.ParaStyleName = ScrStyleNames.NormalParagraph;
			paraBldr.AppendRun("2", StyleUtils.CharStyleTextProps(ScrStyleNames.ChapterNumber,
				Cache.DefaultVernWs));
			paraBldr.AppendRun("Thus the heavens and the earth were completed in all their vast array. ",
				StyleUtils.CharStyleTextProps(null, Cache.DefaultVernWs));
			paraBldr.CreateParagraph(sectionCur.ContentOA);
			// finish the section info
			m_draftView.RefreshDisplay();

			int iBook = 0; // assume that iBook 0 is Genesis

			// Set the IP at the beginning of the 2nd paragraph in the 1st section.
			int iSectionIP = 0; //section with 1:1 to 2:1
			int iParaIP = 1;
			IStText text = m_genesis.SectionsOS[iSectionIP].ContentOA;
			IStTxtPara paraBeforeSectBreak = (IStTxtPara)text[iParaIP - 1];
			int ichIP = 0;
			int cExpectedParagraphsInNewSection = text.ParagraphsOS.Count - iParaIP;

			// Set the para props to something funky, to provide a better test
			paraBeforeSectBreak.StyleRules = StyleUtils.ParaStyleTextProps("Line1");

			// Save details we will test against
			ITsTextProps paraRulesOrig = paraBeforeSectBreak.StyleRules;
			ITsString tssParaOrig = paraBeforeSectBreak.Contents;
			ITsTextProps paraRulesFirstNew = text[iParaIP].StyleRules;
			ITsString tssFirstNewPara =
				text[iParaIP].Contents;

			// Put the IP in place
			m_draftView.SetInsertionPoint(iBook, iSectionIP, iParaIP, ichIP, true);

			// InsertSection should add a scripture section
			int nSectionsExpected = m_genesis.SectionsOS.Count + 1;
			m_draftView.TeEditingHelper.CreateSection(false);
			Assert.AreEqual(nSectionsExpected, m_genesis.SectionsOS.Count, "Should add a section");

			// setup variables for testing
			IScrSection existingSection = m_genesis.SectionsOS[iSectionIP];
			int iSectionIns = iSectionIP + 1;
			IScrSection createdSection = m_genesis.SectionsOS[iSectionIns];

			// Verify verse start and end refs
			Assert.AreEqual(1001001, existingSection.VerseRefMin,
				"Existing section should have same verse start ref");
			Assert.AreEqual(1001001, existingSection.VerseRefMax,
				"Existing section should have new verse end ref");
			Assert.AreEqual(1002001, createdSection.VerseRefMin,
				"New section should have correct verse start ref");
			Assert.AreEqual(1002001, createdSection.VerseRefMax,
				"New section should have correct verse end ref");

			// Verify number of paragraphs in each section
			Assert.AreEqual(iParaIP, existingSection.ContentOA.ParagraphsOS.Count);
			Assert.AreEqual(cExpectedParagraphsInNewSection,
				createdSection.ContentOA.ParagraphsOS.Count);
		}