Supporting logic to handle the use of the backslash character

This commit is contained in:
2016-06-21 15:16:12 +00:00
parent 4c6d09803d
commit 0d13585924
7 changed files with 99 additions and 8 deletions

View File

@@ -453,6 +453,7 @@ namespace Volian.Print.Library
if(Rtf2Pdf.GetTableScrunchingStatus(TableScrunching.Phase2)) // RHM20150429 - Table Scrunch
myPara.SpacingAfter = 0;// YAdjust_SpacingAfter; // RHM 20120925 - Add a line to properly space text from lines.
FixHyphens(myPara, MyTable);
FixBackslashes(myPara, MyTable);
if (Rtf2Pdf.GetTableScrunchingStatus(TableScrunching.Phase3))
TrimNewlines(myPara); // RHM20150429 - Table Scrunch
myColumnText1.AddElement(myPara);
@@ -598,6 +599,70 @@ namespace Volian.Print.Library
}
}
internal static void FixBackslashes(Paragraph myPara, vlnTable myTable)
{
// Find chunk with backslash B2014-108 backslash in tables
// If a backslash symbold is found, the remove it and add a backslash (keyboard char) to the beginning
// of the text that follows it.
int bckSlsh = -1;
Font fnt = null;
while ((bckSlsh = GetBackslash(myPara)) > -1)
{
fnt = null;
if (bckSlsh > 0)
{
Chunk chk1 = (Chunk)myPara[bckSlsh - 1];
if (bckSlsh > 1 && chk1.Content.Equals("\n"))
chk1 = (Chunk)myPara[bckSlsh - 2];
fnt = chk1.Font; // use the font of the text that follows the hyphen (dash)
}
else if (bckSlsh < myPara.Count - 1)
{
Chunk chk2 = (Chunk)myPara[bckSlsh + 1];
if (bckSlsh != 0 && !chk2.Content.Equals("\n"))
fnt = chk2.Font; // use the font of the text that follows the hyphen (dash)
}
if (fnt == null)
{
// if there was no text following the hypen, then use the font defined for tables in the plant's format
VEPROMS.CSLA.Library.VE_Font vfnt = myTable.MyFlexGrid.GetMyItemInfo().FormatStepData.Font;
System.Drawing.Font ffont = new System.Drawing.Font(vfnt.Family, (float)vfnt.Size);
fnt = Volian.Svg.Library.VolianPdf.GetFont(ffont);
fnt.SetStyle(myPara.Font.Style);
fnt.SetColor(myPara.Font.Color.R, myPara.Font.Color.G, myPara.Font.Color.B);
}
Chunk chk = (Chunk)myPara[bckSlsh];
// THIS CODE IS USED FOR DEBUGGING
//if (!fnt.Familyname.StartsWith("L"))
//{
// Console.WriteLine("font = {0}", makeitpretty(fnt));
// Console.WriteLine("Hype = {0}\r\n{1}",hype, myPara.Content);
// if (hype > 0)
// {
// Chunk chk3 = (Chunk)myPara[hype - 1];
// Console.WriteLine("before '{0}'", chk3.Content);
// }
// Chunk chk4 = (Chunk)myPara[hype];
// Console.WriteLine("during '{0}'", chk4.Content);
// if (hype < myPara.Count -1)
// {
// Chunk chk5 = (Chunk)myPara[hype + 1];
// Console.WriteLine("after '{0}'", chk5.Content);
// }
//}
string prefix = "";
if (chk.Content == "\u2572" && bckSlsh < (myPara.Count - 1))
{
myPara.RemoveAt(bckSlsh);// Remove standalone hyphen
chk = (Chunk)myPara[bckSlsh];
prefix = "\\";
}
myPara.RemoveAt(bckSlsh);
myPara.Insert(bckSlsh, new Chunk(prefix + chk.Content.Replace("\u2572", "\\"), fnt));
}
}
// THIS FUNCTION IS USED FOR DEBUGGING
private static string makeitpretty(Font fnt)
{
@@ -614,6 +679,16 @@ namespace Volian.Print.Library
index++;
return -1;
}
private static int GetBackslash(Paragraph myPara)
{
int index=0;
foreach (Chunk chk in myPara.Chunks)
if (chk.Content.Contains("\u2572"))
return index;
else
index++;
return -1;
}
public static float CalculateHangingIndent(string rtf)
{
float chkW = 0;
@@ -1056,6 +1131,7 @@ namespace Volian.Print.Library
_MyPageHelper.YMultiplier, MyPara.Content.Substring(0, Math.Min(20, MyPara.Content.Length)));
MyPara.MultipliedLeading *= _MyPageHelper.YMultiplier;
vlnCells.FixHyphens(MyPara, MyTable);
vlnCells.FixBackslashes(MyPara, MyTable);
myColumnText1.AddElement(MyPara);
foreach(object obj in MyPara)
{