poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kiwiwi...@apache.org
Subject svn commit: r1782635 - in /poi: site/src/documentation/content/xdocs/status.xml trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XMLSlideShow.java trunk/src/ooxml/testcases/org/apache/poi/xslf/TestXSLFBugs.java trunk/test-data/slideshow/bug60715.pptx
Date Sat, 11 Feb 2017 21:48:05 GMT
Author: kiwiwings
Date: Sat Feb 11 21:48:05 2017
New Revision: 1782635

URL: http://svn.apache.org/viewvc?rev=1782635&view=rev
Log:
#60715 - Blank layout was not found

Added:
    poi/trunk/test-data/slideshow/bug60715.pptx   (with props)
Modified:
    poi/site/src/documentation/content/xdocs/status.xml
    poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XMLSlideShow.java
    poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/TestXSLFBugs.java

Modified: poi/site/src/documentation/content/xdocs/status.xml
URL: http://svn.apache.org/viewvc/poi/site/src/documentation/content/xdocs/status.xml?rev=1782635&r1=1782634&r2=1782635&view=diff
==============================================================================
--- poi/site/src/documentation/content/xdocs/status.xml (original)
+++ poi/site/src/documentation/content/xdocs/status.xml Sat Feb 11 21:48:05 2017
@@ -58,6 +58,7 @@
 
     <release version="3.16-beta3" date="2017-04-??">
     <actions>
+        <action dev="PD" type="fix" fixes-bug="60715" module="XSLF">Blank layout was
not found</action>
         <action dev="PD" type="add" fixes-bug="59227,github-48" module="SS Common">Support
Chinese and Japanese date formats</action>
         <action dev="PD" type="fix" fixes-bug="59983" module="XSSF">Shift shared formulas
when shifting rows in a sheet</action>
         <action dev="PD" type="fix" fixes-bug="60625" module="SL Common,XSLF,HSLF">Rendering
