Fixed logic for Find/Replace of backslash and symbol characters B2016-156

Moved repeated logic to a static function RTFConvertedSymbolsToUnicode which is needed for Find/Replace. Used in DisplayText.cs, FindReplace.cs, and VlnFlexGrid  B2016-156
Fixed finding backslash and symbols B2016-156
Fixed finding backslash and symbols in tables (grids) B2016-156
This commit is contained in:
John Jenko 2016-07-06 15:23:30 +00:00
parent ebdfc812a3
commit b7e0e78ca9
4 changed files with 32 additions and 11 deletions

View File

@ -331,10 +331,11 @@ namespace VEPROMS.CSLA.Library
{
// as a precaution, convert any \~ to \u160?. This is for Hard spaces. see the commentary in the
// save portion of this code for an explanation.
text = text.Replace(@"\~", @"\u160?");
//text = text.Replace(@"\~", @"\u160?");
// convert \'99 to \u8482? this is for the trade mark symbol. For some reason RTF is automatically
// converting the unicode \u8482? to \'99, but once this is done, PROMS StepRTB (edit windows) do not show it
text = text.Replace(@"\'99", @"\u8482?");
//text = text.Replace(@"\'99", @"\u8482?");
text = RtfTools.RTFConvertedSymbolsToUnicode(text);
text = text.Replace("\r\n", @"\line "); // replace a \r\n with a \line instead of a \par
text = text.Replace(@"\line", @"\pard\line");
text = text.Replace(@"\pard\pard\line", @"\pard\line");
@ -1147,12 +1148,13 @@ namespace VEPROMS.CSLA.Library
// Note that if the \~ is sent to the rtb, it is treated as a regular space,
// i.e. no longer a hardspace, and actually is converted to a regular space.
// SO, on the way out, convert any \~ to \u160?
string noExtraRtfStr = text.Replace(@"\~", @"\u160?");
noExtraRtfStr = noExtraRtfStr.Replace(@"\'a0", @"\u160?");
//string noExtraRtfStr = text.Replace(@"\~", @"\u160?");
//noExtraRtfStr = noExtraRtfStr.Replace(@"\'a0", @"\u160?");
// convert \'99 to \u8482? this is for the trade mark symbol. For some reason RTF is automatically
// converting the unicode \u8482? to \'99, but once this is done, PROMS StepRTB (edit windows) do not show it
noExtraRtfStr = noExtraRtfStr.Replace(@"\'99", @"\u8482?");
//noExtraRtfStr = noExtraRtfStr.Replace(@"\'99", @"\u8482?");
string noExtraRtfStr = RtfTools.RTFConvertedSymbolsToUnicode(text);
// Check for two links in a row & if found, add separating rtf comment
// commands (these get removed in the richtextbox:
// RHM 20100303 Not sure why this is here. The RichTextBox will always remove it.
@ -1315,10 +1317,12 @@ namespace VEPROMS.CSLA.Library
// Note that if the \~ is sent to the rtb, it is treated as a regular space,
// i.e. no longer a hardspace, and actually is converted to a regular space.
// SO, on the way out, convert any \~ to \u160?
retval = retval.Replace(@"\~", @"\u160?");
//retval = retval.Replace(@"\~", @"\u160?");
// convert \'99 to \u8482? this is for the trade mark symbol. For some reason RTF is automatically
// converting the unicode \u8482? to \'99, but once this is done, PROMS StepRTB (edit windows) do not show it
retval = retval.Replace(@"\'99", @"\u8482?");
//retval = retval.Replace(@"\'99", @"\u8482?");
retval = RtfTools.RTFConvertedSymbolsToUnicode(retval);
// remove carriage return/newlines after \par commands (these are introduced by rtb
// for hard returns, goes into rtb as \par and comes out as \par\r\n):

View File

@ -114,5 +114,21 @@ namespace Volian.Base.Library
rtfprefix += @"\i";
return rtfprefix;
}
public static string RTFConvertedSymbolsToUnicode(string str)
{
string rtnStr = str;
// convert \~ to a hard spece. RTF is automatically converting \u160? to \~ but will then convert
// the \~ to a regular space!
rtnStr = rtnStr.Replace(@"\~", @"\u160?");
rtnStr = rtnStr.Replace(@"\'a0", @"\u160?");
// convert \'99 to \u8482? this is for the trade mark symbol. RTF is automatically
// converting the unicode \u8482? to \'99, but once this is done, PROMS StepRTB (edit windows) does not show it
rtnStr = rtnStr.Replace(@"\'99", @"\u8482?");
// convert \'ae to \u174? this is for the registered symbol. RTF converts the unicode character to \'ae
rtnStr = rtnStr.Replace(@"\'ae",@"\u174?");
// convert \'a9 to \u169? this is for the copyright symbol. RTF converts the unicode character to \'a9
rtnStr = rtnStr.Replace(@"\'a9",@"\u169?");
return rtnStr;
}
}
}

View File

@ -6,6 +6,7 @@ using System.Drawing;
using System.Text;
using System.Windows.Forms;
using VEPROMS.CSLA.Library;
using Volian.Base.Library;
namespace Volian.Controls.Library
{
@ -179,7 +180,7 @@ namespace Volian.Controls.Library
StringBuilder sb = new StringBuilder();
foreach (char c in str)
{
if (c > 0xff)
if (c > 0xff || c == 0xA9 || c == 0xAE) // xA9 is Copyright, xAE is Registered
sb.Append(string.Format(@"\u{0}?", (int)c));
else
sb.Append(c);
@ -195,7 +196,7 @@ namespace Volian.Controls.Library
{
ItemInfo next = (cbxReverse.Checked) ? MyEditItem.MyItemInfo.SearchPrev : MyEditItem.MyItemInfo.SearchNext;
while ((next != null) && !next.IsSection && !next.MyContent.Text.Contains(fndStr))
while ((next != null) && !next.IsSection && !RtfTools.RTFConvertedSymbolsToUnicode(next.MyContent.Text).Contains(fndStr))
{
next = (cbxReverse.Checked) ? next.SearchPrev : next.SearchNext;
}

View File

@ -1230,7 +1230,7 @@ namespace Volian.Controls.Library
// converting the unicode \u8482? to \'99, but once this is done, PROMS StepRTB (edit windows) do not show it
// Also convert \~ to a hard spece. Again RTF is automatically converting \u160? to \~ but will then convert
// the \~ to a regular space!
string rtfText = this.GetDataDisplay(e.Row, e.Col).Replace(@"\~", @"\u160?").Replace(@"\'99", @"\u8482?");
string rtfText = RtfTools.RTFConvertedSymbolsToUnicode(this.GetDataDisplay(e.Row, e.Col));//.Replace(@"\~", @"\u160?").Replace(@"\'99", @"\u8482?");
GridItem gi = Parent as GridItem;
if (gi != null)
{
@ -4634,7 +4634,7 @@ namespace Volian.Controls.Library
// Also convert \~ to a hard spece. Again RTF is automatically converting \u160? to \~ but will then convert
// the \~ to a regular space!
if (tmp.StartsWith(@"{\rtf"))
Rtf = tmp.Replace(@"\~", @"\u160?").Replace(@"\'99", @"\u8482?");
Rtf = RtfTools.RTFConvertedSymbolsToUnicode(tmp);//.Replace(@"\~", @"\u160?").Replace(@"\'99", @"\u8482?");
else
Text = tmp;
}