Development #481
@@ -17,10 +17,10 @@ namespace Volian.Base.Library
 | 
				
			|||||||
					return new List<string>(text.Split(mySplit, StringSplitOptions.None));
 | 
										return new List<string>(text.Split(mySplit, StringSplitOptions.None));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
				int width = 0;			// width of text, non-rtf
 | 
									int width = 0;          // width of text, non-rtf
 | 
				
			||||||
				int start = 0;			// start of line (index into string 'text'), includes rtf
 | 
									int start = 0;          // start of line (index into string 'text'), includes rtf
 | 
				
			||||||
				int lastspace = 0;		// location of lastspace (index into string 'text'), includes rtf
 | 
									int lastspace = 0;      // location of lastspace (index into string 'text'), includes rtf
 | 
				
			||||||
				int startNonRtf = 0;	// start of line, non-rtf (used for determining starting position to determine width if there was a break)
 | 
									int startNonRtf = 0;    // start of line, non-rtf (used for determining starting position to determine width if there was a break)
 | 
				
			||||||
				string rtfprefix = "";
 | 
									string rtfprefix = "";
 | 
				
			||||||
				string nextprefix = "";
 | 
									string nextprefix = "";
 | 
				
			||||||
				for (int indx = 0; indx < text.Length; indx++)
 | 
									for (int indx = 0; indx < text.Length; indx++)
 | 
				
			||||||
@@ -125,32 +125,9 @@ namespace Volian.Base.Library
 | 
				
			|||||||
			//  converting the unicode \u8482? to \'99, but once this is done, PROMS StepRTB (edit windows) does not show it
 | 
								//  converting the unicode \u8482? to \'99, but once this is done, PROMS StepRTB (edit windows) does not show it
 | 
				
			||||||
			rtnStr = rtnStr.Replace(@"\'99", @"\u8482?");
 | 
								rtnStr = rtnStr.Replace(@"\'99", @"\u8482?");
 | 
				
			||||||
			// convert \'ae to \u174? this is for the registered symbol.  RTF converts the unicode character to \'ae
 | 
								// convert \'ae to \u174? this is for the registered symbol.  RTF converts the unicode character to \'ae
 | 
				
			||||||
			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
 | 
				
			||||||
@@ -2871,40 +2875,31 @@ namespace Volian.Controls.Library
 | 
				
			|||||||
			ptext = ptext.TrimEnd("\r\n\t ".ToCharArray());
 | 
								ptext = ptext.TrimEnd("\r\n\t ".ToCharArray());
 | 
				
			||||||
			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)
 | 
									else
 | 
				
			||||||
					sb = sb.Append(ptext[i]);
 | 
										sb.Append(c);
 | 
				
			||||||
			}
 | 
					            }
 | 
				
			||||||
				if (!didCharReplace)
 | 
					            ptext = sb.ToString();
 | 
				
			||||||
					sb = sb.Append(ptext[i]);
 | 
					            ptext = ptext.Replace("\u2013", "-"); // Replace EN Dash with hyphen
 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
			ptext = sb.ToString();
 | 
					 | 
				
			||||||
			ptext = ptext.Replace("\u2013", "-"); // Replace EN Dash with hyphen
 | 
					 | 
				
			||||||
			ptext = ptext.Replace("\u2014", "-"); // Replace EM 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("\u2011", "-"); // Replace non-breaking hyphen with hyphen
 | 
				
			||||||
			ptext = ptext.Replace("\u2572", "\\"); // Replace backslash symbol with backslash character
 | 
								ptext = ptext.Replace("\u2572", "\\"); // Replace backslash symbol with backslash character
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -2883,12 +2883,19 @@ namespace Volian.Controls.Library
 | 
				
			|||||||
					tmpForLink = ItemInfo.ReplaceLinkWithNewID(tmpForLink);
 | 
										tmpForLink = ItemInfo.ReplaceLinkWithNewID(tmpForLink);
 | 
				
			||||||
					myRtb.SelectedRtf = 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)
 | 
										// 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))
 | 
								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;
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user