Examples of EscherBSERecord


Examples of org.apache.poi.ddf.EscherBSERecord

        HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("SimpleWithImages.xls");
        InternalWorkbook iwb = wb.getWorkbook();
        iwb.findDrawingGroup();
       
        for(int pictureIndex=1; pictureIndex <= 4; pictureIndex++){
            EscherBSERecord bse = iwb.getBSERecord(pictureIndex);
            assertEquals(1, bse.getRef());
        }

        wb.cloneSheet(0);
        for(int pictureIndex=1; pictureIndex <= 4; pictureIndex++){
            EscherBSERecord bse = iwb.getBSERecord(pictureIndex);
            assertEquals(2, bse.getRef());
        }

        wb.cloneSheet(0);
        for(int pictureIndex=1; pictureIndex <= 4; pictureIndex++){
            EscherBSERecord bse = iwb.getBSERecord(pictureIndex);
            assertEquals(3, bse.getRef());
        }
    }
View Full Code Here

Examples of org.apache.poi.ddf.EscherBSERecord

        byte[] data1 = new byte[]{1, 2, 3};
        int idx1 = wb.addPicture(data1, Workbook.PICTURE_TYPE_JPEG);
        assertEquals(1, idx1);
        HSSFPicture p1 = dr.createPicture(anchor, idx1);

        EscherBSERecord bse = wb.getWorkbook().getBSERecord(idx1);

        assertEquals(bse.getRef(), 1);
        dr.createPicture(new HSSFClientAnchor(), idx1);
        assertEquals(bse.getRef(), 2);

        HSSFShapeGroup gr = dr.createGroup(new HSSFClientAnchor());
        gr.createPicture(new HSSFChildAnchor(), idx1);
        assertEquals(bse.getRef(), 3);
    }
View Full Code Here

Examples of org.apache.poi.ddf.EscherBSERecord

        byte[] data1 = new byte[]{1, 2, 3};
        int idx1 = wb.addPicture(data1, Workbook.PICTURE_TYPE_JPEG);
        assertEquals(1, idx1);
        HSSFPicture p1 = dr.createPicture(anchor, idx1);

        EscherBSERecord bse = wb.getWorkbook().getBSERecord(idx1);

        assertEquals(bse.getRef(), 1);
        dr.createPicture(new HSSFClientAnchor(), idx1);
        assertEquals(bse.getRef(), 2);

        HSSFShapeGroup gr = dr.createGroup(new HSSFClientAnchor());
        gr.createPicture(new HSSFChildAnchor(), idx1);
        assertEquals(bse.getRef(), 3);
    }
View Full Code Here

Examples of org.apache.poi.ddf.EscherBSERecord

            case HSSFWorkbook.PICTURE_TYPE_DIB:
                blipRecord.setOptions(HSSFPictureData.MSOBI_DIB);
                break;
        }
       
        EscherBSERecord r = new EscherBSERecord();
        r.setRecordId( EscherBSERecord.RECORD_ID );
        r.setOptions( (short) ( 0x0002 | ( format << 4 ) ) );
        r.setBlipTypeMacOS( (byte) format );
        r.setBlipTypeWin32( (byte) format );
        r.setUid( uid );
        r.setTag( escherTag );
        r.setSize( blipSize );
        r.setRef( 0 );
        r.setOffset( 0 );
        r.setBlipRecord( blipRecord );
       
        return workbook.addBSERecord( r );
    }
View Full Code Here

Examples of org.apache.poi.ddf.EscherBSERecord

        Picture pict2 = new Picture(idx);
        Picture pict3 = new Picture(idx);

        pict.setAnchor(new Rectangle(10,10,100,100));
        s.addShape(pict);
        EscherBSERecord bse1 = pict.getEscherBSERecord();
        assertEquals(1, bse1.getRef());

        pict2.setAnchor(new Rectangle(10,10,100,100));
        s2.addShape(pict2);
        EscherBSERecord bse2 = pict.getEscherBSERecord();
        assertSame(bse1, bse2);
        assertEquals(2, bse1.getRef());

        pict3.setAnchor(new Rectangle(10,10,100,100));
        s3.addShape(pict3);
        EscherBSERecord bse3 = pict.getEscherBSERecord();
        assertSame(bse2, bse3);
        assertEquals(3, bse1.getRef());

    }
View Full Code Here

