This commit is contained in:
@@ -115,15 +115,12 @@ namespace Volian.Print.Library
|
||||
/// This variable is used to match 16 bit pagination
|
||||
/// </summary>
|
||||
private bool _Match16BitPagination = false;
|
||||
// the following boolean is to help testing of various formats. If the plant has an alternating foldout
|
||||
// and you want a blank page, until foldouts are developed, set to true.
|
||||
// AEP DU1 - do a blank page for foldout
|
||||
private bool _DoBlankForFoldout = false;
|
||||
public float ParagraphToPdf(PdfContentByte cb, float yPageStart, float yTopMargin, float yBottomMargin)
|
||||
{
|
||||
if (Processed) return yPageStart;
|
||||
Processed = true;
|
||||
if (_PartsAbove != null && _PartsAbove.Count > 0) yPageStart = PartsAbove.ToPdf(cb, yPageStart, yTopMargin, yBottomMargin);
|
||||
if (MyItemInfo.IsHigh && MyItemInfo.MyDocStyle.SpecialStepsFoldout) yPageStart -= SixLinesPerInch;
|
||||
float yLocation = CalculateYOffset(yPageStart, yTopMargin);
|
||||
if (MyItemInfo.HasChangeBar && MyPageHelper.ChangeBarDefinition.MyChangeBarType != PrintChangeBar.Without) MyPageHelper.AddChangeBar(DoChangeBar(cb, MyItemInfo, MyPageHelper, XOffset, yLocation, MyPageHelper.MaxRNO, MyItemInfo.ActiveFormat), cbMess);
|
||||
|
||||
@@ -137,7 +134,10 @@ namespace Volian.Print.Library
|
||||
retval = DrawText(cb, ref yPageStart, yTopMargin, yBottomMargin, ref yLocation);
|
||||
|
||||
}
|
||||
else if (!MyItemInfo.IsStepSection || MyItemInfo.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.StepSectionLayoutData.ShowSectionTitles) // Don't ouput the Step Section title
|
||||
else if (!MyItemInfo.IsStepSection
|
||||
|| (MyItemInfo.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.StepSectionLayoutData.ShowSectionTitles
|
||||
&& !MyItemInfo.MyDocStyle.CancelSectTitle
|
||||
&& !MyItemInfo.MyDocStyle.SpecialStepsFoldout)) // Don't ouput the Step Section title
|
||||
{
|
||||
if (MyItemInfo.MyContent.MyGrid != null)
|
||||
retval = DrawGrid(cb, ref yPageStart, yTopMargin, yBottomMargin, ref yLocation);
|
||||
@@ -179,7 +179,7 @@ namespace Volian.Print.Library
|
||||
retval = Rtf2Pdf.TextAt(cb, IParagraph, XOffset, yLocation, Width, 100, DebugText, yBottomMargin);
|
||||
if (retval == 0) // problem occurred - paragraph was not able to be printed on page
|
||||
{ // pagination logic needs to be fixed.
|
||||
cb.PdfDocument.NewPage();
|
||||
cb.PdfDocument.NewPage(); // pagination issue
|
||||
yPageStart = yTopMargin + YVeryTop;
|
||||
yLocation = yPageStart - YOffset;
|
||||
//MyItemInfo.ItemID, YSize, yPageSize, yLocation
|
||||
@@ -284,17 +284,14 @@ namespace Volian.Print.Library
|
||||
{
|
||||
float yLocation = yPageStart - YTopMost;
|
||||
int paginate = Paginate(yLocation, yTopMargin, yBottomMargin);
|
||||
bool firstHighLevelStep = MyItemInfo.IsHigh && (MyItemInfo.MyPrevious == null);
|
||||
switch (paginate)
|
||||
{
|
||||
case 1: // Break on High Level Step
|
||||
OutputOtherPageSteps(cb, YTopMost, yPageStart, yTopMargin, yBottomMargin);
|
||||
if (_DoBlankForFoldout&&MyItemInfo.ActiveSection.IsDefaultSection)
|
||||
{
|
||||
cb.PdfDocument.NewPage();
|
||||
cb.Circle(100, 100, 50);
|
||||
}
|
||||
cb.PdfDocument.NewPage();
|
||||
|
||||
if ((MyItemInfo.ActiveSection.MyDocStyle.StructureStyle.Style ?? 0 & E_DocStructStyle.UseSectionFoldout) != 0)
|
||||
PromsPrinter.DoFoldoutPage(cb, "HLS", MyPageHelper.TextLayer, MyPageHelper);
|
||||
yPageStart = yTopMargin + YTopMost;
|
||||
MyPageHelper.YMultiplier = 1;
|
||||
break;
|
||||
@@ -306,6 +303,8 @@ namespace Volian.Print.Library
|
||||
{
|
||||
if (myMsg.IndexOf(@"%d") > -1)
|
||||
myMsg = myMsg.Replace(@"%d", MyItemInfo.MyHLS.MyTab.CleanText.Trim());
|
||||
if (myMsg.IndexOf(@"%2d") > -1)
|
||||
myMsg = myMsg.Replace(@"%2d", MyItemInfo.MyHLS.MyTab.CleanText.Trim(" .".ToCharArray()).PadLeft(2));
|
||||
float msg_yLocation = 0;
|
||||
switch (docstyle.Continue.Bottom.Location)
|
||||
{
|
||||
@@ -319,15 +318,11 @@ namespace Volian.Print.Library
|
||||
}
|
||||
MyPageHelper.BottomMessage = new vlnText(cb, this, myMsg, myMsg, docstyle.Layout.LeftMargin + XOffsetBox + docstyle.Continue.Bottom.Margin ?? 0, msg_yLocation, MyItemInfo.ActiveFormat.PlantFormat.FormatData.Font);
|
||||
}
|
||||
if (_DoBlankForFoldout && MyItemInfo.ActiveSection.IsDefaultSection)
|
||||
{
|
||||
cb.PdfDocument.NewPage();
|
||||
cb.Circle(200, 100, 50);
|
||||
}
|
||||
cb.PdfDocument.NewPage();
|
||||
if ((MyItemInfo.ActiveSection.MyDocStyle.StructureStyle.Style ?? 0 & E_DocStructStyle.UseSectionFoldout) != 0)
|
||||
PromsPrinter.DoFoldoutPage(cb, "Break within Step", MyPageHelper.TextLayer, MyPageHelper); // temporary foldout
|
||||
|
||||
// If there is a box, adjust the yTopMost to include it.
|
||||
// TODO: Why doesn't YTopMost account for the box?
|
||||
float yTopMost = YTopMost;
|
||||
//if (YVeryTop < yTopMost) Console.WriteLine("{0},{1},{2}", MyItemInfo.DBSequence, yTopMost, YVeryTop);
|
||||
yTopMost = Math.Min(yTopMost,YVeryTop);
|
||||
@@ -337,20 +332,19 @@ namespace Volian.Print.Library
|
||||
if (myMsg != null && myMsg != "")
|
||||
{
|
||||
if (myMsg.IndexOf(@"%d") > -1)
|
||||
myMsg = myMsg.Replace(@"%d", MyItemInfo.MyHLS.MyTab.CleanText.Trim());
|
||||
myMsg = myMsg.Replace(@"%d", MyItemInfo.MyHLS.MyTab.CleanText.Trim(" .".ToCharArray()));
|
||||
MyPageHelper.TopMessage = new vlnText(cb, this, myMsg, myMsg, docstyle.Layout.LeftMargin + XOffsetBox + docstyle.Continue.Top.Margin ?? 0, yTopMargin + 0.1F, MyItemInfo.ActiveFormat.PlantFormat.FormatData.Font);
|
||||
}
|
||||
MyPageHelper.YMultiplier = 1;
|
||||
break;
|
||||
case 3: // Break on High Level Step (SevenLinesPerInch)
|
||||
OutputOtherPageSteps(cb, YTopMost, yPageStart, yTopMargin, yBottomMargin);
|
||||
if (_DoBlankForFoldout && MyItemInfo.ActiveSection.IsDefaultSection)
|
||||
if (!firstHighLevelStep)
|
||||
{
|
||||
cb.PdfDocument.NewPage();
|
||||
cb.Circle(300, 100, 50);
|
||||
OutputOtherPageSteps(cb, YTopMost, yPageStart, yTopMargin, yBottomMargin);
|
||||
cb.PdfDocument.NewPage(); // HLS (7 lpi) break
|
||||
if ((MyItemInfo.ActiveSection.MyDocStyle.StructureStyle.Style ?? 0 & E_DocStructStyle.UseSectionFoldout) != 0)
|
||||
PromsPrinter.DoFoldoutPage(cb, "HLS (7 lpi) break", MyPageHelper.TextLayer, MyPageHelper);
|
||||
}
|
||||
cb.PdfDocument.NewPage();
|
||||
|
||||
yPageStart = yTopMargin + YTopMost;
|
||||
MyPageHelper.YMultiplier = _SevenLinesPerInch / SixLinesPerInch;
|
||||
break;
|
||||
@@ -366,13 +360,15 @@ namespace Volian.Print.Library
|
||||
string myMsg = (docstyle.End == null) ? null : docstyle.End.Message;
|
||||
if (myMsg != null)
|
||||
{
|
||||
float msg_yLocation = yBottomMargin + SixLinesPerInch;
|
||||
// use the 'flag' to position the message. Just implementing OHLP
|
||||
if (docstyle.End.Flag >= 2)
|
||||
// If the flag is 0 or 1, just put the end message out right below this vlnParagraph:
|
||||
float msg_yLocation = yPageStart - YBottomMost;
|
||||
|
||||
// use the 'flag' to position the message.
|
||||
if (docstyle.End.Flag > 2) // >2 position at an absolute location defined by docstyle.End.Flag.
|
||||
{
|
||||
msg_yLocation = yTopMargin - (float)(docstyle.End.Flag * SixLinesPerInch);
|
||||
}
|
||||
// center it. Just implementing OHLP
|
||||
// center the message.
|
||||
float wtpm = (float)docstyle.Layout.PageWidth - (float)docstyle.Layout.LeftMargin;
|
||||
float centerpos = XOffsetBox + (float)docstyle.Layout.LeftMargin + (wtpm - (myMsg.Length * MyItemInfo.FormatStepData.Font.CharsToTwips)) / 2;
|
||||
MyPageHelper.BottomMessage = new vlnText(cb, this, myMsg, myMsg, centerpos, msg_yLocation, docstyle.End.Font);
|
||||
@@ -467,6 +463,13 @@ namespace Volian.Print.Library
|
||||
private int Paginate(float yLocation, float yTopMargin, float yBottomMargin)
|
||||
{
|
||||
float yPageSize = yTopMargin - yBottomMargin;
|
||||
// TODO: This does not account for a long step as the last step that would exceed more than one page and
|
||||
// that has an end message that needs to be accounted for in determining pagination. To do that the last
|
||||
// child should be the only paragraph that accounts for the End message.
|
||||
//
|
||||
// If last step & there should be an end message, pagination tests need to account for the 3 lines the end
|
||||
// message uses. The 3 is for a line above, the end message line & the line below (in case there is a border/box line).
|
||||
float yEndMsg = !MyItemInfo.IsSection && MyItemInfo.MyHLS.NextItem == null && (MyItemInfo.MyDocStyle.End.Message ?? "") != "" ? 3 * SixLinesPerInch : 0;
|
||||
float yWithinMargins = CalculateYLocation(yLocation, yTopMargin) - yBottomMargin - SixLinesPerInch;
|
||||
// if step is breaking over a number of pages, determine if the current step is the
|
||||
// location of a pagebreak.
|
||||
@@ -482,29 +485,42 @@ namespace Volian.Print.Library
|
||||
}
|
||||
return 0; // this is not an item with a break
|
||||
}
|
||||
if (MyItemInfo.IsStepSection) return 0; // Don't Paginate on a Step Section
|
||||
float mySize = YSize * MyPageHelper.YMultiplier;
|
||||
if (MyItemInfo.IsStepSection)
|
||||
{
|
||||
if (yLocation < yTopMargin) // continuous section
|
||||
{
|
||||
if (ChildrenBelow == null) return 0;
|
||||
// can the title and the first step fit
|
||||
vlnParagraph firstChild = ChildrenBelow[0];
|
||||
// add the first child's size + (the section title's size)
|
||||
float ySizeIncludingFirst = firstChild.YSize + (firstChild.YTop - YTop);
|
||||
if (ySizeIncludingFirst > (yLocation - yBottomMargin - SixLinesPerInch)) return 1;
|
||||
}
|
||||
return 0; // Don't Paginate (page break) on a Step Section if it's first thing on page
|
||||
}
|
||||
if (!MyItemInfo.IsHigh) return 0; // Don't Paginate on a Substep level
|
||||
bool ManualPageBreak = (MyItemInfo.MyConfig as StepConfig).Step_ManualPagebreak;
|
||||
float mySize = YSize * MyPageHelper.YMultiplier;
|
||||
if (_Match16BitPagination) mySize = YSize;
|
||||
float ySize7LPI = YSize + SixLinesPerInch;
|
||||
if (_Match16BitPagination) ySize7LPI += SixLinesPerInch;
|
||||
string firstStep = "No";
|
||||
if (MyItemInfo.IsHigh && MyItemInfo.MyPrevious == null)
|
||||
firstStep = "Yes";
|
||||
if (!ManualPageBreak && mySize <= yWithinMargins) // Don't Paginate if there is enough room, will fit on page
|
||||
if (!ManualPageBreak && mySize+yEndMsg <= yWithinMargins) // Don't Paginate if there is enough room, will fit on page
|
||||
{
|
||||
//Console.WriteLine("'PageBreak',1,'No','HLS will fit on page',{0},{1},{2}, {3}, {4},'{5}'", MyItemInfo.ItemID, YSize, yPageSize, yWithinMargins, (int)(100 * yWithinMargins / yPageSize), MyItemInfo.ShortPath);
|
||||
ShowPageBreak(-1, "HLS will fit on page", firstStep, YSize, yPageSize, yWithinMargins);
|
||||
return 0;
|
||||
}
|
||||
// !MyItemInfo.IsHigh - if (MyItemInfo.IsRNOPart && MyParent.XOffset < XOffset) return 0; // Don't paginate on an RNO to the right
|
||||
if (YSize < yPageSize) // if the entire step can fit on one page, do a page break
|
||||
if (YSize + yEndMsg < yPageSize) // if the entire step can fit on one page, do a page break
|
||||
{
|
||||
//Console.WriteLine("'PageBreak',2,'Yes','HLS will fit on 1 Page',{0},{1},{2}, {3}, {4},'{5}'", MyItemInfo.ItemID, YSize, yPageSize, yWithinMargins, (int)(100 * yWithinMargins / yPageSize), MyItemInfo.ShortPath);
|
||||
ShowPageBreak(5, "HLS will fit on 1 Page at 6 LPI", "Yes", YSize, yPageSize, yWithinMargins);
|
||||
return 1;
|
||||
}
|
||||
// TODO - yEndMsg - compressed size?
|
||||
else if (MyItemInfo.ActiveFormat.MyStepSectionLayoutData.CompressSteps && (ySize7LPI) < (yPageSize * SixLinesPerInch / _SevenLinesPerInch))
|
||||
{
|
||||
//Console.WriteLine("'PageBreak',3,'Yes','HLS will fit on 1 Page at 7 LPI',{0},{1},{2}, {3}, {4},'{5}'", MyItemInfo.ItemID, YSize, yPageSize, yWithinMargins, (int)(100 * yWithinMargins / yPageSize), MyItemInfo.ShortPath);
|
||||
@@ -624,7 +640,7 @@ namespace Volian.Print.Library
|
||||
if (_Match16BitPagination)
|
||||
{
|
||||
yLowerLimit = yStart - SixLinesPerInch + ySpaceOnCurPage / 2;
|
||||
if ((yStart + MyItemInfo.MyDocStyle.Layout.TopRow + 2 * SixLinesPerInch) > ((MyItemInfo.MyDocStyle.Layout.TopRow + yPageSize - 2 * SixLinesPerInch) / 2))
|
||||
if ((yStart + MyItemInfo.MyDocStyle.Layout.TopMargin + 2 * SixLinesPerInch) > ((MyItemInfo.MyDocStyle.Layout.TopMargin + yPageSize - 2 * SixLinesPerInch) / 2))
|
||||
yLowerLimit = yStart + 2 * SixLinesPerInch;
|
||||
}
|
||||
// Make sure that the FirstPiece (Caution Note HLS and First Substeps) fit
|
||||
@@ -774,14 +790,18 @@ namespace Volian.Print.Library
|
||||
if (itemInfo.MyTab != null && itemInfo.MyTab.Text != null && itemInfo.MyTab.Text != "")
|
||||
{
|
||||
float localXOffset = XOffset;
|
||||
if (itemInfo.IsStepSection && formatInfo.PlantFormat.FormatData.SectData.SectionNumber.Just == "PSLeft")
|
||||
if (itemInfo.IsSection && !itemInfo.MyDocStyle.CancelSectTitle && itemInfo.MyTab.Text.ToUpper() != "FOLDOUT")
|
||||
{
|
||||
doSectTab = true;
|
||||
localXOffset = (float)formatInfo.PlantFormat.FormatData.SectData.SectionNumber.Pos + (float)itemInfo.MyDocStyle.Layout.LeftMargin;
|
||||
if (itemInfo.IsStepSection && formatInfo.PlantFormat.FormatData.SectData.SectionNumber.Just == "PSLeft")
|
||||
localXOffset = (float)formatInfo.PlantFormat.FormatData.SectData.SectionNumber.Pos + (float)itemInfo.MyDocStyle.Layout.LeftMargin;
|
||||
}
|
||||
if (!itemInfo.IsSection || doSectTab)
|
||||
{
|
||||
mytab = new vlnTab(cb, this, itemInfo.MyTab.Text, itemInfo.MyTab.CleanText, localXOffset, yoff, itemInfo.MyTab.MyFont, doSectTab);
|
||||
PartsLeft.Add(mytab);
|
||||
if (mytab.MyMacro != null) PartsLeft.Add(mytab.MyMacro);
|
||||
}
|
||||
mytab = new vlnTab(cb, this, itemInfo.MyTab.Text, itemInfo.MyTab.CleanText, localXOffset, yoff, itemInfo.MyTab.MyFont, doSectTab);
|
||||
PartsLeft.Add(mytab);
|
||||
if (mytab.MyMacro != null) PartsLeft.Add(mytab.MyMacro);
|
||||
}
|
||||
AdjustWidth(itemInfo, maxRNO, formatInfo, mytab);
|
||||
AdjustXOffsetForTab(itemInfo, maxRNO, formatInfo, mytab);
|
||||
@@ -794,7 +814,11 @@ namespace Volian.Print.Library
|
||||
yoff += SetHeader(this, cb, itemInfo, formatInfo);
|
||||
YOffset = yoff;
|
||||
AddMacros(itemInfo, mytab);
|
||||
if (mytab != null) mytab.YOffset = yoff;
|
||||
if (mytab != null)
|
||||
{
|
||||
mytab.YOffset = yoff;
|
||||
if (mytab.MyMacro != null) mytab.MyMacro.YOffset = yoff;
|
||||
}
|
||||
if (itemInfo.MyContent.MyGrid != null)
|
||||
{
|
||||
VlnFlexGrid myFlexGrid = new VlnFlexGrid(1,1);
|
||||
@@ -853,7 +877,11 @@ namespace Volian.Print.Library
|
||||
Width = GetTableWidth(cb, IParagraph, MyItemInfo.MyDocStyle.Layout.PageWidth);
|
||||
CalculateXOffset(itemInfo, maxRNO, formatInfo);
|
||||
}
|
||||
if (!itemInfo.IsStepSection || formatInfo.PlantFormat.FormatData.SectData.StepSectionData.StepSectionLayoutData.ShowSectionTitles)
|
||||
// Determine if section title is output
|
||||
if (!itemInfo.IsStepSection
|
||||
|| (formatInfo.PlantFormat.FormatData.SectData.StepSectionData.StepSectionLayoutData.ShowSectionTitles
|
||||
&& !MyItemInfo.MyDocStyle.CancelSectTitle
|
||||
&& !MyItemInfo.MyDocStyle.SpecialStepsFoldout))
|
||||
{
|
||||
yoff += Height;
|
||||
yoff += AdjustForBlankLines();
|
||||
@@ -923,7 +951,7 @@ namespace Volian.Print.Library
|
||||
vlnParagraph hls1 = MyParent;
|
||||
while (hls1.MyParent != null && !hls1.MyItemInfo.IsHigh) hls1 = hls1.MyParent;
|
||||
XOffset = hls1.XOffset + hls1.Width / 2 - Width / 2; // xoffset if AER column
|
||||
int colR = int.Parse(formatInfo.MyStepSectionLayoutData.ColRTable.Split(",".ToCharArray())[itemInfo.ColumnMode]);
|
||||
float colR = float.Parse(formatInfo.MyStepSectionLayoutData.ColRTable.Split(",".ToCharArray())[itemInfo.ColumnMode]);
|
||||
float xLowerLimit = 6; // Adjusted for HLP VE-PROMS
|
||||
float xUpperLimit = hls1.XOffset + hls1.Width + colR * itemInfo.ColumnMode; // 20110429 RHM Adjusted for RNO Tables Removed +18; // Adjusted for HLP VE-PROMS
|
||||
if (!aerTableOrFigure && itemInfo.RNOLevel == 0) // Centered Table of Figure
|
||||
@@ -944,6 +972,7 @@ namespace Volian.Print.Library
|
||||
}
|
||||
private float AdjustForBlankLines()
|
||||
{
|
||||
if (MyItemInfo.MyDocStyle.SpecialStepsFoldout) return 0;
|
||||
int everyNLines = MyItemInfo.FormatStepData == null ? 1 : MyItemInfo.FormatStepData.StepLayoutData.EveryNLines ?? 1;
|
||||
if (MyItemInfo.Ordinal % everyNLines == 0 || MyItemInfo.NextItem == null) return SixLinesPerInch;
|
||||
return 0;
|
||||
@@ -1067,6 +1096,7 @@ namespace Volian.Print.Library
|
||||
System.Drawing.Font myFont = vlntxt.TextFont.WindowsFont;
|
||||
if (!itemInfo.IsTable && StepRTB.MyFontFamily != null)
|
||||
myFont = new System.Drawing.Font(StepRTB.MyFontFamily, myFont.Size, myFont.Style);
|
||||
if (itemInfo.IsHigh && itemInfo.MyDocStyle.UndSpecialStepsFoldout) myFont = new System.Drawing.Font(myFont.FontFamily, myFont.Size, myFont.Style | FontStyle.Underline);
|
||||
_RtfSB.Append(AddFontTable(myFont));
|
||||
_RtfSB.Append(vlntxt.StartText);
|
||||
_RtfSB.Append("}");
|
||||
@@ -1105,7 +1135,7 @@ namespace Volian.Print.Library
|
||||
xoff = XOffset; // XOffset has left margin included
|
||||
vlnHeader myHeader = new vlnHeader(this, cb, itemInfo.MyHeader.Text, itemInfo.MyHeader.CleanText.TrimStart(" ".ToCharArray()), xoff, YOffset, itemInfo.MyHeader.MyFont);
|
||||
PartsAbove.Add(myHeader);
|
||||
return myHeader.Height + SixLinesPerInch;
|
||||
return myHeader.Height + (!MyItemInfo.MyDocStyle.SpecialStepsFoldout ? SixLinesPerInch : 0);
|
||||
}
|
||||
private float AdjustToCharPosition(float position, float? CPI)
|
||||
{
|
||||
|
Reference in New Issue
Block a user