This commit is contained in:
2013-02-08 12:22:26 +00:00
parent 591f3df242
commit 7f58611e6b
4 changed files with 180 additions and 39 deletions

View File

@@ -177,13 +177,13 @@ namespace Volian.Print.Library
if (doprint)retval = DrawText(cb, ref yPageStart, yTopMargin, yBottomMargin, ref yLocation);
if (MyItemInfo.IsHigh)
{
MyPageHelper.PageBookmarks.Add(MyItemInfo, MyItemInfo.MyTab.CleanText + " " + MyItemInfo.DisplayText,
MyPageHelper.PageBookmarks.Add(MyItemInfo, (MyItemInfo.MyTab == null)?"":MyItemInfo.MyTab.CleanText + " " + MyItemInfo.DisplayText,
new PdfDestination(PdfDestination.FITBH, yLocation + YVeryTop - YTopMost + SixLinesPerInch));
}
}
if (MyItemInfo.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.WolfcreekCKLFormat)
{
WCN_DrawBoxLines(cb, MyItemInfo, yPageStart, yTopMargin, yBottomMargin, yLocation);
DrawChkOrValveTableLines(cb, MyItemInfo, yPageStart, yTopMargin, yBottomMargin, yLocation);
}
if (MyItemInfo.IsSection)
{
@@ -208,18 +208,15 @@ namespace Volian.Print.Library
//if (localYPageStart != yPageStart) DebugText.WriteLine("ParToPdf-yPagestartDiff:{0},{1},{2}", MyItemInfo.ItemID, localYPageStart, yPageStart);
return yPageStart;
}
// A few things need completed for the WCNCKL format check list boxes:
// 1) support pagination. This includes tacking on a continued message, breaking table where necessary
// and putting HLS on top of next page, along with its prefix/suffix.
// 2) support seven lines per inch - right now increments are hard coded at 12 = one line.
private void WCN_DrawBoxLines(PdfContentByte cb, ItemInfo ii, float yPageStart, float yTopMargin, float yBottomMargin, float yLocation)
private void DrawChkOrValveTableLines(PdfContentByte cb, ItemInfo ii, float yPageStart, float yTopMargin, float yBottomMargin, float yLocation)
{
if (!ii.IsStep || ii.IsCaution || ii.IsNote) return;
Box bx = ii.ActiveFormat.PlantFormat.FormatData.BoxList[0];
float lpi = MyPageHelper.YMultiplier == 1.0 ? SixLinesPerInch : _SevenLinesPerInch;
bool savedebug = Rtf2Pdf.PdfDebug;
Rtf2Pdf.PdfDebug = false;
System.Drawing.Font symbFont = new System.Drawing.Font("VESymbFix", 10);
System.Drawing.Font symbFont = new System.Drawing.Font("VESymbFix", (float)ii.FormatStepData.Font.Size);
iTextSharp.text.Font iSymblFont = Volian.Svg.Library.VolianPdf.GetFont(symbFont);
iSymblFont.Color = new iTextSharp.text.Color(PrintOverride.OverrideTextColor(System.Drawing.Color.Black));
// The vertPos array from the format defines the column locations:
@@ -239,37 +236,120 @@ namespace Volian.Print.Library
int countLine = 0;
string preSuf_Fix = (ii.FormatStepData.Prefix != null && ii.FormatStepData.Prefix != "") ? ii.FormatStepData.Prefix : null;
if (preSuf_Fix != null) countLine++; // account for a line of prefix (if no \par)
int hIndx = preSuf_Fix.IndexOf(@"{\par}");
while (preSuf_Fix != null && hIndx >= 0)
// if this is a proportional font, need to 'draw' the prefix/suffix. NOTE that the suffix should
// just list the headers and the prefix can be 'empty'.
if (ii.FormatStepData.Font.FontIsProportional())
{
hIndx = preSuf_Fix.IndexOf(@"{\par}", hIndx + 1);
countLine++;
}
preSuf_Fix = (ii.FormatStepData.Suffix != null && ii.FormatStepData.Suffix != "") ? ii.FormatStepData.Suffix : null;
if (preSuf_Fix != null) countLine++; // account for a line of suffix (if no \par)
hIndx = preSuf_Fix.IndexOf(@"{\par}");
while (preSuf_Fix != null && hIndx >= 0)
{
hIndx = preSuf_Fix.IndexOf(@"{\par}", hIndx + 1);
countLine++;
}
// get first and last vertpos for location of lines:
// for each line of text, draw the start & end box line:
countLine = (int)(this.Height / lpi) - countLine;
float yLocVertLine = yLocation - lpi/2;
for (int i = 0; i < countLine; i++)
{
Rtf2Pdf.TextAt(cb, paraVertLine, float.Parse(vertPos[0]) + (float)ii.MyDocStyle.Layout.LeftMargin - csize, yLocVertLine, lWidth, 100, null, yBottomMargin);
Rtf2Pdf.TextAt(cb, paraVertLine, float.Parse(vertPos[cntVertPos - 1]) + (float)ii.MyDocStyle.Layout.LeftMargin - csize, yLocVertLine, lWidth, 100, null, yBottomMargin);
float yLocVertLine = yLocation + (lpi/2);
// Prefix, i.e. Top line:
Paragraph topLeftLine = new Paragraph(bx.BXULC, iSymblFont);
Rtf2Pdf.TextAt(cb, topLeftLine, float.Parse(vertPos[0]) + (float)ii.MyDocStyle.Layout.LeftMargin - csize, yLocVertLine, lWidth, 100, null, yBottomMargin);
Paragraph topRightLine = new Paragraph(bx.BXURC, iSymblFont);
Rtf2Pdf.TextAt(cb, topRightLine, float.Parse(vertPos[cntVertPos - 1]) + (float)ii.MyDocStyle.Layout.LeftMargin - csize, yLocVertLine, lWidth, 100, null, yBottomMargin);
Paragraph horzLine = new Paragraph(bx.BXHorz, iSymblFont);
float thPos = float.Parse(vertPos[0]) + csize;
while (thPos < float.Parse(vertPos[cntVertPos - 1]))
{
Rtf2Pdf.TextAt(cb, horzLine, thPos + (float)ii.MyDocStyle.Layout.LeftMargin - csize, yLocVertLine, lWidth, 100, null, yBottomMargin);
thPos += csize;
}
// Vertical Lines around HLS
//int countLine = (int)(this.Height / lpi);
yLocVertLine = yLocation - (lpi / 2);
for (int i = 0; i < 1; i++)
{
Rtf2Pdf.TextAt(cb, paraVertLine, float.Parse(vertPos[0]) + (float)ii.MyDocStyle.Layout.LeftMargin - csize, yLocVertLine, lWidth, 100, null, yBottomMargin);
Rtf2Pdf.TextAt(cb, paraVertLine, float.Parse(vertPos[cntVertPos - 1]) + (float)ii.MyDocStyle.Layout.LeftMargin - csize, yLocVertLine, lWidth, 100, null, yBottomMargin);
yLocVertLine -= lpi;
}
// Suffix, i.e. Column headers.
// first do left/right side chars above and below column headers
//countLine = (int)(this.Height / lpi);
Paragraph sideLeftLine = new Paragraph(bx.BXMLS, iSymblFont);
Rtf2Pdf.TextAt(cb, sideLeftLine, float.Parse(vertPos[0]) + (float)ii.MyDocStyle.Layout.LeftMargin - csize, yLocVertLine, lWidth, 100, null, yBottomMargin);
Rtf2Pdf.TextAt(cb, sideLeftLine, float.Parse(vertPos[0]) + (float)ii.MyDocStyle.Layout.LeftMargin - csize, yLocVertLine-(2*lpi), lWidth, 100, null, yBottomMargin);
Paragraph sideRightLine = new Paragraph(bx.BXMRS, iSymblFont);
Rtf2Pdf.TextAt(cb, sideRightLine, float.Parse(vertPos[6]) + (float)ii.MyDocStyle.Layout.LeftMargin - csize, yLocVertLine, lWidth, 100, null, yBottomMargin);
Rtf2Pdf.TextAt(cb, sideRightLine, float.Parse(vertPos[6]) + (float)ii.MyDocStyle.Layout.LeftMargin - csize, yLocVertLine - (2 * lpi), lWidth, 100, null, yBottomMargin);
// now do the lines with the 'T' type lines for top/bottom of vertical lines.
thPos = float.Parse(vertPos[0]) + csize;
while (thPos < float.Parse(vertPos[cntVertPos - 1]))
{
Rtf2Pdf.TextAt(cb, horzLine, thPos + (float)ii.MyDocStyle.Layout.LeftMargin - csize, yLocVertLine, lWidth, 100, null, yBottomMargin);
Rtf2Pdf.TextAt(cb, horzLine, thPos + (float)ii.MyDocStyle.Layout.LeftMargin - csize, yLocVertLine - (2 * lpi), lWidth, 100, null, yBottomMargin);
thPos += csize;
}
// now do the vertical bar between header words and the column header words.
yLocVertLine -= lpi;
string [] colHdrs = _MyItemInfo.FormatStepData.Suffix.Substring(_MyItemInfo.FormatStepData.Suffix.IndexOf(";")+1).Split(",".ToCharArray());
iTextSharp.text.Font iHdrFont = Volian.Svg.Library.VolianPdf.GetFont(_MyItemInfo.FormatStepData.Font.WindowsFont);
iHdrFont.Color = new iTextSharp.text.Color(PrintOverride.OverrideTextColor(System.Drawing.Color.Black));
Paragraph topT = new Paragraph(bx.BXUMID, iSymblFont);
Paragraph crossT = new Paragraph(bx.BXMID, iSymblFont);
for (int i = 0; i < cntVertPos; i++)
{
// do vertical line:
Rtf2Pdf.TextAt(cb, paraVertLine, float.Parse(vertPos[i]) + (float)ii.MyDocStyle.Layout.LeftMargin - csize, yLocVertLine, lWidth, 100, null, yBottomMargin);
// do the column header text - center it:
if (i<colHdrs.Length)
{
Paragraph parColHdr = new Paragraph(colHdrs[i], iHdrFont);
// find the center point of column header and subtract 1/2 width of the text to locate the text.
float hloc = (float.Parse(vertPos[i]) + ((float.Parse(vertPos[i + 1]) - float.Parse(vertPos[i])) / 2));
Chunk chk = (Chunk)parColHdr.Chunks[0];
hloc = hloc - (chk.GetWidthPoint() / 2);
Rtf2Pdf.TextAt(cb, parColHdr, hloc + (float)ii.MyDocStyle.Layout.LeftMargin, yLocVertLine, lWidth, 100, null, yBottomMargin);
}
// Do the crosswise table characters, i.e. T and +
if (i > 0 && i < colHdrs.Length)
{
Rtf2Pdf.TextAt(cb, topT, float.Parse(vertPos[i]) + (float)ii.MyDocStyle.Layout.LeftMargin - csize, yLocVertLine + lpi, lWidth, 100, null, yBottomMargin);
Rtf2Pdf.TextAt(cb, crossT, float.Parse(vertPos[i]) + (float)ii.MyDocStyle.Layout.LeftMargin - csize, yLocVertLine - lpi, lWidth, 100, null, yBottomMargin);
}
}
}
else
#region OriginalHLS
{
int hIndx = preSuf_Fix.IndexOf(@"{\par}");
while (preSuf_Fix != null && hIndx >= 0)
{
hIndx = preSuf_Fix.IndexOf(@"{\par}", hIndx + 1);
countLine++;
}
preSuf_Fix = (ii.FormatStepData.Suffix != null && ii.FormatStepData.Suffix != "") ? ii.FormatStepData.Suffix : null;
if (preSuf_Fix != null) countLine++; // account for a line of suffix (if no \par)
hIndx = preSuf_Fix.IndexOf(@"{\par}");
while (preSuf_Fix != null && hIndx >= 0)
{
hIndx = preSuf_Fix.IndexOf(@"{\par}", hIndx + 1);
countLine++;
}
// get first and last vertpos for location of lines:
// for each line of text, draw the start & end box line:
countLine = (int)(this.Height / lpi) - countLine;
float yLocVertLine = yLocation - lpi / 2;
for (int i = 0; i < countLine; i++)
{
Rtf2Pdf.TextAt(cb, paraVertLine, float.Parse(vertPos[0]) + (float)ii.MyDocStyle.Layout.LeftMargin - csize, yLocVertLine, lWidth, 100, null, yBottomMargin);
Rtf2Pdf.TextAt(cb, paraVertLine, float.Parse(vertPos[cntVertPos - 1]) + (float)ii.MyDocStyle.Layout.LeftMargin - csize, yLocVertLine, lWidth, 100, null, yBottomMargin);
yLocVertLine -= lpi;
}
}
#endregion OriginalHLS
}
else
{
// 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.NextItem == null || ii.NextItemCount == 0) ||
(MyPageHelper.ParaBreaks.Count > 0 && MyPageHelper.ParaBreaks[0].MyItemInfo.ItemID == ii.NextItem.ItemID);
Box bx = ii.ActiveFormat.PlantFormat.FormatData.BoxList[0];
// 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);
@@ -360,7 +440,10 @@ namespace Volian.Print.Library
// multiplier accounts for both.
if (!MyItemInfo.IsStepSection && MyItemInfo.FormatStepData.CenterOneLineOnly && MyItemInfo.MyPrevious == null && MyItemInfo.NextItem == null && Height < (1.2F * IParagraph.Leading))
IParagraph.Alignment = Element.ALIGN_CENTER;
if (!MyItemInfo.IsStepSection && MyItemInfo.FormatStepData.StepPrintData.Justify == "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
// was calculated when the paragraph was made.
if (!MyItemInfo.IsStepSection && MyItemInfo.FormatStepData.StepPrintData.Justify == "Center" && !MyItemInfo.FormatStepData.StepLayoutData.AlignWithParentTab)
IParagraph.Alignment = Element.ALIGN_CENTER;
retval = Rtf2Pdf.TextAt(cb, IParagraph, XOffset, yLocation, Width, 100, DebugInfo, yBottomMargin);
if (retval == 0) // problem occurred - paragraph was not able to be printed on page
@@ -1080,7 +1163,18 @@ namespace Volian.Print.Library
{
int stplevl = TheStepLevel(itemInfo);
if (stplevl >= 0 && MyItemInfo.MyHLS.FormatStepData.VertPos[stplevl] > 0)
XOffset = float.Parse(MyItemInfo.MyHLS.FormatStepData.VertPos.Split(",".ToCharArray())[stplevl]) + (float)itemInfo.MyDocStyle.Layout.LeftMargin;
{
if (MyItemInfo.FormatStepData.StepPrintData.Justify == "Center")
{
string[] vertPos = MyItemInfo.MyHLS.FormatStepData.VertPos.Split(",".ToCharArray());
float hloc = (float.Parse(vertPos[stplevl]) + ((float.Parse(vertPos[stplevl + 1]) - float.Parse(vertPos[stplevl])) / 2));
Chunk chk = (Chunk)IParagraph.Chunks[0];
hloc = hloc - (chk.GetWidthPoint() / 2);
XOffset = hloc + (float)itemInfo.MyDocStyle.Layout.LeftMargin;
}
else
XOffset = float.Parse(MyItemInfo.MyHLS.FormatStepData.VertPos.Split(",".ToCharArray())[stplevl]) + (float)itemInfo.MyDocStyle.Layout.LeftMargin;
}
}
}
if (itemInfo.IsTablePart) // Not for grid, this is for old-style tables.
@@ -2079,6 +2173,11 @@ namespace Volian.Print.Library
Width = ToInt(formatInfo.MyStepSectionLayoutData.WidSTablePrint, maxRNO);
Width += _WidthAdjust;
Width += adjwidth;
// if AlignHLSTabWithSect is set, we moved the starting x location of the HLS, and following steps
// to be under section header. Adjust the width accordingly, or the text may go out of the margin.
if (itemInfo.MyDocStyle.AlignHLSTabWithSect)
Width = Width - (float)formatInfo.PlantFormat.FormatData.SectData.SectionHeader.Pos;
}
else if (itemInfo.IsCaution || itemInfo.IsNote)
{