Example #1
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Initializes a new instance of the <see cref="XmlNotePara"/> class based on the given
		/// StTxtPara.
		/// </summary>
		/// <param name="stTxtPara">The FDO paragraph.</param>
		/// <param name="wsDefault">The default (analysis) writing system.</param>
		/// <param name="lgwsf">The writing system factory.</param>
		/// ------------------------------------------------------------------------------------
		public XmlNotePara(IStTxtPara stTxtPara, int wsDefault, ILgWritingSystemFactory lgwsf)
		{
			// REVIEW: Ask TomB about this. The only paragraph style allowed in
			// TE for notes is "Remark" so is it necessary to write it to the XML?
			// It causes a problem for the OXES validator.
			//StyleName = stTxtPara.StyleName;

			ITsString tssParaContents = stTxtPara.Contents;
			if (tssParaContents.RunCount == 0)
				return;

			int dummy;
			int wsFirstRun = tssParaContents.get_Properties(0).GetIntPropValues(
				(int)FwTextPropType.ktptWs, out dummy);

			//if (wsFirstRun != wsDefault)
			IcuLocale = lgwsf.GetStrFromWs(wsFirstRun);

			for (int iRun = 0; iRun < tssParaContents.RunCount; iRun++)
			{
				ITsTextProps props = tssParaContents.get_Properties(iRun);
				string text = tssParaContents.get_RunText(iRun);
				if (TsStringUtils.IsHyperlink(props))
					Runs.Add(new XmlHyperlinkRun(wsFirstRun, lgwsf, text, props));
				else
					Runs.Add(new XmlTextRun(wsFirstRun, lgwsf, text, props));
			}
		}
Example #2
0
		public override void Initialize()
		{
			CheckDisposed();
			base.Initialize();
			//m_inMemoryCache.InitializeAnnotationDefs();
			InstallVirtuals(@"Language Explorer\Configuration\Words\AreaConfiguration.xml",
				new string[] { "SIL.FieldWorks.IText.ParagraphSegmentsVirtualHandler", "SIL.FieldWorks.IText.OccurrencesInTextsVirtualHandler" });
			m_wsVern = Cache.DefaultVernWs;
			m_wsTrans = Cache.DefaultAnalWs;
			m_text = new Text();
			Cache.LangProject.TextsOC.Add(m_text);
			m_para = new StTxtPara();
			StText text = new StText();
			m_text.ContentsOA = text;
			text.ParagraphsOS.Append(m_para);
			m_trans = new CmTranslation();
			m_para.TranslationsOC.Add(m_trans);
			kflidFT = StTxtPara.SegmentFreeTranslationFlid(Cache);
			kflidSegments = StTxtPara.SegmentsFlid(Cache);
			m_btPoss = Cache.LangProject.TranslationTagsOA.LookupPossibilityByGuid(
				LangProject.kguidTranBackTranslation);
			m_trans.TypeRA = m_btPoss;
			m_fWasUseScriptDigits = Cache.LangProject.TranslatedScriptureOA.UseScriptDigits;
			Cache.LangProject.TranslatedScriptureOA.UseScriptDigits = false;
			// do we need to set status?
		}
		/// <summary>
		/// non-undoable task
		/// </summary>
		private void DoSetupFixture()
		{
			var textFactory = Cache.ServiceLocator.GetInstance<ITextFactory>();
			var stTextFactory = Cache.ServiceLocator.GetInstance<IStTextFactory>();
			m_text = textFactory.Create();
			//Cache.LangProject.TextsOC.Add(m_text);
			m_stText = stTextFactory.Create();
			m_text.ContentsOA = m_stText;
			m_para0 = m_stText.AddNewTextPara(null);
			m_para0.Contents = TsStringUtils.MakeTss("Xxxhope xxxthis xxxwill xxxdo. xxxI xxxhope.", Cache.DefaultVernWs);
			m_para1 = m_stText.AddNewTextPara(null);
			m_para1.Contents = TsStringUtils.MakeTss("Xxxcertain xxxto xxxcatch xxxa xxxfrog. xxxCertainly xxxcan. xxxOn xxxLake xxxMonroe.", Cache.DefaultVernWs);
			m_para2 = null;

			using (ParagraphParser pp = new ParagraphParser(Cache))
				foreach (IStTxtPara para in m_stText.ParagraphsOS)
					pp.Parse(para);

			m_expectedAnOcs = new List<AnalysisOccurrence>();
			foreach (IStTxtPara para in m_stText.ParagraphsOS)
				foreach (ISegment seg in para.SegmentsOS)
					for (int i = 0; i < seg.AnalysesRS.Count; i++)
						m_expectedAnOcs.Add(new AnalysisOccurrence(seg, i));

			m_expectedAnOcsPara0 = new List<AnalysisOccurrence>();
			foreach (ISegment seg in m_para0.SegmentsOS)
				for (int i = 0; i < seg.AnalysesRS.Count; i++)
					m_expectedAnOcsPara0.Add(new AnalysisOccurrence(seg, i));
		}
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Create minimal test data required for every test.
		/// </summary>
		/// ------------------------------------------------------------------------------------
		protected override void CreateTestData()
		{
			base.CreateTestData();
			m_helper = new DiscourseTestHelper(Cache);
			m_firstPara = m_helper.FirstPara;
			m_stText = m_firstPara.Owner as IStText;
		}
