Search in sources :

Example 6 with TextProp

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

the class TestTxMasterStyleAtom method checkTitleType.

/**
     * Test styles for type=TextHeaderAtom.TITLE_TYPE
     */
private void checkTitleType(TxMasterStyleAtom txmaster) {
    TextPropCollection props;
    TextProp prop;
    //paragraph styles
    props = txmaster.getParagraphStyles().get(0);
    prop = props.findByName("alignment");
    //title has center alignment
    assertEquals(1, prop.getValue());
    //character styles
    props = txmaster.getCharacterStyles().get(0);
    prop = props.findByName("font.color");
    assertEquals(0x3000000, prop.getValue());
    prop = props.findByName("font.index");
    assertEquals(0, prop.getValue());
    prop = props.findByName("font.size");
    assertEquals(44, prop.getValue());
}
Also used : TextProp(org.apache.poi.hslf.model.textproperties.TextProp) TextPropCollection(org.apache.poi.hslf.model.textproperties.TextPropCollection)

Example 7 with TextProp

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

the class HSLFSlideMaster method getStyleAttribute.

/**
     * Pickup a style attribute from the master.
     * This is the "workhorse" which returns the default style attributes.
     */
@Override
public TextProp getStyleAttribute(int txtype, int level, String name, boolean isCharacter) {
    if (_txmaster.length <= txtype) {
        return null;
    }
    TxMasterStyleAtom t = _txmaster[txtype];
    List<TextPropCollection> styles = isCharacter ? t.getCharacterStyles() : t.getParagraphStyles();
    TextProp prop = null;
    for (int i = Math.min(level, styles.size() - 1); prop == null && i >= 0; i--) {
        prop = styles.get(i).findByName(name);
    }
    if (prop != null) {
        return prop;
    }
    switch(txtype) {
        case TextHeaderAtom.CENTRE_BODY_TYPE:
        case TextHeaderAtom.HALF_BODY_TYPE:
        case TextHeaderAtom.QUARTER_BODY_TYPE:
            txtype = TextHeaderAtom.BODY_TYPE;
            break;
        case TextHeaderAtom.CENTER_TITLE_TYPE:
            txtype = TextHeaderAtom.TITLE_TYPE;
            break;
        default:
            return null;
    }
    return getStyleAttribute(txtype, level, name, isCharacter);
}
Also used : TextProp(org.apache.poi.hslf.model.textproperties.TextProp) TextPropCollection(org.apache.poi.hslf.model.textproperties.TextPropCollection) TxMasterStyleAtom(org.apache.poi.hslf.record.TxMasterStyleAtom)

Example 8 with TextProp

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

the class HSLFTextRun method getFontColor.

/**
	 * @return font color as PaintStyle
	 */
@Override
public SolidPaint getFontColor() {
    TextProp tp = getTextParagraph().getPropVal(characterStyle, masterStyle, "font.color");
    if (tp == null) {
        return null;
    }
    Color color = HSLFTextParagraph.getColorFromColorIndexStruct(tp.getValue(), parentParagraph.getSheet());
    SolidPaint ps = DrawPaint.createSolidPaint(color);
    return ps;
}
Also used : SolidPaint(org.apache.poi.sl.usermodel.PaintStyle.SolidPaint) CharFlagsTextProp(org.apache.poi.hslf.model.textproperties.CharFlagsTextProp) TextProp(org.apache.poi.hslf.model.textproperties.TextProp) BitMaskTextProp(org.apache.poi.hslf.model.textproperties.BitMaskTextProp) Color(java.awt.Color)

Example 9 with TextProp

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

the class HSLFTextRun method getFontFamily.

@Override
public String getFontFamily() {
    HSLFSheet sheet = parentParagraph.getSheet();
    @SuppressWarnings("resource") HSLFSlideShow slideShow = (sheet == null) ? null : sheet.getSlideShow();
    if (sheet == null || slideShow == null) {
        return _fontFamily;
    }
    TextProp tp = getTextParagraph().getPropVal(characterStyle, masterStyle, "font.index,asian.font.index,ansi.font.index,symbol.font.index");
    if (tp == null) {
        return null;
    }
    return slideShow.getFontCollection().getFontWithId(tp.getValue());
}
Also used : CharFlagsTextProp(org.apache.poi.hslf.model.textproperties.CharFlagsTextProp) TextProp(org.apache.poi.hslf.model.textproperties.TextProp) BitMaskTextProp(org.apache.poi.hslf.model.textproperties.BitMaskTextProp)

Example 10 with TextProp

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

the class HSLFTextParagraph method getBulletFont.

/**
     * Returns the bullet font
     */
public String getBulletFont() {
    TextProp tp = getPropVal(_paragraphStyle, _masterStyle, "bullet.font");
    boolean hasFont = getFlag(ParagraphFlagsTextProp.BULLET_HARDFONT_IDX);
    if (tp == null || !hasFont) {
        return getDefaultFontFamily();
    }
    PPFont ppFont = getSheet().getSlideShow().getFont(tp.getValue());
    assert (ppFont != null);
    return ppFont.getFontName();
}
Also used : PPFont(org.apache.poi.hslf.model.PPFont) BitMaskTextProp(org.apache.poi.hslf.model.textproperties.BitMaskTextProp) TextProp(org.apache.poi.hslf.model.textproperties.TextProp) ParagraphFlagsTextProp(org.apache.poi.hslf.model.textproperties.ParagraphFlagsTextProp)

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