]> source.dussan.org Git - poi.git/commitdiff
#59268 - Work on providing an updated version of XMLBeans
authorAndreas Beeker <kiwiwings@apache.org>
Fri, 22 Jun 2018 21:25:00 +0000 (21:25 +0000)
committerAndreas Beeker <kiwiwings@apache.org>
Fri, 22 Jun 2018 21:25:00 +0000 (21:25 +0000)
(imported from https://github.com/apache/poi/pull/113)

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1834165 13f79535-47bb-0310-9956-ffa450edef68

.classpath
build.gradle
build.xml
maven/poi-ooxml-schemas.pom
sonar/pom.xml
src/integrationtest/build.xml
src/ooxml/testcases/org/apache/poi/xssf/streaming/TestSXSSFUnicodeSurrogates.java [new file with mode: 0644]
src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFUnicodeSurrogates.java [new file with mode: 0644]

index 944cd2142bf82d04ba4253aea299cd2ca1de7c97..e312554be149c2ce469a8b52546cb73e8744f8cc 100644 (file)
@@ -18,7 +18,7 @@
        <classpathentry kind="lib" path="lib/ant-1.10.1.jar"/>
        <classpathentry kind="lib" path="lib/ant-launcher-1.10.1.jar"/>
        <classpathentry kind="lib" path="lib/log4j-1.2.17.jar"/>
-       <classpathentry exported="true" kind="lib" path="ooxml-lib/xmlbeans-2.6.0.jar" sourcepath="ooxml-lib/xmlbeans-2.6.0.jar"/>
+       <classpathentry exported="true" kind="lib" path="ooxml-lib/xmlbeans-3.0.0.jar" sourcepath="ooxml-lib/xmlbeans-3.0.0.jar"/>
        <classpathentry kind="lib" path="lib/hamcrest-core-1.3.jar"/>
        <classpathentry kind="lib" path="lib/junit-4.12.jar"/>
        <classpathentry kind="lib" path="ooxml-lib/curvesapi-1.05.jar"/>
index 1f32f6e2dcdb76bbd1e22ad07b1ebe751c7f1985..01aa775e681ef163000b00c0a672f8ad7d193bee 100644 (file)
@@ -25,6 +25,12 @@ buildscript {
     }
 }
 
