This commit is contained in:
parent
8764f057c9
commit
12816c2ff0
@ -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,56 +141,46 @@ 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 there are links, we'll need to do extra processing to see if
|
||||||
if (modtext != OriginalText)
|
// there were additions, deletions or modifications.
|
||||||
|
bool haslinks = ((modtext.IndexOf(@"<START]") > -1) || (OriginalText != null && OriginalText != "" && OriginalText.IndexOf(@"<START]") > -1));
|
||||||
|
if (haslinks)
|
||||||
{
|
{
|
||||||
// if there are links, we'll need to do extra processing to see if
|
// Get all links in original list
|
||||||
// there were additions, deletions or modifications.
|
RtfToDisplayTextElements(OriginalText);
|
||||||
bool haslinks = ((modtext.IndexOf(@"<START]") > -1) || (OriginalText != null && OriginalText != "" && OriginalText.IndexOf(@"<START]") > -1));
|
List<displayLinkElement> origList = GetLinkList(DisplayTextElementList);
|
||||||
if (haslinks)
|
// now get new text into displaytext elements for comparison for links:
|
||||||
{
|
RtfToDisplayTextElements(rtb.Rtf);
|
||||||
// Get all links in original list
|
|
||||||
RtfToDisplayTextElements(OriginalText);
|
|
||||||
List<displayLinkElement> origList = GetLinkList(DisplayTextElementList);
|
|
||||||
// now get new text into displaytext elements for comparison for links:
|
|
||||||
RtfToDisplayTextElements(rtb.Rtf);
|
|
||||||
|
|
||||||
// Compare ro/transition lists and delete or add any to the item for any ros/transitions that have been
|
// Compare ro/transition lists and delete or add any to the item for any ros/transitions that have been
|
||||||
// added/deleted or modified.
|
// added/deleted or modified.
|
||||||
ProcessRoTranChanges(itm, origList);
|
ProcessRoTranChanges(itm, origList);
|
||||||
itm.MyContent.Text = DteToString();
|
itm.MyContent.Text = DteToString();
|
||||||
}
|
|
||||||
else
|
// if new transitions/ros, we need to 'fix' the string in the embedded link to contain the
|
||||||
|
// transition or usage record.
|
||||||
|
Dictionary<int, ContentTransition> ctReplacements = BuildCtReplacements(itm.MyContent.ContentTransitions);
|
||||||
|
Dictionary<int, ContentRoUsage> roUsgReplacements = BuildRoUsgReplacements(itm.MyContent.ContentRoUsages);
|
||||||
|
itm.Save();
|
||||||
|
if (ctReplacements.Count > 0)
|
||||||
{
|
{
|
||||||
itm.MyContent.Text = modtext;
|
itm.MyContent.Text = FixCtReplacements(itm.MyContent.Text, ctReplacements);
|
||||||
itm.Save();
|
itm.Save();
|
||||||
}
|
}
|
||||||
|
if (roUsgReplacements.Count > 0)
|
||||||
if (haslinks)
|
|
||||||
{
|
{
|
||||||
// if new transitions/ros, we need to 'fix' the string in the embedded link to contain the
|
itm.MyContent.Text = FixRoUsgReplacements(itm.MyContent.Text, roUsgReplacements);
|
||||||
// transition or usage record.
|
|
||||||
Dictionary<int, ContentTransition> ctReplacements = BuildCtReplacements(itm.MyContent.ContentTransitions);
|
|
||||||
Dictionary<int, ContentRoUsage> roUsgReplacements = BuildRoUsgReplacements(itm.MyContent.ContentRoUsages);
|
|
||||||
itm.Save();
|
itm.Save();
|
||||||
if (ctReplacements.Count > 0)
|
|
||||||
{
|
|
||||||
itm.MyContent.Text = FixCtReplacements(itm.MyContent.Text, ctReplacements);
|
|
||||||
itm.Save();
|
|
||||||
}
|
|
||||||
if (roUsgReplacements.Count > 0)
|
|
||||||
{
|
|
||||||
itm.MyContent.Text = FixRoUsgReplacements(itm.MyContent.Text, roUsgReplacements);
|
|
||||||
itm.Save();
|
|
||||||
}
|
|
||||||
modtext = itm.MyContent.Text;
|
|
||||||
}
|
}
|
||||||
OriginalText = modtext;
|
modtext = itm.MyContent.Text;
|
||||||
}
|
}
|
||||||
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);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user