FNP: ResetDocStyles for sections that changed the top margin; don’t print ‘.0’ in bottom continue message; fix text overwrite of RNO & following caution/note that spans x direction of page; x-offset improvements (still needs work)

This commit is contained in:
Kathy Ruffing 2013-11-20 13:39:12 +00:00
parent 136905792c
commit 7824091484

View File

@ -67,7 +67,7 @@ namespace Volian.Print.Library
// by the first level of children. The data for the column is the child of the column header.
// Sometimes the column will not have data, the following handles that case. Also, use
// the boolean didComponentTableRow to keep track of the bottom most yoff of the table row.
if ((childItemInfo.ActiveFormat.PlantFormat.FormatData.ComponentTableFormat) && childItemInfo.MyParent.IsInTemplate())
if ((childItemInfo.MyDocStyle.ComponentList) && childItemInfo.MyParent.IsInTemplate())
{
// childItemInfo = 'child' and set to use a template for defining size.
if (childItemInfo.Steps == null)
@ -174,7 +174,7 @@ namespace Volian.Print.Library
{
if (childItemInfo is SectionInfo) formatInfo = (childItemInfo as SectionInfo).LocalFormat ?? formatInfo;
if (rnoLevel < maxRNO && childItemInfo.RNOs != null) yoff = Math.Max(yoff, yoffRight);
vlnParagraph para = new vlnParagraph(Parent, cb, childItemInfo, xoff, yoff, rnoLevel, maxRNO, formatInfo, null, null);
vlnParagraph para = new vlnParagraph(Parent, cb, childItemInfo, xoff, yoff, rnoLevel, maxRNO, formatInfo, null, null, yoffRight);
// if doing the component list (FNP), keep track of the bottom most columns' data
// so this can be returned after the row is done.
@ -192,7 +192,7 @@ namespace Volian.Print.Library
// if doing the component list (FNP), yoff for the HLS (if it's the component in the list,
// i.e. the leftmost item in the table), the yoff is either the HLS bottom, or the bottom most
// of all of the other columns' data.
else if (childItemInfo.IsHigh && childItemInfo.FormatStepData.UseOldTemplate && formatInfo.PlantFormat.FormatData.ComponentTableFormat)
else if (childItemInfo.IsHigh && childItemInfo.FormatStepData.UseOldTemplate && childItemInfo.MyDocStyle.ComponentList)
yoff = Math.Max(para.YBottom, para.YBottomMost) + vlnPrintObject.SixLinesPerInch;
// increment the y offset if not doing the ComponentTableFormat
else if (!para.UseTemplateKeepOnCurLine(childItemInfo))
@ -760,7 +760,7 @@ namespace Volian.Print.Library
float yLocalypagestart = yPageStart;
// yPageStart is offset into roll; YTopMost is offset of topmost of this paragraph.
float yLocation = yPageStart - YTopMost;
DebugText.WriteLine("ToPdf1:{0},'{1}',{2},{3},{4},{5}", MyItemInfo.ItemID, MyItemInfo.ShortSearchPath, XOffset, yLocation, yPageStart, YTopMost);
DebugText.WriteLine("ToPdf1:{0},'{1}',{2},{3},{4},{5}", MyItemInfo.ItemID, MyItemInfo.ShortPath, XOffset, yLocation, yPageStart, YTopMost);
int paginate = Paginate(yLocation, yTopMargin, yBottomMargin);
bool firstHighLevelStep = MyItemInfo.IsHigh && (MyItemInfo.MyPrevious == null);
bool doSectionTitleContinued = false; // will add " Continued" to the section title if format flag is set
@ -778,7 +778,14 @@ namespace Volian.Print.Library
OutputOtherPageSteps(cb, YTopMost, yPageStart, yTopMargin, yBottomMargin);
cb.PdfDocument.NewPage();
//_MyLog.InfoFormat("NewPage 10 {0}", cb.PdfWriter.CurrentPageNumber);
if (MyItemInfo.IsSection || (MyItemInfo.IsHigh && MyItemInfo.MyPrevious != null)) //do not reset for 1st step
if (MyItemInfo.IsSection && MyParent != null && MyParent.MyItemInfo.IsSection && (MyItemInfo as SectionInfo).IsSeparatePagination())
{
RefreshDocStyle();
yTopMargin = 792 - (float)MyItemInfo.MyActiveSection.MyDocStyle.Layout.TopMargin;
yBottomMargin = Math.Max(0, yTopMargin - (float)MyItemInfo.MyActiveSection.MyDocStyle.Layout.PageLength);
yPageStart = yTopMargin;
}
else if (MyItemInfo.IsSection || (MyItemInfo.IsHigh && MyItemInfo.MyPrevious != null)) //do not reset for 1st step
ResetDocStyleAndValues(ref yTopMargin, ref yBottomMargin);
DebugText.WriteLine("Paginate1");
if (MyItemInfo.IsSection)
@ -815,18 +822,27 @@ namespace Volian.Print.Library
string myMsg = docstyle.Continue.Bottom.Message;
if (myMsg != null && myMsg != "")
{
if (myMsg.IndexOf(@"%d") > -1)
myMsg = myMsg.Replace(@"%d", MyItemInfo.MyHLS.MyTab.CleanTextNoSymbols.Trim());
if (myMsg.IndexOf(@"%0d") > -1)
myMsg = myMsg.Replace(@"%0d", MyItemInfo.MyHLS.MyTab.CleanTextNoSymbols.Trim(" .".ToCharArray()));
if (myMsg.IndexOf(@"%2d") > -1)
myMsg = myMsg.Replace(@"%2d", MyItemInfo.MyHLS.MyTab.CleanTextNoSymbols.Trim(" .".ToCharArray()).PadLeft(2));
myMsg = ReplaceStepBottomContinue(myMsg);
float msg_yLocation = 0;
if (myMsg.Contains("{par}"))
{
myMsg = myMsg.Replace("{par}", "");
msg_yLocation = -SixLinesPerInch;
}
float yBtmMarginForMsg = yBottomMargin;
// one of the format flags for FNP had an adjustment for printing the section title only
// on the first page of the section. Adjust the location of the bottom continue message
// if this adjustment was made (the current topmargin may not reflect the value within
// the document style)
if (MyPageHelper.PrintedSectionPage > 0)
{
if ((MyItemInfo.MyActiveSection.MyDocStyle.StructureStyle.Style & E_DocStructStyle.DSS_PrintSectOnFirst) == E_DocStructStyle.DSS_PrintSectOnFirst)
{
float localYTopMargin = 792 - (float)MyItemInfo.MyActiveSection.MyDocStyle.Layout.TopMargin;
yBtmMarginForMsg = Math.Max(0, localYTopMargin - (float)MyItemInfo.MyActiveSection.MyDocStyle.Layout.PageLength);
}
}
switch (docstyle.Continue.Bottom.Location)
{
case E_ContBottomLoc.EndOfText: // place continue string at end of text
@ -837,7 +853,7 @@ namespace Volian.Print.Library
break;
case E_ContBottomLoc.BottomOfPage: // place continue message at bottom of page
//msg_yLocation = yBottomMargin + 2 * SixLinesPerInch + (float)docstyle.Layout.FooterLength; // 2 lines above bottom margin
msg_yLocation = msg_yLocation + yBottomMargin + (float)docstyle.Layout.FooterLength;
msg_yLocation = msg_yLocation + yBtmMarginForMsg + (float)docstyle.Layout.FooterLength;
break;
default:
Console.WriteLine("**** BOTTOM CONTINUE MESSAGE NOT CODED*****");
@ -905,7 +921,7 @@ namespace Volian.Print.Library
// Now check if this is a template type step & if so, add the HLS's prefix/suffix to it.
if (MyItemInfo.MyHLS != null && MyItemInfo.MyHLS.FormatStepData.UseSmartTemplate)
{
vlnParagraph smartPara = new vlnParagraph(MyParent.MyParent, cb, MyItemInfo.MyHLS, MyParent.XOffset, 0, 0, 0, MyParent.MyItemInfo.ActiveFormat, null, " (Continued)");
vlnParagraph smartPara = new vlnParagraph(MyParent.MyParent, cb, MyItemInfo.MyHLS, MyParent.XOffset, 0, 0, 0, MyParent.MyItemInfo.ActiveFormat, null, " (Continued)", 0);
float mytmpfloat = smartPara.ParagraphToPdf(cb, smartPara.Height, yTopMargin, yBottomMargin); // .ToPdf(cb, 0, yTopMargin, yBottomMargin);
yPageStart -= smartPara.Height;
}
@ -959,7 +975,7 @@ namespace Volian.Print.Library
// format must have ContinueSectinHeader format flag set to true
if (doSectionTitleContinued)
{
vlnParagraph sectContPara = new vlnParagraph(MyParent.MyParent, cb, MyItemInfo.ActiveSection, MyParent.XOffset, 0, 0, 0, MyParent.MyItemInfo.ActiveFormat, null, " (Continued)");
vlnParagraph sectContPara = new vlnParagraph(MyParent.MyParent, cb, MyItemInfo.ActiveSection, MyParent.XOffset, 0, 0, 0, MyParent.MyItemInfo.ActiveFormat, null, " (Continued)", 0);
float mytmpfloat = sectContPara.ParagraphToPdf(cb, yTopMargin, yTopMargin, yBottomMargin);
yPageStart -= sectContPara.Height * 2;
}
@ -1027,6 +1043,29 @@ namespace Volian.Print.Library
if (yLocalypagestart != yPageStart) DebugText.WriteLine("ToPdf-yPagestartDiff:{0},{1},{2},{3}", MyPageHelper.MyPdfContentByte.PdfWriter.CurrentPageNumber, MyItemInfo.ItemID, yLocalypagestart, yPageStart);
return yPageStart;
}
private void RefreshDocStyle()
{
MyItemInfo.ActiveSection = null;
MyItemInfo.MyDocStyle = null;
MyPageHelper.MySection = MyItemInfo as SectionInfo;
MyPageHelper.ResetSvg();
MyPageHelper.PrintedSectionPage = 0;
}
private string ReplaceStepBottomContinue(string myMsg)
{
string tb = MyItemInfo.MyHLS.MyTab.CleanTextNoSymbols;
// if the tab ends with .0, remove it if it was added because of the virtualdotinhls flag.
if (MyItemInfo.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.StepSectionLayoutData.VirtualDotInHLSTab && tb.Contains(".0")) tb = tb.Replace(".0", "");
if (myMsg.IndexOf(@"%d") > -1)
myMsg = myMsg.Replace(@"%d", tb.Trim());
if (myMsg.IndexOf(@"%0d") > -1)
myMsg = myMsg.Replace(@"%0d", tb.Trim(" .".ToCharArray()));
if (myMsg.IndexOf(@"%2d") > -1)
myMsg = myMsg.Replace(@"%2d", tb.Trim(" .".ToCharArray()).PadLeft(2));
return myMsg;
}
private vlnParagraph TopMostChild
{
get
@ -1234,7 +1273,7 @@ namespace Volian.Print.Library
if (itm.FormatStepData != null && (itm.FormatStepData.Index == 42 || itm.FormatStepData.Index == 43)) return true;
return false;
}
public vlnParagraph(vlnParagraph parent, PdfContentByte cb, ItemInfo itemInfo, float xoff, float yoff, int rnoLevel, int maxRNO, FormatInfo formatInfo, string prefix, string suffix)
public vlnParagraph(vlnParagraph parent, PdfContentByte cb, ItemInfo itemInfo, float xoff, float yoff, int rnoLevel, int maxRNO, FormatInfo formatInfo, string prefix, string suffix, float yoffRightParent)
{
ShowSectionTitles = formatInfo.PlantFormat.FormatData.SectData.StepSectionData.StepSectionLayoutData.ShowSectionTitles || itemInfo.MyDocStyle.ShowSectionTitles;
if (itemInfo.IsSection && itemInfo.ActiveSection.DisplayText.ToUpper().Contains("<NO TITLE>") && !itemInfo.ActiveFormat.PlantFormat.FormatData.ProcData.PrintNoTitle) ShowSectionTitles = false;
@ -1257,15 +1296,13 @@ namespace Volian.Print.Library
if (MyTopRNO != null) MyTopRNO.LastRNO = this;
}
MyContentByte = cb;
if (!MyPageHelper.MyParagraphs.ContainsKey(itemInfo.ItemID)) MyPageHelper.MyParagraphs.Add(itemInfo.ItemID, this);
if (itemInfo.IsSection && itemInfo.MyParent.IsSection)
{
itemInfo.ActiveSection = null;
itemInfo.MyDocStyle = null;
MyPageHelper.MySection = itemInfo as SectionInfo;
MyPageHelper.ResetSvg();
}
MyItemInfo = itemInfo;
if (!MyPageHelper.MyParagraphs.ContainsKey(itemInfo.ItemID)) MyPageHelper.MyParagraphs.Add(itemInfo.ItemID, this);
// if this a continuous subsection, refresh the style.
if (itemInfo.IsSection && !(itemInfo as SectionInfo).IsSeparatePagination() && itemInfo.MyParent.IsSection)
RefreshDocStyle();
XOffset = xoff;
if (!MyItemInfo.IsStep && !MyItemInfo.IsStepSection)
{
@ -1298,7 +1335,11 @@ namespace Volian.Print.Library
bool doprint = true;
if (itemInfo.IsSection)
{
if (ShowSectionTitles
MyItemInfo.ActiveSection = null;
MyItemInfo.MyDocStyle = null;
DocStyle ds = MyItemInfo.MyDocStyle;
if (!ds.ComponentList && ShowSectionTitles
&& !MyItemInfo.MyDocStyle.CancelSectTitle
&& !MyItemInfo.MyDocStyle.SpecialStepsFoldout) // Don't ouput the Step Section title
{
@ -1371,7 +1412,7 @@ namespace Volian.Print.Library
vlnParagraph hls = GetHighLevelParagraph();
float RnoOffset1 = ToInt(formatInfo.MyStepSectionLayoutData.ColRTable, maxRNO);
float offset = hls.Width + RnoOffset1 + hls.XOffset;
vlnTab tb = hls.PartsLeft[0] as vlnTab;
vlnTab tb = hls.MyTab;
//offset += tb.Width;
if (MyTopRNO == null)
Width -= (float)itemInfo.ActiveFormat.MyStepSectionLayoutData.SingleColumnRNOIndent;
@ -1410,8 +1451,14 @@ namespace Volian.Print.Library
if (itemInfo.ActiveFormat.MyStepSectionLayoutData.Dev_Format)
yoffLeft = Math.Max(yoffLeft, ChildrenLeft.Add(cb, itemInfo.Notes, xoff + 6 + (float)(itemInfo.ActiveFormat.MyStepSectionLayoutData.WidT), yoff, yoff, rnoLevel, maxRNO, formatInfo));
else
{
// Notes/Cautions span the page. If the right (RNO) column is below current yoff, use the
// yoff from this. Without this, an overlap of text between the note and the bottom of the
// RNO was occurring for FNP - Unit 2/AOP, AOP-4.0.
if (yoffRightParent > yoff) yoff = yoffRightParent;
yoff = ChildrenAbove.Add(cb, itemInfo.Notes, xoff, yoff, yoff, rnoLevel, maxRNO, formatInfo);
}
}
// Comanche Peak uses CAUTION2 type to enter a Step Designator, which is placed to the left of the step number.
// The Step Designator information is saved during the processing of the Cautions (ChildrenAbove)
// defined in the vlnParagraphs class (of which ChildrenAbove is defined)
@ -1628,7 +1675,7 @@ namespace Volian.Print.Library
}
// If checklists, the substeps are printed in a row, need to keep track of the 'longest' in
// y direction (bottommost) across the row.
if (itemInfo.IsStep && itemInfo.MyHLS != null && (itemInfo.MyHLS.FormatStepData.UseSmartTemplate || (itemInfo.MyHLS.FormatStepData.UseOldTemplate && itemInfo.ActiveFormat.PlantFormat.FormatData.ComponentTableFormat)) && (TheStepLevel(itemInfo) >= 0))
if (itemInfo.IsStep && itemInfo.MyHLS != null && (itemInfo.MyHLS.FormatStepData.UseSmartTemplate || (itemInfo.MyHLS.FormatStepData.UseOldTemplate && itemInfo.MyDocStyle.ComponentList)) && (TheStepLevel(itemInfo) >= 0))
savCheckListBottomMost = yoff + Height + (itemInfo.MyHLS.FormatStepData.UseSmartTemplate ? SixLinesPerInch : 0);
// Get Y offset for regular steps, or if section title is output or if not within row (not last column of
// text) for wcn checklist, i.e.
@ -1690,8 +1737,13 @@ namespace Volian.Print.Library
float yOffRight = yoff;
float RnoOffset = ToInt(formatInfo.MyStepSectionLayoutData.ColRTable, maxRNO);
if (rnoLevel < maxRNO && itemInfo.RNOs != null)
yOffRight = ChildrenRight.Add(cb, itemInfo.RNOs, XOffset + RnoOffset, YTop, YTop, rnoLevel + 1, maxRNO, formatInfo);
{
float tmpXoff = XOffset;
// if there is an RNO off of a substep at a level deeper than 1, use the parent's xoffset
// otherwise the Xoffset of the RNO is too far to the right.
if (((itemInfo.RNOs[0].FormatStepData.AdjHighLevelTab ?? 0) != 0) && itemInfo.PrintLevel > 1) tmpXoff = MyParent.XOffset;
yOffRight = ChildrenRight.Add(cb, itemInfo.RNOs, tmpXoff + RnoOffset, YTop, YTop, rnoLevel + 1, maxRNO, formatInfo);
}
// Need code to determine if the table will overlap the Right Column if it does then
// use YOffRight rather than yoff
if (itemInfo.Tables != null)
@ -2320,6 +2372,25 @@ namespace Volian.Print.Library
return MyParent.GetHighLevelParagraph();
}
// Tab, Separator, ChangeBar, Box, Circle, Checkoff
private vlnTab _MyTab;
public vlnTab MyTab
{
get
{
if (_MyTab == null)
{
foreach (vlnPrintObject po in PartsLeft)
{
if (po is vlnTab)
{
_MyTab = po as vlnTab;
break;
}
}
}
return _MyTab;
}
}
private vlnPrintObjects _PartsAbove;
public vlnPrintObjects PartsAbove
{
@ -2594,6 +2665,13 @@ namespace Volian.Print.Library
// if format had a tab adjustment for step type, use it
if (itemInfo.MyTab != null && itemInfo.MyTab.Offset != 0)
{
// The following is an attempt to fix FNP xoffsets - it is still under development:
//float xOffTabNew = MyParent.MyTab != null ? MyParent.MyTab.XOffset : MyParent.XOffset + itemInfo.MyTab.Offset;
//xOffTabNew += MyParent.MyTab == null ? 0 : MyParent.MyTab.TabOffset;
//float xIncrement = xOffTabNew - MyTab.XOffset;
//myTab.XOffset += xIncrement;
//XOffset += xIncrement;
//Width -= xIncrement;
myTab.XOffset -= itemInfo.MyTab.Offset;
XOffset -= itemInfo.MyTab.Offset;
Width += itemInfo.MyTab.Offset;
@ -2752,7 +2830,7 @@ namespace Volian.Print.Library
// with it (there may be empty cells at end).
public bool UseTemplateKeepOnCurLine(ItemInfo itemInfo)
{
if (!itemInfo.IsStep || !itemInfo.ActiveFormat.PlantFormat.FormatData.ComponentTableFormat) return false;
if (!itemInfo.IsStep || !itemInfo.MyDocStyle.ComponentList) return false;
if (itemInfo.MyHLS.FormatStepData.UseOldTemplate) return true;
return false;
}
@ -2760,7 +2838,7 @@ namespace Volian.Print.Library
{
if (!itemInfo.IsStep) return false;
if (itemInfo.MyHLS.FormatStepData.UseSmartTemplate) return false;
if (!itemInfo.ActiveFormat.PlantFormat.FormatData.ComponentTableFormat) return false;
if (!itemInfo.MyDocStyle.ComponentList) return false;
if (itemInfo.MyHLS.FormatStepData.UseOldTemplate)
{
ItemInfo useForTemplate = itemInfo.IsHigh?itemInfo:itemInfo.MyParent;
@ -2774,7 +2852,7 @@ namespace Volian.Print.Library
{
int topIndx = itemInfo.GetSmartTemplateTopLevelIndx();
int tmplIndx = 0;
if (itemInfo.ActiveFormat.PlantFormat.FormatData.ComponentTableFormat && !itemInfo.IsHigh)
if (itemInfo.MyDocStyle.ComponentList && !itemInfo.IsHigh)
{
// The ComponentTable format (FNP component table as one example), uses a template
// where the items in the template below the HLS are all paragraphs (the intermediate steps