Search in sources :

Example 1 with ParagraphProperties

use of org.apache.poi.hwpf.usermodel.ParagraphProperties in project poi by apache.

the class ParagraphSprmUncompressor method uncompressPAP.

public static ParagraphProperties uncompressPAP(ParagraphProperties parent, byte[] grpprl, int offset) {
    ParagraphProperties newProperties = null;
    try {
        newProperties = (ParagraphProperties) parent.clone();
    } catch (CloneNotSupportedException cnse) {
        throw new RuntimeException("There is no way this exception should happen!!");
    }
    SprmIterator sprmIt = new SprmIterator(grpprl, offset);
    while (sprmIt.hasNext()) {
        SprmOperation sprm = sprmIt.next();
        // table row
        if (sprm.getType() == SprmOperation.TYPE_PAP) {
            try {
                unCompressPAPOperation(newProperties, sprm);
            } catch (Exception exc) {
                logger.log(POILogger.ERROR, "Unable to apply SPRM operation '" + sprm.getOperation() + "': ", exc);
            }
        }
    }
    return newProperties;
}
Also used : ParagraphProperties(org.apache.poi.hwpf.usermodel.ParagraphProperties)

Example 2 with ParagraphProperties

use of org.apache.poi.hwpf.usermodel.ParagraphProperties in project poi by apache.

the class PAPX method getParagraphProperties.

@Deprecated
@Internal
public ParagraphProperties getParagraphProperties(StyleSheet ss) {
    if (ss == null) {
        // TODO Fix up for Word 6/95
        return new ParagraphProperties();
    }
    short istd = getIstd();
    ParagraphProperties baseStyle = ss.getParagraphStyle(istd);
    ParagraphProperties props = ParagraphSprmUncompressor.uncompressPAP(baseStyle, getGrpprl(), 2);
    return props;
}
Also used : ParagraphProperties(org.apache.poi.hwpf.usermodel.ParagraphProperties) Internal(org.apache.poi.util.Internal)

Example 3 with ParagraphProperties

use of org.apache.poi.hwpf.usermodel.ParagraphProperties in project poi by apache.

the class StyleSheet method createPap.

/**
   * Creates a PartagraphProperties object from a papx stored in the
   * StyleDescription at the index istd in the StyleDescription array. The PAP
   * is placed in the StyleDescription at istd after its been created. Not
   * every StyleDescription will contain a papx. In these cases this function
   * does nothing
   *
   * @param istd The index of the StyleDescription to create the
   *        ParagraphProperties  from (and also place the finished PAP in)
   */
@Deprecated
private void createPap(int istd) {
    StyleDescription sd = _styleDescriptions[istd];
    ParagraphProperties pap = sd.getPAP();
    byte[] papx = sd.getPAPX();
    int baseIndex = sd.getBaseStyle();
    if (pap == null && papx != null) {
        ParagraphProperties parentPAP = new ParagraphProperties();
        if (baseIndex != NIL_STYLE) {
            parentPAP = _styleDescriptions[baseIndex].getPAP();
            if (parentPAP == null) {
                if (baseIndex == istd) {
                    // Oh dear, style claims that it is its own parent
                    throw new IllegalStateException("Pap style " + istd + " claimed to have itself as its parent, which isn't allowed");
                }
                // Create the parent style
                createPap(baseIndex);
                parentPAP = _styleDescriptions[baseIndex].getPAP();
            }
        }
        if (parentPAP == null) {
            parentPAP = new ParagraphProperties();
        }
        pap = ParagraphSprmUncompressor.uncompressPAP(parentPAP, papx, 2);
        sd.setPAP(pap);
    }
}
Also used : ParagraphProperties(org.apache.poi.hwpf.usermodel.ParagraphProperties)

Aggregations

ParagraphProperties (org.apache.poi.hwpf.usermodel.ParagraphProperties)3 Internal (org.apache.poi.util.Internal)1