From 84f415390068de9a697c6e2f50d52e4f7417f154 Mon Sep 17 00:00:00 2001 From: John Date: Fri, 26 Sep 2014 15:39:31 +0000 Subject: [PATCH] Add logic to determine if a section has one high level step and an end message to include the height of the end message when a section will not fit on a page. When determining the Page Break location in a step, verify that the item before the page break will fit on the page Add Error Log output if text is low on the page, --- PROMS/Volian.Print.Library/Pagination.cs | 20 +++++++++++++++++++- PROMS/Volian.Print.Library/vlnParagraph.cs | 1 + 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/PROMS/Volian.Print.Library/Pagination.cs b/PROMS/Volian.Print.Library/Pagination.cs index de59dee5..8659262d 100644 --- a/PROMS/Volian.Print.Library/Pagination.cs +++ b/PROMS/Volian.Print.Library/Pagination.cs @@ -160,7 +160,9 @@ namespace Volian.Print.Library bool firstSubstepExceedsSpaceAvailable = ySizeIncludingFirstStep > yWithinMargins; if (KeepStepsOnPage && firstSubstepExceedsSpaceAvailable && !isFirstChild) KeepStepsOnPage = false; - if (!KeepStepsOnPage && ySizeIncludingFirst > (yLocation - yBottomMargin)) + if (ySizeIncludingFirst == YSize) KeepStepsOnPage = false; + float ySectionEndMsg = !_skipEndMessage && MyItemInfo.IsSection && MyItemInfo.Steps != null && MyItemInfo.Steps.Count == 1 && (MyItemInfo.MyDocStyle.End.Message ?? "") != "" ? 2 * SixLinesPerInch : 0; + if (!KeepStepsOnPage && ySizeIncludingFirst + ySectionEndMsg > (yLocation - yBottomMargin)) { ShowPageBreak(4, "Page Break Before Continuous Step Section", "Yes", YSize, yPageSize, yWithinMargins, ManualPageBreak); return 1; @@ -514,6 +516,7 @@ namespace Volian.Print.Library paraBreak = FindPageBreak(yStart, ySpaceOnCurPage-accountForCalvertAlarmConditionResponseFooter, yLowerLimit, myList, lastBreak, yPageSize - (myTopMsgSpace + SixLinesPerInch) - myBottomMsgSpace, myBottomMsgSpace,MyItemInfo.ActiveFormat.PlantFormat.FormatData.StepDataList[40].ContinueOnly); + float yLoc = ySpaceOnCurPage - (paraBreak.YOffset - (YTopMost + yTop)); //Console.WriteLine("Break at {0}", paraBreak.MyItemInfo.ShortPath);//Comment Out before release //if (lastBreak != null && lastBreak.MyItemInfo.InList(80091, 1985)) // Console.WriteLine("After 80091 {0}",paraBreak.ToString()); @@ -525,6 +528,21 @@ namespace Volian.Print.Library , MyItemInfo.ItemID, MyItemInfo.MyDocVersion.MyFolder.Name, MyItemInfo.ShortPath); break; } + if (yLoc <= 0) // Check where it would break if the space on the page was one line shorter + { + vlnParagraph paraBreak2 = FindPageBreak(yStart, ySpaceOnCurPage - (SixLinesPerInch + accountForCalvertAlarmConditionResponseFooter), yLowerLimit, + myList, lastBreak, yPageSize - (myTopMsgSpace + SixLinesPerInch) - myBottomMsgSpace, + myBottomMsgSpace, MyItemInfo.ActiveFormat.PlantFormat.FormatData.StepDataList[40].ContinueOnly); + if (paraBreak2 != null && paraBreak != paraBreak2) + { + yLoc = ySpaceOnCurPage - (paraBreak2.YOffset - (YTopMost + yTop - paraBreak2.Height)); + if (paraBreak.YOffset == paraBreak2.YOffset + paraBreak2.Height) + { + //_MyLog.WarnFormat("Fix Break when no blank line {0},{1},{2}", paraBreak2.MyItemInfo.ShortPath, paraBreak2.MyItemInfo.ItemID,yLoc); + paraBreak = paraBreak2; + } + } + } if (MyItemInfo.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.WolfcreekCKLFormat) { if (!paraBreak.MyItemInfo.IsHigh // not a high level step diff --git a/PROMS/Volian.Print.Library/vlnParagraph.cs b/PROMS/Volian.Print.Library/vlnParagraph.cs index ed0f7129..2b080755 100644 --- a/PROMS/Volian.Print.Library/vlnParagraph.cs +++ b/PROMS/Volian.Print.Library/vlnParagraph.cs @@ -780,6 +780,7 @@ namespace Volian.Print.Library yPageStart = yTopMargin + YVeryTop; yLocation = yPageStart - YOffset; // yLocation is physical location from bottom of page. } + if (yLocation - Height < 24) _MyLog.WarnFormat("Very Low {0},{1},{2},{3},{4},{5}",MyItemInfo.ShortPath,MyItemInfo.ItemID,yLocation,Height,yLocation-Height,yTopMargin - MyItemInfo.MyDocStyle.Layout.PageLength); retval = Rtf2Pdf.TextAt(cb, IParagraph, XOffset, yLocation, Width, 100, DebugInfo + string.Format(",YLines = {0}",YSize/SixLinesPerInch), yBottomMargin); if (retval == 0) // problem occurred - paragraph was not able to be printed on page { // pagination logic needs to be fixed.