From aa264a4e5d55727e77bfd4e11996787677962d0d Mon Sep 17 00:00:00 2001 From: Kathy Date: Tue, 9 Sep 2014 13:10:34 +0000 Subject: [PATCH] =?UTF-8?q?WCNCKL:=20added=20length=20of=20smart=20templat?= =?UTF-8?q?e=20HLS=20(for=20wrapping)=20WCNCKL:=20Set=20length=20of=20smar?= =?UTF-8?q?t=20template=20HLS=20(for=20wrapping)=20Moved=20=E2=80=98SplitT?= =?UTF-8?q?ext=E2=80=99=20from=20vlnSvgPageHelper=20so=20that=20it=20can?= =?UTF-8?q?=20be=20accessible=20from=20DisplayText=20(Volian.Controls.Libr?= =?UTF-8?q?ary)=20and=20VlnSvgPageHelper=20(print)=20Calvert:=20use=20item?= =?UTF-8?q?=E2=80=99s=20format=20to=20determine=20if=20change=20id=20tab?= =?UTF-8?q?=20should=20be=20visible=20rather=20than=20top=20folder=20(top?= =?UTF-8?q?=20folder=20was=20used=20when=20user=20was=20prompted=20to=20en?= =?UTF-8?q?ter=20change=20id=20for=20session).=20WCNCKL:=20use=20=E2=80=98?= =?UTF-8?q?SplitText=E2=80=99=20to=20handle=20split/wrap=20of=20HLS=20chec?= =?UTF-8?q?klist=20text?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Format/PlantFormat.cs | 9 ++ PROMS/Volian.Base.Library/RtfTools.cs | 118 ++++++++++++++++++ .../DisplayTabControl.cs | 8 +- PROMS/Volian.Controls.Library/DisplayText.cs | 21 +++- .../Volian.Controls.Library/StepTabRibbon.cs | 3 +- PROMS/fmtxml/FmtFileToXml.cs | 4 + PROMS/fmtxml/PlantSpecific_WolfCreak.cs | 2 + PROMS/fmtxml/TranslateFMT.XSL | Bin 214500 -> 214800 bytes 8 files changed, 155 insertions(+), 10 deletions(-) create mode 100644 PROMS/Volian.Base.Library/RtfTools.cs diff --git a/PROMS/VEPROMS.CSLA.Library/Format/PlantFormat.cs b/PROMS/VEPROMS.CSLA.Library/Format/PlantFormat.cs index 8acdda86..b59a62f3 100644 --- a/PROMS/VEPROMS.CSLA.Library/Format/PlantFormat.cs +++ b/PROMS/VEPROMS.CSLA.Library/Format/PlantFormat.cs @@ -3886,6 +3886,7 @@ namespace VEPROMS.CSLA.Library return LazyLoad(ref _UseSmartTemplate, "@UseSmartTemplate"); } } + private LazyLoad _UseOldTemplate; public bool UseOldTemplate { @@ -4708,6 +4709,14 @@ namespace VEPROMS.CSLA.Library return LazyLoad(ref _PosAdjust, "StepPrintData/@PosAdjust"); } } + private LazyLoad _HLSLength; + public int? HLSLength + { + get + { + return LazyLoad(ref _HLSLength, "StepPrintData/@HLSLength"); + } + } private LazyLoad _Justify; public string Justify { diff --git a/PROMS/Volian.Base.Library/RtfTools.cs b/PROMS/Volian.Base.Library/RtfTools.cs new file mode 100644 index 00000000..a5546241 --- /dev/null +++ b/PROMS/Volian.Base.Library/RtfTools.cs @@ -0,0 +1,118 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Text.RegularExpressions; + +namespace Volian.Base.Library +{ + public class RtfTools + { + public static 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 static 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; + } + } +} diff --git a/PROMS/Volian.Controls.Library/DisplayTabControl.cs b/PROMS/Volian.Controls.Library/DisplayTabControl.cs index edb91aba..c8a89789 100644 --- a/PROMS/Volian.Controls.Library/DisplayTabControl.cs +++ b/PROMS/Volian.Controls.Library/DisplayTabControl.cs @@ -868,7 +868,7 @@ namespace Volian.Controls.Library { if (myItemInfo.ActiveFormat.PlantFormat.FormatData.ProcData.ChangeBarData.ChangeIds) { - if (ItemsChangeIds.ContainsKey(myItemInfo.MyProcedure.ItemID)) SetChangeId(ItemsChangeIds[myItemInfo.MyProcedure.ItemID], pg); + if (ItemsChangeIds.ContainsKey(myItemInfo.MyProcedure.ItemID)) SetChangeId(ItemsChangeIds[myItemInfo.MyProcedure.ItemID], pg, myItemInfo); else PromptForChangeId(myItemInfo, pg); } } @@ -877,17 +877,17 @@ namespace Volian.Controls.Library dlgChgId dlgCI = new dlgChgId(this); dlgCI.ShowDialog(this); ItemsChangeIds.Add(myItemInfo.MyProcedure.ItemID, ChgId); - SetChangeId(ChgId, pg); + SetChangeId(ChgId, pg, myItemInfo); } - private void SetChangeId(string chgid, DisplayTabItem pg) + private void SetChangeId(string chgid, DisplayTabItem pg, ItemInfo ii) { if (pg == null || pg.MyStepTabPanel == null) { ChgId = null; return; } - pg.MyStepTabPanel.MyStepTabRibbon.SetChangeId(chgid); + pg.MyStepTabPanel.MyStepTabRibbon.SetChangeId(chgid, ii); ChgId = chgid; } /// diff --git a/PROMS/Volian.Controls.Library/DisplayText.cs b/PROMS/Volian.Controls.Library/DisplayText.cs index f2e03c61..e0ea03a2 100644 --- a/PROMS/Volian.Controls.Library/DisplayText.cs +++ b/PROMS/Volian.Controls.Library/DisplayText.cs @@ -5,6 +5,7 @@ using System.Windows.Forms; using System.Text.RegularExpressions; using System.Drawing; using VEPROMS.CSLA.Library; +using Volian.Base.Library; namespace Volian.Controls.Library { @@ -121,11 +122,21 @@ namespace Volian.Controls.Library if (OriginalText.Contains("Prerequisite")) OriginalText = Regex.Replace(OriginalText, @"\\{Prerequisite Step: .*?\\}", ""); TextFont = itemInfo.GetItemFont();//GetItemFont(); - // if in print mode, and this is the HLS of a smart template (checklist formats), add a space before and - // after the HLS text - this allows for the vertical bar characters to be added. - //if (itemInfo.IsStep && itemInfo.FormatStepData.UseSmartTemplate && epMode == E_EditPrintMode.Print) Console.WriteLine("here"); - string addSpace = (itemInfo.IsStep && itemInfo.FormatStepData.UseSmartTemplate && epMode == E_EditPrintMode.Print) ? " " : ""; - string text = prefix + addSpace + OriginalText + addSpace + suffix; + // if in print mode, and this is the HLS of a smart template (checklist formats) see if the hls + // splits across 2 lines. + if (itemInfo.IsStep && itemInfo.FormatStepData.UseSmartTemplate && epMode == E_EditPrintMode.Print) + { + int hlslen = (int)(itemInfo.FormatStepData.StepPrintData.HLSLength ?? 66); + List titleLines = Volian.Base.Library.RtfTools.SplitText(OriginalText, hlslen); + if (titleLines.Count > 1) + { + string tmporig = titleLines[0]; + for (int ix = 1; ix < titleLines.Count; ix++) + tmporig = tmporig + @"\par " + titleLines[ix]; + OriginalText = tmporig; + } + } + string text = prefix + OriginalText + suffix; _MyFormat = itemInfo.ActiveFormat; bool tableShouldBeOutlined = (epMode == E_EditPrintMode.Print || vwMode == E_ViewMode.View || noEdit) && diff --git a/PROMS/Volian.Controls.Library/StepTabRibbon.cs b/PROMS/Volian.Controls.Library/StepTabRibbon.cs index 430b419f..53d9e19f 100644 --- a/PROMS/Volian.Controls.Library/StepTabRibbon.cs +++ b/PROMS/Volian.Controls.Library/StepTabRibbon.cs @@ -63,9 +63,10 @@ namespace Volian.Controls.Library // txtBxChgId.Text = (this.Parent as StepTabPanel).MyDisplayTabControl.ChgId; } } - public void SetChangeId(string chgid) + public void SetChangeId(string chgid, ItemInfo ii) { txtBxChgId.Text = chgid; + rtabChgId.Visible = (ii != null) ? ii.ActiveFormat.PlantFormat.FormatData.ProcData.ChangeBarData.ChangeIds : false; } // added jcb 20121221 to support set ro from word doc private ROFSTLookup MyLookup; diff --git a/PROMS/fmtxml/FmtFileToXml.cs b/PROMS/fmtxml/FmtFileToXml.cs index ed8fa030..1fcadd43 100644 --- a/PROMS/fmtxml/FmtFileToXml.cs +++ b/PROMS/fmtxml/FmtFileToXml.cs @@ -1044,6 +1044,7 @@ public struct Print public string ForeColor; // Doesn't exist in old format - See StepLayoutData public string BackColor; // Doesn't exist in old format - See StepLayoutData public string PosAdjust; + public string HLSLength; // added for wolf creek checklist to define max string len of HLS (checklist steps) public string Justify; // added for wolf creek checklist procedures. } [Serializable] @@ -5408,6 +5409,7 @@ namespace fmtxml private string StepPartPrintForeColor(Step stp) { return stp.StepPrintData.ForeColor; } private string StepPartPrintBackColor(Step stp) { return stp.StepPrintData.BackColor; } private string StepPartPrintPosAdjust(Step stp) { return stp.StepPrintData.PosAdjust; } + private string StepPartPrintHLSLength(Step stp) { return stp.StepPrintData.HLSLength; } private string StepPartTabIdentEdit(Step stp) { return stp.TabData.IdentEdit; } private string StepPartTabIdent(Step stp) { return stp.TabData.Ident; } @@ -5627,6 +5629,8 @@ namespace fmtxml if (CheckInheritedStr(new StepPartStr(StepPartPrintForeColor), step, dicParents)) step.StepPrintData.ForeColor = null; if (CheckInheritedStr(new StepPartStr(StepPartPrintBackColor), step, dicParents)) step.StepPrintData.BackColor = null; if (CheckInheritedStr(new StepPartStr(StepPartPrintPosAdjust), step, dicParents)) step.StepPrintData.PosAdjust = NullString; + if (CheckInheritedStr(new StepPartStr(StepPartPrintHLSLength), step, dicParents)) step.StepPrintData.HLSLength = NullString; + // substructure - TabData //RHM/KBR added this - not sure: if (mstp.TabData.IdentEdit == sstp.TabData.IdentEdit) subFmt.StepData[i].TabData.IdentEdit = null; diff --git a/PROMS/fmtxml/PlantSpecific_WolfCreak.cs b/PROMS/fmtxml/PlantSpecific_WolfCreak.cs index 3f8a1c4c..b13fee13 100644 --- a/PROMS/fmtxml/PlantSpecific_WolfCreak.cs +++ b/PROMS/fmtxml/PlantSpecific_WolfCreak.cs @@ -136,6 +136,8 @@ namespace fmtxml fmtdata.StepData[30].StepLayoutData.AlignWithParentTab = "True"; fmtdata.StepData[2].StepPrintData.Justify = "Center"; fmtdata.StepData[9].StepPrintData.Justify = "Center"; + fmtdata.StepData[2].StepPrintData.HLSLength = "66"; + fmtdata.StepData[9].StepPrintData.HLSLength = "66"; fmtdata.ROData.UpRoAftrDash = "False"; fmtdata.ROData.UpRoImmAftrDashSpace = "True"; } diff --git a/PROMS/fmtxml/TranslateFMT.XSL b/PROMS/fmtxml/TranslateFMT.XSL index 25e51bcf906f37a6dda5882666f903ccbd745edf..5a07e0a60264d83e0c2bd0b8390a656f041312c6 100644 GIT binary patch delta 87 zcmaFT%{!rwx1oh`3zNy#$yS0ZM6 a444WWV*;nIa9~!Le1TtPd%;$wk_iA=y&0$g delta 19 bcmbQx$NQw4x1oh`3zNy#?FrkMHcS8jQWpqY