Example #5
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Make one for converting the specified paragraph.
		/// </summary>
		/// <param name="para">The paragraph.</param>
		/// <param name="wsBt">The writing system for which to do the conversion.</param>
		/// ------------------------------------------------------------------------------------
		private BtConverter(IStTxtPara para, int wsBt)
		{
			m_para = para;
			m_cache = para.Cache;
			m_cpe = m_cache.ServiceLocator.UnicodeCharProps;
			m_scr = para.Cache.LangProject.TranslatedScriptureOA;
			m_wsBt = wsBt;
		}
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Override to end the undoable UOW, Undo everything, and 'commit',
		/// which will essentially clear out the Redo stack.
		/// </summary>
		/// ------------------------------------------------------------------------------------
		public override void TestTearDown()
		{
			m_philemon = null;
			m_section = null;
			m_para = null;

			base.TestTearDown();
		}
Example #7
0
 /// <summary>
 /// Make an LfParagraph object from an FDO StTxtPara.
 /// </summary>
 /// <returns>The LFParagraph.</returns>
 /// <param name="fdoPara">FDO StTxtPara object to convert.</param>
 public static LfParagraph FdoParaToLfPara(IStTxtPara fdoPara, ILgWritingSystemFactory wsf)
 {
     var lfPara = new LfParagraph();
     lfPara.Guid = fdoPara.Guid;
     lfPara.StyleName = fdoPara.StyleName;
     lfPara.Content = ConvertFdoToMongoTsStrings.TextFromTsString(fdoPara.Contents, wsf);
     return lfPara;
 }
Example #8
0
		/// <summary>
		/// Make one for converting the specified paragraph.
		/// </summary>
		/// <param name="para"></param>
		public BtConverter(IStTxtPara para)
		{
			m_para = para;
			m_cache = para.Cache;
			kflidFT = StTxtPara.SegmentFreeTranslationFlid(m_cache);
			kflidSegments = StTxtPara.SegmentsFlid(m_cache);
			m_cpe = m_cache.LanguageWritingSystemFactoryAccessor.UnicodeCharProps;
			m_scr = para.Cache.LangProject.TranslatedScriptureOA;
		}
		private void FixtureSetupInternal()
		{
			// Setup default analysis ws
			m_wsEn = Cache.ServiceLocator.WritingSystemManager.Get("en").Handle;
			m_text = Cache.ServiceLocator.GetInstance<ITextFactory>().Create();
			//Cache.LangProject.TextsOC.Add(m_text);
			Cache.LangProject.TranslatedScriptureOA = Cache.ServiceLocator.GetInstance<IScriptureFactory>().Create();
			m_para = Cache.ServiceLocator.GetInstance<IStTxtParaFactory>().Create();
			IStText text = Cache.ServiceLocator.GetInstance<IStTextFactory>().Create();
			m_text.ContentsOA = text;
			text.ParagraphsOS.Add(m_para);
		}
		/// <summary>
		///
		/// </summary>
		public override void TestSetup()
		{
			base.TestSetup();

			m_wsVern = Cache.DefaultVernWs;
			m_wsTrans = Cache.DefaultAnalWs;
			m_book = Cache.ServiceLocator.GetInstance<IScrBookFactory>().Create(1);
			m_section = Cache.ServiceLocator.GetInstance<IScrSectionFactory>().Create();
			m_book.SectionsOS.Add(m_section);
			m_section.ContentOA = m_text = Cache.ServiceLocator.GetInstance<IStTextFactory>().Create(); ;
			m_para = m_text.AddNewTextPara(ScrStyleNames.NormalParagraph);
		}
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Override to start an undoable UOW.
		/// </summary>
		/// ------------------------------------------------------------------------------------
		public override void TestSetup()
		{
			base.TestSetup();

			m_editingHelper.m_fUsingMockedSelection = true;
			m_philemon = AddBookToMockedScripture(57, "Philemon");
			AddTitleToMockedBook(m_philemon, "Philemon");
			m_section = AddSectionToMockedBook(m_philemon);
			m_para = AddParaToMockedSectionContent(m_section,
				ScrStyleNames.NormalParagraph);
			AddRunToMockedPara(m_para, "this is text", null);
		}
