From 9456cc72142d8506e0a5b7e26013a23a032d1d80 Mon Sep 17 00:00:00 2001 From: Kathy Date: Wed, 24 Aug 2011 11:48:39 +0000 Subject: [PATCH] --- .../VEPROMS.CSLA.Library/Extension/ItemExt.cs | 107 +++++++++++------- 1 file changed, 64 insertions(+), 43 deletions(-) diff --git a/PROMS/VEPROMS.CSLA.Library/Extension/ItemExt.cs b/PROMS/VEPROMS.CSLA.Library/Extension/ItemExt.cs index 09025059..5ac341b3 100644 --- a/PROMS/VEPROMS.CSLA.Library/Extension/ItemExt.cs +++ b/PROMS/VEPROMS.CSLA.Library/Extension/ItemExt.cs @@ -2024,49 +2024,15 @@ namespace VEPROMS.CSLA.Library // Start with basic cases of alpha/numeric/seq: if (tbformat.IndexOf("{seq}") > -1) { - int level = 0; - ItemInfo par = this; - ItemInfo LastRNO = null; - while (!par.IsHigh) - { - if (par.IsRNOPart) LastRNO = par.MyParent; - if (!par.IsRNOPart && (par.IsSequential || (!(par.IsCaution || par.IsNote) - && ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.CountAllSubLevels))) - level++; - par = par.MyParent; - } - // ImperfectStructure is used so that the sequential numbering for substeps under an RNO is not same - // numbering (alpha vs numeric), if the HLS has substeps - WCNS uses this, as well as other plants. - if (ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.ImperfectStructure && IsSequential - && (LastRNO !=null) && LastRNO.IsHigh && LastRNO.HasChildren - && LastRNO.FirstChild(E_FromType.Step) != null && LastRNO.FirstChild(E_FromType.Step).IsSequential) - { - if (ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.ImperfectStructurePlus4) level += 2; - if (ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.ImperfectSubstep && !ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.ImperfectStructurePlus4) - level--; - } - // ImperfectStructure for substeps - only good for level 1 RNOs - else if (ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.ImperfectSubstep && RNOLevel == 1) - { - par = this; - while (!par.IsRNOPart) par = par.MyParent; // get to the rno. - if (par.MyParent.HasChildren) // if hls has children? - { - ItemInfo tchild = par.FirstChild(E_FromType.Step); - if (tchild != null) - { - int typ = (int)tchild.MyContent.Type - 20000; - if (ActiveFormat.PlantFormat.FormatData.StepDataList[typ].TabData.IdentPrint.Contains("{seq}")) - { - level++; - if (ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.ImperfectStructurePlus4) level += 1; - if (!ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.ImperfectStructurePlus4) level -= 1; - } - } - } - } + int bias = 0; + int level = GetStepLevel(ref bias); SeqTabFmtList seqtabs = ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.SeqTabFmtList; - tbformat = seqtabs[level % seqtabs.Count].PrintTabFormat; + int itmp = (level + bias) % seqtabs.Count; + tbformat = seqtabs[itmp].PrintTabFormat; // seqtab in 16bit, i.e. '. or )' etc. + string tbtoken = seqtabs[level % seqtabs.Count].TabToken; // seqstart in 16bit, number/letter + + tbformat = tbformat.Replace("{seq}", tbtoken); + // If token includes 'Wpar', the parent tab prefix's the tab. if (level > 0 && (tbformat.IndexOf("{numericWpar}") > -1 || tbformat.IndexOf("{alphaWpar}") > -1 || tbformat.IndexOf("{ALPHAWpar}") > -1)) { @@ -2114,7 +2080,7 @@ namespace VEPROMS.CSLA.Library // "{Null}" was introduced so that inheritance in format files could differentiate between an // empty string, and null. And also, so that if a tab was null but it's parent had text in the // tab, don't inherit the parent's tab, use a null. - if ((FormatStepData.Sep != null && FormatStepData.Sep !="{Null}")&& MyPrevious != null && FormatStepData.StepLayoutData.EveryNLines != 99) + if (MyPrevious != null && FormatStepData.Sep != null && FormatStepData.Sep != "{Null}") { if (_MyHeader == null) _MyHeader = new MetaTag(FormatStepData.TabData.Font); @@ -2164,6 +2130,61 @@ namespace VEPROMS.CSLA.Library _MyTab.CleanText = cltext != null ? cltext : tbformat; } + private string GetToken(string tbformat) + { + int stindx = tbformat.IndexOf("{"); + return (tbformat.Substring(stindx, tbformat.IndexOf("}")-stindx+1)); + } + + private int GetStepLevel(ref int bias) + { + int level = 0; + ItemInfo par = this; + ItemInfo LastRNO = null; + while (!par.IsHigh) + { + if (par.IsRNOPart) LastRNO = par.MyParent; + if (!par.IsRNOPart && (par.IsSequential || (!(par.IsCaution || par.IsNote) + && ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.CountAllSubLevels))) + level++; + par = par.MyParent; + } + bias = 0; + + // ImperfectStructure is used so that the sequential numbering for substeps under an RNO is not same + // numbering (alpha vs numeric), if the HLS has substeps - WCN uses this, as well as other plants. + if (ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.ImperfectStructure && IsSequential + && (LastRNO != null) && LastRNO.IsHigh && LastRNO.HasChildren + && LastRNO.FirstChild(E_FromType.Step) != null && LastRNO.FirstChild(E_FromType.Step).IsSequential) + { + level++; // 16bit has this: I didn't and mine worked most of time. + if (ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.ImperfectStructurePlus4) level += 2; + if (ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.ImperfectSubstep && !ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.ImperfectStructurePlus4) + bias = -1; + } + // ImperfectStructure for substeps - only good for level 1 RNOs + else if (ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.ImperfectSubstep && RNOLevel == 1) + { + par = this; + while (!par.IsRNOPart) par = par.MyParent; // get to the rno. + if (par.MyParent.HasChildren) // if parent has children? + { + ItemInfo tchild = par.MyParent.FirstChild(E_FromType.Step); + if (tchild != null) + { + int typ = (int)tchild.MyContent.Type - 20000; + if (ActiveFormat.PlantFormat.FormatData.StepDataList[typ].TabData.IdentPrint.Contains("{seq}")) + { + level++; + if (ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.ImperfectStructurePlus4) level += 1; + if (!ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.ImperfectStructurePlus4) bias = -1; + } + } + } + } + return level; + } + private string SectionPrefix(string tbformat) { // 16 bit has code that handles various levels of sections with a flag called TieTabToLevel. This