]> source.dussan.org Git - poi.git/commitdiff
Bug 60512: Add missing XSSFRelation.CUSTOM_PROPERTY
authorDominik Stadler <centic@apache.org>
Fri, 30 Dec 2016 16:55:19 +0000 (16:55 +0000)
committerDominik Stadler <centic@apache.org>
Fri, 30 Dec 2016 16:55:19 +0000 (16:55 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1776606 13f79535-47bb-0310-9956-ffa450edef68

src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFRelation.java
src/ooxml/testcases/org/apache/poi/xssf/TestXSSFCloneSheet.java
test-data/spreadsheet/60512.xlsm [new file with mode: 0644]

index 0f8b7b32b691c2418eaea9bdc476418f45a702fc..204f1cd4b018d4b40fcc8f4bc89445a4e23adc58 100644 (file)
@@ -351,7 +351,14 @@ public final class XSSFRelation extends POIXMLRelation {
             "/xl/ctrlProps/ctrlProp#.xml",
             null
     );
-    
+
+    public static final XSSFRelation CUSTOM_PROPERTIES = new XSSFRelation(
+            "application/vnd.openxmlformats-officedocument.spreadsheetml.customProperty",
+            "http://schemas.openxmlformats.org/officeDocument/2006/relationships/customProperty",
+            "/xl/customProperty#.bin",
+            null
+    );
+
     public static final String NS_SPREADSHEETML = "http://schemas.openxmlformats.org/spreadsheetml/2006/main";
     public static final String NS_DRAWINGML = "http://schemas.openxmlformats.org/drawingml/2006/main";
     public static final String NS_CHART = "http://schemas.openxmlformats.org/drawingml/2006/chart";
@@ -387,7 +394,7 @@ public final class XSSFRelation extends POIXMLRelation {
      *    <code>http://schemas.openxmlformats.org/officeDocument/2006/relationships/image</code>
      * @return registered POIXMLRelation or null if not found
      */
-    public static XSSFRelation getInstance(String rel){
+    public static XSSFRelation getInstance(String rel) {
         return _table.get(rel);
     }
 }
index 91883a3dfabbdebd61158ec913b1eb0ad690d7d8..36f7ef0198d178b47bf77a31b59a948cb332baa1 100644 (file)
 package org.apache.poi.xssf;\r
 \r
 import static org.junit.Assert.assertEquals;\r
+import static org.junit.Assert.assertNotNull;\r
 import static org.junit.Assert.fail;\r
 \r
 import org.apache.poi.hssf.HSSFITestDataProvider;\r
 import org.apache.poi.ss.usermodel.BaseTestCloneSheet;\r
+import org.apache.poi.ss.usermodel.Sheet;\r
+import org.apache.poi.ss.usermodel.Workbook;\r
 import org.apache.poi.xssf.usermodel.XSSFSheet;\r
 import org.apache.poi.xssf.usermodel.XSSFWorkbook;\r
 import org.junit.Before;\r
 import org.junit.Test;\r
 \r
+import java.io.FileOutputStream;\r
+import java.io.IOException;\r
+import java.io.OutputStream;\r
+\r
 public class TestXSSFCloneSheet  extends BaseTestCloneSheet {\r
     public TestXSSFCloneSheet() {\r
         super(HSSFITestDataProvider.instance);\r
@@ -59,4 +66,28 @@ public class TestXSSFCloneSheet  extends BaseTestCloneSheet {
         }\r
         assertEquals(1, wb.getNumberOfSheets());\r
     }\r
+\r
+    @Test\r
+    public void test60512() throws IOException {\r
+        XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("60512.xlsm");\r
+\r
+        assertEquals(1, wb.getNumberOfSheets());\r
+        Sheet sheet = wb.cloneSheet(0);\r
+        assertNotNull(sheet);\r
+        assertEquals(2, wb.getNumberOfSheets());\r
+\r
+\r
+        Workbook wbBack = XSSFTestDataSamples.writeOutAndReadBack(wb);\r
+        assertNotNull(wbBack);\r
+        wbBack.close();\r
+\r
+        OutputStream str = new FileOutputStream("/tmp/60512.xlsx");\r
+        try {\r
+            wb.write(str);\r
+        } finally {\r
+            str.close();\r
+        }\r
+\r
+        wb.close();\r
+    }\r
 }\r
diff --git a/test-data/spreadsheet/60512.xlsm b/test-data/spreadsheet/60512.xlsm
new file mode 100644 (file)
index 0000000..7c38c6d
Binary files /dev/null and b/test-data/spreadsheet/60512.xlsm differ