From f67d37801abad3786a9a2756b0c2049db9cf9209 Mon Sep 17 00:00:00 2001 From: mschill Date: Fri, 24 Jul 2026 13:36:46 -0400 Subject: [PATCH] Print Library, Svg Library, Utils Library, XYPlots --- .../DlgPrintProcedure.cs | 2 +- PROMS/VEPROMS User Interface/frmVEPROMS.cs | 4 +- PROMS/Volian.Print.Library/CPSGen.cs | 42 +- PROMS/Volian.Print.Library/CompleteRORpt.cs | 511 +- PROMS/Volian.Print.Library/ContActionSum.cs | 56 +- .../GlobalSuppressions.cs | 8 + PROMS/Volian.Print.Library/Grid2Pdf.cs | 733 +- PROMS/Volian.Print.Library/MergedPdf.cs | 86 +- .../PDFChronologyReport.cs | 1646 +- .../PDFConsistencyCheckReport.cs | 365 +- PROMS/Volian.Print.Library/PDFPageSize.cs | 15 +- PROMS/Volian.Print.Library/PDFReport.cs | 3971 +++-- .../PDFTransitionReport.cs | 409 +- PROMS/Volian.Print.Library/PageCount.cs | 81 +- PROMS/Volian.Print.Library/Pagination.cs | 391 +- PROMS/Volian.Print.Library/Placekeeper.cs | 73 +- PROMS/Volian.Print.Library/PromsPrinter.cs | 1223 +- PROMS/Volian.Print.Library/Rtf2Pdf.cs | 160 +- PROMS/Volian.Print.Library/Rtf2iTextSharp.cs | 233 +- .../Volian.Print.Library/VlnSvgPageHelper.cs | 1005 +- .../Volian.Print.Library.csproj | 1 + PROMS/Volian.Print.Library/pdf.cs | 71 +- PROMS/Volian.Print.Library/pkParagraph.cs | 25 +- PROMS/Volian.Print.Library/vlnBox.cs | 196 +- PROMS/Volian.Print.Library/vlnChangeBar.cs | 103 +- PROMS/Volian.Print.Library/vlnHeader.cs | 14 +- PROMS/Volian.Print.Library/vlnMacro.cs | 20 +- PROMS/Volian.Print.Library/vlnParagraph.cs | 14139 ++++++++-------- PROMS/Volian.Print.Library/vlnPrintObject.cs | 246 +- PROMS/Volian.Print.Library/vlnRNOSeparator.cs | 39 +- PROMS/Volian.Print.Library/vlnTab.cs | 91 +- PROMS/Volian.Print.Library/vlnText.cs | 25 +- PROMS/Volian.Svg.Library/FontFind.cs | 30 - PROMS/Volian.Svg.Library/Graphics.cs | 35 +- PROMS/Volian.Svg.Library/Svg.cs | 82 +- PROMS/Volian.Svg.Library/SvgArc.cs | 66 +- PROMS/Volian.Svg.Library/SvgCircle.cs | 64 +- PROMS/Volian.Svg.Library/SvgDefine.cs | 7 - PROMS/Volian.Svg.Library/SvgEllipse.cs | 82 +- PROMS/Volian.Svg.Library/SvgFillSettings.cs | 59 +- PROMS/Volian.Svg.Library/SvgFontSettings.cs | 48 +- PROMS/Volian.Svg.Library/SvgGroup.cs | 93 +- PROMS/Volian.Svg.Library/SvgImage.cs | 104 +- .../SvgInheritedSettings.cs | 75 +- PROMS/Volian.Svg.Library/SvgLine.cs | 152 +- PROMS/Volian.Svg.Library/SvgLinePart.cs | 16 +- PROMS/Volian.Svg.Library/SvgLineSettings.cs | 101 +- PROMS/Volian.Svg.Library/SvgMeasurement.cs | 142 +- PROMS/Volian.Svg.Library/SvgPart.cs | 25 - .../Volian.Svg.Library/SvgPartInheritance.cs | 21 +- PROMS/Volian.Svg.Library/SvgParts.cs | 205 +- PROMS/Volian.Svg.Library/SvgRectangle.cs | 97 +- PROMS/Volian.Svg.Library/SvgScale.cs | 106 +- PROMS/Volian.Svg.Library/SvgSerializer.cs | 9 +- PROMS/Volian.Svg.Library/SvgShapePart.cs | 2 - PROMS/Volian.Svg.Library/SvgTest.cs | 3 - PROMS/Volian.Svg.Library/SvgText.cs | 73 +- PROMS/Volian.Svg.Library/SvgUse.cs | 112 +- PROMS/Volian.Svg.Library/SvgViewBox.cs | 49 +- PROMS/Volian.Svg.Library/SvgXMLConverter.cs | 11 +- .../Volian.Svg.Library.csproj | 1 - PROMS/Volian.Svg.Library/iTextSharp.cs | 523 +- PROMS/Volian.Utils.Library/MSWord/WordDoc.cs | 110 +- .../vlnObject/vlnObject.cs | 38 +- .../vlnServerLibrary/vlnServer.cs | 30 +- .../W2PGrid.csproj.AssemblyReference.cache | Bin 7842 -> 7811 bytes PROMS/XYPlots/XYPlots.cs | 227 +- PROMS/XYPlots/frmXYPlot.cs | 9 - 68 files changed, 12173 insertions(+), 16618 deletions(-) create mode 100644 PROMS/Volian.Print.Library/GlobalSuppressions.cs delete mode 100644 PROMS/Volian.Svg.Library/FontFind.cs diff --git a/PROMS/VEPROMS User Interface/DlgPrintProcedure.cs b/PROMS/VEPROMS User Interface/DlgPrintProcedure.cs index a4f04f9b..2f5bec82 100644 --- a/PROMS/VEPROMS User Interface/DlgPrintProcedure.cs +++ b/PROMS/VEPROMS User Interface/DlgPrintProcedure.cs @@ -1395,7 +1395,7 @@ namespace VEPROMS DoCreatePDF(); // create indivitual pdfs if (_MergedPdfPath != null && _MergedPdfPath != PDFPath) PDFPath = _MergedPfd.Folder = _MergedPdfPath; // C2021-063 pass in whether to generate Alarm Point List text when a merge is done - if (!_MergedPfd.DoTheMerge(PromsPrinter.MergedLandscapePages,cbxAlmPtTxt.Checked)) return; // merge them together. + if (!_MergedPfd.DoTheMerge(cbxAlmPtTxt.Checked)) return; // merge them together. // if the property to show the file after printing is set (on the version dialog), display it. Otherwise do a dialog to let user know it's done if (_DocVersionConfig.Print_MergedPdfsViewAfter) { diff --git a/PROMS/VEPROMS User Interface/frmVEPROMS.cs b/PROMS/VEPROMS User Interface/frmVEPROMS.cs index d9ce5f40..439e9bb7 100644 --- a/PROMS/VEPROMS User Interface/frmVEPROMS.cs +++ b/PROMS/VEPROMS User Interface/frmVEPROMS.cs @@ -1001,7 +1001,7 @@ namespace VEPROMS fs.Close(); System.Diagnostics.Process.Start(fileName); } - catch (Exception ex) + catch (Exception) { StringBuilder sb = new StringBuilder(); @@ -1767,7 +1767,7 @@ namespace VEPROMS } else if (args.TypesSelected == "Complete RO Report") { - Volian.Print.Library.PDFReport myReport = new Volian.Print.Library.PDFReport(args.ReportTitle, args.RODataFile, Volian.Base.Library.VlnSettings.TemporaryFolder + @"\CompleteROReport.pdf", args.RofstLookup, args.CompleteROReport, args.ConvertCaretToDelta, args.IncludeEmptyROFields, args.PaperSize); + Volian.Print.Library.PDFReport myReport = new Volian.Print.Library.PDFReport(args.ReportTitle, args.RODataFile, Volian.Base.Library.VlnSettings.TemporaryFolder + @"\CompleteROReport.pdf", args.RofstLookup, args.ConvertCaretToDelta, args.IncludeEmptyROFields, args.PaperSize); myReport.Build(); } else if (args.TypesSelected == "RO Summary Report") diff --git a/PROMS/Volian.Print.Library/CPSGen.cs b/PROMS/Volian.Print.Library/CPSGen.cs index 3aa6491c..b0d12e3c 100644 --- a/PROMS/Volian.Print.Library/CPSGen.cs +++ b/PROMS/Volian.Print.Library/CPSGen.cs @@ -1,22 +1,14 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Xml; +using System.Xml; using VEPROMS.CSLA.Library; namespace Volian.Print.Library { public class CPSGen { - private vlnParagraph _MyVlnParagraph; - public vlnParagraph MyVlnParagraph + public vlnParagraph MyVlnParagraph { get; set; } + public CPSGen(vlnParagraph myParagraph) { - get { return _MyVlnParagraph; } - set { _MyVlnParagraph = value; } - } - public CPSGen(vlnParagraph myParagraph) - { - _MyVlnParagraph = myParagraph; + MyVlnParagraph = myParagraph; } public void Generate(string fileName) { @@ -33,7 +25,6 @@ namespace Volian.Print.Library AddAttribute(xe, "FromType", fromType); AddAttribute(xe, "Ordinal", itm.Ordinal); AddAttribute(xe, "ParentID", (itm.ActiveParent as ItemInfo).ItemID); - //AddAttribute(xe, "Xoffset", para.XOffset); AddAttribute(xe, "ItemID", itm.ItemID); AddAttribute(xe, "PreviousID", itm.PreviousID); AddAttribute(xe, "ContentID", itm.ContentID); @@ -45,41 +36,20 @@ namespace Volian.Print.Library AddAttribute(xe, "FormatID", itm.MyContent.FormatID); AddAttribute(xe, "Config", itm.MyContent.Config); AddAttribute(xe, "Rtf", para.Rtf); - //AddParts(xe, "PartsAbove", para.PartsAbove); - //AddParts(xe, "PartsLeft", para.PartsLeft); - //AddParts(xe, "PartsRight", para.PartsRight); - //AddParts(xe, "PartsBelow", para.PartsBelow); AddChildren(level,0, parent, "ChildrenAbove", para.ChildrenAbove); AddChildren(level,0, parent, "ChildrenLeft", para.ChildrenLeft); AddChildren(level,0, parent, "ChildrenRight", para.ChildrenRight); AddChildren(level,0, parent, "ChildrenBelow", para.ChildrenBelow); } - private void AddChildren(int level, int fromType, XmlElement parent, string name, vlnParagraphs children) + [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0060:Remove unused parameter", Justification = "Keeping fromType and name for Debugging")] + private void AddChildren(int level, int fromType, XmlElement parent, string name, vlnParagraphs children) { if (children == null || children.Count == 0) return; - //XmlElement xchildren = xe.OwnerDocument.AppendChild(xe.OwnerDocument.CreateElement(name)) as XmlElement; foreach(vlnParagraph child in children) { - //XmlElement xechild = xe.ParentNode.AppendChild(xe.OwnerDocument.CreateElement("Item")) as XmlElement; Generate(level+1,0,parent,child); } } - //private void AddParts(XmlElement xe, string name, vlnPrintObjects parts) - //{ - // if (parts == null || parts.Count == 0) return; - // XmlElement xpart = xe.AppendChild(xe.OwnerDocument.CreateElement(name)) as XmlElement; - // foreach (vlnPrintObject part in parts) - // { - // XmlElement xechild = xpart.AppendChild(xe.OwnerDocument.CreateElement(part.GetType().Name)) as XmlElement; - // Generate(xechild, part); - // } - //} - //private void Generate(XmlElement xe, vlnPrintObject part) - //{ - // AddAttribute(xe, "Xoffset", part.XOffset); - // AddAttribute(xe, "Width", part.Width); - // AddAttribute(xe, "Rtf", part.Rtf); - //} private void AddAttribute(XmlElement xe, string attr, object val) { if (val == null) return; diff --git a/PROMS/Volian.Print.Library/CompleteRORpt.cs b/PROMS/Volian.Print.Library/CompleteRORpt.cs index f43a37e1..91e0f123 100644 --- a/PROMS/Volian.Print.Library/CompleteRORpt.cs +++ b/PROMS/Volian.Print.Library/CompleteRORpt.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Text; using System.Text.RegularExpressions; using System.IO; using System.Windows.Forms; @@ -16,93 +15,54 @@ namespace Volian.Print.Library class CompleteROReport { private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); - //Dictionary _MyErrorBookMarks = new Dictionary(); - Headers Hdrs; // Header stack object. + readonly Headers Hdrs; // Header stack object. RODataFile RO_df = null; int curheaderlen; - string RODataFileName; - iTextSharp.text.Document _pdfReportDoc = null; + readonly string RODataFileName; + readonly iTextSharp.text.Document _pdfReportDoc; PdfPTable datatable = null; - private iTextSharp.text.Font _f14; // = pdf.GetFont("Arial Unicode MS", 14, 1, Color.BLACK); + public iTextSharp.text.Font F14 { get; set; } - public iTextSharp.text.Font F14 - { - get { return _f14; } - set { _f14 = value; } - } - private iTextSharp.text.Font _f10; + public iTextSharp.text.Font F10 { get; set; } - public iTextSharp.text.Font F10 - { - get { return _f10; } - set { _f10 = value; } - } - private iTextSharp.text.Font _f12; + public iTextSharp.text.Font F12 { get; set; } - public iTextSharp.text.Font F12 - { - get { return _f12; } - set { _f12 = value; } - } - private iTextSharp.text.Font _f10Bold; + public iTextSharp.text.Font F10Bold { get; set; } - public iTextSharp.text.Font F10Bold - { - get { return _f10Bold; } - set { _f10Bold = value; } - } - private iTextSharp.text.Font _f12Bold; + public iTextSharp.text.Font F12Bold { get; set; } - public iTextSharp.text.Font F12Bold - { - get { return _f12Bold; } - set { _f12Bold = value; } - } + public bool ConvertCaretToDelta { get; set; } = true; - private bool _ConvertCaretToDelta = true; + public bool IncludeEmptyROFields { get; set; } = false; - public bool ConvertCaretToDelta - { - get { return _ConvertCaretToDelta; } - set { _ConvertCaretToDelta = value; } - } - private bool _IncludeEmptyROFields = false; - - public bool IncludeEmptyROFields - { - get { return _IncludeEmptyROFields; } - set { _IncludeEmptyROFields = value; } - } - private int _ROFstID; - - public int ROFstID - { - get { return _ROFstID; } - set { _ROFstID = value; } - } - private string ReportTitle = "Complete Referenced Objects Report"; - private PdfWriter _MyPDFWriter; + public int ROFstID { get; set; } + private readonly string ReportTitle = "Complete Referenced Objects Report"; + private readonly PdfWriter _MyPDFWriter; public CompleteROReport(PdfWriter mypdfwriter, iTextSharp.text.Document document, string dataFileName, bool convertCaretToDelta, bool includeEmptyROFields) { Hdrs = new Headers(); _pdfReportDoc = document; RODataFileName = dataFileName; - _ConvertCaretToDelta = convertCaretToDelta; + ConvertCaretToDelta = convertCaretToDelta; _MyPDFWriter = mypdfwriter; - _IncludeEmptyROFields = includeEmptyROFields; + IncludeEmptyROFields = includeEmptyROFields; } public void StartNewDataTable() { - datatable = new PdfPTable(1); - datatable.TotalWidth = _pdfReportDoc.PageSize.Width - _pdfReportDoc.LeftMargin - _pdfReportDoc.RightMargin; - datatable.LockedWidth = true; - PdfPCell cell = new PdfPCell(new Phrase(ReportTitle, F14)); - cell.HorizontalAlignment = Element.ALIGN_CENTER; - cell.BackgroundColor = Color.WHITE; - cell.BorderColor = Color.WHITE; - datatable.AddCell(cell); + datatable = new PdfPTable(1) + { + TotalWidth = _pdfReportDoc.PageSize.Width - _pdfReportDoc.LeftMargin - _pdfReportDoc.RightMargin, + LockedWidth = true + }; + PdfPCell cell = new PdfPCell(new Phrase(ReportTitle, F14)) + { + HorizontalAlignment = Element.ALIGN_CENTER, + BackgroundColor = Color.WHITE, + BorderColor = Color.WHITE + }; + datatable.AddCell(cell); datatable.HeaderRows = 3; datatable.DefaultCell.HorizontalAlignment = Element.ALIGN_LEFT; } @@ -113,33 +73,17 @@ namespace Volian.Print.Library PrintReport(); RO_df.close(); } - private Dictionary _MyDocOutline = new Dictionary(); - internal Dictionary MyDocOutline + internal Dictionary MyDocOutline { get; set; } = new Dictionary(); + public class DocOutline { - get { return _MyDocOutline; } - set { _MyDocOutline = value; } - } - public class DocOutline - { - private PdfOutline _MyOutline; + public PdfOutline MyOutline { get; set; } - public PdfOutline MyOutline + public string MyHeader { get; set; } + public DocOutline(PdfOutline outline, string header) { - get { return _MyOutline; } - set { _MyOutline = value; } - } - private string _MyHeader; - - public string MyHeader - { - get { return _MyHeader; } - set { _MyHeader = value; } - } - public DocOutline(PdfOutline outline, string header) - { - _MyHeader = header; - _MyOutline = outline; + MyHeader = header; + MyOutline = outline; } } private string ReplaceLineDrawCharsWithUnicode(string text) @@ -167,7 +111,6 @@ namespace Volian.Print.Library instr = instr.Replace("[RHO]", "\u03C1"); // C2016-018 rho symbol - is being read in as a line draw character, so users need to put "[RHO]" in their text for the rho symbol to print if (ConvertCaretToDelta) { - //char[] ca = instr.ToCharArray(); // for debug instr = instr.Replace("^", "\u0394"); // delta } //instr = instr.Replace("\x94", "\u0394"); // delta - the delta symbol is being read in as character x94 @@ -188,7 +131,7 @@ namespace Volian.Print.Library { string tstr = (instr.Substring(idx+uidx, m1.Index - uidx)); if (tstr.EndsWith(" ")) - tstr = tstr.Substring(0, tstr.Length - 1) + "\xA0"; + tstr = $"{tstr.Substring(0, tstr.Length - 1)}\xA0"; chk = new Chunk(tstr, fnt); if (underlineChunk) chk.SetUnderline(Color.BLACK, 0, 0.05F, 0, -.131F, PdfContentByte.LINE_CAP_ROUND); @@ -244,7 +187,7 @@ namespace Volian.Print.Library { string tstr = (strChk.Substring(uidx, m1.Index - uidx)); if (tstr.EndsWith(" ")) - tstr = tstr.Substring(0, tstr.Length - 1) + "\xA0"; + tstr = $"{tstr.Substring(0, tstr.Length - 1)}\xA0"; chk = new Chunk(tstr, fnt); if (underlineChunk) chk.SetUnderline(Color.BLACK, 0, 0.05F, 0, -.131F, PdfContentByte.LINE_CAP_ROUND); @@ -264,7 +207,7 @@ namespace Volian.Print.Library { string tstr = strChk.Substring(uidx); if (tstr.EndsWith(" ")) - tstr = tstr.Substring(0, tstr.Length - 1) + "\xA0"; + tstr = $"{tstr.Substring(0, tstr.Length - 1)}\xA0"; chk = new Chunk(tstr, fnt); if (underlineChunk) chk.SetUnderline(Color.BLACK, 0, 0.05F, 0, -.131F, PdfContentByte.LINE_CAP_ROUND); @@ -276,12 +219,9 @@ namespace Volian.Print.Library return p; } - public void AddText(string txt, Font fnt) - { - AddText(txt, fnt, Color.BLACK); - } - - public void AddText(string txt, Font fnt, Color txtcolor) + public void AddText(string txt, Font fnt) => AddText(txt, fnt, Color.BLACK); + + public void AddText(string txt, Font fnt, Color txtcolor) { // break the text up on double returns (paragraphs) and put each in their own cell // this will allow for page breaks between paragraphs0 @@ -289,11 +229,15 @@ namespace Volian.Print.Library string[] strlst = txt.Split(delim,StringSplitOptions.None); foreach (string str in strlst) { - Font f = new Font(fnt); - f.Color = txtcolor; - PdfPCell cell = new PdfPCell(ConvertDOSSuperAndSubScripts(str, f)); - cell.BorderColor = Color.WHITE; - if (strlst.Length > 1) + Font f = new Font(fnt) + { + Color = txtcolor + }; + PdfPCell cell = new PdfPCell(ConvertDOSSuperAndSubScripts(str, f)) + { + BorderColor = Color.WHITE + }; + if (strlst.Length > 1) cell.PaddingBottom = 6; datatable.AddCell(cell); } @@ -301,11 +245,12 @@ namespace Volian.Print.Library public void AddImage(string filename) { - ROImageInfo roImage = ROImageInfo.GetByROFstID_FileName(_ROFstID, filename); - if (roImage == null) roImage = ROFstInfo.Get(_ROFstID).GetROImageByFilename(filename, null); - PdfPCell spaceCell = new PdfPCell(); - spaceCell.BorderColor = Color.WHITE; - datatable.AddCell(spaceCell); + ROImageInfo roImage = ROImageInfo.GetByROFstID_FileName(ROFstID, filename) ?? ROFstInfo.Get(ROFstID).GetROImageByFilename(filename, null); + PdfPCell spaceCell = new PdfPCell + { + BorderColor = Color.WHITE + }; + datatable.AddCell(spaceCell); if (roImage != null) { ROImageConfig rc = new ROImageConfig(roImage); @@ -318,8 +263,8 @@ namespace Volian.Print.Library it_image = iTextSharp.text.Image.GetInstance(dcnt); //iTextSharp.text.Image it_image = iTextSharp.text.Image.GetInstance(ROImageInfo.Decompress(roImage.Content, size)); } - catch (Exception ex) - { + catch (Exception) + { try { MemoryStream ms = new MemoryStream(dcnt); @@ -342,9 +287,11 @@ namespace Volian.Print.Library } } it_image.ScaleToFit(_MyPDFWriter.DirectContent.PdfDocument.PageSize.Width - 144, _MyPDFWriter.DirectContent.PdfDocument.PageSize.Height - 216); - PdfPCell cell = new PdfPCell(it_image); - cell.BorderColor = Color.WHITE; - datatable.AddCell(cell); + PdfPCell cell = new PdfPCell(it_image) + { + BorderColor = Color.WHITE + }; + datatable.AddCell(cell); roImage.Dispose(); } else @@ -364,17 +311,21 @@ namespace Volian.Print.Library if (ConvertCaretToDelta) plotlang = plotlang.Replace("^", "\x394"); // delta plotlang = plotlang.Replace("\x7F", "\x394"); //delta - PdfPCell spaceCell = new PdfPCell(); - spaceCell.BorderColor = Color.WHITE; - datatable.AddCell(spaceCell); + PdfPCell spaceCell = new PdfPCell + { + BorderColor = Color.WHITE + }; + datatable.AddCell(spaceCell); try { System.Drawing.RectangleF plotRect = MSWordToPDF.CreatePlot(pngFile, plotlang, 600F, MSWordToPDF.FormForPlotGraphics); iTextSharp.text.Image it_image = iTextSharp.text.Image.GetInstance(pngFile); it_image.ScaleToFit(_MyPDFWriter.DirectContent.PdfDocument.PageSize.Width - 144, _MyPDFWriter.DirectContent.PdfDocument.PageSize.Height - 216); - PdfPCell cell = new PdfPCell(it_image); - cell.BorderColor = Color.WHITE; - datatable.AddCell(cell); + PdfPCell cell = new PdfPCell(it_image) + { + BorderColor = Color.WHITE + }; + datatable.AddCell(cell); } catch (Exception e) { @@ -386,94 +337,88 @@ namespace Volian.Print.Library } private string processingRO = ""; - private string _MyROID = null; - public string MyROID - { - get { return _MyROID; } - set { _MyROID = value; } - } - public void PrintReport() + public string MyROID { get; set; } = null; + + public void PrintReport() { bool StopPrinting = false; - bool UserTerminate = false; - Int16 iRecType = 0; - VlnStatusBar showStatBar = new VlnStatusBar("Complete RO Report"); - try + VlnStatusBar showStatBar = new VlnStatusBar("Complete RO Report"); + try { if (RO_df.GetFileLength() > 0) { showStatBar.BarMax = (int)RO_df.GetFileLength(); showStatBar.StatMsg = "Creating Report"; - // Loop until either printing is aborted or end of file. - while (!StopPrinting && (iRecType = RO_df.ReadInteger16()) != -1) - { - //Console.WriteLine("Record Type: {0}.{0:X}", iRecType); - switch (iRecType) - { - case 1: // Set Header - SetHeader(); - break; - case 2: // Push Header - PushHeader(); - break; - case 3: // Pop Header - PopHeader(); - break; - case 4: // RRO Begin - RROBegin(); - break; - case 5: // RRO End - RROEnd(); - processingRO = ""; - break; - case 6: // Msg - Msg(); - break; - case 7: - processingRO = KeyField(); - break; - case 8: - MyROID = ROIDField(); - break; - case 100: // Text Field - sometimes also XY Plot - Text(); - Application.DoEvents(); - break; - case 101: // Plot Field - XYPlot(); - Application.DoEvents(); - break; - case 102: // Image Field - ImageFile(); - Application.DoEvents(); - break; - case 103: // Multi Begin - Display data for setpoints - Multiple(); - break; - case 104: // Multi End - break; - case 0: // nothing was entered in that field - if (_IncludeEmptyROFields) - NoInformatEntered(); - break; - case 255: - _pdfReportDoc.Add(datatable); - _pdfReportDoc.NewPage(); - StartNewDataTable(); - showStatBar.BarValue = (int)RO_df.GetFilePointerPosition(); - //Console.WriteLine("Record Type: {0} No Operation", iRecType); - //Console.WriteLine("----------------------------------------------"); - break; - default: // Problem - //Console.WriteLine("Record Type: {0} Unrecognized record type", iRecType); - StopPrinting = true; - UserTerminate = true; - MessageBox.Show(string.Format("Unrecognized record type [{0}]", iRecType), "Error Creating Complete RO Report", MessageBoxButtons.OK, MessageBoxIcon.Error); - break; - }; - } - } + short iRecType; + // Loop until either printing is aborted or end of file. + while (!StopPrinting && (iRecType = RO_df.ReadInteger16()) != -1) + { + //Console.WriteLine("Record Type: {0}.{0:X}", iRecType); + switch (iRecType) + { + case 1: // Set Header + SetHeader(); + break; + case 2: // Push Header + PushHeader(); + break; + case 3: // Pop Header + PopHeader(); + break; + case 4: // RRO Begin + RROBegin(); + break; + case 5: // RRO End + RROEnd(); + processingRO = ""; + break; + case 6: // Msg + Msg(); + break; + case 7: + processingRO = KeyField(); + break; + case 8: + MyROID = ROIDField(); + break; + case 100: // Text Field - sometimes also XY Plot + Text(); + Application.DoEvents(); + break; + case 101: // Plot Field + XYPlot(); + Application.DoEvents(); + break; + case 102: // Image Field + ImageFile(); + Application.DoEvents(); + break; + case 103: // Multi Begin - Display data for setpoints + Multiple(); + break; + case 104: // Multi End + break; + case 0: // nothing was entered in that field + if (IncludeEmptyROFields) + NoInformatEntered(); + break; + case 255: + _pdfReportDoc.Add(datatable); + _pdfReportDoc.NewPage(); + StartNewDataTable(); + showStatBar.BarValue = (int)RO_df.GetFilePointerPosition(); + //Console.WriteLine("Record Type: {0} No Operation", iRecType); + //Console.WriteLine("----------------------------------------------"); + break; + default: // Problem + StopPrinting = true; + MessageBox.Show(string.Format("Unrecognized record type [{0}]", iRecType), "Error Creating Complete RO Report", MessageBoxButtons.OK, MessageBoxIcon.Error); + break; + } + ; + } + } else { StartNewDataTable(); @@ -502,20 +447,22 @@ namespace Volian.Print.Library // if there is lenght then we are in the mist of processing an RO string headers = erMsg; for (int iLoop = 0; iLoop < Hdrs.HdrCnt; iLoop++) - headers += Hdrs.strHdrs[iLoop] + "\n "; + headers += $"{Hdrs.strHdrs[iLoop]}\n "; if (processingRO.Length > 0) headers += processingRO; if (erMsg2 != null && erMsg2.Length > 0) headers += "\n" + erMsg2; - //MessageBox.Show(headers, erMsg, MessageBoxButtons.OK, MessageBoxIcon.Error); if (e != null) _MyLog.Error(headers, e); else _MyLog.Error(headers); - PdfOutline outl = new PdfOutline(MyErrorOutline, MyPdfDestPage, processingRO.Length > 0 ? processingRO : "Problem Reading Header"); - //DestSample(outl); - } +#pragma warning disable IDE0059 // Unnecessary assignment of a value - for debugging + PdfOutline outl = new PdfOutline(MyErrorOutline, MyPdfDestPage, processingRO.Length > 0 ? processingRO : "Problem Reading Header"); +#pragma warning restore IDE0059 // Unnecessary assignment of a value + //DestSample(outl); + } + //For Debugging/Testing //private void DestSample(PdfOutline outl) //{ // new PdfOutline(outl, new PdfDestination(PdfDestination.FIT), "FIT"); @@ -531,29 +478,22 @@ namespace Volian.Print.Library public void AddErrorBookmarks() { if (_MyErrorOutline == null) return; - //if (_MyErrorBookMarks.Count == 0) return; - //PdfOutline outline = null; - //foreach (string key in _MyErrorBookMarks.Keys) - //{ - // if (outline == null) outline = new PdfOutline(_MyPDFWriter.DirectContent.RootOutline, _MyErrorBookMarks[key], "Errors"); - // new PdfOutline(outline, _MyErrorBookMarks[key], key); - //} string emsg = "A Bookmark grouping named \"Errors\" was added to the PDF.\n\n Click on the RO in this grouping to jump to the report page which will contain an error message.\n\nThe error were also recorded in the PROMS error log."; MessageBox.Show(emsg, "Errors Found Creating Report", MessageBoxButtons.OK, MessageBoxIcon.Information); } public void Multiple() { - Int16 typ, i, j, nw = 0; + short typ, i, j; string str, sep; string buff = ""; int[] width; LastHeader(); sep = ""; - // nw - number of fields - nw = RO_df.ReadInteger16(); - // allocate space for widths - width = new int[nw]; + // nw - number of fields + short nw = RO_df.ReadInteger16(); + // allocate space for widths + width = new int[nw]; // loop through and load field widths and names for (i = 0; i < nw; i++) { @@ -645,7 +585,7 @@ namespace Volian.Print.Library //Console.WriteLine("Set Header"); // Get the number of header records - Int16 iNewCnt = RO_df.ReadInteger16(); + short iNewCnt = RO_df.ReadInteger16(); //Console.WriteLine("Num Header Records: {0}", iNewCnt); @@ -676,16 +616,11 @@ namespace Volian.Print.Library bool _LastWasName = false;//B2016-251 Don't change underscore to underline to Name value public void PushHeader() { - //if (m_pPrinterOut->Row() > 55) - //// m_pPrinterOut->newpage(); - //pdfReportDoc.NewPage(); string pTmp = RO_df.ReadText(); //Console.WriteLine("PH[{0}]", pTmp); curheaderlen = pTmp.Length; _LastWasName = (pTmp == "Name");//B2016-251 Don't change underscore to underline to Name value - //Hdrs.strHdrs[Hdrs.HdrCnt] = pTmp; Hdrs.strHdrs.Add(pTmp); - //Hdrs.repeatCount[Hdrs.HdrCnt] = 2; Hdrs.repeatCount.Add(2); Hdrs.HdrCnt++; Hdrs.printedLastHeader = false; @@ -704,15 +639,12 @@ namespace Volian.Print.Library // if the last header was pushed on header list // print eject the page if the page ran out, and // print the header with "none". - //if (m_pPrinterOut->Row() > 55) - // m_pPrinterOut->NewPage(); LastHeader(); //m_pPrinterOut->PutLine(0, "none"); //m_pPrinterOut->NewLine(1); } // Remove the header Hdrs.HdrCnt--; - //Hdrs.strHdrs[Hdrs.HdrCnt] = null; Hdrs.strHdrs.RemoveAt(Hdrs.HdrCnt); Hdrs.repeatCount.RemoveAt(Hdrs.HdrCnt); @@ -722,7 +654,6 @@ namespace Volian.Print.Library public void RROBegin() { - //m_pPrinterOut->NewPage(); //Console.WriteLine("RRO Begin"); //Console.WriteLine("----------------------------------------------"); // Start of a new RO, print out the headers @@ -730,12 +661,11 @@ namespace Volian.Print.Library { if (!MyDocOutline.ContainsKey(iLoop) || MyDocOutline[iLoop].MyHeader != Hdrs.strHdrs[iLoop]) { - PdfOutline parentOutline = null; - if (iLoop == 0) + PdfOutline parentOutline; + if (iLoop == 0) parentOutline = MyRootOutline;//_MyPDFWriter.DirectContent.RootOutline; else parentOutline = MyDocOutline[iLoop - 1].MyOutline; - //pdfDest = new PdfDestination(PdfDestination.FITH, _MyPDFWriter.DirectContent.PdfDocument.PageSize.Height); AddOutlineLevel(parentOutline, iLoop, Hdrs.strHdrs[iLoop], MyPdfDestPage); } // Change double underscore to spaces in header text @@ -748,20 +678,13 @@ namespace Volian.Print.Library { // FITH was acting strange and shifting towards bottom of the page as the number of pages increased //Console.WriteLine("Top = {0}, {1}", _Top, _MyPDFWriter.DirectContent.PdfDocument.PageSize.Height); - //return new PdfDestination(PdfDestination.FITH, _Top);//_MyPDFWriter.DirectContent.PdfDocument.PageSize.Height); return new PdfDestination(PdfDestination.XYZ, 0, _MyPDFWriter.DirectContent.PdfDocument.PageSize.Height, 1.5f); } } - public PdfDestination MyPdfDestPage - { - get - { - return new PdfDestination(PdfDestination.FITV,0); - } - } + public PdfDestination MyPdfDestPage => new PdfDestination(PdfDestination.FITV, 0); - private PdfOutline _MyErrorOutline = null; + private PdfOutline _MyErrorOutline = null; public PdfOutline MyErrorOutline { @@ -787,7 +710,6 @@ namespace Volian.Print.Library return _MyRootOutline; } } - private PdfDestination pdfDest = null; private void AddOutlineLevel(PdfOutline parentOutline, int iLoop, string hdr, PdfDestination pdfDest) { if (MyDocOutline.ContainsKey(iLoop)) @@ -798,7 +720,6 @@ namespace Volian.Print.Library public void RROEnd() { - //m_pPrinterOut->PageEnd(); // Remove any headers that are left over //Console.WriteLine("{0} headers cleaned up.", Hdrs.HdrCnt); //Console.WriteLine("RRO End"); @@ -843,7 +764,7 @@ namespace Volian.Print.Library public void Text() { // Get the lenght of the text string and read it in - Int16 iValue = RO_df.ReadInteger16(); + short iValue = RO_df.ReadInteger16(); string szStr = ""; // B2016-247 If size is zero it is an empty string. if (iValue > 0) @@ -867,11 +788,9 @@ namespace Volian.Print.Library if (isXYPlot || (iValue + curheaderlen) > 72 || (szStr.IndexOf('\r') != -1)) { - // If the lenght of the string plus the field title is greater + // If the length of the string plus the field title is greater // than 72 characters or has a carriage return character in it // then output the text on multiple lines - //if (m_pPrinterOut->Row() > 55) - // m_pPrinterOut->newpage(); // the header goes on its own line cell.AddElement(p); @@ -891,10 +810,6 @@ namespace Volian.Print.Library datatable.AddCell(cell); //m_pPrinterOut->SetNumberOfNewLines(0); //m_pPrinterOut->putline(0, temp); - //if (m_pPrinterOut->Row() + 1 > 55) - // Hdrs.repeatCount[Hdrs.HdrCnt] = 1; - //else - // m_pPrinterOut->newline(1); } //Console.WriteLine("Text"); //Console.WriteLine("Value: {0}", iValue); @@ -906,10 +821,11 @@ namespace Volian.Print.Library { // use the key field as the PDF bookbark string szStr = RO_df.ReadText(); - //PdfDestination pdfDest = new PdfDestination(PdfDestination.FITH, _MyPDFWriter.DirectContent.PdfDocument.PageSize.Height); - PdfOutline outl = new PdfOutline(MyDocOutline[Hdrs.HdrCnt - 1].MyOutline, MyPdfDestTop, szStr); - //DestSample(outl); - return szStr; +#pragma warning disable IDE0059 // Unnecessary assignment of a value - For Debugging + PdfOutline outl = new PdfOutline(MyDocOutline[Hdrs.HdrCnt - 1].MyOutline, MyPdfDestTop, szStr); +#pragma warning restore IDE0059 // Unnecessary assignment of a value + //DestSample(outl); + return szStr; //Console.WriteLine("Key Field"); //Console.WriteLine("Key Text: {0}", szStr); //Console.WriteLine("----------------------------------------------"); @@ -918,6 +834,7 @@ namespace Volian.Print.Library { // use the key field as the PDF bookbark string szStr = RO_df.ReadText(); + //For Dubugging //PdfDestination pdfDest = new PdfDestination(PdfDestination.FITH, _MyPDFWriter.DirectContent.PdfDocument.PageSize.Height); //PdfOutline outl = new PdfOutline(MyDocOutline[Hdrs.HdrCnt - 1].MyOutline, MyPdfDestTop, szStr); //DestSample(outl); @@ -931,25 +848,26 @@ namespace Volian.Print.Library public void ImageFile() { string fn = RO_df.ReadText(); - Int16 ht = RO_df.ReadInteger16(); - Int16 wd = RO_df.ReadInteger16(); - //m_pPrinterOut->PrintImage(fn, wd, ht); +#pragma warning disable IDE0059 // Unnecessary assignment of a value - for Debugging + short ht = RO_df.ReadInteger16(); + short wd = RO_df.ReadInteger16(); +#pragma warning restore IDE0059 // Unnecessary assignment of a value + //m_pPrinterOut->PrintImage(fn, wd, ht); - //Console.WriteLine("ImageFile"); - //Console.WriteLine("Name: {0}", fn); - //Console.WriteLine("Height: {0}", ht); - //Console.WriteLine("Width: {0}", wd); - //Console.WriteLine("----------------------------------------------"); - AddImage(fn); + //Console.WriteLine("ImageFile"); + //Console.WriteLine("Name: {0}", fn); + //Console.WriteLine("Height: {0}", ht); + //Console.WriteLine("Width: {0}", wd); + //Console.WriteLine("----------------------------------------------"); + AddImage(fn); } // Read in the X/Y plot info. public void XYPlot() { // Get the lenght of the text string and read it in - Int16 iValue = RO_df.ReadInteger16(); + short iValue = RO_df.ReadInteger16(); string szStr = RO_df.ReadText(iValue); - string temp = szStr; - Chunk chk = LastHeader(); // = new Chunk(m.Value, fnt); + Chunk chk = LastHeader(); Phrase p = new Phrase(); PdfPCell cell = new PdfPCell(); p.Add(chk); // add the header chunk @@ -997,7 +915,6 @@ namespace Volian.Print.Library chk = new Chunk(hdrtxt, F10Bold); Hdrs.printedLastHeader = true; return chk; - //m_pPrinterOut->LastHeader(); } }// end CompSumROReport @@ -1005,9 +922,7 @@ namespace Volian.Print.Library public class Headers { - //public string[] strHdrs; public List strHdrs; -// public int[] repeatCount; public int HdrCnt; public List repeatCount; public bool printedLastHeader; @@ -1022,8 +937,8 @@ namespace Volian.Print.Library public class RODataFile { - FileStream fs = null; - BinaryReader br = null; + readonly FileStream fs = null; + readonly BinaryReader br = null; public RODataFile(string fname) { fs = new FileStream(fname,FileMode.Open); @@ -1034,16 +949,10 @@ namespace Volian.Print.Library br.Close(); fs.Close(); } - public long GetFileLength() - { - return fs.Length; - } - public long GetFilePointerPosition() - { - return fs.Position; - } -// Read an integer value from the data file - public Int16 ReadInteger16() + public long GetFileLength() => fs.Length; + public long GetFilePointerPosition() => fs.Position; + // Read an integer value from the data file + public Int16 ReadInteger16() { try { @@ -1055,18 +964,15 @@ namespace Volian.Print.Library return -1; } } -// Read a text string from the data file and returns it. -// The calling program is responsible for free it -// with the "delete" operator. + // Read a text string from the data file and returns it. + // The calling program is responsible for free it + // with the "delete" operator. - public string ReadText() - { - return ReadText(-1); - } + public string ReadText() => ReadText(-1); - public string ReadText(Int16 i16CharCount) + public string ReadText(Int16 i16CharCount) { - Int16 i16DataSize; + short i16DataSize; if (i16CharCount == -1) i16DataSize = ReadInteger16(); else @@ -1082,15 +988,14 @@ namespace Volian.Print.Library for (int i = 0; i < i16DataSize; i++) str += Convert.ToChar(charbuff[i]).ToString(); return (str); - //return (Encoding.ASCII.GetString(charbuff, 0, i16DataSize)); // this didn't handle line draw chars } } // Search through the file to find the next record public long NextRecord() { - Int16 iType; - Int16 RECORD_START = 255; + short iType; + short RECORD_START = 255; // While not the next record and not end of file get the next meta item while ((iType = ReadInteger16()) != RECORD_START && iType != -1) { @@ -1101,28 +1006,25 @@ namespace Volian.Print.Library // Get the next meta item and discard the data public long NextItem() { - string pTmp; - Int16 iRecType = ReadInteger16(); - Int16 iNewCnt; - int iLoop; - switch (iRecType) + short iRecType = ReadInteger16(); + short iNewCnt; + int iLoop; + switch (iRecType) { case 1: // Set Header iNewCnt = ReadInteger16(); for (iLoop = 0; iLoop < iNewCnt; iLoop++) { ReadInteger16(); - pTmp = ReadText(); - //delete pTmp; + _ = ReadText(); } break; case 2: // Push Header case 6: // Msg case 7: // Key Field case 100: // Text Field - case 101: // Plot Field - pTmp = ReadText(); - //delete pTmp; + case 101: // Plot Field + _ = ReadText(); break; case 3: // Pop Header case 4: // RRO Begin @@ -1133,8 +1035,7 @@ namespace Volian.Print.Library // Do nothing break; case 102: // Image Field - pTmp = ReadText(); - //delete pTmp; + _ = ReadText(); ReadInteger16(); ReadInteger16(); break; diff --git a/PROMS/Volian.Print.Library/ContActionSum.cs b/PROMS/Volian.Print.Library/ContActionSum.cs index 02276c91..87b04c9f 100644 --- a/PROMS/Volian.Print.Library/ContActionSum.cs +++ b/PROMS/Volian.Print.Library/ContActionSum.cs @@ -1,7 +1,5 @@ using System; -using System.Collections.Generic; using System.Text; -using System.Drawing; using LBWordLibrary; using VEPROMS.CSLA.Library; using System.Text.RegularExpressions; @@ -10,12 +8,12 @@ namespace Volian.Print.Library { public class ContinuousActionSummary : IDisposable { - private LBApplicationClass _WordApp; - private LBDocumentClass _WordDoc; - private LBSelection _WordSel; + private readonly LBApplicationClass _WordApp; + private readonly LBDocumentClass _WordDoc; + private readonly LBSelection _WordSel; private LBTable _WordTbl; private const string TheQuickBrownFox = "The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog."; - private VE_Font _pkFont; + private readonly VE_Font _pkFont; public ContinuousActionSummary() { _WordApp = new LBApplicationClass(); @@ -41,7 +39,6 @@ namespace Volian.Print.Library _WordApp = new LBApplicationClass(); _WordDoc = _WordApp.Documents.Add(); _WordSel = _WordApp.Selection; - //_WordApp.Visible = true; _pkFont = pkFont; AddTable(); AddHeader(doingTimeCriticalSummary); // F2022-024 pass flag when creating a Time Critical Action Summary report @@ -72,11 +69,11 @@ namespace Volian.Print.Library if (txtPageNum == "") txtPageNum = (pghC.MyParagraph.MyItemInfo.PageNumber + 1).ToString(); AddContinuousAction(NoteCautionTab, GetContActStepText(pghC.MyParagraph.MyItemInfo), doneStr, txtPageNum, 0, 0); } - string stpTab = pgh.MyParagraph.MyItemInfo.MyTab.CleanText.Trim() + " "; // this is either the High Level step tab or the sub-step tab + string stpTab = $"{pgh.MyParagraph.MyItemInfo.MyTab.CleanText.Trim()} "; // this is either the High Level step tab or the sub-step tab float preTabLen = 0; if (pgh.MyParagraph.MyItemInfo.IsNote || pgh.MyParagraph.MyItemInfo.IsCaution) // only the caution and/or note is on the CAS - high level step not selected { - stpTab = string.Format("{0} ", hlsii.MyTab.Text.Trim()) + " " + stpTab; + stpTab = $"{hlsii.MyTab.Text.Trim()} {stpTab}"; } else if (!pgh.MyParagraph.MyItemInfo.IsHigh) // if the high level step was not included, adjust the tab for a sub-step/RNO { @@ -98,13 +95,13 @@ namespace Volian.Print.Library prevItemInfo = prevItemInfo.MyParent; } if (_FirstLine) // the first of a CAS on the report include the High Level Step tab - sbTabPre.Insert(0, (hlsii != null) ? hlsii.MyTab.Text.Trim() + " " : ""); + sbTabPre.Insert(0, (hlsii != null) ? $"{hlsii.MyTab.Text.Trim()} " : ""); tabPre = sbTabPre.ToString(); if (!_FirstLine) // if not the first line we indent the size of high level step tab - preTabLen = GetTextWidth(hlsii.MyTab.Text.Trim() + " ") / 72f; + preTabLen = GetTextWidth($"{hlsii.MyTab.Text.Trim()} ") / 72f; if (pgh.MyParagraph.MyItemInfo.IsInRNO) { - stpTab = stpTab.TrimEnd() + "[R] "; + stpTab = $"{stpTab.TrimEnd()}[R] "; } stpTab = tabPre + stpTab; } @@ -135,7 +132,7 @@ namespace Volian.Print.Library string stpTab = cpgh.MyParagraph.MyItemInfo.MyTab.CleanText.Trim() + (cpgh.MyParagraph.MyItemInfo.IsInRNO ? "[R] ": " "); if (cpgh.MyParagraph.MyItemInfo.IsNote || cpgh.MyParagraph.MyItemInfo.IsCaution) { - stpTab = string.Format("{0} ", cpgh.MyParagraph.MyParent.MyTab.Text.Trim()) + " " + stpTab; + stpTab = $"{string.Format("{0} ", cpgh.MyParagraph.MyParent.MyTab.Text.Trim())} {stpTab}"; } ItemInfo prevItmInfo = cpgh.MyParagraph.MyItemInfo.MyParent; // F2026-001 the while loop below will add the sub-step's parent tab if applicable @@ -154,19 +151,9 @@ namespace Volian.Print.Library } } - private string GetContActStepText(ItemInfo myItemInfo) - { - //string conActSumText = ""; - //StepConfig sc = myItemInfo.MyConfig as StepConfig; - //if (sc != null && sc.Step_AlternateContActSumText != null) - // conActSumText = sc.Step_AlternateContActSumText; - //if (conActSumText == "") - // conActSumText = myItemInfo.FormattedDisplayText; - //return conActSumText; - return myItemInfo.FormattedDisplayText; - } + private string GetContActStepText(ItemInfo myItemInfo) => myItemInfo.FormattedDisplayText; - private void AddNotesOrCautions(pkParagraph pgh, int level) + private void AddNotesOrCautions(pkParagraph pgh, int level) { foreach (pkParagraph cpgh in pgh.MyCautionsAndNotes) { @@ -305,7 +292,7 @@ namespace Volian.Print.Library } _FirstLine = false; } - static Regex rgx = new Regex(@"\\(b|ul|up[1-9]|dn0|up0|dn[1-9]|b0|ulnone)( |$|(?=\\))"); + static readonly Regex rgx = new Regex(@"\\(b|ul|up[1-9]|dn0|up0|dn[1-9]|b0|ulnone)( |$|(?=\\))"); private void WriteRTF(string text) { Match m = rgx.Match(text); @@ -363,17 +350,8 @@ namespace Volian.Print.Library _WordSel.ParagraphFormat.Alignment = hAlign; _WordSel.Cells.VerticalAlignment = vAlign; } - private void Advance(int count) - { - _WordSel.MoveRight(LBWdUnits.wdCell, count, false); - } - private void Advance() - { - Advance(1); - } - public void Dispose() - { - _WordApp.Quit(false); - } - } + private void Advance(int count) => _WordSel.MoveRight(LBWdUnits.wdCell, count, false); + private void Advance() => Advance(1); + public void Dispose() => _WordApp.Quit(false); + } } diff --git a/PROMS/Volian.Print.Library/GlobalSuppressions.cs b/PROMS/Volian.Print.Library/GlobalSuppressions.cs new file mode 100644 index 00000000..046248af --- /dev/null +++ b/PROMS/Volian.Print.Library/GlobalSuppressions.cs @@ -0,0 +1,8 @@ +// This file is used by Code Analysis to maintain SuppressMessage +// attributes that are applied to this project. +// Project-level suppressions either have no target or are given +// a specific target and scoped to a namespace, type, member, etc. + +using System.Diagnostics.CodeAnalysis; + +[assembly: SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "Not modifying Naming Styles")] diff --git a/PROMS/Volian.Print.Library/Grid2Pdf.cs b/PROMS/Volian.Print.Library/Grid2Pdf.cs index 652cc3fd..9853f5fb 100644 --- a/PROMS/Volian.Print.Library/Grid2Pdf.cs +++ b/PROMS/Volian.Print.Library/Grid2Pdf.cs @@ -2,12 +2,8 @@ using System; using System.Collections.Generic; using System.Text; using C1.Win.C1FlexGrid; -using System.IO; using Itenso.Rtf; -using Itenso.Rtf.Parser; -using Itenso.Rtf.Interpreter; using Itenso.Rtf.Support; -using Volian.Print.Library; using Volian.Controls.Library; using iTextSharp.text; using iTextSharp.text.pdf; @@ -19,139 +15,37 @@ namespace Volian.Print.Library #region Settings // RHM20150429 - Table Scrunch public partial class vlnTable { - private string _DebugInfo = null; // RHM20150429 - Table Scrunch - public string DebugInfo - { - get { return _DebugInfo; } - set { _DebugInfo = value; } - } - private int _ItemID = 0; - public int ItemID - { - get { return _ItemID; } - set { _ItemID = value; } - } - private bool _ShowDetails = false; - public bool ShowDetails - { - get { return _ShowDetails; } - set { _ShowDetails = value; } - } - private bool _IsTooBig = false; - public bool IsTooBig - { - get { return _IsTooBig; } - set { _IsTooBig = value; } - } - } - public partial class vlnCells - { - private static float YAdjust_HContent = 4; // 4 - private float YAdjust_SpacingAfter - { - get - { - return 8-8*MyTable.Adjustment;//0; // 8 - } - } - } + public string DebugInfo { get; set; } = null; + public int ItemID { get; set; } = 0; + public bool ShowDetails { get; set; } = false; + public bool IsTooBig { get; set; } = false; + } public partial class vlnCell { #region Log4Net private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); - #endregion - public bool ShowDetails - { get { return MyTable.ShowDetails; } } - private static float YAdjust_h = 0; // 0 - private float YAdjust_TextLocation - { - get - { - return 4 - 4 * MyTable.Adjustment; ;//0; // 4 - } - } - } - //public partial class vlnTable - //{ - // private static float YAdjust_RowTop = 0;//8; // 0 - //} - //public partial class vlnCells - //{ - // private static float YAdjust_HContent = 4; // 4 - // private static float YAdjust_SpacingAfter = 8;//0; // 8 - //} - //public partial class vlnCell - //{ - // private static float YAdjust_h = 0; // 0 - // private static float YAdjust_TextLocation = 4;//0; // 4 - //} + #endregion + public bool ShowDetails => MyTable.ShowDetails; + private static readonly float YAdjust_h = 0; + } #endregion public partial class vlnTable { - #region Properties - // HContents: For each row, contains the largest height for all columns in that row. - // Merged cells are accounted for. This is done in vlnCells:SetupCells - private float[] _HContents;// RHM20150525 - Table Scrunch - public float[] HContents - { - get { return _HContents; } - set { _HContents = value; } - } - private float[] _RowTop; - public float[] RowTop - { - get { return _RowTop; } - set { _RowTop = value; } - } - private float[] _ColLeft; - public float[] ColLeft - { - get { return _ColLeft; } - set { _ColLeft = value; } - } - private VlnFlexGrid _MyFlexGrid; - public VlnFlexGrid MyFlexGrid - { - get { return _MyFlexGrid; } - set { _MyFlexGrid = value; } - } - private VlnBorders _MyBorders; - public VlnBorders MyBorders - { - get { return _MyBorders; } - set { _MyBorders = value; } - } - // C2021-004 Table cell shading - private VlnGridCellShading _MyShading; - public VlnGridCellShading MyShading - { - get { return _MyShading; } - set { _MyShading = value; } - } - private iTextSharp.text.pdf.PdfContentByte _MyContentByte; - public iTextSharp.text.pdf.PdfContentByte MyContentByte - { - get { return _MyContentByte; } - set { _MyContentByte = value; } - } - private vlnCells _MyCells; - public vlnCells MyCells - { - get { return _MyCells; } - set { _MyCells = value; } - } - public float Height - { get - { - return RowTop[RowTop.Length - 1]; - } } - public float Width - { get - { - return ColLeft[ColLeft.Length - 1]; - } } + #region Properties + // HContents: For each row, contains the largest height for all columns in that row. + // Merged cells are accounted for. This is done in vlnCells:SetupCells + public float[] HContents { get; set; } + public float[] RowTop { get; set; } + public float[] ColLeft { get; set; } + public VlnFlexGrid MyFlexGrid { get; set; } + public VlnBorders MyBorders { get; set; } + public VlnGridCellShading MyShading { get; set; } + public iTextSharp.text.pdf.PdfContentByte MyContentByte { get; set; } + public vlnCells MyCells { get; set; } + public float Height => RowTop[RowTop.Length - 1]; + public float Width => ColLeft[ColLeft.Length - 1]; - private static float _XOffset = -1; // This moves the borders with respect to the text + private static float _XOffset = -1; // This moves the borders with respect to the text public static float XOffset { get { return vlnTable._XOffset; } @@ -186,7 +80,7 @@ namespace Volian.Print.Library get { return (LineThicknessForThick - LineThicknessForDouble) / 2; }//LineThicknessForThick - 2 * LineThicknessForDouble; } } private float _TotalContentHeight = 0;// RHM20150525 - Table Scrunc - // TotalContentHeight - height of just the content of all rows in the table. + public float TotalContentHeight { get @@ -199,29 +93,28 @@ namespace Volian.Print.Library return _TotalContentHeight; } } - public float SpaceAvailable// RHM20150525 - Table Scrunc - { - // SpaceAvailable is the amount of white space there is to work with. It uses the bottom location - // of the table and subtracts how much height the actual contents take, TotalContentHeight. TotalContentHeight - // includes size/height (font size - assumes 12, 6LPI) of text & leading (space between lines) - get { return TotalContentHeight ==0 ? 0 : RowTop[RowTop.Length - 1] - TotalContentHeight; } - } - public float LeadingSpaceAvailable// B2018-085 - Table Scrunch Fix: - { - // LeadingSpaceAvailable is the amount of 'blank' space between lines, this is included in TotalContentHeight. - // 1.5 is difference between 12 and 13.5, 12 is the standard font size, i.e. 6LPI. 13.5 is line leading. - // 1.5/13.5 is amount of space used by leading. - get { return TotalContentHeight == 0 ? 0 : TotalContentHeight * 1.5F/13.5F; } - } - // TooBig is the amount that the grid is over the amount of space on the page. To start (value in TooBig), it is set to - // (height of grid w/ compressed setting if needed + line) - (how much room on page), i.e. negative number if it can fit - private float _TooBig;// RHM20150525 - Table Scrunc + + // RHM20150525 - Table Scrunc + // SpaceAvailable is the amount of white space there is to work with. It uses the bottom location + // of the table and subtracts how much height the actual contents take, TotalContentHeight. TotalContentHeight + // includes size/height (font size - assumes 12, 6LPI) of text & leading (space between lines) + public float SpaceAvailable => TotalContentHeight == 0 ? 0 : RowTop[RowTop.Length - 1] - TotalContentHeight; + + // B2018-085 - Table Scrunch Fix: + // LeadingSpaceAvailable is the amount of 'blank' space between lines, this is included in TotalContentHeight. + // 1.5 is difference between 12 and 13.5, 12 is the standard font size, i.e. 6LPI. 13.5 is line leading. + // 1.5/13.5 is amount of space used by leading. + public float LeadingSpaceAvailable => TotalContentHeight == 0 ? 0 : TotalContentHeight * 1.5F / 13.5F; + // TooBig is the amount that the grid is over the amount of space on the page. To start (value in TooBig), it is set to + // (height of grid w/ compressed setting if needed + line) - (how much room on page), i.e. negative number if it can fit + private float _TooBig;// RHM20150525 - Table Scrunc public float TooBig { get { return _TooBig; } set { _TooBig = value; + //Debugging //_Adjustment = Math.Min(1F, (_TooBig / (RowTop.Length - 1)) / 12); //if (ShowDetails) Console.WriteLine("TooBig\t{0}\t{1}", value, _Adjustment); //if(ShowDetails) Console.WriteLine("Before RowTop={0}", RowTop[RowTop.Length-1] ); @@ -252,21 +145,10 @@ namespace Volian.Print.Library //if(ShowDetails) Console.WriteLine("After RowTop={0}", RowTop[RowTop.Length-1] ); } } - private float _Adjustment = 0;// RHM20150525 - Table Scrunc - public float Adjustment - { - get { return _Adjustment; } - set { _Adjustment = value; } - } - //private float _YAdjust_RowTop = 0;//8; // 0 - public float YAdjust_RowTop - { - get - { - return _Adjustment * 12; - } - } - private void DrawRuler(PdfContentByte cb, float x, float yTop, float height)// RHM20150525 - Table Scrunc + + public float Adjustment { get; set; } = 0; + public float YAdjust_RowTop => Adjustment * 12; + private void DrawRuler(PdfContentByte cb, float x, float yTop, float height)// RHM20150525 - Table Scrunc { VlnSvgPageHelper myPageHelper = cb.PdfWriter.PageEvent as VlnSvgPageHelper; if (myPageHelper.DebugLayer != null) @@ -290,8 +172,8 @@ namespace Volian.Print.Library cb.LineTo(x, y); cb.Stroke(); } - i = 0; - cb.Stroke(); + + cb.Stroke(); cb.RestoreState(); cb.EndLayer(); } @@ -320,17 +202,12 @@ namespace Volian.Print.Library 0, myItemInfo.ItemID, myItemInfo.FormatStepType, myItemInfo.FormatStepData == null ? "NoStepData" : myItemInfo.FormatStepData.Type, myItemInfo.StepLevel, myItemInfo.ShortPath, Width, XOffset, YOffset); } - #endregion - private string _Path; + #endregion -public string Path -{ - get { return _Path; } - set { _Path = value; } -} + public string Path { get; set; } - #region Constructors - public vlnTable(VlnFlexGrid myFlexGrid, iTextSharp.text.pdf.PdfContentByte myContentByte) + #region Constructors + public vlnTable(VlnFlexGrid myFlexGrid, iTextSharp.text.pdf.PdfContentByte myContentByte) { MyFlexGrid = myFlexGrid; MyContentByte = myContentByte; @@ -374,7 +251,7 @@ public string Path string myLPI = myPageHelper.YMultiplier == 1.0F ? ",6LPI" : ",7LPI"; Rtf2Pdf.DrawPdfDebug(myColumnText.Canvas, left-2, top+1, left + Width, top-myPageHelper.YMultiplier *(Height+1), DebugInfo+", Height= " + (myPageHelper.YMultiplier * Height).ToString() + myLPI, 0); - PdfLayer textLayer = myPageHelper == null ? null : myPageHelper.TextLayer; // RHM20150429 - Table Scrunch + PdfLayer textLayer = myPageHelper?.TextLayer; // RHM20150429 - Table Scrunch if (textLayer != null) cb.BeginLayer(textLayer); myPageHelper.AddGap(top, top - Height, left, left + Width); MyCells.ToPdf(myColumnText, left, top); @@ -383,6 +260,7 @@ public string Path ShowRowTops("ToPDF2"); if (ShowDetails) Console.WriteLine("^^^^^^ToPdf============{0}===============", ItemID); } + //For Debugging private void ZoomGrid(iTextSharp.text.pdf.ColumnText myColumnText, float left, float top) { PdfDestination dest = new PdfDestination(PdfDestination.FITR, left - 4, top - Height - 4, left + Width, top + 4); @@ -394,58 +272,29 @@ public string Path { #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 - { - get { return _MyFlexGrid; } - set { _MyFlexGrid = value; } - } - private vlnTable _MyTable; - public vlnTable MyTable - { - get { return _MyTable; } - set { _MyTable = value; } - } - public bool ShowDetails// RHM20150525 - Table Scrunc + #endregion + #region Properties + public VlnFlexGrid MyFlexGrid { get; set; } + public vlnTable MyTable { get; set; } + public bool ShowDetails// RHM20150525 - Table Scrunc { get { return MyTable.ShowDetails; }} - private iTextSharp.text.pdf.PdfContentByte _MyContentByte; - public iTextSharp.text.pdf.PdfContentByte MyContentByte - { - get { return _MyContentByte; } - set { _MyContentByte = value; } - } - #endregion - #region Constructors - public vlnCells(vlnTable myTable, VlnFlexGrid myFlexGrid, iTextSharp.text.pdf.PdfContentByte myContentByte) + + public iTextSharp.text.pdf.PdfContentByte MyContentByte { get; set; } + #endregion + #region Constructors + public vlnCells(vlnTable myTable, VlnFlexGrid myFlexGrid, iTextSharp.text.pdf.PdfContentByte myContentByte) { MyTable = myTable; MyFlexGrid = myFlexGrid; MyContentByte = myContentByte; SetupCells(); - foreach(vlnCell cell in this) - { - myTable.MyShading = VlnGridCellShading.Get(myFlexGrid.MyShading.ConvertToString()); // C2021-004 Table Cell Shading - myTable.MyBorders = VlnBorders.Get(myFlexGrid.MyBorders.ConvertToString()); - GridLinePattern glp = cell.AboveLeftSide; - glp = cell.AboveRightSide; - glp = cell.BelowLeftSide; - glp = cell.BelowRightSide; - glp = cell.RightOfBottomSide; - glp = cell.RightOfTopSide; - object ta = cell.TextAlign; - } + myTable.MyShading = VlnGridCellShading.Get(myFlexGrid.MyShading.ConvertToString()); // C2021-004 Table Cell Shading + myTable.MyBorders = VlnBorders.Get(myFlexGrid.MyBorders.ConvertToString()); } - #endregion - private float _MyLeading = 13.5F; // B2018-085 AEP and APP worked with 13.5 - public float MyLeading - { - get { return _MyLeading; } - set { _MyLeading = value; } - } - #region Private Methods - private void SetupCells() + #endregion + public float MyLeading { get; set; } = 13.5F; + #region Private Methods + private void SetupCells() { // Create a ColumnText to determine the cell heights iTextSharp.text.pdf.ColumnText myColumnText1 = new iTextSharp.text.pdf.ColumnText(MyContentByte); @@ -526,9 +375,9 @@ public string Path TrimNewlines(myPara); // RHM20150429 - Table Scrunch myColumnText1.AddElement(myPara); - float posBefore = myColumnText1.YLine; // position is y of top of paragraph since paragraph was just added - int status = myColumnText1.Go(true); // 'puts out' text for info only - float posAfter = myColumnText1.YLine; // posAfter is y of bottom of paragraph, really y top of line below this + float posBefore = myColumnText1.YLine; // position is y of top of paragraph since paragraph was just added + _ = myColumnText1.Go(true); // 'puts out' text for info only + float posAfter = myColumnText1.YLine; // posAfter is y of bottom of paragraph, really y top of line below this float hContent = 4 + posBefore - posAfter; // TableScrunch Phase 4: sets content height, uses the size derived from iTextsharp putting out text @@ -566,6 +415,7 @@ public string Path } } } + //For Debugging: // This summarizes the Content heights per row //int i=0; //foreach (float h in MyTable.HContents) @@ -580,41 +430,6 @@ public string Path return total; } - // B2017-105 if a symbol character was set to a bigger font size, then the positioning of the larger symbol character was printing too high on the line - // found with Wolf Creek use of the empty box symbol - //private float BiggestFontSize(Paragraph myPara) - //{ - // float fontSize = 12; - // foreach (Chunk ck in myPara.Chunks) - // { - // fontSize = Math.Max(fontSize, ck.Font.Size); - // if (ck.Font.Size > 12) - // { - // ck.SetTextRise(-2f); - // //_MyLog.WarnFormat("set text rise"); - // } - // } - // return fontSize; - //} - // B2017-233, B2017-234 needed to get the smallest font size to help decide if a vertical adjustment of the text is needed in a table cell - //private float SmallestFontSize(Paragraph myPara) - //{ - // float fontSize = 30; - // foreach (Chunk ck in myPara.Chunks) - // { - // fontSize = Math.Min(fontSize, ck.Font.Size); - // } - // return fontSize; - //} - //private void ShowChunks(System.Collections.ArrayList chunks) // RHM20150429 - Table Scrunch - //{ - // StringBuilder sb = new StringBuilder(); - // foreach (Chunk chk in chunks) - // { - // sb.Append(BuildChunks(chk.Content)); - // } - // //if (ShowDetails) Console.WriteLine("Chunks = '{0}'", sb.ToString()); - //} private string BuildChunks(string str) { StringBuilder sb = new StringBuilder(); @@ -625,44 +440,25 @@ public string Path else sb.Append(c); } - return "{" + sb.ToString() + "}"; + return $"{{{sb}}}"; } private void TrimNewlines(Paragraph myPara) { while (myPara.Count > 0 && ParaEndsWithNewLine(myPara)) myPara.RemoveAt(myPara.Count - 1); } - private bool ParaEndsWithNewLine(Paragraph myPara) - { - Chunk chk = myPara[myPara.Count - 1] as Chunk; - if (chk == null) return false; - if (chk.Content == "\n") return true; - return false; - } - public class VlnSplitCharacter : ISplitCharacter - { - public bool IsSplitCharacter(int start, int current, int end, char[] cc, PdfChunk[] ck) - { - return (cc[current] == ' '); - } - public bool IsSplitCharacter(char c) - { - return (c == ' '); - } - } - public static VlnSplitCharacter mySplitter = new VlnSplitCharacter(); - internal static void FixHyphens(Paragraph myPara, vlnTable myTable) + private bool ParaEndsWithNewLine(Paragraph myPara) => myPara[myPara.Count - 1] is Chunk chk && chk.Content == "\n"; + internal static void FixHyphens(Paragraph myPara, vlnTable myTable) { // Find chunk with hardhyphen // If a hard hyphen is found, the remove it and add a dash (keyboard minus sign) to the beginning // of the text that follows it. int hype=-1; - Font fnt = null; - while ((hype = GetHyphen(myPara)) > -1) + while ((hype = GetHyphen(myPara)) > -1) { - fnt = null; - if (hype > 0) + Font fnt = null; + if (hype > 0) { Chunk chk1 = (Chunk)myPara[hype - 1]; if (hype > 1 && chk1.Content.Equals("\n")) @@ -755,11 +551,10 @@ public string Path // 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) + while ((bckSlsh = GetBackslash(myPara)) > -1) { - fnt = null; - if (bckSlsh > 0) + Font fnt = null; + if (bckSlsh > 0) { Chunk chk1 = (Chunk)myPara[bckSlsh - 1]; if (bckSlsh > 1 && chk1.Content.Equals("\n")) @@ -842,23 +637,17 @@ public string Path public static float CalculateHangingIndent(string rtf) { float chkW = 0; - // **** This is intened to be a temporary fix for V.C.Summer **** - // Two procedures would not print: A-2 SAG in Summer's SAMG set, and SAG-3 in Summer's PWOG DAMG set. - // These procedures have tables with hanging indents and use the Letter Gothic Tall font. - // It appears that the font information for the hanging indent character is not included in the RTF - // for those table cells. - // This piece of code checks for the existance of a font definition of \f1 which is need for the \u9999? indent character - // If the a font definition of \f1 is not found then the indent character is removed. This will allow the procedure to print - // but the text in that table cell will not be indented. - jsj 10/10/2014 - //IRtfDocument rtfDoc2 = RtfInterpreterTool.BuildDoc(rtf.Replace(@"\'05", @"\f1 \u9999? \f0 ")); - IRtfDocument rtfDoc2 = null; - //if (rtf.Contains(@"\f1\fnil\fcharset0 ")) - // rtfDoc2 = RtfInterpreterTool.BuildDoc(rtf.Replace(@"\'05", @"\f1 \u9999? \f0 ")); - //else - //{ - // first add the symbol font and then surround the indent as above. - rtfDoc2 = RtfInterpreterTool.BuildDoc(rtf.Replace(@"\'05", @"\par\u9999?\par")); - //} + // **** This is intened to be a temporary fix for V.C.Summer **** + // Two procedures would not print: A-2 SAG in Summer's SAMG set, and SAG-3 in Summer's PWOG DAMG set. + // These procedures have tables with hanging indents and use the Letter Gothic Tall font. + // It appears that the font information for the hanging indent character is not included in the RTF + // for those table cells. + // This piece of code checks for the existance of a font definition of \f1 which is need for the \u9999? indent character + // If the a font definition of \f1 is not found then the indent character is removed. This will allow the procedure to print + // but the text in that table cell will not be indented. - jsj 10/10/2014 + // add the symbol font and then surround the indent. + //IRtfDocument rtfDoc2 = RtfInterpreterTool.BuildDoc(rtf.Replace(@"\'05", @"\f1 \u9999? \f0 ")); + IRtfDocument rtfDoc2 = RtfInterpreterTool.BuildDoc(rtf.Replace(@"\'05", @"\par\u9999?\par")); Rtf2iTextSharp rtf2IText2 = new Rtf2iTextSharp(rtfDoc2); iTextSharp.text.Paragraph para2 = rtf2IText2.Convert(); @@ -883,7 +672,7 @@ public string Path return chkW; } - private static StepRTB _StatRTB = new StepRTB(); + private static readonly StepRTB _StatRTB = new StepRTB(); private string PreProcessRTF(float w, string str) { _StatRTB.Text = string.Empty; @@ -912,25 +701,7 @@ public string Path _StatRTB.Text = str; _StatRTB.SelectAll(); _StatRTB.SelectionColor = PrintOverride.OverrideTextColor(System.Drawing.Color.Black); - str = _StatRTB.Rtf; - // RHM 20180607 The following lines calculated line spacing but it did not give consistent values - //System.Drawing.Point location0 = _StatRTB.GetPositionFromCharIndex(0); - //int ii = 1; - //System.Drawing.Point locnext = location0; - //while (ii < 1000 && (locnext = _StatRTB.GetPositionFromCharIndex(ii)).Y == location0.Y) - // ii++; - //if (ii < 1000) - //{ - // myLeading = (locnext.Y - location0.Y) * 72.0F / 96.0F; - // Console.WriteLine("{0} - {1}", _StatRTB.Font, myLeading); - //} - //else - // myLeading = 12.0F; - // myLeading = 13.5F; // RHM 20180607 This worked for AEP - // RHM 20180607 The following did not work - //RTBAPI.ParaFormatTwo pft = RTBAPI.GetParaFormat(_StatRTB); - //myLeading = Math.Max(12.0F, pft.dyLineSpacing); - return str; + return _StatRTB.Rtf; } private iTextSharp.text.Paragraph RtfToParagraph(string rtf, iTextSharp.text.Font mySymFont,int r, int c) { @@ -940,10 +711,11 @@ public string Path rtf = rtf.Replace(@"\_", "-").Replace(@"\u8209?", "-"); rtf = FixRTFToPrint(rtf, r, c); IRtfDocument rtfDoc = RtfInterpreterTool.BuildDoc(rtf); - Rtf2iTextSharp rtf2IText = new Rtf2iTextSharp(rtfDoc); - rtf2IText.DefaultFont = mySymFont; - iTextSharp.text.Paragraph para = rtf2IText.Convert(); - //para.SetLeading(MyLeading , 0);// RHM 20180607 Not Needed - performed in SetupCells + Rtf2iTextSharp rtf2IText = new Rtf2iTextSharp(rtfDoc) + { + DefaultFont = mySymFont + }; + iTextSharp.text.Paragraph para = rtf2IText.Convert(); return para; } // The text font used in FixRTFToPrint for grid @@ -1011,7 +783,6 @@ public string Path // follow through in fixing an Out of Window Handles bug, use new function to see if // we can retrieve the font from a dictionary instead a doing a New and using another // window handle B2017-117 - //rtb.SelectionFont = new System.Drawing.Font(DefaultFont, fnt.Style); rtb.SelectionFont = VE_Font.GetWinSysFont(DefaultFont, fnt.Style); changed = true; } @@ -1027,8 +798,7 @@ public string Path { //use bolding underline italics from local font System.Drawing.Font fnt = rtb.SelectionFont; - //System.Drawing.Font fntw = new System.Drawing.Font((rc.Family != null) ? rc.Family : fnt.FontFamily.Name, (rc.Size != null) ? (float)rc.Size : fnt.Size, (rc.Style != null) ? (System.Drawing.FontStyle)rc.Style : fnt.Style); - System.Drawing.Font fntw = VE_Font.GetWinSysFont((rc.Family != null) ? rc.Family : fnt.FontFamily.Name, (rc.Size != null) ? (float)rc.Size : fnt.Size, (rc.Style != null) ? (System.Drawing.FontStyle)rc.Style : fnt.Style); + System.Drawing.Font fntw = VE_Font.GetWinSysFont(rc.Family ?? fnt.FontFamily.Name, (rc.Size != null) ? (float)rc.Size : fnt.Size, (rc.Style != null) ? (System.Drawing.FontStyle)rc.Style : fnt.Style); rtb.SelectionFont = fntw; if (rc.Replace != null) { @@ -1047,7 +817,6 @@ public string Path } return rtf; } - private static float _SixLinesPerInch = 12; // twips #endregion #region Public Methods // C2021-005 Get the largest font size being used. @@ -1116,60 +885,20 @@ public string Path } public partial class vlnCell // RHM20150429 - Table Scrunch { - #region Properties - private vlnTable _MyTable; - public vlnTable MyTable - { - get { return _MyTable; } - set { _MyTable = value; } - } - public VlnBorders MyBorders - { - get { return _MyTable.MyBorders; } - } - private int _r1; - public int r1 - { - get { return _r1; } - set { _r1 = value; } - } - private int _c1; - public int c1 - { - get { return _c1; } - set { _c1 = value; } - } - private int _r2; - public int r2 - { - get { return _r2; } - set { _r2 = value; } - } - private int _c2; - public int c2 - { - get { return _c2; } - set { _c2 = value; } - } - private iTextSharp.text.Paragraph _MyPara; - public iTextSharp.text.Paragraph MyPara - { - get { return _MyPara; } - set { _MyPara = value; } - } - private float _HContent; - public float HContent - { - get { return _HContent; } - set { _HContent = value; } - } - public VlnGridCellShading MyShading - { - get { return _MyTable.MyShading; } - } - #endregion - #region Line Pattern Diagram - /* + #region Properties + public vlnTable MyTable { get; set; } + public VlnBorders MyBorders => MyTable.MyBorders; + + public int r1 { get; set; } + public int c1 { get; set; } + public int r2 { get; set; } + public int c2 { get; set; } + public iTextSharp.text.Paragraph MyPara { get; set; } + public float HContent { get; set; } + public VlnGridCellShading MyShading => MyTable.MyShading; + #endregion + #region Line Pattern Diagram + /* The diagram below identifies the various border names for the cell in the center |-AboveLeftSide |-AboveRightSide @@ -1192,9 +921,9 @@ public string Path |-BelowLeftSide |-BelowRightSide */ - #endregion - #region Horizontal Line Patterns - private GridLinePattern _TopSide = GridLinePattern.Unknown; + #endregion + #region Horizontal Line Patterns + private GridLinePattern _TopSide = GridLinePattern.Unknown; public GridLinePattern TopSide { get @@ -1408,27 +1137,27 @@ public string Path return _AboveLeftSide; } } - #endregion - #region Static Properties - private static float XOffset { get { return vlnTable.XOffset; } } - private static float YOffset { get { return vlnTable.YOffset; } } - private static float LineThicknessForThin { get { return vlnTable.LineThicknessForThin; } } - private static float LineThicknessForThick { get { return vlnTable.LineThicknessForThick; } } - private static float LineThicknessForDouble { get { return vlnTable.LineThicknessForDouble; } } - private static float DoubleLineOffset { get { return vlnTable.DoubleLineOffset; } } + #endregion + #region Static Properties + private static float XOffset => vlnTable.XOffset; + private static float YOffset => vlnTable.YOffset; + private static float LineThicknessForThin => vlnTable.LineThicknessForThin; + private static float LineThicknessForThick => vlnTable.LineThicknessForThick; + private static float LineThicknessForDouble => vlnTable.LineThicknessForDouble; + private static float DoubleLineOffset => vlnTable.DoubleLineOffset; - // adjustments for line intersections: - private static float ThickOverDouble { get { return ((2 * DoubleLineOffset) + LineThicknessForDouble - LineThicknessForThick) / 2; } } - private static float ThickUnderDouble { get { return DoubleLineOffset + (LineThicknessForThick - LineThicknessForDouble) / 2; } } - private static float ThickOverThin { get { return (LineThicknessForThin - LineThicknessForThick) / 2; } } - private static float ThinOverThick { get { return (LineThicknessForThick - LineThicknessForThin) / 2; } } - private static float ThinUnderDouble { get { return DoubleLineOffset + (LineThicknessForThin - LineThicknessForDouble) / 2; } } - private static float ThinOverDouble { get { return (DoubleLineOffset + LineThicknessForThin - LineThicknessForDouble) / 2; } } - private static float DoubleUnderThin { get { return (LineThicknessForThin - LineThicknessForDouble) / 2; } } - private static float DoubleUnderThick { get { return (LineThicknessForThick - LineThicknessForDouble) / 2; } } - #endregion - #region Constructors - public vlnCell(int r1, int c1, int r2, int c2, vlnTable myTable, iTextSharp.text.Paragraph myPara, float hContent) + // adjustments for line intersections: + private static float ThickOverDouble => ((2 * DoubleLineOffset) + LineThicknessForDouble - LineThicknessForThick) / 2; + private static float ThickUnderDouble => DoubleLineOffset + (LineThicknessForThick - LineThicknessForDouble) / 2; + private static float ThickOverThin => (LineThicknessForThin - LineThicknessForThick) / 2; + private static float ThinOverThick => (LineThicknessForThick - LineThicknessForThin) / 2; + private static float ThinUnderDouble => DoubleLineOffset + (LineThicknessForThin - LineThicknessForDouble) / 2; + private static float ThinOverDouble => (DoubleLineOffset + LineThicknessForThin - LineThicknessForDouble) / 2; + private static float DoubleUnderThin => (LineThicknessForThin - LineThicknessForDouble) / 2; + private static float DoubleUnderThick => (LineThicknessForThick - LineThicknessForDouble) / 2; + #endregion + #region Constructors + public vlnCell(int r1, int c1, int r2, int c2, vlnTable myTable, iTextSharp.text.Paragraph myPara, float hContent) { this.r1 = r1; this.c1 = c1; @@ -1438,19 +1167,14 @@ public string Path MyPara = myPara; HContent = hContent; } - #endregion - #region Public Methods - public override string ToString() - { - return string.Format("{0}:{1}", r1, c1); - } - // B2018-003 - RHM 20180319 Add - public void PdfDebug(iTextSharp.text.pdf.ColumnText myColumnText, float x, float bottom, float right, float y, string debugText, float yDescent) + #endregion + #region Public Methods + public override string ToString() => string.Format("{0}:{1}", r1, c1); + public void PdfDebug(iTextSharp.text.pdf.ColumnText myColumnText, float x, float bottom, float right, float y, string debugText, float yDescent) { PdfContentByte cb = myColumnText.Canvas; - VlnSvgPageHelper _MyPageHelper = cb.PdfWriter.PageEvent as VlnSvgPageHelper; - PdfLayer debugLayer = _MyPageHelper == null ? null : _MyPageHelper.DebugLayer; - if (debugLayer == null) return; + PdfLayer debugLayer = !(cb.PdfWriter.PageEvent is VlnSvgPageHelper _MyPageHelper) ? null : _MyPageHelper.DebugLayer; + if (debugLayer == null) return; System.Drawing.Color sysColor = PrintOverride.OverrideDebugColor(System.Drawing.Color.Gray); cb.SaveState(); cb.BeginLayer(debugLayer); @@ -1481,7 +1205,6 @@ public string Path cb.EndLayer(); cb.RestoreState(); } - //RHM 20180319 End of Add // B2021-137 Added doShading parameter // We call this twice. The first time to print the shading the second time to print the borders and text public void ToPdf(iTextSharp.text.pdf.ColumnText myColumnText, float left, float top, int topPlacementAdjust, bool doShading) @@ -1518,7 +1241,6 @@ public string Path // B2019-093 missing table cell text when printing South Texas FSG-20 step 1 // Added two more to the last parameter of SetSimplColun (it's the ury value - upper y value) // this will have the cell text print a little more toward the top of the cell - //myColumnText1.SetSimpleColumn(1 + left + x, top - y - h, left + x + w - 2, 3 + top - y - hAdjust - adjustTextLocation); // 2 == Default Padding // B2019-109 Adjusted width of cell to match edit cell // B2020-034 - use the passed in topPlacementAdjust value which is set based on the font size. myColumnText1.SetSimpleColumn(.5F + left + x, top - y - h, left + x + w - 1.5F, topPlacementAdjust + top - y - hAdjust - adjustTextLocation); // 2 == Default Padding @@ -1566,7 +1288,6 @@ public string Path int cellStatus = myColumnText1.Go(); // B2019-109 Add to Error Log if cell too small if (cellStatus != 1) { - //System.Windows.Forms.MessageBox.Show("Cell width too narrow \r\n" + MyTable.Path, "Narrow Cell", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Exclamation); _MyLog.WarnFormat("\r\n=-=-=-= Cell Width too narrow, text is wrapping ItemID={0} Location={1}, Row={2}, Col={3}, Status={4}",MyTable.ItemID, MyTable.Path, r1, c1, cellStatus); } float posAfter = myColumnText1.YLine; // RHM20150429 - Table Scrunch @@ -1606,7 +1327,6 @@ public string Path } return sb.ToString(); } - private static float _SixLinesPerInch = 12; // twips public bool IsRangeStyleNull = false; private TextAlignEnum? _TextAlign = null; public TextAlignEnum? TextAlign @@ -1635,7 +1355,6 @@ public string Path private float VeritcalTextAlignment(float h, float mult) { float hAdjust = 0; - //CellRange cr = MyTable.MyFlexGrid.GetCellRange(r1, c1, r2, c2); if (!IsRangeStyleNull) { switch (TextAlign) @@ -1913,28 +1632,10 @@ public string Path else if (linePattern == GridLinePattern.Dashed) cb.SetLineDash(4, 4, 0); } - private static void SetLineColor(PdfContentByte cb, int row, int col, string side) + [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0060:Remove unused parameter", Justification = "Keeping row and col for Debugging")] + private static void SetLineColor(PdfContentByte cb, int row, int col, string side) { iTextSharp.text.Color lineColor = new iTextSharp.text.Color(PrintOverride.OverrideTextColor(System.Drawing.Color.Black)); - //switch (side) - //{ - // case "Top": - // if (col == 0) lineColor = new iTextSharp.text.Color(PrintOverride.OverrideTextColor(System.Drawing.Color.Blue)); - // else lineColor = new iTextSharp.text.Color(PrintOverride.OverrideTextColor(System.Drawing.Color.Cyan)); - // break; - // case "Left": - // if (row == 0) lineColor = new iTextSharp.text.Color(PrintOverride.OverrideTextColor(System.Drawing.Color.Red)); - // else lineColor = new iTextSharp.text.Color(PrintOverride.OverrideTextColor(System.Drawing.Color.Magenta)); - // break; - // case "Bottom": - // if (col == 0) lineColor = new iTextSharp.text.Color(PrintOverride.OverrideTextColor(System.Drawing.Color.Green)); - // else lineColor = new iTextSharp.text.Color(PrintOverride.OverrideTextColor(System.Drawing.Color.Cyan)); - // break; - // case "Right": - // if (row == 0) lineColor = new iTextSharp.text.Color(PrintOverride.OverrideTextColor(System.Drawing.Color.Orange)); - // else lineColor = new iTextSharp.text.Color(PrintOverride.OverrideTextColor(System.Drawing.Color.Magenta)); - // break; - //} cb.SetColorStroke(lineColor); } private static void InitializeLineStyle(PdfContentByte cb) @@ -1946,9 +1647,11 @@ public string Path #region Debug Methods private static void SetOpacity(PdfContentByte cb, float opacity) { - PdfGState gs = new PdfGState(); - gs.StrokeOpacity = opacity; - cb.SetGState(gs); + PdfGState gs = new PdfGState + { + StrokeOpacity = opacity + }; + cb.SetGState(gs); } private static void ZoomToCell(iTextSharp.text.pdf.ColumnText myColumnText, float xLeft, float yTop, float xRight, float yBottom) { @@ -1956,141 +1659,5 @@ public string Path myColumnText.Canvas.SetAction(PdfAction.GotoLocalPage(myColumnText.Canvas.PdfWriter.CurrentPageNumber, dest, myColumnText.Canvas.PdfWriter), xLeft, yBottom, xRight, yTop); } #endregion - #region Old Border Methods - //private void DrawLeftLine(PdfContentByte cb, float xLeft, float yTop, float yBottom) - //{ - // if (c1 == 0 && LineLeft != GridLinePattern.None) - // { - // InitializeLineStyle(cb); - // SetLineColor(cb, r1, c1, "Left"); - // if (LineLeft == GridLinePattern.Double) - // { - // //Left Line - // float dyTop = DoubleIntersectionLeft(LineTopLeft, LineTop, LineLeftAbove); - // float dyBottom = -DoubleIntersectionRight(LineBottom, LineBottomLeft, LineLeftBelow); - // DrawLine(cb, LineThicknessForDouble, xLeft - DoubleLineOffset, yTop + dyTop, xLeft - DoubleLineOffset, yBottom + dyBottom); - // //Right Line - // dyTop = DoubleIntersectionRight(LineTopLeft, LineTop, LineLeftAbove); - // dyBottom = -DoubleIntersectionLeft(LineBottom, LineBottomLeft, LineLeftBelow); - // DrawLine(cb, LineThicknessForDouble, xLeft + DoubleLineOffset, yTop + dyTop, xLeft + DoubleLineOffset, yBottom + dyBottom); - // } - // else if (LineLeft != GridLinePattern.Thick) - // { - // SetLinePattern(cb, LineLeft); - // float dyTop = ThinIntersection(LineTopLeft, LineTop, LineLeftAbove); - // float dyBottom = -ThinIntersection(LineBottom, LineBottomLeft, LineLeftBelow); - // DrawLine(cb, LineThicknessForThin, xLeft, yTop + dyTop, xLeft, yBottom + dyBottom); - // } - // else - // { - // float dyTop = ThickIntersection(LineTopLeft, LineTop, LineLeftAbove); - // float dyBottom = -ThickIntersection(LineBottom, LineBottomLeft, LineLeftBelow); - // DrawLine(cb, LineThicknessForThick, xLeft, yTop + dyTop, xLeft, yBottom + dyBottom); - // } - // cb.Stroke(); - // } - //} - //private void DrawRightLine(PdfContentByte cb, float xRight, float yTop, float yBottom) - //{ - // if (LineRight != GridLinePattern.None) - // { - // InitializeLineStyle(cb); - // SetLineColor(cb, r1, c1, "Right"); - // if (LineRight == GridLinePattern.Double) - // { - // //Left Line - // float dyTop = DoubleIntersectionLeft(LineTop, LineTopRight, LineRightAbove); - // float dyBottom = -DoubleIntersectionRight(LineBottomRight, LineBottom, LineRightBelow); - // DrawLine(cb, LineThicknessForDouble, xRight - DoubleLineOffset, yTop + dyTop, xRight - DoubleLineOffset, yBottom + dyBottom); - // //Right Line - // dyTop = DoubleIntersectionRight(LineTop, LineTopRight, LineRightAbove); - // dyBottom = -DoubleIntersectionLeft(LineBottomRight, LineBottom, LineRightBelow); - // DrawLine(cb, LineThicknessForDouble, xRight + DoubleLineOffset, yTop + dyTop, xRight + DoubleLineOffset, yBottom + dyBottom); - // } - // else if (LineRight != GridLinePattern.Thick) - // { - // float dyTop = ThinIntersection(LineTop, LineTopRight, LineRightAbove); - // float dyBottom = -ThinIntersection(LineBottomRight, LineBottom, LineRightBelow); - // SetLinePattern(cb, LineRight); - // DrawLine(cb, LineThicknessForThin, xRight, yTop + dyTop, xRight, yBottom + dyBottom); - // } - // else - // { - // float dyTop = ThickIntersection(LineTop, LineTopRight, LineRightAbove); - // float dyBottom = -ThickIntersection(LineBottomRight, LineBottom, LineRightBelow); - // DrawLine(cb, LineThicknessForThick, xRight, yTop + dyTop, xRight, yBottom + dyBottom); - // } - // cb.Stroke(); - // } - //} - //private void DrawTopLine(PdfContentByte cb, float xLeft, float xRight, float yTop) - //{ - // if (r1 == 0 && TopSide != GridLinePattern.None) - // { - // InitializeLineStyle(cb); - // SetLineColor(cb, r1, c1, "Top"); - // if (TopSide == GridLinePattern.Double) - // { - // // Top Line - // float dxLeft = -DoubleIntersectionRight(LeftSide, AboveLeftSide, LeftOfTopSide); - // float dxRight = DoubleIntersectionLeft(AboveRightSide, RightSide, RightOfTopSide); - // DrawLine(cb, LineThicknessForDouble, xLeft + dxLeft, yTop + DoubleLineOffset, xRight + dxRight, yTop + DoubleLineOffset); - // // Bottom Line - // dxLeft = -DoubleIntersectionLeft(LeftSide, AboveLeftSide, LeftOfTopSide); - // dxRight = DoubleIntersectionRight(AboveRightSide, RightSide, RightOfTopSide); - // DrawLine(cb, LineThicknessForDouble, xLeft + dxLeft, yTop - DoubleLineOffset, xRight + dxRight, yTop - DoubleLineOffset); - // } - // else if (TopSide != GridLinePattern.Thick) - // { - // SetLinePattern(cb, TopSide); - // float dxLeft = -ThinIntersection(LeftSide, AboveLeftSide, LeftOfTopSide); - // float dxRight = ThinIntersection(AboveRightSide, RightSide, RightOfTopSide); - // DrawLine(cb, LineThicknessForThin, xLeft + dxLeft, yTop, xRight + dxRight, yTop); - // } - // else - // { - // float dxLeft = -ThickIntersection(LeftSide, AboveLeftSide, LeftOfTopSide); - // float dxRight = ThickIntersection(AboveRightSide, RightSide, RightOfTopSide); - // if (c1 == 0) - // Console.WriteLine("'{0}','{1}','{2}',{3},{4}", LeftSide, AboveLeftSide, LeftOfTopSide, dxLeft, ThickOverThin); - // DrawLine(cb, LineThicknessForThick, xLeft + dxLeft, yTop, xRight + dxRight, yTop); - // } - // cb.Stroke(); - // } - //} - //private void DrawBottomLine(PdfContentByte cb, float xLeft, float xRight, float yBottom) - //{ - // if (BottomSide != GridLinePattern.None) - // { - // InitializeLineStyle(cb); - // SetLineColor(cb, r1, c1, "Bottom"); - // if (BottomSide == GridLinePattern.Double) - // { - // // Top Line - // float dxLeft = -DoubleIntersectionRight(BelowLeftSide, LeftSide, LeftOfBottomSide); - // float dxRight = DoubleIntersectionLeft(RightSide, BelowRightSide, RightOfBottomSide); - // DrawLine(cb, LineThicknessForDouble, xLeft + dxLeft, yBottom + DoubleLineOffset, xRight + dxRight, yBottom + DoubleLineOffset);// Top Line - // // Bottom Line - // dxLeft = -DoubleIntersectionLeft(BelowLeftSide, LeftSide, LeftOfBottomSide); - // dxRight = DoubleIntersectionRight(RightSide, BelowRightSide, RightOfBottomSide); - // DrawLine(cb, LineThicknessForDouble, xLeft + dxLeft, yBottom - DoubleLineOffset, xRight + dxRight, yBottom - DoubleLineOffset);//Bottom Line - // } - // else if (BottomSide != GridLinePattern.Thick) // Bottom line is thin. Determine if intersecting with double: - // { - // SetLinePattern(cb, BottomSide); - // float dxLeft = -ThinIntersection(BelowLeftSide, LeftSide, LeftOfBottomSide); - // float dxRight = ThinIntersection(RightSide, BelowRightSide, RightOfBottomSide); - // DrawLine(cb, LineThicknessForThin, xLeft + dxLeft, yBottom, xRight + dxRight, yBottom); - // } - // else - // { - // float dxLeft = -ThickIntersection(BelowLeftSide, LeftSide, LeftOfBottomSide); - // float dxRight = ThickIntersection(RightSide, BelowRightSide, RightOfBottomSide); - // DrawLine(cb, LineThicknessForThick, xLeft + dxLeft, yBottom, xRight + dxRight, yBottom); - // } - // cb.Stroke(); - // } - //} - #endregion } } diff --git a/PROMS/Volian.Print.Library/MergedPdf.cs b/PROMS/Volian.Print.Library/MergedPdf.cs index 059c9919..e9ceb8f1 100644 --- a/PROMS/Volian.Print.Library/MergedPdf.cs +++ b/PROMS/Volian.Print.Library/MergedPdf.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; using System.Text; using System.IO; using System.Windows.Forms; @@ -14,34 +13,15 @@ namespace Volian.Print.Library { public class MergedPdfProc { - private string _Title; - public string Title + public string Title { get; // used for pdf outline + set; } + public int PageCount { get; set; } + public string PdfFileName { get; set; } + public bool FirstPageNoPageNum { get; set; } = false; + public MergedPdfProc(string title, string pfname) { - get { return _Title; } // used for pdf outline - set { _Title = value; } - } - private int _PageCount; // number of pages in the particular pdf, to aid in determining total page count for merged pdf - public int PageCount - { - get { return _PageCount; } - set { _PageCount = value; } - } - private string _PdfFileName; // used for finding the procedure's pdf file to merge - public string PdfFileName - { - get { return _PdfFileName; } - set { _PdfFileName = value; } - } - private bool _FirstPageNoPageNum = false; - public bool FirstPageNoPageNum - { - get { return _FirstPageNoPageNum; } - set { _FirstPageNoPageNum = value; } - } - public MergedPdfProc(string title, string pfname) - { - _Title = title; - _PdfFileName = pfname; + Title = title; + PdfFileName = pfname; } } // this class will manage the data & do subsequent merging of pdf files. It is used if the user @@ -49,25 +29,11 @@ namespace Volian.Print.Library public class MergedPdf { private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); - private List _mergedPdfs = null; // This list has all procedure pdfs that will be included in the merged file. - public List MergedPdfs - { - get { return _mergedPdfs; } - set { _mergedPdfs = value; } - } - string _mergedFileName = null; // this is the name to be given the merged file - public string MergedFileName - { - get { return _mergedFileName; } - set { _mergedFileName = value; } - } - private string _folder; // this is folder to create the merged file in - public string Folder - { - get { return _folder; } - set { _folder = value; } - } - private DocVersionInfo _docVersionInfo; + + public List MergedPdfs { get; set; } = null; + public string MergedFileName { get; set; } = null; + public string Folder { get; set; } + private readonly DocVersionInfo _docVersionInfo; private string _pageof = null; private iTextSharp.text.Font _itextFont = null; private MergedPdfsPageNumCorner _corner; @@ -80,11 +46,11 @@ namespace Volian.Print.Library // the following constructs the class that contains data for merging a group of pdfs. public MergedPdf(string folder, DocVersionInfo dvi) { - _folder = folder; + Folder = folder; _docVersionInfo = dvi; } // the following merges the procedure pdfs into a single pdf - public bool DoTheMerge(Dictionary> MergedLandscapPages, bool generatePointListFile) + public bool DoTheMerge(bool generatePointListFile) { if (MergedPdfs == null) { @@ -93,7 +59,7 @@ namespace Volian.Print.Library } iTextSharp.text.Document doc = new iTextSharp.text.Document(); string slashReplace = _docVersionInfo.ActiveFormat.PlantFormat.FormatData.PrintData.SlashReplace ?? "_"; - MergedFileName = _folder + @"\" + _docVersionInfo.MyFolder.Name.Replace("/", slashReplace).Replace("\\", slashReplace) + ".pdf"; + MergedFileName = Folder + @"\" + _docVersionInfo.MyFolder.Name.Replace("/", slashReplace).Replace("\\", slashReplace) + ".pdf"; MergedFileName = ItemInfo.StripRtfFormatting(MergedFileName); // C2021-063 file name of Alarm Point List file containing Serial Number, Title, and merged Page Number StreamWriter sw = null; @@ -109,12 +75,12 @@ namespace Volian.Print.Library { writer = PdfWriter.GetInstance(doc, new FileStream(MergedFileName, FileMode.Create)); } - catch (Exception ex) - { + catch (Exception) + { StringBuilder sb = new StringBuilder(); sb.AppendLine("Could not create"); sb.AppendLine(); - sb.AppendLine(MergedFileName + "."); + sb.AppendLine($"{MergedFileName}."); sb.AppendLine(); sb.AppendLine("If it is open, close and retry."); FlexibleMessageBox.Show(sb.ToString(), "Error on CreatePdf", MessageBoxButtons.OK, MessageBoxIcon.Warning); @@ -136,7 +102,7 @@ namespace Volian.Print.Library // write Serial Number, Title, and Page Number in the Point List file sw.WriteLine("{0}\t{1}\t{2}", idxSerialNum++, mpp.Title, mergedPageNumber + 1); } - string pdffilename = _folder + @"\" + mpp.PdfFileName; + string pdffilename = $@"{Folder}\{mpp.PdfFileName}"; if (!File.Exists(pdffilename)) { FlexibleMessageBox.Show("Error in finding pdf files to merge. Cannot print with date/time as part of pdf name. Or check that individual pdfs were generated.", "Error on CreatePdf", MessageBoxButtons.OK, MessageBoxIcon.Warning); @@ -154,7 +120,7 @@ namespace Volian.Print.Library PdfReader reader = null; try // B2019-041: added a try/catch for when a corrupt pdf was created for a procedure, just skip & add message to error log. { - reader = new PdfReader(_folder + @"\" + mpp.PdfFileName); + reader = new PdfReader($@"{Folder}\{mpp.PdfFileName}"); int numPages = reader.NumberOfPages; int currentPageNumber = 0; PdfOutline outline = null; @@ -178,7 +144,7 @@ namespace Volian.Print.Library // if on the first page, add the pdfname & title as part of outline. If on remaining pages, just put out page number. // Later this may need expanded to put sections/steps/etc. if (currentPageNumber == 1) - outline = new PdfOutline(canvas.RootOutline, dest, mpp.PdfFileName.Replace(".pdf", "") + " - " + mpp.Title, false); + outline = new PdfOutline(canvas.RootOutline, dest, $"{mpp.PdfFileName.Replace(".pdf", "")} - {mpp.Title}", false); else new PdfOutline(outline, dest, "Page " + currentPageNumber.ToString(), false); canvas.AddTemplate(page, 0, 0); // adds the page to the combined pdf @@ -204,17 +170,13 @@ namespace Volian.Print.Library private void AddPageNumberToPage(PdfImportedPage page, PdfContentByte cb, string outputpage, bool landscape) { float pgright = page.BoundingBox.Right; - float pgleft = page.BoundingBox.Left; float pgtop = page.BoundingBox.Top; - float pgbot = page.BoundingBox.Bottom; MergedPdfsPageNumCorner cnr = _corner; // C2021-047: Allow for setting of Merged Pdf Landscape Page Number Location // B2019-152: Landscape page numbers when merging if (landscape) { pgright = page.BoundingBox.Top; - pgleft = page.BoundingBox.Bottom; pgtop = page.BoundingBox.Right; - pgbot = page.BoundingBox.Left; cnr = _landcorner; // C2021-047: Allow for setting of Merged Pdf Landscape Page Number Location } Phrase ph = new Phrase(); @@ -281,7 +243,7 @@ namespace Volian.Print.Library private bool GetPageOfInfo() { DocVersionConfig dvc = (DocVersionConfig) _docVersionInfo.MyConfig; - MergedPdfsPageOf po = dvc.Print_MergedPdfsPageOf; + _ = dvc.Print_MergedPdfsPageOf; string tmp = EnumDescConverter.GetEnumDescription((Enum)dvc.Print_MergedPdfsPageOf); if (tmp == "None") return false; // no page number, return false so no page number is put out. @@ -297,7 +259,7 @@ namespace Volian.Print.Library famtmp = _docVersionInfo.ActiveFormat.PlantFormat.FormatData.Font.Family; } tmp = dvc.Print_MergedPdfsPageNumFontSize; - float? tmpi=0; + float? tmpi; if (tmp == null || tmp == "") { // use the default from the format from this working draft diff --git a/PROMS/Volian.Print.Library/PDFChronologyReport.cs b/PROMS/Volian.Print.Library/PDFChronologyReport.cs index 73e7ca1e..c2f5c13c 100644 --- a/PROMS/Volian.Print.Library/PDFChronologyReport.cs +++ b/PROMS/Volian.Print.Library/PDFChronologyReport.cs @@ -26,36 +26,17 @@ namespace Volian.Print.Library return _AnnotationLookup; } } - private string _FileName; - public string FileName + + public string FileName { get; set; } + public ProcedureInfo MyProc { get; set; } + public ContentAuditInfoList AuditList { get; set; } + public AnnotationAuditInfoList AnnotationList { get; set; } + public PDFChronologyReport(string fileName, ProcedureInfo myProc, ContentAuditInfoList auditList, AnnotationAuditInfoList annotationList) { - get { return _FileName; } - set { _FileName = value; } - } - private ProcedureInfo _MyProc; - public ProcedureInfo MyProc - { - get { return _MyProc; } - set { _MyProc = value; } - } - private ContentAuditInfoList _AuditList; - public ContentAuditInfoList AuditList - { - get { return _AuditList; } - set { _AuditList = value; } - } - private AnnotationAuditInfoList _AnnotationList; - public AnnotationAuditInfoList AnnotationList - { - get { return _AnnotationList; } - set { _AnnotationList = value; } - } - public PDFChronologyReport(string fileName, ProcedureInfo myProc, ContentAuditInfoList auditList, AnnotationAuditInfoList annotationList) - { - _FileName = fileName; - _MyProc = myProc; - _AuditList = auditList; - _AnnotationList = annotationList; + FileName = fileName; + MyProc = myProc; + AuditList = auditList; + AnnotationList = annotationList; } public void BuildChronology() { @@ -68,7 +49,6 @@ namespace Volian.Print.Library } catch (Exception ex) { - StringBuilder msg = new StringBuilder(); document.Add(new Paragraph("Error:")); while (ex != null) { @@ -82,28 +62,22 @@ namespace Volian.Print.Library if (document.IsOpen()) { document.Close(); - System.Diagnostics.Process.Start(_FileName); + System.Diagnostics.Process.Start(FileName); } } } - public void BuildSummary() + public void BuildSummary() => BuildSummary(true); + public void BuildSummary(bool openReport) { - BuildSummary(true); - } - public void BuildSummary(bool openReport) - { - bool hasData = false; Rectangle paperSize = PDFPageSize.UsePaperSize(MyProc.ActiveFormat.PlantFormat.FormatData.PDFPageSize.PaperSize); // C2020-002 paper size is now set in the format files iTextSharp.text.Document document = new iTextSharp.text.Document(paperSize, 36, 36, 36, 36); if (!CreateResultsPDF(document)) return; try { BuildSummaryReport(document); - //BuildSummaryReport2(document); } catch (Exception ex) { - StringBuilder msg = new StringBuilder(); document.Add(new Paragraph("Error:")); while (ex != null) { @@ -118,7 +92,7 @@ namespace Volian.Print.Library { document.Close(); if(openReport) - System.Diagnostics.Process.Start(_FileName); + System.Diagnostics.Process.Start(FileName); } } } @@ -129,12 +103,12 @@ namespace Volian.Print.Library int i = 0; // just for safety, the while loop expects to find a file extension // so make sure it has one before going into the loop - if (!_FileName.ToUpper().EndsWith(".PDF")) - _FileName += ".pdf"; + if (!FileName.ToUpper().EndsWith(".PDF")) + FileName += ".pdf"; // Try to open a file for creating the PDF. while (result == false) { - string fileName = _FileName; + string fileName = FileName; // Bug fix: B2013-086 // the folder path part of _FileName contained a folder name with a period // resulting is an invalid file location/file name. @@ -143,12 +117,10 @@ namespace Volian.Print.Library int loc = fileName.LastIndexOf("."); if (loc > -1) { - string fname = fileName.Substring(0, loc); - fileName = fname + suffix + ".pdf"; + fileName = $"{fileName.Substring(0, loc)}{suffix}.pdf"; } else - fileName = fileName + suffix + ".pdf"; -// string fileName = _FileName.ToLower().Replace(".pdf", suffix + ".pdf"); + fileName = $"{fileName}{suffix}.pdf"; try { PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(fileName, FileMode.Create)); @@ -157,7 +129,7 @@ namespace Volian.Print.Library writer.PageEvent = new MyPageHelper("Procedure Changes"); document.SetMargins(36, 36, 36, 36); document.Open(); - _FileName = fileName; + FileName = fileName; result = true; } catch (System.IO.IOException exIO) @@ -196,51 +168,59 @@ namespace Volian.Print.Library } private PdfPCell BlankCell(int colSpan) { - PdfPCell c = new PdfPCell(); - c.Colspan = colSpan; - c.Border = 0; - return c; + PdfPCell c = new PdfPCell + { + Colspan = colSpan, + Border = 0 + }; + return c; } private void BuildChronologyReport(iTextSharp.text.Document doc) { int lastAnnotationID = 0; int cols = 5; - int borders = 0; int paddingBottom = 6; - PdfPTable t = new PdfPTable(cols); - t.HeaderRows = 4; - t.DefaultCell.Padding = 4; + PdfPTable t = new PdfPTable(cols) + { + HeaderRows = 4 + }; + t.DefaultCell.Padding = 4; t.WidthPercentage = 100; float[] widths = new float[] { 1f, 1f, 1f, 1f, 4f }; t.SetWidths(widths); - //t.HorizontalAlignment = 0; // C2017-036 get best available proportional font for symbols that looks close to Arial // Note that Microsoft no longer supplies Arial Unicode MS as of Word16 iTextSharp.text.Font f1 = pdf.GetFont(Volian.Base.Library.vlnFont.ReportsFont, 14, 1, Color.BLACK); iTextSharp.text.Font f2 = pdf.GetFont(Volian.Base.Library.vlnFont.ReportsFont, 10, 0, Color.BLACK); iTextSharp.text.Font f3 = pdf.GetFont(Volian.Base.Library.vlnFont.ReportsFont, 9, 0, Color.BLACK); iTextSharp.text.Font f4 = pdf.GetFont(Volian.Base.Library.vlnFont.ReportsFont, 9, 1, Color.BLACK); - //report title - Phrase h = new Phrase(); - h.Font = f1; - h.Add("Chronology of Changes Report"); - PdfPCell c = new PdfPCell(h); - c.Colspan = cols; - c.HorizontalAlignment = Element.ALIGN_CENTER; - c.PaddingBottom = paddingBottom; - //c.Border = borders; - t.AddCell(c); + //report title + Phrase h = new Phrase + { + Font = f1 + }; + h.Add("Chronology of Changes Report"); + PdfPCell c = new PdfPCell(h) + { + Colspan = cols, + HorizontalAlignment = Element.ALIGN_CENTER, + PaddingBottom = paddingBottom + }; + t.AddCell(c); t.AddCell(BlankCell(cols)); - //procedure title - h = new Phrase(); - h.Font = f2; - h.Add(string.Format("{0} - {1}", MyProc.DisplayNumber, MyProc.DisplayText)); - c = new PdfPCell(h); - c.Colspan = cols; - c.HorizontalAlignment = Element.ALIGN_LEFT; - c.PaddingBottom = paddingBottom; - //c.Border = borders; - t.AddCell(c); + //procedure title + h = new Phrase + { + Font = f2 + }; + h.Add(string.Format("{0} - {1}", MyProc.DisplayNumber, MyProc.DisplayText)); + c = new PdfPCell(h) + { + Colspan = cols, + HorizontalAlignment = Element.ALIGN_LEFT, + PaddingBottom = paddingBottom + }; + t.AddCell(c); t.AddCell(BlankCell(cols)); string section = string.Empty; string stepnum = string.Empty; @@ -249,7 +229,6 @@ namespace Volian.Print.Library ContentAuditInfo oldCAI = null; string oldText = string.Empty; string oldTypeName = string.Empty; -// Dictionary processedAAI = new Dictionary(); Dictionary processedAAI = new Dictionary(); foreach (ContentAuditInfo cai in AuditList) { @@ -259,15 +238,18 @@ namespace Volian.Print.Library { AddStepAnnotation(ref lastAnnotationID, cols, paddingBottom, t, f3, f4, ref h, ref c, oldCAI, processedAAI); section = NewPath[0]; - h = new Phrase(); - h.Font = f4; - h.Add(section); - c = new PdfPCell(h); - c.Colspan = cols; - c.HorizontalAlignment = Element.ALIGN_LEFT; - c.PaddingBottom = paddingBottom; - //c.Border = borders; - t.AddCell(c); + h = new Phrase + { + Font = f4 + }; + h.Add(section); + c = new PdfPCell(h) + { + Colspan = cols, + HorizontalAlignment = Element.ALIGN_LEFT, + PaddingBottom = paddingBottom + }; + t.AddCell(c); t.AddCell(BlankCell(cols)); } //step @@ -286,16 +268,19 @@ namespace Volian.Print.Library // This was happening when we were reporting change information of a section number/title if (stepnum2 != "") { - h = new Phrase(); - h.Font = f3; - h.Add(string.Format("Step {0}", stepnum2)); - c = new PdfPCell(h); - c.Colspan = 1; - c.HorizontalAlignment = Element.ALIGN_RIGHT; - c.PaddingBottom = paddingBottom; - c.PaddingRight = 10; - //c.Border = borders; - t.AddCell(c); + h = new Phrase + { + Font = f3 + }; + h.Add(string.Format("Step {0}", stepnum2)); + c = new PdfPCell(h) + { + Colspan = 1, + HorizontalAlignment = Element.ALIGN_RIGHT, + PaddingBottom = paddingBottom, + PaddingRight = 10 + }; + t.AddCell(c); } else t.AddCell(BlankCell(1)); @@ -304,44 +289,51 @@ namespace Volian.Print.Library t.AddCell(BlankCell(1)); //what if (cai.ContentID != lastID) maxDTS = DateTime.MinValue; - h = new Phrase(); - h.Font = f3; - string actionWhat = (cai.ActionWhat == "Added" && cai.DTS <= MyProc.ChangeBarDate) ? "Original" : cai.ActionWhat != "Changed" ? cai.ActionWhat : cai.DTS <= maxDTS ? "Restored" : cai.DTS > MyProc.ChangeBarDate ? cai.ActionWhat : "Original"; + h = new Phrase + { + Font = f3 + }; + string actionWhat = (cai.ActionWhat == "Added" && cai.DTS <= MyProc.ChangeBarDate) ? "Original" : cai.ActionWhat != "Changed" ? cai.ActionWhat : cai.DTS <= maxDTS ? "Restored" : cai.DTS > MyProc.ChangeBarDate ? cai.ActionWhat : "Original"; if (actionWhat == "Deleted" || actionWhat == "Restored") - h.Add(actionWhat + "\r\n" + (cai.ActionWhen < cai.DTS ? cai.DTS.ToString("M/dd/yyyy") : cai.ActionWhen.ToString())); + h.Add($"{actionWhat}\r\n{(cai.ActionWhen < cai.DTS ? cai.DTS.ToString("M/dd/yyyy") : cai.ActionWhen.ToString())}"); else h.Add(actionWhat); if (cai.DTS > maxDTS) maxDTS = cai.DTS; lastID = cai.ContentID; - c = new PdfPCell(h); - c.Colspan = 1; - c.HorizontalAlignment = Element.ALIGN_CENTER; - c.PaddingBottom = paddingBottom; - //c.Border = borders; - t.AddCell(c); - //who - h = new Phrase(); - h.Font = f3; - h.Add(cai.UserID); - c = new PdfPCell(h); - c.Colspan = 1; - c.HorizontalAlignment = Element.ALIGN_CENTER; - c.PaddingBottom = paddingBottom; - //c.Border = borders; - t.AddCell(c); - //when - h = new Phrase(); - h.Font = f3; - h.Add(cai.DTS.ToString()); - c = new PdfPCell(h); - c.Colspan = 1; - c.HorizontalAlignment = Element.ALIGN_CENTER; - c.PaddingBottom = paddingBottom; - //c.Border = borders; - t.AddCell(c); - //new text - //h.Add(cai.Text); + c = new PdfPCell(h) + { + Colspan = 1, + HorizontalAlignment = Element.ALIGN_CENTER, + PaddingBottom = paddingBottom + }; + t.AddCell(c); + //who + h = new Phrase + { + Font = f3 + }; + h.Add(cai.UserID); + c = new PdfPCell(h) + { + Colspan = 1, + HorizontalAlignment = Element.ALIGN_CENTER, + PaddingBottom = paddingBottom + }; + t.AddCell(c); + //when + h = new Phrase + { + Font = f3 + }; + h.Add(cai.DTS.ToString()); + c = new PdfPCell(h) + { + Colspan = 1, + HorizontalAlignment = Element.ALIGN_CENTER, + PaddingBottom = paddingBottom + }; + t.AddCell(c); if (cai.Type == 20008) { GridAuditInfoList gail = GridAuditInfoList.Get(cai.ContentID); @@ -351,7 +343,6 @@ namespace Volian.Print.Library GridAuditInfo gai = gail[0]; System.Xml.XmlDocument xd = new System.Xml.XmlDocument(); xd.LoadXml(gai.Data); - //int grows = int.Parse(xd.SelectSingleNode("C1FlexGrid/RowInfo/Count").InnerText); int gcols = int.Parse(xd.SelectSingleNode("C1FlexGrid/ColumnInfo/Count").InnerText); string data = ItemInfo.ConvertToDisplayText(cai.Text); PdfPTable gtbl = new PdfPTable(gcols); @@ -363,9 +354,11 @@ namespace Volian.Print.Library addedInfo = true; string val = data.Substring(0, data.IndexOf(";")); data = data.Substring(data.IndexOf(";") + 1); - Phrase hh = new Phrase(); - hh.Font = f4; - hh.Add(val); + Phrase hh = new Phrase + { + Font = f4 + }; + hh.Add(val); PdfPCell cc = new PdfPCell(hh); gtbl.AddCell(cc); } @@ -375,17 +368,21 @@ namespace Volian.Print.Library // If added info above, i.e. no error, put out the cell if (addedInfo) { - c = new PdfPCell(gtbl); - c.Colspan = cols - 4; - c.HorizontalAlignment = Element.ALIGN_LEFT; - t.AddCell(c); + c = new PdfPCell(gtbl) + { + Colspan = cols - 4, + HorizontalAlignment = Element.ALIGN_LEFT + }; + t.AddCell(c); } } if (!addedInfo) // Didn't add info, report that data not available { - h = new Phrase(); - h.Font = f4; - c = new PdfPCell(h); + h = new Phrase + { + Font = f4 + }; + c = new PdfPCell(h); h.Add("No Audit Details Available"); c.Colspan = cols - 4; c.HorizontalAlignment = Element.ALIGN_LEFT; @@ -395,12 +392,14 @@ namespace Volian.Print.Library } else { - h = new Phrase(); - h.Font = f4; - if (cai.Text != oldText && cai.TypeName != oldTypeName) - h.Add(string.Format("[Type Change {0} to {1}] - {2}", oldTypeName, cai.TypeName, ItemInfo.ConvertToDisplayText(cai.Text)));// + " to " + cai.TypeName); + h = new Phrase + { + Font = f4 + }; + if (cai.Text != oldText && cai.TypeName != oldTypeName) + h.Add(string.Format("[Type Change {0} to {1}] - {2}", oldTypeName, cai.TypeName, ItemInfo.ConvertToDisplayText(cai.Text))); else if (cai.Text == oldText && cai.TypeName != oldTypeName) - h.Add(oldTypeName + " to " + cai.TypeName); + h.Add($"{oldTypeName} to {cai.TypeName}"); else { string txt = null; @@ -450,22 +449,14 @@ namespace Volian.Print.Library oldCAI = cai; oldText = cai.Text; oldTypeName = cai.TypeName; - c = new PdfPCell(h); - c.Colspan = cols - 4; - c.HorizontalAlignment = Element.ALIGN_LEFT; - c.PaddingBottom = paddingBottom; - //c.Border = borders; - t.AddCell(c); + c = new PdfPCell(h) + { + Colspan = cols - 4, + HorizontalAlignment = Element.ALIGN_LEFT, + PaddingBottom = paddingBottom + }; + t.AddCell(c); } - ////old text - //t.AddCell(BlankCell(3)); - //h = new Phrase(); - //h.Font = f4; - //h.Add("Old text: " + cai.OldText); - //c = new PdfPCell(h); - //c.Colspan = 7; - //c.Border = 0; - //t.AddCell(c); } //see if any annotations for old stepnum here and add them foreach (AnnotationAuditInfo aai in AnnotationList) @@ -473,57 +464,67 @@ namespace Volian.Print.Library if (oldCAI != null && aai.IContentID == oldCAI.ContentID) { //add annotation to minilist -// processedAAI.Add(aai.AnnotationID, aai); if (!processedAAI.ContainsKey(aai)) // bug fix, only add to the processed list if it is not already in the list processedAAI.Add(aai, aai); //write row to table t.AddCell(BlankCell(1)); - h = new Phrase(); - h.Font = f3; - if (aai.AnnotationID != lastAnnotationID) + h = new Phrase + { + Font = f3 + }; + if (aai.AnnotationID != lastAnnotationID) { lastAnnotationID = aai.AnnotationID; - h.Add(AnnotationLookup[aai.TypeID] + " " + aai.ActionWhat); + h.Add($"{AnnotationLookup[aai.TypeID]} {aai.ActionWhat}"); } else h.Add(aai.ActionWhat); - c = new PdfPCell(h); - c.Colspan = 1; - c.HorizontalAlignment = Element.ALIGN_CENTER; - c.PaddingBottom = paddingBottom; - //c.Border = borders; - t.AddCell(c); - //who - h = new Phrase(); - h.Font = f3; - h.Add(aai.UserID); - c = new PdfPCell(h); - c.Colspan = 1; - c.HorizontalAlignment = Element.ALIGN_CENTER; - c.PaddingBottom = paddingBottom; - //c.Border = borders; - t.AddCell(c); - //when - h = new Phrase(); - h.Font = f3; - h.Add(aai.ActionWhen.ToString()); - c = new PdfPCell(h); - c.Colspan = 1; - c.HorizontalAlignment = Element.ALIGN_CENTER; - c.PaddingBottom = paddingBottom; - //c.Border = borders; - t.AddCell(c); - //new text - h = new Phrase(); - h.Font = f4; - //h.Add(cai.Text); - h.Add(ItemInfo.ConvertToDisplayText(aai.SearchText)); - c = new PdfPCell(h); - c.Colspan = cols - 4; - c.HorizontalAlignment = Element.ALIGN_LEFT; - c.PaddingBottom = paddingBottom; - //c.Border = borders; - t.AddCell(c); + c = new PdfPCell(h) + { + Colspan = 1, + HorizontalAlignment = Element.ALIGN_CENTER, + PaddingBottom = paddingBottom + }; + t.AddCell(c); + //who + h = new Phrase + { + Font = f3 + }; + h.Add(aai.UserID); + c = new PdfPCell(h) + { + Colspan = 1, + HorizontalAlignment = Element.ALIGN_CENTER, + PaddingBottom = paddingBottom + }; + t.AddCell(c); + //when + h = new Phrase + { + Font = f3 + }; + h.Add(aai.ActionWhen.ToString()); + c = new PdfPCell(h) + { + Colspan = 1, + HorizontalAlignment = Element.ALIGN_CENTER, + PaddingBottom = paddingBottom + }; + t.AddCell(c); + //new text + h = new Phrase + { + Font = f4 + }; + h.Add(ItemInfo.ConvertToDisplayText(aai.SearchText)); + c = new PdfPCell(h) + { + Colspan = cols - 4, + HorizontalAlignment = Element.ALIGN_LEFT, + PaddingBottom = paddingBottom + }; + t.AddCell(c); } } bool annotationHeader = false; @@ -531,21 +532,23 @@ namespace Volian.Print.Library stepnum = string.Empty; foreach (AnnotationAuditInfo aai in AnnotationList) { -// if (!processedAAI.ContainsKey(aai.AnnotationID)) if (!processedAAI.ContainsKey(aai)) { if (!annotationHeader) { t.AddCell(BlankCell(cols)); - h = new Phrase(); - h.Font = f4; - h.Add("ANNOTATIONS"); - c = new PdfPCell(h); - c.Colspan = cols; - c.HorizontalAlignment = Element.ALIGN_LEFT; - c.PaddingBottom = paddingBottom; - //c.Border = borders; - t.AddCell(c); + h = new Phrase + { + Font = f4 + }; + h.Add("ANNOTATIONS"); + c = new PdfPCell(h) + { + Colspan = cols, + HorizontalAlignment = Element.ALIGN_LEFT, + PaddingBottom = paddingBottom + }; + t.AddCell(c); t.AddCell(BlankCell(cols)); annotationHeader = true; } @@ -554,90 +557,109 @@ namespace Volian.Print.Library { section = NewPath[0]; stepnum = string.Empty; - h = new Phrase(); - h.Font = f4; - h.Add(section); - c = new PdfPCell(h); - c.Colspan = cols; - c.HorizontalAlignment = Element.ALIGN_LEFT; - c.PaddingBottom = paddingBottom; - //c.Border = borders; - t.AddCell(c); + h = new Phrase + { + Font = f4 + }; + h.Add(section); + c = new PdfPCell(h) + { + Colspan = cols, + HorizontalAlignment = Element.ALIGN_LEFT, + PaddingBottom = paddingBottom + }; + t.AddCell(c); } if (NewPath[1] != stepnum) { stepnum = NewPath[1]; string stepnum2 = Regex.Replace(stepnum, "([0-9])[.]([A-Za-z])", "$1 $2"); stepnum2 = stepnum2.Replace("RNO.", "RNO"); - h = new Phrase(); - h.Font = f3; - h.Add(string.Format("Step {0}", stepnum2)); - c = new PdfPCell(h); - c.Colspan = 1; - c.HorizontalAlignment = Element.ALIGN_RIGHT; - c.PaddingBottom = paddingBottom; - c.PaddingRight = 10; - //c.Border = borders; - t.AddCell(c); + h = new Phrase + { + Font = f3 + }; + h.Add(string.Format("Step {0}", stepnum2)); + c = new PdfPCell(h) + { + Colspan = 1, + HorizontalAlignment = Element.ALIGN_RIGHT, + PaddingBottom = paddingBottom, + PaddingRight = 10 + }; + t.AddCell(c); } else { t.AddCell(BlankCell(1)); } - //what - h = new Phrase(); - h.Font = f3; - if (aai.AnnotationID != lastAnnotationID) + //what + h = new Phrase + { + Font = f3 + }; + if (aai.AnnotationID != lastAnnotationID) { lastAnnotationID = aai.AnnotationID; - h.Add(AnnotationLookup[aai.TypeID] + " " + aai.ActionWhat); + h.Add($"{AnnotationLookup[aai.TypeID]} {aai.ActionWhat}"); } else h.Add(aai.ActionWhat); - c = new PdfPCell(h); - c.Colspan = 1; - c.HorizontalAlignment = Element.ALIGN_CENTER; - c.PaddingBottom = paddingBottom; - //c.Border = borders; - t.AddCell(c); - //who - h = new Phrase(); - h.Font = f3; - h.Add(aai.UserID); - c = new PdfPCell(h); - c.Colspan = 1; - c.HorizontalAlignment = Element.ALIGN_CENTER; - c.PaddingBottom = paddingBottom; - //c.Border = borders; - t.AddCell(c); - //when - h = new Phrase(); - h.Font = f3; - h.Add(aai.ActionWhen.ToString()); - c = new PdfPCell(h); - c.Colspan = 1; - c.HorizontalAlignment = Element.ALIGN_CENTER; - c.PaddingBottom = paddingBottom; - //c.Border = borders; - t.AddCell(c); - //new text - h = new Phrase(); - h.Font = f4; - //h.Add(cai.Text); - h.Add(ItemInfo.ConvertToDisplayText(aai.SearchText)); - c = new PdfPCell(h); - c.Colspan = cols - 4; - c.HorizontalAlignment = Element.ALIGN_LEFT; - c.PaddingBottom = paddingBottom; - //c.Border = borders; - t.AddCell(c); + c = new PdfPCell(h) + { + Colspan = 1, + HorizontalAlignment = Element.ALIGN_CENTER, + PaddingBottom = paddingBottom + }; + t.AddCell(c); + //who + h = new Phrase + { + Font = f3 + }; + h.Add(aai.UserID); + c = new PdfPCell(h) + { + Colspan = 1, + HorizontalAlignment = Element.ALIGN_CENTER, + PaddingBottom = paddingBottom + }; + t.AddCell(c); + //when + h = new Phrase + { + Font = f3 + }; + h.Add(aai.ActionWhen.ToString()); + c = new PdfPCell(h) + { + Colspan = 1, + HorizontalAlignment = Element.ALIGN_CENTER, + PaddingBottom = paddingBottom + }; + t.AddCell(c); + //new text + h = new Phrase + { + Font = f4 + }; + h.Add(ItemInfo.ConvertToDisplayText(aai.SearchText)); + c = new PdfPCell(h) + { + Colspan = cols - 4, + HorizontalAlignment = Element.ALIGN_LEFT, + PaddingBottom = paddingBottom + }; + t.AddCell(c); } } if (t.Rows.Count == t.HeaderRows) { - c = new PdfPCell(new Phrase("No changes to report")); - c.Colspan = cols; - t.AddCell(c); + c = new PdfPCell(new Phrase("No changes to report")) + { + Colspan = cols + }; + t.AddCell(c); } doc.Add(t); } @@ -650,66 +672,75 @@ namespace Volian.Print.Library if (oldCAI != null && aai.IContentID == oldCAI.ContentID) { //add annotation to minilist - // processedAAI.Add(aai.AnnotationID, aai); if(processedAAI.ContainsKey(aai)) return; processedAAI.Add(aai, aai); //write row to table t.AddCell(BlankCell(1)); - h = new Phrase(); - h.Font = f3; - if (aai.AnnotationID != lastAnnotationID) + h = new Phrase + { + Font = f3 + }; + if (aai.AnnotationID != lastAnnotationID) { lastAnnotationID = aai.AnnotationID; - h.Add(AnnotationLookup[aai.TypeID] + " " + aai.ActionWhat); + h.Add($"{AnnotationLookup[aai.TypeID]} {aai.ActionWhat}"); } else h.Add(aai.ActionWhat); - c = new PdfPCell(h); - c.Colspan = 1; - c.HorizontalAlignment = Element.ALIGN_CENTER; - c.PaddingBottom = paddingBottom; - //c.Border = borders; - t.AddCell(c); - //who - h = new Phrase(); - h.Font = f3; - h.Add(aai.UserID); - c = new PdfPCell(h); - c.Colspan = 1; - c.HorizontalAlignment = Element.ALIGN_CENTER; - c.PaddingBottom = paddingBottom; - //c.Border = borders; - t.AddCell(c); - //when - h = new Phrase(); - h.Font = f3; - h.Add(aai.ActionWhen.ToString()); - c = new PdfPCell(h); - c.Colspan = 1; - c.HorizontalAlignment = Element.ALIGN_CENTER; - c.PaddingBottom = paddingBottom; - //c.Border = borders; - t.AddCell(c); - //new text - h = new Phrase(); - h.Font = f4; - //h.Add(cai.Text); - h.Add(ItemInfo.ConvertToDisplayText(aai.SearchText)); - c = new PdfPCell(h); - c.Colspan = cols - 4; - c.HorizontalAlignment = Element.ALIGN_LEFT; - c.PaddingBottom = paddingBottom; - //c.Border = borders; - t.AddCell(c); + c = new PdfPCell(h) + { + Colspan = 1, + HorizontalAlignment = Element.ALIGN_CENTER, + PaddingBottom = paddingBottom + }; + t.AddCell(c); + //who + h = new Phrase + { + Font = f3 + }; + h.Add(aai.UserID); + c = new PdfPCell(h) + { + Colspan = 1, + HorizontalAlignment = Element.ALIGN_CENTER, + PaddingBottom = paddingBottom + }; + t.AddCell(c); + //when + h = new Phrase + { + Font = f3 + }; + h.Add(aai.ActionWhen.ToString()); + c = new PdfPCell(h) + { + Colspan = 1, + HorizontalAlignment = Element.ALIGN_CENTER, + PaddingBottom = paddingBottom + }; + t.AddCell(c); + //new text + h = new Phrase + { + Font = f4 + }; + h.Add(ItemInfo.ConvertToDisplayText(aai.SearchText)); + c = new PdfPCell(h) + { + Colspan = cols - 4, + HorizontalAlignment = Element.ALIGN_LEFT, + PaddingBottom = paddingBottom + }; + t.AddCell(c); } } } private static string[] SplitPath(string path) { // Remove Procedure Number and Title - string sectionAndStep = Regex.Replace(path + "\x7\x7\x7", "^.+?\\u0007", ""); - //sectionAndStep = sectionAndStep.Replace("\x11", sectionAndStep[0] == '\x11' ? "" : " - "); + string sectionAndStep = Regex.Replace($"{path}\x7\x7\x7", "^.+?\\u0007", ""); sectionAndStep = sectionAndStep.Replace("\x11", sectionAndStep[0] == '\x11' ? "" : " "); sectionAndStep = sectionAndStep.Replace("\\u160?", " "); // replace a hardspace with a space // Split Section frrom Steps @@ -729,327 +760,15 @@ namespace Volian.Print.Library } return "Section\x7Step".Split("\x7".ToCharArray()); } - private void BuildSummaryReport2(iTextSharp.text.Document doc) - { - string section = string.Empty; - string stepnum = string.Empty; - ContentAuditInfo firstCAI = null; - ContentAuditInfo nextCAI = null; - ContentAuditInfo lastCAI = null; - List auditList = new List(); - foreach (ContentAuditInfo cai in AuditList) - { - string[] NewPath = SplitPath(cai.Path); - if (NewPath[1] != stepnum) - { - stepnum = NewPath[1]; - if (firstCAI != null) - { - if (lastCAI == null) - { - auditList.Add(firstCAI); - } - else if (lastCAI.ActionWhat == "Deleted" && firstCAI.DTS < MyProc.ChangeBarDate) - { - auditList.Add(lastCAI); - } - else if (lastCAI.ActionWhat == "Changed" && lastCAI.Text != firstCAI.Text) - { - auditList.Add(firstCAI); - auditList.Add(lastCAI); - } - else if (lastCAI.ActionWhat == "Changed" && firstCAI.ActionWhat == "Added" && lastCAI.Text == firstCAI.Text) - { - auditList.Add(firstCAI); - } - else if (lastCAI == null && firstCAI.ActionWhat == "Added") - { - auditList.Add(firstCAI); - } - lastCAI = null; - } - firstCAI = cai; - } - else - { - lastCAI = cai; - } - } - if (firstCAI != null) - auditList.Add(firstCAI); - if (lastCAI != null) - auditList.Add(lastCAI); - #region annotations - AnnotationAuditInfo firstAAI = null; - AnnotationAuditInfo nextAAI = null; - AnnotationAuditInfo lastAAI = null; - int icontentID = 0; - List annotationList = new List(); - foreach (AnnotationAuditInfo aai in AnnotationList) - { - if (aai.IContentID != icontentID) - { - icontentID = aai.IContentID; - if (firstAAI != null) - { - if (lastAAI == null) - { - annotationList.Add(firstAAI); - } - else if (lastAAI.ActionWhat == "Deleted" && firstAAI.DTS < MyProc.ChangeBarDate) - { - annotationList.Add(lastAAI); - } - else if (lastAAI.ActionWhat == "Changed" && lastAAI.SearchText != firstAAI.SearchText) - { - annotationList.Add(firstAAI); - annotationList.Add(lastAAI); - } - else if (lastAAI.ActionWhat == "Changed" && firstAAI.ActionWhat == "Added" && lastAAI.SearchText == firstAAI.SearchText) - { - annotationList.Add(firstAAI); - } - else if (lastAAI == null && firstAAI.ActionWhat == "Added") - { - annotationList.Add(firstAAI); - } - lastAAI = null; - } - firstAAI = aai; - } - else - lastAAI = aai; - } - if (firstAAI != null) - annotationList.Add(firstAAI); - if (lastAAI != null) - annotationList.Add(lastAAI); - #endregion - int cols = 5; - int borders = 0; - int paddingBottom = 6; - PdfPTable t = new PdfPTable(cols); - t.HeaderRows = 4; - t.DefaultCell.Padding = 4; - t.WidthPercentage = 100; - float[] widths = new float[] { 1f, 1f, 1f, 1f, 4f }; - t.SetWidths(widths); - //t.HorizontalAlignment = 0; - // C2017-036 get best available proportional font for symbols that looks close to Arial. - // Note that Microsoft no longer supplies Arial Unicode MS as of Word16 - iTextSharp.text.Font f1 = pdf.GetFont(Volian.Base.Library.vlnFont.ReportsFont, 14, 1, Color.BLACK); - iTextSharp.text.Font f2 = pdf.GetFont(Volian.Base.Library.vlnFont.ReportsFont, 10, 0, Color.BLACK); - iTextSharp.text.Font f3 = pdf.GetFont(Volian.Base.Library.vlnFont.ReportsFont, 9, 0, Color.BLACK); - iTextSharp.text.Font f4 = pdf.GetFont(Volian.Base.Library.vlnFont.ReportsFont, 9, 1, Color.BLACK); - //report title - Phrase h = new Phrase(); - h.Font = f1; - h.Add("Summary of Changes Report"); - PdfPCell c = new PdfPCell(h); - c.Colspan = cols; - c.HorizontalAlignment = Element.ALIGN_CENTER; - c.PaddingBottom = paddingBottom; - //c.Border = borders; - t.AddCell(c); - t.AddCell(BlankCell(cols)); - //procedure title - h = new Phrase(); - h.Font = f2; - h.Add(string.Format("{0} - {1}", MyProc.DisplayNumber, MyProc.DisplayText)); - c = new PdfPCell(h); - c.Colspan = cols; - c.HorizontalAlignment = Element.ALIGN_LEFT; - c.PaddingBottom = paddingBottom; - //c.Border = borders; - t.AddCell(c); - t.AddCell(BlankCell(cols)); - foreach (ContentAuditInfo cai in auditList) - { - //raw path - string[] NewPath = SplitPath(cai.Path); - if (NewPath[0] != section) - { - section = NewPath[0]; - h = new Phrase(); - h.Font = f4; - h.Add(section); - c = new PdfPCell(h); - c.Colspan = cols; - c.HorizontalAlignment = Element.ALIGN_LEFT; - c.PaddingBottom = paddingBottom; - //c.Border = borders; - t.AddCell(c); - t.AddCell(BlankCell(cols)); - } - //step - if (NewPath[1] != stepnum) - { - firstCAI = cai; - stepnum = NewPath[1]; - string stepnum2 = Regex.Replace(stepnum, "([0-9])[.]([A-Za-z])", "$1 $2"); - stepnum2 = stepnum2.Replace("RNO.", "RNO"); - h = new Phrase(); - h.Font = f3; - h.Add(string.Format("Step {0}", stepnum2)); - c = new PdfPCell(h); - c.Colspan = 1; - c.HorizontalAlignment = Element.ALIGN_RIGHT; - c.PaddingBottom = paddingBottom; - c.PaddingRight = 10; - //c.Border = borders; - t.AddCell(c); - } - else - { - t.AddCell(BlankCell(1)); - nextCAI = cai; - } - //what - h = new Phrase(); - h.Font = f3; - h.Add(cai.ActionWhen > MyProc.ChangeBarDate ? cai.ActionWhat : "Original"); - c = new PdfPCell(h); - c.Colspan = 1; - c.HorizontalAlignment = Element.ALIGN_CENTER; - c.PaddingBottom = paddingBottom; - //c.Border = borders; - t.AddCell(c); - //who - h = new Phrase(); - h.Font = f3; - h.Add(cai.UserID); - c = new PdfPCell(h); - c.Colspan = 1; - c.HorizontalAlignment = Element.ALIGN_CENTER; - c.PaddingBottom = paddingBottom; - //c.Border = borders; - t.AddCell(c); - //when - h = new Phrase(); - h.Font = f3; - h.Add(cai.ActionWhen.ToString()); - c = new PdfPCell(h); - c.Colspan = 1; - c.HorizontalAlignment = Element.ALIGN_CENTER; - c.PaddingBottom = paddingBottom; - //c.Border = borders; - t.AddCell(c); - //new text - h = new Phrase(); - h.Font = f4; - //h.Add(cai.Text); - h.Add(ItemInfo.ConvertToDisplayText(cai.Text)); - c = new PdfPCell(h); - c.Colspan = cols - 4; - c.HorizontalAlignment = Element.ALIGN_LEFT; - c.PaddingBottom = paddingBottom; - //c.Border = borders; - t.AddCell(c); - ////old text - //t.AddCell(BlankCell(3)); - //h = new Phrase(); - //h.Font = f4; - //h.Add("Old text: " + cai.OldText); - //c = new PdfPCell(h); - //c.Colspan = 7; - //c.Border = 0; - //t.AddCell(c); - } - t.AddCell(BlankCell(cols)); - h = new Phrase(); - h.Font = f4; - h.Add("ANNOTATIONS"); - c = new PdfPCell(h); - c.Colspan = cols; - c.HorizontalAlignment = Element.ALIGN_LEFT; - c.PaddingBottom = paddingBottom; - //c.Border = borders; - t.AddCell(c); - t.AddCell(BlankCell(cols)); - stepnum = string.Empty; - foreach (AnnotationAuditInfo aai in annotationList) - { - foreach (ContentAuditInfo cai in auditList) - { - if (cai.ContentID == aai.IContentID) - { - string[] NewPath = SplitPath(cai.Path); - if (NewPath[1] != stepnum) - { - stepnum = NewPath[1]; - string stepnum2 = Regex.Replace(stepnum, "([0-9])[.]([A-Za-z])", "$1 $2"); - stepnum2 = stepnum2.Replace("RNO.", "RNO"); - h = new Phrase(); - h.Font = f3; - h.Add(string.Format("Step {0}", stepnum2)); - c = new PdfPCell(h); - c.Colspan = 1; - c.HorizontalAlignment = Element.ALIGN_RIGHT; - c.PaddingBottom = paddingBottom; - c.PaddingRight = 10; - //c.Border = borders; - t.AddCell(c); - break; - } - else - { - t.AddCell(BlankCell(1)); - break; - } - } - } - //what - h = new Phrase(); - h.Font = f3; - h.Add(aai.ActionWhat); - c = new PdfPCell(h); - c.Colspan = 1; - c.HorizontalAlignment = Element.ALIGN_CENTER; - c.PaddingBottom = paddingBottom; - //c.Border = borders; - t.AddCell(c); - //who - h = new Phrase(); - h.Font = f3; - h.Add(aai.UserID); - c = new PdfPCell(h); - c.Colspan = 1; - c.HorizontalAlignment = Element.ALIGN_CENTER; - c.PaddingBottom = paddingBottom; - //c.Border = borders; - t.AddCell(c); - //when - h = new Phrase(); - h.Font = f3; - h.Add(aai.ActionWhen.ToString()); - c = new PdfPCell(h); - c.Colspan = 1; - c.HorizontalAlignment = Element.ALIGN_CENTER; - c.PaddingBottom = paddingBottom; - //c.Border = borders; - t.AddCell(c); - //new text - h = new Phrase(); - h.Font = f4; - //h.Add(cai.Text); - h.Add(ItemInfo.ConvertToDisplayText(aai.SearchText)); - c = new PdfPCell(h); - c.Colspan = cols - 4; - c.HorizontalAlignment = Element.ALIGN_LEFT; - c.PaddingBottom = paddingBottom; - //c.Border = borders; - t.AddCell(c); - } - doc.Add(t); - } - private void BuildSummaryReport(iTextSharp.text.Document doc) + + [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0059:Unnecessary assignment of a value", Justification = "firstCAI and lastCAI are re-used so good to set them back to null")] + private void BuildSummaryReport(iTextSharp.text.Document doc) { int lastAnnotationID = 0; string section = string.Empty; string stepnum = string.Empty; int contentID = 0; ContentAuditInfo firstCAI = null; - ContentAuditInfo nextCAI = null; ContentAuditInfo lastCAI = null; List auditList1 = new List(); foreach (ContentAuditInfo cai in AuditList) @@ -1105,7 +824,6 @@ namespace Volian.Print.Library } else if (firstCAI.ActionWhat == "Added" && lastCAI.ActionWhat == "Deleted" && firstCAI.DTS == lastCAI.DTS) { - //auditList.Add(lastCAI); firstCAI = null; lastCAI = null; } @@ -1116,14 +834,6 @@ namespace Volian.Print.Library firstCAI = null; lastCAI = null; } - //added by jcb - //else if (firstCAI.ActionWhat == "Added" && lastCAI.ActionWhat == "Changed" && firstCAI.DTS == lastCAI.DTS) - //{ - // auditList.Add(firstCAI); - // auditList.Add(lastCAI); - // firstCAI = null; - // lastCAI = null; - //} } } firstCAI = cai; @@ -1170,7 +880,6 @@ namespace Volian.Print.Library { if (lastCAI.ActionWhat == "Deleted" && firstCAI.DTS == lastCAI.DTS) { - //auditList.Add(lastCAI); firstCAI = null; lastCAI = null; } @@ -1185,7 +894,6 @@ namespace Volian.Print.Library } #region annotations commented out AnnotationAuditInfo firstAAI = null; - AnnotationAuditInfo nextAAI = null; AnnotationAuditInfo lastAAI = null; int annotationID = 0; List annotationList = new List(); @@ -1247,19 +955,19 @@ namespace Volian.Print.Library { annotationList.Add(lastAAI); } - else if (lastAAI.ActionWhat == "Changed" && firstAAI.ActionWhat != "Added") // && lastAAI.SearchText != firstAAI.SearchText) + else if (lastAAI.ActionWhat == "Changed" && firstAAI.ActionWhat != "Added") { annotationList.Add(firstAAI); annotationList.Add(lastAAI); } - else if (lastAAI.ActionWhat == "Changed" && firstAAI.ActionWhat == "Added") // && lastAAI.SearchText != firstAAI.SearchText) + else if (lastAAI.ActionWhat == "Changed" && firstAAI.ActionWhat == "Added") { lastAAI.ActionWhat = firstAAI.ActionWhat; annotationList.Add(lastAAI); firstAAI = null; lastAAI = null; } - else if (lastAAI.ActionWhat == "Restored" && firstAAI.ActionWhat == "Added") // && lastAAI.SearchText != firstAAI.SearchText) + else if (lastAAI.ActionWhat == "Restored" && firstAAI.ActionWhat == "Added") { lastAAI.ActionWhat = firstAAI.ActionWhat; annotationList.Add(lastAAI); @@ -1271,86 +979,87 @@ namespace Volian.Print.Library annotationList.Add(firstAAI); } } - //if (firstAAI != null) - // annotationList.Add(firstAAI); - //if (lastAAI != null) - // annotationList.Add(lastAAI); #endregion //new final cleanup List auditList2 = new List(); ContentAuditInfo caiFirst = null; foreach (ContentAuditInfo cai in auditList1) { - if (caiFirst == null) + if (caiFirst == null) caiFirst = cai; else { - if (cai.ContentID == caiFirst.ContentID && cai.Text != caiFirst.Text) - { - if (caiFirst.ActionWhat == "Added" && (cai.ActionWhat == "Added" || cai.ActionWhat == "Restored")) - { - auditList2.Add(cai); - caiFirst = null; - } - else - { - auditList2.Add(caiFirst); - auditList2.Add(cai); - caiFirst = null; - } - } - else - { - if(caiFirst.Text != string.Empty && !(caiFirst.UserID.Contains("Renumber") || cai.UserID.Contains("Renumber"))) - auditList2.Add(caiFirst); - caiFirst = cai; - } - } + if (cai.ContentID == caiFirst.ContentID && cai.Text != caiFirst.Text) + { + if (caiFirst.ActionWhat == "Added" && (cai.ActionWhat == "Added" || cai.ActionWhat == "Restored")) + { + auditList2.Add(cai); + caiFirst = null; + } + else + { + auditList2.Add(caiFirst); + auditList2.Add(cai); + caiFirst = null; + } + } + else + { + if(caiFirst.Text != string.Empty && !(caiFirst.UserID.Contains("Renumber") || cai.UserID.Contains("Renumber"))) + auditList2.Add(caiFirst); + caiFirst = cai; + } + } } if (caiFirst != null) //ciaFirst could end up being null at the end of the above foreach loop auditList2.Add(caiFirst); int cols = 5; - int borders = 0; int paddingBottom = 6; - PdfPTable t = new PdfPTable(cols); - t.HeaderRows = 4; - t.DefaultCell.Padding = 4; + PdfPTable t = new PdfPTable(cols) + { + HeaderRows = 4 + }; + t.DefaultCell.Padding = 4; t.WidthPercentage = 100; float[] widths = new float[] { 1f, 1f, 1f, 1f, 4f }; t.SetWidths(widths); - //t.HorizontalAlignment = 0; // C2017-036 get best available proportional font for symbols that looks close to Arial // Note that Microsoft no longer supplies Arial Unicode MS as of Word16 iTextSharp.text.Font f1 = pdf.GetFont(Volian.Base.Library.vlnFont.ReportsFont, 14, 1, Color.BLACK); iTextSharp.text.Font f2 = pdf.GetFont(Volian.Base.Library.vlnFont.ReportsFont, 10, 0, Color.BLACK); iTextSharp.text.Font f3 = pdf.GetFont(Volian.Base.Library.vlnFont.ReportsFont, 9, 0, Color.BLACK); iTextSharp.text.Font f4 = pdf.GetFont(Volian.Base.Library.vlnFont.ReportsFont, 9, 1, Color.BLACK); - //report title - Phrase h = new Phrase(); - h.Font = f1; - h.Add("Summary of Changes Report"); - PdfPCell c = new PdfPCell(h); - c.Colspan = cols; - c.HorizontalAlignment = Element.ALIGN_CENTER; - c.PaddingBottom = paddingBottom; - //c.Border = borders; - t.AddCell(c); + //report title + Phrase h = new Phrase + { + Font = f1 + }; + h.Add("Summary of Changes Report"); + PdfPCell c = new PdfPCell(h) + { + Colspan = cols, + HorizontalAlignment = Element.ALIGN_CENTER, + PaddingBottom = paddingBottom + }; + t.AddCell(c); t.AddCell(BlankCell(cols)); - //procedure title - h = new Phrase(); - h.Font = f2; - h.Add(string.Format("{0} - {1}", MyProc.DisplayNumber, MyProc.DisplayText)); - c = new PdfPCell(h); - c.Colspan = cols; - c.HorizontalAlignment = Element.ALIGN_LEFT; - c.PaddingBottom = paddingBottom; - //c.Border = borders; - t.AddCell(c); + //procedure title + h = new Phrase + { + Font = f2 + }; + h.Add(string.Format("{0} - {1}", MyProc.DisplayNumber, MyProc.DisplayText)); + c = new PdfPCell(h) + { + Colspan = cols, + HorizontalAlignment = Element.ALIGN_LEFT, + PaddingBottom = paddingBottom + }; + t.AddCell(c); t.AddCell(BlankCell(cols)); ContentAuditInfo oldCAI = null; string oldText = string.Empty; string oldTypeName = string.Empty; - // Dictionary processedAAI = new Dictionary(); Dictionary processedAAI = new Dictionary(); foreach (ContentAuditInfo cai in auditList2) { @@ -1360,73 +1069,24 @@ namespace Volian.Print.Library { AddStepAnnotation(ref lastAnnotationID, cols, paddingBottom, t, f3, f4, ref h, ref c, oldCAI, processedAAI); section = NewPath[0]; - h = new Phrase(); - h.Font = f4; - h.Add(section); - c = new PdfPCell(h); - c.Colspan = cols; - c.HorizontalAlignment = Element.ALIGN_LEFT; - c.PaddingBottom = paddingBottom; - //c.Border = borders; - t.AddCell(c); + h = new Phrase + { + Font = f4 + }; + h.Add(section); + c = new PdfPCell(h) + { + Colspan = cols, + HorizontalAlignment = Element.ALIGN_LEFT, + PaddingBottom = paddingBottom + }; + t.AddCell(c); t.AddCell(BlankCell(cols)); } //step if (NewPath[1] != stepnum) { AddStepAnnotation(ref lastAnnotationID, cols, paddingBottom, t, f3, f4, ref h, ref c, oldCAI, processedAAI); - ////see if any annotations for old stepnum here and add them - //foreach (AnnotationAuditInfo aai in annotationList) - //{ - // if (oldCAI != null && aai.IContentID == oldCAI.ContentID) - // { - // //add annotation to minilist - // // processedAAI.Add(aai.AnnotationID, aai); - // processedAAI.Add(aai, aai); - // //write row to table - // t.AddCell(BlankCell(1)); - // h = new Phrase(); - // h.Font = f3; - // h.Add(AnnotationLookup[aai.TypeID] + " " + aai.ActionWhat); - // c = new PdfPCell(h); - // c.Colspan = 1; - // c.HorizontalAlignment = Element.ALIGN_CENTER; - // c.PaddingBottom = paddingBottom; - // //c.Border = borders; - // t.AddCell(c); - // //who - // h = new Phrase(); - // h.Font = f3; - // h.Add(aai.UserID); - // c = new PdfPCell(h); - // c.Colspan = 1; - // c.HorizontalAlignment = Element.ALIGN_CENTER; - // c.PaddingBottom = paddingBottom; - // //c.Border = borders; - // t.AddCell(c); - // //when - // h = new Phrase(); - // h.Font = f3; - // h.Add(aai.ActionWhen.ToString()); - // c = new PdfPCell(h); - // c.Colspan = 1; - // c.HorizontalAlignment = Element.ALIGN_CENTER; - // c.PaddingBottom = paddingBottom; - // //c.Border = borders; - // t.AddCell(c); - // //new text - // h = new Phrase(); - // h.Font = f4; - // //h.Add(cai.Text); - // h.Add(ItemInfo.ConvertToDisplayText(aai.SearchText)); - // c = new PdfPCell(h); - // c.Colspan = cols - 4; - // c.HorizontalAlignment = Element.ALIGN_LEFT; - // c.PaddingBottom = paddingBottom; - // //c.Border = borders; - // t.AddCell(c); - // } - //} oldCAI = cai; oldText = cai.Text; oldTypeName = cai.TypeName; @@ -1440,16 +1100,19 @@ namespace Volian.Print.Library // This was happening when we were reporting change information of a section number/title if (stepnum2 != "") { - h = new Phrase(); - h.Font = f3; - h.Add(string.Format("Step {0}", stepnum2)); - c = new PdfPCell(h); - c.Colspan = 1; - c.HorizontalAlignment = Element.ALIGN_RIGHT; - c.PaddingBottom = paddingBottom; - c.PaddingRight = 10; - //c.Border = borders; - t.AddCell(c); + h = new Phrase + { + Font = f3 + }; + h.Add(string.Format("Step {0}", stepnum2)); + c = new PdfPCell(h) + { + Colspan = 1, + HorizontalAlignment = Element.ALIGN_RIGHT, + PaddingBottom = paddingBottom, + PaddingRight = 10 + }; + t.AddCell(c); } else t.AddCell(BlankCell(1)); @@ -1457,49 +1120,56 @@ namespace Volian.Print.Library else { t.AddCell(BlankCell(1)); - nextCAI = cai; } - //what - h = new Phrase(); - h.Font = f3; - // h.Add(cai.ActionWhen > MyProc.DTS ? cai.ActionWhat : "Original"); - string actionWhat = ((cai.ActionWhat == "Added" || cai.ActionWhat == "Changed") && cai.DTS <= MyProc.ChangeBarDate) ? "Original" : cai.ActionWhat; //(cai.ActionWhat == "Added" && cai.DTS <= MyProc.DTS) ? "Original" : cai.ActionWhat != "Changed" ? cai.ActionWhat : cai.DTS <= maxDTS ? "Restored" : cai.DTS > MyProc.DTS ? cai.ActionWhat : "Original"; + //what + h = new Phrase + { + Font = f3 + }; + string actionWhat = ((cai.ActionWhat == "Added" || cai.ActionWhat == "Changed") && cai.DTS <= MyProc.ChangeBarDate) ? "Original" : cai.ActionWhat; //(cai.ActionWhat == "Added" && cai.DTS <= MyProc.DTS) ? "Original" : cai.ActionWhat != "Changed" ? cai.ActionWhat : cai.DTS <= maxDTS ? "Restored" : cai.DTS > MyProc.DTS ? cai.ActionWhat : "Original"; if (actionWhat == "Deleted" || actionWhat == "Restored") - h.Add(actionWhat + "\r\n" + (cai.ActionWhen < cai.DTS ? cai.DTS.ToString("M/dd/yyyy") : cai.ActionWhen.ToString())); + h.Add($"{actionWhat}\r\n{(cai.ActionWhen < cai.DTS ? cai.DTS.ToString("M/dd/yyyy") : cai.ActionWhen.ToString())}"); else h.Add(actionWhat); - c = new PdfPCell(h); - c.Colspan = 1; - c.HorizontalAlignment = Element.ALIGN_CENTER; - c.PaddingBottom = paddingBottom; - //c.Border = borders; - t.AddCell(c); - //who - h = new Phrase(); - h.Font = f3; - h.Add(cai.UserID); - c = new PdfPCell(h); - c.Colspan = 1; - c.HorizontalAlignment = Element.ALIGN_CENTER; - c.PaddingBottom = paddingBottom; - //c.Border = borders; - t.AddCell(c); - //when - h = new Phrase(); - h.Font = f3; - h.Add(cai.DTS.ToString()); - c = new PdfPCell(h); - c.Colspan = 1; - c.HorizontalAlignment = Element.ALIGN_CENTER; - c.PaddingBottom = paddingBottom; - //c.Border = borders; - t.AddCell(c); - //new text - h = new Phrase(); - h.Font = f4; - //h.Add(cai.Text); - //h.Add(ItemInfo.ConvertToDisplayText(cai.Text)); - if (cai.Type == 20008) + c = new PdfPCell(h) + { + Colspan = 1, + HorizontalAlignment = Element.ALIGN_CENTER, + PaddingBottom = paddingBottom + }; + t.AddCell(c); + //who + h = new Phrase + { + Font = f3 + }; + h.Add(cai.UserID); + c = new PdfPCell(h) + { + Colspan = 1, + HorizontalAlignment = Element.ALIGN_CENTER, + PaddingBottom = paddingBottom + }; + t.AddCell(c); + //when + h = new Phrase + { + Font = f3 + }; + h.Add(cai.DTS.ToString()); + c = new PdfPCell(h) + { + Colspan = 1, + HorizontalAlignment = Element.ALIGN_CENTER, + PaddingBottom = paddingBottom + }; + t.AddCell(c); + //new text + h = new Phrase + { + Font = f4 + }; + if (cai.Type == 20008) { GridAuditInfoList gail = GridAuditInfoList.Get(cai.ContentID); bool addedInfo = false; @@ -1508,7 +1178,6 @@ namespace Volian.Print.Library GridAuditInfo gai = gail[0]; System.Xml.XmlDocument xd = new System.Xml.XmlDocument(); xd.LoadXml(gai.Data); - //int grows = int.Parse(xd.SelectSingleNode("C1FlexGrid/RowInfo/Count").InnerText); int gcols = int.Parse(xd.SelectSingleNode("C1FlexGrid/ColumnInfo/Count").InnerText); string data = ItemInfo.ConvertToDisplayText(cai.Text); PdfPTable gtbl = new PdfPTable(gcols); @@ -1520,9 +1189,11 @@ namespace Volian.Print.Library addedInfo = true; string val = data.Substring(0, data.IndexOf(";")); data = data.Substring(data.IndexOf(";") + 1); - Phrase hh = new Phrase(); - hh.Font = f4; - hh.Add(val); + Phrase hh = new Phrase + { + Font = f4 + }; + hh.Add(val); PdfPCell cc = new PdfPCell(hh); gtbl.AddCell(cc); } @@ -1531,36 +1202,42 @@ namespace Volian.Print.Library } if (addedInfo) { - c = new PdfPCell(gtbl); - c.Colspan = cols - 4; - c.HorizontalAlignment = Element.ALIGN_LEFT; - //c.PaddingBottom = paddingBottom; - //c.Border = borders; - t.AddCell(c); + c = new PdfPCell(gtbl) + { + Colspan = cols - 4, + HorizontalAlignment = Element.ALIGN_LEFT + }; + t.AddCell(c); } } // B2017-058: The following was added to handle when there are no grid audits, just put a message. Without // adding this cell to the output, the columns get out of sync for rest of report. else { - h = new Phrase(); - h.Font = f4; - h.Add( "No change in table text found."); - c = new PdfPCell(h); - c.Colspan = 1; - c.HorizontalAlignment = Element.ALIGN_LEFT; - c.PaddingBottom = paddingBottom; - t.AddCell(c); + h = new Phrase + { + Font = f4 + }; + h.Add( "No change in table text found."); + c = new PdfPCell(h) + { + Colspan = 1, + HorizontalAlignment = Element.ALIGN_LEFT, + PaddingBottom = paddingBottom + }; + t.AddCell(c); } } else { - h = new Phrase(); - h.Font = f4; - if (cai.Text != oldText && cai.TypeName != oldTypeName) - h.Add(string.Format("[Type Change {0} to {1}] - {2}", oldTypeName, cai.TypeName, ItemInfo.ConvertToDisplayText(cai.Text)));// + " to " + cai.TypeName); + h = new Phrase + { + Font = f4 + }; + if (cai.Text != oldText && cai.TypeName != oldTypeName) + h.Add(string.Format("[Type Change {0} to {1}] - {2}", oldTypeName, cai.TypeName, ItemInfo.ConvertToDisplayText(cai.Text))); else if (cai.Text == oldText && cai.TypeName != oldTypeName) - h.Add(oldTypeName + " to " + cai.TypeName); + h.Add($"{oldTypeName} to {cai.TypeName}"); else { string txt = null; @@ -1612,30 +1289,14 @@ namespace Volian.Print.Library } oldText = cai.Text; oldTypeName = cai.TypeName; -// h.Add(ItemInfo.ConvertToDisplayText(cai.Text) + " " + cai.TypeName); - c = new PdfPCell(h); - c.Colspan = cols - 4; - c.HorizontalAlignment = Element.ALIGN_LEFT; - c.PaddingBottom = paddingBottom; - //c.Border = borders; - t.AddCell(c); + c = new PdfPCell(h) + { + Colspan = cols - 4, + HorizontalAlignment = Element.ALIGN_LEFT, + PaddingBottom = paddingBottom + }; + t.AddCell(c); } - - //c = new PdfPCell(h); - //c.Colspan = cols - 4; - //c.HorizontalAlignment = Element.ALIGN_LEFT; - //c.PaddingBottom = paddingBottom; - ////c.Border = borders; - //t.AddCell(c); - ////old text - //t.AddCell(BlankCell(3)); - //h = new Phrase(); - //h.Font = f4; - //h.Add("Old text: " + cai.OldText); - //c = new PdfPCell(h); - //c.Colspan = 7; - //c.Border = 0; - //t.AddCell(c); } //see if any annotations for old stepnum here and add them foreach (AnnotationAuditInfo aai in annotationList) @@ -1643,64 +1304,63 @@ namespace Volian.Print.Library if (oldCAI != null && aai.IContentID == oldCAI.ContentID && !processedAAI.ContainsKey(aai)) { //add annotation to minilist - // processedAAI.Add(aai.AnnotationID, aai); processedAAI.Add(aai, aai); //write row to table t.AddCell(BlankCell(1)); - h = new Phrase(); - h.Font = f3; - h.Add(AnnotationLookup[aai.TypeID] + " " + aai.ActionWhat); - c = new PdfPCell(h); - c.Colspan = 1; - c.HorizontalAlignment = Element.ALIGN_CENTER; - c.PaddingBottom = paddingBottom; - //c.Border = borders; - t.AddCell(c); - //who - h = new Phrase(); - h.Font = f3; - h.Add(aai.UserID); - c = new PdfPCell(h); - c.Colspan = 1; - c.HorizontalAlignment = Element.ALIGN_CENTER; - c.PaddingBottom = paddingBottom; - //c.Border = borders; - t.AddCell(c); - //when - h = new Phrase(); - h.Font = f3; - h.Add(aai.ActionWhen.ToString()); - c = new PdfPCell(h); - c.Colspan = 1; - c.HorizontalAlignment = Element.ALIGN_CENTER; - c.PaddingBottom = paddingBottom; - //c.Border = borders; - t.AddCell(c); - //new text - h = new Phrase(); - h.Font = f4; - //h.Add(cai.Text); - h.Add(ItemInfo.ConvertToDisplayText(aai.SearchText)); - c = new PdfPCell(h); - c.Colspan = cols - 4; - c.HorizontalAlignment = Element.ALIGN_LEFT; - c.PaddingBottom = paddingBottom; - //c.Border = borders; - t.AddCell(c); + h = new Phrase + { + Font = f3 + }; + h.Add($"{AnnotationLookup[aai.TypeID]} {aai.ActionWhat}"); + c = new PdfPCell(h) + { + Colspan = 1, + HorizontalAlignment = Element.ALIGN_CENTER, + PaddingBottom = paddingBottom + }; + t.AddCell(c); + //who + h = new Phrase + { + Font = f3 + }; + h.Add(aai.UserID); + c = new PdfPCell(h) + { + Colspan = 1, + HorizontalAlignment = Element.ALIGN_CENTER, + PaddingBottom = paddingBottom + }; + t.AddCell(c); + //when + h = new Phrase + { + Font = f3 + }; + h.Add(aai.ActionWhen.ToString()); + c = new PdfPCell(h) + { + Colspan = 1, + HorizontalAlignment = Element.ALIGN_CENTER, + PaddingBottom = paddingBottom + }; + t.AddCell(c); + //new text + h = new Phrase + { + Font = f4 + }; + h.Add(ItemInfo.ConvertToDisplayText(aai.SearchText)); + c = new PdfPCell(h) + { + Colspan = cols - 4, + HorizontalAlignment = Element.ALIGN_LEFT, + PaddingBottom = paddingBottom + }; + t.AddCell(c); } } bool annotationHeader = false; - //t.AddCell(BlankCell(cols)); - //h = new Phrase(); - //h.Font = f4; - //h.Add("ANNOTATIONS"); - //c = new PdfPCell(h); - //c.Colspan = cols; - //c.HorizontalAlignment = Element.ALIGN_LEFT; - //c.PaddingBottom = paddingBottom; - ////c.Border = borders; - //t.AddCell(c); - //t.AddCell(BlankCell(cols)); section = string.Empty; stepnum = string.Empty; foreach (AnnotationAuditInfo aai in annotationList) @@ -1711,15 +1371,18 @@ namespace Volian.Print.Library if (!annotationHeader) { t.AddCell(BlankCell(cols)); - h = new Phrase(); - h.Font = f4; - h.Add("ANNOTATIONS"); - c = new PdfPCell(h); - c.Colspan = cols; - c.HorizontalAlignment = Element.ALIGN_LEFT; - c.PaddingBottom = paddingBottom; - //c.Border = borders; - t.AddCell(c); + h = new Phrase + { + Font = f4 + }; + h.Add("ANNOTATIONS"); + c = new PdfPCell(h) + { + Colspan = cols, + HorizontalAlignment = Element.ALIGN_LEFT, + PaddingBottom = paddingBottom + }; + t.AddCell(c); t.AddCell(BlankCell(cols)); annotationHeader = true; } @@ -1728,85 +1391,104 @@ namespace Volian.Print.Library { section = NewPath[0]; stepnum = string.Empty; - h = new Phrase(); - h.Font = f4; - h.Add(section); - c = new PdfPCell(h); - c.Colspan = cols; - c.HorizontalAlignment = Element.ALIGN_LEFT; - c.PaddingBottom = paddingBottom; - //c.Border = borders; - t.AddCell(c); + h = new Phrase + { + Font = f4 + }; + h.Add(section); + c = new PdfPCell(h) + { + Colspan = cols, + HorizontalAlignment = Element.ALIGN_LEFT, + PaddingBottom = paddingBottom + }; + t.AddCell(c); } if (NewPath[1] != stepnum) { stepnum = NewPath[1]; string stepnum2 = Regex.Replace(stepnum, "([0-9])[.]([A-Za-z])", "$1 $2"); stepnum2 = stepnum2.Replace("RNO.", "RNO"); - h = new Phrase(); - h.Font = f3; - h.Add(string.Format("Step {0}", stepnum2)); - c = new PdfPCell(h); - c.Colspan = 1; - c.HorizontalAlignment = Element.ALIGN_RIGHT; - c.PaddingBottom = paddingBottom; - c.PaddingRight = 10; - //c.Border = borders; - t.AddCell(c); + h = new Phrase + { + Font = f3 + }; + h.Add(string.Format("Step {0}", stepnum2)); + c = new PdfPCell(h) + { + Colspan = 1, + HorizontalAlignment = Element.ALIGN_RIGHT, + PaddingBottom = paddingBottom, + PaddingRight = 10 + }; + t.AddCell(c); } else { t.AddCell(BlankCell(1)); } - //what - h = new Phrase(); - h.Font = f3; - - h.Add(AnnotationLookup[aai.TypeID] + " " + aai.ActionWhat); - c = new PdfPCell(h); - c.Colspan = 1; - c.HorizontalAlignment = Element.ALIGN_CENTER; - c.PaddingBottom = paddingBottom; - //c.Border = borders; - t.AddCell(c); - //who - h = new Phrase(); - h.Font = f3; - h.Add(aai.UserID); - c = new PdfPCell(h); - c.Colspan = 1; - c.HorizontalAlignment = Element.ALIGN_CENTER; - c.PaddingBottom = paddingBottom; - //c.Border = borders; - t.AddCell(c); - //when - h = new Phrase(); - h.Font = f3; - h.Add(aai.ActionWhen.ToString()); - c = new PdfPCell(h); - c.Colspan = 1; - c.HorizontalAlignment = Element.ALIGN_CENTER; - c.PaddingBottom = paddingBottom; - //c.Border = borders; - t.AddCell(c); - //new text - h = new Phrase(); - h.Font = f4; - //h.Add(cai.Text); - h.Add(ItemInfo.ConvertToDisplayText(aai.SearchText)); - c = new PdfPCell(h); - c.Colspan = cols - 4; - c.HorizontalAlignment = Element.ALIGN_LEFT; - c.PaddingBottom = paddingBottom; - //c.Border = borders; - t.AddCell(c); + //what + h = new Phrase + { + Font = f3 + }; + + h.Add($"{AnnotationLookup[aai.TypeID]} {aai.ActionWhat}"); + c = new PdfPCell(h) + { + Colspan = 1, + HorizontalAlignment = Element.ALIGN_CENTER, + PaddingBottom = paddingBottom + }; + t.AddCell(c); + //who + h = new Phrase + { + Font = f3 + }; + h.Add(aai.UserID); + c = new PdfPCell(h) + { + Colspan = 1, + HorizontalAlignment = Element.ALIGN_CENTER, + PaddingBottom = paddingBottom + }; + t.AddCell(c); + //when + h = new Phrase + { + Font = f3 + }; + h.Add(aai.ActionWhen.ToString()); + c = new PdfPCell(h) + { + Colspan = 1, + HorizontalAlignment = Element.ALIGN_CENTER, + PaddingBottom = paddingBottom + }; + t.AddCell(c); + //new text + h = new Phrase + { + Font = f4 + }; + h.Add(ItemInfo.ConvertToDisplayText(aai.SearchText)); + c = new PdfPCell(h) + { + Colspan = cols - 4, + HorizontalAlignment = Element.ALIGN_LEFT, + PaddingBottom = paddingBottom + }; + t.AddCell(c); } } if (t.Rows.Count == t.HeaderRows) { - c = new PdfPCell(new Phrase("No changes to report")); - c.Colspan = cols; - t.AddCell(c); + c = new PdfPCell(new Phrase("No changes to report")) + { + Colspan = cols + }; + t.AddCell(c); } doc.Add(t); } diff --git a/PROMS/Volian.Print.Library/PDFConsistencyCheckReport.cs b/PROMS/Volian.Print.Library/PDFConsistencyCheckReport.cs index ff5c357f..a1c4658b 100644 --- a/PROMS/Volian.Print.Library/PDFConsistencyCheckReport.cs +++ b/PROMS/Volian.Print.Library/PDFConsistencyCheckReport.cs @@ -6,35 +6,20 @@ using iTextSharp.text.pdf; using iTextSharp.text; using System.IO; using System.Text.RegularExpressions; -using System.Windows.Forms; +using System.Linq; namespace Volian.Print.Library { public class PDFConsistencyCheckReport { - private DocVersionInfo _MyDocVersion; - public DocVersionInfo MyDocVersion + public DocVersionInfo MyDocVersion { get; set; } + public string FileName { get; set; } + public ItemInfoList MyItemInfoList { get; set; } + public PDFConsistencyCheckReport(string fileName, ItemInfoList myItemInfoList, DocVersionInfo myDocVersion) { - get { return _MyDocVersion; } - set { _MyDocVersion = value; } - } - private string _FileName; - public string FileName - { - get { return _FileName; } - set { _FileName = value; } - } - private ItemInfoList _MyItemInfoList; - public ItemInfoList MyItemInfoList - { - get { return _MyItemInfoList; } - set { _MyItemInfoList = value; } - } - public PDFConsistencyCheckReport(string fileName, ItemInfoList myItemInfoList, DocVersionInfo myDocVersion) - { - _FileName = fileName; - _MyItemInfoList = myItemInfoList; - _MyDocVersion = myDocVersion; //B2020-020 needed to pass in DocVersion to get paper size from format + FileName = fileName; + MyItemInfoList = myItemInfoList; + MyDocVersion = myDocVersion; //B2020-020 needed to pass in DocVersion to get paper size from format } public void BuildReport() { @@ -47,7 +32,6 @@ namespace Volian.Print.Library } catch (Exception ex) { - StringBuilder msg = new StringBuilder(); document.Add(new Paragraph("Error:")); while (ex != null) { @@ -61,7 +45,7 @@ namespace Volian.Print.Library if (document.IsOpen()) { document.Close(); - System.Diagnostics.Process.Start(_FileName); + System.Diagnostics.Process.Start(FileName); } } } @@ -73,13 +57,13 @@ namespace Volian.Print.Library // Try to open a file for creating the PDF. while (result == false) { - string fileName = _FileName.ToLower().Replace(".pdf", suffix + ".pdf"); + string fileName = FileName.ToLower().Replace(".pdf", suffix + ".pdf"); try { PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(fileName, FileMode.Create)); document.SetMargins(36, 36, 36, 36); document.Open(); - _FileName = fileName; + FileName = fileName; result = true; } catch (System.IO.IOException exIO) @@ -118,10 +102,12 @@ namespace Volian.Print.Library } private PdfPCell BlankCell(int colSpan) { - PdfPCell c = new PdfPCell(); - c.Colspan = colSpan; - c.Border = 0; - return c; + PdfPCell c = new PdfPCell + { + Colspan = colSpan, + Border = 0 + }; + return c; } private void BuildConsistencyReport(iTextSharp.text.Document doc) { @@ -132,7 +118,6 @@ namespace Volian.Print.Library iTextSharp.text.Font f3 = pdf.GetFont(Volian.Base.Library.vlnFont.ReportsFont, 8, 0, Color.BLACK); iTextSharp.text.Font f4 = pdf.GetFont(Volian.Base.Library.vlnFont.ReportsFont, 10, 2, Color.BLACK); int cols = 5; - int borders = 0; int paddingBottom = 6; // float[] widths; Csla.SortedBindingList sortedProcs = new Csla.SortedBindingList(MyItemInfoList); @@ -141,7 +126,7 @@ namespace Volian.Print.Library // B2019-024: First page of Report prints the title at the top and the remainder of the page is blank. // Check if procedure(s) are printed on that page and if not, change message to "No..." and don't do // pagebreak. - foreach (ProcedureInfo pi in sortedProcs) + foreach (ProcedureInfo pi in sortedProcs.OfType()) { if (pi.IsSelected) { @@ -160,17 +145,21 @@ namespace Volian.Print.Library lbSrchResults.DataSource = sortedResults; */ - foreach (ProcedureInfo pi in sortedProcs) + foreach (ProcedureInfo pi in sortedProcs.OfType()) { if (pi.IsSelected) { - PdfPTable tt = new PdfPTable(cols); - tt.KeepTogether = true; - tt.AddCell(AddSubTableCell(pi.DisplayNumber, f2, cols, paddingBottom)); + PdfPTable tt = new PdfPTable(cols) + { + KeepTogether = true + }; + tt.AddCell(AddSubTableCell(pi.DisplayNumber, f2, cols, paddingBottom)); tt.AddCell(AddSubTableCell(pi.MyDifferencesText, f3, cols, paddingBottom)); - PdfPCell c = new PdfPCell(tt); - c.Colspan = cols; - t.AddCell(c); + PdfPCell c = new PdfPCell(tt) + { + Colspan = cols + }; + t.AddCell(c); } } t.AddCell(BlankCell(cols)); @@ -179,60 +168,76 @@ namespace Volian.Print.Library if (didSome) doc.NewPage(); t = CreatePdfPTable(cols); CreatePageHeader(t, f1, f4, cols, paddingBottom, "Approval Consistency Report", "Procedures that should be selected to be approved in order to maintain consistency"); - foreach (ProcedureInfo pi in MyItemInfoList) + foreach (ProcedureInfo pi in MyItemInfoList.OfType()) { if (!pi.IsSelected) { - PdfPTable tt = new PdfPTable(cols); - tt.KeepTogether = true; - tt.AddCell(AddSubTableCell(pi.DisplayNumber, f2, cols, paddingBottom)); + PdfPTable tt = new PdfPTable(cols) + { + KeepTogether = true + }; + tt.AddCell(AddSubTableCell(pi.DisplayNumber, f2, cols, paddingBottom)); tt.AddCell(AddSubTableCell(pi.MyDifferencesText, f3, cols, paddingBottom)); - PdfPCell c = new PdfPCell(tt); - c.Colspan = cols; - t.AddCell(c); + PdfPCell c = new PdfPCell(tt) + { + Colspan = cols + }; + t.AddCell(c); } } doc.Add(t); } private PdfPCell AddSubTableCell(string text, iTextSharp.text.Font f, int cols, float pb) { - Phrase h = new Phrase(); - h.Font = f; - h.Add(text); - PdfPCell c = new PdfPCell(h); - c.Colspan = cols; - c.HorizontalAlignment = Element.ALIGN_LEFT; - c.PaddingBottom = pb; - return c; + Phrase h = new Phrase + { + Font = f + }; + h.Add(text); + PdfPCell c = new PdfPCell(h) + { + Colspan = cols, + HorizontalAlignment = Element.ALIGN_LEFT, + PaddingBottom = pb + }; + return c; } private void CreatePageHeader(PdfPTable t, iTextSharp.text.Font f1, iTextSharp.text.Font f2, int cols, float pb, string hdr1, string hdr2) { - //report title - Phrase h = new Phrase(); - h.Font = f1; - h.Add(hdr1); - PdfPCell c = new PdfPCell(h); - c.Colspan = cols; - c.HorizontalAlignment = Element.ALIGN_CENTER; - c.PaddingBottom = pb; - //c.Border = borders; - t.AddCell(c); - h = new Phrase(); - h.Font = f2; - h.Add(hdr2); - c = new PdfPCell(h); - c.Colspan = cols; - c.HorizontalAlignment = Element.ALIGN_CENTER; - c.PaddingBottom = pb; - //c.Border = borders; - t.AddCell(c); + //report title + Phrase h = new Phrase + { + Font = f1 + }; + h.Add(hdr1); + PdfPCell c = new PdfPCell(h) + { + Colspan = cols, + HorizontalAlignment = Element.ALIGN_CENTER, + PaddingBottom = pb + }; + t.AddCell(c); + h = new Phrase + { + Font = f2 + }; + h.Add(hdr2); + c = new PdfPCell(h) + { + Colspan = cols, + HorizontalAlignment = Element.ALIGN_CENTER, + PaddingBottom = pb + }; + t.AddCell(c); t.AddCell(BlankCell(cols)); } private PdfPTable CreatePdfPTable(int cols) { - PdfPTable t = new PdfPTable(cols); - t.HeaderRows = 3; - t.DefaultCell.Padding = 4; + PdfPTable t = new PdfPTable(cols) + { + HeaderRows = 3 + }; + t.DefaultCell.Padding = 4; t.WidthPercentage = 100; float[] widths = new float[] { 1f, 1f, 1f, 1f, 4f }; t.SetWidths(widths); @@ -251,7 +256,6 @@ namespace Volian.Print.Library } catch (Exception ex) { - StringBuilder msg = new StringBuilder(); document.Add(new Paragraph("Error:")); while (ex != null) { @@ -265,7 +269,7 @@ namespace Volian.Print.Library if (document.IsOpen()) { document.Close(); - System.Diagnostics.Process.Start(_FileName); + System.Diagnostics.Process.Start(FileName); } } } @@ -276,33 +280,40 @@ namespace Volian.Print.Library iTextSharp.text.Font f1 = pdf.GetFont(Volian.Base.Library.vlnFont.ReportsFont, 12, 1, Color.BLACK); iTextSharp.text.Font f2 = pdf.GetFont(Volian.Base.Library.vlnFont.ReportsFont, 10, 0, Color.BLACK); iTextSharp.text.Font f3 = pdf.GetFont(Volian.Base.Library.vlnFont.ReportsFont, 8, 0, Color.BLACK); - iTextSharp.text.Font f4 = pdf.GetFont(Volian.Base.Library.vlnFont.ReportsFont, 10, 2, Color.BLACK); int cols = 3; - int borders = 0; - int paddingBottom = 6; - PdfPTable t = new PdfPTable(cols); - t.HeaderRows = 1; - t.WidthPercentage = 100; - float[] widths = new float[] { 1f, 1f, 10f }; + PdfPTable t = new PdfPTable(cols) + { + HeaderRows = 1, + WidthPercentage = 100 + }; + float[] widths = new float[] { 1f, 1f, 10f }; t.SetWidths(widths); - Phrase h = new Phrase(); - h.Font = f1; - h.Add("Approved Procedures Inconsistencies Report"); - PdfPCell c = new PdfPCell(h); - c.Colspan = cols; - c.HorizontalAlignment = 1; - t.AddCell(c); - // C2021-013: Include the Procedure set name & date - h = new Phrase(); - h.Font = f1; - string tmp = MyDocVersion.MyFolder.Name + " " + DateTime.Now.ToString("M/d/yyyy"); + Phrase h = new Phrase + { + Font = f1 + }; + h.Add("Approved Procedures Inconsistencies Report"); + PdfPCell c = new PdfPCell(h) + { + Colspan = cols, + HorizontalAlignment = 1 + }; + t.AddCell(c); + // C2021-013: Include the Procedure set name & date + h = new Phrase + { + Font = f1 + }; + string tmp = MyDocVersion.MyFolder.Name + " " + DateTime.Now.ToString("M/d/yyyy"); h.Add(tmp); - c = new PdfPCell(h); - c.Colspan = cols; - c.HorizontalAlignment = 1; - t.AddCell(c); + c = new PdfPCell(h) + { + Colspan = cols, + HorizontalAlignment = 1 + }; + t.AddCell(c); Dictionary types = new Dictionary(); - foreach (ProcedureInfo pi in MyItemInfoList) + foreach (ProcedureInfo pi in MyItemInfoList.OfType()) { string type = pi.MyDifferences.ROConsistency.MyROChecks.Length > 0 ? "Reference Object Inconsistencies" : ""; if (type != string.Empty && !types.ContainsKey(0)) @@ -314,15 +325,18 @@ namespace Volian.Print.Library if (type != string.Empty && !types.ContainsKey(2)) types.Add(2, type); } -// types.Clear(); if (types.Count == 0) { - h = new Phrase(); - h.Font = f2; - h.Add("No Inconsistencies"); - c = new PdfPCell(h); - c.Colspan = cols; - t.AddCell(c); + h = new Phrase + { + Font = f2 + }; + h.Add("No Inconsistencies"); + c = new PdfPCell(h) + { + Colspan = cols + }; + t.AddCell(c); } else { @@ -335,7 +349,7 @@ namespace Volian.Print.Library ROFSTLookup lu = rofst.GetROFSTLookup(dvi); if (types.ContainsKey(0)) { - foreach (ProcedureInfo pi in MyItemInfoList) + foreach (ProcedureInfo pi in MyItemInfoList.OfType()) { foreach (ROCheck roc in pi.MyDifferences.ROConsistency.MyROChecks) { @@ -364,7 +378,7 @@ namespace Volian.Print.Library //Dictionary> trs = new Dictionary>(); if (types.ContainsKey(1)) { - foreach (ProcedureInfo pi in MyItemInfoList) + foreach (ProcedureInfo pi in MyItemInfoList.OfType()) { foreach (TransitionCheck trc in pi.MyDifferences.TransitionConsistency.MyTransitionChecks) { @@ -397,7 +411,7 @@ namespace Volian.Print.Library //Dictionary> lds = new Dictionary>(); if (types.ContainsKey(2)) { - foreach (ProcedureInfo pi in MyItemInfoList) + foreach (ProcedureInfo pi in MyItemInfoList.OfType()) { foreach (LibDocCheck ldc in pi.MyDifferences.LibDocConsistency.MyLibDocChecks) { @@ -420,28 +434,38 @@ namespace Volian.Print.Library Color badColor = new Color(System.Drawing.Color.Khaki); if (types.ContainsKey(0)) { - h = new Phrase(); - h.Font = f2; - h.Add(types[0]); - c = new PdfPCell(h); - c.Colspan = cols; - t.AddCell(c); + h = new Phrase + { + Font = f2 + }; + h.Add(types[0]); + c = new PdfPCell(h) + { + Colspan = cols + }; + t.AddCell(c); foreach (string rotitle in ros.Keys) { t.AddCell(BlankCell(1)); - h = new Phrase(); - h.Font = f3; - h.Add(rotitle); - c = new PdfPCell(h); - c.Colspan = cols - 1; - c.BackgroundColor = goodColor; - t.AddCell(c); + h = new Phrase + { + Font = f3 + }; + h.Add(rotitle); + c = new PdfPCell(h) + { + Colspan = cols - 1, + BackgroundColor = goodColor + }; + t.AddCell(c); foreach (KeyValuePair d in ros[rotitle]) { t.AddCell(BlankCell(2)); - h = new Phrase(); - h.Font = f3; - h.Add(d.Key); + h = new Phrase + { + Font = f3 + }; + h.Add(d.Key); c = new PdfPCell(h); if (d.Value) c.BackgroundColor = goodColor; @@ -451,31 +475,40 @@ namespace Volian.Print.Library } } } -//jcb if (types.ContainsKey(1)) { - h = new Phrase(); - h.Font = f2; - h.Add(types[1]); - c = new PdfPCell(h); - c.Colspan = cols; - t.AddCell(c); + h = new Phrase + { + Font = f2 + }; + h.Add(types[1]); + c = new PdfPCell(h) + { + Colspan = cols + }; + t.AddCell(c); foreach (string trtitle in trs.Keys) { t.AddCell(BlankCell(1)); - h = new Phrase(); - h.Font = f3; - h.Add(trtitle); - c = new PdfPCell(h); - c.Colspan = cols - 1; - c.BackgroundColor = goodColor; - t.AddCell(c); + h = new Phrase + { + Font = f3 + }; + h.Add(trtitle); + c = new PdfPCell(h) + { + Colspan = cols - 1, + BackgroundColor = goodColor + }; + t.AddCell(c); foreach (KeyValuePair d in trs[trtitle]) { t.AddCell(BlankCell(2)); - h = new Phrase(); - h.Font = f3; - h.Add(d.Key); + h = new Phrase + { + Font = f3 + }; + h.Add(d.Key); c = new PdfPCell(h); if (d.Value) c.BackgroundColor = goodColor; @@ -488,28 +521,38 @@ namespace Volian.Print.Library //end jcb if (types.ContainsKey(2)) { - h = new Phrase(); - h.Font = f2; - h.Add(types[2]); - c = new PdfPCell(h); - c.Colspan = cols; - t.AddCell(c); + h = new Phrase + { + Font = f2 + }; + h.Add(types[2]); + c = new PdfPCell(h) + { + Colspan = cols + }; + t.AddCell(c); foreach (string ldtitle in lds.Keys) { t.AddCell(BlankCell(1)); - h = new Phrase(); - h.Font = f3; - h.Add(ldtitle); - c = new PdfPCell(h); - c.Colspan = cols - 1; - c.BackgroundColor = goodColor; - t.AddCell(c); + h = new Phrase + { + Font = f3 + }; + h.Add(ldtitle); + c = new PdfPCell(h) + { + Colspan = cols - 1, + BackgroundColor = goodColor + }; + t.AddCell(c); foreach (KeyValuePair d in lds[ldtitle]) { t.AddCell(BlankCell(2)); - h = new Phrase(); - h.Font = f3; - h.Add(d.Key); + h = new Phrase + { + Font = f3 + }; + h.Add(d.Key); c = new PdfPCell(h); if (d.Value) c.BackgroundColor = goodColor; diff --git a/PROMS/Volian.Print.Library/PDFPageSize.cs b/PROMS/Volian.Print.Library/PDFPageSize.cs index d294ceab..c4db26d2 100644 --- a/PROMS/Volian.Print.Library/PDFPageSize.cs +++ b/PROMS/Volian.Print.Library/PDFPageSize.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using VEPROMS.CSLA.Library; +using System.Collections.Generic; using iTextSharp.text; @@ -11,9 +6,11 @@ namespace Volian.Print.Library { public class PDFPageSize { - // C2020-002 paper size is now set in the format files - this class is use to select the page size that PROMS should be using - private static Dictionary dicPDFPageSize = new Dictionary(); - private static Dictionary dicPDFPageSizePnts = new Dictionary(); + // C2020-002 paper size is now set in the format files - this class is use to select the page size that PROMS should be using + [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0044:Add readonly modifier", Justification = "Keeping Collections Not ReadOnly")] + private static Dictionary dicPDFPageSize = new Dictionary(); + [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0044:Add readonly modifier", Justification = "Keeping Collections Not ReadOnly")] + private static Dictionary dicPDFPageSizePnts = new Dictionary(); private static void BuildPDFPageSizeDic() { // the page size is set in the format files using a string description i.e.: diff --git a/PROMS/Volian.Print.Library/PDFReport.cs b/PROMS/Volian.Print.Library/PDFReport.cs index e660630e..2fec6f98 100644 --- a/PROMS/Volian.Print.Library/PDFReport.cs +++ b/PROMS/Volian.Print.Library/PDFReport.cs @@ -1,2018 +1,1967 @@ -using System; -using System.Collections.Generic; -using System.Text; -using VEPROMS.CSLA.Library; -using iTextSharp.text.pdf; using iTextSharp.text; -using System.IO; -using System.Text.RegularExpressions; +using iTextSharp.text.pdf; +using System; using System.Collections; +using System.Collections.Generic; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using VEPROMS.CSLA.Library; namespace Volian.Print.Library { - // B2022-026 New code for RO Memory reduction - now use SQL tables instead of building dictionarys to get RO values - public class PDFReport - { - #region Enums - - public enum ReportType - { - SearchResults = 0, - LibraryDocUsage = 1, - ReferencedObjectsUsage = 2, - TransitionUsage = 3, - ReferencedObjectSummary = 4, - ReferencedObjectComplete = 5 - } - - #endregion - - #region Fields - - private PdfWriter _MyPdfWriter; - private ICollection _ResultList; - - private string _FileName; - private string _ReportTitle; - private string _TypesSelected; - private bool _ShowAnnotations = true; - private string _SearchString; - private string _SortedBy; // C2019-013 pass in sorting information - private DocumentInfoList _LibDocList; - - private int _ReportType = 0; - private string _ByLine; - private bool _SortUsageByProcedure = false; - private string _RODataFile = string.Empty; - private List _ROList; - private ROFSTLookup _ROFSTLookup; - private bool _IncludeMissingROs = false; - private bool _ConvertCaretToDelta = true; - private bool _IncludeEmptyROFields = false; - - private string _PaperSize = "Letter"; // C2020-002 paper size is now set in the format files - private string _RegexSearchString = null; - private ArrayList ProcSetList; - - #endregion - - #region Properties - - public ICollection ResultList - { - get { return _ResultList; } - set { _ResultList = value; } - } - - public string FileName - { - get { return _FileName; } - set { _FileName = value; } - } - - public string ReportTitle - { - get { return _ReportTitle; } - set { _ReportTitle = value; } - } - - public string TypesSelected - { - get { return _TypesSelected; } - set { _TypesSelected = value; } - } - - public bool ShowAnnotations - { - get { return _ShowAnnotations; } - set { _ShowAnnotations = value; } - } - - public string SearchString - { - get { return _SearchString; } - set { _SearchString = VEPROMS.CSLA.Library.ItemInfo.ConvertToDisplayText(value); } - } - - public string SortedBy - { - get { return _SortedBy; } - set { _SortedBy = value; } - } - - public DocumentInfoList LibDocList - { - get { return _LibDocList; } - set { _LibDocList = value; } - } - - private string RegexSearchString - { - get - { - if (_RegexSearchString == null) - { - _RegexSearchString = _SearchString; - - // Make it match the smallest matching string - _RegexSearchString = _RegexSearchString.Replace("*", ".*?"); - - // If search string starts with a wildcard use the beginning of line token (^) - if (_RegexSearchString.StartsWith(".*?")) - { - _RegexSearchString = "^" + _RegexSearchString; - } - - // If search string ends with a wildcard use the end of line token ($) - if (_RegexSearchString.EndsWith(".*?")) - { - _RegexSearchString = _RegexSearchString + "$"; - } - - _RegexSearchString = _RegexSearchString.Replace("[", @"\["); - _RegexSearchString = _RegexSearchString.Replace("]", @"\]"); - _RegexSearchString = _RegexSearchString.Replace("(", @"\("); - _RegexSearchString = _RegexSearchString.Replace(")", @"\)"); - } - - return _RegexSearchString; - } - } - - #endregion - - #region Constructors - - /// - /// Search Results Report - /// - /// - /// - /// - /// - /// - /// - public PDFReport(string reportTitle, string typesSelected, ICollection resultList, string fileName, string paperSize, string sortedBy) - { - _ResultList = resultList; - _FileName = fileName; - _ReportTitle = VEPROMS.CSLA.Library.ItemInfo.ConvertToDisplayText(reportTitle); - _TypesSelected = VEPROMS.CSLA.Library.ItemInfo.ConvertToDisplayText(typesSelected); - _ReportType = (int)ReportType.SearchResults; - _ByLine = "PROMS Search Results"; - _PaperSize = paperSize; - _SortedBy = sortedBy; // C2019--13 pass in sorted by information - - } - - /// - /// Library Document Report - /// - /// - /// - /// - /// - public PDFReport(string reportTitle, DocumentInfoList libDocList, string fileName, string paperSize) - { - _LibDocList = libDocList; - _FileName = fileName; - _ReportTitle = VEPROMS.CSLA.Library.ItemInfo.ConvertToDisplayText(reportTitle); - _ReportType = (int)ReportType.LibraryDocUsage; - _ByLine = "Generated By PROMS"; - _PaperSize = paperSize; - } - - /// - /// RO Usage - /// - /// - /// - /// - /// - /// - /// - public PDFReport(string reportTitle, ICollection resultList, string fileName, bool sortUsageByProcedure, bool includeMissingROs, string paperSize) - { - _ResultList = resultList; - _FileName = fileName; - _ReportTitle = VEPROMS.CSLA.Library.ItemInfo.ConvertToDisplayText(reportTitle); - _ReportType = (int)ReportType.ReferencedObjectsUsage; - _ByLine = "Generated By PROMS"; - _SortUsageByProcedure = sortUsageByProcedure; - _IncludeMissingROs = includeMissingROs; - _PaperSize = paperSize; - } - - /// - /// RO Complete RO Report - /// - /// - /// - /// - /// - /// - /// - /// - /// - public PDFReport(string reportTitle, string roDataFile, string outfile, ROFSTLookup fstlookup, bool completeReport, bool convertCaretToDelta, bool includeEmptyROFields, string paperSize) - { - _FileName = outfile; - _ReportTitle = reportTitle; - _ReportType = (int)ReportType.ReferencedObjectComplete; - _ByLine = "Complete Referenced Objects Report"; - _RODataFile = roDataFile; - _ConvertCaretToDelta = convertCaretToDelta; - _ROFSTLookup = fstlookup; - _IncludeEmptyROFields = includeEmptyROFields; - _PaperSize = paperSize; - } - - /// - /// RO Summary Report - /// - /// - /// - /// - /// - /// - public PDFReport(string reportTitle, string outfile, ROFSTLookup fstlookup, List roList, string paperSize) - { - _FileName = outfile; - _ReportTitle = reportTitle; - _ReportType = (int)ReportType.ReferencedObjectSummary; - _ByLine = "RO Summary Report"; - _ROFSTLookup = fstlookup; - _ROList = roList; - _PaperSize = paperSize; - } - - #endregion - - #region Public Methods - - public void AddMainRODatabaseTitle(PdfPTable datatable, int dbTitleIndex, Font f2, Color bgColor) - { - string dbTitle = _ROFSTLookup.GetRODatabaseTitle(dbTitleIndex); - - PdfPCell cell = new PdfPCell(new Phrase(dbTitle, f2)); - cell.BorderColor = Color.WHITE; - cell.Colspan = 2; - cell.BackgroundColor = bgColor; - datatable.AddCell(cell); - } - - public void AddMainPathGroup(PdfPTable datatable, string dvPath, int splitLevel, Font f2, Color bgColor, int colSpan) - { - int level = 0; - StringBuilder sb = new StringBuilder(); - string[] NewPath = dvPath.Split("\x7".ToCharArray()); - string sep = string.Empty; - 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?", "-").Replace(@"\u9586?", @"\"); - sep = "\r\n"; - level++; - } - - if (sb.Length > 0) - { - PdfPCell cell = new PdfPCell(new Phrase(sb.ToString(), f2)); - - cell.Colspan = colSpan; - cell.BackgroundColor = bgColor; - cell.BorderWidthTop = 1; - - datatable.AddCell(cell); - } - } - - public void AddSubPathGroup(PdfPTable datatable, string oldDVPath, string dvPath, int splitLevel, Font f2, Color bgColor, int colSpan) - { - int level = 0; - StringBuilder sb = new StringBuilder(); - string[] NewPath = dvPath.Split("\x7".ToCharArray()); - string[] OldPath = oldDVPath.Split("\x7".ToCharArray()); - string sep = string.Empty; - int n = NewPath.Length - 1; - - for (int i = 0; i < n; i++) - { - if (OldPath[i] != NewPath[i]) - { - splitLevel = Math.Max(splitLevel, i); - break; - } - } - - if (splitLevel < n) - { - for (int j = splitLevel; j < n; j++) - { - sb.Append(sep + "".PadLeft(2 * level) + NewPath[j].Replace("\x11", " ")).Replace(@"\u8209?", "-").Replace(@"\u9586?", @"\"); - sep = "\r\n"; - level++; - } - - if (sb.Length > 0) - { - PdfPCell cell = new PdfPCell(new Phrase(sb.ToString(), f2)); - - cell.Colspan = colSpan; - cell.BackgroundColor = bgColor; - cell.BorderWidthTop = 1; - - datatable.AddCell(cell); - } - } - } - - public void Build() - { - iTextSharp.text.Document document = new iTextSharp.text.Document(PDFPageSize.UsePaperSize(_PaperSize), 36, 36, 36, 36); // C2020-002 paper size is now set in the format files - - if (!CreateResultsPDF(document, _ReportType)) - return; - - try - { - switch (_ReportType) // set in the PDFReport constructor - { - case (int)ReportType.SearchResults: - BuildSearchResultsTable(document); - break; - - case (int)ReportType.LibraryDocUsage: - BuildLibDocUsageReport(document); - break; - - case (int)ReportType.ReferencedObjectsUsage: - if (_SortUsageByProcedure) - BuildROUsageTableByProcedure(document); - else - BuildROUsageTableByRO(document); - break; - - case (int)ReportType.ReferencedObjectComplete: - BuildCompleteROReport(document); - break; - - case (int)ReportType.ReferencedObjectSummary: - BuildROSummaryReport(document); - break; - } - } - catch (Exception ex) - { - StringBuilder msg = new StringBuilder(); - document.Add(new Paragraph("Error:")); - - while (ex != null) - { - document.Add(new Paragraph(ex.GetType().Name)); - document.Add(new Paragraph(ex.Message)); - ex = ex.InnerException; - } - } - finally - { - if (document.IsOpen()) - { - //document.Add(new Phrase("End of Search Results",FontFactory.GetFont("Arial",4))); // B2019-089 commented out - used for debug - document.Add(new Phrase(" ", FontFactory.GetFont("Arial", 4))); // B2019-089 - assure output has at least a blank space to prevent error on close - document.Close(); - System.Diagnostics.Process.Start(_FileName); - } - } - } - - #endregion - - #region Private Methods - - private string AddGroup(PdfPTable datatable, string dvPath, string lastDvPath, Font f2, bool StripLast, Color bgColor, bool skipFirst) - { - int level = 0; - string retval = string.Empty; - StringBuilder sb = new StringBuilder(); - string ttt = dvPath.Replace("\x11", " "); - string[] OldPath = lastDvPath.Split("\x7".ToCharArray()); - string[] NewPath = dvPath.Split("\x7".ToCharArray()); - string sep = string.Empty; - bool foundMisMatch = false; - - // n-1 Exclude the "Working Draft" entry from the list - int n = NewPath.Length - 1; - int jstart = (skipFirst) ? 1 : 0; - - if (StripLast) - { - retval = NewPath[--n]; - if (retval.Contains("\x11")) - { - retval = retval.Substring(0, retval.IndexOf("\x11")); // this is the step number - } - } - - if (n == 0) - { - // B2020-006: 'clean-up' the output string by making string replaces as in 'else' below. - sb.Append(dvPath.Replace("\x11", " ").Replace(@"\u8209?", "-").Replace(@"\u160?", " ").Replace(@"\u9586?", @"\")); - } - else - { - for (int j = jstart; j < n; j++) - { - if (!string.IsNullOrEmpty(NewPath[j]) && (foundMisMatch || OldPath.Length < j + 1 || NewPath[j] != OldPath[j])) - { - // B2020-006: Add hard space '\u160?' - sb.Append(sep + "".PadLeft(2 * level) + NewPath[j].Replace("\x11", " ")).Replace(@"\u8209?", "-").Replace(@"\u160?", " ").Replace(@"\u9586?", @"\"); - sep = "\r\n"; - foundMisMatch = true; - } - - level++; - } - } - - if (sb.Length > 0) - { - PdfPCell cell = new PdfPCell(new Phrase(sb.ToString(), f2)); - - cell.Colspan = 2; - cell.BackgroundColor = bgColor; - cell.BorderWidthTop = 1; - datatable.AddCell(cell); - } - - return retval; - } - - private string AddGroupLibDoc(PdfPTable datatable, string dvPath, string lastDvPath, Font f2, bool StripLast, Color bgColor, bool skipFirst) - { - int level = 0; - string retval = string.Empty; - StringBuilder sb = new StringBuilder(); - string ttt = dvPath.Replace("\x11", " "); - string[] OldPath = lastDvPath.Split("\x7".ToCharArray()); - string[] NewPath = dvPath.Split("\x7".ToCharArray()); - string sep = string.Empty; - bool foundMisMatch = false; - int n = NewPath.Length - 1; - int jstart = (skipFirst) ? 1 : 0; - - if (StripLast) - { - retval = NewPath[--n]; - if (retval.Contains("\x11")) - { - retval = retval.Substring(0, retval.IndexOf("\x11")); // this is the step number - } - } - - //If no colons output the entire text - if (n == 0) - { - sb.Append(dvPath); - } - else - { - for (int j = jstart; j < n; j++) - { - if (!string.IsNullOrEmpty(NewPath[j]) && (foundMisMatch || OldPath.Length < j + 1 || NewPath[j] != OldPath[j])) - { - sb.Append(sep + "".PadLeft(2 * level) + NewPath[j].Replace("\x11", " ")).Replace(@"\u8209?", "-").Replace(@"\u9586?", @"\"); - sep = "\r\n"; - foundMisMatch = true; - } - - level++; - } - } - - if (sb.Length > 0) - { - PdfPCell cell = new PdfPCell(new Phrase(sb.ToString(), f2)); - - cell.Colspan = 2; - cell.BackgroundColor = bgColor; - cell.BorderWidthTop = 1; - datatable.AddCell(cell); - } - - return retval; - } - - private void AddProcedureSectionGroup(PdfPTable datatable, string curProc, string lastProc, string curSect, string lastSect, Font f2, Color bgColor) - { - string headerText = string.Empty; - - if (curProc != lastProc) - headerText = curProc + "\r\n"; - - if (curSect != lastSect) - headerText += " " + curSect; - - if (headerText.Length > 0) - { - 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; - cell.BorderWidthTop = 1; - datatable.AddCell(cell); - } - } - - private string GetCurProcNum(string path) - { - string[] NewPath = path.Split("\x7".ToCharArray()); - string pnumtitle = NewPath[1]; - pnumtitle = pnumtitle.Replace('\x11', ' '); - - return pnumtitle; - } - - private string GetCurSectionNumTitle(ItemInfo itm) - { - string rtnstr = string.Empty; - - if (itm.ActiveSection != null) - { - rtnstr = itm.ActiveSection.DisplayNumber; - if (rtnstr.Length > 0) rtnstr += " "; - rtnstr += itm.ActiveSection.DisplayText; - } - - return rtnstr; // string containing section and subsection number/titles - } - - private int FindSpitLevel() - { - int level = 0; - bool foundMisMatch = false; - string lastPath = string.Empty; - - foreach (string p in ProcSetList) - { - string[] NewPath = p.Split("\x7".ToCharArray()); - - if (lastPath != string.Empty) - { - string[] OldPath = lastPath.Split("\x7".ToCharArray()); - int n = NewPath.Length; - int lvl = 0; - foundMisMatch = false; - - for (int j = 0; j < n && !foundMisMatch; j++) - { - if (NewPath[j] != string.Empty && (OldPath.Length < j + 1 || NewPath[j] != OldPath[j])) - { - foundMisMatch = true; - } - - lvl++; - } - - if (level == 0) - level = lvl; - - if (foundMisMatch) - level = Math.Min(level, lvl); - } - - lastPath = p; - - if (ProcSetList.Count == 1) - { - level = NewPath.Length - 1; - } - } - - return level; - } - - /// - /// Attempt to open a file for the PDF output. - /// If the file cannot be opened because it is in use, try adding a suffix - /// If the file cannot be opened for some other reason, display an error message - /// - /// - /// - private bool CreateResultsPDF(iTextSharp.text.Document document, int typ) - { - int topMargin = 36; - - switch (typ) - { - case (int)ReportType.LibraryDocUsage: - topMargin = 80; // Add some space for the Report Header for the Library Document Report - break; - } - - bool result = false; - string suffix = string.Empty; - int i = 0; - - // Try to open a file for creating the PDF. - while (result == false) - { - string fileName = _FileName.ToLower().Replace(".pdf", suffix + ".pdf"); - - try - { - _MyPdfWriter = PdfWriter.GetInstance(document, new FileStream(fileName, FileMode.Create)); - _MyPdfWriter.PageEvent = new MyPageHelper(_ByLine); // JSJ - 7/8/2011 - - document.SetMargins(36, 36, topMargin, 36); - document.Open(); - - _FileName = fileName; - - result = true; - } - catch (System.IO.IOException exIO) - { - if (exIO.Message.Contains("because it is being used by another process")) - { - suffix = string.Format("_{0}", ++i);// If this file is in use, increment the suffix and try again - } - else // If some other error, display a message and don't print the results - { - ShowException(exIO); - return false; - } - } - catch (Exception ex) - { - ShowException(ex); - return false; // Could not open the output file - } - } - - return true; - } - - /// - /// Use Cells within Cells to see if I can limit the way Cells break from Page to Page - /// - /// - private void BuildSearchResultsTable(iTextSharp.text.Document document) - { - float[] headerwidths = { 20, 80 }; - PdfPTable datatable = new PdfPTable(1); - PdfPTable colHeader = new PdfPTable(headerwidths); - //datatable.FooterRows = 1; - datatable.TotalWidth = document.PageSize.Width - document.LeftMargin - document.RightMargin; - datatable.LockedWidth = true; - - // C2017-036 get best available proportional font for symbols that looks close to Arial - // Note that Microsoft no longer supplies Arial Unicode MS as of Word16 - iTextSharp.text.Font f1 = pdf.GetFont(Volian.Base.Library.vlnFont.ReportsFont, 14, 1, Color.BLACK); - iTextSharp.text.Font f2 = pdf.GetFont(Volian.Base.Library.vlnFont.ReportsFont, 10, 0, Color.BLACK); - iTextSharp.text.Font f3 = pdf.GetFont(Volian.Base.Library.vlnFont.ReportsFont, 12, 0, Color.BLACK); - PdfPCell cell = new PdfPCell(new Phrase(ReportTitle, f1)); - cell.HorizontalAlignment = Element.ALIGN_CENTER; - cell.BackgroundColor = new Color(0xD0, 0xF0, 0xF0); // light cyan - datatable.AddCell(cell); - - // C2019-013 add sorted by information if sorting is used - cell = new PdfPCell(new Phrase(TypesSelected + ((SortedBy.Length > 0) ? string.Format("\n{0}", SortedBy) : string.Empty), f3)); - cell.HorizontalAlignment = Element.ALIGN_LEFT; - cell.BackgroundColor = new Color(0xD0, 0xF0, 0xF0); // light cyan - datatable.AddCell(cell); - - BuildSearchResultsProcSetList(); - datatable.HeaderRows = 4 + (ProcSetList.Count == 1 ? 1 : 0); - int splitAt = FindSpitLevel(); // find the split level of the common path - for all procedure sets that use these library documents - - Color subHeaderColor = new Color(0xD0, 0xF0, 0xF0); // new Color(0xD0, 0xF0, 0xD0); - datatable.DefaultCell.Padding = 0; // this removes a white space after the header was set to 4; - datatable.DefaultCell.HorizontalAlignment = Element.ALIGN_CENTER; - AddCell(colHeader, "Step", f2, subHeaderColor); - AddCell(colHeader, "Text", f2, subHeaderColor); - - datatable.DefaultCell.HorizontalAlignment = Element.ALIGN_LEFT; - string lastPath = string.Empty; - Color AnnoColor = new Color(0xFF, 0xFF, 0xC0); // yellow - Color TextColor = Color.WHITE; - Color WordSectColor = new Color(0xE8, 0xE8, 0xE8);// light grey - Color StepSectColor = new Color(0xE7, 0xFF, 0xE7); // lighter green - PdfPTable subTable = new PdfPTable(headerwidths); - string lastProcNum = string.Empty; - string lastDVPath = string.Empty; - string lastSectNumAndTitle = string.Empty; - List processedItems = new List(); - - foreach (ItemInfo item in _ResultList) - { - if (!processedItems.Contains(item.ItemID)) - { - processedItems.Add(item.ItemID); - - if (lastDVPath != item.SearchDVPath) - { - datatable.AddCell(subTable); - subTable = new PdfPTable(headerwidths); - AddMainPathGroup(datatable, item.SearchDVPath, splitAt, f2, new Color(0xB0, 0xF0, 0xF0), 0);// little brighter cyan - datatable.AddCell(colHeader); - lastProcNum = string.Empty; - lastSectNumAndTitle = string.Empty; // C2020-019 reset we are processing a different procedure set - } - - lastDVPath = item.SearchDVPath; - string curProcNum = GetCurProcNum(item.SearchPath); - - if (subTable.Rows.Count > 0) // prevent first page from being blank - { - datatable.AddCell(subTable); - subTable = new PdfPTable(headerwidths); - } - - if (curProcNum != lastProcNum) - { - lastSectNumAndTitle = string.Empty; // C2020-019 reset we are processing a different procedure - } - - lastProcNum = curProcNum; - - // B2020-006: When doing a section, don't remove the last item or the procedure title won't print (if section is only item found w/ search string) - string stepPath = AddGroup(subTable, item.SearchPath ?? item.ShortPath, lastPath, f2, item.IsSection ? false : true, new Color(0xC0, 0xFF, 0xC0), true); // light green for procedure number and title - - // C2020-019 add section number and title if is different from last item and it is not a Word Section (item will be a section if search item was found in a Word section) - string curSectNumTitle = GetCurSectionNumTitle(item); - - if (curSectNumTitle != string.Empty && curSectNumTitle != lastSectNumAndTitle && !item.IsSection) - { - AddColSpanCell(subTable, curSectNumTitle, f2, StepSectColor, 2, 0); - lastSectNumAndTitle = curSectNumTitle; - } - - lastPath = item.SearchPath ?? item.ShortPath; - stepPath = BuildStepTab(item); - AddCell(subTable, stepPath, f2, (item.IsSection ? WordSectColor : TextColor)); - AddCell(subTable, item.DisplayText, f2, (item.IsSection ? WordSectColor : TextColor)); - - if (ShowAnnotations && item.ItemAnnotationCount > 0) - { - foreach (AnnotationInfo ai in item.ItemAnnotations) - { - AddCell(subTable, ai.MyAnnotationType.Name, f2, AnnoColor); - AddCell(subTable, ai.SearchText, f2, AnnoColor); - } - } - } - } - - datatable.AddCell(subTable); - document.Add(datatable); - } - - private void AddCell(PdfPTable datatable, string str, iTextSharp.text.Font fnt, Color bgColor) - { - iTextSharp.text.Font fntBold = new Font(fnt.BaseFont, fnt.Size, Font.BOLD, Color.RED); - - Phrase p = BuildPhrase2(str, fnt, fntBold); - PdfPCell cell = new PdfPCell(p); - cell.PaddingBottom = 4; - cell.BackgroundColor = bgColor; - - datatable.AddCell(cell); - } - - private void AddColSpanCell(PdfPTable datatable, string str, iTextSharp.text.Font fnt, Color bgColor, int span, int txtAlign) - { - iTextSharp.text.Font fntBold = new Font(fnt.BaseFont, fnt.Size, Font.BOLD, Color.RED); - - Phrase p = BuildPhrase2(str, fnt, fntBold); - PdfPCell cell = new PdfPCell(p); - cell.PaddingBottom = 4; - cell.BackgroundColor = bgColor; - cell.Colspan = span; - cell.HorizontalAlignment = txtAlign; - - datatable.AddCell(cell); - } - - private Phrase BuildPhrase(string str, Font fnt, Font fntBold) - { - Phrase p = new Phrase(); - - if (_SearchString != null) - { - while (str.ToLower().Contains(_SearchString.ToLower())) - { - int iStart = str.ToLower().IndexOf(_SearchString.ToLower()); - - if (iStart > 0) - { - p.Add(new Phrase(str.Substring(0, iStart), fnt)); - } - - Phrase p2 = new Phrase(str.Substring(iStart, _SearchString.Length), fntBold); - p.Add(p2); - - str = str.Substring(iStart + _SearchString.Length); - } - } - - if (str.Length > 0) - p.Add(new Phrase(str, fnt)); - - return p; - } - - private Phrase BuildPhrase2(string str, Font fnt, Font fntBold) - { - Phrase p = new Phrase(); - int lastIndex = 0; - - if ((_SearchString ?? string.Empty) != string.Empty) - { - Regex reg = new Regex(RegexSearchString, RegexOptions.Multiline | RegexOptions.IgnoreCase); - - foreach (Match m in reg.Matches(str)) - { - if (m.Index > 0) - p.Add(new Phrase(str.Substring(lastIndex, m.Index - lastIndex), fnt)); - - Chunk chk = new Chunk(m.Value, fnt); - chk.SetBackground(Color.YELLOW); - p.Add(chk); - - lastIndex = m.Index + m.Length; - } - } - - p.Add(new Phrase(str.Substring(lastIndex), fnt)); - - return p; - } - - private void BuildLibDocUsageReport(iTextSharp.text.Document document) - { - // Adjusted from 20,80 to 25,75 to account for long Procedure Numbers - float[] headerwidths = { 25, 75 }; - // C2017-036 get best available proportional font for symbols that looks close to Arial - // Note that Microsoft no longer supplies Arial Unicode MS as of Word16 - iTextSharp.text.Font f2 = pdf.GetFont(Volian.Base.Library.vlnFont.ReportsFont, 10, 0, Color.BLACK); - BuildLibDocProcSetList(); - - int splitAt = FindSpitLevel() - 1; // find the split level of the common path - for all procedure sets that use these library documents - string lastDvPath = string.Empty; - Color AnnoBackgroundColor = new Color(0xFF, 0xFF, 0xC0); - Color TextBackgroundColor = Color.WHITE; - Color NotUsedBackgroundColor = Color.WHITE; - MyPageHelper pghlp = _MyPdfWriter.PageEvent as MyPageHelper; - pghlp.HeaderTable = LibDocTable(document, headerwidths, f2, null); - - foreach (DocumentInfo di in _LibDocList) - { - PdfPTable subtable; - subtable = BuildSubTable(document, headerwidths); - - AddGroupLibDoc(subtable, di.DocumentTitle, string.Empty, f2, false, new Color(0xC0, 0xFF, 0xC0), false); // Library Document Title - - if (di.DocumentConfig.LibDoc_Comment != null && di.DocumentConfig.LibDoc_Comment.Length > 0) - { - AddCell(subtable, "Comment", f2, AnnoBackgroundColor); - AddCell(subtable, di.DocumentConfig.LibDoc_Comment, f2, AnnoBackgroundColor); // lib doc comment - } - - if (di.DocumentEntries == null || di.DocumentEntries.Count == 0) - { - AddGroupLibDoc(subtable, "* No References To This Library Document *", string.Empty, f2, false, TextBackgroundColor, false); // Library Document Title - } - else - { - subtable.HeaderRows = 2; - System.Collections.ArrayList LibDocUsageList = GetSortedItemInfoList(di.LibraryDocumentUsageList); - lastDvPath = string.Empty; - - foreach (ItemInfo item in LibDocUsageList)//di.LibraryDocumentUsageList) - { - if (item.SearchDVPath != lastDvPath) - { - if (lastDvPath != string.Empty) - { - document.Add(subtable); - subtable = BuildSubTable(document, headerwidths); - subtable.HeaderRows = 2; - AddGroupLibDoc(subtable, di.DocumentTitle, string.Empty, f2, false, new Color(0xC0, 0xFF, 0xC0), false); // Library Document Title - } - - AddSubPathGroup(subtable, lastDvPath, item.SearchDVPath, splitAt, f2, Color.LIGHT_GRAY, 2);//new Color(0xC0, 0xFF, 0xC0)); - } - - lastDvPath = item.SearchDVPath; - 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); - } - - } - - document.Add(subtable); - } - } - - private PdfPTable LibDocTable(iTextSharp.text.Document document, float[] headerwidths, iTextSharp.text.Font f2, DocumentInfo di) - { - PdfPTable datatable = new PdfPTable(1);// (headerwidths); - PdfPTable colheader = new PdfPTable(headerwidths); - datatable.HeaderRows = 2; - datatable.KeepTogether = false; - datatable.TotalWidth = document.PageSize.Width - document.LeftMargin - document.RightMargin; - datatable.LockedWidth = true; - - // C2017-036 get best available proportional font for symbols that looks close to Arial - // Note that Microsoft no longer supplies Arial Unicode MS as of Word16 - iTextSharp.text.Font f1 = pdf.GetFont(Volian.Base.Library.vlnFont.ReportsFont, 14, 1, Color.BLACK); - iTextSharp.text.Font f3 = pdf.GetFont(Volian.Base.Library.vlnFont.ReportsFont, 12, 0, Color.BLACK); - PdfPCell cell = new PdfPCell(new Phrase(ReportTitle, f1)); - cell.HorizontalAlignment = Element.ALIGN_CENTER; - //cell.Colspan = 2; - - cell.BackgroundColor = new Color(0xD0, 0xF0, 0xF0); - datatable.AddCell(cell); - - Color subHeaderColor = new Color(0xD0, 0xF0, 0xD0); - datatable.DefaultCell.Padding = 4; - datatable.DefaultCell.HorizontalAlignment = Element.ALIGN_CENTER; - AddCell(colheader, "Procedure", f2, subHeaderColor); - AddCell(colheader, "Section", f2, subHeaderColor); - datatable.AddCell(colheader); - - datatable.DefaultCell.HorizontalAlignment = Element.ALIGN_LEFT; - - return datatable; - } - - private void AddROUsages(ItemInfo item, Dictionary> roUse) - { - if (item != null && !string.IsNullOrEmpty(item.FoundROID)) - { - string roid = item.FoundROID; - - if (roUse.ContainsKey(roid)) - { - ((List)roUse[roid]).Add(item); - } - else - { - List itmIfoLst = new List(); - itmIfoLst.Add(item); - roUse.Add(roid, itmIfoLst); - } - } - } - - private void PutROusageForProcedure(PdfPTable curTable, Dictionary> rosused, float[] headerwidths) - { - //if (rosused.Count == 0) return; // nothing to process - // C2017-036 get best available proportional font for symbols that looks close to Arial - // Note that Microsoft no longer supplies Arial Unicode MS as of Word16 - iTextSharp.text.Font f2 = pdf.GetFont(Volian.Base.Library.vlnFont.ReportsFont, 10, 0, Color.BLACK); - - foreach (string roKey in rosused.Keys) - { - PdfPTable rotable = new PdfPTable(headerwidths); - string rotitle = string.Empty; - - foreach (ItemInfo itm in rosused[roKey]) - { - if (string.IsNullOrEmpty(rotitle)) - { - rotitle = GetROTitleAndGroup(roKey, itm); - - if (!string.IsNullOrEmpty(rotitle)) - { - PdfPCell ROTitleCell = new PdfPCell(new Phrase(rotitle, f2)); - ROTitleCell.Colspan = 2; - ROTitleCell.HorizontalAlignment = Element.ALIGN_LEFT; - - if (rotitle.StartsWith("Missing RO")) - { - ROTitleCell.BackgroundColor = Color.PINK; - } - else - { - ROTitleCell.BackgroundColor = new Color(0xDC, 0xE7, 0xC9); //new Color(0xD0, 0xF0, 0xD0);//ligt green //new Color(0xC8, 0xC8, 0x91);//(0xAF, 0xD8, 0xD8);//(0xF5, 0xE4, 0xA0); - } - - rotable.AddCell(ROTitleCell); // put RO value and description - } - } - - string stepnum = string.Empty; - string sectitle = (itm.ActiveSection != null) ? itm.ActiveSection.DisplayText : string.Empty; - - if (itm.IsSection) - { - stepnum = (itm.ActiveSection != null) ? itm.ActiveSection.DisplayNumber : string.Empty; - } - else - { - stepnum = BuildStepTab(itm); - } - - AddCell(rotable, stepnum, f2, Color.WHITE); - AddCell(rotable, itm.DisplayText, f2, Color.WHITE); - - } - - curTable.AddCell(rotable); - } - } - - private void BuildROUsageTableByProcedure(iTextSharp.text.Document document) - { - Dictionary> roUse = new Dictionary>(); - float[] headerwidths = { 20, 80 }; - PdfPTable datatable = new PdfPTable(1); - PdfPTable colHeader = new PdfPTable(headerwidths); - //datatable.FooterRows = 1; - datatable.TotalWidth = document.PageSize.Width - document.LeftMargin - document.RightMargin; - datatable.LockedWidth = true; - - // C2017-036 get best available proportional font for symbols that looks close to Arial - // Note that Microsoft no longer supplies Arial Unicode MS as of Word16 - iTextSharp.text.Font f1 = pdf.GetFont(Volian.Base.Library.vlnFont.ReportsFont, 14, 1, Color.BLACK); - iTextSharp.text.Font f2 = pdf.GetFont(Volian.Base.Library.vlnFont.ReportsFont, 10, 0, Color.BLACK); - iTextSharp.text.Font f3 = pdf.GetFont(Volian.Base.Library.vlnFont.ReportsFont, 12, 0, Color.BLACK); - PdfPCell cell = new PdfPCell(new Phrase(ReportTitle, f1)); - cell.HorizontalAlignment = Element.ALIGN_CENTER; - //cell.Colspan = 2; - cell.BackgroundColor = new Color(0xD0, 0xF0, 0xF0); // light blue - datatable.AddCell(cell); - - BuildSearchResultsProcSetList(); - datatable.HeaderRows = 2;//3 + (ProcSetList.Count == 1 ? 1 : 0); - int splitAt = FindSpitLevel(); // find the split level of the common path - - Color subHeaderColor = new Color(0xD0, 0xF0, 0xF0); // light blue //new Color(0xD0, 0xF0, 0xD0);//ligt green - datatable.DefaultCell.Padding = 4; - datatable.DefaultCell.HorizontalAlignment = Element.ALIGN_CENTER; - - // This puts "Step" and "Text" column headers at the bottom of the page - AddCell(colHeader, "Step", f2, subHeaderColor); - AddCell(colHeader, "Text", f2, subHeaderColor); - datatable.AddCell(colHeader); - datatable.DefaultCell.HorizontalAlignment = Element.ALIGN_LEFT; - Color AnnoColor = new Color(0xFF, 0xFF, 0xC0); - Color TextColor = Color.WHITE; - Color SectColor = new Color(0xE0, 0xFF, 0xE0);//new Color(0xC0, 0xFF, 0xC0);//Color.LIGHT_GRAY; - PdfPTable subTable = new PdfPTable(headerwidths); - datatable.AddCell(subTable); - - string lastProcNum = string.Empty; - string lastSection = string.Empty; - //CSM B2021-043 Step numbering is out of order in RO usage report if RO values exist on steps 10 or higher. - //setting this to something other than empty - otherwise will not print first initial header - string lastDVPath = "start"; - if (_ResultList.Count > 0) - { - foreach (ItemInfo item in _ResultList) - { - bool differentProcSet = false; - bool differentRO = false; - // Check Doc Version path - // if more than one procedure set is in the report data, then - // we will output the procedure set title inside the grouping of each RO - // otherwise, if we are reporting on only one procedure set, print the - // procedure set title at the top of the report (once). - if (lastDVPath != "" && lastDVPath != item.SearchDVPath) - { - //CSM B2021-043 Step numbering is out of order in RO usage report if RO values exist on steps 10 or higher. - //was placing last item from the precious section in the new section - //place it before starting the new section and then clear items - PutROusageForProcedure(datatable, roUse, headerwidths); - roUse.Clear(); - - subTable = new PdfPTable(headerwidths); - AddMainPathGroup(datatable, item.SearchDVPath, splitAt, f2, Color.LIGHT_GRAY, 0); - lastProcNum = string.Empty; - lastSection = string.Empty; - } - - lastDVPath = item.SearchDVPath; - //check for different procedure number - string curProcNum = GetCurProcNum(item.SearchPath); - string curSection = GetCurSectionNumTitle(item); - - if (!string.IsNullOrEmpty(lastProcNum) && (curProcNum != lastProcNum)) - { - if (roUse.Count > 0) - { - PutROusageForProcedure(datatable, roUse, headerwidths); - roUse.Clear(); - } - - lastSection = string.Empty; - } - - if (!string.IsNullOrEmpty(lastSection) && (curSection != lastSection)) - { - if (roUse.Count > 0) - { - PutROusageForProcedure(datatable, roUse, headerwidths); - roUse.Clear(); - } - } - - AddROUsages(item, roUse); // add the used ro to the list for this procedure - AddProcedureSectionGroup(datatable, curProcNum, lastProcNum, curSection, lastSection, f2, new Color(0xC0, 0xFF, 0xC0)); - - lastProcNum = curProcNum; - lastSection = curSection; - } - } - else - { // B2022-093 put out a message if no RO Usages were found - cell = new PdfPCell(new Phrase("No RO Usage Information Found", f3)); - cell.HorizontalAlignment = Element.ALIGN_LEFT; - //cell.BackgroundColor = new Color(0xD0, 0xF0, 0xF0); // light blue - datatable.AddCell(cell); - } - PutROusageForProcedure(datatable, roUse, headerwidths); - - document.Add(datatable); - } - - private void AddProcROUse(ItemInfo item, Dictionary> procRoUse) - { - string dictKey = GetCurProcNum(item.SearchPath) + " " + GetCurSectionNumTitle(item); - - if (!string.IsNullOrEmpty(dictKey)) - { - if (procRoUse.ContainsKey(dictKey)) - { - ((List)procRoUse[dictKey]).Add(item); - } - else - { - List itmIfoLst = new List(); - itmIfoLst.Add(item); - procRoUse.Add(dictKey, itmIfoLst); - } - } - } - - private void PutStepListForProcedure(PdfPTable rotable, Dictionary sortedStepList) - { - // C2017-036 get best available proportional font for symbols that looks close to Arial - // Note that Microsoft no longer supplies Arial Unicode MS as of Word16 - iTextSharp.text.Font f2 = pdf.GetFont(Volian.Base.Library.vlnFont.ReportsFont, 10, 0, Color.BLACK); - - foreach (ItemInfo itm in sortedStepList.Values) - { - string stepnum = (itm.IsSection && itm.ActiveSection != null) ? itm.ActiveSection.DisplayNumber : stepnum = BuildStepTab(itm);// C2018-003 fixed use of getting the active section - AddCell(rotable, stepnum, f2, Color.WHITE); - AddCell(rotable, itm.DisplayText, f2, Color.WHITE); - } - - sortedStepList.Clear(); - } - - private void PutROusageForROID(PdfPTable curTable, Dictionary> procRoUse, float[] headerwidths, int splitAt, bool moreThanOneProcSet) - { - // C2017-036 get best available proportional font for symbols that looks close to Arial - // Note that Microsoft no longer supplies Arial Unicode MS as of Word16 - iTextSharp.text.Font f2 = pdf.GetFont(Volian.Base.Library.vlnFont.ReportsFont, 10, 0, Color.BLACK); - - Dictionary sortedStepList = new Dictionary(); - string lastProcKey = string.Empty; - string lastProcNumTitle = string.Empty; - string lastDVPath = string.Empty; - string curProcNumTitle = string.Empty; - - foreach (string procKey in procRoUse.Keys) - { - PdfPTable rotable = new PdfPTable(headerwidths); - - foreach (ItemInfo itm in procRoUse[procKey]) - { - bool didProcSetTitle = false; - // Check Doc Version path - // where we are reporting on more than one procedure set - // output the procedure set title within the RO value grouping on the report - if (moreThanOneProcSet && lastDVPath != itm.SearchDVPath) - { - AddMainPathGroup(curTable, itm.SearchDVPath, splitAt, f2, Color.LIGHT_GRAY, 0); - didProcSetTitle = true; - } - else - { - didProcSetTitle = false; - } - - lastDVPath = itm.SearchDVPath; - - if (didProcSetTitle || procKey != lastProcKey) - { - if (sortedStepList.Count > 0) - { - PutStepListForProcedure(rotable, sortedStepList); - } - - string procNumTitleSect = string.Empty; - curProcNumTitle = GetCurProcNum(itm.SearchPath); - - if (lastProcNumTitle == string.Empty || lastProcNumTitle != curProcNumTitle) - { - procNumTitleSect = curProcNumTitle + "\r\n"; - lastProcNumTitle = curProcNumTitle; - } - - 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; - ProcTitleCell.BackgroundColor = new Color(0xDC, 0xE7, 0xC9); //new Color(0xD0, 0xF0, 0xD0);//ligt green //new Color(0xC8, 0xC8, 0x91);//(0xAF, 0xD8, 0xD8);//(0xF5, 0xE4, 0xA0); - rotable.AddCell(ProcTitleCell); // put RO value and description - lastProcKey = procKey; - } - - string stepnum = (itm.IsSection && itm.ActiveSection != null) ? itm.ActiveSection.DisplayNumber : BuildStepTab(itm);// C2018-003 fixed use of getting the active section - string itemkey = stepnum + " " + itm.ItemID.ToString(); // add ItemId to stepnum, sometimes we have idential stepnum text for different steps (ex: blank section numbers) - - if (!sortedStepList.ContainsKey(itemkey)) - { - sortedStepList.Add(itemkey, itm); - } - } - - if (sortedStepList.Count > 0) - { - PutStepListForProcedure(rotable, sortedStepList); - } - - curTable.AddCell(rotable); - } - } - - private string GetROTitleAndGroup(string roid, ItemInfo itm) - { - string rotitle = string.Empty; - - ROFSTLookup myrofstlookup = (itm == null) ? _ROFSTLookup : itm.MyDocVersion.DocVersionAssociations[0].MyROFst.GetROFSTLookup(itm.MyDocVersion); - - List roTitleList = myrofstlookup.GetROTitleAndGroupPath(roid, _IncludeMissingROs, _ConvertCaretToDelta); - - if (roTitleList != null && roTitleList.Count > 0) - { - for (int cnt = 0; cnt < roTitleList.Count; cnt++) - { - if (cnt == roTitleList.Count - 1) // Last roTitle in list, don't add a NewLine character after the value - rotitle += roTitleList[cnt]; - else - rotitle += roTitleList[cnt] + "\n "; - } - } - - return rotitle; - } - - private void AddROHeaderGroup(PdfPTable datatable, string curROID, ItemInfo itm, Font f2, Color bgColor) - { - string headerText = GetROTitleAndGroup(curROID, itm); - - if (!string.IsNullOrEmpty(headerText) && headerText.Length > 0) - { - PdfPCell cell = new PdfPCell(new Phrase(headerText, f2)); - - cell.Colspan = 2; - cell.BackgroundColor = (headerText.StartsWith("Missing RO")) ? Color.PINK : bgColor; - cell.BorderWidthTop = 1; - - datatable.AddCell(cell); - } - } - - private void BuildROUsageTableByRO(iTextSharp.text.Document document) - { - Dictionary> procRoUse = new Dictionary>(); - - float[] headerwidths = { 20, 80 }; - PdfPTable datatable = new PdfPTable(1); - PdfPTable colHeader = new PdfPTable(headerwidths); - //datatable.FooterRows = 1; - datatable.TotalWidth = document.PageSize.Width - document.LeftMargin - document.RightMargin; - datatable.LockedWidth = true; - - // C2017-036 get best available proportional font for symbols that looks close to Arial - // Note that Microsoft no longer supplies Arial Unicode MS as of Word16 - iTextSharp.text.Font f1 = pdf.GetFont(Volian.Base.Library.vlnFont.ReportsFont, 14, 1, Color.BLACK); - iTextSharp.text.Font f2 = pdf.GetFont(Volian.Base.Library.vlnFont.ReportsFont, 10, 0, Color.BLACK); - iTextSharp.text.Font f3 = pdf.GetFont(Volian.Base.Library.vlnFont.ReportsFont, 12, 0, Color.BLACK); - PdfPCell cell = new PdfPCell(new Phrase(ReportTitle, f1)); - cell.HorizontalAlignment = Element.ALIGN_CENTER; - cell.BackgroundColor = new Color(0xD0, 0xF0, 0xF0); // light blue - datatable.AddCell(cell); - - BuildSearchResultsProcSetList(); - datatable.HeaderRows = 2;//3 + (ProcSetList.Count == 1 ? 1 : 0); - int splitAt = FindSpitLevel(); // find the split level of the common path - - Color subHeaderColor = new Color(0xD0, 0xF0, 0xF0); // light blue //new Color(0xD0, 0xF0, 0xD0);//ligt green - datatable.DefaultCell.Padding = 4; - datatable.DefaultCell.HorizontalAlignment = Element.ALIGN_CENTER; - // This puts "Step" and "Text" column headers at the bottom of the page - AddCell(colHeader, "Step", f2, subHeaderColor); - AddCell(colHeader, "Text", f2, subHeaderColor); - datatable.AddCell(colHeader); - - datatable.DefaultCell.HorizontalAlignment = Element.ALIGN_LEFT; - Color AnnoColor = new Color(0xFF, 0xFF, 0xC0); - Color TextColor = Color.WHITE; - Color SectColor = new Color(0xE0, 0xFF, 0xE0);//new Color(0xC0, 0xFF, 0xC0);//Color.LIGHT_GRAY; - PdfPTable subTable = new PdfPTable(headerwidths); - datatable.AddCell(subTable); - - string lastDVPath = string.Empty; - string lastROID = string.Empty; - bool moreThanOneProcSet = false; - bool printedSetTitle = false; - bool printedROHeader = false; - ItemInfo lastItem = null; - - if (_ResultList.Count == 0) - { - PdfPCell cell2 = new PdfPCell(new Phrase("Selected RO is not used", f2)); - - cell2.Colspan = 0; - cell2.BorderWidthTop = 1; - datatable.AddCell(cell2); - document.Add(datatable); - - return; - } - - foreach (ItemInfo item in _ResultList) - { - bool differentProcSet = false; - bool differentRO = false; - - // Check Doc Version path - // if more than one procedure set is in the report data, then - // we will output the procedure set title inside the grouping of each RO - // otherwise, if we are reporting on only one procedure set, print the - // procedure set title at the top of the report (once). - if (!string.IsNullOrEmpty(lastDVPath) && lastDVPath != item.SearchDVPath) - { - moreThanOneProcSet = true; - differentProcSet = true; - } - - lastDVPath = item.SearchDVPath; - - // Check for different ROID - string curROID = item.FoundROID; - differentRO = (!string.IsNullOrEmpty(lastROID) && !string.IsNullOrEmpty(curROID) && curROID.Substring(0, 12) != lastROID.Substring(0, 12)); - - if (procRoUse.Count > 0 && (differentProcSet || differentRO)) - { - if (!moreThanOneProcSet && !printedSetTitle) - { - AddMainPathGroup(datatable, lastDVPath, splitAt, f2, Color.LIGHT_GRAY, 0); - printedSetTitle = true; - } - - if (!printedROHeader) - { - AddROHeaderGroup(datatable, lastROID, lastItem, f2, new Color(0xC0, 0xFF, 0xC0)); - printedROHeader = true; - } - - PutROusageForROID(datatable, procRoUse, headerwidths, splitAt, moreThanOneProcSet); - procRoUse.Clear(); - - differentProcSet = false; - } - - if (differentRO) - { - printedROHeader = false; - } - - AddProcROUse(item, procRoUse); - - lastROID = curROID; - lastItem = item; - } - - if (!moreThanOneProcSet && !printedSetTitle) - AddMainPathGroup(datatable, lastDVPath, splitAt, f2, Color.LIGHT_GRAY, 0); - - if (!printedROHeader) - AddROHeaderGroup(datatable, lastROID, lastItem, f2, new Color(0xC0, 0xFF, 0xC0)); - - PutROusageForROID(datatable, procRoUse, headerwidths, splitAt, moreThanOneProcSet); - - document.Add(datatable); - } - - private void BuildSearchResultsProcSetList() - { - ProcSetList = new System.Collections.ArrayList(); - foreach (ItemInfo item in _ResultList) - { - if (!ProcSetList.Contains(item.SearchDVPath)) - ProcSetList.Add(item.SearchDVPath); - } - } - - private void BuildLibDocProcSetList() - { - ProcSetList = new System.Collections.ArrayList(); - foreach (DocumentInfo di in _LibDocList) - { - if (di.LibraryDocumentUsageList != null && di.LibraryDocumentUsageList.Count > 0) - foreach (ItemInfo item in di.LibraryDocumentUsageList) - { - if (!ProcSetList.Contains(item.SearchDVPath)) - ProcSetList.Add(item.SearchDVPath); - } - } - } - - private ArrayList GetSortedItemInfoList(ItemInfoList orgIFL) - { - System.Collections.ArrayList libDocProcSetList = new System.Collections.ArrayList(); - System.Collections.ArrayList rtnIFL = new System.Collections.ArrayList(); - foreach (ItemInfo item in orgIFL) - { - if (!libDocProcSetList.Contains(item.SearchDVPath)) - libDocProcSetList.Add(item.SearchDVPath); - } - foreach (string pset in libDocProcSetList) - { - foreach (ItemInfo item in orgIFL) - { - if (item.SearchDVPath.Equals(pset)) - rtnIFL.Add(item); - } - } - return rtnIFL; - } - - private void BuildCompleteROReport(iTextSharp.text.Document document) - { - CompleteROReport compRORpt = new CompleteROReport(_MyPdfWriter, document, _RODataFile, _ConvertCaretToDelta, _IncludeEmptyROFields); - - compRORpt.F10 = pdf.GetFont("Courier New", 10, 0, Color.BLACK); - compRORpt.F10Bold = pdf.GetFont("Courier New", 10, 1, Color.BLACK); - compRORpt.F12 = pdf.GetFont("Courier New", 12, 0, Color.BLACK); - compRORpt.F12Bold = pdf.GetFont("Courier New", 12, 1, Color.BLACK); - // C2017-036 Get best available proportional font for symbols that looks close to Arial - // Note that Microsoft no longer supplies Arial Unicode MS as of Word16 - compRORpt.F14 = pdf.GetFont(Volian.Base.Library.vlnFont.ReportsFont, 14, 1, Color.BLACK); - - //B2022 - 083: Support Conditional RO Values - compRORpt.ROFstID = _ROFSTLookup.RofstID; - - compRORpt.Run(); - } - - private string GetROTitleAndGroupsForSummary(List roTitleList, List prevROTitleList) - { - string rotitle = string.Empty; - string indent = string.Empty; - - for (int icnt = 0; icnt < roTitleList.Count; icnt++) - { - indent += " "; - - if (icnt == roTitleList.Count - 1) - { - rotitle += indent + roTitleList[icnt]; // this should be the ro description - break; //break out of for loop - } - - if (prevROTitleList == null || (icnt < roTitleList.Count && icnt < prevROTitleList.Count && prevROTitleList[icnt] != roTitleList[icnt])) - { - if (rotitle == string.Empty && prevROTitleList != null) - rotitle = "\n"; - - rotitle += indent + roTitleList[icnt] + "\n"; - } - } - - return rotitle; - } - - private List AddROHeaderGroupForSummary(PdfPTable datatable, string curROID, List prevROTitleList, Font f2, Color bgColor) - { - List roTitleList = _ROFSTLookup.GetROTitleAndGroupPath(curROID, _IncludeMissingROs, _ConvertCaretToDelta); - string headerText = GetROTitleAndGroupsForSummary(roTitleList, prevROTitleList); - - if (headerText.Length > 0) - { - Paragraph pgh = new Paragraph(headerText, f2); - PdfPCell cell = new PdfPCell(pgh); - - cell.FollowingIndent = 72; - cell.Colspan = 2; - cell.BorderColor = Color.WHITE; - cell.BackgroundColor = Color.WHITE; - cell.BorderWidthTop = 1; - - datatable.AddCell(cell); - } - - return roTitleList; - } - - private void BuildROSummaryReport(iTextSharp.text.Document document) - { - float[] headerwidths = { 10, 20, 80 }; - PdfPTable datatable = new PdfPTable(1); - datatable.TotalWidth = document.PageSize.Width - document.LeftMargin - document.RightMargin; - datatable.LockedWidth = true; - - // C2017-036 get best available proportional font for symbols that looks close to Arial - // Note that Microsoft no longer supplies Arial Unicode MS as of Word16 - iTextSharp.text.Font f1 = pdf.GetFont(Volian.Base.Library.vlnFont.ReportsFont, 14, 1, Color.BLACK); - iTextSharp.text.Font f2 = pdf.GetFont(Volian.Base.Library.vlnFont.ReportsFont, 10, 0, Color.BLACK); - iTextSharp.text.Font f3 = pdf.GetFont(Volian.Base.Library.vlnFont.ReportsFont, 12, 1, Color.BLACK); - - PdfPCell cell = new PdfPCell(new Phrase(ReportTitle, f1)); - - cell.HorizontalAlignment = Element.ALIGN_CENTER; - //cell.Colspan = 2; - cell.BackgroundColor = Color.WHITE;//new Color(0xD0, 0xF0, 0xF0); // light blue - cell.BorderColor = Color.WHITE; - datatable.AddCell(cell); - - string roFSTDateTime = "RO.FST Last Created: " + _ROFSTLookup.GetRoFSTdts().ToLongDateString() + " @ " + _ROFSTLookup.GetRoFSTdts().ToShortTimeString() + "\n "; - cell = new PdfPCell(new Phrase(roFSTDateTime, f2)); - cell.BorderColor = Color.WHITE; - datatable.AddCell(cell); - - datatable.HeaderRows = 2;//3 + (ProcSetList.Count == 1 ? 1 : 0); - datatable.DefaultCell.HorizontalAlignment = Element.ALIGN_LEFT; - string lastROID = string.Empty; - List prevROTitleList = null; - int lastDBindex = -1; - - foreach (string curROID in _ROList) - { - string[] tmp = curROID.TrimEnd(',').Split(':'); //curROID.Split(':');// this is the RO FST id number (for plants with multiple RO FSTs) - string rolst = (tmp.Length == 2) ? tmp[1] : tmp[0]; - string[] roIdslst = rolst.Split(','); - - foreach (string cROID in roIdslst) - { - if (string.IsNullOrEmpty(cROID)) - break; - - if (cROID.Length == 4) - ProcessROdb(datatable, f2, f3, ref cell, ref lastROID, ref prevROTitleList, ref lastDBindex, cROID); - else - ProcessROID(datatable, f2, f3, ref cell, ref lastROID, ref prevROTitleList, ref lastDBindex, cROID); - } - } - - document.Add(datatable); - } - - private void ProcessROdb(PdfPTable datatable, iTextSharp.text.Font f2, iTextSharp.text.Font f3, ref PdfPCell cell, ref string lastROID, ref List prevROTitleList, ref int lastDBindex, string cROID) - { - ROFSTLookup.rodbi roDBI = _ROFSTLookup.GetRODatabase(cROID, true, true); - - if (roDBI.children != null && roDBI.children.Length > 0) - { - for (int i = 0; i < roDBI.children.Length; i++) - { - ProcessROChild(datatable, f2, f3, ref cell, ref lastROID, ref prevROTitleList, ref lastDBindex, roDBI.children[i]); - } - } - else - { - ProcessROID(datatable, f2, f3, ref cell, ref lastROID, ref prevROTitleList, ref lastDBindex, cROID); - - cell = new PdfPCell(new Phrase(" ", f2)); - cell.BorderColor = Color.WHITE; - datatable.AddCell(cell); - cell = new PdfPCell(new Phrase("-- No Information Entered --", f2)); - cell.BorderColor = Color.WHITE; - datatable.AddCell(cell); - } - } - - private void ProcessROChild(PdfPTable datatable, iTextSharp.text.Font f2, iTextSharp.text.Font f3, ref PdfPCell cell, ref string lastROID, ref List prevROTitleList, ref int lastDBindex, ROFSTLookup.rochild cld) - { - if (cld.children == null || cld.children.Length <= 0) // leaf node - { - ProcessROID(datatable, f2, f3, ref cell, ref lastROID, ref prevROTitleList, ref lastDBindex, cld.roid); - } - else if (cld.children[0].ParentID == 0) // multiple return value - { - ProcessROID(datatable, f2, f3, ref cell, ref lastROID, ref prevROTitleList, ref lastDBindex, cld.roid); - } - else - { - for (int i = 0; i < cld.children.Length; i++) - { - ProcessROChild(datatable, f2, f3, ref cell, ref lastROID, ref prevROTitleList, ref lastDBindex, cld.children[i]); - } - } - } - - private void ProcessROID(PdfPTable datatable, iTextSharp.text.Font f2, iTextSharp.text.Font f3, ref PdfPCell cell, ref string lastROID, ref List prevROTitleList, ref int lastDBindex, string cROID) - { - int curDBindex = _ROFSTLookup.GetRODatabaseTitleIndex(cROID); - - if (lastDBindex == -1 || curDBindex != lastDBindex) - { - if (prevROTitleList != null) - { - // add blank line to separate groups on the report - cell = new PdfPCell(new Phrase(" ", f2)); - cell.BorderColor = Color.WHITE; - datatable.AddCell(cell); - } - - AddMainRODatabaseTitle(datatable, curDBindex, f3, Color.WHITE); - lastDBindex = curDBindex; - } - - if (string.IsNullOrEmpty(lastROID) || cROID != lastROID) - prevROTitleList = AddROHeaderGroupForSummary(datatable, cROID, prevROTitleList, f2, new Color(0xC0, 0xFF, 0xC0)); - - lastROID = cROID; - } - - #endregion - - #region Private Static Methods - - private static PdfPTable BuildSubTable(iTextSharp.text.Document document, float[] headerwidths) - { - PdfPTable subtable = new PdfPTable(headerwidths); - - subtable.HeaderRows = 1; - subtable.KeepTogether = true; - subtable.TotalWidth = document.PageSize.Width - document.LeftMargin - document.RightMargin; - subtable.LockedWidth = true; - subtable.DefaultCell.Padding = 4; - - return subtable; - } - - private static void ShowException(Exception ex) - { - Console.WriteLine("{0} - {1}", ex.GetType().Name, ex.Message); - StringBuilder msg = new StringBuilder(); - string sep = string.Empty; - string indent = string.Empty; - - while (ex != null) - { - msg.Append(string.Format("{0}{1}{2}:\r\n{1}{3}", sep, indent, ex.GetType().Name, ex.Message)); - ex = ex.InnerException; - sep = "\r\n"; - indent += " "; - } - - System.Windows.Forms.MessageBox.Show(msg.ToString(), "Error during PDF creation for search:", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Exclamation); - } - - public static string BuildStepTab(ItemInfo item) - { - if (item == null) - return string.Empty; - - string sret = string.Empty; - - switch (item.MyContent.Type / 10000) - { - case 0: //procedure - sret = ProcedureInfo.Get(item.ItemID).MyTab.CleanText; - break; - - case 1: // section - sret = SectionInfo.Get(item.ItemID).MyTab.CleanText; - break; - - case 2: // step - ItemInfo pitem = item; - bool hasDelim = item.ActiveFormat.PlantFormat.FormatData.TransData.StepSubstepDelimeter != null; - List DelimList = null; - DelimList = new List(); - - if (!hasDelim) - { - SeqTabFmtList seqtabs = item.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.SeqTabFmtList; - - foreach (SeqTabFmt seqtab in seqtabs) - { - string delim = seqtab.PrintTabFormat.Replace("{seq}", string.Empty); - - if (!DelimList.Contains(delim)) - { - DelimList.Add(delim.Trim()); - } - } - } - else - { - string stpdelms = item.ActiveFormat.PlantFormat.FormatData.TransData.StepSubstepDelimeter; - - foreach (char c in stpdelms) - { - if (!DelimList.Contains(c.ToString())) - { - DelimList.Add(c.ToString()); - } - } - } - - // B2016-160 Support transitions to sections - while (!pitem.IsSection && !pitem.IsHigh) - { - StepInfo stpinfo = StepInfo.Get(pitem.ItemID); - string thisTab = stpinfo.MyTab.CleanText; - - if (IncludesParentToHLS(stpinfo)) - { - if (!thisTab.Contains("\u25CF")) //Remove Bullet - { - return thisTab; - } - else - { - thisTab = null; - } - } - - string typeName = stpinfo.FormatStepData.StepEditData.TypeMenu.MenuItem;//stpinfo.FormatStepData.ToString(); - - // remove delimiters of '.' and ')' in tab. - if (!string.IsNullOrEmpty(thisTab)) - { - // get list of delimiters to remove from the format: - foreach (string rmvDelim in DelimList) - { - thisTab = thisTab.Replace(rmvDelim, string.Empty); - } - } - - if (!string.IsNullOrEmpty(thisTab)) - { - thisTab = thisTab.Trim(); - } - - // if the tab is null or - // if the the tab is not a letter or number OR - // the tab is an AND or OR type and is the letter "o" - // then reset the tab an empty string so that the type name along with the count of that type - // (ex. "AND 2", "OR 3") - if (string.IsNullOrEmpty(thisTab) || (thisTab != string.Empty && (!(char.IsLetterOrDigit(thisTab[0])) || ((pitem.IsAnd || pitem.IsOr || pitem.IsCaution || pitem.IsNote) && thisTab.Contains("o"))))) - { - thisTab = string.Empty; - } - - if (pitem.IsRNOPart) - { - if (string.IsNullOrEmpty(thisTab)) - { - sret = "RNO." + sret; //"RNO." + sret; - } - else - { - thisTab = thisTab.Trim(" ".ToCharArray()); - - if (!thisTab.EndsWith(".") && !thisTab.EndsWith(")")) - { - thisTab = thisTab + "."; - } - - sret = "RNO." + thisTab + sret; //"RNO." + thisTab + sret; - } - } - else if (pitem.IsCaution || pitem.IsNote) - { - // add the Caution or Note count to the tab (ex "Caution 1", "Note 2") - if (string.IsNullOrEmpty(thisTab)) - { - sret = "{" + typeName + " " + pitem.Ordinal.ToString() + "}"; - } - else - { - thisTab = thisTab.Trim(" ".ToCharArray()); - sret = thisTab + " " + pitem.Ordinal.ToString() + sret; - } - } - else - { - if (!string.IsNullOrEmpty(thisTab)) - { - thisTab = thisTab.Trim(" ".ToCharArray()); - - if (!thisTab.EndsWith(".") && !thisTab.EndsWith(")")) - { - thisTab = thisTab + "."; - } - } - else - { - thisTab = "{" + typeName + " " + pitem.Ordinal.ToString() + "}."; - } - - sret = thisTab + sret; - } - - pitem = pitem.ActiveParent as ItemInfo; - - if (pitem == null) - break; - } - - // add hls tab if it's not already in the tab. - if (pitem.IsHigh) - { - StepInfo stpinfo = StepInfo.Get(pitem.ItemID); - - string hlsTab = stpinfo.MyTab.CleanTextNoSymbols; //StepInfo.Get(pitem.ItemID).MyTab.CleanTextNoSymbols; - string typeName = stpinfo.FormatStepData.StepEditData.TypeMenu.MenuItem;//stpinfo.FormatStepData.GetPDDisplayName(); //.ToString(); - // C2020-043: don't remove delimiters on tabs if this step's tab has the parent tab included. - bool hasParent = false; - - if (IncludesParentToHLS(stpinfo) && !hlsTab.Contains("\u25CF")) - { - hlsTab = hlsTab.Trim(" ".ToCharArray()).TrimEnd(".".ToCharArray()); - hasParent = true; - } - - if (string.IsNullOrEmpty(hlsTab)) - { - hlsTab = "{" + typeName + " " + pitem.Ordinal.ToString() + "}."; - } - else if (!hasParent && !sret.StartsWith(hlsTab.Trim(" ".ToCharArray()))) - { - foreach (string rmvDelim in DelimList) - { - hlsTab = hlsTab.Replace(rmvDelim, string.Empty); - } - - hlsTab = hlsTab.Trim(" ".ToCharArray()); - - if (!hlsTab.EndsWith(".") && !hlsTab.EndsWith(")")) - { - hlsTab = hlsTab + "."; - } - } - - sret = hlsTab + sret; - } - - break; - } - - return sret.Trim(" .)".ToCharArray()); - } - - private static bool IncludesParentToHLS(StepInfo stpinfo) - { - if (stpinfo.IsHigh) - return true; - - StepInfo parent = StepInfo.Get((stpinfo.ActiveParent as ItemInfo).ItemID); - - if (stpinfo.MyTab.CleanText.StartsWith(parent.MyTab.CleanText.Trim()) && stpinfo.MyTab.CleanText.Length > parent.MyTab.CleanText.Length) - { - return IncludesParentToHLS(parent); - } - - return false; - } - - #endregion - } - - - public class MyPageHelper : PdfPageEventHelper - { - #region Fields - - private PdfPTable _HeaderTable = null; - protected PdfTemplate total; - protected BaseFont helv; - private int ptSize = 10; // text point size of page number and page total - string _ByLine = "PROMS"; - - #endregion - - #region Properties - - public PdfPTable HeaderTable - { - get { return _HeaderTable; } - set { _HeaderTable = value; } - } - - #endregion - - #region Constructors - - public MyPageHelper(string byLine) - { - _ByLine = byLine; - } - - #endregion - - #region Public Methods - - public override void OnOpenDocument(PdfWriter writer, iTextSharp.text.Document document) - { - total = writer.DirectContent.CreateTemplate(100, 100); - total.BoundingBox = new Rectangle(-20, -20, 100, 100); - helv = BaseFont.CreateFont(BaseFont.HELVETICA, BaseFont.WINANSI, BaseFont.EMBEDDED); - } - - public override void OnEndPage(PdfWriter writer, iTextSharp.text.Document document) - { - PdfContentByte cb = writer.DirectContent; - - cb.SaveState(); - - if (HeaderTable != null) - HeaderTable.WriteSelectedRows(0, 2, 36, document.Top + 44, cb); - String text = "Page " + writer.PageNumber + " of "; - float textBase = document.Bottom - 19;//20; - cb.BeginText(); - cb.SetFontAndSize(helv, ptSize); - - float posCenter = document.Left + ((document.Right - document.Left) / 2) - (helv.GetWidthPoint(text + "XX", ptSize) / 2); - cb.SetTextMatrix(posCenter, textBase); - cb.ShowText(text); - cb.EndText(); - cb.AddTemplate(total, posCenter + helv.GetWidthPoint(text, ptSize), textBase); - cb.RestoreState(); - - AddVolianFooter(writer, document); - AddDateFooter(writer, document); - } - - public override void OnCloseDocument(PdfWriter writer, iTextSharp.text.Document document) - { - total.BeginText(); - total.SetFontAndSize(helv, ptSize); - total.SetTextMatrix(0, 0); - total.ShowText((writer.PageNumber - 1).ToString()); - total.EndText(); - - base.OnCloseDocument(writer, document); - } - - #endregion - - #region Private Methods - - private void AddVolianFooter(PdfWriter writer, iTextSharp.text.Document document) - { - PdfContentByte cb = writer.DirectContent; - cb.SaveState(); - String text = _ByLine;//"PROMS Search Results"; - float textBase = document.Bottom - 19;//20; - float textSize = helv.GetWidthPoint(text, ptSize); - cb.BeginText(); - cb.SetFontAndSize(helv, ptSize); - cb.SetTextMatrix(document.Left, textBase); - cb.ShowText(text); - cb.EndText(); - cb.RestoreState(); - } - - private void AddDateFooter(PdfWriter writer, iTextSharp.text.Document document) - { - PdfContentByte cb = writer.DirectContent; - cb.SaveState(); - String text = DateTime.Today.ToShortDateString(); - float textBase = document.Bottom - 19;//20; - float textSize = helv.GetWidthPoint(text, ptSize); - float posRight = document.Right - helv.GetWidthPoint(text, ptSize); - cb.BeginText(); - cb.SetFontAndSize(helv, ptSize); - cb.SetTextMatrix(posRight, textBase); - cb.ShowText(text); - cb.EndText(); - cb.RestoreState(); - } - - #endregion - } + // B2022-026 New code for RO Memory reduction - now use SQL tables instead of building dictionarys to get RO values + public class PDFReport + { + #region Enums + + public enum ReportType + { + SearchResults = 0, + LibraryDocUsage = 1, + ReferencedObjectsUsage = 2, + TransitionUsage = 3, + ReferencedObjectSummary = 4, + ReferencedObjectComplete = 5 + } + + #endregion + + #region Fields + + private PdfWriter _MyPdfWriter; + private string _SearchString; + private readonly int _ReportType = 0; + private readonly string _ByLine; + private readonly bool _SortUsageByProcedure = false; + private readonly string _RODataFile = string.Empty; + [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0044:Add readonly modifier", Justification = "Keeping Collections Not ReadOnly")] + private List _ROList; + private readonly ROFSTLookup _ROFSTLookup; + private readonly bool _IncludeMissingROs = false; + private readonly bool _ConvertCaretToDelta = true; + private readonly bool _IncludeEmptyROFields = false; + + private readonly string _PaperSize = "Letter"; // C2020-002 paper size is now set in the format files + private string _RegexSearchString = null; + private ArrayList ProcSetList; + + #endregion + + #region Properties + + public ICollection ResultList { get; set; } + + public string FileName { get; set; } + + public string ReportTitle { get; set; } + + public string TypesSelected { get; set; } + + public bool ShowAnnotations { get; set; } = true; + + public string SearchString + { + get { return _SearchString; } + set { _SearchString = VEPROMS.CSLA.Library.ItemInfo.ConvertToDisplayText(value); } + } + + public string SortedBy { get; set; } + + public DocumentInfoList LibDocList { get; set; } + + private string RegexSearchString + { + get + { + if (_RegexSearchString == null) + { + _RegexSearchString = _SearchString; + + // Make it match the smallest matching string + _RegexSearchString = _RegexSearchString.Replace("*", ".*?"); + + // If search string starts with a wildcard use the beginning of line token (^) + if (_RegexSearchString.StartsWith(".*?")) + { + _RegexSearchString = "^" + _RegexSearchString; + } + + // If search string ends with a wildcard use the end of line token ($) + if (_RegexSearchString.EndsWith(".*?")) + { + _RegexSearchString += "$"; + } + + _RegexSearchString = _RegexSearchString.Replace("[", @"\["); + _RegexSearchString = _RegexSearchString.Replace("]", @"\]"); + _RegexSearchString = _RegexSearchString.Replace("(", @"\("); + _RegexSearchString = _RegexSearchString.Replace(")", @"\)"); + } + + return _RegexSearchString; + } + } + + #endregion + + #region Constructors + + /// + /// Search Results Report + /// + /// + /// + /// + /// + /// + /// + public PDFReport(string reportTitle, string typesSelected, ICollection resultList, string fileName, string paperSize, string sortedBy) + { + ResultList = resultList; + FileName = fileName; + ReportTitle = VEPROMS.CSLA.Library.ItemInfo.ConvertToDisplayText(reportTitle); + TypesSelected = VEPROMS.CSLA.Library.ItemInfo.ConvertToDisplayText(typesSelected); + _ReportType = (int)ReportType.SearchResults; + _ByLine = "PROMS Search Results"; + _PaperSize = paperSize; + SortedBy = sortedBy; // C2019--13 pass in sorted by information + + } + + /// + /// Library Document Report + /// + /// + /// + /// + /// + public PDFReport(string reportTitle, DocumentInfoList libDocList, string fileName, string paperSize) + { + LibDocList = libDocList; + FileName = fileName; + ReportTitle = VEPROMS.CSLA.Library.ItemInfo.ConvertToDisplayText(reportTitle); + _ReportType = (int)ReportType.LibraryDocUsage; + _ByLine = "Generated By PROMS"; + _PaperSize = paperSize; + } + + /// + /// RO Usage + /// + /// + /// + /// + /// + /// + /// + public PDFReport(string reportTitle, ICollection resultList, string fileName, bool sortUsageByProcedure, bool includeMissingROs, string paperSize) + { + ResultList = resultList; + FileName = fileName; + ReportTitle = VEPROMS.CSLA.Library.ItemInfo.ConvertToDisplayText(reportTitle); + _ReportType = (int)ReportType.ReferencedObjectsUsage; + _ByLine = "Generated By PROMS"; + _SortUsageByProcedure = sortUsageByProcedure; + _IncludeMissingROs = includeMissingROs; + _PaperSize = paperSize; + } + + /// + /// RO Complete RO Report + /// + /// + /// + /// + /// + /// + /// + /// + public PDFReport(string reportTitle, string roDataFile, string outfile, ROFSTLookup fstlookup, bool convertCaretToDelta, bool includeEmptyROFields, string paperSize) + { + FileName = outfile; + ReportTitle = reportTitle; + _ReportType = (int)ReportType.ReferencedObjectComplete; + _ByLine = "Complete Referenced Objects Report"; + _RODataFile = roDataFile; + _ConvertCaretToDelta = convertCaretToDelta; + _ROFSTLookup = fstlookup; + _IncludeEmptyROFields = includeEmptyROFields; + _PaperSize = paperSize; + } + + /// + /// RO Summary Report + /// + /// + /// + /// + /// + /// + public PDFReport(string reportTitle, string outfile, ROFSTLookup fstlookup, List roList, string paperSize) + { + FileName = outfile; + ReportTitle = reportTitle; + _ReportType = (int)ReportType.ReferencedObjectSummary; + _ByLine = "RO Summary Report"; + _ROFSTLookup = fstlookup; + _ROList = roList; + _PaperSize = paperSize; + } + + #endregion + + #region Public Methods + + public void AddMainRODatabaseTitle(PdfPTable datatable, int dbTitleIndex, Font f2, Color bgColor) + { + string dbTitle = _ROFSTLookup.GetRODatabaseTitle(dbTitleIndex); + + PdfPCell cell = new PdfPCell(new Phrase(dbTitle, f2)) + { + BorderColor = Color.WHITE, + Colspan = 2, + BackgroundColor = bgColor + }; + datatable.AddCell(cell); + } + + public void AddMainPathGroup(PdfPTable datatable, string dvPath, int splitLevel, Font f2, Color bgColor, int colSpan) + { + int level = 0; + StringBuilder sb = new StringBuilder(); + string[] NewPath = dvPath.Split("\x7".ToCharArray()); + string sep = string.Empty; + 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?", "-").Replace(@"\u9586?", @"\"); + sep = "\r\n"; + level++; + } + + if (sb.Length > 0) + { + PdfPCell cell = new PdfPCell(new Phrase(sb.ToString(), f2)) + { + Colspan = colSpan, + BackgroundColor = bgColor, + BorderWidthTop = 1 + }; + + datatable.AddCell(cell); + } + } + + public void AddSubPathGroup(PdfPTable datatable, string oldDVPath, string dvPath, int splitLevel, Font f2, Color bgColor, int colSpan) + { + int level = 0; + StringBuilder sb = new StringBuilder(); + string[] NewPath = dvPath.Split("\x7".ToCharArray()); + string[] OldPath = oldDVPath.Split("\x7".ToCharArray()); + string sep = string.Empty; + int n = NewPath.Length - 1; + + for (int i = 0; i < n; i++) + { + if (OldPath[i] != NewPath[i]) + { + splitLevel = Math.Max(splitLevel, i); + break; + } + } + + if (splitLevel < n) + { + for (int j = splitLevel; j < n; j++) + { + sb.Append($"{sep}{"".PadLeft(2 * level)}{NewPath[j].Replace("\x11", " ")}").Replace(@"\u8209?", "-").Replace(@"\u9586?", @"\"); + sep = "\r\n"; + level++; + } + + if (sb.Length > 0) + { + PdfPCell cell = new PdfPCell(new Phrase(sb.ToString(), f2)) + { + Colspan = colSpan, + BackgroundColor = bgColor, + BorderWidthTop = 1 + }; + + datatable.AddCell(cell); + } + } + } + + public void Build() + { + iTextSharp.text.Document document = new iTextSharp.text.Document(PDFPageSize.UsePaperSize(_PaperSize), 36, 36, 36, 36); // C2020-002 paper size is now set in the format files + + if (!CreateResultsPDF(document, _ReportType)) + return; + + try + { + switch (_ReportType) // set in the PDFReport constructor + { + case (int)ReportType.SearchResults: + BuildSearchResultsTable(document); + break; + + case (int)ReportType.LibraryDocUsage: + BuildLibDocUsageReport(document); + break; + + case (int)ReportType.ReferencedObjectsUsage: + if (_SortUsageByProcedure) + BuildROUsageTableByProcedure(document); + else + BuildROUsageTableByRO(document); + break; + + case (int)ReportType.ReferencedObjectComplete: + BuildCompleteROReport(document); + break; + + case (int)ReportType.ReferencedObjectSummary: + BuildROSummaryReport(document); + break; + } + } + catch (Exception ex) + { + document.Add(new Paragraph("Error:")); + + while (ex != null) + { + document.Add(new Paragraph(ex.GetType().Name)); + document.Add(new Paragraph(ex.Message)); + ex = ex.InnerException; + } + } + finally + { + if (document.IsOpen()) + { + //document.Add(new Phrase("End of Search Results",FontFactory.GetFont("Arial",4))); // B2019-089 commented out - used for debug + document.Add(new Phrase(" ", FontFactory.GetFont("Arial", 4))); // B2019-089 - assure output has at least a blank space to prevent error on close + document.Close(); + System.Diagnostics.Process.Start(FileName); + } + } + } + + #endregion + + #region Private Methods + + private string AddGroup(PdfPTable datatable, string dvPath, string lastDvPath, Font f2, bool StripLast, Color bgColor, bool skipFirst) + { + int level = 0; + string retval = string.Empty; + StringBuilder sb = new StringBuilder(); + string[] OldPath = lastDvPath.Split("\x7".ToCharArray()); + string[] NewPath = dvPath.Split("\x7".ToCharArray()); + string sep = string.Empty; + bool foundMisMatch = false; + + // n-1 Exclude the "Working Draft" entry from the list + int n = NewPath.Length - 1; + int jstart = (skipFirst) ? 1 : 0; + + if (StripLast) + { + retval = NewPath[--n]; + if (retval.Contains("\x11")) + { + retval = retval.Substring(0, retval.IndexOf("\x11")); // this is the step number + } + } + + if (n == 0) + { + // B2020-006: 'clean-up' the output string by making string replaces as in 'else' below. + sb.Append(dvPath.Replace("\x11", " ").Replace(@"\u8209?", "-").Replace(@"\u160?", " ").Replace(@"\u9586?", @"\")); + } + else + { + for (int j = jstart; j < n; j++) + { + if (!string.IsNullOrEmpty(NewPath[j]) && (foundMisMatch || OldPath.Length < j + 1 || NewPath[j] != OldPath[j])) + { + // B2020-006: Add hard space '\u160?' + sb.Append($"{sep}{"".PadLeft(2 * level)}{NewPath[j].Replace("\x11", " ")}").Replace(@"\u8209?", "-").Replace(@"\u160?", " ").Replace(@"\u9586?", @"\"); + sep = "\r\n"; + foundMisMatch = true; + } + + level++; + } + } + + if (sb.Length > 0) + { + PdfPCell cell = new PdfPCell(new Phrase(sb.ToString(), f2)) + { + Colspan = 2, + BackgroundColor = bgColor, + BorderWidthTop = 1 + }; + datatable.AddCell(cell); + } + + return retval; + } + + private string AddGroupLibDoc(PdfPTable datatable, string dvPath, string lastDvPath, Font f2, bool StripLast, Color bgColor, bool skipFirst) + { + int level = 0; + string retval = string.Empty; + StringBuilder sb = new StringBuilder(); + string[] OldPath = lastDvPath.Split("\x7".ToCharArray()); + string[] NewPath = dvPath.Split("\x7".ToCharArray()); + string sep = string.Empty; + bool foundMisMatch = false; + int n = NewPath.Length - 1; + int jstart = (skipFirst) ? 1 : 0; + + if (StripLast) + { + retval = NewPath[--n]; + if (retval.Contains("\x11")) + { + retval = retval.Substring(0, retval.IndexOf("\x11")); // this is the step number + } + } + + //If no colons output the entire text + if (n == 0) + { + sb.Append(dvPath); + } + else + { + for (int j = jstart; j < n; j++) + { + if (!string.IsNullOrEmpty(NewPath[j]) && (foundMisMatch || OldPath.Length < j + 1 || NewPath[j] != OldPath[j])) + { + sb.Append($"{sep}{"".PadLeft(2 * level)}{NewPath[j].Replace("\x11", " ")}").Replace(@"\u8209?", "-").Replace(@"\u9586?", @"\"); + sep = "\r\n"; + foundMisMatch = true; + } + + level++; + } + } + + if (sb.Length > 0) + { + PdfPCell cell = new PdfPCell(new Phrase(sb.ToString(), f2)) + { + Colspan = 2, + BackgroundColor = bgColor, + BorderWidthTop = 1 + }; + datatable.AddCell(cell); + } + + return retval; + } + + private void AddProcedureSectionGroup(PdfPTable datatable, string curProc, string lastProc, string curSect, string lastSect, Font f2, Color bgColor) + { + string headerText = string.Empty; + + if (curProc != lastProc) + headerText = $"{curProc}\r\n"; + + if (curSect != lastSect) + headerText += $" {curSect}"; + + if (headerText.Length > 0) + { + 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)) + { + Colspan = 2, + BackgroundColor = bgColor, + BorderWidthTop = 1 + }; + datatable.AddCell(cell); + } + } + + private string GetCurProcNum(string path) + { + string[] NewPath = path.Split("\x7".ToCharArray()); + string pnumtitle = NewPath[1]; + pnumtitle = pnumtitle.Replace('\x11', ' '); + + return pnumtitle; + } + + private string GetCurSectionNumTitle(ItemInfo itm) + { + string rtnstr = string.Empty; + + if (itm.ActiveSection != null) + { + rtnstr = itm.ActiveSection.DisplayNumber; + if (rtnstr.Length > 0) rtnstr += " "; + rtnstr += itm.ActiveSection.DisplayText; + } + + return rtnstr; // string containing section and subsection number/titles + } + + private int FindSpitLevel() + { + int level = 0; + string lastPath = string.Empty; + + foreach (string p in ProcSetList) + { + string[] NewPath = p.Split("\x7".ToCharArray()); + + if (lastPath != string.Empty) + { + string[] OldPath = lastPath.Split("\x7".ToCharArray()); + int n = NewPath.Length; + int lvl = 0; + bool foundMisMatch = false; + + for (int j = 0; j < n && !foundMisMatch; j++) + { + if (NewPath[j] != string.Empty && (OldPath.Length < j + 1 || NewPath[j] != OldPath[j])) + { + foundMisMatch = true; + } + + lvl++; + } + + if (level == 0) + level = lvl; + + if (foundMisMatch) + level = Math.Min(level, lvl); + } + + lastPath = p; + + if (ProcSetList.Count == 1) + { + level = NewPath.Length - 1; + } + } + + return level; + } + + /// + /// Attempt to open a file for the PDF output. + /// If the file cannot be opened because it is in use, try adding a suffix + /// If the file cannot be opened for some other reason, display an error message + /// + /// + /// + private bool CreateResultsPDF(iTextSharp.text.Document document, int typ) + { + int topMargin = 36; + + switch (typ) + { + case (int)ReportType.LibraryDocUsage: + topMargin = 80; // Add some space for the Report Header for the Library Document Report + break; + } + + bool result = false; + string suffix = string.Empty; + int i = 0; + + // Try to open a file for creating the PDF. + while (result == false) + { + string fileName = FileName.ToLower().Replace(".pdf", $"{suffix}.pdf"); + + try + { + _MyPdfWriter = PdfWriter.GetInstance(document, new FileStream(fileName, FileMode.Create)); + _MyPdfWriter.PageEvent = new MyPageHelper(_ByLine); // JSJ - 7/8/2011 + + document.SetMargins(36, 36, topMargin, 36); + document.Open(); + + FileName = fileName; + + result = true; + } + catch (System.IO.IOException exIO) + { + if (exIO.Message.Contains("because it is being used by another process")) + { + suffix = string.Format("_{0}", ++i);// If this file is in use, increment the suffix and try again + } + else // If some other error, display a message and don't print the results + { + ShowException(exIO); + return false; + } + } + catch (Exception ex) + { + ShowException(ex); + return false; // Could not open the output file + } + } + + return true; + } + + /// + /// Use Cells within Cells to see if I can limit the way Cells break from Page to Page + /// + /// + private void BuildSearchResultsTable(iTextSharp.text.Document document) + { + float[] headerwidths = { 20, 80 }; + PdfPTable datatable = new PdfPTable(1); + PdfPTable colHeader = new PdfPTable(headerwidths); + //datatable.FooterRows = 1; + datatable.TotalWidth = document.PageSize.Width - document.LeftMargin - document.RightMargin; + datatable.LockedWidth = true; + + // C2017-036 get best available proportional font for symbols that looks close to Arial + // Note that Microsoft no longer supplies Arial Unicode MS as of Word16 + iTextSharp.text.Font f1 = pdf.GetFont(Volian.Base.Library.vlnFont.ReportsFont, 14, 1, Color.BLACK); + iTextSharp.text.Font f2 = pdf.GetFont(Volian.Base.Library.vlnFont.ReportsFont, 10, 0, Color.BLACK); + iTextSharp.text.Font f3 = pdf.GetFont(Volian.Base.Library.vlnFont.ReportsFont, 12, 0, Color.BLACK); + PdfPCell cell = new PdfPCell(new Phrase(ReportTitle, f1)) + { + HorizontalAlignment = Element.ALIGN_CENTER, + BackgroundColor = new Color(0xD0, 0xF0, 0xF0) // light cyan + }; + datatable.AddCell(cell); + + // C2019-013 add sorted by information if sorting is used + cell = new PdfPCell(new Phrase(TypesSelected + ((SortedBy.Length > 0) ? string.Format("\n{0}", SortedBy) : string.Empty), f3)) + { + HorizontalAlignment = Element.ALIGN_LEFT, + BackgroundColor = new Color(0xD0, 0xF0, 0xF0) // light cyan + }; + datatable.AddCell(cell); + + BuildSearchResultsProcSetList(); + datatable.HeaderRows = 4 + (ProcSetList.Count == 1 ? 1 : 0); + int splitAt = FindSpitLevel(); // find the split level of the common path - for all procedure sets that use these library documents + + Color subHeaderColor = new Color(0xD0, 0xF0, 0xF0); // new Color(0xD0, 0xF0, 0xD0); + datatable.DefaultCell.Padding = 0; // this removes a white space after the header was set to 4; + datatable.DefaultCell.HorizontalAlignment = Element.ALIGN_CENTER; + AddCell(colHeader, "Step", f2, subHeaderColor); + AddCell(colHeader, "Text", f2, subHeaderColor); + + datatable.DefaultCell.HorizontalAlignment = Element.ALIGN_LEFT; + string lastPath = string.Empty; + Color AnnoColor = new Color(0xFF, 0xFF, 0xC0); // yellow + Color TextColor = Color.WHITE; + Color WordSectColor = new Color(0xE8, 0xE8, 0xE8);// light grey + Color StepSectColor = new Color(0xE7, 0xFF, 0xE7); // lighter green + PdfPTable subTable = new PdfPTable(headerwidths); + string lastProcNum = string.Empty; + string lastDVPath = string.Empty; + string lastSectNumAndTitle = string.Empty; + List processedItems = new List(); + + foreach (ItemInfo item in ResultList) + { + if (!processedItems.Contains(item.ItemID)) + { + processedItems.Add(item.ItemID); + + if (lastDVPath != item.SearchDVPath) + { + datatable.AddCell(subTable); + subTable = new PdfPTable(headerwidths); + AddMainPathGroup(datatable, item.SearchDVPath, splitAt, f2, new Color(0xB0, 0xF0, 0xF0), 0);// little brighter cyan + datatable.AddCell(colHeader); + lastProcNum = string.Empty; + lastSectNumAndTitle = string.Empty; // C2020-019 reset we are processing a different procedure set + } + + lastDVPath = item.SearchDVPath; + string curProcNum = GetCurProcNum(item.SearchPath); + + if (subTable.Rows.Count > 0) // prevent first page from being blank + { + datatable.AddCell(subTable); + subTable = new PdfPTable(headerwidths); + } + + if (curProcNum != lastProcNum) + { + lastSectNumAndTitle = string.Empty; // C2020-019 reset we are processing a different procedure + } + + lastProcNum = curProcNum; + + // B2020-006: When doing a section, don't remove the last item or the procedure title won't print (if section is only item found w/ search string) + string stepPath = AddGroup(subTable, item.SearchPath ?? item.ShortPath, lastPath, f2, !item.IsSection, new Color(0xC0, 0xFF, 0xC0), true); // light green for procedure number and title + + // C2020-019 add section number and title if is different from last item and it is not a Word Section (item will be a section if search item was found in a Word section) + string curSectNumTitle = GetCurSectionNumTitle(item); + + if (curSectNumTitle != string.Empty && curSectNumTitle != lastSectNumAndTitle && !item.IsSection) + { + AddColSpanCell(subTable, curSectNumTitle, f2, StepSectColor, 2, 0); + lastSectNumAndTitle = curSectNumTitle; + } + + lastPath = item.SearchPath ?? item.ShortPath; + stepPath = BuildStepTab(item); + AddCell(subTable, stepPath, f2, (item.IsSection ? WordSectColor : TextColor)); + AddCell(subTable, item.DisplayText, f2, (item.IsSection ? WordSectColor : TextColor)); + + if (ShowAnnotations && item.ItemAnnotationCount > 0) + { + foreach (AnnotationInfo ai in item.ItemAnnotations) + { + AddCell(subTable, ai.MyAnnotationType.Name, f2, AnnoColor); + AddCell(subTable, ai.SearchText, f2, AnnoColor); + } + } + } + } + + datatable.AddCell(subTable); + document.Add(datatable); + } + + private void AddCell(PdfPTable datatable, string str, iTextSharp.text.Font fnt, Color bgColor) + { + + Phrase p = BuildPhrase2(str, fnt); + PdfPCell cell = new PdfPCell(p) + { + PaddingBottom = 4, + BackgroundColor = bgColor + }; + + datatable.AddCell(cell); + } + + private void AddColSpanCell(PdfPTable datatable, string str, iTextSharp.text.Font fnt, Color bgColor, int span, int txtAlign) + { + Phrase p = BuildPhrase2(str, fnt); + PdfPCell cell = new PdfPCell(p) + { + PaddingBottom = 4, + BackgroundColor = bgColor, + Colspan = span, + HorizontalAlignment = txtAlign + }; + + datatable.AddCell(cell); + } + private Phrase BuildPhrase2(string str, Font fnt) + { + Phrase p = new Phrase(); + int lastIndex = 0; + + if ((_SearchString ?? string.Empty) != string.Empty) + { + Regex reg = new Regex(RegexSearchString, RegexOptions.Multiline | RegexOptions.IgnoreCase); + + foreach (Match m in reg.Matches(str)) + { + if (m.Index > 0) + p.Add(new Phrase(str.Substring(lastIndex, m.Index - lastIndex), fnt)); + + Chunk chk = new Chunk(m.Value, fnt); + chk.SetBackground(Color.YELLOW); + p.Add(chk); + + lastIndex = m.Index + m.Length; + } + } + + p.Add(new Phrase(str.Substring(lastIndex), fnt)); + + return p; + } + + private void BuildLibDocUsageReport(iTextSharp.text.Document document) + { + // Adjusted from 20,80 to 25,75 to account for long Procedure Numbers + float[] headerwidths = { 25, 75 }; + // C2017-036 get best available proportional font for symbols that looks close to Arial + // Note that Microsoft no longer supplies Arial Unicode MS as of Word16 + iTextSharp.text.Font f2 = pdf.GetFont(Volian.Base.Library.vlnFont.ReportsFont, 10, 0, Color.BLACK); + BuildLibDocProcSetList(); + + int splitAt = FindSpitLevel() - 1; // find the split level of the common path - for all procedure sets that use these library documents + Color AnnoBackgroundColor = new Color(0xFF, 0xFF, 0xC0); + Color TextBackgroundColor = Color.WHITE; + MyPageHelper pghlp = _MyPdfWriter.PageEvent as MyPageHelper; + pghlp.HeaderTable = LibDocTable(document, headerwidths, f2); + + foreach (DocumentInfo di in LibDocList) + { + PdfPTable subtable; + subtable = BuildSubTable(document, headerwidths); + + AddGroupLibDoc(subtable, di.DocumentTitle, string.Empty, f2, false, new Color(0xC0, 0xFF, 0xC0), false); // Library Document Title + + if (di.DocumentConfig.LibDoc_Comment != null && di.DocumentConfig.LibDoc_Comment.Length > 0) + { + AddCell(subtable, "Comment", f2, AnnoBackgroundColor); + AddCell(subtable, di.DocumentConfig.LibDoc_Comment, f2, AnnoBackgroundColor); // lib doc comment + } + + if (di.DocumentEntries == null || di.DocumentEntries.Count == 0) + { + AddGroupLibDoc(subtable, "* No References To This Library Document *", string.Empty, f2, false, TextBackgroundColor, false); // Library Document Title + } + else + { + subtable.HeaderRows = 2; + System.Collections.ArrayList LibDocUsageList = GetSortedItemInfoList(di.LibraryDocumentUsageList); + string lastDvPath = string.Empty; + + foreach (ItemInfo item in LibDocUsageList)//di.LibraryDocumentUsageList) + { + if (item.SearchDVPath != lastDvPath) + { + if (lastDvPath != string.Empty) + { + document.Add(subtable); + subtable = BuildSubTable(document, headerwidths); + subtable.HeaderRows = 2; + AddGroupLibDoc(subtable, di.DocumentTitle, string.Empty, f2, false, new Color(0xC0, 0xFF, 0xC0), false); // Library Document Title + } + + AddSubPathGroup(subtable, lastDvPath, item.SearchDVPath, splitAt, f2, Color.LIGHT_GRAY, 2);//new Color(0xC0, 0xFF, 0xC0)); + } + + lastDvPath = item.SearchDVPath; + 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); + } + + } + + document.Add(subtable); + } + } + + private PdfPTable LibDocTable(iTextSharp.text.Document document, float[] headerwidths, iTextSharp.text.Font f2) + { + PdfPTable datatable = new PdfPTable(1);// (headerwidths); + PdfPTable colheader = new PdfPTable(headerwidths); + datatable.HeaderRows = 2; + datatable.KeepTogether = false; + datatable.TotalWidth = document.PageSize.Width - document.LeftMargin - document.RightMargin; + datatable.LockedWidth = true; + + // C2017-036 get best available proportional font for symbols that looks close to Arial + // Note that Microsoft no longer supplies Arial Unicode MS as of Word16 + iTextSharp.text.Font f1 = pdf.GetFont(Volian.Base.Library.vlnFont.ReportsFont, 14, 1, Color.BLACK); + PdfPCell cell = new PdfPCell(new Phrase(ReportTitle, f1)) + { + HorizontalAlignment = Element.ALIGN_CENTER, + BackgroundColor = new Color(0xD0, 0xF0, 0xF0) + }; + datatable.AddCell(cell); + + Color subHeaderColor = new Color(0xD0, 0xF0, 0xD0); + datatable.DefaultCell.Padding = 4; + datatable.DefaultCell.HorizontalAlignment = Element.ALIGN_CENTER; + AddCell(colheader, "Procedure", f2, subHeaderColor); + AddCell(colheader, "Section", f2, subHeaderColor); + datatable.AddCell(colheader); + + datatable.DefaultCell.HorizontalAlignment = Element.ALIGN_LEFT; + + return datatable; + } + + private void AddROUsages(ItemInfo item, Dictionary> roUse) + { + if (item != null && !string.IsNullOrEmpty(item.FoundROID)) + { + string roid = item.FoundROID; + + if (roUse.ContainsKey(roid)) + { + ((List)roUse[roid]).Add(item); + } + else + { + List itmIfoLst = new List + { + item + }; + roUse.Add(roid, itmIfoLst); + } + } + } + + private void PutROusageForProcedure(PdfPTable curTable, Dictionary> rosused, float[] headerwidths) + { + // C2017-036 get best available proportional font for symbols that looks close to Arial + // Note that Microsoft no longer supplies Arial Unicode MS as of Word16 + iTextSharp.text.Font f2 = pdf.GetFont(Volian.Base.Library.vlnFont.ReportsFont, 10, 0, Color.BLACK); + + foreach (string roKey in rosused.Keys) + { + PdfPTable rotable = new PdfPTable(headerwidths); + string rotitle = string.Empty; + + foreach (ItemInfo itm in rosused[roKey]) + { + if (string.IsNullOrEmpty(rotitle)) + { + rotitle = GetROTitleAndGroup(roKey, itm); + + if (!string.IsNullOrEmpty(rotitle)) + { + PdfPCell ROTitleCell = new PdfPCell(new Phrase(rotitle, f2)) + { + Colspan = 2, + HorizontalAlignment = Element.ALIGN_LEFT + }; + + if (rotitle.StartsWith("Missing RO")) + { + ROTitleCell.BackgroundColor = Color.PINK; + } + else + { + ROTitleCell.BackgroundColor = new Color(0xDC, 0xE7, 0xC9); //new Color(0xD0, 0xF0, 0xD0);//ligt green //new Color(0xC8, 0xC8, 0x91);//(0xAF, 0xD8, 0xD8);//(0xF5, 0xE4, 0xA0); + } + + rotable.AddCell(ROTitleCell); // put RO value and description + } + } + + string stepnum = string.Empty; + string sectitle = (itm.ActiveSection != null) ? itm.ActiveSection.DisplayText : string.Empty; + + if (itm.IsSection) + { + stepnum = (itm.ActiveSection != null) ? itm.ActiveSection.DisplayNumber : string.Empty; + } + else + { + stepnum = BuildStepTab(itm); + } + + AddCell(rotable, stepnum, f2, Color.WHITE); + AddCell(rotable, itm.DisplayText, f2, Color.WHITE); + + } + + curTable.AddCell(rotable); + } + } + + private void BuildROUsageTableByProcedure(iTextSharp.text.Document document) + { + Dictionary> roUse = new Dictionary>(); + float[] headerwidths = { 20, 80 }; + PdfPTable datatable = new PdfPTable(1); + PdfPTable colHeader = new PdfPTable(headerwidths); + datatable.TotalWidth = document.PageSize.Width - document.LeftMargin - document.RightMargin; + datatable.LockedWidth = true; + + // C2017-036 get best available proportional font for symbols that looks close to Arial + // Note that Microsoft no longer supplies Arial Unicode MS as of Word16 + iTextSharp.text.Font f1 = pdf.GetFont(Volian.Base.Library.vlnFont.ReportsFont, 14, 1, Color.BLACK); + iTextSharp.text.Font f2 = pdf.GetFont(Volian.Base.Library.vlnFont.ReportsFont, 10, 0, Color.BLACK); + iTextSharp.text.Font f3 = pdf.GetFont(Volian.Base.Library.vlnFont.ReportsFont, 12, 0, Color.BLACK); + PdfPCell cell = new PdfPCell(new Phrase(ReportTitle, f1)) + { + HorizontalAlignment = Element.ALIGN_CENTER, + //cell.Colspan = 2; + BackgroundColor = new Color(0xD0, 0xF0, 0xF0) // light blue + }; + datatable.AddCell(cell); + + BuildSearchResultsProcSetList(); + datatable.HeaderRows = 2;//3 + (ProcSetList.Count == 1 ? 1 : 0); + int splitAt = FindSpitLevel(); // find the split level of the common path + + Color subHeaderColor = new Color(0xD0, 0xF0, 0xF0); // light blue //new Color(0xD0, 0xF0, 0xD0);//ligt green + datatable.DefaultCell.Padding = 4; + datatable.DefaultCell.HorizontalAlignment = Element.ALIGN_CENTER; + + // This puts "Step" and "Text" column headers at the bottom of the page + AddCell(colHeader, "Step", f2, subHeaderColor); + AddCell(colHeader, "Text", f2, subHeaderColor); + datatable.AddCell(colHeader); + datatable.DefaultCell.HorizontalAlignment = Element.ALIGN_LEFT; + PdfPTable subTable = new PdfPTable(headerwidths); + datatable.AddCell(subTable); + + string lastProcNum = string.Empty; + string lastSection = string.Empty; + //CSM B2021-043 Step numbering is out of order in RO usage report if RO values exist on steps 10 or higher. + //setting this to something other than empty - otherwise will not print first initial header + string lastDVPath = "start"; + if (ResultList.Count > 0) + { + foreach (ItemInfo item in ResultList) + { + // Check Doc Version path + // if more than one procedure set is in the report data, then + // we will output the procedure set title inside the grouping of each RO + // otherwise, if we are reporting on only one procedure set, print the + // procedure set title at the top of the report (once). + if (lastDVPath != "" && lastDVPath != item.SearchDVPath) + { + //CSM B2021-043 Step numbering is out of order in RO usage report if RO values exist on steps 10 or higher. + //was placing last item from the precious section in the new section + //place it before starting the new section and then clear items + PutROusageForProcedure(datatable, roUse, headerwidths); + roUse.Clear(); + + subTable = new PdfPTable(headerwidths); + AddMainPathGroup(datatable, item.SearchDVPath, splitAt, f2, Color.LIGHT_GRAY, 0); + lastProcNum = string.Empty; + lastSection = string.Empty; + } + + lastDVPath = item.SearchDVPath; + //check for different procedure number + string curProcNum = GetCurProcNum(item.SearchPath); + string curSection = GetCurSectionNumTitle(item); + + if (!string.IsNullOrEmpty(lastProcNum) && (curProcNum != lastProcNum)) + { + if (roUse.Count > 0) + { + PutROusageForProcedure(datatable, roUse, headerwidths); + roUse.Clear(); + } + + lastSection = string.Empty; + } + + if (!string.IsNullOrEmpty(lastSection) && (curSection != lastSection)) + { + if (roUse.Count > 0) + { + PutROusageForProcedure(datatable, roUse, headerwidths); + roUse.Clear(); + } + } + + AddROUsages(item, roUse); // add the used ro to the list for this procedure + AddProcedureSectionGroup(datatable, curProcNum, lastProcNum, curSection, lastSection, f2, new Color(0xC0, 0xFF, 0xC0)); + + lastProcNum = curProcNum; + lastSection = curSection; + } + } + else + { // B2022-093 put out a message if no RO Usages were found + cell = new PdfPCell(new Phrase("No RO Usage Information Found", f3)) + { + HorizontalAlignment = Element.ALIGN_LEFT + }; + //cell.BackgroundColor = new Color(0xD0, 0xF0, 0xF0); // light blue + datatable.AddCell(cell); + } + PutROusageForProcedure(datatable, roUse, headerwidths); + + document.Add(datatable); + } + + private void AddProcROUse(ItemInfo item, Dictionary> procRoUse) + { + string dictKey = $"{GetCurProcNum(item.SearchPath)} {GetCurSectionNumTitle(item)}"; + + if (!string.IsNullOrEmpty(dictKey)) + { + if (procRoUse.ContainsKey(dictKey)) + { + ((List)procRoUse[dictKey]).Add(item); + } + else + { + List itmIfoLst = new List + { + item + }; + procRoUse.Add(dictKey, itmIfoLst); + } + } + } + + private void PutStepListForProcedure(PdfPTable rotable, Dictionary sortedStepList) + { + // C2017-036 get best available proportional font for symbols that looks close to Arial + // Note that Microsoft no longer supplies Arial Unicode MS as of Word16 + iTextSharp.text.Font f2 = pdf.GetFont(Volian.Base.Library.vlnFont.ReportsFont, 10, 0, Color.BLACK); + + foreach (ItemInfo itm in sortedStepList.Values) + { + string stepnum = (itm.IsSection && itm.ActiveSection != null) ? itm.ActiveSection.DisplayNumber : BuildStepTab(itm);// C2018-003 fixed use of getting the active section + AddCell(rotable, stepnum, f2, Color.WHITE); + AddCell(rotable, itm.DisplayText, f2, Color.WHITE); + } + + sortedStepList.Clear(); + } + + private void PutROusageForROID(PdfPTable curTable, Dictionary> procRoUse, float[] headerwidths, int splitAt, bool moreThanOneProcSet) + { + // C2017-036 get best available proportional font for symbols that looks close to Arial + // Note that Microsoft no longer supplies Arial Unicode MS as of Word16 + iTextSharp.text.Font f2 = pdf.GetFont(Volian.Base.Library.vlnFont.ReportsFont, 10, 0, Color.BLACK); + + Dictionary sortedStepList = new Dictionary(); + string lastProcKey = string.Empty; + string lastProcNumTitle = string.Empty; + string lastDVPath = string.Empty; + string curProcNumTitle; + + foreach (string procKey in procRoUse.Keys) + { + PdfPTable rotable = new PdfPTable(headerwidths); + + foreach (ItemInfo itm in procRoUse[procKey]) + { + bool didProcSetTitle = false; + // Check Doc Version path + // where we are reporting on more than one procedure set + // output the procedure set title within the RO value grouping on the report + if (moreThanOneProcSet && lastDVPath != itm.SearchDVPath) + { + AddMainPathGroup(curTable, itm.SearchDVPath, splitAt, f2, Color.LIGHT_GRAY, 0); + didProcSetTitle = true; + } + else + { + didProcSetTitle = false; + } + + lastDVPath = itm.SearchDVPath; + + if (didProcSetTitle || procKey != lastProcKey) + { + if (sortedStepList.Count > 0) + { + PutStepListForProcedure(rotable, sortedStepList); + } + + string procNumTitleSect = string.Empty; + curProcNumTitle = GetCurProcNum(itm.SearchPath); + + if (lastProcNumTitle == string.Empty || lastProcNumTitle != curProcNumTitle) + { + procNumTitleSect = $"{curProcNumTitle}\r\n"; + lastProcNumTitle = curProcNumTitle; + } + + 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)) + { + Colspan = 2, + HorizontalAlignment = Element.ALIGN_LEFT, + BackgroundColor = new Color(0xDC, 0xE7, 0xC9) //new Color(0xD0, 0xF0, 0xD0);//ligt green //new Color(0xC8, 0xC8, 0x91);//(0xAF, 0xD8, 0xD8);//(0xF5, 0xE4, 0xA0); + }; + rotable.AddCell(ProcTitleCell); // put RO value and description + lastProcKey = procKey; + } + + string stepnum = (itm.IsSection && itm.ActiveSection != null) ? itm.ActiveSection.DisplayNumber : BuildStepTab(itm);// C2018-003 fixed use of getting the active section + string itemkey = $"{stepnum} {itm.ItemID}"; // add ItemId to stepnum, sometimes we have idential stepnum text for different steps (ex: blank section numbers) + + if (!sortedStepList.ContainsKey(itemkey)) + { + sortedStepList.Add(itemkey, itm); + } + } + + if (sortedStepList.Count > 0) + { + PutStepListForProcedure(rotable, sortedStepList); + } + + curTable.AddCell(rotable); + } + } + + private string GetROTitleAndGroup(string roid, ItemInfo itm) + { + string rotitle = string.Empty; + + ROFSTLookup myrofstlookup = (itm == null) ? _ROFSTLookup : itm.MyDocVersion.DocVersionAssociations[0].MyROFst.GetROFSTLookup(itm.MyDocVersion); + + List roTitleList = myrofstlookup.GetROTitleAndGroupPath(roid, _IncludeMissingROs, _ConvertCaretToDelta); + + if (roTitleList != null && roTitleList.Count > 0) + { + for (int cnt = 0; cnt < roTitleList.Count; cnt++) + { + if (cnt == roTitleList.Count - 1) // Last roTitle in list, don't add a NewLine character after the value + rotitle += roTitleList[cnt]; + else + rotitle += $"{roTitleList[cnt]}\n "; + } + } + + return rotitle; + } + + private void AddROHeaderGroup(PdfPTable datatable, string curROID, ItemInfo itm, Font f2, Color bgColor) + { + string headerText = GetROTitleAndGroup(curROID, itm); + + if (!string.IsNullOrEmpty(headerText) && headerText.Length > 0) + { + PdfPCell cell = new PdfPCell(new Phrase(headerText, f2)) + { + Colspan = 2, + BackgroundColor = (headerText.StartsWith("Missing RO")) ? Color.PINK : bgColor, + BorderWidthTop = 1 + }; + + datatable.AddCell(cell); + } + } + + private void BuildROUsageTableByRO(iTextSharp.text.Document document) + { + Dictionary> procRoUse = new Dictionary>(); + + float[] headerwidths = { 20, 80 }; + PdfPTable datatable = new PdfPTable(1); + PdfPTable colHeader = new PdfPTable(headerwidths); + //datatable.FooterRows = 1; + datatable.TotalWidth = document.PageSize.Width - document.LeftMargin - document.RightMargin; + datatable.LockedWidth = true; + + // C2017-036 get best available proportional font for symbols that looks close to Arial + // Note that Microsoft no longer supplies Arial Unicode MS as of Word16 + iTextSharp.text.Font f1 = pdf.GetFont(Volian.Base.Library.vlnFont.ReportsFont, 14, 1, Color.BLACK); + iTextSharp.text.Font f2 = pdf.GetFont(Volian.Base.Library.vlnFont.ReportsFont, 10, 0, Color.BLACK); + PdfPCell cell = new PdfPCell(new Phrase(ReportTitle, f1)) + { + HorizontalAlignment = Element.ALIGN_CENTER, + BackgroundColor = new Color(0xD0, 0xF0, 0xF0) // light blue + }; + datatable.AddCell(cell); + + BuildSearchResultsProcSetList(); + datatable.HeaderRows = 2;//3 + (ProcSetList.Count == 1 ? 1 : 0); + int splitAt = FindSpitLevel(); // find the split level of the common path + + Color subHeaderColor = new Color(0xD0, 0xF0, 0xF0); // light blue //new Color(0xD0, 0xF0, 0xD0);//ligt green + datatable.DefaultCell.Padding = 4; + datatable.DefaultCell.HorizontalAlignment = Element.ALIGN_CENTER; + // This puts "Step" and "Text" column headers at the bottom of the page + AddCell(colHeader, "Step", f2, subHeaderColor); + AddCell(colHeader, "Text", f2, subHeaderColor); + datatable.AddCell(colHeader); + + datatable.DefaultCell.HorizontalAlignment = Element.ALIGN_LEFT; + PdfPTable subTable = new PdfPTable(headerwidths); + datatable.AddCell(subTable); + + string lastDVPath = string.Empty; + string lastROID = string.Empty; + bool moreThanOneProcSet = false; + bool printedSetTitle = false; + bool printedROHeader = false; + ItemInfo lastItem = null; + + if (ResultList.Count == 0) + { + PdfPCell cell2 = new PdfPCell(new Phrase("Selected RO is not used", f2)) + { + Colspan = 0, + BorderWidthTop = 1 + }; + datatable.AddCell(cell2); + document.Add(datatable); + + return; + } + + foreach (ItemInfo item in ResultList) + { + bool differentProcSet = false; + bool differentRO = false; + + // Check Doc Version path + // if more than one procedure set is in the report data, then + // we will output the procedure set title inside the grouping of each RO + // otherwise, if we are reporting on only one procedure set, print the + // procedure set title at the top of the report (once). + if (!string.IsNullOrEmpty(lastDVPath) && lastDVPath != item.SearchDVPath) + { + moreThanOneProcSet = true; + differentProcSet = true; + } + + lastDVPath = item.SearchDVPath; + + // Check for different ROID + string curROID = item.FoundROID; + differentRO = (!string.IsNullOrEmpty(lastROID) && !string.IsNullOrEmpty(curROID) && curROID.Substring(0, 12) != lastROID.Substring(0, 12)); + + if (procRoUse.Count > 0 && (differentProcSet || differentRO)) + { + if (!moreThanOneProcSet && !printedSetTitle) + { + AddMainPathGroup(datatable, lastDVPath, splitAt, f2, Color.LIGHT_GRAY, 0); + printedSetTitle = true; + } + + if (!printedROHeader) + { + AddROHeaderGroup(datatable, lastROID, lastItem, f2, new Color(0xC0, 0xFF, 0xC0)); + printedROHeader = true; + } + + PutROusageForROID(datatable, procRoUse, headerwidths, splitAt, moreThanOneProcSet); + procRoUse.Clear(); + + differentProcSet = false; + } + + if (differentRO) + { + printedROHeader = false; + } + + AddProcROUse(item, procRoUse); + + lastROID = curROID; + lastItem = item; + } + + if (!moreThanOneProcSet && !printedSetTitle) + AddMainPathGroup(datatable, lastDVPath, splitAt, f2, Color.LIGHT_GRAY, 0); + + if (!printedROHeader) + AddROHeaderGroup(datatable, lastROID, lastItem, f2, new Color(0xC0, 0xFF, 0xC0)); + + PutROusageForROID(datatable, procRoUse, headerwidths, splitAt, moreThanOneProcSet); + + document.Add(datatable); + } + + private void BuildSearchResultsProcSetList() + { + ProcSetList = new System.Collections.ArrayList(); + foreach (ItemInfo item in ResultList) + { + if (!ProcSetList.Contains(item.SearchDVPath)) + ProcSetList.Add(item.SearchDVPath); + } + } + + private void BuildLibDocProcSetList() + { + ProcSetList = new System.Collections.ArrayList(); + foreach (DocumentInfo di in LibDocList) + { + if (di.LibraryDocumentUsageList != null && di.LibraryDocumentUsageList.Count > 0) + foreach (ItemInfo item in di.LibraryDocumentUsageList) + { + if (!ProcSetList.Contains(item.SearchDVPath)) + ProcSetList.Add(item.SearchDVPath); + } + } + } + + private ArrayList GetSortedItemInfoList(ItemInfoList orgIFL) + { + System.Collections.ArrayList libDocProcSetList = new System.Collections.ArrayList(); + System.Collections.ArrayList rtnIFL = new System.Collections.ArrayList(); + foreach (ItemInfo item in orgIFL) + { + if (!libDocProcSetList.Contains(item.SearchDVPath)) + libDocProcSetList.Add(item.SearchDVPath); + } + foreach (string pset in libDocProcSetList) + { + foreach (ItemInfo item in orgIFL) + { + if (item.SearchDVPath.Equals(pset)) + rtnIFL.Add(item); + } + } + return rtnIFL; + } + + private void BuildCompleteROReport(iTextSharp.text.Document document) + { + CompleteROReport compRORpt = new CompleteROReport(_MyPdfWriter, document, _RODataFile, _ConvertCaretToDelta, _IncludeEmptyROFields) + { + F10 = pdf.GetFont("Courier New", 10, 0, Color.BLACK), + F10Bold = pdf.GetFont("Courier New", 10, 1, Color.BLACK), + F12 = pdf.GetFont("Courier New", 12, 0, Color.BLACK), + F12Bold = pdf.GetFont("Courier New", 12, 1, Color.BLACK), + // C2017-036 Get best available proportional font for symbols that looks close to Arial + // Note that Microsoft no longer supplies Arial Unicode MS as of Word16 + F14 = pdf.GetFont(Volian.Base.Library.vlnFont.ReportsFont, 14, 1, Color.BLACK), + + //B2022 - 083: Support Conditional RO Values + ROFstID = _ROFSTLookup.RofstID + }; + + compRORpt.Run(); + } + + private string GetROTitleAndGroupsForSummary(List roTitleList, List prevROTitleList) + { + string rotitle = string.Empty; + string indent = string.Empty; + + for (int icnt = 0; icnt < roTitleList.Count; icnt++) + { + indent += " "; + + if (icnt == roTitleList.Count - 1) + { + rotitle += indent + roTitleList[icnt]; // this should be the ro description + break; //break out of for loop + } + + if (prevROTitleList == null || (icnt < roTitleList.Count && icnt < prevROTitleList.Count && prevROTitleList[icnt] != roTitleList[icnt])) + { + if (rotitle == string.Empty && prevROTitleList != null) + rotitle = "\n"; + + rotitle += $"{indent}{roTitleList[icnt]}\n"; + } + } + + return rotitle; + } + + private List AddROHeaderGroupForSummary(PdfPTable datatable, string curROID, List prevROTitleList, Font f2) + { + List roTitleList = _ROFSTLookup.GetROTitleAndGroupPath(curROID, _IncludeMissingROs, _ConvertCaretToDelta); + string headerText = GetROTitleAndGroupsForSummary(roTitleList, prevROTitleList); + + if (headerText.Length > 0) + { + Paragraph pgh = new Paragraph(headerText, f2); + PdfPCell cell = new PdfPCell(pgh) + { + FollowingIndent = 72, + Colspan = 2, + BorderColor = Color.WHITE, + BackgroundColor = Color.WHITE, + BorderWidthTop = 1 + }; + + datatable.AddCell(cell); + } + + return roTitleList; + } + + private void BuildROSummaryReport(iTextSharp.text.Document document) + { + PdfPTable datatable = new PdfPTable(1) + { + TotalWidth = document.PageSize.Width - document.LeftMargin - document.RightMargin, + LockedWidth = true + }; + + // C2017-036 get best available proportional font for symbols that looks close to Arial + // Note that Microsoft no longer supplies Arial Unicode MS as of Word16 + iTextSharp.text.Font f1 = pdf.GetFont(Volian.Base.Library.vlnFont.ReportsFont, 14, 1, Color.BLACK); + iTextSharp.text.Font f2 = pdf.GetFont(Volian.Base.Library.vlnFont.ReportsFont, 10, 0, Color.BLACK); + iTextSharp.text.Font f3 = pdf.GetFont(Volian.Base.Library.vlnFont.ReportsFont, 12, 1, Color.BLACK); + + PdfPCell cell = new PdfPCell(new Phrase(ReportTitle, f1)) + { + HorizontalAlignment = Element.ALIGN_CENTER, + //cell.Colspan = 2; + BackgroundColor = Color.WHITE,//new Color(0xD0, 0xF0, 0xF0); // light blue + BorderColor = Color.WHITE + }; + datatable.AddCell(cell); + + string roFSTDateTime = $"RO.FST Last Created: {_ROFSTLookup.GetRoFSTdts().ToLongDateString()} @ {_ROFSTLookup.GetRoFSTdts().ToShortTimeString()}\n "; + cell = new PdfPCell(new Phrase(roFSTDateTime, f2)) + { + BorderColor = Color.WHITE + }; + datatable.AddCell(cell); + + datatable.HeaderRows = 2; + datatable.DefaultCell.HorizontalAlignment = Element.ALIGN_LEFT; + string lastROID = string.Empty; + List prevROTitleList = null; + int lastDBindex = -1; + + foreach (string curROID in _ROList) + { + string[] tmp = curROID.TrimEnd(',').Split(':'); //curROID.Split(':');// this is the RO FST id number (for plants with multiple RO FSTs) + string rolst = (tmp.Length == 2) ? tmp[1] : tmp[0]; + string[] roIdslst = rolst.Split(','); + + foreach (string cROID in roIdslst) + { + if (string.IsNullOrEmpty(cROID)) + break; + + if (cROID.Length == 4) + ProcessROdb(datatable, f2, f3, ref cell, ref lastROID, ref prevROTitleList, ref lastDBindex, cROID); + else + ProcessROID(datatable, f2, f3, ref cell, ref lastROID, ref prevROTitleList, ref lastDBindex, cROID); + } + } + + document.Add(datatable); + } + + private void ProcessROdb(PdfPTable datatable, iTextSharp.text.Font f2, iTextSharp.text.Font f3, ref PdfPCell cell, ref string lastROID, ref List prevROTitleList, ref int lastDBindex, string cROID) + { + ROFSTLookup.rodbi roDBI = _ROFSTLookup.GetRODatabase(cROID, true, true); + + if (roDBI.children != null && roDBI.children.Length > 0) + { + for (int i = 0; i < roDBI.children.Length; i++) + { + ProcessROChild(datatable, f2, f3, ref cell, ref lastROID, ref prevROTitleList, ref lastDBindex, roDBI.children[i]); + } + } + else + { + ProcessROID(datatable, f2, f3, ref cell, ref lastROID, ref prevROTitleList, ref lastDBindex, cROID); + + cell = new PdfPCell(new Phrase(" ", f2)) + { + BorderColor = Color.WHITE + }; + datatable.AddCell(cell); + cell = new PdfPCell(new Phrase("-- No Information Entered --", f2)) + { + BorderColor = Color.WHITE + }; + datatable.AddCell(cell); + } + } + + private void ProcessROChild(PdfPTable datatable, iTextSharp.text.Font f2, iTextSharp.text.Font f3, ref PdfPCell cell, ref string lastROID, ref List prevROTitleList, ref int lastDBindex, ROFSTLookup.rochild cld) + { + if (cld.children == null || cld.children.Length <= 0) // leaf node + { + ProcessROID(datatable, f2, f3, ref cell, ref lastROID, ref prevROTitleList, ref lastDBindex, cld.roid); + } + else if (cld.children[0].ParentID == 0) // multiple return value + { + ProcessROID(datatable, f2, f3, ref cell, ref lastROID, ref prevROTitleList, ref lastDBindex, cld.roid); + } + else + { + for (int i = 0; i < cld.children.Length; i++) + { + ProcessROChild(datatable, f2, f3, ref cell, ref lastROID, ref prevROTitleList, ref lastDBindex, cld.children[i]); + } + } + } + + private void ProcessROID(PdfPTable datatable, iTextSharp.text.Font f2, iTextSharp.text.Font f3, ref PdfPCell cell, ref string lastROID, ref List prevROTitleList, ref int lastDBindex, string cROID) + { + int curDBindex = _ROFSTLookup.GetRODatabaseTitleIndex(cROID); + + if (lastDBindex == -1 || curDBindex != lastDBindex) + { + if (prevROTitleList != null) + { + // add blank line to separate groups on the report + cell = new PdfPCell(new Phrase(" ", f2)) + { + BorderColor = Color.WHITE + }; + datatable.AddCell(cell); + } + + AddMainRODatabaseTitle(datatable, curDBindex, f3, Color.WHITE); + lastDBindex = curDBindex; + } + + if (string.IsNullOrEmpty(lastROID) || cROID != lastROID) + prevROTitleList = AddROHeaderGroupForSummary(datatable, cROID, prevROTitleList, f2); + + lastROID = cROID; + } + + #endregion + + #region Private Static Methods + + private static PdfPTable BuildSubTable(iTextSharp.text.Document document, float[] headerwidths) + { + PdfPTable subtable = new PdfPTable(headerwidths) + { + HeaderRows = 1, + KeepTogether = true, + TotalWidth = document.PageSize.Width - document.LeftMargin - document.RightMargin, + LockedWidth = true + }; + subtable.DefaultCell.Padding = 4; + + return subtable; + } + + private static void ShowException(Exception ex) + { + Console.WriteLine("{0} - {1}", ex.GetType().Name, ex.Message); + StringBuilder msg = new StringBuilder(); + string sep = string.Empty; + string indent = string.Empty; + + while (ex != null) + { + msg.Append(string.Format("{0}{1}{2}:\r\n{1}{3}", sep, indent, ex.GetType().Name, ex.Message)); + ex = ex.InnerException; + sep = "\r\n"; + indent += " "; + } + + System.Windows.Forms.MessageBox.Show(msg.ToString(), "Error during PDF creation for search:", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Exclamation); + } + + public static string BuildStepTab(ItemInfo item) + { + if (item == null) + return string.Empty; + + string sret = string.Empty; + + switch (item.MyContent.Type / 10000) + { + case 0: //procedure + sret = ProcedureInfo.Get(item.ItemID).MyTab.CleanText; + break; + + case 1: // section + sret = SectionInfo.Get(item.ItemID).MyTab.CleanText; + break; + + case 2: // step + ItemInfo pitem = item; + bool hasDelim = item.ActiveFormat.PlantFormat.FormatData.TransData.StepSubstepDelimeter != null; + List DelimList = new List(); + + if (!hasDelim) + { + SeqTabFmtList seqtabs = item.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.SeqTabFmtList; + + foreach (SeqTabFmt seqtab in seqtabs) + { + string delim = seqtab.PrintTabFormat.Replace("{seq}", string.Empty); + + if (!DelimList.Contains(delim)) + { + DelimList.Add(delim.Trim()); + } + } + } + else + { + string stpdelms = item.ActiveFormat.PlantFormat.FormatData.TransData.StepSubstepDelimeter; + + foreach (char c in stpdelms) + { + if (!DelimList.Contains(c.ToString())) + { + DelimList.Add(c.ToString()); + } + } + } + + // B2016-160 Support transitions to sections + while (!pitem.IsSection && !pitem.IsHigh) + { + StepInfo stpinfo = StepInfo.Get(pitem.ItemID); + string thisTab = stpinfo.MyTab.CleanText; + + if (IncludesParentToHLS(stpinfo)) + { + if (!thisTab.Contains("\u25CF")) //Remove Bullet + { + return thisTab; + } + else + { + thisTab = null; + } + } + + string typeName = stpinfo.FormatStepData.StepEditData.TypeMenu.MenuItem;//stpinfo.FormatStepData.ToString(); + + // remove delimiters of '.' and ')' in tab. + if (!string.IsNullOrEmpty(thisTab)) + { + // get list of delimiters to remove from the format: + foreach (string rmvDelim in DelimList) + { + thisTab = thisTab.Replace(rmvDelim, string.Empty); + } + } + + if (!string.IsNullOrEmpty(thisTab)) + { + thisTab = thisTab.Trim(); + } + + // if the tab is null or + // if the the tab is not a letter or number OR + // the tab is an AND or OR type and is the letter "o" + // then reset the tab an empty string so that the type name along with the count of that type + // (ex. "AND 2", "OR 3") + if (string.IsNullOrEmpty(thisTab) || (thisTab != string.Empty && (!(char.IsLetterOrDigit(thisTab[0])) || ((pitem.IsAnd || pitem.IsOr || pitem.IsCaution || pitem.IsNote) && thisTab.Contains("o"))))) + { + thisTab = string.Empty; + } + + if (pitem.IsRNOPart) + { + if (string.IsNullOrEmpty(thisTab)) + { + sret = "RNO." + sret; //"RNO." + sret; + } + else + { + thisTab = thisTab.Trim(" ".ToCharArray()); + + if (!thisTab.EndsWith(".") && !thisTab.EndsWith(")")) + { + thisTab += "."; + } + + sret = $"RNO.{thisTab}{sret}"; //"RNO." + thisTab + sret; + } + } + else if (pitem.IsCaution || pitem.IsNote) + { + // add the Caution or Note count to the tab (ex "Caution 1", "Note 2") + if (string.IsNullOrEmpty(thisTab)) + { + sret = $"{{{typeName} {pitem.Ordinal}}}"; + } + else + { + thisTab = thisTab.Trim(" ".ToCharArray()); + sret = $"{thisTab} {pitem.Ordinal}{sret}"; + } + } + else + { + if (!string.IsNullOrEmpty(thisTab)) + { + thisTab = thisTab.Trim(" ".ToCharArray()); + + if (!thisTab.EndsWith(".") && !thisTab.EndsWith(")")) + { + thisTab += "."; + } + } + else + { + thisTab = $"{{{typeName} {pitem.Ordinal}}}."; + } + + sret = thisTab + sret; + } + + pitem = pitem.ActiveParent as ItemInfo; + + if (pitem == null) + break; + } + + // add hls tab if it's not already in the tab. + if (pitem.IsHigh) + { + StepInfo stpinfo = StepInfo.Get(pitem.ItemID); + + string hlsTab = stpinfo.MyTab.CleanTextNoSymbols; //StepInfo.Get(pitem.ItemID).MyTab.CleanTextNoSymbols; + string typeName = stpinfo.FormatStepData.StepEditData.TypeMenu.MenuItem;//stpinfo.FormatStepData.GetPDDisplayName(); //.ToString(); + // C2020-043: don't remove delimiters on tabs if this step's tab has the parent tab included. + bool hasParent = false; + + if (IncludesParentToHLS(stpinfo) && !hlsTab.Contains("\u25CF")) + { + hlsTab = hlsTab.Trim(" ".ToCharArray()).TrimEnd(".".ToCharArray()); + hasParent = true; + } + + if (string.IsNullOrEmpty(hlsTab)) + { + hlsTab = $"{{{typeName} {pitem.Ordinal}}}."; + } + else if (!hasParent && !sret.StartsWith(hlsTab.Trim(" ".ToCharArray()))) + { + foreach (string rmvDelim in DelimList) + { + hlsTab = hlsTab.Replace(rmvDelim, string.Empty); + } + + hlsTab = hlsTab.Trim(" ".ToCharArray()); + + if (!hlsTab.EndsWith(".") && !hlsTab.EndsWith(")")) + { + hlsTab += "."; + } + } + + sret = hlsTab + sret; + } + + break; + } + + return sret.Trim(" .)".ToCharArray()); + } + + private static bool IncludesParentToHLS(StepInfo stpinfo) + { + if (stpinfo.IsHigh) + return true; + + StepInfo parent = StepInfo.Get((stpinfo.ActiveParent as ItemInfo).ItemID); + + if (stpinfo.MyTab.CleanText.StartsWith(parent.MyTab.CleanText.Trim()) && stpinfo.MyTab.CleanText.Length > parent.MyTab.CleanText.Length) + { + return IncludesParentToHLS(parent); + } + + return false; + } + + #endregion + } + + + public class MyPageHelper : PdfPageEventHelper + { + #region Fields + + protected PdfTemplate total; + protected BaseFont helv; + private readonly int ptSize = 10; // text point size of page number and page total + readonly string _ByLine = "PROMS"; + + #endregion + + #region Properties + + public PdfPTable HeaderTable { get; set; } = null; + + #endregion + + #region Constructors + + public MyPageHelper(string byLine) + { + _ByLine = byLine; + } + + #endregion + + #region Public Methods + + public override void OnOpenDocument(PdfWriter writer, iTextSharp.text.Document document) + { + total = writer.DirectContent.CreateTemplate(100, 100); + total.BoundingBox = new Rectangle(-20, -20, 100, 100); + helv = BaseFont.CreateFont(BaseFont.HELVETICA, BaseFont.WINANSI, BaseFont.EMBEDDED); + } + + public override void OnEndPage(PdfWriter writer, iTextSharp.text.Document document) + { + PdfContentByte cb = writer.DirectContent; + + cb.SaveState(); + + HeaderTable?.WriteSelectedRows(0, 2, 36, document.Top + 44, cb); + String text = $"Page {writer.PageNumber} of "; + float textBase = document.Bottom - 19;//20; + cb.BeginText(); + cb.SetFontAndSize(helv, ptSize); + + float posCenter = document.Left + ((document.Right - document.Left) / 2) - (helv.GetWidthPoint($"{text}XX", ptSize) / 2); + cb.SetTextMatrix(posCenter, textBase); + cb.ShowText(text); + cb.EndText(); + cb.AddTemplate(total, posCenter + helv.GetWidthPoint(text, ptSize), textBase); + cb.RestoreState(); + + AddVolianFooter(writer, document); + AddDateFooter(writer, document); + } + + public override void OnCloseDocument(PdfWriter writer, iTextSharp.text.Document document) + { + total.BeginText(); + total.SetFontAndSize(helv, ptSize); + total.SetTextMatrix(0, 0); + total.ShowText((writer.PageNumber - 1).ToString()); + total.EndText(); + + base.OnCloseDocument(writer, document); + } + + #endregion + + #region Private Methods + + private void AddVolianFooter(PdfWriter writer, iTextSharp.text.Document document) + { + PdfContentByte cb = writer.DirectContent; + cb.SaveState(); + String text = _ByLine;//"PROMS Search Results"; + float textBase = document.Bottom - 19;//20; + cb.BeginText(); + cb.SetFontAndSize(helv, ptSize); + cb.SetTextMatrix(document.Left, textBase); + cb.ShowText(text); + cb.EndText(); + cb.RestoreState(); + } + + private void AddDateFooter(PdfWriter writer, iTextSharp.text.Document document) + { + PdfContentByte cb = writer.DirectContent; + cb.SaveState(); + String text = DateTime.Today.ToShortDateString(); + float textBase = document.Bottom - 19;//20; + float posRight = document.Right - helv.GetWidthPoint(text, ptSize); + cb.BeginText(); + cb.SetFontAndSize(helv, ptSize); + cb.SetTextMatrix(posRight, textBase); + cb.ShowText(text); + cb.EndText(); + cb.RestoreState(); + } + + #endregion + } } diff --git a/PROMS/Volian.Print.Library/PDFTransitionReport.cs b/PROMS/Volian.Print.Library/PDFTransitionReport.cs index fe283a83..79f0919c 100644 --- a/PROMS/Volian.Print.Library/PDFTransitionReport.cs +++ b/PROMS/Volian.Print.Library/PDFTransitionReport.cs @@ -5,7 +5,7 @@ using VEPROMS.CSLA.Library; using iTextSharp.text.pdf; using iTextSharp.text; using System.IO; -using System.Text.RegularExpressions; +using System.Linq; namespace Volian.Print.Library { @@ -13,27 +13,14 @@ namespace Volian.Print.Library public class PDFTransitionReport { public event TransitionReportEvent TransitionProcessed; - private void OnTransitionProcessed(object sender, EventArgs args) - { - if (TransitionProcessed != null) TransitionProcessed(sender, args); - } - public event TransitionReportEvent ProcedureProcessed; - private void OnProcedureProcessed(object sender, EventArgs args) - { - if (ProcedureProcessed != null) ProcedureProcessed(sender, args); - } - public event TransitionReportEvent DocVersionProcessed; - private void OnDocVersionProcessed(object sender, EventArgs args) - { - if (DocVersionProcessed != null) DocVersionProcessed(sender, args); - } - private string _FileName; - public string FileName - { - get { return _FileName; } - set { _FileName = value; } - } - private PdfPCell _CurrentPageNumberCell = null; + private void OnTransitionProcessed(object sender, EventArgs args) => TransitionProcessed?.Invoke(sender, args); + public event TransitionReportEvent ProcedureProcessed; + private void OnProcedureProcessed(object sender, EventArgs args) => ProcedureProcessed?.Invoke(sender, args); + public event TransitionReportEvent DocVersionProcessed; + private void OnDocVersionProcessed(object sender, EventArgs args) => DocVersionProcessed?.Invoke(sender, args); + + public string FileName { get; set; } + private PdfPCell _CurrentPageNumberCell = null; private int _CurrentPageNumber = 1; public int CurrentPageNumber { @@ -51,41 +38,27 @@ namespace Volian.Print.Library } } } - private FolderInfo folderInfo; + private readonly FolderInfo folderInfo; private ProcedureInfo procedureInfo; private TransitionInfoList transitionInfoList; - private int _TransitionInfoCount; - public int TransitionInfoCount - { - get { return _TransitionInfoCount; } - set { _TransitionInfoCount = value; } - } - private List _MyDocVersionList; - public List MyDocVersionList - { - get { return _MyDocVersionList; } - set { _MyDocVersionList = value; } - } - private int _ProcedureCount; - public int ProcedureCount - { - get { return _ProcedureCount; } - set { _ProcedureCount = value; } - } - private string _PaperSize = "Letter"; + + public int TransitionInfoCount { get; set; } + public List MyDocVersionList { get; set; } + public int ProcedureCount { get; set; } + private readonly string _PaperSize = "Letter"; public PDFTransitionReport(FolderInfo fi, string fileName) { - _FileName = fileName; + FileName = fileName; folderInfo = fi; if (fi.ActiveFormat != null) _PaperSize = fi.ActiveFormat.PlantFormat.FormatData.PDFPageSize.PaperSize; // C2020-002 paper size is now set in the format files } public PDFTransitionReport(ProcedureInfo pi, string fileName) { - _FileName = fileName; + FileName = fileName; procedureInfo = pi; transitionInfoList = TransitionInfoList.GetTransitionReportData(procedureInfo.MyDocVersion.VersionID, procedureInfo.ItemID); - _TransitionInfoCount = transitionInfoList.Count; + TransitionInfoCount = transitionInfoList.Count; _PaperSize = pi.ActiveFormat.PlantFormat.FormatData.PDFPageSize.PaperSize; // C2020-002 paper size is now set in the format files } public void BuildTransitionReport() @@ -100,13 +73,13 @@ namespace Volian.Print.Library if (MyDocVersionList.Count == 1) { DocVersionInfo dvi = MyDocVersionList[0]; - foreach (ProcedureInfo pi in dvi.Procedures) + foreach (ProcedureInfo pi in dvi.Procedures.OfType()) { procedureInfo = pi; transitionInfoList = TransitionInfoList.GetTransitionReportData(dvi.VersionID, procedureInfo.ItemID); if (transitionInfoList.Count > 0) { - _TransitionInfoCount = transitionInfoList.Count; + TransitionInfoCount = transitionInfoList.Count; OnProcedureProcessed(this, new EventArgs()); BuildProcedureReport(document); } @@ -122,11 +95,11 @@ namespace Volian.Print.Library { ProcedureCount = dvi.Procedures.Count; OnDocVersionProcessed(this, new EventArgs()); - foreach (ProcedureInfo pi in dvi.Procedures) + foreach (ProcedureInfo pi in dvi.Procedures.OfType()) { procedureInfo = pi; transitionInfoList = TransitionInfoList.GetTransitionReportData(dvi.VersionID, procedureInfo.ItemID); - _TransitionInfoCount = transitionInfoList.Count; + TransitionInfoCount = transitionInfoList.Count; OnProcedureProcessed(this, new EventArgs()); BuildProcedureReport(document); } @@ -140,7 +113,6 @@ namespace Volian.Print.Library } catch (Exception ex) { - StringBuilder msg = new StringBuilder(); document.Add(new Paragraph("Error:")); while (ex != null) { @@ -160,11 +132,13 @@ namespace Volian.Print.Library } PdfOutline outline = null; ProcedureInfo lastProcedureInfo = null; - private PdfPTable BuildProcedurePDFTable(Dictionary levels, Dictionary fonts, int cols, int paddingBottom, int level, iTextSharp.text.Document doc) + private PdfPTable BuildProcedurePDFTable(Dictionary levels, Dictionary fonts, int cols, int paddingBottom, int level) { - PdfPTable t = new PdfPTable(cols); - t.HeaderRows = 4; - t.DefaultCell.Padding = 4; + PdfPTable t = new PdfPTable(cols) + { + HeaderRows = 4 + }; + t.DefaultCell.Padding = 4; t.WidthPercentage = 100; float[] widths; if(level == 1 || level == 2 || level == 4) @@ -172,52 +146,66 @@ namespace Volian.Print.Library else widths = new float[] { 33f, 47f, 20f }; t.SetWidths(widths); - //report title - Phrase h = new Phrase(); - h.Font = fonts[1]; - if (folderInfo != null) + //report title + Phrase h = new Phrase + { + Font = fonts[1] + }; + if (folderInfo != null) h.Add(string.Format("Procedure Set {0} Transition Report", folderInfo.Name)); else h.Add("Transition Report"); - PdfPCell c = new PdfPCell(h); - c.Colspan = cols-1; - c.HorizontalAlignment = Element.ALIGN_LEFT; - c.PaddingBottom = paddingBottom; - c.BackgroundColor = new Color(System.Drawing.Color.DarkGoldenrod); - t.AddCell(c); - //date generated - h = new Phrase(); - h.Font = fonts[4]; - h.Add(DateTime.Now.ToString("dddd MMMM d, yyyy @ h:mm tt")); - c = new PdfPCell(h); - c.HorizontalAlignment = Element.ALIGN_RIGHT; - c.PaddingBottom = paddingBottom; - c.BackgroundColor = new Color(System.Drawing.Color.DarkGoldenrod); - t.AddCell(c); - //procedure title - h = new Phrase(); - h.Font = fonts[2]; - h.Add(string.Format("{0} - {1}", procedureInfo.DisplayNumber, procedureInfo.DisplayText)); + PdfPCell c = new PdfPCell(h) + { + Colspan = cols - 1, + HorizontalAlignment = Element.ALIGN_LEFT, + PaddingBottom = paddingBottom, + BackgroundColor = new Color(System.Drawing.Color.DarkGoldenrod) + }; + t.AddCell(c); + //date generated + h = new Phrase + { + Font = fonts[4] + }; + h.Add(DateTime.Now.ToString("dddd MMMM d, yyyy @ h:mm tt")); + c = new PdfPCell(h) + { + HorizontalAlignment = Element.ALIGN_RIGHT, + PaddingBottom = paddingBottom, + BackgroundColor = new Color(System.Drawing.Color.DarkGoldenrod) + }; + t.AddCell(c); + //procedure title + h = new Phrase + { + Font = fonts[2] + }; + h.Add(string.Format("{0} - {1}", procedureInfo.DisplayNumber, procedureInfo.DisplayText)); PdfDestination dest = new PdfDestination(PdfDestination.FITH, cb.PdfDocument.PageSize.Height); if (lastProcedureInfo != procedureInfo) { outline = new PdfOutline(cb.RootOutline, dest, procedureInfo.DisplayNumber, false); lastProcedureInfo = procedureInfo; } - c = new PdfPCell(h); - c.Colspan = cols-1; - c.HorizontalAlignment = Element.ALIGN_LEFT; - c.PaddingBottom = paddingBottom; - c.BackgroundColor = new Color(System.Drawing.Color.Goldenrod); - t.AddCell(c); + c = new PdfPCell(h) + { + Colspan = cols - 1, + HorizontalAlignment = Element.ALIGN_LEFT, + PaddingBottom = paddingBottom, + BackgroundColor = new Color(System.Drawing.Color.Goldenrod) + }; + t.AddCell(c); //page number _CurrentPageNumberCell = BuildCell(1, string.Format("Page {0}",CurrentPageNumber), fonts[4], new Color(System.Drawing.Color.Goldenrod)); _CurrentPageNumberCell.PaddingBottom = paddingBottom; t.AddCell(_CurrentPageNumberCell); - //transition category - h = new Phrase(); - h.Font = fonts[3]; - if (transitionInfoList.Count == 0) + //transition category + h = new Phrase + { + Font = fonts[3] + }; + if (transitionInfoList.Count == 0) h.Add("N/A"); else { @@ -225,75 +213,97 @@ namespace Volian.Print.Library dest = new PdfDestination(PdfDestination.FITH, cb.PdfDocument.PageSize.Height); new PdfOutline(outline, dest, levels[level]); } - c = new PdfPCell(h); - c.Colspan = cols; - c.HorizontalAlignment = Element.ALIGN_LEFT; - c.PaddingBottom = paddingBottom; - c.BackgroundColor = new Color(System.Drawing.Color.Khaki); - t.AddCell(c); - //add column headers - h = new Phrase(); - h.Font = fonts[4]; - h.Add("From Procedure Location"); - c = new PdfPCell(h); - c.HorizontalAlignment = Element.ALIGN_CENTER; - c.PaddingBottom = paddingBottom; - c.BackgroundColor = new Color(System.Drawing.Color.PaleGoldenrod); - t.AddCell(c); - h = new Phrase(); - h.Font = fonts[4]; - h.Add("From Procedure Text"); - c = new PdfPCell(h); - c.HorizontalAlignment = Element.ALIGN_CENTER; - c.PaddingBottom = paddingBottom; - c.BackgroundColor = new Color(System.Drawing.Color.PaleGoldenrod); - t.AddCell(c); - h = new Phrase(); - h.Font = fonts[4]; - h.Add("To Procedure Location"); - c = new PdfPCell(h); - c.HorizontalAlignment = Element.ALIGN_CENTER; - c.PaddingBottom = paddingBottom; - c.BackgroundColor = new Color(System.Drawing.Color.PaleGoldenrod); - t.AddCell(c); + c = new PdfPCell(h) + { + Colspan = cols, + HorizontalAlignment = Element.ALIGN_LEFT, + PaddingBottom = paddingBottom, + BackgroundColor = new Color(System.Drawing.Color.Khaki) + }; + t.AddCell(c); + //add column headers + h = new Phrase + { + Font = fonts[4] + }; + h.Add("From Procedure Location"); + c = new PdfPCell(h) + { + HorizontalAlignment = Element.ALIGN_CENTER, + PaddingBottom = paddingBottom, + BackgroundColor = new Color(System.Drawing.Color.PaleGoldenrod) + }; + t.AddCell(c); + h = new Phrase + { + Font = fonts[4] + }; + h.Add("From Procedure Text"); + c = new PdfPCell(h) + { + HorizontalAlignment = Element.ALIGN_CENTER, + PaddingBottom = paddingBottom, + BackgroundColor = new Color(System.Drawing.Color.PaleGoldenrod) + }; + t.AddCell(c); + h = new Phrase + { + Font = fonts[4] + }; + h.Add("To Procedure Location"); + c = new PdfPCell(h) + { + HorizontalAlignment = Element.ALIGN_CENTER, + PaddingBottom = paddingBottom, + BackgroundColor = new Color(System.Drawing.Color.PaleGoldenrod) + }; + t.AddCell(c); return t; } PdfContentByte cb; private void BuildProcedureReport(iTextSharp.text.Document doc) { Dictionary tranTypes = FormatInfo.GetTransitionTypesByFormatID(procedureInfo.ActiveFormat.FormatID); - Dictionary levels = new Dictionary(); - levels.Add(1, "Internal Transitions"); - levels.Add(2, "External From Transitions"); - levels.Add(3, "External To Transitions"); - levels.Add(4, "Outside From Transitions"); - levels.Add(5, "Outside To Transitions"); - Dictionary fonts = new Dictionary(); - // C2017-036 get best available proportional font for symbols that looks close to Arial - // Note that Microsoft no longer supplies Arial Unicode MS as of Word16 - fonts.Add(1, pdf.GetFont(Volian.Base.Library.vlnFont.ReportsFont, 12, 0, Color.BLACK)); - fonts.Add(2, pdf.GetFont(Volian.Base.Library.vlnFont.ReportsFont, 10, 0, Color.BLACK)); - fonts.Add(3, pdf.GetFont(Volian.Base.Library.vlnFont.ReportsFont, 8, 0, Color.BLACK)); - fonts.Add(4, pdf.GetFont(Volian.Base.Library.vlnFont.ReportsFont, 8, 0, Color.BLACK)); + Dictionary levels = new Dictionary + { + { 1, "Internal Transitions" }, + { 2, "External From Transitions" }, + { 3, "External To Transitions" }, + { 4, "Outside From Transitions" }, + { 5, "Outside To Transitions" } + }; + Dictionary fonts = new Dictionary + { + // C2017-036 get best available proportional font for symbols that looks close to Arial + // Note that Microsoft no longer supplies Arial Unicode MS as of Word16 + { 1, pdf.GetFont(Volian.Base.Library.vlnFont.ReportsFont, 12, 0, Color.BLACK) }, + { 2, pdf.GetFont(Volian.Base.Library.vlnFont.ReportsFont, 10, 0, Color.BLACK) }, + { 3, pdf.GetFont(Volian.Base.Library.vlnFont.ReportsFont, 8, 0, Color.BLACK) }, + { 4, pdf.GetFont(Volian.Base.Library.vlnFont.ReportsFont, 8, 0, Color.BLACK) } + }; int lastLevel = transitionInfoList.Count > 0 ? transitionInfoList[0].Level : 0; //set level to first transition level #region buildtable int cols = 3; int paddingBottom = 6; if (folderInfo != null) doc.NewPage(); - PdfPTable t = BuildProcedurePDFTable(levels, fonts, cols, paddingBottom, lastLevel, doc); + PdfPTable t = BuildProcedurePDFTable(levels, fonts, cols, paddingBottom, lastLevel); #endregion //gather data if (transitionInfoList.Count == 0) { - Phrase h = new Phrase(); - h.Font = fonts[4]; - h.Add("This procedure contains no transitions"); - PdfPCell c = new PdfPCell(h); - c.Colspan = cols; - c.HorizontalAlignment = Element.ALIGN_LEFT; - c.PaddingBottom = paddingBottom; - t.AddCell(c); + Phrase h = new Phrase + { + Font = fonts[4] + }; + h.Add("This procedure contains no transitions"); + PdfPCell c = new PdfPCell(h) + { + Colspan = cols, + HorizontalAlignment = Element.ALIGN_LEFT, + PaddingBottom = paddingBottom + }; + t.AddCell(c); } else { @@ -308,37 +318,49 @@ namespace Volian.Print.Library doc.Add(t); doc.NewPage(); lastLevel = ti.Level; - t = BuildProcedurePDFTable(levels, fonts, cols, paddingBottom, lastLevel, doc); + t = BuildProcedurePDFTable(levels, fonts, cols, paddingBottom, lastLevel); } } - //add from path - Phrase h = new Phrase(); - h.Font = fonts[4]; - h.Add(StripProcInfo(ti.PathFrom, procedureInfo)); - PdfPCell c = new PdfPCell(h); - c.HorizontalAlignment = Element.ALIGN_LEFT; - c.PaddingBottom = paddingBottom; - if (lastLevel > 1 && (!tranTypes[ti.TranType].Contains("{Proc") && !tranTypes[ti.TranType].Contains("other procedure"))) c.BackgroundColor = new Color(System.Drawing.Color.LightCoral); + //add from path + Phrase h = new Phrase + { + Font = fonts[4] + }; + h.Add(StripProcInfo(ti.PathFrom, procedureInfo)); + PdfPCell c = new PdfPCell(h) + { + HorizontalAlignment = Element.ALIGN_LEFT, + PaddingBottom = paddingBottom + }; + if (lastLevel > 1 && (!tranTypes[ti.TranType].Contains("{Proc") && !tranTypes[ti.TranType].Contains("other procedure"))) c.BackgroundColor = new Color(System.Drawing.Color.LightCoral); t.AddCell(c); - //add from text - h = new Phrase(); - h.Font = fonts[4]; - ItemInfo myItemInfo = ti.MyContent.ContentItems[0]; + //add from text + h = new Phrase + { + Font = fonts[4] + }; + ItemInfo myItemInfo = ti.MyContent.ContentItems[0]; h.Add(GetTextPath(myItemInfo, 0)); - c = new PdfPCell(h); - c.HorizontalAlignment = Element.ALIGN_LEFT; - c.PaddingBottom = paddingBottom; - if (lastLevel > 1 && (!tranTypes[ti.TranType].Contains("{Proc") && !tranTypes[ti.TranType].Contains("other procedure"))) c.BackgroundColor = new Color(System.Drawing.Color.LightCoral); + c = new PdfPCell(h) + { + HorizontalAlignment = Element.ALIGN_LEFT, + PaddingBottom = paddingBottom + }; + if (lastLevel > 1 && (!tranTypes[ti.TranType].Contains("{Proc") && !tranTypes[ti.TranType].Contains("other procedure"))) c.BackgroundColor = new Color(System.Drawing.Color.LightCoral); t.AddCell(c); - //add to text - h = new Phrase(); - h.Font = fonts[4]; - myItemInfo = ti.MyItemToID; + //add to text + h = new Phrase + { + Font = fonts[4] + }; + myItemInfo = ti.MyItemToID; h.Add(GetTextPath(myItemInfo, ti.Level)); - c = new PdfPCell(h); - c.HorizontalAlignment = Element.ALIGN_LEFT; - c.PaddingBottom = paddingBottom; - if (lastLevel > 1 && (!tranTypes[ti.TranType].Contains("{Proc") && !tranTypes[ti.TranType].Contains("other procedure"))) c.BackgroundColor = new Color(System.Drawing.Color.LightCoral); + c = new PdfPCell(h) + { + HorizontalAlignment = Element.ALIGN_LEFT, + PaddingBottom = paddingBottom + }; + if (lastLevel > 1 && (!tranTypes[ti.TranType].Contains("{Proc") && !tranTypes[ti.TranType].Contains("other procedure"))) c.BackgroundColor = new Color(System.Drawing.Color.LightCoral); t.AddCell(c); } } @@ -357,16 +379,16 @@ namespace Volian.Print.Library { StringBuilder sb = new StringBuilder(); if (myItemInfo.IsProcedure) - return myItemInfo.MyProcedure.DisplayNumber + " " + myItemInfo.MyProcedure.DisplayText; + return $"{myItemInfo.MyProcedure.DisplayNumber} {myItemInfo.MyProcedure.DisplayText}"; if (myItemInfo.IsSection) { if (level > 1) - return myItemInfo.MyProcedure.DisplayNumber + " " + myItemInfo.MyProcedure.DisplayText + "\r\n " + myItemInfo.DisplayText; + return $"{myItemInfo.MyProcedure.DisplayNumber} {myItemInfo.MyProcedure.DisplayText}\r\n {myItemInfo.DisplayText}"; else return myItemInfo.DisplayText; } if (myItemInfo.IsHigh) - return myItemInfo.ActiveSection.DisplayText + "\r\n " + myItemInfo.DisplayText; + return $"{myItemInfo.ActiveSection.DisplayText}\r\n {myItemInfo.DisplayText}"; else { string tmp = ""; @@ -393,10 +415,6 @@ namespace Volian.Print.Library } return sb.ToString(); } - public void BuildTransitionReport(FolderInfo fi) - { - System.Windows.Forms.MessageBox.Show("folder"); - } private bool CreateResultsPDF(iTextSharp.text.Document document) { bool result = false; @@ -404,26 +422,20 @@ namespace Volian.Print.Library int i = 0; // just for safety, the while loop expects to find a file extension // so make sure it has one before going into the loop - if (!_FileName.ToUpper().EndsWith(".PDF")) - _FileName += ".pdf"; + if (!FileName.ToUpper().EndsWith(".PDF")) + FileName += ".pdf"; // Try to open a file for creating the PDF. while (result == false) { - string fileName = _FileName; - // Bug fix: B2013-086 - // the folder path part of _FileName contained a folder name with a period - // resulting is an invalid file location/file name. - // Changed the IndexOf call to the LastIndexOf - //int loc = fileName.IndexOf("."); + string fileName = FileName; int loc = fileName.LastIndexOf("."); if (loc > -1) { string fname = fileName.Substring(0, loc); - fileName = fname + suffix + ".pdf"; + fileName = $"{fname}{suffix}.pdf"; } else - fileName = fileName + suffix + ".pdf"; - // string fileName = _FileName.ToLower().Replace(".pdf", suffix + ".pdf"); + fileName = $"{fileName}{suffix}.pdf"; try { PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(fileName, FileMode.Create)); @@ -431,7 +443,7 @@ namespace Volian.Print.Library document.SetMargins(36, 36, 36, 36); document.Open(); cb = writer.DirectContent; - _FileName = fileName; + FileName = fileName; result = true; } catch (System.IO.IOException exIO) @@ -468,28 +480,25 @@ namespace Volian.Print.Library } System.Windows.Forms.MessageBox.Show(msg.ToString(), "Error during PDF creation for search:", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Exclamation); } - private PdfPCell BlankCell(int colSpan) - { - PdfPCell c = new PdfPCell(); - c.Colspan = colSpan; - c.Border = 0; - return c; - } private PdfPCell BuildCell(int colspan, string txt, Font f, iTextSharp.text.Color clr) { - Phrase h = new Phrase(); - h.Font = f; - h.Add(txt); - PdfPCell c = new PdfPCell(h); - c.HorizontalAlignment = iTextSharp.text.Element.ALIGN_RIGHT; - c.Colspan = colspan; - c.BackgroundColor = clr; - return c; + Phrase h = new Phrase + { + Font = f + }; + h.Add(txt); + PdfPCell c = new PdfPCell(h) + { + HorizontalAlignment = iTextSharp.text.Element.ALIGN_RIGHT, + Colspan = colspan, + BackgroundColor = clr + }; + return c; } } public class MyPageEvent : PdfPageEventHelper { - private PDFTransitionReport _rpt = null; + private readonly PDFTransitionReport _rpt = null; public MyPageEvent(PDFTransitionReport rpt) { _rpt = rpt; diff --git a/PROMS/Volian.Print.Library/PageCount.cs b/PROMS/Volian.Print.Library/PageCount.cs index 884d6f33..40ad3ff6 100644 --- a/PROMS/Volian.Print.Library/PageCount.cs +++ b/PROMS/Volian.Print.Library/PageCount.cs @@ -1,40 +1,23 @@ -using System; using System.Collections.Generic; -using System.Text; using iTextSharp.text; using iTextSharp.text.pdf; -using Volian.Svg.Library; namespace Volian.Print.Library { public class PageCount { - private bool _CanIncrement = true; - public bool CanIncrement - { - get { return _CanIncrement; } - set { _CanIncrement = value; } - } - private int Increment() + public bool CanIncrement { get; set; } = true; + private int Increment() { if (CanIncrement) Total++; CanIncrement = false; return Total; } - private int _Total; - public int Total - { - get { return _Total; } - set { _Total = value; } - } - private string _FinalPageMessage; - public string FinalPageMessage - { - get { return _FinalPageMessage; } - set { _FinalPageMessage = value; } - } - private PageCountTemplates _MyTemplates; // (for each page that has this key) + public int Total { get; set; } + + public string FinalPageMessage { get; set; } + private PageCountTemplates _MyTemplates; // (for each page that has this key) internal PageCountTemplates MyTemplates { get @@ -53,10 +36,10 @@ namespace Volian.Print.Library foreach (PageCountTemplate pct in MyTemplates) { cnt++; - string fstr = pct.Text.Replace("{OF}", _Total.ToString()); + string fstr = pct.Text.Replace("{OF}", Total.ToString()); if (pct.Text.Contains("{TOCPAGE}")) { - fstr = pct.Text.Replace("{TOCPAGE}", _Total.ToString()); + fstr = pct.Text.Replace("{TOCPAGE}", Total.ToString()); } if (fstr.Contains("{FINALPAGE}")) { @@ -140,45 +123,21 @@ namespace Volian.Print.Library public class PageCountTemplate { - private string _Text; - public string Text // "Page 1 of {OF}" - { - get { return _Text; } - set { _Text = value; } - } - private System.Drawing.Font _MyFont; - public System.Drawing.Font MyFont - { - get { return _MyFont; } - set { _MyFont = value; } - } - private int _Alignment; // iTextSharp Element. - public int Alignment - { - get { return _Alignment; } - set { _Alignment = value; } - } - private System.Drawing.Color _MyColor; - public System.Drawing.Color MyColor - { - get { return _MyColor; } - set { _MyColor = value; } - } - private PdfTemplate _MyTemplate; - public PdfTemplate MyTemplate - { - get { return _MyTemplate; } - set { _MyTemplate = value; } - } - public PageCountTemplate(PdfWriter pdfWriter, string text, System.Drawing.Font myFont, int alignment, System.Drawing.Color color) + public string Text // "Page 1 of {OF}" + { get; set; } + public System.Drawing.Font MyFont { get; set; } + public int Alignment { get; set; } + public System.Drawing.Color MyColor { get; set; } + public PdfTemplate MyTemplate { get; set; } + public PageCountTemplate(PdfWriter pdfWriter, string text, System.Drawing.Font myFont, int alignment, System.Drawing.Color color) { // Create Template can be called with a small, i.e. 1, width/height because when // it is actually drawn, the bounding box overrides the CreateTemplate values. - _MyTemplate = pdfWriter.DirectContent.CreateTemplate(1, 1); - _Text = text; - _MyFont = myFont; - _MyColor = color; - _Alignment = alignment; + MyTemplate = pdfWriter.DirectContent.CreateTemplate(1, 1); + Text = text; + MyFont = myFont; + MyColor = color; + Alignment = alignment; } } public class PageCountTemplates : List diff --git a/PROMS/Volian.Print.Library/Pagination.cs b/PROMS/Volian.Print.Library/Pagination.cs index 3460f87c..cd7995b9 100644 --- a/PROMS/Volian.Print.Library/Pagination.cs +++ b/PROMS/Volian.Print.Library/Pagination.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Text; using VEPROMS.CSLA.Library; using Volian.Base.Library; using iTextSharp.text.pdf; @@ -10,53 +9,29 @@ namespace Volian.Print.Library { public partial class vlnParagraph { - private string _PageBreakReason = null; - public string PageBreakReason - { - get { return _PageBreakReason; } - set { _PageBreakReason = value; } - } - private bool _CompressPartOfStep = false; - public bool CompressPartOfStep - { - get { return _CompressPartOfStep; } - set { _CompressPartOfStep = value; } - } - private bool _CompressFirstPartOfStep = false; - public bool CompressFirstPartOfStep - { - get { return _CompressFirstPartOfStep; } - set { _CompressFirstPartOfStep = value; } - } - private bool _BreakHighLevelStepWithSection = false; - public bool BreakHighLevelStepWithSection - { - get { return _BreakHighLevelStepWithSection; } - set { _BreakHighLevelStepWithSection = value; } - } - /// - /// This variable is used to match 16 bit pagination - /// - private bool _Match16BitPagination = false; - private bool _CompressFoldout = false; - public bool CompressFoldout - { - get { return _CompressFoldout; } - set { _CompressFoldout = value; } - } - /// - /// Dtermines if the current step is preceded by a Page Break - /// - /// - /// - /// - /// - /// 0 - No page break - /// 1 - Break on High Level Step - /// 2 - Break within a Step - /// 3 - Break on High Level Step (SevenLinesPerInch) - /// - private int Paginate(float yLocation, float yTopMargin, float yBottomMargin) + public string PageBreakReason { get; set; } = null; + public bool CompressPartOfStep { get; set; } = false; + public bool CompressFirstPartOfStep { get; set; } = false; + public bool BreakHighLevelStepWithSection { get; set; } = false; + /// + /// This variable is used to match 16 bit pagination + /// + private readonly bool _Match16BitPagination = false; + + public bool CompressFoldout { get; set; } = false; + /// + /// Dtermines if the current step is preceded by a Page Break + /// + /// + /// + /// + /// + /// 0 - No page break + /// 1 - Break on High Level Step + /// 2 - Break within a Step + /// 3 - Break on High Level Step (SevenLinesPerInch) + /// + private int Paginate(float yLocation, float yTopMargin, float yBottomMargin) { // Check if paginate on a separate section, if within a section. Top level section pagination happens in PromsPrinter float yPageSize = yTopMargin - yBottomMargin; @@ -85,15 +60,15 @@ namespace Volian.Print.Library if (MyPromsPrinter.SupInfoPrintType == E_SupInfoPrintType.SupInfoPdfPrint) { int retval = 0; - SectionInfo supInfoSect = MyItemInfo.ActiveSection as SectionInfo; // C2018-003 fixed use of getting the active section - if (supInfoSect != null && supInfoSect.StepSectPageBreaksForSupInfo != null && supInfoSect.StepSectPageBreaksForSupInfo.Contains(MyItemInfo.ItemID)) - { - MyPromsPrinter.SupInfoPdfPageCount++; - retval = 1; - } - // Printing the supplemental information pages to a pdf: add an item to the dictionary that says what page in the supinfo pdf - // this item can be found on. - if (MyItemInfo.IsSupInfoPart) + // C2018-003 fixed use of getting the active section + if (MyItemInfo.ActiveSection is SectionInfo supInfoSect && supInfoSect.StepSectPageBreaksForSupInfo != null && supInfoSect.StepSectPageBreaksForSupInfo.Contains(MyItemInfo.ItemID)) + { + MyPromsPrinter.SupInfoPdfPageCount++; + retval = 1; + } + // Printing the supplemental information pages to a pdf: add an item to the dictionary that says what page in the supinfo pdf + // this item can be found on. + if (MyItemInfo.IsSupInfoPart) { MyPromsPrinter.SupInfoPdfPage.Add(MyItemInfo.ItemID, MyPromsPrinter.SupInfoPdfPageCount); } @@ -141,37 +116,36 @@ namespace Volian.Print.Library if (MyItemInfo.MyParent.IsHigh && MyItemInfo.IsNote && (MyItemInfo.MyParent.Cautions == null || MyItemInfo.MyParent.Cautions.Count == 0) && MyItemInfo.MyPrevious == null) return 1; // if this is a substep that has a preferredpage break, and it has caution/note that is where the page break had to go if (MyItemInfo.IsSubStep && ChildrenAbove != null && ChildrenAbove.Count > 0) return 0; - // B2017-228: The following flags a break within the step. Before returning a '2' (flags break within step), clear it out of the - // ParaBreaks. Without the 'RemoveAt', a page break will occur after this step also. - string reason = "Unknown"; - if (MyPageHelper.ParaBreaks != null && MyPageHelper.ParaBreaks.Count > 0 && this == MyPageHelper.ParaBreaks[0]) + if (MyPageHelper.ParaBreaks != null && MyPageHelper.ParaBreaks.Count > 0 && this == MyPageHelper.ParaBreaks[0]) { MyPageHelper.ParaBreaks.RemoveAt(0); - reason = AddReason("Partial Step - Case 1"); - ShowPageBreak(1, reason, "Yes", YSize, yPageSize, yWithinMargins, ManualPageBreak); + // B2017-228: The following flags a break within the step. Before returning a '2' (flags break within step), clear it out of the + // ParaBreaks. Without the 'RemoveAt', a page break will occur after this step also. + string reason = AddReason("Partial Step - Case 1"); + ShowPageBreak(1, reason, "Yes", YSize, yPageSize, yWithinMargins, ManualPageBreak); } return 2; } } } - // if the EndForSingle format flag is set to false, then we do not print an End message if the section - // is a single column section. - //bool _skipEndMessage = MyPageHelper.MySection.SectionConfig.Section_ColumnMode == SectionConfig.SectionColumnMode.One && !MyItemInfo.ActiveFormat.MyStepSectionLayoutData.EndForSingle; - SectionInfo si = MyItemInfo.ActiveSection as SectionInfo; // C2018-003 fixed use of getting the active section - bool _skipEndMessage = si != null && si.SectionConfig.Section_ColumnMode == SectionConfig.SectionColumnMode.One && !MyItemInfo.ActiveFormat.MyStepSectionLayoutData.EndForSingle; + // if the EndForSingle format flag is set to false, then we do not print an End message if the section + // is a single column section. + //bool _skipEndMessage = MyPageHelper.MySection.SectionConfig.Section_ColumnMode == SectionConfig.SectionColumnMode.One && !MyItemInfo.ActiveFormat.MyStepSectionLayoutData.EndForSingle; + // C2018-003 fixed use of getting the active section + bool _skipEndMessage = MyItemInfo.ActiveSection is SectionInfo si && si.SectionConfig.Section_ColumnMode == SectionConfig.SectionColumnMode.One && !MyItemInfo.ActiveFormat.MyStepSectionLayoutData.EndForSingle; - // TODO: This does not account for a long step as the last step that would exceed more than one page and - // that has an end message that needs to be accounted for in determining pagination. To do that the last - // child should be the only paragraph that accounts for the End message. - // - // If last step & there should be an end message, pagination tests need to account for the 3 lines the end - // message uses. The 3 is for a line above, the end message line & the line below (in case there is a border/box line). + // TODO: This does not account for a long step as the last step that would exceed more than one page and + // that has an end message that needs to be accounted for in determining pagination. To do that the last + // child should be the only paragraph that accounts for the End message. + // + // If last step & there should be an end message, pagination tests need to account for the 3 lines the end + // message uses. The 3 is for a line above, the end message line & the line below (in case there is a border/box line). - // The 3 was changed to 2 for the end line & the line below. The blank line below the step gives the blank - // line above the end message, thus 2 not 3. This change was made on July 20, 2011 by RHM & KBR. The - // procedure in questions was VEWCNEMG\EMGAPP.PRC, ES-01, Step 8. - //float yEndMsg = !_skipEndMessage && !MyItemInfo.IsSection && MyItemInfo.MyHLS != null && MyItemInfo.MyHLS.NextItem == null && (MyItemInfo.MyDocStyle.End.Message ?? "") != "" ? 2 * SixLinesPerInch : 0; - float yEndMsg = (!_skipEndMessage && !MyItemInfo.IsSection && MyItemInfo.MyHLS != null && MyItemInfo.MyHLS.NextItem == null)? GetEndMessageHeight(MyItemInfo.MyDocStyle) : 0; // B2018-068 account for mult-line End Messages + // The 3 was changed to 2 for the end line & the line below. The blank line below the step gives the blank + // line above the end message, thus 2 not 3. This change was made on July 20, 2011 by RHM & KBR. The + // procedure in questions was VEWCNEMG\EMGAPP.PRC, ES-01, Step 8. + //float yEndMsg = !_skipEndMessage && !MyItemInfo.IsSection && MyItemInfo.MyHLS != null && MyItemInfo.MyHLS.NextItem == null && (MyItemInfo.MyDocStyle.End.Message ?? "") != "" ? 2 * SixLinesPerInch : 0; + float yEndMsg = (!_skipEndMessage && !MyItemInfo.IsSection && MyItemInfo.MyHLS != null && MyItemInfo.MyHLS.NextItem == null)? GetEndMessageHeight() : 0; // B2018-068 account for mult-line End Messages // also consider if there is a phone list at the bottom of the page, add the amount of space the phone // list requires onto yEndMsg to make it easier to figure out pagination (include an extra line for the @@ -196,9 +170,9 @@ namespace Volian.Print.Library // location of a pagebreak. ParaBreaks contains the paragraphs that break within a step. if (MyPageHelper.ParaBreaks.Count > 0) { - string reason = "Unknown"; - // if on current step and it is also the substep that will cause a pagebreak, i.e. the top substep in pagebreaks[[0]: - if (this == MyPageHelper.ParaBreaks[0]) + string reason; + // if on current step and it is also the substep that will cause a pagebreak, i.e. the top substep in pagebreaks[[0]: + if (this == MyPageHelper.ParaBreaks[0]) { MyPageHelper.ParaBreaks.RemoveAt(0); reason = AddReason("Partial Step - Case 1"); @@ -230,14 +204,7 @@ namespace Volian.Print.Library // B2018-065 Calvert's continue message was not including the substep number in AOP-1A Attachment 1, added AERandRNO check else if (!MyPageHelper.ParaBreaks[0].PageBreakOnStep && this.YTopMost >= MyPageHelper.ParaBreaks[0].YTopMost && AERandRNO(this.MyItemInfo, MyPageHelper.ParaBreaks[0].MyItemInfo)) { - //vlnParagraph removed = MyPageHelper.ParaBreaks[0];// 2018-081 Remember where the page break was going to be MyPageHelper.ParaBreaks.RemoveAt(0); - //if (MyParent == removed && MyItemInfo.IsRNOPart && MyParent.MyItemInfo.IsHigh)// B2018-081 If The High Level Step was going to break from the High Level RNO - //{ - // reason = AddReason("Partial Step - Case 4B"); - // ShowPageBreak(1, reason, "Yes", YSize, yPageSize, yWithinMargins, ManualPageBreak); - // return 0; - //} reason = AddReason("Partial Step - Case 4"); ShowPageBreak(1, reason, "Yes", YSize, yPageSize, yWithinMargins, ManualPageBreak); return 2; // break on this item within a step @@ -276,9 +243,8 @@ namespace Volian.Print.Library // flag SectionPageBreak is set to true to flag that a pagebreak should not be done // on that first step. StepConfig sc = firstChild.MyItemInfo.MyConfig as StepConfig; - ManualPageBreak = MyPageHelper.OriginalPageBreak ? (sc == null ? false : sc.Step_ManualPagebreak) : - sc == null ? false : - (MyPageHelper.MyPromsPrinter.RemoveManualPageBreaks == null)? sc.Step_NewManualPagebreak : false; + ManualPageBreak = MyPageHelper.OriginalPageBreak ? (sc != null && sc.Step_ManualPagebreak) : + sc != null && ((MyPageHelper.MyPromsPrinter.RemoveManualPageBreaks == null) && sc.Step_NewManualPagebreak); // C2021-010: Remove trailing returns/spaces & manual page breaks & allow save. if (sc != null && sc.Step_NewManualPagebreak && MyPageHelper.MyPromsPrinter.RemoveManualPageBreaks != null && !MyPageHelper.MyPromsPrinter.RemoveManualPageBreaks.Contains(firstChild.MyItemInfo.ItemID)) MyPageHelper.MyPromsPrinter.RemoveManualPageBreaks.Add(firstChild.MyItemInfo.ItemID); @@ -290,10 +256,7 @@ namespace Volian.Print.Library } // can the title and the first step fit? // add the first child's size + (the section title's size) - //if (ySizeIncludingFirst > (yLocation - yBottomMargin - SixLinesPerInch)) return 1; - //if (ySizeIncludingFirst > (yLocation - yBottomMargin) && ySizeIncludingFirst < yPageSize) vlnParagraph firstStepChild = firstChild; - //while (firstStepChild.MyItemInfo.IsSection && firstStepChild.ChildrenBelow.Count > 0) firstStepChild = firstStepChild.ChildrenBelow[0]; if (firstStepChild.MyItemInfo.IsNumbered) while (firstStepChild.ChildrenBelow.Count > 0 && (firstStepChild.MyItemInfo.IsSection || firstStepChild.MyItemInfo.IsHigh)) { @@ -308,13 +271,12 @@ namespace Volian.Print.Library firstStepChild = firstStepChild.MyParent.ChildrenBelow[firstStepChild.MyParent.ChildrenBelow.Count - 1]; float ySizeIncludingFirstStep = firstStepChild.YSize + (firstStepChild.YTopMost - YTopMost); float ySizeBtmCtnMess = GetBottomContinueMessageSize(MyItemInfo.MyDocStyle); - float ySizeBtmEndMess = GetBottomEndMessageSize(MyItemInfo.MyDocStyle); + float ySizeBtmEndMess = GetBottomEndMessageSize(); bool firstSubstepExceedsSpaceAvailable = ySizeIncludingFirstStep > (yWithinMargins - ySizeBtmCtnMess -ySizeBtmEndMess); if (KeepStepsOnPage && firstSubstepExceedsSpaceAvailable && !isFirstChild) KeepStepsOnPage = false; if (ySizeIncludingFirst == YSize) KeepStepsOnPage = false; - //float ySectionEndMsg = !_skipEndMessage && MyItemInfo.IsSection && MyItemInfo.Steps != null && MyItemInfo.Steps.Count == 1 && (MyItemInfo.MyDocStyle.End.Message ?? "") != "" ? 2 * SixLinesPerInch : 0; - float ySectionEndMsg = (!_skipEndMessage && MyItemInfo.IsSection && MyItemInfo.Steps != null && MyItemInfo.Steps.Count == 1) ? GetEndMessageHeight(MyItemInfo.MyDocStyle) : 0; // B2018-068 account for mult-line End Messages + float ySectionEndMsg = (!_skipEndMessage && MyItemInfo.IsSection && MyItemInfo.Steps != null && MyItemInfo.Steps.Count == 1) ? GetEndMessageHeight() : 0; // B2018-068 account for mult-line End Messages if (MyPageHelper.NotesToFootNotes != null && MyPageHelper.NotesToFootNotes.Count > 0) { float vpHeight = SixLinesPerInch; @@ -401,11 +363,10 @@ namespace Volian.Print.Library return 1; } - //MyPageHelper.HLSText = MyItemInfo.DisplayText; // save the High Level Step Text //Console.WriteLine("{0} Paginate", MyPageHelper.HLSText); StepConfig sc1 = MyItemInfo.MyConfig as StepConfig; - ManualPageBreak = MyPageHelper.OriginalPageBreak ? (sc1 == null ? false : sc1.Step_ManualPagebreak) : - sc1 == null ? false : (MyPageHelper.MyPromsPrinter.RemoveManualPageBreaks == null) ? sc1.Step_NewManualPagebreak : false; + ManualPageBreak = MyPageHelper.OriginalPageBreak ? (sc1 != null && sc1.Step_ManualPagebreak) : + sc1 != null && ((MyPageHelper.MyPromsPrinter.RemoveManualPageBreaks == null) && sc1.Step_NewManualPagebreak); // C2021-010: Remove trailing returns/spaces & manual page breaks & allow save. if (sc1 != null && sc1.Step_NewManualPagebreak && MyPageHelper.MyPromsPrinter.RemoveManualPageBreaks != null && !MyPageHelper.MyPromsPrinter.RemoveManualPageBreaks.Contains(MyItemInfo.ItemID)) MyPageHelper.MyPromsPrinter.RemoveManualPageBreaks.Add(MyItemInfo.ItemID); @@ -423,7 +384,6 @@ namespace Volian.Print.Library string firstStep = "No"; if (MyItemInfo.IsHigh && MyItemInfo.MyPrevious == null) firstStep = "Yes"; - //if (!ManualPageBreak && mySize + yEndMsg <= yWithinMargins) // Don't Paginate if there is enough room, will fit on page // Pagination Fix - Break1LineShort1 float yExtra = (yWithinMargins == yPageSize ? 0 : SixLinesPerInch - MyItemInfo.MyDocStyle.Layout.FooterLength) ?? 0; // Adjust yExtra and mySize for Component List items. @@ -452,12 +412,11 @@ namespace Volian.Print.Library // B2017-254 Fixed Pagination Logic when checking to see if the current item is the last high level step if (MyItemInfo.IsHigh && mySize >= (2 * SixLinesPerInch) && MyItemInfo.MyDocStyle.Layout.FooterLength > 0 && (MyItemInfo.MyDocStyle.End.Message == null || MyItemInfo.MyDocStyle.End.Message == "") && MyItemInfo.NextItem == null && (MyItemInfo.Steps == null || MyItemInfo.Steps.Count == 0) && (MyItemInfo.RNOs == null || MyItemInfo.RNOs.Count == 0)) mySize -= SixLinesPerInch; - //// Account for extra lines in the end message (flag < 0) - float adjMsgY = 0; - if (MyItemInfo.IsHigh && MyItemInfo.NextItem == null && MyItemInfo.MyDocStyle.End.Flag < 0) // Adjust this many lines down the page. + if (MyItemInfo.IsHigh && MyItemInfo.NextItem == null && MyItemInfo.MyDocStyle.End.Flag < 0) // Adjust this many lines down the page. { - adjMsgY = (float)-MyItemInfo.MyDocStyle.End.Flag * SixLinesPerInch; - if (yEndMsg != 0) yEndMsg += adjMsgY; + //// Account for extra lines in the end message (flag < 0) + float adjMsgY = (float)-MyItemInfo.MyDocStyle.End.Flag * SixLinesPerInch; + if (yEndMsg != 0) yEndMsg += adjMsgY; } // F2023-015 check if on the first step of a sub-section that starts on its own page (separate pagination) // Beaver Valley as two sub-sections that are printed continuously followed by a third sub-section printed separate. @@ -489,7 +448,6 @@ namespace Volian.Print.Library ShowPageBreak(-1, "HLS will fit on page", firstStep, YSize, yPageSize, yWithinMargins,ManualPageBreak); return 0; } - // !MyItemInfo.IsHigh - if (MyItemInfo.IsRNOPart && MyParent.XOffset < XOffset) return 0; // Don't paginate on an RNO to the right // YSize includes a blank line after the step which we don't want to include in the page break test, thus the // YSize - SixLinesPerInch: @@ -504,8 +462,6 @@ namespace Volian.Print.Library if (MyItemInfo.IsStep && MyItemInfo.MyHLS.FormatStepData.StepLayoutData.STBoxindex != null && MyItemInfo.MyHLS.FormatStepData.StepLayoutData.STBoxindex >= 0 && (MyItemInfo.RNOs == null || MyItemInfo.RNOs.Count == 0)) mySize += (2 * SixLinesPerInch); - //if (firstStep == "No") - // ResetDocStyleAndValues(ref yTopMargin, ref yBottomMargin); if (MyPageHelper.DidFirstPageDocStyle && MyItemInfo.ActiveSection != null && (MyItemInfo.ActiveSection.MyDocStyle.StructureStyle.Where & E_DocStyleUse.UseOnAllButFirstPage) > 0)// C2018-003 fixed use of getting the active section yPageSizeNextPage = GetYPageSizeUseOnAllButFirstPage(); @@ -532,33 +488,28 @@ namespace Volian.Print.Library // Keep figure (the only figure, i.e. count==1) with its parent. if (ChildrenBelow.Count == 1 && ChildrenBelow[0].MyItemInfo.IsFigure) KeepStepsOnPage = false; - float sectionSpace = 0; - if (doSectionTitleContinued) - { - if (SectionShowTitles) - { - vlnParagraph paraSect = MyParent; - while (!paraSect.MyItemInfo.IsSection) paraSect = paraSect.MyParent; - if (paraSect.ContinueHeight > 24) - sectionSpace = paraSect.ContinueHeight; - else - sectionSpace = 2 * SixLinesPerInch; - // sectionSpace = 3 * SixLinesPerInch;// this should actuall use the physical size of the continue messsage. - // Fixing this caused problems with pagination ex Calvert Unit 2 IO-1l section 6.1.B step 2 - //if (MyItemInfo.ActiveSection.DisplayText.Length < 40) sectionSpace = SixLinesPerInch; - yPageSizeNextPage -= sectionSpace; - yExtra -= sectionSpace; - //yExtra2 -= sectionSpace; // This was removed for Calvert STP O-73H-2 Section 6.3.O.4 and 6.3.R.3 - } - } - // Added for section that was breaking from steps this code was removed to fix B2020-112 - //if (MyItemInfo.ActiveFormat.PlantFormat.FormatData.PrintData.SpecialCaseCalvert && yPageSizeNextPage < yWithinMargins + 3 * 72 && MyItemInfo.MyPrevious == null) - // KeepStepsOnPage = true; - float mySize7LPI = mySize; // +SixLinesPerInch; + if (doSectionTitleContinued) + { + if (SectionShowTitles) + { + vlnParagraph paraSect = MyParent; + while (!paraSect.MyItemInfo.IsSection) paraSect = paraSect.MyParent; + float sectionSpace; + if (paraSect.ContinueHeight > 24) + sectionSpace = paraSect.ContinueHeight; + else + sectionSpace = 2 * SixLinesPerInch; + // this should actuall use the physical size of the continue messsage. + // Fixing this caused problems with pagination ex Calvert Unit 2 IO-1l section 6.1.B step 2 + yPageSizeNextPage -= sectionSpace; + yExtra -= sectionSpace; + } + } + float mySize7LPI = mySize; if (_Match16BitPagination) mySize7LPI += SixLinesPerInch; float tableSpaceAvailable = TableSpaceAvailable;// RHM20150525 - Table Scrunch float ySizeBtmCtnMess1 = GetBottomContinueMessageSize(MyItemInfo.MyDocStyle); - float ySizeBtmEndMess1 = GetBottomEndMessageSize(MyItemInfo.MyDocStyle); + float ySizeBtmEndMess1 = GetBottomEndMessageSize(); // B2017-154 Don't leave an orphan on the next page if the high level step and first sub-step will fit on the current page if (MyItemInfo.ActiveFormat.MyStepSectionLayoutData.NoOrphans1 && KeepStepsOnPage && ChildrenBelow.Count == 2)// Handle Orphans when there are two sub-steps and only one will fit. { @@ -604,7 +555,6 @@ namespace Volian.Print.Library // ySize7LPI includes a blank line after the step which we don't want to include in the page break test. else if (!KeepStepsOnPage && MyItemInfo.ActiveFormat.MyStepSectionLayoutData.CompressSteps - //&& (mySize7LPI - SixLinesPerInch + yEndMsg - tableSpaceAvailable) < (yPageSizeNextPage * SixLinesPerInch / _SevenLinesPerInch))// RHM20150525 - Table Scrunch // if this is the first step, then the step has to fit in the space that remains on the page // otherwise it needs to fit on a blank page // This was originally (10/12/2015) added for Farley Shared AOP 79 but was found to be unnecessary @@ -631,24 +581,9 @@ namespace Volian.Print.Library float myFirstPieceSize = GetFirstPieceSize(); //Case 0 if (_Match16BitPagination) myFirstPieceSize += 2 * SixLinesPerInch; // TODO: Put this line back to case 0, i.e. previous line. This fixes a 16-bit vs 32-bit pagination diff in EO30 Step 20. - //float myFirstPieceSize = GetFirstPieceSize() + 2 * SixLinesPerInch; //Case 10 - this is to match 16bit + //Case 10 - this is to match 16bit //is the amount of space left (yWithinMargins) is greater than 1/2 of the current page (yPageSize / 2): // VCS EOP-4.3 Step 15 - // ***** Adjust yWithinMargins for the bottom continue message - //DocStyle docstyle = MyItemInfo.MyDocStyle; - //string myBottomMsg = docstyle.Continue.Bottom.Message; - //float myBottomMsgSpace = ((myBottomMsg ?? "") != "") ? 2 * SixLinesPerInch : 0; - //switch (docstyle.Continue.Bottom.Location) - //{ - // case E_ContBottomLoc.BottomOfPage: // place continue message at bottom of page - // // The following format flag was added for FNP, without the flag (which stops the reset of BottomMsgSpace) - // // a number of FNP procedures had overwritten steps/bottom continue message. An example can be - // // found in FNP = SAMGS;FNP-1-SACRG-2, step 1. - // if (!docstyle.Continue.Bottom.NoOverrideSpace) - // myBottomMsgSpace = 0; - // break; - //} - //float yWithinMarginsCM = yWithinMargins - myBottomMsgSpace; //// **** Adjust yWithinMargins for the bottom continue message // B2018-080 Don't break if HLS and High Level RNO each have one line of text and there are substeps (keep single line HSL and High Level RNO with their substeps) AEP AOP Unit 1 016-004 steps 36 & 74 // B2018-081 The previous fix caused a different issue @@ -668,8 +603,6 @@ namespace Volian.Print.Library ySpaceOnFirstPage = yWithinMargins; // Accounts for Section Title Line //ShowPageBreak(8, CheckForCompression("First HLS has to split on current page"), firstStep, YSize, yPageSizeNextPage, yWithinMargins, ManualPageBreak); //} - //else - // ShowPageBreak(6, CheckForCompression("HLS will have to split on current page"), "Special", YSize, yPageSizeNextPage, yWithinMargins, ManualPageBreak); //BuildPageBreakList(yWithinMargins + SixLinesPerInch, yPageSizeNextPage + yExtra2, KeepStepsOnPage); // Case 5 - Determine items where page break(s) occur // B2020-027: adjust for lines that may print on first page of section only, added MyPageHelper.PrintedSectionPage // B2020-108: The bug itself was related to keeping a table with its parent. However compression for some pages was @@ -695,7 +628,6 @@ namespace Volian.Print.Library // o888o if (firstStep == "Yes") { - //ySpaceOnFirstPage = yWithinMargins; // Accounts for Section Title Line ShowPageBreak(8, CheckForFirstCompression("First HLS has to split on current page"), firstStep, YSize, yPageSizeNextPage, yWithinMargins, ManualPageBreak); } else @@ -754,6 +686,7 @@ namespace Volian.Print.Library ShowPageBreak(3, CheckForFirstCompression("HLS will have to split on new page"), "Yes", YSize, yPageSizeNextPage, yWithinMargins, ManualPageBreak); return 1; // Paginate on High Level Steps } + //For Debugging: //if (yWithinMargins > yPageSize / 2) //{ // Console.WriteLine("'PageBreak',4,'No','Not Half way down the page',{0},{1},{2}, {3}, {4},'{5}'", MyItemInfo.ItemID, YSize, yPageSize, yWithinMargins, (int)(100 * yWithinMargins / yPageSize), MyItemInfo.ShortPath); @@ -780,7 +713,7 @@ namespace Volian.Print.Library return hasAER && hasRNO; } // B2018-058 the the end message height accounting for multi-line end messages - private float GetEndMessageHeight(DocStyle docstyle) + private float GetEndMessageHeight() { float EndMsgHeight = 0; string endmsg = MyItemInfo.MyDocStyle.End.Message ?? ""; @@ -791,12 +724,12 @@ namespace Volian.Print.Library } return EndMsgHeight; } - private float GetBottomEndMessageSize(DocStyle docstyle) + private float GetBottomEndMessageSize() { float myBottomMsgSpace = 0; if (MyItemInfo.IsHigh && MyItemInfo.NextItem == null && MyItemInfo.MyDocStyle.End.Flag < 0) // Adjust this many lines down the page. { - docstyle = MyItemInfo.MyDocStyle; + DocStyle docstyle = MyItemInfo.MyDocStyle; string myBottomMsg = docstyle.End.Message; myBottomMsgSpace = ((myBottomMsg ?? "") != "") ? 2 * SixLinesPerInch : 0; if (myBottomMsg != null && docstyle.End.Flag < 0) myBottomMsgSpace += (-(float)docstyle.End.Flag * SixLinesPerInch); @@ -806,20 +739,20 @@ namespace Volian.Print.Library private string CheckForFirstCompression(string reason) { if (MyPageHelper.ParaBreaks.Count > 0 && MyPageHelper.ParaBreaks[0].CompressFirstPartOfStep) - return reason + " - 7 LPI"; + return $"{reason} - 7 LPI"; return reason; } private string CheckForCompression(string reason) { if (CompressPartOfStep) - return reason + " - 7 LPI"; + return $"{reason} - 7 LPI"; return reason; } private string AddReason(string prefix) { string retval = prefix; if (PageBreakReason != null) - retval += " - " + PageBreakReason; + retval += $" - {PageBreakReason}"; return retval; } private bool SectionShowTitles @@ -864,8 +797,6 @@ namespace Volian.Print.Library DebugText.WriteLine("*****PaginateError"); yPageStart = yTopMargin + YVeryTop; yLocation = yPageStart - YOffset; - //MyItemInfo.ItemID, YSize, yPageSize, yLocation - //_MyLog.ErrorFormat("<<< ERROR >>> Forced Pagination - ItemID = {0}\r\nLocation = '{1}'", MyItemInfo.ItemID, MyItemInfo.ShortPath); _MyLog.ErrorFormat("<<< ERROR >>> Forced Pagination\r\n==>'Forced Pagination',{0},'{1}','{2}'" , MyItemInfo.ItemID, MyItemInfo.MyDocVersion.MyFolder.Name, MyItemInfo.ShortPath); if (DebugPagination.IsOpen) DebugPagination.WriteLine("=====>,'Yes','Forced Pagination',{0},{1},,{3},'{4}'", MyItemInfo.ItemID, YSize, 0, yLocation, MyItemInfo.ShortPath); @@ -927,11 +858,8 @@ namespace Volian.Print.Library return _AlternateBreaks; } } - private void AddAlternateBreak(vlnParagraph vp) - { - AlternateBreaks.Add(vp); - } - private bool CheckAlternates(vlnParagraph vpBrk) + private void AddAlternateBreak(vlnParagraph vp) => AlternateBreaks.Add(vp); + private bool CheckAlternates(vlnParagraph vpBrk) { if (_AlternateBreaks == null) return false; foreach(vlnParagraph vp in AlternateBreaks) @@ -957,7 +885,7 @@ namespace Volian.Print.Library public float yPageSizeForPagination = -1; private void BuildPageBreakList(float ySpaceOnCurPage, float yPageSize, bool KeepStepsOnPage, float yEndMsg, bool doSectionTitleContinued, bool onNewPage) { - float topContinueHeight = 2 * SixLinesPerInch; + float topContinueHeight; //Defaults to: 2 * SixLinesPerInch; int profileDepth = ProfileTimer.Push(">>>> BuildPageBreakList"); // if this paragraph is flagged to pagebreakonstep (i.e. these are used by background documents // to get each hls/caution/note to be on its own page), then any of the children above should @@ -997,9 +925,8 @@ namespace Volian.Print.Library // the following logic was added to fix Pagination for VCS BDMG1 Step 4 if (ChildrenRight.Count > 0 && ChildrenRight[0].YOffset == YOffset) { - float myFirstPieceRNOSize = 0; - myFirstPieceRNOSize = ChildrenRight[0].GetFirstPieceSize(); - if(myFirstPieceRNOSize < ySpaceOnCurPage) + float myFirstPieceRNOSize = ChildrenRight[0].GetFirstPieceSize(); + if (myFirstPieceRNOSize < ySpaceOnCurPage) if (ChildrenBelow.Count > 0) { float myFirstPieceAERSize = ChildrenBelow[0].GetFirstPieceSize() + ChildrenBelow[0].YOffset - YOffset; @@ -1008,7 +935,6 @@ namespace Volian.Print.Library } } if (myFirstPieceSize < ySpaceOnCurPage) yLowerLimit = Math.Max(myFirstPieceSize + yStart, yLowerLimit); - //while ((YSize - yTop) >= ySpaceOnCurPage) // Pagination Fix Break1LineShort3b DocStyle docstyle = MyItemInfo.MyDocStyle; float myBottomMsgSpace = GetBottomContinueMessageSize(docstyle); @@ -1052,21 +978,12 @@ namespace Volian.Print.Library // The following code determines space required by the Checklist header (Wolf Creek) if a break occurs // Their 2 HLS that define the checklists have 'UseSmartTemplate'. float accountForSmartTemplateHeader = 0; - //if (MyItemInfo.InList(878)) Console.WriteLine("Here"); if (MyItemInfo.FormatStepData.UseSmartTemplate) { if (((MyItemInfo.MyDocStyle.End.Message ?? "") == "") || MyItemInfo.MyHLS.NextItem != null) ySpaceOnCurPage += SixLinesPerInch; accountForSmartTemplateHeader = Height - (2 * SixLinesPerInch); } - // This was added so that if a page break was immediately necessary the code would use the current step. - // However, a better solution was found and put in Paginate() - //if (YSize == Height + SixLinesPerInch && YSize + yEndMsg >= ySpaceOnCurPage) - //{ - // _MyLog.WarnFormat("Would have been unable to break {0},{1}",MyItemInfo.ItemID, MyItemInfo.ShortPath); - // MyPageHelper.ParaBreaks.Add(this); - // return; - //} // ooooo ooo . oooooooooo. oooo // `888b. `8' .o8 `888' `Y8b `888 // 8 `88b. 8 .ooooo. oooo ooo .o888oo 888 888 oooo d8b .ooooo. .oooo. 888 oooo @@ -1170,7 +1087,8 @@ namespace Volian.Print.Library myBottomMsgSpace, MyItemInfo.ActiveFormat.PlantFormat.FormatData.StepDataList[40].ContinueOnly, yTop); if (paraBreak2 != null && paraBreak != paraBreak2) { - yLoc = ySpaceOnCurPage - (paraBreak2.YOffset - (YTopMost + yTop - paraBreak2.Height)); + //For Debugging: + //yLoc = ySpaceOnCurPage - (paraBreak2.YOffset - (YTopMost + yTop - paraBreak2.Height)); if (paraBreak.YOffset == paraBreak2.YOffset + paraBreak2.Height) { //_MyLog.WarnFormat("Fix Break when no blank line {0},{1},{2}", paraBreak2.MyItemInfo.ShortPath, paraBreak2.MyItemInfo.ItemID,yLoc); @@ -1211,10 +1129,7 @@ namespace Volian.Print.Library } if (MyItemInfo.ActiveFormat.PlantFormat.FormatData.PrintData.SpecialCaseCalvertAlarm) // only do the following for Calvert Alarms { - //if (lastBreak != null && lastBreak.MyItemInfo.InList(42656,42923)) Console.WriteLine("here"); // Or Step whose parent fits on a page should break at the parent step - //if (MyItemInfo.InList(119826)) Console.WriteLine("here"); - //if (paraBreak.MyItemInfo.InList(40339)) float ySpaceOnNextPage = yPageSize - (myTopMsgSpace + SixLinesPerInch) - myBottomMsgSpace; if (paraBreak.MyItemInfo.IsOr && paraBreak.MyParent.YSize < ySpaceOnNextPage) { @@ -1307,7 +1222,8 @@ namespace Volian.Print.Library if (firstLevel.MyParent.ChildrenBelow != null && firstLevel.MyParent.ChildrenBelow.Count > 0 && firstLevel.MyParent.ChildrenBelow[0] != firstLevel && firstLevel.YSize < yPageSize - (myTopMsgSpace + SixLinesPerInch)) { - vlnParagraph firstLevel1 = firstLevel; + //For Debugging: + //vlnParagraph firstLevel1 = firstLevel; if (firstLevel.ChildrenAbove != null && firstLevel.ChildrenAbove.Count > 0) // If the aerParent has caution or note firstLevel = firstLevel.ChildrenAbove[0];//, break on the caution or note. if (firstLevel != lastBreak && paraBreak != firstLevel) @@ -1320,14 +1236,10 @@ namespace Volian.Print.Library } // If the break is going to happen on a table, and the tables parent would fit on a page with the table // and the text in the parent includes the word table, then break on the parent - //if (lastBreak != paraBreak.MyParent && paraBreak.MyItemInfo.IsTable && paraBreak.YSize < ySpaceOnCurPage && paraBreak.MyParent.MyItemInfo.DisplayText.ToUpper().Contains("TABLE")) - // paraBreak = paraBreak.MyParent; //paraBreak.ShowPageBreak(999, paraBreak.MyItemInfo.ShortPath, "Yes",paraBreak.YTop, paraBreak.YSize, paraBreak.Height, false); //_MyLog.InfoFormat("Place to break\r\n==>'Place to Break',{0},'{1}','{2}'" //, paraBreak.MyItemInfo.ItemID, paraBreak.MyItemInfo.MyDocVersion.MyFolder.Name, paraBreak.MyItemInfo.ShortPath); // yTopNew is y Location of this page break. YTopMost is top of HLS, including any Cautions/Notes/Boxes/etc - //float yTopNew = paraBreak.YVeryTop - YTopMost; - //float yTopNew = paraBreak.YTopMost - YTopMost; if (JustATableThatWillFit(paraBreak, yPageSize - (myTopMsgSpace + yEndMsg))) paraBreak = paraBreak.ChildrenBelow[0]; // B2020-112: complicated AER/RNO. yEndMsg was accounted for twice -> put endmsg part back in, it broke wcn and didn't affect bge @@ -1412,14 +1324,6 @@ namespace Volian.Print.Library PageBreakOnStepList.RemoveAt(0); yTopNew = paraBreak.YTop - YTopMost; } - // The following code caused forced pagination for Catawba EOP BG - EP/1/A/5000/FR-C.1.SC..S16..N2..S4..S1. - //else if(PageBreakOnStepList[0].YSize - yTop <= ySpaceOnCurPage) - //{ - // DebugPagination.WriteLine("======>>>>> Other Condition"); - // paraBreak = PageBreakOnStepList[0]; - // PageBreakOnStepList.RemoveAt(0); - // yTopNew = paraBreak.YTop - YTopMost; - //} } RemoveProcessedParagraphs(myList, yTopNew - yTop); yTop = yTopNew; @@ -1440,13 +1344,6 @@ namespace Volian.Print.Library // B2017-252 Pagination Fix - RNP was not paginating correctly. Added logic to set ySPaceOnCurPage if ySpaceOnNextPage was larger if (!usedPageBreakOnStepList || ySpaceOnNextPage1 > ySpaceOnCurPage) ySpaceOnCurPage = ySpaceOnNextPage1; - //ySpaceOnCurPage = yPageSize - (myTopMsgSpace + SixLinesPerInch); // Allow for continue message and blank line. - //if (paraBreak.YTopMost != paraBreak.YVeryTop && MyPageHelper.TopMessage == null && MyPageHelper.BottomMessage == null) - // ySpaceOnCurPage = yPageSize; - //ySpaceOnCurPage = yPageSize; // Allow for continue message and blank line. - //DocStyle docstyle = MyItemInfo.MyDocStyle; - //string myMsg = docstyle.Continue.Bottom.Message; - //if ((myMsg ?? "") != "") ySpaceOnCurPage -= 2 * SixLinesPerInch; // Allow for continue message and blank line. yLowerLimit = ySpaceOnCurPage / 2; if (_Match16BitPagination) yLowerLimit -= 1.5F * SixLinesPerInch; // 276 for HLP yStart = 0; @@ -1505,7 +1402,6 @@ namespace Volian.Print.Library { // C2023-015: Pagination on a sub-step added. Do the code if supplemental info or if format supports sub-step pagination // C2023-018: Remove the supplemental info & alarm check, doing the possible page breaks on sub-steps - //if (!MyItemInfo.MyDocStyle.SupplementalInformation && !MyItemInfo.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.StepSectionLayoutData.AlarmPagination) return null; SortedList sdpara = null; foreach (int stepLevel in myList.Keys) // loop thru StepLevels, starting with lowest. { @@ -1534,8 +1430,7 @@ namespace Volian.Print.Library private float GetBottomContinueMessageSize(DocStyle docstyle) { - float myBottomMsgSpace = 0; - docstyle = MyItemInfo.MyDocStyle; + float myBottomMsgSpace; string myBottomMsg = docstyle.Continue.Bottom.Message; myBottomMsgSpace = ((myBottomMsg ?? "") != "") ? 2 * SixLinesPerInch : 0; if (myBottomMsg != null && myBottomMsg.Contains("par")) myBottomMsgSpace += SixLinesPerInch; @@ -1603,7 +1498,7 @@ namespace Volian.Print.Library float? yLocationMin=null; vlnParagraph minPara2 = null; float? yLocationMin2=null; - float yAddForBtmMsg = 0; + float yAddForBtmMsg; // useful for debugging pagination issues, lastbreak gets the paragraph at the top of the previous page, shows all // of the locations within 'range' on the next page. //if (lastBreak != null && lastBreak.MyItemInfo.InList(72481)) @@ -1670,16 +1565,9 @@ namespace Volian.Print.Library // Note that this bug fix for WCN was commented out. Harry Julian wanted this on 11/15/19. A new bug will be written for the WCN error. // B2019-173 reintroduced the 'IsHigh' portion and added IsRNOPart, the HLS & RNOPart print at same location on page so code needs // to account for either. second iteration of this fix removed IsRNOPart (see code in Paginate) - && !myParent.MyItemInfo.IsHigh) /*|| myPara.MyItemInfo.IsRNOPart)) */// B2018-104: don't return if my parent is a high level - a top continue message was printing + && !myParent.MyItemInfo.IsHigh) // B2018-104: don't return if my parent is a high level - a top continue message was printing { //_MyLog.WarnFormat("\r\nMyParentBreak {0},{1},{2},{3},{4}", myParent, myParent.YSize, yUpperLimit, myParent.ChildrenRight[0].YSize, spaceOnPage); - // Removed the following and moved logic to Paginate method for the second iteration of the bug fix. This code below AND the IsRNOPart above caused another - // pagination problem. The insert and subsequent removal of this code are both done under bug B22019-173. - // Initial code for B2019-173: make minPara2 the first step on next page - //if (minPara2 != null && minPara2.MyParent == myParent && minPara2 != lastBreak && minPara2.MyItemInfo.Ordinal == 1) - //{ - // return minPara2; - //} if (myParent != lastBreak) return myParent; } @@ -1736,17 +1624,11 @@ namespace Volian.Print.Library } } } - //while (myPara.MyParent.YTop == myPara.YTop) myPara = myPara.MyParent; while (myPara.MyParent != null && myPara.MyParent.YTop == myPara.YTop) myPara = myPara.MyParent; int everyNLines = myPara.MyItemInfo.MyPrevious != null && myPara.MyItemInfo.FormatStepData == null ? 1 : myPara.MyItemInfo.FormatStepData.StepLayoutData.EveryNLines ?? 1; bool inSameBox = InSameBox(myPara, minPara2); // if this note/caution is in same box as the break, don't break within the notes/cautions in the same box if (!inSameBox && myPara.ChildrenAbove.Count == 0 && wcnChkLstBorder - yLocation < yUpperLimit + yAddForBtmMsg || (everyNLines != 99 && (wcnChkLstBorder - yLocation == yUpperLimit + yAddForBtmMsg))) // Fix for OFN-RJ-23 - //if (-yLocation < yUpperLimit) // Before - //if (-yLocation < yWithinMargins && myList[stepLevel][yLocation].MyItemInfo.MyPrevious != null) { - //ItemInfo prev = myList[stepLevel][yLocation].MyItemInfo.MyPrevious; - //if (myList[stepLevel][yLocation].MyItemInfo.ItemID == 5609) Console.WriteLine("aer"); - //if (myList[stepLevel][yLocation].MyItemInfo.ItemID == 4312) Console.WriteLine("rno"); // The top of this step is more than 1/2 way down the page if ((-yLocation + yStart) >= yLowerLimit) if (myPara != lastBreak) @@ -1819,13 +1701,14 @@ namespace Volian.Print.Library return minPara ?? minPara2; } - // B2020-013 premature break in RNO column - Callaway OTO-AC-00002 step 2 - // B2020-016 bad pagination on RNOs for Robinson AOP-010 step 27 , AOP-024 Step 10, EOP E-0 step 10, EOP ECA-2.1 step 28 - // B2020-073 was not keeping all of RNO sub-step together - Comanche Peak FRC-0.1 (unit 1) Step 14 - // B2020-081 was breaking on an AER substep that has an long RNO - should keep AER substep and part of RNO on the page = D.C. Cook "Current (Post FLEX) U1 NOP NOT [EOPs]" set, ES-0.1 step 1. - // B2020-085 was breaking first child of second RNO (third IF in RNO) - should break on second child of second RNO - D.C. Cook AOP Unit 1 002-020 Step 15 - // B2020-099 was breaking on last sub-step of previous RNO - Calvert Approved Procedures; Abnormal Procedures – Unit 2; AOP-2A; Section VII; Step 11.RNO.11.1.c - private vlnParagraph HasSecondRNOThatWillFit(float yStart, float yLowerLimit, float yUpperLimit, StepLevelList myList, int stepLevel, float yTop) + // B2020-013 premature break in RNO column - Callaway OTO-AC-00002 step 2 + // B2020-016 bad pagination on RNOs for Robinson AOP-010 step 27 , AOP-024 Step 10, EOP E-0 step 10, EOP ECA-2.1 step 28 + // B2020-073 was not keeping all of RNO sub-step together - Comanche Peak FRC-0.1 (unit 1) Step 14 + // B2020-081 was breaking on an AER substep that has an long RNO - should keep AER substep and part of RNO on the page = D.C. Cook "Current (Post FLEX) U1 NOP NOT [EOPs]" set, ES-0.1 step 1. + // B2020-085 was breaking first child of second RNO (third IF in RNO) - should break on second child of second RNO - D.C. Cook AOP Unit 1 002-020 Step 15 + // B2020-099 was breaking on last sub-step of previous RNO - Calvert Approved Procedures; Abnormal Procedures – Unit 2; AOP-2A; Section VII; Step 11.RNO.11.1.c + [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0060:Remove unused parameter", Justification = "Keeping myList and stepLevel for Debugging")] + private vlnParagraph HasSecondRNOThatWillFit(float yStart, float yLowerLimit, float yUpperLimit, StepLevelList myList, int stepLevel, float yTop) { // B2020-120: for calvert alarms/condition response table, don't run code for second rno if (this.ChildrenAbove != null && this.ChildrenAbove.Count > 0) if (HasCalvertMacro) return this; @@ -1856,12 +1739,6 @@ namespace Volian.Print.Library if ((chld.YTopMost + yStart + yTop - yTopParent) < yUpperLimit) return chld; // second RNO will fit, use this instead of myPara - // check to see if there is AER substep children that would be split if we pagination on the RNO - // B2020-150 commented out below. Found it is not needed for B2020-085 fix but it was what cause B2020-150 - //foreach (vlnParagraph chld in parent.ChildrenBelow) - // if (chld.YOffset < this.YOffset && YBottomMostExcludingRNO(chld) > this.YTopMost) // B2020-085 Does AER child start before myPara and length greater than myPara start - // return null; // the AER text positioning overlaps the RNO text positioning (caused AER sub-steps to be split onto next page (i.e. RO step) have pagination logic keep looking for place to break - return this; // current myPara is good } @@ -1903,7 +1780,8 @@ namespace Volian.Print.Library } return false; } - private static int MaxBreakLevel(float yLocation, StepLevelList myList, int maxLevel, vlnParagraph myParaBreak) + [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0060:Remove unused parameter", Justification = "Keeping yLocation for Debugging")] + private static int MaxBreakLevel(float yLocation, StepLevelList myList, int maxLevel, vlnParagraph myParaBreak) { foreach (int stepLevel in myList.Keys) foreach (float yLoc in myList[stepLevel].Keys) @@ -1935,27 +1813,7 @@ namespace Volian.Print.Library if (MyParent == null || MyParent.MyItemInfo.IsHigh) return false; return MyParent.HasAncestor(myParaBreak); } - //private void WalkStepLevel(float yTopMost) - //{ - // foreach (vlnParagraph child in ChildrenAbove) - // child.WalkStepLevel(yTopMost); - // foreach (vlnParagraph child in ChildrenLeft) - // child.WalkStepLevel(yTopMost); - // ShowStepLevel(yTopMost); - // foreach (vlnParagraph child in ChildrenRight) - // child.WalkStepLevel(yTopMost); - // foreach (vlnParagraph child in ChildrenBelow) - // child.WalkStepLevel(yTopMost); - //} - //private void ShowStepLevel(float yTopMost) - //{ - // ItemInfo item = MyItemInfo; - // ItemInfo parent = item.ActiveParent as ItemInfo; - // //if (para.MyItemInfo.ItemID == 205) - // // Console.Write(""); - // DebugPagination.WriteLine("'StepLevel',{0},{1},{2},{3},{4},{5},{6},{7},{8},{9}", YVeryTop - yTopMost, YSize, YBottomMost - yTopMost, item.ItemID, item.DBSequence, item.StepLevel, item.MyContent.Type % 10000, - // parent.MyContent.Type % 10000, item.HasCautionOrNote ? 1 : 0, parent.Cautions == null ? 0 : 1); - //} + public float TableSpaceAvailable// RHM20150525 - Table Scrunch { get // B2019-111 Keep AER Table with parent when RNO extends past the end of the page. @@ -1992,18 +1850,7 @@ namespace Volian.Print.Library } public partial class VlnSvgPageHelper : SvgPageHelper { - private bool _OriginalPageBreak; // use 16bit page breaks. - public bool OriginalPageBreak - { - get { return _OriginalPageBreak; } - set { _OriginalPageBreak = value; } - } - // This handles Page Breaks within a Step - private List _ParaBreaks = new List(); - public List ParaBreaks - { - get { return _ParaBreaks; } - set { _ParaBreaks = value; } - } - } + public bool OriginalPageBreak { get; set; } + public List ParaBreaks { get; set; } = new List(); + } } diff --git a/PROMS/Volian.Print.Library/Placekeeper.cs b/PROMS/Volian.Print.Library/Placekeeper.cs index a206f917..4ee9d2df 100644 --- a/PROMS/Volian.Print.Library/Placekeeper.cs +++ b/PROMS/Volian.Print.Library/Placekeeper.cs @@ -1,7 +1,4 @@ using System; -using System.Collections.Generic; -using System.Text; -using System.Drawing; using LBWordLibrary; using VEPROMS.CSLA.Library; using System.Text.RegularExpressions; @@ -10,12 +7,12 @@ namespace Volian.Print.Library { public class Placekeeper : IDisposable { - private LBApplicationClass _WordApp; - private LBDocumentClass _WordDoc; - private LBSelection _WordSel; + private readonly LBApplicationClass _WordApp; + private readonly LBDocumentClass _WordDoc; + private readonly LBSelection _WordSel; private LBTable _WordTbl; private const string TheQuickBrownFox = "The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog."; - private VE_Font _pkFont; + private readonly VE_Font _pkFont; public Placekeeper() { _WordApp = new LBApplicationClass(); @@ -28,37 +25,11 @@ namespace Volian.Print.Library _WordApp.Visible = true; _WordApp.Activate(); } - //public Placekeeper(pkParagraph myPlacekeeper) - //{ - // _WordApp = new LBApplicationClass(); - // _WordDoc = _WordApp.Documents.Add(); - // _WordSel = _WordApp.Selection; - // _WordApp.Visible = true; - // AddTable(); - // AddHeader(); - // AddSectionHeader(myPlacekeeper.MyParagraph.MyItemInfo.DisplayNumber, myPlacekeeper.MyParagraph.MyItemInfo.DisplayText); - // foreach (pkParagraph pgh in myPlacekeeper.MyChildren) - // { - // AddHighLevelStep(pgh.MyParagraph.MyItemInfo.MyTab.CleanText, pgh.MyParagraph.MyItemInfo.DisplayText, pgh.MyParagraph.MyItemInfo.FormatStepType==9 ? "C" : "", pgh.MyParagraph.MyItemInfo.PageNumber.ToString()); - // if (pgh.MyChildren.Count > 0) - // { - // StartSubStep(); - // foreach (pkParagraph cpgh in pgh.MyChildren) - // { - // ContinueSubStep(cpgh.MyParagraph.MyItemInfo.DisplayText, 1); - // foreach (pkParagraph ccpgh in cpgh.MyChildren) - // ContinueSubStep(ccpgh.MyParagraph.MyItemInfo.DisplayText, 2); - // } - // FinishSubstep("", ""); - // } - // } - //} public Placekeeper(pkParagraphs myPlacekeepers, VE_Font pkFont) { _WordApp = new LBApplicationClass(); _WordDoc = _WordApp.Documents.Add(); _WordSel = _WordApp.Selection; - //_WordApp.Visible = true; _pkFont = pkFont; AddTable(); AddHeader(); @@ -97,7 +68,7 @@ namespace Volian.Print.Library if (cpgh.MyCautionsAndNotes.Count > 0) AddNotesOrCautions(cpgh,level, ref conAct); if (!conAct) - conAct = IsContinuousActionPlacekeeper(conAct, cpgh); + conAct = IsContinuousActionPlacekeeper(cpgh); ContinueSubStep(cpgh.MyParagraph.MyItemInfo.FormattedDisplayText, level); AddChildren(cpgh, level+1, ref conAct); } @@ -108,19 +79,14 @@ namespace Volian.Print.Library foreach (pkParagraph cpgh in pgh.MyCautionsAndNotes) { if (!conAct) - conAct = IsContinuousActionPlacekeeper(conAct, cpgh); + conAct = IsContinuousActionPlacekeeper(cpgh); ContinueNoteOrCaution(cpgh.MyParagraph.MyItemInfo, level); } } - private static bool IsContinuousActionPlacekeeper(bool conAct, pkParagraph pkPar) - { - StepConfig sc = pkPar.MyParagraph.MyItemInfo.MyConfig as StepConfig; - conAct = (sc.Step_Placekeeper.ToUpper() == "C"); - return conAct; - } + private static bool IsContinuousActionPlacekeeper(pkParagraph pkPar) => (pkPar.MyParagraph.MyItemInfo.MyConfig as StepConfig).Step_Placekeeper.ToUpper() == "C"; - private void ContinueNoteOrCaution(ItemInfo ii, int level) + private void ContinueNoteOrCaution(ItemInfo ii, int level) { string NoteCautionTab = "NOTE: "; if (ii.IsCaution) NoteCautionTab = "CAUTION: "; @@ -176,22 +142,17 @@ namespace Volian.Print.Library _WordTbl.TopPadding = 6F; _WordTbl.BottomPadding = 6F; LBColumn col = _WordTbl.Columns.First; - //col.SetWidth(12F, LBWdRulerStyle.wdAdjustNone); - //col = col.Next; col.SetWidth(72 * .91F, LBWdRulerStyle.wdAdjustNone); col = col.Next; col.SetWidth(72 * 4.1F, LBWdRulerStyle.wdAdjustNone); col = col.Next; - //col.SetWidth(72 * .81F, LBWdRulerStyle.wdAdjustNone); col.SetWidth(72 * .76F, LBWdRulerStyle.wdAdjustNone); col = col.Next; - //col.SetWidth(72 * .81F, LBWdRulerStyle.wdAdjustNone); col.SetWidth(72 * .76F, LBWdRulerStyle.wdAdjustNone); _WordTbl.Rows.AllowBreakAcrossPages = 0; } private void AddHeader() { - //Advance(); WriteCell("START", true, true); SetIndent(0.32F, -0F); WriteCell("FUNCTION", true, true); @@ -219,7 +180,6 @@ namespace Volian.Print.Library // follow through in fixing an Out of Window Handles bug, use new function to see if // we can retrieve the font from a dictionary instead a doing a New and using another // window handle B2017-117 - //System.Drawing.Font font = new System.Drawing.Font(_pkFont.Family, (float)_pkFont.Size); System.Drawing.Font font = VE_Font.GetWinSysFont(_pkFont.Family, (float)_pkFont.Size); iTextSharp.text.Font iFont = Volian.Svg.Library.VolianPdf.GetFont(font); float w = 0; @@ -227,8 +187,6 @@ namespace Volian.Print.Library { w += iFont.BaseFont.GetWidthPointKerned(c.ToString(), (float)_pkFont.Size); } - // indented text didn't always line up doing it this way - //float w = iFont.BaseFont.GetWidthPointKerned(txt, (float)_pkFont.Size); return w; } private void AddHighLevelStep(string number, string text, string done, string page) @@ -276,7 +234,6 @@ namespace Volian.Print.Library { Advance(2); SetIndent(.64F, -.31F); - //_WordSel.InsertSymbol(8226, _WordSel.Font, System.Reflection.Missing.Value, System.Reflection.Missing.Value); WriteCell("\u2022" + "\t" + text, false, true); SetAlignment(LBWdParagraphAlignment.wdAlignParagraphCenter, LBWdCellVerticalAlignment.wdCellAlignVerticalBottom); WriteCell(done, false, true); @@ -316,7 +273,7 @@ namespace Volian.Print.Library SetAlignment(LBWdParagraphAlignment.wdAlignParagraphCenter, LBWdCellVerticalAlignment.wdCellAlignVerticalBottom); WriteCell(page, false, false); } - static Regex rgx = new Regex(@"\\(b|ul|up[1-9]|dn0|up0|dn[1-9]|b0|ulnone)( |$|(?=\\))"); + static readonly Regex rgx = new Regex(@"\\(b|ul|up[1-9]|dn0|up0|dn[1-9]|b0|ulnone)( |$|(?=\\))"); private void WriteRTF(string text) { //if (text.Contains("\\")) @@ -381,13 +338,7 @@ namespace Volian.Print.Library { _WordSel.MoveRight(LBWdUnits.wdCell, count, false); } - private void Advance() - { - Advance(1); - } - public void Dispose() - { - _WordApp.Quit(false); - } - } + private void Advance() => Advance(1); + public void Dispose() => _WordApp.Quit(false); + } } diff --git a/PROMS/Volian.Print.Library/PromsPrinter.cs b/PROMS/Volian.Print.Library/PromsPrinter.cs index dcd0572a..159bf433 100644 --- a/PROMS/Volian.Print.Library/PromsPrinter.cs +++ b/PROMS/Volian.Print.Library/PromsPrinter.cs @@ -3,58 +3,39 @@ using System.Collections.Generic; using System.Text; using VEPROMS.CSLA.Library; using Volian.Svg.Library; -using iTextSharp.text.factories; using iTextSharp.text; using iTextSharp.text.pdf; using System.Text.RegularExpressions; using System.IO; -using System.Xml; using System.Windows.Forms; -using LBWordLibrary; using System.Drawing; -using System.Drawing.Imaging; -using Volian.Controls.Library; using Volian.Base.Library; using JR.Utils.GUI.Forms; +using System.Linq; namespace Volian.Print.Library { public delegate void PromsPrinterStatusEvent(object sender, PromsPrintStatusArgs args); public class PromsPrintStatusArgs { - private string _MyStatus; - public string MyStatus - { - get { return _MyStatus; } - } - private DateTime _When = DateTime.Now; - public DateTime When - { - get { return _When; } - } - private PromsPrinterStatusType _Type; - public PromsPrinterStatusType Type - { - get { return _Type; } - set { _Type = value; } - } - private int _Progress = 0; + private readonly string _MyStatus; + public string MyStatus => _MyStatus; + private readonly DateTime _When = DateTime.Now; + public DateTime When => _When; - public int Progress - { - get { return _Progress; } - set { _Progress = value; } - } - public PromsPrintStatusArgs(string myStatus, PromsPrinterStatusType type) + public PromsPrinterStatusType Type { get; set; } + + public int Progress { get; set; } = 0; + public PromsPrintStatusArgs(string myStatus, PromsPrinterStatusType type) { _MyStatus = myStatus; - _Type = type; + Type = type; } public PromsPrintStatusArgs(string myStatus, PromsPrinterStatusType type, int progress) { _MyStatus = myStatus; - _Type = type; - _Progress = progress; + Type = type; + Progress = progress; } } public enum PromsPrinterStatusType @@ -99,162 +80,48 @@ namespace Volian.Print.Library public E_SupInfoPrintType SupInfoPrintType = E_SupInfoPrintType.None; // used to link supinfo steps in pdf public int SupInfoPdfPageCount = -1; - private Dictionary _SupInfoPdfPage; - public Dictionary SupInfoPdfPage - { - get { return _SupInfoPdfPage; } - set { _SupInfoPdfPage = value; } - } - private bool _DoingFacingPage = false; // used to flag actual pdf generation of facing page within final print (so no section titles get printed) - public bool DoingFacingPage - { - get { return _DoingFacingPage; } - set { _DoingFacingPage = value; } - } - // used to save word sections with resolved ROs (for export file generated from approve) - private Dictionary _DocReplace; - public Dictionary DocReplace - { - get { return _DocReplace; } - set { _DocReplace = value; } - } - private bool _SaveLinks = false; - public bool SaveLinks - { - get { return _SaveLinks; } - set { _SaveLinks = value; } - } - // C2021-010: Remove trailing returns/spaces & manual page breaks & allow save. - // Use these 2 lists to track the items that will need to be saved after removing trailing newlines/spaces or - // manual page breaks, if the user selects to do that. - private List _RemoveTrailingHardReturnsAndSpaces = null; - public List RemoveTrailingHardReturnsAndSpaces - { - get { return _RemoveTrailingHardReturnsAndSpaces; } - set { _RemoveTrailingHardReturnsAndSpaces = value; } - } - private List _RemoveManualPageBreaks = null; - public List RemoveManualPageBreaks - { - get { return _RemoveManualPageBreaks; } - set { _RemoveManualPageBreaks = value; } - } - private string _Prefix = ""; // RHM20150506 Multiline ItemID TextBox - public string Prefix - { - get { return _Prefix; } - set { _Prefix = value; } - } + public Dictionary SupInfoPdfPage { get; set; } + public bool DoingFacingPage { get; set; } = false; + public Dictionary DocReplace { get; set; } + public bool SaveLinks { get; set; } = false; + public List RemoveTrailingHardReturnsAndSpaces { get; set; } = null; + public List RemoveManualPageBreaks { get; set; } = null; + public string Prefix { get; set; } = ""; - // B2024-062 Set to true when the procedure being printed has no content. - // When set to true, will prevent the "Try Again" dialog from appearing - // and simply exit the print function - private bool _EmptyProcedure = false; - public bool EmptyProcedure - { - get { return _EmptyProcedure; } - } - private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + // B2024-062 Set to true when the procedure being printed has no content. + // When set to true, will prevent the "Try Again" dialog from appearing + // and simply exit the print function + private bool _EmptyProcedure = false; + public bool EmptyProcedure => _EmptyProcedure; + private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); public event PromsPrinterStatusEvent StatusChanged; - internal void OnStatusChanged(object sender, PromsPrintStatusArgs args) - { - if (StatusChanged != null) - StatusChanged(sender, args); - } - internal void OnStatusChanged(string myStatus, PromsPrinterStatusType type) - { - OnStatusChanged(this, new PromsPrintStatusArgs(myStatus, type)); - } - public void OnStatusChanged(string msg) - { - OnStatusChanged(this, new PromsPrintStatusArgs(msg, PromsPrinterStatusType.General)); - } - internal void OnStatusChanged(string myStatus, PromsPrinterStatusType type, int progress) - { - OnStatusChanged(this, new PromsPrintStatusArgs(myStatus, type, progress)); - } - private string _Rev; - private ItemInfo _MyItem; - public ItemInfo MyItem - { - get { return _MyItem; } - set { _MyItem = value; } - } - private string _Watermark; - private string _WatermarkColor; - //C2018-009 print PROMS version - private string _PromsVersion = ""; - public string PromsVersion - { - get { return _PromsVersion; } - set { _PromsVersion = value; } - } - private string _PDFFile; - public string PDFFile - { - get { return _PDFFile; } - set { _PDFFile = value; } - } - private int _prtSectID = -1; - public int PrtSectID - { - get { return _prtSectID; } - set { _prtSectID = value; } - } - private bool _DebugOutput; - public bool DebugOutput - { - get { return _DebugOutput; } - set { _DebugOutput = value; } - } - private string _BackgroundFolder; - public string BackgroundFolder - { - get { return _BackgroundFolder; } - set { _BackgroundFolder = value; } - } - private bool _OpenPDF; + internal void OnStatusChanged(object sender, PromsPrintStatusArgs args) => StatusChanged?.Invoke(sender, args); + internal void OnStatusChanged(string myStatus, PromsPrinterStatusType type) => OnStatusChanged(this, new PromsPrintStatusArgs(myStatus, type)); + public void OnStatusChanged(string msg) => OnStatusChanged(this, new PromsPrintStatusArgs(msg, PromsPrinterStatusType.General)); + internal void OnStatusChanged(string myStatus, PromsPrinterStatusType type, int progress) => OnStatusChanged(this, new PromsPrintStatusArgs(myStatus, type, progress)); + private readonly string _Rev; - public bool OpenPDF - { - get { return _OpenPDF; } - set { _OpenPDF = value; } - } - private bool _OverWrite; + public ItemInfo MyItem { get; set; } + private readonly string _Watermark; + private readonly string _WatermarkColor; - public bool OverWrite - { - get { return _OverWrite; } - set { _OverWrite = value; } - } - private ChangeBarDefinition _MyChangeBarDefinition; - public ChangeBarDefinition MyChangeBarDefinition - { - get { return _MyChangeBarDefinition; } - set { _MyChangeBarDefinition = value; } - } - private bool _OriginalPageBreak; // use 16bit page breaks. - public bool OriginalPageBreak - { - get { return _OriginalPageBreak; } - set { _OriginalPageBreak = value; } - } - private bool _InsertBlankPages; - public bool InsertBlankPages - { - get { return _InsertBlankPages; } - set { _InsertBlankPages = value; } - } - private bool _BatchPrint = true; // flags that a batch-type print is occurring, i.e. AllProcedures or Automatic testing - public bool BatchPrint - { - get { return _BatchPrint; } - set { _BatchPrint = value; } - } - // B2020-159: When printing, if forced pagination errors occurred (see Pagination.cs), put up a dialog with - // the places they occurred. Do not do this is running baseline/automatic print testing. - private static List _ForcedPaginations = null; + public string PromsVersion { get; set; } = ""; + public string PDFFile { get; set; } + public int PrtSectID { get; set; } = -1; + public bool DebugOutput { get; set; } + public string BackgroundFolder { get; set; } + + public bool OpenPDF { get; set; } + + public bool OverWrite { get; set; } + public ChangeBarDefinition MyChangeBarDefinition { get; set; } + public bool OriginalPageBreak { get; set; } + public bool InsertBlankPages { get; set; } + public bool BatchPrint { get; set; } = true; + // B2020-159: When printing, if forced pagination errors occurred (see Pagination.cs), put up a dialog with + // the places they occurred. Do not do this is running baseline/automatic print testing. + private static List _ForcedPaginations = null; public static List ForcedPaginations { get { return PromsPrinter._ForcedPaginations; } @@ -266,7 +133,7 @@ namespace Volian.Print.Library { string pnProbl = null; foreach (string pstr in ForcedPaginations) - pnProbl = pnProbl + "\r\n" + pstr; + pnProbl = $"{pnProbl}\r\n{pstr}"; Clipboard.SetText(pnProbl); return FlexibleMessageBox.Show( "PROMS has identified location(s) in the PDF file that was created that may not have paginated correctly." @@ -286,17 +153,14 @@ namespace Volian.Print.Library get { return PromsPrinter._TransPageNumProblems; } set { PromsPrinter._TransPageNumProblems = value; } } - public static void ClearTransPageNumProblems() - { - _TransPageNumProblems = null; - } - public static DialogResult ReportTransPageNumProblems() + public static void ClearTransPageNumProblems() => _TransPageNumProblems = null; + public static DialogResult ReportTransPageNumProblems() { if (TransPageNumProblems != null && TransPageNumProblems.Count > 0) { string pnProbl = null; foreach (string pstr in TransPageNumProblems) - pnProbl = pnProbl + "\r\n" + pstr; + pnProbl = $"{pnProbl}\r\n{pstr}"; Clipboard.SetText(pnProbl); return FlexibleMessageBox.Show("The following list was placed on the Windows Clipboard." + "\r\nIt shows the page numbers of the locations that are referenced by transitions." @@ -308,42 +172,18 @@ namespace Volian.Print.Library } return DialogResult.No; } - private ReaderHelper _MyReaderHelper; - public ReaderHelper MyReaderHelper - { - get { return _MyReaderHelper; } - set { _MyReaderHelper = value; } - } - private string _BlankPageText; // C2019-004: Allow user to define duplex blank page text - public string BlankPageText - { - get { return _BlankPageText; } - set { _BlankPageText = value; } - } - // use DidAll & MergeNotIncuded to know that printing all (not single) was done. Used w/ merge code to know when to return, i.e. not include in merged pdf - private bool _DidAll; - public bool DidAll // value passed in from frmPdfStatusForm - { - get { return _DidAll; } - set { _DidAll = value; } - } - private bool _MergeNotIncluded; - public bool MergeNotIncluded - { - get { return _MergeNotIncluded; } - set { _MergeNotIncluded = value; } - } - private MergedPdf _MergedPdf; - public MergedPdf MergedPdf - { - get { return _MergedPdf; } - set { _MergedPdf = value; } - } - //B2025-048 Problem with Printing CAS Steps - // default to Normal - // will skip certain logic if CAS Only or CTS Only - public PromsPrinterPrintType PromsPrinterPrintType { get; set; } = PromsPrinterPrintType.Normal; + public ReaderHelper MyReaderHelper { get; set; } + public string BlankPageText { get; set; } + public bool DidAll // value passed in from frmPdfStatusForm + { get; set; } + public bool MergeNotIncluded { get; set; } + public MergedPdf MergedPdf { get; set; } + + //B2025-048 Problem with Printing CAS Steps + // default to Normal + // will skip certain logic if CAS Only or CTS Only + public PromsPrinterPrintType PromsPrinterPrintType { get; set; } = PromsPrinterPrintType.Normal; //B2025-054 Wrong Page Numbers in CAS Summary // when section title continued and CAS @@ -355,65 +195,53 @@ namespace Volian.Print.Library ChangeBarDefinition cbd, String pdfFile, bool insertBlankPages, bool batchPrint, string prefix, bool saveLinks, int removeTrailngHardReturnsAndManualPageBreaks, string blankPageText, bool didAll, MergedPdf mergedPdf, string watermarkColor, int PrtSectID = -1) { Prefix = prefix; // RHM20150506 Multiline ItemID TextBox - _MyItem = myItem; + MyItem = myItem; _Rev = rev; _Watermark = watermark; _WatermarkColor = watermarkColor; - _DebugOutput = debugOutput; - _BackgroundFolder = backgroundFolder; - _OpenPDF = openPDF; - _OverWrite = overWrite; - _MyChangeBarDefinition = cbd; - _PDFFile = pdfFile; - _OriginalPageBreak = origPgBrk; - _InsertBlankPages = insertBlankPages; - _BatchPrint = batchPrint; - _MyReaderHelper = new ReaderHelper(this); - _SaveLinks = saveLinks; + DebugOutput = debugOutput; + BackgroundFolder = backgroundFolder; + OpenPDF = openPDF; + OverWrite = overWrite; + MyChangeBarDefinition = cbd; + PDFFile = pdfFile; + OriginalPageBreak = origPgBrk; + InsertBlankPages = insertBlankPages; + BatchPrint = batchPrint; + MyReaderHelper = new ReaderHelper(this); + SaveLinks = saveLinks; // C2021-010: Remove trailing returns/spaces & manual page breaks & allow save. if (removeTrailngHardReturnsAndManualPageBreaks == 1 || removeTrailngHardReturnsAndManualPageBreaks == 3) RemoveTrailingHardReturnsAndSpaces = new List(); if (removeTrailngHardReturnsAndManualPageBreaks == 2 || removeTrailngHardReturnsAndManualPageBreaks == 3) RemoveManualPageBreaks = new List(); - _BlankPageText = blankPageText; - _DidAll = didAll; - _MergeNotIncluded = false; - _MergedPdf = mergedPdf; - _prtSectID = PrtSectID; - //_MyReaderHelper.LoadTree(myItem); + BlankPageText = blankPageText; + DidAll = didAll; + MergeNotIncluded = false; + MergedPdf = mergedPdf; + this.PrtSectID = PrtSectID; } - // Pass 1 PDF Name - private string _BeforePageNumberPdf = null; - public string BeforePageNumberPdf - { - get { return _BeforePageNumberPdf; } - set { _BeforePageNumberPdf = value; } - } - // Pass 2 PDF Name - private string _BeforePageNumber2Pdf = null; - public string BeforePageNumber2Pdf - { - get { return _BeforePageNumber2Pdf; } - set { _BeforePageNumber2Pdf = value; } - } - // B2019-152: MergedLandscapePages is a dictionary whose key is the pdf file name & values are all of the page numbers - // in that pdf that should have landscaped page numbers. These are added when the page is finished (onEndPage) - public static Dictionary> MergedLandscapePages = null; + + public string BeforePageNumberPdf { get; set; } = null; + public string BeforePageNumber2Pdf { get; set; } = null; + // B2019-152: MergedLandscapePages is a dictionary whose key is the pdf file name & values are all of the page numbers + // in that pdf that should have landscaped page numbers. These are added when the page is finished (onEndPage) + public static Dictionary> MergedLandscapePages = null; public string Print(string pdfFolder, bool makePlacekeeper, bool makeContinuousActionSummary, bool makeTimeCriticalActionSummary, int PrtSectID = -1) { - if (_MyItem is ProcedureInfo) + if (MyItem is ProcedureInfo) { - _prtSectID = PrtSectID; - ProcedureConfig pcfg = (ProcedureConfig)(_MyItem as ProcedureInfo).MyConfig; + this.PrtSectID = PrtSectID; + ProcedureConfig pcfg = (ProcedureConfig)(MyItem as ProcedureInfo).MyConfig; if (DidAll && pcfg.Print_NotInMergeAll) // will be merging a pdf, so don't print this procedure if user set that on procedure propertures { - _MergeNotIncluded = true; + MergeNotIncluded = true; return null; } // B2017-186 First do Procedures that don't have page number transitions - if (!(_MyItem.ActiveFormat.PlantFormat.FormatData.TransData.UseTransitionModifier || - _MyItem.ActiveFormat.PlantFormat.FormatData.TransData.UseSpecificTransitionModifier)) + if (!(MyItem.ActiveFormat.PlantFormat.FormatData.TransData.UseTransitionModifier || + MyItem.ActiveFormat.PlantFormat.FormatData.TransData.UseSpecificTransitionModifier)) { // B2017-186 Do Facing Page SAMGs - if ((_MyItem as ProcedureInfo).ProcHasSupInfoData) + if ((MyItem as ProcedureInfo).ProcHasSupInfoData) { // Use two passes to print facing page supplemental information for SAMGs // First pass gets pagination for the step sections and stores the associated supplemental information ids in @@ -423,10 +251,10 @@ namespace Volian.Print.Library SectionInfo.ResetLookupStepSectPageBreaks(); // B2017-192: Reset lists for tracking page breaks SectionInfo.ResetLookupStepSectPageBreaksForSupInfo(); SupInfoPrintType = E_SupInfoPrintType.DoPageBreaks; - string retstr = Print(_MyItem as ProcedureInfo, pdfFolder, false, false, false); + string retstr = Print(MyItem as ProcedureInfo, pdfFolder, false, false, false); if (retstr == null) return null; SupInfoPrintType = E_SupInfoPrintType.Merge; - string tmps = Print(_MyItem as ProcedureInfo, pdfFolder, false, false, false); + string tmps = Print(MyItem as ProcedureInfo, pdfFolder, false, false, false); if (!BatchPrint && ForcedPaginations != null && ForcedPaginations.Count > 0) // B2020-159: Forced Pagination Reporting { ReportForcedPaginations(); @@ -436,7 +264,7 @@ namespace Volian.Print.Library } else // B2017-186 Neither Facing Pages or Page Number Transitions { - string tmpss = Print(_MyItem as ProcedureInfo, pdfFolder, makePlacekeeper, makeContinuousActionSummary, makeTimeCriticalActionSummary); + string tmpss = Print(MyItem as ProcedureInfo, pdfFolder, makePlacekeeper, makeContinuousActionSummary, makeTimeCriticalActionSummary); if (!BatchPrint && ForcedPaginations != null && ForcedPaginations.Count > 0) // B2020-159: Forced Pagination Reporting { ReportForcedPaginations(); @@ -453,7 +281,7 @@ namespace Volian.Print.Library // 2nd pass fills in the page numbers in transitions. DirectoryInfo di = new DirectoryInfo(pdfFolder + @"\PageNumberPass1"); if (!di.Exists) di.Create(); - if ((_MyItem as ProcedureInfo).ProcHasSupInfoData)// B2017-186 Adds Facing Page Code to Page Number Transition Code + if ((MyItem as ProcedureInfo).ProcHasSupInfoData)// B2017-186 Adds Facing Page Code to Page Number Transition Code { // Use two passes to print facing page supplemental information for SAMGs // First pass gets pagination for the step sections and stores the associated supplemental information ids in @@ -461,17 +289,17 @@ namespace Volian.Print.Library // Second pass prints the supplemental information pdfs using the list generated in the first pass to know where to do the // supplemental information page breaks & then merges in those pages when printing the step sections. SupInfoPrintType = E_SupInfoPrintType.DoPageBreaks; - retstr = Print(_MyItem as ProcedureInfo, pdfFolder, false, false, false); + retstr = Print(MyItem as ProcedureInfo, pdfFolder, false, false, false); if (retstr == null) return null; SupInfoPrintType = E_SupInfoPrintType.Merge; } - retstr = Print(_MyItem as ProcedureInfo, pdfFolder + @"\PageNumberPass1", false, false, false); + retstr = Print(MyItem as ProcedureInfo, pdfFolder + @"\PageNumberPass1", false, false, false); if (retstr == null) return null; BeforePageNumberPdf = retstr; BeforePageNumber2Pdf = null; // C2017-018 Initialize Pass 2 PDF Name - ProcedureInfo.RefreshPageNumTransitions(_MyItem as ProcedureInfo); - _MyReaderHelper = new ReaderHelper(this); - retstr = Print(_MyItem as ProcedureInfo, pdfFolder, makePlacekeeper, makeContinuousActionSummary, makeTimeCriticalActionSummary); + ProcedureInfo.RefreshPageNumTransitions(MyItem as ProcedureInfo); + MyReaderHelper = new ReaderHelper(this); + retstr = Print(MyItem as ProcedureInfo, pdfFolder, makePlacekeeper, makeContinuousActionSummary, makeTimeCriticalActionSummary); if (!BatchPrint && ForcedPaginations != null && ForcedPaginations.Count > 0) // B2020-159: Forced Pagination Reporting { ReportForcedPaginations(); @@ -497,10 +325,10 @@ namespace Volian.Print.Library _MyLog.ErrorFormat("{0} During Save {1}", ex.GetType().FullName, ex.Message); } ClearTransPageNumProblems(); - RefreshPageNumber(_MyItem); - ProcedureInfo.RefreshPageNumTransitions(_MyItem as ProcedureInfo); - _MyReaderHelper = new ReaderHelper(this); - retstr = Print(_MyItem as ProcedureInfo, pdfFolder, makePlacekeeper, makeContinuousActionSummary, makeTimeCriticalActionSummary); + RefreshPageNumber(MyItem); + ProcedureInfo.RefreshPageNumTransitions(MyItem as ProcedureInfo); + MyReaderHelper = new ReaderHelper(this); + retstr = Print(MyItem as ProcedureInfo, pdfFolder, makePlacekeeper, makeContinuousActionSummary, makeTimeCriticalActionSummary); } } return retstr; @@ -524,15 +352,13 @@ namespace Volian.Print.Library } internal string BuildMSWordPDF(SectionInfo section) { - DateTime tStart = DateTime.Now; string MSWordFile = null; if (section.MyContent.ContentEntryCount == 1) { MSWordToPDF.DocReplace = DocReplace; MSWordFile = MSWordToPDF.GetDocPdf(section, PrintOverride.TextColor); MSWordToPDF.DocReplace = null; - //GC.Collect(); // memory garbage collection - OnStatusChanged("MSWord converted to PDF " + MSWordFile, PromsPrinterStatusType.MSWordToPDF); + OnStatusChanged($"MSWord converted to PDF {MSWordFile}", PromsPrinterStatusType.MSWordToPDF); } return MSWordFile; } @@ -622,12 +448,11 @@ namespace Volian.Print.Library { SectionInfo currentSection = _MyHelper.MySection; SectionInfo nextSection = GetNextSection(currentSection); // _MyHelper.MySection.NextItem as SectionInfo; - //SectionConfig sc = (nextSection ?? currentSection).MyConfig as SectionConfig; - // If we are changing to a different section, then get the config from the nextSection - // else we are still printing in the same section so get the config from the current section - SectionConfig sc = ((!sectionChange || nextSection == null) ? currentSection.MyConfig : nextSection.MyConfig) as SectionConfig; - bool wordMargins = (sc != null && sc.Section_WordMargin == "Y"); - if (wordMargins) + //SectionConfig sc = (nextSection ?? currentSection).MyConfig as SectionConfig; + // If we are changing to a different section, then get the config from the nextSection + // else we are still printing in the same section so get the config from the current section + bool wordMargins = (((!sectionChange || nextSection == null) ? currentSection.MyConfig : nextSection.MyConfig) is SectionConfig sc && sc.Section_WordMargin == "Y"); + if (wordMargins) { if (nextSection != null && (sectionChange) && !nextSection.IsStepSection) //change to a word section { @@ -695,13 +520,9 @@ namespace Volian.Print.Library if (parent == null) return null; return parent.NextItem.GetSectionInfo(); } - private SectionInfo _PreviousWordSection = null; - public SectionInfo PreviousWordSection - { - get { return _PreviousWordSection; } - set { _PreviousWordSection = value; } - } - private SectionInfo _LastWordSection = null; + + public SectionInfo PreviousWordSection { get; set; } = null; + private SectionInfo _LastWordSection = null; public SectionInfo LastWordSection { get { return _LastWordSection; } @@ -712,6 +533,7 @@ namespace Volian.Print.Library } } private int _PageCountOfWordSection = 0; + //For Debugging: //private void ShowNeedForPageSize() //{ // if(PreviousWordSection != null && PreviousWordSection != LastWordSection) @@ -759,16 +581,15 @@ namespace Volian.Print.Library // If enabled, CreateLayers will need to be skipped. //writer.PDFXConformance = PdfWriter.PDFA1B; } - catch (Exception ex) + catch (Exception) { StringBuilder sb = new StringBuilder(); sb.AppendLine("Could not create"); sb.AppendLine(); - sb.AppendLine(outputFileName + "."); + sb.AppendLine($"{outputFileName}."); sb.AppendLine(); sb.AppendLine("If it is open, close and retry."); MessageBox.Show(sb.ToString(), "Error on CreatePdf", MessageBoxButtons.OK, MessageBoxIcon.Warning); - //MessageBox.Show("Could not create " + outputFileName + ". If it is open, close and retry.", "Error on CreatePdf"); return MyContentByte = null; } document.Open(); @@ -788,36 +609,20 @@ namespace Volian.Print.Library return MyContentByte; } - catch (Exception ex) + catch (Exception) { StringBuilder sb = new StringBuilder(); sb.AppendLine("Error occured when creating Print PDF"); sb.AppendLine(); - sb.AppendLine(outputFileName + "."); + sb.AppendLine($"{outputFileName}."); sb.AppendLine(); sb.AppendLine("If it is open, close and retry."); MessageBox.Show(sb.ToString(), "Error Creating PDF", MessageBoxButtons.OK, MessageBoxIcon.Warning); - //MessageBox.Show("Could not create " + outputFileName + ". If it is open, close and retry.", "Error on CreatePdf"); return MyContentByte = null; } } - //private string CreateFileName(string procNumber, string sectNumber, string sectTitle) - //{ - // return FixFileName(procNumber + "_" + ((sectNumber ?? "") != "" ? sectNumber : sectTitle)); - //} - //private string CreateFileName(string procNumber) - //{ - // return FixFileName(procNumber); - //} - //private string FixFileName(string name) - //{ - // return Regex.Replace(name, "[ .,/]", "_") + ".pdf"; - //} - int _StepPageNumber = 0; private VlnSvgPageHelper _MyHelper = null; - //private static PdfReader _MyFoldoutReader = null; - //private static SectionInfo _MyFoldoutSection = null; private static List _MyFoldoutReader = null; public static List MyFoldoutReader { @@ -827,7 +632,7 @@ namespace Volian.Print.Library private static List _MyFoldoutSection = null; private string Print(ProcedureInfo myProcedure, string pdfFolder, bool makePlacekeeper, bool makeContinuousActionSummary, bool makeTimeCriticalAction) { - if (_ForcedPaginations != null) _ForcedPaginations.Clear(); + _ForcedPaginations?.Clear(); int profileDepth = ProfileTimer.Push(">>>> PromsPrinter.Print"); if (_TransPageNumProblems == null) _TransPageNumProblems = new List(); @@ -840,7 +645,7 @@ namespace Volian.Print.Library if (myProcedure.Sections != null) { int cnt = 0; - foreach (SectionInfo mySection in myProcedure.Sections) + foreach (SectionInfo mySection in myProcedure.Sections.OfType()) { if (PrtSectID == -1 || (PrtSectID > -1 && mySection.ItemID == PrtSectID)) { @@ -862,8 +667,8 @@ namespace Volian.Print.Library } } } - OnStatusChanged("Print " + myProcedure.DisplayNumber, PromsPrinterStatusType.Start); - string outputFileName = pdfFolder + "\\" + Prefix + PDFFile; // RHM20150506 Multiline ItemID TextBox + OnStatusChanged($"Print {myProcedure.DisplayNumber}", PromsPrinterStatusType.Start); + string outputFileName = $"{pdfFolder}\\{Prefix}{PDFFile}"; // RHM20150506 Multiline ItemID TextBox string retval = PrintProcedureOrFoldout(myProcedure, null, outputFileName, makePlacekeeper, makeContinuousActionSummary, makeTimeCriticalAction); ProfileTimer.Pop(profileDepth); @@ -893,20 +698,11 @@ namespace Volian.Print.Library } return -1; } - private bool _AllowAllWatermarks = false; - public bool AllowAllWatermarks - { - get { return _AllowAllWatermarks; } - set { _AllowAllWatermarks = value; } - } - private string _WatermarkOverrideColor = "BLUE"; // C2021-019: Override watermark color - public string WatermarkOverrideColor - { - get { return _WatermarkOverrideColor; } - set { _WatermarkOverrideColor = value; } - } - //private PdfReader readerWord; - private string PrintProcedureOrFoldout(ProcedureInfo myProcedure, SectionInfo myFoldoutSection, string outputFileName, bool makePlacekeeper, bool makeContinuousActionSummary, bool makeTimeCriticalActionSummary) + + public bool AllowAllWatermarks { get; set; } = false; + public string WatermarkOverrideColor { get; set; } = "BLUE"; + //private PdfReader readerWord; + private string PrintProcedureOrFoldout(ProcedureInfo myProcedure, SectionInfo myFoldoutSection, string outputFileName, bool makePlacekeeper, bool makeContinuousActionSummary, bool makeTimeCriticalActionSummary) { int profileDepth = ProfileTimer.Push(">>>> PrintProcedureOrFoldout"); Rtf2Pdf.TextAtCounter = 0; @@ -929,9 +725,8 @@ namespace Volian.Print.Library if (myProcedure.Sections != null && !myProcedure.Sections[0].IsStepSection && !doingFoldout) // B2019-166 also don't do this if doing a foldout else it will use the margins set in word { SectionInfo si = myProcedure.Sections[0] as SectionInfo; - SectionConfig sc = si.MyConfig as SectionConfig; - bool wordMargins = (sc != null && sc.Section_WordMargin == "Y"); - if (wordMargins) + bool wordMargins = (si.MyConfig is SectionConfig sc && sc.Section_WordMargin == "Y"); + if (wordMargins) { string pdfFile = BuildMSWordPDF(si); try @@ -975,15 +770,14 @@ namespace Volian.Print.Library string LastFmtName = null; int lastDocStyle = -1; bool firstStepSec = true; - // C2021-019: Override the watermark color, stored in the PSI - color list set as combobox in PSI with list of colors - ProcedureConfig pc = myProcedure.MyConfig as ProcedureConfig; - WatermarkOverrideColor = _WatermarkColor; - if (pc != null) + // C2021-019: Override the watermark color, stored in the PSI - color list set as combobox in PSI with list of colors + WatermarkOverrideColor = _WatermarkColor; + if (myProcedure.MyConfig is ProcedureConfig pc) { string clr = pc.GetValue("PSI", "WATERMARKOVERRIDECLR"); if (clr != null && clr != "") WatermarkOverrideColor = clr.ToUpper().Contains("DEFAULT") ? "BLUE" : clr; } - foreach (SectionInfo mySection in myProcedure.Sections) + foreach (SectionInfo mySection in myProcedure.Sections.OfType()) { if(PrtSectID == -1 || (PrtSectID > -1 && mySection.ItemID == PrtSectID) ) { @@ -1020,11 +814,11 @@ namespace Volian.Print.Library _MyHelper.CreatingSupInfoPage = false; _MyHelper.MyPdfContentByte = cb; - if (!mySection.IsStepSection) _MyHelper.PageBookmarks.Add((ItemInfo)mySection, ((mySection.DisplayNumber ?? "") == "" ? "" : mySection.DisplayNumber + " - ") + mySection.DisplayText, null); + if (!mySection.IsStepSection) _MyHelper.PageBookmarks.Add((ItemInfo)mySection, $"{((mySection.DisplayNumber ?? "") == "" ? "" : $"{mySection.DisplayNumber} - ")}{mySection.DisplayText}", null); if (DebugOutput) { // 16-bit background - string procedureFileName = BackgroundFolder + "\\" + PDFFile.Trim();//CreateFileName(myProcedure.DisplayNumber); + string procedureFileName = $"{BackgroundFolder}\\{PDFFile.Trim()}";//CreateFileName(myProcedure.DisplayNumber); FileInfo VEPromsFile = new FileInfo(procedureFileName); if (VEPromsFile.Exists && !doingFoldout) { @@ -1059,7 +853,7 @@ namespace Volian.Print.Library // C2019-039 Remove automatic zoom on Overlay PDFs //_MyHelper.DoZoomOMatic = DebugOutput; _MyHelper.OriginalPageBreak = OriginalPageBreak; - _MyHelper.PROMSVersion = _PromsVersion; //C2018-009 print PROMS version + _MyHelper.PROMSVersion = PromsVersion; //C2018-009 print PROMS version _MyHelper.WatermarkColor = WatermarkOverrideColor; // C2021-019: save the override for the watermark color OnStatusChanged("After Set PageEvent", PromsPrinterStatusType.SetPageEvent); } @@ -1076,7 +870,7 @@ namespace Volian.Print.Library lastDocStyle = (int)mySection.MyDocStyle.Index; LastFmtName = mySection.ActiveFormat.Name; } - if (!mySection.IsStepSection) _MyHelper.PageBookmarks.Add((ItemInfo)mySection, ((mySection.DisplayNumber ?? "") == "" ? "" : mySection.DisplayNumber + " - ") + mySection.DisplayText, null); + if (!mySection.IsStepSection) _MyHelper.PageBookmarks.Add((ItemInfo)mySection, $"{((mySection.DisplayNumber ?? "") == "" ? "" : $"{mySection.DisplayNumber} - ")}{mySection.DisplayText}", null); _MyHelper.MySection = mySection; //OnStatusChanged("After Set Svg", PromsPrinterStatusType.SetSVG); } @@ -1089,28 +883,27 @@ namespace Volian.Print.Library SectionConfig sc = mySection.MyConfig as SectionConfig; if (sc.Section_PhoneList != null && sc.Section_PhoneList == "Y") { - DocVersionConfig dvc = mySection.MyDocVersion.MyConfig as DocVersionConfig; - if (dvc != null) - { - string phlist = dvc.Print_PhoneList; - if (phlist != null && phlist != "") - { - // count lines: - int cl = 0; - int indx = phlist.IndexOf("\n"); - while (indx > 0) - { - cl++; - if (indx + 1 > phlist.Length) - indx = -1; - else - indx = phlist.IndexOf("\n", indx + 1); - } - if (cl == 0) cl = 1; // phone list is a single line without an ending newline - _MyHelper.PhoneListHeight = cl * vlnPrintObject.SixLinesPerInch; - } - } - } + if (mySection.MyDocVersion.MyConfig is DocVersionConfig dvc) + { + string phlist = dvc.Print_PhoneList; + if (phlist != null && phlist != "") + { + // count lines: + int cl = 0; + int indx = phlist.IndexOf("\n"); + while (indx > 0) + { + cl++; + if (indx + 1 > phlist.Length) + indx = -1; + else + indx = phlist.IndexOf("\n", indx + 1); + } + if (cl == 0) cl = 1; // phone list is a single line without an ending newline + _MyHelper.PhoneListHeight = cl * vlnPrintObject.SixLinesPerInch; + } + } + } } _MyHelper.FinalMessageSectionID = finalMessageSectionID; // set VlnSvgPageHelper with the finalMessageSectionID @@ -1121,12 +914,6 @@ namespace Volian.Print.Library InsertBlankPage(cb); } GenerateTOC(mySection, myProcedure, cb, _TextLayer); - // B2020-102: extra page printing after auto TOC for summer. Retested for Farley and was successful also - // F2018-033: Farley Auto TOC. If doing foldouts or supinfo facing pages, add a blank page after also: - //if (myProcedure.ProcHasSupInfoData && InsertBlankPages) // Bug Fix: B2016-181 - add blank page if page count is even - //{ - // InsertBlankPage(cb); - //} } else { @@ -1189,7 +976,7 @@ namespace Volian.Print.Library _MyHelper.MyPdfContentByte.PdfWriter.CurrentPageNumber, "No PROMS Output"); } } - OnStatusChanged(myProcedure.DisplayNumber + " PDF Creation Completed", PromsPrinterStatusType.Progress, progress); + OnStatusChanged($"{myProcedure.DisplayNumber} PDF Creation Completed", PromsPrinterStatusType.Progress, progress); if (DebugPagination.IsOpen) DebugPagination.TotalPages += cb.PdfWriter.CurrentPageNumber; CloseDocument(outputFileName); if (_MyHelper != null && makePlacekeeper) @@ -1233,7 +1020,7 @@ namespace Volian.Print.Library { _MyHelper.OnBlankPage = true; string baselinemsg = "==Insert Blank Page=="; - if (_BlankPageText != null && _BlankPageText != "") // C2019-004: Allow user to define duplex blank page text + if (BlankPageText != null && BlankPageText != "") // C2019-004: Allow user to define duplex blank page text { if (_MyHelper.IsLandscape) // rotate the blank page message on landscaped pages { @@ -1244,11 +1031,11 @@ namespace Volian.Print.Library string bsfontfamily = MyItem.ActiveFormat.PlantFormat.FormatData.StepDataList[0].Font.Family; int bsfontsize = 26; iTextSharp.text.Font font = FontFactory.GetFont(bsfontfamily, BaseFont.IDENTITY_H, BaseFont.EMBEDDED, bsfontsize, iTextSharp.text.Font.NORMAL, new iTextSharp.text.Color(PrintOverride.TextColor)); - PrintTextMessage(cb, _BlankPageText, _TextLayer, font); + PrintTextMessage(cb, BlankPageText, _TextLayer, font); if (_MyHelper.IsLandscape) cb.RestoreState(); // B2019-019: Add the blank page message to the baseline output file. - baselinemsg = string.Format("==Insert Blank Page With Message \"{0}\"==", _BlankPageText); + baselinemsg = string.Format("==Insert Blank Page With Message \"{0}\"==", BlankPageText); } else cb.PdfDocument.Add(new iTextSharp.text.Table(1)); @@ -1263,30 +1050,12 @@ namespace Volian.Print.Library document.AddCreator(string.Format("{0} {1}", Application.ProductName, Application.ProductVersion)); document.AddAuthor(Volian.Base.Library.VlnSettings.UserID); } - private Placekeeper _MyPlacekeeper = null; - public Placekeeper MyPlacekeeper - { - get { return _MyPlacekeeper; } - set { _MyPlacekeeper = value; } - } + public Placekeeper MyPlacekeeper { get; set; } = null; - private ContinuousActionSummary _MyContActSummary = null; + public ContinuousActionSummary MyContActSummary { get; set; } = null; - public ContinuousActionSummary MyContActSummary - { - get { return _MyContActSummary; } - set { _MyContActSummary = value; } - } - - //F2022-024 Time Critical Action Summary - private ContinuousActionSummary _MyTimeCriticalActSummary = null; - - public ContinuousActionSummary MyTimeCriticalActSummary - { - get { return _MyTimeCriticalActSummary; } - set { _MyTimeCriticalActSummary = value; } - } + public ContinuousActionSummary MyTimeCriticalActSummary { get; set; } = null; public void CreateWordDocPdf(PdfContentByte cb, SectionInfo mySection) { @@ -1340,18 +1109,17 @@ namespace Volian.Print.Library } else { - // see if this section will be added to the table of content. This is for sections that - // precede tha actual Automated TOC section. - SectionConfig sc = mySection.MyConfig as SectionConfig; - if (sc != null && sc.Section_TOC == "Y") - { - string tockey = "TOC" + mySection.ItemID.ToString(); - if (!_MyHelper.MyTOCPageNums.ContainsKey(tockey)) - // increment the CurrentTOCPageNumber by 1 since we haven't hit an - // endpage yet, and that's what increments it to the current page number. - _MyHelper.MyTOCPageNums.Add(tockey, _MyHelper.CurrentTOCPageNumber + 1); - } - } + // see if this section will be added to the table of content. This is for sections that + // precede tha actual Automated TOC section. + if (mySection.MyConfig is SectionConfig sc && sc.Section_TOC == "Y") + { + string tockey = $"TOC{mySection.ItemID}"; + if (!_MyHelper.MyTOCPageNums.ContainsKey(tockey)) + // increment the CurrentTOCPageNumber by 1 since we haven't hit an + // endpage yet, and that's what increments it to the current page number. + _MyHelper.MyTOCPageNums.Add(tockey, _MyHelper.CurrentTOCPageNumber + 1); + } + } float origYoff = (float)mySection.MyDocStyle.Layout.TopMargin; bool resetSvgForCont = true; for (int ii = 0; ii < sectPageCount; ii++) @@ -1428,8 +1196,6 @@ namespace Volian.Print.Library Chunk chk = new Chunk(mySection.DisplayNumber, font); chk.SetLocalDestination(string.Format("ItemID={0}", mySection.ItemID)); //Console.WriteLine("++++ ItemID={0}", mySection.ItemID); - //float x1 = cb.PdfDocument.PageSize.Width / 2; - //float y1 = cb.PdfDocument.PageSize.Height ; // 1.8f; float height = 12 * 1.5F; // B2019-102 Locate the chunk below the bottom of the page ct.SetSimpleColumn(0, -height, chk.GetWidthPoint() * 1.01F, -2 * height); @@ -1464,7 +1230,7 @@ namespace Volian.Print.Library if ((float)mySection.MyDocStyle.End.Flag < 0) // Adjust this many lines down the page. { adjMsgY = (float)(-(float)mySection.MyDocStyle.End.Flag * vlnPrintObject.SixLinesPerInch); - if (ylocation - adjMsgY > mySection.MyDocStyle.Layout.FooterLength) ylocation = ylocation - adjMsgY; + if (ylocation - adjMsgY > mySection.MyDocStyle.Layout.FooterLength) ylocation -= adjMsgY; } bool landscape = (mySection.MyDocStyle.StructureStyle.Style & E_DocStructStyle.DSS_WordContentLandscaped) == E_DocStructStyle.DSS_WordContentLandscaped; if (landscape) @@ -1522,7 +1288,7 @@ namespace Volian.Print.Library OnStatusChanged("After NewPage", PromsPrinterStatusType.NewPage); } } - catch (Exception ex) + catch (Exception) { NewPage(); // can we put out 'error on page'? _MyLog.InfoFormat("NewPage error on page {0}", cb.PdfWriter.CurrentPageNumber); @@ -1544,20 +1310,19 @@ namespace Volian.Print.Library else { // Create the list & add this to dictionary, pdf file with page list. - List children = new List(); - children.Add(_MyHelper.CurrentPageNumber); + List children = new List + { + _MyHelper.CurrentPageNumber + }; MergedLandscapePages.Add(tmp, children); } } private void GenerateTOC(SectionInfo tocSection, ProcedureInfo myProcedure, PdfContentByte cb, PdfLayer textLayer) { - iTextSharp.text.pdf.PdfWriter writer = cb.PdfWriter; float _PointsPerPage = PDFPageSize.PaperSizePoints(myProcedure.ActiveFormat.PlantFormat.FormatData.PDFPageSize.PaperSize); // C2020-002 paper size is now set in the format files float yTopMargin = _PointsPerPage - (float)tocSection.MyDocStyle.Layout.TopMargin; - float yBottomMargin = Math.Max(0, yTopMargin - (float)tocSection.MyDocStyle.Layout.PageLength); // - 2 * vlnPrintObject.SixLinesPerInch); if (textLayer != null) cb.BeginLayer(textLayer); TableOfContentsData tOfC = tocSection.ActiveFormat.PlantFormat.FormatData.SectData.AccSectionData.TableOfContentsData; - //ItemInfo procItem = ItemInfo.Get(myProcedure.ItemID); ItemInfo procItem = myProcedure; lastyLocation = 0; AddSectionToTOC(tocSection, procItem, tOfC, cb, yTopMargin, 0, false); // add all of the marked sections and sub-sections to the table of contents @@ -1567,11 +1332,8 @@ namespace Volian.Print.Library _NoBreakYOffset = 0; } float lastyLocation = 0; - private string GetRtfToC(string txt, TableOfContentsData tOfCData) - { - return GetRtfToC(txt, tOfCData, null); - } - private string GetRtfToC(string txt, TableOfContentsData tOfCData, VE_Font overrideFont) + private string GetRtfToC(string txt, TableOfContentsData tOfCData) => GetRtfToC(txt, tOfCData, null); + private string GetRtfToC(string txt, TableOfContentsData tOfCData, VE_Font overrideFont) { StringBuilder _RtfSB = new StringBuilder(); VEPROMS.CSLA.Library.DisplayText toctxt = new VEPROMS.CSLA.Library.DisplayText(txt, tOfCData.Font, false); @@ -1610,11 +1372,10 @@ namespace Volian.Print.Library { int sectCnt = 0; // keep count of which section/sub-section we are processing bool doSubY = false; - int level = 0; - // C2018-004 create meta file for baseline compares - Volian.Base.Library.BaselineMetaFile.WriteLine("TOC Ystart {0} LeftMar {1} ScNmPos {2} ScTtlPos {3} ScPgPos {4}", yPageStart, leftMargin, secNumPos, secTitlePos, secPagePos); + // C2018-004 create meta file for baseline compares + Volian.Base.Library.BaselineMetaFile.WriteLine("TOC Ystart {0} LeftMar {1} ScNmPos {2} ScTtlPos {3} ScPgPos {4}", yPageStart, leftMargin, secNumPos, secTitlePos, secPagePos); bool inGroup = false; - foreach (SectionInfo mySection in ii.Sections) + foreach (SectionInfo mySection in ii.Sections.OfType()) { if (PrtSectID == -1 || (PrtSectID > -1 && mySection.ItemID == PrtSectID)) { @@ -1623,10 +1384,10 @@ namespace Volian.Print.Library if ((mySection.MyDocStyle != null && mySection.MyDocStyle.IncludeInTOC && (sc == null || sc.Section_TOC != "Y")) || ((mySection.MyDocStyle == null || !mySection.MyDocStyle.IncludeInTOC) && (sc != null && sc.Section_TOC == "Y"))) { - // for indenting of subsections, count up tree. Only start indenting - // at third level, i.e. not indent on 1.0 and 1.1, but indent on 1.1.1: - level = 0; - ItemInfo iilvl = mySection as ItemInfo; + // for indenting of subsections, count up tree. Only start indenting + // at third level, i.e. not indent on 1.0 and 1.1, but indent on 1.1.1: + int level = 0; + ItemInfo iilvl = mySection as ItemInfo; while (!iilvl.IsProcedure) { level++; @@ -1705,7 +1466,6 @@ namespace Volian.Print.Library // Do the title first since it may wrap to 2nd line and this is an issue for // doing a pagebreak, i.e. may cause a page break when the number on a single line // would not. - //if (tocSection.ActiveFormat.PlantFormat.FormatData.SectData.AccSectionData.TableOfContentsData if (level == 0 && tocSection.ActiveFormat.PlantFormat.FormatData.SectData.AccSectionData.TableOfContentsData.TofCUnderlineFirstLevelTitle) { VE_Font ovrFont = new VE_Font(tOfC.Font.Family, (int)tOfC.Font.Size, (E_Style)tOfC.Font.Style | E_Style.Underline, (float)tOfC.Font.CPI); @@ -1737,7 +1497,6 @@ namespace Volian.Print.Library _MyHelper.ResetSvg(); // needed to reset so that PSNotFirst pagelist justify flag gets used for BGE yLocation = lastyLocation = 0; } - //if (yLocation > 0) yLocation += vlnPrintObject.SixLinesPerInch;// commented out for B2016-200 // for two blank line between last TOC title and the new grouping title float rtnval = Rtf2Pdf.TextAt(cb, myparagraphGrpTitle, leftMargin + secNumPos, yPageStart - yLocation, w, height, "", yBottomMargin); // print the Group Title yLocation += vlnPrintObject.SixLinesPerInch; // for two blank line between last TOC title and the new grouping title - added for B2016-200 if (lnsp > -1) yLocation += (lnaftergroup * vlnPrintObject.SixLinesPerInch); // new line @@ -1758,8 +1517,6 @@ namespace Volian.Print.Library // is put out. retval = Rtf2Pdf.TextAt(cb, myparagraphSecNum, leftMargin + secNumPos + indentOffset, yPageStart - yLocation, numwidth * 1.3F, height, "", yBottomMargin); - //float lSpace = (float)(tOfC.TofCLineSpacing ?? 1) * vlnPrintObject.SixLinesPerInch; - // adjust ylocation for pagenumber - the ylocation will get reset if the // section title split on 2 lines and the page number needs to be on the 2nd line. // Only do this if the title is not empty (the code was meant for if title spans more than a line) @@ -1811,7 +1568,7 @@ namespace Volian.Print.Library spacchrwid += chkt.GetWidthPoint(); while (numSpace > 6) { - spaceStr = spaceStr + tOfC.TofCSpaceChar; + spaceStr += tOfC.TofCSpaceChar; numSpace -= spacchrwid; } @@ -1836,13 +1593,9 @@ namespace Volian.Print.Library } //If the format wants single spacing within subsections (2nd level and lower), then need to figure out // spacing (vcb1 table of contents) - //bool dosuby = (((tocSection.ActiveFormat.PlantFormat.FormatData.SectData.AccSectionData.TableOfContentsData.TofCLineSpacingSub ?? 1) > 0) - // && (mySection.MyParent.IsSection && ((mySection.Sections != null && mySection.Sections.Count > 0) || (level > 0 && mySection.NextItem != null)))) - // || didGrp; doSubY = (((tocSection.ActiveFormat.PlantFormat.FormatData.SectData.AccSectionData.TableOfContentsData.TofCLineSpacingSub ?? 1) > 0) && (mySection.MyParent.IsSection && (/* mySection.Sections == null && */ sectCnt < ii.Sections.Count))) // B2016-205 || didGrp; - //float spc = (float)(tOfC.TofCLineSpacing ?? 1); if (doSubY) { float spcs = (float)(tOfC.TofCLineSpacingSub ?? 1); @@ -1871,7 +1624,7 @@ namespace Volian.Print.Library // table of contents for this section, format flag & section has steps: if (mySection.ActiveFormat.PlantFormat.FormatData.SectData.AccSectionData.TableOfContentsData.TofCAllowHLS && mySection.IsStepSection && mySection.Steps != null && mySection.Steps.Count > 0) - yLocation = AddHLSToTOC(tocSection, mySection, tOfC, cb, yPageStart, yLocation, doSubY, level + 1, adjSecTitlePos); + yLocation = AddHLSToTOC(tocSection, mySection, tOfC, cb, yPageStart, yLocation, level + 1, adjSecTitlePos); } float savYLoc = yLocation; yLocation = AddSectionToTOC(tocSection, mySection, tOfC, cb, yPageStart, yLocation, doSubY); @@ -1890,7 +1643,7 @@ namespace Volian.Print.Library return yLocation; } // C2021-015: Barakah High Level Steps in Table of Contents - private float AddHLSToTOC(SectionInfo tocSection, ItemInfo ii, TableOfContentsData tOfC, PdfContentByte cb, float yPageStart, float yLocation, bool didSubSecLineSpacing, int level, float parTitleXOff) + private float AddHLSToTOC(SectionInfo tocSection, ItemInfo ii, TableOfContentsData tOfC, PdfContentByte cb, float yPageStart, float yLocation, int level, float parTitleXOff) { // if section is not in TOC, don't add the HLSs SectionConfig sc = ii.ActiveSection.MyConfig as SectionConfig; @@ -1922,122 +1675,121 @@ namespace Volian.Print.Library float numwidth = 0; foreach (ItemInfo hls in ii.Steps) // Ouput each HLS that has config flag to include it. { - StepConfig stc = hls.MyConfig as StepConfig; - if (stc != null && stc.Step_IncludeInTOC) - { - float yBottomMargin = yPageStart - (float)tocSection.MyDocStyle.Layout.PageLength + (2 * vlnPrintObject.SixLinesPerInch); + if (hls.MyConfig is StepConfig stc && stc.Step_IncludeInTOC) + { + float yBottomMargin = yPageStart - (float)tocSection.MyDocStyle.Layout.PageLength + (2 * vlnPrintObject.SixLinesPerInch); - // need to do the step number, title & page number. Page number has to be put on at end after number of page is known, so use a Template. - string tmptxt = hls.MyTab.CleanText; - if (tmptxt == null || tmptxt == "") tmptxt = " "; // if no number set to blanks. Without this, low level printing gets confused - string rtfText = GetRtfToC(tmptxt, tOfC); - Paragraph myparagraphStepNum = vlnPrintObject.RtfToParagraph(rtfText); - float width = 0; - foreach (Chunk chkt in myparagraphStepNum.Chunks) - width += chkt.GetWidthPoint(); - if (numwidth == 0) numwidth = width; // keep same xoffset for step text unless overwriting by number (see below) - Rtf2Pdf.Offset = new PointF(0, 2.5F); + // need to do the step number, title & page number. Page number has to be put on at end after number of page is known, so use a Template. + string tmptxt = hls.MyTab.CleanText; + if (tmptxt == null || tmptxt == "") tmptxt = " "; // if no number set to blanks. Without this, low level printing gets confused + string rtfText = GetRtfToC(tmptxt, tOfC); + Paragraph myparagraphStepNum = vlnPrintObject.RtfToParagraph(rtfText); + float width = 0; + foreach (Chunk chkt in myparagraphStepNum.Chunks) + width += chkt.GetWidthPoint(); + if (numwidth == 0) numwidth = width; // keep same xoffset for step text unless overwriting by number (see below) + Rtf2Pdf.Offset = new PointF(0, 2.5F); - // if the starting column of text would be in 'middle of' the number, just put it - // a few spaces after the number. The '182' below represents 2 chars. - float adjStepTitlePos = indentOffset + numwidth + 6; - if (width + indentOffset > adjStepTitlePos) - { - adjStepTitlePos = numwidth + 12 + indentOffset; - numwidth = width; - } + // if the starting column of text would be in 'middle of' the number, just put it + // a few spaces after the number. The '182' below represents 2 chars. + float adjStepTitlePos = indentOffset + numwidth + 6; + if (width + indentOffset > adjStepTitlePos) + { + adjStepTitlePos = numwidth + 12 + indentOffset; + numwidth = width; + } - string tocStepTitle = hls.FormattedDisplayText; - tocStepTitle = ConvertSpecialChars(tocStepTitle, ii.ActiveFormat.PlantFormat.FormatData); // B2019-172 process symbol characters - rtfText = GetRtfToC(tocStepTitle, tOfC); - Paragraph myparagraphStepTitle = vlnPrintObject.RtfToParagraph(rtfText); - width = stepPagePos - adjStepTitlePos - ((tOfC.TofCPageNumAlign.ToUpper() == "RIGHT") ? 18 : 6);// B2021-109 proper adjustment of section title width - copied from leader dots lenth calcuation below - float savTitleWid = width; - // Print the step text - float retval = Rtf2Pdf.TextAt(cb, myparagraphStepTitle, leftMargin + ((tOfC.TofCSecNumPos == tOfC.TofCSecTitlePos && tmptxt.Equals(" ")) ? stepNumPos : adjStepTitlePos), yPageStart - yLocation, width, height, "", yBottomMargin); - if (retval == 0) // couldn't fit, flags need for a page break. - { - NewPage(); - _MyHelper.ResetSvg(); // needed to reset so that PSNotFirst pagelist justify flag gets used for BGE - yLocation = lastyLocation = 0; - retval = Rtf2Pdf.TextAt(cb, myparagraphStepTitle, leftMargin + adjStepTitlePos, yPageStart - yLocation, width, height, "", yBottomMargin); - } - float ttlRetval = retval; - float savTitleFillWidth = Rtf2Pdf.FillWidth; + string tocStepTitle = hls.FormattedDisplayText; + tocStepTitle = ConvertSpecialChars(tocStepTitle, ii.ActiveFormat.PlantFormat.FormatData); // B2019-172 process symbol characters + rtfText = GetRtfToC(tocStepTitle, tOfC); + Paragraph myparagraphStepTitle = vlnPrintObject.RtfToParagraph(rtfText); + width = stepPagePos - adjStepTitlePos - ((tOfC.TofCPageNumAlign.ToUpper() == "RIGHT") ? 18 : 6);// B2021-109 proper adjustment of section title width - copied from leader dots lenth calcuation below + float savTitleWid = width; + // Print the step text + float retval = Rtf2Pdf.TextAt(cb, myparagraphStepTitle, leftMargin + ((tOfC.TofCSecNumPos == tOfC.TofCSecTitlePos && tmptxt.Equals(" ")) ? stepNumPos : adjStepTitlePos), yPageStart - yLocation, width, height, "", yBottomMargin); + if (retval == 0) // couldn't fit, flags need for a page break. + { + NewPage(); + _MyHelper.ResetSvg(); // needed to reset so that PSNotFirst pagelist justify flag gets used for BGE + yLocation = lastyLocation = 0; + retval = Rtf2Pdf.TextAt(cb, myparagraphStepTitle, leftMargin + adjStepTitlePos, yPageStart - yLocation, width, height, "", yBottomMargin); + } + float ttlRetval = retval; + float savTitleFillWidth = Rtf2Pdf.FillWidth; - // Now do the step number. Retval is the ylocation on page after the text is put out - retval = Rtf2Pdf.TextAt(cb, myparagraphStepNum, leftMargin + indentOffset, yPageStart - yLocation, numwidth * 1.3F, height, "", yBottomMargin); - if (retval != ttlRetval) yLocation += (retval - ttlRetval); + // Now do the step number. Retval is the ylocation on page after the text is put out + retval = Rtf2Pdf.TextAt(cb, myparagraphStepNum, leftMargin + indentOffset, yPageStart - yLocation, numwidth * 1.3F, height, "", yBottomMargin); + if (retval != ttlRetval) yLocation += (retval - ttlRetval); - // retval = the minimum (further down the page) between step number & text - accounts for multi line step - retval = Math.Min(retval, ttlRetval); - lastyLocation = retval; + // retval = the minimum (further down the page) between step number & text - accounts for multi line step + retval = Math.Min(retval, ttlRetval); + lastyLocation = retval; - // add a template for the page number: - // if the space character is not null & is not a space, the we've got to put out - // these between the section title & the page number - if (tOfC.TofCSpaceChar != null && tOfC.TofCSpaceChar != "" && tOfC.TofCSpaceChar != " ") - { - width = 0; - foreach (Chunk chkt in myparagraphStepTitle.Chunks) - width += chkt.GetWidthPoint(); + // add a template for the page number: + // if the space character is not null & is not a space, the we've got to put out + // these between the section title & the page number + if (tOfC.TofCSpaceChar != null && tOfC.TofCSpaceChar != "" && tOfC.TofCSpaceChar != " ") + { + width = 0; + foreach (Chunk chkt in myparagraphStepTitle.Chunks) + width += chkt.GetWidthPoint(); - // get height - if two lines high, need width of 2nd line for adding - // space characters - float heightTtl = vlnPrintObject.GetHeight(cb, myparagraphStepTitle, string.Empty, savTitleWid, false); - string spaceStr = ""; - float startSpace = 0; - // the '6's in the next few code lines & in the 'while' loop below allows the placement of the dots (or other space character) - // to be not too close to section title & page number. - if (heightTtl > vlnPrintObject.SixLinesPerInch) - { - // this title is 2 or more lines, find start of leader dots by determining length of text - // on 2nd line (the savTitleFillWidth is the widest line of the split title) - float secondLineWidth = width - savTitleFillWidth; - startSpace = leftMargin + adjStepTitlePos + secondLineWidth + 6; - } - else - startSpace = leftMargin + adjStepTitlePos + width + 6; - // If the page number is Right justified, need less space characters ('.') so that page number - // doesn't have the last space character overwriting the 1st digit: - int endJust = (tOfC.TofCPageNumAlign.ToUpper() == "RIGHT") ? 18 : 6; + // get height - if two lines high, need width of 2nd line for adding + // space characters + float heightTtl = vlnPrintObject.GetHeight(cb, myparagraphStepTitle, string.Empty, savTitleWid, false); + string spaceStr = ""; + float startSpace = 0; + // the '6's in the next few code lines & in the 'while' loop below allows the placement of the dots (or other space character) + // to be not too close to section title & page number. + if (heightTtl > vlnPrintObject.SixLinesPerInch) + { + // this title is 2 or more lines, find start of leader dots by determining length of text + // on 2nd line (the savTitleFillWidth is the widest line of the split title) + float secondLineWidth = width - savTitleFillWidth; + startSpace = leftMargin + adjStepTitlePos + secondLineWidth + 6; + } + else + startSpace = leftMargin + adjStepTitlePos + width + 6; + // If the page number is Right justified, need less space characters ('.') so that page number + // doesn't have the last space character overwriting the 1st digit: + int endJust = (tOfC.TofCPageNumAlign.ToUpper() == "RIGHT") ? 18 : 6; - float endSpace = leftMargin + stepPagePos - endJust; - float numSpace = endSpace - startSpace; - rtfText = GetRtfToC(tOfC.TofCSpaceChar, tOfC); - Paragraph tmpmyparagraph = vlnPrintObject.RtfToParagraph(rtfText); - float spacchrwid = 0; - foreach (Chunk chkt in tmpmyparagraph.Chunks) - spacchrwid += chkt.GetWidthPoint(); - while (numSpace > 6) - { - spaceStr = spaceStr + tOfC.TofCSpaceChar; - numSpace -= spacchrwid; - } + float endSpace = leftMargin + stepPagePos - endJust; + float numSpace = endSpace - startSpace; + rtfText = GetRtfToC(tOfC.TofCSpaceChar, tOfC); + Paragraph tmpmyparagraph = vlnPrintObject.RtfToParagraph(rtfText); + float spacchrwid = 0; + foreach (Chunk chkt in tmpmyparagraph.Chunks) + spacchrwid += chkt.GetWidthPoint(); + while (numSpace > 6) + { + spaceStr += tOfC.TofCSpaceChar; + numSpace -= spacchrwid; + } - rtfText = GetRtfToC(spaceStr, tOfC); // out the leader dots - Paragraph myparagraphs = vlnPrintObject.RtfToParagraph(rtfText); - retval = Rtf2Pdf.TextAt(cb, myparagraphs, startSpace, yPageStart - yLocation, endSpace - startSpace, height, "", yBottomMargin); - } - // if in the pre-table of content list, just put the page number out as text. - // otherwise, add a template _MyHelper.MyTOCPageCounts - string key = "TOC" + hls.ItemID.ToString(); - if (ii.IsAutoTOCSection || _MyHelper.MyTOCPageNums.ContainsKey(key)) - { - string pnum = _MyHelper.MyTOCPageNums.ContainsKey(key) ? _MyHelper.MyTOCPageNums[key].ToString() : (_MyHelper.CurrentTOCPageNumber + 1).ToString(); - rtfText = GetRtfToC(pnum, tOfC); - Paragraph myparagraphp = vlnPrintObject.RtfToParagraph(rtfText); - width = pnum.Length * 6; - retval = Rtf2Pdf.TextAt(cb, myparagraphp, leftMargin + stepPagePos, yPageStart - yLocation, width, height, "", yBottomMargin); - } - else - AddTemplateTOCPageCounts(tOfC, yLocation, yPageStartAdj, leftMargin, stepPagePos, height, key); + rtfText = GetRtfToC(spaceStr, tOfC); // out the leader dots + Paragraph myparagraphs = vlnPrintObject.RtfToParagraph(rtfText); + retval = Rtf2Pdf.TextAt(cb, myparagraphs, startSpace, yPageStart - yLocation, endSpace - startSpace, height, "", yBottomMargin); + } + // if in the pre-table of content list, just put the page number out as text. + // otherwise, add a template _MyHelper.MyTOCPageCounts + string key = $"TOC{hls.ItemID}"; + if (ii.IsAutoTOCSection || _MyHelper.MyTOCPageNums.ContainsKey(key)) + { + string pnum = _MyHelper.MyTOCPageNums.ContainsKey(key) ? _MyHelper.MyTOCPageNums[key].ToString() : (_MyHelper.CurrentTOCPageNumber + 1).ToString(); + rtfText = GetRtfToC(pnum, tOfC); + Paragraph myparagraphp = vlnPrintObject.RtfToParagraph(rtfText); + width = pnum.Length * 6; + retval = Rtf2Pdf.TextAt(cb, myparagraphp, leftMargin + stepPagePos, yPageStart - yLocation, width, height, "", yBottomMargin); + } + else + AddTemplateTOCPageCounts(tOfC, yLocation, yPageStartAdj, leftMargin, stepPagePos, height, key); - float spc = (float)(tOfC.TofCLineSpacing ?? 1); - yLocation += (spc * vlnPrintObject.SixLinesPerInch); - } + float spc = (float)(tOfC.TofCLineSpacing ?? 1); + yLocation += (spc * vlnPrintObject.SixLinesPerInch); + } - } + } return yLocation; } //B2019-172 This will add the RTF font commands around the symbol characters @@ -2070,165 +1822,11 @@ namespace Volian.Print.Library PdfTemplate tmp = _MyHelper.MyTOCPageCounts.AddToTemplateList(key, _MyHelper.MyPdfWriter, "{TOCPAGE}", tOfC.Font.WindowsFont, (tOfC.TofCPageNumAlign.ToUpper() == "RIGHT") ? Element.ALIGN_RIGHT : Element.ALIGN_LEFT, PrintOverride.TextColor); _MyHelper.MyPdfContentByte.AddTemplate(tmp, leftMargin + secPagePos, (yPageStartAdj - yLocation) - height / 2); } - - //private string GetRtfPlacekeeper(string txt, PlacekeeperData pkCData) - //{ - // StringBuilder _RtfSB = new StringBuilder(); - // Volian.Controls.Library.DisplayText pktxt = new Volian.Controls.Library.DisplayText(txt, pkCData.Font, false); - // System.Drawing.Font myFont = pktxt.TextFont.WindowsFont; - // _RtfSB.Append(vlnPrintObject.AddFontTable(myFont)); - // _RtfSB.Append(pktxt.StartText); - // _RtfSB.Append("}"); - // return _RtfSB.ToString(); - //} - //private float AddSectionToPK(SectionInfo pkSection, ItemInfo ii, PlacekeeperData pkData, PdfContentByte cb, float yPageStart, float yLocation) - //{ - // SectionConfig pkSC = pkSection.MyConfig as SectionConfig; - // if (pkSC.Section_Placekeeper != "Y") return yLocation; // automatic generation of Placekeeper turned off - // float xAdjNumber = -6 + 1.2F; - // float xAdjTitle = .8F + 1.2F; - // float xAdjTitleIndent = -6 + 2.4F; - // float yadj = 0.5F; // tweak to get 16 & 32 bit output to match. - - // float yPageStartAdj = yPageStart - yadj; - // float leftMargin = (float)pkSection.MyDocStyle.Layout.LeftMargin; - // //float secNumPos = (float)tOfC.TofCSecNumPos + xAdjNumber; - // //float secTitlePos = (float)tOfC.TofCSecTitlePos + xAdjTitle; - // //float secPagePos = (float)tOfC.TofCPageNumPos + xAdjNumber; - // //float height = tOfC.Font.WindowsFont.Size * 1.5F; - // if (ii.Sections != null) - // { - // foreach (SectionInfo mySection in ii.Sections) - // { - // SectionConfig sc = mySection.MyConfig as SectionConfig; - // if (mySection.ItemID != pkSection.ItemID && sc != null && sc.Section_Placekeeper == "Y") - // { - // // Look at each step in the section and build a Placekeeper for those steps that are marked - - // // need to do the section number, section title & page number. Page number - // // has to be put on at end after number of page is known, so use a Template. - // //string tmptxt = mySection.MyContent.Number == null || mySection.MyContent.Number == "" ? " " : mySection.MyContent.Number; - // //string rtfText = GetRtfPlacekeeper(tmptxt, pkData);//GetRtfToC(tmptxt, tOfC); - // //Paragraph myparagraphn = vlnPrintObject.RtfToParagraph(rtfText); - // float width = 0; - // //foreach (Chunk chkt in myparagraphn.Chunks) - // // width += chkt.GetWidthPoint(); - // float numwidth = width; - // float yBottomMargin = yPageStart - (float)pkSection.MyDocStyle.Layout.PageLength + (2 * vlnPrintObject.SixLinesPerInch); - // Rtf2Pdf.Offset = new PointF(0, 2.5F); - - // //// for indenting of subsections, count up tree. Only start indenting - // //// at third level, i.e. not indent on 1.0 and 1.1, but indent on 1.1.1: - // //int level = 0; - // //ItemInfo iilvl = mySection as ItemInfo; - // //while (!iilvl.IsProcedure) - // //{ - // // level++; - // // iilvl = iilvl.MyParent; - // //} - // //// check what level the plant wants the auto ToC indented: - // //int tofCNumLevels = pkSection.ActiveFormat.PlantFormat.FormatData.SectData.AccSectionData.TableOfContentsData.TofCNumLevels ?? 0; - // //if (tofCNumLevels > 0 && level > tofCNumLevels) return yLocation; - - // //level = level <= 2 ? 0 : level - 2; // no indenting until third level - // //float indentOffset = (level * (secTitlePos - secNumPos)); - - // // if the starting column of text would be in 'middle of' the number, just put it - // // a few spaces after the number. The '18' below represents 3 chars. - // //float adjSecTitlePos = secTitlePos + indentOffset + (level * 6); - // //if (secNumPos + numwidth + indentOffset > secTitlePos + indentOffset) - // // adjSecTitlePos = secNumPos + numwidth + 18 - xAdjTitleIndent + indentOffset; - // //rtfText = GetRtfToC(mySection.MyContent.Text, tOfC); - // //Paragraph myparagrapht = vlnPrintObject.RtfToParagraph(rtfText); - // //width = secPagePos - adjSecTitlePos - 6; - // //float retval = Rtf2Pdf.TextAt(cb, myparagrapht, leftMargin + adjSecTitlePos, yPageStart - yLocation, width, height, "", yBottomMargin); - // //float ttlRetval = retval; - // //if (retval == 0) - // //{ - // // cb.PdfDocument.NewPage(); - // // //_MyLog.InfoFormat("NewPage 5 {0}", cb.PdfWriter.CurrentPageNumber); - // // yLocation = lastyLocation = 0; - // // retval = Rtf2Pdf.TextAt(cb, myparagrapht, leftMargin + adjSecTitlePos, yPageStart - yLocation, width, height, "", yBottomMargin); - // // ttlRetval = retval; - // //} - // //retval = Rtf2Pdf.TextAt(cb, myparagraphn, leftMargin + secNumPos + indentOffset, yPageStart - yLocation, width * 1.3F, height, "", yBottomMargin); - // //if (retval == 0) // do a newpage, it couldn't fit on current page. - // //{ - // // cb.PdfDocument.NewPage(); - // // //_MyLog.InfoFormat("NewPage 5 {0}", cb.PdfWriter.CurrentPageNumber); - // // yLocation = lastyLocation = 0; - // // retval = Rtf2Pdf.TextAt(cb, myparagraphn, leftMargin + secNumPos + indentOffset, yPageStart - yLocation, width * 1.3F, height, "", yBottomMargin); - // //} - // //retval = Math.Min(retval, ttlRetval); - // //float lSpace = (tOfC.TofCLineSpacing == 2) ? 2 * vlnPrintObject.SixLinesPerInch : vlnPrintObject.SixLinesPerInch; - // //if (lastyLocation != 0 && ((lastyLocation - retval) > lSpace)) - // // yLocation += (lastyLocation - retval - lSpace); - // //lastyLocation = retval; - - // //// check that the page number should be in the TOC (some BGE sections do not have the page number) - // //if (!((mySection.MyDocStyle.StructureStyle.Style & E_DocStructStyle.DontNumberInTOC) == E_DocStructStyle.DontNumberInTOC)) - // //{ - // // // add a template for the page number: - // // // if the space character is not null & is not a space, the we've got to put out - // // // these between the section title & the page number - // // if (tOfC.TofCSpaceChar != null && tOfC.TofCSpaceChar != "" && tOfC.TofCSpaceChar != " ") - // // { - // // width = 0; - // // foreach (Chunk chkt in myparagrapht.Chunks) - // // width += chkt.GetWidthPoint(); - // // float startSpace = leftMargin + adjSecTitlePos + width; - // // float endSpace = leftMargin + secPagePos; - // // float numSpace = endSpace - startSpace; - // // string spaceStr = ""; - // // rtfText = GetRtfToC(tOfC.TofCSpaceChar, tOfC); - // // Paragraph tmpmyparagraph = vlnPrintObject.RtfToParagraph(rtfText); - // // float spacchrwid = 0; - // // foreach (Chunk chkt in tmpmyparagraph.Chunks) - // // spacchrwid += chkt.GetWidthPoint(); - // // while (numSpace > 0) - // // { - // // spaceStr = spaceStr + tOfC.TofCSpaceChar; - // // numSpace -= spacchrwid; - // // } - // // rtfText = GetRtfToC(spaceStr, tOfC); - // // Paragraph myparagraphs = vlnPrintObject.RtfToParagraph(rtfText); - // // retval = Rtf2Pdf.TextAt(cb, myparagraphs, startSpace, yPageStart - yLocation, endSpace - startSpace, height, "", yBottomMargin); - // // } - // // // if in the pre-table of content list, just put the page number out as text. - // // // otherwise, add a template _MyHelper.MyTOCPageCounts - // // string key = "TOC" + mySection.ItemID.ToString(); - // // if (mySection.IsAutoTOCSection || _MyHelper.MyTOCPageNums.ContainsKey(key)) - // // { - // // string pnum = _MyHelper.MyTOCPageNums.ContainsKey(key) ? _MyHelper.MyTOCPageNums[key].ToString() : (_MyHelper.CurrentTOCPageNumber + 1).ToString(); - // // rtfText = GetRtfToC(pnum, tOfC); - // // Paragraph myparagraphp = vlnPrintObject.RtfToParagraph(rtfText); - // // width = pnum.Length * 6; - // // retval = Rtf2Pdf.TextAt(cb, myparagraphp, leftMargin + secPagePos, yPageStart - yLocation, width, height, "", yBottomMargin); - // // } - // // else - // // AddTemplateTOCPageCounts(tOfC, yLocation, yPageStartAdj, leftMargin, secPagePos, height, mySection); - // //} - - // yLocation += vlnPrintObject.SixLinesPerInch; - // } - // //yLocation = AddSectionToTOC(tocSection, mySection, tOfC, cb, yPageStart, yLocation); - // } - // } - // return yLocation; - //} - - //private void AddTemplatePKPageCounts(TableOfContentsData tOfC, float yLocation, float yPageStartAdj, float leftMargin, float secPagePos, float height, SectionInfo mySection) - //{ - // string key = "PK" + mySection.ItemID.ToString(); - // PdfTemplate tmp = _MyHelper.MyTOCPageCounts.AddToTemplateList(key, _MyHelper.MyPdfWriter, "{TOCPAGE}", tOfC.Font.WindowsFont, Element.ALIGN_LEFT, PrintOverride.TextColor); - // _MyHelper.MyPdfContentByte.AddTemplate(tmp, leftMargin + secPagePos, (yPageStartAdj - yLocation) - height / 2); - //} private static void PrintTextMessage(PdfContentByte cb, string message, PdfLayer textLayer, iTextSharp.text.Font font) { if (textLayer != null) cb.BeginLayer(textLayer); float fontSize = font.Size; ColumnText ct = new ColumnText(cb); - //iTextSharp.text.Font font = FontFactory.GetFont("Arial", BaseFont.IDENTITY_H, BaseFont.EMBEDDED, fontSize,iTextSharp.text.Font.NORMAL, new iTextSharp.text.Color(PrintOverride.TextColor)); Chunk chk = new Chunk(message, font); float xCenter = cb.PdfDocument.PageSize.Width / 2; float yCenter = cb.PdfDocument.PageSize.Height / 2; // 1.8f; @@ -2242,12 +1840,10 @@ namespace Volian.Print.Library if (textLayer != null) cb.EndLayer(); } private float _NoBreakYOffset = 0; - private float _NoBreakYPageStart = 0; private void CreateStepPdf(SectionInfo section, PdfContentByte cb) { int profileDepth = ProfileTimer.Push(">>>> CreateStepPdf"); //PrintTimer pt = new PrintTimer(); - iTextSharp.text.pdf.PdfWriter writer = cb.PdfWriter; ItemInfo myItemInfo = section as ItemInfo; if (SupInfoPrintType == E_SupInfoPrintType.DoPageBreaks) { @@ -2283,6 +1879,7 @@ namespace Volian.Print.Library _MyHelper.ChangeBarDefinition = MyChangeBarDefinition; //pt.Description = "vlnParagrph"; vlnParagraph myParagraph = new vlnParagraph(null, cb, myItemInfo, (float)myItemInfo.MyDocStyle.Layout.LeftMargin, _NoBreakYOffset, 0, myItemInfo.ColumnMode, myItemInfo.ActiveFormat, null, null, 0, true, this); + //For Testing: //pt.Description = "After vlnParagrph"; //if (myParagraph.MyItemInfo.InList(15906)) //{ @@ -2327,16 +1924,15 @@ namespace Volian.Print.Library // i.e. no page break between them. if (section.IsStepSection && nxtItem.IsStepSection) { - SectionInfo si = nxtItem as SectionInfo; - // B2017-201 if si is null we need to get it via the ItemID - if (si == null) - si = SectionInfo.Get(nxtItem.ItemID); //ActiveSection as SectionInfo; - SectionConfig sc = si.SectionConfig; + // B2017-201 if si is null we need to get it via the ItemID + if (!(nxtItem is SectionInfo si)) + si = SectionInfo.Get(nxtItem.ItemID); //ActiveSection as SectionInfo; + SectionConfig sc = si.SectionConfig; try { if (sc != null) sp = sc.Section_Pagination; } - catch (Exception ex) + catch (Exception) { sp = SectionConfig.SectionPagination.Separate; } @@ -2351,9 +1947,8 @@ namespace Volian.Print.Library NewPage(true); // end of step section //_MyLog.InfoFormat("NewPage 6 {0}", cb.PdfWriter.CurrentPageNumber); _NoBreakYOffset = 0; - yPageStart = yTopMargin; - } - else + } + else { if (nxtItem != null && nxtItem.MyPrevious != null && nxtItem.ActiveFormat.PlantFormat.FormatData.SectData.SectionHeader.Level0Big) localYPageStart -= 12; @@ -2367,8 +1962,7 @@ namespace Volian.Print.Library _NoBreakYOffset = myParagraph.YBottomMost; float yOffset = localYPageStart - yTopMargin; _NoBreakYOffset -= yOffset; - yPageStart = localYPageStart; - Volian.Base.Library.DebugText.WriteLine("NOBREAK:{0},'{1}','{2}','{3}','{4}','{5}'", section.ItemID, tmplocal, yTopMargin, localYPageStart, _NoBreakYOffset, myParagraph.YBottomMost); + Volian.Base.Library.DebugText.WriteLine("NOBREAK:{0},'{1}','{2}','{3}','{4}','{5}'", section.ItemID, tmplocal, yTopMargin, localYPageStart, _NoBreakYOffset, myParagraph.YBottomMost); } OnStatusChanged("StepSection converted to PDF " + section.ShortPath, PromsPrinterStatusType.BuildStep); //pt.Description = "End"; @@ -2387,7 +1981,7 @@ namespace Volian.Print.Library iTextSharp.text.Rectangle pageSize = PDFPageSize.UsePaperSize(MyItem.ActiveFormat.PlantFormat.FormatData.PDFPageSize.PaperSize); // C2020-002 paper size is now set in the format files PdfContentByte cb = OpenDoc(ref SupInfoPdfName, pageSize); if (cb == null) return; - VlnSvgPageHelper myPageHelper = new VlnSvgPageHelper(vlnParagraph.MyItemInfo as SectionInfo, this, null, 0, _prtSectID); + VlnSvgPageHelper myPageHelper = new VlnSvgPageHelper(vlnParagraph.MyItemInfo as SectionInfo, this, null, 0, PrtSectID); cb.PdfWriter.PageEvent = myPageHelper; myPageHelper.AllowAllWatermarks = AllowAllWatermarks; myPageHelper.MyPdfWriter = cb.PdfWriter; @@ -2451,7 +2045,7 @@ namespace Volian.Print.Library // Binary Search to find proper font size within .1 while (decrement > .1f) { - decrement = decrement / 2f; //Reduce the decrement by half + decrement /= 2f; //Reduce the decrement by half if (mpglen > pageLength) // If the measured length is too big newFontSize -= decrement;// Reduce the font size else @@ -2466,9 +2060,10 @@ namespace Volian.Print.Library newFontSize -= decrement;// Reduce the font size float scaler = newFontSize / fontSize;// Calculate the reduction ReduceSupInfoGroupFontSize(grp, scaler, cb);// apply the new font size - fontSize = newFontSize;// adjust the base font size - mpglen = MeasureSupInfoGroupLength(grp, cb, pageLength);// Measure the length of the group of supinfo paragraphs - } +#pragma warning disable IDE0059 // Unnecessary assignment of a value - set mpglen for Debugging + mpglen = MeasureSupInfoGroupLength(grp, cb, pageLength);// Measure the length of the group of supinfo paragraphs +#pragma warning restore IDE0059 // Unnecessary assignment of a value + } } } } @@ -2571,7 +2166,7 @@ namespace Volian.Print.Library { float x = cell.MyTable.ColLeft[cell.c1]; float w = cell.MyTable.ColLeft[cell.c2 + 1] - x; - float hBefore = scaler * pg.GetParagraphHeight(cb, cell.MyPara, "", w); + //For Debugging: float hBefore = scaler * pg.GetParagraphHeight(cb, cell.MyPara, "", w); foreach (Chunk chk in cell.MyPara.Chunks) chk.Font.Size = scaler * chk.Font.Size; float hAfter = 1.075F * pg.GetParagraphHeight(cb, cell.MyPara, "", w);// 1.075 is a magic number that worked for Ginna. Otherwise decenders overlapped the bottom line of the cell. @@ -2627,19 +2222,23 @@ namespace Volian.Print.Library foreach (Chunk chk in vlnParagraph.IParagraph.Chunks) chk.Font.Size = scaler * chk.Font.Size; } - /// - /// Measure the Length of the Group - /// - /// Group of SupInfo Paragraphs - /// pdfContentByte - /// Page Length - /// Length - private float MeasureSupInfoGroupLength(List grp, PdfContentByte cb, float pagelength) + /// + /// Measure the Length of the Group + /// + /// Group of SupInfo Paragraphs + /// pdfContentByte + /// Page Length + /// Length + [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0060:Remove unused parameter", Justification = "pagelength kept for Debugging")] + private float MeasureSupInfoGroupLength(List grp, PdfContentByte cb, float pagelength) { _LastBottom = 0; _LastOffset = 12;// 24; // account for the Sup Info header (two lines) - float fontSize = grp[0].IParagraph.Leading; // current font size - // For each SupInfo Paragraph calculate length + // current font size + // For each SupInfo Paragraph calculate length + //For Debugging: + //float fontSize = grp[0].IParagraph.Leading; + foreach (vlnParagraph pg in grp) { MeasureSupInfoGroupLength(pg, cb);// Measure a SupInfo Paragraph and children @@ -2692,7 +2291,7 @@ namespace Volian.Print.Library #endregion //ShrinkSupInfoGroupAtATime - public void DoSupInfoPage(PdfContentByte cb, string str, PdfLayer textLayer, VlnSvgPageHelper myPageHelper, int itemid, bool insertBlankPages) + public void DoSupInfoPage(PdfContentByte cb, PdfLayer textLayer, VlnSvgPageHelper myPageHelper, int itemid) { // see if the ID is in the facing page pdf - if so, get the page: if (SupInfoPdfPage == null || SupInfoPdfPage.Count < 1) return; @@ -2703,16 +2302,16 @@ namespace Volian.Print.Library InsertBlankPage(cb); return; } - PdfImportedPage sipage = null; - try - { + + try + { string SupInfoPdfName = Volian.Base.Library.VlnSettings.TemporaryFolder + @"\SupInfo" + myPageHelper.MySection.ItemID.ToString() + @".pdf"; PdfReader pdfreader = new PdfReader(SupInfoPdfName); - sipage = cb.PdfWriter.GetImportedPage(pdfreader, getpage + 1); - // F2023-035: WCN - allow for change in left margin for supplemental information pages by - // setting a value in the DocStyle for the adjustment. When importing the vlnParagraph page - // use this adjustment (note that page list items are done in VlnSvgPageHelper) - float lmargadj = myPageHelper.MySection.MyDocStyle.SupInfoMargAdj == null ? 0 : (float)myPageHelper.MySection.MyDocStyle.SupInfoMargAdj; + PdfImportedPage sipage = cb.PdfWriter.GetImportedPage(pdfreader, getpage + 1); + // F2023-035: WCN - allow for change in left margin for supplemental information pages by + // setting a value in the DocStyle for the adjustment. When importing the vlnParagraph page + // use this adjustment (note that page list items are done in VlnSvgPageHelper) + float lmargadj = myPageHelper.MySection.MyDocStyle.SupInfoMargAdj == null ? 0 : (float)myPageHelper.MySection.MyDocStyle.SupInfoMargAdj; AddImportedPageToLayer(cb.PdfWriter.DirectContent, textLayer, sipage, lmargadj, 0); DoingFacingPage = true; myPageHelper.ResetSvg(); @@ -2726,7 +2325,8 @@ namespace Volian.Print.Library Console.WriteLine(ex); } } - public void DoFoldoutPage(PdfContentByte cb, string str, PdfLayer textLayer, VlnSvgPageHelper myPageHelper, int foldoutindx, bool insertBlankPages) + [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0060:Remove unused parameter", Justification = "str Kept For Debugging")] + public void DoFoldoutPage(PdfContentByte cb, string str, PdfLayer textLayer, VlnSvgPageHelper myPageHelper, int foldoutindx, bool insertBlankPages) { if (_MyFoldoutSection == null || _MyFoldoutSection.Count == 0) return; @@ -2796,25 +2396,11 @@ namespace Volian.Print.Library cb.SaveState(); cb.BeginLayer(layer); SvgWatermark wm = new SvgWatermark(cb, watermark, System.Drawing.Color.Blue, .15F); - //wm.SetSquareDotPattern(.7F); - //wm.SetTextPattern(8, 3); - //wm.SetTextPattern2(8); - //wm.SetHashPattern(1, 6); - //wm.SetDotPattern(5, 2); wm.Draw(); cb.EndLayer(); cb.RestoreState(); } stamper.Close(); - /* - cb.SaveState(); - if (_WatermarkLayer != null) cb.BeginLayer(_WatermarkLayer); - SvgWatermark myWatermark = new SvgWatermark(cb, Watermark, System.Drawing.Color.Blue, .15F); - myWatermark.SetSquareDotPattern(.7F); - myWatermark.Draw(); - if (_WatermarkLayer != null) cb.EndLayer(); - cb.RestoreState(); - */ return ms.ToArray(); } // C2021-010: Remove trailing returns/spaces & manual page breaks & allow save. @@ -2826,21 +2412,20 @@ namespace Volian.Print.Library foreach (int iid in RemoveManualPageBreaks) { ItemInfo ii = ItemInfo.Get(iid); - StepConfig sc = ii.MyConfig as StepConfig; - if (sc != null) - { - using (Item itm = Item.Get(iid)) - { - if (!HasManPagAnnot(ii, "Removed Manual Page Break")) VEPROMS.CSLA.Library.Annotation.MakeAnnotation(itm, AnnotationType.GetByNameOrCreate("Manual Pagination Issues"), null, "Removed Manual Page Break", null); - sc.Step_NewManualPagebreak = false; // reset the flag that was set in the config - if (sc.Step_SubStepPagebreak) sc.Step_SubStepPagebreak = false; // C2023-018: remove substep page break flags - itm.MyContent.Config = sc.ToString(); - itm.MyContent.DTS = DateTime.Now; - itm.MyContent.UserID = Volian.Base.Library.VlnSettings.UserID; - itm.MyContent.Save(); - } - } - } + if (ii.MyConfig is StepConfig sc) + { + using (Item itm = Item.Get(iid)) + { + if (!HasManPagAnnot(ii, "Removed Manual Page Break")) VEPROMS.CSLA.Library.Annotation.MakeAnnotation(itm, AnnotationType.GetByNameOrCreate("Manual Pagination Issues"), null, "Removed Manual Page Break", null); + sc.Step_NewManualPagebreak = false; // reset the flag that was set in the config + if (sc.Step_SubStepPagebreak) sc.Step_SubStepPagebreak = false; // C2023-018: remove substep page break flags + itm.MyContent.Config = sc.ToString(); + itm.MyContent.DTS = DateTime.Now; + itm.MyContent.UserID = Volian.Base.Library.VlnSettings.UserID; + itm.MyContent.Save(); + } + } + } } // If trailing newlines and/or spages were removed, save those if (RemoveTrailingHardReturnsAndSpaces != null && RemoveTrailingHardReturnsAndSpaces.Count > 0) @@ -2895,13 +2480,9 @@ namespace Volian.Print.Library private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); private Dictionary dicPage = new Dictionary(); private Dictionary dicSize = new Dictionary(); - private PromsPrinter _MyPromsPrinter; - public PromsPrinter MyPromsPrinter - { - get { return _MyPromsPrinter; } - set { _MyPromsPrinter = value; } - } - private SectionInfo _MySectionInfo; + + public PromsPrinter MyPromsPrinter { get; set; } + private SectionInfo _MySectionInfo; public SectionInfo MySectionInfo { get { return _MySectionInfo; } @@ -2910,54 +2491,19 @@ namespace Volian.Print.Library if (_MySectionInfo == null || value.ItemID != _MySectionInfo.ItemID) { _MySectionInfo = value; - //MyPdfFile = _MyPromsPrinter.BuildMSWordPDF(MySectionInfo); - //try - //{ - // MyReader = MyPdfFile != null ? new PdfReader(MyPdfFile) : null; - // string key = string.Empty; - // for (int i = 1; i <= MyReader.NumberOfPages; i++) - // { - // key = string.Format("{0}.{1}", MySectionInfo.ItemID, i); - // dicPage.Add(key, MyPromsPrinter.MyContentByte.PdfWriter.GetImportedPage(MyReader, i)); - // dicSize.Add(key, MyReader.GetPageSizeWithRotation(i)); - // } - //} - //catch (Exception ex) - //{ - // MyReader = null; - //} } } } - private string _MyPdfFile; - public string MyPdfFile - { - get { return _MyPdfFile; } - set { _MyPdfFile = value; } - } - private int _DocID; - public int DocID - { - get { return _DocID; } - set { _DocID = value; } - } - private PdfReader _MyReader; - public PdfReader MyReader - { - get { return _MyReader; } - set { _MyReader = value; } - } - public ReaderHelper(PromsPrinter pp) + + public string MyPdfFile { get; set; } + public int DocID { get; set; } + public PdfReader MyReader { get; set; } + public ReaderHelper(PromsPrinter pp) { MyPromsPrinter = pp; - //this.LoadTree(pp.MyItem); } - public PdfImportedPage GetPage(SectionInfo sectInfo, int pageNumber) - { - string key = string.Format("{0}.{1}", sectInfo.ItemID, pageNumber); - return dicPage[key]; - } - public iTextSharp.text.Rectangle GetSize(SectionInfo sectInfo, int pageNumber) + public PdfImportedPage GetPage(SectionInfo sectInfo, int pageNumber) => dicPage[string.Format("{0}.{1}", sectInfo.ItemID, pageNumber)]; + public iTextSharp.text.Rectangle GetSize(SectionInfo sectInfo, int pageNumber) { string key = string.Format("{0}.{1}", sectInfo.ItemID, pageNumber); if (dicSize.ContainsKey(key)) @@ -2973,7 +2519,7 @@ namespace Volian.Print.Library private void LoadSectionTree(ItemInfo ii) { if (ii.Sections == null) return; // B2021-067 crash on null reference - foreach (SectionInfo si in ii.Sections) + foreach (SectionInfo si in ii.Sections.OfType()) { if (MyPromsPrinter.PrtSectID == -1 || (MyPromsPrinter.PrtSectID > -1 && (ii.ItemID == MyPromsPrinter.PrtSectID || si.ItemID == MyPromsPrinter.PrtSectID))) { @@ -2983,7 +2529,7 @@ namespace Volian.Print.Library } else { - MyPdfFile = _MyPromsPrinter.BuildMSWordPDF(si); + MyPdfFile = MyPromsPrinter.BuildMSWordPDF(si); if (MyPdfFile != null) { try @@ -2992,7 +2538,7 @@ namespace Volian.Print.Library if (fi.Length == 0) // B2017-218 Handle invalid word sections { if (!PromsPrinter.BaselineTesting) //B2018-071 Output a message box unless baseline testing is being performed. - MessageBox.Show(si.DisplayNumber + " " + si.DisplayText + " is not valid", "Invalid Word Section", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + MessageBox.Show($"{si.DisplayNumber} {si.DisplayText} is not valid", "Invalid Word Section", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } MyReader = MyPdfFile != null ? new PdfReader(MyPdfFile) : null; @@ -3006,12 +2552,11 @@ namespace Volian.Print.Library if (!((si.MyDocStyle.StructureStyle.Style & E_DocStructStyle.DSS_WordContentLandscaped) == E_DocStructStyle.DSS_WordContentLandscaped) && rectgl.Height < rectgl.Width) rectgl = new iTextSharp.text.Rectangle(rectgl.Height, rectgl.Width); dicSize.Add(key, rectgl); - //dicSize.Add(key, MyReader.GetPageSizeWithRotation(i)); } } catch (Exception ex) { - if (_MyPromsPrinter.DocReplace == null) + if (MyPromsPrinter.DocReplace == null) MessageBox.Show(ex.Message, ex.GetType().FullName, MessageBoxButtons.OK, MessageBoxIcon.Error); _MyLog.Warn(string.Format("Error in LoadSectionTree [{0}],{1}.{2}", si.ItemID, si.DisplayNumber, si.DisplayText), ex); } @@ -3021,33 +2566,5 @@ namespace Volian.Print.Library } } } - //public class PrintTimer - //{ - // private DateTime _StartTime = DateTime.Now; - - // public DateTime StartTime - // { - // get { return _StartTime; } - // set { _StartTime = value; } - // } - // private string _Description = "Start"; - // public string Description - // { - // get { return _Description; } - // set - // { - // DateTime dtNext = DateTime.Now; - // //Console.WriteLine("{0},'{1}'", TimeSpan.FromTicks(dtNext.Ticks - LastTime.Ticks).TotalSeconds, Description); - // _Description = value; - // _LastTime = dtNext; - // } - // } - // private DateTime _LastTime = DateTime.Now; - // public DateTime LastTime - // { - // get { return _LastTime; } - // set { _LastTime = value; } - // } - //} } diff --git a/PROMS/Volian.Print.Library/Rtf2Pdf.cs b/PROMS/Volian.Print.Library/Rtf2Pdf.cs index 3f6985e5..8646727d 100644 --- a/PROMS/Volian.Print.Library/Rtf2Pdf.cs +++ b/PROMS/Volian.Print.Library/Rtf2Pdf.cs @@ -1,12 +1,7 @@ using System; -using System.Collections.Generic; -using System.Text; using iTextSharp.text; using iTextSharp.text.pdf; -using iTextSharp.text.factories; using Itenso.Rtf; -using Itenso.Rtf.Parser; -using Itenso.Rtf.Interpreter; using Itenso.Rtf.Support; using System.IO; using VEPROMS.CSLA.Library; @@ -36,25 +31,15 @@ namespace Volian.Print.Library { #region Log4Net private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); - #endregion - private string _Rtf; + #endregion - public string Rtf - { - get { return _Rtf; } - set { _Rtf = value; } - } - private string _FileName; + public string Rtf { get; set; } - public string FileName + public string FileName { get; set; } + public Rtf2Pdf(string rtf, string fileName) { - get { return _FileName; } - set { _FileName = value; } - } - public Rtf2Pdf(string rtf, string fileName) - { - _Rtf = rtf; - _FileName = fileName; + Rtf = rtf; + FileName = fileName; } public void Process() { @@ -83,67 +68,31 @@ namespace Volian.Print.Library yTop = newYTop; } } - private static string _PaperSize = "LETTER"; // default paper size - public static string PaperSize // C2020-002 paper size is now set in the format files - { - get { return Rtf2Pdf._PaperSize; } - set { Rtf2Pdf._PaperSize = value; } - } - private Rectangle _PaperSizeRec = PageSize.LETTER; // default paper size - public Rectangle PaperSizeRec - { - get { return PDFPageSize.UsePaperSize(PaperSize); } - } - private static bool _PdfDebug = true; - public static bool PdfDebug - { - get { return Rtf2Pdf._PdfDebug; } - set { Rtf2Pdf._PdfDebug = value; } - } - private static System.Drawing.PointF _Offset = new System.Drawing.PointF(0, 0); + + public static string PaperSize // C2020-002 paper size is now set in the format files + { get; set; } = "LETTER"; + public Rectangle PaperSizeRec => PDFPageSize.UsePaperSize(PaperSize); // default paper size = PageSize.LETTER + + public static bool PdfDebug { get; set; } = true; + private static System.Drawing.PointF _Offset = new System.Drawing.PointF(0, 0); public static System.Drawing.PointF Offset { - get { return Rtf2Pdf._Offset; } - set { Rtf2Pdf._Offset = value; } + get { return _Offset; } + set { _Offset = value; } } - public static float FillWidth = 0; // max text width (used in autoToc code) - private static int _TextAtCounter = 0; - public static int TextAtCounter + public static float FillWidth = 0; // max text width (used in autoToc code) + + public static int TextAtCounter { get; set; } = 0; + private static int NextTextAtCounter => ++TextAtCounter; + public class VlnSplitCharacter : ISplitCharacter { - get { return Rtf2Pdf._TextAtCounter; } - set { Rtf2Pdf._TextAtCounter = value; } - } - private static int NextTextAtCounter - { - get - { - int retval = ++TextAtCounter; - //if (InList(retval, 17)) Console.WriteLine("TextAt {0}", retval); - return retval; - } - } - public class VlnSplitCharacter : ISplitCharacter - { - public bool IsSplitCharacter(int start, int current, int end, char[] cc, PdfChunk[] ck) - { - return (cc[current] == ' '); - } - public bool IsSplitCharacter(char c) - { - return (c == ' '); - } - } - private static TableScrunching _AllowTableScrunching = TableScrunching.AllPhases; // RHM20150507 Table Scrunch - public static TableScrunching AllowTableScrunching - { - get { return Rtf2Pdf._AllowTableScrunching; } - set { Rtf2Pdf._AllowTableScrunching = value; } - } - public static bool GetTableScrunchingStatus(TableScrunching val) - { - return (val & _AllowTableScrunching) == val; - } - public static VlnSplitCharacter mySplitter = new VlnSplitCharacter(); + public bool IsSplitCharacter(int start, int current, int end, char[] cc, PdfChunk[] ck) => (cc[current] == ' '); + public bool IsSplitCharacter(char c) => (c == ' '); + } + + public static TableScrunching AllowTableScrunching { get; set; } = TableScrunching.AllPhases; + public static bool GetTableScrunchingStatus(TableScrunching val) => (val & AllowTableScrunching) == val; + public static VlnSplitCharacter mySplitter = new VlnSplitCharacter(); public static string ChunkTextAttributesInfo(Chunk chk1) // C2018-004 create meta file for baseline compares { string rtnval = "Atrbs:"; @@ -180,11 +129,8 @@ namespace Volian.Print.Library return rtnval; } public static int _lastPageNum = 0; // C2018-004 create meta file for baseline compares - public static float TextAt(PdfContentByte cb, Paragraph iParagraph, float x, float y, float width, float height, string debugText, float yBottomMargin) - { - return TextAt(cb, iParagraph, x, y, width, height, debugText, yBottomMargin, null); - } - public static float TextAt(PdfContentByte cb, Paragraph iParagraph, float x, float y, float width, float height, string debugText, float yBottomMargin, int? itmID) + public static float TextAt(PdfContentByte cb, Paragraph iParagraph, float x, float y, float width, float height, string debugText, float yBottomMargin) => TextAt(cb, iParagraph, x, y, width, height, debugText, yBottomMargin, null); + public static float TextAt(PdfContentByte cb, Paragraph iParagraph, float x, float y, float width, float height, string debugText, float yBottomMargin, int? itmID) { if (cb.PdfDocument.PageNumber != _lastPageNum) // C2018-004 create meta file for baseline compares { @@ -192,7 +138,7 @@ namespace Volian.Print.Library _lastPageNum = cb.PdfDocument.PageNumber; } VlnSvgPageHelper _MyPageHelper = cb.PdfWriter.PageEvent as VlnSvgPageHelper; - PdfLayer textLayer = _MyPageHelper == null ? null : _MyPageHelper.TextLayer; + PdfLayer textLayer = _MyPageHelper?.TextLayer; float left = x + Offset.X; float top = y + Offset.Y; // B2020-059 - Barakah 1T4-OP-EOP-AC-0001 Instructions and Contingency Actions section step 6 last table in RNO is compressed - cause first bullet substep in AER to print on top HLS text @@ -224,8 +170,6 @@ namespace Volian.Print.Library chk.Attributes.Add("NoSplit", false); } } - float right = left + width; - float bottom = top - height; ColumnText myColumnText = new ColumnText(cb); myColumnText.SetSimpleColumn(left, top, left + width, yBottomMargin); myColumnText.AddElement(iParagraph); @@ -259,22 +203,22 @@ namespace Volian.Print.Library } return myColumnText.YLine; } + //For Debugging: private static bool InList(int value, params int [] examples) { foreach (int ex in examples) if (ex == value) return true; return false; } - public static float FigureAt(PdfContentByte cb, iTextSharp.text.Image image, float x, float y, float width, float height, string debugText, float yBottommargin, bool hasBorder, int itmID, float sixLinesPerInch) + public static float FigureAt(PdfContentByte cb, iTextSharp.text.Image image, float x, float y, float width, float height, string debugText, bool hasBorder, int itmID, float sixLinesPerInch) { if (cb.PdfDocument.PageNumber != _lastPageNum) // C2018-004 create meta file for baseline compares { Volian.Base.Library.BaselineMetaFile.WriteLine("Page Change from {0} to {1}", _lastPageNum, cb.PdfDocument.PageNumber); _lastPageNum = cb.PdfDocument.PageNumber; } - VlnSvgPageHelper _MyPageHelper = cb.PdfWriter.PageEvent as VlnSvgPageHelper; - PdfLayer textLayer = _MyPageHelper == null ? null : _MyPageHelper.TextLayer; - float left = x + Offset.X; + PdfLayer textLayer = !(cb.PdfWriter.PageEvent is VlnSvgPageHelper _MyPageHelper) ? null : _MyPageHelper.TextLayer; + float left = x + Offset.X; float top = y + Offset.Y + sixLinesPerInch; float bottom = top - height; image.ScaleAbsoluteWidth(width); @@ -309,21 +253,16 @@ namespace Volian.Print.Library return bottom; } - private static float _GridTopAdjust = -10; - public static float GridTopAdjust - { - get { return _GridTopAdjust; } - set { _GridTopAdjust = value; } - } - public static float GridAt(PdfContentByte cb, vlnTable myGrid, float x, float y, float width, float height, string debugText, float yBottomMargin, bool hasBorder) + + public static float GridTopAdjust { get; set; } = -10; + [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0060:Remove unused parameter", Justification = "debugText Kept For Debugging")] + public static float GridAt(PdfContentByte cb, vlnTable myGrid, float x, float y, float width, float height, string debugText, float yBottomMargin, bool hasBorder) { if (cb.PdfDocument.PageNumber != _lastPageNum) // C2018-004 create meta file for baseline compares { Volian.Base.Library.BaselineMetaFile.WriteLine("Page Change from {0} to {1}", _lastPageNum, cb.PdfDocument.PageNumber); _lastPageNum = cb.PdfDocument.PageNumber; } - //VlnSvgPageHelper _MyPageHelper = cb.PdfWriter.PageEvent as VlnSvgPageHelper; // RHM20150507 Table Scrunch - //PdfLayer textLayer = _MyPageHelper == null ? null : _MyPageHelper.TextLayer; // RHM20150507 Table Scrunch float left = x + Offset.X; float top = y + Offset.Y; float right = left + width; @@ -331,7 +270,6 @@ namespace Volian.Print.Library int paperSizePoints = PDFPageSize.PaperSizePoints(myGrid.MyFlexGrid.MyDVI.ActiveFormat.PlantFormat.FormatData.PDFPageSize.PaperSize); // C2020-002 paper size is now set in the format files ColumnText myColumnText = new ColumnText(cb); myColumnText.SetSimpleColumn(left, top, left + width, yBottomMargin); - //if (textLayer != null) cb.BeginLayer(textLayer); // RHM20150507 Table Scrunch // C2018-004 create meta file for baseline compares if (top + GridTopAdjust > paperSizePoints) // B2019-110 Table continued on the next page - off the top of page { @@ -340,14 +278,12 @@ namespace Volian.Print.Library } Volian.Base.Library.BaselineMetaFile.WriteLine("GD left={0} top={1} right={2} bottom={3} Mygrid.ItmID={4}", left, top + GridTopAdjust, right, bottom, myGrid.ItemID); myGrid.ToPdf(myColumnText, left, top + GridTopAdjust); - //if (textLayer != null) cb.EndLayer(); // RHM20150507 Table Scrunch return bottom; } internal static void DrawPdfDebug(PdfContentByte cb, float left, float top, float right, float bottom, string debugText, float yDescent) { - VlnSvgPageHelper _MyPageHelper = cb.PdfWriter.PageEvent as VlnSvgPageHelper; - PdfLayer debugLayer = _MyPageHelper == null ? null : _MyPageHelper.DebugLayer; - if (debugLayer == null) return; + PdfLayer debugLayer = !(cb.PdfWriter.PageEvent is VlnSvgPageHelper _MyPageHelper) ? null : _MyPageHelper.DebugLayer; + if (debugLayer == null) return; System.Drawing.Color sysColor = PrintOverride.OverrideDebugColor(System.Drawing.Color.Gray); cb.SaveState(); cb.BeginLayer(debugLayer); @@ -374,19 +310,17 @@ namespace Volian.Print.Library cb.RestoreState(); } - internal static float RtfRawAt(PdfContentByte cb, System.Drawing.Image image, float XOffset, float yLocation, float Width, float Height, string debug, float yBottomMargin, bool hasBorder) + internal static float RtfRawAt(PdfContentByte cb, System.Drawing.Image image, float XOffset, float yLocation, float Width, float Height, string debug, bool hasBorder) { - VlnSvgPageHelper _MyPageHelper = cb.PdfWriter.PageEvent as VlnSvgPageHelper; - PdfLayer textLayer = _MyPageHelper == null ? null : _MyPageHelper.TextLayer; - float left = XOffset + Offset.X; + PdfLayer textLayer = !(cb.PdfWriter.PageEvent is VlnSvgPageHelper _MyPageHelper) ? null : _MyPageHelper.TextLayer; + float left = XOffset + Offset.X; float top = yLocation + Offset.Y; float bottom = top - Height; float scale = .6f; - iTextSharp.text.Image it_image=null; - try - { - it_image = iTextSharp.text.Image.GetInstance(image,iTextSharp.text.Color.WHITE); - float itxtWid = scale * Width * 300 / 72; + try + { + iTextSharp.text.Image it_image = iTextSharp.text.Image.GetInstance(image, iTextSharp.text.Color.WHITE); + float itxtWid = scale * Width * 300 / 72; float itxtHt = scale * Height * 300 / 72; it_image.ScaleAbsoluteWidth(scale * Width); it_image.ScaleAbsoluteHeight(scale * Height); diff --git a/PROMS/Volian.Print.Library/Rtf2iTextSharp.cs b/PROMS/Volian.Print.Library/Rtf2iTextSharp.cs index 3b46a8c3..f89db169 100644 --- a/PROMS/Volian.Print.Library/Rtf2iTextSharp.cs +++ b/PROMS/Volian.Print.Library/Rtf2iTextSharp.cs @@ -1,18 +1,13 @@ using System; -using System.Collections.Generic; using System.Text; using iTextSharp.text; using iTextSharp.text.pdf; -using iTextSharp.text.factories; using Itenso.Rtf; -using Itenso.Rtf.Parser; -using Itenso.Rtf.Interpreter; -//using Itenso.Rtf.Model; using Itenso.Rtf.Support; -using Microsoft.Win32; using Volian.Base.Library; using System.Text.RegularExpressions; using VEPROMS.CSLA.Library; +using System.Linq; namespace Volian.Print.Library { @@ -21,17 +16,13 @@ namespace Volian.Print.Library public static bool CompressSub = false; public static bool CompressSuper = false; public static bool CompressPropSubSup = false; - private static System.Drawing.Color _TextColor = System.Drawing.Color.Empty; - public static System.Drawing.Color TextColor + + public static System.Drawing.Color TextColor { get; set; } = System.Drawing.Color.Empty; + public static System.Drawing.Color OverrideTextColor(System.Drawing.Color color) { - get { return _TextColor; } - set { _TextColor = value; } - } - public static System.Drawing.Color OverrideTextColor(System.Drawing.Color color) - { - if (_TextColor == System.Drawing.Color.Empty) + if (TextColor == System.Drawing.Color.Empty) return color; - return _TextColor; + return TextColor; } private static System.Drawing.Color _SvgColor = System.Drawing.Color.Empty; public static System.Drawing.Color SvgColor @@ -45,29 +36,21 @@ namespace Volian.Print.Library return color; return _SvgColor; } - private static System.Drawing.Color _BoxColor = System.Drawing.Color.Empty; - public static System.Drawing.Color BoxColor + + public static System.Drawing.Color BoxColor { get; set; } = System.Drawing.Color.Empty; + public static System.Drawing.Color OverrideBoxColor(System.Drawing.Color color) { - get { return _BoxColor; } - set { _BoxColor = value; } - } - public static System.Drawing.Color OverrideBoxColor(System.Drawing.Color color) - { - if (_BoxColor == System.Drawing.Color.Empty) + if (BoxColor == System.Drawing.Color.Empty) return color; - return _BoxColor; + return BoxColor; } - private static System.Drawing.Color _ChangeBarColor = System.Drawing.Color.Empty; - public static System.Drawing.Color ChangeBarColor + + public static System.Drawing.Color ChangeBarColor { get; set; } = System.Drawing.Color.Empty; + public static System.Drawing.Color OverrideChangeBarColor(System.Drawing.Color color) { - get { return _ChangeBarColor; } - set { _ChangeBarColor = value; } - } - public static System.Drawing.Color OverrideChangeBarColor(System.Drawing.Color color) - { - if (_ChangeBarColor == System.Drawing.Color.Empty) + if (ChangeBarColor == System.Drawing.Color.Empty) return color; - return _ChangeBarColor; + return ChangeBarColor; } private static System.Drawing.Color _DebugColor = System.Drawing.Color.Empty; public static System.Drawing.Color DebugColor @@ -93,43 +76,17 @@ namespace Volian.Print.Library public class Rtf2iTextSharp : RtfVisualVisitorBase { private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); - private bool _HasIndent = false; - public bool HasIndent - { - get { return _HasIndent; } - set { _HasIndent = value; } - } - private IRtfDocument _RtfDoc; - private Paragraph _MyParagraph = new Paragraph(); + + public bool HasIndent { get; set; } = false; + private readonly IRtfDocument _RtfDoc; + private readonly Paragraph _MyParagraph = new Paragraph(); private iTextSharp.text.Font _MyFont; - // Allow for definition of a default font: if the font is not proportional, this gets set. - // It is needed to set the chunk's font if the first character of a cell is a hardspace (or various - // other special cases (see its use below). Without this, pdfs were using the Helvetica font, - // which is a default itextsharp font (this was causing a problem for HLP, their pdfs could not - // contain a Helvetica font when putting them in their production environment). - private iTextSharp.text.Font _DefaultFont; - public iTextSharp.text.Font DefaultFont - { - get { return _DefaultFont; } - set { _DefaultFont = value; } - } - private string _MyDebugID = null; - public string MyDebugID - { - get { return _MyDebugID; } - set { _MyDebugID = value; } - } - public bool DoPdfLinks = false; - // public Rtf2iTextSharp(IRtfDocument rtfDoc, Document doc, PdfWriter writer) - public Rtf2iTextSharp(IRtfDocument rtfDoc) - { - if (rtfDoc == null) - throw new ArgumentNullException("rtfDoc"); - - _RtfDoc = rtfDoc; - } - public Paragraph Convert() + public iTextSharp.text.Font DefaultFont { get; set; } + public string MyDebugID { get; set; } = null; + public bool DoPdfLinks = false; + public Rtf2iTextSharp(IRtfDocument rtfDoc) => _RtfDoc = rtfDoc ?? throw new ArgumentNullException("rtfDoc"); + public Paragraph Convert() { int profileDepth = ProfileTimer.Push(">>>> Rtf2ITextSharp.Convert"); _MyParagraph.Clear(); @@ -138,7 +95,6 @@ namespace Volian.Print.Library { visual.Visit(this); } - //_MyParagraph.SetLeading(0, 1); ProfileTimer.Pop(profileDepth); return _MyParagraph; } @@ -177,6 +133,7 @@ namespace Volian.Print.Library _lastWasLineBreak = 0; // B2017-191 reset hard return count break; } + //For Debugging: //_MyParagraph.Add(string.Format("<{0}>", visualBreak.BreakKind.ToString())); } private void AddChunk(string str, iTextSharp.text.Font font) @@ -188,8 +145,9 @@ namespace Volian.Print.Library } protected override void DoVisitSpecial(IRtfVisualSpecialChar visualSpecialChar) { - //_MyParagraph.Add(string.Format("", visualSpecialChar.CharKind.ToString())); - iTextSharp.text.Font activeFont = _MyFont ?? DefaultFont; + //For Debugging: + //_MyParagraph.Add(string.Format("", visualSpecialChar.CharKind.ToString())); + iTextSharp.text.Font activeFont = _MyFont ?? DefaultFont; switch (visualSpecialChar.CharKind) { case RtfVisualSpecialCharKind.Bullet: @@ -248,23 +206,15 @@ namespace Volian.Print.Library if (c <= '\x7F') return false; return true; } + + //For Debugging: private bool ContainsAnySymbols(string p) { foreach (char c in p) if (c > '\x7F' && c != '\xA0' && c != '\xB0') return true; return false; } -// The funcction below was used for the first few lines of DoVisitText which have been commented-out - //private object FixText(string str) - //{ - // StringBuilder sb = new StringBuilder(); - // foreach (char c in str) - // if (c < ' ' || c > '\xFF') - // sb.Append(string.Format("[{0}]", (int)c)); - // else - // sb.Append(c); - // return sb.ToString(); - //} + // ParseLink & GetDefaultItemInfo (which used to be in vlnParagraph) support coding that was added to DoVisitText for // doing pdflink for each transition/ro in a step, see bug B2019-052 private RoUsageInfo _Roui = null; @@ -278,8 +228,9 @@ namespace Volian.Print.Library if (_LinkInfoText.Contains(@"\v")) throw new Exception("LinkText.ParseLink found RTF token"); Match m = Regex.Match(_LinkInfoText, @"[#]Link:([A-Za-z]*):(.*)"); - string _MyValue = m.Groups[1].Value; - string _MyLink = "#Link:" + m.Groups[2].Value + ":" + m.Groups[3].Value; + //For Debugging: + //string _MyValue = m.Groups[1].Value; + //string _MyLink = "#Link:" + m.Groups[2].Value + ":" + m.Groups[3].Value; switch (m.Groups[1].Value) { case "ReferencedObject": @@ -319,7 +270,7 @@ namespace Volian.Print.Library if (myItemInfo.IsProcedure && myItemInfo.Sections != null) { SectionInfo siProcedureSteps = null; - foreach (SectionInfo si in myItemInfo.Sections) + foreach (SectionInfo si in myItemInfo.Sections.OfType()) { if (si.IsDefaultSection) { @@ -347,7 +298,7 @@ namespace Volian.Print.Library private static int chkStart = -1; protected override void DoVisitText(IRtfVisualText visualText) { - //Code to find text (non-symbol) being output with a symbol font + //Debugging Code to find text (non-symbol) being output with a symbol font //if(visualText.Format.Font.Name=="VESymbFix" && visualText.Text.Length > 1) //{ // string s = visualText.Text; @@ -375,44 +326,43 @@ namespace Volian.Print.Library { try { - Chunk chk = _MyParagraph.Chunks[i] as Chunk; - if (chk != null) - { - if (_linkType == 2 && _Ti != null) // transition - { - ItemInfo tiDefault = GetDefaultItemInfo(_Ti.MyItemToID); - ItemInfo from = _Ti.MyContent.ContentItems[0]; - if (_Ti.MyItemToID.MyProcedure.ItemID == from.MyProcedure.ItemID && - !((from.ActiveSection.MyConfig as SectionConfig).Section_IsFoldout == "Y")) //C2019-042 Section_IsFoldout checks Section Number, Section Title, and use of check box - { // Local Go To - // B2020-028, 029 and 030: all were related to print of supplemental information when printing with - // pdf links. The pdf links in the temporary supinfo pdf caused a crash on save of file because they didn't exist. - if (_Ti.MyItemToID.MyContent.Type > 9999 && !from.IsInSupInfo) // internal to this file - { - chk.SetLocalGoto(string.Format("ItemID={0}", tiDefault.ItemID)); - chk.SetBackground(Color.CYAN); - chk.SetBackground(new Color(System.Drawing.Color.LightCyan)); - } - } - else if (_Ti != null && !from.IsInSupInfo) // Remote Go To. Added SupInfo check for B2020 bugs (see above) - { - // C2024-009 add PDF file prefix and suffix if available to the PDF file name in the transition reference. - DocVersionConfig dvc = _Ti.MyItemToID.MyProcedure.MyDocVersion.DocVersionConfig; - string remotePDFName = dvc.Print_PDFFilePrefix + _Ti.MyItemToID.MyProcedure.DisplayNumber.Replace("/", "_") + dvc.Print_PDFFileSuffix + ".pdf"; - chk.SetRemoteGoto(remotePDFName, string.Format("ItemID={0}", tiDefault.ItemID)); - chk.SetBackground(new Color(System.Drawing.Color.PeachPuff)); - } - } - else if (_linkType == 1 && _Roui != null && !_Roui.MyContent.ContentItems[0].IsInSupInfo) // referenced object. Added SupInfo check for B2020 bugs (see above) - { - if (_Roui.ROID.Substring(0, 4) != "FFFF") - { - chk.SetRemoteGoto("completeroreport.pdf", string.Format("ROID={0}", _Roui.ROID.Substring(0, 12).ToUpper())); - chk.SetBackground(new Color(System.Drawing.Color.LightGreen)); - } - } - } - } + if (_MyParagraph.Chunks[i] is Chunk chk) + { + if (_linkType == 2 && _Ti != null) // transition + { + ItemInfo tiDefault = GetDefaultItemInfo(_Ti.MyItemToID); + ItemInfo from = _Ti.MyContent.ContentItems[0]; + if (_Ti.MyItemToID.MyProcedure.ItemID == from.MyProcedure.ItemID && + !((from.ActiveSection.MyConfig as SectionConfig).Section_IsFoldout == "Y")) //C2019-042 Section_IsFoldout checks Section Number, Section Title, and use of check box + { // Local Go To + // B2020-028, 029 and 030: all were related to print of supplemental information when printing with + // pdf links. The pdf links in the temporary supinfo pdf caused a crash on save of file because they didn't exist. + if (_Ti.MyItemToID.MyContent.Type > 9999 && !from.IsInSupInfo) // internal to this file + { + chk.SetLocalGoto(string.Format("ItemID={0}", tiDefault.ItemID)); + chk.SetBackground(Color.CYAN); + chk.SetBackground(new Color(System.Drawing.Color.LightCyan)); + } + } + else if (_Ti != null && !from.IsInSupInfo) // Remote Go To. Added SupInfo check for B2020 bugs (see above) + { + // C2024-009 add PDF file prefix and suffix if available to the PDF file name in the transition reference. + DocVersionConfig dvc = _Ti.MyItemToID.MyProcedure.MyDocVersion.DocVersionConfig; + string remotePDFName = $"{dvc.Print_PDFFilePrefix}{_Ti.MyItemToID.MyProcedure.DisplayNumber.Replace("/", "_")}{dvc.Print_PDFFileSuffix}.pdf"; + chk.SetRemoteGoto(remotePDFName, string.Format("ItemID={0}", tiDefault.ItemID)); + chk.SetBackground(new Color(System.Drawing.Color.PeachPuff)); + } + } + else if (_linkType == 1 && _Roui != null && !_Roui.MyContent.ContentItems[0].IsInSupInfo) // referenced object. Added SupInfo check for B2020 bugs (see above) + { + if (_Roui.ROID.Substring(0, 4) != "FFFF") + { + chk.SetRemoteGoto("completeroreport.pdf", string.Format("ROID={0}", _Roui.ROID.Substring(0, 12).ToUpper())); + chk.SetBackground(new Color(System.Drawing.Color.LightGreen)); + } + } + } + } catch (Exception ex) { _MyLog.ErrorFormat("Error creating pdf links {0}", ex.Message); @@ -630,6 +580,7 @@ namespace Volian.Print.Library } } + //For Debugging: private string ShowSpecialCharacters(string p) { StringBuilder sb = new StringBuilder(); @@ -642,31 +593,23 @@ namespace Volian.Print.Library sb.Append(c); } return sb.ToString(); - }// DoVisitText + } // ---------------------------------------------------------------------- protected override void DoVisitImage(IRtfVisualImage visualImage) - { - //_MyParagraph.Add(new Chunk("")); - //DateTime dt1 = DateTime.Now; - //System.Drawing.Image img2 = visualImage.ImageForDrawing; - //Console.WriteLine("1 Time Span {0}", TimeSpan.FromTicks(DateTime.Now.Ticks - dt1.Ticks).TotalMilliseconds); - //img2.Save(@"c:\datacvrt\x.png"); - System.IO.MemoryStream ms = new System.IO.MemoryStream(); + { - //Console.WriteLine("2 Time Span {0}", TimeSpan.FromTicks(DateTime.Now.Ticks - dt1.Ticks).TotalMilliseconds); - //Console.WriteLine("Size {0}", visualImage.ImageForDrawing.Size); - visualImage.ImageForDrawing.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg); - //Console.WriteLine("3 Time Span {0}", TimeSpan.FromTicks(DateTime.Now.Ticks - dt1.Ticks).TotalMilliseconds); - ms.Seek(0, System.IO.SeekOrigin.Begin); - //Console.WriteLine("4 Time Span {0}", TimeSpan.FromTicks(DateTime.Now.Ticks - dt1.Ticks).TotalMilliseconds); - iTextSharp.text.Image img = iTextSharp.text.Image.GetInstance(ms); - //Console.WriteLine("5 Time Span {0}", TimeSpan.FromTicks(DateTime.Now.Ticks - dt1.Ticks).TotalMilliseconds); - _MyParagraph.Add(img); - //Console.WriteLine("6 Time Span {0}", TimeSpan.FromTicks(DateTime.Now.Ticks - dt1.Ticks).TotalMilliseconds); - _lastWasLineBreak = 0; // B2017-191 reset hard return count - } // DoVisitImage + using (System.IO.MemoryStream ms = new System.IO.MemoryStream()) + { + visualImage.ImageForDrawing.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg); + ms.Seek(0, System.IO.SeekOrigin.Begin); + iTextSharp.text.Image img = iTextSharp.text.Image.GetInstance(ms); + _MyParagraph.Add(img); + } - } + _lastWasLineBreak = 0; // B2017-191 reset hard return count + } + + } } diff --git a/PROMS/Volian.Print.Library/VlnSvgPageHelper.cs b/PROMS/Volian.Print.Library/VlnSvgPageHelper.cs index 89efa648..2c3592f9 100644 --- a/PROMS/Volian.Print.Library/VlnSvgPageHelper.cs +++ b/PROMS/Volian.Print.Library/VlnSvgPageHelper.cs @@ -1,55 +1,31 @@ using System; using System.Collections.Generic; -using System.Text; using iTextSharp.text; using iTextSharp.text.pdf; -using iTextSharp.text.factories; using Volian.Svg.Library; using System.Text.RegularExpressions; using System.Xml; using VEPROMS.CSLA.Library; using Volian.Base.Library; +using System.Linq; namespace Volian.Print.Library { public partial class VlnSvgPageHelper:SvgPageHelper { - private float _TableAdjustment = 0;// RHM20150525 - Table Scrunch - public float TableAdjustment - { - get { return _TableAdjustment; } - set { _TableAdjustment = value; } - } - private vlnParagraph _AdjustedTable; // B2020-059 - save info of table that was compressed (set in vlnParagraph.cs DrawGrid() and used in RTF2PDF.cs TextAt()) - public vlnParagraph AdjustedTable - { - get { return _AdjustedTable; } - set { _AdjustedTable = value; } - } - private float _AdjustedTableYtop; - public float AdjustedTableYtop // B2020-059 - save the Ytop of the compressed table (set in vlnParagraph.cs DrawGrid() and used in RTF2PDF.cs TextAt()) - { - get { return _AdjustedTableYtop; } - set { _AdjustedTableYtop = value; } - } - private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); - private pkParagraphs _MyPlacekeepers = new pkParagraphs(); - public pkParagraphs MyPlacekeepers - { - get { return _MyPlacekeepers; } - } - private pkParagraphs _MyContActSteps = new pkParagraphs(); - public pkParagraphs MyContActSteps - { - get { return _MyContActSteps; } - } - // F2022-024 Time Critical Action Step - private pkParagraphs _MyTimeCriticalActionSteps = new pkParagraphs(); - public pkParagraphs MyTimeCriticalActionSteps - { - get { return _MyTimeCriticalActionSteps; } - } - private float? _BottomContent = null;// RHM20150525 - Table Scrunch + public float TableAdjustment { get; set; } = 0; + public vlnParagraph AdjustedTable { get; set; } + public float AdjustedTableYtop // B2020-059 - save the Ytop of the compressed table (set in vlnParagraph.cs DrawGrid() and used in RTF2PDF.cs TextAt()) + { get; set; } + private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + private readonly pkParagraphs _MyPlacekeepers = new pkParagraphs(); + public pkParagraphs MyPlacekeepers => _MyPlacekeepers; + private readonly pkParagraphs _MyContActSteps = new pkParagraphs(); + public pkParagraphs MyContActSteps => _MyContActSteps; + // F2022-024 Time Critical Action Step + private readonly pkParagraphs _MyTimeCriticalActionSteps = new pkParagraphs(); + public pkParagraphs MyTimeCriticalActionSteps => _MyTimeCriticalActionSteps; + private float? _BottomContent = null;// RHM20150525 - Table Scrunch public float? BottomContent { get @@ -62,127 +38,31 @@ namespace Volian.Print.Library _BottomContent = value; } } - private PageBookmarks _PageBookmarks = new PageBookmarks(); - public PageBookmarks PageBookmarks - { - get { return _PageBookmarks; } - set { _PageBookmarks = value; } - } - private List _MyPdfOutlines = new List(); - public List MyPdfOutlines - { - get { return _MyPdfOutlines; } - } - private ChkListBoxesHelper _CheckListBoxes = null; - private ChkListBoxesHelper CheckListBoxes - { - get { return _CheckListBoxes; } - set { _CheckListBoxes = value; } - } - private vlnText _TopMessage; - public vlnText TopMessage - { - get { return _TopMessage; } - set { _TopMessage = value; } - } - private int _prtSectID = -1; - public int PrtSectID - { - get { return _prtSectID; } - set { _prtSectID = value; } - } - private List _TopMessageRs=new List(); // Added if there are 2 messages, in AER AND RNO (for BGE) - public List TopMessageRs - { - get { return _TopMessageRs; } - set { _TopMessageRs = value; } - } - private List _TopMessageSub1s=new List(); // BGE Alarms: in CONDITION/RESPONSE if break within substep - public List TopMessageSub1s - { - get { return _TopMessageSub1s; } - set { _TopMessageSub1s = value; } - } - private List _TopMessageSub2s=new List(); // BGE Alarms: in CONDITION/RESPONSE if break within substep - public List TopMessageSub2s - { - get { return _TopMessageSub2s; } - set { _TopMessageSub2s = value; } - } - private List _BottomMessage = new List(); // B2017-203) any continuous sections with end messages may have more than 1 message on a page - public List BottomMessage - { - get { return _BottomMessage; } - set { _BottomMessage = value; } - } - private vlnText _BottomMessageR; // Added if there are 2 messages, in AER AND RNO (for BGE) - public vlnText BottomMessageR - { - get { return _BottomMessageR; } - set { _BottomMessageR = value; } - } - private vlnText _BottomMessageA; // Added if there are 3 messages, at bottom AND in AER AND RNO (for BGEALARMS) - public vlnText BottomMessageA - { - get { return _BottomMessageA; } - set { _BottomMessageA = value; } - } - private Dictionary> _NotesToFootNotesHLS = new Dictionary>(); - public Dictionary> NotesToFootNotesHLS - { - get { return _NotesToFootNotesHLS; } - set { _NotesToFootNotesHLS = value; } - } - private List _NotesToFootNotes = new List(); - public List NotesToFootNotes - { - get { return _NotesToFootNotes; } - set { _NotesToFootNotes = value; } - } - private float _NotesToFootNotesYoffset = 0; - public float NotesToFootNotesYoffset - { - get { return _NotesToFootNotesYoffset; } - set { _NotesToFootNotesYoffset = value; } - } - Dictionary _MyParagraphs = new Dictionary(); - public Dictionary MyParagraphs - { - get { return _MyParagraphs; } - set { _MyParagraphs = value; } - } - float _YMultiplier = 1; - public float YMultiplier - { - get { return _YMultiplier; } - set { _YMultiplier = value; } - } - float _PhoneListHeight = 0; - public float PhoneListHeight - { - get { return _PhoneListHeight; } - set { _PhoneListHeight = value; } - } - private float _AlarmYoffStart = 0; - public float AlarmYoffStart - { - get { return _AlarmYoffStart; } - set { _AlarmYoffStart = value; } - } - private float _AlarmYoffEnd = 0; - public float AlarmYoffEnd - { - get { return _AlarmYoffEnd; } - set { _AlarmYoffEnd = value; } - } - private float _SectionSepLineYoffStart = 0; - public float SectionSepLineYoffStart - { - get { return _SectionSepLineYoffStart; } - set { _SectionSepLineYoffStart = value; } - } - private PdfWriter _MyPdfWriter; + public PageBookmarks PageBookmarks { get; set; } = new PageBookmarks(); + [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0044:Add readonly modifier", Justification = "Keeping Collections Not ReadOnly")] + private List _MyPdfOutlines = new List(); + public List MyPdfOutlines => _MyPdfOutlines; + + public vlnText TopMessage { get; set; } + public int PrtSectID { get; set; } = -1; + public List TopMessageRs { get; set; } = new List(); + public List TopMessageSub1s { get; set; } = new List(); + public List TopMessageSub2s { get; set; } = new List(); + public List BottomMessage { get; set; } = new List(); + public vlnText BottomMessageR { get; set; } + public vlnText BottomMessageA { get; set; } + public Dictionary> NotesToFootNotesHLS { get; set; } = new Dictionary>(); + public List NotesToFootNotes { get; set; } = new List(); + + public float NotesToFootNotesYoffset { get; set; } = 0; + public Dictionary MyParagraphs { get; set; } = new Dictionary(); + public float YMultiplier { get; set; } = 1; + public float PhoneListHeight { get; set; } = 0; + public float AlarmYoffStart { get; set; } = 0; + public float AlarmYoffEnd { get; set; } = 0; + public float SectionSepLineYoffStart { get; set; } = 0; + private PdfWriter _MyPdfWriter; public PdfWriter MyPdfWriter { get { return _MyPdfWriter; } @@ -194,79 +74,34 @@ namespace Volian.Print.Library _MyPdfWriter = value; } } - private PdfContentByte _MyPdfContentByte; - public PdfContentByte MyPdfContentByte - { - get { return _MyPdfContentByte; } - set { _MyPdfContentByte = value; } - } - private int _FinalMessageSectionID; - public int FinalMessageSectionID - { - get { return _FinalMessageSectionID; } - set { _FinalMessageSectionID = value; } - } - private bool _DidFirstPageDocStyle = false; - public bool DidFirstPageDocStyle - { - get { return _DidFirstPageDocStyle; } - set { _DidFirstPageDocStyle = value; } - } - public override void OnCloseDocument(PdfWriter writer, iTextSharp.text.Document document) + + public PdfContentByte MyPdfContentByte { get; set; } + public int FinalMessageSectionID { get; set; } + public bool DidFirstPageDocStyle { get; set; } = false; + public override void OnCloseDocument(PdfWriter writer, iTextSharp.text.Document document) { AddBookmarks(writer); MyPageCounts.DrawTemplates(); } - private bool _OnBlankPage = false; - public bool OnBlankPage // used while inserting a blank page when printing a procedure with duplex foldouts - { - get { return _OnBlankPage; } - set { _OnBlankPage = value; } - } - // when false, no page has been printed yet (for determining whether a blank page before print - // needs done if first section has foldouts) - private bool _PrintedAPage = false; - public bool PrintedAPage - { - get { return _PrintedAPage; } - set { _PrintedAPage = value; } - } - // the following two variables are used to handle the 'PSOnlyFirst' page list Justify flag. - // PSOnlyFirst signals that the pagelist token should only be processed for the first page of - // the section. It gets set when this token is processed, so that any remaining pages will - // not get the token. It's value is derived by taking the different the location of this token - // & the location of the previous token, so that this amount can be used to move the text up - // on the 'not first' pages of the section. It's used as an adjustment on the topmargin. - // This is used in FNP formats. - private int _sectLevelNumTtlDiff = 0; - private int _PrintedSectionPage = 0; - public int PrintedSectionPage - { - get { return _PrintedSectionPage; } - set { _PrintedSectionPage = value; } - } - private static int _CountInApplProcs; // B2021-127: BNPPalr - Auto set of serial # - public static int CountInApplProcs - { - get { return _CountInApplProcs; } - set { _CountInApplProcs = value; } - } - // C2025-033 Child (slave) being printed - private static int _PrintingChild = 0; - public static int PrintingChild - { - get { return _PrintingChild; } - set { _PrintingChild = value; } - } + public bool OnBlankPage // used while inserting a blank page when printing a procedure with duplex foldouts + { get; set; } = false; + public bool PrintedAPage { get; set; } = false; - //private bool _AddBlankPagesForDuplexPrinting = false; - //public bool AddBlankPagesForDuplexPrinting // Tells us if a the option to add a blank page is turn on (for procedures with duplex foldouts) - //{ - // get { return _AddBlankPagesForDuplexPrinting; } - // set { _AddBlankPagesForDuplexPrinting = value; } - //} - private int _prevSectId = 0; + // the following two variables are used to handle the 'PSOnlyFirst' page list Justify flag. + // PSOnlyFirst signals that the pagelist token should only be processed for the first page of + // the section. It gets set when this token is processed, so that any remaining pages will + // not get the token. It's value is derived by taking the different the location of this token + // & the location of the previous token, so that this amount can be used to move the text up + // on the 'not first' pages of the section. It's used as an adjustment on the topmargin. + // This is used in FNP formats. + private int _sectLevelNumTtlDiff = 0; + + public int PrintedSectionPage { get; set; } = 0; + public static int CountInApplProcs { get; set; } + public static int PrintingChild { get; set; } = 0; + + private int _prevSectId = 0; public override void OnEndPage(PdfWriter writer, iTextSharp.text.Document document) { TableAdjustment = 0;// RHM20150525 - Table Scrunch @@ -323,17 +158,15 @@ namespace Volian.Print.Library { // yoffset the footer length + the size of the phone list: float yoff = (float)MySection.MyDocStyle.Layout.FooterLength + PhoneListHeight + 12; // 12 is an extra line for the horizontal. - DocVersionConfig dvc = MySection.MyDocVersion.MyConfig as DocVersionConfig; - if (dvc != null) - DrawPhoneList(writer.DirectContent, (float)MySection.MyDocStyle.Layout.LeftMargin, (float)MySection.MyDocStyle.Layout.PageWidth, yoff, dvc.Print_PhoneList); - } + if (MySection.MyDocVersion.MyConfig is DocVersionConfig dvc) + DrawPhoneList(writer.DirectContent, (float)MySection.MyDocStyle.Layout.LeftMargin, (float)MySection.MyDocStyle.Layout.PageWidth, yoff, dvc.Print_PhoneList); + } } if (MySection.MyDocStyle.CenterLineX != null && !onBlankPage) { if ((MySection.MyDocStyle.StructureStyle.Style & E_DocStructStyle.DoubleBoxHLS) == E_DocStructStyle.DoubleBoxHLS) DrawHorizontal(writer.DirectContent, (float)MySection.MyDocStyle.Layout.LeftMargin, (float)MySection.MyDocStyle.Layout.PageWidth, (float)MySection.MyDocStyle.CenterLineYTop); - //if (MySection.ColumnMode > 0 && onBlankPage == false) if (MySection.ColumnMode > 0 || MySection.ActiveFormat.PlantFormat.FormatData.PrintData.WCNTraining) { DrawCenterLine(writer.DirectContent, MySection.MyDocStyle.Layout.LeftMargin + MySection.MyDocStyle.CenterLineX ?? 0, MySection.MyDocStyle.CenterLineYTop ?? 0, MySection.MyDocStyle.CenterLineYBottom ?? 0); @@ -411,7 +244,7 @@ namespace Volian.Print.Library cb.LineTo(x, y); cb.Stroke(); } - for (float y = yBottom; y <= yTop; y += 10) + for (float y = yBottom; y <= yTop; y += 10) { float w = 10; if (i % 10 == 0) w = 30; @@ -422,8 +255,8 @@ namespace Volian.Print.Library cb.LineTo(x, y); cb.Stroke(); } -i = 0; - cb.Stroke(); + + cb.Stroke(); cb.RestoreState(); cb.EndLayer(); } @@ -434,7 +267,6 @@ i = 0; if (PageListLayer != null) cb.BeginLayer(PageListLayer); cb.SetColorStroke(new Color(PrintOverride.SvgColor)); cb.SetLineWidth(1.05f); // Tweak the line width to match vlnmacro - //cb.SetColorStroke(lineColor); cb.MoveTo(x, top); cb.LineTo(x, bottom); cb.Stroke(); @@ -445,7 +277,7 @@ i = 0; private void DrawPhoneList(PdfContentByte pdfContentByte, float leftMargin, float pageWidth, float yOff, string plist) { // draw the line above the phone list: - yOff = yOff + 4; // move up 1/2 line: + yOff += 4; // move up 1/2 line: DrawHorizontal(pdfContentByte, leftMargin, pageWidth, yOff); pdfContentByte.SaveState(); @@ -494,7 +326,7 @@ i = 0; else endOfLine = true; } - lyoff = lyoff - vlnPrintObject.SixLinesPerInch; + lyoff -= vlnPrintObject.SixLinesPerInch; } } } @@ -513,7 +345,6 @@ i = 0; if (PageListLayer != null) cb.BeginLayer(PageListLayer); cb.SetColorStroke(new Color(PrintOverride.SvgColor)); if (MySection.MyDocStyle.CLineWidth != null && MySection.MyDocStyle.CLineWidth != 0) cb.SetLineWidth((float)MySection.MyDocStyle.CLineWidth); - //cb.SetColorStroke(lineColor); // C2018-004 create meta file for baseline compares Volian.Base.Library.BaselineMetaFile.WriteLine("HorzLn X1={0} Y={1} X2={2}", left, yoff, right); cb.MoveTo(left, yoff); @@ -541,13 +372,11 @@ i = 0; } private void DrawCenterLine(PdfContentByte cb, float xLoc, float yTop, float yBottom) { - //iTextSharp.text.Color lineColor = new iTextSharp.text.Color(PrintOverride.OverrideTextColor(System.Drawing.Color.DarkOrange)); cb.SaveState(); if (PageListLayer != null) cb.BeginLayer(PageListLayer); float lwidth = MySection.MyDocStyle.CLineWidth ?? .95f; cb.SetLineWidth(lwidth); cb.SetColorStroke(new Color(PrintOverride.SvgColor)); - //cb.SetColorStroke(lineColor); cb.MoveTo(xLoc, yTop); float ylast = yTop; if (_MyGaps != null) @@ -608,7 +437,7 @@ i = 0; private float? _YTopMargin = null; public float? YTopMargin { - get { return _YTopMargin - _AdjustTopMarginForMultiLinePageListItems; } + get { return _YTopMargin - AdjustTopMarginForMultiLinePageListItems; } set { _YTopMargin = value; } } private void DrawRuler(PdfContentByte cb) @@ -711,14 +540,6 @@ i = 0; cb.LineTo(x1, yRuler + 5); } } - //cb.MoveTo(122.4F, 0); //WCN2 HLS - //cb.LineTo(122.4F, cb.PdfWriter.PageSize.Height); - //cb.MoveTo(78, 0); // HLP HLS - //cb.LineTo(78, cb.PdfWriter.PageSize.Height); - //cb.MoveTo(441, 0); // HLP cover page date - //cb.LineTo(441, cb.PdfWriter.PageSize.Height); - //cb.MoveTo(71.4F, 0); // WCN Purpose page, Revision: {REV} - //cb.LineTo(71.4F, cb.PdfWriter.PageSize.Height); cb.Stroke(); cb.EndLayer(); cb.RestoreState(); @@ -739,9 +560,8 @@ i = 0; } else { - PdfDestination dest =pb.PdfDestination; - if(dest==null) dest = new PdfDestination(PdfDestination.FIT); - PdfOutline pdo = new PdfOutline(MyPdfOutlines[lev-1], dest,Regex.Replace(pb.Title, @"\\{Prerequisite Step: .*?\\}", string.Empty), false); + PdfDestination dest = pb.PdfDestination ?? new PdfDestination(PdfDestination.FIT); + PdfOutline pdo = new PdfOutline(MyPdfOutlines[lev-1], dest,Regex.Replace(pb.Title, @"\\{Prerequisite Step: .*?\\}", string.Empty), false); if (MyPdfOutlines.Count == lev) MyPdfOutlines.Add(pdo); else @@ -852,42 +672,27 @@ i = 0; // TODO: Pass in zeroes because topdf is inherited. vcb.ToPdf(cb, topMargin, ref tmp, ref tmp); } - _MyChangeBars = new List(); + MyChangeBars = new List(); } - #region SectionLevelData - private ChangeBarDefinition _ChangeBarDefinition; - public ChangeBarDefinition ChangeBarDefinition - { - get { return _ChangeBarDefinition; } - set { _ChangeBarDefinition = value; } - } - #endregion - private PdfLayer _TextLayer; - public PdfLayer TextLayer - { - get { return _TextLayer; } - set { _TextLayer = value; } - } - private PdfLayer _DebugLayer; - public PdfLayer DebugLayer - { - get { return _DebugLayer; } - set { _DebugLayer = value; } - } - private VEPROMS.CSLA.Library.SectionInfo _MySection; + #region SectionLevelData + public ChangeBarDefinition ChangeBarDefinition { get; set; } + #endregion + public PdfLayer TextLayer { get; set; } + public PdfLayer DebugLayer { get; set; } + private VEPROMS.CSLA.Library.SectionInfo _MySection; public VEPROMS.CSLA.Library.SectionInfo MySection { get { return _MySection; } set { _MySection = value; - MySectionTitle = ((_MySection.DisplayNumber ?? string.Empty) == string.Empty ? string.Empty : _MySection.DisplayNumber + " - ") + _MySection.DisplayText; + MySectionTitle = $"{((_MySection.DisplayNumber ?? string.Empty) == string.Empty ? string.Empty : $"{_MySection.DisplayNumber} - ")}{_MySection.DisplayText}"; bool forceLoadSvg = false; if (value.SectionConfig.Section_Pagination == SectionConfig.SectionPagination.Separate && value.MyDocStyle.ResetFirstPageOnSection) DidFirstPageDocStyle = false; if (DidFirstPageDocStyle) forceLoadSvg = SetDocStyleAndValues(); // this method also gets the SVG (the 'else' part of this) - if (_prtSectID > -1) { + if (PrtSectID > -1) { forceLoadSvg = true; } Volian.Svg.Library.Svg sectSvg = BuildSvg(_MySection, forceLoadSvg); @@ -895,52 +700,16 @@ i = 0; _YTopMargin = null; } } - private string _MySectionTitle; - public string MySectionTitle - { - get { return _MySectionTitle; } - set { _MySectionTitle = value; } - } - private int _MaxRNO; - public int MaxRNO - { - get - { - return _MySection.ColumnMode; - } - } - private int _CurrentPageOf = 0; - public int CurrentPageOf - { - get { return _CurrentPageOf; } - set { _CurrentPageOf = value; } - } - private string _Rev = string.Empty; - public string Rev - { - get { return _Rev; } - set { _Rev = value; } - } - private string _RevDate = string.Empty; - public string RevDate - { - get { return _RevDate; } - set { _RevDate = value; } - } - private bool _DoFloatingFoldout = true; - public bool DoFloatingFoldout - { - get { return _DoFloatingFoldout; } - set { _DoFloatingFoldout = value; } - } - private List _MyChangeBars = new List(); - public List MyChangeBars - { - get { return _MyChangeBars; } - set { _MyChangeBars = value; } - } - public void AddChangeBar(vlnChangeBar vcb, string cbmess) + public string MySectionTitle { get; set; } + public int MaxRNO => _MySection.ColumnMode; + + public int CurrentPageOf { get; set; } = 0; + public string Rev { get; set; } = string.Empty; + public string RevDate { get; set; } = string.Empty; + public bool DoFloatingFoldout { get; set; } = true; + public List MyChangeBars { get; set; } = new List(); + public void AddChangeBar(vlnChangeBar vcb, string cbmess) { if (vcb == null) return; vlnChangeBar prevCB = null; @@ -1041,17 +810,12 @@ i = 0; vcb.YChangeBarBottomExtend >= (cb.YChangeBarBottomExtend - tolerance)) return true; return false; } - private PromsPrinter _MyPromsPrinter; - public PromsPrinter MyPromsPrinter - { - get { return _MyPromsPrinter; } - set { _MyPromsPrinter = value; } - } - private int _MyRomanPage = 1; - public VlnSvgPageHelper(VEPROMS.CSLA.Library.SectionInfo mySection, PromsPrinter myPromsPrinter, string hlsText, int hlsItemId, int PrtSectID) + + public PromsPrinter MyPromsPrinter { get; set; } + public VlnSvgPageHelper(VEPROMS.CSLA.Library.SectionInfo mySection, PromsPrinter myPromsPrinter, string hlsText, int hlsItemId, int PrtSectID) : base() { - _prtSectID = PrtSectID; + this.PrtSectID = PrtSectID; HLSText = hlsText; HasHLSTextId = hlsItemId; MyPromsPrinter = myPromsPrinter; @@ -1060,20 +824,6 @@ i = 0; } private Volian.Svg.Library.Svg BuildSvg(VEPROMS.CSLA.Library.SectionInfo mySection, bool forceLoad) { - // if mysection uses continuous pagination, and the previous section uses the same format, - // and the docstyle is set to use on first page only, - // then set section to use the Use On Rest of Pages - //SectionConfig.SectionPagination sPag = SectionConfig.SectionPagination.Separate; - //if (mySection.IsStepSection && mySection.MyPrevious != null && mySection.MyPrevious.IsStepSection) - //{ - // SectionConfig sc = mySection.MyConfig as SectionConfig; - // sPag = sc.Section_Pagination; - // if (sPag == SectionConfig.SectionPagination.Continuous) - // { - // if (MySection.MyDocStyle.StructureStyle.Where == E_DocStyleUse.UseOnFirstPage) - // MySection.DidFirstPageDocStyle = true; - // } - //} VEPROMS.CSLA.Library.FormatInfo activeFormat = mySection.ActiveFormat; VEPROMS.CSLA.Library.DocStyle docStyle = mySection.MyDocStyle; Volian.Svg.Library.Svg mySvg = null; @@ -1101,7 +851,6 @@ i = 0; SectionConfig sc = mySection.MyConfig as SectionConfig; sPag = sc.Section_Pagination; } - //if (sPag == SectionConfig.SectionPagination.Continuous && !mySection.DidFirstPageDocStyle) return null; if (forceLoad) return mySvg; if (sPag == SectionConfig.SectionPagination.Continuous) return null; return mySvg; @@ -1109,8 +858,8 @@ i = 0; public PageCounts MyPageCounts = null; public PageCounts MyTOCPageCounts = null; public Dictionary MyTOCPageNums = null; - private static Regex regexFindToken = new Regex("{[^{}]*}"); - private static Regex regexFindSubToken = new Regex(@"\[[^{}]*\]"); + private static readonly Regex regexFindToken = new Regex("{[^{}]*}"); + private static readonly Regex regexFindSubToken = new Regex(@"\[[^{}]*\]"); private string mySvg_ProcessText(object sender, SvgProcessTextArgs args) { if (args.MyText == null) return string.Empty; // Needed for empty genmac text (was space in 16bit files) @@ -1126,26 +875,18 @@ i = 0; { top = top.MyParent; } - string key = "DocCurPage." + top.ItemID; + string key = $"DocCurPage.{top.ItemID}"; string txt = args.MyText.Replace("{METACURPAGE}", "{PAGE}").Replace("{METATOTPAGE}", "{OF}"); MyPdfContentByte.AddTemplate(MyPageCounts.AddToTemplateList(key, MyPdfWriter, txt, args.MySvgText.Font, args.MySvgText.Align, args.MySvgText.FillColor), args.MySvgScale.X(args.MySvgText.X), args.MySvgScale.Y(MyPdfContentByte, args.MySvgText.Y)); return string.Empty; } if (args.MyText.Contains("{DOCCURPAGE}") || args.MyText.Contains("{DOCTOTPAGE}")) { - string key = "DocCurPage." + MySection.ItemID; + string key = $"DocCurPage.{MySection.ItemID}"; string txt = args.MyText.Replace("{DOCCURPAGE}", "{PAGE}").Replace("{DOCTOTPAGE}", "{OF}"); MyPdfContentByte.AddTemplate(MyPageCounts.AddToTemplateList(key, MyPdfWriter, txt, args.MySvgText.Font, args.MySvgText.Align, args.MySvgText.FillColor), args.MySvgScale.X(args.MySvgText.X), args.MySvgScale.Y(MyPdfContentByte, args.MySvgText.Y)); return string.Empty; } - //if (args.MyText.Contains("{ROMANPAGE}")) - //{ - // //return args.MyText.Replace("{ROMANPAGE}", ItemInfo.RomanNumbering(_MyRomanPage++).ToLower()); - // string key = "RomanPage." + MySection.ItemID; - // string txt = args.MyText; - // MyPdfContentByte.AddTemplate(MyPageCounts.AddToTemplateList(key, MyPdfWriter, txt, args.MySvgText.Font, args.MySvgText.Align, args.MySvgText.FillColor), args.MySvgScale.X(args.MySvgText.X), args.MySvgScale.Y(MyPdfContentByte, args.MySvgText.Y)); - // return string.Empty; - //} if (args.MyText.Contains("{SECONDARYPAGE}") || args.MyText.Contains("{SECONDARYOF}")) { string key = "SecondaryPage." + MySection.DisplayNumber; @@ -1153,12 +894,12 @@ i = 0; MyPdfContentByte.AddTemplate(MyPageCounts.AddToTemplateList(key, MyPdfWriter, txt, args.MySvgText.Font, args.MySvgText.Align, args.MySvgText.FillColor), args.MySvgScale.X(args.MySvgText.X), args.MySvgScale.Y(MyPdfContentByte, args.MySvgText.Y)); return string.Empty; } - //string tocKey = "TOC" + MySection.ItemID.ToString(); if (args.MyText.Contains("{PAGE}") || args.MyText.Contains("{OF}")) { #region numberingseq /* + //For Reference: public enum E_NumberingSequence : uint { NoPageNum = 0, @@ -1189,7 +930,7 @@ i = 0; case E_NumberingSequence.WithSteps: // Number with 'originalstepsection' ProcedureInfo pc = MySection.MyProcedure; int sectid = 0; - foreach (SectionInfo si in pc.Sections) + foreach (SectionInfo si in pc.Sections.OfType()) { SectionConfig sc = si.MyConfig as SectionConfig; if (sc.Section_OriginalSteps == "Y") @@ -1198,33 +939,30 @@ i = 0; break; } } - if (sectid != 0) key = (int)E_NumberingSequence.WithinEachSection + "." + sectid; + if (sectid != 0) key = $"{(int)E_NumberingSequence.WithinEachSection}.{sectid}"; break; case E_NumberingSequence.WithinEachDocStyle: - key = key + "." + MySection.ActiveFormat.FormatID + "." + MySection.MyDocStyle.Index; + key = $"{key}.{MySection.ActiveFormat.FormatID}.{MySection.MyDocStyle.Index}"; break; - //case E_NumberingSequence.WithinEachDocStyle1: - // key = key + "." + MySection.DisplayNumber; - // break; case E_NumberingSequence.WithinEachSection: - key = key + "." + MySection.ItemID; + key = $"{key}.{MySection.ItemID}"; break; case E_NumberingSequence.WithinEachSectionNumber: - key = key + "." + ( MySection.DisplayNumber == string.Empty ? (MySection.ActiveParent as ItemInfo).DisplayNumber : MySection.DisplayNumber); + key = $"{key}.{( MySection.DisplayNumber == string.Empty ? (MySection.ActiveParent as ItemInfo).DisplayNumber : MySection.DisplayNumber)}"; break; case E_NumberingSequence.GroupedByLevel: case E_NumberingSequence.Like6_ButDoesntNeedSubsection: if (MySection.MyParent.IsSection) - key = key + "." + MySection.MyParent.ItemID; + key = $"{key}.{MySection.MyParent.ItemID}"; else - key = key + "." + MySection.ItemID; + key = $"{key}.{MySection.ItemID}"; break; case E_NumberingSequence.WithStepsAndSecondaryPageNumber: // For this one, we'll do two keys and templates. One will go with the main steps // section and one will be for this secondary section. ProcedureInfo pc1 = MySection.MyProcedure; int psectid = 0; - foreach (SectionInfo si in pc1.Sections) + foreach (SectionInfo si in pc1.Sections.OfType()) { SectionConfig sc = si.MyConfig as SectionConfig; if (sc.Section_OriginalSteps == "Y") @@ -1235,7 +973,7 @@ i = 0; } if (psectid != 0) { - key = (int)E_NumberingSequence.WithinEachSection + "." + psectid; + key = $"{(int)E_NumberingSequence.WithinEachSection}.{psectid}"; PdfTemplate tmp1 = MyPageCounts.AddToTemplateList(key, MyPdfWriter, args.MyText, args.MySvgText.Font, args.MySvgText.Align, args.MySvgText.FillColor); } break; @@ -1299,7 +1037,7 @@ i = 0; } if (sGenMacBase != null && sGenMacBase != string.Empty) { - sGenMac = sGenMac.Replace("", sGenMacBase + ""); + sGenMac = sGenMac.Replace("", $"{sGenMacBase}"); } if (!sGenMac.Contains("xmlns")) sGenMac = sGenMac.Replace(" token.Substring(1, 1) + token.Substring(token.Length - 2, 1); // The following variables are used to keep track of whether a check off header should be printed // if the {CHKOFFHEADING} pagelist item is found. PageListTopCheckOffHeader is the text that @@ -1356,12 +1090,6 @@ i = 0; } SvgGroup svgGroup = new SvgGroup(); - //int defPtPerRow = 72 / 6; - //int curLPI = 6; // default - //int prevLPI = 6; - //float PrevRow = 0; - //float rowAdj = 0; // = 18; - bool usePSIvalue = false; // C2021-065 used with ROLkUpMatch pagelist flag (Barakah Alarms) string otherChildUnit = string.Empty; // C2021-065 used when OTHER applicability information is used for the ROLookUp // F2023-035: WCN - allow for change in left margin for supplemental information pages by @@ -1388,18 +1116,6 @@ i = 0; VE_Font useFontForCheckOffHeader = null; if (forceLoad || (sPag == SectionConfig.SectionPagination.Separate || ((sPag == SectionConfig.SectionPagination.Continuous || sPag ==0 )&& (pageItem.Row < 0)))) { - //if (PrevRow > 0) - //{ - // //float pgRow = (float)(pageItem.Row + rowAdj); - // if (curLPI != prevLPI) - // { - // int prow = (int)(PrevRow / defPtPerRow); - // int nrows = ((int)(pageItem.Row / defPtPerRow)) - prow; - // rowAdj += (float)Math.Abs(((nrows * (72 / curLPI)) - ((nrows * defPtPerRow) + rowAdj))); - // //rowAdj += (float)(((pgRow - PrevRow) / (72 * prevLPI)) * (72 / curLPI)); - // prevLPI = curLPI; - // } - //} // C2019-006 - Moved and modified the RO_Lookup() logic here, before we process the tokens in the page list // this allows us to use RO_Lookup() in a "PS=" conditional token (is usually a PSI check box) // A while loop was also added to the we can have more than one call to RO_Lookup() on a pagelist line @@ -1502,7 +1218,6 @@ i = 0; foreach (Match match in matches) { string token = match.Value; - //token = Regex.Replace(token, @"[\xB3-\xDF]", " "); // handle any conditional PS tokens if (token.Contains(@"PS=")) @@ -1528,8 +1243,7 @@ i = 0; string relval = procConfig.GetValue("PSI", reltoken); if (relval == "Y") { - //svgGroup.Add(PageItemToSvgText(pageItem.Token, (float)pageItem.RelatedItem.Row, (float)pageItem.RelatedItem.Col, pageItem.RelatedItem.Justify ?? VEPROMS.CSLA.Library.E_Justify.PSLeft, pageItem.Font, val, MySection)); - svgGroup.Add(PageItemToSvgText(pltok, (float)pageItem.RelatedItem.Row, (float)pageItem.RelatedItem.Col, pageItem.RelatedItem.Justify ?? VEPROMS.CSLA.Library.E_Justify.PSLeft, pageItem.Font, val, MySection)); + svgGroup.Add(PageItemToSvgText(pltok, (float)pageItem.RelatedItem.Row, (float)pageItem.RelatedItem.Col, pageItem.RelatedItem.Justify ?? VEPROMS.CSLA.Library.E_Justify.PSLeft, pageItem.Font, val, MySection)); plstr = string.Empty; // Clear it so it isn't put out twice (used below) } } @@ -1540,8 +1254,6 @@ i = 0; val = token.Substring(bindx + 1, eindx - bindx - 1); } if (val != null && val != string.Empty && !PgLogicals.ContainsKey(pstok)) PgLogicals.Add(pstok, val != null); - //if (val == null || val == string.Empty) - //val = " "; if (val == null) val = string.Empty; plstr = plstr.Replace(token, val); @@ -1595,8 +1307,6 @@ i = 0; val = token.Substring(bindx + 1, eindx - bindx - 1); } if (val != null && val != string.Empty && !PgLogicals.ContainsKey(pstok)) PgLogicals.Add(pstok, val != null); - //if (val == null || val == string.Empty) - //val = " "; if (val == null) val = string.Empty; plstr = plstr.Replace(token, val); @@ -1650,23 +1360,18 @@ i = 0; Volian.Base.Library.BaselineMetaFile.WriteLine("No Pagelist Information"); } - private string ROLookup(string accpageid, string multiid, string deflt) - { - return ROLookup(accpageid, multiid, deflt, string.Empty); - } - // C2021-065 pass in a override for the child unit - in this case the token is being used (Barakah Alarms) private string ROLookup(string accpageid, string multiid, string deflt, string overrideChild) { ROFSTLookup myLookup = MySection.MyDocVersion.DocVersionAssociations[0].MyROFst.GetROFSTLookup(MySection.MyDocVersion, overrideChild); string accpgid = accpageid; - ROFSTLookup.rochild roc = myLookup.GetROChildByAccPageID("<" + accpgid + "." + multiid + ">", MySection.MyDocVersion.DocVersionConfig.RODefaults_setpointprefix, MySection.MyDocVersion.DocVersionConfig.RODefaults_graphicsprefix); + ROFSTLookup.rochild roc = myLookup.GetROChildByAccPageID($"<{accpgid}.{multiid}>", MySection.MyDocVersion.DocVersionConfig.RODefaults_setpointprefix, MySection.MyDocVersion.DocVersionConfig.RODefaults_graphicsprefix); if (roc.value == null) { accpgid = accpgid.Replace(@"\u8209?", "-"); - roc = myLookup.GetROChildByAccPageID("<" + accpgid + "." + multiid + ">", MySection.MyDocVersion.DocVersionConfig.RODefaults_setpointprefix, MySection.MyDocVersion.DocVersionConfig.RODefaults_graphicsprefix); + roc = myLookup.GetROChildByAccPageID($"<{accpgid}.{multiid}>", MySection.MyDocVersion.DocVersionConfig.RODefaults_setpointprefix, MySection.MyDocVersion.DocVersionConfig.RODefaults_graphicsprefix); } if (!deflt.StartsWith("[") && !string.IsNullOrEmpty(roc.value) && roc.value.Trim().Length > 0) // don't return val if it's an empty or blank string - jsj 01-28-2019 @@ -1679,19 +1384,9 @@ i = 0; return deflt; } - private bool _DidHLSText = false; - public bool DidHLSText - { - get { return _DidHLSText; } - set { _DidHLSText = value; } - } - private int _HasHLSTextId = 0; - public int HasHLSTextId - { - get { return _HasHLSTextId; } - set { _HasHLSTextId = value; } - } - private string _HLSText = string.Empty; + public bool DidHLSText { get; set; } = false; + public int HasHLSTextId { get; set; } = 0; + private string _HLSText = string.Empty; public string HLSText { get { return _HLSText; } @@ -1701,43 +1396,24 @@ i = 0; _HLSText = value; } } - private string _HLSTAB = string.Empty; - public string HLSTAB - { - get { return _HLSTAB; } - set { _HLSTAB = value; } - } - private string _HLRNO = string.Empty; - public string HLRNO - { - get { return _HLRNO; } - set { _HLRNO = value; } - } - private bool _OldTemplateContMsg = false; - public bool OldTemplateContMsg - { - get { return _OldTemplateContMsg; } - set { _OldTemplateContMsg = value; } - } - private float _AdjustTopMarginForMultiLinePageListItems = 0; - public float AdjustTopMarginForMultiLinePageListItems - { - get { return _AdjustTopMarginForMultiLinePageListItems; } - set { _AdjustTopMarginForMultiLinePageListItems = value; } - } - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// true - if token is resolved - /// false - if entire text is processed - /// - private bool ProcessPaglistToken(VEPROMS.CSLA.Library.SectionInfo section, SvgGroup svgGroup, VEPROMS.CSLA.Library.PageItem pageItem, ref VE_Font useFontForCheckOffHeader, ref string plstr, string token, float supInfoMargAdj) + + public string HLSTAB { get; set; } = string.Empty; + public string HLRNO { get; set; } = string.Empty; + public bool OldTemplateContMsg { get; set; } = false; + public float AdjustTopMarginForMultiLinePageListItems { get; set; } = 0; + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// true - if token is resolved + /// false - if entire text is processed + /// + private bool ProcessPaglistToken(VEPROMS.CSLA.Library.SectionInfo section, SvgGroup svgGroup, VEPROMS.CSLA.Library.PageItem pageItem, ref VE_Font useFontForCheckOffHeader, ref string plstr, string token, float supInfoMargAdj) { bool retval = true; @@ -1755,12 +1431,6 @@ i = 0; plstr = plstr.Replace(token, string.Empty); AddImage(svgGroup, 10f, 10f, 78.7f, 29.8f, "cpllogo.bmp"); break; - //case "{!domlogo}": - // AddImage(svgGroup, 10f, 70f, 123f, 40.1f, "domlogo.bmp"); - // break; - //case "{!gpclogo}": - // AddImage(svgGroup, 10f, 150f, 35.2f, 35.8f, "gpclogo.bmp"); - // break; case "{HEADER1}": case "[HEADER1]": case "{HEADER2}": @@ -1811,29 +1481,22 @@ i = 0; box = "3"; else if (_MySection.SectionConfig.Section_ColumnMode == SectionConfig.SectionColumnMode.Two) box = "2"; - box = "{BOX" + box + "}"; + box = $"{{BOX{box}}}"; plstr = plstr.Replace(token, string.Empty); svgGroup.Add(PageItemToSvgUse(pageItem, FirstAndLast(box), supInfoMargAdj)); break; case "{DRAFTPAGE}": - //if (!AllowedWatermarks.Contains("Draft")) AllowedWatermarks.Add("Draft"); -- B2018-124 not needed anymore plstr = plstr.Replace(token, string.Empty);// Remove token since it is handled now break; case "{REFERENCEPAGE}": - //if (!AllowedWatermarks.Contains("Reference")) AllowedWatermarks.Add("Reference"); -- B2018-124 not needed anymore plstr = plstr.Replace(token, string.Empty);// Remove token since it is handled now break; case "{MASTERPAGE}": - //if (!AllowedWatermarks.Contains("Master")) AllowedWatermarks.Add("Master"); -- B2018-124 not needed anymore plstr = plstr.Replace(token, string.Empty);// Remove token since it is handled now break; case "{SAMPLEPAGE}": - //if (!AllowedWatermarks.Contains("Sample")) AllowedWatermarks.Add("Sample"); -- B2018-124 not needed anymore plstr = plstr.Replace(token, string.Empty);// Remove token since it is handled now break; - //case "{INFORMATIONPAGE}": - // if (!AllowedWatermarks.Contains("Information Only")) AllowedWatermarks.Add("Information Only"); -- B2018-124 not needed anymore - // break; case "{PROCTITLE}": case "[PROCTITLE]": case "{PROCTITLE1}": @@ -1845,7 +1508,6 @@ i = 0; case "{COVERPROCTITLE}": case "[COVERPROCTITLE]": int tlen = (token.Contains("COVERPROCTITLE"))?(int)section.ActiveFormat.PlantFormat.FormatData.ProcData.CoverTitleLength : (int)section.ActiveFormat.PlantFormat.FormatData.ProcData.TitleLength; - //float linelen = (int)section.ActiveFormat.PlantFormat.FormatData.ProcData.TitleLength * (float)pageItem.Font.CPI / 12; float linelen = tlen * (float)pageItem.Font.CPI / 12; string title = section.MyProcedure.MyContent.Text; if (title.Contains("") && !section.ActiveFormat.PlantFormat.FormatData.ProcData.PrintNoTitle) @@ -1924,7 +1586,7 @@ i = 0; // F2023-087: Added PDFDate at PDFTime - note that cannot have multiple tokens in a conditional because of reg expression // processing. case "[PDFDateAtTime]": - plstr = plstr.Replace("[PDFDateAtTime]", DateTime.Now.ToString("MM/dd/yyyy") + " at " + DateTime.Now.ToString("HH:mm:ss")); + plstr = plstr.Replace("[PDFDateAtTime]", $"{DateTime.Now:MM/dd/yyyy} at {DateTime.Now:HH:mm:ss}"); break; case "{EOPNUM}": case "[EOPNUM]": @@ -1984,8 +1646,6 @@ i = 0; eopnum = eopnum.TrimEnd(pageItem.TrimEnding.ToCharArray()); plstr = plstr.Replace(token, eopnum); - //svgGroup.Add(PageItemToSvgText(pageItem, pageItem.Token.Replace(token, eopnum))); - //svgGroup.Add(PageItemToSvgText(pageItem, pageItem.Token.Replace(token, section.MyProcedure.MyContent.Number))); break; case "{SECTIONLEVELTITLE}": case "[SECTIONLEVELTITLE]": @@ -2007,7 +1667,7 @@ i = 0; && token.Contains("ATTACHTITLECONT") && DidFirstPageDocStyle) { string myMsg = section.MyDocStyle.Continue.Top.Message; - if (myMsg != null && myMsg != string.Empty)stitle = stitle + myMsg; + if (myMsg != null && myMsg != string.Empty)stitle += myMsg; } // B2023-043: Beaver Valley AOP - allow attributes, such as superscript on section titles when printing if (section.ActiveFormat.PlantFormat.FormatData.PrintData.SectionTitleWithAttributes) @@ -2024,7 +1684,6 @@ i = 0; } else plstr = plstr.Replace(token, string.Empty); - //svgGroup.Add(PageItemToSvgText(pageItem, section.DisplayText)); break; case "{METASECTIONTITLE}": // This will print the top level section title (versus level above current) starting from a sub-section case "[METASECTIONTITLE]": @@ -2078,7 +1737,6 @@ i = 0; // text starts with a ' - ' - remove it. else if (plstr.StartsWith(" - ") && plstr.IndexOf("{SECTIONLEVELTITLE}") == 3) plstr = plstr.Substring(3); - //svgGroup.Add(PageItemToSvgText(pageItem, pageItem.Token.Replace(token, section.DisplayNumber))); break; case "{METASECTIONNUMBER}": // This will print the top level section number when starting from a sub-section case "[METASECTIONNUMBER]": @@ -2113,7 +1771,6 @@ i = 0; case "{UNITTEXT}": case "[UNITTEXT]": plstr = plstr.Replace(token, MySection.MyDocVersion.DocVersionConfig.Unit_Text); - //svgGroup.Add(PageItemToSvgText(pageItem, pageItem.Token.Replace(token, MySection.MyDocVersion.DocVersionConfig.Unit_Text))); break; case "{UNITNUMBER}": case "[UNITNUMBER]": @@ -2319,15 +1976,9 @@ i = 0; break; case "{INITIALS}": // For Calvert: if this section has checkoffs turned on, put out this pagelist item: - // Get SectionInfos to access specific section config items... - //SectionInfo si = SectionInfo.Get(MySection.ItemID); - //SectionInfo si = MySection.GetSectionInfo(); - //SectionConfig sectCfg = si.MyConfig as SectionConfig; - //int sc = sectCfg.Section_CheckoffListSelection; if (!MySection.HasInitials) { plstr = plstr.Replace(token, string.Empty); - //PIInitials = pageItem; } else { @@ -2341,19 +1992,19 @@ i = 0; } break; case "{REVUNIT}": - // copied from 16bit's pagelist.cs for BGE: - string revUnit = null; - string unitNum = MySection.MyDocVersion.DocVersionConfig.Print_UnitNumberForPageList; - if (Rev != null && Rev != string.Empty) - { - revUnit = Rev; - int indxs = Rev.IndexOf(MySection.ActiveFormat.PlantFormat.FormatData.PrintData.RevDateWithForwardSlash ? '\\' : '/'); - if (indxs > 0) revUnit = Rev.Substring(0, indxs); - } - else - revUnit = " "; + string unitNum = MySection.MyDocVersion.DocVersionConfig.Print_UnitNumberForPageList; + // copied from 16bit's pagelist.cs for BGE: + string revUnit; + if (Rev != null && Rev != string.Empty) + { + revUnit = Rev; + int indxs = Rev.IndexOf(MySection.ActiveFormat.PlantFormat.FormatData.PrintData.RevDateWithForwardSlash ? '\\' : '/'); + if (indxs > 0) revUnit = Rev.Substring(0, indxs); + } + else + revUnit = " "; - if (unitNum == "2") + if (unitNum == "2") revUnit += "/Unit 2"; else if (unitNum == "1") revUnit += "/Unit 1"; @@ -2431,12 +2082,11 @@ i = 0; { int indx = token.IndexOf("-"); int qindx = token.IndexOf("?", indx); - string val = null; - if (qindx == -1) + if (qindx == -1) { - val = procConfig.GetValue("PSI", token.Substring(4, token.Length - 5)); - // F2021-034: Resolve applicability unit tokens (not just '') - if(val.ToUpper().Contains("") || val.ToUpper().Contains("') + if (val.ToUpper().Contains("") || val.ToUpper().Contains("", sindx + 1); } - //string tmp = str.ToUpper(); - //int sindx = tmp.IndexOf("", sindx + 1); - //string reptmp; - //while (sindx > -1 && eindx > -1) // B2022-007 added while loop to process more than one ") str = str.Replace(reptmp, dvi.DocVersionConfig.Unit_Number); - // else if (tmp == "") str = str.Replace(reptmp, dvi.DocVersionConfig.Unit_Text); - // else if (tmp == "") str = str.Replace(reptmp, dvi.DocVersionConfig.Unit_Number); - // else if (tmp == "") str = str.Replace(reptmp, dvi.DocVersionConfig.Unit_Name); - // else if (tmp == "") str = str.Replace(reptmp, dvi.DocVersionConfig.Unit_ID); - // // B2021-145: For applicability, the tree view & pdf file name are not getting resolved when using any of the ‘OTHER’ tokens - // else if (tmp == "") str = str.Replace(reptmp, dvi.DocVersionConfig.Other_Unit_Text); - // else if (tmp == "") str = str.Replace(reptmp, dvi.DocVersionConfig.Other_Unit_Number); - // else if (tmp == "") str = str.Replace(reptmp, dvi.DocVersionConfig.Other_Unit_Name); - // else if (tmp == "") str = str.Replace(reptmp, dvi.DocVersionConfig.Other_Unit_ID); - // else str = str.Replace(reptmp, tmp.Replace("<", "*?").Replace(">", "?*")); - // tmp = str.ToUpper(); - // sindx = tmp.IndexOf("", sindx + 1); - //} return str; } - // B2019-076: moved the following to DocVersionExt.cs to make it available to transitionext.cs code. - //private string GetInheritedSIValue(ProcedureInfo pi, string fieldName) - //{ - // string val = null; - // DocVersionConfig dvConfig = new DocVersionConfig(pi.MyDocVersion.Config); - // if (dvConfig != null) - // { - // val = dvConfig.GetValue("SI", fieldName); - // if (val != null && val != string.Empty) return val; // the value exists within the docversion level - // } - // FolderInfo fi = pi.MyDocVersion.MyFolder; - // while (fi != null) - // { - // FolderConfig folderConfig = new FolderConfig(fi.Config); - // if (folderConfig != null) - // { - // val = folderConfig.GetValue("SI", fieldName); - // if (val != null && val != string.Empty) return val; // the value exists within this folder - // } - // fi = fi.ActiveParent as FolderInfo; - // } - // return val; - //} private static ItemInfo ValveGetFirstStep(VEPROMS.CSLA.Library.SectionInfo section) { ItemInfo firstHigh = null; @@ -2596,7 +2198,7 @@ i = 0; private static void AddImage(SvgGroup svgGroup, float x, float y, float w, float h, string figure) { svgGroup.Add(new SvgImage(new System.Drawing.PointF(x, y), new System.Drawing.SizeF(w, h), - System.Windows.Forms.Application.StartupPath + @"\Resources\" + figure)); + $@"{System.Windows.Forms.Application.StartupPath}\Resources\{figure}")); } private float SplitTextMaxWidth(SvgGroup svgGroup, VEPROMS.CSLA.Library.PageItem pageItem, string title, int? len, string match, ref string plstr) { @@ -2649,7 +2251,6 @@ i = 0; if (match == "{PROCTITLE}") title = title.Replace("\\line ", string.Empty); if (match == "{PROCTITLE2}" || match == "[PROCTITLE2]") return plstr.Replace(match, string.Empty); // this would have been done in proctitle1 plstr = plstr.Replace(match, title).Replace("@@",string.Empty); - //svgGroup.Add(PageItemToSvgText(pageItem, title)); return plstr; } @@ -2657,7 +2258,7 @@ i = 0; // the '@@' marked the starting location for the title. Process this differently than other split titles: if (plstr.Contains("@@")) { - DoSpecialSectNumTitle(svgGroup, pageItem, title, len, match, plstr); + DoSpecialSectNumTitle(svgGroup, pageItem, title, len, plstr); return string.Empty; // all resolved pagelist items were already added to svgGroup for printing. } // Otherwise determine how many line to split the text into @@ -2710,36 +2311,22 @@ i = 0; set { if (_PIInitials != null && value == null) - _LastPIInitials = _PIInitials; + LastPIInitials = _PIInitials; _PIInitials = value; } } - private PageItem _LastPIInitials = null; - public PageItem LastPIInitials - { - get { return _LastPIInitials; } - set { _LastPIInitials = value; } - } - private bool _HasInitials = false; - public bool HasInitials - { - get { return _HasInitials; } - set { _HasInitials = value; } - } - private bool _InitialsPrinted = false; - public bool InitialsPrinted - { - get { return _InitialsPrinted; } - set { _InitialsPrinted = value; } - } - public bool PrintInitials(PdfContentByte cb,float yLocation, float leftMargin) + + public PageItem LastPIInitials { get; set; } = null; + public bool HasInitials { get; set; } = false; + public bool InitialsPrinted { get; set; } = false; + public bool PrintInitials(PdfContentByte cb,float yLocation, float leftMargin) { if (InitialsPrinted) return false; InitialsPrinted = true; vlnParagraph.TextAt(cb,this, PIInitials ?? LastPIInitials, yLocation, leftMargin); return true; } - private void DoSpecialSectNumTitle(SvgGroup svgGroup, VEPROMS.CSLA.Library.PageItem pageItem, string title, int? len, string match, string plstr) + private void DoSpecialSectNumTitle(SvgGroup svgGroup, VEPROMS.CSLA.Library.PageItem pageItem, string title, int? len, string plstr) { // first add anything up to the "@@" to the svgGroup: string befAts = plstr.Substring(0, plstr.IndexOf("@@")); @@ -2783,28 +2370,6 @@ i = 0; } return plstr.Replace(token, string.Empty); } - //private string symblsStr = "\u25CF\u0394"; // string of possible symbol character in a tab - //// add symbol characters as needed - //// "\u25CF" - solid bullet - //// \x0394 - delta - //private float GetTextWidth(VE_Font vefont, string txt, string symblFontName) - //{ - // System.Drawing.Font font = new System.Drawing.Font(vefont.Family, (float)vefont.Size, GetSysFontStyle(vefont)); - // System.Drawing.Font symbFont = new System.Drawing.Font(symblFontName, (float)vefont.Size); - // iTextSharp.text.Font iFont = Volian.Svg.Library.VolianPdf.GetFont(font); - // iTextSharp.text.Font iSymblFont = Volian.Svg.Library.VolianPdf.GetFont(symbFont); - // float w = 0; - // foreach (char c in txt) - // { - // int idx = symblsStr.IndexOf(c); - // if (idx >= 0) // symbol character - use symbol font to find its width - // w += iSymblFont.BaseFont.GetWidthPointKerned(symblsStr[idx].ToString(), (float)vefont.Size); - // else - // w += iFont.BaseFont.GetWidthPointKerned(c.ToString(), (float)vefont.Size); - // } - // //float w = iFont.BaseFont.GetWidthPointKerned(Text.Replace("\u25CF","@"), (float)vefont.Size); - // return w; - //} private string SplitCoverTitle(SvgGroup svgGroup, VEPROMS.CSLA.Library.PageItem pageItem, string title, int? len, string match, string plstr) { @@ -2812,7 +2377,6 @@ i = 0; { if (match == "{COVERTITLE2}" || match == "[COVERTITLE2]") return plstr; // this would have been done in COVERTITLE1 plstr = plstr.Replace(match, title); - //svgGroup.Add(PageItemToSvgText(pageItem, title)); return plstr; } // Otherwise determine how many line to split the text into @@ -2820,12 +2384,10 @@ i = 0; if (match == "{COVERTITLE1}" || match == "[COVERTITLE1]") { plstr = plstr.Replace(match, titleLines[0]); - //svgGroup.Add(PageItemToSvgText(pageItem, titleLines[0])); return plstr; } // if the token was proctitle, dont' adjust. If the token was PROCTITLE1/2 then // move down 6. -// int adj = pageItem.Token.Contains("1") || pageItem.Token.Contains("2") ? 0 : -6; int adj = (titleLines.Count > 2) ? -6 : 0; float yOffset = adj * (titleLines.Count - 2); int lnCnt = 0; @@ -2840,27 +2402,15 @@ i = 0; } return plstr; } - private int FindWidth(string title, int start, int len) - { - for (int ii = start + len; ii > start; ii--) - { - if (title[ii] == ' ') - { - while (title[ii] == ' ') ii--; - if (ii > start) - return 2 + ii - start; - return len; - } - } - return len; - } private SvgPart PageItemToSvgUse(VEPROMS.CSLA.Library.PageItem pageItem, string templateName, float supmargadj) { - SvgUse svgUse = new SvgUse(); - svgUse.UseID = templateName; - svgUse.X = new SvgMeasurement((float)(pageItem.Col ?? 0) + supmargadj, E_MeasurementUnits.PT); // F2023-035: Add in supplemental info margin adjust - svgUse.Y = new SvgMeasurement((float)(pageItem.Row ?? 0), E_MeasurementUnits.PT); - return svgUse; + SvgUse svgUse = new SvgUse + { + UseID = templateName, + X = new SvgMeasurement((float)(pageItem.Col ?? 0) + supmargadj, E_MeasurementUnits.PT), // F2023-035: Add in supplemental info margin adjust + Y = new SvgMeasurement((float)(pageItem.Row ?? 0), E_MeasurementUnits.PT) + }; + return svgUse; } private static SvgText PageItemToSvgText(VEPROMS.CSLA.Library.PageItem pageItem, string text, VE_Font font, SectionInfo mySection, float supmargadj) { @@ -2924,7 +2474,7 @@ i = 0; // setting a value in the DocStyle for the adjustment. svgText.X = new SvgMeasurement((float)lcol - colAdj16bit + supmargadj, E_MeasurementUnits.PT); // F2023-035: Add in supplemental info margin adjust svgText.Y = new SvgMeasurement(row, E_MeasurementUnits.PT); - if (svgText.Font.Underline && svgText.Text.EndsWith(" ")) svgText.Text = svgText.Text.Substring(0, svgText.Text.Length - 1) + "\xA0";// replace last space with a hardspace + if (svgText.Font.Underline && svgText.Text.EndsWith(" ")) svgText.Text = $"{svgText.Text.Substring(0, svgText.Text.Length - 1)}\xA0";// replace last space with a hardspace // C2018-004 create meta file for baseline compares Volian.Base.Library.BaselineMetaFile.WriteLine(" PL x {0} y {1} {2} {3} {4} \"{5}\"", svgText.X, svgText.Y, svgText.FontFamily, svgText.FontSize, svgText.SVGFontStyle, TextForBaseline.FixText(svgText.Text)); return svgText; @@ -2948,8 +2498,8 @@ i = 0; System.Drawing.SizeF mySize = g.MeasureString(text, svgText.Font); while (mySize.Width > fontShrinkAftLen && tmpi > 8) { - tmpi = tmpi - 1; - svgText.FontSize = tmpi.ToString() + "PT"; + tmpi--; + svgText.FontSize = $"{tmpi}PT"; mySize = g.MeasureString(text, svgText.Font); } @@ -2976,9 +2526,11 @@ i = 0; } private SvgPart PageItemToSvgText(VEPROMS.CSLA.Library.PageItem pageItem, string text, float yOffset) { - SvgText svgText = new SvgText(); - svgText.Text = text; - VEPROMS.CSLA.Library.E_Justify justify = pageItem.Justify ?? VEPROMS.CSLA.Library.E_Justify.PSLeft; + SvgText svgText = new SvgText + { + Text = text + }; + VEPROMS.CSLA.Library.E_Justify justify = pageItem.Justify ?? VEPROMS.CSLA.Library.E_Justify.PSLeft; float colAdj16bit = 0; if ((justify & VEPROMS.CSLA.Library.E_Justify.PSLeft) == VEPROMS.CSLA.Library.E_Justify.PSLeft) svgText.Justify = SvgJustify.Left; @@ -3010,18 +2562,21 @@ i = 0; lcol = (lcol * 25) / dotsPerChar; } svgText.Font = pageItem.Font.WindowsFont; - svgText.X = new SvgMeasurement((float)lcol - colAdj16bit, E_MeasurementUnits.PT); // new SvgMeasurement((float)(pageItem.Col ?? 0), E_MeasurementUnits.PT); + svgText.X = new SvgMeasurement((float)lcol - colAdj16bit, E_MeasurementUnits.PT); svgText.Y = new SvgMeasurement((float)(yOffset + pageItem.Row ?? 0), E_MeasurementUnits.PT); - if (svgText.Font.Underline && svgText.Text.EndsWith(" ")) svgText.Text = svgText.Text.Substring(0, svgText.Text.Length - 1) + "\xA0";// replace last space with a hardspace + if (svgText.Font.Underline && svgText.Text.EndsWith(" ")) svgText.Text = $"{svgText.Text.Substring(0, svgText.Text.Length - 1)}\xA0";// replace last space with a hardspace // C2018-004 create meta file for baseline compares Volian.Base.Library.BaselineMetaFile.WriteLine(" PL x {0} y {1} {2} {3} {4} \"{5}\"", svgText.X, svgText.Y, svgText.FontFamily, svgText.FontSize, svgText.SVGFontStyle, TextForBaseline.FixText(svgText.Text)); return svgText; } - private SvgPart PageItemToSvgText(string token, float row, float col, E_Justify just, VE_Font font, string text, SectionInfo MySection) + [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0060:Remove unused parameter", Justification = "Keeping token for Debugging")] + private SvgPart PageItemToSvgText(string token, float row, float col, E_Justify just, VE_Font font, string text, SectionInfo MySection) { - SvgText svgText = new SvgText(); - svgText.Text = text; - VEPROMS.CSLA.Library.E_Justify justify = just; + SvgText svgText = new SvgText + { + Text = text + }; + VEPROMS.CSLA.Library.E_Justify justify = just; float colAdj16bit = 0; if ((justify & VEPROMS.CSLA.Library.E_Justify.PSLeft) == VEPROMS.CSLA.Library.E_Justify.PSLeft) svgText.Justify = SvgJustify.Left; @@ -3059,12 +2614,13 @@ i = 0; svgText.Font = font.WindowsFont; svgText.X = new SvgMeasurement((float)lcol - colAdj16bit, E_MeasurementUnits.PT); // new SvgMeasurement((float)(pageItem.Col ?? 0), E_MeasurementUnits.PT); svgText.Y = new SvgMeasurement(row, E_MeasurementUnits.PT); - if (svgText.Font.Underline && svgText.Text.EndsWith(" ")) svgText.Text = svgText.Text.Substring(0, svgText.Text.Length - 1) + "\xA0";// replace last space with a hardspace + if (svgText.Font.Underline && svgText.Text.EndsWith(" ")) svgText.Text = $"{svgText.Text.Substring(0, svgText.Text.Length - 1)}\xA0";// replace last space with a hardspace // C2018-004 create meta file for baseline compares Volian.Base.Library.BaselineMetaFile.WriteLine(" PL x {0} y {1} {2} {3} {4} \"{5}\"", svgText.X, svgText.Y, svgText.FontFamily, svgText.FontSize, svgText.SVGFontStyle, TextForBaseline.FixText(svgText.Text)); return svgText; } - private static List _MissingTokens = new List(); + [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0044:Add readonly modifier", Justification = "Keeping Collections Not ReadOnly")] + private static List _MissingTokens = new List(); protected override string ReplacePageListToken(Match match) { switch (match.Value) @@ -3110,26 +2666,6 @@ i = 0; return string.Empty; } } - public class ChkListBoxesHelper : List - { - private float _yOffsetStart; - private float _yOffsetEnd; - public ChkListBoxesHelper() - : base() - { - } - public void Add(ItemInfo myHls, float yoffStart, float yoffend) - { - Add(new ChkListBoxHelper()); - } - public void Draw() - { - foreach (ChkListBoxHelper cb in this) - { - - } - } - } public class ChkListBoxHelper { public ChkListBoxHelper() @@ -3151,40 +2687,17 @@ i = 0; } public class PageBookmark { - private ItemInfo _MyItemInfo; - public ItemInfo MyItemInfo + public ItemInfo MyItemInfo { get; set; } + public string Title { get; set; } + public PdfDestination PdfDestination { get; set; } + public PageBookmark(ItemInfo itemInfo, string title, PdfDestination pdfDestination) { - get { return _MyItemInfo; } - set { _MyItemInfo = value; } + MyItemInfo = itemInfo; + Title = title; + PdfDestination = pdfDestination; } - private string _Title; - public string Title - { - get { return _Title; } - set { _Title = value; } - } - private PdfDestination _PdfDestination; - public PdfDestination PdfDestination - { - get { return _PdfDestination; } - set { _PdfDestination = value; } - } - public PageBookmark(ItemInfo itemInfo, string title, PdfDestination pdfDestination) - { - _MyItemInfo = itemInfo; - _Title = title; - _PdfDestination = pdfDestination; - } - internal bool IsTopLevel - { - get - { - ItemInfo parent = MyItemInfo.ActiveParent as ItemInfo; - if (parent == null || parent.IsProcedure) return true; - return false; - } - } - internal int Level + internal bool IsTopLevel => !(MyItemInfo.ActiveParent is ItemInfo parent) || parent.IsProcedure; + internal int Level { get { @@ -3201,48 +2714,17 @@ i = 0; } public class ChangeBarDefinition // anything that is section level should go in here. { - private PrintChangeBar _MyChangeBarType; - public PrintChangeBar MyChangeBarType - { - get { return _MyChangeBarType; } - set { _MyChangeBarType = value; } - } - private PrintChangeBarLoc _MyChangeBarLoc; - public PrintChangeBarLoc MyChangeBarLoc - { - get { return _MyChangeBarLoc; } - set { _MyChangeBarLoc = value; } - } - private PrintChangeBarText _MyChangeBarText; - public PrintChangeBarText MyChangeBarText - { - get { return _MyChangeBarText; } - set { _MyChangeBarText = value; } - } - private string _MyChangeBarMessage; // user defined change bar message from docconfig - public string MyChangeBarMessage - { - get { return _MyChangeBarMessage; } - set { _MyChangeBarMessage = value; } - } - private int _MyChangeBarColumn; // two dimensional array, if both on same side, values are = - public int MyChangeBarColumn - { - get { return _MyChangeBarColumn; } - set { _MyChangeBarColumn = value; } - } - /* + public PrintChangeBar MyChangeBarType { get; set; } + public PrintChangeBarLoc MyChangeBarLoc { get; set; } + public PrintChangeBarText MyChangeBarText { get; set; } + public string MyChangeBarMessage { get; set; } + public int MyChangeBarColumn { get; set; } + /* * could have line thickness (set default from 16-bit), line color (set default as black), line style - */ - public ChangeBarDefinition() + */ + public ChangeBarDefinition() { } - public ChangeBarDefinition(PrintChangeBar myCBT, PrintChangeBarLoc myCBL, PrintChangeBarText myCBTxt, string myCBMsg) - { - _MyChangeBarType = myCBT; - _MyChangeBarLoc = myCBL; - _MyChangeBarText = myCBTxt; - } public ChangeBarDefinition(DocVersionConfig docverConfig, FormatInfo formatInfo) { // if there is not overridden data on the docversion, prompt user... @@ -3250,81 +2732,58 @@ i = 0; if (docverConfig == null || docverConfig.Print_ChangeBar == PrintChangeBar.SelectBeforePrinting) { // use these for now, i.e. this is what user would have selected from dialog. - _MyChangeBarType = PrintChangeBar.WithDefault; - _MyChangeBarLoc = PrintChangeBarLoc.OutsideBox; - _MyChangeBarText = PrintChangeBarText.None; + MyChangeBarType = PrintChangeBar.WithDefault; + MyChangeBarLoc = PrintChangeBarLoc.OutsideBox; + MyChangeBarText = PrintChangeBarText.None; } else { - _MyChangeBarType = docverConfig.Print_ChangeBar; - _MyChangeBarLoc = docverConfig.Print_ChangeBarLoc; - _MyChangeBarText = docverConfig.Print_ChangeBarText; + MyChangeBarType = docverConfig.Print_ChangeBar; + MyChangeBarLoc = docverConfig.Print_ChangeBarLoc; + MyChangeBarText = docverConfig.Print_ChangeBarText; } - if (_MyChangeBarType == PrintChangeBar.WithDefault) // get data from format + if (MyChangeBarType == PrintChangeBar.WithDefault) // get data from format { - _MyChangeBarText = changeBarData.ChangeBarMessage == "ChgID" ? PrintChangeBarText.ChgID : + MyChangeBarText = changeBarData.ChangeBarMessage == "ChgID" ? PrintChangeBarText.ChgID : changeBarData.ChangeBarMessage == "DateAndChgID" ? PrintChangeBarText.DateChgID : changeBarData.ChangeBarMessage == "None" ? PrintChangeBarText.None : changeBarData.ChangeBarMessage == "RevNum" ? PrintChangeBarText.RevNum : PrintChangeBarText.UserDef; } - if (_MyChangeBarType != PrintChangeBar.Without) + if (MyChangeBarType != PrintChangeBar.Without) { // if the format has the absolutefixedchangecolumn format flag, then always use the fixedchangecolumn from the // format, otherwise, use the default column based on the selected location, stored in the base format. - _MyChangeBarColumn = (changeBarData.AbsoluteFixedChangeColumn) ? + MyChangeBarColumn = (changeBarData.AbsoluteFixedChangeColumn) ? (int)changeBarData.FixedChangeColumn : - System.Convert.ToInt32(changeBarData.DefaultCBLoc.Split(",".ToCharArray())[(int)(_MyChangeBarLoc)]); - if (_MyChangeBarText == PrintChangeBarText.UserDef) - _MyChangeBarMessage = docverConfig.Print_UserCBMess1 + @"\n" + docverConfig.Print_UserCBMess2; + System.Convert.ToInt32(changeBarData.DefaultCBLoc.Split(",".ToCharArray())[(int)(MyChangeBarLoc)]); + if (MyChangeBarText == PrintChangeBarText.UserDef) + MyChangeBarMessage = docverConfig.Print_UserCBMess1 + @"\n" + docverConfig.Print_UserCBMess2; } } } public class CheckOffHeaderHelper { - private SvgText _SvgText; - public SvgText SvgText + public SvgText SvgText { get; set; } + public VEPROMS.CSLA.Library.VE_Font CheckOffHeaderFont { get; set; } + public CheckOffHeaderHelper(SvgText stext, VEPROMS.CSLA.Library.VE_Font vf) { - get { return _SvgText; } - set { _SvgText = value; } - } - private VEPROMS.CSLA.Library.VE_Font _CheckOffHeaderFont; - public VEPROMS.CSLA.Library.VE_Font CheckOffHeaderFont - { - get { return _CheckOffHeaderFont; } - set { _CheckOffHeaderFont = value; } - } - public CheckOffHeaderHelper(SvgText stext, VEPROMS.CSLA.Library.VE_Font vf) - { - _SvgText = stext; - _CheckOffHeaderFont = vf; + SvgText = stext; + CheckOffHeaderFont = vf; } } public class Gap { - private float _YTop; - public float YTop + public float YTop { get; set; } + public float YBottom { get; set; } + public Gap(float yTop, float yBottom) { - get { return _YTop; } - set { _YTop = value; } - } - private float _YBottom; - public float YBottom - { - get { return _YBottom; } - set { _YBottom = value; } - } - public Gap(float yTop, float yBottom) - { - _YTop = yTop; - _YBottom = yBottom; + YTop = yTop; + YBottom = yBottom; } } public class Gaps : List { - public void Add(float yTop, float yBotttom) - { - this.Add(new Gap(yTop, yBotttom)); - } - } + public void Add(float yTop, float yBotttom) => this.Add(new Gap(yTop, yBotttom)); + } } diff --git a/PROMS/Volian.Print.Library/Volian.Print.Library.csproj b/PROMS/Volian.Print.Library/Volian.Print.Library.csproj index d4694ccd..6c40776f 100644 --- a/PROMS/Volian.Print.Library/Volian.Print.Library.csproj +++ b/PROMS/Volian.Print.Library/Volian.Print.Library.csproj @@ -106,6 +106,7 @@ + diff --git a/PROMS/Volian.Print.Library/pdf.cs b/PROMS/Volian.Print.Library/pdf.cs index ccfbc88d..6ceb72de 100644 --- a/PROMS/Volian.Print.Library/pdf.cs +++ b/PROMS/Volian.Print.Library/pdf.cs @@ -1,46 +1,26 @@ using System; -using System.Collections.Generic; using System.Text; using iTextSharp.text; using iTextSharp.text.pdf; using System.IO; -using Microsoft.Win32; using Volian.Base.Library; namespace Volian.Print.Library { public class pdf { - private Document _MyDocument; - public Document MyDocument + public Document MyDocument { get; set; } + public PdfWriter MyWriter { get; set; } + public string MyFileName { get; set; } + public PdfContentByte ContentByte => MyWriter.DirectContent; + public pdf(string myFileName) { - get { return _MyDocument; } - set { _MyDocument = value; } - } - private PdfWriter _MyWriter; - public PdfWriter MyWriter - { - get { return _MyWriter; } - set { _MyWriter = value; } - } - private string _MyFileName; - public string MyFileName - { - get { return _MyFileName; } - set { _MyFileName = value; } - } - public PdfContentByte ContentByte - { - get { return _MyWriter.DirectContent; } - } - public pdf(string myFileName) - { - _MyFileName = myFileName; - _MyDocument = new Document(PageSize.LETTER); + MyFileName = myFileName; + MyDocument = new Document(PageSize.LETTER); try { - _MyWriter = PdfWriter.GetInstance(_MyDocument, new FileStream(myFileName, FileMode.Create)); - _MyWriter.SetAtLeastPdfVersion(PdfWriter.VERSION_1_7); + MyWriter = PdfWriter.GetInstance(MyDocument, new FileStream(myFileName, FileMode.Create)); + MyWriter.SetAtLeastPdfVersion(PdfWriter.VERSION_1_7); } catch (Exception ex) { @@ -49,24 +29,21 @@ namespace Volian.Print.Library } public pdf(string myFileName, Rectangle mySize) { - _MyFileName = myFileName; - _MyDocument = new Document(mySize); + MyFileName = myFileName; + MyDocument = new Document(mySize); try { - _MyWriter = PdfWriter.GetInstance(_MyDocument, new FileStream(myFileName, FileMode.Create)); - _MyWriter.SetAtLeastPdfVersion(PdfWriter.VERSION_1_7); + MyWriter = PdfWriter.GetInstance(MyDocument, new FileStream(myFileName, FileMode.Create)); + MyWriter.SetAtLeastPdfVersion(PdfWriter.VERSION_1_7); } catch (Exception ex) { Console.WriteLine("{0} - {1}\r\n{2}", ex.GetType().Name, ex.Message, ex.StackTrace); } } - public void Close() - { - MyDocument.Close(); - } - private Color _WatermarkColor = Color.BLUE; - private float _WatermarkOpacity = .10F; + public void Close() => MyDocument.Close(); + private readonly Color _WatermarkColor = Color.BLUE; + private readonly float _WatermarkOpacity = .10F; public void WatermarkPageNumber(int pageNumber) { Rectangle pageSize = ContentByte.PdfWriter.PageSize; // Get page size @@ -84,9 +61,11 @@ namespace Volian.Print.Library ContentByte.SetLineWidth(.5F); ContentByte.SetFontAndSize(myBasefont, myFontSize);// Set font and size ContentByte.SetColorStroke(_WatermarkColor); - PdfGState gs2 = new PdfGState(); - gs2.StrokeOpacity = _WatermarkOpacity; - ContentByte.SetGState(gs2); + PdfGState gs2 = new PdfGState + { + StrokeOpacity = _WatermarkOpacity + }; + ContentByte.SetGState(gs2); ContentByte.ShowTextAlignedKerned(PdfContentByte.ALIGN_CENTER, strPage, pageSize.Width / 2, 0, 0);// Draw the text ContentByte.EndText(); ContentByte.FillStroke(); // Controlled by TextRenderMode above @@ -108,9 +87,11 @@ namespace Volian.Print.Library { PdfPatternPainter myPatternPainter; myPatternPainter = ContentByte.CreatePattern(radius * 4, radius * 2, radius * 4, radius * 2); - PdfGState gState = new PdfGState(); - gState.FillOpacity = _WatermarkOpacity; - myPatternPainter.SetGState(gState); + PdfGState gState = new PdfGState + { + FillOpacity = _WatermarkOpacity + }; + myPatternPainter.SetGState(gState); myPatternPainter.SetColorFill(_WatermarkColor); myPatternPainter.Rectangle(0, 0, radius, radius); myPatternPainter.Rectangle(radius * 2, radius, radius, radius); diff --git a/PROMS/Volian.Print.Library/pkParagraph.cs b/PROMS/Volian.Print.Library/pkParagraph.cs index 0a57b8c3..4a6f8d53 100644 --- a/PROMS/Volian.Print.Library/pkParagraph.cs +++ b/PROMS/Volian.Print.Library/pkParagraph.cs @@ -1,27 +1,16 @@ -using System; using System.Collections.Generic; -using System.Text; namespace Volian.Print.Library { public class pkParagraph { - private vlnParagraph _MyParagraph; - public vlnParagraph MyParagraph - { - get { return _MyParagraph; } - } - private pkParagraphs _MyChildren; - public pkParagraphs MyChildren - { - get { return _MyChildren; } - } - private pkParagraphs _MyCautionsAndNotes; - public pkParagraphs MyCautionsAndNotes - { - get { return _MyCautionsAndNotes; } - } - public pkParagraph(vlnParagraph myParagraph) + private readonly vlnParagraph _MyParagraph; + public vlnParagraph MyParagraph => _MyParagraph; + private readonly pkParagraphs _MyChildren; + public pkParagraphs MyChildren => _MyChildren; + private readonly pkParagraphs _MyCautionsAndNotes; + public pkParagraphs MyCautionsAndNotes => _MyCautionsAndNotes; + public pkParagraph(vlnParagraph myParagraph) { _MyParagraph = myParagraph; _MyChildren = new pkParagraphs(); diff --git a/PROMS/Volian.Print.Library/vlnBox.cs b/PROMS/Volian.Print.Library/vlnBox.cs index 4ea37c80..9a7b514e 100644 --- a/PROMS/Volian.Print.Library/vlnBox.cs +++ b/PROMS/Volian.Print.Library/vlnBox.cs @@ -3,7 +3,6 @@ using System.Collections.Generic; using System.Text; using System.Drawing; using iTextSharp.text.pdf; -using iTextSharp.text; using VEPROMS.CSLA.Library; @@ -12,23 +11,11 @@ namespace Volian.Print.Library public partial class vlnBox : vlnPrintObject { private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); - private int _LineType; /* how to represent?? */ - private System.Drawing.Color _Color; - public System.Drawing.Color Color - { - get { return _Color; } - set { _Color = value; } - } - private Box _MyBox; - public Box MyBox - { - get { return _MyBox; } - set { _MyBox = value; } - } - // the following two fields are used if 'boxed' step, thus - // no 'Box' was defined in format file. - public override float Height + public Box MyBox { get; set; } + // the following two fields are used if 'boxed' step, thus + // no 'Box' was defined in format file. + public override float Height { get { @@ -41,26 +28,13 @@ namespace Volian.Print.Library public string DefBox = null; public float DefEnd = 0; - private bool _ContainsPageBreak = false; - public bool ContainsPageBreak - { - get { return _ContainsPageBreak; } - set { _ContainsPageBreak = value; } - } - private bool _DoubleBoxHls = false; // BGE double lined box around HLS - public bool DoubleBoxHls - { - get { return _DoubleBoxHls; } - set { _DoubleBoxHls = value; } - } - public const string DOUBLEboxHLS = "DoubleBox"; + public bool ContainsPageBreak { get; set; } = false; + public bool DoubleBoxHls { get; set; } = false; + public const string DOUBLEboxHLS = "DoubleBox"; //private bool _DoBottom = true; public vlnBox() { } - public vlnBox(vlnParagraph paragraph) - { - } public const string BoxThin = "\x2510.\x2500.\x250c.\x2502. . .\x2518.\x2514. .\x2500. . "; const string BoxThick = "\x2584.\x2584.\x2584.\x2588. . .\x2580.\x2580. .\x2580. . "; const string BoxDouble = "\x2557.\x2550.\x2554.\x2551. . .\x255D.\x255A. .\x2550. . "; @@ -95,10 +69,9 @@ namespace Volian.Print.Library if (MyBox == null) return yPageStart; cb.SaveState(); VlnSvgPageHelper _MyPageHelper = cb.PdfWriter.PageEvent as VlnSvgPageHelper; - PdfLayer textLayer = _MyPageHelper == null ? null : _MyPageHelper.TextLayer; + PdfLayer textLayer = _MyPageHelper?.TextLayer; if (textLayer != null) cb.BeginLayer(textLayer); MyContentByte = cb; - //Console.WriteLine("'{0}','{1}'", CharToAsc(MyBox.BoxStyle), MyParent.MyItemInfo.ShortPath); float top = CalculateYOffset(yPageStart, yTopMargin) - (7*MyPageHelper.YMultiplier); float bottom = top - (Height * MyPageHelper.YMultiplier); float left = (float)((MyBox.Start ?? 0) + MyParent.MyItemInfo.MyDocStyle.Layout.LeftMargin); @@ -157,7 +130,7 @@ namespace Volian.Print.Library else { const float llxOffset = 3; - float lineThickness = 0; + float lineThickness; switch (MyBox.BoxStyle) { case BoxThin: @@ -331,23 +304,23 @@ namespace Volian.Print.Library // create a new font without any styles such as underline. E_Style es = ((vef.Style & E_Style.Bold) == E_Style.Bold) ? E_Style.Bold : E_Style.None; - // if the box has a font, use it - otherwise use this item info's font - VE_Font vf = null; - bool UseBoxFont = false; - try + bool UseBoxFont = false; + try { UseBoxFont = MyParent.MyItemInfo.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.StepSectionPrintData.DiffContActBox; } catch // done this way in case one of the format properties is null in the previous statement, UseBoxFont will be false. { } - if (UseBoxFont) - vf = new VE_Font(vef.Family, (int)vef.Size, es, (float)MyParent.MyItemInfo.FormatStepData.Font.CPI); - else - vf = new VE_Font(MyParent.MyItemInfo.FormatStepData.Font.Family, (int)MyParent.MyItemInfo.FormatStepData.Font.Size, es, (float)MyParent.MyItemInfo.FormatStepData.Font.CPI); + // if the box has a font, use it - otherwise use this item info's font + VE_Font vf; + if (UseBoxFont) + vf = new VE_Font(vef.Family, (int)vef.Size, es, (float)MyParent.MyItemInfo.FormatStepData.Font.CPI); + else + vf = new VE_Font(MyParent.MyItemInfo.FormatStepData.Font.Family, (int)MyParent.MyItemInfo.FormatStepData.Font.Size, es, (float)MyParent.MyItemInfo.FormatStepData.Font.CPI); - // To find the length of the line, account for the length of the upper right corner also (BXURC) - int urcLen = MyBox.BXHorz[MyBox.BXHorz.Length - 1] == ' ' && MyBox.BXURC[0] == ' ' ? 1 : MyBox.BXURC.Length; + // To find the length of the line, account for the length of the upper right corner also (BXURC) + int urcLen = MyBox.BXHorz[MyBox.BXHorz.Length - 1] == ' ' && MyBox.BXURC[0] == ' ' ? 1 : MyBox.BXURC.Length; float endHorz = (float)MyBox.End - (float)MyBox.Start - (float)(urcLen * (72 / vf.CPI)); float bxHorzTextWidth = GetTextWidth(vf, MyBox.BXHorz); // get the width of the BXHorz string @@ -355,21 +328,21 @@ namespace Volian.Print.Library StringBuilder sb = new StringBuilder(); sb.Append(MyBox.BXULC); float size = GetTextWidth(vf, MyBox.BXULC); //(float)(MyBox.BXULC.Length * (72 / vf.CPI)); - string bxstr = null; - if (!ContainsPageBreak) // Only do top line if there is no page break. + string bxstr; + if (!ContainsPageBreak) // Only do top line if there is no page break. { while (size < endHorz) { sb.Append(MyBox.BXHorz); - size = size + bxHorzTextWidth; //(float)(MyBox.BXHorz.Length * (72 / vf.CPI)); + size += bxHorzTextWidth; //(float)(MyBox.BXHorz.Length * (72 / vf.CPI)); } // Tack on the right upper corner. For some formats, the upper right corner in the // had the first character as a space, this would put two spaces in a row at the // end of the string, so remove the space before tacking on the upper right corner: bxstr = sb.ToString(); if (bxstr[bxstr.Length - 1] == ' ' && MyBox.BXURC[0] == ' ') bxstr = bxstr.TrimEnd(); - bxstr = bxstr + MyBox.BXURC; - size = size + GetTextWidth(vf, MyBox.BXURC);//(float)((MyBox.BXURC.Length) * (72 / vf.CPI)); + bxstr += MyBox.BXURC; + size += GetTextWidth(vf, MyBox.BXURC);//(float)((MyBox.BXURC.Length) * (72 / vf.CPI)); Rtf = GetRtf(bxstr, vf); IParagraph = null; // set to null so that next access of IParagraph sets the Rtf. Rtf2Pdf.TextAt(cb, IParagraph, left, top, size + 10, 100, "", yBottomMargin); @@ -384,15 +357,15 @@ namespace Volian.Print.Library while (size < endHorz) { sb.Append(MyBox.BXHorz); - size = size + bxHorzTextWidth;//(float)(MyBox.BXHorz.Length * (72 / vf.CPI)); + size += bxHorzTextWidth;//(float)(MyBox.BXHorz.Length * (72 / vf.CPI)); } bxstr = sb.ToString().TrimEnd() + MyBox.BXLRC; - size = size + GetTextWidth(vf, MyBox.BXLRC); //(float)((MyBox.BXLRC.Length) * (72 / vf.CPI)); + size += GetTextWidth(vf, MyBox.BXLRC); //(float)((MyBox.BXLRC.Length) * (72 / vf.CPI)); Rtf = GetRtf(bxstr, vf); IParagraph = null; // set to null so that next access of IParagraph sets the Rtf. Rtf2Pdf.TextAt(cb, IParagraph, left, bottom, size + 10, 100, "", yBottomMargin); } - private string symblsStr = "\u25CF\u0394"; // string of possible symbol character in a tab + private readonly string symblsStr = "\u25CF\u0394"; // string of possible symbol character in a tab // add symbol characters as needed // "\u25CF" - solid bullet // \x0394 - delta @@ -409,8 +382,6 @@ namespace Volian.Print.Library // follow through in fixing an Out of Window Handles bug, use new function to see if // we can retrieve the font from a dictionary instead a doing a New and using another // window handle - //System.Drawing.Font font = new System.Drawing.Font(vefont.Family, (float)vefont.Size, GetSysFontStyle(vefont)); - //System.Drawing.Font symbFont = new System.Drawing.Font(symblFontName, (float)vefont.Size); System.Drawing.Font font = VE_Font.GetWinSysFont(vefont.Family, (float)vefont.Size, GetSysFontStyle(vefont)); System.Drawing.Font symbFont = VE_Font.GetWinSysFont(symblFontName, (float)vefont.Size); iTextSharp.text.Font iFont = Volian.Svg.Library.VolianPdf.GetFont(font); @@ -424,10 +395,10 @@ namespace Volian.Print.Library else w += iFont.BaseFont.GetWidthPointKerned(c.ToString(), (float)vefont.Size); } - //float w = iFont.BaseFont.GetWidthPointKerned(Text.Replace("\u25CF","@"), (float)vefont.Size); return w; } - private void DrawAsteriskSide(PdfContentByte cb, float yPageStart, float yTopMargin, float yBottomMargin, float top, float bottom, float left, float right, VE_Font vef) + [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0060:Remove unused parameter", Justification = "top and bottom kept for debugging")] + private void DrawAsteriskSide(PdfContentByte cb, float yPageStart, float yTopMargin, float yBottomMargin, float top, float bottom, float left, float right, VE_Font vef) { // set the top & bottom of sides. If there is a page break in the middle of box, adjust these. // The vlnBox property, ContainsPageBreak, flags that a break occurred. @@ -453,23 +424,23 @@ namespace Volian.Print.Library // create a new font without any styles such as underline. E_Style es = ((vef.Style & E_Style.Bold) == E_Style.Bold) ? E_Style.Bold : E_Style.None; - // if the box has a font, use it - otherwise use this item info's font - VE_Font vf = null; - bool UseBoxFont = false; - try + bool UseBoxFont = false; + try { UseBoxFont = MyParent.MyItemInfo.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.StepSectionPrintData.DiffContActBox; } catch // done this way in case one of the format properties is null in the previous statement, UseBoxFont will be false. { } - if (UseBoxFont) - vf = new VE_Font(vef.Family, (int)vef.Size, es, (float)MyParent.MyItemInfo.FormatStepData.Font.CPI); - else - vf = new VE_Font(MyParent.MyItemInfo.FormatStepData.Font.Family, (int)MyParent.MyItemInfo.FormatStepData.Font.Size, es, (float)MyParent.MyItemInfo.FormatStepData.Font.CPI); + // if the box has a font, use it - otherwise use this item info's font + VE_Font vf; + if (UseBoxFont) + vf = new VE_Font(vef.Family, (int)vef.Size, es, (float)MyParent.MyItemInfo.FormatStepData.Font.CPI); + else + vf = new VE_Font(MyParent.MyItemInfo.FormatStepData.Font.Family, (int)MyParent.MyItemInfo.FormatStepData.Font.Size, es, (float)MyParent.MyItemInfo.FormatStepData.Font.CPI); - // Left side first: - Rtf = GetRtf(MyBox.BXVert, vf); + // Left side first: + Rtf = GetRtf(MyBox.BXVert, vf); IParagraph = null; // set to null so that next access of IParagraph sets the Rtf. // start down one line because the top/bottom code draws the corner float vertDiff = top - (SixLinesPerInch * MyPageHelper.YMultiplier); @@ -503,17 +474,8 @@ namespace Volian.Print.Library } return sb.ToString(); } - private static List _UnimplementedBoxStyles = new List(); - private string CharToAsc(string p) - { - StringBuilder sb = new StringBuilder(); - foreach (char c in p) - { - if (c >= ' ' && c < 127) sb.Append(c); - else sb.Append(string.Format("\\x{0:x}", (int)c)); - } - return sb.ToString(); - } + [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0044:Add readonly modifier", Justification = "Keeping Collections Not ReadOnly")] + private static List _UnimplementedBoxStyles = new List(); private void DrawAsteriskTopBottomHLS(PdfContentByte cb, float yPageStart, float yTopMargin, float yBottomMargin, ref float top, ref float bottom, float left, VE_Font vef) { // this box is not drawn, it is a series of asterisks drawn above and below text. @@ -527,45 +489,45 @@ namespace Volian.Print.Library bottom = ytmpbottom1; // create a new font without any styles such as underline. E_Style es = ((vef.Style & E_Style.Bold) == E_Style.Bold) ? E_Style.Bold : E_Style.None; - // if the box has a font, use it - otherwise use this item info's font - VE_Font vf = null; - bool UseBoxFont = false; - try + bool UseBoxFont = false; + try { UseBoxFont = MyParent.MyItemInfo.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.StepSectionPrintData.DiffContActBox; } catch // done this way in case one of the format properties is null in the previous statement, UseBoxFont will be false. { } - if (UseBoxFont) - vf = new VE_Font(vef.Family, (int)vef.Size, es, (float)MyParent.MyItemInfo.FormatStepData.Font.CPI); - else - vf = new VE_Font(MyParent.MyItemInfo.FormatStepData.Font.Family, (int)MyParent.MyItemInfo.FormatStepData.Font.Size, es, (float)MyParent.MyItemInfo.FormatStepData.Font.CPI); + // if the box has a font, use it - otherwise use this item info's font + VE_Font vf; + if (UseBoxFont) + vf = new VE_Font(vef.Family, (int)vef.Size, es, (float)MyParent.MyItemInfo.FormatStepData.Font.CPI); + else + vf = new VE_Font(MyParent.MyItemInfo.FormatStepData.Font.Family, (int)MyParent.MyItemInfo.FormatStepData.Font.Size, es, (float)MyParent.MyItemInfo.FormatStepData.Font.CPI); - // To find the length of the line, account for the length of the upper right corner also (BXURC) - int urcLen = MyBox.BXHorz[MyBox.BXHorz.Length - 1] == ' ' && MyBox.BXURC[0] == ' ' ? 1 : MyBox.BXURC.Length; + // To find the length of the line, account for the length of the upper right corner also (BXURC) + int urcLen = MyBox.BXHorz[MyBox.BXHorz.Length - 1] == ' ' && MyBox.BXURC[0] == ' ' ? 1 : MyBox.BXURC.Length; float endHorz = (float)MyBox.End - (float)MyBox.Start - (float)(urcLen * (72 / vf.CPI)); float bxHorzTextWidth = GetTextWidth(vf, MyBox.BXHorz); // get the width of the BXHorz string // Do the top line first: StringBuilder sb = new StringBuilder(); sb.Append(MyBox.BXULC); - float size = GetTextWidth(vf, MyBox.BXULC); //(float)(MyBox.BXULC.Length * (72 / vf.CPI)); - string bxstr = null; - if (!ContainsPageBreak) // Only do top line if there is no page break. + float size = GetTextWidth(vf, MyBox.BXULC); + string bxstr; + if (!ContainsPageBreak) // Only do top line if there is no page break. { while (size < endHorz) { sb.Append(MyBox.BXHorz); - size = size + bxHorzTextWidth; //(float)(MyBox.BXHorz.Length * (72 / vf.CPI)); + size += bxHorzTextWidth; } // Tack on the right upper corner. For some formats, the upper right corner in the // had the first character as a space, this would put two spaces in a row at the // end of the string, so remove the space before tacking on the upper right corner: bxstr = sb.ToString(); if (bxstr[bxstr.Length - 1] == ' ' && MyBox.BXURC[0] == ' ') bxstr = bxstr.TrimEnd(); - bxstr = bxstr + MyBox.BXURC; - size = size + GetTextWidth(vf, MyBox.BXURC);//(float)((MyBox.BXURC.Length) * (72 / vf.CPI)); + bxstr += MyBox.BXURC; + size += GetTextWidth(vf, MyBox.BXURC);//(float)((MyBox.BXURC.Length) * (72 / vf.CPI)); Rtf = GetRtf(bxstr, vf); IParagraph = null; // set to null so that next access of IParagraph sets the Rtf. Rtf2Pdf.TextAt(cb, IParagraph, left, top, size + 10, 100, "", yBottomMargin); @@ -576,24 +538,25 @@ namespace Volian.Print.Library sb.Remove(0, sb.Length); sb.Append(MyBox.BXLLC); - size = GetTextWidth(vf, MyBox.BXLLC); //(float)(MyBox.BXLLC.Length * (72 / vf.CPI)); + size = GetTextWidth(vf, MyBox.BXLLC); while (size < endHorz) { sb.Append(MyBox.BXHorz); - size = size + bxHorzTextWidth;//(float)(MyBox.BXHorz.Length * (72 / vf.CPI)); + size += bxHorzTextWidth; } bxstr = sb.ToString().TrimEnd() + MyBox.BXLRC; - size = size + GetTextWidth(vf, MyBox.BXLRC); //(float)((MyBox.BXLRC.Length) * (72 / vf.CPI)); + size += GetTextWidth(vf, MyBox.BXLRC); Rtf = GetRtf(bxstr, vf); IParagraph = null; // set to null so that next access of IParagraph sets the Rtf. Rtf2Pdf.TextAt(cb, IParagraph, left, bottom, size + 10, 100, "", yBottomMargin); } - private void DrawAsteriskSideHLS(PdfContentByte cb, float yPageStart, float yTopMargin, float yBottomMargin, float top, float bottom, float left, float right, VE_Font vef) + [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0060:Remove unused parameter", Justification = "top and bottom kept for debugging")] + private void DrawAsteriskSideHLS(PdfContentByte cb, float yPageStart, float yTopMargin, float yBottomMargin, float top, float bottom, float left, float right, VE_Font vef) { - // set the top & bottom of sides. If there is a page break in the middle of box, adjust these. - // The vlnBox property, ContainsPageBreak, flags that a break occurred. - float yOffBreak = 0; - if (!ContainsPageBreak) + // set the top & bottom of sides. If there is a page break in the middle of box, adjust these. + // The vlnBox property, ContainsPageBreak, flags that a break occurred. + float yOffBreak; + if (!ContainsPageBreak) { top = CalculateYOffset(yPageStart, yTopMargin); if (MyPageHelper.YMultiplier != 1) top += 2; @@ -613,8 +576,11 @@ namespace Volian.Print.Library } else { - top = CalculateYOffset(yPageStart, yTopMargin); - yOffBreak = MyPageHelper.ParaBreaks.Count > 0 ? MyPageHelper.ParaBreaks[0].YOffset : 0; + +#pragma warning disable IDE0059 // Unnecessary assignment of a value - Keeping top for Debugging + top = CalculateYOffset(yPageStart, yTopMargin); +#pragma warning restore IDE0059 // Unnecessary assignment of a value + yOffBreak = MyPageHelper.ParaBreaks.Count > 0 ? MyPageHelper.ParaBreaks[0].YOffset : 0; if (yOffBreak > 0) bottom = (yPageStart - yOffBreak) * MyPageHelper.YMultiplier; else @@ -636,23 +602,23 @@ namespace Volian.Print.Library // create a new font without any styles such as underline. E_Style es = ((vef.Style & E_Style.Bold) == E_Style.Bold) ? E_Style.Bold : E_Style.None; - // if the box has a font, use it - otherwise use this item info's font - VE_Font vf = null; - bool UseBoxFont = false; - try + bool UseBoxFont = false; + try { UseBoxFont = MyParent.MyItemInfo.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.StepSectionPrintData.DiffContActBox; } catch // done this way in case one of the format properties is null in the previous statement, UseBoxFont will be false. { } - if (UseBoxFont) - vf = new VE_Font(vef.Family, (int)vef.Size, es, (float)MyParent.MyItemInfo.FormatStepData.Font.CPI); - else - vf = new VE_Font(MyParent.MyItemInfo.FormatStepData.Font.Family, (int)MyParent.MyItemInfo.FormatStepData.Font.Size, es, (float)MyParent.MyItemInfo.FormatStepData.Font.CPI); + // if the box has a font, use it - otherwise use this item info's font + VE_Font vf; + if (UseBoxFont) + vf = new VE_Font(vef.Family, (int)vef.Size, es, (float)MyParent.MyItemInfo.FormatStepData.Font.CPI); + else + vf = new VE_Font(MyParent.MyItemInfo.FormatStepData.Font.Family, (int)MyParent.MyItemInfo.FormatStepData.Font.Size, es, (float)MyParent.MyItemInfo.FormatStepData.Font.CPI); - // Left side first: - Rtf = GetRtf(MyBox.BXVert, vf); + // Left side first: + Rtf = GetRtf(MyBox.BXVert, vf); IParagraph = null; // set to null so that next access of IParagraph sets the Rtf. // start down one line because the top/bottom code draws the corner float vertDiff = top - (SixLinesPerInch * MyPageHelper.YMultiplier); diff --git a/PROMS/Volian.Print.Library/vlnChangeBar.cs b/PROMS/Volian.Print.Library/vlnChangeBar.cs index 4c23968a..f1ae997a 100644 --- a/PROMS/Volian.Print.Library/vlnChangeBar.cs +++ b/PROMS/Volian.Print.Library/vlnChangeBar.cs @@ -1,7 +1,5 @@ using System; using System.Collections.Generic; -using System.Text; -using System.Drawing; using iTextSharp.text.pdf; using iTextSharp.text; using VEPROMS.CSLA.Library; @@ -10,45 +8,26 @@ namespace Volian.Print.Library { public class vlnChangeBarMessage { - private float _ParentX; - public float ParentX - { - get { return _ParentX; } - set { _ParentX = value; } - } - private string _Message; - public string Message - { - get { return _Message; } - set { _Message = value; } - } - private static int _UniqueMessageId = 0; + public float ParentX { get; set; } + public string Message { get; set; } + private static int _UniqueMessageId = 0; public static int UniqueMessageId { - get { return vlnChangeBarMessage._UniqueMessageId++; } - set { vlnChangeBarMessage._UniqueMessageId = value; } + get { return _UniqueMessageId++; } + set { _UniqueMessageId = value; } } - private int _MessageId = UniqueMessageId; - public int MessageId + + public int MessageId { get; set; } = UniqueMessageId; + public vlnChangeBarMessage(float parentx, string msg) { - get { return _MessageId; } - set { _MessageId = value; } - } - public vlnChangeBarMessage(float parentx, string msg) - { - _ParentX = parentx; - _Message = msg; + ParentX = parentx; + Message = msg; } } public partial class vlnChangeBar : vlnPrintObject { - private bool _HasChangeBar; - public bool HasChangeBar - { - get { return _HasChangeBar; } - set { _HasChangeBar = value; } - } - protected float _YChangeBarBottom; + public bool HasChangeBar { get; set; } + protected float _YChangeBarBottom; public float YChangeBarBottom { get @@ -62,36 +41,15 @@ namespace Volian.Print.Library _Height = _YOffset - _YChangeBarBottom; } } - private SortedDictionary _Messages; - public SortedDictionary Messages - { - get { return _Messages; } - set { _Messages = value; } - } - private int _MessageAlignment; - public int MessageAlignment - { - get { return _MessageAlignment; } - set { _MessageAlignment = value; } - } - private float _YExtendLine = 4.75F; - public float YExtendLine - { - get { return _YExtendLine; } - set {_YExtendLine = value; } - } - public float YChangeBarBottomExtend - { - get {return YChangeBarBottom - YExtendLine; } - } - private bool _BottomIsTable = false; - public bool BottomIsTable - { - get { return _BottomIsTable; } - set { _BottomIsTable = value; } - } - private bool _IsRev; - private bool _MsgAtTop; // flags that message should be drawn at top of change bar + + public SortedDictionary Messages { get; set; } + public int MessageAlignment { get; set; } + public float YExtendLine { get; set; } = 4.75F; + public float YChangeBarBottomExtend => YChangeBarBottom - YExtendLine; + + public bool BottomIsTable { get; set; } = false; + private readonly bool _IsRev; + private readonly bool _MsgAtTop; // flags that message should be drawn at top of change bar public vlnChangeBar(PdfContentByte cb, vlnParagraph parent, float xoff, float yoff, int msgAlignment, bool isRev, bool msgAtTop) { // for grids, a y adjustment is made to match 16bit output, see the variable 'GridTopAdjust'. Take this @@ -113,7 +71,7 @@ namespace Volian.Print.Library { // see if any of children don't have changebar if ((vpo as vlnRNOSeparator).ExtendChangeBar) - _YExtendLine = (vpo.Height + vpo.YOffset - ((scale * parent.Height) + parent.YOffset)) * MyPageHelper.YMultiplier; + YExtendLine = (vpo.Height + vpo.YOffset - ((scale * parent.Height) + parent.YOffset)) * MyPageHelper.YMultiplier; } } foreach (vlnPrintObject vph in parent.PartsAbove) @@ -152,13 +110,10 @@ namespace Volian.Print.Library } } } - _MessageAlignment = msgAlignment; + MessageAlignment = msgAlignment; } - public override string ToString() - { - return string.Format("vlnChangeBar: X={0} Y={1} H={2} B={3} ID={4}", XOffset, YOffset, Height, YChangeBarBottom, MyParent.MyItemInfo.ItemID); - } - public override float ToPdf(PdfContentByte cb, float yPageStart, ref float yTopMargin, ref float yBottomMargin) + public override string ToString() => string.Format("vlnChangeBar: X={0} Y={1} H={2} B={3} ID={4}", XOffset, YOffset, Height, YChangeBarBottom, MyParent.MyItemInfo.ItemID); + public override float ToPdf(PdfContentByte cb, float yPageStart, ref float yTopMargin, ref float yBottomMargin) { float? topMost = null; cb.SaveState(); @@ -170,12 +125,10 @@ namespace Volian.Print.Library // calculate a new starting position for the change bar if (_MyParent is vlnParagraph) { - vlnParagraph pgh = _MyParent as vlnParagraph; topMost = cb.PdfWriter.PageSize.Height - yPageStart; } - VlnSvgPageHelper _MyPageHelper = cb.PdfWriter.PageEvent as VlnSvgPageHelper; - PdfLayer textLayer = _MyPageHelper == null ? null : _MyPageHelper.TextLayer; - if (textLayer != null) cb.BeginLayer(textLayer); + PdfLayer textLayer = !(cb.PdfWriter.PageEvent is VlnSvgPageHelper _MyPageHelper) ? null : _MyPageHelper.TextLayer; + if (textLayer != null) cb.BeginLayer(textLayer); float yAdj = -3.75F; //0.5F; float xAdj = 3F; //cb.SetColorStroke(Color.GREEN); @@ -226,8 +179,6 @@ namespace Volian.Print.Library // follow through in fixing an Out of Window Handles bug, use new function to see if // we can retrieve the font from a dictionary instead a doing a New and using another // window handle B21017-117 - //iTextSharp.text.Font iFont = _IsRev? Volian.Svg.Library.VolianPdf.GetFont(new System.Drawing.Font("Letter Gothic", 10F)): - // Volian.Svg.Library.VolianPdf.GetFont(new System.Drawing.Font("Letter Gothic", 5.5F)); iTextSharp.text.Font iFont = _IsRev? Volian.Svg.Library.VolianPdf.GetFont(VE_Font.GetWinSysFont("Letter Gothic", 10F)): Volian.Svg.Library.VolianPdf.GetFont(VE_Font.GetWinSysFont("Letter Gothic", 5.5F)); diff --git a/PROMS/Volian.Print.Library/vlnHeader.cs b/PROMS/Volian.Print.Library/vlnHeader.cs index a7234ee4..59653797 100644 --- a/PROMS/Volian.Print.Library/vlnHeader.cs +++ b/PROMS/Volian.Print.Library/vlnHeader.cs @@ -1,21 +1,13 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Drawing; using iTextSharp.text.pdf; -using iTextSharp.text; using VEPROMS.CSLA.Library; namespace Volian.Print.Library { public partial class vlnHeader: vlnText { - private string _OrigStr; - public float HeaderWidth - { - get { return _WidthAdjust + (MyFont.CharsToTwips * Text.Length); } - } - public vlnHeader(vlnParagraph myParent, PdfContentByte cb, string origStr, string cleanStr, float xoffset, float yoffset, VE_Font vFont) + private readonly string _OrigStr; + public float HeaderWidth => _WidthAdjust + (MyFont.CharsToTwips * Text.Length); + public vlnHeader(vlnParagraph myParent, PdfContentByte cb, string origStr, string cleanStr, float xoffset, float yoffset, VE_Font vFont) { MyParent = myParent; MyContentByte = cb; diff --git a/PROMS/Volian.Print.Library/vlnMacro.cs b/PROMS/Volian.Print.Library/vlnMacro.cs index f701f3ca..5e62e3c5 100644 --- a/PROMS/Volian.Print.Library/vlnMacro.cs +++ b/PROMS/Volian.Print.Library/vlnMacro.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Drawing; using iTextSharp.text.pdf; -using iTextSharp.text; -using VEPROMS.CSLA.Library; namespace Volian.Print.Library { @@ -13,13 +7,8 @@ namespace Volian.Print.Library private bool _UseInternalY = false; // B2020-121: Account for Header on Caution or Note public bool UseInternalY { get => _UseInternalY; set => _UseInternalY = value; } - private string _MacroDef; - public string MacroDef - { - get { return _MacroDef; } - set { _MacroDef = value; } - } - public vlnMacro(float xoffset, float yoffset, string macroDef) + public string MacroDef { get; set; } + public vlnMacro(float xoffset, float yoffset, string macroDef) { YOffset = yoffset; XOffset = xoffset; @@ -33,9 +22,8 @@ namespace Volian.Print.Library if (UseInternalY) yLocation = YOffset; // B2020-121: Account for Header on Caution or Note // Adjust the starting point for the Macro if the LPI is 7 if (MyPageHelper.YMultiplier != 1) yLocation += SixLinesPerInch - _SevenLinesPerInch; - VlnSvgPageHelper _MyPageHelper = cb.PdfWriter.PageEvent as VlnSvgPageHelper; - PdfLayer textLayer = _MyPageHelper == null ? null : _MyPageHelper.TextLayer; - if (textLayer != null) cb.BeginLayer(textLayer); + PdfLayer textLayer = !(cb.PdfWriter.PageEvent is VlnSvgPageHelper _MyPageHelper) ? null : _MyPageHelper.TextLayer; + if (textLayer != null) cb.BeginLayer(textLayer); MyContentByte = cb; System.Drawing.Color push = PrintOverride.SvgColor; PrintOverride.SvgColor = PrintOverride.TextColor == System.Drawing.Color.Empty ? System.Drawing.Color.Black : PrintOverride.TextColor; diff --git a/PROMS/Volian.Print.Library/vlnParagraph.cs b/PROMS/Volian.Print.Library/vlnParagraph.cs index c8f153f4..57a06066 100644 --- a/PROMS/Volian.Print.Library/vlnParagraph.cs +++ b/PROMS/Volian.Print.Library/vlnParagraph.cs @@ -1,1579 +1,1485 @@ +using iTextSharp.text; +using iTextSharp.text.pdf; using System; using System.Collections.Generic; -using System.Text; -//using System.Drawing; -using System.Text.RegularExpressions; using System.IO; -using iTextSharp.text.pdf; -using iTextSharp.text; -using Itenso.Rtf; -using Itenso.Rtf.Parser; -using Itenso.Rtf.Interpreter; -using Itenso.Rtf.Support; -using Volian.Controls.Library; +using System.Linq; +using System.Text; +using System.Text.RegularExpressions; using VEPROMS.CSLA.Library; using Volian.Base.Library; +using Volian.Controls.Library; namespace Volian.Print.Library { - public partial class vlnParagraphs : List - { - private vlnParagraph _Parent; - public vlnParagraph Parent - { - get { return _Parent; } - set { _Parent = value; } - } - public vlnParagraphs(vlnParagraph parent) - { - _Parent = parent; - } - // Step Designators are used by Comanche Peak and stored in their CAUTION2 type - // We need to save this information and not process it like a normal Caution. - private string _StepDesignator; - public string StepDesignator - { - get { return _StepDesignator; } - set { _StepDesignator = value; } - } - private float? _StepDesignatorColumn; + public partial class vlnParagraphs : List + { + public vlnParagraph Parent { get; set; } + public vlnParagraphs(vlnParagraph parent) + { + Parent = parent; + } - public float? StepDesignatorColumn - { - get { return _StepDesignatorColumn; } - set { _StepDesignatorColumn = value; } - } - private VE_Font _StepDesignatorFont; + public string StepDesignator { get; set; } - public VE_Font StepDesignatorFont - { - get { return _StepDesignatorFont; } - set { _StepDesignatorFont = value; } - } + public float? StepDesignatorColumn { get; set; } - public bool IsEnhancedBackgroundFormat(ItemInfo itminfo) - { - return ((itminfo.ActiveFormat.PlantFormat.FormatData.PurchaseOptions.Value & E_PurchaseOptions.EnhancedBackgrounds) == E_PurchaseOptions.EnhancedBackgrounds); - } - public bool IsEnhancedDeviationFormat(ItemInfo itminfo) - { - return ((itminfo.ActiveFormat.PlantFormat.FormatData.PurchaseOptions.Value & E_PurchaseOptions.EnhancedDeviations) == E_PurchaseOptions.EnhancedDeviations); - } - public float Add(PdfContentByte cb, ItemInfoList itemInfoList, float xoff, float yoff, float yoffRight, int rnoLevel, int maxRNO, FormatInfo formatInfo) - { - return Add(cb, itemInfoList, xoff, yoff, yoffRight, rnoLevel, maxRNO, formatInfo, null); - } - public float Add(PdfContentByte cb, ItemInfoList itemInfoList, float xoff, float yoff, float yoffRight, int rnoLevel, int maxRNO, FormatInfo formatInfo, PromsPrinter pp) - { - int profileDepth = ProfileTimer.Push(">>>> vlnParagraphs.Add"); - bool bxHlsDraw = false; - int? bxIndex = null; - vlnBox box = null; - float yTop = yoff; - ItemInfo lastChild = null; - string lastHeader = null; - bool didComponentTableRow = false; - float tableBottomMost = 0; - float xoffBase = xoff; - int prevTplRow = 0; - int maxRnoSav = maxRNO; - foreach (ItemInfo iChildItemInfo in itemInfoList) - { - if (pp != null) pp.OnStatusChanged((iChildItemInfo.DisplayNumber ?? "") == "" ? iChildItemInfo.DisplayText : iChildItemInfo.DisplayNumber, PromsPrinterStatusType.LoadVlnParagraph); - if (iChildItemInfo.IsFootnote) - { - vlnParagraph para = new vlnParagraph(Parent, cb, iChildItemInfo, xoff, yoff, rnoLevel, maxRNO, formatInfo, null, null, yoffRight, true, iChildItemInfo.IsSection ? pp : null); - continue; // don't add it, vlnParagraph adds this item to the footnote list in ToPdf. - } - maxRNO = maxRnoSav; - if (iChildItemInfo.IsHigh) bxIndex = null; - if (iChildItemInfo.IsSection && (iChildItemInfo as SectionInfo).ColumnMode != maxRNO) - maxRNO = (iChildItemInfo as SectionInfo).ColumnMode; - int maxRnoTemplate = iChildItemInfo.TemplateChildColumnMode; - if (maxRnoTemplate >= 0) maxRNO = maxRnoTemplate - 1; - ItemInfo childItemInfo = iChildItemInfo; - int? bxIndx = childItemInfo.FormatStepData == null ? -1 : childItemInfo.FormatStepData.StepLayoutData.STBoxindex; - // if the Caution or Note is not boxed, then use ColT to set the starting column of the Note or Caution - if (((bxIndx ?? -1) == -1) && (childItemInfo.IsCaution || childItemInfo.IsNote) && !childItemInfo.IsInRNO && - !childItemInfo.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.StepSectionLayoutData.Dev_Format && - !IsEnhancedBackgroundFormat(childItemInfo) && !IsEnhancedDeviationFormat(childItemInfo)) - //xoff += (float)childItemInfo.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.StepSectionLayoutData.ColT; - xoff = xoffBase + (float)childItemInfo.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.StepSectionLayoutData.ColT; + public VE_Font StepDesignatorFont { get; set; } - // if in a ComponentTableFormat (FNP sub format 1, component list), column headers are defined - // by the first level of children. The data for the column is the child of the column header. - // Sometimes the column will not have data, the following handles that case. Also, use - // the boolean didComponentTableRow to keep track of the bottom most yoff of the table row. - if ((childItemInfo.MyDocStyle.ComponentList) && childItemInfo.MyParent.IsInTemplate() || - (childItemInfo.ActiveFormat.PlantFormat.FormatData.PrintData.SpecialCaseCalvertAlarm && childItemInfo.IsInTemplate())) - { - if (childItemInfo.ActiveFormat.PlantFormat.FormatData.PrintData.SpecialCaseCalvertAlarm) - { - // if this template element has a -1 for row, print it (if = 0 this is a heading for edit - // and not printed). if this template element has a width of > 0, then also print it, - // these are headings and should be printed). This was added for Calvert Alarm (BGEALN) format for - // DEVICE/SETPOINT (row=-1), and for POSSIBLE CAUSES, AUTOMATIC ACTIONS, etc (width>0) - // find the indexes into the template for this item. The index must be for the HLS this is - // or this is under. - int tindx = childItemInfo.TemplateIndex; - if (tindx == -1) - xoff = (float)childItemInfo.MyDocStyle.Layout.LeftMargin; - else if (childItemInfo.ActiveFormat.PlantFormat.FormatData.Templates[tindx].row < 0 || - childItemInfo.ActiveFormat.PlantFormat.FormatData.Templates[tindx].width > 0) - { - // move down for the 'POSSIBLE CAUSES'. To know it's that step type, check - // the column field in template. -1 represents staying on same row but using - // the start template field to get the xoffset. - if (prevTplRow == -1 && prevTplRow != childItemInfo.ActiveFormat.PlantFormat.FormatData.Templates[tindx].row) - { - // position to the furthest down the page of the Device/setpoint/annunciator window: - yoff = Math.Max(yoff, Parent.YBottomMost + vlnPrintObject.SixLinesPerInch); - yoff = Math.Max(yoff, tableBottomMost + vlnPrintObject.SixLinesPerInch); - } - xoff = (float)childItemInfo.MyDocStyle.Layout.LeftMargin + (childItemInfo.ActiveFormat.PlantFormat.FormatData.Templates[tindx].start * 7.2f); - prevTplRow = childItemInfo.ActiveFormat.PlantFormat.FormatData.Templates[tindx].row; - } - } - else - { - // childItemInfo = 'child' and set to use a template for defining size. - // Note that the 'IsCaution1' was added for Calvert Valve lists, i.e. - // the Caution1 is a subheader & must be printed within the valve list table. - if (childItemInfo.Steps == null && !childItemInfo.IsCaution1) - continue; - if (!childItemInfo.IsCaution1) childItemInfo = childItemInfo.Steps[0]; - didComponentTableRow = true; - } - } - if (childItemInfo.FormatStepData != null && childItemInfo.FormatStepData.TabData != null && childItemInfo.FormatStepData.TabData.IsTransition) - { - lastHeader = childItemInfo.DisplayText; - } - else - { - if ((childItemInfo.IsCaution || childItemInfo.IsNote) && - childItemInfo.MyPrevious != null && childItemInfo.MyPrevious.MyContent.Type != childItemInfo.MyContent.Type && - childItemInfo.NextItem != null && childItemInfo.MyContent.Type == childItemInfo.NextItem.MyContent.Type) - childItemInfo.SetupTags(); // added for V.C. Summer Transition caution in EOP-15.0 step 5.4 - if (lastHeader != null) - { - childItemInfo.SetHeader(childItemInfo.FormatStepData.TabData.Font, lastHeader); - lastHeader = null; - } - // if the format has MatchUpRNOCautNote, then add a line to yoff, if not at top of rno column. - if (childItemInfo.FormatStepData != null && childItemInfo.FormatStepData.MatchUpRNO) - { - if (childItemInfo.MyParent != null && childItemInfo.MyParent.MyParent != null && !childItemInfo.MyParent.MyParent.IsHigh) - { - yoff += vlnPrintObject.SixLinesPerInch; - Parent.AdjustForMatchUpRNO = vlnPrintObject.SixLinesPerInch; // B2020-112 - } - } - // if this is a caution/note and it has a caution/note substep, do it before this caution/note, so that - // it comes above it. - if (childItemInfo.Cautions != null && (childItemInfo.IsCaution || childItemInfo.IsNote)) - yoff = Add(cb, childItemInfo.Cautions, xoff, yoff, yoffRight, rnoLevel, maxRNO, formatInfo); - if (childItemInfo.Notes != null && (childItemInfo.IsCaution || childItemInfo.IsNote)) - yoff = Add(cb, childItemInfo.Notes, xoff, yoff, yoffRight, rnoLevel, maxRNO, formatInfo); - //int? bxIndx = childItemInfo.FormatStepData == null ? -1 : childItemInfo.FormatStepData.StepLayoutData.STBoxindex; - bool boxHLS = false; + public bool IsEnhancedBackgroundFormat(ItemInfo itminfo) => ((itminfo.ActiveFormat.PlantFormat.FormatData.PurchaseOptions.Value & E_PurchaseOptions.EnhancedBackgrounds) == E_PurchaseOptions.EnhancedBackgrounds); + public bool IsEnhancedDeviationFormat(ItemInfo itminfo) => ((itminfo.ActiveFormat.PlantFormat.FormatData.PurchaseOptions.Value & E_PurchaseOptions.EnhancedDeviations) == E_PurchaseOptions.EnhancedDeviations); + public float Add(PdfContentByte cb, ItemInfoList itemInfoList, float xoff, float yoff, float yoffRight, int rnoLevel, int maxRNO, FormatInfo formatInfo) => Add(cb, itemInfoList, xoff, yoff, yoffRight, rnoLevel, maxRNO, formatInfo, null); + public float Add(PdfContentByte cb, ItemInfoList itemInfoList, float xoff, float yoff, float yoffRight, int rnoLevel, int maxRNO, FormatInfo formatInfo, PromsPrinter pp) + { + int profileDepth = ProfileTimer.Push(">>>> vlnParagraphs.Add"); + bool bxHlsDraw = false; + int? bxIndex = null; + vlnBox box = null; + ItemInfo lastChild = null; + string lastHeader = null; + bool didComponentTableRow = false; + float tableBottomMost = 0; + float xoffBase = xoff; + int prevTplRow = 0; + int maxRnoSav = maxRNO; + foreach (ItemInfo iChildItemInfo in itemInfoList) + { + pp?.OnStatusChanged((iChildItemInfo.DisplayNumber ?? "") == "" ? iChildItemInfo.DisplayText : iChildItemInfo.DisplayNumber, PromsPrinterStatusType.LoadVlnParagraph); + if (iChildItemInfo.IsFootnote) + { + vlnParagraph para = new vlnParagraph(Parent, cb, iChildItemInfo, xoff, yoff, rnoLevel, maxRNO, formatInfo, null, null, yoffRight, true, iChildItemInfo.IsSection ? pp : null); + continue; // don't add it, vlnParagraph adds this item to the footnote list in ToPdf. + } + maxRNO = maxRnoSav; + if (iChildItemInfo.IsHigh) bxIndex = null; + if (iChildItemInfo.IsSection && (iChildItemInfo as SectionInfo).ColumnMode != maxRNO) + maxRNO = (iChildItemInfo as SectionInfo).ColumnMode; + int maxRnoTemplate = iChildItemInfo.TemplateChildColumnMode; + if (maxRnoTemplate >= 0) maxRNO = maxRnoTemplate - 1; + ItemInfo childItemInfo = iChildItemInfo; + int? bxIndx = childItemInfo.FormatStepData == null ? -1 : childItemInfo.FormatStepData.StepLayoutData.STBoxindex; + // if the Caution or Note is not boxed, then use ColT to set the starting column of the Note or Caution + if (((bxIndx ?? -1) == -1) && (childItemInfo.IsCaution || childItemInfo.IsNote) && !childItemInfo.IsInRNO && + !childItemInfo.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.StepSectionLayoutData.Dev_Format && + !IsEnhancedBackgroundFormat(childItemInfo) && !IsEnhancedDeviationFormat(childItemInfo)) + //xoff += (float)childItemInfo.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.StepSectionLayoutData.ColT; + xoff = xoffBase + (float)childItemInfo.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.StepSectionLayoutData.ColT; - // If this step has a previous, and its header is different than the previous's header. Allow it to go - // into the box code. Without this check, none of the box code is run. This caused a problem - // for VCS where two different type notes where not getting separate boxes. - bool doSeparateBoxHdrChg = false; - if (childItemInfo.MyPrevious != null && ((childItemInfo.MyHeader != null && childItemInfo.MyPrevious.MyHeader != null - && childItemInfo.MyHeader.CleanText != childItemInfo.MyPrevious.MyHeader.CleanText) || - (childItemInfo.MyHeader == null && childItemInfo.MyPrevious.MyHeader != null || childItemInfo.MyHeader != null && childItemInfo.MyPrevious.MyHeader == null))) - doSeparateBoxHdrChg = childItemInfo.MyPrevious.MyContent.Type != childItemInfo.MyContent.Type;//true; + // if in a ComponentTableFormat (FNP sub format 1, component list), column headers are defined + // by the first level of children. The data for the column is the child of the column header. + // Sometimes the column will not have data, the following handles that case. Also, use + // the boolean didComponentTableRow to keep track of the bottom most yoff of the table row. + if ((childItemInfo.MyDocStyle.ComponentList) && childItemInfo.MyParent.IsInTemplate() || + (childItemInfo.ActiveFormat.PlantFormat.FormatData.PrintData.SpecialCaseCalvertAlarm && childItemInfo.IsInTemplate())) + { + if (childItemInfo.ActiveFormat.PlantFormat.FormatData.PrintData.SpecialCaseCalvertAlarm) + { + // if this template element has a -1 for row, print it (if = 0 this is a heading for edit + // and not printed). if this template element has a width of > 0, then also print it, + // these are headings and should be printed). This was added for Calvert Alarm (BGEALN) format for + // DEVICE/SETPOINT (row=-1), and for POSSIBLE CAUSES, AUTOMATIC ACTIONS, etc (width>0) + // find the indexes into the template for this item. The index must be for the HLS this is + // or this is under. + int tindx = childItemInfo.TemplateIndex; + if (tindx == -1) + xoff = (float)childItemInfo.MyDocStyle.Layout.LeftMargin; + else if (childItemInfo.ActiveFormat.PlantFormat.FormatData.Templates[tindx].row < 0 || + childItemInfo.ActiveFormat.PlantFormat.FormatData.Templates[tindx].width > 0) + { + // move down for the 'POSSIBLE CAUSES'. To know it's that step type, check + // the column field in template. -1 represents staying on same row but using + // the start template field to get the xoffset. + if (prevTplRow == -1 && prevTplRow != childItemInfo.ActiveFormat.PlantFormat.FormatData.Templates[tindx].row) + { + // position to the furthest down the page of the Device/setpoint/annunciator window: + yoff = Math.Max(yoff, Parent.YBottomMost + vlnPrintObject.SixLinesPerInch); + yoff = Math.Max(yoff, tableBottomMost + vlnPrintObject.SixLinesPerInch); + } + xoff = (float)childItemInfo.MyDocStyle.Layout.LeftMargin + (childItemInfo.ActiveFormat.PlantFormat.FormatData.Templates[tindx].start * 7.2f); + prevTplRow = childItemInfo.ActiveFormat.PlantFormat.FormatData.Templates[tindx].row; + } + } + else + { + // childItemInfo = 'child' and set to use a template for defining size. + // Note that the 'IsCaution1' was added for Calvert Valve lists, i.e. + // the Caution1 is a subheader & must be printed within the valve list table. + if (childItemInfo.Steps == null && !childItemInfo.IsCaution1) + continue; + if (!childItemInfo.IsCaution1) childItemInfo = childItemInfo.Steps[0]; + didComponentTableRow = true; + } + } + if (childItemInfo.FormatStepData != null && childItemInfo.FormatStepData.TabData != null && childItemInfo.FormatStepData.TabData.IsTransition) + { + lastHeader = childItemInfo.DisplayText; + } + else + { + if ((childItemInfo.IsCaution || childItemInfo.IsNote) && + childItemInfo.MyPrevious != null && childItemInfo.MyPrevious.MyContent.Type != childItemInfo.MyContent.Type && + childItemInfo.NextItem != null && childItemInfo.MyContent.Type == childItemInfo.NextItem.MyContent.Type) + childItemInfo.SetupTags(); // added for V.C. Summer Transition caution in EOP-15.0 step 5.4 + if (lastHeader != null) + { + childItemInfo.SetHeader(childItemInfo.FormatStepData.TabData.Font, lastHeader); + lastHeader = null; + } + // if the format has MatchUpRNOCautNote, then add a line to yoff, if not at top of rno column. + if (childItemInfo.FormatStepData != null && childItemInfo.FormatStepData.MatchUpRNO) + { + if (childItemInfo.MyParent != null && childItemInfo.MyParent.MyParent != null && !childItemInfo.MyParent.MyParent.IsHigh) + { + yoff += vlnPrintObject.SixLinesPerInch; + Parent.AdjustForMatchUpRNO = vlnPrintObject.SixLinesPerInch; // B2020-112 + } + } + // if this is a caution/note and it has a caution/note substep, do it before this caution/note, so that + // it comes above it. + if (childItemInfo.Cautions != null && (childItemInfo.IsCaution || childItemInfo.IsNote)) + yoff = Add(cb, childItemInfo.Cautions, xoff, yoff, yoffRight, rnoLevel, maxRNO, formatInfo); + if (childItemInfo.Notes != null && (childItemInfo.IsCaution || childItemInfo.IsNote)) + yoff = Add(cb, childItemInfo.Notes, xoff, yoff, yoffRight, rnoLevel, maxRNO, formatInfo); + //int? bxIndx = childItemInfo.FormatStepData == null ? -1 : childItemInfo.FormatStepData.StepLayoutData.STBoxindex; + bool boxHLS = false; - bool alwaysBox = (childItemInfo.IsHigh && childItemInfo.FormatStepData.BoxIt); - if ((alwaysBox || (bxIndx ?? -1) != -1) && (bxIndex != bxIndx || childItemInfo.FormatStepData.BoxIt || childItemInfo.MyHeader != null || doSeparateBoxHdrChg || childItemInfo.FormatStepData.SeparateBox)) - { - if (childItemInfo.FormatStepData.BoxIt) // this is a boxed HLS - { - box = new vlnBox(); - box.MyBox = new Box(); - box.DefBox = vlnBox.BoxThin; - StepSectionLayoutData ssld = formatInfo.MyStepSectionLayoutData; - float colR = float.Parse(formatInfo.MyStepSectionLayoutData.ColRTable.Split(",".ToCharArray())[childItemInfo.ColumnMode]); - int widS = vlnPrintObject.ToInt(formatInfo.MyStepSectionLayoutData.WidSTablePrint, maxRNO); - box.DefEnd = (float)(ssld.ColS + colR + widS + (60 / 4.8)); - box.YOffset = yoff - .75F * vlnPrintObject.SixLinesPerInch; - } - else if (bxIndex == null) // First boxed step - { - if (childItemInfo.IsHigh) boxHLS = true; - box = new vlnBox(); - box.MyBox = formatInfo.PlantFormat.FormatData.BoxList[(int)bxIndx]; - if (box.MyBox != null) - { - // B2022-130: Barakah warning box prints on bottom of section title if warning is on first HLS - if (box.MyBox.ThickDouble && childItemInfo.MyParent != null && childItemInfo.MyParent.IsHigh && childItemInfo.MyParent.ItemID == childItemInfo.MyParent.FirstSibling.ItemID) - { - if (!childItemInfo.MyParent.MyParent.MyDocStyle.CancelSectTitle) - yoff += vlnPrintObject.SixLinesPerInch; - } - box.YOffset = yoff; - int ln = 1; // a format flag determines whether there is a space before the note/caution. - if (childItemInfo.FormatStepData.OneLineBeforeTab) ln++; - if (!boxHLS || (boxHLS && !childItemInfo.HasCautionOrNote)) - { - // note that in the following line of code, the Calvert Alarms' caution1 is their annunciator window - // so it needs the extra lines as defined by 'ln' or the text will be too close to the top of the box. - if (!formatInfo.PlantFormat.FormatData.PrintData.SpecialCaseCalvertAlarm || iChildItemInfo.IsCaution1) - yoff += ln * vlnPrintObject.SixLinesPerInch; - else - yoff += vlnPrintObject.SixLinesPerInch; - } - if (box.MyBox != null) - yoff += (float)(box.MyBox.AdjSpB4Tab ?? 0); // F2024-078 adjust space above the Note/Caution box tab - } - bxIndex = bxIndx; - } - else // Change Box Style - { - bool handleSeparateBox = true; - if (childItemInfo.IsCaution && !childItemInfo.FormatStepData.SeparateBox && !childItemInfo.FormatStepData.SeparateBoxCautions) handleSeparateBox = false; - if (childItemInfo.IsNote && !childItemInfo.FormatStepData.SeparateBox) handleSeparateBox = false; + // If this step has a previous, and its header is different than the previous's header. Allow it to go + // into the box code. Without this check, none of the box code is run. This caused a problem + // for VCS where two different type notes where not getting separate boxes. + bool doSeparateBoxHdrChg = false; + if (childItemInfo.MyPrevious != null && ((childItemInfo.MyHeader != null && childItemInfo.MyPrevious.MyHeader != null + && childItemInfo.MyHeader.CleanText != childItemInfo.MyPrevious.MyHeader.CleanText) || + (childItemInfo.MyHeader == null && childItemInfo.MyPrevious.MyHeader != null || childItemInfo.MyHeader != null && childItemInfo.MyPrevious.MyHeader == null))) + doSeparateBoxHdrChg = childItemInfo.MyPrevious.MyContent.Type != childItemInfo.MyContent.Type;//true; - if (bxIndx != null && (handleSeparateBox || bxIndex != bxIndx || doSeparateBoxHdrChg)) - { - bool didSeparateBoxChgYAdjust = false; - if (box != null) - { - box.Height = yoff - box.YOffset; // new height, with children - if (formatInfo.PlantFormat.FormatData.PrintData.SpecialCaseCalvertAlarm || - formatInfo.PlantFormat.FormatData.PrintData.SpecialCaseCalvert) - { - if (childItemInfo.MyHeader != null && childItemInfo.MyPrevious != null - && ((childItemInfo.MyPrevious.IsCautionOrNotePart && childItemInfo.IsCautionOrNotePart) - || childItemInfo.FormatStepData.SeparateBox)) - yoff += vlnPrintObject.SixLinesPerInch * 2; - } - else if (childItemInfo.MyHeader != null && childItemInfo.MyPrevious != null - && ((childItemInfo.MyPrevious.IsCaution && childItemInfo.IsCaution) || - (childItemInfo.MyPrevious.IsNote && childItemInfo.IsNote) || childItemInfo.FormatStepData.SeparateBox)) - yoff += vlnPrintObject.SixLinesPerInch * 2; - // B2020-026: Farley - Notes before Cautions/cautions and notes in same 'parts' list, so bxIndex what not null, need - // to add an extra line after note box. - else if (formatInfo.Name.ToUpper().StartsWith("FNP") && childItemInfo.MyPrevious != null && childItemInfo.MyPrevious.IsNote && childItemInfo.IsCaution) - yoff += vlnPrintObject.SixLinesPerInch * 2; - else if (doSeparateBoxHdrChg) // F2021-038: SHE/SHEA format - Less space after boxes (removes it below) - { - didSeparateBoxChgYAdjust = true; - yoff += vlnPrintObject.SixLinesPerInch * 2; - } - } - box = new vlnBox(); - box.MyBox = formatInfo.PlantFormat.FormatData.BoxList[(int)bxIndx]; - // F2021-038: SHE/SHEA format - Less space after boxes - if (didSeparateBoxChgYAdjust && childItemInfo.IsStep && childItemInfo.FormatStepData.NoYBxAdjust) yoff -= vlnPrintObject.SixLinesPerInch; - int ln = 1; // a format flag determines whether there is a space before the note/caution. - //if (childItemInfo.FormatStepData.OneLineBeforeTab) ln++; - if (childItemInfo.MixCautionNotesDiffType()) ln += 2; - box.YOffset = yoff + ((ln - 1) * vlnPrintObject.SixLinesPerInch); - if (childItemInfo.FormatStepData.OneLineBeforeTab) ln++; - yoff += ln * vlnPrintObject.SixLinesPerInch; - if (box.MyBox != null) - yoff += (float)(box.MyBox.AdjSpB4Tab ?? 0); // F2024-078 adjust space above the Note/Caution box tab - } - } - bxIndex = bxIndx; - } - else if (((bxIndx ?? -1) == -1) && box != null) - { - // BGE STP has a null box for its 'Date Time Stamp', i.e. Note4, - // without this code if there is a previous sibling the 'Date Time Note' was - // included in its previous sibling's box: - // (STBoxindex="" is how Note4's box in BGE STP is defined - it is the only place - // in the format files that this is done) - box.Height = yoff - box.YOffset; // new height, with children - yoff += 2 * vlnPrintObject.SixLinesPerInch; - box = null; - } - // DoubleBoxHls is a format flag used by BGE to draw double lined boxes around their HLS - if (childItemInfo.IsHigh && ((childItemInfo.MyDocStyle.StructureStyle.Style & E_DocStructStyle.DoubleBoxHLS) == E_DocStructStyle.DoubleBoxHLS)) - { - boxHLS = true; - box = new vlnBox(); - box.MyBox = new Box(); - box.DefBox = vlnBox.DOUBLEboxHLS; - bxHlsDraw = true; - } - vlnParagraph para = null; - // Comanche peak or WCN bck Step designator - if (childItemInfo.IsCaution2 && childItemInfo.SameRowAsParent || - childItemInfo.IsCaution1 && childItemInfo.SameRowAsParent) - { - // Save the Step Designator information - // SameRowAsParentMultiLine currently used in Comanche Peak EOP and Flex formats - handles a hard return in the caution type - _StepDesignator = ((childItemInfo.SameRowAsParentMultiLines) ? childItemInfo.MulitLineStepDesignatorDisplayText : childItemInfo.DisplayText); - int typ = ((int)childItemInfo.MyContent.Type) % 10000; - _StepDesignatorColumn = formatInfo.PlantFormat.FormatData.StepDataList[typ].ColOverride; - E_Style es = (E_Style)childItemInfo.FormatStepData.Font.Style; - _StepDesignatorFont = new VE_Font(childItemInfo.FormatStepData.Font.Family, (int)childItemInfo.FormatStepData.Font.Size, es, (float)childItemInfo.FormatStepData.Font.CPI); - } - else - { - if (childItemInfo is SectionInfo) formatInfo = (childItemInfo as SectionInfo).LocalFormat ?? formatInfo; - if (rnoLevel < maxRNO && childItemInfo.RNOs != null) yoff = Math.Max(yoff, yoffRight); - if (childItemInfo.ActiveSection.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.StepSectionPrintData.ContActBoxOnSubSteps && - box != null && box.MyBox != null && bxIndx == null) // point beach boxed substeps - { - box.Height = yoff - box.YOffset - (1F * vlnPrintObject.SixLinesPerInch); - box = null; - yoff += 1 * vlnPrintObject.SixLinesPerInch; - } - para = new vlnParagraph(Parent, cb, childItemInfo, xoff, yoff, rnoLevel, maxRNO, formatInfo, null, null, yoffRight, true, pp); + bool alwaysBox = (childItemInfo.IsHigh && childItemInfo.FormatStepData.BoxIt); + if ((alwaysBox || (bxIndx ?? -1) != -1) && (bxIndex != bxIndx || childItemInfo.FormatStepData.BoxIt || childItemInfo.MyHeader != null || doSeparateBoxHdrChg || childItemInfo.FormatStepData.SeparateBox)) + { + if (childItemInfo.FormatStepData.BoxIt) // this is a boxed HLS + { + box = new vlnBox + { + MyBox = new Box(), + DefBox = vlnBox.BoxThin + }; + StepSectionLayoutData ssld = formatInfo.MyStepSectionLayoutData; + float colR = float.Parse(formatInfo.MyStepSectionLayoutData.ColRTable.Split(",".ToCharArray())[childItemInfo.ColumnMode]); + int widS = vlnPrintObject.ToInt(formatInfo.MyStepSectionLayoutData.WidSTablePrint, maxRNO); + box.DefEnd = (float)(ssld.ColS + colR + widS + (60 / 4.8)); + box.YOffset = yoff - .75F * vlnPrintObject.SixLinesPerInch; + } + else if (bxIndex == null) // First boxed step + { + if (childItemInfo.IsHigh) boxHLS = true; + box = new vlnBox + { + MyBox = formatInfo.PlantFormat.FormatData.BoxList[(int)bxIndx] + }; + if (box.MyBox != null) + { + // B2022-130: Barakah warning box prints on bottom of section title if warning is on first HLS + if (box.MyBox.ThickDouble && childItemInfo.MyParent != null && childItemInfo.MyParent.IsHigh && childItemInfo.MyParent.ItemID == childItemInfo.MyParent.FirstSibling.ItemID) + { + if (!childItemInfo.MyParent.MyParent.MyDocStyle.CancelSectTitle) + yoff += vlnPrintObject.SixLinesPerInch; + } + box.YOffset = yoff; + int ln = 1; // a format flag determines whether there is a space before the note/caution. + if (childItemInfo.FormatStepData.OneLineBeforeTab) ln++; + if (!boxHLS || (boxHLS && !childItemInfo.HasCautionOrNote)) + { + // note that in the following line of code, the Calvert Alarms' caution1 is their annunciator window + // so it needs the extra lines as defined by 'ln' or the text will be too close to the top of the box. + if (!formatInfo.PlantFormat.FormatData.PrintData.SpecialCaseCalvertAlarm || iChildItemInfo.IsCaution1) + yoff += ln * vlnPrintObject.SixLinesPerInch; + else + yoff += vlnPrintObject.SixLinesPerInch; + } + if (box.MyBox != null) + yoff += (float)(box.MyBox.AdjSpB4Tab ?? 0); // F2024-078 adjust space above the Note/Caution box tab + } + bxIndex = bxIndx; + } + else // Change Box Style + { + bool handleSeparateBox = true; + if (childItemInfo.IsCaution && !childItemInfo.FormatStepData.SeparateBox && !childItemInfo.FormatStepData.SeparateBoxCautions) handleSeparateBox = false; + if (childItemInfo.IsNote && !childItemInfo.FormatStepData.SeparateBox) handleSeparateBox = false; - // if doing the component list (FNP), keep track of the bottom most columns' data - // so this can be returned after the row is done. - tableBottomMost = Math.Max(tableBottomMost, para.YBottomMost); - if (box != null && box.MyParent == null) - { - box.MyParent = para; - para.PartsContainer.Add(box); - } - Add(para); - if (didComponentTableRow && iChildItemInfo.Steps != null && iChildItemInfo.Steps.Count > 1) - tableBottomMost = Math.Max(tableBottomMost, AddComponentTableSiblings(cb, iChildItemInfo.Steps[1], xoff, para.YBottomMost, rnoLevel, maxRNO, formatInfo, yoffRight, pp)); + if (bxIndx != null && (handleSeparateBox || bxIndex != bxIndx || doSeparateBoxHdrChg)) + { + bool didSeparateBoxChgYAdjust = false; + if (box != null) + { + box.Height = yoff - box.YOffset; // new height, with children + if (formatInfo.PlantFormat.FormatData.PrintData.SpecialCaseCalvertAlarm || + formatInfo.PlantFormat.FormatData.PrintData.SpecialCaseCalvert) + { + if (childItemInfo.MyHeader != null && childItemInfo.MyPrevious != null + && ((childItemInfo.MyPrevious.IsCautionOrNotePart && childItemInfo.IsCautionOrNotePart) + || childItemInfo.FormatStepData.SeparateBox)) + yoff += vlnPrintObject.SixLinesPerInch * 2; + } + else if (childItemInfo.MyHeader != null && childItemInfo.MyPrevious != null + && ((childItemInfo.MyPrevious.IsCaution && childItemInfo.IsCaution) || + (childItemInfo.MyPrevious.IsNote && childItemInfo.IsNote) || childItemInfo.FormatStepData.SeparateBox)) + yoff += vlnPrintObject.SixLinesPerInch * 2; + // B2020-026: Farley - Notes before Cautions/cautions and notes in same 'parts' list, so bxIndex what not null, need + // to add an extra line after note box. + else if (formatInfo.Name.ToUpper().StartsWith("FNP") && childItemInfo.MyPrevious != null && childItemInfo.MyPrevious.IsNote && childItemInfo.IsCaution) + yoff += vlnPrintObject.SixLinesPerInch * 2; + else if (doSeparateBoxHdrChg) // F2021-038: SHE/SHEA format - Less space after boxes (removes it below) + { + didSeparateBoxChgYAdjust = true; + yoff += vlnPrintObject.SixLinesPerInch * 2; + } + } + box = new vlnBox + { + MyBox = formatInfo.PlantFormat.FormatData.BoxList[(int)bxIndx] + }; + // F2021-038: SHE/SHEA format - Less space after boxes + if (didSeparateBoxChgYAdjust && childItemInfo.IsStep && childItemInfo.FormatStepData.NoYBxAdjust) yoff -= vlnPrintObject.SixLinesPerInch; + int ln = 1; // a format flag determines whether there is a space before the note/caution. + //if (childItemInfo.FormatStepData.OneLineBeforeTab) ln++; + if (childItemInfo.MixCautionNotesDiffType()) ln += 2; + box.YOffset = yoff + ((ln - 1) * vlnPrintObject.SixLinesPerInch); + if (childItemInfo.FormatStepData.OneLineBeforeTab) ln++; + yoff += ln * vlnPrintObject.SixLinesPerInch; + if (box.MyBox != null) + yoff += (float)(box.MyBox.AdjSpB4Tab ?? 0); // F2024-078 adjust space above the Note/Caution box tab + } + } + bxIndex = bxIndx; + } + else if (((bxIndx ?? -1) == -1) && box != null) + { + // BGE STP has a null box for its 'Date Time Stamp', i.e. Note4, + // without this code if there is a previous sibling the 'Date Time Note' was + // included in its previous sibling's box: + // (STBoxindex="" is how Note4's box in BGE STP is defined - it is the only place + // in the format files that this is done) + box.Height = yoff - box.YOffset; // new height, with children + yoff += 2 * vlnPrintObject.SixLinesPerInch; + box = null; + } + // DoubleBoxHls is a format flag used by BGE to draw double lined boxes around their HLS + if (childItemInfo.IsHigh && ((childItemInfo.MyDocStyle.StructureStyle.Style & E_DocStructStyle.DoubleBoxHLS) == E_DocStructStyle.DoubleBoxHLS)) + { + boxHLS = true; + box = new vlnBox + { + MyBox = new Box(), + DefBox = vlnBox.DOUBLEboxHLS + }; + bxHlsDraw = true; + } + vlnParagraph para = null; + // Comanche peak or WCN bck Step designator + if (childItemInfo.IsCaution2 && childItemInfo.SameRowAsParent || + childItemInfo.IsCaution1 && childItemInfo.SameRowAsParent) + { + // Save the Step Designator information + // SameRowAsParentMultiLine currently used in Comanche Peak EOP and Flex formats - handles a hard return in the caution type + StepDesignator = ((childItemInfo.SameRowAsParentMultiLines) ? childItemInfo.MulitLineStepDesignatorDisplayText : childItemInfo.DisplayText); + int typ = ((int)childItemInfo.MyContent.Type) % 10000; + StepDesignatorColumn = formatInfo.PlantFormat.FormatData.StepDataList[typ].ColOverride; + E_Style es = (E_Style)childItemInfo.FormatStepData.Font.Style; + StepDesignatorFont = new VE_Font(childItemInfo.FormatStepData.Font.Family, (int)childItemInfo.FormatStepData.Font.Size, es, (float)childItemInfo.FormatStepData.Font.CPI); + } + else + { + if (childItemInfo is SectionInfo) formatInfo = (childItemInfo as SectionInfo).LocalFormat ?? formatInfo; + if (rnoLevel < maxRNO && childItemInfo.RNOs != null) yoff = Math.Max(yoff, yoffRight); + if (childItemInfo.ActiveSection.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.StepSectionPrintData.ContActBoxOnSubSteps && + box != null && box.MyBox != null && bxIndx == null) // point beach boxed substeps + { + box.Height = yoff - box.YOffset - (1F * vlnPrintObject.SixLinesPerInch); + box = null; + yoff += 1 * vlnPrintObject.SixLinesPerInch; + } + para = new vlnParagraph(Parent, cb, childItemInfo, xoff, yoff, rnoLevel, maxRNO, formatInfo, null, null, yoffRight, true, pp); - // Calvert Alarm's caution1 is the Annunciator window, i.e. in top right of page. Adjust - // y offset for this caution that is printed BELOW the hls. - if (childItemInfo.ActiveFormat.PlantFormat.FormatData.PrintData.SpecialCaseCalvertAlarm && iChildItemInfo.IsCaution1) para.MyHighLevelParagraph.YBottomMost = para.YBottomMost; + // if doing the component list (FNP), keep track of the bottom most columns' data + // so this can be returned after the row is done. + tableBottomMost = Math.Max(tableBottomMost, para.YBottomMost); + if (box != null && box.MyParent == null) + { + box.MyParent = para; + para.PartsContainer.Add(box); + } + Add(para); + if (didComponentTableRow && iChildItemInfo.Steps != null && iChildItemInfo.Steps.Count > 1) + tableBottomMost = Math.Max(tableBottomMost, AddComponentTableSiblings(cb, iChildItemInfo.Steps[1], xoff, para.YBottomMost, rnoLevel, maxRNO, formatInfo, yoffRight, pp)); - // para.YBottomMost will have y for bottom of any substeps that are also enclosed in the box. - if (childItemInfo.IsStep && childItemInfo.MyHLS != null && childItemInfo.MyHLS.FormatStepData.UseSmartTemplate && para.ChildrenBelow.Count > 0 && para.ChildrenBelow[0].YBottomMost > para.YBottomMost) - yoff = para.ChildrenBelow[0].YBottomMost; - // if doing the component list (FNP), yoff for the HLS (if it's the component in the list, - // i.e. the leftmost item in the table), the yoff is either the HLS bottom, or the bottom most - // of all of the other columns' data. - else if (childItemInfo.IsHigh && childItemInfo.FormatStepData.UseOldTemplate && childItemInfo.MyDocStyle.ComponentList) - yoff = Math.Max(para.YBottom, para.YBottomMost) + vlnPrintObject.SixLinesPerInch; - // increment the y offset if not doing the ComponentTableFormat - else if (!para.UseTemplateKeepOnCurLine(childItemInfo)) - { - // B2019-028: These comments ARE NOT relevant and the code added, the if and the else/console.writeline - // are not correct (left in commented out so that change can be seen): - // Don't set to zero after a Word Section - // Otherwise the step section output will overlap previous step section output - // if in a sub section. - // To see the problem, create a section with three subsections. - // First section a multiple page step section - // Second section a word section - // Third section a step section - // skip the logic in the next three lines. (if to else) - //if (para.YBottomMost > 0) - yoff = para.YBottomMost; - //else - //Console.WriteLine("ERROR Would have changed yoff from {0} to zero",yoff); - } - // don't adjust YBottomost until after yoff is set for the RNO Separator - para.YBottomMost += para.YBottomMostAdjust; - if (box != null && childItemInfo.FormatStepData != null && childItemInfo.FormatStepData.BoxIt) - { - box.Height = yoff - box.YOffset - (1.1F * vlnPrintObject.SixLinesPerInch); - box = null; // if doing boxed steps, only do single sibling at a time. - } - if (bxHlsDraw) - { - box.YOffset = para.YTop; - box.Height = para.Height; - box = null; - } - else if (boxHLS) - { - // the following line controls whether there is 1 line or 2 lines between - // the box line & the starting/ending yoffset of the HLS. WEP2 had no extra line between - // box & top/bottom of step. The DiffContActBox was added for WEP2. - int boxLnAdjust = iChildItemInfo.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.StepSectionPrintData.DiffContActBox ? 1 : 2; - box.YOffset = para.YTop - (boxLnAdjust * vlnPrintObject.SixLinesPerInch); - boxLnAdjust = iChildItemInfo.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.StepSectionPrintData.DiffContActBox ? 1 : 0; + // Calvert Alarm's caution1 is the Annunciator window, i.e. in top right of page. Adjust + // y offset for this caution that is printed BELOW the hls. + if (childItemInfo.ActiveFormat.PlantFormat.FormatData.PrintData.SpecialCaseCalvertAlarm && iChildItemInfo.IsCaution1) para.MyHighLevelParagraph.YBottomMost = para.YBottomMost; - // if the YBottomForBox is set, use it to define height. Note that this property was - // introduced for IP3 continuous hls (surrounded by the asterisk box), no other format/step type uses it. - if (para.YBottomForBox > 0) - box.Height = para.YBottomForBox - box.YOffset - (boxLnAdjust * vlnPrintObject.SixLinesPerInch); // para.YTop - (1.1F * vlnPrintObject.SixLinesPerInch); - else - box.Height = para.YBottomMost - box.YOffset - (boxLnAdjust * vlnPrintObject.SixLinesPerInch); // para.YTop - (1.1F * vlnPrintObject.SixLinesPerInch); - box = null; - } - } - if (boxHLS) - { - // if the next HLS is boxed also, only need 1 line separating, otherwise - // need 2. - ItemInfo nxt = childItemInfo.GetNextItem(); - int nxtIsBoxed = 2; - if (nxt != null && - nxt.FormatStepData.StepLayoutData.STBoxindex != null && nxt.FormatStepData.StepLayoutData.STBoxindex >= 0) nxtIsBoxed--; - if (nxt != null && (nxt.MyDocStyle.StructureStyle.Style & E_DocStructStyle.DoubleBoxHLS) == E_DocStructStyle.DoubleBoxHLS) nxtIsBoxed = 0; - yoff += (nxtIsBoxed * vlnPrintObject.SixLinesPerInch); - } - if (childItemInfo.IsSequential && childItemInfo.NextItem != null && childItemInfo.MyParent.IsHigh && ((childItemInfo.MyDocStyle.StructureStyle.Style & E_DocStructStyle.XBlankW1stLevSub) == E_DocStructStyle.XBlankW1stLevSub)) - { - yoff += vlnPrintObject.SixLinesPerInch; - if (para != null) para.AdjustForXBlankW1stLevSub = vlnPrintObject.SixLinesPerInch; // B2020-112 - } - boxHLS = false; - lastChild = childItemInfo; - } - } - if (box != null && box.MyBox != null) - { - box.Height = yoff - box.YOffset; // new height, with children - // C2017-024 Wolf Creek wanted a hold point with out text and no extra blank lines in the caution/note box - // so if they put only a hard space in for the text, then we will print the note/caution box with only the tab text - // B2018-077 added check for parts under the note (ex. a table off of the note text) fix for Calvert OI-27B 6.11.B and 6.12.B - if (box.MyParent.MyItemInfo.MyContent.Text.StartsWith(@"\u160?") && box.MyParent.MyItemInfo.DisplayText.Length == 1 && box.MyParent.MyItemInfo.MyContent.ContentPartCount == 0) - { - box.Height -= 3 * vlnPrintObject.SixLinesPerInch; - yoff -= vlnPrintObject.SixLinesPerInch; - } - else - yoff += 2 * vlnPrintObject.SixLinesPerInch; - if (lastChild != null && lastChild.FormatStepData.AlwaysUseExtraLines && (lastChild.IsCaution || lastChild.IsNote)) - { - if (!lastChild.MyParent.IsHigh) - yoff += lastChild.ActiveFormat.PlantFormat.FormatData.StepDataList[2].StepLayoutData.STExtraSpace ?? 0; - } - } - // after the last child substep when doing a Component table row (FNP Component Lists), set the value - // of the yoff to be the bottom most line in the table. - if (didComponentTableRow) yoff = tableBottomMost; - ProfileTimer.Pop(profileDepth); - return yoff; - } - private float AddComponentTableSiblings(PdfContentByte cb, ItemInfo ii, float xoff, float yoff, int rnoLevel, int maxRNO, FormatInfo formatInfo, float yoffRight, PromsPrinter pp) - { - // Some of the data for the valve lists (BGE) and component lists (FARLEY) have - // sibling data within a column, rather than hard returns within the same paragraph. - float tableBottomMost = 0; - while (ii != null) - { - vlnParagraph para = new vlnParagraph(Parent, cb, ii, xoff, yoff, rnoLevel, maxRNO, formatInfo, null, null, yoffRight, true, pp); - tableBottomMost = Math.Max(tableBottomMost, para.YBottomMost); - yoff = para.YBottomMost; - Add(para); - ii = ii.GetNextItem(); - } - return tableBottomMost; - } - public float ToPdf(PdfContentByte cb, float yPageStart, ref float yTopMargin, ref float yBottomMargin) - { - foreach (vlnParagraph child in this) - { - yPageStart = child.ToPdf(cb, yPageStart, ref yTopMargin, ref yBottomMargin); - } - return yPageStart; - } - } - public partial class vlnParagraph : vlnPrintObject - { - // B2020-115 Create Static properties for vlnParagraph to limit the size of a figure and paginate large figures properly onto their own page. - public static float wMax = 0; - public static float hMax = 0; - private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); - public override string ToString() - { - return string.Format("{0} - {1} - {2} - '{3}'", this.MyItemInfo.ItemID, this.YTop, this.YSize, this.MyItemInfo.ShortPath); - } - private bool _PageBreakOnStep = false; - public bool PageBreakOnStep - { - get { return _PageBreakOnStep; } - set { _PageBreakOnStep = value; } - } - private bool HasCalvertMacro = false; // this step has the Calvert (BGE) Alarm CONDITION/RESPONSE macro associated with it - private float WidthNoLimit = 0; - private vlnTable _MyGrid; - public vlnTable MyGrid - { - get { return _MyGrid; } - set { _MyGrid = value; } - } - public float SectYPageStart = 0; - private bool _IsWordDocPara = false; - public bool IsWordDocPara - { - get { return _IsWordDocPara; } - set { _IsWordDocPara = value; } - } - public static bool HasPrefPageBreak = false; // use to track page breaks for supp info - public bool PrefPageBreak = false; - private bool _ShowSectionTitles; - public bool ShowSectionTitles - { - get { return _ShowSectionTitles; } - set { _ShowSectionTitles = value; } - } + // para.YBottomMost will have y for bottom of any substeps that are also enclosed in the box. + if (childItemInfo.IsStep && childItemInfo.MyHLS != null && childItemInfo.MyHLS.FormatStepData.UseSmartTemplate && para.ChildrenBelow.Count > 0 && para.ChildrenBelow[0].YBottomMost > para.YBottomMost) + yoff = para.ChildrenBelow[0].YBottomMost; + // if doing the component list (FNP), yoff for the HLS (if it's the component in the list, + // i.e. the leftmost item in the table), the yoff is either the HLS bottom, or the bottom most + // of all of the other columns' data. + else if (childItemInfo.IsHigh && childItemInfo.FormatStepData.UseOldTemplate && childItemInfo.MyDocStyle.ComponentList) + yoff = Math.Max(para.YBottom, para.YBottomMost) + vlnPrintObject.SixLinesPerInch; + // increment the y offset if not doing the ComponentTableFormat + else if (!para.UseTemplateKeepOnCurLine(childItemInfo)) + { + yoff = para.YBottomMost; + } + // don't adjust YBottomost until after yoff is set for the RNO Separator + para.YBottomMost += para.YBottomMostAdjust; + if (box != null && childItemInfo.FormatStepData != null && childItemInfo.FormatStepData.BoxIt) + { + box.Height = yoff - box.YOffset - (1.1F * vlnPrintObject.SixLinesPerInch); + box = null; // if doing boxed steps, only do single sibling at a time. + } + if (bxHlsDraw) + { + box.YOffset = para.YTop; + box.Height = para.Height; + box = null; + } + else if (boxHLS) + { + // the following line controls whether there is 1 line or 2 lines between + // the box line & the starting/ending yoffset of the HLS. WEP2 had no extra line between + // box & top/bottom of step. The DiffContActBox was added for WEP2. + int boxLnAdjust = iChildItemInfo.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.StepSectionPrintData.DiffContActBox ? 1 : 2; + box.YOffset = para.YTop - (boxLnAdjust * vlnPrintObject.SixLinesPerInch); + boxLnAdjust = iChildItemInfo.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.StepSectionPrintData.DiffContActBox ? 1 : 0; - public float ParagraphToPdf(PdfContentByte cb, float yPageStart, float yTopMargin, float yBottomMargin) - { - // Don't print section titles for supplemental information because the title is 'Supplemental Information': - if (MyItemInfo.IsSection && MyPromsPrinter.SupInfoPrintType == E_SupInfoPrintType.SupInfoPdfPrint) return yPageStart; - //if(PartsAbove.Count > 0 && PartsAbove[0] is vlnHeader) - // if (PartsLeft.Count > 0 && PartsLeft[0] is vlnTab) - // //if((PartsLeft[0] as vlnTab).Text[0] != '\u25CF') - // _MyLog.WarnFormat("NoteTab '{0}','{1}','{2}','{3}','{4}','{5}','{6}'", (PartsAbove[0] as vlnHeader).Text, (PartsLeft[0] as vlnTab).Text, MyItemInfo.MyProcedure.DisplayNumber, MyItemInfo.MyHLS.DisplayText, - // MyItemInfo.ShortPath, MyItemInfo.FormatStepData.TabData.IdentPrint, MyItemInfo.FormatStepData.TabData.IdentEdit); - // - // B2017-105 if a symbol character was set to a bigger font size, then the positioning of the larger symbol character was printing too high on the line - // found with Wolf Creek use of the empty box symbol - foreach (Chunk chk in IParagraph.Chunks) - { - if (chk.Font.Size > 16) chk.SetTextRise(-2f); - } - if (MyItemInfo.IsFootnote && Processed) return yPageStart; - int pagenumTran = 0; - if ((MyItemInfo.MyDocStyle.StructureStyle.Style & E_DocStructStyle.DontCountFoldoutPgs) == E_DocStructStyle.DontCountFoldoutPgs) - pagenumTran = MyPageHelper.CurrentPageNumberNoFoldouts; - else - pagenumTran = MyPageHelper.CurrentPageNumber; - if (MyItemInfo.PageNumber == -1) MyItemInfo.PageNumber = pagenumTran; - else if (MyItemInfo.PageNumberUsed != 0 && MyItemInfo.PageNumberUsed != pagenumTran) - { - if (PromsPrinter.TransPageNumProblems == null) PromsPrinter.TransPageNumProblems = new List(); - // C2017-018 Insert tabs between columns - string pnErr = string.Format("{0}\t{1}\t{2}\t{3}", MyItemInfo.ItemID, MyItemInfo.ShortPath, MyItemInfo.PageNumberUsed, pagenumTran); - PromsPrinter.TransPageNumProblems.Add(pnErr); - } - MyItemInfo.PageNumberNextPass = pagenumTran; - if (Processed) return yPageStart; - //float localYPageStart = yPageStart; - Processed = true; - if (_PartsAbove != null && _PartsAbove.Count > 0) - { - // For McGuire and Catawba, they use CustomSpacing which inserts a blank line before high level steps - // if we paginate on one of these blank lines, we want to skip that blank line so that there isn't an - // extra blank line at the top of the page. - if (MyItemInfo.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.StepSectionLayoutData.CustomSpacing && - PartsAbove[0].YOffset + yTopMargin == yPageStart && PartsAbove[0].IParagraph.Content == " ") - { - if (MyItemInfo.IsHigh && ((YOffset - YTopMost) > SixLinesPerInch)) - { - //Console.WriteLine("==> {0} {1} MOST {2} DIF {3}", MyItemInfo.ShortPath, YOffset, YTopMost, YOffset - YTopMost); - yPageStart = yTopMargin + YTopMost; - } - else - yPageStart = yTopMargin + YOffset; - } - else - yPageStart = PartsAbove.ToPdf(cb, yPageStart, ref yTopMargin, ref yBottomMargin); - } + // if the YBottomForBox is set, use it to define height. Note that this property was + // introduced for IP3 continuous hls (surrounded by the asterisk box), no other format/step type uses it. + if (para.YBottomForBox > 0) + box.Height = para.YBottomForBox - box.YOffset - (boxLnAdjust * vlnPrintObject.SixLinesPerInch); // para.YTop - (1.1F * vlnPrintObject.SixLinesPerInch); + else + box.Height = para.YBottomMost - box.YOffset - (boxLnAdjust * vlnPrintObject.SixLinesPerInch); // para.YTop - (1.1F * vlnPrintObject.SixLinesPerInch); + box = null; + } + } + if (boxHLS) + { + // if the next HLS is boxed also, only need 1 line separating, otherwise + // need 2. + ItemInfo nxt = childItemInfo.GetNextItem(); + int nxtIsBoxed = 2; + if (nxt != null && + nxt.FormatStepData.StepLayoutData.STBoxindex != null && nxt.FormatStepData.StepLayoutData.STBoxindex >= 0) nxtIsBoxed--; + if (nxt != null && (nxt.MyDocStyle.StructureStyle.Style & E_DocStructStyle.DoubleBoxHLS) == E_DocStructStyle.DoubleBoxHLS) nxtIsBoxed = 0; + yoff += (nxtIsBoxed * vlnPrintObject.SixLinesPerInch); + } + if (childItemInfo.IsSequential && childItemInfo.NextItem != null && childItemInfo.MyParent.IsHigh && ((childItemInfo.MyDocStyle.StructureStyle.Style & E_DocStructStyle.XBlankW1stLevSub) == E_DocStructStyle.XBlankW1stLevSub)) + { + yoff += vlnPrintObject.SixLinesPerInch; + if (para != null) para.AdjustForXBlankW1stLevSub = vlnPrintObject.SixLinesPerInch; // B2020-112 + } + boxHLS = false; + lastChild = childItemInfo; + } + } + if (box != null && box.MyBox != null) + { + box.Height = yoff - box.YOffset; // new height, with children + // C2017-024 Wolf Creek wanted a hold point with out text and no extra blank lines in the caution/note box + // so if they put only a hard space in for the text, then we will print the note/caution box with only the tab text + // B2018-077 added check for parts under the note (ex. a table off of the note text) fix for Calvert OI-27B 6.11.B and 6.12.B + if (box.MyParent.MyItemInfo.MyContent.Text.StartsWith(@"\u160?") && box.MyParent.MyItemInfo.DisplayText.Length == 1 && box.MyParent.MyItemInfo.MyContent.ContentPartCount == 0) + { + box.Height -= 3 * vlnPrintObject.SixLinesPerInch; + yoff -= vlnPrintObject.SixLinesPerInch; + } + else + yoff += 2 * vlnPrintObject.SixLinesPerInch; + if (lastChild != null && lastChild.FormatStepData.AlwaysUseExtraLines && (lastChild.IsCaution || lastChild.IsNote)) + { + if (!lastChild.MyParent.IsHigh) + yoff += lastChild.ActiveFormat.PlantFormat.FormatData.StepDataList[2].StepLayoutData.STExtraSpace ?? 0; + } + } + // after the last child substep when doing a Component table row (FNP Component Lists), set the value + // of the yoff to be the bottom most line in the table. + if (didComponentTableRow) yoff = tableBottomMost; + ProfileTimer.Pop(profileDepth); + return yoff; + } + private float AddComponentTableSiblings(PdfContentByte cb, ItemInfo ii, float xoff, float yoff, int rnoLevel, int maxRNO, FormatInfo formatInfo, float yoffRight, PromsPrinter pp) + { + // Some of the data for the valve lists (BGE) and component lists (FARLEY) have + // sibling data within a column, rather than hard returns within the same paragraph. + float tableBottomMost = 0; + while (ii != null) + { + vlnParagraph para = new vlnParagraph(Parent, cb, ii, xoff, yoff, rnoLevel, maxRNO, formatInfo, null, null, yoffRight, true, pp); + tableBottomMost = Math.Max(tableBottomMost, para.YBottomMost); + yoff = para.YBottomMost; + Add(para); + ii = ii.GetNextItem(); + } + return tableBottomMost; + } + public float ToPdf(PdfContentByte cb, float yPageStart, ref float yTopMargin, ref float yBottomMargin) + { + foreach (vlnParagraph child in this) + { + yPageStart = child.ToPdf(cb, yPageStart, ref yTopMargin, ref yBottomMargin); + } + return yPageStart; + } + } + public partial class vlnParagraph : vlnPrintObject + { + // B2020-115 Create Static properties for vlnParagraph to limit the size of a figure and paginate large figures properly onto their own page. + public static float wMax = 0; + public static float hMax = 0; + private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + public override string ToString() => string.Format("{0} - {1} - {2} - '{3}'", this.MyItemInfo.ItemID, this.YTop, this.YSize, this.MyItemInfo.ShortPath); - if (MyItemInfo.IsHigh && ((MyItemInfo.MyDocStyle.StructureStyle.Style & E_DocStructStyle.DoubleBoxHLS) == E_DocStructStyle.DoubleBoxHLS)) yPageStart -= SixLinesPerInch; - if (MyItemInfo.IsHigh && MyItemInfo.MyDocStyle.SpecialStepsFoldout) yPageStart -= SixLinesPerInch; - if (MyItemInfo.IsHigh && !MyItemInfo.ActiveFormat.MyStepSectionLayoutData.DoSTExtraAtTop && (yPageStart - YTopMost == yTopMargin)) - { - yPageStart += ((MyItemInfo.FormatStepData == null) ? 0 : MyItemInfo.FormatStepData.StepLayoutData.STExtraSpace ?? 0); - // F2021-038: SHE/SHEA format - Less space after boxes: the AlwaysUseExtyraLines was removed in SHE/SHEA format, but the - // following adjustment to the y location of HLS when AT TOP of page is still needed, i.e. added the NoYBxAdjust check which is SHE/SHEA specific - if ((MyItemInfo.Cautions != null && (MyItemInfo.Cautions[0].FormatStepData.AlwaysUseExtraLines || MyItemInfo.Cautions[0].FormatStepData.NoYBxAdjust)) || (MyItemInfo.Notes != null && (MyItemInfo.Notes[0].FormatStepData.AlwaysUseExtraLines || MyItemInfo.Notes[0].FormatStepData.NoYBxAdjust))) - yPageStart -= ((MyItemInfo.FormatStepData == null) ? 0 : MyItemInfo.FormatStepData.StepLayoutData.STExtraSpace ?? 0); - } - // Save the HLS & RNO string in case the pagelist item uses it (some of the backgrounds): - if (MyItemInfo.FormatStepData != null && MyItemInfo.FormatStepData.PageBreakOnStep) - { - MyPageHelper.HLSTAB = MyItemInfo.HighLevelStepTabPageList; - // find the rno and use it's tab for the HLRNO part. - ItemInfo rno = MyItemInfo.RNOs != null && MyItemInfo.RNOs.Count > 0 ? MyItemInfo.RNOs[0] : null; - string rnotab = (rno == null) ? null : rno.DisplayText; - MyPageHelper.HLRNO = rno == null ? null : MyItemInfo.FormatStepData.TabData.RNOIdent + rnotab; - MyPageHelper.ResetSvg(); - } + public bool PageBreakOnStep { get; set; } = false; + private readonly bool HasCalvertMacro = false; // this step has the Calvert (BGE) Alarm CONDITION/RESPONSE macro associated with it + private readonly float WidthNoLimit = 0; - float yLocation = CalculateYOffset(yPageStart, yTopMargin); - if (MyItemInfo.HasChangeBar && MyPageHelper.ChangeBarDefinition.MyChangeBarType != PrintChangeBar.Without) MyPageHelper.AddChangeBar(DoChangeBar(cb, MyItemInfo, MyPageHelper, XOffset, yLocation, MyPageHelper.MaxRNO, MyItemInfo.ActiveFormat), cbMess); - float retval = yLocation; - // 'doprint' will always be true if not doing NSP's {HLSTEXT} token in page list. The following code is used to prevent - // printing the High level step, if the high level step is printed from the pagelist using {HLSTEXT} token. - bool doprint = !(MyPageHelper.DidHLSText && MyItemInfo.ItemID == MyPageHelper.HasHLSTextId); - if (MyItemInfo.IsFigure) - { - yLocation -= (SixLinesPerInch * MyPageHelper.YMultiplier); - if (ImageText != null) - retval = DrawFigure(cb, yBottomMargin, yLocation, yPageStart, yTopMargin); - else - retval = DrawText(cb, ref yPageStart, yTopMargin, yBottomMargin, ref yLocation); - if (MyItemInfo.IsInSupInfo) _yPageStartForSupInfo = retval; - } - else if (MyItemInfo.IsRtfRaw) - { - retval = DrawRaw(cb, yBottomMargin, yLocation, yPageStart, yTopMargin); - if (MyItemInfo.IsInSupInfo) _yPageStartForSupInfo = retval * .6f; - } - else if (!MyItemInfo.IsStepSection - || (ShowSectionTitles - && !MyItemInfo.MyDocStyle.CancelSectTitle - && !MyItemInfo.MyDocStyle.SpecialStepsFoldout)) // Don't ouput the Step Section title - { - // if this is a section, then check the section config for printable header too. - if (MyItemInfo.IsSection) - { - SectionConfig sch = MyItemInfo.MyConfig as SectionConfig; - //if (!(ShowSectionTitles - // && !MyItemInfo.MyDocStyle.CancelSectTitle - // && !MyItemInfo.MyDocStyle.SpecialStepsFoldout - // && !MyItemInfo.ActiveFormat.PlantFormat.FormatData.SectData.UseMetaSections) - // && - if (sch != null && sch.Section_PrintHdr != "Y") doprint = false; - } - if (MyItemInfo.MyContent.MyGrid != null) - { - int profileDepth = ProfileTimer.Push(">>>> vlnParagraph.DrawGrid"); - // RHM20150507 Include Footer - retval = DrawGrid(cb, ref yPageStart, yTopMargin, yBottomMargin + (float)MyItemInfo.MyDocStyle.Layout.FooterLength, ref yLocation); // RHM20150429 - Table Scrunch - if (MyItemInfo.IsInSupInfo) _yPageStartForSupInfo = (float)MyPageHelper.BottomContent - SixLinesPerInch; - ProfileTimer.Pop(profileDepth); - } - else - { - if (doprint) - { - int profileDepth = ProfileTimer.Push(">>>> vlnParagraph.DrawText"); - IsCompressed = (MyPageHelper.YMultiplier != 1 && MyItemInfo != null && MyItemInfo.FormatStepData != null && MyItemInfo.FormatStepData.Font.Size >= 12 && (MyItemInfo.FormatStepData.Font.Style & E_Style.Underline) != 0); + public vlnTable MyGrid { get; set; } + public float SectYPageStart = 0; - retval = DrawText(cb, ref yPageStart, yTopMargin, yBottomMargin, ref yLocation); - // _yPageStartForSupInfo is used to move steps down the page for the supinfo pdf. Each supinfo step may not be related to previous in structure, so need this to set y location. - if (MyItemInfo.IsInSupInfo) _yPageStartForSupInfo = retval; - // Wolf Creek Training format puts a separator line after printing the section number/title - if (MyItemInfo.IsSection && MyItemInfo.ActiveFormat.PlantFormat.FormatData.PrintData.WCNTraining) - MyPageHelper.SectionSepLineYoffStart = retval - (SixLinesPerInch / 2); - SectionContinuePrinted = true; - ProfileTimer.Pop(profileDepth); - } - } - if (MyItemInfo.IsHigh) - { - // C2025-014 change the zoom setting on the bookmark of a step from FITBH to FITV so that instead of zooming in - // on the step it will zoom to the page level ( like it does when you select a bookmark on a section. - MyPageHelper.PageBookmarks.Add(MyItemInfo, (MyItemInfo.MyTab == null) ? "" : MyItemInfo.MyTab.CleanText + " " + MyItemInfo.DisplayText, - new PdfDestination(PdfDestination.FITV, yLocation + YVeryTop - YTopMost + SixLinesPerInch)); - } - } - if (MyItemInfo.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.WolfcreekCKLFormat) - { - DrawChkOrValveTableLines(cb, MyItemInfo, yPageStart, yTopMargin, yBottomMargin, yLocation); - } - if (MyItemInfo.IsSection) - { - SectionConfig sc = MyItemInfo.MyConfig as SectionConfig; - if ((MyItemInfo.MyDocStyle != null && MyItemInfo.MyDocStyle.IncludeInTOC && (sc == null || sc.Section_TOC != "Y")) - || ((MyItemInfo.MyDocStyle == null || !MyItemInfo.MyDocStyle.IncludeInTOC) && (sc != null && sc.Section_TOC == "Y"))) - { - string tocKey = string.Format("TOC{0}", MyItemInfo.ItemID); - if (MyPageHelper.MyTOCPageCounts.ContainsKey(tocKey)) - { - PageCount pc = MyPageHelper.MyTOCPageCounts[tocKey]; - if (pc.Total == 0) - { - pc.Total = MyPageHelper.CurrentTOCPageNumber + 1; - pc.DrawTemplates(); + public bool IsWordDocPara { get; set; } = false; + public static bool HasPrefPageBreak = false; // use to track page breaks for supp info + public bool PrefPageBreak = false; - } - } - } - } - else if (MyItemInfo.IsHigh && MyItemInfo.MyDocStyle != null && MyItemInfo.MyDocStyle.IncludeInTOC) // && (MyItemInfo.MyActiveSection.MyConfig as SectionConfig).Section_HLS_on_TOC == "Y") - { - // C2021-015: Barakah High Level Steps in Table of Contents - SectionConfig sc = MyItemInfo.ActiveSection.MyConfig as SectionConfig; - StepConfig stc = MyItemInfo.MyConfig as StepConfig; - if ((sc != null && sc.Section_TOC != "Y") && (stc != null && stc.Step_IncludeInTOC)) - { - string tocKey = string.Format("TOC{0}", MyItemInfo.ItemID); - if (MyPageHelper.MyTOCPageCounts.ContainsKey(tocKey)) - { - PageCount pc = MyPageHelper.MyTOCPageCounts[tocKey]; - if (pc.Total == 0) - { - pc.Total = MyPageHelper.CurrentTOCPageNumber + 1; - pc.DrawTemplates(); + public bool ShowSectionTitles { get; set; } - } - } - } - } - if (!doprint) return yPageStart; - if (_PartsLeft != null && _PartsLeft.Count > 0) yPageStart = PartsLeft.ToPdf(cb, yPageStart, ref yTopMargin, ref yBottomMargin); - if (_PartsRight != null && _PartsRight.Count > 0) yPageStart = PartsRight.ToPdf(cb, yPageStart, ref yTopMargin, ref yBottomMargin); - if (_PartsBelow != null && _PartsBelow.Count > 0) yPageStart = PartsBelow.ToPdf(cb, yPageStart, ref yTopMargin, ref yBottomMargin); - if (_PartsContainer != null && _PartsContainer.Count > 0) yPageStart = PartsContainer.ToPdf(cb, yPageStart, ref yTopMargin, ref yBottomMargin); + [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0059:Unnecessary assignment of a value", Justification = "retval kept for Debugging")] + public float ParagraphToPdf(PdfContentByte cb, float yPageStart, float yTopMargin, float yBottomMargin) + { + // Don't print section titles for supplemental information because the title is 'Supplemental Information': + if (MyItemInfo.IsSection && MyPromsPrinter.SupInfoPrintType == E_SupInfoPrintType.SupInfoPdfPrint) return yPageStart; + //For Debugging: + //if(PartsAbove.Count > 0 && PartsAbove[0] is vlnHeader) + // if (PartsLeft.Count > 0 && PartsLeft[0] is vlnTab) + // //if((PartsLeft[0] as vlnTab).Text[0] != '\u25CF') + // _MyLog.WarnFormat("NoteTab '{0}','{1}','{2}','{3}','{4}','{5}','{6}'", (PartsAbove[0] as vlnHeader).Text, (PartsLeft[0] as vlnTab).Text, MyItemInfo.MyProcedure.DisplayNumber, MyItemInfo.MyHLS.DisplayText, + // MyItemInfo.ShortPath, MyItemInfo.FormatStepData.TabData.IdentPrint, MyItemInfo.FormatStepData.TabData.IdentEdit); + // + // B2017-105 if a symbol character was set to a bigger font size, then the positioning of the larger symbol character was printing too high on the line + // found with Wolf Creek use of the empty box symbol + foreach (Chunk chk in IParagraph.Chunks) + { + if (chk.Font.Size > 16) chk.SetTextRise(-2f); + } + if (MyItemInfo.IsFootnote && Processed) return yPageStart; + int pagenumTran; + if ((MyItemInfo.MyDocStyle.StructureStyle.Style & E_DocStructStyle.DontCountFoldoutPgs) == E_DocStructStyle.DontCountFoldoutPgs) + pagenumTran = MyPageHelper.CurrentPageNumberNoFoldouts; + else + pagenumTran = MyPageHelper.CurrentPageNumber; + if (MyItemInfo.PageNumber == -1) MyItemInfo.PageNumber = pagenumTran; + else if (MyItemInfo.PageNumberUsed != 0 && MyItemInfo.PageNumberUsed != pagenumTran) + { + if (PromsPrinter.TransPageNumProblems == null) PromsPrinter.TransPageNumProblems = new List(); + // C2017-018 Insert tabs between columns + string pnErr = string.Format("{0}\t{1}\t{2}\t{3}", MyItemInfo.ItemID, MyItemInfo.ShortPath, MyItemInfo.PageNumberUsed, pagenumTran); + PromsPrinter.TransPageNumProblems.Add(pnErr); + } + MyItemInfo.PageNumberNextPass = pagenumTran; + if (Processed) return yPageStart; + Processed = true; + if (_PartsAbove != null && _PartsAbove.Count > 0) + { + // For McGuire and Catawba, they use CustomSpacing which inserts a blank line before high level steps + // if we paginate on one of these blank lines, we want to skip that blank line so that there isn't an + // extra blank line at the top of the page. + if (MyItemInfo.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.StepSectionLayoutData.CustomSpacing && + PartsAbove[0].YOffset + yTopMargin == yPageStart && PartsAbove[0].IParagraph.Content == " ") + { + if (MyItemInfo.IsHigh && ((YOffset - YTopMost) > SixLinesPerInch)) + { + //Console.WriteLine("==> {0} {1} MOST {2} DIF {3}", MyItemInfo.ShortPath, YOffset, YTopMost, YOffset - YTopMost); + yPageStart = yTopMargin + YTopMost; + } + else + yPageStart = yTopMargin + YOffset; + } + else + yPageStart = PartsAbove.ToPdf(cb, yPageStart, ref yTopMargin, ref yBottomMargin); + } - //if (localYPageStart != yPageStart) DebugText.WriteLine("ParToPdf-yPagestartDiff:{0},{1},{2}", MyItemInfo.ItemID, localYPageStart, yPageStart); - return yPageStart; - } + if (MyItemInfo.IsHigh && ((MyItemInfo.MyDocStyle.StructureStyle.Style & E_DocStructStyle.DoubleBoxHLS) == E_DocStructStyle.DoubleBoxHLS)) yPageStart -= SixLinesPerInch; + if (MyItemInfo.IsHigh && MyItemInfo.MyDocStyle.SpecialStepsFoldout) yPageStart -= SixLinesPerInch; + if (MyItemInfo.IsHigh && !MyItemInfo.ActiveFormat.MyStepSectionLayoutData.DoSTExtraAtTop && (yPageStart - YTopMost == yTopMargin)) + { + yPageStart += ((MyItemInfo.FormatStepData == null) ? 0 : MyItemInfo.FormatStepData.StepLayoutData.STExtraSpace ?? 0); + // F2021-038: SHE/SHEA format - Less space after boxes: the AlwaysUseExtyraLines was removed in SHE/SHEA format, but the + // following adjustment to the y location of HLS when AT TOP of page is still needed, i.e. added the NoYBxAdjust check which is SHE/SHEA specific + if ((MyItemInfo.Cautions != null && (MyItemInfo.Cautions[0].FormatStepData.AlwaysUseExtraLines || MyItemInfo.Cautions[0].FormatStepData.NoYBxAdjust)) || (MyItemInfo.Notes != null && (MyItemInfo.Notes[0].FormatStepData.AlwaysUseExtraLines || MyItemInfo.Notes[0].FormatStepData.NoYBxAdjust))) + yPageStart -= ((MyItemInfo.FormatStepData == null) ? 0 : MyItemInfo.FormatStepData.StepLayoutData.STExtraSpace ?? 0); + } + // Save the HLS & RNO string in case the pagelist item uses it (some of the backgrounds): + if (MyItemInfo.FormatStepData != null && MyItemInfo.FormatStepData.PageBreakOnStep) + { + MyPageHelper.HLSTAB = MyItemInfo.HighLevelStepTabPageList; + // find the rno and use it's tab for the HLRNO part. + ItemInfo rno = MyItemInfo.RNOs != null && MyItemInfo.RNOs.Count > 0 ? MyItemInfo.RNOs[0] : null; + string rnotab = rno?.DisplayText; + MyPageHelper.HLRNO = rno == null ? null : MyItemInfo.FormatStepData.TabData.RNOIdent + rnotab; + MyPageHelper.ResetSvg(); + } - private float DrawRaw(PdfContentByte cb, float yBottomMargin, float yLocation, float yPageStart, float yTopMargin) - { - if (DebugText.IsOpen) DebugText.WriteLine("{0},'{1}','{2}','<>'", MyItemInfo.ItemID, MyItemInfo.DBSequence, FormattedText); - float retval = yLocation; - System.Drawing.Size sz = RtfRawItem.GetRtfRawSize(MyItemInfo.MyContent.Text); - Height = sz.Height; - Width = sz.Width; - Volian.Controls.Library.RTF myRtb = new RTF(); - myRtb.Size = sz; - myRtb.Rtf = MyItemInfo.MyContent.Text; - try - { - System.Drawing.Image image = new System.Drawing.Bitmap((int)Width, (int)Height); - System.Drawing.Graphics gr = System.Drawing.Graphics.FromImage(image); - myRtb.RenderClipped(gr, new System.Drawing.Rectangle(0, 0, (int)Width, (int)Height)); - // B2017-116 Adjust Image Size by Scaler (Used for Facing Pages - Sup Info) - // B2017-241 Adjust Bottom Message Location for the raw figure (Equation or Visio) - MyPageHelper.BottomContent = yLocation - (.6F * Height * MyPageHelper.YMultiplier * ImageScaler); - retval = Rtf2Pdf.RtfRawAt(cb, image, XOffset + MyItemInfo.FormatStepData.Font.CharsToTwips, yLocation, Width * MyPageHelper.YMultiplier * ImageScaler, Height * MyPageHelper.YMultiplier * ImageScaler, DebugInfo, yBottomMargin, !MyItemInfo.FormatStepData.Type.ToUpper().Contains("BORDERLESS")); - } - catch (Exception ex) - { - return retval + 2 * SixLinesPerInch; // couldn't print equation, just print 2 blank lines. - } - return retval; - } - private bool _SectionContinuePrinted = false; + float yLocation = CalculateYOffset(yPageStart, yTopMargin); + if (MyItemInfo.HasChangeBar && MyPageHelper.ChangeBarDefinition.MyChangeBarType != PrintChangeBar.Without) MyPageHelper.AddChangeBar(DoChangeBar(cb, MyItemInfo, MyPageHelper, XOffset, yLocation, MyPageHelper.MaxRNO, MyItemInfo.ActiveFormat), cbMess); + float retval = yLocation; + // 'doprint' will always be true if not doing NSP's {HLSTEXT} token in page list. The following code is used to prevent + // printing the High level step, if the high level step is printed from the pagelist using {HLSTEXT} token. + bool doprint = !(MyPageHelper.DidHLSText && MyItemInfo.ItemID == MyPageHelper.HasHLSTextId); + if (MyItemInfo.IsFigure) + { + yLocation -= (SixLinesPerInch * MyPageHelper.YMultiplier); + if (ImageText != null) + retval = DrawFigure(cb, yLocation, yPageStart, yTopMargin); + else + retval = DrawText(cb, ref yPageStart, yTopMargin, yBottomMargin, ref yLocation); + if (MyItemInfo.IsInSupInfo) _yPageStartForSupInfo = retval; + } + else if (MyItemInfo.IsRtfRaw) + { + retval = DrawRaw(cb, yLocation); + if (MyItemInfo.IsInSupInfo) _yPageStartForSupInfo = retval * .6f; + } + else if (!MyItemInfo.IsStepSection + || (ShowSectionTitles + && !MyItemInfo.MyDocStyle.CancelSectTitle + && !MyItemInfo.MyDocStyle.SpecialStepsFoldout)) // Don't ouput the Step Section title + { + // if this is a section, then check the section config for printable header too. + if (MyItemInfo.IsSection) + { + if (MyItemInfo.MyConfig is SectionConfig sch && sch.Section_PrintHdr != "Y") doprint = false; + } + if (MyItemInfo.MyContent.MyGrid != null) + { + int profileDepth = ProfileTimer.Push(">>>> vlnParagraph.DrawGrid"); + // RHM20150507 Include Footer + retval = DrawGrid(cb, yTopMargin, yBottomMargin + (float)MyItemInfo.MyDocStyle.Layout.FooterLength, ref yLocation); // RHM20150429 - Table Scrunch + if (MyItemInfo.IsInSupInfo) _yPageStartForSupInfo = (float)MyPageHelper.BottomContent - SixLinesPerInch; + ProfileTimer.Pop(profileDepth); + } + else + { + if (doprint) + { + int profileDepth = ProfileTimer.Push(">>>> vlnParagraph.DrawText"); + IsCompressed = (MyPageHelper.YMultiplier != 1 && MyItemInfo != null && MyItemInfo.FormatStepData != null && MyItemInfo.FormatStepData.Font.Size >= 12 && (MyItemInfo.FormatStepData.Font.Style & E_Style.Underline) != 0); - public bool SectionContinuePrinted - { - get { return _SectionContinuePrinted; } - set { _SectionContinuePrinted = value; } - } - private void DrawChkOrValveTableLines(PdfContentByte cb, ItemInfo ii, float yPageStart, float yTopMargin, float yBottomMargin, float yLocation) - { - if (!ii.IsStep || ii.IsCaution || ii.IsNote) return; + retval = DrawText(cb, ref yPageStart, yTopMargin, yBottomMargin, ref yLocation); + // _yPageStartForSupInfo is used to move steps down the page for the supinfo pdf. Each supinfo step may not be related to previous in structure, so need this to set y location. + if (MyItemInfo.IsInSupInfo) _yPageStartForSupInfo = retval; + // Wolf Creek Training format puts a separator line after printing the section number/title + if (MyItemInfo.IsSection && MyItemInfo.ActiveFormat.PlantFormat.FormatData.PrintData.WCNTraining) + MyPageHelper.SectionSepLineYoffStart = retval - (SixLinesPerInch / 2); + SectionContinuePrinted = true; + ProfileTimer.Pop(profileDepth); + } + } + if (MyItemInfo.IsHigh) + { + // C2025-014 change the zoom setting on the bookmark of a step from FITBH to FITV so that instead of zooming in + // on the step it will zoom to the page level ( like it does when you select a bookmark on a section. + MyPageHelper.PageBookmarks.Add(MyItemInfo, (MyItemInfo.MyTab == null) ? "" : $"{MyItemInfo.MyTab.CleanText} {MyItemInfo.DisplayText}", + new PdfDestination(PdfDestination.FITV, yLocation + YVeryTop - YTopMost + SixLinesPerInch)); + } + } + if (MyItemInfo.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.WolfcreekCKLFormat) + { + DrawChkOrValveTableLines(cb, MyItemInfo, yPageStart, yBottomMargin, yLocation); + } + if (MyItemInfo.IsSection) + { + SectionConfig sc = MyItemInfo.MyConfig as SectionConfig; + if ((MyItemInfo.MyDocStyle != null && MyItemInfo.MyDocStyle.IncludeInTOC && (sc == null || sc.Section_TOC != "Y")) + || ((MyItemInfo.MyDocStyle == null || !MyItemInfo.MyDocStyle.IncludeInTOC) && (sc != null && sc.Section_TOC == "Y"))) + { + string tocKey = string.Format("TOC{0}", MyItemInfo.ItemID); + if (MyPageHelper.MyTOCPageCounts.ContainsKey(tocKey)) + { + PageCount pc = MyPageHelper.MyTOCPageCounts[tocKey]; + if (pc.Total == 0) + { + pc.Total = MyPageHelper.CurrentTOCPageNumber + 1; + pc.DrawTemplates(); - Box bx = ii.ActiveFormat.PlantFormat.FormatData.BoxList[0]; - float lpi = MyPageHelper.YMultiplier == 1.0 ? SixLinesPerInch : _SevenLinesPerInch; - bool savedebug = Rtf2Pdf.PdfDebug; - Rtf2Pdf.PdfDebug = false; - // follow through in fixing an Out of Window Handles bug, use new function to see if - // we can retrieve the font from a dictionary instead a doing a New and using another - // window handle B2017-117 - //System.Drawing.Font symbFont = new System.Drawing.Font("VESymbFix", (float)ii.FormatStepData.Font.Size); - System.Drawing.Font symbFont = VE_Font.GetWinSysFont("VESymbFix", (float)ii.FormatStepData.Font.Size); - iTextSharp.text.Font iSymblFont = Volian.Svg.Library.VolianPdf.GetFont(symbFont); - iSymblFont.Color = new iTextSharp.text.Color(PrintOverride.OverrideTextColor(System.Drawing.Color.Black)); - // The vertPos array from the format defines the column locations: - string[] vertPos = ii.MyHLS.FormatStepData.VertPos.Split(",".ToCharArray()); - // Count how many vertical lines are in the checklist table: - int cntVertPos = vertPos.Length - 1; - while (vertPos[cntVertPos] == "0" && cntVertPos > 0) cntVertPos--; - cntVertPos++; - Paragraph paraVertLine = new Paragraph(ii.ActiveFormat.PlantFormat.FormatData.BoxList[0].BXVert, iSymblFont); - float lWidth = 100; - float csize = 6 - .3f; // added the .3 to make line up with 16bit. + } + } + } + } + else if (MyItemInfo.IsHigh && MyItemInfo.MyDocStyle != null && MyItemInfo.MyDocStyle.IncludeInTOC) // && (MyItemInfo.MyActiveSection.MyConfig as SectionConfig).Section_HLS_on_TOC == "Y") + { + // C2021-015: Barakah High Level Steps in Table of Contents + if ((MyItemInfo.ActiveSection.MyConfig is SectionConfig sc && sc.Section_TOC != "Y") && (MyItemInfo.MyConfig is StepConfig stc && stc.Step_IncludeInTOC)) + { + string tocKey = string.Format("TOC{0}", MyItemInfo.ItemID); + if (MyPageHelper.MyTOCPageCounts.ContainsKey(tocKey)) + { + PageCount pc = MyPageHelper.MyTOCPageCounts[tocKey]; + if (pc.Total == 0) + { + pc.Total = MyPageHelper.CurrentTOCPageNumber + 1; + pc.DrawTemplates(); - // if High Level Step, just need to do edges for number of lines: - if (ii.IsHigh) - { - // count # of '{\par} commands in prefix and suffix. - int countLine = 0; - string preSuf_Fix = (ii.FormatStepData.Prefix != null && ii.FormatStepData.Prefix != "") ? ii.FormatStepData.Prefix : null; - if (preSuf_Fix != null) countLine++; // account for a line of prefix (if no \par) - // if this is a proportional font, need to 'draw' the prefix/suffix. NOTE that the suffix should - // just list the headers and the prefix can be 'empty'. - if (ii.FormatStepData.Font.FontIsProportional()) - { - float yLocVertLine = yLocation + (lpi * 1.5F); // +(lpi / 2); - // Prefix, i.e. Top line: - Paragraph topLeftLine = new Paragraph(bx.BXULC, iSymblFont); - Rtf2Pdf.TextAt(cb, topLeftLine, float.Parse(vertPos[0]) + (float)ii.MyDocStyle.Layout.LeftMargin - csize, yLocVertLine, lWidth, 100, null, yBottomMargin); - Paragraph topRightLine = new Paragraph(bx.BXURC, iSymblFont); - Rtf2Pdf.TextAt(cb, topRightLine, float.Parse(vertPos[cntVertPos - 1]) + (float)ii.MyDocStyle.Layout.LeftMargin - csize, yLocVertLine, lWidth, 100, null, yBottomMargin); - Paragraph horzLine = new Paragraph(bx.BXHorz, iSymblFont); - float thPos = float.Parse(vertPos[0]) + csize; - while (thPos < float.Parse(vertPos[cntVertPos - 1])) - { - Rtf2Pdf.TextAt(cb, horzLine, thPos + (float)ii.MyDocStyle.Layout.LeftMargin - csize, yLocVertLine, lWidth, 100, null, yBottomMargin); - thPos += csize; - } + } + } + } + } + if (!doprint) return yPageStart; + if (_PartsLeft != null && _PartsLeft.Count > 0) yPageStart = PartsLeft.ToPdf(cb, yPageStart, ref yTopMargin, ref yBottomMargin); + if (_PartsRight != null && _PartsRight.Count > 0) yPageStart = PartsRight.ToPdf(cb, yPageStart, ref yTopMargin, ref yBottomMargin); + if (_PartsBelow != null && _PartsBelow.Count > 0) yPageStart = PartsBelow.ToPdf(cb, yPageStart, ref yTopMargin, ref yBottomMargin); + if (_PartsContainer != null && _PartsContainer.Count > 0) yPageStart = PartsContainer.ToPdf(cb, yPageStart, ref yTopMargin, ref yBottomMargin); - // Vertical Lines around HLS - //int countLine = (int)(this.Height / lpi); - yLocVertLine = yLocation + (lpi/2);// -(lpi / 2); - for (int i = 0; i < 1; i++) - { - Rtf2Pdf.TextAt(cb, paraVertLine, float.Parse(vertPos[0]) + (float)ii.MyDocStyle.Layout.LeftMargin - csize, yLocVertLine, lWidth, 100, null, yBottomMargin); - Rtf2Pdf.TextAt(cb, paraVertLine, float.Parse(vertPos[cntVertPos - 1]) + (float)ii.MyDocStyle.Layout.LeftMargin - csize, yLocVertLine, lWidth, 100, null, yBottomMargin); - yLocVertLine -= lpi; - } + //if (localYPageStart != yPageStart) DebugText.WriteLine("ParToPdf-yPagestartDiff:{0},{1},{2}", MyItemInfo.ItemID, localYPageStart, yPageStart); + return yPageStart; + } - // Suffix, i.e. Column headers. - // first do left/right side chars above and below column headers - //countLine = (int)(this.Height / lpi); - Paragraph sideLeftLine = new Paragraph(bx.BXMLS, iSymblFont); - Rtf2Pdf.TextAt(cb, sideLeftLine, float.Parse(vertPos[0]) + (float)ii.MyDocStyle.Layout.LeftMargin - csize, yLocVertLine, lWidth, 100, null, yBottomMargin); - Rtf2Pdf.TextAt(cb, sideLeftLine, float.Parse(vertPos[0]) + (float)ii.MyDocStyle.Layout.LeftMargin - csize, yLocVertLine - (2 * lpi), lWidth, 100, null, yBottomMargin); - Paragraph sideRightLine = new Paragraph(bx.BXMRS, iSymblFont); - Rtf2Pdf.TextAt(cb, sideRightLine, float.Parse(vertPos[6]) + (float)ii.MyDocStyle.Layout.LeftMargin - csize, yLocVertLine, lWidth, 100, null, yBottomMargin); - Rtf2Pdf.TextAt(cb, sideRightLine, float.Parse(vertPos[6]) + (float)ii.MyDocStyle.Layout.LeftMargin - csize, yLocVertLine - (2 * lpi), lWidth, 100, null, yBottomMargin); + private float DrawRaw(PdfContentByte cb, float yLocation) + { + if (DebugText.IsOpen) DebugText.WriteLine("{0},'{1}','{2}','<>'", MyItemInfo.ItemID, MyItemInfo.DBSequence, FormattedText); + float retval = yLocation; + System.Drawing.Size sz = RtfRawItem.GetRtfRawSize(MyItemInfo.MyContent.Text); + Height = sz.Height; + Width = sz.Width; + Volian.Controls.Library.RTF myRtb = new RTF + { + Size = sz, + Rtf = MyItemInfo.MyContent.Text + }; + try + { + System.Drawing.Image image = new System.Drawing.Bitmap((int)Width, (int)Height); + System.Drawing.Graphics gr = System.Drawing.Graphics.FromImage(image); + myRtb.RenderClipped(gr, new System.Drawing.Rectangle(0, 0, (int)Width, (int)Height)); + // B2017-116 Adjust Image Size by Scaler (Used for Facing Pages - Sup Info) + // B2017-241 Adjust Bottom Message Location for the raw figure (Equation or Visio) + MyPageHelper.BottomContent = yLocation - (.6F * Height * MyPageHelper.YMultiplier * ImageScaler); + retval = Rtf2Pdf.RtfRawAt(cb, image, XOffset + MyItemInfo.FormatStepData.Font.CharsToTwips, yLocation, Width * MyPageHelper.YMultiplier * ImageScaler, Height * MyPageHelper.YMultiplier * ImageScaler, DebugInfo, !MyItemInfo.FormatStepData.Type.ToUpper().Contains("BORDERLESS")); + } + catch (Exception) + { + return retval + 2 * SixLinesPerInch; // couldn't print equation, just print 2 blank lines. + } + return retval; + } - // now do the lines with the 'T' type lines for top/bottom of vertical lines. - thPos = float.Parse(vertPos[0]) + csize; - while (thPos < float.Parse(vertPos[cntVertPos - 1])) - { - Rtf2Pdf.TextAt(cb, horzLine, thPos + (float)ii.MyDocStyle.Layout.LeftMargin - csize, yLocVertLine, lWidth, 100, null, yBottomMargin); - Rtf2Pdf.TextAt(cb, horzLine, thPos + (float)ii.MyDocStyle.Layout.LeftMargin - csize, yLocVertLine - (2 * lpi), lWidth, 100, null, yBottomMargin); - thPos += csize; - } + public bool SectionContinuePrinted { get; set; } = false; + private void DrawChkOrValveTableLines(PdfContentByte cb, ItemInfo ii, float yPageStart, float yBottomMargin, float yLocation) + { + if (!ii.IsStep || ii.IsCaution || ii.IsNote) return; - // now do the vertical bar between header words and the column header words. - yLocVertLine -= lpi; - string[] colHdrs = _MyItemInfo.FormatStepData.Suffix.Substring(_MyItemInfo.FormatStepData.Suffix.IndexOf(";") + 1).Split(",".ToCharArray()); - iTextSharp.text.Font iHdrFont = Volian.Svg.Library.VolianPdf.GetFont(_MyItemInfo.FormatStepData.Font.WindowsFont); - iHdrFont.Color = new iTextSharp.text.Color(PrintOverride.OverrideTextColor(System.Drawing.Color.Black)); + Box bx = ii.ActiveFormat.PlantFormat.FormatData.BoxList[0]; + float lpi = MyPageHelper.YMultiplier == 1.0 ? SixLinesPerInch : _SevenLinesPerInch; + bool savedebug = Rtf2Pdf.PdfDebug; + Rtf2Pdf.PdfDebug = false; + // follow through in fixing an Out of Window Handles bug, use new function to see if + // we can retrieve the font from a dictionary instead a doing a New and using another + // window handle B2017-117 + //System.Drawing.Font symbFont = new System.Drawing.Font("VESymbFix", (float)ii.FormatStepData.Font.Size); + System.Drawing.Font symbFont = VE_Font.GetWinSysFont("VESymbFix", (float)ii.FormatStepData.Font.Size); + iTextSharp.text.Font iSymblFont = Volian.Svg.Library.VolianPdf.GetFont(symbFont); + iSymblFont.Color = new iTextSharp.text.Color(PrintOverride.OverrideTextColor(System.Drawing.Color.Black)); + // The vertPos array from the format defines the column locations: + string[] vertPos = ii.MyHLS.FormatStepData.VertPos.Split(",".ToCharArray()); + // Count how many vertical lines are in the checklist table: + int cntVertPos = vertPos.Length - 1; + while (vertPos[cntVertPos] == "0" && cntVertPos > 0) cntVertPos--; + cntVertPos++; + Paragraph paraVertLine = new Paragraph(ii.ActiveFormat.PlantFormat.FormatData.BoxList[0].BXVert, iSymblFont); + float lWidth = 100; + float csize = 6 - .3f; // added the .3 to make line up with 16bit. - Paragraph topT = new Paragraph(bx.BXUMID, iSymblFont); - Paragraph crossT = new Paragraph(bx.BXMID, iSymblFont); + // if High Level Step, just need to do edges for number of lines: + if (ii.IsHigh) + { + // count # of '{\par} commands in prefix and suffix. + int countLine = 0; + string preSuf_Fix = (ii.FormatStepData.Prefix != null && ii.FormatStepData.Prefix != "") ? ii.FormatStepData.Prefix : null; + if (preSuf_Fix != null) countLine++; // account for a line of prefix (if no \par) + // if this is a proportional font, need to 'draw' the prefix/suffix. NOTE that the suffix should + // just list the headers and the prefix can be 'empty'. + if (ii.FormatStepData.Font.FontIsProportional()) + { + float yLocVertLine = yLocation + (lpi * 1.5F); // +(lpi / 2); + // Prefix, i.e. Top line: + Paragraph topLeftLine = new Paragraph(bx.BXULC, iSymblFont); + Rtf2Pdf.TextAt(cb, topLeftLine, float.Parse(vertPos[0]) + (float)ii.MyDocStyle.Layout.LeftMargin - csize, yLocVertLine, lWidth, 100, null, yBottomMargin); + Paragraph topRightLine = new Paragraph(bx.BXURC, iSymblFont); + Rtf2Pdf.TextAt(cb, topRightLine, float.Parse(vertPos[cntVertPos - 1]) + (float)ii.MyDocStyle.Layout.LeftMargin - csize, yLocVertLine, lWidth, 100, null, yBottomMargin); + Paragraph horzLine = new Paragraph(bx.BXHorz, iSymblFont); + float thPos = float.Parse(vertPos[0]) + csize; + while (thPos < float.Parse(vertPos[cntVertPos - 1])) + { + Rtf2Pdf.TextAt(cb, horzLine, thPos + (float)ii.MyDocStyle.Layout.LeftMargin - csize, yLocVertLine, lWidth, 100, null, yBottomMargin); + thPos += csize; + } - for (int i = 0; i < cntVertPos; i++) - { - // do vertical line: - Rtf2Pdf.TextAt(cb, paraVertLine, float.Parse(vertPos[i]) + (float)ii.MyDocStyle.Layout.LeftMargin - csize, yLocVertLine, lWidth, 100, null, yBottomMargin); - // do the column header text - center it: - if (i < colHdrs.Length) - { - Paragraph parColHdr = new Paragraph(colHdrs[i], iHdrFont); - // find the center point of column header and subtract 1/2 width of the text to locate the text. - float hloc = (float.Parse(vertPos[i]) + ((float.Parse(vertPos[i + 1]) - float.Parse(vertPos[i])) / 2)); - Chunk chk = (Chunk)parColHdr.Chunks[0]; - hloc = hloc - (chk.GetWidthPoint() / 2); - Rtf2Pdf.TextAt(cb, parColHdr, hloc + (float)ii.MyDocStyle.Layout.LeftMargin, yLocVertLine, lWidth, 100, null, yBottomMargin); - } - // Do the crosswise table characters, i.e. T and + - if (i > 0 && i < colHdrs.Length) - { - Rtf2Pdf.TextAt(cb, topT, float.Parse(vertPos[i]) + (float)ii.MyDocStyle.Layout.LeftMargin - csize, yLocVertLine + lpi, lWidth, 100, null, yBottomMargin); - Rtf2Pdf.TextAt(cb, crossT, float.Parse(vertPos[i]) + (float)ii.MyDocStyle.Layout.LeftMargin - csize, yLocVertLine - lpi, lWidth, 100, null, yBottomMargin); - } - } - } - else - #region OriginalHLS - { - int hIndx = preSuf_Fix.IndexOf(@"{\par}"); - while (preSuf_Fix != null && hIndx >= 0) - { - hIndx = preSuf_Fix.IndexOf(@"{\par}", hIndx + 1); - countLine++; - } - preSuf_Fix = (ii.FormatStepData.Suffix != null && ii.FormatStepData.Suffix != "") ? ii.FormatStepData.Suffix : null; - if (preSuf_Fix != null) countLine++; // account for a line of suffix (if no \par) - hIndx = preSuf_Fix.IndexOf(@"{\par}"); - while (preSuf_Fix != null && hIndx >= 0) - { - hIndx = preSuf_Fix.IndexOf(@"{\par}", hIndx + 1); - countLine++; - } - // get first and last vertpos for location of lines: - // for each line of text, draw the start & end box line: - countLine = (int)(this.Height / lpi) - countLine; - float yLocVertLine = yLocation - lpi / 2; - for (int i = 0; i < countLine; i++) - { - Rtf2Pdf.TextAt(cb, paraVertLine, float.Parse(vertPos[0]) + (float)ii.MyDocStyle.Layout.LeftMargin - csize, yLocVertLine, lWidth, 100, null, yBottomMargin); - Rtf2Pdf.TextAt(cb, paraVertLine, float.Parse(vertPos[cntVertPos - 1]) + (float)ii.MyDocStyle.Layout.LeftMargin - csize, yLocVertLine, lWidth, 100, null, yBottomMargin); - yLocVertLine -= lpi; - } - } - #endregion OriginalHLS - } - else - { - // This section of code draws the lines around the substeps (the actual table part) - Paragraph horzLine = new Paragraph(ii.ActiveFormat.PlantFormat.FormatData.BoxList[0].BXHorz, iSymblFont); - bool bottomOfTable = ii.NextItem == null || - (MyPageHelper.ParaBreaks.Count > 0 && MyPageHelper.ParaBreaks[0].MyItemInfo.ItemID == ii.NextItem.ItemID); - // if bottom of table use different cross/beg/end chars than if in middle of table. - Paragraph leftLine = new Paragraph(bottomOfTable ? bx.BXLLC : bx.BXMLS, iSymblFont); - Paragraph rightLine = new Paragraph(bottomOfTable ? bx.BXLRC : bx.BXMRS, iSymblFont); + // Vertical Lines around HLS + yLocVertLine = yLocation + (lpi / 2);// -(lpi / 2); + for (int i = 0; i < 1; i++) + { + Rtf2Pdf.TextAt(cb, paraVertLine, float.Parse(vertPos[0]) + (float)ii.MyDocStyle.Layout.LeftMargin - csize, yLocVertLine, lWidth, 100, null, yBottomMargin); + Rtf2Pdf.TextAt(cb, paraVertLine, float.Parse(vertPos[cntVertPos - 1]) + (float)ii.MyDocStyle.Layout.LeftMargin - csize, yLocVertLine, lWidth, 100, null, yBottomMargin); + yLocVertLine -= lpi; + } - // If this item is in the leftmost column in table, this is determined by looking at its parent, - // its parent must be a HLS, do the vertical lines since all cells have all vertical lines. - // Lines should be drawn from current to ybottommost. Also draw the bottom line. - if (ii.MyParent.IsHigh) - { - // first do the vertical bars. - float curY = yLocation; - while (curY > (yPageStart - this.YBottomMost + lpi)) - { - for (int i = 0; i < cntVertPos; i++) - Rtf2Pdf.TextAt(cb, paraVertLine, float.Parse(vertPos[i]) + (float)ii.MyDocStyle.Layout.LeftMargin - csize, curY + 3, lWidth, 100, null, yBottomMargin); - curY -= lpi; - } - // Now do the bottom line for this item. - Paragraph crossLine = new Paragraph(bottomOfTable ? bx.BXLMID : bx.BXMID, iSymblFont); - float yloc = yPageStart - this.YBottomMost + 18; - Rtf2Pdf.TextAt(cb, leftLine, float.Parse(vertPos[0]) + (float)ii.MyDocStyle.Layout.LeftMargin - csize, yloc, lWidth, 100, null, yBottomMargin); - float hPos = float.Parse(vertPos[0]) + csize; - int doHorizCnt = 0; - while (doHorizCnt < cntVertPos - 1) - { - while (hPos < float.Parse(vertPos[doHorizCnt + 1])) - { - Rtf2Pdf.TextAt(cb, horzLine, hPos + (float)ii.MyDocStyle.Layout.LeftMargin - csize, yloc, lWidth, 100, null, yBottomMargin); - hPos += csize; - } + // Suffix, i.e. Column headers. + // first do left/right side chars above and below column headers + //For Debugging: countLine = (int)(this.Height / lpi); + Paragraph sideLeftLine = new Paragraph(bx.BXMLS, iSymblFont); + Rtf2Pdf.TextAt(cb, sideLeftLine, float.Parse(vertPos[0]) + (float)ii.MyDocStyle.Layout.LeftMargin - csize, yLocVertLine, lWidth, 100, null, yBottomMargin); + Rtf2Pdf.TextAt(cb, sideLeftLine, float.Parse(vertPos[0]) + (float)ii.MyDocStyle.Layout.LeftMargin - csize, yLocVertLine - (2 * lpi), lWidth, 100, null, yBottomMargin); + Paragraph sideRightLine = new Paragraph(bx.BXMRS, iSymblFont); + Rtf2Pdf.TextAt(cb, sideRightLine, float.Parse(vertPos[6]) + (float)ii.MyDocStyle.Layout.LeftMargin - csize, yLocVertLine, lWidth, 100, null, yBottomMargin); + Rtf2Pdf.TextAt(cb, sideRightLine, float.Parse(vertPos[6]) + (float)ii.MyDocStyle.Layout.LeftMargin - csize, yLocVertLine - (2 * lpi), lWidth, 100, null, yBottomMargin); - // put out middle piece, i.e. + (cross) lines or bottom line - hPos = float.Parse(vertPos[doHorizCnt + 1]); - if (doHorizCnt < cntVertPos - 2) // don't put out crossLine on last one. - Rtf2Pdf.TextAt(cb, crossLine, float.Parse(vertPos[doHorizCnt + 1]) + (float)ii.MyDocStyle.Layout.LeftMargin - csize, yloc, lWidth, 100, null, yBottomMargin); - hPos += csize; - doHorizCnt++; - } - // put out the right side piece - Rtf2Pdf.TextAt(cb, rightLine, float.Parse(vertPos[cntVertPos - 1]) + (float)ii.MyDocStyle.Layout.LeftMargin - csize, yloc, lWidth, 100, null, yBottomMargin); - } - // Now handle middle parts of the table. For whatever sub level we're at, draw the cross character - // and the horizontal. This is case where the component number may have multiple descriptions,positions, etc. associated - // with it. - if (!ii.MyParent.IsHigh && ii.NextItem != null) - { - // draw horizontally from this sublevel to the end. - int sublev = 0; - ItemInfo par = this.MyItemInfo; - while (!par.IsHigh) - { - sublev++; - par = par.MyParent; - } - sublev--; - float ylocs = yPageStart - this.YBottomMost + 15; - for (int i = sublev; i < cntVertPos - 1; i++) - { - float hPos = float.Parse(vertPos[i]) + csize; - Rtf2Pdf.TextAt(cb, leftLine, float.Parse(vertPos[i]) + (float)ii.MyDocStyle.Layout.LeftMargin - csize, ylocs, lWidth, 100, null, yBottomMargin); - while (hPos < float.Parse(vertPos[i + 1])) - { - // do the horizontal line - Rtf2Pdf.TextAt(cb, horzLine, hPos + (float)ii.MyDocStyle.Layout.LeftMargin - csize, ylocs, lWidth, 100, null, yBottomMargin); - hPos += csize; - } - } - // Do the last cross character - Rtf2Pdf.TextAt(cb, rightLine, float.Parse(vertPos[cntVertPos - 1]) + (float)ii.MyDocStyle.Layout.LeftMargin - csize, ylocs, lWidth, 100, null, yBottomMargin); - } - } - Rtf2Pdf.PdfDebug = savedebug; - } - private float DrawGrid(PdfContentByte cb, ref float yPageStart, float yTopMargin, float yBottomMargin, ref float yLocation) - { - //DebugText.WriteLine("{0},'{1}','{2}','<>'", MyItemInfo.ItemID, MyItemInfo.ShortPath, FormattedText); - if (DebugText.IsOpen) DebugText.WriteLine("{0},'{1}','{2}','<>',{3}", MyItemInfo.ItemID, MyItemInfo.ShortPath, MyItemInfo.MyContent.Text, XOffset); - //if (MyItemInfo.InList(11019,11024,111026)) // RHM20150507 Table Scrunch - // Console.WriteLine("here"); - float heightBefore = (MyGrid.Height + 4) * MyPageHelper.YMultiplier; // B2020-014 added parenthesis was calculating wrong for 7lpi Callaway FSG-7 Attachment 7 - // B2018-033 Account for bottom continue message when seeing if a scrunched table will fit - float ySizeBtmCtnMess = GetBottomContinueMessageSize(MyItemInfo.MyDocStyle); - // B2018-085 Ignore the bottom continue message if the Table is the last part of the step. - if(ySizeBtmCtnMess > 0 && MyParent.MyItemInfo.IsHigh && YBottomMost == MyParent.YBottomMost) ySizeBtmCtnMess = 0; - // TableScrunch Phase 1: Is height of table greater than what will fit on current page. - if (Rtf2Pdf.GetTableScrunchingStatus(TableScrunching.Phase1) && heightBefore > (yLocation - (yBottomMargin + ySizeBtmCtnMess))) - { - // TooBig is the amount of height that the grid is larger than the amount of space on the page. It is set to - // (height of grid w/ compressed setting if needed + line) - (how much room on page) - // NOTE TooBig actually will do the adjustments of the row heights by eliminating the blank space! - MyGrid.TooBig = SixLinesPerInch + MyGrid.Height * MyPageHelper.YMultiplier - (yLocation - yBottomMargin - ySizeBtmCtnMess); - float heightAfter = (MyGrid.Height + 4) * MyPageHelper.YMultiplier; // B2020-014 added parenthesis was calculating wrong for 7lpi Callaway FSG-7 Attachment 7 - MyPageHelper.TableAdjustment += (heightBefore - heightAfter); - MyPageHelper.AdjustedTable = this; // B2020-059 - save the information of the table that is being compressed (used in RTF2PDF.cs TextAt()) - MyPageHelper.AdjustedTableYtop = yLocation; // B2020-059 save the top location of the compressed table (used in RTF2PDF.cs TextAt()) - //B2018-092 Determine if the Table is too big by checking it including either 6 LPI or 7 LPI as appropriate - if (heightAfter * MyPageHelper.YMultiplier < (yLocation - yBottomMargin - ySizeBtmCtnMess)) - { - // B2018-081 - Removed error log message if the code was able to properly adjust the table - //_MyLog.WarnFormat("\r\n==> Table is too big to fit on page, Vertical Padding adjusted to fit in\r\n" + - // " [{0}] {1}\r\n" + - // " in {2}\r\n" + - // " Height Before={3:N2} Height After={4:N2} SpaceAvailable={5:N2}\r\n" + - // " No action necessary", - // MyItemInfo.ItemID,_MyItemInfo.ShortPath, - // _MyItemInfo.SearchDVPath.Replace("\a", "/"), heightBefore / 72, MyGrid.Height / 72, (yTopMargin - yBottomMargin) / 72); - //_MyLog.ErrorFormat("<<< WARNING >>> Table is too big to fit on page, Vertical Padding adjusted to fit\r\n==>'Table Adjusted',{0},'{1}','{2}',{3},{4},{5}" - // , MyItemInfo.ItemID, MyItemInfo.MyDocVersion.MyFolder.Name, MyItemInfo.ShortPath, heightBefore, MyGrid.Height, (yTopMargin - yBottomMargin)); - } - else - MyGrid.IsTooBig = true; - if (MyItemInfo.HasChangeBar && MyPageHelper.ChangeBarDefinition.MyChangeBarType != PrintChangeBar.Without) - { - foreach (vlnChangeBar vcb in MyPageHelper.MyChangeBars) - { - if (vcb.Height == heightBefore / MyPageHelper.YMultiplier - 4) - { - float heightDif = (heightBefore - heightAfter); - vcb.YChangeBarBottom += heightDif; - FixMessages(vcb, heightDif); - break; - } - } - } - } - //B2018-092 Correct the location of the bottom continue message including either 6 LPI or 7 LPI as appropriate - MyPageHelper.BottomContent = yLocation - (MyGrid.Height + 4) * MyPageHelper.YMultiplier; - float retval = Rtf2Pdf.GridAt(cb, MyGrid, XOffset, yLocation, Width, 100, DebugInfo, yBottomMargin, !MyItemInfo.FormatStepData.Type.Contains("Borderless")); - //B2018-092 Determine if the Table is too big by checking it including either 6 LPI or 7 LPI as appropriate - if ((MyGrid.Height + 4)* MyPageHelper.YMultiplier > (yLocation - yBottomMargin - ySizeBtmCtnMess)) - { - // B2018-081 Changed the Error Log Message to be more useful when a table is too big. - _MyLog.ErrorFormat("\r\n===> Table is too big to fit on page, expect pagination problems in\r\n" + - " 1> Item [{0}] {1}\r\n" + - " 2> in {2}\r\n" + - " 3> Height Before={3:N2} Height After={4:N2} SpaceAvailable={5:N2}\r\n" + - " 4> ACTION REQUIRED: Table should be restructured or split over multiple pages", - MyItemInfo.ItemID, _MyItemInfo.ShortPath, - _MyItemInfo.SearchDVPath.Replace("\a", "/"), heightBefore/72, MyGrid.Height/72, (yTopMargin - yBottomMargin)/72); - //_MyLog.ErrorFormat("<<< ERROR >>> Table is too big to fit on page, expect pagination problems\r\n==>'Table Too Big',{0},'{1}','{2}',{3},{4},{5}" // RHM20150429 - Table Scrunch - // , MyItemInfo.ItemID, MyItemInfo.MyDocVersion.MyFolder.Name, MyItemInfo.ShortPath, heightBefore, MyGrid.Height, (yTopMargin - yBottomMargin)); - } - return retval; - } + // now do the lines with the 'T' type lines for top/bottom of vertical lines. + thPos = float.Parse(vertPos[0]) + csize; + while (thPos < float.Parse(vertPos[cntVertPos - 1])) + { + Rtf2Pdf.TextAt(cb, horzLine, thPos + (float)ii.MyDocStyle.Layout.LeftMargin - csize, yLocVertLine, lWidth, 100, null, yBottomMargin); + Rtf2Pdf.TextAt(cb, horzLine, thPos + (float)ii.MyDocStyle.Layout.LeftMargin - csize, yLocVertLine - (2 * lpi), lWidth, 100, null, yBottomMargin); + thPos += csize; + } - private void FixMessages(vlnChangeBar vcb, float heightDif) - { - SortedDictionary msd = vcb.Messages; - vcb.Messages = new SortedDictionary(); - foreach (float key in msd.Keys) - { - vcb.Messages.Add(key + heightDif, msd[key]); - } - } - private float DrawText(PdfContentByte cb, ref float yPageStart, float yTopMargin, float yBottomMargin, ref float yLocation) - { - if (DebugText.IsOpen) DebugText.WriteLine("{0},'{1}','{2}','<>'", MyItemInfo.ItemID, MyItemInfo.DBSequence, FormattedText); - //Console.WriteLine("{0},{1},'{2}','<>'", MyItemInfo.ItemID, MyItemInfo.DBSequence, IParagraph.Content); - float retval = yLocation; - if (MyItemInfo.IsRtfRaw) - { - retval = Rtf2Pdf.TextAt(cb, IParagraph, XOffset, yLocation, Width, 100, DebugInfo + string.Format(",YLines = {0}", YSize / SixLinesPerInch), yBottomMargin, MyItemInfo.ItemID); // C2018-004 ItemID for create meta file for baseline compares - return retval; - } + // now do the vertical bar between header words and the column header words. + yLocVertLine -= lpi; + string[] colHdrs = MyItemInfo.FormatStepData.Suffix.Substring(MyItemInfo.FormatStepData.Suffix.IndexOf(";") + 1).Split(",".ToCharArray()); + iTextSharp.text.Font iHdrFont = Volian.Svg.Library.VolianPdf.GetFont(MyItemInfo.FormatStepData.Font.WindowsFont); + iHdrFont.Color = new iTextSharp.text.Color(PrintOverride.OverrideTextColor(System.Drawing.Color.Black)); - // Calvert Alarms have a special case, center text if the next/previous is not the same type of caution or note. - // Calvert Alarms have a note1 that is a warning. if a regular note preceeded it, this regular note was not centered. - // F2023-126: Vogtle Alarms - center single line caution/note if more than one type exist off step, added the check for NoteCautionCenterOneAllTypes - bool doAlign = false; - if ((MyItemInfo.ActiveFormat.PlantFormat.FormatData.PrintData.SpecialCaseCalvert || MyItemInfo.ActiveFormat.PlantFormat.FormatData.PrintData.NoteCautionCenterOneAllTypes) && (MyItemInfo.IsCaution || MyItemInfo.IsNote || MyItemInfo.IsNote1)) - { - bool diffAsPrev = MyItemInfo.MyPrevious == null || (MyItemInfo.MyPrevious != null && MyItemInfo.MyContent.Type != MyItemInfo.MyPrevious.MyContent.Type); - bool diffAsNext = MyItemInfo.NextItem == null || (MyItemInfo.NextItem != null && MyItemInfo.MyContent.Type != MyItemInfo.NextItem.MyContent.Type); - if (diffAsPrev && diffAsNext) doAlign = true; - } - // Check if only one line, i.e. "Height < (1.2F * IParagraph.Leading". The Leading can be for six or seven lines per inch, so the 1.2 - // multiplier accounts for both. - // B2021-091 added a null reference check - MyItemInfo was a section and didn't have FormatStepData - // F2021-042: Added FormatStepData.AlwaysCenter for BNPP1 - Critical Step text always must be centered - // B2022-146: Left Justify Note & Caution text that has sub-steps (for Beaver Valley) - bool cnWithChildren = !MyItemInfo.IsStepSection && MyItemInfo.FormatStepData != null && MyItemInfo.FormatStepData.CenterOnlyIfNoSubs && MyItemInfo.HasChildren; - if (!MyItemInfo.IsStepSection && MyItemInfo.FormatStepData != null && MyItemInfo.FormatStepData.CenterOneLineOnly && !cnWithChildren && ((MyItemInfo.MyPrevious == null && MyItemInfo.NextItem == null) - || MyItemInfo.FormatStepData.SeparateBox || doAlign || MyItemInfo.FormatStepData.AlwaysCenter) && Height < (1.2F * IParagraph.Leading)) - IParagraph.Alignment = Element.ALIGN_CENTER; - // if this step is centered, but not part of the checklist or valvelist format, use itextsharp to center it. - // if it was part of the checklist or valvelist, then the centering is based on the column definitions for the table and - // was calculated when the paragraph was made. - // B2021-091 added a null reference check - MyItemInfo was a section and didn't have FormatStepData - if (!MyItemInfo.IsStepSection && MyItemInfo.FormatStepData != null && MyItemInfo.FormatStepData.StepPrintData.Justify == "Center" && !MyItemInfo.FormatStepData.StepLayoutData.AlignWithParentTab) - IParagraph.Alignment = Element.ALIGN_CENTER; - if (PrefixSpecialCharacter && IParagraph.Chunks.Count > 0) - { - Chunk chk = IParagraph.Chunks[0] as Chunk; - if (chk.Content == " ") - { - PrefixSpecialCharacter = false; - //Console.WriteLine("Special {0}", MyItemInfo.MyHLS.DisplayText); - IParagraph.Chunks.RemoveAt(0); - } - } - // if printing checklist header, adjust ypagestart & ylocation so that won't get forced pagination (pagination is already ok) - //Console.WriteLine("'Q1',{0},'{1}',{2},{3},{4},{5},{6}", MyItemInfo.ItemID, MyItemInfo.ShortPath, yTopMargin, yPageStart, yLocation, YTopMost, YOffset); - if (PrintHeader) - { - yPageStart = yTopMargin + YVeryTop; - yLocation = yPageStart - YOffset; // yLocation is physical location from bottom of page. - } - if (yLocation - Height < 24) - { - if (DebugPagination.IsOpen) - DebugPagination.WriteLine("Very Low {0},{1},{2},{3},{4},{5}", MyItemInfo.ShortPath, MyItemInfo.ItemID, yLocation, Height, yLocation - Height, yTopMargin - MyItemInfo.MyDocStyle.Layout.PageLength); - //C2018-015 add debug pagination to meta file - if (BaselineMetaFile.IsOpen) - BaselineMetaFile.WriteLine("!! Very Low {0},{1},{2},{3},{4},{5}", MyItemInfo.ShortPath, MyItemInfo.ItemID, yLocation, Height, yLocation - Height, yTopMargin - MyItemInfo.MyDocStyle.Layout.PageLength); - } - int profileDepth = ProfileTimer.Push(">>>> Rtf2Pdf.TextAt"); - // ooooooooo. oooooooooo. oooooooooooo ooooooooooooo o8o . o8o - // `888 `Y88. `888' `Y8b `888' `8 8' 888 `8 `"' .o8 `"' - // 888 .d88' 888 888 888 888 oooo d8b .oooo. ooo. .oo. .oooo.o oooo .o888oo oooo .ooooo. ooo. .oo. .oooo.o - // 888ooo88P' 888 888 888oooo8 888 `888""8P `P )88b `888P"Y88b d88( "8 `888 888 `888 d88' `88b `888P"Y88b d88( "8 - // 888 888 888 888 " 888 888 .oP"888 888 888 `"Y88b. 888 888 888 888 888 888 888 `"Y88b. - // 888 888 d88' 888 888 888 d8( 888 888 888 o. )88b 888 888 . 888 888 888 888 888 o. )88b - // o888o o888bood8P' o888o o888o d888b `Y888""8o o888o o888o 8""888P' o888o "888" o888o `Y8bod8P' o888o o888o 8""888P' - // - // Design Suggestion: - // During vlnParagraaph Constuctor Build an end point dictionary - // During toPdf check for end points before adding GoTos for Local - // Need to have a way to get to sections which do not have any output (header only) - // Need to have a way to identify procedures - // - // B2018-034 The following code previously used IParagraph rather than _IParagraph. If the variable IsCompressed (7LPI) is true for this step - // IParagraph would be refreshed each time it was referenced. Thus the link information would be lost when the IParagraph was re-created. - // This resulted in PDFLinks to steps that were not not identified with a LocalDestination. This was changed from the original code to - // fix B2015-076 when the Byron Flex Procedure 0BFSG-6 was printed. The issue for this bug was that the underlining at 7LPI was overlaping the - // top of the next line of text. I was not able to find the case referencedd in the source safe document. However, by adding a line of - // text "One more line" to the end of step 2 in attachment C, I was able to see the effect. - if (_IParagraph.Chunks.Count > 0 && MyPageHelper.MyPromsPrinter.SaveLinks) - { - // B2018-034 The following code previously used IParagraph rather than _IParagraph. See first Comment - Chunk chk1 = _IParagraph.Chunks[0] as Chunk; - if (MyItemInfo.MyContent.Text.ToUpper().Contains("LINK:TR") && MyItemInfo.MyContent.ContentTransitionCount==0) - Console.WriteLine("Missing Transition {0}", MyItemInfo.ItemID); - chk1.SetLocalDestination(string.Format("ItemID={0}", MyItemInfo.ItemID)); // Destination - // B2019-052: If multiple ROs/Transitions within a step, each should have a their own link rather than all linking to same thing. - // Note the pdf link code that was here was moved to Rtf2iTextSharp.cs in DoVisitText so that each 'chunk' could have a link. - // The code that remained here was the code that marks the destination for each step & the code that does the pdf links for - // enhanced steps. - // Also, the method GetDefaultItemInfo was moved to Rtf2iTextSharp.cs also - it was only called from code that was moved. - - StepConfig sc = new StepConfig(MyItemInfo.MyContent.Config); - DVEnhancedDocuments dveds = MyItemInfo.MyDocVersion.DocVersionConfig.MyEnhancedDocuments; - foreach (EnhancedDocument ed in sc.MyEnhancedDocuments) - { - DVEnhancedDocument dved = dveds.GetByType(ed.Type); - AddLinkToEnhancedDocument(cb, yLocation, ed.ItemID, dved.PdfToken, dved.PdfX); - } - // MyPageHelper.BottomContent = yLocation - Height; - //if (MyItemInfo.InList(39048)) Console.WriteLine("Here"); - } - MyPageHelper.BottomContent = yLocation - (Height * MyPageHelper.YMultiplier); - retval = Rtf2Pdf.TextAt(cb, IParagraph, XOffset, yLocation, Width, 100, DebugInfo + string.Format(",YLines = {0}", YSize / SixLinesPerInch), yBottomMargin, MyItemInfo.ItemID); // C2018-004 ItemID for create meta file for baseline compares - ProfileTimer.Pop(profileDepth); - if (retval == 0) // problem occurred - paragraph was not able to be printed on page - { // pagination logic needs to be fixed. - // oooooooooooo ooooooooo. o8o . o8o - // `888' `8 `888 `Y88. `"' .o8 `"' - // 888 .ooooo. oooo d8b .ooooo. .ooooo. 888 .d88' .oooo. .oooooooo oooo ooo. .oo. .oooo. .o888oo oooo .ooooo. ooo. .oo. - // 888oooo8 d88' `88b `888""8P d88' `"Y8 d88' `88b 888ooo88P' `P )88b 888' `88b `888 `888P"Y88b `P )88b 888 `888 d88' `88b `888P"Y88b - // 888 " 888 888 888 888 888ooo888 888 .oP"888 888 888 888 888 888 .oP"888 888 888 888 888 888 888 - // 888 888 888 888 888 .o8 888 .o 888 d8( 888 `88bod8P' 888 888 888 d8( 888 888 . 888 888 888 888 888 - // o888o `Y8bod8P' d888b `Y8bod8P' `Y8bod8P' o888o `Y888""8o `8oooooo. o888o o888o o888o `Y888""8o "888" o888o `Y8bod8P' o888o o888o - // d" YD - // "Y88888P' - ForcePagination(cb, ref yPageStart, yTopMargin, yBottomMargin, ref yLocation, ref retval); - } - else - { - if (MyItemInfo.IsStepSection && MyItemInfo.ActiveFormat.PlantFormat.FormatData.PrintData.SpecialCaseCalvert && (MyItemInfo.ActiveSection as SectionInfo).HasInitials) - { - if (MyPageHelper.PrintInitials(cb, yLocation, (float)MyItemInfo.MyDocStyle.Layout.LeftMargin)) - { - //if(yLocation != yTopMargin) - // Console.WriteLine("'{0}',{1},'{2}',{3},{4},{5},{6}", MyItemInfo.MyProcedure.DisplayNumber, MyItemInfo.ItemID - // , MyItemInfo.DisplayNumber, yLocation,yTopMargin,MyItemInfo.HasCautionOrNote,MyPageHelper.CurrentPageNumber+1); - } - } - } - return retval; - } - private static void AddLinkToEnhancedDocument(PdfContentByte cb, float yLocation, int itemID, String token, int xLocation) - { - ItemInfo ii = ItemInfo.Get(itemID); - //B2020-133 if "ii" is null, then the itemid was not found- probable enhanced step was deleted. so just return with out creating a link - if (ii == null) return; - string prefix = ii.MyDocVersion.DocVersionConfig.Print_PDFFilePrefix ?? ""; - string suffix = ii.MyDocVersion.DocVersionConfig.Print_PDFFileSuffix ?? ""; - ColumnText ct = new ColumnText(cb); - ct.SetSimpleColumn(xLocation, yLocation - 12, xLocation + 30, 12 + yLocation); - iTextSharp.text.Font font = FontFactory.GetFont("Arial", BaseFont.IDENTITY_H, BaseFont.EMBEDDED, 12); - Chunk chk = new Chunk(token); - chk.SetRemoteGoto(prefix + ii.MyProcedure.DisplayNumber.Replace("/", "_") + suffix + ".pdf", string.Format("ItemID={0}", itemID)); - chk.SetBackground(new Color(System.Drawing.Color.LemonChiffon)); - ct.AddElement(chk); - cb.SetColorFill(Color.BLUE); - ct.Go(); + Paragraph topT = new Paragraph(bx.BXUMID, iSymblFont); + Paragraph crossT = new Paragraph(bx.BXMID, iSymblFont); - //foreach (Chunk chk in IParagraph.Chunks) - //{ - // chk.SetRemoteGoto(ii.MyProcedure.DisplayNumber.Replace("/", "_") + ".pdf", string.Format("ItemID={0}",ii.ItemID)); - // chk.SetBackground(new Color(System.Drawing.Color.LemonChiffon)); - //} - } - private static bool _MissingInitials = false; + for (int i = 0; i < cntVertPos; i++) + { + // do vertical line: + Rtf2Pdf.TextAt(cb, paraVertLine, float.Parse(vertPos[i]) + (float)ii.MyDocStyle.Layout.LeftMargin - csize, yLocVertLine, lWidth, 100, null, yBottomMargin); + // do the column header text - center it: + if (i < colHdrs.Length) + { + Paragraph parColHdr = new Paragraph(colHdrs[i], iHdrFont); + // find the center point of column header and subtract 1/2 width of the text to locate the text. + float hloc = (float.Parse(vertPos[i]) + ((float.Parse(vertPos[i + 1]) - float.Parse(vertPos[i])) / 2)); + Chunk chk = (Chunk)parColHdr.Chunks[0]; + hloc -= (chk.GetWidthPoint() / 2); + Rtf2Pdf.TextAt(cb, parColHdr, hloc + (float)ii.MyDocStyle.Layout.LeftMargin, yLocVertLine, lWidth, 100, null, yBottomMargin); + } + // Do the crosswise table characters, i.e. T and + + if (i > 0 && i < colHdrs.Length) + { + Rtf2Pdf.TextAt(cb, topT, float.Parse(vertPos[i]) + (float)ii.MyDocStyle.Layout.LeftMargin - csize, yLocVertLine + lpi, lWidth, 100, null, yBottomMargin); + Rtf2Pdf.TextAt(cb, crossT, float.Parse(vertPos[i]) + (float)ii.MyDocStyle.Layout.LeftMargin - csize, yLocVertLine - lpi, lWidth, 100, null, yBottomMargin); + } + } + } + else + #region OriginalHLS + { + int hIndx = preSuf_Fix.IndexOf(@"{\par}"); + while (preSuf_Fix != null && hIndx >= 0) + { + hIndx = preSuf_Fix.IndexOf(@"{\par}", hIndx + 1); + countLine++; + } + preSuf_Fix = (ii.FormatStepData.Suffix != null && ii.FormatStepData.Suffix != "") ? ii.FormatStepData.Suffix : null; + if (preSuf_Fix != null) countLine++; // account for a line of suffix (if no \par) + hIndx = preSuf_Fix.IndexOf(@"{\par}"); + while (preSuf_Fix != null && hIndx >= 0) + { + hIndx = preSuf_Fix.IndexOf(@"{\par}", hIndx + 1); + countLine++; + } + // get first and last vertpos for location of lines: + // for each line of text, draw the start & end box line: + countLine = (int)(this.Height / lpi) - countLine; + float yLocVertLine = yLocation - lpi / 2; + for (int i = 0; i < countLine; i++) + { + Rtf2Pdf.TextAt(cb, paraVertLine, float.Parse(vertPos[0]) + (float)ii.MyDocStyle.Layout.LeftMargin - csize, yLocVertLine, lWidth, 100, null, yBottomMargin); + Rtf2Pdf.TextAt(cb, paraVertLine, float.Parse(vertPos[cntVertPos - 1]) + (float)ii.MyDocStyle.Layout.LeftMargin - csize, yLocVertLine, lWidth, 100, null, yBottomMargin); + yLocVertLine -= lpi; + } + } + #endregion OriginalHLS + } + else + { + // This section of code draws the lines around the substeps (the actual table part) + Paragraph horzLine = new Paragraph(ii.ActiveFormat.PlantFormat.FormatData.BoxList[0].BXHorz, iSymblFont); + bool bottomOfTable = ii.NextItem == null || + (MyPageHelper.ParaBreaks.Count > 0 && MyPageHelper.ParaBreaks[0].MyItemInfo.ItemID == ii.NextItem.ItemID); + // if bottom of table use different cross/beg/end chars than if in middle of table. + Paragraph leftLine = new Paragraph(bottomOfTable ? bx.BXLLC : bx.BXMLS, iSymblFont); + Paragraph rightLine = new Paragraph(bottomOfTable ? bx.BXLRC : bx.BXMRS, iSymblFont); - public static bool MissingInitials - { - get { return vlnParagraph._MissingInitials; } - set { vlnParagraph._MissingInitials = value; } - } - public static void TextAt(PdfContentByte cb, VlnSvgPageHelper myPageHelper, PageItem pi, float yloc, float leftMargin) - { - System.Drawing.Color sysColor = PrintOverride.OverrideSvgColor(System.Drawing.Color.Black); - cb.SaveState(); - if (myPageHelper.PageListLayer != null) cb.BeginLayer(myPageHelper.PageListLayer); - ColumnText ct = new ColumnText(cb); - iTextSharp.text.Font font; - int fontStyle = 0; - bool underline = false; - if (pi == null) // The header for the signoffs is missing in the current section format. - // An Example can currently be found in Calvert OI-34 - { - if (!MissingInitials) // Only show this once. - { - _MyLog.WarnFormat("Initials Header Missing" + - "\r\nInitials header missing for section {0}" + - "\r\nfrom format [{1}], {2}, subformat {3}" + - "\r\nA default Arial font and a default location will be used." + - "\r\nPerhaps another section format should be used.", - myPageHelper.MySection.ShortPath, - myPageHelper.MySection.ActiveFormat.Name, - myPageHelper.MySection.ActiveFormat.Description, - myPageHelper.MySection.MyDocStyle.Name); - MissingInitials = true; - } - ct.SetSimpleColumn(450 + leftMargin, yloc + 6.9F, 550 + leftMargin, yloc - 50); - font = FontFactory.GetFont("Arial", BaseFont.IDENTITY_H, BaseFont.EMBEDDED, 10F); - } - else - { - ct.SetSimpleColumn((float)pi.Col + leftMargin, yloc + 6.9F, (float)pi.Col + 100 + leftMargin, yloc - 50); - fontStyle = (pi.Font.WindowsFont.Bold ? iTextSharp.text.Font.BOLD : 0) + (pi.Font.WindowsFont.Italic ? iTextSharp.text.Font.ITALIC : 0); - font = FontFactory.GetFont(pi.Font.Family, BaseFont.IDENTITY_H, BaseFont.EMBEDDED, (float)pi.Font.Size, fontStyle); - underline = pi.Font.WindowsFont.Underline; - } - Chunk chk = new Chunk("INITIALS", font); - if (underline) - chk.SetUnderline(new iTextSharp.text.Color(sysColor), 0, 0.05F, 0, -.131F, PdfContentByte.LINE_CAP_ROUND); // Relative Based upon font size - Phrase ph = new Phrase(chk); - ct.AddElement(ph); - cb.SetColorFill(new iTextSharp.text.Color(sysColor)); - ct.Go(); - if (myPageHelper.PageListLayer != null) cb.EndLayer(); - cb.RestoreState(); - } - private bool _PrintHeader = false; - public bool PrintHeader - { - get { return _PrintHeader; } - set { _PrintHeader = value; } - } - private bool CalvertPrintedSubSectTitle = false; // B2020-123 - private static List myAttributes = new List(); - private static void AddAttribute(string attr) - { - if (myAttributes.Contains(attr)) - return; - //Console.WriteLine("Attribute = \"{0}\"", attr); - myAttributes.Add(attr); - } - private void CheckAttributes(System.Collections.Hashtable attributes) - { - foreach (string attr in attributes.Keys) - { - AddAttribute(attr); - } - } - private string FormattedText - { - get - { - bool subscript = false; - //if (_MyItemInfo.ItemID == 467) - // Console.Write(""); - StringBuilder sb = new StringBuilder(); - //if (IParagraph.Chunks.Count > 1) - // Console.WriteLine("{0} Chunks", IParagraph.Chunks.Count); - foreach (Chunk chk in IParagraph.Chunks) - { - string prefix = ""; - string suffix = ""; - CheckAttributes(chk.Attributes); - if (chk.Font.BaseFont != null && chk.Font.BaseFont.PostscriptFontName.ToUpper().Contains("BOLD")) - { - prefix += "\xD5"; - suffix = "\xD6" + suffix; - } - if (chk.Attributes.ContainsKey("SUBSUPSCRIPT")) - { - float sup = (float)(chk.Attributes["SUBSUPSCRIPT"]); - if (sup > 0) - { - prefix += "\xA6"; - suffix = "\xD1" + suffix; - } - else if (sup < 0) - { - prefix += "\xD1"; - suffix = "\xA6" + suffix; - } + // If this item is in the leftmost column in table, this is determined by looking at its parent, + // its parent must be a HLS, do the vertical lines since all cells have all vertical lines. + // Lines should be drawn from current to ybottommost. Also draw the bottom line. + if (ii.MyParent.IsHigh) + { + // first do the vertical bars. + float curY = yLocation; + while (curY > (yPageStart - this.YBottomMost + lpi)) + { + for (int i = 0; i < cntVertPos; i++) + Rtf2Pdf.TextAt(cb, paraVertLine, float.Parse(vertPos[i]) + (float)ii.MyDocStyle.Layout.LeftMargin - csize, curY + 3, lWidth, 100, null, yBottomMargin); + curY -= lpi; + } + // Now do the bottom line for this item. + Paragraph crossLine = new Paragraph(bottomOfTable ? bx.BXLMID : bx.BXMID, iSymblFont); + float yloc = yPageStart - this.YBottomMost + 18; + Rtf2Pdf.TextAt(cb, leftLine, float.Parse(vertPos[0]) + (float)ii.MyDocStyle.Layout.LeftMargin - csize, yloc, lWidth, 100, null, yBottomMargin); + float hPos = float.Parse(vertPos[0]) + csize; + int doHorizCnt = 0; + while (doHorizCnt < cntVertPos - 1) + { + while (hPos < float.Parse(vertPos[doHorizCnt + 1])) + { + Rtf2Pdf.TextAt(cb, horzLine, hPos + (float)ii.MyDocStyle.Layout.LeftMargin - csize, yloc, lWidth, 100, null, yBottomMargin); + hPos += csize; + } - } - if (chk.Attributes.ContainsKey("UNDERLINE")) - { - prefix += "\x16"; - suffix = "\x16" + suffix; ; - } - sb.Append(prefix + chk.Content + suffix); - } - string retval = sb.ToString(); - retval = retval.Replace("\xD1\xA6", "");// Remove Multiple Superscript commands in a row - retval = retval.Replace("\xA6\xD1", "");// Remove Multiple Superscript commands in a row - retval = retval.Replace("\xD6\xD5", ""); - retval = retval.Replace("\xD6\x16\xD5", "\x16"); - return retval; - } - } - private float _ImageScaler = 1F; - /// - /// Scaler used to adjust the Image Size on Sup Info (Facing Pages) - /// - public float ImageScaler - { - get { return _ImageScaler; } - set { _ImageScaler = value; } - } - //private bool _TextDebug = false; //true; this will turn on a writeline with debug in DrawText() - private float DrawFigure(PdfContentByte cb, float yBottomMargin, float yLocation, float yPageStart, float yTopMargin) - { - int profileDepth = ProfileTimer.Push("vlnParagraph.DrawFigure"); - float retval = yLocation; - if (ImageText != null) - { - if (ImageText == "figure") - { - ImageConfig ic = new ImageConfig(MyItemInfo.MyContent.MyImage); - // B2016-277: add a try catch in case of there being 'bad' data in the text field for an image/figure - try - { - byte[] idata = (ic != null && ic.Image_DataSize > 0) ? ROImageInfo.Decompress(MyItemInfo.MyContent.MyImage.Data, ic.Image_DataSize) : MyItemInfo.MyContent.MyImage.Data; - MemoryStream ms = new MemoryStream(idata); - System.Drawing.Image img = System.Drawing.Image.FromStream(ms); - Width = img.Width; - Height = img.Height; - if (ic != null && ic.Image_Height != 0) - { - Width = ic.Image_Width; - Height = ic.Image_Height; - } - // B2020-115 Limit the figure size to the space available in a page. - float mult = 1.0F; - if (Width > (vlnParagraph.wMax-12)) mult = (vlnParagraph.wMax-24) / Width; - if (Height > (vlnParagraph.hMax-36)) mult = Math.Min(mult, (vlnParagraph.hMax-36) / Height); - if (mult < 1.0F) - { - Width = Width * mult; - Height = Height * mult; - } - iTextSharp.text.Image it_image = iTextSharp.text.Image.GetInstance(idata); - // B2017-241 Adjust Bottom Message Location for the figure - MyPageHelper.BottomContent = yLocation - (Height * MyPageHelper.YMultiplier); - // B2017-112 Adjust Image Size by Scaler (Used for Facing Pages - Sup Info) - retval = Rtf2Pdf.FigureAt(cb, it_image, XOffset + MyItemInfo.FormatStepData.Font.CharsToTwips, yLocation, Width * MyPageHelper.YMultiplier * ImageScaler, Height * MyPageHelper.YMultiplier * ImageScaler, DebugInfo, yBottomMargin, !MyItemInfo.FormatStepData.Type.Contains("Borderless"), MyItemInfo.ItemID, SixLinesPerInch); // C2018-004 added ItemID for create meta file for baseline compares - } - catch - { - retval += SixLinesPerInch; - } - } - else - { - string[] vals = ImageText.Split("\n".ToCharArray()); - ProcedureInfo proc = MyItemInfo.MyProcedure; - DocVersionInfo dvi = proc.ActiveParent as DocVersionInfo; - ROFstInfo rofst = dvi.DocVersionAssociations[0].MyROFst; - ROImageInfo roImage = ROImageInfo.GetByROFstID_FileName(rofst.ROFstID, vals[0]); - if (roImage == null) roImage = rofst.GetROImageByFilename(vals[0], MyItemInfo);// need code to go and get an ROImaage if it exists - if (roImage != null) - { - ROImageConfig rc = new ROImageConfig(roImage); - int size = Convert.ToInt32(rc.Image_Size); - byte[] cnt = roImage.Content; - byte[] dcnt = ROImageInfo.Decompress(cnt, size); - iTextSharp.text.Image it_image = null; - try - { - it_image = iTextSharp.text.Image.GetInstance(dcnt); - } - catch - { - MemoryStream ms = new MemoryStream(dcnt); - System.Drawing.Bitmap bm = new System.Drawing.Bitmap(ms); - using (MemoryStream ms2 = new MemoryStream()) - { - bm.Save(ms2, System.Drawing.Imaging.ImageFormat.Png); - ms2.Seek(0, SeekOrigin.Begin); - byte[] newdcnt = new byte[ms2.Length]; - ms2.Read(newdcnt, 0, (int)ms2.Length); - try - { - it_image = iTextSharp.text.Image.GetInstance(newdcnt); - } - catch (Exception ex) - { - _MyLog.Error(string.Format("{0}", roImage.FileName), ex); - return yLocation; - } - } - } - StepInfo si = (StepInfo)MyItemInfo; - StepConfig sc = new StepConfig(si.MyContent.Config); - if (sc != null && sc.Step_ImageWidth != 0) - { - Width = sc.Step_ImageWidth; - Height = sc.Step_ImageHeight; - } - // B2017-241 Adjust Bottom Message Location for the figure - MyPageHelper.BottomContent = yLocation - (Height * MyPageHelper.YMultiplier); - retval = Rtf2Pdf.FigureAt(cb, it_image, XOffset + MyItemInfo.FormatStepData.Font.CharsToTwips, yLocation, Width * MyPageHelper.YMultiplier, Height * MyPageHelper.YMultiplier, DebugInfo, yBottomMargin, !MyItemInfo.FormatStepData.Type.Contains("Borderless"), MyItemInfo.ItemID, SixLinesPerInch); - } - } - // The following code was added to fix B2016-219 (for VCS, the centerline drew through a figure). The 'top' value was taken from the code - // that draws the vlnBoxes (Caution/Note, etc) - // The adjustments, adjtop & adjbottom, were necessary to get the vertical centerline to meet up correctly with the top/bottom of the figure. These - // numbers were determined by trial and error. + // put out middle piece, i.e. + (cross) lines or bottom line + hPos = float.Parse(vertPos[doHorizCnt + 1]); + if (doHorizCnt < cntVertPos - 2) // don't put out crossLine on last one. + Rtf2Pdf.TextAt(cb, crossLine, float.Parse(vertPos[doHorizCnt + 1]) + (float)ii.MyDocStyle.Layout.LeftMargin - csize, yloc, lWidth, 100, null, yBottomMargin); + hPos += csize; + doHorizCnt++; + } + // put out the right side piece + Rtf2Pdf.TextAt(cb, rightLine, float.Parse(vertPos[cntVertPos - 1]) + (float)ii.MyDocStyle.Layout.LeftMargin - csize, yloc, lWidth, 100, null, yBottomMargin); + } + // Now handle middle parts of the table. For whatever sub level we're at, draw the cross character + // and the horizontal. This is case where the component number may have multiple descriptions,positions, etc. associated + // with it. + if (!ii.MyParent.IsHigh && ii.NextItem != null) + { + // draw horizontally from this sublevel to the end. + int sublev = 0; + ItemInfo par = this.MyItemInfo; + while (!par.IsHigh) + { + sublev++; + par = par.MyParent; + } + sublev--; + float ylocs = yPageStart - this.YBottomMost + 15; + for (int i = sublev; i < cntVertPos - 1; i++) + { + float hPos = float.Parse(vertPos[i]) + csize; + Rtf2Pdf.TextAt(cb, leftLine, float.Parse(vertPos[i]) + (float)ii.MyDocStyle.Layout.LeftMargin - csize, ylocs, lWidth, 100, null, yBottomMargin); + while (hPos < float.Parse(vertPos[i + 1])) + { + // do the horizontal line + Rtf2Pdf.TextAt(cb, horzLine, hPos + (float)ii.MyDocStyle.Layout.LeftMargin - csize, ylocs, lWidth, 100, null, yBottomMargin); + hPos += csize; + } + } + // Do the last cross character + Rtf2Pdf.TextAt(cb, rightLine, float.Parse(vertPos[cntVertPos - 1]) + (float)ii.MyDocStyle.Layout.LeftMargin - csize, ylocs, lWidth, 100, null, yBottomMargin); + } + } + Rtf2Pdf.PdfDebug = savedebug; + } + private float DrawGrid(PdfContentByte cb, float yTopMargin, float yBottomMargin, ref float yLocation) + { + //DebugText.WriteLine("{0},'{1}','{2}','<>'", MyItemInfo.ItemID, MyItemInfo.ShortPath, FormattedText); + if (DebugText.IsOpen) DebugText.WriteLine("{0},'{1}','{2}','<>',{3}", MyItemInfo.ItemID, MyItemInfo.ShortPath, MyItemInfo.MyContent.Text, XOffset); + //if (MyItemInfo.InList(11019,11024,111026)) // RHM20150507 Table Scrunch + // Console.WriteLine("here"); + float heightBefore = (MyGrid.Height + 4) * MyPageHelper.YMultiplier; // B2020-014 added parenthesis was calculating wrong for 7lpi Callaway FSG-7 Attachment 7 + // B2018-033 Account for bottom continue message when seeing if a scrunched table will fit + float ySizeBtmCtnMess = GetBottomContinueMessageSize(MyItemInfo.MyDocStyle); + // B2018-085 Ignore the bottom continue message if the Table is the last part of the step. + if (ySizeBtmCtnMess > 0 && MyParent.MyItemInfo.IsHigh && YBottomMost == MyParent.YBottomMost) ySizeBtmCtnMess = 0; + // TableScrunch Phase 1: Is height of table greater than what will fit on current page. + if (Rtf2Pdf.GetTableScrunchingStatus(TableScrunching.Phase1) && heightBefore > (yLocation - (yBottomMargin + ySizeBtmCtnMess))) + { + // TooBig is the amount of height that the grid is larger than the amount of space on the page. It is set to + // (height of grid w/ compressed setting if needed + line) - (how much room on page) + // NOTE TooBig actually will do the adjustments of the row heights by eliminating the blank space! + MyGrid.TooBig = SixLinesPerInch + MyGrid.Height * MyPageHelper.YMultiplier - (yLocation - yBottomMargin - ySizeBtmCtnMess); + float heightAfter = (MyGrid.Height + 4) * MyPageHelper.YMultiplier; // B2020-014 added parenthesis was calculating wrong for 7lpi Callaway FSG-7 Attachment 7 + MyPageHelper.TableAdjustment += (heightBefore - heightAfter); + MyPageHelper.AdjustedTable = this; // B2020-059 - save the information of the table that is being compressed (used in RTF2PDF.cs TextAt()) + MyPageHelper.AdjustedTableYtop = yLocation; // B2020-059 save the top location of the compressed table (used in RTF2PDF.cs TextAt()) + //B2018-092 Determine if the Table is too big by checking it including either 6 LPI or 7 LPI as appropriate + if (heightAfter * MyPageHelper.YMultiplier < (yLocation - yBottomMargin - ySizeBtmCtnMess)) + { + // B2018-081 - Removed error log message if the code was able to properly adjust the table + //_MyLog.WarnFormat("\r\n==> Table is too big to fit on page, Vertical Padding adjusted to fit in\r\n" + + // " [{0}] {1}\r\n" + + // " in {2}\r\n" + + // " Height Before={3:N2} Height After={4:N2} SpaceAvailable={5:N2}\r\n" + + // " No action necessary", + // MyItemInfo.ItemID,_MyItemInfo.ShortPath, + // _MyItemInfo.SearchDVPath.Replace("\a", "/"), heightBefore / 72, MyGrid.Height / 72, (yTopMargin - yBottomMargin) / 72); + //_MyLog.ErrorFormat("<<< WARNING >>> Table is too big to fit on page, Vertical Padding adjusted to fit\r\n==>'Table Adjusted',{0},'{1}','{2}',{3},{4},{5}" + // , MyItemInfo.ItemID, MyItemInfo.MyDocVersion.MyFolder.Name, MyItemInfo.ShortPath, heightBefore, MyGrid.Height, (yTopMargin - yBottomMargin)); + } + else + MyGrid.IsTooBig = true; + if (MyItemInfo.HasChangeBar && MyPageHelper.ChangeBarDefinition.MyChangeBarType != PrintChangeBar.Without) + { + foreach (vlnChangeBar vcb in MyPageHelper.MyChangeBars) + { + if (vcb.Height == heightBefore / MyPageHelper.YMultiplier - 4) + { + float heightDif = (heightBefore - heightAfter); + vcb.YChangeBarBottom += heightDif; + FixMessages(vcb, heightDif); + break; + } + } + } + } + //B2018-092 Correct the location of the bottom continue message including either 6 LPI or 7 LPI as appropriate + MyPageHelper.BottomContent = yLocation - (MyGrid.Height + 4) * MyPageHelper.YMultiplier; + float retval = Rtf2Pdf.GridAt(cb, MyGrid, XOffset, yLocation, Width, 100, DebugInfo, yBottomMargin, !MyItemInfo.FormatStepData.Type.Contains("Borderless")); + //B2018-092 Determine if the Table is too big by checking it including either 6 LPI or 7 LPI as appropriate + if ((MyGrid.Height + 4) * MyPageHelper.YMultiplier > (yLocation - yBottomMargin - ySizeBtmCtnMess)) + { + // B2018-081 Changed the Error Log Message to be more useful when a table is too big. + _MyLog.ErrorFormat("\r\n===> Table is too big to fit on page, expect pagination problems in\r\n" + + " 1> Item [{0}] {1}\r\n" + + " 2> in {2}\r\n" + + " 3> Height Before={3:N2} Height After={4:N2} SpaceAvailable={5:N2}\r\n" + + " 4> ACTION REQUIRED: Table should be restructured or split over multiple pages", + MyItemInfo.ItemID, MyItemInfo.ShortPath, + MyItemInfo.SearchDVPath.Replace("\a", "/"), heightBefore / 72, MyGrid.Height / 72, (yTopMargin - yBottomMargin) / 72); + //_MyLog.ErrorFormat("<<< ERROR >>> Table is too big to fit on page, expect pagination problems\r\n==>'Table Too Big',{0},'{1}','{2}',{3},{4},{5}" // RHM20150429 - Table Scrunch + // , MyItemInfo.ItemID, MyItemInfo.MyDocVersion.MyFolder.Name, MyItemInfo.ShortPath, heightBefore, MyGrid.Height, (yTopMargin - yBottomMargin)); + } + return retval; + } - // only add gap if centered, i.e. in 2 column mode & table is centered - if (MyItemInfo.ColumnMode > 0 && (!MyItemInfo.FormatStepData.Type.Contains("AER") && !MyItemInfo.IsInRNO)) - { - float top = CalculateYOffset(yPageStart, yTopMargin) - (7 * MyPageHelper.YMultiplier); - float adjtop = 0; - float adjbottom = 0; - if (MyPageHelper.YMultiplier == 1) - adjtop = -3; - else - adjbottom = -1; - MyPageHelper.MyGaps.Add(new Gap(top + adjtop, top - Height - Rtf2Pdf.Offset.Y + adjbottom)); - } - } - ProfileTimer.Pop(profileDepth); - return retval; - } - private string DebugInfo - { - get - { - if (!Rtf2Pdf.PdfDebug) return "No Path"; - int profileDepth = ProfileTimer.Push(">>>> vlnParagraph.DebugInfo"); - string retval = string.Format("DebugID = {0}, ID={1} Type={2} TypeName='{3}' StepLevel={4} ShortPath={5} Width={6} Left={7} YOffset={8}, PaginationLevel = {9}, yPageSize = {10}", - DebugId, MyItemInfo.ItemID, MyItemInfo.FormatStepType, MyItemInfo.FormatStepData == null ? "NoStepData" : MyItemInfo.FormatStepData.Type, MyItemInfo.StepLevel, MyItemInfo.ShortPath, Width, XOffset, YOffset, levelForPagination, yPageSizeForPagination); - ProfileTimer.Pop(profileDepth); - return retval; - } - } - private void ResetDocStyleAndValues(ref float yTopMargin, ref float yBottomMargin) - { - float _PointsPerPage = PDFPageSize.PaperSizePoints(MyItemInfo.ActiveFormat.PlantFormat.FormatData.PDFPageSize.PaperSize); // C2020-002 paper size is now set in the format files - // if this document style has another style that is for pages other than first, we need to - // reset the document style off of this section AND reset docstyle values used. - // C2018-003 fixed use of getting the active section - if (MyItemInfo.ActiveSection != null && (MyItemInfo.ActiveSection.MyDocStyle.StructureStyle.Where & E_DocStyleUse.UseOnFirstPage) > 0) - { - ItemInfo ii = (ItemInfo)MyItemInfo.ActiveSection; - int indx = (int)MyItemInfo.ActiveSection.MyDocStyle.IndexOtherThanFirstPage; - foreach (DocStyle ds in ii.ActiveFormat.PlantFormat.DocStyles.DocStyleList) - { - if (ds.Index == indx) - { - // C2018-004 create meta file for baseline compares - // B2020-008: removed some code that was causing the header to not get refreshed, and uncommented - // out the ResetSvg command below. - Volian.Base.Library.BaselineMetaFile.WriteLine("Reset DocStyle to \"{0}\"",ds.Name); - MyItemInfo.ActiveSection.MyDocStyle = ds; - MyPageHelper.MySection = MyItemInfo.ActiveSection as SectionInfo; - MyPageHelper.MySection.MyDocStyle = ds; - MyPageHelper.ResetSvg(); - break; - } - } - MyPageHelper.DidFirstPageDocStyle = true; - if (DebugPagination.IsOpen) DebugPagination.WriteLine("ResetDocStyleAndValues"); - if (BaselineMetaFile.IsOpen) BaselineMetaFile.WriteLine("!! ResetDocStyleAndValues"); //C2018-015 add debug pagination to meta file - MyPageHelper.MySection = (SectionInfo)MyItemInfo.ActiveSection; - yTopMargin = _PointsPerPage - (float)MyItemInfo.ActiveSection.MyDocStyle.Layout.TopMargin; - yBottomMargin = Math.Max(0, yTopMargin - (float)MyItemInfo.ActiveSection.MyDocStyle.Layout.PageLength); - } - // B2020-047 move check of PrintSectionPage to after the ResetSvg - // B2020-152 un-did the change for B2020-047 which was put in for Westinghouse. The issue reported for B2020-047 remained corrected - else if (MyPageHelper.PrintedSectionPage > 0) - { - MyPageHelper.ResetSvg(); - if (MyItemInfo.ActiveSection != null && (MyItemInfo.ActiveSection.MyDocStyle.StructureStyle.Style & E_DocStructStyle.DSS_PrintSectOnFirst) == E_DocStructStyle.DSS_PrintSectOnFirst) - { - yTopMargin = _PointsPerPage - (float)MyItemInfo.ActiveSection.MyDocStyle.Layout.TopMargin + MyPageHelper.PrintedSectionPage; - MyPageHelper.YTopMargin = yTopMargin; - yBottomMargin = Math.Max(0, _PointsPerPage - (float)MyItemInfo.ActiveSection.MyDocStyle.Layout.TopMargin - (float)MyItemInfo.ActiveSection.MyDocStyle.Layout.PageLength); - } - } - } - private string GetSectCombinedTab(ItemInfo tmp) - { - ItemInfo itemInfo = tmp; - if (itemInfo.IsCautionOrNotePart) itemInfo = itemInfo.ActiveParent as ItemInfo; // if caution/note get to its associated step - itemInfo = itemInfo.ActiveParent as ItemInfo; // don't want this one in the combined tab, start at parent - // B2018-084: continue message had bullets in it that didn't have correct font. The message should not have had bullets at - // all - in the following line, there was an 'if' rather than a 'while' - go up parents until find the correct step type - // don't just go up 1 level. - while (!itemInfo.IsHigh && !itemInfo.IsSequential && !itemInfo.IsSection) itemInfo = itemInfo.ActiveParent as ItemInfo; - string prTab = ""; - string thisTab = itemInfo.MyTab.CleanText.Trim(); - if (!itemInfo.IsSection || itemInfo.IsSeparateSubsection) - { - ItemInfo mypar = itemInfo.MyParent; - while (mypar != null && !mypar.IsProcedure) - { - // The following check was added for BGE/OI34. Their APPENDIX sections had the subsections - // printing with incorrect tab in the SectionTitleContinued message. Before this - // fix the tabs were A.B Procedure (Continued) rather than B. Procedure (Continued). - // Unfortunately there was not enough time to make the 'if' statement based on config - // or format settings. - bool addTab = true; - if (mypar.IsSection && mypar.DisplayNumber.ToUpper().Contains("APPENDIX ")) - { - SectionConfig sch = mypar.MyConfig as SectionConfig; - addTab = (sch == null || sch.Section_PrintHdr == "Y");// && !mypar.MyDocStyle.CancelSectTitle; - } - if (addTab) - { - string pTab = mypar.MyTab.CleanText.Trim(); - if (pTab.Length > 0 && char.IsLetterOrDigit(pTab[0])) - { - pTab = pTab.TrimEnd(" .".ToCharArray()) + "."; - prTab = pTab + prTab; - } - else - { - // There' a bullet or some other graphics character. - // clear out the tab we are building so the we can build - // a continue tab up to this bullet or graphic character. - prTab = ""; - thisTab = ""; - } - } - mypar = (mypar.IsSection && !mypar.IsSeparateSubsection) ? null : mypar.MyParent; - } - } - return (prTab + thisTab.Trim()).TrimEnd(".".ToCharArray()); - } - private static bool DoSubs = true; // flag whether to print substeps (don't if doing continued checklist header) - public float AdjustForXBlankW1stLevSub = 0; // B2020-112 this & next line - public float AdjustForMatchUpRNO = 0; - protected float _ContinueHeight = 0; - public virtual float ContinueHeight - { - get - { - int profileDepth = ProfileTimer.Push(">>>> vlnPrintObject.ContinueHeight"); - if (_ContinueHeight == 0 - && MyItemInfo.MyDocStyle.Continue.Top.Message != null - && MyItemInfo.MyDocStyle.Continue.Top.Message.Contains("%s") - && MyItemInfo.MyDocStyle.Continue.Top.Message.ToUpper().EndsWith(" (Continued)".ToUpper())) - { - string suffix = MyItemInfo.MyDocStyle.Continue.Top.Message.Replace("%sR", "").Replace("%s", ""); - _ContinueHeight = GetParagraphHeight(MyContentByte, IParagraph, suffix, Width); - } - ProfileTimer.Pop(profileDepth); - return _ContinueHeight; - } - set { _Height = value; } - } + private void FixMessages(vlnChangeBar vcb, float heightDif) + { + SortedDictionary msd = vcb.Messages; + vcb.Messages = new SortedDictionary(); + foreach (float key in msd.Keys) + { + vcb.Messages.Add(key + heightDif, msd[key]); + } + } + + [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0059:Unnecessary assignment of a value", Justification = "retval kept for Debugging")] + private float DrawText(PdfContentByte cb, ref float yPageStart, float yTopMargin, float yBottomMargin, ref float yLocation) + { + if (DebugText.IsOpen) DebugText.WriteLine("{0},'{1}','{2}','<>'", MyItemInfo.ItemID, MyItemInfo.DBSequence, FormattedText); + //Console.WriteLine("{0},{1},'{2}','<>'", MyItemInfo.ItemID, MyItemInfo.DBSequence, IParagraph.Content); + float retval = yLocation; + if (MyItemInfo.IsRtfRaw) + { + retval = Rtf2Pdf.TextAt(cb, IParagraph, XOffset, yLocation, Width, 100, DebugInfo + string.Format(",YLines = {0}", YSize / SixLinesPerInch), yBottomMargin, MyItemInfo.ItemID); // C2018-004 ItemID for create meta file for baseline compares + return retval; + } + + // Calvert Alarms have a special case, center text if the next/previous is not the same type of caution or note. + // Calvert Alarms have a note1 that is a warning. if a regular note preceeded it, this regular note was not centered. + // F2023-126: Vogtle Alarms - center single line caution/note if more than one type exist off step, added the check for NoteCautionCenterOneAllTypes + bool doAlign = false; + if ((MyItemInfo.ActiveFormat.PlantFormat.FormatData.PrintData.SpecialCaseCalvert || MyItemInfo.ActiveFormat.PlantFormat.FormatData.PrintData.NoteCautionCenterOneAllTypes) && (MyItemInfo.IsCaution || MyItemInfo.IsNote || MyItemInfo.IsNote1)) + { + bool diffAsPrev = MyItemInfo.MyPrevious == null || (MyItemInfo.MyPrevious != null && MyItemInfo.MyContent.Type != MyItemInfo.MyPrevious.MyContent.Type); + bool diffAsNext = MyItemInfo.NextItem == null || (MyItemInfo.NextItem != null && MyItemInfo.MyContent.Type != MyItemInfo.NextItem.MyContent.Type); + if (diffAsPrev && diffAsNext) doAlign = true; + } + // Check if only one line, i.e. "Height < (1.2F * IParagraph.Leading". The Leading can be for six or seven lines per inch, so the 1.2 + // multiplier accounts for both. + // B2021-091 added a null reference check - MyItemInfo was a section and didn't have FormatStepData + // F2021-042: Added FormatStepData.AlwaysCenter for BNPP1 - Critical Step text always must be centered + // B2022-146: Left Justify Note & Caution text that has sub-steps (for Beaver Valley) + bool cnWithChildren = !MyItemInfo.IsStepSection && MyItemInfo.FormatStepData != null && MyItemInfo.FormatStepData.CenterOnlyIfNoSubs && MyItemInfo.HasChildren; + if (!MyItemInfo.IsStepSection && MyItemInfo.FormatStepData != null && MyItemInfo.FormatStepData.CenterOneLineOnly && !cnWithChildren && ((MyItemInfo.MyPrevious == null && MyItemInfo.NextItem == null) + || MyItemInfo.FormatStepData.SeparateBox || doAlign || MyItemInfo.FormatStepData.AlwaysCenter) && Height < (1.2F * IParagraph.Leading)) + IParagraph.Alignment = Element.ALIGN_CENTER; + // if this step is centered, but not part of the checklist or valvelist format, use itextsharp to center it. + // if it was part of the checklist or valvelist, then the centering is based on the column definitions for the table and + // was calculated when the paragraph was made. + // B2021-091 added a null reference check - MyItemInfo was a section and didn't have FormatStepData + if (!MyItemInfo.IsStepSection && MyItemInfo.FormatStepData != null && MyItemInfo.FormatStepData.StepPrintData.Justify == "Center" && !MyItemInfo.FormatStepData.StepLayoutData.AlignWithParentTab) + IParagraph.Alignment = Element.ALIGN_CENTER; + if (PrefixSpecialCharacter && IParagraph.Chunks.Count > 0) + { + Chunk chk = IParagraph.Chunks[0] as Chunk; + if (chk.Content == " ") + { + PrefixSpecialCharacter = false; + //Console.WriteLine("Special {0}", MyItemInfo.MyHLS.DisplayText); + IParagraph.Chunks.RemoveAt(0); + } + } + // if printing checklist header, adjust ypagestart & ylocation so that won't get forced pagination (pagination is already ok) + //Console.WriteLine("'Q1',{0},'{1}',{2},{3},{4},{5},{6}", MyItemInfo.ItemID, MyItemInfo.ShortPath, yTopMargin, yPageStart, yLocation, YTopMost, YOffset); + if (PrintHeader) + { + yPageStart = yTopMargin + YVeryTop; + yLocation = yPageStart - YOffset; // yLocation is physical location from bottom of page. + } + if (yLocation - Height < 24) + { + if (DebugPagination.IsOpen) + DebugPagination.WriteLine("Very Low {0},{1},{2},{3},{4},{5}", MyItemInfo.ShortPath, MyItemInfo.ItemID, yLocation, Height, yLocation - Height, yTopMargin - MyItemInfo.MyDocStyle.Layout.PageLength); + //C2018-015 add debug pagination to meta file + if (BaselineMetaFile.IsOpen) + BaselineMetaFile.WriteLine("!! Very Low {0},{1},{2},{3},{4},{5}", MyItemInfo.ShortPath, MyItemInfo.ItemID, yLocation, Height, yLocation - Height, yTopMargin - MyItemInfo.MyDocStyle.Layout.PageLength); + } + int profileDepth = ProfileTimer.Push(">>>> Rtf2Pdf.TextAt"); + // ooooooooo. oooooooooo. oooooooooooo ooooooooooooo o8o . o8o + // `888 `Y88. `888' `Y8b `888' `8 8' 888 `8 `"' .o8 `"' + // 888 .d88' 888 888 888 888 oooo d8b .oooo. ooo. .oo. .oooo.o oooo .o888oo oooo .ooooo. ooo. .oo. .oooo.o + // 888ooo88P' 888 888 888oooo8 888 `888""8P `P )88b `888P"Y88b d88( "8 `888 888 `888 d88' `88b `888P"Y88b d88( "8 + // 888 888 888 888 " 888 888 .oP"888 888 888 `"Y88b. 888 888 888 888 888 888 888 `"Y88b. + // 888 888 d88' 888 888 888 d8( 888 888 888 o. )88b 888 888 . 888 888 888 888 888 o. )88b + // o888o o888bood8P' o888o o888o d888b `Y888""8o o888o o888o 8""888P' o888o "888" o888o `Y8bod8P' o888o o888o 8""888P' + // + // Design Suggestion: + // During vlnParagraaph Constuctor Build an end point dictionary + // During toPdf check for end points before adding GoTos for Local + // Need to have a way to get to sections which do not have any output (header only) + // Need to have a way to identify procedures + // + // B2018-034 The following code previously used IParagraph rather than _IParagraph. If the variable IsCompressed (7LPI) is true for this step + // IParagraph would be refreshed each time it was referenced. Thus the link information would be lost when the IParagraph was re-created. + // This resulted in PDFLinks to steps that were not not identified with a LocalDestination. This was changed from the original code to + // fix B2015-076 when the Byron Flex Procedure 0BFSG-6 was printed. The issue for this bug was that the underlining at 7LPI was overlaping the + // top of the next line of text. I was not able to find the case referencedd in the source safe document. However, by adding a line of + // text "One more line" to the end of step 2 in attachment C, I was able to see the effect. + if (_IParagraph.Chunks.Count > 0 && MyPageHelper.MyPromsPrinter.SaveLinks) + { + // B2018-034 The following code previously used IParagraph rather than _IParagraph. See first Comment + Chunk chk1 = _IParagraph.Chunks[0] as Chunk; + if (MyItemInfo.MyContent.Text.ToUpper().Contains("LINK:TR") && MyItemInfo.MyContent.ContentTransitionCount == 0) + Console.WriteLine("Missing Transition {0}", MyItemInfo.ItemID); + chk1.SetLocalDestination(string.Format("ItemID={0}", MyItemInfo.ItemID)); // Destination + // B2019-052: If multiple ROs/Transitions within a step, each should have a their own link rather than all linking to same thing. + // Note the pdf link code that was here was moved to Rtf2iTextSharp.cs in DoVisitText so that each 'chunk' could have a link. + // The code that remained here was the code that marks the destination for each step & the code that does the pdf links for + // enhanced steps. + // Also, the method GetDefaultItemInfo was moved to Rtf2iTextSharp.cs also - it was only called from code that was moved. + + StepConfig sc = new StepConfig(MyItemInfo.MyContent.Config); + DVEnhancedDocuments dveds = MyItemInfo.MyDocVersion.DocVersionConfig.MyEnhancedDocuments; + foreach (EnhancedDocument ed in sc.MyEnhancedDocuments) + { + DVEnhancedDocument dved = dveds.GetByType(ed.Type); + AddLinkToEnhancedDocument(cb, yLocation, ed.ItemID, dved.PdfToken, dved.PdfX); + } + } + MyPageHelper.BottomContent = yLocation - (Height * MyPageHelper.YMultiplier); + retval = Rtf2Pdf.TextAt(cb, IParagraph, XOffset, yLocation, Width, 100, DebugInfo + string.Format(",YLines = {0}", YSize / SixLinesPerInch), yBottomMargin, MyItemInfo.ItemID); // C2018-004 ItemID for create meta file for baseline compares + ProfileTimer.Pop(profileDepth); + if (retval == 0) // problem occurred - paragraph was not able to be printed on page + { // pagination logic needs to be fixed. + // oooooooooooo ooooooooo. o8o . o8o + // `888' `8 `888 `Y88. `"' .o8 `"' + // 888 .ooooo. oooo d8b .ooooo. .ooooo. 888 .d88' .oooo. .oooooooo oooo ooo. .oo. .oooo. .o888oo oooo .ooooo. ooo. .oo. + // 888oooo8 d88' `88b `888""8P d88' `"Y8 d88' `88b 888ooo88P' `P )88b 888' `88b `888 `888P"Y88b `P )88b 888 `888 d88' `88b `888P"Y88b + // 888 " 888 888 888 888 888ooo888 888 .oP"888 888 888 888 888 888 .oP"888 888 888 888 888 888 888 + // 888 888 888 888 888 .o8 888 .o 888 d8( 888 `88bod8P' 888 888 888 d8( 888 888 . 888 888 888 888 888 + // o888o `Y8bod8P' d888b `Y8bod8P' `Y8bod8P' o888o `Y888""8o `8oooooo. o888o o888o o888o `Y888""8o "888" o888o `Y8bod8P' o888o o888o + // d" YD + // "Y88888P' + ForcePagination(cb, ref yPageStart, yTopMargin, yBottomMargin, ref yLocation, ref retval); + } + else + { + if (MyItemInfo.IsStepSection && MyItemInfo.ActiveFormat.PlantFormat.FormatData.PrintData.SpecialCaseCalvert && (MyItemInfo.ActiveSection as SectionInfo).HasInitials) + { + if (MyPageHelper.PrintInitials(cb, yLocation, (float)MyItemInfo.MyDocStyle.Layout.LeftMargin)) + { + //if(yLocation != yTopMargin) + // Console.WriteLine("'{0}',{1},'{2}',{3},{4},{5},{6}", MyItemInfo.MyProcedure.DisplayNumber, MyItemInfo.ItemID + // , MyItemInfo.DisplayNumber, yLocation,yTopMargin,MyItemInfo.HasCautionOrNote,MyPageHelper.CurrentPageNumber+1); + } + } + } + return retval; + } + private static void AddLinkToEnhancedDocument(PdfContentByte cb, float yLocation, int itemID, String token, int xLocation) + { + ItemInfo ii = ItemInfo.Get(itemID); + //B2020-133 if "ii" is null, then the itemid was not found- probable enhanced step was deleted. so just return with out creating a link + if (ii == null) return; + string prefix = ii.MyDocVersion.DocVersionConfig.Print_PDFFilePrefix ?? ""; + string suffix = ii.MyDocVersion.DocVersionConfig.Print_PDFFileSuffix ?? ""; + ColumnText ct = new ColumnText(cb); + ct.SetSimpleColumn(xLocation, yLocation - 12, xLocation + 30, 12 + yLocation); + Chunk chk = new Chunk(token); + chk.SetRemoteGoto($"{prefix}{ii.MyProcedure.DisplayNumber.Replace("/", "_")}{suffix}.pdf", string.Format("ItemID={0}", itemID)); + chk.SetBackground(new Color(System.Drawing.Color.LemonChiffon)); + ct.AddElement(chk); + cb.SetColorFill(Color.BLUE); + ct.Go(); + + } + + public static bool MissingInitials { get; set; } = false; + public static void TextAt(PdfContentByte cb, VlnSvgPageHelper myPageHelper, PageItem pi, float yloc, float leftMargin) + { + System.Drawing.Color sysColor = PrintOverride.OverrideSvgColor(System.Drawing.Color.Black); + cb.SaveState(); + if (myPageHelper.PageListLayer != null) cb.BeginLayer(myPageHelper.PageListLayer); + ColumnText ct = new ColumnText(cb); + iTextSharp.text.Font font; + bool underline = false; + if (pi == null) // The header for the signoffs is missing in the current section format. + // An Example can currently be found in Calvert OI-34 + { + if (!MissingInitials) // Only show this once. + { + _MyLog.WarnFormat("Initials Header Missing" + + "\r\nInitials header missing for section {0}" + + "\r\nfrom format [{1}], {2}, subformat {3}" + + "\r\nA default Arial font and a default location will be used." + + "\r\nPerhaps another section format should be used.", + myPageHelper.MySection.ShortPath, + myPageHelper.MySection.ActiveFormat.Name, + myPageHelper.MySection.ActiveFormat.Description, + myPageHelper.MySection.MyDocStyle.Name); + MissingInitials = true; + } + ct.SetSimpleColumn(450 + leftMargin, yloc + 6.9F, 550 + leftMargin, yloc - 50); + font = FontFactory.GetFont("Arial", BaseFont.IDENTITY_H, BaseFont.EMBEDDED, 10F); + } + else + { + ct.SetSimpleColumn((float)pi.Col + leftMargin, yloc + 6.9F, (float)pi.Col + 100 + leftMargin, yloc - 50); + int fontStyle = (pi.Font.WindowsFont.Bold ? iTextSharp.text.Font.BOLD : 0) + (pi.Font.WindowsFont.Italic ? iTextSharp.text.Font.ITALIC : 0); + font = FontFactory.GetFont(pi.Font.Family, BaseFont.IDENTITY_H, BaseFont.EMBEDDED, (float)pi.Font.Size, fontStyle); + underline = pi.Font.WindowsFont.Underline; + } + Chunk chk = new Chunk("INITIALS", font); + if (underline) + chk.SetUnderline(new iTextSharp.text.Color(sysColor), 0, 0.05F, 0, -.131F, PdfContentByte.LINE_CAP_ROUND); // Relative Based upon font size + Phrase ph = new Phrase(chk); + ct.AddElement(ph); + cb.SetColorFill(new iTextSharp.text.Color(sysColor)); + ct.Go(); + if (myPageHelper.PageListLayer != null) cb.EndLayer(); + cb.RestoreState(); + } + + public bool PrintHeader { get; set; } = false; + private bool CalvertPrintedSubSectTitle = false; // B2020-123 + [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0044:Add readonly modifier", Justification = "Keeping Collections Not ReadOnly")] + private static List myAttributes = new List(); + private static void AddAttribute(string attr) + { + if (myAttributes.Contains(attr)) + return; + //Console.WriteLine("Attribute = \"{0}\"", attr); + myAttributes.Add(attr); + } + private void CheckAttributes(System.Collections.Hashtable attributes) + { + foreach (string attr in attributes.Keys) + { + AddAttribute(attr); + } + } + private string FormattedText + { + get + { + StringBuilder sb = new StringBuilder(); + //if (IParagraph.Chunks.Count > 1) + // Console.WriteLine("{0} Chunks", IParagraph.Chunks.Count); + foreach (Chunk chk in IParagraph.Chunks) + { + string prefix = ""; + string suffix = ""; + CheckAttributes(chk.Attributes); + if (chk.Font.BaseFont != null && chk.Font.BaseFont.PostscriptFontName.ToUpper().Contains("BOLD")) + { + prefix += "\xD5"; + suffix = "\xD6" + suffix; + } + if (chk.Attributes.ContainsKey("SUBSUPSCRIPT")) + { + float sup = (float)(chk.Attributes["SUBSUPSCRIPT"]); + if (sup > 0) + { + prefix += "\xA6"; + suffix = "\xD1" + suffix; + } + else if (sup < 0) + { + prefix += "\xD1"; + suffix = "\xA6" + suffix; + } + + } + if (chk.Attributes.ContainsKey("UNDERLINE")) + { + prefix += "\x16"; + suffix = "\x16" + suffix; ; + } + sb.Append(prefix + chk.Content + suffix); + } + string retval = sb.ToString(); + retval = retval.Replace("\xD1\xA6", "");// Remove Multiple Superscript commands in a row + retval = retval.Replace("\xA6\xD1", "");// Remove Multiple Superscript commands in a row + retval = retval.Replace("\xD6\xD5", ""); + retval = retval.Replace("\xD6\x16\xD5", "\x16"); + return retval; + } + } + + /// + /// Scaler used to adjust the Image Size on Sup Info (Facing Pages) + /// + public float ImageScaler { get; set; } = 1F; + //private bool _TextDebug = false; //true; this will turn on a writeline with debug in DrawText() + private float DrawFigure(PdfContentByte cb, float yLocation, float yPageStart, float yTopMargin) + { + int profileDepth = ProfileTimer.Push("vlnParagraph.DrawFigure"); + float retval = yLocation; + if (ImageText != null) + { + if (ImageText == "figure") + { + ImageConfig ic = new ImageConfig(MyItemInfo.MyContent.MyImage); + // B2016-277: add a try catch in case of there being 'bad' data in the text field for an image/figure + try + { + byte[] idata = (ic != null && ic.Image_DataSize > 0) ? ROImageInfo.Decompress(MyItemInfo.MyContent.MyImage.Data, ic.Image_DataSize) : MyItemInfo.MyContent.MyImage.Data; + MemoryStream ms = new MemoryStream(idata); + System.Drawing.Image img = System.Drawing.Image.FromStream(ms); + Width = img.Width; + Height = img.Height; + if (ic != null && ic.Image_Height != 0) + { + Width = ic.Image_Width; + Height = ic.Image_Height; + } + // B2020-115 Limit the figure size to the space available in a page. + float mult = 1.0F; + if (Width > (vlnParagraph.wMax - 12)) mult = (vlnParagraph.wMax - 24) / Width; + if (Height > (vlnParagraph.hMax - 36)) mult = Math.Min(mult, (vlnParagraph.hMax - 36) / Height); + if (mult < 1.0F) + { + Width *= mult; + Height *= mult; + } + iTextSharp.text.Image it_image = iTextSharp.text.Image.GetInstance(idata); + // B2017-241 Adjust Bottom Message Location for the figure + MyPageHelper.BottomContent = yLocation - (Height * MyPageHelper.YMultiplier); + // B2017-112 Adjust Image Size by Scaler (Used for Facing Pages - Sup Info) + retval = Rtf2Pdf.FigureAt(cb, it_image, XOffset + MyItemInfo.FormatStepData.Font.CharsToTwips, yLocation, Width * MyPageHelper.YMultiplier * ImageScaler, Height * MyPageHelper.YMultiplier * ImageScaler, DebugInfo, !MyItemInfo.FormatStepData.Type.Contains("Borderless"), MyItemInfo.ItemID, SixLinesPerInch); // C2018-004 added ItemID for create meta file for baseline compares + } + catch + { + retval += SixLinesPerInch; + } + } + else + { + string[] vals = ImageText.Split("\n".ToCharArray()); + ProcedureInfo proc = MyItemInfo.MyProcedure; + DocVersionInfo dvi = proc.ActiveParent as DocVersionInfo; + ROFstInfo rofst = dvi.DocVersionAssociations[0].MyROFst; + ROImageInfo roImage = ROImageInfo.GetByROFstID_FileName(rofst.ROFstID, vals[0]) ?? rofst.GetROImageByFilename(vals[0], MyItemInfo); + if (roImage != null) + { + ROImageConfig rc = new ROImageConfig(roImage); + int size = Convert.ToInt32(rc.Image_Size); + byte[] cnt = roImage.Content; + byte[] dcnt = ROImageInfo.Decompress(cnt, size); + iTextSharp.text.Image it_image = null; + try + { + it_image = iTextSharp.text.Image.GetInstance(dcnt); + } + catch + { + MemoryStream ms = new MemoryStream(dcnt); + System.Drawing.Bitmap bm = new System.Drawing.Bitmap(ms); + using (MemoryStream ms2 = new MemoryStream()) + { + bm.Save(ms2, System.Drawing.Imaging.ImageFormat.Png); + ms2.Seek(0, SeekOrigin.Begin); + byte[] newdcnt = new byte[ms2.Length]; + ms2.Read(newdcnt, 0, (int)ms2.Length); + try + { + it_image = iTextSharp.text.Image.GetInstance(newdcnt); + } + catch (Exception ex) + { + _MyLog.Error(string.Format("{0}", roImage.FileName), ex); + return yLocation; + } + } + } + StepInfo si = (StepInfo)MyItemInfo; + StepConfig sc = new StepConfig(si.MyContent.Config); + if (sc != null && sc.Step_ImageWidth != 0) + { + Width = sc.Step_ImageWidth; + Height = sc.Step_ImageHeight; + } + // B2017-241 Adjust Bottom Message Location for the figure + MyPageHelper.BottomContent = yLocation - (Height * MyPageHelper.YMultiplier); + retval = Rtf2Pdf.FigureAt(cb, it_image, XOffset + MyItemInfo.FormatStepData.Font.CharsToTwips, yLocation, Width * MyPageHelper.YMultiplier, Height * MyPageHelper.YMultiplier, DebugInfo, !MyItemInfo.FormatStepData.Type.Contains("Borderless"), MyItemInfo.ItemID, SixLinesPerInch); + } + } + // The following code was added to fix B2016-219 (for VCS, the centerline drew through a figure). The 'top' value was taken from the code + // that draws the vlnBoxes (Caution/Note, etc) + // The adjustments, adjtop & adjbottom, were necessary to get the vertical centerline to meet up correctly with the top/bottom of the figure. These + // numbers were determined by trial and error. + + // only add gap if centered, i.e. in 2 column mode & table is centered + if (MyItemInfo.ColumnMode > 0 && (!MyItemInfo.FormatStepData.Type.Contains("AER") && !MyItemInfo.IsInRNO)) + { + float top = CalculateYOffset(yPageStart, yTopMargin) - (7 * MyPageHelper.YMultiplier); + float adjtop = 0; + float adjbottom = 0; + if (MyPageHelper.YMultiplier == 1) + adjtop = -3; + else + adjbottom = -1; + MyPageHelper.MyGaps.Add(new Gap(top + adjtop, top - Height - Rtf2Pdf.Offset.Y + adjbottom)); + } + } + ProfileTimer.Pop(profileDepth); + return retval; + } + private string DebugInfo + { + get + { + if (!Rtf2Pdf.PdfDebug) return "No Path"; + int profileDepth = ProfileTimer.Push(">>>> vlnParagraph.DebugInfo"); + string retval = string.Format("DebugID = {0}, ID={1} Type={2} TypeName='{3}' StepLevel={4} ShortPath={5} Width={6} Left={7} YOffset={8}, PaginationLevel = {9}, yPageSize = {10}", + DebugId, MyItemInfo.ItemID, MyItemInfo.FormatStepType, MyItemInfo.FormatStepData == null ? "NoStepData" : MyItemInfo.FormatStepData.Type, MyItemInfo.StepLevel, MyItemInfo.ShortPath, Width, XOffset, YOffset, levelForPagination, yPageSizeForPagination); + ProfileTimer.Pop(profileDepth); + return retval; + } + } + private void ResetDocStyleAndValues(ref float yTopMargin, ref float yBottomMargin) + { + float _PointsPerPage = PDFPageSize.PaperSizePoints(MyItemInfo.ActiveFormat.PlantFormat.FormatData.PDFPageSize.PaperSize); // C2020-002 paper size is now set in the format files + // if this document style has another style that is for pages other than first, we need to + // reset the document style off of this section AND reset docstyle values used. + // C2018-003 fixed use of getting the active section + if (MyItemInfo.ActiveSection != null && (MyItemInfo.ActiveSection.MyDocStyle.StructureStyle.Where & E_DocStyleUse.UseOnFirstPage) > 0) + { + ItemInfo ii = (ItemInfo)MyItemInfo.ActiveSection; + int indx = (int)MyItemInfo.ActiveSection.MyDocStyle.IndexOtherThanFirstPage; + foreach (DocStyle ds in ii.ActiveFormat.PlantFormat.DocStyles.DocStyleList) + { + if (ds.Index == indx) + { + // C2018-004 create meta file for baseline compares + // B2020-008: removed some code that was causing the header to not get refreshed, and uncommented + // out the ResetSvg command below. + Volian.Base.Library.BaselineMetaFile.WriteLine("Reset DocStyle to \"{0}\"", ds.Name); + MyItemInfo.ActiveSection.MyDocStyle = ds; + MyPageHelper.MySection = MyItemInfo.ActiveSection as SectionInfo; + MyPageHelper.MySection.MyDocStyle = ds; + MyPageHelper.ResetSvg(); + break; + } + } + MyPageHelper.DidFirstPageDocStyle = true; + if (DebugPagination.IsOpen) DebugPagination.WriteLine("ResetDocStyleAndValues"); + if (BaselineMetaFile.IsOpen) BaselineMetaFile.WriteLine("!! ResetDocStyleAndValues"); //C2018-015 add debug pagination to meta file + MyPageHelper.MySection = (SectionInfo)MyItemInfo.ActiveSection; + yTopMargin = _PointsPerPage - (float)MyItemInfo.ActiveSection.MyDocStyle.Layout.TopMargin; + yBottomMargin = Math.Max(0, yTopMargin - (float)MyItemInfo.ActiveSection.MyDocStyle.Layout.PageLength); + } + // B2020-047 move check of PrintSectionPage to after the ResetSvg + // B2020-152 un-did the change for B2020-047 which was put in for Westinghouse. The issue reported for B2020-047 remained corrected + else if (MyPageHelper.PrintedSectionPage > 0) + { + MyPageHelper.ResetSvg(); + if (MyItemInfo.ActiveSection != null && (MyItemInfo.ActiveSection.MyDocStyle.StructureStyle.Style & E_DocStructStyle.DSS_PrintSectOnFirst) == E_DocStructStyle.DSS_PrintSectOnFirst) + { + yTopMargin = _PointsPerPage - (float)MyItemInfo.ActiveSection.MyDocStyle.Layout.TopMargin + MyPageHelper.PrintedSectionPage; + MyPageHelper.YTopMargin = yTopMargin; + yBottomMargin = Math.Max(0, _PointsPerPage - (float)MyItemInfo.ActiveSection.MyDocStyle.Layout.TopMargin - (float)MyItemInfo.ActiveSection.MyDocStyle.Layout.PageLength); + } + } + } + private string GetSectCombinedTab(ItemInfo tmp) + { + ItemInfo itemInfo = tmp; + if (itemInfo.IsCautionOrNotePart) itemInfo = itemInfo.ActiveParent as ItemInfo; // if caution/note get to its associated step + itemInfo = itemInfo.ActiveParent as ItemInfo; // don't want this one in the combined tab, start at parent + // B2018-084: continue message had bullets in it that didn't have correct font. The message should not have had bullets at + // all - in the following line, there was an 'if' rather than a 'while' - go up parents until find the correct step type + // don't just go up 1 level. + while (!itemInfo.IsHigh && !itemInfo.IsSequential && !itemInfo.IsSection) itemInfo = itemInfo.ActiveParent as ItemInfo; + string prTab = ""; + string thisTab = itemInfo.MyTab.CleanText.Trim(); + if (!itemInfo.IsSection || itemInfo.IsSeparateSubsection) + { + ItemInfo mypar = itemInfo.MyParent; + while (mypar != null && !mypar.IsProcedure) + { + // The following check was added for BGE/OI34. Their APPENDIX sections had the subsections + // printing with incorrect tab in the SectionTitleContinued message. Before this + // fix the tabs were A.B Procedure (Continued) rather than B. Procedure (Continued). + // Unfortunately there was not enough time to make the 'if' statement based on config + // or format settings. + bool addTab = true; + if (mypar.IsSection && mypar.DisplayNumber.ToUpper().Contains("APPENDIX ")) + { + addTab = (!(mypar.MyConfig is SectionConfig sch) || sch.Section_PrintHdr == "Y");// && !mypar.MyDocStyle.CancelSectTitle; + } + if (addTab) + { + string pTab = mypar.MyTab.CleanText.Trim(); + if (pTab.Length > 0 && char.IsLetterOrDigit(pTab[0])) + { + pTab = $"{pTab.TrimEnd(" .".ToCharArray())}."; + prTab = pTab + prTab; + } + else + { + // There' a bullet or some other graphics character. + // clear out the tab we are building so the we can build + // a continue tab up to this bullet or graphic character. + prTab = ""; + thisTab = ""; + } + } + mypar = (mypar.IsSection && !mypar.IsSeparateSubsection) ? null : mypar.MyParent; + } + } + return (prTab + thisTab.Trim()).TrimEnd(".".ToCharArray()); + } + private static bool DoSubs = true; // flag whether to print substeps (don't if doing continued checklist header) + public float AdjustForXBlankW1stLevSub = 0; // B2020-112 this & next line + public float AdjustForMatchUpRNO = 0; + protected float _ContinueHeight = 0; + public virtual float ContinueHeight + { + get + { + int profileDepth = ProfileTimer.Push(">>>> vlnPrintObject.ContinueHeight"); + if (_ContinueHeight == 0 + && MyItemInfo.MyDocStyle.Continue.Top.Message != null + && MyItemInfo.MyDocStyle.Continue.Top.Message.Contains("%s") + && MyItemInfo.MyDocStyle.Continue.Top.Message.ToUpper().EndsWith(" (Continued)".ToUpper())) + { + string suffix = MyItemInfo.MyDocStyle.Continue.Top.Message.Replace("%sR", "").Replace("%s", ""); + _ContinueHeight = GetParagraphHeight(MyContentByte, IParagraph, suffix, Width); + } + ProfileTimer.Pop(profileDepth); + return _ContinueHeight; + } + set { _Height = value; } + } // Check if the parent section has both an editable steps section and a sub-section private bool ParentHasSectionAndSteps() { @@ -1581,5779 +1487,5454 @@ namespace Volian.Print.Library SectionInfo parent = MyItemInfo.ActiveParent as SectionInfo; bool hasSteps = false; bool hasSections = false; - foreach(PartInfo pi in parent.MyContent.ContentParts) + foreach (PartInfo pi in parent.MyContent.ContentParts) { if (pi.FromType == (int)E_FromType.Step && parent.SectionConfig.SubSection_Edit == "Y") hasSteps = true; if (pi.FromType == (int)E_FromType.Section) hasSections = true; } return hasSteps && hasSections; } - public override float ToPdf(PdfContentByte cb, float yPageStart, ref float yTopMargin, ref float yBottomMargin) - { - int profileDepth = ProfileTimer.Push(">>>> vlnParagraph.ToPdf"); + [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0059:Unnecessary assignment of a value", Justification = "yLocation and yPageStart kept for Debugging")] + public override float ToPdf(PdfContentByte cb, float yPageStart, ref float yTopMargin, ref float yBottomMargin) + { + int profileDepth = ProfileTimer.Push(">>>> vlnParagraph.ToPdf"); if (MyItemInfo.ActiveFormat.Name.ToUpper().StartsWith("FNP") && MyItemInfo.IsSection && ParentHasSectionAndSteps()) MyPageHelper.BottomMessage.Clear(); // B2017-266 reset the END message on the sub-section - if (MyItemInfo.IsFootnote && Processed) - { - ProfileTimer.Pop(profileDepth); - return yPageStart; - } - if (MyItemInfo.IsInSupInfo) // if generating the pdf for supinfos (facing page) pdf, need a different cb to go to that file. - { - MyContentByte = cb; - MyPageHelper = null; - } - bool doThreeContinues = false; - // For BGE, the very first subsection's pagelist items were not correct - the section/meta section titles were - // at the wrong level. Reset the page helper's section. - if (MyItemInfo.IsStepSection) - { - if (MyItemInfo.IsSection && MyItemInfo.MyPrevious == null && MyItemInfo.MyParent.IsSection && !MyItemInfo.ActiveFormat.PlantFormat.FormatData.PrintData.SpecialCaseWestinghouse) - { - // don't do the following for the WCN training format: - // if parent was continuous & this is separate, don't reset document style to subsection (next page) type - // this was putting incorrect pagelist item on parent section's page. This occurred in BGE/OI3 set/OI-7 procedure/10.0 Attachments. + if (MyItemInfo.IsFootnote && Processed) + { + ProfileTimer.Pop(profileDepth); + return yPageStart; + } + if (MyItemInfo.IsInSupInfo) // if generating the pdf for supinfos (facing page) pdf, need a different cb to go to that file. + { + MyContentByte = cb; + MyPageHelper = null; + } + bool doThreeContinues = false; + // For BGE, the very first subsection's pagelist items were not correct - the section/meta section titles were + // at the wrong level. Reset the page helper's section. + if (MyItemInfo.IsStepSection) + { + if (MyItemInfo.IsSection && MyItemInfo.MyPrevious == null && MyItemInfo.MyParent.IsSection && !MyItemInfo.ActiveFormat.PlantFormat.FormatData.PrintData.SpecialCaseWestinghouse) + { + // don't do the following for the WCN training format: + // if parent was continuous & this is separate, don't reset document style to subsection (next page) type + // this was putting incorrect pagelist item on parent section's page. This occurred in BGE/OI3 set/OI-7 procedure/10.0 Attachments. // B2017-273 added a check for Farley format, we don't want the subsection pagelist infor to appear on the parent section page - works with Paginate() logic - (section has steps and a sub-section ex: FNP-2-EEP-0 Attachment 4) if (!MyItemInfo.ActiveFormat.PlantFormat.FormatData.PrintData.WCNTraining && !MyItemInfo.ActiveFormat.Name.ToUpper().StartsWith("FNP") && (MyParent.MyItemInfo as SectionInfo).IsSeparatePagination() || !(MyItemInfo as SectionInfo).IsSeparatePagination()) - { - MyPageHelper.MySection = MyItemInfo as SectionInfo; - MyPageHelper.ResetSvg(); - } - } - } - // For Calvert Alarms: A macro exists around the CONDITION/RESPONSE portion. If the page break occurs so that - // this 'table' moved to the following page AND there is an associated note/caution that is not on the next page, - // remove the macro so that the header macro doesn't print on the page with the note (without this, an extraneous - // header for the 'table'is printed. - if (PartsLeft.Count != 0 && (PartsLeft[0] is vlnMacro) && MyPageHelper.ParaBreaks.Count != 0 && MyPageHelper.ParaBreaks[0].MyItemInfo.MyPrevious == null) - if (!MyPageHelper.ParaBreaks[0].MyItemInfo.IsNote && !MyPageHelper.ParaBreaks[0].MyItemInfo.IsCaution) - { - // Only clear the header if it is the first child below - if (ChildrenBelow[0].MyItemInfo.ItemID == MyPageHelper.ParaBreaks[0].MyItemInfo.ItemID) - PartsLeft.Clear(); - //else - // _MyLog.WarnFormat("Would Have Cleared PageHeader '{0}','{1}'", MyItemInfo.MyProcedure.DisplayNumber, MyItemInfo.MyHLS.DisplayText); - } - if (IsWordDocPara) - { - SectionInfo si = SectionInfo.Get(MyItemInfo.ItemID); - //Changing this caused Header issues for FNP FNP-1-FRP-1.3 Attachment 3 (Word Sub-Sections) - //SectionInfo si1 = MyItemInfo.GetSectionInfo(); - //CompareSectionInfo(si, si1); - MyPromsPrinter.NewPage(true); - //_MyLog.InfoFormat("NewPage 9 {0}", cb.PdfWriter.CurrentPageNumber); - // Add Bookmark for Word Subsections - MyPageHelper.PageBookmarks.Add(si, ((si.DisplayNumber ?? "") == "" ? "" : si.DisplayNumber + " - ") + si.DisplayText, null); - MyPageHelper.MyPromsPrinter.CreateWordDocPdf(cb, si); - Processed = true; - { - ProfileTimer.Pop(profileDepth); - return yPageStart; - } - } - float yLocalypagestart = yPageStart; - // yPageStart is offset into roll; YTopMost is offset of topmost of this paragraph. - float yLocation = yPageStart - YTopMost; - - // If this document style has a pagelist item with a continue (some IP2BCK docstyles), clear - // out the variable that flags a continue message - MyPageHelper.OldTemplateContMsg = false; - - if (DebugText.IsOpen) DebugText.WriteLine("ToPdf1:{0},'{1}',{2},{3},{4},{5}", MyItemInfo.ItemID, MyItemInfo.ShortPath, XOffset, yLocation, yPageStart, YTopMost); - int profileDepth1 = ProfileTimer.Push(">>>> vlnParagraph.Paginate"); - int paginate = Paginate(yLocation, yTopMargin, yBottomMargin); - ProfileTimer.Pop(profileDepth1); - bool firstHighLevelStep = MyItemInfo.IsHigh && (MyItemInfo.MyPrevious == null); - bool doSectionTitleContinued = false; // will add " Continued" to the section title if format flag is set - DocStyle docstyle = null; - // If SAMG facing page print & doing first pass to generate page break list of supplemental info and - // there was a page break in the step section, but not an associated supinfo item, do the page break when the - // next supinfo item is found: - SectionInfo supInfoSect = MyItemInfo.ActiveSection as SectionInfo; // C2018-003 fixed use of getting the active section - if (MyPromsPrinter.SupInfoPrintType == E_SupInfoPrintType.DoPageBreaks && MyPromsPrinter.NeedSupInfoBreak && MyItemInfo.SupInfos != null && MyItemInfo.SupInfos.Count > 0) - { - // if this has a caution/note with supinfo, that is id that needs to go in pagination list, unless it is in there. - int aboveSupinfoId = ChildrenAboveHaveSupInfo(); - if (supInfoSect != null) - { - if (supInfoSect.StepSectPageBreaksForSupInfo.Contains(aboveSupinfoId)) aboveSupinfoId = -1; - supInfoSect.StepSectPageBreaksForSupInfo.Add(aboveSupinfoId != -1 ? aboveSupinfoId : MyItemInfo.SupInfos[0].ItemID); - } - MyPromsPrinter.NeedSupInfoBreak = false; - } - bool itemIsPrinted = false; - switch (paginate) - { - // .oooooo. .oooo. - // d8P' `Y8b d8P'`Y8b - // 888 .oooo. .oooo.o .ooooo. 888 888 - // 888 `P )88b d88( "8 d88' `88b 888 888 - // 888 .oP"888 `"Y88b. 888ooo888 888 888 - // `88b ooo d8( 888 o. )88b 888 .o `88b d88' - // `Y8bood8P' `Y888""8o 8""888P' `Y8bod8P' `Y8bd8P' - case 0: // No page break - if (MyItemInfo.IsSection) - { - SectionInfo si = MyItemInfo as SectionInfo; - MyPageHelper.PageBookmarks.Add(MyItemInfo, ((si.DisplayNumber ?? "") == "" ? "" : si.DisplayNumber + " - ") + si.DisplayText, null); - DoCheckOffHeader(cb, MyItemInfo, yLocation, yTopMargin, yPageStart); - } - // SupInfo has its own pagination and ylocation handling, reset ypagestart & ylocation if continuing on current page. - // The value used was saved when the previous SupInfo step was printed. - if (MyItemInfo.IsSupInfoPart) - { - yPageStart = _yPageStartForSupInfo - SixLinesPerInch; - yLocation = yPageStart - YTopMost; - } - if (MyPromsPrinter.SupInfoPrintType == E_SupInfoPrintType.Merge) - { - // printing a procedure with section(s) that have supplemental information - determine facing page needed to be merged in. For - // case 0, it is typically at the beginning of the section since the page break occurred in the code that calls this. - // Note that if the procedure has any sections with supinfo, then the entire procedure will need facing pages, either blank page - // or supinfo steps. - // If the section title is printed, then need to get the facing page before the section title is printed and if - // this is the hls where the section title was printed, don't do the facing page. - bool titlePrinted = false; - if (MyItemInfo.IsSection || (MyItemInfo.IsHigh && MyItemInfo.MyPrevious == null)) - { - // see if the section title is printed. - SectionConfig sch = MyItemInfo.ActiveSection.MyConfig as SectionConfig; - titlePrinted = (sch == null || sch.Section_PrintHdr == "Y") || !(MyItemInfo.MyActiveSection as SectionInfo).HasSupInfoSteps; - titlePrinted &= (ShowSectionTitles && !MyItemInfo.MyDocStyle.CancelSectTitle); - } - // If this is first step section and there is no supinfo, the blank page was done in proms printer. - // If this is first step section and there is supinfo, it needs to be put out - bool notFirstOrFirstHasSupInfo = false; - bool firstSec = true; - foreach (SectionInfo sec in MyItemInfo.MyProcedure.Sections) - { - if (sec.IsStepSection) - { - if (MyItemInfo.ActiveSection != null && sec.ItemID == MyItemInfo.ActiveSection.ItemID) break; // C2018-003 fixed use of getting the active section - firstSec = false; - break; - } - } - notFirstOrFirstHasSupInfo = !firstSec || (MyItemInfo.ActiveSection != null && (MyItemInfo.ActiveSection as SectionInfo).HasSupInfoSteps); // C2018-003 fixed use of getting the active section - if (notFirstOrFirstHasSupInfo && ((MyItemInfo.IsHigh && MyItemInfo.MyPrevious == null && !titlePrinted) || (MyItemInfo.IsStepSection && titlePrinted)) && !MyItemInfo.IsInSupInfo && (MyItemInfo.MyProcedure as ProcedureInfo).ProcHasSupInfoData) - { - // If there is supplemental information to be printed on the facing page, then get the id that has supinfo - // so that it can be retrieved from the pdf for the supinfos for this section. - int sid = GetIdThatHasSupInfoItems(MyItemInfo, MyItemInfo.ItemID); - if (sid != -1) - { - MyPromsPrinter.DoSupInfoPage(cb, "TEMP", MyPageHelper.TextLayer, MyPageHelper, sid, true); - } - else - { - MyPromsPrinter.InsertBlankPage(cb); - } - } - } - if (MyItemInfo.IsHigh && MyItemInfo.MyPrevious != null && ((MyItemInfo.MyDocStyle.StructureStyle.Style & E_DocStructStyle.DoubleBoxHLS) == E_DocStructStyle.DoubleBoxHLS)) - yPageStart -= SixLinesPerInch; - if (MyPageHelper.ParaBreaks.Count > 0 && MyPageHelper.ParaBreaks[0].CompressFirstPartOfStep) - MyPageHelper.YMultiplier = _SevenLinesPerInch / SixLinesPerInch; - if (CompressFoldout) - MyPageHelper.YMultiplier = _SevenLinesPerInch / SixLinesPerInch; - - ///else - /// MyPageHelper.YMultiplier = 1; - break; - // .oooooo. .o - // d8P' `Y8b o888 - //888 .oooo. .oooo.o .ooooo. 888 - //888 `P )88b d88( "8 d88' `88b 888 - //888 .oP"888 `"Y88b. 888ooo888 888 - //`88b ooo d8( 888 o. )88b 888 .o 888 - // `Y8bood8P' `Y888""8o 8""888P' `Y8bod8P' o888o - case 1: // Break on High Level Step - if (MyPromsPrinter.SupInfoPrintType == E_SupInfoPrintType.DoPageBreaks) - { - // page break here, determine if there is caution/note above where the page break actually needs to go: - int aboveSupinfoId = ChildrenAboveHaveSupInfo(); - if (supInfoSect!=null && MyItemInfo.SupInfos != null && MyItemInfo.SupInfos.Count > 0 && aboveSupinfoId > 0) supInfoSect.StepSectPageBreaksForSupInfo.Add(aboveSupinfoId); - else if (supInfoSect != null && MyItemInfo.SupInfos != null && MyItemInfo.SupInfos.Count > 0) supInfoSect.StepSectPageBreaksForSupInfo.Add(MyItemInfo.SupInfos[0].ItemID); - else MyPromsPrinter.NeedSupInfoBreak = true; - if (supInfoSect!=null) supInfoSect.StepSectPageBreaks.Add(MyItemInfo.ItemID); - } - YTopMost = OutputOtherPageSteps(cb, YTopMost, yPageStart, yTopMargin, yBottomMargin); - docstyle = MyItemInfo.MyDocStyle; - if (MyPageHelper.NotesToFootNotes != null && MyPageHelper.NotesToFootNotes.Count > 0) MyPageHelper.NotesToFootNotesYoffset = CalculateYLocation(yLocation, yTopMargin); - bool doSectionContinue = !MyItemInfo.IsSection && ((docstyle.StructureStyle.Style & E_DocStructStyle.BottomSectionContinue) == E_DocStructStyle.BottomSectionContinue); - if (doSectionContinue) DoBottomContinueMsg(cb, yBottomMargin, yLocation, docstyle, false); - MyPromsPrinter.NewPage(); - //_MyLog.InfoFormat("NewPage 10 {0}", cb.PdfWriter.CurrentPageNumber); - if (MyItemInfo.IsSection && MyParent != null && MyParent.MyItemInfo.IsSection && (MyItemInfo as SectionInfo).IsSeparatePagination()) - { - // F2023-015 for Beaver Valley as two sub-sections that are printed continuously followed by a third sub-section printed - // with separate pagination. This section type uses a different pagelist for the pages after the first page. - // Needed to call ResetDocStyleAndValues to set the new page with the other pagelist sytle. - ResetDocStyleAndValues(ref yTopMargin, ref yBottomMargin); - RefreshDocStyle(); - yTopMargin = PDFPageSize.PaperSizePoints(MyItemInfo.ActiveFormat.PlantFormat.FormatData.PDFPageSize.PaperSize) - (float)MyItemInfo.ActiveSection.MyDocStyle.Layout.TopMargin; // C2018-003 fixed use of getting the active section // C2020-002 paper size is now set in the format files - yBottomMargin = Math.Max(0, yTopMargin - (float)MyItemInfo.ActiveSection.MyDocStyle.Layout.PageLength); // C2018-003 fixed use of getting the active section - yPageStart = yTopMargin; - } - else if (MyItemInfo.IsSection || (MyItemInfo.IsHigh && MyItemInfo.MyPrevious != null)) //do not reset for 1st step - { - //Console.WriteLine("'b1',{0},'{1}',{2},{3},{4},{5},{6}", MyItemInfo.ItemID, MyItemInfo.ShortPath, yTopMargin, yPageStart, yLocation, YTopMost, YOffset); - ResetDocStyleAndValues(ref yTopMargin, ref yBottomMargin); - //Console.WriteLine("'a1',{0},'{1}',{2},{3},{4},{5},{6}", MyItemInfo.ItemID, MyItemInfo.ShortPath, yTopMargin, yPageStart, yLocation, YTopMost, YOffset); - } - DebugText.WriteLine("Paginate1"); - if (MyItemInfo.IsSection) - { - SectionInfo si = MyItemInfo as SectionInfo; - MyPageHelper.PageBookmarks.Add(MyItemInfo, ((si.DisplayNumber ?? "") == "" ? "" : si.DisplayNumber + " - ") + si.DisplayText, null); - - } - // Only do foldout page if not done for section break, i.e. check the there's a previous step. - if (MyItemInfo.MyPrevious != null && MyItemInfo.FoldoutIndex() > -1) - MyPromsPrinter.DoFoldoutPage(cb, "HLS", MyPageHelper.TextLayer, MyPageHelper, MyItemInfo.FoldoutIndex(), false); - // B2018-108 if paginating on first step don't add blank page (it was already added at this point) - // B2023-011: Beaver Valley - continuous section printing on its own page throws off CAS/blank pages - // added the IsSection check to the else if - else if (PromsPrinter.MyFoldoutReader.Count > 0 && MyPageHelper.MyPromsPrinter.InsertBlankPages && (MyItemInfo.IsSection || (MyItemInfo.IsHigh && MyItemInfo.MyPrevious != null))) - { - // insert a blank page if this step section had a foldout associated and the checkbox - // on the print dialog, to add blank pages, is checked AND the page did NOT have a - // preceeding foldout. - if (MyItemInfo.FoldoutIndex() <= -1) - { - MyPromsPrinter.InsertBlankPage(cb); - //_MyLog.InfoFormat("NewPage 10 blank {0}", cb.PdfWriter.CurrentPageNumber); - } - } - // See comments under case 0 explaining supinfo/facing page processing. - itemIsPrinted = IsPrintedStepItemForSupInfo(); - if (MyPromsPrinter.SupInfoPrintType == E_SupInfoPrintType.Merge && !MyPageHelper.CreatingSupInfoPage && itemIsPrinted /*&& !MyItemInfo.IsSection*/ && !MyItemInfo.IsInSupInfo && (MyItemInfo.MyProcedure as ProcedureInfo).ProcHasSupInfoData) - { - int sid = GetIdThatHasSupInfoItems(MyItemInfo, MyItemInfo.ItemID); - if (sid != -1) - { - MyPromsPrinter.DoSupInfoPage(cb, "TEMP", MyPageHelper.TextLayer, MyPageHelper, sid, true); - } - else - { - MyPromsPrinter.InsertBlankPage(cb); // C2019-004: Allow user to define duplex blank page text - } - } - if (MyItemInfo.MyDocStyle.LandscapePageList) - { - System.Drawing.Drawing2D.Matrix myMatrix = new System.Drawing.Drawing2D.Matrix(0, 1, -1, 0, cb.PdfDocument.PageSize.Height, 0); - cb.Transform(myMatrix); - } - yPageStart = yTopMargin + YTopMost; - // B2020-001 Catawba had an extra line at the top of a page that paginated on a section (EP/1/A/5000/E0 section B) - // Needed to remove the extra line spacing that is before the start of section B - (section is set for continuous pagination) - if (MyItemInfo.IsSection && MyItemInfo.ActiveFormat.MyStepSectionLayoutData.CustomSpacing) - yPageStart += (float)MyItemInfo.ActiveFormat.PlantFormat.FormatData.StepDataList[25].StepLayoutData.STExtraSpace; - DoCheckOffHeader(cb, MyItemInfo, yLocation, yTopMargin, yPageStart); - SectionTopMessage(cb, yTopMargin, yLocation); // does wcntraining & suppinfo section title - if (MyPageHelper.CreatingSupInfoPage) yPageStart -= (2 * SixLinesPerInch); - if (doSectionContinue) DoTopContinueMsg(cb, ref yPageStart, yTopMargin, docstyle, null); - // If "ContinueSectionHeader" (format flag) is true then print the section title with "(Continued)" appended to it - // B2020-164 added check for SpecialCaseCalvert to bypass IsSeparateSubsection STP O-67B-2 step 6.5 - // B2025-060 no section continue message if previous was not in same section or sub-section - // fixes Vogtle units 3&4 3-AOP-116 Attachments 2 & 3 - if ((!MyItemInfo.IsSection || MyItemInfo.IsSubsection) && - (MyItemInfo.MyPrevious != null && MyItemInfo.ActiveSection == MyItemInfo.MyPrevious.ActiveSection) && - MyItemInfo.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.ContinueSectionHeader && - (!MyItemInfo.IsSection || (MyItemInfo.IsSeparateSubsection || MyItemInfo.ActiveFormat.PlantFormat.FormatData.PrintData.SpecialCaseCalvert))) - { - // B2020-162 - SpecialCaseCalvert flag affect single column procedures, use SpecialCaseCalvertPagination for Two Column procedures instead - // B2020-163 - above bug (162) section header breaking from HLS caused forced pagination. turned out we didn't need to change this for B2020-162. - SectionConfig sch = MyItemInfo.ActiveSection.MyConfig as SectionConfig; - doSectionTitleContinued = (sch == null || sch.Section_PrintHdr == "Y") && !MyItemInfo.MyDocStyle.CancelSectTitle; - //B2020-123 - Calvert - set CalvertPrintedSubSectTitle flag to fix section continue bug - //B2020-166 - Calvert - only set CalvertPrintedSubSectTitle flag if doSectionTitleContinued is set - if (doSectionTitleContinued && MyItemInfo.ActiveFormat.PlantFormat.FormatData.PrintData.SpecialCaseCalvert) CalvertPrintedSubSectTitle = true; // B2020-123 - } - - if (MyPageHelper.ParaBreaks.Count > 0 && MyPageHelper.ParaBreaks[0].CompressFirstPartOfStep) - MyPageHelper.YMultiplier = _SevenLinesPerInch / SixLinesPerInch; - else - MyPageHelper.YMultiplier = 1; - break; - // .oooooo. .oooo. - // d8P' `Y8b .dP""Y88b - // 888 .oooo. .oooo.o .ooooo. ]8P' - // 888 `P )88b d88( "8 d88' `88b .d8P' - // 888 .oP"888 `"Y88b. 888ooo888 .dP' - // `88b ooo d8( 888 o. )88b 888 .o .oP .o - // `Y8bood8P' `Y888""8o 8""888P' `Y8bod8P' 8888888888 - case 2: // Break within a Step' - if (MyPromsPrinter.SupInfoPrintType == E_SupInfoPrintType.DoPageBreaks) - { - if (supInfoSect!=null&& MyItemInfo.SupInfos != null && MyItemInfo.SupInfos.Count > 0) supInfoSect.StepSectPageBreaksForSupInfo.Add(MyItemInfo.SupInfos[0].ItemID); - else MyPromsPrinter.NeedSupInfoBreak = true; - if (supInfoSect!=null) supInfoSect.StepSectPageBreaks.Add(MyItemInfo.ItemID); - } - YTopMost = OutputOtherPageSteps(cb, YTopMost, yPageStart, yTopMargin, yBottomMargin); - docstyle = MyItemInfo.MyDocStyle; - bool doAlarmBox = false; - if (MyItemInfo.ActiveFormat.PlantFormat.FormatData.PrintData.SpecialCaseCalvertAlarm) - { - { - // Recognize that the break occurred WITHIN the CONDITION/RESPONSE table. - // Otherwise, we get extraneous header/top of box lines in pdf. - if (MyPageHelper.AlarmYoffStart > 0) - { - // if the first step in box is what broke to next page, then - // don't print the box on this page, only print it on next page: - doAlarmBox = true; - if (MyItemInfo.MyPrevious == null && MyParent.HasCalvertMacro) - MyPageHelper.AlarmYoffStart = 0; - else if (MyPageHelper.AlarmYoffEnd == 0) - { - // doThreeContinues flags when continue messages are printed in the - // bottom of the CONDITION/RESPONSE table columns. - doThreeContinues = MyItemInfo.StepLevel > 1; - MyPageHelper.AlarmYoffEnd = CalculateYLocation(yLocation, yTopMargin); - } - else if (MyPageHelper.AlarmYoffEnd > 0) - doAlarmBox = false; - - } - } - } - if (MyPageHelper.NotesToFootNotes != null && MyPageHelper.NotesToFootNotes.Count > 0) MyPageHelper.NotesToFootNotesYoffset = CalculateYLocation(yLocation, yTopMargin); - // B2019-115 Locate Bottom Continue Message below AER Table if necesssary - float bcm_yLocation = TableBottom == -1 ? yLocation: Math.Min(TableBottom,yLocation); - DoBottomContinueMsg(cb, yBottomMargin, bcm_yLocation, docstyle, doThreeContinues); - MyPromsPrinter.NewPage(); - // C2018-003 fixed use of getting the active section - // F2023-112 Vogtle Units 3 & 4 background document format DSS_PageListBkgndStpContMsg to print continue message next to step number - if (MyItemInfo.IsStep && (MyItemInfo.ActiveSection != null && - ((MyItemInfo.ActiveSection.MyDocStyle.StructureStyle.Style & E_DocStructStyle.DSS_PageListSpBckgrnd) == E_DocStructStyle.DSS_PageListSpBckgrnd) || - ((MyItemInfo.ActiveSection.MyDocStyle.StructureStyle.Style & E_DocStructStyle.DSS_PageListBkgndStpContMsg) == E_DocStructStyle.DSS_PageListBkgndStpContMsg))) - { - // check if parent (can be HLS, Caution or Note) has the UseOldTemplate. If so, - // flag that a continue message should be printed as part of a pagelist header (if pagelist - // has CM: page list item) - ItemInfo itm = MyItemInfo; - while (itm.IsStep && !itm.FormatStepData.UseOldTemplate) itm = itm.MyParent; - // don't put out continue if the page break item is the same as background step item (caution/note or hls) - if (itm.IsStep && itm.ItemID != MyItemInfo.ItemID) - { - MyPageHelper.OldTemplateContMsg = true; - MyPageHelper.ResetSvg(); - } - } - //_MyLog.InfoFormat("NewPage 11 {0}", cb.PdfWriter.CurrentPageNumber); - //Console.WriteLine("'b2',{0},'{1}',{2},{3},{4},{5},{6}", MyItemInfo.ItemID, MyItemInfo.ShortPath, yTopMargin, yPageStart, yLocation, YTopMost, YOffset); - ResetDocStyleAndValues(ref yTopMargin, ref yBottomMargin); - //Console.WriteLine("'a2',{0},'{1}',{2},{3},{4},{5},{6}", MyItemInfo.ItemID, MyItemInfo.ShortPath, yTopMargin, yPageStart, yLocation, YTopMost, YOffset); - - DebugText.WriteLine("Paginate2"); - if (MyItemInfo.MyHLS.FoldoutIndex() > -1) - MyPromsPrinter.DoFoldoutPage(cb, "Break within Step", MyPageHelper.TextLayer, MyPageHelper, MyItemInfo.MyHLS.FoldoutIndex(), false); // temporary foldout - else if (PromsPrinter.MyFoldoutReader.Count > 0 && MyPageHelper.MyPromsPrinter.InsertBlankPages) - { - MyPromsPrinter.InsertBlankPage(cb); - _MyLog.InfoFormat("NewPage Break within step blank {0}", cb.PdfWriter.CurrentPageNumber); - } - if (MyPromsPrinter.SupInfoPrintType == E_SupInfoPrintType.Merge && !MyPageHelper.CreatingSupInfoPage && !MyItemInfo.IsSection && !MyItemInfo.IsInSupInfo && (MyItemInfo.MyProcedure as ProcedureInfo).ProcHasSupInfoData) - { - int sid = GetIdThatHasSupInfoItems(MyItemInfo, MyItemInfo.ItemID); - if (sid != -1) - { - MyPromsPrinter.DoSupInfoPage(cb, "TEMP", MyPageHelper.TextLayer, MyPageHelper, sid, true); - } - else - { - MyPromsPrinter.InsertBlankPage(cb); - } - } - // if there is a 'container vlnbox' around the HLS, flag that the drawn box must also break: - if (MyHighLevelParagraph != null && MyHighLevelParagraph.PartsContainer != null && MyHighLevelParagraph.PartsContainer.Count > 0 && - !((MyHighLevelParagraph.MyItemInfo.MyDocStyle.StructureStyle.Style & E_DocStructStyle.DoubleBoxHLS) == E_DocStructStyle.DoubleBoxHLS)) - { - foreach (vlnPrintObject vpo in MyHighLevelParagraph.PartsContainer) - { - vlnBox vb = vpo as vlnBox; - if (vb != null) - { - vb.ContainsPageBreak = true; - PartsContainer.Add(vb); - } - } - } - - // If there is a box, adjust the yTopMost to include it. - float yTopMost = YTopMost; - if ((MyItemInfo.IsCautionPart || MyItemInfo.IsNotePart) && MyParent.PartsAbove.Count > 0) - yTopMost = MyParent.PartsAbove[0].YOffset; - yTopMost = Math.Min(yTopMost, YVeryTop); - yPageStart = yTopMargin + yTopMost;// -2 * SixLinesPerInch; - DoCheckOffHeader(cb, MyItemInfo, yLocation, yTopMargin, yPageStart); - if (EmptyTopMostPart) yPageStart += SixLinesPerInch; - bool addExtraLines = false; - // If "ContinueSectionHeader" (format flag) is true then print the section title with "(Continued)" appended to it - if (MyItemInfo.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.ContinueSectionHeader) - { - // if this is calvert OI/STP, then also check that docstyle has a top continue message - // in the document style that includes 'Continued' - if (MyItemInfo.ActiveFormat.PlantFormat.FormatData.PrintData.SpecialCaseCalvert) - { - string myMsg = MyItemInfo.MyDocStyle.Continue.Top.Message; - if (myMsg == null || myMsg == "") - { - // There is no message, but still need to check if there is a Section Title Continued message: - // This was added for BGE OI34 (if break was within step, no section title continue message was printed) - if (MyItemInfo.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.ContinueSectionHeader) - { - SectionConfig sch = MyItemInfo.ActiveSection.MyConfig as SectionConfig; - doSectionTitleContinued = (sch == null || sch.Section_PrintHdr == "Y") && !MyItemInfo.MyDocStyle.CancelSectTitle; - } - else - doSectionTitleContinued = false; - } - else - { - SectionConfig sch = MyItemInfo.ActiveSection.MyConfig as SectionConfig; - doSectionTitleContinued = (sch == null || sch.Section_PrintHdr == "Y") && !MyItemInfo.MyDocStyle.CancelSectTitle; - } - } - else - { - SectionConfig sch = MyItemInfo.ActiveSection.MyConfig as SectionConfig; - doSectionTitleContinued = (sch == null || sch.Section_PrintHdr == "Y") && !MyItemInfo.MyDocStyle.CancelSectTitle; - } - } - addExtraLines = SectionTopMessage(cb, yTopMargin, yLocation); // this does wcntraining top section continue message and supplemental info message - if (MyPageHelper.CreatingSupInfoPage) yPageStart -= (2 * SixLinesPerInch); - if (!addExtraLines && (!doSectionTitleContinued || !SectionShowTitles)) - addExtraLines = DoTopContinueMsg(cb, ref yPageStart, yTopMargin, docstyle, doThreeContinues && MyItemInfo.MyParent != null && MyItemInfo.MyParent.MyTab != null ? MyItemInfo.MyParent.MyTab.CleanText : null); - // B2020-128: If compression flag is on RNO, see if there is an AER to the left and do the 7lpi multiplier - if (CompressPartOfStep || CompressRnoWithAerToTheLeft()) - { - MyPageHelper.YMultiplier = _SevenLinesPerInch / SixLinesPerInch; - CompressPartOfStep = false; - } - else - MyPageHelper.YMultiplier = 1; - - // For Calvert Alarms, if there was a page break and there is an box around the current - // step, need to add the header for the box, which is stored in a macro. Also set the - // 'AlarmYoffStart' value to where the vertical lines of the box start on this page. - if (doAlarmBox && MyItemInfo.StepLevel > 1) - { - float alrmY = yTopMargin - (2 * SixLinesPerInch); // CalculateYOffset(yPageStart, yTopMargin); - vlnMacro vlnm = new vlnMacro((float)docstyle.Layout.LeftMargin - 12, alrmY, "H4"); - vlnm.UseInternalY = true; // B2020-121: Account for Header on Caution or Note - PartsLeft.Add(vlnm); - MyPageHelper.AlarmYoffStart = alrmY - SixLinesPerInch; - yPageStart -= (4 * SixLinesPerInch); - if(ChildrenRight.Count>0 && ChildrenRight[0].ChildrenAbove.Count > 0 && ChildrenRight[0].ChildrenAbove[0].MyItemInfo.IsCautionOrNotePart) - yPageStart += (SixLinesPerInch); // B2020-121: Account for Header on Caution or Note - } - // For Calvert Alarms, if there is no box & this is top of page, if previous step - // had box (macro), adjust up page. The constructor (vlnParagraph), inserted these - // lines after the box so that the following text did not print right next to box. - if (MyItemInfo.ActiveFormat.PlantFormat.FormatData.PrintData.SpecialCaseCalvertAlarm) - { - if (MyItemInfo.MyPrevious != null && MyItemInfo.MyPrevious.TemplateIndex > 0 && MyItemInfo.ActiveFormat.PlantFormat.FormatData.Templates[MyItemInfo.MyPrevious.TemplateIndex].hmacro > 0) - yPageStart += (3 * SixLinesPerInch); - } - // Now check if this is a template type step & if so, add the HLS's prefix/suffix to it. - // Since the entire checklist HLS (checklist table header) is printed as part of the - // continue, create a new paragraph to handle pagination and printing. - if (MyItemInfo.MyHLS != null && MyItemInfo.MyHLS.FormatStepData.UseSmartTemplate) - { - DoSubs = false; - vlnParagraph smartPara = new vlnParagraph(MyParent.MyParent, cb, MyItemInfo.MyHLS, MyParent.XOffset, yPageStart, 0, 0, MyParent.MyItemInfo.ActiveFormat, null, " (Continued)", 0, false, MyPromsPrinter); - smartPara.PrintHeader = true; - float mytmpfloat = smartPara.ParagraphToPdf(cb, yPageStart, yTopMargin, yBottomMargin); - yPageStart -= smartPara.Height; - DoSubs = true; - } - if (addExtraLines) yPageStart -= (2 * SixLinesPerInch); - if (MyItemInfo.IsRNOPart && MyItemInfo.FormatStepData.DoubleSpace && MyItemInfo.FormatStepData.SpaceDouble) yPageStart += SixLinesPerInch; - break; - // .oooooo. .oooo. - // d8P' `Y8b .dP""Y88b - // 888 .oooo. .oooo.o .ooooo. ]8P' - // 888 `P )88b d88( "8 d88' `88b <88b. - // 888 .oP"888 `"Y88b. 888ooo888 `88b. - // `88b ooo d8( 888 o. )88b 888 .o o. .88P - // `Y8bood8P' `Y888""8o 8""888P' `Y8bod8P' `8bd88P' - case 3: // Break on High Level Step (SevenLinesPerInch) - if (MyPromsPrinter.SupInfoPrintType == E_SupInfoPrintType.DoPageBreaks) - { - if (supInfoSect!=null && MyItemInfo.SupInfos != null && MyItemInfo.SupInfos.Count > 0) supInfoSect.StepSectPageBreaksForSupInfo.Add(MyItemInfo.SupInfos[0].ItemID); - else MyPromsPrinter.NeedSupInfoBreak = true; - if(supInfoSect!=null) supInfoSect.StepSectPageBreaks.Add(MyItemInfo.ItemID); - } - if (!firstHighLevelStep || (MyPromsPrinter.SupInfoPrintType == E_SupInfoPrintType.Merge && !MyPageHelper.CreatingSupInfoPage)) // B2017-229: Added supinfo print check to run facing page logic - { - YTopMost = OutputOtherPageSteps(cb, YTopMost, yPageStart, yTopMargin, yBottomMargin); - if (MyPageHelper.NotesToFootNotes != null && MyPageHelper.NotesToFootNotes.Count > 0) MyPageHelper.NotesToFootNotesYoffset = CalculateYLocation(yLocation, yTopMargin); - MyPromsPrinter.NewPage(); // HLS (7 lpi) breakif (MyItemInfo.IsSection) - //_MyLog.InfoFormat("NewPage 12 {0}", cb.PdfWriter.CurrentPageNumber); - //Console.WriteLine("'b3',{0},'{1}',{2},{3},{4},{5},{6}", MyItemInfo.ItemID, MyItemInfo.ShortPath, yTopMargin, yPageStart, yLocation, YTopMost, YOffset); - ResetDocStyleAndValues(ref yTopMargin, ref yBottomMargin); - //Console.WriteLine("'a3',{0},'{1}',{2},{3},{4},{5},{6}", MyItemInfo.ItemID, MyItemInfo.ShortPath, yTopMargin, yPageStart, yLocation, YTopMost, YOffset); - DebugText.WriteLine("Paginate3"); - if (MyItemInfo.IsSection) - { - SectionInfo si = MyItemInfo as SectionInfo; - MyPageHelper.PageBookmarks.Add(MyItemInfo, ((si.DisplayNumber ?? "") == "" ? "" : si.DisplayNumber + " - ") + si.DisplayText, null); - } - if (MyItemInfo.FoldoutIndex() > -1) - MyPromsPrinter.DoFoldoutPage(cb, "HLS (7 lpi) break", MyPageHelper.TextLayer, MyPageHelper, MyItemInfo.FoldoutIndex(), false); - else if (PromsPrinter.MyFoldoutReader.Count > 0 && MyPageHelper.MyPromsPrinter.InsertBlankPages) - { - // insert a blank page if this step section had a foldout associated and the checkbox - // on the print dialog, to add blank pages, is checked - MyPromsPrinter.InsertBlankPage(cb); - //_MyLog.InfoFormat("NewPage 12 lpi blank {0}", cb.PdfWriter.CurrentPageNumber); - } - // See comments under case 0 explaining supinfo/facing page processing. - itemIsPrinted = IsPrintedStepItemForSupInfo(); - if (MyPromsPrinter.SupInfoPrintType == E_SupInfoPrintType.Merge && !MyPageHelper.CreatingSupInfoPage && itemIsPrinted /*&& !MyItemInfo.IsSection */ && !MyItemInfo.IsInSupInfo && (MyItemInfo.MyProcedure as ProcedureInfo).ProcHasSupInfoData) - { - int sid = GetIdThatHasSupInfoItems(MyItemInfo, MyItemInfo.ItemID); - if (sid != -1) - { - MyPromsPrinter.DoSupInfoPage(cb, "TEMP", MyPageHelper.TextLayer, MyPageHelper, sid, true); - } - else - { - // B2020-031: Don't put out an extra blank page if section has title that is printed (blank page is output then) - bool titlePrinted = false; - if (MyItemInfo.IsSection || (MyItemInfo.IsHigh && MyItemInfo.MyPrevious == null)) - { - // see if the section title is printed. - SectionConfig sch = MyItemInfo.ActiveSection.MyConfig as SectionConfig; - titlePrinted = (sch == null || sch.Section_PrintHdr == "Y") || !(MyItemInfo.MyActiveSection as SectionInfo).HasSupInfoSteps; - titlePrinted &= (ShowSectionTitles && !MyItemInfo.MyDocStyle.CancelSectTitle); - } - if (MyItemInfo.IsHigh && MyItemInfo.MyPrevious == null && !titlePrinted) - MyPromsPrinter.InsertBlankPage(cb); - } - } - if (MyItemInfo.MyDocStyle.LandscapePageList) - { - System.Drawing.Drawing2D.Matrix myMatrix = new System.Drawing.Drawing2D.Matrix(0, 1, -1, 0, cb.PdfDocument.PageSize.Height, 0); - cb.Transform(myMatrix); - } - - // If "ContinueSectionHeader" (format flag) is true then print the section title with "(Continued)" appended to it - if (!MyItemInfo.IsSection && MyItemInfo.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.ContinueSectionHeader) - { - SectionConfig sch = MyItemInfo.ActiveSection.MyConfig as SectionConfig; - doSectionTitleContinued = (sch == null || sch.Section_PrintHdr == "Y") && !MyItemInfo.MyDocStyle.CancelSectTitle; - } - } - // if printing the section title, we already have the y location (note that only do this for the - // first step in the section. - if (MyItemInfo.MyPrevious == null && MyItemInfo.MyParent != null && MyItemInfo.MyParent.IsStepSection && - ShowSectionTitles - && !MyItemInfo.MyDocStyle.CancelSectTitle - && !MyItemInfo.MyDocStyle.SpecialStepsFoldout) - yPageStart = yPageStart; - else - yPageStart = yTopMargin + YTopMost; - MyPageHelper.YMultiplier = _SevenLinesPerInch / SixLinesPerInch; - DoCheckOffHeader(cb, MyItemInfo, yLocation, yTopMargin, yPageStart); - break; - } - // If "doSectionTitleContinued" is true then print the section title with "(Continued)" appended to it - // format must have ContinueSectinHeader format flag set to true - //B2025-048 Problem with Printing CAS Steps - // skip this if printing CAS or CTAS - was causing it to - // skip/overwrite data - if (doSectionTitleContinued) - { - vlnParagraph sectContPara; - string contMsg = (MyItemInfo.ActiveSection != null) ? MyItemInfo.ActiveSection.MyDocStyle.Continue.SectionTitle.AppendToTitle : ""; // C2018-003 fixed use of getting the active section - // For Calvert, the xoffset will be the highest level sections xoffset (there are metasections, - // don't use their xoffset or the continue message is indented too much) - if (MyItemInfo.ActiveFormat.PlantFormat.FormatData.PrintData.SpecialCaseCalvert) - { - float secContinueTabXoff = (float)MyItemInfo.MyDocStyle.Layout.LeftMargin; - float secContinueXoff = 0f; - float secContinueTabWidth = 0f; - vlnParagraph fndTopSect = this; - while (fndTopSect.MyParent != null) - { - fndTopSect = fndTopSect.MyParent; - } - if (fndTopSect != null && fndTopSect.MyTab != null) - { - secContinueTabXoff = fndTopSect.MyTab.XOffset; - secContinueTabWidth = fndTopSect.MyTab.Width; - secContinueXoff = fndTopSect.XOffset; - } - // get to the correct section for the message, i.e. if on a section, the message should be the parent - // section (not the activesection which is myself); if on a step, the message should be the active section - ItemInfo sectForCont = MyItemInfo.IsSection && MyItemInfo.MyParent.IsSection ? MyItemInfo.MyParent : MyItemInfo.ActiveSection; - //B2025-054 Wrong Page Numbers in CAS Summary - // when section title continued and CAS - //to avoid overwriting data - // - this will be built at a different call to vlnParagraph - if (MyPromsPrinter.PromsPrinterPrintType != PromsPrinterPrintType.Normal) - MyPromsPrinter.ShouldPrint_CAS_CTAS = false; - sectContPara = new vlnParagraph(MyParent.MyParent, cb, sectForCont, MyParent.XOffset, 0, 0, 0, MyParent.MyItemInfo.ActiveFormat, null, (contMsg == null || contMsg == "") ? " (Continued)" : contMsg, 0, false, MyPromsPrinter); - if (sectContPara.PartsLeft.Count > 0) - { - vlnTab vt = sectContPara.MyTab; - string ctab = GetSectCombinedTab(MyItemInfo); - vt.Rtf = GetRtf(ctab, vt.MyFont); - float wd = vt.GetTextWidth(vt.MyFont, ctab); - vt.XOffset = secContinueTabXoff; - vt.Width = secContinueXoff - secContinueTabXoff; - sectContPara.XOffset = secContinueXoff; - if ((wd + 12) > secContinueXoff - secContinueTabXoff) // 12 is 2 characters - { - float dif = wd + 12 - (secContinueXoff - secContinueTabXoff); - vt.Width += dif; - sectContPara.XOffset += dif; - sectContPara.Width -= dif; - } - - } - float mytmpfloat = sectContPara.ParagraphToPdf(cb, yTopMargin, yTopMargin, yBottomMargin); - if (sectContPara.SectionContinuePrinted) - yPageStart -= sectContPara.Height + SixLinesPerInch; - } - else - { - //B2025-054 Wrong Step Numbers - // when section title continued and CAS - //to avoid overwriting data - // - this will be built at a different call to vlnParagraph - if (MyPromsPrinter.PromsPrinterPrintType != PromsPrinterPrintType.Normal) - MyPromsPrinter.ShouldPrint_CAS_CTAS = false; - sectContPara = new vlnParagraph(MyParent.MyParent, cb, MyItemInfo.ActiveSection, MyParent.XOffset, 0, 0, 0, MyParent.MyItemInfo.ActiveFormat, null, (contMsg == null || contMsg == "") ? " (Continued)" : contMsg, 0, false, MyPromsPrinter); - float mytmpfloat = sectContPara.ParagraphToPdf(cb, yTopMargin, yTopMargin, yBottomMargin); - if (sectContPara.SectionContinuePrinted) - yPageStart -= sectContPara.Height + SixLinesPerInch; - } - } - //out of section title section - reset this back to true (default) - MyPromsPrinter.ShouldPrint_CAS_CTAS = true; - - // see if this hls has footnotes, add to the footnote datastructure for processing at end of page. - if (MyItemInfo.IsHigh && MyPageHelper.NotesToFootNotesHLS.ContainsKey(MyItemInfo.ItemID)) AddFootNote(cb); - - yPageStart = ChildrenAbove.ToPdf(cb, yPageStart, ref yTopMargin, ref yBottomMargin); - // B2017-122: if doing supinfo pagebreaks, if there should be a break on a step (not hls) that has a caution/note do it here: - if (!MyItemInfo.IsHigh && ChildrenAbove != null && ChildrenAbove.Count > 0 && MyPromsPrinter.SupInfoPrintType == E_SupInfoPrintType.DoPageBreaks && MyPromsPrinter.NeedSupInfoBreak && MyItemInfo.SupInfos != null && MyItemInfo.SupInfos.Count > 0) - { - // if this has a caution/note with supinfo, that is id that needs to go in pagination list, unless it is in there. - int aboveSupinfoId = ChildrenAboveHaveSupInfo(); - if (supInfoSect != null) - { - if (supInfoSect.StepSectPageBreaksForSupInfo.Contains(aboveSupinfoId)) aboveSupinfoId = -1; - supInfoSect.StepSectPageBreaksForSupInfo.Add(MyItemInfo.SupInfos[0].ItemID); - } - MyPromsPrinter.NeedSupInfoBreak = false; - } - yPageStart = ChildrenLeft.ToPdf(cb, yPageStart, ref yTopMargin, ref yBottomMargin); - - // Handle the PageBreakOnStep flag for a HLS. This will put out the page break right before - // a HLS. One example of this use is for backgrounds (CALBCK). - // 'this' below is a highlevel step, and the only time that ParaBreaks[0] will == 'this' is - // when the PageBreakOnStep flag is true. - if (MyPageHelper.ParaBreaks != null && MyPageHelper.ParaBreaks.Count > 0 && - MyPageHelper.ParaBreaks[0] == this && this.MyItemInfo.FormatStepData.PageBreakOnStep)// B2017-224 Top Continue Messages Add check for PageBreakOnStep 9/26/2017 Ginna SAMGs SAG-8 Step 4 - { - ShowPageBreak(1, CheckForCompression("PageBreakOnStep/Caution/Note HLS"), "Yes", YTop - YBottomMost, yTopMargin - yBottomMargin, yTopMargin - yBottomMargin, false); - YTopMost = OutputOtherPageSteps(cb, YTopMost, yPageStart, yTopMargin, yBottomMargin); - MyPageHelper.BottomMessage.Clear(); - MyPageHelper.TopMessage = null; - MyPromsPrinter.NewPage(); - if (CompressPartOfStep) - { - MyPageHelper.YMultiplier = _SevenLinesPerInch / SixLinesPerInch; - CompressPartOfStep = false; - } - MyPageHelper.ParaBreaks.RemoveAt(0); - yPageStart = yTopMargin + YTop; - } - // The following sets the beginning/ending y location for the lines around the - // CONDITION/RESPONSE text for Calvert Alarm format - if (MyItemInfo.ActiveFormat.PlantFormat.FormatData.PrintData.SpecialCaseCalvertAlarm) - { - int tindx = MyItemInfo.TemplateIndex; - if (tindx >= 0) - { - // save this position to start drawing the alarm box lines around substeps: - if (MyItemInfo.ActiveFormat.PlantFormat.FormatData.Templates[MyItemInfo.TemplateIndex].row > 0) - MyPageHelper.AlarmYoffStart = CalculateYOffset(yPageStart, yTopMargin) - SixLinesPerInch; - else if (MyPageHelper.AlarmYoffStart > 0 && MyPageHelper.AlarmYoffEnd == 0) - MyPageHelper.AlarmYoffEnd = CalculateYOffset(yPageStart, yTopMargin) + (2 * SixLinesPerInch); - } - } - int profileDepth2 = ProfileTimer.Push(">>>> vlnParagraph.ParagraphToPdf"); - // B2020-162 - SpecialCaseCalvert flag affect single column procedures, use SpecialCaseCalvertPagination for Two Column procedures instead - if (MyItemInfo.IsSubsection && MyItemInfo.ActiveFormat.PlantFormat.FormatData.PrintData.SpecialCaseCalvertPagination) CalvertPrintedSubSectTitle = true; // B2020-123 - yPageStart = ParagraphToPdf(cb, yPageStart, yTopMargin, yBottomMargin); - ProfileTimer.Pop(profileDepth2); - // If the yPageStart changes by more than a small amount (pagination) in the RNO (right column), then update - // yPageStart for the AER (left column). - float yPageStartRNO = ChildrenRight.ToPdf(cb, yPageStart, ref yTopMargin, ref yBottomMargin); - if (yPageStartRNO - yPageStart > 24) // 24 is two lines - yPageStart = yPageStartRNO; - yPageStart = ChildrenBelow.ToPdf(cb, yPageStart, ref yTopMargin, ref yBottomMargin); - - if (MyItemInfo.IsHigh && MyItemInfo.NextItem == null) // last hls, add the 'end' message, if there is one - { - docstyle = MyItemInfo.MyDocStyle; - // if the EndForSingle format flag is set to false, then we do not print an End message if the section - // is a single column section. - //bool _skipEndMessage = MyPageHelper.MySection.SectionConfig.Section_ColumnMode == SectionConfig.SectionColumnMode.One && !MyItemInfo.ActiveFormat.MyStepSectionLayoutData.EndForSingle; - SectionInfo si = MyItemInfo.ActiveSection as SectionInfo; // C2018-003 fixed use of getting the active section - // B2017-201 if si is null we need to get it via the ItemID - if (si == null) - si = SectionInfo.Get(MyItemInfo.MyActiveSection.ItemID); // MyActiveSection does not try to resolve anything - ActiveSection is call above and will resolve and set MyActiveSection - bool _skipEndMessage = (si == null ||si.SectionConfig.Section_ColumnMode == SectionConfig.SectionColumnMode.One) && !MyItemInfo.ActiveFormat.MyStepSectionLayoutData.EndForSingle; - bool _lastSect = true; - if (si != null && si.MyActiveParent.IsSection) // is this meta/subsection. Only put end message out on last section - { - ItemInfo mysect = si as ItemInfo; - if (mysect.NextItem != null && !docstyle.End.EndMessageOnEachSubSection) _lastSect = false; - } - string myMsg = (docstyle.End == null) ? null : docstyle.End.FixedMessage; - if (myMsg != null && !_skipEndMessage && _lastSect) - { - // If the flag is 0 or 1, just put the end message out right below this vlnParagraph: - float msg_yLocation = CalculateYLocation(yPageStart - YBottomMost, yTopMargin); - //if (MyPageHelper.YMultiplier < 1) - // msg_yLocation += 4;// Robinson - if the page is compressed, we need this adjustment. - - // the following is for IP3 - it was commented out so that an update could be put on - // before this was tested. - // if end message has {par}, remove these but add a line for each. - //int parindx = myMsg.IndexOf("{par}"); - //bool foundpar = false; - //while (parindx > -1) - //{ - // foundpar = true; - // msg_yLocation += SixLinesPerInch; - // parindx = myMsg.IndexOf("{par}", parindx + 1); - //} - //if (foundpar) myMsg = myMsg.Replace("{par}", ""); - // use the 'flag' to position the message. - if (docstyle.End.Flag > 2) // >2 position at an absolute location defined by docstyle.End.Flag. - { - msg_yLocation = yTopMargin - (float)(docstyle.End.Flag * SixLinesPerInch); - } - float adjMsgY = 0; - if (docstyle.End.Flag < 0) // Adjust this many lines down the page. - { - adjMsgY = (float)(-docstyle.End.Flag * SixLinesPerInch); - if (msg_yLocation - adjMsgY > docstyle.Layout.FooterLength) msg_yLocation = msg_yLocation - adjMsgY; - } - if (myMsg.Contains("{Section Number}")) myMsg = myMsg.Replace("{Section Number}", MyItemInfo.ActiveSection.DisplayNumber); - //jcb code - //if (myMsg.Contains("%-8s")) - // myMsg = myMsg.Replace("%-8s", MyItemInfo.MyProcedure.DisplayNumber.PadRight(8)); - if (myMsg.Contains("%-12s")) - myMsg = myMsg.Replace("%-12s", MyItemInfo.MyProcedure.DisplayNumber.PadRight(12)); - float xpos = 0; - if (yTopMargin - docstyle.Layout.PageLength >= msg_yLocation && docstyle.End.Message != null && docstyle.End.Message != "" && docstyle.End.Flag <= 2) - { - // B2018-037: adjust location of end message to bottom of page if it is too low. This occurs when data just doesn't - // fit on the page, but will locate end message at a more reasonable location. - msg_yLocation = (float)yTopMargin - (float)docstyle.Layout.PageLength; - _MyLog.WarnFormat("End Message LOW on page: {0}, {1}, {2}, Page {3}", msg_yLocation, MyItemInfo.ItemID, MyItemInfo.ShortPath, MyPageHelper.CurrentPageNumber + 1); - } - if ((docstyle.End.Margin ?? 0) != 0) - { - xpos = (float)docstyle.Layout.LeftMargin + (float)docstyle.End.Margin; - MyPageHelper.BottomMessage.Add(new vlnText(cb, this, myMsg, myMsg, xpos, msg_yLocation, docstyle.End.Font)); - } - else - { // Center the bottom message - float wtpm = (float)docstyle.Layout.PageWidth - (float)docstyle.Layout.LeftMargin; - //B2022-126 was using the wrong font definition to calaculate the centering position - // ** B2023-099 commented out and restored the previous calculation. This caused problems centering the END message in Ginna - // their END message prints with the Prestige Elite font but he centering calc uses Courier New - //xpos = XOffsetBox + (float)docstyle.Layout.LeftMargin + (wtpm - (myMsg.Length * docstyle.End.Font.CharsToTwips)) / 2; - xpos = XOffsetBox + (float)docstyle.Layout.LeftMargin + (wtpm - (myMsg.Length * MyItemInfo.FormatStepData.Font.CharsToTwips)) / 2; - xpos = Math.Max(xpos, XOffsetBox + (float)docstyle.Layout.LeftMargin); - vlnText vttmp = new vlnText(cb, this, myMsg, myMsg, xpos, msg_yLocation, docstyle.End.Font); - MyPageHelper.BottomMessage.Add(vttmp); - MyPageHelper.MyGaps.Add(new Gap(msg_yLocation, msg_yLocation - vttmp.Height)); - yPageStart -= (vttmp.Height + adjMsgY); - } - } - } - if (yLocalypagestart != yPageStart) DebugText.WriteLine("ToPdf-yPagestartDiff:{0},{1},{2},{3}", MyPageHelper.MyPdfContentByte.PdfWriter.CurrentPageNumber, MyItemInfo.ItemID, yLocalypagestart, yPageStart); - - // if doing NotesToFootnotes (Calvert valve list format), get the bottom location so that - // footnotes will be printed after last text on page. This is used for the end of the section. - // Pages that broke within pagination logic above had footnote location set during pagination code. - if (MyPageHelper.NotesToFootNotes != null && MyPageHelper.NotesToFootNotes.Count > 0) - MyPageHelper.NotesToFootNotesYoffset = CalculateYLocation(yPageStart - YBottomMost, yTopMargin); - ProfileTimer.Pop(profileDepth); - return yPageStart; - } - // B2020-128: If compression flag is on RNO, see if there is an AER to the left and do the 7lpi multiplier - private bool CompressRnoWithAerToTheLeft() - { - if (!MyItemInfo.IsInRNO) return false; - foreach (vlnParagraph vPara in MyPageHelper.MyParagraphs.Values) - { - if (!vPara.Processed) - { - if (vPara.YOffset <= YOffset && vPara.CompressPartOfStep) return true; - } - } - return false; - } - private bool IsPrintedStepItemForSupInfo() - { - bool printedMySectTitle = true; - if (MyItemInfo.IsSection) - { - // see if the section title is printed. - SectionConfig sch = (MyItemInfo.ActiveSection != null) ? MyItemInfo.ActiveSection.MyConfig as SectionConfig : null; // C2018-003 fixed use of getting the active section - printedMySectTitle = (sch == null || sch.Section_PrintHdr == "Y") || !(MyItemInfo.ActiveSection as SectionInfo).HasSupInfoSteps; - printedMySectTitle &= (ShowSectionTitles && !MyItemInfo.MyDocStyle.CancelSectTitle); - } - return printedMySectTitle; - } - private int ChildrenAboveHaveSupInfo() - { - if (ChildrenAbove == null || ChildrenAbove.Count < 1) return -1; - foreach (vlnParagraph p in ChildrenAbove) - { - if (p.MyItemInfo.SupInfos != null && p.MyItemInfo.SupInfos.Count > 0) return p.MyItemInfo.SupInfos[0].ItemID; - } - return -1; - } - // Find the step that has supplemental information from this step down page until a preferred page break is found - // or a regular page break. - // It is used to determine whether there is a supinfo facing page or if there should be a blank page. - private bool FoundStepPageBreak = false; - private int GetIdThatHasSupInfoItems(ItemInfo ii, int startid) - { - if (ii == null) return -1; - FoundStepPageBreak = false; - // if this item has supinfo, return its id - if (ii.SupInfos != null && ii.SupInfos.Count > 0) return ii.SupInfos[0].ItemID; - - // see if any substeps of this item have supinfo, and if so, return the substep's id - int id = GetSubThatHasSupInfoItems(ii, startid); - if (id != -1) return id; - if (FoundStepPageBreak) return -1; // Set in GetSubThatHasSupInfoItems - - // Now go to the next item, check if it or any of its substeps have supinfo, and if so, return the id - ItemInfo sib = ii.NextItem; - id = GetIdThatHasSupInfoItemsSibNext(sib, startid); - if (id != -1) return id; - if (FoundStepPageBreak) return -1; // Set in GetIdThatHasSupInfoItemsSibNext - - // B2017-122: if this is a note or caution off substep, check if substep has supinfo: - if ((ii.IsNote || ii.IsCaution) && !ii.MyParent.IsHigh) - { - if (ii.MyParent.SupInfos != null && ii.MyParent.SupInfos.Count > 0) return ii.MyParent.SupInfos[0].ItemID; - int sbfromNC = GetSubThatHasSupInfoItems(ii.MyParent, startid); - if (sbfromNC != -1) return sbfromNC; - if (FoundStepPageBreak) return -1; // Set in GetSubThatHasSupInfoItems - } - - // Go to the parent, and find its next and check if it or any of its substeps or next steps or any of their substeps have supinfo, - // and if so, return the id. - ItemInfo par = ii.MyParent; - ItemInfo parsnxt = par.GetNext(); - //B2023-068 check if we are already at the section or procedure level - if (!par.IsSection && !par.IsProcedure && parsnxt != null) - { - par = parsnxt; - while (par != null && !par.IsSection) - { - id = GetIdThatHasSupInfoItemsSibNext(par, startid); - if (id != -1) return id; - par = par.MyParent; - ItemInfo sparsnxt = par.GetNext(); - if (!par.IsSection && sparsnxt != null) par = sparsnxt; - else return -1; - } - } - return -1; - } - - private int GetIdThatHasSupInfoItemsSibNext(ItemInfo ii, int startid) - { - int id = -1; - while (ii != null) - { - SectionInfo supInfoSect = ii.ActiveSection as SectionInfo; - // B2017-193 Error occured when a section in the MRU was being loaded as an iteminfo - if (supInfoSect == null) supInfoSect = SectionInfo.Get(ii.ActiveSection.ItemID); - // if there is a pagebreak on this step section step, quit looking for supinfos. The - // break has to occur here. - if (supInfoSect.StepSectPageBreaks.Contains(ii.ItemID)) - { - FoundStepPageBreak = true; - return -1; - } - if (ii.SupInfos != null && ii.SupInfos.Count > 0) - { - // check if this is in the list of page breaks for supinfos, if not it may have one of its cautions/notes rather than its id: - if (!supInfoSect.StepSectPageBreaksForSupInfo.Contains(ii.SupInfos[0].ItemID)) - { - if (ii.Cautions != null) - { - foreach (ItemInfo caution in ii.Cautions) - if (caution.SupInfos != null && caution.SupInfos.Count > 0 && supInfoSect.StepSectPageBreaksForSupInfo.Contains(caution.SupInfos[0].ItemID)) return caution.SupInfos[0].ItemID; - } - if (ii.Notes != null) - { - foreach (ItemInfo note in ii.Notes) - if (note.SupInfos != null && note.SupInfos.Count > 0 && supInfoSect.StepSectPageBreaksForSupInfo.Contains(note.SupInfos[0].ItemID)) return note.SupInfos[0].ItemID; - } - } - return ii.SupInfos[0].ItemID; - } - id = GetSubThatHasSupInfoItems(ii, startid); - if (id == -2) return -1; - if (id != -1) return id; - ii = ii.NextItem; - } - return -1; - } - private int GetSubThatHasSupInfoItems(ItemInfo ii, int startid) - { - if (ii.MyContent.ContentParts != null) - { - SectionInfo supInfoSect = ii.ActiveSection as SectionInfo; - if (supInfoSect == null) supInfoSect = SectionInfo.Get(ii.ActiveSection.ItemID); - foreach (PartInfo pi in ii.MyContent.ContentParts) - { - if ((E_FromType)pi.FromType != E_FromType.SupInfo) - { - foreach (ItemInfo iic in pi.MyItems) - { - // B2018-021: added code to be sure that check isn't on current step, i.e. startid != iic.ItemID & - // flag when the following page break is found so the next supplemental information page isn't printed - // on a step where the step is on the following page from the one we are looking for. - if (startid != iic.ItemID) - { - if (supInfoSect.StepSectPageBreaks.Contains(iic.ItemID)) - { - FoundStepPageBreak = true; - return -1; - } - if (iic.SupInfos != null && iic.SupInfos.Count > 0) return iic.SupInfos[0].ItemID; - int id = GetSubThatHasSupInfoItems(iic, startid); - if (id != -1) return id; - } - } - } - } - } - return -1; - } - private float GetSectionTopMessageSize() - { - // B2016-134: Account for wcntraining section top continue if item has container - float retval = 0; - if (MyItemInfo.MyDocStyle.SectTop != null && MyItemInfo.MyDocStyle.SectTop.Message != null) - { - if (PartsContainer != null && PartsContainer.Count > 0) retval = SixLinesPerInch * 1; - } - return retval; - } - // For WCNTRN (Wolf Creek Training format): the following prints the section number (and continued, if - // section is continued from previous page) in the Responsibility column. - private bool SectionTopMessage(PdfContentByte cb, float yTopMargin, float yLocation) - { - if (MyPageHelper.CreatingSupInfoPage) - { - float scttopWidths = "Supplemental Information".Length * 6; - float ctrs = ((float)MyItemInfo.MyDocStyle.Layout.PageWidth - (float)MyItemInfo.MyDocStyle.Layout.LeftMargin) / 2; - float sctcntrXs = (float)MyItemInfo.MyDocStyle.Layout.LeftMargin + ctrs - (scttopWidths / 2); - VE_Font vf = MyItemInfo.MyDocStyle.Font; - // F2017-039: The following null check was added in case the format's doc style does not have a font defined: - if (vf == null || vf.Style == null || vf.Family == null || vf.Size == null || vf.CPI == null) vf = MyItemInfo.ActiveFormat.PlantFormat.FormatData.Font; - E_Style sty = E_Style.Underline; - if (vf != null && vf.Style != null) sty = (E_Style)(vf.Style | E_Style.Underline); - vf = new VE_Font(vf.Family, (int)vf.Size, sty, (float)vf.CPI); - MyPageHelper.TopMessage = new vlnText(cb, this, "Supplemental Information", "Supplemental Information", sctcntrXs, yTopMargin + 0.1F, vf); - return true; - } - bool addextra = false; - if (MyItemInfo.MyDocStyle.SectTop != null && MyItemInfo.MyDocStyle.SectTop.Message != null) - { - float sectMsgY = 0; - if (PartsContainer == null || PartsContainer.Count == 0) - sectMsgY = CalculateYLocation(YTop, yTopMargin); - else - { - // B2016-134: Account for section top continue if item has container, i.e. move section top continue message above the container - sectMsgY = CalculateYLocation(YTopMost - (SixLinesPerInch * 3), yTopMargin); // 3 is # of lines: header, box, blank line moving up page - addextra = true; - } - VE_Font sctMsgFont = MyItemInfo.MyDocStyle.SectTop.Font; - string scttop = null; - if (!MyItemInfo.IsStepSection && MyItemInfo.MyDocStyle.SectTop.Message != null) - scttop = MyItemInfo.MyDocStyle.SectTop.Message.Replace("%s", (MyItemInfo.ActiveSection as SectionInfo).DisplayNumber); - else - scttop = (MyItemInfo as SectionInfo).DisplayNumber; - float scttopWidth = scttop.Length * 6; - float ctr = (float)MyItemInfo.MyDocStyle.SectTop.Margin; - float sctcntrX = (float)MyItemInfo.MyDocStyle.Layout.LeftMargin + ctr - (scttopWidth / 2); - vlnText mySectMsg = new vlnText(cb, this, scttop, scttop, sctcntrX, sectMsgY, sctMsgFont); - PartsLeft.Add(mySectMsg); - } - return addextra; - } - // Added to try to resolve a problem when printing FNP-1-FRP-I.3 Attachment 3 Table 1. - // May be needed to evaluate this problem in the future. - //private void CompareSectionInfo(SectionInfo si, SectionInfo si1) - //{ - // if (si.ItemID != si1.ItemID) - // Console.WriteLine("Different"); - // if (si.ActiveFormat.FullName != si1.ActiveFormat.FullName) - // Console.WriteLine("Different"); - // if (si.ActiveParent != si1.ActiveParent) - // Console.WriteLine("Different"); - // if (si.ActiveSection.ItemID != si1.ActiveSection.ItemID) - // Console.WriteLine("Different"); - // if (si.MyDocStyle.Name != si1.MyDocStyle.Name) - // Console.WriteLine("Different"); - //} - private void AddFootNote(PdfContentByte cb) - { - // for calvert valve lists footnotes, if there is footnote data, save it for vlnSvgPageHelper - // which puts the footnotes out when page is printed. - List myNotes = MyPageHelper.NotesToFootNotesHLS[MyItemInfo.ItemID]; - foreach (int myNote in myNotes) - { - ItemInfo inote = StepInfo.Get(myNote); - - // first check if this exact text is already in the foot note list. If it is - // in there, don't add it. - bool inlist = false; - if (MyPageHelper.NotesToFootNotes != null) - { - foreach (vlnParagraph vp in MyPageHelper.NotesToFootNotes) - { - if (vp.MyItemInfo.MyContent.Text == inote.MyContent.Text) - { - inlist = true; - break; - } - } - } - if (!inlist) - { - vlnParagraph vpFNote = new vlnParagraph(null, cb, inote, (float)MyItemInfo.MyDocStyle.Layout.LeftMargin, 0, 0, 0, MyItemInfo.ActiveFormat, null, null, 0, false, MyPromsPrinter); - vpFNote.Width = (float)MyItemInfo.MyDocStyle.Layout.PageWidth - (float)MyItemInfo.MyDocStyle.Layout.LeftMargin; - vpFNote.Height = 0; - vpFNote.XOffset = (float)MyItemInfo.MyDocStyle.Layout.LeftMargin; - if (MyPageHelper.NotesToFootNotes == null) MyPageHelper.NotesToFootNotes = new List(); - MyPageHelper.NotesToFootNotes.Add(vpFNote); - } - } - MyPageHelper.NotesToFootNotesHLS.Remove(MyItemInfo.ItemID); - } - private bool DoTopContinueMsg(PdfContentByte cb, ref float yPageStart, float yTopMargin, DocStyle docstyle, string subTab) - { - bool addExtraLine = false; - if ((bool)docstyle.Continue.Top.UseStepTabs) - { - // UseStepTabs is a format flag added for Comanche Peak to print out step tabs as - // a top comtinue message. This code will go up through parents putting out - // their tabs - at this y location, but at the tabs' x location - vlnParagraph myPar = this; - MyPageHelper.TopMessageRs = new List(); - while (!myPar.MyItemInfo.IsHigh) - { - myPar = myPar.MyParent; - foreach (vlnPrintObject vpo in myPar.PartsLeft) - { - if (vpo is vlnTab) - { - vlnTab vt = vpo as vlnTab; - string cltxt = vt.Text; - // Originally the Comache Peak customer did not want the '*'. As of 6/22/15, CP wants the asterisk in continue msg - ///cltxt = cltxt.Replace("*", " "); - // replace C# representation of unicode character "\u25CF" which is hex - // with the rtf representation @"\u9679?" - if (cltxt.Contains("\u25CF")) cltxt = cltxt.Replace("\u25CF", @"\u9679?"); // handle a bullet, if it isn't unicode yet - float msgTopMargin = yTopMargin; - // B2017-106: if caution/note move the message up a little so it doesn't touch the caution/note lines: - if (MyItemInfo.IsNote || MyItemInfo.IsCaution) msgTopMargin += 4; - // B2018-140: if table move the message up a little so it doesn't touch the table lines: - if (MyItemInfo.IsTable) msgTopMargin += 6; - MyPageHelper.TopMessageRs.Add(new vlnText(cb, this, cltxt, cltxt, vt.XOffset, msgTopMargin, vt.MyFont)); - } - else if (vpo is vlnText) // As of 6/22/15, CP wants the step designator in the continue message also. - { - vpo.YOffset = yTopMargin; - int nlcnt = 1; // number of lines to adjust the yoffset for the next step designator we are adding to TopMessageRs - string rtxt = ""; - int istr = 0; - int Rsidx = 0; - MyPageHelper.TopMessageRs.Add(vpo as vlnText); // this appends a previous step designator associated with this sub-step (there may be more than one and/or might have multiple lines) - // we are processing the step designator on the top continue message in reverse order - // we therefore need to adjust the y location of multiple step designors attached tothe top continue message - if (MyPageHelper.TopMessageRs.Count > 3) - { - Rsidx = MyPageHelper.TopMessageRs.Count - 1; - rtxt = MyPageHelper.TopMessageRs[Rsidx].Text; - // find the number of lines to shift existing TopMessageRs step designators down - istr = rtxt.IndexOf("\\line", 0); - while (istr != -1) - { - nlcnt++; - istr = rtxt.IndexOf("\\line", istr + 1); - } - // move the previous TopMessageRs step designators down - Rsidx -= 2; // index to the previous step desginator - while (Rsidx > 0) - { - MyPageHelper.TopMessageRs[Rsidx].YOffset -= (nlcnt * SixLinesPerInch); - Rsidx -= 2;// every other TopMessageRs is a step designator - } - } - // for Comanche Peak - if step breaks on a sub-step, and both the high level step and the sub-step have a step designator - // then since the high level step and its step designator are printed as part of the top continue message, - // move the step designator associated with the sub-step down so that it does not print on top of the - // ones in the top continue message. - if (this.PartsLeft.Count > 1) // was a step designator printed for the sub-step? - { - // count the number of lines in the step designator text in the top continue message - nlcnt = 0; // reset for the number of lines to push the sub-step's step designator down - Rsidx = MyPageHelper.TopMessageRs.Count - 1; // note that TopMessageRs[0] is a tab not a step designator - while (Rsidx > 0) - { - nlcnt++; - rtxt = MyPageHelper.TopMessageRs[Rsidx].Text; - istr = rtxt.IndexOf("\\line", 0); - while (istr != -1) - { - nlcnt++; - istr = rtxt.IndexOf("\\line", istr + 1); - } - Rsidx -= 2; // every other TopMessageRs is a step designator - } - if (nlcnt > 0) - { - for (int idx = 1; idx < this.PartsLeft.Count; idx++) - { - vlnPrintObject vpol = this.PartsLeft[idx]; - vpol.YOffset += (nlcnt * SixLinesPerInch); // move the existing step designator down - } - } - } - } - } - } - return false; - } - - string myMsg = docstyle.Continue.Top.Message; - MyPageHelper.TopMessageRs = new List(); - // bug fix B2106-099 - // when there are more than one Caution/Note off of a high level background step, - // the second, third, etc background Caution/Note pages begin printing two additional lines from the top of the page - // to fix, added a check to see the the item we are printing has the PageBrrakOnStep flag set, if it's set, - // then DON'T add two lines to the yPageStart (for the top conitnue message) - if (myMsg != null && myMsg != "" && !MyItemInfo.IsSection && !MyItemInfo.FormatStepData.PageBreakOnStep) // B2020-123 - { - // C2019-044 for BNPP put the top continue message on the same row as the Checkoff/Signoff header - // This is done by specifing a row positon in the top continue definition in the format. - // If the top continue messsage RowOverride is being used, don't move the yPageStart down (don't need to make room for it) - if (docstyle.Continue.Top.RowOverride == null) - yPageStart -= 2 * SixLinesPerInch;// Allow two lines for top continue message - if (myMsg.IndexOf(@"%sR") > -1) - { - ItemInfo myAer = MyItemInfo.IsHigh ? MyItemInfo : MyItemInfo.MyParent; - if (MyItemInfo.IsInRNO) - { - // If this is an RNO part, find the parent that is not an RNO (the reason for this is - // that RNO parts are structured as parent/child not sibling relationships, for - // example, RNO part 1.2 is the child of 1.1 not sibling). Also, if this is a caution - // or note of the RNO part, do the same because it should not use the RNO part's tab. - // However, the RNO Part will have the combined tab using its parent because this is - // needed if any of its children, for example substeps, need the combined tab. - if (((MyItemInfo.IsNote || MyItemInfo.IsCaution) && MyItemInfo.MyParent.IsRNOPart) || MyItemInfo.IsRNOPart) - { - ItemInfo ip = MyItemInfo.MyParent; - while (ip.IsRNOPart) ip = ip.MyParent; - myMsg = myMsg.Replace(@"%sR", ip.CombinedTab); - } - // B2020-154: Incorrect top continue message tab in RNO column if for single level substep with a Caution/Note - else if ((MyItemInfo.IsNote || MyItemInfo.IsCaution) && MyItemInfo.MyParent.MyParent.IsRNOPart) - { - if (DebugPagination.IsOpen) DebugPagination.WriteLine("***===>,'Yes','Case 1:Changed RNO Continue Message',{0},{1},,{3},'{4}'", MyItemInfo.ItemID, YSize, 0, 0, this); - ItemInfo ip = MyItemInfo.MyParent; - while (!ip.IsRNOPart) ip = ip.MyParent; - myMsg = myMsg.Replace(@"%sR", ip.CombinedTab); - } - // B2020-154: Incorrect top continue message tab in RNO column for substep with a Caution/Note within parent substeps - else if ((MyItemInfo.IsNote || MyItemInfo.IsCaution) && MyItemInfo.MyParent.MyParent.IsInRNO) - { - if (DebugPagination.IsOpen) DebugPagination.WriteLine("***===>,'Yes','Case 2:Changed RNO Continue Message',{0},{1},,{3},'{4}'", MyItemInfo.ItemID, YSize, 0, 0, this); - myMsg = myMsg.Replace(@"%sR", MyItemInfo.MyParent.MyParent.CombinedTab); - } - else - myMsg = myMsg.Replace(@"%sR", MyItemInfo.MyParent.CombinedTab); - float xor = MyTopRNO.MyTab.XOffset; - MyPageHelper.TopMessageRs.Add(new vlnText(cb, this, myMsg, myMsg, xor, yTopMargin + 0.1F, docstyle.Continue.Top.Font)); - // get aer message, go up parent until find aer and use its combined tab: - myAer = MyItemInfo; - while (myAer.IsInRNO) myAer = myAer.MyParent; - } - else if (!MyItemInfo.IsHigh && (MyItemInfo.IsNote || MyItemInfo.IsCaution)) - { - ItemInfo ip1 = MyItemInfo.MyParent; - if (!ip1.IsHigh) myAer = ip1.MyParent; - } - myMsg = docstyle.Continue.Top.Message.Replace(@"%sR", myAer.CombinedTab); - } - if (myMsg.IndexOf(@"%s") > -1) - { - if (MyItemInfo.MyParent.IsSection && (docstyle.StructureStyle.Style & E_DocStructStyle.BottomSectionContinue) == E_DocStructStyle.BottomSectionContinue) - myMsg = myMsg.Replace(@"%s", MyItemInfo.MyParent.MyTab.CleanText.Trim()); - else - { - // F2020-023: tab includes parent tab and if caution/note don't use its parent, go up another level - string noBullet = MyItemInfo.IsCautionOrNotePart ? MyItemInfo.MyParent.MyParent.CombinedTab : MyItemInfo.MyParent.CombinedTab; - // F2026-002 Vogtle Units 3&4, don't include the RNO sub-step tab if the parent is an AER sub-step - if (docstyle.Continue.Top.DontIncludeRNOTabIfHasAERParent && MyItemInfo.MyParent.IsRNOPart && !MyItemInfo.MyParent.MyParent.IsRNOPart) - noBullet = MyItemInfo.MyParent.MyParent.CombinedTab; - // C2021-024: WCN1 if bullet exists in combined tab, stop right before bullet. - // B2021-085 & 087: crash if noBullet was null. Also, if null, see if text in parent. if no text, replace the - // "%s." with noBullet (null) which won't put out just a '.' as step number. - if (docstyle.Continue.Top.RemoveBullet) - { - if (noBullet == null && MyItemInfo.IsCautionOrNotePart) noBullet = MyItemInfo.MyParent.CombinedTab; - if (noBullet != null) - { - int ind = noBullet.IndexOf(".o"); - if (ind < 0) ind = noBullet.IndexOf(".*"); - if (ind > -1) noBullet = noBullet.Substring(0, ind); - } - else - { - myMsg = myMsg.Replace(@"%s.", noBullet); - } - } - myMsg = myMsg.Replace(@"%s", noBullet); - } - } - if (myMsg.IndexOf(@"%3d") > -1) - myMsg = myMsg.Replace(@"%3d", MyItemInfo.MyHLS.Ordinal.ToString()); - if (myMsg.IndexOf(@"%2d") > -1) - myMsg = myMsg.Replace(@"%2d", MyItemInfo.MyHLS.MyTab.CleanTextNoSymbols.Trim(" .".ToCharArray()).PadLeft(2)); - if (myMsg.IndexOf(@"%d") > -1) - myMsg = myMsg.Replace(@"%d", MyItemInfo.MyHLS.MyTab.CleanTextNoSymbols.Trim(" .".ToCharArray())); - if (myMsg.IndexOf(@"%c") > -1) - myMsg = myMsg.Replace(@"%c", " "); - - // Top Continue message includes high level step tab and text - if ((docstyle.Continue.Top.HLS ?? 0) == 1) - { - myMsg = docstyle.Continue.Top.Message; // reset because we did replace strings in code above - ItemInfo parentStep = MyItemInfo.MyHLS; // get the high level step - myMsg = string.Format(myMsg, parentStep.CombinedTab, parentStep.DisplayTextKeepSpecialChars); - } - // B2023-115 Top continue message for Vogtle Alarms: 1st version done on 12/6/23. Changes to logic as per request - // from engineering done on 12/12/23. See comment below for logic for 12/12/23 (history of this file has previous - // logic) - if (((docstyle.Continue.Top.HLS ?? 0) == 4) || ((docstyle.Continue.Top.HLS ?? 0) == 7)) - { - // Vogtle Alarms: Their alarms are set up differently than standard procedures - the HLS in Vogtle - // alarms is a section in other procedures. The top continue message is shown when a break occurs: - // • A continued message will appear on the top of the page ONLY if the pagination occurs anywhere - // within the first level substep. If, for example, the page break occurs between substep 3 and substep - // 4 as in example 2, no continued message will appear on the top of the page. - // • If a continued message is needed, the continued message will include the first level substep number - // if it is a sequential substep, such as “5. (continued)”. If it is NOT a sequential substep, then only - // the word “(continued)” will appear. - // • If a page break occurs between high level steps, such as before “Causes:”, then no continued message is needed. - - // F2024-027 & F2024-028 - // Vogtle Units 3&4 needed similar top continue messages in the Local Alarms attachments as they have for the MCR Alarm point pages - // with the exception that when High Level Step (grouping text) is split and continued to the next page, the top continue message - // needs to be the HLS text with "(continued)" appended to it. - // Added a TOP.HLS value of 7 to allow for this minor difference and is set in the docstyle for that section - - bool doMessage = true; - if (MyItemInfo.IsHigh) doMessage = false; // at high, don't do message - if (MyItemInfo.MyParent.IsHigh) doMessage = false; // at first level, don't do message - // Caution/Note on first level, don't do message - if ((MyItemInfo.IsCaution || MyItemInfo.IsNote) && MyItemInfo.MyParent.MyParent.IsHigh) doMessage = false; - myMsg = docstyle.Continue.Top.Message; - if (doMessage) - { - // Get to highest level below HLS - ItemInfo cur = MyItemInfo; - while (!cur.MyParent.IsHigh) cur = cur.MyParent; - // if sequential, add on step number, otherwise just put out message: - myMsg = !cur.IsSequential ? myMsg : cur.CombinedTab + ". " + myMsg; - } - // F2024-027 & F2024-028 added else if to check of the case where we want to use the High Level Step text in the top continue message - else if (((docstyle.Continue.Top.HLS ?? 0) == 7) && MyItemInfo.MyParent != null && MyItemInfo.MyParent.IsHigh) - { - myMsg = MyItemInfo.MyParent.DisplayText + " " + myMsg; - } - else // if not doing message, clear it & set yPageStart back to what it was before handling message - { - myMsg = ""; - yPageStart += 2 * SixLinesPerInch; - } - } - // B2021-138: Top continue message for Barakah Single column New (2021) format was incorrect for some lower - // sub-steps. - if ((docstyle.Continue.Top.HLS ?? 0) == 6) - { - myMsg = docstyle.Continue.Top.Message; // reset because we did replace strings in code above - ItemInfo parentStep = MyItemInfo.MyHLS; - string ctab = parentStep.CombinedTab; - if (!MyItemInfo.MyParent.IsHigh) // If lower sub-step, get parent substep tab, skipping caution/note if in one of those - ctab = (MyItemInfo.IsInCautionOrNote) ? MyItemInfo.MyParent.MyParent.CombinedTab : MyItemInfo.MyParent.CombinedTab; - myMsg = string.Format(myMsg, ctab, parentStep.DisplayTextKeepSpecialChars); - } - // Calvert Alarms, step description have the alarm number as part of the top continue message - // Also, if the break is within the CONDITION/RESPONSE, there are continue messages in both columns at the top - // of the table, note that the continue messages WITHIN table are only printed when the - // steplevel is greater than 2 - this is from 16bit. - // NOTE THAT this code is not complete - the positioning & addition of step tab for within table are not working correctly - if ((docstyle.Continue.Top.HLS ?? 0) == 3) - { - MyPageHelper.TopMessageSub1s = new List(); - MyPageHelper.TopMessageSub2s = new List(); - - //string HLSTabTextForContMsg = MyHighLevelParagraph.MyItemInfo.MyTab.CleanText + " " + MyHighLevelParagraph.MyItemInfo.MyContent.Text; - //int len = (HLSTabTextForContMsg.Length - 10) * 6; - string tabText = @"\ul\b " + MyHighLevelParagraph.MyItemInfo.MyTab.CleanText.Trim() + @"\b0\ulnone"; - // B2017-185: added the replace of unicode dash to regular dash for the continue message so it matches the step text: - string stepText = @"\b " + MyHighLevelParagraph.MyItemInfo.MyContent.Text.Replace(@"\u8209?", "-") + @"\b0"; - //HLSTabTextForContMsg = @"\ul\b " + MyHighLevelParagraph.MyItemInfo.MyTab.CleanText.Trim() + @"\b0\ulnone \b " + MyHighLevelParagraph.MyItemInfo.MyContent.Text + @"\b0"; - vlnText vt1 = new vlnText(cb, this, tabText, tabText, MyHighLevelParagraph.MyTab.XOffset, yTopMargin + 0.1F, docstyle.Continue.Top.Font); - vt1.Width = MyHighLevelParagraph.MyTab.Width; - MyPageHelper.TopMessageRs.Add(vt1); - vlnText vt2 = new vlnText(cb, this, stepText, stepText, MyHighLevelParagraph.XOffset, yTopMargin + 0.1F, docstyle.Continue.Top.Font); - vt2.Width = MyHighLevelParagraph.Width; - MyPageHelper.TopMessageRs.Add(vt2); - - // the following code is used to print the top continue messages in the Calvert Alarm format - // CONDITION/RESPONSE table. Messages only get printed if the break is on a substep at steplevel > 2. - // see comments within code for what the tab contains, it varies depending on which side - // break occurred & how deep in the step the break occurred. - if (subTab != null && MyItemInfo.StepLevel > 2) { - bool incond = !MyItemInfo.IsInRNO; - float ybot = yTopMargin + (4 * SixLinesPerInch); - string concatrnoTab = ""; // constructed tab for Response side - string concataerTab = ""; // constructed tab for Condition side - float xoffTab = 0; // position for Response tab - float xoffMsg = 0; // position for Response message - vlnParagraph useAerParaForTab = null; // use this paragraph under Conditions for locating tab & message - if (incond) - { - // If break is in Condition side of table, use Condition tab of parent & no tab for Response side. - // Both sides have the message '(continued)'. - useAerParaForTab = MyParent; - concataerTab = MyParent.MyTab != null ? MyParent.MyTab.Text.TrimEnd() : ""; - xoffTab = 0; // no rno tab - xoffMsg = ToInt(MyItemInfo.ActiveFormat.MyStepSectionLayoutData.ColRTable, 1) + (float)MyItemInfo.MyDocStyle.Layout.LeftMargin + ((useAerParaForTab != null && useAerParaForTab.MyTab != null) ? useAerParaForTab.MyTab.Width : 7.2f); - } - else - { - // break occurred in Response side. Use the tabs up to highest RNO concatenated together. - vlnParagraph useRnoParaForTab = MyParent; - vlnParagraph useParaForTab = MyParent; - while (useParaForTab.MyItemInfo.IsInRNO) - { - concatrnoTab = (useParaForTab.MyTab != null ? useParaForTab.MyTab.Text.TrimEnd() : "") + concatrnoTab.Trim(); - if (concatrnoTab.Length > 0 && concatrnoTab[0] > '\xff') concatrnoTab = ""; - useRnoParaForTab = useParaForTab; - useParaForTab = useParaForTab.MyParent; - } - xoffTab = useRnoParaForTab.MyTab.XOffset; - xoffMsg = useRnoParaForTab.XOffset; - - // aer message when rno broke. Need to concatenate up the Condition side also until - // hitting 1st non-sequential, i.e. moves out of Condition/Response table. - useAerParaForTab = useParaForTab; // useParaForTab is 1st found non-Response step, i.e. moved into Condition side of table - while (useParaForTab.MyItemInfo.IsSequential) - { - concataerTab = (useParaForTab.MyTab != null ? useParaForTab.MyTab.Text.TrimEnd() : "") + concataerTab.Trim(); - useAerParaForTab = useParaForTab; - useParaForTab = useParaForTab.MyParent; - } - } - // For RNO tab, add a vlntext for tab and one for continue message: - float xoff1 = xoffMsg; - if (!incond) - { - vlnText vtc = new vlnText(cb, this, concatrnoTab, concatrnoTab, xoffTab, ybot, docstyle.Continue.Bottom.Font); - MyPageHelper.TopMessageSub1s.Add(vtc); - Chunk chk = (vtc.IParagraph.Chunks[0]) as Chunk; - if (chk != null) - { - float xoff2 = xoffTab + chk.GetWidthPoint() + 6; - // If the "(continue)" is going to overlap the tab, then move the "Continue)" so that it doesn't overlap. - if (xoff2 > xoff1) xoff1 = xoff2; - } - } - MyPageHelper.TopMessageSub1s.Add(new vlnText(cb, this, myMsg, myMsg, xoff1, ybot, docstyle.Continue.Bottom.Font)); - - // for aer tab, add a vlntext for tab and one for continue message: - MyPageHelper.TopMessageSub2s.Add(new vlnText(cb, this, concataerTab, concataerTab, useAerParaForTab.MyTab.XOffset, ybot, docstyle.Continue.Bottom.Font)); - MyPageHelper.TopMessageSub2s.Add(new vlnText(cb, this, myMsg, myMsg, useAerParaForTab.XOffset, ybot, docstyle.Continue.Bottom.Font)); - addExtraLine = true; - } - } - if (!PageBreakOnStep) - { - float colPos = docstyle.Layout.LeftMargin + docstyle.Continue.Top.Margin ?? 0; - if (!docstyle.Continue.Top.PlaceAtLeftMargin) //F2019-033 when true position with respect only to the left margin - colPos += XOffsetBox; //XOffsetbox get set when the tables, figures & equations were beyond the border and needed repositioned - // C2019-044 for BNPP, put the top continue message on the same row as the checkoff/signoff heading - // RowOverride specifies the position of the top continue message - // For BNPP, RowOverride is set to the same row as the checkoff header is set to in the pagelist - if (docstyle.Continue.Top.RowOverride != null) - { - float adjRowPosition = (float)docstyle.Layout.TopMargin - (float)docstyle.Continue.Top.RowOverride; - MyPageHelper.TopMessage = new vlnText(cb, this, myMsg, myMsg, colPos, yTopMargin + 0.1F + adjRowPosition, docstyle.Continue.Top.Font);// MyItemInfo.ActiveFormat.PlantFormat.FormatData.Font); - } - else - MyPageHelper.TopMessage = new vlnText(cb, this, myMsg, myMsg, colPos, yTopMargin + 0.1F, docstyle.Continue.Top.Font);// MyItemInfo.ActiveFormat.PlantFormat.FormatData.Font); - - } - else - MyPageHelper.TopMessage = null; - } - return addExtraLine; - } - - private void DoBottomContinueMsg(PdfContentByte cb, float yBottomMargin, float yLocation, DocStyle docstyle, bool doThreeContinues) - { - // Console.WriteLine("Page {0} - yLocation {1}", cb.PdfWriter.PageNumber, yLocation); - string myMsg = docstyle.Continue.Bottom.Message; - - // a format flag exists that states to only put a BOTTOM message if it is a certain type (RNO) - // check for this.... - bool RNOContinueOnly = MyItemInfo.ActiveFormat.PlantFormat.FormatData.StepDataList[40].ContinueOnly; - bool doBottom = !RNOContinueOnly || (MyItemInfo.IsInRNO && RNOContinueOnly); - if (doBottom && myMsg != null && myMsg != "") - { - myMsg = ReplaceStepBottomContinue(myMsg); - float msg_yLocation = 0; - if (myMsg.Contains("{par}")) - { - myMsg = myMsg.Replace("{par}", ""); - msg_yLocation = -SixLinesPerInch; - } - float yBtmMarginForMsg = yBottomMargin; - - // one of the format flags for FNP had an adjustment for printing the section title only - // on the first page of the section. Adjust the location of the bottom continue message - // if this adjustment was made (the current topmargin may not reflect the value within - // the document style) - if (MyPageHelper.PrintedSectionPage > 0) - { - if (MyItemInfo.ActiveSection != null && (MyItemInfo.ActiveSection.MyDocStyle.StructureStyle.Style & E_DocStructStyle.DSS_PrintSectOnFirst) == E_DocStructStyle.DSS_PrintSectOnFirst) // C2018-003 fixed use of getting the active section - { - float localYTopMargin = PDFPageSize.PaperSizePoints(MyItemInfo.ActiveFormat.PlantFormat.FormatData.PDFPageSize.PaperSize) - (float)MyItemInfo.ActiveSection.MyDocStyle.Layout.TopMargin; // C2020-002 paper size is now set in the format files - yBtmMarginForMsg = Math.Max(0, localYTopMargin - (float)MyItemInfo.ActiveSection.MyDocStyle.Layout.PageLength); - } - } - // include space for phone list when determining bottom continue message location - if (MyItemInfo.ActiveFormat.PlantFormat.FormatData.SectData.PrintPhoneList && MyPageHelper.PhoneListHeight != 0) - yBtmMarginForMsg += (MyPageHelper.PhoneListHeight - vlnPrintObject.SixLinesPerInch); - // B2019-079: Account for compression when locating the bottom continue message - if (MyPageHelper.YMultiplier != 1) - { - //float topOfPage = PDFPageSize.PaperSizePoints(MyItemInfo.ActiveFormat.PlantFormat.FormatData.PDFPageSize.PaperSize) - (float)MyItemInfo.MyDocStyle.Layout.TopMargin; // A4 paper logic - float topOfPage = 792 - (float)MyItemInfo.MyDocStyle.Layout.TopMargin; - yLocation = topOfPage - (topOfPage - yLocation) * MyPageHelper.YMultiplier; - } - switch (docstyle.Continue.Bottom.Location) - { - case E_ContBottomLoc.EndOfText: // place continue string at end of text - // msg_yLocation accounts for extra lines in message from docstyle; and BottomContent is the actual - // location of the last line of text on page. - //msg_yLocation = ((float)(MyPageHelper.BottomContent??0) - (SixLinesPerInch * MyPageHelper.YMultiplier)); // B2018-080 null reference check added - // B2019-079 changed yLocaton - msg_yLocation to '+'. The msg_ylocation has an adjustment for adding an extra line by moving down the page, this was moving - // the line up the page (double negative). - msg_yLocation = yLocation + msg_yLocation - (SixLinesPerInch * MyPageHelper.YMultiplier); //B2019-021 yLocation accounts for checkoffs - if (yBottomMargin + (docstyle.Layout.FooterLength ?? 0) > msg_yLocation) - { // Adjusted Continue Message Y Offset - //DebugPagination.WriteLine("====>> {0},'{1}'", msg_yLocation, MyItemInfo.ShortPath); - //msg_yLocation = (float) MyPageHelper.BottomContent - SixLinesPerInch; // Account for how low the lowest Item is on the page - float msg_yLocationOld = msg_yLocation = yBottomMargin + (docstyle.Layout.FooterLength ?? 0); - if (MyPageHelper.BottomContent != null) - msg_yLocation = Math.Min(yBottomMargin + (docstyle.Layout.FooterLength ?? 0), (float)MyPageHelper.BottomContent - SixLinesPerInch);// RHM20150525 - Table Scrunch - if (msg_yLocationOld != msg_yLocation) - _MyLog.WarnFormat("Continue Message Moved from {0} to {1} for {2}", msg_yLocationOld, msg_yLocation, this);// RHM20150525 - Table Scrunch - } - break; - case E_ContBottomLoc.BtwnTextAndBottom: // place continue string between end of text & bottom of page - msg_yLocation = msg_yLocation + yLocation - ((yLocation - yBottomMargin) / 2); // +SixLinesPerInch; // (need this for IP3) - msg_yLocation = Math.Max(msg_yLocation, yBottomMargin + SixLinesPerInch); - break; - case E_ContBottomLoc.BottomOfPage: // place continue message at bottom of page - //msg_yLocation = yBottomMargin + 2 * SixLinesPerInch + (float)docstyle.Layout.FooterLength; // 2 lines above bottom margin - msg_yLocation = msg_yLocation + yBtmMarginForMsg + (float)docstyle.Layout.FooterLength; - // if (MyPageHelper.YMultiplier != 1.0F) msg_yLocation = msg_yLocation / MyPageHelper.YMultiplier; - break; - case E_ContBottomLoc.BelowBottom1: - msg_yLocation = msg_yLocation + yBtmMarginForMsg; - break; - case E_ContBottomLoc.BottomWithFooter: // put bottom message AND if in CONDITION/RESPONSE table, in both columns. - msg_yLocation = msg_yLocation + yBtmMarginForMsg; - break; - case E_ContBottomLoc.EndOfText2: // Like EndOfText but limited within yBottomMargin - msg_yLocation = Math.Max(msg_yLocation + yLocation - SixLinesPerInch, yBottomMargin + SixLinesPerInch); - break; - case E_ContBottomLoc.BtwnTextAndBottom2: - // Like BtwnTextAndBottom but accounts for line spacing of step & is 1 line up on page (for BGE - Procedure Steps - 2 column) - float adj = (!MyItemInfo.IsSection && MyItemInfo.FormatStepData.StepLayoutData.EveryNLines == 1) ? SixLinesPerInch : 0; - msg_yLocation = msg_yLocation + yLocation - ((yLocation - yBottomMargin) / 2) + adj;// +SixLinesPerInch; - if (msg_yLocation < yBottomMargin) msg_yLocation = yBottomMargin; - break; - default: - _MyLog.WarnFormat("**** BOTTOM CONTINUE MESSAGE NOT CODED FOR LOCATION {0}*****", docstyle.Continue.Bottom.Location); - break; - } - if (!PageBreakOnStep) - { - float xoffB = 0; - // Added for Calvert Alarms: if 'doThreeContinues', continue message at bottom of page - // and a continue message at the bottom of each column. - if (doThreeContinues) - { - float ybot = yLocation; - xoffB = (float)docstyle.Layout.LeftMargin + docstyle.Continue.Bottom.Margin ?? 0; - MyPageHelper.BottomMessageA = new vlnText(cb, this, myMsg, myMsg, xoffB, ybot, docstyle.Continue.Bottom.Font); - xoffB = docstyle.Layout.LeftMargin + docstyle.Continue.Bottom.MarginR ?? 0; - MyPageHelper.BottomMessageR = new vlnText(cb, this, myMsg, myMsg, xoffB, ybot, docstyle.Continue.Bottom.Font); - MyPageHelper.AlarmYoffEnd -= SixLinesPerInch; - float tmp = (((float)docstyle.Layout.PageWidth - (float)docstyle.Layout.LeftMargin) / 2) - (myMsg.Length / 2 * 5); - xoffB = (float)docstyle.Layout.LeftMargin + tmp; - } - else if (docstyle.Continue.Bottom.Location == E_ContBottomLoc.BottomWithFooter) - { - float tmp = (((float)docstyle.Layout.PageWidth - (float)docstyle.Layout.LeftMargin) / 2) - (myMsg.Length / 2 * 5); - xoffB = (float)docstyle.Layout.LeftMargin + tmp; - } - else if (RNOContinueOnly) - { - // The following line was added for McGuire APs/AP/1/5500/12, Step 13 - //if (msg_yLocation < yBottomMargin + SixLinesPerInch) msg_yLocation = yBottomMargin + SixLinesPerInch; - float colR = float.Parse(MyItemInfo.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.StepSectionLayoutData.ColRTable.Split(",".ToCharArray())[MyItemInfo.ColumnMode]); - xoffB = colR + docstyle.Layout.LeftMargin + docstyle.Continue.Bottom.Margin ?? 0; - } - else if (MyItemInfo.IsInRNO && (docstyle.Continue.Bottom.MarginR ?? 0) > 0) - { - xoffB = (float)docstyle.Layout.LeftMargin + (float)docstyle.Continue.Bottom.MarginR; - MyPageHelper.BottomMessageR = new vlnText(cb, this, myMsg, myMsg, xoffB, msg_yLocation, docstyle.Continue.Bottom.Font); - xoffB = (float)docstyle.Layout.LeftMargin + (float)docstyle.Continue.Bottom.Margin; - - } - // FloatingContinueMessage format flag: - // if breaking at the AER put continue message in left column, - // if breaking RNO put continue message in Right column. - else if (MyItemInfo.IsInRNO && MyItemInfo.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.FloatingContinueMessage) - { - float colR = float.Parse(MyItemInfo.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.StepSectionLayoutData.ColRTable.Split(",".ToCharArray())[MyItemInfo.ColumnMode]); - xoffB = colR + docstyle.Layout.LeftMargin + docstyle.Continue.Bottom.Margin ?? 0; - } - else - xoffB = docstyle.Layout.LeftMargin + docstyle.Continue.Bottom.Margin ?? 0; - //MyPageHelper.BottomMessage = new vlnText(cb, this, myMsg, myMsg, docstyle.Layout.LeftMargin + XOffsetBox + docstyle.Continue.Bottom.Margin ?? 0, msg_yLocation, docstyle.Continue.Bottom.Font);// MyItemInfo.ActiveFormat.PlantFormat.FormatData.Font); - MyPageHelper.BottomMessage.Clear(); // B2017-207 should be only one continue message - was putting an extra continue message in middle of page for V.S.Summer (ex. AOP set, 900.4 Attachment 12) - MyPageHelper.BottomMessage.Add(new vlnText(cb, this, myMsg, myMsg, xoffB, msg_yLocation, docstyle.Continue.Bottom.Font)); - } - } - if (PageBreakOnStep) MyPageHelper.BottomMessage.Clear(); - } - - private void RefreshDocStyle() - { - MyItemInfo.ActiveSection = null; - MyItemInfo.MyDocStyle = null; - MyPageHelper.MySection = MyItemInfo as SectionInfo; - MyPageHelper.ResetSvg(); - MyPageHelper.PrintedSectionPage = 0; - } - - private string ReplaceStepBottomContinue(string myMsg) - { - string tb = null; - if (MyItemInfo.IsSection) - tb = MyItemInfo.MyTab.CleanText.Trim(); - else - tb = MyItemInfo.MyHLS.MyTab.CleanTextNoSymbols; - // if the tab ends with .0, remove it if it was added because of the virtualdotinhls flag. - if (MyItemInfo.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.StepSectionLayoutData.VirtualDotInHLSTab && tb.Contains(".0")) tb = tb.Replace(".0", ""); - if (myMsg.IndexOf(@"%d") > -1) - myMsg = myMsg.Replace(@"%d", tb.Trim()); - if (myMsg.IndexOf(@"%0d") > -1) - myMsg = myMsg.Replace(@"%0d", tb.Trim(" .".ToCharArray())); - if (myMsg.IndexOf(@"%2d") > -1) - myMsg = myMsg.Replace(@"%2d", tb.Trim(" .".ToCharArray()).PadLeft(2)); - if (myMsg.IndexOf(@"%3d") > -1) - myMsg = myMsg.Replace(@"%3d", MyItemInfo.MyHLS.Ordinal.ToString()); - // F2020-023: tab includes parent tab and if caution/note don't use its parent, go up another level - if (myMsg.IndexOf(@"%s") > -1) // %s was added for F2020-023 - { - string tmp = tb.Trim(); - if (!MyItemInfo.MyParent.IsHigh) - { - tmp = MyItemInfo.IsCautionOrNotePart ? MyItemInfo.MyParent.MyParent.CombinedTab : MyItemInfo.MyParent.CombinedTab; - // C2021-024: WCN1 if bullet exists in combined tab, stop right before bullet. - // B2021-085 & 087: crash if noBullet was null. Also, if null, see if text in parent. if no text, replace the - // "%s." with noBullet (null) which won't put out just a '.' as step number. - if (MyItemInfo.MyDocStyle.Continue.Bottom.RemoveBullet) - { - if (tmp == null && MyItemInfo.IsCautionOrNotePart) tmp = MyItemInfo.MyParent.CombinedTab; - if (tmp != null) - { - int ind = tmp.IndexOf(".o"); - if (ind < 0) ind = tmp.IndexOf(".*"); - if (ind > -1) tmp = tmp.Substring(0, ind); - } - else - { - myMsg = myMsg.Replace(@"%s.", tmp); - } - } - } - myMsg = myMsg.Replace(@"%s", tmp); - } - return myMsg; - } - private vlnParagraph TopMostChild - { - get - { - if (ChildrenAbove.Count > 0) return ChildrenAbove[0].TopMostChild; - return this; - } - } - private bool EmptyTopMostPart - { - get - { - if (TopMostChild.PartsAbove.Count == 0) return false; - if (TopMostChild.PartsContainer != null && TopMostChild.PartsContainer.Count > 0) return false; // B2016-198: not 'EmptyTopMostPart' if there is a box. - foreach (vlnPrintObject po in TopMostChild.PartsAbove) - { - vlnHeader hd = po as vlnHeader; - if (hd == null) return false; - if (hd.Text != "") return false; - } - return true; - } - } - // B2019-115 Locate Bottom Continue Message below AER Table if necesssary - private float _TableBottom = -1; - public float TableBottom - { - get { return _TableBottom; } - set { _TableBottom = value; } - } - private float OutputOtherPageSteps(PdfContentByte cb, float YTopMost, float yPageStart, float yTopMargin, float yBottomMargin) - { - // B2019-115 Locate Bottom Continue Message below AER Table if necessary - Initialize TableBottom to -1 - TableBottom = -1; - float retval = YTopMost; - // Find any items remaining in MyPageHelper.MyParagraphs that should be printed on this page. - vlnParagraphs process = new vlnParagraphs(null); - int processed = 0; - foreach (vlnParagraph vPara in MyPageHelper.MyParagraphs.Values) - { - if (!vPara.Processed) - { - if (vPara.MyItemInfo.IsTable && (vPara.YOffset <= YTopMost) && vPara.MyItemInfo.ActiveSection.ColumnMode > 0 && vPara.Height + yBottomMargin < yPageStart - vPara.YOffset) //B2019-120 Byron ELEC-1 step 3 second table was not printing on following page - { - if (this.MyItemInfo.ItemID != vPara.MyItemInfo.ItemID) - { - // B2019-115 Locate Bottom Continue Message below AER Table if necessary - _MyLog.WarnFormat("\r\n=-=-=> Table Print on First Page {0} {1} ColumnMode = {2}", vPara.MyItemInfo.ItemID, vPara.MyItemInfo.ShortPath, vPara.MyItemInfo.ActiveSection.ColumnMode); - process.Add(vPara); - // Console.WriteLine("Table YOffset {0} height {1} Bottom = {2} yPageStart = {3} Bottom {4}", vPara.YOffset, vPara.Height, vPara.YOffset + vPara.Height - yPageStart, yPageStart, this.YBottom); - } - } - else if (((vPara.YOffset + vPara.Height) < YTopMost)) - { - // B2019-028: Added check for active section in next line so that following section text doesn't overlap or start too far down on page for case where there is a subsection - // with subsections of type Step/Word/Step - //if (vPara.MyItemInfo.ActiveSection.ItemID == this.MyItemInfo.ActiveSection.ItemID && (this.MyItemInfo.ItemID != vPara.MyItemInfo.ItemID)) // 20150701 Complicated RNO change - if (this.MyItemInfo.ItemID != vPara.MyItemInfo.ItemID) - { - // B2019-077: 2.0 SCOPE empty section not printing for WES (revert to previous code line versus above) - process.Add(vPara); - } - else // 20150701 Complicated RNO change - _MyLog.WarnFormat("Less Than: Step Could Have Fit {0}, {1}", MyItemInfo.ItemID, MyItemInfo.ShortPath); - } - else if (((vPara.YOffset + vPara.Height) == YTopMost)) - { - - // B2019-028: see above comment (same check was added) - //if (vPara.MyItemInfo.ActiveSection.ItemID == this.MyItemInfo.ActiveSection.ItemID && (this.MyItemInfo.ItemID != vPara.MyItemInfo.ItemID)) // RHM20150507 Table Scrunch - if (this.MyItemInfo.ItemID != vPara.MyItemInfo.ItemID) // B2019-077: see above - { - process.Add(vPara); - _MyLog.WarnFormat("New AerRno PageBreak Logic: Step Could Have Fit {0}, {1}", MyItemInfo.ItemID, MyItemInfo.ShortPath); - } - else // RHM20150507 Table Scrunch - _MyLog.WarnFormat("Equal: Step Could Have Fit {0}, {1}", MyItemInfo.ItemID, MyItemInfo.ShortPath); - } - else if (((vPara.YOffset) < YTopMost)) - { - retval = Math.Min(retval, vPara.YTopMost); - } - } - else - processed++; - } - //Console.WriteLine("~~~ {0} has {1} Steps {2} Processed {3} to Process", MyItemInfo.ShortPath, MyPageHelper.MyParagraphs.Count - // , processed,process.Count); - foreach (vlnParagraph vPara in process) - { - vPara.ParagraphToPdf(cb, yPageStart, yTopMargin, yBottomMargin); - // B2019-115 Locate Bottom Continue Message below AER Table if necessary - if(vPara.MyItemInfo.IsTable) - { - if (TableBottom == -1) - TableBottom = (yPageStart-vPara.YOffset)-vPara.Height- SixLinesPerInch; - else - TableBottom = Math.Min(TableBottom, (yPageStart - vPara.YOffset) - vPara.Height - SixLinesPerInch); - } - } - return retval; - } - private float _YVeryTop = -1; - public float YVeryTop - { - get - { - if (_YVeryTop == -1) - { - _YVeryTop = YTop; - _YVeryTop = VeryTop(PartsAbove, _YVeryTop); - _YVeryTop = VeryTop(PartsContainer, _YVeryTop); - } - return _YVeryTop; - } - } - - private float VeryTop(vlnPrintObjects parts, float yVeryTop) - { - if (parts != null) - foreach (vlnPrintObject part in parts) - if (part.YOffset < yVeryTop) - yVeryTop = part.YOffset; - return yVeryTop; - } - /// - /// This gets the height of the step with it's Caution's, Notes and potentially any First Substeps - /// - /// - // F2024-006: Vogtle Alarms pagination - added 'includeFirstSub' to get that size of the first substep with the parent step - // to help determine pagination - private float GetFirstPieceSize(bool includeFirstSub = false) - { - vlnParagraph paraLast = GetFirstPieceLastPart(includeFirstSub); - float retval = (paraLast.YBottom) - YTopMost; - //Console.WriteLine(MyItemInfo.DBSequence); - return retval; - } - public override float YBottom - { - get - { - float bottom = YOffset + Height; - if (PartsBelow != null) - { - foreach (vlnPrintObject part in PartsBelow) - { - float partBottom = part.YBottom; - bottom = Math.Max(partBottom, bottom); - } - } - return bottom; - } - } - public float YVeryBottom - { - get - { - float bottom = YOffset + Height; - if (ChildrenBelow != null) - foreach (vlnParagraph child in ChildrenBelow) - bottom = Math.Max(child.YVeryBottom, bottom); - if (ChildrenLeft != null) - foreach (vlnParagraph child in ChildrenLeft) - bottom = Math.Max(child.YVeryBottom, bottom); - if (ChildrenRight != null) - foreach (vlnParagraph child in ChildrenRight) - bottom = Math.Max(child.YVeryBottom, bottom); - if (PartsBelow != null) - foreach (vlnPrintObject part in PartsBelow) - bottom = Math.Max(part.YBottom, bottom); - return bottom; - } - } - public float YBottomText - { - get - { - return YOffset + Height; - } - } - private float _YBottomForBox = 0; - public float YBottomForBox - { - get { return _YBottomForBox; } - set { _YBottomForBox = value; } - } - // F2024-006: Vogtle Alarms pagination - added 'includeFirstSub' to get that size of the first substep with the parent step - // to help determine pagination - even when PaginateOnFirstSubstep is turned on - private vlnParagraph GetFirstPieceLastPart(bool includeFirstSub = false) - { - vlnParagraph para = this; - if ((!MyItemInfo.ActiveFormat.MyStepSectionLayoutData.PaginateOnFirstSubstep || includeFirstSub) && ChildrenBelow != null && ChildrenBelow.Count > 0) - { - // If the substep has a separator (OR, AND) then return the last substep rather than the first. - string mySep = ChildrenBelow[0].MyItemInfo.FormatStepData.Sep ?? "{Null}"; - if (mySep != "{Null}" && mySep != "") - para = ChildrenBelow[ChildrenBelow.Count - 1].GetFirstPieceLastPart(); - else - { - // MNS Pagination - Mike Weiner Case 1a to keep step together with any non-sequential substeps (ANDs, EQ List) - bool keepEqListTogether = ChildrenBelow[0].MyItemInfo.ActiveFormat.MyStepSectionLayoutData.PutOnPageByItself; - if (keepEqListTogether && !ChildrenBelow[0].MyItemInfo.IsSequential && !this.MyItemInfo.IsHigh) // Extend to the last Item. - para = ChildrenBelow[ChildrenBelow.Count - 1].GetFirstPieceLastPart(); - else - para = ChildrenBelow[0].GetFirstPieceLastPart(includeFirstSub); - } - } - if (ChildrenRight != null && ChildrenRight.Count > 0) - { - foreach (vlnParagraph paraRight in ChildrenRight) - { - vlnParagraph paraRightLast = paraRight.GetFirstPieceLastPart(includeFirstSub); - if (paraRightLast.YBottom > para.YBottom) - para = paraRightLast; - } - } - return para; - } - /// - /// Find items from previous page (yLocation less than yTop) and remove them from the list. - /// yTop is the new starting location on the next page for this step. - /// - /// - /// - private void RemoveProcessedParagraphs(StepLevelList myList, float yTop) - { - // the two CleanUpLists are used to remove items from - // the original list because list items cannot be removed in a - // 'foreach'. - List CleanupListStepLevel = new List(); - foreach (int stepLevel in myList.Keys) - { - List CleanupListYLocation = new List(); - SortedList AdjustYLocation = new SortedList(); - foreach (float yLocation in myList[stepLevel].Keys) - { - if (-yLocation <= yTop) - CleanupListYLocation.Add(yLocation); - else - AdjustYLocation.Add(-yLocation, yLocation); // order in ascending order - } - foreach (float yLocation in CleanupListYLocation) - myList[stepLevel].Remove(yLocation); - foreach (float yLocation in AdjustYLocation.Keys) - { - vlnParagraph para = myList[stepLevel][-yLocation]; - myList[stepLevel].Remove(-yLocation); - // shift yLocation by yTop to work with items whose locations - // are defined from the top of the new page rather than - // from the beginning of the step. - // Note that yLocation is negative to have items in descending - // order so that adding yTop decrements their values. - if (!myList[stepLevel].ContainsKey(yTop - yLocation)) - myList[stepLevel].Add(yTop - yLocation, para); - } - if (myList[stepLevel].Count == 0) - CleanupListStepLevel.Add(stepLevel); - } - foreach (int stepLevel in CleanupListStepLevel) - myList.Remove(stepLevel); - } - /// - /// Builds a list of paragraphs by StepLevel and yLocation in descending order. - /// - /// - /// - private void BuildLocationList(float yTopMost, ParagraphLocations myLocations) - { - foreach (vlnParagraph child in ChildrenAbove) - child.BuildLocationList(yTopMost, myLocations); - foreach (vlnParagraph child in ChildrenLeft) - child.BuildLocationList(yTopMost, myLocations); - - // Add a list entry consisting of StepLevel, yoffset from the beginning of this step, paragraph itself - myLocations.Add(this, yTopMost); - - foreach (vlnParagraph child in ChildrenRight) - child.BuildLocationList(yTopMost, myLocations); - foreach (vlnParagraph child in ChildrenBelow) - child.BuildLocationList(yTopMost, myLocations); - } - private int COL_WID_ADJ = 6; // adjusts for incorrect use of WidSTable when breaking a line (it breaks 6 chars too short) - private bool IsTitleType(ItemInfo itm) - { - if (itm.FormatStepData != null && (itm.FormatStepData.Index == 42 || itm.FormatStepData.Index == 43)) return true; - return false; - } - private static VlnFlexGrid _MyFlexGrid = new VlnFlexGrid(1, 1); - public static VlnFlexGrid MyFlexGrid - { - get { return _MyFlexGrid; } - } - private pkParagraph _MyPlaceKeeper = null; - public pkParagraph MyPlaceKeeper - { - get { return _MyPlaceKeeper; } - set { _MyPlaceKeeper = value; } - } - private pkParagraph _MyContAct = null; - public pkParagraph MyContAct - { - get { return _MyContAct; } - set { _MyContAct = value; } - } - // F2022-024 Time Critical Action - private pkParagraph _MyTimeCriticalAction = null; - public pkParagraph MyTimeCriticalAction - { - get { return _MyTimeCriticalAction; } - set { _MyTimeCriticalAction = value; } - } - public static bool InList(int id, params int[] ids) - { - foreach (int listid in ids) - if (id == listid) return true; - return false; - } - private bool _PrefixSpecialCharacter = false; - public bool PrefixSpecialCharacter - { - get { return _PrefixSpecialCharacter; } - set { _PrefixSpecialCharacter = value; } - } - private string _Prefix; - public string Prefix - { - get { return _Prefix; } - set { _Prefix = value; } - } - private string _Suffix; - public string Suffix - { - get { return _Suffix; } - set { _Suffix = value; } - } - private float RoughSizeOfPage - { - get - { - return (float)(MyItemInfo.MyDocStyle.Layout.PageLength /*- MyItemInfo.MyDocStyle.Layout.TopMargin*/ - MyItemInfo.MyDocStyle.Layout.FooterLength); - } - } - private PromsPrinter _MyPromsPrinter; - public PromsPrinter MyPromsPrinter - { - get { return _MyPromsPrinter; } - set { _MyPromsPrinter = value; } - } - public static float _yPageStartForSupInfo = 0; - public vlnParagraph(vlnParagraph parent, PdfContentByte cb, ItemInfo itemInfo, float xoff, float yoff, int rnoLevel, int maxRNO, FormatInfo formatInfo, string prefix, string suffix, float yoffRightParent, bool loadChildren, PromsPrinter pp) - { - MyPromsPrinter = pp ?? parent.MyPromsPrinter; - int profileDepth = ProfileTimer.Push(">>>> vlnParagraph"); - Prefix = prefix; - Suffix = suffix; - MyItemInfo = itemInfo; - MyContentByte = cb; - if (itemInfo.IsFootnote && loadChildren) - { - // notestofootnoteshls is a list, a hls can have more than one note - if (MyPageHelper.NotesToFootNotesHLS.ContainsKey(itemInfo.MyHLS.ItemID)) - MyPageHelper.NotesToFootNotesHLS[itemInfo.MyHLS.ItemID].Add(itemInfo.ItemID); - else - { - List notesList = new List(); - notesList.Add(itemInfo.ItemID); - MyPageHelper.NotesToFootNotesHLS.Add(itemInfo.MyHLS.ItemID, notesList); - } - Processed = true; // don't want to print during normal ToPdf/ParagraphToPdf cycle - print in vlnsvgpagehelper - ProfileTimer.Pop(profileDepth); - return; - } - // do some 'setup' for Calvert Alarms: - if (itemInfo.ActiveFormat.PlantFormat.FormatData.PrintData.SpecialCaseCalvertAlarm) - { - // The CONDITION/RESPONSE portion of the alarm uses a macro to print the 'table' heading, - // i.e. the lines/boxes and text for CONDITION and RESPONSE. This does not have a tab, - // tabs are where the macros are usually stored, so flag this for future reference. - // The 2nd if is executed when the step is at the same y offset as the parent, i.e. DEVICE & SETPOINT text. - if (itemInfo.TemplateIndex > 0 && itemInfo.ActiveFormat.PlantFormat.FormatData.Templates[itemInfo.TemplateIndex].hmacro > 0) - HasCalvertMacro = true; - if (KeepOnParentLine(itemInfo)) yoff = parent.YOffset; - } - float yOffOrig = yoff; - // Save step text information to be used to create a PlaceKeeper (Calver Cliffs) - BuildPlacekeeper(parent, itemInfo); - - // Save step text information to be used to create a Continuous Action Summary - if (MyPromsPrinter.ShouldPrint_CAS_CTAS) BuildContinuousActionSummary(parent, itemInfo); - - // F2022-024 Time Critical Step - // Save step text information to be used to create a Time Critical Action Summary - if (MyPromsPrinter.ShouldPrint_CAS_CTAS) BuildTimeCriticalActionSummary(parent, itemInfo); - - if (itemInfo.ActiveFormat.MyStepSectionLayoutData.BoxLeftAdj != null) - _MyBoxLeftAdj = float.Parse(itemInfo.ActiveFormat.MyStepSectionLayoutData.BoxLeftAdj); - ShowSectionTitles = formatInfo.PlantFormat.FormatData.SectData.StepSectionData.StepSectionLayoutData.ShowSectionTitles || itemInfo.MyDocStyle.ShowSectionTitles; - if (itemInfo.IsSection && itemInfo.ActiveSection.DisplayText.ToUpper().Contains("") && !itemInfo.ActiveFormat.PlantFormat.FormatData.ProcData.PrintNoTitle) ShowSectionTitles = false; - HasIndent = itemInfo.IsStep && itemInfo.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.DontResetIndentOnNewline; - - int MetaLevel = 0; // if meta section, stores what level this section is. - float savCheckListBottomMost = 0; - //int[] problemIDs = { 889 }; - //List lProblemIDs = new List(problemIDs); - //if (lProblemIDs.Contains(itemInfo.ItemID)) - // Console.WriteLine("Found Item {0}", itemInfo.ItemID);formatInfochecko - MyParent = parent; - // The following code determines the last paragraph for an RNO - // MyTopRNO finds the Top paragraph for an RNO - if (itemInfo.IsInRNO) - { - if (rnoLevel <= maxRNO && itemInfo.IsRNOPart) // Not top level RNO - MyTopRNO = this; - else - MyTopRNO = MyParent.MyTopRNO; - if (MyTopRNO != null) MyTopRNO.LastRNO = this; - } - if (!MyPageHelper.MyParagraphs.ContainsKey(itemInfo.ItemID) && !itemInfo.IsFootnote) - { - MyPageHelper.MyParagraphs.Add(itemInfo.ItemID, this); - } - // if this a continuous subsection, refresh the style. - // This was commented out to fix a Westinghouse print issue 3-21-2014, orignally put in for Farley - //if (itemInfo.IsStepSection && !(itemInfo as SectionInfo).IsSeparatePagination() && itemInfo.MyParent.IsSection) - // RefreshDocStyle(); - - XOffset = xoff; - if (!MyItemInfo.IsStep && !MyItemInfo.IsStepSection && MyItemInfo.MyContent.MyEntry != null) - { - IsWordDocPara = true; - // special case - this is a 'Word Doc' paragraph. The Processed flag is used to know - // that steps need put out on a page for the pagination logic, and since there are no steps - // we don't want to have to worry about putting this out for pagination logic. - Processed = true; - ProfileTimer.Pop(profileDepth); - return; - } - YTopMost = YOffset = yoff; - vlnTab mytab = null; - bool doSectTab = false; - // if this substep has a caution or note as its parent, then there may have been a special indent done on the - // substep... check the CautionOrNoteSubstepIndent value, this is the additional indent amount in number - // of characters. - if (itemInfo.MyParent.IsCaution || itemInfo.MyParent.IsNote) - { - // if this is a Note or Caution off of a Note or Caution (Catawba EG/1A/CSAM/SACGR1 step 1) - // then indent it the length of its tab - if (itemInfo.IsCaution || itemInfo.IsNote) - XOffset += (!itemInfo.IsBackgroundStep()) ? (itemInfo.FormatStepData.TabData.IdentPrint.Length - 1) * 6 : 0; // B2018-139 don't adjust XOffset when processing a Caution, or Note background text is is off of Caution or Note WCN BG SAG-10 step 4 - - else - if (itemInfo.ActiveFormat.MyStepSectionLayoutData.DevNoteOrCautionTabOffset != null) - XOffset = float.Parse(itemInfo.ActiveFormat.MyStepSectionLayoutData.DevNoteOrCautionTabOffset); - else - XOffset += 72 * (itemInfo.FormatStepData.CautionOrNoteSubstepIndent == null ? 0 : (float)itemInfo.FormatStepData.CautionOrNoteSubstepIndent / (float)itemInfo.FormatStepData.Font.CPI); - } - - if (itemInfo.IsStep && itemInfo.MyHLS != null && itemInfo.MyHLS.FormatStepData.UseSmartTemplate && - itemInfo.FormatStepData.StepLayoutData.AlignWithParentTab - || (itemInfo.Steps != null && itemInfo.Steps.Count > 0 && itemInfo.Steps[0].FormatStepData.StepLayoutData.AlignWithParentTab)) - itemInfo.MyTab = null; - - float xMetaAdj = 0; - - if (itemInfo.IsFootnote) itemInfo.MyTab = null; - - if (itemInfo.IsSupInfoPart) XOffset = (float)itemInfo.MyDocStyle.Layout.LeftMargin; - - //if (itemInfo.MyTab != null && itemInfo.MyTab.Text != null && itemInfo.MyTab.Text != "") - // bug fix - if the section does not have a section number, then we need to build an empty tab for the itemInfo - // so that we place the section title in the correct location. so we need to go into this IF code block - // even if itemInfo has a MyTab that is an empty string when itemInfo is a section - 2/11/2015 - if (itemInfo.MyTab != null && itemInfo.MyTab.Text != null && (itemInfo.MyTab.Text != "" || itemInfo.IsSection)) - { - float localXOffset = XOffset; - bool doprint = true; - if (itemInfo.IsSection) - { - MyItemInfo.ActiveSection = null; - MyItemInfo.MyDocStyle = null; - DocStyle ds = MyItemInfo.MyDocStyle; - - if (!ds.ComponentList && ShowSectionTitles - && !MyItemInfo.MyDocStyle.CancelSectTitle - && !MyItemInfo.MyDocStyle.SpecialStepsFoldout) // Don't ouput the Step Section title - { - SectionConfig sch = MyItemInfo.MyConfig as SectionConfig; - if (sch != null && sch.Section_PrintHdr != "Y") - { - doprint = false; - YTopMost = 0; - } - } - else - doprint = false; - } - // if printing the supplemental info facing page, don't put out the section title. ToPdf will put out 'Supplemental Information' title. - if (MyPromsPrinter.SupInfoPrintType == E_SupInfoPrintType.Merge && MyPageHelper.CreatingSupInfoPage && itemInfo.IsSection) doprint = false; - if (doprint && itemInfo.IsSection && !itemInfo.MyDocStyle.CancelSectTitle && (itemInfo.MyConfig as SectionConfig).Section_IsFoldout != "Y") //C2019-042 Section_IsFoldout checks Section Number, Section Title, and use of check box - { - doSectTab = true; - if (itemInfo.IsStepSection && formatInfo.PlantFormat.FormatData.SectData.SectionNumber.Just.Contains("PSLeft")) - { - float offset = (float)itemInfo.MyDocStyle.Layout.LeftMargin; - if (formatInfo.PlantFormat.FormatData.SectData.SectionNumber.Pos != null) - { - ItemInfo iilvl = itemInfo; - while (!iilvl.IsProcedure) - { - // see if this metasection, walking up the tree, has its header printed, - // if so, indent for it. - SectionConfig sch1 = iilvl.MyConfig as SectionConfig; - if (sch1.Section_PrintHdr == "Y" || MyItemInfo.ActiveFormat.PlantFormat.FormatData.SectData.UseMetaSections) - MetaLevel++; - iilvl = iilvl.MyParent; - } - - if (formatInfo.PlantFormat.FormatData.PrintData.SpecialCaseCalvert) - { - if (MetaLevel == 1) - offset += (float)formatInfo.PlantFormat.FormatData.SectData.SectionNumber.Pos; - else - { - SectionConfig sc = itemInfo.MyParent.MyConfig as SectionConfig; - if (MyParent != null) - { - // if the parent is not printed, then adjust the xoffset based on - // the level of the metasection. Note that the 'if (MetaLevel==20) MetaLevel = 1' - // line of code was added so that the xoffsets between 16 & 32 bit are closer. - // This code was added to fix problems in BGE OI34, Appendix sections/subsection xoffsets. - if (sc != null && sc.Section_PrintHdr == "N") - { - if (MetaLevel == 2) MetaLevel = 1; - xMetaAdj = (float)formatInfo.PlantFormat.FormatData.SectData.MetaSectionList[0].ColSByLevel; - for (int i = 0; i < MetaLevel; i++) - { - xMetaAdj += (float)formatInfo.PlantFormat.FormatData.SectData.SectionHeader.Pos - (float)formatInfo.PlantFormat.FormatData.SectData.SectionNumber.Pos; - xMetaAdj += (float)formatInfo.PlantFormat.FormatData.SectData.MetaSectionList[i].SecNumPositionAdj; - } - offset += xMetaAdj; - } - else - { - offset = (sc != null && sc.SubSection_AutoIndent == "Y") ? MyParent.XOffset - : (MyParent.MyTab != null) ? MyParent.MyTab.XOffset : XOffset; - } - } - } - } - else - { - - MetaLevel = MetaLevel <= 2 ? 1 : MetaLevel - 1; - if (MetaLevel == 1) - offset += (float)formatInfo.PlantFormat.FormatData.SectData.SectionNumber.Pos; - else - { - xMetaAdj = (float)formatInfo.PlantFormat.FormatData.SectData.MetaSectionList[0].ColSByLevel; - for (int i = 0; i < MetaLevel; i++) - { - xMetaAdj += (float)formatInfo.PlantFormat.FormatData.SectData.SectionHeader.Pos - (float)formatInfo.PlantFormat.FormatData.SectData.SectionNumber.Pos; - xMetaAdj += (float)formatInfo.PlantFormat.FormatData.SectData.MetaSectionList[i].SecNumPositionAdj; - - } - offset += xMetaAdj; - itemInfo.MyTab.Text = itemInfo.MyTab.Text.TrimEnd(" ".ToCharArray()); - itemInfo.MyTab.CleanText = itemInfo.MyTab.CleanText.TrimEnd(" ".ToCharArray()); - if (((itemInfo.MyDocStyle.StructureStyle.Style & E_DocStructStyle.DSS_SameXOffSubsections) == E_DocStructStyle.DSS_SameXOffSubsections)) - offset += (float)formatInfo.PlantFormat.FormatData.SectData.SectionNumber.Pos; - } - } - } - localXOffset = offset; - } - } - if (!itemInfo.IsSection || doSectTab) - { - if (itemInfo.IsSupInfoPart) // get combined tab if on a supinfo facing page: - mytab = GetSupInfoTab(cb, itemInfo, yoff, mytab, doSectTab, localXOffset); - else if (itemInfo.MyTab.AltPrintTab != null) - mytab = new vlnTab(cb, this, itemInfo.MyTab.AltPrintTab, itemInfo.MyTab.AltPrintTab, localXOffset, yoff, itemInfo.MyTab.MyFont, doSectTab, StepRTB.MySymbolFontName, itemInfo.MyTab.RemovedStyleUnderline); - else { - string clntxt = itemInfo.MyTab.CleanText; - if (!string.IsNullOrEmpty(itemInfo.FormatStepData?.TabData?.MacroEditTag) && itemInfo.FormatStepData.TabData.MacroEditTag == "_" && clntxt.StartsWith("_")) - clntxt = clntxt.Substring(1); - mytab = new vlnTab(cb, this, itemInfo.MyTab.Text, clntxt, localXOffset, yoff, itemInfo.MyTab.MyFont, doSectTab, StepRTB.MySymbolFontName, itemInfo.MyTab.RemovedStyleUnderline); - } - PartsLeft.Add(mytab); - if (mytab.MyMacro != null) PartsLeft.Add(mytab.MyMacro); - } - } - else if (itemInfo.IsSupInfoPart) // if it was an empty tab - it may have been a caution/note - { - mytab = GetSupInfoTab(cb, itemInfo, yoff, mytab, doSectTab, XOffset); - PartsLeft.Add(mytab); - } - // if this is the High Level RNO step (MyTopRNO) and we are numbering the RNO, adjust the xoffset to start the tab - // at the x location rather than starting the text at the x location: - AdjustWidth(itemInfo, maxRNO, formatInfo, mytab); - bool adjustAgain = ((itemInfo.MyTab != null && itemInfo.MyTab.Position == 0) || (itemInfo.MyPrevious != null && itemInfo.MyPrevious.FormatStepData != null && itemInfo.MyPrevious.FormatStepData.TabData.IsTransition)) ? true : false; - if (!itemInfo.IsSection && itemInfo.FormatStepData.NumberHighLevel && itemInfo.IsRNOPart && (MyTopRNO == null || itemInfo.ItemID == MyTopRNO.MyItemInfo.ItemID)) - { - // adjust the x-offset of the RNO to include the tab. - if (itemInfo.ActiveFormat.MyStepSectionLayoutData.RNOWidthSameAsHighParent)// && !itemInfo.MyParent.IsHigh) - { - vlnParagraph hls = GetHighLevelParagraph(); - float RnoOffset1 = ToInt(formatInfo.MyStepSectionLayoutData.ColRTable, maxRNO); - float offset = hls.Width + RnoOffset1 + hls.XOffset; - vlnTab tb = hls.MyTab; - //offset += tb.Width; - if (MyTopRNO == null) - Width -= (float)itemInfo.ActiveFormat.MyStepSectionLayoutData.SingleColumnRNOIndent; - offset -= Width; - float inc = offset - XOffset; - if (mytab != null) - mytab.XOffset += inc;// +(itemInfo.MyParent.IsHigh ? 6.8f : 0); - XOffset += inc; - adjustAgain = false; - } - else if (itemInfo.FormatStepData.AdjHighLevelTab != null && itemInfo.ColumnMode > 0) - // For Farley (only plant format to use AdjHighLevelTab), determine the xoffset based on - // where the right edge of the text is. Their RNO's are numbered with parent numbering - // so the calculations for determining the xoffset backs up from the right edge. - { - float rightTextEdge = this.MyHighLevelParagraph.XOffset + this.MyHighLevelParagraph.Width; - int colRx = int.Parse(formatInfo.MyStepSectionLayoutData.ColRTable.Split(",".ToCharArray())[itemInfo.ColumnMode]); - rightTextEdge += (colRx + (itemInfo.FormatStepData.AdjHighLevelTab ?? 0)); - float diff = rightTextEdge - (XOffset + Width); - if (mytab != null) mytab.XOffset += diff; - XOffset += diff; - adjustAgain = false; - } - else if (mytab != null) - { - float adjusttab = (itemInfo.MyParent.IsHigh) ? itemInfo.FormatStepData.AdjHighLevelTab ?? 0 : 0; - mytab.XOffset += (mytab.Width + adjusttab); - XOffset = mytab.XOffset + mytab.Width; - if (adjusttab != 0) Width += (mytab.Width); - } - } - if (adjustAgain) - { - AdjustXOffsetForTab(itemInfo, maxRNO, formatInfo, mytab, xMetaAdj); - // Used in Ginna's Attachment format. - // if the Note/Caution is off of a sub-step, then adjust the width so that the Caution/Note text box does not extend past the HLS text box - if (itemInfo.IsCautionOrNotePart && maxRNO == 0 && (itemInfo.ActiveSection != null && itemInfo.ActiveSection.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.LimitCautionNoteWidthToHLS)) // C2018-003 fixed use of getting the active section - { - float wMax = MyHighLevelParagraph.Width + MyHighLevelParagraph.XOffset - XOffset; - if (wMax < Width && (Width + XOffset > MyItemInfo.MyDocStyle.Layout.PageWidth)) Width = wMax; - } - } - - if (itemInfo.IsSection && MyParent == null && itemInfo.MyDocStyle.SupplementalInformation && MyPromsPrinter.SupInfoPrintType == E_SupInfoPrintType.Merge) - { - _SupInfoSection = new vlnParagraph(this, cb, itemInfo, xoff, yoff, rnoLevel, maxRNO, formatInfo, null, null, yoffRightParent, false, pp); - MyPromsPrinter.SupInfoPdfPageCount = -1; - } - // For Calvert Alarms: if within the CONDITION/RESPONSE table, indent by 1 character. - // Sequential substeps are ok because of the tab string, but items without a tab & other step - // types were writing over the CONDITION/RESPONSE vertical table line. This code uses - // 7.2 for the character size to match 16bit output. - if (itemInfo.IsStep && !itemInfo.IsSequential && !itemInfo.IsCaution && !itemInfo.IsNote && MyParent.HasCalvertMacro) - { - XOffset += 7.2f; - if (mytab != null) mytab.XOffset += 7.2f; - } - if ((itemInfo.IsCaution || (itemInfo.IsNote && !itemInfo.IsFootnote)) && (itemInfo.MyDocStyle.StructureStyle.Style & E_DocStructStyle.DoubleBoxHLS) == E_DocStructStyle.DoubleBoxHLS) - { - if (itemInfo.IsInRNO) - { - XOffset = MyTopRNO.MyTab != null ? MyTopRNO.MyTab.XOffset : MyTopRNO.XOffset; - Width = (float)itemInfo.MyDocStyle.Layout.PageWidth - XOffset - 10; - } - else - { - XOffset = MyHighLevelParagraph.MyTab.XOffset; - Width = MyHighLevelParagraph.MyTab.Width + MyHighLevelParagraph.Width - 6; // make width 1/2 char smaller so it doesn't touch line - } - } - if (UseTemplateWidthOrXOff(itemInfo)) - { - float txoff = GetWidthOrStartFromTemplate(itemInfo, itemInfo.ActiveFormat, false); - if (txoff > 0) XOffset = (float)itemInfo.MyDocStyle.Layout.LeftMargin + txoff; // GetWidthOrStartFromTemplate(itemInfo, itemInfo.ActiveFormat, false); - } - if (itemInfo.MyHeader != null && itemInfo.MyHeader.Text != null && !doSectTab) - yoff += SetHeader(this, cb, itemInfo, formatInfo); - else if (itemInfo.FormatStepData != null && itemInfo.FormatStepData.SeparateBox && itemInfo.FirstSibling.MyHeader != null && itemInfo.FirstSibling.MyHeader.Text != null) - yoff += SetHeader(this, cb, itemInfo.FirstSibling, formatInfo); - float yoffLeft = yoff; - if (ChildrenAbove != null) - ChildrenAbove.StepDesignator = null; //reset StepDesignator - if (DoSubs && itemInfo.Cautions != null && (!itemInfo.ActiveFormat.PlantFormat.FormatData.PrintData.SpecialCaseCalvertAlarm || itemInfo.Cautions[0].FormatStepData.Type != "Caution1") && !(itemInfo.IsCaution || itemInfo.IsNote)) - { - if (itemInfo.ActiveFormat.MyStepSectionLayoutData.Dev_Format) - { - // For deviations, the Cautions are always in the same place. - // Fix for Catawba E-1 deviation for step 10. Has note/caution off of a paragraph instead of HLS - float xoffDev = (float)itemInfo.MyDocStyle.Layout.LeftMargin; - if (loadChildren) yoffLeft = ChildrenLeft.Add(cb, itemInfo.Cautions, xoff, yoff, yoff, rnoLevel, maxRNO, formatInfo); - } - else - { - if (yoffRightParent > yoff && ((itemInfo.MyDocStyle.StructureStyle.Style & E_DocStructStyle.DoubleBoxHLS) != E_DocStructStyle.DoubleBoxHLS)) yoff = yoffRightParent; - if (loadChildren) yoff = ChildrenAbove.Add(cb, itemInfo.Cautions, xoff, yoff, yoff, rnoLevel, maxRNO, formatInfo); - } - } - if (DoSubs && itemInfo.Notes != null && !(itemInfo.IsCaution || itemInfo.IsNote)) - { - if (itemInfo.ActiveFormat.MyStepSectionLayoutData.Dev_Format) - { - // For deviations, the Cautions are always in the same place. - // Fix for Catawba E-1 deviation for step 10. Has note/caution off of a paragraph instead of HLS - float xoffDev = (float)itemInfo.MyDocStyle.Layout.LeftMargin + 6 + (float)(itemInfo.ActiveFormat.MyStepSectionLayoutData.WidT); - if (loadChildren) yoffLeft = Math.Max(yoffLeft, ChildrenLeft.Add(cb, itemInfo.Notes, xoffDev, yoff, yoff, rnoLevel, maxRNO, formatInfo)); - } - else - { - // Notes/Cautions span the page. If the right (RNO) column is below current yoff, use the - // yoff from this. Without this, an overlap of text between the note and the bottom of the - // RNO was occurring for FNP - Unit 2/AOP, AOP-4.0. - if (yoffRightParent > yoff && ((itemInfo.MyDocStyle.StructureStyle.Style & E_DocStructStyle.DoubleBoxHLS) != E_DocStructStyle.DoubleBoxHLS)) yoff = yoffRightParent; - if (loadChildren) - { - float yoffadj = 0; - if (itemInfo.IsTable && MyFlexGrid.BorderStyle == C1.Win.C1FlexGrid.Util.BaseControls.BorderStyleEnum.None && !MyFlexGrid.TopRowHasBorder()) - yoffadj = SixLinesPerInch; // adjust the yoffset if the note is off of a borderless table - yoff = ChildrenAbove.Add(cb, itemInfo.Notes, xoff, yoff + yoffadj, yoff + yoffadj, rnoLevel, maxRNO, formatInfo) - yoffadj; - } - } - } - if (itemInfo is StepInfo && ((itemInfo as StepInfo).MyConfig as StepConfig).Step_PreferredPagebreak) HasPrefPageBreak = true; - // The following adds supplemental information items to the SupInfoSection list off of the section level paragraph for printing - // of the sup info pdf. The SupInfoSection list is just a flat list of all supplemental information within the section. - if (MyPromsPrinter.SupInfoPrintType == E_SupInfoPrintType.Merge && loadChildren && itemInfo.SupInfos != null) - { - SupInfoSection.ChildrenBelow.Add(cb, itemInfo.SupInfos, XOffset, 0, 0, rnoLevel, maxRNO, formatInfo); - } - - // Without the following, BGE had gaps in y-direction if the AER/RNO both had cautions/notes. - // The only time this needs done is if caution/notes are printed in separate columns in dual - // column mode (used the DoubleBoxHLS BGE flag for this - if another plant needs this, make it - // a more generic flag). - if (itemInfo.IsRNOPart && ((itemInfo.MyDocStyle.StructureStyle.Style & E_DocStructStyle.DoubleBoxHLS) == E_DocStructStyle.DoubleBoxHLS) && - rnoLevel == maxRNO && ChildrenAbove.Count > 0 && MyParent.ChildrenAbove.Count > 0) - { - float yDeltaRno = yoff - yOffOrig; - float yDeltaAer = SixLinesPerInch + yOffOrig - MyParent.ChildrenAbove[0].YTopMost; - if (yDeltaRno > yDeltaAer) - { - foreach (vlnParagraph chlda in MyParent.ChildrenAbove) - { - chlda.AdjustYOffset(yDeltaAer - yDeltaRno); - } - foreach (vlnParagraph chld in ChildrenAbove) - chld.AdjustYOffset(yDeltaAer); - yoff -= yDeltaAer; - } - else - { - foreach (vlnParagraph chld in ChildrenAbove) - chld.AdjustYOffset(yDeltaRno); - yoff -= yDeltaRno; - } - } - // Comanche Peak uses CAUTION2 type to enter a Step Designator, which is placed to the left of the step number. - // The Step Designator information is saved during the processing of the Cautions (ChildrenAbove) - // defined in the vlnParagraphs class (of which ChildrenAbove is defined) - if (ChildrenAbove.StepDesignator != null) - { - string pref = ChildrenAbove.StepDesignator; - float colOvrd = (float)(ChildrenAbove.StepDesignatorColumn ?? 0); - float xPref = (colOvrd > 0) ? colOvrd : mytab.XOffset - (pref.Length * (72 / (float)_MyItemInfo.FormatStepData.Font.CPI)); - PartsLeft.Add(new vlnText(cb, this, pref, pref, xPref, yoff, ChildrenAbove.StepDesignatorFont)); - ChildrenAbove.StepDesignator = null; - ChildrenAbove.StepDesignatorColumn = null; - } - DoAnnotationPrintableText(cb, itemInfo, yoff); // Look in annotation type to see if annotation has text that should be printed (like a step designator) - - // if this is a hls with a box, adjust the starting y location for the hls. this is done here - // in case this hls had a boxed caution and/or note before it. Also, this code is here rather - // than in the vlnparagraphs.add code because the yoff in that code will position the box, but - // this code positions the hls (in y direction), without this, the hls starts on the box line. - int bxIndx = itemInfo.IsSection ? 0 : itemInfo.FormatStepData.StepLayoutData.STBoxindex ?? 0; - if (itemInfo.IsHigh && bxIndx > 0) - { - int boxLnAdjust = itemInfo.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.StepSectionPrintData.DiffContActBox ? 1 : 2; - yoff += (boxLnAdjust * SixLinesPerInch); // this yoff is where the BOX starts (boxLnAdjust was added for WEP2) - } - - // If the format has that extra space should be put out before the step, then - // handle this by using the 'PartsAbove' structure. By using the parts above, the extra - // space above will be done regardless of where page breaks fall. - float addExtraSpace = 0; - if (MyItemInfo.FormatStepData != null && MyItemInfo.ActiveFormat.MyStepSectionLayoutData.CustomSpacing) - addExtraSpace = MyItemInfo.FormatStepData.StepLayoutData.STExtraSpace ?? 0; - //if (MyItemInfo.MyParent != null && MyItemInfo.MyParent.FormatStepData != null && - // MyItemInfo.MyParent.FormatStepData.Type != "TitleWithTextRight") - // addExtraSpace = (MyItemInfo.FormatStepData == null) ? 0 : MyItemInfo.FormatStepData.StepLayoutData.STExtraSpace ?? 0; - if (MyItemInfo.MyParent != null && MyItemInfo.MyParent.FormatStepData != null) - addExtraSpace = (MyItemInfo.MyParent.FormatStepData.Type == "TitleWithTextRight" || MyItemInfo.FormatStepData == null) ? 0 : MyItemInfo.FormatStepData.StepLayoutData.STExtraSpace ?? 0; - // If a high level step, the 16bit code uses the value of the extra space - // from the high level step format regardless of what type of high level step it is: - // Added check for UseSTExtraRealValue, if set, we want to use what is set for the specific step type - // Added check for CustomSpacing (was also in 16-bit logic) - if (!MyItemInfo.ActiveFormat.MyStepSectionLayoutData.UseSTExtraRealValue && - !MyItemInfo.ActiveFormat.MyStepSectionLayoutData.CustomSpacing && - MyItemInfo.IsHigh) - addExtraSpace = MyItemInfo.ActiveFormat.PlantFormat.FormatData.StepDataList[2].StepLayoutData.STExtraSpace ?? 0; - // If CustomSpacing flag is true - // then use the STExtraSpace from the step type called "Default" (index number 25) - //if (YOffset != 0 && MyItemInfo.IsSection && MyItemInfo.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.StepSectionLayoutData.CustomSpacing) - if (YOffset != 0 && MyItemInfo.IsSection && MyItemInfo.ActiveFormat.MyStepSectionLayoutData.CustomSpacing) - addExtraSpace = (float)MyItemInfo.ActiveFormat.PlantFormat.FormatData.StepDataList[25].StepLayoutData.STExtraSpace; - if (YOffset != 0 && MyItemInfo.FormatStepData != null && - MyItemInfo.MyPrevious == null && MyItemInfo.FormatStepData.ThreeBlanksAbove && (!MyItemInfo.IsNote || MyItemInfo.MyParent.Cautions == null)) - addExtraSpace = 24; // already has one blank line above, added two more - //if (YOffset != 0 && MyItemInfo.FormatStepData != null && MyItemInfo.FormatStepData.StepLayoutData.STExtraSpace > 0) - // addExtraSpace = (float)MyItemInfo.FormatStepData.StepLayoutData.STExtraSpace; - // if this plant has the AlwaysUseExtraLines and there are notes/cautions above the hls, don't add in the - // extra space: - if (itemInfo.IsHigh && (itemInfo.Cautions != null || itemInfo.Notes != null)) - { - if ((itemInfo.Cautions != null && itemInfo.Cautions[0].FormatStepData.AlwaysUseExtraLines) || (itemInfo.Notes != null && itemInfo.Notes[0].FormatStepData.AlwaysUseExtraLines)) - addExtraSpace = 0; - // F2021-038: SHE/SHEA format - Less space after boxes - if (itemInfo.Cautions != null && itemInfo.Cautions[itemInfo.Cautions.Count - 1].FormatStepData.NoYBxAdjust) - addExtraSpace = 0; - if (itemInfo.Notes != null && itemInfo.Notes[itemInfo.Notes.Count - 1].FormatStepData.NoYBxAdjust) - addExtraSpace = 0; - } - // F2021-038: SHE/SHEA format - Less space after boxes. The following is for when a HLS has an RNO that has Cautions/Notes - if (itemInfo.IsHigh && itemInfo.RNOs != null) - { - if (itemInfo.RNOs[0].Notes != null && itemInfo.RNOs[0].Notes[0].FormatStepData.NoYBxAdjust) - addExtraSpace = 0; - if (itemInfo.RNOs[0].Cautions != null && itemInfo.RNOs[0].Cautions[0].FormatStepData.NoYBxAdjust) - addExtraSpace = 0; - } - if (addExtraSpace > 0 && MyItemInfo.FormatStepData != null) - { - // We need to strip out the underline style from the font before putting out - // the extra line. - VE_Font vf = MyItemInfo.FormatStepData.Font; - E_Style sty = (E_Style)vf.Style; - if ((sty & E_Style.Underline) != 0) - sty ^= E_Style.Underline; - vf = new VE_Font(vf.Family, (int)vf.Size, sty, (float)vf.CPI); - this.PartsAbove.Add(new vlnText(cb, this, " ", " ", 72, yoff, vf)); - } - - yoff += addExtraSpace; - - YTop = yoff; - YOffset = yoff; - if (mytab != null && mytab.SeparateBullet) - { - string identB = formatInfo.PlantFormat.FormatData.SectData.StepSectionData.IdentB; - vlnText myBullet = new vlnText(cb, this, identB, identB, XOffset - 12, YOffset, MyItemInfo.FormatStepData.TabData.Bullet.Font); - myBullet.Rtf = myBullet.Rtf.Replace("\u25CF", @"\f1\u9679?\f0 "); - PartsLeft.Add(myBullet); - } - if (itemInfo.MyTab != null && itemInfo.MyTab.AsteriskOffset != 0) - { - - // the '-24' in x-direction & '+4' in y-direction was used for the SHE format to get the continuous - // HLS's asterisk to match 16bit. The font size was set at 16 to make it match also: - VE_Font astFont = new VE_Font(MyItemInfo.FormatStepData.TabData.Font.Family, 16, E_Style.Bold, 10); - vlnText myAsterisk = new vlnText(cb, this, "*", "*", mytab.XOffset - 24, YOffset + 4, astFont); - PartsLeft.Add(myAsterisk); - } - if (itemInfo.IsRNOPart && rnoLevel > maxRNO) - { - // the DoubleSpace & SpaceDouble flags seem redundant. The 2nd line was added for foldout - // line spacing for IP2 foldouts (one example can be found in E-1) - if (!itemInfo.FormatStepData.SpaceDouble && itemInfo.MyParent.IsHigh) - { - // but it we are in single column mode, don't remove the blank line. (Wolf Creek Admin Instructions - wcn1) - if (itemInfo.ActiveSection != null && (itemInfo.ActiveSection as SectionInfo).SectionConfig.Section_ColumnMode != SectionConfig.SectionColumnMode.One) // C2018-003 fixed use of getting the active section - yoff = YOffset = yoff - SixLinesPerInch; - } - else if (itemInfo.FormatStepData.NoSpaceMultipleRNOs) yoff = YOffset = yoff - SixLinesPerInch; - if (itemInfo.FormatStepData.DoubleSpace && itemInfo.FormatStepData.SpaceDouble) yoff = YOffset = yoff + SixLinesPerInch; - } - AddMacros(itemInfo, mytab); - if (mytab != null) - { - mytab.YOffset = yoff; - if (mytab.MyMacro != null) mytab.MyMacro.YOffset = yoff; - } - // For background formats, HLS's or Caution or any Notes have tab on line and then text - // on line below (with space in between) - if (itemInfo.IsBackgroundStep() && itemInfo.MyTab != null && itemInfo.MyTab.AltPrintTab != null && itemInfo.MyTab.AltPrintTab.Trim() != "") - yoff = YOffset = yoff + (2 * SixLinesPerInch); - CheckOff co = itemInfo.GetCheckOffStep(); - float yForCheckoff = yoff; //0; - default checkoff row is same as FIRST line of text - // if dropCheckoff is true, then the checkoff is place on the same of row as the LAST line of text - bool dropCheckoff = itemInfo.ActiveFormat.PlantFormat.FormatData.ProcData.CheckOffData.DropCheckOff - || (co != null && co.DropCheckOff); - if (itemInfo.MyContent.MyGrid != null) - { - vlnCells.DefaultFont = itemInfo.FormatStepData.Font.WindowsFont;// Set the default text font based upon the format - int profileDepth1 = ProfileTimer.Push(">>>> Before vlnParagraph.Grid"); - //Use Static MyFlexGrid - BWD INST2 - FlexGrid Errors - MyFlexGrid.LoadGrid(itemInfo); - MyGrid = new vlnTable(MyFlexGrid, cb); - Height = MyGrid.Height; - Width = MyGrid.Width; - // Adjust the XOffset before determining if the table will overlap the RNO column RHM 20150529 - CalculateXOffsetGridOrFigure(itemInfo, maxRNO, formatInfo); - - yoff = AdjustLocIfLongerRNO(itemInfo, yoff, yoffRightParent); - // if the table does not have a border, only move down one line: - float yoffForBorder = 2 * SixLinesPerInch; - if (MyFlexGrid.BorderStyle == C1.Win.C1FlexGrid.Util.BaseControls.BorderStyleEnum.None && !MyFlexGrid.TopRowHasBorder()) - yoffForBorder -= SixLinesPerInch; - //yForCheckoff = yoff + Height - SixLinesPerInch; - if (dropCheckoff) - yForCheckoff += Height - SixLinesPerInch; // place checkoff on last row of text - yoff += (Height + yoffForBorder); //(2 * SixLinesPerInch)); - yoff = (float)Math.Ceiling(yoff); - ProfileTimer.Pop(profileDepth1); - } - else if (itemInfo.IsRtfRaw) - { - CalculateXOffsetGridOrFigure(itemInfo, maxRNO, formatInfo); - YOffset = yoff; - yoff += Height * .6f; // .6 is used as a scale factor in RtfRawAt (rtf2pdf). Use it here too for moving down page after equation. - yoff = (float)Math.Ceiling(yoff); - yoff += AdjustForBlankLines(); - } - else if (itemInfo.IsFigure) // if a figure we've got to determine the size: - { - int profileDepth2 = ProfileTimer.Push(">>>> Before vlnParagraph.Figure"); - string erMsg = null; - if (itemInfo.MyContent.Text != null) // ro image - { - if (itemInfo.MyContent.Text != "") // also check for text, there is an RO image then: - { - ProcedureInfo proc = itemInfo.MyProcedure; - DocVersionInfo dvi = proc.MyDocVersion; - ROFstInfo rofst = dvi.DocVersionAssociations[0].MyROFst; - //rofst.docVer = dvi; - ROFSTLookup lookup = rofst.GetROFSTLookup(dvi); - string linkInfoText = itemInfo.MyContent.Text.Replace(@"\v ", ""); - Match m = Regex.Match(linkInfoText, @"(.*)[#]Link:([A-Za-z]*):(.*)"); - string val = null; - if (m.Length > 0) // if m.lengh is zero, then no match was found - no RO was entered in the figure substep - { - if (m.Groups.Count < 4) - { - //erMsg = "RO was not found during data migration."; - // added newlines in the RO number (shown in figure substep type with figure RO) - // if we are here, then there is no RO link information, use this number to find the RO image to print - val = string.Format("{0}\n{1}\n{2}\n{3}", - linkInfoText.Substring(0, linkInfoText.Length - 16), - linkInfoText.Substring(linkInfoText.Length - 16, 8), - linkInfoText.Substring(linkInfoText.Length - 8, 4), - linkInfoText.Substring(linkInfoText.Length - 4, 4)); - val = val.Replace(@"\u8209?", "-").Replace(@"\u9586?", @"\"); // replace dash and backslash symbols with dash and backslash characters - } - else - { - string[] subs = m.Groups[3].Value.Split(" ".ToCharArray()); - // B2022-088: Find Doc Ro button not working in Word Sections - val = lookup.GetRoChild(subs[1]).value; - if (val == null || val == "?") val = lookup.GetRoChild(subs[1].Substring(0, 12)).value; - if (val == "?") - { - erMsg = string.Format("Referenced Object does not exist."); - _MyLog.WarnFormat("\r\nMissing Referenced Object {0} in {1}", subs[1], itemInfo.ShortPath); - yoff += 2 * SixLinesPerInch; - } - } - } - GC.Collect(); // memory garbage collection (Regex memory bug) - if (val != null && val != "?") - { - string[] vals = val.Split("\n".ToCharArray()); - Width = Int32.Parse(vals[3], System.Globalization.NumberStyles.AllowHexSpecifier) * MyItemInfo.FormatStepData.Font.CharsToTwips; - int lines = Int32.Parse(vals[2], System.Globalization.NumberStyles.AllowHexSpecifier); - // Check that the Height of figure isn't too big to fit on the page, if it is - // set the Height to the printable part of page - Height of the HLS and an extra line - // for between HLS & figure. - float h1 = lines * SixLinesPerInch; - float h2 = RoughSizeOfPage - MyParent.Height - SixLinesPerInch; - Height = Math.Min(h1, h2); - if (h1 > h2) - { - Width *= (h2 / h1); - } - StepInfo si = (StepInfo)MyItemInfo; - StepConfig sc = new StepConfig(si.MyContent.Config); - if (sc != null && sc.Step_ImageWidth != 0) - { - Width = sc.Step_ImageWidth; - Height = sc.Step_ImageHeight; - } - yoff = AdjustLocIfLongerRNO(itemInfo, yoff, yoffRightParent); - if (dropCheckoff) - yForCheckoff += Height - SixLinesPerInch; // place checkoff on last row of text - bool noborder = MyItemInfo.FormatStepData.Type.ToUpper().Contains("BORDERLESS"); - yoff += (Height + ((noborder ? 1 : 2) * SixLinesPerInch)); // RHM 20120925 - Eliminate extra space after Figure } - try - { - ROImageInfo roImage = ROImageInfo.GetByROFstID_FileName(rofst.ROFstID, vals[0]); - if (roImage != null) - ImageText = val; - else - { - roImage = rofst.GetROImageByFilename(vals[0], MyItemInfo);// need code to go and get an ROImaage if it exists - if (roImage == null) - erMsg = string.Format("Image {0} does not exist.", vals[0]); - else - ImageText = val; - } - } - catch (Exception ex) - { - erMsg = string.Format("Image {0} does not exist, error = {1}.", vals[0], ex.Message); - } - } - if (erMsg != null) Rtf = GetRtf(erMsg, itemInfo.ActiveFormat.PlantFormat.FormatData.Font); - } - CalculateXOffsetGridOrFigure(itemInfo, maxRNO, formatInfo); - } - else - { - // figure - ImageText = "figure"; - } - if (ImageText == null && erMsg == null) - { - ImageText = "figure"; - ImageConfig ic = new ImageConfig(MyItemInfo.MyContent.MyImage); - // B2016-277: add a try catch in case of there being 'bad' data in the text field for an image/figure - try - { - byte[] idata = (ic != null && ic.Image_DataSize > 0) ? ROImageInfo.Decompress(MyItemInfo.MyContent.MyImage.Data, ic.Image_DataSize) : MyItemInfo.MyContent.MyImage.Data; - MemoryStream ms = new MemoryStream(idata); - System.Drawing.Image img = System.Drawing.Image.FromStream(ms); - Width = img.Width; - Height = img.Height; - if (ic != null && ic.Image_Height != 0) - { - Width = ic.Image_Width; - Height = ic.Image_Height; - - // B2022-041: extra whitespace after resized image. Make same adjustment here that gets made in ParagrphToPdf - // B2023-040: WCN pagination changed for And steps with large image after - add format flag for - // Barakah - if (MyItemInfo.ActiveFormat.PlantFormat.FormatData.PrintData.AdjustLargeImage) - { - float mult = 1.0F; - if (Width > (vlnParagraph.wMax - 12)) mult = (vlnParagraph.wMax - 24) / Width; - if (Height > (vlnParagraph.hMax - 36)) mult = Math.Min(mult, (vlnParagraph.hMax - 36) / Height); - if (mult < 1.0F) - { - Width = Width * mult; - Height = Height * mult; - } - } - } - yoff = AdjustLocIfLongerRNO(itemInfo, yoff, yoffRightParent); - bool noborder = MyItemInfo.FormatStepData.Type.ToUpper().Contains("BORDERLESS"); - yoff += (Height + SixLinesPerInch); // B2019-059 only one extra line after a figure (does not matter if it has a border or not) - CalculateXOffsetGridOrFigure(itemInfo, maxRNO, formatInfo); - } - catch (Exception ex) - { - _MyLog.WarnFormat("Bad figure content data: item = {0}, {1}", MyItemInfo.ItemID, MyItemInfo.ShortPath); - } - } - ProfileTimer.Pop(profileDepth2); - } - else - { - // For Calvert Alarms, the 'CONDITION/RESPONSE' portion uses a macro to print - // the CONDITION and RESPONSE text with the lines around it. Add the macro here because - // there is no tab for the step & that's where the macro is usually stored: - if (HasCalvertMacro) PartsLeft.Add(new vlnMacro(xoff - 12f, yoff, "H4")); - - //if (itemInfo.IsSection) - // Rtf = GetRtf(itemInfo, prefix, " (Continued)"); - //else - // BuildRtf(); // not necessary, RTF is lazyloaded - if (itemInfo.IsStep && itemInfo.MyHLS != null && itemInfo.MyHLS.FormatStepData.UseSmartTemplate) - { - if (itemInfo.FormatStepData.StepLayoutData.AlignWithParentTab - || (itemInfo.Steps != null && itemInfo.Steps.Count > 0 && itemInfo.Steps[0].FormatStepData.StepLayoutData.AlignWithParentTab)) - { - int stplevl = TheStepLevel(itemInfo); - if (stplevl >= 0 && MyItemInfo.MyHLS.FormatStepData.VertPos[stplevl] > 0) - { - if (MyItemInfo.FormatStepData.StepPrintData.Justify == "Center") - { - string[] vertPos = MyItemInfo.MyHLS.FormatStepData.VertPos.Split(",".ToCharArray()); - float hloc = (float.Parse(vertPos[stplevl]) + ((float.Parse(vertPos[stplevl + 1]) - float.Parse(vertPos[stplevl])) / 2)); - Chunk chk = (Chunk)IParagraph.Chunks[0]; - hloc = hloc - (chk.GetWidthPoint() / 2); - XOffset = hloc + (float)itemInfo.MyDocStyle.Layout.LeftMargin; - } - else - XOffset = float.Parse(MyItemInfo.MyHLS.FormatStepData.VertPos.Split(",".ToCharArray())[stplevl]) + (float)itemInfo.MyDocStyle.Layout.LeftMargin; - } - } - } - if (itemInfo.IsTablePart) // Not for grid, this is for old-style tables. - { - Width = GetTableWidth(cb, IParagraph, MyItemInfo.MyDocStyle.Layout.PageWidth); - CalculateXOffsetGridOrFigure(itemInfo, maxRNO, formatInfo); - } - else - if (itemInfo.FormatStepData != null && itemInfo.FormatStepData.StepPrintData != null && (itemInfo.IsHigh || (!itemInfo.IsHigh && itemInfo.MyContent.Type != itemInfo.MyParent.MyContent.Type))) XOffset += (float)(itemInfo.FormatStepData.StepPrintData.PosAdjust ?? 0); - - // point beach wpb subformats 20 & 22 were printing some text past right margin. Limit the width to the right margin, i.e. pagewid - if (itemInfo.ActiveFormat.MyStepSectionPrintData.LimitWidToPageWid) - { - float lim = (MyTab == null ? (XOffset - (float)itemInfo.MyDocStyle.Layout.LeftMargin) : MyTab.XOffset + MyTab.Width) + Width; - float docStyleLim = (float)itemInfo.MyDocStyle.Layout.PageWidth - (float)itemInfo.MyDocStyle.Layout.LeftMargin; - - if (lim > docStyleLim) - { - WidthNoLimit = Width; // Use this width to calculate childrens' width, without this, code was making children to narrow! - Width = docStyleLim - (MyTab == null ? (XOffset - (float)itemInfo.MyDocStyle.Layout.LeftMargin) : MyTab.XOffset + MyTab.Width); - } - } - if (itemInfo.IsSection && ShowSectionTitles - && !MyItemInfo.MyDocStyle.CancelSectTitle) - { - if (MyItemInfo.MyDocStyle.Layout.SectionMacro != null) - { - string macro = GetMacroName(MyItemInfo.MyDocStyle.Layout.SectionMacro); - PartsAbove.Add(new vlnMacro(xoff, yoff, macro)); - yoff += SixLinesPerInch; - YOffset = yoff; - } - } - - // if this step has a prefix but it's not checklist... do a partsleft for prefix - if (_MyItemInfo.IsStep && !_MyItemInfo.FormatStepData.UseSmartTemplate) - { - if (_MyItemInfo.FormatStepData.Prefix != null && _MyItemInfo.FormatStepData.Prefix != "") - { - string pref = _MyItemInfo.FormatStepData.Prefix.Replace("{Backspace}", ""); - float xPref = XOffset - (pref.Length * (72 / (float)_MyItemInfo.FormatStepData.Font.CPI)); - E_Style es = (E_Style)_MyItemInfo.FormatStepData.Font.Style & E_Style.Bold; - VE_Font tmpFont = new VE_Font(_MyItemInfo.FormatStepData.Font.Family, (int)_MyItemInfo.FormatStepData.Font.Size, es, (float)_MyItemInfo.FormatStepData.Font.CPI); - PartsLeft.Add(new vlnText(cb, this, pref, pref, xPref, yoff, tmpFont)); - } - } - // If checklists, the substeps are printed in a row, need to keep track of the 'longest' in - // y direction (bottommost) across the row. - if (itemInfo.IsStep && itemInfo.MyHLS != null && (itemInfo.MyHLS.FormatStepData.UseSmartTemplate || (itemInfo.MyHLS.FormatStepData.UseOldTemplate && itemInfo.MyDocStyle.ComponentList)) && (TheStepLevel(itemInfo) >= 0)) - savCheckListBottomMost = yoff + Height + (itemInfo.MyHLS.FormatStepData.UseSmartTemplate ? SixLinesPerInch : 0); - - // The following was added for BGE valve lists, this format (BGEVLV) used caution1 as - // a subheader within the valve list. To print correctly, a line needs to be added to - // where the bottom of this (subheader) is located and XOffset is set to the leftmargin. - if (itemInfo.IsStep && itemInfo.MyHLS != null && !itemInfo.ActiveFormat.PlantFormat.FormatData.PrintData.SpecialCaseCalvertAlarm && itemInfo.IsCaution1 && itemInfo.MyHLS.FormatStepData.UseOldTemplate && itemInfo.MyDocStyle.ComponentList) - { - savCheckListBottomMost += SixLinesPerInch; - yoff += Height; - XOffset = (float)itemInfo.MyDocStyle.Layout.LeftMargin; - } - - if (itemInfo.ActiveFormat.PlantFormat.FormatData.PrintData.SpecialCaseCalvertAlarm && itemInfo.IsCaution1) savCheckListBottomMost = yoff + Height; - // Get Y offset for regular steps, or if section title is output or if not within row (not last column of - // text) for wcn checklist, i.e. - if ((!itemInfo.IsStepSection && itemInfo.MyHLS != null && !itemInfo.MyHLS.FormatStepData.UseSmartTemplate) // regular step - || (ShowSectionTitles - && !MyItemInfo.MyDocStyle.CancelSectTitle - && !MyItemInfo.MyDocStyle.SpecialStepsFoldout) - // In Checklist: I don't have children or if I have children the first child doesn't alignwithparent. - || (!itemInfo.IsStepSection && itemInfo.MyHLS != null && itemInfo.MyHLS.FormatStepData.UseSmartTemplate - && ((itemInfo.Steps == null || itemInfo.Steps.Count == 0) - || !itemInfo.Steps[0].FormatStepData.StepLayoutData.AlignWithParentTab)) - || ((MyItemInfo.IsNote || MyItemInfo.IsCaution) && MyItemInfo.MyParent.IsSection)) // B2016-222 check if is a caution or note and parent is a section - { - bool doprint = !(MyPageHelper.DidHLSText && MyItemInfo.ItemID == MyPageHelper.HasHLSTextId); - if (MyItemInfo.IsSection) - { - SectionConfig sch = MyItemInfo.MyConfig as SectionConfig; - if (sch != null && sch.Section_PrintHdr != "Y") doprint = false; - } - //C2025-021 Add logic to PROMS to support a special High Level Step type that is not printed. - if (doprint && !UseTemplateKeepOnCurLine(itemInfo) && !itemInfo.IsType("InvisibleHigh")) - { - float tyoff = yoff; - if (itemInfo.Steps != null) - { - if (itemInfo.FormatStepData != null && itemInfo.FormatStepData.Type == "TitleWithTextRight") - if (loadChildren) tyoff = ChildrenRight.Add(cb, itemInfo.Steps, XOffset + 72, yoff, yoff, rnoLevel, maxRNO, formatInfo); - } - yoff += Height; - yoff = Math.Max(yoff, tyoff); - yoff += AdjustForBlankLines(); - if (dropCheckoff) - yForCheckoff += Height - SixLinesPerInch; // place checkoff on last row of text - } - } - } - if (itemInfo.ActiveFormat.PlantFormat.FormatData.PrintData.SpecialCaseCalvertAlarm) - { - // For Calvert Alarms, the row has formatting that makes this template item have a header & box - // (CONDITION/RESPONSE), header with box around it is defined in genmac whereas the lines around - // substeps are drawn in pagehelper. Adjust some yoffsets around this box. - // Need to: - // 1) move the text down a bit for top line (1.5f * SixLinesPerInch) - // 2) move the substep down 2 lines (2 * SixLinesPerInch) for bottom of box - // and space before substep - // 3) if the previous item had this condition, add space for the - // line below. - if (HasCalvertMacro) - { - YOffset += (1.5f * vlnPrintObject.SixLinesPerInch); - yoff += (2 * vlnPrintObject.SixLinesPerInch); - } - if (itemInfo.MyPrevious != null && itemInfo.MyPrevious.TemplateIndex > 0) - { - if (itemInfo.MyPrevious.ActiveFormat.PlantFormat.FormatData.Templates[itemInfo.MyPrevious.TemplateIndex].hmacro > 0) - { - YOffset += (3 * vlnPrintObject.SixLinesPerInch); - yoff += (3 * vlnPrintObject.SixLinesPerInch); - } - } - } - if (co != null && !MyItemInfo.IsInSupInfo) // C2018-002: don't print checkboxes on supplemental infromation pages. - { - // if this item's content is empty, and the flag is set to 'notonempty', don't print out the - // checkoff - this was added for shearon harris: - if (!(co.NotOnEmpty && itemInfo.MyContent.Text.Replace(@"\u160?", " ").TrimEnd() == "")) - { - float xloc_co = (float)itemInfo.MyDocStyle.Layout.LeftMargin; - // if the format has 'SkipSpaces', look at the tab, and back up the macros to the number of - // spaces in the tab. - if (formatInfo.PlantFormat.FormatData.ProcData.CheckOffData.SkipSpaces) - { - if (mytab != null) - xloc_co = mytab.XOffset; - else - xloc_co = XOffset; //there's no tab - put checkoff at step's xoff. Macro should back up from step's x. - } - else - { - if (formatInfo.PlantFormat.FormatData.ProcData.CheckOffData.XLocation != 0) - xloc_co += (float)formatInfo.PlantFormat.FormatData.ProcData.CheckOffData.XLocation; - else if (formatInfo.PlantFormat.FormatData.ProcData.CheckOffData.RelXLocation != 0) - { - float relX = (float)formatInfo.PlantFormat.FormatData.ProcData.CheckOffData.RelXLocation; - xloc_co = XOffset + (relX > 0 ? Width : 0) + relX; - } - } - - // CheckOffXtraLines was introduced for the additional lines needed for the longer signoffs - // for VCBA (&WST1), for F2016-061. - float checkOffNumberOfLines = (co.CheckOffNumberOfLines ?? 0); - if (checkOffNumberOfLines > 0) - { - yForCheckoff += (2 * SixLinesPerInch); - PartsRight.Add(new vlnMacro(xloc_co, yForCheckoff/* + xtraCheckOffLines */, co.Macro)); - yoff += ((checkOffNumberOfLines *= SixLinesPerInch) + (2 * SixLinesPerInch)); - } - else - { - // if xtraCheckOffLines is a negative number, start the checkoff on the same line - // as text and adjust the y-offset after the checkoff by the amount of the absolute - // value of xtraCheckOffLines. - // if xtraCheckOffLines is a positive number, start the checkoff xtraCheckOffLines - 1 - // down from the text and adjust the y-offset after the checkoff by the amount - // of xtraCheckOffLines. - float xtraCheckOffLines = (co.CheckOffXtraLines ?? 0); - if (xtraCheckOffLines < 0) - { - xtraCheckOffLines = -xtraCheckOffLines; - xtraCheckOffLines *= SixLinesPerInch; - PartsRight.Add(new vlnMacro(xloc_co, yForCheckoff/* + xtraCheckOffLines */, co.Macro)); - yoff += xtraCheckOffLines; - } - else - { - xtraCheckOffLines *= SixLinesPerInch; - xtraCheckOffLines -= ((xtraCheckOffLines > 0) ? SixLinesPerInch : 0); - PartsRight.Add(new vlnMacro(xloc_co, yForCheckoff + xtraCheckOffLines, co.Macro)); - yoff += (xtraCheckOffLines != 0) ? xtraCheckOffLines + SixLinesPerInch : 0; - } - } - } - } - // for WCNTRN, do the responsibility: - if (formatInfo.PlantFormat.FormatData.PrintData.WCNTraining) DoResponsibility(cb, YOffset); - float yOffRight = yoff; - float RnoOffset = ToInt(formatInfo.MyStepSectionLayoutData.ColRTable, maxRNO); - if (DoSubs && rnoLevel < maxRNO && itemInfo.RNOs != null) - { - if (loadChildren) yOffRight = ChildrenRight.Add(cb, itemInfo.RNOs, XOffset + RnoOffset, YTop, YTop, rnoLevel + 1, maxRNO, formatInfo); - if (ChildrenRight[0].ChildrenAbove.Count > 0) - { - float adj = ChildrenRight[0].YOffset - YOffset; - YOffset = ChildrenRight[0].YOffset; - yoff += adj; - if (MyTab != null) MyTab.YOffset = ChildrenRight[0].YOffset; - if (PartsRight.Count > 0) PartsRight[0].YOffset = ChildrenRight[0].YOffset; - //B2020-160 use YTopMost instead of Yoffset if there are children above. - // Get the minimun value between the AER and RNO YtopMost. - // example. Calvert AOP-7E/XIII/Step A5.h Unit 2 Approved set - //B2021-027 use YOffset if there isn't any children above (AER). - // example: Catawba Unit 1 AP’s; AP/1/A/5500/050; Enclosure 8 step 1 - if (ChildrenAbove.Count == 0) - YTopMost = ChildrenRight[0].ChildrenAbove[0].YOffset; //B2021-027 - else - YTopMost = Math.Min(ChildrenAbove[0].YTopMost, ChildrenRight[0].ChildrenAbove[0].YTopMost); //B2020-160 - } - } - // if this hls had a box drawn, add a line for substeps. - if (itemInfo.IsHigh && ((itemInfo.MyDocStyle.StructureStyle.Style & E_DocStructStyle.DoubleBoxHLS) == E_DocStructStyle.DoubleBoxHLS)) yoff += vlnPrintObject.SixLinesPerInch; - - // Need code to determine if the table will overlap the Right Column if it does then - // use YOffRight rather than yoff - if (DoSubs && itemInfo.Tables != null) - { - bool aerTableOrFigure = itemInfo.Tables[0].FormatStepData.Type.Contains("AER"); - // get the first table & see if it is borderless. If borderless, 16bit code removed a - // line (yoffset) before printing it: - float yoffadj = 0; - if (itemInfo.Tables[0].IsTable) - { - MyFlexGrid.LoadGrid(itemInfo.Tables[0]); - // B2018-077 added check for caution and note parts in which case we want the blank line - fix for Calvert OI-27B 6.11.B and 6.12.B - if (MyFlexGrid.BorderStyle == C1.Win.C1FlexGrid.Util.BaseControls.BorderStyleEnum.None && !MyFlexGrid.TopRowHasBorder() && !MyItemInfo.IsCautionOrNotePart) - yoffadj = -SixLinesPerInch; - } - // B2023-008: when an equation is off a paragraph sub-step in single column mode, extra lines were added so - // when in single column mode & the substep has an equation (rtfraw), then don't reset yoffright to yverybottom - bool rtfRawInSingleCol = (itemInfo.ColumnMode == ((int)VEPROMS.CSLA.Library.SectionConfig.SectionColumnMode.One-1)) && (itemInfo.Tables != null && itemInfo.Tables.Count > 0 && itemInfo.Tables[0].IsRtfRaw); - if (yOffRight < yoffRightParent) yOffRight = yoffRightParent; - // find the very bottom Yoffset (don't do this is in single column mode for cautions/notes: B2016-261) - vlnParagraph parentPar = parent; - if (!rtfRawInSingleCol && (!((MyItemInfo.IsCaution || MyItemInfo.IsNote) && itemInfo.RNOLevel == 0))) - { - while (parentPar != null && parentPar.MyItemInfo.IsStep) - { - float vb = parentPar.YVeryBottom; - if (yOffRight < vb) yOffRight = vb; - parentPar = parentPar.MyParent; - } - } - bool rightLonger = yOffRight > yoff; - if (!aerTableOrFigure && itemInfo.RNOLevel == 0) // Centered Table - { - if (loadChildren) - yoff = ChildrenBelow.Add(cb, itemInfo.Tables, XOffset, rightLonger ? yOffRight : yoff + yoffadj, yOffRight + yoffadj, rnoLevel, maxRNO, formatInfo); - } - else // AER or RNO Table - if (loadChildren) - yoff = ChildrenBelow.Add(cb, itemInfo.Tables, XOffset, yoff + yoffadj, yOffRight + yoffadj, rnoLevel, maxRNO, formatInfo); - } - yOffRight = Math.Max(yOffRight, yoffLeft); - // Look for the meta section case where the 'Editable' flag is set to 'N', which means that - // these steps should not be printed: - bool printsteps = true; - if (itemInfo.Steps != null && itemInfo.IsSection && itemInfo.Sections != null && itemInfo.Sections.Count > 0) - { - SectionConfig sc = itemInfo.MyConfig as SectionConfig; - if (sc != null && sc.SubSection_Edit != "Y") printsteps = false; - } - bool rnoBefore = false; - bool rnoAfter = false; - if (rnoLevel >= maxRNO && itemInfo.RNOs != null && - !itemInfo.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.WolfCreekBackgroundFormat && - !itemInfo.RNOs[0].FormatStepData.InPageList) - { - if ((itemInfo.ActiveFormat.MyStepSectionPrintData.HLRNOStpSeparatorString ?? "") != "" || - (itemInfo.ActiveFormat.MyStepSectionPrintData.HLStpSeparatorString ?? "") != "") - rnoBefore = true; - else - rnoAfter = true; - } - if (rnoBefore) - { - if ((itemInfo.ActiveFormat.MyStepSectionPrintData.HLStpSeparatorString ?? "") != "") - { - string tmpSepStr = itemInfo.ActiveFormat.MyStepSectionPrintData.HLStpSeparatorString; - float tmpSepLen = itemInfo.ActiveFormat.MyStepSectionPrintData.HLStpSeparatorString.Length; - float xsep = MyHighLevelParagraph.PartsLeft.Count > 0 ? MyHighLevelParagraph.PartsLeft[0].XOffset : MyHighLevelParagraph.XOffset; - vlnRNOSeparator mySep = new vlnRNOSeparator(this, cb, tmpSepStr, xsep, yoff, itemInfo.ActiveFormat, false); - PartsBelow.Add(mySep); - yoff += mySep.Height;// +SixLinesPerInch; - } - if (loadChildren) yoff = ChildrenBelow.Add(cb, itemInfo.RNOs, MyTab.XOffset, yoff, yoff, rnoLevel + 1, maxRNO, formatInfo); - if ((itemInfo.ActiveFormat.MyStepSectionPrintData.HLRNOStpSeparatorString ?? "") != "") - { - string tmpSepStr = itemInfo.ActiveFormat.MyStepSectionPrintData.HLRNOStpSeparatorString; - float tmpSepLen = itemInfo.ActiveFormat.MyStepSectionPrintData.HLRNOStpSeparatorString.Length; - float xsep = MyHighLevelParagraph.PartsLeft.Count > 0 ? MyHighLevelParagraph.PartsLeft[0].XOffset : MyHighLevelParagraph.XOffset; - vlnRNOSeparator mySep = new vlnRNOSeparator(this, cb, tmpSepStr, xsep, yoff, itemInfo.ActiveFormat, false); - PartsBelow.Add(mySep); - yoff += mySep.Height;// +SixLinesPerInch; - } - } - // For Calvert Alarms, 'Caution1' was used to implement the Annunciator Window, i.e. is printed - // below the HLS and close to the right margin. - if (itemInfo.ActiveFormat.PlantFormat.FormatData.PrintData.SpecialCaseCalvertAlarm && itemInfo.Cautions != null && itemInfo.Cautions[0].FormatStepData.Type == "Caution1") - { - if (loadChildren) - yoff = ChildrenBelow.Add(cb, itemInfo.Cautions, xoff, yoff, yoff, rnoLevel, maxRNO, formatInfo); - savCheckListBottomMost = yoff; - } - if (DoSubs && itemInfo.Steps != null && printsteps) - { - if (itemInfo.FormatStepData == null || itemInfo.FormatStepData.Type != "TitleWithTextRight") - if (rnoBefore) - { - if (loadChildren) - yoff = ChildrenBelow.Add(cb, itemInfo.Steps, MyTab.XOffset, yoff, yOffRight, rnoLevel, maxRNO, formatInfo); - } - else - if (loadChildren) yoff = ChildrenBelow.Add(cb, itemInfo.Steps, XOffset, yoff, yOffRight, rnoLevel, maxRNO, formatInfo); - } - if (itemInfo.Sections != null) - if (loadChildren) - yoff = ChildrenBelow.Add(cb, itemInfo.Sections, xoff, yoff, yoff, rnoLevel, maxRNO, formatInfo, pp); - if (itemInfo.Procedures != null) - if (loadChildren) - yoff = ChildrenBelow.Add(cb, itemInfo.Procedures, xoff, yoff, yoff, rnoLevel, maxRNO, formatInfo); - // Don't add the RNO to print if doing backgrounds. That piece of data is part of the pagelist item. - if (rnoAfter) - if (loadChildren) - yoff = ChildrenBelow.Add(cb, itemInfo.RNOs, XOffset, yoff, yoff, rnoLevel + 1, maxRNO, formatInfo); - YBottomPagination = yoff;// B2019-111 Exclude Right for Pagination - yoff = Math.Max(yoff, yOffRight); - // TODO - use RNOSepAfterAER flag too: - string tmpRnoSepStr = formatInfo.MyStepSectionPrintData.RNOSepString; - float tmpRnoSepLen = formatInfo.MyStepSectionPrintData.RNOSepLineLength ?? 0; - if (rnoLevel < maxRNO && itemInfo.RNOs != null && (tmpRnoSepStr != null || tmpRnoSepLen != 0)) - { - vlnParagraph rno = ChildrenRight[0]; - vlnParagraph bottomChild = BottomChild; - float xsep = MyHighLevelParagraph.XOffset + RnoOffset; - - // ip3 has an rno separator and also has asterisk boxes around continous HLS. If - // the hls has RNOs off of it, then the rno separator line is outside of the box. If - // there are RNOs, but not off of HLS, then rno separator line is within the box (this is - // how 16bit proms did this). The following use of yadjSep and YBottomForBox handle that - float yadjSep = (MyItemInfo.MyHLS.FormatStepData.StepLayoutData.STBoxindex != null && MyItemInfo.MyHLS.FormatStepData.StepLayoutData.STBoxindex >= 0 && - MyItemInfo.MyHLS.RNOs != null && MyItemInfo.MyHLS.RNOs.Count > 0) ? 2 * SixLinesPerInch : 0; - vlnRNOSeparator myRnoSep = new vlnRNOSeparator(this, cb, tmpRnoSepStr, xsep, yoff + yadjSep, formatInfo, bottomChild == null ? true : bottomChild.MyItemInfo.HasChangeBar); - // TODO: May need to handle more than one RNO column for RNO Separator - if ((rno.LastRNO.MyItemInfo.HasChangeBar == false && bottomChild != null && bottomChild.MyItemInfo.HasChangeBar) - || (bottomChild != null && bottomChild.YBottom > rno.LastRNO.YBottomMost)) - bottomChild.PartsBelow.Add(myRnoSep); - else - rno.LastRNO.PartsBelow.Add(myRnoSep); - MyHighLevelParagraph.YBottomForBox = 0; - if (yadjSep > 0) - { - MyHighLevelParagraph.YBottomForBox = yoff; // if hlrno, box before sep - YBottomMostAdjust = SixLinesPerInch; // added for IP3 pagination, the RNO separator is outside asterisk box - } - yoff += (myRnoSep.Height + SixLinesPerInch); - } - // if in WCNTRN (Wolf Creek Training), need to consider the ysize of the Responsibility text when setting - // YBottomMost, i.e. if the Responsibilty has more height (y-direction) compared to the actual step text, - // need to move down on page the height of the responsibility. - if (formatInfo.PlantFormat.FormatData.PrintData.WCNTraining && MyItemInfo.IsHigh) - { - if (PartsLeft.Count > 0 && PartsLeft[0] is vlnText) - { - foreach (vlnText vt in PartsLeft) - yoff = Math.Max(yoff, vt.YOffset + vt.Height); - } - } - YBottomMost = yoff; - - if ((MyItemInfo.IsHigh || MyItemInfo.IsCaution1) && MyItemInfo.MyDocStyle.LandscapePageList && MyItemInfo.MyDocStyle.ComponentList) - { - // put out line after step (for BGEVLV format) - float macroY = YBottomMost - (0.25f * SixLinesPerInch); - PartsLeft.Add(new vlnMacro((float)MyItemInfo.MyDocStyle.Layout.LeftMargin, macroY, "B9")); - } - - // For Checklist, the substeps are in rows of data. The YBottomMost is the bottom most for - // the row. - if (savCheckListBottomMost != 0) YBottomMost = Math.Max(savCheckListBottomMost, YBottomMost); - if (XOffsetCenter != null) XOffset = (float)XOffsetCenter; - ProfileTimer.Pop(profileDepth); - } - - private vlnTab GetSupInfoTab(PdfContentByte cb, ItemInfo itemInfo, float yoff, vlnTab mytab, bool doSectTab, float localXOffset) - { - string strmytab = null; - if (itemInfo.MyParent.IsHigh) - strmytab = itemInfo.MyTab.CleanText; - else if (itemInfo.MyParent.IsCaution) - strmytab = "Caution"; - else if (itemInfo.MyParent.IsNote) - strmytab = "Note"; - else - { - // B2018-022: use flag to determine whether to pre-pend the parent's tab as part of the supplemental info tab - // (if the procedure tab is long, such as in Farley, the tab overwrites text in the supplemental info pages) - strmytab = itemInfo.ActiveSection.ActiveFormat.PlantFormat.FormatData.PrintData.SupInfoIncludeParTab - ? ItemInfo.GetCombinedTab(itemInfo.MyParent, itemInfo.MyParent.MyParent.CombinedTab) - : itemInfo.MyTab.CleanText; - } - strmytab = strmytab.Trim(); - mytab = new vlnTab(cb, this, strmytab, strmytab, localXOffset, yoff, itemInfo.MyTab.MyFont, doSectTab, StepRTB.MySymbolFontName, itemInfo.MyTab.RemovedStyleUnderline); - return mytab; - } - private static VE_Font _AnnotationFont; - public static VE_Font AnnotationFont - { - get { return vlnParagraph._AnnotationFont; } - set { vlnParagraph._AnnotationFont = value; } - } - - // Check to see if the procedure has any printable text in the annotations - private bool? _CanDoPrintableText = null; - public bool CanDoPrintableText - { - get - { - if (_CanDoPrintableText == null) - { - _CanDoPrintableText = false; - AnnotationTypeInfoList atil = AnnotationTypeInfoList.Get(); - foreach (AnnotationTypeInfo ati in atil) - { - AnnotationTypeConfig atc = new AnnotationTypeConfig(ati.Config); - if (atc.PrintableText_XLocation != 0) - { - _CanDoPrintableText = true; - break; - } - } - } - return (bool)_CanDoPrintableText; - } - } - private void DoAnnotationPrintableText(PdfContentByte cb, ItemInfo itemInfo, float yoff) - { - // check to see if this procedure has any printable annotations. - // if it does not, then there is no need to spin through checking for the given itemInfo - if (!CanDoPrintableText) return; - - // if this step has an Annotation and it has config data to define location, parse out '[xx]' and print it at the location - // this was added for VC Summer (unit 2 & 3) but is available for any data that has defined the location in the config (from the folder properties - // at the top node - annotationtype tab. - if (itemInfo.ItemAnnotationCount > 0) - { - foreach (AnnotationInfo ai in itemInfo.ItemAnnotations) - { - // get the annotation type from the annotation, and see if it has a print location: - AnnotationTypeInfo at = ai.MyAnnotationType; - AnnotationTypeConfig atc = new AnnotationTypeConfig(at.Config); - if (atc.PrintableText_XLocation != 0) - { - int st = ai.SearchText.IndexOf("["); - int end = ai.SearchText.IndexOf("]"); - if (st != -1 && end != -1 && end > st) - { - string pref = ai.SearchText.Substring(st + 1, end - st - 1); // annotation - parse out [xx] - pref = Regex.Replace(pref, "{Up}", @"\u8593?", RegexOptions.IgnoreCase); - pref = Regex.Replace(pref, "{Down}", @"\u8595?", RegexOptions.IgnoreCase); - float xPref = atc.PrintableText_XLocation; - if (AnnotationFont == null) - AnnotationFont = new VE_Font(_MyItemInfo.FormatStepData.Font.Family, 6, (E_Style)_MyItemInfo.FormatStepData.Font.Style, 20F); - PartsLeft.Add(new vlnText(cb, this, pref, pref, xPref, yoff, AnnotationFont)); - break; - } - } - } - } - } - - private float AdjustLocIfLongerRNO(ItemInfo itemInfo, float yoff, float yoffRightParent) - { - if (!itemInfo.IsInRNO && yoffRightParent > yoff && itemInfo.FormatStepData.Type.Contains("AER")) - { - // is the width of this table going to cause the table to overlap the RNO - vlnParagraph parRno = FindParentRNO(); - float xMinRno = FindMinXOffsetRno(parRno); - if (XOffset + Width > xMinRno - 12) // 12 = 2 characters, so that tables don't almost touch & look like an overlap - { - if ((float)MyItemInfo.MyDocStyle.Layout.LeftMargin + Width > xMinRno) - { - yoff = yoffRightParent; - YOffset = yoff; - } - else - XOffset = (float)MyItemInfo.MyDocStyle.Layout.LeftMargin; - } - } - return yoff; - } - private float FindMinXOffsetRno(vlnParagraph parRno) - { - // Find the minimum xoffset in the rno column that overlaps in the y direction with - // the table that is currently being processed. This is necessary in order to fix the - // case where the AER table overlaps an RNO table (or tab/text) - float xcur = 0; - // YOffset/Height is for the current table, check it against the rno's yoffset & height - // if aer & rno are within y range of each other - if (YOffset <= (parRno.YOffset + parRno.Height) && (YOffset + Height) >= parRno.YOffset) - { - xcur = parRno.XOffset; - if (parRno.MyTab != null) xcur = parRno.MyTab.XOffset; - } - // recursively look at steps in the rno column to get the smallest xoffset which will - // then be used to compare to table's xoffset/width to see if there is an overlap - if (parRno.ChildrenBelow != null) - { - foreach (vlnParagraph vp in parRno.ChildrenBelow) - { - // yoffset is past where the table is, so don't consider it: - if (vp.YOffset > (YOffset + Height)) return xcur; - - float xchild = FindMinXOffsetRno(vp); - if (xchild > 0 && (xcur == 0 || xchild < xcur)) - xcur = xchild; - } - } - return xcur; - } - private void DoResponsibility(PdfContentByte cb, float yoff) // WCNTRN's text in 1st column (saved in config for HLS) - { - StepConfig sc2 = MyItemInfo.MyConfig as StepConfig; - if (sc2 != null) - { - string resp = sc2.Step_Responsibility; - - if (resp != null && resp != "") // lines are separated by "\r\n" - { - resp = DelimitResponse((int)MyItemInfo.MyDocStyle.SectTop.MaxLen, resp); - if (!resp.EndsWith("\r\n")) resp = resp + "\r\n"; // parsing needs this. - int indx = resp.IndexOf("\r\n"); - int stindx = 0; - float y = yoff; - while (indx > -1) - { - string subresp = resp.Substring(stindx, indx - stindx); - float respWidth = subresp.Length * 6; - float ctr = (float)MyItemInfo.MyDocStyle.SectTop.Margin; - float respcntrX = (float)MyItemInfo.MyDocStyle.Layout.LeftMargin + ctr - (respWidth / 2); - vlnText myResp = new vlnText(cb, this, subresp, subresp, respcntrX, y, MyItemInfo.FormatStepData.Font); - PartsLeft.Add(myResp); - y += SixLinesPerInch; - stindx = indx + 2; - indx = stindx < resp.Length ? resp.IndexOf("\r\n", stindx) : -1; - } - } - } - } - private string DelimitResponse(int maxLen, string responsStr) - { - // This code handles whether user enters \r\n to separate lines or not. The - // max width that a line can be in the Responsibility column is a format flag (passed in) - List results = new List(); - int width = 0; // keep track of current width of current 'line' while looking for space to break - int start = 0; // start of line (index into string 'text') - int lastspace = 0; // location of lastspace (index into string) - for (int indx = 0; indx < responsStr.Length; indx++) - { - if ((indx + 1) < responsStr.Length && responsStr.Substring(indx, 2) == "\r\n") - { - results.Add(responsStr.Substring(start, indx - start).Trim(" ".ToCharArray()) + "\r\n"); - start = indx + 2; - width = 0; - } - else - { - if (responsStr[indx] == ' ') lastspace = indx; - width++; - if (width > maxLen) - { - // what should be done if lastspace == 0 - // cannot find space char to split on, so break the word - bool spFound = true; - if (lastspace == 0) - { - lastspace = indx; - spFound = false; - } - results.Add(responsStr.Substring(start, lastspace - start).Trim(" ".ToCharArray()) + "\r\n"); - start = lastspace + (spFound ? 1 : 0); // increment start based on whether a space is found, i.e. if no space keep at 'indx' - // width either is equal to width of text after the last space, or is zero if at the maxlen of width: - width = (indx - lastspace - 1) > 0 ? indx - lastspace - 1 : 0; - lastspace = 0; - } - } - } - if (width > 0 || start < responsStr.Length) results.Add(responsStr.Substring(start).Trim(" ".ToCharArray())); - string retval = null; - foreach (string st in results) retval = retval + st; - return retval; - } - public override string Rtf - { - get - { - if (_Rtf == null) BuildRtf(); - return _Rtf; - } - set { _Rtf = value; } - } - private void BuildRtf() - { - int profileDepth = ProfileTimer.Push(">>>> BuildRtf"); - if (_Rtf == null) - { - if (MyItemInfo.ActiveFormat.PlantFormat.FormatData.PrintData.SpecialCaseCalvertAlarm && MyItemInfo.IsCaution1 && - MyItemInfo.MyContent.Text.StartsWith(@"\u") && !MyItemInfo.MyContent.Text.StartsWith(@"\u160?")) - { - Rtf = GetRtf(MyItemInfo, " " + (Prefix ?? ""), Suffix); - PrefixSpecialCharacter = true; - } - else - { - Rtf = GetRtf(MyItemInfo, Prefix, Suffix); - } - // Need the following with some modifications for WCNCKL format: - if (Rtf.Contains("{Backspace}")) - { - XOffset -= 25; - Width += 24; - Rtf = Rtf.Replace("{Backspace}", ""); - } - } - Rtf = FixRTFToPrint(MyItemInfo, Rtf); - ProfileTimer.Pop(profileDepth); - } - // C2018-024 I in Arial font changed to I in TimesNewRoman - private static System.Drawing.Font _TNR; - // F2018-013 Changed to static and public so that it can be used with step identifiers for bullets - public static string FixRTFToPrint(ItemInfo myItemInfo, string rtf) - { - // Only do this if the text contains symbols. - if ((rtf.Contains("VESymbFix") || rtf.Contains(Volian.Base.Library.vlnFont.ProportionalSymbolFont))) // C2017-036 get best available proportional font for symbols - { - // bug fix: B2017-117 was getting an out of window handles error when doing a print all for Bryon - // add the using statment to free up window handle that is created doing a New RichTextBox() - using (System.Windows.Forms.RichTextBox rtb = new System.Windows.Forms.RichTextBox()) - { - rtb.Rtf = rtf.Replace(@"\\", ""); // rename backslash character to avoid RTF confusion - //string showRTF = rtf; - bool changed = false; - // C2018-024 I in Arial font changed to I in TimesNewRoman - if (myItemInfo.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.ChangeFontUpperCaseIinArial) - { - bool lastWasNumber = false; - for (int i = 0; i < rtb.TextLength - 1; i++) - { - rtb.Select(i, 2); - if (rtb.SelectionLength == 2) - { - if ((rtb.SelectedText == ".I") && rtb.SelectionFont.FontFamily.Name == "Arial") - { - if (_TNR == null) - _TNR = new System.Drawing.Font("Times New Roman", rtb.SelectionFont.Size, rtb.SelectionFont.Style); - if (lastWasNumber) - { - rtb.SelectionFont = _TNR; - changed = true; - lastWasNumber = false; - } - } - else - lastWasNumber = Regex.IsMatch(rtb.SelectedText, @"[0-9]\."); - } - } - } - // C2017-008 - WCN wants the box symbol to look like their checkoff/signoff box - // Check for a list of replacement character for symbols in the format file - // ReplaceSymbolChars lets you do one or more of the following with a symbol character: - // - change the point size - // - change the style - // - change the font family - // - change the symbol character - // - // below is taken from the BaseAll format file - is currently commentout and there for reference - // Wolf Creek (WCN) currently uses this to increase the size of the box symbol - // - // - // - // - // get the list of symbol replacements - FormatData fmtdata = (myItemInfo.ActiveFormat != null) ? myItemInfo.ActiveFormat.PlantFormat.FormatData : FormatInfo.PROMSBaseFormat.FormatData; - ReplaceSymbolCharList SymReplaceList = (fmtdata != null && fmtdata.SectData.ReplaceSymbolCharList != null) ? fmtdata.SectData.ReplaceSymbolCharList : null; - // Look at one character at a time - for (int i = 0; i < rtb.TextLength; i++) - { - rtb.Select(i, 1); - if ((rtb.SelectedRtf.Contains("VESymbFix") || rtb.SelectedRtf.Contains(Volian.Base.Library.vlnFont.ProportionalSymbolFont)) && rtb.SelectedText.Length > 0) // C2017-036 get best available proportional font for symbols - { - for (int j = 0; j < SymReplaceList.MaxIndex; j++) - { - ReplaceChar rc = SymReplaceList[j]; - if (rc.Unicode != null && (rc.Family != null || rc.Size != null || rc.Style != null)) - { - char rc_uchar = Convert.ToChar(Convert.ToInt32(rc.Unicode)); - if (rc_uchar == rtb.SelectedText[0]) - { - //use bolding underline italics from local font - System.Drawing.Font fnt = rtb.SelectionFont; - // follow through in fixing an Out of Window Handles bug, use new function to see if - // we can retrieve the font from a dictionary instead a doing a New and using another - // window handle B2017-117 - //System.Drawing.Font fntw = new System.Drawing.Font((rc.Family != null) ? rc.Family : fnt.FontFamily.Name, (rc.Size != null) ? (float)rc.Size : fnt.Size, (rc.Style != null) ? (System.Drawing.FontStyle)rc.Style : fnt.Style); - System.Drawing.Font fntw = VE_Font.GetWinSysFont((rc.Family != null) ? rc.Family : fnt.FontFamily.Name, (rc.Size != null) ? (float)rc.Size : fnt.Size, (rc.Style != null) ? (System.Drawing.FontStyle)rc.Style : fnt.Style); - rtb.SelectionFont = fntw; - if (rc.Replace != null) - { - char rc_RplChar = Convert.ToChar(Convert.ToInt32(rc.Replace)); - rtb.SelectedText = rc_RplChar.ToString(); - } - changed = true; - break; // break out of foreach loop since we changed the character - } - } - } - } - } - if (changed) - { - if (rtb.Rtf.EndsWith(" \\par\r\n}\r\n") && rtf.EndsWith(" }")) //B2018-060 rtb.RTF added extra new line characters and commands to the end. so remove it. - rtf = rtb.Rtf.Replace(" \\par\r\n}\r\n", " }"); - else - rtf = rtb.Rtf; - return rtf.Replace("", @"\\"); // put back the backslash character - } - } - } - return rtf; - } - - // for Calvert (BGE) alarms, some step text is kept on the same line as its parent. This - // is flagged by the -1 row in the template definition. - private bool KeepOnParentLine(ItemInfo itemInfo) - { - int tindx = itemInfo.TemplateIndex; - if (tindx < 0) return false; - if (itemInfo.ActiveFormat.PlantFormat.FormatData.Templates[tindx].row == -1) return true; - return false; - } - - private void AdjustYOffset(float yDelta) - { - YOffset -= yDelta; - foreach (vlnPrintObject vpo in PartsAbove) - vpo.YOffset -= yDelta; - foreach (vlnParagraph vp in ChildrenBelow) - vp.AdjustYOffset(yDelta); - } - - private void BuildPlacekeeper(vlnParagraph parent, ItemInfo itemInfo) - { - if (itemInfo is SectionInfo && (itemInfo as SectionInfo).SectionConfig.Section_Placekeeper.ToUpper() != "N") // if is a section type and the section is marked to create placekeeper - { - MyPlaceKeeper = new pkParagraph(this); - if (parent != null && parent.MyItemInfo.IsSection) - parent.MyPlaceKeeper = MyPlaceKeeper; - } - else if (parent != null && parent.MyPlaceKeeper != null && itemInfo is StepInfo)//InList(parent.MyItemInfo.ItemID, 513, 514, 519, 520, 525)) - { - StepConfig sc = itemInfo.MyConfig as StepConfig; - if (sc != null && sc.Step_Placekeeper.ToUpper() != "N") - { - if (itemInfo.IsCautionPart || itemInfo.IsNotePart) - MyPlaceKeeper = parent.MyPlaceKeeper.AddCautionsAndNotes(this); - else - MyPlaceKeeper = parent.MyPlaceKeeper.AddChild(this); - } - } - } - - private void BuildContinuousActionSummary(vlnParagraph parent, ItemInfo itemInfo) - { - if (itemInfo is SectionInfo) - { - MyContAct = new pkParagraph(this); - if (parent != null && parent.MyItemInfo.IsSection) - parent.MyContAct = MyContAct; - } - else if (itemInfo is StepInfo) - { - StepConfig sc = itemInfo.MyConfig as StepConfig; - if ((sc != null && sc.Step_CAS == "True") || ((sc == null || sc.Step_CAS == null) && itemInfo.IncludeOnContActSum)) - { - // save this step info for use on the Continuous Action Summary - vlnParagraph tparent = parent; - while (tparent != null && tparent.MyContAct == null) - tparent = tparent.MyParent; - if (parent.MyContAct != null) - { - if (itemInfo.IsCautionPart || itemInfo.IsNotePart) - MyContAct = parent.MyContAct.AddCautionsAndNotes(this); - else - MyContAct = parent.MyContAct.AddChild(this); - } - else - MyContAct = tparent.MyContAct.AddChild(this); - } - } - } - private void BuildTimeCriticalActionSummary(vlnParagraph parent, ItemInfo itemInfo) - { - if (itemInfo is SectionInfo) - { - MyTimeCriticalAction = new pkParagraph(this); - if (parent != null && parent.MyItemInfo.IsSection) - parent.MyTimeCriticalAction = MyTimeCriticalAction; - } - else if (itemInfo is StepInfo) - { - StepConfig sc = itemInfo.MyConfig as StepConfig; - if ((sc != null && sc.Step_TCAS == "True") || ((sc == null || sc.Step_TCAS == null) && itemInfo.IncludeOnTimeCriticalActionSum)) - { - // save this step info for use on the Continuous Action Summary - vlnParagraph tparent = parent; - while (tparent != null && tparent.MyTimeCriticalAction == null) - tparent = tparent.MyParent; - if (parent.MyTimeCriticalAction != null) - { - if (itemInfo.IsCautionPart || itemInfo.IsNotePart) - MyTimeCriticalAction = parent.MyTimeCriticalAction.AddCautionsAndNotes(this); - else - MyTimeCriticalAction = parent.MyTimeCriticalAction.AddChild(this); - } - else - MyTimeCriticalAction = tparent.MyTimeCriticalAction.AddChild(this); - } - } - } - - private vlnParagraph FindParentRNO() - { - if (ChildrenRight != null && ChildrenRight.Count > 0) return ChildrenRight[0]; - return MyParent.FindParentRNO(); - } - - private string GetMacroName(string str) - { - int mindx = str.IndexOf(@"{!"); - string macro = str.Substring(mindx + 2, str.Length - 3); - return macro; - } - - private int TheStepLevel(ItemInfo itemInfo) - { - if (itemInfo.IsHigh) return -1; - int lev = 0; - ItemInfo ii = itemInfo; - while (!ii.MyParent.IsHigh) - { - lev++; - ii = ii.MyParent; - } - return lev; - } - - private string SectionHasCheckOffHeader(ItemInfo itemInfo, ref VE_Font font) - { - // If the passed in itemInfo is not a section, get it's parent section. This may be a subsection, so - // it will be found here, versus using 'MyActiveSection'. - while (!itemInfo.IsSection) - { - itemInfo = itemInfo.MyParent; - } - // See if this section has a checkoffheading index - this value, if set is stored in the config field. - // -1 flags no entries in the format's CheckOffHeaderList & 0 flags the first - // entry which is always '{NO HEADING}'. So only continue if it's greater than 0. - //SectionInfo si = SectionInfo.Get(itemInfo.ItemID); // sometimes the itemInfo isn't a section info - SectionInfo si = itemInfo.GetSectionInfo(); // sometimes the itemInfo isn't a section info - int sindx = si.CheckOffHeadingIndex(); - - // If there is a checkoff header for this section, see if this section has subsections. - // If this has a header but no subsections, put out the header. - // Else if this section has a header AND subsections, don't put it out... - // the subsection's checkoff header will be processed (or lack there of). - bool doCheckoffHeader = sindx > 0 && (itemInfo.Sections == null || itemInfo.Sections.Count == 0); - - // if doing it, then grab the string from the format.... CHECK if this works for subsection, it is - // getting ActiveSection which may return the top section, not subsections. - if (doCheckoffHeader && itemInfo.SectionCheckOffHeader != "") - { - font = itemInfo.ActiveFormat.PlantFormat.FormatData.ProcData.CheckOffData.CheckOffHeaderList[sindx].Font; - return itemInfo.SectionCheckOffHeader; - } - return null; - } - - private void DoCheckOffHeader(PdfContentByte cb, ItemInfo itemInfo, float yLocation, float yTopMargin, float yPageStart) - { - // CheckOffHeaders are handled in two different ways: - // 1) Where the pagelist item puts them - this is at the 'top' of the page, when the current section on the - // page has a checkoff header defined. Support for this is here AND in the VlnSvgPageHelper pagelist code. - // 2) If a continuous section, and it doesn't start at 'top' of the page, then the checkoff header is - // printed on the same line as the continuous section. Support for this is here, the check off header is added - // to the 'PartRight' off of the section's VlnParagraph. - - // First see if there is any checkoff data in the format file and that there - // is a pagelist item for the checkoff header. - int maxindx = itemInfo.ActiveFormat.PlantFormat.FormatData.ProcData.CheckOffData.CheckOffList.MaxIndexNoInherit; - if (maxindx <= 0) return; - if (MyPageHelper.PageListCheckOffHeader == null) return; - - VE_Font font = null; - ItemInfo mySectionInfo = itemInfo.ActiveSection; // C2018-003 fixed use of getting the active section - ItemInfo mySubSectionInfo = itemInfo; - - // If the passed in itemInfo is not a section, get it's parent section. This may be a subsection, so - // it will be found here, versus using 'MyActiveSection' which is the topmost section. The passed in - // item may be a regular step, i.e. if a page break had occurred. - if (!itemInfo.IsSection) - { - while (!mySubSectionInfo.IsSection) - { - mySubSectionInfo = mySubSectionInfo.MyParent; - } - } - else - mySubSectionInfo = (mySectionInfo == null || mySectionInfo.Sections == null) ? null : mySectionInfo.Sections[0]; - - if (mySectionInfo == mySubSectionInfo) mySubSectionInfo = null; - - // The following duplicates the 16bit logic. The 16bit logic only put out a header if: - // there is no subsection and section has a header (from config); - // OR there is a subsection and the first subsection has a header. - // For locating the header in 16bit logic: - // If no subsections, output with section - // If subsections and continuous section, put out on same line as subsection. (done here) - // If subsections and starts at top of page, (on top of page, use pagelist code in VlnSvgPageHelper) - - // Get SectionInfos to access specific section config items... - //SectionInfo si = SectionInfo.Get(mySectionInfo.ItemID); - SectionInfo si = (mySectionInfo != null)? mySectionInfo.GetSectionInfo() : null; - int sindx = si.CheckOffHeadingIndex(); - //SectionInfo subi = mySubSectionInfo == null ? null : SectionInfo.Get(mySubSectionInfo.ItemID); - SectionInfo subi = (mySubSectionInfo == null)? null : mySubSectionInfo.GetSectionInfo(); - int subindx = (subi == null)? -1 : subi.CheckOffHeadingIndex(); - - // if there is no subsections & the main section doesn't use a header OR - // if there is a subsection, & it does not use a header... Return. - if ((subi == null && sindx < 1) || (subi != null && subindx < 1)) return; - - // figure out location now: - // if step, it uses pagelist logic to locate it (this is a page break condition). - // if continuous, put out with subsection if there is one, otherwise section. - // otherwise, use pagelist logic. - bool usePageListCOHdr = false; - - // B2022-129: Barakah - Adjust the INITIAL header location, i.e. make it a pagelist item - if (itemInfo.IsStep || itemInfo.MyDocStyle.AdjSectTitleLoc) - { - usePageListCOHdr = true; - } - // This checks to see if the section is starting at the top of the page. - // If it is, then we want to use PageList to print the checkoff/sighoff header - // else the checkoff/signoff header will be printed across from the section title where ever it is on the page (i.e. section pagination set to continuous) - else if (subi == null) //no subsection - { - // B2021-106 added check if the section has a note or caution - if ((yPageStart - YOffset) == yTopMargin || mySectionInfo.HasCautionOrNote) usePageListCOHdr = true; - } - else // there is a sub-section - { - // B2021-106 added check if the section has a note or caution - if (mySectionInfo == itemInfo && ((yPageStart - YOffset) == yTopMargin) || mySectionInfo.HasCautionOrNote) usePageListCOHdr = true; - if (!usePageListCOHdr && mySubSectionInfo != itemInfo) return; - } - - // grab the string from the format, depending on whether it should get it from the section or subsection. - string cohead = (mySubSectionInfo != null) ? mySubSectionInfo.SectionCheckOffHeader : (mySectionInfo != null)? mySectionInfo.SectionCheckOffHeader : null; - if (cohead == "" || cohead == null) return; - - // PageListCheckOffHeader is an svgtext - but really we only need the x/y location for this (pagelist support) - // The actual text is from the checkoff header selection in the section config. - if (cohead != MyPageHelper.PageListLastCheckOffHeader) - { - font = mySectionInfo.ActiveFormat.PlantFormat.FormatData.ProcData.CheckOffData.CheckOffHeaderList[sindx].Font; - float chkOffY = CalculateYLocation(YTop, yTopMargin); - if (MyPageHelper.YMultiplier != 1) - { - chkOffY = -1 + yTopMargin - (yTopMargin - yLocation) * MyPageHelper.YMultiplier; - if (Rtf != null) - IParagraph.Leading = _SevenLinesPerInch; - } - if (!usePageListCOHdr) - { - vlnText myCOHead = new vlnText(cb, this, cohead, cohead, MyPageHelper.PageListCheckOffHeader.X.Value + (float)MyItemInfo.MyDocStyle.Layout.LeftMargin, chkOffY, font); - PartsRight.Add(myCOHead); - } - else - MyPageHelper.PageListTopCheckOffHeader = cohead; - MyPageHelper.PageListLastCheckOffHeader = cohead; - } - } - internal vlnParagraph BottomChild - { - get - { - float bottomChildYBottomText = YBottomText; - vlnParagraph bottomChild = this; - foreach (vlnParagraph child in ChildrenRight) - { - vlnParagraph grandChild = child.BottomChild; - if (grandChild != null && grandChild.YBottomText > bottomChildYBottomText) bottomChild = grandChild; - if (grandChild != null && grandChild.YBottomText == bottomChildYBottomText && grandChild.MyItemInfo.HasChangeBar) bottomChild = grandChild; - bottomChildYBottomText = bottomChild.YBottomText; - } - foreach (vlnParagraph child in ChildrenBelow) - { - vlnParagraph grandChild = child.BottomChild; - if (grandChild != null && grandChild.YBottomText > bottomChildYBottomText) bottomChild = grandChild; - if (grandChild != null && grandChild.YBottomText == bottomChildYBottomText && grandChild.MyItemInfo.HasChangeBar) bottomChild = grandChild; - bottomChildYBottomText = bottomChild.YBottomText; - } - return bottomChild; - } - } - private void CalculateXOffsetGridOrFigure(ItemInfo itemInfo, int maxRNO, FormatInfo formatInfo) - { - float scale = itemInfo.IsRtfRaw ? 0.6f : 1.0f; - bool aerTableOrFigure = itemInfo.FormatStepData.Type.Contains("AER"); - vlnParagraph hls1 = MyParent; - if (!formatInfo.PlantFormat.FormatData.PrintData.SpecialCaseCalvertAlarm && !itemInfo.IsInSupInfo) - while (hls1.MyParent != null && !hls1.MyItemInfo.IsHigh) hls1 = hls1.MyParent; - else if (itemInfo.IsInSupInfo) - while (hls1.MyParent != null && !hls1.MyItemInfo.IsSupInfoPart) hls1 = hls1.MyParent; - float colR = float.Parse(formatInfo.MyStepSectionLayoutData.ColRTable.Split(",".ToCharArray())[itemInfo.ColumnMode]); - float xLowerLimit = (aerTableOrFigure && hls1.PartsLeft != null && hls1.PartsLeft.Count > 0) ? hls1.PartsLeft[0].XOffset : hls1.XOffset; - float xUpperLimit = 0; - float pageWidth = ((float)itemInfo.ActiveSection.MyDocStyle.Layout.PageWidth); // C2018-003 fixed use of getting the active section - float leftMargin = ((float)itemInfo.ActiveSection.MyDocStyle.Layout.LeftMargin); // C2018-003 fixed use of getting the active section - if (itemInfo.IsInRNO) - // if in rno column, the upper limit is width of the page (right margin). Subtract off size of a character - xUpperLimit = pageWidth - (72 / (float)MyItemInfo.FormatStepData.Font.CPI); - else - // in the following calculation, the hls width (hls1.Width) == rno column width, so xUpperLimit is - // the around the right margin, i.e. 'hls xoffset' + 'location of rno (colR) * columnmode' + 'width of rno' - xUpperLimit = hls1.XOffset + hls1.Width + hls1.CheckOffWidth + colR * itemInfo.ColumnMode; - - // If a table is within the alarm section and its parent is a template item is single column - // adjust the xoffset so that the table is centered around center of page - bool ctrCalvertAlarmTbl = false; - if (formatInfo.PlantFormat.FormatData.PrintData.SpecialCaseCalvertAlarm) - ctrCalvertAlarmTbl = MyItemInfo.IsWithInSingleColumnTemplate(); - // B2019-049 added check for table being in a Caution or Note - if so, use the single column setting for the format variable TableCenterPos - float TableCenterPos = float.Parse(formatInfo.MyStepSectionLayoutData.TableCenterPos.Split(",".ToCharArray())[(itemInfo.IsInCautionOrNote)?0:itemInfo.ColumnMode]); - if (ctrCalvertAlarmTbl || formatInfo.PlantFormat.FormatData.SectData.StepSectionData.StepSectionLayoutData.TieTabToLevel) - XOffset = leftMargin + (pageWidth - leftMargin - (scale * Width)) / 2; - else - { - if (!aerTableOrFigure && itemInfo.RNOLevel == 0 && TableCenterPos != 0) // Only adjust TableCenterPos for Non-RNO Cenetered Tables - { - XOffset = TableCenterPos; - XOffset = XOffset - (this.Width / 2) + (float)itemInfo.MyDocStyle.Layout.LeftMargin; - } - else if (itemInfo.RNOLevel != 0) // RNO - XOffset = MyParent.XOffset + (MyParent.Width / 2) - ((scale * Width) / 2); - else if (aerTableOrFigure) - { - // if in the BGE alarm format and the hls is a Window (upper right corner when it prints), use the parent of the table - // to print in aer column (B2014-105) - if (MyItemInfo.IsInCalvertConditionResponse) - XOffset = hls1.XOffset + hls1.Width / 2 - Width / 2; - else - XOffset = MyHighLevelParagraph.XOffset + MyHighLevelParagraph.Width / 2 - Width / 2; - } - else // Centered Table or Figure - { - // Determine center of hls - XOffset = hls1.XOffset + hls1.Width / 2; - // Determine left edge of the table by subtracting 1/2 of its width. - XOffset -= Width / 2; - // Add in 1/2 of the width of all RNO columns - XOffset += (colR * itemInfo.ColumnMode) / 2; - - if (!aerTableOrFigure && !MyItemInfo.IsRtfRaw) - { - // 05/14/12 - 16bit code adjusts the center depending upon the CPI of the table font. - // Start with XOffset of table, then calculate the XOffset adjusted for the table font, - // based on the default CPI of 12. Adjust the XOffset by the difference of these - // two numbers. - XOffset -= (XOffset - (XOffset * (float)MyItemInfo.FormatStepData.Font.CPI / 12)); - } - XOffset -= 12; // This makes the 16bit & 32bit align very closely. - // if outside of the page margins then center within the page margins - float xOffset2 = (float)itemInfo.MyDocStyle.Layout.LeftMargin; - float xWidth2 = (float)itemInfo.MyDocStyle.Layout.PageWidth; - if (XOffset + Width > xOffset2 + xWidth2) - XOffset = xOffset2 / 2 + xWidth2 / 2 - Width / 2; - - } - // 05/14/12 - The PosAdjust is a format flag from 16bit. For WCN2, it appears that this amount equals - // the amount of difference from a 10 CPI to a 12 CPI font. See comment above. - float posAdjust = (float)(itemInfo.FormatStepData.StepPrintData.PosAdjust ?? 0); - if (itemInfo.FormatStepData != null && itemInfo.FormatStepData.StepPrintData != null && - posAdjust > 0) - { - if (Width < hls1.Width - posAdjust) - XOffset += posAdjust; - else if (Width < hls1.Width) - XOffset = hls1.XOffset + hls1.Width - Width; // align with the right edge of hls text - } - } - if (itemInfo.MyDocStyle.Layout.CenterToStepThenPage) - { - if (Width > hls1.Width) - { - float XOffsetPage = leftMargin + ((pageWidth - leftMargin) - Width) / 2; - float fraction = (Width - hls1.Width) / ((pageWidth - leftMargin) - hls1.Width); - float XOffsetNew = (1 - fraction) * XOffset + fraction * XOffsetPage; - _MyLog.WarnFormat("***XOffsetAdjust-CenterToStepThenPage*** ItemID, XOffset, XOffsetPage, XOffsetNew ={0},{1},{2},{3}", itemInfo.ItemID, XOffset, XOffsetPage, XOffsetNew); - XOffset = XOffsetNew; - } - } - else - { - // if the XOffset < High Level Step Text's XOffset , then align with the High Level Step Text' - // B2020-161 - needed to substract the checkoff width when deterniming the XOffset - // fixes centered tables in Calvert Unit 2 STP O-90-2 step 6.3.A - if (XOffset < xLowerLimit && Width < (xUpperLimit - xLowerLimit - hls1.CheckOffWidth)) - XOffset = xLowerLimit; - - // if the right margin exceeds the right edge of the rightmost RNO, then adjust right edge to match. - // In lines below, the 12 was used for Wolf Creek 2 column format, the pagewidth goes beyond the right border line so that - // the tables, figures & equations were beyond the border. -12 takes it enough so that if boxed, it won't print out of border - // We know this is not ideal. - if (MyItemInfo.IsRtfRaw && (XOffset + (scale * Width) > xUpperLimit - 12)) - XOffset = xUpperLimit - (scale * Width) - 12; - if (!MyItemInfo.IsRtfRaw && XOffset + Width > xUpperLimit) - XOffset = xUpperLimit - Width; - // because of the above, if it pushes beyond the left margin, use the left margin. - if (XOffset < (float)itemInfo.MyDocStyle.Layout.LeftMargin) - XOffset = XOffsetBox = (float)itemInfo.MyDocStyle.Layout.LeftMargin; - } - } - private float AdjustForBlankLines() - { - if (MyParent != null && MyParent.MyItemInfo.FormatStepData != null && MyParent.MyItemInfo.FormatStepData.Type == "TitleWithTextRight") return 0; - // F2022-121 added SpecialStepsFoldoutKeepWhiteSpace flag to allow for all of the other special foldout formatting, but - // not compress the page - if (MyItemInfo.MyDocStyle.SpecialStepsFoldout && !MyItemInfo.MyDocStyle.SpecialStepsFoldoutKeepWhiteSpace) return 0; - if (MyItemInfo.FormatStepData != null && MyItemInfo.FormatStepData.Prefix != null && MyItemInfo.FormatStepData.Suffix != null && MyItemInfo.FormatStepData.UseSmartTemplate) return 0; - int everyNLines = MyItemInfo.FormatStepData == null ? 1 : MyItemInfo.FormatStepData.StepLayoutData.EveryNLines ?? 1; - if (everyNLines == -99) return 0; - if (everyNLines == -1) return -SixLinesPerInch; - if (MyItemInfo.ActiveFormat.PlantFormat.FormatData.PrintData.SpecialCaseCalvertAlarm || - (MyItemInfo.ActiveFormat.PlantFormat.FormatData.PrintData.SpecialCaseCalvert && MyItemInfo.IsStep && MyItemInfo.FormatStepData.StepLayoutData.STBoxindex != null)) - { - if ((MyItemInfo.IsCaution || MyItemInfo.IsNote || MyItemInfo.MyParent.IsCaution || MyItemInfo.MyParent.IsNote) && !MyItemInfo.FormatStepData.SpaceIn - && (MyItemInfo.Steps == null || MyItemInfo.Steps.Count == 0) - && (MyItemInfo.NextItem == null || MyItemInfo.MyContent.Type != MyItemInfo.NextItem.MyContent.Type)) - { - // C2014-009: Don't add another blank line - print the calvert Condition/Response RNO Caution/Notes without it. - if (!(MyItemInfo.ActiveFormat.PlantFormat.FormatData.PrintData.SpecialCaseCalvertAlarm && MyItemInfo.IsInRNO)) - return 0; - } - //B2020-117 for multiple Calvert Condition/Response Cautions,Note, and Warnings, do add an extra blank line - // between them - if (MyItemInfo.ActiveFormat.PlantFormat.FormatData.PrintData.SpecialCaseCalvertAlarm && - MyItemInfo.IsInRNO && (MyItemInfo.IsCaution || MyItemInfo.IsNote) && - MyItemInfo != MyItemInfo.LastSibling) - return 0; - if (everyNLines == 99 && MyItemInfo.NextItem == null) - { - if (MyItemInfo.Steps != null && MyItemInfo.Steps.Count > 0 && MyItemInfo.Steps[0].MyContent.Type == MyItemInfo.MyContent.Type) return 0; - if (MyItemInfo.MyParent.NextItem != null && MyItemInfo.MyParent.NextItem.MyContent.Type == MyItemInfo.MyContent.Type) return 0; - } - } - // B2015-005: if there isn't a blank line after this step && it has children, see if there shouldn't be - // a blank line, i.e. if the first substep child's type is the same as this. - if (!MyItemInfo.IsHigh && everyNLines == 99 && MyItemInfo.NextItem == null && MyItemInfo.HasChildren) - { - ItemInfo chld = MyItemInfo.FirstChild(E_FromType.Step); - if (chld != null && chld.MyContent.Type == MyItemInfo.MyContent.Type) return 0; - } - // F2021-033: No blank line between hls and its first substep: - if (MyItemInfo.ActiveFormat.PlantFormat.FormatData.PrintData.NoBlankHlsAndFirstSub && MyItemInfo.IsHigh) - { - // F2021-060 Do not remove blank line between step and Caution, Note or Warning below it (Caution, Note, Warning are off 1st sub step) - if (MyItemInfo.Steps != null && MyItemInfo.Steps.Count > 0 && !MyItemInfo.Steps[0].HasCautionOrNote) return 0; - } - // F2021-025: Barakah single column no blank line between last Note/Caution/Warning text and bottom line of box - // C2021-049: Barakah no blank line between last Note/Caution/Warning text, include sub-step text by using 'IsInCautionOrNote' - // B2022-017: Barakah within note/caution, if note has substeps, there should be a blank line between note & 1st substep - // B2022-027: Barakah blank line not printing after list within another list. Rewrote code for all of these issues so that - // code looks up parents to see if they have next before returning a 0 (no blank line) - // B2022-042: double Caution followed by Critical Step missing bullet - // F2022-010: substeps in multiple notes, cautions, warning print differently - if (MyItemInfo.IsInCautionOrNote) - { - float adjLastBlankLineInNoteCautionWarning = 0; - // Get the box information for the Note, Caution, or Warning - ItemInfo tifo = (MyItemInfo.IsCaution || MyItemInfo.IsNote) ? MyItemInfo : MyItemInfo.ParentNoteOrCaution; - int typ = ((int)tifo.MyContent.Type) % 10000; - int? bxIndx = tifo.ActiveFormat.PlantFormat.FormatData.StepDataList[typ].StepLayoutData.STBoxindex; - if (bxIndx != null) - { - Box bx = tifo.ActiveFormat.PlantFormat.FormatData.BoxList[(int)bxIndx]; - // F2024-078 save the adjustment of the last blank line - this value will be added to the SixLinesPerInch value (a blank line) - adjLastBlankLineInNoteCautionWarning = (float)(bx.AdjLastBlnkLn ?? 0); - } - //} - // if (MyItemInfo.ActiveFormat.PlantFormat.FormatData.PrintData.NoBlankLastNoteCautionWarn && (MyItemInfo.IsInCautionOrNote)) - // F2024-078 added check for adjustment of the last blank line in the Note/Caution box - if (MyItemInfo.ActiveFormat.PlantFormat.FormatData.PrintData.NoBlankLastNoteCautionWarn || adjLastBlankLineInNoteCautionWarning != 0) - { - if ((MyItemInfo.Steps == null || MyItemInfo.Steps.Count == 0) && (MyItemInfo.NextItem == null)) // there are no sub-steps, see if any parents have next - { - ItemInfo par = MyItemInfo.MyParent; - while (par.IsInCautionOrNote) // while in the caution or note, see if there is anything below this item - { - // if there is no next item, or content types are different, go up to see if the parent has any next item. If note - // keep going up tree, otherwise there is a next so don't return 0, i.e. continue on with code to determine - // whether there is a blank line - if ((par.NextItem == null) || (par.MyContent.Type != par.NextItem.MyContent.Type)) par = par.MyParent; - else break; - } - if (!par.IsInCautionOrNote || (par != null && par.MyContent.Type != par.NextItem.MyContent.Type)) - { - if (adjLastBlankLineInNoteCautionWarning != 0) - return SixLinesPerInch + adjLastBlankLineInNoteCautionWarning; // F2024-078 adjust the size of the last blank line of Note/Caution box - else - return 0; // no blank line after last text line of Note/Caution/Warning - } - } - if ((MyItemInfo.Steps == null || MyItemInfo.Steps.Count == 0) && MyItemInfo.NextItem != null && MyItemInfo.MyContent.Type != MyItemInfo.NextItem.MyContent.Type) - { - if (adjLastBlankLineInNoteCautionWarning != 0) - return SixLinesPerInch + adjLastBlankLineInNoteCautionWarning; - else - return 0; // no blank line after last text line of Note/Caution/Warning - } - } - } - if (MyItemInfo.Ordinal % everyNLines == 0 || MyItemInfo.NextItem == null) return SixLinesPerInch; - // B2022-003: BNPP Alarms (BNPPalr) - incorrect line spacing for substeps off substeps. Added a format flag so as not to affect other plants. - if (MyItemInfo.FormatStepData != null && MyItemInfo.FormatStepData.StepPrintData != null && MyItemInfo.FormatStepData.StepPrintData.BlankAfterSubWithSub && MyItemInfo.NextItem != null && MyItemInfo.HasChildren && MyItemInfo.Steps != null && MyItemInfo.Steps.Count > 0) return SixLinesPerInch; - - // If the next table child is a figure, equation or a visio drawing add a blank line - if (MyItemInfo.Tables != null && MyItemInfo.Tables.Count > 0 && MyItemInfo.Tables[0].MyContent.MyGrid == null) return SixLinesPerInch; - // Pagination issue to be used with yEndsWithBlankLine in Pagination code, but not checked in yet. - //if (MyItemInfo.Ordinal % everyNLines == 0 || MyItemInfo.NextItem == null) return SixLinesPerInch; - return 0; - } - private void AddMacros(ItemInfo itemInfo, vlnTab mytab) - { - float y = YOffset; - float x = mytab == null ? XOffset : mytab.XOffset + mytab.TabOffset; - List myMacros = itemInfo.MyMacros; - if (myMacros != null) - { - int colMode = (MyItemInfo.ActiveSection != null)? MyItemInfo.ActiveSection.ColumnMode : 0; // C2018-003 fixed use of getting the active section - foreach (Macro myMacro in myMacros) - { - // if the format has the 'LocWithXOff' locate the macro along with the tab's offset. - // however, if the tab is more than 2 characters long, adjust so that it aligns with the - // last two characters, not the first 2. - string tabText = mytab == null ? null : mytab.Text.Trim(" .".ToCharArray()); - int tablen = (tabText == null) ? 0 : (tabText.Length <= 2) ? 0 : tabText.Length - 2; - if (myMacro.LocWithXOff ?? false) x = mytab == null ? XOffset : ((float)mytab.XOffset + (tablen * (float)mytab.MyFont.CharsToTwips)); - if (colMode == 0 && myMacro.SingleColMacroDef != null && myMacro.SingleColMacroDef.Length > 0) - { - float macroXOffset = myMacro.MacroXOffSet ?? 0; - float widthAdj = myMacro.SingleColWidthAdjust ?? 0; // set as negative number in format - float rightTextEdge = (itemInfo.IsHigh) ? XOffset + Width + mytab.XOffset : this.MyHighLevelParagraph.XOffset + this.MyHighLevelParagraph.Width; - x = (macroXOffset > 0) ? macroXOffset : rightTextEdge; - if (rightTextEdge > x) - Width += widthAdj; - PartsRight.Add(new vlnMacro(x, y, myMacro.SingleColMacroDef)); - } - else - PartsLeft.Add(new vlnMacro(x, y, myMacro.MacroDef)); - } - } - } - // HLP Change bar flags in format file: - // Locations: With Text, Outside Box, AER on Left RNO on Right, To The Left of Text - // Text: Date & Change ID, Revision Number, Change ID, None, Custom (use input data) - // Flag AERChgBarMsgRNOChgBarNoMsg and AERMsgRNONoMsg are NOT Used in 16-bit. - private string cbMess = null; - private vlnChangeBar DoChangeBar(PdfContentByte cb, ItemInfo itemInfo, VlnSvgPageHelper myPageHelper, float xoff, float yoff, int maxRNO, FormatInfo formatInfo) //, vlnChangeBar myCB) - { - // find column for the change bar based on format flags - this is code from 16-bit - // if AbsoluteFixedChangeColumn - // if FixedAERChangeColumn - // if col>ColsS+ColR+COL_WID+ADJ - // FixedChangeColumn - // else - // AERLeftChangeBarLocation() - // else - // FixedChangeColumn - // else - // ChangeBarLocation() - ChangeBarData cbd = formatInfo.PlantFormat.FormatData.ProcData.ChangeBarData; - float cols = formatInfo.MyStepSectionLayoutData.ColS ?? 0; - float colr = ToInt(formatInfo.MyStepSectionLayoutData.ColRTable, maxRNO); - // FixedChangeColumn + - Column location for change bars - // 0 - Separate AER and RNO change bars to the right of the text - // -10 to -1 - Change bars on left (specify # of columns from the text) - // <-10 - AER change bars on the left and RNO change bars on the right. - // FixedAERChangeColumn overrides the -5 default setting in chgbar.c, value is converted to a negative by the code - - float col = (cbd.AbsoluteFixedChangeColumn) ? - ((cbd.FixedAERChangeColumn ?? 0) > 0) ? - (xoff > (cols + colr + COL_WID_ADJ)) ? - cbd.FixedChangeColumn ?? 0 : AERLeftChangeBarLocation(formatInfo) : - cbd.FixedChangeColumn ?? 0 : ChangeBarLocation(xoff, this, formatInfo, maxRNO); - string chgIdTxt = null; - if (itemInfo.ActiveFormat.PlantFormat.FormatData.ProcData.ChangeBarData.ChangeIds) - { - StepConfig sc = itemInfo.MyConfig as StepConfig; - chgIdTxt = sc == null ? null : sc.Step_ChangeID; - } - if (myPageHelper.ChangeBarDefinition.MyChangeBarText == PrintChangeBarText.ChgID) - cbMess = chgIdTxt != null ? chgIdTxt : itemInfo.MyContent.UserID; - else if (myPageHelper.ChangeBarDefinition.MyChangeBarText == PrintChangeBarText.DateChgID) - { - string fmtDate = itemInfo.MyContent.DTS.ToShortDateString(); - if (fmtDate.Length != 10) // need to add zeros - { - if (fmtDate.IndexOf("/") == 1) - fmtDate = "0" + fmtDate; - if (fmtDate.IndexOf("/", 3) == 1) - fmtDate = fmtDate.Substring(0, 3) + "0" + fmtDate.Substring(3, fmtDate.Length - 3); - } - cbMess = (chgIdTxt != null ? chgIdTxt : itemInfo.MyContent.UserID) + @"\n" + fmtDate; - } - else if (myPageHelper.ChangeBarDefinition.MyChangeBarText == PrintChangeBarText.RevNum) - { - - string lRev = myPageHelper.Rev; - // Now check the format flags to determine if/how the Rev string should be parsed. - if ((itemInfo.ActiveFormat.PlantFormat.FormatData.PrintData.DoRevDate && lRev.Contains("/")) - || (itemInfo.ActiveFormat.PlantFormat.FormatData.PrintData.RevDateWithForwardSlash && lRev.Contains("\\"))) - { - int indx = lRev.IndexOf(itemInfo.ActiveFormat.PlantFormat.FormatData.PrintData.DoRevDate ? '/' : '\\'); - cbMess = lRev.Substring(0, indx > -1 ? indx : lRev.Length); - } - else - cbMess = lRev; - } - else if (myPageHelper.ChangeBarDefinition.MyChangeBarText == PrintChangeBarText.UserDef) - cbMess = myPageHelper.ChangeBarDefinition.MyChangeBarMessage; - - int msgAlign = Element.ALIGN_LEFT; - if (myPageHelper.ChangeBarDefinition.MyChangeBarLoc == PrintChangeBarLoc.LeftOfText || - (myPageHelper.ChangeBarDefinition.MyChangeBarLoc == PrintChangeBarLoc.AERleftRNOright && - !itemInfo.IsInRNO)) msgAlign = Element.ALIGN_RIGHT; - float coltotwips = col * itemInfo.FormatStepData.Font.CharsToTwips; - if (cbd.AbsoluteFixedChangeColumn) coltotwips = col * itemInfo.ActiveFormat.PlantFormat.FormatData.Font.CharsToTwips; - // B2023-052: Beaver Valley - Inconsistent change bar location - used AbsoluteFixedChangeColumn flag, but the LeftMargin - // was still added in, thus sections had different locations for change bar if sections had different left margin. Use - // adjustment, 'AbsChgBarAdj' - coltotwips += itemInfo.MyDocStyle.Layout.AbsChgBarAdj ?? 0; - if (itemInfo.IsFigure) coltotwips = col * itemInfo.ActiveFormat.PlantFormat.FormatData.Font.CharsToTwips; - return new vlnChangeBar(cb, this, (float)itemInfo.MyDocStyle.Layout.LeftMargin + coltotwips, yoff, msgAlign, - myPageHelper.ChangeBarDefinition.MyChangeBarText == PrintChangeBarText.RevNum, - itemInfo.ActiveFormat.PlantFormat.FormatData.ProcData.ChangeBarData.ChangeIds); - } - - // changed this function to return a float instead of an int to correct a rounding error which cause change bars - // to inconsistantly position next to changed text. Bug B2015-033 - private float ChangeBarLocation(float c, vlnParagraph paragraph, FormatInfo formatInfo, int maxRNO) - { - int fixedChgCol = formatInfo.PlantFormat.FormatData.ProcData.ChangeBarData.FixedChangeColumn ?? 0; - float cols = formatInfo.MyStepSectionLayoutData.ColS ?? 0; - int colr = ToInt(formatInfo.MyStepSectionLayoutData.ColRTable, maxRNO); - float tmpc = c; - Box bxCautNote = null; // used for notes and cautions in the Prairie Island Alarms format - if (MyItemInfo.IsCaution || MyItemInfo.IsNote) - { - // Temporary fix for change bars on Notes and Cautions where the FixedChgCol < -10 - tmpc = (float)formatInfo.MyStepSectionLayoutData.ColT + (float)formatInfo.MyStepSectionLayoutData.WidT; // end position of Caution / Note - int typ = (int)(MyItemInfo.MyContent.Type % 10000); - int? bxIndx = formatInfo.PlantFormat.FormatData.StepDataList[typ].StepLayoutData.STBoxindex; - if (bxIndx != null) - { - bxCautNote = formatInfo.PlantFormat.FormatData.BoxList[(int)bxIndx]; - if (bxCautNote != null) - tmpc = (float)bxCautNote.Start + (float)bxCautNote.End; // end position of a boxed Caution / Note - } - } - // if this is a caution or note, put the change bar to the right of the text: - //if ((paragraph.MyItemInfo.IsCaution || paragraph.MyItemInfo.IsNote) && fixedChgCol < -10) return -fixedChgCol; - if ((fixedChgCol == 0))// && paragraph.MyItemInfo.IsCaution || paragraph.MyItemInfo.IsNote) - //if ((fixedChgCol==0) || paragraph.MyItemInfo.IsCaution || paragraph.MyItemInfo.IsNote) - { - float rightEdge = (paragraph.XOffset + paragraph.Width + 5); - rightEdge -= (float)paragraph.MyItemInfo.MyDocStyle.Layout.LeftMargin; - if (bxCautNote != null) - rightEdge = (float)bxCautNote.End + 10; // used for notes and cautions in the Prairie Island Alarms format - rightEdge = rightEdge / paragraph.MyItemInfo.FormatStepData.Font.CharsToTwips; - return MyItemInfo.IsFigure ? rightEdge + 1 : rightEdge; // B2017-111: Add a little more space between figure & change bar - } - if (fixedChgCol < -10 || fixedChgCol >= 0) - return ((fixedChgCol > 0) ? fixedChgCol : - (fixedChgCol == 0) ? (int)c + 1 : - (tmpc > (cols + colr + COL_WID_ADJ)) ? -fixedChgCol : - //(c > (cols + colr + COL_WID_ADJ) || (MyItemInfo.IsCaution || MyItemInfo.IsNote)) ? -fixedChgCol : - AERLeftChangeBarLocation(formatInfo)); - else - return (fixedChgCol + (((c < cols + Width + colr) || TableTest() - || MyItemInfo.IsCaution || MyItemInfo.IsNote) ? 0 : cols + colr)); // || (GetColumnMode() == 0)) ? 0 : cols + colr)); - /* Change bars to left of text -- ColS+WidS+ColR is the end of RNO col*/ - } - /* - ** Centered tables whose width exceeds the end of the RNO column should - ** still have their change bars printed on the left. This procedure checks - ** to make sure the step is a table and that it is not an RNO. - */ - private bool TableTest() - { - return false; - //return ((s->Type == TABLE || s->Type == BORDERLESSTABLE) && - //!(strchr((char *)&s->dbseq[2],RNO_MARKER))); - } - private float GetBottomYoff(float bottomY) - { - foreach (vlnParagraph child in ChildrenBelow) - { - if (child.YOffset > bottomY) bottomY = child.YOffset; - bottomY = child.GetBottomYoff(bottomY); - } - return bottomY; - } - private int AERLeftChangeBarLocation(FormatInfo formatInfo) - { - // use -5 default unless it is format specified - int fixedAERChgCol = formatInfo.PlantFormat.FormatData.ProcData.ChangeBarData.FixedAERChangeColumn ?? 0; - return (fixedAERChgCol != 0) ? - (fixedAERChgCol > 100) ? - (fixedAERChgCol % 100) : -fixedAERChgCol : -5; - } - private StringBuilder _RtfSB = null; - public string GetRtf(ItemInfo itemInfo, string prefix, string suffix) - { - int profileDepth = ProfileTimer.Push(">>>> GetRtf"); - _RtfSB = new StringBuilder(); - DisplayText vlntxt = new DisplayText(itemInfo, E_EditPrintMode.Print, E_ViewMode.View, true, E_FieldToEdit.StepText, false, prefix, suffix, MyPageHelper.MyPromsPrinter.RemoveTrailingHardReturnsAndSpaces != null); - - //C2025-021 Add logic to PROMS to support a special High Level Step type that is not printed. - if (itemInfo.IsType("InvisibleHigh")) - { - System.Drawing.Font myHighFont = vlntxt.TextFont.WindowsFont; - _RtfSB.Append(AddFontTable(myHighFont)); - _RtfSB.Append("}"); - string rtfHigh = _RtfSB.ToString(); - ProfileTimer.Pop(profileDepth); - return rtfHigh; - } - - // C2021-010: Remove trailing returns/spaces & manual page breaks & allow save. - if (DisplayText.RemoveTrailingBlankID > 0 && !MyPageHelper.MyPromsPrinter.RemoveTrailingHardReturnsAndSpaces.Contains(itemInfo.ItemID)) MyPageHelper.MyPromsPrinter.RemoveTrailingHardReturnsAndSpaces.Add(DisplayText.RemoveTrailingBlankID); - System.Drawing.Font myFont = vlntxt.TextFont.WindowsFont; - if (!itemInfo.IsTable && StepRTB.MyFontFamily != null) - // follow through in fixing an Out of Window Handles bug, use new function to see if - // we can retrieve the font from a dictionary instead a doing a New and using another - // window handle B2017-117 - //myFont = new System.Drawing.Font(StepRTB.MyFontFamily, myFont.Size, myFont.Style); - myFont = VE_Font.GetWinSysFont(StepRTB.MyFontFamily, myFont.Size, myFont.Style); - - string stText = null; // if Calvert (BGE) Alarms, the text is included in the macro, so save text as a blank: - if (HasCalvertMacro) - { - stText = " "; - // turn underline off - // follow through in fixing an Out of Window Handles bug, use new function to see if - // we can retrieve the font from a dictionary instead a doing a New and using another - // window handle B2017-117 - //myFont = new System.Drawing.Font(myFont.FontFamily, myFont.Size, System.Drawing.FontStyle.Regular); //myFont.Style. | FontStyle.Underline); - myFont = VE_Font.GetWinSysFont(myFont.FontFamily, myFont.Size, System.Drawing.FontStyle.Regular); //myFont.Style. | FontStyle.Underline); - } - else - stText = vlntxt.StartText; - - if (itemInfo.IsHigh && itemInfo.MyDocStyle.UndSpecialStepsFoldout) - { - // follow through in fixing an Out of Window Handles bug, use new function to see if - // we can retrieve the font from a dictionary instead a doing a New and using another - // window handle B2017-117 - //myFont = new System.Drawing.Font(myFont.FontFamily, myFont.Size, myFont.Style | System.Drawing.FontStyle.Underline); - myFont = VE_Font.GetWinSysFont(myFont.FontFamily, myFont.Size, myFont.Style | System.Drawing.FontStyle.Underline); - stText = stText.Replace(@"\ulnone ", ""); - stText = stText.Replace(@"\ulnone", ""); - } - if (stText.Contains("{IND}")) stText = stText.Replace("{IND}", "\x5"); - if (itemInfo.IsSection && itemInfo.ActiveFormat.PlantFormat.FormatData.SectData.SectionNumber.Level0Big && itemInfo.MyParent.IsProcedure) - // follow through in fixing an Out of Window Handles bug, use new function to see if - // we can retrieve the font from a dictionary instead a doing a New and using another - // window handle B2017-117 - //myFont = new System.Drawing.Font(myFont.FontFamily, 14, myFont.Style | System.Drawing.FontStyle.Bold); - myFont = VE_Font.GetWinSysFont(myFont.FontFamily, 14, myFont.Style | System.Drawing.FontStyle.Bold); - _RtfSB.Append(AddFontTable(myFont)); - _RtfSB.Append(stText); - if (_MyItemInfo.IsStep && !itemInfo.FormatStepData.UseSmartTemplate && _MyItemInfo.FormatStepData.Suffix != null && _MyItemInfo.FormatStepData.Suffix != "") - _RtfSB.Append(_MyItemInfo.FormatStepData.Suffix.Replace("{ulnone}", @"\ulnone ")); - _RtfSB.Append("}"); - string rtf = _RtfSB.ToString(); - UnderlineTerminateList utl = MyItemInfo.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.UnderlineTerminateList; - if (utl != null && myFont.Underline) - { - foreach (UnderlineTerminate ut in utl) - { - MatchCollection mc = Regex.Matches(rtf, "(? 0) - { - Match m = mc[mc.Count - 1]; - rtf = rtf.Substring(0, m.Index) + @"\ulnone " + rtf.Substring(m.Index); - } - } - } - ProfileTimer.Pop(profileDepth); - return rtf; - } - private float _XOffsetBox = 0; - public float XOffsetBox - { - get { return _XOffsetBox; } - set { _XOffsetBox = value; } - } - private float _MyBoxLeftAdj = 0; - private float SetHeader(vlnParagraph para, PdfContentByte cb, ItemInfo itemInfo, FormatInfo formatInfo) - { - float xoff = (float)itemInfo.MyDocStyle.Layout.LeftMargin; - // The '6' below is really converting from characters to Twips. But instead of considering the CPI, 16bit assumed - // it was 12 to center the header. That's where the 6 comes from. - float hdrWidth = (itemInfo.MyHeader.CleanText == null) ? 0 : itemInfo.MyHeader.CleanText.Length * 6; - int typ = ((int)itemInfo.MyContent.Type) % 10000; - int? bxIndx = formatInfo.PlantFormat.FormatData.StepDataList[typ].StepLayoutData.STBoxindex; - float adjmentAfterBoxedNoteCautionTab = 0; // F2024-078 used to save the adjustment of the space after the Note/Caution tab - - if (itemInfo.MyHeader.Justify == System.Drawing.ContentAlignment.MiddleCenter) - { - if (bxIndx != null) - { - Box bx = formatInfo.PlantFormat.FormatData.BoxList[(int)bxIndx]; - if (bx.TabPos > 0) - xoff += (float)bx.TabPos; // xoff starts as left margin - else - xoff += (float)((bx.TxtStart + _MyBoxLeftAdj + XOffsetBox + (bx.TxtWidth / 2)) - (hdrWidth / 2)); // xoff starts as left margin - adjmentAfterBoxedNoteCautionTab = (float) (bx.AdjSpAftTab ?? 0); // F2024-078 save the adjustment of the space (line) after the Note/Caution tab - } - else if (formatInfo.PlantFormat.FormatData.PrintData.SpecialCaseCalvertAlarm && itemInfo.IsInRNO && (itemInfo.IsCaution || itemInfo.IsNote)) // C2014-009 - xoff = XOffset + (para.Width / 2) - (hdrWidth / 2); - else if (formatInfo.MyStepSectionLayoutData.Separator.Location > 0) - xoff = XOffset + AdjustToCharPosition((float)((para.Width - hdrWidth) / formatInfo.MyStepSectionLayoutData.Separator.Location), itemInfo.MyHeader.MyFont.CPI); - else if (itemInfo.IsInRNO && itemInfo.ActiveFormat.PlantFormat.FormatData.StepDataList[40].NumberWithLevel) - xoff = XOffset + (para.Width / 2) - (hdrWidth / 2); - else if (itemInfo.ActiveFormat.PlantFormat.FormatData.StepDataList[40].NumberWithLevel) - xoff = XOffset + (para.Width / 2) - (hdrWidth / 2); - else - xoff = XOffset + (para.Width / 2) + (hdrWidth / 2); // XOffset has left margin included - } - else - xoff = XOffset; // XOffset has left margin included - // KEEP: This may be needed in the future to fix location of 'OR's when Separator location="0" - // the following code would place the 'OR' at the location of the tab rather than text. This - // is how 16bit was. However, a number of plants had been sent out with the xoffset at the xlocation - // of text (does not match 16bit) when this was found for BGE OI3/OI-1B/6.1.B.4. Previous releases - // went to CAT, MCG, FPL, NSP. - //{ - // if (this.MyTab != null) - // xoff = this.MyTab.XOffset; - // else - // xoff = XOffset; - //} - // B2018-096 AEP 082.002CD Note Box overlapping Step Box - vlnHeader myHeader = new vlnHeader(this, cb, itemInfo.MyHeader.Text, itemInfo.MyHeader.CleanText.TrimStart(" ".ToCharArray()), xoff + AdjustHeader + _MyBoxLeftAdj, YOffset, itemInfo.MyHeader.MyFont); - PartsAbove.Add(myHeader); - //return myHeader.Height + (!MyItemInfo.MyDocStyle.SpecialStepsFoldout || (MyItemInfo.MyDocStyle.ExtraLineHeader && (MyItemInfo.IsCaution || MyItemInfo.IsNote)) ? SixLinesPerInch : 0); - // Only use SpaceIn property for Cautions or Notes - bool bSpaceIn = (MyItemInfo.IsCaution || MyItemInfo.IsNote) ? MyItemInfo.FormatStepData.SpaceIn : true; - // F2022-121 added SpecialStepsFoldoutKeepWhiteSpace flag to allow for all of the other special foldout formatting, but - // not compress the page - this need to handle explicit OR and AND sub-steps to ensure there are blank lines before and after - // the separator text. - return myHeader.Height + (!MyItemInfo.MyDocStyle.SpecialStepsFoldout || (MyItemInfo.MyDocStyle.SpecialStepsFoldout && MyItemInfo.MyDocStyle.SpecialStepsFoldoutKeepWhiteSpace) || (MyItemInfo.MyDocStyle.ExtraLineHeader && (MyItemInfo.IsCaution || MyItemInfo.IsNote)) ? bSpaceIn ? SixLinesPerInch : 0 : 0) + adjmentAfterBoxedNoteCautionTab; // F2024-078 add adjustment to the space after the Note/Caution tab - } - private float AdjustToCharPosition(float position, float? CPI) - { - int iPosition = (int)position; - int charsToTwips = (int)(72 / (CPI ?? 12)); - iPosition = (iPosition / charsToTwips) * charsToTwips; - position = (position / 7.2F) * 7.2F; - return (float)iPosition; - } - private bool _SectionPageBreak = false; - public bool SectionPageBreak - { - get { return _SectionPageBreak; } - set { _SectionPageBreak = value; } - } - private bool _Processed = false; - public bool Processed - { - get { return _Processed; } - set { _Processed = value; } - } - private vlnParagraph _LastRNO; - public vlnParagraph LastRNO - { - get { return _LastRNO; } - set { _LastRNO = value; } - } - private vlnParagraph _MyTopRNO; - public vlnParagraph MyTopRNO - { - get { return _MyTopRNO; } - set { _MyTopRNO = value; } - } - private static string _PathPrefix = ""; - public static string PathPrefix - { - get { return vlnParagraph._PathPrefix; } - set { vlnParagraph._PathPrefix = value; } - } - protected float _YBottomMost; // Bottom of the paragraph including the children - public float YBottomMost - { - get { return _YBottomMost; } - set - { - _YBottomMost = value; - } - } - private float _YBottomPagination; // B2019-111 Keep table with Parent - protected float YBottomPagination - { - get { return _YBottomPagination; } - set { _YBottomPagination = value; } - } - protected float _YBottomMostAdjust = 0; // the RNO separator is outside asterisk box, account for additional Y space - public float YBottomMostAdjust - { - get { return _YBottomMostAdjust; } - set { _YBottomMostAdjust = value; } - } - protected float _YTopMost; // Top of the paragraph including the children - public float YTopMost - { - get { return _YTopMost; } - set { _YTopMost = value; } - } - protected float _YTop; // Top of the paragraph including parts - public float YTop - { - get { return _YTop; } - set - { - vlnParagraph vp = this as vlnParagraph; - _YTop = value; - - } - } - public float SmartTemplateAdjust - { - // If we're in a smart template (WCNCKL checklists) then account for the bottom line in the - // table. - get { return (MyItemInfo.IsHigh && MyItemInfo.FormatStepData.UseSmartTemplate) ? SixLinesPerInch : 0; } - } - public float YSize // How big this paragraph is with all of its children - { - get - { - float ysize = SmartTemplateAdjust + _YBottomMost - _YTopMost; - if (MyItemInfo.IsHigh && ((MyItemInfo.MyDocStyle.StructureStyle.Style & E_DocStructStyle.DoubleBoxHLS) == E_DocStructStyle.DoubleBoxHLS)) - ysize += SixLinesPerInch; - return ysize; - } - } - private ItemInfo _MyItemInfo; - public ItemInfo MyItemInfo - { - get { return _MyItemInfo; } - set { _MyItemInfo = value; } - } - private vlnParagraph _MyHighLevelParagraph; - - public vlnParagraph MyHighLevelParagraph - { - get - { - if (_MyHighLevelParagraph == null) - { - _MyHighLevelParagraph = GetHighLevelParagraph(); - } - return _MyHighLevelParagraph; - } - } - private vlnParagraph GetHighLevelParagraph() - { - if (MyItemInfo.IsHigh) return this; - return MyParent.GetHighLevelParagraph(); - } - private vlnParagraph _SupInfoSection; - public vlnParagraph SupInfoSection - { - get - { - if (_SupInfoSection == null) - { - _SupInfoSection = GetSupInfoSectionParagraph(); - } - return _SupInfoSection; - } - } - private vlnParagraph GetSupInfoSectionParagraph() - { - if (MyItemInfo.IsSection) return this._SupInfoSection; - return MyParent.GetSupInfoSectionParagraph(); - } - // Tab, Separator, ChangeBar, Box, Circle, Checkoff - private vlnTab _MyTab; - public vlnTab MyTab - { - get - { - if (_MyTab == null) - { - foreach (vlnPrintObject po in PartsLeft) - { - if (po is vlnTab) - { - _MyTab = po as vlnTab; - break; - } - } - } - return _MyTab; - } - } - private vlnPrintObjects _PartsAbove; - public vlnPrintObjects PartsAbove - { - get - { - if (_PartsAbove == null) _PartsAbove = new vlnPrintObjects(); - return _PartsAbove; - } - } - private vlnPrintObjects _PartsBelow; - public vlnPrintObjects PartsBelow - { - get - { - if (_PartsBelow == null) _PartsBelow = new vlnPrintObjects(); - return _PartsBelow; - } - } - private vlnPrintObjects _PartsRight; - public vlnPrintObjects PartsRight - { - get - { - if (_PartsRight == null) _PartsRight = new vlnPrintObjects(); - return _PartsRight; - } - } - private vlnPrintObjects _PartsLeft; - public vlnPrintObjects PartsLeft - { - get - { - if (_PartsLeft == null) _PartsLeft = new vlnPrintObjects(); - return _PartsLeft; - } - } - private vlnPrintObjects _PartsContainer; - public vlnPrintObjects PartsContainer - { - get - { - if (_PartsContainer == null) _PartsContainer = new vlnPrintObjects(); - return _PartsContainer; - } - } - private vlnParagraphs _ChildrenAbove; - public vlnParagraphs ChildrenAbove - { - get - { - if (_ChildrenAbove == null) _ChildrenAbove = new vlnParagraphs(this); - return _ChildrenAbove; - } - } - private vlnParagraphs _ChildrenBelow; - public vlnParagraphs ChildrenBelow - { - get - { - if (_ChildrenBelow == null) _ChildrenBelow = new vlnParagraphs(this); - return _ChildrenBelow; - } - } - private vlnParagraphs _ChildrenRight; - public vlnParagraphs ChildrenRight - { - get - { - if (_ChildrenRight == null) _ChildrenRight = new vlnParagraphs(this); - return _ChildrenRight; - } - } - private vlnParagraphs _ChildrenLeft; - public vlnParagraphs ChildrenLeft - { - get - { - if (_ChildrenLeft == null) _ChildrenLeft = new vlnParagraphs(this); - return _ChildrenLeft; - } - } - private float? _XOffsetCenter = null; - - public float? XOffsetCenter - { - get { return _XOffsetCenter; } - set { _XOffsetCenter = value; } - } - - public bool IsEnhancedBackgroundFormat(ItemInfo itminfo) - { - return ((itminfo.ActiveFormat.PlantFormat.FormatData.PurchaseOptions.Value & E_PurchaseOptions.EnhancedBackgrounds) == E_PurchaseOptions.EnhancedBackgrounds); - } - - public void AdjustXOffsetForTab(ItemInfo itemInfo, int maxRNO, FormatInfo formatInfo, vlnTab myTab, float xMetaAdj) - { - if (itemInfo.IsSupInfoPart) - { - // The SupInfoTabOff was added to the base format during initial development to shift the tab over by 3/4 inch (54) to allow for enough space for Note/Caution tab - int sitabloc = itemInfo.ActiveFormat.PlantFormat.FormatData.PrintData.SupInfoTabOff == null ? 0 : (int)itemInfo.ActiveFormat.PlantFormat.FormatData.PrintData.SupInfoTabOff; - // B2023-069 allow for the adjustment of the Supplemental Information tab at the section level (SecOvrideSupInfoTabOff). - // this will also override the SupInoTabOff setting which is for the entire format - int secOvrSupInfoTab = itemInfo.MyDocStyle.SecOvrideSupInfoTabOff == null ? 0 : (int)itemInfo.MyDocStyle.SecOvrideSupInfoTabOff; - if (secOvrSupInfoTab != 0) sitabloc = secOvrSupInfoTab; - XOffset = (float)itemInfo.MyDocStyle.Layout.LeftMargin + sitabloc; - if (myTab != null) - { - myTab.XOffset = XOffset - ((myTab == null) ? 0 : myTab.Width) - 12; - // B2017-253 - Limit the tab offset to 2 points inside the left margin - myTab.XOffset = Math.Max(myTab.XOffset,itemInfo.MyDocStyle.Layout.LeftMargin ?? 72)+2; - float mytbwidth = myTab.Width; - myTab.Width = 2.5f * myTab.Width; - // C2018-022: adjust xoffset of text by 12 if the tab would overwrite the text and the format flag is on: - if (itemInfo.ActiveFormat.PlantFormat.FormatData.PrintData.SupInfoAdjustXOffForLongTab && ((myTab.XOffset + mytbwidth + 12) > XOffset)) - XOffset = 12F + myTab.XOffset + mytbwidth; - } - // B2017-102: need to set width here since using Xoffset because AdjustWidth is called before this adjustment. - Width = (float)itemInfo.MyDocStyle.Layout.PageWidth - XOffset - (sitabloc / 2); - return; - } - // F2019-069: Hold Point designator for Barakah, use parent's tab for xoffset - if (itemInfo.IsStep && itemInfo.FormatStepData.ColUseParentTab && (myTab == null || myTab.Text == "")) - { - if (MyParent != null) - { - XOffset = (MyParent.MyTab == null || MyParent.MyTab.Text == null || MyParent.MyTab.Text.Trim() == "") ? MyParent.XOffset : MyParent.MyTab.XOffset; - return; - } - } - float tabWidth = (myTab == null) ? 0 : myTab.Width; - if (itemInfo.IsStepSection) - { - if (formatInfo.PlantFormat.FormatData.SectData.SectionHeader.Just == "PSLeft") - { - int level = 0; - ItemInfo iilvl = itemInfo; - while (!iilvl.IsProcedure) - { - level++; - iilvl = iilvl.MyParent; - } - if (formatInfo.PlantFormat.FormatData.PrintData.SpecialCaseCalvert) - { - XOffset = (myTab == null ? 0 : myTab.XOffset) + ((float)formatInfo.PlantFormat.FormatData.SectData.SectionHeader.Pos - (float)formatInfo.PlantFormat.FormatData.SectData.SectionNumber.Pos); - } - else - { - level = level <= 2 ? 1 : level - 1; - if (level == 1) - { - // Use the section number position for the section title when the section number is blank - if (formatInfo.PlantFormat.FormatData.SectData.SectionHeader.UseNumPosWhenNumBlank && MyTab != null && MyTab.Text.Trim().Length == 0) - { - XOffset = (float)itemInfo.MyDocStyle.Layout.LeftMargin + ((float)formatInfo.PlantFormat.FormatData.SectData.SectionNumber.Pos); - } - else - XOffset = (float)itemInfo.MyDocStyle.Layout.LeftMargin + (level * (float)formatInfo.PlantFormat.FormatData.SectData.SectionHeader.Pos); - } - else if (formatInfo.PlantFormat.FormatData.PrintData.SpecialCaseCalvert) - XOffset = (myTab == null ? 0 : myTab.XOffset) + ((float)formatInfo.PlantFormat.FormatData.SectData.SectionHeader.Pos - (float)formatInfo.PlantFormat.FormatData.SectData.SectionNumber.Pos); - else - { - XOffset = (float)itemInfo.MyDocStyle.Layout.LeftMargin + (float)formatInfo.PlantFormat.FormatData.SectData.MetaSectionList[level].ColSByLevel; - XOffset += (float)formatInfo.PlantFormat.FormatData.SectData.MetaSectionList[level].SecTitlePositionAdj; - XOffset -= xMetaAdj; - } - - if (itemInfo.MyDocStyle.SectTitleOffsetOverride != null) + MyPageHelper.MySection = MyItemInfo as SectionInfo; + MyPageHelper.ResetSvg(); + } + } + } + // For Calvert Alarms: A macro exists around the CONDITION/RESPONSE portion. If the page break occurs so that + // this 'table' moved to the following page AND there is an associated note/caution that is not on the next page, + // remove the macro so that the header macro doesn't print on the page with the note (without this, an extraneous + // header for the 'table'is printed. + if (PartsLeft.Count != 0 && (PartsLeft[0] is vlnMacro) && MyPageHelper.ParaBreaks.Count != 0 && MyPageHelper.ParaBreaks[0].MyItemInfo.MyPrevious == null) + if (!MyPageHelper.ParaBreaks[0].MyItemInfo.IsNote && !MyPageHelper.ParaBreaks[0].MyItemInfo.IsCaution) + { + // Only clear the header if it is the first child below + if (ChildrenBelow[0].MyItemInfo.ItemID == MyPageHelper.ParaBreaks[0].MyItemInfo.ItemID) + PartsLeft.Clear(); + //else + // _MyLog.WarnFormat("Would Have Cleared PageHeader '{0}','{1}'", MyItemInfo.MyProcedure.DisplayNumber, MyItemInfo.MyHLS.DisplayText); + } + if (IsWordDocPara) + { + SectionInfo si = SectionInfo.Get(MyItemInfo.ItemID); + //Changing this caused Header issues for FNP FNP-1-FRP-1.3 Attachment 3 (Word Sub-Sections) + //SectionInfo si1 = MyItemInfo.GetSectionInfo(); + //CompareSectionInfo(si, si1); + MyPromsPrinter.NewPage(true); + //_MyLog.InfoFormat("NewPage 9 {0}", cb.PdfWriter.CurrentPageNumber); + // Add Bookmark for Word Subsections + MyPageHelper.PageBookmarks.Add(si, $"{((si.DisplayNumber ?? "") == "" ? "" : $"{si.DisplayNumber} - ")}{si.DisplayText}", null); + MyPageHelper.MyPromsPrinter.CreateWordDocPdf(cb, si); + Processed = true; + { + ProfileTimer.Pop(profileDepth); + return yPageStart; + } + } + float yLocalypagestart = yPageStart; + // yPageStart is offset into roll; YTopMost is offset of topmost of this paragraph. + float yLocation = yPageStart - YTopMost; + + // If this document style has a pagelist item with a continue (some IP2BCK docstyles), clear + // out the variable that flags a continue message + MyPageHelper.OldTemplateContMsg = false; + + if (DebugText.IsOpen) DebugText.WriteLine("ToPdf1:{0},'{1}',{2},{3},{4},{5}", MyItemInfo.ItemID, MyItemInfo.ShortPath, XOffset, yLocation, yPageStart, YTopMost); + int profileDepth1 = ProfileTimer.Push(">>>> vlnParagraph.Paginate"); + int paginate = Paginate(yLocation, yTopMargin, yBottomMargin); + ProfileTimer.Pop(profileDepth1); + bool firstHighLevelStep = MyItemInfo.IsHigh && (MyItemInfo.MyPrevious == null); + bool doSectionTitleContinued = false; // will add " Continued" to the section title if format flag is set + // If SAMG facing page print & doing first pass to generate page break list of supplemental info and + // there was a page break in the step section, but not an associated supinfo item, do the page break when the + // next supinfo item is found: + SectionInfo supInfoSect = MyItemInfo.ActiveSection as SectionInfo; // C2018-003 fixed use of getting the active section + if (MyPromsPrinter.SupInfoPrintType == E_SupInfoPrintType.DoPageBreaks && MyPromsPrinter.NeedSupInfoBreak && MyItemInfo.SupInfos != null && MyItemInfo.SupInfos.Count > 0) + { + // if this has a caution/note with supinfo, that is id that needs to go in pagination list, unless it is in there. + int aboveSupinfoId = ChildrenAboveHaveSupInfo(); + if (supInfoSect != null) + { + if (supInfoSect.StepSectPageBreaksForSupInfo.Contains(aboveSupinfoId)) aboveSupinfoId = -1; + supInfoSect.StepSectPageBreaksForSupInfo.Add(aboveSupinfoId != -1 ? aboveSupinfoId : MyItemInfo.SupInfos[0].ItemID); + } + MyPromsPrinter.NeedSupInfoBreak = false; + } + + DocStyle docstyle; + bool itemIsPrinted; + switch (paginate) + { + // .oooooo. .oooo. + // d8P' `Y8b d8P'`Y8b + // 888 .oooo. .oooo.o .ooooo. 888 888 + // 888 `P )88b d88( "8 d88' `88b 888 888 + // 888 .oP"888 `"Y88b. 888ooo888 888 888 + // `88b ooo d8( 888 o. )88b 888 .o `88b d88' + // `Y8bood8P' `Y888""8o 8""888P' `Y8bod8P' `Y8bd8P' + case 0: // No page break + if (MyItemInfo.IsSection) + { + SectionInfo si = MyItemInfo as SectionInfo; + MyPageHelper.PageBookmarks.Add(MyItemInfo, $"{((si.DisplayNumber ?? "") == "" ? "" : $"{si.DisplayNumber} - ")}{si.DisplayText}", null); + DoCheckOffHeader(cb, MyItemInfo, yLocation, yTopMargin, yPageStart); + } + // SupInfo has its own pagination and ylocation handling, reset ypagestart & ylocation if continuing on current page. + // The value used was saved when the previous SupInfo step was printed. + if (MyItemInfo.IsSupInfoPart) + { + yPageStart = _yPageStartForSupInfo - SixLinesPerInch; + yLocation = yPageStart - YTopMost; + } + if (MyPromsPrinter.SupInfoPrintType == E_SupInfoPrintType.Merge) + { + // printing a procedure with section(s) that have supplemental information - determine facing page needed to be merged in. For + // case 0, it is typically at the beginning of the section since the page break occurred in the code that calls this. + // Note that if the procedure has any sections with supinfo, then the entire procedure will need facing pages, either blank page + // or supinfo steps. + // If the section title is printed, then need to get the facing page before the section title is printed and if + // this is the hls where the section title was printed, don't do the facing page. + bool titlePrinted = false; + if (MyItemInfo.IsSection || (MyItemInfo.IsHigh && MyItemInfo.MyPrevious == null)) { - XOffset += (float)itemInfo.MyDocStyle.SectTitleOffsetOverride; - } + // see if the section title is printed. + titlePrinted = (!(MyItemInfo.ActiveSection.MyConfig is SectionConfig sch) || sch.Section_PrintHdr == "Y") || !(MyItemInfo.MyActiveSection as SectionInfo).HasSupInfoSteps; + titlePrinted &= (ShowSectionTitles && !MyItemInfo.MyDocStyle.CancelSectTitle); + } + bool firstSec = true; + foreach (SectionInfo sec in MyItemInfo.MyProcedure.Sections.OfType()) + { + if (sec.IsStepSection) + { + if (MyItemInfo.ActiveSection != null && sec.ItemID == MyItemInfo.ActiveSection.ItemID) break; // C2018-003 fixed use of getting the active section + firstSec = false; + break; + } + } + // If this is first step section and there is no supinfo, the blank page was done in proms printer. + // If this is first step section and there is supinfo, it needs to be put out + bool notFirstOrFirstHasSupInfo = !firstSec || (MyItemInfo.ActiveSection != null && (MyItemInfo.ActiveSection as SectionInfo).HasSupInfoSteps); // C2018-003 fixed use of getting the active section + if (notFirstOrFirstHasSupInfo && ((MyItemInfo.IsHigh && MyItemInfo.MyPrevious == null && !titlePrinted) || (MyItemInfo.IsStepSection && titlePrinted)) && !MyItemInfo.IsInSupInfo && (MyItemInfo.MyProcedure as ProcedureInfo).ProcHasSupInfoData) + { + // If there is supplemental information to be printed on the facing page, then get the id that has supinfo + // so that it can be retrieved from the pdf for the supinfos for this section. + int sid = GetIdThatHasSupInfoItems(MyItemInfo, MyItemInfo.ItemID); + if (sid != -1) + { + MyPromsPrinter.DoSupInfoPage(cb, MyPageHelper.TextLayer, MyPageHelper, sid); + } + else + { + MyPromsPrinter.InsertBlankPage(cb); + } + } + } + if (MyItemInfo.IsHigh && MyItemInfo.MyPrevious != null && ((MyItemInfo.MyDocStyle.StructureStyle.Style & E_DocStructStyle.DoubleBoxHLS) == E_DocStructStyle.DoubleBoxHLS)) + yPageStart -= SixLinesPerInch; + if (MyPageHelper.ParaBreaks.Count > 0 && MyPageHelper.ParaBreaks[0].CompressFirstPartOfStep) + MyPageHelper.YMultiplier = _SevenLinesPerInch / SixLinesPerInch; + if (CompressFoldout) + MyPageHelper.YMultiplier = _SevenLinesPerInch / SixLinesPerInch; - } - } - else if (formatInfo.PlantFormat.FormatData.SectData.SectionHeader.Just == "PSCenter") - { - float hdrWidth = itemInfo.MyContent.Text.Length * 6; - float ctr = (((float)itemInfo.MyDocStyle.Layout.PageWidth - (float)itemInfo.MyDocStyle.Layout.LeftMargin)) / 2; - XOffsetCenter = (float)itemInfo.MyDocStyle.Layout.LeftMargin + ctr - (hdrWidth / 2); - } - return; - } - // B2021-091 added a null reference check - itemInfo was a section and didn't have FormatStepData so just return - if (itemInfo.FormatStepData == null) return; + ///else + /// MyPageHelper.YMultiplier = 1; + break; + // .oooooo. .o + // d8P' `Y8b o888 + //888 .oooo. .oooo.o .ooooo. 888 + //888 `P )88b d88( "8 d88' `88b 888 + //888 .oP"888 `"Y88b. 888ooo888 888 + //`88b ooo d8( 888 o. )88b 888 .o 888 + // `Y8bood8P' `Y888""8o 8""888P' `Y8bod8P' o888o + case 1: // Break on High Level Step + if (MyPromsPrinter.SupInfoPrintType == E_SupInfoPrintType.DoPageBreaks) + { + // page break here, determine if there is caution/note above where the page break actually needs to go: + int aboveSupinfoId = ChildrenAboveHaveSupInfo(); + if (supInfoSect != null && MyItemInfo.SupInfos != null && MyItemInfo.SupInfos.Count > 0 && aboveSupinfoId > 0) supInfoSect.StepSectPageBreaksForSupInfo.Add(aboveSupinfoId); + else if (supInfoSect != null && MyItemInfo.SupInfos != null && MyItemInfo.SupInfos.Count > 0) supInfoSect.StepSectPageBreaksForSupInfo.Add(MyItemInfo.SupInfos[0].ItemID); + else MyPromsPrinter.NeedSupInfoBreak = true; + supInfoSect?.StepSectPageBreaks.Add(MyItemInfo.ItemID); + } + YTopMost = OutputOtherPageSteps(cb, YTopMost, yPageStart, yTopMargin, yBottomMargin); + docstyle = MyItemInfo.MyDocStyle; + if (MyPageHelper.NotesToFootNotes != null && MyPageHelper.NotesToFootNotes.Count > 0) MyPageHelper.NotesToFootNotesYoffset = CalculateYLocation(yLocation, yTopMargin); + bool doSectionContinue = !MyItemInfo.IsSection && ((docstyle.StructureStyle.Style & E_DocStructStyle.BottomSectionContinue) == E_DocStructStyle.BottomSectionContinue); + if (doSectionContinue) DoBottomContinueMsg(cb, yBottomMargin, yLocation, docstyle, false); + MyPromsPrinter.NewPage(); + //_MyLog.InfoFormat("NewPage 10 {0}", cb.PdfWriter.CurrentPageNumber); + if (MyItemInfo.IsSection && MyParent != null && MyParent.MyItemInfo.IsSection && (MyItemInfo as SectionInfo).IsSeparatePagination()) + { + // F2023-015 for Beaver Valley as two sub-sections that are printed continuously followed by a third sub-section printed + // with separate pagination. This section type uses a different pagelist for the pages after the first page. + // Needed to call ResetDocStyleAndValues to set the new page with the other pagelist sytle. + ResetDocStyleAndValues(ref yTopMargin, ref yBottomMargin); + RefreshDocStyle(); + yTopMargin = PDFPageSize.PaperSizePoints(MyItemInfo.ActiveFormat.PlantFormat.FormatData.PDFPageSize.PaperSize) - (float)MyItemInfo.ActiveSection.MyDocStyle.Layout.TopMargin; // C2018-003 fixed use of getting the active section // C2020-002 paper size is now set in the format files + yBottomMargin = Math.Max(0, yTopMargin - (float)MyItemInfo.ActiveSection.MyDocStyle.Layout.PageLength); // C2018-003 fixed use of getting the active section + yPageStart = yTopMargin; + } + else if (MyItemInfo.IsSection || (MyItemInfo.IsHigh && MyItemInfo.MyPrevious != null)) //do not reset for 1st step + { + //Console.WriteLine("'b1',{0},'{1}',{2},{3},{4},{5},{6}", MyItemInfo.ItemID, MyItemInfo.ShortPath, yTopMargin, yPageStart, yLocation, YTopMost, YOffset); + ResetDocStyleAndValues(ref yTopMargin, ref yBottomMargin); + //Console.WriteLine("'a1',{0},'{1}',{2},{3},{4},{5},{6}", MyItemInfo.ItemID, MyItemInfo.ShortPath, yTopMargin, yPageStart, yLocation, YTopMost, YOffset); + } + DebugText.WriteLine("Paginate1"); + if (MyItemInfo.IsSection) + { + SectionInfo si = MyItemInfo as SectionInfo; + MyPageHelper.PageBookmarks.Add(MyItemInfo, $"{((si.DisplayNumber ?? "") == "" ? "" : $"{si.DisplayNumber} - ")}{si.DisplayText}", null); - int? bxIndx = itemInfo.FormatStepData.StepLayoutData.STBoxindex; - float? colOvrd = itemInfo.FormatStepData.ColOverride; - if (itemInfo.IsBackgroundStep())//WolfCreekBackgroundFormat && IsHigh||IsNote||IsCaution or ImplicitOR - { - int adj = 2; - if (myTab != null) - { - //B2018-139 use XOffset when processing HLS, Caution, or Note background text and tab - if (itemInfo.IsHigh || (itemInfo.IsNote && (itemInfo.MyParent.IsHigh || itemInfo.MyParent.IsCaution || itemInfo.MyParent.IsNote)) || (itemInfo.IsCaution && (itemInfo.MyParent.IsHigh || itemInfo.MyParent.IsCaution || itemInfo.MyParent.IsNote))) - myTab.XOffset = XOffset; - else - { - // F2018-041 seq tabs off of TitleWithTextBelow were running into the step text - myTab.XOffset = XOffset + (itemInfo.FormatStepData.Font.CharsToTwips * adj); // F2018-041 move tab over 2 chars so it positions like paragraphs under TitleWithTextBelow - adj += myTab.Text.Length; // F2018-041 add the length of the tab to the adjustment of the XOffset - } - } - XOffset += (itemInfo.FormatStepData.Font.CharsToTwips * adj); // indent 2 characters for background steps - // B2018-146 Adjust the width to match the HLS Right Margin. - //if (itemInfo.ActiveFormat.Name.StartsWith("WCN")) -- Not needed since IsBackgroundStep - Width = this.MyHighLevelParagraph.Width + this.MyHighLevelParagraph.XOffset - this.XOffset; - //else - // Width -= (itemInfo.FormatStepData.Font.CharsToTwips * adj); // Adjust width by 2 characters - return; - } - else if (itemInfo.FormatStepData.UseOldTemplate && itemInfo.IsInTemplate() && - (MyItemInfo.ActiveSection != null && (MyItemInfo.ActiveSection.MyDocStyle.StructureStyle.Style & E_DocStructStyle.DSS_PageListSpBckgrnd) == E_DocStructStyle.DSS_PageListSpBckgrnd)) // C2018-003 fixed use of getting the active section - { - if (myTab != null) myTab.XOffset = XOffset; - XOffset += myTab.Width; - return; - } - else if (itemInfo.FormatStepData != null && itemInfo.FormatStepData.Type == "TitleWithTextBelow") - { - if ((colOvrd ?? 0) != 0) - XOffset = (float)colOvrd; - else - XOffset = (float)itemInfo.MyDocStyle.Layout.LeftMargin; - // B2018-146 Adjust the width to match the HLS Right Margin. - if(itemInfo.IsPartOfBackgroundStep()) - //if(itemInfo.ActiveFormat.Name.StartsWith("WCN")) - Width = this.MyHighLevelParagraph.Width + this.MyHighLevelParagraph.XOffset - this.XOffset; - return; - } - else if (itemInfo.IsParagraph && - (((itemInfo.ActiveFormat.PlantFormat.FormatData.PurchaseOptions.Value & E_PurchaseOptions.EnhancedBackgrounds) == E_PurchaseOptions.EnhancedBackgrounds) || - ((itemInfo.ActiveFormat.PlantFormat.FormatData.PurchaseOptions.Value & E_PurchaseOptions.EnhancedDeviations) == E_PurchaseOptions.EnhancedDeviations)) && - itemInfo.FormatStepData != null && PreviousIsTitleWithTextBelow(itemInfo)) - { - // This code was needed for fix for B2015-183 && - // IP2 backgrounds so that any 'paragraph's that were at the same - // level as the 'TitleWithTextBelow's would have same left margin (xoffset) as the 'TitleWithTextBelow'. - // an example of this can be found in IP2 Backgrounds, 2-E-0, Step Description Table, Step 22, PLANT-SPECIFIC INFORMATION. - // (NOTE that the IP2 exaxmple was no longer in the data when the work on B2015-183 was done) - if ((colOvrd ?? 0) != 0) - XOffset = (float)colOvrd; - else - { - //Adjuust Indent for Wolf Creek Background format flag - float indentBG1 = itemInfo.IsPartOfBackgroundStep() ? itemInfo.FormatStepData.Font.CharsToTwips * 2 : 0; - XOffset = (float)itemInfo.MyDocStyle.Layout.LeftMargin + indentBG1; - // B2018-146 Adjust the width to match the HLS Right Margin. - if (itemInfo.IsPartOfBackgroundStep()) - //if (itemInfo.ActiveFormat.Name.StartsWith("WCN")) - Width = this.MyHighLevelParagraph.XOffset + this.MyHighLevelParagraph.Width - XOffset; - else - Width = (float)itemInfo.MyDocStyle.Layout.PageWidth - (float)itemInfo.MyDocStyle.Layout.LeftMargin - indentBG1; - } - return; - } - else if (itemInfo.MyParent.FormatStepData != null && itemInfo.MyParent.FormatStepData.Type == "TitleWithTextBelow" && (!itemInfo.ActiveFormat.PlantFormat.FormatData.PrintData.SpecialCaseCalvertAlarm || (!itemInfo.IsCaution && !itemInfo.IsNote))) - { - float childindent = itemInfo.MyParent.FormatStepData.ChildIndent ?? 0; - if (myTab != null) - { - float delta = childindent + MyParent.XOffset - myTab.XOffset; - myTab.XOffset += delta; - XOffset += delta; - // B2018-036: set the width of (background/deviation/alarms/etc) steps that have a tab - if (!itemInfo.ActiveFormat.PlantFormat.FormatData.PrintData.SpecialCaseCalvertAlarm || !UseTemplateWidthOrXOff(itemInfo.MyParent)) - { - // B2018-146 Adjust the width to match the HLS Right Margin. - // F2023-112 added format flag for Vogtle Units 3 & 4 backgrounds. This allows use of override width on AND and List sub-step types - if (itemInfo.IsBackgroundStepOrChild() || itemInfo.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.Vogtle3and4BackgroundFormat) - Width = this.MyHighLevelParagraph.Width + this.MyHighLevelParagraph.XOffset - this.XOffset; - else - Width = (float)itemInfo.MyDocStyle.Layout.PageWidth - (float)itemInfo.MyDocStyle.Layout.LeftMargin - delta; - } - } - else - { - //Adjust Indent for Wolf Creek Background format flag - float indentBG2 = itemInfo.IsPartOfBackgroundStep() ? itemInfo.FormatStepData.Font.CharsToTwips * 2 : 0; - XOffset = childindent + MyParent.XOffset + indentBG2;//(itemInfo.FormatStepData.Font.CharsToTwips * 2); - // B2016-164: Added the following 'if' so that the width is not recalculated if in the alarm format & the parent has a template - // B2016-168: The fix for 164 broke deviation document printing. The if statement was fixed for both: - // B2019-057 Added a check to see if there is a width override for this step element (Robinson AOP Backgrounds - paragraphs) - float wdthovrd = (itemInfo.FormatStepData.WidthOverride == null) ? 0 : (float)ToInt(itemInfo.FormatStepData.WidthOverride, maxRNO); - if ((!itemInfo.ActiveFormat.PlantFormat.FormatData.PrintData.SpecialCaseCalvertAlarm || !UseTemplateWidthOrXOff(itemInfo.MyParent)) && wdthovrd == 0) - Width = (float)itemInfo.MyDocStyle.Layout.PageWidth - (float)itemInfo.MyDocStyle.Layout.LeftMargin - indentBG2; - } - return; - } - else if (itemInfo.FormatStepData != null && itemInfo.FormatStepData.Type == "TitleWithTextRight") - { - if ((colOvrd ?? 0) != 0) - XOffset = (float)colOvrd; - else - XOffset = (float)itemInfo.MyDocStyle.Layout.LeftMargin; - return; - } - else if (itemInfo.MyParent.FormatStepData != null && itemInfo.MyParent.FormatStepData.Type == "TitleWithTextRight") - { - XOffset = MyParent.MyParent.XOffset; - // if the step text has a tab, then we need to position the tab to the XOffset and then ajust the text XOffset - // by the length of the tab. - fix for IP2 backgrounds (ex. 2-ECA-3.3, step 6) - if (myTab != null) - { - myTab.XOffset = XOffset; - XOffset += (myTab.Text.Length * myTab.MyFont.CharsToTwips);//myTab.Width - myTab.XOffset; - } - return; - } - if (itemInfo.IsHigh) - { - if (formatInfo.PlantFormat.FormatData.PrintData.SpecialCaseCalvertAlarm || - ((itemInfo.MyDocStyle.StructureStyle.Style & E_DocStructStyle.DSS_SameXOffSubsections) == E_DocStructStyle.DSS_SameXOffSubsections)) - { - // the HLS in the template prints the tab/step on the right edge of page. Don't - // do the other calculations to relocate it. - if (itemInfo.FormatStepData.UseOldTemplate && itemInfo.IsInTemplate()) - { - MyTab.XOffset = XOffset - MyTab.Width; - return; - } - // the following code handles the xoffsets of tabs/HLS in the non-alarm sections for - // the Calvert Alarm format. - if (itemInfo.MyDocStyle.UseColSByLevel) - { - if (myTab != null) - { - myTab.Rtf = myTab.Rtf.Replace(myTab.Text, myTab.Text.TrimStart(" ".ToCharArray())); - // B2022-129: don't indent HLS when flag is on (Barakah - single column step attachment with meta sect) - if (itemInfo.MyDocStyle.AdjSectTitleLoc) - { - myTab.XOffset = MyParent.MyTab.XOffset; - XOffset = MyParent.XOffset; - } - else - { - myTab.XOffset = MyParent.XOffset; - XOffset = myTab.XOffset + MyTab.Width; - } - } - else - XOffset = MyParent.XOffset; // unnumbered hls - return; - } - } - float x = 0; - float xoff = 0; - if ((colOvrd ?? 0) != 0) - x = (float)itemInfo.MyDocStyle.Layout.LeftMargin + (float)colOvrd; - else - x = (float)itemInfo.MyDocStyle.Layout.LeftMargin + (float)formatInfo.PlantFormat.FormatData.SectData.StepSectionData.StepSectionLayoutData.ColS; + } + // Only do foldout page if not done for section break, i.e. check the there's a previous step. + if (MyItemInfo.MyPrevious != null && MyItemInfo.FoldoutIndex() > -1) + MyPromsPrinter.DoFoldoutPage(cb, "HLS", MyPageHelper.TextLayer, MyPageHelper, MyItemInfo.FoldoutIndex(), false); + // B2018-108 if paginating on first step don't add blank page (it was already added at this point) + // B2023-011: Beaver Valley - continuous section printing on its own page throws off CAS/blank pages + // added the IsSection check to the else if + else if (PromsPrinter.MyFoldoutReader.Count > 0 && MyPageHelper.MyPromsPrinter.InsertBlankPages && (MyItemInfo.IsSection || (MyItemInfo.IsHigh && MyItemInfo.MyPrevious != null))) + { + // insert a blank page if this step section had a foldout associated and the checkbox + // on the print dialog, to add blank pages, is checked AND the page did NOT have a + // preceeding foldout. + if (MyItemInfo.FoldoutIndex() <= -1) + { + MyPromsPrinter.InsertBlankPage(cb); + //_MyLog.InfoFormat("NewPage 10 blank {0}", cb.PdfWriter.CurrentPageNumber); + } + } + // See comments under case 0 explaining supinfo/facing page processing. + itemIsPrinted = IsPrintedStepItemForSupInfo(); + if (MyPromsPrinter.SupInfoPrintType == E_SupInfoPrintType.Merge && !MyPageHelper.CreatingSupInfoPage && itemIsPrinted /*&& !MyItemInfo.IsSection*/ && !MyItemInfo.IsInSupInfo && (MyItemInfo.MyProcedure as ProcedureInfo).ProcHasSupInfoData) + { + int sid = GetIdThatHasSupInfoItems(MyItemInfo, MyItemInfo.ItemID); + if (sid != -1) + { + MyPromsPrinter.DoSupInfoPage(cb, MyPageHelper.TextLayer, MyPageHelper, sid); + } + else + { + MyPromsPrinter.InsertBlankPage(cb); // C2019-004: Allow user to define duplex blank page text + } + } + if (MyItemInfo.MyDocStyle.LandscapePageList) + { + System.Drawing.Drawing2D.Matrix myMatrix = new System.Drawing.Drawing2D.Matrix(0, 1, -1, 0, cb.PdfDocument.PageSize.Height, 0); + cb.Transform(myMatrix); + } + yPageStart = yTopMargin + YTopMost; + // B2020-001 Catawba had an extra line at the top of a page that paginated on a section (EP/1/A/5000/E0 section B) + // Needed to remove the extra line spacing that is before the start of section B - (section is set for continuous pagination) + if (MyItemInfo.IsSection && MyItemInfo.ActiveFormat.MyStepSectionLayoutData.CustomSpacing) + yPageStart += (float)MyItemInfo.ActiveFormat.PlantFormat.FormatData.StepDataList[25].StepLayoutData.STExtraSpace; + DoCheckOffHeader(cb, MyItemInfo, yLocation, yTopMargin, yPageStart); + SectionTopMessage(cb, yTopMargin); // does wcntraining & suppinfo section title + if (MyPageHelper.CreatingSupInfoPage) yPageStart -= (2 * SixLinesPerInch); + if (doSectionContinue) DoTopContinueMsg(cb, ref yPageStart, yTopMargin, docstyle, null); + // If "ContinueSectionHeader" (format flag) is true then print the section title with "(Continued)" appended to it + // B2020-164 added check for SpecialCaseCalvert to bypass IsSeparateSubsection STP O-67B-2 step 6.5 + // B2025-060 no section continue message if previous was not in same section or sub-section + // fixes Vogtle units 3&4 3-AOP-116 Attachments 2 & 3 + if ((!MyItemInfo.IsSection || MyItemInfo.IsSubsection) && + (MyItemInfo.MyPrevious != null && MyItemInfo.ActiveSection == MyItemInfo.MyPrevious.ActiveSection) && + MyItemInfo.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.ContinueSectionHeader && + (!MyItemInfo.IsSection || (MyItemInfo.IsSeparateSubsection || MyItemInfo.ActiveFormat.PlantFormat.FormatData.PrintData.SpecialCaseCalvert))) + { + // B2020-162 - SpecialCaseCalvert flag affect single column procedures, use SpecialCaseCalvertPagination for Two Column procedures instead + // B2020-163 - above bug (162) section header breaking from HLS caused forced pagination. turned out we didn't need to change this for B2020-162. + SectionConfig sch = MyItemInfo.ActiveSection.MyConfig as SectionConfig; + doSectionTitleContinued = (sch == null || sch.Section_PrintHdr == "Y") && !MyItemInfo.MyDocStyle.CancelSectTitle; + //B2020-123 - Calvert - set CalvertPrintedSubSectTitle flag to fix section continue bug + //B2020-166 - Calvert - only set CalvertPrintedSubSectTitle flag if doSectionTitleContinued is set + if (doSectionTitleContinued && MyItemInfo.ActiveFormat.PlantFormat.FormatData.PrintData.SpecialCaseCalvert) CalvertPrintedSubSectTitle = true; // B2020-123 + } - xoff = x - XOffset; - // ColSByLevel will specify the column in which the High Level Step starts with - // respect to the overall level calculation based on sections & meta-sections. - // Only a few of the single column formats use this: WCN1, CAL1, RGEBCK - if (formatInfo.PlantFormat.FormatData.SectData.StepSectionData.StepSectionLayoutData.TieTabToLevel - && !(itemInfo.MyDocStyle.SpecialStepsFoldout && itemInfo.MyDocStyle.UseColSByLevel)) - { - int indxLevel = itemInfo.PrintLevel + itemInfo.CurrentSectionLevel(); - // B2021-113: BNPP1new - subsection & HLS should be same level (xoffset of tab & text) - if (formatInfo.PlantFormat.FormatData.SectData.StepSectionData.StepSectionLayoutData.SubSectAndHighSameLevel && !MyItemInfo.MyActiveSection.MyParent.IsProcedure) indxLevel++; - float colsbylevel = (float)formatInfo.PlantFormat.FormatData.SectData.MetaSectionList[indxLevel % formatInfo.PlantFormat.FormatData.SectData.MetaSectionList.MaxIndex].ColSByLevel; - float seclvlindent = colsbylevel - (float)formatInfo.PlantFormat.FormatData.SectData.StepSectionData.StepSectionLayoutData.ColS; - float adjCols = (float)formatInfo.PlantFormat.FormatData.SectData.StepSectionData.StepSectionLayoutData.ColS + seclvlindent; - float xtabcol = adjCols - ((myTab == null || myTab.Text == null) ? 0 : (myTab.Text.Length * 7.2f)); - if (indxLevel > 1 && myTab != null) myTab.XOffset = (float)itemInfo.MyDocStyle.Layout.LeftMargin + xtabcol; - else if (myTab != null) myTab.XOffset = (float)itemInfo.MyDocStyle.Layout.LeftMargin + colsbylevel; - if (myTab != null) - { - myTab.Rtf = myTab.Rtf.Replace(myTab.Text, myTab.Text.TrimStart(" ".ToCharArray())); - if (formatInfo.PlantFormat.FormatData.SectData.StepSectionData.StepSectionPrintData.LeftJustifyList != null && - formatInfo.PlantFormat.FormatData.SectData.StepSectionData.StepSectionPrintData.LeftJustifyList.Count > 0) - // B2021-113: BNPP1new - subsection & HLS should be same level (xoffset of tab & text) - if (formatInfo.PlantFormat.FormatData.SectData.StepSectionData.StepSectionLayoutData.SubSectAndHighSameLevel && !MyItemInfo.MyActiveSection.MyParent.IsProcedure) - XOffset += tabWidth; - else - XOffset = myTab.XOffset + GetLeftJustify(formatInfo, indxLevel); // 2.1.1 goes here xoffset = 136 - else - XOffset = myTab.XOffset + (myTab.Text.Length * (float)itemInfo.FormatStepData.Font.CPI) - colsbylevel; - } - } - else - { - XOffset += xoff; - // For Calvert, adjust from the left margin and current section's tab. This is used - // in BGEEOP (see EOP-0/Purpose ). However, it caused BGESTP's to print LossOfAC steps (unnumbered HLS) too - // far to the left. The ForceAlignNullTabWSectHead was introduced so that for that step type (LossOfAC) in STP/OI format, - // the SectData.SectionHeader.Pos was used rather than SectData.SectionNumber.Pos - if (myTab == null && !itemInfo.FormatStepData.ForceAlignNullTabWSectHead && itemInfo.FormatStepData.AlignNullTabWSectHead && itemInfo.ActiveFormat.PlantFormat.FormatData.PrintData.SpecialCaseCalvert) - XOffset = (float)itemInfo.MyDocStyle.Layout.LeftMargin + (float)formatInfo.PlantFormat.FormatData.SectData.SectionNumber.Pos; - else if (myTab == null && itemInfo.FormatStepData.AlignNullTabWSectHead) - XOffset = (float)itemInfo.MyDocStyle.Layout.LeftMargin + (float)formatInfo.PlantFormat.FormatData.SectData.SectionHeader.Pos; - if (myTab != null) - { - if (itemInfo.MyDocStyle.AlignHLSTabWithSect || itemInfo.FormatStepData.AlignHLSTabWithSectOvride) - { - float orgXOffset = MyTab.XOffset; - myTab.XOffset = (float)itemInfo.MyDocStyle.Layout.LeftMargin + (float)formatInfo.PlantFormat.FormatData.SectData.SectionHeader.Pos; - XOffset = myTab.XOffset + myTab.Width; - // F2025-040 Adjust the Cont Act box position around HLS number - if (myTab.MyMacro != null) myTab.MyMacro.XOffset += (MyTab.XOffset - orgXOffset); - } - else - { - myTab.XOffset += xoff; - if (myTab.MyMacro != null) myTab.MyMacro.XOffset += xoff; - } - } - else - { - if (itemInfo.MyDocStyle.AlignHLSTabWithSect) - XOffset = (float)itemInfo.MyDocStyle.Layout.LeftMargin + (float)formatInfo.PlantFormat.FormatData.SectData.SectionHeader.Pos; - } - } - } - else if (((colOvrd ?? 0) != 0) && (formatInfo.PlantFormat.FormatData.SectData.StepSectionData.StepSectionLayoutData.NullBox)) - { - float tabOffset = (myTab == null ? 0 : myTab.XOffset) - XOffset; - XOffset = (float)colOvrd; - if (myTab != null) myTab.XOffset = XOffset + tabOffset; - return; - } - else if (((colOvrd ?? 0) != 0) && (IsEnhancedBackgroundFormat(itemInfo) && (itemInfo.IsNote || itemInfo.IsCaution))) - { - float tabOffset = (myTab == null ? 0 : myTab.XOffset); - // Adjust the position of the Note/Caution text by the difference of the colOverride and the tab xoffset - XOffset += ((float)colOvrd - tabOffset); - if (myTab != null) myTab.XOffset = (float)colOvrd; // set the note/caution tab offset to the colOverride - return; - } - // put in for Point Beach (wep2) we don't want to do this if we are processing a boxed substep (cont. action substep) - else if (bxIndx != null && (itemInfo.IsCaution || itemInfo.IsNote || - !itemInfo.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.StepSectionPrintData.ContActBoxOnSubSteps)) - { - Box bx = formatInfo.PlantFormat.FormatData.BoxList[(int)bxIndx]; - if (bx == null) - { - if ((colOvrd ?? 0) != 0) - { - // 16-bit code subtracted the left margin - //xoff = ((float)colOvrd - (float)itemInfo.MyDocStyle.Layout.LeftMargin) - XOffset; - //XOffset += xoff; - //if (myTab != null) myTab.XOffset += xoff; - //xoff = MyParent.XOffset - myTab.XOffset; - //XOffset += xoff; - float tabOffset = (myTab == null ? 0 : myTab.XOffset) - XOffset; + if (MyPageHelper.ParaBreaks.Count > 0 && MyPageHelper.ParaBreaks[0].CompressFirstPartOfStep) + MyPageHelper.YMultiplier = _SevenLinesPerInch / SixLinesPerInch; + else + MyPageHelper.YMultiplier = 1; + break; + // .oooooo. .oooo. + // d8P' `Y8b .dP""Y88b + // 888 .oooo. .oooo.o .ooooo. ]8P' + // 888 `P )88b d88( "8 d88' `88b .d8P' + // 888 .oP"888 `"Y88b. 888ooo888 .dP' + // `88b ooo d8( 888 o. )88b 888 .o .oP .o + // `Y8bood8P' `Y888""8o 8""888P' `Y8bod8P' 8888888888 + case 2: // Break within a Step' + if (MyPromsPrinter.SupInfoPrintType == E_SupInfoPrintType.DoPageBreaks) + { + if (supInfoSect != null && MyItemInfo.SupInfos != null && MyItemInfo.SupInfos.Count > 0) supInfoSect.StepSectPageBreaksForSupInfo.Add(MyItemInfo.SupInfos[0].ItemID); + else MyPromsPrinter.NeedSupInfoBreak = true; + supInfoSect?.StepSectPageBreaks.Add(MyItemInfo.ItemID); + } + YTopMost = OutputOtherPageSteps(cb, YTopMost, yPageStart, yTopMargin, yBottomMargin); + docstyle = MyItemInfo.MyDocStyle; + bool doAlarmBox = false; + if (MyItemInfo.ActiveFormat.PlantFormat.FormatData.PrintData.SpecialCaseCalvertAlarm) + { + { + // Recognize that the break occurred WITHIN the CONDITION/RESPONSE table. + // Otherwise, we get extraneous header/top of box lines in pdf. + if (MyPageHelper.AlarmYoffStart > 0) + { + // if the first step in box is what broke to next page, then + // don't print the box on this page, only print it on next page: + doAlarmBox = true; + if (MyItemInfo.MyPrevious == null && MyParent.HasCalvertMacro) + MyPageHelper.AlarmYoffStart = 0; + else if (MyPageHelper.AlarmYoffEnd == 0) + { + // doThreeContinues flags when continue messages are printed in the + // bottom of the CONDITION/RESPONSE table columns. + doThreeContinues = MyItemInfo.StepLevel > 1; + MyPageHelper.AlarmYoffEnd = CalculateYLocation(yLocation, yTopMargin); + } + else if (MyPageHelper.AlarmYoffEnd > 0) + doAlarmBox = false; - XOffset = (float)colOvrd; - if (myTab != null) myTab.XOffset = XOffset + tabOffset; - return; - } - else - XOffset = (float)itemInfo.MyDocStyle.Layout.LeftMargin + tabWidth + XOffsetBox; - } - else - XOffset = (float)itemInfo.MyDocStyle.Layout.LeftMargin + (float)bx.TxtStart + _MyBoxLeftAdj + tabWidth + XOffsetBox; - if (myTab != null) myTab.XOffset = XOffset - tabWidth; - } - else if (itemInfo.IsRNOPart && itemInfo.MyParent != null && itemInfo.MyParent.IsRNOPart && itemInfo.FormatStepData.NumberWithLevel) - { - // xoffset is same as parent RNO (this is a BGE format flag). Instead of RNO's being siblings, - // they had a parent/child relationship. So want the child to have same xoffset as parent, i.e. - // the same xoffset. - XOffset = MyParent.XOffset; - myTab.XOffset = MyParent.MyTab.XOffset; - return; - } - else if (itemInfo.IsRNOPart && (colOvrd > 0 || !((ItemInfo)itemInfo.ActiveParent).IsHigh) && itemInfo.FormatStepData.OffsetTab) - { - if (colOvrd > 0) - { - XOffset = (int)colOvrd; - if (!((ItemInfo)itemInfo.MyParent).IsHigh) - { - ItemInfo hls = itemInfo.MyHLS; - XOffset -= (itemInfo.MyTab.Offset - hls.MyTab.Offset); - } - } - // if this format has the centerline & numberwithlevel (special tabbing for rno) then - // position rno xoffset of the tab to be close to centerline & text indented from there (only BGE) - if (itemInfo.MyDocStyle.CenterLineX != null && itemInfo.FormatStepData.NumberWithLevel) - { - // if the tab is 3 char or smaller, make the indent amount for the rno text 4 characters. - // if bigger, make it the additional tab size. - int len = myTab.Text.Trim().Length; - int adj = len <= 3 ? 4 : (len - 3) + 4; - float rnoOffset = (float)itemInfo.MyDocStyle.Layout.LeftMargin + (float)itemInfo.MyDocStyle.CenterLineX + 5; - float tPtPerChar = itemInfo.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.StepSectionLayoutData.TabPtsPerChar ?? 6; - XOffset = rnoOffset + tPtPerChar * adj; - Width = (float)itemInfo.MyDocStyle.Layout.PageWidth - XOffset - 11; // 11 is about size of char, so don't touch right line. - if (myTab != null) myTab.XOffset = rnoOffset; - } - // if the step is within the rno and we're numbering the high level rno, we've got to account for the - // indenting (increased x offset) for the top level rno's tab, if there is no top level rno: - else if (itemInfo.FormatStepData.NumberHighLevel && (itemInfo.MyHLS.RNOs == null || itemInfo.MyHLS.RNOs.Count <= 0)) - { - // add in the size that an RNO off HLS would take. - tabWidth += itemInfo.MyTab.RNOTabWidthAdjust; - XOffset += tabWidth; - if (myTab != null) myTab.XOffset += tabWidth; - } - if (itemInfo.ActiveFormat.MyStepSectionLayoutData.DevNoteOrCautionTabOffset != null) - { - MyTab.XOffset = float.Parse(itemInfo.ActiveFormat.MyStepSectionLayoutData.DevNoteOrCautionTabOffset); - XOffset = MyTab.XOffset + tabWidth - MyTab.TabAlign; - } - } - else if (MyParent != null) - { - if (myTab == null && itemInfo.FormatStepData.AlignNullTabWSectHead && itemInfo.ActiveFormat.PlantFormat.FormatData.PrintData.SpecialCaseCalvert) - XOffset = (float)itemInfo.MyDocStyle.Layout.LeftMargin + (float)formatInfo.PlantFormat.FormatData.SectData.SectionNumber.Pos; - else if (itemInfo.ActiveFormat.MyStepSectionLayoutData.DevNoteOrCautionTabOffset != null) - { - if (MyTab != null) - { - MyTab.XOffset = float.Parse(itemInfo.ActiveFormat.MyStepSectionLayoutData.DevNoteOrCautionTabOffset); - XOffset = MyTab.XOffset + tabWidth - MyTab.TabAlign; - if (myTab.MyMacro != null && myTab.MyMacro.XOffset != 0) myTab.MyMacro.XOffset += tabWidth - myTab.TabAlign; - } - } - else if (itemInfo.IsSequential && itemInfo.MyParent.IsHigh && ((itemInfo.MyDocStyle.StructureStyle.Style & E_DocStructStyle.Align1StLevSubWHLS) == E_DocStructStyle.Align1StLevSubWHLS)) - { - XOffset = MyParent.XOffset; - if (myTab != null) myTab.XOffset = (MyParent.MyTab != null ? MyParent.MyTab.XOffset : XOffset); - } - else if (itemInfo.IsSequential && itemInfo.MyHLS.FormatStepData.AppendDotZero)// F2018-025 shift first level substep to column position of high level step Westinghouse wst1 step type 50 - { - if (itemInfo.MyParent.IsHigh) - { - XOffset = MyParent.XOffset; - if (myTab != null) myTab.XOffset = (MyParent.MyTab != null ? MyParent.MyTab.XOffset : XOffset); - } - else - { - myTab.XOffset = MyParent.XOffset; - XOffset = myTab.XOffset + MyTab.Width; - } - } - else if (myTab != null && itemInfo.IsSequential && formatInfo.PlantFormat.FormatData.SectData.UseMetaSections && formatInfo.PlantFormat.FormatData.SectData.StepSectionData.StepSectionPrintData.LeftJustifyList.Count > 0) - { - int indxLevels = itemInfo.PrintLevel + itemInfo.CurrentSectionLevel(); - // B2021-113: BNPP1new - subsection & HLS should be same level (xoffset of tab & text) - if (formatInfo.PlantFormat.FormatData.SectData.StepSectionData.StepSectionLayoutData.SubSectAndHighSameLevel && !MyItemInfo.MyActiveSection.MyParent.IsProcedure) indxLevels++; - float tableftadj = GetLeftJustify(formatInfo, indxLevels); - if (tableftadj != 0) - { - // the order of this is important. First adjust the tab's xoffset for the width of - // the tab. The offset of text needs to be adjusted by the 'leftjustify' format variable - // if it existed for this level. - myTab.XOffset += tabWidth; - if (tableftadj != 0 && myTab.Width < tableftadj) - tabWidth = myTab.Width = tableftadj; - XOffset += tabWidth; - myTab.Rtf = myTab.Rtf.Replace(myTab.Text, myTab.Text.TrimStart(" ".ToCharArray())); - Width = MyParent.Width - myTab.Width; - } - else // if no left justify, right align the tab - { - XOffset += tabWidth - (myTab == null ? 0 : myTab.TabAlign); - if (myTab != null) - { - myTab.XOffset += tabWidth - myTab.TabAlign; - if (myTab.MyMacro != null && myTab.MyMacro.XOffset != 0) myTab.MyMacro.XOffset += tabWidth - myTab.TabAlign; - } - } - } + } + } + } + if (MyPageHelper.NotesToFootNotes != null && MyPageHelper.NotesToFootNotes.Count > 0) MyPageHelper.NotesToFootNotesYoffset = CalculateYLocation(yLocation, yTopMargin); + // B2019-115 Locate Bottom Continue Message below AER Table if necesssary + float bcm_yLocation = TableBottom == -1 ? yLocation : Math.Min(TableBottom, yLocation); + DoBottomContinueMsg(cb, yBottomMargin, bcm_yLocation, docstyle, doThreeContinues); + MyPromsPrinter.NewPage(); + // C2018-003 fixed use of getting the active section + // F2023-112 Vogtle Units 3 & 4 background document format DSS_PageListBkgndStpContMsg to print continue message next to step number + if (MyItemInfo.IsStep && (MyItemInfo.ActiveSection != null && + ((MyItemInfo.ActiveSection.MyDocStyle.StructureStyle.Style & E_DocStructStyle.DSS_PageListSpBckgrnd) == E_DocStructStyle.DSS_PageListSpBckgrnd) || + ((MyItemInfo.ActiveSection.MyDocStyle.StructureStyle.Style & E_DocStructStyle.DSS_PageListBkgndStpContMsg) == E_DocStructStyle.DSS_PageListBkgndStpContMsg))) + { + // check if parent (can be HLS, Caution or Note) has the UseOldTemplate. If so, + // flag that a continue message should be printed as part of a pagelist header (if pagelist + // has CM: page list item) + ItemInfo itm = MyItemInfo; + while (itm.IsStep && !itm.FormatStepData.UseOldTemplate) itm = itm.MyParent; + // don't put out continue if the page break item is the same as background step item (caution/note or hls) + if (itm.IsStep && itm.ItemID != MyItemInfo.ItemID) + { + MyPageHelper.OldTemplateContMsg = true; + MyPageHelper.ResetSvg(); + } + } + //_MyLog.InfoFormat("NewPage 11 {0}", cb.PdfWriter.CurrentPageNumber); + //Console.WriteLine("'b2',{0},'{1}',{2},{3},{4},{5},{6}", MyItemInfo.ItemID, MyItemInfo.ShortPath, yTopMargin, yPageStart, yLocation, YTopMost, YOffset); + ResetDocStyleAndValues(ref yTopMargin, ref yBottomMargin); + //Console.WriteLine("'a2',{0},'{1}',{2},{3},{4},{5},{6}", MyItemInfo.ItemID, MyItemInfo.ShortPath, yTopMargin, yPageStart, yLocation, YTopMost, YOffset); - //else if ((itemInfo.FormatStepData.ColOverride ?? 0) > 0) - //{ - // XOffset = (float)itemInfo.FormatStepData.ColOverride; - // MyTab.XOffset = XOffset; - // return; - //} - else // if no left justify, right align the tab - { - // The following fixes F2016-033: Print the Verification Point at left margin. - if (itemInfo.ActiveFormat.Name.ToUpper().StartsWith("VCB") && (itemInfo.FormatStepData.ColOverride ?? 0) > 0) - { - XOffset = (float)itemInfo.FormatStepData.ColOverride; - } - else - { - XOffset += tabWidth - (myTab == null ? 0 : myTab.TabAlign); - if (myTab != null) - { - myTab.XOffset += tabWidth - myTab.TabAlign; - if (myTab.MyMacro != null && myTab.MyMacro.XOffset != 0) myTab.MyMacro.XOffset += tabWidth - myTab.TabAlign; - } - // B2018-146 Adjust the width to match the HLS Right Margin. - if (itemInfo.IsBackgroundStepOrChild()) - Width = this.MyHighLevelParagraph.Width + this.MyHighLevelParagraph.XOffset - this.XOffset; - } - } - } - // if format had a tab adjustment for step type, use it. MyTab.Offset is only set for FNP formats - // to get the correct xoffset for their tabs/text. The issue is that they use very large tabs - // because levels of substeps include the parent tab. This code will only be run for FNP. - if (itemInfo.MyTab != null && itemInfo.MyTab.Offset != 0) - { - float xOffTabNew = (MyParent.MyTab != null ? MyParent.MyTab.XOffset : MyParent.XOffset) + itemInfo.MyTab.Offset; - xOffTabNew += MyParent.MyTab == null ? 0 : MyParent.MyTab.TabOffset; - float xIncrement = xOffTabNew - MyTab.XOffset; - myTab.XOffset += xIncrement; - XOffset += xIncrement; - Width -= xIncrement; - } - } - private bool PreviousIsTitleWithTextBelow(ItemInfo itemInfo) - { - while (itemInfo.MyPrevious != null) - { - if (itemInfo.MyPrevious.FormatStepData.Type == "TitleWithTextBelow") return true; - itemInfo = itemInfo.MyPrevious; - } - return false; - } + DebugText.WriteLine("Paginate2"); + if (MyItemInfo.MyHLS.FoldoutIndex() > -1) + MyPromsPrinter.DoFoldoutPage(cb, "Break within Step", MyPageHelper.TextLayer, MyPageHelper, MyItemInfo.MyHLS.FoldoutIndex(), false); // temporary foldout + else if (PromsPrinter.MyFoldoutReader.Count > 0 && MyPageHelper.MyPromsPrinter.InsertBlankPages) + { + MyPromsPrinter.InsertBlankPage(cb); + _MyLog.InfoFormat("NewPage Break within step blank {0}", cb.PdfWriter.CurrentPageNumber); + } + if (MyPromsPrinter.SupInfoPrintType == E_SupInfoPrintType.Merge && !MyPageHelper.CreatingSupInfoPage && !MyItemInfo.IsSection && !MyItemInfo.IsInSupInfo && (MyItemInfo.MyProcedure as ProcedureInfo).ProcHasSupInfoData) + { + int sid = GetIdThatHasSupInfoItems(MyItemInfo, MyItemInfo.ItemID); + if (sid != -1) + { + MyPromsPrinter.DoSupInfoPage(cb, MyPageHelper.TextLayer, MyPageHelper, sid); + } + else + { + MyPromsPrinter.InsertBlankPage(cb); + } + } + // if there is a 'container vlnbox' around the HLS, flag that the drawn box must also break: + if (MyHighLevelParagraph != null && MyHighLevelParagraph.PartsContainer != null && MyHighLevelParagraph.PartsContainer.Count > 0 && + !((MyHighLevelParagraph.MyItemInfo.MyDocStyle.StructureStyle.Style & E_DocStructStyle.DoubleBoxHLS) == E_DocStructStyle.DoubleBoxHLS)) + { + foreach (vlnPrintObject vpo in MyHighLevelParagraph.PartsContainer) + { + if (vpo is vlnBox vb) + { + vb.ContainsPageBreak = true; + PartsContainer.Add(vb); + } + } + } - private static float GetLeftJustify(FormatInfo formatInfo, int indxLevels) - { - LeftJustifyList jstlst = formatInfo.PlantFormat.FormatData.SectData.StepSectionData.StepSectionPrintData.LeftJustifyList; - float tableftadj = 0; - foreach (LeftJustify lj in jstlst) - { - if (lj.Index == indxLevels) - { - tableftadj = lj.Size ?? 0; - break; - } - } - return tableftadj; - } - private float _CheckOffWidth = 0; - public float CheckOffWidth - { - get { return _CheckOffWidth; } - set { _CheckOffWidth = value; } - } - private float _AdjustHeader = 0;// B2018-096 AEP 082.002CD Note Box overlapping Step Box - public float AdjustHeader - { - get { return _AdjustHeader; } - set { _AdjustHeader = value; } - } - public void AdjustWidth(ItemInfo itemInfo, int maxRNO, FormatInfo formatInfo, vlnTab myTab) - { - int? bxIndx = itemInfo.IsStep ? itemInfo.FormatStepData.StepLayoutData.STBoxindex : null; - float? widOvrd = 0; - float xwid = 0; - if (itemInfo.IsStep && itemInfo.MyHLS != null && UseTemplateWidthOrXOff(itemInfo) && (xwid = GetWidthOrStartFromTemplate(itemInfo, formatInfo, true)) > 0) - widOvrd = xwid; - else - widOvrd = itemInfo.FormatStepData == null ? null : itemInfo.FormatStepData.WidthOverride == null ? null : - (float?)ToInt(itemInfo.FormatStepData.WidthOverride, maxRNO); - // Calvert subheaders in valve lists - the text gets centered, so the width is the width - // of the page (also, don't do this for alarms, thus the !SpecialCaseCalvert Alarms, since - // alarms use Caution1 as the annunciator): - if (itemInfo.IsStep && itemInfo.MyHLS != null && !itemInfo.ActiveFormat.PlantFormat.FormatData.PrintData.SpecialCaseCalvertAlarm && - itemInfo.MyHLS.FormatStepData.UseOldTemplate && itemInfo.MyDocStyle.ComponentList && itemInfo.IsCaution1) - { - Width = (float)itemInfo.MyDocStyle.Layout.PageWidth - (float)itemInfo.MyDocStyle.Layout.LeftMargin; - return; - } + // If there is a box, adjust the yTopMost to include it. + float yTopMost = YTopMost; + if ((MyItemInfo.IsCautionPart || MyItemInfo.IsNotePart) && MyParent.PartsAbove.Count > 0) + yTopMost = MyParent.PartsAbove[0].YOffset; + yTopMost = Math.Min(yTopMost, YVeryTop); + yPageStart = yTopMargin + yTopMost;// -2 * SixLinesPerInch; + DoCheckOffHeader(cb, MyItemInfo, yLocation, yTopMargin, yPageStart); + if (EmptyTopMostPart) yPageStart += SixLinesPerInch; + // If "ContinueSectionHeader" (format flag) is true then print the section title with "(Continued)" appended to it + if (MyItemInfo.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.ContinueSectionHeader) + { + // if this is calvert OI/STP, then also check that docstyle has a top continue message + // in the document style that includes 'Continued' + if (MyItemInfo.ActiveFormat.PlantFormat.FormatData.PrintData.SpecialCaseCalvert) + { + string myMsg = MyItemInfo.MyDocStyle.Continue.Top.Message; + if (myMsg == null || myMsg == "") + { + // There is no message, but still need to check if there is a Section Title Continued message: + // This was added for BGE OI34 (if break was within step, no section title continue message was printed) + if (MyItemInfo.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.ContinueSectionHeader) + { + SectionConfig sch = MyItemInfo.ActiveSection.MyConfig as SectionConfig; + doSectionTitleContinued = (sch == null || sch.Section_PrintHdr == "Y") && !MyItemInfo.MyDocStyle.CancelSectTitle; + } + else + doSectionTitleContinued = false; + } + else + { + SectionConfig sch = MyItemInfo.ActiveSection.MyConfig as SectionConfig; + doSectionTitleContinued = (sch == null || sch.Section_PrintHdr == "Y") && !MyItemInfo.MyDocStyle.CancelSectTitle; + } + } + else + { + SectionConfig sch = MyItemInfo.ActiveSection.MyConfig as SectionConfig; + doSectionTitleContinued = (sch == null || sch.Section_PrintHdr == "Y") && !MyItemInfo.MyDocStyle.CancelSectTitle; + } + } + bool addExtraLines = SectionTopMessage(cb, yTopMargin); + if (MyPageHelper.CreatingSupInfoPage) yPageStart -= (2 * SixLinesPerInch); + if (!addExtraLines && (!doSectionTitleContinued || !SectionShowTitles)) + addExtraLines = DoTopContinueMsg(cb, ref yPageStart, yTopMargin, docstyle, doThreeContinues && MyItemInfo.MyParent != null && MyItemInfo.MyParent.MyTab != null ? MyItemInfo.MyParent.MyTab.CleanText : null); + // B2020-128: If compression flag is on RNO, see if there is an AER to the left and do the 7lpi multiplier + if (CompressPartOfStep || CompressRnoWithAerToTheLeft()) + { + MyPageHelper.YMultiplier = _SevenLinesPerInch / SixLinesPerInch; + CompressPartOfStep = false; + } + else + MyPageHelper.YMultiplier = 1; - // Calvert Alarms had a case where the Title With Text Below (type 42) did not match - // any of the template items, but needed the width from the template. The previous step (of - // same type) was in the template. Check for this case. The issue can be found in - // Unit 1 Alarms/1c06/Alarm E-48/'General Information' section. - if (itemInfo.ActiveFormat.PlantFormat.FormatData.PrintData.SpecialCaseCalvertAlarm && widOvrd == 0) - { - if (itemInfo.MyPrevious != null && itemInfo.MyPrevious.TemplateIndex > 1) widOvrd = GetWidthOrStartFromTemplate(itemInfo.MyPrevious, itemInfo.MyPrevious.ActiveFormat, true); - } + // For Calvert Alarms, if there was a page break and there is an box around the current + // step, need to add the header for the box, which is stored in a macro. Also set the + // 'AlarmYoffStart' value to where the vertical lines of the box start on this page. + if (doAlarmBox && MyItemInfo.StepLevel > 1) + { + float alrmY = yTopMargin - (2 * SixLinesPerInch); // CalculateYOffset(yPageStart, yTopMargin); + vlnMacro vlnm = new vlnMacro((float)docstyle.Layout.LeftMargin - 12, alrmY, "H4") + { + UseInternalY = true // B2020-121: Account for Header on Caution or Note + }; + PartsLeft.Add(vlnm); + MyPageHelper.AlarmYoffStart = alrmY - SixLinesPerInch; + yPageStart -= (4 * SixLinesPerInch); + if (ChildrenRight.Count > 0 && ChildrenRight[0].ChildrenAbove.Count > 0 && ChildrenRight[0].ChildrenAbove[0].MyItemInfo.IsCautionOrNotePart) + yPageStart += (SixLinesPerInch); // B2020-121: Account for Header on Caution or Note + } + // For Calvert Alarms, if there is no box & this is top of page, if previous step + // had box (macro), adjust up page. The constructor (vlnParagraph), inserted these + // lines after the box so that the following text did not print right next to box. + if (MyItemInfo.ActiveFormat.PlantFormat.FormatData.PrintData.SpecialCaseCalvertAlarm) + { + if (MyItemInfo.MyPrevious != null && MyItemInfo.MyPrevious.TemplateIndex > 0 && MyItemInfo.ActiveFormat.PlantFormat.FormatData.Templates[MyItemInfo.MyPrevious.TemplateIndex].hmacro > 0) + yPageStart += (3 * SixLinesPerInch); + } + // Now check if this is a template type step & if so, add the HLS's prefix/suffix to it. + // Since the entire checklist HLS (checklist table header) is printed as part of the + // continue, create a new paragraph to handle pagination and printing. + if (MyItemInfo.MyHLS != null && MyItemInfo.MyHLS.FormatStepData.UseSmartTemplate) + { + DoSubs = false; + vlnParagraph smartPara = new vlnParagraph(MyParent.MyParent, cb, MyItemInfo.MyHLS, MyParent.XOffset, yPageStart, 0, 0, MyParent.MyItemInfo.ActiveFormat, null, " (Continued)", 0, false, MyPromsPrinter) + { + PrintHeader = true + }; + _ = smartPara.ParagraphToPdf(cb, yPageStart, yTopMargin, yBottomMargin); + yPageStart -= smartPara.Height; + DoSubs = true; + } + if (addExtraLines) yPageStart -= (2 * SixLinesPerInch); + if (MyItemInfo.IsRNOPart && MyItemInfo.FormatStepData.DoubleSpace && MyItemInfo.FormatStepData.SpaceDouble) yPageStart += SixLinesPerInch; + break; + // .oooooo. .oooo. + // d8P' `Y8b .dP""Y88b + // 888 .oooo. .oooo.o .ooooo. ]8P' + // 888 `P )88b d88( "8 d88' `88b <88b. + // 888 .oP"888 `"Y88b. 888ooo888 `88b. + // `88b ooo d8( 888 o. )88b 888 .o o. .88P + // `Y8bood8P' `Y888""8o 8""888P' `Y8bod8P' `8bd88P' + case 3: // Break on High Level Step (SevenLinesPerInch) + if (MyPromsPrinter.SupInfoPrintType == E_SupInfoPrintType.DoPageBreaks) + { + if (supInfoSect != null && MyItemInfo.SupInfos != null && MyItemInfo.SupInfos.Count > 0) supInfoSect.StepSectPageBreaksForSupInfo.Add(MyItemInfo.SupInfos[0].ItemID); + else MyPromsPrinter.NeedSupInfoBreak = true; + supInfoSect?.StepSectPageBreaks.Add(MyItemInfo.ItemID); + } + if (!firstHighLevelStep || (MyPromsPrinter.SupInfoPrintType == E_SupInfoPrintType.Merge && !MyPageHelper.CreatingSupInfoPage)) // B2017-229: Added supinfo print check to run facing page logic + { + YTopMost = OutputOtherPageSteps(cb, YTopMost, yPageStart, yTopMargin, yBottomMargin); + if (MyPageHelper.NotesToFootNotes != null && MyPageHelper.NotesToFootNotes.Count > 0) MyPageHelper.NotesToFootNotesYoffset = CalculateYLocation(yLocation, yTopMargin); + MyPromsPrinter.NewPage(); // HLS (7 lpi) breakif (MyItemInfo.IsSection) + //_MyLog.InfoFormat("NewPage 12 {0}", cb.PdfWriter.CurrentPageNumber); + //Console.WriteLine("'b3',{0},'{1}',{2},{3},{4},{5},{6}", MyItemInfo.ItemID, MyItemInfo.ShortPath, yTopMargin, yPageStart, yLocation, YTopMost, YOffset); + ResetDocStyleAndValues(ref yTopMargin, ref yBottomMargin); + //Console.WriteLine("'a3',{0},'{1}',{2},{3},{4},{5},{6}", MyItemInfo.ItemID, MyItemInfo.ShortPath, yTopMargin, yPageStart, yLocation, YTopMost, YOffset); + DebugText.WriteLine("Paginate3"); + if (MyItemInfo.IsSection) + { + SectionInfo si = MyItemInfo as SectionInfo; + MyPageHelper.PageBookmarks.Add(MyItemInfo, $"{((si.DisplayNumber ?? "") == "" ? "" : $"{si.DisplayNumber} - ")}{si.DisplayText}", null); + } + if (MyItemInfo.FoldoutIndex() > -1) + MyPromsPrinter.DoFoldoutPage(cb, "HLS (7 lpi) break", MyPageHelper.TextLayer, MyPageHelper, MyItemInfo.FoldoutIndex(), false); + else if (PromsPrinter.MyFoldoutReader.Count > 0 && MyPageHelper.MyPromsPrinter.InsertBlankPages) + { + // insert a blank page if this step section had a foldout associated and the checkbox + // on the print dialog, to add blank pages, is checked + MyPromsPrinter.InsertBlankPage(cb); + //_MyLog.InfoFormat("NewPage 12 lpi blank {0}", cb.PdfWriter.CurrentPageNumber); + } + // See comments under case 0 explaining supinfo/facing page processing. + itemIsPrinted = IsPrintedStepItemForSupInfo(); + if (MyPromsPrinter.SupInfoPrintType == E_SupInfoPrintType.Merge && !MyPageHelper.CreatingSupInfoPage && itemIsPrinted /*&& !MyItemInfo.IsSection */ && !MyItemInfo.IsInSupInfo && (MyItemInfo.MyProcedure as ProcedureInfo).ProcHasSupInfoData) + { + int sid = GetIdThatHasSupInfoItems(MyItemInfo, MyItemInfo.ItemID); + if (sid != -1) + { + MyPromsPrinter.DoSupInfoPage(cb, MyPageHelper.TextLayer, MyPageHelper, sid); + } + else + { + // B2020-031: Don't put out an extra blank page if section has title that is printed (blank page is output then) + bool titlePrinted = false; + if (MyItemInfo.IsSection || (MyItemInfo.IsHigh && MyItemInfo.MyPrevious == null)) + { + // see if the section title is printed. + titlePrinted = (!(MyItemInfo.ActiveSection.MyConfig is SectionConfig sch) || sch.Section_PrintHdr == "Y") || !(MyItemInfo.MyActiveSection as SectionInfo).HasSupInfoSteps; + titlePrinted &= (ShowSectionTitles && !MyItemInfo.MyDocStyle.CancelSectTitle); + } + if (MyItemInfo.IsHigh && MyItemInfo.MyPrevious == null && !titlePrinted) + MyPromsPrinter.InsertBlankPage(cb); + } + } + if (MyItemInfo.MyDocStyle.LandscapePageList) + { + System.Drawing.Drawing2D.Matrix myMatrix = new System.Drawing.Drawing2D.Matrix(0, 1, -1, 0, cb.PdfDocument.PageSize.Height, 0); + cb.Transform(myMatrix); + } - // for IP2 backgrounds, set widths appropriately for template items: - if (itemInfo.IsStep && (itemInfo.ActiveSection != null && (itemInfo.ActiveSection.MyDocStyle.StructureStyle.Style & E_DocStructStyle.DSS_PageListSpBckgrnd) == E_DocStructStyle.DSS_PageListSpBckgrnd)) // C2018-003 fixed use of getting the active section - { - if (itemInfo.FormatStepData.Type.ToUpper() == "TITLEWITHTEXTBELOW") - { - Width = MyParent.Width; - return; - } - if (itemInfo.MyPrevious != null && itemInfo.MyPrevious.FormatStepData.Type == "TitleWithTextBelow") - { - Width = MyParent.MyParent.Width; - return; - } - if (widOvrd == 0 && itemInfo.MyParent.IsStep && - (itemInfo.MyParent.FormatStepData.Type.ToUpper() == "TITLEWITHTEXTBELOW" || - (((itemInfo.ActiveSection.MyDocStyle.StructureStyle.Style & E_DocStructStyle.DSS_PageListSpBckgrnd) == E_DocStructStyle.DSS_PageListSpBckgrnd) && - itemInfo.FormatStepData != null && MyParent.MyItemInfo.MyPrevious != null && MyParent.MyItemInfo.MyPrevious.FormatStepData.Type == "TitleWithTextBelow"))) - { - Width = MyParent.MyParent.Width + (MyParent.MyParent.MyTab != null ? MyParent.MyParent.MyTab.Width : 0); - Width -= (MyTab != null ? MyTab.Width : 0); - return; - } - } + // If "ContinueSectionHeader" (format flag) is true then print the section title with "(Continued)" appended to it + if (!MyItemInfo.IsSection && MyItemInfo.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.ContinueSectionHeader) + { + SectionConfig sch = MyItemInfo.ActiveSection.MyConfig as SectionConfig; + doSectionTitleContinued = (sch == null || sch.Section_PrintHdr == "Y") && !MyItemInfo.MyDocStyle.CancelSectTitle; + } + } + // if printing the section title, we already have the y location (note that only do this for the + // first step in the section. + if (MyItemInfo.MyPrevious != null || MyItemInfo.MyParent == null || !MyItemInfo.MyParent.IsStepSection || !ShowSectionTitles || MyItemInfo.MyDocStyle.CancelSectTitle || MyItemInfo.MyDocStyle.SpecialStepsFoldout) + { + yPageStart = yTopMargin + YTopMost; + } - //widOvrd = itemInfo.FormatStepData == null ? null : itemInfo.FormatStepData.WidthOverride; - // Don't adjust the RNO width if in single column mode: - if (itemInfo.IsRNOPart && itemInfo.MyParent.IsHigh && itemInfo.ActiveSection != null && itemInfo.ActiveSection.ColumnMode != 0 && itemInfo.ActiveFormat.MyStepSectionLayoutData.RNOWidthAlt != null) // C2018-003 fixed use of getting the active section - { - string[] splitRNOWidthAlt = itemInfo.ActiveFormat.MyStepSectionLayoutData.RNOWidthAlt.Split(','); - float ovrd = (itemInfo.RNOLevel < splitRNOWidthAlt.Length) ? float.Parse(splitRNOWidthAlt[itemInfo.RNOLevel]) : 0; - if (ovrd > 0) - widOvrd = ovrd; // + 6; // Change bars on RNO column (signoff line) would not line up with 16-bit without this - NSP Alarms - } - if ((widOvrd ?? 0) != 0) - { - //F2023-112 Vogtle Units 3 & 4 Backgrounds. Don't use override width of paragraph when it's off of TitleWithTextRight - // We need to allow the code to calculate the width of that paragraph for this case (later in this function) - if (!(itemInfo.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.Vogtle3and4BackgroundFormat && itemInfo.MyParent.FormatStepData != null && itemInfo.MyParent.FormatStepData.Type == "TitleWithTextRight")) - { - Width = (float)widOvrd; - // if there's a box, we may need to do an adjustment on the width, if the tab data was changed - // so don't return. - if (bxIndx == null) return; - } - } - float tabWidth = (myTab == null) ? 0 : myTab.Width; - if (itemInfo.IsHigh) - { - float CheckOffAdj = 0; - bool ChkOff = itemInfo.MyDocStyle.UseCheckOffs; - // C2019-040 use format flag to see if any of the steps in this section have a checkoff set - previously we check if the format file name starts with VCB (VCB no longer a customer) - if (itemInfo.ActiveFormat.PlantFormat.FormatData.PrintData.SpecialCaseCalvert || itemInfo.ActiveFormat.PlantFormat.FormatData.ProcData.CheckOffData.CheckoffsWithoutHeader) - { - SectionInfo si = itemInfo.ActiveSection.GetSectionInfo(); - ChkOff = si.HasInitials; // this determines if any steps within the section have checkoffs. - } - bool FmtHasAdj = false; - if (ChkOff) - { - if (formatInfo.PlantFormat.FormatData.ProcData.CheckOffData.CheckOffAdjustment != null) - { - FmtHasAdj = true; - CheckOffAdj = -(float)formatInfo.PlantFormat.FormatData.ProcData.CheckOffData.CheckOffAdjustment; - } - // C2019-040 use format flag to not readjust the CheckOffAdj value - previously we check if the format file name starts with VCB (VCB no longer a customer) - if (!itemInfo.ActiveFormat.PlantFormat.FormatData.ProcData.CheckOffData.CheckoffsWithoutHeader) // Don't do the following if in a vcb format (part of fix F2016-039) - { - if (!HasCheckOffHeading(itemInfo, formatInfo) && CheckOffAdj < 0) - CheckOffAdj += (float)(9 * 7.2); // 9 is the size of the SIGNOFF adjustment - else if (!FmtHasAdj && HasCheckOffHeading(itemInfo, formatInfo)) - // For Robinson, tried using font's CharsToTwips but it made it too narrow, so used hardcoded 6: - CheckOffAdj = -((float)9 * 6); - } - } - float adjwidth = CheckOffAdj; - CheckOffWidth = -CheckOffAdj; - adjwidth = AdjustMetaWidth(itemInfo, formatInfo, adjwidth, FmtHasAdj); - Width = ToInt(formatInfo.MyStepSectionLayoutData.WidSTablePrint, maxRNO); - Width += _WidthAdjust; - Width += adjwidth; + MyPageHelper.YMultiplier = _SevenLinesPerInch / SixLinesPerInch; + DoCheckOffHeader(cb, MyItemInfo, yLocation, yTopMargin, yPageStart); + break; + } + // If "doSectionTitleContinued" is true then print the section title with "(Continued)" appended to it + // format must have ContinueSectinHeader format flag set to true + //B2025-048 Problem with Printing CAS Steps + // skip this if printing CAS or CTAS - was causing it to + // skip/overwrite data + if (doSectionTitleContinued) + { + vlnParagraph sectContPara; + string contMsg = (MyItemInfo.ActiveSection != null) ? MyItemInfo.ActiveSection.MyDocStyle.Continue.SectionTitle.AppendToTitle : ""; // C2018-003 fixed use of getting the active section + // For Calvert, the xoffset will be the highest level sections xoffset (there are metasections, + // don't use their xoffset or the continue message is indented too much) + if (MyItemInfo.ActiveFormat.PlantFormat.FormatData.PrintData.SpecialCaseCalvert) + { + float secContinueTabXoff = (float)MyItemInfo.MyDocStyle.Layout.LeftMargin; + float secContinueXoff = 0f; + vlnParagraph fndTopSect = this; + while (fndTopSect.MyParent != null) + { + fndTopSect = fndTopSect.MyParent; + } + if (fndTopSect != null && fndTopSect.MyTab != null) + { + secContinueTabXoff = fndTopSect.MyTab.XOffset; + secContinueXoff = fndTopSect.XOffset; + } + // get to the correct section for the message, i.e. if on a section, the message should be the parent + // section (not the activesection which is myself); if on a step, the message should be the active section + ItemInfo sectForCont = MyItemInfo.IsSection && MyItemInfo.MyParent.IsSection ? MyItemInfo.MyParent : MyItemInfo.ActiveSection; + //B2025-054 Wrong Page Numbers in CAS Summary + // when section title continued and CAS + //to avoid overwriting data + // - this will be built at a different call to vlnParagraph + if (MyPromsPrinter.PromsPrinterPrintType != PromsPrinterPrintType.Normal) + MyPromsPrinter.ShouldPrint_CAS_CTAS = false; + sectContPara = new vlnParagraph(MyParent.MyParent, cb, sectForCont, MyParent.XOffset, 0, 0, 0, MyParent.MyItemInfo.ActiveFormat, null, (contMsg == null || contMsg == "") ? " (Continued)" : contMsg, 0, false, MyPromsPrinter); + if (sectContPara.PartsLeft.Count > 0) + { + vlnTab vt = sectContPara.MyTab; + string ctab = GetSectCombinedTab(MyItemInfo); + vt.Rtf = GetRtf(ctab, vt.MyFont); + float wd = vt.GetTextWidth(vt.MyFont, ctab); + vt.XOffset = secContinueTabXoff; + vt.Width = secContinueXoff - secContinueTabXoff; + sectContPara.XOffset = secContinueXoff; + if ((wd + 12) > secContinueXoff - secContinueTabXoff) // 12 is 2 characters + { + float dif = wd + 12 - (secContinueXoff - secContinueTabXoff); + vt.Width += dif; + sectContPara.XOffset += dif; + sectContPara.Width -= dif; + } - // if AlignHLSTabWithSect is set, we moved the starting x location of the HLS, and following steps - // to be under section header. Adjust the width accordingly, or the text may go out of the margin. - if (myTab == null && itemInfo.FormatStepData.AlignNullTabWSectHead && itemInfo.ActiveFormat.PlantFormat.FormatData.PrintData.SpecialCaseCalvert) - Width = Width + (float)formatInfo.PlantFormat.FormatData.SectData.SectionHeader.Pos - (float)formatInfo.PlantFormat.FormatData.SectData.SectionNumber.Pos; - else if (myTab == null && itemInfo.FormatStepData.AlignNullTabWSectHead) - Width = Width + (float)formatInfo.PlantFormat.FormatData.SectData.SectionHeader.Pos; - else if (itemInfo.MyDocStyle.AlignHLSTabWithSect) - Width = Width - (float)formatInfo.PlantFormat.FormatData.SectData.SectionHeader.Pos; + } - // B2022-002: Section text is printing into the INITIAL column (BNPP1new). If this flag is set adjust the width of the - // section text to that of the first hls (child) text and its tab. This is to prevent the very long section titles (that should have - // been steps) from extending into the INITIAL (checkoff) column. - if (formatInfo.PlantFormat.FormatData.SectData.AdjWidthForCheckOff && MyParent != null && MyParent.MyItemInfo.IsSection && ChkOff && CheckOffWidth != 0 && itemInfo.ItemID == itemInfo.FirstSibling.ItemID) - { - SectionInfo si = MyParent.MyItemInfo.GetSectionInfo(); - if (si.HasInitials) MyParent.Width = Width + ((myTab == null) ? 0 : myTab.Width); - } - } - else if (bxIndx != null) - { - Box bx = formatInfo.PlantFormat.FormatData.BoxList[(int)bxIndx]; - if (bx == null) - { - // NOT SURE IF WE NEED TO TEST FOR THE NULLBOX FORMAT FLAG, MAYBE "bx == null" IS THE SAME THING - //if (formatInfo.MyStepSectionLayoutData.NullBox) - if (widOvrd != 0) - Width = (float)widOvrd - tabWidth; - else - Width = (float)formatInfo.MyStepSectionLayoutData.WidT - tabWidth; - } - else - { - float oldWidth = _WidthAdjustBox + (float)bx.TxtWidth - tabWidth; // add 1 to get it to wrap like 16Bit - // B2018-096 AEP 082.002CD Note Box overlapping Step Box - if (MyParent.MyItemInfo.FormatStepData != null && MyParent.MyItemInfo.FormatStepData.BoxIt) // B2018-100 not for parents that are sections // B2018-098 only adjust width if parent has Boxit turned on - { - Width = Math.Min(MyParent.Width + MyParent.XOffset - XOffset, oldWidth); - AdjustHeader = (Width - oldWidth) / 2; - } - else - Width = oldWidth; - } - } - else if ((itemInfo.IsCaution || itemInfo.IsNote) && !itemInfo.FormatStepData.UseOldTemplate) - { - float mycolT = (float)formatInfo.MyStepSectionLayoutData.ColT; - if (formatInfo.MyStepSectionLayoutData.Dev_Format) - Width = (float)formatInfo.MyStepSectionLayoutData.WidT + 1; - else if (itemInfo.IsInRNO) - { - // C2014-009: Condition/Response adjust xoffset & width - // B2020-117 add a check that there is only one Caution/Note/Warning - if (MyItemInfo.FormatStepData.CenterOneLineAdjust && MyItemInfo.FirstSibling == MyItemInfo.LastSibling) - { - int rnoOff = ToInt(formatInfo.MyStepSectionLayoutData.ColRTable, maxRNO); - if (MyItemInfo.ActiveFormat.PlantFormat.FormatData.PrintData.SpecialCaseCalvertAlarm) - { - XOffset = MyTopRNO.MyTab.XOffset + 7.2f; - Width = MyParent.Width + (MyParent.XOffset - XOffset); - } - else - { - XOffset = rnoOff + MyHighLevelParagraph.XOffset; - Width = MyParent.Width; - } - } - // B2020-117 There are muliple Cautions, Notes, or Warnings in the Calvert Alarm Contition/Response - // Need to adjust the starting positon of the bulleted tab, text and width - else if (MyItemInfo.ActiveFormat.PlantFormat.FormatData.PrintData.SpecialCaseCalvertAlarm) - { - XOffset = MyTopRNO.MyTab.XOffset + 7.2f; - this.MyTab.XOffset = XOffset; - XOffset += this.MyTab.Width; - Width = MyParent.Width + (MyParent.XOffset - XOffset); - } - else - Width = (MyParent.XOffset + MyParent.Width) - (XOffset + mycolT); - } - else - { - // B2016-269: if caution/note & not boxed, with tab adjust width based on xoffset of tab - // so text doesn't print out of right border. - // B2017-027: Added a check for column mode - we only want to do this if in single column mode - if (!MyItemInfo.MyParent.IsHigh && MyTab != null && MyTab.YOffset == YOffset && MyItemInfo.ActiveSection != null && MyItemInfo.ActiveSection.ColumnMode == 0) // C2018-003 fixed use of getting the active section - { - // B2017-xxx if this is a caution/note off of a substep in the supinfo column, need to look up for its supinfo part, not - // its HLS. - if (MyItemInfo.IsInSupInfo) - { - vlnParagraph supinfopart = this; - while (supinfopart.MyParent != null && !supinfopart.MyItemInfo.IsSupInfoPart) supinfopart = supinfopart.MyParent; - XOffset = supinfopart.XOffset; - MyTab.XOffset = XOffset - MyTab.Width - 10; - Width = supinfopart.Width; - } - else - Width = MyHighLevelParagraph.Width - MyTab.Width - (MyTab.XOffset - MyHighLevelParagraph.XOffset) - 6; - } - else - Width = (float)formatInfo.MyStepSectionLayoutData.WidT - 6 - mycolT; - } - XOffset += mycolT; // adjust caution/note text position - if (PartsLeft != null && PartsLeft.Count > 0)// adjust tab position - { - if (myTab != null && (itemInfo.IsNote || itemInfo.IsCaution)) - Width -= myTab.Width; - foreach (vlnPrintObject vpo in PartsLeft) - vpo.XOffset += mycolT; - } - } - else if (itemInfo.IsSection) - { - // B2023-074 The itemInfo we are processing is a section (number and title). Change maxRNO to zero to getting the width. - // The Width is used when printing the section number and title (when the check box on the properties page is checked) - // and is assumemed the section is a single column section (maxRNO = 0) and uses the format variable WidSTablePrint - // which holds the widths for then the section has one column, two column, or three column. - // For printing section numbers and titles like this, we always want to accomodate for lone section title text. - // So the initial width should always be set to the one column width value so that it can spane across the page. - Width = ToInt(formatInfo.MyStepSectionLayoutData.WidSTablePrint, 0); - float adjwidths = 0; - adjwidths = AdjustMetaWidth(itemInfo, formatInfo, adjwidths, false); - Width += (adjwidths + _WidthAdjust); - } - else if (MyParent == null) - { - // 72 points / inch - 7 inches (about width of page) - Width = 72 * 7; - } - else if (itemInfo.IsRNOPart && itemInfo.ActiveSection != null && itemInfo.ActiveSection.ColumnMode != 0 && itemInfo.ActiveFormat.MyStepSectionLayoutData.RNOWidthAltAll != null) // C2018-003 fixed use of getting the active section - { - // This code was added for AEP. Other code that adjusted RNO widths was only adjusting the RNO widths - // off of the HLS. AEP needed adjusting for all RNOs. - float ovrd = (float)itemInfo.ActiveFormat.MyStepSectionLayoutData.RNOWidthAltAll; - if (ovrd > 0) - Width = ovrd - tabWidth; - if (XOffset + Width > (float)itemInfo.MyDocStyle.Layout.PageWidth) - Width = (float)itemInfo.MyDocStyle.Layout.PageWidth - XOffset - 5; - } - else if (itemInfo.IsRNOPart && !((ItemInfo)itemInfo.ActiveParent).IsHigh) - { - if (itemInfo.ActiveFormat.MyStepSectionLayoutData.RNOWidthAdj != null && !((ItemInfo)itemInfo.ActiveParent).IsInRNO) - Width = MyParent.Width + float.Parse(itemInfo.ActiveFormat.MyStepSectionLayoutData.RNOWidthAdj); - else - Width = MyParent.Width; - } - else if (itemInfo.IsRtfRaw) // this needs to be before the check for 'IsTablePart' - the rtfraw may be a table part, but the size is defined by raw rtf - { - System.Drawing.Size sz = RtfRawItem.GetRtfRawSize(MyItemInfo.MyContent.Text); - Height = sz.Height; - Width = sz.Width; - Rtf = MyItemInfo.MyContent.Text; - } - else if (itemInfo.IsTablePart) - { - Width = 72 * 7; // TODO: Need to determine the Width of the Table based upon the contents - } - else if (itemInfo.MyParent.FormatStepData != null && itemInfo.MyParent.FormatStepData.Type == "TitleWithTextRight") // B2019-141: Background steps width too small - { - Width = (float)itemInfo.MyDocStyle.Layout.PageWidth - XOffset; - } - else if (itemInfo.MyParent.IsCaution || itemInfo.MyParent.IsNote) - { - if (itemInfo.ActiveFormat.MyStepSectionLayoutData.DevNoteOrCautionTabOffset != null) - Width = MyParent.MyParent.Width - tabWidth + (myTab == null ? 0 : myTab.TabAlign); - else - Width = MyParent.Width - tabWidth + (myTab == null ? 0 : myTab.TabAlign); - Width -= 72 * (itemInfo.FormatStepData.CautionOrNoteSubstepIndent == null ? 0 : (float)itemInfo.FormatStepData.CautionOrNoteSubstepIndent / (float)itemInfo.FormatStepData.Font.CPI); - } - else - { - float adjwidth = 0; - if (itemInfo.IsRNOPart && itemInfo.ActiveFormat.MyStepSectionLayoutData.RNOWidthSameAsHighParent && itemInfo.MyParent.IsHigh) - Width = adjwidth + MyParent.Width; - else if (itemInfo.MyTab != null && itemInfo.MyTab.Position != 0) - Width = adjwidth + MyParent.Width; - else if (MyParent.WidthNoLimit != 0) - Width = adjwidth + MyParent.WidthNoLimit - tabWidth + (myTab == null ? 0 : myTab.TabAlign); - else if ((itemInfo.MyDocStyle.StructureStyle.Style & E_DocStructStyle.DSS_PageListSpBckgrnd) == E_DocStructStyle.DSS_PageListSpBckgrnd) - Width = adjwidth + MyParent.Width - (MyTab != null ? MyTab.Width : 0); - else - Width = adjwidth + MyParent.Width - tabWidth + (myTab == null ? 0 : myTab.TabAlign); - } - if (itemInfo.IsSequential && itemInfo.MyParent.IsHigh && ((itemInfo.MyDocStyle.StructureStyle.Style & E_DocStructStyle.Align1StLevSubWHLS) == E_DocStructStyle.Align1StLevSubWHLS)) - Width += 10; // FIX THIS!!! - } + _ = sectContPara.ParagraphToPdf(cb, yTopMargin, yTopMargin, yBottomMargin); + if (sectContPara.SectionContinuePrinted) + yPageStart -= sectContPara.Height + SixLinesPerInch; + } + else + { + //B2025-054 Wrong Step Numbers + // when section title continued and CAS + //to avoid overwriting data + // - this will be built at a different call to vlnParagraph + if (MyPromsPrinter.PromsPrinterPrintType != PromsPrinterPrintType.Normal) + MyPromsPrinter.ShouldPrint_CAS_CTAS = false; + sectContPara = new vlnParagraph(MyParent.MyParent, cb, MyItemInfo.ActiveSection, MyParent.XOffset, 0, 0, 0, MyParent.MyItemInfo.ActiveFormat, null, (contMsg == null || contMsg == "") ? " (Continued)" : contMsg, 0, false, MyPromsPrinter); + _ = sectContPara.ParagraphToPdf(cb, yTopMargin, yTopMargin, yBottomMargin); + if (sectContPara.SectionContinuePrinted) + yPageStart -= sectContPara.Height + SixLinesPerInch; + } + } + //out of section title section - reset this back to true (default) + MyPromsPrinter.ShouldPrint_CAS_CTAS = true; - private float AdjustMetaWidth(ItemInfo itemInfo, FormatInfo formatInfo, float adjwidth, bool coadj) - { - SectData sd = formatInfo.PlantFormat.FormatData.SectData; - if (((itemInfo.MyDocStyle.StructureStyle.Style & E_DocStructStyle.DSS_SameXOffSubsections) == E_DocStructStyle.DSS_SameXOffSubsections)) - { - // don't adjust the width if there already was an adjustment for checkoffs - for VCB only (F2016-039) - VCB no longer a customer - // C2019-040 use format flag to adjust the width (was already don for checkoffs) - previously we check if the format file name starts with VCB (VCB no longer a customer) - if (!(itemInfo.ActiveFormat.PlantFormat.FormatData.ProcData.CheckOffData.CheckoffsWithoutHeader && coadj)) - adjwidth = MyTab != null ? -MyTab.Width : 0; - } - else if (sd.UseMetaSections) - { - if (sd.StepSectionData.StepSectionLayoutData.TieTabToLevel) - { - if (ShowSectionTitles - && !itemInfo.MyDocStyle.CancelSectTitle - && !(itemInfo.MyDocStyle.SpecialStepsFoldout && itemInfo.MyDocStyle.UseColSByLevel)) - { - int indxLevel = itemInfo.PrintLevel + itemInfo.CurrentSectionLevel(); - //F2022-023 Used the SubSectAndHighSameLevel (BNPP1New format) flag to get the proper level if we have sub-sections so that we get the proper WidSAdjByLevel value - if (formatInfo.PlantFormat.FormatData.SectData.StepSectionData.StepSectionLayoutData.SubSectAndHighSameLevel && !MyItemInfo.MyActiveSection.MyParent.IsProcedure) indxLevel++; - adjwidth += formatInfo.PlantFormat.FormatData.SectData.MetaSectionList[indxLevel % formatInfo.PlantFormat.FormatData.SectData.MetaSectionList.MaxIndex].WidSAdjByLevel ?? 0; ; - float colsbylevel = (float)formatInfo.PlantFormat.FormatData.SectData.MetaSectionList[indxLevel % formatInfo.PlantFormat.FormatData.SectData.MetaSectionList.MaxIndex].ColSByLevel; - float seclvlindent = colsbylevel - (float)formatInfo.PlantFormat.FormatData.SectData.StepSectionData.StepSectionLayoutData.ColS; - adjwidth -= seclvlindent; - if (itemInfo.IsStep) adjwidth -= AdjustForSectionLevelTab(); - if (itemInfo.IsSection && itemInfo.ActiveFormat.PlantFormat.FormatData.PrintData.WCNTraining) - adjwidth -= (float)((itemInfo.MyTab.CleanText.Trim().Length * 72) / itemInfo.ActiveFormat.PlantFormat.FormatData.SectData.SectionHeader.Font.CPI); - } - } - else - { - if (formatInfo.PlantFormat.FormatData.SectData.MetaSectionList.MaxIndex > 0) - adjwidth += (float)formatInfo.PlantFormat.FormatData.SectData.MetaSectionList[itemInfo.PrintLevel % formatInfo.PlantFormat.FormatData.SectData.MetaSectionList.MaxIndex].ColSByLevel; - } - } - return adjwidth; - } + // see if this hls has footnotes, add to the footnote datastructure for processing at end of page. + if (MyItemInfo.IsHigh && MyPageHelper.NotesToFootNotesHLS.ContainsKey(MyItemInfo.ItemID)) AddFootNote(cb); - // for Component Table, don't increment yoff unless last item in table that HAS data associated - // with it (there may be empty cells at end). - public bool UseTemplateKeepOnCurLine(ItemInfo itemInfo) - { - if (!itemInfo.IsStep || !itemInfo.MyDocStyle.ComponentList) return false; - if (!itemInfo.ActiveFormat.PlantFormat.FormatData.PrintData.SpecialCaseCalvert - && itemInfo.MyHLS.FormatStepData.UseOldTemplate) return true; - return false; - } - private bool UseTemplateWidthOrXOff(ItemInfo itemInfo) - { - if (!itemInfo.IsStep) return false; - if (itemInfo.MyHLS == null) return false; - if (itemInfo.MyHLS.FormatStepData.UseSmartTemplate || (itemInfo.MyDocStyle.ComponentList && itemInfo.MyHLS.FormatStepData.UseOldTemplate)) - { - ItemInfo useForTemplate = itemInfo.IsHigh ? itemInfo : itemInfo.MyParent; - int topIndx = useForTemplate.GetSmartTemplateTopLevelIndx(); - int tpIndx = -1; - if (itemInfo.ActiveFormat.PlantFormat.FormatData.PrintData.SpecialCaseCalvertAlarm) - { - if (itemInfo.IsCaution1) return false; - else tpIndx = useForTemplate.GetSmartTemplateIndex(topIndx, itemInfo.MyContent.Text); - } - else - tpIndx = useForTemplate.GetSmartTemplateIndex(topIndx, (int)useForTemplate.MyContent.Type); - if (tpIndx > -1) return true; - } - return false; - } - private float GetWidthOrStartFromTemplate(ItemInfo itemInfo, FormatInfo formatInfo, bool bGetWidth) - { - int topIndx = itemInfo.GetSmartTemplateTopLevelIndx(); - int tmplIndx = 0; - if (itemInfo.MyDocStyle.ComponentList && !itemInfo.IsHigh) - { - // The following was added so that the Calvert Alarms sequentials under the CONDITION/RESPONSE would be - // printed as 2 column (data within the template definition set the columns to 2) - if (itemInfo.ActiveFormat.PlantFormat.FormatData.PrintData.SpecialCaseCalvertAlarm) - { - if (itemInfo.IsSequential && itemInfo.MyParent.TemplateIndex > 0) - { - if (bGetWidth && itemInfo.MyParent.ColumnMode == 1) // 2 columns - return (ToInt(formatInfo.MyStepSectionLayoutData.WidSTablePrint, itemInfo.ColumnMode) - MyTab.Width); - } - tmplIndx = itemInfo.TemplateIndex; - if (tmplIndx == -1) return 0; - } - else - { - // The ComponentTable format (FNP component table as one example), uses a template - // where the items in the template below the HLS are all paragraphs (the intermediate steps - // are TitleWithTextRight). Find the ordinal of in this list to get the index. Use the ordinal - // as an offset from the HLS's index into the template. - tmplIndx = itemInfo.MyParent.Ordinal + topIndx; - if (tmplIndx < 0 || tmplIndx > formatInfo.PlantFormat.FormatData.Templates.Count - 1) return 0; - } - } - else - { - tmplIndx = itemInfo.GetSmartTemplateIndex(topIndx, (int)itemInfo.MyContent.Type); - if (tmplIndx == -1) return 0; - } - // Calvert Alarms' template defines number of columns & their width. - if (bGetWidth && formatInfo.PlantFormat.FormatData.Templates[tmplIndx].width == 0) - { - int nocol = formatInfo.PlantFormat.FormatData.Templates[tmplIndx].nocolm == 0 ? 0 : formatInfo.PlantFormat.FormatData.Templates[tmplIndx].nocolm - 1; - return ToInt(formatInfo.MyStepSectionLayoutData.WidSTablePrint, nocol); - } - int ncol = bGetWidth ? formatInfo.PlantFormat.FormatData.Templates[tmplIndx].width : formatInfo.PlantFormat.FormatData.Templates[tmplIndx].start; - // now convert to the units for this format. The template width data is in number of columns. - return (ncol * itemInfo.FormatStepData.Font.CharsToTwips) + (bGetWidth ? 1 : 0); // + 1 is slight adjustment so column doesn't wrap - } - private float AdjustForSectionLevelTab() - { - string sectTab = MyItemInfo.ActiveSection.MyTab.CleanText.TrimEnd(); - if (sectTab.EndsWith(".0")) return 0; - string myTab = MyItemInfo.MyTab.CleanText; - // -1 below code, +1 for '.' and -2 for standard wid of tab - // standard wid of this tab is 2 (ex: '1.') - // so adjust width if longer than normal - return (float)(sectTab.Length - 1) * 72 / (float)MyItemInfo.FormatStepData.Font.CPI; - } - private bool HasCheckOffHeading(ItemInfo itemInfo, FormatInfo formatInfo) - { - if (formatInfo.PlantFormat.FormatData.ProcData.CheckOffData.CheckOffHeaderList.MaxIndex != 0) - { - // does this section have a check off heading? - SectionConfig sc = (itemInfo.ActiveSection != null) ? itemInfo.MyActiveSection.MyConfig as SectionConfig : null; // C2018-003 fixed use of getting the active section - if (sc != null && sc.Section_CheckoffHeaderSelection > 0) return true; - } - if (formatInfo.PlantFormat.FormatData.ProcData.CheckOffData.CheckOffHeaderInPagelist) return true; - return false; - } - } + yPageStart = ChildrenAbove.ToPdf(cb, yPageStart, ref yTopMargin, ref yBottomMargin); + // B2017-122: if doing supinfo pagebreaks, if there should be a break on a step (not hls) that has a caution/note do it here: + if (!MyItemInfo.IsHigh && ChildrenAbove != null && ChildrenAbove.Count > 0 && MyPromsPrinter.SupInfoPrintType == E_SupInfoPrintType.DoPageBreaks && MyPromsPrinter.NeedSupInfoBreak && MyItemInfo.SupInfos != null && MyItemInfo.SupInfos.Count > 0) + { + // if this has a caution/note with supinfo, that is id that needs to go in pagination list, unless it is in there. + int aboveSupinfoId = ChildrenAboveHaveSupInfo(); + if (supInfoSect != null) + { + if (supInfoSect.StepSectPageBreaksForSupInfo.Contains(aboveSupinfoId)) aboveSupinfoId = -1; + supInfoSect.StepSectPageBreaksForSupInfo.Add(MyItemInfo.SupInfos[0].ItemID); + } + MyPromsPrinter.NeedSupInfoBreak = false; + } + yPageStart = ChildrenLeft.ToPdf(cb, yPageStart, ref yTopMargin, ref yBottomMargin); - /// - /// First order by stepLevel, then within a stepLevel, order by descending yLocation on page. - /// Want to find maximum y value that fits on page, i.e. put the most on page that can - /// fit which is defined by the largest yLocation - /// - public class StepLevelList : SortedDictionary> - { - public StepLevelList() - : base() - { - } - public void Add(int stepLevel, float yLocation, vlnParagraph para) - { - if (stepLevel == 0) return; - if (!this.ContainsKey(stepLevel)) - this.Add(stepLevel, new SortedDictionary()); - // using a negative for yLocation so that its in descending order: - // B2020-112: Make various adjustments to location if there are format flags used - // B2020-116: Only make the 112 change for Calvert - // B2020-151: check for SpecialCaseCalvertPagination flag instead of SpecialCase Calvert flag so only EOPs/AOPs are affected - float adjust = 0; - if (para.MyItemInfo.ActiveFormat.PlantFormat.FormatData.PrintData.SpecialCaseCalvertPagination) - adjust = para.YVeryTop - para.YTop; - //if (para.MyItemInfo.MyParent.IsHigh && (para.ChildrenAbove == null || para.ChildrenAbove.Count == 0)) - //{ - // //Console.WriteLine("Adjust Add extra Line (flag) = '{0}'", para); - // adjust -= para.AdjustForXBlankW1stLevSub; - //} - //else if (para.MyParent.MyItemInfo.IsHigh && (para.MyParent.ChildrenAbove != null && para.MyParent.ChildrenAbove.Count > 0) - // && para.MyParent.ChildrenAbove[0] == para) - //{ - // //Console.WriteLine("Adjust Add extra Line (flag) = '{0}'", para); - // adjust -= para.MyParent.AdjustForXBlankW1stLevSub; - //} - //if (para.AdjustForMatchUpRNO != 0 && (para.ChildrenAbove == null || para.ChildrenAbove.Count == 0)) - // adjust -= para.AdjustForMatchUpRNO; - //else if (para.MyParent.AdjustForMatchUpRNO != 0 && (para.MyParent.ChildrenAbove != null && para.MyParent.ChildrenAbove.Count > 0) - // && para.MyParent.ChildrenAbove[0] == para) - // adjust -= para.MyParent.AdjustForMatchUpRNO; + // Handle the PageBreakOnStep flag for a HLS. This will put out the page break right before + // a HLS. One example of this use is for backgrounds (CALBCK). + // 'this' below is a highlevel step, and the only time that ParaBreaks[0] will == 'this' is + // when the PageBreakOnStep flag is true. + if (MyPageHelper.ParaBreaks != null && MyPageHelper.ParaBreaks.Count > 0 && + MyPageHelper.ParaBreaks[0] == this && this.MyItemInfo.FormatStepData.PageBreakOnStep)// B2017-224 Top Continue Messages Add check for PageBreakOnStep 9/26/2017 Ginna SAMGs SAG-8 Step 4 + { + ShowPageBreak(1, CheckForCompression("PageBreakOnStep/Caution/Note HLS"), "Yes", YTop - YBottomMost, yTopMargin - yBottomMargin, yTopMargin - yBottomMargin, false); + YTopMost = OutputOtherPageSteps(cb, YTopMost, yPageStart, yTopMargin, yBottomMargin); + MyPageHelper.BottomMessage.Clear(); + MyPageHelper.TopMessage = null; + MyPromsPrinter.NewPage(); + if (CompressPartOfStep) + { + MyPageHelper.YMultiplier = _SevenLinesPerInch / SixLinesPerInch; + CompressPartOfStep = false; + } + MyPageHelper.ParaBreaks.RemoveAt(0); + yPageStart = yTopMargin + YTop; + } + // The following sets the beginning/ending y location for the lines around the + // CONDITION/RESPONSE text for Calvert Alarm format + if (MyItemInfo.ActiveFormat.PlantFormat.FormatData.PrintData.SpecialCaseCalvertAlarm) + { + int tindx = MyItemInfo.TemplateIndex; + if (tindx >= 0) + { + // save this position to start drawing the alarm box lines around substeps: + if (MyItemInfo.ActiveFormat.PlantFormat.FormatData.Templates[MyItemInfo.TemplateIndex].row > 0) + MyPageHelper.AlarmYoffStart = CalculateYOffset(yPageStart, yTopMargin) - SixLinesPerInch; + else if (MyPageHelper.AlarmYoffStart > 0 && MyPageHelper.AlarmYoffEnd == 0) + MyPageHelper.AlarmYoffEnd = CalculateYOffset(yPageStart, yTopMargin) + (2 * SixLinesPerInch); + } + } + int profileDepth2 = ProfileTimer.Push(">>>> vlnParagraph.ParagraphToPdf"); + // B2020-162 - SpecialCaseCalvert flag affect single column procedures, use SpecialCaseCalvertPagination for Two Column procedures instead + if (MyItemInfo.IsSubsection && MyItemInfo.ActiveFormat.PlantFormat.FormatData.PrintData.SpecialCaseCalvertPagination) CalvertPrintedSubSectTitle = true; // B2020-123 + yPageStart = ParagraphToPdf(cb, yPageStart, yTopMargin, yBottomMargin); + ProfileTimer.Pop(profileDepth2); + // If the yPageStart changes by more than a small amount (pagination) in the RNO (right column), then update + // yPageStart for the AER (left column). + float yPageStartRNO = ChildrenRight.ToPdf(cb, yPageStart, ref yTopMargin, ref yBottomMargin); + if (yPageStartRNO - yPageStart > 24) // 24 is two lines + yPageStart = yPageStartRNO; + yPageStart = ChildrenBelow.ToPdf(cb, yPageStart, ref yTopMargin, ref yBottomMargin); - if (!this[stepLevel].ContainsKey(-(yLocation + adjust))) - this[stepLevel].Add(-(yLocation + adjust), para); - } - } - public class ParagraphLocations : List - { - public ParagraphLocations() - : base() - { - } - public void Add(vlnParagraph myParagraph, float yTopMost) - { - ParagraphLocation foundOverlap = FindOverlap(myParagraph); - if (foundOverlap == null) - { - this.Add(new ParagraphLocation(yTopMost, myParagraph)); - return; - } - ParagraphLocation doubleOverlap = FindOverlap(foundOverlap); - while (doubleOverlap != null) - { - doubleOverlap.Merge(foundOverlap); - this.Remove(foundOverlap); - foundOverlap = doubleOverlap; - doubleOverlap = FindOverlap(foundOverlap); - } - } + if (MyItemInfo.IsHigh && MyItemInfo.NextItem == null) // last hls, add the 'end' message, if there is one + { + docstyle = MyItemInfo.MyDocStyle; + // if the EndForSingle format flag is set to false, then we do not print an End message if the section + // is a single column section. + //bool _skipEndMessage = MyPageHelper.MySection.SectionConfig.Section_ColumnMode == SectionConfig.SectionColumnMode.One && !MyItemInfo.ActiveFormat.MyStepSectionLayoutData.EndForSingle; + // C2018-003 fixed use of getting the active section + // B2017-201 if si is null we need to get it via the ItemID + if (!(MyItemInfo.ActiveSection is SectionInfo si)) + si = SectionInfo.Get(MyItemInfo.MyActiveSection.ItemID); // MyActiveSection does not try to resolve anything - ActiveSection is call above and will resolve and set MyActiveSection + bool _skipEndMessage = (si == null || si.SectionConfig.Section_ColumnMode == SectionConfig.SectionColumnMode.One) && !MyItemInfo.ActiveFormat.MyStepSectionLayoutData.EndForSingle; + bool _lastSect = true; + if (si != null && si.MyActiveParent.IsSection) // is this meta/subsection. Only put end message out on last section + { + ItemInfo mysect = si as ItemInfo; + if (mysect.NextItem != null && !docstyle.End.EndMessageOnEachSubSection) _lastSect = false; + } + string myMsg = docstyle.End?.FixedMessage; + if (myMsg != null && !_skipEndMessage && _lastSect) + { + // If the flag is 0 or 1, just put the end message out right below this vlnParagraph: + float msg_yLocation = CalculateYLocation(yPageStart - YBottomMost, yTopMargin); + // use the 'flag' to position the message. + if (docstyle.End.Flag > 2) // >2 position at an absolute location defined by docstyle.End.Flag. + { + msg_yLocation = yTopMargin - (float)(docstyle.End.Flag * SixLinesPerInch); + } + float adjMsgY = 0; + if (docstyle.End.Flag < 0) // Adjust this many lines down the page. + { + adjMsgY = (float)(-docstyle.End.Flag * SixLinesPerInch); + if (msg_yLocation - adjMsgY > docstyle.Layout.FooterLength) msg_yLocation -= adjMsgY; + } + if (myMsg.Contains("{Section Number}")) myMsg = myMsg.Replace("{Section Number}", MyItemInfo.ActiveSection.DisplayNumber); + if (myMsg.Contains("%-12s")) + myMsg = myMsg.Replace("%-12s", MyItemInfo.MyProcedure.DisplayNumber.PadRight(12)); + if (yTopMargin - docstyle.Layout.PageLength >= msg_yLocation && docstyle.End.Message != null && docstyle.End.Message != "" && docstyle.End.Flag <= 2) + { + // B2018-037: adjust location of end message to bottom of page if it is too low. This occurs when data just doesn't + // fit on the page, but will locate end message at a more reasonable location. + msg_yLocation = (float)yTopMargin - (float)docstyle.Layout.PageLength; + _MyLog.WarnFormat("End Message LOW on page: {0}, {1}, {2}, Page {3}", msg_yLocation, MyItemInfo.ItemID, MyItemInfo.ShortPath, MyPageHelper.CurrentPageNumber + 1); + } + float xpos; + if ((docstyle.End.Margin ?? 0) != 0) + { + xpos = (float)docstyle.Layout.LeftMargin + (float)docstyle.End.Margin; + MyPageHelper.BottomMessage.Add(new vlnText(cb, this, myMsg, myMsg, xpos, msg_yLocation, docstyle.End.Font)); + } + else + { // Center the bottom message + float wtpm = (float)docstyle.Layout.PageWidth - (float)docstyle.Layout.LeftMargin; + //B2022-126 was using the wrong font definition to calaculate the centering position + // ** B2023-099 commented out and restored the previous calculation. This caused problems centering the END message in Ginna + // their END message prints with the Prestige Elite font but he centering calc uses Courier New + //xpos = XOffsetBox + (float)docstyle.Layout.LeftMargin + (wtpm - (myMsg.Length * docstyle.End.Font.CharsToTwips)) / 2; + xpos = XOffsetBox + (float)docstyle.Layout.LeftMargin + (wtpm - (myMsg.Length * MyItemInfo.FormatStepData.Font.CharsToTwips)) / 2; + xpos = Math.Max(xpos, XOffsetBox + (float)docstyle.Layout.LeftMargin); + vlnText vttmp = new vlnText(cb, this, myMsg, myMsg, xpos, msg_yLocation, docstyle.End.Font); + MyPageHelper.BottomMessage.Add(vttmp); + MyPageHelper.MyGaps.Add(new Gap(msg_yLocation, msg_yLocation - vttmp.Height)); + yPageStart -= (vttmp.Height + adjMsgY); + } + } + } + if (yLocalypagestart != yPageStart) DebugText.WriteLine("ToPdf-yPagestartDiff:{0},{1},{2},{3}", MyPageHelper.MyPdfContentByte.PdfWriter.CurrentPageNumber, MyItemInfo.ItemID, yLocalypagestart, yPageStart); - private ParagraphLocation FindOverlap(vlnParagraph myParagraph) - { - foreach (ParagraphLocation paraLoc in this) - if (paraLoc.Overlap(myParagraph)) - return paraLoc; - return null; - } - private ParagraphLocation FindOverlap(ParagraphLocation myParaLoc) - { - foreach (ParagraphLocation paraLoc in this) - if (paraLoc != myParaLoc && paraLoc.Overlap(myParaLoc)) - return paraLoc; - return null; - } - internal StepLevelList BuildStepLevelList(bool KeepStepsOnPage) - { - StepLevelList myList = new StepLevelList(); - foreach (ParagraphLocation paraLoc in this) - { - int level = paraLoc.StepLevel; - if (KeepStepsOnPage) - { - // B2020-116: change from checking for type 20001 to looking for a non-high sequential since some - // step types were sequential but not 20001 - bool keepBullettedTogether = paraLoc.MyParagraph.MyItemInfo.IsSubStep; - if (!paraLoc.MyParagraph.MyItemInfo.IsHigh) - { - bool AlarmPagination = paraLoc.MyParagraph.MyItemInfo.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.StepSectionLayoutData.AlarmPagination; - if (paraLoc.MyParagraph.MyItemInfo.IsSequential) - { - if (DontBreakHere(paraLoc)) - //if (paraLoc.MyParagraph.MyItemInfo.MyPrevious == null) // First substep - level = 0; - else - level = 1; // AlarmPagination?3:1; // B2023-091: backout B2023-088 make it easier to break on a sequential for alarms - } - else if (AlarmPagination && paraLoc.MyParagraph.MyItemInfo.IsSubStep) - { - // make it harder to break on first caution or note & within a list if doing Alarm Pagination: - vlnParagraph myPara = paraLoc.MyParagraph; - if ((myPara.MyItemInfo.IsCaution || myPara.MyItemInfo.IsNote) && myPara.MyItemInfo.MyPrevious == null) level = 1; - else if (myPara.MyItemInfo.MyPrevious != null || myPara.MyItemInfo.NextItem != null) level = 2; - } - } - } - // For B2015-014, some migrated data for background documents had the TitleWithTextBelow with associated paragraphs - // as siblings rather than children. Pagination was sometimes putting the TitleWithTextBelow on one page and the - // paragraphs on next. The following code checks thse types, if in enhanced documents but not the Short Form Deviations. - if (paraLoc.MyParagraph.MyItemInfo.ActiveFormat != null - && ((paraLoc.MyParagraph.MyItemInfo.ActiveFormat.PlantFormat.FormatData.PurchaseOptions.Value & E_PurchaseOptions.EnhancedBackgrounds) == E_PurchaseOptions.EnhancedBackgrounds) - || (((paraLoc.MyParagraph.MyItemInfo.ActiveFormat.PlantFormat.FormatData.PurchaseOptions.Value & E_PurchaseOptions.EnhancedDeviations) == E_PurchaseOptions.EnhancedDeviations) - && paraLoc.MyParagraph.MyItemInfo.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.StepSectionLayoutData.EnhancedShortFormDev)) - { - if (!paraLoc.MyParagraph.MyItemInfo.IsTitle && paraLoc.MyParagraph.MyItemInfo.MyPrevious != null && paraLoc.MyParagraph.MyItemInfo.MyPrevious.FormatStepData.Type == "TitleWithTextBelow") level = 0; - } - paraLoc.MyParagraph.levelForPagination = level; - myList.Add(level, paraLoc.YTop, paraLoc.MyParagraph); - } - return myList; - } - private bool DontBreakHere(ParagraphLocation paraLoc) - { - if (paraLoc.MyParagraph.MyItemInfo.MyPrevious == null) // First substep - return true; - vlnParagraph myPara = paraLoc.MyParagraph; - while (!myPara.MyItemInfo.IsHigh) - { - if (myPara.MyItemInfo.IsCaution) return true; - if (myPara.MyItemInfo.IsNote) return true; - myPara = myPara.MyParent; - } - return false; - } - } - public class ParagraphLocation - { - public override string ToString() - { - return string.Format("{0} {1} - {2} - '{3}'", this.MyParagraph.MyItemInfo.ItemID, this.StepLevel, this.YTop, this.MyParagraph.MyItemInfo.ShortPath); - } - private float _YTop; - public float YTop - { - get { return _YTop; } - set { _YTop = value; } - } - private float _YBottom; - public float YBottom - { - get { return _YBottom; } - set { _YBottom = value; } - } - private int _StepLevel; - public int StepLevel - { - get { return _StepLevel; } - set { - //if (MyParagraph.MyItemInfo.InList(97960,84472,91010)) - // Console.WriteLine("stop"); - _StepLevel = value; } - } - private vlnParagraph _MyParagraph; - public vlnParagraph MyParagraph - { - get { return _MyParagraph; } - set { _MyParagraph = value; } - } - public ParagraphLocation(float yTopMost, vlnParagraph myParagraph) - { - MyParagraph = myParagraph; - YTop = myParagraph.YVeryTop - yTopMost; - YBottom = myParagraph.YBottom - yTopMost; - StepLevel = myParagraph.MyItemInfo.StepLevel; - // B2020-115 Set a very large figure's Step Level so that pagination will happen prior to the figure. - if (myParagraph.MyItemInfo.IsFigure && myParagraph.MyParent.Height + myParagraph.Height > vlnParagraph.hMax) - { - StepLevel = 1;// Set figure as a guaranteed break location - } - } - public bool Overlap(vlnParagraph otherParagraph) - { - if (Between(otherParagraph.YTop, YTop, YBottom)) return true; - if (Between(otherParagraph.YBottom, YTop, YBottom)) return true; - if (Between(YTop, otherParagraph.YVeryTop, otherParagraph.YBottom)) return true; - if (Between(YBottom, otherParagraph.YVeryTop, otherParagraph.YBottom)) return true; - return false; - } - public static bool Between(float x, float lower, float higher) - { return x > lower && x < higher; } - public bool Overlap(ParagraphLocation otherParagraphLocation) - { - if (Between(otherParagraphLocation.YTop, YTop, YBottom)) return true; // The top is within the other - if (Between(otherParagraphLocation.YBottom, YTop, YBottom)) return true; // The bottom is within the other - if (Between(YTop, otherParagraphLocation.YTop, otherParagraphLocation.YBottom)) return true; // the other top is within this one - if (Between(YBottom, otherParagraphLocation.YTop, otherParagraphLocation.YBottom)) return true;// I believe this is unnecessary - return false; - } - public void Merge(vlnParagraph otherParagraph) - { - if (StepLevel < otherParagraph.MyItemInfo.StepLevel) MyParagraph = otherParagraph; - YTop = Math.Min(YTop, otherParagraph.YVeryTop); - YBottom = Math.Max(YBottom, otherParagraph.YBottom); - StepLevel = Math.Max(StepLevel, otherParagraph.MyItemInfo.StepLevel); - } - public void Merge(ParagraphLocation otherParagraphLocation) - { - if (StepLevel < otherParagraphLocation.StepLevel) MyParagraph = otherParagraphLocation.MyParagraph; - YTop = Math.Min(YTop, otherParagraphLocation.YTop); - YBottom = Math.Max(YBottom, otherParagraphLocation.YBottom); - StepLevel = Math.Max(StepLevel, otherParagraphLocation.StepLevel); - } - } + // if doing NotesToFootnotes (Calvert valve list format), get the bottom location so that + // footnotes will be printed after last text on page. This is used for the end of the section. + // Pages that broke within pagination logic above had footnote location set during pagination code. + if (MyPageHelper.NotesToFootNotes != null && MyPageHelper.NotesToFootNotes.Count > 0) + MyPageHelper.NotesToFootNotesYoffset = CalculateYLocation(yPageStart - YBottomMost, yTopMargin); + ProfileTimer.Pop(profileDepth); + return yPageStart; + } + // B2020-128: If compression flag is on RNO, see if there is an AER to the left and do the 7lpi multiplier + private bool CompressRnoWithAerToTheLeft() + { + if (!MyItemInfo.IsInRNO) return false; + foreach (vlnParagraph vPara in MyPageHelper.MyParagraphs.Values) + { + if (!vPara.Processed) + { + if (vPara.YOffset <= YOffset && vPara.CompressPartOfStep) return true; + } + } + return false; + } + private bool IsPrintedStepItemForSupInfo() + { + bool printedMySectTitle = true; + if (MyItemInfo.IsSection) + { + // see if the section title is printed. + SectionConfig sch = (MyItemInfo.ActiveSection != null) ? MyItemInfo.ActiveSection.MyConfig as SectionConfig : null; // C2018-003 fixed use of getting the active section + printedMySectTitle = (sch == null || sch.Section_PrintHdr == "Y") || !(MyItemInfo.ActiveSection as SectionInfo).HasSupInfoSteps; + printedMySectTitle &= (ShowSectionTitles && !MyItemInfo.MyDocStyle.CancelSectTitle); + } + return printedMySectTitle; + } + private int ChildrenAboveHaveSupInfo() + { + if (ChildrenAbove == null || ChildrenAbove.Count < 1) return -1; + foreach (vlnParagraph p in ChildrenAbove) + { + if (p.MyItemInfo.SupInfos != null && p.MyItemInfo.SupInfos.Count > 0) return p.MyItemInfo.SupInfos[0].ItemID; + } + return -1; + } + // Find the step that has supplemental information from this step down page until a preferred page break is found + // or a regular page break. + // It is used to determine whether there is a supinfo facing page or if there should be a blank page. + private bool FoundStepPageBreak = false; + private int GetIdThatHasSupInfoItems(ItemInfo ii, int startid) + { + if (ii == null) return -1; + FoundStepPageBreak = false; + // if this item has supinfo, return its id + if (ii.SupInfos != null && ii.SupInfos.Count > 0) return ii.SupInfos[0].ItemID; + + // see if any substeps of this item have supinfo, and if so, return the substep's id + int id = GetSubThatHasSupInfoItems(ii, startid); + if (id != -1) return id; + if (FoundStepPageBreak) return -1; // Set in GetSubThatHasSupInfoItems + + // Now go to the next item, check if it or any of its substeps have supinfo, and if so, return the id + ItemInfo sib = ii.NextItem; + id = GetIdThatHasSupInfoItemsSibNext(sib, startid); + if (id != -1) return id; + if (FoundStepPageBreak) return -1; // Set in GetIdThatHasSupInfoItemsSibNext + + // B2017-122: if this is a note or caution off substep, check if substep has supinfo: + if ((ii.IsNote || ii.IsCaution) && !ii.MyParent.IsHigh) + { + if (ii.MyParent.SupInfos != null && ii.MyParent.SupInfos.Count > 0) return ii.MyParent.SupInfos[0].ItemID; + int sbfromNC = GetSubThatHasSupInfoItems(ii.MyParent, startid); + if (sbfromNC != -1) return sbfromNC; + if (FoundStepPageBreak) return -1; // Set in GetSubThatHasSupInfoItems + } + + // Go to the parent, and find its next and check if it or any of its substeps or next steps or any of their substeps have supinfo, + // and if so, return the id. + ItemInfo par = ii.MyParent; + ItemInfo parsnxt = par.GetNext(); + //B2023-068 check if we are already at the section or procedure level + if (!par.IsSection && !par.IsProcedure && parsnxt != null) + { + par = parsnxt; + while (par != null && !par.IsSection) + { + id = GetIdThatHasSupInfoItemsSibNext(par, startid); + if (id != -1) return id; + par = par.MyParent; + ItemInfo sparsnxt = par.GetNext(); + if (!par.IsSection && sparsnxt != null) par = sparsnxt; + else return -1; + } + } + return -1; + } + + private int GetIdThatHasSupInfoItemsSibNext(ItemInfo ii, int startid) + { + while (ii != null) + { + // B2017-193 Error occured when a section in the MRU was being loaded as an iteminfo + if (!(ii.ActiveSection is SectionInfo supInfoSect)) supInfoSect = SectionInfo.Get(ii.ActiveSection.ItemID); + // if there is a pagebreak on this step section step, quit looking for supinfos. The + // break has to occur here. + if (supInfoSect.StepSectPageBreaks.Contains(ii.ItemID)) + { + FoundStepPageBreak = true; + return -1; + } + if (ii.SupInfos != null && ii.SupInfos.Count > 0) + { + // check if this is in the list of page breaks for supinfos, if not it may have one of its cautions/notes rather than its id: + if (!supInfoSect.StepSectPageBreaksForSupInfo.Contains(ii.SupInfos[0].ItemID)) + { + if (ii.Cautions != null) + { + foreach (ItemInfo caution in ii.Cautions) + if (caution.SupInfos != null && caution.SupInfos.Count > 0 && supInfoSect.StepSectPageBreaksForSupInfo.Contains(caution.SupInfos[0].ItemID)) return caution.SupInfos[0].ItemID; + } + if (ii.Notes != null) + { + foreach (ItemInfo note in ii.Notes) + if (note.SupInfos != null && note.SupInfos.Count > 0 && supInfoSect.StepSectPageBreaksForSupInfo.Contains(note.SupInfos[0].ItemID)) return note.SupInfos[0].ItemID; + } + } + return ii.SupInfos[0].ItemID; + } + int id = GetSubThatHasSupInfoItems(ii, startid); + if (id == -2) return -1; + if (id != -1) return id; + ii = ii.NextItem; + } + return -1; + } + private int GetSubThatHasSupInfoItems(ItemInfo ii, int startid) + { + if (ii.MyContent.ContentParts != null) + { + if (!(ii.ActiveSection is SectionInfo supInfoSect)) supInfoSect = SectionInfo.Get(ii.ActiveSection.ItemID); + foreach (PartInfo pi in ii.MyContent.ContentParts) + { + if ((E_FromType)pi.FromType != E_FromType.SupInfo) + { + foreach (ItemInfo iic in pi.MyItems) + { + // B2018-021: added code to be sure that check isn't on current step, i.e. startid != iic.ItemID & + // flag when the following page break is found so the next supplemental information page isn't printed + // on a step where the step is on the following page from the one we are looking for. + if (startid != iic.ItemID) + { + if (supInfoSect.StepSectPageBreaks.Contains(iic.ItemID)) + { + FoundStepPageBreak = true; + return -1; + } + if (iic.SupInfos != null && iic.SupInfos.Count > 0) return iic.SupInfos[0].ItemID; + int id = GetSubThatHasSupInfoItems(iic, startid); + if (id != -1) return id; + } + } + } + } + } + return -1; + } + private float GetSectionTopMessageSize() + { + // B2016-134: Account for wcntraining section top continue if item has container + float retval = 0; + if (MyItemInfo.MyDocStyle.SectTop != null && MyItemInfo.MyDocStyle.SectTop.Message != null) + { + if (PartsContainer != null && PartsContainer.Count > 0) retval = SixLinesPerInch * 1; + } + return retval; + } + // For WCNTRN (Wolf Creek Training format): the following prints the section number (and continued, if + // section is continued from previous page) in the Responsibility column. + private bool SectionTopMessage(PdfContentByte cb, float yTopMargin) + { + if (MyPageHelper.CreatingSupInfoPage) + { + float scttopWidths = "Supplemental Information".Length * 6; + float ctrs = ((float)MyItemInfo.MyDocStyle.Layout.PageWidth - (float)MyItemInfo.MyDocStyle.Layout.LeftMargin) / 2; + float sctcntrXs = (float)MyItemInfo.MyDocStyle.Layout.LeftMargin + ctrs - (scttopWidths / 2); + VE_Font vf = MyItemInfo.MyDocStyle.Font; + // F2017-039: The following null check was added in case the format's doc style does not have a font defined: + if (vf == null || vf.Style == null || vf.Family == null || vf.Size == null || vf.CPI == null) vf = MyItemInfo.ActiveFormat.PlantFormat.FormatData.Font; + E_Style sty = E_Style.Underline; + if (vf != null && vf.Style != null) sty = (E_Style)(vf.Style | E_Style.Underline); + vf = new VE_Font(vf.Family, (int)vf.Size, sty, (float)vf.CPI); + MyPageHelper.TopMessage = new vlnText(cb, this, "Supplemental Information", "Supplemental Information", sctcntrXs, yTopMargin + 0.1F, vf); + return true; + } + bool addextra = false; + if (MyItemInfo.MyDocStyle.SectTop != null && MyItemInfo.MyDocStyle.SectTop.Message != null) + { + float sectMsgY; + if (PartsContainer == null || PartsContainer.Count == 0) + sectMsgY = CalculateYLocation(YTop, yTopMargin); + else + { + // B2016-134: Account for section top continue if item has container, i.e. move section top continue message above the container + sectMsgY = CalculateYLocation(YTopMost - (SixLinesPerInch * 3), yTopMargin); // 3 is # of lines: header, box, blank line moving up page + addextra = true; + } + VE_Font sctMsgFont = MyItemInfo.MyDocStyle.SectTop.Font; + string scttop; + if (!MyItemInfo.IsStepSection && MyItemInfo.MyDocStyle.SectTop.Message != null) + scttop = MyItemInfo.MyDocStyle.SectTop.Message.Replace("%s", (MyItemInfo.ActiveSection as SectionInfo).DisplayNumber); + else + scttop = (MyItemInfo as SectionInfo).DisplayNumber; + float scttopWidth = scttop.Length * 6; + float ctr = (float)MyItemInfo.MyDocStyle.SectTop.Margin; + float sctcntrX = (float)MyItemInfo.MyDocStyle.Layout.LeftMargin + ctr - (scttopWidth / 2); + vlnText mySectMsg = new vlnText(cb, this, scttop, scttop, sctcntrX, sectMsgY, sctMsgFont); + PartsLeft.Add(mySectMsg); + } + return addextra; + } + // Added to try to resolve a problem when printing FNP-1-FRP-I.3 Attachment 3 Table 1. + // May be needed to evaluate this problem in the future. + //private void CompareSectionInfo(SectionInfo si, SectionInfo si1) + //{ + // if (si.ItemID != si1.ItemID) + // Console.WriteLine("Different"); + // if (si.ActiveFormat.FullName != si1.ActiveFormat.FullName) + // Console.WriteLine("Different"); + // if (si.ActiveParent != si1.ActiveParent) + // Console.WriteLine("Different"); + // if (si.ActiveSection.ItemID != si1.ActiveSection.ItemID) + // Console.WriteLine("Different"); + // if (si.MyDocStyle.Name != si1.MyDocStyle.Name) + // Console.WriteLine("Different"); + //} + private void AddFootNote(PdfContentByte cb) + { + // for calvert valve lists footnotes, if there is footnote data, save it for vlnSvgPageHelper + // which puts the footnotes out when page is printed. + List myNotes = MyPageHelper.NotesToFootNotesHLS[MyItemInfo.ItemID]; + foreach (int myNote in myNotes) + { + ItemInfo inote = StepInfo.Get(myNote); + + // first check if this exact text is already in the foot note list. If it is + // in there, don't add it. + bool inlist = false; + if (MyPageHelper.NotesToFootNotes != null) + { + foreach (vlnParagraph vp in MyPageHelper.NotesToFootNotes) + { + if (vp.MyItemInfo.MyContent.Text == inote.MyContent.Text) + { + inlist = true; + break; + } + } + } + if (!inlist) + { + vlnParagraph vpFNote = new vlnParagraph(null, cb, inote, (float)MyItemInfo.MyDocStyle.Layout.LeftMargin, 0, 0, 0, MyItemInfo.ActiveFormat, null, null, 0, false, MyPromsPrinter) + { + Width = (float)MyItemInfo.MyDocStyle.Layout.PageWidth - (float)MyItemInfo.MyDocStyle.Layout.LeftMargin, + Height = 0, + XOffset = (float)MyItemInfo.MyDocStyle.Layout.LeftMargin + }; + if (MyPageHelper.NotesToFootNotes == null) MyPageHelper.NotesToFootNotes = new List(); + MyPageHelper.NotesToFootNotes.Add(vpFNote); + } + } + MyPageHelper.NotesToFootNotesHLS.Remove(MyItemInfo.ItemID); + } + private bool DoTopContinueMsg(PdfContentByte cb, ref float yPageStart, float yTopMargin, DocStyle docstyle, string subTab) + { + bool addExtraLine = false; + if ((bool)docstyle.Continue.Top.UseStepTabs) + { + // UseStepTabs is a format flag added for Comanche Peak to print out step tabs as + // a top comtinue message. This code will go up through parents putting out + // their tabs - at this y location, but at the tabs' x location + vlnParagraph myPar = this; + MyPageHelper.TopMessageRs = new List(); + while (!myPar.MyItemInfo.IsHigh) + { + myPar = myPar.MyParent; + foreach (vlnPrintObject vpo in myPar.PartsLeft) + { + if (vpo is vlnTab) + { + vlnTab vt = vpo as vlnTab; + string cltxt = vt.Text; + // replace C# representation of unicode character "\u25CF" which is hex + // with the rtf representation @"\u9679?" + if (cltxt.Contains("\u25CF")) cltxt = cltxt.Replace("\u25CF", @"\u9679?"); // handle a bullet, if it isn't unicode yet + float msgTopMargin = yTopMargin; + // B2017-106: if caution/note move the message up a little so it doesn't touch the caution/note lines: + if (MyItemInfo.IsNote || MyItemInfo.IsCaution) msgTopMargin += 4; + // B2018-140: if table move the message up a little so it doesn't touch the table lines: + if (MyItemInfo.IsTable) msgTopMargin += 6; + MyPageHelper.TopMessageRs.Add(new vlnText(cb, this, cltxt, cltxt, vt.XOffset, msgTopMargin, vt.MyFont)); + } + else if (vpo is vlnText) // As of 6/22/15, CP wants the step designator in the continue message also. + { + vpo.YOffset = yTopMargin; + int nlcnt = 1; // number of lines to adjust the yoffset for the next step designator we are adding to TopMessageRs + string rtxt; + int istr; + int Rsidx; + MyPageHelper.TopMessageRs.Add(vpo as vlnText); // this appends a previous step designator associated with this sub-step (there may be more than one and/or might have multiple lines) + // we are processing the step designator on the top continue message in reverse order + // we therefore need to adjust the y location of multiple step designors attached tothe top continue message + if (MyPageHelper.TopMessageRs.Count > 3) + { + Rsidx = MyPageHelper.TopMessageRs.Count - 1; + rtxt = MyPageHelper.TopMessageRs[Rsidx].Text; + // find the number of lines to shift existing TopMessageRs step designators down + istr = rtxt.IndexOf("\\line", 0); + while (istr != -1) + { + nlcnt++; + istr = rtxt.IndexOf("\\line", istr + 1); + } + // move the previous TopMessageRs step designators down + Rsidx -= 2; // index to the previous step desginator + while (Rsidx > 0) + { + MyPageHelper.TopMessageRs[Rsidx].YOffset -= (nlcnt * SixLinesPerInch); + Rsidx -= 2;// every other TopMessageRs is a step designator + } + } + // for Comanche Peak - if step breaks on a sub-step, and both the high level step and the sub-step have a step designator + // then since the high level step and its step designator are printed as part of the top continue message, + // move the step designator associated with the sub-step down so that it does not print on top of the + // ones in the top continue message. + if (this.PartsLeft.Count > 1) // was a step designator printed for the sub-step? + { + // count the number of lines in the step designator text in the top continue message + nlcnt = 0; // reset for the number of lines to push the sub-step's step designator down + Rsidx = MyPageHelper.TopMessageRs.Count - 1; // note that TopMessageRs[0] is a tab not a step designator + while (Rsidx > 0) + { + nlcnt++; + rtxt = MyPageHelper.TopMessageRs[Rsidx].Text; + istr = rtxt.IndexOf("\\line", 0); + while (istr != -1) + { + nlcnt++; + istr = rtxt.IndexOf("\\line", istr + 1); + } + Rsidx -= 2; // every other TopMessageRs is a step designator + } + if (nlcnt > 0) + { + for (int idx = 1; idx < this.PartsLeft.Count; idx++) + { + vlnPrintObject vpol = this.PartsLeft[idx]; + vpol.YOffset += (nlcnt * SixLinesPerInch); // move the existing step designator down + } + } + } + } + } + } + return false; + } + + string myMsg = docstyle.Continue.Top.Message; + MyPageHelper.TopMessageRs = new List(); + // bug fix B2106-099 + // when there are more than one Caution/Note off of a high level background step, + // the second, third, etc background Caution/Note pages begin printing two additional lines from the top of the page + // to fix, added a check to see the the item we are printing has the PageBrrakOnStep flag set, if it's set, + // then DON'T add two lines to the yPageStart (for the top conitnue message) + if (myMsg != null && myMsg != "" && !MyItemInfo.IsSection && !MyItemInfo.FormatStepData.PageBreakOnStep) // B2020-123 + { + // C2019-044 for BNPP put the top continue message on the same row as the Checkoff/Signoff header + // This is done by specifing a row positon in the top continue definition in the format. + // If the top continue messsage RowOverride is being used, don't move the yPageStart down (don't need to make room for it) + if (docstyle.Continue.Top.RowOverride == null) + yPageStart -= 2 * SixLinesPerInch;// Allow two lines for top continue message + if (myMsg.IndexOf(@"%sR") > -1) + { + ItemInfo myAer = MyItemInfo.IsHigh ? MyItemInfo : MyItemInfo.MyParent; + if (MyItemInfo.IsInRNO) + { + // If this is an RNO part, find the parent that is not an RNO (the reason for this is + // that RNO parts are structured as parent/child not sibling relationships, for + // example, RNO part 1.2 is the child of 1.1 not sibling). Also, if this is a caution + // or note of the RNO part, do the same because it should not use the RNO part's tab. + // However, the RNO Part will have the combined tab using its parent because this is + // needed if any of its children, for example substeps, need the combined tab. + if (((MyItemInfo.IsNote || MyItemInfo.IsCaution) && MyItemInfo.MyParent.IsRNOPart) || MyItemInfo.IsRNOPart) + { + ItemInfo ip = MyItemInfo.MyParent; + while (ip.IsRNOPart) ip = ip.MyParent; + myMsg = myMsg.Replace(@"%sR", ip.CombinedTab); + } + // B2020-154: Incorrect top continue message tab in RNO column if for single level substep with a Caution/Note + else if ((MyItemInfo.IsNote || MyItemInfo.IsCaution) && MyItemInfo.MyParent.MyParent.IsRNOPart) + { + if (DebugPagination.IsOpen) DebugPagination.WriteLine("***===>,'Yes','Case 1:Changed RNO Continue Message',{0},{1},,{3},'{4}'", MyItemInfo.ItemID, YSize, 0, 0, this); + ItemInfo ip = MyItemInfo.MyParent; + while (!ip.IsRNOPart) ip = ip.MyParent; + myMsg = myMsg.Replace(@"%sR", ip.CombinedTab); + } + // B2020-154: Incorrect top continue message tab in RNO column for substep with a Caution/Note within parent substeps + else if ((MyItemInfo.IsNote || MyItemInfo.IsCaution) && MyItemInfo.MyParent.MyParent.IsInRNO) + { + if (DebugPagination.IsOpen) DebugPagination.WriteLine("***===>,'Yes','Case 2:Changed RNO Continue Message',{0},{1},,{3},'{4}'", MyItemInfo.ItemID, YSize, 0, 0, this); + myMsg = myMsg.Replace(@"%sR", MyItemInfo.MyParent.MyParent.CombinedTab); + } + else + myMsg = myMsg.Replace(@"%sR", MyItemInfo.MyParent.CombinedTab); + float xor = MyTopRNO.MyTab.XOffset; + MyPageHelper.TopMessageRs.Add(new vlnText(cb, this, myMsg, myMsg, xor, yTopMargin + 0.1F, docstyle.Continue.Top.Font)); + // get aer message, go up parent until find aer and use its combined tab: + myAer = MyItemInfo; + while (myAer.IsInRNO) myAer = myAer.MyParent; + } + else if (!MyItemInfo.IsHigh && (MyItemInfo.IsNote || MyItemInfo.IsCaution)) + { + ItemInfo ip1 = MyItemInfo.MyParent; + if (!ip1.IsHigh) myAer = ip1.MyParent; + } + myMsg = docstyle.Continue.Top.Message.Replace(@"%sR", myAer.CombinedTab); + } + if (myMsg.IndexOf(@"%s") > -1) + { + if (MyItemInfo.MyParent.IsSection && (docstyle.StructureStyle.Style & E_DocStructStyle.BottomSectionContinue) == E_DocStructStyle.BottomSectionContinue) + myMsg = myMsg.Replace(@"%s", MyItemInfo.MyParent.MyTab.CleanText.Trim()); + else + { + // F2020-023: tab includes parent tab and if caution/note don't use its parent, go up another level + string noBullet = MyItemInfo.IsCautionOrNotePart ? MyItemInfo.MyParent.MyParent.CombinedTab : MyItemInfo.MyParent.CombinedTab; + // F2026-002 Vogtle Units 3&4, don't include the RNO sub-step tab if the parent is an AER sub-step + if (docstyle.Continue.Top.DontIncludeRNOTabIfHasAERParent && MyItemInfo.MyParent.IsRNOPart && !MyItemInfo.MyParent.MyParent.IsRNOPart) + noBullet = MyItemInfo.MyParent.MyParent.CombinedTab; + // C2021-024: WCN1 if bullet exists in combined tab, stop right before bullet. + // B2021-085 & 087: crash if noBullet was null. Also, if null, see if text in parent. if no text, replace the + // "%s." with noBullet (null) which won't put out just a '.' as step number. + if (docstyle.Continue.Top.RemoveBullet) + { + if (noBullet == null && MyItemInfo.IsCautionOrNotePart) noBullet = MyItemInfo.MyParent.CombinedTab; + if (noBullet != null) + { + int ind = noBullet.IndexOf(".o"); + if (ind < 0) ind = noBullet.IndexOf(".*"); + if (ind > -1) noBullet = noBullet.Substring(0, ind); + } + else + { + myMsg = myMsg.Replace(@"%s.", noBullet); + } + } + myMsg = myMsg.Replace(@"%s", noBullet); + } + } + if (myMsg.IndexOf(@"%3d") > -1) + myMsg = myMsg.Replace(@"%3d", MyItemInfo.MyHLS.Ordinal.ToString()); + if (myMsg.IndexOf(@"%2d") > -1) + myMsg = myMsg.Replace(@"%2d", MyItemInfo.MyHLS.MyTab.CleanTextNoSymbols.Trim(" .".ToCharArray()).PadLeft(2)); + if (myMsg.IndexOf(@"%d") > -1) + myMsg = myMsg.Replace(@"%d", MyItemInfo.MyHLS.MyTab.CleanTextNoSymbols.Trim(" .".ToCharArray())); + if (myMsg.IndexOf(@"%c") > -1) + myMsg = myMsg.Replace(@"%c", " "); + + // Top Continue message includes high level step tab and text + if ((docstyle.Continue.Top.HLS ?? 0) == 1) + { + myMsg = docstyle.Continue.Top.Message; // reset because we did replace strings in code above + ItemInfo parentStep = MyItemInfo.MyHLS; // get the high level step + myMsg = string.Format(myMsg, parentStep.CombinedTab, parentStep.DisplayTextKeepSpecialChars); + } + // B2023-115 Top continue message for Vogtle Alarms: 1st version done on 12/6/23. Changes to logic as per request + // from engineering done on 12/12/23. See comment below for logic for 12/12/23 (history of this file has previous + // logic) + if (((docstyle.Continue.Top.HLS ?? 0) == 4) || ((docstyle.Continue.Top.HLS ?? 0) == 7)) + { + // Vogtle Alarms: Their alarms are set up differently than standard procedures - the HLS in Vogtle + // alarms is a section in other procedures. The top continue message is shown when a break occurs: + // • A continued message will appear on the top of the page ONLY if the pagination occurs anywhere + // within the first level substep. If, for example, the page break occurs between substep 3 and substep + // 4 as in example 2, no continued message will appear on the top of the page. + // • If a continued message is needed, the continued message will include the first level substep number + // if it is a sequential substep, such as “5. (continued)”. If it is NOT a sequential substep, then only + // the word “(continued)” will appear. + // • If a page break occurs between high level steps, such as before “Causes:”, then no continued message is needed. + + // F2024-027 & F2024-028 + // Vogtle Units 3&4 needed similar top continue messages in the Local Alarms attachments as they have for the MCR Alarm point pages + // with the exception that when High Level Step (grouping text) is split and continued to the next page, the top continue message + // needs to be the HLS text with "(continued)" appended to it. + // Added a TOP.HLS value of 7 to allow for this minor difference and is set in the docstyle for that section + + bool doMessage = true; + if (MyItemInfo.IsHigh) doMessage = false; // at high, don't do message + if (MyItemInfo.MyParent.IsHigh) doMessage = false; // at first level, don't do message + // Caution/Note on first level, don't do message + if ((MyItemInfo.IsCaution || MyItemInfo.IsNote) && MyItemInfo.MyParent.MyParent.IsHigh) doMessage = false; + myMsg = docstyle.Continue.Top.Message; + if (doMessage) + { + // Get to highest level below HLS + ItemInfo cur = MyItemInfo; + while (!cur.MyParent.IsHigh) cur = cur.MyParent; + // if sequential, add on step number, otherwise just put out message: + myMsg = !cur.IsSequential ? myMsg : $"{cur.CombinedTab}. {myMsg}"; + } + // F2024-027 & F2024-028 added else if to check of the case where we want to use the High Level Step text in the top continue message + else if (((docstyle.Continue.Top.HLS ?? 0) == 7) && MyItemInfo.MyParent != null && MyItemInfo.MyParent.IsHigh) + { + myMsg = $"{MyItemInfo.MyParent.DisplayText} {myMsg}"; + } + else // if not doing message, clear it & set yPageStart back to what it was before handling message + { + myMsg = ""; + yPageStart += 2 * SixLinesPerInch; + } + } + // B2021-138: Top continue message for Barakah Single column New (2021) format was incorrect for some lower + // sub-steps. + if ((docstyle.Continue.Top.HLS ?? 0) == 6) + { + myMsg = docstyle.Continue.Top.Message; // reset because we did replace strings in code above + ItemInfo parentStep = MyItemInfo.MyHLS; + string ctab = parentStep.CombinedTab; + if (!MyItemInfo.MyParent.IsHigh) // If lower sub-step, get parent substep tab, skipping caution/note if in one of those + ctab = (MyItemInfo.IsInCautionOrNote) ? MyItemInfo.MyParent.MyParent.CombinedTab : MyItemInfo.MyParent.CombinedTab; + myMsg = string.Format(myMsg, ctab, parentStep.DisplayTextKeepSpecialChars); + } + // Calvert Alarms, step description have the alarm number as part of the top continue message + // Also, if the break is within the CONDITION/RESPONSE, there are continue messages in both columns at the top + // of the table, note that the continue messages WITHIN table are only printed when the + // steplevel is greater than 2 - this is from 16bit. + // NOTE THAT this code is not complete - the positioning & addition of step tab for within table are not working correctly + if ((docstyle.Continue.Top.HLS ?? 0) == 3) + { + MyPageHelper.TopMessageSub1s = new List(); + MyPageHelper.TopMessageSub2s = new List(); + + string tabText = @"\ul\b " + MyHighLevelParagraph.MyItemInfo.MyTab.CleanText.Trim() + @"\b0\ulnone"; + // B2017-185: added the replace of unicode dash to regular dash for the continue message so it matches the step text: + string stepText = @"\b " + MyHighLevelParagraph.MyItemInfo.MyContent.Text.Replace(@"\u8209?", "-") + @"\b0"; + vlnText vt1 = new vlnText(cb, this, tabText, tabText, MyHighLevelParagraph.MyTab.XOffset, yTopMargin + 0.1F, docstyle.Continue.Top.Font) + { + Width = MyHighLevelParagraph.MyTab.Width + }; + MyPageHelper.TopMessageRs.Add(vt1); + vlnText vt2 = new vlnText(cb, this, stepText, stepText, MyHighLevelParagraph.XOffset, yTopMargin + 0.1F, docstyle.Continue.Top.Font) + { + Width = MyHighLevelParagraph.Width + }; + MyPageHelper.TopMessageRs.Add(vt2); + + // the following code is used to print the top continue messages in the Calvert Alarm format + // CONDITION/RESPONSE table. Messages only get printed if the break is on a substep at steplevel > 2. + // see comments within code for what the tab contains, it varies depending on which side + // break occurred & how deep in the step the break occurred. + if (subTab != null && MyItemInfo.StepLevel > 2) + { + bool incond = !MyItemInfo.IsInRNO; + float ybot = yTopMargin + (4 * SixLinesPerInch); + string concatrnoTab = ""; // constructed tab for Response side + string concataerTab = ""; // constructed tab for Condition side + float xoffTab; // position for Response tab + float xoffMsg; // position for Response message + vlnParagraph useAerParaForTab; // use this paragraph under Conditions for locating tab & message + if (incond) + { + // If break is in Condition side of table, use Condition tab of parent & no tab for Response side. + // Both sides have the message '(continued)'. + useAerParaForTab = MyParent; + concataerTab = MyParent.MyTab != null ? MyParent.MyTab.Text.TrimEnd() : ""; + xoffTab = 0; // no rno tab + xoffMsg = ToInt(MyItemInfo.ActiveFormat.MyStepSectionLayoutData.ColRTable, 1) + (float)MyItemInfo.MyDocStyle.Layout.LeftMargin + ((useAerParaForTab != null && useAerParaForTab.MyTab != null) ? useAerParaForTab.MyTab.Width : 7.2f); + } + else + { + // break occurred in Response side. Use the tabs up to highest RNO concatenated together. + vlnParagraph useRnoParaForTab = MyParent; + vlnParagraph useParaForTab = MyParent; + while (useParaForTab.MyItemInfo.IsInRNO) + { + concatrnoTab = (useParaForTab.MyTab != null ? useParaForTab.MyTab.Text.TrimEnd() : "") + concatrnoTab.Trim(); + if (concatrnoTab.Length > 0 && concatrnoTab[0] > '\xff') concatrnoTab = ""; + useRnoParaForTab = useParaForTab; + useParaForTab = useParaForTab.MyParent; + } + xoffTab = useRnoParaForTab.MyTab.XOffset; + xoffMsg = useRnoParaForTab.XOffset; + + // aer message when rno broke. Need to concatenate up the Condition side also until + // hitting 1st non-sequential, i.e. moves out of Condition/Response table. + useAerParaForTab = useParaForTab; // useParaForTab is 1st found non-Response step, i.e. moved into Condition side of table + while (useParaForTab.MyItemInfo.IsSequential) + { + concataerTab = (useParaForTab.MyTab != null ? useParaForTab.MyTab.Text.TrimEnd() : "") + concataerTab.Trim(); + useAerParaForTab = useParaForTab; + useParaForTab = useParaForTab.MyParent; + } + } + // For RNO tab, add a vlntext for tab and one for continue message: + float xoff1 = xoffMsg; + if (!incond) + { + vlnText vtc = new vlnText(cb, this, concatrnoTab, concatrnoTab, xoffTab, ybot, docstyle.Continue.Bottom.Font); + MyPageHelper.TopMessageSub1s.Add(vtc); + if ((vtc.IParagraph.Chunks[0]) is Chunk chk) + { + float xoff2 = xoffTab + chk.GetWidthPoint() + 6; + // If the "(continue)" is going to overlap the tab, then move the "Continue)" so that it doesn't overlap. + if (xoff2 > xoff1) xoff1 = xoff2; + } + } + MyPageHelper.TopMessageSub1s.Add(new vlnText(cb, this, myMsg, myMsg, xoff1, ybot, docstyle.Continue.Bottom.Font)); + + // for aer tab, add a vlntext for tab and one for continue message: + MyPageHelper.TopMessageSub2s.Add(new vlnText(cb, this, concataerTab, concataerTab, useAerParaForTab.MyTab.XOffset, ybot, docstyle.Continue.Bottom.Font)); + MyPageHelper.TopMessageSub2s.Add(new vlnText(cb, this, myMsg, myMsg, useAerParaForTab.XOffset, ybot, docstyle.Continue.Bottom.Font)); + addExtraLine = true; + } + } + if (!PageBreakOnStep) + { + float colPos = docstyle.Layout.LeftMargin + docstyle.Continue.Top.Margin ?? 0; + if (!docstyle.Continue.Top.PlaceAtLeftMargin) //F2019-033 when true position with respect only to the left margin + colPos += XOffsetBox; //XOffsetbox get set when the tables, figures & equations were beyond the border and needed repositioned + // C2019-044 for BNPP, put the top continue message on the same row as the checkoff/signoff heading + // RowOverride specifies the position of the top continue message + // For BNPP, RowOverride is set to the same row as the checkoff header is set to in the pagelist + if (docstyle.Continue.Top.RowOverride != null) + { + float adjRowPosition = (float)docstyle.Layout.TopMargin - (float)docstyle.Continue.Top.RowOverride; + MyPageHelper.TopMessage = new vlnText(cb, this, myMsg, myMsg, colPos, yTopMargin + 0.1F + adjRowPosition, docstyle.Continue.Top.Font);// MyItemInfo.ActiveFormat.PlantFormat.FormatData.Font); + } + else + MyPageHelper.TopMessage = new vlnText(cb, this, myMsg, myMsg, colPos, yTopMargin + 0.1F, docstyle.Continue.Top.Font);// MyItemInfo.ActiveFormat.PlantFormat.FormatData.Font); + + } + else + MyPageHelper.TopMessage = null; + } + return addExtraLine; + } + + private void DoBottomContinueMsg(PdfContentByte cb, float yBottomMargin, float yLocation, DocStyle docstyle, bool doThreeContinues) + { + // Console.WriteLine("Page {0} - yLocation {1}", cb.PdfWriter.PageNumber, yLocation); + string myMsg = docstyle.Continue.Bottom.Message; + + // a format flag exists that states to only put a BOTTOM message if it is a certain type (RNO) + // check for this.... + bool RNOContinueOnly = MyItemInfo.ActiveFormat.PlantFormat.FormatData.StepDataList[40].ContinueOnly; + bool doBottom = !RNOContinueOnly || (MyItemInfo.IsInRNO && RNOContinueOnly); + if (doBottom && myMsg != null && myMsg != "") + { + myMsg = ReplaceStepBottomContinue(myMsg); + float msg_yLocation = 0; + if (myMsg.Contains("{par}")) + { + myMsg = myMsg.Replace("{par}", ""); + msg_yLocation = -SixLinesPerInch; + } + float yBtmMarginForMsg = yBottomMargin; + + // one of the format flags for FNP had an adjustment for printing the section title only + // on the first page of the section. Adjust the location of the bottom continue message + // if this adjustment was made (the current topmargin may not reflect the value within + // the document style) + if (MyPageHelper.PrintedSectionPage > 0) + { + if (MyItemInfo.ActiveSection != null && (MyItemInfo.ActiveSection.MyDocStyle.StructureStyle.Style & E_DocStructStyle.DSS_PrintSectOnFirst) == E_DocStructStyle.DSS_PrintSectOnFirst) // C2018-003 fixed use of getting the active section + { + float localYTopMargin = PDFPageSize.PaperSizePoints(MyItemInfo.ActiveFormat.PlantFormat.FormatData.PDFPageSize.PaperSize) - (float)MyItemInfo.ActiveSection.MyDocStyle.Layout.TopMargin; // C2020-002 paper size is now set in the format files + yBtmMarginForMsg = Math.Max(0, localYTopMargin - (float)MyItemInfo.ActiveSection.MyDocStyle.Layout.PageLength); + } + } + // include space for phone list when determining bottom continue message location + if (MyItemInfo.ActiveFormat.PlantFormat.FormatData.SectData.PrintPhoneList && MyPageHelper.PhoneListHeight != 0) + yBtmMarginForMsg += (MyPageHelper.PhoneListHeight - vlnPrintObject.SixLinesPerInch); + // B2019-079: Account for compression when locating the bottom continue message + if (MyPageHelper.YMultiplier != 1) + { + //float topOfPage = PDFPageSize.PaperSizePoints(MyItemInfo.ActiveFormat.PlantFormat.FormatData.PDFPageSize.PaperSize) - (float)MyItemInfo.MyDocStyle.Layout.TopMargin; // A4 paper logic + float topOfPage = 792 - (float)MyItemInfo.MyDocStyle.Layout.TopMargin; + yLocation = topOfPage - (topOfPage - yLocation) * MyPageHelper.YMultiplier; + } + switch (docstyle.Continue.Bottom.Location) + { + case E_ContBottomLoc.EndOfText: // place continue string at end of text + // msg_yLocation accounts for extra lines in message from docstyle; and BottomContent is the actual + // location of the last line of text on page. + // B2019-079 changed yLocaton - msg_yLocation to '+'. The msg_ylocation has an adjustment for adding an extra line by moving down the page, this was moving + // the line up the page (double negative). + msg_yLocation = yLocation + msg_yLocation - (SixLinesPerInch * MyPageHelper.YMultiplier); //B2019-021 yLocation accounts for checkoffs + if (yBottomMargin + (docstyle.Layout.FooterLength ?? 0) > msg_yLocation) + { // Adjusted Continue Message Y Offset + //DebugPagination.WriteLine("====>> {0},'{1}'", msg_yLocation, MyItemInfo.ShortPath); + float msg_yLocationOld = msg_yLocation = yBottomMargin + (docstyle.Layout.FooterLength ?? 0); + if (MyPageHelper.BottomContent != null) + msg_yLocation = Math.Min(yBottomMargin + (docstyle.Layout.FooterLength ?? 0), (float)MyPageHelper.BottomContent - SixLinesPerInch);// RHM20150525 - Table Scrunch + if (msg_yLocationOld != msg_yLocation) + _MyLog.WarnFormat("Continue Message Moved from {0} to {1} for {2}", msg_yLocationOld, msg_yLocation, this);// RHM20150525 - Table Scrunch + } + break; + case E_ContBottomLoc.BtwnTextAndBottom: // place continue string between end of text & bottom of page + msg_yLocation = msg_yLocation + yLocation - ((yLocation - yBottomMargin) / 2); // +SixLinesPerInch; // (need this for IP3) + msg_yLocation = Math.Max(msg_yLocation, yBottomMargin + SixLinesPerInch); + break; + case E_ContBottomLoc.BottomOfPage: // place continue message at bottom of page + msg_yLocation = msg_yLocation + yBtmMarginForMsg + (float)docstyle.Layout.FooterLength; + break; + case E_ContBottomLoc.BelowBottom1: + msg_yLocation += yBtmMarginForMsg; + break; + case E_ContBottomLoc.BottomWithFooter: // put bottom message AND if in CONDITION/RESPONSE table, in both columns. + msg_yLocation += yBtmMarginForMsg; + break; + case E_ContBottomLoc.EndOfText2: // Like EndOfText but limited within yBottomMargin + msg_yLocation = Math.Max(msg_yLocation + yLocation - SixLinesPerInch, yBottomMargin + SixLinesPerInch); + break; + case E_ContBottomLoc.BtwnTextAndBottom2: + // Like BtwnTextAndBottom but accounts for line spacing of step & is 1 line up on page (for BGE - Procedure Steps - 2 column) + float adj = (!MyItemInfo.IsSection && MyItemInfo.FormatStepData.StepLayoutData.EveryNLines == 1) ? SixLinesPerInch : 0; + msg_yLocation = msg_yLocation + yLocation - ((yLocation - yBottomMargin) / 2) + adj;// +SixLinesPerInch; + if (msg_yLocation < yBottomMargin) msg_yLocation = yBottomMargin; + break; + default: + _MyLog.WarnFormat("**** BOTTOM CONTINUE MESSAGE NOT CODED FOR LOCATION {0}*****", docstyle.Continue.Bottom.Location); + break; + } + if (!PageBreakOnStep) + { + float xoffB; + // Added for Calvert Alarms: if 'doThreeContinues', continue message at bottom of page + // and a continue message at the bottom of each column. + if (doThreeContinues) + { + float ybot = yLocation; + xoffB = (float)docstyle.Layout.LeftMargin + docstyle.Continue.Bottom.Margin ?? 0; + MyPageHelper.BottomMessageA = new vlnText(cb, this, myMsg, myMsg, xoffB, ybot, docstyle.Continue.Bottom.Font); + xoffB = docstyle.Layout.LeftMargin + docstyle.Continue.Bottom.MarginR ?? 0; + MyPageHelper.BottomMessageR = new vlnText(cb, this, myMsg, myMsg, xoffB, ybot, docstyle.Continue.Bottom.Font); + MyPageHelper.AlarmYoffEnd -= SixLinesPerInch; + float tmp = (((float)docstyle.Layout.PageWidth - (float)docstyle.Layout.LeftMargin) / 2) - (myMsg.Length / 2 * 5); + xoffB = (float)docstyle.Layout.LeftMargin + tmp; + } + else if (docstyle.Continue.Bottom.Location == E_ContBottomLoc.BottomWithFooter) + { + float tmp = (((float)docstyle.Layout.PageWidth - (float)docstyle.Layout.LeftMargin) / 2) - (myMsg.Length / 2 * 5); + xoffB = (float)docstyle.Layout.LeftMargin + tmp; + } + else if (RNOContinueOnly) + { + float colR = float.Parse(MyItemInfo.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.StepSectionLayoutData.ColRTable.Split(",".ToCharArray())[MyItemInfo.ColumnMode]); + xoffB = colR + docstyle.Layout.LeftMargin + docstyle.Continue.Bottom.Margin ?? 0; + } + else if (MyItemInfo.IsInRNO && (docstyle.Continue.Bottom.MarginR ?? 0) > 0) + { + xoffB = (float)docstyle.Layout.LeftMargin + (float)docstyle.Continue.Bottom.MarginR; + MyPageHelper.BottomMessageR = new vlnText(cb, this, myMsg, myMsg, xoffB, msg_yLocation, docstyle.Continue.Bottom.Font); + xoffB = (float)docstyle.Layout.LeftMargin + (float)docstyle.Continue.Bottom.Margin; + + } + // FloatingContinueMessage format flag: + // if breaking at the AER put continue message in left column, + // if breaking RNO put continue message in Right column. + else if (MyItemInfo.IsInRNO && MyItemInfo.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.FloatingContinueMessage) + { + float colR = float.Parse(MyItemInfo.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.StepSectionLayoutData.ColRTable.Split(",".ToCharArray())[MyItemInfo.ColumnMode]); + xoffB = colR + docstyle.Layout.LeftMargin + docstyle.Continue.Bottom.Margin ?? 0; + } + else + xoffB = docstyle.Layout.LeftMargin + docstyle.Continue.Bottom.Margin ?? 0; + MyPageHelper.BottomMessage.Clear(); // B2017-207 should be only one continue message - was putting an extra continue message in middle of page for V.S.Summer (ex. AOP set, 900.4 Attachment 12) + MyPageHelper.BottomMessage.Add(new vlnText(cb, this, myMsg, myMsg, xoffB, msg_yLocation, docstyle.Continue.Bottom.Font)); + } + } + if (PageBreakOnStep) MyPageHelper.BottomMessage.Clear(); + } + + private void RefreshDocStyle() + { + MyItemInfo.ActiveSection = null; + MyItemInfo.MyDocStyle = null; + MyPageHelper.MySection = MyItemInfo as SectionInfo; + MyPageHelper.ResetSvg(); + MyPageHelper.PrintedSectionPage = 0; + } + + private string ReplaceStepBottomContinue(string myMsg) + { + string tb; + if (MyItemInfo.IsSection) + tb = MyItemInfo.MyTab.CleanText.Trim(); + else + tb = MyItemInfo.MyHLS.MyTab.CleanTextNoSymbols; + // if the tab ends with .0, remove it if it was added because of the virtualdotinhls flag. + if (MyItemInfo.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.StepSectionLayoutData.VirtualDotInHLSTab && tb.Contains(".0")) tb = tb.Replace(".0", ""); + if (myMsg.IndexOf(@"%d") > -1) + myMsg = myMsg.Replace(@"%d", tb.Trim()); + if (myMsg.IndexOf(@"%0d") > -1) + myMsg = myMsg.Replace(@"%0d", tb.Trim(" .".ToCharArray())); + if (myMsg.IndexOf(@"%2d") > -1) + myMsg = myMsg.Replace(@"%2d", tb.Trim(" .".ToCharArray()).PadLeft(2)); + if (myMsg.IndexOf(@"%3d") > -1) + myMsg = myMsg.Replace(@"%3d", MyItemInfo.MyHLS.Ordinal.ToString()); + // F2020-023: tab includes parent tab and if caution/note don't use its parent, go up another level + if (myMsg.IndexOf(@"%s") > -1) // %s was added for F2020-023 + { + string tmp = tb.Trim(); + if (!MyItemInfo.MyParent.IsHigh) + { + tmp = MyItemInfo.IsCautionOrNotePart ? MyItemInfo.MyParent.MyParent.CombinedTab : MyItemInfo.MyParent.CombinedTab; + // C2021-024: WCN1 if bullet exists in combined tab, stop right before bullet. + // B2021-085 & 087: crash if noBullet was null. Also, if null, see if text in parent. if no text, replace the + // "%s." with noBullet (null) which won't put out just a '.' as step number. + if (MyItemInfo.MyDocStyle.Continue.Bottom.RemoveBullet) + { + if (tmp == null && MyItemInfo.IsCautionOrNotePart) tmp = MyItemInfo.MyParent.CombinedTab; + if (tmp != null) + { + int ind = tmp.IndexOf(".o"); + if (ind < 0) ind = tmp.IndexOf(".*"); + if (ind > -1) tmp = tmp.Substring(0, ind); + } + else + { + myMsg = myMsg.Replace(@"%s.", tmp); + } + } + } + myMsg = myMsg.Replace(@"%s", tmp); + } + return myMsg; + } + private vlnParagraph TopMostChild => ChildrenAbove.Count > 0 ? ChildrenAbove[0].TopMostChild : this; + private bool EmptyTopMostPart + { + get + { + if (TopMostChild.PartsAbove.Count == 0) return false; + if (TopMostChild.PartsContainer != null && TopMostChild.PartsContainer.Count > 0) return false; // B2016-198: not 'EmptyTopMostPart' if there is a box. + foreach (vlnPrintObject po in TopMostChild.PartsAbove) + { + if (!(po is vlnHeader hd)) return false; + if (hd.Text != "") return false; + } + return true; + } + } + + public float TableBottom { get; set; } = -1; + private float OutputOtherPageSteps(PdfContentByte cb, float YTopMost, float yPageStart, float yTopMargin, float yBottomMargin) + { + // B2019-115 Locate Bottom Continue Message below AER Table if necessary - Initialize TableBottom to -1 + TableBottom = -1; + float retval = YTopMost; + // Find any items remaining in MyPageHelper.MyParagraphs that should be printed on this page. + vlnParagraphs process = new vlnParagraphs(null); + int processed = 0; + foreach (vlnParagraph vPara in MyPageHelper.MyParagraphs.Values) + { + if (!vPara.Processed) + { + if (vPara.MyItemInfo.IsTable && (vPara.YOffset <= YTopMost) && vPara.MyItemInfo.ActiveSection.ColumnMode > 0 && vPara.Height + yBottomMargin < yPageStart - vPara.YOffset) //B2019-120 Byron ELEC-1 step 3 second table was not printing on following page + { + if (this.MyItemInfo.ItemID != vPara.MyItemInfo.ItemID) + { + // B2019-115 Locate Bottom Continue Message below AER Table if necessary + _MyLog.WarnFormat("\r\n=-=-=> Table Print on First Page {0} {1} ColumnMode = {2}", vPara.MyItemInfo.ItemID, vPara.MyItemInfo.ShortPath, vPara.MyItemInfo.ActiveSection.ColumnMode); + process.Add(vPara); + // Console.WriteLine("Table YOffset {0} height {1} Bottom = {2} yPageStart = {3} Bottom {4}", vPara.YOffset, vPara.Height, vPara.YOffset + vPara.Height - yPageStart, yPageStart, this.YBottom); + } + } + else if (((vPara.YOffset + vPara.Height) < YTopMost)) + { + // B2019-028: Added check for active section in next line so that following section text doesn't overlap or start too far down on page for case where there is a subsection + // with subsections of type Step/Word/Step + if (this.MyItemInfo.ItemID != vPara.MyItemInfo.ItemID) + { + // B2019-077: 2.0 SCOPE empty section not printing for WES (revert to previous code line versus above) + process.Add(vPara); + } + else // 20150701 Complicated RNO change + _MyLog.WarnFormat("Less Than: Step Could Have Fit {0}, {1}", MyItemInfo.ItemID, MyItemInfo.ShortPath); + } + else if (((vPara.YOffset + vPara.Height) == YTopMost)) + { + + if (this.MyItemInfo.ItemID != vPara.MyItemInfo.ItemID) + { + process.Add(vPara); + _MyLog.WarnFormat("New AerRno PageBreak Logic: Step Could Have Fit {0}, {1}", MyItemInfo.ItemID, MyItemInfo.ShortPath); + } + else // RHM20150507 Table Scrunch + _MyLog.WarnFormat("Equal: Step Could Have Fit {0}, {1}", MyItemInfo.ItemID, MyItemInfo.ShortPath); + } + else if (((vPara.YOffset) < YTopMost)) + { + retval = Math.Min(retval, vPara.YTopMost); + } + } + else + processed++; + } + //Console.WriteLine("~~~ {0} has {1} Steps {2} Processed {3} to Process", MyItemInfo.ShortPath, MyPageHelper.MyParagraphs.Count + // , processed,process.Count); + foreach (vlnParagraph vPara in process) + { + vPara.ParagraphToPdf(cb, yPageStart, yTopMargin, yBottomMargin); + // B2019-115 Locate Bottom Continue Message below AER Table if necessary + if (vPara.MyItemInfo.IsTable) + { + if (TableBottom == -1) + TableBottom = (yPageStart - vPara.YOffset) - vPara.Height - SixLinesPerInch; + else + TableBottom = Math.Min(TableBottom, (yPageStart - vPara.YOffset) - vPara.Height - SixLinesPerInch); + } + } + return retval; + } + private float _YVeryTop = -1; + public float YVeryTop + { + get + { + if (_YVeryTop == -1) + { + _YVeryTop = YTop; + _YVeryTop = VeryTop(PartsAbove, _YVeryTop); + _YVeryTop = VeryTop(PartsContainer, _YVeryTop); + } + return _YVeryTop; + } + } + + private float VeryTop(vlnPrintObjects parts, float yVeryTop) + { + if (parts != null) + foreach (vlnPrintObject part in parts) + if (part.YOffset < yVeryTop) + yVeryTop = part.YOffset; + return yVeryTop; + } + /// + /// This gets the height of the step with it's Caution's, Notes and potentially any First Substeps + /// + /// + // F2024-006: Vogtle Alarms pagination - added 'includeFirstSub' to get that size of the first substep with the parent step + // to help determine pagination + private float GetFirstPieceSize(bool includeFirstSub = false) + { + vlnParagraph paraLast = GetFirstPieceLastPart(includeFirstSub); + float retval = (paraLast.YBottom) - YTopMost; + //Console.WriteLine(MyItemInfo.DBSequence); + return retval; + } + public override float YBottom + { + get + { + float bottom = YOffset + Height; + if (PartsBelow != null) + { + foreach (vlnPrintObject part in PartsBelow) + { + float partBottom = part.YBottom; + bottom = Math.Max(partBottom, bottom); + } + } + return bottom; + } + } + public float YVeryBottom + { + get + { + float bottom = YOffset + Height; + if (ChildrenBelow != null) + foreach (vlnParagraph child in ChildrenBelow) + bottom = Math.Max(child.YVeryBottom, bottom); + if (ChildrenLeft != null) + foreach (vlnParagraph child in ChildrenLeft) + bottom = Math.Max(child.YVeryBottom, bottom); + if (ChildrenRight != null) + foreach (vlnParagraph child in ChildrenRight) + bottom = Math.Max(child.YVeryBottom, bottom); + if (PartsBelow != null) + foreach (vlnPrintObject part in PartsBelow) + bottom = Math.Max(part.YBottom, bottom); + return bottom; + } + } + public float YBottomText => YOffset + Height; + + public float YBottomForBox { get; set; } = 0; + // F2024-006: Vogtle Alarms pagination - added 'includeFirstSub' to get that size of the first substep with the parent step + // to help determine pagination - even when PaginateOnFirstSubstep is turned on + private vlnParagraph GetFirstPieceLastPart(bool includeFirstSub = false) + { + vlnParagraph para = this; + if ((!MyItemInfo.ActiveFormat.MyStepSectionLayoutData.PaginateOnFirstSubstep || includeFirstSub) && ChildrenBelow != null && ChildrenBelow.Count > 0) + { + // If the substep has a separator (OR, AND) then return the last substep rather than the first. + string mySep = ChildrenBelow[0].MyItemInfo.FormatStepData.Sep ?? "{Null}"; + if (mySep != "{Null}" && mySep != "") + para = ChildrenBelow[ChildrenBelow.Count - 1].GetFirstPieceLastPart(); + else + { + // MNS Pagination - Mike Weiner Case 1a to keep step together with any non-sequential substeps (ANDs, EQ List) + bool keepEqListTogether = ChildrenBelow[0].MyItemInfo.ActiveFormat.MyStepSectionLayoutData.PutOnPageByItself; + if (keepEqListTogether && !ChildrenBelow[0].MyItemInfo.IsSequential && !this.MyItemInfo.IsHigh) // Extend to the last Item. + para = ChildrenBelow[ChildrenBelow.Count - 1].GetFirstPieceLastPart(); + else + para = ChildrenBelow[0].GetFirstPieceLastPart(includeFirstSub); + } + } + if (ChildrenRight != null && ChildrenRight.Count > 0) + { + foreach (vlnParagraph paraRight in ChildrenRight) + { + vlnParagraph paraRightLast = paraRight.GetFirstPieceLastPart(includeFirstSub); + if (paraRightLast.YBottom > para.YBottom) + para = paraRightLast; + } + } + return para; + } + /// + /// Find items from previous page (yLocation less than yTop) and remove them from the list. + /// yTop is the new starting location on the next page for this step. + /// + /// + /// + private void RemoveProcessedParagraphs(StepLevelList myList, float yTop) + { + // the two CleanUpLists are used to remove items from + // the original list because list items cannot be removed in a + // 'foreach'. + List CleanupListStepLevel = new List(); + foreach (int stepLevel in myList.Keys) + { + List CleanupListYLocation = new List(); + SortedList AdjustYLocation = new SortedList(); + foreach (float yLocation in myList[stepLevel].Keys) + { + if (-yLocation <= yTop) + CleanupListYLocation.Add(yLocation); + else + AdjustYLocation.Add(-yLocation, yLocation); // order in ascending order + } + foreach (float yLocation in CleanupListYLocation) + myList[stepLevel].Remove(yLocation); + foreach (float yLocation in AdjustYLocation.Keys) + { + vlnParagraph para = myList[stepLevel][-yLocation]; + myList[stepLevel].Remove(-yLocation); + // shift yLocation by yTop to work with items whose locations + // are defined from the top of the new page rather than + // from the beginning of the step. + // Note that yLocation is negative to have items in descending + // order so that adding yTop decrements their values. + if (!myList[stepLevel].ContainsKey(yTop - yLocation)) + myList[stepLevel].Add(yTop - yLocation, para); + } + if (myList[stepLevel].Count == 0) + CleanupListStepLevel.Add(stepLevel); + } + foreach (int stepLevel in CleanupListStepLevel) + myList.Remove(stepLevel); + } + /// + /// Builds a list of paragraphs by StepLevel and yLocation in descending order. + /// + /// + /// + private void BuildLocationList(float yTopMost, ParagraphLocations myLocations) + { + foreach (vlnParagraph child in ChildrenAbove) + child.BuildLocationList(yTopMost, myLocations); + foreach (vlnParagraph child in ChildrenLeft) + child.BuildLocationList(yTopMost, myLocations); + + // Add a list entry consisting of StepLevel, yoffset from the beginning of this step, paragraph itself + myLocations.Add(this, yTopMost); + + foreach (vlnParagraph child in ChildrenRight) + child.BuildLocationList(yTopMost, myLocations); + foreach (vlnParagraph child in ChildrenBelow) + child.BuildLocationList(yTopMost, myLocations); + } + private readonly int COL_WID_ADJ = 6; // adjusts for incorrect use of WidSTable when breaking a line (it breaks 6 chars too short) + + private static readonly VlnFlexGrid _MyFlexGrid = new VlnFlexGrid(1, 1); + public static VlnFlexGrid MyFlexGrid => _MyFlexGrid; + + public pkParagraph MyPlaceKeeper { get; set; } = null; + public pkParagraph MyContAct { get; set; } = null; + public pkParagraph MyTimeCriticalAction { get; set; } = null; + public static bool InList(int id, params int[] ids) + { + foreach (int listid in ids) + if (id == listid) return true; + return false; + } + + public bool PrefixSpecialCharacter { get; set; } = false; + public string Prefix { get; set; } + public string Suffix { get; set; } + private float RoughSizeOfPage => (float)(MyItemInfo.MyDocStyle.Layout.PageLength /*- MyItemInfo.MyDocStyle.Layout.TopMargin*/ - MyItemInfo.MyDocStyle.Layout.FooterLength); + + public PromsPrinter MyPromsPrinter { get; set; } + public static float _yPageStartForSupInfo = 0; + public vlnParagraph(vlnParagraph parent, PdfContentByte cb, ItemInfo itemInfo, float xoff, float yoff, int rnoLevel, int maxRNO, FormatInfo formatInfo, string prefix, string suffix, float yoffRightParent, bool loadChildren, PromsPrinter pp) + { + MyPromsPrinter = pp ?? parent.MyPromsPrinter; + int profileDepth = ProfileTimer.Push(">>>> vlnParagraph"); + Prefix = prefix; + Suffix = suffix; + MyItemInfo = itemInfo; + MyContentByte = cb; + if (itemInfo.IsFootnote && loadChildren) + { + // notestofootnoteshls is a list, a hls can have more than one note + if (MyPageHelper.NotesToFootNotesHLS.ContainsKey(itemInfo.MyHLS.ItemID)) + MyPageHelper.NotesToFootNotesHLS[itemInfo.MyHLS.ItemID].Add(itemInfo.ItemID); + else + { + List notesList = new List + { + itemInfo.ItemID + }; + MyPageHelper.NotesToFootNotesHLS.Add(itemInfo.MyHLS.ItemID, notesList); + } + Processed = true; // don't want to print during normal ToPdf/ParagraphToPdf cycle - print in vlnsvgpagehelper + ProfileTimer.Pop(profileDepth); + return; + } + // do some 'setup' for Calvert Alarms: + if (itemInfo.ActiveFormat.PlantFormat.FormatData.PrintData.SpecialCaseCalvertAlarm) + { + // The CONDITION/RESPONSE portion of the alarm uses a macro to print the 'table' heading, + // i.e. the lines/boxes and text for CONDITION and RESPONSE. This does not have a tab, + // tabs are where the macros are usually stored, so flag this for future reference. + // The 2nd if is executed when the step is at the same y offset as the parent, i.e. DEVICE & SETPOINT text. + if (itemInfo.TemplateIndex > 0 && itemInfo.ActiveFormat.PlantFormat.FormatData.Templates[itemInfo.TemplateIndex].hmacro > 0) + HasCalvertMacro = true; + if (KeepOnParentLine(itemInfo)) yoff = parent.YOffset; + } + float yOffOrig = yoff; + // Save step text information to be used to create a PlaceKeeper (Calver Cliffs) + BuildPlacekeeper(parent, itemInfo); + + // Save step text information to be used to create a Continuous Action Summary + if (MyPromsPrinter.ShouldPrint_CAS_CTAS) BuildContinuousActionSummary(parent, itemInfo); + + // F2022-024 Time Critical Step + // Save step text information to be used to create a Time Critical Action Summary + if (MyPromsPrinter.ShouldPrint_CAS_CTAS) BuildTimeCriticalActionSummary(parent, itemInfo); + + if (itemInfo.ActiveFormat.MyStepSectionLayoutData.BoxLeftAdj != null) + _MyBoxLeftAdj = float.Parse(itemInfo.ActiveFormat.MyStepSectionLayoutData.BoxLeftAdj); + ShowSectionTitles = formatInfo.PlantFormat.FormatData.SectData.StepSectionData.StepSectionLayoutData.ShowSectionTitles || itemInfo.MyDocStyle.ShowSectionTitles; + if (itemInfo.IsSection && itemInfo.ActiveSection.DisplayText.ToUpper().Contains("") && !itemInfo.ActiveFormat.PlantFormat.FormatData.ProcData.PrintNoTitle) ShowSectionTitles = false; + HasIndent = itemInfo.IsStep && itemInfo.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.DontResetIndentOnNewline; + + int MetaLevel = 0; // if meta section, stores what level this section is. + float savCheckListBottomMost = 0; + //int[] problemIDs = { 889 }; + //List lProblemIDs = new List(problemIDs); + //if (lProblemIDs.Contains(itemInfo.ItemID)) + // Console.WriteLine("Found Item {0}", itemInfo.ItemID);formatInfochecko + MyParent = parent; + // The following code determines the last paragraph for an RNO + // MyTopRNO finds the Top paragraph for an RNO + if (itemInfo.IsInRNO) + { + if (rnoLevel <= maxRNO && itemInfo.IsRNOPart) // Not top level RNO + MyTopRNO = this; + else + MyTopRNO = MyParent.MyTopRNO; + if (MyTopRNO != null) MyTopRNO.LastRNO = this; + } + if (!MyPageHelper.MyParagraphs.ContainsKey(itemInfo.ItemID) && !itemInfo.IsFootnote) + { + MyPageHelper.MyParagraphs.Add(itemInfo.ItemID, this); + } + + XOffset = xoff; + if (!MyItemInfo.IsStep && !MyItemInfo.IsStepSection && MyItemInfo.MyContent.MyEntry != null) + { + IsWordDocPara = true; + // special case - this is a 'Word Doc' paragraph. The Processed flag is used to know + // that steps need put out on a page for the pagination logic, and since there are no steps + // we don't want to have to worry about putting this out for pagination logic. + Processed = true; + ProfileTimer.Pop(profileDepth); + return; + } + YTopMost = YOffset = yoff; + vlnTab mytab = null; + bool doSectTab = false; + // if this substep has a caution or note as its parent, then there may have been a special indent done on the + // substep... check the CautionOrNoteSubstepIndent value, this is the additional indent amount in number + // of characters. + if (itemInfo.MyParent.IsCaution || itemInfo.MyParent.IsNote) + { + // if this is a Note or Caution off of a Note or Caution (Catawba EG/1A/CSAM/SACGR1 step 1) + // then indent it the length of its tab + if (itemInfo.IsCaution || itemInfo.IsNote) + XOffset += (!itemInfo.IsBackgroundStep()) ? (itemInfo.FormatStepData.TabData.IdentPrint.Length - 1) * 6 : 0; // B2018-139 don't adjust XOffset when processing a Caution, or Note background text is is off of Caution or Note WCN BG SAG-10 step 4 + + else + if (itemInfo.ActiveFormat.MyStepSectionLayoutData.DevNoteOrCautionTabOffset != null) + XOffset = float.Parse(itemInfo.ActiveFormat.MyStepSectionLayoutData.DevNoteOrCautionTabOffset); + else + XOffset += 72 * (itemInfo.FormatStepData.CautionOrNoteSubstepIndent == null ? 0 : (float)itemInfo.FormatStepData.CautionOrNoteSubstepIndent / (float)itemInfo.FormatStepData.Font.CPI); + } + + if (itemInfo.IsStep && itemInfo.MyHLS != null && itemInfo.MyHLS.FormatStepData.UseSmartTemplate && + itemInfo.FormatStepData.StepLayoutData.AlignWithParentTab + || (itemInfo.Steps != null && itemInfo.Steps.Count > 0 && itemInfo.Steps[0].FormatStepData.StepLayoutData.AlignWithParentTab)) + itemInfo.MyTab = null; + + float xMetaAdj = 0; + + if (itemInfo.IsFootnote) itemInfo.MyTab = null; + + if (itemInfo.IsSupInfoPart) XOffset = (float)itemInfo.MyDocStyle.Layout.LeftMargin; + + //if (itemInfo.MyTab != null && itemInfo.MyTab.Text != null && itemInfo.MyTab.Text != "") + // bug fix - if the section does not have a section number, then we need to build an empty tab for the itemInfo + // so that we place the section title in the correct location. so we need to go into this IF code block + // even if itemInfo has a MyTab that is an empty string when itemInfo is a section - 2/11/2015 + if (itemInfo.MyTab != null && itemInfo.MyTab.Text != null && (itemInfo.MyTab.Text != "" || itemInfo.IsSection)) + { + float localXOffset = XOffset; + bool doprint = true; + if (itemInfo.IsSection) + { + MyItemInfo.ActiveSection = null; + MyItemInfo.MyDocStyle = null; + DocStyle ds = MyItemInfo.MyDocStyle; + + if (!ds.ComponentList && ShowSectionTitles + && !MyItemInfo.MyDocStyle.CancelSectTitle + && !MyItemInfo.MyDocStyle.SpecialStepsFoldout) // Don't ouput the Step Section title + { + if (MyItemInfo.MyConfig is SectionConfig sch && sch.Section_PrintHdr != "Y") + { + doprint = false; + YTopMost = 0; + } + } + else + doprint = false; + } + // if printing the supplemental info facing page, don't put out the section title. ToPdf will put out 'Supplemental Information' title. + if (MyPromsPrinter.SupInfoPrintType == E_SupInfoPrintType.Merge && MyPageHelper.CreatingSupInfoPage && itemInfo.IsSection) doprint = false; + if (doprint && itemInfo.IsSection && !itemInfo.MyDocStyle.CancelSectTitle && (itemInfo.MyConfig as SectionConfig).Section_IsFoldout != "Y") //C2019-042 Section_IsFoldout checks Section Number, Section Title, and use of check box + { + doSectTab = true; + if (itemInfo.IsStepSection && formatInfo.PlantFormat.FormatData.SectData.SectionNumber.Just.Contains("PSLeft")) + { + float offset = (float)itemInfo.MyDocStyle.Layout.LeftMargin; + if (formatInfo.PlantFormat.FormatData.SectData.SectionNumber.Pos != null) + { + ItemInfo iilvl = itemInfo; + while (!iilvl.IsProcedure) + { + // see if this metasection, walking up the tree, has its header printed, + // if so, indent for it. + SectionConfig sch1 = iilvl.MyConfig as SectionConfig; + if (sch1.Section_PrintHdr == "Y" || MyItemInfo.ActiveFormat.PlantFormat.FormatData.SectData.UseMetaSections) + MetaLevel++; + iilvl = iilvl.MyParent; + } + + if (formatInfo.PlantFormat.FormatData.PrintData.SpecialCaseCalvert) + { + if (MetaLevel == 1) + offset += (float)formatInfo.PlantFormat.FormatData.SectData.SectionNumber.Pos; + else + { + SectionConfig sc = itemInfo.MyParent.MyConfig as SectionConfig; + if (MyParent != null) + { + // if the parent is not printed, then adjust the xoffset based on + // the level of the metasection. Note that the 'if (MetaLevel==20) MetaLevel = 1' + // line of code was added so that the xoffsets between 16 & 32 bit are closer. + // This code was added to fix problems in BGE OI34, Appendix sections/subsection xoffsets. + if (sc != null && sc.Section_PrintHdr == "N") + { + if (MetaLevel == 2) MetaLevel = 1; + xMetaAdj = (float)formatInfo.PlantFormat.FormatData.SectData.MetaSectionList[0].ColSByLevel; + for (int i = 0; i < MetaLevel; i++) + { + xMetaAdj += (float)formatInfo.PlantFormat.FormatData.SectData.SectionHeader.Pos - (float)formatInfo.PlantFormat.FormatData.SectData.SectionNumber.Pos; + xMetaAdj += (float)formatInfo.PlantFormat.FormatData.SectData.MetaSectionList[i].SecNumPositionAdj; + } + offset += xMetaAdj; + } + else + { + offset = (sc != null && sc.SubSection_AutoIndent == "Y") ? MyParent.XOffset + : (MyParent.MyTab != null) ? MyParent.MyTab.XOffset : XOffset; + } + } + } + } + else + { + + MetaLevel = MetaLevel <= 2 ? 1 : MetaLevel - 1; + if (MetaLevel == 1) + offset += (float)formatInfo.PlantFormat.FormatData.SectData.SectionNumber.Pos; + else + { + xMetaAdj = (float)formatInfo.PlantFormat.FormatData.SectData.MetaSectionList[0].ColSByLevel; + for (int i = 0; i < MetaLevel; i++) + { + xMetaAdj += (float)formatInfo.PlantFormat.FormatData.SectData.SectionHeader.Pos - (float)formatInfo.PlantFormat.FormatData.SectData.SectionNumber.Pos; + xMetaAdj += (float)formatInfo.PlantFormat.FormatData.SectData.MetaSectionList[i].SecNumPositionAdj; + + } + offset += xMetaAdj; + itemInfo.MyTab.Text = itemInfo.MyTab.Text.TrimEnd(" ".ToCharArray()); + itemInfo.MyTab.CleanText = itemInfo.MyTab.CleanText.TrimEnd(" ".ToCharArray()); + if (((itemInfo.MyDocStyle.StructureStyle.Style & E_DocStructStyle.DSS_SameXOffSubsections) == E_DocStructStyle.DSS_SameXOffSubsections)) + offset += (float)formatInfo.PlantFormat.FormatData.SectData.SectionNumber.Pos; + } + } + } + localXOffset = offset; + } + } + if (!itemInfo.IsSection || doSectTab) + { + if (itemInfo.IsSupInfoPart) // get combined tab if on a supinfo facing page: + mytab = GetSupInfoTab(cb, itemInfo, yoff, doSectTab, localXOffset); + else if (itemInfo.MyTab.AltPrintTab != null) + mytab = new vlnTab(cb, this, itemInfo.MyTab.AltPrintTab, itemInfo.MyTab.AltPrintTab, localXOffset, yoff, itemInfo.MyTab.MyFont, doSectTab, StepRTB.MySymbolFontName, itemInfo.MyTab.RemovedStyleUnderline); + else + { + string clntxt = itemInfo.MyTab.CleanText; + if (!string.IsNullOrEmpty(itemInfo.FormatStepData?.TabData?.MacroEditTag) && itemInfo.FormatStepData.TabData.MacroEditTag == "_" && clntxt.StartsWith("_")) + clntxt = clntxt.Substring(1); + mytab = new vlnTab(cb, this, itemInfo.MyTab.Text, clntxt, localXOffset, yoff, itemInfo.MyTab.MyFont, doSectTab, StepRTB.MySymbolFontName, itemInfo.MyTab.RemovedStyleUnderline); + } + PartsLeft.Add(mytab); + if (mytab.MyMacro != null) PartsLeft.Add(mytab.MyMacro); + } + } + else if (itemInfo.IsSupInfoPart) // if it was an empty tab - it may have been a caution/note + { + mytab = GetSupInfoTab(cb, itemInfo, yoff, doSectTab, XOffset); + PartsLeft.Add(mytab); + } + // if this is the High Level RNO step (MyTopRNO) and we are numbering the RNO, adjust the xoffset to start the tab + // at the x location rather than starting the text at the x location: + AdjustWidth(itemInfo, maxRNO, formatInfo, mytab); + bool adjustAgain = ((itemInfo.MyTab != null && itemInfo.MyTab.Position == 0) || (itemInfo.MyPrevious != null && itemInfo.MyPrevious.FormatStepData != null && itemInfo.MyPrevious.FormatStepData.TabData.IsTransition)); + if (!itemInfo.IsSection && itemInfo.FormatStepData.NumberHighLevel && itemInfo.IsRNOPart && (MyTopRNO == null || itemInfo.ItemID == MyTopRNO.MyItemInfo.ItemID)) + { + // adjust the x-offset of the RNO to include the tab. + if (itemInfo.ActiveFormat.MyStepSectionLayoutData.RNOWidthSameAsHighParent) + { + vlnParagraph hls = GetHighLevelParagraph(); + float RnoOffset1 = ToInt(formatInfo.MyStepSectionLayoutData.ColRTable, maxRNO); + float offset = hls.Width + RnoOffset1 + hls.XOffset; +#pragma warning disable IDE0059 // Unnecessary assignment of a value - Kept for Debugging + vlnTab tb = hls.MyTab; +#pragma warning restore IDE0059 // Unnecessary assignment of a value + if (MyTopRNO == null) + Width -= (float)itemInfo.ActiveFormat.MyStepSectionLayoutData.SingleColumnRNOIndent; + offset -= Width; + float inc = offset - XOffset; + if (mytab != null) + mytab.XOffset += inc;// +(itemInfo.MyParent.IsHigh ? 6.8f : 0); + XOffset += inc; + adjustAgain = false; + } + else if (itemInfo.FormatStepData.AdjHighLevelTab != null && itemInfo.ColumnMode > 0) + // For Farley (only plant format to use AdjHighLevelTab), determine the xoffset based on + // where the right edge of the text is. Their RNO's are numbered with parent numbering + // so the calculations for determining the xoffset backs up from the right edge. + { + float rightTextEdge = this.MyHighLevelParagraph.XOffset + this.MyHighLevelParagraph.Width; + int colRx = int.Parse(formatInfo.MyStepSectionLayoutData.ColRTable.Split(",".ToCharArray())[itemInfo.ColumnMode]); + rightTextEdge += (colRx + (itemInfo.FormatStepData.AdjHighLevelTab ?? 0)); + float diff = rightTextEdge - (XOffset + Width); + if (mytab != null) mytab.XOffset += diff; + XOffset += diff; + adjustAgain = false; + } + else if (mytab != null) + { + float adjusttab = (itemInfo.MyParent.IsHigh) ? itemInfo.FormatStepData.AdjHighLevelTab ?? 0 : 0; + mytab.XOffset += (mytab.Width + adjusttab); + XOffset = mytab.XOffset + mytab.Width; + if (adjusttab != 0) Width += (mytab.Width); + } + } + if (adjustAgain) + { + AdjustXOffsetForTab(itemInfo, maxRNO, formatInfo, mytab, xMetaAdj); + // Used in Ginna's Attachment format. + // if the Note/Caution is off of a sub-step, then adjust the width so that the Caution/Note text box does not extend past the HLS text box + if (itemInfo.IsCautionOrNotePart && maxRNO == 0 && (itemInfo.ActiveSection != null && itemInfo.ActiveSection.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.LimitCautionNoteWidthToHLS)) // C2018-003 fixed use of getting the active section + { + float wMax = MyHighLevelParagraph.Width + MyHighLevelParagraph.XOffset - XOffset; + if (wMax < Width && (Width + XOffset > MyItemInfo.MyDocStyle.Layout.PageWidth)) Width = wMax; + } + } + + if (itemInfo.IsSection && MyParent == null && itemInfo.MyDocStyle.SupplementalInformation && MyPromsPrinter.SupInfoPrintType == E_SupInfoPrintType.Merge) + { + _SupInfoSection = new vlnParagraph(this, cb, itemInfo, xoff, yoff, rnoLevel, maxRNO, formatInfo, null, null, yoffRightParent, false, pp); + MyPromsPrinter.SupInfoPdfPageCount = -1; + } + // For Calvert Alarms: if within the CONDITION/RESPONSE table, indent by 1 character. + // Sequential substeps are ok because of the tab string, but items without a tab & other step + // types were writing over the CONDITION/RESPONSE vertical table line. This code uses + // 7.2 for the character size to match 16bit output. + if (itemInfo.IsStep && !itemInfo.IsSequential && !itemInfo.IsCaution && !itemInfo.IsNote && MyParent.HasCalvertMacro) + { + XOffset += 7.2f; + if (mytab != null) mytab.XOffset += 7.2f; + } + if ((itemInfo.IsCaution || (itemInfo.IsNote && !itemInfo.IsFootnote)) && (itemInfo.MyDocStyle.StructureStyle.Style & E_DocStructStyle.DoubleBoxHLS) == E_DocStructStyle.DoubleBoxHLS) + { + if (itemInfo.IsInRNO) + { + XOffset = MyTopRNO.MyTab != null ? MyTopRNO.MyTab.XOffset : MyTopRNO.XOffset; + Width = (float)itemInfo.MyDocStyle.Layout.PageWidth - XOffset - 10; + } + else + { + XOffset = MyHighLevelParagraph.MyTab.XOffset; + Width = MyHighLevelParagraph.MyTab.Width + MyHighLevelParagraph.Width - 6; // make width 1/2 char smaller so it doesn't touch line + } + } + if (UseTemplateWidthOrXOff(itemInfo)) + { + float txoff = GetWidthOrStartFromTemplate(itemInfo, itemInfo.ActiveFormat, false); + if (txoff > 0) XOffset = (float)itemInfo.MyDocStyle.Layout.LeftMargin + txoff; // GetWidthOrStartFromTemplate(itemInfo, itemInfo.ActiveFormat, false); + } + if (itemInfo.MyHeader != null && itemInfo.MyHeader.Text != null && !doSectTab) + yoff += SetHeader(this, cb, itemInfo, formatInfo); + else if (itemInfo.FormatStepData != null && itemInfo.FormatStepData.SeparateBox && itemInfo.FirstSibling.MyHeader != null && itemInfo.FirstSibling.MyHeader.Text != null) + yoff += SetHeader(this, cb, itemInfo.FirstSibling, formatInfo); + float yoffLeft = yoff; + if (ChildrenAbove != null) + ChildrenAbove.StepDesignator = null; //reset StepDesignator + if (DoSubs && itemInfo.Cautions != null && (!itemInfo.ActiveFormat.PlantFormat.FormatData.PrintData.SpecialCaseCalvertAlarm || itemInfo.Cautions[0].FormatStepData.Type != "Caution1") && !(itemInfo.IsCaution || itemInfo.IsNote)) + { + if (itemInfo.ActiveFormat.MyStepSectionLayoutData.Dev_Format) + { + // For deviations, the Cautions are always in the same place. + // Fix for Catawba E-1 deviation for step 10. Has note/caution off of a paragraph instead of HLS + if (loadChildren) yoffLeft = ChildrenLeft.Add(cb, itemInfo.Cautions, xoff, yoff, yoff, rnoLevel, maxRNO, formatInfo); + } + else + { + if (yoffRightParent > yoff && ((itemInfo.MyDocStyle.StructureStyle.Style & E_DocStructStyle.DoubleBoxHLS) != E_DocStructStyle.DoubleBoxHLS)) yoff = yoffRightParent; + if (loadChildren) yoff = ChildrenAbove.Add(cb, itemInfo.Cautions, xoff, yoff, yoff, rnoLevel, maxRNO, formatInfo); + } + } + if (DoSubs && itemInfo.Notes != null && !(itemInfo.IsCaution || itemInfo.IsNote)) + { + if (itemInfo.ActiveFormat.MyStepSectionLayoutData.Dev_Format) + { + // For deviations, the Cautions are always in the same place. + // Fix for Catawba E-1 deviation for step 10. Has note/caution off of a paragraph instead of HLS + float xoffDev = (float)itemInfo.MyDocStyle.Layout.LeftMargin + 6 + (float)(itemInfo.ActiveFormat.MyStepSectionLayoutData.WidT); + if (loadChildren) yoffLeft = Math.Max(yoffLeft, ChildrenLeft.Add(cb, itemInfo.Notes, xoffDev, yoff, yoff, rnoLevel, maxRNO, formatInfo)); + } + else + { + // Notes/Cautions span the page. If the right (RNO) column is below current yoff, use the + // yoff from this. Without this, an overlap of text between the note and the bottom of the + // RNO was occurring for FNP - Unit 2/AOP, AOP-4.0. + if (yoffRightParent > yoff && ((itemInfo.MyDocStyle.StructureStyle.Style & E_DocStructStyle.DoubleBoxHLS) != E_DocStructStyle.DoubleBoxHLS)) yoff = yoffRightParent; + if (loadChildren) + { + float yoffadj = 0; + if (itemInfo.IsTable && MyFlexGrid.BorderStyle == C1.Win.C1FlexGrid.Util.BaseControls.BorderStyleEnum.None && !MyFlexGrid.TopRowHasBorder()) + yoffadj = SixLinesPerInch; // adjust the yoffset if the note is off of a borderless table + yoff = ChildrenAbove.Add(cb, itemInfo.Notes, xoff, yoff + yoffadj, yoff + yoffadj, rnoLevel, maxRNO, formatInfo) - yoffadj; + } + } + } + if (itemInfo is StepInfo && ((itemInfo as StepInfo).MyConfig as StepConfig).Step_PreferredPagebreak) HasPrefPageBreak = true; + // The following adds supplemental information items to the SupInfoSection list off of the section level paragraph for printing + // of the sup info pdf. The SupInfoSection list is just a flat list of all supplemental information within the section. + if (MyPromsPrinter.SupInfoPrintType == E_SupInfoPrintType.Merge && loadChildren && itemInfo.SupInfos != null) + { + SupInfoSection.ChildrenBelow.Add(cb, itemInfo.SupInfos, XOffset, 0, 0, rnoLevel, maxRNO, formatInfo); + } + + // Without the following, BGE had gaps in y-direction if the AER/RNO both had cautions/notes. + // The only time this needs done is if caution/notes are printed in separate columns in dual + // column mode (used the DoubleBoxHLS BGE flag for this - if another plant needs this, make it + // a more generic flag). + if (itemInfo.IsRNOPart && ((itemInfo.MyDocStyle.StructureStyle.Style & E_DocStructStyle.DoubleBoxHLS) == E_DocStructStyle.DoubleBoxHLS) && + rnoLevel == maxRNO && ChildrenAbove.Count > 0 && MyParent.ChildrenAbove.Count > 0) + { + float yDeltaRno = yoff - yOffOrig; + float yDeltaAer = SixLinesPerInch + yOffOrig - MyParent.ChildrenAbove[0].YTopMost; + if (yDeltaRno > yDeltaAer) + { + foreach (vlnParagraph chlda in MyParent.ChildrenAbove) + { + chlda.AdjustYOffset(yDeltaAer - yDeltaRno); + } + foreach (vlnParagraph chld in ChildrenAbove) + chld.AdjustYOffset(yDeltaAer); + yoff -= yDeltaAer; + } + else + { + foreach (vlnParagraph chld in ChildrenAbove) + chld.AdjustYOffset(yDeltaRno); + yoff -= yDeltaRno; + } + } + // Comanche Peak uses CAUTION2 type to enter a Step Designator, which is placed to the left of the step number. + // The Step Designator information is saved during the processing of the Cautions (ChildrenAbove) + // defined in the vlnParagraphs class (of which ChildrenAbove is defined) + if (ChildrenAbove.StepDesignator != null) + { + string pref = ChildrenAbove.StepDesignator; + float colOvrd = (float)(ChildrenAbove.StepDesignatorColumn ?? 0); + float xPref = (colOvrd > 0) ? colOvrd : mytab.XOffset - (pref.Length * (72 / (float)MyItemInfo.FormatStepData.Font.CPI)); + PartsLeft.Add(new vlnText(cb, this, pref, pref, xPref, yoff, ChildrenAbove.StepDesignatorFont)); + ChildrenAbove.StepDesignator = null; + ChildrenAbove.StepDesignatorColumn = null; + } + DoAnnotationPrintableText(cb, itemInfo, yoff); // Look in annotation type to see if annotation has text that should be printed (like a step designator) + + // if this is a hls with a box, adjust the starting y location for the hls. this is done here + // in case this hls had a boxed caution and/or note before it. Also, this code is here rather + // than in the vlnparagraphs.add code because the yoff in that code will position the box, but + // this code positions the hls (in y direction), without this, the hls starts on the box line. + int bxIndx = itemInfo.IsSection ? 0 : itemInfo.FormatStepData.StepLayoutData.STBoxindex ?? 0; + if (itemInfo.IsHigh && bxIndx > 0) + { + int boxLnAdjust = itemInfo.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.StepSectionPrintData.DiffContActBox ? 1 : 2; + yoff += (boxLnAdjust * SixLinesPerInch); // this yoff is where the BOX starts (boxLnAdjust was added for WEP2) + } + + // If the format has that extra space should be put out before the step, then + // handle this by using the 'PartsAbove' structure. By using the parts above, the extra + // space above will be done regardless of where page breaks fall. + float addExtraSpace = 0; + if (MyItemInfo.FormatStepData != null && MyItemInfo.ActiveFormat.MyStepSectionLayoutData.CustomSpacing) + addExtraSpace = MyItemInfo.FormatStepData.StepLayoutData.STExtraSpace ?? 0; + if (MyItemInfo.MyParent != null && MyItemInfo.MyParent.FormatStepData != null) + addExtraSpace = (MyItemInfo.MyParent.FormatStepData.Type == "TitleWithTextRight" || MyItemInfo.FormatStepData == null) ? 0 : MyItemInfo.FormatStepData.StepLayoutData.STExtraSpace ?? 0; + // If a high level step, the 16bit code uses the value of the extra space + // from the high level step format regardless of what type of high level step it is: + // Added check for UseSTExtraRealValue, if set, we want to use what is set for the specific step type + // Added check for CustomSpacing (was also in 16-bit logic) + if (!MyItemInfo.ActiveFormat.MyStepSectionLayoutData.UseSTExtraRealValue && + !MyItemInfo.ActiveFormat.MyStepSectionLayoutData.CustomSpacing && + MyItemInfo.IsHigh) + addExtraSpace = MyItemInfo.ActiveFormat.PlantFormat.FormatData.StepDataList[2].StepLayoutData.STExtraSpace ?? 0; + // If CustomSpacing flag is true + // then use the STExtraSpace from the step type called "Default" (index number 25) + //if (YOffset != 0 && MyItemInfo.IsSection && MyItemInfo.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.StepSectionLayoutData.CustomSpacing) + if (YOffset != 0 && MyItemInfo.IsSection && MyItemInfo.ActiveFormat.MyStepSectionLayoutData.CustomSpacing) + addExtraSpace = (float)MyItemInfo.ActiveFormat.PlantFormat.FormatData.StepDataList[25].StepLayoutData.STExtraSpace; + if (YOffset != 0 && MyItemInfo.FormatStepData != null && + MyItemInfo.MyPrevious == null && MyItemInfo.FormatStepData.ThreeBlanksAbove && (!MyItemInfo.IsNote || MyItemInfo.MyParent.Cautions == null)) + addExtraSpace = 24; // already has one blank line above, added two more + // if this plant has the AlwaysUseExtraLines and there are notes/cautions above the hls, don't add in the + // extra space: + if (itemInfo.IsHigh && (itemInfo.Cautions != null || itemInfo.Notes != null)) + { + if ((itemInfo.Cautions != null && itemInfo.Cautions[0].FormatStepData.AlwaysUseExtraLines) || (itemInfo.Notes != null && itemInfo.Notes[0].FormatStepData.AlwaysUseExtraLines)) + addExtraSpace = 0; + // F2021-038: SHE/SHEA format - Less space after boxes + if (itemInfo.Cautions != null && itemInfo.Cautions[itemInfo.Cautions.Count - 1].FormatStepData.NoYBxAdjust) + addExtraSpace = 0; + if (itemInfo.Notes != null && itemInfo.Notes[itemInfo.Notes.Count - 1].FormatStepData.NoYBxAdjust) + addExtraSpace = 0; + } + // F2021-038: SHE/SHEA format - Less space after boxes. The following is for when a HLS has an RNO that has Cautions/Notes + if (itemInfo.IsHigh && itemInfo.RNOs != null) + { + if (itemInfo.RNOs[0].Notes != null && itemInfo.RNOs[0].Notes[0].FormatStepData.NoYBxAdjust) + addExtraSpace = 0; + if (itemInfo.RNOs[0].Cautions != null && itemInfo.RNOs[0].Cautions[0].FormatStepData.NoYBxAdjust) + addExtraSpace = 0; + } + if (addExtraSpace > 0 && MyItemInfo.FormatStepData != null) + { + // We need to strip out the underline style from the font before putting out + // the extra line. + VE_Font vf = MyItemInfo.FormatStepData.Font; + E_Style sty = (E_Style)vf.Style; + if ((sty & E_Style.Underline) != 0) + sty ^= E_Style.Underline; + vf = new VE_Font(vf.Family, (int)vf.Size, sty, (float)vf.CPI); + this.PartsAbove.Add(new vlnText(cb, this, " ", " ", 72, yoff, vf)); + } + + yoff += addExtraSpace; + + YTop = yoff; + YOffset = yoff; + if (mytab != null && mytab.SeparateBullet) + { + string identB = formatInfo.PlantFormat.FormatData.SectData.StepSectionData.IdentB; + vlnText myBullet = new vlnText(cb, this, identB, identB, XOffset - 12, YOffset, MyItemInfo.FormatStepData.TabData.Bullet.Font); + myBullet.Rtf = myBullet.Rtf.Replace("\u25CF", @"\f1\u9679?\f0 "); + PartsLeft.Add(myBullet); + } + if (itemInfo.MyTab != null && itemInfo.MyTab.AsteriskOffset != 0) + { + + // the '-24' in x-direction & '+4' in y-direction was used for the SHE format to get the continuous + // HLS's asterisk to match 16bit. The font size was set at 16 to make it match also: + VE_Font astFont = new VE_Font(MyItemInfo.FormatStepData.TabData.Font.Family, 16, E_Style.Bold, 10); + vlnText myAsterisk = new vlnText(cb, this, "*", "*", mytab.XOffset - 24, YOffset + 4, astFont); + PartsLeft.Add(myAsterisk); + } + if (itemInfo.IsRNOPart && rnoLevel > maxRNO) + { + // the DoubleSpace & SpaceDouble flags seem redundant. The 2nd line was added for foldout + // line spacing for IP2 foldouts (one example can be found in E-1) + if (!itemInfo.FormatStepData.SpaceDouble && itemInfo.MyParent.IsHigh) + { + // but it we are in single column mode, don't remove the blank line. (Wolf Creek Admin Instructions - wcn1) + if (itemInfo.ActiveSection != null && (itemInfo.ActiveSection as SectionInfo).SectionConfig.Section_ColumnMode != SectionConfig.SectionColumnMode.One) // C2018-003 fixed use of getting the active section + yoff = YOffset = yoff - SixLinesPerInch; + } + else if (itemInfo.FormatStepData.NoSpaceMultipleRNOs) yoff = YOffset = yoff - SixLinesPerInch; + if (itemInfo.FormatStepData.DoubleSpace && itemInfo.FormatStepData.SpaceDouble) yoff = YOffset = yoff + SixLinesPerInch; + } + AddMacros(itemInfo, mytab); + if (mytab != null) + { + mytab.YOffset = yoff; + if (mytab.MyMacro != null) mytab.MyMacro.YOffset = yoff; + } + // For background formats, HLS's or Caution or any Notes have tab on line and then text + // on line below (with space in between) + if (itemInfo.IsBackgroundStep() && itemInfo.MyTab != null && itemInfo.MyTab.AltPrintTab != null && itemInfo.MyTab.AltPrintTab.Trim() != "") + yoff = YOffset = yoff + (2 * SixLinesPerInch); + CheckOff co = itemInfo.GetCheckOffStep(); + float yForCheckoff = yoff; //0; - default checkoff row is same as FIRST line of text + // if dropCheckoff is true, then the checkoff is place on the same of row as the LAST line of text + bool dropCheckoff = itemInfo.ActiveFormat.PlantFormat.FormatData.ProcData.CheckOffData.DropCheckOff + || (co != null && co.DropCheckOff); + if (itemInfo.MyContent.MyGrid != null) + { + vlnCells.DefaultFont = itemInfo.FormatStepData.Font.WindowsFont;// Set the default text font based upon the format + int profileDepth1 = ProfileTimer.Push(">>>> Before vlnParagraph.Grid"); + //Use Static MyFlexGrid - BWD INST2 - FlexGrid Errors + MyFlexGrid.LoadGrid(itemInfo); + MyGrid = new vlnTable(MyFlexGrid, cb); + Height = MyGrid.Height; + Width = MyGrid.Width; + // Adjust the XOffset before determining if the table will overlap the RNO column RHM 20150529 + CalculateXOffsetGridOrFigure(itemInfo, formatInfo); + + yoff = AdjustLocIfLongerRNO(itemInfo, yoff, yoffRightParent); + // if the table does not have a border, only move down one line: + float yoffForBorder = 2 * SixLinesPerInch; + if (MyFlexGrid.BorderStyle == C1.Win.C1FlexGrid.Util.BaseControls.BorderStyleEnum.None && !MyFlexGrid.TopRowHasBorder()) + yoffForBorder -= SixLinesPerInch; + if (dropCheckoff) + yForCheckoff += Height - SixLinesPerInch; // place checkoff on last row of text + yoff += (Height + yoffForBorder); //(2 * SixLinesPerInch)); + yoff = (float)Math.Ceiling(yoff); + ProfileTimer.Pop(profileDepth1); + } + else if (itemInfo.IsRtfRaw) + { + CalculateXOffsetGridOrFigure(itemInfo, formatInfo); + YOffset = yoff; + yoff += Height * .6f; // .6 is used as a scale factor in RtfRawAt (rtf2pdf). Use it here too for moving down page after equation. + yoff = (float)Math.Ceiling(yoff); + yoff += AdjustForBlankLines(); + } + else if (itemInfo.IsFigure) // if a figure we've got to determine the size: + { + int profileDepth2 = ProfileTimer.Push(">>>> Before vlnParagraph.Figure"); + string erMsg = null; + if (itemInfo.MyContent.Text != null) // ro image + { + if (itemInfo.MyContent.Text != "") // also check for text, there is an RO image then: + { + ProcedureInfo proc = itemInfo.MyProcedure; + DocVersionInfo dvi = proc.MyDocVersion; + ROFstInfo rofst = dvi.DocVersionAssociations[0].MyROFst; + ROFSTLookup lookup = rofst.GetROFSTLookup(dvi); + string linkInfoText = itemInfo.MyContent.Text.Replace(@"\v ", ""); + Match m = Regex.Match(linkInfoText, @"(.*)[#]Link:([A-Za-z]*):(.*)"); + string val = null; + if (m.Length > 0) // if m.lengh is zero, then no match was found - no RO was entered in the figure substep + { + if (m.Groups.Count < 4) + { + //erMsg = "RO was not found during data migration."; + // added newlines in the RO number (shown in figure substep type with figure RO) + // if we are here, then there is no RO link information, use this number to find the RO image to print + val = string.Format("{0}\n{1}\n{2}\n{3}", + linkInfoText.Substring(0, linkInfoText.Length - 16), + linkInfoText.Substring(linkInfoText.Length - 16, 8), + linkInfoText.Substring(linkInfoText.Length - 8, 4), + linkInfoText.Substring(linkInfoText.Length - 4, 4)); + val = val.Replace(@"\u8209?", "-").Replace(@"\u9586?", @"\"); // replace dash and backslash symbols with dash and backslash characters + } + else + { + string[] subs = m.Groups[3].Value.Split(" ".ToCharArray()); + // B2022-088: Find Doc Ro button not working in Word Sections + val = lookup.GetRoChild(subs[1]).value; + if (val == null || val == "?") val = lookup.GetRoChild(subs[1].Substring(0, 12)).value; + if (val == "?") + { + erMsg = string.Format("Referenced Object does not exist."); + _MyLog.WarnFormat("\r\nMissing Referenced Object {0} in {1}", subs[1], itemInfo.ShortPath); + yoff += 2 * SixLinesPerInch; + } + } + } + GC.Collect(); // memory garbage collection (Regex memory bug) + if (val != null && val != "?") + { + string[] vals = val.Split("\n".ToCharArray()); + Width = Int32.Parse(vals[3], System.Globalization.NumberStyles.AllowHexSpecifier) * MyItemInfo.FormatStepData.Font.CharsToTwips; + int lines = Int32.Parse(vals[2], System.Globalization.NumberStyles.AllowHexSpecifier); + // Check that the Height of figure isn't too big to fit on the page, if it is + // set the Height to the printable part of page - Height of the HLS and an extra line + // for between HLS & figure. + float h1 = lines * SixLinesPerInch; + float h2 = RoughSizeOfPage - MyParent.Height - SixLinesPerInch; + Height = Math.Min(h1, h2); + if (h1 > h2) + { + Width *= (h2 / h1); + } + StepInfo si = (StepInfo)MyItemInfo; + StepConfig sc = new StepConfig(si.MyContent.Config); + if (sc != null && sc.Step_ImageWidth != 0) + { + Width = sc.Step_ImageWidth; + Height = sc.Step_ImageHeight; + } + yoff = AdjustLocIfLongerRNO(itemInfo, yoff, yoffRightParent); + if (dropCheckoff) + yForCheckoff += Height - SixLinesPerInch; // place checkoff on last row of text + bool noborder = MyItemInfo.FormatStepData.Type.ToUpper().Contains("BORDERLESS"); + yoff += (Height + ((noborder ? 1 : 2) * SixLinesPerInch)); // RHM 20120925 - Eliminate extra space after Figure } + try + { + ROImageInfo roImage = ROImageInfo.GetByROFstID_FileName(rofst.ROFstID, vals[0]); + if (roImage != null) + ImageText = val; + else + { + roImage = rofst.GetROImageByFilename(vals[0], MyItemInfo);// need code to go and get an ROImaage if it exists + if (roImage == null) + erMsg = string.Format("Image {0} does not exist.", vals[0]); + else + ImageText = val; + } + } + catch (Exception ex) + { + erMsg = string.Format("Image {0} does not exist, error = {1}.", vals[0], ex.Message); + } + } + if (erMsg != null) Rtf = GetRtf(erMsg, itemInfo.ActiveFormat.PlantFormat.FormatData.Font); + } + CalculateXOffsetGridOrFigure(itemInfo, formatInfo); + } + else + { + // figure + ImageText = "figure"; + } + if (ImageText == null && erMsg == null) + { + ImageText = "figure"; + ImageConfig ic = new ImageConfig(MyItemInfo.MyContent.MyImage); + // B2016-277: add a try catch in case of there being 'bad' data in the text field for an image/figure + try + { + byte[] idata = (ic != null && ic.Image_DataSize > 0) ? ROImageInfo.Decompress(MyItemInfo.MyContent.MyImage.Data, ic.Image_DataSize) : MyItemInfo.MyContent.MyImage.Data; + MemoryStream ms = new MemoryStream(idata); + System.Drawing.Image img = System.Drawing.Image.FromStream(ms); + Width = img.Width; + Height = img.Height; + if (ic != null && ic.Image_Height != 0) + { + Width = ic.Image_Width; + Height = ic.Image_Height; + + // B2022-041: extra whitespace after resized image. Make same adjustment here that gets made in ParagrphToPdf + // B2023-040: WCN pagination changed for And steps with large image after - add format flag for + // Barakah + if (MyItemInfo.ActiveFormat.PlantFormat.FormatData.PrintData.AdjustLargeImage) + { + float mult = 1.0F; + if (Width > (vlnParagraph.wMax - 12)) mult = (vlnParagraph.wMax - 24) / Width; + if (Height > (vlnParagraph.hMax - 36)) mult = Math.Min(mult, (vlnParagraph.hMax - 36) / Height); + if (mult < 1.0F) + { + Width *= mult; + Height *= mult; + } + } + } + yoff = AdjustLocIfLongerRNO(itemInfo, yoff, yoffRightParent); + bool noborder = MyItemInfo.FormatStepData.Type.ToUpper().Contains("BORDERLESS"); + yoff += (Height + SixLinesPerInch); // B2019-059 only one extra line after a figure (does not matter if it has a border or not) + CalculateXOffsetGridOrFigure(itemInfo, formatInfo); + } + catch (Exception) + { + _MyLog.WarnFormat("Bad figure content data: item = {0}, {1}", MyItemInfo.ItemID, MyItemInfo.ShortPath); + } + } + ProfileTimer.Pop(profileDepth2); + } + else + { + // For Calvert Alarms, the 'CONDITION/RESPONSE' portion uses a macro to print + // the CONDITION and RESPONSE text with the lines around it. Add the macro here because + // there is no tab for the step & that's where the macro is usually stored: + if (HasCalvertMacro) PartsLeft.Add(new vlnMacro(xoff - 12f, yoff, "H4")); + + if (itemInfo.IsStep && itemInfo.MyHLS != null && itemInfo.MyHLS.FormatStepData.UseSmartTemplate) + { + if (itemInfo.FormatStepData.StepLayoutData.AlignWithParentTab + || (itemInfo.Steps != null && itemInfo.Steps.Count > 0 && itemInfo.Steps[0].FormatStepData.StepLayoutData.AlignWithParentTab)) + { + int stplevl = TheStepLevel(itemInfo); + if (stplevl >= 0 && MyItemInfo.MyHLS.FormatStepData.VertPos[stplevl] > 0) + { + if (MyItemInfo.FormatStepData.StepPrintData.Justify == "Center") + { + string[] vertPos = MyItemInfo.MyHLS.FormatStepData.VertPos.Split(",".ToCharArray()); + float hloc = (float.Parse(vertPos[stplevl]) + ((float.Parse(vertPos[stplevl + 1]) - float.Parse(vertPos[stplevl])) / 2)); + Chunk chk = (Chunk)IParagraph.Chunks[0]; + hloc -= (chk.GetWidthPoint() / 2); + XOffset = hloc + (float)itemInfo.MyDocStyle.Layout.LeftMargin; + } + else + XOffset = float.Parse(MyItemInfo.MyHLS.FormatStepData.VertPos.Split(",".ToCharArray())[stplevl]) + (float)itemInfo.MyDocStyle.Layout.LeftMargin; + } + } + } + if (itemInfo.IsTablePart) // Not for grid, this is for old-style tables. + { + Width = GetTableWidth(cb, IParagraph, MyItemInfo.MyDocStyle.Layout.PageWidth); + CalculateXOffsetGridOrFigure(itemInfo, formatInfo); + } + else + if (itemInfo.FormatStepData != null && itemInfo.FormatStepData.StepPrintData != null && (itemInfo.IsHigh || (!itemInfo.IsHigh && itemInfo.MyContent.Type != itemInfo.MyParent.MyContent.Type))) XOffset += (float)(itemInfo.FormatStepData.StepPrintData.PosAdjust ?? 0); + + // point beach wpb subformats 20 & 22 were printing some text past right margin. Limit the width to the right margin, i.e. pagewid + if (itemInfo.ActiveFormat.MyStepSectionPrintData.LimitWidToPageWid) + { + float lim = (MyTab == null ? (XOffset - (float)itemInfo.MyDocStyle.Layout.LeftMargin) : MyTab.XOffset + MyTab.Width) + Width; + float docStyleLim = (float)itemInfo.MyDocStyle.Layout.PageWidth - (float)itemInfo.MyDocStyle.Layout.LeftMargin; + + if (lim > docStyleLim) + { + WidthNoLimit = Width; // Use this width to calculate childrens' width, without this, code was making children to narrow! + Width = docStyleLim - (MyTab == null ? (XOffset - (float)itemInfo.MyDocStyle.Layout.LeftMargin) : MyTab.XOffset + MyTab.Width); + } + } + if (itemInfo.IsSection && ShowSectionTitles + && !MyItemInfo.MyDocStyle.CancelSectTitle) + { + if (MyItemInfo.MyDocStyle.Layout.SectionMacro != null) + { + string macro = GetMacroName(MyItemInfo.MyDocStyle.Layout.SectionMacro); + PartsAbove.Add(new vlnMacro(xoff, yoff, macro)); + yoff += SixLinesPerInch; + YOffset = yoff; + } + } + + // if this step has a prefix but it's not checklist... do a partsleft for prefix + if (MyItemInfo.IsStep && !MyItemInfo.FormatStepData.UseSmartTemplate) + { + if (MyItemInfo.FormatStepData.Prefix != null && MyItemInfo.FormatStepData.Prefix != "") + { + string pref = MyItemInfo.FormatStepData.Prefix.Replace("{Backspace}", ""); + float xPref = XOffset - (pref.Length * (72 / (float)MyItemInfo.FormatStepData.Font.CPI)); + E_Style es = (E_Style)MyItemInfo.FormatStepData.Font.Style & E_Style.Bold; + VE_Font tmpFont = new VE_Font(MyItemInfo.FormatStepData.Font.Family, (int)MyItemInfo.FormatStepData.Font.Size, es, (float)MyItemInfo.FormatStepData.Font.CPI); + PartsLeft.Add(new vlnText(cb, this, pref, pref, xPref, yoff, tmpFont)); + } + } + // If checklists, the substeps are printed in a row, need to keep track of the 'longest' in + // y direction (bottommost) across the row. + if (itemInfo.IsStep && itemInfo.MyHLS != null && (itemInfo.MyHLS.FormatStepData.UseSmartTemplate || (itemInfo.MyHLS.FormatStepData.UseOldTemplate && itemInfo.MyDocStyle.ComponentList)) && (TheStepLevel(itemInfo) >= 0)) + savCheckListBottomMost = yoff + Height + (itemInfo.MyHLS.FormatStepData.UseSmartTemplate ? SixLinesPerInch : 0); + + // The following was added for BGE valve lists, this format (BGEVLV) used caution1 as + // a subheader within the valve list. To print correctly, a line needs to be added to + // where the bottom of this (subheader) is located and XOffset is set to the leftmargin. + if (itemInfo.IsStep && itemInfo.MyHLS != null && !itemInfo.ActiveFormat.PlantFormat.FormatData.PrintData.SpecialCaseCalvertAlarm && itemInfo.IsCaution1 && itemInfo.MyHLS.FormatStepData.UseOldTemplate && itemInfo.MyDocStyle.ComponentList) + { + savCheckListBottomMost += SixLinesPerInch; + yoff += Height; + XOffset = (float)itemInfo.MyDocStyle.Layout.LeftMargin; + } + + if (itemInfo.ActiveFormat.PlantFormat.FormatData.PrintData.SpecialCaseCalvertAlarm && itemInfo.IsCaution1) savCheckListBottomMost = yoff + Height; + // Get Y offset for regular steps, or if section title is output or if not within row (not last column of + // text) for wcn checklist, i.e. + if ((!itemInfo.IsStepSection && itemInfo.MyHLS != null && !itemInfo.MyHLS.FormatStepData.UseSmartTemplate) // regular step + || (ShowSectionTitles + && !MyItemInfo.MyDocStyle.CancelSectTitle + && !MyItemInfo.MyDocStyle.SpecialStepsFoldout) + // In Checklist: I don't have children or if I have children the first child doesn't alignwithparent. + || (!itemInfo.IsStepSection && itemInfo.MyHLS != null && itemInfo.MyHLS.FormatStepData.UseSmartTemplate + && ((itemInfo.Steps == null || itemInfo.Steps.Count == 0) + || !itemInfo.Steps[0].FormatStepData.StepLayoutData.AlignWithParentTab)) + || ((MyItemInfo.IsNote || MyItemInfo.IsCaution) && MyItemInfo.MyParent.IsSection)) // B2016-222 check if is a caution or note and parent is a section + { + bool doprint = !(MyPageHelper.DidHLSText && MyItemInfo.ItemID == MyPageHelper.HasHLSTextId); + if (MyItemInfo.IsSection) + { + if (MyItemInfo.MyConfig is SectionConfig sch && sch.Section_PrintHdr != "Y") doprint = false; + } + //C2025-021 Add logic to PROMS to support a special High Level Step type that is not printed. + if (doprint && !UseTemplateKeepOnCurLine(itemInfo) && !itemInfo.IsType("InvisibleHigh")) + { + float tyoff = yoff; + if (itemInfo.Steps != null) + { + if (itemInfo.FormatStepData != null && itemInfo.FormatStepData.Type == "TitleWithTextRight") + if (loadChildren) tyoff = ChildrenRight.Add(cb, itemInfo.Steps, XOffset + 72, yoff, yoff, rnoLevel, maxRNO, formatInfo); + } + yoff += Height; + yoff = Math.Max(yoff, tyoff); + yoff += AdjustForBlankLines(); + if (dropCheckoff) + yForCheckoff += Height - SixLinesPerInch; // place checkoff on last row of text + } + } + } + if (itemInfo.ActiveFormat.PlantFormat.FormatData.PrintData.SpecialCaseCalvertAlarm) + { + // For Calvert Alarms, the row has formatting that makes this template item have a header & box + // (CONDITION/RESPONSE), header with box around it is defined in genmac whereas the lines around + // substeps are drawn in pagehelper. Adjust some yoffsets around this box. + // Need to: + // 1) move the text down a bit for top line (1.5f * SixLinesPerInch) + // 2) move the substep down 2 lines (2 * SixLinesPerInch) for bottom of box + // and space before substep + // 3) if the previous item had this condition, add space for the + // line below. + if (HasCalvertMacro) + { + YOffset += (1.5f * vlnPrintObject.SixLinesPerInch); + yoff += (2 * vlnPrintObject.SixLinesPerInch); + } + if (itemInfo.MyPrevious != null && itemInfo.MyPrevious.TemplateIndex > 0) + { + if (itemInfo.MyPrevious.ActiveFormat.PlantFormat.FormatData.Templates[itemInfo.MyPrevious.TemplateIndex].hmacro > 0) + { + YOffset += (3 * vlnPrintObject.SixLinesPerInch); + yoff += (3 * vlnPrintObject.SixLinesPerInch); + } + } + } + if (co != null && !MyItemInfo.IsInSupInfo) // C2018-002: don't print checkboxes on supplemental infromation pages. + { + // if this item's content is empty, and the flag is set to 'notonempty', don't print out the + // checkoff - this was added for shearon harris: + if (!(co.NotOnEmpty && itemInfo.MyContent.Text.Replace(@"\u160?", " ").TrimEnd() == "")) + { + float xloc_co = (float)itemInfo.MyDocStyle.Layout.LeftMargin; + // if the format has 'SkipSpaces', look at the tab, and back up the macros to the number of + // spaces in the tab. + if (formatInfo.PlantFormat.FormatData.ProcData.CheckOffData.SkipSpaces) + { + if (mytab != null) + xloc_co = mytab.XOffset; + else + xloc_co = XOffset; //there's no tab - put checkoff at step's xoff. Macro should back up from step's x. + } + else + { + if (formatInfo.PlantFormat.FormatData.ProcData.CheckOffData.XLocation != 0) + xloc_co += (float)formatInfo.PlantFormat.FormatData.ProcData.CheckOffData.XLocation; + else if (formatInfo.PlantFormat.FormatData.ProcData.CheckOffData.RelXLocation != 0) + { + float relX = (float)formatInfo.PlantFormat.FormatData.ProcData.CheckOffData.RelXLocation; + xloc_co = XOffset + (relX > 0 ? Width : 0) + relX; + } + } + + // CheckOffXtraLines was introduced for the additional lines needed for the longer signoffs + // for VCBA (&WST1), for F2016-061. + float checkOffNumberOfLines = (co.CheckOffNumberOfLines ?? 0); + if (checkOffNumberOfLines > 0) + { + yForCheckoff += (2 * SixLinesPerInch); + PartsRight.Add(new vlnMacro(xloc_co, yForCheckoff/* + xtraCheckOffLines */, co.Macro)); + yoff += ((checkOffNumberOfLines *= SixLinesPerInch) + (2 * SixLinesPerInch)); + } + else + { + // if xtraCheckOffLines is a negative number, start the checkoff on the same line + // as text and adjust the y-offset after the checkoff by the amount of the absolute + // value of xtraCheckOffLines. + // if xtraCheckOffLines is a positive number, start the checkoff xtraCheckOffLines - 1 + // down from the text and adjust the y-offset after the checkoff by the amount + // of xtraCheckOffLines. + float xtraCheckOffLines = (co.CheckOffXtraLines ?? 0); + if (xtraCheckOffLines < 0) + { + xtraCheckOffLines = -xtraCheckOffLines; + xtraCheckOffLines *= SixLinesPerInch; + PartsRight.Add(new vlnMacro(xloc_co, yForCheckoff/* + xtraCheckOffLines */, co.Macro)); + yoff += xtraCheckOffLines; + } + else + { + xtraCheckOffLines *= SixLinesPerInch; + xtraCheckOffLines -= ((xtraCheckOffLines > 0) ? SixLinesPerInch : 0); + PartsRight.Add(new vlnMacro(xloc_co, yForCheckoff + xtraCheckOffLines, co.Macro)); + yoff += (xtraCheckOffLines != 0) ? xtraCheckOffLines + SixLinesPerInch : 0; + } + } + } + } + // for WCNTRN, do the responsibility: + if (formatInfo.PlantFormat.FormatData.PrintData.WCNTraining) DoResponsibility(cb, YOffset); + float yOffRight = yoff; + float RnoOffset = ToInt(formatInfo.MyStepSectionLayoutData.ColRTable, maxRNO); + if (DoSubs && rnoLevel < maxRNO && itemInfo.RNOs != null) + { + if (loadChildren) yOffRight = ChildrenRight.Add(cb, itemInfo.RNOs, XOffset + RnoOffset, YTop, YTop, rnoLevel + 1, maxRNO, formatInfo); + if (ChildrenRight[0].ChildrenAbove.Count > 0) + { + float adj = ChildrenRight[0].YOffset - YOffset; + YOffset = ChildrenRight[0].YOffset; + yoff += adj; + if (MyTab != null) MyTab.YOffset = ChildrenRight[0].YOffset; + if (PartsRight.Count > 0) PartsRight[0].YOffset = ChildrenRight[0].YOffset; + //B2020-160 use YTopMost instead of Yoffset if there are children above. + // Get the minimun value between the AER and RNO YtopMost. + // example. Calvert AOP-7E/XIII/Step A5.h Unit 2 Approved set + //B2021-027 use YOffset if there isn't any children above (AER). + // example: Catawba Unit 1 AP’s; AP/1/A/5500/050; Enclosure 8 step 1 + if (ChildrenAbove.Count == 0) + YTopMost = ChildrenRight[0].ChildrenAbove[0].YOffset; //B2021-027 + else + YTopMost = Math.Min(ChildrenAbove[0].YTopMost, ChildrenRight[0].ChildrenAbove[0].YTopMost); //B2020-160 + } + } + // if this hls had a box drawn, add a line for substeps. + if (itemInfo.IsHigh && ((itemInfo.MyDocStyle.StructureStyle.Style & E_DocStructStyle.DoubleBoxHLS) == E_DocStructStyle.DoubleBoxHLS)) yoff += vlnPrintObject.SixLinesPerInch; + + // Need code to determine if the table will overlap the Right Column if it does then + // use YOffRight rather than yoff + if (DoSubs && itemInfo.Tables != null) + { + bool aerTableOrFigure = itemInfo.Tables[0].FormatStepData.Type.Contains("AER"); + // get the first table & see if it is borderless. If borderless, 16bit code removed a + // line (yoffset) before printing it: + float yoffadj = 0; + if (itemInfo.Tables[0].IsTable) + { + MyFlexGrid.LoadGrid(itemInfo.Tables[0]); + // B2018-077 added check for caution and note parts in which case we want the blank line - fix for Calvert OI-27B 6.11.B and 6.12.B + if (MyFlexGrid.BorderStyle == C1.Win.C1FlexGrid.Util.BaseControls.BorderStyleEnum.None && !MyFlexGrid.TopRowHasBorder() && !MyItemInfo.IsCautionOrNotePart) + yoffadj = -SixLinesPerInch; + } + // B2023-008: when an equation is off a paragraph sub-step in single column mode, extra lines were added so + // when in single column mode & the substep has an equation (rtfraw), then don't reset yoffright to yverybottom + bool rtfRawInSingleCol = (itemInfo.ColumnMode == ((int)VEPROMS.CSLA.Library.SectionConfig.SectionColumnMode.One - 1)) && (itemInfo.Tables != null && itemInfo.Tables.Count > 0 && itemInfo.Tables[0].IsRtfRaw); + if (yOffRight < yoffRightParent) yOffRight = yoffRightParent; + // find the very bottom Yoffset (don't do this is in single column mode for cautions/notes: B2016-261) + vlnParagraph parentPar = parent; + if (!rtfRawInSingleCol && (!((MyItemInfo.IsCaution || MyItemInfo.IsNote) && itemInfo.RNOLevel == 0))) + { + while (parentPar != null && parentPar.MyItemInfo.IsStep) + { + float vb = parentPar.YVeryBottom; + if (yOffRight < vb) yOffRight = vb; + parentPar = parentPar.MyParent; + } + } + bool rightLonger = yOffRight > yoff; + if (!aerTableOrFigure && itemInfo.RNOLevel == 0) // Centered Table + { + if (loadChildren) + yoff = ChildrenBelow.Add(cb, itemInfo.Tables, XOffset, rightLonger ? yOffRight : yoff + yoffadj, yOffRight + yoffadj, rnoLevel, maxRNO, formatInfo); + } + else // AER or RNO Table + if (loadChildren) + yoff = ChildrenBelow.Add(cb, itemInfo.Tables, XOffset, yoff + yoffadj, yOffRight + yoffadj, rnoLevel, maxRNO, formatInfo); + } + yOffRight = Math.Max(yOffRight, yoffLeft); + // Look for the meta section case where the 'Editable' flag is set to 'N', which means that + // these steps should not be printed: + bool printsteps = true; + if (itemInfo.Steps != null && itemInfo.IsSection && itemInfo.Sections != null && itemInfo.Sections.Count > 0) + { + if (itemInfo.MyConfig is SectionConfig sc && sc.SubSection_Edit != "Y") printsteps = false; + } + bool rnoBefore = false; + bool rnoAfter = false; + if (rnoLevel >= maxRNO && itemInfo.RNOs != null && + !itemInfo.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.WolfCreekBackgroundFormat && + !itemInfo.RNOs[0].FormatStepData.InPageList) + { + if ((itemInfo.ActiveFormat.MyStepSectionPrintData.HLRNOStpSeparatorString ?? "") != "" || + (itemInfo.ActiveFormat.MyStepSectionPrintData.HLStpSeparatorString ?? "") != "") + rnoBefore = true; + else + rnoAfter = true; + } + if (rnoBefore) + { + if ((itemInfo.ActiveFormat.MyStepSectionPrintData.HLStpSeparatorString ?? "") != "") + { + string tmpSepStr = itemInfo.ActiveFormat.MyStepSectionPrintData.HLStpSeparatorString; + float xsep = MyHighLevelParagraph.PartsLeft.Count > 0 ? MyHighLevelParagraph.PartsLeft[0].XOffset : MyHighLevelParagraph.XOffset; + vlnRNOSeparator mySep = new vlnRNOSeparator(this, cb, tmpSepStr, xsep, yoff, itemInfo.ActiveFormat, false); + PartsBelow.Add(mySep); + yoff += mySep.Height;// +SixLinesPerInch; + } + if (loadChildren) yoff = ChildrenBelow.Add(cb, itemInfo.RNOs, MyTab.XOffset, yoff, yoff, rnoLevel + 1, maxRNO, formatInfo); + if ((itemInfo.ActiveFormat.MyStepSectionPrintData.HLRNOStpSeparatorString ?? "") != "") + { + string tmpSepStr = itemInfo.ActiveFormat.MyStepSectionPrintData.HLRNOStpSeparatorString; + float xsep = MyHighLevelParagraph.PartsLeft.Count > 0 ? MyHighLevelParagraph.PartsLeft[0].XOffset : MyHighLevelParagraph.XOffset; + vlnRNOSeparator mySep = new vlnRNOSeparator(this, cb, tmpSepStr, xsep, yoff, itemInfo.ActiveFormat, false); + PartsBelow.Add(mySep); + yoff += mySep.Height;// +SixLinesPerInch; + } + } + // For Calvert Alarms, 'Caution1' was used to implement the Annunciator Window, i.e. is printed + // below the HLS and close to the right margin. + if (itemInfo.ActiveFormat.PlantFormat.FormatData.PrintData.SpecialCaseCalvertAlarm && itemInfo.Cautions != null && itemInfo.Cautions[0].FormatStepData.Type == "Caution1") + { + if (loadChildren) + yoff = ChildrenBelow.Add(cb, itemInfo.Cautions, xoff, yoff, yoff, rnoLevel, maxRNO, formatInfo); + savCheckListBottomMost = yoff; + } + if (DoSubs && itemInfo.Steps != null && printsteps) + { + if (itemInfo.FormatStepData == null || itemInfo.FormatStepData.Type != "TitleWithTextRight") + if (rnoBefore) + { + if (loadChildren) + yoff = ChildrenBelow.Add(cb, itemInfo.Steps, MyTab.XOffset, yoff, yOffRight, rnoLevel, maxRNO, formatInfo); + } + else + if (loadChildren) yoff = ChildrenBelow.Add(cb, itemInfo.Steps, XOffset, yoff, yOffRight, rnoLevel, maxRNO, formatInfo); + } + if (itemInfo.Sections != null) + if (loadChildren) + yoff = ChildrenBelow.Add(cb, itemInfo.Sections, xoff, yoff, yoff, rnoLevel, maxRNO, formatInfo, pp); + if (itemInfo.Procedures != null) + if (loadChildren) + yoff = ChildrenBelow.Add(cb, itemInfo.Procedures, xoff, yoff, yoff, rnoLevel, maxRNO, formatInfo); + // Don't add the RNO to print if doing backgrounds. That piece of data is part of the pagelist item. + if (rnoAfter) + if (loadChildren) + yoff = ChildrenBelow.Add(cb, itemInfo.RNOs, XOffset, yoff, yoff, rnoLevel + 1, maxRNO, formatInfo); + YBottomPagination = yoff;// B2019-111 Exclude Right for Pagination + yoff = Math.Max(yoff, yOffRight); + // TODO - use RNOSepAfterAER flag too: + string tmpRnoSepStr = formatInfo.MyStepSectionPrintData.RNOSepString; + float tmpRnoSepLen = formatInfo.MyStepSectionPrintData.RNOSepLineLength ?? 0; + if (rnoLevel < maxRNO && itemInfo.RNOs != null && (tmpRnoSepStr != null || tmpRnoSepLen != 0)) + { + vlnParagraph rno = ChildrenRight[0]; + vlnParagraph bottomChild = BottomChild; + float xsep = MyHighLevelParagraph.XOffset + RnoOffset; + + // ip3 has an rno separator and also has asterisk boxes around continous HLS. If + // the hls has RNOs off of it, then the rno separator line is outside of the box. If + // there are RNOs, but not off of HLS, then rno separator line is within the box (this is + // how 16bit proms did this). The following use of yadjSep and YBottomForBox handle that + float yadjSep = (MyItemInfo.MyHLS.FormatStepData.StepLayoutData.STBoxindex != null && MyItemInfo.MyHLS.FormatStepData.StepLayoutData.STBoxindex >= 0 && + MyItemInfo.MyHLS.RNOs != null && MyItemInfo.MyHLS.RNOs.Count > 0) ? 2 * SixLinesPerInch : 0; + vlnRNOSeparator myRnoSep = new vlnRNOSeparator(this, cb, tmpRnoSepStr, xsep, yoff + yadjSep, formatInfo, bottomChild == null || bottomChild.MyItemInfo.HasChangeBar); + // TODO: May need to handle more than one RNO column for RNO Separator + if ((rno.LastRNO.MyItemInfo.HasChangeBar == false && bottomChild != null && bottomChild.MyItemInfo.HasChangeBar) + || (bottomChild != null && bottomChild.YBottom > rno.LastRNO.YBottomMost)) + bottomChild.PartsBelow.Add(myRnoSep); + else + rno.LastRNO.PartsBelow.Add(myRnoSep); + MyHighLevelParagraph.YBottomForBox = 0; + if (yadjSep > 0) + { + MyHighLevelParagraph.YBottomForBox = yoff; // if hlrno, box before sep + YBottomMostAdjust = SixLinesPerInch; // added for IP3 pagination, the RNO separator is outside asterisk box + } + yoff += (myRnoSep.Height + SixLinesPerInch); + } + // if in WCNTRN (Wolf Creek Training), need to consider the ysize of the Responsibility text when setting + // YBottomMost, i.e. if the Responsibilty has more height (y-direction) compared to the actual step text, + // need to move down on page the height of the responsibility. + if (formatInfo.PlantFormat.FormatData.PrintData.WCNTraining && MyItemInfo.IsHigh) + { + if (PartsLeft.Count > 0 && PartsLeft[0] is vlnText) + { + foreach (vlnText vt in PartsLeft.OfType()) + yoff = Math.Max(yoff, vt.YOffset + vt.Height); + } + } + YBottomMost = yoff; + + if ((MyItemInfo.IsHigh || MyItemInfo.IsCaution1) && MyItemInfo.MyDocStyle.LandscapePageList && MyItemInfo.MyDocStyle.ComponentList) + { + // put out line after step (for BGEVLV format) + float macroY = YBottomMost - (0.25f * SixLinesPerInch); + PartsLeft.Add(new vlnMacro((float)MyItemInfo.MyDocStyle.Layout.LeftMargin, macroY, "B9")); + } + + // For Checklist, the substeps are in rows of data. The YBottomMost is the bottom most for + // the row. + if (savCheckListBottomMost != 0) YBottomMost = Math.Max(savCheckListBottomMost, YBottomMost); + if (XOffsetCenter != null) XOffset = (float)XOffsetCenter; + ProfileTimer.Pop(profileDepth); + } + + private vlnTab GetSupInfoTab(PdfContentByte cb, ItemInfo itemInfo, float yoff, bool doSectTab, float localXOffset) + { + string strmytab; + if (itemInfo.MyParent.IsHigh) + strmytab = itemInfo.MyTab.CleanText; + else if (itemInfo.MyParent.IsCaution) + strmytab = "Caution"; + else if (itemInfo.MyParent.IsNote) + strmytab = "Note"; + else + { + // B2018-022: use flag to determine whether to pre-pend the parent's tab as part of the supplemental info tab + // (if the procedure tab is long, such as in Farley, the tab overwrites text in the supplemental info pages) + strmytab = itemInfo.ActiveSection.ActiveFormat.PlantFormat.FormatData.PrintData.SupInfoIncludeParTab + ? ItemInfo.GetCombinedTab(itemInfo.MyParent, itemInfo.MyParent.MyParent.CombinedTab) + : itemInfo.MyTab.CleanText; + } + strmytab = strmytab.Trim(); + return new vlnTab(cb, this, strmytab, strmytab, localXOffset, yoff, itemInfo.MyTab.MyFont, doSectTab, StepRTB.MySymbolFontName, itemInfo.MyTab.RemovedStyleUnderline); + } + + public static VE_Font AnnotationFont { get; set; } + + // Check to see if the procedure has any printable text in the annotations + private bool? _CanDoPrintableText = null; + public bool CanDoPrintableText + { + get + { + if (_CanDoPrintableText == null) + { + _CanDoPrintableText = false; + AnnotationTypeInfoList atil = AnnotationTypeInfoList.Get(); + foreach (AnnotationTypeInfo ati in atil) + { + AnnotationTypeConfig atc = new AnnotationTypeConfig(ati.Config); + if (atc.PrintableText_XLocation != 0) + { + _CanDoPrintableText = true; + break; + } + } + } + return (bool)_CanDoPrintableText; + } + } + private void DoAnnotationPrintableText(PdfContentByte cb, ItemInfo itemInfo, float yoff) + { + // check to see if this procedure has any printable annotations. + // if it does not, then there is no need to spin through checking for the given itemInfo + if (!CanDoPrintableText) return; + + // if this step has an Annotation and it has config data to define location, parse out '[xx]' and print it at the location + // this was added for VC Summer (unit 2 & 3) but is available for any data that has defined the location in the config (from the folder properties + // at the top node - annotationtype tab. + if (itemInfo.ItemAnnotationCount > 0) + { + foreach (AnnotationInfo ai in itemInfo.ItemAnnotations) + { + // get the annotation type from the annotation, and see if it has a print location: + AnnotationTypeInfo at = ai.MyAnnotationType; + AnnotationTypeConfig atc = new AnnotationTypeConfig(at.Config); + if (atc.PrintableText_XLocation != 0) + { + int st = ai.SearchText.IndexOf("["); + int end = ai.SearchText.IndexOf("]"); + if (st != -1 && end != -1 && end > st) + { + string pref = ai.SearchText.Substring(st + 1, end - st - 1); // annotation - parse out [xx] + pref = Regex.Replace(pref, "{Up}", @"\u8593?", RegexOptions.IgnoreCase); + pref = Regex.Replace(pref, "{Down}", @"\u8595?", RegexOptions.IgnoreCase); + float xPref = atc.PrintableText_XLocation; + if (AnnotationFont == null) + AnnotationFont = new VE_Font(MyItemInfo.FormatStepData.Font.Family, 6, (E_Style)MyItemInfo.FormatStepData.Font.Style, 20F); + PartsLeft.Add(new vlnText(cb, this, pref, pref, xPref, yoff, AnnotationFont)); + break; + } + } + } + } + } + + private float AdjustLocIfLongerRNO(ItemInfo itemInfo, float yoff, float yoffRightParent) + { + if (!itemInfo.IsInRNO && yoffRightParent > yoff && itemInfo.FormatStepData.Type.Contains("AER")) + { + // is the width of this table going to cause the table to overlap the RNO + vlnParagraph parRno = FindParentRNO(); + float xMinRno = FindMinXOffsetRno(parRno); + if (XOffset + Width > xMinRno - 12) // 12 = 2 characters, so that tables don't almost touch & look like an overlap + { + if ((float)MyItemInfo.MyDocStyle.Layout.LeftMargin + Width > xMinRno) + { + yoff = yoffRightParent; + YOffset = yoff; + } + else + XOffset = (float)MyItemInfo.MyDocStyle.Layout.LeftMargin; + } + } + return yoff; + } + private float FindMinXOffsetRno(vlnParagraph parRno) + { + // Find the minimum xoffset in the rno column that overlaps in the y direction with + // the table that is currently being processed. This is necessary in order to fix the + // case where the AER table overlaps an RNO table (or tab/text) + float xcur = 0; + // YOffset/Height is for the current table, check it against the rno's yoffset & height + // if aer & rno are within y range of each other + if (YOffset <= (parRno.YOffset + parRno.Height) && (YOffset + Height) >= parRno.YOffset) + { + xcur = parRno.XOffset; + if (parRno.MyTab != null) xcur = parRno.MyTab.XOffset; + } + // recursively look at steps in the rno column to get the smallest xoffset which will + // then be used to compare to table's xoffset/width to see if there is an overlap + if (parRno.ChildrenBelow != null) + { + foreach (vlnParagraph vp in parRno.ChildrenBelow) + { + // yoffset is past where the table is, so don't consider it: + if (vp.YOffset > (YOffset + Height)) return xcur; + + float xchild = FindMinXOffsetRno(vp); + if (xchild > 0 && (xcur == 0 || xchild < xcur)) + xcur = xchild; + } + } + return xcur; + } + private void DoResponsibility(PdfContentByte cb, float yoff) // WCNTRN's text in 1st column (saved in config for HLS) + { + if (MyItemInfo.MyConfig is StepConfig sc2) + { + string resp = sc2.Step_Responsibility; + + if (resp != null && resp != "") // lines are separated by "\r\n" + { + resp = DelimitResponse((int)MyItemInfo.MyDocStyle.SectTop.MaxLen, resp); + if (!resp.EndsWith("\r\n")) resp += "\r\n"; // parsing needs this. + int indx = resp.IndexOf("\r\n"); + int stindx = 0; + float y = yoff; + while (indx > -1) + { + string subresp = resp.Substring(stindx, indx - stindx); + float respWidth = subresp.Length * 6; + float ctr = (float)MyItemInfo.MyDocStyle.SectTop.Margin; + float respcntrX = (float)MyItemInfo.MyDocStyle.Layout.LeftMargin + ctr - (respWidth / 2); + vlnText myResp = new vlnText(cb, this, subresp, subresp, respcntrX, y, MyItemInfo.FormatStepData.Font); + PartsLeft.Add(myResp); + y += SixLinesPerInch; + stindx = indx + 2; + indx = stindx < resp.Length ? resp.IndexOf("\r\n", stindx) : -1; + } + } + } + } + private string DelimitResponse(int maxLen, string responsStr) + { + // This code handles whether user enters \r\n to separate lines or not. The + // max width that a line can be in the Responsibility column is a format flag (passed in) + List results = new List(); + int width = 0; // keep track of current width of current 'line' while looking for space to break + int start = 0; // start of line (index into string 'text') + int lastspace = 0; // location of lastspace (index into string) + for (int indx = 0; indx < responsStr.Length; indx++) + { + if ((indx + 1) < responsStr.Length && responsStr.Substring(indx, 2) == "\r\n") + { + results.Add($"{responsStr.Substring(start, indx - start).Trim(" ".ToCharArray())}\r\n"); + start = indx + 2; + width = 0; + } + else + { + if (responsStr[indx] == ' ') lastspace = indx; + width++; + if (width > maxLen) + { + // what should be done if lastspace == 0 + // cannot find space char to split on, so break the word + bool spFound = true; + if (lastspace == 0) + { + lastspace = indx; + spFound = false; + } + results.Add($"{responsStr.Substring(start, lastspace - start).Trim(" ".ToCharArray())}\r\n"); + start = lastspace + (spFound ? 1 : 0); // increment start based on whether a space is found, i.e. if no space keep at 'indx' + // width either is equal to width of text after the last space, or is zero if at the maxlen of width: + width = (indx - lastspace - 1) > 0 ? indx - lastspace - 1 : 0; + lastspace = 0; + } + } + } + if (width > 0 || start < responsStr.Length) results.Add(responsStr.Substring(start).Trim(" ".ToCharArray())); + string retval = null; + foreach (string st in results) retval += st; + return retval; + } + public override string Rtf + { + get + { + if (_Rtf == null) BuildRtf(); + return _Rtf; + } + set { _Rtf = value; } + } + private void BuildRtf() + { + int profileDepth = ProfileTimer.Push(">>>> BuildRtf"); + if (_Rtf == null) + { + if (MyItemInfo.ActiveFormat.PlantFormat.FormatData.PrintData.SpecialCaseCalvertAlarm && MyItemInfo.IsCaution1 && + MyItemInfo.MyContent.Text.StartsWith(@"\u") && !MyItemInfo.MyContent.Text.StartsWith(@"\u160?")) + { + Rtf = GetRtf(MyItemInfo, " " + (Prefix ?? ""), Suffix); + PrefixSpecialCharacter = true; + } + else + { + Rtf = GetRtf(MyItemInfo, Prefix, Suffix); + } + // Need the following with some modifications for WCNCKL format: + if (Rtf.Contains("{Backspace}")) + { + XOffset -= 25; + Width += 24; + Rtf = Rtf.Replace("{Backspace}", ""); + } + } + Rtf = FixRTFToPrint(MyItemInfo, Rtf); + ProfileTimer.Pop(profileDepth); + } + // C2018-024 I in Arial font changed to I in TimesNewRoman + private static System.Drawing.Font _TNR; + // F2018-013 Changed to static and public so that it can be used with step identifiers for bullets + public static string FixRTFToPrint(ItemInfo myItemInfo, string rtf) + { + // Only do this if the text contains symbols. + if ((rtf.Contains("VESymbFix") || rtf.Contains(Volian.Base.Library.vlnFont.ProportionalSymbolFont))) // C2017-036 get best available proportional font for symbols + { + // bug fix: B2017-117 was getting an out of window handles error when doing a print all for Bryon + // add the using statment to free up window handle that is created doing a New RichTextBox() + using (System.Windows.Forms.RichTextBox rtb = new System.Windows.Forms.RichTextBox()) + { + rtb.Rtf = rtf.Replace(@"\\", ""); // rename backslash character to avoid RTF confusion + //string showRTF = rtf; + bool changed = false; + // C2018-024 I in Arial font changed to I in TimesNewRoman + if (myItemInfo.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.ChangeFontUpperCaseIinArial) + { + bool lastWasNumber = false; + for (int i = 0; i < rtb.TextLength - 1; i++) + { + rtb.Select(i, 2); + if (rtb.SelectionLength == 2) + { + if ((rtb.SelectedText == ".I") && rtb.SelectionFont.FontFamily.Name == "Arial") + { + if (_TNR == null) + _TNR = new System.Drawing.Font("Times New Roman", rtb.SelectionFont.Size, rtb.SelectionFont.Style); + if (lastWasNumber) + { + rtb.SelectionFont = _TNR; + changed = true; + lastWasNumber = false; + } + } + else + lastWasNumber = Regex.IsMatch(rtb.SelectedText, @"[0-9]\."); + } + } + } + // C2017-008 - WCN wants the box symbol to look like their checkoff/signoff box + // Check for a list of replacement character for symbols in the format file + // ReplaceSymbolChars lets you do one or more of the following with a symbol character: + // - change the point size + // - change the style + // - change the font family + // - change the symbol character + // + // below is taken from the BaseAll format file - is currently commentout and there for reference + // Wolf Creek (WCN) currently uses this to increase the size of the box symbol + // + // + // + // + // get the list of symbol replacements + FormatData fmtdata = (myItemInfo.ActiveFormat != null) ? myItemInfo.ActiveFormat.PlantFormat.FormatData : FormatInfo.PROMSBaseFormat.FormatData; + ReplaceSymbolCharList SymReplaceList = (fmtdata != null && fmtdata.SectData.ReplaceSymbolCharList != null) ? fmtdata.SectData.ReplaceSymbolCharList : null; + // Look at one character at a time + for (int i = 0; i < rtb.TextLength; i++) + { + rtb.Select(i, 1); + if ((rtb.SelectedRtf.Contains("VESymbFix") || rtb.SelectedRtf.Contains(Volian.Base.Library.vlnFont.ProportionalSymbolFont)) && rtb.SelectedText.Length > 0) // C2017-036 get best available proportional font for symbols + { + for (int j = 0; j < SymReplaceList.MaxIndex; j++) + { + ReplaceChar rc = SymReplaceList[j]; + if (rc.Unicode != null && (rc.Family != null || rc.Size != null || rc.Style != null)) + { + char rc_uchar = Convert.ToChar(Convert.ToInt32(rc.Unicode)); + if (rc_uchar == rtb.SelectedText[0]) + { + //use bolding underline italics from local font + System.Drawing.Font fnt = rtb.SelectionFont; + // follow through in fixing an Out of Window Handles bug, use new function to see if + // we can retrieve the font from a dictionary instead a doing a New and using another + // window handle B2017-117 + //System.Drawing.Font fntw = new System.Drawing.Font((rc.Family != null) ? rc.Family : fnt.FontFamily.Name, (rc.Size != null) ? (float)rc.Size : fnt.Size, (rc.Style != null) ? (System.Drawing.FontStyle)rc.Style : fnt.Style); + System.Drawing.Font fntw = VE_Font.GetWinSysFont(rc.Family ?? fnt.FontFamily.Name, (rc.Size != null) ? (float)rc.Size : fnt.Size, (rc.Style != null) ? (System.Drawing.FontStyle)rc.Style : fnt.Style); + rtb.SelectionFont = fntw; + if (rc.Replace != null) + { + char rc_RplChar = Convert.ToChar(Convert.ToInt32(rc.Replace)); + rtb.SelectedText = rc_RplChar.ToString(); + } + changed = true; + break; // break out of foreach loop since we changed the character + } + } + } + } + } + if (changed) + { + if (rtb.Rtf.EndsWith(" \\par\r\n}\r\n") && rtf.EndsWith(" }")) //B2018-060 rtb.RTF added extra new line characters and commands to the end. so remove it. + rtf = rtb.Rtf.Replace(" \\par\r\n}\r\n", " }"); + else + rtf = rtb.Rtf; + return rtf.Replace("", @"\\"); // put back the backslash character + } + } + } + return rtf; + } + + // for Calvert (BGE) alarms, some step text is kept on the same line as its parent. This + // is flagged by the -1 row in the template definition. + private bool KeepOnParentLine(ItemInfo itemInfo) + { + int tindx = itemInfo.TemplateIndex; + if (tindx < 0) return false; + if (itemInfo.ActiveFormat.PlantFormat.FormatData.Templates[tindx].row == -1) return true; + return false; + } + + private void AdjustYOffset(float yDelta) + { + YOffset -= yDelta; + foreach (vlnPrintObject vpo in PartsAbove) + vpo.YOffset -= yDelta; + foreach (vlnParagraph vp in ChildrenBelow) + vp.AdjustYOffset(yDelta); + } + + private void BuildPlacekeeper(vlnParagraph parent, ItemInfo itemInfo) + { + if (itemInfo is SectionInfo && (itemInfo as SectionInfo).SectionConfig.Section_Placekeeper.ToUpper() != "N") // if is a section type and the section is marked to create placekeeper + { + MyPlaceKeeper = new pkParagraph(this); + if (parent != null && parent.MyItemInfo.IsSection) + parent.MyPlaceKeeper = MyPlaceKeeper; + } + else if (parent != null && parent.MyPlaceKeeper != null && itemInfo is StepInfo)//InList(parent.MyItemInfo.ItemID, 513, 514, 519, 520, 525)) + { + if (itemInfo.MyConfig is StepConfig sc && sc.Step_Placekeeper.ToUpper() != "N") + { + if (itemInfo.IsCautionPart || itemInfo.IsNotePart) + MyPlaceKeeper = parent.MyPlaceKeeper.AddCautionsAndNotes(this); + else + MyPlaceKeeper = parent.MyPlaceKeeper.AddChild(this); + } + } + } + + private void BuildContinuousActionSummary(vlnParagraph parent, ItemInfo itemInfo) + { + if (itemInfo is SectionInfo) + { + MyContAct = new pkParagraph(this); + if (parent != null && parent.MyItemInfo.IsSection) + parent.MyContAct = MyContAct; + } + else if (itemInfo is StepInfo) + { + StepConfig sc = itemInfo.MyConfig as StepConfig; + if ((sc != null && sc.Step_CAS == "True") || ((sc == null || sc.Step_CAS == null) && itemInfo.IncludeOnContActSum)) + { + // save this step info for use on the Continuous Action Summary + vlnParagraph tparent = parent; + while (tparent != null && tparent.MyContAct == null) + tparent = tparent.MyParent; + if (parent.MyContAct != null) + { + if (itemInfo.IsCautionPart || itemInfo.IsNotePart) + MyContAct = parent.MyContAct.AddCautionsAndNotes(this); + else + MyContAct = parent.MyContAct.AddChild(this); + } + else + MyContAct = tparent.MyContAct.AddChild(this); + } + } + } + private void BuildTimeCriticalActionSummary(vlnParagraph parent, ItemInfo itemInfo) + { + if (itemInfo is SectionInfo) + { + MyTimeCriticalAction = new pkParagraph(this); + if (parent != null && parent.MyItemInfo.IsSection) + parent.MyTimeCriticalAction = MyTimeCriticalAction; + } + else if (itemInfo is StepInfo) + { + StepConfig sc = itemInfo.MyConfig as StepConfig; + if ((sc != null && sc.Step_TCAS == "True") || ((sc == null || sc.Step_TCAS == null) && itemInfo.IncludeOnTimeCriticalActionSum)) + { + // save this step info for use on the Continuous Action Summary + vlnParagraph tparent = parent; + while (tparent != null && tparent.MyTimeCriticalAction == null) + tparent = tparent.MyParent; + if (parent.MyTimeCriticalAction != null) + { + if (itemInfo.IsCautionPart || itemInfo.IsNotePart) + MyTimeCriticalAction = parent.MyTimeCriticalAction.AddCautionsAndNotes(this); + else + MyTimeCriticalAction = parent.MyTimeCriticalAction.AddChild(this); + } + else + MyTimeCriticalAction = tparent.MyTimeCriticalAction.AddChild(this); + } + } + } + + private vlnParagraph FindParentRNO() => ChildrenRight != null && ChildrenRight.Count > 0 ? ChildrenRight[0] : MyParent.FindParentRNO(); + + private string GetMacroName(string str) => str.Substring(str.IndexOf(@"{!") + 2, str.Length - 3); + + private int TheStepLevel(ItemInfo itemInfo) + { + if (itemInfo.IsHigh) return -1; + int lev = 0; + ItemInfo ii = itemInfo; + while (!ii.MyParent.IsHigh) + { + lev++; + ii = ii.MyParent; + } + return lev; + } + + private void DoCheckOffHeader(PdfContentByte cb, ItemInfo itemInfo, float yLocation, float yTopMargin, float yPageStart) + { + // CheckOffHeaders are handled in two different ways: + // 1) Where the pagelist item puts them - this is at the 'top' of the page, when the current section on the + // page has a checkoff header defined. Support for this is here AND in the VlnSvgPageHelper pagelist code. + // 2) If a continuous section, and it doesn't start at 'top' of the page, then the checkoff header is + // printed on the same line as the continuous section. Support for this is here, the check off header is added + // to the 'PartRight' off of the section's VlnParagraph. + + // First see if there is any checkoff data in the format file and that there + // is a pagelist item for the checkoff header. + int maxindx = itemInfo.ActiveFormat.PlantFormat.FormatData.ProcData.CheckOffData.CheckOffList.MaxIndexNoInherit; + if (maxindx <= 0) return; + if (MyPageHelper.PageListCheckOffHeader == null) return; + ItemInfo mySectionInfo = itemInfo.ActiveSection; // C2018-003 fixed use of getting the active section + ItemInfo mySubSectionInfo = itemInfo; + + // If the passed in itemInfo is not a section, get it's parent section. This may be a subsection, so + // it will be found here, versus using 'MyActiveSection' which is the topmost section. The passed in + // item may be a regular step, i.e. if a page break had occurred. + if (!itemInfo.IsSection) + { + while (!mySubSectionInfo.IsSection) + { + mySubSectionInfo = mySubSectionInfo.MyParent; + } + } + else + mySubSectionInfo = (mySectionInfo == null || mySectionInfo.Sections == null) ? null : mySectionInfo.Sections[0]; + + if (mySectionInfo == mySubSectionInfo) mySubSectionInfo = null; + + // The following duplicates the 16bit logic. The 16bit logic only put out a header if: + // there is no subsection and section has a header (from config); + // OR there is a subsection and the first subsection has a header. + // For locating the header in 16bit logic: + // If no subsections, output with section + // If subsections and continuous section, put out on same line as subsection. (done here) + // If subsections and starts at top of page, (on top of page, use pagelist code in VlnSvgPageHelper) + + // Get SectionInfos to access specific section config items... + SectionInfo si = mySectionInfo?.GetSectionInfo(); + int sindx = si.CheckOffHeadingIndex(); + SectionInfo subi = mySubSectionInfo?.GetSectionInfo(); + int subindx = (subi == null) ? -1 : subi.CheckOffHeadingIndex(); + + // if there is no subsections & the main section doesn't use a header OR + // if there is a subsection, & it does not use a header... Return. + if ((subi == null && sindx < 1) || (subi != null && subindx < 1)) return; + + // figure out location now: + // if step, it uses pagelist logic to locate it (this is a page break condition). + // if continuous, put out with subsection if there is one, otherwise section. + // otherwise, use pagelist logic. + bool usePageListCOHdr = false; + + // B2022-129: Barakah - Adjust the INITIAL header location, i.e. make it a pagelist item + if (itemInfo.IsStep || itemInfo.MyDocStyle.AdjSectTitleLoc) + { + usePageListCOHdr = true; + } + // This checks to see if the section is starting at the top of the page. + // If it is, then we want to use PageList to print the checkoff/sighoff header + // else the checkoff/signoff header will be printed across from the section title where ever it is on the page (i.e. section pagination set to continuous) + else if (subi == null) //no subsection + { + // B2021-106 added check if the section has a note or caution + if ((yPageStart - YOffset) == yTopMargin || mySectionInfo.HasCautionOrNote) usePageListCOHdr = true; + } + else // there is a sub-section + { + // B2021-106 added check if the section has a note or caution + if (mySectionInfo == itemInfo && ((yPageStart - YOffset) == yTopMargin) || mySectionInfo.HasCautionOrNote) usePageListCOHdr = true; + if (!usePageListCOHdr && mySubSectionInfo != itemInfo) return; + } + + // grab the string from the format, depending on whether it should get it from the section or subsection. + string cohead = (mySubSectionInfo != null) ? mySubSectionInfo.SectionCheckOffHeader : mySectionInfo?.SectionCheckOffHeader; + if (cohead == "" || cohead == null) return; + + // PageListCheckOffHeader is an svgtext - but really we only need the x/y location for this (pagelist support) + // The actual text is from the checkoff header selection in the section config. + if (cohead != MyPageHelper.PageListLastCheckOffHeader) + { + VE_Font font = mySectionInfo.ActiveFormat.PlantFormat.FormatData.ProcData.CheckOffData.CheckOffHeaderList[sindx].Font; + float chkOffY = CalculateYLocation(YTop, yTopMargin); + if (MyPageHelper.YMultiplier != 1) + { + chkOffY = -1 + yTopMargin - (yTopMargin - yLocation) * MyPageHelper.YMultiplier; + if (Rtf != null) + IParagraph.Leading = _SevenLinesPerInch; + } + if (!usePageListCOHdr) + { + vlnText myCOHead = new vlnText(cb, this, cohead, cohead, MyPageHelper.PageListCheckOffHeader.X.Value + (float)MyItemInfo.MyDocStyle.Layout.LeftMargin, chkOffY, font); + PartsRight.Add(myCOHead); + } + else + MyPageHelper.PageListTopCheckOffHeader = cohead; + MyPageHelper.PageListLastCheckOffHeader = cohead; + } + } + internal vlnParagraph BottomChild + { + get + { + float bottomChildYBottomText = YBottomText; + vlnParagraph bottomChild = this; + foreach (vlnParagraph child in ChildrenRight) + { + vlnParagraph grandChild = child.BottomChild; + if (grandChild != null && grandChild.YBottomText > bottomChildYBottomText) bottomChild = grandChild; + if (grandChild != null && grandChild.YBottomText == bottomChildYBottomText && grandChild.MyItemInfo.HasChangeBar) bottomChild = grandChild; + bottomChildYBottomText = bottomChild.YBottomText; + } + foreach (vlnParagraph child in ChildrenBelow) + { + vlnParagraph grandChild = child.BottomChild; + if (grandChild != null && grandChild.YBottomText > bottomChildYBottomText) bottomChild = grandChild; + if (grandChild != null && grandChild.YBottomText == bottomChildYBottomText && grandChild.MyItemInfo.HasChangeBar) bottomChild = grandChild; + bottomChildYBottomText = bottomChild.YBottomText; + } + return bottomChild; + } + } + private void CalculateXOffsetGridOrFigure(ItemInfo itemInfo, FormatInfo formatInfo) + { + float scale = itemInfo.IsRtfRaw ? 0.6f : 1.0f; + bool aerTableOrFigure = itemInfo.FormatStepData.Type.Contains("AER"); + vlnParagraph hls1 = MyParent; + if (!formatInfo.PlantFormat.FormatData.PrintData.SpecialCaseCalvertAlarm && !itemInfo.IsInSupInfo) + while (hls1.MyParent != null && !hls1.MyItemInfo.IsHigh) hls1 = hls1.MyParent; + else if (itemInfo.IsInSupInfo) + while (hls1.MyParent != null && !hls1.MyItemInfo.IsSupInfoPart) hls1 = hls1.MyParent; + float colR = float.Parse(formatInfo.MyStepSectionLayoutData.ColRTable.Split(",".ToCharArray())[itemInfo.ColumnMode]); + float xLowerLimit = (aerTableOrFigure && hls1.PartsLeft != null && hls1.PartsLeft.Count > 0) ? hls1.PartsLeft[0].XOffset : hls1.XOffset; + float pageWidth = ((float)itemInfo.ActiveSection.MyDocStyle.Layout.PageWidth); // C2018-003 fixed use of getting the active section + float leftMargin = ((float)itemInfo.ActiveSection.MyDocStyle.Layout.LeftMargin); // C2018-003 fixed use of getting the active section + float xUpperLimit; + if (itemInfo.IsInRNO) + // if in rno column, the upper limit is width of the page (right margin). Subtract off size of a character + xUpperLimit = pageWidth - (72 / (float)MyItemInfo.FormatStepData.Font.CPI); + else + // in the following calculation, the hls width (hls1.Width) == rno column width, so xUpperLimit is + // the around the right margin, i.e. 'hls xoffset' + 'location of rno (colR) * columnmode' + 'width of rno' + xUpperLimit = hls1.XOffset + hls1.Width + hls1.CheckOffWidth + colR * itemInfo.ColumnMode; + + // If a table is within the alarm section and its parent is a template item is single column + // adjust the xoffset so that the table is centered around center of page + bool ctrCalvertAlarmTbl = false; + if (formatInfo.PlantFormat.FormatData.PrintData.SpecialCaseCalvertAlarm) + ctrCalvertAlarmTbl = MyItemInfo.IsWithInSingleColumnTemplate(); + // B2019-049 added check for table being in a Caution or Note - if so, use the single column setting for the format variable TableCenterPos + float TableCenterPos = float.Parse(formatInfo.MyStepSectionLayoutData.TableCenterPos.Split(",".ToCharArray())[(itemInfo.IsInCautionOrNote) ? 0 : itemInfo.ColumnMode]); + if (ctrCalvertAlarmTbl || formatInfo.PlantFormat.FormatData.SectData.StepSectionData.StepSectionLayoutData.TieTabToLevel) + XOffset = leftMargin + (pageWidth - leftMargin - (scale * Width)) / 2; + else + { + if (!aerTableOrFigure && itemInfo.RNOLevel == 0 && TableCenterPos != 0) // Only adjust TableCenterPos for Non-RNO Cenetered Tables + { + XOffset = TableCenterPos; + XOffset = XOffset - (this.Width / 2) + (float)itemInfo.MyDocStyle.Layout.LeftMargin; + } + else if (itemInfo.RNOLevel != 0) // RNO + XOffset = MyParent.XOffset + (MyParent.Width / 2) - ((scale * Width) / 2); + else if (aerTableOrFigure) + { + // if in the BGE alarm format and the hls is a Window (upper right corner when it prints), use the parent of the table + // to print in aer column (B2014-105) + if (MyItemInfo.IsInCalvertConditionResponse) + XOffset = hls1.XOffset + hls1.Width / 2 - Width / 2; + else + XOffset = MyHighLevelParagraph.XOffset + MyHighLevelParagraph.Width / 2 - Width / 2; + } + else // Centered Table or Figure + { + // Determine center of hls + XOffset = hls1.XOffset + hls1.Width / 2; + // Determine left edge of the table by subtracting 1/2 of its width. + XOffset -= Width / 2; + // Add in 1/2 of the width of all RNO columns + XOffset += (colR * itemInfo.ColumnMode) / 2; + + if (!aerTableOrFigure && !MyItemInfo.IsRtfRaw) + { + // 05/14/12 - 16bit code adjusts the center depending upon the CPI of the table font. + // Start with XOffset of table, then calculate the XOffset adjusted for the table font, + // based on the default CPI of 12. Adjust the XOffset by the difference of these + // two numbers. + XOffset -= (XOffset - (XOffset * (float)MyItemInfo.FormatStepData.Font.CPI / 12)); + } + XOffset -= 12; // This makes the 16bit & 32bit align very closely. + // if outside of the page margins then center within the page margins + float xOffset2 = (float)itemInfo.MyDocStyle.Layout.LeftMargin; + float xWidth2 = (float)itemInfo.MyDocStyle.Layout.PageWidth; + if (XOffset + Width > xOffset2 + xWidth2) + XOffset = xOffset2 / 2 + xWidth2 / 2 - Width / 2; + + } + // 05/14/12 - The PosAdjust is a format flag from 16bit. For WCN2, it appears that this amount equals + // the amount of difference from a 10 CPI to a 12 CPI font. See comment above. + float posAdjust = (float)(itemInfo.FormatStepData.StepPrintData.PosAdjust ?? 0); + if (itemInfo.FormatStepData != null && itemInfo.FormatStepData.StepPrintData != null && + posAdjust > 0) + { + if (Width < hls1.Width - posAdjust) + XOffset += posAdjust; + else if (Width < hls1.Width) + XOffset = hls1.XOffset + hls1.Width - Width; // align with the right edge of hls text + } + } + if (itemInfo.MyDocStyle.Layout.CenterToStepThenPage) + { + if (Width > hls1.Width) + { + float XOffsetPage = leftMargin + ((pageWidth - leftMargin) - Width) / 2; + float fraction = (Width - hls1.Width) / ((pageWidth - leftMargin) - hls1.Width); + float XOffsetNew = (1 - fraction) * XOffset + fraction * XOffsetPage; + _MyLog.WarnFormat("***XOffsetAdjust-CenterToStepThenPage*** ItemID, XOffset, XOffsetPage, XOffsetNew ={0},{1},{2},{3}", itemInfo.ItemID, XOffset, XOffsetPage, XOffsetNew); + XOffset = XOffsetNew; + } + } + else + { + // if the XOffset < High Level Step Text's XOffset , then align with the High Level Step Text' + // B2020-161 - needed to substract the checkoff width when deterniming the XOffset + // fixes centered tables in Calvert Unit 2 STP O-90-2 step 6.3.A + if (XOffset < xLowerLimit && Width < (xUpperLimit - xLowerLimit - hls1.CheckOffWidth)) + XOffset = xLowerLimit; + + // if the right margin exceeds the right edge of the rightmost RNO, then adjust right edge to match. + // In lines below, the 12 was used for Wolf Creek 2 column format, the pagewidth goes beyond the right border line so that + // the tables, figures & equations were beyond the border. -12 takes it enough so that if boxed, it won't print out of border + // We know this is not ideal. + if (MyItemInfo.IsRtfRaw && (XOffset + (scale * Width) > xUpperLimit - 12)) + XOffset = xUpperLimit - (scale * Width) - 12; + if (!MyItemInfo.IsRtfRaw && XOffset + Width > xUpperLimit) + XOffset = xUpperLimit - Width; + // because of the above, if it pushes beyond the left margin, use the left margin. + if (XOffset < (float)itemInfo.MyDocStyle.Layout.LeftMargin) + XOffset = XOffsetBox = (float)itemInfo.MyDocStyle.Layout.LeftMargin; + } + } + private float AdjustForBlankLines() + { + if (MyParent != null && MyParent.MyItemInfo.FormatStepData != null && MyParent.MyItemInfo.FormatStepData.Type == "TitleWithTextRight") return 0; + // F2022-121 added SpecialStepsFoldoutKeepWhiteSpace flag to allow for all of the other special foldout formatting, but + // not compress the page + if (MyItemInfo.MyDocStyle.SpecialStepsFoldout && !MyItemInfo.MyDocStyle.SpecialStepsFoldoutKeepWhiteSpace) return 0; + if (MyItemInfo.FormatStepData != null && MyItemInfo.FormatStepData.Prefix != null && MyItemInfo.FormatStepData.Suffix != null && MyItemInfo.FormatStepData.UseSmartTemplate) return 0; + int everyNLines = MyItemInfo.FormatStepData == null ? 1 : MyItemInfo.FormatStepData.StepLayoutData.EveryNLines ?? 1; + if (everyNLines == -99) return 0; + if (everyNLines == -1) return -SixLinesPerInch; + if (MyItemInfo.ActiveFormat.PlantFormat.FormatData.PrintData.SpecialCaseCalvertAlarm || + (MyItemInfo.ActiveFormat.PlantFormat.FormatData.PrintData.SpecialCaseCalvert && MyItemInfo.IsStep && MyItemInfo.FormatStepData.StepLayoutData.STBoxindex != null)) + { + if ((MyItemInfo.IsCaution || MyItemInfo.IsNote || MyItemInfo.MyParent.IsCaution || MyItemInfo.MyParent.IsNote) && !MyItemInfo.FormatStepData.SpaceIn + && (MyItemInfo.Steps == null || MyItemInfo.Steps.Count == 0) + && (MyItemInfo.NextItem == null || MyItemInfo.MyContent.Type != MyItemInfo.NextItem.MyContent.Type)) + { + // C2014-009: Don't add another blank line - print the calvert Condition/Response RNO Caution/Notes without it. + if (!(MyItemInfo.ActiveFormat.PlantFormat.FormatData.PrintData.SpecialCaseCalvertAlarm && MyItemInfo.IsInRNO)) + return 0; + } + //B2020-117 for multiple Calvert Condition/Response Cautions,Note, and Warnings, do add an extra blank line + // between them + if (MyItemInfo.ActiveFormat.PlantFormat.FormatData.PrintData.SpecialCaseCalvertAlarm && + MyItemInfo.IsInRNO && (MyItemInfo.IsCaution || MyItemInfo.IsNote) && + MyItemInfo != MyItemInfo.LastSibling) + return 0; + if (everyNLines == 99 && MyItemInfo.NextItem == null) + { + if (MyItemInfo.Steps != null && MyItemInfo.Steps.Count > 0 && MyItemInfo.Steps[0].MyContent.Type == MyItemInfo.MyContent.Type) return 0; + if (MyItemInfo.MyParent.NextItem != null && MyItemInfo.MyParent.NextItem.MyContent.Type == MyItemInfo.MyContent.Type) return 0; + } + } + // B2015-005: if there isn't a blank line after this step && it has children, see if there shouldn't be + // a blank line, i.e. if the first substep child's type is the same as this. + if (!MyItemInfo.IsHigh && everyNLines == 99 && MyItemInfo.NextItem == null && MyItemInfo.HasChildren) + { + ItemInfo chld = MyItemInfo.FirstChild(E_FromType.Step); + if (chld != null && chld.MyContent.Type == MyItemInfo.MyContent.Type) return 0; + } + // F2021-033: No blank line between hls and its first substep: + if (MyItemInfo.ActiveFormat.PlantFormat.FormatData.PrintData.NoBlankHlsAndFirstSub && MyItemInfo.IsHigh) + { + // F2021-060 Do not remove blank line between step and Caution, Note or Warning below it (Caution, Note, Warning are off 1st sub step) + if (MyItemInfo.Steps != null && MyItemInfo.Steps.Count > 0 && !MyItemInfo.Steps[0].HasCautionOrNote) return 0; + } + // F2021-025: Barakah single column no blank line between last Note/Caution/Warning text and bottom line of box + // C2021-049: Barakah no blank line between last Note/Caution/Warning text, include sub-step text by using 'IsInCautionOrNote' + // B2022-017: Barakah within note/caution, if note has substeps, there should be a blank line between note & 1st substep + // B2022-027: Barakah blank line not printing after list within another list. Rewrote code for all of these issues so that + // code looks up parents to see if they have next before returning a 0 (no blank line) + // B2022-042: double Caution followed by Critical Step missing bullet + // F2022-010: substeps in multiple notes, cautions, warning print differently + if (MyItemInfo.IsInCautionOrNote) + { + float adjLastBlankLineInNoteCautionWarning = 0; + // Get the box information for the Note, Caution, or Warning + ItemInfo tifo = (MyItemInfo.IsCaution || MyItemInfo.IsNote) ? MyItemInfo : MyItemInfo.ParentNoteOrCaution; + int typ = ((int)tifo.MyContent.Type) % 10000; + int? bxIndx = tifo.ActiveFormat.PlantFormat.FormatData.StepDataList[typ].StepLayoutData.STBoxindex; + if (bxIndx != null) + { + Box bx = tifo.ActiveFormat.PlantFormat.FormatData.BoxList[(int)bxIndx]; + // F2024-078 save the adjustment of the last blank line - this value will be added to the SixLinesPerInch value (a blank line) + adjLastBlankLineInNoteCautionWarning = (float)(bx.AdjLastBlnkLn ?? 0); + } + // F2024-078 added check for adjustment of the last blank line in the Note/Caution box + if (MyItemInfo.ActiveFormat.PlantFormat.FormatData.PrintData.NoBlankLastNoteCautionWarn || adjLastBlankLineInNoteCautionWarning != 0) + { + if ((MyItemInfo.Steps == null || MyItemInfo.Steps.Count == 0) && (MyItemInfo.NextItem == null)) // there are no sub-steps, see if any parents have next + { + ItemInfo par = MyItemInfo.MyParent; + while (par.IsInCautionOrNote) // while in the caution or note, see if there is anything below this item + { + // if there is no next item, or content types are different, go up to see if the parent has any next item. If note + // keep going up tree, otherwise there is a next so don't return 0, i.e. continue on with code to determine + // whether there is a blank line + if ((par.NextItem == null) || (par.MyContent.Type != par.NextItem.MyContent.Type)) par = par.MyParent; + else break; + } + if (!par.IsInCautionOrNote || (par != null && par.MyContent.Type != par.NextItem.MyContent.Type)) + { + if (adjLastBlankLineInNoteCautionWarning != 0) + return SixLinesPerInch + adjLastBlankLineInNoteCautionWarning; // F2024-078 adjust the size of the last blank line of Note/Caution box + else + return 0; // no blank line after last text line of Note/Caution/Warning + } + } + if ((MyItemInfo.Steps == null || MyItemInfo.Steps.Count == 0) && MyItemInfo.NextItem != null && MyItemInfo.MyContent.Type != MyItemInfo.NextItem.MyContent.Type) + { + if (adjLastBlankLineInNoteCautionWarning != 0) + return SixLinesPerInch + adjLastBlankLineInNoteCautionWarning; + else + return 0; // no blank line after last text line of Note/Caution/Warning + } + } + } + if (MyItemInfo.Ordinal % everyNLines == 0 || MyItemInfo.NextItem == null) return SixLinesPerInch; + // B2022-003: BNPP Alarms (BNPPalr) - incorrect line spacing for substeps off substeps. Added a format flag so as not to affect other plants. + if (MyItemInfo.FormatStepData != null && MyItemInfo.FormatStepData.StepPrintData != null && MyItemInfo.FormatStepData.StepPrintData.BlankAfterSubWithSub && MyItemInfo.NextItem != null && MyItemInfo.HasChildren && MyItemInfo.Steps != null && MyItemInfo.Steps.Count > 0) return SixLinesPerInch; + + // If the next table child is a figure, equation or a visio drawing add a blank line + if (MyItemInfo.Tables != null && MyItemInfo.Tables.Count > 0 && MyItemInfo.Tables[0].MyContent.MyGrid == null) return SixLinesPerInch; + return 0; + } + private void AddMacros(ItemInfo itemInfo, vlnTab mytab) + { + float y = YOffset; + float x = mytab == null ? XOffset : mytab.XOffset + mytab.TabOffset; + List myMacros = itemInfo.MyMacros; + if (myMacros != null) + { + int colMode = (MyItemInfo.ActiveSection != null) ? MyItemInfo.ActiveSection.ColumnMode : 0; // C2018-003 fixed use of getting the active section + foreach (Macro myMacro in myMacros) + { + // if the format has the 'LocWithXOff' locate the macro along with the tab's offset. + // however, if the tab is more than 2 characters long, adjust so that it aligns with the + // last two characters, not the first 2. + string tabText = mytab?.Text.Trim(" .".ToCharArray()); + int tablen = (tabText == null) ? 0 : (tabText.Length <= 2) ? 0 : tabText.Length - 2; + if (myMacro.LocWithXOff ?? false) x = mytab == null ? XOffset : ((float)mytab.XOffset + (tablen * (float)mytab.MyFont.CharsToTwips)); + if (colMode == 0 && myMacro.SingleColMacroDef != null && myMacro.SingleColMacroDef.Length > 0) + { + float macroXOffset = myMacro.MacroXOffSet ?? 0; + float widthAdj = myMacro.SingleColWidthAdjust ?? 0; // set as negative number in format + float rightTextEdge = (itemInfo.IsHigh) ? XOffset + Width + mytab.XOffset : this.MyHighLevelParagraph.XOffset + this.MyHighLevelParagraph.Width; + x = (macroXOffset > 0) ? macroXOffset : rightTextEdge; + if (rightTextEdge > x) + Width += widthAdj; + PartsRight.Add(new vlnMacro(x, y, myMacro.SingleColMacroDef)); + } + else + PartsLeft.Add(new vlnMacro(x, y, myMacro.MacroDef)); + } + } + } + // HLP Change bar flags in format file: + // Locations: With Text, Outside Box, AER on Left RNO on Right, To The Left of Text + // Text: Date & Change ID, Revision Number, Change ID, None, Custom (use input data) + // Flag AERChgBarMsgRNOChgBarNoMsg and AERMsgRNONoMsg are NOT Used in 16-bit. + private string cbMess = null; + private vlnChangeBar DoChangeBar(PdfContentByte cb, ItemInfo itemInfo, VlnSvgPageHelper myPageHelper, float xoff, float yoff, int maxRNO, FormatInfo formatInfo) //, vlnChangeBar myCB) + { + ChangeBarData cbd = formatInfo.PlantFormat.FormatData.ProcData.ChangeBarData; + float cols = formatInfo.MyStepSectionLayoutData.ColS ?? 0; + float colr = ToInt(formatInfo.MyStepSectionLayoutData.ColRTable, maxRNO); + // FixedChangeColumn + - Column location for change bars + // 0 - Separate AER and RNO change bars to the right of the text + // -10 to -1 - Change bars on left (specify # of columns from the text) + // <-10 - AER change bars on the left and RNO change bars on the right. + // FixedAERChangeColumn overrides the -5 default setting in chgbar.c, value is converted to a negative by the code + + float col = (cbd.AbsoluteFixedChangeColumn) ? + ((cbd.FixedAERChangeColumn ?? 0) > 0) ? + (xoff > (cols + colr + COL_WID_ADJ)) ? + cbd.FixedChangeColumn ?? 0 : AERLeftChangeBarLocation(formatInfo) : + cbd.FixedChangeColumn ?? 0 : ChangeBarLocation(xoff, this, formatInfo, maxRNO); + string chgIdTxt = null; + if (itemInfo.ActiveFormat.PlantFormat.FormatData.ProcData.ChangeBarData.ChangeIds) + { + chgIdTxt = !(itemInfo.MyConfig is StepConfig sc) ? null : sc.Step_ChangeID; + } + if (myPageHelper.ChangeBarDefinition.MyChangeBarText == PrintChangeBarText.ChgID) + cbMess = chgIdTxt ?? itemInfo.MyContent.UserID; + else if (myPageHelper.ChangeBarDefinition.MyChangeBarText == PrintChangeBarText.DateChgID) + { + string fmtDate = itemInfo.MyContent.DTS.ToShortDateString(); + if (fmtDate.Length != 10) // need to add zeros + { + if (fmtDate.IndexOf("/") == 1) + fmtDate = "0" + fmtDate; + if (fmtDate.IndexOf("/", 3) == 1) + fmtDate = $"{fmtDate.Substring(0, 3)}0{fmtDate.Substring(3, fmtDate.Length - 3)}"; + } + cbMess = $@"{chgIdTxt ?? itemInfo.MyContent.UserID}\n{fmtDate}"; + } + else if (myPageHelper.ChangeBarDefinition.MyChangeBarText == PrintChangeBarText.RevNum) + { + + string lRev = myPageHelper.Rev; + // Now check the format flags to determine if/how the Rev string should be parsed. + if ((itemInfo.ActiveFormat.PlantFormat.FormatData.PrintData.DoRevDate && lRev.Contains("/")) + || (itemInfo.ActiveFormat.PlantFormat.FormatData.PrintData.RevDateWithForwardSlash && lRev.Contains("\\"))) + { + int indx = lRev.IndexOf(itemInfo.ActiveFormat.PlantFormat.FormatData.PrintData.DoRevDate ? '/' : '\\'); + cbMess = lRev.Substring(0, indx > -1 ? indx : lRev.Length); + } + else + cbMess = lRev; + } + else if (myPageHelper.ChangeBarDefinition.MyChangeBarText == PrintChangeBarText.UserDef) + cbMess = myPageHelper.ChangeBarDefinition.MyChangeBarMessage; + + int msgAlign = Element.ALIGN_LEFT; + if (myPageHelper.ChangeBarDefinition.MyChangeBarLoc == PrintChangeBarLoc.LeftOfText || + (myPageHelper.ChangeBarDefinition.MyChangeBarLoc == PrintChangeBarLoc.AERleftRNOright && + !itemInfo.IsInRNO)) msgAlign = Element.ALIGN_RIGHT; + float coltotwips = col * itemInfo.FormatStepData.Font.CharsToTwips; + if (cbd.AbsoluteFixedChangeColumn) coltotwips = col * itemInfo.ActiveFormat.PlantFormat.FormatData.Font.CharsToTwips; + // B2023-052: Beaver Valley - Inconsistent change bar location - used AbsoluteFixedChangeColumn flag, but the LeftMargin + // was still added in, thus sections had different locations for change bar if sections had different left margin. Use + // adjustment, 'AbsChgBarAdj' + coltotwips += itemInfo.MyDocStyle.Layout.AbsChgBarAdj ?? 0; + if (itemInfo.IsFigure) coltotwips = col * itemInfo.ActiveFormat.PlantFormat.FormatData.Font.CharsToTwips; + return new vlnChangeBar(cb, this, (float)itemInfo.MyDocStyle.Layout.LeftMargin + coltotwips, yoff, msgAlign, + myPageHelper.ChangeBarDefinition.MyChangeBarText == PrintChangeBarText.RevNum, + itemInfo.ActiveFormat.PlantFormat.FormatData.ProcData.ChangeBarData.ChangeIds); + } + + // changed this function to return a float instead of an int to correct a rounding error which cause change bars + // to inconsistantly position next to changed text. Bug B2015-033 + private float ChangeBarLocation(float c, vlnParagraph paragraph, FormatInfo formatInfo, int maxRNO) + { + int fixedChgCol = formatInfo.PlantFormat.FormatData.ProcData.ChangeBarData.FixedChangeColumn ?? 0; + float cols = formatInfo.MyStepSectionLayoutData.ColS ?? 0; + int colr = ToInt(formatInfo.MyStepSectionLayoutData.ColRTable, maxRNO); + float tmpc = c; + Box bxCautNote = null; // used for notes and cautions in the Prairie Island Alarms format + if (MyItemInfo.IsCaution || MyItemInfo.IsNote) + { + // Temporary fix for change bars on Notes and Cautions where the FixedChgCol < -10 + tmpc = (float)formatInfo.MyStepSectionLayoutData.ColT + (float)formatInfo.MyStepSectionLayoutData.WidT; // end position of Caution / Note + int typ = (int)(MyItemInfo.MyContent.Type % 10000); + int? bxIndx = formatInfo.PlantFormat.FormatData.StepDataList[typ].StepLayoutData.STBoxindex; + if (bxIndx != null) + { + bxCautNote = formatInfo.PlantFormat.FormatData.BoxList[(int)bxIndx]; + if (bxCautNote != null) + tmpc = (float)bxCautNote.Start + (float)bxCautNote.End; // end position of a boxed Caution / Note + } + } + // if this is a caution or note, put the change bar to the right of the text: + if ((fixedChgCol == 0)) + { + float rightEdge = (paragraph.XOffset + paragraph.Width + 5); + rightEdge -= (float)paragraph.MyItemInfo.MyDocStyle.Layout.LeftMargin; + if (bxCautNote != null) + rightEdge = (float)bxCautNote.End + 10; // used for notes and cautions in the Prairie Island Alarms format + rightEdge /= paragraph.MyItemInfo.FormatStepData.Font.CharsToTwips; + return MyItemInfo.IsFigure ? rightEdge + 1 : rightEdge; // B2017-111: Add a little more space between figure & change bar + } + if (fixedChgCol < -10 || fixedChgCol >= 0) + return ((fixedChgCol > 0) ? fixedChgCol : + (fixedChgCol == 0) ? (int)c + 1 : + (tmpc > (cols + colr + COL_WID_ADJ)) ? -fixedChgCol : + AERLeftChangeBarLocation(formatInfo)); + else + return (fixedChgCol + (((c < cols + Width + colr) + || MyItemInfo.IsCaution || MyItemInfo.IsNote) ? 0 : cols + colr)); + /* Change bars to left of text -- ColS+WidS+ColR is the end of RNO col*/ + } + /* + ** Centered tables whose width exceeds the end of the RNO column should + ** still have their change bars printed on the left. + */ + private float GetBottomYoff(float bottomY) + { + foreach (vlnParagraph child in ChildrenBelow) + { + if (child.YOffset > bottomY) bottomY = child.YOffset; + bottomY = child.GetBottomYoff(bottomY); + } + return bottomY; + } + private int AERLeftChangeBarLocation(FormatInfo formatInfo) + { + // use -5 default unless it is format specified + int fixedAERChgCol = formatInfo.PlantFormat.FormatData.ProcData.ChangeBarData.FixedAERChangeColumn ?? 0; + return (fixedAERChgCol != 0) ? + (fixedAERChgCol > 100) ? + (fixedAERChgCol % 100) : -fixedAERChgCol : -5; + } + private StringBuilder _RtfSB = null; + public string GetRtf(ItemInfo itemInfo, string prefix, string suffix) + { + int profileDepth = ProfileTimer.Push(">>>> GetRtf"); + _RtfSB = new StringBuilder(); + DisplayText vlntxt = new DisplayText(itemInfo, E_EditPrintMode.Print, E_ViewMode.View, true, E_FieldToEdit.StepText, false, prefix, suffix, MyPageHelper.MyPromsPrinter.RemoveTrailingHardReturnsAndSpaces != null); + + //C2025-021 Add logic to PROMS to support a special High Level Step type that is not printed. + if (itemInfo.IsType("InvisibleHigh")) + { + System.Drawing.Font myHighFont = vlntxt.TextFont.WindowsFont; + _RtfSB.Append(AddFontTable(myHighFont)); + _RtfSB.Append("}"); + string rtfHigh = _RtfSB.ToString(); + ProfileTimer.Pop(profileDepth); + return rtfHigh; + } + + // C2021-010: Remove trailing returns/spaces & manual page breaks & allow save. + if (DisplayText.RemoveTrailingBlankID > 0 && !MyPageHelper.MyPromsPrinter.RemoveTrailingHardReturnsAndSpaces.Contains(itemInfo.ItemID)) MyPageHelper.MyPromsPrinter.RemoveTrailingHardReturnsAndSpaces.Add(DisplayText.RemoveTrailingBlankID); + System.Drawing.Font myFont = vlntxt.TextFont.WindowsFont; + if (!itemInfo.IsTable && StepRTB.MyFontFamily != null) + // follow through in fixing an Out of Window Handles bug, use new function to see if + // we can retrieve the font from a dictionary instead a doing a New and using another + // window handle B2017-117 + //myFont = new System.Drawing.Font(StepRTB.MyFontFamily, myFont.Size, myFont.Style); + myFont = VE_Font.GetWinSysFont(StepRTB.MyFontFamily, myFont.Size, myFont.Style); + + string stText; // if Calvert (BGE) Alarms, the text is included in the macro, so save text as a blank: + if (HasCalvertMacro) + { + stText = " "; + // turn underline off + // follow through in fixing an Out of Window Handles bug, use new function to see if + // we can retrieve the font from a dictionary instead a doing a New and using another + // window handle B2017-117 + myFont = VE_Font.GetWinSysFont(myFont.FontFamily, myFont.Size, System.Drawing.FontStyle.Regular); //myFont.Style. | FontStyle.Underline); + } + else + stText = vlntxt.StartText; + + if (itemInfo.IsHigh && itemInfo.MyDocStyle.UndSpecialStepsFoldout) + { + // follow through in fixing an Out of Window Handles bug, use new function to see if + // we can retrieve the font from a dictionary instead a doing a New and using another + // window handle B2017-117 + myFont = VE_Font.GetWinSysFont(myFont.FontFamily, myFont.Size, myFont.Style | System.Drawing.FontStyle.Underline); + stText = stText.Replace(@"\ulnone ", ""); + stText = stText.Replace(@"\ulnone", ""); + } + if (stText.Contains("{IND}")) stText = stText.Replace("{IND}", "\x5"); + if (itemInfo.IsSection && itemInfo.ActiveFormat.PlantFormat.FormatData.SectData.SectionNumber.Level0Big && itemInfo.MyParent.IsProcedure) + // follow through in fixing an Out of Window Handles bug, use new function to see if + // we can retrieve the font from a dictionary instead a doing a New and using another + // window handle B2017-117 + myFont = VE_Font.GetWinSysFont(myFont.FontFamily, 14, myFont.Style | System.Drawing.FontStyle.Bold); + _RtfSB.Append(AddFontTable(myFont)); + _RtfSB.Append(stText); + if (MyItemInfo.IsStep && !itemInfo.FormatStepData.UseSmartTemplate && MyItemInfo.FormatStepData.Suffix != null && MyItemInfo.FormatStepData.Suffix != "") + _RtfSB.Append(MyItemInfo.FormatStepData.Suffix.Replace("{ulnone}", @"\ulnone ")); + _RtfSB.Append("}"); + string rtf = _RtfSB.ToString(); + UnderlineTerminateList utl = MyItemInfo.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.UnderlineTerminateList; + if (utl != null && myFont.Underline) + { + foreach (UnderlineTerminate ut in utl) + { + MatchCollection mc = Regex.Matches(rtf, "(? 0) + { + Match m = mc[mc.Count - 1]; + rtf = rtf.Substring(0, m.Index) + @"\ulnone " + rtf.Substring(m.Index); + } + } + } + ProfileTimer.Pop(profileDepth); + return rtf; + } + + public float XOffsetBox { get; set; } = 0; + private readonly float _MyBoxLeftAdj = 0; + private float SetHeader(vlnParagraph para, PdfContentByte cb, ItemInfo itemInfo, FormatInfo formatInfo) + { + float xoff = (float)itemInfo.MyDocStyle.Layout.LeftMargin; + // The '6' below is really converting from characters to Twips. But instead of considering the CPI, 16bit assumed + // it was 12 to center the header. That's where the 6 comes from. + float hdrWidth = (itemInfo.MyHeader.CleanText == null) ? 0 : itemInfo.MyHeader.CleanText.Length * 6; + int typ = ((int)itemInfo.MyContent.Type) % 10000; + int? bxIndx = formatInfo.PlantFormat.FormatData.StepDataList[typ].StepLayoutData.STBoxindex; + float adjmentAfterBoxedNoteCautionTab = 0; // F2024-078 used to save the adjustment of the space after the Note/Caution tab + + if (itemInfo.MyHeader.Justify == System.Drawing.ContentAlignment.MiddleCenter) + { + if (bxIndx != null) + { + Box bx = formatInfo.PlantFormat.FormatData.BoxList[(int)bxIndx]; + if (bx.TabPos > 0) + xoff += (float)bx.TabPos; // xoff starts as left margin + else + xoff += (float)((bx.TxtStart + _MyBoxLeftAdj + XOffsetBox + (bx.TxtWidth / 2)) - (hdrWidth / 2)); // xoff starts as left margin + adjmentAfterBoxedNoteCautionTab = (float)(bx.AdjSpAftTab ?? 0); // F2024-078 save the adjustment of the space (line) after the Note/Caution tab + } + else if (formatInfo.PlantFormat.FormatData.PrintData.SpecialCaseCalvertAlarm && itemInfo.IsInRNO && (itemInfo.IsCaution || itemInfo.IsNote)) // C2014-009 + xoff = XOffset + (para.Width / 2) - (hdrWidth / 2); + else if (formatInfo.MyStepSectionLayoutData.Separator.Location > 0) + xoff = XOffset + AdjustToCharPosition((float)((para.Width - hdrWidth) / formatInfo.MyStepSectionLayoutData.Separator.Location), itemInfo.MyHeader.MyFont.CPI); + else if (itemInfo.IsInRNO && itemInfo.ActiveFormat.PlantFormat.FormatData.StepDataList[40].NumberWithLevel) + xoff = XOffset + (para.Width / 2) - (hdrWidth / 2); + else if (itemInfo.ActiveFormat.PlantFormat.FormatData.StepDataList[40].NumberWithLevel) + xoff = XOffset + (para.Width / 2) - (hdrWidth / 2); + else + xoff = XOffset + (para.Width / 2) + (hdrWidth / 2); // XOffset has left margin included + } + else + xoff = XOffset; // XOffset has left margin included + // KEEP: This may be needed in the future to fix location of 'OR's when Separator location="0" + // the following code would place the 'OR' at the location of the tab rather than text. This + // is how 16bit was. However, a number of plants had been sent out with the xoffset at the xlocation + // of text (does not match 16bit) when this was found for BGE OI3/OI-1B/6.1.B.4. Previous releases + // went to CAT, MCG, FPL, NSP. + //{ + // if (this.MyTab != null) + // xoff = this.MyTab.XOffset; + // else + // xoff = XOffset; + //} + // B2018-096 AEP 082.002CD Note Box overlapping Step Box + vlnHeader myHeader = new vlnHeader(this, cb, itemInfo.MyHeader.Text, itemInfo.MyHeader.CleanText.TrimStart(" ".ToCharArray()), xoff + AdjustHeader + _MyBoxLeftAdj, YOffset, itemInfo.MyHeader.MyFont); + PartsAbove.Add(myHeader); + // Only use SpaceIn property for Cautions or Notes + bool bSpaceIn = !MyItemInfo.IsCaution && !MyItemInfo.IsNote || MyItemInfo.FormatStepData.SpaceIn; + // F2022-121 added SpecialStepsFoldoutKeepWhiteSpace flag to allow for all of the other special foldout formatting, but + // not compress the page - this need to handle explicit OR and AND sub-steps to ensure there are blank lines before and after + // the separator text. + return myHeader.Height + (!MyItemInfo.MyDocStyle.SpecialStepsFoldout || (MyItemInfo.MyDocStyle.SpecialStepsFoldout && MyItemInfo.MyDocStyle.SpecialStepsFoldoutKeepWhiteSpace) || (MyItemInfo.MyDocStyle.ExtraLineHeader && (MyItemInfo.IsCaution || MyItemInfo.IsNote)) ? bSpaceIn ? SixLinesPerInch : 0 : 0) + adjmentAfterBoxedNoteCautionTab; // F2024-078 add adjustment to the space after the Note/Caution tab + } + private float AdjustToCharPosition(float position, float? CPI) + { + int iPosition = (int)position; + int charsToTwips = (int)(72 / (CPI ?? 12)); + iPosition = (iPosition / charsToTwips) * charsToTwips; + return (float)iPosition; + } + + public bool SectionPageBreak { get; set; } = false; + public bool Processed { get; set; } = false; + public vlnParagraph LastRNO { get; set; } + public vlnParagraph MyTopRNO { get; set; } + public static string PathPrefix { get; set; } = ""; + protected float _YBottomMost; // Bottom of the paragraph including the children + public float YBottomMost + { + get + { + return _YBottomMost; + } + set + { + _YBottomMost = value; + } + } + + protected float YBottomPagination { get; set; } + protected float _YBottomMostAdjust = 0; // the RNO separator is outside asterisk box, account for additional Y space + public float YBottomMostAdjust + { + get { return _YBottomMostAdjust; } + set { _YBottomMostAdjust = value; } + } + protected float _YTopMost; // Top of the paragraph including the children + public float YTopMost + { + get { return _YTopMost; } + set { _YTopMost = value; } + } + protected float _YTop; // Top of the paragraph including parts + [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0059:Unnecessary assignment of a value", Justification = "vp kept due to possible side effect code")] + public float YTop + { + get { return _YTop; } + set + { + vlnParagraph vp = this as vlnParagraph; + _YTop = value; + + } + } + // If we're in a smart template (WCNCKL checklists) then account for the bottom line in the + // table. + public float SmartTemplateAdjust => (MyItemInfo.IsHigh && MyItemInfo.FormatStepData.UseSmartTemplate) ? SixLinesPerInch : 0; + public float YSize // How big this paragraph is with all of its children + { + get + { + float ysize = SmartTemplateAdjust + _YBottomMost - _YTopMost; + if (MyItemInfo.IsHigh && ((MyItemInfo.MyDocStyle.StructureStyle.Style & E_DocStructStyle.DoubleBoxHLS) == E_DocStructStyle.DoubleBoxHLS)) + ysize += SixLinesPerInch; + return ysize; + } + } + + public ItemInfo MyItemInfo { get; set; } + private vlnParagraph _MyHighLevelParagraph; + + public vlnParagraph MyHighLevelParagraph + { + get + { + if (_MyHighLevelParagraph == null) + { + _MyHighLevelParagraph = GetHighLevelParagraph(); + } + return _MyHighLevelParagraph; + } + } + private vlnParagraph GetHighLevelParagraph() => MyItemInfo.IsHigh ? this : MyParent.GetHighLevelParagraph(); + private vlnParagraph _SupInfoSection; + public vlnParagraph SupInfoSection + { + get + { + if (_SupInfoSection == null) + { + _SupInfoSection = GetSupInfoSectionParagraph(); + } + return _SupInfoSection; + } + } + private vlnParagraph GetSupInfoSectionParagraph() => MyItemInfo.IsSection ? this._SupInfoSection : MyParent.GetSupInfoSectionParagraph(); + // Tab, Separator, ChangeBar, Box, Circle, Checkoff + private vlnTab _MyTab; + public vlnTab MyTab + { + get + { + if (_MyTab == null) + { + foreach (vlnPrintObject po in PartsLeft) + { + if (po is vlnTab) + { + _MyTab = po as vlnTab; + break; + } + } + } + return _MyTab; + } + } + private vlnPrintObjects _PartsAbove; + public vlnPrintObjects PartsAbove + { + get + { + if (_PartsAbove == null) _PartsAbove = new vlnPrintObjects(); + return _PartsAbove; + } + } + private vlnPrintObjects _PartsBelow; + public vlnPrintObjects PartsBelow + { + get + { + if (_PartsBelow == null) _PartsBelow = new vlnPrintObjects(); + return _PartsBelow; + } + } + private vlnPrintObjects _PartsRight; + public vlnPrintObjects PartsRight + { + get + { + if (_PartsRight == null) _PartsRight = new vlnPrintObjects(); + return _PartsRight; + } + } + private vlnPrintObjects _PartsLeft; + public vlnPrintObjects PartsLeft + { + get + { + if (_PartsLeft == null) _PartsLeft = new vlnPrintObjects(); + return _PartsLeft; + } + } + private vlnPrintObjects _PartsContainer; + public vlnPrintObjects PartsContainer + { + get + { + if (_PartsContainer == null) _PartsContainer = new vlnPrintObjects(); + return _PartsContainer; + } + } + private vlnParagraphs _ChildrenAbove; + public vlnParagraphs ChildrenAbove + { + get + { + if (_ChildrenAbove == null) _ChildrenAbove = new vlnParagraphs(this); + return _ChildrenAbove; + } + } + private vlnParagraphs _ChildrenBelow; + public vlnParagraphs ChildrenBelow + { + get + { + if (_ChildrenBelow == null) _ChildrenBelow = new vlnParagraphs(this); + return _ChildrenBelow; + } + } + private vlnParagraphs _ChildrenRight; + public vlnParagraphs ChildrenRight + { + get + { + if (_ChildrenRight == null) _ChildrenRight = new vlnParagraphs(this); + return _ChildrenRight; + } + } + private vlnParagraphs _ChildrenLeft; + public vlnParagraphs ChildrenLeft + { + get + { + if (_ChildrenLeft == null) _ChildrenLeft = new vlnParagraphs(this); + return _ChildrenLeft; + } + } + + public float? XOffsetCenter { get; set; } = null; + + public bool IsEnhancedBackgroundFormat(ItemInfo itminfo) => ((itminfo.ActiveFormat.PlantFormat.FormatData.PurchaseOptions.Value & E_PurchaseOptions.EnhancedBackgrounds) == E_PurchaseOptions.EnhancedBackgrounds); + + public void AdjustXOffsetForTab(ItemInfo itemInfo, int maxRNO, FormatInfo formatInfo, vlnTab myTab, float xMetaAdj) + { + if (itemInfo.IsSupInfoPart) + { + // The SupInfoTabOff was added to the base format during initial development to shift the tab over by 3/4 inch (54) to allow for enough space for Note/Caution tab + int sitabloc = itemInfo.ActiveFormat.PlantFormat.FormatData.PrintData.SupInfoTabOff == null ? 0 : (int)itemInfo.ActiveFormat.PlantFormat.FormatData.PrintData.SupInfoTabOff; + // B2023-069 allow for the adjustment of the Supplemental Information tab at the section level (SecOvrideSupInfoTabOff). + // this will also override the SupInoTabOff setting which is for the entire format + int secOvrSupInfoTab = itemInfo.MyDocStyle.SecOvrideSupInfoTabOff == null ? 0 : (int)itemInfo.MyDocStyle.SecOvrideSupInfoTabOff; + if (secOvrSupInfoTab != 0) sitabloc = secOvrSupInfoTab; + XOffset = (float)itemInfo.MyDocStyle.Layout.LeftMargin + sitabloc; + if (myTab != null) + { + myTab.XOffset = XOffset - ((myTab == null) ? 0 : myTab.Width) - 12; + // B2017-253 - Limit the tab offset to 2 points inside the left margin + myTab.XOffset = Math.Max(myTab.XOffset, itemInfo.MyDocStyle.Layout.LeftMargin ?? 72) + 2; + float mytbwidth = myTab.Width; + myTab.Width = 2.5f * myTab.Width; + // C2018-022: adjust xoffset of text by 12 if the tab would overwrite the text and the format flag is on: + if (itemInfo.ActiveFormat.PlantFormat.FormatData.PrintData.SupInfoAdjustXOffForLongTab && ((myTab.XOffset + mytbwidth + 12) > XOffset)) + XOffset = 12F + myTab.XOffset + mytbwidth; + } + // B2017-102: need to set width here since using Xoffset because AdjustWidth is called before this adjustment. + Width = (float)itemInfo.MyDocStyle.Layout.PageWidth - XOffset - (sitabloc / 2); + return; + } + // F2019-069: Hold Point designator for Barakah, use parent's tab for xoffset + if (itemInfo.IsStep && itemInfo.FormatStepData.ColUseParentTab && (myTab == null || myTab.Text == "")) + { + if (MyParent != null) + { + XOffset = (MyParent.MyTab == null || MyParent.MyTab.Text == null || MyParent.MyTab.Text.Trim() == "") ? MyParent.XOffset : MyParent.MyTab.XOffset; + return; + } + } + float tabWidth = (myTab == null) ? 0 : myTab.Width; + if (itemInfo.IsStepSection) + { + if (formatInfo.PlantFormat.FormatData.SectData.SectionHeader.Just == "PSLeft") + { + int level = 0; + ItemInfo iilvl = itemInfo; + while (!iilvl.IsProcedure) + { + level++; + iilvl = iilvl.MyParent; + } + if (formatInfo.PlantFormat.FormatData.PrintData.SpecialCaseCalvert) + { + XOffset = (myTab == null ? 0 : myTab.XOffset) + ((float)formatInfo.PlantFormat.FormatData.SectData.SectionHeader.Pos - (float)formatInfo.PlantFormat.FormatData.SectData.SectionNumber.Pos); + } + else + { + level = level <= 2 ? 1 : level - 1; + if (level == 1) + { + // Use the section number position for the section title when the section number is blank + if (formatInfo.PlantFormat.FormatData.SectData.SectionHeader.UseNumPosWhenNumBlank && MyTab != null && MyTab.Text.Trim().Length == 0) + { + XOffset = (float)itemInfo.MyDocStyle.Layout.LeftMargin + ((float)formatInfo.PlantFormat.FormatData.SectData.SectionNumber.Pos); + } + else + XOffset = (float)itemInfo.MyDocStyle.Layout.LeftMargin + (level * (float)formatInfo.PlantFormat.FormatData.SectData.SectionHeader.Pos); + } + else if (formatInfo.PlantFormat.FormatData.PrintData.SpecialCaseCalvert) + XOffset = (myTab == null ? 0 : myTab.XOffset) + ((float)formatInfo.PlantFormat.FormatData.SectData.SectionHeader.Pos - (float)formatInfo.PlantFormat.FormatData.SectData.SectionNumber.Pos); + else + { + XOffset = (float)itemInfo.MyDocStyle.Layout.LeftMargin + (float)formatInfo.PlantFormat.FormatData.SectData.MetaSectionList[level].ColSByLevel; + XOffset += (float)formatInfo.PlantFormat.FormatData.SectData.MetaSectionList[level].SecTitlePositionAdj; + XOffset -= xMetaAdj; + } + + if (itemInfo.MyDocStyle.SectTitleOffsetOverride != null) + { + XOffset += (float)itemInfo.MyDocStyle.SectTitleOffsetOverride; + } + + } + } + else if (formatInfo.PlantFormat.FormatData.SectData.SectionHeader.Just == "PSCenter") + { + float hdrWidth = itemInfo.MyContent.Text.Length * 6; + float ctr = (((float)itemInfo.MyDocStyle.Layout.PageWidth - (float)itemInfo.MyDocStyle.Layout.LeftMargin)) / 2; + XOffsetCenter = (float)itemInfo.MyDocStyle.Layout.LeftMargin + ctr - (hdrWidth / 2); + } + return; + } + // B2021-091 added a null reference check - itemInfo was a section and didn't have FormatStepData so just return + if (itemInfo.FormatStepData == null) return; + + int? bxIndx = itemInfo.FormatStepData.StepLayoutData.STBoxindex; + float? colOvrd = itemInfo.FormatStepData.ColOverride; + if (itemInfo.IsBackgroundStep())//WolfCreekBackgroundFormat && IsHigh||IsNote||IsCaution or ImplicitOR + { + int adj = 2; + if (myTab != null) + { + //B2018-139 use XOffset when processing HLS, Caution, or Note background text and tab + if (itemInfo.IsHigh || (itemInfo.IsNote && (itemInfo.MyParent.IsHigh || itemInfo.MyParent.IsCaution || itemInfo.MyParent.IsNote)) || (itemInfo.IsCaution && (itemInfo.MyParent.IsHigh || itemInfo.MyParent.IsCaution || itemInfo.MyParent.IsNote))) + myTab.XOffset = XOffset; + else + { + // F2018-041 seq tabs off of TitleWithTextBelow were running into the step text + myTab.XOffset = XOffset + (itemInfo.FormatStepData.Font.CharsToTwips * adj); // F2018-041 move tab over 2 chars so it positions like paragraphs under TitleWithTextBelow + adj += myTab.Text.Length; // F2018-041 add the length of the tab to the adjustment of the XOffset + } + } + XOffset += (itemInfo.FormatStepData.Font.CharsToTwips * adj); // indent 2 characters for background steps + // B2018-146 Adjust the width to match the HLS Right Margin. + + Width = this.MyHighLevelParagraph.Width + this.MyHighLevelParagraph.XOffset - this.XOffset; + return; + } + else if (itemInfo.FormatStepData.UseOldTemplate && itemInfo.IsInTemplate() && + (MyItemInfo.ActiveSection != null && (MyItemInfo.ActiveSection.MyDocStyle.StructureStyle.Style & E_DocStructStyle.DSS_PageListSpBckgrnd) == E_DocStructStyle.DSS_PageListSpBckgrnd)) // C2018-003 fixed use of getting the active section + { + if (myTab != null) myTab.XOffset = XOffset; + XOffset += myTab.Width; + return; + } + else if (itemInfo.FormatStepData != null && itemInfo.FormatStepData.Type == "TitleWithTextBelow") + { + if ((colOvrd ?? 0) != 0) + XOffset = (float)colOvrd; + else + XOffset = (float)itemInfo.MyDocStyle.Layout.LeftMargin; + // B2018-146 Adjust the width to match the HLS Right Margin. + if (itemInfo.IsPartOfBackgroundStep()) + Width = this.MyHighLevelParagraph.Width + this.MyHighLevelParagraph.XOffset - this.XOffset; + return; + } + else if (itemInfo.IsParagraph && + (((itemInfo.ActiveFormat.PlantFormat.FormatData.PurchaseOptions.Value & E_PurchaseOptions.EnhancedBackgrounds) == E_PurchaseOptions.EnhancedBackgrounds) || + ((itemInfo.ActiveFormat.PlantFormat.FormatData.PurchaseOptions.Value & E_PurchaseOptions.EnhancedDeviations) == E_PurchaseOptions.EnhancedDeviations)) && + itemInfo.FormatStepData != null && PreviousIsTitleWithTextBelow(itemInfo)) + { + // This code was needed for fix for B2015-183 && + // IP2 backgrounds so that any 'paragraph's that were at the same + // level as the 'TitleWithTextBelow's would have same left margin (xoffset) as the 'TitleWithTextBelow'. + // an example of this can be found in IP2 Backgrounds, 2-E-0, Step Description Table, Step 22, PLANT-SPECIFIC INFORMATION. + // (NOTE that the IP2 exaxmple was no longer in the data when the work on B2015-183 was done) + if ((colOvrd ?? 0) != 0) + XOffset = (float)colOvrd; + else + { + //Adjuust Indent for Wolf Creek Background format flag + float indentBG1 = itemInfo.IsPartOfBackgroundStep() ? itemInfo.FormatStepData.Font.CharsToTwips * 2 : 0; + XOffset = (float)itemInfo.MyDocStyle.Layout.LeftMargin + indentBG1; + // B2018-146 Adjust the width to match the HLS Right Margin. + if (itemInfo.IsPartOfBackgroundStep()) + Width = this.MyHighLevelParagraph.XOffset + this.MyHighLevelParagraph.Width - XOffset; + else + Width = (float)itemInfo.MyDocStyle.Layout.PageWidth - (float)itemInfo.MyDocStyle.Layout.LeftMargin - indentBG1; + } + return; + } + else if (itemInfo.MyParent.FormatStepData != null && itemInfo.MyParent.FormatStepData.Type == "TitleWithTextBelow" && (!itemInfo.ActiveFormat.PlantFormat.FormatData.PrintData.SpecialCaseCalvertAlarm || (!itemInfo.IsCaution && !itemInfo.IsNote))) + { + float childindent = itemInfo.MyParent.FormatStepData.ChildIndent ?? 0; + if (myTab != null) + { + float delta = childindent + MyParent.XOffset - myTab.XOffset; + myTab.XOffset += delta; + XOffset += delta; + // B2018-036: set the width of (background/deviation/alarms/etc) steps that have a tab + if (!itemInfo.ActiveFormat.PlantFormat.FormatData.PrintData.SpecialCaseCalvertAlarm || !UseTemplateWidthOrXOff(itemInfo.MyParent)) + { + // B2018-146 Adjust the width to match the HLS Right Margin. + // F2023-112 added format flag for Vogtle Units 3 & 4 backgrounds. This allows use of override width on AND and List sub-step types + if (itemInfo.IsBackgroundStepOrChild() || itemInfo.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.Vogtle3and4BackgroundFormat) + Width = this.MyHighLevelParagraph.Width + this.MyHighLevelParagraph.XOffset - this.XOffset; + else + Width = (float)itemInfo.MyDocStyle.Layout.PageWidth - (float)itemInfo.MyDocStyle.Layout.LeftMargin - delta; + } + } + else + { + //Adjust Indent for Wolf Creek Background format flag + float indentBG2 = itemInfo.IsPartOfBackgroundStep() ? itemInfo.FormatStepData.Font.CharsToTwips * 2 : 0; + XOffset = childindent + MyParent.XOffset + indentBG2; + // B2016-164: Added the following 'if' so that the width is not recalculated if in the alarm format & the parent has a template + // B2016-168: The fix for 164 broke deviation document printing. The if statement was fixed for both: + // B2019-057 Added a check to see if there is a width override for this step element (Robinson AOP Backgrounds - paragraphs) + float wdthovrd = (itemInfo.FormatStepData.WidthOverride == null) ? 0 : (float)ToInt(itemInfo.FormatStepData.WidthOverride, maxRNO); + if ((!itemInfo.ActiveFormat.PlantFormat.FormatData.PrintData.SpecialCaseCalvertAlarm || !UseTemplateWidthOrXOff(itemInfo.MyParent)) && wdthovrd == 0) + Width = (float)itemInfo.MyDocStyle.Layout.PageWidth - (float)itemInfo.MyDocStyle.Layout.LeftMargin - indentBG2; + } + return; + } + else if (itemInfo.FormatStepData != null && itemInfo.FormatStepData.Type == "TitleWithTextRight") + { + if ((colOvrd ?? 0) != 0) + XOffset = (float)colOvrd; + else + XOffset = (float)itemInfo.MyDocStyle.Layout.LeftMargin; + return; + } + else if (itemInfo.MyParent.FormatStepData != null && itemInfo.MyParent.FormatStepData.Type == "TitleWithTextRight") + { + XOffset = MyParent.MyParent.XOffset; + // if the step text has a tab, then we need to position the tab to the XOffset and then ajust the text XOffset + // by the length of the tab. - fix for IP2 backgrounds (ex. 2-ECA-3.3, step 6) + if (myTab != null) + { + myTab.XOffset = XOffset; + XOffset += (myTab.Text.Length * myTab.MyFont.CharsToTwips);//myTab.Width - myTab.XOffset; + } + return; + } + if (itemInfo.IsHigh) + { + if (formatInfo.PlantFormat.FormatData.PrintData.SpecialCaseCalvertAlarm || + ((itemInfo.MyDocStyle.StructureStyle.Style & E_DocStructStyle.DSS_SameXOffSubsections) == E_DocStructStyle.DSS_SameXOffSubsections)) + { + // the HLS in the template prints the tab/step on the right edge of page. Don't + // do the other calculations to relocate it. + if (itemInfo.FormatStepData.UseOldTemplate && itemInfo.IsInTemplate()) + { + MyTab.XOffset = XOffset - MyTab.Width; + return; + } + // the following code handles the xoffsets of tabs/HLS in the non-alarm sections for + // the Calvert Alarm format. + if (itemInfo.MyDocStyle.UseColSByLevel) + { + if (myTab != null) + { + myTab.Rtf = myTab.Rtf.Replace(myTab.Text, myTab.Text.TrimStart(" ".ToCharArray())); + // B2022-129: don't indent HLS when flag is on (Barakah - single column step attachment with meta sect) + if (itemInfo.MyDocStyle.AdjSectTitleLoc) + { + myTab.XOffset = MyParent.MyTab.XOffset; + XOffset = MyParent.XOffset; + } + else + { + myTab.XOffset = MyParent.XOffset; + XOffset = myTab.XOffset + MyTab.Width; + } + } + else + XOffset = MyParent.XOffset; // unnumbered hls + return; + } + } + float x; + if ((colOvrd ?? 0) != 0) + x = (float)itemInfo.MyDocStyle.Layout.LeftMargin + (float)colOvrd; + else + x = (float)itemInfo.MyDocStyle.Layout.LeftMargin + (float)formatInfo.PlantFormat.FormatData.SectData.StepSectionData.StepSectionLayoutData.ColS; + + float xoff = x - XOffset; + // ColSByLevel will specify the column in which the High Level Step starts with + // respect to the overall level calculation based on sections & meta-sections. + // Only a few of the single column formats use this: WCN1, CAL1, RGEBCK + if (formatInfo.PlantFormat.FormatData.SectData.StepSectionData.StepSectionLayoutData.TieTabToLevel + && !(itemInfo.MyDocStyle.SpecialStepsFoldout && itemInfo.MyDocStyle.UseColSByLevel)) + { + int indxLevel = itemInfo.PrintLevel + itemInfo.CurrentSectionLevel(); + // B2021-113: BNPP1new - subsection & HLS should be same level (xoffset of tab & text) + if (formatInfo.PlantFormat.FormatData.SectData.StepSectionData.StepSectionLayoutData.SubSectAndHighSameLevel && !MyItemInfo.MyActiveSection.MyParent.IsProcedure) indxLevel++; + float colsbylevel = (float)formatInfo.PlantFormat.FormatData.SectData.MetaSectionList[indxLevel % formatInfo.PlantFormat.FormatData.SectData.MetaSectionList.MaxIndex].ColSByLevel; + float seclvlindent = colsbylevel - (float)formatInfo.PlantFormat.FormatData.SectData.StepSectionData.StepSectionLayoutData.ColS; + float adjCols = (float)formatInfo.PlantFormat.FormatData.SectData.StepSectionData.StepSectionLayoutData.ColS + seclvlindent; + float xtabcol = adjCols - ((myTab == null || myTab.Text == null) ? 0 : (myTab.Text.Length * 7.2f)); + if (indxLevel > 1 && myTab != null) myTab.XOffset = (float)itemInfo.MyDocStyle.Layout.LeftMargin + xtabcol; + else if (myTab != null) myTab.XOffset = (float)itemInfo.MyDocStyle.Layout.LeftMargin + colsbylevel; + if (myTab != null) + { + myTab.Rtf = myTab.Rtf.Replace(myTab.Text, myTab.Text.TrimStart(" ".ToCharArray())); + if (formatInfo.PlantFormat.FormatData.SectData.StepSectionData.StepSectionPrintData.LeftJustifyList != null && + formatInfo.PlantFormat.FormatData.SectData.StepSectionData.StepSectionPrintData.LeftJustifyList.Count > 0) + // B2021-113: BNPP1new - subsection & HLS should be same level (xoffset of tab & text) + if (formatInfo.PlantFormat.FormatData.SectData.StepSectionData.StepSectionLayoutData.SubSectAndHighSameLevel && !MyItemInfo.MyActiveSection.MyParent.IsProcedure) + XOffset += tabWidth; + else + XOffset = myTab.XOffset + GetLeftJustify(formatInfo, indxLevel); // 2.1.1 goes here xoffset = 136 + else + XOffset = myTab.XOffset + (myTab.Text.Length * (float)itemInfo.FormatStepData.Font.CPI) - colsbylevel; + } + } + else + { + XOffset += xoff; + // For Calvert, adjust from the left margin and current section's tab. This is used + // in BGEEOP (see EOP-0/Purpose ). However, it caused BGESTP's to print LossOfAC steps (unnumbered HLS) too + // far to the left. The ForceAlignNullTabWSectHead was introduced so that for that step type (LossOfAC) in STP/OI format, + // the SectData.SectionHeader.Pos was used rather than SectData.SectionNumber.Pos + if (myTab == null && !itemInfo.FormatStepData.ForceAlignNullTabWSectHead && itemInfo.FormatStepData.AlignNullTabWSectHead && itemInfo.ActiveFormat.PlantFormat.FormatData.PrintData.SpecialCaseCalvert) + XOffset = (float)itemInfo.MyDocStyle.Layout.LeftMargin + (float)formatInfo.PlantFormat.FormatData.SectData.SectionNumber.Pos; + else if (myTab == null && itemInfo.FormatStepData.AlignNullTabWSectHead) + XOffset = (float)itemInfo.MyDocStyle.Layout.LeftMargin + (float)formatInfo.PlantFormat.FormatData.SectData.SectionHeader.Pos; + if (myTab != null) + { + if (itemInfo.MyDocStyle.AlignHLSTabWithSect || itemInfo.FormatStepData.AlignHLSTabWithSectOvride) + { + float orgXOffset = MyTab.XOffset; + myTab.XOffset = (float)itemInfo.MyDocStyle.Layout.LeftMargin + (float)formatInfo.PlantFormat.FormatData.SectData.SectionHeader.Pos; + XOffset = myTab.XOffset + myTab.Width; + // F2025-040 Adjust the Cont Act box position around HLS number + if (myTab.MyMacro != null) myTab.MyMacro.XOffset += (MyTab.XOffset - orgXOffset); + } + else + { + myTab.XOffset += xoff; + if (myTab.MyMacro != null) myTab.MyMacro.XOffset += xoff; + } + } + else + { + if (itemInfo.MyDocStyle.AlignHLSTabWithSect) + XOffset = (float)itemInfo.MyDocStyle.Layout.LeftMargin + (float)formatInfo.PlantFormat.FormatData.SectData.SectionHeader.Pos; + } + } + } + else if (((colOvrd ?? 0) != 0) && (formatInfo.PlantFormat.FormatData.SectData.StepSectionData.StepSectionLayoutData.NullBox)) + { + float tabOffset = (myTab == null ? 0 : myTab.XOffset) - XOffset; + XOffset = (float)colOvrd; + if (myTab != null) myTab.XOffset = XOffset + tabOffset; + return; + } + else if (((colOvrd ?? 0) != 0) && (IsEnhancedBackgroundFormat(itemInfo) && (itemInfo.IsNote || itemInfo.IsCaution))) + { + float tabOffset = (myTab == null ? 0 : myTab.XOffset); + // Adjust the position of the Note/Caution text by the difference of the colOverride and the tab xoffset + XOffset += ((float)colOvrd - tabOffset); + if (myTab != null) myTab.XOffset = (float)colOvrd; // set the note/caution tab offset to the colOverride + return; + } + // put in for Point Beach (wep2) we don't want to do this if we are processing a boxed substep (cont. action substep) + else if (bxIndx != null && (itemInfo.IsCaution || itemInfo.IsNote || + !itemInfo.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.StepSectionPrintData.ContActBoxOnSubSteps)) + { + Box bx = formatInfo.PlantFormat.FormatData.BoxList[(int)bxIndx]; + if (bx == null) + { + if ((colOvrd ?? 0) != 0) + { + float tabOffset = (myTab == null ? 0 : myTab.XOffset) - XOffset; + + XOffset = (float)colOvrd; + if (myTab != null) myTab.XOffset = XOffset + tabOffset; + return; + } + else + XOffset = (float)itemInfo.MyDocStyle.Layout.LeftMargin + tabWidth + XOffsetBox; + } + else + XOffset = (float)itemInfo.MyDocStyle.Layout.LeftMargin + (float)bx.TxtStart + _MyBoxLeftAdj + tabWidth + XOffsetBox; + if (myTab != null) myTab.XOffset = XOffset - tabWidth; + } + else if (itemInfo.IsRNOPart && itemInfo.MyParent != null && itemInfo.MyParent.IsRNOPart && itemInfo.FormatStepData.NumberWithLevel) + { + // xoffset is same as parent RNO (this is a BGE format flag). Instead of RNO's being siblings, + // they had a parent/child relationship. So want the child to have same xoffset as parent, i.e. + // the same xoffset. + XOffset = MyParent.XOffset; + myTab.XOffset = MyParent.MyTab.XOffset; + return; + } + else if (itemInfo.IsRNOPart && (colOvrd > 0 || !((ItemInfo)itemInfo.ActiveParent).IsHigh) && itemInfo.FormatStepData.OffsetTab) + { + if (colOvrd > 0) + { + XOffset = (int)colOvrd; + if (!((ItemInfo)itemInfo.MyParent).IsHigh) + { + ItemInfo hls = itemInfo.MyHLS; + XOffset -= (itemInfo.MyTab.Offset - hls.MyTab.Offset); + } + } + // if this format has the centerline & numberwithlevel (special tabbing for rno) then + // position rno xoffset of the tab to be close to centerline & text indented from there (only BGE) + if (itemInfo.MyDocStyle.CenterLineX != null && itemInfo.FormatStepData.NumberWithLevel) + { + // if the tab is 3 char or smaller, make the indent amount for the rno text 4 characters. + // if bigger, make it the additional tab size. + int len = myTab.Text.Trim().Length; + int adj = len <= 3 ? 4 : (len - 3) + 4; + float rnoOffset = (float)itemInfo.MyDocStyle.Layout.LeftMargin + (float)itemInfo.MyDocStyle.CenterLineX + 5; + float tPtPerChar = itemInfo.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.StepSectionLayoutData.TabPtsPerChar ?? 6; + XOffset = rnoOffset + tPtPerChar * adj; + Width = (float)itemInfo.MyDocStyle.Layout.PageWidth - XOffset - 11; // 11 is about size of char, so don't touch right line. + if (myTab != null) myTab.XOffset = rnoOffset; + } + // if the step is within the rno and we're numbering the high level rno, we've got to account for the + // indenting (increased x offset) for the top level rno's tab, if there is no top level rno: + else if (itemInfo.FormatStepData.NumberHighLevel && (itemInfo.MyHLS.RNOs == null || itemInfo.MyHLS.RNOs.Count <= 0)) + { + // add in the size that an RNO off HLS would take. + tabWidth += itemInfo.MyTab.RNOTabWidthAdjust; + XOffset += tabWidth; + if (myTab != null) myTab.XOffset += tabWidth; + } + if (itemInfo.ActiveFormat.MyStepSectionLayoutData.DevNoteOrCautionTabOffset != null) + { + MyTab.XOffset = float.Parse(itemInfo.ActiveFormat.MyStepSectionLayoutData.DevNoteOrCautionTabOffset); + XOffset = MyTab.XOffset + tabWidth - MyTab.TabAlign; + } + } + else if (MyParent != null) + { + if (myTab == null && itemInfo.FormatStepData.AlignNullTabWSectHead && itemInfo.ActiveFormat.PlantFormat.FormatData.PrintData.SpecialCaseCalvert) + XOffset = (float)itemInfo.MyDocStyle.Layout.LeftMargin + (float)formatInfo.PlantFormat.FormatData.SectData.SectionNumber.Pos; + else if (itemInfo.ActiveFormat.MyStepSectionLayoutData.DevNoteOrCautionTabOffset != null) + { + if (MyTab != null) + { + MyTab.XOffset = float.Parse(itemInfo.ActiveFormat.MyStepSectionLayoutData.DevNoteOrCautionTabOffset); + XOffset = MyTab.XOffset + tabWidth - MyTab.TabAlign; + if (myTab.MyMacro != null && myTab.MyMacro.XOffset != 0) myTab.MyMacro.XOffset += tabWidth - myTab.TabAlign; + } + } + else if (itemInfo.IsSequential && itemInfo.MyParent.IsHigh && ((itemInfo.MyDocStyle.StructureStyle.Style & E_DocStructStyle.Align1StLevSubWHLS) == E_DocStructStyle.Align1StLevSubWHLS)) + { + XOffset = MyParent.XOffset; + if (myTab != null) myTab.XOffset = (MyParent.MyTab != null ? MyParent.MyTab.XOffset : XOffset); + } + else if (itemInfo.IsSequential && itemInfo.MyHLS.FormatStepData.AppendDotZero)// F2018-025 shift first level substep to column position of high level step Westinghouse wst1 step type 50 + { + if (itemInfo.MyParent.IsHigh) + { + XOffset = MyParent.XOffset; + if (myTab != null) myTab.XOffset = (MyParent.MyTab != null ? MyParent.MyTab.XOffset : XOffset); + } + else + { + myTab.XOffset = MyParent.XOffset; + XOffset = myTab.XOffset + MyTab.Width; + } + } + else if (myTab != null && itemInfo.IsSequential && formatInfo.PlantFormat.FormatData.SectData.UseMetaSections && formatInfo.PlantFormat.FormatData.SectData.StepSectionData.StepSectionPrintData.LeftJustifyList.Count > 0) + { + int indxLevels = itemInfo.PrintLevel + itemInfo.CurrentSectionLevel(); + // B2021-113: BNPP1new - subsection & HLS should be same level (xoffset of tab & text) + if (formatInfo.PlantFormat.FormatData.SectData.StepSectionData.StepSectionLayoutData.SubSectAndHighSameLevel && !MyItemInfo.MyActiveSection.MyParent.IsProcedure) indxLevels++; + float tableftadj = GetLeftJustify(formatInfo, indxLevels); + if (tableftadj != 0) + { + // the order of this is important. First adjust the tab's xoffset for the width of + // the tab. The offset of text needs to be adjusted by the 'leftjustify' format variable + // if it existed for this level. + myTab.XOffset += tabWidth; + if (tableftadj != 0 && myTab.Width < tableftadj) + tabWidth = myTab.Width = tableftadj; + XOffset += tabWidth; + myTab.Rtf = myTab.Rtf.Replace(myTab.Text, myTab.Text.TrimStart(" ".ToCharArray())); + Width = MyParent.Width - myTab.Width; + } + else // if no left justify, right align the tab + { + XOffset += tabWidth - (myTab == null ? 0 : myTab.TabAlign); + if (myTab != null) + { + myTab.XOffset += tabWidth - myTab.TabAlign; + if (myTab.MyMacro != null && myTab.MyMacro.XOffset != 0) myTab.MyMacro.XOffset += tabWidth - myTab.TabAlign; + } + } + } + else // if no left justify, right align the tab + { + // The following fixes F2016-033: Print the Verification Point at left margin. + if (itemInfo.ActiveFormat.Name.ToUpper().StartsWith("VCB") && (itemInfo.FormatStepData.ColOverride ?? 0) > 0) + { + XOffset = (float)itemInfo.FormatStepData.ColOverride; + } + else + { + XOffset += tabWidth - (myTab == null ? 0 : myTab.TabAlign); + if (myTab != null) + { + myTab.XOffset += tabWidth - myTab.TabAlign; + if (myTab.MyMacro != null && myTab.MyMacro.XOffset != 0) myTab.MyMacro.XOffset += tabWidth - myTab.TabAlign; + } + // B2018-146 Adjust the width to match the HLS Right Margin. + if (itemInfo.IsBackgroundStepOrChild()) + Width = this.MyHighLevelParagraph.Width + this.MyHighLevelParagraph.XOffset - this.XOffset; + } + } + } + // if format had a tab adjustment for step type, use it. MyTab.Offset is only set for FNP formats + // to get the correct xoffset for their tabs/text. The issue is that they use very large tabs + // because levels of substeps include the parent tab. This code will only be run for FNP. + if (itemInfo.MyTab != null && itemInfo.MyTab.Offset != 0) + { + float xOffTabNew = (MyParent.MyTab != null ? MyParent.MyTab.XOffset : MyParent.XOffset) + itemInfo.MyTab.Offset; + xOffTabNew += MyParent.MyTab == null ? 0 : MyParent.MyTab.TabOffset; + float xIncrement = xOffTabNew - MyTab.XOffset; + myTab.XOffset += xIncrement; + XOffset += xIncrement; + Width -= xIncrement; + } + } + private bool PreviousIsTitleWithTextBelow(ItemInfo itemInfo) + { + while (itemInfo.MyPrevious != null) + { + if (itemInfo.MyPrevious.FormatStepData.Type == "TitleWithTextBelow") return true; + itemInfo = itemInfo.MyPrevious; + } + return false; + } + + private static float GetLeftJustify(FormatInfo formatInfo, int indxLevels) + { + LeftJustifyList jstlst = formatInfo.PlantFormat.FormatData.SectData.StepSectionData.StepSectionPrintData.LeftJustifyList; + float tableftadj = 0; + foreach (LeftJustify lj in jstlst) + { + if (lj.Index == indxLevels) + { + tableftadj = lj.Size ?? 0; + break; + } + } + return tableftadj; + } + + public float CheckOffWidth { get; set; } = 0; + public float AdjustHeader { get; set; } = 0; + public void AdjustWidth(ItemInfo itemInfo, int maxRNO, FormatInfo formatInfo, vlnTab myTab) + { + int? bxIndx = itemInfo.IsStep ? itemInfo.FormatStepData.StepLayoutData.STBoxindex : null; + float xwid; + float? widOvrd; + if (itemInfo.IsStep && itemInfo.MyHLS != null && UseTemplateWidthOrXOff(itemInfo) && (xwid = GetWidthOrStartFromTemplate(itemInfo, formatInfo, true)) > 0) + widOvrd = xwid; + else + widOvrd = itemInfo.FormatStepData == null ? null : itemInfo.FormatStepData.WidthOverride == null ? null : + (float?)ToInt(itemInfo.FormatStepData.WidthOverride, maxRNO); + // Calvert subheaders in valve lists - the text gets centered, so the width is the width + // of the page (also, don't do this for alarms, thus the !SpecialCaseCalvert Alarms, since + // alarms use Caution1 as the annunciator): + if (itemInfo.IsStep && itemInfo.MyHLS != null && !itemInfo.ActiveFormat.PlantFormat.FormatData.PrintData.SpecialCaseCalvertAlarm && + itemInfo.MyHLS.FormatStepData.UseOldTemplate && itemInfo.MyDocStyle.ComponentList && itemInfo.IsCaution1) + { + Width = (float)itemInfo.MyDocStyle.Layout.PageWidth - (float)itemInfo.MyDocStyle.Layout.LeftMargin; + return; + } + + // Calvert Alarms had a case where the Title With Text Below (type 42) did not match + // any of the template items, but needed the width from the template. The previous step (of + // same type) was in the template. Check for this case. The issue can be found in + // Unit 1 Alarms/1c06/Alarm E-48/'General Information' section. + if (itemInfo.ActiveFormat.PlantFormat.FormatData.PrintData.SpecialCaseCalvertAlarm && widOvrd == 0) + { + if (itemInfo.MyPrevious != null && itemInfo.MyPrevious.TemplateIndex > 1) widOvrd = GetWidthOrStartFromTemplate(itemInfo.MyPrevious, itemInfo.MyPrevious.ActiveFormat, true); + } + + // for IP2 backgrounds, set widths appropriately for template items: + if (itemInfo.IsStep && (itemInfo.ActiveSection != null && (itemInfo.ActiveSection.MyDocStyle.StructureStyle.Style & E_DocStructStyle.DSS_PageListSpBckgrnd) == E_DocStructStyle.DSS_PageListSpBckgrnd)) // C2018-003 fixed use of getting the active section + { + if (itemInfo.FormatStepData.Type.ToUpper() == "TITLEWITHTEXTBELOW") + { + Width = MyParent.Width; + return; + } + if (itemInfo.MyPrevious != null && itemInfo.MyPrevious.FormatStepData.Type == "TitleWithTextBelow") + { + Width = MyParent.MyParent.Width; + return; + } + if (widOvrd == 0 && itemInfo.MyParent.IsStep && + (itemInfo.MyParent.FormatStepData.Type.ToUpper() == "TITLEWITHTEXTBELOW" || + (((itemInfo.ActiveSection.MyDocStyle.StructureStyle.Style & E_DocStructStyle.DSS_PageListSpBckgrnd) == E_DocStructStyle.DSS_PageListSpBckgrnd) && + itemInfo.FormatStepData != null && MyParent.MyItemInfo.MyPrevious != null && MyParent.MyItemInfo.MyPrevious.FormatStepData.Type == "TitleWithTextBelow"))) + { + Width = MyParent.MyParent.Width + (MyParent.MyParent.MyTab != null ? MyParent.MyParent.MyTab.Width : 0); + Width -= (MyTab != null ? MyTab.Width : 0); + return; + } + } + + //widOvrd = itemInfo.FormatStepData == null ? null : itemInfo.FormatStepData.WidthOverride; + // Don't adjust the RNO width if in single column mode: + if (itemInfo.IsRNOPart && itemInfo.MyParent.IsHigh && itemInfo.ActiveSection != null && itemInfo.ActiveSection.ColumnMode != 0 && itemInfo.ActiveFormat.MyStepSectionLayoutData.RNOWidthAlt != null) // C2018-003 fixed use of getting the active section + { + string[] splitRNOWidthAlt = itemInfo.ActiveFormat.MyStepSectionLayoutData.RNOWidthAlt.Split(','); + float ovrd = (itemInfo.RNOLevel < splitRNOWidthAlt.Length) ? float.Parse(splitRNOWidthAlt[itemInfo.RNOLevel]) : 0; + if (ovrd > 0) + widOvrd = ovrd; // + 6; // Change bars on RNO column (signoff line) would not line up with 16-bit without this - NSP Alarms + } + if ((widOvrd ?? 0) != 0) + { + //F2023-112 Vogtle Units 3 & 4 Backgrounds. Don't use override width of paragraph when it's off of TitleWithTextRight + // We need to allow the code to calculate the width of that paragraph for this case (later in this function) + if (!(itemInfo.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.Vogtle3and4BackgroundFormat && itemInfo.MyParent.FormatStepData != null && itemInfo.MyParent.FormatStepData.Type == "TitleWithTextRight")) + { + Width = (float)widOvrd; + // if there's a box, we may need to do an adjustment on the width, if the tab data was changed + // so don't return. + if (bxIndx == null) return; + } + } + float tabWidth = (myTab == null) ? 0 : myTab.Width; + if (itemInfo.IsHigh) + { + float CheckOffAdj = 0; + bool ChkOff = itemInfo.MyDocStyle.UseCheckOffs; + // C2019-040 use format flag to see if any of the steps in this section have a checkoff set - previously we check if the format file name starts with VCB (VCB no longer a customer) + if (itemInfo.ActiveFormat.PlantFormat.FormatData.PrintData.SpecialCaseCalvert || itemInfo.ActiveFormat.PlantFormat.FormatData.ProcData.CheckOffData.CheckoffsWithoutHeader) + { + SectionInfo si = itemInfo.ActiveSection.GetSectionInfo(); + ChkOff = si.HasInitials; // this determines if any steps within the section have checkoffs. + } + bool FmtHasAdj = false; + if (ChkOff) + { + if (formatInfo.PlantFormat.FormatData.ProcData.CheckOffData.CheckOffAdjustment != null) + { + FmtHasAdj = true; + CheckOffAdj = -(float)formatInfo.PlantFormat.FormatData.ProcData.CheckOffData.CheckOffAdjustment; + } + // C2019-040 use format flag to not readjust the CheckOffAdj value - previously we check if the format file name starts with VCB (VCB no longer a customer) + if (!itemInfo.ActiveFormat.PlantFormat.FormatData.ProcData.CheckOffData.CheckoffsWithoutHeader) // Don't do the following if in a vcb format (part of fix F2016-039) + { + if (!HasCheckOffHeading(itemInfo, formatInfo) && CheckOffAdj < 0) + CheckOffAdj += (float)(9 * 7.2); // 9 is the size of the SIGNOFF adjustment + else if (!FmtHasAdj && HasCheckOffHeading(itemInfo, formatInfo)) + // For Robinson, tried using font's CharsToTwips but it made it too narrow, so used hardcoded 6: + CheckOffAdj = -((float)9 * 6); + } + } + float adjwidth = CheckOffAdj; + CheckOffWidth = -CheckOffAdj; + adjwidth = AdjustMetaWidth(itemInfo, formatInfo, adjwidth, FmtHasAdj); + Width = ToInt(formatInfo.MyStepSectionLayoutData.WidSTablePrint, maxRNO); + Width += _WidthAdjust; + Width += adjwidth; + + // if AlignHLSTabWithSect is set, we moved the starting x location of the HLS, and following steps + // to be under section header. Adjust the width accordingly, or the text may go out of the margin. + if (myTab == null && itemInfo.FormatStepData.AlignNullTabWSectHead && itemInfo.ActiveFormat.PlantFormat.FormatData.PrintData.SpecialCaseCalvert) + Width = Width + (float)formatInfo.PlantFormat.FormatData.SectData.SectionHeader.Pos - (float)formatInfo.PlantFormat.FormatData.SectData.SectionNumber.Pos; + else if (myTab == null && itemInfo.FormatStepData.AlignNullTabWSectHead) + Width += (float)formatInfo.PlantFormat.FormatData.SectData.SectionHeader.Pos; + else if (itemInfo.MyDocStyle.AlignHLSTabWithSect) + Width -= (float)formatInfo.PlantFormat.FormatData.SectData.SectionHeader.Pos; + + // B2022-002: Section text is printing into the INITIAL column (BNPP1new). If this flag is set adjust the width of the + // section text to that of the first hls (child) text and its tab. This is to prevent the very long section titles (that should have + // been steps) from extending into the INITIAL (checkoff) column. + if (formatInfo.PlantFormat.FormatData.SectData.AdjWidthForCheckOff && MyParent != null && MyParent.MyItemInfo.IsSection && ChkOff && CheckOffWidth != 0 && itemInfo.ItemID == itemInfo.FirstSibling.ItemID) + { + SectionInfo si = MyParent.MyItemInfo.GetSectionInfo(); + if (si.HasInitials) MyParent.Width = Width + ((myTab == null) ? 0 : myTab.Width); + } + } + else if (bxIndx != null) + { + Box bx = formatInfo.PlantFormat.FormatData.BoxList[(int)bxIndx]; + if (bx == null) + { + if (widOvrd != 0) + Width = (float)widOvrd - tabWidth; + else + Width = (float)formatInfo.MyStepSectionLayoutData.WidT - tabWidth; + } + else + { + float oldWidth = _WidthAdjustBox + (float)bx.TxtWidth - tabWidth; // add 1 to get it to wrap like 16Bit + // B2018-096 AEP 082.002CD Note Box overlapping Step Box + if (MyParent.MyItemInfo.FormatStepData != null && MyParent.MyItemInfo.FormatStepData.BoxIt) // B2018-100 not for parents that are sections // B2018-098 only adjust width if parent has Boxit turned on + { + Width = Math.Min(MyParent.Width + MyParent.XOffset - XOffset, oldWidth); + AdjustHeader = (Width - oldWidth) / 2; + } + else + Width = oldWidth; + } + } + else if ((itemInfo.IsCaution || itemInfo.IsNote) && !itemInfo.FormatStepData.UseOldTemplate) + { + float mycolT = (float)formatInfo.MyStepSectionLayoutData.ColT; + if (formatInfo.MyStepSectionLayoutData.Dev_Format) + Width = (float)formatInfo.MyStepSectionLayoutData.WidT + 1; + else if (itemInfo.IsInRNO) + { + // C2014-009: Condition/Response adjust xoffset & width + // B2020-117 add a check that there is only one Caution/Note/Warning + if (MyItemInfo.FormatStepData.CenterOneLineAdjust && MyItemInfo.FirstSibling == MyItemInfo.LastSibling) + { + int rnoOff = ToInt(formatInfo.MyStepSectionLayoutData.ColRTable, maxRNO); + if (MyItemInfo.ActiveFormat.PlantFormat.FormatData.PrintData.SpecialCaseCalvertAlarm) + { + XOffset = MyTopRNO.MyTab.XOffset + 7.2f; + Width = MyParent.Width + (MyParent.XOffset - XOffset); + } + else + { + XOffset = rnoOff + MyHighLevelParagraph.XOffset; + Width = MyParent.Width; + } + } + // B2020-117 There are muliple Cautions, Notes, or Warnings in the Calvert Alarm Contition/Response + // Need to adjust the starting positon of the bulleted tab, text and width + else if (MyItemInfo.ActiveFormat.PlantFormat.FormatData.PrintData.SpecialCaseCalvertAlarm) + { + XOffset = MyTopRNO.MyTab.XOffset + 7.2f; + this.MyTab.XOffset = XOffset; + XOffset += this.MyTab.Width; + Width = MyParent.Width + (MyParent.XOffset - XOffset); + } + else + Width = (MyParent.XOffset + MyParent.Width) - (XOffset + mycolT); + } + else + { + // B2016-269: if caution/note & not boxed, with tab adjust width based on xoffset of tab + // so text doesn't print out of right border. + // B2017-027: Added a check for column mode - we only want to do this if in single column mode + if (!MyItemInfo.MyParent.IsHigh && MyTab != null && MyTab.YOffset == YOffset && MyItemInfo.ActiveSection != null && MyItemInfo.ActiveSection.ColumnMode == 0) // C2018-003 fixed use of getting the active section + { + // B2017-xxx if this is a caution/note off of a substep in the supinfo column, need to look up for its supinfo part, not + // its HLS. + if (MyItemInfo.IsInSupInfo) + { + vlnParagraph supinfopart = this; + while (supinfopart.MyParent != null && !supinfopart.MyItemInfo.IsSupInfoPart) supinfopart = supinfopart.MyParent; + XOffset = supinfopart.XOffset; + MyTab.XOffset = XOffset - MyTab.Width - 10; + Width = supinfopart.Width; + } + else + Width = MyHighLevelParagraph.Width - MyTab.Width - (MyTab.XOffset - MyHighLevelParagraph.XOffset) - 6; + } + else + Width = (float)formatInfo.MyStepSectionLayoutData.WidT - 6 - mycolT; + } + XOffset += mycolT; // adjust caution/note text position + if (PartsLeft != null && PartsLeft.Count > 0)// adjust tab position + { + if (myTab != null && (itemInfo.IsNote || itemInfo.IsCaution)) + Width -= myTab.Width; + foreach (vlnPrintObject vpo in PartsLeft) + vpo.XOffset += mycolT; + } + } + else if (itemInfo.IsSection) + { + // B2023-074 The itemInfo we are processing is a section (number and title). Change maxRNO to zero to getting the width. + // The Width is used when printing the section number and title (when the check box on the properties page is checked) + // and is assumemed the section is a single column section (maxRNO = 0) and uses the format variable WidSTablePrint + // which holds the widths for then the section has one column, two column, or three column. + // For printing section numbers and titles like this, we always want to accomodate for lone section title text. + // So the initial width should always be set to the one column width value so that it can spane across the page. + Width = ToInt(formatInfo.MyStepSectionLayoutData.WidSTablePrint, 0); + float adjwidths = 0; + adjwidths = AdjustMetaWidth(itemInfo, formatInfo, adjwidths, false); + Width += (adjwidths + _WidthAdjust); + } + else if (MyParent == null) + { + // 72 points / inch - 7 inches (about width of page) + Width = 72 * 7; + } + else if (itemInfo.IsRNOPart && itemInfo.ActiveSection != null && itemInfo.ActiveSection.ColumnMode != 0 && itemInfo.ActiveFormat.MyStepSectionLayoutData.RNOWidthAltAll != null) // C2018-003 fixed use of getting the active section + { + // This code was added for AEP. Other code that adjusted RNO widths was only adjusting the RNO widths + // off of the HLS. AEP needed adjusting for all RNOs. + float ovrd = (float)itemInfo.ActiveFormat.MyStepSectionLayoutData.RNOWidthAltAll; + if (ovrd > 0) + Width = ovrd - tabWidth; + if (XOffset + Width > (float)itemInfo.MyDocStyle.Layout.PageWidth) + Width = (float)itemInfo.MyDocStyle.Layout.PageWidth - XOffset - 5; + } + else if (itemInfo.IsRNOPart && !((ItemInfo)itemInfo.ActiveParent).IsHigh) + { + if (itemInfo.ActiveFormat.MyStepSectionLayoutData.RNOWidthAdj != null && !((ItemInfo)itemInfo.ActiveParent).IsInRNO) + Width = MyParent.Width + float.Parse(itemInfo.ActiveFormat.MyStepSectionLayoutData.RNOWidthAdj); + else + Width = MyParent.Width; + } + else if (itemInfo.IsRtfRaw) // this needs to be before the check for 'IsTablePart' - the rtfraw may be a table part, but the size is defined by raw rtf + { + System.Drawing.Size sz = RtfRawItem.GetRtfRawSize(MyItemInfo.MyContent.Text); + Height = sz.Height; + Width = sz.Width; + Rtf = MyItemInfo.MyContent.Text; + } + else if (itemInfo.IsTablePart) + { + Width = 72 * 7; // TODO: Need to determine the Width of the Table based upon the contents + } + else if (itemInfo.MyParent.FormatStepData != null && itemInfo.MyParent.FormatStepData.Type == "TitleWithTextRight") // B2019-141: Background steps width too small + { + Width = (float)itemInfo.MyDocStyle.Layout.PageWidth - XOffset; + } + else if (itemInfo.MyParent.IsCaution || itemInfo.MyParent.IsNote) + { + if (itemInfo.ActiveFormat.MyStepSectionLayoutData.DevNoteOrCautionTabOffset != null) + Width = MyParent.MyParent.Width - tabWidth + (myTab == null ? 0 : myTab.TabAlign); + else + Width = MyParent.Width - tabWidth + (myTab == null ? 0 : myTab.TabAlign); + Width -= 72 * (itemInfo.FormatStepData.CautionOrNoteSubstepIndent == null ? 0 : (float)itemInfo.FormatStepData.CautionOrNoteSubstepIndent / (float)itemInfo.FormatStepData.Font.CPI); + } + else + { + float adjwidth = 0; + if (itemInfo.IsRNOPart && itemInfo.ActiveFormat.MyStepSectionLayoutData.RNOWidthSameAsHighParent && itemInfo.MyParent.IsHigh) + Width = adjwidth + MyParent.Width; + else if (itemInfo.MyTab != null && itemInfo.MyTab.Position != 0) + Width = adjwidth + MyParent.Width; + else if (MyParent.WidthNoLimit != 0) + Width = adjwidth + MyParent.WidthNoLimit - tabWidth + (myTab == null ? 0 : myTab.TabAlign); + else if ((itemInfo.MyDocStyle.StructureStyle.Style & E_DocStructStyle.DSS_PageListSpBckgrnd) == E_DocStructStyle.DSS_PageListSpBckgrnd) + Width = adjwidth + MyParent.Width - (MyTab != null ? MyTab.Width : 0); + else + Width = adjwidth + MyParent.Width - tabWidth + (myTab == null ? 0 : myTab.TabAlign); + } + if (itemInfo.IsSequential && itemInfo.MyParent.IsHigh && ((itemInfo.MyDocStyle.StructureStyle.Style & E_DocStructStyle.Align1StLevSubWHLS) == E_DocStructStyle.Align1StLevSubWHLS)) + Width += 10; + } + + private float AdjustMetaWidth(ItemInfo itemInfo, FormatInfo formatInfo, float adjwidth, bool coadj) + { + SectData sd = formatInfo.PlantFormat.FormatData.SectData; + if (((itemInfo.MyDocStyle.StructureStyle.Style & E_DocStructStyle.DSS_SameXOffSubsections) == E_DocStructStyle.DSS_SameXOffSubsections)) + { + // don't adjust the width if there already was an adjustment for checkoffs - for VCB only (F2016-039) - VCB no longer a customer + // C2019-040 use format flag to adjust the width (was already don for checkoffs) - previously we check if the format file name starts with VCB (VCB no longer a customer) + if (!(itemInfo.ActiveFormat.PlantFormat.FormatData.ProcData.CheckOffData.CheckoffsWithoutHeader && coadj)) + adjwidth = MyTab != null ? -MyTab.Width : 0; + } + else if (sd.UseMetaSections) + { + if (sd.StepSectionData.StepSectionLayoutData.TieTabToLevel) + { + if (ShowSectionTitles + && !itemInfo.MyDocStyle.CancelSectTitle + && !(itemInfo.MyDocStyle.SpecialStepsFoldout && itemInfo.MyDocStyle.UseColSByLevel)) + { + int indxLevel = itemInfo.PrintLevel + itemInfo.CurrentSectionLevel(); + //F2022-023 Used the SubSectAndHighSameLevel (BNPP1New format) flag to get the proper level if we have sub-sections so that we get the proper WidSAdjByLevel value + if (formatInfo.PlantFormat.FormatData.SectData.StepSectionData.StepSectionLayoutData.SubSectAndHighSameLevel && !MyItemInfo.MyActiveSection.MyParent.IsProcedure) indxLevel++; + adjwidth += formatInfo.PlantFormat.FormatData.SectData.MetaSectionList[indxLevel % formatInfo.PlantFormat.FormatData.SectData.MetaSectionList.MaxIndex].WidSAdjByLevel ?? 0; ; + float colsbylevel = (float)formatInfo.PlantFormat.FormatData.SectData.MetaSectionList[indxLevel % formatInfo.PlantFormat.FormatData.SectData.MetaSectionList.MaxIndex].ColSByLevel; + float seclvlindent = colsbylevel - (float)formatInfo.PlantFormat.FormatData.SectData.StepSectionData.StepSectionLayoutData.ColS; + adjwidth -= seclvlindent; + if (itemInfo.IsStep) adjwidth -= AdjustForSectionLevelTab(); + if (itemInfo.IsSection && itemInfo.ActiveFormat.PlantFormat.FormatData.PrintData.WCNTraining) + adjwidth -= (float)((itemInfo.MyTab.CleanText.Trim().Length * 72) / itemInfo.ActiveFormat.PlantFormat.FormatData.SectData.SectionHeader.Font.CPI); + } + } + else + { + if (formatInfo.PlantFormat.FormatData.SectData.MetaSectionList.MaxIndex > 0) + adjwidth += (float)formatInfo.PlantFormat.FormatData.SectData.MetaSectionList[itemInfo.PrintLevel % formatInfo.PlantFormat.FormatData.SectData.MetaSectionList.MaxIndex].ColSByLevel; + } + } + return adjwidth; + } + + // for Component Table, don't increment yoff unless last item in table that HAS data associated + // with it (there may be empty cells at end). + public bool UseTemplateKeepOnCurLine(ItemInfo itemInfo) + { + if (!itemInfo.IsStep || !itemInfo.MyDocStyle.ComponentList) return false; + if (!itemInfo.ActiveFormat.PlantFormat.FormatData.PrintData.SpecialCaseCalvert + && itemInfo.MyHLS.FormatStepData.UseOldTemplate) return true; + return false; + } + private bool UseTemplateWidthOrXOff(ItemInfo itemInfo) + { + if (!itemInfo.IsStep) return false; + if (itemInfo.MyHLS == null) return false; + if (itemInfo.MyHLS.FormatStepData.UseSmartTemplate || (itemInfo.MyDocStyle.ComponentList && itemInfo.MyHLS.FormatStepData.UseOldTemplate)) + { + ItemInfo useForTemplate = itemInfo.IsHigh ? itemInfo : itemInfo.MyParent; + int topIndx = useForTemplate.GetSmartTemplateTopLevelIndx(); + int tpIndx; + if (itemInfo.ActiveFormat.PlantFormat.FormatData.PrintData.SpecialCaseCalvertAlarm) + { + if (itemInfo.IsCaution1) return false; + else tpIndx = useForTemplate.GetSmartTemplateIndex(topIndx, itemInfo.MyContent.Text); + } + else + tpIndx = useForTemplate.GetSmartTemplateIndex(topIndx, (int)useForTemplate.MyContent.Type); + if (tpIndx > -1) return true; + } + return false; + } + private float GetWidthOrStartFromTemplate(ItemInfo itemInfo, FormatInfo formatInfo, bool bGetWidth) + { + int topIndx = itemInfo.GetSmartTemplateTopLevelIndx(); + int tmplIndx; + if (itemInfo.MyDocStyle.ComponentList && !itemInfo.IsHigh) + { + // The following was added so that the Calvert Alarms sequentials under the CONDITION/RESPONSE would be + // printed as 2 column (data within the template definition set the columns to 2) + if (itemInfo.ActiveFormat.PlantFormat.FormatData.PrintData.SpecialCaseCalvertAlarm) + { + if (itemInfo.IsSequential && itemInfo.MyParent.TemplateIndex > 0) + { + if (bGetWidth && itemInfo.MyParent.ColumnMode == 1) // 2 columns + return (ToInt(formatInfo.MyStepSectionLayoutData.WidSTablePrint, itemInfo.ColumnMode) - MyTab.Width); + } + tmplIndx = itemInfo.TemplateIndex; + if (tmplIndx == -1) return 0; + } + else + { + // The ComponentTable format (FNP component table as one example), uses a template + // where the items in the template below the HLS are all paragraphs (the intermediate steps + // are TitleWithTextRight). Find the ordinal of in this list to get the index. Use the ordinal + // as an offset from the HLS's index into the template. + tmplIndx = itemInfo.MyParent.Ordinal + topIndx; + if (tmplIndx < 0 || tmplIndx > formatInfo.PlantFormat.FormatData.Templates.Count - 1) return 0; + } + } + else + { + tmplIndx = itemInfo.GetSmartTemplateIndex(topIndx, (int)itemInfo.MyContent.Type); + if (tmplIndx == -1) return 0; + } + // Calvert Alarms' template defines number of columns & their width. + if (bGetWidth && formatInfo.PlantFormat.FormatData.Templates[tmplIndx].width == 0) + { + int nocol = formatInfo.PlantFormat.FormatData.Templates[tmplIndx].nocolm == 0 ? 0 : formatInfo.PlantFormat.FormatData.Templates[tmplIndx].nocolm - 1; + return ToInt(formatInfo.MyStepSectionLayoutData.WidSTablePrint, nocol); + } + int ncol = bGetWidth ? formatInfo.PlantFormat.FormatData.Templates[tmplIndx].width : formatInfo.PlantFormat.FormatData.Templates[tmplIndx].start; + // now convert to the units for this format. The template width data is in number of columns. + return (ncol * itemInfo.FormatStepData.Font.CharsToTwips) + (bGetWidth ? 1 : 0); // + 1 is slight adjustment so column doesn't wrap + } + [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0059:Unnecessary assignment of a value", Justification = "myTab Kept For Debugging")] + private float AdjustForSectionLevelTab() + { + string sectTab = MyItemInfo.ActiveSection.MyTab.CleanText.TrimEnd(); + if (sectTab.EndsWith(".0")) return 0; + string myTab = MyItemInfo.MyTab.CleanText; + // -1 below code, +1 for '.' and -2 for standard wid of tab + // standard wid of this tab is 2 (ex: '1.') + // so adjust width if longer than normal + return (float)(sectTab.Length - 1) * 72 / (float)MyItemInfo.FormatStepData.Font.CPI; + } + private bool HasCheckOffHeading(ItemInfo itemInfo, FormatInfo formatInfo) + { + if (formatInfo.PlantFormat.FormatData.ProcData.CheckOffData.CheckOffHeaderList.MaxIndex != 0) + { + // does this section have a check off heading? + SectionConfig sc = (itemInfo.ActiveSection != null) ? itemInfo.MyActiveSection.MyConfig as SectionConfig : null; // C2018-003 fixed use of getting the active section + if (sc != null && sc.Section_CheckoffHeaderSelection > 0) return true; + } + if (formatInfo.PlantFormat.FormatData.ProcData.CheckOffData.CheckOffHeaderInPagelist) return true; + return false; + } + } + + /// + /// First order by stepLevel, then within a stepLevel, order by descending yLocation on page. + /// Want to find maximum y value that fits on page, i.e. put the most on page that can + /// fit which is defined by the largest yLocation + /// + public class StepLevelList : SortedDictionary> + { + public StepLevelList() + : base() + { + } + public void Add(int stepLevel, float yLocation, vlnParagraph para) + { + if (stepLevel == 0) return; + if (!this.ContainsKey(stepLevel)) + this.Add(stepLevel, new SortedDictionary()); + // using a negative for yLocation so that its in descending order: + // B2020-112: Make various adjustments to location if there are format flags used + // B2020-116: Only make the 112 change for Calvert + // B2020-151: check for SpecialCaseCalvertPagination flag instead of SpecialCase Calvert flag so only EOPs/AOPs are affected + float adjust = 0; + if (para.MyItemInfo.ActiveFormat.PlantFormat.FormatData.PrintData.SpecialCaseCalvertPagination) + adjust = para.YVeryTop - para.YTop; + if (!this[stepLevel].ContainsKey(-(yLocation + adjust))) + this[stepLevel].Add(-(yLocation + adjust), para); + } + } + public class ParagraphLocations : List + { + public ParagraphLocations() + : base() + { + } + public void Add(vlnParagraph myParagraph, float yTopMost) + { + ParagraphLocation foundOverlap = FindOverlap(myParagraph); + if (foundOverlap == null) + { + this.Add(new ParagraphLocation(yTopMost, myParagraph)); + return; + } + ParagraphLocation doubleOverlap = FindOverlap(foundOverlap); + while (doubleOverlap != null) + { + doubleOverlap.Merge(foundOverlap); + this.Remove(foundOverlap); + foundOverlap = doubleOverlap; + doubleOverlap = FindOverlap(foundOverlap); + } + } + + private ParagraphLocation FindOverlap(vlnParagraph myParagraph) + { + foreach (ParagraphLocation paraLoc in this) + if (paraLoc.Overlap(myParagraph)) + return paraLoc; + return null; + } + private ParagraphLocation FindOverlap(ParagraphLocation myParaLoc) + { + foreach (ParagraphLocation paraLoc in this) + if (paraLoc != myParaLoc && paraLoc.Overlap(myParaLoc)) + return paraLoc; + return null; + } + internal StepLevelList BuildStepLevelList(bool KeepStepsOnPage) + { + StepLevelList myList = new StepLevelList(); + foreach (ParagraphLocation paraLoc in this) + { + int level = paraLoc.StepLevel; + if (KeepStepsOnPage) + { + // B2020-116: change from checking for type 20001 to looking for a non-high sequential since some + // step types were sequential but not 20001 + if (!paraLoc.MyParagraph.MyItemInfo.IsHigh) + { + bool AlarmPagination = paraLoc.MyParagraph.MyItemInfo.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.StepSectionLayoutData.AlarmPagination; + if (paraLoc.MyParagraph.MyItemInfo.IsSequential) + { + if (DontBreakHere(paraLoc)) + level = 0; + else + level = 1; // AlarmPagination?3:1; // B2023-091: backout B2023-088 make it easier to break on a sequential for alarms + } + else if (AlarmPagination && paraLoc.MyParagraph.MyItemInfo.IsSubStep) + { + // make it harder to break on first caution or note & within a list if doing Alarm Pagination: + vlnParagraph myPara = paraLoc.MyParagraph; + if ((myPara.MyItemInfo.IsCaution || myPara.MyItemInfo.IsNote) && myPara.MyItemInfo.MyPrevious == null) level = 1; + else if (myPara.MyItemInfo.MyPrevious != null || myPara.MyItemInfo.NextItem != null) level = 2; + } + } + } + // For B2015-014, some migrated data for background documents had the TitleWithTextBelow with associated paragraphs + // as siblings rather than children. Pagination was sometimes putting the TitleWithTextBelow on one page and the + // paragraphs on next. The following code checks thse types, if in enhanced documents but not the Short Form Deviations. + if (paraLoc.MyParagraph.MyItemInfo.ActiveFormat != null + && ((paraLoc.MyParagraph.MyItemInfo.ActiveFormat.PlantFormat.FormatData.PurchaseOptions.Value & E_PurchaseOptions.EnhancedBackgrounds) == E_PurchaseOptions.EnhancedBackgrounds) + || (((paraLoc.MyParagraph.MyItemInfo.ActiveFormat.PlantFormat.FormatData.PurchaseOptions.Value & E_PurchaseOptions.EnhancedDeviations) == E_PurchaseOptions.EnhancedDeviations) + && paraLoc.MyParagraph.MyItemInfo.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.StepSectionLayoutData.EnhancedShortFormDev)) + { + if (!paraLoc.MyParagraph.MyItemInfo.IsTitle && paraLoc.MyParagraph.MyItemInfo.MyPrevious != null && paraLoc.MyParagraph.MyItemInfo.MyPrevious.FormatStepData.Type == "TitleWithTextBelow") level = 0; + } + paraLoc.MyParagraph.levelForPagination = level; + myList.Add(level, paraLoc.YTop, paraLoc.MyParagraph); + } + return myList; + } + private bool DontBreakHere(ParagraphLocation paraLoc) + { + if (paraLoc.MyParagraph.MyItemInfo.MyPrevious == null) // First substep + return true; + vlnParagraph myPara = paraLoc.MyParagraph; + while (!myPara.MyItemInfo.IsHigh) + { + if (myPara.MyItemInfo.IsCaution) return true; + if (myPara.MyItemInfo.IsNote) return true; + myPara = myPara.MyParent; + } + return false; + } + } + public class ParagraphLocation + { + public override string ToString() => string.Format("{0} {1} - {2} - '{3}'", this.MyParagraph.MyItemInfo.ItemID, this.StepLevel, this.YTop, this.MyParagraph.MyItemInfo.ShortPath); + + public float YTop { get; set; } + public float YBottom { get; set; } + public int StepLevel { get; set; } + public vlnParagraph MyParagraph { get; set; } + public ParagraphLocation(float yTopMost, vlnParagraph myParagraph) + { + MyParagraph = myParagraph; + YTop = myParagraph.YVeryTop - yTopMost; + YBottom = myParagraph.YBottom - yTopMost; + StepLevel = myParagraph.MyItemInfo.StepLevel; + // B2020-115 Set a very large figure's Step Level so that pagination will happen prior to the figure. + if (myParagraph.MyItemInfo.IsFigure && myParagraph.MyParent.Height + myParagraph.Height > vlnParagraph.hMax) + { + StepLevel = 1;// Set figure as a guaranteed break location + } + } + public bool Overlap(vlnParagraph otherParagraph) + { + if (Between(otherParagraph.YTop, YTop, YBottom)) return true; + if (Between(otherParagraph.YBottom, YTop, YBottom)) return true; + if (Between(YTop, otherParagraph.YVeryTop, otherParagraph.YBottom)) return true; + if (Between(YBottom, otherParagraph.YVeryTop, otherParagraph.YBottom)) return true; + return false; + } + public static bool Between(float x, float lower, float higher) => x > lower && x < higher; + public bool Overlap(ParagraphLocation otherParagraphLocation) + { + if (Between(otherParagraphLocation.YTop, YTop, YBottom)) return true; // The top is within the other + if (Between(otherParagraphLocation.YBottom, YTop, YBottom)) return true; // The bottom is within the other + if (Between(YTop, otherParagraphLocation.YTop, otherParagraphLocation.YBottom)) return true; // the other top is within this one + if (Between(YBottom, otherParagraphLocation.YTop, otherParagraphLocation.YBottom)) return true;// I believe this is unnecessary + return false; + } + public void Merge(vlnParagraph otherParagraph) + { + if (StepLevel < otherParagraph.MyItemInfo.StepLevel) MyParagraph = otherParagraph; + YTop = Math.Min(YTop, otherParagraph.YVeryTop); + YBottom = Math.Max(YBottom, otherParagraph.YBottom); + StepLevel = Math.Max(StepLevel, otherParagraph.MyItemInfo.StepLevel); + } + public void Merge(ParagraphLocation otherParagraphLocation) + { + if (StepLevel < otherParagraphLocation.StepLevel) MyParagraph = otherParagraphLocation.MyParagraph; + YTop = Math.Min(YTop, otherParagraphLocation.YTop); + YBottom = Math.Max(YBottom, otherParagraphLocation.YBottom); + StepLevel = Math.Max(StepLevel, otherParagraphLocation.StepLevel); + } + } } diff --git a/PROMS/Volian.Print.Library/vlnPrintObject.cs b/PROMS/Volian.Print.Library/vlnPrintObject.cs index b09edea2..84bc658b 100644 --- a/PROMS/Volian.Print.Library/vlnPrintObject.cs +++ b/PROMS/Volian.Print.Library/vlnPrintObject.cs @@ -1,14 +1,10 @@ using System; using System.Collections.Generic; using System.Text; -using System.Drawing; using iTextSharp.text.pdf; using iTextSharp.text; using Itenso.Rtf; -using Itenso.Rtf.Parser; -using Itenso.Rtf.Interpreter; using Itenso.Rtf.Support; -using Volian.Controls.Library; using VEPROMS.CSLA.Library; using Volian.Base.Library; using System.Text.RegularExpressions; @@ -24,22 +20,14 @@ namespace Volian.Print.Library get { return _UniqueDebugId++; } set { _UniqueDebugId = value; } } - private int _DebugId = UniqueDebugId; - public int DebugId - { - get { return _DebugId; } - set { _DebugId = value; } - } - protected static float _WidthAdjust = 1; // 1 Point - adjusted to match 16-bit line wrapping. For editting it's 3. + public int DebugId { get; set; } = UniqueDebugId; + + protected static float _WidthAdjust = 1; // 1 Point - adjusted to match 16-bit line wrapping. For editting it's 3. protected static float _WidthAdjustBox = 6; - private static float _SixLinesPerInch = 12; // twips - public static float SixLinesPerInch - { - get { return vlnPrintObject._SixLinesPerInch; } - set { vlnPrintObject._SixLinesPerInch = value; } - } - protected static float _SevenLinesPerInch = 10.1F;//72F / 7F; + + public static float SixLinesPerInch { get; set; } = 12; + protected static float _SevenLinesPerInch = 10.1F;//72F / 7F; protected float _XOffset; public float XOffset @@ -64,31 +52,13 @@ namespace Volian.Print.Library set { _MyParent = value; - if (_MyParent != null) - { - - } } } - private bool _HasIndent = false; - public bool HasIndent - { - get { return _HasIndent; } - set { _HasIndent = value; } - } - private bool _IsCompressed = false; - public bool IsCompressed - { - get { return _IsCompressed; } - set { _IsCompressed = value; } - } - private string _ImageText; // ro definition, value part of #Link in case of image/figure - public string ImageText - { - get { return _ImageText; } - set { _ImageText = value; } - } - protected string _Rtf; // may become iTextSharp paragraph + + public bool HasIndent { get; set; } = false; + public bool IsCompressed { get; set; } = false; + public string ImageText { get; set; } + protected string _Rtf; // may become iTextSharp paragraph public virtual string Rtf { get { return _Rtf; } @@ -96,15 +66,9 @@ namespace Volian.Print.Library } public class VlnSplitCharacter : ISplitCharacter { - public bool IsSplitCharacter(int start, int current, int end, char[] cc, PdfChunk[] ck) - { - return (cc[current] == ' '); - } - public bool IsSplitCharacter(char c) - { - return (c == ' '); - } - } + public bool IsSplitCharacter(int start, int current, int end, char[] cc, PdfChunk[] ck) => (cc[current] == ' '); + public bool IsSplitCharacter(char c) => (c == ' '); + } public static VlnSplitCharacter mySplitter = new VlnSplitCharacter(); // B2018-034 Attributes were being lost when the IsCompressed flag was true. // The following variable was changed to a public so that it could be used @@ -114,6 +78,7 @@ namespace Volian.Print.Library { get { + //For Debugging: // If the paragraph iscompressed, it may have been created as not compressed since compression // is not set when paragraph is initially created, it is set during pagination tests. //if (_IParagraph == null || IsCompressed) @@ -186,49 +151,10 @@ namespace Volian.Print.Library } set { _Height = value; } } - public float GetParagraphHeight(PdfContentByte cb, Paragraph iParagraph, string suffix, float width) - { - return GetParagraphHeight(cb, iParagraph, suffix, width, true); - } - public float GetParagraphHeight(PdfContentByte cb, Paragraph iParagraph, string suffix, float width, bool throwException) - { - float heightAll = GetHeight(cb, iParagraph, suffix, width, throwException); - return heightAll; - } - private static void RestoreLastCharacter(Paragraph iParagraph, Chunk chk) - { - iParagraph.RemoveAt(iParagraph.Count - 1); - iParagraph.Add(chk); - } - private static Chunk RemoveLastCharacter(Paragraph iParagraph) - { - if (iParagraph.Count == 0) - return null; - object obj = iParagraph[iParagraph.Count-1]; - Chunk chk = obj as Chunk; - if (chk == null) - return null; - string s = chk.Content; - if (s.Length > 1 || iParagraph.Count > 1) // don't remove last character if it's the only one - { - iParagraph.RemoveAt(iParagraph.Count - 1); - if (s.Length > 0) - { - if (s == "\xA0") // If this is a space at the end put it back - { - iParagraph.Add(chk); - return null; - } - else - { - s = s.Substring(0, s.Length - 1); - iParagraph.Add(new Chunk(s, chk.Font)); - } - } - } - return chk; - } - public static float GetHeight(PdfContentByte cb, Paragraph iParagraph, string suffix, float width, bool throwException) + public float GetParagraphHeight(PdfContentByte cb, Paragraph iParagraph, string suffix, float width) => GetParagraphHeight(cb, iParagraph, suffix, width, true); + public float GetParagraphHeight(PdfContentByte cb, Paragraph iParagraph, string suffix, float width, bool throwException) => (float)GetHeight(cb, iParagraph, suffix, width, throwException); + + public static float GetHeight(PdfContentByte cb, Paragraph iParagraph, string suffix, float width, bool throwException) { ColumnText myColumnText = new ColumnText(cb); float pgHeight = cb.PdfDocument.PageSize.Height; // C2020-002 paper size is now set in the format files @@ -243,7 +169,6 @@ namespace Volian.Print.Library { myColumnText.AddElement(iParagraph); } - //myColumnText.UseAscender = true;// Adjusts to the top of the text box. int status = myColumnText.Go(true); // Check to see if it will fit on the page. if (ColumnText.HasMoreText(status) && throwException) { @@ -255,7 +180,6 @@ namespace Volian.Print.Library iParagraph.IndentationLeft = 0; return GetHeight(cb, iParagraph, suffix, width, throwException); } - //throw (new Exception("Paragraph longer than a page")); Console.WriteLine("Paragraph longer than a page"); } return pgHeight - myColumnText.YLine; // This gives the height of the Paragraph // C2020-002 paper size is now set in the format files @@ -266,23 +190,19 @@ namespace Volian.Print.Library float h = GetParagraphHeight(cb, iParagraph, string.Empty, iWidth); int iWidthMax = iWidth; // maximum width in Characters int iDelta = iWidth / 2; - iWidth = iWidth / 2; + iWidth /= 2; while (iDelta > 0) { float h2 = GetParagraphHeight(cb, iParagraph, string.Empty, iWidth,false); - iDelta = iDelta / 2; + iDelta /= 2; if (h2 == h) iWidthMax = iWidth; iWidth += (h2>h ? 1: -1) * iDelta; } return (float) iWidthMax; } - private PdfContentByte _MyContentByte; - public PdfContentByte MyContentByte - { - get { return _MyContentByte; } - set { _MyContentByte = value; } - } - private VlnSvgPageHelper _MyPageHelper; + + public PdfContentByte MyContentByte { get; set; } + private VlnSvgPageHelper _MyPageHelper; public VlnSvgPageHelper MyPageHelper { get @@ -296,50 +216,34 @@ namespace Volian.Print.Library public vlnPrintObject() { } - /// - /// No conversion necessary: twips -> twips - /// - /// - /// - public static int ToInt(int value) - { - return value; - } - /// - /// No conversion necessary: int? twips -> int twips - /// - /// - /// - public static int ToInt(int? value) - { - return ToInt((int)value); - } - /// - /// No conversion necessary: string twips -> int twips - /// - /// - /// - public static int ToInt(string value) - { - return ToInt((int)Convert.ToSingle(value)); - } - /// - /// No conversion necessary: value from a list in a string, twips -> int twips - /// - /// - /// - public static int ToInt(string value, int i) - { - string s = (value.Contains(",")) ? value.Split(",".ToCharArray())[i] : value; - return ToInt(s); - } - public static string GetRtf(string text, VE_Font vFont) + /// + /// No conversion necessary: twips -> twips + /// + /// + /// + public static int ToInt(int value) => value; + /// + /// No conversion necessary: int? twips -> int twips + /// + /// + /// + public static int ToInt(int? value) => ToInt((int)value); + /// + /// No conversion necessary: string twips -> int twips + /// + /// + /// + public static int ToInt(string value) => ToInt((int)Convert.ToSingle(value)); + /// + /// No conversion necessary: value from a list in a string, twips -> int twips + /// + /// + /// + public static int ToInt(string value, int i) => ToInt((value.Contains(",")) ? value.Split(",".ToCharArray())[i] : value); + public static string GetRtf(string text, VE_Font vFont) { StringBuilder rtfSB = new StringBuilder(); - //DisplayText vlntxt = new DisplayText(text.TrimStart(" ".ToCharArray()), vFont, false); DisplayText vlntxt = new DisplayText(text, vFont, false); - //rtfSB.Append(AddFontTable(vlntxt.TextFont.WindowsFont)); - //rtfSB.Append(AddFontTable(vFont.WindowsFont)); rtfSB.Append(AddFontTable(vFont)); rtfSB.Append(vlntxt.StartText); rtfSB.Append("}"); @@ -413,11 +317,8 @@ namespace Volian.Print.Library float fE = iFont.BaseFont.GetWidthPointKerned("!", 12); return fW == fE; } - public static iTextSharp.text.Paragraph RtfToParagraph(string rtf) - { - return RtfToParagraph(rtf, false, false); - } - public static iTextSharp.text.Paragraph RtfToParagraph(string rtf, bool hasIndent, bool doPdfLinks) + public static iTextSharp.text.Paragraph RtfToParagraph(string rtf) => RtfToParagraph(rtf, false, false); + public static iTextSharp.text.Paragraph RtfToParagraph(string rtf, bool hasIndent, bool doPdfLinks) { if (hasIndent) { @@ -427,11 +328,13 @@ namespace Volian.Print.Library } IRtfDocument rtfDoc = RtfInterpreterTool.BuildDoc(rtf); - Rtf2iTextSharp rtf2IText = new Rtf2iTextSharp(rtfDoc); - rtf2IText.DoPdfLinks = doPdfLinks; - rtf2IText.HasIndent = hasIndent; - iTextSharp.text.Paragraph para = rtf2IText.Convert(); - para.SetLeading(_SixLinesPerInch, 0); + Rtf2iTextSharp rtf2IText = new Rtf2iTextSharp(rtfDoc) + { + DoPdfLinks = doPdfLinks, + HasIndent = hasIndent + }; + iTextSharp.text.Paragraph para = rtf2IText.Convert(); + para.SetLeading(SixLinesPerInch, 0); if (rtf.Contains("\x05")) // note that this is for existing customer data as of August 2015. { // if there is a hanging indent, the iTextSharp paragraph properties must be set @@ -459,22 +362,17 @@ namespace Volian.Print.Library // Change the chunks to only split on spaces rather than spaces and hyphens foreach (object obj in para)//Fix the code to check for chunks before assuming chunks { - Chunk chk = obj as Chunk; - if (chk != null && (chk.Attributes==null || !chk.Attributes.ContainsKey("NoSplit"))) - { - if (chk.Attributes == null) chk.Attributes = new System.Collections.Hashtable(); - chk.SetSplitCharacter(mySplitter); - chk.Attributes.Add("NoSplit", false); - } - } + if (obj is Chunk chk && (chk.Attributes == null || !chk.Attributes.ContainsKey("NoSplit"))) + { + if (chk.Attributes == null) chk.Attributes = new System.Collections.Hashtable(); + chk.SetSplitCharacter(mySplitter); + chk.Attributes.Add("NoSplit", false); + } + } return para; } - private static string FixNumber(string num) - { - if (num == "") return ("0"); - return num; - } - public static float CalculateHangingIndent(string rtf) + private static string FixNumber(string num) => num == "" ? "0" : num; + public static float CalculateHangingIndent(string rtf) { float chkW=0; IRtfDocument rtfDoc2 = RtfInterpreterTool.BuildDoc(rtf.Replace("\x05", @"\f1 \u9999? \f0 ")); @@ -515,9 +413,8 @@ namespace Volian.Print.Library } public void DebugPdf(PdfContentByte cb, float left, float top) { - VlnSvgPageHelper _MyPageHelper = cb.PdfWriter.PageEvent as VlnSvgPageHelper; - PdfLayer debugLayer = _MyPageHelper == null ? null : _MyPageHelper.DebugLayer; - if (debugLayer == null) return; + PdfLayer debugLayer = !(cb.PdfWriter.PageEvent is VlnSvgPageHelper _MyPageHelper) ? null : _MyPageHelper.DebugLayer; + if (debugLayer == null) return; cb.SaveState(); cb.BeginLayer(debugLayer); ColumnText ct = new ColumnText(cb); @@ -531,9 +428,8 @@ namespace Volian.Print.Library cb.EndLayer(); cb.RestoreState(); } - public virtual float YBottom - { get { return YOffset + Height;} } - } + public virtual float YBottom => YOffset + Height; + } public partial class vlnPrintObjects : List { public float ToPdf(PdfContentByte cb, float yPageStart, ref float yTopMargin, ref float yBottomMargin) diff --git a/PROMS/Volian.Print.Library/vlnRNOSeparator.cs b/PROMS/Volian.Print.Library/vlnRNOSeparator.cs index db4ff3c9..ad2f3976 100644 --- a/PROMS/Volian.Print.Library/vlnRNOSeparator.cs +++ b/PROMS/Volian.Print.Library/vlnRNOSeparator.cs @@ -1,40 +1,20 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Drawing; using iTextSharp.text.pdf; -using iTextSharp.text; using VEPROMS.CSLA.Library; namespace Volian.Print.Library { public partial class vlnRNOSeparator : vlnPrintObject { - private VE_Font _MyFont; - public VE_Font MyFont - { - get { return _MyFont; } - set { _MyFont = value; } - } - private bool _ExtendChangeBar; - public bool ExtendChangeBar - { - get { return _ExtendChangeBar; } - set { _ExtendChangeBar = value; } - } - private float _XLength = 0; - public float XLength - { - get { return _XLength; } - set { _XLength = value; } - } + public VE_Font MyFont { get; set; } + public bool ExtendChangeBar { get; set; } + public float XLength { get; set; } = 0; - /* if flag set and separator defined then output separator */ - /*if separator is a control-A use RNOSepLine*/ - public vlnRNOSeparator(vlnParagraph parent, PdfContentByte cb, string sepStr, float xoffset, float yoffset, FormatInfo formatInfo, bool extendChangeBar) + /* if flag set and separator defined then output separator */ + /*if separator is a control-A use RNOSepLine*/ + public vlnRNOSeparator(vlnParagraph parent, PdfContentByte cb, string sepStr, float xoffset, float yoffset, FormatInfo formatInfo, bool extendChangeBar) { MyContentByte = cb; // B2019-091: crash when printing (note moved from the 'ToPdf' method) - ExtendChangeBar = formatInfo.PlantFormat.FormatData.ProcData.ChangeBarData.ChangeBarToRNOSep ? extendChangeBar : false; + ExtendChangeBar = formatInfo.PlantFormat.FormatData.ProcData.ChangeBarData.ChangeBarToRNOSep && extendChangeBar; YOffset = yoffset; XOffset = xoffset; XLength = formatInfo.PlantFormat.FormatData.SectData.StepSectionData.StepSectionPrintData.RNOSepLineLength??0; @@ -60,9 +40,8 @@ namespace Volian.Print.Library if (XLength != 0) { cb.SaveState(); - VlnSvgPageHelper _MyPageHelper = cb.PdfWriter.PageEvent as VlnSvgPageHelper; - PdfLayer textLayer = _MyPageHelper == null ? null : _MyPageHelper.TextLayer; - if (textLayer != null) cb.BeginLayer(textLayer); + PdfLayer textLayer = !(cb.PdfWriter.PageEvent is VlnSvgPageHelper _MyPageHelper) ? null : _MyPageHelper.TextLayer; + if (textLayer != null) cb.BeginLayer(textLayer); iTextSharp.text.Color lineColor = new iTextSharp.text.Color(PrintOverride.OverrideChangeBarColor(System.Drawing.Color.Black)); cb.SetColorStroke(lineColor); cb.SetLineWidth(.5F); diff --git a/PROMS/Volian.Print.Library/vlnTab.cs b/PROMS/Volian.Print.Library/vlnTab.cs index 40fce490..46596404 100644 --- a/PROMS/Volian.Print.Library/vlnTab.cs +++ b/PROMS/Volian.Print.Library/vlnTab.cs @@ -1,9 +1,5 @@ -using System; -using System.Collections.Generic; -using System.Text; using System.Drawing; using iTextSharp.text.pdf; -using iTextSharp.text; using VEPROMS.CSLA.Library; namespace Volian.Print.Library @@ -59,35 +55,21 @@ namespace Volian.Print.Library return (float)_TabOffset * MyFont.CharsToTwips; } } - private vlnMacro _MyMacro; - public vlnMacro MyMacro - { - get { return _MyMacro; } - set { _MyMacro = value; } - } - private string symblsStr = "\u25CF\u0394"; // string of possible symbol character in a tab - // add symbol characters as needed - // "\u25CF" - solid bullet - // \u0394 - delta + public vlnMacro MyMacro { get; set; } - private System.Drawing.FontStyle GetSysFontStyle(VE_Font f) - { - if (f.Style == E_Style.Italics) - return System.Drawing.FontStyle.Italic; - return FontStyle.Regular; - } - public float GetTextWidth(VE_Font vefont, string txt) - { - return GetTextWidth(vefont, txt, SymbolFontName); - } - private float GetTextWidth(VE_Font vefont, string txt, string symblFontName) + private readonly string symblsStr = "\u25CF\u0394"; // string of possible symbol character in a tab + // add symbol characters as needed + // "\u25CF" - solid bullet + // \u0394 - delta + + private System.Drawing.FontStyle GetSysFontStyle(VE_Font f) => f.Style == E_Style.Italics ? System.Drawing.FontStyle.Italic : FontStyle.Regular; + public float GetTextWidth(VE_Font vefont, string txt) => GetTextWidth(vefont, txt, SymbolFontName); + private float GetTextWidth(VE_Font vefont, string txt, string symblFontName) { // follow through in fixing an Out of Window Handles bug, use new function to see if // we can retrieve the font from a dictionary instead a doing a New and using another // window handle B2017-117 - //System.Drawing.Font font = new System.Drawing.Font(vefont.Family, (float)vefont.Size, GetSysFontStyle(vefont)); - //System.Drawing.Font symbFont = new System.Drawing.Font(symblFontName, (float)vefont.Size); System.Drawing.Font font = VE_Font.GetWinSysFont(vefont.Family, (float)vefont.Size, GetSysFontStyle(vefont)); System.Drawing.Font symbFont = VE_Font.GetWinSysFont(symblFontName, (float)vefont.Size); iTextSharp.text.Font iFont = Volian.Svg.Library.VolianPdf.GetFont(font); @@ -101,30 +83,14 @@ namespace Volian.Print.Library else w += iFont.BaseFont.GetWidthPointKerned(c.ToString(), (float)vefont.Size); } - //float w = iFont.BaseFont.GetWidthPointKerned(Text.Replace("\u25CF","@"), (float)vefont.Size); return w; } - bool _ScriptCaution = false; - public bool ScriptCaution - { - get { return _ScriptCaution; } - set { _ScriptCaution = value; } - } - bool _SeparateBullet = false; + public bool ScriptCaution { get; set; } = false; - public bool SeparateBullet - { - get { return _SeparateBullet; } - set { _SeparateBullet = value; } - } - private string _SymbolFontName; - public string SymbolFontName - { - get { return _SymbolFontName; } - set { _SymbolFontName = value; } - } - public vlnTab(PdfContentByte cb, vlnParagraph myparent, string origTab, string cleanTab, float xoffset, float yoffset, VE_Font vFont, bool doSectTab, string symblFontName, bool removedUnderline) + public bool SeparateBullet { get; set; } = false; + public string SymbolFontName { get; set; } + public vlnTab(PdfContentByte cb, vlnParagraph myparent, string origTab, string cleanTab, float xoffset, float yoffset, VE_Font vFont, bool doSectTab, string symblFontName, bool removedUnderline) { SymbolFontName = symblFontName; bool alignAsIfBulleted = false; @@ -149,20 +115,14 @@ namespace Volian.Print.Library 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) { float tPtPerChar = myparent.MyItemInfo.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.StepSectionLayoutData.TabPtsPerChar ?? 6; Width = (tPtPerChar == 0 ? 6 : tPtPerChar) * origTab.Length; - // Check the following, it may be needed for FPL: - //origTab1 = origTab1.TrimStart(" ".ToCharArray()); - // 6 = number of points per character. 4 characters between end of tab and beginning of text - // origTab1.Trim... is number of non-space characters of the tab string. - //Width = 6 * (4 + origTab1.Trim(" ".ToCharArray()).Length); } else - Width = GetTextWidth(MyFont, (Text != null ? Text : origTab), symblFontName); //MyFont.CharsToTwips * (Text != null ? Text.Length : origTab.Length); + Width = GetTextWidth(MyFont, (Text ?? origTab), symblFontName); // Pairie Island (NSP) Caution and Note tabs use a larger font // When using a bullet, we need to use the font size of the Caution/Note text instead of the tab. @@ -195,7 +155,7 @@ namespace Volian.Print.Library Width = (float)myparent.MyItemInfo.FormatStepData.TabData.IdentWidth; else { - origTab = origTab + " "; + origTab += " "; origTab = origTab.TrimStart(" ".ToCharArray()); if (mindx > 2) // ouch! Width = 6f * (origTab.Length - 1); // FPL (macro is after {numeric}) FPL is good with genmac output! @@ -204,7 +164,7 @@ namespace Volian.Print.Library } } else - Width = GetTextWidth(MyFont, (cleanTab != null ? cleanTab : origTab), symblFontName);//MyFont.CharsToTwips * (cleanTab != null ? cleanTab.Length : origTab.Length); + Width = GetTextWidth(MyFont, (cleanTab ?? origTab), symblFontName);//MyFont.CharsToTwips * (cleanTab != null ? cleanTab.Length : origTab.Length); } else { @@ -219,8 +179,6 @@ namespace Volian.Print.Library int sep = origTab.IndexOfAny(". ".ToCharArray()); string prefix = ((vFont.Style & E_Style.Bold) > 0) ? @"\b\ul " : @"\ul "; string suffix = ((vFont.Style & E_Style.Bold) > 0) ? @"\b0\ulnone " : @"\ulnone "; - //origTab = @"\ul " + origTab.Substring(0, sep-1) + @"\ulnone" + origTab.Substring(sep-1); - //origTab = @"\ul " + origTab.Substring(0, sep) + @"\ulnone" + origTab.Substring(sep); origTab = prefix + origTab.Substring(0, sep) + suffix + origTab.Substring(sep); } @@ -238,7 +196,6 @@ namespace Volian.Print.Library // follow through in fixing an Out of Window Handles bug, use new function to see if // we can retrieve the font from a dictionary instead a doing a New and using another // window handle B2017-117 - //vFont.WindowsFont = new System.Drawing.Font(vFont.Family, (float)vFont.Size, style); vFont.WindowsFont = VE_Font.GetWinSysFont(vFont.Family, (float)vFont.Size, style); int indxC = origTab.IndexOf(":"); origTab = @"\ul " + origTab.Substring(0, indxC) + @"\ulnone" + origTab.Substring(indxC); @@ -255,7 +212,6 @@ namespace Volian.Print.Library // follow through in fixing an Out of Window Handles bug, use new function to see if // we can retrieve the font from a dictionary instead a doing a New and using another // window handle B2017-117 - //vFont.WindowsFont = new System.Drawing.Font(vFont.Family, (float)vFont.Size, style); vFont.WindowsFont = VE_Font.GetWinSysFont(vFont.Family, (float)vFont.Size, style); int indxC = origTab.IndexOf(ut.Text); string prefix = ((vFont.Style & E_Style.Bold) > 0) ? @"\b\ul " : @"\ul "; @@ -294,7 +250,6 @@ namespace Volian.Print.Library (myparent.MyItemInfo.MyPrevious.MyContent.Type == myparent.MyItemInfo.MyContent.Type))) { //if (scriptCaution) - // Rtf = Rtf.Replace("CAUTION ", @"\u61472?\u61472?\u61472?\u61472?\u61472?\u61472?\u61472?\u61472?\u61472?"); Rtf = Rtf.Replace("Caution:", " "); Rtf = Rtf.Replace("Note:", " "); Rtf = Rtf.Replace("CAUTION:", " "); @@ -305,19 +260,6 @@ namespace Volian.Print.Library Rtf = Rtf.Replace("NOTE", " "); } } - //if (ScriptCaution && Rtf.Contains("Caution")) - //{ - // // NSP script caution - // iTextSharp.text.Font myfont = pdf.GetFont(vFont.Family, 28, 0, iTextSharp.text.Color.BLACK); - // if (!myfont.BaseFont.CharExists(0x43)) // Capital 'C' exists as text - // { - // //VE_Font vf = new VE_Font("VolianScript", 28, E_Style.Italics, 12); - // // Capital 'C' exists as Symbol - // Rtf = Rtf.Replace("Caution ", @"\u61507?\u61537?\u61557?\u61556?\u61545?\u61551?\u61550?\u61472?\u61472?"); - // } - - //} - // do positioning based on whether format has locations for section 'header'. If it's not centered, treat // it's location more like a 'tab'. @@ -343,7 +285,6 @@ namespace Volian.Print.Library // follow through in fixing an Out of Window Handles bug, use new function to see if // we can retrieve the font from a dictionary instead a doing a New and using another // window handle B2017-117 - //System.Drawing.Font font = new System.Drawing.Font(MyFont.Family, (float)MyFont.Size); System.Drawing.Font font = VE_Font.GetWinSysFont(MyFont.Family, (float)MyFont.Size); iTextSharp.text.Font iFont = Volian.Svg.Library.VolianPdf.GetFont(font); float w = iFont.BaseFont.GetWidthPointKerned(txt, (float)MyFont.Size); diff --git a/PROMS/Volian.Print.Library/vlnText.cs b/PROMS/Volian.Print.Library/vlnText.cs index 5693d0e1..2e314635 100644 --- a/PROMS/Volian.Print.Library/vlnText.cs +++ b/PROMS/Volian.Print.Library/vlnText.cs @@ -1,32 +1,13 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Drawing; using iTextSharp.text.pdf; -using iTextSharp.text; using VEPROMS.CSLA.Library; namespace Volian.Print.Library { public partial class vlnText : vlnPrintObject { - //public float Width - //{ - // get { return _CharsToTwips * Text.Length; } - //} - private string _Text; - public string Text - { - get { return _Text; } - set { _Text = value; } - } - private VE_Font _MyFont; - public VE_Font MyFont - { - get { return _MyFont; } - set { _MyFont = value; } - } - public vlnText(PdfContentByte cb, vlnParagraph myparent, string origText, string cleanText, float xoffset, float yoffset, VE_Font vFont) + public string Text { get; set; } + public VE_Font MyFont { get; set; } + public vlnText(PdfContentByte cb, vlnParagraph myparent, string origText, string cleanText, float xoffset, float yoffset, VE_Font vFont) { MyContentByte = cb; MyParent = myparent; diff --git a/PROMS/Volian.Svg.Library/FontFind.cs b/PROMS/Volian.Svg.Library/FontFind.cs deleted file mode 100644 index 1ddad575..00000000 --- a/PROMS/Volian.Svg.Library/FontFind.cs +++ /dev/null @@ -1,30 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Text.RegularExpressions; -using Microsoft.Win32; - -namespace Volian.Svg.Library -{ - //public static class FontFind - //{ - // public static string FileName(string fontName) - // { - // string baseFont = string.Empty; - // Regex find = new Regex(fontName + @".* ?\(.*\)", RegexOptions.IgnoreCase); - // RegistryKey regKey = Registry.LocalMachine.CreateSubKey(@"Software\Microsoft\Windows NT\CurrentVersion\Fonts"); - // string[] values = regKey.GetValueNames(); - // baseFont = regKey.GetValue(values[0]).ToString(); - // foreach (string valueName in regKey.GetValueNames()) - // { - // if (find.IsMatch(valueName)) - // return regKey.GetValue(valueName).ToString(); - // } - // return baseFont; - // } - // public static string FullFileName(string fontName) - // { - // return @"c:\windows\fonts\" + FileName(fontName); - // } - //} -} diff --git a/PROMS/Volian.Svg.Library/Graphics.cs b/PROMS/Volian.Svg.Library/Graphics.cs index 0b04d26b..02f07f00 100644 --- a/PROMS/Volian.Svg.Library/Graphics.cs +++ b/PROMS/Volian.Svg.Library/Graphics.cs @@ -17,13 +17,6 @@ namespace Volian.Svg.Library } public partial class Svg : SvgGroup { - public void Draw(Graphics graphics) - { - //SetupInheritance(); - //Console.WriteLine("{0}, DPI {1}", graphics.VisibleClipBounds, graphics.DpiX); - SvgParts.Draw(graphics, new SvgScale(DeviceDPI(graphics), graphics.VisibleClipBounds, _Width, _Height, _ViewBox), this, this); - //SvgParts.Draw(graphics, new SvgScale(100, graphics.VisibleClipBounds, _Width, _Height, _ViewBox)); - } public static float DeviceDPI(Graphics g) { PointF[] tmp = { new PointF(g.DpiX, g.DpiY) }; @@ -36,7 +29,6 @@ namespace Volian.Svg.Library public override void Draw(System.Drawing.Graphics graphics, SvgScale scale, Svg mySvg, SvgPartInheritance myParent) { SetupInheritance(myParent.MyInheritedSettings); - //_MyLineSettings.Scale = scale.M(1F); if (FillColor != Color.Transparent) using (Brush brush = new SolidBrush(FillColor)) graphics.FillEllipse(brush, scale.X(CX - Radius), scale.Y(CY - Radius), scale.M(Radius * 2), scale.M(Radius * 2)); @@ -50,7 +42,6 @@ namespace Volian.Svg.Library public override void Draw(System.Drawing.Graphics graphics, SvgScale scale, Svg mySvg, SvgPartInheritance myParent) { SetupInheritance(myParent.MyInheritedSettings); - //_MyLineSettings.Scale = scale.M(1F); if (FillColor != Color.Transparent) using (Brush brush = new SolidBrush(FillColor)) graphics.FillEllipse(brush, scale.X(CX - Radius), scale.Y(CY - Radius), scale.M(Radius * 2), scale.M(Radius * 2)); @@ -64,7 +55,6 @@ namespace Volian.Svg.Library public override void Draw(Graphics graphics, SvgScale myScale, Svg mySvg, SvgPartInheritance myParent) { // Don't draw - //_SvgParts.Draw(graphics, myScale); } } public partial class SvgEllipse : SvgShapePart @@ -85,7 +75,7 @@ namespace Volian.Svg.Library public override void Draw(Graphics graphics, SvgScale myScale, Svg mySvg, SvgPartInheritance myParent) { SetupInheritance(myParent.MyInheritedSettings); - _SvgParts.Draw(graphics, myScale, mySvg, this); + SvgParts.Draw(graphics, myScale, mySvg, this); } } public partial class SvgImage : SvgPart @@ -130,26 +120,9 @@ namespace Volian.Svg.Library graphics.DrawRectangle(pen, scale.X(X),scale.Y(Y), scale.M(Width), scale.M(Height)); } } - //public partial class SvgRtf : SvgShapePart - //{ - // //private static float _Factor = 1.085F; // 20 point Arial Font - // public override void Draw(System.Drawing.Graphics graphics, SvgScale scale, Svg mySvg, SvgPartInheritance myParent) - // { - // SetupInheritance(myParent.MyInheritedSettings); - // _MyFontSettings.Scale = scale.M(1F); - // } - // private float YAdjustment(Graphics gr, Font fnt) - // { - // int yAsc = fnt.FontFamily.GetCellAscent(fnt.Style); - // int yLS = fnt.FontFamily.GetLineSpacing(fnt.Style); - // float gth = fnt.GetHeight(gr); - // float fAsc = (yAsc * gth) / yLS; - // return -fAsc; - // } - //} + public partial class SvgText : SvgShapePart { - //private static float _Factor = 1.085F; // 20 point Arial Font public override void Draw(System.Drawing.Graphics graphics, SvgScale scale, Svg mySvg, SvgPartInheritance myParent) { SetupInheritance(myParent.MyInheritedSettings); @@ -175,8 +148,6 @@ namespace Volian.Svg.Library private float YAdjustment(Graphics gr, Font fnt) { int yAsc = fnt.FontFamily.GetCellAscent(fnt.Style); - //int yDesc = fnt.FontFamily.GetCellDescent(fnt.Style); - //int yEm = fnt.FontFamily.GetEmHeight(fnt.Style); int yLS = fnt.FontFamily.GetLineSpacing(fnt.Style); float gth = fnt.GetHeight(gr); float fh = fnt.Size; @@ -189,7 +160,7 @@ namespace Volian.Svg.Library public override void Draw(System.Drawing.Graphics graphics, SvgScale scale, Svg mySvg, SvgPartInheritance myParent) { SetupInheritance(myParent.MyInheritedSettings); - mySvg[_UseID.Substring(1)].Draw(graphics, scale.AdjustOrigin(X, Y), mySvg, this); + mySvg[UseID.Substring(1)].Draw(graphics, scale.AdjustOrigin(X, Y), mySvg, this); } } } diff --git a/PROMS/Volian.Svg.Library/Svg.cs b/PROMS/Volian.Svg.Library/Svg.cs index 982a7029..03d52264 100644 --- a/PROMS/Volian.Svg.Library/Svg.cs +++ b/PROMS/Volian.Svg.Library/Svg.cs @@ -1,6 +1,4 @@ -using System; using System.Collections.Generic; -using System.Text; using System.Xml.Serialization; using System.ComponentModel; @@ -37,84 +35,46 @@ namespace Volian.Svg.Library } set { _Namespaces = value; } } - #endregion - #region Width - private SvgMeasurement _Width = new SvgMeasurement(); - [XmlIgnore] - public SvgMeasurement Width - { - get { return _Width; } - set { _Width = value; } - } - [System.ComponentModel.DefaultValueAttribute("0")] + #endregion + #region Width + [XmlIgnore] + public SvgMeasurement Width { get; set; } = new SvgMeasurement(); + [System.ComponentModel.DefaultValueAttribute("0")] [XmlAttribute("width")] [Browsable(false)] [EditorBrowsable(EditorBrowsableState.Never)] public string Width_XmlSurrogate { - get { return SvgXmlConverter.GetString(_Width); } - set { _Width = SvgXmlConverter.GetObject(value); } + get { return SvgXmlConverter.GetString(Width); } + set { Width = SvgXmlConverter.GetObject(value); } } - //private string _Watermark=""; - //[XmlAttribute("watermark")] - //public string Watermark - //{ - // get { return _Watermark; } - // set { _Watermark = value; } - //} - //public void SetValidWaterMark(string token, string watermark) - //{ - // if (token == "{" + watermark.ToUpper() + "PAGE}" ) - // _Watermark = watermark; - //} - #endregion - #region Height - private SvgMeasurement _Height = new SvgMeasurement(); - [XmlIgnore] - public SvgMeasurement Height - { - get { return _Height; } - set { _Height = value; } - } - [System.ComponentModel.DefaultValueAttribute("0")] + #endregion + #region Height + [XmlIgnore] + public SvgMeasurement Height { get; set; } = new SvgMeasurement(); + [System.ComponentModel.DefaultValueAttribute("0")] [XmlAttribute("height")] [Browsable(false)] [EditorBrowsable(EditorBrowsableState.Never)] public string Height_XmlSurrogate { - get { return SvgXmlConverter.GetString(_Height); } - set { _Height = SvgXmlConverter.GetObject(value); } + get { return SvgXmlConverter.GetString(Height); } + set { Height = SvgXmlConverter.GetObject(value); } } - #endregion - #region ViewBox - private SvgViewBox _ViewBox = new SvgViewBox("0 0 0 0"); - [XmlIgnore] - public SvgViewBox ViewBox - { - get { return _ViewBox; } - set { _ViewBox = value; } - } - [System.ComponentModel.DefaultValueAttribute("0 0 0 0")] + #endregion + #region ViewBox + [XmlIgnore] + public SvgViewBox ViewBox { get; set; } = new SvgViewBox("0 0 0 0"); + [System.ComponentModel.DefaultValueAttribute("0 0 0 0")] [XmlAttribute("viewBox")] [Browsable(false)] [EditorBrowsable(EditorBrowsableState.Never)] public string SVGViewBox_XmlSurrogate { - get { return SvgXmlConverter.GetString(_ViewBox); } - set { _ViewBox = SvgXmlConverter.GetObject(value); } + get { return SvgXmlConverter.GetString(ViewBox); } + set { ViewBox = SvgXmlConverter.GetObject(value); } } #endregion - //#region Setup Inheritance - //private void SetupInheritance() - //{ - // SvgParts.SetupInheritance(_MyInheritedSettings); - //} - ////override internal void SetupInheritance(SvgInheritedSettings myParentsSettings) - ////{ - //// _MyInheritedSettings.MyParentsSettings = myParentsSettings; - //// SvgParts.SetupInheritance(_MyInheritedSettings); - ////} - //#endregion #region Part Lookup private Dictionary _LookUp; [XmlIgnore] diff --git a/PROMS/Volian.Svg.Library/SvgArc.cs b/PROMS/Volian.Svg.Library/SvgArc.cs index 407d26d1..9e3c7fd1 100644 --- a/PROMS/Volian.Svg.Library/SvgArc.cs +++ b/PROMS/Volian.Svg.Library/SvgArc.cs @@ -1,6 +1,3 @@ -using System; -using System.Collections.Generic; -using System.Text; using System.Xml.Serialization; using System.ComponentModel; using System.Drawing; @@ -13,65 +10,48 @@ namespace Volian.Svg.Library public SvgArc() { ;} public SvgArc(PointF location, float radius, float startAngle, float endAngle, Color fillColor, Color lineColor, float lineWidth) { - _CX.Value = location.X; - _CY.Value = location.Y; - _Radius.Value = radius; + CX.Value = location.X; + CY.Value = location.Y; + Radius.Value = radius; FillColor = fillColor; LineColor = lineColor; LineWidth = new SvgMeasurement(lineWidth); } - //XMLElementAttribute(ElementName = "PREFIX", IsNullable = false) - #endregion - #region Location - private SvgMeasurement _CX = new SvgMeasurement(); - [XmlIgnore] - public SvgMeasurement CX - { - get { return _CX; } - set { _CX = value; } - } - [XmlAttribute("cx")] + #endregion + #region Location + [XmlIgnore] + public SvgMeasurement CX { get; set; } = new SvgMeasurement(); + [XmlAttribute("cx")] [Browsable(false)] [EditorBrowsable(EditorBrowsableState.Never)] public string CX_XmlSurrogate { - get { return SvgXmlConverter.GetString(_CX); } - set { _CX = SvgXmlConverter.GetObject(value); } + get { return SvgXmlConverter.GetString(CX); } + set { CX = SvgXmlConverter.GetObject(value); } } - private SvgMeasurement _CY = new SvgMeasurement(); - [XmlIgnore] - public SvgMeasurement CY - { - get { return _CY; } - set { _CY = value; } - } - [XmlAttribute("cy")] + + [XmlIgnore] + public SvgMeasurement CY { get; set; } = new SvgMeasurement(); + [XmlAttribute("cy")] [Browsable(false)] [EditorBrowsable(EditorBrowsableState.Never)] public string CY_XmlSurrogate { - get { return SvgXmlConverter.GetString(_CY); } - set { _CY = SvgXmlConverter.GetObject(value); } + get { return SvgXmlConverter.GetString(CY); } + set { CY = SvgXmlConverter.GetObject(value); } } - #endregion - #region Radius - private SvgMeasurement _Radius = new SvgMeasurement(); - [XmlIgnore] - public SvgMeasurement Radius - { - get { return _Radius; } - set { _Radius = value; } - } - [XmlAttribute("r")] + #endregion + #region Radius + [XmlIgnore] + public SvgMeasurement Radius { get; set; } = new SvgMeasurement(); + [XmlAttribute("r")] [Browsable(false)] [EditorBrowsable(EditorBrowsableState.Never)] public string X_XmlSurrogate { - get { return SvgXmlConverter.GetString(_Radius); } - set { _Radius = SvgXmlConverter.GetObject(value); } + get { return SvgXmlConverter.GetString(Radius); } + set { Radius = SvgXmlConverter.GetObject(value); } } #endregion - #region Angles - #endregion } } diff --git a/PROMS/Volian.Svg.Library/SvgCircle.cs b/PROMS/Volian.Svg.Library/SvgCircle.cs index 5c1b8500..9ff8f2fd 100644 --- a/PROMS/Volian.Svg.Library/SvgCircle.cs +++ b/PROMS/Volian.Svg.Library/SvgCircle.cs @@ -1,6 +1,3 @@ -using System; -using System.Collections.Generic; -using System.Text; using System.Xml.Serialization; using System.ComponentModel; using System.Drawing; @@ -13,62 +10,47 @@ namespace Volian.Svg.Library public SvgCircle() { ;} public SvgCircle(PointF location, float radius, Color fillColor, Color lineColor, float lineWidth) { - _CX.Value = location.X; - _CY.Value = location.Y; - _Radius.Value = radius; + CX.Value = location.X; + CY.Value = location.Y; + Radius.Value = radius; FillColor = fillColor; LineColor = lineColor; LineWidth = new SvgMeasurement(lineWidth); } - //XMLElementAttribute(ElementName = "PREFIX", IsNullable = false) - #endregion - #region Location - private SvgMeasurement _CX = new SvgMeasurement(); - [XmlIgnore] - public SvgMeasurement CX - { - get { return _CX; } - set { _CX = value; } - } - [XmlAttribute("cx")] + #endregion + #region Location + [XmlIgnore] + public SvgMeasurement CX { get; set; } = new SvgMeasurement(); + [XmlAttribute("cx")] [Browsable(false)] [EditorBrowsable(EditorBrowsableState.Never)] public string CX_XmlSurrogate { - get { return SvgXmlConverter.GetString(_CX); } - set { _CX = SvgXmlConverter.GetObject(value); } + get { return SvgXmlConverter.GetString(CX); } + set { CX = SvgXmlConverter.GetObject(value); } } - private SvgMeasurement _CY = new SvgMeasurement(); - [XmlIgnore] - public SvgMeasurement CY - { - get { return _CY; } - set { _CY = value; } - } - [XmlAttribute("cy")] + + [XmlIgnore] + public SvgMeasurement CY { get; set; } = new SvgMeasurement(); + [XmlAttribute("cy")] [Browsable(false)] [EditorBrowsable(EditorBrowsableState.Never)] public string CY_XmlSurrogate { - get { return SvgXmlConverter.GetString(_CY); } - set { _CY = SvgXmlConverter.GetObject(value); } + get { return SvgXmlConverter.GetString(CY); } + set { CY = SvgXmlConverter.GetObject(value); } } - #endregion - #region Radius - private SvgMeasurement _Radius = new SvgMeasurement(); - [XmlIgnore] - public SvgMeasurement Radius - { - get { return _Radius; } - set { _Radius = value; } - } - [XmlAttribute("r")] + #endregion + #region Radius + [XmlIgnore] + public SvgMeasurement Radius { get; set; } = new SvgMeasurement(); + [XmlAttribute("r")] [Browsable(false)] [EditorBrowsable(EditorBrowsableState.Never)] public string X_XmlSurrogate { - get { return SvgXmlConverter.GetString(_Radius); } - set { _Radius = SvgXmlConverter.GetObject(value); } + get { return SvgXmlConverter.GetString(Radius); } + set { Radius = SvgXmlConverter.GetObject(value); } } #endregion } diff --git a/PROMS/Volian.Svg.Library/SvgDefine.cs b/PROMS/Volian.Svg.Library/SvgDefine.cs index 30a64e56..8e2ff09b 100644 --- a/PROMS/Volian.Svg.Library/SvgDefine.cs +++ b/PROMS/Volian.Svg.Library/SvgDefine.cs @@ -1,10 +1,3 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Xml.Serialization; -using System.ComponentModel; -using System.Drawing; - namespace Volian.Svg.Library { public partial class SvgDefine : SvgGroup diff --git a/PROMS/Volian.Svg.Library/SvgEllipse.cs b/PROMS/Volian.Svg.Library/SvgEllipse.cs index bd72768d..7cf0c823 100644 --- a/PROMS/Volian.Svg.Library/SvgEllipse.cs +++ b/PROMS/Volian.Svg.Library/SvgEllipse.cs @@ -1,6 +1,3 @@ -using System; -using System.Collections.Generic; -using System.Text; using System.Xml.Serialization; using System.ComponentModel; using System.Drawing; @@ -13,78 +10,59 @@ namespace Volian.Svg.Library public SvgEllipse() { ;} public SvgEllipse(PointF location, float radiusX, float radiusY, Color fillColor, Color lineColor, float lineWidth) { - _CX.Value = location.X; - _CY.Value = location.Y; - _RX.Value = radiusX; - _RY.Value = radiusY; + CX.Value = location.X; + CY.Value = location.Y; + RX.Value = radiusX; + RY.Value = radiusY; FillColor = fillColor; LineColor = lineColor; LineWidth = new SvgMeasurement(lineWidth); } - //XMLElementAttribute(ElementName = "PREFIX", IsNullable = false) - #endregion - #region Location - private SvgMeasurement _CX = new SvgMeasurement(); - [XmlIgnore] - public SvgMeasurement CX - { - get { return _CX; } - set { _CX = value; } - } - [XmlAttribute("cx")] + #endregion + #region Location + [XmlIgnore] + public SvgMeasurement CX { get; set; } = new SvgMeasurement(); + [XmlAttribute("cx")] [Browsable(false)] [EditorBrowsable(EditorBrowsableState.Never)] public string CX_XmlSurrogate { - get { return SvgXmlConverter.GetString(_CX); } - set { _CX = SvgXmlConverter.GetObject(value); } + get { return SvgXmlConverter.GetString(CX); } + set { CX = SvgXmlConverter.GetObject(value); } } - private SvgMeasurement _CY = new SvgMeasurement(); - [XmlIgnore] - public SvgMeasurement CY - { - get { return _CY; } - set { _CY = value; } - } - [XmlAttribute("cy")] + + [XmlIgnore] + public SvgMeasurement CY { get; set; } = new SvgMeasurement(); + [XmlAttribute("cy")] [Browsable(false)] [EditorBrowsable(EditorBrowsableState.Never)] public string CY_XmlSurrogate { - get { return SvgXmlConverter.GetString(_CY); } - set { _CY = SvgXmlConverter.GetObject(value); } + get { return SvgXmlConverter.GetString(CY); } + set { CY = SvgXmlConverter.GetObject(value); } } - #endregion - #region Size - private SvgMeasurement _RX = new SvgMeasurement(); - [XmlIgnore] - public SvgMeasurement RX - { - get { return _RX; } - set { _RX = value; } - } - [XmlAttribute("rx")] + #endregion + #region Size + [XmlIgnore] + public SvgMeasurement RX { get; set; } = new SvgMeasurement(); + [XmlAttribute("rx")] [Browsable(false)] [EditorBrowsable(EditorBrowsableState.Never)] public string RX_RXmlSurrogate { - get { return SvgXmlConverter.GetString(_RX); } - set { _RX = SvgXmlConverter.GetObject(value); } + get { return SvgXmlConverter.GetString(RX); } + set { RX = SvgXmlConverter.GetObject(value); } } - private SvgMeasurement _RY = new SvgMeasurement(); - [XmlIgnore] - public SvgMeasurement RY - { - get { return _RY; } - set { _RY = value; } - } - [XmlAttribute("ry")] + + [XmlIgnore] + public SvgMeasurement RY { get; set; } = new SvgMeasurement(); + [XmlAttribute("ry")] [Browsable(false)] [EditorBrowsable(EditorBrowsableState.Never)] public string RY_XmlSurrogate { - get { return SvgXmlConverter.GetString(_RY); } - set { _RY = SvgXmlConverter.GetObject(value); } + get { return SvgXmlConverter.GetString(RY); } + set { RY = SvgXmlConverter.GetObject(value); } } #endregion } diff --git a/PROMS/Volian.Svg.Library/SvgFillSettings.cs b/PROMS/Volian.Svg.Library/SvgFillSettings.cs index 5c371699..d35fddbe 100644 --- a/PROMS/Volian.Svg.Library/SvgFillSettings.cs +++ b/PROMS/Volian.Svg.Library/SvgFillSettings.cs @@ -1,6 +1,3 @@ -using System; -using System.Collections.Generic; -using System.Text; using System.Drawing; namespace Volian.Svg.Library @@ -9,34 +6,18 @@ namespace Volian.Svg.Library { #region ctor public SvgFillSettings() { ;} - public SvgFillSettings(Color myColor) - { - _Fill = ColorTranslator.ToHtml(myColor); - } - //public SvgFillSettings(string myFill) - //{ - // _Fill = myFill; - //} - #endregion - #region Inheritance - private SvgFillSettings _MyParentsSettings = null; - public SvgFillSettings MyParentsSettings - { - get { return _MyParentsSettings; } - set - { - _MyParentsSettings = value; - } - } - #endregion - #region Internal Inherited Properties - protected string InheritedFill + public SvgFillSettings(Color myColor) => Fill = ColorTranslator.ToHtml(myColor); + #endregion + #region Inheritance + public SvgFillSettings MyParentsSettings { get; set; } = null; + #endregion + #region Internal Inherited Properties + protected string InheritedFill { get { - // Fill = "", "0" - Default, otherwise the value - if (_Fill != "" && _Fill != "0" && _Fill.ToLower() != "empty") return _Fill; // Current Value - if (_MyParentsSettings != null) return _MyParentsSettings.InheritedFill; // Inherited + if (Fill != "" && Fill != "0" && Fill.ToLower() != "empty") return Fill; // Current Value + if (MyParentsSettings != null) return MyParentsSettings.InheritedFill; // Inherited return "Black"; // Default } } @@ -54,20 +35,12 @@ namespace Volian.Svg.Library } set { - if (value == Color.Transparent || value == Color.Empty) - _Fill = "none"; - else - _Fill = ColorTranslator.ToHtml(value); - } + Fill = value == Color.Transparent || value == Color.Empty ? "none" : ColorTranslator.ToHtml(value); + } } - #endregion - #region Properties - private string _Fill = string.Empty; // Default value is None - public string Fill - { - get { return _Fill; } - set { _Fill = value; } - } - #endregion - } + #endregion + #region Properties + public string Fill { get; set; } = string.Empty; + #endregion + } } diff --git a/PROMS/Volian.Svg.Library/SvgFontSettings.cs b/PROMS/Volian.Svg.Library/SvgFontSettings.cs index d151c16e..30e8100d 100644 --- a/PROMS/Volian.Svg.Library/SvgFontSettings.cs +++ b/PROMS/Volian.Svg.Library/SvgFontSettings.cs @@ -1,6 +1,3 @@ -using System; -using System.Collections.Generic; -using System.Text; using System.Drawing; namespace Volian.Svg.Library @@ -17,33 +14,17 @@ namespace Volian.Svg.Library _FontWeight = ((myFont.Style & FontStyle.Bold) == FontStyle.Bold ? "bold" : "normal"); _TextDecoration = ((myFont.Style & FontStyle.Underline) == FontStyle.Underline ? "underline" : "normal"); } - //public SvgFontSettings(string myFontFamily, string myFontSize, string mySvgStyle, string myFontWeight, string myTextDecoration) - //{ - // _FontFamilyName = myFontFamily; - // _FontSize = myFontSize; - // _SVGFontStyle = mySvgStyle; - // _FontWeight = myFontWeight; - // _TextDecoration = myTextDecoration; - //} - #endregion - #region Inheritance - private SvgFontSettings _MyParentsSettings = null; - public SvgFontSettings MyParentsSettings - { - get { return _MyParentsSettings; } - set - { - _MyParentsSettings = value; - } - } - #endregion - #region Internal Inherited Properties - protected string InheritedFontFamily + #endregion + #region Inheritance + public SvgFontSettings MyParentsSettings { get; set; } = null; + #endregion + #region Internal Inherited Properties + protected string InheritedFontFamily { get { if (_FontFamily != "") return _FontFamily; - if (_MyParentsSettings != null) return _MyParentsSettings.InheritedFontFamily; // Default + if (MyParentsSettings != null) return MyParentsSettings.InheritedFontFamily; // Default return "Arial"; // Absolute Default } } @@ -52,7 +33,7 @@ namespace Volian.Svg.Library get { if (_FontSize != "") return _FontSize; // Current Value - if (_MyParentsSettings != null) return _MyParentsSettings.InheritedFontSize; // Default + if (MyParentsSettings != null) return MyParentsSettings.InheritedFontSize; // Default return "9PT"; // Absolute Default } } @@ -61,7 +42,7 @@ namespace Volian.Svg.Library get { if (_SVGFontStyle != "") return _SVGFontStyle; // Current Value - if (_MyParentsSettings != null) return _MyParentsSettings.InheritedFontStyle;// Default + if (MyParentsSettings != null) return MyParentsSettings.InheritedFontStyle;// Default return "normal"; // Absolute Default } } @@ -70,7 +51,7 @@ namespace Volian.Svg.Library get { if (_FontWeight != "") return _FontWeight;// Current Value - if (_MyParentsSettings != null) return _MyParentsSettings.InheritedFontWeight;// Default + if (MyParentsSettings != null) return MyParentsSettings.InheritedFontWeight;// Default return "normal"; // Absolute Default } } @@ -79,7 +60,7 @@ namespace Volian.Svg.Library get { if (_TextDecoration != "") return _TextDecoration;// Current Value - if (_MyParentsSettings != null) return _MyParentsSettings.InheritedTextDecoration;// Default + if (MyParentsSettings != null) return MyParentsSettings.InheritedTextDecoration;// Default return "normal"; // Absolute Default } } @@ -110,13 +91,6 @@ namespace Volian.Svg.Library } set { - // This was disposing fonts that are saved in our static dictionary. - // caused problems with the step editor display after printing (found with Wolf Creek Chem procedure RW-G02 Step 6.1.17) - jsj 7/14/2017 - //if (_Font != null) - //{ - // Console.WriteLine("font dispose {0}, {1}", _Font, _Font.Style); - // //_Font.Dispose(); - //} if (value != null) { _FontFamily = value.FontFamily.Name; diff --git a/PROMS/Volian.Svg.Library/SvgGroup.cs b/PROMS/Volian.Svg.Library/SvgGroup.cs index 69a49907..a6380fd9 100644 --- a/PROMS/Volian.Svg.Library/SvgGroup.cs +++ b/PROMS/Volian.Svg.Library/SvgGroup.cs @@ -1,75 +1,48 @@ -using System; using System.Collections.Generic; -using System.Text; using System.Xml.Serialization; -using System.ComponentModel; -using System.Drawing; namespace Volian.Svg.Library { public partial class SvgGroup : SvgPartInheritance { - #region Description - private string _Description = string.Empty; - [System.ComponentModel.DefaultValueAttribute("")] - [XmlElement("desc")] - public string Description + #region Description + [System.ComponentModel.DefaultValueAttribute("")] + [XmlElement("desc")] + public string Description { get; set; } = string.Empty; + #endregion + #region Title + [System.ComponentModel.DefaultValueAttribute("")] + [XmlElement("title")] + public string Title { get; set; } = string.Empty; + #endregion + #region Parts + // SVG Parts + [XmlElement("use", typeof(SvgUse))] + [XmlElement("image", typeof(SvgImage))] + [XmlElement("text", typeof(SvgText))] + [XmlElement("line", typeof(SvgLine))] + [XmlElement("circle", typeof(SvgCircle))] + [XmlElement("rect", typeof(SvgRectangle))] + [XmlElement("ellipse", typeof(SvgEllipse))] + [XmlElement("svg", typeof(Svg))] + [XmlElement("g", typeof(SvgGroup))] + [XmlElement("defs", typeof(SvgDefine))] + public SvgParts SvgParts { get; set; } = new SvgParts(); + public SvgPart Add(SvgPart svgPart) { - get { return _Description; } - set { _Description = value; } - } - #endregion - #region Title - private string _Title = string.Empty; - [System.ComponentModel.DefaultValueAttribute("")] - [XmlElement("title")] - public string Title - { - get { return _Title; } - set { _Title = value; } - } - #endregion - #region Parts - // SVG Parts - SvgParts _SvgParts = new SvgParts(); - //[XmlElement("foreignObject", typeof(SvgRtf))] - [XmlElement("use", typeof(SvgUse))] - [XmlElement("image", typeof(SvgImage))] - [XmlElement("text", typeof(SvgText))] - [XmlElement("line", typeof(SvgLine))] - [XmlElement("circle", typeof(SvgCircle))] - [XmlElement("rect", typeof(SvgRectangle))] - [XmlElement("ellipse", typeof(SvgEllipse))] - [XmlElement("svg", typeof(Svg))] - [XmlElement("g", typeof(SvgGroup))] - [XmlElement("defs", typeof(SvgDefine))] - public SvgParts SvgParts - { - get { return _SvgParts; } - set { _SvgParts = value; } - } - public SvgPart Add(SvgPart svgPart) - { - _SvgParts.Add(svgPart); + SvgParts.Add(svgPart); return svgPart; } - public void RemoveAt(int i) - { - _SvgParts.RemoveAt(i); - } - public int Count - { get { return _SvgParts.Count; } } - #endregion - #region Dictionary of Parts - internal override void AddLookup(Dictionary lookUp) + public void RemoveAt(int i) => SvgParts.RemoveAt(i); + public int Count => SvgParts.Count; + #endregion + #region Dictionary of Parts + internal override void AddLookup(Dictionary lookUp) { base.AddLookup(lookUp); SvgParts.AddLookup(lookUp); } - #endregion - public override string ToString() - { - return ID; - } - } + #endregion + public override string ToString() => ID; + } } \ No newline at end of file diff --git a/PROMS/Volian.Svg.Library/SvgImage.cs b/PROMS/Volian.Svg.Library/SvgImage.cs index 012cae61..be0a1843 100644 --- a/PROMS/Volian.Svg.Library/SvgImage.cs +++ b/PROMS/Volian.Svg.Library/SvgImage.cs @@ -1,6 +1,3 @@ -using System; -using System.Collections.Generic; -using System.Text; using System.Xml.Serialization; using System.ComponentModel; using System.Drawing; @@ -13,87 +10,64 @@ namespace Volian.Svg.Library public SvgImage() { ;} public SvgImage(PointF location, SizeF size, string path) { - _X.Value = location.X; - _Y.Value = location.Y; - _Width.Value = size.Width; - _Height.Value = size.Height; - _ImagePath = path; + X.Value = location.X; + Y.Value = location.Y; + Width.Value = size.Width; + Height.Value = size.Height; + ImagePath = path; } - #endregion - #region Location - private SvgMeasurement _X = new SvgMeasurement(); - [XmlIgnore] - public SvgMeasurement X - { - get { return _X; } - set { _X = value; } - } - [XmlAttribute("x")] + #endregion + #region Location + [XmlIgnore] + public SvgMeasurement X { get; set; } = new SvgMeasurement(); + [XmlAttribute("x")] [Browsable(false)] [EditorBrowsable(EditorBrowsableState.Never)] public string X_XmlSurrogate { - get { return SvgXmlConverter.GetString(_X); } - set { _X = SvgXmlConverter.GetObject(value); } + get { return SvgXmlConverter.GetString(X); } + set { X = SvgXmlConverter.GetObject(value); } } - private SvgMeasurement _Y = new SvgMeasurement(); - [XmlIgnore] - public SvgMeasurement Y - { - get { return _Y; } - set { _Y = value; } - } - [XmlAttribute("y")] + + [XmlIgnore] + public SvgMeasurement Y { get; set; } = new SvgMeasurement(); + [XmlAttribute("y")] [Browsable(false)] [EditorBrowsable(EditorBrowsableState.Never)] public string Y_XmlSurrogate { - get { return SvgXmlConverter.GetString(_Y); } - set { _Y = SvgXmlConverter.GetObject(value); } + get { return SvgXmlConverter.GetString(Y); } + set { Y = SvgXmlConverter.GetObject(value); } } - #endregion - #region Size - private SvgMeasurement _Width = new SvgMeasurement(); - [XmlIgnore] - public SvgMeasurement Width - { - get { return _Width; } - set { _Width = value; } - } - [XmlAttribute("width")] + #endregion + #region Size + [XmlIgnore] + public SvgMeasurement Width { get; set; } = new SvgMeasurement(); + [XmlAttribute("width")] [Browsable(false)] [EditorBrowsable(EditorBrowsableState.Never)] public string Width_WidthmlSurrogate { - get { return SvgXmlConverter.GetString(_Width); } - set { _Width = SvgXmlConverter.GetObject(value); } + get { return SvgXmlConverter.GetString(Width); } + set { Width = SvgXmlConverter.GetObject(value); } } - private SvgMeasurement _Height = new SvgMeasurement(); - [XmlIgnore] - public SvgMeasurement Height - { - get { return _Height; } - set { _Height = value; } - } - [XmlAttribute("height")] + + [XmlIgnore] + public SvgMeasurement Height { get; set; } = new SvgMeasurement(); + [XmlAttribute("height")] [Browsable(false)] [EditorBrowsable(EditorBrowsableState.Never)] public string Height_XmlSurrogate { - get { return SvgXmlConverter.GetString(_Height); } - set { _Height = SvgXmlConverter.GetObject(value); } + get { return SvgXmlConverter.GetString(Height); } + set { Height = SvgXmlConverter.GetObject(value); } } - #endregion - #region Path to Image File - private string _ImagePath = null; - [XmlAttribute(AttributeName = "href", Namespace = "http://www.w3.org/1999/xlink")] - [Browsable(false)] - [EditorBrowsable(EditorBrowsableState.Never)] - public string ImagePath - { - get { return _ImagePath; } - set { _ImagePath = value; } - } - #endregion - } + #endregion + #region Path to Image File + [XmlAttribute(AttributeName = "href", Namespace = "http://www.w3.org/1999/xlink")] + [Browsable(false)] + [EditorBrowsable(EditorBrowsableState.Never)] + public string ImagePath { get; set; } = null; + #endregion + } } \ No newline at end of file diff --git a/PROMS/Volian.Svg.Library/SvgInheritedSettings.cs b/PROMS/Volian.Svg.Library/SvgInheritedSettings.cs index 702ad9cc..97e0d442 100644 --- a/PROMS/Volian.Svg.Library/SvgInheritedSettings.cs +++ b/PROMS/Volian.Svg.Library/SvgInheritedSettings.cs @@ -1,7 +1,3 @@ -using System; -using System.Collections.Generic; -using System.Text; - namespace Volian.Svg.Library { internal class SvgInheritedSettings @@ -19,69 +15,54 @@ namespace Volian.Svg.Library MyFontSettings.MyParentsSettings = value.MyFontSettings; } } - #endregion - #region Line Settings - private SvgLineSettings _MyLineSettings = new SvgLineSettings(); - public SvgLineSettings MyLineSettings + #endregion + #region Line Settings + public SvgLineSettings MyLineSettings { get; set; } = new SvgLineSettings(); + public string Stroke { - get { return _MyLineSettings; } - set { _MyLineSettings = value; } - } - public string Stroke - { - get { return _MyLineSettings.Stroke; } - set { _MyLineSettings.Stroke = value; } + get { return MyLineSettings.Stroke; } + set { MyLineSettings.Stroke = value; } } public string StrokeWidth { - get { return _MyLineSettings.StrokeWidth; } - set { _MyLineSettings.StrokeWidth = value; } + get { return MyLineSettings.StrokeWidth; } + set { MyLineSettings.StrokeWidth = value; } } - #endregion - #region Fill Settings - private SvgFillSettings _MyFillSettings = new SvgFillSettings(); - internal SvgFillSettings MyFillSettings + #endregion + #region Fill Settings + internal SvgFillSettings MyFillSettings { get; set; } = new SvgFillSettings(); + public string Fill { - get { return _MyFillSettings; } - set { _MyFillSettings = value; } + get { return MyFillSettings.Fill; } + set { MyFillSettings.Fill = value; } } - public string Fill + #endregion + #region Font Settings + internal SvgFontSettings MyFontSettings { get; set; } = new SvgFontSettings(); + public string FontFamily { - get { return _MyFillSettings.Fill; } - set { _MyFillSettings.Fill = value; } - } - #endregion - #region Font Settings - private SvgFontSettings _MyFontSettings = new SvgFontSettings(); - internal SvgFontSettings MyFontSettings - { - get { return _MyFontSettings; } - set { _MyFontSettings = value; } - } - public string FontFamily - { - get { return _MyFontSettings.FontFamily; } - set { _MyFontSettings.FontFamily = value; } + get { return MyFontSettings.FontFamily; } + set { MyFontSettings.FontFamily = value; } } public string FontSize { - get { return _MyFontSettings.FontSize; } - set { _MyFontSettings.FontSize = value; } + get { return MyFontSettings.FontSize; } + set { MyFontSettings.FontSize = value; } } public string SVGFontStyle { - get { return _MyFontSettings.SVGFontStyle; } - set { _MyFontSettings.SVGFontStyle = value; } + get { return MyFontSettings.SVGFontStyle; } + set { MyFontSettings.SVGFontStyle = value; } } public string FontWeight { - get { return _MyFontSettings.FontWeight; } - set { _MyFontSettings.FontWeight = value; } + get { return MyFontSettings.FontWeight; } + set { MyFontSettings.FontWeight = value; } } public string TextDecoration { - get { return _MyFontSettings.TextDecoration; } - set { _MyFontSettings.TextDecoration = value; } + get { return MyFontSettings.TextDecoration; } + set { MyFontSettings.TextDecoration = value; } } #endregion } diff --git a/PROMS/Volian.Svg.Library/SvgLine.cs b/PROMS/Volian.Svg.Library/SvgLine.cs index c613d60a..63c28e19 100644 --- a/PROMS/Volian.Svg.Library/SvgLine.cs +++ b/PROMS/Volian.Svg.Library/SvgLine.cs @@ -1,6 +1,4 @@ using System; -using System.Collections.Generic; -using System.Text; using System.Xml.Serialization; using System.ComponentModel; using System.Drawing; @@ -13,146 +11,72 @@ namespace Volian.Svg.Library public SvgLine() { ;} public SvgLine(PointF location1, PointF location2, Color lineColor, float lineWidth) { - _X1.Value = location1.X; - _Y1.Value = location1.Y; - _X2.Value = location2.X; - _Y2.Value = location2.Y; + X1.Value = location1.X; + Y1.Value = location1.Y; + X2.Value = location2.X; + Y2.Value = location2.Y; LineColor = lineColor; LineWidth = new SvgMeasurement(lineWidth); } - //XMLElementAttribute(ElementName = "PREFIX", IsNullable = false) - #endregion - #region Location1 - private SvgMeasurement _X1 = new SvgMeasurement(); - [XmlIgnore] - public SvgMeasurement X1 - { - get { return _X1; } - set { _X1 = value; } - } - [XmlAttribute("x1")] + #endregion + #region Location1 + [XmlIgnore] + public SvgMeasurement X1 { get; set; } = new SvgMeasurement(); + [XmlAttribute("x1")] [Browsable(false)] [EditorBrowsable(EditorBrowsableState.Never)] public string X1_XmlSurrogate { - get { return SvgXmlConverter.GetString(_X1); } - set { _X1 = SvgXmlConverter.GetObject(value); } + get { return SvgXmlConverter.GetString(X1); } + set { X1 = SvgXmlConverter.GetObject(value); } } - private SvgMeasurement _Y1 = new SvgMeasurement(); - [XmlIgnore] - public SvgMeasurement Y1 - { - get { return _Y1; } - set { _Y1 = value; } - } - [XmlAttribute("y1")] + + [XmlIgnore] + public SvgMeasurement Y1 { get; set; } = new SvgMeasurement(); + [XmlAttribute("y1")] [Browsable(false)] [EditorBrowsable(EditorBrowsableState.Never)] public string Y1_XmlSurrogate { - get { return SvgXmlConverter.GetString(_Y1); } - set { _Y1 = SvgXmlConverter.GetObject(value); } + get { return SvgXmlConverter.GetString(Y1); } + set { Y1 = SvgXmlConverter.GetObject(value); } } - #endregion - #region Location2 - private SvgMeasurement _X2 = new SvgMeasurement(); - [XmlIgnore] - public SvgMeasurement X2 - { - get { return _X2; } - set { _X2 = value; } - } - [XmlAttribute("x2")] + #endregion + #region Location2 + [XmlIgnore] + public SvgMeasurement X2 { get; set; } = new SvgMeasurement(); + [XmlAttribute("x2")] [Browsable(false)] [EditorBrowsable(EditorBrowsableState.Never)] public string X2_XmlSurrogate { - get { return SvgXmlConverter.GetString(_X2); } - set { _X2 = SvgXmlConverter.GetObject(value); } + get { return SvgXmlConverter.GetString(X2); } + set { X2 = SvgXmlConverter.GetObject(value); } } - private SvgMeasurement _Y2 = new SvgMeasurement(); - [XmlIgnore] - public SvgMeasurement Y2 - { - get { return _Y2; } - set { _Y2 = value; } - } - [XmlAttribute("y2")] + + [XmlIgnore] + public SvgMeasurement Y2 { get; set; } = new SvgMeasurement(); + [XmlAttribute("y2")] [Browsable(false)] [EditorBrowsable(EditorBrowsableState.Never)] public string Y_XmlSurrogate { - get { return SvgXmlConverter.GetString(_Y2); } - set { _Y2 = SvgXmlConverter.GetObject(value); } + get { return SvgXmlConverter.GetString(Y2); } + set { Y2 = SvgXmlConverter.GetObject(value); } } - #endregion - #region Description - private string _Description = string.Empty; - [System.ComponentModel.DefaultValueAttribute("")] - [XmlElement("desc")] - public string Description - { - get { return _Description; } - set { _Description = value; } - } - #endregion - #region LineColor - //protected Color _LineColor = Color.Empty; - //[XmlIgnoreAttribute()] - //public Color LineColor - //{ - // get { return _LineWidth.Value == 0 ? Color.LightGray : _LineColor == Color.Empty ? Color.Gray : _LineColor; } - // set { _LineColor = value; } - //} - private Color AdjustColorForWidth(Color myColor, float myWidth) + #endregion + #region Description + [System.ComponentModel.DefaultValueAttribute("")] + [XmlElement("desc")] + public string Description { get; set; } = string.Empty; + #endregion + #region LineColor + private Color AdjustColorForWidth(Color myColor, float myWidth) { if (myWidth > 1F) return myColor; //Console.WriteLine("Line Width = {0}, Alpha = {1}", myWidth, Convert.ToInt32(myWidth * 255)); return Color.FromArgb(Convert.ToInt32(myWidth * 255), myColor); } - // Serializes the 'BackgroundColor' Color to XML. - //[System.ComponentModel.DefaultValueAttribute("none")] - //[XmlAttribute("stroke")] - //public string Stroke - //{ - // get { return _LineColor == Color.Empty ? "none" : _LineColor == Color.Black ? "" : ColorTranslator.ToHtml(_LineColor); } - // set { _LineColor = (value == "none" ? Color.Empty : (value == "" ? Color.Empty : ColorTranslator.FromHtml(value))); } - //} - #endregion - #region LineWidth - //private SvgMeasurement GetLineWidth() - //{ - // if (_LineWidth.Value == -1) return new SvgMeasurement(1F);// Minimum Strokewidth - // if (_LineWidth.Value == 0) return new SvgMeasurement(.01F);// Minimum Strokewidth - // if (_LineColor == Color.Empty) return new SvgMeasurement( .01F);// No Color - Minimum Strokewidth - // return _LineWidth; - //} - //private SvgMeasurement _LineWidth = new SvgMeasurement(); - //[XmlIgnore] - //public SvgMeasurement LineWidth - //{ - // get { return _LineWidth; } - // set { _LineWidth = value; } - //} - //[XmlAttribute("stroke-width")] - //[Browsable(false)] - //[EditorBrowsable(EditorBrowsableState.Never)] - //public string LineWidth_XmlSurrogate - //{ - // get - // { - // if (_LineWidth.Value == -1) - // return "none"; - // return VolianXmlConverter.GetString(_LineWidth); - // } - // set - // { - // if (value == "none") - // _LineWidth = VolianXmlConverter.GetObject("-1"); - // else - // _LineWidth = VolianXmlConverter.GetObject(value); - // } - //} #endregion } } diff --git a/PROMS/Volian.Svg.Library/SvgLinePart.cs b/PROMS/Volian.Svg.Library/SvgLinePart.cs index f0c859a7..e4e5004c 100644 --- a/PROMS/Volian.Svg.Library/SvgLinePart.cs +++ b/PROMS/Volian.Svg.Library/SvgLinePart.cs @@ -1,6 +1,3 @@ -using System; -using System.Collections.Generic; -using System.Text; using System.Drawing; using System.Xml.Serialization; using System.ComponentModel; @@ -50,12 +47,9 @@ namespace Volian.Svg.Library get { return _MyLineSettings.OutlineWidth; } set { _MyLineSettings.OutlineWidth = value; } } - #endregion - #region Setup Inheritance - override internal void SetupInheritance(SvgInheritedSettings myParentsSettings) - { - _MyLineSettings.MyParentsSettings = myParentsSettings.MyLineSettings; - } - #endregion - } + #endregion + #region Setup Inheritance + override internal void SetupInheritance(SvgInheritedSettings myParentsSettings) => _MyLineSettings.MyParentsSettings = myParentsSettings.MyLineSettings; + #endregion + } } diff --git a/PROMS/Volian.Svg.Library/SvgLineSettings.cs b/PROMS/Volian.Svg.Library/SvgLineSettings.cs index b995d0d7..5bdd7066 100644 --- a/PROMS/Volian.Svg.Library/SvgLineSettings.cs +++ b/PROMS/Volian.Svg.Library/SvgLineSettings.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; using System.Drawing; -using System.ComponentModel; -using System.Xml.Serialization; namespace Volian.Svg.Library { @@ -13,34 +8,20 @@ namespace Volian.Svg.Library public SvgLineSettings() { ;} public SvgLineSettings(Color myColor, SvgMeasurement myWidth) { - _Stroke = ColorTranslator.ToHtml(myColor); - _StrokeWidth = myWidth.ToString(); + Stroke = ColorTranslator.ToHtml(myColor); + StrokeWidth = myWidth.ToString(); } - //public SvgLineSettings(string myStroke, string myStrokeWidth) - //{ - // _Stroke = myStroke; - // _StrokeWidth = myStrokeWidth; - //} - #endregion - #region Inheritance - private SvgLineSettings _MyParentsSettings = null; - public SvgLineSettings MyParentsSettings - { - get { return _MyParentsSettings; } - set - { - _MyParentsSettings = value; - } - } - #endregion - #region Internal Inherited Properties - protected string InheritedStroke + #endregion + #region Inheritance + public SvgLineSettings MyParentsSettings { get; set; } = null; + #endregion + #region Internal Inherited Properties + protected string InheritedStroke { get { - // Stroke = "", "0" - Default, otherwise the value - if (_Stroke != "" && _Stroke != "0") return _Stroke; // Current Value - if (_MyParentsSettings != null) return _MyParentsSettings.InheritedStroke;// Inherited + if (Stroke != "" && Stroke != "0") return Stroke; // Current Value + if (MyParentsSettings != null) return MyParentsSettings.InheritedStroke;// Inherited return "None"; // Default } } @@ -49,68 +30,47 @@ namespace Volian.Svg.Library get { // StrokeWidth = "", "none" - Default, otherwise the value - if (_StrokeWidth != "" && _StrokeWidth != "none") return _StrokeWidth; // Current Value - if (_MyParentsSettings != null) return _MyParentsSettings.InheritedLineWidth; // Inherited + if (StrokeWidth != "" && StrokeWidth != "none") return StrokeWidth; // Current Value + if (MyParentsSettings != null) return MyParentsSettings.InheritedLineWidth; // Inherited return "1PX"; // Default } } - //protected string InheritedOutlineWidth - //{ - // get - // { - // // StrokeWidth = "", "none" - Default, otherwise the value - // if (_StrokeWidth != "" && _StrokeWidth.ToLower() != "none") return _StrokeWidth; // Current Value - // if (_MyParent != null) return _MyParent.InheritedLineWidth; // Inherited - // return "1PX"; // Default - // } - //} #endregion #region Inherited Values public SvgMeasurement LineWidth { get { - // Stroke = "None" - Light, otherwise the value - // StrokeWidth = "None" Light, otherwise the value string myStroke = InheritedStroke; string myWidth = InheritedLineWidth; - //if (myStroke.ToLower() == "none" || myWidth.ToLower() == "none") // Light - // return new SvgMeasurement(.001F, E_MeasurementUnits.PX); SvgMeasurement myMeasurement = new SvgMeasurement(myWidth); - //myMeasurement.Value *= _Scale; return myMeasurement; } set { - _StrokeWidth = value.ToString(); + StrokeWidth = value.ToString(); } } public SvgMeasurement OutlineWidth { get { - // Stroke = "None" - Eliminate, otherwise the value - // StrokeWidth = "0" Eliminate, otherwise the value string myStroke = InheritedStroke; - //string myWidth = InheritedOutlineWidth; string myWidth = InheritedLineWidth; if (myStroke.ToLower() == "none" || myWidth == "0") // Eliminate return new SvgMeasurement(0, E_MeasurementUnits.PX); SvgMeasurement myMeasurement = new SvgMeasurement(myWidth); - //myMeasurement.Value *= _Scale; return myMeasurement; } set { - _StrokeWidth = value.ToString(); + StrokeWidth = value.ToString(); } } public Color LineColor { get { - // Stroke = "None" - Eliminate, otherwise the value - // StrokeWidth = "None" Eliminate, otherwise the value string myStroke = InheritedStroke; string myWidth = InheritedLineWidth; if (myStroke.ToLower() == "none" || myWidth.ToLower() == "none" || myWidth == "0") // Light @@ -120,9 +80,9 @@ namespace Volian.Svg.Library set { if (value == Color.Empty) - _Stroke = "none"; + Stroke = "none"; else - _Stroke = ColorTranslator.ToHtml(value); + Stroke = ColorTranslator.ToHtml(value); } } @@ -130,10 +90,7 @@ namespace Volian.Svg.Library { get { - // Stroke = "None" - Eliminate, otherwise the value - // StrokeWidth = "0" Eliminate, otherwise the value string myStroke = InheritedStroke; - //string myWidth = InheritedOutlineWidth; string myWidth = InheritedLineWidth; if (myStroke.ToLower() == "none" || myWidth == "0") // Eliminate return Color.Empty; @@ -142,26 +99,16 @@ namespace Volian.Svg.Library set { if (value == Color.Empty) - _Stroke = "none"; + Stroke = "none"; else - _Stroke = ColorTranslator.ToHtml(value); + Stroke = ColorTranslator.ToHtml(value); } } - #endregion - #region Properties - private string _Stroke = string.Empty; // Default value is None - public string Stroke - { - get { return _Stroke; } - set { _Stroke = value; } - } - private string _StrokeWidth = string.Empty; // Default value is 1PX - public string StrokeWidth - { - get { return _StrokeWidth; } - set { _StrokeWidth = value; } - } - #endregion - } + #endregion + #region Properties + public string Stroke { get; set; } = string.Empty; + public string StrokeWidth { get; set; } = string.Empty; + #endregion + } } diff --git a/PROMS/Volian.Svg.Library/SvgMeasurement.cs b/PROMS/Volian.Svg.Library/SvgMeasurement.cs index e953cf6e..eabc42fd 100644 --- a/PROMS/Volian.Svg.Library/SvgMeasurement.cs +++ b/PROMS/Volian.Svg.Library/SvgMeasurement.cs @@ -1,9 +1,5 @@ using System; -using System.Collections.Generic; -using System.Text; using System.ComponentModel; -using System.Drawing; -using System.Windows.Forms; using System.Text.RegularExpressions; namespace Volian.Svg.Library @@ -57,24 +53,24 @@ namespace Volian.Svg.Library public SvgMeasurement() { ;} public SvgMeasurement(int value) { - _Value = Convert.ToSingle(value); + Value = Convert.ToSingle(value); _Units = E_MeasurementUnits.PX; } public SvgMeasurement(float value) { - _Value = value; + Value = value; _Units = E_MeasurementUnits.PX; } public SvgMeasurement(float value, E_MeasurementUnits units) { - _Value = value; + Value = value; _Units = units; } public SvgMeasurement(string val) { val = val.Replace("{size}", "10");// B2020-145 BWD SAMG TSG-6 Fix for Base Format {size} parameter rather than font size MatchCollection mc = Regex.Matches(val.ToLower(), "([+-]?[.0-9]+)|(in|cm|mm|em|ex|pc|pt|px|percentage)"); - _Value = Convert.ToSingle(mc[0].Value); + Value = Convert.ToSingle(mc[0].Value); if (mc.Count == 2) { //Console.WriteLine("{0} - '{1}'", val, mc[1].Value.ToUpper()); @@ -93,108 +89,55 @@ namespace Volian.Svg.Library { float tmp = GetSizeInPoints(DPI); _Units = value; - _Value *= (tmp / GetSizeInPoints(DPI)); + Value *= (tmp / GetSizeInPoints(DPI)); } } - private float _Value; - public float Value - { - get { return _Value; } - set { _Value = value; } - } - #endregion - #region ToString - public override string ToString() + + public float Value { get; set; } + #endregion + #region ToString + public override string ToString() { switch (_Units) { case E_MeasurementUnits.PX: // Default - return string.Format("{0}", _Value); + return string.Format("{0}", Value); case E_MeasurementUnits.PERCENTAGE: // Precentage is preceded by a space - return string.Format("{0} {1}", _Value, _Units); + return string.Format("{0} {1}", Value, _Units); } - return string.Format("{0}{1}", _Value, _Units); + return string.Format("{0}{1}", Value, _Units); } #endregion - //public float SizeInPixels - //{ - // get - // { - // switch (_Units) - // { - // case E_MeasurementUnits.PT: //Points - 72 per inch - // return _Value * DPI / 72F; - // case E_MeasurementUnits.PC: //Picas - 6 per inch - // return _Value * DPI / 6F; - // case E_MeasurementUnits.IN: //inches - // return _Value * DPI; - // case E_MeasurementUnits.CM: // Centimeter - // return _Value * DPI / 2.54F; - // case E_MeasurementUnits.MM: // Millimeter - // return _Value * DPI / 25.4F; - // case E_MeasurementUnits.EM: // EMs - // return _Value * DPI / 8; - // case E_MeasurementUnits.EX: // EXs - // return _Value * DPI / 16; - // default: - // return _Value; - // } - // } - //} public float GetSizeInPoints(float myDPI) { switch (_Units) { case E_MeasurementUnits.PX: //Pixels myDPI per inch - return _Value * 72F / myDPI; + return Value * 72F / myDPI; case E_MeasurementUnits.PC: //Picas - 6 per inch - return _Value * 72F / 6F; + return Value * 72F / 6F; case E_MeasurementUnits.IN: //inches - return _Value * 72F; + return Value * 72F; case E_MeasurementUnits.CM: // Centimeter - return _Value * 72F / 2.54F; + return Value * 72F / 2.54F; case E_MeasurementUnits.MM: // Millimeter - return _Value * 72F / 25.4F; + return Value * 72F / 25.4F; case E_MeasurementUnits.EM: // EMs - return _Value * 72F / 8; + return Value * 72F / 8; case E_MeasurementUnits.EX: // EXs - return _Value * 72F / 16; + return Value * 72F / 16; default: // Points - return _Value; + return Value; } } - //public float SizeInPoints - //{ get { return SizeInPixels * 72 / DPI; } } - //public float SizeInInches - //{ get { return SizeInPixels / DPI; } } - //public float SizeInCentimeters - //{ get { return SizeInPixels * 2.54F / DPI; } } - //public float SizeInMillimeters - //{ get { return SizeInPixels * 25.4F / DPI; } } - //public float SizeInEms - //{ get { return SizeInPixels * 5 / (6 * DPI); } } - //public float SizeInExs - //{ get { return SizeInPixels * 5 / (6 * DPI); } } - //public float SizeInPicas - //{ get { return SizeInPixels * 6 / DPI; } } - //public Unit SizeInUnits - //{ get { return new Unit((double)SizeInPoints, UnitTypeEnum.Point); } } - public float GetSizeInPixels(float myDPI) - { return GetSizeInPoints(myDPI) * myDPI / 72F;} - public float GetSizeInInches(float myDPI) - { return GetSizeInPoints(myDPI) / 72F; } - public float GetSizeInCentimeters(float myDPI) - { return GetSizeInPoints(myDPI) * 2.54F / 72F; } - public float GetSizeInMillimeters(float myDPI) - { return GetSizeInPoints(myDPI) * 25.4F / 72F; } - public float GetSizeInEms(float myDPI) - { return GetSizeInPoints(myDPI) * 5 / (6 * 72F); } - public float GetSizeInExs(float myDPI) - { return GetSizeInPoints(myDPI) * 5 / (6 * 72F); } - public float GetSizeInPicas(float myDPI) - { return GetSizeInPoints(myDPI) * 6 / 72F; } - //public Unit GetSizeInUnits(float myDPI) - //{ return new Unit((double)GetSizeInPoints(myDPI), UnitTypeEnum.Point); } + public float GetSizeInPixels(float myDPI) => GetSizeInPoints(myDPI) * myDPI / 72F; + public float GetSizeInInches(float myDPI) => GetSizeInPoints(myDPI) / 72F; + public float GetSizeInCentimeters(float myDPI) => GetSizeInPoints(myDPI) * 2.54F / 72F; + public float GetSizeInMillimeters(float myDPI) => GetSizeInPoints(myDPI) * 25.4F / 72F; + public float GetSizeInEms(float myDPI) => GetSizeInPoints(myDPI) * 5 / (6 * 72F); + public float GetSizeInExs(float myDPI) => GetSizeInPoints(myDPI) * 5 / (6 * 72F); + public float GetSizeInPicas(float myDPI) => GetSizeInPoints(myDPI) * 6 / 72F; + public static float StringToPoints(string value) { SvgMeasurement tmp = new SvgMeasurement(value); @@ -226,26 +169,9 @@ namespace Volian.Svg.Library } public class MeasurementTypeConverter : ExpandableObjectConverter { - public override bool CanConvertTo(ITypeDescriptorContext context, Type t) - { - return t == typeof(String); - } - public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType) - { - if (destType == typeof(string) && value is SvgMeasurement) - { - return value.ToString(); - } - return base.ConvertTo(context, culture, value, destType); - } - public override bool CanConvertFrom(ITypeDescriptorContext context, Type t) - { - return t == typeof(String); - } - public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object val) - { - SvgMeasurement measurement = new SvgMeasurement((string)val); - return measurement; - } - } + public override bool CanConvertTo(ITypeDescriptorContext context, Type t) => t == typeof(String); + public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType) => destType == typeof(string) && value is SvgMeasurement ? value.ToString() : base.ConvertTo(context, culture, value, destType); + public override bool CanConvertFrom(ITypeDescriptorContext context, Type t) => t == typeof(String); + public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object val) => new SvgMeasurement((string)val); + } } diff --git a/PROMS/Volian.Svg.Library/SvgPart.cs b/PROMS/Volian.Svg.Library/SvgPart.cs index 2f509335..af7068ef 100644 --- a/PROMS/Volian.Svg.Library/SvgPart.cs +++ b/PROMS/Volian.Svg.Library/SvgPart.cs @@ -1,7 +1,4 @@ -using System; -using System.IO; using System.Xml.Serialization; -using System.Drawing; using System.ComponentModel; using System.Collections.Generic; @@ -21,28 +18,6 @@ namespace Volian.Svg.Library set { _ID = value; } } #endregion - //#region Parent and Containing Svg - //// ToDo: MyParent - //private SvgPartGrouping _MyParent; - //[XmlIgnore()] - //public SvgPartGrouping MyParent - //{ - // get { return _MyParent; } - // set { _MyParent = value; } - //} - //// ToDo: MySvg - //private Svg _MySvg; - //public Svg MySvg - //{ - // get { return _MySvg; } - // set { _MySvg = value; } - //} - //internal void SetParent(SvgPartGrouping myParent) - //{ - // _MyParent = myParent; - // _MySvg = myParent.MySvg == null? MyParent : myParent.MySvg; - //} - //#endregion #region Setup Inheritance virtual internal void SetupInheritance(SvgInheritedSettings myParentsSettings) { ; } #endregion diff --git a/PROMS/Volian.Svg.Library/SvgPartInheritance.cs b/PROMS/Volian.Svg.Library/SvgPartInheritance.cs index aaf48f24..ee41f0df 100644 --- a/PROMS/Volian.Svg.Library/SvgPartInheritance.cs +++ b/PROMS/Volian.Svg.Library/SvgPartInheritance.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; using System.Xml.Serialization; -using System.ComponentModel; -using System.Drawing; namespace Volian.Svg.Library { @@ -78,14 +73,10 @@ namespace Volian.Svg.Library get { return _MyInheritedSettings.TextDecoration; } set { _MyInheritedSettings.TextDecoration = value; } } - #endregion - #endregion - #region Setup Inheritance - override internal void SetupInheritance(SvgInheritedSettings myParentsSettings) - { - _MyInheritedSettings.MyParentsSettings = myParentsSettings; - //_SvgParts.SetupInheritance(_MyInheritedSettings); - } - #endregion - } + #endregion + #endregion + #region Setup Inheritance + override internal void SetupInheritance(SvgInheritedSettings myParentsSettings) => _MyInheritedSettings.MyParentsSettings = myParentsSettings; + #endregion + } } diff --git a/PROMS/Volian.Svg.Library/SvgParts.cs b/PROMS/Volian.Svg.Library/SvgParts.cs index 18cbb24f..7091dc46 100644 --- a/PROMS/Volian.Svg.Library/SvgParts.cs +++ b/PROMS/Volian.Svg.Library/SvgParts.cs @@ -1,7 +1,6 @@ using System; using System.Collections; using System.Collections.Generic; -using System.Drawing; using System.ComponentModel; using System.Text; @@ -38,52 +37,39 @@ namespace Volian.Svg.Library { } - /// - /// - /// Initializes a new instance of based on another . - /// - /// - /// - /// A from which the contents are copied - /// - public SvgParts(SvgParts value) - { - this.AddRange(value); - } + /// + /// + /// Initializes a new instance of based on another . + /// + /// + /// + /// A from which the contents are copied + /// + public SvgParts(SvgParts value) => this.AddRange(value); - /// - /// - /// Initializes a new instance of containing any array of objects. - /// - /// - /// - /// A array of objects with which to intialize the collection - /// - public SvgParts(SvgPart[] value) - { - this.AddRange(value); - } + /// + /// + /// Initializes a new instance of containing any array of objects. + /// + /// + /// + /// A array of objects with which to intialize the collection + /// + public SvgParts(SvgPart[] value) => this.AddRange(value); - /// - /// Represents the entry at the specified index of the . - /// - /// The zero-based index of the entry to locate in the collection. - /// - /// The entry at the specified index of the collection. - /// - /// is outside the valid range of indexes for the collection. - public SvgPart this[int index] + /// + /// Represents the entry at the specified index of the . + /// + /// The zero-based index of the entry to locate in the collection. + /// + /// The entry at the specified index of the collection. + /// + /// is outside the valid range of indexes for the collection. + public SvgPart this[int index] { get { return ((SvgPart)(List[index])); } set { List[index] = value; } } - //#region SetupInheritance - //internal void SetupInheritance(SvgInheritedSettings myParentsSettings) - //{ - // foreach (SvgPart svgPart in List) - // svgPart.SetupInheritance(myParentsSettings); - //} - //#endregion #region Dictionary of Parts internal void AddLookup(Dictionary lookUp) { @@ -194,29 +180,26 @@ namespace Volian.Svg.Library List.CopyTo(array, index); } - /// - /// Returns the index of a in - /// the . - /// - /// The to locate. - /// - /// The index of the of in the - /// , if found; otherwise, -1. - /// - /// - public int IndexOf(SvgPart value) - { - return List.IndexOf(value); - } + /// + /// Returns the index of a in + /// the . + /// + /// The to locate. + /// + /// The index of the of in the + /// , if found; otherwise, -1. + /// + /// + public int IndexOf(SvgPart value) => List.IndexOf(value); - /// - /// Inserts a into the at the specified index. - /// - /// The zero-based index where should be inserted. - /// The to insert. - /// None. - /// - public void Insert(int index, SvgPart value) + /// + /// Inserts a into the at the specified index. + /// + /// The zero-based index where should be inserted. + /// The to insert. + /// None. + /// + public void Insert(int index, SvgPart value) { List.Insert(index, value); if (OnItemAdd != null) { OnItemAdd(this, new SVGPartArgs(value)); } @@ -288,45 +271,25 @@ namespace Volian.Svg.Library /// Event arguments for the SVGParts collection class. public class SVGPartArgs : EventArgs { - private SvgParts t; - /// Default constructor. - public SVGPartArgs() - { - t = new SvgParts(); - } + /// Default constructor. + public SVGPartArgs() => SVGParts = new SvgParts(); - /// Initializes with a SVGPart. - /// Data object. - public SVGPartArgs(SvgPart t) - : this() - { - this.t.Add(t); - } + /// Initializes with a SVGPart. + /// Data object. + public SVGPartArgs(SvgPart t) : this() => this.SVGParts.Add(t); - /// Initializes with a collection of SVGPart objects. - /// Collection of data. - public SVGPartArgs(SvgParts ts) - : this() - { - this.t.AddRange(ts); - } + /// Initializes with a collection of SVGPart objects. + /// Collection of data. + public SVGPartArgs(SvgParts ts) : this() => this.SVGParts.AddRange(ts); - /// Initializes with an array of SVGPart objects. - /// Array of data. - public SVGPartArgs(SvgPart[] ts) - : this() - { - this.t.AddRange(ts); - } + /// Initializes with an array of SVGPart objects. + /// Array of data. + public SVGPartArgs(SvgPart[] ts) : this() => this.SVGParts.AddRange(ts); - /// Gets or sets the data of this argument. - public SvgParts SVGParts - { - get { return t; } - set { t = value; } - } - } + /// Gets or sets the data of this argument. + public SvgParts SVGParts { get; set; } + } /// SVGParts event handler. public delegate void SVGPartHandler(object sender, SVGPartArgs e); @@ -338,43 +301,29 @@ namespace Volian.Svg.Library { private SvgPart Item { get { return (SvgPart)_Item; } } public SvgPartsPropertyDescriptor(SvgParts collection, int index) : base(collection, index) { ;} - public override string DisplayName - { get { return Item.GetType().Name; } } - } + public override string DisplayName => Item.GetType().Name; + } #endregion [Serializable()] public partial class vlnListPropertyDescriptor : PropertyDescriptor { protected object _Item = null; - public vlnListPropertyDescriptor(System.Collections.IList collection, int index) - : base("#" + index.ToString(), null) - { _Item = collection[index]; } - public override bool CanResetValue(object component) - { return true; } - public override Type ComponentType - { get { return _Item.GetType(); } } - public override object GetValue(object component) - { return _Item; } - public override bool IsReadOnly - { get { return false; } } - public override Type PropertyType - { get { return _Item.GetType(); } } - public override void ResetValue(object component) + public vlnListPropertyDescriptor(System.Collections.IList collection, int index) + : base($"#{index}", null) => _Item = collection[index]; + public override bool CanResetValue(object component) => true; + public override Type ComponentType => _Item.GetType(); + public override object GetValue(object component) => _Item; + public override bool IsReadOnly => false; + public override Type PropertyType => _Item.GetType(); + public override void ResetValue(object component) { ;} - public override bool ShouldSerializeValue(object component) - { return true; } - public override void SetValue(object component, object value) - { /*_Item = value*/;} - //public override AttributeCollection Attributes - //{ get { return new AttributeCollection(null); } } - public override string DisplayName - { get { return _Item.ToString(); } } - public override string Description - { get { return _Item.ToString(); } } - public override string Name - { get { return _Item.ToString(); } } + public override bool ShouldSerializeValue(object component) => true; + public override void SetValue(object component, object value) { /*_Item = value*/; } + public override string DisplayName => _Item.ToString(); + public override string Description => _Item.ToString(); + public override string Name => _Item.ToString(); - } // Class + } // Class #region Converter internal class SVGPartsConverter : ExpandableObjectConverter { @@ -383,7 +332,7 @@ namespace Volian.Svg.Library if (destType == typeof(string) && value is SvgParts) { // Return department and department role separated by comma. - return ((SvgParts)value).List.Count.ToString() + " SVG Drawing Parts"; + return $"{((SvgParts)value).List.Count} SVG Drawing Parts"; } return base.ConvertTo(context, culture, value, destType); } diff --git a/PROMS/Volian.Svg.Library/SvgRectangle.cs b/PROMS/Volian.Svg.Library/SvgRectangle.cs index 2e34ed35..56dca848 100644 --- a/PROMS/Volian.Svg.Library/SvgRectangle.cs +++ b/PROMS/Volian.Svg.Library/SvgRectangle.cs @@ -1,6 +1,3 @@ -using System; -using System.Collections.Generic; -using System.Text; using System.Xml.Serialization; using System.ComponentModel; using System.Drawing; @@ -13,88 +10,64 @@ namespace Volian.Svg.Library public SvgRectangle() { ;} public SvgRectangle(PointF location, SizeF size, Color fillColor, Color lineColor, float lineWidth) { - _X.Value = location.X; - _Y.Value = location.Y; - _Width.Value = size.Width; - _Height.Value = size.Height; + X.Value = location.X; + Y.Value = location.Y; + Width.Value = size.Width; + Height.Value = size.Height; FillColor = fillColor; LineColor = lineColor; LineWidth = new SvgMeasurement(lineWidth); } - //XMLElementAttribute(ElementName = "PREFIX", IsNullable = false) - #endregion - #region Description - private string _Description = string.Empty; - [System.ComponentModel.DefaultValueAttribute("")] - [XmlElement("desc")] - public string Description - { - get { return _Description; } - set { _Description = value; } - } - #endregion - #region Location - private SvgMeasurement _X = new SvgMeasurement(); - [XmlIgnore] - public SvgMeasurement X - { - get { return _X; } - set { _X = value; } - } - [XmlAttribute("x")] + #endregion + #region Description + [System.ComponentModel.DefaultValueAttribute("")] + [XmlElement("desc")] + public string Description { get; set; } = string.Empty; + #endregion + #region Location + [XmlIgnore] + public SvgMeasurement X { get; set; } = new SvgMeasurement(); + [XmlAttribute("x")] [Browsable(false)] [EditorBrowsable(EditorBrowsableState.Never)] public string X_XmlSurrogate { - get { return SvgXmlConverter.GetString(_X); } - set { _X = SvgXmlConverter.GetObject(value); } + get { return SvgXmlConverter.GetString(X); } + set { X = SvgXmlConverter.GetObject(value); } } - private SvgMeasurement _Y = new SvgMeasurement(); - [XmlIgnore] - public SvgMeasurement Y - { - get { return _Y; } - set { _Y = value; } - } - [XmlAttribute("y")] + + [XmlIgnore] + public SvgMeasurement Y { get; set; } = new SvgMeasurement(); + [XmlAttribute("y")] [Browsable(false)] [EditorBrowsable(EditorBrowsableState.Never)] public string Y_XmlSurrogate { - get { return SvgXmlConverter.GetString(_Y); } - set { _Y = SvgXmlConverter.GetObject(value); } + get { return SvgXmlConverter.GetString(Y); } + set { Y = SvgXmlConverter.GetObject(value); } } - #endregion - #region Size - private SvgMeasurement _Width = new SvgMeasurement(); - [XmlIgnore] - public SvgMeasurement Width - { - get { return _Width; } - set { _Width = value; } - } - [XmlAttribute("width")] + #endregion + #region Size + [XmlIgnore] + public SvgMeasurement Width { get; set; } = new SvgMeasurement(); + [XmlAttribute("width")] [Browsable(false)] [EditorBrowsable(EditorBrowsableState.Never)] public string Width_WidthmlSurrogate { - get { return SvgXmlConverter.GetString(_Width); } - set { _Width = SvgXmlConverter.GetObject(value); } + get { return SvgXmlConverter.GetString(Width); } + set { Width = SvgXmlConverter.GetObject(value); } } - private SvgMeasurement _Height = new SvgMeasurement(); - [XmlIgnore] - public SvgMeasurement Height - { - get { return _Height; } - set { _Height = value; } - } - [XmlAttribute("height")] + + [XmlIgnore] + public SvgMeasurement Height { get; set; } = new SvgMeasurement(); + [XmlAttribute("height")] [Browsable(false)] [EditorBrowsable(EditorBrowsableState.Never)] public string Height_XmlSurrogate { - get { return SvgXmlConverter.GetString(_Height); } - set { _Height = SvgXmlConverter.GetObject(value); } + get { return SvgXmlConverter.GetString(Height); } + set { Height = SvgXmlConverter.GetObject(value); } } #endregion } diff --git a/PROMS/Volian.Svg.Library/SvgScale.cs b/PROMS/Volian.Svg.Library/SvgScale.cs index 94c523b0..ad8a92c5 100644 --- a/PROMS/Volian.Svg.Library/SvgScale.cs +++ b/PROMS/Volian.Svg.Library/SvgScale.cs @@ -1,48 +1,29 @@ -using System; -using System.Collections.Generic; -using System.Text; using System.Drawing; namespace Volian.Svg.Library { public class SvgScale { - private float _XLowerLimit; - public float XLowerLimit - { - get { return _XLowerLimit; } - set { _XLowerLimit = value; } - } - private float _YLowerLimit; - public float YLowerLimit - { - get { return _YLowerLimit; } - set { _YLowerLimit = value; } - } - private float _Scale; // Scale from Logical to Physical - public float Scale - { get { return _Scale; } } - private float _Width; // Physical Width - public float Width - { get { return _Width; } } - private float _Height; // Physical Height - public float Height - { get { return _Height; } } - public float XUpperLimit - { get { return _Width * _Scale + _XLowerLimit; } } - public float YUpperLimit - { get { return _Height * _Scale + _YLowerLimit; } } - private float _DPI; - public float DPI - { get { return _DPI; } } - private SvgScale(SvgScale tmp,SvgMeasurement newX, SvgMeasurement newY) + public float XLowerLimit { get; set; } + public float YLowerLimit { get; set; } + private float _Scale; // Scale from Logical to Physical + public float Scale => _Scale; + private float _Width; // Physical Width + public float Width => _Width; + private float _Height; // Physical Height + public float Height => _Height; + public float XUpperLimit => _Width * _Scale + XLowerLimit; + public float YUpperLimit => _Height * _Scale + YLowerLimit; + private float _DPI; + public float DPI => _DPI; + private SvgScale(SvgScale tmp,SvgMeasurement newX, SvgMeasurement newY) { _DPI = tmp.DPI; _Scale = tmp.Scale; _Width = tmp.Width; _Height = tmp.Height; - _XLowerLimit = tmp.XLowerLimit - newX.GetSizeInPixels(DPI); - _YLowerLimit = tmp.YLowerLimit - newY.GetSizeInPixels(DPI); + XLowerLimit = tmp.XLowerLimit - newX.GetSizeInPixels(DPI); + YLowerLimit = tmp.YLowerLimit - newY.GetSizeInPixels(DPI); } public SvgScale(float myDPI, RectangleF bounds,SvgMeasurement width, SvgMeasurement height, SvgViewBox myViewBox) { @@ -62,28 +43,16 @@ namespace Volian.Svg.Library //Console.WriteLine("'Scale',{0}",_Scale); _Width = outputWidth / _Scale; _Height = outputHeight / _Scale; - _XLowerLimit = myViewBox.X + (inputWidth - _Width) / 2; - _YLowerLimit = myViewBox.Y + (inputHeight - _Height) / 2; + XLowerLimit = myViewBox.X + (inputWidth - _Width) / 2; + YLowerLimit = myViewBox.Y + (inputHeight - _Height) / 2; //if (myDPI != 96) Console.WriteLine("DPI {0}", myDPI); //Console.WriteLine("Scale,{0},{1},{2},{3},{4},{5},{6}", Scale, Width, Height, XLowerLimit, XUpperLimit, YLowerLimit, YUpperLimit); } - public SvgScale AdjustOrigin(SvgMeasurement newX, SvgMeasurement newY) - { - return new SvgScale(this, newX, newY); - } - public float X(float x) - { - return _Scale * (x - XLowerLimit); - } - public float Y(float y) - { - return _Scale * (y - YLowerLimit); - } - public float AbsX(SvgMeasurement x) - { - return x.GetSizeInPixels(DPI) + Svg.AbsoluteOffset.X; - } - public float AbsY(iTextSharp.text.pdf.PdfContentByte cb, SvgMeasurement y) + public SvgScale AdjustOrigin(SvgMeasurement newX, SvgMeasurement newY) => new SvgScale(this, newX, newY); + public float X(float x) => _Scale * (x - XLowerLimit); + public float Y(float y) => _Scale * (y - YLowerLimit); + public float AbsX(SvgMeasurement x) => x.GetSizeInPixels(DPI) + Svg.AbsoluteOffset.X; + public float AbsY(iTextSharp.text.pdf.PdfContentByte cb, SvgMeasurement y) { // the following line of code is 'taken' from the 16bit code: \promsnt\exe\wined\togdi.cpp // whenever doing an 'Absolute' macro. @@ -91,36 +60,21 @@ namespace Volian.Svg.Library yOffset = yOffset / 20; // convert from twips to points (point = 1/72 inch) return cb.PdfDocument.PageSize.Height - y.GetSizeInPixels(DPI) + yOffset + Svg.AbsoluteOffset.Y; } - public float Y(iTextSharp.text.pdf.PdfContentByte cb, float y) - { - return cb.PdfDocument.PageSize.Height - _Scale * (y - YLowerLimit); - } - public float M(float m) - { - return _Scale * m; - } - public float X(SvgMeasurement x) + public float Y(iTextSharp.text.pdf.PdfContentByte cb, float y) => cb.PdfDocument.PageSize.Height - _Scale * (y - YLowerLimit); + public float M(float m) => _Scale * m; + public float X(SvgMeasurement x) { float retval = _Scale * (x.GetSizeInPixels(DPI) - XLowerLimit); return retval; } - public float Y(SvgMeasurement y) - { - return _Scale * (y.GetSizeInPixels(DPI) - YLowerLimit); - } - public float Y(iTextSharp.text.pdf.PdfContentByte cb, SvgMeasurement y) + public float Y(SvgMeasurement y) => _Scale * (y.GetSizeInPixels(DPI) - YLowerLimit); + public float Y(iTextSharp.text.pdf.PdfContentByte cb, SvgMeasurement y) { float yOffset = 0; // = (cb.PdfWriter.CurrentPageNumber -1) * .8F * cb.PdfDocument.PageSize.Height; float myY = yOffset + cb.PdfDocument.PageSize.Height - _Scale * (y.GetSizeInPixels(DPI) - YLowerLimit); return myY; } - public float YY(SvgMeasurement y) - { - return -_Scale * y.GetSizeInPixels(DPI); - } - public float M(SvgMeasurement m) - { - return _Scale * m.GetSizeInPixels(DPI); - } - } + public float YY(SvgMeasurement y) => -_Scale * y.GetSizeInPixels(DPI); + public float M(SvgMeasurement m) => _Scale * m.GetSizeInPixels(DPI); + } } diff --git a/PROMS/Volian.Svg.Library/SvgSerializer.cs b/PROMS/Volian.Svg.Library/SvgSerializer.cs index c04a7754..13b4d915 100644 --- a/PROMS/Volian.Svg.Library/SvgSerializer.cs +++ b/PROMS/Volian.Svg.Library/SvgSerializer.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; using System.Text; using System.Xml.Serialization; using System.Xml; @@ -60,11 +59,9 @@ namespace Volian.Svg.Library } public class NonXsiTextWriter : XmlTextWriter { - public NonXsiTextWriter( TextWriter w ) : base( w ) {} - public NonXsiTextWriter( Stream w, Encoding encoding ) : base( w, encoding ) { - this.Formatting = Formatting.Indented; - } - public NonXsiTextWriter( string filename, Encoding encoding ) : base( filename, encoding ) {} + public NonXsiTextWriter( TextWriter w ) : base( w ) {} + public NonXsiTextWriter(Stream w, Encoding encoding) : base(w, encoding) => this.Formatting = Formatting.Indented; + public NonXsiTextWriter( string filename, Encoding encoding ) : base( filename, encoding ) {} bool _skip = false; public override void WriteStartAttribute( string prefix, string localName, string ns ) { diff --git a/PROMS/Volian.Svg.Library/SvgShapePart.cs b/PROMS/Volian.Svg.Library/SvgShapePart.cs index c1429167..82d47084 100644 --- a/PROMS/Volian.Svg.Library/SvgShapePart.cs +++ b/PROMS/Volian.Svg.Library/SvgShapePart.cs @@ -1,5 +1,3 @@ -using System; -using System.IO; using System.Xml.Serialization; using System.Drawing; using System.ComponentModel; diff --git a/PROMS/Volian.Svg.Library/SvgTest.cs b/PROMS/Volian.Svg.Library/SvgTest.cs index a0eaaab2..4017e45a 100644 --- a/PROMS/Volian.Svg.Library/SvgTest.cs +++ b/PROMS/Volian.Svg.Library/SvgTest.cs @@ -1,6 +1,3 @@ -using System; -using System.Collections.Generic; -using System.Text; using System.Xml.Serialization; using System.Drawing; diff --git a/PROMS/Volian.Svg.Library/SvgText.cs b/PROMS/Volian.Svg.Library/SvgText.cs index 41988c87..1f07473b 100644 --- a/PROMS/Volian.Svg.Library/SvgText.cs +++ b/PROMS/Volian.Svg.Library/SvgText.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; using System.Drawing; -using System.Drawing.Drawing2D; using System.Xml.Serialization; using System.ComponentModel; @@ -14,52 +10,38 @@ namespace Volian.Svg.Library public SvgText() { ;} public SvgText(PointF location, string text, Font font, Color fillColor) { - _X.Value = location.X; - _Y.Value = location.Y; + X.Value = location.X; + Y.Value = location.Y; Text = text; Font = font; FillColor = fillColor; LineColor = Color.Empty; LineWidth = new SvgMeasurement(0); } - #endregion - #region Location - private SvgJustify _Justify = SvgJustify.Left; - [XmlAttribute("Justify")] - public SvgJustify Justify - { - get { return _Justify; } - set { _Justify = value; } - } - private SvgMeasurement _X = new SvgMeasurement(); - [XmlIgnore] - public SvgMeasurement X - { - get { return _X; } - set { _X = value; } - } - [XmlAttribute("x")] + #endregion + #region Location + [XmlAttribute("Justify")] + public SvgJustify Justify { get; set; } = SvgJustify.Left; + [XmlIgnore] + public SvgMeasurement X { get; set; } = new SvgMeasurement(); + [XmlAttribute("x")] [Browsable(false)] [EditorBrowsable(EditorBrowsableState.Never)] public string X_XmlSurrogate { - get { return SvgXmlConverter.GetString(_X); } - set { _X = SvgXmlConverter.GetObject(value); } + get { return SvgXmlConverter.GetString(X); } + set { X = SvgXmlConverter.GetObject(value); } } - private SvgMeasurement _Y = new SvgMeasurement(); - [XmlIgnore] - public SvgMeasurement Y - { - get { return _Y; } - set { _Y = value; } - } - [XmlAttribute("y")] + + [XmlIgnore] + public SvgMeasurement Y { get; set; } = new SvgMeasurement(); + [XmlAttribute("y")] [Browsable(false)] [EditorBrowsable(EditorBrowsableState.Never)] public string Y_XmlSurrogate { - get { return SvgXmlConverter.GetString(_Y); } - set { _Y = SvgXmlConverter.GetObject(value); } + get { return SvgXmlConverter.GetString(Y); } + set { Y = SvgXmlConverter.GetObject(value); } } #endregion #region Text @@ -124,19 +106,14 @@ namespace Volian.Svg.Library get { return _MyFontSettings.TextDecoration; } set { _MyFontSettings.TextDecoration = value; } } - #endregion - #region Description - private string _Description = string.Empty; - [System.ComponentModel.DefaultValueAttribute("")] - [XmlElement("desc")] - public string Description - { - get { return _Description; } - set { _Description = value; } - } - #endregion - #region Setup Inheritance - override internal void SetupInheritance(SvgInheritedSettings myParentsSettings) + #endregion + #region Description + [System.ComponentModel.DefaultValueAttribute("")] + [XmlElement("desc")] + public string Description { get; set; } = string.Empty; + #endregion + #region Setup Inheritance + override internal void SetupInheritance(SvgInheritedSettings myParentsSettings) { base.SetupInheritance(myParentsSettings); _MyFontSettings.MyParentsSettings = myParentsSettings.MyFontSettings; diff --git a/PROMS/Volian.Svg.Library/SvgUse.cs b/PROMS/Volian.Svg.Library/SvgUse.cs index 26054bef..0425cb1b 100644 --- a/PROMS/Volian.Svg.Library/SvgUse.cs +++ b/PROMS/Volian.Svg.Library/SvgUse.cs @@ -1,6 +1,3 @@ -using System; -using System.Collections.Generic; -using System.Text; using System.Xml.Serialization; using System.ComponentModel; using System.Drawing; @@ -13,95 +10,66 @@ namespace Volian.Svg.Library public SvgUse() { ;} public SvgUse(PointF location, SizeF size, string id) { - _X.Value = location.X; - _Y.Value = location.Y; - _Width.Value = size.Width; - _Height.Value = size.Height; + X.Value = location.X; + Y.Value = location.Y; + Width.Value = size.Width; + Height.Value = size.Height; _ID = id; } - #endregion - #region Location - private SvgMeasurement _X = new SvgMeasurement(); - [XmlIgnore] - public SvgMeasurement X - { - get { return _X; } - set { _X = value; } - } - [XmlAttribute("x")] + #endregion + #region Location + [XmlIgnore] + public SvgMeasurement X { get; set; } = new SvgMeasurement(); + [XmlAttribute("x")] [Browsable(false)] [EditorBrowsable(EditorBrowsableState.Never)] public string X_XmlSurrogate { - get { return SvgXmlConverter.GetString(_X); } - set { _X = SvgXmlConverter.GetObject(value); } + get { return SvgXmlConverter.GetString(X); } + set { X = SvgXmlConverter.GetObject(value); } } - private SvgMeasurement _Y = new SvgMeasurement(); - [XmlIgnore] - public SvgMeasurement Y - { - get { return _Y; } - set { _Y = value; } - } - [XmlAttribute("y")] + + [XmlIgnore] + public SvgMeasurement Y { get; set; } = new SvgMeasurement(); + [XmlAttribute("y")] [Browsable(false)] [EditorBrowsable(EditorBrowsableState.Never)] public string Y_XmlSurrogate { - get { return SvgXmlConverter.GetString(_Y); } - set { _Y = SvgXmlConverter.GetObject(value); } + get { return SvgXmlConverter.GetString(Y); } + set { Y = SvgXmlConverter.GetObject(value); } } - #endregion - #region Size - private SvgMeasurement _Width = new SvgMeasurement(); - [XmlIgnore] - public SvgMeasurement Width - { - get { return _Width; } - set { _Width = value; } - } - [XmlAttribute("width")] + #endregion + #region Size + [XmlIgnore] + public SvgMeasurement Width { get; set; } = new SvgMeasurement(); + [XmlAttribute("width")] [Browsable(false)] [EditorBrowsable(EditorBrowsableState.Never)] public string Width_WidthmlSurrogate { - get { return SvgXmlConverter.GetString(_Width); } - set { _Width = SvgXmlConverter.GetObject(value); } + get { return SvgXmlConverter.GetString(Width); } + set { Width = SvgXmlConverter.GetObject(value); } } - private SvgMeasurement _Height = new SvgMeasurement(); - [XmlIgnore] - public SvgMeasurement Height - { - get { return _Height; } - set { _Height = value; } - } - [XmlAttribute("height")] + + [XmlIgnore] + public SvgMeasurement Height { get; set; } = new SvgMeasurement(); + [XmlAttribute("height")] [Browsable(false)] [EditorBrowsable(EditorBrowsableState.Never)] public string Height_XmlSurrogate { - get { return SvgXmlConverter.GetString(_Height); } - set { _Height = SvgXmlConverter.GetObject(value); } + get { return SvgXmlConverter.GetString(Height); } + set { Height = SvgXmlConverter.GetObject(value); } } - #endregion - #region ID to be used - private string _UseID = null; - [XmlAttribute(AttributeName = "href", Namespace = "http://www.w3.org/1999/xlink")] - public string UseID - { - get { return _UseID; } - set { _UseID = value; } - } - #endregion - #region Setup Inheritance - override internal void SetupInheritance(SvgInheritedSettings myParentsSettings) - { - _MyInheritedSettings.MyParentsSettings = myParentsSettings; - } - #endregion - public override string ToString() - { - return string.Format("({0}, {1}) Template '{2}'", this.X, this.Y, this.UseID); - } - } + #endregion + #region ID to be used + [XmlAttribute(AttributeName = "href", Namespace = "http://www.w3.org/1999/xlink")] + public string UseID { get; set; } = null; + #endregion + #region Setup Inheritance + override internal void SetupInheritance(SvgInheritedSettings myParentsSettings) => _MyInheritedSettings.MyParentsSettings = myParentsSettings; + #endregion + public override string ToString() => string.Format("({0}, {1}) Template '{2}'", this.X, this.Y, this.UseID); + } } diff --git a/PROMS/Volian.Svg.Library/SvgViewBox.cs b/PROMS/Volian.Svg.Library/SvgViewBox.cs index 1098d550..7dedc2f3 100644 --- a/PROMS/Volian.Svg.Library/SvgViewBox.cs +++ b/PROMS/Volian.Svg.Library/SvgViewBox.cs @@ -1,8 +1,6 @@ - using System; - using System.Collections.Generic; - using System.Text; - using System.Drawing; - using System.ComponentModel; +using System; +using System.Drawing; +using System.ComponentModel; namespace Volian.Svg.Library { @@ -11,11 +9,8 @@ namespace Volian.Svg.Library { #region ctor public SvgViewBox() { ;} - public SvgViewBox(float x, float y, float width, float height) - { - _MyRectangleF = new RectangleF(x, y, width, height); - } - public SvgViewBox(string val) + public SvgViewBox(float x, float y, float width, float height) => _MyRectangleF = new RectangleF(x, y, width, height); + public SvgViewBox(string val) { string[] parms = ((string)val).Split(' '); _MyRectangleF = new RectangleF(Convert.ToSingle(parms[0]), Convert.ToSingle(parms[1]), Convert.ToSingle(parms[2]), Convert.ToSingle(parms[3])); @@ -43,33 +38,17 @@ namespace Volian.Svg.Library get { return _MyRectangleF.Height; } set { _MyRectangleF.Height = value; } } - #endregion - #region ToString - public override string ToString() - { - return string.Format("{0} {1} {2} {3}", X, Y, Width, Height); - } - #endregion - } + #endregion + #region ToString + public override string ToString() => string.Format("{0} {1} {2} {3}", X, Y, Width, Height); + #endregion + } public class ViewBoxTypeConverter : ExpandableObjectConverter { - public override bool CanConvertTo(ITypeDescriptorContext context, Type t) - { - return t == typeof(String); - } - public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType) - { - if (destType == typeof(string) && value is SvgViewBox) - { - return value.ToString(); - } - return base.ConvertTo(context, culture, value, destType); - } - public override bool CanConvertFrom(ITypeDescriptorContext context, Type t) - { - return t == typeof(String); - } - public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object val) + public override bool CanConvertTo(ITypeDescriptorContext context, Type t) => t == typeof(string); + public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType) => destType == typeof(string) && value is SvgViewBox ? value.ToString() : base.ConvertTo(context, culture, value, destType); + public override bool CanConvertFrom(ITypeDescriptorContext context, Type t) => t == typeof(string); + public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object val) { string[] parms = ((string)val).Split(' '); SvgViewBox viewBox = new SvgViewBox(Convert.ToSingle(parms[0]), Convert.ToSingle(parms[1]), Convert.ToSingle(parms[2]), Convert.ToSingle(parms[3])); diff --git a/PROMS/Volian.Svg.Library/SvgXMLConverter.cs b/PROMS/Volian.Svg.Library/SvgXMLConverter.cs index 815e7d9d..4db5c565 100644 --- a/PROMS/Volian.Svg.Library/SvgXMLConverter.cs +++ b/PROMS/Volian.Svg.Library/SvgXMLConverter.cs @@ -1,6 +1,3 @@ -using System; -using System.Collections.Generic; -using System.Text; using System.ComponentModel; namespace Volian.Svg.Library @@ -13,10 +10,6 @@ namespace Volian.Svg.Library TypeConverter FontConverter = TypeDescriptor.GetConverter(typeof(T)); return FontConverter.ConvertToInvariantString(myObject); } - public static T GetObject(string value) - { - TypeConverter converter = TypeDescriptor.GetConverter(typeof(T)); - return (T)converter.ConvertFromInvariantString(value); - } - } + public static T GetObject(string value) => (T)TypeDescriptor.GetConverter(typeof(T)).ConvertFromInvariantString(value); + } } diff --git a/PROMS/Volian.Svg.Library/Volian.Svg.Library.csproj b/PROMS/Volian.Svg.Library/Volian.Svg.Library.csproj index 9beda668..afe8ba6c 100644 --- a/PROMS/Volian.Svg.Library/Volian.Svg.Library.csproj +++ b/PROMS/Volian.Svg.Library/Volian.Svg.Library.csproj @@ -89,7 +89,6 @@ - diff --git a/PROMS/Volian.Svg.Library/iTextSharp.cs b/PROMS/Volian.Svg.Library/iTextSharp.cs index 0be29927..4a0771a9 100644 --- a/PROMS/Volian.Svg.Library/iTextSharp.cs +++ b/PROMS/Volian.Svg.Library/iTextSharp.cs @@ -1,18 +1,10 @@ using System; using System.Collections; -using System.Text; using System.Collections.Generic; using System.Xml.Serialization; using iTextSharp.text; using iTextSharp.text.pdf; -using iTextSharp.text.factories; -using Itenso.Rtf; -using Itenso.Rtf.Parser; -using Itenso.Rtf.Interpreter; -using Itenso.Rtf.Support; -using Microsoft.Win32; using System.Text.RegularExpressions; -using System.Xml; using System.IO; using Volian.Base.Library; @@ -97,23 +89,14 @@ namespace Volian.Svg.Library { get { return _MyText; } } - private SvgText _MySvgText; - public SvgText MySvgText - { - get { return _MySvgText; } - set { _MySvgText = value; } - } - private SvgScale _MySvgScale; - public SvgScale MySvgScale - { - get { return _MySvgScale; } - set { _MySvgScale = value; } - } - public SvgProcessTextArgs(string myText, SvgText mySvgText, SvgScale mySvgScale) + + public SvgText MySvgText { get; set; } + public SvgScale MySvgScale { get; set; } + public SvgProcessTextArgs(string myText, SvgText mySvgText, SvgScale mySvgScale) { _MyText = myText; - _MySvgText = mySvgText; - _MySvgScale = mySvgScale; + MySvgText = mySvgText; + MySvgScale = mySvgScale; } } public partial class Svg : SvgGroup @@ -121,7 +104,7 @@ namespace Volian.Svg.Library private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); public void DrawMacro(string macroDef, float x, float y, PdfContentByte cb) { - _MyContentByte = cb; + MyContentByte = cb; SvgMeasurement X = new SvgMeasurement(x, E_MeasurementUnits.PT); SvgMeasurement Y = new SvgMeasurement(Height.GetSizeInPoints(72) - y, E_MeasurementUnits.PT); if (!this.LookUp.ContainsKey(macroDef)) return; // AEP - DU1 (missing C22 macro for AEP) @@ -157,45 +140,31 @@ namespace Volian.Svg.Library top = (yll > yul ? (yll > top ? yll : top) : (yul > top ? yul : top)); tmp.BoundingBox = new iTextSharp.text.Rectangle(xll, yll, xul, yul); } - private PdfContentByte _MyContentByte; - [XmlIgnore] - public PdfContentByte MyContentByte - { - get { return _MyContentByte; } - set { _MyContentByte = value; } - } - private float _LeftMargin = 0; - public float LeftMargin - { - get { return _LeftMargin; } - set { _LeftMargin = value; } - } - private float _TopMargin = 0; - public float TopMargin - { - get { return _TopMargin; } - set { _TopMargin = value; } - } - private SvgScale _MyScale; + + [XmlIgnore] + public PdfContentByte MyContentByte { get; set; } + + public float LeftMargin { get; set; } = 0; + + public float TopMargin { get; set; } = 0; + private SvgScale _MyScale; public SvgScale MyScale { get { if (_MyScale == null) { - _MyScale = new SvgScale(72, new System.Drawing.RectangleF(0, 0, _MyContentByte.PdfWriter.PageSize.Width, _MyContentByte.PdfWriter.PageSize.Height), _Width, _Height, _ViewBox); - _MyScale.XLowerLimit -= _LeftMargin; - _MyScale.YLowerLimit -= _TopMargin; + _MyScale = new SvgScale(72, new System.Drawing.RectangleF(0, 0, MyContentByte.PdfWriter.PageSize.Width, MyContentByte.PdfWriter.PageSize.Height), Width, Height, ViewBox); + _MyScale.XLowerLimit -= LeftMargin; + _MyScale.YLowerLimit -= TopMargin; } return _MyScale; } } public void Draw(PdfContentByte cb) { - //myPdf.Clear(); - _MyContentByte = cb; + MyContentByte = cb; _Templates = new Dictionary(); - //RegisterFonts(); SvgParts.Draw(cb, MyScale, this, this); //72 - Points } public static iTextSharp.text.Font GetFont(string fontName) @@ -214,36 +183,6 @@ namespace Volian.Svg.Library VlnItextFont.RegisterFont(fontName); return FontFactory.GetFont(fontName, BaseFont.IDENTITY_H, BaseFont.EMBEDDED, size, style, new iTextSharp.text.Color(color)); } - //private static string _FontFolder = null; - //public static string FontFolder - //{ - // get - // { - // if (_FontFolder == null) - // { - // _FontFolder = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Fonts); - // if (_FontFolder == null) _FontFolder = (String)Registry.CurrentUser.OpenSubKey("Software").OpenSubKey("Microsoft").OpenSubKey("Windows").OpenSubKey("CurrentVersion").OpenSubKey("Explorer").OpenSubKey("Shell Folders").GetValue("Fontz"); - // _MyLog.WarnFormat("FontFolder set to {0}", _FontFolder); - // } - // return _FontFolder; - // } - //} - private static int _StackTraceSkip = 1; - private static DateTime _LastTime = DateTime.Now; - private static DateTime _StartTime = DateTime.Now; - public static void ResetWhen() - { - _StartTime = _LastTime = DateTime.Now; - } - public static void WhenAndWhere() - { - DateTime thisTime = DateTime.Now; - System.Diagnostics.StackFrame sf = new System.Diagnostics.StackFrame(_StackTraceSkip, true); - Console.WriteLine("{0:000000},{1:000000},'{2}',{3},'{4}'", TimeSpan.FromTicks(thisTime.Ticks - _StartTime.Ticks).TotalMilliseconds, - TimeSpan.FromTicks(thisTime.Ticks - _LastTime.Ticks).TotalMilliseconds, sf.GetMethod().Name, sf.GetFileLineNumber() - ,sf.GetFileName()); - _LastTime = thisTime; - } } public partial class SvgArc : SvgShapePart { @@ -326,18 +265,13 @@ namespace Volian.Svg.Library { // TODO: Could I try creating a template // Don't draw - // SvgParts.Draw(cb, myScale, mySvg, myParent); PdfTemplate tmp = null; if (ID != "") tmp = mySvg.GetTemplate(ID, cb); // the size will be adjusted as items are added. SvgParts.Draw(tmp, myScale, mySvg, myParent); } public override void Draw(PdfTemplate tmp, SvgScale myScale, Svg mySvg, SvgPartInheritance myParent) { - // TODO: Could I try creating a template // Don't draw - // SvgParts.Draw(cb, myScale, mySvg, myParent); - //PdfTemplate tmp2 = mySvg.GetTemplate(ID); // the size will be adjusted as items are added. - //SvgParts.Draw(tmp2, myScale, mySvg, myParent); } } public partial class SvgUse : SvgPartInheritance @@ -348,24 +282,22 @@ namespace Volian.Svg.Library { // TODO: Could I use the template SetupInheritance(myParent.MyInheritedSettings); - if (mySvg.LookUp.ContainsKey(_UseID)) - mySvg[_UseID].Draw(cb, scale.AdjustOrigin(X, Y), mySvg, this); + if (mySvg.LookUp.ContainsKey(UseID)) + mySvg[UseID].Draw(cb, scale.AdjustOrigin(X, Y), mySvg, this); else { - if (!_MissingMacros.Contains(_UseID)) + if (!_MissingMacros.Contains(UseID)) { - _MissingMacros.Add(_UseID); - _MyLog.WarnFormat("Missing Macro '{0}'", _UseID); + _MissingMacros.Add(UseID); + _MyLog.WarnFormat("Missing Macro '{0}'", UseID); } } - //cb.AddTemplate(mySvg.GetTemplate(_UseID.Substring(1),cb), scale.X(X), scale.Y(cb, Y)); } public override void Draw(PdfTemplate tmp, SvgScale scale, Svg mySvg, SvgPartInheritance myParent) { // TODO: Could I use the template SetupInheritance(myParent.MyInheritedSettings); - //mySvg[_UseID.Substring(1)].Draw(tmp, scale.AdjustOrigin(X, Y), mySvg, this); - mySvg[_UseID].Draw(tmp, scale.AdjustOrigin(X, Y), mySvg, this); + mySvg[UseID].Draw(tmp, scale.AdjustOrigin(X, Y), mySvg, this); } } public partial class SvgEllipse : SvgShapePart @@ -410,7 +342,7 @@ namespace Volian.Svg.Library public override void Draw(PdfContentByte cb, SvgScale myScale, Svg mySvg, SvgPartInheritance myParent) { SetupInheritance(myParent.MyInheritedSettings); - _SvgParts.Draw(cb, myScale, mySvg, this); + SvgParts.Draw(cb, myScale, mySvg, this); } public override void Draw(PdfTemplate tmp, SvgScale myScale, Svg mySvg, SvgPartInheritance myParent) { @@ -443,7 +375,8 @@ namespace Volian.Svg.Library { SetupInheritance(myParent.MyInheritedSettings); tmp.SaveState(); - try +#pragma warning disable CS0168 // Variable is declared but never used - ex kept for debugging + try { if (ImagePath != null) { @@ -457,7 +390,8 @@ namespace Volian.Svg.Library { //_MyLog.WarnFormat("SvgImage.Draw '{0}' {1} - {2}", ImagePath, ex.GetType().Name, ex.Message); } - tmp.RestoreState(); +#pragma warning restore CS0168 // Variable is declared but never used + tmp.RestoreState(); } } public partial class SvgLine : SvgLinePart @@ -581,28 +515,19 @@ namespace Volian.Svg.Library { case SvgJustify.Left: return Element.ALIGN_LEFT; - break; case SvgJustify.Center: return Element.ALIGN_CENTER; - break; case SvgJustify.Right: return Element.ALIGN_RIGHT; - break; } return Element.ALIGN_LEFT; } } public class VlnSplitCharacter : ISplitCharacter { - public bool IsSplitCharacter(int start, int current, int end, char[] cc, PdfChunk[] ck) - { - return (cc[current] == ' '); - } - public bool IsSplitCharacter(char c) - { - return (c == ' '); - } - } + public bool IsSplitCharacter(int start, int current, int end, char[] cc, PdfChunk[] ck) => (cc[current] == ' '); + public bool IsSplitCharacter(char c) => (c == ' '); + } public static VlnSplitCharacter mySplitter = new VlnSplitCharacter(); // Draw's using PdfContentByte are for drawing PageList items. public override void Draw(PdfContentByte cb, SvgScale scale, Svg mySvg, SvgPartInheritance myParent) @@ -654,9 +579,6 @@ namespace Volian.Svg.Library } switch (Justify) { - //case SvgJustify.Left: - // x = x; - // break; case SvgJustify.Center: x-=w/2; break; @@ -687,12 +609,6 @@ namespace Volian.Svg.Library public static bool CompressPropSubSup = false; private Phrase BuildPhrase(string text, float fontSize, int fontStyle, iTextSharp.text.Font font) { - //if (text == "Caution") - //{ - // if (iTextSharp.text.FontFactory.IsRegistered("VolianScript")) - // Console.WriteLine("Is Registered"); - // Console.WriteLine("stop"); - //} bool fontUnderline = false; float fontTextRise = 0; @@ -700,8 +616,6 @@ namespace Volian.Svg.Library text = Regex.Replace(text, @"\\'[0-9a-fA-F][0-9a-fA-F]", new MatchEvaluator(ReplaceHexCharacter)); text += " "; - //if (text.Contains("\\")) -- these 2 lines made \ul and \ulnone in page list text not get resolved and would then print - //text = text.Replace("\\", ((char)9586).ToString()); // B2016-155 convert backslash char to the unicode symbol - to allow processing rtf commands \ul, \up, \dn, etc. // B2016-167: handle backslashes but don't do if the backslash is an underline rtf command int stindx = text.IndexOf("\\"); while (stindx != -1) @@ -892,170 +806,38 @@ namespace Volian.Svg.Library tmp.RestoreState(); } } - public class SvgPageTotal - { - public SvgPageTotal(System.Drawing.Font myFont, PdfContentByte cb) - { - _MyFont = myFont; - _MyTemplate = cb.CreateTemplate(100, 100); - _MyTemplate.BoundingBox= new Rectangle(-20, -20, 100, 100); - } - private int _PageCount=1; - private System.Drawing.Font _MyFont; - private PdfTemplate _MyTemplate; - public PdfTemplate MyTemplate - { - get { return _MyTemplate; } - } - public void Draw() - { - // Output Page Count - _MyTemplate.BeginText(); - iTextSharp.text.Font font = Svg.GetFont(_MyFont.Name); - BaseFont baseFont = font.BaseFont; - _MyTemplate.SetFontAndSize(baseFont,_MyFont.Size); - _MyTemplate.SetTextMatrix(0, 0); - _MyTemplate.ShowText(_PageCount.ToString()); - _MyTemplate.EndText(); - } - } public class SvgPageHelper : PdfPageEventHelper { - private bool _SpecialCAS; // B2023-005: CAS page, rotate watermark - public bool SpecialCAS + public bool SpecialCAS { get; set; } + public bool IsLandscape { get; set; } + public bool IsWatermarkLandscape { get; set; } + public Svg MySvg { get; set; } + public PdfLayer PageListLayer { get; set; } + public PdfLayer WatermarkLayer { get; set; } + public string Watermark { get; set; } = string.Empty; + public string WatermarkColor { get; set; } = "BLUE"; + public PdfLayer PROMSVersionLayer { get; set; } + public string PROMSVersion { get; set; } = string.Empty; + public bool DoZoomOMatic { get; set; } = false; + public int CurrentPageNumber { get; set; } = 0; + public int CurrentPageNumberNoFoldouts { get; set; } = 0; + public int CurrentTOCPageNumber { get; set; } = 0; + public bool OnFoldoutPage { get; set; } = false; + public bool CreatingFoldoutPage { get; set; } = false; + public bool CreatingSupInfoPage { get; set; } = false; + public SvgPageHelper(Svg mySvg) { - get { return _SpecialCAS; } - set { _SpecialCAS = value; } - } - private bool _IsLandscape; - public bool IsLandscape - { - get { return _IsLandscape; } - set { _IsLandscape = value; } - } - // B2019-145: added the following property so that the code would know that an adjustment should be made to print the watermark - // in landscape mode. Note that 'IsLandscape' could not be used because it also does the pagelist items. - private bool _IsWatermarkLandscape; - public bool IsWatermarkLandscape - { - get { return _IsWatermarkLandscape; } - set { _IsWatermarkLandscape = value; } - } - // B2018-124 we no longer need is list was not hanling "Information Only" water mark - //private List _AllowedWatermarks = new List(); - //public List AllowedWatermarks - //{ - // get { return _AllowedWatermarks; } - // set { _AllowedWatermarks = value; } - //} - private Svg _MySvg; - public Svg MySvg - { - get { return _MySvg; } - set { _MySvg = value; } - } - private PdfLayer _PageListLayer; - public PdfLayer PageListLayer - { - get { return _PageListLayer; } - set { _PageListLayer = value; } - } - private PdfLayer _WatermarkLayer; - public PdfLayer WatermarkLayer - { - get { return _WatermarkLayer; } - set { _WatermarkLayer = value; } - } - private string _Watermark=string.Empty; - public string Watermark - { - get { return _Watermark; } - set { _Watermark = value; } - } - private string _WatermarkColor = "BLUE"; - public string WatermarkColor - { - get { return _WatermarkColor; } - set { _WatermarkColor = value; } - } - private PdfLayer _PROMSVersionLayer; //C2018-009 print PROMS version - public PdfLayer PROMSVersionLayer - { - get { return _PROMSVersionLayer; } - set { _PROMSVersionLayer = value; } - } - private string _PROMSVersion = string.Empty; - public string PROMSVersion - { - get { return _PROMSVersion; } - set { _PROMSVersion = value; } - } - private bool _DoZoomOMatic = false; - public bool DoZoomOMatic - { - get { return _DoZoomOMatic; } - set { _DoZoomOMatic = value; } - } - private int _CurrentPageNumber = 0; - public int CurrentPageNumber - { - get { return _CurrentPageNumber; } - set { _CurrentPageNumber = value; } - } - private int _CurrentPageNumberNoFoldouts = 0; - public int CurrentPageNumberNoFoldouts - { - get { return _CurrentPageNumberNoFoldouts; } - set { _CurrentPageNumberNoFoldouts = value; } - } - private int _CurrentTOCPageNumber = 0; - public int CurrentTOCPageNumber - { - get { return _CurrentTOCPageNumber; } - set { _CurrentTOCPageNumber = value; } - } - private bool _OnFoldoutPage = false; - public bool OnFoldoutPage - { - get { return _OnFoldoutPage; } - set { _OnFoldoutPage = value; } - } - private bool _CreatingFoldoutPage = false; - public bool CreatingFoldoutPage - { - get { return _CreatingFoldoutPage; } - set { _CreatingFoldoutPage = value; } - } - private bool _CreatingSupInfoPage = false; - public bool CreatingSupInfoPage - { - get { return _CreatingSupInfoPage; } - set { _CreatingSupInfoPage = value; } - } - public SvgPageHelper(Svg mySvg) - { - _MySvg = mySvg; + MySvg = mySvg; } public SvgPageHelper() { } - private int _BGPageOffset = 0; - public int BackgroundPageOffset - { - get { return _BGPageOffset; } - set { _BGPageOffset = value; } - } - protected virtual string ReplacePageListToken(Match match) - { - return string.Empty; - } - public override void OnOpenDocument(PdfWriter writer, Document document) + public int BackgroundPageOffset { get; set; } = 0; + protected virtual string ReplacePageListToken(Match match) => string.Empty; + + public override void OnOpenDocument(PdfWriter writer, Document document) { - //base.OnOpenDocument(writer, document); - //tmpTotal = writer.DirectContent.CreateTemplate(100, 100); - //tmpTotal.BoundingBox = new Rectangle(-20, -20, 100, 100); - //PdfContentByte cb = writer.DirectContent; } public override void OnEndPage(PdfWriter writer, Document document) { @@ -1093,8 +875,8 @@ namespace Volian.Svg.Library { get { - if (_BackgroundReader == null && _BackgroundFile != null && File.Exists(_BackgroundFile)) - _BackgroundReader = new PdfReader(_BackgroundFile); + if (_BackgroundReader == null && BackgroundFile != null && File.Exists(BackgroundFile)) + _BackgroundReader = new PdfReader(BackgroundFile); return _BackgroundReader; } } @@ -1106,29 +888,17 @@ namespace Volian.Svg.Library return BackgroundReader.Info["Producer"].ToString().StartsWith("iTextSharp"); } } - private string _BackgroundFile = null; - public string BackgroundFile - { - get { return _BackgroundFile; } - set { _BackgroundFile = value; } - } - private PdfLayer _BackgroundLayer = null; - public PdfLayer BackgroundLayer - { - get { return _BackgroundLayer; } - set { _BackgroundLayer = value; } - } - private System.Drawing.PointF _BackgroundOffset = new System.Drawing.PointF(0, 0); + + public string BackgroundFile { get; set; } = null; + public PdfLayer BackgroundLayer { get; set; } = null; + private System.Drawing.PointF _BackgroundOffset = new System.Drawing.PointF(0, 0); public System.Drawing.PointF BackgroundOffset { get { return _BackgroundOffset; } set { _BackgroundOffset = value; } } - public int BackgroundPageCount - { - get { return BackgroundReader == null ? 0 : BackgroundReader.NumberOfPages; } - } - private PdfImportedPage GetBackgroundPage(PdfContentByte cb) + public int BackgroundPageCount => BackgroundReader == null ? 0 : BackgroundReader.NumberOfPages; + private PdfImportedPage GetBackgroundPage(PdfContentByte cb) { if (BackgroundReader == null) return null; int page = cb.PdfWriter.CurrentPageNumber + BackgroundPageOffset; @@ -1151,14 +921,10 @@ namespace Volian.Svg.Library ZoomOMatic(cb, 36); cb.RestoreState(); } - private bool _AllowAllWatermarks = false; - public bool AllowAllWatermarks - { - get { return _AllowAllWatermarks; } - set { _AllowAllWatermarks = value; } - } - //C2022-004 This will return the system drawing color from either the color name or ARGB values - public System.Drawing.Color GetWatermarkColor(string colorDescription) + + public bool AllowAllWatermarks { get; set; } = false; + //C2022-004 This will return the system drawing color from either the color name or ARGB values + public System.Drawing.Color GetWatermarkColor(string colorDescription) { System.Drawing.Color systemColor; if (colorDescription.StartsWith("[A=")) // if color is ARGB representation, parse out the values @@ -1192,9 +958,8 @@ namespace Volian.Svg.Library private void DrawWatermark(PdfContentByte cb) { if (Watermark == null || Watermark.ToLower().Contains("none") || Watermark == "") return; - //if (!AllowAllWatermarks && !AllowedWatermarks.Contains(Watermark)) return; -- B2018-124 not needed anymore with above if statement - this does not hanle "Information Only" cb.SaveState(); - if (_WatermarkLayer != null) cb.BeginLayer(_WatermarkLayer); + if (WatermarkLayer != null) cb.BeginLayer(WatermarkLayer); // B2023-005: Beaver Valley, second page of CAS page is a 'foldout' on large paper - need to rotate the // watermark if (SpecialCAS) @@ -1207,16 +972,13 @@ namespace Volian.Svg.Library else if (IsLandscape || IsWatermarkLandscape) // B2019-145: Added for printing landscape watermark on step section pages. { // The watermark needs to be rotated back for landscape pagelist - B2016-191 - //double a = -33 * (Math.PI / 180); - //System.Drawing.Drawing2D.Matrix myMatrix = new System.Drawing.Drawing2D.Matrix((float)Math.Cos(a), (float)Math.Sin(a), (float)-Math.Sin(a), (float)Math.Cos(a), -60, 320); double a = -90 * (Math.PI / 180); System.Drawing.Drawing2D.Matrix myMatrix = new System.Drawing.Drawing2D.Matrix((float)Math.Cos(a), (float)Math.Sin(a), (float)-Math.Sin(a), (float)Math.Cos(a), 0, cb.PdfDocument.PageSize.Height); cb.Transform(myMatrix); } SvgWatermark myWatermark = new SvgWatermark(cb, Watermark, GetWatermarkColor(WatermarkColor), .15F); - //myWatermark.SetSquareDotPattern(.7F); myWatermark.Draw(); - if (_WatermarkLayer != null) cb.EndLayer(); + if (WatermarkLayer != null) cb.EndLayer(); cb.RestoreState(); } //C2018-009 print PROMS version @@ -1226,32 +988,22 @@ namespace Volian.Svg.Library string text = PROMSVersion; float textBase =cb.PdfDocument.Top + 19; float textLeft = cb.PdfDocument.Right - 15; - if (_PROMSVersionLayer != null) cb.BeginLayer(_PROMSVersionLayer); + if (PROMSVersionLayer != null) cb.BeginLayer(PROMSVersionLayer); cb.BeginText(); cb.SetFontAndSize(BaseFont.CreateFont(BaseFont.HELVETICA, BaseFont.WINANSI, BaseFont.EMBEDDED), 6f); cb.SetTextMatrix(textLeft, textBase); cb.SetColorFill(new iTextSharp.text.Color(System.Drawing.Color.Indigo)); cb.ShowText(text); cb.EndText(); - if (_PROMSVersionLayer != null) cb.EndLayer(); + if (PROMSVersionLayer != null) cb.EndLayer(); cb.RestoreState(); } private void DrawPageList(PdfContentByte cb) { - if (_MySvg != null) + if (MySvg != null) { cb.SaveState(); - if (_PageListLayer != null) cb.BeginLayer(_PageListLayer); - // Do anything needed to finish off the page - //System.Drawing.Drawing2D.Matrix myMatrix = new System.Drawing.Drawing2D.Matrix(); - //myMatrix.Rotate(90); // Rotate the Pagelist items by 90 Degrees. - //// Translate by the Height of the page. - //myMatrix.Translate(cb.PdfDocument.PageSize.Height, 0, System.Drawing.Drawing2D.MatrixOrder.Append); - //// This was for fun - //// myMatrix.Scale(.75F, .75F, System.Drawing.Drawing2D.MatrixOrder.Append); - //cb.Transform(myMatrix); - //// You can look at the value of the Matrix at this point, to create the matrix directly like I did below - //OR + if (PageListLayer != null) cb.BeginLayer(PageListLayer); // Rotate 90 Degrees and Translate by the Height of the Page if (IsLandscape) @@ -1259,8 +1011,8 @@ namespace Volian.Svg.Library System.Drawing.Drawing2D.Matrix myMatrix = new System.Drawing.Drawing2D.Matrix(0, 1, -1, 0, cb.PdfDocument.PageSize.Height, 0); cb.Transform(myMatrix); } - _MySvg.Draw(cb); - if (_PageListLayer != null) cb.EndLayer(); + MySvg.Draw(cb); + if (PageListLayer != null) cb.EndLayer(); cb.RestoreState(); } } @@ -1277,7 +1029,7 @@ namespace Volian.Svg.Library } public override void OnStartPage(PdfWriter writer, Document document) { - //base.OnStartPage(writer, document); + } public override void OnCloseDocument(PdfWriter writer, Document document) { @@ -1289,137 +1041,24 @@ namespace Volian.Svg.Library private PdfContentByte _ContentByte; private string _Text; private System.Drawing.Color _Color; - private PdfPatternPainter _PatternPainter; - private BaseFont _Basefont; - private float _Fontsize; - private float _XOffset; - private float _YOffset; - private float _TextAngle; private float _Opacity; public SvgWatermark(PdfContentByte contentByte, string text, System.Drawing.Color color, float opacity) { _ContentByte = contentByte; _Text = text; - //float radius = .5F; - //float space = 3; // B2021-081: Blue was too intense with an alpha of 255 Read was too light with an alpha of 96 if (color != System.Drawing.Color.Red) _Color = System.Drawing.Color.FromArgb(96, color); else _Color = color; // C2021-019: save color for color override _Opacity = opacity; - //SetDotPattern(radius, space); - //SetTextLayout(); } - #region commentedout - //private void SetTextLayout() - //{ - // Rectangle pageSize = _ContentByte.PdfWriter.PageSize; // Get page size - // _Basefont = BaseFont.CreateFont(BaseFont.HELVETICA_BOLD, Encoding.ASCII.EncodingName, BaseFont.EMBEDDED); - // float hgtA = _Basefont.GetAscentPoint(_Text, 12); - // //float hgtD = basefont.GetDescentPoint(text,20); - // float wid = _Basefont.GetWidthPointKerned(_Text, 12); - // //Console.WriteLine("{0} {1} {2}",hgtA,hgtD,wid); - // float rho = wid / hgtA; - // float x2 = (rho * pageSize.Height - pageSize.Width) / (rho * rho - 1); - // float y1 = x2 * rho; - // float y2 = pageSize.Height - y1; - // float x1 = pageSize.Width - x2; - // _XOffset = x2 + x1 / 2; - // _YOffset = y1 / 2; - // _TextAngle = CalcAngle(y1, x1); - // _Fontsize = (float)(10 * Math.Sqrt(x2 * x2 + y2 * y2) / hgtA); - //} - //public void SetDotPattern(float radius, float space) - //{ - // _PatternPainter = _ContentByte.CreatePattern(radius * 2, radius * 2, radius * 2 + space, radius * 2 + space); - // PdfGState gState = new PdfGState(); - // gState.FillOpacity = _Opacity; - // _PatternPainter.SetGState(gState); - // _PatternPainter.SetColorFill(_Color); - // _PatternPainter.Circle(radius, radius, radius); - // _PatternPainter.Fill(); - //} - //public void SetSquareDotPattern(float radius) - //{ - // _PatternPainter = _ContentByte.CreatePattern(radius * 4, radius * 2, radius * 4, radius * 2); - // PdfGState gState = new PdfGState(); - // gState.FillOpacity = .5f * _Opacity; - // _PatternPainter.SetGState(gState); - // _PatternPainter.SetColorFill(_Color); - // _PatternPainter.Rectangle(0, 0, radius, radius); - // _PatternPainter.Rectangle(radius * 2, radius, radius, radius); - // _PatternPainter.Fill(); - //} - //public void SetHashPattern(float thickness, float size) - //{ - // _PatternPainter = _ContentByte.CreatePattern(size, size, size, size); - // PdfGState gState = new PdfGState(); - // gState.FillOpacity = _Opacity; - // gState.StrokeOpacity = _Opacity; - // _PatternPainter.SetGState(gState); - // _PatternPainter.SetLineWidth(.01F); - // _PatternPainter.SetColorStroke(_Color); // Set color - // _PatternPainter.MoveTo(0, 0); - // _PatternPainter.LineTo(size, size); - // _PatternPainter.MoveTo(size, 0); - // _PatternPainter.LineTo(0, size); - // _PatternPainter.Stroke(); - //} - //public void SetTextPattern(float fontSize, float space) - //{ - // float hgtA = _Basefont.GetAscentPoint(_Text, fontSize) + _Basefont.GetDescentPoint(_Text, fontSize); - // float wid = _Basefont.GetWidthPointKerned(_Text, fontSize); - // _PatternPainter = _ContentByte.CreatePattern(wid, hgtA, wid + space, hgtA + space); - // _PatternPainter.SetFontAndSize(_Basefont, fontSize); - // _PatternPainter.BoundingBox = new Rectangle(-20, -20, 100, 100); - // _PatternPainter.BeginText(); - // PdfGState gs1 = new PdfGState(); - // gs1.FillOpacity = _Opacity; - // _PatternPainter.SetGState(gs1); - // _PatternPainter.SetColorFill(_Color); // Set color - // _PatternPainter.ShowText(_Text); - // _PatternPainter.EndText(); - //} - //public void SetTextPattern2(float fontSize) - //{ - // BaseFont _Basefont2 = BaseFont.CreateFont(BaseFont.HELVETICA, Encoding.ASCII.EncodingName, BaseFont.EMBEDDED); - // float hgtA = _Basefont2.GetAscentPoint(_Text, fontSize); - // float wid = _Basefont2.GetWidthPointKerned(_Text, fontSize); - // _PatternPainter = _ContentByte.CreatePattern(wid * 2, hgtA * 2, wid * 2, hgtA * 2); - // _PatternPainter.SetFontAndSize(_Basefont2, fontSize); - // _PatternPainter.BoundingBox = new Rectangle(-20, -20, 100, 100); - // _PatternPainter.BeginText(); - // PdfGState gs1 = new PdfGState(); - // gs1.FillOpacity = _Opacity; - // _PatternPainter.SetGState(gs1); - // _PatternPainter.SetColorFill(_Color); // Set color - // _PatternPainter.ShowText(_Text); - // _PatternPainter.ShowTextAligned(PdfContentByte.ALIGN_LEFT, _Text, wid, hgtA, 0); - // _PatternPainter.EndText(); - //} - #endregion public void Draw() { _ContentByte.SaveState(); - //_ContentByte.BeginText(); - //_ContentByte.SetPatternFill(_PatternPainter); - //_ContentByte.SetTextRenderingMode(PdfContentByte.TEXT_RENDER_MODE_FILL_STROKE); - //_ContentByte.SetLineWidth(.5F); - //_ContentByte.SetFontAndSize(_Basefont, _Fontsize);// Set font and size - //_ContentByte.SetColorStroke(_Color); - //PdfGState gs2 = new PdfGState(); - //gs2.StrokeOpacity = _Opacity; - //_ContentByte.SetGState(gs2); - //_ContentByte.ShowTextAlignedKerned(PdfContentByte.ALIGN_CENTER, _Text, _XOffset, _YOffset, _TextAngle);// Draw the text - //_ContentByte.EndText(); _ContentByte.AddImage(WatermarkImage); _ContentByte.RestoreState(); } - //private float CalcAngle(float opposite, float adjacent) - //{ - // return (float)(Math.Atan2(opposite, adjacent) * (180 / Math.PI)); - //} private Image _WatermarkImage; public Image WatermarkImage { @@ -1452,7 +1091,6 @@ namespace Volian.Svg.Library _Color, System.Drawing.Color.Transparent); g.FillPath(aHatchBrush, gp); g.DrawPath(new System.Drawing.Pen(_Color), gp); - //g.DrawRectangle(System.Drawing.Pens.Cyan, 0, 0, bnds.Width, bnds.Height); } _WatermarkImage = iTextSharp.text.Image.GetInstance(bmp, System.Drawing.Imaging.ImageFormat.Png); _WatermarkImage.SetAbsolutePosition(72, 72); @@ -1481,11 +1119,4 @@ namespace Volian.Svg.Library } } - public enum SvgWatermarkFill - { - Dots = 1, - Text1 = 2, - Text2 = 3, - Hash = 4 - } } diff --git a/PROMS/Volian.Utils.Library/MSWord/WordDoc.cs b/PROMS/Volian.Utils.Library/MSWord/WordDoc.cs index 86b436a0..e8c37df8 100644 --- a/PROMS/Volian.Utils.Library/MSWord/WordDoc.cs +++ b/PROMS/Volian.Utils.Library/MSWord/WordDoc.cs @@ -1,108 +1,9 @@ using System; -using System.Collections.Generic; -using System.Text; -using LBWordLibrary; namespace Volian.MSWord { public class WordDoc { - private static LBApplicationClass _MyWordApp; - public static LBApplicationClass MyWordApp - { - get - { - if (_MyWordApp == null) - _MyWordApp = new LBApplicationClass(); - return WordDoc._MyWordApp; - } - } - private LBDocumentClass _MyWordDoc; - public LBDocumentClass MyWordDoc - { - get - { return _MyWordDoc; } - } - private string _DocName; - public string DocName - { - get { return _DocName; } - set { _DocName = value; } - } - public WordDoc(string docName) - { - DocName = docName; - _MyWordDoc = MyWordApp.Documents.Open(_DocName, false); - } - public string Save() - { - try - { - MyWordDoc.SaveAs(DocName, LBWdSaveFormat.wdFormatDocument); - return "Successful Save"; - } - catch (Exception ex) - { - return string.Format("Error during Doc save - {0}", ex.Message); - } - } - public string Save(string docName) - { - DocName = docName; - return Save(); - } - public void Close() - { - MyWordDoc.Close(false); - } - public float SetLineSpacing(float linesPerInch) // if need landscape set too: , bool landscape) - { - float retval = 0; - LBSelection selection = MyWordApp.Selection; - selection.WholeStory(); - retval = selection.ParagraphFormat.LineSpacing; - selection.ParagraphFormat.SpaceBefore = 0; - selection.ParagraphFormat.SpaceAfter = 0; - selection.ParagraphFormat.LineSpacingRule = LBWdLineSpacing.wdLineSpaceExactly; - selection.ParagraphFormat.LineSpacing = 72 / linesPerInch; - return retval; - } - public float Length - { - get - { - try - { - return MyWordDoc.Length; - } - catch (Exception ex) - { - Console.WriteLine("Error Getting Length, {0}", ex.Message); - } - return 0; - } - } - public static void CloseApp() - { - if(_MyWordApp != null) - { - TryToQuit(); - KillWordApps(); - } - } - - private static void TryToQuit() - { - try - { - _MyWordApp.Quit(false); - } - catch (Exception ex) - { - Console.WriteLine("{0} - {1}", ex.GetType().Name, ex.Message); - } - _MyWordApp=null; - } public static void KillWordApps() { try @@ -124,15 +25,8 @@ namespace Volian.MSWord if(proc.MainWindowTitle=="") proc.Kill(); } - _MyWordApp = null; - } - public static System.Diagnostics.Process[] WordProcesses - { - get - { - return System.Diagnostics.Process.GetProcessesByName("WINWORD"); - } } + public static System.Diagnostics.Process[] WordProcesses => System.Diagnostics.Process.GetProcessesByName("WINWORD"); - } + } } diff --git a/PROMS/Volian.Utils.Library/vlnObject/vlnObject.cs b/PROMS/Volian.Utils.Library/vlnObject/vlnObject.cs index 3de17358..e1b24b77 100644 --- a/PROMS/Volian.Utils.Library/vlnObject/vlnObject.cs +++ b/PROMS/Volian.Utils.Library/vlnObject/vlnObject.cs @@ -1,10 +1,8 @@ using System; using System.Collections.Generic; -using System.Text; using System.Xml.Serialization; using System.Xml; using System.Xml.Schema; -using System.Collections; using System.IO; using System.Text.RegularExpressions; @@ -20,12 +18,9 @@ namespace vlnObjectLibrary { /* See if I need to do anything */ } - #region XML Serialization - public void WriteXml(XmlWriter w) - { - WriteXml(w, true); - } - public void WriteXml(XmlWriter w,bool bSaveParent) + #region XML Serialization + public void WriteXml(XmlWriter w) => WriteXml(w, true); + public void WriteXml(XmlWriter w,bool bSaveParent) { w.WriteAttributeString("title", Title); w.WriteAttributeString("path", Path); @@ -74,13 +69,10 @@ namespace vlnObjectLibrary xr.Close(); } - public XmlSchema GetSchema() - { - return (null); - } - #endregion - #region Constructors - public vlnObject(vlnObject parent, string type, string title, string path) + public XmlSchema GetSchema() => (null); + #endregion + #region Constructors + public vlnObject(vlnObject parent, string type, string title, string path) { m_Parent = parent; m_Type = type; @@ -148,11 +140,8 @@ namespace vlnObjectLibrary vlnObject b = new vlnObject(this, type, title, path); return b; } - public void AddProp(string name, string value) - { - PropArray[name.ToUpper()] = value; - } - public void AddProp(XmlReader xr) + public void AddProp(string name, string value) => PropArray[name.ToUpper()] = value; + public void AddProp(XmlReader xr) { SkipToElement(xr); string sName = null; @@ -182,11 +171,8 @@ namespace vlnObjectLibrary m_Children = value; } } - public void LoadChildren(string sXml) - { - LoadChildren(new XmlTextReader(new StringReader(sXml))); - } - public void LoadChildren(XmlReader xr) + public void LoadChildren(string sXml) => LoadChildren(new XmlTextReader(new StringReader(sXml))); + public void LoadChildren(XmlReader xr) { m_Children = new List(); SkipToElement(xr); @@ -212,8 +198,6 @@ namespace vlnObjectLibrary } public string ProcessString(string s) { - //string retval=s; - //string retval = Regex.Replace(s, "{[.]*}", new MatchEvaluator(ReplaceKey)); string retval = Regex.Replace(s, "{{.*?}}", new MatchEvaluator(ReplaceRow)); retval = Regex.Replace(retval, "{.*?}", new MatchEvaluator(ReplaceDrv)); return retval; diff --git a/PROMS/Volian.Utils.Library/vlnServerLibrary/vlnServer.cs b/PROMS/Volian.Utils.Library/vlnServerLibrary/vlnServer.cs index e3a0c027..f21a3667 100644 --- a/PROMS/Volian.Utils.Library/vlnServerLibrary/vlnServer.cs +++ b/PROMS/Volian.Utils.Library/vlnServerLibrary/vlnServer.cs @@ -1,12 +1,10 @@ using System; using System.Collections.Generic; -using System.Text; using vlnObjectLibrary; using System.Xml; using System.IO; using System.Data; using System.Data.OleDb; -using System.Reflection; namespace vlnServerLibrary { @@ -15,18 +13,10 @@ namespace vlnServerLibrary #region Log4Net private static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); #endregion - #region Static Properties - private static string m_XmlControlPath = "vlnControl.xml"; - private static XmlDocument m_XmlControl; - public static string XMLControlPath - { - get { return m_XmlControlPath; } - set - { - m_XmlControlPath = value; - } - } - public static XmlDocument XMLControl + #region Static Properties + private static XmlDocument m_XmlControl; + public static string XMLControlPath { get; set; } = "vlnControl.xml"; + public static XmlDocument XMLControl { get { @@ -35,7 +25,7 @@ namespace vlnServerLibrary m_XmlControl = new XmlDocument(); lock (m_XmlControl) { - m_XmlControl.Load(m_XmlControlPath); + m_XmlControl.Load(XMLControlPath); } } return m_XmlControl; @@ -75,11 +65,8 @@ namespace vlnServerLibrary string xPath = string.Format(".//dbObject[@type='{0}']/@{1}", o.Parent.Type, s); return LookUpX(o,xPath); } - protected string LookUpX(vlnObject o,string xPath) - { - return LookUpX(o,xPath, XMLControl); - } - private void LoadChildrenFromDB(vlnObject o,string sSelect) + protected string LookUpX(vlnObject o, string xPath) => LookUpX(o, xPath, XMLControl); + private void LoadChildrenFromDB(vlnObject o,string sSelect) { if (sSelect != "") { @@ -89,7 +76,6 @@ namespace vlnServerLibrary OleDbConnectionStringBuilder csb = new OleDbConnectionStringBuilder(s); OleDbConnection dbConn = new OleDbConnection(csb.ConnectionString); string sTable = LookUp(o,"table"); - //if (dbConn.State != ConnectionState.Open) dbConn.Open(); OleDbDataAdapter da = new OleDbDataAdapter(sSelect, dbConn); DataSet ds = new DataSet(); da.Fill(ds, sTable); @@ -222,7 +208,7 @@ namespace vlnServerLibrary string sRetval = sDefault; if (sRetval[0] == '~') { - string sTitlePath = sPath + "\\title"; + string sTitlePath = $"{sPath}\\title"; if (File.Exists(sTitlePath)) { StreamReader sr = File.OpenText(sTitlePath); diff --git a/PROMS/Word Add-Ins for PROMS Import/W2PGrid/W2PGrid/obj/Debug/W2PGrid.csproj.AssemblyReference.cache b/PROMS/Word Add-Ins for PROMS Import/W2PGrid/W2PGrid/obj/Debug/W2PGrid.csproj.AssemblyReference.cache index 45134d463d004644fd7b29608b692159250cc49d..2346fb730af461376f1a2891be482d4ed6f552ad 100644 GIT binary patch delta 289 zcmZ2v+ic6oHj(WtW9UR)adltUU}w+J;27up+=BeP)Vvb^ywsTR%sjXJqTJ$`q|CgS zG9x{Mn8}We!jp9vx!7i%{&s80&B=ihit=Cm7#KvD7#J8Cptv5$U}=DIVkg%y%EOG; zM>bv`X1qSoczuxZ`e5VlFy3J^G}bdUHrl+8X(`iWWeIh*S4|cFpNTNyJwc@2NdO}lqQ#C=I3o*FQLpRRN-tD0~C)zh);eYnM1r0l8l=tF-;H! E0D^&CO8@`> delta 295 zcmZp+U1ZDV>l761%s7$pEMv^X^WwVB`MCx8d8v6N{&}e}j==$Xey$-3;i*XqZuv#I z#R{$|nI)O|c`-?uc`;>1lN*>sCMz&Ysu4s07I*E6YYmgLM5o$Sx5!S*v~s_2};$@T0G@-2*MnK`Le`uh6L zR{EjEsYS*5&KX6S#rnbdrA5i9n{Tm8GAb~@0Ar1_RSZ~F3|LhRMAc+o_8ig-eaQ>} D{nKF9 diff --git a/PROMS/XYPlots/XYPlots.cs b/PROMS/XYPlots/XYPlots.cs index 8ac65c0d..9135f7fe 100644 --- a/PROMS/XYPlots/XYPlots.cs +++ b/PROMS/XYPlots/XYPlots.cs @@ -1,5 +1,4 @@ using System; -using System.Collections; using System.Collections.Generic; using System.IO; using System.Windows.Forms; @@ -18,36 +17,19 @@ namespace XYPlots #region Log4Net // C2018-035 Added error Handling to provide more useful information when a plot fails private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); - #endregion - static string _MyFontFamily = "Letter Gothic Tall"; - public static string MyFontFamily - { - get { return _MyFontFamily; } - set { _MyFontFamily = value; } - } - private static Color _BlackColor = Color.Red; + #endregion + public static string MyFontFamily { get; set; } = "Letter Gothic Tall"; + private static Color _BlackColor = Color.Red; public static Color BlackColor { get { return VG.VG.BlackColor; } set { VG.VG.BlackColor = value; } } - public float Width - { - get { return 72 * (LeftMargin + RightMargin) + printerunits[0] * .05F; } - } - public float Height - { - get { return 72 * (TopMargin + BottomMargin) + printerunits[1] * .05F; } - } - public float PlotWidth - { - get { return (float) userunits[X]; } - } - public float PlotHeight - { - get { return (float) userunits[Y]; } - } - private double ConvertToTwips = 4.8; + public float Width => 72 * (LeftMargin + RightMargin) + printerunits[0] * .05F; + public float Height => 72 * (TopMargin + BottomMargin) + printerunits[1] * .05F; + public float PlotWidth => (float)userunits[X]; + public float PlotHeight => (float)userunits[Y]; + private double ConvertToTwips = 4.8; static int MAX_XY_STACK = 8; /* this is max of CIE cursor/font stack */ static int DPI = 1440; //300; static int CWIDEDOTS = 120; //25; @@ -146,7 +128,7 @@ namespace XYPlots private bool[,] doLOG10 = { { false, false }, { false, false } }; public struct point { - public int[] xyValue; //new int[Dimensions]; + public int[] xyValue; } public struct XyBox { @@ -162,23 +144,17 @@ namespace XYPlots private XyBoxes ActiveBoxes = new XyBoxes(); public class DataPoint { - public override string ToString() // Make it easier to Debug - { - return string.Format("{0},{1}", APoint.xyValue[X],APoint.xyValue[Y]); - } - private point m_APoint; + // Make it easier to Debug + public override string ToString() => string.Format("{0},{1}", APoint.xyValue[X], APoint.xyValue[Y]); + private point m_APoint; public point APoint { get { return m_APoint; } set { m_APoint = value; } } - private double m_slope; // slope of tangent to circle at this point - public double slope - { - get { return m_slope; } - set { m_slope = value; } - } - } + + public double slope { get; set; } + } public class DataPoints : List { } @@ -211,41 +187,20 @@ namespace XYPlots result = (double)(val * val); return result; } - private double FMin(double f1, double f2) - { - return ((f1 >= f2) ? f2 : f1); - } - private double FMax(double f1, double f2) - { - return ((f1 >= f2) ? f1 : f2); - } - private double atan_deg(double x) - { - return (Math.Atan(x) * 180.0 / PI); - } - private double cos_deg(double x) - { - return (Math.Cos(x * PI / 180.0)); - } - private double tan_deg(double x) - { - return (Math.Tan(x * PI / 180.0)); - } - private double sin_deg(double x) - { - return (Math.Sin(x * PI / 180.0)); - } - /// - /// the following function is pointed to by a function pointer - /// and is provided for compatibility with log10() function usage - /// - /// - /// - private double linear(double x) - { - return x; - } - private bool isWhiteSpace(char cptr) + private double FMin(double f1, double f2) => ((f1 >= f2) ? f2 : f1); + private double FMax(double f1, double f2) => ((f1 >= f2) ? f1 : f2); + private double atan_deg(double x) => (Math.Atan(x) * 180.0 / PI); + private double cos_deg(double x) => (Math.Cos(x * PI / 180.0)); + private double tan_deg(double x) => (Math.Tan(x * PI / 180.0)); + private double sin_deg(double x) => (Math.Sin(x * PI / 180.0)); + /// + /// the following function is pointed to by a function pointer + /// and is provided for compatibility with log10() function usage + /// + /// + /// + private double linear(double x) => x; + private bool isWhiteSpace(char cptr) { bool rtnval = false; if (!cptr.Equals(null)) @@ -332,11 +287,8 @@ namespace XYPlots BuffPtr = 0; return true; } - private void LoadBuffFromString(string str) - { - Buff = str; - } - private int getint() + private void LoadBuffFromString(string str) => Buff = str; + private int getint() { int retval; string np = NextPiece(); @@ -381,26 +333,15 @@ namespace XYPlots retval = Convert.ToDouble(NextPiece()); return retval; } - private char NextChar() - { - return Buff[BuffPtr++]; - } - private char getchr() + private char NextChar() => Buff[BuffPtr++]; + private char getchr() { string nxtstring = NextPiece(); - if (nxtstring.Equals("")) - return '\0'; - else - return nxtstring[0]; - } - // C2018-035 Added error Handling to provide more useful information when a plot fails - private string _XYPlotIssue; - public string XYPlotIssue - { - get { return _XYPlotIssue; } - set { _XYPlotIssue = value; } - } - private point GetPair(int flag) + return nxtstring.Equals("") ? '\0' : nxtstring[0]; + } + + public string XYPlotIssue { get; set; } + private point GetPair(int flag) { point retval = new point(); retval.xyValue = new int[Dimensions]; @@ -489,7 +430,6 @@ namespace XYPlots Buff = Buff.Substring(4); } // remove an extra spaces between >< - //Buff = Regex.Replace(Buff, @"[ ]+<", "<"); Buff = Buff.Replace(">\r ", ">\r\n "); Buff = Buff.Replace(">\n ", ">\r\n "); // C2022-003 if RO has symbols Buff = Regex.Replace(Buff, @"[ ]+<", "<"); @@ -595,11 +535,8 @@ namespace XYPlots Offset[PLOT, Y] = -Scale[PLOT, Y] * Math.Log10(minimum[Y]); } } - private void GetAxisTitle(int flag) - { - AxisTitles[flag] = GetString(); - } - private string stripSuperSub(string instr) + private void GetAxisTitle(int flag) => AxisTitles[flag] = GetString(); + private string stripSuperSub(string instr) { StringBuilder sb = new StringBuilder(instr); sb.Replace(SuperScript[0], ""); @@ -749,27 +686,14 @@ namespace XYPlots SetPenDiameter(5); BoxRelative(printerunits[X], printerunits[Y], CurPenWidth, pg, vgOutput); if (GridOnFlag == 0) Visible = 0; - //if (vgOutput is VGOut_Graphics) - //{ - DoGrid(X, pg, vgOutput, 1); - DoGrid(Y, pg, vgOutput, 1); - DoGrid(X, pg, vgOutput, 2); - DoGrid(Y, pg, vgOutput, 2); - DoGrid(X, pg, vgOutput, 3); - DoGrid(Y, pg, vgOutput, 3); - //} - //else if (vgOutput is VGOut_C1PDF) - //{ - // DrawDirection = Y; - // DoGrid(X, pg, vgOutput); - // DrawDirection = X; - // DoGrid(Y, pg, vgOutput); - //} + DoGrid(X, pg, vgOutput, 1); + DoGrid(Y, pg, vgOutput, 1); + DoGrid(X, pg, vgOutput, 2); + DoGrid(Y, pg, vgOutput, 2); + DoGrid(X, pg, vgOutput, 3); + DoGrid(Y, pg, vgOutput, 3); Visible = 1; RecallPosition(); - // Draw outline last to overlap any grid lines. - //SetPenDiameter(5); - //BoxRelative(printerunits[X], printerunits[Y], CurPenWidth, pg, vgOutput); } private void DoGrid(int flag, VG.Page pg, IVGOutput vgOutput) { @@ -890,7 +814,7 @@ namespace XYPlots { if (!SubLogValue) DrawGridRelative((int)(-30 * ConvertToTwips), 0, pg, vgOutput); - // OLD: MoveRelative((int)(-(15 + 300 * size / (int)FontPitch) * ConvertToTwips), (int)(-15 * ConvertToTwips)); + MoveRelative((int)(-(14 + 250 * size / (int)FontPitch) * ConvertToTwips), (int)(-16 * ConvertToTwips)); if ((AxisLabel[1]) != 0) { @@ -1438,11 +1362,8 @@ namespace XYPlots CurPenWidth = (int)(pd * ConvertToTwips); } } - private void PrintStackError(string relation, int limit) - { - MessageBox.Show(String.Format("Position Stack Pointer {0} {1}", relation, limit.ToString()), "Print Stack Error"); - } - private void SavePosition() + private void PrintStackError(string relation, int limit) => MessageBox.Show(String.Format("Position Stack Pointer {0} {1}", relation, limit.ToString()), "Print Stack Error"); + private void SavePosition() { if (stack >= MAX_XY_STACK) PrintStackError(">=", MAX_XY_STACK); SavedX[stack] = Position[X]; @@ -1454,15 +1375,9 @@ namespace XYPlots Position[X] = SavedX[--stack]; Position[Y] = SavedY[stack]; } - private void MoveTo(point pnt) - { - MoveAbsolute(pnt.xyValue[X], pnt.xyValue[Y]); - } - private void DrawTo(point pnt, VG.Page pg, IVGOutput vgOutput) - { - DrawAbsolute(pnt.xyValue[X], pnt.xyValue[Y], pg, vgOutput); - } - private void MoveAbsolute(int ptx, int pty) + private void MoveTo(point pnt) => MoveAbsolute(pnt.xyValue[X], pnt.xyValue[Y]); + private void DrawTo(point pnt, VG.Page pg, IVGOutput vgOutput) => DrawAbsolute(pnt.xyValue[X], pnt.xyValue[Y], pg, vgOutput); + private void MoveAbsolute(int ptx, int pty) { int x, y; x = ptx - Position[X]; @@ -1483,11 +1398,8 @@ namespace XYPlots y = Position[Y] - pty; DrawGridRelative(x, y, pg, vgOutput); } - private void relval(string ptr, int i) - { - ptr = string.Format("+{0}", i.ToString()); - } - private void MoveRelative(int x, int y) + private void relval(string ptr, int i) => ptr = string.Format("+{0}", i.ToString()); + private void MoveRelative(int x, int y) { Position[X] += x; Position[Y] -= y; @@ -1760,15 +1672,9 @@ namespace XYPlots GraphText(tstr.ToString(), pg, vgOutput); RecallPosition(); } - private void FreeBoxList() - { - AllBoxes.Clear(); - } - private void FreeLineList() - { - AllPlots.Clear(); - } - private void Init_Graphic_Vars() + private void FreeBoxList() => AllBoxes.Clear(); + private void FreeLineList() => AllPlots.Clear(); + private void Init_Graphic_Vars() { int i; SavedX = new int[MAX_XY_STACK]; @@ -1923,19 +1829,10 @@ namespace XYPlots //VG.VG_Arc.iColor = 0; //#endif } - private int _OffsetX = 0; - public int OffsetX - { - get { return _OffsetX; } - set { _OffsetX = value; } - } - private int _OffsetY = 0; - public int OffsetY - { - get { return _OffsetY; } - set { _OffsetY = value; } - } - public void Setup() + + public int OffsetX { get; set; } = 0; + public int OffsetY { get; set; } = 0; + public void Setup() { char Command, PrevCommand = ' '; Init_Graphic_Vars(); @@ -2014,7 +1911,7 @@ namespace XYPlots step = "FreeLineList";FreeLineList(); step = "CloseGraph";CloseGraph(); } - catch (Exception ex) + catch (Exception) { _MyLog.WarnFormat("X/Y Plot Error - {0} - {1} - {2}", step, XYPlotIssue ?? "Unknown Issue"); throw new Exception(String.Format("X/Y Plot Error - {0} - {1}",step,XYPlotIssue ?? "Unknown Issue")); diff --git a/PROMS/XYPlots/frmXYPlot.cs b/PROMS/XYPlots/frmXYPlot.cs index 461fed05..c42a892d 100644 --- a/PROMS/XYPlots/frmXYPlot.cs +++ b/PROMS/XYPlots/frmXYPlot.cs @@ -1,17 +1,8 @@ using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Diagnostics; using System.Drawing; -using System.Drawing.Imaging; -using System.Drawing.Printing; -using System.IO; -using System.Text; using System.Text.RegularExpressions; using System.Windows.Forms; using VG; -//using XYPlots; namespace XYPlots {