You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

SlideShow.java 38KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172
  1. /* ====================================================================
  2. Licensed to the Apache Software Foundation (ASF) under one or more
  3. contributor license agreements. See the NOTICE file distributed with
  4. this work for additional information regarding copyright ownership.
  5. The ASF licenses this file to You under the Apache License, Version 2.0
  6. (the "License"); you may not use this file except in compliance with
  7. the License. You may obtain a copy of the License at
  8. http://www.apache.org/licenses/LICENSE-2.0
  9. Unless required by applicable law or agreed to in writing, software
  10. distributed under the License is distributed on an "AS IS" BASIS,
  11. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. See the License for the specific language governing permissions and
  13. limitations under the License.
  14. ==================================================================== */
  15. package org.apache.poi.hslf.usermodel;
  16. import java.awt.Dimension;
  17. import java.io.ByteArrayInputStream;
  18. import java.io.ByteArrayOutputStream;
  19. import java.io.File;
  20. import java.io.FileInputStream;
  21. import java.io.IOException;
  22. import java.io.InputStream;
  23. import java.io.OutputStream;
  24. import java.util.ArrayList;
  25. import java.util.Arrays;
  26. import java.util.HashMap;
  27. import java.util.Iterator;
  28. import java.util.List;
  29. import java.util.Map;
  30. import org.apache.poi.ddf.EscherBSERecord;
  31. import org.apache.poi.ddf.EscherContainerRecord;
  32. import org.apache.poi.ddf.EscherOptRecord;
  33. import org.apache.poi.ddf.EscherRecord;
  34. import org.apache.poi.hpsf.ClassID;
  35. import org.apache.poi.hslf.HSLFSlideShow;
  36. import org.apache.poi.hslf.exceptions.CorruptPowerPointFileException;
  37. import org.apache.poi.hslf.exceptions.HSLFException;
  38. import org.apache.poi.hslf.model.HeadersFooters;
  39. import org.apache.poi.hslf.model.Hyperlink;
  40. import org.apache.poi.hslf.model.MovieShape;
  41. import org.apache.poi.hslf.model.Notes;
  42. import org.apache.poi.hslf.model.PPFont;
  43. import org.apache.poi.hslf.model.Picture;
  44. import org.apache.poi.hslf.model.Shape;
  45. import org.apache.poi.hslf.model.Slide;
  46. import org.apache.poi.hslf.model.SlideMaster;
  47. import org.apache.poi.hslf.model.TitleMaster;
  48. import org.apache.poi.hslf.record.Document;
  49. import org.apache.poi.hslf.record.DocumentAtom;
  50. import org.apache.poi.hslf.record.ExAviMovie;
  51. import org.apache.poi.hslf.record.ExControl;
  52. import org.apache.poi.hslf.record.ExEmbed;
  53. import org.apache.poi.hslf.record.ExEmbedAtom;
  54. import org.apache.poi.hslf.record.ExHyperlink;
  55. import org.apache.poi.hslf.record.ExHyperlinkAtom;
  56. import org.apache.poi.hslf.record.ExMCIMovie;
  57. import org.apache.poi.hslf.record.ExObjList;
  58. import org.apache.poi.hslf.record.ExObjListAtom;
  59. import org.apache.poi.hslf.record.ExOleObjAtom;
  60. import org.apache.poi.hslf.record.ExOleObjStg;
  61. import org.apache.poi.hslf.record.ExVideoContainer;
  62. import org.apache.poi.hslf.record.FontCollection;
  63. import org.apache.poi.hslf.record.FontEntityAtom;
  64. import org.apache.poi.hslf.record.HeadersFootersContainer;
  65. import org.apache.poi.hslf.record.PersistPtrHolder;
  66. import org.apache.poi.hslf.record.PositionDependentRecord;
  67. import org.apache.poi.hslf.record.PositionDependentRecordContainer;
  68. import org.apache.poi.hslf.record.Record;
  69. import org.apache.poi.hslf.record.RecordContainer;
  70. import org.apache.poi.hslf.record.RecordTypes;
  71. import org.apache.poi.hslf.record.SlideListWithText;
  72. import org.apache.poi.hslf.record.SlideListWithText.SlideAtomsSet;
  73. import org.apache.poi.hslf.record.SlidePersistAtom;
  74. import org.apache.poi.hslf.record.UserEditAtom;
  75. import org.apache.poi.poifs.filesystem.DirectoryNode;
  76. import org.apache.poi.poifs.filesystem.POIFSFileSystem;
  77. import org.apache.poi.util.POILogFactory;
  78. import org.apache.poi.util.POILogger;
  79. /**
  80. * This class is a friendly wrapper on top of the more scary HSLFSlideShow.
  81. *
  82. * TODO: - figure out how to match notes to their correct sheet (will involve
  83. * understanding DocSlideList and DocNotesList) - handle Slide creation cleaner
  84. *
  85. * @author Nick Burch
  86. * @author Yegor kozlov
  87. */
  88. public final class SlideShow {
  89. // What we're based on
  90. private HSLFSlideShow _hslfSlideShow;
  91. // Pointers to the most recent versions of the core records
  92. // (Document, Notes, Slide etc)
  93. private Record[] _mostRecentCoreRecords;
  94. // Lookup between the PersitPtr "sheet" IDs, and the position
  95. // in the mostRecentCoreRecords array
  96. private Map<Integer,Integer> _sheetIdToCoreRecordsLookup;
  97. // Records that are interesting
  98. private Document _documentRecord;
  99. // Friendly objects for people to deal with
  100. private SlideMaster[] _masters;
  101. private TitleMaster[] _titleMasters;
  102. private Slide[] _slides;
  103. private Notes[] _notes;
  104. private FontCollection _fonts;
  105. // For logging
  106. private POILogger logger = POILogFactory.getLogger(this.getClass());
  107. /* ===============================================================
  108. * Setup Code
  109. * ===============================================================
  110. */
  111. /**
  112. * Constructs a Powerpoint document from the underlying
  113. * HSLFSlideShow object. Finds the model stuff from this
  114. *
  115. * @param hslfSlideShow the HSLFSlideShow to base on
  116. */
  117. public SlideShow(HSLFSlideShow hslfSlideShow) {
  118. // Get useful things from our base slideshow
  119. _hslfSlideShow = hslfSlideShow;
  120. // Handle Parent-aware Records
  121. for (Record record : _hslfSlideShow.getRecords()) {
  122. if(record instanceof RecordContainer){
  123. RecordContainer.handleParentAwareRecords((RecordContainer)record);
  124. }
  125. }
  126. // Find the versions of the core records we'll want to use
  127. findMostRecentCoreRecords();
  128. // Build up the model level Slides and Notes
  129. buildSlidesAndNotes();
  130. }
  131. /**
  132. * Constructs a new, empty, Powerpoint document.
  133. */
  134. public SlideShow() {
  135. this(HSLFSlideShow.create());
  136. }
  137. /**
  138. * Constructs a Powerpoint document from an input stream.
  139. */
  140. public SlideShow(InputStream inputStream) throws IOException {
  141. this(new HSLFSlideShow(inputStream));
  142. }
  143. /**
  144. * Use the PersistPtrHolder entries to figure out what is the "most recent"
  145. * version of all the core records (Document, Notes, Slide etc), and save a
  146. * record of them. Do this by walking from the oldest PersistPtr to the
  147. * newest, overwriting any references found along the way with newer ones
  148. */
  149. private void findMostRecentCoreRecords() {
  150. // To start with, find the most recent in the byte offset domain
  151. Map<Integer,Integer> mostRecentByBytes = new HashMap<Integer,Integer>();
  152. for (Record record : _hslfSlideShow.getRecords()) {
  153. if (record instanceof PersistPtrHolder) {
  154. PersistPtrHolder pph = (PersistPtrHolder) record;
  155. // If we've already seen any of the "slide" IDs for this
  156. // PersistPtr, remove their old positions
  157. int[] ids = pph.getKnownSlideIDs();
  158. for (int id : ids) {
  159. if (mostRecentByBytes.containsKey(id)) {
  160. mostRecentByBytes.remove(id);
  161. }
  162. }
  163. // Now, update the byte level locations with their latest values
  164. Map<Integer,Integer> thisSetOfLocations = pph.getSlideLocationsLookup();
  165. for (int id : ids) {
  166. mostRecentByBytes.put(id, thisSetOfLocations.get(id));
  167. }
  168. }
  169. }
  170. // We now know how many unique special records we have, so init
  171. // the array
  172. _mostRecentCoreRecords = new Record[mostRecentByBytes.size()];
  173. // We'll also want to be able to turn the slide IDs into a position
  174. // in this array
  175. _sheetIdToCoreRecordsLookup = new HashMap<Integer,Integer>();
  176. Integer[] allIDs = mostRecentByBytes.keySet().toArray(new Integer[mostRecentByBytes.size()]);
  177. Arrays.sort(allIDs);
  178. for (int i = 0; i < allIDs.length; i++) {
  179. _sheetIdToCoreRecordsLookup.put(allIDs[i], i);
  180. }
  181. Map<Integer,Integer> mostRecentByBytesRev = new HashMap<Integer,Integer>(mostRecentByBytes.size());
  182. for (Map.Entry<Integer,Integer> me : mostRecentByBytes.entrySet()) {
  183. mostRecentByBytesRev.put(me.getValue(), me.getKey());
  184. }
  185. // Now convert the byte offsets back into record offsets
  186. for (Record record : _hslfSlideShow.getRecords()) {
  187. if (!(record instanceof PositionDependentRecord)) continue;
  188. PositionDependentRecord pdr = (PositionDependentRecord) record;
  189. int recordAt = pdr.getLastOnDiskOffset();
  190. Integer thisID = mostRecentByBytesRev.get(recordAt);
  191. if (thisID == null) continue;
  192. // Bingo. Now, where do we store it?
  193. int storeAt = _sheetIdToCoreRecordsLookup.get(thisID);
  194. // Tell it its Sheet ID, if it cares
  195. if (pdr instanceof PositionDependentRecordContainer) {
  196. PositionDependentRecordContainer pdrc = (PositionDependentRecordContainer) record;
  197. pdrc.setSheetId(thisID);
  198. }
  199. // Finally, save the record
  200. _mostRecentCoreRecords[storeAt] = record;
  201. }
  202. // Now look for the interesting records in there
  203. for (Record record : _mostRecentCoreRecords) {
  204. // Check there really is a record at this number
  205. if (record != null) {
  206. // Find the Document, and interesting things in it
  207. if (record.getRecordType() == RecordTypes.Document.typeID) {
  208. _documentRecord = (Document) record;
  209. _fonts = _documentRecord.getEnvironment().getFontCollection();
  210. }
  211. } else {
  212. // No record at this number
  213. // Odd, but not normally a problem
  214. }
  215. }
  216. }
  217. /**
  218. * For a given SlideAtomsSet, return the core record, based on the refID
  219. * from the SlidePersistAtom
  220. */
  221. private Record getCoreRecordForSAS(SlideAtomsSet sas) {
  222. SlidePersistAtom spa = sas.getSlidePersistAtom();
  223. int refID = spa.getRefID();
  224. return getCoreRecordForRefID(refID);
  225. }
  226. /**
  227. * For a given refID (the internal, 0 based numbering scheme), return the
  228. * core record
  229. *
  230. * @param refID
  231. * the refID
  232. */
  233. private Record getCoreRecordForRefID(int refID) {
  234. Integer coreRecordId = _sheetIdToCoreRecordsLookup.get(refID);
  235. if (coreRecordId != null) {
  236. Record r = _mostRecentCoreRecords[coreRecordId];
  237. return r;
  238. }
  239. logger.log(POILogger.ERROR,
  240. "We tried to look up a reference to a core record, but there was no core ID for reference ID "
  241. + refID);
  242. return null;
  243. }
  244. /**
  245. * Build up model level Slide and Notes objects, from the underlying
  246. * records.
  247. */
  248. private void buildSlidesAndNotes() {
  249. // Ensure we really found a Document record earlier
  250. // If we didn't, then the file is probably corrupt
  251. if (_documentRecord == null) {
  252. throw new CorruptPowerPointFileException(
  253. "The PowerPoint file didn't contain a Document Record in its PersistPtr blocks. It is probably corrupt.");
  254. }
  255. // Fetch the SlideListWithTexts in the most up-to-date Document Record
  256. //
  257. // As far as we understand it:
  258. // * The first SlideListWithText will contain a SlideAtomsSet
  259. // for each of the master slides
  260. // * The second SlideListWithText will contain a SlideAtomsSet
  261. // for each of the slides, in their current order
  262. // These SlideAtomsSets will normally contain text
  263. // * The third SlideListWithText (if present), will contain a
  264. // SlideAtomsSet for each Notes
  265. // These SlideAtomsSets will not normally contain text
  266. //
  267. // Having indentified the masters, slides and notes + their orders,
  268. // we have to go and find their matching records
  269. // We always use the latest versions of these records, and use the
  270. // SlideAtom/NotesAtom to match them with the StyleAtomSet
  271. SlideListWithText masterSLWT = _documentRecord.getMasterSlideListWithText();
  272. SlideListWithText slidesSLWT = _documentRecord.getSlideSlideListWithText();
  273. SlideListWithText notesSLWT = _documentRecord.getNotesSlideListWithText();
  274. // Find master slides
  275. // These can be MainMaster records, but oddly they can also be
  276. // Slides or Notes, and possibly even other odd stuff....
  277. // About the only thing you can say is that the master details are in
  278. // the first SLWT.
  279. SlideAtomsSet[] masterSets = new SlideAtomsSet[0];
  280. if (masterSLWT != null) {
  281. masterSets = masterSLWT.getSlideAtomsSets();
  282. ArrayList<SlideMaster> mmr = new ArrayList<SlideMaster>();
  283. ArrayList<TitleMaster> tmr = new ArrayList<TitleMaster>();
  284. for (SlideAtomsSet sas : masterSets) {
  285. Record r = getCoreRecordForSAS(sas);
  286. int sheetNo = sas.getSlidePersistAtom().getSlideIdentifier();
  287. if (r instanceof org.apache.poi.hslf.record.Slide) {
  288. TitleMaster master = new TitleMaster((org.apache.poi.hslf.record.Slide) r,
  289. sheetNo);
  290. master.setSlideShow(this);
  291. tmr.add(master);
  292. } else if (r instanceof org.apache.poi.hslf.record.MainMaster) {
  293. SlideMaster master = new SlideMaster((org.apache.poi.hslf.record.MainMaster) r,
  294. sheetNo);
  295. master.setSlideShow(this);
  296. mmr.add(master);
  297. }
  298. }
  299. _masters = mmr.toArray(new SlideMaster[mmr.size()]);
  300. _titleMasters = tmr.toArray(new TitleMaster[tmr.size()]);
  301. }
  302. // Having sorted out the masters, that leaves the notes and slides
  303. // Start by finding the notes records to go with the entries in
  304. // notesSLWT
  305. org.apache.poi.hslf.record.Notes[] notesRecords;
  306. SlideAtomsSet[] notesSets = new SlideAtomsSet[0];
  307. Map<Integer,Integer> slideIdToNotes = new HashMap<Integer,Integer>();
  308. if (notesSLWT == null) {
  309. // None
  310. notesRecords = new org.apache.poi.hslf.record.Notes[0];
  311. } else {
  312. // Match up the records and the SlideAtomSets
  313. notesSets = notesSLWT.getSlideAtomsSets();
  314. List<org.apache.poi.hslf.record.Notes> notesRecordsL =
  315. new ArrayList<org.apache.poi.hslf.record.Notes>();
  316. for (int i = 0; i < notesSets.length; i++) {
  317. // Get the right core record
  318. Record r = getCoreRecordForSAS(notesSets[i]);
  319. // Ensure it really is a notes record
  320. if (r == null || r instanceof org.apache.poi.hslf.record.Notes) {
  321. if (r == null) {
  322. logger.log(POILogger.WARN, "A Notes SlideAtomSet at " + i
  323. + " said its record was at refID "
  324. + notesSets[i].getSlidePersistAtom().getRefID()
  325. + ", but that record didn't exist - record ignored.");
  326. }
  327. // we need to add also null-records, otherwise the index references to other existing
  328. // don't work anymore
  329. org.apache.poi.hslf.record.Notes notesRecord = (org.apache.poi.hslf.record.Notes) r;
  330. notesRecordsL.add(notesRecord);
  331. // Record the match between slide id and these notes
  332. SlidePersistAtom spa = notesSets[i].getSlidePersistAtom();
  333. int slideId = spa.getSlideIdentifier();
  334. slideIdToNotes.put(slideId, i);
  335. } else {
  336. logger.log(POILogger.ERROR, "A Notes SlideAtomSet at " + i
  337. + " said its record was at refID "
  338. + notesSets[i].getSlidePersistAtom().getRefID()
  339. + ", but that was actually a " + r);
  340. }
  341. }
  342. notesRecords = new org.apache.poi.hslf.record.Notes[notesRecordsL.size()];
  343. notesRecords = notesRecordsL.toArray(notesRecords);
  344. }
  345. // Now, do the same thing for our slides
  346. org.apache.poi.hslf.record.Slide[] slidesRecords;
  347. SlideAtomsSet[] slidesSets = new SlideAtomsSet[0];
  348. if (slidesSLWT == null) {
  349. // None
  350. slidesRecords = new org.apache.poi.hslf.record.Slide[0];
  351. } else {
  352. // Match up the records and the SlideAtomSets
  353. slidesSets = slidesSLWT.getSlideAtomsSets();
  354. slidesRecords = new org.apache.poi.hslf.record.Slide[slidesSets.length];
  355. for (int i = 0; i < slidesSets.length; i++) {
  356. // Get the right core record
  357. Record r = getCoreRecordForSAS(slidesSets[i]);
  358. // Ensure it really is a slide record
  359. if (r instanceof org.apache.poi.hslf.record.Slide) {
  360. slidesRecords[i] = (org.apache.poi.hslf.record.Slide) r;
  361. } else {
  362. logger.log(POILogger.ERROR, "A Slide SlideAtomSet at " + i
  363. + " said its record was at refID "
  364. + slidesSets[i].getSlidePersistAtom().getRefID()
  365. + ", but that was actually a " + r);
  366. }
  367. }
  368. }
  369. // Finally, generate model objects for everything
  370. // Notes first
  371. _notes = new Notes[notesRecords.length];
  372. for (int i = 0; i < _notes.length; i++) {
  373. if (notesRecords[i] != null) {
  374. _notes[i] = new Notes(notesRecords[i]);
  375. _notes[i].setSlideShow(this);
  376. }
  377. }
  378. // Then slides
  379. _slides = new Slide[slidesRecords.length];
  380. for (int i = 0; i < _slides.length; i++) {
  381. SlideAtomsSet sas = slidesSets[i];
  382. int slideIdentifier = sas.getSlidePersistAtom().getSlideIdentifier();
  383. // Do we have a notes for this?
  384. Notes notes = null;
  385. // Slide.SlideAtom.notesId references the corresponding notes slide.
  386. // 0 if slide has no notes.
  387. int noteId = slidesRecords[i].getSlideAtom().getNotesID();
  388. if (noteId != 0) {
  389. Integer notesPos = slideIdToNotes.get(noteId);
  390. if (notesPos != null) {
  391. notes = _notes[notesPos];
  392. } else {
  393. logger.log(POILogger.ERROR, "Notes not found for noteId=" + noteId);
  394. }
  395. }
  396. // Now, build our slide
  397. _slides[i] = new Slide(slidesRecords[i], notes, sas, slideIdentifier, (i + 1));
  398. _slides[i].setSlideShow(this);
  399. }
  400. }
  401. /**
  402. * Writes out the slideshow file the is represented by an instance of this
  403. * class
  404. *
  405. * @param out
  406. * The OutputStream to write to.
  407. * @throws IOException
  408. * If there is an unexpected IOException from the passed in
  409. * OutputStream
  410. */
  411. public void write(OutputStream out) throws IOException {
  412. _hslfSlideShow.write(out);
  413. }
  414. /*
  415. * ===============================================================
  416. * Accessor Code
  417. * ===============================================================
  418. */
  419. /**
  420. * Returns an array of the most recent version of all the interesting
  421. * records
  422. */
  423. public Record[] getMostRecentCoreRecords() {
  424. return _mostRecentCoreRecords;
  425. }
  426. /**
  427. * Returns an array of all the normal Slides found in the slideshow
  428. */
  429. public Slide[] getSlides() {
  430. return _slides;
  431. }
  432. /**
  433. * Returns an array of all the normal Notes found in the slideshow
  434. */
  435. public Notes[] getNotes() {
  436. return _notes;
  437. }
  438. /**
  439. * Returns an array of all the normal Slide Masters found in the slideshow
  440. */
  441. public SlideMaster[] getSlidesMasters() {
  442. return _masters;
  443. }
  444. /**
  445. * Returns an array of all the normal Title Masters found in the slideshow
  446. */
  447. public TitleMaster[] getTitleMasters() {
  448. return _titleMasters;
  449. }
  450. /**
  451. * Returns the data of all the pictures attached to the SlideShow
  452. */
  453. public PictureData[] getPictureData() {
  454. return _hslfSlideShow.getPictures();
  455. }
  456. /**
  457. * Returns the data of all the embedded OLE object in the SlideShow
  458. */
  459. public ObjectData[] getEmbeddedObjects() {
  460. return _hslfSlideShow.getEmbeddedObjects();
  461. }
  462. /**
  463. * Returns the data of all the embedded sounds in the SlideShow
  464. */
  465. public SoundData[] getSoundData() {
  466. return SoundData.find(_documentRecord);
  467. }
  468. /**
  469. * Return the current page size
  470. */
  471. public Dimension getPageSize() {
  472. DocumentAtom docatom = _documentRecord.getDocumentAtom();
  473. int pgx = (int) docatom.getSlideSizeX() * Shape.POINT_DPI / Shape.MASTER_DPI;
  474. int pgy = (int) docatom.getSlideSizeY() * Shape.POINT_DPI / Shape.MASTER_DPI;
  475. return new Dimension(pgx, pgy);
  476. }
  477. /**
  478. * Change the current page size
  479. *
  480. * @param pgsize
  481. * page size (in points)
  482. */
  483. public void setPageSize(Dimension pgsize) {
  484. DocumentAtom docatom = _documentRecord.getDocumentAtom();
  485. docatom.setSlideSizeX(pgsize.width * Shape.MASTER_DPI / Shape.POINT_DPI);
  486. docatom.setSlideSizeY(pgsize.height * Shape.MASTER_DPI / Shape.POINT_DPI);
  487. }
  488. /**
  489. * Helper method for usermodel: Get the font collection
  490. */
  491. protected FontCollection getFontCollection() {
  492. return _fonts;
  493. }
  494. /**
  495. * Helper method for usermodel and model: Get the document record
  496. */
  497. public Document getDocumentRecord() {
  498. return _documentRecord;
  499. }
  500. /*
  501. * ===============================================================
  502. * Re-ordering Code
  503. * ===============================================================
  504. */
  505. /**
  506. * Re-orders a slide, to a new position.
  507. *
  508. * @param oldSlideNumber
  509. * The old slide number (1 based)
  510. * @param newSlideNumber
  511. * The new slide number (1 based)
  512. */
  513. public void reorderSlide(int oldSlideNumber, int newSlideNumber) {
  514. // Ensure these numbers are valid
  515. if (oldSlideNumber < 1 || newSlideNumber < 1) {
  516. throw new IllegalArgumentException("Old and new slide numbers must be greater than 0");
  517. }
  518. if (oldSlideNumber > _slides.length || newSlideNumber > _slides.length) {
  519. throw new IllegalArgumentException(
  520. "Old and new slide numbers must not exceed the number of slides ("
  521. + _slides.length + ")");
  522. }
  523. // The order of slides is defined by the order of slide atom sets in the
  524. // SlideListWithText container.
  525. SlideListWithText slwt = _documentRecord.getSlideSlideListWithText();
  526. SlideAtomsSet[] sas = slwt.getSlideAtomsSets();
  527. SlideAtomsSet tmp = sas[oldSlideNumber - 1];
  528. sas[oldSlideNumber - 1] = sas[newSlideNumber - 1];
  529. sas[newSlideNumber - 1] = tmp;
  530. ArrayList<Record> lst = new ArrayList<Record>();
  531. for (int i = 0; i < sas.length; i++) {
  532. lst.add(sas[i].getSlidePersistAtom());
  533. Record[] r = sas[i].getSlideRecords();
  534. for (int j = 0; j < r.length; j++) {
  535. lst.add(r[j]);
  536. }
  537. _slides[i].setSlideNumber(i + 1);
  538. }
  539. Record[] r = lst.toArray(new Record[lst.size()]);
  540. slwt.setChildRecord(r);
  541. }
  542. /**
  543. * Removes the slide at the given index (0-based).
  544. * <p>
  545. * Shifts any subsequent slides to the left (subtracts one from their slide
  546. * numbers).
  547. * </p>
  548. *
  549. * @param index
  550. * the index of the slide to remove (0-based)
  551. * @return the slide that was removed from the slide show.
  552. */
  553. public Slide removeSlide(int index) {
  554. int lastSlideIdx = _slides.length - 1;
  555. if (index < 0 || index > lastSlideIdx) {
  556. throw new IllegalArgumentException("Slide index (" + index + ") is out of range (0.."
  557. + lastSlideIdx + ")");
  558. }
  559. SlideListWithText slwt = _documentRecord.getSlideSlideListWithText();
  560. SlideAtomsSet[] sas = slwt.getSlideAtomsSets();
  561. Slide removedSlide = null;
  562. ArrayList<Record> records = new ArrayList<Record>();
  563. ArrayList<SlideAtomsSet> sa = new ArrayList<SlideAtomsSet>();
  564. ArrayList<Slide> sl = new ArrayList<Slide>();
  565. ArrayList<Notes> nt = new ArrayList<Notes>();
  566. for (Notes notes : getNotes())
  567. nt.add(notes);
  568. for (int i = 0, num = 0; i < _slides.length; i++) {
  569. if (i != index) {
  570. sl.add(_slides[i]);
  571. sa.add(sas[i]);
  572. _slides[i].setSlideNumber(num++);
  573. records.add(sas[i].getSlidePersistAtom());
  574. records.addAll(Arrays.asList(sas[i].getSlideRecords()));
  575. } else {
  576. removedSlide = _slides[i];
  577. nt.remove(_slides[i].getNotesSheet());
  578. }
  579. }
  580. if (sa.size() == 0) {
  581. _documentRecord.removeSlideListWithText(slwt);
  582. } else {
  583. slwt.setSlideAtomsSets(sa.toArray(new SlideAtomsSet[sa.size()]));
  584. slwt.setChildRecord(records.toArray(new Record[records.size()]));
  585. }
  586. _slides = sl.toArray(new Slide[sl.size()]);
  587. // if the removed slide had notes - remove references to them too
  588. if (removedSlide != null) {
  589. int notesId = removedSlide.getSlideRecord().getSlideAtom().getNotesID();
  590. if (notesId != 0) {
  591. SlideListWithText nslwt = _documentRecord.getNotesSlideListWithText();
  592. records = new ArrayList<Record>();
  593. ArrayList<SlideAtomsSet> na = new ArrayList<SlideAtomsSet>();
  594. for (SlideAtomsSet ns : nslwt.getSlideAtomsSets()) {
  595. if (ns.getSlidePersistAtom().getSlideIdentifier() != notesId) {
  596. na.add(ns);
  597. records.add(ns.getSlidePersistAtom());
  598. if (ns.getSlideRecords() != null)
  599. records.addAll(Arrays.asList(ns.getSlideRecords()));
  600. }
  601. }
  602. if (na.size() == 0) {
  603. _documentRecord.removeSlideListWithText(nslwt);
  604. } else {
  605. nslwt.setSlideAtomsSets(na.toArray(new SlideAtomsSet[na.size()]));
  606. nslwt.setChildRecord(records.toArray(new Record[records.size()]));
  607. }
  608. }
  609. }
  610. _notes = nt.toArray(new Notes[nt.size()]);
  611. return removedSlide;
  612. }
  613. /*
  614. * ===============================================================
  615. * Addition Code
  616. * ===============================================================
  617. */
  618. /**
  619. * Create a blank <code>Slide</code>.
  620. *
  621. * @return the created <code>Slide</code>
  622. */
  623. public Slide createSlide() {
  624. SlideListWithText slist = null;
  625. // We need to add the records to the SLWT that deals
  626. // with Slides.
  627. // Add it, if it doesn't exist
  628. slist = _documentRecord.getSlideSlideListWithText();
  629. if (slist == null) {
  630. // Need to add a new one
  631. slist = new SlideListWithText();
  632. slist.setInstance(SlideListWithText.SLIDES);
  633. _documentRecord.addSlideListWithText(slist);
  634. }
  635. // Grab the SlidePersistAtom with the highest Slide Number.
  636. // (Will stay as null if no SlidePersistAtom exists yet in
  637. // the slide, or only master slide's ones do)
  638. SlidePersistAtom prev = null;
  639. for (SlideAtomsSet sas : slist.getSlideAtomsSets()) {
  640. SlidePersistAtom spa = sas.getSlidePersistAtom();
  641. if (spa.getSlideIdentifier() < 0) {
  642. // This is for a master slide
  643. // Odd, since we only deal with the Slide SLWT
  644. } else {
  645. // Must be for a real slide
  646. if (prev == null) {
  647. prev = spa;
  648. }
  649. if (prev.getSlideIdentifier() < spa.getSlideIdentifier()) {
  650. prev = spa;
  651. }
  652. }
  653. }
  654. // Set up a new SlidePersistAtom for this slide
  655. SlidePersistAtom sp = new SlidePersistAtom();
  656. // First slideId is always 256
  657. sp.setSlideIdentifier(prev == null ? 256 : (prev.getSlideIdentifier() + 1));
  658. // Add this new SlidePersistAtom to the SlideListWithText
  659. slist.addSlidePersistAtom(sp);
  660. // Create a new Slide
  661. Slide slide = new Slide(sp.getSlideIdentifier(), sp.getRefID(), _slides.length + 1);
  662. slide.setSlideShow(this);
  663. slide.onCreate();
  664. // Add in to the list of Slides
  665. Slide[] s = new Slide[_slides.length + 1];
  666. System.arraycopy(_slides, 0, s, 0, _slides.length);
  667. s[_slides.length] = slide;
  668. _slides = s;
  669. logger.log(POILogger.INFO, "Added slide " + _slides.length + " with ref " + sp.getRefID()
  670. + " and identifier " + sp.getSlideIdentifier());
  671. // Add the core records for this new Slide to the record tree
  672. org.apache.poi.hslf.record.Slide slideRecord = slide.getSlideRecord();
  673. int psrId = addPersistentObject(slideRecord);
  674. sp.setRefID(psrId);
  675. slideRecord.setSheetId(psrId);
  676. slide.setMasterSheet(_masters[0]);
  677. // All done and added
  678. return slide;
  679. }
  680. /**
  681. * Adds a picture to this presentation and returns the associated index.
  682. *
  683. * @param data
  684. * picture data
  685. * @param format
  686. * the format of the picture. One of constans defined in the
  687. * <code>Picture</code> class.
  688. * @return the index to this picture (1 based).
  689. */
  690. public int addPicture(byte[] data, int format) throws IOException {
  691. byte[] uid = PictureData.getChecksum(data);
  692. EscherContainerRecord bstore;
  693. EscherContainerRecord dggContainer = _documentRecord.getPPDrawingGroup().getDggContainer();
  694. bstore = (EscherContainerRecord) Shape.getEscherChild(dggContainer,
  695. EscherContainerRecord.BSTORE_CONTAINER);
  696. if (bstore == null) {
  697. bstore = new EscherContainerRecord();
  698. bstore.setRecordId(EscherContainerRecord.BSTORE_CONTAINER);
  699. dggContainer.addChildBefore(bstore, EscherOptRecord.RECORD_ID);
  700. } else {
  701. Iterator<EscherRecord> iter = bstore.getChildIterator();
  702. for (int i = 0; iter.hasNext(); i++) {
  703. EscherBSERecord bse = (EscherBSERecord) iter.next();
  704. if (Arrays.equals(bse.getUid(), uid)) {
  705. return i + 1;
  706. }
  707. }
  708. }
  709. PictureData pict = PictureData.create(format);
  710. pict.setData(data);
  711. int offset = _hslfSlideShow.addPicture(pict);
  712. EscherBSERecord bse = new EscherBSERecord();
  713. bse.setRecordId(EscherBSERecord.RECORD_ID);
  714. bse.setOptions((short) (0x0002 | (format << 4)));
  715. bse.setSize(pict.getRawData().length + 8);
  716. bse.setUid(uid);
  717. bse.setBlipTypeMacOS((byte) format);
  718. bse.setBlipTypeWin32((byte) format);
  719. if (format == Picture.EMF)
  720. bse.setBlipTypeMacOS((byte) Picture.PICT);
  721. else if (format == Picture.WMF)
  722. bse.setBlipTypeMacOS((byte) Picture.PICT);
  723. else if (format == Picture.PICT)
  724. bse.setBlipTypeWin32((byte) Picture.WMF);
  725. bse.setRef(0);
  726. bse.setOffset(offset);
  727. bse.setRemainingData(new byte[0]);
  728. bstore.addChildRecord(bse);
  729. int count = bstore.getChildRecords().size();
  730. bstore.setOptions((short) ((count << 4) | 0xF));
  731. return count;
  732. }
  733. /**
  734. * Adds a picture to this presentation and returns the associated index.
  735. *
  736. * @param pict
  737. * the file containing the image to add
  738. * @param format
  739. * the format of the picture. One of constans defined in the
  740. * <code>Picture</code> class.
  741. * @return the index to this picture (1 based).
  742. */
  743. public int addPicture(File pict, int format) throws IOException {
  744. int length = (int) pict.length();
  745. byte[] data = new byte[length];
  746. FileInputStream is = null;
  747. try {
  748. is = new FileInputStream(pict);
  749. is.read(data);
  750. } finally {
  751. if(is != null) is.close();
  752. }
  753. return addPicture(data, format);
  754. }
  755. /**
  756. * Add a font in this presentation
  757. *
  758. * @param font
  759. * the font to add
  760. * @return 0-based index of the font
  761. */
  762. public int addFont(PPFont font) {
  763. FontCollection fonts = getDocumentRecord().getEnvironment().getFontCollection();
  764. int idx = fonts.getFontIndex(font.getFontName());
  765. if (idx == -1) {
  766. idx = fonts.addFont(font.getFontName(), font.getCharSet(), font.getFontFlags(), font
  767. .getFontType(), font.getPitchAndFamily());
  768. }
  769. return idx;
  770. }
  771. /**
  772. * Get a font by index
  773. *
  774. * @param idx
  775. * 0-based index of the font
  776. * @return of an instance of <code>PPFont</code> or <code>null</code> if not
  777. * found
  778. */
  779. public PPFont getFont(int idx) {
  780. FontCollection fonts = getDocumentRecord().getEnvironment().getFontCollection();
  781. for (Record ch : fonts.getChildRecords()) {
  782. if (ch instanceof FontEntityAtom) {
  783. FontEntityAtom atom = (FontEntityAtom) ch;
  784. if (atom.getFontIndex() == idx) {
  785. return new PPFont(atom);
  786. }
  787. }
  788. }
  789. return null;
  790. }
  791. /**
  792. * get the number of fonts in the presentation
  793. *
  794. * @return number of fonts
  795. */
  796. public int getNumberOfFonts() {
  797. return getDocumentRecord().getEnvironment().getFontCollection().getNumberOfFonts();
  798. }
  799. /**
  800. * Return Header / Footer settings for slides
  801. *
  802. * @return Header / Footer settings for slides
  803. */
  804. public HeadersFooters getSlideHeadersFooters() {
  805. // detect if this ppt was saved in Office2007
  806. String tag = getSlidesMasters()[0].getProgrammableTag();
  807. boolean ppt2007 = "___PPT12".equals(tag);
  808. HeadersFootersContainer hdd = null;
  809. for (Record ch : _documentRecord.getChildRecords()) {
  810. if (ch instanceof HeadersFootersContainer
  811. && ((HeadersFootersContainer) ch).getOptions() == HeadersFootersContainer.SlideHeadersFootersContainer) {
  812. hdd = (HeadersFootersContainer) ch;
  813. break;
  814. }
  815. }
  816. boolean newRecord = false;
  817. if (hdd == null) {
  818. hdd = new HeadersFootersContainer(HeadersFootersContainer.SlideHeadersFootersContainer);
  819. newRecord = true;
  820. }
  821. return new HeadersFooters(hdd, this, newRecord, ppt2007);
  822. }
  823. /**
  824. * Return Header / Footer settings for notes
  825. *
  826. * @return Header / Footer settings for notes
  827. */
  828. public HeadersFooters getNotesHeadersFooters() {
  829. // detect if this ppt was saved in Office2007
  830. String tag = getSlidesMasters()[0].getProgrammableTag();
  831. boolean ppt2007 = "___PPT12".equals(tag);
  832. HeadersFootersContainer hdd = null;
  833. for (Record ch : _documentRecord.getChildRecords()) {
  834. if (ch instanceof HeadersFootersContainer
  835. && ((HeadersFootersContainer) ch).getOptions() == HeadersFootersContainer.NotesHeadersFootersContainer) {
  836. hdd = (HeadersFootersContainer) ch;
  837. break;
  838. }
  839. }
  840. boolean newRecord = false;
  841. if (hdd == null) {
  842. hdd = new HeadersFootersContainer(HeadersFootersContainer.NotesHeadersFootersContainer);
  843. newRecord = true;
  844. }
  845. if (ppt2007 && _notes.length > 0) {
  846. return new HeadersFooters(hdd, _notes[0], newRecord, ppt2007);
  847. }
  848. return new HeadersFooters(hdd, this, newRecord, ppt2007);
  849. }
  850. /**
  851. * Add a movie in this presentation
  852. *
  853. * @param path
  854. * the path or url to the movie
  855. * @return 0-based index of the movie
  856. */
  857. public int addMovie(String path, int type) {
  858. ExMCIMovie mci;
  859. switch (type) {
  860. case MovieShape.MOVIE_MPEG:
  861. mci = new ExMCIMovie();
  862. break;
  863. case MovieShape.MOVIE_AVI:
  864. mci = new ExAviMovie();
  865. break;
  866. default:
  867. throw new IllegalArgumentException("Unsupported Movie: " + type);
  868. }
  869. ExVideoContainer exVideo = mci.getExVideo();
  870. exVideo.getExMediaAtom().setMask(0xE80000);
  871. exVideo.getPathAtom().setText(path);
  872. int objectId = addToObjListAtom(mci);
  873. exVideo.getExMediaAtom().setObjectId(objectId);
  874. return objectId;
  875. }
  876. /**
  877. * Add a control in this presentation
  878. *
  879. * @param name
  880. * name of the control, e.g. "Shockwave Flash Object"
  881. * @param progId
  882. * OLE Programmatic Identifier, e.g.
  883. * "ShockwaveFlash.ShockwaveFlash.9"
  884. * @return 0-based index of the control
  885. */
  886. public int addControl(String name, String progId) {
  887. ExControl ctrl = new ExControl();
  888. ctrl.setProgId(progId);
  889. ctrl.setMenuName(name);
  890. ctrl.setClipboardName(name);
  891. ExOleObjAtom oleObj = ctrl.getExOleObjAtom();
  892. oleObj.setDrawAspect(ExOleObjAtom.DRAW_ASPECT_VISIBLE);
  893. oleObj.setType(ExOleObjAtom.TYPE_CONTROL);
  894. oleObj.setSubType(ExOleObjAtom.SUBTYPE_DEFAULT);
  895. int objectId = addToObjListAtom(ctrl);
  896. oleObj.setObjID(objectId);
  897. return objectId;
  898. }
  899. /**
  900. * Add a hyperlink to this presentation
  901. *
  902. * @return 0-based index of the hyperlink
  903. */
  904. public int addHyperlink(Hyperlink link) {
  905. ExHyperlink ctrl = new ExHyperlink();
  906. ExHyperlinkAtom obj = ctrl.getExHyperlinkAtom();
  907. if(link.getType() == Hyperlink.LINK_SLIDENUMBER) {
  908. ctrl.setLinkURL(link.getAddress(), 0x30);
  909. } else {
  910. ctrl.setLinkURL(link.getAddress());
  911. }
  912. ctrl.setLinkTitle(link.getTitle());
  913. int objectId = addToObjListAtom(ctrl);
  914. link.setId(objectId);
  915. obj.setNumber(objectId);
  916. return objectId;
  917. }
  918. /**
  919. * Add a embedded object to this presentation
  920. *
  921. * @return 0-based index of the embedded object
  922. */
  923. public int addEmbed(POIFSFileSystem poiData) {
  924. DirectoryNode root = poiData.getRoot();
  925. // prepare embedded data
  926. if (new ClassID().equals(root.getStorageClsid())) {
  927. // need to set class id
  928. Map<String,ClassID> olemap = getOleMap();
  929. ClassID classID = null;
  930. for (Map.Entry<String,ClassID> entry : olemap.entrySet()) {
  931. if (root.hasEntry(entry.getKey())) {
  932. classID = entry.getValue();
  933. break;
  934. }
  935. }
  936. if (classID == null) {
  937. throw new IllegalArgumentException("Unsupported embedded document");
  938. }
  939. root.setStorageClsid(classID);
  940. }
  941. ExEmbed exEmbed = new ExEmbed();
  942. // remove unneccessary infos, so we don't need to specify the type
  943. // of the ole object multiple times
  944. Record children[] = exEmbed.getChildRecords();
  945. exEmbed.removeChild(children[2]);
  946. exEmbed.removeChild(children[3]);
  947. exEmbed.removeChild(children[4]);
  948. ExEmbedAtom eeEmbed = exEmbed.getExEmbedAtom();
  949. eeEmbed.setCantLockServerB(true);
  950. ExOleObjAtom eeAtom = exEmbed.getExOleObjAtom();
  951. eeAtom.setDrawAspect(ExOleObjAtom.DRAW_ASPECT_VISIBLE);
  952. eeAtom.setType(ExOleObjAtom.TYPE_EMBEDDED);
  953. // eeAtom.setSubType(ExOleObjAtom.SUBTYPE_EXCEL);
  954. // should be ignored?!?, see MS-PPT ExOleObjAtom, but Libre Office sets it ...
  955. eeAtom.setOptions(1226240);
  956. ExOleObjStg exOleObjStg = new ExOleObjStg();
  957. try {
  958. final String OLESTREAM_NAME = "\u0001Ole";
  959. if (!root.hasEntry(OLESTREAM_NAME)) {
  960. // the following data was taken from an example libre office document
  961. // beside this "\u0001Ole" record there were several other records, e.g. CompObj,
  962. // OlePresXXX, but it seems, that they aren't neccessary
  963. byte oleBytes[] = { 1, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
  964. poiData.createDocument(new ByteArrayInputStream(oleBytes), OLESTREAM_NAME);
  965. }
  966. ByteArrayOutputStream bos = new ByteArrayOutputStream();
  967. poiData.writeFilesystem(bos);
  968. exOleObjStg.setData(bos.toByteArray());
  969. } catch (IOException e) {
  970. throw new HSLFException(e);
  971. }
  972. int psrId = addPersistentObject(exOleObjStg);
  973. exOleObjStg.setPersistId(psrId);
  974. eeAtom.setObjStgDataRef(psrId);
  975. int objectId = addToObjListAtom(exEmbed);
  976. eeAtom.setObjID(objectId);
  977. return objectId;
  978. }
  979. protected int addToObjListAtom(RecordContainer exObj) {
  980. ExObjList lst = (ExObjList) _documentRecord.findFirstOfType(RecordTypes.ExObjList.typeID);
  981. if (lst == null) {
  982. lst = new ExObjList();
  983. _documentRecord.addChildAfter(lst, _documentRecord.getDocumentAtom());
  984. }
  985. ExObjListAtom objAtom = lst.getExObjListAtom();
  986. // increment the object ID seed
  987. int objectId = (int) objAtom.getObjectIDSeed() + 1;
  988. objAtom.setObjectIDSeed(objectId);
  989. lst.addChildAfter(exObj, objAtom);
  990. return objectId;
  991. }
  992. protected static Map<String,ClassID> getOleMap() {
  993. Map<String,ClassID> olemap = new HashMap<String,ClassID>();
  994. olemap.put("PowerPoint Document", ClassID.PPT_SHOW);
  995. olemap.put("Workbook", ClassID.EXCEL97); // as per BIFF8 spec
  996. olemap.put("WORKBOOK", ClassID.EXCEL97); // Typically from third party programs
  997. olemap.put("BOOK", ClassID.EXCEL97); // Typically odd Crystal Reports exports
  998. // ... to be continued
  999. return olemap;
  1000. }
  1001. protected int addPersistentObject(PositionDependentRecord slideRecord) {
  1002. slideRecord.setLastOnDiskOffset(HSLFSlideShow.UNSET_OFFSET);
  1003. _hslfSlideShow.appendRootLevelRecord((Record)slideRecord);
  1004. // For position dependent records, hold where they were and now are
  1005. // As we go along, update, and hand over, to any Position Dependent
  1006. // records we happen across
  1007. Map<RecordTypes.Type,PositionDependentRecord> interestingRecords =
  1008. new HashMap<RecordTypes.Type,PositionDependentRecord>();
  1009. try {
  1010. _hslfSlideShow.updateAndWriteDependantRecords(null,interestingRecords);
  1011. } catch (IOException e) {
  1012. throw new HSLFException(e);
  1013. }
  1014. PersistPtrHolder ptr = (PersistPtrHolder)interestingRecords.get(RecordTypes.PersistPtrIncrementalBlock);
  1015. UserEditAtom usr = (UserEditAtom)interestingRecords.get(RecordTypes.UserEditAtom);
  1016. // persist ID is UserEditAtom.maxPersistWritten + 1
  1017. int psrId = usr.getMaxPersistWritten() + 1;
  1018. // Last view is now of the slide
  1019. usr.setLastViewType((short) UserEditAtom.LAST_VIEW_SLIDE_VIEW);
  1020. // increment the number of persistent objects
  1021. usr.setMaxPersistWritten(psrId);
  1022. // Add the new slide into the last PersistPtr
  1023. // (Also need to tell it where it is)
  1024. int slideOffset = slideRecord.getLastOnDiskOffset();
  1025. slideRecord.setLastOnDiskOffset(slideOffset);
  1026. ptr.addSlideLookup(psrId, slideOffset);
  1027. logger.log(POILogger.INFO, "New slide/object ended up at " + slideOffset);
  1028. return psrId;
  1029. }
  1030. }