From 7a0edda568f66632a447832c1c25a8337078d118 Mon Sep 17 00:00:00 2001 From: John Date: Wed, 1 Aug 2018 15:05:22 +0000 Subject: [PATCH] C2018-017 Put description of all know symbol characters in the baseline meta file C2018-018 Put the contents of the Word sections in the baseline meta file --- .../Extension/DisplayText.cs | 299 +++++++++++++++++- .../Extension/DocumentExt.cs | 38 ++- 2 files changed, 332 insertions(+), 5 deletions(-) diff --git a/PROMS/VEPROMS.CSLA.Library/Extension/DisplayText.cs b/PROMS/VEPROMS.CSLA.Library/Extension/DisplayText.cs index 8510291b..f1fcadcb 100644 --- a/PROMS/VEPROMS.CSLA.Library/Extension/DisplayText.cs +++ b/PROMS/VEPROMS.CSLA.Library/Extension/DisplayText.cs @@ -2376,5 +2376,302 @@ namespace VEPROMS.CSLA.Library _MyWord = myWord; } } - + public class TextForBaseline + { + // put the symbol description in the baseline metafile output + public static string MetaSymbolText(string str) + { + string rtnVal = str; + FormatData fmtdata = FormatInfo.PROMSBaseFormat.FormatData; + if (fmtdata != null && fmtdata.SymbolList != null) + { + SymbolList sl = fmtdata.SymbolList; + if (sl != null) + { + foreach (Symbol sym in sl) + rtnVal = rtnVal.Replace(((char)sym.Unicode).ToString(), string.Format("[{0}]", sym.Desc)); //C2018-017 output symbol description from fromat file + } + } + return rtnVal; + } + public static string FixText(string str) // C2018-004 create meta file for baseline compares + { + return FixText(str, false); + } + public static string FixText(string str, bool doingWordDoc) // C2018-004 create meta file for baseline compares + { + // put a description of know symbols and ascii commands inbetween square brackets + if (str == null) return null; + str = MetaSymbolText(str); // C2018-017 replace know symbol character with text description + StringBuilder sb = new StringBuilder(); + foreach (char c in str) + { + if (c < '\x1F' || c > '\x7F') + { + int i = (int)c; + switch (i) + { + case '\u0005': + sb.Append("[HngInd]"); // Hanging Indent char (for 16-bit) also used in MS Word tables for cell borders + break; + case '\u000A': + sb.Append("[LF]"); // line feed + break; + case '\u00A0': + sb.Append("[HS]"); // hard space + break; + case '\u2011': + sb.Append("[NBDash]"); // non-breaking dash + break; + case '\u000D': + sb.Append("[CR]"); // carriage return + break; + case '\uF0C9': + sb.Append("[dbxULC]"); // upper left cornner double line box + break; + case '\uF0BB': + sb.Append("[dbxURC]"); //upper right cornner double line box + break; + case '\uF0C8': + sb.Append("[dbxLLC]"); // lower left cornner double line box + break; + case '\uF0BC': + sb.Append("[dbxLRC]"); // lower right cornner double line box + break; + case '\uF0CD': + sb.Append("[dbxHZ]"); // horz double line box + break; + case '\uF0BA': + sb.Append("[dbxVT]"); // vertial double line box + break; + case '\uF0CC': + sb.Append("[dbxLM]"); // Left Midddle double line box + break; + case '\uF0B9': + sb.Append("[dbxRM]"); // right Midddle double line box + break; + case '\uF0CB': + sb.Append("[dbxDM]"); // down Midddle double line box + break; + case '\uF0CA': + sb.Append("[dbxUM]"); // up Midddle double line box + break; + case '\uF0CE': + sb.Append("[dbxMI]"); // Midddle intersection double line box + break; + case '\uF0D7': + sb.Append("[bxMIVDL]"); // Midddle intersection Single line box Vertial double line + break; + case '\uF0D8': + sb.Append("[dbxMIVSL]"); // Midddle intersection double line box Vertial Single line + break; + case '\uF0D1': + sb.Append("[dbxSLD]"); //double line to single line down + break; + case '\uF0CF': + sb.Append("[dbxSLU]"); //double line to single line Up + break; + case '\uF0C7': + sb.Append("[dbxSL]"); //double line to single line left + break; + case '\uF0B6': + sb.Append("[dbxSR]"); //double line to single line right + break; + case '\uF0D2': + sb.Append("[bxDLD]"); //single line to double line down + break; + case '\uF0D0': + sb.Append("[bxDLU]"); //single line to double line up + break; + case '\uF0DA': + case '\u250C': + sb.Append("[bxULC]"); //upper left cornner single line box + break; + case '\uF0BF': + case '\u2510': + sb.Append("[bxURC]"); //upper right cornner single line box + break; + case '\uF0C0': + case '\u2514': + sb.Append("[bxLLC]"); //lower left cornner single line box + break; + case '\uF0D9': + case '\u2518': + sb.Append("[bxLRC]"); //lower right cornner single line box + break; + case '\uF0C4': + case '\u2500': + sb.Append("[bxHZ]"); // horz single line box + break; + case '\uF0B3': + sb.Append("[bxVT]"); // Vertial single line box + break; + case '\uF0C5': + case '\u253C': + sb.Append("[bxMI]"); // middle intersection single line box + break; + case '\uF0B4': + case '\u2524': + sb.Append("[bxMR]"); // middle right single line box + break; + case '\uF0C3': + case '\u251C': + sb.Append("[bxML]"); // middle left single line box + break; + case '\uF0B5': + sb.Append("[bxMDLL]"); // middle single line box double line left + break; + case '\uF0C2': + case '\u252C': + sb.Append("[bxMD]"); // middle down single line box + break; + case '\uF0C1': + case '\u2534': + sb.Append("[bxMU]"); // middle up single line box + break; + case '\uF0DC': + sb.Append("[thbxtop]"); // top thick line box + break; + case '\uF0DB': + sb.Append("[thbxSide]"); // Side thick line box + break; + case '\uF0DF': + sb.Append("[thbxBtm]"); // Bottom thick line box + break; + case '\uF0DD': + sb.Append("[thbxLfSide]"); // Left Side thick line box + break; + case '\uF0DE': + sb.Append("[thbxRtSide]"); // Right Side thick line box + break; + case '\uF020': + case '\u2002': + case '\u2003': + sb.Append("[{SP}]"); // unicode space + break; + case '\u2010': + case '\u2012': + case '\u2013': + case '\u2014': + case '\u001E': + case '\u25AA': + sb.Append("[{Dash}]"); // dash + break; + case '\u201C': + case '\u001C': + sb.Append("[{BgDblQt}]"); // begin double quote + break; + case '\u201D': + case '\u001D': + case '\u2033': + sb.Append("[{EnDblQt}]"); // end double quote + break; + case '\u2018': + sb.Append("[{fwdQuote}]"); // forward quote (single quote) + break; + case '\u2019': + case '\u2032': + sb.Append("[{bckQuote}]"); // back quote (single quote) + break; + case '\u2022': + //case '\uF06C': + sb.Append("[{bullet}]"); // bullet not in PROMS symbol list + break; + case '\u00B7': + //case '\uF06C': + sb.Append("[{SqrBullet}]"); // square bullet not in PROMS symbol list + break; + case '\uF0B7': + case '\uF0A3': + sb.Append("[{ChkBox}]"); // check box not in PROMS symbol list + break; + case '\u00B5': + sb.Append("[{Micro}]"); // micro not in PROMS symbol list + break; + case '\u00B3': + sb.Append("[{Cubed}]"); // cubed char (supper script 3) not in PROMS symbol list + break; + case '\u2206': + sb.Append("[{Delta}]"); // Delta not in PROMS symbol list + break; + case '\u00BE': + sb.Append("[{3/4}]"); // 3/4 char not in PROMS symbol list + break; + case '\u2070': + case '\u00BA': + case '\u030A': + case '\u02DA': + case '\uF0B0': + sb.Append("[{Degree}]"); // degree char not in PROMS symbol list + break; + case '\uF0A8': + sb.Append("[{Diamond}]"); // Diamond char not in PROMS symbol list + break; + case '\u0018': + sb.Append("[{UpArrow}]"); // Up Arrow char not in PROMS symbol list + break; + case '\u01C0': + sb.Append("[{VtBar}]"); // Vertical bar char not in PROMS symbol list + break; + case '\u2026': + sb.Append("[{...}]"); // 3 dots (etc) char not in PROMS symbol list + break; + case '\u02C3': + sb.Append("[{>}]"); // greater than char not in PROMS symbol list + break; + case '\u00D7': + sb.Append("[{x}]"); // times char not in PROMS symbol list + break; + case '\u2298': + sb.Append("[{CirWthVLn}]"); // Cirlce with VLine char not in PROMS symbol list + break; + default: + bool hanledWrdChar = false; + if (doingWordDoc) // These characters are valid only in Word documents + { + hanledWrdChar = true; + switch (i) + { + case '\u0001': + sb.Append("[WordImage]"); // embedded image in Word document + break; + case '\u0002': + sb.Append("[WordFtNtChar]"); // Foot Note in Word document + break; + case '\u0015': + sb.Append("[WordBltLstChar]"); // Bullet List in Word document + break; + case '\u000B': + sb.Append("[VT]"); // vertical tab (used to center text in Word tables) + break; + case '\u000C': + sb.Append("[PgBrk]"); // new page (form feed) + break; + case '\u0009': + sb.Append("[TAB]"); // tab + break; + case '\u0007': + sb.Append("[Bell]"); // bell but used in MS Word tables for cell borders + break; + default: + hanledWrdChar = false; + break; + } + } + if (!hanledWrdChar) + { + if (c > '\uF01F' && c < '\uF07F') + sb.Append(string.Format("[{{{0}}}]", Convert.ToChar(((int)c & '\xFF')))); // usually normal text but was using the Volian Line Draw font + else + sb.Append(string.Format("[[{0:X}]]", (int)c)); + } + break; + } + } + else + sb.Append(c); + } + return sb.ToString(); + } + } } diff --git a/PROMS/VEPROMS.CSLA.Library/Extension/DocumentExt.cs b/PROMS/VEPROMS.CSLA.Library/Extension/DocumentExt.cs index 4507e604..82197b94 100644 --- a/PROMS/VEPROMS.CSLA.Library/Extension/DocumentExt.cs +++ b/PROMS/VEPROMS.CSLA.Library/Extension/DocumentExt.cs @@ -776,6 +776,7 @@ namespace VEPROMS.CSLA.Library public static string ToPDFReplaceROs(DocumentInfo doc, List roids, ItemInfo sect, VolianStatusChange statusChange) { //ItemInfo sect = doc.DocumentEntries[0].MyContent.ContentItems[0]; + if (Volian.Base.Library.BaselineMetaFile.IsOpen) Volian.Base.Library.BaselineMetaFile.WriteLine("WrdSec SecNum=\"{0}\" SecTitle=\"{1}\" Itemid={2}", sect.MyActiveSection.DisplayNumber, sect.MyActiveSection.DisplayText, sect.ItemID); return ToPDFReplaceROs(sect, false, roids, statusChange); } private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); @@ -845,7 +846,12 @@ namespace VEPROMS.CSLA.Library AddErrorLogInfoMarginNotFixed(sect,"Word section could not adjust margins"); // B2018-089 - Made error log output more useful //_MyLog.Error("Could not Adjust Margins", ex); } - LBSelection selxy = hasRos ? FindXyPlot() : null; + string txtForBaseline = ""; // C2018-018 save the contents of Word sections - after resolving RO values + if (Volian.Base.Library.BaselineMetaFile.IsOpen) Volian.Base.Library.BaselineMetaFile.WriteLine("++BgnTxt++"); + LBSelection sel = MyApp.Selection; + sel.WholeStory(); + if (Volian.Base.Library.BaselineMetaFile.IsOpen) txtForBaseline = sel.Text; + LBSelection selxy = hasRos ? FindXyPlot() : null; // look for XY Plot language typed into word section (not an RO) string pngFile = VlnSettings.TemporaryFolder + @"\XYPlot1.png"; //@"C:\Temp\XYPlot1.png"; if (File.Exists(pngFile)) File.Delete(pngFile); int filecount = 1; @@ -855,9 +861,21 @@ namespace VEPROMS.CSLA.Library string xyplot = selxy.Text; xyplot = xyplot.Replace("`", "\xB0"); xyplot = xyplot.Replace("\xF8", "\xB0"); + if (Volian.Base.Library.BaselineMetaFile.IsOpen) + { + txtForBaseline = txtForBaseline.Replace("`", "\xB0"); + txtForBaseline = txtForBaseline.Replace("\xF8", "\xB0"); + } if (convertCaretToDeltaSymbol) + { xyplot = xyplot.Replace("^", "\x394"); // delta - xyplot = xyplot.Replace("\x7F", "\x394"); //delta + xyplot = xyplot.Replace("\x7F", "\x394"); //delta + if (Volian.Base.Library.BaselineMetaFile.IsOpen) + { + txtForBaseline = txtForBaseline.Replace("^", "\x394"); + txtForBaseline = txtForBaseline.Replace("\x7F", "\x394"); + } + } // The 16bit code must have kept the carriage returns in the word doc, if there // are carriage returns in the plot language. Count number of carriage return/newlines // so that they can be added back. @@ -914,8 +932,9 @@ namespace VEPROMS.CSLA.Library selxy.WholeStory(); selxy = FindXyPlot(); } - LBSelection sel = MyApp.Selection; + //LBSelection sel = MyApp.Selection; sel.WholeStory(); + string roTokenForBaseline = ""; if (statusChange != null) statusChange(VolianStatusType.Initialize, sel.End, "Refreshing ROs"); sel = hasRos ? FindRO() : null; int roCount = 0; @@ -925,6 +944,7 @@ namespace VEPROMS.CSLA.Library int lastStart = sel == null ? 0 : sel.Start; while (sel != null) { + if (Volian.Base.Library.BaselineMetaFile.IsOpen) roTokenForBaseline = sel.Text; if (statusChange != null) statusChange(VolianStatusType.Update, sel.Start, string.Format("{0} ROs Refreshed", ++roCount)); string val = lookup.GetROValueByAccPagID(sel.Text, spPrefix, igPrefix); int? type = lookup.GetROTypeByAccPagID(sel.Text, spPrefix, igPrefix); @@ -995,10 +1015,14 @@ namespace VEPROMS.CSLA.Library shape.Left = xxx; shape.Top = pt.Y; //_MyLog.WarnFormat("Shape.Left={0}, Shape.Top={1}", shape.Left, shape.Top); + if (Volian.Base.Library.BaselineMetaFile.IsOpen) txtForBaseline = txtForBaseline.Replace(roTokenForBaseline, string.Format("[{0}]", vals[0])); imageROTokenReplaced = true; } if (!imageROTokenReplaced) + { sel.Text = string.Format("Bad Image Link (Missing Image File:{0})", vals[0]); + if (Volian.Base.Library.BaselineMetaFile.IsOpen) txtForBaseline = txtForBaseline.Replace(roTokenForBaseline, sel.Text); + } } else if ((int)type == 4) // X-Y Plot { @@ -1010,6 +1034,7 @@ namespace VEPROMS.CSLA.Library if (convertCaretToDeltaSymbol) val = val.Replace("^", "\x394"); // delta val = val.Replace("\x7F", "\x394"); //delta + if (Volian.Base.Library.BaselineMetaFile.IsOpen) txtForBaseline = txtForBaseline.Replace(sel.Text, val); // An X/Y Plot RO type might have text preceding the Plot Commands int pstart = val.IndexOf("< -.5) xxx = 0; @@ -1047,11 +1072,13 @@ namespace VEPROMS.CSLA.Library shape.Left = xxx; shape.Top = pt.Y; sel.WholeStory(); + if (Volian.Base.Library.BaselineMetaFile.IsOpen) Volian.Base.Library.BaselineMetaFile.WriteLine("{0}", TextForBaseline.FixText(txtForBaseline,true)); } catch (Exception ex) { // something is wrong with the X/Y plot RO. // print out the un-processed X/Y plot RO value + if (Volian.Base.Library.BaselineMetaFile.IsOpen) txtForBaseline = txtForBaseline.Replace(roTokenForBaseline, string.Format("BAD XYPLOT: {0}", val)); sel.Text = val; //return null; } @@ -1066,6 +1093,7 @@ namespace VEPROMS.CSLA.Library //AddInfo("\tRO Found {0} = '{1}'", sel.Text, val); // if val is null, then InsertROValue will put in "RO Not Found" for the value float indent = (float)sel.get_Information(LBWdInformation.wdHorizontalPositionRelativeToTextBoundary); + if (Volian.Base.Library.BaselineMetaFile.IsOpen) txtForBaseline = txtForBaseline.Replace(roTokenForBaseline, val); // B2017-217 Added logic so that underscores are not converted to underline InsertROValue(sel, val, sect.ActiveFormat.PlantFormat.FormatData.ROData.UpRoIfPrevUpper, indent, sect.MyActiveSection.ActiveFormat.PlantFormat.FormatData.SectData.ConvertUnderscoreToUnderline); } @@ -1079,6 +1107,7 @@ namespace VEPROMS.CSLA.Library if (statusChange != null) statusChange(VolianStatusType.Update, 0, "Creating PDF"); sel = MyApp.Selection; sel.WholeStory(); + if (Volian.Base.Library.BaselineMetaFile.IsOpen) Volian.Base.Library.BaselineMetaFile.WriteLine("{0}", TextForBaseline.FixText(txtForBaseline,true)); //sel.Range.Font.Color = (LBWdColor)WordColor(PrintOverride.OverrideTextColor(System.Drawing.Color.Black)); //Console.WriteLine("'{0}' Colors Sel '{1}' Override '{2}' Transparent '{3}' Black '{4}' Red '{5}'", sect.DisplayNumber, sel.Range.Font.Color, OverrideColor, System.Drawing.Color.Transparent, System.Drawing.Color.Black, System.Drawing.Color.Red); if(sel.Range.Font.Color != (LBWdColor)9999999 || OverrideColor == System.Drawing.Color.Red)// B2017-144 If the font color is 9999999 then the color is mixed, and if the override color isn't red, don't change the color. @@ -1098,6 +1127,7 @@ namespace VEPROMS.CSLA.Library CloseAppAfterWait(); } if (statusChange != null) statusChange(VolianStatusType.Complete, 0, ""); + if (Volian.Base.Library.BaselineMetaFile.IsOpen) Volian.Base.Library.BaselineMetaFile.WriteLine("++EndTxt++"); GC.Collect(); //jsj 2-15-2016 - for memeory garbage collection return fileName; }