B2016-216 Don’t put a page break between a group heading and the first item under it.
This commit is contained in:
parent
72282c3184
commit
570404687c
@ -1178,25 +1178,13 @@ namespace Volian.Print.Library
|
||||
// The grouping title will print if the same title wasn't last printed
|
||||
string tocGrpHeading = sc.Section_TOC_Group_Title; // returns a "" if no title was entered
|
||||
float yBottomMargin = yPageStart - (float)tocSection.MyDocStyle.Layout.PageLength + (2 * vlnPrintObject.SixLinesPerInch);
|
||||
bool doGroupHeading = false;
|
||||
if (tocGrpHeading != lastTOCGroupHeading && tocGrpHeading.Length > 0)
|
||||
{
|
||||
doGroupHeading = true;
|
||||
if (lastTOCGroupHeading != "")
|
||||
yLocation += vlnPrintObject.SixLinesPerInch;
|
||||
lastTOCGroupHeading = tocGrpHeading;
|
||||
VE_Font grpingFont = new VE_Font(tOfC.Font.Family, (int)tOfC.Font.Size, (E_Style)tOfC.Font.Style | E_Style.Underline, (float)tOfC.Font.CPI);
|
||||
string rtfGrpingText = GetRtfToC(tocGrpHeading, tOfC, grpingFont);
|
||||
Paragraph myparagraphtc = vlnPrintObject.RtfToParagraph(rtfGrpingText);
|
||||
float w = secPagePos - 6;
|
||||
//if (yLocation > 0) yLocation += vlnPrintObject.SixLinesPerInch;// commented out for B2016-200 // for two blank line between last TOC title and the new grouping title
|
||||
float rtnval = Rtf2Pdf.TextAt(cb, myparagraphtc, leftMargin + secNumPos, yPageStart - yLocation, w, height, "", yBottomMargin);
|
||||
if (rtnval == 0) // couldn't fit, flags need for a page break.
|
||||
{
|
||||
NewPage();
|
||||
_MyHelper.ResetSvg(); // needed to reset so that PSNotFirst pagelist justify flag gets used for BGE
|
||||
yLocation = lastyLocation = 0;
|
||||
rtnval = Rtf2Pdf.TextAt(cb, myparagraphtc, leftMargin + secNumPos, yPageStart - yLocation, w, height, "", yBottomMargin);
|
||||
}
|
||||
yLocation += vlnPrintObject.SixLinesPerInch; // for two blank line between last TOC title and the new grouping title - added for B2016-200
|
||||
int lnaftergroup = ((tocSection.ActiveFormat.PlantFormat.FormatData.SectData.AccSectionData.TableOfContentsData.TofCLineSpacingSub ?? 0) > 0) ? 1 : 2;
|
||||
yLocation += (lnaftergroup * vlnPrintObject.SixLinesPerInch); // new line
|
||||
}
|
||||
// need to do the section number, section title & page number. Page number
|
||||
// has to be put on at end after number of page is known, so use a Template.
|
||||
@ -1215,9 +1203,9 @@ namespace Volian.Print.Library
|
||||
didGrp = true;
|
||||
}
|
||||
string rtfText = GetRtfToC(tmptxt, tOfC);
|
||||
Paragraph myparagraphn = vlnPrintObject.RtfToParagraph(rtfText);
|
||||
Paragraph myparagraphSecNum = vlnPrintObject.RtfToParagraph(rtfText);
|
||||
float width = 0;
|
||||
foreach (Chunk chkt in myparagraphn.Chunks)
|
||||
foreach (Chunk chkt in myparagraphSecNum.Chunks)
|
||||
width += chkt.GetWidthPoint();
|
||||
float numwidth = width;
|
||||
Rtf2Pdf.Offset = new PointF(0, 2.5F);
|
||||
@ -1245,25 +1233,46 @@ namespace Volian.Print.Library
|
||||
}
|
||||
else
|
||||
rtfText = GetRtfToC(tocSecTitle, tOfC);
|
||||
Paragraph myparagrapht = vlnPrintObject.RtfToParagraph(rtfText);
|
||||
Paragraph myparagraphSecTitle = vlnPrintObject.RtfToParagraph(rtfText); // section title
|
||||
width = secPagePos - adjSecTitlePos - 6;
|
||||
float savTitleWid = width;
|
||||
// for South Texas Table of Contents
|
||||
// if there is no section number (we put a blank in tmptxt) then move the section title over to the section number position
|
||||
float retval = Rtf2Pdf.TextAt(cb, myparagrapht, leftMargin + ((tOfC.TofCSecNumPos == tOfC.TofCSecTitlePos && tmptxt.Equals(" "))? secNumPos : adjSecTitlePos), yPageStart - yLocation, width, height, "", yBottomMargin);
|
||||
if (doGroupHeading) // see if the group title and the first item under it will fit on the page B2016-216
|
||||
{
|
||||
VE_Font grpingFont = new VE_Font(tOfC.Font.Family, (int)tOfC.Font.Size, (E_Style)tOfC.Font.Style | E_Style.Underline, (float)tOfC.Font.CPI);
|
||||
string rtfGrpingText = GetRtfToC(tocGrpHeading, tOfC, grpingFont);
|
||||
Paragraph myparagraphGrpTitle = vlnPrintObject.RtfToParagraph(rtfGrpingText);
|
||||
float w = secPagePos - 6;
|
||||
int lnaftergroup = ((tocSection.ActiveFormat.PlantFormat.FormatData.SectData.AccSectionData.TableOfContentsData.TofCLineSpacingSub ?? 0) > 0) ? 1 : 2;
|
||||
float yLocAfterGrpTitleAndFirstItem = yLocation + (lnaftergroup * vlnPrintObject.SixLinesPerInch) + vlnPrintObject.GetHeight(cb, myparagraphGrpTitle, string.Empty, w, false) + vlnPrintObject.GetHeight(cb, myparagraphSecTitle, string.Empty, savTitleWid, false);
|
||||
// if group heading and first item under it does not fit on the page, do a page break
|
||||
if ((yPageStart - yLocAfterGrpTitleAndFirstItem) < yBottomMargin)
|
||||
{
|
||||
NewPage();
|
||||
_MyHelper.ResetSvg(); // needed to reset so that PSNotFirst pagelist justify flag gets used for BGE
|
||||
yLocation = lastyLocation = 0;
|
||||
}
|
||||
//if (yLocation > 0) yLocation += vlnPrintObject.SixLinesPerInch;// commented out for B2016-200 // for two blank line between last TOC title and the new grouping title
|
||||
float rtnval = Rtf2Pdf.TextAt(cb, myparagraphGrpTitle, leftMargin + secNumPos, yPageStart - yLocation, w, height, "", yBottomMargin); // print the Group Title
|
||||
yLocation += vlnPrintObject.SixLinesPerInch; // for two blank line between last TOC title and the new grouping title - added for B2016-200
|
||||
yLocation += (lnaftergroup * vlnPrintObject.SixLinesPerInch); // new line
|
||||
}
|
||||
// Print the section title
|
||||
float retval = Rtf2Pdf.TextAt(cb, myparagraphSecTitle, leftMargin + ((tOfC.TofCSecNumPos == tOfC.TofCSecTitlePos && tmptxt.Equals(" "))? secNumPos : adjSecTitlePos), yPageStart - yLocation, width, height, "", yBottomMargin);
|
||||
if (retval == 0) // couldn't fit, flags need for a page break.
|
||||
{
|
||||
NewPage();
|
||||
_MyHelper.ResetSvg(); // needed to reset so that PSNotFirst pagelist justify flag gets used for BGE
|
||||
yLocation = lastyLocation = 0;
|
||||
retval = Rtf2Pdf.TextAt(cb, myparagrapht, leftMargin + adjSecTitlePos, yPageStart - yLocation, width, height, "", yBottomMargin);
|
||||
retval = Rtf2Pdf.TextAt(cb, myparagraphSecTitle, 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, numwidth * 1.3F, height, "", yBottomMargin);
|
||||
retval = Rtf2Pdf.TextAt(cb, myparagraphSecNum, leftMargin + secNumPos + indentOffset, yPageStart - yLocation, numwidth * 1.3F, height, "", yBottomMargin);
|
||||
|
||||
//float lSpace = (float)(tOfC.TofCLineSpacing ?? 1) * vlnPrintObject.SixLinesPerInch;
|
||||
|
||||
@ -1286,12 +1295,12 @@ namespace Volian.Print.Library
|
||||
if (tOfC.TofCSpaceChar != null && tOfC.TofCSpaceChar != "" && tOfC.TofCSpaceChar != " ")
|
||||
{
|
||||
width = 0;
|
||||
foreach (Chunk chkt in myparagrapht.Chunks)
|
||||
foreach (Chunk chkt in myparagraphSecTitle.Chunks)
|
||||
width += chkt.GetWidthPoint();
|
||||
|
||||
// get height - if two lines high, need width of 2nd line for adding
|
||||
// space characters
|
||||
float heightTtl = vlnPrintObject.GetHeight(cb, myparagrapht, string.Empty, savTitleWid, false);
|
||||
float heightTtl = vlnPrintObject.GetHeight(cb, myparagraphSecTitle, string.Empty, 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)
|
||||
@ -1322,7 +1331,7 @@ namespace Volian.Print.Library
|
||||
numSpace -= spacchrwid;
|
||||
}
|
||||
|
||||
rtfText = GetRtfToC(spaceStr, tOfC);
|
||||
rtfText = GetRtfToC(spaceStr, tOfC); // out the leader dots
|
||||
Paragraph myparagraphs = vlnPrintObject.RtfToParagraph(rtfText);
|
||||
retval = Rtf2Pdf.TextAt(cb, myparagraphs, startSpace, yPageStart - yLocation, endSpace - startSpace, height, "", yBottomMargin);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user