From 907ff47e5dda45eac998fa8130f67b49e50acd9b Mon Sep 17 00:00:00 2001 From: Rich Date: Mon, 25 Aug 2014 18:39:36 +0000 Subject: [PATCH] 1 Keep Notes/Cautions/Warnings with Condition/Response text 2 Don't break Condition/Response text before 3 lines. 3 Paginate Device and Setpoint lists properly --- PROMS/Volian.Print.Library/Pagination.cs | 79 ++++++++++++++++++++++-- 1 file changed, 73 insertions(+), 6 deletions(-) diff --git a/PROMS/Volian.Print.Library/Pagination.cs b/PROMS/Volian.Print.Library/Pagination.cs index 3e81d892..11a82fbc 100644 --- a/PROMS/Volian.Print.Library/Pagination.cs +++ b/PROMS/Volian.Print.Library/Pagination.cs @@ -78,7 +78,7 @@ namespace Volian.Print.Library // location of a pagebreak. if (MyPageHelper.ParaBreaks.Count > 0) { - if (this == MyPageHelper.ParaBreaks[0] || (!MyPageHelper.ParaBreaks[0].PageBreakOnStep && this.YTopMost > MyPageHelper.ParaBreaks[0].YTopMost)) + if (this == MyPageHelper.ParaBreaks[0] || MyPageHelper.ParaBreaks[0].CheckAlternates(this) || (!MyPageHelper.ParaBreaks[0].PageBreakOnStep && this.YTopMost > MyPageHelper.ParaBreaks[0].YTopMost)) { MyPageHelper.ParaBreaks.RemoveAt(0); //Console.WriteLine("'PageBreak',6,'Yes','Page Break within Step',{0},{1},{2},{3}, {4},'{5}'", MyItemInfo.ItemID, YSize, 0, 0, 0, MyItemInfo.ShortPath); @@ -227,7 +227,7 @@ namespace Volian.Print.Library // ResetDocStyleAndValues(ref yTopMargin, ref yBottomMargin); if (MyPageHelper.DidFirstPageDocStyle && (MyItemInfo.MyActiveSection.MyDocStyle.StructureStyle.Where & E_DocStyleUse.UseOnAllButFirstPage) > 0) yPageSizeNextPage = GetYPageSizeUseOnAllButFirstPage(); - if (!KeepWithHeader && !KeepStepsOnPage && YSize - SixLinesPerInch + yEndMsg <= yPageSizeNextPage) // if the entire step can fit on one page, do a page break + if (!KeepWithHeader && !KeepStepsOnPage && YSize - SixLinesPerInch + yEndMsg <= yPageSizeNextPage) // if the entire step can fit on one page, do a page break { // Don't want extra line before step //Console.WriteLine("'PageBreak',2,'Yes','HLS will fit on 1 Page',{0},{1},{2}, {3}, {4},'{5}'", MyItemInfo.ItemID, YSize, yPageSize, yWithinMargins, (int)(100 * yWithinMargins / yPageSize), MyItemInfo.ShortPath); @@ -370,6 +370,40 @@ namespace Volian.Print.Library return false; } } + private List _AlternateBreaks = null; + public List AlternateBreaks + { + get + { + if (_AlternateBreaks == null) + _AlternateBreaks = new List(); + return _AlternateBreaks; + } + } + private void AddAlternateBreak(vlnParagraph vp) + { + AlternateBreaks.Add(vp); + } + private bool CheckAlternates(vlnParagraph vpBrk) + { + if (_AlternateBreaks == null) return false; + foreach(vlnParagraph vp in AlternateBreaks) + if (vp.MyItemInfo.ItemID == vpBrk.MyItemInfo.ItemID) + { +// _MyLog.WarnFormat("alternate used '{0}'-'{1}'",vpBrk.MyItemInfo.ShortPath,vp.MyItemInfo.ShortPath); + return true; + } + return false; + } + private vlnParagraph FirstCRParagraph(vlnParagraph pg) + { + if (pg.HasCalvertMacro) return null; + while ( !pg.MyParent.HasCalvertMacro) + pg = pg.MyParent; + if(pg.MyItemInfo.MyPrevious == null) + return pg; + return pg.MyParent.ChildrenBelow[0]; + } private void BuildPageBreakList(float ySpaceOnCurPage, float yPageSize, bool KeepStepsOnPage) { // if this paragraph is flagged to pagebreakonstep (i.e. these are used by background documents @@ -436,10 +470,8 @@ namespace Volian.Print.Library break; } // also account for phonelist for locating bottom continue message: - float phoneListHeight = 0; if (MyItemInfo.ActiveFormat.PlantFormat.FormatData.SectData.PrintPhoneList && MyPageHelper.PhoneListHeight != 0) - phoneListHeight = MyPageHelper.PhoneListHeight; - ySpaceOnCurPage -= phoneListHeight; + myBottomMsgSpace += (MyPageHelper.PhoneListHeight - vlnPrintObject.SixLinesPerInch); string myTopMsg = docstyle.Continue.Top.Message; float myTopMsgSpace = ((myTopMsg ?? "") != "") ? 2 * SixLinesPerInch : 0; @@ -448,6 +480,7 @@ namespace Volian.Print.Library // OR there are page breaks for HLS/cautions/notes remaining, typically for backgrounds (PageBreakOnStepList.Count > 0) vlnParagraph paraBreak = null; float accountForCalvertAlarmConditionResponseFooter = 0; + //if (MyItemInfo.InList(122358,122610,125485,125613)) Console.WriteLine("here"); while (((YSize - yTop) > (ySpaceOnCurPage - accountForCalvertAlarmConditionResponseFooter)) || PageBreakOnStepList.Count > 0) { float ySpaceOnCurPageSave = ySpaceOnCurPage; @@ -467,6 +500,18 @@ namespace Volian.Print.Library } if (MyItemInfo.ActiveFormat.PlantFormat.FormatData.PrintData.SpecialCaseCalvertAlarm) // only do the following for Calvert Alarms { + if (!paraBreak.ParentHasCalvertMacro) + { + foreach (int lev in myList.Keys) + { + foreach (float y in myList[lev].Keys) + { + vlnParagraph p = myList[lev][y]; + if (p.YOffset == paraBreak.YOffset && p.MyItemInfo.ItemID != paraBreak.MyItemInfo.ItemID) + paraBreak.AddAlternateBreak(p); + } + } + } // if first condition/response and the parent has caution, notes or warnings then move the break to the caution, note or warning if (!paraBreak.MyItemInfo.IsCautionPart && !paraBreak.MyItemInfo.IsNotePart && paraBreak.ParentHasCalvertMacro && paraBreak.MyParent.HasCalvertMacro && paraBreak.MyItemInfo.MyPrevious == null && paraBreak.MyParent.ChildrenAbove.Count > 0) { @@ -477,6 +522,28 @@ namespace Volian.Print.Library { paraBreak = FindPageBreak(yStart, ySpaceOnCurPage - vlnPrintObject.SixLinesPerInch * 4, yLowerLimit, myList, paraBreak, yPageSize - (myTopMsgSpace + SixLinesPerInch) - myBottomMsgSpace, myBottomMsgSpace, MyItemInfo.ActiveFormat.PlantFormat.FormatData.StepDataList[40].ContinueOnly); + if (paraBreak.MyItemInfo.MyPrevious == null && paraBreak.MyParent.ChildrenAbove.Count > 0) + { + paraBreak = paraBreak.MyParent.ChildrenAbove[0]; + //_MyLog.WarnFormat("Keep notes and cautions with CR text {0},'{1}','{2}','{3}'", paraBreak.MyItemInfo.ItemID, paraBreak.MyItemInfo.ShortPath, paraBreak.MyItemInfo.MyProcedure.DisplayNumber, paraBreak.MyParent.MyParent.MyItemInfo.DisplayText); + } + } + if (!paraBreak.MyItemInfo.IsCautionPart && !paraBreak.MyItemInfo.IsNotePart && paraBreak.ParentHasCalvertMacro) + { + vlnParagraph pTop = FirstCRParagraph(paraBreak); + if (pTop != null && paraBreak.YOffset > pTop.YOffset && paraBreak.YOffset <= pTop.YOffset + 2 * SixLinesPerInch && pTop.MyParent != lastBreak) + { + if (pTop.MyItemInfo.MyPrevious == null && pTop.MyParent.ChildrenAbove.Count > 0) + { + paraBreak = pTop.MyParent.ChildrenAbove[0]; + //_MyLog.WarnFormat("Break at First CR Paragraph w/Notes {0},'{1}','{2}','{3}'", paraBreak.MyItemInfo.ItemID, paraBreak.MyItemInfo.ShortPath, paraBreak.MyItemInfo.MyProcedure.DisplayNumber, pTop.MyParent.MyParent.MyItemInfo.DisplayText); + } + else + { + paraBreak = pTop.MyParent; + //_MyLog.WarnFormat("Break at First CR Paragraph {0},'{1}','{2}','{3}'", paraBreak.MyItemInfo.ItemID, paraBreak.MyItemInfo.ShortPath, paraBreak.MyItemInfo.MyProcedure.DisplayNumber, pTop.MyParent.MyParent.MyItemInfo.DisplayText); + } + } } if (!paraBreak.MyItemInfo.IsCautionPart && !paraBreak.MyItemInfo.IsNotePart && paraBreak.ParentHasCalvertMacro) accountForCalvertAlarmConditionResponseFooter = 5 * SixLinesPerInch; @@ -556,7 +623,7 @@ namespace Volian.Print.Library RemoveProcessedParagraphs(myList, yTopNew - yTop); yTop = yTopNew; MyPageHelper.ParaBreaks.Add(paraBreak); - ySpaceOnCurPage = yPageSize - (myTopMsgSpace + phoneListHeight + SixLinesPerInch); // Allow for continue message and blank line. + ySpaceOnCurPage = yPageSize - (myTopMsgSpace + SixLinesPerInch); // Allow for continue message and blank line. //ySpaceOnCurPage = yPageSize - (myTopMsgSpace + SixLinesPerInch); // Allow for continue message and blank line. //if (paraBreak.YTopMost != paraBreak.YVeryTop && MyPageHelper.TopMessage == null && MyPageHelper.BottomMessage == null) // ySpaceOnCurPage = yPageSize;