Example #12
0
		private static AnalysisOccurrence[] GetParaAnalyses(IStTxtPara para)
		{
			var result = new List<AnalysisOccurrence>();
			var point1 = new AnalysisOccurrence(para.SegmentsOS[0], 0);
			if (!point1.IsValid)
				return result.ToArray();
			do
			{
				if (point1.HasWordform)
					result.Add(point1);
				point1 = point1.NextWordform();
			} while (point1 != null && point1.IsValid);
			return result.ToArray();
		}
Example #13
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Create test data for tests.
		/// </summary>
		/// ------------------------------------------------------------------------------------
		protected override void CreateTestData()
		{
			m_servloc = Cache.ServiceLocator;
			m_text = AddInterlinearTextToLangProj("My Interlinear Text");
			m_stTextPara = AddParaToInterlinearTextContents(m_text, "Here is a sentence I can chart.");
			m_stText = m_text.ContentsOA;
			m_tssFact = Cache.TsStrFactory;
			m_rowFact = m_servloc.GetInstance<IConstChartRowFactory>();
			m_wordGrpFact = m_servloc.GetInstance<IConstChartWordGroupFactory>();
			m_possFact = m_servloc.GetInstance<ICmPossibilityFactory>();
			m_wfiFact = m_servloc.GetInstance<IWfiWordformFactory>();
			m_mtMrkrFact = m_servloc.GetInstance<IConstChartMovedTextMarkerFactory>();
			m_clsMrkrFact = m_servloc.GetInstance<IConstChartClauseMarkerFactory>();
		}
Example #14
0
		public override void Initialize()
		{
			CheckDisposed();
			base.Initialize();
			m_inMemoryCache.InitializeAnnotationDefs();
			InstallVirtuals(@"Language Explorer\Configuration\Words\AreaConfiguration.xml",
				new string[] { "SIL.FieldWorks.IText.ParagraphSegmentsVirtualHandler", "SIL.FieldWorks.IText.OccurrencesInTextsVirtualHandler" });
			m_text = new Text();
			Cache.LangProject.TextsOC.Add(m_text);
			m_para = new StTxtPara();
			StText text = new StText();
			m_text.ContentsOA = text;
			text.ParagraphsOS.Append(m_para);
		}
Example #15
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Creates a text for testing.
		/// </summary>
		/// ------------------------------------------------------------------------------------
		private void CreateTestText()
		{
			m_txt = m_servLoc.GetInstance<ITextFactory>().Create();
			//Cache.LangProject.TextsOC.Add(m_txt);
			m_stTxt = m_servLoc.GetInstance<IStTextFactory>().Create();
			m_txt.ContentsOA = m_stTxt;
			m_txtPara = m_txt.ContentsOA.AddNewTextPara(null);

			// 0         1         2         3         4
			// 0123456789012345678901234567890123456789012
			// This is a test string for CopyObject tests.

			int hvoVernWs = Cache.DefaultVernWs;
			m_txtPara.Contents = TsStringUtils.MakeTss("This is a test string for CopyObject tests.", hvoVernWs);
		}
