This commit is contained in:
@@ -109,7 +109,7 @@ namespace fmtxml
|
||||
else if (text.StartsWith("\xAD\xAD"))
|
||||
hasC0 |= AddGroupStart(sb, ref group, text).ToLower() == "c0";
|
||||
else if (text == "END")
|
||||
group = AndGroupEnd(sb, group);
|
||||
group = AddGroupEnd(sb, group);
|
||||
else if (text != "")
|
||||
ProcessCommand(sb, text, file);
|
||||
}
|
||||
@@ -123,15 +123,17 @@ namespace fmtxml
|
||||
}
|
||||
sb.Append(string.Format("</svg>\r\n"));
|
||||
}
|
||||
private static bool AndGroupEnd(StringBuilder sb, bool group)
|
||||
private static bool AddGroupEnd(StringBuilder sb, bool group)
|
||||
{
|
||||
if (group) sb.Append(" </g>\r\n");
|
||||
group = false;
|
||||
_Xoff = 0;
|
||||
_Yoff = 0;
|
||||
return group;
|
||||
}
|
||||
private static string AddGroupStart(StringBuilder sb, ref bool group, string text)
|
||||
{
|
||||
AndGroupEnd(sb, group);
|
||||
AddGroupEnd(sb, group);
|
||||
group = true;
|
||||
string grpID = text.Substring(2).ToUpper();
|
||||
sb.Append(string.Format(" <g id=\"{0}\">\r\n", grpID));
|
||||
@@ -193,9 +195,12 @@ namespace fmtxml
|
||||
Converters[(int)ECommand.RTFADJ] = new Converter(AddRtfAdj);
|
||||
Converters[(int)ECommand.ABSOLUTE] = new Converter(AddAbsolute);
|
||||
}
|
||||
private static Regex regGdiAdj = new Regex(@"GDIADJ ([-0-9]*) ([-0-9]*)$", RegexOptions.Multiline);
|
||||
private static void AddGdiAdj(StringBuilder sb, string text)
|
||||
{
|
||||
// May need to do something with this
|
||||
Match gdiadjMatch = regGdiAdj.Match(text);
|
||||
_Xoff = int.Parse(gdiadjMatch.Groups[1].Value);
|
||||
_Yoff = int.Parse(gdiadjMatch.Groups[2].Value);
|
||||
}
|
||||
private static void AddAbsolute(StringBuilder sb, string text)
|
||||
{
|
||||
@@ -216,8 +221,8 @@ namespace fmtxml
|
||||
string bmHeight = bmp.Height.ToString() + "px";
|
||||
//Console.WriteLine("'{0}'", bmFileName);
|
||||
sb.Append(string.Format(" <image x=\"{0}\" y=\"{1}\" width=\"{2}\" height=\"{3}\" bname=\"{4}\"/>\r\n",
|
||||
TwipsToPoints(bitmapMatch.Groups[1].Value),
|
||||
TwipsToPoints(bitmapMatch.Groups[2].Value),
|
||||
TwipsToPointsX(bitmapMatch.Groups[1].Value),
|
||||
TwipsToPointsY(bitmapMatch.Groups[2].Value),
|
||||
bmWidth,
|
||||
bmHeight,
|
||||
bmFileName));
|
||||
@@ -228,8 +233,8 @@ namespace fmtxml
|
||||
Match textMatch = regText.Match(text);
|
||||
|
||||
sb.Append(string.Format(" <text x=\"{0}\" y=\"{1}\" font-family=\"{3}\" font-size=\"{2}\" {4}>{5}</text>\r\n",
|
||||
TwipsToPoints(textMatch.Groups[1].Value),
|
||||
TwipsToPoints(textMatch.Groups[2].Value),
|
||||
TwipsToPointsX(textMatch.Groups[1].Value),
|
||||
TwipsToPointsY(textMatch.Groups[2].Value),
|
||||
FontSizeToPoints(textMatch.Groups[3].Value),
|
||||
FontToFamily(textMatch.Groups[4].Value),
|
||||
FontStyle(textMatch.Groups[5].Value),
|
||||
@@ -240,8 +245,8 @@ namespace fmtxml
|
||||
{
|
||||
Match ellipseMatch = regEllipse.Match(text);
|
||||
sb.Append(string.Format(" <ellipse cx=\"{0}\" cy=\"{1}\" rx=\"{2}\" ry=\"{3}\" fill=\"none\" stroke=\"black\" stroke-width=\"{4}\" />\r\n",
|
||||
TwipsToPoints(ellipseMatch.Groups[1].Value),
|
||||
TwipsToPoints(ellipseMatch.Groups[2].Value),
|
||||
TwipsToPointsX(ellipseMatch.Groups[1].Value),
|
||||
TwipsToPointsY(ellipseMatch.Groups[2].Value),
|
||||
TwipsToPoints(ellipseMatch.Groups[3].Value),
|
||||
TwipsToPoints(ellipseMatch.Groups[4].Value),
|
||||
TwipsToPoints(ellipseMatch.Groups[5].Value)));
|
||||
@@ -251,21 +256,23 @@ namespace fmtxml
|
||||
{
|
||||
Match boxMatch = regBox.Match(text);
|
||||
sb.Append(string.Format(" <rect x=\"{0}\" y=\"{1}\" width=\"{2}\" height=\"{3}\" fill=\"none\" stroke=\"black\" stroke-width=\"{4}\" />\r\n",
|
||||
TwipsToPoints(boxMatch.Groups[1].Value),
|
||||
TwipsToPoints(boxMatch.Groups[2].Value),
|
||||
TwipsToPointsX(boxMatch.Groups[1].Value),
|
||||
TwipsToPointsY(boxMatch.Groups[2].Value),
|
||||
TwipsToPoints(boxMatch.Groups[3].Value),
|
||||
TwipsToPoints(boxMatch.Groups[4].Value),
|
||||
TwipsToPoints(boxMatch.Groups[5].Value)));
|
||||
}
|
||||
private static int _Xoff = 0;
|
||||
private static int _Yoff = 0;
|
||||
private static Regex regLine = new Regex(@"LINE ([-0-9]*) ([-0-9]*) ([-0-9]*) ([-0-9]*) ([-0-9]*)", RegexOptions.Multiline);
|
||||
private static void AddLine(StringBuilder sb, string text)
|
||||
{
|
||||
Match lineMatch = regLine.Match(text);
|
||||
sb.Append(string.Format(" <line x1=\"{0}\" y1=\"{1}\" x2=\"{2}\" y2=\"{3}\" stroke=\"black\" stroke-width=\"{4}\" />\r\n",
|
||||
TwipsToPoints(lineMatch.Groups[1].Value),
|
||||
TwipsToPoints(lineMatch.Groups[2].Value),
|
||||
TwipsToPoints(lineMatch.Groups[3].Value) + TwipsToPoints(lineMatch.Groups[1].Value),
|
||||
TwipsToPoints(lineMatch.Groups[4].Value) + TwipsToPoints(lineMatch.Groups[2].Value),
|
||||
TwipsToPointsX(lineMatch.Groups[1].Value),
|
||||
TwipsToPointsY(lineMatch.Groups[2].Value),
|
||||
TwipsToPoints(lineMatch.Groups[3].Value) + TwipsToPointsX(lineMatch.Groups[1].Value),
|
||||
TwipsToPoints(lineMatch.Groups[4].Value) + TwipsToPointsY(lineMatch.Groups[2].Value),
|
||||
TwipsToPoints(lineMatch.Groups[5].Value)));
|
||||
}
|
||||
private static string FontStyle(string style)
|
||||
@@ -315,6 +322,14 @@ namespace fmtxml
|
||||
{
|
||||
return float.Parse(twips) / 20;
|
||||
}
|
||||
private static float TwipsToPointsX(string twips)
|
||||
{
|
||||
return (_Xoff + float.Parse(twips)) / 20;
|
||||
}
|
||||
private static float TwipsToPointsY(string twips)
|
||||
{
|
||||
return (_Yoff + float.Parse(twips)) / 20;
|
||||
}
|
||||
private static float FontSizeToPoints(string fontSize)
|
||||
{
|
||||
return float.Parse(fontSize) / 2;
|
||||
|
Reference in New Issue
Block a user