diff --git a/PROMS/Volian.Controls.Library/VlnFlexGrid.cs b/PROMS/Volian.Controls.Library/VlnFlexGrid.cs index b419a1e6..59d447f2 100644 --- a/PROMS/Volian.Controls.Library/VlnFlexGrid.cs +++ b/PROMS/Volian.Controls.Library/VlnFlexGrid.cs @@ -3470,9 +3470,94 @@ namespace Volian.Controls.Library stepText = stepText.Replace(@"\u9830?", "\xA9"); // diamond, 2666 stepText = stepText.Replace(@"\u8593?", "\x18"); // Up Arrow - changes to \xff stepText = stepText.Replace(@"\u8595?", "\x19"); // Down Arrow - changes to \xd6 + // Fix "|" followed by a newline - this confuses the table converter + stepText = stepText.Replace(@"|\r\n", @"| \r\n"); + stepText = stepText.Replace(@"|\n\r", @"| \n\r"); + stepText = stepText.Replace(@"|\n", @"| \n"); + + // if the entire row is underlined, then remove the underline and insert a row of dashes + stepText = ConvertUnderlineToRow(stepText); return stepText; } + private bool IsPrintableTableChar(char c) + { + string printablSymbols = "\xB3\xA0\x7F\xF2\xF3\xE4\xE7\xFE\x07\xF7\xF0\xFB\xE2\xE3\xE6\xEB\xE5\x90\xEE\xE9\xEC\xA8\xA9\x18\x19"; + return (((c > '\x1F') && (c < '\x80')) || (printablSymbols.IndexOf(c) >= 0)); + } + private string ConvertUnderlineToRow(string stepText) + { + string rtnStr = ""; + char[] sep = { '\n' }; + string[] lines = stepText.Split(sep); + foreach (string line in lines) + { + int idx = 0; + int chrCnt = 0; + int uOnPos = -1; + int uOffPos = -1; + bool ulineOn = false; + char curChar = line[idx]; + string dashRow = ""; + while (idx < line.Length && !IsPrintableTableChar(line[idx])) + { + if (line[idx] == '\xAB') //underline ON + { + ulineOn = true; + uOnPos = idx; + } + idx++; + } + while (ulineOn && idx < line.Length) + { + if (IsPrintableTableChar(line[idx])) + { + if (line[idx] == '|' || line[idx] == '\xB3') + { + dashRow += new string('-', chrCnt); + dashRow += "|"; + chrCnt = 0; + } + else + chrCnt++; + idx++; + } + else + { + if (line[idx] == '\xBB') //underline OFF + { + uOffPos = idx; + ulineOn = false; + while ((idx < line.Length) && !IsPrintableTableChar(line[idx])) + { + if (line[idx] == '\xAB') + ulineOn = true; + idx++; + } + if (idx == line.Length) + ulineOn = true; + if (!ulineOn) + dashRow = ""; + } + else + idx++; + } + } + string curLine = line; + curLine = curLine.Replace('\xB3', '|'); // replace graphic vert bar with DOS vert bar + if (ulineOn && idx == line.Length) // entire line is underlined, remove underline, insert row of dashes + { + curLine = curLine.Replace("\xAB", ""); // remove Underline ON + curLine = curLine.Replace("\xBB", ""); // remove Underline OFF + dashRow += new string('-', chrCnt); + dashRow = "\n" + dashRow; + } + if (rtnStr.Length > 0) rtnStr += "\n"; + rtnStr += curLine; + rtnStr += dashRow; + } + return rtnStr; + } /// /// This will parse a string containing the ascii text of the old style VE-PROMS (16-bit) tables. diff --git a/PROMS/Volian.Print.Library/vlnTab.cs b/PROMS/Volian.Print.Library/vlnTab.cs index faef9966..38ad47b6 100644 --- a/PROMS/Volian.Print.Library/vlnTab.cs +++ b/PROMS/Volian.Print.Library/vlnTab.cs @@ -112,7 +112,7 @@ namespace Volian.Print.Library } public vlnTab(PdfContentByte cb, vlnParagraph myparent, string origTab, string cleanTab, float xoffset, float yoffset, VE_Font vFont, bool doSectTab, string symblFontName, bool removedUnderline) { - //ScriptCaution = (origTab.Contains("Caution") && vFont.Family == "VolianScript"); + ScriptCaution = (origTab.Contains("Caution") && vFont.Family == "VolianScript"); MyContentByte = cb; MyParent = myparent; YOffset = yoffset; @@ -121,13 +121,13 @@ namespace Volian.Print.Library float CCCs = GetTextWidth(MyFont, "CCCCCCCCCC", symblFontName); float IIIs = GetTextWidth(MyFont, "iiiiiiiiii", symblFontName); string origTab1 = origTab; - //if (ScriptCaution) - //{ - // Text = origTab.Replace("Caution ", "\uF043\uF061\uF069\uF06E\uF06F\uF074\uF075\uF020\uF020"); - // Width = 90; - //} - //else if ((myparent.MyItemInfo.FormatStepData != null) && (myparent.MyItemInfo.FormatStepData.TabData.IdentWidth ?? 0) > 0) - if ((myparent.MyItemInfo.FormatStepData != null) && (myparent.MyItemInfo.FormatStepData.TabData.IdentWidth ?? 0) > 0) + if (ScriptCaution) + { + Text = origTab.Replace("Caution ", "\uF043\uF061\uF069\uF06E\uF06F\uF074\uF075\uF020\uF020"); + Width = 90; + } + else if ((myparent.MyItemInfo.FormatStepData != null) && (myparent.MyItemInfo.FormatStepData.TabData.IdentWidth ?? 0) > 0) + //if ((myparent.MyItemInfo.FormatStepData != null) && (myparent.MyItemInfo.FormatStepData.TabData.IdentWidth ?? 0) > 0) Width = (float)myparent.MyItemInfo.FormatStepData.TabData.IdentWidth; else if (CCCs != IIIs) {