Example #16
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Creates and initializes a footnote.
		/// </summary>
		/// ------------------------------------------------------------------------------------
		protected override void CreateTestData()
		{
			m_vernWs = Cache.DefaultVernWs;
			// create footnote
			IFdoServiceLocator servloc = Cache.ServiceLocator;
			m_footnote = servloc.GetInstance<IScrFootnoteFactory>().Create();
			m_book = AddBookToMockedScripture(1, "Genesis");
			m_book.FootnotesOS.Add(m_footnote);
			m_footnote.FootnoteMarker = TsStringUtils.MakeTss("a", m_vernWs);
			m_scr.DisplaySymbolInFootnote = true;
			m_scr.DisplayFootnoteReference = false;

			// create one empty footnote para
			m_footnotePara = m_footnote.AddNewTextPara(ScrStyleNames.NormalFootnoteParagraph);
			m_footnotePara.Contents = TsStringUtils.MakeTss(string.Empty, m_vernWs);
		}
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Creates a text for testing.
		/// </summary>
		/// ------------------------------------------------------------------------------------
		private void CreateTestText()
		{
			m_txt = m_servLoc.GetInstance<ITextFactory>().Create();
			//Cache.LangProject.TextsOC.Add(m_txt);
			m_possTagList = Cache.LangProject.GetDefaultTextTagList();
			m_stTxt = m_servLoc.GetInstance<IStTextFactory>().Create();
			m_txt.ContentsOA = m_stTxt;
			m_txtPara = m_txt.ContentsOA.AddNewTextPara(null);

			// 0    1  2 3    4      5   6                        7    8
			// This is a test string for ReferenceAdjusterService tests.

			var hvoVernWs = Cache.DefaultVernWs;
			m_txtPara.Contents = TsStringUtils.MakeTss("This is a test string for ReferenceAdjusterService tests.", hvoVernWs);
			ParseText();
		}
