Search in sources :

Example 6 with PPDrawing

use of org.apache.poi.hslf.record.PPDrawing in project poi by apache.

the class HSLFSheet method getShapes.

/**
     * Returns all shapes contained in this Sheet
     *
     * @return all shapes contained in this Sheet (Slide or Notes)
     */
@Override
public List<HSLFShape> getShapes() {
    PPDrawing ppdrawing = getPPDrawing();
    EscherContainerRecord dg = ppdrawing.getDgContainer();
    EscherContainerRecord spgr = null;
    for (EscherRecord rec : dg) {
        if (rec.getRecordId() == EscherContainerRecord.SPGR_CONTAINER) {
            spgr = (EscherContainerRecord) rec;
            break;
        }
    }
    if (spgr == null) {
        throw new IllegalStateException("spgr not found");
    }
    List<HSLFShape> shapeList = new ArrayList<HSLFShape>();
    boolean isFirst = true;
    for (EscherRecord r : spgr) {
        if (isFirst) {
            // skip first item
            isFirst = false;
            continue;
        }
        EscherContainerRecord sp = (EscherContainerRecord) r;
        HSLFShape sh = HSLFShapeFactory.createShape(sp, null);
        sh.setSheet(this);
        if (sh instanceof HSLFSimpleShape) {
            HSLFHyperlink link = HSLFHyperlink.find(sh);
            if (link != null) {
                ((HSLFSimpleShape) sh).setHyperlink(link);
            }
        }
        shapeList.add(sh);
    }
    return shapeList;
}
Also used : PPDrawing(org.apache.poi.hslf.record.PPDrawing) ArrayList(java.util.ArrayList) EscherContainerRecord(org.apache.poi.ddf.EscherContainerRecord) EscherRecord(org.apache.poi.ddf.EscherRecord)

Example 7 with PPDrawing

use of org.apache.poi.hslf.record.PPDrawing in project poi by apache.

the class HSLFSheet method getBackground.

/**
     * Returns the background shape for this sheet.
     *
     * @return the background shape for this sheet.
     */
@Override
public HSLFBackground getBackground() {
    if (_background == null) {
        PPDrawing ppdrawing = getPPDrawing();
        EscherContainerRecord dg = ppdrawing.getDgContainer();
        EscherContainerRecord spContainer = dg.getChildById(EscherContainerRecord.SP_CONTAINER);
        _background = new HSLFBackground(spContainer, null);
        _background.setSheet(this);
    }
    return _background;
}
Also used : PPDrawing(org.apache.poi.hslf.record.PPDrawing) EscherContainerRecord(org.apache.poi.ddf.EscherContainerRecord)

Example 8 with PPDrawing

use of org.apache.poi.hslf.record.PPDrawing in project poi by apache.

the class HSLFTextShape method afterInsert.

/**
     * When a textbox is added to  a sheet we need to tell upper-level
     * <code>PPDrawing</code> about it.
     *
     * @param sh the sheet we are adding to
     */
@Override
protected void afterInsert(HSLFSheet sh) {
    super.afterInsert(sh);
    storeText();
    EscherTextboxWrapper thisTxtbox = getEscherTextboxWrapper();
    if (thisTxtbox != null) {
        getSpContainer().addChildRecord(thisTxtbox.getEscherRecord());
        PPDrawing ppdrawing = sh.getPPDrawing();
        ppdrawing.addTextboxWrapper(thisTxtbox);
        // Ensure the escher layer knows about the added records
        try {
            thisTxtbox.writeOut(null);
        } catch (IOException e) {
            throw new HSLFException(e);
        }
        boolean isInitialAnchor = getAnchor().equals(new Rectangle2D.Double());
        boolean isFilledTxt = !"".equals(getText());
        if (isInitialAnchor && isFilledTxt) {
            resizeToFitText();
        }
    }
    for (HSLFTextParagraph htp : _paragraphs) {
        htp.setShapeId(getShapeId());
    }
    sh.onAddTextShape(this);
}
Also used : PPDrawing(org.apache.poi.hslf.record.PPDrawing) HSLFException(org.apache.poi.hslf.exceptions.HSLFException) EscherTextboxWrapper(org.apache.poi.hslf.record.EscherTextboxWrapper) Rectangle2D(java.awt.geom.Rectangle2D) IOException(java.io.IOException)

Aggregations

PPDrawing (org.apache.poi.hslf.record.PPDrawing)8 EscherContainerRecord (org.apache.poi.ddf.EscherContainerRecord)4 EscherTextboxWrapper (org.apache.poi.hslf.record.EscherTextboxWrapper)3 EscherRecord (org.apache.poi.ddf.EscherRecord)2 Rectangle2D (java.awt.geom.Rectangle2D)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 EscherTextboxRecord (org.apache.poi.ddf.EscherTextboxRecord)1 HSLFException (org.apache.poi.hslf.exceptions.HSLFException)1 ColorSchemeAtom (org.apache.poi.hslf.record.ColorSchemeAtom)1 Record (org.apache.poi.hslf.record.Record)1 TextBytesAtom (org.apache.poi.hslf.record.TextBytesAtom)1 TextCharsAtom (org.apache.poi.hslf.record.TextCharsAtom)1 HSLFSlideShowImpl (org.apache.poi.hslf.usermodel.HSLFSlideShowImpl)1