WCNCKL: added length of smart template HLS (for wrapping)

WCNCKL: Set length of smart template HLS (for wrapping)
Moved ‘SplitText’ from vlnSvgPageHelper so that it can be accessible from DisplayText (Volian.Controls.Library) and VlnSvgPageHelper (print)
Calvert: use item’s format to determine if change id tab should be visible rather than top folder (top folder was used when user was prompted to enter change id for session).
WCNCKL: use ‘SplitText’ to handle split/wrap of HLS checklist text
This commit is contained in:
Kathy Ruffing 2014-09-09 13:10:34 +00:00
parent d6aae18a46
commit aa264a4e5d
8 changed files with 155 additions and 10 deletions

View File

@ -3886,6 +3886,7 @@ namespace VEPROMS.CSLA.Library
return LazyLoad(ref _UseSmartTemplate, "@UseSmartTemplate");
}
}
private LazyLoad<bool> _UseOldTemplate;
public bool UseOldTemplate
{
@ -4708,6 +4709,14 @@ namespace VEPROMS.CSLA.Library
return LazyLoad(ref _PosAdjust, "StepPrintData/@PosAdjust");
}
}
private LazyLoad<int?> _HLSLength;
public int? HLSLength
{
get
{
return LazyLoad(ref _HLSLength, "StepPrintData/@HLSLength");
}
}
private LazyLoad<string> _Justify;
public string Justify
{

View File

@ -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<string> SplitText(string text, int len)
{
{
List<string> results = new List<string>();
if (text.Contains("\\LINE ") || text.Contains("\r\n"))
{
string[] mySplit = { "\\LINE ", "\r\n" };
return new List<string>(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;
}
}
}

View File

@ -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;
}
/// <summary>

View File

@ -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<string> 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) &&

View File

@ -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;

View File

@ -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;

View File

@ -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";
}

Binary file not shown.