B2017-196: Hanging indent entered negative numbers rather than indent

This commit is contained in:
Kathy Ruffing 2017-09-08 13:14:41 +00:00
parent aa1af73cd6
commit 83e13a93ee

View File

@ -811,11 +811,26 @@ namespace VEPROMS.CSLA.Library
/// <summary> /// <summary>
/// B2017-121 Regular Express for all RTF tokens for Hyphens /// B2017-121 Regular Express for all RTF tokens for Hyphens
/// </summary> /// </summary>
private static Regex regHyphen = new Regex(@"(?<!\\)(\\u8208\?|\\u8210\?|\\u8211\?|\\u8212\?|\\u8213\?|\\_|\\endash|\\emdash|-)"); private static Regex regHyphen = new Regex(@"(?<!\\)(\\u8208\?|\\u8210\?|\\u8211\?|\\u8212\?|\\u8213\?|\\_|\\endash|\\emdash)");
public bool Save(RichTextBox rtb) public bool Save(RichTextBox rtb)
{ {
// B2017-121 Replace all types of hyphens with non-breaking hyphens // B2017-121 Replace all types of hyphens with non-breaking hyphens
string rtbString = regHyphen.Replace( RtfToDbText(rtb.Rtf).Replace("<BackSlash>", "\\\\"),@"\u8209?"); string rtbString = regHyphen.Replace( RtfToDbText(rtb.Rtf).Replace("<BackSlash>", "\\\\"),@"\u8209?");
// B2017-196: Now replace plain '-' with unicode. Note that the hanging indent rtf command had 'fi-' in it, so couldn't do it in regex above:
int indx = rtbString.IndexOf('-');
while (indx > -1)
{
if (indx > 2)
{
if (rtbString[indx - 1] != 'i' || rtbString[indx - 2] != 'f' || rtbString[indx - 3] != '\\')
{
rtbString = rtbString.Remove(indx, 1);
rtbString = rtbString.Insert(indx, @"\u8209?");
}
if (indx + 1 > rtbString.Length) indx = -1;
else indx = rtbString.IndexOf('-', indx+1);
}
}
return Save(rtbString); return Save(rtbString);
} }
public bool Save(string modtext) public bool Save(string modtext)