From fbb2df544c51e8f30b8a02b7d6b82db02f82205d Mon Sep 17 00:00:00 2001 From: Kathy Date: Tue, 9 Sep 2014 13:11:20 +0000 Subject: [PATCH] =?UTF-8?q?WCNCKL:=20Improve=20pagination=20of=20checklist?= =?UTF-8?q?s,=20i.e.=20don=E2=80=99t=20break=20if=201st=20substep=20doesn?= =?UTF-8?q?=E2=80=99t=20fit=20on=20page=20WCNCLK:=20=E2=80=98SplitText?= =?UTF-8?q?=E2=80=99=20moved=20out=20of=20file=20&=20use=20it=20from=20Rtf?= =?UTF-8?q?Tools?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- PROMS/Volian.Print.Library/Pagination.cs | 11 ++ .../Volian.Print.Library/VlnSvgPageHelper.cs | 114 +----------------- 2 files changed, 15 insertions(+), 110 deletions(-) diff --git a/PROMS/Volian.Print.Library/Pagination.cs b/PROMS/Volian.Print.Library/Pagination.cs index 228c8c28..a9c12546 100644 --- a/PROMS/Volian.Print.Library/Pagination.cs +++ b/PROMS/Volian.Print.Library/Pagination.cs @@ -500,6 +500,17 @@ namespace Volian.Print.Library , MyItemInfo.ItemID, MyItemInfo.MyDocVersion.MyFolder.Name, MyItemInfo.ShortPath); break; } + if (MyItemInfo.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.WolfcreekCKLFormat) + { + if (!paraBreak.MyItemInfo.IsHigh // not a high level step + && paraBreak.MyParent.MyItemInfo.IsHigh // my parent is a hls + && paraBreak.MyItemInfo.MyPrevious == null // first substep + && paraBreak.MyParent.MyItemInfo.FormatStepData.UseSmartTemplate) // my parent has the checklist header + { + if (DebugPagination.IsOpen) DebugPagination.WriteLine("Breaking at parent of {0}", paraBreak.MyItemInfo.DisplayText); + paraBreak = paraBreak.MyParent; + } + } if (MyItemInfo.ActiveFormat.PlantFormat.FormatData.PrintData.SpecialCaseCalvertAlarm) // only do the following for Calvert Alarms { //if (lastBreak != null && lastBreak.MyItemInfo.InList(42656,42923)) Console.WriteLine("here"); diff --git a/PROMS/Volian.Print.Library/VlnSvgPageHelper.cs b/PROMS/Volian.Print.Library/VlnSvgPageHelper.cs index a0572fd2..f4015f07 100644 --- a/PROMS/Volian.Print.Library/VlnSvgPageHelper.cs +++ b/PROMS/Volian.Print.Library/VlnSvgPageHelper.cs @@ -1694,7 +1694,7 @@ namespace Volian.Print.Library } // Otherwise determine how many line to split the text into - List titleLines = SplitText(title, (int)len); + List titleLines = Volian.Base.Library.RtfTools.SplitText(title, (int)len); // Adjust y location based on which pagelist token & how many lines. Proctitle1 is adjusted if // there are more than 2 lines (proctitle1 should have it's own y location that is used if there are 1 or 2 lines.) @@ -1738,7 +1738,7 @@ namespace Volian.Print.Library float yoff = (float)pageItem.Row; - List titleLines = SplitText(title, (int)len); + List titleLines = Volian.Base.Library.RtfTools.SplitText(title, (int)len); foreach (string line in titleLines) { svgGroup.Add(PageItemToSvgText(pageItem.Token, yoff, xoff, (E_Justify)pageItem.Justify, pageItem.Font, line, MySection)); @@ -1747,7 +1747,7 @@ namespace Volian.Print.Library } private string SplitTitleAndUnit(SvgGroup svgGroup, VEPROMS.CSLA.Library.PageItem pageItem, string title, int? len, string token, string plstr) { - List titleLines = SplitText(title, (int)len); + List titleLines = Volian.Base.Library.RtfTools.SplitText(title, (int)len); // Add a separate line with the Unit Number titleLines.Add("UNIT " + MySection.MyDocVersion.DocVersionConfig.Unit_Number); // Adjust y location based on which pagelist token & how many lines. @@ -1803,7 +1803,7 @@ namespace Volian.Print.Library return plstr; } // Otherwise determine how many line to split the text into - List titleLines = SplitText(title, (int)len); + List titleLines = Volian.Base.Library.RtfTools.SplitText(title, (int)len); if (match == "{COVERTITLE1}" || match == "[COVERTITLE1]") { plstr = plstr.Replace(match, titleLines[0]); @@ -1827,112 +1827,6 @@ namespace Volian.Print.Library } return plstr; } - private List SplitText(string text, int len) - { - List results = new List(); - if (text.Contains("\\LINE ") || text.Contains("\r\n")) - { - string[] mySplit = {"\\LINE ","\r\n"}; - return new List(text.Split(mySplit, StringSplitOptions.None)); - - } - int width = 0; // width of text, non-rtf - int start = 0; // start of line (index into string 'text'), includes rtf - int lastspace = 0; // location of lastspace (index into string 'text'), includes rtf - int startNonRtf = 0; // start of line, non-rtf (used for determining starting position to determine width if there was a break) - string rtfprefix = ""; - string nextprefix = ""; - for (int indx = 0; indx < text.Length; indx++) - { - if (text[indx] == '\\') //rtf command - { - // look for three things at beginning of string: hex, unicode, rtfcommand. - Match m = Regex.Match(text.Substring(indx), @"^\\'[a-fA-F0-9][a-fA-F0-9]"); //hex - if (m.Success) - { - indx += m.Length - 1; - width++; - } - else - { - m = Regex.Match(text.Substring(indx), @"^\\[uU][a-fA-F0-9][a-fA-F0-9][a-fA-F0-9][?]"); // 3 char unicode, for example \u160? (hardspace) - if (m.Success) - { - indx += m.Length - 1; - width++; - } - else - { - m = Regex.Match(text.Substring(indx), @"^\\[uU][a-fA-F0-9][a-fA-F0-9][a-fA-F0-9][a-fA-F0-9][?]"); - if (m.Success) - { - indx += m.Length - 1; - width++; - } - else - { - m = Regex.Match(text.Substring(indx), @"^\\[^ ]*? "); - if (m.Success) - { - indx += m.Length - 1; - rtfprefix = AdjustRtfPrefix(rtfprefix, m.Value); - } - } - } - } - - } - else - { - if (text[indx] == ' ') - { - lastspace = indx; - startNonRtf = width; - } - width++; - if (width > len) - { - // what should be done if lastspace == 0 - // cannot find space char to split on, so break the word - // not ideal but PROMS was bombing otherwise - jsj 7/7/2014 - if (lastspace == 0) - { - lastspace = indx; - startNonRtf = width - 1; - } - results.Add(nextprefix+text.Substring(start, lastspace-start).Trim(" ".ToCharArray())); - nextprefix = rtfprefix; - if (nextprefix != "") nextprefix += " "; - start = lastspace + 1; - width = (width - startNonRtf - 1) > 0 ? width - startNonRtf - 1 : 0; - lastspace = 0; - } - } - - } - if (width > 0 || start < text.Length) results.Add(nextprefix + text.Substring(start).Trim(" ".ToCharArray())); - return results; - } - - private string AdjustRtfPrefix(string rtfprefix, string rtfcommand) - { - if (rtfcommand.Contains(@"\ulnone") || rtfcommand.Contains(@"\ul0")) // off - rtfprefix = rtfprefix.Replace(@"\ul",""); - else if (rtfcommand.Contains(@"\ul")) - rtfprefix += @"\ul"; - if (rtfcommand.Contains(@"\up0") || rtfcommand.Contains(@"\dn0")) rtfprefix = rtfprefix.Replace(@"\up2", "").Replace(@"\dn2", ""); - else if (rtfcommand.Contains(@"\up")) rtfprefix += @"\up2"; - else if (rtfcommand.Contains(@"\dn")) rtfprefix += @"\dn2"; - if (rtfcommand.Contains(@"\b0")) - rtfprefix = rtfprefix.Replace(@"\b", ""); - else if (rtfcommand.Contains(@"\b")) - rtfprefix += @"\b"; - if (rtfcommand.Contains(@"\i0")) - rtfprefix = rtfprefix.Replace(@"\i", ""); - else if (rtfcommand.Contains(@"\i")) - rtfprefix += @"\i"; - return rtfprefix; - } private int FindWidth(string title, int start, int len) { for (int ii = start + len; ii > start; ii--)