Support for SAMGS Supplemental Information

This commit is contained in:
2017-05-03 14:37:25 +00:00
parent e7f9d4e3ed
commit f139c79d32
14 changed files with 1513 additions and 682 deletions

View File

@@ -446,6 +446,8 @@ namespace Volian.Print.Library
get { return _IsWordDocPara; }
set { _IsWordDocPara = value; }
}
public static bool HasPrefPageBreak = false; // use to track page breaks for supp info
public bool PrefPageBreak = false;
private bool _ShowSectionTitles;
public bool ShowSectionTitles
{
@@ -565,6 +567,8 @@ namespace Volian.Print.Library
int profileDepth = ProfileTimer.Push(">>>> vlnParagraph.DrawText");
IsCompressed = (MyPageHelper.YMultiplier != 1 && MyItemInfo != null && MyItemInfo.FormatStepData != null && MyItemInfo.FormatStepData.Font.Size >= 12 && (MyItemInfo.FormatStepData.Font.Style & E_Style.Underline) != 0);
retval = DrawText(cb, ref yPageStart, yTopMargin, yBottomMargin, ref yLocation);
// _yPageStartForSupInfo is used to move steps down the page for the supinfo pdf. Each supinfo step may not be related to previous in structure, so need this to set y location.
if (MyItemInfo.IsInSupInfo) _yPageStartForSupInfo = retval;
// Wolf Creek Training format puts a separator line after printing the section number/title
if (MyItemInfo.IsSection && MyItemInfo.ActiveFormat.PlantFormat.FormatData.PrintData.WCNTraining)
MyPageHelper.SectionSepLineYoffStart = retval - (SixLinesPerInch / 2);
@@ -1461,6 +1465,11 @@ namespace Volian.Print.Library
ProfileTimer.Pop(profileDepth);
return yPageStart;
}
if (MyItemInfo.IsInSupInfo) // if generating the pdf for supinfos (facing page) pdf, need a different cb to go to that file.
{
MyContentByte = cb;
MyPageHelper = null;
}
bool doThreeContinues = false;
// For BGE, the very first subsection's pagelist items were not correct - the section/meta section titles were
// at the wrong level. Reset the page helper's section.
@@ -1539,6 +1548,13 @@ namespace Volian.Print.Library
MyPageHelper.PageBookmarks.Add(MyItemInfo, ((si.DisplayNumber ?? "") == "" ? "" : si.DisplayNumber + " - ") + si.DisplayText, null);
DoCheckOffHeader(cb, MyItemInfo, yLocation, yTopMargin, yPageStart);
}
// SupInfo has its own pagination and ylocation handling, reset ypagestart & ylocation if continuing on current page.
// The value used was saved when the previous SupInfo step was printed.
if (MyItemInfo.IsSupInfoPart)
{
yPageStart = _yPageStartForSupInfo - SixLinesPerInch;
yLocation = yPageStart - YTopMost;
}
if (MyItemInfo.IsHigh && MyItemInfo.MyPrevious != null && ((MyItemInfo.MyDocStyle.StructureStyle.Style & E_DocStructStyle.DoubleBoxHLS) == E_DocStructStyle.DoubleBoxHLS))
yPageStart -= SixLinesPerInch;
if (MyPageHelper.ParaBreaks.Count > 0 && MyPageHelper.ParaBreaks[0].CompressFirstPartOfStep)
@@ -1582,6 +1598,7 @@ namespace Volian.Print.Library
{
SectionInfo si = MyItemInfo as SectionInfo;
MyPageHelper.PageBookmarks.Add(MyItemInfo, ((si.DisplayNumber ?? "") == "" ? "" : si.DisplayNumber + " - ") + si.DisplayText, null);
}
// Only do foldout page if not done for section break, i.e. check the there's a previous step.
if (MyItemInfo.MyPrevious != null && MyItemInfo.FoldoutIndex() > -1)
@@ -1597,7 +1614,24 @@ namespace Volian.Print.Library
cb.PdfDocument.Add(new iTextSharp.text.Table(1));
MyPromsPrinter.NewPage();
//_MyLog.InfoFormat("NewPage 10 blank {0}", cb.PdfWriter.CurrentPageNumber);
}
}
// If there is supplemental information to be printed on the facing page, then get the id that has supinfo
// so that it can be retrieved from the pdf for the supinfos for this section. If there is one,
// use DoSupInfoPage to put out the page, otherwise do a blank page.
if (!MyItemInfo.IsSection && !MyItemInfo.IsInSupInfo && (MyItemInfo.MyActiveSection as SectionInfo).HasSupInfoSteps)
{
int sid = GetIdThatHasSupInfoItems(MyItemInfo, MyItemInfo.ItemID);
if (sid != -1)
{
MyPromsPrinter.DoSupInfoPage(cb, "TEMP", MyPageHelper.TextLayer, MyPageHelper, sid, true);
}
else
{
MyPageHelper.OnBlankPage = true;
cb.PdfDocument.Add(new iTextSharp.text.Table(1));
MyPromsPrinter.NewPage();
}
}
if (MyItemInfo.MyDocStyle.LandscapePageList)
{
@@ -1606,7 +1640,8 @@ namespace Volian.Print.Library
}
yPageStart = yTopMargin + YTopMost;
DoCheckOffHeader(cb, MyItemInfo, yLocation, yTopMargin, yPageStart);
SectionTopMessage(cb, yTopMargin, yLocation);
SectionTopMessage(cb, yTopMargin, yLocation); // does wcntraining & suppinfo section title
if (MyPageHelper.CreatingSupInfoPage) yPageStart -= (2 * SixLinesPerInch);
if (doSectionContinue ) DoTopContinueMsg(cb, ref yPageStart, yTopMargin, docstyle , null);
// If "ContinueSectionHeader" (format flag) is true then print the section title with "(Continued)" appended to it
if (!MyItemInfo.IsSection && MyItemInfo.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.ContinueSectionHeader && (!MyItemInfo.IsSection || MyItemInfo.IsSeparateSubsection))
@@ -1688,7 +1723,20 @@ namespace Volian.Print.Library
MyPromsPrinter.NewPage();
_MyLog.InfoFormat("NewPage Break within step blank {0}", cb.PdfWriter.CurrentPageNumber);
}
if (!MyItemInfo.IsSection && !MyItemInfo.IsInSupInfo && (MyItemInfo.MyActiveSection as SectionInfo).HasSupInfoSteps)
{
int sid = GetIdThatHasSupInfoItems(MyItemInfo, MyItemInfo.ItemID);
if (sid != -1)
{
MyPromsPrinter.DoSupInfoPage(cb, "TEMP", MyPageHelper.TextLayer, MyPageHelper, sid, true);
}
else
{
MyPageHelper.OnBlankPage = true;
cb.PdfDocument.Add(new iTextSharp.text.Table(1));
MyPromsPrinter.NewPage();
}
}
// if there is a 'container vlnbox' around the HLS, flag that the drawn box must also break:
if (MyHighLevelParagraph != null && MyHighLevelParagraph.PartsContainer != null && MyHighLevelParagraph.PartsContainer.Count > 0 &&
!((MyHighLevelParagraph.MyItemInfo.MyDocStyle.StructureStyle.Style & E_DocStructStyle.DoubleBoxHLS) == E_DocStructStyle.DoubleBoxHLS))
@@ -1745,7 +1793,8 @@ namespace Volian.Print.Library
doSectionTitleContinued = (sch == null || sch.Section_PrintHdr == "Y") && !MyItemInfo.MyDocStyle.CancelSectTitle;
}
}
addExtraLines = SectionTopMessage(cb, yTopMargin, yLocation); // this does wcntraining top section continue message
addExtraLines = SectionTopMessage(cb, yTopMargin, yLocation); // this does wcntraining top section continue message and supplemental info message
if (MyPageHelper.CreatingSupInfoPage) yPageStart -= (2 * SixLinesPerInch);
if (!addExtraLines && (!doSectionTitleContinued || !SectionShowTitles))
addExtraLines = DoTopContinueMsg(cb, ref yPageStart, yTopMargin, docstyle, doThreeContinues && MyItemInfo.MyParent != null && MyItemInfo.MyParent.MyTab != null ? MyItemInfo.MyParent.MyTab.CleanText : null);
@@ -2043,6 +2092,44 @@ namespace Volian.Print.Library
ProfileTimer.Pop(profileDepth);
return yPageStart;
}
// Find the step that has supplemental information from this step down page until a preferred page break is found.
// It is used to determine whether there is a supinfo facing page or if there should be a blank page.
private int GetIdThatHasSupInfoItems(ItemInfo ii, int startid)
{
if (ii == null) return -1;
if (ii.SupInfos != null && ii.SupInfos.Count > 0) return ii.SupInfos[0].ItemID;
int id = GetSubThatHasSupInfoItems(ii, startid);
if (id != -1) return id;
ItemInfo sib = ii.NextItem;
while (sib != null)
{
if (sib.SupInfos != null && sib.SupInfos.Count > 0) return sib.SupInfos[0].ItemID;
id = GetSubThatHasSupInfoItems(sib, startid);
if (id != -1) return id;
sib = sib.NextItem;
}
return -1;
}
private int GetSubThatHasSupInfoItems(ItemInfo ii, int startid)
{
if (ii is StepInfo && ((ii as StepInfo).MyConfig as StepConfig).Step_PreferredPagebreak && ii.ItemID != startid) return -1;
if (ii.MyContent.ContentParts != null)
{
foreach (PartInfo pi in ii.MyContent.ContentParts)
{
if ((E_FromType)pi.FromType != E_FromType.SupInfo)
{
foreach (ItemInfo iic in pi.MyItems)
{
if (iic.SupInfos != null && iic.SupInfos.Count > 0) return iic.SupInfos[0].ItemID;
int id = GetSubThatHasSupInfoItems(iic, startid);
if (id != -1) return id;
}
}
}
}
return -1;
}
private float GetSectionTopMessageSize()
{
// B2016-134: Account for wcntraining section top continue if item has container
@@ -2057,6 +2144,17 @@ namespace Volian.Print.Library
// section is continued from previous page) in the Responsibility column.
private bool SectionTopMessage(PdfContentByte cb, float yTopMargin, float yLocation)
{
if (MyPageHelper.CreatingSupInfoPage)
{
float scttopWidths = "Supplemental Information".Length * 6;
float ctrs = ((float)MyItemInfo.MyDocStyle.Layout.PageWidth - (float)MyItemInfo.MyDocStyle.Layout.LeftMargin) / 2;
float sctcntrXs = (float)MyItemInfo.MyDocStyle.Layout.LeftMargin + ctrs - (scttopWidths / 2);
VE_Font vf = MyItemInfo.MyDocStyle.Font;
E_Style sty = (E_Style)(vf.Style | E_Style.Underline);
vf = new VE_Font(vf.Family, (int)vf.Size, sty, (float)vf.CPI);
MyPageHelper.TopMessage = new vlnText(cb, this, "Supplemental Information", "Supplemental Information", sctcntrXs, yTopMargin + 0.1F, vf);
return true;
}
bool addextra = false;
if (MyItemInfo.MyDocStyle.SectTop != null && MyItemInfo.MyDocStyle.SectTop.Message != null)
{
@@ -2841,6 +2939,7 @@ namespace Volian.Print.Library
get { return _MyPromsPrinter; }
set { _MyPromsPrinter = value; }
}
public static float _yPageStartForSupInfo = 0;
public vlnParagraph(vlnParagraph parent, PdfContentByte cb, ItemInfo itemInfo, float xoff, float yoff, int rnoLevel, int maxRNO, FormatInfo formatInfo, string prefix, string suffix, float yoffRightParent, bool loadChildren, PromsPrinter pp)
{
MyPromsPrinter = pp ?? parent.MyPromsPrinter;
@@ -2952,6 +3051,8 @@ namespace Volian.Print.Library
if (itemInfo.IsFootnote) itemInfo.MyTab = null;
if (itemInfo.IsSupInfoPart) XOffset = (float)itemInfo.MyDocStyle.Layout.LeftMargin;
//if (itemInfo.MyTab != null && itemInfo.MyTab.Text != null && itemInfo.MyTab.Text != "")
// bug fix - if the section does not have a section number, then we need to build an empty tab for the itemInfo
// so that we place the section title in the correct location. so we need to go into this IF code block
@@ -2980,6 +3081,8 @@ namespace Volian.Print.Library
else
doprint = false;
}
// if printing the supplemental info facing page, don't put out the section title. ToPdf will put out 'Supplemental Information' title.
if (MyPageHelper.CreatingSupInfoPage && itemInfo.IsSection) doprint = false;
if (doprint && itemInfo.IsSection && !itemInfo.MyDocStyle.CancelSectTitle && itemInfo.MyTab.Text.ToUpper() != "FOLDOUT")
{
doSectTab = true;
@@ -3059,7 +3162,16 @@ namespace Volian.Print.Library
}
if (!itemInfo.IsSection || doSectTab)
{
if (itemInfo.MyTab.AltPrintTab != null)
if (itemInfo.IsSupInfoPart) // get combined tab if on a supinfo facing page:
{
string strmytab = null;
if (itemInfo.MyParent.IsHigh)
strmytab = itemInfo.MyTab.CleanText;
else
strmytab = ItemInfo.GetCombinedTab(itemInfo.MyParent, itemInfo.MyParent.MyParent.CombinedTab);
mytab = new vlnTab(cb, this, strmytab, strmytab, localXOffset, yoff, itemInfo.MyTab.MyFont, doSectTab, StepRTB.MySymbolFontName, itemInfo.MyTab.RemovedStyleUnderline);
}
else if (itemInfo.MyTab.AltPrintTab != null)
mytab = new vlnTab(cb, this, itemInfo.MyTab.AltPrintTab, itemInfo.MyTab.AltPrintTab, localXOffset, yoff, itemInfo.MyTab.MyFont, doSectTab, StepRTB.MySymbolFontName, itemInfo.MyTab.RemovedStyleUnderline);
else
mytab = new vlnTab(cb, this, itemInfo.MyTab.Text, itemInfo.MyTab.CleanText, localXOffset, yoff, itemInfo.MyTab.MyFont, doSectTab, StepRTB.MySymbolFontName, itemInfo.MyTab.RemovedStyleUnderline);
@@ -3123,6 +3235,11 @@ namespace Volian.Print.Library
}
}
if (itemInfo.IsSection && MyParent == null && itemInfo.MyDocStyle.SupplementalInformation)
{
_SupInfoSection = new vlnParagraph(this, cb, itemInfo, xoff, yoff, rnoLevel, maxRNO, formatInfo, null, null, yoffRightParent, false, pp);
MyPromsPrinter.SupInfoPdfPageCount = -1;
}
// For Calvert Alarms: if within the CONDITION/RESPONSE table, indent by 1 character.
// Sequential substeps are ok because of the tab string, but items without a tab & other step
// types were writing over the CONDITION/RESPONSE vertical table line. This code uses
@@ -3196,7 +3313,13 @@ namespace Volian.Print.Library
}
}
}
if (itemInfo is StepInfo && ((itemInfo as StepInfo).MyConfig as StepConfig).Step_PreferredPagebreak) HasPrefPageBreak = true;
if (loadChildren && itemInfo.SupInfos != null)
{
SupInfoSection.ChildrenBelow.Add(cb, itemInfo.SupInfos, XOffset, 0, 0, rnoLevel, maxRNO, formatInfo);
SupInfoSection.ChildrenBelow[SupInfoSection.ChildrenBelow.Count - 1].PrefPageBreak = HasPrefPageBreak;
HasPrefPageBreak = false;
}
// Without the following, BGE had gaps in y-direction if the AER/RNO both had cautions/notes.
// The only time this needs done is if caution/notes are printed in separate columns in dual
// column mode (used the DoubleBoxHLS BGE flag for this - if another plant needs this, make it
@@ -4884,6 +5007,23 @@ namespace Volian.Print.Library
if (MyItemInfo.IsHigh) return this;
return MyParent.GetHighLevelParagraph();
}
private vlnParagraph _SupInfoSection;
public vlnParagraph SupInfoSection
{
get
{
if (_SupInfoSection == null)
{
_SupInfoSection = GetSupInfoSectionParagraph();
}
return _SupInfoSection;
}
}
private vlnParagraph GetSupInfoSectionParagraph()
{
if (MyItemInfo.IsSection) return this._SupInfoSection;
return MyParent.GetSupInfoSectionParagraph();
}
// Tab, Separator, ChangeBar, Box, Circle, Checkoff
private vlnTab _MyTab;
public vlnTab MyTab
@@ -5000,6 +5140,18 @@ namespace Volian.Print.Library
public void AdjustXOffsetForTab(ItemInfo itemInfo, int maxRNO, FormatInfo formatInfo, vlnTab myTab, float xMetaAdj)
{
if (itemInfo.IsSupInfoPart)
{
int addForTab = itemInfo.MyParent.IsCaution || itemInfo.MyParent.IsNote ? 72 : 36;
XOffset = (float)itemInfo.MyDocStyle.Layout.LeftMargin + addForTab; // add in an inch to allow for enough space for Note/Caution tab
if (myTab != null)
{
myTab.XOffset = XOffset - ((myTab == null) ? 0 : myTab.Width) - 12;
if (!itemInfo.MyParent.IsHigh && !itemInfo.MyParent.IsCaution && !itemInfo.MyParent.IsNote) myTab.Width = 2 * myTab.Width;
}
return;
}
float tabWidth = (myTab == null) ? 0 : myTab.Width;
if (itemInfo.IsStepSection)
{