Changed NextItem property to use GetNextItem method when printing

Added Profile debug
Added Command-line parameters (/X= and /Y=) to specify the offset used for Compare.
Changed NextItem property to use GetNextItem method when printing.
Remove PrintTimer which has been replaced with ProfileTimer
Added Profile debug
Added code to handle special characters when printing,
Added Profile debug
Changed NextItem property to use GetNextItem method when printing
This commit is contained in:
Rich
2015-01-19 20:56:35 +00:00
parent d501a39a7b
commit 389c6575d0
4 changed files with 151 additions and 39 deletions

View File

@@ -65,6 +65,7 @@ namespace Volian.Print.Library
}
public float Add(PdfContentByte cb, ItemInfoList itemInfoList, float xoff, float yoff, float yoffRight, int rnoLevel, int maxRNO, FormatInfo formatInfo, PromsPrinter pp)
{
int profileDepth = ProfileTimer.Push(">>>> vlnParagraphs.Add");
bool bxHlsDraw = false;
int? bxIndex = null;
vlnBox box = null;
@@ -151,7 +152,7 @@ namespace Volian.Print.Library
{
if ((childItemInfo.IsCaution || childItemInfo.IsNote) &&
childItemInfo.MyPrevious != null && childItemInfo.MyPrevious.MyContent.Type != childItemInfo.MyContent.Type &&
childItemInfo.NextItemCount > 0 && childItemInfo.GetNextItem()!= null && childItemInfo.MyContent.Type == childItemInfo.GetNextItem().MyContent.Type)
childItemInfo.NextItemCount > 0 && childItemInfo.NextItem!= null && childItemInfo.MyContent.Type == childItemInfo.NextItem.MyContent.Type)
childItemInfo.SetupTags(); // added for V.C. Summer Transition caution in EOP-15.0 step 5.4
if (lastHeader != null)
{
@@ -364,6 +365,7 @@ namespace Volian.Print.Library
// after the last child substep when doing a Component table row (FNP Component Lists), set the value
// of the yoff to be the bottom most line in the table.
if (didComponentTableRow) yoff = tableBottomMost;
ProfileTimer.Pop(profileDepth);
return yoff;
}
public float ToPdf(PdfContentByte cb, float yPageStart, ref float yTopMargin, ref float yBottomMargin)
@@ -499,13 +501,19 @@ namespace Volian.Print.Library
if (sch != null && sch.Section_PrintHdr != "Y") doprint = false;
}
if (MyItemInfo.MyContent.MyGrid != null)
{
int profileDepth = ProfileTimer.Push(">>>> vlnParagraph.DrawDrid");
retval = DrawGrid(cb, ref yPageStart, yTopMargin, yBottomMargin, ref yLocation);
ProfileTimer.Pop(profileDepth);
}
else
{
if (doprint)
{
int profileDepth = ProfileTimer.Push(">>>> vlnParagraph.DrawText");
retval = DrawText(cb, ref yPageStart, yTopMargin, yBottomMargin, ref yLocation);
SectionContinuePrinted = true;
ProfileTimer.Pop(profileDepth);
}
}
if (MyItemInfo.IsHigh)
@@ -692,8 +700,8 @@ namespace Volian.Print.Library
{
// This section of code draws the lines around the substeps (the actual table part)
Paragraph horzLine = new Paragraph(ii.ActiveFormat.PlantFormat.FormatData.BoxList[0].BXHorz, iSymblFont);
bool bottomOfTable = (ii.GetNextItem() == null || ii.NextItemCount == 0) ||
(MyPageHelper.ParaBreaks.Count > 0 && MyPageHelper.ParaBreaks[0].MyItemInfo.ItemID == ii.GetNextItem().ItemID);
bool bottomOfTable = (ii.NextItem == null || ii.NextItemCount == 0) ||
(MyPageHelper.ParaBreaks.Count > 0 && MyPageHelper.ParaBreaks[0].MyItemInfo.ItemID == ii.NextItem.ItemID);
// if bottom of table use different cross/beg/end chars than if in middle of table.
Paragraph leftLine = new Paragraph(bottomOfTable ? bx.BXLLC : bx.BXMLS, iSymblFont);
Paragraph rightLine = new Paragraph(bottomOfTable ? bx.BXLRC : bx.BXMRS, iSymblFont);
@@ -738,7 +746,7 @@ namespace Volian.Print.Library
// Now handle middle parts of the table. For whatever sub level we're at, draw the cross character
// and the horizontal. This is case where the component number may have multiple descriptions,positions, etc. associated
// with it.
if (!ii.MyParent.IsHigh && ii.GetNextItem() != null && ii.NextItemCount > 0)
if (!ii.MyParent.IsHigh && ii.NextItem != null && ii.NextItemCount > 0)
{
// draw horizontally from this sublevel to the end.
int sublev = 0;
@@ -791,12 +799,12 @@ namespace Volian.Print.Library
if (MyItemInfo.ActiveFormat.PlantFormat.FormatData.PrintData.SpecialCaseCalvert && (MyItemInfo.IsCaution || MyItemInfo.IsNote || MyItemInfo.IsNote1))
{
bool diffAsPrev = MyItemInfo.MyPrevious == null || (MyItemInfo.MyPrevious != null && MyItemInfo.MyContent.Type != MyItemInfo.MyPrevious.MyContent.Type);
bool diffAsNext = MyItemInfo.GetNextItem() == null || (MyItemInfo.GetNextItem() != null && MyItemInfo.MyContent.Type != MyItemInfo.GetNextItem().MyContent.Type);
bool diffAsNext = MyItemInfo.NextItem == null || (MyItemInfo.NextItem != null && MyItemInfo.MyContent.Type != MyItemInfo.NextItem.MyContent.Type);
if (diffAsPrev && diffAsNext) doAlign = true;
}
// Check if only one line, i.e. "Height < (1.2F * IParagraph.Leading". The Leading can be for six or seven lines per inch, so the 1.2
// multiplier accounts for both.
if (!MyItemInfo.IsStepSection && MyItemInfo.FormatStepData.CenterOneLineOnly && ((MyItemInfo.MyPrevious == null && MyItemInfo.GetNextItem() == null) || MyItemInfo.FormatStepData.SeparateBox || doAlign) && Height < (1.2F * IParagraph.Leading))
if (!MyItemInfo.IsStepSection && MyItemInfo.FormatStepData.CenterOneLineOnly && ((MyItemInfo.MyPrevious == null && MyItemInfo.NextItem == null) || MyItemInfo.FormatStepData.SeparateBox || doAlign) && Height < (1.2F * IParagraph.Leading))
IParagraph.Alignment = Element.ALIGN_CENTER;
// if this step is centered, but not part of the checklist or valvelist format, use itextsharp to center it.
// if it was part of the checklist or valvelist, then the centering is based on the column definitions for the table and
@@ -825,7 +833,9 @@ namespace Volian.Print.Library
if (DebugPagination.IsOpen)
DebugPagination.WriteLine("Very Low {0},{1},{2},{3},{4},{5}", MyItemInfo.ShortPath, MyItemInfo.ItemID, yLocation, Height, yLocation - Height, yTopMargin - MyItemInfo.MyDocStyle.Layout.PageLength);
}
int profileDepth = ProfileTimer.Push(">>>> Rtf2Pdf.TextAt");
retval = Rtf2Pdf.TextAt(cb, IParagraph, XOffset, yLocation, Width, 100, DebugInfo + string.Format(",YLines = {0}",YSize/SixLinesPerInch), yBottomMargin);
ProfileTimer.Pop(profileDepth);
if (retval == 0) // problem occurred - paragraph was not able to be printed on page
{ // pagination logic needs to be fixed.
ForcePagination(cb, ref yPageStart, yTopMargin, yBottomMargin, ref yLocation, ref retval);
@@ -950,6 +960,7 @@ namespace Volian.Print.Library
//private bool _TextDebug = false; //true; this will turn on a writeline with debug in DrawText()
private float DrawFigure(PdfContentByte cb, float yBottomMargin, float yLocation)
{
int profileDepth = ProfileTimer.Push("vlnParagraph.DrawFigure");
float retval = yLocation;
if (ImageText != null)
{
@@ -966,12 +977,14 @@ namespace Volian.Print.Library
retval = Rtf2Pdf.FigureAt(cb, it_image, XOffset + MyItemInfo.FormatStepData.Font.CharsToTwips, yLocation, Width * MyPageHelper.YMultiplier, Height * MyPageHelper.YMultiplier, DebugInfo, yBottomMargin, !MyItemInfo.FormatStepData.Type.Contains("Borderless"));
}
}
ProfileTimer.Pop(profileDepth);
return retval;
}
private string DebugInfo
{
get
{
if (!Rtf2Pdf.PdfDebug) return "No Path";
return string.Format("DebugID = {0}, ID={1} Type={2} TypeName='{3}' StepLevel={4} ShortPath={5} Width={6} Left={7}",
DebugId, MyItemInfo.ItemID, MyItemInfo.FormatStepType, MyItemInfo.FormatStepData == null ? "NoStepData" : MyItemInfo.FormatStepData.Type, MyItemInfo.StepLevel, MyItemInfo.ShortPath, Width, XOffset);
}
@@ -1049,7 +1062,12 @@ namespace Volian.Print.Library
private static bool DoSubs = true; // flag whether to print substeps (don't if doing continued checklist header)
public override float ToPdf(PdfContentByte cb, float yPageStart, ref float yTopMargin, ref float yBottomMargin)
{
if (MyItemInfo.IsFootnote && Processed) return yPageStart;
int profileDepth = ProfileTimer.Push(">>>> vlnParagraph.ToPdf");
if (MyItemInfo.IsFootnote && Processed)
{
ProfileTimer.Pop(profileDepth);
return yPageStart;
}
bool doThreeContinues = false;
// For BGE, the very first subsection's pagelist items were not correct - the section/meta section titles were
// at the wrong level. Reset the page helper's section.
@@ -1087,7 +1105,10 @@ namespace Volian.Print.Library
//_MyLog.InfoFormat("NewPage 9 {0}", cb.PdfWriter.CurrentPageNumber);
MyPageHelper.MyPromsPrinter.CreateWordDocPdf(cb, si, ref tmp, ref tmpstr);
Processed = true;
return yPageStart;
{
ProfileTimer.Pop(profileDepth);
return yPageStart;
}
}
float yLocalypagestart = yPageStart;
// yPageStart is offset into roll; YTopMost is offset of topmost of this paragraph.
@@ -1098,7 +1119,9 @@ namespace Volian.Print.Library
MyPageHelper.OldTemplateContMsg = false;
if(DebugText.IsOpen) DebugText.WriteLine("ToPdf1:{0},'{1}',{2},{3},{4},{5}", MyItemInfo.ItemID, MyItemInfo.ShortPath, XOffset, yLocation, yPageStart, YTopMost);
int profileDepth1 = ProfileTimer.Push(">>>> vlnParagraph.Paginate");
int paginate = Paginate(yLocation, yTopMargin, yBottomMargin);
ProfileTimer.Pop(profileDepth1);
bool firstHighLevelStep = MyItemInfo.IsHigh && (MyItemInfo.MyPrevious == null);
bool doSectionTitleContinued = false; // will add " Continued" to the section title if format flag is set
DocStyle docstyle = null;
@@ -1374,7 +1397,6 @@ namespace Volian.Print.Library
DoCheckOffHeader(cb, MyItemInfo, yLocation, yTopMargin, yPageStart);
break;
}
// If "doSectionTitleContinued" is true then print the section title with "(Continued)" appended to it
// format must have ContinueSectinHeader format flag set to true
if (doSectionTitleContinued)
@@ -1471,7 +1493,9 @@ namespace Volian.Print.Library
MyPageHelper.AlarmYoffEnd = CalculateYOffset(yPageStart, yTopMargin) + (2 * SixLinesPerInch);
}
}
int profileDepth2 = ProfileTimer.Push(">>>> vlnParagraph.ParagraphToPdf");
yPageStart = ParagraphToPdf(cb, yPageStart, yTopMargin, yBottomMargin);
ProfileTimer.Pop(profileDepth2);
// If the yPageStart changes by more than a small amount (pagination) in the RNO (right column), then update
// yPageStart for the AER (left column).
float yPageStartRNO = ChildrenRight.ToPdf(cb, yPageStart, ref yTopMargin, ref yBottomMargin);
@@ -1479,7 +1503,7 @@ namespace Volian.Print.Library
yPageStart = yPageStartRNO;
yPageStart = ChildrenBelow.ToPdf(cb, yPageStart, ref yTopMargin, ref yBottomMargin);
if (MyItemInfo.IsHigh && MyItemInfo.GetNextItem() == null) // last hls, add the 'end' message, if there is one
if (MyItemInfo.IsHigh && MyItemInfo.NextItem == null) // last hls, add the 'end' message, if there is one
{
docstyle = MyItemInfo.MyDocStyle;
// if the EndForSingle format flag is set to false, then we do not print an End message if the section
@@ -1491,7 +1515,7 @@ namespace Volian.Print.Library
if (si.MyActiveParent.IsSection) // is this meta/subsection. Only put end message out on last section
{
ItemInfo mysect = si as ItemInfo;
if (mysect.GetNextItem() != null && !docstyle.End.EndMessageOnEachSubSection) _lastSect = false;
if (mysect.NextItem != null && !docstyle.End.EndMessageOnEachSubSection) _lastSect = false;
}
string myMsg = (docstyle.End == null) ? null : docstyle.End.FixedMessage;
if (myMsg != null && !_skipEndMessage && _lastSect)
@@ -1555,7 +1579,7 @@ namespace Volian.Print.Library
// Pages that broke within pagination logic above had footnote location set during pagination code.
if (MyPageHelper.NotesToFootNotes != null && MyPageHelper.NotesToFootNotes.Count > 0)
MyPageHelper.NotesToFootNotesYoffset = CalculateYLocation(yPageStart - YBottomMost, yTopMargin);
ProfileTimer.Pop(profileDepth);
return yPageStart;
}
@@ -2168,6 +2192,7 @@ namespace Volian.Print.Library
}
public vlnParagraph(vlnParagraph parent, PdfContentByte cb, ItemInfo itemInfo, float xoff, float yoff, int rnoLevel, int maxRNO, FormatInfo formatInfo, string prefix, string suffix, float yoffRightParent, bool loadChildren, PromsPrinter pp)
{
int profileDepth = ProfileTimer.Push(">>>> vlnParagraph");
Prefix = prefix;
Suffix = suffix;
MyItemInfo = itemInfo;
@@ -2184,6 +2209,7 @@ namespace Volian.Print.Library
MyPageHelper.NotesToFootNotesHLS.Add(itemInfo.MyHLS.ItemID, notesList);
}
Processed = true; // don't want to print during normal ToPdf/ParagraphToPdf cycle - print in vlnsvgpagehelper
ProfileTimer.Pop(profileDepth);
return;
}
// do some 'setup' for Calvert Alarms:
@@ -2222,7 +2248,7 @@ namespace Volian.Print.Library
MyTopRNO = MyParent.MyTopRNO;
if (MyTopRNO != null) MyTopRNO.LastRNO = this;
}
if (!MyPageHelper.MyParagraphs.ContainsKey(itemInfo.ItemID) && !itemInfo.IsFootnote) MyPageHelper.MyParagraphs.Add(itemInfo.ItemID, this);
// if this a continuous subsection, refresh the style.
@@ -2238,6 +2264,7 @@ namespace Volian.Print.Library
// that steps need put out on a page for the pagination logic, and since there are no steps
// we don't want to have to worry about putting this out for pagination logic.
Processed = true;
ProfileTimer.Pop(profileDepth);
return;
}
YTopMost = YOffset = yoff;
@@ -2619,6 +2646,7 @@ namespace Volian.Print.Library
bool dropCheckoff = itemInfo.ActiveFormat.PlantFormat.FormatData.ProcData.CheckOffData.DropCheckOff;
if (itemInfo.MyContent.MyGrid != null)
{
int profileDepth1 = ProfileTimer.Push(">>>> Before vlnParagraph.Grid");
//Use Static MyFlexGrid - BWD INST2 - FlexGrid Errors
MyFlexGrid.LoadGrid(itemInfo);
MyGrid = new vlnTable(MyFlexGrid, cb);
@@ -2649,9 +2677,11 @@ namespace Volian.Print.Library
yoff += (Height + yoffForBorder); //(2 * SixLinesPerInch));
CalculateXOffsetGridOrFigure(itemInfo, maxRNO, formatInfo);
yoff = (float)Math.Ceiling(yoff);
ProfileTimer.Pop(profileDepth1);
}
else if (itemInfo.IsFigure) // if a figure we've got to determine the size:
{
int profileDepth2 = ProfileTimer.Push(">>>> Before vlnParagraph.Figure");
string erMsg = null;
if (itemInfo.MyContent.Text != null)
{
@@ -2712,6 +2742,7 @@ namespace Volian.Print.Library
if (erMsg != null) Rtf = GetRtf(erMsg, itemInfo.ActiveFormat.PlantFormat.FormatData.Font);
CalculateXOffsetGridOrFigure(itemInfo, maxRNO, formatInfo);
}
ProfileTimer.Pop(profileDepth2);
}
else
{
@@ -3059,6 +3090,7 @@ namespace Volian.Print.Library
// the row.
if (savCheckListBottomMost != 0) YBottomMost = Math.Max(savCheckListBottomMost, YBottomMost);
if (XOffsetCenter != null) XOffset = (float)XOffsetCenter;
ProfileTimer.Pop(profileDepth);
}
public override string Rtf
{
@@ -3071,6 +3103,7 @@ namespace Volian.Print.Library
}
private void BuildRtf()
{
int profileDepth = ProfileTimer.Push(">>>> BuildRtf");
if (_Rtf == null)
{
if (MyItemInfo.ActiveFormat.PlantFormat.FormatData.PrintData.SpecialCaseCalvertAlarm && MyItemInfo.IsCaution1 &&
@@ -3091,6 +3124,7 @@ namespace Volian.Print.Library
Rtf = Rtf.Replace("{Backspace}", "");
}
}
ProfileTimer.Pop(profileDepth);
}
// for Calvert (BGE) alarms, some step text is kept on the same line as its parent. This
// is flagged by the -1 row in the template definition.
@@ -3410,14 +3444,14 @@ namespace Volian.Print.Library
{
if ((MyItemInfo.IsCaution || MyItemInfo.IsNote || MyItemInfo.MyParent.IsCaution || MyItemInfo.MyParent.IsNote) && !MyItemInfo.FormatStepData.SpaceIn
&& (MyItemInfo.Steps == null || MyItemInfo.Steps.Count == 0)
&& (MyItemInfo.GetNextItem() == null || MyItemInfo.MyContent.Type != MyItemInfo.GetNextItem().MyContent.Type)) return 0;
if (everyNLines == 99 && MyItemInfo.GetNextItem() == null)
&& (MyItemInfo.NextItem == null || MyItemInfo.MyContent.Type != MyItemInfo.NextItem.MyContent.Type)) return 0;
if (everyNLines == 99 && MyItemInfo.NextItem == null)
{
if (MyItemInfo.Steps != null && MyItemInfo.Steps.Count > 0 && MyItemInfo.Steps[0].MyContent.Type == MyItemInfo.MyContent.Type) return 0;
if (MyItemInfo.MyParent.GetNextItem() != null && MyItemInfo.MyParent.GetNextItem().MyContent.Type == MyItemInfo.MyContent.Type) return 0;
if (MyItemInfo.MyParent.NextItem != null && MyItemInfo.MyParent.NextItem.MyContent.Type == MyItemInfo.MyContent.Type) return 0;
}
}
if (MyItemInfo.Ordinal % everyNLines == 0 || MyItemInfo.GetNextItem() == null) return SixLinesPerInch;
if (MyItemInfo.Ordinal % everyNLines == 0 || MyItemInfo.NextItem == null) return SixLinesPerInch;
// Pagination issue to be used with yEndsWithBlankLine in Pagination code, but not checked in yet.
//if (MyItemInfo.Ordinal % everyNLines == 0 || MyItemInfo.NextItem == null) return SixLinesPerInch;
return 0;
@@ -3607,6 +3641,7 @@ namespace Volian.Print.Library
private StringBuilder _RtfSB = null;
public string GetRtf(ItemInfo itemInfo, string prefix, string suffix)
{
int profileDepth = ProfileTimer.Push(">>>> GetRtf");
_RtfSB = new StringBuilder();
DisplayText vlntxt = new DisplayText(itemInfo, E_EditPrintMode.Print, E_ViewMode.View, true, E_FieldToEdit.StepText, false, prefix, suffix);
System.Drawing.Font myFont = vlntxt.TextFont.WindowsFont;
@@ -3651,7 +3686,7 @@ namespace Volian.Print.Library
}
}
}
ProfileTimer.Pop(profileDepth);
return rtf;
}
private float _XOffsetBox = 0;