Example #1
0
		int m_wsUr; // Urdu writing system (used for Foreign style)
		#endregion

		#region Test setup
		/// ------------------------------------------------------------------------------------
		/// <summary>
		///
		/// </summary>
		/// ------------------------------------------------------------------------------------
		protected override void CreateTestData()
		{
			m_inMemoryCache.InitializeWritingSystemEncodings();

			// create footnote
			m_footnote = new StFootnote();
			m_book = (ScrBook)m_scrInMemoryCache.AddBookToMockedScripture(1, "Genesis");
			m_book.FootnotesOS.Append(m_footnote);
			m_footnote.FootnoteMarker.Text = "o";
			m_footnote.DisplayFootnoteMarker = true;
			m_footnote.DisplayFootnoteReference = false;

			// create one empty footnote para
			StTxtPara para = new StTxtPara();
			m_footnote.ParagraphsOS.Append(para);
			para.StyleRules = StyleUtils.ParaStyleTextProps(ScrStyleNames.NormalFootnoteParagraph);

			m_strFact = TsStrFactoryClass.Create();
			m_vernWs = Cache.LangProject.DefaultVernacularWritingSystem;
			para.Contents.UnderlyingTsString = m_strFact.MakeString(string.Empty, m_vernWs);
			m_footnotePara = (StTxtPara)m_footnote.ParagraphsOS[0];

			m_wsUr = InMemoryFdoCache.s_wsHvos.Ur; // used with 'foreign' character style
			m_wsDe = InMemoryFdoCache.s_wsHvos.De; // used for back translations
			m_wsEs = InMemoryFdoCache.s_wsHvos.Es;
		}
Example #2
0
		public void Dispose()
		{
			m_stText = null;
			m_tsf = null;
			m_text = null;
			m_firstPara = null;
			m_cache = null;
		}
Example #3
0
		public DiscourseTestHelper(FdoCache cache)
		{
			m_cache = cache;
			m_tsf = TsStrFactoryClass.Create();
			m_text = (Text)Cache.LangProject.TextsOC.Add(new Text());
			m_stText = new StText();
			m_text.ContentsOA = m_stText;
			m_firstPara = MakeParagraph();
		}
Example #4
0
		/// <summary>overload for same end ref</summary>
		public static void VerifyParaDiff(Difference diff,
			BCVRef startAndEnd, DifferenceType type,
			StTxtPara paraCurr, int ichMinCurr, int ichLimCurr,
			StTxtPara paraRev, int ichMinRev, int ichLimRev)
		{
			VerifyParaDiff(diff, startAndEnd, startAndEnd, type,
				paraCurr, ichMinCurr, ichLimCurr,
				paraRev, ichMinRev, ichLimRev);
		}
		public override void Exit()
		{
			CheckDisposed();

			m_philemon = null;
			m_section = null;
			m_para = null;

			base.Exit();
		}
		/// ------------------------------------------------------------------------------------
		/// <summary>
		///
		/// </summary>
		/// ------------------------------------------------------------------------------------
		protected override void CreateTestData()
		{
			base.CreateTestData();

			m_philemon = m_scrInMemoryCache.AddBookToMockedScripture(57, "Philemon");
			m_scrInMemoryCache.AddTitleToMockedBook(m_philemon.Hvo, "Philemon");
			m_section = m_scrInMemoryCache.AddSectionToMockedBook(m_philemon.Hvo);
			m_para = m_scrInMemoryCache.AddParaToMockedSectionContent(m_section.Hvo,
				ScrStyleNames.NormalParagraph);
			m_scrInMemoryCache.AddRunToMockedPara(m_para, "this is text", null);
		}
		public void SetupTexts()
		{
			// First make a regular text.
			using (new UndoRedoTaskHelper(Cache, "ConstituentChartDatabaseTests - SetupTexts()", "ConstituentChartDatabaseTests - SetupTexts()"))
			{
				m_text1 = Cache.LangProject.TextsOC.Add(new Text());
				m_text1.ContentsOA = new StText();
				StTxtPara para0 = new StTxtPara();
				m_text1.ContentsOA.ParagraphsOS.Append(para0);
				//m_text1.ContentsOA.ParagraphsOS.Append(para1);
				//           1         2         3         4         5         6
				// 0123456789012345678901234567890123456789012345678901234567890123456789
				// this is the first paragraph for our constituent chart database tests.
				para0.Contents.UnderlyingTsString = m_tsf.MakeString("this is the first paragraph for our constituent chart database tests.",
					Cache.DefaultVernWs);
			}
		}
Example #8
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Create a title paragrpaph for the given book.
		/// </summary>
		/// <param name="scrInMemoryCache">in-memory cache to use for testing</param>
		/// <param name="book">The book</param>param>
		/// <param name="sTitle">The text of the title. Can be a simple string or a format
		/// string. (See InMemoryFdoCache.CreateFormatText for the definition of the
		/// format string)</param>
		/// ------------------------------------------------------------------------------------
		internal static void SetTitle(ScrInMemoryFdoCache scrInMemoryCache, IScrBook book, string sTitle)
		{
			book.TitleOA = new StText();

			if (sTitle[0] != '\\')
			{
				scrInMemoryCache.AddTitleToMockedBook(book.Hvo, sTitle);
			}
			else
			{
				// Create a more complex title from the given format string
				// insert a new para in the title
				StTxtPara para = new StTxtPara();
				book.TitleOA.ParagraphsOS.Append(para);
				// set the para's fields
				scrInMemoryCache.AddFormatTextToMockedPara(book, para, sTitle, scrInMemoryCache.Cache.DefaultVernWs);
				para.StyleRules = StyleUtils.ParaStyleTextProps(ScrStyleNames.MainBookTitle);
			}
		}
