diff --git a/PROMS/fmtxml/FmtToXml.cs b/PROMS/fmtxml/FmtToXml.cs index e5f69649..cd046040 100644 --- a/PROMS/fmtxml/FmtToXml.cs +++ b/PROMS/fmtxml/FmtToXml.cs @@ -381,7 +381,12 @@ public class VE_Font _CPISet = true; return _CPI; } - set { CheckPartial(_CPI, value); _CPI = value; } + set + { + CheckPartial(_CPI, value); + _CPI = value; + if (value != null) _CPISet = true; + } } private string _FontCheckOff = null; private bool _FontCheckOffSet = false; @@ -619,7 +624,11 @@ namespace fmtxml // Get the number of page styles, and create the array for them. short numpgstyles = brFmt.ReadInt16(); - PageStyle [] pgs = new PageStyle[numpgstyles]; + // If any page styles need added for a plant, the new count will be here: + short newnumpgstyles = GetPlantSpecificStyleCount(fname, numpgstyles); + bool didNewPageStyle = newnumpgstyles != numpgstyles; + + PageStyle[] pgs = new PageStyle[newnumpgstyles]; pgstyles.PgStyles = pgs; short offptr = brFmt.ReadInt16(); @@ -719,6 +728,7 @@ namespace fmtxml pg.Items = psitms; pgs[i] = pg; } + if (didNewPageStyle) pgs[numpgstyles] = AddPageStyles(fname); brFmt.Close(); DoPSFontInherit(ref pgstyles); @@ -731,7 +741,7 @@ namespace fmtxml // from original name. This will allow the data load to know it's a sub. string destfile = "tmp_fmt_xml\\" + lfmtname + "p.xml"; if (File.Exists(destfile)) File.Delete(destfile); - TextWriter writer = new StreamWriter(destfile); + TextWriter writer = new StreamWriter(destfile); try { serializer.Serialize(writer, pgstyles); @@ -748,6 +758,76 @@ namespace fmtxml writer.Close(); } } + + private short GetPlantSpecificStyleCount(string fname, short nmstyles) + { + switch (fname.ToUpper()) + { + case "RGESAM1.PAG": + case "RGESAM1.DOC": + return ++nmstyles; + break; + default: + return nmstyles; + break; + } + } + private PageStyle AddPageStyles(string fname) + { + PageStyle pg = new PageStyle(); + switch (fname.ToUpper()) + { + case "RGESAM1.PAG": + /* + + + + + + + + */ + + pg.Index=3; + pg.Name = "Cover Page"; + + PSItem [] psitms = new PSItem[3]; + PSItem pi = new PSItem(); + pi.Token = "{DRAFTPAGE}{REFERENCEPAGE}{MASTERPAGE}{SAMPLEPAGE}"; + pi.Row = 12; + pi.Col = -2; + pi.Justify = "PSCenter"; + psitms[0] = pi; + + PSItem pi1 = new PSItem(); + pi1.Token = "{COVERTITLE1}"; + pi1.Row=320; + pi1.Col=282; + pi1.Justify="PSTop"; + pi1.Style = new VE_Font(); + pi1.Style.FontFamily = "Arial"; + pi1.Style.FontSize = "18"; + pi1.Style.CPI = "9"; + psitms[1] = pi1; + + PSItem pi2 = new PSItem(); + pi2.Token = "{COVERTITLE2}"; + pi2.Row=336; + pi2.Col=282; + pi2.Justify="PSCenter"; + pi2.Style = new VE_Font(); + pi2.Style.FontFamily = "Arial"; + pi2.Style.FontSize = "18"; + pi2.Style.CPI = "9"; + psitms[2] = pi2; + pg.Items = psitms; + return pg; + break; + default: + break; + } + return pg; + } private void GetFormatFlags(string lfmtname) { string fmtFile = "tmp_fmt_xml\\" + lfmtname + "f.xml"; @@ -824,6 +904,8 @@ namespace fmtxml 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); + bool didNewDocStyle = false; + short newnumdcstyles = 0; // read in struct name/def name/doc file name string structName = GetAsciiString(brFmt); @@ -864,7 +946,12 @@ namespace fmtxml // Get the number of page styles, and create the array for them. short numdcstyles = brFmt.ReadInt16(); - dcs = new DocStyle[numdcstyles]; + + // If any doc styles need added for a plant, the new count will be here: + newnumdcstyles = GetPlantSpecificStyleCount(fname, numdcstyles); + didNewDocStyle = newnumdcstyles != numdcstyles; + + dcs = new DocStyle[newnumdcstyles]; short offptr = brFmt.ReadInt16(); // not sure what these bytes contain? short vnum = brFmt.ReadInt16(); @@ -936,6 +1023,7 @@ namespace fmtxml vnum = brFmt.ReadInt16(); } } + if (didNewDocStyle) dcs[newnumdcstyles - 1] = AddDocStyles(fname); dcstyles.DcStyles = dcs; brFmt.Close(); @@ -980,6 +1068,47 @@ namespace fmtxml } } + private DocStyle AddDocStyles(string fname) + { + DocStyle dc = new DocStyle(); + switch (fname.ToUpper()) + { + case "RGESAM1.DOC": + /* + * + + + + */ + dc.Index = 5; + dc.Name = "Cover Page"; + dc.numberingsequence = 0; + dc.IsStepSection = false; + dc.UseCheckOffs = false; + dc.UseColSByLevel = false; + dc.oldtonew = 544; + dc.CancelSectTitle = false; + dc.SpecialStepsFoldout=false; + dc.UndSpecialStepsFoldout=false; + dc.pagestyle = 3; + dc.TopMargin = 54; + dc.FooterLen = 0; + dc.PageLength = 780; + dc.PageWidth = 540; + dc.LeftMargin = 72; + dc.dstyle = new VE_Font(); + dc.dstyle.FontFamily = "Courier New"; + dc.dstyle.FontSize = "12"; + dc.dstyle.CPI = "10"; + dc.DocStructStyle = new VE_DocStyle(); + dc.DocStructStyle.DocStyleUse = E_DocStyleUse.UseOnAllPages; + break; + default: + break; + } + return dc; + } + private bool UseCheckOffsIn(string p, int p_2) { try