From 86cac2ae133a2a94e31cb942d8f1156f9b886a98 Mon Sep 17 00:00:00 2001 From: Kathy Date: Mon, 19 May 2014 13:16:45 +0000 Subject: [PATCH] BGE: Fix pagination when a phone list exists BGE: Auto Table Of Contents, multi-line title leader dots BGE: Auto ToC, save section title length for printing of leader dots on last line of title BGE: Fix location of bottom continue message when phone list exists BGE: Auto ToC, save section title length for printing of leader dots on multi-line of title --- PROMS/Volian.Print.Library/Pagination.cs | 11 +++- PROMS/Volian.Print.Library/PromsPrinter.cs | 58 ++++++++++++++------ PROMS/Volian.Print.Library/Rtf2Pdf.cs | 2 + PROMS/Volian.Print.Library/vlnParagraph.cs | 3 + PROMS/Volian.Print.Library/vlnPrintObject.cs | 2 +- 5 files changed, 54 insertions(+), 22 deletions(-) diff --git a/PROMS/Volian.Print.Library/Pagination.cs b/PROMS/Volian.Print.Library/Pagination.cs index 879ee0b0..29ca2c6d 100644 --- a/PROMS/Volian.Print.Library/Pagination.cs +++ b/PROMS/Volian.Print.Library/Pagination.cs @@ -57,9 +57,10 @@ namespace Volian.Print.Library float yEndMsg = !_skipEndMessage && !MyItemInfo.IsSection && MyItemInfo.MyHLS != null && MyItemInfo.MyHLS.GetNextItem() == null && (MyItemInfo.MyDocStyle.End.Message ?? "") != "" ? 2 * SixLinesPerInch : 0; // also consider if there is a phone list at the bottom of the page, add the amount of space the phone - // list requires onto yEndMsg to make it easier to figure out pagination. - if (MyItemInfo.ActiveFormat.PlantFormat.FormatData.SectData.PrintPhoneList) - yEndMsg += MyPageHelper.PhoneListHeight; + // list requires onto yEndMsg to make it easier to figure out pagination (include an extra line for the + // horizonal line above the phone list. + if (MyItemInfo.ActiveFormat.PlantFormat.FormatData.SectData.PrintPhoneList && MyPageHelper.PhoneListHeight != 0) + yEndMsg += (MyPageHelper.PhoneListHeight - vlnPrintObject.SixLinesPerInch); // The following code is to fix a pagination issue in SHE. It was decided to not put it into development // because some of the pagination logic may be redesigned. Without this fix, some pages had a page break @@ -419,6 +420,10 @@ namespace Volian.Print.Library myBottomMsgSpace = 0; break; } + // also account for phonelist for locating bottom continue message: + if (MyItemInfo.ActiveFormat.PlantFormat.FormatData.SectData.PrintPhoneList && MyPageHelper.PhoneListHeight != 0) + myBottomMsgSpace += (MyPageHelper.PhoneListHeight - vlnPrintObject.SixLinesPerInch); + string myTopMsg = docstyle.Continue.Top.Message; float myTopMsgSpace = ((myTopMsg ?? "") != "") ? 2 * SixLinesPerInch : 0; diff --git a/PROMS/Volian.Print.Library/PromsPrinter.cs b/PROMS/Volian.Print.Library/PromsPrinter.cs index b59a3d8e..830df79f 100644 --- a/PROMS/Volian.Print.Library/PromsPrinter.cs +++ b/PROMS/Volian.Print.Library/PromsPrinter.cs @@ -504,24 +504,29 @@ namespace Volian.Print.Library _MyHelper.PhoneListHeight = 0; if (mySection.ActiveFormat.PlantFormat.FormatData.SectData.PrintPhoneList) { - DocVersionConfig dvc = mySection.MyDocVersion.MyConfig as DocVersionConfig; - if (dvc != null) + // get config for section + SectionConfig sc = mySection.MyConfig as SectionConfig; + if (sc.Section_PhoneList != null && sc.Section_PhoneList == "Y") { - string phlist = dvc.Print_PhoneList; - if (phlist != null && phlist != "") + DocVersionConfig dvc = mySection.MyDocVersion.MyConfig as DocVersionConfig; + if (dvc != null) { - // count lines: - int cl = 1; - int indx = phlist.IndexOf("\n"); - while (indx > 0) + string phlist = dvc.Print_PhoneList; + if (phlist != null && phlist != "") { - cl++; - if (indx + 1 > phlist.Length) - indx = -1; - else - indx = phlist.IndexOf("\n", indx + 1); + // count lines: + int cl = 1; + int indx = phlist.IndexOf("\n"); + while (indx > 0) + { + cl++; + if (indx + 1 > phlist.Length) + indx = -1; + else + indx = phlist.IndexOf("\n", indx + 1); + } + _MyHelper.PhoneListHeight = cl * vlnPrintObject.SixLinesPerInch; } - _MyHelper.PhoneListHeight = cl * vlnPrintObject.SixLinesPerInch; } } } @@ -826,6 +831,7 @@ namespace Volian.Print.Library rtfText = GetRtfToC(mySection.MyContent.Text, tOfC); Paragraph myparagrapht = vlnPrintObject.RtfToParagraph(rtfText); width = secPagePos - adjSecTitlePos - 6; + float savTitleWid = width; float retval = Rtf2Pdf.TextAt(cb, myparagrapht, leftMargin + adjSecTitlePos, yPageStart - yLocation, width, height, "", yBottomMargin); if (retval == 0) // couldn't fit, flags need for a page break. { @@ -835,10 +841,11 @@ namespace Volian.Print.Library retval = Rtf2Pdf.TextAt(cb, myparagrapht, leftMargin + adjSecTitlePos, yPageStart - yLocation, width, height, "", yBottomMargin); } float ttlRetval = retval; + float savTitleFillWidth = Rtf2Pdf.FillWidth; // Now do the section number. Retval is the ylocation on page after the text // is put out. - retval = Rtf2Pdf.TextAt(cb, myparagraphn, leftMargin + secNumPos + indentOffset, yPageStart - yLocation, width * 1.3F, height, "", yBottomMargin); + retval = Rtf2Pdf.TextAt(cb, myparagraphn, leftMargin + secNumPos + indentOffset, yPageStart - yLocation, numwidth * 1.3F, height, "", yBottomMargin); float lSpace = (tOfC.TofCLineSpacing == 2) ? 2 * vlnPrintObject.SixLinesPerInch : vlnPrintObject.SixLinesPerInch; @@ -862,12 +869,25 @@ namespace Volian.Print.Library width = 0; foreach (Chunk chkt in myparagrapht.Chunks) width += chkt.GetWidthPoint(); - // the '6' in the next 2 lines & in the 'while' loop below allows the placement of the dots (or other space character) + + // get height - if two lines high, need width of 2nd line for adding + // space characters + float heightTtl = vlnPrintObject.GetHeight(cb, myparagrapht, savTitleWid, false); + string spaceStr = ""; + float startSpace = 0; + // the '6's in the next few code lines & in the 'while' loop below allows the placement of the dots (or other space character) // to be not too close to section title & page number. - float startSpace = leftMargin + adjSecTitlePos + width + 6; + if (heightTtl > vlnPrintObject.SixLinesPerInch) + { + // this title is 2 or more lines, find start of leader dots by determining length of text + // on 2nd line (the savTitleFillWidth is the widest line of the split title) + float secondLineWidth = width - savTitleFillWidth; + startSpace = leftMargin + adjSecTitlePos + secondLineWidth + 6; + } + else + startSpace = leftMargin + adjSecTitlePos + width + 6; float endSpace = leftMargin + secPagePos - 6; float numSpace = endSpace - startSpace; - string spaceStr = ""; rtfText = GetRtfToC(tOfC.TofCSpaceChar, tOfC); Paragraph tmpmyparagraph = vlnPrintObject.RtfToParagraph(rtfText); float spacchrwid = 0; @@ -878,9 +898,11 @@ namespace Volian.Print.Library spaceStr = spaceStr + tOfC.TofCSpaceChar; numSpace -= spacchrwid; } + rtfText = GetRtfToC(spaceStr, tOfC); Paragraph myparagraphs = vlnPrintObject.RtfToParagraph(rtfText); retval = Rtf2Pdf.TextAt(cb, myparagraphs, startSpace, yPageStart - yLocation, endSpace - startSpace, height, "", yBottomMargin); + } // if in the pre-table of content list, just put the page number out as text. // otherwise, add a template _MyHelper.MyTOCPageCounts diff --git a/PROMS/Volian.Print.Library/Rtf2Pdf.cs b/PROMS/Volian.Print.Library/Rtf2Pdf.cs index ee7b551c..f175cc55 100644 --- a/PROMS/Volian.Print.Library/Rtf2Pdf.cs +++ b/PROMS/Volian.Print.Library/Rtf2Pdf.cs @@ -72,6 +72,7 @@ namespace Volian.Print.Library get { return Rtf2Pdf._Offset; } set { Rtf2Pdf._Offset = value; } } + public static float FillWidth = 0; // max text width (used in autoToc code) public static float TextAt(PdfContentByte cb, Paragraph iParagraph, float x, float y, float width, float height, string debugText, float yBottomMargin) { VlnSvgPageHelper _MyPageHelper = cb.PdfWriter.PageEvent as VlnSvgPageHelper; @@ -91,6 +92,7 @@ namespace Volian.Print.Library myColumnText.AddElement(iParagraph); // add in paragraph if (textLayer != null) cb.BeginLayer(textLayer); myColumnText.Go(false); // Draw the paragraph + FillWidth = myColumnText.FilledWidth; if (textLayer != null) cb.EndLayer(); // Approximate Descent by using Leading divided by 5. float yDescent = iParagraph.Leading / 5; diff --git a/PROMS/Volian.Print.Library/vlnParagraph.cs b/PROMS/Volian.Print.Library/vlnParagraph.cs index 3924a791..2575c266 100644 --- a/PROMS/Volian.Print.Library/vlnParagraph.cs +++ b/PROMS/Volian.Print.Library/vlnParagraph.cs @@ -947,6 +947,9 @@ namespace Volian.Print.Library yBtmMarginForMsg = Math.Max(0, localYTopMargin - (float)MyItemInfo.MyActiveSection.MyDocStyle.Layout.PageLength); } } + // include space for phone list when determining bottom continue message location + if (MyItemInfo.ActiveFormat.PlantFormat.FormatData.SectData.PrintPhoneList && MyPageHelper.PhoneListHeight != 0) + yBtmMarginForMsg += (MyPageHelper.PhoneListHeight - vlnPrintObject.SixLinesPerInch); switch (docstyle.Continue.Bottom.Location) { case E_ContBottomLoc.EndOfText: // place continue string at end of text diff --git a/PROMS/Volian.Print.Library/vlnPrintObject.cs b/PROMS/Volian.Print.Library/vlnPrintObject.cs index b2ba1a3e..1f56c721 100644 --- a/PROMS/Volian.Print.Library/vlnPrintObject.cs +++ b/PROMS/Volian.Print.Library/vlnPrintObject.cs @@ -168,7 +168,7 @@ namespace Volian.Print.Library } return chk; } - private static float GetHeight(PdfContentByte cb, Paragraph iParagraph, float width, bool throwException) + public static float GetHeight(PdfContentByte cb, Paragraph iParagraph, float width, bool throwException) { ColumnText myColumnText = new ColumnText(cb); myColumnText.SetSimpleColumn(0, 792F, width, 0); // Bottom margin