Example #9
0
		protected void CreateTestData()
		{
			using (new UndoRedoTaskHelper(Cache, "Undo LogicTest - CreateTestData", "Redo LogicTest - CreateTestData"))
			{
				m_helper = new DiscourseTestHelper(Cache);
				m_firstPara = m_helper.FirstPara;
				m_stText = m_firstPara.Owner as StText;
				m_firstParaWfics = m_helper.MakeAnnotations(m_firstPara);
				m_logic = new TestCCLogic(Cache, m_chart, m_stText.Hvo);
				m_helper.Logic = m_logic;
				m_logic.Ribbon = m_mockRibbon = new MockRibbon(Cache, m_stText.Hvo);
				m_template = m_helper.MakeTemplate(out m_allColumns);
				// Note: do this AFTER creating the template, which may also create the DiscourseData object.
				m_chart = new DsConstChart();
				Cache.LangProject.DiscourseDataOA.ChartsOC.Add(m_chart);
				m_chart.TemplateRA = m_template;
				m_logic.Chart = m_chart;
				m_helper.Chart = m_chart;
			}
		}
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Create minimal test data required for every test.
		/// </summary>
		/// ------------------------------------------------------------------------------------
		protected override void CreateTestData()
		{
			base.CreateTestData();
			m_inMemoryCache.InitializeWritingSystemEncodings();
			m_inMemoryCache.InitializeLexDb();
			m_helper = new DiscourseTestHelper(Cache);
			m_firstPara = m_helper.FirstPara;
			m_stText = m_firstPara.Owner as StText;
			//// We want a real action handler so we can test Undo/Redo.
			//m_originalHandler = m_inMemoryCache.Cache.ActionHandlerAccessor;
			//((NewFdoCache)(m_inMemoryCache.Cache)).ActionHandler = ActionHandlerClass.Create();
			//// Make the key annotationdefns.
			ICmPossibilityList defns = Cache.LangProject.AnnotationDefsOA;
			if (defns == null)
			{
				defns = new CmPossibilityList();
				Cache.LangProject.AnnotationDefsOA = defns;
			}
			MakeAnnDefn(defns, LangProject.kguidAnnWordformInContext);
			MakeAnnDefn(defns, LangProject.kguidConstituentChartRow);
			MakeAnnDefn(defns, LangProject.kguidConstituentChartAnnotation);
		}
		/// ------------------------------------------------------------------------------------
		/// <summary>
		///
		/// </summary>
		/// ------------------------------------------------------------------------------------
		protected override void OnFormClosing(FormClosingEventArgs e)
		{
			base.OnFormClosing(e);

			if (DialogResult == DialogResult.Cancel)
				return;

			FdoOwningSequence<IStPara> oldParas = m_error.ResolutionOA.ParagraphsOS;
			ITsString[] newParas = m_text.Paragraphs;

			// If there are fewer paragraphs in the new comment, then remove from the end
			// of the old comment the number paragraphs that is the difference between
			// the number of old and new paragraphs.
			if (newParas.Length < oldParas.Count)
			{
				for (int i = oldParas.Count - 1; i >= newParas.Length; i--)
					oldParas.RemoveAt(i);
			}

			for (int i = 0; i < newParas.Length; i++)
			{
				if (i < oldParas.Count)
				{
					// Reuse the old paragraph.
					((StTxtPara)oldParas[i]).Contents.UnderlyingTsString = newParas[i];
				}
				else
				{
					// Create a new paragraph
					StTxtPara newStPara = new StTxtPara();
					oldParas.Append(newStPara);
					newStPara.Contents.UnderlyingTsString = newParas[i];
					ITsPropsFactory tspf = TsPropsFactoryClass.Create();
					newStPara.StyleRules = tspf.MakeProps(ScrStyleNames.Remark, m_text.CurrentWs, 0);
				}
			}
		}
Example #12
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// A helper method for book merger tests-
		/// Verifies the contents of the given difference
		/// for any types that deal with changes in a paragraph.
		/// </summary>
		/// <remarks>char styles and subDiffs are not verified here; test code should just check
		/// those directly if relevant</remarks>
		/// <param name="diff">the given Difference.</param>
		/// <param name="start">The verse ref start.</param>
		/// <param name="end">The verse ref end.</param>
		/// <param name="type">Type of the diff.</param>
		/// <param name="paraCurr">The Current paragraph.</param>
		/// <param name="ichMinCurr">The ich min in paraCurr.</param>
		/// <param name="ichLimCurr">The ich lim in paraCurr.</param>
		/// <param name="paraRev">The Revision paragraph.</param>
		/// <param name="ichMinRev">The ich min in paraRev.</param>
		/// <param name="ichLimRev">The ich lim in paraRev.</param>
		/// ------------------------------------------------------------------------------------
		public static void VerifyParaDiff(Difference diff,
			BCVRef start, BCVRef end, DifferenceType type,
			StTxtPara paraCurr, int ichMinCurr, int ichLimCurr,
			StTxtPara paraRev, int ichMinRev, int ichLimRev)
		{
			// verify the basics
			Assert.AreEqual(start, diff.RefStart);
			Assert.AreEqual(end, diff.RefEnd);
			Assert.AreEqual(type, diff.DiffType);

			// the Current para stuff
			Assert.AreEqual(paraCurr.Hvo, diff.HvoCurr);
			Assert.AreEqual(ichMinCurr, diff.IchMinCurr);
			Assert.AreEqual(ichLimCurr, diff.IchLimCurr);

			// the Revision para stuff
			Assert.AreEqual(paraRev.Hvo, diff.HvoRev);
			Assert.AreEqual(ichMinRev, diff.IchMinRev);
			Assert.AreEqual(ichLimRev, diff.IchLimRev);

			// section stuff should be null
			Assert.IsNull(diff.HvosSectionsRev);
			Assert.IsNull(diff.HvosSectionsCurr);
		}
Example #13
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// A helper method for book merger tests-
		/// Verifies the contents of the given difference
		/// for types: missing/added paragraphs.
		/// </summary>
		/// <param name="diff">the given Difference</param>
		/// <param name="start">The verse ref start.</param>
		/// <param name="end">The verse ref end.</param>
		/// <param name="type">Type of the diff.</param>
		/// <param name="paraAdded">The paragraph added.</param>
		/// <param name="paraDest">the destination paragraph</param>
		/// <param name="ichDest">The character index in the destination paragraph,
		/// where the added items could be inserted in the other book.</param>
		/// ------------------------------------------------------------------------------------
		public static void VerifyParaAddedDiff(Difference diff,
			BCVRef start, BCVRef end, DifferenceType type,
			StTxtPara paraAdded, StTxtPara paraDest, int ichDest)
		{
			Assert.AreEqual(start, diff.RefStart);
			Assert.AreEqual(end, diff.RefEnd);
			Assert.AreEqual(type, diff.DiffType);
			switch (type)
			{
				case DifferenceType.ParagraphAddedToCurrent:
					Assert.IsNull(diff.HvosSectionsRev);

					Assert.AreEqual(paraAdded.Hvo, diff.HvoCurr);
					Assert.AreEqual(0, diff.IchMinCurr);
					Assert.AreEqual(paraAdded.Contents.Length, diff.IchLimCurr);

					Assert.AreEqual(paraDest.Hvo, diff.HvoRev);
					Assert.AreEqual(ichDest, diff.IchMinRev);
					Assert.AreEqual(ichDest, diff.IchLimRev);

					Assert.IsNull(diff.StyleNameCurr);
					Assert.IsNull(diff.StyleNameRev);
					break;

				case DifferenceType.ParagraphMissingInCurrent:
					Assert.IsNull(diff.HvosSectionsRev);

					Assert.AreEqual(paraDest.Hvo, diff.HvoCurr);
					Assert.AreEqual(ichDest, diff.IchMinCurr);
					Assert.AreEqual(ichDest, diff.IchLimCurr);

					Assert.AreEqual(paraAdded.Hvo, diff.HvoRev);
					Assert.AreEqual(0, diff.IchMinRev);
					Assert.AreEqual(paraAdded.Contents.Length, diff.IchLimRev);

					Assert.IsNull(diff.StyleNameCurr);
					Assert.IsNull(diff.StyleNameRev);
					break;
			}
		}
Example #14
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// A helper method for book merger tests-
		/// Verifies the contents of the given difference
		/// for types: missing/added empty paragraphs.
		/// </summary>
		/// <param name="diff">the given Difference</param>
		/// <param name="startAndEnd">The starting and ending verse ref start.</param>
		/// <param name="type">Type of the diff.</param>
		/// <param name="paraAdded">The paragraph added.</param>
		/// <param name="paraDest">the destination paragraph</param>
		/// <param name="ichDest">The character index in the destination paragraph,
		/// where the added items could be inserted in the other book.</param>
		/// ------------------------------------------------------------------------------------
		public static void VerifyStanzaBreakAddedDiff(Difference diff,
			BCVRef startAndEnd, DifferenceType type,
			StTxtPara paraAdded, /*string strAddedParaStyle,*/ StTxtPara paraDest, int ichDest)
		{
			Assert.IsTrue(diff.DiffType == DifferenceType.StanzaBreakAddedToCurrent ||
				diff.DiffType == DifferenceType.StanzaBreakMissingInCurrent);
			//string addedParaStyle = (diff.DiffType == DifferenceType.StanzaBreakAddedToCurrent) ?
			//    diff.StyleNameCurr : diff.StyleNameRev;
			//Assert.AreEqual(strAddedParaStyle, addedParaStyle);

			VerifyParaAddedDiff(diff, startAndEnd, startAndEnd, type, paraAdded, paraDest, ichDest);
		}
