From bfcd9ce1db06cefbcbb6ce88be35721649de2b34 Mon Sep 17 00:00:00 2001 From: Kathy Date: Mon, 21 Nov 2011 17:00:26 +0000 Subject: [PATCH] --- PROMS/Volian.Print.Library/vlnParagraph.cs | 175 +++++++++++++++++++-- 1 file changed, 164 insertions(+), 11 deletions(-) diff --git a/PROMS/Volian.Print.Library/vlnParagraph.cs b/PROMS/Volian.Print.Library/vlnParagraph.cs index ba9ae4af..f9d6271c 100644 --- a/PROMS/Volian.Print.Library/vlnParagraph.cs +++ b/PROMS/Volian.Print.Library/vlnParagraph.cs @@ -35,6 +35,12 @@ namespace Volian.Print.Library float yTop = yoff; foreach (ItemInfo childItemInfo in itemInfoList) { + // if this is a caution/note and it has a caution/note substep, do it before this caution/note, so that + // it comes above it. + if (childItemInfo.Cautions != null && (childItemInfo.IsCaution || childItemInfo.IsNote)) + yoff = Add(cb, childItemInfo.Cautions, xoff, yoff, yoffRight, rnoLevel, maxRNO, formatInfo); + if (childItemInfo.Notes != null && (childItemInfo.IsCaution || childItemInfo.IsNote)) + yoff = Add(cb, childItemInfo.Notes, xoff, yoff, yoffRight, rnoLevel, maxRNO, formatInfo); int? bxIndx = childItemInfo.FormatStepData==null?-1:childItemInfo.FormatStepData.StepLayoutData.STBoxindex; if (bxIndx != -1 && (bxIndex != bxIndx || childItemInfo.FormatStepData.BoxIt)) { @@ -72,6 +78,8 @@ namespace Volian.Print.Library } if (childItemInfo is SectionInfo) formatInfo = (childItemInfo as SectionInfo).LocalFormat ?? formatInfo; if (rnoLevel < maxRNO && childItemInfo.RNOs != null) yoff = Math.Max(yoff, yoffRight); + + vlnParagraph para = new vlnParagraph(Parent, cb, childItemInfo, xoff, yoff, rnoLevel, maxRNO, formatInfo); if (box != null && box.MyParent == null) { @@ -537,7 +545,8 @@ namespace Volian.Print.Library // break on the first step (child) in the section. if so, break on the section. The // flag SectionPageBreak is set to true to flag that a pagebreak should not be done // on that first step. - ManualPageBreak = (firstChild.MyItemInfo.MyConfig as StepConfig).Step_ManualPagebreak; + StepConfig sc = firstChild.MyItemInfo.MyConfig as StepConfig; + ManualPageBreak = sc == null? false: sc.Step_ManualPagebreak; if (ManualPageBreak) { SectionPageBreak = true; @@ -846,7 +855,8 @@ namespace Volian.Print.Library //int[] problemIDs = { 889 }; //List lProblemIDs = new List(problemIDs); //if (lProblemIDs.Contains(itemInfo.ItemID)) - // Console.WriteLine("Found Item {0}", itemInfo.ItemID); + // Console.WriteLine("Found Item {0}", itemInfo.ItemID);formatInfochecko + MyParent = parent; // The following code determines the last paragraph for an RNO // MyTopRNO finds the Top paragraph for an RNO @@ -888,6 +898,7 @@ namespace Volian.Print.Library } if (!itemInfo.IsSection || doSectTab) { + mytab = new vlnTab(cb, this, itemInfo.MyTab.Text, itemInfo.MyTab.CleanText, localXOffset, yoff, itemInfo.MyTab.MyFont, doSectTab, StepRTB.MySymbolFontName); PartsLeft.Add(mytab); if (mytab.MyMacro != null) PartsLeft.Add(mytab.MyMacro); @@ -895,9 +906,9 @@ namespace Volian.Print.Library } AdjustWidth(itemInfo, maxRNO, formatInfo, mytab); AdjustXOffsetForTab(itemInfo, maxRNO, formatInfo, mytab); - if (itemInfo.Cautions != null) + if (itemInfo.Cautions != null && !(itemInfo.IsCaution || itemInfo.IsNote)) yoff = ChildrenAbove.Add(cb, itemInfo.Cautions, xoff, yoff, yoff, rnoLevel, maxRNO, formatInfo); - if (itemInfo.Notes != null) + if (itemInfo.Notes != null && !(itemInfo.IsCaution || itemInfo.IsNote)) yoff = ChildrenAbove.Add(cb, itemInfo.Notes, xoff, yoff, yoff, rnoLevel, maxRNO, formatInfo); YTop = yoff; if (itemInfo.MyHeader != null && itemInfo.MyHeader.Text != null && !doSectTab) @@ -914,6 +925,7 @@ namespace Volian.Print.Library mytab.YOffset = yoff; if (mytab.MyMacro != null) mytab.MyMacro.YOffset = yoff; } + float yForCheckoff = 0; if (itemInfo.MyContent.MyGrid != null) { VlnFlexGrid myFlexGrid = new VlnFlexGrid(1,1); @@ -921,6 +933,7 @@ namespace Volian.Print.Library MyGrid = new vlnTable(myFlexGrid, cb); Height = MyGrid.Height; Width = MyGrid.Width; + yForCheckoff = yoff + Height - SixLinesPerInch; yoff += (Height + (2 * SixLinesPerInch)); CalculateXOffset(itemInfo, maxRNO, formatInfo); } @@ -944,6 +957,7 @@ namespace Volian.Print.Library Width = Int32.Parse(vals[3], System.Globalization.NumberStyles.AllowHexSpecifier) * MyItemInfo.FormatStepData.Font.CharsToTwips; int lines = Int32.Parse(vals[2], System.Globalization.NumberStyles.AllowHexSpecifier); Height = lines * SixLinesPerInch; + yForCheckoff = yoff + Height - SixLinesPerInch; yoff += (Height + (2 * SixLinesPerInch)); string erMsg = null; try @@ -979,9 +993,16 @@ namespace Volian.Print.Library && !MyItemInfo.MyDocStyle.SpecialStepsFoldout)) { yoff += Height; + yForCheckoff = yoff - SixLinesPerInch; yoff += AdjustForBlankLines(); } } + CheckOff co = itemInfo.GetCheckOffStep(); + if (co != null) + { + float xloc_co = (float)formatInfo.PlantFormat.FormatData.ProcData.CheckOffData.XLocation + (float)itemInfo.MyDocStyle.Layout.LeftMargin; + PartsRight.Add(new vlnMacro(xloc_co, yForCheckoff, co.Macro)); + } float yOffRight = yoff; float RnoOffset = ToInt(formatInfo.MyStepSectionLayoutData.ColRTable, maxRNO); if (rnoLevel < maxRNO && itemInfo.RNOs != null) yOffRight = ChildrenRight.Add(cb, itemInfo.RNOs, XOffset + RnoOffset, YTop, YTop, rnoLevel + 1, maxRNO, formatInfo); @@ -995,7 +1016,17 @@ namespace Volian.Print.Library else // AER or RNO Table yoff = ChildrenBelow.Add(cb, itemInfo.Tables, XOffset, yoff, yOffRight, rnoLevel, maxRNO, formatInfo); } - if (itemInfo.Steps != null) yoff = ChildrenBelow.Add(cb, itemInfo.Steps, XOffset, yoff, yOffRight, rnoLevel, maxRNO, formatInfo); + + // Look for the meta section case where the 'Editable' flag is set to 'N', which means that + // these steps should not be printed: + bool printsteps = true; + if (itemInfo.Steps != null && itemInfo.IsSection) + { + SectionConfig sc = itemInfo.MyConfig as SectionConfig; + if (sc != null && sc.SubSection_Edit == "N") printsteps = false; + } + + if (itemInfo.Steps != null && printsteps) yoff = ChildrenBelow.Add(cb, itemInfo.Steps, XOffset, yoff, yOffRight, rnoLevel, maxRNO, formatInfo); if (itemInfo.Sections != null) yoff = ChildrenBelow.Add(cb, itemInfo.Sections, xoff, yoff, yoff, rnoLevel, maxRNO, formatInfo); if (itemInfo.Procedures != null) yoff = ChildrenBelow.Add(cb, itemInfo.Procedures, xoff, yoff, yoff, rnoLevel, maxRNO, formatInfo); if (rnoLevel >= maxRNO && itemInfo.RNOs != null) yoff = ChildrenBelow.Add(cb, itemInfo.RNOs, XOffset, yoff, yoff, rnoLevel + 1, maxRNO, formatInfo); @@ -1422,6 +1453,7 @@ namespace Volian.Print.Library float tabWidth = (myTab == null) ? 0 : myTab.Width; if (itemInfo.IsStepSection) { + if (itemInfo.MyDocStyle.CancelSectTitle) return; if (formatInfo.PlantFormat.FormatData.SectData.SectionHeader.Just == "PSLeft") XOffset = (float)itemInfo.MyDocStyle.Layout.LeftMargin + (float)formatInfo.PlantFormat.FormatData.SectData.SectionHeader.Pos; return; @@ -1438,8 +1470,35 @@ namespace Volian.Print.Library { float x = (float)itemInfo.MyDocStyle.Layout.LeftMargin + (float)formatInfo.PlantFormat.FormatData.SectData.StepSectionData.StepSectionLayoutData.ColS; float xoff = x - XOffset; - XOffset += xoff; - if (myTab != null) myTab.XOffset += xoff; + + // ColSByLevel will specify the column in which the High Level Step starts with + // respect to the overall level calculation based on sections & meta-sections. + // Only a few of the single column formats use this: WCN1, CAL1, RGEBCK + if (formatInfo.PlantFormat.FormatData.SectData.StepSectionData.StepSectionLayoutData.TieTabToLevel + && itemInfo.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.StepSectionLayoutData.ShowSectionTitles + && !itemInfo.MyDocStyle.CancelSectTitle + && !(itemInfo.MyDocStyle.SpecialStepsFoldout && itemInfo.MyDocStyle.UseColSByLevel)) + { + int indxLevel = itemInfo.PrintLevel + itemInfo.CurrentSectionLevel(); + float colsbylevel = (float)formatInfo.PlantFormat.FormatData.SectData.MetaSectionList[indxLevel % formatInfo.PlantFormat.FormatData.SectData.MetaSectionList.Count].ColSByLevel; + float seclvlindent = colsbylevel - (float)formatInfo.PlantFormat.FormatData.SectData.StepSectionData.StepSectionLayoutData.ColS; + x = (float)itemInfo.MyDocStyle.Layout.LeftMargin + (float)formatInfo.PlantFormat.FormatData.SectData.StepSectionData.StepSectionLayoutData.ColS + seclvlindent; + xoff = x - XOffset; + if (myTab != null) myTab.XOffset = (float)itemInfo.MyDocStyle.Layout.LeftMargin + colsbylevel; + LeftJustifyList jstlst = formatInfo.PlantFormat.FormatData.SectData.StepSectionData.StepSectionPrintData.LeftJustifyList; + if (jstlst.Count > 0) + { + float leftJustifyTabSize = jstlst[indxLevel % jstlst.Count].Size ?? 0; + XOffset = myTab.XOffset + leftJustifyTabSize; + } + else + XOffset = myTab.XOffset + (myTab.Text.Length * (float)itemInfo.FormatStepData.Font.CPI) - colsbylevel; + } + else + { + XOffset += xoff; + if (myTab != null) myTab.XOffset += xoff; + } } else if (itemInfo.IsRNOPart && !((ItemInfo)itemInfo.ActiveParent).IsHigh) { @@ -1447,10 +1506,40 @@ namespace Volian.Print.Library } else if (MyParent != null) { - XOffset += tabWidth - (myTab == null ? 0 : myTab.TabAlign); - if (myTab != null) myTab.XOffset += tabWidth - myTab.TabAlign; + if (myTab != null && itemInfo.IsSequential && formatInfo.PlantFormat.FormatData.SectData.UseMetaSections && formatInfo.PlantFormat.FormatData.SectData.StepSectionData.StepSectionPrintData.LeftJustifyList.Count > 0) + { + int indxLevels = itemInfo.PrintLevel + itemInfo.CurrentSectionLevel(); + LeftJustifyList jstlst = formatInfo.PlantFormat.FormatData.SectData.StepSectionData.StepSectionPrintData.LeftJustifyList; + float tableftadj = (jstlst[indxLevels >= jstlst.Count ? jstlst.Count - 1 : indxLevels].Size) ?? 0; + if (tableftadj != 0) tabWidth = myTab.Width = (jstlst[indxLevels >= jstlst.Count ? jstlst.Count - 1 : indxLevels].Size) ?? 0; + XOffset += tabWidth; + myTab.XOffset += tabWidth; + myTab.Rtf = myTab.Rtf.Replace(myTab.Text, myTab.Text.TrimStart(" ".ToCharArray())); + Width = MyParent.Width - myTab.Width; + } + else // if no left justify, right align the tab + { + XOffset += tabWidth - (myTab == null ? 0 : myTab.TabAlign); + if (myTab != null) myTab.XOffset += tabWidth - myTab.TabAlign; + } } } + private static int CurrentSectionLevel(ItemInfo itemInfo) + { + int retval = 0; + SectionInfo si = itemInfo.MyActiveSection as SectionInfo; + if ((si != null && si.TrueSectionNum()) || (itemInfo.ActiveSection.MyDocStyle.StructureStyle.Style & E_DocStructStyle.DSS_TreatAsTrueSectNum) == E_DocStructStyle.DSS_TreatAsTrueSectNum) + { + ItemInfo sec = itemInfo.MyActiveSection; + while (sec != null && sec.IsSection) + { + SectionConfig sc = sec.MyConfig as SectionConfig; + if (sc != null && sc.SubSection_AutoIndent != "N") retval++; + sec = sec.MyParent as SectionInfo; + } + } + return retval; + } public void AdjustWidth(ItemInfo itemInfo, int maxRNO, FormatInfo formatInfo, vlnTab myTab) { float tabWidth = (myTab == null) ? 0 : myTab.Width; @@ -1463,7 +1552,38 @@ namespace Volian.Print.Library } else if (itemInfo.IsHigh) { - Width = _WidthAdjust + ToInt(formatInfo.MyStepSectionLayoutData.WidSTablePrint, maxRNO); + float CheckOffAdj = 0; + if (itemInfo.MyDocStyle.UseCheckOffs) + { + CheckOffAdj = -(float)formatInfo.PlantFormat.FormatData.ProcData.CheckOffData.CheckOffAdjustment; + if (!HasCheckOffHeading(itemInfo, formatInfo)) + CheckOffAdj += (float)(9 * 7.2); // 9 is the size of the SIGNOFF adjustment + } + float adjwidth = CheckOffAdj; + SectData sd = formatInfo.PlantFormat.FormatData.SectData; + if (sd.StepSectionData.StepSectionLayoutData.TieTabToLevel && sd.UseMetaSections) + { + if (itemInfo.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.StepSectionLayoutData.ShowSectionTitles + && !itemInfo.MyDocStyle.CancelSectTitle + && !(itemInfo.MyDocStyle.SpecialStepsFoldout && itemInfo.MyDocStyle.UseColSByLevel)) + { + int indxLevel = itemInfo.PrintLevel + itemInfo.CurrentSectionLevel(); + adjwidth += formatInfo.PlantFormat.FormatData.SectData.MetaSectionList[indxLevel % formatInfo.PlantFormat.FormatData.SectData.MetaSectionList.Count].WidSAdjByLevel ?? 0; ; + float colsbylevel = (float)formatInfo.PlantFormat.FormatData.SectData.MetaSectionList[indxLevel % formatInfo.PlantFormat.FormatData.SectData.MetaSectionList.Count].ColSByLevel; + float seclvlindent = colsbylevel - (float)formatInfo.PlantFormat.FormatData.SectData.StepSectionData.StepSectionLayoutData.ColS; + adjwidth -= seclvlindent; + adjwidth -= AdjustForSectionLevelTab(); + } + } + else + { + if (formatInfo.PlantFormat.FormatData.SectData.MetaSectionList.Count > 0) + adjwidth += (float)formatInfo.PlantFormat.FormatData.SectData.MetaSectionList[itemInfo.PrintLevel % formatInfo.PlantFormat.FormatData.SectData.MetaSectionList.Count].ColSByLevel; + } + + Width = ToInt(formatInfo.MyStepSectionLayoutData.WidSTablePrint, maxRNO); + Width += _WidthAdjust; + Width += adjwidth; } else if (itemInfo.IsCaution || itemInfo.IsNote) { @@ -1498,9 +1618,42 @@ namespace Volian.Print.Library } else { - Width = MyParent.Width - tabWidth + (myTab == null ? 0 : myTab.TabAlign); + float adjwidth = 0; + Width = adjwidth + MyParent.Width - tabWidth + (myTab == null ? 0 : myTab.TabAlign); } } + + private float AdjustForSectionLevelTab() + { + string sectTab = MyItemInfo.ActiveSection.MyTab.CleanText.TrimEnd(); + if (sectTab.EndsWith(".0")) return 0; + string myTab = MyItemInfo.MyTab.CleanText; + // -1 below code, +1 for '.' and -2 for standard wid of tab + // standard wid of this tab is 2 (ex: '1.') + // so adjust width if longer than normal + return (float)(sectTab.Length - 1) * 72/(float)MyItemInfo.FormatStepData.Font.CPI; + } + private bool HasCheckOffHeading(ItemInfo itemInfo, FormatInfo formatInfo) + { + if (formatInfo.PlantFormat.FormatData.ProcData.CheckOffData.CheckOffHeaderList.Count != 0) + { + // does this section have a check off heading? + SectionConfig sc = itemInfo.MyActiveSection.MyConfig as SectionConfig; + if (sc != null && sc.Section_CheckoffHeaderSelection > 0) return true; + } + return false; + } + private bool UseCheckOffsDocStyle(int oldToNew, FormatInfo formatInfo) + { + int bit, retval=0; + int mask=1; + + for(bit=0; bit < 32; bit++){ + if ((oldToNew & mask) != 0 && ((int)formatInfo.PlantFormat.FormatData.ProcData.CheckOffData.UseCheckOffsIn & mask) !=0) retval = 1; + mask <<= 1; + } + return retval > 0; + } } ///