From 19349d9fcd3bb35c8bbce7b3e2fe7bd49186414d Mon Sep 17 00:00:00 2001 From: Kathy Date: Mon, 21 Nov 2011 16:37:30 +0000 Subject: [PATCH] --- PROMS/fmtxml/AppendPlantSpecific.cs | 4 ++- PROMS/fmtxml/EntireFormat.cs | 22 ++++++++++--- PROMS/fmtxml/FmtFileToXml.cs | 33 +++++++++++++------ PROMS/fmtxml/FmtToXml.cs | 14 +++++++-- PROMS/fmtxml/RtfToSvg.cs | 47 ++++++++++++++++++---------- PROMS/fmtxml/TranslateDoc.XSL | 6 ++++ PROMS/fmtxml/TranslateFMT.XSL | Bin 190952 -> 191818 bytes 7 files changed, 91 insertions(+), 35 deletions(-) diff --git a/PROMS/fmtxml/AppendPlantSpecific.cs b/PROMS/fmtxml/AppendPlantSpecific.cs index a697895d..bbf7e122 100644 --- a/PROMS/fmtxml/AppendPlantSpecific.cs +++ b/PROMS/fmtxml/AppendPlantSpecific.cs @@ -39,7 +39,9 @@ namespace fmtxml case "WCN2": AddWCN2(myDoc); break; - + case "WCN1": + AddWCN2(myDoc); // same cover page box as wcn2 + break; } } diff --git a/PROMS/fmtxml/EntireFormat.cs b/PROMS/fmtxml/EntireFormat.cs index d14b6b98..bb753e72 100644 --- a/PROMS/fmtxml/EntireFormat.cs +++ b/PROMS/fmtxml/EntireFormat.cs @@ -44,12 +44,24 @@ namespace fmtxml XmlNode doc = xmldoc.ReadNode(reader); top.AppendChild(doc); } - XmlWriterSettings settingsout = new XmlWriterSettings(); - settingsout.Encoding = Encoding.Unicode; string outname = MyPath + @"\fmtall\" + mxml.Substring(mxml.IndexOf("\\")+1,mxml.Length - 13) + "all.xml"; - XmlWriter xmlwrite = XmlWriter.Create(outname,settingsout); - xmldoc.WriteContentTo(xmlwrite); - xmlwrite.Close(); + XmlWriterSettings settingsout = new XmlWriterSettings(); + settingsout.Encoding = Encoding.Unicode; + settingsout.Indent = true; + settingsout.IndentChars = "\t"; + XmlWriter xmlwrite = XmlWriter.Create(outname,settingsout); + xmldoc.WriteContentTo(xmlwrite); + xmlwrite.Close(); + XmlDocument newDoc = new XmlDocument(); + newDoc.Load(outname); + XmlNodeReader xtr = new XmlNodeReader(newDoc); + XmlTextWriter xtw = new XmlTextWriter(outname, Encoding.Unicode); + xtw.Formatting = Formatting.Indented; + xtw.Indentation = 1; + xtw.IndentChar = '\t'; + xtw.WriteNode(xtr, true); + xtr.Close(); + xtw.Close(); } catch (Exception ex) { diff --git a/PROMS/fmtxml/FmtFileToXml.cs b/PROMS/fmtxml/FmtFileToXml.cs index 5f9ca122..77071632 100644 --- a/PROMS/fmtxml/FmtFileToXml.cs +++ b/PROMS/fmtxml/FmtFileToXml.cs @@ -513,7 +513,8 @@ public struct CheckOffData public string AllowSectEdit; public string AllowStepEdit; public int UseCheckOffsIn; - public sbyte CheckOffAdjustment; + public float CheckOffAdjustment; + public float XLocation; /* Format flags ... */ public string DropCheckOff; public string CheckOffOnHLSOnly; @@ -785,7 +786,6 @@ public struct StepSectionEdit public struct SeqTabFmt { public int Index; - public int LeftJustify; public string TabToken; public string TabFormat; public string PrintTabFormat; @@ -805,9 +805,16 @@ public struct StepSectionPrint /* End of format flags */ public VE_Font ModifiedTextStyle; public VE_Font ImmStepHdrStyle; + public LeftJustify[] LeftJustifyList; public string[] ImmStepHdr; } [Serializable] +public struct LeftJustify +{ + public int Index; + public float Size; +} +[Serializable] public struct ReplaceStr { public string Flag; @@ -1546,7 +1553,7 @@ namespace fmtxml fmtName = alias; //if (fmtName.ToUpper() != "CPLS" && fmtName.ToUpper() != "BASE") return; //if (fmtName.ToUpper() != "OHLP" && fmtName.ToUpper() != "BASE" && fmtName.ToUpper() != "WCN2") return; - //if (fmtName.ToUpper() != "WCN2" && fmtName.ToUpper() != "BASE") return; + //if (fmtName.ToUpper() != "WCN1" && fmtName.ToUpper() != "BASE") return; try { LoadFormatFile(nm + ".fmt", ref SubXtraFlags); @@ -2421,6 +2428,10 @@ namespace fmtxml for (int i = 0; i < MAXCHKHEADINGS; i++) fmtdata.ProcData.CheckOffData.CheckOffHeaderList[i].Index = i; for (int i = 0; i < MAXCHKHEADINGS; i++) fmtdata.ProcData.CheckOffData.CheckOffHeaderList[i].Font = LoadVE_Font(); fmtdata.ProcData.CheckOffData.UseCheckOffsIn = brFmt.ReadInt32(); + // 16 bit code was defaulting to Elite when calculating the starting location of the check off line. + // so use elite: 72 points per inch, 12 chars per inch + int tmpcolco = (rightCheckOffBox[3] & 0xFF) * 72/12; + if (tmpcolco > 0) fmtdata.ProcData.CheckOffData.XLocation = (float)tmpcolco; // ColToPoints((float)tmpcolco, _PlantDefaultFontStyle); tmplong = (int)brFmt.ReadUInt32(); fmtdata.SectData.StepSectionData.StpSectLayData.EndMessagePos = brFmt.ReadInt16(); tmpshort = brFmt.ReadInt16(); // CenterTableAdjustment @@ -2517,7 +2528,7 @@ namespace fmtxml accsec.TableOfContentsData = toc; for (int i = 0; i < MAXSTEPS; i++) tmpbyte = brFmt.ReadByte(); - fmtdata.ProcData.CheckOffData.CheckOffAdjustment = brFmt.ReadSByte(); + fmtdata.ProcData.CheckOffData.CheckOffAdjustment = ColToPoints(Convert.ToInt16(brFmt.ReadSByte()), _PlantDefaultFontStyle); tmpshort = brFmt.ReadInt16(); // ColsAdjustInS2 tmpbyte = brFmt.ReadByte(); // SeriesTitleLength; @@ -2551,13 +2562,14 @@ namespace fmtxml for (int i = 0; i < 3; i++) tmpbyte3[i] = brFmt.ReadSByte(); tmpstr = string.Format("{0}, {1}, {2}", tmpbyte3[0], tmpbyte3[1], tmpbyte3[2]); fmtdata.SectData.StepSectionData.StpSectLayData.TableCenterPos = tmpstr; - - //short[] tmpint9 = new short[9]; - //for (int i = 0; i < 9; i++) tmpint9[i] = brFmt.ReadInt16(); - //tmpstr = string.Format("{0},{1},{2},{3},{4},{5},{6},{7},{8}", tmpint9[0], tmpint9[1], tmpint9[2], tmpint9[3], tmpint9[4], tmpint9[5], tmpint9[6], tmpint9[7], tmpint9[8]); - //fmtdata.SectData.StepSectionData.LeftJustSeqTab = tmpstr; for (int i = 0; i < MAXSEQ; i++) fmtdata.SectData.StepSectionData.SequentialTabFormat[i].Index = i; - for (int i = 0; i < MAXSEQ; i++) fmtdata.SectData.StepSectionData.SequentialTabFormat[i].LeftJustify = brFmt.ReadInt16(); + LeftJustify[] lftjust = new LeftJustify[MAXSEQ]; + fmtdata.SectData.StepSectionData.StpSectPrtData.LeftJustifyList = lftjust; + for (int i = 0; i < MAXSEQ; i++) + { + lftjust[i].Index = i; + lftjust[i].Size = ColToPoints(brFmt.ReadInt16(), _PlantDefaultFontStyle); //brFmt.ReadInt16(); + } MetaSection[] metsects = new MetaSection[10]; fmtdata.SectData.MetaSectionData = metsects; for (int i = 0; i < 10; i++) metsects[i].Index = i; @@ -4780,6 +4792,7 @@ namespace fmtxml if (mco.AllowSectEdit == sco.AllowSectEdit) subFmt.ProcData.CheckOffData.AllowSectEdit = "null"; if (mco.AllowStepEdit == sco.AllowStepEdit) subFmt.ProcData.CheckOffData.AllowStepEdit = "null"; if (mco.UseCheckOffsIn == sco.UseCheckOffsIn) subFmt.ProcData.CheckOffData.UseCheckOffsIn = 0; + if (mco.XLocation == sco.XLocation) subFmt.ProcData.CheckOffData.XLocation = 0; if (mco.CheckOffAdjustment == sco.CheckOffAdjustment) subFmt.ProcData.CheckOffData.CheckOffAdjustment = 0; if (mco.DropCheckOff != null && mco.DropCheckOff == sco.DropCheckOff) subFmt.ProcData.CheckOffData.DropCheckOff = "null"; if (mco.CheckOffOnHLSOnly != null && mco.CheckOffOnHLSOnly == sco.CheckOffOnHLSOnly) subFmt.ProcData.CheckOffData.CheckOffOnHLSOnly = "null"; diff --git a/PROMS/fmtxml/FmtToXml.cs b/PROMS/fmtxml/FmtToXml.cs index 36887785..8777b60a 100644 --- a/PROMS/fmtxml/FmtToXml.cs +++ b/PROMS/fmtxml/FmtToXml.cs @@ -61,6 +61,7 @@ public struct DocStyle public bool IsStepSection; // using oldtonew, determine whether is step // section or word doc section (new to 32-bit) public bool UseCheckOffs; // This was originally in fmt. Load fmt to get + public bool UseColSByLevel; // Didn't want a OldToNew Test in new proms, so set this if doc is an E2. public int oldtonew; // Bits for converting from old to new // document style public bool CancelSectTitle; // Was format flags CancelSecTitlesOnS1 & CancelSecTitlesOnS2 @@ -484,7 +485,7 @@ namespace fmtxml { MyPath = path; fmtName = nm; - //if (!fmtName.ToUpper().StartsWith("TP") && fmtName.ToUpper() != "BASE") return; + //if (!fmtName.ToUpper().StartsWith("WCN1") && fmtName.ToUpper() != "BASE") return; try { // get the default base & plant files to use when figuring out inheritance. @@ -632,7 +633,7 @@ namespace fmtxml PSItem [] Fpsitms = null; bool isfirst=true; int cnt = 0; - + uint prevstyleForcheckoff = 0; while ((vnum = brFmt.ReadInt16()) != 0) { long fseek = brFmt.BaseStream.Position; @@ -651,13 +652,18 @@ namespace fmtxml if ((etmpjust & E_PageStructMod.PSLeft) == E_PageStructMod.PSLeft) adj = 0; if ((etmpjust & E_PageStructMod.PSRight) == E_PageStructMod.PSRight) adj *= 2; uint tmpstyle = brFmt.ReadUInt32(); + pi.Style = new VE_Font(tmpstyle); string tkn = DoReplaceTokens(GetAsciiStringUntilNull(brFmt)); // see if any initial line draw chars are in token (WCN2 and others). If so, // remove the line draw & its following space. Also adjust the column. int coladj = 0; // see if any initial draw chars are included and if so remove. pi.Token = tkn==null||tkn==""?tkn:RemoveInitialLineDraw(tkn, ref coladj); - pi.Col = ColToPoints(lcol + coladj + adj, tmpstyle); + bool isChkOffHeading = false; + if (pi.Token != null && pi.Token.Contains("CHKOFFHEADING")) isChkOffHeading = true; + pi.Col = ColToPoints(lcol + coladj + adj, isChkOffHeading?prevstyleForcheckoff:tmpstyle); + prevstyleForcheckoff = tmpstyle; + //Console.WriteLine("{0}, pi.Col = {1}, style = {2}", pi.Token, pi.Col, tmpstyle); if (pi.Token != null) { // replace the '<' with '{' & '>' with '}' @@ -860,6 +866,8 @@ namespace fmtxml dc.EndFlag = brFmt.ReadInt16(); dc.EndStyle = LoadVE_Font(); dc.UseCheckOffs = UseCheckOffsIn(fname.Substring(0, fname.Length - 4), dc.oldtonew); + dc.UseColSByLevel = dc.oldtonew == 5; + // use the string offsets to read in the strings. int[] offst = new int[strings]; for (int j = 0; j < strings; j++) diff --git a/PROMS/fmtxml/RtfToSvg.cs b/PROMS/fmtxml/RtfToSvg.cs index 759f5be0..5acc3544 100644 --- a/PROMS/fmtxml/RtfToSvg.cs +++ b/PROMS/fmtxml/RtfToSvg.cs @@ -109,7 +109,7 @@ namespace fmtxml else if (text.StartsWith("\xAD\xAD")) hasC0 |= AddGroupStart(sb, ref group, text).ToLower() == "c0"; else if (text == "END") - group = AndGroupEnd(sb, group); + group = AddGroupEnd(sb, group); else if (text != "") ProcessCommand(sb, text, file); } @@ -123,15 +123,17 @@ namespace fmtxml } sb.Append(string.Format("\r\n")); } - private static bool AndGroupEnd(StringBuilder sb, bool group) + private static bool AddGroupEnd(StringBuilder sb, bool group) { if (group) sb.Append(" \r\n"); group = false; + _Xoff = 0; + _Yoff = 0; return group; } private static string AddGroupStart(StringBuilder sb, ref bool group, string text) { - AndGroupEnd(sb, group); + AddGroupEnd(sb, group); group = true; string grpID = text.Substring(2).ToUpper(); sb.Append(string.Format(" \r\n", grpID)); @@ -193,9 +195,12 @@ namespace fmtxml Converters[(int)ECommand.RTFADJ] = new Converter(AddRtfAdj); Converters[(int)ECommand.ABSOLUTE] = new Converter(AddAbsolute); } + private static Regex regGdiAdj = new Regex(@"GDIADJ ([-0-9]*) ([-0-9]*)$", RegexOptions.Multiline); private static void AddGdiAdj(StringBuilder sb, string text) { - // May need to do something with this + Match gdiadjMatch = regGdiAdj.Match(text); + _Xoff = int.Parse(gdiadjMatch.Groups[1].Value); + _Yoff = int.Parse(gdiadjMatch.Groups[2].Value); } private static void AddAbsolute(StringBuilder sb, string text) { @@ -216,8 +221,8 @@ namespace fmtxml string bmHeight = bmp.Height.ToString() + "px"; //Console.WriteLine("'{0}'", bmFileName); sb.Append(string.Format(" \r\n", - TwipsToPoints(bitmapMatch.Groups[1].Value), - TwipsToPoints(bitmapMatch.Groups[2].Value), + TwipsToPointsX(bitmapMatch.Groups[1].Value), + TwipsToPointsY(bitmapMatch.Groups[2].Value), bmWidth, bmHeight, bmFileName)); @@ -228,8 +233,8 @@ namespace fmtxml Match textMatch = regText.Match(text); sb.Append(string.Format(" {5}\r\n", - TwipsToPoints(textMatch.Groups[1].Value), - TwipsToPoints(textMatch.Groups[2].Value), + TwipsToPointsX(textMatch.Groups[1].Value), + TwipsToPointsY(textMatch.Groups[2].Value), FontSizeToPoints(textMatch.Groups[3].Value), FontToFamily(textMatch.Groups[4].Value), FontStyle(textMatch.Groups[5].Value), @@ -240,8 +245,8 @@ namespace fmtxml { Match ellipseMatch = regEllipse.Match(text); sb.Append(string.Format(" \r\n", - TwipsToPoints(ellipseMatch.Groups[1].Value), - TwipsToPoints(ellipseMatch.Groups[2].Value), + TwipsToPointsX(ellipseMatch.Groups[1].Value), + TwipsToPointsY(ellipseMatch.Groups[2].Value), TwipsToPoints(ellipseMatch.Groups[3].Value), TwipsToPoints(ellipseMatch.Groups[4].Value), TwipsToPoints(ellipseMatch.Groups[5].Value))); @@ -251,21 +256,23 @@ namespace fmtxml { Match boxMatch = regBox.Match(text); sb.Append(string.Format(" \r\n", - TwipsToPoints(boxMatch.Groups[1].Value), - TwipsToPoints(boxMatch.Groups[2].Value), + TwipsToPointsX(boxMatch.Groups[1].Value), + TwipsToPointsY(boxMatch.Groups[2].Value), TwipsToPoints(boxMatch.Groups[3].Value), TwipsToPoints(boxMatch.Groups[4].Value), TwipsToPoints(boxMatch.Groups[5].Value))); } + private static int _Xoff = 0; + private static int _Yoff = 0; private static Regex regLine = new Regex(@"LINE ([-0-9]*) ([-0-9]*) ([-0-9]*) ([-0-9]*) ([-0-9]*)", RegexOptions.Multiline); private static void AddLine(StringBuilder sb, string text) { Match lineMatch = regLine.Match(text); sb.Append(string.Format(" \r\n", - TwipsToPoints(lineMatch.Groups[1].Value), - TwipsToPoints(lineMatch.Groups[2].Value), - TwipsToPoints(lineMatch.Groups[3].Value) + TwipsToPoints(lineMatch.Groups[1].Value), - TwipsToPoints(lineMatch.Groups[4].Value) + TwipsToPoints(lineMatch.Groups[2].Value), + TwipsToPointsX(lineMatch.Groups[1].Value), + TwipsToPointsY(lineMatch.Groups[2].Value), + TwipsToPoints(lineMatch.Groups[3].Value) + TwipsToPointsX(lineMatch.Groups[1].Value), + TwipsToPoints(lineMatch.Groups[4].Value) + TwipsToPointsY(lineMatch.Groups[2].Value), TwipsToPoints(lineMatch.Groups[5].Value))); } private static string FontStyle(string style) @@ -315,6 +322,14 @@ namespace fmtxml { return float.Parse(twips) / 20; } + private static float TwipsToPointsX(string twips) + { + return (_Xoff + float.Parse(twips)) / 20; + } + private static float TwipsToPointsY(string twips) + { + return (_Yoff + float.Parse(twips)) / 20; + } private static float FontSizeToPoints(string fontSize) { return float.Parse(fontSize) / 2; diff --git a/PROMS/fmtxml/TranslateDoc.XSL b/PROMS/fmtxml/TranslateDoc.XSL index cd09a976..2cae67bc 100644 --- a/PROMS/fmtxml/TranslateDoc.XSL +++ b/PROMS/fmtxml/TranslateDoc.XSL @@ -19,6 +19,7 @@ + @@ -39,6 +40,11 @@ + + + + + diff --git a/PROMS/fmtxml/TranslateFMT.XSL b/PROMS/fmtxml/TranslateFMT.XSL index 2aabe871aa695aa433b988bd3c08023857a90499..9740faa6e6051b3d94c3d4e0b0661605bbac08a9 100644 GIT binary patch delta 297 zcmaEHnfuf&?hQNY1S1%H81fmC84?*v7&3vZyvvC2?JFz6a%eQVz6W2W#D4qWUv8ipMI&C zNo=}63lqom1-y(#lQqupO%Gsadcz#gt$V0K+R=2LJ#7 delta 147 zcmX?gi~Gf8?hQNYCNp(PY<^PL!7+V-1Eay@8J%j=4FVYRHqYpsP&fSn6Qk7R0}6c8 z6}TDM81<$Xu4R;*UR1{@H@#pEqu%6z7?#O@&hkuuu$qx?`kh@&0+Sc;7_cia*fJ