C2021-056 Added FirstWord flag to ReplaceWords

C2021-056 Added logic to support the FirstWord flag in ReplaceWords.  When set, the word will be replaced only if it the first word in the text.
This commit is contained in:
John Jenko 2021-10-27 17:44:14 +00:00
parent 2e8e01e8ab
commit 8755e9f0ad
3 changed files with 15 additions and 6 deletions

View File

@ -303,7 +303,8 @@ namespace VEPROMS.CSLA.Library
InSecTitle = 0x40000, InSecTitle = 0x40000,
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
} }
[Serializable] [Serializable]
[TypeConverter(typeof(ExpandableObjectConverter))] [TypeConverter(typeof(ExpandableObjectConverter))]

View File

@ -2077,10 +2077,11 @@ namespace VEPROMS.CSLA.Library
{ {
bool dopartial = (E_ReplaceFlags)(rs.Flag & FormatConfig.E_ReplaceFlagsUCF.Partials) == E_ReplaceFlags.Partials; bool dopartial = (E_ReplaceFlags)(rs.Flag & FormatConfig.E_ReplaceFlagsUCF.Partials) == E_ReplaceFlags.Partials;
bool onlyDoList = (E_ReplaceFlags)(rs.Flag & FormatConfig.E_ReplaceFlagsUCF.BeforeList) == E_ReplaceFlags.BeforeList; // C2021-045 bool onlyDoList = (E_ReplaceFlags)(rs.Flag & FormatConfig.E_ReplaceFlagsUCF.BeforeList) == E_ReplaceFlags.BeforeList; // C2021-045
bool onlyIfFirstWord = (E_ReplaceFlags)(rs.Flag & FormatConfig.E_ReplaceFlagsUCF.FirstWord) == E_ReplaceFlags.FirstWord; // C2021-056
// note that the order of this check is important. Check in this order... // note that the order of this check is important. Check in this order...
// background here // background here
if (!shouldReplace.ContainsKey((E_ReplaceFlags)rs.Flag)) if (!shouldReplace.ContainsKey((E_ReplaceFlags)rs.Flag))
{ {
//int profileDepth2 = ProfileTimer.Push(">>>> Before ShouldReplaceIt"); //int profileDepth2 = ProfileTimer.Push(">>>> Before ShouldReplaceIt");
shouldReplace.Add((E_ReplaceFlags)rs.Flag, ShouldReplaceIt((E_ReplaceFlags)rs.Flag)); shouldReplace.Add((E_ReplaceFlags)rs.Flag, ShouldReplaceIt((E_ReplaceFlags)rs.Flag));
@ -2088,9 +2089,15 @@ namespace VEPROMS.CSLA.Library
} }
bool replaceit = shouldReplace[(E_ReplaceFlags)rs.Flag]; bool replaceit = shouldReplace[(E_ReplaceFlags)rs.Flag];
// C2021-045 if the BeforeList ReplaceWords flag is set, only do the replace word if the text ends with a colon if (replaceit)
if (replaceit && onlyDoList && !Text.EndsWith(":")) {
replaceit = false; // text does not end with a colon so don't replace this word // C2021-045 if the BeforeList ReplaceWords flag is set, only do the replace word if the text ends with a colon
if (onlyDoList && !Text.EndsWith(":"))
replaceit = false; // text does not end with a colon so don't replace this word
// C2021-056 if FirstWord ReplaceWords flag is set, only do if the replace word is the first word in the text
if (onlyIfFirstWord && !Text.StartsWith(rs.ReplaceWord))
replaceit = false;
}
if (!replaceit && _DoReplWordInPageList) replaceit = true; // F2021-053: Do replace words in page list if (!replaceit && _DoReplWordInPageList) replaceit = true; // F2021-053: Do replace words in page list
if (replaceit) if (replaceit)
{ {

View File

@ -229,7 +229,8 @@ namespace VEPROMS.CSLA.Library
InSecTitle = 0x40000, InSecTitle = 0x40000,
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
} }
public enum E_ArrowKeys : uint public enum E_ArrowKeys : uint
{ {