B2022-015: BNPP - Added an ‘NotInRO flag’ for replace words to determine whether RO text should have Replace Words applied

This commit is contained in:
Kathy Ruffing 2022-01-21 15:23:47 +00:00
parent 6808579c38
commit 1e217c71ec
3 changed files with 39 additions and 20 deletions

View File

@ -304,7 +304,8 @@ namespace VEPROMS.CSLA.Library
BeforeTrans = 0x80000, // Only do replace if the string occurs immediately before a transition. BeforeTrans = 0x80000, // Only do replace if the string occurs immediately before a transition.
BeforeList = 0x100000, // C2021-045 Only if the text ends with a colon ":" BeforeList = 0x100000, // C2021-045 Only if the text ends with a colon ":"
PageList = 0x200000, // F2021-053 Do replace words for PageList items that are ROs PageList = 0x200000, // F2021-053 Do replace words for PageList items that are ROs
FirstWord = 0x400000 // C2021-056 Do only if is the first word in the text FirstWord = 0x400000, // C2021-056 Do only if is the first word in the text
NotInRO = 0x800000 // B2022-015 BNPPalr: Determine whether RO text should have Replace Words applied
} }
[Serializable] [Serializable]
[TypeConverter(typeof(ExpandableObjectConverter))] [TypeConverter(typeof(ExpandableObjectConverter))]

View File

@ -2443,7 +2443,10 @@ namespace VEPROMS.CSLA.Library
{ {
if (foundMatch.MyWord != null) if (foundMatch.MyWord != null)
{ {
if (VerifyNoHardSpace(text, foundMatch, offset) && VerifyNoLink(text, foundMatch, offset)) // 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 & FormatConfig.E_ReplaceFlagsUCF.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(offset != 0 || foundMatch.MyMatch.Index != 0 || !foundMatch.MyWord.ReplaceWith.StartsWith(@"{\par}"))
//{ //{
@ -2534,6 +2537,20 @@ namespace VEPROMS.CSLA.Library
} }
return text; return text;
} }
// B2022-015 BNPPalr: Determine whether RO text should have Replace Words applied
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
int sindx = text.LastIndexOf("<START]", foundMatch.MyMatch.Index);
if (sindx > -1)
{
int eindx = text.IndexOf("[END>",sindx + 1);
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;
}
return false;
}
private bool VerifyNoLink(string text, FoundMatch fndMatch, int offset) private bool VerifyNoLink(string text, FoundMatch fndMatch, int offset)
{ {
if (text.Substring(offset + fndMatch.MyMatch.Index, fndMatch.MyMatch.Length) == "START") if (text.Substring(offset + fndMatch.MyMatch.Index, fndMatch.MyMatch.Length) == "START")

View File

@ -230,7 +230,8 @@ namespace VEPROMS.CSLA.Library
BeforeTrans = 0x80000, // Only do replace if the string occurs immediately before a transition. BeforeTrans = 0x80000, // Only do replace if the string occurs immediately before a transition.
BeforeList = 0x100000, // C2021-045 Only if the text ends with a colon ":" BeforeList = 0x100000, // C2021-045 Only if the text ends with a colon ":"
PageList = 0x200000, // F2021-053: Do replace words in page list PageList = 0x200000, // F2021-053: Do replace words in page list
FirstWord = 0x400000 // C2021-056 Do only if is the first word in the text FirstWord = 0x400000, // C2021-056 Do only if is the first word in the text
NotInRO = 0x800000 // B2022-015 BNPPalr: Determine whether RO text should have Replace Words applied
} }
public enum E_ArrowKeys : uint public enum E_ArrowKeys : uint
{ {