List of usage examples for org.apache.poi.xwpf.usermodel XWPFRun getSubscript
@Removal(version = "4.2") public VerticalAlign getSubscript()
From source file:apachepoitest.DocumentPropertyEnumerator.java
public static void showParagraphElementProperties(List<XWPFRun> rl) { System.out.println("\nELEMENTS: "); int counter = 1; for (XWPFRun r : rl) { if (r.toString().trim().length() > 0) { System.out.println("#" + counter++ + ": " + r.toString()); } else {/*from w w w . ja va 2 s . c om*/ //Ignore spaces, uncomment to display spaces and comment out "continue" //System.out.println("#" + counter++ + ": <SPACE>"); continue; } if (r.getColor() != null) { System.out.println("COLOR: " + r.getColor()); } if (r.getFontFamily() != null) { System.out.println("FONT: " + r.getFontFamily()); } if (r.getFontSize() > 0) { System.out.println("FONT SIZE: " + r.getFontSize()); } if (r.getPictureText().length() > 0) { System.out.println("PIC TEXT: " + r.getPictureText()); } if (r.getTextPosition() > 0) { System.out.println("TEXT POS: " + r.getTextPosition()); } if (r.isBold()) { System.out.println("BOLD: " + r.isBold()); } if (r.isItalic()) { System.out.println("ITALIC: " + r.isItalic()); } if (r.isStrike()) { System.out.println("STRIKETHROUGH: " + r.isStrike()); } if (!r.getUnderline().toString().equals("NONE")) { System.out.println("UNDERLINE: " + r.getUnderline().toString()); } if (!r.getSubscript().toString().equals("BASELINE")) { System.out.println("Subscript: " + r.getSubscript().toString()); } System.out.println(""); } }
From source file:org.articleEditor.insertContent.POIDocxReader.java
License:Apache License
protected void processRun(XWPFRun run) throws BadLocationException { charAttrs = new SimpleAttributeSet(); if (run.getFontSize() > 0) { int size = run.getFontSize(); StyleConstants.setFontSize(charAttrs, size); }/*from w w w.j a v a2 s .com*/ StyleConstants.setBold(charAttrs, run.isBold()); StyleConstants.setItalic(charAttrs, run.isItalic()); StyleConstants.setStrikeThrough(charAttrs, run.isStrike()); boolean underlined = run.getUnderline() != UnderlinePatterns.NONE; StyleConstants.setUnderline(charAttrs, underlined); VerticalAlign verticalAlignment = run.getSubscript(); if (verticalAlignment == VerticalAlign.SUBSCRIPT) { StyleConstants.setSubscript(parAttrs, true); } else if (verticalAlignment == VerticalAlign.SUPERSCRIPT) { StyleConstants.setSuperscript(parAttrs, true); } else { StyleConstants.setSubscript(parAttrs, false); StyleConstants.setSuperscript(parAttrs, false); } if (run.getFontFamily() != null) { StyleConstants.setFontFamily(charAttrs, run.getFontFamily()); } if (run.getColor() != null) { String name = run.getColor(); if (!name.toLowerCase().equals("auto")) { Color color = Color.decode("#" + name); StyleConstants.setForeground(charAttrs, color); } } // Not working if (run.getCTR().getRPr() != null && run.getCTR().getRPr().getHighlight() != null) { STHighlightColor.Enum colorEnum = run.getCTR().getRPr().getHighlight().getVal(); Color color = decodeHighlightName(colorEnum); StyleConstants.setBackground(charAttrs, color); } for (XWPFPicture picture : run.getEmbeddedPictures()) { processPicture(picture); } String text = run.toString(); document.insertString(currentOffset, text, charAttrs); currentOffset += text.length(); }