Search in sources :

Example 6 with PredefinedStyle

use of org.olat.core.util.openxml.OpenXMLDocument.PredefinedStyle 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 7 with PredefinedStyle

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

the class HTMLToOpenXMLHandler method setImage.

protected void setImage(String path) {
    Element imgEl = factory.createImageEl(path, maxWidthCm);
    if (imgEl != null) {
        PredefinedStyle style = getCurrentPredefinedStyle();
        Element runEl = factory.createRunEl(Collections.singletonList(imgEl), style);
        Element paragrapheEl = getCurrentParagraph(false);
        paragrapheEl.appendChild(runEl);
    }
}
Also used : PredefinedStyle(org.olat.core.util.openxml.OpenXMLDocument.PredefinedStyle) Element(org.w3c.dom.Element)

Example 8 with PredefinedStyle

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

the class HTMLToOpenXMLHandler method getRunForTextPreferences.

protected Node getRunForTextPreferences() {
    Element paragraphEl = getCurrentParagraph(false);
    Node runPrefs = null;
    Node run = paragraphEl.getLastChild();
    if (run != null && "w:r".equals(run.getNodeName())) {
        Node prefs = run.getLastChild();
        if ("w:rPr".equals(prefs.getNodeName())) {
            runPrefs = prefs;
        }
    }
    if (runPrefs == null) {
        PredefinedStyle style = getCurrentPredefinedStyle();
        run = paragraphEl.appendChild(factory.createRunEl(null, style));
        runPrefs = run.appendChild(factory.createRunPrefsEl());
    }
    if (!"w:rPr".equals(runPrefs.getNodeName())) {
        runPrefs = run.appendChild(factory.createRunPrefsEl());
    }
    return runPrefs;
}
Also used : PredefinedStyle(org.olat.core.util.openxml.OpenXMLDocument.PredefinedStyle) Element(org.w3c.dom.Element) Node(org.w3c.dom.Node)

Example 9 with PredefinedStyle

use of org.olat.core.util.openxml.OpenXMLDocument.PredefinedStyle 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)

Example 10 with PredefinedStyle

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

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

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