Fixed how ConvertROToText handles curly braces.

Improved how FixContentText handles curly braces
Improved how BuildTransitionToChecks handles curly braces
This commit is contained in:
Rich 2014-05-28 02:13:21 +00:00
parent 6d0a14c364
commit 22e1a52278
2 changed files with 64 additions and 24 deletions

View File

@ -139,7 +139,8 @@ namespace VEPROMS.CSLA.Library
string newvalue = value;
string findLink = @"<START\].*?\[END>";
MatchCollection ms = Regex.Matches(Text, findLink);
string lookFor = string.Format(@"<START\](\\[^v \\]+)*\\v0(\\[^v \\]+)* (.*?)(\\[^v '?\\]+)*\\v(\\[^v \\]+)* #Link:ReferencedObject:{0} .*?\[END>", rousg.ROUsageID);
//string lookFor = string.Format(@"<START\](\\[^v \\]+)*\\v0(\\[^v \\]+)* (.*?)(\\[^v '?\\]+)*\\v(\\[^v \\]+)* #Link:ReferencedObject:{0} .*?\[END>", rousg.ROUsageID);
string lookFor = string.Format(@"^<START\](\\[^v \\]+)*\\v0(\\[^v '?{{}}~\\]+)*( |\\u[0-9]{{1,4}}?|\\'[0-9a-fA-F]{{2}}|\\[{{}}~])(.*?)(\\[^v'?{{}}~ \\]+)*\\v(\\[^v \\]+)* #Link:ReferencedObject:{0} .*?\[END>$", rousg.ROUsageID);
int lastIndex = 0;
string newText = Text;
foreach (Match mm in ms)
@ -150,9 +151,17 @@ namespace VEPROMS.CSLA.Library
{
string prefix = GetMyPrefix(mm.Index, lastIndex);
string suffix = GetMySuffix(mm.Index + mm.Length);
System.Text.RegularExpressions.Group g = m.Groups[3];
int myIndex = m.Groups[4].Index + mm.Index;
int myLength = m.Groups[4].Length;
if (m.Groups[3].Value != " ")
{
myIndex = m.Groups[3].Index + mm.Index;
myLength += m.Groups[3].Length;
}
string gg = newText.Substring(myIndex, myLength);
gg = gg.Replace("{", @"\{").Replace("}", @"\}");
string part1 = newText.Substring(0, mm.Index);
string part2 = g.Value;
string part2 = gg;
string part3 = newText.Substring(mm.Index + mm.Length);
//modify part1 based on prefix
if (prefix == @"\v ")
@ -164,19 +173,27 @@ namespace VEPROMS.CSLA.Library
part3 = part3.Substring(4);
else
part3 = suffix.Replace(@"\v0","") + part3.Substring(suffix.Length);
System.Text.RegularExpressions.Group g2 = m.Groups[2];
if (g2.Value.StartsWith(@"\u8209?"))
{
string gg = g2.Value + " " + g.Value;
retval = gg;
part2 = retval;
}
else
//else if (g.ToString() != newvalue)
{
retval = g.Value;
part2 = retval;
}
if (gg.Contains(@"\u8209?"))
{
Match mmm = Regex.Match(gg, @"(\\f[0-9]+)(\\u[0-9]{1,4}\?)(\\f[0-9]+ ?)");
if (mmm == null)
newvalue = newvalue.Replace(@"\u8209?", "-");
else
newvalue = newvalue.Replace(@"\u8209?", m.Groups[1].Value + @"\u8209?" + m.Groups[3].Value);
}
//System.Text.RegularExpressions.Group g2 = m.Groups[2];
//if (g2.Value.StartsWith(@"\u8209?"))
//{
// string gg = g2.Value + " " + g.Value;
// retval = gg;
// part2 = retval;
//}
//else
////else if (g.ToString() != newvalue)
//{
// retval = g.Value;
// part2 = retval;
//}
Text = part1 + part2 + part3;
break; // Text has been processed
}
@ -204,8 +221,9 @@ namespace VEPROMS.CSLA.Library
{
// if it's an ro within a table, need to process into an flex grid to save the grid data:
string findLinkXml = @"&lt;START\].*?\[END&gt;";
string lookForXml = string.Format(@"&lt;START\](\\[^v \\]+)*\\v0(\\[^v \\]+)* (.*?)(\\[^v '?\\]+)*\\v(\\[^v \\]+)* #Link:ReferencedObject:{0} .*?\[END&gt;", rousg.ROUsageID);
MatchCollection msg = Regex.Matches(MyGrid.Data, findLinkXml);
//string lookForXml = string.Format(@"&lt;START\](\\[^v \\]+)*\\v0(\\[^v \\]+)* (.*?)(\\[^v '?\\]+)*\\v(\\[^v \\]+)* #Link:ReferencedObject:{0} .*?\[END&gt;", rousg.ROUsageID);
string lookForXml = string.Format(@"^&lt;START\](\\[^v \\]+)*\\v0(\\[^v '?{{}}\\]+)*( |\\u[0-9]{{1,4}}?|\\'[0-9a-fA-F]{{2}}|\\[{{}}~])(.*?)(\\[^v'?{{}} \\]+)*\\v(\\[^v \\]+)* #Link:ReferencedObject:{0} .*?\[END&gt;$", rousg.ROUsageID);
MatchCollection msg = Regex.Matches(MyGrid.Data, findLinkXml);
int nmsg = msg.Count;
for (int i = nmsg - 1; i >= 0; i--)
{
@ -214,12 +232,32 @@ namespace VEPROMS.CSLA.Library
Match mg = Regex.Match(mmg.Value, lookForXml);// Regex.Match(MyGrid.Data, lookForXml);
if (mg != null && mg.Groups.Count > 1)
{
System.Text.RegularExpressions.Group g = mg.Groups[3];
if (g.ToString() != newvalue)
{
retval = g.Value;
MyGrid.Data = MyGrid.Data.Substring(0, offset + mmg.Index + g.Index) + newvalue + MyGrid.Data.Substring(offset + mmg.Index + g.Index + g.Length);
}
int myIndex = mg.Groups[4].Index + mmg.Index;
int myLength = mg.Groups[4].Length;
if (mg.Groups[3].Value != " ")
{
myIndex = mg.Groups[3].Index + mmg.Index;
myLength += mg.Groups[3].Length;
}
string gg = MyGrid.Data.Substring(myIndex, myLength);
if (newvalue.Contains(@"\u8209?"))
{
Match m = Regex.Match(newvalue, @"(\\f[0-9]+)(\\u[0-9]{1,4}\?)(\\f[0-9]+ ?)");
if (m == null)
newvalue = newvalue.Replace(@"\u8209?", "-");
else
newvalue = newvalue.Replace(@"\u8209?", m.Groups[1].Value + @"\u8209?" + m.Groups[3].Value);
}
if (gg != newvalue)
{
MyGrid.Data = MyGrid.Data.Substring(0, myIndex) + newvalue + MyGrid.Data.Substring(myIndex + myLength);
}
//System.Text.RegularExpressions.Group g = mg.Groups[3];
//if (g.ToString() != newvalue)
//{
// retval = g.Value;
// MyGrid.Data = MyGrid.Data.Substring(0, offset + mmg.Index + g.Index) + newvalue + MyGrid.Data.Substring(offset + mmg.Index + g.Index + g.Length);
//}
}
}
}
@ -234,6 +272,7 @@ namespace VEPROMS.CSLA.Library
{
string retval = null;
string newvalue = value;
newvalue = newvalue.Replace("{", @"\{").Replace("}", @"\}");
string findLink = @"<START\].*?\[END>";
MatchCollection ms = Regex.Matches(Text, findLink);
//string lookFor = string.Format(@"<START\](\\[^v \\]+)*\\v0(\\[^v \\]+)* (.*?)(\\[^v '?\\]+)*\\v(\\[^v \\]+)* #Link:ReferencedObject:{0} .*?\[END>", rousg.ROUsageID);

View File

@ -978,6 +978,7 @@ namespace VEPROMS.CSLA.Library
myLength += m.Groups[3].Length;
}
string gg = myTI.ContentText.Substring(myIndex, myLength);
gg = gg.Replace("{", @"\{").Replace("}", @"\}");
cc.AddTransitionToCheck(myTI.TransitionID, gg);
// System.Text.RegularExpressions.Group g = m.Groups[3];
// cc.AddTransitionToCheck(myTI.TransitionID, g.ToString());