C2024-002-Print-Section

This commit is contained in:
Paul Larsen 2024-01-25 11:05:04 -05:00
parent 0095b2883b
commit d6cb841d46

View File

@ -948,7 +948,7 @@ namespace Volian.Print.Library
}
foreach (SectionInfo mySection in myProcedure.Sections)
{
if(PntSectID == -1 || (PntSectID > -1 && mySection.ItemID == PntSectID) )
if(PntSectID == -1 || (PntSectID > -1 && mySection.ItemID == PntSectID) )
{
// B2020-115 Calculate maximum available space on a page for figures
vlnParagraph.hMax = ((float)mySection.MyDocStyle.Layout.PageLength);
@ -1579,270 +1579,273 @@ namespace Volian.Print.Library
bool inGroup = false;
foreach (SectionInfo mySection in ii.Sections)
{
sectCnt++;
SectionConfig sc = mySection.MyConfig as SectionConfig;
if ((mySection.MyDocStyle != null && mySection.MyDocStyle.IncludeInTOC && (sc == null || sc.Section_TOC != "Y"))
|| ((mySection.MyDocStyle == null || !mySection.MyDocStyle.IncludeInTOC) && (sc != null && sc.Section_TOC == "Y")))
if (PntSectID == -1 || (PntSectID > -1 && mySection.ItemID == PntSectID))
{
// for indenting of subsections, count up tree. Only start indenting
// at third level, i.e. not indent on 1.0 and 1.1, but indent on 1.1.1:
level = 0;
ItemInfo iilvl = mySection as ItemInfo;
while (!iilvl.IsProcedure)
sectCnt++;
SectionConfig sc = mySection.MyConfig as SectionConfig;
if ((mySection.MyDocStyle != null && mySection.MyDocStyle.IncludeInTOC && (sc == null || sc.Section_TOC != "Y"))
|| ((mySection.MyDocStyle == null || !mySection.MyDocStyle.IncludeInTOC) && (sc != null && sc.Section_TOC == "Y")))
{
level++;
iilvl = iilvl.MyParent;
}
// check what level the plant wants the auto ToC indented:
int tofCNumLevels = tocSection.ActiveFormat.PlantFormat.FormatData.SectData.AccSectionData.TableOfContentsData.TofCNumLevels ?? 0;
if (tofCNumLevels > 0 && level > tofCNumLevels) return yLocation;
int startIndentAfterLevel = tocSection.ActiveFormat.PlantFormat.FormatData.SectData.AccSectionData.TableOfContentsData.TofCStartIndentAfterLevel ?? 2; //
level = level <= startIndentAfterLevel ? 0 : level - startIndentAfterLevel;
float indentOffset = (level * (secTitlePos - secNumPos));
if (didSubSecLineSpacing && sectCnt == 1 && indentOffset > 0) // processing first sub-section and we are indenting B2016-205
{
// processed last sub-section so use the main section line spacing (most times is double spaced)
yLocation -= (float)(tOfC.TofCLineSpacingSub ?? 1) * vlnPrintObject.SixLinesPerInch;
yLocation += (float)(tOfC.TofCLineSpacing ?? 1) * vlnPrintObject.SixLinesPerInch;
}
// The Group Title logic was added for V.C. Summer and Farley(new writer guide format)
// It allows the user to enter a Table of Contents Grouping Title on the Section Property (under automation)
// 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;
inGroup = true;
// B2020-033: for single spacing, add an extra line before a grouping title:
float tmpspc = (float)(tOfC.TofCLineSpacing ?? 1);
if (lastTOCGroupHeading != "" || (firstGroupHeading && tmpspc == 1))
// for indenting of subsections, count up tree. Only start indenting
// at third level, i.e. not indent on 1.0 and 1.1, but indent on 1.1.1:
level = 0;
ItemInfo iilvl = mySection as ItemInfo;
while (!iilvl.IsProcedure)
{
yLocation += vlnPrintObject.SixLinesPerInch;
firstGroupHeading = false;
level++;
iilvl = iilvl.MyParent;
}
lastTOCGroupHeading = tocGrpHeading;
}
// 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.
bool didGrp = false;
string tmptxt = mySection.MyContent.Number == null || mySection.MyContent.Number == "" ? " " : mySection.DisplayNumber;// B2017-019 - process "<u>" in section number
if (tocSection.ActiveFormat.PlantFormat.FormatData.SectData.AccSectionData.TableOfContentsData.TofCRemoveGrpNameInSects
&& tocGrpHeading.Length > 0 && tmptxt.ToUpper().Contains(tocGrpHeading))
{
tmptxt = tmptxt.Replace(tocGrpHeading, "");
didGrp = true;
}
if (tocSection.ActiveFormat.PlantFormat.FormatData.SectData.AccSectionData.TableOfContentsData.TofCRemoveGrpNameInSects
&& lastTOCGroupHeading.Length > 0 && tmptxt.ToUpper().Contains(lastTOCGroupHeading))
{
tmptxt = tmptxt.Replace(lastTOCGroupHeading, "");
didGrp = true;
}
string rtfText = GetRtfToC(tmptxt, tOfC);
Paragraph myparagraphSecNum = vlnPrintObject.RtfToParagraph(rtfText);
float width = 0;
foreach (Chunk chkt in myparagraphSecNum.Chunks)
width += chkt.GetWidthPoint();
float numwidth = width;
Rtf2Pdf.Offset = new PointF(0, 2.5F);
// check what level the plant wants the auto ToC indented:
int tofCNumLevels = tocSection.ActiveFormat.PlantFormat.FormatData.SectData.AccSectionData.TableOfContentsData.TofCNumLevels ?? 0;
if (tofCNumLevels > 0 && level > tofCNumLevels) return yLocation;
// 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);
if (secNumPos + numwidth + indentOffset > secTitlePos + indentOffset)
adjSecTitlePos = secNumPos + numwidth + 18 - xAdjTitleIndent + indentOffset;
int startIndentAfterLevel = tocSection.ActiveFormat.PlantFormat.FormatData.SectData.AccSectionData.TableOfContentsData.TofCStartIndentAfterLevel ?? 2; //
level = level <= startIndentAfterLevel ? 0 : level - startIndentAfterLevel;
float indentOffset = (level * (secTitlePos - secNumPos));
// logic put in for V.C. Summer who wants to their auto table of contents to print "OPERATOR ACTIONS" (set in the format) instead of "Procedure Steps"
// - note that Summer didn't want to change the section title because they want transition to say "procedure step" for the section title. 03/08/2016
string tocSecTitle = mySection.FormattedDisplayText;// B2017-019 - process "<u>" in section title
tocSecTitle = ConvertSpecialChars(tocSecTitle, ii.ActiveFormat.PlantFormat.FormatData); // B2019-172 process symbol characters
if (tocSecTitle.ToUpper() == "PROCEDURE STEPS" && tocSection.ActiveFormat.PlantFormat.FormatData.SectData.AccSectionData.TableOfContentsData.TofCProcedureStepsTitle != "")
tocSecTitle = tocSection.ActiveFormat.PlantFormat.FormatData.SectData.AccSectionData.TableOfContentsData.TofCProcedureStepsTitle;
if (didSubSecLineSpacing && sectCnt == 1 && indentOffset > 0) // processing first sub-section and we are indenting B2016-205
{
// processed last sub-section so use the main section line spacing (most times is double spaced)
yLocation -= (float)(tOfC.TofCLineSpacingSub ?? 1) * vlnPrintObject.SixLinesPerInch;
yLocation += (float)(tOfC.TofCLineSpacing ?? 1) * vlnPrintObject.SixLinesPerInch;
}
// The Group Title logic was added for V.C. Summer and Farley(new writer guide format)
// It allows the user to enter a Table of Contents Grouping Title on the Section Property (under automation)
// 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;
inGroup = true;
// B2020-033: for single spacing, add an extra line before a grouping title:
float tmpspc = (float)(tOfC.TofCLineSpacing ?? 1);
if (lastTOCGroupHeading != "" || (firstGroupHeading && tmpspc == 1))
{
yLocation += vlnPrintObject.SixLinesPerInch;
firstGroupHeading = false;
}
lastTOCGroupHeading = tocGrpHeading;
}
// 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.
bool didGrp = false;
string tmptxt = mySection.MyContent.Number == null || mySection.MyContent.Number == "" ? " " : mySection.DisplayNumber;// B2017-019 - process "<u>" in section number
if (tocSection.ActiveFormat.PlantFormat.FormatData.SectData.AccSectionData.TableOfContentsData.TofCRemoveGrpNameInSects
&& tocGrpHeading.Length > 0 && tmptxt.ToUpper().Contains(tocGrpHeading))
{
tmptxt = tmptxt.Replace(tocGrpHeading, "");
didGrp = true;
}
if (tocSection.ActiveFormat.PlantFormat.FormatData.SectData.AccSectionData.TableOfContentsData.TofCRemoveGrpNameInSects
&& lastTOCGroupHeading.Length > 0 && tmptxt.ToUpper().Contains(lastTOCGroupHeading))
{
tmptxt = tmptxt.Replace(lastTOCGroupHeading, "");
didGrp = true;
}
string rtfText = GetRtfToC(tmptxt, tOfC);
Paragraph myparagraphSecNum = vlnPrintObject.RtfToParagraph(rtfText);
float width = 0;
foreach (Chunk chkt in myparagraphSecNum.Chunks)
width += chkt.GetWidthPoint();
float numwidth = width;
Rtf2Pdf.Offset = new PointF(0, 2.5F);
// Do the title first since it may wrap to 2nd line and this is an issue for
// doing a pagebreak, i.e. may cause a page break when the number on a single line
// would not.
//if (tocSection.ActiveFormat.PlantFormat.FormatData.SectData.AccSectionData.TableOfContentsData
if (level == 0 && tocSection.ActiveFormat.PlantFormat.FormatData.SectData.AccSectionData.TableOfContentsData.TofCUnderlineFirstLevelTitle)
{
VE_Font ovrFont = new VE_Font(tOfC.Font.Family, (int)tOfC.Font.Size, (E_Style)tOfC.Font.Style | E_Style.Underline, (float)tOfC.Font.CPI);
rtfText = GetRtfToC(tocSecTitle, tOfC, ovrFont);
}
else
rtfText = GetRtfToC(tocSecTitle, tOfC);
Paragraph myparagraphSecTitle = vlnPrintObject.RtfToParagraph(rtfText); // section title
width = secPagePos - adjSecTitlePos - ((tOfC.TofCPageNumAlign.ToUpper() == "RIGHT") ? 18 : 6);// B2021-109 proper adjustment of section title width - copied from leader dots lenth calcuation below
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
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;
// F2018-033: Farley Auto TOC. If line spacing is less than 0, then spacing is double spaced if on section items (such as
// Purpose, Proc Steps; and spacing is single spaced if within groups. If not less than 0, just use what is in format file.
int lnaftergroup = 1;
float lnsp = tocSection.ActiveFormat.PlantFormat.FormatData.SectData.AccSectionData.TableOfContentsData.TofCLineSpacing ?? 0;
if (lnsp < 0) 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)
// 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);
if (secNumPos + numwidth + indentOffset > secTitlePos + indentOffset)
adjSecTitlePos = secNumPos + numwidth + 18 - xAdjTitleIndent + indentOffset;
// logic put in for V.C. Summer who wants to their auto table of contents to print "OPERATOR ACTIONS" (set in the format) instead of "Procedure Steps"
// - note that Summer didn't want to change the section title because they want transition to say "procedure step" for the section title. 03/08/2016
string tocSecTitle = mySection.FormattedDisplayText;// B2017-019 - process "<u>" in section title
tocSecTitle = ConvertSpecialChars(tocSecTitle, ii.ActiveFormat.PlantFormat.FormatData); // B2019-172 process symbol characters
if (tocSecTitle.ToUpper() == "PROCEDURE STEPS" && tocSection.ActiveFormat.PlantFormat.FormatData.SectData.AccSectionData.TableOfContentsData.TofCProcedureStepsTitle != "")
tocSecTitle = tocSection.ActiveFormat.PlantFormat.FormatData.SectData.AccSectionData.TableOfContentsData.TofCProcedureStepsTitle;
// Do the title first since it may wrap to 2nd line and this is an issue for
// doing a pagebreak, i.e. may cause a page break when the number on a single line
// would not.
//if (tocSection.ActiveFormat.PlantFormat.FormatData.SectData.AccSectionData.TableOfContentsData
if (level == 0 && tocSection.ActiveFormat.PlantFormat.FormatData.SectData.AccSectionData.TableOfContentsData.TofCUnderlineFirstLevelTitle)
{
VE_Font ovrFont = new VE_Font(tOfC.Font.Family, (int)tOfC.Font.Size, (E_Style)tOfC.Font.Style | E_Style.Underline, (float)tOfC.Font.CPI);
rtfText = GetRtfToC(tocSecTitle, tOfC, ovrFont);
}
else
rtfText = GetRtfToC(tocSecTitle, tOfC);
Paragraph myparagraphSecTitle = vlnPrintObject.RtfToParagraph(rtfText); // section title
width = secPagePos - adjSecTitlePos - ((tOfC.TofCPageNumAlign.ToUpper() == "RIGHT") ? 18 : 6);// B2021-109 proper adjustment of section title width - copied from leader dots lenth calcuation below
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
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;
// F2018-033: Farley Auto TOC. If line spacing is less than 0, then spacing is double spaced if on section items (such as
// Purpose, Proc Steps; and spacing is single spaced if within groups. If not less than 0, just use what is in format file.
int lnaftergroup = 1;
float lnsp = tocSection.ActiveFormat.PlantFormat.FormatData.SectData.AccSectionData.TableOfContentsData.TofCLineSpacing ?? 0;
if (lnsp < 0) 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
if (lnsp > -1) 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, myparagraphSecTitle, leftMargin + adjSecTitlePos, yPageStart - yLocation, width, height, "", yBottomMargin);
}
//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
if (lnsp > -1) 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, myparagraphSecTitle, leftMargin + adjSecTitlePos, yPageStart - yLocation, width, height, "", yBottomMargin);
}
float ttlRetval = retval;
float savTitleFillWidth = Rtf2Pdf.FillWidth;
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, myparagraphSecNum, leftMargin + secNumPos + indentOffset, yPageStart - yLocation, numwidth * 1.3F, height, "", yBottomMargin);
// Now do the section number. Retval is the ylocation on page after the text
// is put out.
retval = Rtf2Pdf.TextAt(cb, myparagraphSecNum, leftMargin + secNumPos + indentOffset, yPageStart - yLocation, numwidth * 1.3F, height, "", yBottomMargin);
//float lSpace = (float)(tOfC.TofCLineSpacing ?? 1) * vlnPrintObject.SixLinesPerInch;
//float lSpace = (float)(tOfC.TofCLineSpacing ?? 1) * vlnPrintObject.SixLinesPerInch;
// adjust ylocation for pagenumber - the ylocation will get reset if the
// section title split on 2 lines and the page number needs to be on the 2nd line.
// Only do this if the title is not empty (the code was meant for if title spans more than a line)
if (retval != ttlRetval && mySection.MyContent.Text != null && mySection.MyContent.Text != "") yLocation += (retval - ttlRetval);
// adjust ylocation for pagenumber - the ylocation will get reset if the
// section title split on 2 lines and the page number needs to be on the 2nd line.
// Only do this if the title is not empty (the code was meant for if title spans more than a line)
if (retval != ttlRetval && mySection.MyContent.Text != null && mySection.MyContent.Text != "") yLocation += (retval - ttlRetval);
// retval = the minimum (further down the page) between section number and
// title - this accounts for multi line title.
retval = Math.Min(retval, ttlRetval);
lastyLocation = retval;
// retval = the minimum (further down the page) between section number and
// title - this accounts for multi line title.
retval = Math.Min(retval, ttlRetval);
lastyLocation = retval;
// 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))
{
// 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 != " ")
// 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 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, 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)
// to be not too close to section title & page number.
if (heightTtl > vlnPrintObject.SixLinesPerInch)
// 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 != " ")
{
// 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;
width = 0;
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, 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)
// to be not too close to section title & page number.
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;
// If the page number is Right justified, need less space characters ('.') so that page number
// doesn't have the last space character overwriting the 1st digit:
int endJust = (tOfC.TofCPageNumAlign.ToUpper() == "RIGHT") ? 18 : 6;
float endSpace = leftMargin + secPagePos - endJust;
float numSpace = endSpace - startSpace;
rtfText = GetRtfToC(tOfC.TofCSpaceChar, tOfC);
Paragraph tmpmyparagraph = vlnPrintObject.RtfToParagraph(rtfText);
float spacchrwid = 0;
foreach (Chunk chkt in tmpmyparagraph.Chunks)
spacchrwid += chkt.GetWidthPoint();
while (numSpace > 6)
{
spaceStr = spaceStr + tOfC.TofCSpaceChar;
numSpace -= spacchrwid;
}
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);
}
// 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
startSpace = leftMargin + adjSecTitlePos + width + 6;
// If the page number is Right justified, need less space characters ('.') so that page number
// doesn't have the last space character overwriting the 1st digit:
int endJust = (tOfC.TofCPageNumAlign.ToUpper() == "RIGHT") ? 18 : 6;
float endSpace = leftMargin + secPagePos - endJust;
float numSpace = endSpace - startSpace;
rtfText = GetRtfToC(tOfC.TofCSpaceChar, tOfC);
Paragraph tmpmyparagraph = vlnPrintObject.RtfToParagraph(rtfText);
float spacchrwid = 0;
foreach (Chunk chkt in tmpmyparagraph.Chunks)
spacchrwid += chkt.GetWidthPoint();
while (numSpace > 6)
{
spaceStr = spaceStr + tOfC.TofCSpaceChar;
numSpace -= spacchrwid;
}
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);
AddTemplateTOCPageCounts(tOfC, yLocation, yPageStartAdj, leftMargin, secPagePos, height, key);
}
// 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))
//If the format wants single spacing within subsections (2nd level and lower), then need to figure out
// spacing (vcb1 table of contents)
//bool dosuby = (((tocSection.ActiveFormat.PlantFormat.FormatData.SectData.AccSectionData.TableOfContentsData.TofCLineSpacingSub ?? 1) > 0)
// && (mySection.MyParent.IsSection && ((mySection.Sections != null && mySection.Sections.Count > 0) || (level > 0 && mySection.NextItem != null))))
// || didGrp;
doSubY = (((tocSection.ActiveFormat.PlantFormat.FormatData.SectData.AccSectionData.TableOfContentsData.TofCLineSpacingSub ?? 1) > 0)
&& (mySection.MyParent.IsSection && (/* mySection.Sections == null && */ sectCnt < ii.Sections.Count))) // B2016-205
|| didGrp;
//float spc = (float)(tOfC.TofCLineSpacing ?? 1);
if (doSubY)
{
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);
float spcs = (float)(tOfC.TofCLineSpacingSub ?? 1);
if (spcs == -1) // F2018-033: Allow for single & double spacing for Farley (if in group or not)
{
if (inGroup) // Do not require a title to be placed on each section in group for Farley. If in group from above, single space
spcs = 1;
else
spcs = 2;
}
yLocation += (spcs * vlnPrintObject.SixLinesPerInch);
}
else
AddTemplateTOCPageCounts(tOfC, yLocation, yPageStartAdj, leftMargin, secPagePos, height, key);
}
//If the format wants single spacing within subsections (2nd level and lower), then need to figure out
// spacing (vcb1 table of contents)
//bool dosuby = (((tocSection.ActiveFormat.PlantFormat.FormatData.SectData.AccSectionData.TableOfContentsData.TofCLineSpacingSub ?? 1) > 0)
// && (mySection.MyParent.IsSection && ((mySection.Sections != null && mySection.Sections.Count > 0) || (level > 0 && mySection.NextItem != null))))
// || didGrp;
doSubY = (((tocSection.ActiveFormat.PlantFormat.FormatData.SectData.AccSectionData.TableOfContentsData.TofCLineSpacingSub ?? 1) > 0)
&& (mySection.MyParent.IsSection && (/* mySection.Sections == null && */ sectCnt < ii.Sections.Count))) // B2016-205
|| didGrp;
//float spc = (float)(tOfC.TofCLineSpacing ?? 1);
if (doSubY)
{
float spcs = (float)(tOfC.TofCLineSpacingSub ?? 1);
if (spcs == -1) // F2018-033: Allow for single & double spacing for Farley (if in group or not)
{
if (inGroup) // Do not require a title to be placed on each section in group for Farley. If in group from above, single space
spcs = 1;
else
spcs = 2;
float spc = (float)(tOfC.TofCLineSpacing ?? 1);
if (spc == -1) // F2018-033: Allow for single & double spacing for Farley (if in group or not)
{
if (inGroup) // Do not require a title to be placed on each section in group for Farley. If in group from above, single space
spc = 1;
else
spc = 2;
}
yLocation += (spc * vlnPrintObject.SixLinesPerInch);
}
yLocation += (spcs * vlnPrintObject.SixLinesPerInch);
// C2021-015: Barakah High Level Steps in Table of Contents - check to see if we need to add the high level steps on
// table of contents for this section, format flag & section has steps:
if (mySection.ActiveFormat.PlantFormat.FormatData.SectData.AccSectionData.TableOfContentsData.TofCAllowHLS &&
mySection.IsStepSection && mySection.Steps != null && mySection.Steps.Count > 0)
yLocation = AddHLSToTOC(tocSection, mySection, tOfC, cb, yPageStart, yLocation, doSubY, level + 1, adjSecTitlePos);
}
else
float savYLoc = yLocation;
yLocation = AddSectionToTOC(tocSection, mySection, tOfC, cb, yPageStart, yLocation, doSubY);
if (savYLoc == yLocation) // nothing was outputted i.e. the subsections are not included on the TOC // B2016-205
{
float spc = (float)(tOfC.TofCLineSpacing ?? 1);
if (spc == -1) // F2018-033: Allow for single & double spacing for Farley (if in group or not)
if (doSubY && sectCnt == ii.Sections.Count)
{
if (inGroup) // Do not require a title to be placed on each section in group for Farley. If in group from above, single space
spc = 1;
else
spc = 2;
// processed last sub-section so use the main section line spacing (most times is double spaced)
yLocation -= (float)(tOfC.TofCLineSpacingSub ?? 1) * vlnPrintObject.SixLinesPerInch;
yLocation += (float)(tOfC.TofCLineSpacing ?? 1) * vlnPrintObject.SixLinesPerInch;
}
yLocation += (spc * vlnPrintObject.SixLinesPerInch);
}
// C2021-015: Barakah High Level Steps in Table of Contents - check to see if we need to add the high level steps on
// table of contents for this section, format flag & section has steps:
if (mySection.ActiveFormat.PlantFormat.FormatData.SectData.AccSectionData.TableOfContentsData.TofCAllowHLS &&
mySection.IsStepSection && mySection.Steps != null && mySection.Steps.Count > 0)
yLocation = AddHLSToTOC(tocSection, mySection, tOfC, cb, yPageStart, yLocation, doSubY, level + 1, adjSecTitlePos);
}
float savYLoc = yLocation;
yLocation = AddSectionToTOC(tocSection, mySection, tOfC, cb, yPageStart, yLocation, doSubY);
if (savYLoc == yLocation) // nothing was outputted i.e. the subsections are not included on the TOC // B2016-205
{
if (doSubY && sectCnt == ii.Sections.Count)
{
// processed last sub-section so use the main section line spacing (most times is double spaced)
yLocation -= (float)(tOfC.TofCLineSpacingSub ?? 1) * vlnPrintObject.SixLinesPerInch;
yLocation += (float)(tOfC.TofCLineSpacing ?? 1) * vlnPrintObject.SixLinesPerInch;
}
}
}
@ -2935,46 +2938,49 @@ namespace Volian.Print.Library
if (ii.Sections == null) return; // B2021-067 crash on null reference
foreach (SectionInfo si in ii.Sections)
{
if (MyPromsPrinter.PntSectID == -1 || (MyPromsPrinter.PntSectID > -1 && si.ItemID == MyPromsPrinter.PntSectID))
{
if (si.IsStepSection)
{
if (si.Sections != null) LoadSectionTree(si);
}
else
{
MyPdfFile = _MyPromsPrinter.BuildMSWordPDF(si);
if (MyPdfFile != null)
{
try
if (si.Sections != null) LoadSectionTree(si);
}
else
{
MyPdfFile = _MyPromsPrinter.BuildMSWordPDF(si);
if (MyPdfFile != null)
{
FileInfo fi = new FileInfo(MyPdfFile);
if (fi.Length == 0) // B2017-218 Handle invalid word sections
try
{
if (!PromsPrinter.BaselineTesting) //B2018-071 Output a message box unless baseline testing is being performed.
MessageBox.Show(si.DisplayNumber + " " + si.DisplayText + " is not valid", "Invalid Word Section", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
return;
FileInfo fi = new FileInfo(MyPdfFile);
if (fi.Length == 0) // B2017-218 Handle invalid word sections
{
if (!PromsPrinter.BaselineTesting) //B2018-071 Output a message box unless baseline testing is being performed.
MessageBox.Show(si.DisplayNumber + " " + si.DisplayText + " is not valid", "Invalid Word Section", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
return;
}
MyReader = MyPdfFile != null ? new PdfReader(MyPdfFile) : null;
string key = string.Empty;
for (int i = 1; i <= MyReader.NumberOfPages; i++)
{
key = string.Format("{0}.{1}", si.ItemID, i);
dicPage.Add(key, MyPromsPrinter.MyContentByte.PdfWriter.GetImportedPage(MyReader, i));
iTextSharp.text.Rectangle rectgl = MyReader.GetPageSizeWithRotation(i);
// If the word page is set to landscape, but the document style is not landscape, then flip the height and width (put back to portrait)
if (!((si.MyDocStyle.StructureStyle.Style & E_DocStructStyle.DSS_WordContentLandscaped) == E_DocStructStyle.DSS_WordContentLandscaped) && rectgl.Height < rectgl.Width)
rectgl = new iTextSharp.text.Rectangle(rectgl.Height, rectgl.Width);
dicSize.Add(key, rectgl);
//dicSize.Add(key, MyReader.GetPageSizeWithRotation(i));
}
}
MyReader = MyPdfFile != null ? new PdfReader(MyPdfFile) : null;
string key = string.Empty;
for (int i = 1; i <= MyReader.NumberOfPages; i++)
catch (Exception ex)
{
key = string.Format("{0}.{1}", si.ItemID, i);
dicPage.Add(key, MyPromsPrinter.MyContentByte.PdfWriter.GetImportedPage(MyReader, i));
iTextSharp.text.Rectangle rectgl = MyReader.GetPageSizeWithRotation(i);
// If the word page is set to landscape, but the document style is not landscape, then flip the height and width (put back to portrait)
if (!((si.MyDocStyle.StructureStyle.Style & E_DocStructStyle.DSS_WordContentLandscaped) == E_DocStructStyle.DSS_WordContentLandscaped) && rectgl.Height < rectgl.Width)
rectgl = new iTextSharp.text.Rectangle(rectgl.Height, rectgl.Width);
dicSize.Add(key, rectgl);
//dicSize.Add(key, MyReader.GetPageSizeWithRotation(i));
if (_MyPromsPrinter.DocReplace == null)
MessageBox.Show(ex.Message, ex.GetType().FullName, MessageBoxButtons.OK, MessageBoxIcon.Error);
_MyLog.Warn(string.Format("Error in LoadSectionTree [{0}],{1}.{2}", si.ItemID, si.DisplayNumber, si.DisplayText), ex);
}
}
catch (Exception ex)
{
if (_MyPromsPrinter.DocReplace == null)
MessageBox.Show(ex.Message, ex.GetType().FullName, MessageBoxButtons.OK, MessageBoxIcon.Error);
_MyLog.Warn(string.Format("Error in LoadSectionTree [{0}],{1}.{2}", si.ItemID, si.DisplayNumber, si.DisplayText), ex);
}
}
}
//}
}
}
}