From b030911ef3964b21ff607197747b6a5dd9b28eb2 Mon Sep 17 00:00:00 2001 From: Rich Date: Tue, 17 Dec 2013 14:07:23 +0000 Subject: [PATCH] Fixed ReplaceWord logic to not add bolding if the step is bolded. --- PROMS/Volian.Controls.Library/DisplayText.cs | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/PROMS/Volian.Controls.Library/DisplayText.cs b/PROMS/Volian.Controls.Library/DisplayText.cs index d4128c16..cce1ea5c 100644 --- a/PROMS/Volian.Controls.Library/DisplayText.cs +++ b/PROMS/Volian.Controls.Library/DisplayText.cs @@ -1510,7 +1510,7 @@ namespace Volian.Controls.Library private string DoReplaceWords2(string Text) { if (_MyItemInfo.MyContent.Type < 20000) return Text; // for now only replace in steps. - FoundMatches myMatches = new FoundMatches(Text); + FoundMatches myMatches = new FoundMatches(Text,_MyItemInfo.FormatStepData.Font); // Exclude Link Text from Replace Word process myMatches.AddLink(regFindLink, _MyFormat.PlantFormat.FormatData.SectData.ReplaceWordsInROs, _MyItemInfo.MyProcedure.MyDocVersion); ReplaceStrList rsl = _MyFormat.PlantFormat.FormatData.SectData.ReplaceStrList; @@ -1656,10 +1656,12 @@ namespace Volian.Controls.Library { private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); private string _Text; - public FoundMatches(string text) + private VE_Font _Font; + public FoundMatches(string text, VE_Font font) : base() { _Text = text; + _Font = font; } public void Add(Regex myRegEx, ReplaceStr myWord) { @@ -1722,7 +1724,18 @@ namespace Volian.Controls.Library { if(offset != 0 || foundMatch.MyMatch.Index != 0 || !foundMatch.MyWord.ReplaceWith.StartsWith("{\\par}")) { - text = text.Substring(0, offset + foundMatch.MyMatch.Index) + foundMatch.MyWord.ReplaceWith + text.Substring(offset + foundMatch.MyMatch.Index + foundMatch.MyMatch.Length); + string with = foundMatch.MyWord.ReplaceWith; + if (((_Font.Style & E_Style.Bold) == E_Style.Bold) && with.Contains(@"\b ")) + { + with = with.Replace(@"\b ",""); + with = with.Replace(@"\b0 ",""); + } + if (((_Font.Style & E_Style.Underline) == E_Style.Underline) && with.Contains(@"\ul ")) + { + with = with.Replace(@"\ul ", ""); + with = with.Replace(@"\ulnone ", ""); + } + text = text.Substring(0, offset + foundMatch.MyMatch.Index) + with + text.Substring(offset + foundMatch.MyMatch.Index + foundMatch.MyMatch.Length); offset += foundMatch.MyWord.ReplaceWith.Length - foundMatch.MyMatch.Length; } }