mirror of https://github.com/apache/poi.git
#62037 - SlideNames should not be null but have a default as if accessed by VBA
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1831745 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
e371ce46cc
commit
4a3ea104fe
|
@ -83,4 +83,11 @@ public interface Slide<
|
||||||
* @since POI 4.0.0
|
* @since POI 4.0.0
|
||||||
*/
|
*/
|
||||||
MasterSheet getSlideLayout();
|
MasterSheet getSlideLayout();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the slide name, defaults to "Slide[slideNumber]"
|
||||||
|
*
|
||||||
|
* @since POI 4.0.0
|
||||||
|
*/
|
||||||
|
String getSlideName();
|
||||||
}
|
}
|
||||||
|
|
|
@ -391,4 +391,10 @@ implements Slide<XSLFShape,XSLFTextParagraph> {
|
||||||
CTSlide sld = getXmlObject();
|
CTSlide sld = getXmlObject();
|
||||||
return sld.isSetShow() && !sld.getShow();
|
return sld.isSetShow() && !sld.getShow();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getSlideName() {
|
||||||
|
final CTCommonSlideData cSld = getXmlObject().getCSld();
|
||||||
|
return cSld.isSetName() ? cSld.getName() : "Slide"+getSlideNumber();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,7 @@ import org.apache.poi.ddf.EscherDggRecord;
|
||||||
import org.apache.poi.ddf.EscherSpRecord;
|
import org.apache.poi.ddf.EscherSpRecord;
|
||||||
import org.apache.poi.hslf.exceptions.HSLFException;
|
import org.apache.poi.hslf.exceptions.HSLFException;
|
||||||
import org.apache.poi.hslf.model.HeadersFooters;
|
import org.apache.poi.hslf.model.HeadersFooters;
|
||||||
|
import org.apache.poi.hslf.record.CString;
|
||||||
import org.apache.poi.hslf.record.ColorSchemeAtom;
|
import org.apache.poi.hslf.record.ColorSchemeAtom;
|
||||||
import org.apache.poi.hslf.record.Comment2000;
|
import org.apache.poi.hslf.record.Comment2000;
|
||||||
import org.apache.poi.hslf.record.EscherTextboxWrapper;
|
import org.apache.poi.hslf.record.EscherTextboxWrapper;
|
||||||
|
@ -231,7 +232,12 @@ public final class HSLFSlide extends HSLFSheet implements Slide<HSLFShape,HSLFTe
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Simple Accesser methods follow
|
@Override
|
||||||
|
public String getSlideName() {
|
||||||
|
final CString name = (CString)getSlideRecord().findFirstOfType(RecordTypes.CString.typeID);
|
||||||
|
return name != null ? name.getText() : "Slide"+getSlideNumber();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an array of all the TextRuns found
|
* Returns an array of all the TextRuns found
|
||||||
|
|
|
@ -159,16 +159,20 @@ public abstract class BaseTestSlideShow {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void shapeName() throws IOException {
|
public void shapeAndSlideName() throws IOException {
|
||||||
final String file = "SampleShow.ppt"+(getClass().getSimpleName().contains("XML")?"x":"");
|
final String file = "SampleShow.ppt"+(getClass().getSimpleName().contains("XML")?"x":"");
|
||||||
try (final InputStream is = slTests.openResourceAsStream(file)) {
|
try (final InputStream is = slTests.openResourceAsStream(file);
|
||||||
try (final SlideShow<? extends Shape, ?> ppt = SlideShowFactory.create(is)) {
|
final SlideShow<? extends Shape, ?> ppt = SlideShowFactory.create(is)) {
|
||||||
final List<? extends Shape> shapes1 = ppt.getSlides().get(0).getShapes();
|
final List<? extends Shape> shapes1 = ppt.getSlides().get(0).getShapes();
|
||||||
assertEquals("The Title", shapes1.get(0).getShapeName());
|
assertEquals("The Title", shapes1.get(0).getShapeName());
|
||||||
assertEquals("Another Subtitle", shapes1.get(1).getShapeName());
|
assertEquals("Another Subtitle", shapes1.get(1).getShapeName());
|
||||||
final List<? extends Shape> shapes2 = ppt.getSlides().get(1).getShapes();
|
final List<? extends Shape> shapes2 = ppt.getSlides().get(1).getShapes();
|
||||||
assertEquals("Title 1", shapes2.get(0).getShapeName());
|
assertEquals("Title 1", shapes2.get(0).getShapeName());
|
||||||
assertEquals("Content Placeholder 2", shapes2.get(1).getShapeName());
|
assertEquals("Content Placeholder 2", shapes2.get(1).getShapeName());
|
||||||
|
|
||||||
|
for (final Slide<?,?> slide : ppt.getSlides()) {
|
||||||
|
final String expected = slide.getSlideNumber()==1 ? "FirstSlide" : "Slide2";
|
||||||
|
assertEquals(expected, slide.getSlideName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue