Examples of SlidePersistAtom


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

      }

      // Grab the SlidePersistAtom with the highest Slide Number.
      // (Will stay as null if no SlidePersistAtom exists yet in
      //  the slide, or only master slide's ones do)
      SlidePersistAtom prev = null;
      for(int i=0; i<slwts.length; i++) {
        SlideAtomsSet[] sas = slwts[i].getSlideAtomsSets();
        for(int j=0; j<sas.length; j++) {
          SlidePersistAtom spa = sas[j].getSlidePersistAtom();
          if(spa.getSlideIdentifier() < 0) {
            // This is for a master slide
          } else {
            // Must be for a real slide
              if(prev == null) { prev = spa; }
              if(prev.getSlideIdentifier() < spa.getSlideIdentifier()) {
                prev = spa;
              }
          }
        }
      }
     
      // Set up a new  SlidePersistAtom for this slide
      SlidePersistAtom sp = new SlidePersistAtom();

      // Reference is the 1-based index of the slide container in
      //  the PersistPtr root.
      // It always starts with 3 (1 is Document, 2 is MainMaster, 3 is
      //  the first slide), but quicksaves etc can leave gaps
      _highestSheetId++;
      sp.setRefID(_highestSheetId);
      // First slideId is always 256
      sp.setSlideIdentifier(prev == null ? 256 : (prev.getSlideIdentifier() + 1));
     
      // Add this new SlidePersistAtom to the SlideListWithText
      slist.addSlidePersistAtom(sp);
     
     
      // Create a new Slide
      Slide slide = new Slide(sp.getSlideIdentifier(), sp.getRefID(), _slides.length+1);
      // Add in to the list of Slides
      Slide[] s = new Slide[_slides.length+1];
      System.arraycopy(_slides, 0, s, 0, _slides.length);
      s[_slides.length] = slide;
      _slides = s;
      System.out.println("Added slide " + _slides.length + " with ref " + sp.getRefID() + " and identifier " + sp.getSlideIdentifier());
     
      // Add the core records for this new Slide to the record tree
      org.apache.poi.hslf.record.Slide slideRecord = slide.getSlideRecord();
      slideRecord.setSheetId(sp.getRefID());
      int slideRecordPos = _hslfSlideShow.appendRootLevelRecord(slideRecord);
      _records = _hslfSlideShow.getRecords();

      // Add the new Slide into the PersistPtr stuff
      int offset = 0;
      int slideOffset = 0;
      PersistPtrHolder ptr = null;
      UserEditAtom usr = null;
      for (int i = 0; i < _records.length; i++) {
        Record record = _records[i];
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        record.writeOut(out);
       
        // Grab interesting records as they come past
        if(_records[i].getRecordType() == RecordTypes.PersistPtrIncrementalBlock.typeID){
          ptr = (PersistPtrHolder)_records[i];
        }
        if(_records[i].getRecordType() == RecordTypes.UserEditAtom.typeID) {
          usr = (UserEditAtom)_records[i];
        }
       
        if(i == slideRecordPos) {
          slideOffset = offset;
        }
        offset += out.size();
      }
     
    // Add the new slide into the last PersistPtr
      // (Also need to tell it where it is)
    slideRecord.setLastOnDiskOffset(slideOffset);
    ptr.addSlideLookup(sp.getRefID(), slideOffset);
    System.out.println("New slide ended up at " + slideOffset);

    // Last view is now of the slide
      usr.setLastViewType((short)UserEditAtom.LAST_VIEW_SLIDE_VIEW);
     
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.