From dd2d97ceb7368462811cece6f1cc9e00d8536a06 Mon Sep 17 00:00:00 2001 From: Kathy Date: Wed, 5 Feb 2014 13:47:52 +0000 Subject: [PATCH] Fixed B2013-160: printing with blank page option causes various problems when procedure has continuous sections and for sections after the procedure steps section Fixed B2014-023, null reference crash when printing some Farley procedures. Also WCN BCK formatting --- PROMS/Volian.Print.Library/PromsPrinter.cs | 22 +++++++++++----- PROMS/Volian.Print.Library/vlnParagraph.cs | 30 ++++++++++++++-------- 2 files changed, 34 insertions(+), 18 deletions(-) diff --git a/PROMS/Volian.Print.Library/PromsPrinter.cs b/PROMS/Volian.Print.Library/PromsPrinter.cs index 23257290..a90ec043 100644 --- a/PROMS/Volian.Print.Library/PromsPrinter.cs +++ b/PROMS/Volian.Print.Library/PromsPrinter.cs @@ -493,12 +493,16 @@ namespace Volian.Print.Library DoFoldoutPage(cb, "Beginning of Step Section", _TextLayer, _MyHelper, firstStep.FoldoutIndex(), InsertBlankPages); else if (!_MyHelper.CreatingFoldoutPage && _MyFoldoutReader.Count > 0 && InsertBlankPages) { - // only insert a blank page if this section does not have a foldout (but the procedure as a whole does) - // and the checkbox on the print dialog to add blank pages is checked - _MyHelper.OnBlankPage = true; - cb.PdfDocument.Add(new iTextSharp.text.Table(1)); - cb.PdfDocument.NewPage(); - //_MyLog.InfoFormat("NewPage Begin Step Sect blank {0}", cb.PdfWriter.CurrentPageNumber); + // if it is continuous pagination, don't do blank page - not sure if this is correct place for this: + if (mySection.SectionConfig.Section_Pagination == SectionConfig.SectionPagination.Separate) + { + // only insert a blank page if this section does not have a foldout (but the procedure as a whole does) + // and the checkbox on the print dialog to add blank pages is checked + _MyHelper.OnBlankPage = true; + cb.PdfDocument.Add(new iTextSharp.text.Table(1)); + cb.PdfDocument.NewPage(); + //_MyLog.InfoFormat("NewPage Begin Step Sect blank {0}", cb.PdfWriter.CurrentPageNumber); + } } } CreateStepPdf(mySection, cb); @@ -570,8 +574,12 @@ namespace Volian.Print.Library for (int ii = 0; ii < sectPageCount; ii++) { int pageNumber = 1 + ii; + bool didFoldout = false; if (((mySection.MyDocStyle.StructureStyle.Style ?? 0) & E_DocStructStyle.UseSectionFoldout) != 0) + { + didFoldout = true; DoFoldoutPage(cb, "Word Document", _TextLayer, _MyHelper, 0, false); + } if (readerWord != null) { bool doimport2 = true; @@ -588,7 +596,7 @@ namespace Volian.Print.Library OnStatusChanged("Read MSWord", PromsPrinterStatusType.ReadMSWord); if (doimport2) { - if (cb.PdfWriter.CurrentPageNumber > 1 && _MyFoldoutReader.Count > 0 && InsertBlankPages) + if (!didFoldout && cb.PdfWriter.CurrentPageNumber > 1 && _MyFoldoutReader.Count > 0 && InsertBlankPages) { // only insert a blank page if this section does not have a foldout (but the procedure as a whole does) // and the checkbox on the print dialog to add blank pages is checked diff --git a/PROMS/Volian.Print.Library/vlnParagraph.cs b/PROMS/Volian.Print.Library/vlnParagraph.cs index 3ea0334e..057dcade 100644 --- a/PROMS/Volian.Print.Library/vlnParagraph.cs +++ b/PROMS/Volian.Print.Library/vlnParagraph.cs @@ -194,8 +194,9 @@ namespace Volian.Print.Library } bxIndex = bxIndx; } - // Comanche peak Step Designator - if (childItemInfo.IsCaution2 && childItemInfo.SameRowAsParent) + // Comanche peak or WCN bck Step designator + if (childItemInfo.IsCaution2 && childItemInfo.SameRowAsParent || + childItemInfo.IsCaution1 && childItemInfo.SameRowAsParent) { // Save the Step Designator information _StepDesignator = childItemInfo.DisplayText; @@ -843,11 +844,15 @@ namespace Volian.Print.Library else if (PromsPrinter.MyFoldoutReader.Count > 0 && MyPageHelper.MyPromsPrinter.InsertBlankPages) { // insert a blank page if this step section had a foldout associated and the checkbox - // on the print dialog, to add blank pages, is checked - MyPageHelper.OnBlankPage = true; - cb.PdfDocument.Add(new iTextSharp.text.Table(1)); - cb.PdfDocument.NewPage(); - //_MyLog.InfoFormat("NewPage 10 blank {0}", cb.PdfWriter.CurrentPageNumber); + // on the print dialog, to add blank pages, is checked AND the page did NOT have a + // preceeding foldout. + if (MyItemInfo.FoldoutIndex() <= -1) + { + MyPageHelper.OnBlankPage = true; + cb.PdfDocument.Add(new iTextSharp.text.Table(1)); + cb.PdfDocument.NewPage(); + //_MyLog.InfoFormat("NewPage 10 blank {0}", cb.PdfWriter.CurrentPageNumber); + } } yPageStart = yTopMargin + YTopMost; DoCheckOffHeader(cb, MyItemInfo, yLocation, yTopMargin, yPageStart); @@ -1339,8 +1344,11 @@ namespace Volian.Print.Library } private bool IsBackgroundStep() { - if (MyItemInfo.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.WolfCreekBackgroundFormat && - (MyItemInfo.IsHigh || MyItemInfo.IsCaution || MyItemInfo.IsNote)) return true; + if (MyItemInfo.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.WolfCreekBackgroundFormat) + { + if (MyItemInfo.IsHigh || MyItemInfo.IsCaution || MyItemInfo.IsNote) return true; + if (MyItemInfo.MyParent != null && MyItemInfo.MyParent.IsStep && MyItemInfo.MyParent.FormatStepData.Type.ToUpper() == "TITLEWITHTEXTBELOW" && MyItemInfo.FormatStepData.Type.ToUpper() != "IMPLICITOR") return true; + } return false; } @@ -1498,7 +1506,7 @@ namespace Volian.Print.Library // if this is the High Level RNO step (MyTopRNO) and we are numbering the RNO, adjust the xoffset to start the tab // at the x location rather than starting the text at the x location: AdjustWidth(itemInfo, maxRNO, formatInfo, mytab); - bool adjustAgain = ((itemInfo.MyTab != null && itemInfo.MyTab.Position == 0)||itemInfo.MyPrevious.FormatStepData.TabData.IsTransition) ? true : false; + bool adjustAgain = ((itemInfo.MyTab != null && itemInfo.MyTab.Position == 0) || (itemInfo.MyPrevious != null && itemInfo.MyPrevious.FormatStepData != null && itemInfo.MyPrevious.FormatStepData.TabData.IsTransition)) ? true : false; if (!itemInfo.IsSection && itemInfo.FormatStepData.NumberHighLevel && itemInfo.IsRNOPart && (MyTopRNO == null || itemInfo.ItemID == MyTopRNO.MyItemInfo.ItemID)) { // adjust the x-offset of the RNO to include the tab. @@ -1671,7 +1679,7 @@ namespace Volian.Print.Library } // For background formats, HLS's or Caution or any Notes have tab on line and then text // on line below (with space in between) - if (IsBackgroundStep() && itemInfo.MyTab.AltPrintTab.Trim() != "") + if (IsBackgroundStep() && itemInfo.MyTab != null && itemInfo.MyTab.AltPrintTab != null && itemInfo.MyTab.AltPrintTab.Trim() != "") yoff = YOffset = yoff + (2 * SixLinesPerInch); float yForCheckoff = yoff; //0; - default checkoff row is same as FIRST line of text