Search in sources :

Example 6 with EscherSpRecord

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

the class PPDrawing method findEscherTextboxRecord.

/**
	 * Look for EscherTextboxRecords
	 */
private void findEscherTextboxRecord(List<EscherRecord> toSearch, List<EscherTextboxWrapper> found) {
    EscherSpRecord sp = null;
    for (EscherRecord r : toSearch) {
        if (r instanceof EscherSpRecord) {
            sp = (EscherSpRecord) r;
        } else if (r instanceof EscherTextboxRecord) {
            EscherTextboxRecord tbr = (EscherTextboxRecord) r;
            EscherTextboxWrapper w = new EscherTextboxWrapper(tbr);
            if (sp != null) {
                w.setShapeId(sp.getShapeId());
            }
            found.add(w);
        } else if (r.isContainerRecord()) {
            // If it has children, walk them
            List<EscherRecord> children = r.getChildRecords();
            findEscherTextboxRecord(children, found);
        }
    }
}
Also used : EscherSpRecord(org.apache.poi.ddf.EscherSpRecord) EscherTextboxRecord(org.apache.poi.ddf.EscherTextboxRecord) EscherRecord(org.apache.poi.ddf.EscherRecord)

Example 7 with EscherSpRecord

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

the class HSLFSlide method onCreate.

/**
     * Called by SlideShow ater a new slide is created.
     * <p>
     * For Slide we need to do the following:
     *  <li> set id of the drawing group.
     *  <li> set shapeId for the container descriptor and background
     * </p>
     */
@Override
public void onCreate() {
    //initialize drawing group id
    EscherDggRecord dgg = getSlideShow().getDocumentRecord().getPPDrawingGroup().getEscherDggRecord();
    EscherContainerRecord dgContainer = getSheetContainer().getPPDrawing().getDgContainer();
    EscherDgRecord dg = (EscherDgRecord) HSLFShape.getEscherChild(dgContainer, EscherDgRecord.RECORD_ID);
    int dgId = dgg.getMaxDrawingGroupId() + 1;
    dg.setOptions((short) (dgId << 4));
    dgg.setDrawingsSaved(dgg.getDrawingsSaved() + 1);
    dgg.setMaxDrawingGroupId(dgId);
    for (EscherContainerRecord c : dgContainer.getChildContainers()) {
        EscherSpRecord spr = null;
        switch(c.getRecordId()) {
            case EscherContainerRecord.SPGR_CONTAINER:
                EscherContainerRecord dc = (EscherContainerRecord) c.getChild(0);
                spr = dc.getChildById(EscherSpRecord.RECORD_ID);
                break;
            case EscherContainerRecord.SP_CONTAINER:
                spr = c.getChildById(EscherSpRecord.RECORD_ID);
                break;
            default:
                break;
        }
        if (spr != null) {
            spr.setShapeId(allocateShapeId());
        }
    }
    //PPT doen't increment the number of saved shapes for group descriptor and background
    dg.setNumShapes(1);
}
Also used : EscherSpRecord(org.apache.poi.ddf.EscherSpRecord) EscherContainerRecord(org.apache.poi.ddf.EscherContainerRecord) EscherDggRecord(org.apache.poi.ddf.EscherDggRecord) EscherDgRecord(org.apache.poi.ddf.EscherDgRecord)

Example 8 with EscherSpRecord

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

the class EscherAggregate method setMainSpRecordId.

/**
     * EscherDgContainer
     * -EscherSpgrContainer
     * --EscherSpContainer
     * ---EscherSpRecord -set id for this record
     * ---***
     * --***
     * -EscherDgRecord
     * set id for the sp record of the first spContainer in main spgrConatiner
     * @param shapeId - id which must be set
     */
public void setMainSpRecordId(int shapeId) {
    EscherContainerRecord dgContainer = getEscherContainer();
    EscherContainerRecord spgrConatiner = (EscherContainerRecord) dgContainer.getChildById(EscherContainerRecord.SPGR_CONTAINER);
    EscherContainerRecord spContainer = (EscherContainerRecord) spgrConatiner.getChild(0);
    EscherSpRecord sp = (EscherSpRecord) spContainer.getChildById(EscherSpRecord.RECORD_ID);
    sp.setShapeId(shapeId);
}
Also used : EscherSpRecord(org.apache.poi.ddf.EscherSpRecord) EscherContainerRecord(org.apache.poi.ddf.EscherContainerRecord)

