Fix forced pagination errors for backgrounds

This commit is contained in:
Kathy Ruffing 2015-03-25 12:03:15 +00:00
parent 9910cff2c5
commit 48a03c1c48
2 changed files with 62 additions and 36 deletions

View File

@ -16,17 +16,17 @@ namespace Volian.Print.Library
get { return _PageBreakReason; }
set { _PageBreakReason = value; }
}
private bool _CompressPartOfPage = false;
public bool CompressPartOfPage
private bool _CompressPartOfStep = false;
public bool CompressPartOfStep
{
get { return _CompressPartOfPage; }
set { _CompressPartOfPage = value; }
get { return _CompressPartOfStep; }
set { _CompressPartOfStep = value; }
}
private bool _CompressPreviousPartOfPage = false;
public bool CompressPreviousPartOfPage
private bool _CompressFirstPartOfStep = false;
public bool CompressFirstPartOfStep
{
get { return _CompressPreviousPartOfPage; }
set { _CompressPreviousPartOfPage = value; }
get { return _CompressFirstPartOfStep; }
set { _CompressFirstPartOfStep = value; }
}
private bool _BreakHighLevelStepWithSection = false;
public bool BreakHighLevelStepWithSection
@ -270,7 +270,7 @@ namespace Volian.Print.Library
// Document style: DSS_PageBreakHLS breaks on hls.
if (MyItemInfo.IsHigh && (MyItemInfo.MyDocStyle.StructureStyle.Style & E_DocStructStyle.DSS_PageBreakHLS) == E_DocStructStyle.DSS_PageBreakHLS)
{
BuildPageBreakList(yPageSize, yPageSize, KeepStepsOnPage, yEndMsg, doSectionTitleContinued & SectionShowTitles);
BuildPageBreakList(yPageSize, yPageSize, KeepStepsOnPage, yEndMsg, doSectionTitleContinued & SectionShowTitles, true);
ShowPageBreak(1, "Page Break on DSS_PageBreakHLS", "Yes", YSize, yPageSize, yWithinMargins, ManualPageBreak);
return 1;
}
@ -280,7 +280,7 @@ namespace Volian.Print.Library
// if this step contains Cautions or Notes page breaks have to be added for those.
if (TopMostChild != this) PageBreakOnStep = true;
BuildPageBreakList(yPageSize, yPageSize, KeepStepsOnPage, yEndMsg, doSectionTitleContinued & SectionShowTitles); // Case 1 :Works for ES05 Step 15 SubStep 7
BuildPageBreakList(yPageSize, yPageSize, KeepStepsOnPage, yEndMsg, doSectionTitleContinued & SectionShowTitles, true); // Case 1 :Works for ES05 Step 15 SubStep 7
ShowPageBreak(1, "Page Break on Steps, Cautions or Notes", "Yes", YSize, yPageSize, yWithinMargins, ManualPageBreak);
return 1;
}
@ -479,7 +479,7 @@ namespace Volian.Print.Library
//else
// 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
BuildPageBreakList(ySpaceOnFirstPage, yPageSize + yExtra2, KeepStepsOnPage, yEndMsg, doSectionTitleContinued & SectionShowTitles); // Case 5 - Determine items where page break(s) occur
BuildPageBreakList(ySpaceOnFirstPage, yPageSize + yExtra2, KeepStepsOnPage, yEndMsg, doSectionTitleContinued & SectionShowTitles, false); // 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
@ -492,10 +492,10 @@ namespace Volian.Print.Library
if (firstStep == "Yes")
{
//ySpaceOnFirstPage = yWithinMargins; // Accounts for Section Title Line
ShowPageBreak(8, CheckForCompression("First HLS has to split on current page"), firstStep, YSize, yPageSizeNextPage, yWithinMargins, ManualPageBreak);
ShowPageBreak(8, CheckForFirstCompression("First HLS has to split on current page"), firstStep, YSize, yPageSizeNextPage, yWithinMargins, ManualPageBreak);
}
else
ShowPageBreak(6, CheckForCompression("HLS will have to split on current page"), "Special", YSize, yPageSizeNextPage, yWithinMargins, ManualPageBreak);
ShowPageBreak(6, CheckForFirstCompression("HLS will have to split on current page"), "Special", YSize, yPageSizeNextPage, yWithinMargins, ManualPageBreak);
return 0; // Stay on this page
}
@ -507,7 +507,7 @@ namespace Volian.Print.Library
// Pagination Fix Break1LineShort2
//BuildPageBreakList(yPageSize + yExtra, yPageSize); // Case 1 :Works for ES05 Step 15 SubStep 7
// Pagination Fix Break1LineShort4
BuildPageBreakList(yPageSize + yExtra, yPageSizeNextPage + yExtra2, KeepStepsOnPage, yEndMsg, doSectionTitleContinued & SectionShowTitles); // Case 1 :Works for ES05 Step 15 SubStep 7
BuildPageBreakList(yPageSize + yExtra, yPageSizeNextPage + yExtra2, KeepStepsOnPage, yEndMsg, doSectionTitleContinued & SectionShowTitles, true); // Case 1 :Works for ES05 Step 15 SubStep 7
// ooooo ooooo ooooo .oooooo..o .oooooo..o oooo o8o . ooooo ooo
// `888' `888' `888' d8P' `Y8 d8P' `Y8 `888 `"' .o8 `888b. `8'
// 888 888 888 Y88bo. Y88bo. oo.ooooo. 888 oooo .o888oo 8 `88b. 8 .ooooo. oooo oooo ooo
@ -518,9 +518,9 @@ namespace Volian.Print.Library
// 888
// o888o
if (firstStep == "Yes")
ShowPageBreak(9, CheckForCompression("First HLS will have to split on new page"), "Yes", YSize, yPageSizeNextPage, yWithinMargins, ManualPageBreak);
ShowPageBreak(9, CheckForFirstCompression("First HLS will have to split on new page"), "Yes", YSize, yPageSizeNextPage, yWithinMargins, ManualPageBreak);
else
ShowPageBreak(3, CheckForCompression("HLS will have to split on new page"), "Yes", YSize, yPageSizeNextPage, yWithinMargins, ManualPageBreak);
ShowPageBreak(3, CheckForFirstCompression("HLS will have to split on new page"), "Yes", YSize, yPageSizeNextPage, yWithinMargins, ManualPageBreak);
return 1; // Paginate on High Level Steps
}
//if (yWithinMargins > yPageSize / 2)
@ -534,9 +534,15 @@ namespace Volian.Print.Library
//return 2;
throw new Exception("PageBreak Logic Missing, vlnParagraph.cs");
}
private string CheckForFirstCompression(string reason)
{
if (MyPageHelper.ParaBreaks.Count > 0 && MyPageHelper.ParaBreaks[0].CompressFirstPartOfStep)
return reason + " - 7 LPI";
return reason;
}
private string CheckForCompression(string reason)
{
if (MyPageHelper.ParaBreaks.Count > 0 && MyPageHelper.ParaBreaks[0].CompressPreviousPartOfPage)
if (CompressPartOfStep)
return reason + " - 7 LPI";
return reason;
}
@ -656,7 +662,7 @@ namespace Volian.Print.Library
return pg;
return pg.MyParent.ChildrenBelow[0];
}
private void BuildPageBreakList(float ySpaceOnCurPage, float yPageSize, bool KeepStepsOnPage, float yEndMsg, bool doSectionTitleContinued)
private void BuildPageBreakList(float ySpaceOnCurPage, float yPageSize, bool KeepStepsOnPage, float yEndMsg, bool doSectionTitleContinued, bool onNewPage)
{
float topContinueHeight=2 * SixLinesPerInch;
//if(MyItemInfo.InList(41955)) Console.WriteLine("Here");
@ -975,7 +981,7 @@ namespace Volian.Print.Library
paraBreak = paraBreak.ChildrenBelow[0];
float ySpaceOnNextPage1 = yPageSize - (myTopMsgSpace + (yEndMsg == 0 ? SixLinesPerInch : 0)); // Allow for continue message and blank line.
ySpaceOnNextPage1 -= accountForSmartTemplateHeader;
if (MyItemInfo.ActiveFormat.MyStepSectionLayoutData.PartialStepCompression && ySpaceOnNextPage1 == ySpaceOnCurPage+myBottomMsgSpace)
if (MyItemInfo.ActiveFormat.MyStepSectionLayoutData.PartialStepCompression && onNewPage) // ySpaceOnNextPage1 == ySpaceOnCurPage+myBottomMsgSpace)
{
float ySpaceAt7LPI = ((ySpaceOnCurPage - accountForCalvertAlarmConditionResponseFooter) * SixLinesPerInch / _SevenLinesPerInch) - _SevenLinesPerInch;
vlnParagraph paraBreak7 = FindPageBreak(yStart, ySpaceAt7LPI, yLowerLimit,
@ -984,6 +990,7 @@ namespace Volian.Print.Library
if (paraBreak7 != null && paraBreak7.YOffset > paraBreak.YOffset && paraBreak.MyItemInfo.StepLevel >= paraBreak7.MyItemInfo.StepLevel)
{
paraBreak = paraBreak7;
// Compress Part of Step
// .oooooo. ooooooooo. .
// d8P' `Y8b `888 `Y88. .o8
// 888 .ooooo. ooo. .oo. .oo. oo.ooooo. oooo d8b .ooooo. .oooo.o .oooo.o 888 .d88' .oooo. oooo d8b .o888oo
@ -993,17 +1000,32 @@ namespace Volian.Print.Library
// `Y8bood8P' `Y8bod8P' o888o o888o o888o 888bod8P' d888b `Y8bod8P' 8""888P' 8""888P' o888o `Y888""8o d888b "888"
// 888
// o888o
if (lastBreak != null)
//
// | Step over a Number of Pages |
// | First Page | Second Page | Third Page |
//--------------------------------------------------------------------------------------
// |paraBreak[0] |paraBreak[1]
// | |
// |CompressPartOfStep |CompressPartOfStep
// | Flags compression for 2nd page | Flags compression for 2nd page
// | of step starting at paraBreak[0] | of step starting at paraBreak[1]
// | | See code below for 'Compress Rest of Step'
// <==|CompressFirstPartOfStep |
// | Flags compression for 1st page |
// | (1st page doesn't use paraBreak) |
//
if (lastBreak != null) // not on first page of step
{
lastBreak.PageBreakReason = "More of Step at 7 LPI";
lastBreak.CompressPartOfPage = true;
lastBreak.CompressPartOfStep = true;
}
else
{
paraBreak.CompressPreviousPartOfPage = true;
paraBreak.CompressFirstPartOfStep = true;
}
}
}
onNewPage = true;
float yTopNew = Math.Min(paraBreak.YTopMost, paraBreak.YVeryTop) - YTopMost;
// This is for formats that break on all HLS, Cautions & Notes (often backgrounds):
@ -1013,6 +1035,7 @@ namespace Volian.Print.Library
// hls/caution/note.
if (PageBreakOnStepList[0].YTop <= paraBreak.YTop)
{
PageBreakOnStepList[0].CompressFirstPartOfStep = paraBreak.CompressFirstPartOfStep;
paraBreak = PageBreakOnStepList[0];
PageBreakOnStepList.RemoveAt(0);
yTopNew = paraBreak.YTop - YTopMost;
@ -1047,6 +1070,7 @@ namespace Volian.Print.Library
if ((YSize - yTop) > (ySpaceOnCurPage - (accountForCalvertAlarmConditionResponseFooter + yEndMsg))
&& (YSize - yTop) < ySpaceAt7LPI )
{
// Compress Rest of Step
// .oooooo. ooooooooo. .
// d8P' `Y8b `888 `Y88. .o8
// 888 .ooooo. ooo. .oo. .oo. oo.ooooo. oooo d8b .ooooo. .oooo.o .oooo.o 888 .d88' .ooooo. .oooo.o .o888oo
@ -1057,7 +1081,7 @@ namespace Volian.Print.Library
// 888
// o888o
paraBreak.PageBreakReason = "Rest of Step fits at 7 LPI";
paraBreak.CompressPartOfPage = true;
paraBreak.CompressPartOfStep = true;
break;
}
}

View File

@ -1247,11 +1247,8 @@ namespace Volian.Print.Library
}
if (MyItemInfo.IsHigh && MyItemInfo.MyPrevious != null && ((MyItemInfo.MyDocStyle.StructureStyle.Style & E_DocStructStyle.DoubleBoxHLS) == E_DocStructStyle.DoubleBoxHLS))
yPageStart -= SixLinesPerInch;
if (MyPageHelper.ParaBreaks.Count > 0 && MyPageHelper.ParaBreaks[0].CompressPreviousPartOfPage)
{
if (MyPageHelper.ParaBreaks.Count > 0 && MyPageHelper.ParaBreaks[0].CompressFirstPartOfStep)
MyPageHelper.YMultiplier = _SevenLinesPerInch / SixLinesPerInch;
CompressPartOfPage = false;
}
if(CompressFoldout)
MyPageHelper.YMultiplier = _SevenLinesPerInch / SixLinesPerInch;
@ -1323,11 +1320,9 @@ namespace Volian.Print.Library
SectionConfig sch = MyItemInfo.ActiveSection.MyConfig as SectionConfig;
doSectionTitleContinued = (sch == null || sch.Section_PrintHdr == "Y") && !MyItemInfo.MyDocStyle.CancelSectTitle;
}
if (MyPageHelper.ParaBreaks.Count > 0 && MyPageHelper.ParaBreaks[0].CompressPreviousPartOfPage)
{
if (MyPageHelper.ParaBreaks.Count > 0 && MyPageHelper.ParaBreaks[0].CompressFirstPartOfStep)
MyPageHelper.YMultiplier = _SevenLinesPerInch / SixLinesPerInch;
CompressPartOfPage = false;
}
else
MyPageHelper.YMultiplier = 1;
break;
@ -1449,10 +1444,10 @@ namespace Volian.Print.Library
if (!doSectionTitleContinued || !SectionShowTitles)
addExtraLines = DoTopContinueMsg(cb, ref yPageStart, yTopMargin, docstyle, doThreeContinues && MyItemInfo.MyParent != null && MyItemInfo.MyParent.MyTab != null ? MyItemInfo.MyParent.MyTab.CleanText : null);
if (CompressPartOfPage)
if (CompressPartOfStep)
{
MyPageHelper.YMultiplier = _SevenLinesPerInch / SixLinesPerInch;
CompressPartOfPage = false;
CompressPartOfStep = false;
}
else
MyPageHelper.YMultiplier = 1;
@ -1622,14 +1617,21 @@ namespace Volian.Print.Library
// Handle the PageBreakOnStep flag for a HLS. This will put out the page break right before
// a HLS. One example of this use is for backgrounds (CALBCK).
// 'this' below is a highlevel step, and the only time that ParaBreaks[0] will == 'this' is
// when the PageBreakOnStep flag is true.
if (MyPageHelper.ParaBreaks != null && MyPageHelper.ParaBreaks.Count > 0 &&
MyPageHelper.ParaBreaks[0] == this)
{
if (DebugPagination.IsOpen) DebugPagination.WriteLine("XXXXXXXXXXXXXX Special Page Break (PageBreakOnStep) On Item {0},{1}", MyItemInfo.ItemID, MyItemInfo.ShortPath);
ShowPageBreak(1, CheckForCompression("PageBreakOnStep/Caution/Note HLS"), "Yes", YTop - YBottomMost, yTopMargin - yBottomMargin, yTopMargin - yBottomMargin, false);
OutputOtherPageSteps(cb, YTopMost, yPageStart, yTopMargin, yBottomMargin);
MyPageHelper.BottomMessage = null;
MyPageHelper.TopMessage = null;
cb.PdfDocument.NewPage();
if (CompressPartOfStep)
{
MyPageHelper.YMultiplier = _SevenLinesPerInch / SixLinesPerInch;
CompressPartOfStep = false;
}
MyPageHelper.ParaBreaks.RemoveAt(0);
yPageStart = yTopMargin + YTop;
}