Fixed logic to support text library documents

A couple more fixes to paste dashes from Adobe
This commit is contained in:
Rich
2012-12-06 21:29:55 +00:00
parent fd983f616c
commit 414378e0f3
2 changed files with 36 additions and 25 deletions

View File

@@ -162,31 +162,38 @@ namespace DataLoader
private void LoadAndSaveRichTextBox41(string tmpName)
{
string rtf = LoadFileRaw(tmpName);
rtf = StripTokensFromFontTable(rtf);
// Parse for margins because the RTB will remove them
rtf = rtf.Replace("\x95", @"\bullet ");// Bullet
rtf = rtf.Replace("\x93", @"\'93");// Left Double Quote
rtf = rtf.Replace("\x94", @"\'94");// Right Double Quote
rtf = rtf.Replace("\x96", @"\u8211?");//
rtf = rtf.Replace("\x89", @"\u8240?");//
rtf = rtf.Replace("\x92", @"\u8217?");//
rtf = rtf.Replace("\x84", @"\u8222?");//
rtf = rtf.Replace("\x85", @"\u8230?");//
rtf = rtf.Replace("\x97", @"\u8212?");//
rtf = rtf.Replace("\x9C", @"\u339?");//
rtf = rtf.Replace("\x98", @"\u732?");//
Match match = Regex.Match(rtf, @"((\\marg[^\\]+)+)", RegexOptions.Singleline);
rtf = Regex.Replace(rtf, @"(?<!\\[^ \\\r\n]*)\\sectd ", "");
rtf = Regex.Replace(rtf, @"(?<!\\[^ \\\r\n]*)\\sbkpage ", "");
rtf = Regex.Replace(rtf, @"\\ri[0-9]*(?=[ \\{])", "");// Remove Right Indents
rtf = Regex.Replace(rtf, @"\\sectd(?=[\\{])", "");
rtf = Regex.Replace(rtf, @"\\sbkpage(?=[\\{])", "");
rtf = Regex.Replace(rtf, @"\\sect(?=[ \\{\r])", @"\page");
MyRichTextBox41.Rtf = rtf; // Allow the RichTextBox to parse the RTF
rtf = MyRichTextBox41.Rtf; // Get the RTF back from the RichTextBox
// Add the margins to the RTB output
rtf = Regex.Replace(rtf, @"\\ansi(?=[ \\{])", @"\ansi" + match.Value);
// Save the modified rtf to the temporary file
if (rtf.StartsWith(@"{\rtf"))
{
rtf = StripTokensFromFontTable(rtf);
// Parse for margins because the RTB will remove them
rtf = rtf.Replace("\x95", @"\bullet ");// Bullet
rtf = rtf.Replace("\x93", @"\'93");// Left Double Quote
rtf = rtf.Replace("\x94", @"\'94");// Right Double Quote
rtf = rtf.Replace("\x96", @"\u8211?");//
rtf = rtf.Replace("\x89", @"\u8240?");//
rtf = rtf.Replace("\x92", @"\u8217?");//
rtf = rtf.Replace("\x84", @"\u8222?");//
rtf = rtf.Replace("\x85", @"\u8230?");//
rtf = rtf.Replace("\x97", @"\u8212?");//
rtf = rtf.Replace("\x9C", @"\u339?");//
rtf = rtf.Replace("\x98", @"\u732?");//
Match match = Regex.Match(rtf, @"((\\marg[^\\]+)+)", RegexOptions.Singleline);
rtf = Regex.Replace(rtf, @"(?<!\\[^ \\\r\n]*)\\sectd ", "");
rtf = Regex.Replace(rtf, @"(?<!\\[^ \\\r\n]*)\\sbkpage ", "");
rtf = Regex.Replace(rtf, @"\\ri[0-9]*(?=[ \\{])", "");// Remove Right Indents
rtf = Regex.Replace(rtf, @"\\sectd(?=[\\{])", "");
rtf = Regex.Replace(rtf, @"\\sbkpage(?=[\\{])", "");
rtf = Regex.Replace(rtf, @"\\sect(?=[ \\{\r])", @"\page");
MyRichTextBox41.Rtf = rtf; // Allow the RichTextBox to parse the RTF
rtf = MyRichTextBox41.Rtf; // Get the RTF back from the RichTextBox
// Add the margins to the RTB output
rtf = Regex.Replace(rtf, @"\\ansi(?=[ \\{])", @"\ansi" + match.Value);
}
else
{
MyRichTextBox41.Text = rtf;
rtf = MyRichTextBox41.Rtf;
}
SaveFile(rtf, tmpName);
}
private string _Prefix;