Example 9 with EscherSpRecord

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

the class HSLFShape method setFlipVertical.

public void setFlipVertical(boolean flip) {
    EscherSpRecord spRecord = getEscherChild(EscherSpRecord.RECORD_ID);
    int flag = spRecord.getFlags() | EscherSpRecord.FLAG_FLIPVERT;
    spRecord.setFlags(flag);
}
Also used : EscherSpRecord(org.apache.poi.ddf.EscherSpRecord)

Example 10 with EscherSpRecord

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

the class HSLFShape method getAnchor.

/**
     * Returns the anchor (the bounding box rectangle) of this shape.
     * All coordinates are expressed in points (72 dpi).
     *
     * @return the anchor of this shape
     */
@Override
public Rectangle2D getAnchor() {
    EscherSpRecord spRecord = getEscherChild(EscherSpRecord.RECORD_ID);
    int flags = spRecord.getFlags();
    int x1, y1, x2, y2;
    EscherChildAnchorRecord childRec = getEscherChild(EscherChildAnchorRecord.RECORD_ID);
    boolean useChildRec = ((flags & EscherSpRecord.FLAG_CHILD) != 0);
    if (useChildRec && childRec != null) {
        x1 = childRec.getDx1();
        y1 = childRec.getDy1();
        x2 = childRec.getDx2();
        y2 = childRec.getDy2();
    } else {
        if (useChildRec) {
            LOG.log(POILogger.WARN, "EscherSpRecord.FLAG_CHILD is set but EscherChildAnchorRecord was not found");
        }
        EscherClientAnchorRecord clientRec = getEscherChild(EscherClientAnchorRecord.RECORD_ID);
        x1 = clientRec.getCol1();
        y1 = clientRec.getFlag();
        x2 = clientRec.getDx1();
        y2 = clientRec.getRow1();
    }
    // TODO: find out where this -1 value comes from at #57820 (link to ms docs?)
    Rectangle2D anchor = new Rectangle2D.Double((x1 == -1 ? -1 : Units.masterToPoints(x1)), (y1 == -1 ? -1 : Units.masterToPoints(y1)), (x2 == -1 ? -1 : Units.masterToPoints(x2 - x1)), (y2 == -1 ? -1 : Units.masterToPoints(y2 - y1)));
    return anchor;
}
Also used : EscherChildAnchorRecord(org.apache.poi.ddf.EscherChildAnchorRecord) EscherSpRecord(org.apache.poi.ddf.EscherSpRecord) EscherClientAnchorRecord(org.apache.poi.ddf.EscherClientAnchorRecord) Rectangle2D(java.awt.geom.Rectangle2D)

Aggregations

EscherSpRecord (org.apache.poi.ddf.EscherSpRecord)31 EscherContainerRecord (org.apache.poi.ddf.EscherContainerRecord)17 EscherClientAnchorRecord (org.apache.poi.ddf.EscherClientAnchorRecord)5 EscherDgRecord (org.apache.poi.ddf.EscherDgRecord)5 EscherOptRecord (org.apache.poi.ddf.EscherOptRecord)5 CommonObjectDataSubRecord (org.apache.poi.hssf.record.CommonObjectDataSubRecord)5 AbstractEscherOptRecord (org.apache.poi.ddf.AbstractEscherOptRecord)4 EscherChildAnchorRecord (org.apache.poi.ddf.EscherChildAnchorRecord)4 EscherRecord (org.apache.poi.ddf.EscherRecord)4 EscherTextboxRecord (org.apache.poi.ddf.EscherTextboxRecord)4 Test (org.junit.Test)4 EscherSimpleProperty (org.apache.poi.ddf.EscherSimpleProperty)3 EscherSpgrRecord (org.apache.poi.ddf.EscherSpgrRecord)3 HSLFEscherClientDataRecord (org.apache.poi.hslf.record.HSLFEscherClientDataRecord)3 EscherBoolProperty (org.apache.poi.ddf.EscherBoolProperty)2 EscherClientDataRecord (org.apache.poi.ddf.EscherClientDataRecord)2 EscherDggRecord (org.apache.poi.ddf.EscherDggRecord)2 EscherRGBProperty (org.apache.poi.ddf.EscherRGBProperty)2 ExObjRefAtom (org.apache.poi.hslf.record.ExObjRefAtom)2 Record (org.apache.poi.hslf.record.Record)2