Fixed ReplaceWord logic to not add bolding if the step is bolded.
This commit is contained in:
parent
768890116c
commit
b030911ef3
@ -1510,7 +1510,7 @@ namespace Volian.Controls.Library
|
|||||||
private string DoReplaceWords2(string Text)
|
private string DoReplaceWords2(string Text)
|
||||||
{
|
{
|
||||||
if (_MyItemInfo.MyContent.Type < 20000) return Text; // for now only replace in steps.
|
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
|
// Exclude Link Text from Replace Word process
|
||||||
myMatches.AddLink(regFindLink, _MyFormat.PlantFormat.FormatData.SectData.ReplaceWordsInROs, _MyItemInfo.MyProcedure.MyDocVersion);
|
myMatches.AddLink(regFindLink, _MyFormat.PlantFormat.FormatData.SectData.ReplaceWordsInROs, _MyItemInfo.MyProcedure.MyDocVersion);
|
||||||
ReplaceStrList rsl = _MyFormat.PlantFormat.FormatData.SectData.ReplaceStrList;
|
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 static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
private string _Text;
|
private string _Text;
|
||||||
public FoundMatches(string text)
|
private VE_Font _Font;
|
||||||
|
public FoundMatches(string text, VE_Font font)
|
||||||
: base()
|
: base()
|
||||||
{
|
{
|
||||||
_Text = text;
|
_Text = text;
|
||||||
|
_Font = font;
|
||||||
}
|
}
|
||||||
public void Add(Regex myRegEx, ReplaceStr myWord)
|
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}"))
|
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;
|
offset += foundMatch.MyWord.ReplaceWith.Length - foundMatch.MyMatch.Length;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user