diff --git a/PROMS/Volian.Base.Library/RtfTools.cs b/PROMS/Volian.Base.Library/RtfTools.cs index 7ca54304..6e41e0d4 100644 --- a/PROMS/Volian.Base.Library/RtfTools.cs +++ b/PROMS/Volian.Base.Library/RtfTools.cs @@ -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; } } diff --git a/PROMS/Volian.Controls.Library/StepRTB.cs b/PROMS/Volian.Controls.Library/StepRTB.cs index 2e9c7ec3..0067f776 100644 --- a/PROMS/Volian.Controls.Library/StepRTB.cs +++ b/PROMS/Volian.Controls.Library/StepRTB.cs @@ -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; } diff --git a/PROMS/Volian.Controls.Library/StepTabRibbon.designer.cs b/PROMS/Volian.Controls.Library/StepTabRibbon.designer.cs index 9d3093ed..e51e7841 100644 Binary files a/PROMS/Volian.Controls.Library/StepTabRibbon.designer.cs and b/PROMS/Volian.Controls.Library/StepTabRibbon.designer.cs differ