From be20ad5e9c5bba7c4e99ee46462f5f6f74b26ca0 Mon Sep 17 00:00:00 2001 From: Kathy Date: Tue, 10 Aug 2010 10:51:21 +0000 Subject: [PATCH] --- .../Extension/DocumentExt.cs | 4 +- .../Extension/FormatExt.cs | 8 +++ .../VEPROMS.CSLA.Library/Extension/ItemExt.cs | 50 ++++++++++++++++--- 3 files changed, 52 insertions(+), 10 deletions(-) diff --git a/PROMS/VEPROMS.CSLA.Library/Extension/DocumentExt.cs b/PROMS/VEPROMS.CSLA.Library/Extension/DocumentExt.cs index a7958210..931ce58f 100644 --- a/PROMS/VEPROMS.CSLA.Library/Extension/DocumentExt.cs +++ b/PROMS/VEPROMS.CSLA.Library/Extension/DocumentExt.cs @@ -543,8 +543,8 @@ namespace VEPROMS.CSLA.Library sel.ParagraphFormat.LineSpacingRule = LBWdLineSpacing.wdLineSpaceExactly; sel.ParagraphFormat.LineSpacing = 12; fileName = CreatePDF(fileName, openPdf); - MyApp.ActiveDocument.Close(); - MyApp.Quit(); + MyApp.ActiveDocument.Close(false); + MyApp.Quit(false); _MyApp = null; return fileName; } diff --git a/PROMS/VEPROMS.CSLA.Library/Extension/FormatExt.cs b/PROMS/VEPROMS.CSLA.Library/Extension/FormatExt.cs index 42f755f1..b2dd841c 100644 --- a/PROMS/VEPROMS.CSLA.Library/Extension/FormatExt.cs +++ b/PROMS/VEPROMS.CSLA.Library/Extension/FormatExt.cs @@ -76,6 +76,14 @@ namespace VEPROMS.CSLA.Library return MyParent.Description + " - " + Description + " (" + Name + ")"; } } + public StepSectionLayoutData MyStepSectionLayoutData + { + get { return PlantFormat.FormatData.SectData.StepSectionData.StepSectionLayoutData; } + } + public StepSectionPrintData MyStepSectionPrintData + { + get { return PlantFormat.FormatData.SectData.StepSectionData.StepSectionPrintData; } + } } public partial class FormatInfoList { diff --git a/PROMS/VEPROMS.CSLA.Library/Extension/ItemExt.cs b/PROMS/VEPROMS.CSLA.Library/Extension/ItemExt.cs index 37775f64..ca51f1d8 100644 --- a/PROMS/VEPROMS.CSLA.Library/Extension/ItemExt.cs +++ b/PROMS/VEPROMS.CSLA.Library/Extension/ItemExt.cs @@ -287,6 +287,15 @@ namespace VEPROMS.CSLA.Library #region ItemInfo public partial class ItemInfo:IVEDrillDownReadOnly { + public bool IsFirstSubStep + { + get + { + if (!IsStepPart) return false; + if (IsHigh) return false; + return (MyPrevious == null); + } + } #region StepLevel private int _StepLevel = -2;// Not yet calculated public int StepLevel @@ -355,41 +364,66 @@ namespace VEPROMS.CSLA.Library { if(item == null) return 0; int id=0; - if(item.ItemID == 507) - id = item.ItemID; + // Determines the substep level. int level = CountLevels(item); - int firstInc = item.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.StepSectionLayoutData.PaginateOnFirstSubstep ? 0 : 1; + + // PaginateOnFirstSubstep allows orphans, first child can be separated from its parent. + int firstInc = item.ActiveFormat.MyStepSectionLayoutData.PaginateOnFirstSubstep ? 0 : 1; ItemInfo parent = item.ActiveParent as ItemInfo; + + // TODO: Format flag 'TreatAsSequential': + // The following needs to account for use of format flag 'TreatAsSequential' when doing + // formats that have it. if (item.IsExactType("And") || item.IsExactType("Or") || item.IsExactType("ImplicitOr")) level++; if (parent != null && (parent.IsExactType("And") || parent.IsExactType("Or"))) level++; + + // First substep, this is where it uses the orphan logic from above. if (!item.IsRNOPart && !item.IsHigh && item.MyPrevious == null) - level+=firstInc; + level += firstInc; + else + firstInc = 0; + + // Try not to paginate on a step that has Cautions & Notes, keep the Caution/Note with + // the step. if (item.IsStepPart) { if (item.Cautions != null || item.Notes != null) level += 2; } - else if (item.IsCautionPart) + // Paginate before first caution, not between cautions. + else if (item.IsCautionPart) { if (item.MyPrevious == null) level-=(1 + firstInc); else level++; } + // Paginate before first note, if the step does not have a caution. + // Otherwise, try to keep the notes together. else if (item.IsNotePart) { if (parent.Cautions == null && item.MyPrevious == null) level-=(1 + firstInc); else level++; } + // Try not to paginate on a table. else if (item.IsTablePart) { level += 2; } + // For an RNO to the right, make it the same level as the AER item. else if(item.IsRNOPart) { + level = (item.ActiveParent as ItemInfo).StepLevel + item.RNOLevel - item.ColumnMode; } return level; } + + /// + /// Count all levels, including substeps within RNOs. Ignore RNOs that are to the right of + /// the AER, but count those that are below higher level RNOs. + /// + /// + /// private static int CountLevels(ItemInfo item) { int level = 0; @@ -399,7 +433,7 @@ namespace VEPROMS.CSLA.Library if (ignoreRNOs > 0 && item.IsRNOPart) ignoreRNOs--; else - level++; // need logic to not increment for RNOs less than MaxRNO + level++; item = item.ActiveParent as ItemInfo; } return level; @@ -829,7 +863,7 @@ namespace VEPROMS.CSLA.Library //if (si.SectionConfig.Section_ColumnMode != SectionConfig.SectionColumnMode.Default) return (int)si.SectionConfig.Section_ColumnMode - 1; } - return (ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.StepSectionLayoutData.PMode ?? 2) -1; + return (ActiveFormat.MyStepSectionLayoutData.PMode ?? 2) -1; } } /// @@ -2147,7 +2181,7 @@ namespace VEPROMS.CSLA.Library if (ii.MyContent.Type == MyContent.Type) count++; ii = ii.NextItem; } - if (count < macro.Grouping) addToList = false; + if (count <= macro.Grouping) addToList = false; } if (addToList) tmp.Add(macro); }