Search in sources :

Example 6 with ListLevel

use of org.apache.poi.hwpf.model.ListLevel in project poi by apache.

the class Paragraph method newParagraph.

@Internal
public static Paragraph newParagraph(Range parent, PAPX papx) {
    HWPFDocumentCore doc = parent._doc;
    ListTables listTables = doc.getListTables();
    StyleSheet styleSheet = doc.getStyleSheet();
    ParagraphProperties properties = new ParagraphProperties();
    properties.setIstd(papx.getIstd());
    properties = newParagraph_applyStyleProperties(styleSheet, papx, properties);
    properties = ParagraphSprmUncompressor.uncompressPAP(properties, papx.getGrpprl(), 2);
    if (properties.getIlfo() != 0 && listTables != null) {
        LFO lfo = null;
        try {
            lfo = listTables.getLfo(properties.getIlfo());
        } catch (NoSuchElementException exc) {
            log.log(POILogger.WARN, "Paragraph refers to LFO #", properties.getIlfo(), " that does not exists");
        }
        if (lfo != null) {
            final ListLevel listLevel = listTables.getLevel(lfo.getLsid(), properties.getIlvl());
            if (listLevel != null && listLevel.getGrpprlPapx() != null) {
                properties = ParagraphSprmUncompressor.uncompressPAP(properties, listLevel.getGrpprlPapx(), 0);
                // reapply style and local PAPX properties
                properties = newParagraph_applyStyleProperties(styleSheet, papx, properties);
                properties = ParagraphSprmUncompressor.uncompressPAP(properties, papx.getGrpprl(), 2);
            }
        }
    }
    if (properties.getIlfo() > 0)
        return new ListEntry(papx, properties, parent);
    return new Paragraph(papx, properties, parent);
}
Also used : HWPFDocumentCore(org.apache.poi.hwpf.HWPFDocumentCore) StyleSheet(org.apache.poi.hwpf.model.StyleSheet) LFO(org.apache.poi.hwpf.model.LFO) ListTables(org.apache.poi.hwpf.model.ListTables) NoSuchElementException(java.util.NoSuchElementException) ListLevel(org.apache.poi.hwpf.model.ListLevel) Internal(org.apache.poi.util.Internal)

Example 7 with ListLevel

use of org.apache.poi.hwpf.model.ListLevel in project poi by apache.

the class HWPFList method setLevelNumberProperties.

/**
     * Sets the character properties of the list numbers.
     * 
     * @param level
     *            the level number that the properties should apply to.
     * @param chp
     *            The character properties.
     */
public void setLevelNumberProperties(int level, CharacterProperties chp) {
    ListLevel listLevel = _listData.getLevel(level);
    int styleIndex = _listData.getLevelStyle(level);
    CharacterProperties base = _styleSheet.getCharacterStyle(styleIndex);
    byte[] grpprl = CharacterSprmCompressor.compressCharacterProperty(chp, base);
    listLevel.setNumberProperties(grpprl);
}
Also used : ListLevel(org.apache.poi.hwpf.model.ListLevel)

Aggregations

ListLevel (org.apache.poi.hwpf.model.ListLevel)7 LFO (org.apache.poi.hwpf.model.LFO)3 HWPFDocument (org.apache.poi.hwpf.HWPFDocument)2 NoSuchElementException (java.util.NoSuchElementException)1 HWPFDocumentCore (org.apache.poi.hwpf.HWPFDocumentCore)1 LFOData (org.apache.poi.hwpf.model.LFOData)1 ListFormatOverrideLevel (org.apache.poi.hwpf.model.ListFormatOverrideLevel)1 ListTables (org.apache.poi.hwpf.model.ListTables)1 StyleSheet (org.apache.poi.hwpf.model.StyleSheet)1 SprmIterator (org.apache.poi.hwpf.sprm.SprmIterator)1 Internal (org.apache.poi.util.Internal)1