Added missing properties to format and fixed logic.

Fixed inheritance logic.
This commit is contained in:
Rich 2009-09-16 16:13:20 +00:00
parent da310f2436
commit a72f4118c5
2 changed files with 565 additions and 265 deletions

View File

@ -10,6 +10,7 @@ using System.Xml.Xsl;
using System.Xml; using System.Xml;
using System.Xml.Serialization; using System.Xml.Serialization;
using System.ComponentModel; using System.ComponentModel;
using System.Text.RegularExpressions;
#region StructDefinitions #region StructDefinitions
// top of the format. // top of the format.
@ -727,6 +728,7 @@ public struct SeqTabFmt
public int Index; public int Index;
public int LeftJustify; public int LeftJustify;
public string TabFormat; public string TabFormat;
public string PrintTabFormat;
} }
[Serializable] [Serializable]
public struct StepSectionPrint public struct StepSectionPrint
@ -863,8 +865,8 @@ public struct Step
[Serializable] [Serializable]
public struct Edit public struct Edit
{ {
public string ForeColor; public string ForeColor; // Doesn't exist in old format - See StepLayoutData
public string BackColor; public string BackColor; // Doesn't exist in old format - See StepLayoutData
public string AcTable; public string AcTable;
public string Searchable; public string Searchable;
public TypeMenu TypeMenu; public TypeMenu TypeMenu;
@ -900,8 +902,8 @@ public struct TypeMenu
[Serializable] [Serializable]
public struct Print public struct Print
{ {
public string ForeColor; public string ForeColor; // Doesn't exist in old format - See StepLayoutData
public string BackColor; public string BackColor; // Doesn't exist in old format - See StepLayoutData
public string PosAdjust; public string PosAdjust;
} }
[Serializable] [Serializable]
@ -925,6 +927,7 @@ public struct Tab
{ {
public string IdentEdit; public string IdentEdit;
public string Ident; public string Ident;
public string IdentAltPrint;
public string RNOIdentEdit; public string RNOIdentEdit;
public string RNOIdent; public string RNOIdent;
public string IdentEditWid; public string IdentEditWid;
@ -933,6 +936,7 @@ public struct Tab
public string RNOIdentWid; public string RNOIdentWid;
public string Justify; // from tbstyle - None, CENTER, LEFT, RIGHT public string Justify; // from tbstyle - None, CENTER, LEFT, RIGHT
public string CheckOff; // from tbstyle - None, LEFT, RIGHT public string CheckOff; // from tbstyle - None, LEFT, RIGHT
public string UsePreviousStyle;
public VE_Font Font; public VE_Font Font;
} }
[Serializable] [Serializable]
@ -1452,6 +1456,7 @@ namespace fmtxml
public string MyPath; public string MyPath;
public FmtFileToXml(FmtFileToXml gendata, string nm, string path) public FmtFileToXml(FmtFileToXml gendata, string nm, string path)
{ {
//DateTime tStart = DateTime.Now;
MyPath = path; MyPath = path;
if (gendata == null) if (gendata == null)
HasBase = false; HasBase = false;
@ -1473,6 +1478,7 @@ namespace fmtxml
{ {
MessageBox.Show("Format name FAILED = " + nm, ex.Message); MessageBox.Show("Format name FAILED = " + nm, ex.Message);
} }
//Console.WriteLine(" {0:0.000} seconds", TimeSpan.FromTicks(DateTime.Now.Ticks - tStart.Ticks).TotalSeconds);
} }
#region GetBinaryReaderData #region GetBinaryReaderData
private byte[] GetByteArray(BinaryReader br, int len) private byte[] GetByteArray(BinaryReader br, int len)
@ -1739,12 +1745,12 @@ namespace fmtxml
private VE_Font LoadVE_Font() private VE_Font LoadVE_Font()
{ {
UInt32 ui = brFmt.ReadUInt32(); UInt32 ui = brFmt.ReadUInt32();
if (ui > 0) //if (ui > 0) - Always set the font, even if it is 0 (default)
{ //{
VE_Font retval = new VE_Font(ui); VE_Font retval = new VE_Font(ui);
return retval; return retval;
} //}
return null; //return null;
} }
private VE_Font LoadVE_FontByte() private VE_Font LoadVE_FontByte()
{ {
@ -2013,6 +2019,8 @@ namespace fmtxml
{ {
return (i * 12); // row_in_points = input * 72/6, row = input * 12 return (i * 12); // row_in_points = input * 72/6, row = input * 12
} }
string _AlternateIndex = null;
public bool ReadInFmtFile(ref FormatData fmtdata, ref XtraFlgs XtraFlags, string fname) public bool ReadInFmtFile(ref FormatData fmtdata, ref XtraFlgs XtraFlags, string fname)
{ {
int[] tmpshort3 = new int[3]; int[] tmpshort3 = new int[3];
@ -2050,7 +2058,8 @@ namespace fmtxml
// it. // it.
string otherfile = MyPath + @"\" + fname.Substring(0, fname.LastIndexOf(".")) + @".tpl"; string otherfile = MyPath + @"\" + fname.Substring(0, fname.LastIndexOf(".")) + @".tpl";
if (File.Exists(otherfile)) if (File.Exists(otherfile))
fmtdata.TPL = File.ReadAllText(otherfile); fmtdata.TPL = FixXmlString(File.ReadAllText(otherfile));
// http://www.w3.org/TR/2000/REC-xml-20001006#NT-Char
otherfile = MyPath + @"\" + fname.Substring(0, fname.LastIndexOf(".")) + @".ini"; otherfile = MyPath + @"\" + fname.Substring(0, fname.LastIndexOf(".")) + @".ini";
if (File.Exists(otherfile)) if (File.Exists(otherfile))
fmtdata.PSI = File.ReadAllText(otherfile); fmtdata.PSI = File.ReadAllText(otherfile);
@ -2073,9 +2082,13 @@ namespace fmtxml
{ {
fmtdata.StepData[i].Type = StepTypes[i]; fmtdata.StepData[i].Type = StepTypes[i];
fmtdata.StepData[i].ParentType = ParentTypes[i]; fmtdata.StepData[i].ParentType = ParentTypes[i];
if (i > 0) fmtdata.StepData[i].Font = LoadVE_Font(); if (i == 1)
{
fmtdata.StepData[0].Font = LoadVE_Font();
//fmtdata.StepData[1].Font will inherit the Base Font
}
if (i > 1) fmtdata.StepData[i].Font = LoadVE_Font();
} }
fmtdata.StepData[0].Font = fmtdata.StepData[1].Font;
for (int i = 1; i < MAXSTEPS+1; i++) for (int i = 1; i < MAXSTEPS+1; i++)
{ {
Int16 tmpcoli = brFmt.ReadInt16(); Int16 tmpcoli = brFmt.ReadInt16();
@ -2135,6 +2148,22 @@ namespace fmtxml
for (int i = 0; i < MAXTABS; i++) for (int i = 0; i < MAXTABS; i++)
{ {
VE_Font st = LoadVE_Font(); VE_Font st = LoadVE_Font();
if (i == 0)
{
fmtdata.StepData[0].TabData.Font = st == null ? null : st.Copy();
fmtdata.StepData[0].TabData.Justify = st == null ? "None" : st.FontJustify;
fmtdata.StepData[0].TabData.CheckOff = st == null ? "None" : st.FontCheckOff;
for (int j = 0; j < MAXSTEPS; j++)
{
if (Tabindx[j] == -1)
{
fmtdata.StepData[j + 1].TabData.UsePreviousStyle = "True";
fmtdata.StepData[j+1].TabData.Font = st == null ? null : st.Copy();
fmtdata.StepData[j+1].TabData.Justify = st == null ? "None" : st.FontJustify;
fmtdata.StepData[j+1].TabData.CheckOff = st == null ? "None" : st.FontCheckOff;
}
}
}
for (int j = 0; j < MAXSTEPS; j++) for (int j = 0; j < MAXSTEPS; j++)
{ {
if (Tabindx[j] == i) if (Tabindx[j] == i)
@ -2554,6 +2583,7 @@ namespace fmtxml
indx = offset[arcnt]; indx = offset[arcnt];
arcnt++; arcnt++;
if (indx > 0) fmtdata.SectData.StepSectionData.SequentialTabFormat[i].TabFormat = fmtdata.SectData.StepSectionData.SequentialTabFormat[i].TabFormat + GetStringFromByte(input, indx); if (indx > 0) fmtdata.SectData.StepSectionData.SequentialTabFormat[i].TabFormat = fmtdata.SectData.StepSectionData.SequentialTabFormat[i].TabFormat + GetStringFromByte(input, indx);
else fmtdata.SectData.StepSectionData.SequentialTabFormat[i].TabFormat = null;
} }
// replace word strings // replace word strings
for (int i = 0; i < MAXREPLACE; i++) for (int i = 0; i < MAXREPLACE; i++)
@ -2668,7 +2698,7 @@ namespace fmtxml
// fmtdata.SectData.StepSectionData.TextType = new string[10]; // fmtdata.SectData.StepSectionData.TextType = new string[10];
// Set up the text type fields - these are used to define what types of steps the current step // Set up the text type fields - these are used to define what types of steps the current step
// can be changed to.. // can be changed to..
string tmpalternateindx = null; _AlternateIndex = null;
int [] tmparray={0,0,0,0,0,0,0,0,0,0}; int [] tmparray={0,0,0,0,0,0,0,0,0,0};
for (int i = 0; i < 10; i++) for (int i = 0; i < 10; i++)
{ {
@ -2680,16 +2710,16 @@ namespace fmtxml
string tmpstring = GetStringFromByte(input, indx); string tmpstring = GetStringFromByte(input, indx);
// put this in the step data alternatename field. If there already is one. stop // put this in the step data alternatename field. If there already is one. stop
// here for now to see this!. // here for now to see this!.
if (fmtdata.StepData[TextTypeValue[i] + 1].StepEditData.TypeMenu.MenuItem != null && fmtdata.StepData[TextTypeValue[i] + 1].StepEditData.TypeMenu.MenuItem != tmpstring) //if (fmtdata.StepData[TextTypeValue[i] + 1].StepEditData.TypeMenu.MenuItem != null && fmtdata.StepData[TextTypeValue[i] + 1].StepEditData.TypeMenu.MenuItem != tmpstring)
Console.WriteLine("different name, " + fmtdata.StepData[TextTypeValue[i] + 1].StepEditData.TypeMenu.MenuItem + ", " + tmpstring); // Console.WriteLine("different name, " + fmtdata.StepData[TextTypeValue[i] + 1].StepEditData.TypeMenu.MenuItem + ", " + tmpstring);
fmtdata.StepData[TextTypeValue[i]+1].StepEditData.TypeMenu.MenuItem = tmpstring; fmtdata.StepData[TextTypeValue[i]+1].StepEditData.TypeMenu.MenuItem = tmpstring;
tmpalternateindx = (tmpalternateindx == null) ? fmtdata.StepData[TextTypeValue[i] + 1].Type : tmpalternateindx + "," + fmtdata.StepData[TextTypeValue[i] + 1].Type; _AlternateIndex = (_AlternateIndex == null) ? fmtdata.StepData[TextTypeValue[i] + 1].Type : _AlternateIndex + "," + fmtdata.StepData[TextTypeValue[i] + 1].Type;
//fmtdata.SectData.StepSectionData.TextType[i] = GetStringFromByte(input, indx); //fmtdata.SectData.StepSectionData.TextType[i] = GetStringFromByte(input, indx);
} }
} }
if (tmpalternateindx != null) if (_AlternateIndex != null)
{ {
// For any step types in the texttypevalue list, add the alternatename list: // For any step types in the texttypevalue list, add the alternatename list:
for (int i = 0; i < 10; i++) for (int i = 0; i < 10; i++)
@ -2699,7 +2729,7 @@ namespace fmtxml
// format->xml migration. // format->xml migration.
if (TextTypeValue[i] != 0) if (TextTypeValue[i] != 0)
{ {
fmtdata.StepData[TextTypeValue[i] + 1].StepEditData.TypeMenu.AlternateNameList = tmpalternateindx; fmtdata.StepData[TextTypeValue[i] + 1].StepEditData.TypeMenu.AlternateNameList = _AlternateIndex;
fmtdata.StepData[TextTypeValue[i] + 1].StepEditData.TypeMenu.InMenu = true.ToString(); fmtdata.StepData[TextTypeValue[i] + 1].StepEditData.TypeMenu.InMenu = true.ToString();
} }
} }
@ -2710,24 +2740,32 @@ namespace fmtxml
arcnt = arcnt + 50; arcnt = arcnt + 50;
// some seqtab data. // some seqtab data.
string [] tmpSeqStrings = new string[MAXSEQ];
for (int i = 0; i < MAXSEQ; i++) for (int i = 0; i < MAXSEQ; i++)
{ {
tmpSeqStrings[i] = fmtdata.SectData.StepSectionData.SequentialTabFormat[i].TabFormat;
indx = offset[arcnt]; indx = offset[arcnt];
arcnt++; arcnt++;
if (indx > 0) fmtdata.SectData.StepSectionData.SequentialTabFormat[i].TabFormat = GetStringFromByte(input, indx) + fmtdata.SectData.StepSectionData.SequentialTabFormat[i].TabFormat; if (indx > 0) // PreSeqTab - Edit
fmtdata.SectData.StepSectionData.SequentialTabFormat[i].TabFormat = GetStringFromByte(input, indx) + tmpSeqStrings[i];
indx = offset[arcnt]; indx = offset[arcnt];
arcnt++; arcnt++;
if (indx > 0) tmpstr = GetStringFromByte(input, indx).Replace("\x08", ""); if (indx > 0) // PreSeqTab - Print
fmtdata.SectData.StepSectionData.SequentialTabFormat[i].PrintTabFormat = GetStringFromByte(input, indx).Replace("\x08","{0x08}") + tmpSeqStrings[i];
else
fmtdata.SectData.StepSectionData.SequentialTabFormat[i].PrintTabFormat = tmpSeqStrings[i];
//tmpstr = GetStringFromByte(input, indx).Replace("\x08", "");
} }
for (int i = 0; i < MAXSEQ; i++) for (int i = 0; i < MAXSEQ; i++)
{ {
indx = offset[arcnt]; indx = offset[arcnt];
arcnt++; arcnt++;
if (indx > 0) tmpstr = GetStringFromByte(input, indx).Replace("\x08", ""); if (indx > 0) // PostSeqTab - Edit
fmtdata.SectData.StepSectionData.SequentialTabFormat[i].TabFormat += GetStringFromByte(input, indx);
indx = offset[arcnt]; indx = offset[arcnt];
arcnt++; arcnt++;
if (indx > 0) tmpstr = GetStringFromByte(input, indx).Replace("\x08", ""); if (indx > 0) // PostSeqTab - Print
fmtdata.SectData.StepSectionData.SequentialTabFormat[i].PrintTabFormat += GetStringFromByte(input, indx);
} }
indx = offset[arcnt]; indx = offset[arcnt];
@ -2922,7 +2960,7 @@ namespace fmtxml
} }
} }
} }
arcnt = arcnt + MAXTRANS; //arcnt = arcnt + MAXTRANS;
// not used OutsideTransFmt & OutsideTransMenu // not used OutsideTransFmt & OutsideTransMenu
arcnt = arcnt + (MAXTRANS * 2); arcnt = arcnt + (MAXTRANS * 2);
@ -2933,6 +2971,25 @@ namespace fmtxml
//not used BldLstFile //not used BldLstFile
arcnt++; arcnt++;
// AltPrintTBIdent (20 items)
//arcnt += MAXTABS;
for (int j = 0; j < MAXTABS; j++)
{
indx = offset[arcnt];
arcnt++;
if (indx != 0)
{
string ts = GetStringFromByte(input, indx);
for (int i = 0; i < MAXSTEPS; i++)
{
if (Tabindx[i] == j)
{
fmtdata.StepData[i + 1].TabData.IdentAltPrint = ts;
break;
}
}
}
}
indx = offset[arcnt]; indx = offset[arcnt];
arcnt++; arcnt++;
@ -2962,6 +3019,32 @@ namespace fmtxml
return AdjustFlags(ref fmtdata, ref XtraFlags); return AdjustFlags(ref fmtdata, ref XtraFlags);
} }
/// <summary>
/// Replace invalid characters with a special sequence
/// </summary>
/// <param name="str"></param>
/// <returns></returns>
private string FixXmlString(string str)
{
// http://www.w3.org/TR/2000/REC-xml-20001006#NT-Char
// http://cse-mjmcl.cse.bris.ac.uk/blog/2007/02/14/1171465494443.html
// The regular expression below find any invalid characters
// by looking for characters that are not valid
MatchCollection matches = Regex.Matches(str,@"[^\x09\x0A\x0D\x20-\uD7FF\uE000-\uFFFD]");
int lastIndex = 0;
StringBuilder sb = new StringBuilder();
int len = str.Length;
foreach (Match match in matches)
{
sb.Append(str.Substring(lastIndex, match.Index-lastIndex));
foreach (char c in match.Value)
sb.Append(string.Format("[({0:X04}])", (int)c));
lastIndex = match.Index + match.Length;
}
sb.Append(str.Substring(lastIndex));
return sb.ToString();
}
private bool AdjustFlags(ref FormatData fmtdata, ref XtraFlgs XtraFlags) private bool AdjustFlags(ref FormatData fmtdata, ref XtraFlgs XtraFlags)
{ {
// do format flags here - this will get yucky!!! // do format flags here - this will get yucky!!!
@ -3829,14 +3912,52 @@ namespace fmtxml
else return "{UNKNOWN}"; else return "{UNKNOWN}";
} }
#endregion #endregion
private static Dictionary<string, XslCompiledTransform> _TransForms= new Dictionary<string,XslCompiledTransform>();
public static XslCompiledTransform getTransform(string path)
{
if (!_TransForms.ContainsKey(path))
{
XslCompiledTransform xsl = new XslCompiledTransform();
xsl.Load(path);
_TransForms.Add(path, xsl);
}
return _TransForms[path];
}
public bool WriteOutXmlTmp(FormatData fmtdata, string suffix)
{
try
{
XmlSerializer serializer = new XmlSerializer(typeof(FormatData));
string lfmtname = fmtName;
int findx = fmtName.IndexOf('.');
// for subformats, make the name FMT_00 where FMT is format name & 00 is number
// from original name. This will allow the data load to know it's a sub.
if (findx > 0)
lfmtname = fmtName.Substring(0, fmtName.Length - 4) + "_" + fmtName.Substring(fmtName.Length - 2, 2);
string destfile = "tmp_fmt_xml\\" + lfmtname + "_" + suffix + ".xml";
if (File.Exists(destfile)) File.Delete(destfile);
TextWriter writer = new StreamWriter(destfile);
_MyFormatSerializer.Serialize(writer, fmtdata);
writer.Close();
return true;
}
catch (Exception e)
{
Console.WriteLine("Error writing out xml or xsl - format = {0}", fmtdata.Name);
Console.WriteLine(e.Message);
Console.WriteLine();
return false;
}
}
#region WriteOutXml #region WriteOutXml
static private XmlSerializer _MyFormatSerializer = new XmlSerializer(typeof(FormatData));
public bool WriteOutXml(FormatData fmtdata) public bool WriteOutXml(FormatData fmtdata)
{ {
// First serialize files based on the above - then use xsl to transform // First serialize files based on the above - then use xsl to transform
// into prefered xml. // into prefered xml.
if (!Directory.Exists("fmt_xml")) Directory.CreateDirectory("fmt_xml"); if (!Directory.Exists("fmt_xml")) Directory.CreateDirectory("fmt_xml");
if (!Directory.Exists("tmp_fmt_xml")) Directory.CreateDirectory("tmp_fmt_xml"); if (!Directory.Exists("tmp_fmt_xml")) Directory.CreateDirectory("tmp_fmt_xml");
XmlSerializer serializer = new XmlSerializer(typeof(FormatData)); //XmlSerializer serializer = new XmlSerializer(typeof(FormatData));
string lfmtname = fmtName; string lfmtname = fmtName;
int findx = fmtName.IndexOf('.'); int findx = fmtName.IndexOf('.');
@ -3849,14 +3970,16 @@ namespace fmtxml
TextWriter writer = new StreamWriter(destfile); TextWriter writer = new StreamWriter(destfile);
try try
{ {
serializer.Serialize(writer, fmtdata); _MyFormatSerializer.Serialize(writer, fmtdata);
writer.Close(); writer.Close();
XslCompiledTransform xsl = new XslCompiledTransform(); //XslCompiledTransform xsl = new XslCompiledTransform();
xsl.Load(Application.StartupPath + "\\TranslateFmt.XSL"); //xsl.Load(Application.StartupPath + "\\TranslateFmt.XSL");
string sResults = "fmt_xml\\" + lfmtname + "f.xml"; string sResults = "fmt_xml\\" + lfmtname + "f.xml";
//xsl.Transform(destfile, sResults); // Perform Transform
XslCompiledTransform xsl = getTransform(Application.StartupPath + "\\TranslateFmt.XSL");
xsl.Transform(destfile, sResults); // Perform Transform xsl.Transform(destfile, sResults); // Perform Transform
xsl = getTransform(Application.StartupPath + "\\removeempty.XSL");
xsl.Load(Application.StartupPath + "\\removeempty.XSL"); //xsl.Load(Application.StartupPath + "\\removeempty.XSL");
string sResults2 = "fmt_xml\\" + lfmtname + "xf.xml"; string sResults2 = "fmt_xml\\" + lfmtname + "xf.xml";
xsl.Transform(sResults, sResults2); xsl.Transform(sResults, sResults2);
File.Delete(sResults); File.Delete(sResults);
@ -3928,18 +4051,26 @@ namespace fmtxml
string fnm = MyPath + @"\" + fname; string fnm = MyPath + @"\" + fname;
brFmt = new BinaryReader(File.Open(fnm, System.IO.FileMode.Open, System.IO.FileAccess.ReadWrite, FileShare.ReadWrite)); brFmt = new BinaryReader(File.Open(fnm, System.IO.FileMode.Open, System.IO.FileAccess.ReadWrite, FileShare.ReadWrite));
bool success = ReadInFmtFile(ref fmtdata, ref BaseXtraFlags, fname); bool success = ReadInFmtFile(ref fmtdata, ref BaseXtraFlags, fname);
FixInactiveForHigh(ref fmtdata);
FixInactiveForSubStep(ref fmtdata);
FixInactiveForText(ref fmtdata);
//OutputStepFonts(fname, fmtdata);
if (!HasBase) InitSymbols(ref fmtdata); if (!HasBase) InitSymbols(ref fmtdata);
else fmtdata.Symbols = null; else fmtdata.Symbols = null;
if (success) if (success)
{ {
//success = WriteOutXmlTmp(fmtdata, "beforeStep");
DoStepInheritance(ref fmtdata.StepData); DoStepInheritance(ref fmtdata.StepData);
success = WriteOutXml(fmtdata); //success = WriteOutXml(fmtdata);
} }
brFmt.Close(); brFmt.Close();
// Now compare with gen (if !gen). // Now compare with gen (if !gen).
if (HasBase == true) if (HasBase == false)
success = WriteOutXml(fmtdata);
else
{ {
//success = WriteOutXmlTmp(fmtdata, "beforeParent");
success = CompareParentSub(BaseFormat, ref fmtdata); success = CompareParentSub(BaseFormat, ref fmtdata);
success = WriteOutXml(fmtdata); success = WriteOutXml(fmtdata);
@ -3955,6 +4086,7 @@ namespace fmtxml
brFmt = new BinaryReader(File.Open(fnm, System.IO.FileMode.Open, System.IO.FileAccess.ReadWrite, FileShare.ReadWrite)); brFmt = new BinaryReader(File.Open(fnm, System.IO.FileMode.Open, System.IO.FileAccess.ReadWrite, FileShare.ReadWrite));
FormatData subdata = new FormatData(); FormatData subdata = new FormatData();
success = ReadInFmtFile(ref subdata, ref SubXtraFlags, fi.Name); success = ReadInFmtFile(ref subdata, ref SubXtraFlags, fi.Name);
//OutputStepFonts(fi.Name, subdata);
if (success) if (success)
{ {
DoStepInheritance(ref subdata.StepData); DoStepInheritance(ref subdata.StepData);
@ -3968,6 +4100,71 @@ namespace fmtxml
MyFormat = fmtdata; MyFormat = fmtdata;
} }
private static void OutputStepFonts1(string fname, FormatData fmtdata)
{
if (fname == "BASE.fmt")
{
Console.Write("'Name','Description'");
for (int i = 0; i < MAXSTEPS + 1; i++)
{
Console.Write(",'{0}'", fmtdata.StepData[i].Type);
}
Console.Write("\r\n");
Console.Write("'base','Default'");
}
else
Console.Write("'{0}','{1}'", FixName(fname), fmtdata.Name);
for (int i = 0; i < MAXSTEPS + 1; i++)
{
if (fmtdata.StepData[i].Font != null)
Console.Write(",'{0} [{1}] - {2}'", fmtdata.StepData[i].Font.FontFamily, fmtdata.StepData[i].Font.FontSize, fmtdata.StepData[i].Font.FontStyle);
else if (i == 1 && fmtdata.StepData[0].Font != null)
Console.Write(",'{0} [{1}] - {2}'", fmtdata.StepData[0].Font.FontFamily, fmtdata.StepData[0].Font.FontSize, fmtdata.StepData[0].Font.FontStyle);
else
Console.Write(",'Prestige Elite Tall [10] - None'");
}
Console.Write("\r\n");
}
private static void OutputStepFonts(string fname, FormatData fmtdata)
{
if (fname == "BASE.fmt")
{
Console.Write("'Name','Description'");
for (int i = 0; i < MAXSTEPS + 1; i++)
{
Console.Write(",'{0}'", fmtdata.StepData[i].Type);
}
Console.Write("\r\n");
Console.Write("'base','Default'");
}
else
Console.Write("'{0}','{1}'", FixName(fname), fmtdata.Name);
for (int i = 0; i < MAXSTEPS + 1; i++)
{
if (fmtdata.StepData[i].TabData.Font != null)
Console.Write(",'{0} [{1}] - {2}'", fmtdata.StepData[i].TabData.Font.FontFamily, fmtdata.StepData[i].TabData.Font.FontSize, fmtdata.StepData[i].TabData.Font.FontStyle);
else if (i == 1 && fmtdata.StepData[0].TabData.Font != null)
Console.Write(",'{0} [{1}] - {2}'", fmtdata.StepData[0].TabData.Font.FontFamily, fmtdata.StepData[0].TabData.Font.FontSize, fmtdata.StepData[0].TabData.Font.FontStyle);
else
Console.Write(",'*'");
}
Console.Write("\r\n");
}
private static string FixName(string fname)
{
string lfmtname = fname;
int findx = fname.IndexOf('.');
// for subformats, make the name FMT_00 where FMT is format name & 00 is number
// from original name. This will allow the data load to know it's a sub.
if (findx > 0)
{
if(fname.ToUpper().EndsWith(".FMT"))
lfmtname = fname.Substring(0, fname.Length - 4);
else
lfmtname = fname.Substring(0, fname.Length - 4) + fname.Substring(fname.Length - 2, 2);
}
return lfmtname;
}
private void InitSymbols(ref FormatData fmtdata) private void InitSymbols(ref FormatData fmtdata)
{ {
fmtdata.Symbols = new Symbol[35]; fmtdata.Symbols = new Symbol[35];
@ -4248,12 +4445,7 @@ namespace fmtxml
{ {
// just compare all fields - clear the subformat if equal. // just compare all fields - clear the subformat if equal.
#region COMPAREACTIVE #region COMPAREACTIVE
if (mainFmt.FontData != null && subFmt.FontData != null) subFmt.FontData = FixInheritedFont(subFmt.FontData, mainFmt.FontData); // Phase 10
{
if (mainFmt.FontData.FontFamily == subFmt.FontData.FontFamily) subFmt.FontData.FontFamily = null;
if (mainFmt.FontData.FontSize == subFmt.FontData.FontSize) subFmt.FontData.FontSize = null;
if (mainFmt.FontData.FontStyle == subFmt.FontData.FontStyle) subFmt.FontData.FontStyle = null;
}
if (mainFmt.PurchaseOptions == subFmt.PurchaseOptions) subFmt.PurchaseOptions = null; if (mainFmt.PurchaseOptions == subFmt.PurchaseOptions) subFmt.PurchaseOptions = null;
if (mainFmt.PSI == subFmt.PSI) subFmt.PSI = null; if (mainFmt.PSI == subFmt.PSI) subFmt.PSI = null;
if (mainFmt.TPL == subFmt.TPL) subFmt.TPL = null; if (mainFmt.TPL == subFmt.TPL) subFmt.TPL = null;
@ -4274,15 +4466,16 @@ namespace fmtxml
// compare step data, step index by step index. This assumes that step data between // compare step data, step index by step index. This assumes that step data between
// the two indices is the same. // the two indices is the same.
for (int i = 0; i < MAXSTEPS; i++) for (int i = 0; i < MAXSTEPS; i++)
//for (int i = 0; i > 0; i++)
{ {
Step mstp = mainFmt.StepData[i]; Step mstp = mainFmt.StepData[i];
Step sstp = subFmt.StepData[i]; Step sstp = subFmt.StepData[i];
if (mstp.Font != null && sstp.Font != null) //if (i > 0) // Don't inherit base font
{ //{
if (mstp.Font.FontFamily == sstp.Font.FontFamily) subFmt.StepData[i].Font.FontFamily = null; // _LookForChange = true;
if (mstp.Font.FontSize == sstp.Font.FontSize) subFmt.StepData[i].Font.FontSize = null; // subFmt.StepData[i].Font = FixInheritedFont(sstp.Font, mstp.Font);// Phase 1
if (mstp.Font.FontStyle == sstp.Font.FontStyle) subFmt.StepData[i].Font.FontStyle = null; // _LookForChange = false;
} //}
if (mstp.StepLayoutData.ForeColor == sstp.StepLayoutData.ForeColor) subFmt.StepData[i].StepLayoutData.ForeColor = null; if (mstp.StepLayoutData.ForeColor == sstp.StepLayoutData.ForeColor) subFmt.StepData[i].StepLayoutData.ForeColor = null;
if (mstp.StepLayoutData.BackColor == sstp.StepLayoutData.BackColor) subFmt.StepData[i].StepLayoutData.BackColor = null; if (mstp.StepLayoutData.BackColor == sstp.StepLayoutData.BackColor) subFmt.StepData[i].StepLayoutData.BackColor = null;
if (mstp.StepLayoutData.STExtraSpace == sstp.StepLayoutData.STExtraSpace) subFmt.StepData[i].StepLayoutData.STExtraSpace = null; if (mstp.StepLayoutData.STExtraSpace == sstp.StepLayoutData.STExtraSpace) subFmt.StepData[i].StepLayoutData.STExtraSpace = null;
@ -4361,12 +4554,7 @@ namespace fmtxml
if (mstp.Suffix == sstp.Suffix) subFmt.StepData[i].Suffix =null; if (mstp.Suffix == sstp.Suffix) subFmt.StepData[i].Suffix =null;
// KBR TODO if (mstp.AlternateName == sstp.AlternateName) subFmt.StepData[i].AlternateName = null; // KBR TODO if (mstp.AlternateName == sstp.AlternateName) subFmt.StepData[i].AlternateName = null;
if (mstp.UnderlineTheseChar == sstp.UnderlineTheseChar) subFmt.StepData[i].UnderlineTheseChar = null; if (mstp.UnderlineTheseChar == sstp.UnderlineTheseChar) subFmt.StepData[i].UnderlineTheseChar = null;
if (mstp.TabData.Font != null && sstp.TabData.Font != null) //subFmt.StepData[i].TabData.Font = FixInheritedFont(sstp.TabData.Font, mstp.TabData.Font);// Phase 2
{
if (mstp.TabData.Font.FontFamily == sstp.TabData.Font.FontFamily) subFmt.StepData[i].TabData.Font.FontFamily = null;
if (mstp.TabData.Font.FontSize == sstp.TabData.Font.FontSize) subFmt.StepData[i].TabData.Font.FontSize = null;
if (mstp.TabData.Font.FontStyle == sstp.TabData.Font.FontStyle) subFmt.StepData[i].TabData.Font.FontStyle = null;
}
if (mstp.TabData.IdentEdit == sstp.TabData.IdentEdit) subFmt.StepData[i].TabData.IdentEdit = null; if (mstp.TabData.IdentEdit == sstp.TabData.IdentEdit) subFmt.StepData[i].TabData.IdentEdit = null;
if (mstp.TabData.Ident == sstp.TabData.Ident) subFmt.StepData[i].TabData.Ident = null; if (mstp.TabData.Ident == sstp.TabData.Ident) subFmt.StepData[i].TabData.Ident = null;
if (mstp.TabData.RNOIdentEdit == sstp.TabData.RNOIdentEdit) subFmt.StepData[i].TabData.RNOIdentEdit = null; if (mstp.TabData.RNOIdentEdit == sstp.TabData.RNOIdentEdit) subFmt.StepData[i].TabData.RNOIdentEdit = null;
@ -4389,40 +4577,20 @@ namespace fmtxml
if (mbox.TxtWidth == sbox.TxtWidth) sbox.TxtWidth = 0; if (mbox.TxtWidth == sbox.TxtWidth) sbox.TxtWidth = 0;
if (mbox.Height == sbox.Height) sbox.Height = 0; if (mbox.Height == sbox.Height) sbox.Height = 0;
if (mbox.TabPos == sbox.TabPos) sbox.TabPos = 0; if (mbox.TabPos == sbox.TabPos) sbox.TabPos = 0;
if (mbox.Font != null && sbox.Font != null) subFmt.BoxData[i].Font = FixInheritedFont(sbox.Font, mbox.Font); // Phase 3
{
if (mbox.Font.FontFamily == sbox.Font.FontFamily) sbox.Font.FontFamily = null;
if (mbox.Font.FontSize == sbox.Font.FontSize) sbox.Font.FontSize = null;
if (mbox.Font.FontStyle == sbox.Font.FontStyle) sbox.Font.FontStyle = null;
}
} }
StepSectionLayout msctlay = mainFmt.SectData.StepSectionData.StpSectLayData; StepSectionLayout msctlay = mainFmt.SectData.StepSectionData.StpSectLayData;
StepSectionLayout ssctlay = subFmt.SectData.StepSectionData.StpSectLayData; StepSectionLayout ssctlay = subFmt.SectData.StepSectionData.StpSectLayData;
if (msctlay.TableCenterPos == ssctlay.TableCenterPos) subFmt.SectData.StepSectionData.StpSectLayData.TableCenterPos = null; if (msctlay.TableCenterPos == ssctlay.TableCenterPos) subFmt.SectData.StepSectionData.StpSectLayData.TableCenterPos = null;
if (msctlay.TopOfPage.Font != null && ssctlay.TopOfPage.Font != null) subFmt.SectData.StepSectionData.StpSectLayData.TopOfPage.Font = FixInheritedFont(ssctlay.TopOfPage.Font, msctlay.TopOfPage.Font);// Phase 4
{
if (msctlay.TopOfPage.Font.FontFamily == ssctlay.TopOfPage.Font.FontFamily) subFmt.SectData.StepSectionData.StpSectLayData.TopOfPage.Font.FontFamily = null;
if (msctlay.TopOfPage.Font.FontSize == ssctlay.TopOfPage.Font.FontSize) subFmt.SectData.StepSectionData.StpSectLayData.TopOfPage.Font.FontSize = null;
if (msctlay.TopOfPage.Font.FontStyle == ssctlay.TopOfPage.Font.FontStyle) subFmt.SectData.StepSectionData.StpSectLayData.TopOfPage.Font.FontStyle = null;
}
if (msctlay.TopOfPage.Row == ssctlay.TopOfPage.Row) subFmt.SectData.StepSectionData.StpSectLayData.TopOfPage.Row = 0; if (msctlay.TopOfPage.Row == ssctlay.TopOfPage.Row) subFmt.SectData.StepSectionData.StpSectLayData.TopOfPage.Row = 0;
if (msctlay.TopOfPage.Col == ssctlay.TopOfPage.Col) subFmt.SectData.StepSectionData.StpSectLayData.TopOfPage.Col = 0; if (msctlay.TopOfPage.Col == ssctlay.TopOfPage.Col) subFmt.SectData.StepSectionData.StpSectLayData.TopOfPage.Col = 0;
StepSectionPrint msctpr = mainFmt.SectData.StepSectionData.StpSectPrtData; StepSectionPrint msctpr = mainFmt.SectData.StepSectionData.StpSectPrtData;
StepSectionPrint ssctpr = subFmt.SectData.StepSectionData.StpSectPrtData; StepSectionPrint ssctpr = subFmt.SectData.StepSectionData.StpSectPrtData;
if (msctpr.ModifiedTextStyle != null && ssctpr.ModifiedTextStyle != null) subFmt.SectData.StepSectionData.StpSectPrtData.ModifiedTextStyle = FixInheritedFont(msctpr.ModifiedTextStyle, msctpr.ModifiedTextStyle); // Phase 11
{ subFmt.SectData.StepSectionData.StpSectLayData.Separator.Font = FixInheritedFont(ssctlay.Separator.Font, msctlay.Separator.Font); // Phase 5
if (msctpr.ModifiedTextStyle.FontFamily == ssctpr.ModifiedTextStyle.FontFamily) subFmt.SectData.StepSectionData.StpSectPrtData.ModifiedTextStyle.FontFamily = null;
if (msctpr.ModifiedTextStyle.FontSize == ssctpr.ModifiedTextStyle.FontSize) subFmt.SectData.StepSectionData.StpSectPrtData.ModifiedTextStyle.FontSize = null;
if (msctpr.ModifiedTextStyle.FontStyle == ssctpr.ModifiedTextStyle.FontStyle) subFmt.SectData.StepSectionData.StpSectPrtData.ModifiedTextStyle.FontStyle = null;
}
if (msctlay.Separator.Font != null && ssctlay.Separator.Font != null)
{
if (msctlay.Separator.Font.FontFamily == ssctlay.Separator.Font.FontFamily) subFmt.SectData.StepSectionData.StpSectLayData.Separator.Font.FontFamily = null;
if (msctlay.Separator.Font.FontSize == ssctlay.Separator.Font.FontSize) subFmt.SectData.StepSectionData.StpSectLayData.Separator.Font.FontSize = null;
if (msctlay.Separator.Font.FontStyle == ssctlay.Separator.Font.FontStyle) subFmt.SectData.StepSectionData.StpSectLayData.Separator.Font.FontStyle = null;
}
if (msctlay.Separator.SeparatorLocation == ssctlay.Separator.SeparatorLocation) subFmt.SectData.StepSectionData.StpSectLayData.Separator.SeparatorLocation = 0; if (msctlay.Separator.SeparatorLocation == ssctlay.Separator.SeparatorLocation) subFmt.SectData.StepSectionData.StpSectLayData.Separator.SeparatorLocation = 0;
if (msctlay.LastLineToStartStep == ssctlay.LastLineToStartStep) subFmt.SectData.StepSectionData.StpSectLayData.LastLineToStartStep = 0; if (msctlay.LastLineToStartStep == ssctlay.LastLineToStartStep) subFmt.SectData.StepSectionData.StpSectLayData.LastLineToStartStep = 0;
@ -4494,12 +4662,7 @@ namespace fmtxml
for (int i = 0; i < MAXCHKHEADINGS; i++) for (int i = 0; i < MAXCHKHEADINGS; i++)
{ {
if (mco.CheckOffHeaderList[i].CheckOffHeading == sco.CheckOffHeaderList[i].CheckOffHeading) subFmt.ProcData.CheckOffData.CheckOffHeaderList[i].CheckOffHeading = null; if (mco.CheckOffHeaderList[i].CheckOffHeading == sco.CheckOffHeaderList[i].CheckOffHeading) subFmt.ProcData.CheckOffData.CheckOffHeaderList[i].CheckOffHeading = null;
if (mco.CheckOffHeaderList[i].Font != null && sco.CheckOffHeaderList[i].Font != null) sco.CheckOffHeaderList[i].Font = FixInheritedFont(sco.CheckOffHeaderList[i].Font, mco.CheckOffHeaderList[i].Font); // Phase 6
{
if (mco.CheckOffHeaderList[i].Font.FontFamily == sco.CheckOffHeaderList[i].Font.FontFamily) subFmt.ProcData.CheckOffData.CheckOffHeaderList[i].Font.FontFamily = null;
if (mco.CheckOffHeaderList[i].Font.FontSize == sco.CheckOffHeaderList[i].Font.FontSize) subFmt.ProcData.CheckOffData.CheckOffHeaderList[i].Font.FontSize = null;
if (mco.CheckOffHeaderList[i].Font.FontStyle == sco.CheckOffHeaderList[i].Font.FontStyle) subFmt.ProcData.CheckOffData.CheckOffHeaderList[i].Font.FontStyle = null;
}
} }
if (mco.UseCheckOffsIn == sco.UseCheckOffsIn) subFmt.ProcData.CheckOffData.UseCheckOffsIn = 0; if (mco.UseCheckOffsIn == sco.UseCheckOffsIn) subFmt.ProcData.CheckOffData.UseCheckOffsIn = 0;
if (mco.CheckOffAdjustment == sco.CheckOffAdjustment) subFmt.ProcData.CheckOffData.CheckOffAdjustment = 0; if (mco.CheckOffAdjustment == sco.CheckOffAdjustment) subFmt.ProcData.CheckOffData.CheckOffAdjustment = 0;
@ -4513,22 +4676,17 @@ namespace fmtxml
//for (int i = 0; i < MAXSEQ; i++) //for (int i = 0; i < MAXSEQ; i++)
// if (msctstp.SeqStart[i] == ssctstp.SeqStart[i]) subFmt.SectData.StepSectionData.SeqStart[i] = 0; // if (msctstp.SeqStart[i] == ssctstp.SeqStart[i]) subFmt.SectData.StepSectionData.SeqStart[i] = 0;
for (int i = 0; i < MAXSEQ; i++) //for (int i = 0; i < MAXSEQ; i++)
{ //{
if (msctstp.SequentialTabFormat[i].LeftJustify == ssctstp.SequentialTabFormat[i].LeftJustify) subFmt.SectData.StepSectionData.SequentialTabFormat[i].LeftJustify = 0; //if (msctstp.SequentialTabFormat[i].LeftJustify == ssctstp.SequentialTabFormat[i].LeftJustify) subFmt.SectData.StepSectionData.SequentialTabFormat[i].LeftJustify = 0;
if (msctstp.SequentialTabFormat[i].TabFormat == ssctstp.SequentialTabFormat[i].TabFormat) subFmt.SectData.StepSectionData.SequentialTabFormat[i].TabFormat = null; //if (msctstp.SequentialTabFormat[i].TabFormat == ssctstp.SequentialTabFormat[i].TabFormat) subFmt.SectData.StepSectionData.SequentialTabFormat[i].TabFormat = null;
} //}
//if (msctstp.HighSeqStart == ssctstp.HighSeqStart) subFmt.SectData.StepSectionData.HighSeqStart = 0; //if (msctstp.HighSeqStart == ssctstp.HighSeqStart) subFmt.SectData.StepSectionData.HighSeqStart = 0;
if (msctstp.IndentToken == ssctstp.IndentToken) subFmt.SectData.StepSectionData.IndentToken = 0; if (msctstp.IndentToken == ssctstp.IndentToken) subFmt.SectData.StepSectionData.IndentToken = 0;
if (msctpr.ImmStepHdrCol == ssctpr.ImmStepHdrCol) subFmt.SectData.StepSectionData.StpSectPrtData.ImmStepHdrCol = 0; if (msctpr.ImmStepHdrCol == ssctpr.ImmStepHdrCol) subFmt.SectData.StepSectionData.StpSectPrtData.ImmStepHdrCol = 0;
if (msctpr.ImmStepHdrStyle != null && ssctpr.ImmStepHdrStyle != null) subFmt.SectData.StepSectionData.StpSectPrtData.ImmStepHdrStyle = FixInheritedFont(ssctpr.ImmStepHdrStyle, msctpr.ImmStepHdrStyle);
{
if (msctpr.ImmStepHdrStyle.FontFamily == ssctpr.ImmStepHdrStyle.FontFamily) subFmt.SectData.StepSectionData.StpSectPrtData.ImmStepHdrStyle.FontFamily = null;
if (msctpr.ImmStepHdrStyle.FontSize == ssctpr.ImmStepHdrStyle.FontSize) subFmt.SectData.StepSectionData.StpSectPrtData.ImmStepHdrStyle.FontSize = null;
if (msctpr.ImmStepHdrStyle.FontStyle == ssctpr.ImmStepHdrStyle.FontStyle) subFmt.SectData.StepSectionData.StpSectPrtData.ImmStepHdrStyle.FontStyle = null;
}
if (msctstp.WolfCreekBackgroundFormat != null && msctstp.WolfCreekBackgroundFormat == ssctstp.WolfCreekBackgroundFormat) subFmt.SectData.StepSectionData.WolfCreekBackgroundFormat = "null"; if (msctstp.WolfCreekBackgroundFormat != null && msctstp.WolfCreekBackgroundFormat == ssctstp.WolfCreekBackgroundFormat) subFmt.SectData.StepSectionData.WolfCreekBackgroundFormat = "null";
if (msctstp.WolfcreekCKLFormat != null && msctstp.WolfcreekCKLFormat == ssctstp.WolfcreekCKLFormat) subFmt.SectData.StepSectionData.WolfcreekCKLFormat = "null"; if (msctstp.WolfcreekCKLFormat != null && msctstp.WolfcreekCKLFormat == ssctstp.WolfcreekCKLFormat) subFmt.SectData.StepSectionData.WolfcreekCKLFormat = "null";
if (msctstp.WolfcreekCKLBackgndFormat != null && msctstp.WolfcreekCKLBackgndFormat == ssctstp.WolfcreekCKLBackgndFormat) subFmt.SectData.StepSectionData.WolfcreekCKLBackgndFormat = "null"; if (msctstp.WolfcreekCKLBackgndFormat != null && msctstp.WolfcreekCKLBackgndFormat == ssctstp.WolfcreekCKLBackgndFormat) subFmt.SectData.StepSectionData.WolfcreekCKLBackgndFormat = "null";
@ -4556,20 +4714,10 @@ namespace fmtxml
SectionNum ssctn = subFmt.SectData.SectionNumber; SectionNum ssctn = subFmt.SectData.SectionNumber;
SectionHead mscth = mainFmt.SectData.SectionHeader; SectionHead mscth = mainFmt.SectData.SectionHeader;
SectionHead sscth = subFmt.SectData.SectionHeader; SectionHead sscth = subFmt.SectData.SectionHeader;
if (msctn.Font != null && ssctn.Font != null) subFmt.SectData.SectionNumber.Font = FixInheritedFont(ssctn.Font, msctn.Font); // Phase 7
{ if (msctn.Pos == ssctn.Pos) subFmt.SectData.SectionNumber.Pos = 0;
if (msctn.Font.FontFamily == ssctn.Font.FontFamily) subFmt.SectData.SectionNumber.Font.FontFamily = null;
if (msctn.Font.FontSize == ssctn.Font.FontSize) subFmt.SectData.SectionNumber.Font.FontSize = null;
if (msctn.Font.FontStyle == ssctn.Font.FontStyle) subFmt.SectData.SectionNumber.Font.FontStyle = null;
}
if (msctn.Pos == ssctn.Pos) subFmt.SectData.SectionNumber.Pos =0;
if (msctn.Just == ssctn.Just) subFmt.SectData.SectionNumber.Just = null; if (msctn.Just == ssctn.Just) subFmt.SectData.SectionNumber.Just = null;
if (mscth.Font != null && sscth.Font != null) subFmt.SectData.SectionHeader.Font = FixInheritedFont(sscth.Font, mscth.Font); // Phase 8
{
if (mscth.Font.FontFamily == sscth.Font.FontFamily) subFmt.SectData.SectionHeader.Font.FontFamily = null;
if (mscth.Font.FontSize == sscth.Font.FontSize) subFmt.SectData.SectionHeader.Font.FontSize = null;
if (mscth.Font.FontStyle == sscth.Font.FontStyle) subFmt.SectData.SectionHeader.Font.FontStyle = null;
}
if (mscth.Pos == sscth.Pos) subFmt.SectData.SectionHeader.Pos =0; if (mscth.Pos == sscth.Pos) subFmt.SectData.SectionHeader.Pos =0;
if (mscth.Just == sscth.Just) subFmt.SectData.SectionHeader.Just = null; if (mscth.Just == sscth.Just) subFmt.SectData.SectionHeader.Just = null;
@ -4601,19 +4749,8 @@ namespace fmtxml
if (maccsec.TableOfContentsData.TofCPageNumPos == saccsec.TableOfContentsData.TofCPageNumPos) subFmt.SectData.AccSectionData.TableOfContentsData.TofCPageNumPos = 0; if (maccsec.TableOfContentsData.TofCPageNumPos == saccsec.TableOfContentsData.TofCPageNumPos) subFmt.SectData.AccSectionData.TableOfContentsData.TofCPageNumPos = 0;
if (maccsec.TableOfContentsData.TofCSpaceChar == saccsec.TableOfContentsData.TofCSpaceChar) subFmt.SectData.AccSectionData.TableOfContentsData.TofCSpaceChar = 0; if (maccsec.TableOfContentsData.TofCSpaceChar == saccsec.TableOfContentsData.TofCSpaceChar) subFmt.SectData.AccSectionData.TableOfContentsData.TofCSpaceChar = 0;
if (maccsec.TableOfContentsData.TofCLineSpacing == saccsec.TableOfContentsData.TofCLineSpacing) subFmt.SectData.AccSectionData.TableOfContentsData.TofCLineSpacing = 0; if (maccsec.TableOfContentsData.TofCLineSpacing == saccsec.TableOfContentsData.TofCLineSpacing) subFmt.SectData.AccSectionData.TableOfContentsData.TofCLineSpacing = 0;
if (maccsec.TableOfContentsData.Font != null && saccsec.TableOfContentsData.Font != null) subFmt.SectData.AccSectionData.TableOfContentsData.Font = FixInheritedFont(saccsec.TableOfContentsData.Font, maccsec.TableOfContentsData.Font); // Phase 9
{ subFmt.SectData.StepSectionData.StpSectLayData.VertStyle = FixInheritedFont(ssctlay.VertStyle, msctlay.VertStyle);// Phase 13
if (maccsec.TableOfContentsData.Font.FontFamily == saccsec.TableOfContentsData.Font.FontFamily) subFmt.SectData.AccSectionData.TableOfContentsData.Font.FontFamily = null;
if (maccsec.TableOfContentsData.Font.FontSize == saccsec.TableOfContentsData.Font.FontSize) subFmt.SectData.AccSectionData.TableOfContentsData.Font.FontSize = null;
if (maccsec.TableOfContentsData.Font.FontStyle == saccsec.TableOfContentsData.Font.FontStyle) subFmt.SectData.AccSectionData.TableOfContentsData.Font.FontStyle = null;
}
if (msctlay.VertStyle != null && ssctlay.VertStyle != null)
{
if (msctlay.VertStyle.FontFamily == ssctlay.VertStyle.FontFamily) subFmt.SectData.StepSectionData.StpSectLayData.VertStyle.FontFamily = null;
if (msctlay.VertStyle.FontSize == ssctlay.VertStyle.FontSize) subFmt.SectData.StepSectionData.StpSectLayData.VertStyle.FontSize = null;
if (msctlay.VertStyle.FontStyle == ssctlay.VertStyle.FontStyle) subFmt.SectData.StepSectionData.StpSectLayData.VertStyle.FontStyle = null;
}
//if (msctstp.LeftJustSeqTab == ssctstp.LeftJustSeqTab) subFmt.SectData.StepSectionData.LeftJustSeqTab = null; //if (msctstp.LeftJustSeqTab == ssctstp.LeftJustSeqTab) subFmt.SectData.StepSectionData.LeftJustSeqTab = null;
for (int i = 0; i < 10; i++) for (int i = 0; i < 10; i++)
@ -4800,6 +4937,24 @@ namespace fmtxml
#endregion #endregion
return true; return true;
} }
//private bool _LookForChange = false;
private VE_Font FixInheritedFont(VE_Font font, VE_Font inhFont)
{
if (inhFont != null && font != null)
{
if (!font.CanInherit()) return font; // Already partially inherited
if (inhFont.FontFamily == font.FontFamily) font.FontFamily = null;
if (inhFont.FontSize == font.FontSize) font.FontSize = null;
if (inhFont.FontStyle == font.FontStyle) font.FontStyle = null;
if (inhFont.FontJustify == font.FontJustify) font.FontJustify = null;
if (inhFont.FontCheckOff == font.FontCheckOff) font.FontCheckOff = null;
//if (_LookForChange && !font.CanInherit())
// Console.WriteLine("Change Happened");
if (font.FontFamily == null && font.FontSize == null && font.FontStyle == null && font.FontJustify == null && font.FontCheckOff == null)
font = null;
}
return font;
}
#endregion #endregion
#region DoStepInherit #region DoStepInherit
delegate string StepPartStr(Step stp); delegate string StepPartStr(Step stp);
@ -4827,7 +4982,17 @@ namespace fmtxml
if (stp.Font == null) return null; if (stp.Font == null) return null;
return stp.Font.FontStyle; return stp.Font.FontStyle;
} }
private string StepPartLayoutForeColor(Step stp) { return stp.StepLayoutData.ForeColor;} private string StepPartFontJustify(Step stp)
{
if (stp.Font == null) return null;
return stp.Font.FontJustify;
}
private string StepPartFontCheckOff(Step stp)
{
if (stp.Font == null) return null;
return stp.Font.FontCheckOff;
}
private string StepPartLayoutForeColor(Step stp) { return stp.StepLayoutData.ForeColor; }
private string StepPartLayoutBackColor(Step stp) { return stp.StepLayoutData.BackColor; } private string StepPartLayoutBackColor(Step stp) { return stp.StepLayoutData.BackColor; }
private string StepPartLayoutSTExtraSpace(Step stp) { return stp.StepLayoutData.STExtraSpace; } private string StepPartLayoutSTExtraSpace(Step stp) { return stp.StepLayoutData.STExtraSpace; }
private string StepPartLayoutSTBoxindex(Step stp) { return stp.StepLayoutData.STBoxindex; } private string StepPartLayoutSTBoxindex(Step stp) { return stp.StepLayoutData.STBoxindex; }
@ -4874,6 +5039,16 @@ namespace fmtxml
{ {
if (stp.TabData.Font == null) return null; if (stp.TabData.Font == null) return null;
return stp.TabData.Font.FontStyle; return stp.TabData.Font.FontStyle;
}
private string StepPartTabFontJustify(Step stp)
{
if (stp.TabData.Font == null) return null;
return stp.TabData.Font.FontJustify;
}
private string StepPartTabFontCheckOff(Step stp)
{
if (stp.TabData.Font == null) return null;
return stp.TabData.Font.FontCheckOff;
} }
private string StepPartEditTypeInMenu(Step stp){return stp.StepEditData.TypeMenu.InMenu;} private string StepPartEditTypeInMenu(Step stp){return stp.StepEditData.TypeMenu.InMenu;}
private string StepPartEditTypeRnoInMenu(Step stp){return stp.StepEditData.TypeMenu.RnoInMenu;} private string StepPartEditTypeRnoInMenu(Step stp){return stp.StepEditData.TypeMenu.RnoInMenu;}
@ -4901,12 +5076,19 @@ namespace fmtxml
if (CheckInheritedStr(new StepPartStr(StepPartVertPos), step, dicParents)) step.VertPos = null; if (CheckInheritedStr(new StepPartStr(StepPartVertPos), step, dicParents)) step.VertPos = null;
// substructures - Font // substructures - Font
if (step.Font != null && CheckInheritedStr(new StepPartStr(StepPartFontFamily), step, dicParents)) if (step.Font != null && CheckInheritedStr(new StepPartStr(StepPartFontFamily), step, dicParents))
{
//Console.WriteLine("Step[{0}] {1} - {2}", step.Index, step.Type, step.Font.FontFamily);
step.Font.FontFamily = null; step.Font.FontFamily = null;
}
if (step.Font != null && CheckInheritedStr(new StepPartStr(StepPartFontStyle), step, dicParents)) if (step.Font != null && CheckInheritedStr(new StepPartStr(StepPartFontStyle), step, dicParents))
step.Font.FontStyle = null; step.Font.FontStyle = null;
if (step.Font != null && CheckInheritedStr(new StepPartStr(StepPartFontSize), step, dicParents)) if (step.Font != null && CheckInheritedStr(new StepPartStr(StepPartFontSize), step, dicParents))
step.Font.FontSize = null; step.Font.FontSize = null;
if ((step.Font != null) && (step.Font.FontFamily == null) && (step.Font.FontStyle == null) && (step.Font.FontSize == null)) if (step.Font != null && CheckInheritedStr(new StepPartStr(StepPartFontJustify), step, dicParents))
step.Font.FontJustify = null;
if (step.Font != null && CheckInheritedStr(new StepPartStr(StepPartFontCheckOff), step, dicParents))
step.Font.FontCheckOff = null;
if ((step.Font != null) && (step.Font.FontFamily == null) && (step.Font.FontStyle == null) && (step.Font.FontSize == null) && (step.Font.FontJustify == null) && (step.Font.FontCheckOff == null))
step.Font = null; step.Font = null;
// substructure - StepLayoutData // substructure - StepLayoutData
if (CheckInheritedStr(new StepPartStr(StepPartLayoutForeColor), step, dicParents)) step.StepLayoutData.ForeColor = null; if (CheckInheritedStr(new StepPartStr(StepPartLayoutForeColor), step, dicParents)) step.StepLayoutData.ForeColor = null;
@ -4934,8 +5116,8 @@ namespace fmtxml
if (CheckInheritedStr(new StepPartStr(StepPartEditTypeNoChg_Reason), step, dicParents)) step.StepEditData.TypeMenu.NoChgReason = null; if (CheckInheritedStr(new StepPartStr(StepPartEditTypeNoChg_Reason), step, dicParents)) step.StepEditData.TypeMenu.NoChgReason = null;
if (CheckInheritedStr(new StepPartStr(StepPartEditTypeAlternateNameList), step, dicParents)) step.StepEditData.TypeMenu.AlternateNameList = null; if (CheckInheritedStr(new StepPartStr(StepPartEditTypeAlternateNameList), step, dicParents)) step.StepEditData.TypeMenu.AlternateNameList = null;
// substructure - StepPrintData // substructure - StepPrintData
if (CheckInheritedStr(new StepPartStr(StepPartPrintForeColor), step, dicParents)) step.StepEditData.ForeColor = null; if (CheckInheritedStr(new StepPartStr(StepPartPrintForeColor), step, dicParents)) step.StepPrintData.ForeColor = null;
if (CheckInheritedStr(new StepPartStr(StepPartPrintBackColor), step, dicParents)) step.StepEditData.BackColor = null; if (CheckInheritedStr(new StepPartStr(StepPartPrintBackColor), step, dicParents)) step.StepPrintData.BackColor = null;
if (CheckInheritedStr(new StepPartStr(StepPartPrintPosAdjust), step, dicParents)) step.StepPrintData.PosAdjust = null; if (CheckInheritedStr(new StepPartStr(StepPartPrintPosAdjust), step, dicParents)) step.StepPrintData.PosAdjust = null;
// substructure - TabData // substructure - TabData
if (CheckInheritedStr(new StepPartStr(StepPartTabIdentEdit), step, dicParents)) step.TabData.IdentEdit = null; if (CheckInheritedStr(new StepPartStr(StepPartTabIdentEdit), step, dicParents)) step.TabData.IdentEdit = null;
@ -4956,7 +5138,11 @@ namespace fmtxml
step.TabData.Font.FontStyle = null; step.TabData.Font.FontStyle = null;
if (step.TabData.Font != null && CheckInheritedStr(new StepPartStr(StepPartTabFontSize), step, dicParents)) if (step.TabData.Font != null && CheckInheritedStr(new StepPartStr(StepPartTabFontSize), step, dicParents))
step.TabData.Font.FontSize = null; step.TabData.Font.FontSize = null;
if ((step.TabData.Font != null) && (step.TabData.Font.FontFamily == null) && (step.TabData.Font.FontStyle == null) && (step.TabData.Font.FontSize == null)) if (step.TabData.Font != null && CheckInheritedStr(new StepPartStr(StepPartTabJustify), step, dicParents))
step.TabData.Font.FontJustify = null;
if (step.TabData.Font != null && CheckInheritedStr(new StepPartStr(StepPartTabCheckOff), step, dicParents))
step.TabData.Font.FontCheckOff = null;
if ((step.TabData.Font != null) && (step.TabData.Font.FontFamily == null) && (step.TabData.Font.FontStyle == null) && (step.TabData.Font.FontSize == null) && (step.TabData.Font.FontJustify == null) && (step.TabData.Font.FontCheckOff == null))
step.TabData.Font = null; step.TabData.Font = null;
} }
@ -4985,5 +5171,70 @@ namespace fmtxml
return dicParent; return dicParent;
} }
#endregion #endregion
private void FixInactiveForHigh(ref FormatData fmtdata) // set all the HighLevelSteps beyond
{
Step[] stpdata = fmtdata.StepData;
int numHigh = fmtdata.SectData.StepSectionData.NumberOfHighLevelSteps;
if (numHigh == 0) return;
if (numHigh < HighTypeValue.Length) // need to set steps to inactive beyond numHigh
{
for (int i = numHigh; i < HighTypeValue.Length; i++)
{
string inactiveType = HighTypeValue[i];
for(int j = 0;j < stpdata.Length; j++)
{
if (stpdata[j].Type == inactiveType)
stpdata[j].Inactive = "True";
} }
}
}
}
private void FixInactiveForSubStep(ref FormatData fmtdata)
{
Step[] stpdata = fmtdata.StepData;
int numSub = fmtdata.SectData.StepSectionData.NumberOfSubStepTypes;
if (numSub == 0) return;
if (numSub < SubStepValue.Length) // need to set steps to inactive beyond numHigh
{
for (int i = numSub; i < SubStepValue.Length; i++)
{
string inactiveType = SubStepValue[i];
for (int j = 0; j < stpdata.Length; j++)
{
if (stpdata[j].Type == inactiveType)
stpdata[j].Inactive = "True";
}
}
}
}
private void FixInactiveForText(ref FormatData fmtdata)
{
Step[] stpdata = fmtdata.StepData;
if ((_AlternateIndex ?? "") == "") return;
string mask = "," + _AlternateIndex + ",";
foreach (string textType in TextTypes)
{
if (!mask.Contains("," + textType + ","))
{
for (int j = 0; j < stpdata.Length; j++)
{
if (stpdata[j].Type == textType)
stpdata[j].Inactive = "True";
}
}
}
}
private string [] HighTypeValue={"High","Continuous","Immediate","LossOfAC","High5"};
private string [] SubStepValue = {"Substep","And","Or","EquipmentList","EquipmentWBlank",
"ExplicitAnd","ImplicitOr","Paragraph","EquipmentOpt","EquipmentOptWBlank","ContAcSequential",
"ContAcAnd","ContAcOr","ContAcParagraph","TitleWithTextRight","TitleWithTextBelow"};
private string[] TextTypes = {"Caution","Caution1","Caution2","Caution3","Caution4",
"Note","Note1","Note2","Note3","Note4","Note5"};
private bool RHMDebugPause(string fname, string lookfor)
{
return lookfor.Contains("." + fname.Substring(0, fname.LastIndexOf(".")).ToLower() + ".");
}
}
} }

