Package org.apache.poi.ddf

Examples of org.apache.poi.ddf.DefaultEscherRecordFactory


        }
    }

    private void convertToEscherRecords( int offset, int size, byte[] data )
    {
        EscherRecordFactory recordFactory = new DefaultEscherRecordFactory();
        int pos = offset;
        while ( pos < offset + size )
        {
            EscherRecord r = recordFactory.createRecord(data, pos);
            int bytesRead = r.fillFields(data, pos, recordFactory );
            escherRecords.add(r);
            pos += bytesRead;
        }
    }
View Full Code Here


        }
    }

    private void convertToEscherRecords( int offset, int size, byte[] data )
    {
        EscherRecordFactory recordFactory = new DefaultEscherRecordFactory();
        int pos = offset;
        while ( pos < offset + size )
        {
            EscherRecord r = recordFactory.createRecord(data, pos);
            int bytesRead = r.fillFields(data, pos, recordFactory );
            escherRecords.add(r);
            pos += bytesRead;
        }
    }
View Full Code Here

    System.out.println(ind + " Type is " + r.getRecordType() + " (" + hexType + " -> " + rHexType + " )");
    System.out.println(ind + " Len is " + (len-8) + " (" + makeHex((len-8),8) + "), on disk len is " + len );

    // print additional information for drawings and atoms
    if (optEscher && cname.equals("PPDrawing")) {
      DefaultEscherRecordFactory factory = new DefaultEscherRecordFactory();

      ByteArrayOutputStream baos = new ByteArrayOutputStream();
      r.writeOut(baos);
      byte[] b = baos.toByteArray();

      EscherRecord er = factory.createRecord(b, 0);
      er.fillFields(b, 0, factory);

      System.out.println( printEscherRecord( er ) );

    } else if(optVerbose && r.getChildRecords() == null) {
View Full Code Here

                        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()));
                    }
                }
