Search in sources :

Example 1 with TextProp

use of org.apache.poi.hslf.model.textproperties.TextProp in project poi by apache.

the class TextStyleListing method showTextProps.

public static void showTextProps(TextPropCollection tpc) {
    List<TextProp> textProps = tpc.getTextPropList();
    System.out.println("    Contains " + textProps.size() + " TextProps");
    for (int i = 0; i < textProps.size(); i++) {
        TextProp tp = textProps.get(i);
        System.out.println("      " + i + " - " + tp.getName());
        System.out.println("          = " + tp.getValue());
        System.out.println("          @ " + tp.getMask());
        if (tp instanceof BitMaskTextProp) {
            BitMaskTextProp bmtp = (BitMaskTextProp) tp;
            String[] subPropNames = bmtp.getSubPropNames();
            boolean[] subPropMatches = bmtp.getSubPropMatches();
            for (int j = 0; j < subPropNames.length; j++) {
                System.out.println("            -> " + j + " - " + subPropNames[j]);
                System.out.println("               " + j + " = " + subPropMatches[j]);
            }
        }
    }
}
Also used : BitMaskTextProp(org.apache.poi.hslf.model.textproperties.BitMaskTextProp) BitMaskTextProp(org.apache.poi.hslf.model.textproperties.BitMaskTextProp) TextProp(org.apache.poi.hslf.model.textproperties.TextProp)

Example 2 with TextProp

use of org.apache.poi.hslf.model.textproperties.TextProp in project poi by apache.

the class HSLFTextParagraph method getPctOrPoints.

private Double getPctOrPoints(String propName) {
    TextProp tp = getPropVal(_paragraphStyle, _masterStyle, propName);
    if (tp == null) {
        return null;
    }
    int val = tp.getValue();
    return (val < 0) ? Units.masterToPoints(val) : val;
}
Also used : BitMaskTextProp(org.apache.poi.hslf.model.textproperties.BitMaskTextProp) TextProp(org.apache.poi.hslf.model.textproperties.TextProp) ParagraphFlagsTextProp(org.apache.poi.hslf.model.textproperties.ParagraphFlagsTextProp) DrawPaint(org.apache.poi.sl.draw.DrawPaint) SolidPaint(org.apache.poi.sl.usermodel.PaintStyle.SolidPaint)

Example 3 with TextProp

use of org.apache.poi.hslf.model.textproperties.TextProp in project poi by apache.

the class HSLFTextParagraph method getBulletColor.

/**
     * Returns the bullet color
     */
public Color getBulletColor() {
    TextProp tp = getPropVal(_paragraphStyle, _masterStyle, "bullet.color");
    boolean hasColor = getFlag(ParagraphFlagsTextProp.BULLET_HARDCOLOR_IDX);
    if (tp == null || !hasColor) {
        // if bullet color is undefined, return color of first run
        if (_runs.isEmpty()) {
            return null;
        }
        SolidPaint sp = _runs.get(0).getFontColor();
        if (sp == null) {
            return null;
        }
        return DrawPaint.applyColorTransform(sp.getSolidColor());
    }
    return getColorFromColorIndexStruct(tp.getValue(), _sheet);
}
Also used : SolidPaint(org.apache.poi.sl.usermodel.PaintStyle.SolidPaint) BitMaskTextProp(org.apache.poi.hslf.model.textproperties.BitMaskTextProp) TextProp(org.apache.poi.hslf.model.textproperties.TextProp) ParagraphFlagsTextProp(org.apache.poi.hslf.model.textproperties.ParagraphFlagsTextProp)

Example 4 with TextProp

use of org.apache.poi.hslf.model.textproperties.TextProp in project poi by apache.

the class HSLFTextParagraph method setPropVal.

/**
     * Returns the named TextProp, either by fetching it (if it exists) or
     * adding it (if it didn't)
     *
     * @param props the TextPropCollection to fetch from / add into
     * @param name the name of the TextProp to fetch/add
     * @param val the value, null if unset
     */
protected void setPropVal(TextPropCollection props, TextPropCollection masterProps, String name, Integer val) {
    TextPropCollection pc = props;
    if (getSheet() instanceof MasterSheet && masterProps != null) {
        pc = masterProps;
    }
    if (val == null) {
        pc.removeByName(name);
        return;
    }
    // Fetch / Add the TextProp
    TextProp tp = pc.addWithName(name);
    tp.setValue(val);
}
Also used : BitMaskTextProp(org.apache.poi.hslf.model.textproperties.BitMaskTextProp) TextProp(org.apache.poi.hslf.model.textproperties.TextProp) ParagraphFlagsTextProp(org.apache.poi.hslf.model.textproperties.ParagraphFlagsTextProp) MasterSheet(org.apache.poi.sl.usermodel.MasterSheet) TextPropCollection(org.apache.poi.hslf.model.textproperties.TextPropCollection)

Example 5 with TextProp

use of org.apache.poi.hslf.model.textproperties.TextProp in project poi by apache.

the class TestTxMasterStyleAtom method checkOtherType.

/**
     * Test styles for type=TextHeaderAtom.OTHER_TYPE
     */
private void checkOtherType(TxMasterStyleAtom txmaster) {
    TextPropCollection props;
    TextProp prop;
    //paragraph styles
    props = txmaster.getParagraphStyles().get(0);
    prop = props.findByName("alignment");
    assertEquals(0, prop.getValue());
    //character styles
    props = txmaster.getCharacterStyles().get(0);
    prop = props.findByName("font.color");
    assertEquals(0x1000000, prop.getValue());
    prop = props.findByName("font.index");
    assertEquals(0, prop.getValue());
    prop = props.findByName("font.size");
    assertEquals(18, prop.getValue());
}
Also used : TextProp(org.apache.poi.hslf.model.textproperties.TextProp) TextPropCollection(org.apache.poi.hslf.model.textproperties.TextPropCollection)

Aggregations

TextProp (org.apache.poi.hslf.model.textproperties.TextProp)13 BitMaskTextProp (org.apache.poi.hslf.model.textproperties.BitMaskTextProp)8 TextPropCollection (org.apache.poi.hslf.model.textproperties.TextPropCollection)6 ParagraphFlagsTextProp (org.apache.poi.hslf.model.textproperties.ParagraphFlagsTextProp)5 SolidPaint (org.apache.poi.sl.usermodel.PaintStyle.SolidPaint)4 CharFlagsTextProp (org.apache.poi.hslf.model.textproperties.CharFlagsTextProp)2 DrawPaint (org.apache.poi.sl.draw.DrawPaint)2 Color (java.awt.Color)1 PPFont (org.apache.poi.hslf.model.PPFont)1 TxMasterStyleAtom (org.apache.poi.hslf.record.TxMasterStyleAtom)1 MasterSheet (org.apache.poi.sl.usermodel.MasterSheet)1