B2023-037: Handle <=, >=, +-, -> and <- symbols in ROs.
This commit is contained in:
		@@ -282,6 +282,22 @@ namespace VEPROMS.CSLA.Library
 | 
			
		||||
 | 
			
		||||
		#endregion
 | 
			
		||||
 | 
			
		||||
		#region ROTextConvertMethods
 | 
			
		||||
		// B2023-037: Handle <=, >=, +-, -> and <- symbols. Convert to unicode for output, i.e. print and edit/view (when editing
 | 
			
		||||
		//   step, will show as 2 characters, not unicode, unless ro inserted when code replaced link text with unicode.
 | 
			
		||||
		public static string ROConvertSymbols(string retval)
 | 
			
		||||
		{
 | 
			
		||||
			retval = retval.Replace("\\u8209?>", @"\u8594?"); // Right Arrow
 | 
			
		||||
			retval = retval.Replace("<\\u8209?", @"\u8592?"); // Left Arrow
 | 
			
		||||
			retval = retval.Replace("->", @"\u8594?"); // Right Arrow
 | 
			
		||||
			retval = retval.Replace("<-", @"\u8592?"); // Left Arrow
 | 
			
		||||
			retval = retval.Replace("<=", @"\u8804?"); // Less than or Equal
 | 
			
		||||
			retval = retval.Replace(">=", @"\u8805?"); // Greater than or Equal
 | 
			
		||||
			retval = retval.Replace("+\\u8209?", @"\'b1"); // plus minus
 | 
			
		||||
			retval = retval.Replace("+-", @"\'b1"); // plus minus
 | 
			
		||||
			return retval;
 | 
			
		||||
		}
 | 
			
		||||
		#endregion
 | 
			
		||||
		#region Public Methods
 | 
			
		||||
 | 
			
		||||
		#region (RO Search / Collections)
 | 
			
		||||
