This commit is contained in:
Kathy Ruffing 2011-06-16 10:39:46 +00:00
parent c37687639d
commit c22b8fd262
3 changed files with 122 additions and 54 deletions

View File

@ -73,6 +73,7 @@ namespace Volian.Print.Library
get { return _MyPdfContentByte; } get { return _MyPdfContentByte; }
set { _MyPdfContentByte = value; } set { _MyPdfContentByte = value; }
} }
public override void OnCloseDocument(PdfWriter writer, iTextSharp.text.Document document) public override void OnCloseDocument(PdfWriter writer, iTextSharp.text.Document document)
{ {
AddBookmarks(writer); AddBookmarks(writer);
@ -80,12 +81,24 @@ namespace Volian.Print.Library
} }
public override void OnEndPage(PdfWriter writer, iTextSharp.text.Document document) public override void OnEndPage(PdfWriter writer, iTextSharp.text.Document document)
{ {
AddBookmarks(writer); if (!OnFoldoutPage)
MyPageCounts.CanIncrement = true; {
base.OnEndPage(writer, document); AddBookmarks(writer);
DrawChangeBars(writer.DirectContent); MyPageCounts.CanIncrement = true;
DrawMessages(writer.DirectContent); base.OnEndPage(writer, document);
DrawRuler(writer.DirectContent); DrawChangeBars(writer.DirectContent);
DrawMessages(writer.DirectContent);
if (!CreatingFoldoutPage)
DrawRuler(writer.DirectContent);
}
else
{
MyPageCounts.CanIncrement = true;
base.OnEndPage(writer, document);
if (!CreatingFoldoutPage)
DrawRuler(writer.DirectContent);
}
} }
private void DrawRuler(PdfContentByte cb) private void DrawRuler(PdfContentByte cb)
{ {
@ -120,7 +133,7 @@ namespace Volian.Print.Library
cb.LineTo(x, y-1); cb.LineTo(x, y-1);
} }
Layout layout = MySection.MyDocStyle.Layout; Layout layout = MySection.MyDocStyle.Layout;
cb.Rectangle((float)layout.LeftMargin, (float)(cb.PdfWriter.PageSize.Height - layout.TopRow), (float)layout.PageWidth, (float)-layout.PageLength); cb.Rectangle((float)layout.LeftMargin, (float)(cb.PdfWriter.PageSize.Height - layout.TopMargin), (float)layout.PageWidth - (float)layout.LeftMargin, (float)-layout.PageLength);
cb.MoveTo(0, 504); cb.MoveTo(0, 504);
cb.LineTo(612, 504); cb.LineTo(612, 504);
for (float x1 = 0; x1 < 612; x1 += 6) // tic marks every 1/8 inch for (float x1 = 0; x1 < 612; x1 += 6) // tic marks every 1/8 inch
@ -377,18 +390,26 @@ namespace Volian.Print.Library
mySvg.ProcessText += new SvgProcessTextEvent(mySvg_ProcessText); mySvg.ProcessText += new SvgProcessTextEvent(mySvg_ProcessText);
return mySvg; return mySvg;
} }
PageCounts MyPageCounts = null; public PageCounts MyPageCounts = null;
private static Regex regexFindToken = new Regex("{[^{}]*}"); private static Regex regexFindToken = new Regex("{[^{}]*}");
private string mySvg_ProcessText(object sender, SvgProcessTextArgs args) private string mySvg_ProcessText(object sender, SvgProcessTextArgs args)
{ {
if (args.MyText == null) return string.Empty; // KBR needed for WCN crash if (args.MyText == null) return string.Empty; // Needed for empty genmac text (was space in 16bit files)
if (!args.MyText.Contains("{")) if (!args.MyText.Contains("{"))
return args.MyText; return args.MyText;
/* /*
* Check if tokens for handling page counts ({PAGE} {OF} etc). if so, do templates. * Check if tokens for handling page counts ({PAGE} {OF} etc). if so, do templates.
*/ */
if (args.MyText.Contains("{DOCCURPAGE}") || args.MyText.Contains("{DOCTOTPAGE}"))
{
string key = "DocCurPage." + MySection.ItemID;
string txt = args.MyText.Replace("{DOCCURPAGE}", "{PAGE}").Replace("{DOCTOTPAGE}", "{OF}");
MyPdfContentByte.AddTemplate(MyPageCounts.AddToTemplateList(key, MyPdfWriter, txt, args.MySvgText.Font, args.MySvgText.Align, args.MySvgText.FillColor), args.MySvgScale.X(args.MySvgText.X), args.MySvgScale.Y(MyPdfContentByte, args.MySvgText.Y));
return string.Empty;
}
if (args.MyText.Contains("{PAGE}") || args.MyText.Contains("{OF}")) if (args.MyText.Contains("{PAGE}") || args.MyText.Contains("{OF}"))
{ {
#region numberingseq
/* /*
public enum E_NumberingSequence : uint public enum E_NumberingSequence : uint
{ {
@ -405,6 +426,7 @@ namespace Volian.Print.Library
Like6_ButDoesntNeedSubsection1 = 10 Like6_ButDoesntNeedSubsection1 = 10
}; };
*/ */
#endregion
// default for the key is to make it NumberingSequence. Then handle // default for the key is to make it NumberingSequence. Then handle
// specific cases. // specific cases.
string key = ((int)MySection.MyDocStyle.NumberingSequence).ToString(); string key = ((int)MySection.MyDocStyle.NumberingSequence).ToString();
@ -503,6 +525,17 @@ namespace Volian.Print.Library
case "{BOX9}": case "{BOX9}":
svgGroup.Add(PageItemToSvgUse(pageItem, FirstAndLast(token))); svgGroup.Add(PageItemToSvgUse(pageItem, FirstAndLast(token)));
break; break;
case "{PMODEBOX}": // need to set either 1 or 2 depending on number of columns
string box = "1";
if (_MySection.SectionConfig.Section_ColumnMode == SectionConfig.SectionColumnMode.Four)
box = "4";
else if (_MySection.SectionConfig.Section_ColumnMode == SectionConfig.SectionColumnMode.Three)
box = "3";
else if (_MySection.SectionConfig.Section_ColumnMode == SectionConfig.SectionColumnMode.Two)
box = "2";
box = "{BOX" + box + "}";
svgGroup.Add(PageItemToSvgUse(pageItem, FirstAndLast(box)));
break;
case "{DRAFTPAGE}": case "{DRAFTPAGE}":
case "{REFERENCEPAGE}": case "{REFERENCEPAGE}":
case "{MASTERPAGE}": case "{MASTERPAGE}":
@ -522,7 +555,7 @@ namespace Volian.Print.Library
svgGroup.Add(PageItemToSvgText(pageItem, section.DisplayText)); svgGroup.Add(PageItemToSvgText(pageItem, section.DisplayText));
break; break;
case "{SECTIONLEVELNUMBER}": case "{SECTIONLEVELNUMBER}":
svgGroup.Add(PageItemToSvgText(pageItem, section.DisplayNumber)); svgGroup.Add(PageItemToSvgText(pageItem, pageItem.Token.Replace(token,section.DisplayNumber)));
break; break;
default: default:
// see if it's a PSI token: // see if it's a PSI token:

View File

@ -115,15 +115,12 @@ namespace Volian.Print.Library
/// This variable is used to match 16 bit pagination /// This variable is used to match 16 bit pagination
/// </summary> /// </summary>
private bool _Match16BitPagination = false; 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) public float ParagraphToPdf(PdfContentByte cb, float yPageStart, float yTopMargin, float yBottomMargin)
{ {
if (Processed) return yPageStart; if (Processed) return yPageStart;
Processed = true; Processed = true;
if (_PartsAbove != null && _PartsAbove.Count > 0) yPageStart = PartsAbove.ToPdf(cb, yPageStart, yTopMargin, yBottomMargin); 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); 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); 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); 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) if (MyItemInfo.MyContent.MyGrid != null)
retval = DrawGrid(cb, ref yPageStart, yTopMargin, yBottomMargin, ref yLocation); 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); 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 if (retval == 0) // problem occurred - paragraph was not able to be printed on page
{ // pagination logic needs to be fixed. { // pagination logic needs to be fixed.
cb.PdfDocument.NewPage(); cb.PdfDocument.NewPage(); // pagination issue
yPageStart = yTopMargin + YVeryTop; yPageStart = yTopMargin + YVeryTop;
yLocation = yPageStart - YOffset; yLocation = yPageStart - YOffset;
//MyItemInfo.ItemID, YSize, yPageSize, yLocation //MyItemInfo.ItemID, YSize, yPageSize, yLocation
@ -284,17 +284,14 @@ namespace Volian.Print.Library
{ {
float yLocation = yPageStart - YTopMost; float yLocation = yPageStart - YTopMost;
int paginate = Paginate(yLocation, yTopMargin, yBottomMargin); int paginate = Paginate(yLocation, yTopMargin, yBottomMargin);
bool firstHighLevelStep = MyItemInfo.IsHigh && (MyItemInfo.MyPrevious == null);
switch (paginate) switch (paginate)
{ {
case 1: // Break on High Level Step case 1: // Break on High Level Step
OutputOtherPageSteps(cb, YTopMost, yPageStart, yTopMargin, yBottomMargin); OutputOtherPageSteps(cb, YTopMost, yPageStart, yTopMargin, yBottomMargin);
if (_DoBlankForFoldout&&MyItemInfo.ActiveSection.IsDefaultSection)
{
cb.PdfDocument.NewPage();
cb.Circle(100, 100, 50);
}
cb.PdfDocument.NewPage(); cb.PdfDocument.NewPage();
if ((MyItemInfo.ActiveSection.MyDocStyle.StructureStyle.Style ?? 0 & E_DocStructStyle.UseSectionFoldout) != 0)
PromsPrinter.DoFoldoutPage(cb, "HLS", MyPageHelper.TextLayer, MyPageHelper);
yPageStart = yTopMargin + YTopMost; yPageStart = yTopMargin + YTopMost;
MyPageHelper.YMultiplier = 1; MyPageHelper.YMultiplier = 1;
break; break;
@ -306,6 +303,8 @@ namespace Volian.Print.Library
{ {
if (myMsg.IndexOf(@"%d") > -1) if (myMsg.IndexOf(@"%d") > -1)
myMsg = myMsg.Replace(@"%d", MyItemInfo.MyHLS.MyTab.CleanText.Trim()); 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; float msg_yLocation = 0;
switch (docstyle.Continue.Bottom.Location) 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); 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(); 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. // If there is a box, adjust the yTopMost to include it.
// TODO: Why doesn't YTopMost account for the box?
float yTopMost = YTopMost; float yTopMost = YTopMost;
//if (YVeryTop < yTopMost) Console.WriteLine("{0},{1},{2}", MyItemInfo.DBSequence, yTopMost, YVeryTop); //if (YVeryTop < yTopMost) Console.WriteLine("{0},{1},{2}", MyItemInfo.DBSequence, yTopMost, YVeryTop);
yTopMost = Math.Min(yTopMost,YVeryTop); yTopMost = Math.Min(yTopMost,YVeryTop);
@ -337,20 +332,19 @@ namespace Volian.Print.Library
if (myMsg != null && myMsg != "") if (myMsg != null && myMsg != "")
{ {
if (myMsg.IndexOf(@"%d") > -1) 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.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; MyPageHelper.YMultiplier = 1;
break; break;
case 3: // Break on High Level Step (SevenLinesPerInch) case 3: // Break on High Level Step (SevenLinesPerInch)
OutputOtherPageSteps(cb, YTopMost, yPageStart, yTopMargin, yBottomMargin); if (!firstHighLevelStep)
if (_DoBlankForFoldout && MyItemInfo.ActiveSection.IsDefaultSection)
{ {
cb.PdfDocument.NewPage(); OutputOtherPageSteps(cb, YTopMost, yPageStart, yTopMargin, yBottomMargin);
cb.Circle(300, 100, 50); 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; yPageStart = yTopMargin + YTopMost;
MyPageHelper.YMultiplier = _SevenLinesPerInch / SixLinesPerInch; MyPageHelper.YMultiplier = _SevenLinesPerInch / SixLinesPerInch;
break; break;
@ -366,13 +360,15 @@ namespace Volian.Print.Library
string myMsg = (docstyle.End == null) ? null : docstyle.End.Message; string myMsg = (docstyle.End == null) ? null : docstyle.End.Message;
if (myMsg != null) if (myMsg != null)
{ {
float msg_yLocation = yBottomMargin + SixLinesPerInch; // If the flag is 0 or 1, just put the end message out right below this vlnParagraph:
// use the 'flag' to position the message. Just implementing OHLP float msg_yLocation = yPageStart - YBottomMost;
if (docstyle.End.Flag >= 2)
// 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); 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 wtpm = (float)docstyle.Layout.PageWidth - (float)docstyle.Layout.LeftMargin;
float centerpos = XOffsetBox + (float)docstyle.Layout.LeftMargin + (wtpm - (myMsg.Length * MyItemInfo.FormatStepData.Font.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); 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) private int Paginate(float yLocation, float yTopMargin, float yBottomMargin)
{ {
float yPageSize = yTopMargin - 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; float yWithinMargins = CalculateYLocation(yLocation, yTopMargin) - yBottomMargin - SixLinesPerInch;
// if step is breaking over a number of pages, determine if the current step is the // if step is breaking over a number of pages, determine if the current step is the
// location of a pagebreak. // location of a pagebreak.
@ -482,29 +485,42 @@ namespace Volian.Print.Library
} }
return 0; // this is not an item with a break 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 if (!MyItemInfo.IsHigh) return 0; // Don't Paginate on a Substep level
bool ManualPageBreak = (MyItemInfo.MyConfig as StepConfig).Step_ManualPagebreak; bool ManualPageBreak = (MyItemInfo.MyConfig as StepConfig).Step_ManualPagebreak;
float mySize = YSize * MyPageHelper.YMultiplier;
if (_Match16BitPagination) mySize = YSize; if (_Match16BitPagination) mySize = YSize;
float ySize7LPI = YSize + SixLinesPerInch; float ySize7LPI = YSize + SixLinesPerInch;
if (_Match16BitPagination) ySize7LPI += SixLinesPerInch; if (_Match16BitPagination) ySize7LPI += SixLinesPerInch;
string firstStep = "No"; string firstStep = "No";
if (MyItemInfo.IsHigh && MyItemInfo.MyPrevious == null) if (MyItemInfo.IsHigh && MyItemInfo.MyPrevious == null)
firstStep = "Yes"; 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); //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); ShowPageBreak(-1, "HLS will fit on page", firstStep, YSize, yPageSize, yWithinMargins);
return 0; return 0;
} }
// !MyItemInfo.IsHigh - if (MyItemInfo.IsRNOPart && MyParent.XOffset < XOffset) return 0; // Don't paginate on an RNO to the right // !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); //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); ShowPageBreak(5, "HLS will fit on 1 Page at 6 LPI", "Yes", YSize, yPageSize, yWithinMargins);
return 1; return 1;
} }
// TODO - yEndMsg - compressed size?
else if (MyItemInfo.ActiveFormat.MyStepSectionLayoutData.CompressSteps && (ySize7LPI) < (yPageSize * SixLinesPerInch / _SevenLinesPerInch)) 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); //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) if (_Match16BitPagination)
{ {
yLowerLimit = yStart - SixLinesPerInch + ySpaceOnCurPage / 2; 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; yLowerLimit = yStart + 2 * SixLinesPerInch;
} }
// Make sure that the FirstPiece (Caution Note HLS and First Substeps) fit // 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 != "") if (itemInfo.MyTab != null && itemInfo.MyTab.Text != null && itemInfo.MyTab.Text != "")
{ {
float localXOffset = XOffset; 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; 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); AdjustWidth(itemInfo, maxRNO, formatInfo, mytab);
AdjustXOffsetForTab(itemInfo, maxRNO, formatInfo, mytab); AdjustXOffsetForTab(itemInfo, maxRNO, formatInfo, mytab);
@ -794,7 +814,11 @@ namespace Volian.Print.Library
yoff += SetHeader(this, cb, itemInfo, formatInfo); yoff += SetHeader(this, cb, itemInfo, formatInfo);
YOffset = yoff; YOffset = yoff;
AddMacros(itemInfo, mytab); 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) if (itemInfo.MyContent.MyGrid != null)
{ {
VlnFlexGrid myFlexGrid = new VlnFlexGrid(1,1); VlnFlexGrid myFlexGrid = new VlnFlexGrid(1,1);
@ -853,7 +877,11 @@ namespace Volian.Print.Library
Width = GetTableWidth(cb, IParagraph, MyItemInfo.MyDocStyle.Layout.PageWidth); Width = GetTableWidth(cb, IParagraph, MyItemInfo.MyDocStyle.Layout.PageWidth);
CalculateXOffset(itemInfo, maxRNO, formatInfo); 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 += Height;
yoff += AdjustForBlankLines(); yoff += AdjustForBlankLines();
@ -923,7 +951,7 @@ namespace Volian.Print.Library
vlnParagraph hls1 = MyParent; vlnParagraph hls1 = MyParent;
while (hls1.MyParent != null && !hls1.MyItemInfo.IsHigh) hls1 = hls1.MyParent; while (hls1.MyParent != null && !hls1.MyItemInfo.IsHigh) hls1 = hls1.MyParent;
XOffset = hls1.XOffset + hls1.Width / 2 - Width / 2; // xoffset if AER column 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 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 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 if (!aerTableOrFigure && itemInfo.RNOLevel == 0) // Centered Table of Figure
@ -944,6 +972,7 @@ namespace Volian.Print.Library
} }
private float AdjustForBlankLines() private float AdjustForBlankLines()
{ {
if (MyItemInfo.MyDocStyle.SpecialStepsFoldout) return 0;
int everyNLines = MyItemInfo.FormatStepData == null ? 1 : MyItemInfo.FormatStepData.StepLayoutData.EveryNLines ?? 1; 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; return 0;
@ -1067,6 +1096,7 @@ namespace Volian.Print.Library
System.Drawing.Font myFont = vlntxt.TextFont.WindowsFont; System.Drawing.Font myFont = vlntxt.TextFont.WindowsFont;
if (!itemInfo.IsTable && StepRTB.MyFontFamily != null) if (!itemInfo.IsTable && StepRTB.MyFontFamily != null)
myFont = new System.Drawing.Font(StepRTB.MyFontFamily, myFont.Size, myFont.Style); 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(AddFontTable(myFont));
_RtfSB.Append(vlntxt.StartText); _RtfSB.Append(vlntxt.StartText);
_RtfSB.Append("}"); _RtfSB.Append("}");
@ -1105,7 +1135,7 @@ namespace Volian.Print.Library
xoff = XOffset; // XOffset has left margin included 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); vlnHeader myHeader = new vlnHeader(this, cb, itemInfo.MyHeader.Text, itemInfo.MyHeader.CleanText.TrimStart(" ".ToCharArray()), xoff, YOffset, itemInfo.MyHeader.MyFont);
PartsAbove.Add(myHeader); PartsAbove.Add(myHeader);
return myHeader.Height + SixLinesPerInch; return myHeader.Height + (!MyItemInfo.MyDocStyle.SpecialStepsFoldout ? SixLinesPerInch : 0);
} }
private float AdjustToCharPosition(float position, float? CPI) private float AdjustToCharPosition(float position, float? CPI)
{ {

View File

@ -71,8 +71,13 @@ namespace Volian.Print.Library
int mindx = origTab.IndexOf(@"{!"); int mindx = origTab.IndexOf(@"{!");
int meindx = origTab.IndexOf(@"}", mindx); int meindx = origTab.IndexOf(@"}", mindx);
string macro = origTab.Substring(mindx, meindx - mindx+1); string macro = origTab.Substring(mindx, meindx - mindx+1);
MyMacro = new vlnMacro(xoffset - Width, yoffset, macro.Substring(2, macro.Length - 3)); // Width for placement of macro should be position in the string where the macro was located.
float lwidth = MyFont.CharsToTwips * (origTab.Length - meindx);
MyMacro = new vlnMacro(xoffset - lwidth, yoffset, macro.Substring(2, macro.Length - 3));
origTab = origTab.Replace(macro,""); origTab = origTab.Replace(macro,"");
origTab = origTab + " ";
cleanTab = origTab;
Width = MyFont.CharsToTwips * (cleanTab != null ? cleanTab.Length : origTab.Length);
} }
Rtf = GetRtf(origTab, vFont); Rtf = GetRtf(origTab, vFont);
// do positioning based on whether format has locations for section 'header'. If it's not centered, treat // do positioning based on whether format has locations for section 'header'. If it's not centered, treat