+repositories {
+    maven { url "https://repository.apache.org/content/repositories/staging" }
+    mavenCentral()
+}
+
+
 // Only add the plugin for Sonar if enabled
 if (project.hasProperty('enableSonar')) {
     println 'Enabling Sonar support'
@@ -189,7 +195,7 @@ project('ooxml') {
     compileJava.dependsOn 'ant-compile-ooxml-xsds'
 
     dependencies {
-        compile 'org.apache.xmlbeans:xmlbeans:2.6.0'
+        compile 'org.apache.xmlbeans:xmlbeans:3.0.0'
         compile 'org.apache.commons:commons-collections4:4.1'
         compile 'org.apache.commons:commons-math3:3.6.1'
         compile 'org.apache.commons:commons-compress:1.17'
index c70c4b3099b1c13dd584d561334d29aa6774dcd5..0465da74a89bfaf933f675d1643e3e9fa9c5c52a 100644 (file)
--- a/build.xml
+++ b/build.xml
@@ -199,9 +199,9 @@ under the License.
     <property name="ooxml.curvesapi.jar" location="${ooxml.lib}/curvesapi-1.05.jar"/>
     <property name="ooxml.curvesapi.url"
               value="${repository.m2}/maven2/com/github/virtuald/curvesapi/1.05/curvesapi-1.05.jar"/>
-    <property name="ooxml.xmlbeans.jar" location="${ooxml.lib}/xmlbeans-2.6.0.jar"/>
+    <property name="ooxml.xmlbeans.jar" location="${ooxml.lib}/xmlbeans-3.0.0.jar"/>
     <property name="ooxml.xmlbeans.url"
-              value="${repository.m2}/maven2/org/apache/xmlbeans/xmlbeans/2.6.0/xmlbeans-2.6.0.jar"/>
+              value="https://repository.apache.org/content/repositories/staging/org/apache/xmlbeans/xmlbeans/3.0.0/xmlbeans-3.0.0.jar"/>
     <property name="ooxml.commons-compress.jar" location="${main.lib}/commons-compress-1.17.jar"/>
     <property name="ooxml.commons-compress.url"
               value="${repository.m2}/maven2/org/apache/commons/commons-compress/1.17/commons-compress-1.17.jar"/>
@@ -624,7 +624,7 @@ under the License.
                 <include name="ooxml-security-1.0.jar"/>
                 <include name="curvesapi-1.03.jar"/>
                 <include name="curvesapi-1.04.jar"/>
-                <include name="xmlbeans-2.3.0.jar*"/>
+                <include name="xmlbeans-2.*.jar*"/>
             </fileset>
             <fileset dir="${compile.lib}">
                 <include name="xercesImpl-*.jar"/>
@@ -729,12 +729,8 @@ under the License.
     <target name="fetch-ooxml-jars" depends="check-ooxml-jars" unless="ooxml.jars.present">
         <mkdir dir="${ooxml.lib}"/>
         <downloadfile src="${ooxml.curvesapi.url}" dest="${ooxml.curvesapi.jar}"/>
-        <downloadfile src="${ooxml.xmlbeans.url}" dest="${ooxml.xmlbeans.jar}.orig"/>
+        <downloadfile src="${ooxml.xmlbeans.url}" dest="${ooxml.xmlbeans.jar}"/>
         <downloadfile src="${ooxml.commons-compress.url}" dest="${ooxml.commons-compress.jar}"/>
-        <!-- remove piccolo parser, so we don't use unsafe calls to it instead of using jaxp -->
-        <zip destfile="${ooxml.xmlbeans.jar}">
-            <zipfileset src="${ooxml.xmlbeans.jar}.orig" excludes="org/apache/xmlbeans/impl/piccolo/**"/>
-        </zip>
     </target>
     <target name="check-svn-jars">
         <condition property="svn.jars.present">
@@ -840,7 +836,7 @@ under the License.
 
             <taskdef name="xmlbean"
                      classname="org.apache.xmlbeans.impl.tool.XMLBean"
-                     classpath="${ooxml.xmlbeans.jar}.orig"/>
+                     classpath="${ooxml.xmlbeans.jar}"/>
 
             <property name="xmlbean.xsds.dir" location="build/xmlbean-xsds"/>
             <property name="xmlbean.sources.dir" location="build/xmlbean-sources"/>
@@ -871,7 +867,7 @@ under the License.
                     nopvr="@{nopvr}"
                     >
                 <classpath>
-                    <path location="${ooxml.xmlbeans.jar}.orig"/>
+                    <path location="${ooxml.xmlbeans.jar}"/>
                 </classpath>
             </xmlbean>
 
@@ -1954,8 +1950,8 @@ under the License.
                 <globmapper from="*" to="${zipdir}/lib/*"/>
             </mappedresources>
             <mappedresources cache="true">
-                <fileset dir="${ooxml.lib}" includes="xmlbeans-2.6.0.jar.orig,curvesapi-*.jar"/>
-                <regexpmapper from="^(.*\.jar)(\.orig)?$$" to="${zipdir}/ooxml-lib/\1"/>
+                <fileset dir="${ooxml.lib}" includes="xmlbeans-3.0.0.jar,curvesapi-*.jar"/>
+                <regexpmapper from="^(.*\.jar)$$" to="${zipdir}/ooxml-lib/\1"/>
             </mappedresources>
             <mappedresources cache="true">
                 <fileset dir="${dist.dir}/maven" includes="**/*.jar" excludes="**/*-javadoc.jar,**/*-sources.jar"/>
index baf531d542c401dd05f9609c988b12b2b79aa1b0..295eeab9b04aca39553f15d4314dc006e7f53fd7 100644 (file)
@@ -62,7 +62,7 @@
     <dependency>
       <groupId>org.apache.xmlbeans</groupId>
       <artifactId>xmlbeans</artifactId>
-      <version>2.6.0</version>
+      <version>3.0.0</version>
     </dependency>
   </dependencies>
 </project>
index 81b000c761e8a7bdc30993649ea5e58bf888ccde..f201c7b49d8fc6ddd03a30e3ed4105576546b675 100644 (file)
@@ -63,7 +63,7 @@
                <sonar.scm.disabled>true</sonar.scm.disabled>
 
                <!-- define some of the third-party or plugin-versions globally to use the same in all modules -->
-               <xmlbeans.version>2.6.0</xmlbeans.version>
+               <xmlbeans.version>3.0.0</xmlbeans.version>
                <junit.version>4.12</junit.version>
                <xmlunit.version>2.5.1</xmlunit.version>
                <mockito.version>2.13.0</mockito.version>
index 4d29baea5dfc9b69c6a368a87768e305dc53a9f8..26bd57e108051d9ad92685d83fffa082c669f6c2 100644 (file)
@@ -119,8 +119,8 @@ Before running this, you should execute the "assemble" target in the main build.
             </fileset>
             <fileset dir="../../ooxml-lib">
                 <include name="ooxml-schemas-*.jar"/>
-                <include name="xmlbeans-*.jar"/>
-                <exclude name="xmlbeans-2.3.*.jar"/>
+                <include name="xmlbeans-3.*.jar"/>
+                <exclude name="xmlbeans-2.*.jar"/>
             </fileset>
         </path>
 
diff --git a/src/ooxml/testcases/org/apache/poi/xssf/streaming/TestSXSSFUnicodeSurrogates.java b/src/ooxml/testcases/org/apache/poi/xssf/streaming/TestSXSSFUnicodeSurrogates.java
new file mode 100644 (file)
index 0000000..9346235
--- /dev/null
@@ -0,0 +1,42 @@
+package org.apache.poi.xssf.streaming;
+
+import org.apache.poi.ss.usermodel.Cell;
+import org.apache.poi.ss.usermodel.Row;
+import org.apache.poi.ss.usermodel.Sheet;
+import org.apache.poi.util.TempFile;
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
+import org.junit.Assert;
+import org.junit.Test;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+
+public class TestSXSSFUnicodeSurrogates {
+
+    private static String unicodeText = "𝝊𝝋𝝌𝝍𝝎𝝏𝝐𝝑𝝒𝝓𝝔𝝕𝝖𝝗𝝘𝝙𝝚𝝛𝝜𝝝𝝞𝝟𝝠𝝡𝝢𝝣𝝤𝝥𝝦𝝧𝝨𝝩𝝪𝝫𝝬𝝭𝝮𝝯𝝰𝝱𝝲𝝳𝝴𝝵𝝶𝝷𝝸𝝹𝝺";
+
+    @Test
+    public void testWriteUnicodeSurrogates() throws IOException {
+        String sheetName = "Sheet1";
+        File tf = TempFile.createTempFile("poi-xmlbeans-test", ".xlsx");
+        try (SXSSFWorkbook wb = new SXSSFWorkbook()) {
+            Sheet sheet = wb.createSheet(sheetName);
+            Row row = sheet.createRow(0);
+            Cell cell = row.createCell(0);
+            cell.setCellValue(unicodeText);
+            try (FileOutputStream os = new FileOutputStream(tf)) {
+                wb.write(os);
+            }
+            try (FileInputStream fis = new FileInputStream(tf);
+                 XSSFWorkbook wb2 = new XSSFWorkbook(fis)) {
+                Sheet sheet2 = wb2.getSheet(sheetName);
+                Cell cell2 = sheet2.getRow(0).getCell(0);
+                Assert.assertEquals(unicodeText, cell2.getStringCellValue());
+            }
+        } finally {
+            tf.delete();
+        }
+    }
+}
diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFUnicodeSurrogates.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFUnicodeSurrogates.java
new file mode 100644 (file)
index 0000000..d4d7369
--- /dev/null
@@ -0,0 +1,42 @@
+package org.apache.poi.xssf.usermodel;
+
+import org.apache.poi.ss.usermodel.Cell;
+import org.apache.poi.ss.usermodel.Row;
+import org.apache.poi.ss.usermodel.Sheet;
+import org.apache.poi.util.TempFile;
+import org.junit.Assert;
+import org.junit.Test;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+
+public class TestXSSFUnicodeSurrogates {
+
+    private static String unicodeText = "𝝊𝝋𝝌𝝍𝝎𝝏𝝐𝝑𝝒𝝓𝝔𝝕𝝖𝝗𝝘𝝙𝝚𝝛𝝜𝝝𝝞𝝟𝝠𝝡𝝢𝝣𝝤𝝥𝝦𝝧𝝨𝝩𝝪𝝫𝝬𝝭𝝮𝝯𝝰𝝱𝝲𝝳𝝴𝝵𝝶𝝷𝝸𝝹𝝺";
+
+    @Test
+    public void testWriteUnicodeSurrogates() throws IOException {
+        String sheetName = "Sheet1";
+        File tf = TempFile.createTempFile("poi-xmlbeans-test", ".xlsx");
+        try (XSSFWorkbook wb = new XSSFWorkbook()) {
+            Sheet sheet = wb.createSheet(sheetName);
+            Row row = sheet.createRow(0);
+            Cell cell = row.createCell(0);
+            cell.setCellValue(unicodeText);
+            try (FileOutputStream os = new FileOutputStream(tf)) {
+                wb.write(os);
+            }
+            try (FileInputStream fis = new FileInputStream(tf);
+                 XSSFWorkbook wb2 = new XSSFWorkbook(fis)) {
+                Sheet sheet2 = wb2.getSheet(sheetName);
+                Cell cell2 = sheet2.getRow(0).getCell(0);
+                Assert.assertEquals(unicodeText, cell2.getStringCellValue());
+            }
+        } finally {
+            tf.delete();
+        }
+    }
+}
+