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

@@ -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<strings;i++)
Console.WriteLine("Other Structure {0}", structName);
if (structName == "BKPGDOC.STR")
{
vnum=brFmt.ReadInt16();
stringoffsets.Add(vnum);
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();
}
}
for (short i=0;i<numdcstyles;i++)
else
{
DocStyle dc = new DocStyle();
dc.Index=i;
len = brFmt.ReadInt16();
dc.Name = GetAsciiString(brFmt,len);
vnum = brFmt.ReadInt16(); // not sure what this is!
dc.pagestyle = brFmt.ReadInt16();
dc.dstyle = LoadVE_Font();
dc.PTopRow = RowToPoints(brFmt.ReadInt16());
dc.FooterLen = RowToPoints(brFmt.ReadInt16());
dc.LeftMargin = ColToPoints(brFmt.ReadInt16());
dc.PageLength = RowToPoints(brFmt.ReadInt16());
dc.PageWidth = ColToPoints(brFmt.ReadInt16());
dc.numberingsequence = brFmt.ReadInt16();
dc.oldtonew = brFmt.ReadInt32();
dc.IsStepSection = ConvertToSectType(dc.oldtonew);
dc.ContTopHLS = brFmt.ReadInt16();
dc.CTMargin = RowToPoints(brFmt.ReadInt16());
dc.CBMargin = RowToPoints(brFmt.ReadInt16());
dc.CBLoc = brFmt.ReadInt16();
dc.ContStyle = LoadVE_Font();
dc.EndFlag = brFmt.ReadInt16();
dc.EndStyle = LoadVE_Font();
// use the string offsets to read in the strings.
int [] offst = new int[strings];
for (int j=0; j<strings; j++)
// Get the number of page styles, and create the array for them.
short numdcstyles = brFmt.ReadInt16();
dcs = new DocStyle[numdcstyles];
short offptr = brFmt.ReadInt16(); // not sure what these bytes contain?
short vnum = brFmt.ReadInt16();
if (vnum != 0)
{
offst[j] = brFmt.ReadInt32();
strings = vnum;
for (int i = 0; i < strings; i++)
{
vnum = brFmt.ReadInt16();
stringoffsets.Add(vnum);
}
}
for (short i = 0; i < numdcstyles; i++)
{
DocStyle dc = new DocStyle();
dc.Index = i;
dc.Name = GetAsciiString(brFmt);
vnum = brFmt.ReadInt16(); // not sure what this is!
dc.pagestyle = brFmt.ReadInt16();
dc.dstyle = LoadVE_Font();
dc.PTopRow = RowToPoints(brFmt.ReadInt16());
dc.FooterLen = RowToPoints(brFmt.ReadInt16());
dc.LeftMargin = ColToPoints(brFmt.ReadInt16());
dc.PageLength = RowToPoints(brFmt.ReadInt16());
dc.PageWidth = ColToPoints(brFmt.ReadInt16());
dc.numberingsequence = brFmt.ReadInt16();
dc.oldtonew = brFmt.ReadInt32();
dc.IsStepSection = ConvertToSectType(dc.oldtonew);
dc.ContTopHLS = brFmt.ReadInt16();
dc.CTMargin = RowToPoints(brFmt.ReadInt16());
dc.CBMargin = RowToPoints(brFmt.ReadInt16());
dc.CBLoc = brFmt.ReadInt16();
dc.ContStyle = LoadVE_Font();
dc.EndFlag = brFmt.ReadInt16();
dc.EndStyle = LoadVE_Font();
// use the string offsets to read in the strings.
int[] offst = new int[strings];
for (int j = 0; j < strings; j++)
{
offst[j] = brFmt.ReadInt32();
}
dc.DocStructStyle = LoadVE_DocStyle();
if (offst[0] != 0) dc.ContTop = DoReplaceTokens(GetAsciiStringUntilNull(brFmt));
else dc.ContTop = null;
if (offst[1] != 0) dc.ContBottom = DoReplaceTokens(GetAsciiStringUntilNull(brFmt));
else dc.ContBottom = null;
if (offst[2] != 0) dc.EndString = DoReplaceTokens(GetAsciiStringUntilNull(brFmt));
else dc.EndString = null;
if (offst[3] != 0) dc.FinalMsg = DoReplaceTokens(GetAsciiStringUntilNull(brFmt));
else dc.FinalMsg = null;
if (dc.ContTop == null && dc.ContBottom == null) dc.ContStyle = null;
if (dc.EndString == null) dc.EndStyle = null;
dcs[i] = dc;
vnum = brFmt.ReadInt16();
}
dc.DocStructStyle = LoadVE_DocStyle();
if (offst[0]!=0)dc.ContTop = DoReplaceTokens(GetAsciiStringUntilNull(brFmt));
else dc.ContTop = null;
if (offst[1]!=0)dc.ContBottom = DoReplaceTokens(GetAsciiStringUntilNull(brFmt));
else dc.ContBottom = null;
if (offst[2]!=0)dc.EndString = DoReplaceTokens(GetAsciiStringUntilNull(brFmt));
else dc.EndString = null;
if (offst[3]!=0)dc.FinalMsg = DoReplaceTokens(GetAsciiStringUntilNull(brFmt));
else dc.FinalMsg = null;
if (dc.ContTop == null && dc.ContBottom == null)dc.ContStyle = null;
if (dc.EndString == null) dc.EndStyle = null;
dcs[i] = dc;
vnum = brFmt.ReadInt16();
}
dcstyles.DcStyles = dcs;
brFmt.Close();
@@ -767,8 +817,7 @@ namespace fmtxml
{
serializer.Serialize(writer, dcstyles);
writer.Close();
XslCompiledTransform xsl = new XslCompiledTransform();
xsl.Load(Application.StartupPath + "\\TranslateDoc.XSL");
XslCompiledTransform xsl = FmtFileToXml.getTransform(Application.StartupPath + "\\TranslateDoc.XSL");
string sResults = "fmt_xml\\" + lfmtname + "d.xml";
xsl.Transform(destfile, sResults); // Perform Transform
}