diff --git a/PROMS/Formats/fmtall/VEGP1all.xml b/PROMS/Formats/fmtall/VEGP1all.xml index 97afe8f2..6640b2c8 100644 Binary files a/PROMS/Formats/fmtall/VEGP1all.xml and b/PROMS/Formats/fmtall/VEGP1all.xml differ diff --git a/PROMS/Formats/fmtall/VEGP2all.xml b/PROMS/Formats/fmtall/VEGP2all.xml index 00006cb3..f0beeefd 100644 Binary files a/PROMS/Formats/fmtall/VEGP2all.xml and b/PROMS/Formats/fmtall/VEGP2all.xml differ diff --git a/PROMS/Formats/fmtall/VEGPAlrall.xml b/PROMS/Formats/fmtall/VEGPAlrall.xml index e9b5ae4b..0752764b 100644 Binary files a/PROMS/Formats/fmtall/VEGPAlrall.xml and b/PROMS/Formats/fmtall/VEGPAlrall.xml differ diff --git a/PROMS/VEPROMS User Interface/DlgPrintProcedure.cs b/PROMS/VEPROMS User Interface/DlgPrintProcedure.cs index 40be0144..c61857ad 100644 --- a/PROMS/VEPROMS User Interface/DlgPrintProcedure.cs +++ b/PROMS/VEPROMS User Interface/DlgPrintProcedure.cs @@ -59,6 +59,13 @@ namespace VEPROMS get { return _Automatic; } set { _Automatic = value; } } + private int _prtSectID = -1; + public int PrtSectID + { + get { return _prtSectID; } + set { _prtSectID = value; } + } + // C2018-033 Used to turn off using the date/time PDF file prefix and suffix when doing batch file autmatic baseline print testing (frmVEPROMS.cs RunAutomatic()) // This is needed so the the automatic baselines can compare results from different runs of PROMS @@ -768,7 +775,7 @@ namespace VEPROMS // B2021-102 put in the using for better memory management using (frmPDFStatusForm frmStatus = new frmPDFStatusForm(MyProcedure, RevNumAndDate, waterMarkText, cbxDebug.Checked, cbxOrPgBrk.Checked, cbxOpenAfterCreate2.Checked, cbxOverwritePDF2.Checked, myPDFPath, cbd, txbPDFName.Text, new Point(Left, Bottom - 50), - swtbtnBlankPgsForDuplex.Value, _AllProcedures || Automatic, Prefix, SaveLinks, RemoveTrailingHardReturnsAndManualPageBreaks, swtbtnPROMSVersion.Value, true, tbBlankPage.Text, _MergedPfd, watermarkColor))//;//C2018-009 print PROMS version + swtbtnBlankPgsForDuplex.Value, _AllProcedures || Automatic, Prefix, SaveLinks, RemoveTrailingHardReturnsAndManualPageBreaks, swtbtnPROMSVersion.Value, true, tbBlankPage.Text, _MergedPfd, watermarkColor, PrtSectID))//;//C2018-009 print PROMS version { frmStatus.CloseWhenDone = true; Application.DoEvents(); @@ -849,8 +856,9 @@ namespace VEPROMS // B2016-249 Output Procedure to folder associated with Parent Child using (frmPDFStatusForm frmStatus = new frmPDFStatusForm(MyProcedure, RevNumAndDate, waterMarkText, cbxDebug.Checked, cbxOrPgBrk.Checked, cbxOpenAfterCreate2.Checked, cbxOverwritePDF2.Checked, GetMultiunitPDFPath(), cbd, txbPDFName.Text, - new Point(Left, Bottom - 50), swtbtnBlankPgsForDuplex.Value, _AllProcedures || Automatic, Prefix, SaveLinks, RemoveTrailingHardReturnsAndManualPageBreaks, swtbtnPROMSVersion.Value, true, tbBlankPage.Text, _MergedPfd, watermarkColor)) // ;//C2018-009 print PROMS version + new Point(Left, Bottom - 50), swtbtnBlankPgsForDuplex.Value, _AllProcedures || Automatic, Prefix, SaveLinks, RemoveTrailingHardReturnsAndManualPageBreaks, swtbtnPROMSVersion.Value, true, tbBlankPage.Text, _MergedPfd, watermarkColor, PrtSectID)) // ;//C2018-009 print PROMS version { + frmStatus.PrtSectID = PrtSectID; frmStatus.CloseWhenDone = true; Application.DoEvents(); frmStatus.CancelStop = true; @@ -1001,7 +1009,7 @@ namespace VEPROMS // B2018-124 use text of watermark form drop down list instead of enum value using (frmPDFStatusForm frmStatus = new frmPDFStatusForm(MyProcedure, RevNumAndDate, waterMarkText, cbxDebug.Checked, cbxOrPgBrk.Checked, cbxOpenAfterCreate2.Checked, cbxOverwritePDF2.Checked, GetMultiunitPDFPath(), cbd, txbPDFName.Text, new Point(Left, Bottom - 50), - swtbtnBlankPgsForDuplex.Value, _AllProcedures || Automatic, Prefix, SaveLinks, RemoveTrailingHardReturnsAndManualPageBreaks, swtbtnPROMSVersion.Value, false, tbBlankPage.Text, _MergedPfd, watermarkColor))//; //C2018-009 print PROMS version + swtbtnBlankPgsForDuplex.Value, _AllProcedures || Automatic, Prefix, SaveLinks, RemoveTrailingHardReturnsAndManualPageBreaks, swtbtnPROMSVersion.Value, false, tbBlankPage.Text, _MergedPfd, watermarkColor, PrtSectID))//; //C2018-009 print PROMS version { frmStatus.MakePlaceKeeper = swtbtnGeneratePlacekeeper.Value; frmStatus.MakeContinuousActionSummary = cbxGenerateConActSum.Checked; diff --git a/PROMS/VEPROMS User Interface/frmPDFStatusForm.cs b/PROMS/VEPROMS User Interface/frmPDFStatusForm.cs index 34513d86..91c20e91 100644 --- a/PROMS/VEPROMS User Interface/frmPDFStatusForm.cs +++ b/PROMS/VEPROMS User Interface/frmPDFStatusForm.cs @@ -91,7 +91,13 @@ namespace VEPROMS get { return _DidAll; } set { _DidAll = value; } } - public frmPDFStatusForm(ItemInfo myItem, string rev, string watermark, bool debugOutput, bool origPgBrk, bool openPDF, bool overWrite, string pdfPath, ChangeBarDefinition cbd, string pdfFile, Point newLocation, bool insertBlankPages, bool allOrAuto, string prefix, bool saveLinks, int removeTrailingHardReturnsAndManualPageBreaks, bool showPROMSVer, bool didAll, string blankPageText, MergedPdf mergedPdf, string watermarkColor) + private int _prtSectID = -1; + public int PrtSectID + { + get { return _prtSectID; } + set { _prtSectID = value; } + } + public frmPDFStatusForm(ItemInfo myItem, string rev, string watermark, bool debugOutput, bool origPgBrk, bool openPDF, bool overWrite, string pdfPath, ChangeBarDefinition cbd, string pdfFile, Point newLocation, bool insertBlankPages, bool allOrAuto, string prefix, bool saveLinks, int removeTrailingHardReturnsAndManualPageBreaks, bool showPROMSVer, bool didAll, string blankPageText, MergedPdf mergedPdf, string watermarkColor, int PrtSectID = -1) { // B2021-088 moved this if/else from CreatePDF() so that the Approval logic will have access to this logic ProcedureInfo MyProcedure = myItem as ProcedureInfo; @@ -116,6 +122,7 @@ namespace VEPROMS Prefix = prefix; OpenPDF = openPDF; DidAll = didAll; + _prtSectID = PrtSectID; InitializeComponent(); @@ -276,7 +283,7 @@ namespace VEPROMS cachePartInfo = PartInfo.CacheList; } - _PdfFile = MyPromsPrinter.Print(PDFPath, MakePlaceKeeper, MakeContinuousActionSummary, MakeTimeCriticalActionSummary); + _PdfFile = MyPromsPrinter.Print(PDFPath, MakePlaceKeeper, MakeContinuousActionSummary, MakeTimeCriticalActionSummary, PrtSectID); ProfileTimer.Pop(profileDepth); diff --git a/PROMS/VEPROMS User Interface/frmVEPROMS.cs b/PROMS/VEPROMS User Interface/frmVEPROMS.cs index 8ef3ef42..bc046ef3 100644 --- a/PROMS/VEPROMS User Interface/frmVEPROMS.cs +++ b/PROMS/VEPROMS User Interface/frmVEPROMS.cs @@ -515,6 +515,7 @@ namespace VEPROMS ItemInfo.ItemDeleted += new ItemInfoEvent(RefreshDisplayHistory); tv.PrintProcedure += new vlnTreeViewEvent(tv_PrintProcedure); + tv.PrintSection += new vlnTreeViewEvent(tv_PrintSection); tv.QPrintProcedure += new vlnTreeViewEvent(tv_QPrintProcedure); tv.PrintAllProcedures += new vlnTreeViewEvent(tv_PrintAllProcedures); tv.ApproveProcedure += new vlnTreeViewEvent(tv_ApproveProcedure); @@ -1190,6 +1191,45 @@ namespace VEPROMS } + void tv_PrintSection(object sender, vlnTreeEventArgs args) // Quick Print right click menu on Procedure name. + { + try + { + //args.Node.Parent. + SectionInfo si2 = (args.Node as VETreeNode).VEObject as SectionInfo; + int _prtSectID = si2.ItemID; + + if (si2 == null) return; + + tc.SaveCurrentEditItem(si2.MyProcedure); + + si2.MyDocVersion.DocVersionConfig.SelectedSlave = args.UnitIndex; + + using (DlgPrintProcedure prnDlg = new DlgPrintProcedure(si2.MyProcedure)) + { + prnDlg.PrtSectID = _prtSectID; + prnDlg.SelectedSlave = args.UnitIndex; + prnDlg.MySessionInfo = MySessionInfo; + prnDlg.SetupForProcedure(); // Setup filename + prnDlg.ShowDialog(this); // Create Print report + + si2.MyProcedure.MyDocVersion.DocVersionConfig.SelectedSlave = 0; + } + } + catch (Exception ex) + { + StringBuilder sb = new StringBuilder(); + + sb.AppendLine("Could not create PDF Print"); + sb.AppendLine(); + MessageBox.Show(sb.ToString(), "Error when creating PDF Print", MessageBoxButtons.OK, MessageBoxIcon.Warning); + + _MyLog.Warn("Failed to create PDF print", ex); + } + + } + + void tv_CreateContinuousActionSummary(object sender, vlnTreeEventArgs args) { DialogResult dr = System.Windows.Forms.DialogResult.Yes; diff --git a/PROMS/Volian.Controls.Library/vlnTreeView.Designer.cs b/PROMS/Volian.Controls.Library/vlnTreeView.Designer.cs index 98e486b8..605c0232 100644 --- a/PROMS/Volian.Controls.Library/vlnTreeView.Designer.cs +++ b/PROMS/Volian.Controls.Library/vlnTreeView.Designer.cs @@ -1,36 +1,36 @@ namespace Volian.Controls.Library { - partial class vlnTreeView - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; + partial class vlnTreeView + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } - #region Component Designer generated code + #region Component Designer generated code - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - components = new System.ComponentModel.Container(); - } + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + components = new System.ComponentModel.Container(); + } - #endregion - } + #endregion + } } diff --git a/PROMS/Volian.Controls.Library/vlnTreeView.cs b/PROMS/Volian.Controls.Library/vlnTreeView.cs index eb220f91..ef52239f 100644 --- a/PROMS/Volian.Controls.Library/vlnTreeView.cs +++ b/PROMS/Volian.Controls.Library/vlnTreeView.cs @@ -506,6 +506,11 @@ namespace Volian.Controls.Library { if (QPrintProcedure != null) QPrintProcedure(sender, args); } + public event vlnTreeViewEvent PrintSection; + private void OnPrintSection(object sender, vlnTreeEventArgs args) + { + if (PrintSection != null) PrintSection(sender, args); + } public event vlnTreeViewEvent PrintAllProcedures; private void OnPrintAllProcedures(object sender, vlnTreeEventArgs args) { @@ -837,6 +842,7 @@ namespace Volian.Controls.Library MenuItem mitcas = new MenuItem("Create Time Critical Action Summary"); //F2022-024 added menu option MenuItem mip = new MenuItem("Print"); MenuItem miqp = new MenuItem("Quick Print"); + //MenuItem mips = new MenuItem("Print Section"); MenuItem mia = new MenuItem("Approve"); int k = 0; foreach (string s in pri.MyDocVersion.UnitNames) @@ -850,6 +856,9 @@ namespace Volian.Controls.Library MenuItem mqp = miqp.MenuItems.Add(s, new EventHandler(miMultiUnit_Click)); mqp.Enabled = procAppl; mqp.Tag = k; + //MenuItem mps = mips.MenuItems.Add(s, new EventHandler(miMultiUnit_Click)); + //mps.Enabled = procAppl; + //mps.Tag = k; MenuItem ma = mia.MenuItems.Add(s, new EventHandler(miMultiUnit_Click)); ma.Enabled = procAppl; ma.Tag = k; @@ -864,6 +873,7 @@ namespace Volian.Controls.Library cm.MenuItems.Add(mitcas); cm.MenuItems.Add(mip); cm.MenuItems.Add(miqp); + //cm.MenuItems.Add(mips); AddShowChangeBarsAfterMenuItem(cm.MenuItems, pri); cm.MenuItems.Add(mia); AddApprovedRevisionsMultiUnit(cm.MenuItems, pri); @@ -874,6 +884,7 @@ namespace Volian.Controls.Library cm.MenuItems.Add("Create Time Critical Action Summary", new EventHandler(mi_Click)); cm.MenuItems.Add("Print", new EventHandler(mi_Click)); cm.MenuItems.Add("Quick Print", new EventHandler(mi_Click)); + //cm.MenuItems.Add("Print Section", new EventHandler(mi_Click)); //MenuItem miqp = new MenuItem("Print"); AddShowChangeBarsAfterMenuItem(cm.MenuItems, pri); cm.MenuItems.Add("Approve", new EventHandler(mi_Click)); @@ -945,6 +956,25 @@ namespace Volian.Controls.Library SectionConfig sc = si.MyConfig as SectionConfig; if (!si.IsEnhancedSection && (si.Sections == null || si.Sections.Count == 0 || (meta && sc != null && si.Sections != null && si.Sections.Count > 0 && sc.SubSection_Edit == "Y"))) cm.MenuItems.Add("New Step", new EventHandler(mi_Click)); + + //ProcedureInfo pri = tn as SectionInfo; + SectionInfo si2 = (tn as VETreeNode).VEObject as SectionInfo; + if (si2.MyDocVersion.MultiUnitCount > 1) + { + MenuItem mps = new MenuItem("Print Section"); + int k = 0; + foreach (string s in si2.MyDocVersion.UnitNames) + { + k++; + MenuItem mp = mps.MenuItems.Add(s, new EventHandler(miMultiUnit_Click)); + mp.Tag = k; + } + cm.MenuItems.Add(mps); + } + else + { + cm.MenuItems.Add("Print Section", new EventHandler(mi_Click)); + } } } } @@ -962,7 +992,13 @@ namespace Volian.Controls.Library } #endregion //_MyLog.WarnFormat("Context Menu 2 - {0}", GC.GetTotalMemory(true)); - + //#region Print_Section + //if (!tn.IsExpanded && tn.VEObject as SectionInfo != null) + //{ + // SectionInfo si = tn.VEObject as SectionInfo; + // if (si.IsStepSection) cm.MenuItems.Add("Print Section", new EventHandler(mi_Click)); + //} + //#endregion #region Menu_Open if (!tn.IsExpanded && tn.VEObject as SectionInfo != null) { @@ -1000,6 +1036,10 @@ namespace Volian.Controls.Library // require clearing of all enhanced config data or mapping it to existing data (quite complicated) if ((ui.IsAdministrator() || ui.IsSetAdministrator(i.MyProcedure.MyDocVersion) || ui.IsWriter(i.MyProcedure.MyDocVersion)) && (!i.IsEnhancedStep && !i.IsEnhancedProcedure && !i.IsEnhancedSection && !i.IsRtfRaw && !i.IsFigure)) cm.MenuItems.Add("Copy", new EventHandler(mi_Click)); + if (i.HasWordContent) + { + cm.MenuItems.Add("Print Section", new EventHandler(mi_Click)); + } } #endregion //_MyLog.WarnFormat("Context Menu 4 - {0}", GC.GetTotalMemory(true)); @@ -1747,6 +1787,9 @@ namespace Volian.Controls.Library case "Quick Print": OnQPrintProcedure(this, new vlnTreeEventArgs(SelectedNode as VETreeNode, null, 0, mi.Text, (int)mi.Tag)); break; + case "Print Section": + OnPrintSection(this, new vlnTreeEventArgs(SelectedNode as VETreeNode, null, 0, mi.Text, (int)mi.Tag)); + break; case "Print All Procedures for": OnPrintAllProcedures(this, new vlnTreeEventArgs(SelectedNode as VETreeNode, null, 0,mi.Text,(int)mi.Tag)); break; @@ -1880,6 +1923,10 @@ namespace Volian.Controls.Library } switch (mi.Text) { + case "Print Section": + VETreeNode tn2 = SelectedNode as VETreeNode; + OnPrintSection(this, new vlnTreeEventArgs(tn2 as VETreeNode, null, 0)); + break; case "Open": OpenNode(); break; diff --git a/PROMS/Volian.Print.Library/PromsPrinter.cs b/PROMS/Volian.Print.Library/PromsPrinter.cs index ab857036..61b32bc1 100644 --- a/PROMS/Volian.Print.Library/PromsPrinter.cs +++ b/PROMS/Volian.Print.Library/PromsPrinter.cs @@ -179,6 +179,12 @@ namespace Volian.Print.Library 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 { @@ -317,7 +323,7 @@ namespace Volian.Print.Library set { _MergedPdf = value; } } public PromsPrinter(ItemInfo myItem, string rev, string watermark, bool debugOutput, bool origPgBrk, string backgroundFolder, bool openPDF, bool overWrite, - ChangeBarDefinition cbd, String pdfFile, bool insertBlankPages, bool batchPrint, string prefix, bool saveLinks, int removeTrailngHardReturnsAndManualPageBreaks, string blankPageText, bool didAll, MergedPdf mergedPdf, string watermarkColor) + 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; @@ -342,6 +348,7 @@ namespace Volian.Print.Library _DidAll = didAll; _MergeNotIncluded = false; _MergedPdf = mergedPdf; + _prtSectID = PrtSectID; //_MyReaderHelper.LoadTree(myItem); } // Pass 1 PDF Name @@ -361,10 +368,11 @@ namespace Volian.Print.Library // 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) + public string Print(string pdfFolder, bool makePlacekeeper, bool makeContinuousActionSummary, bool makeTimeCriticalActionSummary, int PrtSectID = -1) { if (_MyItem is ProcedureInfo) { + _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 { @@ -799,20 +807,23 @@ namespace Volian.Print.Library int cnt = 0; foreach (SectionInfo mySection in myProcedure.Sections) { - if (!mySection.MyDocStyle.IsStepSection && !mySection.IsAutoTOCSection) + if (PrtSectID == -1 || (PrtSectID > -1 && mySection.ItemID == PrtSectID)) { - VEPROMS.CSLA.Library.Document.ConvertWordSectionToDOCX((ItemInfo)mySection); // B2023-093 Convert a Word section to the DOCX Word format if needed before printing - } - //C2019-042 Section_IsFoldout checks Section Number, Section Title, and use of check box - if ((myProcedure.ActiveFormat.PlantFormat.FormatData.PrintData.SectionLevelFoldouts && (mySection.MyConfig as SectionConfig).Section_IsFoldout == "Y") - || (myProcedure.ActiveFormat.PlantFormat.FormatData.PrintData.AlternateFloatingFoldout && (mySection.MyConfig as SectionConfig).Section_IsFoldout == "Y")) - { - // if floating foldouts, need a list of sections & foldoutreaders. Just do first for now. + if (!mySection.MyDocStyle.IsStepSection && !mySection.IsAutoTOCSection) + { + VEPROMS.CSLA.Library.Document.ConvertWordSectionToDOCX((ItemInfo)mySection); // B2023-093 Convert a Word section to the DOCX Word format if needed before printing + } + //C2019-042 Section_IsFoldout checks Section Number, Section Title, and use of check box + if ((myProcedure.ActiveFormat.PlantFormat.FormatData.PrintData.SectionLevelFoldouts && (mySection.MyConfig as SectionConfig).Section_IsFoldout == "Y") + || (myProcedure.ActiveFormat.PlantFormat.FormatData.PrintData.AlternateFloatingFoldout && (mySection.MyConfig as SectionConfig).Section_IsFoldout == "Y")) + { + // if floating foldouts, need a list of sections & foldoutreaders. Just do first for now. - _MyFoldoutSection.Add(mySection); - string foldoutPdf = PrintProcedureOrFoldout(myProcedure, mySection, Volian.Base.Library.VlnSettings.TemporaryFolder + @"\Foldout" + cnt.ToString() + @".pdf", false, false, false); - _MyFoldoutReader.Add(foldoutPdf != null ? new PdfReader(foldoutPdf) : null); - cnt++; + _MyFoldoutSection.Add(mySection); + string foldoutPdf = PrintProcedureOrFoldout(myProcedure, mySection, Volian.Base.Library.VlnSettings.TemporaryFolder + @"\Foldout" + cnt.ToString() + @".pdf", false, false, false); + _MyFoldoutReader.Add(foldoutPdf != null ? new PdfReader(foldoutPdf) : null); + cnt++; + } } } } @@ -942,190 +953,193 @@ namespace Volian.Print.Library } foreach (SectionInfo mySection in myProcedure.Sections) { - // B2020-115 Calculate maximum available space on a page for figures - vlnParagraph.hMax = ((float)mySection.MyDocStyle.Layout.PageLength); - vlnParagraph.wMax = ((float)mySection.MyDocStyle.Layout.PageWidth) - ((float)mySection.MyDocStyle.Layout.LeftMargin - 12); - NeedSupInfoBreak = true; - bool isFoldoutSection = (mySection.MyConfig as SectionConfig).Section_IsFoldout == "Y"; //C2019-042 Section_IsFoldout checks Section Number, Section Title, and use of check box - if (((isFoldoutSection && myProcedure.ActiveFormat.PlantFormat.FormatData.PrintData.SectionLevelFoldouts) - || (myProcedure.ActiveFormat.PlantFormat.FormatData.PrintData.AlternateFloatingFoldout && isFoldoutSection)) - != doingFoldout) continue; - if (myFoldoutSection != null && myFoldoutSection.ItemID != mySection.ItemID) continue; - PrintOverride.CompressSuper = mySection.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.CompressHPSuper; - PrintOverride.CompressSub = mySection.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.CompressHPSub; - PrintOverride.CompressPropSubSup = mySection.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.CompressPropSubSup; + if(PrtSectID == -1 || (PrtSectID > -1 && mySection.ItemID == PrtSectID) ) + { + // B2020-115 Calculate maximum available space on a page for figures + vlnParagraph.hMax = ((float)mySection.MyDocStyle.Layout.PageLength); + vlnParagraph.wMax = ((float)mySection.MyDocStyle.Layout.PageWidth) - ((float)mySection.MyDocStyle.Layout.LeftMargin - 12); + NeedSupInfoBreak = true; + bool isFoldoutSection = (mySection.MyConfig as SectionConfig).Section_IsFoldout == "Y"; //C2019-042 Section_IsFoldout checks Section Number, Section Title, and use of check box + if (((isFoldoutSection && myProcedure.ActiveFormat.PlantFormat.FormatData.PrintData.SectionLevelFoldouts) + || (myProcedure.ActiveFormat.PlantFormat.FormatData.PrintData.AlternateFloatingFoldout && isFoldoutSection)) + != doingFoldout) continue; + if (myFoldoutSection != null && myFoldoutSection.ItemID != mySection.ItemID) continue; + PrintOverride.CompressSuper = mySection.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.CompressHPSuper; + PrintOverride.CompressSub = mySection.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.CompressHPSub; + PrintOverride.CompressPropSubSup = mySection.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.CompressPropSubSup; - OnStatusChanged((mySection.DisplayNumber ?? "") == "" ? mySection.DisplayText : mySection.DisplayNumber, PromsPrinterStatusType.Progress, progress++); - // Set up Helper for the particular Section - if (_MyHelper == null) - { - LastFmtName = mySection.ActiveFormat.Name; - lastDocStyle = (int)mySection.MyDocStyle.Index; - string hlsText = ""; - int hlsItemId = 0; - if (mySection.IsStepSection && mySection.Steps != null && mySection.Steps.Count > 0) + OnStatusChanged((mySection.DisplayNumber ?? "") == "" ? mySection.DisplayText : mySection.DisplayNumber, PromsPrinterStatusType.Progress, progress++); + // Set up Helper for the particular Section + if (_MyHelper == null) { - hlsItemId = mySection.Steps[0].ItemID; - hlsText = mySection.Steps[0].DisplayText; // save the High level step text for use in the page list - } - cb.PdfWriter.PageEvent = _MyHelper = new VlnSvgPageHelper(mySection, this, hlsText, hlsItemId); - _MyHelper.AllowAllWatermarks = AllowAllWatermarks; - _MyHelper.MyPdfWriter = cb.PdfWriter; - _MyHelper.CreatingFoldoutPage = doingFoldout; - _MyHelper.CreatingSupInfoPage = false; - _MyHelper.MyPdfContentByte = cb; - - 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); - FileInfo VEPromsFile = new FileInfo(procedureFileName); - if (VEPromsFile.Exists && !doingFoldout) - { - _MyHelper.BackgroundFile = procedureFileName; - float x = 0; - float y = 0; - if (!(mySection.ActiveFormat.Name.ToUpper().StartsWith("WST") || _MyHelper.Back32BitPROMS)) // compare folder contains PROMS generated PDF - { - // X value below = 16-bit pdf OverrideLeftMargin = -2 characters at the plant format's default Font's - // characters per inch. - // 16bit OverrideLeftMargin, defined as -2 in driver\drvin.rtf, - override took 2 characters out, so we're adding it back in: - // These values adjust if overlay is 16bit versus 32bit. This is - // used so that the comparison is an exact match. Use 0,0 if comparing to another 32bit - // pdf, i.e. won't process the following 2 lines of code. - x = 2 * 72F / (float)myProcedure.ActiveFormat.PlantFormat.FormatData.Font.CPI; - y = -9.5F; - } - x += 72F * VlnSettings.GetCommandFloat("X", 0); - y -= 72F * VlnSettings.GetCommandFloat("Y", 0); - _MyHelper.BackgroundOffset = new PointF(x, y); - _MyHelper.BackgroundPageOffset = 0; - } - _MyHelper.WatermarkLayer = _WatermarkLayer; - _MyHelper.PageListLayer = _PagelistLayer; - _MyHelper.TextLayer = _TextLayer; - _MyHelper.BackgroundLayer = _BackgroundLayer; - _MyHelper.DebugLayer = _DebugLayer; - _MyHelper.PROMSVersionLayer = _PROMSVersionLayer; //C2018-009 print PROMS version - } - _MyHelper.Rev = _Rev; - _MyHelper.Watermark = _Watermark; - // C2019-039 Remove automatic zoom on Overlay PDFs - //_MyHelper.DoZoomOMatic = DebugOutput; - _MyHelper.OriginalPageBreak = OriginalPageBreak; - _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); - } - else - { - //added by jcb to reset mygaps when changing a section. found old section gaps were carrying over to new section - _MyHelper.MyGaps.Clear(); - //Console.WriteLine("'{0}' PromsPrinter", mySection.DisplayText); - // if pagination is separate or we've changed the format, we have not done the first page - // (if this format has the useonfirst page docstyle flag) - if (LastFmtName != mySection.ActiveFormat.Name || lastDocStyle != (int)mySection.MyDocStyle.Index || mySection.SectionConfig.Section_Pagination == SectionConfig.SectionPagination.Separate) - { - _MyHelper.DidFirstPageDocStyle = false; - lastDocStyle = (int)mySection.MyDocStyle.Index; LastFmtName = mySection.ActiveFormat.Name; - } - if (!mySection.IsStepSection) _MyHelper.PageBookmarks.Add((ItemInfo)mySection, ((mySection.DisplayNumber ?? "") == "" ? "" : mySection.DisplayNumber + " - ") + mySection.DisplayText, null); - _MyHelper.MySection = mySection; - //OnStatusChanged("After Set Svg", PromsPrinterStatusType.SetSVG); - } - // if this format uses phonelists, see if this section has one. We need to know the number - //of lines to adjust the pagelength for pagination and printing. - _MyHelper.PhoneListHeight = 0; - if (mySection.ActiveFormat.PlantFormat.FormatData.SectData.PrintPhoneList) - { - // get config for section - 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) + lastDocStyle = (int)mySection.MyDocStyle.Index; + string hlsText = ""; + int hlsItemId = 0; + if (mySection.IsStepSection && mySection.Steps != null && mySection.Steps.Count > 0) { - 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; - } + hlsItemId = mySection.Steps[0].ItemID; + hlsText = mySection.Steps[0].DisplayText; // save the High level step text for use in the page list } - } - } - _MyHelper.FinalMessageSectionID = finalMessageSectionID; // set VlnSvgPageHelper with the finalMessageSectionID + cb.PdfWriter.PageEvent = _MyHelper = new VlnSvgPageHelper(mySection, this, hlsText, hlsItemId, PrtSectID); + _MyHelper.AllowAllWatermarks = AllowAllWatermarks; + _MyHelper.MyPdfWriter = cb.PdfWriter; + _MyHelper.CreatingFoldoutPage = doingFoldout; + _MyHelper.CreatingSupInfoPage = false; + _MyHelper.MyPdfContentByte = cb; - if (mySection.IsAutoTOCSection) - { - if (((cb.PdfWriter.CurrentPageNumber % 2 == 0 && !_MyHelper.CreatingFoldoutPage) || myProcedure.ProcHasSupInfoData) && InsertBlankPages) // Bug Fix: B2016-181 - add blank page if page count is even - { - 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 - { - if (mySection.IsStepSection) - { - if (mySection.Steps != null && mySection.Steps.Count > 0) + if (!mySection.IsStepSection) _MyHelper.PageBookmarks.Add((ItemInfo)mySection, ((mySection.DisplayNumber ?? "") == "" ? "" : mySection.DisplayNumber + " - ") + mySection.DisplayText, null); + if (DebugOutput) { - // get first step to send to floating foldout indx.&& MyItemInfo.FoldoutIndex>-1) - ItemInfo firstStep = mySection.Steps[0]; - // B2019-165 Don't print the duplex foldout (on the back of the page) if the Don't Include Duplex Foldout check box was checked in section properties - if (firstStep.FoldoutIndex() > -1 && (mySection.MyPrevious == null || !((mySection.MyPrevious.MyConfig as SectionConfig).Section_DontIncludeDuplexFoldout))) - DoFoldoutPage(cb, "Beginning of Step Section", _TextLayer, _MyHelper, firstStep.FoldoutIndex(), InsertBlankPages); - else if (!_MyHelper.CreatingFoldoutPage && _MyFoldoutReader.Count > 0 && InsertBlankPages) + // 16-bit background + string procedureFileName = BackgroundFolder + "\\" + PDFFile.Trim();//CreateFileName(myProcedure.DisplayNumber); + FileInfo VEPromsFile = new FileInfo(procedureFileName); + if (VEPromsFile.Exists && !doingFoldout) { - // if it is continuous pagination, don't do blank page - not sure if this is correct place for this: - // C2023-001 if the previous section has the flag to not insert blank pages, - // then don't insert a blank page between the previous section and this one - if (mySection.SectionConfig.Section_Pagination == SectionConfig.SectionPagination.Separate && !mySection.SearchPrev.MyDocStyle.DontInsertBlankPages) + _MyHelper.BackgroundFile = procedureFileName; + float x = 0; + float y = 0; + if (!(mySection.ActiveFormat.Name.ToUpper().StartsWith("WST") || _MyHelper.Back32BitPROMS)) // compare folder contains PROMS generated PDF { - // only insert a blank page if this section does not have a foldout (but the procedure as a whole does) - // and the checkbox on the print dialog to add blank pages is checked - InsertBlankPage(cb); - //_MyLog.InfoFormat("NewPage Begin Step Sect blank {0}", cb.PdfWriter.CurrentPageNumber); - } - } - else - { - // If the procedure has supplemental facing pages, but this section does not & it's the first section, - // need a blank 'facing page'. Sections after the first will get blank 'facing page' in print's pagination logic - if (SupInfoPrintType == E_SupInfoPrintType.Merge && !mySection.HasSupInfoSteps && firstStepSec && InsertBlankPages) - { - InsertBlankPage(cb); + // X value below = 16-bit pdf OverrideLeftMargin = -2 characters at the plant format's default Font's + // characters per inch. + // 16bit OverrideLeftMargin, defined as -2 in driver\drvin.rtf, - override took 2 characters out, so we're adding it back in: + // These values adjust if overlay is 16bit versus 32bit. This is + // used so that the comparison is an exact match. Use 0,0 if comparing to another 32bit + // pdf, i.e. won't process the following 2 lines of code. + x = 2 * 72F / (float)myProcedure.ActiveFormat.PlantFormat.FormatData.Font.CPI; + y = -9.5F; } + x += 72F * VlnSettings.GetCommandFloat("X", 0); + y -= 72F * VlnSettings.GetCommandFloat("Y", 0); + _MyHelper.BackgroundOffset = new PointF(x, y); + _MyHelper.BackgroundPageOffset = 0; } + _MyHelper.WatermarkLayer = _WatermarkLayer; + _MyHelper.PageListLayer = _PagelistLayer; + _MyHelper.TextLayer = _TextLayer; + _MyHelper.BackgroundLayer = _BackgroundLayer; + _MyHelper.DebugLayer = _DebugLayer; + _MyHelper.PROMSVersionLayer = _PROMSVersionLayer; //C2018-009 print PROMS version } - firstStepSec = false; - CreateStepPdf(mySection, cb); + _MyHelper.Rev = _Rev; + _MyHelper.Watermark = _Watermark; + // C2019-039 Remove automatic zoom on Overlay PDFs + //_MyHelper.DoZoomOMatic = DebugOutput; + _MyHelper.OriginalPageBreak = OriginalPageBreak; + _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); } else { - CreateWordDocPdf(cb, mySection); + //added by jcb to reset mygaps when changing a section. found old section gaps were carrying over to new section + _MyHelper.MyGaps.Clear(); + //Console.WriteLine("'{0}' PromsPrinter", mySection.DisplayText); + // if pagination is separate or we've changed the format, we have not done the first page + // (if this format has the useonfirst page docstyle flag) + if (LastFmtName != mySection.ActiveFormat.Name || lastDocStyle != (int)mySection.MyDocStyle.Index || mySection.SectionConfig.Section_Pagination == SectionConfig.SectionPagination.Separate) + { + _MyHelper.DidFirstPageDocStyle = false; + lastDocStyle = (int)mySection.MyDocStyle.Index; + LastFmtName = mySection.ActiveFormat.Name; + } + if (!mySection.IsStepSection) _MyHelper.PageBookmarks.Add((ItemInfo)mySection, ((mySection.DisplayNumber ?? "") == "" ? "" : mySection.DisplayNumber + " - ") + mySection.DisplayText, null); + _MyHelper.MySection = mySection; + //OnStatusChanged("After Set Svg", PromsPrinterStatusType.SetSVG); } + // if this format uses phonelists, see if this section has one. We need to know the number + //of lines to adjust the pagelength for pagination and printing. + _MyHelper.PhoneListHeight = 0; + if (mySection.ActiveFormat.PlantFormat.FormatData.SectData.PrintPhoneList) + { + // get config for section + 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; + } + } + } + } + _MyHelper.FinalMessageSectionID = finalMessageSectionID; // set VlnSvgPageHelper with the finalMessageSectionID + + if (mySection.IsAutoTOCSection) + { + if (((cb.PdfWriter.CurrentPageNumber % 2 == 0 && !_MyHelper.CreatingFoldoutPage) || myProcedure.ProcHasSupInfoData) && InsertBlankPages) // Bug Fix: B2016-181 - add blank page if page count is even + { + 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 + { + if (mySection.IsStepSection) + { + if (mySection.Steps != null && mySection.Steps.Count > 0) + { + // get first step to send to floating foldout indx.&& MyItemInfo.FoldoutIndex>-1) + ItemInfo firstStep = mySection.Steps[0]; + // B2019-165 Don't print the duplex foldout (on the back of the page) if the Don't Include Duplex Foldout check box was checked in section properties + if (firstStep.FoldoutIndex() > -1 && (mySection.MyPrevious == null || !((mySection.MyPrevious.MyConfig as SectionConfig).Section_DontIncludeDuplexFoldout))) + DoFoldoutPage(cb, "Beginning of Step Section", _TextLayer, _MyHelper, firstStep.FoldoutIndex(), InsertBlankPages); + else if (!_MyHelper.CreatingFoldoutPage && _MyFoldoutReader.Count > 0 && InsertBlankPages) + { + // if it is continuous pagination, don't do blank page - not sure if this is correct place for this: + // C2023-001 if the previous section has the flag to not insert blank pages, + // then don't insert a blank page between the previous section and this one + if (mySection.SectionConfig.Section_Pagination == SectionConfig.SectionPagination.Separate && !mySection.SearchPrev.MyDocStyle.DontInsertBlankPages) + { + // only insert a blank page if this section does not have a foldout (but the procedure as a whole does) + // and the checkbox on the print dialog to add blank pages is checked + InsertBlankPage(cb); + //_MyLog.InfoFormat("NewPage Begin Step Sect blank {0}", cb.PdfWriter.CurrentPageNumber); + } + } + else + { + // If the procedure has supplemental facing pages, but this section does not & it's the first section, + // need a blank 'facing page'. Sections after the first will get blank 'facing page' in print's pagination logic + if (SupInfoPrintType == E_SupInfoPrintType.Merge && !mySection.HasSupInfoSteps && firstStepSec && InsertBlankPages) + { + InsertBlankPage(cb); + } + } + } + firstStepSec = false; + CreateStepPdf(mySection, cb); + } + else + { + CreateWordDocPdf(cb, mySection); + } + } + _MyHelper.PrintedSectionPage = 0; } - _MyHelper.PrintedSectionPage = 0; } if (_MyHelper != null && _MyHelper.BackgroundFile != null) { @@ -1570,270 +1584,273 @@ namespace Volian.Print.Library bool inGroup = false; foreach (SectionInfo mySection in ii.Sections) { - sectCnt++; - SectionConfig sc = mySection.MyConfig as SectionConfig; - 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"))) + if (PrtSectID == -1 || (PrtSectID > -1 && mySection.ItemID == PrtSectID)) { - // 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; - while (!iilvl.IsProcedure) + sectCnt++; + SectionConfig sc = mySection.MyConfig as SectionConfig; + 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"))) { - level++; - iilvl = iilvl.MyParent; - } - // check what level the plant wants the auto ToC indented: - int tofCNumLevels = tocSection.ActiveFormat.PlantFormat.FormatData.SectData.AccSectionData.TableOfContentsData.TofCNumLevels ?? 0; - if (tofCNumLevels > 0 && level > tofCNumLevels) return yLocation; - - int startIndentAfterLevel = tocSection.ActiveFormat.PlantFormat.FormatData.SectData.AccSectionData.TableOfContentsData.TofCStartIndentAfterLevel ?? 2; // - level = level <= startIndentAfterLevel ? 0 : level - startIndentAfterLevel; - float indentOffset = (level * (secTitlePos - secNumPos)); - - if (didSubSecLineSpacing && sectCnt == 1 && indentOffset > 0) // processing first sub-section and we are indenting B2016-205 - { - // processed last sub-section so use the main section line spacing (most times is double spaced) - yLocation -= (float)(tOfC.TofCLineSpacingSub ?? 1) * vlnPrintObject.SixLinesPerInch; - yLocation += (float)(tOfC.TofCLineSpacing ?? 1) * vlnPrintObject.SixLinesPerInch; - } - // The Group Title logic was added for V.C. Summer and Farley(new writer guide format) - // It allows the user to enter a Table of Contents Grouping Title on the Section Property (under automation) - // The grouping title will print if the same title wasn't last printed - string tocGrpHeading = sc.Section_TOC_Group_Title; // returns a "" if no title was entered - float yBottomMargin = yPageStart - (float)tocSection.MyDocStyle.Layout.PageLength + (2 * vlnPrintObject.SixLinesPerInch); - bool doGroupHeading = false; - if (tocGrpHeading != lastTOCGroupHeading && tocGrpHeading.Length > 0) - { - doGroupHeading = true; - inGroup = true; - // B2020-033: for single spacing, add an extra line before a grouping title: - float tmpspc = (float)(tOfC.TofCLineSpacing ?? 1); - if (lastTOCGroupHeading != "" || (firstGroupHeading && tmpspc == 1)) + // 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; + while (!iilvl.IsProcedure) { - yLocation += vlnPrintObject.SixLinesPerInch; - firstGroupHeading = false; + level++; + iilvl = iilvl.MyParent; } - lastTOCGroupHeading = tocGrpHeading; - } - // 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. - bool didGrp = false; - string tmptxt = mySection.MyContent.Number == null || mySection.MyContent.Number == "" ? " " : mySection.DisplayNumber;// B2017-019 - process "" in section number - if (tocSection.ActiveFormat.PlantFormat.FormatData.SectData.AccSectionData.TableOfContentsData.TofCRemoveGrpNameInSects - && tocGrpHeading.Length > 0 && tmptxt.ToUpper().Contains(tocGrpHeading)) - { - tmptxt = tmptxt.Replace(tocGrpHeading, ""); - didGrp = true; - } - if (tocSection.ActiveFormat.PlantFormat.FormatData.SectData.AccSectionData.TableOfContentsData.TofCRemoveGrpNameInSects - && lastTOCGroupHeading.Length > 0 && tmptxt.ToUpper().Contains(lastTOCGroupHeading)) - { - tmptxt = tmptxt.Replace(lastTOCGroupHeading, ""); - didGrp = true; - } - string rtfText = GetRtfToC(tmptxt, tOfC); - Paragraph myparagraphSecNum = vlnPrintObject.RtfToParagraph(rtfText); - float width = 0; - foreach (Chunk chkt in myparagraphSecNum.Chunks) - width += chkt.GetWidthPoint(); - float numwidth = width; - Rtf2Pdf.Offset = new PointF(0, 2.5F); + // check what level the plant wants the auto ToC indented: + int tofCNumLevels = tocSection.ActiveFormat.PlantFormat.FormatData.SectData.AccSectionData.TableOfContentsData.TofCNumLevels ?? 0; + if (tofCNumLevels > 0 && level > tofCNumLevels) return yLocation; - // 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; + int startIndentAfterLevel = tocSection.ActiveFormat.PlantFormat.FormatData.SectData.AccSectionData.TableOfContentsData.TofCStartIndentAfterLevel ?? 2; // + level = level <= startIndentAfterLevel ? 0 : level - startIndentAfterLevel; + float indentOffset = (level * (secTitlePos - secNumPos)); - // logic put in for V.C. Summer who wants to their auto table of contents to print "OPERATOR ACTIONS" (set in the format) instead of "Procedure Steps" - // - note that Summer didn't want to change the section title because they want transition to say "procedure step" for the section title. 03/08/2016 - string tocSecTitle = mySection.FormattedDisplayText;// B2017-019 - process "" in section title - tocSecTitle = ConvertSpecialChars(tocSecTitle, ii.ActiveFormat.PlantFormat.FormatData); // B2019-172 process symbol characters - if (tocSecTitle.ToUpper() == "PROCEDURE STEPS" && tocSection.ActiveFormat.PlantFormat.FormatData.SectData.AccSectionData.TableOfContentsData.TofCProcedureStepsTitle != "") - tocSecTitle = tocSection.ActiveFormat.PlantFormat.FormatData.SectData.AccSectionData.TableOfContentsData.TofCProcedureStepsTitle; + if (didSubSecLineSpacing && sectCnt == 1 && indentOffset > 0) // processing first sub-section and we are indenting B2016-205 + { + // processed last sub-section so use the main section line spacing (most times is double spaced) + yLocation -= (float)(tOfC.TofCLineSpacingSub ?? 1) * vlnPrintObject.SixLinesPerInch; + yLocation += (float)(tOfC.TofCLineSpacing ?? 1) * vlnPrintObject.SixLinesPerInch; + } + // The Group Title logic was added for V.C. Summer and Farley(new writer guide format) + // It allows the user to enter a Table of Contents Grouping Title on the Section Property (under automation) + // The grouping title will print if the same title wasn't last printed + string tocGrpHeading = sc.Section_TOC_Group_Title; // returns a "" if no title was entered + float yBottomMargin = yPageStart - (float)tocSection.MyDocStyle.Layout.PageLength + (2 * vlnPrintObject.SixLinesPerInch); + bool doGroupHeading = false; + if (tocGrpHeading != lastTOCGroupHeading && tocGrpHeading.Length > 0) + { + doGroupHeading = true; + inGroup = true; + // B2020-033: for single spacing, add an extra line before a grouping title: + float tmpspc = (float)(tOfC.TofCLineSpacing ?? 1); + if (lastTOCGroupHeading != "" || (firstGroupHeading && tmpspc == 1)) + { + yLocation += vlnPrintObject.SixLinesPerInch; + firstGroupHeading = false; + } + lastTOCGroupHeading = tocGrpHeading; + } + // 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. + bool didGrp = false; + string tmptxt = mySection.MyContent.Number == null || mySection.MyContent.Number == "" ? " " : mySection.DisplayNumber;// B2017-019 - process "" in section number + if (tocSection.ActiveFormat.PlantFormat.FormatData.SectData.AccSectionData.TableOfContentsData.TofCRemoveGrpNameInSects + && tocGrpHeading.Length > 0 && tmptxt.ToUpper().Contains(tocGrpHeading)) + { + tmptxt = tmptxt.Replace(tocGrpHeading, ""); + didGrp = true; + } + if (tocSection.ActiveFormat.PlantFormat.FormatData.SectData.AccSectionData.TableOfContentsData.TofCRemoveGrpNameInSects + && lastTOCGroupHeading.Length > 0 && tmptxt.ToUpper().Contains(lastTOCGroupHeading)) + { + tmptxt = tmptxt.Replace(lastTOCGroupHeading, ""); + didGrp = true; + } + string rtfText = GetRtfToC(tmptxt, tOfC); + Paragraph myparagraphSecNum = vlnPrintObject.RtfToParagraph(rtfText); + float width = 0; + foreach (Chunk chkt in myparagraphSecNum.Chunks) + width += chkt.GetWidthPoint(); + float numwidth = width; + Rtf2Pdf.Offset = new PointF(0, 2.5F); - // 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); - rtfText = GetRtfToC(tocSecTitle, tOfC, ovrFont); - } - else - rtfText = GetRtfToC(tocSecTitle, tOfC); - Paragraph myparagraphSecTitle = vlnPrintObject.RtfToParagraph(rtfText); // section title - width = secPagePos - adjSecTitlePos - ((tOfC.TofCPageNumAlign.ToUpper() == "RIGHT") ? 18 : 6);// B2021-109 proper adjustment of section title width - copied from leader dots lenth calcuation below - float savTitleWid = width; - // for South Texas Table of Contents - // if there is no section number (we put a blank in tmptxt) then move the section title over to the section number position - if (doGroupHeading) // see if the group title and the first item under it will fit on the page B2016-216 - { - VE_Font grpingFont = new VE_Font(tOfC.Font.Family, (int)tOfC.Font.Size, (E_Style)tOfC.Font.Style | E_Style.Underline, (float)tOfC.Font.CPI); - string rtfGrpingText = GetRtfToC(tocGrpHeading, tOfC, grpingFont); - Paragraph myparagraphGrpTitle = vlnPrintObject.RtfToParagraph(rtfGrpingText); - float w = secPagePos - 6; - // F2018-033: Farley Auto TOC. If line spacing is less than 0, then spacing is double spaced if on section items (such as - // Purpose, Proc Steps; and spacing is single spaced if within groups. If not less than 0, just use what is in format file. - int lnaftergroup = 1; - float lnsp = tocSection.ActiveFormat.PlantFormat.FormatData.SectData.AccSectionData.TableOfContentsData.TofCLineSpacing ?? 0; - if (lnsp < 0) lnaftergroup = ((tocSection.ActiveFormat.PlantFormat.FormatData.SectData.AccSectionData.TableOfContentsData.TofCLineSpacingSub ?? 0) > 0) ? 1 : 2; - float yLocAfterGrpTitleAndFirstItem = yLocation + (lnaftergroup * vlnPrintObject.SixLinesPerInch) + vlnPrintObject.GetHeight(cb, myparagraphGrpTitle, string.Empty, w, false) + vlnPrintObject.GetHeight(cb, myparagraphSecTitle, string.Empty, savTitleWid, false); - // if group heading and first item under it does not fit on the page, do a page break - if ((yPageStart - yLocAfterGrpTitleAndFirstItem) < yBottomMargin) + // 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; + + // logic put in for V.C. Summer who wants to their auto table of contents to print "OPERATOR ACTIONS" (set in the format) instead of "Procedure Steps" + // - note that Summer didn't want to change the section title because they want transition to say "procedure step" for the section title. 03/08/2016 + string tocSecTitle = mySection.FormattedDisplayText;// B2017-019 - process "" in section title + tocSecTitle = ConvertSpecialChars(tocSecTitle, ii.ActiveFormat.PlantFormat.FormatData); // B2019-172 process symbol characters + if (tocSecTitle.ToUpper() == "PROCEDURE STEPS" && tocSection.ActiveFormat.PlantFormat.FormatData.SectData.AccSectionData.TableOfContentsData.TofCProcedureStepsTitle != "") + tocSecTitle = tocSection.ActiveFormat.PlantFormat.FormatData.SectData.AccSectionData.TableOfContentsData.TofCProcedureStepsTitle; + + // 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); + rtfText = GetRtfToC(tocSecTitle, tOfC, ovrFont); + } + else + rtfText = GetRtfToC(tocSecTitle, tOfC); + Paragraph myparagraphSecTitle = vlnPrintObject.RtfToParagraph(rtfText); // section title + width = secPagePos - adjSecTitlePos - ((tOfC.TofCPageNumAlign.ToUpper() == "RIGHT") ? 18 : 6);// B2021-109 proper adjustment of section title width - copied from leader dots lenth calcuation below + float savTitleWid = width; + // for South Texas Table of Contents + // if there is no section number (we put a blank in tmptxt) then move the section title over to the section number position + if (doGroupHeading) // see if the group title and the first item under it will fit on the page B2016-216 + { + VE_Font grpingFont = new VE_Font(tOfC.Font.Family, (int)tOfC.Font.Size, (E_Style)tOfC.Font.Style | E_Style.Underline, (float)tOfC.Font.CPI); + string rtfGrpingText = GetRtfToC(tocGrpHeading, tOfC, grpingFont); + Paragraph myparagraphGrpTitle = vlnPrintObject.RtfToParagraph(rtfGrpingText); + float w = secPagePos - 6; + // F2018-033: Farley Auto TOC. If line spacing is less than 0, then spacing is double spaced if on section items (such as + // Purpose, Proc Steps; and spacing is single spaced if within groups. If not less than 0, just use what is in format file. + int lnaftergroup = 1; + float lnsp = tocSection.ActiveFormat.PlantFormat.FormatData.SectData.AccSectionData.TableOfContentsData.TofCLineSpacing ?? 0; + if (lnsp < 0) lnaftergroup = ((tocSection.ActiveFormat.PlantFormat.FormatData.SectData.AccSectionData.TableOfContentsData.TofCLineSpacingSub ?? 0) > 0) ? 1 : 2; + float yLocAfterGrpTitleAndFirstItem = yLocation + (lnaftergroup * vlnPrintObject.SixLinesPerInch) + vlnPrintObject.GetHeight(cb, myparagraphGrpTitle, string.Empty, w, false) + vlnPrintObject.GetHeight(cb, myparagraphSecTitle, string.Empty, savTitleWid, false); + // if group heading and first item under it does not fit on the page, do a page break + if ((yPageStart - yLocAfterGrpTitleAndFirstItem) < yBottomMargin) + { + NewPage(); + _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 + } + // Print the section title + float retval = Rtf2Pdf.TextAt(cb, myparagraphSecTitle, leftMargin + ((tOfC.TofCSecNumPos == tOfC.TofCSecTitlePos && tmptxt.Equals(" ")) ? secNumPos : adjSecTitlePos), 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, myparagraphSecTitle, leftMargin + adjSecTitlePos, yPageStart - yLocation, width, height, "", yBottomMargin); } - //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 - } - // Print the section title - float retval = Rtf2Pdf.TextAt(cb, myparagraphSecTitle, leftMargin + ((tOfC.TofCSecNumPos == tOfC.TofCSecTitlePos && tmptxt.Equals(" ")) ? secNumPos : adjSecTitlePos), 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, myparagraphSecTitle, leftMargin + adjSecTitlePos, yPageStart - yLocation, width, height, "", yBottomMargin); - } - float ttlRetval = retval; - float savTitleFillWidth = Rtf2Pdf.FillWidth; + float ttlRetval = retval; + float savTitleFillWidth = Rtf2Pdf.FillWidth; - // Now do the section number. Retval is the ylocation on page after the text - // is put out. - retval = Rtf2Pdf.TextAt(cb, myparagraphSecNum, leftMargin + secNumPos + indentOffset, yPageStart - yLocation, numwidth * 1.3F, height, "", yBottomMargin); + // Now do the section number. Retval is the ylocation on page after the text + // 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; + //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) - if (retval != ttlRetval && mySection.MyContent.Text != null && mySection.MyContent.Text != "") yLocation += (retval - ttlRetval); + // 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) + if (retval != ttlRetval && mySection.MyContent.Text != null && mySection.MyContent.Text != "") yLocation += (retval - ttlRetval); - // retval = the minimum (further down the page) between section number and - // title - this accounts for multi line title. - retval = Math.Min(retval, ttlRetval); - lastyLocation = retval; + // retval = the minimum (further down the page) between section number and + // title - this accounts for multi line title. + retval = Math.Min(retval, ttlRetval); + 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 != " ") + // 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)) { - width = 0; - foreach (Chunk chkt in myparagraphSecTitle.Chunks) - width += chkt.GetWidthPoint(); - - // get height - if two lines high, need width of 2nd line for adding - // space characters - float heightTtl = vlnPrintObject.GetHeight(cb, myparagraphSecTitle, 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) + // 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 != " ") { - // 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 + adjSecTitlePos + secondLineWidth + 6; + width = 0; + foreach (Chunk chkt in myparagraphSecTitle.Chunks) + width += chkt.GetWidthPoint(); + + // get height - if two lines high, need width of 2nd line for adding + // space characters + float heightTtl = vlnPrintObject.GetHeight(cb, myparagraphSecTitle, 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 + adjSecTitlePos + secondLineWidth + 6; + } + else + startSpace = leftMargin + adjSecTitlePos + 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 + secPagePos - 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; + } + + 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" + 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 - startSpace = leftMargin + adjSecTitlePos + 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 + secPagePos - 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; - } - - 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); - + AddTemplateTOCPageCounts(tOfC, yLocation, yPageStartAdj, leftMargin, secPagePos, height, key); } - // 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)) + //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) { - 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); + float spcs = (float)(tOfC.TofCLineSpacingSub ?? 1); + if (spcs == -1) // F2018-033: Allow for single & double spacing for Farley (if in group or not) + { + if (inGroup) // Do not require a title to be placed on each section in group for Farley. If in group from above, single space + spcs = 1; + else + spcs = 2; + } + yLocation += (spcs * vlnPrintObject.SixLinesPerInch); } else - AddTemplateTOCPageCounts(tOfC, yLocation, yPageStartAdj, leftMargin, secPagePos, height, key); - } - //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); - if (spcs == -1) // F2018-033: Allow for single & double spacing for Farley (if in group or not) { - if (inGroup) // Do not require a title to be placed on each section in group for Farley. If in group from above, single space - spcs = 1; - else - spcs = 2; + float spc = (float)(tOfC.TofCLineSpacing ?? 1); + if (spc == -1) // F2018-033: Allow for single & double spacing for Farley (if in group or not) + { + if (inGroup) // Do not require a title to be placed on each section in group for Farley. If in group from above, single space + spc = 1; + else + spc = 2; + } + yLocation += (spc * vlnPrintObject.SixLinesPerInch); } - yLocation += (spcs * vlnPrintObject.SixLinesPerInch); + // C2021-015: Barakah High Level Steps in Table of Contents - check to see if we need to add the high level steps on + // 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); } - else + float savYLoc = yLocation; + yLocation = AddSectionToTOC(tocSection, mySection, tOfC, cb, yPageStart, yLocation, doSubY); + if (savYLoc == yLocation) // nothing was outputted i.e. the subsections are not included on the TOC // B2016-205 { - float spc = (float)(tOfC.TofCLineSpacing ?? 1); - if (spc == -1) // F2018-033: Allow for single & double spacing for Farley (if in group or not) + if (doSubY && sectCnt == ii.Sections.Count) { - if (inGroup) // Do not require a title to be placed on each section in group for Farley. If in group from above, single space - spc = 1; - else - spc = 2; + // processed last sub-section so use the main section line spacing (most times is double spaced) + yLocation -= (float)(tOfC.TofCLineSpacingSub ?? 1) * vlnPrintObject.SixLinesPerInch; + yLocation += (float)(tOfC.TofCLineSpacing ?? 1) * vlnPrintObject.SixLinesPerInch; } - yLocation += (spc * vlnPrintObject.SixLinesPerInch); - } - // C2021-015: Barakah High Level Steps in Table of Contents - check to see if we need to add the high level steps on - // 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); - } - float savYLoc = yLocation; - yLocation = AddSectionToTOC(tocSection, mySection, tOfC, cb, yPageStart, yLocation, doSubY); - if (savYLoc == yLocation) // nothing was outputted i.e. the subsections are not included on the TOC // B2016-205 - { - if (doSubY && sectCnt == ii.Sections.Count) - { - // processed last sub-section so use the main section line spacing (most times is double spaced) - yLocation -= (float)(tOfC.TofCLineSpacingSub ?? 1) * vlnPrintObject.SixLinesPerInch; - yLocation += (float)(tOfC.TofCLineSpacing ?? 1) * vlnPrintObject.SixLinesPerInch; } } } @@ -2338,7 +2355,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); + VlnSvgPageHelper myPageHelper = new VlnSvgPageHelper(vlnParagraph.MyItemInfo as SectionInfo, this, null, 0, _prtSectID); cb.PdfWriter.PageEvent = myPageHelper; myPageHelper.AllowAllWatermarks = AllowAllWatermarks; myPageHelper.MyPdfWriter = cb.PdfWriter; @@ -2926,46 +2943,49 @@ namespace Volian.Print.Library if (ii.Sections == null) return; // B2021-067 crash on null reference foreach (SectionInfo si in ii.Sections) { + if (MyPromsPrinter.PrtSectID == -1 || (MyPromsPrinter.PrtSectID > -1 && si.ItemID == MyPromsPrinter.PrtSectID)) + { if (si.IsStepSection) - { - if (si.Sections != null) LoadSectionTree(si); - } - else - { - MyPdfFile = _MyPromsPrinter.BuildMSWordPDF(si); - if (MyPdfFile != null) { - try + if (si.Sections != null) LoadSectionTree(si); + } + else + { + MyPdfFile = _MyPromsPrinter.BuildMSWordPDF(si); + if (MyPdfFile != null) { - FileInfo fi = new FileInfo(MyPdfFile); - if (fi.Length == 0) // B2017-218 Handle invalid word sections + try { - 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); - return; + FileInfo fi = new FileInfo(MyPdfFile); + 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); + return; + } + MyReader = MyPdfFile != null ? new PdfReader(MyPdfFile) : null; + string key = string.Empty; + for (int i = 1; i <= MyReader.NumberOfPages; i++) + { + key = string.Format("{0}.{1}", si.ItemID, i); + dicPage.Add(key, MyPromsPrinter.MyContentByte.PdfWriter.GetImportedPage(MyReader, i)); + iTextSharp.text.Rectangle rectgl = MyReader.GetPageSizeWithRotation(i); + // If the word page is set to landscape, but the document style is not landscape, then flip the height and width (put back to portrait) + 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)); + } } - MyReader = MyPdfFile != null ? new PdfReader(MyPdfFile) : null; - string key = string.Empty; - for (int i = 1; i <= MyReader.NumberOfPages; i++) + catch (Exception ex) { - key = string.Format("{0}.{1}", si.ItemID, i); - dicPage.Add(key, MyPromsPrinter.MyContentByte.PdfWriter.GetImportedPage(MyReader, i)); - iTextSharp.text.Rectangle rectgl = MyReader.GetPageSizeWithRotation(i); - // If the word page is set to landscape, but the document style is not landscape, then flip the height and width (put back to portrait) - 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)); + 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); } } - catch (Exception ex) - { - 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); - } } - } + } } } } diff --git a/PROMS/Volian.Print.Library/VlnSvgPageHelper.cs b/PROMS/Volian.Print.Library/VlnSvgPageHelper.cs index 92554a34..ea078716 100644 --- a/PROMS/Volian.Print.Library/VlnSvgPageHelper.cs +++ b/PROMS/Volian.Print.Library/VlnSvgPageHelper.cs @@ -85,6 +85,12 @@ namespace Volian.Print.Library 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 { @@ -867,12 +873,15 @@ i = 0; 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) { + forceLoadSvg = true; + } Volian.Svg.Library.Svg sectSvg = BuildSvg(_MySection, forceLoadSvg); if (sectSvg != null) MySvg = sectSvg; _YTopMargin = null; @@ -1031,9 +1040,10 @@ i = 0; set { _MyPromsPrinter = value; } } private int _MyRomanPage = 1; - public VlnSvgPageHelper(VEPROMS.CSLA.Library.SectionInfo mySection, PromsPrinter myPromsPrinter, string hlsText, int hlsItemId) + public VlnSvgPageHelper(VEPROMS.CSLA.Library.SectionInfo mySection, PromsPrinter myPromsPrinter, string hlsText, int hlsItemId, int PrtSectID) : base() { + _prtSectID = PrtSectID; HLSText = hlsText; HasHLSTextId = hlsItemId; MyPromsPrinter = myPromsPrinter;