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:
parent
ebdfc812a3
commit
b7e0e78ca9
@ -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
|
// 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.
|
// 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
|
// 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
|
// 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("\r\n", @"\line "); // replace a \r\n with a \line instead of a \par
|
||||||
text = text.Replace(@"\line", @"\pard\line");
|
text = text.Replace(@"\line", @"\pard\line");
|
||||||
text = text.Replace(@"\pard\pard\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,
|
// 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.
|
// i.e. no longer a hardspace, and actually is converted to a regular space.
|
||||||
// SO, on the way out, convert any \~ to \u160?
|
// SO, on the way out, convert any \~ to \u160?
|
||||||
string noExtraRtfStr = text.Replace(@"\~", @"\u160?");
|
//string noExtraRtfStr = text.Replace(@"\~", @"\u160?");
|
||||||
noExtraRtfStr = noExtraRtfStr.Replace(@"\'a0", @"\u160?");
|
//noExtraRtfStr = noExtraRtfStr.Replace(@"\'a0", @"\u160?");
|
||||||
// convert \'99 to \u8482? this is for the trade mark symbol. For some reason RTF is automatically
|
// 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
|
// 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
|
// Check for two links in a row & if found, add separating rtf comment
|
||||||
// commands (these get removed in the richtextbox:
|
// commands (these get removed in the richtextbox:
|
||||||
// RHM 20100303 Not sure why this is here. The RichTextBox will always remove it.
|
// 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,
|
// 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.
|
// i.e. no longer a hardspace, and actually is converted to a regular space.
|
||||||
// SO, on the way out, convert any \~ to \u160?
|
// 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
|
// 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
|
// 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
|
// 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):
|
// for hard returns, goes into rtb as \par and comes out as \par\r\n):
|
||||||
|
@ -114,5 +114,21 @@ namespace Volian.Base.Library
|
|||||||
rtfprefix += @"\i";
|
rtfprefix += @"\i";
|
||||||
return rtfprefix;
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@ using System.Drawing;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
using VEPROMS.CSLA.Library;
|
using VEPROMS.CSLA.Library;
|
||||||
|
using Volian.Base.Library;
|
||||||
|
|
||||||
namespace Volian.Controls.Library
|
namespace Volian.Controls.Library
|
||||||
{
|
{
|
||||||
@ -179,7 +180,7 @@ namespace Volian.Controls.Library
|
|||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
foreach (char c in str)
|
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));
|
sb.Append(string.Format(@"\u{0}?", (int)c));
|
||||||
else
|
else
|
||||||
sb.Append(c);
|
sb.Append(c);
|
||||||
@ -195,7 +196,7 @@ namespace Volian.Controls.Library
|
|||||||
{
|
{
|
||||||
ItemInfo next = (cbxReverse.Checked) ? MyEditItem.MyItemInfo.SearchPrev : MyEditItem.MyItemInfo.SearchNext;
|
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;
|
next = (cbxReverse.Checked) ? next.SearchPrev : next.SearchNext;
|
||||||
}
|
}
|
||||||
|
@ -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
|
// 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
|
// Also convert \~ to a hard spece. Again RTF is automatically converting \u160? to \~ but will then convert
|
||||||
// the \~ to a regular space!
|
// 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;
|
GridItem gi = Parent as GridItem;
|
||||||
if (gi != null)
|
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
|
// Also convert \~ to a hard spece. Again RTF is automatically converting \u160? to \~ but will then convert
|
||||||
// the \~ to a regular space!
|
// the \~ to a regular space!
|
||||||
if (tmp.StartsWith(@"{\rtf"))
|
if (tmp.StartsWith(@"{\rtf"))
|
||||||
Rtf = tmp.Replace(@"\~", @"\u160?").Replace(@"\'99", @"\u8482?");
|
Rtf = RtfTools.RTFConvertedSymbolsToUnicode(tmp);//.Replace(@"\~", @"\u160?").Replace(@"\'99", @"\u8482?");
|
||||||
else
|
else
|
||||||
Text = tmp;
|
Text = tmp;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user