This commit is contained in:
parent
c83ee4259a
commit
54cc4b1322
@ -125,8 +125,9 @@ namespace DataLoader
|
||||
}
|
||||
public static string ReplaceUnicode(string s2, bool DoCaret)
|
||||
{
|
||||
char[] tmp;
|
||||
tmp = s2.ToCharArray();
|
||||
//char[] tmp;
|
||||
//tmp = s2.ToCharArray();
|
||||
string orig = s2;
|
||||
s2 = s2.Replace("`", @"\'b0"); // convert backquote to degree - left over from DOS days.
|
||||
s2 = s2.Replace("\xa0",@"\u160?"); // hardspace
|
||||
s2 = s2.Replace("\xb0", @"\'b0"); // degree
|
||||
@ -169,166 +170,213 @@ namespace DataLoader
|
||||
//s2 = s2.Replace("^", @"\u916");
|
||||
|
||||
//s2 = ConvertDOSSuperAndSubScripts(s2);
|
||||
|
||||
string sBefore = s2;
|
||||
s2 = ConvertFortranFormatToScienctificNotation(s2);
|
||||
|
||||
if (sBefore != s2)
|
||||
MyGlitches.Add("ConvertFortranFormatToScienctificNotation", sBefore, s2);
|
||||
// Convert dash to a non-breaking dash. This is a unicode character.
|
||||
// This character will be used in veproms rather than a dash.
|
||||
//if the dash is preceeded byte a token remove the space following the token
|
||||
if (s2.Contains(@"\super "))
|
||||
Console.WriteLine("Here");
|
||||
s2 = Regex.Replace(s2, @"(\\[^ \\?]*) \-", @"$1\u8209?");
|
||||
s2 = s2.Replace("-", @"\u8209?");
|
||||
|
||||
//Remove spaces between comment end nad Next token
|
||||
s2 = s2.Replace(@"\v0 \", @"\v0\");
|
||||
//Change Token Order to match RTB output
|
||||
s2 = s2.Replace(@"\v0\b0", @"\b0\v0");
|
||||
s2 = s2.Replace(@"\b0\ulnone", @"\ulnone\b0");
|
||||
s2 = s2.Replace(@"\par ", "\r\n");
|
||||
return s2;
|
||||
}
|
||||
private static string ConvertFortranFormatToScienctificNotation(string str)
|
||||
private static DataLoaderGlitches _MyGlitches;
|
||||
public static DataLoaderGlitches MyGlitches
|
||||
{
|
||||
string outstr = "";
|
||||
int orglen = str.Length;
|
||||
int cnt = 0;
|
||||
int ptr;
|
||||
|
||||
int nbytes;
|
||||
int tstr, tstr2, rptr, start = 0;
|
||||
|
||||
while (cnt < orglen)
|
||||
get
|
||||
{
|
||||
// position up to the the next number, sign, or period
|
||||
ptr = str.IndexOfAny("+-0123456789.".ToCharArray(), cnt);
|
||||
if (ptr == -1)
|
||||
{
|
||||
outstr += str.Substring(cnt);
|
||||
break; // jump out of while loop - nothing else to process
|
||||
}
|
||||
if ((ptr - cnt) > 0)
|
||||
{
|
||||
outstr += str.Substring(cnt, ptr - cnt);
|
||||
cnt = ptr;
|
||||
}
|
||||
|
||||
if (cnt > start && str[cnt - 1] == '\'')
|
||||
{
|
||||
//B2003-053: only remove the single quote character
|
||||
// if str ptr is not at the end of the string or
|
||||
// the next char (after the str ptr) is not a space
|
||||
// or newline... (as per Paul Linn on 7/17/03)
|
||||
int len = orglen - cnt;
|
||||
if (len <= 1 || str[cnt + 1] == ' ' || str[cnt + 1] == '\n')
|
||||
start = cnt;
|
||||
else
|
||||
start = cnt - 1;
|
||||
}
|
||||
else start = cnt;
|
||||
tstr = cnt;
|
||||
|
||||
//Skip preceeding signs
|
||||
if (str[cnt] == '+' || str[cnt] == '-')
|
||||
cnt++;
|
||||
|
||||
cnt = NextNonNumber(str, cnt);
|
||||
if ((cnt < str.Length -1) && str[cnt] == '.')
|
||||
{
|
||||
cnt = NextNonNumber(str, cnt + 1);
|
||||
if (str[start] == '\'')
|
||||
{
|
||||
start++;
|
||||
}
|
||||
else if ((cnt < str.Length -1) && (str[cnt] == 'E') && (cnt > tstr))
|
||||
{
|
||||
nbytes = (cnt - tstr); // don't include the 'E'
|
||||
outstr += str.Substring(tstr, nbytes);
|
||||
cnt++;
|
||||
|
||||
rptr = outstr.Length - 1;
|
||||
while (outstr[rptr] == '0') rptr--;
|
||||
if (outstr[rptr] != '.') rptr++;
|
||||
if (rptr < (outstr.Length - 1))
|
||||
outstr = outstr.Substring(0, rptr + 1); // trim trailing 0's
|
||||
|
||||
int poutstr = 0;
|
||||
if (outstr[poutstr] == '+' || outstr[poutstr] == '-') poutstr++;
|
||||
if (!outstr[poutstr].Equals("1"))
|
||||
{
|
||||
outstr += "x1";
|
||||
}
|
||||
outstr += "0\\super ";
|
||||
|
||||
tstr2 = cnt;
|
||||
if (str[cnt] == '+' || str[cnt] == '-') cnt++;
|
||||
cnt = NextNonNumber(str, cnt);
|
||||
|
||||
if (str[cnt] == '.' && char.IsDigit(str, cnt + 1))
|
||||
cnt = NextNonNumber(str, cnt + 1);
|
||||
|
||||
nbytes = cnt - tstr2; // +1;
|
||||
outstr += str.Substring(tstr2, nbytes);
|
||||
outstr += "\\nosupersub ";
|
||||
|
||||
if (!char.IsLetterOrDigit(str, cnt) && !char.IsWhiteSpace(str, cnt))
|
||||
return (str.Substring(tstr));
|
||||
}
|
||||
else if (cnt > 0)
|
||||
{
|
||||
outstr += str.Substring(start, cnt - start + ((cnt < str.Length) ? 1 : 0));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
outstr += str.Substring(start, cnt - start + ((cnt < str.Length)?1:0));
|
||||
cnt++;
|
||||
}
|
||||
if (_MyGlitches == null)
|
||||
_MyGlitches = new DataLoaderGlitches();
|
||||
return _MyGlitches;
|
||||
}
|
||||
return (outstr);
|
||||
set { _MyGlitches = value; }
|
||||
}
|
||||
|
||||
private static int NextNonNumber(string str, int cnt)
|
||||
public static string ConvertFortranFormatToScienctificNotation(string str)
|
||||
{
|
||||
int rtn = 0;
|
||||
string tstr = str.Substring(cnt);
|
||||
int len = tstr.Length;
|
||||
while (rtn < len && char.IsDigit(tstr, rtn)) rtn++;
|
||||
return rtn + cnt;
|
||||
// Convert E style numbers to RTF with \super and \nosupersub
|
||||
string retval = Regex.Replace(str, "([+-]?)([0-9]+)[.]([0-9]*?)0*E([+-]?[0-9]+)", new MatchEvaluator(FixFortranNumber));
|
||||
return retval;
|
||||
}
|
||||
|
||||
public static string ConvertDOSSuperAndSubScripts(string instr)
|
||||
{
|
||||
string outstr = "";
|
||||
string tstr = instr;
|
||||
int cnt = 0;
|
||||
int ptr = 0;
|
||||
bool issupper = false, issub = false;
|
||||
|
||||
while (tstr != null && (ptr = tstr.IndexOfAny("#~".ToCharArray(), cnt)) >= 0)
|
||||
{
|
||||
if (ptr > cnt)
|
||||
outstr += tstr.Substring(cnt, ptr - cnt);
|
||||
switch (tstr[ptr])
|
||||
{
|
||||
case '#':
|
||||
if (issub || issupper)
|
||||
outstr += "\\nosupersub ";
|
||||
else
|
||||
outstr += "\\super ";
|
||||
issupper = !issupper;
|
||||
issub = false;
|
||||
break;
|
||||
case '~':
|
||||
if (issupper || issub)
|
||||
outstr += "\\nosupersub ";
|
||||
else
|
||||
outstr += "\\sub ";
|
||||
issub = !issub;
|
||||
issupper = false;
|
||||
break;
|
||||
}
|
||||
cnt = ptr + 1;
|
||||
if (cnt >= tstr.Length)
|
||||
tstr = null;
|
||||
else
|
||||
tstr = instr.Substring(cnt);
|
||||
cnt = 0;
|
||||
}
|
||||
if (tstr != null)
|
||||
outstr += tstr;
|
||||
return outstr;
|
||||
string retval = Regex.Replace(instr, "[#](.*?)[#]", "\\super $1\\nosupersub ");// DOS Superscript
|
||||
retval = Regex.Replace(retval, "[~](.*?)[~]", "\\sub $1\\nosupersub ");// DOS Subscript
|
||||
return retval;
|
||||
}
|
||||
private static string FixFortranNumber(Match match)
|
||||
{
|
||||
StringBuilder sb = new StringBuilder(match.Groups[1].Value);
|
||||
if (match.Groups[3].Length == 0) // Nothing to the right of the decimal
|
||||
if (match.Groups[2].Value != "1") // Other than "1", multiply it times 10 raised to a power
|
||||
sb.Append(match.Groups[2].Value + "x10");
|
||||
else // The number is simply 1 so it can be ignored and 10 can be raised to a power
|
||||
sb.Append("10");
|
||||
else // A number with a decimal point
|
||||
sb.Append(match.Groups[2].Value + "." + match.Groups[3].Value + "x10");
|
||||
// Add the exponent as superscript
|
||||
return sb.ToString() + "\\super " + match.Groups[4].Value + "\\nosupersub ";
|
||||
}
|
||||
//private static string ConvertFortranFormatToScienctificNotation(string str)
|
||||
//{
|
||||
// string outstr = "";
|
||||
// int orglen = str.Length;
|
||||
// int cnt = 0;
|
||||
// int ptr;
|
||||
|
||||
// int nbytes;
|
||||
// int tstr, tstr2, rptr, start = 0;
|
||||
|
||||
// while (cnt < orglen)
|
||||
// {
|
||||
// // position up to the the next number, sign, or period
|
||||
// ptr = str.IndexOfAny("+-0123456789.".ToCharArray(), cnt);
|
||||
// if (ptr == -1)
|
||||
// {
|
||||
// outstr += str.Substring(cnt);
|
||||
// break; // jump out of while loop - nothing else to process
|
||||
// }
|
||||
// if ((ptr - cnt) > 0)
|
||||
// {
|
||||
// outstr += str.Substring(cnt, ptr - cnt);
|
||||
// cnt = ptr;
|
||||
// }
|
||||
|
||||
// if (cnt > start && str[cnt - 1] == '\'')
|
||||
// {
|
||||
// //B2003-053: only remove the single quote character
|
||||
// // if str ptr is not at the end of the string or
|
||||
// // the next char (after the str ptr) is not a space
|
||||
// // or newline... (as per Paul Linn on 7/17/03)
|
||||
// int len = orglen - cnt;
|
||||
// if (len <= 1 || str[cnt + 1] == ' ' || str[cnt + 1] == '\n')
|
||||
// start = cnt;
|
||||
// else
|
||||
// start = cnt - 1;
|
||||
// }
|
||||
// else start = cnt;
|
||||
// tstr = cnt;
|
||||
|
||||
// //Skip preceeding signs
|
||||
// if (str[cnt] == '+' || str[cnt] == '-')
|
||||
// cnt++;
|
||||
|
||||
// cnt = NextNonNumber(str, cnt);
|
||||
// if ((cnt < str.Length -1) && str[cnt] == '.')
|
||||
// {
|
||||
// cnt = NextNonNumber(str, cnt + 1);
|
||||
// if (str[start] == '\'')
|
||||
// {
|
||||
// start++;
|
||||
// }
|
||||
// else if ((cnt < str.Length -1) && (str[cnt] == 'E') && (cnt > tstr))
|
||||
// {
|
||||
// nbytes = (cnt - tstr); // don't include the 'E'
|
||||
// outstr += str.Substring(tstr, nbytes);
|
||||
// cnt++;
|
||||
|
||||
// rptr = outstr.Length - 1;
|
||||
// while (outstr[rptr] == '0') rptr--;
|
||||
// if (outstr[rptr] != '.') rptr++;
|
||||
// if (rptr < (outstr.Length - 1))
|
||||
// outstr = outstr.Substring(0, rptr + 1); // trim trailing 0's
|
||||
|
||||
// int poutstr = 0;
|
||||
// if (outstr[poutstr] == '+' || outstr[poutstr] == '-') poutstr++;
|
||||
// if (!outstr[poutstr].Equals("1"))
|
||||
// {
|
||||
// outstr += "x1";
|
||||
// }
|
||||
// outstr += "0\\super ";
|
||||
|
||||
// tstr2 = cnt;
|
||||
// if (str[cnt] == '+' || str[cnt] == '-') cnt++;
|
||||
// cnt = NextNonNumber(str, cnt);
|
||||
|
||||
// if (str[cnt] == '.' && char.IsDigit(str, cnt + 1))
|
||||
// cnt = NextNonNumber(str, cnt + 1);
|
||||
|
||||
// nbytes = cnt - tstr2; // +1;
|
||||
// outstr += str.Substring(tstr2, nbytes);
|
||||
// outstr += "\\nosupersub ";
|
||||
|
||||
// if (!char.IsLetterOrDigit(str, cnt) && !char.IsWhiteSpace(str, cnt))
|
||||
// return (str.Substring(tstr));
|
||||
// }
|
||||
// else if (cnt > 0)
|
||||
// {
|
||||
// outstr += str.Substring(start, cnt - start + ((cnt < str.Length) ? 1 : 0));
|
||||
// }
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// outstr += str.Substring(start, cnt - start + ((cnt < str.Length)?1:0));
|
||||
// cnt++;
|
||||
// }
|
||||
// }
|
||||
// return (outstr);
|
||||
//}
|
||||
|
||||
//private static int NextNonNumber(string str, int cnt)
|
||||
//{
|
||||
// int rtn = 0;
|
||||
// string tstr = str.Substring(cnt);
|
||||
// int len = tstr.Length;
|
||||
// while (rtn < len && char.IsDigit(tstr, rtn)) rtn++;
|
||||
// return rtn + cnt;
|
||||
//}
|
||||
|
||||
//public static string ConvertDOSSuperAndSubScripts(string instr)
|
||||
//{
|
||||
// string outstr = "";
|
||||
// string tstr = instr;
|
||||
// int cnt = 0;
|
||||
// int ptr = 0;
|
||||
// bool issupper = false, issub = false;
|
||||
|
||||
// while (tstr != null && (ptr = tstr.IndexOfAny("#~".ToCharArray(), cnt)) >= 0)
|
||||
// {
|
||||
// if (ptr > cnt)
|
||||
// outstr += tstr.Substring(cnt, ptr - cnt);
|
||||
// switch (tstr[ptr])
|
||||
// {
|
||||
// case '#':
|
||||
// if (issub || issupper)
|
||||
// outstr += "\\nosupersub ";
|
||||
// else
|
||||
// outstr += "\\super ";
|
||||
// issupper = !issupper;
|
||||
// issub = false;
|
||||
// break;
|
||||
// case '~':
|
||||
// if (issupper || issub)
|
||||
// outstr += "\\nosupersub ";
|
||||
// else
|
||||
// outstr += "\\sub ";
|
||||
// issub = !issub;
|
||||
// issupper = false;
|
||||
// break;
|
||||
// }
|
||||
// cnt = ptr + 1;
|
||||
// if (cnt >= tstr.Length)
|
||||
// tstr = null;
|
||||
// else
|
||||
// tstr = instr.Substring(cnt);
|
||||
// cnt = 0;
|
||||
// }
|
||||
// if (tstr != null)
|
||||
// outstr += tstr;
|
||||
// return outstr;
|
||||
//}
|
||||
public static string ConvertText(string s1)
|
||||
{
|
||||
string s2 = s1;
|
||||
@ -338,7 +386,7 @@ namespace DataLoader
|
||||
// bold on/off (D5, D6), subscript on/off (D1 A6), and
|
||||
// italics on/off (B2, DD)
|
||||
s2 = s2.Replace("\xAB", "\\ul ");
|
||||
s2 = s2.Replace("\xBB", "\\ul0 ");
|
||||
s2 = s2.Replace("\xBB", "\\ulnone ");
|
||||
s2 = s2.Replace("\x255E", "\\super ");
|
||||
s2 = s2.Replace("\x255F", "\\nosupersub ");
|
||||
s2 = s2.Replace("\x2552", "\\b ");
|
||||
@ -348,13 +396,13 @@ namespace DataLoader
|
||||
s2 = s2.Replace("\x2593", "\\i ");
|
||||
s2 = s2.Replace("\x258C", "\\i0 ");
|
||||
s2 = s2.Replace("\x2559", "\\ul\\b ");
|
||||
s2 = s2.Replace("\x2558", "\\b0\\ul0 ");
|
||||
s2 = s2.Replace("\x2558", "\\b0\\ulnone ");
|
||||
|
||||
// underline next word is 0x17
|
||||
// superscript next is 0x18
|
||||
// subscript next is 0x19
|
||||
// bold next is 0x13
|
||||
s2 = Regex.Replace(s2, @"\x17([^\x17 ]*?)(?:[\x17]|(?= )|\Z)(.*?)", @"\ul $1\ul0 $2");
|
||||
s2 = Regex.Replace(s2, @"\x17([^\x17 ]*?)(?:[\x17]|(?= )|\Z)(.*?)", @"\ul $1\ulnone $2");
|
||||
s2 = Regex.Replace(s2, @"\x18([^\x18 ]*?)(?:[\x18]|(?= )|\Z)(.*?)", @"\super $1\nosupersub $2");
|
||||
s2 = Regex.Replace(s2, @"\x19([^\x19 ]*?)(?:[\x19]|(?= )|\Z)(.*?)", @"\sub $1\nosupersub $2");
|
||||
s2 = Regex.Replace(s2, @"\x13([^\x13 ]*?)(?:[\x13]|(?= )|\Z)(.*?)", @"\b $1\b0 $2");
|
||||
@ -366,6 +414,8 @@ namespace DataLoader
|
||||
s2 = s2.Replace(@"{", @"\{");
|
||||
s2 = s2.Replace(@"}", @"\}");
|
||||
s2 = s2.Replace("\n", @"\par "); // line break in tables
|
||||
s2 = s2.Replace(@"\nosupersub \super ", @"\super "); //jsj - 18MAR2010 - rbt.Save() seems to do this automatically
|
||||
s2 = s2.Replace(@"\nosupersub \sub ", @"\sub "); //jsj - 18MAR2010 - rbt.Save() seems to do this automatically
|
||||
return s2;
|
||||
}
|
||||
|
||||
|
@ -89,7 +89,8 @@ namespace DataLoader
|
||||
//toItem = Item.New(null, TransDummyCont, DateTime.Now, "Migration");
|
||||
fromCon.Save();
|
||||
migrationErrors.Add("Transition Error: Missing Data - " + _OutTran.GetDescription(thekey) + ". Converted to text");
|
||||
_ContentMigrationErrors.Add(fromCon.ContentID, migrationErrors);
|
||||
if (!_ContentMigrationErrors.ContainsKey(fromCon.ContentID))
|
||||
_ContentMigrationErrors.Add(fromCon.ContentID, migrationErrors);
|
||||
return _OutTran.GetTransitionText(thekey);
|
||||
}
|
||||
toItem2 = toItem;
|
||||
@ -99,6 +100,7 @@ namespace DataLoader
|
||||
}
|
||||
else
|
||||
{
|
||||
if (itype > 6) itype--; // Corrected to match transformat table (16-bit skips type 6 because it's an outside transition)
|
||||
if (dicTrans_ItemDone.ContainsKey(thekey))
|
||||
{
|
||||
toItem = dicTrans_ItemDone[thekey];
|
||||
@ -174,9 +176,9 @@ namespace DataLoader
|
||||
}
|
||||
string results = null;
|
||||
if (toItem.ItemID == toItem2.ItemID)
|
||||
results = string.Format(@"\v <START]\v0 (Resolved Transition Text)\v #Link:Transition:{0} {1} {2}\v0 \v [END>\v0 ", tr.TranType, tr.TransitionID, tr.ToID);
|
||||
results = string.Format(@"\v <START]\v0 (Resolved Transition Text)\v #Link:Transition:{0} {1} {2}[END>\v0 ", tr.TranType, tr.TransitionID, tr.ToID);
|
||||
else
|
||||
results = string.Format(@"\v <START]\v0 (Resolved Transition Text)\v #Link:TransitionRange:{0} {1} {2} {3}\v0 \v [END>\v0 ", tr.TranType, tr.TransitionID, tr.ToID, tr.RangeID);
|
||||
results = string.Format(@"\v <START]\v0 (Resolved Transition Text)\v #Link:TransitionRange:{0} {1} {2} {3}[END>\v0 ", tr.TranType, tr.TransitionID, tr.ToID, tr.RangeID);
|
||||
return results;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user