This commit is contained in:
Kathy Ruffing 2010-06-16 14:11:02 +00:00
parent 893282d7a2
commit ef5f141b03

View File

@ -28,25 +28,45 @@ namespace Volian.Print.Library
public float Add(PdfContentByte cb, ItemInfoList itemInfoList, float xoff, float yoff, float yoffRight, int rnoLevel, int maxRNO, FormatInfo formatInfo)
{
int? bxIndex = null;
vlnBox box = null;
foreach (ItemInfo childItemInfo in itemInfoList)
{
int? bxIndx = childItemInfo.FormatStepData.StepLayoutData.STBoxindex;
if (bxIndex != bxIndx)
{
if (bxIndex == null) // First boxed step
yoff += 2 * vlnPrintObject._SixLinesPerInch;
{
box = new vlnBox();
box.MyBox = formatInfo.PlantFormat.FormatData.BoxList[(int)bxIndx];
box.YOffset = yoff;
yoff += 2 * vlnPrintObject.SixLinesPerInch;
}
else // Change Box Style
yoff += 2 * vlnPrintObject._SixLinesPerInch;
{
if (box != null) box.Height = yoff - box.YOffset; // new height, with children
box = new vlnBox();
box.MyBox = formatInfo.PlantFormat.FormatData.BoxList[(int)bxIndx];
box.YOffset = yoff;
yoff += 2 * vlnPrintObject.SixLinesPerInch;
}
bxIndex = bxIndx;
}
if (childItemInfo is SectionInfo) formatInfo = (childItemInfo as SectionInfo).LocalFormat ?? formatInfo;
if (rnoLevel < maxRNO && childItemInfo.RNOs != null) yoff = Math.Max(yoff, yoffRight);
vlnParagraph para = new vlnParagraph(Parent, cb, childItemInfo, xoff, yoff, rnoLevel, maxRNO, formatInfo);
if (box != null && box.MyParent == null)
{
box.MyParent = para;
para.PartsContainer.Add(box);
}
Add(para);
yoff = para.YBottomMost;
}
if (bxIndex != null) // End Box Style
yoff += 2 * vlnPrintObject._SixLinesPerInch;
{
if (box != null) box.Height = yoff - box.YOffset; // new height, with children
yoff += 2 * vlnPrintObject.SixLinesPerInch;
}
return yoff;
}
public float ToPdf(PdfContentByte cb, float yPageStart, float yTopMargin, float yBottomMargin)
@ -77,15 +97,15 @@ namespace Volian.Print.Library
float retval = yLocation;
if (!MyItemInfo.IsStepSection) // Don't ouput the Step Section title
{
retval = Rtf2Pdf.TextAt(cb, IParagraph, XOffset, yLocation, Width, 100, PdfDebugText);
if (retval == 0)
{
retval = Rtf2Pdf.TextAt(cb, IParagraph, XOffset, yLocation, Width, 100, PdfDebugText, yBottomMargin);
if (retval == 0) // problem occurred - paragraph was not able to be printed on page
{ // pagination logic needs to be fixed.
cb.PdfDocument.NewPage();
yPageStart = yTopMargin + YTop;
yLocation = yPageStart - YOffset;
//MyItemInfo.ItemID, YSize, yPageSize, yLocation
Console.WriteLine("-1,'Yes','Forced Pagination',{0},{1},,{3},'{4}'", MyItemInfo.ItemID, YSize, 0, yLocation, MyItemInfo.ShortPath);
retval = Rtf2Pdf.TextAt(cb, IParagraph, XOffset, yLocation, Width, 100, PdfDebugText);
retval = Rtf2Pdf.TextAt(cb, IParagraph, XOffset, yLocation, Width, 100, PdfDebugText, yBottomMargin);
}
}
//Height = yLocation - retval;
@ -93,6 +113,7 @@ namespace Volian.Print.Library
if (_PartsRight != null && _PartsRight.Count > 0) yPageStart = PartsRight.ToPdf(cb, yPageStart, yTopMargin, yBottomMargin);
if (_PartsBelow != null && _PartsBelow.Count > 0) yPageStart = PartsBelow.ToPdf(cb, yPageStart, yTopMargin, yBottomMargin);
if (_PartsContainer != null && _PartsContainer.Count > 0) yPageStart = PartsContainer.ToPdf(cb, yPageStart, yTopMargin, yBottomMargin);
return yPageStart;
}
private string PdfDebugText
@ -118,15 +139,38 @@ namespace Volian.Print.Library
break;
case 2: // Break within a Step
OutputOtherPageSteps(cb, YTopMost, yPageStart, yTopMargin, yBottomMargin);
DocStyle docstyle = MyItemInfo.MyDocStyle;
string myMsg = docstyle.Continue.Bottom.Message;
if (myMsg.IndexOf(@"%d") > -1)
myMsg = myMsg.Replace(@"%d", MyItemInfo.MyHLS.MyTab.CleanText.Trim());
float msg_yLocation = 0;
switch (docstyle.Continue.Bottom.Location)
{
case E_ContBottomLoc.EndOfText: // place continue string at end of text
case E_ContBottomLoc.BtwnTextAndBottom: // place continue string between end of text & bottom of page
Console.WriteLine("Not done yet");
break;
case E_ContBottomLoc.BottomOfPage: // place continue message at bottom of page
msg_yLocation = yBottomMargin; // +2 * _SixLinesPerInch; // 2 lines above bottom margin
break;
}
//float msg_yLocation = CalculateYOffset(yPageStart, yTopMargin);
MyPageHelper.BottomMessage = new vlnText(cb, this, myMsg, myMsg, docstyle.Layout.LeftMargin + XOffsetBox + docstyle.Continue.Bottom.Margin ?? 0, msg_yLocation, MyItemInfo.ActiveFormat.PlantFormat.FormatData.Font);
cb.PdfDocument.NewPage();
yPageStart = yTopMargin + YTopMost - 2 * _SixLinesPerInch;
yPageStart = yTopMargin + YTopMost - 2 * SixLinesPerInch;
msg_yLocation = CalculateYOffset(yPageStart, yTopMargin);
myMsg = docstyle.Continue.Top.Message;
if (myMsg.IndexOf(@"%d") > -1)
myMsg = myMsg.Replace(@"%d", MyItemInfo.MyHLS.MyTab.CleanText.Trim());
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);
cb.PdfDocument.NewPage();
yPageStart = yTopMargin + YTopMost;
MyPageHelper.YMultiplier = _SevenLinesPerInch / _SixLinesPerInch;
MyPageHelper.YMultiplier = _SevenLinesPerInch / SixLinesPerInch;
break;
}
yPageStart = ChildrenAbove.ToPdf(cb, yPageStart, yTopMargin, yBottomMargin);
@ -134,6 +178,24 @@ namespace Volian.Print.Library
yPageStart = ParagraphToPdf(cb, yPageStart, yTopMargin, yBottomMargin);
yPageStart = ChildrenRight.ToPdf(cb, yPageStart, yTopMargin, yBottomMargin);
yPageStart = ChildrenBelow.ToPdf(cb, yPageStart, yTopMargin, yBottomMargin);
if (MyItemInfo.IsHigh && MyItemInfo.NextItem == null) // last hls, add the 'end' message, if there is one
{
DocStyle docstyle = MyItemInfo.MyDocStyle;
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)
{
msg_yLocation = yTopMargin - (float)(docstyle.End.Flag * SixLinesPerInch);
}
// 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;
MyPageHelper.BottomMessage = new vlnText(cb, this, myMsg, myMsg, centerpos, msg_yLocation, docstyle.End.Font);
}
}
return yPageStart;
}
@ -174,7 +236,7 @@ namespace Volian.Print.Library
Console.WriteLine("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);
return 1; // Paginate on High Level Steps
}
else if (YSize < (yPageSize * _SixLinesPerInch / _SevenLinesPerInch))
else if (YSize < (yPageSize * SixLinesPerInch / _SevenLinesPerInch))
{
Console.WriteLine("6,'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);
return 3; // High Level Step can fit at SevenLinesPerInch
@ -227,7 +289,7 @@ namespace Volian.Print.Library
vlnTab mytab = null;
if (itemInfo.MyTab != null && itemInfo.MyTab.Text != null && itemInfo.MyTab.Text != "")
{
mytab = new vlnTab(cb, itemInfo.MyTab.Text, itemInfo.MyTab.CleanText, XOffset, yoff, itemInfo.MyTab.MyFont);
mytab = new vlnTab(cb, this, itemInfo.MyTab.Text, itemInfo.MyTab.CleanText, XOffset, yoff, itemInfo.MyTab.MyFont);
PartsLeft.Add(mytab);
}
AdjustWidth(itemInfo, maxRNO, formatInfo, mytab);
@ -270,6 +332,11 @@ namespace Volian.Print.Library
yoff += Height;
yoff += AdjustForBlankLines();
}
if (itemInfo.IsFigure)
{
// get image from ro.
string myro = itemInfo.MyContent.Text;
}
float yOffRight = yoff;
float RnoOffset = ToInt(formatInfo.PlantFormat.FormatData.SectData.StepSectionData.StepSectionLayoutData.ColRTable, maxRNO);
if (rnoLevel < maxRNO && itemInfo.RNOs != null) yOffRight = ChildrenRight.Add(cb, itemInfo.RNOs, XOffset + RnoOffset, YTop, YTop, rnoLevel + 1, maxRNO, formatInfo);
@ -290,14 +357,14 @@ namespace Volian.Print.Library
vlnParagraph rno = ChildrenRight[0];
// TODO: May need to handle more than one RNO column for RNO Separator
rno.LastRNO.PartsBelow.Add(myRnoSep);
yoff += myRnoSep.Height + _SixLinesPerInch;
yoff += myRnoSep.Height + SixLinesPerInch;
}
YBottomMost = yoff;
}
private float AdjustForBlankLines()
{
int everyNLines = MyItemInfo.FormatStepData == null ? 1 : MyItemInfo.FormatStepData.StepLayoutData.EveryNLines ?? 1;
if (MyItemInfo.Ordinal % everyNLines == 0 || MyItemInfo.NextItem == null) return _SixLinesPerInch;
if (MyItemInfo.Ordinal % everyNLines == 0 || MyItemInfo.NextItem == null) return SixLinesPerInch;
return 0;
}
private void AddMacros(ItemInfo itemInfo, vlnTab mytab)
@ -420,9 +487,6 @@ namespace Volian.Print.Library
_RtfSB.Append(vlntxt.StartText);
_RtfSB.Append("}");
return _RtfSB.ToString();
//if (formatInfo.PlantFormat.FormatData.StepDataList[itemInfo.FormatStepType].Boxed) myParagraph.Parts.Add(new vlnBox(myParagraph));
//Console.WriteLine("{0} {1} - {2}, {3}", itemInfo.MyTab.CleanText, itemInfo.MyContent.Text, xoff, yoff);
}
private float _XOffsetBox = -24;
public float XOffsetBox
@ -458,9 +522,9 @@ namespace Volian.Print.Library
}
else
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, itemInfo.MyHeader.Justify);
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 + SixLinesPerInch;
}
private bool _Processed = false;
public bool Processed
@ -644,7 +708,7 @@ namespace Volian.Print.Library
public void AdjustXOffsetForTab(ItemInfo itemInfo, int maxRNO, FormatInfo formatInfo, vlnTab myTab)
{
float tabWidth = (myTab == null) ? 0 : myTab.TabWidth;
float tabWidth = (myTab == null) ? 0 : myTab.Width;
int typ = ((int)itemInfo.MyContent.Type) % 10000;
int? bxIndx = formatInfo.PlantFormat.FormatData.StepDataList[typ].StepLayoutData.STBoxindex;
if (bxIndx != null)
@ -671,7 +735,7 @@ namespace Volian.Print.Library
}
public void AdjustWidth(ItemInfo itemInfo, int maxRNO, FormatInfo formatInfo, vlnTab myTab)
{
float tabWidth = (myTab == null) ? 0 : myTab.TabWidth;
float tabWidth = (myTab == null) ? 0 : myTab.Width;
int typ = ((int)itemInfo.MyContent.Type) % 10000;
int? bxIndx = formatInfo.PlantFormat.FormatData.StepDataList[typ].StepLayoutData.STBoxindex;
if (bxIndx != null)