From c9c26d235a3d02c5ad5876d80bc4ab3969860343 Mon Sep 17 00:00:00 2001 From: John Date: Fri, 15 Mar 2019 18:23:34 +0000 Subject: [PATCH] B2019-034 Added logic to handle when the user manually bolds and/or underlines a word that would normally be bolded and/or underlined via Replace Words --- .../Extension/DisplayText.cs | 27 +++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/PROMS/VEPROMS.CSLA.Library/Extension/DisplayText.cs b/PROMS/VEPROMS.CSLA.Library/Extension/DisplayText.cs index 93147f73..80b8bd31 100644 --- a/PROMS/VEPROMS.CSLA.Library/Extension/DisplayText.cs +++ b/PROMS/VEPROMS.CSLA.Library/Extension/DisplayText.cs @@ -2271,14 +2271,32 @@ namespace VEPROMS.CSLA.Library with = with.Replace(@"{\par}", ""); bool IsBold = ((_Font.Style & E_Style.Bold) == E_Style.Bold) || (_MyItemInfo.FormatStepData != null && _MyItemInfo.FormatStepData.BoldHighLevel && _MyItemInfo.IsRNOPart && _MyItemInfo.MyParent.IsHigh ); - if (IsBold && with.Contains(@"\b ")) + // B2019-034 If the word to be replaced in the procedure text was manually bolded, remove the bold on/off commands from the replacement word + if (!IsBold) + { + int repidxBoldOff = text.LastIndexOf(@"\b0", foundMatch.MyMatch.Index + offset); + int repidxBoldOn = text.LastIndexOf(@"\b", foundMatch.MyMatch.Index + offset); + if (repidxBoldOff > 0) + { + repidxBoldOn = text.Substring(repidxBoldOff + 3, foundMatch.MyMatch.Index + offset - (repidxBoldOff + 3)).LastIndexOf(@"\b"); + if (repidxBoldOn >= 0) + repidxBoldOn += (repidxBoldOff + 3); + } + if (repidxBoldOn >= 0) IsBold = true; + } + // B2019-034 added more cases to look for and remove bold on/off from the ReplaceWith word + if (IsBold && (with.Contains(@"\b ") || with.Contains(@"\b\"))) { with = with.Replace(@"\b ",""); + with = with.Replace(@"\b\", @"\"); with = with.Replace(@"\b0 ",""); + with = with.Replace(@"\b0\", @"\"); + if (with.EndsWith(@"\b0")) + with = with.Replace(@"\b0",""); } bool IsUnderline = (((_Font.Style & E_Style.Underline) == E_Style.Underline) && with.Contains(@"\ul ")); // handle where replace words replaces a string with 'underline on'string'underline off', for example Point Beach - // had replaced OR's turning underline off in the middle of a transition, "EOP-0 UNIT 1, RACTORE TRIP OR SAFETY INJECTION". + // had replaced OR's turning underline off in the middle of a transition, "EOP-0 UNIT 1, REACTOR TRIP OR SAFETY INJECTION". if (!IsUnderline) { int repidxulnone = text.LastIndexOf(@"\ulnone", foundMatch.MyMatch.Index + offset); @@ -2291,10 +2309,15 @@ namespace VEPROMS.CSLA.Library } if (repidxst >= 0) IsUnderline = true; } + // B2019-034 added more cases to look for and remove underline on/off from the ReplaceWith word if (IsUnderline) { with = with.Replace(@"\ul ", ""); + with = with.Replace(@"\ul\", @"\"); with = with.Replace(@"\ulnone ", ""); + with = with.Replace(@"\ulnone\", @"\"); + if (with.EndsWith(@"\ulnone")) + with = with.Replace(@"\ulnone",""); } string preceedingText = text.Substring(0, offset + foundMatch.MyMatch.Index); int ndxBold = preceedingText.LastIndexOf(@"\b");