diff --git a/PROMS/VEPROMS.CSLA.Library/Extension/ItemExt.cs b/PROMS/VEPROMS.CSLA.Library/Extension/ItemExt.cs index 807c2dc4..46966861 100644 --- a/PROMS/VEPROMS.CSLA.Library/Extension/ItemExt.cs +++ b/PROMS/VEPROMS.CSLA.Library/Extension/ItemExt.cs @@ -344,6 +344,15 @@ namespace VEPROMS.CSLA.Library return (MyPrevious == null); } } + public bool IsAutoTOCSection + { + get + { + if (!IsSection) return false; + return ((ActiveFormat.PlantFormat.FormatData.PurchaseOptions & E_PurchaseOptions.AutoTableOfContents) == E_PurchaseOptions.AutoTableOfContents && + (MyDocStyle.StructureStyle.Style & E_DocStructStyle.TableOfContents) == E_DocStructStyle.TableOfContents); + } + } #region StepLevel private int _StepLevel = -2;// Not yet calculated public int StepLevel @@ -1679,7 +1688,7 @@ namespace VEPROMS.CSLA.Library public System.Collections.IList GetChildren() { _PartInfoList = this.MyContent.ContentParts; - if (_PartInfoList.Count == 1 && ( _PartInfoList[0].ToString() == "Sections" || _PartInfoList[0].ToString() == "Steps")) + if (_PartInfoList.Count == 1 && ((IsProcedure && _PartInfoList[0].ToString() == "Sections") || _PartInfoList[0].ToString() == "Steps")) return _PartInfoList[0].GetChildren(); return _PartInfoList; } @@ -1688,7 +1697,8 @@ namespace VEPROMS.CSLA.Library _PartInfoList = this.MyContent.ContentParts; if (allParts) { - if (_PartInfoList.Count == 1 && (_PartInfoList[0].ToString() == "Sections" || _PartInfoList[0].ToString() == "Steps")) + if (_PartInfoList.Count == 1 && ((IsProcedure && _PartInfoList[0].ToString() == "Sections") || _PartInfoList[0].ToString() == "Steps")) + return _PartInfoList[0].GetChildren(); return _PartInfoList; } @@ -2148,7 +2158,7 @@ namespace VEPROMS.CSLA.Library _MyHeader.CleanText = StripRtfFormatting(_MyHeader.Text); _MyHeader.Justify = ContentAlignment.MiddleCenter; } - #region Non HLP tab TODO + #region Non Converted Plants tab TODO // other possible 'tokens' // Position offset - do this one here, so don't get background substitution below.. // ##-3# - Offset of -3 from Parent (FNP) @@ -2160,11 +2170,6 @@ namespace VEPROMS.CSLA.Library //"{LNK C/N Num}" //"{LNK Step Num}" - //Section Numbers - // % - Prefix with section number (works string in 16 bit, ie.e For 4.3 the prefix becomes 4. - // wid that would be stored. - //"{Section Prefix}" - // Position offset // \257 - Indent (CALLOWAY BACKGROUNDS) // Newline within a tab (calbck) @@ -2254,8 +2259,12 @@ namespace VEPROMS.CSLA.Library ItemInfo ii = ActiveSection.MyParent; while (!ii.IsProcedure) { - // the following line must also include a check for the section config autoindent flag - if (ii.DisplayNumber != null && ii.DisplayNumber != "") countlev++; + if (ii.DisplayNumber != null && ii.DisplayNumber != "") + { + SectionConfig sc = MyActiveSection.MyConfig as SectionConfig; + if (sc != null && sc.SubSection_AutoIndent == "Y") + countlev++; + } ii = ii.MyParent; } } @@ -2263,34 +2272,48 @@ namespace VEPROMS.CSLA.Library } private string SectionPrefix(string tbformat) { - // If the Section's 'tab' is a character or has a character preceding the '.' is an alpha character, - // just return the alpha (no '.') - // If the character preceding the '. 'is a number, return the section tab up to and including the '.' - // Otherwise, just return the section tab. - - // Before checking for anything, if the DisplayNumber starts with 'ATTACHMENT ', don't use that in the Section - // prefix for the tabstring. - string attNum = ActiveSection.DisplayNumber.ToUpper().StartsWith("ATTACHMENT ") ? ActiveSection.DisplayNumber.Substring(11) : ActiveSection.DisplayNumber; - Match m = Regex.Match(attNum, @"[a-zA-Z]"); // for alpha, use non-touched displaynumber - int indx = -1; - if (m.Success) + // if not metasection/tietabtolevel, return the 'section number'. (where the '.' may or may not exist) + if (!ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.StepSectionLayoutData.TieTabToLevel) { - indx = attNum.IndexOf("."); - if (indx < 0) return attNum; - return attNum.Substring(0, indx); + int indx = ActiveSection.MyTab.CleanText.IndexOf("."); + if (indx > 0) return ActiveSection.MyTab.CleanText.Substring(0, indx + 1); // include the '.' + return ActiveSection.MyTab.CleanText.TrimEnd(); } - if (IsHigh && ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.StepSectionLayoutData.TieTabToLevel) + + // the rest of this is for metasections (tietabtolevel format flag) + + SectionInfo si = SectionInfo.Get(ActiveSection.ItemID); + // A 'TrueSectionNum' must have a '.' and cannot have lettters after the '.'. + if (si != null && si.TrueSectionNum()) { - int subsection = CurrentSectionLevel(); - if (subsection >= 1) + string attNum = ActiveSection.DisplayNumber; // ActiveSection.DisplayNumber.ToUpper().StartsWith("ATTACHMENT ") ? ActiveSection.DisplayNumber.Substring(11) : ActiveSection.DisplayNumber; + // If section number is of form '1.0', return '1.' + if (attNum.Length > 1 && attNum[attNum.Length - 1] == '0' && attNum[attNum.Length - 2] == '.') + return attNum.Substring(0, attNum.Length - 1); + // If section number is of form '1', return '1.' + else if (attNum.Length > 0 && attNum[attNum.Length - 1] != '.') + return attNum + '.'; + } + // For the docstyle flag DSS_TreatAsTrueSectNum, look for last space, and if one is + // found, the the Section Prefix is the text after the space with a '.' appended - for + // example, 'Attachment A' becomes 'A.'. + if ((MyDocStyle.StructureStyle.Style ?? 0 & E_DocStructStyle.DSS_TreatAsTrueSectNum) != 0) + { + int lindx = ActiveSection.DisplayNumber.LastIndexOf(" "); + if (lindx > 0) { - string tmptab = ActiveSection.MyTab.CleanText.TrimEnd(); - if (tmptab.LastIndexOf(".") != tmptab.Length - 1) tmptab = tmptab + "."; - return tmptab; + return ActiveSection.DisplayNumber.Substring(lindx + 1) + "."; } } - indx = ActiveSection.MyTab.CleanText.IndexOf("."); - if (indx > 0) return ActiveSection.MyTab.CleanText.Substring(0,indx+1); // include the '.' + + // If we're in a subsection, be sure there is a '.' at the end. + int subsection = CurrentSectionLevel(); + if (subsection >= 1) + { + string tmptab = ActiveSection.MyTab.CleanText.TrimEnd(); + if (tmptab.LastIndexOf(".") != tmptab.Length - 1) tmptab = tmptab + "."; + return tmptab; + } return ActiveSection.MyTab.CleanText.TrimEnd(); } @@ -3369,7 +3392,7 @@ namespace VEPROMS.CSLA.Library int indx = DisplayNumber.IndexOf("."); if (indx < 0 || indx + 1 == DisplayNumber.Length) return false; // for it to be a 'TrueSectionNum', there can be no letters after the '.' - for (int lindx = indx; lindx < DisplayNumber.Length - 1; lindx++) if (DisplayNumber[lindx] < '0' || DisplayNumber[lindx] > '9') return false; + for (int lindx = indx+1; lindx < DisplayNumber.Length - 1; lindx++) if (DisplayNumber[lindx] < '0' || DisplayNumber[lindx] > '9') return false; return true; } // the following returns the 'index' into the format's CheckOffHeaderList.