Example #15
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Append a new <see cref="StTxtPara"/> to the given <see cref="StText"/>.
		/// Set it with data accumulated in this builder.
		/// </summary>
		/// <param name="hvoOwner">HVO of the <see cref="StText"/> that is to own the new
		/// paragraph</param>
		/// <returns>A new StTextPara whose contents are built up from the prior calls
		/// to <see cref="AppendRun"/> and whose style is set based on the current value of
		/// <see cref="ParaStylePropsProxy"/>.</returns>
		/// ------------------------------------------------------------------------------------
		public StTxtPara CreateParagraph(int hvoOwner)
		{
			CheckDisposed();
			// insert a new para in the owner's collection
			StTxtPara para = new StTxtPara();
			StText text = new StText(m_cache, hvoOwner);
			text.ParagraphsOS.Append(para);

			SetStTxtParaPropertiesAndClearBuilder(para, 0);

			return para;
		}
Example #16
0
		public void CreateFromStringRep_twoParas()
		{
			CheckDisposed();

			ITsStrBldr bldr = m_footnotePara.Contents.UnderlyingTsString.GetBldr();
			bldr.Replace(0, 0, "Paragraph One", null);
			m_footnotePara.Contents.UnderlyingTsString = bldr.GetString();

			// create second para
			StTxtPara para = new StTxtPara();
			m_footnote.ParagraphsOS.Append(para);
			para.StyleRules = StyleUtils.ParaStyleTextProps("Note Exegesis Paragraph");
			bldr = TsStrBldrClass.Create();
			bldr.Replace(0, 0, "Paragraph Two", StyleUtils.CharStyleTextProps("Foreign", m_wsUr));
			para.Contents.UnderlyingTsString = bldr.GetString();

			string footnoteRep = @"<FN><M>o</M><ShowMarker/><P><PS>Note General Paragraph</PS>" +
				@"<RUN WS='fr'>Paragraph One</RUN></P><P><PS>Note Exegesis Paragraph</PS>" +
				@"<RUN WS='ur' CS='Foreign'>Paragraph Two</RUN></P></FN>";
			StFootnote footnote = StFootnote.CreateFromStringRep(m_book,
				(int)ScrBook.ScrBookTags.kflidFootnotes, footnoteRep, 0, "Note Marker");
			CompareFootnote(footnote);
		}
Example #17
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// A helper method for book merger tests-
		/// Verifies the contents of the given sub-difference
		/// for a two-sided subDiff representing a text comparison. This overload does not
		/// check for the starting and ending references for sub-diffs that are created without
		/// that information.
		/// </summary>
		/// <param name="rootDiff">The root difference.</param>
		/// <param name="iSubDiff">The sub difference to verify.</param>
		/// <param name="subDiffType">Type of the sub difference.</param>
		/// <param name="paraCurr">The current paragraph.</param>
		/// <param name="ichMinCurr">The beginning character offset of the difference in the
		/// current.</param>
		/// <param name="ichLimCurr">The ending character offset of the difference in the
		/// current.</param>
		/// <param name="paraRev">The revision paragraph.</param>
		/// <param name="ichMinRev">The beginning character offset of the difference in the
		/// revision.</param>
		/// <param name="ichLimRev">The ending character offset of the difference in the
		/// current.</param>
		/// <remarks>char styles are not verified here; test code should just check
		/// those directly if relevant</remarks>
		/// ------------------------------------------------------------------------------------
		//TODO: use an iSubDiff parameter instead of the subDiff itself;
		// use the following method as a model to verify the root diff type
		// make a separate method for footnote subdiffs
		public static void VerifySubDiffTextCompared(Difference rootDiff, int iSubDiff,
			DifferenceType subDiffType,
			StTxtPara paraCurr, int ichMinCurr, int ichLimCurr,
			StTxtPara paraRev, int ichMinRev, int ichLimRev)
		{
			Difference subDiff = rootDiff.SubDiffsForParas[iSubDiff];
			// the Current para stuff
			Assert.AreEqual((paraCurr != null) ? paraCurr.Hvo : 0, subDiff.HvoCurr);
			Assert.AreEqual(ichMinCurr, subDiff.IchMinCurr);
			Assert.AreEqual(ichLimCurr, subDiff.IchLimCurr);

			// the Revision para stuff
			Assert.AreEqual((paraRev != null) ? paraRev.Hvo : 0, subDiff.HvoRev);
			Assert.AreEqual(ichMinRev, subDiff.IchMinRev);
			Assert.AreEqual(ichLimRev, subDiff.IchLimRev);

			// section stuff should be null
			Assert.IsNull(subDiff.HvosSectionsRev);
			Assert.IsNull(subDiff.HvosSectionsCurr);

			// subDiffs may not have subDiffs, so far
			Assert.IsNull(subDiff.SubDiffsForORCs);
			Assert.IsNull(subDiff.SubDiffsForParas);

			Assert.AreEqual(subDiffType, subDiff.DiffType);

			if ((rootDiff.DiffType & DifferenceType.ParagraphSplitInCurrent) != 0 ||
				(rootDiff.DiffType & DifferenceType.ParagraphMergedInCurrent) != 0 ||
				(rootDiff.DiffType & DifferenceType.ParagraphStructureChange) != 0)
			{
				// check the subDiff for consistency with the root diff.
				Assert.IsTrue((subDiff.DiffType & DifferenceType.TextDifference) != 0 ||
					(subDiff.DiffType & DifferenceType.FootnoteAddedToCurrent) != 0 ||
					(subDiff.DiffType & DifferenceType.FootnoteMissingInCurrent) != 0 ||
					(subDiff.DiffType & DifferenceType.FootnoteDifference) != 0 ||
					(subDiff.DiffType & DifferenceType.MultipleCharStyleDifferences) != 0 ||
					(subDiff.DiffType & DifferenceType.CharStyleDifference) != 0 ||
					(subDiff.DiffType & DifferenceType.PictureAddedToCurrent) != 0 ||
					(subDiff.DiffType & DifferenceType.PictureMissingInCurrent) != 0 ||
					(subDiff.DiffType & DifferenceType.PictureDifference) != 0 ||
					subDiff.DiffType == DifferenceType.NoDifference, // (structure change only)
					subDiff.DiffType.ToString() +
					" is not a consistent subtype with split or merged paragraph differences.");
			}
			else
			{
				Assert.IsNotNull(paraCurr, "The current paragraph cannot be null except for para split/merge root diff");
				Assert.IsNotNull(paraRev, "The revision paragraph cannot be null except for para split/merge root diff");

				//check the root difference for consistency with this subDiff
				if (subDiff.DiffType == DifferenceType.VerseMoved)
				// ||
				// subDiff.DiffType == DifferenceType.ParagraphMoved)
				{
					// this subDiff verse or paragraph was moved into an added section
					Assert.IsTrue(rootDiff.DiffType == DifferenceType.SectionAddedToCurrent ||
						rootDiff.DiffType == DifferenceType.SectionMissingInCurrent,
						"inconsistent type of root difference");
				}
				else if (subDiff.DiffType == DifferenceType.TextDifference)
				{
					// this subDiff text difference is within a footnote
					Assert.AreEqual(DifferenceType.FootnoteDifference, rootDiff.DiffType);
				}
				else
					Assert.Fail("unexpected type of sub-diff");
			}
		}