@@ -468,7 +484,7 @@ namespace VEPROMS.CSLA.Library
 | 
			
		||||
			return rc;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		public string GetTranslatedRoValue(string roid, bool DoCaret, bool DoDOSSuperSubScript)
 | 
			
		||||
		public string GetTranslatedRoValue(string roid, bool DoCaret, bool DoDOSSuperSubScript, bool convertRoSymbols)
 | 
			
		||||
		{
 | 
			
		||||
			roid = FormatRoidKey(roid, true);
 | 
			
		||||
 | 
			
		||||
@@ -478,6 +494,10 @@ namespace VEPROMS.CSLA.Library
 | 
			
		||||
				return "?"; // Returning a "?" character indicates that the selected RO Value no longer exists or has been deleted.
 | 
			
		||||
 | 
			
		||||
			retval = ReplaceUnicode(retval, DoCaret);
 | 
			
		||||
			// B2023-037: Handle <=, >=, +-, -> and <- symbols. Convert to unicode for output, i.e. print and edit/view (when editing
 | 
			
		||||
			//   step, will show as 2 characters, not unicode, unless ro inserted when code replaced link text with unicode.
 | 
			
		||||
			if (convertRoSymbols) retval = ROFSTLookup.ROConvertSymbols(retval);
 | 
			
		||||
 | 
			
		||||
			retval = ConvertFortranFormatToScienctificNotation(retval);
 | 
			
		||||
 | 
			
		||||
			// B2019-037 handle the super an sub scripts after getting the RO value from the FST
 | 
			
		||||
 
 | 
			
		||||
@@ -1616,7 +1616,7 @@ namespace VEPROMS.CSLA.Library
 | 
			
		||||
						foreach (ContentRoUsage ro in cont.ContentRoUsages)
 | 
			
		||||
						{
 | 
			
		||||
							RoUsageInfo rou = RoUsageInfo.Get(ro.ROUsageID);
 | 
			
		||||
							string myvalue = mylookup.GetTranslatedRoValue(rou.ROID, tmp.ActiveFormat.PlantFormat.FormatData.SectData.ConvertCaretToDelta, tmp.ActiveFormat.PlantFormat.FormatData.SectData.UseTildaPoundCharsForSuperSubScriptInROValues);
 | 
			
		||||
							string myvalue = mylookup.GetTranslatedRoValue(rou.ROID, tmp.ActiveFormat.PlantFormat.FormatData.SectData.ConvertCaretToDelta, tmp.ActiveFormat.PlantFormat.FormatData.SectData.UseTildaPoundCharsForSuperSubScriptInROValues, false);
 | 
			
		||||
							
 | 
			
		||||
							ROFSTLookup.rochild rocc = mylookup.GetRoChild(rou.ROID);
 | 
			
		||||
							
 | 
			
		||||
@@ -1843,7 +1843,7 @@ namespace VEPROMS.CSLA.Library
 | 
			
		||||
						ROFSTLookup mylookup = myRoFst.GetROFSTLookup(tmp.ContentItems[0].MyProcedure.MyDocVersion);
 | 
			
		||||
						foreach (RoUsageInfo rou in tmp.ContentRoUsages)
 | 
			
		||||
						{
 | 
			
		||||
							string myvalue = mylookup.GetTranslatedRoValue(rou.ROID, tmp.ContentItems[0].ActiveFormat.PlantFormat.FormatData.SectData.ConvertCaretToDelta, tmp.ContentItems[0].ActiveFormat.PlantFormat.FormatData.SectData.UseTildaPoundCharsForSuperSubScriptInROValues);
 | 
			
		||||
							string myvalue = mylookup.GetTranslatedRoValue(rou.ROID, tmp.ContentItems[0].ActiveFormat.PlantFormat.FormatData.SectData.ConvertCaretToDelta, tmp.ContentItems[0].ActiveFormat.PlantFormat.FormatData.SectData.UseTildaPoundCharsForSuperSubScriptInROValues, false);
 | 
			
		||||
							ROFSTLookup.rochild rocc = mylookup.GetRoChild(rou.ROID);
 | 
			
		||||
							int mytype = rocc.type;
 | 
			
		||||
							ctmp.FixContentText(rou, myvalue, mytype, myRoFst);
 | 
			
		||||
 
 | 
			
		||||
@@ -693,6 +693,11 @@ namespace VEPROMS.CSLA.Library
 | 
			
		||||
					if (isSetpoint)	newvalue = ReplaceSpaceWithHardspace(newvalue);
 | 
			
		||||
					// B2017-147: backquotes should be translated to degrees for edit/print:
 | 
			
		||||
					newvalue = newvalue.Replace("`", @"\'b0");
 | 
			
		||||
					// B2023-037: Handle <=, >=, +-, -> and <- symbols. If the format has flags to convert these RO symbols, it
 | 
			
		||||
					//	is done here so that output (print & edit/view) has symbol, not 2 characters.
 | 
			
		||||
					if (_MyItemInfo.ActiveFormat.PlantFormat.FormatData.SectData.UseDashGreaterLessThenForArrowsInROValue ||
 | 
			
		||||
						_MyItemInfo.ActiveFormat.PlantFormat.FormatData.SectData.ConvertGTELTEPMinROValue)
 | 
			
		||||
						newvalue = ROFSTLookup.ROConvertSymbols(newvalue);
 | 
			
		||||
 | 
			
		||||
					if (gg != newvalue)
 | 
			
		||||
						text = text.Substring(0, myIndex) + newvalue + text.Substring(myIndex + myLength);
 | 
			
		||||
 
 | 
			
		||||
@@ -900,7 +900,7 @@ namespace VEPROMS.CSLA.Library
 | 
			
		||||
					{
 | 
			
		||||
						string oldText = this.MyContent.Text;
 | 
			
		||||
 | 
			
		||||
						string roval = lookup.GetTranslatedRoValue(rousage.ROID, this.ActiveSection.ActiveFormat.PlantFormat.FormatData.SectData.ConvertCaretToDelta, this.ActiveSection.ActiveFormat.PlantFormat.FormatData.SectData.UseTildaPoundCharsForSuperSubScriptInROValues);
 | 
			
		||||
						string roval = lookup.GetTranslatedRoValue(rousage.ROID, this.ActiveSection.ActiveFormat.PlantFormat.FormatData.SectData.ConvertCaretToDelta, this.ActiveSection.ActiveFormat.PlantFormat.FormatData.SectData.UseTildaPoundCharsForSuperSubScriptInROValues, false);
 | 
			
		||||
						ROFSTLookup.rochild roch = lookup.GetRoChild(rousage.ROID);
 | 
			
		||||
						
 | 
			
		||||
						this.MyContent.FixContentText(rousage, roval, roch.type, rofstinfo, this);
 | 
			
		||||
@@ -956,7 +956,7 @@ namespace VEPROMS.CSLA.Library
 | 
			
		||||
						ROCheckCount++;
 | 
			
		||||
						string oldText = itemInfo.MyContent.Text;
 | 
			
		||||
 | 
			
		||||
						string roval = lookup.GetTranslatedRoValue(rousage.ROID, sectionInfo.ActiveFormat.PlantFormat.FormatData.SectData.ConvertCaretToDelta, sectionInfo.ActiveFormat.PlantFormat.FormatData.SectData.UseTildaPoundCharsForSuperSubScriptInROValues);
 | 
			
		||||
						string roval = lookup.GetTranslatedRoValue(rousage.ROID, sectionInfo.ActiveFormat.PlantFormat.FormatData.SectData.ConvertCaretToDelta, sectionInfo.ActiveFormat.PlantFormat.FormatData.SectData.UseTildaPoundCharsForSuperSubScriptInROValues, false);
 | 
			
		||||
						ROFSTLookup.rochild roch = lookup.GetRoChild(rousage.ROID);
 | 
			
		||||
 | 
			
		||||
						itemInfo.MyContent.FixContentText(rousage, roval, roch.type, origROFst, itemInfo);
 | 
			
		||||
@@ -1023,7 +1023,29 @@ namespace VEPROMS.CSLA.Library
 | 
			
		||||
		{
 | 
			
		||||
			string nt = newText.Replace(@"\u8209?", "-").Replace(@"\u160?", " ").Replace("\xA0", " ");
 | 
			
		||||
			string ot = oldText.Replace(@"\u8209?", "-").Replace(@"\u160?", " ").Replace("\xA0", " ");
 | 
			
		||||
			if (nt.Equals(ot))
 | 
			
		||||
			{
 | 
			
		||||
				return false;
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			// B2023-037: Handle <=, >=, +-, -> and <- symbols. Previous code changes replaced these symbol pairs with their
 | 
			
		||||
			//  unicode representation, thus link text data may have the Unicode character. This code update keeps the double
 | 
			
		||||
			//  character sequences in the link text (the RO text as is) and just converts when needing the output.  When
 | 
			
		||||
			//  updating ROs need to check for unicode characters too since some data may have that
 | 
			
		||||
			nt = nt.Replace(@"\u8594?", "->"); // Right Arrow
 | 
			
		||||
			ot = ot.Replace(@"\u8594?", "->"); // Right Arrow
 | 
			
		||||
			nt = nt.Replace(@"\u8592?", "<-"); // Left Arrow
 | 
			
		||||
			ot = ot.Replace(@"\u8592?", "<-"); // Left Arrow
 | 
			
		||||
			nt = nt.Replace(@"\u8804?", "<="); // Less than or Equal
 | 
			
		||||
			ot = ot.Replace(@"\u8804?", "<="); // Less than or Equal
 | 
			
		||||
			nt = nt.Replace(@"\u8805?", ">="); // Greater than or Equal
 | 
			
		||||
			ot = ot.Replace(@"\u8805?", ">="); // Greater than or Equal
 | 
			
		||||
			nt = nt.Replace(@"\u8805?", ">="); // Greater than or Equal
 | 
			
		||||
			ot = ot.Replace(@"\u8805?", ">="); // Greater than or Equal
 | 
			
		||||
			nt = nt.Replace(@"\u8594?", "+-"); // plus minus
 | 
			
		||||
			ot = ot.Replace(@"\u8594?", "+-"); // plus minus
 | 
			
		||||
			nt = nt.Replace(@"\'b1", "+-");
 | 
			
		||||
			ot = ot.Replace(@"\'b1", "+-");
 | 
			
		||||
			if (nt.Equals(ot))
 | 
			
		||||
			{
 | 
			
		||||
				return false;
 | 
			
		||||
@@ -1151,7 +1173,8 @@ namespace VEPROMS.CSLA.Library
 | 
			
		||||
					{
 | 
			
		||||
						if (sectionInfo != null)
 | 
			
		||||
						{
 | 
			
		||||
							string roval = lookup.GetTranslatedRoValue(rousage.ROID, sectionInfo.ActiveFormat.PlantFormat.FormatData.SectData.ConvertCaretToDelta, sectionInfo.ActiveFormat.PlantFormat.FormatData.SectData.UseTildaPoundCharsForSuperSubScriptInROValues);
 | 
			
		||||
							// B2023-037: loading print text, resolve the RO symbols 
 | 
			
		||||
							string roval = lookup.GetTranslatedRoValue(rousage.ROID, sectionInfo.ActiveFormat.PlantFormat.FormatData.SectData.ConvertCaretToDelta, sectionInfo.ActiveFormat.PlantFormat.FormatData.SectData.UseTildaPoundCharsForSuperSubScriptInROValues,sectionInfo.ActiveFormat.PlantFormat.FormatData.SectData.ConvertGTELTEPMinROValue|| sectionInfo.ActiveFormat.PlantFormat.FormatData.SectData.UseDashGreaterLessThenForArrowsInROValue);
 | 
			
		||||
							ROFSTLookup.rochild roch = lookup.GetRoChild(rousage.ROID);
 | 
			
		||||
							itemInfo.MyContent.FixContentText(rousage, roval, roch.type, rofstinfo, itemInfo);
 | 
			
		||||
						}
 | 
			
		||||
 
 | 
			
		||||
@@ -746,7 +746,7 @@ namespace VEPROMS.CSLA.Library
 | 
			
		||||
								{
 | 
			
		||||
									foreach (ItemInfo ii in roUsg.MyContent.ContentItems)
 | 
			
		||||
									{
 | 
			
		||||
										string val = newLookup.GetTranslatedRoValue(padroid, ii.ActiveFormat.PlantFormat.FormatData.SectData.ConvertCaretToDelta, ii.ActiveFormat.PlantFormat.FormatData.SectData.UseTildaPoundCharsForSuperSubScriptInROValues);
 | 
			
		||||
										string val = newLookup.GetTranslatedRoValue(padroid, ii.ActiveFormat.PlantFormat.FormatData.SectData.ConvertCaretToDelta, ii.ActiveFormat.PlantFormat.FormatData.SectData.UseTildaPoundCharsForSuperSubScriptInROValues, false);
 | 
			
		||||
										content.FixContentText(roUsg, val, roch.type, origROFstInfo, true);
 | 
			
		||||
 | 
			
		||||
										if (content.IsDirty)
 | 
			
		||||
 
 | 
			
		||||
@@ -905,7 +905,7 @@ namespace Volian.Controls.Library
 | 
			
		||||
						string linktxt = string.Format(@"#Link:ReferencedObject:<NewID> {0} {1}", padroid, MyROFST.RODbID);
 | 
			
		||||
 | 
			
		||||
						// Resolve symbols and scientific notation in the RO return value
 | 
			
		||||
						string valtxt = MyROFSTLookup.GetTranslatedRoValue(padroid, MyRTB.MyItemInfo.ActiveFormat.PlantFormat.FormatData.SectData.ConvertCaretToDelta, MyRTB.MyItemInfo.ActiveFormat.PlantFormat.FormatData.SectData.UseTildaPoundCharsForSuperSubScriptInROValues);
 | 
			
		||||
						string valtxt = MyROFSTLookup.GetTranslatedRoValue(padroid, MyRTB.MyItemInfo.ActiveFormat.PlantFormat.FormatData.SectData.ConvertCaretToDelta, MyRTB.MyItemInfo.ActiveFormat.PlantFormat.FormatData.SectData.UseTildaPoundCharsForSuperSubScriptInROValues, false);
 | 
			
		||||
 | 
			
		||||
						MyRTB.OnRoInsert(this, new StepRTBRoEventArgs(valtxt, selectedChld.value, linktxt, padroid, MyROFST.RODbID));
 | 
			
		||||
					}
 | 
			
		||||
 
 | 
			
		||||
@@ -972,29 +972,31 @@ namespace Volian.Controls.Library
 | 
			
		||||
		//    SelectionLength = 0;
 | 
			
		||||
		//    //OnModeChange(this, new StepRTBModeChangeEventArgs(ViewRTB?E_ViewMode.View:E_ViewMode.Edit));
 | 
			
		||||
		//}
 | 
			
		||||
		public string InsertSymbolInRO(string val)
 | 
			
		||||
		{
 | 
			
		||||
			string retval = val;
 | 
			
		||||
		//public string InsertSymbolInRO(string val)
 | 
			
		||||
		//{
 | 
			
		||||
		//	string retval = val;
 | 
			
		||||
			// C2019-043 convert a "->" to the Right Arrow symbol and a "<-" to the Left Arrow Symbol
 | 
			
		||||
			//           note that at the dash character gets convert to a non-breaking hyphen "\u8209?"
 | 
			
		||||
			if (MyItemInfo.ActiveFormat.PlantFormat.FormatData.SectData.UseDashGreaterLessThenForArrowsInROValue) 
 | 
			
		||||
			{
 | 
			
		||||
				retval = retval.Replace("\\u8209?>", GetAddSymbolTextForROs(@"\u8594?")); // Right Arrow
 | 
			
		||||
				retval = retval.Replace("<\\u8209?", GetAddSymbolTextForROs(@"\u8592?")); // Left Arrow
 | 
			
		||||
			}
 | 
			
		||||
			// C2022-021 convert a "<=" to a less than or equal symbol, a ">=" to a greather than or equal symbol and +- to a 
 | 
			
		||||
			//	plus/minus symbol in ROs
 | 
			
		||||
			if (MyItemInfo.ActiveFormat.PlantFormat.FormatData.SectData.ConvertGTELTEPMinROValue)
 | 
			
		||||
			{
 | 
			
		||||
				retval = retval.Replace("<=", GetAddSymbolTextForROs(@"\u8804?")); // Less than or Equal
 | 
			
		||||
				retval = retval.Replace(">=", GetAddSymbolTextForROs(@"\u8805?")); // Greater than or Equal
 | 
			
		||||
				retval = retval.Replace("+\\u8209?", @"\'b1");   // plus/minus - note - is stored as \u8209 and plus/minus is < 256, i.e. handled differently
 | 
			
		||||
			}
 | 
			
		||||
			return retval;
 | 
			
		||||
		}
 | 
			
		||||
			//if (MyItemInfo.ActiveFormat.PlantFormat.FormatData.SectData.UseDashGreaterLessThenForArrowsInROValue) 
 | 
			
		||||
			//{
 | 
			
		||||
			//	retval = retval.Replace("\\u8209?>", GetAddSymbolTextForROs(@"\u8594?")); // Right Arrow
 | 
			
		||||
			//	retval = retval.Replace("<\\u8209?", GetAddSymbolTextForROs(@"\u8592?")); // Left Arrow
 | 
			
		||||
			//}
 | 
			
		||||
			//// C2022-021 convert a "<=" to a less than or equal symbol, a ">=" to a greather than or equal symbol and +- to a 
 | 
			
		||||
			////	plus/minus symbol in ROs
 | 
			
		||||
			//if (MyItemInfo.ActiveFormat.PlantFormat.FormatData.SectData.ConvertGTELTEPMinROValue)
 | 
			
		||||
			//{
 | 
			
		||||
			//	retval = retval.Replace("<=", GetAddSymbolTextForROs(@"\u8804?")); // Less than or Equal
 | 
			
		||||
			//	retval = retval.Replace(">=", GetAddSymbolTextForROs(@"\u8805?")); // Greater than or Equal
 | 
			
		||||
			//	retval = retval.Replace("+\\u8209?", @"\'b1");   // plus/minus - note - is stored as \u8209 and plus/minus is < 256, i.e. handled differently
 | 
			
		||||
			//}
 | 
			
		||||
		//	return retval;
 | 
			
		||||
		//}
 | 
			
		||||
		public void InsertRO(string value, string link)
 | 
			
		||||
		{
 | 
			
		||||
			AddRtfLink(InsertSymbolInRO(value), link);
 | 
			
		||||
			// B2023-037:  Remove code that saves the unicode characters for <=, >=, +-, <- and -> into the link text.  The characters
 | 
			
		||||
			//  now get resolved when used.  InsertSymbolInRo was commented out also
 | 
			
		||||
			AddRtfLink(value, link);
 | 
			
		||||
		}
 | 
			
		||||
		public void InsertTran(string value, string link)
 | 
			
		||||
		{
 | 
			
		||||
 
 | 
			
		||||
@@ -562,7 +562,8 @@ namespace Volian.Controls.Library
 | 
			
		||||
			string padroid = (myroid.Length <= 12) ? myroid + "0000" : myroid;
 | 
			
		||||
			string linktxt = string.Format(@"#Link:ReferencedObject:<NewID> {0} {1}", padroid, MyLookup.MyDocVersionInfo.DocVersionAssociations[0].MyROFst.MyRODb.RODbID);
 | 
			
		||||
			// Resolve symbols and scientific notation in the RO return value
 | 
			
		||||
			string valtxt = MyLookup.GetTranslatedRoValue(padroid, MyStepRTB.MyItemInfo.ActiveFormat.PlantFormat.FormatData.SectData.ConvertCaretToDelta, MyStepRTB.MyItemInfo.ActiveFormat.PlantFormat.FormatData.SectData.UseTildaPoundCharsForSuperSubScriptInROValues); //ConvertSymbolsAndStuff(selectedChld.value);
 | 
			
		||||
			string valtxt = MyLookup.GetTranslatedRoValue(padroid, MyStepRTB.MyItemInfo.ActiveFormat.PlantFormat.FormatData.SectData.ConvertCaretToDelta, MyStepRTB.MyItemInfo.ActiveFormat.PlantFormat.FormatData.SectData.UseTildaPoundCharsForSuperSubScriptInROValues,
 | 
			
		||||
			 false); //ConvertSymbolsAndStuff(selectedChld.value);
 | 
			
		||||
			MyStepRTB.OnRoInsert(this, new StepRTBRoEventArgs(valtxt, myvalue, linktxt, padroid, MyLookup.MyDocVersionInfo.DocVersionAssociations[0].MyROFst.MyRODb.RODbID));
 | 
			
		||||
		}
 | 
			
		||||
		private void SaveROWithAnnotation_Click(object sender, EventArgs e)
 | 
			
		||||
@@ -579,7 +580,7 @@ namespace Volian.Controls.Library
 | 
			
		||||
			string padroid = (myroid.Length <= 12) ? myroid + "0000" : myroid;
 | 
			
		||||
			string linktxt = string.Format(@"#Link:ReferencedObject:<NewID> {0} {1}", padroid, MyLookup.MyDocVersionInfo.DocVersionAssociations[0].MyROFst.MyRODb.RODbID);
 | 
			
		||||
			// Resolve symbols and scientific notation in the RO return value
 | 
			
		||||
			string valtxt = MyLookup.GetTranslatedRoValue(padroid, MyStepRTB.MyItemInfo.ActiveFormat.PlantFormat.FormatData.SectData.ConvertCaretToDelta, MyStepRTB.MyItemInfo.ActiveFormat.PlantFormat.FormatData.SectData.UseTildaPoundCharsForSuperSubScriptInROValues); //ConvertSymbolsAndStuff(selectedChld.value);
 | 
			
		||||
			string valtxt = MyLookup.GetTranslatedRoValue(padroid, MyStepRTB.MyItemInfo.ActiveFormat.PlantFormat.FormatData.SectData.ConvertCaretToDelta, MyStepRTB.MyItemInfo.ActiveFormat.PlantFormat.FormatData.SectData.UseTildaPoundCharsForSuperSubScriptInROValues, false); //ConvertSymbolsAndStuff(selectedChld.value);
 | 
			
		||||
			MyStepRTB.OnRoInsert(this, new StepRTBRoEventArgs(valtxt, myvalue, linktxt, padroid, MyLookup.MyDocVersionInfo.DocVersionAssociations[0].MyROFst.MyRODb.RODbID));
 | 
			
		||||
		}
 | 
			
		||||
		private void NoROFound_Click(object sender, EventArgs e)
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user