Added code to limit when Replace Words are replaced within ROs.

ReplaceWords are only replaced when the flag is set and when the RO is not a setpoint
This commit is contained in:
Rich 2010-10-15 21:14:34 +00:00
parent efdd461edf
commit b39ee1b05b

View File

@ -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.