aboutsummaryrefslogtreecommitdiffstats
path: root/src/scratchpad
diff options
context:
space:
mode:
authorYegor Kozlov <yegor@apache.org>2009-06-27 10:25:23 +0000
committerYegor Kozlov <yegor@apache.org>2009-06-27 10:25:23 +0000
commit0b2d3cf6938806e4086bfb4766e95572d5bd9134 (patch)
tree28965f19b8df9a692bf47bfe69e6e7dd509dbfd7 /src/scratchpad
parentd90f75b05ef03a1909e7dbf6676f57608b127ab6 (diff)
downloadpoi-0b2d3cf6938806e4086bfb4766e95572d5bd9134.tar.gz
poi-0b2d3cf6938806e4086bfb4766e95572d5bd9134.zip
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
Diffstat (limited to 'src/scratchpad')
-rw-r--r--src/scratchpad/src/org/apache/poi/hslf/usermodel/SlideShow.java14
-rwxr-xr-xsrc/scratchpad/testcases/org/apache/poi/hslf/data/47261.pptbin183296 -> 378368 bytes
-rw-r--r--src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestAddingSlides.java11
3 files changed, 17 insertions, 8 deletions
diff --git a/src/scratchpad/src/org/apache/poi/hslf/usermodel/SlideShow.java b/src/scratchpad/src/org/apache/poi/hslf/usermodel/SlideShow.java
index cf8d89050f..b456798bae 100644
--- a/src/scratchpad/src/org/apache/poi/hslf/usermodel/SlideShow.java
+++ b/src/scratchpad/src/org/apache/poi/hslf/usermodel/SlideShow.java
@@ -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,8 +615,9 @@ 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();
+ int notesId = removedSlide.getSlideRecord().getSlideAtom().getNotesID();
if(notesId != 0){
SlideListWithText nslwt = _documentRecord.getNotesSlideListWithText();
records = new ArrayList<Record>();
@@ -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;
}
diff --git a/src/scratchpad/testcases/org/apache/poi/hslf/data/47261.ppt b/src/scratchpad/testcases/org/apache/poi/hslf/data/47261.ppt
index be472de7c9..7a26a7981e 100755
--- a/src/scratchpad/testcases/org/apache/poi/hslf/data/47261.ppt
+++ b/src/scratchpad/testcases/org/apache/poi/hslf/data/47261.ppt
Binary files differ
diff --git a/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestAddingSlides.java b/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestAddingSlides.java
index 4ffeb87894..dd1ccd0b4e 100644
--- a/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestAddingSlides.java
+++ b/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestAddingSlides.java
@@ -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);
- 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.getNotes().length);
assertNull(doc.getSlideSlideListWithText());
assertNull(doc.getNotesSlideListWithText());