mirror of
https://github.com/apache/poi.git
synced 2025-03-06 17:09:08 +00:00
merge trunk
git-svn-id: https://svn.apache.org/repos/asf/poi/branches/hemf@1840324 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
commit
24f14e2494
@ -91,9 +91,9 @@ subprojects {
|
||||
// See https://github.com/melix/japicmp-gradle-plugin
|
||||
apply plugin: 'me.champeau.gradle.japicmp'
|
||||
|
||||
version = '4.0.0-SNAPSHOT'
|
||||
version = '4.0.1-SNAPSHOT'
|
||||
ext {
|
||||
japicmpversion = '3.17'
|
||||
japicmpversion = '4.0.0'
|
||||
}
|
||||
|
||||
tasks.withType(JavaCompile) {
|
||||
|
131
build.xml
131
build.xml
@ -42,7 +42,7 @@ under the License.
|
||||
|
||||
<description>The Apache POI project Ant build.</description>
|
||||
|
||||
<property name="version.id" value="4.0.1-beta1"/>
|
||||
<property name="version.id" value="4.0.1-SNAPSHOT"/>
|
||||
<property name="release.rc" value="RC1"/>
|
||||
|
||||
<property environment="env"/>
|
||||
@ -552,7 +552,6 @@ under the License.
|
||||
|
||||
<scriptdef name="release_tag" language="javascript">
|
||||
var rel = ("REL_"+project.getProperty("version.id")).toUpperCase().replace(/\W/g,"_");
|
||||
if (rel.search(/BETA/) == -1) rel += "_FINAL";
|
||||
project.setProperty("RELEASE_TAG", rel);
|
||||
</scriptdef>
|
||||
<release_tag/>
|
||||
@ -2545,7 +2544,6 @@ under the License.
|
||||
<scriptdef name="getnextrel" language="javascript">
|
||||
var relCurr = new String(project.getProperty("version.id"));
|
||||
var relNext = relCurr.replace(/[0-9]+$/, function(lastNum){ return new String(new Number(lastNum)+1); });
|
||||
if (relNext.search(/beta/i) == -1) relNext += "-beta1";
|
||||
project.setProperty("rel_next", relNext);
|
||||
</scriptdef>
|
||||
<getnextrel/>
|
||||
@ -2591,7 +2589,7 @@ under the License.
|
||||
message="tag r${svn_version2} as ${version.id}"/>
|
||||
</svn>
|
||||
|
||||
<!-- update build.xml to the next beta version -->
|
||||
<!-- update build.xml to the next snapshot version -->
|
||||
<antcall target="-update-build.xml">
|
||||
<param name="version_id" value="${rel_next}"/>
|
||||
</antcall>
|
||||
@ -2605,7 +2603,7 @@ under the License.
|
||||
</fileset>
|
||||
</replaceregexp>
|
||||
|
||||
<!-- unpin documentation and commit next beta version -->
|
||||
<!-- unpin documentation and commit next snapshot version -->
|
||||
<svn refid="svn.settings">
|
||||
<update dir="." recurse="true"/>
|
||||
<propset path="src" name="svn:externals" value="documentation https://svn.apache.org/repos/asf/poi/site/src/documentation"/>
|
||||
@ -2656,6 +2654,45 @@ under the License.
|
||||
</svn>
|
||||
</target>
|
||||
|
||||
<target name="release-finish" description="write the dist to the release candidate repo - needs Java7+">
|
||||
<!--svn refid="svn.settings">
|
||||
<update dir="." recurse="true"/>
|
||||
</svn-->
|
||||
<local name="rel_prev"/>
|
||||
<local name="file_date"/>
|
||||
<local name="file_date_iso"/>
|
||||
|
||||
<tstamp>
|
||||
<!-- usually overwritten by a command line argument -->
|
||||
<!-- for convience this is kept in the same format as in the release-prep call -->
|
||||
<format property="file_date" pattern="yyyyMMdd" locale="US"/>
|
||||
</tstamp>
|
||||
|
||||
|
||||
<scriptdef name="getnextrel" language="javascript">
|
||||
var relPrev = new String(project.getProperty("version.id"))
|
||||
.replace(/([0-9]+)[^0-9]*$/, function(all,lastNum){ return new String(new Number(lastNum)-1); });
|
||||
project.setProperty("rel_prev", relPrev);
|
||||
var fileDateIso = new String(project.getProperty("file_date"))
|
||||
.replace(/([0-9]{4})([0-9]{2})([0-9]{2})/, "$1-$2-$3");
|
||||
project.setProperty("file_date_iso", fileDateIso);
|
||||
</scriptdef>
|
||||
<getnextrel/>
|
||||
|
||||
<replaceregexp file="build.gradle" match="( +version += +)'[^']+'" replace="\1'${version.id}'"/>
|
||||
<replaceregexp file="build.gradle" match="(japicmpversion += +)'[^']+'" replace="\1'${rel_prev}'"/>
|
||||
<replaceregexp file="src/examples/groovy/build.gradle" match="( *compile 'org.apache.poi:[^0-9]+)([0-9.]+)'" replace="\1${rel_prev}'" byline="true"/>
|
||||
<replaceregexp file="src/examples/scala/build.sbt" match='( *org.apache.poi.* ")[0-9.]+(.+)' replace="\1${rel_prev}\2" byline="true"/>
|
||||
<replaceregexp file="osgi/build.xml" match='(name="version.id" value=")[^"]+' replace="\1${version.id}"/>
|
||||
<replaceregexp file="doap_POI.rdf" match="<release>" replace="<release> <Version> <name>Apache POI ${rel_prev}</name> <created>${file_date_iso}</created> <revision>${rel_prev}</revision> </Version> </release> <release>"/>
|
||||
|
||||
<replaceregexp match="(<version>)[^<]+" replace="\1${version.id}">
|
||||
<fileset dir="sonar" includes="**/pom.xml"/>
|
||||
</replaceregexp>
|
||||
</target>
|
||||
|
||||
|
||||
|
||||
<target name="-update-build.xml">
|
||||
<replaceregexp byline="true">
|
||||
<regexp pattern="(<property name="version.id" value=")[^"]+("/>)"/>
|
||||
@ -2758,21 +2795,15 @@ under the License.
|
||||
<format property="rel_date" pattern="dd MMMM yyyy" locale="US"/>
|
||||
<format property="file_date" pattern="yyyyMMdd" locale="US"/>
|
||||
</tstamp>
|
||||
<!-- TODO: change reltype (dev/release), depending on BETA / FINAL -->
|
||||
<property name="reltype" value="dev"/>
|
||||
<property name="baseurl" value="https://www.apache.org/dist/poi/${reltype}"/>
|
||||
<property name="baseurl" value="https://www.apache.org/dist/poi/release"/>
|
||||
|
||||
<loadChecksum property="bin-tar-md5" url="${baseurl}/bin/poi-bin-${version.id}-${file_date}.tar.gz.md5"/>
|
||||
<loadChecksum property="bin-tar-sha1" url="${baseurl}/bin/poi-bin-${version.id}-${file_date}.tar.gz.sha1"/>
|
||||
<loadChecksum property="bin-tar-sha256" url="${baseurl}/bin/poi-bin-${version.id}-${file_date}.tar.gz.sha256"/>
|
||||
<loadChecksum property="bin-tar-sha512" url="${baseurl}/bin/poi-bin-${version.id}-${file_date}.tar.gz.sha512"/>
|
||||
<loadChecksum property="bin-zip-md5" url="${baseurl}/bin/poi-bin-${version.id}-${file_date}.zip.md5"/>
|
||||
<loadChecksum property="bin-zip-sha1" url="${baseurl}/bin/poi-bin-${version.id}-${file_date}.zip.sha1"/>
|
||||
<loadChecksum property="bin-zip-sha256" url="${baseurl}/bin/poi-bin-${version.id}-${file_date}.zip.sha256"/>
|
||||
<loadChecksum property="bin-zip-sha512" url="${baseurl}/bin/poi-bin-${version.id}-${file_date}.zip.sha512"/>
|
||||
<loadChecksum property="src-tar-md5" url="${baseurl}/src/poi-src-${version.id}-${file_date}.tar.gz.md5"/>
|
||||
<loadChecksum property="src-tar-sha1" url="${baseurl}/src/poi-src-${version.id}-${file_date}.tar.gz.sha1"/>
|
||||
<loadChecksum property="src-tar-sha256" url="${baseurl}/src/poi-src-${version.id}-${file_date}.tar.gz.sha256"/>
|
||||
<loadChecksum property="src-tar-sha512" url="${baseurl}/src/poi-src-${version.id}-${file_date}.tar.gz.sha512"/>
|
||||
<loadChecksum property="src-zip-md5" url="${baseurl}/src/poi-src-${version.id}-${file_date}.zip.md5"/>
|
||||
<loadChecksum property="src-zip-sha1" url="${baseurl}/src/poi-src-${version.id}-${file_date}.zip.sha1"/>
|
||||
<loadChecksum property="src-zip-sha256" url="${baseurl}/src/poi-src-${version.id}-${file_date}.zip.sha256"/>
|
||||
<loadChecksum property="src-zip-sha512" url="${baseurl}/src/poi-src-${version.id}-${file_date}.zip.sha512"/>
|
||||
|
||||
<loadFilesize property="bin-tar-size" url="${baseurl}/bin/poi-bin-${version.id}-${file_date}.tar.gz"/>
|
||||
@ -2785,69 +2816,57 @@ under the License.
|
||||
<p>The Apache POI team is pleased to announce the release of ${version.id}.
|
||||
Featured are a handful of new areas of functionality and numerous bug fixes.</p>
|
||||
<p>A summary of changes is available in the
|
||||
<link href="https://www.apache.org/dyn/closer.lua/poi/dev/RELEASE-NOTES-${version.id}.txt">Release Notes</link>.
|
||||
A full list of changes is available in the <link href="changes.html">change log</link>.
|
||||
People interested should also follow the <link href="mailinglists.html">dev list</link>
|
||||
<a href="https://www.apache.org/dyn/closer.lua/poi/dev/RELEASE-NOTES-${version.id}.txt">Release Notes</a>.
|
||||
A full list of changes is available in the <a href="site:changes">change log</a>.
|
||||
People interested should also follow the <a href="site:mailinglists">dev list</a>
|
||||
to track progress.</p>
|
||||
<p>
|
||||
The POI source release as well as the pre-built binary deployment packages are listed below.
|
||||
Pre-built versions of all <link href="overview.html#components">POI components</link>
|
||||
Pre-built versions of all <a href="site:components">POI components</a>
|
||||
are available in the central Maven repository under Group ID "org.apache.poi" and Version
|
||||
"${version.id}".
|
||||
</p>
|
||||
<section id="POI-${version.id}-bin"><title>Binary Distribution</title>
|
||||
<ul>
|
||||
<li><link href="https://www.apache.org/dyn/closer.lua/poi/${reltype}/bin/poi-bin-${version.id}-${file_date}.tar.gz">poi-bin-${version.id}-${file_date}.tar.gz</link>
|
||||
(${bin-tar-size} MB, <link href="https://www.apache.org/dist/poi/${reltype}/bin/poi-bin-${version.id}-${file_date}.tar.gz.asc">signature (.asc)</link>)
|
||||
<li><a href="https://www.apache.org/dyn/closer.lua/poi/release/bin/poi-bin-${version.id}-${file_date}.tar.gz">poi-bin-${version.id}-${file_date}.tar.gz</a>
|
||||
(${bin-tar-size} MB, <a href="https://www.apache.org/dist/poi/release/bin/poi-bin-${version.id}-${file_date}.tar.gz.asc">signature (.asc)</a>)
|
||||
<br/>
|
||||
MD5 checksum: <link href="https://www.apache.org/dist/poi/${reltype}/bin/poi-bin-${version.id}-${file_date}.tar.gz.md5">
|
||||
${bin-tar-md5}</link>
|
||||
SHA256 checksum: <a href="https://www.apache.org/dist/poi/release/bin/poi-bin-${version.id}-${file_date}.tar.gz.sha256">
|
||||
${bin-tar-sha256}</a>
|
||||
<br/>
|
||||
SHA1 checksum: <link href="https://www.apache.org/dist/poi/${reltype}/bin/poi-bin-${version.id}-${file_date}.tar.gz.sha1">
|
||||
${bin-tar-sha1}</link>
|
||||
<br/>
|
||||
SHA512 checksum: <link href="https://www.apache.org/dist/poi/${reltype}/bin/poi-bin-${version.id}-${file_date}.tar.gz.sha512">
|
||||
${bin-tar-sha512}</link>
|
||||
SHA512 checksum: <a href="https://www.apache.org/dist/poi/release/bin/poi-bin-${version.id}-${file_date}.tar.gz.sha512">
|
||||
${bin-tar-sha512}</a>
|
||||
</li>
|
||||
<li><link href="https://www.apache.org/dyn/closer.lua/poi/${reltype}/bin/poi-bin-${version.id}-${file_date}.zip">poi-bin-${version.id}-${file_date}.zip</link>
|
||||
(${bin-zip-size} MB, <link href="https://www.apache.org/dist/poi/${reltype}/bin/poi-bin-${version.id}-${file_date}.zip.asc">signature (.asc)</link>)
|
||||
<li><a href="https://www.apache.org/dyn/closer.lua/poi/release/bin/poi-bin-${version.id}-${file_date}.zip">poi-bin-${version.id}-${file_date}.zip</a>
|
||||
(${bin-zip-size} MB, <a href="https://www.apache.org/dist/poi/release/bin/poi-bin-${version.id}-${file_date}.zip.asc">signature (.asc)</a>)
|
||||
<br/>
|
||||
MD5 checksum: <link href="https://www.apache.org/dist/poi/${reltype}/bin/poi-bin-${version.id}-${file_date}.zip.md5">
|
||||
${bin-zip-md5}</link>
|
||||
SHA256 checksum: <a href="https://www.apache.org/dist/poi/release/bin/poi-bin-${version.id}-${file_date}.zip.sha256">
|
||||
${bin-zip-sha256}</a>
|
||||
<br/>
|
||||
SHA1 checksum: <link href="https://www.apache.org/dist/poi/${reltype}/bin/poi-bin-${version.id}-${file_date}.zip.sha1">
|
||||
${bin-zip-sha1}</link>
|
||||
<br/>
|
||||
SHA512 checksum: <link href="https://www.apache.org/dist/poi/${reltype}/bin/poi-bin-${version.id}-${file_date}.zip.sha512">
|
||||
${bin-zip-sha512}</link>
|
||||
SHA512 checksum: <a href="https://www.apache.org/dist/poi/release/bin/poi-bin-${version.id}-${file_date}.zip.sha512">
|
||||
${bin-zip-sha512}</a>
|
||||
</li>
|
||||
</ul>
|
||||
</section>
|
||||
<section id="POI-${version.id}-src"><title>Source Distribution</title>
|
||||
<ul>
|
||||
<li><link href="https://www.apache.org/dyn/closer.lua/poi/${reltype}/src/poi-src-${version.id}-${file_date}.tar.gz">poi-src-${version.id}-${file_date}.tar.gz</link>
|
||||
(${src-tar-size} MB, <link href="https://www.apache.org/dist/poi/${reltype}/src/poi-src-${version.id}-${file_date}.tar.gz.asc">signature (.asc)</link>)
|
||||
<li><a href="https://www.apache.org/dyn/closer.lua/poi/release/src/poi-src-${version.id}-${file_date}.tar.gz">poi-src-${version.id}-${file_date}.tar.gz</a>
|
||||
(${src-tar-size} MB, <a href="https://www.apache.org/dist/poi/release/src/poi-src-${version.id}-${file_date}.tar.gz.asc">signature (.asc)</a>)
|
||||
<br/>
|
||||
MD5 checksum: <link href="https://www.apache.org/dist/poi/${reltype}/src/poi-src-${version.id}-${file_date}.tar.gz.md5">
|
||||
${src-tar-md5}</link>
|
||||
SHA256 checksum: <a href="https://www.apache.org/dist/poi/release/src/poi-src-${version.id}-${file_date}.tar.gz.sha256">
|
||||
${src-tar-sha256}</a>
|
||||
<br/>
|
||||
SHA1 checksum: <link href="https://www.apache.org/dist/poi/${reltype}/src/poi-src-${version.id}-${file_date}.tar.gz.sha1">
|
||||
${src-tar-sha1}</link>
|
||||
<br/>
|
||||
SHA512 checksum: <link href="https://www.apache.org/dist/poi/${reltype}/src/poi-src-${version.id}-${file_date}.tar.gz.sha512">
|
||||
${src-tar-sha512}</link>
|
||||
SHA512 checksum: <a href="https://www.apache.org/dist/poi/release/src/poi-src-${version.id}-${file_date}.tar.gz.sha512">
|
||||
${src-tar-sha512}</a>
|
||||
</li>
|
||||
<li><link href="https://www.apache.org/dyn/closer.lua/poi/${reltype}/src/poi-src-${version.id}-${file_date}.zip">poi-src-${version.id}-${file_date}.zip</link>
|
||||
(${src-zip-size} MB, <link href="https://www.apache.org/dist/poi/${reltype}/src/poi-src-${version.id}-${file_date}.zip.asc">signature (.asc)</link>)
|
||||
<li><a href="https://www.apache.org/dyn/closer.lua/poi/release/src/poi-src-${version.id}-${file_date}.zip">poi-src-${version.id}-${file_date}.zip</a>
|
||||
(${src-zip-size} MB, <a href="https://www.apache.org/dist/poi/release/src/poi-src-${version.id}-${file_date}.zip.asc">signature (.asc)</a>)
|
||||
<br/>
|
||||
MD5 checksum: <link href="https://www.apache.org/dist/poi/${reltype}/src/poi-src-${version.id}-${file_date}.zip.md5">
|
||||
${src-zip-md5}</link>
|
||||
SHA256 checksum: <a href="https://www.apache.org/dist/poi/release/src/poi-src-${version.id}-${file_date}.zip.sha256">
|
||||
${src-zip-sha256}</a>
|
||||
<br/>
|
||||
SHA1 checksum: <link href="https://www.apache.org/dist/poi/${reltype}/src/poi-src-${version.id}-${file_date}.zip.sha1">
|
||||
${src-zip-sha1}</link>
|
||||
<br/>
|
||||
SHA512 checksum: <link href="https://www.apache.org/dist/poi/${reltype}/src/poi-src-${version.id}-${file_date}.zip.sha512">
|
||||
${src-zip-sha512}</link>
|
||||
SHA512 checksum: <a href="https://www.apache.org/dist/poi/release/src/poi-src-${version.id}-${file_date}.zip.sha512">
|
||||
${src-zip-sha512}</a>
|
||||
</li>
|
||||
</ul>
|
||||
</section>
|
||||
|
@ -35,6 +35,13 @@
|
||||
<programming-language>Java</programming-language>
|
||||
<category rdf:resource="https://projects.apache.org/category/content" />
|
||||
<category rdf:resource="https://projects.apache.org/category/library" />
|
||||
<release>
|
||||
<Version>
|
||||
<name>Apache POI 4.0.0</name>
|
||||
<created>2018-09-07</created>
|
||||
<revision>4.0.0</revision>
|
||||
</Version>
|
||||
</release>
|
||||
<release>
|
||||
<Version>
|
||||
<name>Apache POI 3.17</name>
|
||||
|
@ -11,7 +11,7 @@ H H * * 0
|
||||
'''
|
||||
|
||||
def xercesUrl = 'http://repo1.maven.org/maven2/xerces/xercesImpl/2.6.1/xercesImpl-2.6.1.jar'
|
||||
def xercesLib = 'compile-lib/xercesImpl-2.6.1.jar'
|
||||
def xercesLib = './xercesImpl-2.6.1.jar'
|
||||
|
||||
def poijobs = [
|
||||
[ name: 'POI-DSL-1.8', trigger: 'H */12 * * *'
|
||||
@ -88,7 +88,7 @@ def poijobs = [
|
||||
disabled: true, skipcigame: true
|
||||
],
|
||||
[ name: 'POI-DSL-old-Xerces', trigger: triggerSundays,
|
||||
shell: "mkdir -p compile-lib && test -f ${xercesLib} || wget -O ${xercesLib} ${xercesUrl}\n",
|
||||
shell: "test -f ${xercesLib} || wget -O ${xercesLib} ${xercesUrl}\n",
|
||||
// the property triggers using Xerces as XML Parser and previously showed some exception that can occur
|
||||
properties: ["-Dadditionaljar=${xercesLib}"]
|
||||
],
|
||||
|
@ -26,7 +26,7 @@ under the License.
|
||||
|
||||
<!-- TODO Import these from the parent build file -->
|
||||
<property name="repository.m2" value="http://repo1.maven.org"/>
|
||||
<property name="version.id" value="4.0.0-SNAPSHOT"/>
|
||||
<property name="version.id" value="4.0.1-SNAPSHOT"/>
|
||||
<property name="dist.dir" value="build/dist"/>
|
||||
|
||||
<!-- jars in the /lib directory, see the fetch-bundle-jars target-->
|
||||
|
@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi-parent</artifactId>
|
||||
<version>4.0.1-beta1-SNAPSHOT</version>
|
||||
<version>4.0.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>poi-examples</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi-parent</artifactId>
|
||||
<version>4.0.1-beta1-SNAPSHOT</version>
|
||||
<version>4.0.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>poi-excelant</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi-parent</artifactId>
|
||||
<version>4.0.1-beta1-SNAPSHOT</version>
|
||||
<version>4.0.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>poi-main</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi-parent</artifactId>
|
||||
<version>4.0.1-beta1-SNAPSHOT</version>
|
||||
<version>4.0.1-SNAPSHOT</version>
|
||||
<relativePath>..</relativePath>
|
||||
</parent>
|
||||
<artifactId>poi-ooxml-schema-encryption</artifactId>
|
||||
|
@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi-parent</artifactId>
|
||||
<version>4.0.1-beta1-SNAPSHOT</version>
|
||||
<version>4.0.1-SNAPSHOT</version>
|
||||
<relativePath>..</relativePath>
|
||||
</parent>
|
||||
<artifactId>poi-ooxml-schema-security</artifactId>
|
||||
|
@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi-parent</artifactId>
|
||||
<version>4.0.1-beta1-SNAPSHOT</version>
|
||||
<version>4.0.1-SNAPSHOT</version>
|
||||
<relativePath>..</relativePath>
|
||||
</parent>
|
||||
<artifactId>poi-ooxml-schema</artifactId>
|
||||
|
@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi-parent</artifactId>
|
||||
<version>4.0.1-beta1-SNAPSHOT</version>
|
||||
<version>4.0.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>poi-ooxml</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
@ -4,7 +4,7 @@
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi-parent</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
<version>4.0.1-beta1-SNAPSHOT</version>
|
||||
<version>4.0.1-SNAPSHOT</version>
|
||||
<name>Apache POI - the Java API for Microsoft Documents</name>
|
||||
<description>Maven build of Apache POI for Sonar checks</description>
|
||||
<url>http://poi.apache.org/</url>
|
||||
|
@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi-parent</artifactId>
|
||||
<version>4.0.1-beta1-SNAPSHOT</version>
|
||||
<version>4.0.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>poi-scratchpad</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
@ -23,8 +23,8 @@ repositories {
|
||||
}
|
||||
dependencies {
|
||||
compile 'org.codehaus.groovy:groovy-all:2.4.13'
|
||||
compile 'org.apache.poi:poi:3.17'
|
||||
compile 'org.apache.poi:poi-ooxml:3.17'
|
||||
compile 'org.apache.poi:poi:4.0.0'
|
||||
compile 'org.apache.poi:poi-ooxml:4.0.0'
|
||||
}
|
||||
|
||||
// Our files are in the current directory
|
||||
|
@ -17,7 +17,7 @@
|
||||
|
||||
// Add the POI core and OOXML support dependencies into your build.sbt
|
||||
libraryDependencies ++= Seq(
|
||||
"org.apache.poi" % "poi" % "3.17",
|
||||
"org.apache.poi" % "poi-ooxml" % "3.17",
|
||||
"org.apache.poi" % "poi-ooxml-schemas" "3.17",
|
||||
"org.apache.poi" % "poi" % "4.0.0",
|
||||
"org.apache.poi" % "poi-ooxml" % "4.0.0",
|
||||
"org.apache.poi" % "poi-ooxml-schemas" "4.0.0",
|
||||
)
|
||||
|
@ -20,6 +20,7 @@ package org.apache.poi.ooxml.util;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.xml.XMLConstants;
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
@ -38,6 +39,7 @@ import org.xml.sax.SAXParseException;
|
||||
|
||||
public final class DocumentHelper {
|
||||
private static POILogger logger = POILogFactory.getLogger(DocumentHelper.class);
|
||||
private static long lastLog;
|
||||
|
||||
private DocumentHelper() {}
|
||||
|
||||
@ -102,19 +104,19 @@ public final class DocumentHelper {
|
||||
//this doesn't appear to work, and we still need to limit
|
||||
//entity expansions to 1 in trySetXercesSecurityManager
|
||||
documentBuilderFactory.setExpandEntityReferences(false);
|
||||
trySetSAXFeature(documentBuilderFactory, XMLConstants.FEATURE_SECURE_PROCESSING, true);
|
||||
trySetSAXFeature(documentBuilderFactory, POIXMLConstants.FEATURE_LOAD_DTD_GRAMMAR, false);
|
||||
trySetSAXFeature(documentBuilderFactory, POIXMLConstants.FEATURE_LOAD_EXTERNAL_DTD, false);
|
||||
trySetFeature(documentBuilderFactory, XMLConstants.FEATURE_SECURE_PROCESSING, true);
|
||||
trySetFeature(documentBuilderFactory, POIXMLConstants.FEATURE_LOAD_DTD_GRAMMAR, false);
|
||||
trySetFeature(documentBuilderFactory, POIXMLConstants.FEATURE_LOAD_EXTERNAL_DTD, false);
|
||||
trySetXercesSecurityManager(documentBuilderFactory);
|
||||
}
|
||||
|
||||
private static void trySetSAXFeature(DocumentBuilderFactory dbf, String feature, boolean enabled) {
|
||||
private static void trySetFeature(DocumentBuilderFactory dbf, String feature, boolean enabled) {
|
||||
try {
|
||||
dbf.setFeature(feature, enabled);
|
||||
} catch (Exception e) {
|
||||
logger.log(POILogger.WARN, "SAX Feature unsupported", feature, e);
|
||||
logger.log(POILogger.WARN, "DocumentBuilderFactory Feature unsupported", feature, e);
|
||||
} catch (AbstractMethodError ame) {
|
||||
logger.log(POILogger.WARN, "Cannot set SAX feature because outdated XML parser in classpath", feature, ame);
|
||||
logger.log(POILogger.WARN, "Cannot set DocumentBuilderFactory feature because outdated XML parser in classpath", feature, ame);
|
||||
}
|
||||
}
|
||||
|
||||
@ -134,13 +136,23 @@ public final class DocumentHelper {
|
||||
} catch (ClassNotFoundException e) {
|
||||
// continue without log, this is expected in some setups
|
||||
} catch (Throwable e) { // NOSONAR - also catch things like NoClassDefError here
|
||||
logger.log(POILogger.WARN, "SAX Security Manager could not be setup", e);
|
||||
if(System.currentTimeMillis() > lastLog + TimeUnit.MINUTES.toMillis(5)) {
|
||||
logger.log(POILogger.WARN, "DocumentBuilderFactory Security Manager could not be setup [log suppressed for 5 minutes]", e);
|
||||
lastLog = System.currentTimeMillis();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// separate old version of Xerces not found => use the builtin way of setting the property
|
||||
// Note: when entity_expansion_limit==0, there is no limit!
|
||||
dbf.setAttribute(POIXMLConstants.PROPERTY_ENTITY_EXPANSION_LIMIT, 1);
|
||||
try {
|
||||
dbf.setAttribute(POIXMLConstants.PROPERTY_ENTITY_EXPANSION_LIMIT, 1);
|
||||
} catch (Throwable e) {
|
||||
if(System.currentTimeMillis() > lastLog + TimeUnit.MINUTES.toMillis(5)) {
|
||||
logger.log(POILogger.WARN, "DocumentBuilderFactory Entity Expansion Limit could not be setup [log suppressed for 5 minutes]", e);
|
||||
lastLog = System.currentTimeMillis();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -101,40 +101,44 @@ public final class XSSFDrawing extends POIXMLDocumentPart implements Drawing<XSS
|
||||
/**
|
||||
* Construct a SpreadsheetML drawing from a package part
|
||||
*
|
||||
* @param part the package part holding the drawing data,
|
||||
* the content type must be <code>application/vnd.openxmlformats-officedocument.drawing+xml</code>
|
||||
* @param part
|
||||
* the package part holding the drawing data, the content type
|
||||
* must be
|
||||
* <code>application/vnd.openxmlformats-officedocument.drawing+xml</code>
|
||||
*
|
||||
* @since POI 3.14-Beta1
|
||||
*/
|
||||
public XSSFDrawing(PackagePart part) throws IOException, XmlException {
|
||||
super(part);
|
||||
XmlOptions options = new XmlOptions(DEFAULT_XML_OPTIONS);
|
||||
//Removing root element
|
||||
XmlOptions options = new XmlOptions(DEFAULT_XML_OPTIONS);
|
||||
// Removing root element
|
||||
options.setLoadReplaceDocumentElement(null);
|
||||
InputStream is = part.getInputStream();
|
||||
try {
|
||||
drawing = CTDrawing.Factory.parse(is,options);
|
||||
drawing = CTDrawing.Factory.parse(is, options);
|
||||
} finally {
|
||||
is.close();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a new CTDrawing bean. By default, it's just an empty placeholder for drawing objects
|
||||
* Construct a new CTDrawing bean. By default, it's just an empty
|
||||
* placeholder for drawing objects
|
||||
*
|
||||
* @return a new CTDrawing bean
|
||||
*/
|
||||
private static CTDrawing newDrawing(){
|
||||
private static CTDrawing newDrawing() {
|
||||
return CTDrawing.Factory.newInstance();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the underlying CTDrawing bean, the root element of the SpreadsheetML Drawing part.
|
||||
* Return the underlying CTDrawing bean, the root element of the
|
||||
* SpreadsheetML Drawing part.
|
||||
*
|
||||
* @return the underlying CTDrawing bean
|
||||
*/
|
||||
@Internal
|
||||
public CTDrawing getCTDrawing(){
|
||||
public CTDrawing getCTDrawing() {
|
||||
return drawing;
|
||||
}
|
||||
|
||||
@ -143,14 +147,13 @@ public final class XSSFDrawing extends POIXMLDocumentPart implements Drawing<XSS
|
||||
XmlOptions xmlOptions = new XmlOptions(DEFAULT_XML_OPTIONS);
|
||||
|
||||
/*
|
||||
Saved drawings must have the following namespaces set:
|
||||
<xdr:wsDr
|
||||
xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main"
|
||||
xmlns:xdr="http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing">
|
||||
*/
|
||||
xmlOptions.setSaveSyntheticDocumentElement(
|
||||
new QName(CTDrawing.type.getName().getNamespaceURI(), "wsDr", "xdr")
|
||||
);
|
||||
* Saved drawings must have the following namespaces set: <xdr:wsDr
|
||||
* xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main"
|
||||
* xmlns:xdr=
|
||||
* "http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing">
|
||||
*/
|
||||
xmlOptions
|
||||
.setSaveSyntheticDocumentElement(new QName(CTDrawing.type.getName().getNamespaceURI(), "wsDr", "xdr"));
|
||||
|
||||
PackagePart part = getPackagePart();
|
||||
OutputStream out = part.getOutputStream();
|
||||
@ -158,20 +161,20 @@ public final class XSSFDrawing extends POIXMLDocumentPart implements Drawing<XSS
|
||||
out.close();
|
||||
}
|
||||
|
||||
@Override
|
||||
public XSSFClientAnchor createAnchor(int dx1, int dy1, int dx2, int dy2,
|
||||
int col1, int row1, int col2, int row2) {
|
||||
return new XSSFClientAnchor(dx1, dy1, dx2, dy2, col1, row1, col2, row2);
|
||||
}
|
||||
@Override
|
||||
public XSSFClientAnchor createAnchor(int dx1, int dy1, int dx2, int dy2, int col1, int row1, int col2, int row2) {
|
||||
return new XSSFClientAnchor(dx1, dy1, dx2, dy2, col1, row1, col2, row2);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a textbox under the drawing.
|
||||
*
|
||||
* @param anchor the client anchor describes how this group is attached
|
||||
* to the sheet.
|
||||
* @return the newly created textbox.
|
||||
* @param anchor
|
||||
* the client anchor describes how this group is attached to the
|
||||
* sheet.
|
||||
* @return the newly created textbox.
|
||||
*/
|
||||
public XSSFTextBox createTextbox(XSSFClientAnchor anchor){
|
||||
public XSSFTextBox createTextbox(XSSFClientAnchor anchor) {
|
||||
long shapeId = newShapeId();
|
||||
CTTwoCellAnchor ctAnchor = createTwoCellAnchor(anchor);
|
||||
CTShape ctShape = ctAnchor.addNewSp();
|
||||
@ -186,14 +189,18 @@ public final class XSSFDrawing extends POIXMLDocumentPart implements Drawing<XSS
|
||||
/**
|
||||
* Creates a picture.
|
||||
*
|
||||
* @param anchor the client anchor describes how this picture is attached to the sheet.
|
||||
* @param pictureIndex the index of the picture in the workbook collection of pictures,
|
||||
* {@link org.apache.poi.xssf.usermodel.XSSFWorkbook#getAllPictures()} .
|
||||
* @param anchor
|
||||
* the client anchor describes how this picture is attached to
|
||||
* the sheet.
|
||||
* @param pictureIndex
|
||||
* the index of the picture in the workbook collection of
|
||||
* pictures,
|
||||
* {@link org.apache.poi.xssf.usermodel.XSSFWorkbook#getAllPictures()}
|
||||
* .
|
||||
*
|
||||
* @return the newly created picture shape.
|
||||
* @return the newly created picture shape.
|
||||
*/
|
||||
public XSSFPicture createPicture(XSSFClientAnchor anchor, int pictureIndex)
|
||||
{
|
||||
public XSSFPicture createPicture(XSSFClientAnchor anchor, int pictureIndex) {
|
||||
PackageRelationship rel = addPictureReference(pictureIndex);
|
||||
|
||||
long shapeId = newShapeId();
|
||||
@ -212,23 +219,24 @@ public final class XSSFDrawing extends POIXMLDocumentPart implements Drawing<XSS
|
||||
}
|
||||
|
||||
@Override
|
||||
public XSSFPicture createPicture(ClientAnchor anchor, int pictureIndex){
|
||||
return createPicture((XSSFClientAnchor)anchor, pictureIndex);
|
||||
public XSSFPicture createPicture(ClientAnchor anchor, int pictureIndex) {
|
||||
return createPicture((XSSFClientAnchor) anchor, pictureIndex);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a chart.
|
||||
* @param anchor the client anchor describes how this chart is attached to
|
||||
* the sheet.
|
||||
* @return the newly created chart
|
||||
* @see org.apache.poi.xssf.usermodel.XSSFDrawing#createChart(ClientAnchor)
|
||||
*/
|
||||
/**
|
||||
* Creates a chart.
|
||||
*
|
||||
* @param anchor
|
||||
* the client anchor describes how this chart is attached to the
|
||||
* sheet.
|
||||
* @return the newly created chart
|
||||
* @see org.apache.poi.xssf.usermodel.XSSFDrawing#createChart(ClientAnchor)
|
||||
*/
|
||||
public XSSFChart createChart(XSSFClientAnchor anchor) {
|
||||
int chartNumber = getPackagePart().getPackage().
|
||||
getPartsByContentType(XSSFRelation.CHART.getContentType()).size() + 1;
|
||||
int chartNumber = getPackagePart().getPackage().getPartsByContentType(XSSFRelation.CHART.getContentType())
|
||||
.size() + 1;
|
||||
|
||||
RelationPart rp = createRelationship(
|
||||
XSSFRelation.CHART, XSSFFactory.getInstance(), chartNumber, false);
|
||||
RelationPart rp = createRelationship(XSSFRelation.CHART, XSSFFactory.getInstance(), chartNumber, false);
|
||||
XSSFChart chart = rp.getDocumentPart();
|
||||
String chartRelId = rp.getRelationship().getId();
|
||||
|
||||
@ -239,25 +247,52 @@ public final class XSSFDrawing extends POIXMLDocumentPart implements Drawing<XSS
|
||||
return chart;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a chart.
|
||||
* @param anchor the client anchor describes how this chart is attached to
|
||||
* the sheet.
|
||||
* @return the newly created chart
|
||||
*/
|
||||
/**
|
||||
* Creates a chart.
|
||||
*
|
||||
* @param anchor
|
||||
* the client anchor describes how this chart is attached to the
|
||||
* sheet.
|
||||
* @return the newly created chart
|
||||
*/
|
||||
public XSSFChart createChart(ClientAnchor anchor) {
|
||||
return createChart((XSSFClientAnchor)anchor);
|
||||
}
|
||||
return createChart((XSSFClientAnchor) anchor);
|
||||
}
|
||||
|
||||
/**
|
||||
* Imports the chart from the <code>srcChart</code> into this drawing.
|
||||
*
|
||||
* @param srcChart
|
||||
* the source chart to be cloned into this drawing.
|
||||
* @return the newly created chart.
|
||||
* @throws XmlException
|
||||
* @throws IOException
|
||||
* @since 4.0.0
|
||||
*/
|
||||
public XSSFChart importChart(XSSFChart srcChart) throws IOException, XmlException {
|
||||
CTTwoCellAnchor anchor = ((XSSFDrawing) srcChart.getParent()).getCTDrawing().getTwoCellAnchorArray(0);
|
||||
CTMarker from = (CTMarker) anchor.getFrom().copy();
|
||||
CTMarker to = (CTMarker) anchor.getTo().copy();
|
||||
XSSFClientAnchor destAnchor = new XSSFClientAnchor(from, to);
|
||||
destAnchor.setAnchorType(ClientAnchor.AnchorType.MOVE_AND_RESIZE);
|
||||
XSSFChart destChart = createChart(destAnchor);
|
||||
destChart.getCTChartSpace().set(srcChart.getCTChartSpace().copy());
|
||||
destChart.getCTChart().set(srcChart.getCTChart().copy());
|
||||
return destChart;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the indexed picture to this drawing relations
|
||||
*
|
||||
* @param pictureIndex the index of the picture in the workbook collection of pictures,
|
||||
* {@link org.apache.poi.xssf.usermodel.XSSFWorkbook#getAllPictures()} .
|
||||
* @param pictureIndex
|
||||
* the index of the picture in the workbook collection of
|
||||
* pictures,
|
||||
* {@link org.apache.poi.xssf.usermodel.XSSFWorkbook#getAllPictures()}
|
||||
* .
|
||||
*/
|
||||
@SuppressWarnings("resource")
|
||||
protected PackageRelationship addPictureReference(int pictureIndex){
|
||||
XSSFWorkbook wb = (XSSFWorkbook)getParent().getParent();
|
||||
protected PackageRelationship addPictureReference(int pictureIndex) {
|
||||
XSSFWorkbook wb = (XSSFWorkbook) getParent().getParent();
|
||||
XSSFPictureData data = wb.getAllPictures().get(pictureIndex);
|
||||
XSSFPictureData pic = new XSSFPictureData(data.getPackagePart());
|
||||
RelationPart rp = addRelation(null, XSSFRelation.IMAGES, pic);
|
||||
@ -265,15 +300,15 @@ public final class XSSFDrawing extends POIXMLDocumentPart implements Drawing<XSS
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a simple shape. This includes such shapes as lines, rectangles,
|
||||
* Creates a simple shape. This includes such shapes as lines, rectangles,
|
||||
* and ovals.
|
||||
*
|
||||
* @param anchor the client anchor describes how this group is attached
|
||||
* to the sheet.
|
||||
* @return the newly created shape.
|
||||
* @param anchor
|
||||
* the client anchor describes how this group is attached to the
|
||||
* sheet.
|
||||
* @return the newly created shape.
|
||||
*/
|
||||
public XSSFSimpleShape createSimpleShape(XSSFClientAnchor anchor)
|
||||
{
|
||||
public XSSFSimpleShape createSimpleShape(XSSFClientAnchor anchor) {
|
||||
long shapeId = newShapeId();
|
||||
CTTwoCellAnchor ctAnchor = createTwoCellAnchor(anchor);
|
||||
CTShape ctShape = ctAnchor.addNewSp();
|
||||
@ -286,15 +321,15 @@ public final class XSSFDrawing extends POIXMLDocumentPart implements Drawing<XSS
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a simple shape. This includes such shapes as lines, rectangles,
|
||||
* Creates a simple shape. This includes such shapes as lines, rectangles,
|
||||
* and ovals.
|
||||
*
|
||||
* @param anchor the client anchor describes how this group is attached
|
||||
* to the sheet.
|
||||
* @return the newly created shape.
|
||||
* @param anchor
|
||||
* the client anchor describes how this group is attached to the
|
||||
* sheet.
|
||||
* @return the newly created shape.
|
||||
*/
|
||||
public XSSFConnector createConnector(XSSFClientAnchor anchor)
|
||||
{
|
||||
public XSSFConnector createConnector(XSSFClientAnchor anchor) {
|
||||
CTTwoCellAnchor ctAnchor = createTwoCellAnchor(anchor);
|
||||
CTConnector ctShape = ctAnchor.addNewCxnSp();
|
||||
ctShape.set(XSSFConnector.prototype());
|
||||
@ -305,20 +340,20 @@ public final class XSSFDrawing extends POIXMLDocumentPart implements Drawing<XSS
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a simple shape. This includes such shapes as lines, rectangles,
|
||||
* Creates a simple shape. This includes such shapes as lines, rectangles,
|
||||
* and ovals.
|
||||
*
|
||||
* @param anchor the client anchor describes how this group is attached
|
||||
* to the sheet.
|
||||
* @return the newly created shape.
|
||||
* @param anchor
|
||||
* the client anchor describes how this group is attached to the
|
||||
* sheet.
|
||||
* @return the newly created shape.
|
||||
*/
|
||||
public XSSFShapeGroup createGroup(XSSFClientAnchor anchor)
|
||||
{
|
||||
public XSSFShapeGroup createGroup(XSSFClientAnchor anchor) {
|
||||
CTTwoCellAnchor ctAnchor = createTwoCellAnchor(anchor);
|
||||
CTGroupShape ctGroup = ctAnchor.addNewGrpSp();
|
||||
ctGroup.set(XSSFShapeGroup.prototype());
|
||||
CTTransform2D xfrm = createXfrm(anchor);
|
||||
CTGroupTransform2D grpXfrm =ctGroup.getGrpSpPr().getXfrm();
|
||||
CTGroupTransform2D grpXfrm = ctGroup.getGrpSpPr().getXfrm();
|
||||
grpXfrm.setOff(xfrm.getOff());
|
||||
grpXfrm.setExt(xfrm.getExt());
|
||||
grpXfrm.setChExt(xfrm.getExt());
|
||||
@ -328,38 +363,38 @@ public final class XSSFDrawing extends POIXMLDocumentPart implements Drawing<XSS
|
||||
return shape;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a comment.
|
||||
* @param anchor the client anchor describes how this comment is attached
|
||||
* to the sheet.
|
||||
* @return the newly created comment.
|
||||
*/
|
||||
/**
|
||||
* Creates a comment.
|
||||
*
|
||||
* @param anchor
|
||||
* the client anchor describes how this comment is attached to
|
||||
* the sheet.
|
||||
* @return the newly created comment.
|
||||
*/
|
||||
@Override
|
||||
public XSSFComment createCellComment(ClientAnchor anchor) {
|
||||
XSSFClientAnchor ca = (XSSFClientAnchor)anchor;
|
||||
XSSFClientAnchor ca = (XSSFClientAnchor) anchor;
|
||||
XSSFSheet sheet = getSheet();
|
||||
|
||||
//create comments and vmlDrawing parts if they don't exist
|
||||
// create comments and vmlDrawing parts if they don't exist
|
||||
CommentsTable comments = sheet.getCommentsTable(true);
|
||||
XSSFVMLDrawing vml = sheet.getVMLDrawing(true);
|
||||
com.microsoft.schemas.vml.CTShape vmlShape = vml.newCommentShape();
|
||||
if(ca.isSet()){
|
||||
// convert offsets from emus to pixels since we get a DrawingML-anchor
|
||||
if (ca.isSet()) {
|
||||
// convert offsets from emus to pixels since we get a
|
||||
// DrawingML-anchor
|
||||
// but create a VML Drawing
|
||||
int dx1Pixels = ca.getDx1()/Units.EMU_PER_PIXEL;
|
||||
int dy1Pixels = ca.getDy1()/Units.EMU_PER_PIXEL;
|
||||
int dx2Pixels = ca.getDx2()/Units.EMU_PER_PIXEL;
|
||||
int dy2Pixels = ca.getDy2()/Units.EMU_PER_PIXEL;
|
||||
String position =
|
||||
ca.getCol1() + ", " + dx1Pixels + ", " +
|
||||
ca.getRow1() + ", " + dy1Pixels + ", " +
|
||||
ca.getCol2() + ", " + dx2Pixels + ", " +
|
||||
ca.getRow2() + ", " + dy2Pixels;
|
||||
int dx1Pixels = ca.getDx1() / Units.EMU_PER_PIXEL;
|
||||
int dy1Pixels = ca.getDy1() / Units.EMU_PER_PIXEL;
|
||||
int dx2Pixels = ca.getDx2() / Units.EMU_PER_PIXEL;
|
||||
int dy2Pixels = ca.getDy2() / Units.EMU_PER_PIXEL;
|
||||
String position = ca.getCol1() + ", " + dx1Pixels + ", " + ca.getRow1() + ", " + dy1Pixels + ", " + ca
|
||||
.getCol2() + ", " + dx2Pixels + ", " + ca.getRow2() + ", " + dy2Pixels;
|
||||
vmlShape.getClientDataArray(0).setAnchorArray(0, position);
|
||||
}
|
||||
CellAddress ref = new CellAddress(ca.getRow1(), ca.getCol1());
|
||||
|
||||
if(comments.findCellComment(ref) != null) {
|
||||
if (comments.findCellComment(ref) != null) {
|
||||
throw new IllegalArgumentException("Multiple cell comments in one cell are not allowed, cell: " + ref);
|
||||
}
|
||||
|
||||
@ -369,9 +404,10 @@ public final class XSSFDrawing extends POIXMLDocumentPart implements Drawing<XSS
|
||||
/**
|
||||
* Creates a new graphic frame.
|
||||
*
|
||||
* @param anchor the client anchor describes how this frame is attached
|
||||
* to the sheet
|
||||
* @return the newly created graphic frame
|
||||
* @param anchor
|
||||
* the client anchor describes how this frame is attached to the
|
||||
* sheet
|
||||
* @return the newly created graphic frame
|
||||
*/
|
||||
private XSSFGraphicFrame createGraphicFrame(XSSFClientAnchor anchor) {
|
||||
CTTwoCellAnchor ctAnchor = createTwoCellAnchor(anchor);
|
||||
@ -395,36 +431,40 @@ public final class XSSFDrawing extends POIXMLDocumentPart implements Drawing<XSS
|
||||
/*
|
||||
* The shape id of the ole object seems to be a legacy shape id.
|
||||
*
|
||||
* see 5.3.2.1 legacyDrawing (Legacy Drawing Object):
|
||||
* Legacy Shape ID that is unique throughout the entire document.
|
||||
* Legacy shape IDs should be assigned based on which portion of the document the
|
||||
* drawing resides on. The assignment of these ids is broken down into clusters of
|
||||
* 1024 values. The first cluster is 1-1024, the second 1025-2048 and so on.
|
||||
* see 5.3.2.1 legacyDrawing (Legacy Drawing Object): Legacy Shape ID
|
||||
* that is unique throughout the entire document. Legacy shape IDs
|
||||
* should be assigned based on which portion of the document the drawing
|
||||
* resides on. The assignment of these ids is broken down into clusters
|
||||
* of 1024 values. The first cluster is 1-1024, the second 1025-2048 and
|
||||
* so on.
|
||||
*
|
||||
* Ole shapes seem to start with 1025 on the first sheet ...
|
||||
* and not sure, if the ids need to be reindexed when sheets are removed
|
||||
* or more than 1024 shapes are on a given sheet (see #51332 for a similar issue)
|
||||
* Ole shapes seem to start with 1025 on the first sheet ... and not
|
||||
* sure, if the ids need to be reindexed when sheets are removed or more
|
||||
* than 1024 shapes are on a given sheet (see #51332 for a similar
|
||||
* issue)
|
||||
*/
|
||||
XSSFSheet sheet = getSheet();
|
||||
XSSFWorkbook wb = sheet.getWorkbook();
|
||||
int sheetIndex = wb.getSheetIndex(sheet);
|
||||
long shapeId = (sheetIndex+1)*1024 + newShapeId();
|
||||
long shapeId = (sheetIndex + 1) * 1024 + newShapeId();
|
||||
|
||||
// add reference to OLE part
|
||||
PackagePartName olePN;
|
||||
try {
|
||||
olePN = PackagingURIHelper.createPartName( "/xl/embeddings/oleObject"+storageId+".bin" );
|
||||
olePN = PackagingURIHelper.createPartName("/xl/embeddings/oleObject" + storageId + ".bin");
|
||||
} catch (InvalidFormatException e) {
|
||||
throw new POIXMLException(e);
|
||||
}
|
||||
PackageRelationship olePR = sheetPart.addRelationship( olePN, TargetMode.INTERNAL, POIXMLDocument.OLE_OBJECT_REL_TYPE );
|
||||
PackageRelationship olePR = sheetPart.addRelationship(olePN, TargetMode.INTERNAL,
|
||||
POIXMLDocument.OLE_OBJECT_REL_TYPE);
|
||||
|
||||
// add reference to image part
|
||||
XSSFPictureData imgPD = sh.getWorkbook().getAllPictures().get(pictureIndex);
|
||||
PackagePartName imgPN = imgPD.getPackagePart().getPartName();
|
||||
PackageRelationship imgSheetPR = sheetPart.addRelationship( imgPN, TargetMode.INTERNAL, PackageRelationshipTypes.IMAGE_PART );
|
||||
PackageRelationship imgDrawPR = getPackagePart().addRelationship( imgPN, TargetMode.INTERNAL, PackageRelationshipTypes.IMAGE_PART );
|
||||
|
||||
PackageRelationship imgSheetPR = sheetPart.addRelationship(imgPN, TargetMode.INTERNAL,
|
||||
PackageRelationshipTypes.IMAGE_PART);
|
||||
PackageRelationship imgDrawPR = getPackagePart().addRelationship(imgPN, TargetMode.INTERNAL,
|
||||
PackageRelationshipTypes.IMAGE_PART);
|
||||
|
||||
// add OLE part metadata to sheet
|
||||
CTWorksheet cwb = sh.getCTWorksheet();
|
||||
@ -443,7 +483,7 @@ public final class XSSFDrawing extends POIXMLDocumentPart implements Drawing<XSS
|
||||
cur1.beginElement("anchor", XSSFRelation.NS_SPREADSHEETML);
|
||||
cur1.insertAttributeWithValue("moveWithCells", "1");
|
||||
|
||||
CTTwoCellAnchor ctAnchor = createTwoCellAnchor((XSSFClientAnchor)anchor);
|
||||
CTTwoCellAnchor ctAnchor = createTwoCellAnchor((XSSFClientAnchor) anchor);
|
||||
|
||||
XmlCursor cur2 = ctAnchor.newCursor();
|
||||
cur2.copyXmlContents(cur1);
|
||||
@ -460,7 +500,7 @@ public final class XSSFDrawing extends POIXMLDocumentPart implements Drawing<XSS
|
||||
// add a new shape and link OLE & image part
|
||||
CTShape ctShape = ctAnchor.addNewSp();
|
||||
ctShape.set(XSSFObjectData.prototype());
|
||||
ctShape.getSpPr().setXfrm(createXfrm((XSSFClientAnchor)anchor));
|
||||
ctShape.getSpPr().setXfrm(createXfrm((XSSFClientAnchor) anchor));
|
||||
|
||||
// workaround for not having the vmlDrawing filled
|
||||
CTBlipFillProperties blipFill = ctShape.getSpPr().addNewBlipFill();
|
||||
@ -469,35 +509,35 @@ public final class XSSFDrawing extends POIXMLDocumentPart implements Drawing<XSS
|
||||
|
||||
CTNonVisualDrawingProps cNvPr = ctShape.getNvSpPr().getCNvPr();
|
||||
cNvPr.setId(shapeId);
|
||||
cNvPr.setName("Object "+shapeId);
|
||||
cNvPr.setName("Object " + shapeId);
|
||||
|
||||
XmlCursor extCur = cNvPr.getExtLst().getExtArray(0).newCursor();
|
||||
extCur.toFirstChild();
|
||||
extCur.setAttributeText(new QName("spid"), "_x0000_s"+shapeId);
|
||||
extCur.setAttributeText(new QName("spid"), "_x0000_s" + shapeId);
|
||||
extCur.dispose();
|
||||
|
||||
XSSFObjectData shape = new XSSFObjectData(this, ctShape);
|
||||
shape.anchor = (XSSFClientAnchor)anchor;
|
||||
shape.anchor = (XSSFClientAnchor) anchor;
|
||||
|
||||
return shape;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns all charts in this drawing.
|
||||
*/
|
||||
public List<XSSFChart> getCharts() {
|
||||
List<XSSFChart> charts = new ArrayList<>();
|
||||
for(POIXMLDocumentPart part : getRelations()) {
|
||||
if(part instanceof XSSFChart) {
|
||||
charts.add((XSSFChart)part);
|
||||
}
|
||||
}
|
||||
return charts;
|
||||
List<XSSFChart> charts = new ArrayList<>();
|
||||
for (POIXMLDocumentPart part : getRelations()) {
|
||||
if (part instanceof XSSFChart) {
|
||||
charts.add((XSSFChart) part);
|
||||
}
|
||||
}
|
||||
return charts;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create and initialize a CTTwoCellAnchor that anchors a shape against top-left and bottom-right cells.
|
||||
* Create and initialize a CTTwoCellAnchor that anchors a shape against
|
||||
* top-left and bottom-right cells.
|
||||
*
|
||||
* @return a new CTTwoCellAnchor
|
||||
*/
|
||||
@ -508,14 +548,21 @@ public final class XSSFDrawing extends POIXMLDocumentPart implements Drawing<XSS
|
||||
ctAnchor.addNewClientData();
|
||||
anchor.setTo(ctAnchor.getTo());
|
||||
anchor.setFrom(ctAnchor.getFrom());
|
||||
STEditAs.Enum aditAs;
|
||||
switch(anchor.getAnchorType()) {
|
||||
case DONT_MOVE_AND_RESIZE: aditAs = STEditAs.ABSOLUTE; break;
|
||||
case MOVE_AND_RESIZE: aditAs = STEditAs.TWO_CELL; break;
|
||||
case MOVE_DONT_RESIZE: aditAs = STEditAs.ONE_CELL; break;
|
||||
default: aditAs = STEditAs.ONE_CELL;
|
||||
STEditAs.Enum editAs;
|
||||
switch (anchor.getAnchorType()) {
|
||||
case DONT_MOVE_AND_RESIZE:
|
||||
editAs = STEditAs.ABSOLUTE;
|
||||
break;
|
||||
case MOVE_AND_RESIZE:
|
||||
editAs = STEditAs.TWO_CELL;
|
||||
break;
|
||||
case MOVE_DONT_RESIZE:
|
||||
editAs = STEditAs.ONE_CELL;
|
||||
break;
|
||||
default:
|
||||
editAs = STEditAs.ONE_CELL;
|
||||
}
|
||||
ctAnchor.setEditAs(aditAs);
|
||||
ctAnchor.setEditAs(editAs);
|
||||
return ctAnchor;
|
||||
}
|
||||
|
||||
@ -526,15 +573,15 @@ public final class XSSFDrawing extends POIXMLDocumentPart implements Drawing<XSS
|
||||
off.setY(anchor.getDy1());
|
||||
XSSFSheet sheet = getSheet();
|
||||
double widthPx = 0;
|
||||
for (int col=anchor.getCol1(); col<anchor.getCol2(); col++) {
|
||||
for (int col = anchor.getCol1(); col < anchor.getCol2(); col++) {
|
||||
widthPx += sheet.getColumnWidthInPixels(col);
|
||||
}
|
||||
double heightPx = 0;
|
||||
for (int row=anchor.getRow1(); row<anchor.getRow2(); row++) {
|
||||
for (int row = anchor.getRow1(); row < anchor.getRow2(); row++) {
|
||||
heightPx += ImageUtils.getRowHeightInPixels(sheet, row);
|
||||
}
|
||||
long width = Units.pixelToEMU((int)widthPx);
|
||||
long height = Units.pixelToEMU((int)heightPx);
|
||||
long width = Units.pixelToEMU((int) widthPx);
|
||||
long height = Units.pixelToEMU((int) heightPx);
|
||||
CTPositiveSize2D ext = xfrm.addNewExt();
|
||||
ext.setCx(width - anchor.getDx1() + anchor.getDx2());
|
||||
ext.setCy(height - anchor.getDy1() + anchor.getDy2());
|
||||
@ -543,17 +590,15 @@ public final class XSSFDrawing extends POIXMLDocumentPart implements Drawing<XSS
|
||||
return xfrm;
|
||||
}
|
||||
|
||||
private long newShapeId(){
|
||||
return 1+
|
||||
drawing.sizeOfAbsoluteAnchorArray()+
|
||||
drawing.sizeOfOneCellAnchorArray()+
|
||||
drawing.sizeOfTwoCellAnchorArray();
|
||||
private long newShapeId() {
|
||||
return 1 + drawing.sizeOfAbsoluteAnchorArray() + drawing.sizeOfOneCellAnchorArray() + drawing
|
||||
.sizeOfTwoCellAnchorArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list of shapes in this drawing
|
||||
*/
|
||||
public List<XSSFShape> getShapes(){
|
||||
public List<XSSFShape> getShapes() {
|
||||
List<XSSFShape> lst = new ArrayList<>();
|
||||
XmlCursor cur = drawing.newCursor();
|
||||
try {
|
||||
@ -569,7 +614,7 @@ public final class XSSFDrawing extends POIXMLDocumentPart implements Drawing<XSS
|
||||
/**
|
||||
* @return list of shapes in this shape group
|
||||
*/
|
||||
public List<XSSFShape> getShapes(XSSFShapeGroup groupshape){
|
||||
public List<XSSFShape> getShapes(XSSFShapeGroup groupshape) {
|
||||
List<XSSFShape> lst = new ArrayList<>();
|
||||
XmlCursor cur = groupshape.getCTGroupShape().newCursor();
|
||||
try {
|
||||
@ -593,29 +638,28 @@ public final class XSSFDrawing extends POIXMLDocumentPart implements Drawing<XSS
|
||||
// ignore anchor elements
|
||||
continue;
|
||||
} else if (obj instanceof CTPicture) {
|
||||
shape = new XSSFPicture(this, (CTPicture)obj) ;
|
||||
} else if(obj instanceof CTConnector) {
|
||||
shape = new XSSFConnector(this, (CTConnector)obj) ;
|
||||
} else if(obj instanceof CTShape) {
|
||||
shape = hasOleLink(obj)
|
||||
? new XSSFObjectData(this, (CTShape)obj)
|
||||
: new XSSFSimpleShape(this, (CTShape)obj) ;
|
||||
} else if(obj instanceof CTGraphicalObjectFrame) {
|
||||
shape = new XSSFGraphicFrame(this, (CTGraphicalObjectFrame)obj) ;
|
||||
} else if(obj instanceof CTGroupShape) {
|
||||
shape = new XSSFShapeGroup(this, (CTGroupShape)obj) ;
|
||||
} else if(obj instanceof XmlAnyTypeImpl) {
|
||||
LOG.log(POILogger.WARN, "trying to parse AlternateContent, "
|
||||
+ "this unlinks the returned Shapes from the underlying xml content, "
|
||||
+ "so those shapes can't be used to modify the drawing, "
|
||||
+ "i.e. modifications will be ignored!");
|
||||
shape = new XSSFPicture(this, (CTPicture) obj);
|
||||
} else if (obj instanceof CTConnector) {
|
||||
shape = new XSSFConnector(this, (CTConnector) obj);
|
||||
} else if (obj instanceof CTShape) {
|
||||
shape = hasOleLink(obj) ? new XSSFObjectData(this, (CTShape) obj)
|
||||
: new XSSFSimpleShape(this, (CTShape) obj);
|
||||
} else if (obj instanceof CTGraphicalObjectFrame) {
|
||||
shape = new XSSFGraphicFrame(this, (CTGraphicalObjectFrame) obj);
|
||||
} else if (obj instanceof CTGroupShape) {
|
||||
shape = new XSSFShapeGroup(this, (CTGroupShape) obj);
|
||||
} else if (obj instanceof XmlAnyTypeImpl) {
|
||||
LOG.log(POILogger.WARN,
|
||||
"trying to parse AlternateContent, " + "this unlinks the returned Shapes from the underlying xml content, " + "so those shapes can't be used to modify the drawing, " + "i.e. modifications will be ignored!");
|
||||
|
||||
// XmlAnyTypeImpl is returned for AlternateContent parts, which might contain a CTDrawing
|
||||
// XmlAnyTypeImpl is returned for AlternateContent
|
||||
// parts, which might contain a CTDrawing
|
||||
cur.push();
|
||||
cur.toFirstChild();
|
||||
XmlCursor cur2 = null;
|
||||
try {
|
||||
// need to parse AlternateContent again, otherwise the child elements aren't typed,
|
||||
// need to parse AlternateContent again,
|
||||
// otherwise the child elements aren't typed,
|
||||
// but also XmlAnyTypes
|
||||
CTDrawing alterWS = CTDrawing.Factory.parse(cur.newXMLStreamReader());
|
||||
cur2 = alterWS.newCursor();
|
||||
@ -636,7 +680,7 @@ public final class XSSFDrawing extends POIXMLDocumentPart implements Drawing<XSS
|
||||
continue;
|
||||
}
|
||||
|
||||
assert(shape != null);
|
||||
assert (shape != null);
|
||||
shape.anchor = getAnchorFromParent(obj);
|
||||
lst.add(shape);
|
||||
|
||||
@ -651,7 +695,7 @@ public final class XSSFDrawing extends POIXMLDocumentPart implements Drawing<XSS
|
||||
|
||||
private boolean hasOleLink(XmlObject shape) {
|
||||
QName uriName = new QName(null, "uri");
|
||||
String xquery = "declare namespace a='"+XSSFRelation.NS_DRAWINGML+"' .//a:extLst/a:ext";
|
||||
String xquery = "declare namespace a='" + XSSFRelation.NS_DRAWINGML + "' .//a:extLst/a:ext";
|
||||
XmlCursor cur = shape.newCursor();
|
||||
cur.selectPath(xquery);
|
||||
try {
|
||||
@ -667,21 +711,21 @@ public final class XSSFDrawing extends POIXMLDocumentPart implements Drawing<XSS
|
||||
return false;
|
||||
}
|
||||
|
||||
private XSSFAnchor getAnchorFromParent(XmlObject obj){
|
||||
private XSSFAnchor getAnchorFromParent(XmlObject obj) {
|
||||
XSSFAnchor anchor = null;
|
||||
|
||||
XmlObject parentXbean = null;
|
||||
XmlCursor cursor = obj.newCursor();
|
||||
if(cursor.toParent()) {
|
||||
if (cursor.toParent()) {
|
||||
parentXbean = cursor.getObject();
|
||||
}
|
||||
cursor.dispose();
|
||||
if(parentXbean != null){
|
||||
if (parentXbean != null) {
|
||||
if (parentXbean instanceof CTTwoCellAnchor) {
|
||||
CTTwoCellAnchor ct = (CTTwoCellAnchor)parentXbean;
|
||||
CTTwoCellAnchor ct = (CTTwoCellAnchor) parentXbean;
|
||||
anchor = new XSSFClientAnchor(ct.getFrom(), ct.getTo());
|
||||
} else if (parentXbean instanceof CTOneCellAnchor) {
|
||||
CTOneCellAnchor ct = (CTOneCellAnchor)parentXbean;
|
||||
CTOneCellAnchor ct = (CTOneCellAnchor) parentXbean;
|
||||
anchor = new XSSFClientAnchor(getSheet(), ct.getFrom(), ct.getExt());
|
||||
} else if (parentXbean instanceof CTAbsoluteAnchor) {
|
||||
CTAbsoluteAnchor ct = (CTAbsoluteAnchor) parentXbean;
|
||||
@ -700,7 +744,7 @@ public final class XSSFDrawing extends POIXMLDocumentPart implements Drawing<XSS
|
||||
* @return the sheet associated with the drawing
|
||||
*/
|
||||
public XSSFSheet getSheet() {
|
||||
return (XSSFSheet)getParent();
|
||||
return (XSSFSheet) getParent();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -84,7 +84,6 @@ import org.openxmlformats.schemas.wordprocessingml.x2006.main.STDocProtect;
|
||||
import org.openxmlformats.schemas.wordprocessingml.x2006.main.STHdrFtr;
|
||||
import org.openxmlformats.schemas.wordprocessingml.x2006.main.STOnOff;
|
||||
import org.openxmlformats.schemas.wordprocessingml.x2006.main.StylesDocument;
|
||||
import org.openxmlformats.schemas.wordprocessingml.x2006.main.*;
|
||||
|
||||
/**
|
||||
* <p>High(ish) level class for working with .docx files.</p>
|
||||
|
Loading…
x
Reference in New Issue
Block a user