diff --git a/PROMS/VEPROMS.CSLA.Library/Extension/ItemExt.cs b/PROMS/VEPROMS.CSLA.Library/Extension/ItemExt.cs index e53e9cd1..e0440eeb 100644 --- a/PROMS/VEPROMS.CSLA.Library/Extension/ItemExt.cs +++ b/PROMS/VEPROMS.CSLA.Library/Extension/ItemExt.cs @@ -1099,6 +1099,7 @@ namespace VEPROMS.CSLA.Library case 2: // step types int typindx = type - 20000; // what to do for other types rather than steps font = format.PlantFormat.FormatData.StepDataList[typindx].Font; + if (IsParagraph) font = AdjustForTextSubFollowsTextStyle(font); break; } } @@ -1108,6 +1109,24 @@ namespace VEPROMS.CSLA.Library } return font; } + + protected VE_Font AdjustForTextSubFollowsTextStyle(VE_Font font) + { + if (FormatStepData.TextSubFollowsTextStyle && ParentNoteOrCaution != null) + { + bool isBold = (FormatStepData.Font.Style & E_Style.Bold) > 0; + bool isMmBold = (FormatStepData.Font.Style & E_Style.MmBold) > 0; + font = ParentNoteOrCaution.FormatStepData.Font; + E_Style myStyle = (E_Style) font.Style; + myStyle ^= (myStyle & E_Style.Bold); + myStyle ^= (myStyle & E_Style.MmBold); + myStyle |= isBold ? E_Style.Bold : 0; + myStyle |= isMmBold ? E_Style.MmBold : 0; + if (myStyle != font.Style) + font = new VE_Font(font.Family, (int)font.Size, myStyle); + } + return font; + } private string RemoveToken(string str, string token) { // if this token is preceeded by another token and followed by a space @@ -1655,7 +1674,7 @@ namespace VEPROMS.CSLA.Library { if (IsStep) { - MyTab = new Tab(FormatStepData.TabData.Font); + MyTab = new Tab(AdjustForTextSubFollowsTextStyle(FormatStepData.TabData.Font)); MyHeader = new MetaTag(FormatStepData.TabData.Font); MyFooter = new MetaTag(FormatStepData.TabData.Font); SetTabText(); @@ -1808,14 +1827,14 @@ namespace VEPROMS.CSLA.Library StepData nextStepData = null; if (MyPrevious != null) { - int prevStepType = ((int)MyPrevious.MyContent.Type) % 10000; - StepData prevStepData = ActiveFormat.PlantFormat.FormatData.StepDataList[prevStepType]; + // int prevStepType = ((int)MyPrevious.MyContent.Type) % 10000; + StepData prevStepData = MyPrevious.FormatStepData; // ActiveFormat.PlantFormat.FormatData.StepDataList[prevStepType]; prevTbFormat = MyPrevious.IsInRNO ? prevStepData.TabData.RNOIdentPrint : prevStepData.TabData.IdentPrint; } if (NextItem != null) { - int nextStepType = ((int)NextItem.MyContent.Type) % 10000; - nextStepData = ActiveFormat.PlantFormat.FormatData.StepDataList[nextStepType]; + //int nextStepType = ((int)NextItem.MyContent.Type) % 10000; + nextStepData = NextItem.FormatStepData; // ActiveFormat.PlantFormat.FormatData.StepDataList[nextStepType]; // tried to duplicate functionality from 16-bit code. nextTbFormat = NextItem.IsInRNO ? nextStepData.TabData.RNOIdentPrint : nextStepData.TabData.IdentPrint; } @@ -1914,6 +1933,31 @@ namespace VEPROMS.CSLA.Library } } #endregion + #region ParentNoteOrCaution + private bool _ParentNoteOrCautionLoaded = false; + private ItemInfo _ParentNoteOrCaution; + public ItemInfo ParentNoteOrCaution + { + get + { + if (!_ParentNoteOrCautionLoaded) + { + ItemInfo parent = ActiveParent as ItemInfo; + if (parent != null) + { + if (parent.IsCautionPart || parent.IsNotePart) + _ParentNoteOrCaution = parent; + else + { + _ParentNoteOrCaution = parent.ParentNoteOrCaution; + } + } + _ParentNoteOrCautionLoaded = true; + } + return _ParentNoteOrCaution; + } + } + #endregion #region Macro List [NonSerialized] protected List _MyMacros; @@ -1932,12 +1976,15 @@ namespace VEPROMS.CSLA.Library } private void SetupMacros() { + if (FormatStepData == null) return; // see if each macro should be printed based on its attributes and the item we're on. // Attributes to check are NotInRNO, i.e. only add this macro to the result list if // the item is not in the RNO column. Also, Groupings is used to only have the macro if // there are N or more of the type in the grouping. List tmp = new List(); - foreach (Macro macro in ActiveFormat.PlantFormat.FormatData.StepDataList[FormatStepType].TabData.MacroList) + StepData myStepData = (FormatStepData.TextSubFollowsTextStyle && ParentNoteOrCaution != null) ? ParentNoteOrCaution.FormatStepData : FormatStepData; + // foreach (Macro macro in ActiveFormat.PlantFormat.FormatData.StepDataList[FormatStepType].TabData.MacroList) + foreach (Macro macro in myStepData.TabData.MacroList) { bool addToList = true; if (macro.NotInRNO && IsInRNO) addToList = false; @@ -2764,7 +2811,7 @@ namespace VEPROMS.CSLA.Library public override void SetupTags() { _TagsSetup = true; - MyTab = new Tab(FormatStepData.TabData.Font); + MyTab = new Tab(AdjustForTextSubFollowsTextStyle(FormatStepData.TabData.Font)); MyHeader = new MetaTag(FormatStepData.TabData.Font); MyFooter = new MetaTag(FormatStepData.TabData.Font); SetTabText();