Example usage for org.apache.poi.xwpf.usermodel VerticalAlign BASELINE

List of usage examples for org.apache.poi.xwpf.usermodel VerticalAlign BASELINE

Introduction

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

Prototype

VerticalAlign BASELINE

To view the source code for org.apache.poi.xwpf.usermodel VerticalAlign BASELINE.

Click Source Link

Document

Specifies that the text in the parent run shall be located at the baseline and presented in the same size as surrounding text.

Usage

From source file:de.knowwe.include.export.FootnoteExporter.java

License:Open Source License

@Override
public void export(Section<FootnoteType> section, DocumentBuilder manager) throws ExportException {
    // find id for our footnote
    String refNumber = section.get().getFootnoteID(section);
    BigInteger noteId = getFootnoteIDInternal(manager, section.getArticle(), refNumber);

    // create footnote for that id
    CTFtnEdn ctNote = CTFtnEdn.Factory.newInstance();
    ctNote.setId(noteId);/*w  w w  .  java  2  s. c o m*/
    ctNote.setType(STFtnEdn.NORMAL);
    XWPFFootnotes footnotes = manager.getDocument().createFootnotes();
    XWPFFootnote footnote = footnotes.addFootnote(ctNote);

    // add contents to footer
    XWPFParagraph footPara = footnote.addNewParagraph(CTP.Factory.newInstance());
    footPara.setStyle(Style.footnote.getStyleName());
    XWPFRun footRun = footPara.createRun();
    footRun.setSubscript(VerticalAlign.SUPERSCRIPT);
    footRun.setText(String.valueOf(noteId.intValue()));
    footRun = footPara.createRun();
    footRun.setSubscript(VerticalAlign.BASELINE);
    DocumentBuilder contentBuilder = new ListBuilder(manager, footPara, Style.text);
    contentBuilder.export(section.getChildren());
}

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

License:Apache License

public void applyAttributes(XWPFRun run, AttributeSet attributes) {
    Enumeration attributeNames = attributes.getAttributeNames();
    while (attributeNames.hasMoreElements()) {
        Object attributeName = attributeNames.nextElement();
        Object attributeValue = attributes.getAttribute(attributeName);
        if (attributeName == Bold) {
            run.setBold((Boolean) attributeValue);
        } else if (attributeName == Italic) {
            run.setItalic((Boolean) attributeValue);
        } else if (attributeName == Underline) {
            run.setUnderline((Boolean) attributeValue ? UnderlinePatterns.SINGLE : UnderlinePatterns.NONE);
        } else if (attributeName == FontFamily || attributeName == Family) {
            run.setFontFamily((String) attributeValue);
        } else if (attributeName == FontSize) {
            run.setFontSize(((Number) attributeValue).intValue());
        } else if (attributeName == Foreground) {
            Color color = (Color) attributeValue;
            String rgb = Integer.toHexString((color.getRGB() & 0xffffff) | 0x1000000).substring(1);
            run.setColor(rgb);/*from w w  w.  j a  v  a2  s.  c  o  m*/
        } else if (attributeName == Background) {
            Color color = (Color) attributeValue;
            String rgb = Integer.toHexString((color.getRGB() & 0xffffff) | 0x1000000).substring(1);
            //run.getCTR().getRPr().setHighlight();
        } else if (attributeName == Subscript) {
            run.setSubscript((Boolean) attributeValue ? VerticalAlign.SUBSCRIPT : VerticalAlign.BASELINE);
        } else if (attributeName == Superscript) {
            run.setSubscript((Boolean) attributeValue ? VerticalAlign.SUPERSCRIPT : VerticalAlign.BASELINE);
        } else if (attributeName == StrikeThrough) {
            run.setStrike((Boolean) attributeValue);
        } else if (attributeName == Alignment) {
            ParagraphAlignment alignment = documentToPOI((Integer) attributeValue);
            run.getParagraph().setAlignment(alignment);
        }
    }
}