use of javax.swing.text.rtf.RTFEditorKit in project intellij-community by JetBrains.
the class HtmlCopyPastePreProcessor method convertFromRtfStream.
private static String convertFromRtfStream(InputStream stream) {
final DefaultStyledDocument document = new DefaultStyledDocument();
try {
new RTFEditorKit().read(stream, document, 0);
final StringWriter writer = new StringWriter();
new HTMLEditorKit().write(writer, document, 0, document.getLength());
return writer.toString();
} catch (IOException | BadLocationException e) {
LOG.error(e);
}
return null;
}
use of javax.swing.text.rtf.RTFEditorKit in project org.csstudio.display.builder by kasemir.
the class WidgetTransfer method installWidgetsFromRTF.
/**
* @param db The {@link Dragboard} containing the dragged data.
* @param selection_tracker Used to get the grid steps from its model to be
* used in offsetting multiple widgets.
* @param widgets The container of the created widgets.
*/
private static void installWidgetsFromRTF(final DragEvent event, final SelectedWidgetUITracker selection_tracker, final List<Widget> widgets) {
final Dragboard db = event.getDragboard();
final String rtf = db.getRtf();
final RTFEditorKit rtfParser = new RTFEditorKit();
final Document document = rtfParser.createDefaultDocument();
try {
rtfParser.read(new ByteArrayInputStream(rtf.getBytes()), document, 0);
installWidgetsFromString(event, document.getText(0, document.getLength()), selection_tracker, widgets);
} catch (Exception ex) {
logger.log(Level.WARNING, "Invalid RTF string", ex);
}
}
use of javax.swing.text.rtf.RTFEditorKit in project openj9 by eclipse.
the class Rtf method convert.
public static String convert(String rtf) throws Exception {
DefaultStyledDocument styledDoc = new DefaultStyledDocument();
RTFEditorKit rtfKit = new RTFEditorKit();
StringReader reader = null;
reader = new StringReader(rtf);
rtfKit.read(reader, styledDoc, 0);
Document doc = styledDoc.getDefaultRootElement().getDocument();
String txt = doc.getText(0, doc.getLength());
return txt;
}
use of javax.swing.text.rtf.RTFEditorKit in project openj9 by eclipse.
the class RtfChild method convert.
public static String convert(String rtf) throws Exception {
DefaultStyledDocument styledDoc = new DefaultStyledDocument();
RTFEditorKit rtfKit = new RTFEditorKit();
StringReader reader = null;
reader = new StringReader(rtf);
rtfKit.read(reader, styledDoc, 0);
Document doc = styledDoc.getDefaultRootElement().getDocument();
String txt = doc.getText(0, doc.getLength());
return txt;
}
use of javax.swing.text.rtf.RTFEditorKit in project openj9 by eclipse.
the class Rtf method convert.
public static String convert(String rtf) throws Exception {
DefaultStyledDocument styledDoc = new DefaultStyledDocument();
RTFEditorKit rtfKit = new RTFEditorKit();
StringReader reader = null;
reader = new StringReader(rtf);
rtfKit.read(reader, styledDoc, 0);
Document doc = styledDoc.getDefaultRootElement().getDocument();
String txt = doc.getText(0, doc.getLength());
return txt;
}
Aggregations