Search in sources :

Example 61 with AbstractEscherOptRecord

use of org.apache.poi.ddf.AbstractEscherOptRecord in project poi by apache.

the class HSLFTextShape method getTextRotation.

@Override
public Double getTextRotation() {
    // see 2.4.6 MSOCDIR
    AbstractEscherOptRecord opt = getEscherOptRecord();
    EscherSimpleProperty prop = getEscherProperty(opt, EscherProperties.TEXT__FONTROTATION);
    return (prop == null) ? null : (90. * prop.getPropertyValue());
}
Also used : EscherSimpleProperty(org.apache.poi.ddf.EscherSimpleProperty) AbstractEscherOptRecord(org.apache.poi.ddf.AbstractEscherOptRecord)

Example 62 with AbstractEscherOptRecord

use of org.apache.poi.ddf.AbstractEscherOptRecord in project poi by apache.

the class HSLFTextShape method getInset.

/**
     * Returns the distance (in points) between the edge of the text frame
     * and the edge of the inscribed rectangle of the shape that contains the text.
     * Default value is 1/20 inch.
     *
     * @param propId the id of the inset edge
     * @return the inset in points
     */
private double getInset(short propId, double defaultInch) {
    AbstractEscherOptRecord opt = getEscherOptRecord();
    EscherSimpleProperty prop = getEscherProperty(opt, propId);
    int val = prop == null ? (int) (Units.toEMU(Units.POINT_DPI) * defaultInch) : prop.getPropertyValue();
    return Units.toPoints(val);
}
Also used : EscherSimpleProperty(org.apache.poi.ddf.EscherSimpleProperty) AbstractEscherOptRecord(org.apache.poi.ddf.AbstractEscherOptRecord)

Example 63 with AbstractEscherOptRecord

use of org.apache.poi.ddf.AbstractEscherOptRecord in project poi by apache.

the class HSLFTextShape method getTextId.

/**
     * @return id for the text.
     */
public int getTextId() {
    AbstractEscherOptRecord opt = getEscherOptRecord();
    EscherSimpleProperty prop = getEscherProperty(opt, EscherProperties.TEXT__TEXTID);
    return prop == null ? 0 : prop.getPropertyValue();
}
Also used : EscherSimpleProperty(org.apache.poi.ddf.EscherSimpleProperty) AbstractEscherOptRecord(org.apache.poi.ddf.AbstractEscherOptRecord)

Example 64 with AbstractEscherOptRecord

use of org.apache.poi.ddf.AbstractEscherOptRecord in project poi by apache.

the class HSLFTextShape method getAlignment.

/**
     * Returns the type of vertical alignment for the text.
     * One of the <code>Anchor*</code> constants defined in this class.
     *
     * @return the type of alignment
     */
/* package */
HSLFTextAnchor getAlignment() {
    AbstractEscherOptRecord opt = getEscherOptRecord();
    EscherSimpleProperty prop = getEscherProperty(opt, EscherProperties.TEXT__ANCHORTEXT);
    HSLFTextAnchor align = HSLFTextAnchor.TOP;
    if (prop == null) {
        /**
             * If vertical alignment was not found in the shape properties then try to
             * fetch the master shape and search for the align property there.
             */
        int type = getRunType();
        HSLFSheet sh = getSheet();
        HSLFMasterSheet master = (sh != null) ? sh.getMasterSheet() : null;
        HSLFTextShape masterShape = (master != null) ? master.getPlaceholderByTextType(type) : null;
        if (masterShape != null && type != TextHeaderAtom.OTHER_TYPE) {
            align = masterShape.getAlignment();
        } else {
            //not found in the master sheet. Use the hardcoded defaults.
            switch(type) {
                case TextHeaderAtom.TITLE_TYPE:
                case TextHeaderAtom.CENTER_TITLE_TYPE:
                    align = HSLFTextAnchor.MIDDLE;
                    break;
                default:
                    align = HSLFTextAnchor.TOP;
                    break;
            }
        }
    } else {
        align = HSLFTextAnchor.fromNativeId(prop.getPropertyValue());
    }
    if (align == null) {
        align = HSLFTextAnchor.TOP;
    }
    return align;
}
Also used : EscherSimpleProperty(org.apache.poi.ddf.EscherSimpleProperty) AbstractEscherOptRecord(org.apache.poi.ddf.AbstractEscherOptRecord)

Example 65 with AbstractEscherOptRecord

use of org.apache.poi.ddf.AbstractEscherOptRecord in project poi by apache.

the class HSLFTextShape method setTextDirection.

@Override
public void setTextDirection(TextDirection orientation) {
    AbstractEscherOptRecord opt = getEscherOptRecord();
    int msotxfl;
    if (orientation == null) {
        msotxfl = -1;
    } else {
        switch(orientation) {
            default:
            case STACKED:
                // not supported -> remove
                msotxfl = -1;
                break;
            case HORIZONTAL:
                msotxfl = 0;
                break;
            case VERTICAL:
                msotxfl = 1;
                break;
            case VERTICAL_270:
                // always interpreted as horizontal
                msotxfl = 2;
                break;
        }
    }
    setEscherProperty(opt, EscherProperties.TEXT__TEXTFLOW, msotxfl);
}
Also used : AbstractEscherOptRecord(org.apache.poi.ddf.AbstractEscherOptRecord)

Aggregations

AbstractEscherOptRecord (org.apache.poi.ddf.AbstractEscherOptRecord)68 EscherSimpleProperty (org.apache.poi.ddf.EscherSimpleProperty)36 DrawPaint (org.apache.poi.sl.draw.DrawPaint)13 Color (java.awt.Color)8 GradientPaint (org.apache.poi.sl.usermodel.PaintStyle.GradientPaint)7 TexturePaint (org.apache.poi.sl.usermodel.PaintStyle.TexturePaint)7 EscherArrayProperty (org.apache.poi.ddf.EscherArrayProperty)6 EscherContainerRecord (org.apache.poi.ddf.EscherContainerRecord)6 SolidPaint (org.apache.poi.sl.usermodel.PaintStyle.SolidPaint)6 EscherBSERecord (org.apache.poi.ddf.EscherBSERecord)4 Rectangle2D (java.awt.geom.Rectangle2D)3 EscherColorRef (org.apache.poi.ddf.EscherColorRef)3 EscherComplexProperty (org.apache.poi.ddf.EscherComplexProperty)3 EscherRecord (org.apache.poi.ddf.EscherRecord)3 EscherSpRecord (org.apache.poi.ddf.EscherSpRecord)3 AffineTransform (java.awt.geom.AffineTransform)2 EscherProperty (org.apache.poi.ddf.EscherProperty)2 Document (org.apache.poi.hslf.record.Document)2 Test (org.junit.Test)2 Insets (java.awt.Insets)1