Added logic to handle compression of partial steps

This commit is contained in:
Rich 2015-03-06 12:57:11 +00:00
parent f97433e12a
commit f908b2ad02
2 changed files with 111 additions and 15 deletions

View File

@ -10,6 +10,24 @@ namespace Volian.Print.Library
{ {
public partial class vlnParagraph public partial class vlnParagraph
{ {
private string _PageBreakReason = null;
public string PageBreakReason
{
get { return _PageBreakReason; }
set { _PageBreakReason = value; }
}
private bool _CompressPartOfPage = false;
public bool CompressPartOfPage
{
get { return _CompressPartOfPage; }
set { _CompressPartOfPage = value; }
}
private bool _CompressPreviousPartOfPage = false;
public bool CompressPreviousPartOfPage
{
get { return _CompressPreviousPartOfPage; }
set { _CompressPreviousPartOfPage = value; }
}
private bool _BreakHighLevelStepWithSection = false; private bool _BreakHighLevelStepWithSection = false;
public bool BreakHighLevelStepWithSection public bool BreakHighLevelStepWithSection
{ {
@ -88,22 +106,26 @@ namespace Volian.Print.Library
// location of a pagebreak. // location of a pagebreak.
if (MyPageHelper.ParaBreaks.Count > 0) if (MyPageHelper.ParaBreaks.Count > 0)
{ {
string reason = "Unknown";
if (this == MyPageHelper.ParaBreaks[0]) if (this == MyPageHelper.ParaBreaks[0])
{ {
MyPageHelper.ParaBreaks.RemoveAt(0); MyPageHelper.ParaBreaks.RemoveAt(0);
ShowPageBreak(1, "Page Break within Step 1", "Yes", YSize, yPageSize, yWithinMargins, ManualPageBreak); reason = AddReason("Partial Step - Case 1");
ShowPageBreak(1,reason, "Yes", YSize, yPageSize, yWithinMargins, ManualPageBreak);
return 2; // break on this item within a step return 2; // break on this item within a step
} }
else if (MyPageHelper.ParaBreaks[0].CheckAlternates(this)) else if (MyPageHelper.ParaBreaks[0].CheckAlternates(this))
{ {
MyPageHelper.ParaBreaks.RemoveAt(0); MyPageHelper.ParaBreaks.RemoveAt(0);
ShowPageBreak(1, "Page Break within Step 2", "Yes", YSize, yPageSize, yWithinMargins, ManualPageBreak); reason = AddReason("Partial Step - Case 2");
ShowPageBreak(1, reason, "Yes", YSize, yPageSize, yWithinMargins, ManualPageBreak);
return 2; // break on this item within a step return 2; // break on this item within a step
} }
else if (!MyPageHelper.ParaBreaks[0].PageBreakOnStep && this.YTopMost > MyPageHelper.ParaBreaks[0].YTopMost) else if (!MyPageHelper.ParaBreaks[0].PageBreakOnStep && this.YTopMost > MyPageHelper.ParaBreaks[0].YTopMost)
{ {
MyPageHelper.ParaBreaks.RemoveAt(0); MyPageHelper.ParaBreaks.RemoveAt(0);
ShowPageBreak(1, "Page Break within Step 3", "Yes", YSize, yPageSize, yWithinMargins, ManualPageBreak); reason = AddReason("Partial Step - Case 3");
ShowPageBreak(1, reason, "Yes", YSize, yPageSize, yWithinMargins, ManualPageBreak);
return 2; // break on this item within a step return 2; // break on this item within a step
} }
return 0; // this is not an item with a break return 0; // this is not an item with a break
@ -386,23 +408,26 @@ namespace Volian.Print.Library
// text. // text.
float ySpaceOnFirstPage = yWithinMargins + (MyItemInfo.FormatStepData.UseSmartTemplate ? 0 : SixLinesPerInch); float ySpaceOnFirstPage = yWithinMargins + (MyItemInfo.FormatStepData.UseSmartTemplate ? 0 : SixLinesPerInch);
if (firstStep == "Yes") if (firstStep == "Yes")
{ //{
ySpaceOnFirstPage = yWithinMargins; // Accounts for Section Title Line ySpaceOnFirstPage = yWithinMargins; // Accounts for Section Title Line
ShowPageBreak(8, "First HLS has to split on current page", firstStep, YSize, yPageSizeNextPage, yWithinMargins, ManualPageBreak); //ShowPageBreak(8, CheckForCompression("First HLS has to split on current page"), firstStep, YSize, yPageSizeNextPage, yWithinMargins, ManualPageBreak);
} //}
else //else
ShowPageBreak(6, "HLS will have to split on current page", "Special", YSize, yPageSizeNextPage, yWithinMargins, ManualPageBreak); // 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(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); // Case 5 - Determine items where page break(s) occur
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);
}
else
ShowPageBreak(6, CheckForCompression("HLS will have to split on current page"), "Special", YSize, yPageSizeNextPage, yWithinMargins, ManualPageBreak);
return 0; // Stay on this page return 0; // Stay on this page
} }
// Less than half a page left, start printing on a new page. // Less than half a page left, start printing on a new page.
//Console.WriteLine("'PageBreak',5,'Yes','HLS will have to split',{0},{1},{2}, {3}, {4},'{5}'", MyItemInfo.ItemID, YSize, yPageSize, yWithinMargins, (int)(100 * yWithinMargins / yPageSize), MyItemInfo.ShortPath); //Console.WriteLine("'PageBreak',5,'Yes','HLS will have to split',{0},{1},{2}, {3}, {4},'{5}'", MyItemInfo.ItemID, YSize, yPageSize, yWithinMargins, (int)(100 * yWithinMargins / yPageSize), MyItemInfo.ShortPath);
if (firstStep == "Yes")
ShowPageBreak(9, "First HLS will have to split on new page", "Yes", YSize, yPageSizeNextPage, yWithinMargins, ManualPageBreak);
else
ShowPageBreak(3, "HLS will have to split on new page", "Yes", YSize, yPageSizeNextPage, yWithinMargins, ManualPageBreak);
// Determine items where page break(s) occur // Determine items where page break(s) occur
//BuildPageBreakList(yPageSize, yPageSize - 2 * SixLinesPerInch); // Case Base //BuildPageBreakList(yPageSize, yPageSize - 2 * SixLinesPerInch); // Case Base
//BuildPageBreakList(yPageSize, yPageSize); // Case 1 :Works for ES05 Step 15 SubStep 7 //BuildPageBreakList(yPageSize, yPageSize); // Case 1 :Works for ES05 Step 15 SubStep 7
@ -410,6 +435,10 @@ namespace Volian.Print.Library
//BuildPageBreakList(yPageSize + yExtra, yPageSize); // Case 1 :Works for ES05 Step 15 SubStep 7 //BuildPageBreakList(yPageSize + yExtra, yPageSize); // Case 1 :Works for ES05 Step 15 SubStep 7
// Pagination Fix Break1LineShort4 // 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); // Case 1 :Works for ES05 Step 15 SubStep 7
if (firstStep == "Yes")
ShowPageBreak(9, CheckForCompression("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);
return 1; // Paginate on High Level Steps return 1; // Paginate on High Level Steps
} }
//if (yWithinMargins > yPageSize / 2) //if (yWithinMargins > yPageSize / 2)
@ -423,6 +452,19 @@ namespace Volian.Print.Library
//return 2; //return 2;
throw new Exception("PageBreak Logic Missing, vlnParagraph.cs"); throw new Exception("PageBreak Logic Missing, vlnParagraph.cs");
} }
private string CheckForCompression(string reason)
{
if (MyPageHelper.ParaBreaks.Count > 0 && MyPageHelper.ParaBreaks[0].CompressPreviousPartOfPage)
return reason + " - 7 LPI";
return reason;
}
private string AddReason(string prefix)
{
string retval = prefix;
if (PageBreakReason != null)
retval += " - " + PageBreakReason;
return retval;
}
private bool SectionShowTitles private bool SectionShowTitles
{ {
get get
@ -531,7 +573,7 @@ namespace Volian.Print.Library
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)
{ {
float topContinueHeight=2 * SixLinesPerInch; float topContinueHeight=2 * SixLinesPerInch;
//if(MyItemInfo.InList(54573)) Console.WriteLine("Here"); //if(MyItemInfo.InList(41955)) Console.WriteLine("Here");
int profileDepth = ProfileTimer.Push(">>>> BuildPageBreakList"); int profileDepth = ProfileTimer.Push(">>>> BuildPageBreakList");
// if this paragraph is flagged to pagebreakonstep (i.e. these are used by background documents // if this paragraph is flagged to pagebreakonstep (i.e. these are used by background documents
// to get each hls/caution/note to be on its own page), then any of the children above should // to get each hls/caution/note to be on its own page), then any of the children above should
@ -836,6 +878,26 @@ namespace Volian.Print.Library
//float yTopNew = paraBreak.YTopMost - YTopMost; //float yTopNew = paraBreak.YTopMost - YTopMost;
if (JustATableThatWillFit(paraBreak, yPageSize - (myTopMsgSpace + yEndMsg))) if (JustATableThatWillFit(paraBreak, yPageSize - (myTopMsgSpace + yEndMsg)))
paraBreak = paraBreak.ChildrenBelow[0]; paraBreak = paraBreak.ChildrenBelow[0];
if (MyItemInfo.ActiveFormat.MyStepSectionLayoutData.CompressSteps)
{
float ySpaceAt7LPI = ((ySpaceOnCurPage - accountForCalvertAlarmConditionResponseFooter) * SixLinesPerInch / _SevenLinesPerInch) - _SevenLinesPerInch;
vlnParagraph paraBreak7 = FindPageBreak(yStart, ySpaceAt7LPI, yLowerLimit,
myList, lastBreak, yPageSize - (myTopMsgSpace + SixLinesPerInch) - myBottomMsgSpace,
myBottomMsgSpace, MyItemInfo.ActiveFormat.PlantFormat.FormatData.StepDataList[40].ContinueOnly);
if (paraBreak7 != null && paraBreak7.YOffset > paraBreak.YOffset && paraBreak.MyItemInfo.StepLevel >= paraBreak7.MyItemInfo.StepLevel)
{
paraBreak = paraBreak7;
if (lastBreak != null)
{
lastBreak.PageBreakReason = "More of Step at 7 LPI";
lastBreak.CompressPartOfPage = true;
}
else
{
paraBreak.CompressPreviousPartOfPage = true;
}
}
}
float yTopNew = Math.Min(paraBreak.YTopMost, paraBreak.YVeryTop) - YTopMost; float yTopNew = Math.Min(paraBreak.YTopMost, paraBreak.YVeryTop) - YTopMost;
// This is for formats that break on all HLS, Cautions & Notes (often backgrounds): // This is for formats that break on all HLS, Cautions & Notes (often backgrounds):
@ -874,7 +936,20 @@ namespace Volian.Print.Library
yLowerLimit = ySpaceOnCurPage / 2; yLowerLimit = ySpaceOnCurPage / 2;
if (_Match16BitPagination) yLowerLimit -= 1.5F * SixLinesPerInch; // 276 for HLP if (_Match16BitPagination) yLowerLimit -= 1.5F * SixLinesPerInch; // 276 for HLP
yStart = 0; yStart = 0;
if (MyItemInfo.ActiveFormat.MyStepSectionLayoutData.CompressSteps)
{
float ySpaceAt7LPI = (ySpaceOnCurPage - (accountForCalvertAlarmConditionResponseFooter + yEndMsg)) * SixLinesPerInch / _SevenLinesPerInch;
if ((YSize - yTop) > (ySpaceOnCurPage - (accountForCalvertAlarmConditionResponseFooter + yEndMsg))
&& (YSize - yTop) < ySpaceAt7LPI )
{
paraBreak.PageBreakReason = "Rest of Step fits at 7 LPI";
paraBreak.CompressPartOfPage = true;
break;
}
}
} }
if (paraBreak.PageBreakReason == null)
paraBreak.PageBreakReason = "Rest of Step fits at 6 LPI";
ProfileTimer.Pop(profileDepth); ProfileTimer.Pop(profileDepth);
} }

View File

@ -1215,6 +1215,15 @@ namespace Volian.Print.Library
if (MyItemInfo.IsHigh && MyItemInfo.MyPrevious != null && ((MyItemInfo.MyDocStyle.StructureStyle.Style & E_DocStructStyle.DoubleBoxHLS) == E_DocStructStyle.DoubleBoxHLS)) if (MyItemInfo.IsHigh && MyItemInfo.MyPrevious != null && ((MyItemInfo.MyDocStyle.StructureStyle.Style & E_DocStructStyle.DoubleBoxHLS) == E_DocStructStyle.DoubleBoxHLS))
yPageStart -= SixLinesPerInch; yPageStart -= SixLinesPerInch;
break; break;
// XXXX XX XXXXX XXXXXXX X
// X X X X X X X XXX
// X X X X X
// X X X X X X X
// X X X XXXXX XXXX X
// X X X X X X X
// X XXXXX X X X
// X X X X X X X X X
// XXXX XXX XXX XXXXX XXXXXXX XXXXX
case 1: // Break on High Level Step case 1: // Break on High Level Step
OutputOtherPageSteps(cb, YTopMost, yPageStart, yTopMargin, yBottomMargin); OutputOtherPageSteps(cb, YTopMost, yPageStart, yTopMargin, yBottomMargin);
docstyle = MyItemInfo.MyDocStyle; docstyle = MyItemInfo.MyDocStyle;
@ -1273,7 +1282,13 @@ namespace Volian.Print.Library
SectionConfig sch = MyItemInfo.ActiveSection.MyConfig as SectionConfig; SectionConfig sch = MyItemInfo.ActiveSection.MyConfig as SectionConfig;
doSectionTitleContinued = (sch == null || sch.Section_PrintHdr == "Y") && !MyItemInfo.MyDocStyle.CancelSectTitle; doSectionTitleContinued = (sch == null || sch.Section_PrintHdr == "Y") && !MyItemInfo.MyDocStyle.CancelSectTitle;
} }
MyPageHelper.YMultiplier = 1; if (MyPageHelper.ParaBreaks.Count > 0 && MyPageHelper.ParaBreaks[0].CompressPreviousPartOfPage)
{
MyPageHelper.YMultiplier = _SevenLinesPerInch / SixLinesPerInch;
CompressPartOfPage = false;
}
else
MyPageHelper.YMultiplier = 1;
break; break;
case 2: // Break within a Step case 2: // Break within a Step
OutputOtherPageSteps(cb, YTopMost, yPageStart, yTopMargin, yBottomMargin); OutputOtherPageSteps(cb, YTopMost, yPageStart, yTopMargin, yBottomMargin);
@ -1386,7 +1401,13 @@ namespace Volian.Print.Library
if (!doSectionTitleContinued || !SectionShowTitles) if (!doSectionTitleContinued || !SectionShowTitles)
addExtraLines = DoTopContinueMsg(cb, ref yPageStart, yTopMargin, docstyle, doThreeContinues && MyItemInfo.MyParent != null && MyItemInfo.MyParent.MyTab != null ? MyItemInfo.MyParent.MyTab.CleanText : null); addExtraLines = DoTopContinueMsg(cb, ref yPageStart, yTopMargin, docstyle, doThreeContinues && MyItemInfo.MyParent != null && MyItemInfo.MyParent.MyTab != null ? MyItemInfo.MyParent.MyTab.CleanText : null);
MyPageHelper.YMultiplier = 1; if (CompressPartOfPage)
{
MyPageHelper.YMultiplier = _SevenLinesPerInch / SixLinesPerInch;
CompressPartOfPage = false;
}
else
MyPageHelper.YMultiplier = 1;
// For Calvert Alarms, if there was a page break and there is an box around the current // For Calvert Alarms, if there was a page break and there is an box around the current
// step, need to add the header for the box, which is stored in a macro. Also set the // step, need to add the header for the box, which is stored in a macro. Also set the