Package org.apache.poi.ddf

Examples of org.apache.poi.ddf.EscherRecord


     *  children (and most top level escher holders do),
     *  then return that.
     */
    public EscherContainerRecord getEscherContainer() {
      for(Iterator<EscherRecord> it = escherRecords.iterator(); it.hasNext();) {
        EscherRecord er = it.next();
        if(er instanceof EscherContainerRecord) {
          return (EscherContainerRecord)er;
        }
      }
      return null;
View Full Code Here


      return findFirstWithId(id, getEscherRecords());
    }
    private EscherRecord findFirstWithId(short id, List<EscherRecord> records) {
      // Check at our level
      for(Iterator<EscherRecord> it = records.iterator(); it.hasNext();) {
        EscherRecord r = it.next();
        if(r.getRecordId() == id) {
          return r;
        }
      }

      // Then check our children in turn
      for(Iterator<EscherRecord> it = records.iterator(); it.hasNext();) {
        EscherRecord r = it.next();
        if(r.isContainerRecord()) {
          EscherRecord found = findFirstWithId(id, r.getChildRecords());
          if(found != null) {
            return found;
          }
        }
      }
View Full Code Here

                }

                EscherDggRecord dgg = null;
                EscherContainerRecord bStore = null;
                for(Iterator<EscherRecord> it = cr.getChildIterator(); it.hasNext();) {
                    EscherRecord er = it.next();
                    if(er instanceof EscherDggRecord) {
                        dgg = (EscherDggRecord)er;
                    } else if (er.getRecordId() == EscherContainerRecord.BSTORE_CONTAINER) {
                        bStore = (EscherContainerRecord) er;
                    }
                }

                if(dgg != null) {
                    drawingManager = new DrawingManager2(dgg);
                    if(bStore != null){
                        for(EscherRecord bs : bStore.getChildRecords()){
                            if(bs instanceof EscherBSERecord) escherBSERecords.add((EscherBSERecord)bs);
                        }
                    }
                    return drawingManager;
                }
            }
        }

        // Look for the DrawingGroup record
        int dgLoc = findFirstRecordLocBySid(DrawingGroupRecord.sid);

        // If there is one, does it have a EscherDggRecord?
        if(dgLoc != -1) {
            DrawingGroupRecord dg = (DrawingGroupRecord)records.get(dgLoc);
            EscherDggRecord dgg = null;
            EscherContainerRecord bStore = null;
            for(EscherRecord er : dg.getEscherRecords()) {
                if (er instanceof EscherDggRecord) {
                    dgg = (EscherDggRecord) er;
                } else if (er.getRecordId() == EscherContainerRecord.BSTORE_CONTAINER) {
                    bStore = (EscherContainerRecord) er;
                }
            }

            if(dgg != null) {
View Full Code Here

    final EscherContainerRecord SpgrContainer = findFirstEscherContainerRecordOfType((short)0xf003, escherContainerF002);
    final EscherContainerRecord[] escherContainersF004 = findAllEscherContainerRecordOfType((short)0xf004, SpgrContainer);
    for (EscherContainerRecord spContainer : escherContainersF004) {
      StyleTextProp9Atom nineAtom = findInSpContainer(spContainer);
      EscherSpRecord sp = null;
      final EscherRecord escherContainerF00A = findFirstEscherRecordOfType((short)0xf00a, spContainer);
      if (null != escherContainerF00A) {
        if (escherContainerF00A instanceof EscherSpRecord) {
          sp = (EscherSpRecord) escherContainerF00A;
        }
      }
      final EscherRecord escherContainerF00D = findFirstEscherRecordOfType((short)0xf00d, spContainer);
      if (null == escherContainerF00D) { continue; }
      if (escherContainerF00D instanceof EscherTextboxRecord) {
        EscherTextboxRecord tbr = (EscherTextboxRecord) escherContainerF00D;
        EscherTextboxWrapper w = new EscherTextboxWrapper(tbr);
        w.setStyleTextProp9Atom(nineAtom);
View Full Code Here

  private void findEscherChildren(DefaultEscherRecordFactory erf, byte[] source, int startPos, int lenToGo, List<EscherRecord> found) {

    int escherBytes = LittleEndian.getInt( source, startPos + 4 ) + 8;

    // Find the record
    EscherRecord r = erf.createRecord(source,startPos);
    // Fill it in
    r.fillFields( source, startPos, erf );
    // Save it
    found.add(r);

    // Wind on
    int size = r.getRecordSize();
    if(size < 8) {
      logger.log(POILogger.WARN, "Hit short DDF record at " + startPos + " - " + size);
    }

    /**
     * Sanity check. Always advance the cursor by the correct value.
     *
     * getRecordSize() must return exactly the same number of bytes that was written in fillFields.
     * Sometimes it is not so, see an example in bug #44770. Most likely reason is that one of ddf records calculates wrong size.
     */
    if(size != escherBytes){
      logger.log(POILogger.WARN, "Record length=" + escherBytes + " but getRecordSize() returned " + r.getRecordSize() + "; record: " + r.getClass());
      size = escherBytes;
    }
    startPos += size;
    lenToGo -= size;
    if(lenToGo >= 8) {
View Full Code Here

            return null;
        }

        EscherContainerRecord spContainer = shape.getSpContainer();
        for (Iterator<EscherRecord> it = spContainer.getChildIterator(); it.hasNext(); ) {
            EscherRecord obj = it.next();
            if (obj.getRecordId() ==  EscherClientDataRecord.RECORD_ID){
                byte[] data = obj.serialize();
                Record[] records = Record.findChildRecords(data, 8, data.length-8);
                if(records != null) find(records, exobj, lst);
            }
        }
View Full Code Here

   */
  public EscherDgRecord getEscherDgRecord(){
    if(dg == null){
      EscherContainerRecord dgContainer = (EscherContainerRecord)childRecords[0];
      for(Iterator<EscherRecord> it = dgContainer.getChildIterator(); it.hasNext();){
        EscherRecord r = it.next();
        if(r instanceof EscherDgRecord){
          dg = (EscherDgRecord)r;
          break;
        }
      }
View Full Code Here

        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);

        // serialize to byte array
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        try {
            for(EscherRecord r : records) out.write(r.serialize());
        } catch (IOException e){
            throw new RuntimeException(e);
        }
        assertEquals(HexDump.toHex(buffer, 10), HexDump.toHex(out.toByteArray(), 10));
    }
View Full Code Here

        return createSimpeShape(spContainer, parent);
    }

    public static ShapeGroup createShapeGroup(EscherContainerRecord spContainer, Shape parent){
        ShapeGroup group = null;
        EscherRecord opt = Shape.getEscherChild((EscherContainerRecord)spContainer.getChild(0), (short)0xF122);
        if(opt != null){
            try {
                EscherPropertyFactory f = new EscherPropertyFactory();
                List props = f.createProperties( opt.serialize(), 8, opt.getInstance() );
                EscherSimpleProperty p = (EscherSimpleProperty)props.get(0);
                if(p.getPropertyNumber() == 0x39F && p.getPropertyValue() == 1){
                    group = new Table(spContainer, parent);
                } else {
                    group = new ShapeGroup(spContainer, parent);
View Full Code Here

    }

    protected static Record getClientDataRecord(EscherContainerRecord spContainer, int recordType) {
        Record oep = null;
        for (Iterator<EscherRecord> it = spContainer.getChildIterator(); it.hasNext();) {
            EscherRecord obj = it.next();
            if (obj.getRecordId() == EscherClientDataRecord.RECORD_ID) {
                byte[] data = obj.serialize();
                Record[] records = Record.findChildRecords(data, 8, data.length - 8);
                for (int j = 0; j < records.length; j++) {
                    if (records[j].getRecordType() == recordType) {
                        return records[j];
                    }
View Full Code Here

TOP

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

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.