This commit is contained in:
2008-03-19 12:44:57 +00:00
parent 30c3bf71d2
commit 0f4ce7874a
2 changed files with 111 additions and 24 deletions

View File

@@ -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<displayTextElement> _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
/// <summary>
@@ -47,7 +48,7 @@ namespace VEPROMS.CSLA.Library
/// </summary>
public DisplayText(ItemInfo itemInfo, E_EditPrintMode epMode, E_ViewMode vwMode)
{
_itemInfo = itemInfo;
_MyItemInfo = itemInfo;
DisplayTextElementList = new List<displayTextElement>();
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)
{