Only convert Page and Document formats is the related Format file exists.
Skip commented lines in INI file. Remove inline comments before processing INI file. Use more explicit comparisons to determine type of command. Replace spaces with {sp}.
This commit is contained in:
parent
a9d012651a
commit
5a7af006a8
@ -488,7 +488,8 @@ namespace fmtxml
|
||||
try
|
||||
{
|
||||
// get the default base & plant files to use when figuring out inheritance.
|
||||
GetPlantBaseDefaultFonts();
|
||||
if (GetPlantBaseDefaultFonts())
|
||||
{
|
||||
|
||||
// will have entire name, such as aep.x01 - use number to differentiate it.
|
||||
int indx = nm.IndexOf('.');
|
||||
@ -503,6 +504,7 @@ namespace fmtxml
|
||||
LoadDocFile(nm + ".doc");
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show("Format name = " + nm, ex.Message);
|
||||
@ -1144,7 +1146,9 @@ namespace fmtxml
|
||||
int indx = fmtName.IndexOf('.');
|
||||
if (indx > 0)
|
||||
lfmtName = fmtName.Substring(0, fmtName.Length - 4) + "_" + fmtName.Substring(fmtName.Length - 2, 2);
|
||||
xdoc.Load("fmt_xml\\" + lfmtName + "f.xml");
|
||||
string fName = "fmt_xml\\" + lfmtName + "f.xml";
|
||||
if (!File.Exists(fName)) return false;
|
||||
xdoc.Load(fName);
|
||||
xfont = xdoc.SelectSingleNode("FormatData/Font");
|
||||
if (xfont!=null)DefPlantFont = new VE_Font(xfont);
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.IO;
|
||||
using System.Xml;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace fmtxml
|
||||
{
|
||||
@ -13,6 +14,16 @@ namespace fmtxml
|
||||
private int NumTexts = 0;
|
||||
private int NumFields = 0;
|
||||
private int CountForLists = 0;
|
||||
private Regex removeComment = new Regex("/[*].*?[*]/");
|
||||
private Regex removeComment1 = new Regex("/[*].*?$");
|
||||
private Regex removeComment2 = new Regex("[*]/");
|
||||
private string RemoveComments(string inStr)
|
||||
{
|
||||
string str = removeComment.Replace(inStr, "");
|
||||
str = removeComment1.Replace(str, "");
|
||||
str = removeComment2.Replace(str, "");
|
||||
return str;
|
||||
}
|
||||
public void PsiIniToXml(ref FormatData fmtdata, string path)
|
||||
{
|
||||
string sLine;
|
||||
@ -31,17 +42,20 @@ namespace fmtxml
|
||||
{
|
||||
// read in the count of objects - these may not be in order, fix this:
|
||||
sLine = myReader.ReadLine();
|
||||
while(sLine.StartsWith(";")) sLine = myReader.ReadLine(); // Skip Comments
|
||||
int indx = sLine.IndexOf("=");
|
||||
string tmp = sLine.Substring(indx + 1, sLine.Length - indx - 1);
|
||||
NumBoxes = Convert.ToInt32(tmp);
|
||||
NumBoxes = Convert.ToInt32(RemoveComments(tmp));
|
||||
sLine = myReader.ReadLine();
|
||||
while (sLine.StartsWith(";")) sLine = myReader.ReadLine(); // Skip Comments
|
||||
indx = sLine.IndexOf("=");
|
||||
tmp = sLine.Substring(indx + 1, sLine.Length -indx - 1);
|
||||
NumTexts = Convert.ToInt32(tmp);
|
||||
NumTexts = Convert.ToInt32(RemoveComments(tmp));
|
||||
sLine = myReader.ReadLine();
|
||||
while (sLine.StartsWith(";")) sLine = myReader.ReadLine(); // Skip Comments
|
||||
indx = sLine.IndexOf("=");
|
||||
tmp = sLine.Substring(indx + 1, sLine.Length -indx - 1);
|
||||
NumFields = Convert.ToInt32(tmp);
|
||||
NumFields = Convert.ToInt32(RemoveComments(tmp));
|
||||
fmtdata.ProcData.Psi.Boxes = new PsiBox[NumBoxes];
|
||||
fmtdata.ProcData.Psi.Labels = new PsiLabel[NumTexts];
|
||||
fmtdata.ProcData.Psi.Fields = new PsiField[NumFields];
|
||||
@ -59,7 +73,7 @@ namespace fmtxml
|
||||
default:
|
||||
if (sLine.IndexOf("=") >= 0)
|
||||
{
|
||||
AddParam(ref fmtdata, sLine);
|
||||
AddParam(ref fmtdata, RemoveComments(sLine));
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -72,11 +86,17 @@ namespace fmtxml
|
||||
}
|
||||
myReader.Close();
|
||||
}
|
||||
private Regex findBOX = new Regex("^BOX[0-9]+$");
|
||||
private Regex findSIZE = new Regex("^SIZE$");
|
||||
private Regex findFONT = new Regex("^FONT$");
|
||||
private Regex findCAPTION = new Regex("^CAPTION$");
|
||||
private Regex findBUTTONSONBOTTOM = new Regex("^BUTTONSONBOTTOM$");
|
||||
private Regex findTEXT = new Regex("^TEXT[0-9]+$");
|
||||
private void AddParam(ref FormatData fmtdata, string sParam)
|
||||
{
|
||||
int i = sParam.IndexOf("=");
|
||||
string attrname = sParam.Substring(0, i);
|
||||
if (attrname.Contains("SIZE"))
|
||||
if (findSIZE.IsMatch(attrname))
|
||||
{
|
||||
int end = (sParam.IndexOf(";") > -1) ? sParam.IndexOf(";") : sParam.Length;
|
||||
string sb = sParam.Substring(i + 1, end - i - 1);
|
||||
@ -85,7 +105,7 @@ namespace fmtxml
|
||||
fmtdata.ProcData.Psi.y = Convert.ToInt32(split[1].Trim());
|
||||
return;
|
||||
}
|
||||
if (attrname.Contains("FONT"))
|
||||
if (findFONT.IsMatch(attrname))
|
||||
{
|
||||
int end = (sParam.IndexOf(";") > -1) ? sParam.IndexOf(";") : sParam.Length;
|
||||
string sb = sParam.Substring(i + 1, end - i - 1);
|
||||
@ -93,19 +113,19 @@ namespace fmtxml
|
||||
fmtdata.ProcData.Psi.font = split[0].Trim();
|
||||
return;
|
||||
}
|
||||
if (attrname.Contains("CAPTION"))
|
||||
if (findCAPTION.IsMatch(attrname))
|
||||
{
|
||||
int end = (sParam.IndexOf(";") > -1) ? sParam.IndexOf(";") : sParam.Length;
|
||||
fmtdata.ProcData.Psi.Caption = sParam.Substring(i + 1, end-i-1).Replace("\"","");
|
||||
return;
|
||||
}
|
||||
if (attrname.Contains("BUTTONSONBOTTOM"))
|
||||
if (findBUTTONSONBOTTOM.IsMatch(attrname))
|
||||
{
|
||||
int end = (sParam.IndexOf(";") > -1) ? sParam.IndexOf(";") : sParam.Length;
|
||||
fmtdata.ProcData.Psi.ButtonsOnBottom = sParam.Substring(i + 1, end - i - 1);
|
||||
return;
|
||||
}
|
||||
if (attrname.Contains("BOX"))
|
||||
if (findBOX.IsMatch(attrname)) // attrname.StartsWith("BOX"))
|
||||
{
|
||||
//<Box style="BLACKFRAME" x="4" y="4" width="192" height="112"/>
|
||||
int end = (sParam.IndexOf(";") > -1) ? sParam.IndexOf(";") : sParam.Length;
|
||||
@ -119,7 +139,7 @@ namespace fmtxml
|
||||
CountForLists++;
|
||||
return;
|
||||
}
|
||||
if (attrname.Contains("TEXT"))
|
||||
if (findTEXT.IsMatch(attrname))
|
||||
{
|
||||
//<Label text="Responsible Manager's Title:" Justify="LEFT" x="12" y="11" width="100" height="8" />
|
||||
int end = (sParam.IndexOf(";") > -1) ? sParam.IndexOf(";") : sParam.Length;
|
||||
|
@ -296,6 +296,7 @@ namespace fmtxml
|
||||
str = str.Replace("<", "<");
|
||||
str = str.Replace(">", ">");
|
||||
str = str.Replace("\x0B", "");
|
||||
str = str.Replace(" ", "{sp}");
|
||||
return str;
|
||||
}
|
||||
private static string[] FontChoice =
|
||||
|
Loading…
x
Reference in New Issue
Block a user