From 37fb880794bba883868cfb9a0c9e7764cbf74f8e Mon Sep 17 00:00:00 2001 From: John Date: Mon, 8 Oct 2018 15:30:05 +0000 Subject: [PATCH] C2018-003 corrected use of MyActiveSection vs ActiveSection and added NULL checks --- .../Extension/DocumentExt.cs | 10 +- .../VEPROMS.CSLA.Library/Extension/ItemExt.cs | 7 +- PROMS/Volian.Controls.Library/vlnTreeView.cs | 2 +- PROMS/Volian.Print.Library/PDFReport.cs | 8 +- PROMS/Volian.Print.Library/Pagination.cs | 11 +- PROMS/Volian.Print.Library/PromsPrinter.cs | 4 +- PROMS/Volian.Print.Library/vlnParagraph.cs | 116 ++++++++++-------- 7 files changed, 85 insertions(+), 73 deletions(-) diff --git a/PROMS/VEPROMS.CSLA.Library/Extension/DocumentExt.cs b/PROMS/VEPROMS.CSLA.Library/Extension/DocumentExt.cs index d066560e..d2f126d1 100644 --- a/PROMS/VEPROMS.CSLA.Library/Extension/DocumentExt.cs +++ b/PROMS/VEPROMS.CSLA.Library/Extension/DocumentExt.cs @@ -776,7 +776,7 @@ namespace VEPROMS.CSLA.Library public static string ToPDFReplaceROs(DocumentInfo doc, List roids, ItemInfo sect, VolianStatusChange statusChange) { //ItemInfo sect = doc.DocumentEntries[0].MyContent.ContentItems[0]; - if (Volian.Base.Library.BaselineMetaFile.IsOpen && Volian.Base.Library.BaselineMetaFile.IncludeWordSecText) Volian.Base.Library.BaselineMetaFile.WriteLine("WrdSec SecNum=\"{0}\" SecTitle=\"{1}\" Itemid={2}", sect.MyActiveSection.DisplayNumber, sect.MyActiveSection.DisplayText, sect.ItemID); + if (Volian.Base.Library.BaselineMetaFile.IsOpen && Volian.Base.Library.BaselineMetaFile.IncludeWordSecText) Volian.Base.Library.BaselineMetaFile.WriteLine("WrdSec SecNum=\"{0}\" SecTitle=\"{1}\" Itemid={2}", sect.ActiveSection.DisplayNumber, sect.ActiveSection.DisplayText, sect.ItemID); // C2018-003 fixed use of getting the active section return ToPDFReplaceROs(sect, false, roids, statusChange); } private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); @@ -797,7 +797,7 @@ namespace VEPROMS.CSLA.Library ROFSTLookup lookup = null; string igPrefix = null; string spPrefix = null; - bool convertCaretToDeltaSymbol = sect.MyActiveSection.ActiveFormat.PlantFormat.FormatData.SectData.ConvertCaretToDelta; + bool convertCaretToDeltaSymbol = (sect.ActiveSection != null) ? sect.ActiveSection.ActiveFormat.PlantFormat.FormatData.SectData.ConvertCaretToDelta : false; // C2018-003 fixed use of getting the active section if (dvi.DocVersionAssociationCount > 0) { hasRos = true; @@ -1038,7 +1038,8 @@ namespace VEPROMS.CSLA.Library // An X/Y Plot RO type might have text preceding the Plot Commands int pstart = val.IndexOf("< 0) + if (MyPageHelper.DidFirstPageDocStyle && MyItemInfo.ActiveSection != null && (MyItemInfo.ActiveSection.MyDocStyle.StructureStyle.Where & E_DocStyleUse.UseOnAllButFirstPage) > 0)// C2018-003 fixed use of getting the active section yPageSizeNextPage = GetYPageSizeUseOnAllButFirstPage(); if (KeepStepsOnPage @@ -1038,7 +1038,8 @@ namespace Volian.Print.Library // Console.WriteLine("{0}\t{1}", MyItemInfo.ItemID, paraBreak); // Console.WriteLine("Here"); //} - if (paraBreak.MyItemInfo.IsStep && ((paraBreak.MyItemInfo.MyActiveSection.MyDocStyle.StructureStyle.Style & E_DocStructStyle.DSS_PageListSpBckgrnd) == E_DocStructStyle.DSS_PageListSpBckgrnd) && + // C2018-003 fixed use of getting the active section + if (paraBreak.MyItemInfo.IsStep && paraBreak.MyItemInfo.ActiveSection != null && ((paraBreak.MyItemInfo.ActiveSection.MyDocStyle.StructureStyle.Style & E_DocStructStyle.DSS_PageListSpBckgrnd) == E_DocStructStyle.DSS_PageListSpBckgrnd) && paraBreak.MyItemInfo.FormatStepData != null && paraBreak.MyItemInfo.MyParent.MyPrevious != null && paraBreak.MyItemInfo.MyParent.IsStep && paraBreak.MyItemInfo.MyParent.MyPrevious.FormatStepData.Type == "TitleWithTextBelow") { if (lastBreak != null && lastBreak != paraBreak.MyParent) paraBreak = paraBreak.MyParent; diff --git a/PROMS/Volian.Print.Library/PromsPrinter.cs b/PROMS/Volian.Print.Library/PromsPrinter.cs index c8b9c0b3..b0062e40 100644 --- a/PROMS/Volian.Print.Library/PromsPrinter.cs +++ b/PROMS/Volian.Print.Library/PromsPrinter.cs @@ -2099,8 +2099,8 @@ namespace Volian.Print.Library supInfoGroups = new List>(); foreach (vlnParagraph pg in vlnParagraph.ChildrenBelow) { - SectionInfo supInfoSect = pg.MyItemInfo.MyActiveSection as SectionInfo; - if (supInfoSect.StepSectPageBreaksForSupInfo != null && supInfoSect.StepSectPageBreaksForSupInfo.Contains(pg.MyItemInfo.ItemID)) + SectionInfo supInfoSect = (pg.MyItemInfo.ActiveSection != null) ? pg.MyItemInfo.ActiveSection as SectionInfo : null; + if (supInfoSect != null && supInfoSect.StepSectPageBreaksForSupInfo != null && supInfoSect.StepSectPageBreaksForSupInfo.Contains(pg.MyItemInfo.ItemID)) // C2018-003 fixed use of getting the active section supInfoGroups.Add(new List()); // add a grouping since a page break exists if (supInfoGroups.Count == 0) { diff --git a/PROMS/Volian.Print.Library/vlnParagraph.cs b/PROMS/Volian.Print.Library/vlnParagraph.cs index 782636f2..180163d8 100644 --- a/PROMS/Volian.Print.Library/vlnParagraph.cs +++ b/PROMS/Volian.Print.Library/vlnParagraph.cs @@ -1433,10 +1433,11 @@ namespace Volian.Print.Library float _PointsPerPage = 792; // if this document style has another style that is for pages other than first, we need to // reset the document style off of this section AND reset docstyle values used. - if ((MyItemInfo.MyActiveSection.MyDocStyle.StructureStyle.Where & E_DocStyleUse.UseOnFirstPage) > 0) + // C2018-003 fixed use of getting the active section + if (MyItemInfo.ActiveSection != null && (MyItemInfo.ActiveSection.MyDocStyle.StructureStyle.Where & E_DocStyleUse.UseOnFirstPage) > 0) { - ItemInfo ii = (ItemInfo)MyItemInfo.MyActiveSection; - int indx = (int)MyItemInfo.MyActiveSection.MyDocStyle.IndexOtherThanFirstPage; + ItemInfo ii = (ItemInfo)MyItemInfo.ActiveSection; + int indx = (int)MyItemInfo.ActiveSection.MyDocStyle.IndexOtherThanFirstPage; bool reassignedDocStyle = false; // C2018-004 create meta file for baseline compares foreach (DocStyle ds in ii.ActiveFormat.PlantFormat.DocStyles.DocStyleList) { @@ -1444,8 +1445,8 @@ namespace Volian.Print.Library { // C2018-004 create meta file for baseline compares Volian.Base.Library.BaselineMetaFile.WriteLine("Reset DocStyle to \"{0}\"",ds.Name); - MyItemInfo.MyActiveSection.MyDocStyle = ds; - MyPageHelper.MySection = MyItemInfo.MyActiveSection as SectionInfo; + MyItemInfo.ActiveSection.MyDocStyle = ds; + MyPageHelper.MySection = MyItemInfo.ActiveSection as SectionInfo; MyPageHelper.MySection.MyDocStyle = ds; //MyPageHelper.ResetSvg(); this is done when MyPageHelper.MySection is assigned - no need to do again. reassignedDocStyle = true; // C2018-004 create meta file for baseline compares @@ -1456,18 +1457,18 @@ namespace Volian.Print.Library if (DebugPagination.IsOpen) DebugPagination.WriteLine("ResetDocStyleAndValues"); if (BaselineMetaFile.IsOpen) BaselineMetaFile.WriteLine("!! ResetDocStyleAndValues"); //C2018-015 add debug pagination to meta file if (!reassignedDocStyle) // C2018-004 create meta file for baseline compares - MyPageHelper.MySection = (SectionInfo)MyItemInfo.MyActiveSection; - yTopMargin = _PointsPerPage - (float)MyItemInfo.MyActiveSection.MyDocStyle.Layout.TopMargin; - yBottomMargin = Math.Max(0, yTopMargin - (float)MyItemInfo.MyActiveSection.MyDocStyle.Layout.PageLength); + MyPageHelper.MySection = (SectionInfo)MyItemInfo.ActiveSection; + yTopMargin = _PointsPerPage - (float)MyItemInfo.ActiveSection.MyDocStyle.Layout.TopMargin; + yBottomMargin = Math.Max(0, yTopMargin - (float)MyItemInfo.ActiveSection.MyDocStyle.Layout.PageLength); } else if (MyPageHelper.PrintedSectionPage > 0) { MyPageHelper.ResetSvg(); - if ((MyItemInfo.MyActiveSection.MyDocStyle.StructureStyle.Style & E_DocStructStyle.DSS_PrintSectOnFirst) == E_DocStructStyle.DSS_PrintSectOnFirst) + if (MyItemInfo.ActiveSection != null && (MyItemInfo.ActiveSection.MyDocStyle.StructureStyle.Style & E_DocStructStyle.DSS_PrintSectOnFirst) == E_DocStructStyle.DSS_PrintSectOnFirst) { - yTopMargin = _PointsPerPage - (float)MyItemInfo.MyActiveSection.MyDocStyle.Layout.TopMargin + MyPageHelper.PrintedSectionPage; + yTopMargin = _PointsPerPage - (float)MyItemInfo.ActiveSection.MyDocStyle.Layout.TopMargin + MyPageHelper.PrintedSectionPage; MyPageHelper.YTopMargin = yTopMargin; - yBottomMargin = Math.Max(0, _PointsPerPage - (float)MyItemInfo.MyActiveSection.MyDocStyle.Layout.TopMargin - (float)MyItemInfo.MyActiveSection.MyDocStyle.Layout.PageLength); + yBottomMargin = Math.Max(0, _PointsPerPage - (float)MyItemInfo.ActiveSection.MyDocStyle.Layout.TopMargin - (float)MyItemInfo.ActiveSection.MyDocStyle.Layout.PageLength); } } @@ -1636,13 +1637,16 @@ namespace Volian.Print.Library // If SAMG facing page print & doing first pass to generate page break list of supplemental info and // there was a page break in the step section, but not an associated supinfo item, do the page break when the // next supinfo item is found: - SectionInfo supInfoSect = MyItemInfo.MyActiveSection as SectionInfo; + SectionInfo supInfoSect = MyItemInfo.ActiveSection as SectionInfo; // C2018-003 fixed use of getting the active section if (MyPromsPrinter.SupInfoPrintType == E_SupInfoPrintType.DoPageBreaks && MyPromsPrinter.NeedSupInfoBreak && MyItemInfo.SupInfos != null && MyItemInfo.SupInfos.Count > 0) { // if this has a caution/note with supinfo, that is id that needs to go in pagination list, unless it is in there. int aboveSupinfoId = ChildrenAboveHaveSupInfo(); - if (supInfoSect.StepSectPageBreaksForSupInfo.Contains(aboveSupinfoId)) aboveSupinfoId = -1; - supInfoSect.StepSectPageBreaksForSupInfo.Add(aboveSupinfoId != -1 ? aboveSupinfoId : MyItemInfo.SupInfos[0].ItemID); + if (supInfoSect != null) + { + if (supInfoSect.StepSectPageBreaksForSupInfo.Contains(aboveSupinfoId)) aboveSupinfoId = -1; + supInfoSect.StepSectPageBreaksForSupInfo.Add(aboveSupinfoId != -1 ? aboveSupinfoId : MyItemInfo.SupInfos[0].ItemID); + } MyPromsPrinter.NeedSupInfoBreak = false; } bool itemIsPrinted = false; @@ -1693,12 +1697,12 @@ namespace Volian.Print.Library { if (sec.IsStepSection) { - if (sec.ItemID == MyItemInfo.MyActiveSection.ItemID) break; + if (MyItemInfo.ActiveSection != null && sec.ItemID == MyItemInfo.ActiveSection.ItemID) break; // C2018-003 fixed use of getting the active section firstSec = false; break; } } - notFirstOrFirstHasSupInfo = !firstSec || (MyItemInfo.ActiveSection as SectionInfo).HasSupInfoSteps; + notFirstOrFirstHasSupInfo = !firstSec || (MyItemInfo.ActiveSection != null && (MyItemInfo.ActiveSection as SectionInfo).HasSupInfoSteps); // C2018-003 fixed use of getting the active section if (notFirstOrFirstHasSupInfo && ((MyItemInfo.IsHigh && MyItemInfo.MyPrevious == null && !titlePrinted) || (MyItemInfo.IsStepSection && titlePrinted)) && !MyItemInfo.IsInSupInfo && (MyItemInfo.MyProcedure as ProcedureInfo).ProcHasSupInfoData) { // If there is supplemental information to be printed on the facing page, then get the id that has supinfo @@ -1736,10 +1740,10 @@ namespace Volian.Print.Library { // page break here, determine if there is caution/note above where the page break actually needs to go: int aboveSupinfoId = ChildrenAboveHaveSupInfo(); - if (MyItemInfo.SupInfos != null && MyItemInfo.SupInfos.Count > 0 && aboveSupinfoId > 0) supInfoSect.StepSectPageBreaksForSupInfo.Add(aboveSupinfoId); - else if (MyItemInfo.SupInfos != null && MyItemInfo.SupInfos.Count > 0) supInfoSect.StepSectPageBreaksForSupInfo.Add(MyItemInfo.SupInfos[0].ItemID); + if (supInfoSect!=null && MyItemInfo.SupInfos != null && MyItemInfo.SupInfos.Count > 0 && aboveSupinfoId > 0) supInfoSect.StepSectPageBreaksForSupInfo.Add(aboveSupinfoId); + else if (supInfoSect != null && MyItemInfo.SupInfos != null && MyItemInfo.SupInfos.Count > 0) supInfoSect.StepSectPageBreaksForSupInfo.Add(MyItemInfo.SupInfos[0].ItemID); else MyPromsPrinter.NeedSupInfoBreak = true; - supInfoSect.StepSectPageBreaks.Add(MyItemInfo.ItemID); + if (supInfoSect!=null) supInfoSect.StepSectPageBreaks.Add(MyItemInfo.ItemID); } YTopMost = OutputOtherPageSteps(cb, YTopMost, yPageStart, yTopMargin, yBottomMargin); docstyle = MyItemInfo.MyDocStyle; @@ -1751,8 +1755,8 @@ namespace Volian.Print.Library if (MyItemInfo.IsSection && MyParent != null && MyParent.MyItemInfo.IsSection && (MyItemInfo as SectionInfo).IsSeparatePagination()) { RefreshDocStyle(); - yTopMargin = 792 - (float)MyItemInfo.MyActiveSection.MyDocStyle.Layout.TopMargin; - yBottomMargin = Math.Max(0, yTopMargin - (float)MyItemInfo.MyActiveSection.MyDocStyle.Layout.PageLength); + yTopMargin = 792 - (float)MyItemInfo.ActiveSection.MyDocStyle.Layout.TopMargin; // C2018-003 fixed use of getting the active section + yBottomMargin = Math.Max(0, yTopMargin - (float)MyItemInfo.ActiveSection.MyDocStyle.Layout.PageLength); // C2018-003 fixed use of getting the active section yPageStart = yTopMargin; } else if (MyItemInfo.IsSection || (MyItemInfo.IsHigh && MyItemInfo.MyPrevious != null)) //do not reset for 1st step @@ -1830,9 +1834,9 @@ namespace Volian.Print.Library case 2: // Break within a Step' if (MyPromsPrinter.SupInfoPrintType == E_SupInfoPrintType.DoPageBreaks) { - if (MyItemInfo.SupInfos != null && MyItemInfo.SupInfos.Count > 0) supInfoSect.StepSectPageBreaksForSupInfo.Add(MyItemInfo.SupInfos[0].ItemID); + if (supInfoSect!=null&& MyItemInfo.SupInfos != null && MyItemInfo.SupInfos.Count > 0) supInfoSect.StepSectPageBreaksForSupInfo.Add(MyItemInfo.SupInfos[0].ItemID); else MyPromsPrinter.NeedSupInfoBreak = true; - supInfoSect.StepSectPageBreaks.Add(MyItemInfo.ItemID); + if (supInfoSect!=null) supInfoSect.StepSectPageBreaks.Add(MyItemInfo.ItemID); } YTopMost = OutputOtherPageSteps(cb, YTopMost, yPageStart, yTopMargin, yBottomMargin); docstyle = MyItemInfo.MyDocStyle; @@ -1865,7 +1869,7 @@ namespace Volian.Print.Library if (MyPageHelper.NotesToFootNotes != null && MyPageHelper.NotesToFootNotes.Count > 0) MyPageHelper.NotesToFootNotesYoffset = CalculateYLocation(yLocation, yTopMargin); DoBottomContinueMsg(cb, yBottomMargin, yLocation, docstyle, doThreeContinues); MyPromsPrinter.NewPage(); - if (MyItemInfo.IsStep && ((MyItemInfo.MyActiveSection.MyDocStyle.StructureStyle.Style & E_DocStructStyle.DSS_PageListSpBckgrnd) == E_DocStructStyle.DSS_PageListSpBckgrnd)) + if (MyItemInfo.IsStep && (MyItemInfo.ActiveSection != null && ((MyItemInfo.ActiveSection.MyDocStyle.StructureStyle.Style & E_DocStructStyle.DSS_PageListSpBckgrnd) == E_DocStructStyle.DSS_PageListSpBckgrnd))) // C2018-003 fixed use of getting the active section { // check if parent (can be HLS, Caution or Note) has the UseOldTemplate. If so, // flag that a continue message should be printed as part of a pagelist header (if pagelist @@ -2017,9 +2021,9 @@ namespace Volian.Print.Library case 3: // Break on High Level Step (SevenLinesPerInch) if (MyPromsPrinter.SupInfoPrintType == E_SupInfoPrintType.DoPageBreaks) { - if (MyItemInfo.SupInfos != null && MyItemInfo.SupInfos.Count > 0) supInfoSect.StepSectPageBreaksForSupInfo.Add(MyItemInfo.SupInfos[0].ItemID); + if (supInfoSect!=null && MyItemInfo.SupInfos != null && MyItemInfo.SupInfos.Count > 0) supInfoSect.StepSectPageBreaksForSupInfo.Add(MyItemInfo.SupInfos[0].ItemID); else MyPromsPrinter.NeedSupInfoBreak = true; - supInfoSect.StepSectPageBreaks.Add(MyItemInfo.ItemID); + if(supInfoSect!=null) supInfoSect.StepSectPageBreaks.Add(MyItemInfo.ItemID); } if (!firstHighLevelStep || (MyPromsPrinter.SupInfoPrintType == E_SupInfoPrintType.Merge && !MyPageHelper.CreatingSupInfoPage)) // B2017-229: Added supinfo print check to run facing page logic { @@ -2090,7 +2094,7 @@ namespace Volian.Print.Library if (doSectionTitleContinued) { vlnParagraph sectContPara; - string contMsg = MyItemInfo.MyActiveSection.MyDocStyle.Continue.SectionTitle.AppendToTitle; + string contMsg = (MyItemInfo.ActiveSection != null) ? MyItemInfo.ActiveSection.MyDocStyle.Continue.SectionTitle.AppendToTitle : ""; // C2018-003 fixed use of getting the active section // 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) @@ -2153,8 +2157,11 @@ namespace Volian.Print.Library { // if this has a caution/note with supinfo, that is id that needs to go in pagination list, unless it is in there. int aboveSupinfoId = ChildrenAboveHaveSupInfo(); - if (supInfoSect.StepSectPageBreaksForSupInfo.Contains(aboveSupinfoId)) aboveSupinfoId = -1; - supInfoSect.StepSectPageBreaksForSupInfo.Add(MyItemInfo.SupInfos[0].ItemID); + if (supInfoSect != null) + { + if (supInfoSect.StepSectPageBreaksForSupInfo.Contains(aboveSupinfoId)) aboveSupinfoId = -1; + supInfoSect.StepSectPageBreaksForSupInfo.Add(MyItemInfo.SupInfos[0].ItemID); + } MyPromsPrinter.NeedSupInfoBreak = false; } yPageStart = ChildrenLeft.ToPdf(cb, yPageStart, ref yTopMargin, ref yBottomMargin); @@ -2209,13 +2216,13 @@ namespace Volian.Print.Library // if the EndForSingle format flag is set to false, then we do not print an End message if the section // is a single column section. //bool _skipEndMessage = MyPageHelper.MySection.SectionConfig.Section_ColumnMode == SectionConfig.SectionColumnMode.One && !MyItemInfo.ActiveFormat.MyStepSectionLayoutData.EndForSingle; - SectionInfo si = MyItemInfo.MyActiveSection as SectionInfo; + SectionInfo si = MyItemInfo.ActiveSection as SectionInfo; // C2018-003 fixed use of getting the active section // B2017-201 if si is null we need to get it via the ItemID if (si == null) - si = SectionInfo.Get(MyItemInfo.MyActiveSection.ItemID); //ActiveSection as SectionInfo; - bool _skipEndMessage = si.SectionConfig.Section_ColumnMode == SectionConfig.SectionColumnMode.One && !MyItemInfo.ActiveFormat.MyStepSectionLayoutData.EndForSingle; + si = SectionInfo.Get(MyItemInfo.MyActiveSection.ItemID); // MyActiveSection does not try to resolve anything - ActiveSection is call above and will resolve and set MyActiveSection + bool _skipEndMessage = (si == null ||si.SectionConfig.Section_ColumnMode == SectionConfig.SectionColumnMode.One) && !MyItemInfo.ActiveFormat.MyStepSectionLayoutData.EndForSingle; bool _lastSect = true; - if (si.MyActiveParent.IsSection) // is this meta/subsection. Only put end message out on last section + if (si != null && si.MyActiveParent.IsSection) // is this meta/subsection. Only put end message out on last section { ItemInfo mysect = si as ItemInfo; if (mysect.NextItem != null && !docstyle.End.EndMessageOnEachSubSection) _lastSect = false; @@ -2298,8 +2305,8 @@ namespace Volian.Print.Library if (MyItemInfo.IsSection) { // see if the section title is printed. - SectionConfig sch = MyItemInfo.ActiveSection.MyConfig as SectionConfig; - printedMySectTitle = (sch == null || sch.Section_PrintHdr == "Y") || !(MyItemInfo.MyActiveSection as SectionInfo).HasSupInfoSteps; + SectionConfig sch = (MyItemInfo.ActiveSection != null) ? MyItemInfo.ActiveSection.MyConfig as SectionConfig : null; // C2018-003 fixed use of getting the active section + printedMySectTitle = (sch == null || sch.Section_PrintHdr == "Y") || !(MyItemInfo.ActiveSection as SectionInfo).HasSupInfoSteps; printedMySectTitle &= (ShowSectionTitles && !MyItemInfo.MyDocStyle.CancelSectTitle); } return printedMySectTitle; @@ -2830,10 +2837,10 @@ namespace Volian.Print.Library // the document style) if (MyPageHelper.PrintedSectionPage > 0) { - if ((MyItemInfo.MyActiveSection.MyDocStyle.StructureStyle.Style & E_DocStructStyle.DSS_PrintSectOnFirst) == E_DocStructStyle.DSS_PrintSectOnFirst) + if (MyItemInfo.ActiveSection != null && (MyItemInfo.ActiveSection.MyDocStyle.StructureStyle.Style & E_DocStructStyle.DSS_PrintSectOnFirst) == E_DocStructStyle.DSS_PrintSectOnFirst) // C2018-003 fixed use of getting the active section { - float localYTopMargin = 792 - (float)MyItemInfo.MyActiveSection.MyDocStyle.Layout.TopMargin; - yBtmMarginForMsg = Math.Max(0, localYTopMargin - (float)MyItemInfo.MyActiveSection.MyDocStyle.Layout.PageLength); + float localYTopMargin = 792 - (float)MyItemInfo.ActiveSection.MyDocStyle.Layout.TopMargin; + yBtmMarginForMsg = Math.Max(0, localYTopMargin - (float)MyItemInfo.ActiveSection.MyDocStyle.Layout.PageLength); } } // include space for phone list when determining bottom continue message location @@ -3539,7 +3546,7 @@ namespace Volian.Print.Library AdjustXOffsetForTab(itemInfo, maxRNO, formatInfo, mytab, xMetaAdj); // Used in Ginna's Attachment format. // if the Note/Caution is off of a sub-step, then adjust the width so that the Caution/Note text box does not extend past the HLS text box - if (itemInfo.IsCautionOrNotePart && maxRNO == 0 && itemInfo.MyActiveSection.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.LimitCautionNoteWidthToHLS) + if (itemInfo.IsCautionOrNotePart && maxRNO == 0 && (itemInfo.ActiveSection != null && itemInfo.ActiveSection.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.LimitCautionNoteWidthToHLS)) // C2018-003 fixed use of getting the active section { float wMax = MyHighLevelParagraph.Width + MyHighLevelParagraph.XOffset - XOffset; if (wMax < Width && (Width + XOffset > MyItemInfo.MyDocStyle.Layout.PageWidth)) Width = wMax; @@ -3758,7 +3765,7 @@ namespace Volian.Print.Library if (!itemInfo.FormatStepData.SpaceDouble && itemInfo.MyParent.IsHigh) { // but it we are in single column mode, don't remove the blank line. (Wolf Creek Admin Instructions - wcn1) - if ((itemInfo.MyActiveSection as SectionInfo).SectionConfig.Section_ColumnMode != SectionConfig.SectionColumnMode.One) + if (itemInfo.ActiveSection != null && (itemInfo.ActiveSection as SectionInfo).SectionConfig.Section_ColumnMode != SectionConfig.SectionColumnMode.One) // C2018-003 fixed use of getting the active section yoff = YOffset = yoff - SixLinesPerInch; } else if (itemInfo.FormatStepData.NoSpaceMultipleRNOs) yoff = YOffset = yoff - SixLinesPerInch; @@ -4804,7 +4811,7 @@ namespace Volian.Print.Library if (MyPageHelper.PageListCheckOffHeader == null) return; VE_Font font = null; - ItemInfo mySectionInfo = itemInfo.MyActiveSection; + ItemInfo mySectionInfo = itemInfo.ActiveSection; // C2018-003 fixed use of getting the active section ItemInfo mySubSectionInfo = itemInfo; // If the passed in itemInfo is not a section, get it's parent section. This may be a subsection, so @@ -4818,7 +4825,7 @@ namespace Volian.Print.Library } } else - mySubSectionInfo = (mySectionInfo.Sections == null) ? null : mySectionInfo.Sections[0]; + mySubSectionInfo = (mySectionInfo == null || mySectionInfo.Sections == null) ? null : mySectionInfo.Sections[0]; if (mySectionInfo == mySubSectionInfo) mySubSectionInfo = null; @@ -4832,7 +4839,7 @@ namespace Volian.Print.Library // Get SectionInfos to access specific section config items... //SectionInfo si = SectionInfo.Get(mySectionInfo.ItemID); - SectionInfo si = mySectionInfo.GetSectionInfo(); + SectionInfo si = (mySectionInfo != null)? mySectionInfo.GetSectionInfo() : null; int sindx = si.CheckOffHeadingIndex(); //SectionInfo subi = mySubSectionInfo == null ? null : SectionInfo.Get(mySubSectionInfo.ItemID); SectionInfo subi = mySubSectionInfo == null ? null : mySubSectionInfo.GetSectionInfo(); @@ -4861,7 +4868,7 @@ namespace Volian.Print.Library } // grab the string from the format, depending on whether it should get it from the section or subsection. - string cohead = (mySubSectionInfo != null) ? mySubSectionInfo.SectionCheckOffHeader : mySectionInfo.SectionCheckOffHeader; + string cohead = (mySubSectionInfo != null) ? mySubSectionInfo.SectionCheckOffHeader : (mySectionInfo != null)? mySectionInfo.SectionCheckOffHeader : null; if (cohead == "" || cohead == null) return; // PageListCheckOffHeader is an svgtext - but really we only need the x/y location for this (pagelist support) @@ -4921,8 +4928,8 @@ namespace Volian.Print.Library float colR = float.Parse(formatInfo.MyStepSectionLayoutData.ColRTable.Split(",".ToCharArray())[itemInfo.ColumnMode]); float xLowerLimit = (aerTableOrFigure && hls1.PartsLeft != null && hls1.PartsLeft.Count > 0) ? hls1.PartsLeft[0].XOffset : hls1.XOffset; float xUpperLimit = 0; - float pageWidth = ((float)itemInfo.MyActiveSection.MyDocStyle.Layout.PageWidth); - float leftMargin = ((float)itemInfo.MyActiveSection.MyDocStyle.Layout.LeftMargin); //* (float)MyItemInfo.FormatStepData.Font.CPI / 12; + float pageWidth = ((float)itemInfo.ActiveSection.MyDocStyle.Layout.PageWidth); // C2018-003 fixed use of getting the active section + float leftMargin = ((float)itemInfo.ActiveSection.MyDocStyle.Layout.LeftMargin); // C2018-003 fixed use of getting the active section if (itemInfo.IsInRNO) // if in rno column, the upper limit is width of the page (right margin). Subtract off size of a character xUpperLimit = pageWidth - (72 / (float)MyItemInfo.FormatStepData.Font.CPI); @@ -5065,6 +5072,7 @@ namespace Volian.Print.Library List myMacros = itemInfo.MyMacros; if (myMacros != null) { + int colMode = (MyItemInfo.ActiveSection != null)? MyItemInfo.ActiveSection.ColumnMode : 0; // C2018-003 fixed use of getting the active section foreach (Macro myMacro in myMacros) { // if the format has the 'LocWithXOff' locate the macro along with the tab's offset. @@ -5073,7 +5081,7 @@ namespace Volian.Print.Library string tabText = mytab == null ? null : mytab.Text.Trim(" .".ToCharArray()); int tablen = (tabText == null) ? 0 : (tabText.Length <= 2) ? 0 : tabText.Length - 2; if (myMacro.LocWithXOff ?? false) x = mytab == null ? XOffset : ((float)mytab.XOffset + (tablen * (float)mytab.MyFont.CharsToTwips)); - if (MyItemInfo.MyActiveSection.ColumnMode == 0 && myMacro.SingleColMacroDef != null && myMacro.SingleColMacroDef.Length > 0) + if (colMode == 0 && myMacro.SingleColMacroDef != null && myMacro.SingleColMacroDef.Length > 0) { float macroXOffset = myMacro.MacroXOffSet ?? 0; float widthAdj = myMacro.SingleColWidthAdjust ?? 0; // set as negative number in format @@ -5680,7 +5688,7 @@ namespace Volian.Print.Library return; } else if (itemInfo.FormatStepData.UseOldTemplate && itemInfo.IsInTemplate() && - ((MyItemInfo.MyActiveSection.MyDocStyle.StructureStyle.Style & E_DocStructStyle.DSS_PageListSpBckgrnd) == E_DocStructStyle.DSS_PageListSpBckgrnd)) + (MyItemInfo.ActiveSection != null && (MyItemInfo.ActiveSection.MyDocStyle.StructureStyle.Style & E_DocStructStyle.DSS_PageListSpBckgrnd) == E_DocStructStyle.DSS_PageListSpBckgrnd)) // C2018-003 fixed use of getting the active section { if (myTab != null) myTab.XOffset = XOffset; XOffset += myTab.Width; @@ -6102,7 +6110,7 @@ namespace Volian.Print.Library } // for IP2 backgrounds, set widths appropriately for template items: - if (itemInfo.IsStep && ((itemInfo.MyActiveSection.MyDocStyle.StructureStyle.Style & E_DocStructStyle.DSS_PageListSpBckgrnd) == E_DocStructStyle.DSS_PageListSpBckgrnd)) + if (itemInfo.IsStep && (itemInfo.ActiveSection != null && (itemInfo.ActiveSection.MyDocStyle.StructureStyle.Style & E_DocStructStyle.DSS_PageListSpBckgrnd) == E_DocStructStyle.DSS_PageListSpBckgrnd)) // C2018-003 fixed use of getting the active section { if (itemInfo.FormatStepData.Type.ToUpper() == "TITLEWITHTEXTBELOW") { @@ -6116,7 +6124,7 @@ namespace Volian.Print.Library } if (widOvrd == 0 && itemInfo.MyParent.IsStep && (itemInfo.MyParent.FormatStepData.Type.ToUpper() == "TITLEWITHTEXTBELOW" || - (((itemInfo.MyActiveSection.MyDocStyle.StructureStyle.Style & E_DocStructStyle.DSS_PageListSpBckgrnd) == E_DocStructStyle.DSS_PageListSpBckgrnd) && + (((itemInfo.ActiveSection.MyDocStyle.StructureStyle.Style & E_DocStructStyle.DSS_PageListSpBckgrnd) == E_DocStructStyle.DSS_PageListSpBckgrnd) && itemInfo.FormatStepData != null && MyParent.MyItemInfo.MyPrevious != null && MyParent.MyItemInfo.MyPrevious.FormatStepData.Type == "TitleWithTextBelow"))) { Width = MyParent.MyParent.Width + (MyParent.MyParent.MyTab != null ? MyParent.MyParent.MyTab.Width : 0); @@ -6127,7 +6135,7 @@ namespace Volian.Print.Library //widOvrd = itemInfo.FormatStepData == null ? null : itemInfo.FormatStepData.WidthOverride; // Don't adjust the RNO width if in single column mode: - if (itemInfo.IsRNOPart && itemInfo.MyParent.IsHigh && itemInfo.MyActiveSection.ColumnMode != 0 && itemInfo.ActiveFormat.MyStepSectionLayoutData.RNOWidthAlt != null) + if (itemInfo.IsRNOPart && itemInfo.MyParent.IsHigh && itemInfo.ActiveSection != null && itemInfo.ActiveSection.ColumnMode != 0 && itemInfo.ActiveFormat.MyStepSectionLayoutData.RNOWidthAlt != null) // C2018-003 fixed use of getting the active section { string[] splitRNOWidthAlt = itemInfo.ActiveFormat.MyStepSectionLayoutData.RNOWidthAlt.Split(','); float ovrd = (itemInfo.RNOLevel < splitRNOWidthAlt.Length) ? float.Parse(splitRNOWidthAlt[itemInfo.RNOLevel]) : 0; @@ -6230,7 +6238,7 @@ namespace Volian.Print.Library // B2016-269: if caution/note & not boxed, with tab adjust width based on xoffset of tab // so text doesn't print out of right border. // B2017-027: Added a check for column mode - we only want to do this if in single column mode - if (!MyItemInfo.MyParent.IsHigh && MyTab != null && MyTab.YOffset == YOffset && MyItemInfo.MyActiveSection.ColumnMode == 0) + if (!MyItemInfo.MyParent.IsHigh && MyTab != null && MyTab.YOffset == YOffset && MyItemInfo.ActiveSection != null && MyItemInfo.ActiveSection.ColumnMode == 0) // C2018-003 fixed use of getting the active section { // B2017-xxx if this is a caution/note off of a substep in the supinfo column, need to look up for its supinfo part, not // its HLS. @@ -6269,7 +6277,7 @@ namespace Volian.Print.Library // 72 points / inch - 7 inches (about width of page) Width = 72 * 7; } - else if (itemInfo.IsRNOPart && itemInfo.MyActiveSection.ColumnMode != 0 && itemInfo.ActiveFormat.MyStepSectionLayoutData.RNOWidthAltAll != null) + else if (itemInfo.IsRNOPart && itemInfo.ActiveSection != null && itemInfo.ActiveSection.ColumnMode != 0 && itemInfo.ActiveFormat.MyStepSectionLayoutData.RNOWidthAltAll != null) // C2018-003 fixed use of getting the active section { // This code was added for AEP. Other code that adjusted RNO widths was only adjusting the RNO widths // off of the HLS. AEP needed adjusting for all RNOs. @@ -6446,7 +6454,7 @@ namespace Volian.Print.Library if (formatInfo.PlantFormat.FormatData.ProcData.CheckOffData.CheckOffHeaderList.MaxIndex != 0) { // does this section have a check off heading? - SectionConfig sc = itemInfo.MyActiveSection.MyConfig as SectionConfig; + SectionConfig sc = (itemInfo.ActiveSection != null) ? itemInfo.MyActiveSection.MyConfig as SectionConfig : null; // C2018-003 fixed use of getting the active section if (sc != null && sc.Section_CheckoffHeaderSelection > 0) return true; } if (formatInfo.PlantFormat.FormatData.ProcData.CheckOffData.CheckOffHeaderInPagelist) return true;