fixed typo in SlideShow.removeSlide which prevened deletion of slide's notes, see Bugzilla 47261
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@788948 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
af131d4cee
commit
0a044cce25
@ -590,6 +590,10 @@ public final class SlideShow {
|
||||
ArrayList<Record> records = new ArrayList<Record>();
|
||||
ArrayList<SlideAtomsSet> sa = new ArrayList<SlideAtomsSet>();
|
||||
ArrayList<Slide> sl = new ArrayList<Slide>();
|
||||
|
||||
ArrayList<Notes> nt = new ArrayList<Notes>();
|
||||
for(Notes notes : getNotes()) nt.add(notes);
|
||||
|
||||
for (int i = 0, num = 0; i < _slides.length; i++){
|
||||
if(i != index) {
|
||||
sl.add(_slides[i]);
|
||||
@ -599,6 +603,7 @@ public final class SlideShow {
|
||||
records.addAll(Arrays.asList(sas[i].getSlideRecords()));
|
||||
} else {
|
||||
removedSlide = _slides[i];
|
||||
nt.remove(_slides[i].getNotesSheet());
|
||||
}
|
||||
}
|
||||
if(sa.size() == 0){
|
||||
@ -610,6 +615,7 @@ public final class SlideShow {
|
||||
_slides = sl.toArray(new Slide[sl.size()]);
|
||||
|
||||
//if the removed slide had notes - remove references to them too
|
||||
|
||||
if(removedSlide != null){
|
||||
int notesId = removedSlide.getSlideRecord().getSlideAtom().getNotesID();
|
||||
if(notesId != 0){
|
||||
@ -626,13 +632,13 @@ public final class SlideShow {
|
||||
if(na.size() == 0){
|
||||
_documentRecord.removeSlideListWithText(nslwt);
|
||||
} else {
|
||||
slwt.setSlideAtomsSets( na.toArray(new SlideAtomsSet[na.size()]) );
|
||||
slwt.setChildRecord(records.toArray(new Record[records.size()]));
|
||||
nslwt.setSlideAtomsSets( na.toArray(new SlideAtomsSet[na.size()]) );
|
||||
nslwt.setChildRecord(records.toArray(new Record[records.size()]));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
_notes = nt.toArray(new Notes[nt.size()]);
|
||||
|
||||
return removedSlide;
|
||||
}
|
||||
|
Binary file not shown.
@ -279,15 +279,18 @@ public final class TestAddingSlides extends TestCase {
|
||||
Slide[] slides = ppt.getSlides();
|
||||
Document doc = ppt.getDocumentRecord();
|
||||
assertNotNull(doc.getSlideSlideListWithText());
|
||||
assertEquals(1, ppt.getSlides().length);
|
||||
assertEquals(14, ppt.getSlides().length);
|
||||
int notesId = slides[0].getSlideRecord().getSlideAtom().getNotesID();
|
||||
assertTrue(notesId > 0);
|
||||
assertNotNull(doc.getNotesSlideListWithText());
|
||||
//the SLWT container for notes has one entry which will deleted
|
||||
assertEquals(1, doc.getNotesSlideListWithText().getSlideAtomsSets().length);
|
||||
assertEquals(14, doc.getNotesSlideListWithText().getSlideAtomsSets().length);
|
||||
|
||||
//remove all slides, corresponding notes should be removed too
|
||||
for (int i = 0; i < slides.length; i++) {
|
||||
ppt.removeSlide(0);
|
||||
}
|
||||
assertEquals(0, ppt.getSlides().length);
|
||||
assertEquals(0, ppt.getNotes().length);
|
||||
assertNull(doc.getSlideSlideListWithText());
|
||||
assertNull(doc.getNotesSlideListWithText());
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user