From 15efb46dd31b10054aec2233b54dc1fed82aadb9 Mon Sep 17 00:00:00 2001 From: Kathy Date: Wed, 17 Jul 2013 13:09:04 +0000 Subject: [PATCH] NSPIFG support NSPIFG2 missing genmac NSP IFG improvements --- PROMS/Volian.Print.Library/Pagination.cs | 15 +++++++++-- PROMS/Volian.Print.Library/PromsPrinter.cs | 12 +++++++-- .../Volian.Print.Library/VlnSvgPageHelper.cs | 25 +++++++++++++------ PROMS/Volian.Print.Library/vlnParagraph.cs | 8 +++--- PROMS/fmtxml/AppendPlantSpecific.cs | 10 ++++++++ PROMS/fmtxml/FmtFileToXml.cs | 6 +++-- PROMS/fmtxml/Form1.cs | 3 +++ 7 files changed, 61 insertions(+), 18 deletions(-) diff --git a/PROMS/Volian.Print.Library/Pagination.cs b/PROMS/Volian.Print.Library/Pagination.cs index fbe8c587..293e74b5 100644 --- a/PROMS/Volian.Print.Library/Pagination.cs +++ b/PROMS/Volian.Print.Library/Pagination.cs @@ -42,6 +42,17 @@ namespace Volian.Print.Library // procedure in questions was VEWCNEMG\EMGAPP.PRC, ES-01, Step 8. bool ManualPageBreak = false; float yEndMsg = !MyItemInfo.IsSection && MyItemInfo.MyHLS.NextItem == null && (MyItemInfo.MyDocStyle.End.Message ?? "") != "" ? 2 * SixLinesPerInch : 0; + + // The following code is to fix a pagination issue in SHE. It was decided to not put it into development + // because some of the pagination logic may be redesigned. Without this fix, some pages had a page break + // before they should. I did not want to lose this code, in case at some point we want to revisit this. + // if doing an end message & we already are ending with a blank line, add one line for the end message + // otherwise, we need to add two lines, i.e. ((2 * SixLinesPerInch) - yEndsWithBlankLine) + // this change was necessary to fix a pagination problem in Shearon Harris, EOPs, User Guide, Attachment 2. + //float yEndsWithBlankLine = AdjustForBlankLines(); + //KBR debug: if (yEndsWithBlankLine != 0) Console.WriteLine("*** yEndsWithBlankLine = {0}", yEndsWithBlankLine); + //float yEndMsg = !MyItemInfo.IsSection && MyItemInfo.MyHLS.NextItem == null && (MyItemInfo.MyDocStyle.End.Message ?? "") != "" ? ((2 * SixLinesPerInch) - yEndsWithBlankLine) : 0; + float yWithinMargins = CalculateYLocation(yLocation, yTopMargin) - yBottomMargin; // -SixLinesPerInch; bool isFirstChild = MyItemInfo.MyPrevious == null; bool nearTheTop = (yWithinMargins < yPageSize) && (yWithinMargins > (yPageSize - 5 * SixLinesPerInch)); @@ -64,7 +75,7 @@ namespace Volian.Print.Library // Steps that have the smart template (the WCNCKL format for example), always include two children. if (MyItemInfo.IsHigh && MyItemInfo.FormatStepData.UseSmartTemplate && ChildrenBelow.Count > 1) firstChild = ChildrenBelow[1]; - if (firstChild != null && !firstChild.MyItemInfo.IsNumbered) // If not numbered get the last child + if (firstChild != null && firstChild.MyItemInfo != null && !firstChild.MyItemInfo.IsNumbered) // If not numbered get the last child firstChild = firstChild.MyParent.ChildrenBelow[firstChild.MyParent.ChildrenBelow.Count - 1]; float ySizeIncludingFirst = firstChild == null ? YSize : firstChild.YSize + (firstChild.YTopMost - YTopMost); bool KeepStepsOnPage = MyItemInfo.ActiveFormat.MyStepSectionLayoutData.KeepStepsOnPage; @@ -127,7 +138,7 @@ namespace Volian.Print.Library return 0; // Don't Paginate (page break) on a Step Section if it's first thing on page } if (!MyItemInfo.IsHigh) return 0; // Don't Paginate on a Substep level - MyPageHelper.HLSText = MyItemInfo.DisplayText; // save the High Level Step Text + //MyPageHelper.HLSText = MyItemInfo.DisplayText; // save the High Level Step Text //Console.WriteLine("{0} Paginate", MyPageHelper.HLSText); StepConfig sc1 = MyItemInfo.MyConfig as StepConfig; ManualPageBreak = MyPageHelper.OriginalPageBreak ? (sc1 == null ? false : sc1.Step_ManualPagebreak) : diff --git a/PROMS/Volian.Print.Library/PromsPrinter.cs b/PROMS/Volian.Print.Library/PromsPrinter.cs index c4caca3f..cebec712 100644 --- a/PROMS/Volian.Print.Library/PromsPrinter.cs +++ b/PROMS/Volian.Print.Library/PromsPrinter.cs @@ -369,6 +369,7 @@ namespace Volian.Print.Library OnStatusChanged(myProcedure.DisplayNumber, PromsPrinterStatusType.ProgressSetup, myProcedure.Sections.Count); int progress = 0; int finalMessageSectionID = GetFinalMessageSectionID(myProcedure, doingFoldout); + string LastFmtName = null; foreach (SectionInfo mySection in myProcedure.Sections) { if (((mySection.MyContent.Number.ToUpper() == "FOLDOUT" && myProcedure.ActiveFormat.PlantFormat.FormatData.PrintData.SectionLevelFoldouts) @@ -381,10 +382,15 @@ namespace Volian.Print.Library // Set up Helper for the particular Section if (_MyHelper == null) { + LastFmtName = mySection.ActiveFormat.Name; string hlsText = ""; + int hlsItemId = 0; if (mySection.IsStepSection && mySection.Steps.Count > 0) + { + hlsItemId = mySection.Steps[0].ItemID; hlsText = mySection.Steps[0].DisplayText; // save the High level step text for use in the page list - cb.PdfWriter.PageEvent = _MyHelper = new VlnSvgPageHelper(mySection, this, hlsText); + } + cb.PdfWriter.PageEvent = _MyHelper = new VlnSvgPageHelper(mySection, this, hlsText, hlsItemId); _MyHelper.AllowAllWatermarks = AllowAllWatermarks; _MyHelper.MyPdfWriter = cb.PdfWriter; _MyHelper.CreatingFoldoutPage = doingFoldout; @@ -425,7 +431,9 @@ namespace Volian.Print.Library //added by jcb to reset mygaps when changing a section. found old section gaps were carrying over to new section _MyHelper.MyGaps.Clear(); //Console.WriteLine("'{0}' PromsPrinter", mySection.DisplayText); - if (mySection.SectionConfig.Section_Pagination == SectionConfig.SectionPagination.Separate) + // if pagination is separate or we've changed the format, we have not done the first page + // (if this format has the useonfirst page docstyle flag) + if (LastFmtName != mySection.ActiveFormat.Name || mySection.SectionConfig.Section_Pagination == SectionConfig.SectionPagination.Separate) _MyHelper.DidFirstPageDocStyle = false; if (!mySection.IsStepSection) _MyHelper.PageBookmarks.Add((ItemInfo)mySection, ((mySection.DisplayNumber ?? "") == "" ? "" : mySection.DisplayNumber + " - ") + mySection.DisplayText, null); _MyHelper.MySection = mySection; diff --git a/PROMS/Volian.Print.Library/VlnSvgPageHelper.cs b/PROMS/Volian.Print.Library/VlnSvgPageHelper.cs index 1f161fa9..d3b57ea5 100644 --- a/PROMS/Volian.Print.Library/VlnSvgPageHelper.cs +++ b/PROMS/Volian.Print.Library/VlnSvgPageHelper.cs @@ -507,9 +507,11 @@ namespace Volian.Print.Library set { _MyPromsPrinter = value; } } private int _MyRomanPage = 1; - public VlnSvgPageHelper(VEPROMS.CSLA.Library.SectionInfo mySection,PromsPrinter myPromsPrinter,string hlsText) : base() + public VlnSvgPageHelper(VEPROMS.CSLA.Library.SectionInfo mySection, PromsPrinter myPromsPrinter, string hlsText, int hlsItemId) + : base() { HLSText = hlsText; + HasHLSTextId = hlsItemId; MySection = mySection; MyPromsPrinter = myPromsPrinter; } @@ -531,7 +533,7 @@ namespace Volian.Print.Library //} VEPROMS.CSLA.Library.FormatInfo activeFormat = mySection.ActiveFormat; VEPROMS.CSLA.Library.DocStyle docStyle = mySection.MyDocStyle; - Volian.Svg.Library.Svg mySvg = null; + Volian.Svg.Library.Svg mySvg = null; mySvg = SvgSerializer.StringDeserialize(BuildMyText(activeFormat)); mySvg.ViewBox.Height = 1100; mySvg.ViewBox.Width = 850; @@ -753,6 +755,8 @@ namespace Volian.Print.Library //float rowAdj = 0; // = 18; foreach (VEPROMS.CSLA.Library.PageItem pageItem in pageStyle.PageItems) { + if (pageItem.Token == null) continue; // can be null if token is dependent on PSI lookup! + DidHLSText = false; // reset to false for this group of tokens. //if (pageItem.Token.Contains("HLSTEXT")) // Console.WriteLine("{0} - PageList Token", pageItem.Token); @@ -866,11 +870,17 @@ namespace Volian.Print.Library } return deflt; } - private bool _HasHLSText = false; - public bool HasHLSText + private bool _DidHLSText = false; + public bool DidHLSText { - get { return _HasHLSText; } - set { _HasHLSText = value; } + get { return _DidHLSText; } + set { _DidHLSText = value; } + } + private int _HasHLSTextId = 0; + public int HasHLSTextId + { + get { return _HasHLSTextId; } + set { _HasHLSTextId = value; } } private string _HLSText = ""; public string HLSText @@ -1049,9 +1059,8 @@ namespace Volian.Print.Library PageListCheckOffHeader = PageItemToSvgText(pageItem, pageItem.Token, vf, section); break; case "{HLSTEXT}": - HasHLSText = true; + DidHLSText = true; plstr = plstr.Replace(token, HLSText); - Console.WriteLine("'{0}' pagelist", plstr); break; default: if (token.Contains(@"RO-")) diff --git a/PROMS/Volian.Print.Library/vlnParagraph.cs b/PROMS/Volian.Print.Library/vlnParagraph.cs index a689d355..81bded37 100644 --- a/PROMS/Volian.Print.Library/vlnParagraph.cs +++ b/PROMS/Volian.Print.Library/vlnParagraph.cs @@ -206,9 +206,9 @@ namespace Volian.Print.Library float yLocation = CalculateYOffset(yPageStart, yTopMargin); if (MyItemInfo.HasChangeBar && MyPageHelper.ChangeBarDefinition.MyChangeBarType != PrintChangeBar.Without) MyPageHelper.AddChangeBar(DoChangeBar(cb, MyItemInfo, MyPageHelper, XOffset, yLocation, MyPageHelper.MaxRNO, MyItemInfo.ActiveFormat), cbMess); float retval = yLocation; - bool doprint = true; - if (MyItemInfo.ItemID == 25045) - Console.WriteLine("jcb"); + // 'doprint' will always be true if not doing NSP's {HLSTEXT} token in page list. The following code is used to prevent + // printing the High level step, if the high level step is printed from the pagelist using {HLSTEXT} token. + bool doprint = !(MyPageHelper.DidHLSText && MyItemInfo.ItemID == MyPageHelper.HasHLSTextId); if (MyItemInfo.IsFigure) { yLocation -= (SixLinesPerInch * MyPageHelper.YMultiplier); @@ -674,7 +674,7 @@ namespace Volian.Print.Library case 1: // Break on High Level Step OutputOtherPageSteps(cb, YTopMost, yPageStart, yTopMargin, yBottomMargin); cb.PdfDocument.NewPage(); - if(MyItemInfo.IsHigh && MyItemInfo.MyPrevious != null) //do not reset for 1st step + if(MyItemInfo.IsSection || (MyItemInfo.IsHigh && MyItemInfo.MyPrevious != null)) //do not reset for 1st step ResetDocStyleAndValues(ref yTopMargin, ref yBottomMargin); DebugText.WriteLine("Paginate1"); if (MyItemInfo.IsSection) diff --git a/PROMS/fmtxml/AppendPlantSpecific.cs b/PROMS/fmtxml/AppendPlantSpecific.cs index 792607c8..8e9a9f2e 100644 --- a/PROMS/fmtxml/AppendPlantSpecific.cs +++ b/PROMS/fmtxml/AppendPlantSpecific.cs @@ -2980,8 +2980,11 @@ namespace fmtxml AddNSPDEVDOC(ref dcstyles); break; case "NSPIFG.DOC": + AddNSPIFGDOC(ref dcstyles); + break; case "NSPIFG2.DOC": AddNSPIFGDOC(ref dcstyles); + AddNSPIFG2DOC(ref dcstyles); break; case "NSPIFG.Y00": AddNSPARP_00DOC(ref dcstyles); @@ -3013,6 +3016,8 @@ namespace fmtxml } } + + private void AddIP315DOC(ref DocStyles dcstyles) { dcstyles.DcStyles[0].ContBottom = "(STEP %0d CONTINUED ON NEXT PAGE)"; @@ -3322,6 +3327,11 @@ namespace fmtxml dcstyles.DcStyles[3].dstyle.FontSize = "11"; } + private void AddNSPIFG2DOC(ref DocStyles dcstyles) + { + dcstyles.DcStyles[0].ContTop = ""; + dcstyles.DcStyles[1].ContTop = ""; + } public void AddNSPARPDOC(ref DocStyles dcstyles) { //First Procedure Steps Page diff --git a/PROMS/fmtxml/FmtFileToXml.cs b/PROMS/fmtxml/FmtFileToXml.cs index f5825b29..251dbfc4 100644 --- a/PROMS/fmtxml/FmtFileToXml.cs +++ b/PROMS/fmtxml/FmtFileToXml.cs @@ -4810,7 +4810,9 @@ namespace fmtxml if (mbox.TabPos == sbox.TabPos) sbox.TabPos = NullInt; subFmt.BoxData[i].Font = FixInheritedFont(sbox.Font, mbox.Font); // Phase 3 } - + string subName = subFmt.Name; + bool inheritShowSectionTitles = true; + if (fmtName.Contains("NSPIFG.X00")) inheritShowSectionTitles = false; StepSectionLayout msctlay = mainFmt.SectData.StepSectionData.StpSectLayData; StepSectionLayout ssctlay = subFmt.SectData.StepSectionData.StpSectLayData; if (msctlay.TableCenterPos == ssctlay.TableCenterPos) subFmt.SectData.StepSectionData.StpSectLayData.TableCenterPos = null; @@ -5137,7 +5139,7 @@ namespace fmtxml if (msctlay.DoSTExtraAtTop != null && msctlay.DoSTExtraAtTop == ssctlay.DoSTExtraAtTop) subFmt.SectData.StepSectionData.StpSectLayData.DoSTExtraAtTop = "null"; if (msctlay.KeepStepsOnPage != null && msctlay.KeepStepsOnPage == ssctlay.KeepStepsOnPage) subFmt.SectData.StepSectionData.StpSectLayData.KeepStepsOnPage = "null"; if (msctlay.BreakOnSections != null && msctlay.BreakOnSections == ssctlay.BreakOnSections) subFmt.SectData.StepSectionData.StpSectLayData.BreakOnSections = "null"; - if (msctlay.ShowSectionTitles != null && msctlay.ShowSectionTitles == ssctlay.ShowSectionTitles) subFmt.SectData.StepSectionData.StpSectLayData.ShowSectionTitles = "null"; + if (inheritShowSectionTitles && msctlay.ShowSectionTitles != null && msctlay.ShowSectionTitles == ssctlay.ShowSectionTitles) subFmt.SectData.StepSectionData.StpSectLayData.ShowSectionTitles = "null"; if (msctlay.EndForSingle != null && msctlay.EndForSingle == ssctlay.EndForSingle) subFmt.SectData.StepSectionData.StpSectLayData.EndForSingle = "null"; if (msctlay.PaginateOnFirstSubstep3X != null && msctlay.PaginateOnFirstSubstep3X == ssctlay.PaginateOnFirstSubstep3X) subFmt.SectData.StepSectionData.StpSectLayData.PaginateOnFirstSubstep3X = "null"; if (msctlay.PaginateOnLowerStepLevel != null && msctlay.PaginateOnLowerStepLevel == ssctlay.PaginateOnLowerStepLevel) subFmt.SectData.StepSectionData.StpSectLayData.PaginateOnLowerStepLevel = "null"; diff --git a/PROMS/fmtxml/Form1.cs b/PROMS/fmtxml/Form1.cs index 68df2441..1b5c1d65 100644 --- a/PROMS/fmtxml/Form1.cs +++ b/PROMS/fmtxml/Form1.cs @@ -583,6 +583,9 @@ namespace fmtxml myConvert.Save(tbResultPath.Text + @"genmacall\" + fi.Name.ToLower().Replace(".rtf", ".svg")); } } + // The NSPIFG2 file did not exist. Copy over NSPIFG to it. + FileInfo fix = new FileInfo(tbResultPath.Text + @"genmacall\nspifg.svg"); + fix.CopyTo(tbResultPath.Text + @"genmacall\nspifg2.svg"); MessageBox.Show("DONE converting GenMac RTF files to drawing svg - Results are in " + tbResultPath.Text + @"genmacall"); }