List of usage examples for org.apache.poi.xslf.usermodel XSLFTextParagraph getTextRuns
@Override
public List<XSLFTextRun> getTextRuns()
From source file:org.joeffice.presentation.ShapeComponent.java
License:Apache License
private void handleTextShape(XSLFTextShape textShape) { final JTextPane textField = new JTextPane(); textField.setBorder(BorderFactory.createEmptyBorder()); textField.setOpaque(false);//from w w w. j av a2s .c o m textField.getActionMap().remove(DefaultEditorKit.pageDownAction); // used to move to next or previous slide textField.getActionMap().remove(DefaultEditorKit.pageUpAction); List<XSLFTextParagraph> paragraphs = textShape.getTextParagraphs(); boolean newLine = false; for (XSLFTextParagraph paragraph : paragraphs) { applyAlignment(paragraph, textField); List<XSLFTextRun> textParts = paragraph.getTextRuns(); for (XSLFTextRun textPart : textParts) { try { String text = textPart.getText(); AttributeSet attributes = null; String simpleBullet = ""; try { attributes = getFontAttributes(textPart); simpleBullet = getBullet(paragraph); } catch (Exception ex) { // ignore } if (!text.isEmpty()) { text = simpleBullet + text; } if (newLine) { text = "\r\n" + text; } int documentLength = textField.getDocument().getLength(); textField.getDocument().insertString(documentLength, text, attributes); } catch (BadLocationException ex) { Exceptions.printStackTrace(ex); } } newLine = true; } add(textField); if (editable) { textField.getDocument().addDocumentListener(this); textField.getDocument().addUndoableEditListener( (UndoRedo.Manager) getSlideComponent().getSlidesComponent().getUndoRedo()); textField.addFocusListener(new FocusListener() { @Override public void focusGained(FocusEvent e) { registerActions(textField); } @Override public void focusLost(FocusEvent e) { unregisterActions(); } }); } else { textField.setEditable(false); } }