/** * Find all sound records in the supplied Document records * * @param document the document to find in * @return the array with the sound data */ public static SoundData[] find(Document document){ ArrayList<SoundData> lst = new ArrayList<SoundData>(); Record[] ch = document.getChildRecords(); for (int i = 0; i < ch.length; i++) { if(ch[i].getRecordType() == RecordTypes.SoundCollection.typeID){ RecordContainer col = (RecordContainer)ch[i]; Record[] sr = col.getChildRecords(); for (int j = 0; j < sr.length; j++) { if(sr[j] instanceof Sound){ lst.add(new SoundData((Sound)sr[j])); } } } } return lst.toArray(new SoundData[lst.size()]); } }
/** * Find all sound records in the supplied Document records * * @param document the document to find in * @return the array with the sound data */ public static HSLFSoundData[] find(Document document){ ArrayList<HSLFSoundData> lst = new ArrayList<>(); Record[] ch = document.getChildRecords(); for (int i = 0; i < ch.length; i++) { if(ch[i].getRecordType() == RecordTypes.SoundCollection.typeID){ RecordContainer col = (RecordContainer)ch[i]; Record[] sr = col.getChildRecords(); for (int j = 0; j < sr.length; j++) { if(sr[j] instanceof Sound){ lst.add(new HSLFSoundData((Sound)sr[j])); } } } } return lst.toArray(new HSLFSoundData[lst.size()]); } }
/** * Attach this HeadersFootersContainer to the parent Document record */ private void attach(){ Document doc = _ppt.getDocumentRecord(); Record[] ch = doc.getChildRecords(); Record lst = null; for (int i=0; i < ch.length; i++){ if(ch[i].getRecordType() == RecordTypes.List.typeID){ lst = ch[i]; break; } } doc.addChildAfter(_container, lst); _newRecord = false; }
/** * Return Header / Footer settings for slides * * @return Header / Footer settings for slides */ public HeadersFooters getSlideHeadersFooters() { // detect if this ppt was saved in Office2007 String tag = getSlidesMasters()[0].getProgrammableTag(); boolean ppt2007 = "___PPT12".equals(tag); HeadersFootersContainer hdd = null; Record[] ch = _documentRecord.getChildRecords(); for (int i = 0; i < ch.length; i++) { if (ch[i] instanceof HeadersFootersContainer && ((HeadersFootersContainer) ch[i]).getOptions() == HeadersFootersContainer.SlideHeadersFootersContainer) { hdd = (HeadersFootersContainer) ch[i]; break; } } boolean newRecord = false; if (hdd == null) { hdd = new HeadersFootersContainer(HeadersFootersContainer.SlideHeadersFootersContainer); newRecord = true; } return new HeadersFooters(hdd, this, newRecord, ppt2007); }
/** * Return Header / Footer settings for notes * * @return Header / Footer settings for notes */ public HeadersFooters getNotesHeadersFooters() { // detect if this ppt was saved in Office2007 String tag = getSlidesMasters()[0].getProgrammableTag(); boolean ppt2007 = "___PPT12".equals(tag); HeadersFootersContainer hdd = null; Record[] ch = _documentRecord.getChildRecords(); for (int i = 0; i < ch.length; i++) { if (ch[i] instanceof HeadersFootersContainer && ((HeadersFootersContainer) ch[i]).getOptions() == HeadersFootersContainer.NotesHeadersFootersContainer) { hdd = (HeadersFootersContainer) ch[i]; break; } } boolean newRecord = false; if (hdd == null) { hdd = new HeadersFootersContainer(HeadersFootersContainer.NotesHeadersFootersContainer); newRecord = true; } if (ppt2007 && _notes.length > 0) { return new HeadersFooters(hdd, _notes[0], newRecord, ppt2007); } return new HeadersFooters(hdd, this, newRecord, ppt2007); }
public HeadersFooters(HSLFSheet sheet, short headerFooterType) { _sheet = sheet; @SuppressWarnings("resource") HSLFSlideShow ppt = _sheet.getSlideShow(); Document doc = ppt.getDocumentRecord(); // detect if this ppt was saved in Office2007 String tag = ppt.getSlideMasters().get(0).getProgrammableTag(); _ppt2007 = _ppt2007tag.equals(tag); SheetContainer sc = _sheet.getSheetContainer(); HeadersFootersContainer hdd = (HeadersFootersContainer)sc.findFirstOfType(RecordTypes.HeadersFooters.typeID); // boolean ppt2007 = sc.findFirstOfType(RecordTypes.RoundTripContentMasterId.typeID) != null; if (hdd == null) { for (Record ch : doc.getChildRecords()) { if (ch instanceof HeadersFootersContainer && ((HeadersFootersContainer) ch).getOptions() == headerFooterType) { hdd = (HeadersFootersContainer) ch; break; } } } if (hdd == null) { hdd = new HeadersFootersContainer(headerFooterType); Record lst = doc.findFirstOfType(RecordTypes.List.typeID); doc.addChildAfter(hdd, lst); } _container = hdd; }