From 3363a94037dc15761cef93f5dd789961e1601fb7 Mon Sep 17 00:00:00 2001 From: Rich Date: Wed, 25 Sep 2013 15:57:24 +0000 Subject: [PATCH] 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". --- PROMS/Volian.Controls.Library/DisplayText.cs | 23 ++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/PROMS/Volian.Controls.Library/DisplayText.cs b/PROMS/Volian.Controls.Library/DisplayText.cs index 1ffb2427..a41d3802 100644 --- a/PROMS/Volian.Controls.Library/DisplayText.cs +++ b/PROMS/Volian.Controls.Library/DisplayText.cs @@ -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 {