Lines 25-31
Link Here
|
25 |
import java.io.IOException; |
25 |
import java.io.IOException; |
26 |
import java.io.InputStream; |
26 |
import java.io.InputStream; |
27 |
import java.io.OutputStream; |
27 |
import java.io.OutputStream; |
28 |
import java.util.*; |
28 |
import java.util.ArrayList; |
|
|
29 |
import java.util.Arrays; |
30 |
import java.util.HashMap; |
31 |
import java.util.Iterator; |
32 |
import java.util.List; |
33 |
import java.util.Map; |
29 |
|
34 |
|
30 |
import org.apache.poi.ddf.EscherBSERecord; |
35 |
import org.apache.poi.ddf.EscherBSERecord; |
31 |
import org.apache.poi.ddf.EscherContainerRecord; |
36 |
import org.apache.poi.ddf.EscherContainerRecord; |
Lines 35-45
Link Here
|
35 |
import org.apache.poi.hslf.HSLFSlideShow; |
40 |
import org.apache.poi.hslf.HSLFSlideShow; |
36 |
import org.apache.poi.hslf.exceptions.CorruptPowerPointFileException; |
41 |
import org.apache.poi.hslf.exceptions.CorruptPowerPointFileException; |
37 |
import org.apache.poi.hslf.exceptions.HSLFException; |
42 |
import org.apache.poi.hslf.exceptions.HSLFException; |
38 |
import org.apache.poi.hslf.model.*; |
43 |
import org.apache.poi.hslf.model.HeadersFooters; |
|
|
44 |
import org.apache.poi.hslf.model.Hyperlink; |
45 |
import org.apache.poi.hslf.model.MovieShape; |
39 |
import org.apache.poi.hslf.model.Notes; |
46 |
import org.apache.poi.hslf.model.Notes; |
|
|
47 |
import org.apache.poi.hslf.model.PPFont; |
48 |
import org.apache.poi.hslf.model.Picture; |
49 |
import org.apache.poi.hslf.model.Shape; |
40 |
import org.apache.poi.hslf.model.Slide; |
50 |
import org.apache.poi.hslf.model.Slide; |
41 |
import org.apache.poi.hslf.record.*; |
51 |
import org.apache.poi.hslf.model.SlideMaster; |
|
|
52 |
import org.apache.poi.hslf.model.TitleMaster; |
53 |
import org.apache.poi.hslf.record.Document; |
54 |
import org.apache.poi.hslf.record.DocumentAtom; |
55 |
import org.apache.poi.hslf.record.ExAviMovie; |
56 |
import org.apache.poi.hslf.record.ExControl; |
57 |
import org.apache.poi.hslf.record.ExEmbed; |
58 |
import org.apache.poi.hslf.record.ExEmbedAtom; |
59 |
import org.apache.poi.hslf.record.ExHyperlink; |
60 |
import org.apache.poi.hslf.record.ExHyperlinkAtom; |
61 |
import org.apache.poi.hslf.record.ExMCIMovie; |
62 |
import org.apache.poi.hslf.record.ExObjList; |
63 |
import org.apache.poi.hslf.record.ExObjListAtom; |
64 |
import org.apache.poi.hslf.record.ExOleObjAtom; |
65 |
import org.apache.poi.hslf.record.ExOleObjStg; |
66 |
import org.apache.poi.hslf.record.ExVideoContainer; |
67 |
import org.apache.poi.hslf.record.FontCollection; |
68 |
import org.apache.poi.hslf.record.FontEntityAtom; |
69 |
import org.apache.poi.hslf.record.HeadersFootersContainer; |
70 |
import org.apache.poi.hslf.record.PersistPtrHolder; |
71 |
import org.apache.poi.hslf.record.PositionDependentRecord; |
72 |
import org.apache.poi.hslf.record.PositionDependentRecordContainer; |
73 |
import org.apache.poi.hslf.record.Record; |
74 |
import org.apache.poi.hslf.record.RecordContainer; |
75 |
import org.apache.poi.hslf.record.RecordTypes; |
76 |
import org.apache.poi.hslf.record.SlideListWithText; |
42 |
import org.apache.poi.hslf.record.SlideListWithText.SlideAtomsSet; |
77 |
import org.apache.poi.hslf.record.SlideListWithText.SlideAtomsSet; |
|
|
78 |
import org.apache.poi.hslf.record.SlidePersistAtom; |
79 |
import org.apache.poi.hslf.record.UserEditAtom; |
43 |
import org.apache.poi.poifs.filesystem.DirectoryNode; |
80 |
import org.apache.poi.poifs.filesystem.DirectoryNode; |
44 |
import org.apache.poi.poifs.filesystem.POIFSFileSystem; |
81 |
import org.apache.poi.poifs.filesystem.POIFSFileSystem; |
45 |
import org.apache.poi.util.POILogFactory; |
82 |
import org.apache.poi.util.POILogFactory; |
Lines 58-72
Link Here
|
58 |
// What we're based on |
95 |
// What we're based on |
59 |
private HSLFSlideShow _hslfSlideShow; |
96 |
private HSLFSlideShow _hslfSlideShow; |
60 |
|
97 |
|
61 |
// Low level contents, as taken from HSLFSlideShow |
|
|
62 |
private Record[] _records; |
63 |
|
64 |
// Pointers to the most recent versions of the core records |
98 |
// Pointers to the most recent versions of the core records |
65 |
// (Document, Notes, Slide etc) |
99 |
// (Document, Notes, Slide etc) |
66 |
private Record[] _mostRecentCoreRecords; |
100 |
private Record[] _mostRecentCoreRecords; |
67 |
// Lookup between the PersitPtr "sheet" IDs, and the position |
101 |
// Lookup between the PersitPtr "sheet" IDs, and the position |
68 |
// in the mostRecentCoreRecords array |
102 |
// in the mostRecentCoreRecords array |
69 |
private Hashtable<Integer,Integer> _sheetIdToCoreRecordsLookup; |
103 |
private Map<Integer,Integer> _sheetIdToCoreRecordsLookup; |
70 |
|
104 |
|
71 |
// Records that are interesting |
105 |
// Records that are interesting |
72 |
private Document _documentRecord; |
106 |
private Document _documentRecord; |
Lines 97-106
Link Here
|
97 |
public SlideShow(HSLFSlideShow hslfSlideShow) { |
131 |
public SlideShow(HSLFSlideShow hslfSlideShow) { |
98 |
// Get useful things from our base slideshow |
132 |
// Get useful things from our base slideshow |
99 |
_hslfSlideShow = hslfSlideShow; |
133 |
_hslfSlideShow = hslfSlideShow; |
100 |
_records = _hslfSlideShow.getRecords(); |
|
|
101 |
|
134 |
|
102 |
// Handle Parent-aware Records |
135 |
// Handle Parent-aware Records |
103 |
for (Record record : _records) { |
136 |
for (Record record : _hslfSlideShow.getRecords()) { |
104 |
if(record instanceof RecordContainer){ |
137 |
if(record instanceof RecordContainer){ |
105 |
RecordContainer.handleParentAwareRecords((RecordContainer)record); |
138 |
RecordContainer.handleParentAwareRecords((RecordContainer)record); |
106 |
} |
139 |
} |
Lines 135-159
Link Here
|
135 |
*/ |
168 |
*/ |
136 |
private void findMostRecentCoreRecords() { |
169 |
private void findMostRecentCoreRecords() { |
137 |
// To start with, find the most recent in the byte offset domain |
170 |
// To start with, find the most recent in the byte offset domain |
138 |
Hashtable<Integer,Integer> mostRecentByBytes = new Hashtable<Integer,Integer>(); |
171 |
Map<Integer,Integer> mostRecentByBytes = new HashMap<Integer,Integer>(); |
139 |
for (int i = 0; i < _records.length; i++) { |
172 |
for (Record record : _hslfSlideShow.getRecords()) { |
140 |
if (_records[i] instanceof PersistPtrHolder) { |
173 |
if (record instanceof PersistPtrHolder) { |
141 |
PersistPtrHolder pph = (PersistPtrHolder) _records[i]; |
174 |
PersistPtrHolder pph = (PersistPtrHolder) record; |
142 |
|
175 |
|
143 |
// If we've already seen any of the "slide" IDs for this |
176 |
// If we've already seen any of the "slide" IDs for this |
144 |
// PersistPtr, remove their old positions |
177 |
// PersistPtr, remove their old positions |
145 |
int[] ids = pph.getKnownSlideIDs(); |
178 |
int[] ids = pph.getKnownSlideIDs(); |
146 |
for (int j = 0; j < ids.length; j++) { |
179 |
for (int id : ids) { |
147 |
Integer id = Integer.valueOf(ids[j]); |
|
|
148 |
if (mostRecentByBytes.containsKey(id)) { |
180 |
if (mostRecentByBytes.containsKey(id)) { |
149 |
mostRecentByBytes.remove(id); |
181 |
mostRecentByBytes.remove(id); |
150 |
} |
182 |
} |
151 |
} |
183 |
} |
152 |
|
184 |
|
153 |
// Now, update the byte level locations with their latest values |
185 |
// Now, update the byte level locations with their latest values |
154 |
Hashtable<Integer,Integer> thisSetOfLocations = pph.getSlideLocationsLookup(); |
186 |
Map<Integer,Integer> thisSetOfLocations = pph.getSlideLocationsLookup(); |
155 |
for (int j = 0; j < ids.length; j++) { |
187 |
for (int id : ids) { |
156 |
Integer id = Integer.valueOf(ids[j]); |
|
|
157 |
mostRecentByBytes.put(id, thisSetOfLocations.get(id)); |
188 |
mostRecentByBytes.put(id, thisSetOfLocations.get(id)); |
158 |
} |
189 |
} |
159 |
} |
190 |
} |
Lines 165-218
Link Here
|
165 |
|
196 |
|
166 |
// We'll also want to be able to turn the slide IDs into a position |
197 |
// We'll also want to be able to turn the slide IDs into a position |
167 |
// in this array |
198 |
// in this array |
168 |
_sheetIdToCoreRecordsLookup = new Hashtable<Integer,Integer>(); |
199 |
_sheetIdToCoreRecordsLookup = new HashMap<Integer,Integer>(); |
169 |
int[] allIDs = new int[_mostRecentCoreRecords.length]; |
200 |
Integer[] allIDs = mostRecentByBytes.keySet().toArray(new Integer[mostRecentByBytes.size()]); |
170 |
Enumeration<Integer> ids = mostRecentByBytes.keys(); |
|
|
171 |
for (int i = 0; i < allIDs.length; i++) { |
172 |
Integer id = ids.nextElement(); |
173 |
allIDs[i] = id.intValue(); |
174 |
} |
175 |
Arrays.sort(allIDs); |
201 |
Arrays.sort(allIDs); |
176 |
for (int i = 0; i < allIDs.length; i++) { |
202 |
for (int i = 0; i < allIDs.length; i++) { |
177 |
_sheetIdToCoreRecordsLookup.put(Integer.valueOf(allIDs[i]), Integer.valueOf(i)); |
203 |
_sheetIdToCoreRecordsLookup.put(allIDs[i], i); |
178 |
} |
204 |
} |
179 |
|
205 |
|
180 |
// Now convert the byte offsets back into record offsets |
206 |
// Now convert the byte offsets back into record offsets |
181 |
for (int i = 0; i < _records.length; i++) { |
207 |
for (Record record : _hslfSlideShow.getRecords()) { |
182 |
if (_records[i] instanceof PositionDependentRecord) { |
208 |
if (record instanceof PositionDependentRecord) { |
183 |
PositionDependentRecord pdr = (PositionDependentRecord) _records[i]; |
209 |
PositionDependentRecord pdr = (PositionDependentRecord) record; |
184 |
Integer recordAt = Integer.valueOf(pdr.getLastOnDiskOffset()); |
210 |
int recordAt = pdr.getLastOnDiskOffset(); |
185 |
|
211 |
|
186 |
// Is it one we care about? |
212 |
// Is it one we care about? |
187 |
for (int j = 0; j < allIDs.length; j++) { |
213 |
for (Integer thisID : allIDs) { |
188 |
Integer thisID = Integer.valueOf(allIDs[j]); |
214 |
int thatRecordAt = mostRecentByBytes.get(thisID); |
189 |
Integer thatRecordAt = mostRecentByBytes.get(thisID); |
|
|
190 |
|
215 |
|
191 |
if (thatRecordAt.equals(recordAt)) { |
216 |
if (thatRecordAt == recordAt) { |
192 |
// Bingo. Now, where do we store it? |
217 |
// Bingo. Now, where do we store it? |
193 |
Integer storeAtI = _sheetIdToCoreRecordsLookup.get(thisID); |
218 |
Integer storeAtI = _sheetIdToCoreRecordsLookup.get(thisID); |
194 |
int storeAt = storeAtI.intValue(); |
219 |
int storeAt = storeAtI.intValue(); |
195 |
|
220 |
|
196 |
// Tell it its Sheet ID, if it cares |
221 |
// Tell it its Sheet ID, if it cares |
197 |
if (pdr instanceof PositionDependentRecordContainer) { |
222 |
if (pdr instanceof PositionDependentRecordContainer) { |
198 |
PositionDependentRecordContainer pdrc = (PositionDependentRecordContainer) _records[i]; |
223 |
PositionDependentRecordContainer pdrc = (PositionDependentRecordContainer) record; |
199 |
pdrc.setSheetId(thisID.intValue()); |
224 |
pdrc.setSheetId(thisID); |
200 |
} |
225 |
} |
201 |
|
226 |
|
202 |
// Finally, save the record |
227 |
// Finally, save the record |
203 |
_mostRecentCoreRecords[storeAt] = _records[i]; |
228 |
_mostRecentCoreRecords[storeAt] = record; |
204 |
} |
229 |
} |
205 |
} |
230 |
} |
206 |
} |
231 |
} |
207 |
} |
232 |
} |
208 |
|
233 |
|
209 |
// Now look for the interesting records in there |
234 |
// Now look for the interesting records in there |
210 |
for (int i = 0; i < _mostRecentCoreRecords.length; i++) { |
235 |
for (Record record : _mostRecentCoreRecords) { |
211 |
// Check there really is a record at this number |
236 |
// Check there really is a record at this number |
212 |
if (_mostRecentCoreRecords[i] != null) { |
237 |
if (record != null) { |
213 |
// Find the Document, and interesting things in it |
238 |
// Find the Document, and interesting things in it |
214 |
if (_mostRecentCoreRecords[i].getRecordType() == RecordTypes.Document.typeID) { |
239 |
if (record.getRecordType() == RecordTypes.Document.typeID) { |
215 |
_documentRecord = (Document) _mostRecentCoreRecords[i]; |
240 |
_documentRecord = (Document) record; |
216 |
_fonts = _documentRecord.getEnvironment().getFontCollection(); |
241 |
_fonts = _documentRecord.getEnvironment().getFontCollection(); |
217 |
} |
242 |
} |
218 |
} else { |
243 |
} else { |
Lines 296-304
Link Here
|
296 |
ArrayList<SlideMaster> mmr = new ArrayList<SlideMaster>(); |
321 |
ArrayList<SlideMaster> mmr = new ArrayList<SlideMaster>(); |
297 |
ArrayList<TitleMaster> tmr = new ArrayList<TitleMaster>(); |
322 |
ArrayList<TitleMaster> tmr = new ArrayList<TitleMaster>(); |
298 |
|
323 |
|
299 |
for (int i = 0; i < masterSets.length; i++) { |
324 |
for (SlideAtomsSet sas : masterSets) { |
300 |
Record r = getCoreRecordForSAS(masterSets[i]); |
325 |
Record r = getCoreRecordForSAS(sas); |
301 |
SlideAtomsSet sas = masterSets[i]; |
|
|
302 |
int sheetNo = sas.getSlidePersistAtom().getSlideIdentifier(); |
326 |
int sheetNo = sas.getSlidePersistAtom().getSlideIdentifier(); |
303 |
if (r instanceof org.apache.poi.hslf.record.Slide) { |
327 |
if (r instanceof org.apache.poi.hslf.record.Slide) { |
304 |
TitleMaster master = new TitleMaster((org.apache.poi.hslf.record.Slide) r, |
328 |
TitleMaster master = new TitleMaster((org.apache.poi.hslf.record.Slide) r, |
Lines 313-323
Link Here
|
313 |
} |
337 |
} |
314 |
} |
338 |
} |
315 |
|
339 |
|
316 |
_masters = new SlideMaster[mmr.size()]; |
340 |
_masters = mmr.toArray(new SlideMaster[mmr.size()]); |
317 |
mmr.toArray(_masters); |
341 |
_titleMasters = tmr.toArray(new TitleMaster[tmr.size()]); |
318 |
|
|
|
319 |
_titleMasters = new TitleMaster[tmr.size()]; |
320 |
tmr.toArray(_titleMasters); |
321 |
} |
342 |
} |
322 |
|
343 |
|
323 |
// Having sorted out the masters, that leaves the notes and slides |
344 |
// Having sorted out the masters, that leaves the notes and slides |
Lines 326-339
Link Here
|
326 |
// notesSLWT |
347 |
// notesSLWT |
327 |
org.apache.poi.hslf.record.Notes[] notesRecords; |
348 |
org.apache.poi.hslf.record.Notes[] notesRecords; |
328 |
SlideAtomsSet[] notesSets = new SlideAtomsSet[0]; |
349 |
SlideAtomsSet[] notesSets = new SlideAtomsSet[0]; |
329 |
Hashtable<Integer,Integer> slideIdToNotes = new Hashtable<Integer,Integer>(); |
350 |
Map<Integer,Integer> slideIdToNotes = new HashMap<Integer,Integer>(); |
330 |
if (notesSLWT == null) { |
351 |
if (notesSLWT == null) { |
331 |
// None |
352 |
// None |
332 |
notesRecords = new org.apache.poi.hslf.record.Notes[0]; |
353 |
notesRecords = new org.apache.poi.hslf.record.Notes[0]; |
333 |
} else { |
354 |
} else { |
334 |
// Match up the records and the SlideAtomSets |
355 |
// Match up the records and the SlideAtomSets |
335 |
notesSets = notesSLWT.getSlideAtomsSets(); |
356 |
notesSets = notesSLWT.getSlideAtomsSets(); |
336 |
ArrayList<org.apache.poi.hslf.record.Notes> notesRecordsL = |
357 |
List<org.apache.poi.hslf.record.Notes> notesRecordsL = |
337 |
new ArrayList<org.apache.poi.hslf.record.Notes>(); |
358 |
new ArrayList<org.apache.poi.hslf.record.Notes>(); |
338 |
for (int i = 0; i < notesSets.length; i++) { |
359 |
for (int i = 0; i < notesSets.length; i++) { |
339 |
// Get the right core record |
360 |
// Get the right core record |
Lines 346-353
Link Here
|
346 |
|
367 |
|
347 |
// Record the match between slide id and these notes |
368 |
// Record the match between slide id and these notes |
348 |
SlidePersistAtom spa = notesSets[i].getSlidePersistAtom(); |
369 |
SlidePersistAtom spa = notesSets[i].getSlidePersistAtom(); |
349 |
Integer slideId = Integer.valueOf(spa.getSlideIdentifier()); |
370 |
int slideId = spa.getSlideIdentifier(); |
350 |
slideIdToNotes.put(slideId, Integer.valueOf(i)); |
371 |
slideIdToNotes.put(slideId, i); |
351 |
} else { |
372 |
} else { |
352 |
logger.log(POILogger.ERROR, "A Notes SlideAtomSet at " + i |
373 |
logger.log(POILogger.ERROR, "A Notes SlideAtomSet at " + i |
353 |
+ " said its record was at refID " |
374 |
+ " said its record was at refID " |
Lines 686-694
Link Here
|
686 |
// (Will stay as null if no SlidePersistAtom exists yet in |
707 |
// (Will stay as null if no SlidePersistAtom exists yet in |
687 |
// the slide, or only master slide's ones do) |
708 |
// the slide, or only master slide's ones do) |
688 |
SlidePersistAtom prev = null; |
709 |
SlidePersistAtom prev = null; |
689 |
SlideAtomsSet[] sas = slist.getSlideAtomsSets(); |
710 |
for (SlideAtomsSet sas : slist.getSlideAtomsSets()) { |
690 |
for (int j = 0; j < sas.length; j++) { |
711 |
SlidePersistAtom spa = sas.getSlidePersistAtom(); |
691 |
SlidePersistAtom spa = sas[j].getSlidePersistAtom(); |
|
|
692 |
if (spa.getSlideIdentifier() < 0) { |
712 |
if (spa.getSlideIdentifier() < 0) { |
693 |
// This is for a master slide |
713 |
// This is for a master slide |
694 |
// Odd, since we only deal with the Slide SLWT |
714 |
// Odd, since we only deal with the Slide SLWT |
Lines 850-868
Link Here
|
850 |
* found |
870 |
* found |
851 |
*/ |
871 |
*/ |
852 |
public PPFont getFont(int idx) { |
872 |
public PPFont getFont(int idx) { |
853 |
PPFont font = null; |
|
|
854 |
FontCollection fonts = getDocumentRecord().getEnvironment().getFontCollection(); |
873 |
FontCollection fonts = getDocumentRecord().getEnvironment().getFontCollection(); |
855 |
Record[] ch = fonts.getChildRecords(); |
874 |
for (Record ch : fonts.getChildRecords()) { |
856 |
for (int i = 0; i < ch.length; i++) { |
875 |
if (ch instanceof FontEntityAtom) { |
857 |
if (ch[i] instanceof FontEntityAtom) { |
876 |
FontEntityAtom atom = (FontEntityAtom) ch; |
858 |
FontEntityAtom atom = (FontEntityAtom) ch[i]; |
|
|
859 |
if (atom.getFontIndex() == idx) { |
877 |
if (atom.getFontIndex() == idx) { |
860 |
font = new PPFont(atom); |
878 |
return new PPFont(atom); |
861 |
break; |
|
|
862 |
} |
879 |
} |
863 |
} |
880 |
} |
864 |
} |
881 |
} |
865 |
return font; |
882 |
return null; |
866 |
} |
883 |
} |
867 |
|
884 |
|
868 |
/** |
885 |
/** |
Lines 885-895
Link Here
|
885 |
boolean ppt2007 = "___PPT12".equals(tag); |
902 |
boolean ppt2007 = "___PPT12".equals(tag); |
886 |
|
903 |
|
887 |
HeadersFootersContainer hdd = null; |
904 |
HeadersFootersContainer hdd = null; |
888 |
Record[] ch = _documentRecord.getChildRecords(); |
905 |
for (Record ch : _documentRecord.getChildRecords()) { |
889 |
for (int i = 0; i < ch.length; i++) { |
906 |
if (ch instanceof HeadersFootersContainer |
890 |
if (ch[i] instanceof HeadersFootersContainer |
907 |
&& ((HeadersFootersContainer) ch).getOptions() == HeadersFootersContainer.SlideHeadersFootersContainer) { |
891 |
&& ((HeadersFootersContainer) ch[i]).getOptions() == HeadersFootersContainer.SlideHeadersFootersContainer) { |
908 |
hdd = (HeadersFootersContainer) ch; |
892 |
hdd = (HeadersFootersContainer) ch[i]; |
|
|
893 |
break; |
909 |
break; |
894 |
} |
910 |
} |
895 |
} |
911 |
} |
Lines 912-922
Link Here
|
912 |
boolean ppt2007 = "___PPT12".equals(tag); |
928 |
boolean ppt2007 = "___PPT12".equals(tag); |
913 |
|
929 |
|
914 |
HeadersFootersContainer hdd = null; |
930 |
HeadersFootersContainer hdd = null; |
915 |
Record[] ch = _documentRecord.getChildRecords(); |
931 |
for (Record ch : _documentRecord.getChildRecords()) { |
916 |
for (int i = 0; i < ch.length; i++) { |
932 |
if (ch instanceof HeadersFootersContainer |
917 |
if (ch[i] instanceof HeadersFootersContainer |
933 |
&& ((HeadersFootersContainer) ch).getOptions() == HeadersFootersContainer.NotesHeadersFootersContainer) { |
918 |
&& ((HeadersFootersContainer) ch[i]).getOptions() == HeadersFootersContainer.NotesHeadersFootersContainer) { |
934 |
hdd = (HeadersFootersContainer) ch; |
919 |
hdd = (HeadersFootersContainer) ch[i]; |
|
|
920 |
break; |
935 |
break; |
921 |
} |
936 |
} |
922 |
} |
937 |
} |
Lines 1107-1143
Link Here
|
1107 |
} |
1122 |
} |
1108 |
|
1123 |
|
1109 |
protected int addPersistentObject(PositionDependentRecord slideRecord) { |
1124 |
protected int addPersistentObject(PositionDependentRecord slideRecord) { |
1110 |
int slideRecordPos = _hslfSlideShow.appendRootLevelRecord((Record)slideRecord); |
1125 |
slideRecord.setLastOnDiskOffset(HSLFSlideShow.UNSET_OFFSET); |
1111 |
_records = _hslfSlideShow.getRecords(); |
1126 |
_hslfSlideShow.appendRootLevelRecord((Record)slideRecord); |
1112 |
|
1127 |
|
1113 |
// Add the new Slide into the PersistPtr stuff |
1128 |
// For position dependent records, hold where they were and now are |
1114 |
int offset = 0; |
1129 |
// As we go along, update, and hand over, to any Position Dependent |
1115 |
int slideOffset = 0; |
1130 |
// records we happen across |
1116 |
PersistPtrHolder ptr = null; |
1131 |
Map<RecordTypes.Type,PositionDependentRecord> interestingRecords = |
1117 |
UserEditAtom usr = null; |
1132 |
new HashMap<RecordTypes.Type,PositionDependentRecord>(); |
1118 |
int i = 0; |
|
|
1119 |
for (Record record : _records) { |
1120 |
// Grab interesting records as they come past |
1121 |
int recordType = (int)record.getRecordType(); |
1122 |
if (recordType == RecordTypes.PersistPtrIncrementalBlock.typeID) { |
1123 |
ptr = (PersistPtrHolder)record; |
1124 |
} |
1125 |
if (recordType == RecordTypes.UserEditAtom.typeID) { |
1126 |
usr = (UserEditAtom)record; |
1127 |
} |
1128 |
|
1133 |
|
1129 |
if (i++ == slideRecordPos) { |
1134 |
try { |
1130 |
slideOffset = offset; |
1135 |
_hslfSlideShow.updateAndWriteDependantRecords(null,interestingRecords); |
1131 |
} |
1136 |
} catch (IOException e) { |
1132 |
|
1137 |
throw new HSLFException(e); |
1133 |
try { |
1138 |
} |
1134 |
ByteArrayOutputStream out = new ByteArrayOutputStream(); |
1139 |
|
1135 |
record.writeOut(out); |
1140 |
PersistPtrHolder ptr = (PersistPtrHolder)interestingRecords.get(RecordTypes.PersistPtrIncrementalBlock); |
1136 |
offset += out.size(); |
1141 |
UserEditAtom usr = (UserEditAtom)interestingRecords.get(RecordTypes.UserEditAtom); |
1137 |
} catch (IOException e) { |
|
|
1138 |
throw new HSLFException(e); |
1139 |
} |
1140 |
} |
1141 |
|
1142 |
|
1142 |
// persist ID is UserEditAtom.maxPersistWritten + 1 |
1143 |
// persist ID is UserEditAtom.maxPersistWritten + 1 |
1143 |
int psrId = usr.getMaxPersistWritten() + 1; |
1144 |
int psrId = usr.getMaxPersistWritten() + 1; |
Lines 1149-1154
Link Here
|
1149 |
|
1150 |
|
1150 |
// Add the new slide into the last PersistPtr |
1151 |
// Add the new slide into the last PersistPtr |
1151 |
// (Also need to tell it where it is) |
1152 |
// (Also need to tell it where it is) |
|
|
1153 |
int slideOffset = slideRecord.getLastOnDiskOffset(); |
1152 |
slideRecord.setLastOnDiskOffset(slideOffset); |
1154 |
slideRecord.setLastOnDiskOffset(slideOffset); |
1153 |
ptr.addSlideLookup(psrId, slideOffset); |
1155 |
ptr.addSlideLookup(psrId, slideOffset); |
1154 |
logger.log(POILogger.INFO, "New slide/object ended up at " + slideOffset); |
1156 |
logger.log(POILogger.INFO, "New slide/object ended up at " + slideOffset); |