diff --git a/PROMS/VEPROMS.CSLA.Library/Format/PlantFormat.cs b/PROMS/VEPROMS.CSLA.Library/Format/PlantFormat.cs index de424b16..6fd11b59 100644 --- a/PROMS/VEPROMS.CSLA.Library/Format/PlantFormat.cs +++ b/PROMS/VEPROMS.CSLA.Library/Format/PlantFormat.cs @@ -1977,6 +1977,15 @@ namespace VEPROMS.CSLA.Library } set { _ReplaceStrList = value; } } + private ReplaceSymbolCharList _ReplaceSymbolCharList; + public ReplaceSymbolCharList ReplaceSymbolCharList + { + get + { + return (_ReplaceSymbolCharList == null) ? _ReplaceSymbolCharList = new ReplaceSymbolCharList(SelectNodes("ReplaceSymbolChars/ReplaceChar")) : _ReplaceSymbolCharList; + } + set { _ReplaceSymbolCharList = value; } + } private LazyLoad _SectionTitleLength; public int? SectionTitleLength { @@ -2999,6 +3008,90 @@ namespace VEPROMS.CSLA.Library public ReplaceStrList(XmlNodeList xmlNodeList) : base(xmlNodeList) { } } #endregion + #region ReplaceChar + [TypeConverter(typeof(ExpandableObjectConverter))] + public class ReplaceChar : vlnFormatItem + { + public ReplaceChar(XmlNode xmlNode) : base(xmlNode) { } + public ReplaceChar() : base() { } + [Category("Strings")] + private LazyLoad _Unicode; + public string Unicode + { + get + { + return LazyLoad(ref _Unicode, "@Unicode"); + } + } + [Category("Strings")] + private LazyLoad _Replace; + public string Replace + { + get + { + return LazyLoad(ref _Replace, "@Replace"); + } + } + [Category("Strings")] + private LazyLoad _Family; + public string Family + { + get + { + return LazyLoad(ref _Family, "@Family"); + } + } + [Category("FontStyle?")] + private LazyLoad _Style; // format has E_Style value. The public will translate it to a systemdrawing.FontStyle used in printing + public FontStyle? Style + { + get + { + E_Style? eStyle = LazyLoad(ref _Style, "@Style"); + if (eStyle == null) return null; // not set in the format, return null + FontStyle sdfStyle = FontStyle.Regular; + if (eStyle != E_Style.None) + { + if (((eStyle & E_Style.Bold) != 0) || ((eStyle & E_Style.MmBold) != 0)) + sdfStyle |= FontStyle.Bold; + if ((eStyle & E_Style.Italics) != 0) + sdfStyle |= FontStyle.Italic; + if ((eStyle & E_Style.Underline) != 0) + sdfStyle |= FontStyle.Underline; + } + return sdfStyle; // return systemdrawing.FontStyle + //return LazyLoad(ref _Style, "@Style"); + } + } + [Category("float?")] + private LazyLoad _Size; + public float? Size + { + get + { + return LazyLoad(ref _Size, "@Size"); + } + } + //public override string GetPDDisplayName() + //{ return Unicode; } + //public override string GetPDDescription() + //{ return string.Format("Replace '{0}' with '{1}'", Unicode, Replace); } + //public override string GetPDCategory() + //{ return "Chars to Replace"; } + //public override string ToString() + //{ + // return Replace; + //} + } + + #endregion + #region ReplaceSymbolCharList + [TypeConverter(typeof(vlnListConverter))] + public class ReplaceSymbolCharList : vlnFormatList + { + public ReplaceSymbolCharList(XmlNodeList xmlNodeList) : base(xmlNodeList) { } + } + #endregion #region StepSectionLayoutData public class StepSectionLayoutData : vlnFormatItem { diff --git a/PROMS/Volian.Print.Library/Grid2Pdf.cs b/PROMS/Volian.Print.Library/Grid2Pdf.cs index 49d2d96c..1ef6fdd2 100644 --- a/PROMS/Volian.Print.Library/Grid2Pdf.cs +++ b/PROMS/Volian.Print.Library/Grid2Pdf.cs @@ -760,7 +760,7 @@ namespace Volian.Print.Library str = _StatRTB.Rtf; return str; } - public static iTextSharp.text.Paragraph RtfToParagraph(string rtf, iTextSharp.text.Font mySymFont) + private iTextSharp.text.Paragraph RtfToParagraph(string rtf, iTextSharp.text.Font mySymFont) { rtf=FixRTFToPrint(rtf); IRtfDocument rtfDoc = RtfInterpreterTool.BuildDoc(rtf); @@ -777,15 +777,36 @@ namespace Volian.Print.Library /// /// /// - private static string FixRTFToPrint(string rtf) + private string FixRTFToPrint(string rtf) { // Only do this if the text contains symbols. if (rtf.Contains("VESymbFix")) { System.Windows.Forms.RichTextBox rtb = new System.Windows.Forms.RichTextBox(); - rtb.Rtf = rtf; + rtb.Rtf = rtf.Replace(@"\u9586?", "");// rename backslash character to avoid RTF confusion string strRTF = rtf; bool changed = false; + // C2017-008 - WCN wants the box symbol to look like their checkoff/signoff box + // Check for a list of replacement character for symbols in the format file + // ReplaceSymbolChars lets you do one or more of the following with a symbol character: + // - change the point size + // - change the style + // - change the font family + // - change the symbol character + // + // below is taken from the BaseAll format file - is currently commentout and there for reference + // Wolf Creek (WCN) currently uses this to increase the size of the box symbol + // + // + // + // + // get the list of symbol replacements + FormatData fmtdata = (MyFlexGrid.MyDVI != null) ? MyFlexGrid.MyDVI.ActiveFormat.PlantFormat.FormatData : FormatInfo.PROMSBaseFormat.FormatData; + ReplaceSymbolCharList SymReplaceList = (fmtdata != null && fmtdata.SectData.ReplaceSymbolCharList != null) ? fmtdata.SectData.ReplaceSymbolCharList : null; // Look at one character at a time for (int i = 0; i < rtb.TextLength; i++) { @@ -806,8 +827,26 @@ namespace Volian.Print.Library rtb.SelectionFont = new System.Drawing.Font(DefaultFont, fnt.Style); changed = true; } + if (rtb.SelectionFont.FontFamily.Name == "VESymbFix" && rtb.SelectedText.Length > 0) + { + foreach (ReplaceChar rc in SymReplaceList) + { + if (rc.Unicode != null) + { + char rc_uchar = Convert.ToChar(Convert.ToInt32(rc.Unicode)); + if (rc_uchar == rtb.SelectedText[0]) + { + //use bolding underline italics from local font + System.Drawing.Font fnt = rtb.SelectionFont; + System.Drawing.Font fntw = new System.Drawing.Font((rc.Family != null) ? rc.Family : fnt.FontFamily.Name, (rc.Size != null) ? (float)rc.Size : fnt.Size, (rc.Style != null) ? (System.Drawing.FontStyle)rc.Style : fnt.Style); + rtb.SelectionFont = fntw; + changed = true; + } + } + } + } } - if (changed) return rtb.Rtf; + if (changed) return rtb.Rtf.Replace("", @"\u9586?"); } return rtf; } diff --git a/PROMS/Volian.Print.Library/vlnParagraph.cs b/PROMS/Volian.Print.Library/vlnParagraph.cs index e4c0a6a6..8a56f2d0 100644 --- a/PROMS/Volian.Print.Library/vlnParagraph.cs +++ b/PROMS/Volian.Print.Library/vlnParagraph.cs @@ -4323,8 +4323,67 @@ namespace Volian.Print.Library Rtf = Rtf.Replace("{Backspace}", ""); } } + Rtf = FixRTFToPrint(Rtf); ProfileTimer.Pop(profileDepth); } + private string FixRTFToPrint(string rtf) + { + // Only do this if the text contains symbols. + if (rtf.Contains("VESymbFix")) + { + System.Windows.Forms.RichTextBox rtb = new System.Windows.Forms.RichTextBox(); + rtb.Rtf = rtf.Replace(@"\\",""); // rename backslash character to avoid RTF confusion + //string showRTF = rtf; + bool changed = false; + // C2017-008 - WCN wants the box symbol to look like their checkoff/signoff box + // Check for a list of replacement character for symbols in the format file + // ReplaceSymbolChars lets you do one or more of the following with a symbol character: + // - change the point size + // - change the style + // - change the font family + // - change the symbol character + // + // below is taken from the BaseAll format file - is currently commentout and there for reference + // Wolf Creek (WCN) currently uses this to increase the size of the box symbol + // + // + // + // + // get the list of symbol replacements + FormatData fmtdata = (MyItemInfo.MyDocVersion != null) ? MyItemInfo.MyDocVersion.ActiveFormat.PlantFormat.FormatData : FormatInfo.PROMSBaseFormat.FormatData; + ReplaceSymbolCharList SymReplaceList = (fmtdata != null && fmtdata.SectData.ReplaceSymbolCharList != null) ? fmtdata.SectData.ReplaceSymbolCharList : null; + // Look at one character at a time + for (int i = 0; i < rtb.TextLength; i++) + { + rtb.Select(i, 1); + if (rtb.SelectionFont.FontFamily.Name == "VESymbFix" && rtb.SelectedText.Length > 0) + { + foreach (ReplaceChar rc in SymReplaceList) + { + if (rc.Unicode != null) + { + char rc_uchar = Convert.ToChar(Convert.ToInt32(rc.Unicode)); + if (rc_uchar == rtb.SelectedText[0]) + { + //use bolding underline italics from local font + System.Drawing.Font fnt = rtb.SelectionFont; + System.Drawing.Font fntw = new System.Drawing.Font((rc.Family != null)?rc.Family:fnt.FontFamily.Name, (rc.Size != null)?(float)rc.Size:fnt.Size, (rc.Style != null)?(System.Drawing.FontStyle)rc.Style:fnt.Style); + rtb.SelectionFont = fntw; + changed = true; + } + } + } + } + } + if (changed) return rtb.Rtf.Replace("",@"\\"); // put back the backslash character + } + return rtf; + } + // for Calvert (BGE) alarms, some step text is kept on the same line as its parent. This // is flagged by the -1 row in the template definition. private bool KeepOnParentLine(ItemInfo itemInfo)