Fixed logic to handle Fortran Formatted Numbers in word documents
Added StepLevel property to ItemInfo Added StepLevel debug
This commit is contained in:
@@ -614,10 +614,10 @@ namespace VEPROMS.CSLA.Library
|
||||
// Look for superscript or subscript and insert the appropriate commands
|
||||
//Match roMatch = Regex.Match(tmp, @"(.*?)\\(super|sub) (.*?)\\nosupersub ");
|
||||
Match roMatch = Regex.Match(tmp, @"(.*?)\\(up3|dn3) (.*?)\\(up0|dn0) ");
|
||||
if (roMatch.Groups.Count == 4)// Superscript or subscript found
|
||||
if (roMatch.Groups.Count == 5)// Superscript or subscript found
|
||||
{
|
||||
sel.Font.Color = LBWdColor.wdColorRed;
|
||||
while (roMatch.Groups.Count == 4)
|
||||
while (roMatch.Groups.Count == 5)
|
||||
{
|
||||
sel.TypeText(roMatch.Groups[1].Value); // output the text preceeding the super or sub command
|
||||
sel.Font.Position = roMatch.Groups[2].Value == "up3" ? 2 : -2; // Shift the vertical position for super or sub
|
||||
|
@@ -287,6 +287,124 @@ namespace VEPROMS.CSLA.Library
|
||||
#region ItemInfo
|
||||
public partial class ItemInfo:IVEDrillDownReadOnly
|
||||
{
|
||||
#region StepLevel
|
||||
private int _StepLevel = -2;// Not yet calculated
|
||||
public int StepLevel
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_StepLevel == -2)
|
||||
{
|
||||
_StepLevel = CalcStepLevel(this);
|
||||
//ItemInfo parent = ActiveParent as ItemInfo;
|
||||
//Console.WriteLine("{0},{1},{2},{3},{4},{5},{6}",ItemID, DBSequence, _StepLevel, MyContent.Type % 10000, parent.MyContent.Type % 10000,HasCautionOrNote ? 1 : 0, parent.Cautions == null? 0 : 1);
|
||||
}
|
||||
return _StepLevel;
|
||||
}
|
||||
set { _StepLevel = value; }
|
||||
}
|
||||
public bool HasCautionOrNote
|
||||
{
|
||||
get { return Cautions != null || Notes != null; }
|
||||
}
|
||||
private static Regex regexDBSeqPass1 = new Regex("([^.]*)[.]S([^.]*)[.]S([0-9]*)[.](.*)");
|
||||
private static Regex regexDBSeqPass2 = new Regex("[.](.)([^.]*)[.]");
|
||||
public string DBSequence
|
||||
{
|
||||
get
|
||||
{
|
||||
Match m1 = regexDBSeqPass1.Match(ShortPath);
|
||||
MatchCollection m2s = regexDBSeqPass2.Matches(m1.Groups[4].Value);
|
||||
StringBuilder retval = new StringBuilder(string.Format("'{0}','{1}',{2},'", m1.Groups[1].Value, m1.Groups[2].Value, m1.Groups[3].Value));
|
||||
string prefix = "S";
|
||||
string suffix = "";
|
||||
foreach (Match m2 in m2s)
|
||||
{
|
||||
int i = ((int) '0') + int.Parse(m2.Groups[2].Value);
|
||||
char c = (char)i;
|
||||
suffix = c.ToString();
|
||||
switch (m2.Groups[1].Value)
|
||||
{
|
||||
case "S":
|
||||
break;
|
||||
case "R":
|
||||
prefix += "$";
|
||||
suffix = "";
|
||||
break;
|
||||
case "C":
|
||||
prefix = "!";
|
||||
break;
|
||||
case "N":
|
||||
prefix = "*";
|
||||
break;
|
||||
case "T":
|
||||
prefix += "#";
|
||||
suffix = "";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
retval.Append(prefix + suffix);
|
||||
prefix = "";
|
||||
}
|
||||
retval.Append(prefix + "'");
|
||||
return retval.ToString();
|
||||
}
|
||||
}
|
||||
private static int CalcStepLevel(ItemInfo item)
|
||||
{
|
||||
if(item == null) return 0;
|
||||
int id=0;
|
||||
if(item.ItemID == 507)
|
||||
id = item.ItemID;
|
||||
int level = CountLevels(item);
|
||||
int firstInc = item.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.StepSectionLayoutData.PaginateOnFirstSubstep ? 0 : 1;
|
||||
ItemInfo parent = item.ActiveParent as ItemInfo;
|
||||
if (item.IsExactType("And") || item.IsExactType("Or") || item.IsExactType("ImplicitOr"))
|
||||
level++;
|
||||
if (parent != null && (parent.IsExactType("And") || parent.IsExactType("Or")))
|
||||
level++;
|
||||
if (!item.IsRNOPart && !item.IsHigh && item.MyPrevious == null)
|
||||
level+=firstInc;
|
||||
if (item.IsStepPart)
|
||||
{
|
||||
if (item.Cautions != null || item.Notes != null)
|
||||
level += 2;
|
||||
}
|
||||
else if (item.IsCautionPart)
|
||||
{
|
||||
if (item.MyPrevious == null) level-=(1 + firstInc);
|
||||
else level++;
|
||||
}
|
||||
else if (item.IsNotePart)
|
||||
{
|
||||
if (parent.Cautions == null && item.MyPrevious == null) level-=(1 + firstInc);
|
||||
else level++;
|
||||
}
|
||||
else if (item.IsTablePart)
|
||||
{
|
||||
level += 2;
|
||||
}
|
||||
else if(item.IsRNOPart)
|
||||
{
|
||||
}
|
||||
return level;
|
||||
}
|
||||
private static int CountLevels(ItemInfo item)
|
||||
{
|
||||
int level = 0;
|
||||
int ignoreRNOs = item.ActiveSection.ColumnMode;
|
||||
while (item != null && !item.IsHigh)
|
||||
{
|
||||
if (ignoreRNOs > 0 && item.IsRNOPart)
|
||||
ignoreRNOs--;
|
||||
else
|
||||
level++; // need logic to not increment for RNOs less than MaxRNO
|
||||
item = item.ActiveParent as ItemInfo;
|
||||
}
|
||||
return level;
|
||||
}
|
||||
#endregion
|
||||
public bool HasHeader
|
||||
{
|
||||
get
|
||||
@@ -545,13 +663,21 @@ namespace VEPROMS.CSLA.Library
|
||||
if (sd.Type == type) return true;
|
||||
sd = sdlist[sd.ParentType];
|
||||
}
|
||||
// TODO: RHM20071115 while (sd.Index != 0)
|
||||
// TODO: RHM20071115 {
|
||||
// TODO: RHM20071115 if (sd.Type == type) return true;
|
||||
// TODO: RHM20071115 sd = sdlist[sd.ParentType];
|
||||
// TODO: RHM20071115 }
|
||||
return false;
|
||||
}
|
||||
public bool IsExactType(string type)
|
||||
{
|
||||
if ((int)MyContent.Type < 20000) return false;
|
||||
int stepType = ((int)MyContent.Type) % 10000;
|
||||
StepDataList sdlist = ActiveFormat.PlantFormat.FormatData.StepDataList;
|
||||
if (stepType > sdlist.Count)
|
||||
{
|
||||
Console.WriteLine("Error getting type - contentid = {0}", MyContent.ContentID);
|
||||
return false;
|
||||
}
|
||||
StepData sd = sdlist[stepType];
|
||||
return (sd.Type == type);
|
||||
}
|
||||
public bool IsCaution
|
||||
{
|
||||
get
|
||||
@@ -811,7 +937,6 @@ namespace VEPROMS.CSLA.Library
|
||||
{
|
||||
get
|
||||
{
|
||||
//if (MyContent.Type == 10000) return true;
|
||||
if (IsSection && MyDocStyle.IsStepSection) return true;
|
||||
return false;
|
||||
}
|
||||
|
Reference in New Issue
Block a user