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
This commit is contained in:
Kathy Ruffing 2014-05-19 13:16:45 +00:00
parent 5f9331b1b8
commit 86cac2ae13
5 changed files with 54 additions and 22 deletions

View File

@ -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; 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 // 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. // list requires onto yEndMsg to make it easier to figure out pagination (include an extra line for the
if (MyItemInfo.ActiveFormat.PlantFormat.FormatData.SectData.PrintPhoneList) // horizonal line above the phone list.
yEndMsg += MyPageHelper.PhoneListHeight; 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 // 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 // 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; myBottomMsgSpace = 0;
break; 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; string myTopMsg = docstyle.Continue.Top.Message;
float myTopMsgSpace = ((myTopMsg ?? "") != "") ? 2 * SixLinesPerInch : 0; float myTopMsgSpace = ((myTopMsg ?? "") != "") ? 2 * SixLinesPerInch : 0;

View File

@ -504,24 +504,29 @@ namespace Volian.Print.Library
_MyHelper.PhoneListHeight = 0; _MyHelper.PhoneListHeight = 0;
if (mySection.ActiveFormat.PlantFormat.FormatData.SectData.PrintPhoneList) if (mySection.ActiveFormat.PlantFormat.FormatData.SectData.PrintPhoneList)
{ {
DocVersionConfig dvc = mySection.MyDocVersion.MyConfig as DocVersionConfig; // get config for section
if (dvc != null) SectionConfig sc = mySection.MyConfig as SectionConfig;
if (sc.Section_PhoneList != null && sc.Section_PhoneList == "Y")
{ {
string phlist = dvc.Print_PhoneList; DocVersionConfig dvc = mySection.MyDocVersion.MyConfig as DocVersionConfig;
if (phlist != null && phlist != "") if (dvc != null)
{ {
// count lines: string phlist = dvc.Print_PhoneList;
int cl = 1; if (phlist != null && phlist != "")
int indx = phlist.IndexOf("\n");
while (indx > 0)
{ {
cl++; // count lines:
if (indx + 1 > phlist.Length) int cl = 1;
indx = -1; int indx = phlist.IndexOf("\n");
else while (indx > 0)
indx = phlist.IndexOf("\n", indx + 1); {
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); rtfText = GetRtfToC(mySection.MyContent.Text, tOfC);
Paragraph myparagrapht = vlnPrintObject.RtfToParagraph(rtfText); Paragraph myparagrapht = vlnPrintObject.RtfToParagraph(rtfText);
width = secPagePos - adjSecTitlePos - 6; width = secPagePos - adjSecTitlePos - 6;
float savTitleWid = width;
float retval = Rtf2Pdf.TextAt(cb, myparagrapht, leftMargin + adjSecTitlePos, yPageStart - yLocation, width, height, "", yBottomMargin); 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. 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); retval = Rtf2Pdf.TextAt(cb, myparagrapht, leftMargin + adjSecTitlePos, yPageStart - yLocation, width, height, "", yBottomMargin);
} }
float ttlRetval = retval; float ttlRetval = retval;
float savTitleFillWidth = Rtf2Pdf.FillWidth;
// Now do the section number. Retval is the ylocation on page after the text // Now do the section number. Retval is the ylocation on page after the text
// is put out. // 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; float lSpace = (tOfC.TofCLineSpacing == 2) ? 2 * vlnPrintObject.SixLinesPerInch : vlnPrintObject.SixLinesPerInch;
@ -862,12 +869,25 @@ namespace Volian.Print.Library
width = 0; width = 0;
foreach (Chunk chkt in myparagrapht.Chunks) foreach (Chunk chkt in myparagrapht.Chunks)
width += chkt.GetWidthPoint(); 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. // 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 endSpace = leftMargin + secPagePos - 6;
float numSpace = endSpace - startSpace; float numSpace = endSpace - startSpace;
string spaceStr = "";
rtfText = GetRtfToC(tOfC.TofCSpaceChar, tOfC); rtfText = GetRtfToC(tOfC.TofCSpaceChar, tOfC);
Paragraph tmpmyparagraph = vlnPrintObject.RtfToParagraph(rtfText); Paragraph tmpmyparagraph = vlnPrintObject.RtfToParagraph(rtfText);
float spacchrwid = 0; float spacchrwid = 0;
@ -878,9 +898,11 @@ namespace Volian.Print.Library
spaceStr = spaceStr + tOfC.TofCSpaceChar; spaceStr = spaceStr + tOfC.TofCSpaceChar;
numSpace -= spacchrwid; numSpace -= spacchrwid;
} }
rtfText = GetRtfToC(spaceStr, tOfC); rtfText = GetRtfToC(spaceStr, tOfC);
Paragraph myparagraphs = vlnPrintObject.RtfToParagraph(rtfText); Paragraph myparagraphs = vlnPrintObject.RtfToParagraph(rtfText);
retval = Rtf2Pdf.TextAt(cb, myparagraphs, startSpace, yPageStart - yLocation, endSpace - startSpace, height, "", yBottomMargin); 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. // if in the pre-table of content list, just put the page number out as text.
// otherwise, add a template _MyHelper.MyTOCPageCounts // otherwise, add a template _MyHelper.MyTOCPageCounts

View File

@ -72,6 +72,7 @@ namespace Volian.Print.Library
get { return Rtf2Pdf._Offset; } get { return Rtf2Pdf._Offset; }
set { Rtf2Pdf._Offset = value; } 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) 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; VlnSvgPageHelper _MyPageHelper = cb.PdfWriter.PageEvent as VlnSvgPageHelper;
@ -91,6 +92,7 @@ namespace Volian.Print.Library
myColumnText.AddElement(iParagraph); // add in paragraph myColumnText.AddElement(iParagraph); // add in paragraph
if (textLayer != null) cb.BeginLayer(textLayer); if (textLayer != null) cb.BeginLayer(textLayer);
myColumnText.Go(false); // Draw the paragraph myColumnText.Go(false); // Draw the paragraph
FillWidth = myColumnText.FilledWidth;
if (textLayer != null) cb.EndLayer(); if (textLayer != null) cb.EndLayer();
// Approximate Descent by using Leading divided by 5. // Approximate Descent by using Leading divided by 5.
float yDescent = iParagraph.Leading / 5; float yDescent = iParagraph.Leading / 5;

View File

@ -947,6 +947,9 @@ namespace Volian.Print.Library
yBtmMarginForMsg = Math.Max(0, localYTopMargin - (float)MyItemInfo.MyActiveSection.MyDocStyle.Layout.PageLength); 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) switch (docstyle.Continue.Bottom.Location)
{ {
case E_ContBottomLoc.EndOfText: // place continue string at end of text case E_ContBottomLoc.EndOfText: // place continue string at end of text

View File

@ -168,7 +168,7 @@ namespace Volian.Print.Library
} }
return chk; 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); ColumnText myColumnText = new ColumnText(cb);
myColumnText.SetSimpleColumn(0, 792F, width, 0); // Bottom margin myColumnText.SetSimpleColumn(0, 792F, width, 0); // Bottom margin