Fixed logic to handle Fortran Formatted Numbers in word documents
Added StepLevel property to ItemInfo Added StepLevel debug
This commit is contained in:
parent
0963dbb79c
commit
ef26bcbdc4
@ -614,10 +614,10 @@ namespace VEPROMS.CSLA.Library
|
|||||||
// Look for superscript or subscript and insert the appropriate commands
|
// Look for superscript or subscript and insert the appropriate commands
|
||||||
//Match roMatch = Regex.Match(tmp, @"(.*?)\\(super|sub) (.*?)\\nosupersub ");
|
//Match roMatch = Regex.Match(tmp, @"(.*?)\\(super|sub) (.*?)\\nosupersub ");
|
||||||
Match roMatch = Regex.Match(tmp, @"(.*?)\\(up3|dn3) (.*?)\\(up0|dn0) ");
|
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;
|
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.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
|
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
|
#region ItemInfo
|
||||||
public partial class ItemInfo:IVEDrillDownReadOnly
|
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
|
public bool HasHeader
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
@ -545,13 +663,21 @@ namespace VEPROMS.CSLA.Library
|
|||||||
if (sd.Type == type) return true;
|
if (sd.Type == type) return true;
|
||||||
sd = sdlist[sd.ParentType];
|
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;
|
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
|
public bool IsCaution
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
@ -811,7 +937,6 @@ namespace VEPROMS.CSLA.Library
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
//if (MyContent.Type == 10000) return true;
|
|
||||||
if (IsSection && MyDocStyle.IsStepSection) return true;
|
if (IsSection && MyDocStyle.IsStepSection) return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -169,7 +169,7 @@ namespace Volian.Print.Library
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return string.Format("DebugID = {0}, ID={1} Type={2} TypeName='{3}' EveryNLines= {4}", DebugId, MyItemInfo.ItemID, MyItemInfo.FormatStepType, MyItemInfo.FormatStepData.Type, MyItemInfo.FormatStepData.StepLayoutData.EveryNLines);
|
return string.Format("DebugID = {0}, ID={1} Type={2} TypeName='{3}' EveryNLines={4} StepLevel={5}", DebugId, MyItemInfo.ItemID, MyItemInfo.FormatStepType, MyItemInfo.FormatStepData.Type, MyItemInfo.FormatStepData.StepLayoutData.EveryNLines, MyItemInfo.StepLevel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public override float ToPdf(PdfContentByte cb, float yPageStart, float yTopMargin, float yBottomMargin)
|
public override float ToPdf(PdfContentByte cb, float yPageStart, float yTopMargin, float yBottomMargin)
|
||||||
@ -260,7 +260,50 @@ namespace Volian.Print.Library
|
|||||||
vPara.ParagraphToPdf(cb, yPageStart, yTopMargin, yBottomMargin);
|
vPara.ParagraphToPdf(cb, yPageStart, yTopMargin, yBottomMargin);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
private static void WalkStepLevel(vlnParagraph para,float yTopMost)
|
||||||
|
{
|
||||||
|
foreach (vlnParagraph child in para.ChildrenAbove)
|
||||||
|
WalkStepLevel(child, yTopMost);
|
||||||
|
foreach (vlnParagraph child in para.ChildrenLeft)
|
||||||
|
WalkStepLevel(child, yTopMost);
|
||||||
|
ShowStepLevel(para,yTopMost);
|
||||||
|
foreach (vlnParagraph child in para.ChildrenRight)
|
||||||
|
WalkStepLevel(child, yTopMost);
|
||||||
|
foreach (vlnParagraph child in para.ChildrenBelow)
|
||||||
|
WalkStepLevel(child, yTopMost);
|
||||||
|
}
|
||||||
|
private static void ShowStepLevel(vlnParagraph para,float yTopMost)
|
||||||
|
{
|
||||||
|
ItemInfo item = para.MyItemInfo;
|
||||||
|
ItemInfo parent = item.ActiveParent as ItemInfo;
|
||||||
|
if (para.MyItemInfo.ItemID == 205)
|
||||||
|
Console.Write("");
|
||||||
|
Console.WriteLine("'StepLevel',{0},{1},{2},{3},{4},{5},{6},{7},{8},{9}", para.YVeryTop - yTopMost, para.YSize, para.YBottomMost-yTopMost, item.ItemID, item.DBSequence, item.StepLevel, item.MyContent.Type % 10000,
|
||||||
|
parent.MyContent.Type % 10000, item.HasCautionOrNote ? 1 : 0, parent.Cautions == null ? 0 : 1);
|
||||||
|
}
|
||||||
|
private float _YVeryTop = -1;
|
||||||
|
public float YVeryTop
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (_YVeryTop == -1)
|
||||||
|
{
|
||||||
|
_YVeryTop = YTop;
|
||||||
|
_YVeryTop = VeryTop(PartsAbove,_YVeryTop);
|
||||||
|
_YVeryTop = VeryTop(PartsContainer,_YVeryTop);
|
||||||
|
}
|
||||||
|
return _YVeryTop;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private float VeryTop(vlnPrintObjects parts, float yVeryTop)
|
||||||
|
{
|
||||||
|
if (parts != null)
|
||||||
|
foreach (vlnPrintObject part in parts)
|
||||||
|
if (part.YOffset < yVeryTop)
|
||||||
|
yVeryTop = part.YOffset;
|
||||||
|
return yVeryTop;
|
||||||
|
}
|
||||||
private int Paginate(float yLocation, float yTopMargin, float yBottomMargin)
|
private int Paginate(float yLocation, float yTopMargin, float yBottomMargin)
|
||||||
{
|
{
|
||||||
float yPageSize = yTopMargin - yBottomMargin;
|
float yPageSize = yTopMargin - yBottomMargin;
|
||||||
@ -270,7 +313,7 @@ namespace Volian.Print.Library
|
|||||||
if (mySize <= yWithinMargins)
|
if (mySize <= yWithinMargins)
|
||||||
{
|
{
|
||||||
if (MyItemInfo.IsHigh)
|
if (MyItemInfo.IsHigh)
|
||||||
Console.WriteLine("1,'No','HLS will fit on page',{0},{1},{2}, {3}, {4},'{5}'", MyItemInfo.ItemID, YSize, yPageSize, yWithinMargins, (int)(100 * yWithinMargins / yPageSize), MyItemInfo.ShortPath);
|
Console.WriteLine("'PageBreak',1,'No','HLS will fit on page',{0},{1},{2}, {3}, {4},'{5}'", MyItemInfo.ItemID, YSize, yPageSize, yWithinMargins, (int)(100 * yWithinMargins / yPageSize), MyItemInfo.ShortPath);
|
||||||
return 0; // Don't Paginate if there is enough room
|
return 0; // Don't Paginate if there is enough room
|
||||||
}
|
}
|
||||||
if (MyItemInfo.IsRNOPart && MyParent.XOffset < XOffset) return 0; // Don't paginate on an RNO to the right
|
if (MyItemInfo.IsRNOPart && MyParent.XOffset < XOffset) return 0; // Don't paginate on an RNO to the right
|
||||||
@ -278,12 +321,12 @@ namespace Volian.Print.Library
|
|||||||
{
|
{
|
||||||
if (YSize < yPageSize) // if the entire step can fit on one page, do a page break
|
if (YSize < yPageSize) // if the entire step can fit on one page, do a page break
|
||||||
{
|
{
|
||||||
Console.WriteLine("2,'Yes','HLS will fit on 1 Page',{0},{1},{2}, {3}, {4},'{5}'", MyItemInfo.ItemID, YSize, yPageSize, yWithinMargins, (int)(100 * yWithinMargins / yPageSize), MyItemInfo.ShortPath);
|
Console.WriteLine("'PageBreak',2,'Yes','HLS will fit on 1 Page',{0},{1},{2}, {3}, {4},'{5}'", MyItemInfo.ItemID, YSize, yPageSize, yWithinMargins, (int)(100 * yWithinMargins / yPageSize), MyItemInfo.ShortPath);
|
||||||
return 1; // Paginate on High Level Steps
|
return 1; // Paginate on High Level Steps
|
||||||
}
|
}
|
||||||
else if (YSize < (yPageSize * SixLinesPerInch / _SevenLinesPerInch))
|
else if (YSize < (yPageSize * SixLinesPerInch / _SevenLinesPerInch))
|
||||||
{
|
{
|
||||||
Console.WriteLine("6,'Yes','HLS will fit on 1 Page at 7 LPI',{0},{1},{2}, {3}, {4},'{5}'", MyItemInfo.ItemID, YSize, yPageSize, yWithinMargins, (int)(100 * yWithinMargins / yPageSize), MyItemInfo.ShortPath);
|
Console.WriteLine("'PageBreak',6,'Yes','HLS will fit on 1 Page at 7 LPI',{0},{1},{2}, {3}, {4},'{5}'", MyItemInfo.ItemID, YSize, yPageSize, yWithinMargins, (int)(100 * yWithinMargins / yPageSize), MyItemInfo.ShortPath);
|
||||||
return 3; // High Level Step can fit at SevenLinesPerInch
|
return 3; // High Level Step can fit at SevenLinesPerInch
|
||||||
}
|
}
|
||||||
else // The entire step cannot fit go ahead and kick to the next page
|
else // The entire step cannot fit go ahead and kick to the next page
|
||||||
@ -291,21 +334,25 @@ namespace Volian.Print.Library
|
|||||||
if (yWithinMargins > yPageSize / 2)
|
if (yWithinMargins > yPageSize / 2)
|
||||||
{
|
{
|
||||||
// If High level Step will not fit, kick to the next page
|
// If High level Step will not fit, kick to the next page
|
||||||
Console.WriteLine("3,'No','HLS will have to split anyway',{0},{1},{2}, {3}, {4},'{5}'", MyItemInfo.ItemID, YSize, yPageSize, yWithinMargins, (int)(100 * yWithinMargins / yPageSize), MyItemInfo.ShortPath);
|
Console.WriteLine("'PageBreak',3.1,'No','HLS will have to split anyway',{0},{1},{2}, {3}, {4},'{5}'", MyItemInfo.ItemID, YSize, yPageSize, yWithinMargins, (int)(100 * yWithinMargins / yPageSize), MyItemInfo.ShortPath);
|
||||||
|
if (MyItemInfo.IsHigh)
|
||||||
|
WalkStepLevel(this,this.YTopMost);
|
||||||
return 0;// Otherwise stay on this page
|
return 0;// Otherwise stay on this page
|
||||||
}
|
}
|
||||||
Console.WriteLine("3,'Yes','HLS will have to split',{0},{1},{2}, {3}, {4},'{5}'", MyItemInfo.ItemID, YSize, yPageSize, yWithinMargins, (int)(100 * yWithinMargins / yPageSize), MyItemInfo.ShortPath);
|
Console.WriteLine("'PageBreak',3.2,'Yes','HLS will have to split',{0},{1},{2}, {3}, {4},'{5}'", MyItemInfo.ItemID, YSize, yPageSize, yWithinMargins, (int)(100 * yWithinMargins / yPageSize), MyItemInfo.ShortPath);
|
||||||
|
if (MyItemInfo.IsHigh)
|
||||||
|
WalkStepLevel(this,this.YTopMost);
|
||||||
return 1; // Paginate on High Level Steps
|
return 1; // Paginate on High Level Steps
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (yWithinMargins > yPageSize / 2)
|
if (yWithinMargins > yPageSize / 2)
|
||||||
{
|
{
|
||||||
Console.WriteLine("4,'No','Not Half way down the page',{0},{1},{2}, {3}, {4},'{5}'", MyItemInfo.ItemID, YSize, yPageSize, yWithinMargins, (int)(100 * yWithinMargins / yPageSize), MyItemInfo.ShortPath);
|
Console.WriteLine("'PageBreak',4,'No','Not Half way down the page',{0},{1},{2}, {3}, {4},'{5}'", MyItemInfo.ItemID, YSize, yPageSize, yWithinMargins, (int)(100 * yWithinMargins / yPageSize), MyItemInfo.ShortPath);
|
||||||
return 0; // More than half way down the page
|
return 0; // More than half way down the page
|
||||||
}
|
}
|
||||||
//if (ChildrenBelow.Count > 0 && ChildrenBelow[0].YSize < yWithinMargins)
|
//if (ChildrenBelow.Count > 0 && ChildrenBelow[0].YSize < yWithinMargins)
|
||||||
// return 0;
|
// return 0;
|
||||||
Console.WriteLine("5,'Yes','At least half the page is filled',{0},{1},{2},{3}, {4},'{5}'", MyItemInfo.ItemID, YSize, yPageSize, yWithinMargins, (int)(100 * yWithinMargins / yPageSize), MyItemInfo.ShortPath);
|
Console.WriteLine("'PageBreak',5,'Yes','At least half the page is filled',{0},{1},{2},{3}, {4},'{5}'", MyItemInfo.ItemID, YSize, yPageSize, yWithinMargins, (int)(100 * yWithinMargins / yPageSize), MyItemInfo.ShortPath);
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
private int COL_WID_ADJ = 6; // adjusts for incorrect use of WidSTable when breaking a line (it breaks 6 chars too short)
|
private int COL_WID_ADJ = 6; // adjusts for incorrect use of WidSTable when breaking a line (it breaks 6 chars too short)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user