Example usage for org.apache.poi.xwpf.usermodel LineSpacingRule AT_LEAST

List of usage examples for org.apache.poi.xwpf.usermodel LineSpacingRule AT_LEAST

Introduction

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

Prototype

LineSpacingRule AT_LEAST

To view the source code for org.apache.poi.xwpf.usermodel LineSpacingRule AT_LEAST.

Click Source Link

Document

Specifies that the height of the line shall be at least the value specified, but may be expanded to fit its content as needed.

Usage

From source file:org.articleEditor.insertContent.POIDocxReader.java

License:Apache License

protected void processParagraph(XWPFParagraph paragraph) throws BadLocationException {
    parAttrs = new SimpleAttributeSet();
    ParagraphAlignment alignment = paragraph.getAlignment();
    if (alignment == ParagraphAlignment.CENTER) {
        StyleConstants.setAlignment(parAttrs, StyleConstants.ALIGN_CENTER);
    } else if (alignment == ParagraphAlignment.LEFT) {
        StyleConstants.setAlignment(parAttrs, StyleConstants.ALIGN_LEFT);
    } else if (alignment == ParagraphAlignment.RIGHT) {
        StyleConstants.setAlignment(parAttrs, StyleConstants.ALIGN_RIGHT);
    } else if (alignment == ParagraphAlignment.BOTH || alignment == ParagraphAlignment.DISTRIBUTE) {
        StyleConstants.setAlignment(parAttrs, StyleConstants.ALIGN_JUSTIFIED);
    }//w w w  . j av  a2s. c  o  m
    List<TabStop> tabs = new ArrayList<>();
    int leftIndentation = paragraph.getIndentationLeft();
    if (leftIndentation > 0) {
        float indentation = leftIndentation / INDENTS_MULTIPLIER;
        StyleConstants.setLeftIndent(parAttrs, indentation);
        /*TabStop stop = new TabStop(pos, TabStop.ALIGN_LEFT, TabStop.LEAD_NONE);
         tabs.add(stop);*/
    }
    int rightIndentation = paragraph.getIndentationRight();
    if (rightIndentation > 0) {
        float indentation = rightIndentation / INDENTS_MULTIPLIER;
        StyleConstants.setLeftIndent(parAttrs, indentation);
        /*TabStop stop = new TabStop(pos, TabStop.ALIGN_RIGHT, TabStop.LEAD_NONE);
         tabs.add(stop);*/
    }
    /*TabSet tabSet = new TabSet(tabs.toArray(new TabStop[tabs.size()]));
     StyleConstants.setTabSet(parAttrs, tabSet);*/
    int firstLineIndentation = paragraph.getIndentationFirstLine();
    if (firstLineIndentation > 0) {
        float indentation = firstLineIndentation / INDENTS_MULTIPLIER;
        StyleConstants.setFirstLineIndent(parAttrs, indentation);
        /*TabStop stop = new TabStop(pos, TabStop.ALIGN_RIGHT, TabStop.LEAD_NONE);
         tabs.add(stop);*/
    }

    int spacingBefore = paragraph.getSpacingBefore();
    if (spacingBefore > 0) {
        int before = spacingBefore / INDENTS_MULTIPLIER;
        StyleConstants.setSpaceAbove(parAttrs, before);
    }
    int spacingAfter = paragraph.getSpacingAfter();
    if (spacingAfter > 0) {
        int after = spacingAfter / INDENTS_MULTIPLIER;
        StyleConstants.setSpaceAbove(parAttrs, after);
    }
    LineSpacingRule spacingLine = paragraph.getSpacingLineRule();
    if (spacingLine == LineSpacingRule.AT_LEAST || spacingLine == LineSpacingRule.AUTO) {
        float spacing = spacingLine.getValue() / 240;
        StyleConstants.setLineSpacing(parAttrs, spacing);
    }
    document.setParagraphAttributes(currentOffset, 1, parAttrs, true);
    for (XWPFRun run : paragraph.getRuns()) {
        processRun(run);
    }
}