B2017-046 added a check for a zero selection length when we check a table cell that uses the symbol font

This commit is contained in:
John Jenko 2017-03-16 19:28:38 +00:00
parent 41bc492517
commit b8f330718e

View File

@ -336,6 +336,9 @@ namespace Volian.Print.Library
}
public partial class vlnCells : List<vlnCell> // RHM20150429 - Table Scrunch
{
#region Log4Net
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion
#region Properties
private VlnFlexGrid _MyFlexGrid;
public VlnFlexGrid MyFlexGrid
@ -781,13 +784,22 @@ namespace Volian.Print.Library
{
System.Windows.Forms.RichTextBox rtb = new System.Windows.Forms.RichTextBox();
rtb.Rtf = rtf;
string strRTF = rtf;
bool changed = false;
// Look at one character at a time
for (int i = 0; i < rtb.TextLength; i++)
{
rtb.Select(i, 1);
// If the character is a printable character set the font to the text font
if (rtb.SelectionFont.FontFamily.Name == "VESymbFix" && rtb.SelectedText[0] > ' ' && rtb.SelectedText[0] <= '\xFF')
if (rtb.SelectionLength == 0 && strRTF != null && rtb.SelectionFont.FontFamily.Name == "VESymbFix")
{
// Add debug information to the error log if the selection length is zero
_MyLog.WarnFormat("Font Issues in Table Cell rtf= {0}, \nI= {1}, TXT = {2}", strRTF,i,rtb.Text.Substring(0,i));
strRTF = null;
}
// bug fix: B2017-046 - check for selection length of zero to fix index out of bounds error
// System.Windows.Forms.RichTextBox is having issues selection text in some cases (ex. Symbol char followed by a RO reference - without a space between them)
if (rtb.SelectionLength > 0 && rtb.SelectionFont.FontFamily.Name == "VESymbFix" && rtb.SelectedText[0] > ' ' && rtb.SelectedText[0] <= '\xFF')
{
//use bolding underline italics from local font
System.Drawing.Font fnt = rtb.SelectionFont;