Examples of org.apache.poi.ddf.EscherBSERecord

        blipRecord.setUID( uid );
        blipRecord.setMarker( (byte) 0xFF );
        blipRecord.setPictureData( pictureData );

        EscherBSERecord r = new EscherBSERecord();
        r.setRecordId( EscherBSERecord.RECORD_ID );
        r.setOptions( (short) ( 0x0002 | ( format << 4 ) ) );
        r.setBlipTypeMacOS( (byte) format );
        r.setBlipTypeWin32( (byte) format );
        r.setUid( uid );
        r.setTag( (short) 0xFF );
        r.setSize( pictureData.length + 25 );
        r.setRef( 1 );
        r.setOffset( 0 );
        r.setBlipRecord( blipRecord );

        return workbook.addBSERecord( r );
    }
View Full Code Here

Examples of org.apache.poi.ddf.EscherBSERecord

     * Return the dimension of this image
     *
     * @return image dimension
     */
    public Dimension getImageDimension(){
        EscherBSERecord bse = patriarch.sheet.book.getBSERecord(pictureIndex);
        byte[] data = bse.getBlipRecord().getPicturedata();
        int type = bse.getBlipTypeWin32();
        Dimension size = new Dimension();

        switch (type){
            //we can calculate the preferred size only for JPEG and PNG
            //other formats like WMF, EMF and PICT are not supported in Java
View Full Code Here

Examples of org.apache.poi.ddf.EscherBSERecord

            }
            dggContainer.setChildRecords(child);
        } else {
            List lst = bstore.getChildRecords();
            for ( int i = 0; i < lst.size(); i++ ) {
                EscherBSERecord bse = (EscherBSERecord) lst.get(i);
                if (Arrays.equals(bse.getUid(), uid)){
                    return i + 1;
                }
                offset += bse.getSize();
             }
        }

        PictureData pict = PictureData.create(format);
        pict.setData(data);
        pict.setOffset(offset);

        EscherBSERecord bse = new EscherBSERecord();
        bse.setRecordId(EscherBSERecord.RECORD_ID);
        bse.setOptions( (short) ( 0x0002 | ( format << 4 ) ) );
        bse.setSize(pict.getRawData().length + 8);
        bse.setUid(uid);

        bse.setBlipTypeMacOS((byte)format);
        bse.setBlipTypeWin32((byte)format);

        if (format == Picture.EMF) bse.setBlipTypeMacOS((byte)Picture.PICT);
        else if (format == Picture.WMF) bse.setBlipTypeMacOS((byte)Picture.PICT);
        else if (format == Picture.PICT) bse.setBlipTypeWin32((byte)Picture.WMF);

        bse.setRef(0);
        bse.setOffset(offset);

        bstore.addChildRecord(bse);
        int count = bstore.getChildRecords().size();
        bstore.setOptions((short)( (count << 4) | 0xF ));
View Full Code Here

Examples of org.apache.poi.ddf.EscherBSERecord

            {
                EscherRecord escherRecord = (EscherRecord) obj;

                if (escherRecord instanceof EscherBSERecord)
                {
                    EscherBSERecord bse = (EscherBSERecord) escherRecord;
                    EscherBlipRecord blip = bse.getBlipRecord();
                    if (blip != null)
                    {
                        pictures.add(new Picture(blip.getPicturedata()));
                    }
                    else if (bse.getOffset() > 0)
                    {
                        // Blip stored in delay stream, which in a word doc, is the main stream
                        EscherRecordFactory recordFactory = new DefaultEscherRecordFactory();
                        blip = (EscherBlipRecord) recordFactory.createRecord(_mainStream, bse.getOffset());
                        blip.fillFields(_mainStream, bse.getOffset(), recordFactory);
                        pictures.add(new Picture(blip.getPicturedata()));
                    }
                }

                // Recursive call.
View Full Code Here

Examples of org.apache.poi.ddf.EscherBSERecord

        blipRecord.setUID( uid );
        blipRecord.setMarker( (byte) 0xFF );
        blipRecord.setPictureData( pictureData );

        EscherBSERecord r = new EscherBSERecord();
        r.setRecordId( EscherBSERecord.RECORD_ID );
        r.setOptions( (short) ( 0x0002 | ( format << 4 ) ) );
        r.setBlipTypeMacOS( (byte) format );
        r.setBlipTypeWin32( (byte) format );
        r.setUid( uid );
        r.setTag( (short) 0xFF );
        r.setSize( pictureData.length + 25 );
        r.setRef( 1 );
        r.setOffset( 0 );
        r.setBlipRecord( blipRecord );

        return workbook.addBSERecord( r );
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.