From f74ce841a574bfd7b33e024665cd5a220f77d775 Mon Sep 17 00:00:00 2001 From: Kathy Date: Thu, 19 May 2011 13:18:48 +0000 Subject: [PATCH] --- PROMS/fmtxml/FmtFileToXml.cs | 208 +++++++++++++++++++--------------- PROMS/fmtxml/FmtToXml.cs | 151 +++++++++++++++++------- PROMS/fmtxml/GenXmlToSvg.cs | 12 ++ PROMS/fmtxml/TranslateFMT.XSL | Bin 190076 -> 191884 bytes 4 files changed, 241 insertions(+), 130 deletions(-) diff --git a/PROMS/fmtxml/FmtFileToXml.cs b/PROMS/fmtxml/FmtFileToXml.cs index 78f0ca5a..efb6cb9b 100644 --- a/PROMS/fmtxml/FmtFileToXml.cs +++ b/PROMS/fmtxml/FmtFileToXml.cs @@ -10,7 +10,6 @@ using System.Xml.Xsl; using System.Xml; using System.Xml.Serialization; using System.ComponentModel; -using System.Text.RegularExpressions; #region StructDefinitions // top of the format. @@ -552,7 +551,7 @@ public struct CheckOff public string MenuItem; public string ExcludeInSectMenu; public string Macro; - public int CheckOffWidAdjust; + public float CheckOffWidAdjust; public int CheckOffXtraLines; } [Serializable] @@ -620,14 +619,14 @@ public struct Section [Serializable] public struct SectionNum { - public Int16 Pos; + public float Pos; public string Just; public VE_Font Font; } [Serializable] public struct SectionHead { - public Int16 Pos; + public float Pos; public string Just; public VE_Font Font; } @@ -678,10 +677,10 @@ public struct AccSection [Serializable] public struct TOC { - public Int16 TofCSecNumPos; - public Int16 TofCSecTitlePos; + public float TofCSecNumPos; + public float TofCSecTitlePos; public byte TofCSecTitleLen; - public Int16 TofCPageNumPos; + public float TofCPageNumPos; public byte TofCSpaceChar; public byte TofCLineSpacing; public VE_Font Font; @@ -690,28 +689,28 @@ public struct TOC public struct MetaSection { public int Index; // do I need this to order them or will SecNumPositionAdj work? - public Int16 SecNumPositionAdj; - public Int16 SecTitlePositionAdj; - public Int16 ColSByLevel; - public Int16 TofCPositionAdj; - public Int16 WidSAdjByLevel; + public float SecNumPositionAdj; + public float SecTitlePositionAdj; + public float ColSByLevel; + public float TofCPositionAdj; + public float WidSAdjByLevel; } [Serializable] public struct StepSectionLayout { - public int LastLineToStartStep; + public float LastLineToStartStep; public Int16 LineDrawingOption; - public Int16 ColS; - public Int16 ColT; - public Int16 ColAbs; - public Int16 WidT; + public float ColS; + public float ColT; + public float ColAbs; + public float WidT; public Int16 PMode; public Int16 MaxRNO; public string MaxRNOTable; public string ColRTable; public string WidSTableEdit; public string WidSTablePrint; - public Int16 AdjRNOCol; + public float AdjRNOCol; public Int16 EndMessagePos; public string RNOWidthAlt; public Int16 HLSWidthOVRD; @@ -765,8 +764,8 @@ public struct StepSectionLayout [Serializable] public struct TopOfPg { - public Int16 Row; - public Int16 Col; + public float Row; + public float Col; public VE_Font Font; } [Serializable] @@ -778,8 +777,8 @@ public struct Separtr [Serializable] public struct StepSectionEdit { - public Int16 ColSScreenAdj; - public Int16 ScrnAdjRNOText; + public float ColSScreenAdj; + public float ScrnAdjRNOText; public string ColRScreen; } [Serializable] @@ -793,7 +792,7 @@ public struct SeqTabFmt [Serializable] public struct StepSectionPrint { - public Int16 ImmStepHdrCol; + public float ImmStepHdrCol; public Int16 SecColHdrforActPMode; public string RNOSepString; public string HLStpSeparatorString; @@ -1011,12 +1010,12 @@ public struct COMacro public struct Box { public int Index; - public Int16 Start; - public int End; - public Int16 TxtStart; - public int TxtWidth; - public Int16 Height; - public Int16 TabPos; + public float Start; + public float End; + public float TxtStart; + public float TxtWidth; + public float Height; + public float TabPos; public sbyte TxtRowAdj; public string BXURC; // Upper Right Corner, etc. public string BXHorz; @@ -1541,7 +1540,7 @@ namespace fmtxml BuildDictionaryText(); fmtName = alias; //if (fmtName.ToUpper() != "CPLS" && fmtName.ToUpper() != "BASE") return; - //if (fmtName.ToUpper() != "HLP" && fmtName.ToUpper() != "BASE") return; + //if (fmtName.ToUpper() != "OHLP" && fmtName.ToUpper() != "BASE" && fmtName.ToUpper() != "WCN2") return; //if (fmtName.ToUpper() != "AEP" && fmtName.ToUpper() != "BASE") return; try { @@ -2085,17 +2084,18 @@ namespace fmtxml } #endregion #region ReadInFile - private int ColToPoints(int i) - { - return (i * 6); // col_in_points = input * 72/12, col = input * 6 - } - private int RowToPoints(int i) + private float RowToPoints(int i) { return (i * 12); // row_in_points = input * 72/6, row = input * 12 } - string _AlternateIndex = null; + private float ColToPoints(float f, uint style) + { + return 72 * (f / CvtFont.CvtFont.GetPrintPitch(style)); + } + string _AlternateIndex = null; int[] rtCheckOffGroups = new int[MAXSTEPS + 1]; private string _fmtFileName; + private uint _PlantDefaultFontStyle; public bool ReadInFmtFile(ref FormatData fmtdata, ref XtraFlgs XtraFlags, string fname) { _fmtFileName = fname; @@ -2158,10 +2158,21 @@ namespace fmtxml fmtdata.StepData[i].ParentType = ParentTypes[i]; if (i == 1) { - fmtdata.StepData[0].Font = LoadVE_Font(); + _PlantDefaultFontStyle = brFmt.ReadUInt32(); + fmtdata.StepData[0].Font = new VE_Font(_PlantDefaultFontStyle); + fmtdata.FontData = fmtdata.StepData[0].Font.Copy(); //fmtdata.StepData[1].Font will inherit the Base Font } - if (i > 1) fmtdata.StepData[i].Font = LoadVE_Font(); + if (i > 1) + { + uint tmpuint = brFmt.ReadUInt32(); + if (i == 40 && tmpuint==0) // check if RNOtype's font = 0, if so use the plant default + { + fmtdata.StepData[i].Font = new VE_Font(_PlantDefaultFontStyle); + } + else + fmtdata.StepData[i].Font = new VE_Font(tmpuint); + } } for (int i = 1; i < MAXSTEPS+1; i++) { @@ -2203,17 +2214,19 @@ namespace fmtxml // convert these to points. Also, each set of data had 24, not 12 box fields, the // second twelve for RTF. For now, I'm going to just skip these. They can be added in // later - for (int i = 1; i < MAXBOXES+1; i++) fmtdata.BoxData[i].Start = (Int16)(ColToPoints(brFmt.ReadInt16())); + // Note that the box start (we think) and the box end locations used ELITE, at 12 characters per inch, + // for locating the line draw/box drawing. + for (int i = 1; i < MAXBOXES + 1; i++) fmtdata.BoxData[i].Start = ColToPoints(brFmt.ReadInt16(), CvtFont.CvtFont.ELITE); for (int i = 1; i < MAXBOXES+1; i++) tmpshort = brFmt.ReadInt16(); - for (int i = 1; i < MAXBOXES+1; i++) fmtdata.BoxData[i].End = (int)(ColToPoints(brFmt.ReadInt16())); + for (int i = 1; i < MAXBOXES + 1; i++) fmtdata.BoxData[i].End = ColToPoints(brFmt.ReadInt16(), CvtFont.CvtFont.ELITE); for (int i = 1; i < MAXBOXES+1; i++) tmpshort = brFmt.ReadInt16(); - for (int i = 1; i < MAXBOXES+1; i++) fmtdata.BoxData[i].TxtStart = (Int16)(ColToPoints(brFmt.ReadInt16())); + for (int i = 1; i < MAXBOXES + 1; i++) fmtdata.BoxData[i].TxtStart = ColToPoints(brFmt.ReadInt16(), _PlantDefaultFontStyle); for (int i = 1; i < MAXBOXES+1; i++) tmpshort = brFmt.ReadInt16(); - for (int i = 1; i < MAXBOXES+1; i++) fmtdata.BoxData[i].TxtWidth = (int)(ColToPoints(brFmt.ReadInt16())); + for (int i = 1; i < MAXBOXES + 1; i++) fmtdata.BoxData[i].TxtWidth = ColToPoints(brFmt.ReadInt16(), _PlantDefaultFontStyle); for (int i = 1; i < MAXBOXES+1; i++) tmpshort = brFmt.ReadInt16(); - for (int i = 1; i < MAXBOXES+1; i++) fmtdata.BoxData[i].Height = (Int16)(RowToPoints(brFmt.ReadInt16())); + for (int i = 1; i < MAXBOXES+1; i++) fmtdata.BoxData[i].Height = RowToPoints(brFmt.ReadInt16()); for (int i = 1; i < MAXBOXES+1; i++) tmpshort = brFmt.ReadInt16(); - for (int i = 1; i < MAXBOXES+1; i++) fmtdata.BoxData[i].TabPos = (Int16)(RowToPoints(brFmt.ReadInt16())); + for (int i = 1; i < MAXBOXES+1; i++) fmtdata.BoxData[i].TabPos = RowToPoints(brFmt.ReadInt16()); for (int i = 1; i < MAXBOXES+1; i++) tmpshort = brFmt.ReadInt16(); tmpshort = brFmt.ReadInt16(); // TransitionCautionOffset for (int i = 1; i < MAXBOXES+1; i++) fmtdata.BoxData[i].Font = LoadVE_Font(); @@ -2283,8 +2296,8 @@ namespace fmtxml fmtdata.SectData.StepSectionData.StpSectLayData = new StepSectionLayout(); fmtdata.SectData.StepSectionData.StpSectLayData.TopOfPage = new TopOfPg(); fmtdata.SectData.StepSectionData.StpSectLayData.TopOfPage.Font = LoadVE_Font(); - fmtdata.SectData.StepSectionData.StpSectLayData.TopOfPage.Row = (Int16)(RowToPoints(brFmt.ReadInt16())); - fmtdata.SectData.StepSectionData.StpSectLayData.TopOfPage.Col = (Int16)(ColToPoints(brFmt.ReadInt16())); + fmtdata.SectData.StepSectionData.StpSectLayData.TopOfPage.Row = RowToPoints(brFmt.ReadInt16()); + fmtdata.SectData.StepSectionData.StpSectLayData.TopOfPage.Col = ColToPoints(brFmt.ReadInt16(), _PlantDefaultFontStyle); fmtdata.SectData.StepSectionData.StpSectPrtData = new StepSectionPrint(); fmtdata.SectData.StepSectionData.StpSectPrtData.ModifiedTextStyle = LoadVE_Font(); @@ -2308,16 +2321,16 @@ namespace fmtxml tmpshort = brFmt.ReadInt16(); // OmitErgEopUsage - not used. fmtdata.SectData.StepSectionData.StpSectLayData.LineDrawingOption = brFmt.ReadInt16(); - fmtdata.SectData.StepSectionData.StpSectLayData.ColS = (Int16)(ColToPoints(brFmt.ReadInt16())); + fmtdata.SectData.StepSectionData.StpSectLayData.ColS = ColToPoints(brFmt.ReadInt16(), _PlantDefaultFontStyle); fmtdata.SectData.StepSectionData.StpSectEditData = new StepSectionEdit(); - fmtdata.SectData.StepSectionData.StpSectEditData.ColSScreenAdj = (Int16)(ColToPoints(brFmt.ReadInt16())); - fmtdata.SectData.StepSectionData.StpSectEditData.ScrnAdjRNOText = (Int16)(ColToPoints(brFmt.ReadInt16())); - fmtdata.SectData.StepSectionData.StpSectLayData.ColT = (Int16)(ColToPoints(brFmt.ReadInt16())); + fmtdata.SectData.StepSectionData.StpSectEditData.ColSScreenAdj = ColToPoints(brFmt.ReadInt16(), _PlantDefaultFontStyle); + fmtdata.SectData.StepSectionData.StpSectEditData.ScrnAdjRNOText = ColToPoints(brFmt.ReadInt16(), _PlantDefaultFontStyle); + fmtdata.SectData.StepSectionData.StpSectLayData.ColT = ColToPoints(brFmt.ReadInt16(),0); tmpshort = brFmt.ReadInt16(); // Coltincr - not used tmpshort = brFmt.ReadInt16(); // ColTab - not used - fmtdata.SectData.StepSectionData.StpSectLayData.ColAbs = (Int16)(ColToPoints(brFmt.ReadInt16())); - fmtdata.SectData.StepSectionData.StpSectLayData.WidT = (Int16)(ColToPoints(brFmt.ReadInt16())); + fmtdata.SectData.StepSectionData.StpSectLayData.ColAbs = ColToPoints(brFmt.ReadInt16(), _PlantDefaultFontStyle); + fmtdata.SectData.StepSectionData.StpSectLayData.WidT = ColToPoints(brFmt.ReadInt16(), _PlantDefaultFontStyle); tmpshort = brFmt.ReadInt16(); // WidTab - not used. fmtdata.SectData.StepSectionData.StpSectLayData.PMode = brFmt.ReadInt16(); @@ -2328,26 +2341,27 @@ namespace fmtxml tmpstr = string.Format("{0},{1},{2}", tmpshort3[0], tmpshort3[1], tmpshort3[2]); fmtdata.SectData.StepSectionData.StpSectLayData.MaxRNOTable = tmpstr; - for (int i = 0; i < 3; i++) tmpshort3[i] = (Int16)(ColToPoints(brFmt.ReadInt16())); - tmpstr = string.Format("{0},{1},{2}", tmpshort3[0], tmpshort3[1], tmpshort3[2]); + float[] tmpfloat = new float[3]; + for (int i = 0; i < 3; i++) tmpfloat[i] = ColToPoints(brFmt.ReadInt16(), _PlantDefaultFontStyle); + tmpstr = string.Format("{0},{1},{2}", tmpfloat[0], tmpfloat[1], tmpfloat[2]); fmtdata.SectData.StepSectionData.StpSectLayData.ColRTable = tmpstr; - Int16[] tmpshort3a = new Int16[3]; + float[] tmpfloata = new float[3]; for (int i = 0; i < 3; i++) { - tmpshort3[i] = (Int16)(ColToPoints(brFmt.ReadInt16())); - tmpshort3a[i] = (Int16)(ColToPoints(brFmt.ReadInt16())); + tmpfloat[i] = ColToPoints(brFmt.ReadInt16(), _PlantDefaultFontStyle); + tmpfloata[i] = ColToPoints(brFmt.ReadInt16(), _PlantDefaultFontStyle); } - tmpstr = string.Format("{0},{1},{2}", tmpshort3[0], tmpshort3[1], tmpshort3[2]); + tmpstr = string.Format("{0},{1},{2}", tmpfloat[0], tmpfloat[1], tmpfloat[2]); fmtdata.SectData.StepSectionData.StpSectLayData.WidSTableEdit = tmpstr; - tmpstr = string.Format("{0},{1},{2}", tmpshort3a[0], tmpshort3a[1], tmpshort3a[2]); + tmpstr = string.Format("{0},{1},{2}", tmpfloata[0], tmpfloata[1], tmpfloata[2]); fmtdata.SectData.StepSectionData.StpSectLayData.WidSTablePrint = tmpstr; - for (int i = 0; i < 3; i++) tmpshort3[i] = (Int16)(ColToPoints(brFmt.ReadInt16())); - tmpstr = string.Format("{0},{1},{2}", tmpshort3[0], tmpshort3[1], tmpshort3[2]); + for (int i = 0; i < 3; i++) tmpfloat[i] = ColToPoints(brFmt.ReadInt16(), _PlantDefaultFontStyle); + tmpstr = string.Format("{0},{1},{2}", tmpfloat[0], tmpfloat[1], tmpfloat[2]); fmtdata.SectData.StepSectionData.StpSectEditData.ColRScreen = tmpstr; - fmtdata.SectData.StepSectionData.StpSectLayData.AdjRNOCol = (Int16)(ColToPoints(brFmt.ReadInt16())); + fmtdata.SectData.StepSectionData.StpSectLayData.AdjRNOCol = ColToPoints(brFmt.ReadInt16(), _PlantDefaultFontStyle); ChangeBar cb = new ChangeBar(); @@ -2396,7 +2410,7 @@ namespace fmtxml for (int i = 0; i < MAXCHECKOFFS; i++) fmtdata.ProcData.CheckOffData.CheckOffList[i].Index = i; for (int i = 0; i < MAXCHECKOFFS; i++) fmtdata.ProcData.CheckOffData.CheckOffList[i].UIMark = brFmt.ReadByte(); for (int i = 0; i < MAXCHECKOFFS; i++) fmtdata.ProcData.CheckOffData.CheckOffList[i].CheckOffXtraLines = brFmt.ReadByte(); // CheckOffXtraLines - for (int i = 0; i < MAXCHECKOFFS; i++) fmtdata.ProcData.CheckOffData.CheckOffList[i].CheckOffWidAdjust = (int)(ColToPoints(brFmt.ReadSByte())); + for (int i = 0; i < MAXCHECKOFFS; i++) fmtdata.ProcData.CheckOffData.CheckOffList[i].CheckOffWidAdjust = ColToPoints(brFmt.ReadSByte(), _PlantDefaultFontStyle); for (int i = 0; i < MAXCHECKOFFS; i++) tmpbyte = brFmt.ReadByte(); // CheckOffFeatures fmtdata.ProcData.CheckOffData.CheckOffHeaderList = new CheckOffHeader[MAXCHKHEADINGS]; for (int i = 0; i < MAXCHKHEADINGS; i++) fmtdata.ProcData.CheckOffData.CheckOffHeaderList[i].Index = i; @@ -2418,7 +2432,7 @@ namespace fmtxml tmpbyte = brFmt.ReadByte(); // HighSeqStart fmtdata.SectData.StepSectionData.IndentToken = brFmt.ReadByte(); - fmtdata.SectData.StepSectionData.StpSectPrtData.ImmStepHdrCol = (Int16)(ColToPoints(brFmt.ReadInt16())); + fmtdata.SectData.StepSectionData.StpSectPrtData.ImmStepHdrCol = ColToPoints(brFmt.ReadInt16(), _PlantDefaultFontStyle); fmtdata.SectData.StepSectionData.StpSectPrtData.ImmStepHdrStyle = LoadVE_Font(); ReplaceStr[] repstr = new ReplaceStr[MAXREPLACE]; @@ -2438,9 +2452,9 @@ namespace fmtxml fmtdata.SectData.SectionHeader = new SectionHead(); fmtdata.SectData.SectionNumber.Font = LoadVE_Font(); fmtdata.SectData.SectionHeader.Font = LoadVE_Font(); - fmtdata.SectData.SectionNumber.Pos = (Int16)(ColToPoints(brFmt.ReadInt16())); + fmtdata.SectData.SectionNumber.Pos = ColToPoints(brFmt.ReadInt16(), _PlantDefaultFontStyle); fmtdata.SectData.SectionNumber.Just = ((E_PageStructMod)brFmt.ReadByte()).ToString(); - fmtdata.SectData.SectionHeader.Pos = (Int16)(ColToPoints(brFmt.ReadInt16())); + fmtdata.SectData.SectionHeader.Pos = ColToPoints(brFmt.ReadInt16(), _PlantDefaultFontStyle); fmtdata.SectData.SectionHeader.Just = ((E_PageStructMod)brFmt.ReadByte()).ToString(); for (int i = 0; i < 10; i++) tmpbyte = brFmt.ReadByte(); // SecLevelDelta @@ -2481,17 +2495,17 @@ namespace fmtxml for (int i = 0; i < MAXTRANS; i++) tmpbyte = brFmt.ReadByte(); // TransMode for (int i = 0; i < MAXTRANS; i++) tmpbyte = brFmt.ReadByte(); // OutsideTransType - for (int i = 0; i < MAXSTEPS; i++) fmtdata.StepData[i].StepLayoutData.StepTypeWidthOverride = ((Int16)(ColToPoints(brFmt.ReadInt16()))).ToString(); + for (int i = 0; i < MAXSTEPS; i++) fmtdata.StepData[i].StepLayoutData.StepTypeWidthOverride = (ColToPoints(brFmt.ReadInt16(), _PlantDefaultFontStyle)).ToString(); // auto table of contents data AccSection accsec = new AccSection(); TOC toc = new TOC(); - toc.TofCSecNumPos = (Int16)(ColToPoints(brFmt.ReadSByte())); - toc.TofCSecTitlePos = (Int16)(ColToPoints(brFmt.ReadSByte())); + toc.TofCSecNumPos = ColToPoints(brFmt.ReadSByte(), _PlantDefaultFontStyle); + toc.TofCSecTitlePos = ColToPoints(brFmt.ReadSByte(), _PlantDefaultFontStyle); tmpbyte = brFmt.ReadByte(); // TofCSecTitlePos2 toc.TofCSecTitleLen = brFmt.ReadByte(); - toc.TofCPageNumPos = (Int16)(ColToPoints(brFmt.ReadSByte())); + toc.TofCPageNumPos = ColToPoints(brFmt.ReadSByte(), _PlantDefaultFontStyle); toc.TofCSpaceChar = brFmt.ReadByte(); toc.TofCLineSpacing = brFmt.ReadByte(); toc.Font = LoadVE_FontByte(); ; @@ -2542,11 +2556,11 @@ namespace fmtxml MetaSection[] metsects = new MetaSection[10]; fmtdata.SectData.MetaSectionData = metsects; for (int i = 0; i < 10; i++) metsects[i].Index = i; - for (int i = 0; i < 10; i++) metsects[i].SecNumPositionAdj = (Int16)(ColToPoints(brFmt.ReadSByte())); - for (int i = 0; i < 10; i++) metsects[i].SecTitlePositionAdj = (Int16)(ColToPoints(brFmt.ReadSByte())); - for (int i = 0; i < 10; i++) metsects[i].ColSByLevel = (Int16)(ColToPoints(brFmt.ReadSByte())); - for (int i = 0; i < 10; i++) metsects[i].TofCPositionAdj = (Int16)(ColToPoints(brFmt.ReadSByte())); - for (int i = 0; i < 10; i++) metsects[i].WidSAdjByLevel = (Int16)(ColToPoints(brFmt.ReadSByte())); + for (int i = 0; i < 10; i++) metsects[i].SecNumPositionAdj = ColToPoints(brFmt.ReadSByte(), _PlantDefaultFontStyle); + for (int i = 0; i < 10; i++) metsects[i].SecTitlePositionAdj = ColToPoints(brFmt.ReadSByte(), _PlantDefaultFontStyle); + for (int i = 0; i < 10; i++) metsects[i].ColSByLevel = ColToPoints(brFmt.ReadSByte(), _PlantDefaultFontStyle); + for (int i = 0; i < 10; i++) metsects[i].TofCPositionAdj = ColToPoints(brFmt.ReadSByte(), _PlantDefaultFontStyle); + for (int i = 0; i < 10; i++) metsects[i].WidSAdjByLevel = ColToPoints(brFmt.ReadSByte(), _PlantDefaultFontStyle); fmtdata.SectData.StepSectionData.NumberOfHighLevelSteps = brFmt.ReadByte(); @@ -2554,7 +2568,7 @@ namespace fmtxml for (int i = 1; i < MAXBOXES+1; i++) fmtdata.BoxData[i].TxtRowAdj = brFmt.ReadSByte(); for (int i = 1; i < MAXBOXES+1; i++) tmpshort = brFmt.ReadByte(); - for (int i = 1; i < MAXSTEPS+1; i++) fmtdata.StepData[i].StepTypeColOverride = ((Int16)(ColToPoints(brFmt.ReadInt16()))).ToString(); + for (int i = 1; i < MAXSTEPS + 1; i++) fmtdata.StepData[i].StepTypeColOverride = (ColToPoints(brFmt.ReadInt16(), _PlantDefaultFontStyle)).ToString(); fmtdata.SectData.StepSectionData.NumberOfSubStepTypes = brFmt.ReadByte(); @@ -4494,7 +4508,7 @@ namespace fmtxml return wkstr; } - private int CalculateTabWid(string p) + private float CalculateTabWid(string p) { if (p == null || p.Length == 0) return 0; int tablen = p.Length; @@ -4518,7 +4532,7 @@ namespace fmtxml for (int i=0; i' with '}' - pi.Token = pi.Token.Replace('<', '{'); - pi.Token = pi.Token.Replace('>', '}'); - - cnt++; - if (!isfirst) + int lcol = brFmt.ReadInt16(); + uint tmpjust = brFmt.ReadUInt16(); + E_PageStructMod etmpjust = (E_PageStructMod)tmpjust; + pi.Justify = ((E_PageStructMod)tmpjust).ToString(); + float adj = 0.5F; + if ((etmpjust & E_PageStructMod.PSTrue) == 0) adj = -0.5F; + 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); + if (pi.Token != null) { - Fpsitms = new PSItem[cnt]; - psitms.CopyTo(Fpsitms,0); - Fpsitms[cnt-1] = pi; - psitms = Fpsitms; - + // replace the '<' with '{' & '>' with '}' + pi.Token = pi.Token.Replace('<', '{'); + pi.Token = pi.Token.Replace('>', '}'); + + cnt++; + if (!isfirst) + { + Fpsitms = new PSItem[cnt]; + psitms.CopyTo(Fpsitms, 0); + Fpsitms[cnt - 1] = pi; + psitms = Fpsitms; + + } + else + psitms[0] = pi; + isfirst = false; } else - psitms[0] = pi; - isfirst=false; + { + if (!didLineDraw) + { + didLineDraw = true; + pi.Token = "{BOX9}"; + cnt++; + if (!isfirst) + { + Fpsitms = new PSItem[cnt]; + psitms.CopyTo(Fpsitms, 0); + Fpsitms[cnt - 1] = pi; + psitms = Fpsitms; + + } + else + psitms[0] = pi; + isfirst = false; + } + } brFmt.BaseStream.Position = fseek+vnum; } pg.Items = psitms; @@ -680,6 +727,20 @@ namespace fmtxml } } + private string RemoveInitialLineDraw(string tkn, ref int coladj) + { + // if first two characters are line draw and space, remove them and adjust column. + if (tkn[0] == '\xB3' && tkn[1] == ' ') + { + coladj += 2; + tkn = tkn.Substring(2, tkn.Length - 2); + //trim any end line char too. + tkn = tkn.Replace('\xB3',' '); + tkn = tkn.TrimEnd(" ".ToCharArray()); + } + return tkn; + } + private string GetAsciiString(BinaryReader brFmt) { short len = brFmt.ReadInt16(); @@ -693,7 +754,7 @@ namespace fmtxml // read in title. string fnm = MyPath + @"\" + fname; - Console.WriteLine(fname); + if (fname == "CPL.Y01") Console.WriteLine(fname); brFmt = new BinaryReader(File.Open(fnm,System.IO.FileMode.Open,System.IO.FileAccess.ReadWrite,FileShare.ReadWrite)); dcstyles.Name = GetAsciiString(brFmt); @@ -757,12 +818,13 @@ namespace fmtxml dc.Name = GetAsciiString(brFmt); vnum = brFmt.ReadInt16(); // not sure what this is! dc.pagestyle = brFmt.ReadInt16(); - dc.dstyle = LoadVE_Font(); + uint tmpstyle = brFmt.ReadUInt32(); + dc.dstyle = new VE_Font(tmpstyle); dc.PTopRow = RowToPoints(brFmt.ReadInt16()); dc.FooterLen = RowToPoints(brFmt.ReadInt16()); - dc.LeftMargin = ColToPoints(brFmt.ReadInt16()); + dc.LeftMargin = ColToPoints(brFmt.ReadInt16(), tmpstyle); dc.PageLength = RowToPoints(brFmt.ReadInt16()); - dc.PageWidth = ColToPoints(brFmt.ReadInt16()); + dc.PageWidth = ColToPoints(brFmt.ReadInt16(), tmpstyle); dc.numberingsequence = brFmt.ReadInt16(); dc.oldtonew = brFmt.ReadInt32(); dc.IsStepSection = ConvertToSectType(dc.oldtonew); @@ -874,6 +936,8 @@ namespace fmtxml string wkstr = p; // use regular expressions to do the following... + // first see if entire string is line draw type chars, if so, just don't include it. + if (AllDrawChars(wkstr)) return null; try { // replace newline with {par} @@ -931,6 +995,7 @@ namespace fmtxml // replace x15 with {RO} for now. wkstr = wkstr.Replace("\x15", "{RO}"); + } catch (Exception ex) { @@ -940,6 +1005,14 @@ namespace fmtxml return wkstr; } + private bool AllDrawChars(string wkstr) + { + foreach (char c in wkstr) + { + if (c < '\xB3' || c > '\xDF') return false; + } + return true; + } private void CompareFonts(VE_Font parFont, ref VE_Font subFont) { if (parFont != null && subFont != null) diff --git a/PROMS/fmtxml/GenXmlToSvg.cs b/PROMS/fmtxml/GenXmlToSvg.cs index 5fc67131..8e207088 100644 --- a/PROMS/fmtxml/GenXmlToSvg.cs +++ b/PROMS/fmtxml/GenXmlToSvg.cs @@ -166,6 +166,18 @@ namespace fmtxml private string MyResultPath; + /* + * The following svg group must be added for WCN2 for its box on the cover page: + * + + + + + + + + + */ public GenXmlToSvg(string nm, string resPath) { MyResultPath = resPath; diff --git a/PROMS/fmtxml/TranslateFMT.XSL b/PROMS/fmtxml/TranslateFMT.XSL index 3fae44db35b1bbf4c70833a045483e22bef0eda9..c34f5be9f4157caec3ade7b9c944278f85a0648a 100644 GIT binary patch delta 458 zcmex!hP&rB_l8q^(=RkLu}l_NEHnLs4Wk09GeZD_=j819woumk#qP{Nk?H!6m~5w~ z2{39+_i<%vnw%iOwK)ZMt3}lf`76DFWa%_GuXWKH6g6)@F z7`G&XSkuEcFp6!zv7AwX4J=`@p7Fx$=>^V=Y9Q_;ftJYur`V=TU1t=TK1&#=lFyf^ GZUF$IFDe!Q