From b65815bd7925e2aaddeac328f23b240fccb4e3ea Mon Sep 17 00:00:00 2001 From: Kathy Date: Wed, 2 Sep 2020 13:07:48 +0000 Subject: [PATCH] B2020-108: Pagination not always keeping parent step with table --- PROMS/Volian.Print.Library/Pagination.cs | 60 +++++++++++++++++++++++- 1 file changed, 58 insertions(+), 2 deletions(-) diff --git a/PROMS/Volian.Print.Library/Pagination.cs b/PROMS/Volian.Print.Library/Pagination.cs index f4a4d016..bc579ab9 100644 --- a/PROMS/Volian.Print.Library/Pagination.cs +++ b/PROMS/Volian.Print.Library/Pagination.cs @@ -616,7 +616,12 @@ namespace Volian.Print.Library // ShowPageBreak(6, CheckForCompression("HLS will have to split on current page"), "Special", YSize, yPageSizeNextPage, yWithinMargins, ManualPageBreak); //BuildPageBreakList(yWithinMargins + SixLinesPerInch, yPageSizeNextPage + yExtra2, KeepStepsOnPage); // Case 5 - Determine items where page break(s) occur // B2020-027: adjust for lines that may print on first page of section only, added MyPageHelper.PrintedSectionPage - BuildPageBreakList(ySpaceOnFirstPage, yPageSize + yExtra2 + MyPageHelper.PrintedSectionPage, KeepStepsOnPage, yEndMsg, doSectionTitleContinued & SectionShowTitles, false); // Case 5 - Determine items where page break(s) occur + // B2020-108: The bug itself was related to keeping a table with its parent. However compression for some pages was + // not working because onnewpage was always false in the next BuildPageBreakList call. onnewpage is used to determine compression + // (has to be on a new page to compress page). Use calculated value rather than always false in this case. + bool onnewpage = MyItemInfo.MyPrevious == null && (MyItemInfo.MyActiveSection as SectionInfo) != null + && (MyItemInfo.MyActiveSection as SectionInfo).IsSeparatePagination(); + BuildPageBreakList(ySpaceOnFirstPage, yPageSize + yExtra2 + MyPageHelper.PrintedSectionPage, KeepStepsOnPage, yEndMsg, doSectionTitleContinued & SectionShowTitles, onnewpage); // Case 5 - Determine items where page break(s) occur // ooooo ooooo ooooo .oooooo..o .oooooo..o oooo o8o . .oooooo. . // `888' `888' `888' d8P' `Y8 d8P' `Y8 `888 `"' .o8 d8P' `Y8b .o8 // 888 888 888 Y88bo. Y88bo. oo.ooooo. 888 oooo .o888oo 888 oooo oooo oooo d8b oooo d8b .ooooo. ooo. .oo. .o888oo @@ -1447,6 +1452,35 @@ namespace Volian.Print.Library return true; return false; } + // B2020-108: Original FindPageBreak was renamed to FindPageBreak1 so that an additional check can be made after + // the page break is found. Check if the location identified is a parent of a table that is too long to allow parent to fit + // on the same page, if so break at the table rather than the parent. + private static vlnParagraph FindPageBreak(float yStart, float yUpperLimit, float yLowerLimit, StepLevelList myList, vlnParagraph lastBreak, float fullPage, + float myBottomMsgSpace, bool RNOContinueOnly, float yTop) + { + vlnParagraph myPara = FindPageBreak1(yStart, yUpperLimit, yLowerLimit, myList, lastBreak, fullPage, myBottomMsgSpace, RNOContinueOnly, yTop); + float yLocation = GetYLocationFromMyList(myPara, myList); + float spaceOnPage = yUpperLimit + yLocation; + if (myPara.YSize > spaceOnPage && myPara.ChildrenBelow != null && myPara.ChildrenBelow.Count > 0 + && myPara.ChildrenBelow[0].MyItemInfo.IsTable && spaceOnPage > 0) + { + vlnParagraph tpara = myPara.ChildrenBelow[0] as vlnParagraph; + if (tpara.YSize + myPara.Height > yUpperLimit) return tpara; + } + return myPara; + } + private static float GetYLocationFromMyList(vlnParagraph myPara, StepLevelList myList) + { + foreach (int stepLevel in myList.Keys) // loop thru StepLevels, starting with lowest. + { + foreach (float yLocation in myList[stepLevel].Keys) // loop thru yLocation + { + vlnParagraph pg = myList[stepLevel][yLocation]; + if (pg == myPara) return -yLocation; + } + } + return 0; + } /// /// Finds the highest StepLevel (lowest StepLevel number, 0 = HLS, 1 = first substep) that /// fills the page sufficiently (more than half-full) @@ -1455,7 +1489,7 @@ namespace Volian.Print.Library /// /// /// - private static vlnParagraph FindPageBreak(float yStart, float yUpperLimit, float yLowerLimit, StepLevelList myList, vlnParagraph lastBreak, float fullPage, + private static vlnParagraph FindPageBreak1(float yStart, float yUpperLimit, float yLowerLimit, StepLevelList myList, vlnParagraph lastBreak, float fullPage, float myBottomMsgSpace,bool RNOContinueOnly, float yTop) { vlnParagraph minPara = null; @@ -1464,6 +1498,28 @@ namespace Volian.Print.Library vlnParagraph minPara2 = null; float? yLocationMin2=null; float yAddForBtmMsg = 0; + // useful for debugging pagination issues, lastbreak gets the paragraph at the top of the previous page, shows all + // of the locations within 'range' on the next page. + //if (lastBreak != null && lastBreak.MyItemInfo.InList(72481)) + //{ + // int range = 120; + // Console.WriteLine("lastBreak = {0}, {1}", yUpperLimit, lastBreak); + // foreach (int stepLevel in myList.Keys) // loop thru StepLevels, starting with lowest. + // { + // foreach (float yLocation in myList[stepLevel].Keys) // loop thru yLocation + // { + // if (-yLocation > yUpperLimit - range && -yLocation <= yUpperLimit + range) + // { + // vlnParagraph pg = myList[stepLevel][yLocation]; + // if (pg.PartsAbove != null && pg.PartsAbove.Count > 0) + // Console.WriteLine("{0}\t{1}\t{2}\t{3}\t{4}\t\"{5}\"", stepLevel, yUpperLimit + yLocation, (yUpperLimit + yLocation) - pg.Height, pg.YOffset, (pg.PartsAbove[0] as vlnPrintObject).YOffset, pg); + // else + // Console.WriteLine("{0}\t{1}\t{2}\t\"{3}\"", stepLevel, yUpperLimit + yLocation, (yUpperLimit + yLocation) - pg.Height, pg); + + // } + // } + // } + //} foreach (int stepLevel in myList.Keys) // loop thru StepLevels, starting with lowest. { foreach (float yLocation in myList[stepLevel].Keys) // loop thru yLocation