This commit is contained in:
Kathy Ruffing 2009-07-24 11:52:42 +00:00
parent 8764f057c9
commit 12816c2ff0

View File

@ -34,7 +34,7 @@ namespace VEPROMS.CSLA.Library
set { _textFont = value; } set { _textFont = value; }
} }
public string StartText; public string StartText;
public string OriginalText; // compare for save to see if change. public string OriginalText; // compare for save to see if change for links.
private FormatInfo _MyFormat; private FormatInfo _MyFormat;
#endregion #endregion
#region Constructors #region Constructors
@ -66,8 +66,9 @@ namespace VEPROMS.CSLA.Library
// as a precaution, convert any \~ to \u160?. This is for Hard spaces. see the commentary in the // as a precaution, convert any \~ to \u160?. This is for Hard spaces. see the commentary in the
// save portion of this code for an explanation. // save portion of this code for an explanation.
text = text.Replace(@"\~", @"\u160?"); text = text.Replace(@"\~", @"\u160?");
text = text.Replace(@"\r\n", @"\par "); text = text.Replace("\r\n", @"\par ");
if (text.IndexOf(@"\line") > -1)
MessageBox.Show("Found rtf line");
text = text.Replace(@"\line", @"\par"); text = text.Replace(@"\line", @"\par");
// add colors around links: // add colors around links:
@ -140,11 +141,7 @@ namespace VEPROMS.CSLA.Library
return false; return false;
} }
// remove rtf codes that aren't defining attributes, symbols, or links
string modtext = RtfToDbText(rtb.Rtf); string modtext = RtfToDbText(rtb.Rtf);
if (modtext != OriginalText)
{
// if there are links, we'll need to do extra processing to see if // if there are links, we'll need to do extra processing to see if
// there were additions, deletions or modifications. // there were additions, deletions or modifications.
bool haslinks = ((modtext.IndexOf(@"<START]") > -1) || (OriginalText != null && OriginalText != "" && OriginalText.IndexOf(@"<START]") > -1)); bool haslinks = ((modtext.IndexOf(@"<START]") > -1) || (OriginalText != null && OriginalText != "" && OriginalText.IndexOf(@"<START]") > -1));
@ -160,15 +157,7 @@ namespace VEPROMS.CSLA.Library
// added/deleted or modified. // added/deleted or modified.
ProcessRoTranChanges(itm, origList); ProcessRoTranChanges(itm, origList);
itm.MyContent.Text = DteToString(); itm.MyContent.Text = DteToString();
}
else
{
itm.MyContent.Text = modtext;
itm.Save();
}
if (haslinks)
{
// if new transitions/ros, we need to 'fix' the string in the embedded link to contain the // if new transitions/ros, we need to 'fix' the string in the embedded link to contain the
// transition or usage record. // transition or usage record.
Dictionary<int, ContentTransition> ctReplacements = BuildCtReplacements(itm.MyContent.ContentTransitions); Dictionary<int, ContentTransition> ctReplacements = BuildCtReplacements(itm.MyContent.ContentTransitions);
@ -186,10 +175,12 @@ namespace VEPROMS.CSLA.Library
} }
modtext = itm.MyContent.Text; modtext = itm.MyContent.Text;
} }
OriginalText = modtext;
}
else else
return true; // no text changed, but did not fail so return true. {
itm.MyContent.Text = modtext;
itm.Save();
}
OriginalText = modtext;
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -515,7 +506,7 @@ namespace VEPROMS.CSLA.Library
if (m.Value == @"\line") return m.Value; if (m.Value == @"\line") return m.Value;
break; break;
case 'p': case 'p':
if (m.Value == @"\par") return @"\par"; if (m.Value == @"\par") return "\r\n";
//if (m.Value == @"\protect") //if (m.Value == @"\protect")
// return m.Value; // return m.Value;
//if (m.Value == @"\protect0") //if (m.Value == @"\protect0")
@ -546,6 +537,7 @@ namespace VEPROMS.CSLA.Library
retval = Regex.Replace(retval, @"\{[^{]*?\}", "", RegexOptions.Singleline); // Strip Clauses - remove anything from curly braces retval = Regex.Replace(retval, @"\{[^{]*?\}", "", RegexOptions.Singleline); // Strip Clauses - remove anything from curly braces
retval = Regex.Replace(retval, @"\\f[0-9] ", ""); // remove font command with ending space retval = Regex.Replace(retval, @"\\f[0-9] ", ""); // remove font command with ending space
retval = Regex.Replace(retval, @"\\f[0-9]", ""); // remove font command without ending space retval = Regex.Replace(retval, @"\\f[0-9]", ""); // remove font command without ending space
retval = Regex.Replace(retval, @"\\par ", "\r\n");
retval = Regex.Replace(retval, @"\\[^ \\?]+", new MatchEvaluator(ReplaceRTFClause)); // take backslash xyz and evaluates them retval = Regex.Replace(retval, @"\\[^ \\?]+", new MatchEvaluator(ReplaceRTFClause)); // take backslash xyz and evaluates them
// remove a space if there is one as the first character or the last character // remove a space if there is one as the first character or the last character
if (retval[0]==' ')retval = retval.Remove(0, 1); if (retval[0]==' ')retval = retval.Remove(0, 1);