poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kiwiwi...@apache.org
Subject svn commit: r1694592 - 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
Date Fri, 07 Aug 2015 00:17:55 GMT
Author: kiwiwings
Date: Fri Aug  7 00:17:55 2015
New Revision: 1694592

URL: http://svn.apache.org/r1694592
Log:
#58205 - getSlideMasters() returns the master slides in the incorrect order

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=1694592&r1=1694591&r2=1694592&view=diff
==============================================================================
--- poi/site/src/documentation/content/xdocs/status.xml (original)
+++ poi/site/src/documentation/content/xdocs/status.xml Fri Aug  7 00:17:55 2015
@@ -39,6 +39,7 @@
     </devs>
 
     <release version="3.13-beta2" date="2015-10-??">
+        <action dev="PD" type="fix" fixes-bug="58205">getSlideMasters() returns the
master slides in the incorrect order</action>
         <action dev="PD" type="fix" fixes-bug="57786">XSLFFreeformShape ignores quadratic
bezier curves</action>
         <action dev="PD" type="fix" fixes-bug="58206">provide a mechanism to find slide
layouts by name</action>
         <action dev="PD" type="fix" fixes-bug="58204">STYLE: ShapeContainer interface
makes internal getShapesList() redundant</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=1694592&r1=1694591&r2=1694592&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 Fri Aug  7 00:17:55
2015
@@ -57,6 +57,7 @@ import org.openxmlformats.schemas.presen
 import org.openxmlformats.schemas.presentationml.x2006.main.CTPresentation;
 import org.openxmlformats.schemas.presentationml.x2006.main.CTSlideIdList;
 import org.openxmlformats.schemas.presentationml.x2006.main.CTSlideIdListEntry;
+import org.openxmlformats.schemas.presentationml.x2006.main.CTSlideMasterIdListEntry;
 import org.openxmlformats.schemas.presentationml.x2006.main.CTSlideSize;
 import org.openxmlformats.schemas.presentationml.x2006.main.PresentationDocument;
 
@@ -72,7 +73,7 @@ public class XMLSlideShow extends POIXML
 
     private CTPresentation _presentation;
     private List<XSLFSlide> _slides;
-    private Map<String, XSLFSlideMaster> _masters;
+    private List<XSLFSlideMaster> _masters;
     private List<XSLFPictureData> _pictures;
     private XSLFTableStyles _tableStyles;
     private XSLFNotesMaster _notesMaster;
@@ -120,21 +121,19 @@ public class XMLSlideShow extends POIXML
     }
 
     @Override
