diff --git a/PROMS/VEPROMS.CSLA.Library/Config/FormatConfig.cs b/PROMS/VEPROMS.CSLA.Library/Config/FormatConfig.cs index 17aa07dd..2288d018 100644 --- a/PROMS/VEPROMS.CSLA.Library/Config/FormatConfig.cs +++ b/PROMS/VEPROMS.CSLA.Library/Config/FormatConfig.cs @@ -302,7 +302,8 @@ namespace VEPROMS.CSLA.Library Plackeep = 0x20000, // Do replace in PlaceKeepers InSecTitle = 0x40000, BeforeTrans = 0x80000, // Only do replace if the string occurs immediately before a transition. - BeforeList = 0x100000 // C2021-045 Only if the text ends with a colon ":" + BeforeList = 0x100000, // C2021-045 Only if the text ends with a colon ":" + PageList = 0x200000 // F2021-053 Do replace words for PageList items that are ROs } [Serializable] [TypeConverter(typeof(ExpandableObjectConverter))] diff --git a/PROMS/VEPROMS.CSLA.Library/Extension/DisplayText.cs b/PROMS/VEPROMS.CSLA.Library/Extension/DisplayText.cs index 67bd87cf..1426b645 100644 --- a/PROMS/VEPROMS.CSLA.Library/Extension/DisplayText.cs +++ b/PROMS/VEPROMS.CSLA.Library/Extension/DisplayText.cs @@ -258,6 +258,28 @@ namespace VEPROMS.CSLA.Library TextFont = vFont; StartText = CreateRtf(colorLinks, text, false, false, false, false, false, false, E_EditPrintMode.Edit); } + // F2021-053: BNPP Alarm - need ability to have super/sub scripts in the text of Alarm Tables (ROs). Added a + // constructor that allows for passing in a flag to set whether replace words should be done on page list. If doing + // on page list, the object has a section not a step associated with it. + private bool _DoReplWordInPageList = false; + public DisplayText(ItemInfo itemInfo, string text, bool colorLinks, bool dorepl) + { + _DoReplWordInPageList = dorepl; + _FieldToEdit = E_FieldToEdit.Text; + _MyItemInfo = itemInfo; + OriginalText = text; + TextFont = itemInfo.GetItemFont(); + _MyFormat = itemInfo.ActiveFormat; + + bool wordsShouldBeReplaced = true; + bool numbersShouldBeFormated = !_MyFormat.PlantFormat.FormatData.SectData.StepSectionData.FortranFormatNumbers; + int typ = ((int)itemInfo.MyContent.Type) % 10000; + bool ROsShouldBeAdjusted = wordsShouldBeReplaced; // same logical value + bool underlineAfterDashSpace = (itemInfo.FormatStepData == null) ? false : itemInfo.FormatStepData.UnderlineAfterDashSpace; + + text = CreateRtf(colorLinks, text, false, wordsShouldBeReplaced, numbersShouldBeFormated, false, ROsShouldBeAdjusted, underlineAfterDashSpace, E_EditPrintMode.Edit); + StartText = text; + } public DisplayText(ItemInfo itemInfo, string text, bool colorLinks) { _FieldToEdit = E_FieldToEdit.Text; @@ -272,7 +294,7 @@ namespace VEPROMS.CSLA.Library bool ROsShouldBeAdjusted = wordsShouldBeReplaced; // same logical value bool underlineAfterDashSpace = (itemInfo.FormatStepData == null) ? false : itemInfo.FormatStepData.UnderlineAfterDashSpace; - text = CreateRtf(colorLinks, text, false, wordsShouldBeReplaced, numbersShouldBeFormated, false, ROsShouldBeAdjusted, underlineAfterDashSpace,E_EditPrintMode.Edit); + text = CreateRtf(colorLinks, text, false, wordsShouldBeReplaced, numbersShouldBeFormated, false, ROsShouldBeAdjusted, underlineAfterDashSpace, E_EditPrintMode.Edit); StartText = text; // Shearon Harris Tables are Bold if (itemInfo.IsTable && (TextFont.Style & E_Style.Bold) == E_Style.Bold) @@ -2036,8 +2058,11 @@ namespace VEPROMS.CSLA.Library private string DoReplaceWords2(string Text) { if(!ProcessReplaceWords) return Text; - if (_MyItemInfo.MyContent.Type < 20000) return Text; // for now only replace in steps. - FoundMatches myMatches = new FoundMatches(Text,_MyItemInfo.FormatStepData.Font,_MyItemInfo); + // F2021-053: BNPP Alarm - need ability to have super/sub scripts in the text of Alarm Tables (ROs). + // if doing replace words for Page List items, the current item is not a step, use _DoReplWordInPageList flags this + if (_MyItemInfo.MyContent.Type < 20000 && !_DoReplWordInPageList) return Text; // for now only replace in steps. + VE_Font vf = _MyItemInfo.MyContent.Type >= 20000 ? _MyItemInfo.FormatStepData.Font : _MyItemInfo.ActiveFormat.PlantFormat.FormatData.Font; + FoundMatches myMatches = new FoundMatches(Text,vf,_MyItemInfo); // Exclude Link Text from Replace Word process myMatches.AddLink(regFindLink, _MyFormat.PlantFormat.FormatData.SectData.ReplaceWordsInROs, _MyItemInfo.MyProcedure.MyDocVersion); FormatConfig.ReplaceStrData rsl = _MyFormat.PlantFormat.UCFandOrigReplaceStrData; @@ -2066,7 +2091,7 @@ namespace VEPROMS.CSLA.Library // C2021-045 if the BeforeList ReplaceWords flag is set, only do the replace word if the text ends with a colon if (replaceit && onlyDoList && !Text.EndsWith(":")) replaceit = false; // text does not end with a colon so don't replace this word - + if (!replaceit && _DoReplWordInPageList) replaceit = true; // F2021-053: Do replace words in page list if (replaceit) { if (!dicReplaceRegex.ContainsKey(rs)) diff --git a/PROMS/VEPROMS.CSLA.Library/Format/ENums.cs b/PROMS/VEPROMS.CSLA.Library/Format/ENums.cs index a919e03c..9e90e718 100644 --- a/PROMS/VEPROMS.CSLA.Library/Format/ENums.cs +++ b/PROMS/VEPROMS.CSLA.Library/Format/ENums.cs @@ -228,7 +228,8 @@ namespace VEPROMS.CSLA.Library Plackeep = 0x20000, // Do replace in PlaceKeepers InSecTitle = 0x40000, BeforeTrans = 0x80000, // Only do replace if the string occurs immediately before a transition. - BeforeList = 0x100000 // C2021-045 Only if the text ends with a colon ":" + BeforeList = 0x100000, // C2021-045 Only if the text ends with a colon ":" + PageList = 0x200000 // F2021-053: Do replace words in page list } public enum E_ArrowKeys : uint { diff --git a/PROMS/VEPROMS.CSLA.Library/Format/PageStyles.cs b/PROMS/VEPROMS.CSLA.Library/Format/PageStyles.cs index b3b7878d..366a20eb 100644 --- a/PROMS/VEPROMS.CSLA.Library/Format/PageStyles.cs +++ b/PROMS/VEPROMS.CSLA.Library/Format/PageStyles.cs @@ -133,6 +133,14 @@ namespace VEPROMS.CSLA.Library return LazyLoad(ref _Justify, "@Justify"); } } + private LazyLoad _RepWords; // F2021-053: Do replace words in page list + public bool RepWords + { + get + { + return LazyLoad(ref _RepWords, "@RepWords"); + } + } private LazyLoad _MaxWidth; public int? MaxWidth { diff --git a/PROMS/Volian.Print.Library/VlnSvgPageHelper.cs b/PROMS/Volian.Print.Library/VlnSvgPageHelper.cs index b6befdbd..f7dca972 100644 --- a/PROMS/Volian.Print.Library/VlnSvgPageHelper.cs +++ b/PROMS/Volian.Print.Library/VlnSvgPageHelper.cs @@ -1393,6 +1393,14 @@ i = 0; // parts[1] - Which of the multiple return value from the RO to return // parts[2] - the value to use if not found in ROs - usually defined in a PSI field for that Alarm procedure string ROLookupVal = ROLookup(parts[0], parts[1], parts[2]); + + // F2021-053: Do replace words for Page List items. This uses a DisplayText constructor that flags this case + // and gets the resulting replaced words + if (pageItem.RepWords) + { + DisplayText dt1 = new DisplayText(MyPromsPrinter.MyItem, ROLookupVal, false, true); + ROLookupVal = dt1.StartText; + } pltok = pltok.Substring(0, idxstart) + ROLookupVal + ((idxstart + idxend < pltok.Length) ? pltok.Substring(idxstart + idxend + 1) : ""); } MatchCollection matches = regexFindToken.Matches(pltok);//(pageItem.Token); @@ -2629,6 +2637,10 @@ i = 0; private static SvgText PageItemToSvgText(VEPROMS.CSLA.Library.PageItem pageItem, string text, SectionInfo mySection) { SvgText svgText = new SvgText(); + // F2021-053: Do replace words for Page List items. Send format items down to svgtext. + SvgText.CompressSuper = mySection.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.CompressHPSuper; + SvgText.CompressSub = mySection.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.CompressHPSub; + SvgText.CompressPropSubSup = mySection.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.CompressPropSubSup; svgText.Text = text; VEPROMS.CSLA.Library.E_Justify justify = pageItem.Justify ?? VEPROMS.CSLA.Library.E_Justify.PSLeft; float colAdj16bit = 0; @@ -2752,6 +2764,10 @@ i = 0; int dotsPerChar = (int)(2400 / (MySection.MyDocStyle.Layout.PageWidth / 6)); lcol = (lcol * 25) / dotsPerChar; } + // F2021-053: Do replace words for Page List items. Send format items down to svgtext. + SvgText.CompressSuper = MySection.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.CompressHPSuper; + SvgText.CompressSub = MySection.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.CompressHPSub; + SvgText.CompressPropSubSup = MySection.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.CompressPropSubSup; svgText.Font = font.WindowsFont; svgText.X = new SvgMeasurement((float)lcol - colAdj16bit, E_MeasurementUnits.PT); // new SvgMeasurement((float)(pageItem.Col ?? 0), E_MeasurementUnits.PT); svgText.Y = new SvgMeasurement(row, E_MeasurementUnits.PT); diff --git a/PROMS/Volian.Svg.Library/iTextSharp.cs b/PROMS/Volian.Svg.Library/iTextSharp.cs index fce583f2..d85d4675 100644 --- a/PROMS/Volian.Svg.Library/iTextSharp.cs +++ b/PROMS/Volian.Svg.Library/iTextSharp.cs @@ -681,7 +681,10 @@ namespace Volian.Svg.Library ct.Go(); cb.RestoreState(); } - + // F2021-053: Do replace words for Page List items. Format flags to use for compressing and locating sub/super scripts + public static bool CompressSuper = false; + public static bool CompressSub = false; + public static bool CompressPropSubSup = false; private Phrase BuildPhrase(string text, float fontSize, int fontStyle, iTextSharp.text.Font font) { //if (text == "Caution") @@ -747,8 +750,23 @@ namespace Volian.Svg.Library else if (m.Value.Contains(@"\ul")) fontUnderline = true; if (m.Value.Contains(@"\up0") || m.Value.Contains(@"\dn0")) fontTextRise = 0; - else if (m.Value.Contains(@"\up")) fontTextRise = .25F; - else if (m.Value.Contains(@"\dn")) fontTextRise = -.25F; + else if (m.Value.Contains(@"\up")) + { + fontTextRise = .25F; + // F2021-053: Do replace words for Page List items. size and locate superscript + if (CompressSuper || CompressPropSubSup) + { + font = FontFactory.GetFont(font.Familyname, BaseFont.IDENTITY_H, BaseFont.EMBEDDED, fontSize * .75f, fontStyle, new Color(FillColor)); ; + fontTextRise = .33F; + } + } + else if (m.Value.Contains(@"\dn")) + { + fontTextRise = -.25F; + // F2021-053: Do replace words for Page List items. size subscript + if (CompressSub || CompressPropSubSup) + font = FontFactory.GetFont(font.Familyname, BaseFont.IDENTITY_H, BaseFont.EMBEDDED, fontSize * .75f, fontStyle, new Color(FillColor)); ; + } if (m.Value.Contains(@"\b0")) { fontStyle ^= iTextSharp.text.Font.BOLD;