Example #18
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Append a run of text to a back translation of a paragraph.
		/// </summary>
		/// <param name="para">given paragraph</param>
		/// <param name="ws">given writing system for the back translation</param>
		/// <param name="runText">given text to append to back translation</param>
		/// ------------------------------------------------------------------------------------
		private void AppendRunToBt(StTxtPara para, int ws, string runText)
		{
			ICmTranslation trans = para.GetOrCreateBT();
			ITsStrBldr bldr = trans.Translation.GetAlternative(ws).UnderlyingTsString.GetBldr();
			ITsTextProps ttp = StyleUtils.CharStyleTextProps(null, ws);
			int bldrLength = bldr.Length;
			bldr.ReplaceRgch(bldrLength, bldrLength, runText, runText.Length, ttp);
			trans.Translation.SetAlternative(bldr.GetString(), ws);
		}
Example #19
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Notifies a paragraph that needs to have its highlighting refreshed.
		/// </summary>
		/// <param name="hvoPara"></param>
		/// ------------------------------------------------------------------------------------
		private void NotifyParagraph(int hvoPara)
		{
			if (m_cache.IsRealObject(hvoPara, StTxtPara.kClassId))
			{
				StTxtPara para = new StTxtPara(m_cache, hvoPara);
				m_cache.PropChanged(null, PropChangeType.kpctNotifyAll, hvoPara,
					(int)StTxtPara.StParaTags.kflidStyleRules, 0, 1, 1);
			}
		}
Example #20
0
		public void ArchiveDraft_TestFootnoteOrder()
		{
			CheckDisposed();
			int draftCount = m_scr.ArchivedDraftsOC.Count;
			ScrBook james = (ScrBook)m_scr.ScriptureBooksOS[1];
			int hvoBookRef = m_fdoCache.ScriptureReferenceSystem.BooksOS[58].Hvo;

			// Add a footnote to the first content para2 of the second section.
			FdoOwningSequence<IStPara> contentParas = james.SectionsOS[1].ContentOA.ParagraphsOS;
			StTxtPara para2 = (StTxtPara)contentParas[0];
			StFootnote footnoteOrig3 = InsertTestFootnote(james, para2, 0, 0);
			StTxtPara para1 = new StTxtPara();
			contentParas.InsertAt(para1, 0);
			StFootnote footnoteOrig2 = InsertTestFootnote(james, para1, 0, 0);
			StText titleText = new StText();
			StTxtPara title = new StTxtPara();
			james.TitleOA = titleText;
			titleText.ParagraphsOS.Append(title);
			StFootnote footnoteOrig1 = InsertTestFootnote(james, title, 0, 0);

			// archive draft
			IScrDraft draft = m_scr.CreateSavedVersion("FootnoteOrder james", new int[] { james.Hvo });

			Assert.AreEqual(draftCount + 1, m_scr.ArchivedDraftsOC.Count);
			Assert.AreEqual("FootnoteOrder james", draft.Description);
			Assert.AreEqual(1, draft.BooksOS.Count);
			IScrBook revision = draft.BooksOS.FirstItem;
			Assert.IsFalse(james.Hvo == revision.Hvo);
			Assert.AreEqual(james.SectionsOS.Count, revision.SectionsOS.Count);
			IScrSection revSection1 = revision.SectionsOS[0];
			IScrSection revSection2 = revision.SectionsOS[1];
			Assert.IsTrue(james.SectionsOS[0].Hvo != revSection1.Hvo);
			Assert.IsTrue(james.SectionsOS[0].Hvo != revSection2.Hvo);
			Assert.IsTrue(james.SectionsOS[1].Hvo != revSection1.Hvo);
			Assert.IsTrue(james.SectionsOS[1].Hvo != revSection2.Hvo);
			FdoOwningSequence<IStPara> s2Paras = revSection2.ContentOA.ParagraphsOS;
			Assert.AreEqual(james.SectionsOS[1].ContentOA.ParagraphsOS.Count,
				s2Paras.Count);

			StTxtPara titleRev = (StTxtPara)revision.TitleOA.ParagraphsOS[0];
			StTxtPara paraRev1 = (StTxtPara)s2Paras[0];
			StTxtPara paraRev2 = (StTxtPara)s2Paras[1];
			Assert.IsFalse(title.Hvo == titleRev.Hvo);
			Assert.IsFalse(para1.Hvo == paraRev1.Hvo);
			Assert.IsFalse(para2.Hvo == paraRev2.Hvo);

			Assert.AreEqual(hvoBookRef, revision.BookIdRAHvo);

			// Check the footnote
			Assert.AreEqual(james.FootnotesOS.Count, revision.FootnotesOS.Count);
			Assert.AreEqual(footnoteOrig1.Hvo, james.FootnotesOS[0].Hvo);
			Assert.AreEqual(footnoteOrig2.Hvo, james.FootnotesOS[1].Hvo);
			Assert.AreEqual(footnoteOrig3.Hvo, james.FootnotesOS[2].Hvo);
			IStFootnote footnoteRev1 = revision.FootnotesOS[0];
			IStFootnote footnoteRev2 = revision.FootnotesOS[1];
			IStFootnote footnoteRev3 = revision.FootnotesOS[2];
			Assert.IsTrue(footnoteRev1.Hvo != footnoteOrig1.Hvo);
			Assert.IsTrue(footnoteRev2.Hvo != footnoteOrig2.Hvo);
			Assert.IsTrue(footnoteRev3.Hvo != footnoteOrig3.Hvo);

			VerifyFootnote(footnoteRev1, titleRev, 0);
			VerifyFootnote(footnoteRev2, paraRev1, 0);
			VerifyFootnote(footnoteRev3, paraRev2, 0);
		}
