diff --git a/PROMS/Volian.Print.Library/Pagination.cs b/PROMS/Volian.Print.Library/Pagination.cs index 5b2153c0..f62ea945 100644 --- a/PROMS/Volian.Print.Library/Pagination.cs +++ b/PROMS/Volian.Print.Library/Pagination.cs @@ -99,7 +99,6 @@ namespace Volian.Print.Library } else if (MyItemInfo.MyDocStyle.SupplementalInformation && MyItemInfo.IsStep) { - //if (MyItemInfo.IsHigh && MyItemInfo.MyPrevious == null) return 1; // appears we don't need this line any more Forced Pagination on OR substep Ginna SAG-8 Step 1 jsj/RHM 05-19-2017 StepConfig sci = MyItemInfo.MyConfig as StepConfig; if (sci.Step_PreferredPagebreak) { @@ -765,6 +764,7 @@ namespace Volian.Print.Library ParagraphLocations myLocations = new ParagraphLocations(); BuildLocationList(YTopMost, myLocations); StepLevelList myList = myLocations.BuildStepLevelList(KeepStepsOnPage); + SortedList myPreferredBreaks = GetMyPreferredBreaks(myList); // Find Break Locations in the list based upon StepLevel and yLocation float yTop = 0; float yLowerLimit = (yPageSize - 2 * SixLinesPerInch) / 2; @@ -871,9 +871,17 @@ namespace Volian.Print.Library if (PageBreakOnStepList.Count > 0 && (PageBreakOnStepList[0].YTop - (lastBreak == null ? 0 : lastBreak.YTop) <= ySpaceOnCurPage)) paraBreak = PageBreakOnStepList[0]; else + { paraBreak = FindPageBreak(yStart, ySpaceOnCurPage - accountForCalvertAlarmConditionResponseFooter - yAccountForBottomMsg, yLowerLimit, myList, lastBreak, yPageSize - (myTopMsgSpace + SixLinesPerInch) - myBottomMsgSpace, myBottomMsgSpace, MyItemInfo.ActiveFormat.PlantFormat.FormatData.StepDataList[40].ContinueOnly); + // B2017-109: for supplemental information, if there is a preferred page break, account for it. + if (myPreferredBreaks != null && myPreferredBreaks.Count > 0 && myPreferredBreaks.Keys[0] < paraBreak.YOffset) + { + paraBreak = myPreferredBreaks[myPreferredBreaks.Keys[0]]; + myPreferredBreaks.RemoveAt(0); + } + } yAccountForBottomMsg = 0; // Do Not Remove: The following is used for debug - useful place to debug //if (paraBreak.MyItemInfo.InList(207, 211, 214, 219, 221, 216, 197)) Console.WriteLine("BUILD2: Break at {0}", paraBreak.MyItemInfo.ShortPath);//Comment Out before release @@ -1194,6 +1202,30 @@ namespace Volian.Print.Library ProfileTimer.Pop(profileDepth); } + // The following finds all of the preferred page breaks for this step & if found adds them to a + // list of the location & the paragraph it is on. This is used so that pagination calculations + // occur for steps following the preferred page break rather than starting on the page after + // substep with preferred page break (B207-109) + private SortedList GetMyPreferredBreaks(StepLevelList myList) + { + if (!MyItemInfo.MyDocStyle.SupplementalInformation) return null; + SortedList sdpara = null; + foreach (int stepLevel in myList.Keys) // loop thru StepLevels, starting with lowest. + { + foreach (float yLocation in myList[stepLevel].Keys) // loop thru yLocation + { + vlnParagraph myPara = myList[stepLevel][yLocation]; + StepConfig sci = myPara.MyItemInfo.MyConfig as StepConfig; + if (sci != null && sci.Step_PreferredPagebreak) + { + if (sdpara == null) sdpara = new SortedList(); + sdpara.Add(-yLocation, myPara); + } + } + } + return sdpara; + } + private float GetBottomContinueMessageSize(DocStyle docstyle) { float myBottomMsgSpace = 0; diff --git a/PROMS/Volian.Print.Library/vlnParagraph.cs b/PROMS/Volian.Print.Library/vlnParagraph.cs index c644bbab..a754f8f0 100644 --- a/PROMS/Volian.Print.Library/vlnParagraph.cs +++ b/PROMS/Volian.Print.Library/vlnParagraph.cs @@ -1552,7 +1552,6 @@ namespace Volian.Print.Library // if this has a caution/note with supinfo, that is id that needs to go in pagination list, unless it is in there. int aboveSupinfoId = ChildrenAboveHaveSupInfo(); if (supInfoSect.StepSectPageBreaksForSupInfo.Contains(aboveSupinfoId)) aboveSupinfoId = -1; - supInfoSect.StepSectPageBreaks.Add(aboveSupinfoId!=-1?ItemInfo.Get(aboveSupinfoId).MyParent.ItemID:MyItemInfo.ItemID); supInfoSect.StepSectPageBreaksForSupInfo.Add(aboveSupinfoId!=-1?aboveSupinfoId:MyItemInfo.SupInfos[0].ItemID); MyPromsPrinter.NeedSupInfoBreak = false; } @@ -2185,35 +2184,66 @@ namespace Volian.Print.Library private int GetIdThatHasSupInfoItems(ItemInfo ii, int startid) { if (ii == null) return -1; + // if this item has supinfo, return its id if (ii.SupInfos != null && ii.SupInfos.Count > 0) return ii.SupInfos[0].ItemID; + + // see if any substeps of this item have supinfo, and if so, return the substep's id int id = GetSubThatHasSupInfoItems(ii, startid); if (id != -1) return id; + + // Now go to the next item, check if it or any of its substeps have supinfo, and if so, return the id ItemInfo sib = ii.NextItem; - while (sib != null) + id = GetIdThatHasSupInfoItemsSibNext(sib, startid); + if (id != -1) return id; + + // Go to the parent, and find its next and check if it or any of its substeps or next steps or any of their substeps have supinfo, + // and if so, return the id. + ItemInfo par = ii.MyParent; + if (!par.IsSection && par.NextItems != null && par.NextItems.Count > 0) + { + par = par.NextItem; + while (par != null && !par.IsSection) + { + id = GetIdThatHasSupInfoItemsSibNext(par, startid); + if (id != -1) return id; + par = par.MyParent; + if (!par.IsSection && par.NextItems != null && par.NextItems.Count > 0) par = par.NextItem; + else return -1; + } + } + return -1; + } + + private int GetIdThatHasSupInfoItemsSibNext(ItemInfo ii, int startid) + { + int id = -1; + while (ii != null) { SectionInfo supInfoSect = ii.MyActiveSection as SectionInfo; - if (supInfoSect.StepSectPageBreaks.Contains(sib.ItemID)) return -1; - if (sib.SupInfos != null && sib.SupInfos.Count > 0) + // if there is a pagebreak on this step section step, quit looking for supinfos. The + // break has to occur here. + if (supInfoSect.StepSectPageBreaks.Contains(ii.ItemID)) return -1; + if (ii.SupInfos != null && ii.SupInfos.Count > 0) { // check if this is in the list of page breaks for supinfos, if not it may have one of its cautions/notes rather than its id: - if (!supInfoSect.StepSectPageBreaksForSupInfo.Contains(sib.SupInfos[0].ItemID)) + if (!supInfoSect.StepSectPageBreaksForSupInfo.Contains(ii.SupInfos[0].ItemID)) { - if (sib.Cautions != null) + if (ii.Cautions != null) { - foreach (ItemInfo caution in sib.Cautions) + foreach (ItemInfo caution in ii.Cautions) if (caution.SupInfos != null && caution.SupInfos.Count > 0 && supInfoSect.StepSectPageBreaksForSupInfo.Contains(caution.SupInfos[0].ItemID)) return caution.SupInfos[0].ItemID; } - if (sib.Notes != null) + if (ii.Notes != null) { - foreach (ItemInfo note in sib.Notes) + foreach (ItemInfo note in ii.Notes) if (note.SupInfos != null && note.SupInfos.Count > 0 && supInfoSect.StepSectPageBreaksForSupInfo.Contains(note.SupInfos[0].ItemID)) return note.SupInfos[0].ItemID; } } - return sib.SupInfos[0].ItemID; + return ii.SupInfos[0].ItemID; } - id = GetSubThatHasSupInfoItems(sib, startid); + id = GetSubThatHasSupInfoItems(ii, startid); if (id != -1) return id; - sib = sib.NextItem; + ii = ii.NextItem; } return -1; }