poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cen...@apache.org
Subject svn commit: r1665959 - in /poi/trunk/src/ooxml: java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java
Date Wed, 11 Mar 2015 18:24:49 GMT
Author: centic
Date: Wed Mar 11 18:24:49 2015
New Revision: 1665959

URL: http://svn.apache.org/r1665959
Log:
Bug 56467: Fix cloning of sheets with pictures

Modified:
    poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java
    poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java?rev=1665959&r1=1665958&r2=1665959&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java Wed Mar 11 18:24:49
2015
@@ -576,13 +576,17 @@ public class XSSFWorkbook extends POIXML
             // copy drawing contents
             clonedDg.getCTDrawing().set(dg.getCTDrawing());
 
+            clonedDg = clonedSheet.createDrawingPatriarch();
+            
             // Clone drawing relations
             List<POIXMLDocumentPart> srcRels = srcSheet.createDrawingPatriarch().getRelations();
             for (POIXMLDocumentPart rel : srcRels) {
                 PackageRelationship relation = rel.getPackageRelationship();
-                clonedSheet
-                        .createDrawingPatriarch()
-                        .getPackagePart()
+
+                clonedDg.addRelation(relation.getId(), rel);
+                
+                clonedDg
+						.getPackagePart()
                         .addRelationship(relation.getTargetURI(), relation.getTargetMode(),
                                 relation.getRelationshipType(), relation.getId());
             }

Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java?rev=1665959&r1=1665958&r2=1665959&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java Wed Mar
11 18:24:49 2015
@@ -31,6 +31,7 @@ import java.io.File;
 import java.io.FileInputStream;
 import java.io.FileOutputStream;
 import java.io.IOException;
+import java.io.OutputStream;
 import java.util.Calendar;
 import java.util.List;
 
@@ -2262,4 +2263,31 @@ public final class TestXSSFBugs extends
             wb.close();
         }
     }
+    
+    @Test
+    public void test56467() throws IOException {
+        Workbook wb = XSSFTestDataSamples.openSampleWorkbook("picture.xlsx");
+        try {
+            Sheet orig = wb.getSheetAt(0);
+            assertNotNull(orig);
+            
+            Sheet sheet = wb.cloneSheet(0);
+            Drawing drawing = sheet.createDrawingPatriarch();
+            for (XSSFShape shape : ((XSSFDrawing) drawing).getShapes()) {
+                if (shape instanceof XSSFPicture) {
+                    XSSFPictureData pictureData = ((XSSFPicture) shape).getPictureData();
+                    assertNotNull(pictureData);
+                }
+            }
+            
+//            OutputStream out = new FileOutputStream("/tmp/56467.xls");
+//            try {
+//            	wb.write(out);
+//            } finally {
+//            	out.close();
+//            }
+        } finally {
+        	wb.close();
+        }
+    }
 }



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


Mime
View raw message