poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ye...@apache.org
Subject svn commit: r563185 - in /poi/trunk/src/scratchpad: src/org/apache/poi/hslf/record/UserEditAtom.java src/org/apache/poi/hslf/usermodel/SlideShow.java testcases/org/apache/poi/hslf/usermodel/TestAddingSlides.java
Date Mon, 06 Aug 2007 16:49:48 GMT
Author: yegor
Date: Mon Aug  6 09:49:47 2007
New Revision: 563185

URL: http://svn.apache.org/viewvc?view=rev&rev=563185
Log:
fixed bug 42620: More than one slide fails to open in OpenOffice. Fix: UserEditAtom.MaxPersistWritten
wasn't updated when adding new slides.

Modified:
    poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/UserEditAtom.java
    poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/SlideShow.java
    poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestAddingSlides.java

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/UserEditAtom.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/UserEditAtom.java?view=diff&rev=563185&r1=563184&r2=563185
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/UserEditAtom.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/UserEditAtom.java Mon Aug  6 09:49:47
2007
@@ -68,6 +68,7 @@
 	public void setLastUserEditAtomOffset(int offset) { lastUserEditAtomOffset = offset; }
 	public void setPersistPointersOffset(int offset)  { persistPointersOffset = offset; }
 	public void setLastViewType(short type)           { lastViewType=type; }
+    public void setMaxPersistWritten(int max)           { maxPersistWritten=max; }
 
 	/* *************** record code follows ********************** */
 

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/SlideShow.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/SlideShow.java?view=diff&rev=563185&r1=563184&r2=563185
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/SlideShow.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/SlideShow.java Mon Aug  6 09:49:47
2007
@@ -662,7 +662,8 @@
 
 		// Last view is now of the slide
   		usr.setLastViewType((short)UserEditAtom.LAST_VIEW_SLIDE_VIEW);
-  		
+  		usr.setMaxPersistWritten(_highestSheetId);
+
   		// All done and added
   		slide.setSlideShow(this);
   		return slide;

Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestAddingSlides.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestAddingSlides.java?view=diff&rev=563185&r1=563184&r2=563185
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestAddingSlides.java
(original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestAddingSlides.java
Mon Aug  6 09:49:47 2007
@@ -26,6 +26,9 @@
 
 import junit.framework.TestCase;
 import org.apache.poi.hslf.*;
+import org.apache.poi.hslf.record.Record;
+import org.apache.poi.hslf.record.RecordTypes;
+import org.apache.poi.hslf.record.UserEditAtom;
 import org.apache.poi.hslf.model.*;
 
 /**
@@ -73,14 +76,26 @@
 		
 		// Should only have a master SLWT
 		assertEquals(1, ss_empty.getDocumentRecord().getSlideListWithTexts().length);
-		
+
+        //grab UserEditAtom
+        UserEditAtom usredit = null;
+        Record[] _records = hss_empty.getRecords();
+        for (int i = 0; i < _records.length; i++) {
+            Record record = _records[i];
+            if(_records[i].getRecordType() == RecordTypes.UserEditAtom.typeID) {
+                usredit = (UserEditAtom)_records[i];
+            }
+       }
+       assertNotNull(usredit);
+
 		// Add one
 		Slide slide = ss_empty.createSlide();
 		assertEquals(1, ss_empty.getSlides().length);
 		assertEquals(256, slide._getSheetNumber());
 		assertEquals(3, slide._getSheetRefId());
 		assertEquals(1, slide.getSlideNumber());
-		
+        assertEquals(usredit.getMaxPersistWritten(), slide._getSheetRefId());
+
 		// Write out, and read back in
 		ByteArrayOutputStream baos = new ByteArrayOutputStream();
 		hss_empty.write(baos);
@@ -155,6 +170,17 @@
 	 *  with two slides already
 	 */
 	public void testAddSlideToExisting2() throws Exception {
+        //grab UserEditAtom
+        UserEditAtom usredit = null;
+        Record[] _records = hss_two.getRecords();
+        for (int i = 0; i < _records.length; i++) {
+            Record record = _records[i];
+            if(_records[i].getRecordType() == RecordTypes.UserEditAtom.typeID) {
+                usredit = (UserEditAtom)_records[i];
+            }
+       }
+       assertNotNull(usredit);
+
 		// Has two slides
 		assertEquals(2, ss_two.getSlides().length);
 		Slide s1 = ss_two.getSlides()[0];
@@ -168,14 +194,15 @@
 		assertEquals(257, s2._getSheetNumber());
 		assertEquals(6, s2._getSheetRefId()); // master and 1 have notes
 		assertEquals(2, s2.getSlideNumber());
-		
+
 		// Add a third one
 		Slide s3 = ss_two.createSlide();
 		assertEquals(3, ss_two.getSlides().length);
 		assertEquals(258, s3._getSheetNumber());
 		assertEquals(8, s3._getSheetRefId()); // lots of notes before us
 		assertEquals(3, s3.getSlideNumber());
-		
+        assertEquals(usredit.getMaxPersistWritten(), s3._getSheetRefId());
+
 		// Write out, and read back in
 		ByteArrayOutputStream baos = new ByteArrayOutputStream();
 		hss_two.write(baos);



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org


Mime
View raw message