issue with background and shape overlayed by image</action>

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XMLSlideShow.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XMLSlideShow.java?rev=1782635&r1=1782634&r2=1782635&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XMLSlideShow.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XMLSlideShow.java Sat Feb 11 21:48:05
2017
@@ -72,7 +72,7 @@ import org.openxmlformats.schemas.presen
 @Beta
 public class XMLSlideShow extends POIXMLDocument
 implements SlideShow<XSLFShape,XSLFTextParagraph> {
-    private final static POILogger _logger = POILogFactory.getLogger(XMLSlideShow.class);
+    private static final POILogger LOG = POILogFactory.getLogger(XMLSlideShow.class);
 
     private CTPresentation _presentation;
     private List<XSLFSlide> _slides;
@@ -154,7 +154,7 @@ implements SlideShow<XSLFShape,XSLFTextP
                 for (CTSlideIdListEntry slId : _presentation.getSldIdLst().getSldIdList())
{
                     XSLFSlide sh = shIdMap.get(slId.getId2());
                     if (sh == null) {
-                        _logger.log(POILogger.WARN, "Slide with r:id " + slId.getId() + "
was defined, but didn't exist in package, skipping");
+                        LOG.log(POILogger.WARN, "Slide with r:id " + slId.getId() + " was
defined, but didn't exist in package, skipping");
                         continue;
                     }
                     _slides.add(sh);
@@ -206,8 +206,9 @@ implements SlideShow<XSLFShape,XSLFTextP
     public XSLFSlide createSlide(XSLFSlideLayout layout) {
         int slideNumber = 256, cnt = 1;
         CTSlideIdList slideList;
-        if (!_presentation.isSetSldIdLst()) slideList = _presentation.addNewSldIdLst();
-        else {
+        if (!_presentation.isSetSldIdLst()) {
+            slideList = _presentation.addNewSldIdLst();
+        } else {
             slideList = _presentation.getSldIdLst();
             for(CTSlideIdListEntry slideId : slideList.getSldIdArray()){
                 slideNumber = (int)Math.max(slideId.getId() + 1, slideNumber);
@@ -255,31 +256,39 @@ implements SlideShow<XSLFShape,XSLFTextP
         _slides.add(slide);
         return slide;
     }
-    
+
     /**
      * Create a blank slide using the default (first) master.
      */
     @Override
     public XSLFSlide createSlide() {
-        XSLFSlideLayout layout = _masters.get(0).getLayout(SlideLayout.BLANK);
-        if(layout == null) throw new IllegalArgumentException("Blank layout was not found");
-
+        XSLFSlideMaster sm = _masters.get(0);
+        XSLFSlideLayout layout = sm.getLayout(SlideLayout.BLANK);
+        if (layout == null) {
+            LOG.log(POILogger.WARN, "Blank layout was not found - defaulting to first slide
layout in master");
+            XSLFSlideLayout sl[] = sm.getSlideLayouts();
+            if (sl.length == 0) {
+                throw new POIXMLException("SlideMaster must contain a SlideLayout.");
+            }
+            layout = sl[0];
+        }
+        
         return createSlide(layout);
     }
-    
+
     /**
      * Return notes slide for the specified slide or create new if it does not exist yet.
      */
     public XSLFNotes getNotesSlide(XSLFSlide slide) {
-        
+
         XSLFNotes notesSlide = slide.getNotes();
         if (notesSlide == null) {
             notesSlide = createNotesSlide(slide);
         }
-        
+
         return notesSlide;
-    }    
-    
+    }
+
     /**
      * Create a blank notes slide.
      */
@@ -288,10 +297,10 @@ implements SlideShow<XSLFShape,XSLFTextP
         if (_notesMaster == null) {
             createNotesMaster();
         }
-        
+
         Integer slideIndex = XSLFRelation.SLIDE.getFileNameIndex(slide);
-        
-        // add notes slide to presentation 
+
+        // add notes slide to presentation
         XSLFNotes notesSlide = (XSLFNotes) createRelationship
             (XSLFRelation.NOTES, XSLFFactory.getInstance(), slideIndex);
         // link slide and notes slide with each other
@@ -300,22 +309,22 @@ implements SlideShow<XSLFShape,XSLFTextP
         notesSlide.addRelation(null, XSLFRelation.SLIDE, slide);
 
         notesSlide.importContent(_notesMaster);
-        
+
         return notesSlide;
     }
 
     /**
      * Create a notes master.
-     */ 
+     */
     public void createNotesMaster() {
         RelationPart rp = createRelationship
             (XSLFRelation.NOTES_MASTER, XSLFFactory.getInstance(), 1, false);
         _notesMaster = rp.getDocumentPart();
-        
+
         CTNotesMasterIdList notesMasterIdList = _presentation.addNewNotesMasterIdLst();
         CTNotesMasterIdListEntry notesMasterId = notesMasterIdList.addNewNotesMasterId();
         notesMasterId.setId(rp.getRelationship().getId());
-        
+
         Integer themeIndex = 1;
         // TODO: check if that list can be replaced by idx = Math.max(idx,themeIdx)
         List<Integer> themeIndexList = new ArrayList<Integer>();
@@ -324,7 +333,7 @@ implements SlideShow<XSLFShape,XSLFTextP
                 themeIndexList.add(XSLFRelation.THEME.getFileNameIndex(p));
             }
         }
-         
+
         if (!themeIndexList.isEmpty()) {
             Boolean found = false;
             for (Integer i = 1; i <= themeIndexList.size(); i++) {
@@ -337,20 +346,20 @@ implements SlideShow<XSLFShape,XSLFTextP
                 themeIndex = themeIndexList.size() + 1;
             }
         }
-        
+
         XSLFTheme theme = (XSLFTheme) createRelationship
             (XSLFRelation.THEME, XSLFFactory.getInstance(), themeIndex);
         theme.importTheme(getSlides().get(0).getTheme());
-        
+
         _notesMaster.addRelation(null, XSLFRelation.THEME, theme);
     }
-    
+
     /**
      * Return the Notes Master, if there is one.
-     * (May not be present if no notes exist)  
+     * (May not be present if no notes exist)
      */
     public XSLFNotesMaster getNotesMaster() {
-        return _notesMaster; 
+        return _notesMaster;
     }
 
     @Override
@@ -361,10 +370,11 @@ implements SlideShow<XSLFShape,XSLFTextP
     /**
      * Return all the slides in the slideshow
      */
+    @Override
     public List<XSLFSlide> getSlides() {
         return _slides;
     }
-    
+
     /**
      * Returns the list of comment authors, if there is one.
      * Will only be present if at least one slide has comments on it.
@@ -379,8 +389,12 @@ implements SlideShow<XSLFShape,XSLFTextP
      */
     public void setSlideOrder(XSLFSlide slide, int newIndex){
         int oldIndex = _slides.indexOf(slide);
-        if(oldIndex == -1) throw new IllegalArgumentException("Slide not found");
-        if (oldIndex == newIndex) return;
+        if(oldIndex == -1) {
+            throw new IllegalArgumentException("Slide not found");
+        }
+        if (oldIndex == newIndex) {
+            return;
+        }
 
         // fix the usermodel container
         _slides.add(newIndex, _slides.remove(oldIndex));
@@ -404,7 +418,7 @@ implements SlideShow<XSLFShape,XSLFTextP
          _presentation.getSldIdLst().removeSldId(index);
         return slide;
     }
-    
+
     @Override
     public Dimension getPageSize(){
         CTSlideSize sz = _presentation.getSldSz();
@@ -424,7 +438,7 @@ implements SlideShow<XSLFShape,XSLFTextP
 
     @Internal
     public CTPresentation getCTPresentation(){
-        return _presentation;        
+        return _presentation;
     }
 
     /**
@@ -435,11 +449,14 @@ implements SlideShow<XSLFShape,XSLFTextP
      *
      * @return the picture data
      */
+    @Override
     public XSLFPictureData addPicture(byte[] pictureData, PictureType format) {
         XSLFPictureData img = findPictureData(pictureData);
 
-        if (img != null) return img;
-        
+        if (img != null) {
+            return img;
+        }
+
         int imageNumber = _pictures.size();
         XSLFRelation relType = XSLFPictureData.getRelationForType(format);
         if (relType == null) {
@@ -455,7 +472,7 @@ implements SlideShow<XSLFShape,XSLFTextP
         } catch (IOException e) {
             throw new POIXMLException(e);
         }
-        
+
         return img;
     }
 
@@ -502,7 +519,7 @@ implements SlideShow<XSLFShape,XSLFTextP
 
     /**
      * check if a picture with this picture data already exists in this presentation
-     * 
+     *
      * @param pictureData The picture data to find in the SlideShow
      * @return {@code null} if picture data is not found in this slideshow
      * @since 3.15 beta 2
@@ -560,6 +577,7 @@ implements SlideShow<XSLFShape,XSLFTextP
         throw new UnsupportedOperationException();
     }
 
+    @Override
     public Resources getResources() {
         // TODO: implement!
         throw new UnsupportedOperationException();

Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/TestXSLFBugs.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/TestXSLFBugs.java?rev=1782635&r1=1782634&r2=1782635&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/TestXSLFBugs.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/TestXSLFBugs.java Sat Feb 11 21:48:05
2017
@@ -71,7 +71,7 @@ import org.junit.Test;
 
 public class TestXSLFBugs {
     private static final POIDataSamples slTests = POIDataSamples.getSlideShowInstance();
-    
+
     @Test
     public void bug51187() throws Exception {
        XMLSlideShow ss1 = XSLFTestDataSamples.openSampleDocument("51187.pptx");
@@ -586,4 +586,10 @@ public class TestXSLFBugs {
         return cell;
     }
 
+    @Test
+    public void bug60715() throws IOException {
+        XMLSlideShow ppt = XSLFTestDataSamples.openSampleDocument("bug60715.pptx");
+        ppt.createSlide();
+        ppt.close();
+    }
 }
\ No newline at end of file

Added: poi/trunk/test-data/slideshow/bug60715.pptx
URL: http://svn.apache.org/viewvc/poi/trunk/test-data/slideshow/bug60715.pptx?rev=1782635&view=auto
==============================================================================
Binary file - no diff available.

Propchange: poi/trunk/test-data/slideshow/bug60715.pptx
------------------------------------------------------------------------------
--- svn:mime-type (added)
+++ svn:mime-type Sat Feb 11 21:48:05 2017
@@ -0,0 +1 @@
+application/vnd.openxmlformats-officedocument.presentationml.presentation



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


Mime
View raw message