View File

@ -30,7 +30,8 @@ public struct PSItem
{ {
public int Row; public int Row;
public int Col; public int Col;
public E_PageStructMod Justify; //public E_PageStructMod Justify;
public string Justify;
public VE_Font Style; public VE_Font Style;
public string Token; public string Token;
} }
@ -280,7 +281,17 @@ internal class VE_DocStyleConverter:ExpandableObjectConverter
public class VE_Font public class VE_Font
{ {
uint i; uint i;
private bool _PartialInheritance = false;
//public bool PartialInheritance
//{
// get { return _PartialInheritance; }
// set { _PartialInheritance = value; }
//}
public bool CanInherit()
{
return !_PartialInheritance;
}
public VE_Font(string s) public VE_Font(string s)
{ {
@ -313,7 +324,13 @@ public class VE_Font
_FontFamilySet = true; _FontFamilySet = true;
return _FontFamily; return _FontFamily;
} }
set {_FontFamily=value;} set { CheckPartial(_FontFamily,value); _FontFamily = value; }
}
private void CheckPartial(string member, string value)
{
if (member != null && value == null)
_PartialInheritance = true;
} }
private string _FontSize = null; private string _FontSize = null;
private bool _FontSizeSet = false; private bool _FontSizeSet = false;
@ -325,7 +342,7 @@ public class VE_Font
_FontSizeSet = true; _FontSizeSet = true;
return _FontSize; return _FontSize;
} }
set { _FontSize = value;} set { CheckPartial(_FontSize, value); _FontSize = value; }
//set { i = ((uint)value) | (i & 0xFFFFFFC0); } //set { i = ((uint)value) | (i & 0xFFFFFFC0); }
} }
//public E_FontName FontName //public E_FontName FontName
@ -344,7 +361,7 @@ public class VE_Font
return _FontStyle; return _FontStyle;
} }
// return (E_FontStyle)(i & 0xFFFFFFC0);} // return (E_FontStyle)(i & 0xFFFFFFC0);}
set { _FontStyle = value;} set { CheckPartial(_FontStyle, value); _FontStyle = value; }
//set{i = ((uint)value) | (i & 0x3F);} //set{i = ((uint)value) | (i & 0x3F);}
} }
private string _FontCheckOff = null; private string _FontCheckOff = null;
@ -366,7 +383,7 @@ public class VE_Font
_FontCheckOffSet = true; _FontCheckOffSet = true;
return _FontCheckOff; return _FontCheckOff;
} }
set { _FontCheckOff = value; } set { CheckPartial(_FontCheckOff, value); _FontCheckOff = value; }
} }
private string _FontJustify = null; private string _FontJustify = null;
private bool _FontJustifySet = false; private bool _FontJustifySet = false;
@ -387,7 +404,7 @@ public class VE_Font
_FontJustifySet = true; _FontJustifySet = true;
return _FontJustify; return _FontJustify;
} }
set { _FontJustify = value; } set { CheckPartial(_FontJustify, value); _FontJustify = value; }
} }
public bool IsBoxed public bool IsBoxed
{ {
@ -548,22 +565,22 @@ namespace fmtxml
ArrayList stringoffsets = new ArrayList(); ArrayList stringoffsets = new ArrayList();
short strings = 0; short strings = 0;
PageStyles pgstyles = new PageStyles(); PageStyles pgstyles = new PageStyles();
string str = null;
// read in title. // read in title.
string fnm = MyPath + @"\" + fname; string fnm = MyPath + @"\" + fname;
Console.WriteLine(fname); Console.WriteLine(fname);
brFmt = new BinaryReader(File.Open(fnm,System.IO.FileMode.Open,System.IO.FileAccess.ReadWrite,FileShare.ReadWrite)); brFmt = new BinaryReader(File.Open(fnm,System.IO.FileMode.Open,System.IO.FileAccess.ReadWrite,FileShare.ReadWrite));
short len = brFmt.ReadInt16(); pgstyles.Name = GetAsciiString(brFmt);
pgstyles.Name = GetAsciiString(brFmt,len);
// read in struct name/def name/page file name // read in struct name/def name/page file name
for (int i=0;i<3;i++) //for (int i=0;i<3;i++)
{ //{
len = brFmt.ReadInt16(); // len = brFmt.ReadInt16();
str = GetAsciiString(brFmt,len); // str = GetAsciiString(brFmt,len);
} //}
string structName = GetAsciiString(brFmt);
string includeName = GetAsciiString(brFmt);
string formatName = GetAsciiString(brFmt);
// Get the number of page styles, and create the array for them. // Get the number of page styles, and create the array for them.
short numpgstyles = brFmt.ReadInt16(); short numpgstyles = brFmt.ReadInt16();
@ -586,8 +603,7 @@ namespace fmtxml
{ {
PageStyle pg = new PageStyle(); PageStyle pg = new PageStyle();
pg.Index=i; pg.Index=i;
len = brFmt.ReadInt16(); pg.Name = GetAsciiString(brFmt);
pg.Name = GetAsciiString(brFmt,len);
PSItem [] psitms = new PSItem[1]; PSItem [] psitms = new PSItem[1];
PSItem [] Fpsitms = null; PSItem [] Fpsitms = null;
@ -604,7 +620,8 @@ namespace fmtxml
// the column is 12 char/inch // the column is 12 char/inch
pi.Row = RowToPoints(brFmt.ReadInt16()); pi.Row = RowToPoints(brFmt.ReadInt16());
pi.Col = ColToPoints(brFmt.ReadInt16()); pi.Col = ColToPoints(brFmt.ReadInt16());
pi.Justify = (E_PageStructMod)brFmt.ReadUInt16(); //pi.Justify = (E_PageStructMod)brFmt.ReadUInt16();
pi.Justify = ((E_PageStructMod)brFmt.ReadUInt16()).ToString();
pi.Style = LoadVE_Font(); pi.Style = LoadVE_Font();
pi.Token = DoReplaceTokens(GetAsciiStringUntilNull(brFmt)); pi.Token = DoReplaceTokens(GetAsciiStringUntilNull(brFmt));
// replace the '<' with '{' & '>' with '}' // replace the '<' with '{' & '>' with '}'
@ -649,8 +666,7 @@ namespace fmtxml
{ {
serializer.Serialize(writer, pgstyles); serializer.Serialize(writer, pgstyles);
writer.Close(); writer.Close();
XslCompiledTransform xsl = new XslCompiledTransform(); XslCompiledTransform xsl = FmtFileToXml.getTransform(Application.StartupPath + "\\TranslatePag.XSL");
xsl.Load(Application.StartupPath + "\\TranslatePag.XSL");
string sResults = "fmt_xml\\" + lfmtname + "p.xml"; string sResults = "fmt_xml\\" + lfmtname + "p.xml";
xsl.Transform(destfile, sResults); // Perform Transform xsl.Transform(destfile, sResults); // Perform Transform
} }
@ -660,49 +676,82 @@ namespace fmtxml
writer.Close(); writer.Close();
} }
} }
private string GetAsciiString(BinaryReader brFmt)
{
short len = brFmt.ReadInt16();
return GetAsciiString(brFmt, len);
}
public void LoadDocFile(string fname) public void LoadDocFile(string fname)
{ {
ArrayList stringoffsets = new ArrayList(); ArrayList stringoffsets = new ArrayList();
short strings = 0; short strings = 0;
DocStyles dcstyles = new DocStyles(); DocStyles dcstyles = new DocStyles();
string str = null;
// read in title. // read in title.
string fnm = MyPath + @"\" + fname; string fnm = MyPath + @"\" + fname;
Console.WriteLine(fname); Console.WriteLine(fname);
brFmt = new BinaryReader(File.Open(fnm,System.IO.FileMode.Open,System.IO.FileAccess.ReadWrite,FileShare.ReadWrite)); brFmt = new BinaryReader(File.Open(fnm,System.IO.FileMode.Open,System.IO.FileAccess.ReadWrite,FileShare.ReadWrite));
short len = brFmt.ReadInt16(); dcstyles.Name = GetAsciiString(brFmt);
dcstyles.Name = GetAsciiString(brFmt,len);
// read in struct name/def name/doc file name // read in struct name/def name/doc file name
for (int i=0;i<3;i++) string structName = GetAsciiString(brFmt);
string includeName = GetAsciiString(brFmt);
string formatName = GetAsciiString(brFmt);
DocStyle[] dcs = null;
if (structName != "DOCSTYL.STR")
{ {
len = brFmt.ReadInt16(); Console.WriteLine("Other Structure {0}", structName);
str = GetAsciiString(brFmt,len); if (structName == "BKPGDOC.STR")
{
for(int i=0;i<4;i++) brFmt.ReadInt16(); // Skip 4 integers
dcs = new DocStyle[4];
string baseName = GetAsciiString(brFmt);
dcs[0].Index = 0;
dcs[1].Index = 1;
dcs[2].Index = 2;
dcs[3].Index = 3;
dcs[0].Name = baseName + "- portrait @ 6 lpi";
dcs[1].Name = baseName + "- portrait @ 4 lpi";
dcs[2].Name = baseName + "- landscape @ 6 lpi";
dcs[3].Name = baseName + "- landscape @ 4 lpi";
brFmt.ReadInt16();
dcs[0].dstyle = LoadVE_Font();
dcs[1].dstyle = dcs[0].dstyle.Copy();
dcs[2].dstyle = dcs[0].dstyle.Copy();
dcs[3].dstyle = dcs[0].dstyle.Copy();
dcs[0].PTopRow = dcs[1].PTopRow = dcs[2].PTopRow = dcs[3].PTopRow = brFmt.ReadInt16();
dcs[0].LeftMargin = dcs[1].LeftMargin = dcs[2].LeftMargin = dcs[3].LeftMargin = brFmt.ReadInt16();
dcs[0].PageLength = brFmt.ReadInt16();
dcs[1].PageLength = brFmt.ReadInt16();
dcs[2].PageLength = brFmt.ReadInt16();
dcs[3].PageLength = brFmt.ReadInt16();
} }
}
else
{
// Get the number of page styles, and create the array for them. // Get the number of page styles, and create the array for them.
short numdcstyles = brFmt.ReadInt16(); short numdcstyles = brFmt.ReadInt16();
DocStyle [] dcs = new DocStyle[numdcstyles]; dcs = new DocStyle[numdcstyles];
short offptr = brFmt.ReadInt16(); // not sure what these bytes contain? short offptr = brFmt.ReadInt16(); // not sure what these bytes contain?
short vnum = brFmt.ReadInt16(); short vnum = brFmt.ReadInt16();
if (vnum!=0) if (vnum != 0)
{ {
strings = vnum; strings = vnum;
for(int i=0;i<strings;i++) for (int i = 0; i < strings; i++)
{ {
vnum=brFmt.ReadInt16(); vnum = brFmt.ReadInt16();
stringoffsets.Add(vnum); stringoffsets.Add(vnum);
} }
} }
for (short i=0;i<numdcstyles;i++) for (short i = 0; i < numdcstyles; i++)
{ {
DocStyle dc = new DocStyle(); DocStyle dc = new DocStyle();
dc.Index=i; dc.Index = i;
len = brFmt.ReadInt16(); dc.Name = GetAsciiString(brFmt);
dc.Name = GetAsciiString(brFmt,len);
vnum = brFmt.ReadInt16(); // not sure what this is! vnum = brFmt.ReadInt16(); // not sure what this is!
dc.pagestyle = brFmt.ReadInt16(); dc.pagestyle = brFmt.ReadInt16();
dc.dstyle = LoadVE_Font(); dc.dstyle = LoadVE_Font();
@ -723,26 +772,27 @@ namespace fmtxml
dc.EndStyle = LoadVE_Font(); dc.EndStyle = LoadVE_Font();
// use the string offsets to read in the strings. // use the string offsets to read in the strings.
int [] offst = new int[strings]; int[] offst = new int[strings];
for (int j=0; j<strings; j++) for (int j = 0; j < strings; j++)
{ {
offst[j] = brFmt.ReadInt32(); offst[j] = brFmt.ReadInt32();
} }
dc.DocStructStyle = LoadVE_DocStyle(); dc.DocStructStyle = LoadVE_DocStyle();
if (offst[0]!=0)dc.ContTop = DoReplaceTokens(GetAsciiStringUntilNull(brFmt)); if (offst[0] != 0) dc.ContTop = DoReplaceTokens(GetAsciiStringUntilNull(brFmt));
else dc.ContTop = null; else dc.ContTop = null;
if (offst[1]!=0)dc.ContBottom = DoReplaceTokens(GetAsciiStringUntilNull(brFmt)); if (offst[1] != 0) dc.ContBottom = DoReplaceTokens(GetAsciiStringUntilNull(brFmt));
else dc.ContBottom = null; else dc.ContBottom = null;
if (offst[2]!=0)dc.EndString = DoReplaceTokens(GetAsciiStringUntilNull(brFmt)); if (offst[2] != 0) dc.EndString = DoReplaceTokens(GetAsciiStringUntilNull(brFmt));
else dc.EndString = null; else dc.EndString = null;
if (offst[3]!=0)dc.FinalMsg = DoReplaceTokens(GetAsciiStringUntilNull(brFmt)); if (offst[3] != 0) dc.FinalMsg = DoReplaceTokens(GetAsciiStringUntilNull(brFmt));
else dc.FinalMsg = null; else dc.FinalMsg = null;
if (dc.ContTop == null && dc.ContBottom == null)dc.ContStyle = null; if (dc.ContTop == null && dc.ContBottom == null) dc.ContStyle = null;
if (dc.EndString == null) dc.EndStyle = null; if (dc.EndString == null) dc.EndStyle = null;
dcs[i] = dc; dcs[i] = dc;
vnum = brFmt.ReadInt16(); vnum = brFmt.ReadInt16();
} }
}
dcstyles.DcStyles = dcs; dcstyles.DcStyles = dcs;
brFmt.Close(); brFmt.Close();
@ -767,8 +817,7 @@ namespace fmtxml
{ {
serializer.Serialize(writer, dcstyles); serializer.Serialize(writer, dcstyles);
writer.Close(); writer.Close();
XslCompiledTransform xsl = new XslCompiledTransform(); XslCompiledTransform xsl = FmtFileToXml.getTransform(Application.StartupPath + "\\TranslateDoc.XSL");
xsl.Load(Application.StartupPath + "\\TranslateDoc.XSL");
string sResults = "fmt_xml\\" + lfmtname + "d.xml"; string sResults = "fmt_xml\\" + lfmtname + "d.xml";
xsl.Transform(destfile, sResults); // Perform Transform xsl.Transform(destfile, sResults); // Perform Transform
} }