Example #21
0
		public void GetTextTokens_EmptyTsStringWithMissingWs()
		{
			ScrChecksDataSource dataSource = new ScrChecksDataSource(Cache);
			int iExodus = 2;
			IScrBook exodus = m_scrInMemoryCache.AddBookToMockedScripture(iExodus, "Exodus");
			m_scrInMemoryCache.AddTitleToMockedBook(exodus.Hvo, "Exodus");
			IScrSection section = m_scrInMemoryCache.AddIntroSectionToMockedBook(exodus.Hvo);

			// Make the heading paragraph empty, and with no writing system set
			CacheBase cachebase = m_inMemoryCache.CacheAccessor;
			StTxtPara paraIntroSectHead = new StTxtPara(Cache, cachebase.NewHvo(StTxtPara.kClassId));
			cachebase.AppendToFdoVector(section.HeadingOAHvo,
				(int)StText.StTextTags.kflidParagraphs, paraIntroSectHead.Hvo);
			cachebase.SetBasicProps(paraIntroSectHead.Hvo, section.HeadingOAHvo, (int)StTxtPara.kClassId,
				(int)StText.StTextTags.kflidParagraphs, 1);
			ITsPropsFactory propFact = TsPropsFactoryClass.Create();
			paraIntroSectHead.StyleRules = propFact.MakeProps(ScrStyleNames.IntroSectionHead, 0, 0);
			ITsStrBldr strBldr = TsStrBldrClass.Create();
			strBldr.Replace(0, 0, "", null);
			paraIntroSectHead.Contents.UnderlyingTsString = strBldr.GetString();
			cachebase.SetGuid(paraIntroSectHead.Hvo, (int)CmObjectFields.kflidCmObject_Guid, Guid.NewGuid());

			// Set up the intro section contents
			StTxtPara paraIntroSectContent = m_scrInMemoryCache.AddParaToMockedText(section.ContentOAHvo,
				ScrStyleNames.IntroParagraph);
			m_scrInMemoryCache.AddRunToMockedPara(paraIntroSectContent, "There's not much to say, really.", null);
			section.AdjustReferences();

			Assert.IsTrue(dataSource.GetText(iExodus, 0));
			IEnumerator<ITextToken> tokens = dataSource.TextTokens().GetEnumerator();
			VerifyToken(tokens, "Exodus", ScrStyleNames.MainBookTitle, string.Empty, exodus.TitleOA.ParagraphsOS[0]);
			BCVRef expectedRef = new BCVRef(iExodus, 1, 0);
			VerifyToken(tokens, string.Empty, ScrStyleNames.IntroSectionHead, string.Empty, expectedRef, expectedRef,
				true, TextType.Other, null, paraIntroSectHead, (int)StTxtPara.StTxtParaTags.kflidContents);
			VerifyToken(tokens, "There's not much to say, really.", ScrStyleNames.IntroParagraph, string.Empty, paraIntroSectContent);
			Assert.IsFalse(tokens.MoveNext());
		}
Example #22
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Sets the StyleRules and Contents properties for the new <see cref="StTxtPara"/>;
		/// then clears the builder.
		/// </summary>
		/// <param name="para">The <see cref="StTxtPara"/> that was just created</param>
		/// <param name="iPos">index of new paragraph</param>
		/// ------------------------------------------------------------------------------------
		private void SetStTxtParaPropertiesAndClearBuilder(StTxtPara para, int iPos)
		{
			// sets the new StTxtPara properties, with contents built up from prior calls
			ITsTextProps props = (ParaStylePropsProxy == null ?
				ParaProps : ParaStylePropsProxy.Props);
			para.StyleRules = props;

			para.Contents.UnderlyingTsString = m_ParaStrBldr.GetString();

			m_cache.PropChanged(null, PropChangeType.kpctNotifyAll,
				para.OwnerHVO,
				(int)StText.StTextTags.kflidParagraphs, iPos, 1, 0);

			// Clear the builder, for new paragraph
			m_ParaStrBldr.Replace(0, Length, null, null);
		}
Example #23
0
		public void Export()
		{
			using (MemoryStream stream = new MemoryStream())
			{
				//Set up some cells.
				int[] allParaWfics = m_helper.MakeAnnotationsUsedN(5);

				// This block makes the first row, puts CCAs in cells 1 and 2, and list refs in cells 1 and 2
				CmIndirectAnnotation row0 = m_helper.MakeFirstRow();
				int[] movedItems = new int[] { allParaWfics[1] };
				CmIndirectAnnotation cca0_1 = m_helper.MakeColumnAnnotation(1, new int[] { allParaWfics[0] }, row0);
				ICmPossibility marker = m_helper.GetAMarker();
				ICmBaseAnnotation cca0_1b = m_helper.MakeMarkerAnnotation(1, row0, marker);
				CmIndirectAnnotation cca0_2 = m_helper.MakeColumnAnnotation(2, movedItems, row0);
				ICmPossibility marker2 = m_helper.GetAnotherMarker();
				ICmBaseAnnotation cca0_2b = m_helper.MakeMarkerAnnotation(2, row0, marker2);
				ICmBaseAnnotation cca0_2c = m_helper.MakeMarkerAnnotation(2, row0, marker);

				// Now another row, and cell 4 on the first has a ref to it. The new row has a CCA with two wfics in cell 1. The cell is
				// two columns wide, being merged with the previous cell.
				CmIndirectAnnotation row1 = m_helper.MakeSecondRow();
				ICmIndirectAnnotation cca0_4 = m_helper.MakeDependentClauseMarker(row0, 4, new int[] { row1.Hvo }, "song", "2");
				CmIndirectAnnotation cca1_1 = m_helper.MakeColumnAnnotation(1, new int[] { allParaWfics[2], allParaWfics[3] }, row1);
				ConstituentChartLogic.SetFeature(Cache.MainCacheAccessor, cca1_1.Hvo, ConstituentChartLogic.mergeBeforeTag, true);

				// Let's have some notes on row 0.
				StText notesText = new StText();
				row0.TextOA = notesText;
				StTxtPara notesPara = new StTxtPara();
				notesText.ParagraphsOS.Append(notesPara);
				notesPara.Contents.UnderlyingTsString = Cache.MakeAnalysisTss("This is a test note");

				// And some moved text in row 1
				CmIndirectAnnotation cca1_2 = m_helper.MakeColumnAnnotation(2, new int[] { allParaWfics[4] }, row1);
				ConstituentChartLogic.SetFeature(Cache.MainCacheAccessor, cca1_2.Hvo,
					ConstituentChartLogic.MovedTextFeatureName, true);
				CmIndirectAnnotation cca2_3 = m_helper.MakeMovedTextAnnotation(3, cca1_2, row1, "Preposed");

				// We need four rows to properly test the variations on endPara/endSent
				CmIndirectAnnotation row2 = m_helper.MakeRow(m_chart, "2");
				ConstituentChartLogic.SetFeature(Cache.MainCacheAccessor, row2.Hvo, ConstituentChartLogic.EndSentFeatureName, true);
				CmIndirectAnnotation row3 = m_helper.MakeRow(m_chart, "3");
				ConstituentChartLogic.SetFeature(Cache.MainCacheAccessor, row3.Hvo, ConstituentChartLogic.EndParaFeatureName, true);
				ConstituentChartLogic.SetFeature(Cache.MainCacheAccessor, row3.Hvo, ConstituentChartLogic.EndSentFeatureName, true);
				CmIndirectAnnotation row4 = m_helper.MakeRow(m_chart, "4");


				XmlWriter writer = new XmlTextWriter(stream, Encoding.UTF8);
				ConstChartVc vc = new ConstChartVc(m_chartBody);
				vc.LineChoices = m_chartBody.LineChoices;
				DiscourseExporter exporter = new DiscourseExporter(m_inMemoryCache.Cache, writer, m_chart.Hvo,
					vc, m_inMemoryCache.Cache.DefaultAnalWs);
				writer.WriteStartDocument();
				writer.WriteStartElement("document");
				exporter.ExportDisplay();
				writer.WriteEndElement();
				writer.WriteEndDocument();
				writer.Flush(); // Close makes it unuseable
				stream.Position = 0;
				StreamReader reader = new StreamReader(stream, Encoding.UTF8);
				string result = reader.ReadToEnd();
				XmlDocument doc = new XmlDocument();
				doc.LoadXml(result);
				XmlNode docNode = doc.DocumentElement;
				Assert.AreEqual("document", docNode.Name);
				XmlNode chartNode = VerifyNode("chart", docNode, 0, "chart", 7, 0);
				VerifyTitleRow(chartNode);
				VerifyTitle2Row(chartNode);
				VerifyFirstDataRow(chartNode);
				VerifySecondDataRow(chartNode);
				XmlNode thirdRow = VerifyNode("row", chartNode, 4, "row", 8, 3);
				AssertAttr(thirdRow, "endSent", "true");
				XmlNode fourthRow = VerifyNode("row", chartNode, 5, "row", 8, 3);
				AssertAttr(fourthRow, "endPara", "true");


				XmlNode langNode = VerifyNode("languages", docNode, 1, "languages", 2, 0);
				XmlNode enNode = VerifyNode("english lang node", langNode, 0, "language", 0, 2);
				AssertAttr(enNode, "lang", "en");
				AssertAttr(enNode, "font", null); // don't verify exact font, may depend on installation.

			}

		}
