B2022-022: BNPP replace words, NotInRO flag not always working when other replacements exist in step

This commit is contained in:
Kathy Ruffing 2022-01-27 13:58:43 +00:00
parent 56c5212a84
commit 13105d7048

View File

@ -2538,15 +2538,17 @@ namespace VEPROMS.CSLA.Library
return text; return text;
} }
// B2022-015 BNPPalr: Determine whether RO text should have Replace Words applied // B2022-015 BNPPalr: Determine whether RO text should have Replace Words applied
// B2022-022 BNPP needed to add use of 'offset' to work with string. 'offset' is used in code to keep track
// of offset in text in case other replacements are made before the current, i.e. adjusts the index found in the Match.
private bool VerifyWithinLink(string text, FoundMatch foundMatch, int offset) private bool VerifyWithinLink(string text, FoundMatch foundMatch, int offset)
{ {
// Is Match within a link, i.e. between a start & end and has '#Link:R' (defined referenced object link) between them too // Is Match within a link, i.e. between a start & end and has '#Link:R' (defined referenced object link) between them too
int sindx = text.LastIndexOf("<START]", foundMatch.MyMatch.Index); int sindx = text.LastIndexOf("<START]", offset + foundMatch.MyMatch.Index); // B2022-022 added offset
if (sindx > -1) if (sindx > -1)
{ {
int eindx = text.IndexOf("[END>",sindx + 1); int eindx = text.IndexOf("[END>",sindx + 1);
bool isRo = eindx > sindx && text.Substring(sindx, eindx - sindx - 1).Contains("#Link:R"); bool isRo = eindx > sindx && text.Substring(sindx, eindx - sindx - 1).Contains("#Link:R");
if (isRo && foundMatch.MyMatch.Index > sindx && foundMatch.MyMatch.Index < eindx) return true; if (isRo && foundMatch.MyMatch.Index + offset > sindx && foundMatch.MyMatch.Index + offset < eindx) return true; // B2022-022 added offset
} }
return false; return false;
} }