diff --git a/PROMS/VEPROMS.CSLA.Library/Extension/DisplayText.cs b/PROMS/VEPROMS.CSLA.Library/Extension/DisplayText.cs index 9c351b8b..5318c418 100644 --- a/PROMS/VEPROMS.CSLA.Library/Extension/DisplayText.cs +++ b/PROMS/VEPROMS.CSLA.Library/Extension/DisplayText.cs @@ -10,7 +10,7 @@ namespace VEPROMS.CSLA.Library public class DisplayText { #region Properties - private ItemInfo _itemInfo; + private ItemInfo _MyItemInfo; // list of 'pieces of text' for this item. Pieces include symbols, ros, // transitions & plain text. private List _DisplayTextElementList; @@ -34,6 +34,7 @@ namespace VEPROMS.CSLA.Library set { _textFont = value; } } public string OriginalText; // compare for save to see if change. + private FormatInfo _MyFormat; #endregion #region Constructors /// @@ -47,7 +48,7 @@ namespace VEPROMS.CSLA.Library /// public DisplayText(ItemInfo itemInfo, E_EditPrintMode epMode, E_ViewMode vwMode) { - _itemInfo = itemInfo; + _MyItemInfo = itemInfo; DisplayTextElementList = new List(); OriginalText = itemInfo.MyContent.Text; TextFont = GetItemFont(); @@ -55,8 +56,8 @@ namespace VEPROMS.CSLA.Library // if in print mode or view mode, do replace words. Only if in edit mode are replace // words left as is. - FormatInfo format = itemInfo.ActiveFormat; - if (epMode == E_EditPrintMode.Print || vwMode == E_ViewMode.View) text = DoReplaceWords(text, format); + _MyFormat = itemInfo.ActiveFormat; + if (epMode == E_EditPrintMode.Print || vwMode == E_ViewMode.View) text = DoReplaceWords(text); // as a precaution, convert any \~ to \u160?. This is for Hard spaces.. see the commentary in the // save portion of this code for an explanation. @@ -111,7 +112,7 @@ namespace VEPROMS.CSLA.Library string modtext = sret.ToString(); if (modtext != OriginalText) { - Item itm = _itemInfo.Get(); + Item itm = _MyItemInfo.Get(); // check for different text, i.e. text from this itm doesn't match // original text. if (OriginalText != itm.MyContent.Text) @@ -551,8 +552,8 @@ namespace VEPROMS.CSLA.Library private VE_Font GetItemFont() { VE_Font font = null; - FormatInfo format = _itemInfo.ActiveFormat; - int type = (int)_itemInfo.MyContent.Type; + FormatInfo format = _MyItemInfo.ActiveFormat; + int type = (int)_MyItemInfo.MyContent.Type; switch (type/10000) { case 0: // procedure @@ -571,7 +572,7 @@ namespace VEPROMS.CSLA.Library } private string InsertRtfStyles() { - StringBuilder sb = new StringBuilder(_itemInfo.MyContent.Text); + StringBuilder sb = new StringBuilder(_MyItemInfo.MyContent.Text); if ((TextFont.Style & E_Style.Bold)>0) { sb.Insert(0, "\\b "); @@ -657,12 +658,13 @@ namespace VEPROMS.CSLA.Library { int transitionID = Convert.ToInt32(link.Split(" ".ToCharArray())[1]); // Find the transition - foreach (TransitionInfo ti in _itemInfo.MyContent.ContentTransitions) + foreach (TransitionInfo ti in _MyItemInfo.MyContent.ContentTransitions) { if (ti.TransitionID == transitionID) { - string path = ti.PathTo.Replace(" Section PROCEDURE STEPS ", ", "); - path = path.Replace(" Section PROCEDURE STEPS", ""); + //string path = ti.PathTo.Replace(" Section PROCEDURE STEPS ", ", "); + //path = path.Replace(" Section PROCEDURE STEPS", ""); + string path = ti.ResolvePathTo(_MyFormat, _MyItemInfo, ItemInfo.Get(ti.ToID), ti.RangeID==0?null:ItemInfo.Get(ti.RangeID)); return path; } } @@ -714,23 +716,23 @@ namespace VEPROMS.CSLA.Library string t = s.Replace(_rs.ReplaceWord, _rs.ReplaceWith); return m.ToString().Replace(_rs.ReplaceWord, _rs.ReplaceWith); } - private string DoReplaceWords(string Text, FormatInfo format) + private string DoReplaceWords(string Text) { - ReplaceStrList rsl = format.PlantFormat.FormatData.SectData.ReplaceStrList; + ReplaceStrList rsl = _MyFormat.PlantFormat.FormatData.SectData.ReplaceStrList; foreach (ReplaceStr rs in rsl) { - if (_itemInfo.MyContent.Type < 20000) return Text; // for now only replace in steps. + if (_MyItemInfo.MyContent.Type < 20000) return Text; // for now only replace in steps. bool replaceit = false; // note that the order of this check is important. Check in this order... // background here - if (_itemInfo.IsHigh && (rs.Flag & E_ReplaceFlags.High)>0) replaceit = true; - else if ((_itemInfo.IsTable || _itemInfo.IsFigure) && (rs.Flag & E_ReplaceFlags.Table) > 0) replaceit = true; - else if (_itemInfo.IsInRNO && (rs.Flag & E_ReplaceFlags.RNO) > 0) replaceit = true; - else if (_itemInfo.IsCaution && (rs.Flag & E_ReplaceFlags.Caution) > 0) replaceit = true; - else if (_itemInfo.IsNote && (rs.Flag & E_ReplaceFlags.Note) > 0) replaceit = true; - else if (_itemInfo.IsInFirstLevelSubStep && (rs.Flag & E_ReplaceFlags.Substep) > 0) replaceit = true; - else if (_itemInfo.IsAccPages & (rs.Flag & E_ReplaceFlags.Attach) > 0) replaceit = true; + if (_MyItemInfo.IsHigh && (rs.Flag & E_ReplaceFlags.High)>0) replaceit = true; + else if ((_MyItemInfo.IsTable || _MyItemInfo.IsFigure) && (rs.Flag & E_ReplaceFlags.Table) > 0) replaceit = true; + else if (_MyItemInfo.IsInRNO && (rs.Flag & E_ReplaceFlags.RNO) > 0) replaceit = true; + else if (_MyItemInfo.IsCaution && (rs.Flag & E_ReplaceFlags.Caution) > 0) replaceit = true; + else if (_MyItemInfo.IsNote && (rs.Flag & E_ReplaceFlags.Note) > 0) replaceit = true; + else if (_MyItemInfo.IsInFirstLevelSubStep && (rs.Flag & E_ReplaceFlags.Substep) > 0) replaceit = true; + else if (_MyItemInfo.IsAccPages & (rs.Flag & E_ReplaceFlags.Attach) > 0) replaceit = true; if (replaceit) { diff --git a/PROMS/VEPROMS.CSLA.Library/Extension/TransitionExt.cs b/PROMS/VEPROMS.CSLA.Library/Extension/TransitionExt.cs index 679f6ce6..87bd938c 100644 --- a/PROMS/VEPROMS.CSLA.Library/Extension/TransitionExt.cs +++ b/PROMS/VEPROMS.CSLA.Library/Extension/TransitionExt.cs @@ -6,11 +6,96 @@ namespace VEPROMS.CSLA.Library { public partial class TransitionInfo { + public string ResolvePathTo(FormatInfo fi, ItemInfo itminfo, ItemInfo toitem, ItemInfo rangeitem) + { + StringBuilder retstr = new StringBuilder(); + // get the format of the transition string based on this transition's index into the TransData part of + // format.... + string tranformat = fi.PlantFormat.FormatData.TransData.TransTypeList[TranType].TransFormat; + E_TransUI etm = (E_TransUI)fi.PlantFormat.FormatData.TransData.TransTypeList[TranType].TransUI; + int startIndex = 0; + int index = -1; + while ((index = tranformat.IndexOf("{", startIndex))>-1) + { + // Append any non-token text that preceeds the token. + string remstptext = null; + if (index > startIndex) + { + retstr.Append(tranformat.Substring(startIndex, index-startIndex)); + remstptext = tranformat.Substring(startIndex, index-startIndex); + } + int endtokn = tranformat.IndexOf("}", index); + string token = tranformat.Substring(index, endtokn - index + 1); + switch (token) + { + case "{Proc Num}": + retstr.Append(toitem.MyProcedure.MyContent.Number); + break; + case "{Proc Title}": + if (fi.PlantFormat.FormatData.XtraOptions("CapsTransitions")) + retstr.Append(toitem.MyProcedure.MyContent.Text.ToUpper()); + else + retstr.Append(toitem.MyProcedure.MyContent.Text); + break; + case "{First Step}": // TODO: LowerCaseTranNumber - lower case substep numbers in transitions + // If we're on a step put out the step number. + ItemInfo secitm = TranGetSectionItem(toitem); + if ((!((etm & E_TransUI.StepAllowNone) == E_TransUI.StepAllowNone)) || toitem.MyContent.Type >20000) + retstr.Append(toitem.Ordinal.ToString()); + else // if the word 'step' or ',' preceeds this template & there is no step, remove it. + { + if (remstptext != null) + { + int len = remstptext.Length; + retstr.Remove(retstr.Length-len,len); + } + } + break; + case "{Last Step}": // TODO: TStepNoFlag, i.e. include step number in range items. + retstr.Append(rangeitem.Ordinal.ToString()); + break; + case "{.}": // TODO: TStepNoFlag, i.e. include step number in range items. + retstr.Append("#"); // TODO: Intermediate Range. + break; + case "{Sect Hdr}": + retstr.Append(TranGetSectionHdr(toitem)); + break; + case "{Sect Title}": + retstr.Append(TranGetSectionTitle(toitem)); + break; + } + startIndex = endtokn+1; + if (startIndex >= tranformat.Length) break; + } + if (startIndex < tranformat.Length) retstr.Append(tranformat.Substring(startIndex, tranformat.Length - startIndex - 1)); + return (retstr.ToString()); + } + // TODO: Section methods are not complete.... + private ItemInfo TranGetSectionItem(ItemInfo itminfo) + { + ItemInfo tmpitm = itminfo; + while (tmpitm.MyContent.Type >= 20000) tmpitm = tmpitm.MyParent; + return tmpitm; + } + private string TranGetSectionHdr(ItemInfo itminfo) + { + ItemInfo tmpitm = TranGetSectionItem(itminfo); + StringBuilder retstr = new StringBuilder(); + retstr.Append(tmpitm.MyContent.Number); + if (tmpitm.MyContent.Number != null && tmpitm.MyContent.Number != "" && tmpitm.MyContent.Text != null && tmpitm.MyContent.Text != "") retstr.Append(" "); + retstr.Append(tmpitm.MyContent.Text); + return (retstr.ToString()); + } + + private string TranGetSectionTitle(ItemInfo itminfo) + { + ItemInfo tmpitm = TranGetSectionItem(itminfo); + return (tmpitm.MyContent.Text); + } public string PathTo { - get - { - //return "To " + MyItemToID.Path; + get + { return MyItemToID.Path; } }