Example #24
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// A helper method for book merger tests-
		/// Verifies the contents of the given difference and given SubDiffForParas
		/// when the subdiff provides only reference points (i.e. IPs) as the first subdiff.
		/// for rootdiff types: ParagraphStructureChange, ParagraphSplitInCurrent,
		/// ParagraphMergedInCurrent.
		/// </summary>
		/// <param name="rootDiff">The root diff.</param>
		/// <param name="iSubDiff">The i sub diff.</param>
		/// <param name="paraCurr">The para curr.</param>
		/// <param name="ichCurr">The ich curr.</param>
		/// <param name="paraRev">The para rev.</param>
		/// <param name="ichRev">The ich rev.</param>
		/// ------------------------------------------------------------------------------------
		public static void VerifySubDiffParaReferencePoints(Difference rootDiff, int iSubDiff,
			StTxtPara paraCurr, int ichCurr,
			StTxtPara paraRev, int ichRev)
		{
			Assert.IsTrue((rootDiff.DiffType & DifferenceType.ParagraphStructureChange) != 0 ||
				(rootDiff.DiffType & DifferenceType.ParagraphSplitInCurrent) != 0 ||
				(rootDiff.DiffType & DifferenceType.ParagraphMergedInCurrent) != 0);
			// a para reference point subDiff must be at index 0 (preceeding the ParaAdded/Missing subdiffs)
			Assert.AreEqual(0, iSubDiff);

			Difference subDiff = rootDiff.SubDiffsForParas[iSubDiff];
			Assert.AreEqual(DifferenceType.NoDifference, subDiff.DiffType);

			Assert.AreEqual(paraCurr.Hvo, subDiff.HvoCurr);
			Assert.AreEqual(ichCurr, subDiff.IchMinCurr);
			Assert.AreEqual(ichCurr, subDiff.IchLimCurr);

			Assert.AreEqual(paraRev.Hvo, subDiff.HvoRev);
			Assert.AreEqual(ichRev, subDiff.IchMinRev);
			Assert.AreEqual(ichRev, subDiff.IchLimRev);

			Assert.IsNull(subDiff.HvosSectionsRev);
			Assert.IsNull(subDiff.HvosSectionsRev);
			Assert.IsNull(subDiff.StyleNameCurr);
			Assert.IsNull(subDiff.StyleNameRev);
			Assert.IsNull(subDiff.SubDiffsForORCs);
		}
Example #25
0
		public void GetTextRepresentation_twoParas()
		{
			CheckDisposed();

			m_footnotePara.Contents.UnderlyingTsString =
				m_strFact.MakeString("Paragraph One", m_vernWs);

			// create second para
			StTxtPara para = new StTxtPara();
			m_footnote.ParagraphsOS.Append(para);

			// Set the paragraph style
			para.StyleRules = StyleUtils.ParaStyleTextProps("Note Exegesis Paragraph");

			ITsStrBldr bldr = TsStrBldrClass.Create();
			bldr.Replace(0, 0, "Paragraph Two", StyleUtils.CharStyleTextProps(
				"Foreign", m_wsUr));
			para.Contents.UnderlyingTsString = bldr.GetString();

			string result = m_footnote.GetTextRepresentation();
			Assert.AreEqual(@"<FN><M>o</M><ShowMarker/><P><PS>Note General Paragraph</PS>" +
				@"<RUN WS='fr'>Paragraph One</RUN></P><P><PS>Note Exegesis Paragraph</PS>" +
				@"<RUN WS='ur' CS='Foreign'>Paragraph Two</RUN></P></FN>", result);
		}
Example #26
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// A helper method for book merger tests-
		/// Verifies the contents of the given difference and given SubDiffForParas
		/// for subdiff types: missing/added paragraphs.
		/// </summary>
		/// <param name="rootDiff">The root diff.</param>
		/// <param name="iSubDiff">The para subdiff index.</param>
		/// <param name="subDiffType">diffType of the subdiff.</param>
		/// <param name="paraAdded">The para added.</param>
		/// <param name="ichLim">The ichlim for the paraAdded. Often this may be the end of the para,
		/// or it may indicate only the first portion (ScrVerse) of the final paragraph.</param>
		/// ------------------------------------------------------------------------------------
		public static void VerifySubDiffParaAdded(Difference rootDiff, int iSubDiff,
			DifferenceType subDiffType, StTxtPara paraAdded, int ichLim)
		{
			Assert.AreEqual(DifferenceType.ParagraphStructureChange, rootDiff.DiffType);
			// a ParaAdded/Missing subDiff must not be at index 0 (paragraph reference points must be in that subdiff
			Assert.LessOrEqual(1, iSubDiff);

			Difference subDiff = rootDiff.SubDiffsForParas[iSubDiff];
			Assert.AreEqual(subDiffType, subDiff.DiffType);

			switch (subDiffType)
			{
				case DifferenceType.ParagraphAddedToCurrent:
					Assert.AreEqual(paraAdded.Hvo, subDiff.HvoCurr);
					Assert.AreEqual(0, subDiff.IchMinCurr);
					Assert.AreEqual(ichLim, subDiff.IchLimCurr); //subDiff may be only first portion of the final paragraph

					Assert.AreEqual(0, subDiff.HvoRev);
					Assert.AreEqual(0, subDiff.IchMinRev);
					Assert.AreEqual(0, subDiff.IchLimRev);
					break;

				case DifferenceType.ParagraphMissingInCurrent:
					Assert.AreEqual(0, subDiff.HvoCurr);
					Assert.AreEqual(0, subDiff.IchMinCurr);
					Assert.AreEqual(0, subDiff.IchLimCurr);

					Assert.AreEqual(paraAdded.Hvo, subDiff.HvoRev);
					Assert.AreEqual(0, subDiff.IchMinRev);
					Assert.AreEqual(ichLim, subDiff.IchLimRev); //subDiff may be only first portion of the final paragraph
					break;

				default:
					Assert.Fail("Invalid subDiff type for a Paragraph Added/Missing subDiff");
					break;
			}

			Assert.IsNull(subDiff.HvosSectionsRev);
			Assert.IsNull(subDiff.HvosSectionsRev);
			Assert.IsNull(subDiff.StyleNameCurr);
			Assert.IsNull(subDiff.StyleNameRev);
			Assert.IsNull(subDiff.SubDiffsForORCs);
		}
