poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kiwiwi...@apache.org
Subject svn commit: r1831745 - in /poi: site/src/documentation/content/xdocs/ trunk/src/java/org/apache/poi/sl/usermodel/ trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/ trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/ trunk/src/testcases/org/apache...
Date Wed, 16 May 2018 21:57:49 GMT
Author: kiwiwings
Date: Wed May 16 21:57:49 2018
New Revision: 1831745

URL: http://svn.apache.org/viewvc?rev=1831745&view=rev
Log:
#62037 - SlideNames should not be null but have a default as if accessed by VBA

Modified:
    poi/site/src/documentation/content/xdocs/status.xml
    poi/trunk/src/java/org/apache/poi/sl/usermodel/Slide.java
    poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlide.java
    poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlide.java
    poi/trunk/src/testcases/org/apache/poi/sl/usermodel/BaseTestSlideShow.java
    poi/trunk/test-data/slideshow/SampleShow.ppt
    poi/trunk/test-data/slideshow/SampleShow.pptx

Modified: poi/site/src/documentation/content/xdocs/status.xml
URL: http://svn.apache.org/viewvc/poi/site/src/documentation/content/xdocs/status.xml?rev=1831745&r1=1831744&r2=1831745&view=diff
==============================================================================
--- poi/site/src/documentation/content/xdocs/status.xml (original)
+++ poi/site/src/documentation/content/xdocs/status.xml Wed May 16 21:57:49 2018
@@ -68,6 +68,7 @@
         <summary-item>Provide new ooxml-schemas-1.4.jar</summary-item>
       </summary>
       <actions>
+        <action dev="PD" type="add" fixes-bug="62037" module="SL Common">SlideNames
should not be null but have a default as if accessed by VBA</action>
         <action dev="PD" type="fix" fixes-bug="62381" module="SL Common">Fix rendering
of AutoShapes</action>
         <action dev="PD" type="fix" fixes-bug="59893" module="POI Overall">Forbid calls
to InputStream.available</action>
         <action dev="PD" type="fix" fixes-bug="61905" module="HSSF">HSSFWorkbook.setActiveCell()
does not actually make the cell selected in Excel</action>

Modified: poi/trunk/src/java/org/apache/poi/sl/usermodel/Slide.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/sl/usermodel/Slide.java?rev=1831745&r1=1831744&r2=1831745&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/sl/usermodel/Slide.java (original)
+++ poi/trunk/src/java/org/apache/poi/sl/usermodel/Slide.java Wed May 16 21:57:49 2018
@@ -83,4 +83,11 @@ public interface Slide<
      * @since POI 4.0.0
      */
     MasterSheet getSlideLayout();
+
+    /**
+     * @return the slide name, defaults to "Slide[slideNumber]"
+     *
+     * @since POI 4.0.0
+     */
+    String getSlideName();
 }

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlide.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlide.java?rev=1831745&r1=1831744&r2=1831745&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlide.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlide.java Wed May 16 21:57:49
2018
@@ -390,5 +390,11 @@ implements Slide<XSLFShape,XSLFTextParag
     public boolean isHidden() {
         CTSlide sld = getXmlObject();
         return sld.isSetShow() && !sld.getShow();
-    }    
+    }
+
+    @Override
+    public String getSlideName() {
+        final CTCommonSlideData cSld = getXmlObject().getCSld();
+        return cSld.isSetName() ? cSld.getName() : "Slide"+getSlideNumber();
+    }
 }

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlide.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlide.java?rev=1831745&r1=1831744&r2=1831745&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlide.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlide.java Wed May 16 21:57:49
2018
@@ -27,6 +27,7 @@ import org.apache.poi.ddf.EscherDggRecor
 import org.apache.poi.ddf.EscherSpRecord;
 import org.apache.poi.hslf.exceptions.HSLFException;
 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.Comment2000;
 import org.apache.poi.hslf.record.EscherTextboxWrapper;
@@ -231,7 +232,12 @@ public final class HSLFSlide extends HSL
 		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

Modified: poi/trunk/src/testcases/org/apache/poi/sl/usermodel/BaseTestSlideShow.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/sl/usermodel/BaseTestSlideShow.java?rev=1831745&r1=1831744&r2=1831745&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/sl/usermodel/BaseTestSlideShow.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/sl/usermodel/BaseTestSlideShow.java Wed May 16
21:57:49 2018
@@ -159,16 +159,20 @@ public abstract class BaseTestSlideShow
     }
 
     @Test
-    public void shapeName() throws IOException {
+    public void shapeAndSlideName() throws IOException {
         final String file = "SampleShow.ppt"+(getClass().getSimpleName().contains("XML")?"x":"");
-        try (final InputStream is = slTests.openResourceAsStream(file)) {
-            try (final SlideShow<? extends Shape, ?> ppt = SlideShowFactory.create(is))
{
-                final List<? extends Shape> shapes1 = ppt.getSlides().get(0).getShapes();
-                assertEquals("The Title", shapes1.get(0).getShapeName());
-                assertEquals("Another Subtitle", shapes1.get(1).getShapeName());
-                final List<? extends Shape> shapes2 = ppt.getSlides().get(1).getShapes();
-                assertEquals("Title 1", shapes2.get(0).getShapeName());
-                assertEquals("Content Placeholder 2", shapes2.get(1).getShapeName());
+        try (final InputStream is = slTests.openResourceAsStream(file);
+             final SlideShow<? extends Shape, ?> ppt = SlideShowFactory.create(is))
{
+            final List<? extends Shape> shapes1 = ppt.getSlides().get(0).getShapes();
+            assertEquals("The Title", shapes1.get(0).getShapeName());
+            assertEquals("Another Subtitle", shapes1.get(1).getShapeName());
+            final List<? extends Shape> shapes2 = ppt.getSlides().get(1).getShapes();
+            assertEquals("Title 1", shapes2.get(0).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());
             }
         }
     }

Modified: poi/trunk/test-data/slideshow/SampleShow.ppt
URL: http://svn.apache.org/viewvc/poi/trunk/test-data/slideshow/SampleShow.ppt?rev=1831745&r1=1831744&r2=1831745&view=diff
==============================================================================
Binary files - no diff available.

Modified: poi/trunk/test-data/slideshow/SampleShow.pptx
URL: http://svn.apache.org/viewvc/poi/trunk/test-data/slideshow/SampleShow.pptx?rev=1831745&r1=1831744&r2=1831745&view=diff
==============================================================================
Binary files - no diff available.



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org


Mime
View raw message