Example #18
0
		private void FixtureSetupInternal()
		{
			//IWritingSystem wsEn = Cache.WritingSystemFactory.get_Engine("en");
			// Setup default analysis ws
			//m_wsEn = Cache.ServiceLocator.GetInstance<ILgWritingSystemRepository>().GetObject(wsEn.WritingSystem);
			m_wsVern = Cache.DefaultVernWs;
			m_wsTrans = Cache.DefaultAnalWs;

			m_text = Cache.ServiceLocator.GetInstance<ITextFactory>().Create();
			//Cache.LangProject.TextsOC.Add(m_text);
			var stText = Cache.ServiceLocator.GetInstance<IStTextFactory>().Create();
			m_text.ContentsOA = stText;
			m_para = Cache.ServiceLocator.GetInstance<IScrTxtParaFactory>().CreateWithStyle(stText, ScrStyleNames.NormalParagraph);

			m_trans = m_para.GetOrCreateBT();
			Cache.LangProject.TranslatedScriptureOA.UseScriptDigits = false;
			m_tsf = Cache.TsStrFactory;
		}
		public override void Initialize()
		{
			CheckDisposed();
			base.Initialize();
			InstallVirtuals(@"Language Explorer\Configuration\Words\AreaConfiguration.xml",
				new string[] { "SIL.FieldWorks.IText.ParagraphSegmentsVirtualHandler", "SIL.FieldWorks.IText.OccurrencesInTextsVirtualHandler" });
			m_wsVern = Cache.DefaultVernWs;
			m_wsTrans = Cache.DefaultAnalWs;
			m_book = new ScrBook();
			Cache.LangProject.TranslatedScriptureOA.ScriptureBooksOS.Append(m_book);
			m_section = new ScrSection();
			m_book.SectionsOS.Append(m_section);
			m_para = new StTxtPara();
			m_text = new StText();
			m_section.ContentOA = m_text;
			m_text.ParagraphsOS.Append(m_para);
			m_hvoSegDefn = CmAnnotationDefn.TextSegment(Cache).Hvo;
			m_hvoFtDefn = Cache.GetIdFromGuid(new Guid(LangProject.kguidAnnFreeTranslation));
			kflidFT = StTxtPara.SegmentFreeTranslationFlid(Cache);
			kflidSegments = StTxtPara.SegmentsFlid(Cache);
		}
		/// <summary>
		/// non-undoable task
		/// </summary>
		private void DoSetupFixture()
		{
			// setup default vernacular ws.
			IWritingSystem wsXkal = Cache.ServiceLocator.WritingSystemManager.Set("qaa-x-kal");
			wsXkal.DefaultFontName = "Times New Roman";
			Cache.ServiceLocator.WritingSystems.VernacularWritingSystems.Add(wsXkal);
			Cache.ServiceLocator.WritingSystems.CurrentVernacularWritingSystems.Insert(0, wsXkal);
			var textFactory = Cache.ServiceLocator.GetInstance<ITextFactory>();
			var stTextFactory = Cache.ServiceLocator.GetInstance<IStTextFactory>();
			m_text0 = textFactory.Create();
			//Cache.LangProject.TextsOC.Add(m_text0);
			m_stText0 = stTextFactory.Create();
			m_text0.ContentsOA = m_stText0;
			m_para0_0 = m_stText0.AddNewTextPara(null);
			m_para0_0.Contents = TsStringUtils.MakeTss("Xxxhope xxxthis xxxwill xxxdo. xxxI xxxhope.", wsXkal.Handle);

			InterlinMaster.LoadParagraphAnnotationsAndGenerateEntryGuessesIfNeeded(m_stText0, false);
			// paragraph 0_0 simply has wordforms as analyses
			foreach (var occurence in SegmentServices.GetAnalysisOccurrences(m_para0_0))
				if (occurence.HasWordform)
					m_analysis_para0_0.Add(new AnalysisTree(occurence.Analysis));

		}
		/// <summary>
		/// Get the next segment with either a non-null annotation that is configured or
		/// a non-punctuation analysis. Also skip segments that are Scripture labels (like
		/// Chapter/Verse/Footnote numbers.
		/// It tries the next one after the SelectedOccurrence.Segment
		/// then tries the next paragraph, etc..
		/// Use this version if the calling code already has the actual para/seg objects.
		/// </summary>
		/// <param name="currentPara"></param>
		/// <param name="seg"></param>
		/// <param name="upward">true if moving up and left, false otherwise</param>
		/// <param name="realAnalysis">the first or last real analysis found in the next segment</param>
		/// <returns>A segment meeting the criteria or null if not found.</returns>
		private ISegment GetNextSegment(IStTxtPara currentPara, ISegment seg, bool upward,
				out AnalysisOccurrence realAnalysis)
		{
			ISegment nextSeg = null;
			realAnalysis = null;
			var currentText = currentPara.Owner as IStText;
			Debug.Assert(currentText != null, "Paragraph not owned by a text.");
			var lines = LineChoices.m_specs as IEnumerable<InterlinLineSpec>;
			var delta = upward ? -1 : 1;
			var nextSegIndex = delta + seg.IndexInOwner;
			do
			{
				if (0 <= nextSegIndex && nextSegIndex < currentPara.SegmentsOS.Count)
				{
					nextSeg = currentPara.SegmentsOS[nextSegIndex];
					nextSegIndex += delta; // increment for next loop in case it doesn't check out
				}
				else
				{   // try the first (last) segment in the next (previous) paragraph
					int nextParaIndex = delta + currentPara.IndexInOwner;
					nextSeg = null;
					IStTxtPara nextPara = null;
					if (0 <= nextParaIndex && nextParaIndex < currentText.ParagraphsOS.Count)
					{   // try to find this paragraph's first (last) segment
						currentPara = (IStTxtPara)currentText.ParagraphsOS[nextParaIndex];
						nextSegIndex = upward ? currentPara.SegmentsOS.Count - 1 : 0;
					}
					else
					{	// no more paragraphs in this text
						break;
					}
				}
				realAnalysis = FindRealAnalysisInSegment(nextSeg, !upward);
			} while (nextSeg == null || (realAnalysis == null && !HasVisibleTranslationOrNote(nextSeg, lines)));
			return nextSeg;
		}
Example #22
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Create test data for tests.
		/// </summary>
		/// ------------------------------------------------------------------------------------
		protected override void CreateTestData()
		{
			m_text = AddInterlinearTextToLangProj("My Interlinear Text");
			m_stTextPara = AddParaToInterlinearTextContents(m_text, "Here is a sentence I can chart.");
			m_stText = m_text.ContentsOA;
		}
