This commit is contained in:
parent
30c3bf71d2
commit
0f4ce7874a
@ -10,7 +10,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
public class DisplayText
|
public class DisplayText
|
||||||
{
|
{
|
||||||
#region Properties
|
#region Properties
|
||||||
private ItemInfo _itemInfo;
|
private ItemInfo _MyItemInfo;
|
||||||
// list of 'pieces of text' for this item. Pieces include symbols, ros,
|
// list of 'pieces of text' for this item. Pieces include symbols, ros,
|
||||||
// transitions & plain text.
|
// transitions & plain text.
|
||||||
private List<displayTextElement> _DisplayTextElementList;
|
private List<displayTextElement> _DisplayTextElementList;
|
||||||
@ -34,6 +34,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
set { _textFont = value; }
|
set { _textFont = value; }
|
||||||
}
|
}
|
||||||
public string OriginalText; // compare for save to see if change.
|
public string OriginalText; // compare for save to see if change.
|
||||||
|
private FormatInfo _MyFormat;
|
||||||
#endregion
|
#endregion
|
||||||
#region Constructors
|
#region Constructors
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -47,7 +48,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public DisplayText(ItemInfo itemInfo, E_EditPrintMode epMode, E_ViewMode vwMode)
|
public DisplayText(ItemInfo itemInfo, E_EditPrintMode epMode, E_ViewMode vwMode)
|
||||||
{
|
{
|
||||||
_itemInfo = itemInfo;
|
_MyItemInfo = itemInfo;
|
||||||
DisplayTextElementList = new List<displayTextElement>();
|
DisplayTextElementList = new List<displayTextElement>();
|
||||||
OriginalText = itemInfo.MyContent.Text;
|
OriginalText = itemInfo.MyContent.Text;
|
||||||
TextFont = GetItemFont();
|
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
|
// if in print mode or view mode, do replace words. Only if in edit mode are replace
|
||||||
// words left as is.
|
// words left as is.
|
||||||
FormatInfo format = itemInfo.ActiveFormat;
|
_MyFormat = itemInfo.ActiveFormat;
|
||||||
if (epMode == E_EditPrintMode.Print || vwMode == E_ViewMode.View) text = DoReplaceWords(text, format);
|
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
|
// 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.
|
// save portion of this code for an explanation.
|
||||||
@ -111,7 +112,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
string modtext = sret.ToString();
|
string modtext = sret.ToString();
|
||||||
if (modtext != OriginalText)
|
if (modtext != OriginalText)
|
||||||
{
|
{
|
||||||
Item itm = _itemInfo.Get();
|
Item itm = _MyItemInfo.Get();
|
||||||
// check for different text, i.e. text from this itm doesn't match
|
// check for different text, i.e. text from this itm doesn't match
|
||||||
// original text.
|
// original text.
|
||||||
if (OriginalText != itm.MyContent.Text)
|
if (OriginalText != itm.MyContent.Text)
|
||||||
@ -551,8 +552,8 @@ namespace VEPROMS.CSLA.Library
|
|||||||
private VE_Font GetItemFont()
|
private VE_Font GetItemFont()
|
||||||
{
|
{
|
||||||
VE_Font font = null;
|
VE_Font font = null;
|
||||||
FormatInfo format = _itemInfo.ActiveFormat;
|
FormatInfo format = _MyItemInfo.ActiveFormat;
|
||||||
int type = (int)_itemInfo.MyContent.Type;
|
int type = (int)_MyItemInfo.MyContent.Type;
|
||||||
switch (type/10000)
|
switch (type/10000)
|
||||||
{
|
{
|
||||||
case 0: // procedure
|
case 0: // procedure
|
||||||
@ -571,7 +572,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
}
|
}
|
||||||
private string InsertRtfStyles()
|
private string InsertRtfStyles()
|
||||||
{
|
{
|
||||||
StringBuilder sb = new StringBuilder(_itemInfo.MyContent.Text);
|
StringBuilder sb = new StringBuilder(_MyItemInfo.MyContent.Text);
|
||||||
if ((TextFont.Style & E_Style.Bold)>0)
|
if ((TextFont.Style & E_Style.Bold)>0)
|
||||||
{
|
{
|
||||||
sb.Insert(0, "\\b ");
|
sb.Insert(0, "\\b ");
|
||||||
@ -657,12 +658,13 @@ namespace VEPROMS.CSLA.Library
|
|||||||
{
|
{
|
||||||
int transitionID = Convert.ToInt32(link.Split(" ".ToCharArray())[1]);
|
int transitionID = Convert.ToInt32(link.Split(" ".ToCharArray())[1]);
|
||||||
// Find the transition
|
// Find the transition
|
||||||
foreach (TransitionInfo ti in _itemInfo.MyContent.ContentTransitions)
|
foreach (TransitionInfo ti in _MyItemInfo.MyContent.ContentTransitions)
|
||||||
{
|
{
|
||||||
if (ti.TransitionID == transitionID)
|
if (ti.TransitionID == transitionID)
|
||||||
{
|
{
|
||||||
string path = ti.PathTo.Replace(" Section PROCEDURE STEPS ", ", ");
|
//string path = ti.PathTo.Replace(" Section PROCEDURE STEPS ", ", ");
|
||||||
path = path.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;
|
return path;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -714,23 +716,23 @@ namespace VEPROMS.CSLA.Library
|
|||||||
string t = s.Replace(_rs.ReplaceWord, _rs.ReplaceWith);
|
string t = s.Replace(_rs.ReplaceWord, _rs.ReplaceWith);
|
||||||
return m.ToString().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)
|
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;
|
bool replaceit = false;
|
||||||
|
|
||||||
// note that the order of this check is important. Check in this order...
|
// note that the order of this check is important. Check in this order...
|
||||||
// background here
|
// background here
|
||||||
if (_itemInfo.IsHigh && (rs.Flag & E_ReplaceFlags.High)>0) replaceit = true;
|
if (_MyItemInfo.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 ((_MyItemInfo.IsTable || _MyItemInfo.IsFigure) && (rs.Flag & E_ReplaceFlags.Table) > 0) replaceit = true;
|
||||||
else if (_itemInfo.IsInRNO && (rs.Flag & E_ReplaceFlags.RNO) > 0) replaceit = true;
|
else if (_MyItemInfo.IsInRNO && (rs.Flag & E_ReplaceFlags.RNO) > 0) replaceit = true;
|
||||||
else if (_itemInfo.IsCaution && (rs.Flag & E_ReplaceFlags.Caution) > 0) replaceit = true;
|
else if (_MyItemInfo.IsCaution && (rs.Flag & E_ReplaceFlags.Caution) > 0) replaceit = true;
|
||||||
else if (_itemInfo.IsNote && (rs.Flag & E_ReplaceFlags.Note) > 0) replaceit = true;
|
else if (_MyItemInfo.IsNote && (rs.Flag & E_ReplaceFlags.Note) > 0) replaceit = true;
|
||||||
else if (_itemInfo.IsInFirstLevelSubStep && (rs.Flag & E_ReplaceFlags.Substep) > 0) replaceit = true;
|
else if (_MyItemInfo.IsInFirstLevelSubStep && (rs.Flag & E_ReplaceFlags.Substep) > 0) replaceit = true;
|
||||||
else if (_itemInfo.IsAccPages & (rs.Flag & E_ReplaceFlags.Attach) > 0) replaceit = true;
|
else if (_MyItemInfo.IsAccPages & (rs.Flag & E_ReplaceFlags.Attach) > 0) replaceit = true;
|
||||||
|
|
||||||
if (replaceit)
|
if (replaceit)
|
||||||
{
|
{
|
||||||
|
@ -6,11 +6,96 @@ namespace VEPROMS.CSLA.Library
|
|||||||
{
|
{
|
||||||
public partial class TransitionInfo
|
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
|
public string PathTo
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
//return "To " + MyItemToID.Path;
|
|
||||||
return MyItemToID.Path;
|
return MyItemToID.Path;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user