C2024-003-print-sub-sections

This commit is contained in:
Paul Larsen 2024-02-25 21:40:27 -05:00
parent dcfdf5f852
commit 837978da92
7 changed files with 65 additions and 58 deletions

View File

@ -59,7 +59,9 @@ namespace VEPROMS
get { return _Automatic; }
set { _Automatic = value; }
}
private int[] _prtSectID = new int[] { -1, -1, 0 };
// C2024-003 parameter contains parent section, child section, issubsection flag.
// C2024-003 values needed to print section.
private int[] _prtSectID = new int[] { -1, -1, 0 };
public int[] PrtSectID
{
get { return _prtSectID; }
@ -427,9 +429,9 @@ namespace VEPROMS
RevNum = (_NewRevForAllProcs == null) ? pc.Print_Rev : _NewRevForAllProcs;
RevDate = pc.Print_RevDate; //== null || pc.Print_RevDate=="" ? DateTime.Today : Convert.ToDateTime(pc.Print_RevDate);
ReviewDate = pc.Print_ReviewDate; // == null ? DateTime.Today : Convert.ToDateTime(pc.Print_ReviewDate);
//Now check the format flags to determine if/how the Rev string should be parsed.
// This will covert the old way (16-bit) of setting a RevDate (appending it to the RevNumber)
// to the new way saving the RevNumber and RevDate in there own config fields
//Now check the format flags to determine if/how the Rev string should be parsed.
// This will covert the old way (16-bit) of setting a RevDate (appending it to the RevNumber)
// to the new way saving the RevNumber and RevDate in there own config fields
if ((_MyProcedure.ActiveFormat.PlantFormat.FormatData.PrintData.DoRevDate && RevNum.Contains("/"))
|| (_MyProcedure.ActiveFormat.PlantFormat.FormatData.PrintData.RevDateWithForwardSlash && RevNum.Contains("\\")))
{
@ -530,9 +532,9 @@ namespace VEPROMS
PDFDTSuffix dtSuf = _DocVersionConfig.Print_PDFdtFileSuffix;
if (dtPre != PDFDTPrefix.None) PDFFilePrefix = ""; // incase user entered prefix text but then selected a date/time (in working draft properties)
if (dtSuf != PDFDTSuffix.None) PDFFileSuffix = ""; // incase user entered suffix text but then selected a date/time (in working draft properties)
// B2020-062 control the toggle of date/time prefix/suffix on pdf file name
// disable the date/time Prefix/Suffix switch if no date/time was selected
// This switch is does not affect the use of it if the user typed in text for prefix/suffix
// B2020-062 control the toggle of date/time prefix/suffix on pdf file name
// disable the date/time Prefix/Suffix switch if no date/time was selected
// This switch is does not affect the use of it if the user typed in text for prefix/suffix
if (!AllowDateTimePrefixSuffix || (dtPre == PDFDTPrefix.None && dtSuf == PDFDTSuffix.None))
{
swtbtnPDFdtPrefixSuffix.Value = false;
@ -565,7 +567,7 @@ namespace VEPROMS
private void SetupPrefixSuffixSwitch()
{
if (_CreateButtonClicked) return; // B2020-062 control the toggle of date/time prefix/suffix on pdf file name
// note that MyProcedure must be set before calling this because BuildPDFFileName() will be called when the swbtnPDFPrefixSuffix is set
// note that MyProcedure must be set before calling this because BuildPDFFileName() will be called when the swbtnPDFPrefixSuffix is set
string PDFFilePrefix = _DocVersionConfig.Print_PDFFilePrefix;
string PDFFileSuffix = _DocVersionConfig.Print_PDFFileSuffix;
PDFDTPrefix dtPre = _DocVersionConfig.Print_PDFdtFilePrefix;
@ -724,8 +726,8 @@ namespace VEPROMS
// B2019-128: The combo box list did not include the 'None' option so the selected value was not the correct watermark (had to add 1 to the selected index)
string waterMarkText = (swtbtnWaterMark.Value) ? cbxWaterMark.Text : "None"; // C2021-019
string watermarkColor = "Blue"; // this is the default watermark color
// Determine change bar settings. First get from config & then see if override from dialog.
// Also check that format allows override.
// Determine change bar settings. First get from config & then see if override from dialog.
// Also check that format allows override.
ChangeBarDefinition cbd = DetermineChangeBarSettings();
int n = _DocVersionInfo.Procedures.Count;
int i = 0;
@ -772,8 +774,8 @@ namespace VEPROMS
string myPDFPath = GetMultiunitPDFPath();
_MergedPdfPath = myPDFPath; // If Slave, need its subdirectory/unit path for merging
// RHM 20120925 Overlay the bottom of the dialog so that cancel button is covered.
// B2021-102 put in the using for better memory management
// RHM 20120925 Overlay the bottom of the dialog so that cancel button is covered.
// 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, PrtSectID))//;//C2018-009 print PROMS version
@ -959,9 +961,9 @@ namespace VEPROMS
return;
}
MyProcedure.SelectedChildToPrint = SelectedSlave; // B2023-035 for BNPP Alarms save the number of the child selected to print
// B2021-127: BNPPalr - Auto set of serial #, skip Front Matter as per PAL 11/1/21 (set to 1 not 0)
// Only do if set has applicability, printing an individual procedure, need to determine
// applicability count.
// B2021-127: BNPPalr - Auto set of serial #, skip Front Matter as per PAL 11/1/21 (set to 1 not 0)
// Only do if set has applicability, printing an individual procedure, need to determine
// applicability count.
if (MyProcedure.MyDocVersion.MultiUnitCount > 1)
{
VlnSvgPageHelper.CountInApplProcs = 1;

View File

@ -91,6 +91,8 @@ namespace VEPROMS
get { return _DidAll; }
set { _DidAll = value; }
}
// C2024-003 parameter contains parent section itemid, child section itemid, issubsection flag.
// C2024-003 values needed to print section.
private int[] _prtSectID = new int[] { -1, -1, 0 };
public int[] PrtSectID
{

View File

@ -1197,17 +1197,17 @@ namespace VEPROMS
{
//args.Node.Parent.
SectionInfo si2 = (args.Node as VETreeNode).VEObject as SectionInfo;
int[] _prtSectID = new int[3];
int[] _prtSectID = new int[3]; // C2024-003 parameter contains parent section itemid, child section itemid, issubsection flag.
if (si2.IsSubsection == true)
{
// If section is a subsection.
// If section is a subsection. assign values is section is a subsection.
_prtSectID[0] = si2.MyParent.ItemID; // section
_prtSectID[1] = si2.ItemID; // sub section
_prtSectID[2] = Convert.ToInt32(si2.IsSubsection); // IsSubSection flag
}
else
{
// If section is a regular section
// If section is a regular section. assign values is section is not a subsection.
_prtSectID[0] = si2.ItemID; // section
_prtSectID[1] = -1; // sub section
_prtSectID[2] = Convert.ToInt32(si2.IsSubsection); // IsSubSection flag

View File

@ -2803,8 +2803,8 @@ namespace Volian.Controls.Library
{
tn = new VETreeNode(_LastSectionInfo);
SelectedNode.Nodes.Add(tn); // add tree node to end of list.
// if the new section was flagged as either having an enhanced link for Title or Contents, create the
// Enhanced section:
// if the new section was flagged as either having an enhanced link for Title or Contents, create the
// Enhanced section:
Section sectiontmp = Section.Get(section.ItemID); // need to do this because of 'caching' problem.
if (sectiontmp.SectionConfig.LinkEnhanced == "T" || sectiontmp.SectionConfig.LinkEnhanced == "Y")
CreateEnhancedForSection(newtype, sectiontmp, savLastSectionInfo, sectiontmp.DisplayNumber, sectiontmp.MyContent.Text);
@ -2832,7 +2832,7 @@ namespace Volian.Controls.Library
if (s1 != -1)
{
DeleteItemInfoAndChildren(_LastSectionInfo);// Delete Item and reset Previous and Next
// B2020-087 refresh the tree node after canceling the creation of the subsection
// B2020-087 refresh the tree node after canceling the creation of the subsection
_LastTreeNode.ChildrenLoaded = false;
_LastTreeNode.RefreshNode();
_LastTreeNode.Collapse();
@ -2879,7 +2879,7 @@ namespace Volian.Controls.Library
if (s2 != -1)
{
DeleteItemInfoAndChildren(_LastSectionInfo);// Delete Item and reset Previous and Next
// B2020-087 refresh the tree node after canceling the creation of the subsection
// B2020-087 refresh the tree node after canceling the creation of the subsection
_LastTreeNode.ChildrenLoaded = false;
_LastTreeNode.RefreshNode();
_LastTreeNode.Collapse();

View File

@ -179,6 +179,8 @@ namespace Volian.Print.Library
get { return _PDFFile; }
set { _PDFFile = value; }
}
// C2024-003 parameter contains parent section itemid, child section itemid, issubsection flag.
// C2024-003 values needed to print section.
private int[] _prtSectID = new int[] { -1, -1, 0 };
public int[] PrtSectID
{
@ -341,7 +343,8 @@ namespace Volian.Print.Library
_BatchPrint = batchPrint;
_MyReaderHelper = new ReaderHelper(this);
_SaveLinks = saveLinks;
_prtSectID = PrtSectID;
// C2024-003 parameter contains parent section itemid, child section itemid, issubsection flag.
_prtSectID = PrtSectID;
// C2021-010: Remove trailing returns/spaces & manual page breaks & allow save.
if (removeTrailngHardReturnsAndManualPageBreaks == 1 || removeTrailngHardReturnsAndManualPageBreaks == 3) RemoveTrailingHardReturnsAndSpaces = new List<int>();
if (removeTrailngHardReturnsAndManualPageBreaks == 2 || removeTrailngHardReturnsAndManualPageBreaks == 3) RemoveManualPageBreaks = new List<int>();
@ -349,16 +352,7 @@ namespace Volian.Print.Library
_DidAll = didAll;
_MergeNotIncluded = false;
_MergedPdf = mergedPdf;
//if(Convert.ToBoolean(PrtSectID[0]))
// {
// }
// else
// {
// }
//_prtSectID = PrtSectID;
//_MyReaderHelper.LoadTree(myItem);
}
// Pass 1 PDF Name
private string _BeforePageNumberPdf = null;
@ -381,7 +375,7 @@ namespace Volian.Print.Library
{
if (_MyItem is ProcedureInfo)
{
_prtSectID = PrtSectID;
_prtSectID = PrtSectID; // C2024-003 parameter contains parent section itemid, child section itemid, issubsection flag.
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
{
@ -813,7 +807,7 @@ namespace Volian.Print.Library
VlnItextFont.RegisterFontFolder(); //B2019-174 register the font folder so that symbols will display on auto TOC
if (myProcedure.Sections != null)
{
SectionInfo CurSection = null;
SectionInfo CurSection = null; // C2024-003 detrimine if the user in printing a sub section.
if (Convert.ToBoolean(PrtSectID[2])) // If section is a CurSection retrieved the CurSection.
{
foreach (SectionInfo si2 in myProcedure.Sections)
@ -833,12 +827,12 @@ namespace Volian.Print.Library
int cnt = 0;
foreach (SectionInfo mySection in myProcedure.Sections)
{
if (PrtSectID[0] == -1 || (PrtSectID[0] > -1 && mySection.ItemID == PrtSectID[0]))
if (PrtSectID[0] == -1 || (PrtSectID[0] > -1 && mySection.ItemID == PrtSectID[0])) // C2024-003 check if the user is printing a section
{
if (!Convert.ToBoolean(PrtSectID[2])) // If section is not a Sub Section assign the iteration variable to CurSection
if (!Convert.ToBoolean(PrtSectID[2])) // If section is not a Sub Section assign the iteration variable to CurSection. CurSection contains any type of section.
{
CurSection = mySection;
CurSection = mySection; // if section is not a sub section.
}
if (!CurSection.MyDocStyle.IsStepSection && !CurSection.IsAutoTOCSection)
@ -983,8 +977,9 @@ namespace Volian.Print.Library
string clr = pc.GetValue("PSI", "WATERMARKOVERRIDECLR");
if (clr != null && clr != "") WatermarkOverrideColor = clr.ToUpper().Contains("DEFAULT") ? "BLUE" : clr;
}
SectionInfo CurSection = null;
if (Convert.ToBoolean(PrtSectID[2]))
SectionInfo CurSection = null; // C2024-003 detrimine if the user is printing a sub section.1639
if (Convert.ToBoolean(PrtSectID[2]))
{
foreach (SectionInfo si2 in myProcedure.Sections)
{
@ -1636,10 +1631,11 @@ namespace Volian.Print.Library
// 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;
SectionInfo CurSection = null;
if (Convert.ToBoolean(PrtSectID[2]))
SectionInfo CurSection = null; // C2024-003 detrimine determine if the user in printing a sub section.
if (Convert.ToBoolean(PrtSectID[2]))
{
foreach (SectionInfo si2 in ii.Sections)
foreach (SectionInfo si2 in ii.Sections)
{
if (si2.ItemID == PrtSectID[0])
{
@ -3019,8 +3015,8 @@ namespace Volian.Print.Library
private void LoadSectionTree(ItemInfo ii)
{
if (ii.Sections == null) return; // B2021-067 crash on null reference
SectionInfo SubSection = null;
if (Convert.ToBoolean(MyPromsPrinter.PrtSectID[2])) // If section is a sub section
SectionInfo CurSection = null;
if (Convert.ToBoolean(MyPromsPrinter.PrtSectID[2])) // C2024-003 determine if the user is printing a sub section. If so assign it to CurSection.
{
foreach (SectionInfo si2 in ii.Sections)
{
@ -3028,9 +3024,10 @@ namespace Volian.Print.Library
{
foreach (SectionInfo subsi in si2.Sections)
{
if (subsi.ItemID == MyPromsPrinter.PrtSectID[0])
if (subsi.ItemID == MyPromsPrinter.PrtSectID[1])
{
SubSection = subsi;
CurSection = subsi;
break;
}
}
}
@ -3040,13 +3037,17 @@ namespace Volian.Print.Library
foreach (SectionInfo si in ii.Sections)
if (MyPromsPrinter.PrtSectID[0] == -1 || (MyPromsPrinter.PrtSectID[0] > -1 && si.ItemID == MyPromsPrinter.PrtSectID[0]))
{
if (si.IsStepSection)
if (!Convert.ToBoolean(MyPromsPrinter.PrtSectID[2])) // If section is not a Sub Section assign the iteration variable to CurSection
{
if (si.Sections != null) LoadSectionTree(si);
CurSection = si;
}
if (CurSection.IsStepSection)
{
if (CurSection.Sections != null) LoadSectionTree(CurSection);
}
else
{
MyPdfFile = _MyPromsPrinter.BuildMSWordPDF(si);
MyPdfFile = _MyPromsPrinter.BuildMSWordPDF(CurSection);
if (MyPdfFile != null)
{
try
@ -3055,18 +3056,18 @@ 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(CurSection.DisplayNumber + " " + CurSection.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);
key = string.Format("{0}.{1}", CurSection.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)
if (!((CurSection.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));
@ -3076,7 +3077,7 @@ namespace Volian.Print.Library
{
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);
_MyLog.Warn(string.Format("Error in LoadSectionTree [{0}],{1}.{2}", CurSection.ItemID, CurSection.DisplayNumber, CurSection.DisplayText), ex);
}
}
}

View File

@ -85,6 +85,8 @@ namespace Volian.Print.Library
get { return _TopMessage; }
set { _TopMessage = value; }
}
// C2024-003 parameter contains parent section itemid, child section itemid, issubsection flag.
// C2024-003 values needed to print section.
private int[] _prtSectID = new int[] { -1, -1, 0 };
public int[] PrtSectID
{
@ -262,8 +264,8 @@ namespace Volian.Print.Library
public override void OnEndPage(PdfWriter writer, iTextSharp.text.Document document)
{
TableAdjustment = 0;// RHM20150525 - Table Scrunch
//string path = Volian.Base.Library.vlnStackTrace.StackToStringLocal(3, 1);
//Console.WriteLine("End {0}",path);
//string path = Volian.Base.Library.vlnStackTrace.StackToStringLocal(3, 1);
//Console.WriteLine("End {0}",path);
int profileDepth = ProfileTimer.Push(">>>> OnEndPage");
InitialsPrinted = false;
MyPromsPrinter.OnStatusChanged(string.Format("Page {0}", CurrentPageNumber + 1));
@ -1369,8 +1371,8 @@ namespace Volian.Print.Library
{
if (pageItem.Token == null) continue; // can be null if token is dependent on PSI lookup!
DidHLSText = false; // reset to false for this group of tokens.
//if (pageItem.Token.Contains("HLSTEXT"))
// Console.WriteLine("{0} - PageList Token", pageItem.Token);
//if (pageItem.Token.Contains("HLSTEXT"))
// Console.WriteLine("{0} - PageList Token", pageItem.Token);
// the pagelist 'justify="{PSNotFirst}"' flag only puts item out if not on first page of section, check for this
if (((pageItem.Justify & VEPROMS.CSLA.Library.E_Justify.PSNotFirst) == VEPROMS.CSLA.Library.E_Justify.PSNotFirst)

View File

@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Text;
//using System.Drawing;