When there is a bold and underline command remove the space between the two commands.

Logic to consider underline and bold command between a hard space a word when determining if replace words should be done.
This commit is contained in:
John Jenko 2015-11-10 15:40:24 +00:00
parent 8af0edb375
commit 10c11b9f36
2 changed files with 11 additions and 9 deletions

View File

@ -1778,14 +1778,12 @@ namespace Volian.Controls.Library
} }
private string DoReplaceWords2(string Text) private string DoReplaceWords2(string Text)
{ {
if(!ProcessReplaceWords) return Text; if (!ProcessReplaceWords) return 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,_MyItemInfo.FormatStepData.Font,_MyItemInfo); FoundMatches myMatches = new FoundMatches(Text, _MyItemInfo.FormatStepData.Font, _MyItemInfo);
// 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;
// The only way to get an 'empty' list is to have one 'dummy' replacestr, i.e. that has ReplaceWord as an empty string. If the
// ReplaceStrData xml node is empty, it does the inheritance and gets the 'base' format's list. // ReplaceStrData xml node is empty, it does the inheritance and gets the 'base' format's list.
if (rsl.Count==1 && (rsl[0].ReplaceWord == null || rsl[0].ReplaceWord == "")) return Text; if (rsl.Count==1 && (rsl[0].ReplaceWord == null || rsl[0].ReplaceWord == "")) return Text;
// Loop through text looking for words to be replaced // Loop through text looking for words to be replaced
@ -1845,6 +1843,7 @@ namespace Volian.Controls.Library
} }
//ProfileTimer.Pop(profileDepth); //ProfileTimer.Pop(profileDepth);
//int profileDepth5 = ProfileTimer.Push(">>>> DoReplaceWords2.ReplaceMatches"); //int profileDepth5 = ProfileTimer.Push(">>>> DoReplaceWords2.ReplaceMatches");
Text = myMatches.ReplaceMatches(); Text = myMatches.ReplaceMatches();
//ProfileTimer.Pop(profileDepth5); //ProfileTimer.Pop(profileDepth5);
Text = Text.Replace(@"\xA0", @"\u160?"); //replace hard space Text = Text.Replace(@"\xA0", @"\u160?"); //replace hard space
@ -2150,10 +2149,11 @@ namespace Volian.Controls.Library
if (text.StartsWith(@"{\rtf")) if (text.StartsWith(@"{\rtf"))
{ {
// make sure that it is not preceded by \u160? \'a0 or \~ // make sure that it is not preceded by \u160? \'a0 or \~
if(Regex.IsMatch(begin,@"(\\(u160\?|'a0|~)(\\f[0-9]* ?)*(\\fs[0-9]* ?)*)$")) // bug fix B2015-197 - need to consider underline and bold commands between a hard space and a word
if (Regex.IsMatch(begin, @"(\\(u160\?|'a0|~)(\\ulnone ?|\\b0 ?|\\ul ?|\\b ?)*(\\f[0-9]* ?)*(\\fs[0-9]* ?)*)$"))
return false; return false;
// make sure that it is not followed by \u160? \'a0 or \~ // make sure that it is not followed by \u160? \'a0 or \~
if (Regex.IsMatch(end, @"^((\\f[0-9]* ?)*(\\fs[0-9]* ?)*\\(u160\?|'a0|~))")) if (Regex.IsMatch(end, @"^((\\f[0-9]* ?)*(\\fs[0-9]* ?)*(\\ulnone ?|\\b0 ?|\\ul ?|\\b ?)*\\(u160\?|'a0|~))"))
return false; return false;
} }
else else

View File

@ -664,14 +664,16 @@ namespace Volian.Print.Library
_StatRTB.Width = (int)w; _StatRTB.Width = (int)w;
_StatRTB.Font = MyFlexGrid.Font; _StatRTB.Font = MyFlexGrid.Font;
if (str.StartsWith(@"{\rtf")) if (str.StartsWith(@"{\rtf"))
// The 'Replace(@" \ulnone", @"\u160?\ulnone")' was added so that data in VEWCN SUR_WTC {
// tables would print. There were a number of tables, for example in STN NB-106/8.1.6, // The 'Replace(@" \ulnone", @"\u160?\ulnone")' was added so that data in VEWCNSUR_MTC
// tables would print. There were a number of tables, for example in STN NB-115/8.1.6,
// that had a series of spaces underlined and these spaces were not underlined in the // that had a series of spaces underlined and these spaces were not underlined in the
// generated pdf. It seems that there is a problem somewhere in the rtb -> itextsharp // generated pdf. It seems that there is a problem somewhere in the rtb -> itextsharp
// level. This fixed the immediate problem. If there is 'b0' (bold off) after the // level. This fixed the immediate problem. If there is 'b0' (bold off) after the
// space before the 'ulnone' the following won't work. Also, this change was not // space before the 'ulnone' the following won't work. Also, this change was not
// made in the non-table code. If the problem occurs there, it should be added. // made in the non-table code. If the problem occurs there, it should be added.
_StatRTB.Rtf = str.Replace(@"\~", @"\u160?").Replace(@" \ulnone", @"\u160?\ulnone"); _StatRTB.Rtf = Regex.Replace(str.Replace(@"\~", @"\u160?"), @"(?<!\\[a-z0-9]+) \\ulnone", @"\u160?\ulnone");
}
else else
_StatRTB.Text = str; _StatRTB.Text = str;
_StatRTB.SelectAll(); _StatRTB.SelectAll();