Example usage for org.apache.poi.xwpf.usermodel XWPFRun isStrike

List of usage examples for org.apache.poi.xwpf.usermodel XWPFRun isStrike

Introduction

In this page you can find the example usage for org.apache.poi.xwpf.usermodel XWPFRun isStrike.

Prototype

@Deprecated
    public boolean isStrike() 

Source Link

Usage

From source file:apachepoitest.DocumentPropertyChecker.java

public static Boolean checkIfRunHasProperty(XWPFRun r, String property, String value) {
    try {//w ww . j a  va 2s  .  c o  m
        switch (property) {
        case "COLOR":
            return r.getColor().equals(value);
        case "FONT FAMILY":
            return r.getFontFamily().equalsIgnoreCase(value);
        case "FONT SIZE":
            return r.getFontSize() == Integer.parseInt(value);
        case "BOLD":
            return r.isBold() == Boolean.valueOf(value);
        case "ITALIC":
            return r.isItalic() == Boolean.valueOf(value);
        case "STRIKETHROUGH":
            return r.isStrike() == Boolean.valueOf(value);
        default:
            System.out.println("Property " + property + " does not exist!");
            return false;
        }
    } catch (NullPointerException e) {
        return false;
    }
}

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   ww w .j a  v a2  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:com.deepoove.poi.resolver.TemplateResolver.java

License:Apache License

private static void styleRun(XWPFRun destRun, XWPFRun srcRun) {
    if (null == destRun || null == srcRun)
        return;/*from www .  j  a  v a2 s. c om*/
    destRun.setBold(srcRun.isBold());
    destRun.setColor(srcRun.getColor());
    destRun.setFontFamily(srcRun.getFontFamily());
    int fontSize = srcRun.getFontSize();
    if (-1 != fontSize)
        destRun.setFontSize(fontSize);
    destRun.setItalic(srcRun.isItalic());
    destRun.setStrike(srcRun.isStrike());
    destRun.setUnderline(srcRun.getUnderline());
}

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);
    }/*ww w .j  a  v  a2s . c  o  m*/
    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();
}