SIL.FieldWorks.IText.LinguaLinksImport.UpdateParagraphTextForPhrase C# (CSharp) Method

UpdateParagraphTextForPhrase() private static method

This method will update the newTextPara param appending the phraseText and possibly modifying the segment ending to add an end of segment character. The offset parameter will be set to the value where a following segment would start from.
private static UpdateParagraphTextForPhrase ( IStTxtPara newTextPara, int &offset, ITsString phraseText ) : void
newTextPara IStTxtPara
offset int
phraseText ITsString
return void
		private static void UpdateParagraphTextForPhrase(IStTxtPara newTextPara, ref int offset, ITsString phraseText)
		{
			if (phraseText != null && phraseText.Length > 0)
			{
				offset += phraseText.Length;
				var bldr = newTextPara.Contents.GetBldr();
				var oldText = (bldr.Text ?? "").Trim();
				if (oldText.Length > 0 && !TsStringUtils.IsEndOfSentenceChar(oldText[oldText.Length - 1], LgGeneralCharCategory.kccPo))
				{
					// 'segment' does not end with recognizable EOS character. Add our special one.
					bldr.Replace(bldr.Length, bldr.Length, "\x00A7", null);
				}
				// Insert a space between phrases unless there is already one
				if (bldr.Length > 0 && phraseText.Text[0] != ' ' && bldr.Text[bldr.Length - 1] != ' ')
					bldr.Replace(bldr.Length, bldr.Length, " ", null);
				bldr.ReplaceTsString(bldr.Length, bldr.Length, phraseText);
				newTextPara.Contents = bldr.GetString();
			}
		}