Package org.apache.poi.hslf.record

Examples of org.apache.poi.hslf.record.Record


          // Report the first 5 children, to give a flavour
          int upTo = 5;
          if(children.length < 5) { upTo = children.length; }
          for(int k=0; k<upTo; k++) {
            Record r = children[k];
            int typeID = (int)r.getRecordType();
            String typeName = RecordTypes.recordName(typeID);
            System.out.println("   - " + typeID + " (" + typeName + ")");
          }
        }
      }
View Full Code Here


      buf.append(printEscherContainerRecord( (EscherContainerRecord)er ));
    } else if (er instanceof EscherTextboxRecord) {
      buf.append("EscherTextboxRecord:" + nl);

      EscherTextboxWrapper etw = new EscherTextboxWrapper((EscherTextboxRecord)er);
      Record children[] = etw.getChildRecords();
      for (int j=0; j<children.length; j++) {
        if (children[j] instanceof StyleTextPropAtom) {

          // need preceding Text[Chars|Bytes]Atom to initialize the data structure
          if (j > 0 && (children[j-1] instanceof TextCharsAtom ||
View Full Code Here

  int indent = depth;
  String ind = "";
  for(int i=0; i<indent; i++) { ind += " "; }

  for(int i=0; i<records.length; i++) {
    Record r = records[i];
    if (r == null) {
      System.out.println(ind + "At position " + pos + " (" + makeHex(pos,6) + "):");
      System.out.println(ind + "Warning! Null record found.");
      continue;
    }

    // Figure out how big it is
    int len = getDiskLen(r);

    // Grab the type as hex
    String hexType = makeHex((int)r.getRecordType(),4);
    String rHexType = reverseHex(hexType);

    // Grab the hslf.record type
    Class c = r.getClass();
    String cname = c.toString();
    if(cname.startsWith("class ")) {
      cname = cname.substring(6);
    }
    if(cname.startsWith("org.apache.poi.hslf.record.")) {
      cname = cname.substring(27);
    }

    // Display the record
    System.out.println(ind + "At position " + pos + " (" + makeHex(pos,6) + "):");
    System.out.println(ind + " Record is of type " + cname);
    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) {
      String recData = getPrintableRecordContents(r);
      System.out.println(ind + recData );
    }

    System.out.println();

    // If it has children, show them
    if(r.getChildRecords() != null) {
      walkTree((depth+3),pos+8,r.getChildRecords());
    }

    // Wind on the position marker
    pos += len;
  }
View Full Code Here

        throw new CorruptPowerPointFileException("The CurrentUserAtom claims that the offset of last edit details are past the end of the file");
      }

      // Grab the details of the UserEditAtom there
      // If the record's messed up, we could AIOOB
      Record r = null;
      try {
        r = Record.buildRecordAtOffset(
            hss.getUnderlyingBytes(),
            (int)cua.getCurrentEditOffset()
        );
      } catch (ArrayIndexOutOfBoundsException e) {
        return null;
      }
      if(r == null) { return null; }
      if(! (r instanceof UserEditAtom)) { return null; }
      UserEditAtom uea = (UserEditAtom)r;

      // Now get the PersistPtrHolder
      Record r2 = Record.buildRecordAtOffset(
          hss.getUnderlyingBytes(),
          uea.getPersistPointersOffset()
      );
      if(! (r2 instanceof PersistPtrHolder)) { return null; }
      PersistPtrHolder pph = (PersistPtrHolder)r2;

      // Now get the last record
      int[] slideIds = pph.getKnownSlideIDs();
      int maxSlideId = -1;
      for(int i=0; i<slideIds.length; i++) {
        if(slideIds[i] > maxSlideId) { maxSlideId = slideIds[i]; }
      }
      if(maxSlideId == -1) { return null; }

      int offset = (
          (Integer)pph.getSlideLocationsLookup().get(
              Integer.valueOf(maxSlideId)
          ) ).intValue();
      Record r3 = Record.buildRecordAtOffset(
          hss.getUnderlyingBytes(),
          offset
      );

      // If we have a DocumentEncryptionAtom, it'll be this one
View Full Code Here

        throw new CorruptPowerPointFileException("The CurrentUserAtom claims that the offset of last edit details are past the end of the file");
      }

      // Grab the details of the UserEditAtom there
      // If the record's messed up, we could AIOOB
      Record r = null;
      try {
        r = Record.buildRecordAtOffset(
            hss.getUnderlyingBytes(),
            (int)cua.getCurrentEditOffset()
        );
      } catch (ArrayIndexOutOfBoundsException e) {
        return null;
      }
      if(r == null) { return null; }
      if(! (r instanceof UserEditAtom)) { return null; }
      UserEditAtom uea = (UserEditAtom)r;

      // Now get the PersistPtrHolder
      Record r2 = Record.buildRecordAtOffset(
          hss.getUnderlyingBytes(),
          uea.getPersistPointersOffset()
      );
      if(! (r2 instanceof PersistPtrHolder)) { return null; }
      PersistPtrHolder pph = (PersistPtrHolder)r2;

      // Now get the last record
      int[] slideIds = pph.getKnownSlideIDs();
      int maxSlideId = -1;
      for(int i=0; i<slideIds.length; i++) {
        if(slideIds[i] > maxSlideId) { maxSlideId = slideIds[i]; }
      }
      if(maxSlideId == -1) { return null; }

      int offset = (
          (Integer)pph.getSlideLocationsLookup().get(
              Integer.valueOf(maxSlideId)
          ) ).intValue();
      Record r3 = Record.buildRecordAtOffset(
          hss.getUnderlyingBytes(),
          offset
      );

      // If we have a DocumentEncryptionAtom, it'll be this one
View Full Code Here

        //grab UserEditAtom
        UserEditAtom usredit = null;
        Record[] _records = hss_empty.getRecords();
        for (int i = 0; i < _records.length; i++) {
            Record record = _records[i];
            if(record.getRecordType() == RecordTypes.UserEditAtom.typeID) {
                usredit = (UserEditAtom)record;
            }
       }
       assertNotNull(usredit);
View Full Code Here

  public void testAddSlideToExisting2() throws Exception {
        //grab UserEditAtom
        UserEditAtom usredit = null;
        Record[] _records = hss_two.getRecords();
        for (int i = 0; i < _records.length; i++) {
            Record record = _records[i];
            if(_records[i].getRecordType() == RecordTypes.UserEditAtom.typeID) {
                usredit = (UserEditAtom)_records[i];
            }
       }
       assertNotNull(usredit);
View Full Code Here

      buf.append(printEscherContainerRecord( (EscherContainerRecord)er ));
    } else if (er instanceof EscherTextboxRecord) {
      buf.append("EscherTextboxRecord:" + nl);
     
      EscherTextboxWrapper etw = new EscherTextboxWrapper((EscherTextboxRecord)er);
      Record children[] = etw.getChildRecords();
      for (int j=0; j<children.length; j++) {
        if (children[j] instanceof StyleTextPropAtom) {
         
          // need preceding Text[Chars|Bytes]Atom to initialize the data structure
          if (j > 0 && (children[j-1] instanceof TextCharsAtom ||
View Full Code Here

  int indent = depth;
  String ind = "";
  for(int i=0; i<indent; i++) { ind += " "; }

  for(int i=0; i<records.length; i++) {
    Record r = records[i];
    if (r == null) {
      System.out.println(ind + "At position " + pos + " (" + makeHex(pos,6) + "):");
      System.out.println(ind + "Warning! Null record found.");
      continue;
    }

    // Figure out how big it is
    int len = getDiskLen(r);
   
    // Grab the type as hex
    String hexType = makeHex((int)r.getRecordType(),4);
    String rHexType = reverseHex(hexType);

    // Grab the hslf.record type
    Class c = r.getClass();
    String cname = c.toString();
    if(cname.startsWith("class ")) {
      cname = cname.substring(6);
    }
    if(cname.startsWith("org.apache.poi.hslf.record.")) {
      cname = cname.substring(27);
    }

    // Display the record
    System.out.println(ind + "At position " + pos + " (" + makeHex(pos,6) + "):");
    System.out.println(ind + " Record is of type " + cname);
    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) {
      String recData = getPrintableRecordContents(r);
      System.out.println(ind + recData );
    }

    System.out.println();

    // If it has children, show them
    if(r.getChildRecords() != null) {
      walkTree((depth+3),pos+8,r.getChildRecords());
    }

    // Wind on the position marker
    pos += len;
  }
View Full Code Here

      buf.append(printEscherContainerRecord( (EscherContainerRecord)er ));
    } else if (er instanceof EscherTextboxRecord) {
      buf.append("EscherTextboxRecord:" + nl);
     
      EscherTextboxWrapper etw = new EscherTextboxWrapper((EscherTextboxRecord)er);
      Record children[] = etw.getChildRecords();
      for (int j=0; j<children.length; j++) {
        if (children[j] instanceof StyleTextPropAtom) {
         
          // need preceding Text[Chars|Bytes]Atom to initialize the data structure
          if (j > 0 && (children[j-1] instanceof TextCharsAtom ||
View Full Code Here

TOP

Related Classes of org.apache.poi.hslf.record.Record

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.