Section titles & section title continue messages improved

Calvert OP/STP: Improved section title continue message
Calvert OP/STP: Added a method to get tab width with no symbol font name as argument
This commit is contained in:
Kathy Ruffing 2014-10-21 14:42:43 +00:00
parent 5e33d7ec2a
commit 6c564c8e4d
5 changed files with 105 additions and 9 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -946,6 +946,25 @@ namespace Volian.Print.Library
}
}
private string GetSectCombinedTab(ItemInfo tmp)
{
ItemInfo itemInfo = tmp;
if (itemInfo.IsCautionOrNotePart) itemInfo = itemInfo.ActiveParent as ItemInfo; // if caution/note get to its associated step
itemInfo = itemInfo.ActiveParent as ItemInfo; // don't want this one in the combined tab, start at parent
if (!itemInfo.IsHigh && !itemInfo.IsSequential && !itemInfo.IsSection) itemInfo = itemInfo.ActiveParent as ItemInfo;
string prTab = "";
string thisTab = itemInfo.MyTab.CleanText.Trim();
ItemInfo mypar = itemInfo.MyParent;
while (mypar.MyParent != null && !mypar.MyParent.IsProcedure)
{
string pTab = mypar.MyTab.CleanText.Trim();
pTab = pTab.TrimEnd(" .".ToCharArray()) + ".";
prTab = pTab + prTab;
mypar = mypar.MyParent;
}
return (prTab + thisTab.Trim()).TrimEnd(".".ToCharArray());
}
private static bool DoSubs = true; // flag whether to print substeps (don't if doing continued checklist header)
public override float ToPdf(PdfContentByte cb, float yPageStart, ref float yTopMargin, ref float yBottomMargin)
{
@ -1146,14 +1165,32 @@ namespace Volian.Print.Library
yPageStart = yTopMargin + yTopMost;// -2 * SixLinesPerInch;
DoCheckOffHeader(cb, MyItemInfo, yLocation, yTopMargin, yPageStart);
if (EmptyTopMostPart) yPageStart += SixLinesPerInch;
bool addExtraLines = DoTopContinueMsg(cb, ref yPageStart, yTopMargin, docstyle, doThreeContinues && MyItemInfo.MyParent != null && MyItemInfo.MyParent.MyTab != null ? MyItemInfo.MyParent.MyTab.CleanText : null);
bool addExtraLines = false;
// If "ContinueSectionHeader" (format flag) is true then print the section title with "(Continued)" appended to it
if (MyItemInfo.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.ContinueSectionHeader)
{
SectionConfig sch = MyItemInfo.ActiveSection.MyConfig as SectionConfig;
doSectionTitleContinued = (sch == null || sch.Section_PrintHdr == "Y");
// if this is calvert OI/STP, then also check that docstyle has a top continue message
// in the document style that includes 'Continued'
if (MyItemInfo.ActiveFormat.PlantFormat.FormatData.PrintData.SpecialCaseCalvert)
{
string myMsg = MyItemInfo.MyDocStyle.Continue.Top.Message;
if (myMsg == null || myMsg == "")
doSectionTitleContinued = false;
else
{
SectionConfig sch = MyItemInfo.ActiveSection.MyConfig as SectionConfig;
doSectionTitleContinued = (sch == null || sch.Section_PrintHdr == "Y");
}
}
else
{
SectionConfig sch = MyItemInfo.ActiveSection.MyConfig as SectionConfig;
doSectionTitleContinued = (sch == null || sch.Section_PrintHdr == "Y");
}
}
if (!doSectionTitleContinued)
addExtraLines = DoTopContinueMsg(cb, ref yPageStart, yTopMargin, docstyle, doThreeContinues && MyItemInfo.MyParent != null && MyItemInfo.MyParent.MyTab != null ? MyItemInfo.MyParent.MyTab.CleanText : null);
MyPageHelper.YMultiplier = 1;
// For Calvert Alarms, if there was a page break and there is an box around the current
@ -1244,10 +1281,55 @@ namespace Volian.Print.Library
{
vlnParagraph sectContPara;
string contMsg = MyItemInfo.MyActiveSection.MyDocStyle.Continue.SectionTitle.AppendToTitle;
sectContPara = new vlnParagraph(MyParent.MyParent, cb, MyItemInfo.ActiveSection, MyParent.XOffset, 0, 0, 0, MyParent.MyItemInfo.ActiveFormat, null, (contMsg == null || contMsg == "") ? " (Continued)" : contMsg, 0, false);
float mytmpfloat = sectContPara.ParagraphToPdf(cb, yTopMargin, yTopMargin, yBottomMargin);
if (sectContPara.SectionContinuePrinted)
yPageStart -= sectContPara.Height * 2;
// For Calvert, the xoffset will be the highest level sections xoffset (there are metasections,
// don't use their xoffset or the continue message is indented too much)
if (MyItemInfo.ActiveFormat.PlantFormat.FormatData.PrintData.SpecialCaseCalvert)
{
float secContinueTabXoff = (float)MyItemInfo.MyDocStyle.Layout.LeftMargin;
float secContinueXoff = 0f;
float secContinueTabWidth = 0f;
vlnParagraph fndTopSect = this;
while (fndTopSect.MyParent != null)
{
fndTopSect = fndTopSect.MyParent;
}
if (fndTopSect != null && fndTopSect.MyTab != null)
{
secContinueTabXoff = fndTopSect.MyTab.XOffset;
secContinueTabWidth = fndTopSect.MyTab.Width;
secContinueXoff = fndTopSect.XOffset;
}
sectContPara = new vlnParagraph(MyParent.MyParent, cb, MyItemInfo.ActiveSection, MyParent.XOffset, 0, 0, 0, MyParent.MyItemInfo.ActiveFormat, null, (contMsg == null || contMsg == "") ? " (Continued)" : contMsg, 0, false);
if (sectContPara.PartsLeft.Count > 0)
{
vlnTab vt = sectContPara.MyTab;
string ctab = GetSectCombinedTab(MyItemInfo);
vt.Rtf = GetRtf(ctab, vt.MyFont);
float wd = vt.GetTextWidth(vt.MyFont, ctab);
vt.XOffset = secContinueTabXoff;
vt.Width = secContinueXoff - secContinueTabXoff;
sectContPara.XOffset = secContinueXoff;
if ((wd + 12) > secContinueXoff - secContinueTabXoff) // 12 is 2 characters
{
float dif = wd + 12 - (secContinueXoff - secContinueTabXoff);
vt.Width += dif;
sectContPara.XOffset += dif;
sectContPara.Width -= dif;
}
}
float mytmpfloat = sectContPara.ParagraphToPdf(cb, yTopMargin, yTopMargin, yBottomMargin);
if (sectContPara.SectionContinuePrinted)
yPageStart -= sectContPara.Height * 2;
}
else
{
sectContPara = new vlnParagraph(MyParent.MyParent, cb, MyItemInfo.ActiveSection, MyParent.XOffset, 0, 0, 0, MyParent.MyItemInfo.ActiveFormat, null, (contMsg == null || contMsg == "") ? " (Continued)" : contMsg, 0, false);
float mytmpfloat = sectContPara.ParagraphToPdf(cb, yTopMargin, yTopMargin, yBottomMargin);
if (sectContPara.SectionContinuePrinted)
yPageStart -= sectContPara.Height * 2;
}
}
yPageStart = ChildrenAbove.ToPdf(cb, yPageStart, ref yTopMargin, ref yBottomMargin);
yPageStart = ChildrenLeft.ToPdf(cb, yPageStart, ref yTopMargin, ref yBottomMargin);
@ -1357,7 +1439,6 @@ namespace Volian.Print.Library
if (yLocalypagestart != yPageStart) DebugText.WriteLine("ToPdf-yPagestartDiff:{0},{1},{2},{3}", MyPageHelper.MyPdfContentByte.PdfWriter.CurrentPageNumber, MyItemInfo.ItemID, yLocalypagestart, yPageStart);
return yPageStart;
}
private bool DoTopContinueMsg(PdfContentByte cb, ref float yPageStart, float yTopMargin, DocStyle docstyle, string subTab)
{
bool addExtraLine = false;
@ -2059,6 +2140,8 @@ namespace Volian.Print.Library
MetaLevel = MetaLevel <= 2 ? 1 : MetaLevel - 1;
if (MetaLevel == 1)
offset += (float)formatInfo.PlantFormat.FormatData.SectData.SectionNumber.Pos;
else if (formatInfo.PlantFormat.FormatData.PrintData.SpecialCaseCalvert)
offset = MyParent.XOffset;
else
{
xMetaAdj = (float)formatInfo.PlantFormat.FormatData.SectData.MetaSectionList[0].ColSByLevel;
@ -3616,6 +3699,8 @@ namespace Volian.Print.Library
level = level <= 2 ? 1 : level - 1;
if (level == 1)
XOffset = (float)itemInfo.MyDocStyle.Layout.LeftMargin + (level * (float)formatInfo.PlantFormat.FormatData.SectData.SectionHeader.Pos);
else if (formatInfo.PlantFormat.FormatData.PrintData.SpecialCaseCalvert)
XOffset = myTab.XOffset + ((float)formatInfo.PlantFormat.FormatData.SectData.SectionHeader.Pos - (float)formatInfo.PlantFormat.FormatData.SectData.SectionNumber.Pos);
else
{
XOffset = (float)itemInfo.MyDocStyle.Layout.LeftMargin + (float)formatInfo.PlantFormat.FormatData.SectData.MetaSectionList[level].ColSByLevel;

View File

@ -77,6 +77,10 @@ namespace Volian.Print.Library
return System.Drawing.FontStyle.Italic;
return FontStyle.Regular;
}
public float GetTextWidth(VE_Font vefont, string txt)
{
return GetTextWidth(vefont, txt, SymbolFontName);
}
private float GetTextWidth(VE_Font vefont, string txt, string symblFontName)
{
System.Drawing.Font font = new System.Drawing.Font(vefont.Family, (float)vefont.Size, GetSysFontStyle(vefont));
@ -109,8 +113,15 @@ namespace Volian.Print.Library
get { return _SeparateBullet; }
set { _SeparateBullet = value; }
}
private string _SymbolFontName;
public string SymbolFontName
{
get { return _SymbolFontName; }
set { _SymbolFontName = value; }
}
public vlnTab(PdfContentByte cb, vlnParagraph myparent, string origTab, string cleanTab, float xoffset, float yoffset, VE_Font vFont, bool doSectTab, string symblFontName, bool removedUnderline)
{
SymbolFontName = symblFontName;
bool alignAsIfBulleted = false;
ScriptCaution = (origTab.Contains("Caution") && vFont.Family == "VolianScript");
MyContentByte = cb;