Search in sources :

Example 1 with Indent

use of org.olat.core.util.openxml.OpenXMLDocument.Indent in project OpenOLAT by OpenOLAT.

the class HTMLToOpenXMLHandler method getCurrentIndent.

public Indent getCurrentIndent() {
    if (styleStack.isEmpty())
        return null;
    int indent = 0;
    for (StyleStatus style : styleStack) {
        if (style.isQuote()) {
            indent++;
        }
    }
    int emuIndent = 0;
    if (indent > 0) {
        emuIndent = 700;
    }
    if (indent > 1) {
        emuIndent += (indent - 1) * 100;
    }
    return emuIndent == 0 ? null : new Indent(emuIndent);
}
Also used : Indent(org.olat.core.util.openxml.OpenXMLDocument.Indent)

Example 2 with Indent

use of org.olat.core.util.openxml.OpenXMLDocument.Indent in project OpenOLAT by OpenOLAT.

the class HTMLToOpenXMLHandler method getCurrentParagraph.

/**
 * Flush the text if a new paragraph is created. Trailing text is flushed
 * in the previous paragraph.
 * @param create
 * @return
 */
protected Element getCurrentParagraph(boolean create) {
    if (create || currentParagraph == null) {
        // flush the text
        if (textBuffer != null) {
            flushText();
            addContent(currentParagraph);
        }
        Indent indent = getCurrentIndent();
        Border leftBorder = getCurrentLeftBorder();
        PredefinedStyle predefinedStyle = getCurrentPredefinedStyle();
        currentParagraph = factory.createParagraphEl(indent, leftBorder, startSpacing, predefinedStyle);
        // consumed
        startSpacing = null;
    }
    return currentParagraph;
}
Also used : Indent(org.olat.core.util.openxml.OpenXMLDocument.Indent) PredefinedStyle(org.olat.core.util.openxml.OpenXMLDocument.PredefinedStyle) Border(org.olat.core.util.openxml.OpenXMLDocument.Border)

Example 3 with Indent

use of org.olat.core.util.openxml.OpenXMLDocument.Indent in project OpenOLAT by OpenOLAT.

the class HTMLToOpenXMLHandler method getCurrentRun.

/**
 * Get or create a run on the current paragraph
 * @return
 */
protected Element getCurrentRun() {
    Element paragraphEl;
    if (currentParagraph == null) {
        Indent indent = getCurrentIndent();
        Border leftBorder = getCurrentLeftBorder();
        PredefinedStyle predefinedStyle = getCurrentPredefinedStyle();
        paragraphEl = currentParagraph = factory.createParagraphEl(indent, leftBorder, startSpacing, predefinedStyle);
        startSpacing = null;
    } else {
        paragraphEl = currentParagraph;
    }
    Node lastChild = paragraphEl.getLastChild();
    if (lastChild != null && "w:r".equals(lastChild.getNodeName())) {
        return (Element) lastChild;
    }
    PredefinedStyle runStyle = getCurrentPredefinedStyle();
    return (Element) paragraphEl.appendChild(factory.createRunEl(null, runStyle));
}
Also used : Indent(org.olat.core.util.openxml.OpenXMLDocument.Indent) PredefinedStyle(org.olat.core.util.openxml.OpenXMLDocument.PredefinedStyle) Element(org.w3c.dom.Element) Node(org.w3c.dom.Node) Border(org.olat.core.util.openxml.OpenXMLDocument.Border)

Example 4 with Indent

use of org.olat.core.util.openxml.OpenXMLDocument.Indent in project openolat by klemens.

the class HTMLToOpenXMLHandler method getCurrentRun.

/**
 * Get or create a run on the current paragraph
 * @return
 */
protected Element getCurrentRun() {
    Element paragraphEl;
    if (currentParagraph == null) {
        Indent indent = getCurrentIndent();
        Border leftBorder = getCurrentLeftBorder();
        PredefinedStyle predefinedStyle = getCurrentPredefinedStyle();
        paragraphEl = currentParagraph = factory.createParagraphEl(indent, leftBorder, startSpacing, predefinedStyle);
        startSpacing = null;
    } else {
        paragraphEl = currentParagraph;
    }
    Node lastChild = paragraphEl.getLastChild();
    if (lastChild != null && "w:r".equals(lastChild.getNodeName())) {
        return (Element) lastChild;
    }
    PredefinedStyle runStyle = getCurrentPredefinedStyle();
    return (Element) paragraphEl.appendChild(factory.createRunEl(null, runStyle));
}
Also used : Indent(org.olat.core.util.openxml.OpenXMLDocument.Indent) PredefinedStyle(org.olat.core.util.openxml.OpenXMLDocument.PredefinedStyle) Element(org.w3c.dom.Element) Node(org.w3c.dom.Node) Border(org.olat.core.util.openxml.OpenXMLDocument.Border)

Example 5 with Indent

use of org.olat.core.util.openxml.OpenXMLDocument.Indent in project openolat by klemens.

the class HTMLToOpenXMLHandler method appendParagraph.

protected Element appendParagraph(Spacing spacing) {
    // flush the text
    if (textBuffer != null) {
        flushText();
        addContent(currentParagraph);
    }
    Indent indent = getCurrentIndent();
    Border leftBorder = getCurrentLeftBorder();
    PredefinedStyle predefinedStyle = getCurrentPredefinedStyle();
    currentParagraph = factory.createParagraphEl(indent, leftBorder, spacing, predefinedStyle);
    return currentParagraph;
}
Also used : Indent(org.olat.core.util.openxml.OpenXMLDocument.Indent) PredefinedStyle(org.olat.core.util.openxml.OpenXMLDocument.PredefinedStyle) Border(org.olat.core.util.openxml.OpenXMLDocument.Border)

Aggregations

Indent (org.olat.core.util.openxml.OpenXMLDocument.Indent)8 Border (org.olat.core.util.openxml.OpenXMLDocument.Border)6 PredefinedStyle (org.olat.core.util.openxml.OpenXMLDocument.PredefinedStyle)6 Element (org.w3c.dom.Element)2 Node (org.w3c.dom.Node)2