B2023-095_U2022-004 - When Copy/Pasting Symbols, some of the symbols paste in an incorrect font #473
@ -128,29 +128,6 @@ namespace Volian.Base.Library
|
|||||||
rtnStr = rtnStr.Replace(@"\'ae", @"\u174?");
|
rtnStr = rtnStr.Replace(@"\'ae", @"\u174?");
|
||||||
// convert \'a9 to \u169? this is for the copyright symbol. RTF converts the unicode character to \'a9
|
// convert \'a9 to \u169? this is for the copyright symbol. RTF converts the unicode character to \'a9
|
||||||
rtnStr = rtnStr.Replace(@"\'a9", @"\u169?");
|
rtnStr = rtnStr.Replace(@"\'a9", @"\u169?");
|
||||||
// B2021-039: paste of the greek symbols was not working correctly, RTF was converting unicode, similar to above
|
|
||||||
// B2022-052: Division symbol converted to an x, caused by fix B2021-039. The code below was translating the division
|
|
||||||
// symbol but it should only be translated if the character's font is Greek or Baltic. Unfortunately this is not
|
|
||||||
// a complete solution since it converts characters it shouldn't, for example, using the following steps: all
|
|
||||||
// of Proms symbols are entered into a step; a ctrl-a/ctrl-c is used to copy these and then ctrl-v to paste
|
|
||||||
// into another new step. The paste (from the underlying richtextbox) causes some characters to be in plain
|
|
||||||
// arial font, and others to be in arial with Greek flag. Some character codes exist in each font, for example f7.
|
|
||||||
// The code below does not look into what font is used, just converts the character. Since any kind of font
|
|
||||||
// can occur during paste, if from an external program, a message will be given stating that a symbol may be incorrect
|
|
||||||
// because an unsupported font was pasted. It was felt that this was sufficient based on estimate of fix versus chance of
|
|
||||||
// occurrence. Note that the message was moved into StepRTB since this code is called by non-UI code (5/26/22)
|
|
||||||
if (str.ToUpper().Contains("GREEK") || str.ToUpper().Contains("BALTIC"))
|
|
||||||
{
|
|
||||||
//System.Windows.Forms.MessageBox.Show("Pasted text may use an unsupported font so some characters may not paste correctly and may require delete/reenter of character from within Proms.",
|
|
||||||
// "Paste Font Issue", System.Windows.Forms.MessageBoxButtons.OK);
|
|
||||||
for (int i = 0; i < 26; i++)
|
|
||||||
{
|
|
||||||
rtnStr = rtnStr.Replace(string.Format("\\'{0:x2}", 0xc0 + i) // upper case Greek
|
|
||||||
, string.Format("\\u{0}?", 912 + i));
|
|
||||||
rtnStr = rtnStr.Replace(string.Format("\\'{0:x2}", 0xe0 + i) // lower case Greek
|
|
||||||
, string.Format("\\u{0}?", 944 + i));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return rtnStr;
|
return rtnStr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,7 @@ using System.Text.RegularExpressions;
|
|||||||
using VEPROMS.CSLA.Library;
|
using VEPROMS.CSLA.Library;
|
||||||
using Volian.Base.Library;
|
using Volian.Base.Library;
|
||||||
using JR.Utils.GUI.Forms;
|
using JR.Utils.GUI.Forms;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
namespace Volian.Controls.Library
|
namespace Volian.Controls.Library
|
||||||
{
|
{
|
||||||
@ -2855,7 +2856,10 @@ namespace Volian.Controls.Library
|
|||||||
return false;
|
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:
|
// 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
|
// get base list of valid symbols, use base format if MyItemInfo is null. Use symbols from
|
||||||
@ -2872,36 +2876,27 @@ namespace Volian.Controls.Library
|
|||||||
if (PasteNoReturnsSetting) ptext = ptext.Replace("\r\n", " ");
|
if (PasteNoReturnsSetting) ptext = ptext.Replace("\r\n", " ");
|
||||||
|
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
bool didCharReplace = false;
|
|
||||||
bool hasBadChar = false;
|
bool hasBadChar = false;
|
||||||
for (int i = 0; i < ptext.Length; i++)
|
foreach (char c in ptext)
|
||||||
{
|
{
|
||||||
didCharReplace = false;
|
if ((c > 0x7e))
|
||||||
string sym = string.Format(@"{0}", Convert.ToInt32(ptext[i]));
|
|
||||||
if ((ptext[i] > 0x7e))
|
|
||||||
{
|
{
|
||||||
// is this an allowable symbol/character:
|
// is this an allowable symbol/character:
|
||||||
for (int j = 0; j < sl.Count; j++)
|
if (allowableSymbols.Any(x => x == $@"{(short)c}"))
|
||||||
{
|
{
|
||||||
if (sym == allowableSymbols[j])
|
if (convertunicode)
|
||||||
{
|
sb.Append($"\\u{(short) c}?");
|
||||||
sb = sb.Append((char)(Convert.ToInt32(allowableSymbols[j])));
|
else
|
||||||
didCharReplace = true;
|
sb.Append(c);
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
else
|
||||||
// if not allowable, put in a "?" and give a message to user (below)
|
|
||||||
if (!didCharReplace)
|
|
||||||
{
|
{
|
||||||
sb = sb.Append("?");
|
|
||||||
didCharReplace = true;
|
|
||||||
hasBadChar = true;
|
hasBadChar = true;
|
||||||
|
sb.Append("?");
|
||||||
}
|
}
|
||||||
if (!didCharReplace)
|
|
||||||
sb = sb.Append(ptext[i]);
|
|
||||||
}
|
}
|
||||||
if (!didCharReplace)
|
else
|
||||||
sb = sb.Append(ptext[i]);
|
sb.Append(c);
|
||||||
}
|
}
|
||||||
ptext = sb.ToString();
|
ptext = sb.ToString();
|
||||||
ptext = ptext.Replace("\u2013", "-"); // Replace EN Dash with hyphen
|
ptext = ptext.Replace("\u2013", "-"); // Replace EN Dash with hyphen
|
||||||
|
@ -2888,7 +2888,14 @@ namespace Volian.Controls.Library
|
|||||||
|
|
||||||
}
|
}
|
||||||
else if (myDO.GetDataPresent(DataFormats.Text))
|
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;
|
if (myRtb.SelectionLength == 0 && myRtb is StepRTB) myRtb.SelectionFont = (myRtb as StepRTB).MyStyleFont.WindowsFont;
|
||||||
_PastePlainTextOvrRide = false;
|
_PastePlainTextOvrRide = false;
|
||||||
_PasteStepTextOvrRide = false;
|
_PasteStepTextOvrRide = false;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user