From 3be584102766fea40f6cdaeffb42e0892b9b8ada Mon Sep 17 00:00:00 2001 From: Kathy Date: Fri, 4 Apr 2014 13:16:13 +0000 Subject: [PATCH] Process pagenum transitions for BGE, improve automatic ToC pagination, Level0Big support UNITALPHA, REVUNIT pagelist items --- PROMS/Volian.Print.Library/PromsPrinter.cs | 111 ++++++++++-------- .../Volian.Print.Library/VlnSvgPageHelper.cs | 25 ++++ PROMS/Volian.Print.Library/vlnTab.cs | 3 + 3 files changed, 92 insertions(+), 47 deletions(-) diff --git a/PROMS/Volian.Print.Library/PromsPrinter.cs b/PROMS/Volian.Print.Library/PromsPrinter.cs index b54e793b..369014a5 100644 --- a/PROMS/Volian.Print.Library/PromsPrinter.cs +++ b/PROMS/Volian.Print.Library/PromsPrinter.cs @@ -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); diff --git a/PROMS/Volian.Print.Library/VlnSvgPageHelper.cs b/PROMS/Volian.Print.Library/VlnSvgPageHelper.cs index 7d35d3ab..d05e6e73 100644 --- a/PROMS/Volian.Print.Library/VlnSvgPageHelper.cs +++ b/PROMS/Volian.Print.Library/VlnSvgPageHelper.cs @@ -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-")) { diff --git a/PROMS/Volian.Print.Library/vlnTab.cs b/PROMS/Volian.Print.Library/vlnTab.cs index 01061228..a44fd1ef 100644 --- a/PROMS/Volian.Print.Library/vlnTab.cs +++ b/PROMS/Volian.Print.Library/vlnTab.cs @@ -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;