Search in sources :

Example 11 with TextProp

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

the class HSLFTextParagraph method getMasterPropVal.

private TextProp getMasterPropVal(TextPropCollection props, TextPropCollection masterProps, String propName) {
    boolean isChar = props.getTextPropType() == TextPropType.character;
    // check if we can delegate to master for the property
    if (!isChar) {
        BitMaskTextProp maskProp = (BitMaskTextProp) props.findByName(ParagraphFlagsTextProp.NAME);
        boolean hardAttribute = (maskProp != null && maskProp.getValue() == 0);
        if (hardAttribute) {
            return null;
        }
    }
    String[] propNames = propName.split(",");
    if (masterProps == null) {
        HSLFSheet sheet = getSheet();
        int txtype = getRunType();
        HSLFMasterSheet master = sheet.getMasterSheet();
        if (master == null) {
            logger.log(POILogger.WARN, "MasterSheet is not available");
            return null;
        }
        for (String pn : propNames) {
            TextProp prop = master.getStyleAttribute(txtype, getIndentLevel(), pn, isChar);
            if (prop != null) {
                return prop;
            }
        }
    } else {
        for (String pn : propNames) {
            TextProp prop = masterProps.findByName(pn);
            if (prop != null) {
                return prop;
            }
        }
    }
    return null;
}
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) ParagraphFlagsTextProp(org.apache.poi.hslf.model.textproperties.ParagraphFlagsTextProp) DrawPaint(org.apache.poi.sl.draw.DrawPaint) SolidPaint(org.apache.poi.sl.usermodel.PaintStyle.SolidPaint)

Example 12 with TextProp

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

the class TestTxMasterStyleAtom method checkNotesType.

/**
     * Test styles for type=TextHeaderAtom.NOTES_TYPE
     */
private void checkNotesType(TxMasterStyleAtom txmaster) {
    TextPropCollection props;
    TextProp prop;
    //paragraph styles
    props = txmaster.getParagraphStyles().get(0);
    prop = props.findByName("alignment");
    //title has center 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(12, prop.getValue());
}
Also used : TextProp(org.apache.poi.hslf.model.textproperties.TextProp) TextPropCollection(org.apache.poi.hslf.model.textproperties.TextPropCollection)

Example 13 with TextProp

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

the class TestTxMasterStyleAtom method checkBodyType.

/**
     * Test styles for type=TextHeaderAtom.BODY_TYPE
     */
private void checkBodyType(TxMasterStyleAtom txmaster) {
    TextPropCollection props;
    TextProp prop;
    List<TextPropCollection> prstyles = txmaster.getParagraphStyles();
    List<TextPropCollection> chstyles = txmaster.getCharacterStyles();
    assertEquals("TxMasterStyleAtom for TextHeaderAtom.BODY_TYPE " + "must contain styles for 5 indentation levels", 5, prstyles.size());
    assertEquals("TxMasterStyleAtom for TextHeaderAtom.BODY_TYPE " + "must contain styles for 5 indentation levels", 5, chstyles.size());
    //paragraph styles
    props = prstyles.get(0);
    prop = props.findByName("alignment");
    assertEquals(0, prop.getValue());
    for (int i = 0; i < prstyles.size(); i++) {
        assertNotNull("text.offset is null for indentation level " + i, prstyles.get(i).findByName("text.offset"));
        assertNotNull("bullet.offset is null for indentation level " + i, prstyles.get(i).findByName("bullet.offset"));
    }
    //character styles
    props = chstyles.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(32, 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