Example #27
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Adds the overrides to highlight a footnote diff.
		/// </summary>
		/// <param name="hvo">The hvo of the footnote paragraph.</param>
		/// ------------------------------------------------------------------------------------
		private void AddOverridesToHighlightFootnoteDiff(int hvo)
		{
			Difference diff = FindSubDiffForFootnote(hvo);
			if (diff == null)
				return;

			StTxtPara para = new StTxtPara(Cache, hvo);

			// Get the footnote which contains the paragraph.
			int ownerHvo = para.OwnerHVO;
			Debug.Assert(m_cache.GetClassOfObject(ownerHvo) == StFootnote.kClassId);
			if (m_cache.GetClassOfObject(ownerHvo) != StFootnote.kClassId)
				return; //don't override the props for this para; continue on gracefully
			ScrFootnote footnote = new ScrFootnote(Cache, ownerHvo);

			// Only add offset to first paragraph in footnote (should only be one para)
			int offset = 0;
			if (footnote.ParagraphsOS[0].Hvo == hvo)
			{
				int refLength = footnote.GetReference(m_wsDefault).Length;
				int markerLength = footnote.FootnoteMarker.Length;
				//add one for the space in between (added in StVc)
				offset = refLength + markerLength + 1;
			}

			const uint knNinch = 0x80000000;


			// Now add appropriate properties.
			// Need to add override properties for each run in the
			// range to be highlighted.
			int ichOverrideMin = diff.GetIchMin(m_fRev);
			ITsString tss = para.Contents.UnderlyingTsString;
			TsRunInfo runInfo;
			int ichOverrideLim;
			int prevLim = 0;
			do
			{
				tss.FetchRunInfoAt(ichOverrideMin, out runInfo);
				ichOverrideLim = Math.Min(diff.GetIchLim(m_fRev), runInfo.ichLim);
				// Prevent infinite loop in case of bad data in difference
				if (ichOverrideLim == prevLim)
					break;
				prevLim = ichOverrideLim;
				DispPropOverride prop = new DispPropOverride();
				prop.chrp.clrBack = DiffViewVc.kHighlightColor;
				prop.chrp.clrFore = knNinch;
				prop.chrp.clrUnder = knNinch;
				prop.chrp.dympOffset = -1;
				prop.chrp.ssv = -1;
				prop.chrp.unt = -1;
				prop.chrp.ttvBold = -1;
				prop.chrp.ttvItalic = -1;
				prop.chrp.dympHeight = -1;
				prop.chrp.szFaceName = null;
				prop.chrp.szFontVar = null;
				prop.ichMin = ichOverrideMin + offset;
				prop.ichLim = ichOverrideLim + offset;
				m_DispPropOverrides.Add(prop);
				ichOverrideMin = ichOverrideLim;
			}
			while (ichOverrideLim < diff.GetIchLim(m_fRev));
		}
Example #28
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Create a new <see cref="StTxtPara"/>, owned by the given <see cref="StText"/>.
		/// Set it with data accumulated in this builder.
		/// </summary>
		/// <param name="hvoOwner">HVO of the <see cref="StText"/> that is to own the new
		/// paragraph</param>
		/// <param name="iPos">0-based index of the position in the sequence of paragraphs where the
		/// new paragraph is to be inserted. If a paragraph is already in this position, the new
		/// paragraph will be inserted before the existing paragraph.</param>
		/// <returns>A new StTextPara whose contents are built up from the prior calls
		/// to <see cref="AppendRun"/> and whose style is set based on the current value of
		/// <see cref="ParaStylePropsProxy"/>.</returns>
		/// ------------------------------------------------------------------------------------
		public StTxtPara CreateParagraph(int hvoOwner, int iPos)
		{
			CheckDisposed();
			// ENHANCE: Could maybe squeeze a little more performance out of this by calling the
			// stored procedure that used to be called by TeImporter to create paragraphs.

			// insert a new para in the owner's collection
			StTxtPara para = new StTxtPara();
			StText text = new StText(m_cache, hvoOwner);
			text.ParagraphsOS.InsertAt(para, iPos);

			SetStTxtParaPropertiesAndClearBuilder(para, iPos);

			return para;
		}
