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();
}
}