You've already forked linux-packaging-mono
Imported Upstream version 6.12.0.86
Former-commit-id: 7a84ce7d08c42c458ac8e74b27186ca863315d79
This commit is contained in:
parent
92747312ea
commit
0b380204a4
@ -21,6 +21,7 @@
|
||||
//
|
||||
// Authors:
|
||||
// Peter Bartok (pbartok@novell.com)
|
||||
// Karl Scowen <contact@scowencomputers.co.nz>
|
||||
//
|
||||
|
||||
// COMPLETE
|
||||
@ -60,10 +61,6 @@ namespace System.Windows.Forms.RTF {
|
||||
|
||||
private char prev_char;
|
||||
private bool bump_line;
|
||||
|
||||
private Font font_list;
|
||||
|
||||
private Charset cur_charset;
|
||||
private Stack charset_stack;
|
||||
|
||||
private Style styles;
|
||||
@ -101,10 +98,7 @@ namespace System.Windows.Forms.RTF {
|
||||
line_pos = 0;
|
||||
prev_char = unchecked((char)-1);
|
||||
bump_line = false;
|
||||
font_list = null;
|
||||
charset_stack = null;
|
||||
|
||||
cur_charset = new Charset();
|
||||
charset_stack = new Stack();
|
||||
|
||||
destination_callbacks = new DestinationCallback();
|
||||
class_callbacks = new ClassCallback();
|
||||
@ -369,49 +363,52 @@ SkipCRLF:
|
||||
GetToken2();
|
||||
|
||||
if (this.rtf_class == TokenClass.Text) {
|
||||
this.minor = (Minor)this.cur_charset[(int)this.major];
|
||||
if (encoding == null) {
|
||||
if (encoding == null)
|
||||
encoding = Encoding.GetEncoding (encoding_code_page);
|
||||
}
|
||||
encoded_text = new String (encoding.GetChars (new byte [] { (byte) this.major }));
|
||||
}
|
||||
|
||||
if (this.cur_charset.Flags == CharsetFlags.None) {
|
||||
return this.rtf_class;
|
||||
}
|
||||
|
||||
if (CheckCMM (TokenClass.Control, Major.Unicode, Minor.UnicodeAnsiCodepage)) {
|
||||
} else if (CheckCMM (TokenClass.Control, Major.Unicode, Minor.UnicodeAnsiCodepage)) {
|
||||
encoding_code_page = param;
|
||||
|
||||
// fallback to the default one in case we have an invalid value
|
||||
if (encoding_code_page < 0 || encoding_code_page > 65535)
|
||||
encoding_code_page = DefaultEncodingCodePage;
|
||||
}
|
||||
|
||||
if (((this.cur_charset.Flags & CharsetFlags.Read) != 0) && CheckCM(TokenClass.Control, Major.CharSet)) {
|
||||
this.cur_charset.ReadMap();
|
||||
} else if (((this.cur_charset.Flags & CharsetFlags.Switch) != 0) && CheckCMM(TokenClass.Control, Major.CharAttr, Minor.FontNum)) {
|
||||
encoding = null;
|
||||
} else if (CheckCMM(TokenClass.Control, Major.CharAttr, Minor.FontNum)) {
|
||||
Font fp;
|
||||
|
||||
fp = Font.GetFont(this.font_list, this.param);
|
||||
fp = Font.GetFont(this.fonts, this.param);
|
||||
|
||||
if (fp != null) {
|
||||
if (fp.Name.StartsWith("Symbol")) {
|
||||
this.cur_charset.ID = CharsetType.Symbol;
|
||||
if (fp.Codepage != 0) {
|
||||
if (fp.Codepage != encoding_code_page) {
|
||||
encoding_code_page = fp.Codepage;
|
||||
encoding = null;
|
||||
}
|
||||
} else {
|
||||
this.cur_charset.ID = CharsetType.General;
|
||||
var cp = CharsetToCodepage.Translate (fp.Charset);
|
||||
if (cp != 0 && cp != encoding_code_page) {
|
||||
encoding_code_page = cp;
|
||||
encoding = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (this.rtf_class == TokenClass.Group) {
|
||||
switch(this.major) {
|
||||
case Major.BeginGroup: {
|
||||
charset_stack.Push(encoding_code_page);
|
||||
break;
|
||||
}
|
||||
} else if (((this.cur_charset.Flags & CharsetFlags.Switch) != 0) && (this.rtf_class == TokenClass.Group)) {
|
||||
switch(this.major) {
|
||||
case Major.BeginGroup: {
|
||||
this.charset_stack.Push(this.cur_charset);
|
||||
break;
|
||||
}
|
||||
|
||||
case Major.EndGroup: {
|
||||
this.cur_charset = (Charset)this.charset_stack.Pop();
|
||||
break;
|
||||
case Major.EndGroup: {
|
||||
if (charset_stack.Count > 0) {
|
||||
encoding_code_page = (int)this.charset_stack.Pop();
|
||||
} else {
|
||||
encoding_code_page = DefaultEncodingCodePage;
|
||||
}
|
||||
if (encoding != null && encoding.CodePage != encoding_code_page)
|
||||
encoding = null;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -677,7 +674,10 @@ SkipCRLF:
|
||||
|
||||
font = new Font(rtf);
|
||||
|
||||
while ((rtf.rtf_class != TokenClass.EOF) && (!rtf.CheckCM(TokenClass.Text, (Major)';')) && (!rtf.CheckCM(TokenClass.Group, Major.EndGroup))) {
|
||||
int depth = 0;
|
||||
string untaggedName = null;
|
||||
|
||||
while ((rtf.rtf_class != TokenClass.EOF) && (!rtf.CheckCM(TokenClass.Text, (Major)';')) && depth >= 0) {
|
||||
if (rtf.rtf_class == TokenClass.Control) {
|
||||
switch(rtf.major) {
|
||||
case Major.FontFamily: {
|
||||
@ -734,6 +734,26 @@ SkipCRLF:
|
||||
break;
|
||||
}
|
||||
|
||||
case Major.Destination: {
|
||||
switch (rtf.minor) {
|
||||
case Minor.FontName:
|
||||
untaggedName = ReadFontName (rtf);
|
||||
break;
|
||||
|
||||
case Minor.FontAltName:
|
||||
font.AltName = ReadFontName (rtf);
|
||||
break;
|
||||
|
||||
default: {
|
||||
#if RTF_DEBUG
|
||||
Console.WriteLine ("Got unhandled Control.Destination.Minor: " + rtf.minor);
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
default: {
|
||||
#if RTF_DEBUG
|
||||
Console.WriteLine("ReadFontTbl: Unknown Control token " + rtf.major);
|
||||
@ -742,22 +762,12 @@ SkipCRLF:
|
||||
}
|
||||
}
|
||||
} else if (rtf.CheckCM(TokenClass.Group, Major.BeginGroup)) {
|
||||
rtf.SkipGroup();
|
||||
} else if (rtf.rtf_class == TokenClass.Text) {
|
||||
StringBuilder sb;
|
||||
|
||||
sb = new StringBuilder();
|
||||
|
||||
while ((rtf.rtf_class != TokenClass.EOF) && (!rtf.CheckCM(TokenClass.Text, (Major)';')) && (!rtf.CheckCM(TokenClass.Group, Major.EndGroup)) && (!rtf.CheckCM(TokenClass.Group, Major.BeginGroup))) {
|
||||
sb.Append((char)rtf.major);
|
||||
rtf.GetToken();
|
||||
}
|
||||
|
||||
if (rtf.CheckCM(TokenClass.Group, Major.EndGroup)) {
|
||||
rtf.UngetToken();
|
||||
}
|
||||
|
||||
font.Name = sb.ToString();
|
||||
depth++;
|
||||
} else if (rtf.CheckCM(TokenClass.Group, Major.EndGroup)) {
|
||||
depth--;
|
||||
} else if (rtf.rtf_class == TokenClass.Text)
|
||||
{
|
||||
font.Name = ReadFontName (rtf);
|
||||
continue;
|
||||
#if RTF_DEBUG
|
||||
} else {
|
||||
@ -768,6 +778,9 @@ SkipCRLF:
|
||||
rtf.GetToken();
|
||||
}
|
||||
|
||||
if (untaggedName != null)
|
||||
font.Name = untaggedName;
|
||||
|
||||
if (old == 0) {
|
||||
rtf.GetToken();
|
||||
|
||||
@ -788,6 +801,26 @@ SkipCRLF:
|
||||
rtf.RouteToken();
|
||||
}
|
||||
|
||||
private static String ReadFontName(RTF rtf)
|
||||
{
|
||||
StringBuilder sb = new StringBuilder ();
|
||||
|
||||
while (rtf.rtf_class != TokenClass.EOF && rtf.rtf_class != TokenClass.Text)
|
||||
rtf.GetToken ();
|
||||
|
||||
while ((rtf.rtf_class != TokenClass.EOF) && (!rtf.CheckCM (TokenClass.Text, (Major)';')) && (!rtf.CheckCM(TokenClass.Group, Major.EndGroup)) &&
|
||||
(!rtf.CheckCM (TokenClass.Group, Major.BeginGroup))) {
|
||||
sb.Append ((char)rtf.major);
|
||||
rtf.GetToken ();
|
||||
}
|
||||
|
||||
if (rtf.CheckCM (TokenClass.Group, Major.EndGroup)) {
|
||||
rtf.UngetToken();
|
||||
}
|
||||
|
||||
return sb.ToString ();
|
||||
}
|
||||
|
||||
private void ReadColorTbl(RTF rtf) {
|
||||
Color color;
|
||||
int num;
|
||||
@ -943,20 +976,25 @@ SkipCRLF:
|
||||
private void ReadPictGroup(RTF rtf)
|
||||
{
|
||||
bool read_image_data = false;
|
||||
|
||||
int groupDepth = 0;
|
||||
Picture picture = new Picture ();
|
||||
while (true) {
|
||||
rtf.GetToken ();
|
||||
|
||||
if (rtf.CheckCM (TokenClass.Group, Major.BeginGroup))
|
||||
groupDepth++;
|
||||
|
||||
if (rtf.CheckCM (TokenClass.Group, Major.EndGroup))
|
||||
groupDepth--;
|
||||
|
||||
if (groupDepth < 0)
|
||||
break;
|
||||
|
||||
switch (minor) {
|
||||
case Minor.PngBlip:
|
||||
picture.ImageType = minor;
|
||||
read_image_data = true;
|
||||
break;
|
||||
case Minor.JpegBlip:
|
||||
case Minor.WinMetafile:
|
||||
case Minor.EnhancedMetafile:
|
||||
picture.ImageType = minor;
|
||||
read_image_data = true;
|
||||
continue;
|
||||
@ -1047,10 +1085,33 @@ SkipCRLF:
|
||||
}
|
||||
}
|
||||
|
||||
private void ReadObjGroup(RTF rtf) {
|
||||
rtf.SkipGroup();
|
||||
rtf.RouteToken();
|
||||
private void ReadObjGroup (RTF rtf)
|
||||
{
|
||||
int level;
|
||||
|
||||
level = 1;
|
||||
|
||||
while (GetToken () != TokenClass.EOF && this.minor != Minor.ObjResult) {
|
||||
if (rtf_class == TokenClass.Group) {
|
||||
if (this.major == Major.BeginGroup) {
|
||||
level++;
|
||||
} else if (this.major == Major.EndGroup) {
|
||||
level--;
|
||||
if (level < 1) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (level >= 1) {
|
||||
GetToken ();
|
||||
|
||||
if (rtf_class == TokenClass.Group)
|
||||
GetToken ();
|
||||
rtf.RouteToken ();
|
||||
}
|
||||
}
|
||||
#endregion // Default Delegates
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user