C2025-022-Remove-UCF-2

This commit is contained in:
2025-08-28 15:24:28 -04:00
parent 525173bc9f
commit 8abe57552c
12 changed files with 116 additions and 767 deletions

View File

@@ -2153,7 +2153,7 @@ namespace VEPROMS.CSLA.Library
// return Text;
//}
#endregion
private static Dictionary<FormatConfig.ReplaceStr, Regex> dicReplaceRegex = new Dictionary<FormatConfig.ReplaceStr, Regex>();
private static Dictionary<ReplaceStr, Regex> dicReplaceRegex = new Dictionary<ReplaceStr, Regex>();
private static bool? _ProcessReplaceWords;
public static bool ProcessReplaceWords
{
@@ -2178,7 +2178,8 @@ namespace VEPROMS.CSLA.Library
// F2021-053: BNPP Alarm - need ability to have super/sub scripts in the text of Alarm Tables (ROs).
// if doing replace words for Page List items, the current item is not a step, use _DoReplWordInPageList flags this
if (_MyItemInfo.MyContent.Type < 20000 && !_DoReplWordInPageList) return Text; // for now only replace in steps.
FormatConfig.ReplaceStrData rsl = _MyFormat.PlantFormat.UCFandOrigReplaceStrData;
//FormatConfig.ReplaceStrData rsl = _MyFormat.PlantFormat.FormatConfig.UCFandReplaceStrData;
ReplaceStrList rsl = _MyFormat.PlantFormat.FormatData.SectData.ReplaceStrList;
if (rsl.Count == 1 && (rsl[0].ReplaceWord == null || rsl[0].ReplaceWord == "")) return Text;
// F2021-093: Handle partials first and then plain replace words. Need to do this so that the words don't get processed by plain replace
@@ -2193,15 +2194,16 @@ namespace VEPROMS.CSLA.Library
// Loop through text looking for words to be replaced
Dictionary<E_ReplaceFlags?, bool> shouldReplace = new Dictionary<E_ReplaceFlags?, bool>();
//int profileDepth = ProfileTimer.Push(">>>> DoReplaceWords2.ForLoop");
foreach (FormatConfig.ReplaceStr rs in rsl)
foreach (ReplaceStr rs in rsl)
{
bool dopartial = (E_ReplaceFlags)(rs.Flag) == E_ReplaceFlags.Partials;
if (!dopartial) // F2021-093: Partials moved into their own method and done first
//bool dopartial = (E_ReplaceFlags)(rs.Flag & E_ReplaceFlags.CaseInsens) == E_ReplaceFlags.Partials; // save it may need to be changed back to this code.
bool dopartial = (rs.Flag & E_ReplaceFlags.Partials) == E_ReplaceFlags.Partials; // from pre-UCF
if (!dopartial) // F2021-093: Partials moved into their own method and done first
{
bool onlyDoList = (E_ReplaceFlags)(rs.Flag) == E_ReplaceFlags.BeforeList; // C2021-045
bool onlyIfFirstWord = (E_ReplaceFlags)(rs.Flag) == E_ReplaceFlags.FirstWord; // C2021-056
bool doInPagelist = (E_ReplaceFlags)(rs.Flag) == E_ReplaceFlags.PageList; // B2021-132
//B2021-132 only do replacewords in paglist if the replaceword pagelist flag is set
bool onlyDoList = (E_ReplaceFlags)(rs.Flag & E_ReplaceFlags.BeforeList) == E_ReplaceFlags.BeforeList; // C2021-045, C2025-022 remove UFC
bool onlyIfFirstWord = (E_ReplaceFlags)(rs.Flag & E_ReplaceFlags.FirstWord) == E_ReplaceFlags.FirstWord; // C2021-056
bool doInPagelist = (E_ReplaceFlags)(rs.Flag & E_ReplaceFlags.PageList) == E_ReplaceFlags.PageList; // B2021-132
//B2021-132 only do replacewords in paglist if the replaceword pagelist flag is set
if (_DoReplWordInPageList && !doInPagelist) continue;
// note that the order of this check is important. Check in this order...
@@ -2228,7 +2230,9 @@ namespace VEPROMS.CSLA.Library
{
if (!dicReplaceRegex.ContainsKey(rs))
{
RegexOptions myOptions = (E_ReplaceFlags)(rs.Flag) == E_ReplaceFlags.CaseInsens ? RegexOptions.IgnoreCase : RegexOptions.None;
RegexOptions myOptions = (E_ReplaceFlags)(rs.Flag & E_ReplaceFlags.CaseInsens) == E_ReplaceFlags.CaseInsens ? RegexOptions.IgnoreCase : RegexOptions.None;
//RegexOptions myOptions = (E_ReplaceFlags)(rs.Flag) == E_ReplaceFlags.CaseInsens ? RegexOptions.IgnoreCase : RegexOptions.None;
//RegexOptions myOptions = (rs.Flag & E_ReplaceFlags.CaseInsens) == E_ReplaceFlags.CaseInsens ? RegexOptions.IgnoreCase : RegexOptions.None;
//int profileDepth3 = ProfileTimer.Push(">>>> DoReplaceWords2.BuildMatch");
// CASEINSENS: Do ReplaceWords for all words that match, regardless of case, and replace with the ReplaceWith string as is
//RegexOptions myOptions = (rs.Flag & E_ReplaceFlags.CaseInsens) == E_ReplaceFlags.CaseInsens ? RegexOptions.IgnoreCase & RegexOptions.Singleline : RegexOptions.None & RegexOptions.Singleline;
@@ -2268,18 +2272,18 @@ namespace VEPROMS.CSLA.Library
// F2021-093: separate out partial replace words so that they can all be done before normal replace words. Partials read in the 'repword', use
// it as-is as a dotnet regular expression to do replacement. Aside from the dotnet regular expression process, the rest of this
// code is similar to plain regular expressions, in terms of processing flags for which steps, etc.
private string DoReplacePartials(string Text, FormatConfig.ReplaceStrData rsl)
private string DoReplacePartials(string Text, ReplaceStrList rsl)
{
Dictionary<FormatConfig.ReplaceStr, Regex> partialReplaceList = new Dictionary<FormatConfig.ReplaceStr, Regex>();
Dictionary<ReplaceStr, Regex> partialReplaceList = new Dictionary<ReplaceStr, Regex>();
Dictionary<E_ReplaceFlags?, bool> shouldReplace = new Dictionary<E_ReplaceFlags?, bool>();
foreach (FormatConfig.ReplaceStr rs in rsl)
foreach (ReplaceStr rs in rsl)
{
bool dopartial = (E_ReplaceFlags)(rs.Flag) == E_ReplaceFlags.Partials;
bool dopartial = (E_ReplaceFlags)(rs.Flag & E_ReplaceFlags.Partials) == E_ReplaceFlags.Partials;
if (dopartial)
{
bool onlyDoList = (E_ReplaceFlags)(rs.Flag) == E_ReplaceFlags.BeforeList; // C2021-045
bool onlyDoList = (E_ReplaceFlags)(rs.Flag & E_ReplaceFlags.BeforeList) == E_ReplaceFlags.BeforeList; // C2021-045
bool onlyIfFirstWord = (E_ReplaceFlags)(rs.Flag) == E_ReplaceFlags.FirstWord; // C2021-056
bool doInPagelist = (E_ReplaceFlags)(rs.Flag) == E_ReplaceFlags.PageList; // B2021-132
bool doInPagelist = (E_ReplaceFlags)(rs.Flag & E_ReplaceFlags.PageList) == E_ReplaceFlags.PageList; // B2021-132
//B2021-132 only do replacewords in paglist if the replaceword pagelist flag is set
if (_DoReplWordInPageList && !doInPagelist) continue;
@@ -2304,7 +2308,7 @@ namespace VEPROMS.CSLA.Library
{
if (!dicReplaceRegex.ContainsKey(rs))
{
RegexOptions myOptions = (E_ReplaceFlags)(rs.Flag) == E_ReplaceFlags.CaseInsens ? RegexOptions.IgnoreCase : RegexOptions.None;
RegexOptions myOptions = (E_ReplaceFlags)(rs.Flag & E_ReplaceFlags.CaseInsens) == E_ReplaceFlags.CaseInsens ? RegexOptions.IgnoreCase : RegexOptions.None;
dicReplaceRegex.Add(rs, new Regex(rs.ReplaceWord, myOptions));
}
try
@@ -2320,7 +2324,7 @@ namespace VEPROMS.CSLA.Library
Text = Text.Replace(@"\xA0", @"\u160?"); //replace hard space
try
{
foreach (FormatConfig.ReplaceStr prs in partialReplaceList.Keys)
foreach (ReplaceStr prs in partialReplaceList.Keys)
Text = partialReplaceList[prs].Replace(Text, prs.ReplaceWith);
//if (partialReplaceList.Count>0) GC.Collect(); // microsoft had a memory leak in regular expression code - this REALLY slows it down though
}
@@ -2486,7 +2490,7 @@ namespace VEPROMS.CSLA.Library
_Font = font;
_MyItemInfo = myItemInfo;
}
public void Add(Regex myRegEx, FormatConfig.ReplaceStr myWord)
public void Add(Regex myRegEx, ReplaceStr myWord)
{
MatchCollection myMatches = myRegEx.Matches(_Text);
foreach (Match myMatch in myMatches)
@@ -2529,7 +2533,7 @@ namespace VEPROMS.CSLA.Library
}
return false;
}
public void Add(Match myMatch, FormatConfig.ReplaceStr myWord)
public void Add(Match myMatch, ReplaceStr myWord)
{
// If one already exists for this location, then don't add another.
if (ContainsKey(myMatch.Index)) return;
@@ -2563,12 +2567,12 @@ namespace VEPROMS.CSLA.Library
{
// B2022-015 BNPPalr: Determine whether RO text should have Replace Words applied. InLinkAndNotInRoFlag checks
// for flag on replace word item & checks that it is within and RO link
bool InLinkAndNotInRoFlag = ((foundMatch.MyWord.Flag) != 0) ? VerifyWithinLink(text, foundMatch, offset) : false;
bool InLinkAndNotInRoFlag = ((foundMatch.MyWord.Flag & E_ReplaceFlags.NotInRO) != 0) ? VerifyWithinLink(text, foundMatch, offset) : false;
if (!InLinkAndNotInRoFlag && VerifyNoHardSpace(text, foundMatch, offset) && VerifyNoLink(text, foundMatch, offset))
{
//if(offset != 0 || foundMatch.MyMatch.Index != 0 || !foundMatch.MyWord.ReplaceWith.StartsWith(@"{\par}"))
//{
if (((foundMatch.MyWord.Flag) == 0) || DiffUnit(foundMatch.MyWord.ReplaceWord, _MyItemInfo, "UNIT "))
if (((foundMatch.MyWord.Flag & E_ReplaceFlags.DiffUnit) == 0) || DiffUnit(foundMatch.MyWord.ReplaceWord, _MyItemInfo, "UNIT "))
{
string with = foundMatch.MyWord.ReplaceWith;
if (offset == 0 && with.StartsWith(@"{\par}"))
@@ -2723,13 +2727,13 @@ namespace VEPROMS.CSLA.Library
get { return _MyMatch; }
set { _MyMatch = value; }
}
private FormatConfig.ReplaceStr _MyWord;
public FormatConfig.ReplaceStr MyWord
private ReplaceStr _MyWord;
public ReplaceStr MyWord
{
get { return _MyWord; }
set { _MyWord = value; }
}
public FoundMatch(Match myMatch, FormatConfig.ReplaceStr myWord)
public FoundMatch(Match myMatch, ReplaceStr myWord)
{
_MyMatch = myMatch;
_MyWord = myWord;