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,6 +59,8 @@ namespace VEPROMS
get { return _Automatic; } get { return _Automatic; }
set { _Automatic = value; } set { _Automatic = value; }
} }
// 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 }; private int[] _prtSectID = new int[] { -1, -1, 0 };
public int[] PrtSectID public int[] PrtSectID
{ {

View File

@ -91,6 +91,8 @@ namespace VEPROMS
get { return _DidAll; } get { return _DidAll; }
set { _DidAll = value; } 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 }; private int[] _prtSectID = new int[] { -1, -1, 0 };
public int[] PrtSectID public int[] PrtSectID
{ {

View File

@ -1197,17 +1197,17 @@ namespace VEPROMS
{ {
//args.Node.Parent. //args.Node.Parent.
SectionInfo si2 = (args.Node as VETreeNode).VEObject as SectionInfo; 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 (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[0] = si2.MyParent.ItemID; // section
_prtSectID[1] = si2.ItemID; // sub section _prtSectID[1] = si2.ItemID; // sub section
_prtSectID[2] = Convert.ToInt32(si2.IsSubsection); // IsSubSection flag _prtSectID[2] = Convert.ToInt32(si2.IsSubsection); // IsSubSection flag
} }
else 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[0] = si2.ItemID; // section
_prtSectID[1] = -1; // sub section _prtSectID[1] = -1; // sub section
_prtSectID[2] = Convert.ToInt32(si2.IsSubsection); // IsSubSection flag _prtSectID[2] = Convert.ToInt32(si2.IsSubsection); // IsSubSection flag

View File

@ -179,6 +179,8 @@ namespace Volian.Print.Library
get { return _PDFFile; } get { return _PDFFile; }
set { _PDFFile = value; } 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 }; private int[] _prtSectID = new int[] { -1, -1, 0 };
public int[] PrtSectID public int[] PrtSectID
{ {
@ -341,6 +343,7 @@ namespace Volian.Print.Library
_BatchPrint = batchPrint; _BatchPrint = batchPrint;
_MyReaderHelper = new ReaderHelper(this); _MyReaderHelper = new ReaderHelper(this);
_SaveLinks = saveLinks; _SaveLinks = saveLinks;
// C2024-003 parameter contains parent section itemid, child section itemid, issubsection flag.
_prtSectID = PrtSectID; _prtSectID = PrtSectID;
// C2021-010: Remove trailing returns/spaces & manual page breaks & allow save. // C2021-010: Remove trailing returns/spaces & manual page breaks & allow save.
if (removeTrailngHardReturnsAndManualPageBreaks == 1 || removeTrailngHardReturnsAndManualPageBreaks == 3) RemoveTrailingHardReturnsAndSpaces = new List<int>(); if (removeTrailngHardReturnsAndManualPageBreaks == 1 || removeTrailngHardReturnsAndManualPageBreaks == 3) RemoveTrailingHardReturnsAndSpaces = new List<int>();
@ -349,16 +352,7 @@ namespace Volian.Print.Library
_DidAll = didAll; _DidAll = didAll;
_MergeNotIncluded = false; _MergeNotIncluded = false;
_MergedPdf = mergedPdf; _MergedPdf = mergedPdf;
//if(Convert.ToBoolean(PrtSectID[0]))
// {
// }
// else
// {
// }
//_prtSectID = PrtSectID;
//_MyReaderHelper.LoadTree(myItem);
} }
// Pass 1 PDF Name // Pass 1 PDF Name
private string _BeforePageNumberPdf = null; private string _BeforePageNumberPdf = null;
@ -381,7 +375,7 @@ namespace Volian.Print.Library
{ {
if (_MyItem is ProcedureInfo) 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; 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 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 VlnItextFont.RegisterFontFolder(); //B2019-174 register the font folder so that symbols will display on auto TOC
if (myProcedure.Sections != null) 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. if (Convert.ToBoolean(PrtSectID[2])) // If section is a CurSection retrieved the CurSection.
{ {
foreach (SectionInfo si2 in myProcedure.Sections) foreach (SectionInfo si2 in myProcedure.Sections)
@ -833,12 +827,12 @@ namespace Volian.Print.Library
int cnt = 0; int cnt = 0;
foreach (SectionInfo mySection in myProcedure.Sections) 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) if (!CurSection.MyDocStyle.IsStepSection && !CurSection.IsAutoTOCSection)
@ -983,7 +977,8 @@ namespace Volian.Print.Library
string clr = pc.GetValue("PSI", "WATERMARKOVERRIDECLR"); string clr = pc.GetValue("PSI", "WATERMARKOVERRIDECLR");
if (clr != null && clr != "") WatermarkOverrideColor = clr.ToUpper().Contains("DEFAULT") ? "BLUE" : clr; if (clr != null && clr != "") WatermarkOverrideColor = clr.ToUpper().Contains("DEFAULT") ? "BLUE" : clr;
} }
SectionInfo CurSection = null;
SectionInfo CurSection = null; // C2024-003 detrimine if the user is printing a sub section.1639
if (Convert.ToBoolean(PrtSectID[2])) if (Convert.ToBoolean(PrtSectID[2]))
{ {
foreach (SectionInfo si2 in myProcedure.Sections) foreach (SectionInfo si2 in myProcedure.Sections)
@ -1636,7 +1631,8 @@ namespace Volian.Print.Library
// C2018-004 create meta file for baseline compares // 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); Volian.Base.Library.BaselineMetaFile.WriteLine("TOC Ystart {0} LeftMar {1} ScNmPos {2} ScTtlPos {3} ScPgPos {4}", yPageStart, leftMargin, secNumPos, secTitlePos, secPagePos);
bool inGroup = false; bool inGroup = false;
SectionInfo CurSection = null;
SectionInfo CurSection = null; // C2024-003 detrimine determine if the user in printing a sub section.
if (Convert.ToBoolean(PrtSectID[2])) if (Convert.ToBoolean(PrtSectID[2]))
{ {
foreach (SectionInfo si2 in ii.Sections) foreach (SectionInfo si2 in ii.Sections)
@ -3019,8 +3015,8 @@ namespace Volian.Print.Library
private void LoadSectionTree(ItemInfo ii) private void LoadSectionTree(ItemInfo ii)
{ {
if (ii.Sections == null) return; // B2021-067 crash on null reference if (ii.Sections == null) return; // B2021-067 crash on null reference
SectionInfo SubSection = null; SectionInfo CurSection = null;
if (Convert.ToBoolean(MyPromsPrinter.PrtSectID[2])) // If section is a sub section 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) foreach (SectionInfo si2 in ii.Sections)
{ {
@ -3028,9 +3024,10 @@ namespace Volian.Print.Library
{ {
foreach (SectionInfo subsi in si2.Sections) 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) foreach (SectionInfo si in ii.Sections)
if (MyPromsPrinter.PrtSectID[0] == -1 || (MyPromsPrinter.PrtSectID[0] > -1 && si.ItemID == MyPromsPrinter.PrtSectID[0])) 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 else
{ {
MyPdfFile = _MyPromsPrinter.BuildMSWordPDF(si); MyPdfFile = _MyPromsPrinter.BuildMSWordPDF(CurSection);
if (MyPdfFile != null) if (MyPdfFile != null)
{ {
try try
@ -3055,18 +3056,18 @@ namespace Volian.Print.Library
if (fi.Length == 0) // B2017-218 Handle invalid word sections 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. 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; return;
} }
MyReader = MyPdfFile != null ? new PdfReader(MyPdfFile) : null; MyReader = MyPdfFile != null ? new PdfReader(MyPdfFile) : null;
string key = string.Empty; string key = string.Empty;
for (int i = 1; i <= MyReader.NumberOfPages; i++) 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)); dicPage.Add(key, MyPromsPrinter.MyContentByte.PdfWriter.GetImportedPage(MyReader, i));
iTextSharp.text.Rectangle rectgl = MyReader.GetPageSizeWithRotation(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 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); rectgl = new iTextSharp.text.Rectangle(rectgl.Height, rectgl.Width);
dicSize.Add(key, rectgl); dicSize.Add(key, rectgl);
//dicSize.Add(key, MyReader.GetPageSizeWithRotation(i)); //dicSize.Add(key, MyReader.GetPageSizeWithRotation(i));
@ -3076,7 +3077,7 @@ namespace Volian.Print.Library
{ {
if (_MyPromsPrinter.DocReplace == null) if (_MyPromsPrinter.DocReplace == null)
MessageBox.Show(ex.Message, ex.GetType().FullName, MessageBoxButtons.OK, MessageBoxIcon.Error); 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; } get { return _TopMessage; }
set { _TopMessage = value; } 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 }; private int[] _prtSectID = new int[] { -1, -1, 0 };
public int[] PrtSectID public int[] PrtSectID
{ {

View File

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