Process pagenum transitions for BGE, improve automatic ToC pagination, Level0Big support

UNITALPHA, REVUNIT pagelist items
This commit is contained in:
Kathy Ruffing 2014-04-04 13:16:13 +00:00
parent 0ef5a19cd5
commit 3be5841027
3 changed files with 92 additions and 47 deletions

View File

@ -193,7 +193,8 @@ namespace Volian.Print.Library
{
if (_MyItem is ProcedureInfo)
{
if (!_MyItem.ActiveFormat.PlantFormat.FormatData.TransData.UseTransitionModifier)
if (!(_MyItem.ActiveFormat.PlantFormat.FormatData.TransData.UseTransitionModifier ||
_MyItem.ActiveFormat.PlantFormat.FormatData.TransData.UseSpecificTransitionModifier))
return Print(_MyItem as ProcedureInfo, pdfFolder);
else
{
@ -756,15 +757,7 @@ namespace Volian.Print.Library
level = level <= 2 ? 0 : level - 2; // no indenting until third level
float indentOffset = (level * (secTitlePos - secNumPos));
float retval = Rtf2Pdf.TextAt(cb, myparagraphn, leftMargin + secNumPos + indentOffset, yPageStart - yLocation, width * 1.3F, height, "", yBottomMargin);
if (retval == 0) // do a newpage, it couldn't fit on current page.
{
cb.PdfDocument.NewPage();
//_MyLog.InfoFormat("NewPage 5 {0}", cb.PdfWriter.CurrentPageNumber);
yLocation = 0;
retval = Rtf2Pdf.TextAt(cb, myparagraphn, leftMargin + secNumPos + indentOffset, yPageStart - yLocation, width * 1.3F, height, "", yBottomMargin);
}
// if the starting column of text would be in 'middle of' the number, just put it
// a few spaces after the number. The '18' below represents 3 chars.
float adjSecTitlePos = secTitlePos + indentOffset + (level * 6);
@ -773,52 +766,74 @@ namespace Volian.Print.Library
rtfText = GetRtfToC(mySection.MyContent.Text, tOfC);
Paragraph myparagrapht = vlnPrintObject.RtfToParagraph(rtfText);
width = secPagePos - adjSecTitlePos - 6;
retval = Rtf2Pdf.TextAt(cb, myparagrapht, leftMargin + adjSecTitlePos, yPageStart - yLocation, width, height, "", yBottomMargin);
// add a template for the page number:
float retval = Rtf2Pdf.TextAt(cb, myparagrapht, leftMargin + adjSecTitlePos, yPageStart - yLocation, width, height, "", yBottomMargin);
float ttlRetval = retval;
if (retval == 0)
{
cb.PdfDocument.NewPage();
//_MyLog.InfoFormat("NewPage 5 {0}", cb.PdfWriter.CurrentPageNumber);
yLocation = lastyLocation = 0;
retval = Rtf2Pdf.TextAt(cb, myparagrapht, leftMargin + adjSecTitlePos, yPageStart - yLocation, width, height, "", yBottomMargin);
ttlRetval = retval;
}
retval = Rtf2Pdf.TextAt(cb, myparagraphn, leftMargin + secNumPos + indentOffset, yPageStart - yLocation, width * 1.3F, height, "", yBottomMargin);
if (retval == 0) // do a newpage, it couldn't fit on current page.
{
cb.PdfDocument.NewPage();
//_MyLog.InfoFormat("NewPage 5 {0}", cb.PdfWriter.CurrentPageNumber);
yLocation = lastyLocation = 0;
retval = Rtf2Pdf.TextAt(cb, myparagraphn, leftMargin + secNumPos + indentOffset, yPageStart - yLocation, width * 1.3F, height, "", yBottomMargin);
}
retval = Math.Min(retval, ttlRetval);
float lSpace = (tOfC.TofCLineSpacing == 2) ? 2 * vlnPrintObject.SixLinesPerInch : vlnPrintObject.SixLinesPerInch;
if (lastyLocation != 0 && ((lastyLocation - retval) > lSpace))
yLocation += (lastyLocation - retval - lSpace);
lastyLocation = retval;
// if the space character is not null & is not a space, the we've got to put out
// these between the section title & the page number
if (tOfC.TofCSpaceChar != null && tOfC.TofCSpaceChar != "" && tOfC.TofCSpaceChar != " ")
// check that the page number should be in the TOC (some BGE sections do not have the page number)
if (!((mySection.MyDocStyle.StructureStyle.Style & E_DocStructStyle.DontNumberInTOC) == E_DocStructStyle.DontNumberInTOC))
{
width = 0;
foreach (Chunk chkt in myparagrapht.Chunks)
width += chkt.GetWidthPoint();
float startSpace = leftMargin + adjSecTitlePos + width;
float endSpace = leftMargin + secPagePos;
float numSpace = endSpace - startSpace;
string spaceStr = "";
rtfText = GetRtfToC(tOfC.TofCSpaceChar, tOfC);
Paragraph tmpmyparagraph = vlnPrintObject.RtfToParagraph(rtfText);
float spacchrwid = 0;
foreach (Chunk chkt in tmpmyparagraph.Chunks)
spacchrwid += chkt.GetWidthPoint();
while (numSpace > 0)
// add a template for the page number:
// if the space character is not null & is not a space, the we've got to put out
// these between the section title & the page number
if (tOfC.TofCSpaceChar != null && tOfC.TofCSpaceChar != "" && tOfC.TofCSpaceChar != " ")
{
spaceStr = spaceStr + tOfC.TofCSpaceChar;
numSpace -= spacchrwid;
width = 0;
foreach (Chunk chkt in myparagrapht.Chunks)
width += chkt.GetWidthPoint();
float startSpace = leftMargin + adjSecTitlePos + width;
float endSpace = leftMargin + secPagePos;
float numSpace = endSpace - startSpace;
string spaceStr = "";
rtfText = GetRtfToC(tOfC.TofCSpaceChar, tOfC);
Paragraph tmpmyparagraph = vlnPrintObject.RtfToParagraph(rtfText);
float spacchrwid = 0;
foreach (Chunk chkt in tmpmyparagraph.Chunks)
spacchrwid += chkt.GetWidthPoint();
while (numSpace > 0)
{
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);
}
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
string key = "TOC" + mySection.ItemID.ToString();
if (mySection.IsAutoTOCSection || _MyHelper.MyTOCPageNums.ContainsKey(key))
{
string pnum = _MyHelper.MyTOCPageNums.ContainsKey(key) ? _MyHelper.MyTOCPageNums[key].ToString() : (_MyHelper.CurrentTOCPageNumber + 1).ToString();
rtfText = GetRtfToC(pnum, tOfC);
Paragraph myparagraphp = vlnPrintObject.RtfToParagraph(rtfText);
width = pnum.Length * 6;
retval = Rtf2Pdf.TextAt(cb, myparagraphp, leftMargin + secPagePos, yPageStart - yLocation, width, height, "", yBottomMargin);
}
else
AddTemplateTOCPageCounts(tOfC, yLocation, yPageStartAdj, leftMargin, secPagePos, height, mySection);
}
// if in the pre-table of content list, just put the page number out as text.
// otherwise, add a template _MyHelper.MyTOCPageCounts
string key = "TOC" + mySection.ItemID.ToString();
if (mySection.IsAutoTOCSection || _MyHelper.MyTOCPageNums.ContainsKey(key))
{
string pnum = _MyHelper.MyTOCPageNums.ContainsKey(key) ? _MyHelper.MyTOCPageNums[key].ToString() : (_MyHelper.CurrentTOCPageNumber + 1).ToString();
rtfText = GetRtfToC(pnum, tOfC);
Paragraph myparagraphp = vlnPrintObject.RtfToParagraph(rtfText);
width = pnum.Length * 6;
retval = Rtf2Pdf.TextAt(cb, myparagraphp, leftMargin + secPagePos, yPageStart - yLocation, width, height, "", yBottomMargin);
}
else
AddTemplateTOCPageCounts(tOfC, yLocation, yPageStartAdj, leftMargin, secPagePos, height, mySection);
yLocation += (tOfC.TofCLineSpacing == 2 ? 2 * vlnPrintObject.SixLinesPerInch : vlnPrintObject.SixLinesPerInch);
}
yLocation = AddSectionToTOC(tocSection, mySection, tOfC, cb, yPageStart, yLocation);
@ -903,6 +918,8 @@ namespace Volian.Print.Library
}
else
{
if (nxtItem != null && nxtItem.MyPrevious != null && nxtItem.ActiveFormat.PlantFormat.FormatData.SectData.SectionHeader.Level0Big)
localYPageStart -= 12;
if (_MyHelper.BottomMessage != null)
{
_MyHelper.DrawBottomMessage(cb);

View File

@ -1279,6 +1279,31 @@ namespace Volian.Print.Library
case "{HLSTAB}":
plstr = plstr.Replace(token, HLSTAB);
break;
case "{UNITALPHA}":
// copied from 16bit's pagelist.cs for BGE:
string unitnm = MySection.MyDocVersion.DocVersionConfig.Print_UnitNumberForPageList;
if (unitnm == "1")
plstr = plstr.Replace(token, "ONE");
else if (unitnm == "2")
plstr = plstr.Replace(token, "TWO");
else
plstr = plstr.Replace(token, "ONE AND TWO");
break;
case "{REVUNIT}":
// copied from 16bit's pagelist.cs for BGE:
string revUnit = null;
string unitNum = MySection.MyDocVersion.DocVersionConfig.Print_UnitNumberForPageList;
if (Rev != null && Rev != "")
revUnit = Rev;
else
revUnit = " ";
if (unitNum == "2")
revUnit += "/Unit 2";
else if (unitNum == "1")
revUnit += "/Unit 1";
plstr = plstr.Replace(token, revUnit);
break;
default:
if (token.Contains(@"RO-"))
{

View File

@ -118,6 +118,9 @@ namespace Volian.Print.Library
YOffset = yoffset;
Text = cleanTab;
MyFont = vFont;
// BGE has a format flag to increase size of font, if top level:
if (doSectTab && myparent.MyItemInfo.ActiveFormat.PlantFormat.FormatData.SectData.SectionNumber.Level0Big && myparent.MyItemInfo.MyParent.IsProcedure)
vFont = new VE_Font(vFont.Family, 14, (E_Style)vFont.Style | E_Style.Bold, 8);
float CCCs = GetTextWidth(MyFont, "CCCCCCCCCC", symblFontName);
float IIIs = GetTextWidth(MyFont, "iiiiiiiiii", symblFontName);
string origTab1 = origTab;