Replace Words in RNOs no longer shuts-off bolding

This commit is contained in:
Rich 2014-01-08 11:52:35 +00:00
parent 09b58793fc
commit dade570a7f

View File

@ -1512,7 +1512,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,_MyItemInfo.FormatStepData.Font);
FoundMatches myMatches = new FoundMatches(Text,_MyItemInfo.FormatStepData.Font,_MyItemInfo);
// 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;
@ -1659,11 +1659,13 @@ namespace Volian.Controls.Library
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
private string _Text;
private VE_Font _Font;
public FoundMatches(string text, VE_Font font)
private ItemInfo _MyItemInfo;
public FoundMatches(string text, VE_Font font, ItemInfo myItemInfo)
: base()
{
_Text = text;
_Font = font;
_MyItemInfo = myItemInfo;
}
public void Add(Regex myRegEx, ReplaceStr myWord)
{
@ -1727,7 +1729,9 @@ namespace Volian.Controls.Library
if(offset != 0 || foundMatch.MyMatch.Index != 0 || !foundMatch.MyWord.ReplaceWith.StartsWith("{\\par}"))
{
string with = foundMatch.MyWord.ReplaceWith;
if (((_Font.Style & E_Style.Bold) == E_Style.Bold) && with.Contains(@"\b "))
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 "))
{
with = with.Replace(@"\b ","");
with = with.Replace(@"\b0 ","");