Added handler to PageList Items for PicaIgnoreFiveSixths flag.

This commit is contained in:
Rich
2011-12-02 16:41:25 +00:00
parent aed6c8740c
commit 0641588ee8

View File

@@ -585,8 +585,19 @@ namespace fmtxml
VE_DocStyle retval=new VE_DocStyle(brFmt.ReadUInt32());
return retval;
}
private bool _PicaIgnoreFiveSixths;
public bool PicaIgnoreFiveSixths
{
get { return _PicaIgnoreFiveSixths; }
set { _PicaIgnoreFiveSixths = value; }
}
public void LoadPageFile(string fname)
{
string lfmtname = fmtName;
int indx = fmtName.IndexOf('.');
if (indx > 0)
lfmtname = fmtName.Substring(0, fmtName.Length - 4) + "_" + fmtName.Substring(fmtName.Length - 2, 2);
GetFormatFlags(lfmtname);
ArrayList stringoffsets = new ArrayList();
short strings = 0;
PageStyles pgstyles = new PageStyles();
@@ -648,11 +659,11 @@ namespace fmtxml
E_PageStructMod etmpjust = (E_PageStructMod)tmpjust;
pi.Justify = ((E_PageStructMod)tmpjust).ToString();
float adj = 0.5F;
if ((etmpjust & E_PageStructMod.PSTrue) == 0) adj = -0.5F;
//if ((etmpjust & E_PageStructMod.PSTrue) == 0 ) adj = -0.5F;
if ((etmpjust & E_PageStructMod.PSTrue) == 0 && !PicaIgnoreFiveSixths ) adj = -0.5F;
if ((etmpjust & E_PageStructMod.PSLeft) == E_PageStructMod.PSLeft) adj = 0;
if ((etmpjust & E_PageStructMod.PSRight) == E_PageStructMod.PSRight) adj *= 2;
uint tmpstyle = brFmt.ReadUInt32();
pi.Style = new VE_Font(tmpstyle);
string tkn = DoReplaceTokens(GetAsciiStringUntilNull(brFmt));
// see if any initial line draw chars are in token (WCN2 and others). If so,
@@ -716,15 +727,11 @@ namespace fmtxml
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(PageStyles));
string lfmtname = fmtName;
// 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.
int indx = fmtName.IndexOf('.');
if (indx>0)
lfmtname = fmtName.Substring(0,fmtName.Length-4) + "_" + fmtName.Substring(fmtName.Length-2,2);
string destfile = "tmp_fmt_xml\\" + lfmtname + "p.xml";
if (File.Exists(destfile)) File.Delete(destfile);
TextWriter writer = new StreamWriter(destfile);
TextWriter writer = new StreamWriter(destfile);
try
{
serializer.Serialize(writer, pgstyles);
@@ -741,7 +748,41 @@ namespace fmtxml
writer.Close();
}
}
private void GetFormatFlags(string lfmtname)
{
string fmtFile = "tmp_fmt_xml\\" + lfmtname + "f.xml";
string fmtParent = null;
if (Regex.IsMatch(lfmtname, "[^_]*_[0-9][0-9]"))
fmtParent = "tmp_fmt_xml\\" + lfmtname.Substring(0, lfmtname.Length - 3) + "f.xml";
XmlDocument fmtDoc = GetXMLDoc(fmtFile);
string picaIgnoreFiveSixths = GetXML(fmtDoc, "PicaIgnoreFiveSixths");
if (picaIgnoreFiveSixths != "True" && fmtParent != null) // Could not find it, look in parent
{
fmtDoc = GetXMLDoc(fmtParent);
picaIgnoreFiveSixths = GetXML(fmtDoc, "PicaIgnoreFiveSixths");
}
PicaIgnoreFiveSixths = (picaIgnoreFiveSixths == "True");
}
private string GetXML(XmlDocument fDoc, string lookFor)
{
if (fDoc == null) return null;
XmlNodeList xl = fDoc.DocumentElement.SelectNodes("//*/@" + lookFor); // Look for Attribute
if (xl.Count == 0) xl = fDoc.DocumentElement.SelectNodes("//" + lookFor); // Look for Node
string found = xl.Count == 1 ? xl[0].InnerText : null;
if (found != null)
Console.WriteLine("Found '" + lookFor + "'");
return found;
}
private XmlDocument GetXMLDoc(string fmtFile)
{
XmlDocument fDoc=null;
if (File.Exists(fmtFile))
{
fDoc = new XmlDocument();
fDoc.Load(fmtFile);
}
return fDoc;
}
private string RemoveInitialLineDraw(string tkn, ref int coladj)
{
// if first two characters are line draw and space, remove them and adjust column.