Change DebugPagination format for forced pagination output.

Added DebugPagination output if a location cannot be found to break a step over pages.
Changed pagination logic when a logical location cannot be found, to location the maximum location on the page for a break to occur.  For example, if a table is too large to fit on the current page, the pagination can move that table to the next page.
This commit is contained in:
Rich 2014-02-18 17:06:52 +00:00
parent bc69a84d33
commit 67a088f505

View File

@ -234,6 +234,23 @@ namespace Volian.Print.Library
// TODO: Put this line back to case 0, i.e. previous line. This fixes a 16-bit vs 32-bit pagination diff in EO30 Step 20. // TODO: Put this line back to case 0, i.e. previous line. This fixes a 16-bit vs 32-bit pagination diff in EO30 Step 20.
//float myFirstPieceSize = GetFirstPieceSize() + 2 * SixLinesPerInch; //Case 10 - this is to match 16bit //float myFirstPieceSize = GetFirstPieceSize() + 2 * SixLinesPerInch; //Case 10 - this is to match 16bit
//is the amount of space left (yWithinMargins) is greater than 1/2 of the current page (yPageSize / 2): //is the amount of space left (yWithinMargins) is greater than 1/2 of the current page (yPageSize / 2):
// VCS EOP-4.3 Step 15
// ***** Adjust yWithinMargins for the bottom continue message
//DocStyle docstyle = MyItemInfo.MyDocStyle;
//string myBottomMsg = docstyle.Continue.Bottom.Message;
//float myBottomMsgSpace = ((myBottomMsg ?? "") != "") ? 2 * SixLinesPerInch : 0;
//switch (docstyle.Continue.Bottom.Location)
//{
// case E_ContBottomLoc.BottomOfPage: // place continue message at bottom of page
// // The following format flag was added for FNP, without the flag (which stops the reset of BottomMsgSpace)
// // a number of FNP procedures had overwritten steps/bottom continue message. An example can be
// // found in FNP = SAMGS;FNP-1-SACRG-2, step 1.
// if (!docstyle.Continue.Bottom.NoOverrideSpace)
// myBottomMsgSpace = 0;
// break;
//}
//float yWithinMarginsCM = yWithinMargins - myBottomMsgSpace;
//// **** Adjust yWithinMargins for the bottom continue message
if (KeepWithHeader ||( !ManualPageBreak && ((MyItemInfo.ActiveFormat.MyStepSectionLayoutData.SpecialPageBreakFlag && yWithinMargins > yPageSize / 2 && if (KeepWithHeader ||( !ManualPageBreak && ((MyItemInfo.ActiveFormat.MyStepSectionLayoutData.SpecialPageBreakFlag && yWithinMargins > yPageSize / 2 &&
myFirstPieceSize < yWithinMargins) || KeepStepsOnPage))) myFirstPieceSize < yWithinMargins) || KeepStepsOnPage)))
{ {
@ -309,7 +326,7 @@ namespace Volian.Print.Library
//_MyLog.ErrorFormat("<<< ERROR >>> Forced Pagination - ItemID = {0}\r\nLocation = '{1}'", MyItemInfo.ItemID, MyItemInfo.ShortPath); //_MyLog.ErrorFormat("<<< ERROR >>> Forced Pagination - ItemID = {0}\r\nLocation = '{1}'", MyItemInfo.ItemID, MyItemInfo.ShortPath);
_MyLog.ErrorFormat("<<< ERROR >>> Forced Pagination\r\n==>'Forced Pagination',{0},'{1}','{2}'" _MyLog.ErrorFormat("<<< ERROR >>> Forced Pagination\r\n==>'Forced Pagination',{0},'{1}','{2}'"
, MyItemInfo.ItemID, MyItemInfo.MyDocVersion.MyFolder.Name, MyItemInfo.ShortPath); , MyItemInfo.ItemID, MyItemInfo.MyDocVersion.MyFolder.Name, MyItemInfo.ShortPath);
DebugPagination.WriteLine("------,'Yes','Forced Pagination',{0},{1},,{3},{4}", MyItemInfo.ItemID, YSize, 0, yLocation, MyItemInfo.DBSequence); DebugPagination.WriteLine("=====>,'Yes','Forced Pagination',{0},{1},,{3},{4}", MyItemInfo.ItemID, YSize, 0, yLocation, MyItemInfo.DBSequence);
retval = Rtf2Pdf.TextAt(cb, IParagraph, XOffset, yLocation, Width, 100, DebugInfo, yBottomMargin); retval = Rtf2Pdf.TextAt(cb, IParagraph, XOffset, yLocation, Width, 100, DebugInfo, yBottomMargin);
} }
private void ShowPageBreak(int instance, string message, string breakOrNot, float YSize, float yPageSize, float yWithinMargins, bool manualPageBreak) private void ShowPageBreak(int instance, string message, string breakOrNot, float YSize, float yPageSize, float yWithinMargins, bool manualPageBreak)
@ -385,12 +402,15 @@ namespace Volian.Print.Library
vlnParagraph paraBreak = null; vlnParagraph paraBreak = null;
while (((YSize - yTop) > ySpaceOnCurPage) || PageBreakOnStepList.Count > 0) while (((YSize - yTop) > ySpaceOnCurPage) || PageBreakOnStepList.Count > 0)
{ {
float ySpaceOnCurPageSave = ySpaceOnCurPage;
ySpaceOnCurPage -= myBottomMsgSpace; ySpaceOnCurPage -= myBottomMsgSpace;
vlnParagraph lastBreak = paraBreak; vlnParagraph lastBreak = paraBreak;
paraBreak = FindPageBreak(yStart, ySpaceOnCurPage, yLowerLimit, myList, paraBreak, yPageSize - (myTopMsgSpace + SixLinesPerInch) - myBottomMsgSpace); paraBreak = FindPageBreak(yStart, ySpaceOnCurPage, yLowerLimit, myList, paraBreak, yPageSize - (myTopMsgSpace + SixLinesPerInch) - myBottomMsgSpace);
//Console.WriteLine("Break at {0}", paraBreak.MyItemInfo.ShortPath);//Comment Out before release //Console.WriteLine("Break at {0}", paraBreak.MyItemInfo.ShortPath);//Comment Out before release
if (paraBreak == null) if (paraBreak == null)
{ {
DebugPagination.WriteLine("<<< ERROR >>> Cannot find a place to break ==>,{0},'{1}','{2}',{3},{4}"
, MyItemInfo.ItemID, MyItemInfo.MyDocVersion.MyFolder.Name, MyItemInfo.ShortPath, YSize - yTop, ySpaceOnCurPageSave);
_MyLog.ErrorFormat("<<< ERROR >>> Cannot find a place to break\r\n==>'Cannot Find Place to Break',{0},'{1}','{2}'" _MyLog.ErrorFormat("<<< ERROR >>> Cannot find a place to break\r\n==>'Cannot Find Place to Break',{0},'{1}','{2}'"
, MyItemInfo.ItemID, MyItemInfo.MyDocVersion.MyFolder.Name, MyItemInfo.ShortPath); , MyItemInfo.ItemID, MyItemInfo.MyDocVersion.MyFolder.Name, MyItemInfo.ShortPath);
break; break;
@ -446,6 +466,10 @@ namespace Volian.Print.Library
private static vlnParagraph FindPageBreak(float yStart, float yUpperLimit, float yLowerLimit, StepLevelList myList, vlnParagraph lastBreak, float fullPage) private static vlnParagraph FindPageBreak(float yStart, float yUpperLimit, float yLowerLimit, StepLevelList myList, vlnParagraph lastBreak, float fullPage)
{ {
vlnParagraph minPara = null; vlnParagraph minPara = null;
//StringBuilder minBuff = new StringBuilder();
float? yLocationMin=null;
vlnParagraph minPara2 = null;
float? yLocationMin2=null;
foreach (int stepLevel in myList.Keys) // loop thru StepLevels, starting with lowest. foreach (int stepLevel in myList.Keys) // loop thru StepLevels, starting with lowest.
{ {
foreach (float yLocation in myList[stepLevel].Keys) // loop thru yLocation foreach (float yLocation in myList[stepLevel].Keys) // loop thru yLocation
@ -473,9 +497,51 @@ namespace Volian.Print.Library
// The top of this step will fit onto page (-yLocation < yWithinMargins) // The top of this step will fit onto page (-yLocation < yWithinMargins)
float wcnChkLstBorder = myPara.MyItemInfo.MyHLS != null && myPara.MyItemInfo.MyHLS.FormatStepData.UseSmartTemplate && float wcnChkLstBorder = myPara.MyItemInfo.MyHLS != null && myPara.MyItemInfo.MyHLS.FormatStepData.UseSmartTemplate &&
(myPara.MyItemInfo.MyHLS.FormatStepData.Suffix ?? "") != "" ? 2*SixLinesPerInch : 0; (myPara.MyItemInfo.MyHLS.FormatStepData.Suffix ?? "") != "" ? 2*SixLinesPerInch : 0;
if (myPara != lastBreak && (minPara == null || minPara.YTop > myPara.YTop)) if(myPara != lastBreak)
if ((-yLocation + yStart) >= yLowerLimit) // Only if it is more than the lower limit {
if ((-yLocation + yStart) >= yLowerLimit) // More than the lower limit
{
if (yLocationMin == null) // No old location
{
//minBuff.AppendLine(string.Format("OLD1 >>>>> '{0}',{1},{2}", myPara.MyItemInfo.ShortPath, -yLocation, yUpperLimit));
yLocationMin = yLocation;
minPara = myPara; minPara = myPara;
}
else if (-yLocation < -yLocationMin && -yLocationMin >= yUpperLimit) // New location is smaller and old location excedes limit
{
//minBuff.AppendLine(string.Format("NEW1A >>>>> '{0}',{1},{2}", myPara.MyItemInfo.ShortPath, -yLocation, yUpperLimit));
yLocationMin = yLocation;
minPara = myPara;
}
else if (-yLocation > -yLocationMin && -yLocation <= yUpperLimit) // New location is larger and new location is less than limit
{
//minBuff.AppendLine(string.Format("NEWB1 >>>>> '{0}',{1},{2}", myPara.MyItemInfo.ShortPath, -yLocation, yUpperLimit));
yLocationMin = yLocation;
minPara = myPara;
}
}
else // Less than the lower limit
{
if (yLocationMin2 == null)
{
//minBuff.AppendLine(string.Format("OLD2 >>>>> '{0}',{1},{2}", myPara.MyItemInfo.ShortPath, -yLocation, yUpperLimit));
yLocationMin2 = yLocation;
minPara2 = myPara;
}
else if (-yLocation < -yLocationMin2 && -yLocationMin2 >= yUpperLimit) // New location is smaller and old location excedes limit
{
//minBuff.AppendLine(string.Format("NEW2A >>>>> '{0}',{1},{2}", myPara.MyItemInfo.ShortPath, -yLocation, yUpperLimit));
yLocationMin2 = yLocation;
minPara2 = myPara;
}
else if (-yLocation > -yLocationMin2 && -yLocation <= yUpperLimit) // New location is larger and new location is less than limit
{
//minBuff.AppendLine(string.Format("NEW2B >>>>> '{0}',{1},{2}", myPara.MyItemInfo.ShortPath, -yLocation, yUpperLimit));
yLocationMin2 = yLocation;
minPara2 = myPara;
}
}
}
if (myPara.MyParent.YTop == myPara.YTop) myPara = myPara.MyParent; if (myPara.MyParent.YTop == myPara.YTop) myPara = myPara.MyParent;
if (wcnChkLstBorder -yLocation <= yUpperLimit) // Fix for OFN-RJ-23 if (wcnChkLstBorder -yLocation <= yUpperLimit) // Fix for OFN-RJ-23
//if (-yLocation < yUpperLimit) // Before //if (-yLocation < yUpperLimit) // Before
@ -491,7 +557,7 @@ namespace Volian.Print.Library
return myPara; return myPara;
// If this item will not fit on the current page, put a page break // If this item will not fit on the current page, put a page break
if (myPara.YBottom - myPara.YTop > (yUpperLimit - (-yLocation + yStart))) if (myPara.YBottom - myPara.YTop > (yUpperLimit + yLocation))
if (myPara != lastBreak) if (myPara != lastBreak)
if ((-yLocation + yStart) >= yLowerLimit) // Only if it is more than the lower limit if ((-yLocation + yStart) >= yLowerLimit) // Only if it is more than the lower limit
return myPara; return myPara;
@ -507,7 +573,11 @@ namespace Volian.Print.Library
} }
} }
} }
return minPara; //DebugPagination.Write(minBuff.ToString());
if (-yLocationMin > yUpperLimit && minPara2 != null) minPara = null;
//if (minPara != null) DebugPagination.WriteLine("### 111111 {0}", minPara);
//if(minPara2 != null) DebugPagination.WriteLine("### n222222 {0}", minPara2);
return minPara ?? minPara2;
} }
//private void WalkStepLevel(float yTopMost) //private void WalkStepLevel(float yTopMost)