B2021-039: Paste of symbols results in invalid symbols
This commit is contained in:
parent
9339a49002
commit
1e85522762
@ -128,6 +128,14 @@ namespace Volian.Base.Library
|
||||
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?");
|
||||
// B2021-039: paste of the greek symbols was not working correctly, RTF was converting unicode, similar to above
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -2798,31 +2798,56 @@ namespace Volian.Controls.Library
|
||||
|
||||
public string GetPasteText(bool PasteNoReturnsSetting, IDataObject myDO)
|
||||
{
|
||||
// allowable symbols are those symbols between 127-256 that the proms editor supports that
|
||||
// can be pasted from word as is. These symbols are (in the order they are in the following
|
||||
// string): degree, plus/minus, exponent 2, exponent 3, micro, quarter, half, divide:
|
||||
char[] allowableSymbols = { '\xb0', '\xb1', '\xb2', '\xb3', '\xb5', '\xbc', '\xbd', '\xf7' };
|
||||
string ptext = myDO.GetData(DataFormats.Text).ToString();
|
||||
// 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
|
||||
// the format file versus a list in code
|
||||
FormatData fmtd = MyItemInfo != null ? MyItemInfo.ActiveFormat.PlantFormat.FormatData : FormatInfo.PROMSBaseFormat.FormatData;
|
||||
SymbolList sl = fmtd.SymbolList;
|
||||
string[] allowableSymbols = new string[sl.Count];
|
||||
for (int i = 0; i < sl.Count; i++) allowableSymbols[i] = string.Format(@"{0}", sl[i].Unicode);
|
||||
|
||||
// allowable symbols are those symbols in the format file that the proms editor supports that
|
||||
// can be pasted from word as is.
|
||||
string ptext = (string)myDO.GetData(DataFormats.UnicodeText);
|
||||
ptext = ptext.TrimEnd("\r\n\t ".ToCharArray());
|
||||
if (PasteNoReturnsSetting) ptext = ptext.Replace("\r\n", " ");
|
||||
StringBuilder sb = new StringBuilder(ptext);
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
bool didCharReplace = false;
|
||||
bool hasBadChar = false;
|
||||
for (int i = 0; i < ptext.Length; i++)
|
||||
{
|
||||
// if allowable, allow for it to pasted. Otherwise, replace that character with a '?'.
|
||||
if ((sb[i] > 0x7e))
|
||||
if ((ptext.Substring(i, 1).IndexOfAny(allowableSymbols) < 0))
|
||||
didCharReplace = false;
|
||||
string sym = string.Format(@"{0}", Convert.ToInt32(ptext[i]));
|
||||
if ((ptext[i] > 0x7e))
|
||||
{
|
||||
sb[i] = '?';
|
||||
didCharReplace = true;
|
||||
// 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)
|
||||
{
|
||||
sb = sb.Append("?");
|
||||
didCharReplace = true;
|
||||
hasBadChar = true;
|
||||
}
|
||||
}
|
||||
if (!didCharReplace)
|
||||
sb = sb.Append(ptext[i]);
|
||||
}
|
||||
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
|
||||
if (didCharReplace)
|
||||
if (hasBadChar)
|
||||
FlexibleMessageBox.Show("Replacing pasted characters that are not supported by Proms with a '?'.");
|
||||
return ptext;
|
||||
}
|
||||
|
BIN
PROMS/Volian.Controls.Library/StepTabRibbon.designer.cs
generated
BIN
PROMS/Volian.Controls.Library/StepTabRibbon.designer.cs
generated
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user