src/share/classes/javax/swing/text/rtf/RTFReader.java

Print this page

        

*** 218,227 **** --- 218,228 ---- /* we do this little dance to avoid cloning the entire state stack and immediately throwing it away. */ Object oldSaveState = parserState.get("_savedState"); if (oldSaveState != null) parserState.remove("_savedState"); + @SuppressWarnings("unchecked") Dictionary<String, Object> saveState = (Dictionary<String, Object>)((Hashtable)parserState).clone(); if (oldSaveState != null) saveState.put("_savedState", oldSaveState); parserState.put("_savedState", saveState);
*** 240,266 **** if (skippingCharacters > 0) { /* NB this indicates an error in the RTF. Log it? */ skippingCharacters = 0; } Dictionary<Object, Object> restoredState = (Dictionary<Object, Object>)parserState.get("_savedState"); Destination restoredDestination = (Destination)restoredState.get("dst"); if (restoredDestination != rtfDestination) { rtfDestination.close(); /* allow the destination to clean up */ rtfDestination = restoredDestination; } ! Dictionary oldParserState = parserState; parserState = restoredState; if (rtfDestination != null) rtfDestination.endgroup(oldParserState); } protected void setRTFDestination(Destination newDestination) { /* Check that setting the destination won't close the current destination (should never happen) */ ! Dictionary previousState = (Dictionary)parserState.get("_savedState"); if (previousState != null) { if (rtfDestination != previousState.get("dst")) { warning("Warning, RTF destination overridden, invalid RTF."); rtfDestination.close(); } --- 241,269 ---- if (skippingCharacters > 0) { /* NB this indicates an error in the RTF. Log it? */ skippingCharacters = 0; } + @SuppressWarnings("unchecked") Dictionary<Object, Object> restoredState = (Dictionary<Object, Object>)parserState.get("_savedState"); Destination restoredDestination = (Destination)restoredState.get("dst"); if (restoredDestination != rtfDestination) { rtfDestination.close(); /* allow the destination to clean up */ rtfDestination = restoredDestination; } ! Dictionary<Object, Object> oldParserState = parserState; parserState = restoredState; if (rtfDestination != null) rtfDestination.endgroup(oldParserState); } protected void setRTFDestination(Destination newDestination) { /* Check that setting the destination won't close the current destination (should never happen) */ ! @SuppressWarnings("unchecked") ! Dictionary<Object, Object> previousState = (Dictionary)parserState.get("_savedState"); if (previousState != null) { if (rtfDestination != previousState.get("dst")) { warning("Warning, RTF destination overridden, invalid RTF."); rtfDestination.close(); }
*** 275,285 **** * @see OutputStream#close */ public void close() throws IOException { ! Enumeration docProps = documentAttributes.getAttributeNames(); while(docProps.hasMoreElements()) { Object propName = docProps.nextElement(); target.putProperty(propName, documentAttributes.getAttribute(propName)); } --- 278,288 ---- * @see OutputStream#close */ public void close() throws IOException { ! Enumeration<?> docProps = documentAttributes.getAttributeNames(); while(docProps.hasMoreElements()) { Object propName = docProps.nextElement(); target.putProperty(propName, documentAttributes.getAttribute(propName)); }
*** 626,636 **** void handleText(String text); boolean handleKeyword(String keyword); boolean handleKeyword(String keyword, int parameter); void begingroup(); ! void endgroup(Dictionary oldState); void close(); } /** This data-sink class is used to implement ignored destinations --- 629,639 ---- void handleText(String text); boolean handleKeyword(String keyword); boolean handleKeyword(String keyword, int parameter); void begingroup(); ! void endgroup(Dictionary<Object, Object> oldState); void close(); } /** This data-sink class is used to implement ignored destinations
*** 664,674 **** { /* Ignore groups --- the RTFReader will keep track of the current group level as necessary */ } ! public void endgroup(Dictionary oldState) { /* Ignore groups */ } public void close() --- 667,677 ---- { /* Ignore groups --- the RTFReader will keep track of the current group level as necessary */ } ! public void endgroup(Dictionary<Object, Object> oldState) { /* Ignore groups */ } public void close()
*** 734,744 **** return false; } /* Groups are irrelevant. */ public void begingroup() {} ! public void endgroup(Dictionary oldState) {} /* currently, the only thing we do when the font table ends is dump its contents to the debugging log. */ public void close() { --- 737,747 ---- return false; } /* Groups are irrelevant. */ public void begingroup() {} ! public void endgroup(Dictionary<Object, Object> oldState) {} /* currently, the only thing we do when the font table ends is dump its contents to the debugging log. */ public void close() {
*** 804,814 **** /* Colortbls don't understand any parameterless keywords */ public boolean handleKeyword(String keyword) { return false; } /* Groups are irrelevant. */ public void begingroup() {} ! public void endgroup(Dictionary oldState) {} /* Shouldn't see any binary blobs ... */ public void handleBinaryBlob(byte[] data) {} } --- 807,817 ---- /* Colortbls don't understand any parameterless keywords */ public boolean handleKeyword(String keyword) { return false; } /* Groups are irrelevant. */ public void begingroup() {} ! public void endgroup(Dictionary<Object, Object> oldState) {} /* Shouldn't see any binary blobs ... */ public void handleBinaryBlob(byte[] data) {} }
*** 1096,1106 **** sectionAttributes = new SimpleAttributeSet(); sectionAttributes.addAttributes(sectionParent); parserState.put("sec", sectionAttributes); } ! public void endgroup(Dictionary oldState) { characterAttributes = (MutableAttributeSet)parserState.get("chr"); paragraphAttributes = (MutableAttributeSet)parserState.get("pgf"); sectionAttributes = (MutableAttributeSet)parserState.get("sec"); } --- 1099,1109 ---- sectionAttributes = new SimpleAttributeSet(); sectionAttributes.addAttributes(sectionParent); parserState.put("sec", sectionAttributes); } ! public void endgroup(Dictionary<Object, Object> oldState) { characterAttributes = (MutableAttributeSet)parserState.get("chr"); paragraphAttributes = (MutableAttributeSet)parserState.get("pgf"); sectionAttributes = (MutableAttributeSet)parserState.get("sec"); }
*** 1260,1270 **** TabStop newStop = new TabStop(tabPosition, tabAlignment, tabLeader); Dictionary<Object, Object> tabs; Integer stopCount; ! tabs = (Dictionary<Object, Object>)parserState.get("_tabs"); if (tabs == null) { tabs = new Hashtable<Object, Object>(); parserState.put("_tabs", tabs); stopCount = Integer.valueOf(1); } else { --- 1263,1275 ---- TabStop newStop = new TabStop(tabPosition, tabAlignment, tabLeader); Dictionary<Object, Object> tabs; Integer stopCount; ! @SuppressWarnings("unchecked") ! Dictionary<Object, Object>tmp = (Dictionary)parserState.get("_tabs"); ! tabs = tmp; if (tabs == null) { tabs = new Hashtable<Object, Object>(); parserState.put("_tabs", tabs); stopCount = Integer.valueOf(1); } else {
*** 1418,1428 **** /*** Tab stops ***/ TabStop tabs[]; tabs = (TabStop[])parserState.get("_tabs_immutable"); if (tabs == null) { ! Dictionary workingTabs = (Dictionary)parserState.get("_tabs"); if (workingTabs != null) { int count = ((Integer)workingTabs.get("stop count")).intValue(); tabs = new TabStop[count]; for (int ix = 1; ix <= count; ix ++) tabs[ix-1] = (TabStop)workingTabs.get(Integer.valueOf(ix)); --- 1423,1434 ---- /*** Tab stops ***/ TabStop tabs[]; tabs = (TabStop[])parserState.get("_tabs_immutable"); if (tabs == null) { ! @SuppressWarnings("unchecked") ! Dictionary<Object, Object> workingTabs = (Dictionary)parserState.get("_tabs"); if (workingTabs != null) { int count = ((Integer)workingTabs.get("stop count")).intValue(); tabs = new TabStop[count]; for (int ix = 1; ix <= count; ix ++) tabs[ix-1] = (TabStop)workingTabs.get(Integer.valueOf(ix));