fixed bug 42620: More than one slide fails to open in OpenOffice. Fix: UserEditAtom.MaxPersistWritten wasn't updated when adding new slides.
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@563185 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
d03f88c96b
commit
65c68651ab
@ -68,6 +68,7 @@ public class UserEditAtom extends PositionDependentRecordAtom
|
|||||||
public void setLastUserEditAtomOffset(int offset) { lastUserEditAtomOffset = offset; }
|
public void setLastUserEditAtomOffset(int offset) { lastUserEditAtomOffset = offset; }
|
||||||
public void setPersistPointersOffset(int offset) { persistPointersOffset = offset; }
|
public void setPersistPointersOffset(int offset) { persistPointersOffset = offset; }
|
||||||
public void setLastViewType(short type) { lastViewType=type; }
|
public void setLastViewType(short type) { lastViewType=type; }
|
||||||
|
public void setMaxPersistWritten(int max) { maxPersistWritten=max; }
|
||||||
|
|
||||||
/* *************** record code follows ********************** */
|
/* *************** record code follows ********************** */
|
||||||
|
|
||||||
|
@ -662,6 +662,7 @@ public class SlideShow
|
|||||||
|
|
||||||
// Last view is now of the slide
|
// Last view is now of the slide
|
||||||
usr.setLastViewType((short)UserEditAtom.LAST_VIEW_SLIDE_VIEW);
|
usr.setLastViewType((short)UserEditAtom.LAST_VIEW_SLIDE_VIEW);
|
||||||
|
usr.setMaxPersistWritten(_highestSheetId);
|
||||||
|
|
||||||
// All done and added
|
// All done and added
|
||||||
slide.setSlideShow(this);
|
slide.setSlideShow(this);
|
||||||
|
@ -26,6 +26,9 @@ import java.io.ByteArrayOutputStream;
|
|||||||
|
|
||||||
import junit.framework.TestCase;
|
import junit.framework.TestCase;
|
||||||
import org.apache.poi.hslf.*;
|
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.*;
|
import org.apache.poi.hslf.model.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -74,12 +77,24 @@ public class TestAddingSlides extends TestCase {
|
|||||||
// Should only have a master SLWT
|
// Should only have a master SLWT
|
||||||
assertEquals(1, ss_empty.getDocumentRecord().getSlideListWithTexts().length);
|
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
|
// Add one
|
||||||
Slide slide = ss_empty.createSlide();
|
Slide slide = ss_empty.createSlide();
|
||||||
assertEquals(1, ss_empty.getSlides().length);
|
assertEquals(1, ss_empty.getSlides().length);
|
||||||
assertEquals(256, slide._getSheetNumber());
|
assertEquals(256, slide._getSheetNumber());
|
||||||
assertEquals(3, slide._getSheetRefId());
|
assertEquals(3, slide._getSheetRefId());
|
||||||
assertEquals(1, slide.getSlideNumber());
|
assertEquals(1, slide.getSlideNumber());
|
||||||
|
assertEquals(usredit.getMaxPersistWritten(), slide._getSheetRefId());
|
||||||
|
|
||||||
// Write out, and read back in
|
// Write out, and read back in
|
||||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||||
@ -155,6 +170,17 @@ public class TestAddingSlides extends TestCase {
|
|||||||
* with two slides already
|
* with two slides already
|
||||||
*/
|
*/
|
||||||
public void testAddSlideToExisting2() throws Exception {
|
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
|
// Has two slides
|
||||||
assertEquals(2, ss_two.getSlides().length);
|
assertEquals(2, ss_two.getSlides().length);
|
||||||
Slide s1 = ss_two.getSlides()[0];
|
Slide s1 = ss_two.getSlides()[0];
|
||||||
@ -175,6 +201,7 @@ public class TestAddingSlides extends TestCase {
|
|||||||
assertEquals(258, s3._getSheetNumber());
|
assertEquals(258, s3._getSheetNumber());
|
||||||
assertEquals(8, s3._getSheetRefId()); // lots of notes before us
|
assertEquals(8, s3._getSheetRefId()); // lots of notes before us
|
||||||
assertEquals(3, s3.getSlideNumber());
|
assertEquals(3, s3.getSlideNumber());
|
||||||
|
assertEquals(usredit.getMaxPersistWritten(), s3._getSheetRefId());
|
||||||
|
|
||||||
// Write out, and read back in
|
// Write out, and read back in
|
||||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||||
|
Loading…
Reference in New Issue
Block a user