diff --git a/PROMS/fmtxml/FmtFileToXml.cs b/PROMS/fmtxml/FmtFileToXml.cs
index 0a330c0a..465cc632 100644
--- a/PROMS/fmtxml/FmtFileToXml.cs
+++ b/PROMS/fmtxml/FmtFileToXml.cs
@@ -10,6 +10,7 @@ using System.Xml.Xsl;
using System.Xml;
using System.Xml.Serialization;
using System.ComponentModel;
+using System.Text.RegularExpressions;
#region StructDefinitions
// top of the format.
@@ -727,6 +728,7 @@ public struct SeqTabFmt
public int Index;
public int LeftJustify;
public string TabFormat;
+ public string PrintTabFormat;
}
[Serializable]
public struct StepSectionPrint
@@ -863,8 +865,8 @@ public struct Step
[Serializable]
public struct Edit
{
- public string ForeColor;
- public string BackColor;
+ public string ForeColor; // Doesn't exist in old format - See StepLayoutData
+ public string BackColor; // Doesn't exist in old format - See StepLayoutData
public string AcTable;
public string Searchable;
public TypeMenu TypeMenu;
@@ -900,8 +902,8 @@ public struct TypeMenu
[Serializable]
public struct Print
{
- public string ForeColor;
- public string BackColor;
+ public string ForeColor; // Doesn't exist in old format - See StepLayoutData
+ public string BackColor; // Doesn't exist in old format - See StepLayoutData
public string PosAdjust;
}
[Serializable]
@@ -925,6 +927,7 @@ public struct Tab
{
public string IdentEdit;
public string Ident;
+ public string IdentAltPrint;
public string RNOIdentEdit;
public string RNOIdent;
public string IdentEditWid;
@@ -933,6 +936,7 @@ public struct Tab
public string RNOIdentWid;
public string Justify; // from tbstyle - None, CENTER, LEFT, RIGHT
public string CheckOff; // from tbstyle - None, LEFT, RIGHT
+ public string UsePreviousStyle;
public VE_Font Font;
}
[Serializable]
@@ -1452,6 +1456,7 @@ namespace fmtxml
public string MyPath;
public FmtFileToXml(FmtFileToXml gendata, string nm, string path)
{
+ //DateTime tStart = DateTime.Now;
MyPath = path;
if (gendata == null)
HasBase = false;
@@ -1473,6 +1478,7 @@ namespace fmtxml
{
MessageBox.Show("Format name FAILED = " + nm, ex.Message);
}
+ //Console.WriteLine(" {0:0.000} seconds", TimeSpan.FromTicks(DateTime.Now.Ticks - tStart.Ticks).TotalSeconds);
}
#region GetBinaryReaderData
private byte[] GetByteArray(BinaryReader br, int len)
@@ -1739,12 +1745,12 @@ namespace fmtxml
private VE_Font LoadVE_Font()
{
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);
return retval;
- }
- return null;
+ //}
+ //return null;
}
private VE_Font LoadVE_FontByte()
{
@@ -2013,6 +2019,8 @@ namespace fmtxml
{
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)
{
int[] tmpshort3 = new int[3];
@@ -2049,8 +2057,9 @@ namespace fmtxml
// if this format has an associated PSI or TPL file, just read in the string & save
// it.
string otherfile = MyPath + @"\" + fname.Substring(0, fname.LastIndexOf(".")) + @".tpl";
- if (File.Exists(otherfile))
- fmtdata.TPL = File.ReadAllText(otherfile);
+ if (File.Exists(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";
if (File.Exists(otherfile))
fmtdata.PSI = File.ReadAllText(otherfile);
@@ -2073,9 +2082,13 @@ namespace fmtxml
{
fmtdata.StepData[i].Type = StepTypes[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++)
{
Int16 tmpcoli = brFmt.ReadInt16();
@@ -2135,6 +2148,22 @@ namespace fmtxml
for (int i = 0; i < MAXTABS; i++)
{
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++)
{
if (Tabindx[j] == i)
@@ -2554,6 +2583,7 @@ namespace fmtxml
indx = offset[arcnt];
arcnt++;
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
for (int i = 0; i < MAXREPLACE; i++)
@@ -2668,7 +2698,7 @@ namespace fmtxml
// 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
// can be changed to..
- string tmpalternateindx = null;
+ _AlternateIndex = null;
int [] tmparray={0,0,0,0,0,0,0,0,0,0};
for (int i = 0; i < 10; i++)
{
@@ -2680,16 +2710,16 @@ namespace fmtxml
string tmpstring = GetStringFromByte(input, indx);
// put this in the step data alternatename field. If there already is one. stop
// 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)
- Console.WriteLine("different name, " + 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);
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);
}
}
- if (tmpalternateindx != null)
+ if (_AlternateIndex != null)
{
// For any step types in the texttypevalue list, add the alternatename list:
for (int i = 0; i < 10; i++)
@@ -2699,7 +2729,7 @@ namespace fmtxml
// format->xml migration.
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();
}
}
@@ -2710,25 +2740,33 @@ namespace fmtxml
arcnt = arcnt + 50;
// some seqtab data.
-
- for (int i = 0; i < MAXSEQ; i++)
- {
- indx = offset[arcnt];
- arcnt++;
- if (indx > 0) fmtdata.SectData.StepSectionData.SequentialTabFormat[i].TabFormat = GetStringFromByte(input, indx) + fmtdata.SectData.StepSectionData.SequentialTabFormat[i].TabFormat;
- indx = offset[arcnt];
- arcnt++;
- if (indx > 0) tmpstr = GetStringFromByte(input, indx).Replace("\x08", "");
- }
- for (int i = 0; i < MAXSEQ; i++)
- {
- indx = offset[arcnt];
- arcnt++;
- if (indx > 0) tmpstr = GetStringFromByte(input, indx).Replace("\x08", "");
- indx = offset[arcnt];
- arcnt++;
- if (indx > 0) tmpstr = GetStringFromByte(input, indx).Replace("\x08", "");
- }
+ string [] tmpSeqStrings = new string[MAXSEQ];
+ for (int i = 0; i < MAXSEQ; i++)
+ {
+ tmpSeqStrings[i] = fmtdata.SectData.StepSectionData.SequentialTabFormat[i].TabFormat;
+ indx = offset[arcnt];
+ arcnt++;
+ if (indx > 0) // PreSeqTab - Edit
+ fmtdata.SectData.StepSectionData.SequentialTabFormat[i].TabFormat = GetStringFromByte(input, indx) + tmpSeqStrings[i];
+ indx = offset[arcnt];
+ arcnt++;
+ 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++)
+ {
+ indx = offset[arcnt];
+ arcnt++;
+ if (indx > 0) // PostSeqTab - Edit
+ fmtdata.SectData.StepSectionData.SequentialTabFormat[i].TabFormat += GetStringFromByte(input, indx);
+ indx = offset[arcnt];
+ arcnt++;
+ if (indx > 0) // PostSeqTab - Print
+ fmtdata.SectData.StepSectionData.SequentialTabFormat[i].PrintTabFormat += GetStringFromByte(input, indx);
+ }
indx = offset[arcnt];
arcnt++;
@@ -2922,7 +2960,7 @@ namespace fmtxml
}
}
}
- arcnt = arcnt + MAXTRANS;
+ //arcnt = arcnt + MAXTRANS;
// not used OutsideTransFmt & OutsideTransMenu
arcnt = arcnt + (MAXTRANS * 2);
@@ -2933,6 +2971,25 @@ namespace fmtxml
//not used BldLstFile
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];
arcnt++;
@@ -2962,6 +3019,32 @@ namespace fmtxml
return AdjustFlags(ref fmtdata, ref XtraFlags);
}
+ ///
+ /// Replace invalid characters with a special sequence
+ ///
+ ///
+ ///
+ 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)
{
// do format flags here - this will get yucky!!!
@@ -3829,50 +3912,90 @@ namespace fmtxml
else return "{UNKNOWN}";
}
#endregion
+ private static Dictionary _TransForms= new Dictionary();
+ 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
- public bool WriteOutXml(FormatData fmtdata)
- {
- // First serialize files based on the above - then use xsl to transform
- // into prefered xml.
- if (!Directory.Exists("fmt_xml")) Directory.CreateDirectory("fmt_xml");
- if (!Directory.Exists("tmp_fmt_xml")) Directory.CreateDirectory("tmp_fmt_xml");
- XmlSerializer serializer = new XmlSerializer(typeof(FormatData));
+ static private XmlSerializer _MyFormatSerializer = new XmlSerializer(typeof(FormatData));
+ public bool WriteOutXml(FormatData fmtdata)
+ {
+ // First serialize files based on the above - then use xsl to transform
+ // into prefered xml.
+ if (!Directory.Exists("fmt_xml")) Directory.CreateDirectory("fmt_xml");
+ if (!Directory.Exists("tmp_fmt_xml")) Directory.CreateDirectory("tmp_fmt_xml");
+ //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 + "f.xml";
- if (File.Exists(destfile)) File.Delete(destfile);
- TextWriter writer = new StreamWriter(destfile);
- try
- {
- serializer.Serialize(writer, fmtdata);
- writer.Close();
- XslCompiledTransform xsl = new XslCompiledTransform();
- xsl.Load(Application.StartupPath + "\\TranslateFmt.XSL");
- string sResults = "fmt_xml\\" + lfmtname + "f.xml";
- xsl.Transform(destfile, sResults); // Perform Transform
+ 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 + "f.xml";
+ if (File.Exists(destfile)) File.Delete(destfile);
+ TextWriter writer = new StreamWriter(destfile);
+ try
+ {
+ _MyFormatSerializer.Serialize(writer, fmtdata);
+ writer.Close();
+ //XslCompiledTransform xsl = new XslCompiledTransform();
+ //xsl.Load(Application.StartupPath + "\\TranslateFmt.XSL");
+ 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 = getTransform(Application.StartupPath + "\\removeempty.XSL");
+ //xsl.Load(Application.StartupPath + "\\removeempty.XSL");
+ string sResults2 = "fmt_xml\\" + lfmtname + "xf.xml";
+ xsl.Transform(sResults, sResults2);
+ File.Delete(sResults);
+ xsl.Transform(sResults2, sResults);
+ File.Delete(sResults2);
+ }
- xsl.Load(Application.StartupPath + "\\removeempty.XSL");
- string sResults2 = "fmt_xml\\" + lfmtname + "xf.xml";
- xsl.Transform(sResults, sResults2);
- File.Delete(sResults);
- xsl.Transform(sResults2, sResults);
- File.Delete(sResults2);
- }
-
- catch (Exception e)
- {
- Console.WriteLine("Error writing out xml or xsl - format = {0}", fmtdata.Name);
- Console.WriteLine(e.Message);
- Console.WriteLine();
- return false;
- }
- 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;
+ }
+ return true;
+ }
#endregion
#region OriginalNoBase
//public void LoadFormatFileOrig(string fname)
@@ -3928,18 +4051,26 @@ namespace fmtxml
string fnm = MyPath + @"\" + fname;
brFmt = new BinaryReader(File.Open(fnm, System.IO.FileMode.Open, System.IO.FileAccess.ReadWrite, FileShare.ReadWrite));
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);
else fmtdata.Symbols = null;
if (success)
{
- DoStepInheritance(ref fmtdata.StepData);
- success = WriteOutXml(fmtdata);
+ //success = WriteOutXmlTmp(fmtdata, "beforeStep");
+ DoStepInheritance(ref fmtdata.StepData);
+ //success = WriteOutXml(fmtdata);
}
brFmt.Close();
// 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 = WriteOutXml(fmtdata);
@@ -3955,6 +4086,7 @@ namespace fmtxml
brFmt = new BinaryReader(File.Open(fnm, System.IO.FileMode.Open, System.IO.FileAccess.ReadWrite, FileShare.ReadWrite));
FormatData subdata = new FormatData();
success = ReadInFmtFile(ref subdata, ref SubXtraFlags, fi.Name);
+ //OutputStepFonts(fi.Name, subdata);
if (success)
{
DoStepInheritance(ref subdata.StepData);
@@ -3968,6 +4100,71 @@ namespace fmtxml
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)
{
fmtdata.Symbols = new Symbol[35];
@@ -4248,12 +4445,7 @@ namespace fmtxml
{
// just compare all fields - clear the subformat if equal.
#region COMPAREACTIVE
- if (mainFmt.FontData != null && subFmt.FontData != null)
- {
- 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;
- }
+ subFmt.FontData = FixInheritedFont(subFmt.FontData, mainFmt.FontData); // Phase 10
if (mainFmt.PurchaseOptions == subFmt.PurchaseOptions) subFmt.PurchaseOptions = null;
if (mainFmt.PSI == subFmt.PSI) subFmt.PSI = null;
if (mainFmt.TPL == subFmt.TPL) subFmt.TPL = null;
@@ -4273,16 +4465,17 @@ namespace fmtxml
// compare step data, step index by step index. This assumes that step data between
// 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 sstp = subFmt.StepData[i];
- if (mstp.Font != null && sstp.Font != null)
- {
- if (mstp.Font.FontFamily == sstp.Font.FontFamily) subFmt.StepData[i].Font.FontFamily = null;
- if (mstp.Font.FontSize == sstp.Font.FontSize) subFmt.StepData[i].Font.FontSize = null;
- if (mstp.Font.FontStyle == sstp.Font.FontStyle) subFmt.StepData[i].Font.FontStyle = null;
- }
+ //if (i > 0) // Don't inherit base font
+ //{
+ // _LookForChange = true;
+ // subFmt.StepData[i].Font = FixInheritedFont(sstp.Font, mstp.Font);// Phase 1
+ // _LookForChange = false;
+ //}
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.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;
// KBR TODO if (mstp.AlternateName == sstp.AlternateName) subFmt.StepData[i].AlternateName = null;
if (mstp.UnderlineTheseChar == sstp.UnderlineTheseChar) subFmt.StepData[i].UnderlineTheseChar = null;
- if (mstp.TabData.Font != null && sstp.TabData.Font != null)
- {
- 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;
- }
+ //subFmt.StepData[i].TabData.Font = FixInheritedFont(sstp.TabData.Font, mstp.TabData.Font);// Phase 2
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.RNOIdentEdit == sstp.TabData.RNOIdentEdit) subFmt.StepData[i].TabData.RNOIdentEdit = null;
@@ -4389,41 +4577,21 @@ namespace fmtxml
if (mbox.TxtWidth == sbox.TxtWidth) sbox.TxtWidth = 0;
if (mbox.Height == sbox.Height) sbox.Height = 0;
if (mbox.TabPos == sbox.TabPos) sbox.TabPos = 0;
- if (mbox.Font != null && sbox.Font != null)
- {
- 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;
- }
+ subFmt.BoxData[i].Font = FixInheritedFont(sbox.Font, mbox.Font); // Phase 3
}
StepSectionLayout msctlay = mainFmt.SectData.StepSectionData.StpSectLayData;
StepSectionLayout ssctlay = subFmt.SectData.StepSectionData.StpSectLayData;
if (msctlay.TableCenterPos == ssctlay.TableCenterPos) subFmt.SectData.StepSectionData.StpSectLayData.TableCenterPos = null;
- if (msctlay.TopOfPage.Font != null && ssctlay.TopOfPage.Font != null)
- {
- 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;
- }
+ subFmt.SectData.StepSectionData.StpSectLayData.TopOfPage.Font = FixInheritedFont(ssctlay.TopOfPage.Font, msctlay.TopOfPage.Font);// Phase 4
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;
StepSectionPrint msctpr = mainFmt.SectData.StepSectionData.StpSectPrtData;
StepSectionPrint ssctpr = subFmt.SectData.StepSectionData.StpSectPrtData;
- if (msctpr.ModifiedTextStyle != null && ssctpr.ModifiedTextStyle != null)
- {
- 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;
+ 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 (msctlay.Separator.SeparatorLocation == ssctlay.Separator.SeparatorLocation) subFmt.SectData.StepSectionData.StpSectLayData.Separator.SeparatorLocation = 0;
if (msctlay.LastLineToStartStep == ssctlay.LastLineToStartStep) subFmt.SectData.StepSectionData.StpSectLayData.LastLineToStartStep = 0;
//for (int i=0; i<10; i++)
@@ -4494,12 +4662,7 @@ namespace fmtxml
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].Font != null && sco.CheckOffHeaderList[i].Font != null)
- {
- 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;
- }
+ sco.CheckOffHeaderList[i].Font = FixInheritedFont(sco.CheckOffHeaderList[i].Font, mco.CheckOffHeaderList[i].Font); // Phase 6
}
if (mco.UseCheckOffsIn == sco.UseCheckOffsIn) subFmt.ProcData.CheckOffData.UseCheckOffsIn = 0;
if (mco.CheckOffAdjustment == sco.CheckOffAdjustment) subFmt.ProcData.CheckOffData.CheckOffAdjustment = 0;
@@ -4513,22 +4676,17 @@ namespace fmtxml
//for (int i = 0; i < MAXSEQ; i++)
// if (msctstp.SeqStart[i] == ssctstp.SeqStart[i]) subFmt.SectData.StepSectionData.SeqStart[i] = 0;
- 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].TabFormat == ssctstp.SequentialTabFormat[i].TabFormat) subFmt.SectData.StepSectionData.SequentialTabFormat[i].TabFormat = null;
- }
+ //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].TabFormat == ssctstp.SequentialTabFormat[i].TabFormat) subFmt.SectData.StepSectionData.SequentialTabFormat[i].TabFormat = null;
+ //}
//if (msctstp.HighSeqStart == ssctstp.HighSeqStart) subFmt.SectData.StepSectionData.HighSeqStart = 0;
if (msctstp.IndentToken == ssctstp.IndentToken) subFmt.SectData.StepSectionData.IndentToken = 0;
if (msctpr.ImmStepHdrCol == ssctpr.ImmStepHdrCol) subFmt.SectData.StepSectionData.StpSectPrtData.ImmStepHdrCol = 0;
- if (msctpr.ImmStepHdrStyle != null && ssctpr.ImmStepHdrStyle != null)
- {
- 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;
- }
+ subFmt.SectData.StepSectionData.StpSectPrtData.ImmStepHdrStyle = FixInheritedFont(ssctpr.ImmStepHdrStyle, msctpr.ImmStepHdrStyle);
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.WolfcreekCKLBackgndFormat != null && msctstp.WolfcreekCKLBackgndFormat == ssctstp.WolfcreekCKLBackgndFormat) subFmt.SectData.StepSectionData.WolfcreekCKLBackgndFormat = "null";
@@ -4556,20 +4714,10 @@ namespace fmtxml
SectionNum ssctn = subFmt.SectData.SectionNumber;
SectionHead mscth = mainFmt.SectData.SectionHeader;
SectionHead sscth = subFmt.SectData.SectionHeader;
- if (msctn.Font != null && ssctn.Font != null)
- {
- 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;
+ subFmt.SectData.SectionNumber.Font = FixInheritedFont(ssctn.Font, msctn.Font); // Phase 7
+ if (msctn.Pos == ssctn.Pos) subFmt.SectData.SectionNumber.Pos = 0;
if (msctn.Just == ssctn.Just) subFmt.SectData.SectionNumber.Just = null;
- if (mscth.Font != null && sscth.Font != null)
- {
- 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;
- }
+ subFmt.SectData.SectionHeader.Font = FixInheritedFont(sscth.Font, mscth.Font); // Phase 8
if (mscth.Pos == sscth.Pos) subFmt.SectData.SectionHeader.Pos =0;
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.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.Font != null && saccsec.TableOfContentsData.Font != null)
- {
- 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;
- }
-
+ 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 (msctstp.LeftJustSeqTab == ssctstp.LeftJustSeqTab) subFmt.SectData.StepSectionData.LeftJustSeqTab = null;
for (int i = 0; i < 10; i++)
@@ -4800,6 +4937,24 @@ namespace fmtxml
#endregion
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
#region DoStepInherit
delegate string StepPartStr(Step stp);
@@ -4827,7 +4982,17 @@ namespace fmtxml
if (stp.Font == null) return null;
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 StepPartLayoutSTExtraSpace(Step stp) { return stp.StepLayoutData.STExtraSpace; }
private string StepPartLayoutSTBoxindex(Step stp) { return stp.StepLayoutData.STBoxindex; }
@@ -4875,6 +5040,16 @@ namespace fmtxml
if (stp.TabData.Font == null) return null;
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 StepPartEditTypeRnoInMenu(Step stp){return stp.StepEditData.TypeMenu.RnoInMenu;}
private string StepPartEditTypeMenuItem(Step stp){return stp.StepEditData.TypeMenu.MenuItem;}
@@ -4900,13 +5075,20 @@ namespace fmtxml
if (CheckInheritedStr(new StepPartStr(StepPartUnderlineTheseChar), step, dicParents)) step.UnderlineTheseChar = null;
if (CheckInheritedStr(new StepPartStr(StepPartVertPos), step, dicParents)) step.VertPos = null;
// substructures - Font
- if (step.Font != null && CheckInheritedStr(new StepPartStr(StepPartFontFamily), step, dicParents))
- step.Font.FontFamily = null;
+ 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;
+ }
if (step.Font != null && CheckInheritedStr(new StepPartStr(StepPartFontStyle), step, dicParents))
step.Font.FontStyle = null;
if (step.Font != null && CheckInheritedStr(new StepPartStr(StepPartFontSize), step, dicParents))
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;
// substructure - StepLayoutData
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(StepPartEditTypeAlternateNameList), step, dicParents)) step.StepEditData.TypeMenu.AlternateNameList = null;
// substructure - StepPrintData
- if (CheckInheritedStr(new StepPartStr(StepPartPrintForeColor), step, dicParents)) step.StepEditData.ForeColor = null;
- if (CheckInheritedStr(new StepPartStr(StepPartPrintBackColor), step, dicParents)) step.StepEditData.BackColor = null;
+ if (CheckInheritedStr(new StepPartStr(StepPartPrintForeColor), step, dicParents)) step.StepPrintData.ForeColor = null;
+ if (CheckInheritedStr(new StepPartStr(StepPartPrintBackColor), step, dicParents)) step.StepPrintData.BackColor = null;
if (CheckInheritedStr(new StepPartStr(StepPartPrintPosAdjust), step, dicParents)) step.StepPrintData.PosAdjust = null;
// substructure - TabData
if (CheckInheritedStr(new StepPartStr(StepPartTabIdentEdit), step, dicParents)) step.TabData.IdentEdit = null;
@@ -4956,7 +5138,11 @@ namespace fmtxml
step.TabData.Font.FontStyle = null;
if (step.TabData.Font != null && CheckInheritedStr(new StepPartStr(StepPartTabFontSize), step, dicParents))
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;
}
@@ -4985,5 +5171,70 @@ namespace fmtxml
return dicParent;
}
#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() + ".");
+ }
+ }
+
}
\ No newline at end of file
diff --git a/PROMS/fmtxml/FmtToXml.cs b/PROMS/fmtxml/FmtToXml.cs
index 85672ced..4bb26e18 100644
--- a/PROMS/fmtxml/FmtToXml.cs
+++ b/PROMS/fmtxml/FmtToXml.cs
@@ -30,7 +30,8 @@ public struct PSItem
{
public int Row;
public int Col;
- public E_PageStructMod Justify;
+ //public E_PageStructMod Justify;
+ public string Justify;
public VE_Font Style;
public string Token;
}
@@ -280,7 +281,17 @@ internal class VE_DocStyleConverter:ExpandableObjectConverter
public class VE_Font
{
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)
{
@@ -313,8 +324,14 @@ public class VE_Font
_FontFamilySet = true;
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 bool _FontSizeSet = false;
public string FontSize
@@ -325,7 +342,7 @@ public class VE_Font
_FontSizeSet = true;
return _FontSize;
}
- set { _FontSize = value;}
+ set { CheckPartial(_FontSize, value); _FontSize = value; }
//set { i = ((uint)value) | (i & 0xFFFFFFC0); }
}
//public E_FontName FontName
@@ -344,7 +361,7 @@ public class VE_Font
return _FontStyle;
}
// return (E_FontStyle)(i & 0xFFFFFFC0);}
- set { _FontStyle = value;}
+ set { CheckPartial(_FontStyle, value); _FontStyle = value; }
//set{i = ((uint)value) | (i & 0x3F);}
}
private string _FontCheckOff = null;
@@ -366,7 +383,7 @@ public class VE_Font
_FontCheckOffSet = true;
return _FontCheckOff;
}
- set { _FontCheckOff = value; }
+ set { CheckPartial(_FontCheckOff, value); _FontCheckOff = value; }
}
private string _FontJustify = null;
private bool _FontJustifySet = false;
@@ -387,7 +404,7 @@ public class VE_Font
_FontJustifySet = true;
return _FontJustify;
}
- set { _FontJustify = value; }
+ set { CheckPartial(_FontJustify, value); _FontJustify = value; }
}
public bool IsBoxed
{
@@ -469,7 +486,7 @@ namespace fmtxml
}
catch (Exception ex)
{
- MessageBox.Show("Format name = " + nm, ex.Message);
+ MessageBox.Show("Format name = " + nm, ex.Message);
}
}
private int ColToPoints(int i)
@@ -548,22 +565,22 @@ namespace fmtxml
ArrayList stringoffsets = new ArrayList();
short strings = 0;
PageStyles pgstyles = new PageStyles();
- string str = null;
// read in title.
string fnm = MyPath + @"\" + fname;
Console.WriteLine(fname);
brFmt = new BinaryReader(File.Open(fnm,System.IO.FileMode.Open,System.IO.FileAccess.ReadWrite,FileShare.ReadWrite));
- short len = brFmt.ReadInt16();
- pgstyles.Name = GetAsciiString(brFmt,len);
+ pgstyles.Name = GetAsciiString(brFmt);
// read in struct name/def name/page file name
- for (int i=0;i<3;i++)
- {
- len = brFmt.ReadInt16();
- str = GetAsciiString(brFmt,len);
- }
-
+ //for (int i=0;i<3;i++)
+ //{
+ // len = brFmt.ReadInt16();
+ // 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.
short numpgstyles = brFmt.ReadInt16();
@@ -586,8 +603,7 @@ namespace fmtxml
{
PageStyle pg = new PageStyle();
pg.Index=i;
- len = brFmt.ReadInt16();
- pg.Name = GetAsciiString(brFmt,len);
+ pg.Name = GetAsciiString(brFmt);
PSItem [] psitms = new PSItem[1];
PSItem [] Fpsitms = null;
@@ -604,7 +620,8 @@ namespace fmtxml
// the column is 12 char/inch
pi.Row = RowToPoints(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.Token = DoReplaceTokens(GetAsciiStringUntilNull(brFmt));
// replace the '<' with '{' & '>' with '}'
@@ -649,8 +666,7 @@ namespace fmtxml
{
serializer.Serialize(writer, pgstyles);
writer.Close();
- XslCompiledTransform xsl = new XslCompiledTransform();
- xsl.Load(Application.StartupPath + "\\TranslatePag.XSL");
+ XslCompiledTransform xsl = FmtFileToXml.getTransform(Application.StartupPath + "\\TranslatePag.XSL");
string sResults = "fmt_xml\\" + lfmtname + "p.xml";
xsl.Transform(destfile, sResults); // Perform Transform
}
@@ -660,88 +676,122 @@ namespace fmtxml
writer.Close();
}
}
+
+ private string GetAsciiString(BinaryReader brFmt)
+ {
+ short len = brFmt.ReadInt16();
+ return GetAsciiString(brFmt, len);
+ }
public void LoadDocFile(string fname)
{
ArrayList stringoffsets = new ArrayList();
short strings = 0;
DocStyles dcstyles = new DocStyles();
- string str = null;
// read in title.
string fnm = MyPath + @"\" + fname;
Console.WriteLine(fname);
brFmt = new BinaryReader(File.Open(fnm,System.IO.FileMode.Open,System.IO.FileAccess.ReadWrite,FileShare.ReadWrite));
- short len = brFmt.ReadInt16();
- dcstyles.Name = GetAsciiString(brFmt,len);
+ dcstyles.Name = GetAsciiString(brFmt);
// 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();
- str = GetAsciiString(brFmt,len);
- }
-
- // Get the number of page styles, and create the array for them.
- short numdcstyles = brFmt.ReadInt16();
- DocStyle [] dcs = new DocStyle[numdcstyles];
-
- short offptr = brFmt.ReadInt16(); // not sure what these bytes contain?
- short vnum = brFmt.ReadInt16();
- if (vnum!=0)
- {
- strings = vnum;
- for(int i=0;i