B2023-095_U2022-004 - When Copy/Pasting Symbols, some of the symbols paste in an incorrect font
This commit is contained in:
@@ -11,6 +11,7 @@ using System.Text.RegularExpressions;
|
||||
using VEPROMS.CSLA.Library;
|
||||
using Volian.Base.Library;
|
||||
using JR.Utils.GUI.Forms;
|
||||
using System.Linq;
|
||||
|
||||
namespace Volian.Controls.Library
|
||||
{
|
||||
@@ -2855,7 +2856,10 @@ namespace Volian.Controls.Library
|
||||
return false;
|
||||
}
|
||||
|
||||
public string GetPasteText(bool PasteNoReturnsSetting, IDataObject myDO)
|
||||
//CSM B2023-095/U2022-004 When Copy/Pasting Symbols, some of the symbols paste in an incorrect font
|
||||
// Changed this to put in the unicode code for any symbols outside the normal ascii range
|
||||
// if supplied convertunicode flag is true
|
||||
public string GetPasteText(bool PasteNoReturnsSetting, IDataObject myDO, bool convertunicode = false)
|
||||
{
|
||||
// B2021-0039: symbols not pasting correctly from ctrl-v:
|
||||
// get base list of valid symbols, use base format if MyItemInfo is null. Use symbols from
|
||||
@@ -2871,40 +2875,31 @@ namespace Volian.Controls.Library
|
||||
ptext = ptext.TrimEnd("\r\n\t ".ToCharArray());
|
||||
if (PasteNoReturnsSetting) ptext = ptext.Replace("\r\n", " ");
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
bool didCharReplace = false;
|
||||
StringBuilder sb = new StringBuilder();
|
||||
bool hasBadChar = false;
|
||||
for (int i = 0; i < ptext.Length; i++)
|
||||
{
|
||||
didCharReplace = false;
|
||||
string sym = string.Format(@"{0}", Convert.ToInt32(ptext[i]));
|
||||
if ((ptext[i] > 0x7e))
|
||||
foreach (char c in ptext)
|
||||
{
|
||||
if ((c > 0x7e))
|
||||
{
|
||||
// is this an allowable symbol/character:
|
||||
for (int j = 0; j < sl.Count; j++)
|
||||
{
|
||||
if (sym == allowableSymbols[j])
|
||||
{
|
||||
sb = sb.Append((char)(Convert.ToInt32(allowableSymbols[j])));
|
||||
didCharReplace = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// if not allowable, put in a "?" and give a message to user (below)
|
||||
if (!didCharReplace)
|
||||
if (allowableSymbols.Any(x => x == $@"{(short)c}"))
|
||||
{
|
||||
if (convertunicode)
|
||||
sb.Append($"\\u{(short) c}?");
|
||||
else
|
||||
sb.Append(c);
|
||||
}
|
||||
else
|
||||
{
|
||||
sb = sb.Append("?");
|
||||
didCharReplace = true;
|
||||
hasBadChar = true;
|
||||
sb.Append("?");
|
||||
}
|
||||
}
|
||||
if (!didCharReplace)
|
||||
sb = sb.Append(ptext[i]);
|
||||
}
|
||||
if (!didCharReplace)
|
||||
sb = sb.Append(ptext[i]);
|
||||
}
|
||||
ptext = sb.ToString();
|
||||
ptext = ptext.Replace("\u2013", "-"); // Replace EN Dash with hyphen
|
||||
else
|
||||
sb.Append(c);
|
||||
}
|
||||
ptext = sb.ToString();
|
||||
ptext = ptext.Replace("\u2013", "-"); // Replace EN Dash with hyphen
|
||||
ptext = ptext.Replace("\u2014", "-"); // Replace EM Dash with hyphen
|
||||
ptext = ptext.Replace("\u2011", "-"); // Replace non-breaking hyphen with hyphen
|
||||
ptext = ptext.Replace("\u2572", "\\"); // Replace backslash symbol with backslash character
|
||||
|
@@ -2883,12 +2883,19 @@ namespace Volian.Controls.Library
|
||||
tmpForLink = ItemInfo.ReplaceLinkWithNewID(tmpForLink);
|
||||
myRtb.SelectedRtf = tmpForLink;
|
||||
// Fix for B2014-071: if link, save after paste so that goto's don't crash (grid & step run through this code)
|
||||
if (tmpForLink.Contains("<NewID>")) _MyStepRTB.OnDoSaveContents(this, new EventArgs());
|
||||
if (tmpForLink.Contains("<NewID>")) _MyStepRTB.OnDoSaveContents(this, new EventArgs());
|
||||
}
|
||||
|
||||
}
|
||||
else if (myDO.GetDataPresent(DataFormats.Text))
|
||||
myRtb.SelectedText = _MyStepRTB.GetPasteText(PasteNoReturnsSetting, myDO);
|
||||
{
|
||||
//CSM B2023-095/U2022-004 When Copy/Pasting Symbols, some of the symbols paste in an incorrect font
|
||||
// Changed this to put in the unicode code for any symbols outside the normal ascii range
|
||||
// Also need to input as an RTF so that correct font is used with these
|
||||
// and unicode is converted to actual text
|
||||
string clipboardtext = _MyStepRTB.GetPasteText(PasteNoReturnsSetting, myDO, true);
|
||||
myRtb.SelectedRtf = _MyStepRTB.RtfPrefixForSymbols + clipboardtext + @"}";
|
||||
}
|
||||
if (myRtb.SelectionLength == 0 && myRtb is StepRTB) myRtb.SelectionFont = (myRtb as StepRTB).MyStyleFont.WindowsFont;
|
||||
_PastePlainTextOvrRide = false;
|
||||
_PasteStepTextOvrRide = false;
|
||||
|
Reference in New Issue
Block a user