-    @SuppressWarnings("deprecation")
     protected void onDocumentRead() throws IOException {
         try {
             PresentationDocument doc =
                     PresentationDocument.Factory.parse(getCorePart().getInputStream());
             _presentation = doc.getPresentation();
-            Map<String, XSLFSlide> shIdMap = new HashMap<String, XSLFSlide>();
 
-            _masters = new HashMap<String, XSLFSlideMaster>();
+            Map<String, XSLFSlideMaster> masterMap = new HashMap<String, XSLFSlideMaster>();
+            Map<String, XSLFSlide> shIdMap = new HashMap<String, XSLFSlide>();
             for (POIXMLDocumentPart p : getRelations()) {
                 if (p instanceof XSLFSlide) {
                     shIdMap.put(p.getPackageRelationship().getId(), (XSLFSlide) p);
                 } else if (p instanceof XSLFSlideMaster) {
-                    XSLFSlideMaster master = (XSLFSlideMaster)p;
-                    _masters.put(p.getPackageRelationship().getId(), master);
+                    masterMap.put(getRelationId(p), (XSLFSlideMaster) p);
                 } else if (p instanceof XSLFTableStyles){
                     _tableStyles = (XSLFTableStyles)p;
                 } else if (p instanceof XSLFNotesMaster) {
@@ -144,9 +143,15 @@ public class XMLSlideShow extends POIXML
                 }
             }
 
-            _slides = new ArrayList<XSLFSlide>();
+            _masters = new ArrayList<XSLFSlideMaster>(masterMap.size());
+            for (CTSlideMasterIdListEntry masterId : _presentation.getSldMasterIdLst().getSldMasterIdList())
{
+                XSLFSlideMaster master = masterMap.get(masterId.getId2());
+                _masters.add(master);
+            }
+
+            _slides = new ArrayList<XSLFSlide>(shIdMap.size());
             if (_presentation.isSetSldIdLst()) {
-                for (CTSlideIdListEntry slId : _presentation.getSldIdLst().getSldIdArray())
{
+                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");
@@ -239,13 +244,11 @@ public class XMLSlideShow extends POIXML
     }
     
     /**
-     * Create a blank slide.
+     * Create a blank slide using the default (first) master.
      */
+    @Override
     public XSLFSlide createSlide() {
-        String masterId = _presentation.getSldMasterIdLst().getSldMasterIdArray(0).getId2();
-        XSLFSlideMaster master = _masters.get(masterId);
-
-        XSLFSlideLayout layout = master.getLayout(SlideLayout.BLANK);
+        XSLFSlideLayout layout = _masters.get(0).getLayout(SlideLayout.BLANK);
         if(layout == null) throw new IllegalArgumentException("Blank layout was not found");
 
         return createSlide(layout);
@@ -350,7 +353,7 @@ public class XMLSlideShow extends POIXML
 
     @Override
     public List<XSLFSlideMaster> getSlideMasters() {
-        return new ArrayList<XSLFSlideMaster>(_masters.values());
+        return _masters;
     }
 
     /**

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=1694592&r1=1694591&r2=1694592&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 Fri Aug  7 00:17:55
2015
@@ -30,6 +30,7 @@ import java.awt.geom.AffineTransform;
 import java.awt.geom.Rectangle2D;
 import java.awt.image.BufferedImage;
 import java.io.File;
+import java.io.IOException;
 import java.net.URI;
 import java.util.List;
 
@@ -47,6 +48,7 @@ import org.apache.poi.xslf.usermodel.XSL
 import org.apache.poi.xslf.usermodel.XSLFShape;
 import org.apache.poi.xslf.usermodel.XSLFSlide;
 import org.apache.poi.xslf.usermodel.XSLFSlideLayout;
+import org.apache.poi.xslf.usermodel.XSLFSlideMaster;
 import org.junit.Ignore;
 import org.junit.Test;
 
@@ -337,8 +339,8 @@ public class TestXSLFBugs {
         
         
         // Save and re-load
-        ss = XSLFTestDataSamples.writeOutAndReadBack(ss);
-        slide = ss.getSlides().get(0);
+        XMLSlideShow ss2 = XSLFTestDataSamples.writeOutAndReadBack(ss);
+        slide = ss2.getSlides().get(0);
         
         // Check the 15 individual ones added
         for (int i=0; i<15; i++) {
@@ -353,14 +355,17 @@ public class TestXSLFBugs {
         assertArrayEquals(pics[3], shape.getPictureData().getData());
         
         // Add another duplicate
-        data = ss.addPicture(pics[5], PictureType.JPEG);
+        data = ss2.addPicture(pics[5], PictureType.JPEG);
         assertEquals(5, data.getIndex());
-        assertEquals(15, ss.getAllPictures().size());
+        assertEquals(15, ss2.getAllPictures().size());
         
         shape = slide.createPicture(data);
         assertNotNull(shape.getPictureData());
         assertArrayEquals(pics[5], shape.getPictureData().getData());
         assertEquals(18, slide.getShapes().size());
+        
+        ss2.close();
+        ss.close();
     }
 
     private void validateSlides(XMLSlideShow ss, boolean saveAndReload, String... slideTexts)
{
@@ -379,4 +384,16 @@ public class TestXSLFBugs {
         assertEquals(expected.getContentType(), relation.getPackagePart().getContentType());
         assertEquals(expected.getFileName(expected.getFileNameIndex(relation)), relation.getPackagePart().getPartName().getName());
     }
+    
+    @Test
+    public void bug58205() throws IOException {
+        XMLSlideShow ss = XSLFTestDataSamples.openSampleDocument("themes.pptx");
+       
+        int i = 1;
+        for (XSLFSlideMaster sm : ss.getSlideMasters()) {
+            assertEquals("rId"+(i++), ss.getRelationId(sm));
+        }
+        
+        ss.close();
+    }
 }



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


Mime
View raw message