This commit is contained in:
Kathy Ruffing 2011-05-19 13:37:13 +00:00
parent 1b1e5668d1
commit 382ec20867

View File

@ -53,7 +53,9 @@ namespace Volian.Print.Library
box = new vlnBox();
box.MyBox = formatInfo.PlantFormat.FormatData.BoxList[(int)bxIndx];
box.YOffset = yoff;
yoff += 2 * vlnPrintObject.SixLinesPerInch;
int ln = 1; // a format flag determines whether there is a space before the note/caution.
if (childItemInfo.FormatStepData.OneLineBeforeTab) ln++;
yoff += ln * vlnPrintObject.SixLinesPerInch;
}
else // Change Box Style
{
@ -61,7 +63,9 @@ namespace Volian.Print.Library
box = new vlnBox();
box.MyBox = formatInfo.PlantFormat.FormatData.BoxList[(int)bxIndx];
box.YOffset = yoff;
yoff += 2 * vlnPrintObject.SixLinesPerInch;
int ln = 1; // a format flag determines whether there is a space before the note/caution.
if (childItemInfo.FormatStepData.OneLineBeforeTab) ln++;
yoff += ln * vlnPrintObject.SixLinesPerInch;
}
bxIndex = bxIndx;
}
@ -133,7 +137,7 @@ namespace Volian.Print.Library
retval = DrawText(cb, ref yPageStart, yTopMargin, yBottomMargin, ref yLocation);
}
else if (!MyItemInfo.IsStepSection) // Don't ouput the Step Section title
else if (!MyItemInfo.IsStepSection || MyItemInfo.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.StepSectionLayoutData.ShowSectionTitles) // Don't ouput the Step Section title
{
if (MyItemInfo.MyContent.MyGrid != null)
retval = DrawGrid(cb, ref yPageStart, yTopMargin, yBottomMargin, ref yLocation);
@ -170,7 +174,7 @@ namespace Volian.Print.Library
float retval = yLocation;
// 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.FormatStepData.CenterOneLineOnly && MyItemInfo.MyPrevious == null && MyItemInfo.NextItem == null && Height < (1.2F * IParagraph.Leading))
if (!MyItemInfo.IsStepSection && MyItemInfo.FormatStepData.CenterOneLineOnly && MyItemInfo.MyPrevious == null && MyItemInfo.NextItem == null && Height < (1.2F * IParagraph.Leading))
IParagraph.Alignment = Element.ALIGN_CENTER;
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
@ -264,7 +268,7 @@ namespace Volian.Print.Library
if (roImage != null)
{
iTextSharp.text.Image it_image = iTextSharp.text.Image.GetInstance(roImage.Content);
retval = Rtf2Pdf.FigureAt(cb, it_image, XOffset + _CharsToTwips, yLocation, Width * MyPageHelper.YMultiplier, Height * MyPageHelper.YMultiplier, DebugText, yBottomMargin, !MyItemInfo.FormatStepData.Type.Contains("Borderless"));
retval = Rtf2Pdf.FigureAt(cb, it_image, XOffset + MyItemInfo.FormatStepData.Font.CharsToTwips, yLocation, Width * MyPageHelper.YMultiplier, Height * MyPageHelper.YMultiplier, DebugText, yBottomMargin, !MyItemInfo.FormatStepData.Type.Contains("Borderless"));
}
}
return retval;
@ -273,7 +277,7 @@ namespace Volian.Print.Library
{
get
{
return string.Format("DebugID = {0}, ID={1} Type={2} TypeName='{3}' StepLevel={4} DBSequence={5}", DebugId, MyItemInfo.ItemID, MyItemInfo.FormatStepType, MyItemInfo.FormatStepData.Type, MyItemInfo.StepLevel, MyItemInfo.DBSequence);
return string.Format("DebugID = {0}, ID={1} Type={2} TypeName='{3}' StepLevel={4} DBSequence={5}", DebugId, MyItemInfo.ItemID, MyItemInfo.FormatStepType, MyItemInfo.FormatStepData==null?"NoStepData":MyItemInfo.FormatStepData.Type, MyItemInfo.StepLevel, MyItemInfo.DBSequence);
}
}
public override float ToPdf(PdfContentByte cb, float yPageStart, float yTopMargin, float yBottomMargin)
@ -370,7 +374,7 @@ namespace Volian.Print.Library
}
// center it. Just implementing OHLP
float wtpm = (float)docstyle.Layout.PageWidth - (float)docstyle.Layout.LeftMargin;
float centerpos = XOffsetBox + (float)docstyle.Layout.LeftMargin + (wtpm - (myMsg.Length * vlnPrintObject._CharsToTwips)) / 2;
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);
}
}
@ -629,6 +633,7 @@ namespace Volian.Print.Library
while ((YSize - yTop) >= ySpaceOnCurPage)
{
vlnParagraph paraBreak = FindPageBreak(yStart, ySpaceOnCurPage, yLowerLimit, myList);
if (paraBreak == null) break;
// yTopNew is y Location of this page break. YTopMost is top of HLS, including any Cautions/Notes/Boxes/etc
float yTopNew = paraBreak.YVeryTop - YTopMost;
RemoveProcessedParagraphs(myList, yTopNew-yTop);
@ -765,27 +770,27 @@ namespace Volian.Print.Library
XOffset = xoff;
YTopMost = YOffset = yoff;
vlnTab mytab = null;
bool doSectTab = false;
if (itemInfo.MyTab != null && itemInfo.MyTab.Text != null && itemInfo.MyTab.Text != "")
{
mytab = new vlnTab(cb, this, itemInfo.MyTab.Text, itemInfo.MyTab.CleanText, XOffset, yoff, itemInfo.MyTab.MyFont);
float localXOffset = XOffset;
if (itemInfo.IsStepSection && formatInfo.PlantFormat.FormatData.SectData.SectionNumber.Just == "PSLeft")
{
doSectTab = true;
localXOffset = (float)formatInfo.PlantFormat.FormatData.SectData.SectionNumber.Pos + (float)itemInfo.MyDocStyle.Layout.LeftMargin;
}
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);
if (itemInfo.Cautions != null)
{
//yoff += 2 * _SixLinesPerInch;
yoff = ChildrenAbove.Add(cb, itemInfo.Cautions, xoff, yoff, yoff, rnoLevel, maxRNO, formatInfo);
//yoff += 2 * _SixLinesPerInch;
}
if (itemInfo.Notes != null)
{
//yoff += 2 * _SixLinesPerInch;
yoff = ChildrenAbove.Add(cb, itemInfo.Notes, xoff, yoff, yoff, rnoLevel, maxRNO, formatInfo);
//yoff += 2 * _SixLinesPerInch;
}
YTop = yoff;
if (itemInfo.MyHeader != null && itemInfo.MyHeader.Text != null)
if (itemInfo.MyHeader != null && itemInfo.MyHeader.Text != null && !doSectTab)
yoff += SetHeader(this, cb, itemInfo, formatInfo);
YOffset = yoff;
AddMacros(itemInfo, mytab);
@ -817,7 +822,7 @@ namespace Volian.Print.Library
if (val != null)
{
string[] vals = val.Split("\n".ToCharArray());
Width = Int32.Parse(vals[3], System.Globalization.NumberStyles.AllowHexSpecifier) * _CharsToTwips;
Width = Int32.Parse(vals[3], System.Globalization.NumberStyles.AllowHexSpecifier) * MyItemInfo.FormatStepData.Font.CharsToTwips;
int lines = Int32.Parse(vals[2], System.Globalization.NumberStyles.AllowHexSpecifier);
Height = lines * SixLinesPerInch;
yoff += (Height + (2 * SixLinesPerInch));
@ -845,10 +850,10 @@ namespace Volian.Print.Library
Rtf = GetRtf(itemInfo);
if (itemInfo.IsTablePart) // Not for grid, this is for old-style tables.
{
Width = GetTableWidth(cb, IParagraph);
Width = GetTableWidth(cb, IParagraph, MyItemInfo.MyDocStyle.Layout.PageWidth);
CalculateXOffset(itemInfo, maxRNO, formatInfo);
}
if (!itemInfo.IsStepSection) // Don't add any lines for the Section Title
if (!itemInfo.IsStepSection || formatInfo.PlantFormat.FormatData.SectData.StepSectionData.StepSectionLayoutData.ShowSectionTitles)
{
yoff += Height;
yoff += AdjustForBlankLines();
@ -975,8 +980,8 @@ namespace Volian.Print.Library
// else
// ChangeBarLocation()
ChangeBarData cbd = formatInfo.PlantFormat.FormatData.ProcData.ChangeBarData;
int cols = formatInfo.MyStepSectionLayoutData.ColS ?? 0;
int colr = ToInt(formatInfo.MyStepSectionLayoutData.ColRTable, maxRNO);
float cols = formatInfo.MyStepSectionLayoutData.ColS ?? 0;
float colr = ToInt(formatInfo.MyStepSectionLayoutData.ColRTable, maxRNO);
float col = (cbd.AbsoluteFixedChangeColumn) ?
((cbd.FixedAERChangeColumn ?? 0) > 0) ?
(xoff > (cols + colr + COL_WID_ADJ)) ?
@ -1006,13 +1011,13 @@ namespace Volian.Print.Library
if (myPageHelper.ChangeBarDefinition.MyChangeBarLoc == PrintChangeBarLoc.LeftOfText ||
(myPageHelper.ChangeBarDefinition.MyChangeBarLoc == PrintChangeBarLoc.AERleftRNOright &&
!itemInfo.IsInRNO)) msgAlign = Element.ALIGN_RIGHT;
return new vlnChangeBar(cb, this, (float)itemInfo.MyDocStyle.Layout.LeftMargin + (col * _CharsToTwips), yoff, msgAlign);
return new vlnChangeBar(cb, this, (float)itemInfo.MyDocStyle.Layout.LeftMargin + (col * itemInfo.FormatStepData.Font.CharsToTwips), yoff, msgAlign);
}
private int ChangeBarLocation(float c, vlnParagraph paragraph, FormatInfo formatInfo, int maxRNO)
{
int fixedChgCol = formatInfo.PlantFormat.FormatData.ProcData.ChangeBarData.FixedChangeColumn ?? 0;
int cols = formatInfo.MyStepSectionLayoutData.ColS ?? 0;
float cols = formatInfo.MyStepSectionLayoutData.ColS ?? 0;
int colr = ToInt(formatInfo.MyStepSectionLayoutData.ColRTable, maxRNO);
if (fixedChgCol < -10 || fixedChgCol >= 0)
return ((fixedChgCol > 0) ? fixedChgCol :
@ -1020,7 +1025,7 @@ namespace Volian.Print.Library
(c > cols + colr + COL_WID_ADJ) ? -fixedChgCol :
AERLeftChangeBarLocation(formatInfo));
else
return (fixedChgCol + (((c < cols + Width + colr) || TableTest()
return (int)(fixedChgCol + (((c < cols + Width + colr) || TableTest()
|| MyItemInfo.IsCaution || MyItemInfo.IsNote) ? 0 : cols + colr)); // || (GetColumnMode() == 0)) ? 0 : cols + colr));
/* Change bars to left of text -- ColS+WidS+ColR is the end of RNO col*/
}
@ -1067,7 +1072,7 @@ namespace Volian.Print.Library
_RtfSB.Append("}");
return _RtfSB.ToString();
}
private float _XOffsetBox = -24;
private float _XOffsetBox = 0;
public float XOffsetBox
{
get { return _XOffsetBox; }
@ -1076,7 +1081,9 @@ namespace Volian.Print.Library
private float SetHeader(vlnParagraph para, PdfContentByte cb, ItemInfo itemInfo, FormatInfo formatInfo)
{
float xoff = (float)itemInfo.MyDocStyle.Layout.LeftMargin;
float hdrWidth = (itemInfo.MyHeader.CleanText == null) ? 0 : itemInfo.MyHeader.CleanText.Length * _CharsToTwips; // convert to twips
// The '6' below is really converting from characters to Twips. But instead of considering the CPI, 16bit assumed
// it was 12 to center the header. That's where the 6 comes from.
float hdrWidth = (itemInfo.MyHeader.CleanText == null) ? 0 : itemInfo.MyHeader.CleanText.Length * 6;
int typ = ((int)itemInfo.MyContent.Type) % 10000;
int? bxIndx = formatInfo.PlantFormat.FormatData.StepDataList[typ].StepLayoutData.STBoxindex;
if (itemInfo.MyHeader.Justify == System.Drawing.ContentAlignment.MiddleCenter)
@ -1090,7 +1097,7 @@ namespace Volian.Print.Library
xoff += (float)((bx.TxtStart + XOffsetBox + (bx.TxtWidth / 2)) - (hdrWidth / 2)); // xoff starts as left margin
}
else if (formatInfo.MyStepSectionLayoutData.Separator.Location > 0)
xoff = XOffset + AdjustToCharPosition((float)((para.Width - hdrWidth) / formatInfo.MyStepSectionLayoutData.Separator.Location));
xoff = XOffset + AdjustToCharPosition((float)((para.Width - hdrWidth) / formatInfo.MyStepSectionLayoutData.Separator.Location), itemInfo.MyHeader.MyFont.CPI);
else
xoff = XOffset + (para.Width / 2) + (hdrWidth / 2); // XOffset has left margin included
}
@ -1100,6 +1107,13 @@ namespace Volian.Print.Library
PartsAbove.Add(myHeader);
return myHeader.Height + SixLinesPerInch;
}
private float AdjustToCharPosition(float position, float? CPI)
{
int iPosition = (int)position;
int charsToTwips = (int)(72 / (CPI ?? 12));
iPosition = (iPosition / charsToTwips) * charsToTwips;
return (float)iPosition;
}
private bool _Processed = false;
public bool Processed
{
@ -1262,19 +1276,26 @@ namespace Volian.Print.Library
public void AdjustXOffsetForTab(ItemInfo itemInfo, int maxRNO, FormatInfo formatInfo, vlnTab myTab)
{
float tabWidth = (myTab == null) ? 0 : myTab.Width;
if (itemInfo.IsStepSection)
{
if (formatInfo.PlantFormat.FormatData.SectData.SectionHeader.Just == "PSLeft")
XOffset = (float)itemInfo.MyDocStyle.Layout.LeftMargin + (float)formatInfo.PlantFormat.FormatData.SectData.SectionHeader.Pos;
return;
}
int typ = ((int)itemInfo.MyContent.Type) % 10000;
int? bxIndx = formatInfo.PlantFormat.FormatData.StepDataList[typ].StepLayoutData.STBoxindex;
if (bxIndx != null)
{
Box bx = formatInfo.PlantFormat.FormatData.BoxList[(int)bxIndx];
//XOffset += (float)bx.TxtStart + tabWidth + XOffsetBox;
XOffset = (float)itemInfo.MyDocStyle.Layout.LeftMargin + (float)bx.TxtStart + tabWidth + XOffsetBox;
if (myTab != null) myTab.XOffset = XOffset - tabWidth;
}
else if (itemInfo.IsHigh)
{
XOffset += tabWidth - myTab.TabAlign;
if (myTab != null) myTab.XOffset += tabWidth - myTab.TabAlign;
float x = (float)itemInfo.MyDocStyle.Layout.LeftMargin + (float)formatInfo.PlantFormat.FormatData.SectData.StepSectionData.StepSectionLayoutData.ColS;
float xoff = x - XOffset;
XOffset += xoff;
if (myTab != null) myTab.XOffset += xoff;
}
else if (itemInfo.IsRNOPart && !((ItemInfo)itemInfo.ActiveParent).IsHigh)
{
@ -1290,7 +1311,7 @@ namespace Volian.Print.Library
{
float tabWidth = (myTab == null) ? 0 : myTab.Width;
int typ = ((int)itemInfo.MyContent.Type) % 10000;
int? bxIndx = formatInfo.PlantFormat.FormatData.StepDataList[typ].StepLayoutData.STBoxindex;
int? bxIndx = itemInfo.IsStep ? formatInfo.PlantFormat.FormatData.StepDataList[typ].StepLayoutData.STBoxindex : null;
if (bxIndx != null)
{
Box bx = formatInfo.PlantFormat.FormatData.BoxList[(int)bxIndx];
@ -1300,6 +1321,10 @@ namespace Volian.Print.Library
{
Width = _WidthAdjust + ToInt(formatInfo.MyStepSectionLayoutData.WidSTablePrint, maxRNO);
}
else if (itemInfo.IsSection)
{
Width = _WidthAdjust + ToInt(formatInfo.MyStepSectionLayoutData.WidSTablePrint, maxRNO);
}
else if (MyParent == null)
{
// 72 points / inch - 7 inches (about width of page)