View Full Code Here

  public static EscherAggregate createAggregate( List records, int locFirstDrawingRecord, DrawingManager2 drawingManager )
  {
    // Keep track of any shape records created so we can match them back to the object id's.
    // Textbox objects are also treated as shape objects.
    final List<EscherRecord> shapeRecords = new ArrayList<EscherRecord>();
    EscherRecordFactory recordFactory = new DefaultEscherRecordFactory()
    {
      public EscherRecord createRecord( byte[] data, int offset )
      {
        EscherRecord r = super.createRecord( data, offset );
        if ( r.getRecordId() == EscherClientDataRecord.RECORD_ID || r.getRecordId() == EscherTextboxRecord.RECORD_ID )
        {
          shapeRecords.add( r );
        }
        return r;
      }
    };

    // Calculate the size of the buffer
    EscherAggregate agg = new EscherAggregate(drawingManager);
    int loc = locFirstDrawingRecord;
    int dataSize = 0;
    while ( loc + 1 < records.size()
        && sid( records, loc ) == DrawingRecord.sid
        && isObjectRecord( records, loc + 1 ) )
    {
      dataSize += ( (DrawingRecord) records.get( loc ) ).getData().length;
      loc += 2;
    }

    // Create one big buffer
    byte buffer[] = new byte[dataSize];
    int offset = 0;
    loc = locFirstDrawingRecord;
    while ( loc + 1 < records.size()
        && sid( records, loc ) == DrawingRecord.sid
        && isObjectRecord( records, loc + 1 ) )
    {
      DrawingRecord drawingRecord = (DrawingRecord) records.get( loc );
      System.arraycopy( drawingRecord.getData(), 0, buffer, offset, drawingRecord.getData().length );
      offset += drawingRecord.getData().length;
      loc += 2;
    }

    // Decode the shapes
    //    agg.escherRecords = new ArrayList();
    int pos = 0;
    while ( pos < dataSize )
    {
      EscherRecord r = recordFactory.createRecord( buffer, pos );
      int bytesRead = r.fillFields( buffer, pos, recordFactory );
      agg.addEscherRecord( r );
      pos += bytesRead;
    }
View Full Code Here

    protected void convertRawBytesToEscherRecords() {
      convertToEscherRecords(0, rawData.length, rawData);
    }
    private void convertToEscherRecords( int offset, int size, byte[] data )
    {
        EscherRecordFactory recordFactory = new DefaultEscherRecordFactory();
        int pos = offset;
        while ( pos < offset + size )
        {
            EscherRecord r = recordFactory.createRecord(data, pos);
            int bytesRead = r.fillFields(data, pos, recordFactory );
            escherRecords.add(r);
            pos += bytesRead;
        }
    }
View Full Code Here

  public static EscherAggregate createAggregate( List records, int locFirstDrawingRecord, DrawingManager2 drawingManager )
  {
    // Keep track of any shape records created so we can match them back to the object id's.
    // Textbox objects are also treated as shape objects.
    final List<EscherRecord> shapeRecords = new ArrayList<EscherRecord>();
    EscherRecordFactory recordFactory = new DefaultEscherRecordFactory()
    {
      public EscherRecord createRecord( byte[] data, int offset )
      {
        EscherRecord r = super.createRecord( data, offset );
        if ( r.getRecordId() == EscherClientDataRecord.RECORD_ID || r.getRecordId() == EscherTextboxRecord.RECORD_ID )
        {
          shapeRecords.add( r );
        }
        return r;
      }
    };

    // Calculate the size of the buffer
    EscherAggregate agg = new EscherAggregate(drawingManager);
    int loc = locFirstDrawingRecord;
    int dataSize = 0;
    while ( loc + 1 < records.size()
        && sid( records, loc ) == DrawingRecord.sid
        && isObjectRecord( records, loc + 1 ) )
    {
      dataSize += ( (DrawingRecord) records.get( loc ) ).getData().length;
      loc += 2;
    }

    // Create one big buffer
    byte buffer[] = new byte[dataSize];
    int offset = 0;
    loc = locFirstDrawingRecord;
    while ( loc + 1 < records.size()
        && sid( records, loc ) == DrawingRecord.sid
        && isObjectRecord( records, loc + 1 ) )
    {
      DrawingRecord drawingRecord = (DrawingRecord) records.get( loc );
      System.arraycopy( drawingRecord.getData(), 0, buffer, offset, drawingRecord.getData().length );
      offset += drawingRecord.getData().length;
      loc += 2;
    }

    // Decode the shapes
    //    agg.escherRecords = new ArrayList();
    int pos = 0;
    while ( pos < dataSize )
    {
      EscherRecord r = recordFactory.createRecord( buffer, pos );
      int bytesRead = r.fillFields( buffer, pos, recordFactory );
      agg.addEscherRecord( r );
      pos += bytesRead;
    }
View Full Code Here

      convertToEscherRecords(0, rawData.length, rawData);
    }
    private void convertToEscherRecords( int offset, int size, byte[] data )
    {
         escherRecords.clear();
        EscherRecordFactory recordFactory = new DefaultEscherRecordFactory();
        int pos = offset;
        while ( pos < offset + size )
        {
            EscherRecord r = recordFactory.createRecord(data, pos);
            int bytesRead = r.fillFields(data, pos, recordFactory );
            escherRecords.add(r);
            pos += bytesRead;
        }
    }
View Full Code Here

    // Get the contents for now
    final byte[] contents = new byte[len];
    System.arraycopy(source,start,contents,0,len);

    // Build up a tree of Escher records contained within
    final DefaultEscherRecordFactory erf = new DefaultEscherRecordFactory();
    final List<EscherRecord> escherChildren = new ArrayList<EscherRecord>();
    findEscherChildren(erf, contents, 8, len-8, escherChildren);
    this.childRecords = (EscherRecord[]) escherChildren.toArray(new EscherRecord[escherChildren.size()]);

    if (1 == this.childRecords.length && (short)0xf002 == this.childRecords[0].getRecordId() && this.childRecords[0] instanceof EscherContainerRecord) {
View Full Code Here

                " 00 00 00 00 00 05 00 00 00 01 00 00 00 0B 00 00 " +
                " 00 0F 00 66 00 00 00 11 F0 00 00 00 00 ";
        byte[] buffer = HexRead.readFromString(hex);

        List<EscherRecord> records = new ArrayList<EscherRecord>();
        EscherRecordFactory recordFactory = new DefaultEscherRecordFactory();
        int pos = 0;
        while (pos < buffer.length) {
            EscherRecord r = recordFactory.createRecord(buffer, pos);
            int bytesRead = r.fillFields(buffer, pos, recordFactory);
            records.add(r);
            pos += bytesRead;
        }
        assertEquals("data was not fully read", buffer.length, pos);
View Full Code Here

TOP

Related Classes of org.apache.poi.ddf.DefaultEscherRecordFactory

Copyright © 2018 www.massapicom. 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.