diff --git a/PROMS/Volian.Print.Library/Grid2Pdf.cs b/PROMS/Volian.Print.Library/Grid2Pdf.cs index 4b65eff2..92fb48c4 100644 --- a/PROMS/Volian.Print.Library/Grid2Pdf.cs +++ b/PROMS/Volian.Print.Library/Grid2Pdf.cs @@ -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) { diff --git a/PROMS/Volian.Print.Library/PDFReport.cs b/PROMS/Volian.Print.Library/PDFReport.cs index a632d614..1a1f8da7 100644 --- a/PROMS/Volian.Print.Library/PDFReport.cs +++ b/PROMS/Volian.Print.Library/PDFReport.cs @@ -162,7 +162,7 @@ namespace Volian.Print.Library { if (NewPath[j] != "" && (foundMisMatch || OldPath.Length < j + 1 || NewPath[j] != OldPath[j])) { - sb.Append(sep + "".PadLeft(2 * level) + NewPath[j].Replace("\x11", " ")).Replace(@"\u8209?", "-"); + sb.Append(sep + "".PadLeft(2 * level) + NewPath[j].Replace("\x11", " ")).Replace(@"\u8209?", "-").Replace(@"\u9586?",@"\"); sep = "\r\n"; foundMisMatch = true; } @@ -211,7 +211,7 @@ namespace Volian.Print.Library { if (NewPath[j] != "" && (foundMisMatch || OldPath.Length < j + 1 || NewPath[j] != OldPath[j])) { - sb.Append(sep + "".PadLeft(2 * level) + NewPath[j].Replace("\x11", " ")).Replace(@"\u8209?", "-"); + sb.Append(sep + "".PadLeft(2 * level) + NewPath[j].Replace("\x11", " ")).Replace(@"\u8209?", "-").Replace(@"\u9586?", @"\"); sep = "\r\n"; foundMisMatch = true; } @@ -240,6 +240,7 @@ namespace Volian.Print.Library { headerText = headerText.Replace(@"\u8209?", "-");// repace unicode with dash char headerText = headerText.Replace(@"\u160?", " "); // replace Hard Space with normal Space + headerText = headerText.Replace(@"\u9586?", @"\"); // replace backslash symbol with a backslash PdfPCell cell = new PdfPCell(new Phrase(headerText, f2)); cell.Colspan = 2; cell.BackgroundColor = bgColor; @@ -313,7 +314,7 @@ namespace Volian.Print.Library int n = NewPath.Length; for (int j = 1; j < n && j < splitLevel; j++) { - sb.Append(sep + "".PadLeft(2 * level) + NewPath[j].Replace("\x11", " ")).Replace(@"\u8209?", "-"); + sb.Append(sep + "".PadLeft(2 * level) + NewPath[j].Replace("\x11", " ")).Replace(@"\u8209?", "-").Replace(@"\u9586?", @"\"); sep = "\r\n"; level++; } @@ -346,7 +347,7 @@ namespace Volian.Print.Library { for (int j = splitLevel; j < n; j++) { - sb.Append(sep + "".PadLeft(2 * level) + NewPath[j].Replace("\x11", " ")).Replace(@"\u8209?", "-"); + sb.Append(sep + "".PadLeft(2 * level) + NewPath[j].Replace("\x11", " ")).Replace(@"\u8209?", "-").Replace(@"\u9586?", @"\"); sep = "\r\n"; level++; } @@ -696,6 +697,7 @@ namespace Volian.Print.Library string ProcNumber = item.MyProcedure.ProcedureConfig.Number; ProcNumber = ProcNumber.Replace(@"\u8209?", "-"); // repace unicode with dash char ProcNumber = ProcNumber.Replace(@"\u160?", " "); // replace Hard Space with normal Space + ProcNumber = ProcNumber.Replace(@"\u9586?", @"\"); // replace backslash symbol with a backslash AddCell(subtable, ProcNumber, f2, TextBackgroundColor); AddCell(subtable, item.DisplayNumber + " - " + item.DisplayText, f2, TextBackgroundColor); } @@ -1068,6 +1070,7 @@ namespace Volian.Print.Library procNumTitleSect += " " + GetCurSectionNumTitle(itm); procNumTitleSect = procNumTitleSect.Replace(@"\u8209?", "-"); // repace unicode with dash char procNumTitleSect = procNumTitleSect.Replace(@"\u160?", " "); // replace Hard Space with normal Space + procNumTitleSect = procNumTitleSect.Replace(@"\u9586?", @"\"); // replace backslash symbol with a backslash PdfPCell ProcTitleCell = new PdfPCell(new Phrase(procNumTitleSect, f2)); ProcTitleCell.Colspan = 2; ProcTitleCell.HorizontalAlignment = Element.ALIGN_LEFT; diff --git a/PROMS/Volian.Print.Library/Rtf2iTextSharp.cs b/PROMS/Volian.Print.Library/Rtf2iTextSharp.cs index 7e652922..41e9b045 100644 --- a/PROMS/Volian.Print.Library/Rtf2iTextSharp.cs +++ b/PROMS/Volian.Print.Library/Rtf2iTextSharp.cs @@ -273,6 +273,10 @@ namespace Volian.Print.Library fs.AddFont(FontFactory.GetFont("Consolas", BaseFont.IDENTITY_H, BaseFont.EMBEDDED, (visualText.Format.FontSize * 1.1F) / 2, (visualText.Format.IsBold ? iTextSharp.text.Font.BOLD : 0) + (visualText.Format.IsItalic ? iTextSharp.text.Font.ITALIC : 0), font.Color)); + // added the FreeMono font because when were was a backslash symbol (\u9568?) it was not found and thus removed from the chunk B2014-108 backslash in table + fs.AddFont(FontFactory.GetFont("FreeMono", BaseFont.IDENTITY_H, BaseFont.EMBEDDED, (visualText.Format.FontSize * 1.1F) / 2, + (visualText.Format.IsBold ? iTextSharp.text.Font.BOLD : 0) + + (visualText.Format.IsItalic ? iTextSharp.text.Font.ITALIC : 0), font.Color)); Phrase ph = fs.Process(visualText.Text); foreach (Chunk chk in ph.Chunks) { diff --git a/PROMS/Volian.Print.Library/VlnSvgPageHelper.cs b/PROMS/Volian.Print.Library/VlnSvgPageHelper.cs index 54f73198..2f0b6289 100644 --- a/PROMS/Volian.Print.Library/VlnSvgPageHelper.cs +++ b/PROMS/Volian.Print.Library/VlnSvgPageHelper.cs @@ -1756,7 +1756,7 @@ namespace Volian.Print.Library ProcDescrList pdl = section.ActiveFormat.PlantFormat.FormatData.PrintData.ProcDescrList; if (pdl != null && pdl.Count > 0) { - string procnum = section.MyProcedure.MyContent.Number.Replace(@"\u8209?", "-"); + string procnum = section.MyProcedure.MyContent.Number.Replace(@"\u8209?", "-").Replace(@"\u9586?", @"\"); foreach (ProcDescr pd in pdl) { if (pd.MatchProcNumber != null) @@ -1799,7 +1799,7 @@ namespace Volian.Print.Library ProcDescrList pdl2 = section.ActiveFormat.PlantFormat.FormatData.PrintData.ProcDescrList; if (pdl2 != null && pdl2.Count > 0) { - string procnum = section.MyProcedure.MyContent.Number.Replace(@"\u8209?", "-"); + string procnum = section.MyProcedure.MyContent.Number.Replace(@"\u8209?", "-").Replace(@"\u9586?", @"\"); foreach (ProcDescr pd in pdl2) { if (pd.MatchProcNumber != null) diff --git a/PROMS/Volian.Print.Library/vlnParagraph.cs b/PROMS/Volian.Print.Library/vlnParagraph.cs index 9b7eda93..4355b816 100644 --- a/PROMS/Volian.Print.Library/vlnParagraph.cs +++ b/PROMS/Volian.Print.Library/vlnParagraph.cs @@ -3311,7 +3311,7 @@ namespace Volian.Print.Library linkInfoText.Substring(linkInfoText.Length - 16, 8), linkInfoText.Substring(linkInfoText.Length - 8, 4), linkInfoText.Substring(linkInfoText.Length - 4, 4)); - val = val.Replace(@"\u8209?", "-"); + val = val.Replace(@"\u8209?", "-").Replace(@"\u9586?", @"\"); // replace dash and backslash symbols with dash and backslash characters } else { diff --git a/PROMS/Volian.Svg.Library/DisplayText.cs b/PROMS/Volian.Svg.Library/DisplayText.cs index 47bdb311..db47d981 100644 --- a/PROMS/Volian.Svg.Library/DisplayText.cs +++ b/PROMS/Volian.Svg.Library/DisplayText.cs @@ -59,7 +59,8 @@ namespace Volian.Svg.Library // replace the dash/hyphen or whatever you want to call it, with a hard hyphen. The 16-bit program // treated the dash/hyphen as such. Translate back on any data saves. text = text.Replace(@"-", @"\u8209?"); - + // Replace the backslash with a backslash symbol. Translate back on data saves. + text = text.Replace(@"\\", @"\u9586?"); // unicode hex 2572 // displayTextElement List items are created for anything that is handled differently in RTB, i.e. // symbols, ros, trans, text. int startIndex = 0; @@ -174,6 +175,9 @@ namespace Volian.Svg.Library noExtraRtfStr = noExtraRtfStr.Replace(@"\u8209? ", @"-"); noExtraRtfStr = noExtraRtfStr.Replace(@"\u8209?", @"-"); + // change back the backslahs symbol to a regular backslash + noExtraRtfStr = noExtraRtfStr.Replace(@"\u9586?", @"\\"); + DisplayTextElementList.Clear(); int startIndex = 0; int index = -1; diff --git a/PROMS/Volian.Svg.Library/iTextSharp.cs b/PROMS/Volian.Svg.Library/iTextSharp.cs index 69e2bd2f..43dac0a4 100644 --- a/PROMS/Volian.Svg.Library/iTextSharp.cs +++ b/PROMS/Volian.Svg.Library/iTextSharp.cs @@ -681,6 +681,10 @@ namespace Volian.Svg.Library // this will enable the hyphens to be found in a PDF search if(text.Contains("\\u8209?")) text = text.Replace("\\u8209?", "-"); + // Replace symbol backslash with a text backslash when printing pagelist items + // this will enable the backslash to be found in a PDF search + if (text.Contains("\\u9586?")) + text = text.Replace("\\u9586?", "\\"); SetupInheritance(myParent.MyInheritedSettings); float yScale = (myParent is SvgGroup && (myParent as SvgGroup).Description.ToUpper() == "ABSOLUTE") ? scale.AbsY(cb, Y): scale.Y(cb, Y); cb.SaveState();