diff --git a/PROMS/Volian.Controls.Library/DisplayText.cs b/PROMS/Volian.Controls.Library/DisplayText.cs index 27925aae..fa1e62f5 100644 --- a/PROMS/Volian.Controls.Library/DisplayText.cs +++ b/PROMS/Volian.Controls.Library/DisplayText.cs @@ -1302,7 +1302,8 @@ namespace Volian.Controls.Library { if (_MyItemInfo.MyContent.Type < 20000) return Text; // for now only replace in steps. FoundMatches myMatches = new FoundMatches(Text); - //KBR myMatches.Add(regFindLink, null); + // Exclude Link Text from Replace Word process + myMatches.AddLink(regFindLink, _MyFormat.PlantFormat.FormatData.SectData.ReplaceWordsInROs, _MyItemInfo.MyProcedure.MyDocVersion); ReplaceStrList rsl = _MyFormat.PlantFormat.FormatData.SectData.ReplaceStrList; // Loop through text looking for words to be replaced foreach (ReplaceStr rs in rsl) @@ -1445,6 +1446,32 @@ namespace Volian.Controls.Library foreach (Match myMatch in myMatches) Add(myMatch, myWord); } + public void AddLink(Regex myRegEx, bool replaceWordsInROs, DocVersionInfo myDocVersion) + { + MatchCollection myMatches = myRegEx.Matches(_Text); + foreach (Match myMatch in myMatches) + { + if (!replaceWordsInROs || IsTransition(myMatch.Value) || IsSetpointRO(myMatch.Value, myDocVersion)) + Add(myMatch, null);// Exclude from Replace Words + } + } + private bool IsTransition(string link) + { + return link.Contains("#Link:Transition"); + } + private static Regex regRefObj = new Regex(@"\#Link\:ReferencedObject\:([0-9]*) ([0-9]*) ([0-9]*)", RegexOptions.Singleline); + private static bool IsSetpointRO(string link, DocVersionInfo myDocVersion) + { + Match myMatch = regRefObj.Match(link); + if (myMatch.Success) + { + int dbid = int.Parse(myMatch.Groups[2].Value.Substring(0, 4))-1; + int rodbid = int.Parse(myMatch.Groups[3].Value); + ROFstInfo myROFst = myDocVersion.GetROFst(rodbid); + return myROFst.IsSetpointDB(dbid); + } + return false; + } public void Add(Match myMatch, ReplaceStr myWord) { // If one already exists for this location, then don't add another.