Example #23
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Compares the translations of the footnote.
		/// </summary>
		/// <param name="expectedTrans">The expected translation</param>
		/// <param name="currentPara">The current footnote paragraph.</param>
		/// ------------------------------------------------------------------------------------
		private void CompareFootnoteTrans(ICmTranslation expectedTrans, IStTxtPara currentPara)
		{
			ICmTranslation actualTrans = currentPara.GetBT();

			if (expectedTrans == null)
			{
				Assert.IsNull(actualTrans, "Found an unexpected translation for footnote paragraph " +
					currentPara.IndexInOwner + " having text: " + currentPara.Contents.Text);
				return;
			}
			Assert.IsNotNull(actualTrans, "Translation missing for paragraph " +
					currentPara.IndexInOwner + " having text: " + currentPara.Contents.Text);

			foreach (int ws in actualTrans.Translation.AvailableWritingSystemIds)
			{
				ITsString tssExpected = expectedTrans.Translation.get_String(ws);
				ITsString tssActual = actualTrans.Translation.get_String(ws);

				if (tssExpected == null || tssExpected.Length == 0)
				{
					Assert.IsTrue(tssActual == null || tssActual.Length == 0,
						"Found an unexpected translation for WS " + ws);
					continue;
				}

				AssertEx.AreTsStringsEqual(tssExpected, tssActual);
			}
		}
Example #24
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Allows this StText to perform any side-effects when the contents of one of its
		/// paragraphs changes.
		/// </summary>
		/// <param name="stTxtPara">The changed paragraph.</param>
		/// <param name="originalValue">The original value.</param>
		/// <param name="newValue">The new value.</param>
		/// ------------------------------------------------------------------------------------
		internal virtual void OnParagraphContentsChanged(IStTxtPara stTxtPara,
			ITsString originalValue, ITsString newValue)
		{
		}
Example #25
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Delete a paragraph from this StText.
		/// </summary>
		/// <param name="para">paragraph to delete</param>
		/// ------------------------------------------------------------------------------------
		public void DeleteParagraph(IStTxtPara para)
		{
			// delete any linked objects (footnotes or pictures)
			((StTxtPara)para).RemoveOwnedObjectsForString(0, para.Contents.Length);
			// delete the paragraph
			((IStText)para.Owner).ParagraphsOS.Remove(para);
		}
Example #26
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Make sure picture exists and is referred to properly in the paragraph contents
		/// </summary>
		/// <param name="pictureOrig">The original picture</param>
		/// <param name="para"></param>
		/// <param name="ich">Character position where ORC should be</param>
		/// ------------------------------------------------------------------------------------
		private void VerifyPicture(ICmPicture pictureOrig, IStTxtPara para, int ich)
		{
			ITsString tss = para.Contents.UnderlyingTsString;
			int iRun = tss.get_RunAt(ich);
			ITsTextProps orcPropsParaFootnote = tss.get_Properties(iRun);
			string objData = orcPropsParaFootnote.GetStrPropValue(
				(int)FwTextPropType.ktptObjData);
			Assert.AreEqual((char)(int)FwObjDataTypes.kodtGuidMoveableObjDisp, objData[0]);

			// Send the objData string without the first character because the first character
			// is the object replacement character and the rest of the string is the GUID.
			Guid newPicGuid = MiscUtils.GetGuidFromObjData(objData.Substring(1));
			int newPicHvo = m_fdoCache.GetIdFromGuid(newPicGuid);
			Assert.IsTrue(pictureOrig.Guid != newPicGuid);
			Assert.IsTrue(pictureOrig.Hvo != newPicHvo);
			string sOrc = tss.get_RunText(iRun);
			Assert.AreEqual(StringUtils.kchObject, sOrc[0]);

			CmPicture pictureNew = new CmPicture(m_fdoCache, newPicHvo);
			Assert.IsTrue(pictureOrig.PictureFileRAHvo != pictureNew.PictureFileRAHvo);
			Assert.AreEqual(pictureOrig.PictureFileRA.InternalPath,
				pictureNew.PictureFileRA.InternalPath);
		}
