When a hardspace was added before or after a "Replace Word" (IF, THEN, WHEN, AND, OR, NOT) in a table, the word was still underlined. The issue was that there was some RTF formatting which occured between the hardspace and the "Replace Word". Logic was added to check for Hardspaces preceding or following a "Replace Word".
This commit is contained in:
parent
928c390c42
commit
3363a94037
@ -1718,12 +1718,31 @@ namespace Volian.Controls.Library
|
||||
{
|
||||
if (foundMatch.MyWord != null)
|
||||
{
|
||||
text = text.Substring(0, offset + foundMatch.MyMatch.Index) + foundMatch.MyWord.ReplaceWith + text.Substring(offset + foundMatch.MyMatch.Index + foundMatch.MyMatch.Length);
|
||||
offset += foundMatch.MyWord.ReplaceWith.Length - foundMatch.MyMatch.Length;
|
||||
if (VerifyNoHardSpace(text, foundMatch, offset))
|
||||
{
|
||||
text = text.Substring(0, offset + foundMatch.MyMatch.Index) + foundMatch.MyWord.ReplaceWith + text.Substring(offset + foundMatch.MyMatch.Index + foundMatch.MyMatch.Length);
|
||||
offset += foundMatch.MyWord.ReplaceWith.Length - foundMatch.MyMatch.Length;
|
||||
}
|
||||
}
|
||||
}
|
||||
return text;
|
||||
}
|
||||
|
||||
private bool VerifyNoHardSpace(string text, FoundMatch foundMatch, int offset)
|
||||
{
|
||||
string begin = text.Substring(0, offset + foundMatch.MyMatch.Index);
|
||||
string end = text.Substring(offset + foundMatch.MyMatch.Index + foundMatch.MyMatch.Length);
|
||||
if (text.StartsWith(@"{\rtf"))
|
||||
{
|
||||
// make sure that it is not preceded by \u160? \'a0 or \~
|
||||
if(Regex.IsMatch(begin,@"(\\(u160\?|'a0|~)(\\f[0-9]* ?)*(\\fs[0-9]* ?)*)$"))
|
||||
return false;
|
||||
// make sure that it is not followed by \u160? \'a0 or \~
|
||||
if(Regex.IsMatch(end,@"^((\\f[0-9]* ?)*(\\fs[0-9]* ?)*\\(u160\?|'a0|~))"))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
public class FoundMatch
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user