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<Record> records = new ArrayList<Record>();
|
||||||
ArrayList<SlideAtomsSet> sa = new ArrayList<SlideAtomsSet>();
|
ArrayList<SlideAtomsSet> sa = new ArrayList<SlideAtomsSet>();
|
||||||
ArrayList<Slide> sl = new ArrayList<Slide>();
|
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++){
|
for (int i = 0, num = 0; i < _slides.length; i++){
|
||||||
if(i != index) {
|
if(i != index) {
|
||||||
sl.add(_slides[i]);
|
sl.add(_slides[i]);
|
||||||
@ -599,6 +603,7 @@ public final class SlideShow {
|
|||||||
records.addAll(Arrays.asList(sas[i].getSlideRecords()));
|
records.addAll(Arrays.asList(sas[i].getSlideRecords()));
|
||||||
} else {
|
} else {
|
||||||
removedSlide = _slides[i];
|
removedSlide = _slides[i];
|
||||||
|
nt.remove(_slides[i].getNotesSheet());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(sa.size() == 0){
|
if(sa.size() == 0){
|
||||||
@ -610,8 +615,9 @@ public final class SlideShow {
|
|||||||
_slides = sl.toArray(new Slide[sl.size()]);
|
_slides = sl.toArray(new Slide[sl.size()]);
|
||||||
|
|
||||||
//if the removed slide had notes - remove references to them too
|
//if the removed slide had notes - remove references to them too
|
||||||
|
|
||||||
if(removedSlide != null){
|
if(removedSlide != null){
|
||||||
int notesId = removedSlide.getSlideRecord().getSlideAtom().getNotesID();
|
int notesId = removedSlide.getSlideRecord().getSlideAtom().getNotesID();
|
||||||
if(notesId != 0){
|
if(notesId != 0){
|
||||||
SlideListWithText nslwt = _documentRecord.getNotesSlideListWithText();
|
SlideListWithText nslwt = _documentRecord.getNotesSlideListWithText();
|
||||||
records = new ArrayList<Record>();
|
records = new ArrayList<Record>();
|
||||||
@ -626,13 +632,13 @@ public final class SlideShow {
|
|||||||
if(na.size() == 0){
|
if(na.size() == 0){
|
||||||
_documentRecord.removeSlideListWithText(nslwt);
|
_documentRecord.removeSlideListWithText(nslwt);
|
||||||
} else {
|
} else {
|
||||||
slwt.setSlideAtomsSets( na.toArray(new SlideAtomsSet[na.size()]) );
|
nslwt.setSlideAtomsSets( na.toArray(new SlideAtomsSet[na.size()]) );
|
||||||
slwt.setChildRecord(records.toArray(new Record[records.size()]));
|
nslwt.setChildRecord(records.toArray(new Record[records.size()]));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
_notes = nt.toArray(new Notes[nt.size()]);
|
||||||
|
|
||||||
return removedSlide;
|
return removedSlide;
|
||||||
}
|
}
|
||||||
|
Binary file not shown.
@ -279,15 +279,18 @@ public final class TestAddingSlides extends TestCase {
|
|||||||
Slide[] slides = ppt.getSlides();
|
Slide[] slides = ppt.getSlides();
|
||||||
Document doc = ppt.getDocumentRecord();
|
Document doc = ppt.getDocumentRecord();
|
||||||
assertNotNull(doc.getSlideSlideListWithText());
|
assertNotNull(doc.getSlideSlideListWithText());
|
||||||
assertEquals(1, ppt.getSlides().length);
|
assertEquals(14, ppt.getSlides().length);
|
||||||
int notesId = slides[0].getSlideRecord().getSlideAtom().getNotesID();
|
int notesId = slides[0].getSlideRecord().getSlideAtom().getNotesID();
|
||||||
assertTrue(notesId > 0);
|
assertTrue(notesId > 0);
|
||||||
assertNotNull(doc.getNotesSlideListWithText());
|
assertNotNull(doc.getNotesSlideListWithText());
|
||||||
//the SLWT container for notes has one entry which will deleted
|
assertEquals(14, doc.getNotesSlideListWithText().getSlideAtomsSets().length);
|
||||||
assertEquals(1, doc.getNotesSlideListWithText().getSlideAtomsSets().length);
|
|
||||||
|
|
||||||
ppt.removeSlide(0);
|
//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.getSlides().length);
|
||||||
|
assertEquals(0, ppt.getNotes().length);
|
||||||
assertNull(doc.getSlideSlideListWithText());
|
assertNull(doc.getSlideSlideListWithText());
|
||||||
assertNull(doc.getNotesSlideListWithText());
|
assertNull(doc.getNotesSlideListWithText());
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user