69 /** This array maps character style numbers to Style objects. */
70 Style[] characterStyles;
71 /** This array maps paragraph style numbers to Style objects. */
72 Style[] paragraphStyles;
73 /** This array maps section style numbers to Style objects. */
74 Style[] sectionStyles;
75
76 /** This is the RTF version number, extracted from the \rtf keyword.
77 * The version information is currently not used. */
78 int rtfversion;
79
80 /** <code>true</code> to indicate that if the next keyword is unknown,
81 * the containing group should be ignored. */
82 boolean ignoreGroupIfUnknownKeyword;
83
84 /** The parameter of the most recently parsed \\ucN keyword,
85 * used for skipping alternative representations after a
86 * Unicode character. */
87 int skippingCharacters;
88
89 static private Dictionary<String, RTFAttribute> straightforwardAttributes;
90 static {
91 straightforwardAttributes = RTFAttributes.attributesByKeyword();
92 }
93
94 private MockAttributeSet mockery;
95
96 /* this should be final, but there's a bug in javac... */
97 /** textKeywords maps RTF keywords to single-character strings,
98 * for those keywords which simply insert some text. */
99 static Dictionary<String, String> textKeywords = null;
100 static {
101 textKeywords = new Hashtable<String, String>();
102 textKeywords.put("\\", "\\");
103 textKeywords.put("{", "{");
104 textKeywords.put("}", "}");
105 textKeywords.put(" ", "\u00A0"); /* not in the spec... */
106 textKeywords.put("~", "\u00A0"); /* nonbreaking space */
107 textKeywords.put("_", "\u2011"); /* nonbreaking hyphen */
108 textKeywords.put("bullet", "\u2022");
109 textKeywords.put("emdash", "\u2014");
1049 /** This is the "chr" element of parserState, cached for
1050 * more efficient use */
1051 MutableAttributeSet characterAttributes;
1052 /** This is the "pgf" element of parserState, cached for
1053 * more efficient use */
1054 MutableAttributeSet paragraphAttributes;
1055 /** This is the "sec" element of parserState, cached for
1056 * more efficient use */
1057 MutableAttributeSet sectionAttributes;
1058
1059 public AttributeTrackingDestination()
1060 {
1061 characterAttributes = rootCharacterAttributes();
1062 parserState.put("chr", characterAttributes);
1063 paragraphAttributes = rootParagraphAttributes();
1064 parserState.put("pgf", paragraphAttributes);
1065 sectionAttributes = rootSectionAttributes();
1066 parserState.put("sec", sectionAttributes);
1067 }
1068
1069 abstract public void handleText(String text);
1070
1071 public void handleBinaryBlob(byte[] data)
1072 {
1073 /* This should really be in TextHandlingDestination, but
1074 * since *nobody* does anything with binary blobs, this
1075 * is more convenient. */
1076 warning("Unexpected binary data in RTF file.");
1077 }
1078
1079 public void begingroup()
1080 {
1081 AttributeSet characterParent = currentTextAttributes();
1082 AttributeSet paragraphParent = currentParagraphAttributes();
1083 AttributeSet sectionParent = currentSectionAttributes();
1084
1085 /* It would probably be more efficient to use the
1086 * resolver property of the attributes set for
1087 * implementing rtf groups,
1088 * but that's needed for styles. */
1089
|
69 /** This array maps character style numbers to Style objects. */
70 Style[] characterStyles;
71 /** This array maps paragraph style numbers to Style objects. */
72 Style[] paragraphStyles;
73 /** This array maps section style numbers to Style objects. */
74 Style[] sectionStyles;
75
76 /** This is the RTF version number, extracted from the \rtf keyword.
77 * The version information is currently not used. */
78 int rtfversion;
79
80 /** <code>true</code> to indicate that if the next keyword is unknown,
81 * the containing group should be ignored. */
82 boolean ignoreGroupIfUnknownKeyword;
83
84 /** The parameter of the most recently parsed \\ucN keyword,
85 * used for skipping alternative representations after a
86 * Unicode character. */
87 int skippingCharacters;
88
89 private static Dictionary<String, RTFAttribute> straightforwardAttributes;
90 static {
91 straightforwardAttributes = RTFAttributes.attributesByKeyword();
92 }
93
94 private MockAttributeSet mockery;
95
96 /* this should be final, but there's a bug in javac... */
97 /** textKeywords maps RTF keywords to single-character strings,
98 * for those keywords which simply insert some text. */
99 static Dictionary<String, String> textKeywords = null;
100 static {
101 textKeywords = new Hashtable<String, String>();
102 textKeywords.put("\\", "\\");
103 textKeywords.put("{", "{");
104 textKeywords.put("}", "}");
105 textKeywords.put(" ", "\u00A0"); /* not in the spec... */
106 textKeywords.put("~", "\u00A0"); /* nonbreaking space */
107 textKeywords.put("_", "\u2011"); /* nonbreaking hyphen */
108 textKeywords.put("bullet", "\u2022");
109 textKeywords.put("emdash", "\u2014");
1049 /** This is the "chr" element of parserState, cached for
1050 * more efficient use */
1051 MutableAttributeSet characterAttributes;
1052 /** This is the "pgf" element of parserState, cached for
1053 * more efficient use */
1054 MutableAttributeSet paragraphAttributes;
1055 /** This is the "sec" element of parserState, cached for
1056 * more efficient use */
1057 MutableAttributeSet sectionAttributes;
1058
1059 public AttributeTrackingDestination()
1060 {
1061 characterAttributes = rootCharacterAttributes();
1062 parserState.put("chr", characterAttributes);
1063 paragraphAttributes = rootParagraphAttributes();
1064 parserState.put("pgf", paragraphAttributes);
1065 sectionAttributes = rootSectionAttributes();
1066 parserState.put("sec", sectionAttributes);
1067 }
1068
1069 public abstract void handleText(String text);
1070
1071 public void handleBinaryBlob(byte[] data)
1072 {
1073 /* This should really be in TextHandlingDestination, but
1074 * since *nobody* does anything with binary blobs, this
1075 * is more convenient. */
1076 warning("Unexpected binary data in RTF file.");
1077 }
1078
1079 public void begingroup()
1080 {
1081 AttributeSet characterParent = currentTextAttributes();
1082 AttributeSet paragraphParent = currentParagraphAttributes();
1083 AttributeSet sectionParent = currentSectionAttributes();
1084
1085 /* It would probably be more efficient to use the
1086 * resolver property of the attributes set for
1087 * implementing rtf groups,
1088 * but that's needed for styles. */
1089
|