Example #29
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Calculates the diff type of the label text.
		/// </summary>
		/// <param name="baseDiff">the base difference</param>
		/// <param name="fIsCurr">true if the label is for the Current pane; false if for the
		/// Revision</param>
		/// <returns>the text of the label</returns>
		/// ------------------------------------------------------------------------------------
		private string CalcLblText(Difference baseDiff, bool fIsCurr)
		{
			// True if the Current pane is the newer text; False if Revision is newer
			// set a local for now; when we import into a revision, this will need to be a parameter
			ScrDraft draft = new ScrDraft(m_cache, m_bookMerger.BookRev.OwnerHVO);
			bool fCurrIsNewer = (draft.Type == ScrDraftType.SavedVersion);

			DifferenceType diffType = CombineDifferenceTypes(baseDiff);
			int paraHvo = (fIsCurr) ? baseDiff.HvoCurr : baseDiff.HvoRev;
			int ichMin = (fIsCurr) ? baseDiff.IchMinCurr : baseDiff.IchMinRev;

			string labelText = string.Empty;
			if ((diffType & DifferenceType.ParagraphStyleDifference) != 0)
			{
				// paragraph style difference
				StTxtPara para = new StTxtPara(m_cache, paraHvo);
				ITsTextProps props = para.StyleRules;
				if (props != null)
				{
					labelText = AppendLabel(labelText,
						props.GetStrPropValue((int)FwTextPropType.ktptNamedStyle));
				}
				else
					labelText = AppendLabel(labelText, TeDiffViewResources.kstidMissingParaStyle);
			}
			else if ((diffType & DifferenceType.CharStyleDifference) != 0)
			{
				string styleName = (fIsCurr) ? baseDiff.StyleNameCurr : baseDiff.StyleNameRev;
				if (styleName == null)
					styleName = FdoResources.DefaultParaCharsStyleName;
				labelText = AppendLabel(labelText, styleName);
			}
			else if ((diffType & DifferenceType.WritingSystemDifference) != 0)
			{
				string wsName = (fIsCurr) ? baseDiff.WsNameCurr : baseDiff.WsNameRev;
				labelText = AppendLabel(labelText, wsName);
			}
			else if ((diffType & DifferenceType.MultipleCharStyleDifferences) != 0)
			{
				labelText = AppendLabel(labelText, TeDiffViewResources.kstidMultipleStyleDiffs);
			}
			else if ((diffType & DifferenceType.MultipleWritingSystemDifferences) != 0)
			{
				labelText = AppendLabel(labelText, TeDiffViewResources.kstidMultipleWritingSystemDiffs);
			}

			// The remaining labels are for "added/deleted/changed" types of differences;
			// for these differences, we put a label ONLY on the pane with the 'newer' text.
			// If we are in the 'older' pane, quit now.
			if (fCurrIsNewer != fIsCurr)
				return labelText;

			if ((diffType & DifferenceType.TextDifference) != 0)
			{
				// normal text difference; append to the style label, if any
				labelText = AppendLabel(labelText, TeDiffViewResources.kstidTextChanged);
			}

			if ((diffType & DifferenceType.FootnoteDifference) != 0)
			{
				string sFootnoteDiffLabel = string.Empty;
				Debug.Assert(baseDiff.HasORCSubDiffs,
					"Found a footnote subdifference whose owning diff does not have subdiffs for ORCs");
				sFootnoteDiffLabel = GetFootnoteDifferenceText(baseDiff, fIsCurr); // add info from my ORC subdiffs.

				// footnote differences; append to the style label
				labelText = AppendLabel(labelText, sFootnoteDiffLabel);
			}

			if ((diffType & DifferenceType.FootnoteMissingInCurrent) != 0)
			{
				// Footnote missing in current difference
				labelText = AppendLabel(labelText, fIsCurr ? TeDiffViewResources.kstidFootnoteDeleted
					: TeDiffViewResources.kstidFootnoteAdded);
			}
			if ((diffType & DifferenceType.FootnoteAddedToCurrent) != 0)
			{
				// Footnote missing in revision difference
				labelText = AppendLabel(labelText, fIsCurr ? TeDiffViewResources.kstidFootnoteAdded
					: TeDiffViewResources.kstidFootnoteDeleted);
			}

			if ((diffType & DifferenceType.PictureAddedToCurrent) != 0)
			{
				// Picture missing in current difference
				labelText = AppendLabel(labelText, fIsCurr ? TeDiffViewResources.kstidPictureAdded
					: TeDiffViewResources.kstidPictureMissing);
			}
			if ((diffType & DifferenceType.PictureMissingInCurrent) != 0)
			{
				// Picture missing in current difference
				labelText = AppendLabel(labelText, fIsCurr ? TeDiffViewResources.kstidPictureMissing
					: TeDiffViewResources.kstidPictureAdded);
			}

			if ((diffType & DifferenceType.VerseMissingInCurrent) != 0)
			{
				// Verse missing in current difference
				labelText = fIsCurr ? TeDiffViewResources.kstidVerseDeleted
					: TeDiffViewResources.kstidVerseAdded;
			}
			else if ((diffType & DifferenceType.VerseAddedToCurrent) != 0)
			{
				// Verse missing in revision difference
				labelText = fIsCurr ? TeDiffViewResources.kstidVerseAdded
					: TeDiffViewResources.kstidVerseDeleted;
			}

			if ((diffType & DifferenceType.ParagraphMissingInCurrent) != 0)
			{
				// Paragraph missing in current difference
				labelText = fIsCurr ? TeDiffViewResources.kstidParagraphDeleted
					: TeDiffViewResources.kstidParagraphAdded;
			}
			else if ((diffType & DifferenceType.ParagraphAddedToCurrent) != 0)
			{
				// Paragraph missing in revision difference
				labelText = fIsCurr ? TeDiffViewResources.kstidParagraphAdded
					: TeDiffViewResources.kstidParagraphDeleted;
			}

			if ((diffType & DifferenceType.StanzaBreakMissingInCurrent) != 0)
			{
				// Stanza break missing in current difference
				labelText = fIsCurr ? TeDiffViewResources.kstidStanzaBreakDeleted
					: TeDiffViewResources.kstidStanzaBreakAdded;
			}
			else if ((diffType & DifferenceType.StanzaBreakAddedToCurrent) != 0)
			{
				// Stanza break missing in revision difference
				labelText = fIsCurr ? TeDiffViewResources.kstidStanzaBreakAdded
					: TeDiffViewResources.kstidStanzaBreakDeleted;
			}

			if ((diffType & DifferenceType.SectionAddedToCurrent) != 0)
			{
				if (baseDiff.HvosSectionsCurr.Length > 1)
					labelText = fIsCurr ? TeDiffViewResources.kstidSectionsAdded
						: TeDiffViewResources.kstidSectionsDeleted;
				else
					labelText = fIsCurr ? TeDiffViewResources.kstidSectionAdded
						: TeDiffViewResources.kstidSectionDeleted;
			}
			else if ((diffType & DifferenceType.SectionMissingInCurrent) != 0)
			{
				if (baseDiff.HvosSectionsRev.Length > 1)
					labelText = fIsCurr ? TeDiffViewResources.kstidSectionsDeleted
						: TeDiffViewResources.kstidSectionsAdded;
				else
					labelText = fIsCurr ? TeDiffViewResources.kstidSectionDeleted
						: TeDiffViewResources.kstidSectionAdded;
			}

			if ((diffType & DifferenceType.SectionHeadAddedToCurrent) != 0)
			{
				// Section split in Current difference
				labelText = fIsCurr ? TeDiffViewResources.kstidSectionHeadAdded
					: TeDiffViewResources.kstidSectionHeadDeleted;
			}
			else if ((diffType & DifferenceType.SectionHeadMissingInCurrent) != 0)
			{
				// Section merged in Current difference
				labelText = fIsCurr ? TeDiffViewResources.kstidSectionHeadDeleted
					: TeDiffViewResources.kstidSectionHeadAdded;
			}

			if ((diffType & DifferenceType.SectionAddedToCurrent) != 0 && baseDiff.HasParaSubDiffs)
			{
				Debug.Assert(((Difference)baseDiff.SubDiffsForParas[0]).DiffType == DifferenceType.VerseMoved);
				//sMovedDiffLabel = string.Format(TeDiffViewResources.fmt,
				//	CalcLblText((Difference)diff.subDiffs[0], fIsCurr));  "Verse 10 moved"
				string sMovedDiffLabel = baseDiff.SubDiffsForParas.Count == 1 ?
					TeDiffViewResources.kstidVerseMoved : TeDiffViewResources.kstidVersesMoved;
				labelText = AppendLabel(labelText, sMovedDiffLabel);
			}

			if ((diffType & DifferenceType.ParagraphSplitInCurrent) != 0 ||
				(diffType & DifferenceType.ParagraphMergedInCurrent) != 0 ||
				(diffType & DifferenceType.ParagraphStructureChange) != 0)
			{
				if ((diffType & DifferenceType.ParagraphAddedToCurrent) != 0 &&
					(diffType & DifferenceType.ParagraphMissingInCurrent) != 0)
				{
					labelText = AppendLabel(labelText,
						CreateParaStructLabel(baseDiff, fIsCurr, fCurrIsNewer));
				}
				else
					labelText = CreateParaStructLabel(baseDiff, fIsCurr, fCurrIsNewer);
			}

			// if we didn't find a difference we know about then just put some text in saying
			// that we don't know about the current difference.
			if (labelText == string.Empty)
				labelText = "Unknown DiffType";
			return labelText;
		}
Example #30
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// A helper method for book merger tests-
		/// Verifies the contents of the given sub-difference
		/// for a two-sided subDiff representing a text comparison.
		/// </summary>
		/// <remarks>char styles are not verified here; test code should just check
		/// those directly if relevant</remarks>
		/// ------------------------------------------------------------------------------------
		//TODO: this is used only for VerseMoved subdiffs. rename it as VerifySubDiffVerseMoved.
		// provide logic appropriate for VerseMoved, and don't rely on VerifySubDiffTextCompared
		// Maybe just revert to the 2006 logic when VerseMoved was implemented.
		public static void VerifySubDiffTextCompared(Difference rootDiff, int iSubDiff,
			BCVRef start, BCVRef end, DifferenceType subDiffType,
			StTxtPara paraCurr, int ichMinCurr, int ichLimCurr,
			StTxtPara paraRev, int ichMinRev, int ichLimRev)
		{
			Difference subDiff = rootDiff.SubDiffsForParas[iSubDiff];
			// verify the Scripture references
			Assert.AreEqual(start, subDiff.RefStart);
			Assert.AreEqual(end, subDiff.RefEnd);

			// verify everything else
			VerifySubDiffTextCompared(rootDiff, iSubDiff, subDiffType, paraCurr, ichMinCurr, ichLimCurr,
				paraRev, ichMinRev, ichLimRev);
		}