Search in sources :

Example 1 with AbstractEscherOptRecord

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

the class ActiveXShape method afterInsert.

@Override
protected void afterInsert(HSLFSheet sheet) {
    ExControl ctrl = getExControl();
    if (ctrl == null) {
        throw new NullPointerException("ExControl is not defined");
    }
    ctrl.getExControlAtom().setSlideId(sheet._getSheetNumber());
    String name = ctrl.getProgId() + "-" + getControlIndex() + '';
    byte[] data = StringUtil.getToUnicodeLE(name);
    EscherComplexProperty prop = new EscherComplexProperty(EscherProperties.GROUPSHAPE__SHAPENAME, false, data);
    AbstractEscherOptRecord opt = getEscherOptRecord();
    opt.addEscherProperty(prop);
}
Also used : ExControl(org.apache.poi.hslf.record.ExControl) EscherComplexProperty(org.apache.poi.ddf.EscherComplexProperty) AbstractEscherOptRecord(org.apache.poi.ddf.AbstractEscherOptRecord)

Example 2 with AbstractEscherOptRecord

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

the class HSLFTableCell method createBorder.

/**
     * Create a border to format this table
     *
     * @return the created border
     */
private HSLFLine createBorder(BorderEdge edge) {
    HSLFTable table = getParent();
    HSLFLine line = new HSLFLine(table);
    table.addShape(line);
    AbstractEscherOptRecord opt = getEscherOptRecord();
    setEscherProperty(opt, EscherProperties.GEOMETRY__SHAPEPATH, -1);
    setEscherProperty(opt, EscherProperties.GEOMETRY__FILLOK, -1);
    setEscherProperty(opt, EscherProperties.SHADOWSTYLE__SHADOWOBSURED, 0x20000);
    setEscherProperty(opt, EscherProperties.THREED__LIGHTFACE, 0x80000);
    anchorBorder(edge, line);
    return line;
}
Also used : AbstractEscherOptRecord(org.apache.poi.ddf.AbstractEscherOptRecord)

Example 3 with AbstractEscherOptRecord

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

the class HSLFTable method setRowHeight.

@Override
public void setRowHeight(int row, final double height) {
    if (row < 0 || row >= cells.length) {
        throw new IllegalArgumentException("Row index '" + row + "' is not within range [0-" + (cells.length - 1) + "]");
    }
    // update row height in the table properties
    AbstractEscherOptRecord opt = getEscherChild(RecordTypes.EscherUserDefined.typeID);
    EscherArrayProperty p = opt.lookup(EscherProperties.GROUPSHAPE__TABLEROWPROPERTIES);
    byte[] masterBytes = p.getElement(row);
    double currentHeight = Units.masterToPoints(LittleEndian.getInt(masterBytes, 0));
    LittleEndian.putInt(masterBytes, 0, Units.pointsToMaster(height));
    p.setElement(row, masterBytes);
    // move the cells
    double dy = height - currentHeight;
    for (int i = row; i < cells.length; i++) {
        for (HSLFTableCell c : cells[i]) {
            if (c == null) {
                continue;
            }
            Rectangle2D anchor = c.getAnchor();
            if (i == row) {
                anchor.setRect(anchor.getX(), anchor.getY(), anchor.getWidth(), height);
            } else {
                anchor.setRect(anchor.getX(), anchor.getY() + dy, anchor.getWidth(), anchor.getHeight());
            }
            c.setAnchor(anchor);
        }
    }
    Rectangle2D tblanchor = getAnchor();
    tblanchor.setRect(tblanchor.getX(), tblanchor.getY(), tblanchor.getWidth(), tblanchor.getHeight() + dy);
    setExteriorAnchor(tblanchor);
}
Also used : EscherArrayProperty(org.apache.poi.ddf.EscherArrayProperty) Rectangle2D(java.awt.geom.Rectangle2D) AbstractEscherOptRecord(org.apache.poi.ddf.AbstractEscherOptRecord)

Example 4 with AbstractEscherOptRecord

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

the class HSLFTable method updateRowHeightsProperty.

private void updateRowHeightsProperty() {
    AbstractEscherOptRecord opt = getEscherChild(RecordTypes.EscherUserDefined.typeID);
    EscherArrayProperty p = opt.lookup(EscherProperties.GROUPSHAPE__TABLEROWPROPERTIES);
    byte[] val = new byte[4];
    for (int rowIdx = 0; rowIdx < cells.length; rowIdx++) {
        int rowHeight = Units.pointsToMaster(cells[rowIdx][0].getAnchor().getHeight());
        LittleEndian.putInt(val, 0, rowHeight);
        p.setElement(rowIdx, val);
    }
}
Also used : EscherArrayProperty(org.apache.poi.ddf.EscherArrayProperty) AbstractEscherOptRecord(org.apache.poi.ddf.AbstractEscherOptRecord)

Example 5 with AbstractEscherOptRecord

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

the class HSLFTextShape method getTextDirection.

@Override
public TextDirection getTextDirection() {
    // see 2.4.5 MSOTXFL
    AbstractEscherOptRecord opt = getEscherOptRecord();
    EscherSimpleProperty prop = getEscherProperty(opt, EscherProperties.TEXT__TEXTFLOW);
    int msotxfl = (prop == null) ? 0 : prop.getPropertyValue();
    switch(msotxfl) {
        default:
        // msotxflHorzN
        case 0:
        case // msotxflHorzA
        4:
            return TextDirection.HORIZONTAL;
        // msotxflTtoBA
        case 1:
        // msotxflTtoBN
        case 3:
        case // msotxflVertN
        5:
            return TextDirection.VERTICAL;
        case // msotxflBtoT
        2:
            return TextDirection.VERTICAL_270;
    }
}
Also used : EscherSimpleProperty(org.apache.poi.ddf.EscherSimpleProperty) 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