Example #27
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Make sure footnote exists and is referred to properly in the paragraph contents
		/// </summary>
		/// <param name="footnote">The footnote to verify</param>
		/// <param name="para">The paragraph that is expected to contain the footnote ORC</param>
		/// <param name="ich">Character position where ORC should be</param>
		/// ------------------------------------------------------------------------------------
		protected void VerifyFootnote(IStFootnote footnote, IStTxtPara para, int ich)
		{
			StTxtParaTests.VerifyFootnote(footnote, para, ich);
		}
Example #28
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Create a mindless footnote (i.e., it's marker, paragraph style, etc. won't be set).
		/// </summary>
		/// <param name="book">Book to insert footnote into</param>
		/// <param name="para">Paragraph to insert footnote into</param>
		/// <param name="iFootnotePos">The 0-based index of the new footnote in the collection
		/// of footnotes owned by the book</param>
		/// <param name="ichPos">The 0-based character offset into the paragraph</param>
		/// <returns></returns>
		/// ------------------------------------------------------------------------------------
		protected StFootnote InsertTestFootnote(IScrBook book, IStTxtPara para,
			int iFootnotePos, int ichPos)
		{
			// Create the footnote
			StFootnote footnote = new StFootnote();
			book.FootnotesOS.InsertAt(footnote, iFootnotePos);

			// Update the paragraph contents to include the footnote marker
			ITsStrBldr tsStrBldr = para.Contents.UnderlyingTsString.GetBldr();
			footnote.InsertOwningORCIntoPara(tsStrBldr, ichPos, 0); // Don't care about ws
			para.Contents.UnderlyingTsString = tsStrBldr.GetString();

			return footnote;
		}
Example #29
0
		void SetParaContents(IStTxtPara para, string contents)
		{
			para.Contents = Cache.TsStrFactory.MakeString(contents, Cache.DefaultVernWs);
		}
Example #30
0
		/// <summary>
		/// Executes in two distinct scenarios.
		///
		/// 1. If disposing is true, the method has been called directly
		/// or indirectly by a user's code via the Dispose method.
		/// Both managed and unmanaged resources can be disposed.
		///
		/// 2. If disposing is false, the method has been called by the
		/// runtime from inside the finalizer and you should not reference (access)
		/// other managed objects, as they already have been garbage collected.
		/// Only unmanaged resources can be disposed.
		/// </summary>
		/// <param name="disposing"></param>
		/// <remarks>
		/// If any exceptions are thrown, that is fine.
		/// If the method is being done in a finalizer, it will be ignored.
		/// If it is thrown by client code calling Dispose,
		/// it needs to be handled by fixing the bug.
		///
		/// If subclasses override this method, they should call the base implementation.
		/// </remarks>
		protected override void Dispose(bool disposing)
		{
			//Debug.WriteLineIf(!disposing, "****************** " + GetType().Name + " 'disposing' is false. ******************");
			// Must not be run more than once.
			if (m_isDisposed)
				return;

			if (disposing)
			{
				// Dispose managed resources here.
			}

			// Dispose unmanaged resources here, whether disposing is true or false.
			if (m_cpe != null && Marshal.IsComObject(m_cpe))
				Marshal.ReleaseComObject(m_cpe);
			m_cpe = null;
			m_settings = null;
			m_SOWrapper = null;
			m_sSegmentText = null;
			m_sMarker = null;
			m_styleProxy = null;
			m_vernParaStyleProxy = null;
			m_vernTextProps = null;
			m_analTextProps = null;
			m_styleProxies = null;
			m_notesStyleProxies = null;
			m_lastPara = null;
			m_BookTitleParaProxy = null;
			m_DefaultFootnoteParaProxy = null;
			m_TsStringFactory = null;
			m_BTFootnoteStrBldr = null;
			m_CurrParaPictures = null;
			m_CurrParaFootnotes = null;
			m_BTPendingPictures = null;
			m_CurrBTFootnote = null;
			m_sBtFootnoteParaStyle = null;
			m_BtFootnoteStrBldrs = null;
			m_PendingAnnotations = null;
			m_BTfootnoteIndex = null;
			m_sCharStyleEndMarker = null;
			m_sFootnoteEndMarker = null;
			m_sCharStyleBeginMarker = null;
			m_sFootnoteBeginMarker = null;
			m_scrTranslatorAnnotationDef = null;

			base.Dispose(disposing);
		}