// If you don't know about the type, play safe and skip over it (using
// its length to know where the next record will start)
//
- // For now, this work is handled by Record.findChildRecords
-
- _records = Record.findChildRecords(_docstream,0,_docstream.length);
+
+ _records = read(_docstream, (int)currentUser.getCurrentEditOffset());
}
+ private Record[] read(byte[] docstream, int usrOffset){
+ ArrayList lst = new ArrayList();
+ while (usrOffset != 0){
+ UserEditAtom usr = (UserEditAtom) Record.buildRecordAtOffset(docstream, usrOffset);
+ lst.add(new Integer(usrOffset));
+ int psrOffset = usr.getPersistPointersOffset();
+
+ PersistPtrHolder ptr = (PersistPtrHolder)Record.buildRecordAtOffset(docstream, psrOffset);
+ lst.add(new Integer(psrOffset));
+ Hashtable entries = ptr.getSlideLocationsLookup();
+ for (Iterator it = entries.keySet().iterator(); it.hasNext(); ) {
+ Integer id = (Integer)it.next();
+ Integer offset = (Integer)entries.get(id);
+
+ lst.add(offset);
+ }
+
+ usrOffset = usr.getLastUserEditAtomOffset();
+ }
+ //sort found records by offset.
+ //(it is not necessary but SlideShow.findMostRecentCoreRecords() expects them sorted)
+ Object a[] = lst.toArray();
+ Arrays.sort(a);
+ Record[] rec = new Record[lst.size()];
+ for (int i = 0; i < a.length; i++) {
+ Integer offset = (Integer)a[i];
+ rec[i] = (Record)Record.buildRecordAtOffset(docstream, offset.intValue());
+ }
+
+ return rec;
+ }
+
/**
* Find the "Current User" stream, and load it
*/
\r
}\r
\r
+ /**\r
+ * Bug 38256: RuntimeException: Couldn't instantiate the class for type with id 0.\r
+ * ( also fixed followup: getTextRuns() returns no text )\r
+ */\r
+ public void test38256 () throws Exception {\r
+ FileInputStream is = new FileInputStream(new File(cwd, "38256.ppt"));\r
+ SlideShow ppt = new SlideShow(is);\r
+ is.close();\r
+\r
+ assertTrue("No Exceptions while reading file", true);\r
+\r
+ Slide[] slide = ppt.getSlides();\r
+ assertEquals(1, slide.length);\r
+ TextRun[] runs = slide[0].getTextRuns();\r
+ assertEquals(4, runs.length);\r
+\r
+ HashSet txt = new HashSet();\r
+ txt.add("\93HAPPY BIRTHDAY SCOTT\94");\r
+ txt.add("Have a HAPPY DAY");\r
+ txt.add("PS Nobody is allowed to hassle Scott TODAY\85");\r
+ txt.add("Drinks will be in the Boardroom at 5pm today to celebrate Scott\92s B\92Day\85 See you all there!");\r
+\r
+ for (int i = 0; i < runs.length; i++) {\r
+ String text = runs[i].getRawText();\r
+ assertTrue(txt.contains(text));\r
+ }\r
+\r
+ }\r
+\r
}\r