Rainer Klute klute@rainer-klute.de
Bruno Girin brunogirin@gmail.com
+ Yegor Kozlov yegor at apache.org
This build was tested with ant 1.6.2 although it will probably work with
other versions. The following jar files should be available on the
======= ========
junit(3.8+) http://www.junit.org
- The ant jar "optional.jar" should also be available otherwise the
- build will fail.
-
To build the documentation you will need to install forrest and set
the FORREST_HOME environment variable. Forrest 0.5.1 required.
happens to you, try giving Ant some more memory when you run it, eg:
ANT_OPTS="-Xmx1024m -XX:MaxPermSize=256m" ant test
-
- TO BE COMPLETED:
-
- Convert book.xml files to a sitemap.
-
-->
<project name="POI Build" default="help" basedir=".">
- <description>The Apache POI project Ant build.</description>
-
- <property environment="env"/>
-
- <property name="repository.m2" value="http://repo1.maven.org"/>
- <property name="forrest.home" value="${env.FORREST_HOME}"/>
-
- <!-- Main: -->
- <property name="main.resource1.dir" value="src/resources/main"/>
- <property name="main.src" location="src/java"/>
- <property name="main.src.test" location="src/testcases"/>
- <property name="main.documentation" value="src/documentation"/>
- <property name="main.output.dir" location="build/classes"/>
- <property name="main.output.test.dir" location="build/test-classes"/>
- <property name="main.lib" location="lib"/>
- <property name="ooxml.lib" location="ooxml-lib"/>
- <property name="main.reports.test" location="build/test-results"/>
- <property name="poi.test.dir" location="test-data"/>
-
- <property name="main.commons-logging.jar" location="${main.lib}/commons-logging-1.1.jar"/>
- <property name="main.commons-logging.url" value="${repository.m2}/maven2/commons-logging/commons-logging/1.1/commons-logging-1.1.jar"/>
- <property name="main.log4j.jar" location="${main.lib}/log4j-1.2.13.jar"/>
- <property name="main.log4j.url" value="${repository.m2}/maven2/log4j/log4j/1.2.13/log4j-1.2.13.jar"/>
- <property name="main.junit.jar" location="${main.lib}/junit-3.8.1.jar"/>
- <property name="main.junit.url" value="${repository.m2}/maven2/junit/junit/3.8.1/junit-3.8.1.jar"/>
-
- <property name="main.testokfile" location="build/main-testokfile.txt"/>
-
- <!-- Scratchpad: -->
- <property name="scratchpad.resource1.dir" value="src/resources/scratchpad"/>
- <property name="scratchpad.src" location="src/scratchpad/src"/>
- <property name="scratchpad.src.test" location="src/scratchpad/testcases"/>
- <property name="scratchpad.lib" location="src/scratchpad/lib"/>
- <property name="scratchpad.reports.test" location="build/scratchpad-test-results"/>
- <property name="scratchpad.output.dir" location="build/scratchpad-classes"/>
- <property name="scratchpad.output.test.dir" location="build/scratchpad-test-classes"/>
- <property name="scratchpad.testokfile" location="build/scratchpad-testokfile.txt"/>
-
- <!-- Contributed software: -->
- <property name="contrib.src" location="src/contrib/src"/>
- <property name="contrib.src.test" location="src/contrib/testcases"/>
- <property name="contrib.lib" location="src/contrib/lib"/>
- <property name="contrib.reports.test" location="build/contrib-test-results"/>
- <property name="contrib.output.dir" location="build/contrib-classes"/>
- <property name="contrib.output.test.dir" location="build/contrib-test-classes"/>
- <property name="contrib.testokfile" location="build/contrib-testokfile.txt"/>
-
- <!-- Examples: -->
- <property name="examples.src" location="src/examples/src"/>
- <property name="examples.output.dir" location="build/examples-classes"/>
-
- <!-- Scratchpad Examples: -->
- <property name="scratchpad.examples.src" location="src/scratchpad/examples/src"/>
- <property name="scratchpad.examples.output.dir" location="build/scratchpad-examples-classes"/>
-
- <!-- OOXML support: -->
- <property name="ooxml.src" location="src/ooxml/java"/>
- <property name="ooxml.src.test" location="src/ooxml/testcases"/>
- <property name="ooxml.reports.test" location="build/ooxml-test-results"/>
- <property name="ooxml.output.dir" location="build/ooxml-classes"/>
- <property name="ooxml.output.test.dir" location="build/ooxml-test-classes"/>
- <property name="ooxml.testokfile" location="build/ooxml-testokfile.txt"/>
-
- <!-- The following jars are downloaded by the fetch-ooxml-jars task -->
- <property name="ooxml.dom4j.jar" location="${ooxml.lib}/dom4j-1.6.1.jar"/>
- <property name="ooxml.dom4j.url" value="${repository.m2}/maven2/dom4j/dom4j/1.6.1/dom4j-1.6.1.jar"/>
- <property name="ooxml.xmlbeans.jar" location="${ooxml.lib}/xmlbeans-2.3.0.jar"/>
- <property name="ooxml.xmlbeans.url" value="${repository.m2}/maven2/org/apache/xmlbeans/xmlbeans/2.3.0/xmlbeans-2.3.0.jar"/>
- <property name="ooxml.jsr173.jar" location="${ooxml.lib}/geronimo-stax-api_1.0_spec-1.0.jar"/>
- <property name="ooxml.jsr173.url" value="${repository.m2}/maven2/org/apache/geronimo/specs/geronimo-stax-api_1.0_spec/1.0/geronimo-stax-api_1.0_spec-1.0.jar"/>
- <property name="ooxml.schemas.jar" location="${ooxml.lib}/ooxml-schemas-1.0.jar"/>
- <property name="ooxml.schemas.url" value="${repository.m2}/maven2/org/apache/poi/ooxml-schemas/1.0/ooxml-schemas-1.0.jar"/>
-
- <!-- See http://www.ecma-international.org/publications/standards/Ecma-376.htm -->
- <!-- "Copy these file(s), free of charge" -->
- <property name="ooxml.xsds.ozip" location="${ooxml.lib}/OfficeOpenXML-Part4.zip"/>
- <property name="ooxml.xsds.izip" location="${ooxml.lib}/OfficeOpenXML-XMLSchema.zip"/>
- <property name="ooxml.xsds.url" value="http://www.ecma-international.org/publications/files/ECMA-ST/Office%20Open%20XML%201st%20edition%20Part%204%20(PDF).zip" />
- <property name="ooxml.xsds.tmp.dir" location="build/ooxml-xsds"/>
- <property name="ooxml.xsds.src.dir" location="build/ooxml-xsds-src"/>
- <property name="ooxml.xsds.src.jar" location="${ooxml.lib}/ooxml-schemas-src-1.0.jar"/>
- <property name="ooxml.xsds.jar" location="${ooxml.lib}/ooxml-schemas-1.0.jar"/>
-
- <property name="maven.ooxml.xsds.version.id" value="1.0"/>
- <property name="maven.ooxml.xsds.jar" value="ooxml-schemas-${maven.ooxml.xsds.version.id}.jar"/>
-
- <property name="build.site" location="build/tmp/site/build/site"/>
- <property name="build.site.src" location="build/tmp/site"/>
- <property name="junit.report.dir" location="${build.site}/junit"/>
- <property name="apidocs.report.dir" location="${build.site}/apidocs"/>
- <property name="dist.dir" location="build/dist"/>
- <property name="mavendist.ooxml.dir" location="build/maven-ooxml-dependencies"/>
- <property name="apache.repository" value="scp://people.apache.org/www/people.apache.org/repo/m2-ibiblio-rsync-repository"/>
- <property name="jar.name" value="poi"/>
- <property name="version.id" value="3.6-beta1"/>
- <property name="halt.on.test.failure" value="true"/>
-
- <property name="jdk.version.source" value="1.5" description="JDK version of source code"/>
- <property name="jdk.version.class" value="1.5" description="JDK version of generated class files"/>
+ <description>The Apache POI project Ant build.</description>
+
+ <property name="version.id" value="3.6-beta1"/>
+
+ <property environment="env"/>
+ <!-- the repository to download jars from -->
+ <property name="repository.m2" value="http://repo1.maven.org"/>
+
+ <property name="main.lib" location="lib"/>
+ <property name="ooxml.lib" location="ooxml-lib"/>
+ <property name="forrest.home" value="${env.FORREST_HOME}"/>
+
+ <!-- compiler options options -->
+ <property name="jdk.version.source" value="1.5" description="JDK version of source code"/>
+ <property name="jdk.version.class" value="1.5" description="JDK version of generated class files"/>
+ <property name="compile.debug" value="true"/>
+
+ <!--
+ JVM system properties for running tests,
+ user.language and user.country are required as we have locale-sensitive formatters
+ -->
+ <property name="user.language" value="en"/>
+ <property name="user.country" value="US"/>
+ <property name="POI.testdata.path" value="test-data"/>
+ <property name="java.awt.headless" value="true"/>
+
+ <!-- Main: -->
+ <property name="main.resource1.dir" value="src/resources/main"/>
+ <property name="main.src" location="src/java"/>
+ <property name="main.src.test" location="src/testcases"/>
+ <property name="main.documentation" value="src/documentation"/>
+ <property name="main.output.dir" location="build/classes"/>
+ <property name="main.output.test.dir" location="build/test-classes"/>
+ <property name="main.reports.test" location="build/test-results"/>
+ <property name="main.testokfile" location="build/main-testokfile.txt"/>
+
+ <!-- Scratchpad: -->
+ <property name="scratchpad.resource1.dir" value="src/resources/scratchpad"/>
+ <property name="scratchpad.src" location="src/scratchpad/src"/>
+ <property name="scratchpad.src.test" location="src/scratchpad/testcases"/>
+ <property name="scratchpad.reports.test" location="build/scratchpad-test-results"/>
+ <property name="scratchpad.output.dir" location="build/scratchpad-classes"/>
+ <property name="scratchpad.output.test.dir" location="build/scratchpad-test-classes"/>
+ <property name="scratchpad.testokfile" location="build/scratchpad-testokfile.txt"/>
+
+ <!-- Contributed software: -->
+ <property name="contrib.src" location="src/contrib/src"/>
+ <property name="contrib.src.test" location="src/contrib/testcases"/>
+ <property name="contrib.reports.test" location="build/contrib-test-results"/>
+ <property name="contrib.output.dir" location="build/contrib-classes"/>
+ <property name="contrib.output.test.dir" location="build/contrib-test-classes"/>
+ <property name="contrib.testokfile" location="build/contrib-testokfile.txt"/>
+
+ <!-- Examples: -->
+ <property name="examples.src" location="src/examples/src"/>
+ <property name="examples.output.dir" location="build/examples-classes"/>
+
+ <!-- OOXML support: -->
+ <property name="ooxml.src" location="src/ooxml/java"/>
+ <property name="ooxml.src.test" location="src/ooxml/testcases"/>
+ <property name="ooxml.reports.test" location="build/ooxml-test-results"/>
+ <property name="ooxml.output.dir" location="build/ooxml-classes"/>
+ <property name="ooxml.output.test.dir" location="build/ooxml-test-classes"/>
+ <property name="ooxml.testokfile" location="build/ooxml-testokfile.txt"/>
+ <property name="ooxml.lite.output.dir" location="build/ooxml-lite-classes"/>
+
+ <!-- jars in the /lib directory, see the fetch-jars target-->
+ <property name="main.commons-logging.jar" location="${main.lib}/commons-logging-1.1.jar"/>
+ <property name="main.commons-logging.url"
+ value="${repository.m2}/maven2/commons-logging/commons-logging/1.1/commons-logging-1.1.jar"/>
+ <property name="main.log4j.jar" location="${main.lib}/log4j-1.2.13.jar"/>
+ <property name="main.log4j.url" value="${repository.m2}/maven2/log4j/log4j/1.2.13/log4j-1.2.13.jar"/>
+ <property name="main.junit.jar" location="${main.lib}/junit-3.8.1.jar"/>
+ <property name="main.junit.url" value="${repository.m2}/maven2/junit/junit/3.8.1/junit-3.8.1.jar"/>
+
+ <!-- jars in the lib-ooxml directory, see the fetch-ooxml-jars target-->
+ <property name="ooxml.dom4j.jar" location="${ooxml.lib}/dom4j-1.6.1.jar"/>
+ <property name="ooxml.dom4j.url" value="${repository.m2}/maven2/dom4j/dom4j/1.6.1/dom4j-1.6.1.jar"/>
+ <property name="ooxml.xmlbeans.jar" location="${ooxml.lib}/xmlbeans-2.3.0.jar"/>
+ <property name="ooxml.xmlbeans.url"
+ value="${repository.m2}/maven2/org/apache/xmlbeans/xmlbeans/2.3.0/xmlbeans-2.3.0.jar"/>
+ <property name="ooxml.jsr173.jar" location="${ooxml.lib}/geronimo-stax-api_1.0_spec-1.0.jar"/>
+ <property name="ooxml.jsr173.url"
+ value="${repository.m2}/maven2/org/apache/geronimo/specs/geronimo-stax-api_1.0_spec/1.0/geronimo-stax-api_1.0_spec-1.0.jar"/>
+ <property name="ooxml.schemas.jar" location="${ooxml.lib}/ooxml-schemas-1.0.jar"/>
+ <property name="ooxml.schemas.url"
+ value="${repository.m2}/maven2/org/apache/poi/ooxml-schemas/1.0/ooxml-schemas-1.0.jar"/>
+
+ <!-- See http://www.ecma-international.org/publications/standards/Ecma-376.htm -->
+ <!-- "Copy these file(s), free of charge" -->
+ <property name="ooxml.xsds.ozip" location="${ooxml.lib}/OfficeOpenXML-Part4.zip"/>
+ <property name="ooxml.xsds.izip" location="${ooxml.lib}/OfficeOpenXML-XMLSchema.zip"/>
+ <property name="ooxml.xsds.url"
+ value="http://www.ecma-international.org/publications/files/ECMA-ST/Office%20Open%20XML%201st%20edition%20Part%204%20(PDF).zip"/>
+ <property name="ooxml.xsds.src.dir" location="build/ooxml-xsds-src"/>
+ <property name="ooxml.xsds.src.jar" location="${ooxml.lib}/ooxml-schemas-src-1.0.jar"/>
+ <property name="ooxml.xsds.jar" location="${ooxml.lib}/ooxml-schemas-1.0.jar"/>
+
+ <property name="maven.ooxml.xsds.version.id" value="1.0"/>
+ <property name="maven.ooxml.xsds.jar" value="ooxml-schemas-${maven.ooxml.xsds.version.id}.jar"/>
+
+ <!-- build and distro settings -->
+ <property name="jar.name" value="poi"/>
+ <property name="repository.m2" value="http://repo1.maven.org"/>
+ <property name="build.site" location="build/tmp/site/build/site"/>
+ <property name="build.site.src" location="build/tmp/site"/>
+ <property name="apidocs.report.dir" location="${build.site}/apidocs"/>
+ <property name="dist.dir" location="build/dist"/>
+ <property name="apache.repository"
+ value="scp://people.apache.org/www/people.apache.org/repo/m2-ibiblio-rsync-repository"/>
+ <property name="halt.on.test.failure" value="true"/>
+
+ <propertyset id="junit.properties">
+ <propertyref name="user.language"/>
+ <propertyref name="user.country"/>
+ <propertyref name="POI.testdata.path"/>
+ <propertyref name="java.awt.headless"/>
+ </propertyset>
<path id="main.classpath">
- <fileset dir="${main.lib}">
- <include name="*.jar"/>
- </fileset>
- <pathelement location="${main.resource1.dir}"/>
+ <fileset dir="${main.lib}">
+ <include name="*.jar"/>
+ </fileset>
</path>
<path id="scratchpad.classpath">
<path refid="main.classpath"/>
<pathelement location="${main.output.dir}"/>
- <pathelement location="${scratchpad.resource1.dir}"/>
</path>
<path id="contrib.classpath">
<path refid="main.classpath"/>
<pathelement location="${main.output.dir}"/>
- <pathelement location="${main.output.test.dir}"/>
- <pathelement location="${scratchpad.output.dir}"/>
- <pathelement location="${scratchpad.output.test.dir}"/>
- <pathelement location="${contrib.output.dir}"/>
- <pathelement location="${contrib.output.test.dir}"/>
</path>
<path id="ooxml.classpath">
+ <pathelement location="${ooxml.dom4j.jar}"/>
+ <pathelement location="${ooxml.xmlbeans.jar}"/>
+ <pathelement location="${ooxml.schemas.jar}"/>
<path refid="main.classpath"/>
<pathelement location="${main.output.dir}"/>
<pathelement location="${scratchpad.output.dir}"/>
- <fileset dir="${ooxml.lib}">
- <include name="*.jar" />
- </fileset>
</path>
<path id="test.classpath">
<path refid="main.classpath"/>
<pathelement location="${main.output.dir}"/>
<pathelement location="${main.output.test.dir}"/>
- <pathelement location="${junit.jar1.dir}"/>
+ </path>
+
+ <path id="test.scratchpad.classpath">
+ <path refid="scratchpad.classpath"/>
+ <pathelement location="${main.output.test.dir}"/>
+ <pathelement location="${scratchpad.output.dir}"/>
+ <pathelement location="${scratchpad.output.test.dir}"/>
</path>
<path id="test.ooxml.classpath">
<path refid="ooxml.classpath"/>
<pathelement location="${ooxml.output.dir}"/>
<pathelement location="${ooxml.output.test.dir}"/>
- <pathelement location="${main.output.test.dir}"/> <!-- ooxml tests use some utilities from main tests -->
- <pathelement location="${scratchpad.output.test.dir}"/>
- <pathelement location="${junit.jar1.dir}"/>
+ <pathelement location="${main.output.test.dir}"/>
+ </path>
+
+ <path id="ooxml-lite.classpath">
+ <pathelement location="${ooxml.dom4j.jar}"/>
+ <pathelement location="${ooxml.xmlbeans.jar}"/>
+ <pathelement location="build/ooxml-xsds-lite"/> <!-- instead of ooxml-schemas.jar use the filtered classes-->
+ <path refid="main.classpath"/>
+ <pathelement location="${main.output.dir}"/>
+ <pathelement location="${scratchpad.output.dir}"/>
+ <path refid="ooxml.classpath"/>
+ <pathelement location="${ooxml.output.dir}"/>
+ <pathelement location="${ooxml.output.test.dir}"/>
+ <pathelement location="${main.output.test.dir}"/>
</path>
</path>
-
- <!-- Prints POI's Ant usage help -->
- <target name="help" description="Prints Apache POI's Ant usage help">
- <echo>
- - Execute "ant -projecthelp" to view a listing of the main build
- targets.
- - Execute "ant help-properties" to view a listing of some properties
- controlling the build process.
- </echo>
- </target>
+ <!-- Prints POI's Ant usage help -->
+ <target name="help" description="Prints Apache POI's Ant usage help">
+ <echo>
+ - Execute "ant -projecthelp" to view a listing of the main build
+ targets.
+ - Execute "ant help-properties" to view a listing of some properties
+ controlling the build process.
+ </echo>
+ </target>
+ <target name="help-properties"
+ description="Prints a listing of build controlling properties">
+ <echo>
+ The following properties control the build process:
- <target name="help-properties"
- description="Prints a listing of build controlling properties">
- <echo>
- The following properties control the build process:
+ -Ddisconnected="true": Do not execute any targets that require an online
+ connection to the Internet.
+ -Dtestcase=org.apache.poi.xxx.xxx : for the single-test target, specify
+ the test to run
+ -Dfilename=xxxx.xls : for the command line task targets, specify the
+ file to run against
- -Ddisconnected="true": Do not execute any targets that require an online
- connection to the Internet.
- -Dtestcase=org.apache.poi.xxx.xxx : for the single-test target, specify
- the test to run
- -Dfilename=xxxx.xls : for the command line task targets, specify the
- file to run against
+ WARNING: This list is not exhaustive.
+ </echo>
+ </target>
- WARNING: This list is not exhaustive.
- </echo>
- </target>
+ <tstamp>
+ <format property="tstamp.year" pattern="yyyy"/>
+ </tstamp>
<target name="init" depends="fetch-jars,fetch-ooxml-jars">
-
- <tstamp>
- <format property="tstamp.year" pattern="yyyy"/>
- </tstamp>
-
<mkdir dir="build"/>
- <mkdir dir="build/non-ant-classes"/>
<mkdir dir="${main.output.dir}"/>
- <mkdir dir="${scratchpad.output.dir}"/>
- <mkdir dir="${contrib.output.dir}"/>
- <mkdir dir="${examples.output.dir}"/>
- <mkdir dir="${scratchpad.examples.output.dir}"/>
- <mkdir dir="${ooxml.output.dir}"/>
<mkdir dir="${main.output.test.dir}"/>
- <mkdir dir="${contrib.output.test.dir}"/>
- <mkdir dir="${scratchpad.output.test.dir}"/>
- <mkdir dir="${ooxml.output.test.dir}"/>
<mkdir dir="${main.reports.test}"/>
+ <mkdir dir="${scratchpad.output.dir}"/>
+ <mkdir dir="${scratchpad.output.test.dir}"/>
<mkdir dir="${scratchpad.reports.test}"/>
+ <mkdir dir="${contrib.output.dir}"/>
+ <mkdir dir="${contrib.output.test.dir}"/>
<mkdir dir="${contrib.reports.test}"/>
+ <mkdir dir="${ooxml.output.dir}"/>
+ <mkdir dir="${ooxml.output.test.dir}"/>
<mkdir dir="${ooxml.reports.test}"/>
- <mkdir dir="${junit.report.dir}"/>
- <mkdir dir="${apidocs.report.dir}"/>
- <mkdir dir="${ooxml.xsds.tmp.dir}" />
+ <mkdir dir="${examples.output.dir}"/>
<mkdir dir="${dist.dir}"/>
- <mkdir dir="${build.site.src}/${main.documentation}"/>
-
- <copy todir="${build.site.src}/${main.documentation}">
- <fileset dir="${main.documentation}"/>
- </copy>
- <copy file="forrest.properties" tofile="${build.site.src}/forrest.properties"/>
</target>
<target name="clean">
<delete dir="build"/>
</target>
-
<target name="testexist">
- <echo message="Testing for ${destfile}" level="debug"/>
- <available file="${destfile}" property="exist"/>
+ <echo message="Testing for ${destfile}" level="debug"/>
+ <available file="${destfile}" property="exist"/>
</target>
<target name="downloadfile" unless="exist" depends="testexist">
- <get src="${sourcefile}" dest="${destfile}" />
+ <get src="${sourcefile}" dest="${destfile}"/>
</target>
<target name="check-jars">
</target>
<target name="fetch-jars" depends="check-jars" unless="jars.present"
- description="Fetches needed JAR files from the Internet">
+ description="Fetches needed JAR files from the Internet">
+ <mkdir dir="${main.lib}"/>
<antcall target="downloadfile">
- <param name="sourcefile" value="${main.commons-logging.url}"/>
- <param name="destfile" value="${main.commons-logging.jar}"/>
+ <param name="sourcefile" value="${main.commons-logging.url}"/>
+ <param name="destfile" value="${main.commons-logging.jar}"/>
</antcall>
<antcall target="downloadfile">
- <param name="sourcefile" value="${main.log4j.url}"/>
- <param name="destfile" value="${main.log4j.jar}"/>
+ <param name="sourcefile" value="${main.log4j.url}"/>
+ <param name="destfile" value="${main.log4j.jar}"/>
</antcall>
<antcall target="downloadfile">
- <param name="sourcefile" value="${main.junit.url}"/>
- <param name="destfile" value="${main.junit.jar}"/>
+ <param name="sourcefile" value="${main.junit.url}"/>
+ <param name="destfile" value="${main.junit.jar}"/>
</antcall>
</target>
</condition>
</target>
<target name="fetch-ooxml-jars" depends="check-ooxml-jars" unless="ooxml.jars.present">
- <antcall target="downloadfile">
- <param name="sourcefile" value="${ooxml.dom4j.url}"/>
- <param name="destfile" value="${ooxml.dom4j.jar}"/>
- </antcall>
- <antcall target="downloadfile">
- <param name="sourcefile" value="${ooxml.xmlbeans.url}"/>
- <param name="destfile" value="${ooxml.xmlbeans.jar}"/>
- </antcall>
- <antcall target="downloadfile">
- <param name="sourcefile" value="${ooxml.jsr173.url}"/>
- <param name="destfile" value="${ooxml.jsr173.jar}"/>
- </antcall>
- <antcall target="downloadfile">
- <param name="sourcefile" value="${ooxml.schemas.url}"/>
- <param name="destfile" value="${ooxml.schemas.jar}"/>
- </antcall>
+ <mkdir dir="${ooxml.lib}"/>
+ <antcall target="downloadfile">
+ <param name="sourcefile" value="${ooxml.dom4j.url}"/>
+ <param name="destfile" value="${ooxml.dom4j.jar}"/>
+ </antcall>
+ <antcall target="downloadfile">
+ <param name="sourcefile" value="${ooxml.xmlbeans.url}"/>
+ <param name="destfile" value="${ooxml.xmlbeans.jar}"/>
+ </antcall>
+ <antcall target="downloadfile">
+ <param name="sourcefile" value="${ooxml.jsr173.url}"/>
+ <param name="destfile" value="${ooxml.jsr173.jar}"/>
+ </antcall>
+ <antcall target="downloadfile">
+ <param name="sourcefile" value="${ooxml.schemas.url}"/>
+ <param name="destfile" value="${ooxml.schemas.jar}"/>
+ </antcall>
</target>
- <target name="check-ooxml-xsds">
+ <target name="check-ooxml-xsds">
<condition property="ooxml-xsds.present">
<or>
<and>
<isset property="disconnected"/>
</or>
</condition>
- </target>
+ </target>
<target name="fetch-ooxml-xsds" unless="ooxml-xsds.present"
- description="Fetches needed OOXML xsd files from the Internet">
+ description="Fetches needed OOXML xsd files from the Internet">
<get src="${ooxml.xsds.url}" dest="${ooxml.xsds.ozip}"/>
- <unzip src="${ooxml.xsds.ozip}" dest="${ooxml.lib}">
- <patternset>
- <include name="OfficeOpenXML-XMLSchema.zip" />
- </patternset>
- </unzip>
- </target>
- <target name="check-compiled-ooxml-xsds">
+ <unzip src="${ooxml.xsds.ozip}" dest="${ooxml.lib}">
+ <patternset>
+ <include name="OfficeOpenXML-XMLSchema.zip"/>
+ </patternset>
+ </unzip>
+ </target>
+ <target name="check-compiled-ooxml-xsds">
<condition property="ooxml-compiled-xsds.present">
<or>
<and>
<isset property="disconnected"/>
</or>
</condition>
- </target>
- <target name="compile-ooxml-xsds" unless="ooxml-compiled-xsds.present"
- depends="check-jars,fetch-jars"
- description="Unpacks the OOXML xsd files, and compiles them into XmlBeans">
- <taskdef name="xmlbean"
- classname="org.apache.xmlbeans.impl.tool.XMLBean"
- classpath="${ooxml.dom4j.jar}:${ooxml.xmlbeans.jar}:${ooxml.jsr173.jar}" />
-
- <unzip src="${ooxml.xsds.izip}" dest="${ooxml.xsds.tmp.dir}" />
- <!--
- schema="build/ooxml-xsds/"
- schema="build/ooxml-xsds/sml-workbook.xsd"
- -->
- <xmlbean
- schema="${ooxml.xsds.tmp.dir}"
- srcgendir="${ooxml.xsds.src.dir}"
- optimize="yes"
- destfile="${ooxml.xsds.jar}"
- javasource="1.5"
- failonerror="true"
- fork="true"
- memoryMaximumSize="512m"
- >
- <classpath refid="ooxml.classpath"/>
- </xmlbean>
-
- <!-- Now make a jar of the schema sources -->
- <jar
- basedir="${ooxml.xsds.src.dir}"
- destfile="${ooxml.xsds.src.jar}"
- />
- </target>
-
- <!-- Build a 'lite' version of the ooxml-schemas.jar-->
- <target name="ooxml-xsds-lite" depends="test-ooxml">
- <java classname="org.apache.poi.util.OOXMLLite" fork="yes">
- <classpath refid="test.ooxml.classpath"/>
- <sysproperty key="POI.testdata.path" file="${poi.test.dir}"/>
- <sysproperty key="user.language" value="en"/>
- <sysproperty key="user.country" value="US"/>
- <arg line="-ooxml ${ooxml.xsds.jar} -test ${ooxml.output.test.dir} -dest build/ooxml-xsds-lite"/>
- </java>
- <echo message="Running ooxml tests against the 'lite' classes"/>
- <antcall target="test-ooxml-lite"/>
- <jar basedir="build/ooxml-xsds-lite" destfile="build/dist/ooxml-schemas-lite-${version.id}.jar"/>
- </target>
-
- <!-- Run ooxml tests against the 'lite' version of the ooxml-schemas.jar-->
- <target name="test-ooxml-lite">
- <junit printsummary="yes" fork="yes" forkmode="once" haltonfailure="${halt.on.test.failure}" failureproperty="ooxml.test.failed">
- <classpath>
- <path refid="main.classpath"/>
- <pathelement location="${main.output.dir}"/>
- <pathelement location="${scratchpad.output.dir}"/>
- <fileset dir="${ooxml.lib}">
- <include name="*.jar" />
- <exclude name="ooxml-schemas-*.jar" />
- </fileset>
- <pathelement location="build/ooxml-xsds-lite"/>
- <pathelement location="${ooxml.output.dir}"/>
- <pathelement location="${ooxml.output.test.dir}"/>
- <pathelement location="${main.output.test.dir}"/>
- <pathelement location="${scratchpad.output.test.dir}"/>
- <pathelement location="${junit.jar1.dir}"/>
- </classpath>
- <sysproperty key="user.language" value="en"/>
- <sysproperty key="user.country" value="US"/>
- <sysproperty key="POI.testdata.path" file="${poi.test.dir}"/>
- <sysproperty key="java.awt.headless" value="true"/>
- <formatter type="plain"/>
- <formatter type="xml"/>
- <batchtest todir="${ooxml.reports.test}">
- <fileset dir="${ooxml.src.test}">
- <include name="**/Test*.java"/>
- <exclude name="**/All*Tests.java"/>
- </fileset>
- </batchtest>
- </junit>
- </target>
-
- <target name="compile" depends="init, compile-main,
- compile-scratchpad, compile-contrib, compile-examples, compile-scratchpad-examples"
- description="Compiles the POI main classes, scratchpad, contrib, examples, and scratchpad examples"/>
-
- <target name="compile-main">
- <copy todir="${main.output.dir}">
- <fileset dir="${main.resource1.dir}"/>
- </copy>
- <javac target="${jdk.version.class}" source="${jdk.version.source}"
- failonerror="true" destdir="${main.output.dir}" debug="on" fork="yes">
- <src path="${main.src}" />
- <classpath refid="main.classpath"/>
- </javac>
- <javac target="${jdk.version.class}" source="${jdk.version.source}"
- failonerror="true" destdir="${main.output.test.dir}" debug="on"
- fork="yes" srcdir="${main.src.test}">
- <classpath>
- <path refid="main.classpath"/>
- <pathelement path="${main.output.dir}"/>
- <pathelement location="${junit.jar1.dir}"/>
- </classpath>
- </javac>
- </target>
-
- <target name="compile-scratchpad" depends="init,compile-main">
- <javac target="${jdk.version.class}" source="${jdk.version.source}"
- failonerror="true" destdir="${scratchpad.output.dir}" debug="on"
- fork="yes" srcdir="${scratchpad.src}">
- <classpath refid="scratchpad.classpath"/>
- </javac>
- <javac target="${jdk.version.class}" source="${jdk.version.source}"
- failonerror="true" destdir="${scratchpad.output.test.dir}" debug="on"
- fork="yes" srcdir="${scratchpad.src.test}">
- <classpath>
- <path refid="scratchpad.classpath"/>
- <pathelement location="${main.output.test.dir}"/>
- <pathelement location="${scratchpad.output.dir}"/>
- <pathelement location="${junit.jar1.dir}"/>
- </classpath>
- </javac>
-
- <!-- Copy HSLF Resources over -->
- <property name="hslf.data" value="org/apache/poi/hslf/data" />
- <mkdir dir="${scratchpad.output.dir}/${hslf.data}" />
- <copy todir="${scratchpad.output.dir}/${hslf.data}">
- <fileset dir="${scratchpad.src}/${hslf.data}">
- <include name="*.ppt" />
- </fileset>
- </copy>
-
- <!-- Copy HDGF Resources over -->
- <copy todir="${scratchpad.output.dir}">
- <fileset dir="${scratchpad.resource1.dir}"/>
- </copy>
- </target>
-
- <target name="compile-contrib" depends="init">
- <javac target="${jdk.version.class}" source="${jdk.version.source}"
- failonerror="true" destdir="${contrib.output.dir}" debug="on" fork="yes"
- srcdir="${contrib.src}">
- <classpath refid="contrib.classpath"/>
- </javac>
- <javac target="${jdk.version.class}" source="${jdk.version.source}"
- failonerror="true" destdir="${contrib.output.test.dir}" debug="on"
- fork="yes" srcdir="${contrib.src.test}">
- <classpath>
- <path refid="contrib.classpath"/>
- <pathelement path="${contrib.output.dir}"/>
- <pathelement location="${junit.jar1.dir}"/>
- </classpath>
- </javac>
- </target>
-
- <target name="compile-examples" depends="init,compile-ooxml">
- <javac target="${jdk.version.class}" source="${jdk.version.source}"
- failonerror="true" destdir="${examples.output.dir}" debug="on" fork="yes"
- srcdir="${examples.src}">
- <classpath>
- <path refid="examples.classpath"/>
- <path refid="ooxml.classpath"/>
- <pathelement path="${ooxml.output.dir}"/>
- <pathelement location="${junit.jar1.dir}"/>
- </classpath>
- </javac>
- </target>
-
- <target name="compile-scratchpad-examples" depends="init,compile-ooxml">
- <javac target="${jdk.version.class}" source="${jdk.version.source}"
- failonerror="true" destdir="${scratchpad.examples.output.dir}" debug="on" fork="yes"
- srcdir="${scratchpad.examples.src}">
- <classpath>
- <path refid="examples.classpath"/>
- <path refid="ooxml.classpath"/>
- <pathelement path="${ooxml.output.dir}"/>
- <pathelement location="${junit.jar1.dir}"/>
- </classpath>
- </javac>
- </target>
-
- <target name="compile-ooxml" depends="init, compile-main, compile-scratchpad">
- <javac target="1.5" source="1.5"
- destdir="${ooxml.output.dir}" debug="on" srcdir="${ooxml.src}">
- <classpath refid="ooxml.classpath"/>
- </javac>
-
- <javac target="1.5" source="1.5"
- failonerror="true" destdir="${ooxml.output.test.dir}" debug="on"
- fork="yes" srcdir="${ooxml.src.test}">
- <classpath>
- <path refid="ooxml.classpath"/>
- <pathelement path="${ooxml.output.dir}"/>
- <pathelement path="${main.output.test.dir}"/>
- <pathelement path="${scratchpad.output.test.dir}"/>
- <pathelement location="${junit.jar1.dir}"/>
- </classpath>
- </javac>
- </target>
-
- <target name="compile-version" depends="init"
- description="Compiles the version class">
- <!-- Generate the .java file -->
- <property name="version.java" value="${main.output.dir}/org/apache/poi/Version.java" />
- <delete file="${version.java}" />
- <copy
- file="src/resources/version/Version.java.template"
- tofile="${version.java}">
- <filterset>
- <filter token="VERSION" value="${version.id}" />
- <filter token="DSTAMP" value="${DSTAMP}" />
- </filterset>
- </copy>
-
- <!-- Compile -->
- <javac target="${jdk.version.class}" source="${jdk.version.source}"
- failonerror="true" destdir="${main.output.dir}" debug="on" fork="yes"
- srcdir="${main.output.dir}" />
- <!-- Tidy up -->
- <delete file="${version.java}" />
- </target>
-
- <target name="test" depends="compile,test-main,test-scratchpad,test-contrib,test-ooxml"
- description="Tests main, contrib, scratchpad and ooxml"/>
+ </target>
+ <target name="compile-ooxml-xsds" unless="ooxml-compiled-xsds.present"
+ depends="check-jars,fetch-jars"
+ description="Unpacks the OOXML xsd files, and compiles them into XmlBeans">
+ <property name="ooxml.xsds.tmp.dir" location="build/ooxml-xsds"/>
+ <mkdir dir="${ooxml.xsds.tmp.dir}"/>
+
+ <taskdef name="xmlbean"
+ classname="org.apache.xmlbeans.impl.tool.XMLBean"
+ classpath="${ooxml.xmlbeans.jar}:${ooxml.jsr173.jar}"/>
+
+ <unzip src="${ooxml.xsds.izip}" dest="${ooxml.xsds.tmp.dir}"/>
+ <!--
+ schema="build/ooxml-xsds/"
+ schema="build/ooxml-xsds/sml-workbook.xsd"
+ -->
+ <xmlbean
+ schema="${ooxml.xsds.tmp.dir}"
+ srcgendir="${ooxml.xsds.src.dir}"
+ optimize="yes"
+ destfile="${ooxml.xsds.jar}"
+ javasource="1.5"
+ failonerror="true"
+ fork="true"
+ memoryMaximumSize="512m"
+ >
+ <classpath refid="ooxml.classpath"/>
+ </xmlbean>
+
+ <!-- Now make a jar of the schema sources -->
+ <jar
+ basedir="${ooxml.xsds.src.dir}"
+ destfile="${ooxml.xsds.src.jar}"
+ />
+ </target>
+
+ <target name="compile" depends="init, compile-main,
+ compile-scratchpad, compile-contrib, compile-examples, compile-ooxml-lite"
+ description="Compiles the POI main classes, scratchpad, contrib and examples"/>
+
+ <target name="compile-main">
+ <javac target="${jdk.version.class}"
+ source="${jdk.version.source}"
+ destdir="${main.output.dir}"
+ srcdir="${main.src}"
+ debug="${compile.debug}"
+ fork="yes">
+ <classpath refid="main.classpath"/>
+ </javac>
+ <javac target="${jdk.version.class}"
+ source="${jdk.version.source}"
+ destdir="${main.output.test.dir}"
+ srcdir="${main.src.test}"
+ debug="${compile.debug}"
+ fork="yes">
+ <classpath>
+ <path refid="main.classpath"/>
+ <pathelement path="${main.output.dir}"/>
+ </classpath>
+ </javac>
+ <copy todir="${main.output.dir}">
+ <fileset dir="${main.resource1.dir}"/>
+ </copy>
+ </target>
+
+ <target name="compile-scratchpad" depends="compile-main">
+ <javac target="${jdk.version.class}"
+ source="${jdk.version.source}"
+ destdir="${scratchpad.output.dir}"
+ srcdir="${scratchpad.src}"
+ debug="${compile.debug}"
+ fork="yes">
+ <classpath refid="scratchpad.classpath"/>
+ </javac>
+ <javac target="${jdk.version.class}"
+ source="${jdk.version.source}"
+ destdir="${scratchpad.output.test.dir}"
+ srcdir="${scratchpad.src.test}"
+ debug="${compile.debug}"
+ fork="yes">
+ <classpath>
+ <path refid="scratchpad.classpath"/>
+ <pathelement location="${scratchpad.output.dir}"/>
+ <pathelement location="${main.output.test.dir}"/>
+ </classpath>
+ </javac>
+ <copy todir="${scratchpad.output.dir}">
+ <fileset dir="${scratchpad.resource1.dir}"/>
+ </copy>
+ </target>
+
+ <target name="compile-contrib" depends="compile-main">
+ <javac target="${jdk.version.class}"
+ source="${jdk.version.source}"
+ destdir="${contrib.output.dir}"
+ srcdir="${contrib.src}"
+ debug="${compile.debug}"
+ fork="yes">
+ <classpath refid="contrib.classpath"/>
+ </javac>
+ <javac target="${jdk.version.class}"
+ source="${jdk.version.source}"
+ failonerror="true"
+ destdir="${contrib.output.test.dir}"
+ srcdir="${contrib.src.test}"
+ debug="${compile.debug}"
+ fork="yes">
+ <classpath>
+ <path refid="contrib.classpath"/>
+ <pathelement path="${contrib.output.dir}"/>
+ </classpath>
+ </javac>
+ </target>
+
+ <target name="compile-examples" depends="compile-main,compile-scratchpad,compile-ooxml">
+ <javac target="${jdk.version.class}"
+ source="${jdk.version.source}"
+ destdir="${examples.output.dir}"
+ srcdir="${examples.src}"
+ debug="${compile.debug}"
+ fork="yes">
+ <classpath>
+ <path refid="ooxml.classpath"/>
+ <pathelement path="${ooxml.output.dir}"/>
+ </classpath>
+ </javac>
+ </target>
+
+ <target name="compile-ooxml" depends="compile-main,compile-scratchpad">
+ <javac target="${jdk.version.class}"
+ source="${jdk.version.source}"
+ destdir="${ooxml.output.dir}"
+ srcdir="${ooxml.src}"
+ debug="${compile.debug}">
+ <classpath refid="ooxml.classpath"/>
+ </javac>
+ <javac target="${jdk.version.class}"
+ source="${jdk.version.source}"
+ destdir="${ooxml.output.test.dir}"
+ srcdir="${ooxml.src.test}"
+ debug="${compile.debug}"
+ fork="yes">
+ <classpath>
+ <path refid="ooxml.classpath"/>
+ <pathelement path="${ooxml.output.dir}"/>
+ <pathelement path="${main.output.test.dir}"/>
+ </classpath>
+ </javac>
+ </target>
+
+ <target name="compile-version" depends="init"
+ description="Compiles the version class">
+ <!-- Generate the .java file -->
+ <property name="version.java" value="${main.output.dir}/org/apache/poi/Version.java"/>
+ <delete file="${version.java}"/>
+ <copy
+ file="src/resources/version/Version.java.template"
+ tofile="${version.java}">
+ <filterset>
+ <filter token="VERSION" value="${version.id}"/>
+ <filter token="DSTAMP" value="${DSTAMP}"/>
+ </filterset>
+ </copy>
+
+ <!-- Compile -->
+ <javac target="${jdk.version.class}" source="${jdk.version.source}"
+ failonerror="true" destdir="${main.output.dir}" debug="on" fork="yes"
+ srcdir="${main.output.dir}"/>
+ <!-- Tidy up -->
+ <delete file="${version.java}"/>
+ </target>
+
+ <target name="test" depends="compile,test-main,test-scratchpad,test-contrib,test-ooxml,test-ooxml-lite"
+ description="Tests main, contrib, scratchpad and ooxml"/>
<target name="-test-main-check">
<uptodate property="main.test.notRequired" targetfile="${main.testokfile}">
<srcfiles dir="${main.src}"/>
<srcfiles dir="${main.src.test}"/>
- <srcfiles dir="${ooxml.src}"/>
</uptodate>
</target>
- <target name="test-main" unless="main.test.notRequired"
- depends="compile-main, -test-main-check">
- <junit fork="yes" forkmode="once" printsummary="yes" haltonfailure="${halt.on.test.failure}"
- failureproperty="main.test.failed" showoutput="true">
- <classpath refid="test.classpath"/>
- <sysproperty key="user.language" value="en"/>
- <sysproperty key="user.country" value="US"/>
- <sysproperty key="POI.testdata.path" file="${poi.test.dir}"/>
- <sysproperty key="java.awt.headless" value="true"/>
- <formatter type="plain"/>
- <formatter type="xml"/>
- <batchtest todir="${main.reports.test}">
- <fileset dir="${main.src.test}">
- <include name="**/Test*.java"/>
- <exclude name="**/All*Tests.java"/>
- <exclude name="**/TestUnfixedBugs.java"/>
- <exclude name="**/TestcaseRecordInputStream.java"/>
- </fileset>
- </batchtest>
- </junit>
- <delete file="${main.testokfile}"/>
- <antcall target="-test-main-write-testfile"/>
- </target>
-
- <target name="test-fail" depends="compile-main"
- description="run tests that are known to fail">
- <junit printsummary="yes" showoutput="true" filtertrace="no"
- haltonfailure="false">
- <classpath refid="test.classpath"/>
- <classpath>
- <path refid="scratchpad.classpath"/>
- <pathelement location="${main.output.dir}"/>
- <pathelement location="${scratchpad.output.dir}"/>
- <pathelement location="${scratchpad.output.test.dir}"/>
- <pathelement location="${junit.jar1.dir}"/>
- </classpath>
- <sysproperty key="user.language" value="en"/>
- <sysproperty key="user.country" value="US"/>
- <sysproperty key="POI.testdata.path" file="${poi.test.dir}"/>
- <sysproperty key="java.awt.headless" value="true"/>
- <formatter type="plain" usefile="no"/>
- <batchtest todir="${main.reports.test}">
- <fileset dir="${main.src.test}">
- <include name="**/TestEmptyDocument.java"/>
- <include name="**/TestUnfixedBugs.java"/>
- </fileset>
- </batchtest>
- </junit>
- </target>
-
-
-
- <target name="single-test" depends="-test-property-check,compile-main" description="Runs a single test case specified with -Dtestcase=classname">
- <junit printsummary="yes" showoutput="true" filtertrace="no" haltonfailure="false" >
+ <target name="test-main" unless="main.test.notRequired"
+ depends="compile-main, -test-main-check">
+ <junit fork="yes" forkmode="once" printsummary="yes" haltonfailure="${halt.on.test.failure}"
+ failureproperty="main.test.failed" showoutput="true">
<classpath refid="test.classpath"/>
- <classpath>
- <path refid="test.classpath"/>
- <pathelement location="${main.output.dir}"/>
- <pathelement location="${scratchpad.output.dir}"/>
- <pathelement location="${scratchpad.output.test.dir}"/>
- <pathelement location="${junit.jar1.dir}"/>
- </classpath>
- <sysproperty key="user.language" value="en"/>
- <sysproperty key="user.country" value="US"/>
- <sysproperty key="POI.testdata.path" file="${poi.test.dir}"/>
- <sysproperty key="java.awt.headless" value="true"/>
- <formatter type="plain" usefile="no"/>
- <formatter type="xml"/>
- <test name="${testcase}"/>
+ <syspropertyset refid="junit.properties"/>
+ <formatter type="plain"/>
+ <batchtest todir="${main.reports.test}">
+ <fileset dir="${main.src.test}">
+ <include name="**/Test*.java"/>
+ <exclude name="**/All*Tests.java"/>
+ <exclude name="**/TestUnfixedBugs.java"/>
+ <exclude name="**/TestcaseRecordInputStream.java"/>
+ </fileset>
+ </batchtest>
</junit>
+ <delete file="${main.testokfile}"/>
+ <antcall target="-test-main-write-testfile"/>
</target>
<target name="-test-property-check" unless="testcase">
</uptodate>
</target>
- <target name="test-scratchpad" depends="compile-main,compile-scratchpad,-test-scratchpad-check" unless="scratchpad.test.notRequired">
- <junit printsummary="yes" fork="yes" forkmode="once" haltonfailure="${halt.on.test.failure}" failureproperty="scratchpad.test.failed">
- <classpath>
- <path refid="scratchpad.classpath"/>
- <pathelement location="${main.output.dir}"/>
- <pathelement location="${main.output.test.dir}"/>
- <pathelement location="${scratchpad.output.dir}"/>
- <pathelement location="${scratchpad.output.test.dir}"/>
- <pathelement location="${junit.jar1.dir}"/>
- </classpath>
- <sysproperty key="user.language" value="en"/>
- <sysproperty key="user.country" value="US"/>
- <sysproperty key="POI.testdata.path" file="${poi.test.dir}"/>
- <sysproperty key="java.awt.headless" value="true"/>
+ <target name="test-scratchpad" depends="compile-main,compile-scratchpad,-test-scratchpad-check"
+ unless="scratchpad.test.notRequired">
+ <junit printsummary="yes" fork="yes" forkmode="once" haltonfailure="${halt.on.test.failure}"
+ failureproperty="scratchpad.test.failed">
+ <classpath refid="test.scratchpad.classpath"/>
+ <syspropertyset refid="junit.properties"/>
<formatter type="plain"/>
- <formatter type="xml"/>
<batchtest todir="${scratchpad.reports.test}">
<fileset dir="${scratchpad.src.test}">
<include name="**/Test*.java"/>
<echo file="${scratchpad.testokfile}" append="false" message="testok"/>
</target>
- <target name="single-scratchpad-test" depends="compile-scratchpad,-test-property-check" description="Runs a single test case specified with -Dtestcase=classname">
- <junit printsummary="yes" showoutput="true" filtertrace="no" haltonfailure="false" >
- <classpath refid="test.classpath"/>
- <classpath>
- <path refid="scratchpad.classpath"/>
- <pathelement location="${main.output.dir}"/>
- <pathelement location="${scratchpad.output.dir}"/>
- <pathelement location="${scratchpad.output.test.dir}"/>
- <pathelement location="${junit.jar1.dir}"/>
- </classpath>
- <sysproperty key="user.language" value="en"/>
- <sysproperty key="user.country" value="US"/>
- <sysproperty key="POI.testdata.path" file="${poi.test.dir}"/>
- <sysproperty key="java.awt.headless" value="true"/>
- <sysproperty key="java.awt.headless" value="true"/>
- <formatter type="plain" usefile="no"/>
- <formatter type="xml"/>
- <test name="${testcase}"/>
- </junit>
- </target>
-
<target name="-test-contrib-check">
<uptodate property="contrib.test.notRequired" targetfile="${contrib.testokfile}">
<srcfiles dir="${contrib.src}"/>
</uptodate>
</target>
- <target name="test-contrib" depends="compile-main,compile-contrib,-test-contrib-check" unless="contrib.test.notRequired">
- <junit printsummary="yes" fork="yes" haltonfailure="${halt.on.test.failure}" failureproperty="contrib.test.failed">
+ <target name="test-contrib" depends="compile-main,compile-contrib,-test-contrib-check"
+ unless="contrib.test.notRequired">
+ <junit printsummary="yes" fork="yes" haltonfailure="${halt.on.test.failure}"
+ failureproperty="contrib.test.failed">
<classpath>
<path refid="contrib.classpath"/>
<pathelement location="${main.output.dir}"/>
<pathelement location="${contrib.output.dir}"/>
<pathelement location="${contrib.output.test.dir}"/>
- <pathelement location="${junit.jar1.dir}"/>
</classpath>
- <sysproperty key="user.language" value="en"/>
- <sysproperty key="user.country" value="US"/>
- <sysproperty key="java.awt.headless" value="true"/>
+ <syspropertyset refid="junit.properties"/>
<formatter type="plain"/>
- <formatter type="xml"/>
<batchtest todir="${contrib.reports.test}">
<fileset dir="${contrib.src.test}">
<include name="**/Test*.java"/>
</uptodate>
</target>
+ <macrodef name="ooxml-test-runner">
+ <attribute name="classpath"/>
+ <sequential>
+ <junit printsummary="yes" fork="yes" forkmode="once" haltonfailure="${halt.on.test.failure}"
+ failureproperty="ooxml.test.failed">
+ <classpath refid="@{classpath}"/>
+ <syspropertyset refid="junit.properties"/>
+ <formatter type="plain"/>
+ <batchtest todir="${ooxml.reports.test}">
+ <fileset dir="${ooxml.src.test}">
+ <include name="**/Test*.java"/>
+ <exclude name="**/All*Tests.java"/>
+ </fileset>
+ </batchtest>
+ </junit>
+ </sequential>
+ </macrodef>
+
<target name="test-ooxml" depends="compile-main,compile-ooxml,-test-ooxml-check" unless="ooxml.test.notRequired">
- <junit printsummary="yes" fork="yes" forkmode="once" haltonfailure="${halt.on.test.failure}" failureproperty="ooxml.test.failed">
- <classpath refid="test.ooxml.classpath" />
- <sysproperty key="user.language" value="en"/>
- <sysproperty key="user.country" value="US"/>
- <sysproperty key="POI.testdata.path" file="${poi.test.dir}"/>
- <sysproperty key="java.awt.headless" value="true"/>
- <formatter type="plain"/>
- <formatter type="xml"/>
- <batchtest todir="${ooxml.reports.test}">
- <fileset dir="${ooxml.src.test}">
- <include name="**/Test*.java"/>
- <exclude name="**/All*Tests.java"/>
- </fileset>
- </batchtest>
- </junit>
+ <ooxml-test-runner classpath="test.ooxml.classpath"/>
<delete file="${ooxml.testokfile}"/>
<antcall target="-test-ooxml-write-testfile"/>
</target>
<echo file="${ooxml.testokfile}" append="false" message="testok"/>
</target>
- <target name="single-test-ooxml" depends="-test-property-check,compile-main,compile-ooxml" description="Runs a single ooxml test case specified with -Dtestcase=classname">
- <junit printsummary="yes" showoutput="true" filtertrace="no" haltonfailure="false" >
- <classpath refid="test.ooxml.classpath" />
- <sysproperty key="user.language" value="en"/>
- <sysproperty key="user.country" value="US"/>
- <sysproperty key="POI.testdata.path" file="${poi.test.dir}"/>
- <sysproperty key="java.awt.headless" value="true"/>
- <formatter type="plain" usefile="no"/>
- <formatter type="xml"/>
- <test name="${testcase}"/>
- </junit>
+ <target name="compile-ooxml-lite" depends="compile-ooxml">
+ <java classname="org.apache.poi.util.OOXMLLite" fork="yes">
+ <classpath refid="test.ooxml.classpath"/>
+ <syspropertyset refid="junit.properties"/>
+ <arg line="-ooxml ${ooxml.xsds.jar} -test ${ooxml.output.test.dir} -dest ${ooxml.lite.output.dir}"/>
+ </java>
</target>
+ <target name="test-ooxml-lite">
+ <echo message="Running ooxml tests against the 'lite' classes"/>
+ <delete file="${ooxml.testokfile}"/>
+ <ooxml-test-runner classpath="ooxml-lite.classpath"/>
+ </target>
+
<target name="-check-docs">
<uptodate property="main.docs.notRequired" targetfile="${build.site}/index.html">
<srcfiles dir="${build.site.src}"/>
<target name="-check-forrest-installed" unless="env.FORREST_HOME">
<echo>Please install Apache Forrest (see
-<http://forrest.apache.org/index.html>) and set the
-FORREST_HOME environment variable!</echo>
+ <http://forrest.apache.org/index.html>) and set the
+ FORREST_HOME environment variable!
+ </echo>
<fail message="Apache Forrest is not installed."/>
</target>
- <!-- <target name="check-docs">-->
- <!-- <uptodate property="main.docs.notRequired" targetfile="${build.site}/index.html" >-->
- <!-- <srcfiles dir= "${build.site.src}"/>-->
- <!-- </uptodate>-->
- <!-- </target>-->
-
<target name="docs" depends="init, -check-forrest-installed, -check-docs"
- unless="main.docs.notRequired" description="Builds the POI website">
+ unless="main.docs.notRequired" description="Builds the POI website">
- <mkdir dir="${build.site.src}/src/documentation/content/apidocs"/>
- <copy todir="${build.site.src}/src/documentation/content/apidocs">
- <fileset dir="${apidocs.report.dir}"/>
- </copy>
- <mkdir dir="${build.site.src}/src/documentation/content/junit"/>
- <copy todir="${build.site.src}/src/documentation/content/junit">
- <fileset dir="${junit.report.dir}"/>
+ <mkdir dir="${build.site.src}/${main.documentation}"/>
+ <copy todir="${build.site.src}/${main.documentation}">
+ <fileset dir="${main.documentation}"/>
</copy>
+ <copy file="forrest.properties" tofile="${build.site.src}/forrest.properties"/>
<move
- file="${build.site.src}/src/documentation/content/xdocs/status.xml"
- tofile="${build.site.src}/status.xml"/>
+ file="${build.site.src}/src/documentation/content/xdocs/status.xml"
+ tofile="${build.site.src}/status.xml"/>
- <ant antfile="${forrest.home}/forrest.antproxy.xml" target="site">
+ <ant antfile="${env.FORREST_HOME}/forrest.antproxy.xml" target="site">
<property name="project.home" location="${build.site.src}"/>
</ant>
</touch>
</target>
+ <!-- Generates the API documentation. -->
+ <target name="javadocs"
+ description="Generates the API documentation">
+ <javadoc verbose="false" author="true" destdir="${apidocs.report.dir}"
+ windowtitle="POI API Documentation" use="true" version="true" maxmemory="256M">
+
+ <packageset dir="${main.src}" defaultexcludes="yes">
+ <include name="org/apache/poi/**"/>
+ </packageset>
+ <packageset dir="${scratchpad.src}" defaultexcludes="yes">
+ <include name="org/apache/poi/**"/>
+ <exclude name="org/apache/poi/hdf/**"/>
+ </packageset>
+ <packageset dir="${contrib.src}" defaultexcludes="yes">
+ <include name="org/apache/poi/**"/>
+ </packageset>
+ <packageset dir="${ooxml.src}" defaultexcludes="yes">
+ <include name="org/apache/poi/**"/>
+ </packageset>
+
+ <classpath id="javadoc.classpath">
+ <path refid="main.classpath"/>
+ <path refid="scratchpad.classpath"/>
+ <path refid="contrib.classpath"/>
+ <path refid="ooxml.classpath"/>
+ <path path="${env.CLASSPATH}"/>
+ </classpath>
- <!-- Runs all JUnit tests without aborting if one of the tests fails. -->
- <target name="test-ignore-failures" depends="init">
- <antcall target="test">
- <param name="halt.on.test.failure" value="false"/>
- </antcall>
- </target>
- <!-- Generates the API documentation. -->
- <target name="javadocs" depends="init"
- description="Generates the API documentation">
- <javadoc verbose="false" author="true" destdir="${apidocs.report.dir}"
- windowtitle="POI API Documentation" use="true" version="true" maxmemory="256M">
-
- <packageset dir="${main.src}" defaultexcludes="yes">
- <include name="org/apache/poi/**"/>
- </packageset>
- <packageset dir="${scratchpad.src}" defaultexcludes="yes">
- <include name="org/apache/poi/**"/>
- <exclude name="org/apache/poi/hdf/**"/>
- </packageset>
- <packageset dir="${contrib.src}" defaultexcludes="yes">
- <include name="org/apache/poi/**"/>
- </packageset>
- <packageset dir="${ooxml.src}" defaultexcludes="yes">
- <include name="org/apache/poi/**"/>
- </packageset>
-
- <classpath id="javadoc.classpath">
- <path refid="main.classpath"/>
- <path refid="scratchpad.classpath"/>
- <path refid="contrib.classpath"/>
- <path refid="ooxml.classpath"/>
- <path path="${env.CLASSPATH}"/>
- </classpath>
-
- <doctitle><![CDATA[<h1>POI API Documentation</h1>]]></doctitle>
- <bottom>
- <![CDATA[<i>Copyright ${tstamp.year} The Apache Software Foundation or
+ <doctitle><![CDATA[<h1>POI API Documentation</h1>]]></doctitle>
+ <bottom>
+ <![CDATA[<i>Copyright ${tstamp.year} The Apache Software Foundation or
its licensors, as applicable.</i>]]>
- </bottom>
- <group>
- <title>DDF - Dreadful Drawing Format</title>
- <package name="org.apache.poi.ddf*"/>
- </group>
- <group>
- <title>HPSF - Horrible Property Set Format</title>
- <package name="org.apache.poi.hpsf*"/>
- </group>
- <group>
- <title>HSSF - Horrible Spreadsheet Format</title>
- <package name="org.apache.poi.hssf*"/>
- </group>
- <group>
- <title>HWPF - Horrible Word Processor Format</title>
- <package name="org.apache.poi.hwpf*"/>
- </group>
- <group>
- <title>POIFS - POI File System</title>
- <package name="org.apache.poi.poifs*"/>
- </group>
- <group>
- <title>Utilities</title>
- <package name="org.apache.poi.util*"/>
- </group>
- <group>
- <title>Examples</title>
- <package name="org.apache.poi.hpsf.examples*"/>
- <package name="org.apache.poi.hssf.usermodel.examples*"/>
- </group>
- </javadoc>
-
- </target>
+ </bottom>
+ <group>
+ <title>DDF - Dreadful Drawing Format</title>
+ <package name="org.apache.poi.ddf*"/>
+ </group>
+ <group>
+ <title>HPSF - Horrible Property Set Format</title>
+ <package name="org.apache.poi.hpsf*"/>
+ </group>
+ <group>
+ <title>HSSF - Horrible Spreadsheet Format</title>
+ <package name="org.apache.poi.hssf*"/>
+ </group>
+ <group>
+ <title>HWPF - Horrible Word Processor Format</title>
+ <package name="org.apache.poi.hwpf*"/>
+ </group>
+ <group>
+ <title>POIFS - POI File System</title>
+ <package name="org.apache.poi.poifs*"/>
+ </group>
+ <group>
+ <title>Utilities</title>
+ <package name="org.apache.poi.util*"/>
+ </group>
+ <group>
+ <title>Examples</title>
+ <package name="org.apache.poi.hpsf.examples*"/>
+ <package name="org.apache.poi.hssf.usermodel.examples*"/>
+ </group>
+ </javadoc>
+
+ </target>
<!-- Generates documentation and reports -->
- <target name="site" depends="docs"
- description="Generates POI's website's contents"/>
-
-
- <target name="maven-poms" description="Builds the POM files for a maven distribution, and copies these and the jars to the appropriate locations">
- <!-- TODO: Decide about source jars, and copy them if we have some -->
-
- <!-- Build the org.apache.poi poms -->
- <copy file="maven/poi.pom" tofile="${dist.dir}/poi-${version.id}.pom">
- <filterchain>
- <replacetokens>
- <token key="VERSION" value="${version.id}" />
- </replacetokens>
- </filterchain>
- </copy>
- <copy file="maven/poi-contrib.pom" tofile="${dist.dir}/poi-contrib-${version.id}.pom">
- <filterchain>
- <replacetokens>
- <token key="VERSION" value="${version.id}" />
- </replacetokens>
- </filterchain>
- </copy>
- <copy file="maven/poi-scratchpad.pom" tofile="${dist.dir}/poi-scratchpad-${version.id}.pom">
- <filterchain>
- <replacetokens>
- <token key="VERSION" value="${version.id}" />
- </replacetokens>
- </filterchain>
- </copy>
- <copy file="maven/poi-ooxml.pom" tofile="${dist.dir}/poi-ooxml-${version.id}.pom">
- <filterchain>
- <replacetokens>
- <token key="VERSION" value="${version.id}" />
- </replacetokens>
- </filterchain>
- </copy>
- <copy file="maven/mvn-deploy.sh" todir="${dist.dir}">
- <filterchain>
- <replacetokens>
- <token key="REPOSITORY" value="${apache.repository}" />
- <token key="VERSION" value="${version.id}" />
- <token key="DSTAMP" value="${DSTAMP}" />
- </replacetokens>
- </filterchain>
- </copy>
- </target>
-
- <target name="maven-ooxml-dependencies" description="Builds the POM files for the compiled XmlBeans generated from the Ecma supplied xsds">
-
- <!-- ooxml-schemas -->
- <copy file="${ooxml.xsds.jar}" tofile="${mavendist.ooxml.dir}/org.apache.poi/jars/${maven.ooxml.xsds.jar}" />
- <copy file="maven/ooxml-schemas.pom" tofile="${mavendist.ooxml.dir}/org.apache.poi/poms/ooxml-schemas-${maven.ooxml.xsds.version.id}.pom">
- <filterchain>
- <replacetokens>
- <token key="VERSION" value="${maven.ooxml.xsds.version.id}" />
- </replacetokens>
- </filterchain>
- </copy>
- </target>
-
- <target name="jar" depends="compile, compile-version" description="Creates jar files for distribution">
- <jar destfile="${dist.dir}/${jar.name}-${version.id}-${DSTAMP}.jar">
- <fileset dir="${main.output.dir}" />
- <fileset dir="legal/" />
- <manifest>
- <attribute name="Built-By" value="${user.name}"/>
- <attribute name="Specification-Title" value="Apache POI"/>
- <attribute name="Specification-Version" value="${version.id}-${DSTAMP}"/>
- <attribute name="Specification-Vendor" value="Apache"/>
- <attribute name="Implementation-Title" value="Apache POI"/>
- <attribute name="Implementation-Version" value="${version.id}-${DSTAMP}"/>
- <attribute name="Implementation-Vendor" value="Apache"/>
- </manifest>
+ <target name="site" depends="docs,javadocs"
+ description="Generates POI's website's contents"/>
+
+
+ <target name="maven-poms"
+ description="Builds the POM files for a maven distribution, and copies these and the jars to the appropriate locations">
+
+ <!-- Build the org.apache.poi poms -->
+ <copy file="maven/poi.pom" tofile="${dist.dir}/poi-${version.id}.pom">
+ <filterchain>
+ <replacetokens>
+ <token key="VERSION" value="${version.id}"/>
+ </replacetokens>
+ </filterchain>
+ </copy>
+ <copy file="maven/poi-contrib.pom" tofile="${dist.dir}/poi-contrib-${version.id}.pom">
+ <filterchain>
+ <replacetokens>
+ <token key="VERSION" value="${version.id}"/>
+ </replacetokens>
+ </filterchain>
+ </copy>
+ <copy file="maven/poi-scratchpad.pom" tofile="${dist.dir}/poi-scratchpad-${version.id}.pom">
+ <filterchain>
+ <replacetokens>
+ <token key="VERSION" value="${version.id}"/>
+ </replacetokens>
+ </filterchain>
+ </copy>
+ <copy file="maven/poi-ooxml.pom" tofile="${dist.dir}/poi-ooxml-${version.id}.pom">
+ <filterchain>
+ <replacetokens>
+ <token key="VERSION" value="${version.id}"/>
+ </replacetokens>
+ </filterchain>
+ </copy>
+ <copy file="maven/poi-ooxml-schemas.pom" tofile="${dist.dir}/poi-ooxml-schemas-${version.id}.pom">
+ <filterchain>
+ <replacetokens>
+ <token key="VERSION" value="${version.id}"/>
+ </replacetokens>
+ </filterchain>
+ </copy>
+ <copy file="maven/mvn-deploy.sh" todir="${dist.dir}">
+ <filterchain>
+ <replacetokens>
+ <token key="REPOSITORY" value="${apache.repository}"/>
+ <token key="VERSION" value="${version.id}"/>
+ <token key="DSTAMP" value="${DSTAMP}"/>
+ </replacetokens>
+ </filterchain>
+ </copy>
+ </target>
+
+ <target name="jar" depends="compile, compile-version" description="Creates jar files for distribution">
+ <manifest file="build/poi-manifest.mf">
+ <attribute name="Built-By" value="${user.name}"/>
+ <attribute name="Specification-Title" value="Apache POI"/>
+ <attribute name="Specification-Version" value="${version.id}"/>
+ <attribute name="Specification-Vendor" value="The Apache Software Foundation"/>
+ <attribute name="Implementation-Title" value="Apache POI"/>
+ <attribute name="Implementation-Version" value="${version.id}"/>
+ <attribute name="Implementation-Vendor-Id" value="org.apache.poi"/>
+ <attribute name="Implementation-Vendor" value="The Apache Software Foundation"/>
+ </manifest>
+ <jar destfile="${dist.dir}/${jar.name}-${version.id}-${DSTAMP}.jar"
+ manifest="build/poi-manifest.mf">
+ <fileset dir="${main.output.dir}"/>
+ <metainf dir="legal/"/>
+ </jar>
+ <jar destfile="${dist.dir}/${jar.name}-contrib-${version.id}-${DSTAMP}.jar"
+ manifest="build/poi-manifest.mf">
+ <fileset dir="${contrib.output.dir}"/>
+ <metainf dir="legal/"/>
</jar>
- <jar destfile="${dist.dir}/${jar.name}-contrib-${version.id}-${DSTAMP}.jar">
- <fileset dir="${contrib.output.dir}" />
- <fileset dir="legal/" />
- <manifest>
- <attribute name="Built-By" value="${user.name}"/>
- <attribute name="Specification-Title" value="Apache POI"/>
- <attribute name="Specification-Version" value="${version.id}-${DSTAMP}"/>
- <attribute name="Specification-Vendor" value="Apache"/>
- <attribute name="Implementation-Title" value="Apache POI"/>
- <attribute name="Implementation-Version" value="${version.id}-${DSTAMP}"/>
- <attribute name="Implementation-Vendor" value="Apache"/>
- </manifest>
+ <jar destfile="${dist.dir}/${jar.name}-scratchpad-${version.id}-${DSTAMP}.jar"
+ manifest="build/poi-manifest.mf">
+ <fileset dir="${scratchpad.output.dir}"/>
+ <metainf dir="legal/"/>
</jar>
- <jar destfile="${dist.dir}/${jar.name}-scratchpad-${version.id}-${DSTAMP}.jar">
- <fileset dir="${scratchpad.output.dir}" />
- <fileset dir="legal/" />
- <manifest>
- <attribute name="Built-By" value="${user.name}"/>
- <attribute name="Specification-Title" value="Apache POI"/>
- <attribute name="Specification-Version" value="${version.id}-${DSTAMP}"/>
- <attribute name="Specification-Vendor" value="Apache"/>
- <attribute name="Implementation-Title" value="Apache POI"/>
- <attribute name="Implementation-Version" value="${version.id}-${DSTAMP}"/>
- <attribute name="Implementation-Vendor" value="Apache"/>
- </manifest>
+ <jar destfile="${dist.dir}/${jar.name}-ooxml-${version.id}-${DSTAMP}.jar"
+ manifest="build/poi-manifest.mf">
+ <fileset dir="${ooxml.output.dir}"/>
+ <metainf dir="legal/"/>
</jar>
- <jar destfile="${dist.dir}/${jar.name}-ooxml-${version.id}-${DSTAMP}.jar">
- <fileset dir="${ooxml.output.dir}" />
- <fileset dir="legal/" />
- <manifest>
- <attribute name="Built-By" value="${user.name}"/>
- <attribute name="Specification-Title" value="Apache POI"/>
- <attribute name="Specification-Version" value="${version.id}-${DSTAMP}"/>
- <attribute name="Specification-Vendor" value="Apache"/>
- <attribute name="Implementation-Title" value="Apache POI"/>
- <attribute name="Implementation-Version" value="${version.id}-${DSTAMP}"/>
- <attribute name="Implementation-Vendor" value="Apache"/>
- </manifest>
+ <jar destfile="${dist.dir}/${jar.name}-examples-${version.id}-${DSTAMP}.jar"
+ manifest="build/poi-manifest.mf">
+ <fileset dir="${examples.output.dir}"/>
+ <metainf dir="legal/"/>
+ </jar>
+ <jar destfile="${dist.dir}/${jar.name}-ooxml-schemas-${version.id}-${DSTAMP}.jar"
+ manifest="build/poi-manifest.mf">
+ <fileset dir="${ooxml.lite.output.dir}"/>
+ <metainf dir="legal/"/>
</jar>
</target>
- <target name="jar-examples" depends="compile, compile-version" description="Creates a jar file of the examples, in case people want to use them as-is">
- <jar destfile="${dist.dir}/${jar.name}-examples-${version.id}-${DSTAMP}.jar">
- <fileset dir="${examples.output.dir}" />
- <fileset dir="legal/" />
- <manifest>
- <attribute name="Built-By" value="${user.name}"/>
- <attribute name="Specification-Title" value="Apache POI"/>
- <attribute name="Specification-Version" value="${version.id}-${DSTAMP}"/>
- <attribute name="Specification-Vendor" value="Apache"/>
- <attribute name="Implementation-Title" value="Apache POI"/>
- <attribute name="Implementation-Version" value="${version.id}-${DSTAMP}"/>
- <attribute name="Implementation-Vendor" value="Apache"/>
- </manifest>
+
+ <target name="jar-src" description="Sources for Maven">
+ <jar destfile="${dist.dir}/${jar.name}-${version.id}-sources.jar"
+ manifest="build/poi-manifest.mf">
+ <fileset dir="${main.src}"/>
+ <metainf dir="legal/"/>
+ </jar>
+ <jar destfile="${dist.dir}/${jar.name}-scratchpad-${version.id}-sources.jar"
+ manifest="build/poi-manifest.mf">
+ <fileset dir="${scratchpad.src}"/>
+ <metainf dir="legal/"/>
</jar>
+ <jar destfile="${dist.dir}/${jar.name}-contrib-${version.id}-sources.jar"
+ manifest="build/poi-manifest.mf">
+ <fileset dir="${contrib.src}"/>
+ <metainf dir="legal/"/>
+ </jar>
+ <jar destfile="${dist.dir}/${jar.name}-ooxml-${version.id}-sources.jar"
+ manifest="build/poi-manifest.mf">
+ <fileset dir="${ooxml.src}"/>
+ <metainf dir="legal/"/>
+ </jar>
+ <jar destfile="${dist.dir}/${jar.name}-examples-${version.id}-sources.jar"
+ manifest="build/poi-manifest.mf">
+ <fileset dir="${examples.src}"/>
+ <metainf dir="legal/"/>
+ </jar>
+ </target>
+
+ <target name="assemble" depends="jar,jar-src">
+
+ <property name="zipdir" value="${jar.name}-${version.id}"/>
+
+ <zip destfile="${dist.dir}/${jar.name}-bin-${version.id}-${DSTAMP}.zip">
+ <zipfileset dir="legal/" prefix="${zipdir}"/>
+ <zipfileset dir="${main.lib}" prefix="${zipdir}/lib" includes="*.jar"/>
+ <zipfileset dir="${ooxml.lib}" prefix="${zipdir}/ooxml-lib">
+ <include name="dom4j-*.jar"/>
+ <include name="xmlbeans-*.jar"/>
+ </zipfileset>
+ <zipfileset dir="${build.site}" prefix="${zipdir}/docs"/>
+ <zipfileset file="${dist.dir}/${jar.name}-${version.id}-${DSTAMP}.jar" prefix="${zipdir}"/>
+ <zipfileset file="${dist.dir}/${jar.name}-contrib-${version.id}-${DSTAMP}.jar" prefix="${zipdir}"/>
+ <zipfileset file="${dist.dir}/${jar.name}-scratchpad-${version.id}-${DSTAMP}.jar" prefix="${zipdir}"/>
+ <zipfileset file="${dist.dir}/${jar.name}-ooxml-${version.id}-${DSTAMP}.jar" prefix="${zipdir}"/>
+ <zipfileset file="${dist.dir}/${jar.name}-examples-${version.id}-${DSTAMP}.jar" prefix="${zipdir}"/>
+ <zipfileset file="${dist.dir}/${jar.name}-ooxml-schemas-${version.id}-${DSTAMP}.jar" prefix="${zipdir}"/>
+ </zip>
+
+ <zip destfile="${dist.dir}/${jar.name}-src-${version.id}-${DSTAMP}.zip">
+ <zipfileset dir="legal/" prefix="${zipdir}"/>
+ <zipfileset dir="${build.site}" prefix="${zipdir}/docs"/>
+ <zipfileset dir="." prefix="${zipdir}">
+ <exclude name="build/**"/>
+ <exclude name="maven/**"/>
+ <exclude name="lib/**"/>
+ <exclude name="ooxml-lib/**"/>
+ <exclude name="scripts/**"/>
+ <exclude name="TEST*"/>
+ <exclude name="*.ipr"/>
+ <exclude name="*.iml"/>
+ <exclude name="*.iws"/>
+ <exclude name="*.lnk"/>
+ <exclude name="*.rdf"/>
+ <exclude name="*.swp"/>
+ <exclude name=".classpath"/>
+ <exclude name=".project"/>
+ </zipfileset>
+ </zip>
+
+ <tar destfile="${dist.dir}/${jar.name}-bin-${version.id}-${DSTAMP}.tar.gz"
+ longfile="gnu"
+ compression="gzip">
+ <tarfileset dir="legal/" prefix="${zipdir}"/>
+ <tarfileset dir="${main.lib}" prefix="${zipdir}/lib" includes="*.jar"/>
+ <tarfileset dir="${ooxml.lib}" prefix="${zipdir}/ooxml-lib">
+ <include name="dom4j-*.jar"/>
+ <include name="xmlbeans-*.jar"/>
+ </tarfileset>
+ <tarfileset dir="${build.site}" prefix="${zipdir}/docs"/>
+ <tarfileset file="${dist.dir}/${jar.name}-${version.id}-${DSTAMP}.jar" prefix="${zipdir}"/>
+ <tarfileset file="${dist.dir}/${jar.name}-contrib-${version.id}-${DSTAMP}.jar" prefix="${zipdir}"/>
+ <tarfileset file="${dist.dir}/${jar.name}-scratchpad-${version.id}-${DSTAMP}.jar" prefix="${zipdir}"/>
+ <tarfileset file="${dist.dir}/${jar.name}-ooxml-${version.id}-${DSTAMP}.jar" prefix="${zipdir}"/>
+ <tarfileset file="${dist.dir}/${jar.name}-examples-${version.id}-${DSTAMP}.jar" prefix="${zipdir}"/>
+ <tarfileset file="${dist.dir}/${jar.name}-ooxml-schemas-${version.id}-${DSTAMP}.jar" prefix="${zipdir}"/>
+ </tar>
+
+ <tar destfile="${dist.dir}/${jar.name}-src-${version.id}-${DSTAMP}.tar.gz"
+ longfile="gnu"
+ compression="gzip">
+ <tarfileset dir="legal/" prefix="${zipdir}"/>
+ <tarfileset dir="${build.site}" prefix="${zipdir}/docs"/>
+ <tarfileset dir="." prefix="${zipdir}">
+ <exclude name="build/**"/>
+ <exclude name="maven/**"/>
+ <exclude name="lib/**"/>
+ <exclude name="ooxml-lib/**"/>
+ <exclude name="scripts/**"/>
+ <exclude name="TEST*"/>
+ <exclude name="*.ipr"/>
+ <exclude name="*.iml"/>
+ <exclude name="*.iws"/>
+ <exclude name="*.lnk"/>
+ <exclude name="*.rdf"/>
+ <exclude name="*.swp"/>
+ <exclude name=".classpath"/>
+ <exclude name=".project"/>
+ </tarfileset>
+ </tar>
+
+ <echo>Creating Maven POMs</echo>
+ <antcall target="maven-poms"/>
+
+
+ <echo>Generating MD5 Checksums</echo>
+
+ <checksum fileext=".md5">
+ <fileset dir="${dist.dir}" includes="*.pom,*.gz,*.zip"/>
+ </checksum>
+
+ <echo>Distribution located in build/dist</echo>
</target>
- <target name="dist" depends="clean, fail-unless-tools-are-available, compile, site, jar"
- description="Creates the entire distribution into build/dist, from scratch">
-
- <property name="zipdir" value="${jar.name}-${version.id}" />
-
- <zip destfile="${dist.dir}/${jar.name}-bin-${version.id}-${DSTAMP}.zip">
- <zipfileset dir="legal/" prefix="${zipdir}" />
- <zipfileset dir="lib/" prefix="${zipdir}/lib" />
- <zipfileset dir="ooxml-lib/" prefix="${zipdir}/ooxml-lib">
- <exclude name="*.zip"/>
- </zipfileset>
- <zipfileset dir="${build.site}" prefix="${zipdir}/docs"/>
- <zipfileset file="${dist.dir}/${jar.name}-${version.id}-${DSTAMP}.jar" prefix="${zipdir}" />
- <zipfileset file="${dist.dir}/${jar.name}-contrib-${version.id}-${DSTAMP}.jar" prefix="${zipdir}" />
- <zipfileset file="${dist.dir}/${jar.name}-scratchpad-${version.id}-${DSTAMP}.jar" prefix="${zipdir}" />
- <zipfileset file="${dist.dir}/${jar.name}-ooxml-${version.id}-${DSTAMP}.jar" prefix="${zipdir}" />
- </zip>
-
- <zip destfile="${dist.dir}/${jar.name}-src-${version.id}-${DSTAMP}.zip">
- <zipfileset dir="legal/" prefix="${zipdir}" />
- <zipfileset dir="${build.site}" prefix="${zipdir}/docs"/>
- <zipfileset dir="." prefix="${zipdir}">
- <exclude name="build/**"/>
- <exclude name="scripts/**"/>
- <exclude name="TEST*"/>
- <exclude name="*.ipr"/>
- <exclude name="*.iml"/>
- <exclude name="*.iws"/>
- <exclude name="*.swp"/>
- <exclude name=".classpath"/>
- <exclude name=".project"/>
- </zipfileset>
- </zip>
-
- <tar destfile="${dist.dir}/${jar.name}-bin-${version.id}-${DSTAMP}.tar.gz"
- longfile="gnu"
- compression="gzip">
- <tarfileset dir="legal/" prefix="${zipdir}" />
- <tarfileset dir="lib/" prefix="${zipdir}/lib" />
- <tarfileset dir="ooxml-lib/" prefix="${zipdir}/ooxml-lib">
- <exclude name="*.zip"/>
- </tarfileset>
- <tarfileset dir="${build.site}" prefix="${zipdir}/docs"/>
- <tarfileset file="${dist.dir}/${jar.name}-${version.id}-${DSTAMP}.jar" prefix="${zipdir}" />
- <tarfileset file="${dist.dir}/${jar.name}-contrib-${version.id}-${DSTAMP}.jar" prefix="${zipdir}" />
- <tarfileset file="${dist.dir}/${jar.name}-scratchpad-${version.id}-${DSTAMP}.jar" prefix="${zipdir}" />
- <tarfileset file="${dist.dir}/${jar.name}-ooxml-${version.id}-${DSTAMP}.jar" prefix="${zipdir}" />
- </tar>
-
- <tar destfile="${dist.dir}/${jar.name}-src-${version.id}-${DSTAMP}.tar.gz"
- longfile="gnu"
- compression="gzip">
- <tarfileset dir="legal/" prefix="${zipdir}" />
- <tarfileset dir="${build.site}" prefix="${zipdir}/docs"/>
- <tarfileset dir="." prefix="${zipdir}">
- <exclude name="build/**"/>
- <exclude name="scripts/**"/>
- <exclude name="TEST*"/>
- <exclude name="*.ipr"/>
- <exclude name="*.iml"/>
- <exclude name="*.iws"/>
- <exclude name="*.swp"/>
- <exclude name=".classpath"/>
- <exclude name=".project"/>
- </tarfileset>
- </tar>
-
- <echo>Creating Maven POMs</echo>
- <antcall target="maven-poms"/>
-
- <echo>Distribution located in build/dist</echo>
- </target>
-
- <target name="clean-compile" depends="clean, compile"/>
-
- <target name="clean-dist" depends="clean, dist"
- description="Cleans the build directory then creates a distribution"/>
-
- <target name="gump" depends="test, jar"/>
-
-
- <!-- Aborts the build if any of the required tools are missing. -->
- <target name="fail-unless-tools-are-available"/>
-
- <target name="-require-filename" description="Ensure -Dfilename=... was given">
- <fail unless="filename" message="A filename must be supplied with -Dfilename=, eg -Dfilename=test.xls" />
- </target>
-
- <!-- These tasks make it easy to run our command line tools, -->
- <!-- without you needing to worry about classpaths etc -->
- <target name="POIFSViewer" depends="compile-main,-require-filename"
- description="Runs poifs.dev.POIFSViewer against the supplied file">
- <java classname="org.apache.poi.poifs.dev.POIFSViewer">
- <arg line="${filename}" />
- <classpath refid="test.classpath"/>
- </java>
- </target>
- <target name="OOXMLLister" depends="compile-ooxml,-require-filename"
- description="Runs dev.OOXMLLister against the supplied file">
- <java classname="org.apache.poi.dev.OOXMLLister">
- <arg line="${filename}" />
- <classpath refid="test.ooxml.classpath"/>
- </java>
- </target>
- <target name="BiffViewer" depends="compile-main,-require-filename"
- description="Runs hssf.dev.BiffViewer against the supplied file">
- <java classname="org.apache.poi.hssf.dev.BiffViewer">
- <arg line="${filename}" />
- <classpath refid="test.classpath"/>
- </java>
- </target>
+ <target name="dist" depends="clean, compile, test, site, jar, assemble"
+ description="Creates the entire distribution into build/dist, from scratch">
+ </target>
+
+ <target name="gump" depends="test, jar"/>
+
+
+ <target name="-require-filename" description="Ensure -Dfilename=... was given">
+ <fail unless="filename" message="A filename must be supplied with -Dfilename=, eg -Dfilename=test.xls"/>
+ </target>
+
+ <!-- These tasks make it easy to run our command line tools, -->
+ <!-- without you needing to worry about classpaths etc -->
+ <target name="POIFSViewer" depends="compile-main,-require-filename"
+ description="Runs poifs.dev.POIFSViewer against the supplied file">
+ <java classname="org.apache.poi.poifs.dev.POIFSViewer">
+ <arg line="${filename}"/>
+ <classpath refid="test.classpath"/>
+ </java>
+ </target>
+ <target name="OOXMLLister" depends="compile-ooxml,-require-filename"
+ description="Runs dev.OOXMLLister against the supplied file">
+ <java classname="org.apache.poi.dev.OOXMLLister">
+ <arg line="${filename}"/>
+ <classpath refid="test.ooxml.classpath"/>
+ </java>
+ </target>
+ <target name="BiffViewer" depends="compile-main,-require-filename"
+ description="Runs hssf.dev.BiffViewer against the supplied file">
+ <java classname="org.apache.poi.hssf.dev.BiffViewer">
+ <arg line="${filename}"/>
+ <classpath refid="test.classpath"/>
+ </java>
+ </target>
</project>
+++ /dev/null
-<?xml version="1.0"?>
-<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
-
-<!--
-/* ====================================================================
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-==================================================================== */
- -->
-
-<xsl:output method="html" indent="yes"/>
-
-<xsl:template match="JDepend">
- <html>
- <head>
- <title>JDepend Analysis</title>
-
- <style type="text/css">
- body {
- font:normal 68% verdana,arial,helvetica;
- color:#000000;
- }
- table tr td, tr th {
- font-size: 68%;
- }
- table.details tr th{
- font-weight: bold;
- text-align:left;
- background:#a6caf0;
- }
- table.details tr td{
- background:#eeeee0;
- }
-
- p {
- line-height:1.5em;
- margin-top:0.5em; margin-bottom:1.0em;
- margin-left:2em;
- margin-right:2em;
- }
- h1 {
- margin: 0px 0px 5px; font: 165% verdana,arial,helvetica
- }
- h2 {
- margin-top: 1em; margin-bottom: 0.5em; font: bold 125% verdana,arial,helvetica
- }
- h3 {
- margin-bottom: 0.5em; font: bold 115% verdana,arial,helvetica
- }
- h4 {
- margin-bottom: 0.5em; font: bold 100% verdana,arial,helvetica
- }
- h5 {
- margin-bottom: 0.5em; font: bold 100% verdana,arial,helvetica
- }
- h6 {
- margin-bottom: 0.5em; font: bold 100% verdana,arial,helvetica
- }
- .Error {
- font-weight:bold; color:red;
- }
- .Failure {
- font-weight:bold; color:purple;
- }
- .Properties {
- text-align:right;
- }
- </style>
-
-
- </head>
- <body>
- <!--h1>JDepend Report</h1>
- <ul>
- <xsl:for-each select="./Packages/Package">
- <xsl:sort select="@name"/>
- <li><xsl:value-of select="@name"/></li>
- </xsl:for-each>
- </ul-->
-
- <h1><a name="top">JDepend Analysis</a></h1>
- <p align="right">Designed for use with <a href="http://www.clarkware.com/software/JDepend.html">JDepend</a> and <a href="http://jakarta.apache.org">Ant</a>.</p>
- <hr size="2" />
-
- <table width="100%"><tr><td>
- <a name="NVsummary"><h2>Summary</h2></a>
- </td><td align="right">
- [<a href="#NVsummary">summary</a>]
- [<a href="#NVpackages">packages</a>]
- [<a href="#NVcycles">cycles</a>]
- [<a href="#NVexplanations">explanations</a>]
- </td></tr></table>
-
- <table width="100%" class="details">
- <tr>
- <th>Package</th>
- <th>Total Classes</th>
- <th><a href="#EXnumber">Abstract Classes</a></th>
- <th><a href="#EXnumber">Concrete Classes</a></th>
- <th><a href="#EXafferent">Afferent Couplings</a></th>
- <th><a href="#EXefferent">Efferent Couplings</a></th>
- <th><a href="#EXabstractness">Abstractness</a></th>
- <th><a href="#EXinstability">Instability</a></th>
- <th><a href="#EXdistance">Distance</a></th>
-
- </tr>
- <xsl:for-each select="./Packages/Package">
- <xsl:if test="count(error) = 0">
- <tr>
- <td align="left">
- <a>
- <xsl:attribute name="href">#PK<xsl:value-of select="@name"/>
- </xsl:attribute>
- <xsl:value-of select="@name"/>
- </a>
- </td>
- <td align="right"><xsl:value-of select="Stats/TotalClasses"/></td>
- <td align="right"><xsl:value-of select="Stats/AbstractClasses"/></td>
- <td align="right"><xsl:value-of select="Stats/ConcreteClasses"/></td>
- <td align="right"><xsl:value-of select="Stats/Ca"/></td>
- <td align="right"><xsl:value-of select="Stats/Ce"/></td>
- <td align="right"><xsl:value-of select="Stats/A"/></td>
- <td align="right"><xsl:value-of select="Stats/I"/></td>
- <td align="right"><xsl:value-of select="Stats/D"/></td>
-
-
- </tr>
- </xsl:if>
- </xsl:for-each>
- <xsl:for-each select="./Packages/Package">
- <xsl:if test="count(error) > 0">
- <tr>
- <td align="left">
- <xsl:value-of select="@name"/>
- </td>
- <td align="left" colspan="8"><xsl:value-of select="error"/></td>
- </tr>
- </xsl:if>
- </xsl:for-each>
- </table>
-
- <table width="100%"><tr><td>
- <a name="NVpackages"><h2>Packages</h2></a>
- </td><td align="right">
- [<a href="#NVsummary">summary</a>]
- [<a href="#NVpackages">packages</a>]
- [<a href="#NVcycles">cycles</a>]
- [<a href="#NVexplanations">explanations</a>]
- </td></tr></table>
-
- <xsl:for-each select="./Packages/Package">
- <xsl:if test="count(error) = 0">
- <h3><a><xsl:attribute name="name">PK<xsl:value-of select="@name"/></xsl:attribute>
- <xsl:value-of select="@name"/></a></h3>
-
- <table width="100%"><tr>
- <td><a href="#EXafferent">Afferent Couplings</a>: <xsl:value-of select="Stats/Ca"/></td>
- <td><a href="#EXefferent">Efferent Couplings</a>: <xsl:value-of select="Stats/Ce"/></td>
- <td><a href="#EXabstractness">Abstractness</a>: <xsl:value-of select="Stats/A"/></td>
- <td><a href="#EXinstability">Instability</a>: <xsl:value-of select="Stats/I"/></td>
- <td><a href="#EXdistance">Distance</a>: <xsl:value-of select="Stats/D"/></td>
- </tr></table>
-
- <table width="100%" class="details">
- <tr>
- <th>Abstract Classes</th>
- <th>Concrete Classes</th>
- <th>Used by Packages</th>
- <th>Uses Packages</th>
- </tr>
- <tr>
- <td valign="top" width="25%">
- <xsl:if test="count(AbstractClasses/Class)=0">
- <i>None</i>
- </xsl:if>
- <xsl:for-each select="AbstractClasses/Class">
- <xsl:value-of select="node()"/><br/>
- </xsl:for-each>
- </td>
- <td valign="top" width="25%">
- <xsl:if test="count(ConcreteClasses/Class)=0">
- <i>None</i>
- </xsl:if>
- <xsl:for-each select="ConcreteClasses/Class">
- <xsl:value-of select="node()"/><br/>
- </xsl:for-each>
- </td>
- <td valign="top" width="25%">
- <xsl:if test="count(UsedBy/Package)=0">
- <i>None</i>
- </xsl:if>
- <xsl:for-each select="UsedBy/Package">
- <a>
- <xsl:attribute name="href">#PK<xsl:value-of select="node()"/></xsl:attribute>
- <xsl:value-of select="node()"/>
- </a><br/>
- </xsl:for-each>
- </td>
- <td valign="top" width="25%">
- <xsl:if test="count(DependsUpon/Package)=0">
- <i>None</i>
- </xsl:if>
- <xsl:for-each select="DependsUpon/Package">
- <a>
- <xsl:attribute name="href">#PK<xsl:value-of select="node()"/></xsl:attribute>
- <xsl:value-of select="node()"/>
- </a><br/>
- </xsl:for-each>
- </td>
- </tr>
- </table>
- </xsl:if>
- </xsl:for-each>
-
- <table width="100%"><tr><td>
- <a name="NVcycles"><h2>Cycles</h2></a>
- </td><td align="right">
- [<a href="#NVsummary">summary</a>]
- [<a href="#NVpackages">packages</a>]
- [<a href="#NVcycles">cycles</a>]
- [<a href="#NVexplanations">explanations</a>]
- </td></tr></table>
-
- <xsl:if test="count(Cycles/Package) = 0">
- <p>There are no cyclic dependancies.</p>
- </xsl:if>
- <xsl:for-each select="Cycles/Package">
- <h3><xsl:value-of select="@Name"/></h3><p>
- <xsl:for-each select="Package">
- <xsl:value-of select="."/><br/>
- </xsl:for-each></p>
- </xsl:for-each>
-
- <table width="100%"><tr><td>
- <a name="NVexplanations"><h2>Explanations</h2></a>
- </td><td align="right">
- [<a href="#NVsummary">summary</a>]
- [<a href="#NVpackages">packages</a>]
- [<a href="#NVcycles">cycles</a>]
- [<a href="#NVexplanations">explanations</a>]
- </td></tr></table>
-
- <p>The following explanations are for quick reference and are lifted directly from the original <a href="http://www.clarkware.com/software/JDepend.html">JDepend documentation</a>.</p>
-
- <h3><a name="EXnumber">Number of Classes</a></h3>
- <p>The number of concrete and abstract classes (and interfaces) in the package is an indicator of the extensibility of the package.</p>
- <h3><a name="EXafferent">Afferent Couplings</a></h3>
- <p>The number of other packages that depend upon classes within the package is an indicator of the package's responsibility. </p>
- <h3><a name="EXefferent">Efferent Couplings</a></h3>
- <p>The number of other packages that the classes in the package depend upon is an indicator of the package's independence. </p>
- <h3><a name="EXabstractness">Abstractness</a></h3>
- <p>The ratio of the number of abstract classes (and interfaces) in the analyzed package to the total number of classes in the analyzed package. </p>
- <p>The range for this metric is 0 to 1, with A=0 indicating a completely concrete package and A=1 indicating a completely abstract package. </p>
- <h3><a name="EXinstability">Instability</a></h3>
- <p>The ratio of efferent coupling (Ce) to total coupling (Ce / (Ce + Ca)). This metric is an indicator of the package's resilience to change. </p>
- <p>The range for this metric is 0 to 1, with I=0 indicating a completely stable package and I=1 indicating a completely instable package. </p>
- <h3><a name="EXdistance">Distance</a></h3>
- <p>The perpendicular distance of a package from the idealized line A + I = 1. This metric is an indicator of the package's balance between abstractness and stability. </p>
- <p>A package squarely on the main sequence is optimally balanced with respect to its abstractness and stability. Ideal packages are either completely abstract and stable (x=0, y=1) or completely concrete and instable (x=1, y=0). </p>
- <p>The range for this metric is 0 to 1, with D=0 indicating a package that is coincident with the main sequence and D=1 indicating a package that is as far from the main sequence as possible. </p>
-
- </body>
- </html>
-</xsl:template>
-
-</xsl:stylesheet>
-Durl=$M2_REPOSITORY \
-Dfile=poi-@VERSION@-@DSTAMP@.jar -DpomFile=poi-@VERSION@.pom
scp poi-@VERSION@.pom.asc $M2_SCP/org/apache/poi/poi/@VERSION@/
+scp poi-@VERSION@-sources.* $M2_SCP/org/apache/poi/poi/@VERSION@/
mvn gpg:sign-and-deploy-file -DrepositoryId=apache-releases -P apache-releases \
-Durl=$M2_REPOSITORY \
-Dfile=poi-scratchpad-@VERSION@-@DSTAMP@.jar -DpomFile=poi-scratchpad-@VERSION@.pom
scp poi-scratchpad-@VERSION@.pom.asc $M2_SCP/org/apache/poi/poi-scratchpad/@VERSION@/
+scp poi-scratchpad-@VERSION@-sources.* $M2_SCP/org/apache/poi/poi-scratchpad/@VERSION@/
mvn gpg:sign-and-deploy-file -DrepositoryId=apache-releases -P apache-releases \
-Durl=$M2_REPOSITORY \
-Dfile=poi-contrib-@VERSION@-@DSTAMP@.jar -DpomFile=poi-contrib-@VERSION@.pom
scp poi-contrib-@VERSION@.pom.asc $M2_SCP/org/apache/poi/poi-contrib/@VERSION@/
+scp poi-contrib-@VERSION@-sources.* $M2_SCP/org/apache/poi/poi-contrib/@VERSION@/
mvn gpg:sign-and-deploy-file -DrepositoryId=apache-releases -P apache-releases \
-Durl=$M2_REPOSITORY \
-Dfile=poi-ooxml-@VERSION@-@DSTAMP@.jar -DpomFile=poi-ooxml-@VERSION@.pom
scp poi-ooxml-@VERSION@.pom.asc $M2_SCP/org/apache/poi/poi-ooxml/@VERSION@/
+scp poi-ooxml-@VERSION@-sources.* $M2_SCP/org/apache/poi/poi-ooxml/@VERSION@/
+
+mvn gpg:sign-and-deploy-file -DrepositoryId=apache-releases -P apache-releases \
+ -Durl=$M2_REPOSITORY \
+ -Dfile=poi-ooxml-schemas-@VERSION@-@DSTAMP@.jar -DpomFile=poi-ooxml-schemas-@VERSION@.pom
+scp poi-ooxml-schemas-@VERSION@.pom.asc $M2_SCP/org/apache/poi/poi-ooxml-schemas/@VERSION@/
+
+mvn gpg:sign-and-deploy-file -DrepositoryId=apache-releases -P apache-releases \
+ -Durl=$M2_REPOSITORY \
+ -Dfile=poi-examples-@VERSION@-@DSTAMP@.jar -DpomFile=poi-examples-@VERSION@.pom
+scp poi-examples-@VERSION@.pom.asc $M2_SCP/org/apache/poi/poi-examples/@VERSION@/
--- /dev/null
+<?xml version="1.0"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.apache.poi</groupId>
+ <artifactId>poi-examples</artifactId>
+ <version>@VERSION@</version>
+ <packaging>jar</packaging>
+ <name>Apache POI</name>
+ <url>http://poi.apache.org/</url>
+ <description>Apache POI Examples</description>
+
+ <mailingLists>
+ <mailingList>
+ <name>POI Users List</name>
+ <subscribe>user-subscribe@poi.apache.org</subscribe>
+ <unsubscribe>user-unsubscribe@poi.apache.org</unsubscribe>
+ <archive>http://mail-archives.apache.org/mod_mbox/poi-user/</archive>
+ </mailingList>
+ <mailingList>
+ <name>POI Developer List</name>
+ <subscribe>dev-subscribe@poi.apache.org</subscribe>
+ <unsubscribe>dev-unsubscribe@poi.apache.org</unsubscribe>
+ <archive>http://mail-archives.apache.org/mod_mbox/poi-dev/</archive>
+ </mailingList>
+ </mailingLists>
+
+ <licenses>
+ <license>
+ <name>The Apache Software License, Version 2.0</name>
+ <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
+ </license>
+ </licenses>
+
+ <organization>
+ <name>Apache Software Foundation</name>
+ <url>http://www.apache.org/</url>
+ </organization>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.poi</groupId>
+ <artifactId>poi</artifactId>
+ <version>@VERSION@</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.poi</groupId>
+ <artifactId>poi-scratchpad</artifactId>
+ <version>@VERSION@</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.poi</groupId>
+ <artifactId>poi-ooxml</artifactId>
+ <version>@VERSION@</version>
+ </dependency>
+ </dependencies>
+</project>
--- /dev/null
+<?xml version="1.0"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.apache.poi</groupId>
+ <artifactId>poi-ooxml-schemas</artifactId>
+ <version>@VERSION@</version>
+ <packaging>jar</packaging>
+ <name>Apache POI</name>
+ <url>http://poi.apache.org/</url>
+ <description>Apache POI - Java API To Access Microsoft Format Files</description>
+
+ <mailingLists>
+ <mailingList>
+ <name>POI Users List</name>
+ <subscribe>user-subscribe@poi.apache.org</subscribe>
+ <unsubscribe>user-unsubscribe@poi.apache.org</unsubscribe>
+ <archive>http://mail-archives.apache.org/mod_mbox/poi-user/</archive>
+ </mailingList>
+ <mailingList>
+ <name>POI Developer List</name>
+ <subscribe>dev-subscribe@poi.apache.org</subscribe>
+ <unsubscribe>dev-unsubscribe@poi.apache.org</unsubscribe>
+ <archive>http://mail-archives.apache.org/mod_mbox/poi-dev/</archive>
+ </mailingList>
+ </mailingLists>
+
+ <licenses>
+ <license>
+ <name>The Apache Software License, Version 2.0</name>
+ <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
+ </license>
+ </licenses>
+
+ <organization>
+ <name>Apache Software Foundation</name>
+ <url>http://www.apache.org/</url>
+ </organization>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.xmlbeans</groupId>
+ <artifactId>xmlbeans</artifactId>
+ <version>2.3.0</version>
+ </dependency>
+ </dependencies>
+</project>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
- <artifactId>ooxml-schemas</artifactId>
- <version>1.0</version>
+ <artifactId>poi-ooxml-schemas</artifactId>
+ <version>@VERSION@</version>
</dependency>
<dependency>
<groupId>dom4j</groupId>
</tr>
<tr>
<td>test</td>
- <td>Run all unit tests from main, contrib and scratchpad (Requires JUnit)</td>
+ <td>Run all unit tests from main, ooxml, contrib and scratchpad</td>
</tr>
<tr>
<td>jar</td>
<td>Produce jar files</td>
</tr>
+ <tr>
+ <td>assemble</td>
+ <td>Produce .zip and tar.gz distribution packages</td>
+ </tr>
<tr>
<td>docs</td>
<td>Generate all documentation (Requires Apache Forrest)</td>
</tr>
<tr>
<td>dist</td>
- <td>Create a distribution (Requires JUnit and Apache Forrest)</td>
+ <td>Create a distribution (Apache Forrest)</td>
</tr>
</table>
</section>
--- /dev/null
+/* ====================================================================
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+==================================================================== */
+
+package org.apache.poi.hslf.examples;
+
+import org.apache.poi.hslf.usermodel.*;
+import org.apache.poi.hslf.model.*;
+import org.apache.poi.hslf.record.TextHeaderAtom;
+
+import java.io.IOException;
+import java.io.FileOutputStream;
+import java.io.File;
+import java.awt.*;
+
+/**
+ * Presentation for Fast Feather Track on ApacheconEU 2008
+ *
+ * @author Yegor Kozlov
+ */
+public final class ApacheconEU08 {
+
+ public static void main(String[] args) throws IOException {
+ SlideShow ppt = new SlideShow();
+ ppt.setPageSize(new Dimension(720, 540));
+
+ slide1(ppt);
+ slide2(ppt);
+ slide3(ppt);
+ slide4(ppt);
+ slide5(ppt);
+ slide6(ppt);
+ slide7(ppt);
+ slide8(ppt);
+ slide9(ppt);
+ slide10(ppt);
+ slide11(ppt);
+ slide12(ppt);
+
+ FileOutputStream out = new FileOutputStream("apachecon_eu_08.ppt");
+ ppt.write(out);
+ out.close();
+
+ }
+
+ public static void slide1(SlideShow ppt) throws IOException {
+ Slide slide = ppt.createSlide();
+
+ TextBox box1 = new TextBox();
+ TextRun tr1 = box1.getTextRun();
+ tr1.setRunType(TextHeaderAtom.CENTER_TITLE_TYPE);
+ tr1.setText("POI-HSLF");
+ box1.setAnchor(new Rectangle(54, 78, 612, 115));
+ slide.addShape(box1);
+
+ TextBox box2 = new TextBox();
+ TextRun tr2 = box2.getTextRun();
+ tr2.setRunType(TextHeaderAtom.CENTRE_BODY_TYPE);
+ tr2.setText("Java API To Access Microsoft PowerPoint Format Files");
+ box2.setAnchor(new Rectangle(108, 204, 504, 138));
+ slide.addShape(box2);
+
+ TextBox box3 = new TextBox();
+ TextRun tr3 = box3.getTextRun();
+ tr3.getRichTextRuns()[0].setFontSize(32);
+ box3.setHorizontalAlignment(TextBox.AlignCenter);
+ tr3.setText(
+ "Yegor Kozlov\r" +
+ "yegor - apache - org");
+ box3.setAnchor(new Rectangle(206, 348, 310, 84));
+ slide.addShape(box3);
+ }
+
+ public static void slide2(SlideShow ppt) throws IOException {
+ Slide slide = ppt.createSlide();
+
+ TextBox box1 = new TextBox();
+ TextRun tr1 = box1.getTextRun();
+ tr1.setRunType(TextHeaderAtom.TITLE_TYPE);
+ tr1.setText("What is HSLF?");
+ box1.setAnchor(new Rectangle(36, 21, 648, 90));
+ slide.addShape(box1);
+
+ TextBox box2 = new TextBox();
+ TextRun tr2 = box2.getTextRun();
+ tr2.setRunType(TextHeaderAtom.BODY_TYPE);
+ tr2.setText("HorribleSLideshowFormat is the POI Project's pure Java implementation " +
+ "of the Powerpoint binary file format. \r" +
+ "POI sub-project since 2005\r" +
+ "Started by Nick Birch, Yegor Kozlov joined soon after");
+ box2.setAnchor(new Rectangle(36, 126, 648, 356));
+ slide.addShape(box2);
+
+
+ }
+
+ public static void slide3(SlideShow ppt) throws IOException {
+ Slide slide = ppt.createSlide();
+
+ TextBox box1 = new TextBox();
+ TextRun tr1 = box1.getTextRun();
+ tr1.setRunType(TextHeaderAtom.TITLE_TYPE);
+ tr1.setText("HSLF in a Nutshell");
+ box1.setAnchor(new Rectangle(36, 15, 648, 65));
+ slide.addShape(box1);
+
+ TextBox box2 = new TextBox();
+ TextRun tr2 = box2.getTextRun();
+ tr2.setRunType(TextHeaderAtom.BODY_TYPE);
+ tr2.setText(
+ "HSLF provides a way to read, create and modify MS PowerPoint presentations\r" +
+ "Pure Java API - you don't need PowerPoint to read and write *.ppt files\r" +
+ "Comprehensive support of PowerPoint objects");
+ tr2.getRichTextRuns()[0].setFontSize(28);
+ box2.setAnchor(new Rectangle(36, 80, 648, 200));
+ slide.addShape(box2);
+
+ TextBox box3 = new TextBox();
+ TextRun tr3 = box3.getTextRun();
+ tr3.setRunType(TextHeaderAtom.BODY_TYPE);
+ tr3.setText(
+ "Rich text\r" +
+ "Tables\r" +
+ "Shapes\r" +
+ "Pictures\r" +
+ "Master slides");
+ tr3.getRichTextRuns()[0].setFontSize(24);
+ tr3.getRichTextRuns()[0].setIndentLevel(1);
+ box3.setAnchor(new Rectangle(36, 265, 648, 150));
+ slide.addShape(box3);
+
+ TextBox box4 = new TextBox();
+ TextRun tr4 = box4.getTextRun();
+ tr4.setRunType(TextHeaderAtom.BODY_TYPE);
+ tr4.setText("Access to low level data structures");
+ box4.setAnchor(new Rectangle(36, 430, 648, 50));
+ slide.addShape(box4);
+ }
+
+ public static void slide4(SlideShow ppt) throws IOException {
+ Slide slide = ppt.createSlide();
+
+ String[][] txt1 = {
+ {"Note"},
+ {"This presentation was created programmatically using POI HSLF"}
+ };
+ Table table1 = new Table(2, 1);
+ for (int i = 0; i < txt1.length; i++) {
+ for (int j = 0; j < txt1[i].length; j++) {
+ TableCell cell = table1.getCell(i, j);
+ cell.setText(txt1[i][j]);
+ cell.getTextRun().getRichTextRuns()[0].setFontSize(10);
+ RichTextRun rt = cell.getTextRun().getRichTextRuns()[0];
+ rt.setFontName("Arial");
+ rt.setBold(true);
+ if(i == 0){
+ rt.setFontSize(32);
+ rt.setFontColor(Color.white);
+ cell.getFill().setForegroundColor(new Color(0, 153, 204));
+ } else {
+ rt.setFontSize(28);
+ cell.getFill().setForegroundColor(new Color(235, 239, 241));
+ }
+ cell.setVerticalAlignment(TextBox.AnchorMiddle);
+ }
+ }
+
+ Line border1 = table1.createBorder();
+ border1.setLineColor(Color.black);
+ border1.setLineWidth(1.0);
+ table1.setAllBorders(border1);
+
+ Line border2 = table1.createBorder();
+ border2.setLineColor(Color.black);
+ border2.setLineWidth(2.0);
+ table1.setOutsideBorders(border2);
+
+ table1.setColumnWidth(0, 510);
+ table1.setRowHeight(0, 60);
+ table1.setRowHeight(1, 100);
+ slide.addShape(table1);
+
+ table1.moveTo(100, 100);
+
+ TextBox box1 = new TextBox();
+ box1.setHorizontalAlignment(TextBox.AlignCenter);
+ TextRun tr1 = box1.getTextRun();
+ tr1.setText("The source code is available at\r" +
+ "http://people.apache.org/~yegor/apachecon_eu08/");
+ RichTextRun rt = tr1.getRichTextRuns()[0];
+ rt.setFontSize(24);
+ box1.setAnchor(new Rectangle(80, 356, 553, 65));
+ slide.addShape(box1);
+
+ }
+
+ public static void slide5(SlideShow ppt) throws IOException {
+ Slide slide = ppt.createSlide();
+
+ TextBox box1 = new TextBox();
+ TextRun tr1 = box1.getTextRun();
+ tr1.setRunType(TextHeaderAtom.TITLE_TYPE);
+ tr1.setText("HSLF in Action - 1\rData Extraction");
+ box1.setAnchor(new Rectangle(36, 21, 648, 100));
+ slide.addShape(box1);
+
+ TextBox box2 = new TextBox();
+ TextRun tr2 = box2.getTextRun();
+ tr2.setRunType(TextHeaderAtom.BODY_TYPE);
+ tr2.setText(
+ "Text from slides and notes\r" +
+ "Images\r" +
+ "Shapes and their properties (type, position in the slide, color, font, etc.)");
+ box2.setAnchor(new Rectangle(36, 150, 648, 300));
+ slide.addShape(box2);
+
+
+ }
+
+ public static void slide6(SlideShow ppt) throws IOException {
+ Slide slide = ppt.createSlide();
+
+ TextBox box1 = new TextBox();
+ TextRun tr1 = box1.getTextRun();
+ tr1.setRunType(TextHeaderAtom.TITLE_TYPE);
+ tr1.setText("HSLF in Action - 2");
+ box1.setAnchor(new Rectangle(36, 20, 648, 90));
+ slide.addShape(box1);
+
+ TextBox box2 = new TextBox();
+ TextRun tr2 = box2.getTextRun();
+ tr2.getRichTextRuns()[0].setFontSize(18);
+ tr2.setText("Creating a simple presentation from scratch");
+ box2.setAnchor(new Rectangle(170, 100, 364, 30));
+ slide.addShape(box2);
+
+ TextBox box3 = new TextBox();
+ TextRun tr3 = box3.getTextRun();
+ RichTextRun rt3 = tr3.getRichTextRuns()[0];
+ rt3.setFontName("Courier New");
+ rt3.setFontSize(8);
+ tr3.setText(
+ " SlideShow ppt = new SlideShow();\r" +
+ " Slide slide = ppt.createSlide();\r" +
+ "\r" +
+ " TextBox box2 = new TextBox();\r" +
+ " box2.setHorizontalAlignment(TextBox.AlignCenter);\r" +
+ " box2.setVerticalAlignment(TextBox.AnchorMiddle);\r" +
+ " box2.getTextRun().setText(\"Java Code\");\r" +
+ " box2.getFill().setForegroundColor(new Color(187, 224, 227));\r" +
+ " box2.setLineColor(Color.black);\r" +
+ " box2.setLineWidth(0.75);\r" +
+ " box2.setAnchor(new Rectangle(66, 243, 170, 170));\r" +
+ " slide.addShape(box2);\r" +
+ "\r" +
+ " TextBox box3 = new TextBox();\r" +
+ " box3.setHorizontalAlignment(TextBox.AlignCenter);\r" +
+ " box3.setVerticalAlignment(TextBox.AnchorMiddle);\r" +
+ " box3.getTextRun().setText(\"*.ppt file\");\r" +
+ " box3.setLineWidth(0.75);\r" +
+ " box3.setLineColor(Color.black);\r" +
+ " box3.getFill().setForegroundColor(new Color(187, 224, 227));\r" +
+ " box3.setAnchor(new Rectangle(473, 243, 170, 170));\r" +
+ " slide.addShape(box3);\r" +
+ "\r" +
+ " AutoShape box4 = new AutoShape(ShapeTypes.Arrow);\r" +
+ " box4.getFill().setForegroundColor(new Color(187, 224, 227));\r" +
+ " box4.setLineWidth(0.75);\r" +
+ " box4.setLineColor(Color.black);\r" +
+ " box4.setAnchor(new Rectangle(253, 288, 198, 85));\r" +
+ " slide.addShape(box4);\r" +
+ "\r" +
+ " FileOutputStream out = new FileOutputStream(\"hslf-demo.ppt\");\r" +
+ " ppt.write(out);\r" +
+ " out.close();");
+ box3.setAnchor(new Rectangle(30, 150, 618, 411));
+ slide.addShape(box3);
+ }
+
+ public static void slide7(SlideShow ppt) throws IOException {
+ Slide slide = ppt.createSlide();
+
+ TextBox box2 = new TextBox();
+ box2.setHorizontalAlignment(TextBox.AlignCenter);
+ box2.setVerticalAlignment(TextBox.AnchorMiddle);
+ box2.getTextRun().setText("Java Code");
+ box2.getFill().setForegroundColor(new Color(187, 224, 227));
+ box2.setLineColor(Color.black);
+ box2.setLineWidth(0.75);
+ box2.setAnchor(new Rectangle(66, 243, 170, 170));
+ slide.addShape(box2);
+
+ TextBox box3 = new TextBox();
+ box3.setHorizontalAlignment(TextBox.AlignCenter);
+ box3.setVerticalAlignment(TextBox.AnchorMiddle);
+ box3.getTextRun().setText("*.ppt file");
+ box3.setLineWidth(0.75);
+ box3.setLineColor(Color.black);
+ box3.getFill().setForegroundColor(new Color(187, 224, 227));
+ box3.setAnchor(new Rectangle(473, 243, 170, 170));
+ slide.addShape(box3);
+
+ AutoShape box4 = new AutoShape(ShapeTypes.Arrow);
+ box4.getFill().setForegroundColor(new Color(187, 224, 227));
+ box4.setLineWidth(0.75);
+ box4.setLineColor(Color.black);
+ box4.setAnchor(new Rectangle(253, 288, 198, 85));
+ slide.addShape(box4);
+ }
+
+ public static void slide8(SlideShow ppt) throws IOException {
+ Slide slide = ppt.createSlide();
+
+ TextBox box1 = new TextBox();
+ TextRun tr1 = box1.getTextRun();
+ tr1.setRunType(TextHeaderAtom.TITLE_TYPE);
+ tr1.setText("Wait, there is more!");
+ box1.setAnchor(new Rectangle(36, 21, 648, 90));
+ slide.addShape(box1);
+
+ TextBox box2 = new TextBox();
+ TextRun tr2 = box2.getTextRun();
+ tr2.setRunType(TextHeaderAtom.BODY_TYPE);
+ tr2.setText(
+ "Rich text\r" +
+ "Tables\r" +
+ "Pictures (JPEG, PNG, BMP, WMF, PICT)\r" +
+ "Comprehensive formatting features");
+ box2.setAnchor(new Rectangle(36, 126, 648, 356));
+ slide.addShape(box2);
+ }
+
+ public static void slide9(SlideShow ppt) throws IOException {
+ Slide slide = ppt.createSlide();
+
+ TextBox box1 = new TextBox();
+ TextRun tr1 = box1.getTextRun();
+ tr1.setRunType(TextHeaderAtom.TITLE_TYPE);
+ tr1.setText("HSLF in Action - 3");
+ box1.setAnchor(new Rectangle(36, 20, 648, 50));
+ slide.addShape(box1);
+
+ TextBox box2 = new TextBox();
+ TextRun tr2 = box2.getTextRun();
+ tr2.getRichTextRuns()[0].setFontSize(18);
+ tr2.setText("PPGraphics2D: PowerPoint Graphics2D driver");
+ box2.setAnchor(new Rectangle(178, 70, 387, 30));
+ slide.addShape(box2);
+
+ TextBox box3 = new TextBox();
+ TextRun tr3 = box3.getTextRun();
+ RichTextRun rt3 = tr3.getRichTextRuns()[0];
+ rt3.setFontName("Courier New");
+ rt3.setFontSize(8);
+ tr3.setText(
+ " //bar chart data. The first value is the bar color, the second is the width\r" +
+ " Object[] def = new Object[]{\r" +
+ " Color.yellow, new Integer(100),\r" +
+ " Color.green, new Integer(150),\r" +
+ " Color.gray, new Integer(75),\r" +
+ " Color.red, new Integer(200),\r" +
+ " };\r" +
+ "\r" +
+ " SlideShow ppt = new SlideShow();\r" +
+ " Slide slide = ppt.createSlide();\r" +
+ "\r" +
+ " ShapeGroup group = new ShapeGroup();\r" +
+ " //define position of the drawing in the slide\r" +
+ " Rectangle bounds = new java.awt.Rectangle(200, 100, 350, 300);\r" +
+ " group.setAnchor(bounds);\r" +
+ " slide.addShape(group);\r" +
+ " Graphics2D graphics = new PPGraphics2D(group);\r" +
+ "\r" +
+ " //draw a simple bar graph\r" +
+ " int x = bounds.x + 50, y = bounds.y + 50;\r" +
+ " graphics.setFont(new Font(\"Arial\", Font.BOLD, 10));\r" +
+ " for (int i = 0, idx = 1; i < def.length; i+=2, idx++) {\r" +
+ " graphics.setColor(Color.black);\r" +
+ " int width = ((Integer)def[i+1]).intValue();\r" +
+ " graphics.drawString(\"Q\" + idx, x-20, y+20);\r" +
+ " graphics.drawString(width + \"%\", x + width + 10, y + 20);\r" +
+ " graphics.setColor((Color)def[i]);\r" +
+ " graphics.fill(new Rectangle(x, y, width, 30));\r" +
+ " y += 40;\r" +
+ " }\r" +
+ " graphics.setColor(Color.black);\r" +
+ " graphics.setFont(new Font(\"Arial\", Font.BOLD, 14));\r" +
+ " graphics.draw(bounds);\r" +
+ " graphics.drawString(\"Performance\", x + 70, y + 40);\r" +
+ "\r" +
+ " FileOutputStream out = new FileOutputStream(\"hslf-demo.ppt\");\r" +
+ " ppt.write(out);\r" +
+ " out.close();");
+ box3.setAnchor(new Rectangle(96, 110, 499, 378));
+ slide.addShape(box3);
+ }
+
+ public static void slide10(SlideShow ppt) throws IOException {
+ //bar chart data. The first value is the bar color, the second is the width
+ Object[] def = new Object[]{
+ Color.yellow, new Integer(100),
+ Color.green, new Integer(150),
+ Color.gray, new Integer(75),
+ Color.red, new Integer(200),
+ };
+
+ Slide slide = ppt.createSlide();
+
+ ShapeGroup group = new ShapeGroup();
+ //define position of the drawing in the slide
+ Rectangle bounds = new java.awt.Rectangle(200, 100, 350, 300);
+ group.setAnchor(bounds);
+ slide.addShape(group);
+ Graphics2D graphics = new PPGraphics2D(group);
+
+ //draw a simple bar graph
+ int x = bounds.x + 50, y = bounds.y + 50;
+ graphics.setFont(new Font("Arial", Font.BOLD, 10));
+ for (int i = 0, idx = 1; i < def.length; i+=2, idx++) {
+ graphics.setColor(Color.black);
+ int width = ((Integer)def[i+1]).intValue();
+ graphics.drawString("Q" + idx, x-20, y+20);
+ graphics.drawString(width + "%", x + width + 10, y + 20);
+ graphics.setColor((Color)def[i]);
+ graphics.fill(new Rectangle(x, y, width, 30));
+ y += 40;
+ }
+ graphics.setColor(Color.black);
+ graphics.setFont(new Font("Arial", Font.BOLD, 14));
+ graphics.draw(bounds);
+ graphics.drawString("Performance", x + 70, y + 40);
+
+ }
+
+ public static void slide11(SlideShow ppt) throws IOException {
+ Slide slide = ppt.createSlide();
+
+ TextBox box1 = new TextBox();
+ TextRun tr1 = box1.getTextRun();
+ tr1.setRunType(TextHeaderAtom.TITLE_TYPE);
+ tr1.setText("HSLF Development Plans");
+ box1.setAnchor(new Rectangle(36, 21, 648, 90));
+ slide.addShape(box1);
+
+ TextBox box2 = new TextBox();
+ TextRun tr2 = box2.getTextRun();
+ tr2.setRunType(TextHeaderAtom.BODY_TYPE);
+ tr2.getRichTextRuns()[0].setFontSize(32);
+ tr2.setText(
+ "Support for more PowerPoint functionality\r" +
+ "Rendering slides into java.awt.Graphics2D");
+ box2.setAnchor(new Rectangle(36, 126, 648, 100));
+ slide.addShape(box2);
+
+ TextBox box3 = new TextBox();
+ TextRun tr3 = box3.getTextRun();
+ tr3.setRunType(TextHeaderAtom.BODY_TYPE);
+ tr3.getRichTextRuns()[0].setIndentLevel(1);
+ tr3.setText(
+ "A way to export slides into images or other formats");
+ box3.setAnchor(new Rectangle(36, 220, 648, 70));
+ slide.addShape(box3);
+
+ TextBox box4 = new TextBox();
+ TextRun tr4 = box4.getTextRun();
+ tr4.setRunType(TextHeaderAtom.BODY_TYPE);
+ tr4.getRichTextRuns()[0].setFontSize(32);
+ tr4.setText(
+ "Integration with Apache FOP - Formatting Objects Processor");
+ box4.setAnchor(new Rectangle(36, 290, 648, 90));
+ slide.addShape(box4);
+
+ TextBox box5 = new TextBox();
+ TextRun tr5 = box5.getTextRun();
+ tr5.setRunType(TextHeaderAtom.BODY_TYPE);
+ tr5.getRichTextRuns()[0].setIndentLevel(1);
+ tr5.setText(
+ "Transformation of XSL-FO into PPT\r" +
+ "PPT2PDF transcoder");
+ box5.setAnchor(new Rectangle(36, 380, 648, 100));
+ slide.addShape(box5);
+ }
+
+ public static void slide12(SlideShow ppt) throws IOException {
+ Slide slide = ppt.createSlide();
+
+ TextBox box1 = new TextBox();
+ TextRun tr1 = box1.getTextRun();
+ tr1.setRunType(TextHeaderAtom.CENTER_TITLE_TYPE);
+ tr1.setText("Questions?");
+ box1.setAnchor(new Rectangle(54, 167, 612, 115));
+ slide.addShape(box1);
+
+ TextBox box2 = new TextBox();
+ TextRun tr2 = box2.getTextRun();
+ tr2.setRunType(TextHeaderAtom.CENTRE_BODY_TYPE);
+ tr2.setText(
+ "http://poi.apache.org/hslf/\r" +
+ "http://people.apache.org/~yegor");
+ box2.setAnchor(new Rectangle(108, 306, 504, 138));
+ slide.addShape(box2);
+ }
+}
--- /dev/null
+/* ====================================================================
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+==================================================================== */
+
+package org.apache.poi.hslf.examples;
+
+import org.apache.poi.hslf.usermodel.SlideShow;
+import org.apache.poi.hslf.usermodel.RichTextRun;
+import org.apache.poi.hslf.model.Slide;
+import org.apache.poi.hslf.model.TextBox;
+
+import java.io.FileOutputStream;
+
+/**
+ * How to create a single-level bulleted list
+ * and change some of the bullet attributes
+ *
+ * @author Yegor Kozlov
+ */
+public final class BulletsDemo {
+
+ public static void main(String[] args) throws Exception {
+
+ SlideShow ppt = new SlideShow();
+
+ Slide slide = ppt.createSlide();
+
+ TextBox shape = new TextBox();
+ RichTextRun rt = shape.getTextRun().getRichTextRuns()[0];
+ shape.setText(
+ "January\r" +
+ "February\r" +
+ "March\r" +
+ "April");
+ rt.setFontSize(42);
+ rt.setBullet(true);
+ rt.setBulletOffset(0); //bullet offset
+ rt.setTextOffset(50); //text offset (should be greater than bullet offset)
+ rt.setBulletChar('\u263A'); //bullet character
+ slide.addShape(shape);
+
+ shape.setAnchor(new java.awt.Rectangle(50, 50, 500, 300)); //position of the text box in the slide
+ slide.addShape(shape);
+
+ FileOutputStream out = new FileOutputStream("bullets.ppt");
+ ppt.write(out);
+ out.close();
+ }
+}
--- /dev/null
+/* ====================================================================
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+==================================================================== */
+
+package org.apache.poi.hslf.examples;
+
+import org.apache.poi.hslf.usermodel.SlideShow;
+import org.apache.poi.hslf.usermodel.RichTextRun;
+import org.apache.poi.hslf.model.*;
+
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.awt.*;
+
+/**
+ * Demonstrates how to create hyperlinks in PowerPoint presentations
+ *
+ * @author Yegor Kozlov
+ */
+public final class CreateHyperlink {
+
+ public static void main(String[] args) throws Exception {
+ SlideShow ppt = new SlideShow();
+
+ Slide slide = ppt.createSlide();
+
+ TextBox shape = new TextBox();
+ shape.setText("Apache POI");
+ Rectangle anchor = new Rectangle(100, 100, 200, 50);
+ shape.setAnchor(anchor);
+
+ String text = shape.getText();
+ Hyperlink link = new Hyperlink();
+ link.setAddress("http://www.apache.org");
+ link.setTitle(shape.getText());
+ int linkId = ppt.addHyperlink(link);
+
+ shape.setHyperlink(linkId, 0, text.length());
+
+ slide.addShape(shape);
+
+ FileOutputStream out = new FileOutputStream("hyperlink.ppt");
+ ppt.write(out);
+ out.close();
+
+ }
+}
--- /dev/null
+/* ====================================================================
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+==================================================================== */
+
+package org.apache.poi.hslf.examples;
+
+import org.apache.poi.hslf.usermodel.*;
+import org.apache.poi.hslf.model.*;
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
+import org.apache.poi.hwpf.HWPFDocument;
+import org.apache.poi.hwpf.usermodel.Range;
+import org.apache.poi.hwpf.usermodel.Paragraph;
+
+import java.io.*;
+
+/**
+ * Demonstrates how you can extract misc embedded data from a ppt file
+ *
+ * @author Yegor Kozlov
+ */
+public final class DataExtraction {
+
+ public static void main(String args[]) throws Exception {
+
+ if (args.length == 0) {
+ usage();
+ return;
+ }
+
+ FileInputStream is = new FileInputStream(args[0]);
+ SlideShow ppt = new SlideShow(is);
+ is.close();
+
+ //extract all sound files embedded in this presentation
+ SoundData[] sound = ppt.getSoundData();
+ for (int i = 0; i < sound.length; i++) {
+ String type = sound[i].getSoundType(); //*.wav
+ String name = sound[i].getSoundName(); //typically file name
+ byte[] data = sound[i].getData(); //raw bytes
+
+ //save the sound on disk
+ FileOutputStream out = new FileOutputStream(name + type);
+ out.write(data);
+ out.close();
+ }
+
+ //extract embedded OLE documents
+ Slide[] slide = ppt.getSlides();
+ for (int i = 0; i < slide.length; i++) {
+ Shape[] shape = slide[i].getShapes();
+ for (int j = 0; j < shape.length; j++) {
+ if (shape[j] instanceof OLEShape) {
+ OLEShape ole = (OLEShape) shape[j];
+ ObjectData data = ole.getObjectData();
+ String name = ole.getInstanceName();
+ if ("Worksheet".equals(name)) {
+
+ //read xls
+ HSSFWorkbook wb = new HSSFWorkbook(data.getData());
+
+ } else if ("Document".equals(name)) {
+ HWPFDocument doc = new HWPFDocument(data.getData());
+ //read the word document
+ Range r = doc.getRange();
+ for(int k = 0; k < r.numParagraphs(); k++) {
+ Paragraph p = r.getParagraph(k);
+ System.out.println(p.text());
+ }
+
+ //save on disk
+ FileOutputStream out = new FileOutputStream(name + "-("+(j)+").doc");
+ doc.write(out);
+ out.close();
+ } else {
+ FileOutputStream out = new FileOutputStream(ole.getProgID() + "-"+(j+1)+".dat");
+ InputStream dis = data.getData();
+ byte[] chunk = new byte[2048];
+ int count;
+ while ((count = dis.read(chunk)) >= 0) {
+ out.write(chunk,0,count);
+ }
+ is.close();
+ out.close();
+ }
+ }
+
+ }
+ }
+
+ //Pictures
+ for (int i = 0; i < slide.length; i++) {
+ Shape[] shape = slide[i].getShapes();
+ for (int j = 0; j < shape.length; j++) {
+ if (shape[j] instanceof Picture) {
+ Picture p = (Picture) shape[j];
+ PictureData data = p.getPictureData();
+ String name = p.getPictureName();
+ int type = data.getType();
+ String ext;
+ switch (type) {
+ case Picture.JPEG:
+ ext = ".jpg";
+ break;
+ case Picture.PNG:
+ ext = ".png";
+ break;
+ case Picture.WMF:
+ ext = ".wmf";
+ break;
+ case Picture.EMF:
+ ext = ".emf";
+ break;
+ case Picture.PICT:
+ ext = ".pict";
+ break;
+ case Picture.DIB:
+ ext = ".dib";
+ break;
+ default:
+ continue;
+ }
+ FileOutputStream out = new FileOutputStream("pict-" + j + ext);
+ out.write(data.getData());
+ out.close();
+ }
+
+ }
+ }
+
+ }
+
+ private static void usage(){
+ System.out.println("Usage: DataExtraction ppt");
+ }
+}
--- /dev/null
+/* ====================================================================
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+==================================================================== */
+
+package org.apache.poi.hslf.examples;
+
+import org.apache.poi.hslf.usermodel.SlideShow;
+import org.apache.poi.hslf.model.*;
+
+import java.awt.*;
+import java.io.FileOutputStream;
+import java.io.FileInputStream;
+
+/**
+ * Demonstrates how to draw into a slide using the HSLF Graphics2D driver.
+ *
+ * @author Yegor Kozlov
+ */
+public final class Graphics2DDemo {
+
+ /**
+ * A simple bar chart demo
+ */
+ public static void main(String[] args) throws Exception {
+ SlideShow ppt = new SlideShow();
+
+ //bar chart data. The first value is the bar color, the second is the width
+ Object[] def = new Object[]{
+ Color.yellow, new Integer(40),
+ Color.green, new Integer(60),
+ Color.gray, new Integer(30),
+ Color.red, new Integer(80),
+ };
+
+ Slide slide = ppt.createSlide();
+
+ ShapeGroup group = new ShapeGroup();
+ //define position of the drawing in the slide
+ Rectangle bounds = new java.awt.Rectangle(200, 100, 350, 300);
+ group.setAnchor(bounds);
+ group.setCoordinates(new java.awt.Rectangle(0, 0, 100, 100));
+ slide.addShape(group);
+ Graphics2D graphics = new PPGraphics2D(group);
+
+ //draw a simple bar graph
+ int x = 10, y = 10;
+ graphics.setFont(new Font("Arial", Font.BOLD, 10));
+ for (int i = 0, idx = 1; i < def.length; i+=2, idx++) {
+ graphics.setColor(Color.black);
+ int width = ((Integer)def[i+1]).intValue();
+ graphics.drawString("Q" + idx, x-5, y+10);
+ graphics.drawString(width + "%", x + width+3, y + 10);
+ graphics.setColor((Color)def[i]);
+ graphics.fill(new Rectangle(x, y, width, 10));
+ y += 15;
+ }
+ graphics.setColor(Color.black);
+ graphics.setFont(new Font("Arial", Font.BOLD, 14));
+ graphics.draw(group.getCoordinates());
+ graphics.drawString("Performance", x + 30, y + 10);
+
+ FileOutputStream out = new FileOutputStream("hslf-graphics.ppt");
+ ppt.write(out);
+ out.close();
+ }
+
+}
--- /dev/null
+/* ====================================================================
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+==================================================================== */
+package org.apache.poi.hslf.examples;
+
+import org.apache.poi.hslf.usermodel.SlideShow;
+import org.apache.poi.hslf.model.HeadersFooters;
+import org.apache.poi.hslf.model.Slide;
+
+import java.io.FileOutputStream;
+
+/**
+ * Demonstrates how to set headers / footers
+ *
+ * @author Yegor Kozlov
+ */
+public class HeadersFootersDemo {
+ public static void main(String[] args) throws Exception {
+ SlideShow ppt = new SlideShow();
+
+ HeadersFooters slideHeaders = ppt.getSlideHeadersFooters();
+ slideHeaders.setFootersText("Created by POI-HSLF");
+ slideHeaders.setSlideNumberVisible(true);
+ slideHeaders.setDateTimeText("custom date time");
+
+ HeadersFooters notesHeaders = ppt.getNotesHeadersFooters();
+ notesHeaders.setFootersText("My notes footers");
+ notesHeaders.setHeaderText("My notes header");
+
+ Slide slide = ppt.createSlide();
+
+ FileOutputStream out = new FileOutputStream("headers_footers.ppt");
+ ppt.write(out);
+ out.close();
+
+ }
+
+}
--- /dev/null
+/* ====================================================================
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+==================================================================== */
+
+package org.apache.poi.hslf.examples;
+
+import org.apache.poi.hslf.usermodel.SlideShow;
+import org.apache.poi.hslf.model.Slide;
+import org.apache.poi.hslf.model.TextRun;
+import org.apache.poi.hslf.model.Hyperlink;
+import org.apache.poi.hslf.model.Shape;
+
+import java.io.FileInputStream;
+
+/**
+ * Demonstrates how to read hyperlinks from a presentation
+ *
+ * @author Yegor Kozlov
+ */
+public final class Hyperlinks {
+
+ public static void main(String[] args) throws Exception {
+ for (int i = 0; i < args.length; i++) {
+ FileInputStream is = new FileInputStream(args[i]);
+ SlideShow ppt = new SlideShow(is);
+ is.close();
+
+ Slide[] slide = ppt.getSlides();
+ for (int j = 0; j < slide.length; j++) {
+ System.out.println("slide " + slide[j].getSlideNumber());
+
+ //read hyperlinks from the slide's text runs
+ System.out.println("reading hyperlinks from the text runs");
+ TextRun[] txt = slide[j].getTextRuns();
+ for (int k = 0; k < txt.length; k++) {
+ String text = txt[k].getText();
+ Hyperlink[] links = txt[k].getHyperlinks();
+ if(links != null) for (int l = 0; l < links.length; l++) {
+ Hyperlink link = links[l];
+ String title = link.getTitle();
+ String address = link.getAddress();
+ System.out.println(" " + title);
+ System.out.println(" " + address);
+ String substring = text.substring(link.getStartIndex(), link.getEndIndex()-1);//in ppt end index is inclusive
+ System.out.println(" " + substring);
+ }
+ }
+
+ //in PowerPoint you can assign a hyperlink to a shape without text,
+ //for example to a Line object. The code below demonstrates how to
+ //read such hyperlinks
+ System.out.println(" reading hyperlinks from the slide's shapes");
+ Shape[] sh = slide[j].getShapes();
+ for (int k = 0; k < sh.length; k++) {
+ Hyperlink link = sh[k].getHyperlink();
+ if(link != null) {
+ String title = link.getTitle();
+ String address = link.getAddress();
+ System.out.println(" " + title);
+ System.out.println(" " + address);
+ }
+ }
+ }
+
+ }
+
+ }
+}
--- /dev/null
+/* ====================================================================
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+==================================================================== */
+
+package org.apache.poi.hslf.examples;
+
+import org.apache.poi.hslf.usermodel.*;
+import org.apache.poi.hslf.model.*;
+import org.apache.poi.hslf.record.TextHeaderAtom;
+
+import javax.imageio.ImageIO;
+import java.io.IOException;
+import java.io.FileOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.awt.*;
+import java.awt.image.BufferedImage;
+import java.awt.geom.AffineTransform;
+import java.awt.geom.Rectangle2D;
+
+/**
+ * Demonstrates how you can use HSLF to convert each slide into a PNG image
+ *
+ * @author Yegor Kozlov
+ */
+public final class PPT2PNG {
+
+ public static void main(String args[]) throws Exception {
+
+ if (args.length == 0) {
+ usage();
+ return;
+ }
+
+ int slidenum = -1;
+ float scale = 1;
+ String file = null;
+
+ for (int i = 0; i < args.length; i++) {
+ if (args[i].startsWith("-")) {
+ if ("-scale".equals(args[i])){
+ scale = Float.parseFloat(args[++i]);
+ } else if ("-slide".equals(args[i])) {
+ slidenum = Integer.parseInt(args[++i]);
+ }
+ } else {
+ file = args[i];
+ }
+ }
+ if(file == null){
+ usage();
+ return;
+ }
+
+ FileInputStream is = new FileInputStream(file);
+ SlideShow ppt = new SlideShow(is);
+ is.close();
+
+ Dimension pgsize = ppt.getPageSize();
+ int width = (int)(pgsize.width*scale);
+ int height = (int)(pgsize.height*scale);
+
+ Slide[] slide = ppt.getSlides();
+ for (int i = 0; i < slide.length; i++) {
+ if (slidenum != -1 && slidenum != (i+1)) continue;
+
+ String title = slide[i].getTitle();
+ System.out.println("Rendering slide "+slide[i].getSlideNumber() + (title == null ? "" : ": " + title));
+
+ BufferedImage img = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
+ Graphics2D graphics = img.createGraphics();
+ graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
+ graphics.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
+ graphics.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC);
+ graphics.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON);
+
+ graphics.setPaint(Color.white);
+ graphics.fill(new Rectangle2D.Float(0, 0, width, height));
+
+ graphics.scale((double)width/pgsize.width, (double)height/pgsize.height);
+
+ slide[i].draw(graphics);
+
+ String fname = file.replaceAll("\\.ppt", "-" + (i+1) + ".png");
+ FileOutputStream out = new FileOutputStream(fname);
+ ImageIO.write(img, "png", out);
+ out.close();
+ }
+ }
+
+ private static void usage(){
+ System.out.println("Usage: PPT2PNG [-scale <scale> -slide <num>] ppt");
+ }
+}
--- /dev/null
+/* ====================================================================
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+==================================================================== */
+package org.apache.poi.hslf.examples;
+import org.apache.poi.ddf.*;
+import org.apache.poi.hslf.model.*;
+import org.apache.poi.hslf.record.InteractiveInfo;
+import org.apache.poi.hslf.record.InteractiveInfoAtom;
+import org.apache.poi.hslf.record.Record;
+import org.apache.poi.hslf.usermodel.*;
+import java.io.FileInputStream;
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * For each slide iterate over shapes and found associated sound data.
+ *
+ * @author Yegor Kozlov
+ */
+public class SoundFinder {
+ public static void main(String[] args) throws Exception {
+ SlideShow ppt = new SlideShow(new FileInputStream(args[0]));
+ SoundData[] sounds = ppt.getSoundData();
+
+ Slide[] slide = ppt.getSlides();
+ for (int i = 0; i < slide.length; i++) {
+ Shape[] shape = slide[i].getShapes();
+ for (int j = 0; j < shape.length; j++) {
+ int soundRef = getSoundReference(shape[j]);
+ if(soundRef != -1) {
+ System.out.println("Slide["+i+"], shape["+j+"], soundRef: "+soundRef);
+ System.out.println(" " + sounds[soundRef].getSoundName());
+ System.out.println(" " + sounds[soundRef].getSoundType());
+ }
+ }
+ }
+ }
+
+ /**
+ * Check if a given shape is associated with a sound.
+ * @return 0-based reference to a sound in the sound collection
+ * or -1 if the shape is not associated with a sound
+ */
+ protected static int getSoundReference(Shape shape){
+ int soundRef = -1;
+ //dive into the shape container and search for InteractiveInfoAtom
+ EscherContainerRecord spContainer = shape.getSpContainer();
+ List spchild = spContainer.getChildRecords();
+ for (Iterator it = spchild.iterator(); it.hasNext();) {
+ EscherRecord obj = (EscherRecord) it.next();
+ if (obj.getRecordId() == EscherClientDataRecord.RECORD_ID) {
+ byte[] data = obj.serialize();
+ Record[] records = Record.findChildRecords(data, 8,
+data.length - 8);
+ for (int j = 0; j < records.length; j++) {
+ if (records[j] instanceof InteractiveInfo) {
+ InteractiveInfoAtom info = ((InteractiveInfo)records[j]).getInteractiveInfoAtom();
+ if (info.getAction() == InteractiveInfoAtom.ACTION_MEDIA) {
+ soundRef = info.getSoundRef();
+ }
+ }
+ }
+ }
+ }
+ return soundRef;
+ }
+}
--- /dev/null
+/* ====================================================================
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+==================================================================== */
+
+package org.apache.poi.hslf.examples;
+
+import org.apache.poi.hslf.usermodel.SlideShow;
+import org.apache.poi.hslf.usermodel.RichTextRun;
+import org.apache.poi.hslf.model.*;
+
+import java.awt.*;
+import java.io.FileOutputStream;
+
+/**
+ * Demonstrates how to create tables
+ *
+ * @author Yegor Kozlov
+ */
+public final class TableDemo {
+
+ public static void main(String[] args) throws Exception {
+
+ //test data for the first taable
+ String[][] txt1 = {
+ {"INPUT FILE", "NUMBER OF RECORDS"},
+ {"Item File", "11,559"},
+ {"Vendor File", "502"},
+ {"Purchase History File - # of PO\u2019s\r(12/01/04 - 05/31/06)", "12,852"},
+ {"Purchase History File - # of PO Lines\r(12/01/04 - 05/31/06)", "53,523" },
+ {"Total PO History Spend", "$10,172,038"}
+ };
+
+ SlideShow ppt = new SlideShow();
+
+ Slide slide = ppt.createSlide();
+
+ //six rows, two columns
+ Table table1 = new Table(6, 2);
+ for (int i = 0; i < txt1.length; i++) {
+ for (int j = 0; j < txt1[i].length; j++) {
+ TableCell cell = table1.getCell(i, j);
+ cell.setText(txt1[i][j]);
+ RichTextRun rt = cell.getTextRun().getRichTextRuns()[0];
+ rt.setFontName("Arial");
+ rt.setFontSize(10);
+ if(i == 0){
+ cell.getFill().setForegroundColor(new Color(227, 227, 227));
+ } else {
+ rt.setBold(true);
+ }
+ cell.setVerticalAlignment(TextBox.AnchorMiddle);
+ cell.setHorizontalAlignment(TextBox.AlignCenter);
+ }
+ }
+
+ Line border1 = table1.createBorder();
+ border1.setLineColor(Color.black);
+ border1.setLineWidth(1.0);
+ table1.setAllBorders(border1);
+
+ table1.setColumnWidth(0, 300);
+ table1.setColumnWidth(1, 150);
+
+ slide.addShape(table1);
+ int pgWidth = ppt.getPageSize().width;
+ table1.moveTo((pgWidth - table1.getAnchor().width)/2, 100);
+
+ //test data for the second taable
+ String[][] txt2 = {
+ {"Data Source"},
+ {"CAS Internal Metrics - Item Master Summary\r" +
+ "CAS Internal Metrics - Vendor Summary\r" +
+ "CAS Internal Metrics - PO History Summary"}
+ };
+
+ //two rows, one column
+ Table table2 = new Table(2, 1);
+ for (int i = 0; i < txt2.length; i++) {
+ for (int j = 0; j < txt2[i].length; j++) {
+ TableCell cell = table2.getCell(i, j);
+ cell.setText(txt2[i][j]);
+ RichTextRun rt = cell.getTextRun().getRichTextRuns()[0];
+ rt.setFontSize(10);
+ rt.setFontName("Arial");
+ if(i == 0){
+ cell.getFill().setForegroundColor(new Color(0, 51, 102));
+ rt.setFontColor(Color.white);
+ rt.setBold(true);
+ rt.setFontSize(14);
+ cell.setHorizontalAlignment(TextBox.AlignCenter);
+ } else {
+ rt.setBullet(true);
+ rt.setFontSize(12);
+ cell.setHorizontalAlignment(TextBox.AlignLeft);
+ }
+ cell.setVerticalAlignment(TextBox.AnchorMiddle);
+ }
+ }
+ table2.setColumnWidth(0, 300);
+ table2.setRowHeight(0, 30);
+ table2.setRowHeight(1, 70);
+
+ Line border2 = table2.createBorder();
+ table2.setOutsideBorders(border2);
+
+ slide.addShape(table2);
+ table2.moveTo(200, 400);
+
+ FileOutputStream out = new FileOutputStream("hslf-table.ppt");
+ ppt.write(out);
+ out.close();
+
+ }
+}
--- /dev/null
+/* ====================================================================
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+==================================================================== */
+
+package org.apache.poi.hsmf.examples;
+
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.PrintWriter;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.apache.poi.hsmf.MAPIMessage;
+import org.apache.poi.hsmf.exceptions.ChunkNotFoundException;
+
+/**
+ * Reads one or several Outlook MSG files and for each of them creates
+ * a text file from available chunks and a directory that contains
+ * attachments.
+ *
+ * @author Bruno Girin
+ *
+ */
+public class Msg2txt {
+
+ /**
+ * The stem used to create file names for the text file and the directory
+ * that contains the attachments.
+ */
+ private String fileNameStem;
+
+ /**
+ * The Outlook MSG file being processed.
+ */
+ private MAPIMessage msg;
+
+ public Msg2txt(String fileName) throws IOException {
+ fileNameStem = fileName;
+ if(fileNameStem.endsWith(".msg") || fileNameStem.endsWith(".MSG")) {
+ fileNameStem = fileNameStem.substring(0, fileNameStem.length() - 4);
+ }
+ msg = new MAPIMessage(fileName);
+ }
+
+ /**
+ * Processes the message.
+ *
+ * @throws IOException if an exception occurs while writing the message out
+ */
+ public void processMessage() throws IOException {
+ String txtFileName = fileNameStem + ".txt";
+ String attDirName = fileNameStem + "-att";
+ PrintWriter txtOut = null;
+ try {
+ txtOut = new PrintWriter(txtFileName);
+ try {
+ String displayFrom = msg.getDisplayFrom();
+ txtOut.println("From: "+displayFrom);
+ } catch (ChunkNotFoundException e) {
+ // ignore
+ }
+ try {
+ String displayTo = msg.getDisplayTo();
+ txtOut.println("To: "+displayTo);
+ } catch (ChunkNotFoundException e) {
+ // ignore
+ }
+ try {
+ String displayCC = msg.getDisplayCC();
+ txtOut.println("CC: "+displayCC);
+ } catch (ChunkNotFoundException e) {
+ // ignore
+ }
+ try {
+ String displayBCC = msg.getDisplayBCC();
+ txtOut.println("BCC: "+displayBCC);
+ } catch (ChunkNotFoundException e) {
+ // ignore
+ }
+ try {
+ String subject = msg.getSubject();
+ txtOut.println("Subject: "+subject);
+ } catch (ChunkNotFoundException e) {
+ // ignore
+ }
+ try {
+ String body = msg.getTextBody();
+ txtOut.println(body);
+ } catch (ChunkNotFoundException e) {
+ System.err.println("No message body");
+ }
+ Map attachmentMap = msg.getAttachmentFiles();
+ if(attachmentMap.size() > 0) {
+ File d = new File(attDirName);
+ if(d.mkdir()) {
+ for(
+ Iterator ii = attachmentMap.entrySet().iterator();
+ ii.hasNext();
+ ) {
+ Map.Entry entry = (Map.Entry)ii.next();
+ processAttachment(d, entry.getKey().toString(),
+ (ByteArrayInputStream)entry.getValue());
+ }
+ } else {
+ System.err.println("Can't create directory "+attDirName);
+ }
+ }
+ } finally {
+ if(txtOut != null) {
+ txtOut.close();
+ }
+ }
+ }
+
+ /**
+ * Processes a single attachment: reads it from the Outlook MSG file and
+ * writes it to disk as an individual file.
+ *
+ * @param dir the directory in which to write the attachment file
+ * @param fileName the name of the attachment file
+ * @param fileIn the input stream that contains the attachment's data
+ * @throws IOException when any of the file operations fails
+ */
+ public void processAttachment(File dir, String fileName,
+ ByteArrayInputStream fileIn) throws IOException {
+ File f = new File(dir, fileName);
+ OutputStream fileOut = null;
+ try {
+ fileOut = new FileOutputStream(f);
+ byte[] buffer = new byte[2048];
+ int bNum = fileIn.read(buffer);
+ while(bNum > 0) {
+ fileOut.write(buffer);
+ bNum = fileIn.read(buffer);
+ }
+ } finally {
+ try {
+ if(fileIn != null) {
+ fileIn.close();
+ }
+ } finally {
+ if(fileOut != null) {
+ fileOut.close();
+ }
+ }
+ }
+ }
+
+ /**
+ * Processes the list of arguments as a list of names of Outlook MSG files.
+ *
+ * @param args the list of MSG files to process
+ */
+ public static void main(String[] args) {
+ if(args.length <= 0) {
+ System.err.println("No files names provided");
+ } else {
+ for(int i = 0; i < args.length; i++) {
+ try {
+ Msg2txt processor = new Msg2txt(args[i]);
+ processor.processMessage();
+ } catch (IOException e) {
+ System.err.println("Could not process "+args[i]+": "+e);
+ }
+ }
+ }
+ }
+
+}
--- /dev/null
+/* ====================================================================
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+==================================================================== */
+
+package org.apache.poi.hwpf;
+
+import org.apache.poi.hwpf.HWPFDocument;
+import org.apache.poi.hwpf.usermodel.*;
+import org.apache.poi.hwpf.model.*;
+
+import java.io.*;
+
+public final class Word2Forrest
+{
+ Writer _out;
+ HWPFDocument _doc;
+
+ public Word2Forrest(HWPFDocument doc, OutputStream stream)
+ throws IOException, UnsupportedEncodingException
+ {
+ OutputStreamWriter out = new OutputStreamWriter (stream, "UTF-8");
+ _out = out;
+ _doc = doc;
+
+ init ();
+ openDocument ();
+ openBody ();
+
+ Range r = doc.getRange ();
+ StyleSheet styleSheet = doc.getStyleSheet ();
+
+ int sectionLevel = 0;
+ int lenParagraph = r.numParagraphs ();
+ boolean inCode = false;
+ for (int x = 0; x < lenParagraph; x++)
+ {
+ Paragraph p = r.getParagraph (x);
+ String text = p.text ();
+ if (text.trim ().length () == 0)
+ {
+ continue;
+ }
+ StyleDescription paragraphStyle = styleSheet.getStyleDescription (p.
+ getStyleIndex ());
+ String styleName = paragraphStyle.getName();
+ if (styleName.startsWith ("Heading"))
+ {
+ if (inCode)
+ {
+ closeSource();
+ inCode = false;
+ }
+
+ int headerLevel = Integer.parseInt (styleName.substring (8));
+ if (headerLevel > sectionLevel)
+ {
+ openSection ();
+ }
+ else
+ {
+ for (int y = 0; y < (sectionLevel - headerLevel) + 1; y++)
+ {
+ closeSection ();
+ }
+ openSection ();
+ }
+ sectionLevel = headerLevel;
+ openTitle ();
+ writePlainText (text);
+ closeTitle ();
+ }
+ else
+ {
+ int cruns = p.numCharacterRuns ();
+ CharacterRun run = p.getCharacterRun (0);
+ String fontName = run.getFontName();
+ if (fontName.startsWith ("Courier"))
+ {
+ if (!inCode)
+ {
+ openSource ();
+ inCode = true;
+ }
+ writePlainText (p.text());
+ }
+ else
+ {
+ if (inCode)
+ {
+ inCode = false;
+ closeSource();
+ }
+ openParagraph();
+ writePlainText(p.text());
+ closeParagraph();
+ }
+ }
+ }
+ for (int x = 0; x < sectionLevel; x++)
+ {
+ closeSection();
+ }
+ closeBody();
+ closeDocument();
+ _out.flush();
+
+ }
+
+ public void init ()
+ throws IOException
+ {
+ _out.write ("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n");
+ _out.write ("<!DOCTYPE document PUBLIC \"-//APACHE//DTD Documentation V1.1//EN\" \"./dtd/document-v11.dtd\">\r\n");
+ }
+
+ public void openDocument ()
+ throws IOException
+ {
+ _out.write ("<document>\r\n");
+ }
+ public void closeDocument ()
+ throws IOException
+ {
+ _out.write ("</document>\r\n");
+ }
+
+
+ public void openBody ()
+ throws IOException
+ {
+ _out.write ("<body>\r\n");
+ }
+
+ public void closeBody ()
+ throws IOException
+ {
+ _out.write ("</body>\r\n");
+ }
+
+
+ public void openSection ()
+ throws IOException
+ {
+ _out.write ("<section>");
+
+ }
+
+ public void closeSection ()
+ throws IOException
+ {
+ _out.write ("</section>");
+
+ }
+
+ public void openTitle ()
+ throws IOException
+ {
+ _out.write ("<title>");
+ }
+
+ public void closeTitle ()
+ throws IOException
+ {
+ _out.write ("</title>");
+ }
+
+ public void writePlainText (String text)
+ throws IOException
+ {
+ _out.write (text);
+ }
+
+ public void openParagraph ()
+ throws IOException
+ {
+ _out.write ("<p>");
+ }
+
+ public void closeParagraph ()
+ throws IOException
+ {
+ _out.write ("</p>");
+ }
+
+ public void openSource ()
+ throws IOException
+ {
+ _out.write ("<source><![CDATA[");
+ }
+ public void closeSource ()
+ throws IOException
+ {
+ _out.write ("]]></source>");
+ }
+
+
+ public static void main(String[] args)
+ {
+ try
+ {
+ OutputStream out = new FileOutputStream("c:\\test.xml");
+
+ new Word2Forrest(new HWPFDocument(new FileInputStream(args[0])), out);
+ out.close();
+ }
+ catch (Throwable t)
+ {
+ t.printStackTrace();
+ }
+
+ }
+}
List<String> lst = new ArrayList<String>();
//collect unit tests
- System.out.println("Collecting unit tests");
+ System.out.println("Collecting unit tests from " + _testDir);
collectTests(_testDir, _testDir, lst, ".+?\\.Test.+?\\.class$");
TestSuite suite = new TestSuite();
}
//run tests
- System.out.println("Running tests");
TestRunner.run(suite);
//see what classes from the ooxml-schemas.jar are loaded
- System.out.println("Copying classes");
+ System.out.println("Copying classes to " + _destDest);
Map<String, Class<?>> classes = getLoadedClasses(_ooxmlJar.getName());
for (Class<?> cls : classes.values()) {
String className = cls.getName();
import org.apache.poi.hdgf.extractor.VisioTextExtractor;
import org.apache.poi.hslf.extractor.PowerPointExtractor;
import org.apache.poi.hssf.extractor.ExcelExtractor;
-import org.apache.poi.hssf.HSSFTestDataSamples;
import org.apache.poi.hwpf.extractor.WordExtractor;
-import org.apache.poi.hwpf.HWPFTestDataSamples;
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
import org.apache.poi.xslf.extractor.XSLFPowerPointExtractor;
import org.apache.poi.xssf.extractor.XSSFExcelExtractor;
package org.apache.poi.xwpf;\r
\r
import org.apache.poi.xwpf.usermodel.XWPFDocument;\r
-import org.apache.poi.hwpf.HWPFTestDataSamples;\r
import org.apache.poi.POIDataSamples;\r
\r
import java.io.*;\r
+++ /dev/null
-/* ====================================================================
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-==================================================================== */
-
-package org.apache.poi.hslf.examples;
-
-import org.apache.poi.hslf.usermodel.*;
-import org.apache.poi.hslf.model.*;
-import org.apache.poi.hslf.record.TextHeaderAtom;
-
-import java.io.IOException;
-import java.io.FileOutputStream;
-import java.io.File;
-import java.awt.*;
-
-/**
- * Presentation for Fast Feather Track on ApacheconEU 2008
- *
- * @author Yegor Kozlov
- */
-public final class ApacheconEU08 {
-
- public static void main(String[] args) throws IOException {
- SlideShow ppt = new SlideShow();
- ppt.setPageSize(new Dimension(720, 540));
-
- slide1(ppt);
- slide2(ppt);
- slide3(ppt);
- slide4(ppt);
- slide5(ppt);
- slide6(ppt);
- slide7(ppt);
- slide8(ppt);
- slide9(ppt);
- slide10(ppt);
- slide11(ppt);
- slide12(ppt);
-
- FileOutputStream out = new FileOutputStream("apachecon_eu_08.ppt");
- ppt.write(out);
- out.close();
-
- }
-
- public static void slide1(SlideShow ppt) throws IOException {
- Slide slide = ppt.createSlide();
-
- TextBox box1 = new TextBox();
- TextRun tr1 = box1.getTextRun();
- tr1.setRunType(TextHeaderAtom.CENTER_TITLE_TYPE);
- tr1.setText("POI-HSLF");
- box1.setAnchor(new Rectangle(54, 78, 612, 115));
- slide.addShape(box1);
-
- TextBox box2 = new TextBox();
- TextRun tr2 = box2.getTextRun();
- tr2.setRunType(TextHeaderAtom.CENTRE_BODY_TYPE);
- tr2.setText("Java API To Access Microsoft PowerPoint Format Files");
- box2.setAnchor(new Rectangle(108, 204, 504, 138));
- slide.addShape(box2);
-
- TextBox box3 = new TextBox();
- TextRun tr3 = box3.getTextRun();
- tr3.getRichTextRuns()[0].setFontSize(32);
- box3.setHorizontalAlignment(TextBox.AlignCenter);
- tr3.setText(
- "Yegor Kozlov\r" +
- "yegor - apache - org");
- box3.setAnchor(new Rectangle(206, 348, 310, 84));
- slide.addShape(box3);
- }
-
- public static void slide2(SlideShow ppt) throws IOException {
- Slide slide = ppt.createSlide();
-
- TextBox box1 = new TextBox();
- TextRun tr1 = box1.getTextRun();
- tr1.setRunType(TextHeaderAtom.TITLE_TYPE);
- tr1.setText("What is HSLF?");
- box1.setAnchor(new Rectangle(36, 21, 648, 90));
- slide.addShape(box1);
-
- TextBox box2 = new TextBox();
- TextRun tr2 = box2.getTextRun();
- tr2.setRunType(TextHeaderAtom.BODY_TYPE);
- tr2.setText("HorribleSLideshowFormat is the POI Project's pure Java implementation " +
- "of the Powerpoint binary file format. \r" +
- "POI sub-project since 2005\r" +
- "Started by Nick Birch, Yegor Kozlov joined soon after");
- box2.setAnchor(new Rectangle(36, 126, 648, 356));
- slide.addShape(box2);
-
-
- }
-
- public static void slide3(SlideShow ppt) throws IOException {
- Slide slide = ppt.createSlide();
-
- TextBox box1 = new TextBox();
- TextRun tr1 = box1.getTextRun();
- tr1.setRunType(TextHeaderAtom.TITLE_TYPE);
- tr1.setText("HSLF in a Nutshell");
- box1.setAnchor(new Rectangle(36, 15, 648, 65));
- slide.addShape(box1);
-
- TextBox box2 = new TextBox();
- TextRun tr2 = box2.getTextRun();
- tr2.setRunType(TextHeaderAtom.BODY_TYPE);
- tr2.setText(
- "HSLF provides a way to read, create and modify MS PowerPoint presentations\r" +
- "Pure Java API - you don't need PowerPoint to read and write *.ppt files\r" +
- "Comprehensive support of PowerPoint objects");
- tr2.getRichTextRuns()[0].setFontSize(28);
- box2.setAnchor(new Rectangle(36, 80, 648, 200));
- slide.addShape(box2);
-
- TextBox box3 = new TextBox();
- TextRun tr3 = box3.getTextRun();
- tr3.setRunType(TextHeaderAtom.BODY_TYPE);
- tr3.setText(
- "Rich text\r" +
- "Tables\r" +
- "Shapes\r" +
- "Pictures\r" +
- "Master slides");
- tr3.getRichTextRuns()[0].setFontSize(24);
- tr3.getRichTextRuns()[0].setIndentLevel(1);
- box3.setAnchor(new Rectangle(36, 265, 648, 150));
- slide.addShape(box3);
-
- TextBox box4 = new TextBox();
- TextRun tr4 = box4.getTextRun();
- tr4.setRunType(TextHeaderAtom.BODY_TYPE);
- tr4.setText("Access to low level data structures");
- box4.setAnchor(new Rectangle(36, 430, 648, 50));
- slide.addShape(box4);
- }
-
- public static void slide4(SlideShow ppt) throws IOException {
- Slide slide = ppt.createSlide();
-
- String[][] txt1 = {
- {"Note"},
- {"This presentation was created programmatically using POI HSLF"}
- };
- Table table1 = new Table(2, 1);
- for (int i = 0; i < txt1.length; i++) {
- for (int j = 0; j < txt1[i].length; j++) {
- TableCell cell = table1.getCell(i, j);
- cell.setText(txt1[i][j]);
- cell.getTextRun().getRichTextRuns()[0].setFontSize(10);
- RichTextRun rt = cell.getTextRun().getRichTextRuns()[0];
- rt.setFontName("Arial");
- rt.setBold(true);
- if(i == 0){
- rt.setFontSize(32);
- rt.setFontColor(Color.white);
- cell.getFill().setForegroundColor(new Color(0, 153, 204));
- } else {
- rt.setFontSize(28);
- cell.getFill().setForegroundColor(new Color(235, 239, 241));
- }
- cell.setVerticalAlignment(TextBox.AnchorMiddle);
- }
- }
-
- Line border1 = table1.createBorder();
- border1.setLineColor(Color.black);
- border1.setLineWidth(1.0);
- table1.setAllBorders(border1);
-
- Line border2 = table1.createBorder();
- border2.setLineColor(Color.black);
- border2.setLineWidth(2.0);
- table1.setOutsideBorders(border2);
-
- table1.setColumnWidth(0, 510);
- table1.setRowHeight(0, 60);
- table1.setRowHeight(1, 100);
- slide.addShape(table1);
-
- table1.moveTo(100, 100);
-
- TextBox box1 = new TextBox();
- box1.setHorizontalAlignment(TextBox.AlignCenter);
- TextRun tr1 = box1.getTextRun();
- tr1.setText("The source code is available at\r" +
- "http://people.apache.org/~yegor/apachecon_eu08/");
- RichTextRun rt = tr1.getRichTextRuns()[0];
- rt.setFontSize(24);
- box1.setAnchor(new Rectangle(80, 356, 553, 65));
- slide.addShape(box1);
-
- }
-
- public static void slide5(SlideShow ppt) throws IOException {
- Slide slide = ppt.createSlide();
-
- TextBox box1 = new TextBox();
- TextRun tr1 = box1.getTextRun();
- tr1.setRunType(TextHeaderAtom.TITLE_TYPE);
- tr1.setText("HSLF in Action - 1\rData Extraction");
- box1.setAnchor(new Rectangle(36, 21, 648, 100));
- slide.addShape(box1);
-
- TextBox box2 = new TextBox();
- TextRun tr2 = box2.getTextRun();
- tr2.setRunType(TextHeaderAtom.BODY_TYPE);
- tr2.setText(
- "Text from slides and notes\r" +
- "Images\r" +
- "Shapes and their properties (type, position in the slide, color, font, etc.)");
- box2.setAnchor(new Rectangle(36, 150, 648, 300));
- slide.addShape(box2);
-
-
- }
-
- public static void slide6(SlideShow ppt) throws IOException {
- Slide slide = ppt.createSlide();
-
- TextBox box1 = new TextBox();
- TextRun tr1 = box1.getTextRun();
- tr1.setRunType(TextHeaderAtom.TITLE_TYPE);
- tr1.setText("HSLF in Action - 2");
- box1.setAnchor(new Rectangle(36, 20, 648, 90));
- slide.addShape(box1);
-
- TextBox box2 = new TextBox();
- TextRun tr2 = box2.getTextRun();
- tr2.getRichTextRuns()[0].setFontSize(18);
- tr2.setText("Creating a simple presentation from scratch");
- box2.setAnchor(new Rectangle(170, 100, 364, 30));
- slide.addShape(box2);
-
- TextBox box3 = new TextBox();
- TextRun tr3 = box3.getTextRun();
- RichTextRun rt3 = tr3.getRichTextRuns()[0];
- rt3.setFontName("Courier New");
- rt3.setFontSize(8);
- tr3.setText(
- " SlideShow ppt = new SlideShow();\r" +
- " Slide slide = ppt.createSlide();\r" +
- "\r" +
- " TextBox box2 = new TextBox();\r" +
- " box2.setHorizontalAlignment(TextBox.AlignCenter);\r" +
- " box2.setVerticalAlignment(TextBox.AnchorMiddle);\r" +
- " box2.getTextRun().setText(\"Java Code\");\r" +
- " box2.getFill().setForegroundColor(new Color(187, 224, 227));\r" +
- " box2.setLineColor(Color.black);\r" +
- " box2.setLineWidth(0.75);\r" +
- " box2.setAnchor(new Rectangle(66, 243, 170, 170));\r" +
- " slide.addShape(box2);\r" +
- "\r" +
- " TextBox box3 = new TextBox();\r" +
- " box3.setHorizontalAlignment(TextBox.AlignCenter);\r" +
- " box3.setVerticalAlignment(TextBox.AnchorMiddle);\r" +
- " box3.getTextRun().setText(\"*.ppt file\");\r" +
- " box3.setLineWidth(0.75);\r" +
- " box3.setLineColor(Color.black);\r" +
- " box3.getFill().setForegroundColor(new Color(187, 224, 227));\r" +
- " box3.setAnchor(new Rectangle(473, 243, 170, 170));\r" +
- " slide.addShape(box3);\r" +
- "\r" +
- " AutoShape box4 = new AutoShape(ShapeTypes.Arrow);\r" +
- " box4.getFill().setForegroundColor(new Color(187, 224, 227));\r" +
- " box4.setLineWidth(0.75);\r" +
- " box4.setLineColor(Color.black);\r" +
- " box4.setAnchor(new Rectangle(253, 288, 198, 85));\r" +
- " slide.addShape(box4);\r" +
- "\r" +
- " FileOutputStream out = new FileOutputStream(\"hslf-demo.ppt\");\r" +
- " ppt.write(out);\r" +
- " out.close();");
- box3.setAnchor(new Rectangle(30, 150, 618, 411));
- slide.addShape(box3);
- }
-
- public static void slide7(SlideShow ppt) throws IOException {
- Slide slide = ppt.createSlide();
-
- TextBox box2 = new TextBox();
- box2.setHorizontalAlignment(TextBox.AlignCenter);
- box2.setVerticalAlignment(TextBox.AnchorMiddle);
- box2.getTextRun().setText("Java Code");
- box2.getFill().setForegroundColor(new Color(187, 224, 227));
- box2.setLineColor(Color.black);
- box2.setLineWidth(0.75);
- box2.setAnchor(new Rectangle(66, 243, 170, 170));
- slide.addShape(box2);
-
- TextBox box3 = new TextBox();
- box3.setHorizontalAlignment(TextBox.AlignCenter);
- box3.setVerticalAlignment(TextBox.AnchorMiddle);
- box3.getTextRun().setText("*.ppt file");
- box3.setLineWidth(0.75);
- box3.setLineColor(Color.black);
- box3.getFill().setForegroundColor(new Color(187, 224, 227));
- box3.setAnchor(new Rectangle(473, 243, 170, 170));
- slide.addShape(box3);
-
- AutoShape box4 = new AutoShape(ShapeTypes.Arrow);
- box4.getFill().setForegroundColor(new Color(187, 224, 227));
- box4.setLineWidth(0.75);
- box4.setLineColor(Color.black);
- box4.setAnchor(new Rectangle(253, 288, 198, 85));
- slide.addShape(box4);
- }
-
- public static void slide8(SlideShow ppt) throws IOException {
- Slide slide = ppt.createSlide();
-
- TextBox box1 = new TextBox();
- TextRun tr1 = box1.getTextRun();
- tr1.setRunType(TextHeaderAtom.TITLE_TYPE);
- tr1.setText("Wait, there is more!");
- box1.setAnchor(new Rectangle(36, 21, 648, 90));
- slide.addShape(box1);
-
- TextBox box2 = new TextBox();
- TextRun tr2 = box2.getTextRun();
- tr2.setRunType(TextHeaderAtom.BODY_TYPE);
- tr2.setText(
- "Rich text\r" +
- "Tables\r" +
- "Pictures (JPEG, PNG, BMP, WMF, PICT)\r" +
- "Comprehensive formatting features");
- box2.setAnchor(new Rectangle(36, 126, 648, 356));
- slide.addShape(box2);
- }
-
- public static void slide9(SlideShow ppt) throws IOException {
- Slide slide = ppt.createSlide();
-
- TextBox box1 = new TextBox();
- TextRun tr1 = box1.getTextRun();
- tr1.setRunType(TextHeaderAtom.TITLE_TYPE);
- tr1.setText("HSLF in Action - 3");
- box1.setAnchor(new Rectangle(36, 20, 648, 50));
- slide.addShape(box1);
-
- TextBox box2 = new TextBox();
- TextRun tr2 = box2.getTextRun();
- tr2.getRichTextRuns()[0].setFontSize(18);
- tr2.setText("PPGraphics2D: PowerPoint Graphics2D driver");
- box2.setAnchor(new Rectangle(178, 70, 387, 30));
- slide.addShape(box2);
-
- TextBox box3 = new TextBox();
- TextRun tr3 = box3.getTextRun();
- RichTextRun rt3 = tr3.getRichTextRuns()[0];
- rt3.setFontName("Courier New");
- rt3.setFontSize(8);
- tr3.setText(
- " //bar chart data. The first value is the bar color, the second is the width\r" +
- " Object[] def = new Object[]{\r" +
- " Color.yellow, new Integer(100),\r" +
- " Color.green, new Integer(150),\r" +
- " Color.gray, new Integer(75),\r" +
- " Color.red, new Integer(200),\r" +
- " };\r" +
- "\r" +
- " SlideShow ppt = new SlideShow();\r" +
- " Slide slide = ppt.createSlide();\r" +
- "\r" +
- " ShapeGroup group = new ShapeGroup();\r" +
- " //define position of the drawing in the slide\r" +
- " Rectangle bounds = new java.awt.Rectangle(200, 100, 350, 300);\r" +
- " group.setAnchor(bounds);\r" +
- " slide.addShape(group);\r" +
- " Graphics2D graphics = new PPGraphics2D(group);\r" +
- "\r" +
- " //draw a simple bar graph\r" +
- " int x = bounds.x + 50, y = bounds.y + 50;\r" +
- " graphics.setFont(new Font(\"Arial\", Font.BOLD, 10));\r" +
- " for (int i = 0, idx = 1; i < def.length; i+=2, idx++) {\r" +
- " graphics.setColor(Color.black);\r" +
- " int width = ((Integer)def[i+1]).intValue();\r" +
- " graphics.drawString(\"Q\" + idx, x-20, y+20);\r" +
- " graphics.drawString(width + \"%\", x + width + 10, y + 20);\r" +
- " graphics.setColor((Color)def[i]);\r" +
- " graphics.fill(new Rectangle(x, y, width, 30));\r" +
- " y += 40;\r" +
- " }\r" +
- " graphics.setColor(Color.black);\r" +
- " graphics.setFont(new Font(\"Arial\", Font.BOLD, 14));\r" +
- " graphics.draw(bounds);\r" +
- " graphics.drawString(\"Performance\", x + 70, y + 40);\r" +
- "\r" +
- " FileOutputStream out = new FileOutputStream(\"hslf-demo.ppt\");\r" +
- " ppt.write(out);\r" +
- " out.close();");
- box3.setAnchor(new Rectangle(96, 110, 499, 378));
- slide.addShape(box3);
- }
-
- public static void slide10(SlideShow ppt) throws IOException {
- //bar chart data. The first value is the bar color, the second is the width
- Object[] def = new Object[]{
- Color.yellow, new Integer(100),
- Color.green, new Integer(150),
- Color.gray, new Integer(75),
- Color.red, new Integer(200),
- };
-
- Slide slide = ppt.createSlide();
-
- ShapeGroup group = new ShapeGroup();
- //define position of the drawing in the slide
- Rectangle bounds = new java.awt.Rectangle(200, 100, 350, 300);
- group.setAnchor(bounds);
- slide.addShape(group);
- Graphics2D graphics = new PPGraphics2D(group);
-
- //draw a simple bar graph
- int x = bounds.x + 50, y = bounds.y + 50;
- graphics.setFont(new Font("Arial", Font.BOLD, 10));
- for (int i = 0, idx = 1; i < def.length; i+=2, idx++) {
- graphics.setColor(Color.black);
- int width = ((Integer)def[i+1]).intValue();
- graphics.drawString("Q" + idx, x-20, y+20);
- graphics.drawString(width + "%", x + width + 10, y + 20);
- graphics.setColor((Color)def[i]);
- graphics.fill(new Rectangle(x, y, width, 30));
- y += 40;
- }
- graphics.setColor(Color.black);
- graphics.setFont(new Font("Arial", Font.BOLD, 14));
- graphics.draw(bounds);
- graphics.drawString("Performance", x + 70, y + 40);
-
- }
-
- public static void slide11(SlideShow ppt) throws IOException {
- Slide slide = ppt.createSlide();
-
- TextBox box1 = new TextBox();
- TextRun tr1 = box1.getTextRun();
- tr1.setRunType(TextHeaderAtom.TITLE_TYPE);
- tr1.setText("HSLF Development Plans");
- box1.setAnchor(new Rectangle(36, 21, 648, 90));
- slide.addShape(box1);
-
- TextBox box2 = new TextBox();
- TextRun tr2 = box2.getTextRun();
- tr2.setRunType(TextHeaderAtom.BODY_TYPE);
- tr2.getRichTextRuns()[0].setFontSize(32);
- tr2.setText(
- "Support for more PowerPoint functionality\r" +
- "Rendering slides into java.awt.Graphics2D");
- box2.setAnchor(new Rectangle(36, 126, 648, 100));
- slide.addShape(box2);
-
- TextBox box3 = new TextBox();
- TextRun tr3 = box3.getTextRun();
- tr3.setRunType(TextHeaderAtom.BODY_TYPE);
- tr3.getRichTextRuns()[0].setIndentLevel(1);
- tr3.setText(
- "A way to export slides into images or other formats");
- box3.setAnchor(new Rectangle(36, 220, 648, 70));
- slide.addShape(box3);
-
- TextBox box4 = new TextBox();
- TextRun tr4 = box4.getTextRun();
- tr4.setRunType(TextHeaderAtom.BODY_TYPE);
- tr4.getRichTextRuns()[0].setFontSize(32);
- tr4.setText(
- "Integration with Apache FOP - Formatting Objects Processor");
- box4.setAnchor(new Rectangle(36, 290, 648, 90));
- slide.addShape(box4);
-
- TextBox box5 = new TextBox();
- TextRun tr5 = box5.getTextRun();
- tr5.setRunType(TextHeaderAtom.BODY_TYPE);
- tr5.getRichTextRuns()[0].setIndentLevel(1);
- tr5.setText(
- "Transformation of XSL-FO into PPT\r" +
- "PPT2PDF transcoder");
- box5.setAnchor(new Rectangle(36, 380, 648, 100));
- slide.addShape(box5);
- }
-
- public static void slide12(SlideShow ppt) throws IOException {
- Slide slide = ppt.createSlide();
-
- TextBox box1 = new TextBox();
- TextRun tr1 = box1.getTextRun();
- tr1.setRunType(TextHeaderAtom.CENTER_TITLE_TYPE);
- tr1.setText("Questions?");
- box1.setAnchor(new Rectangle(54, 167, 612, 115));
- slide.addShape(box1);
-
- TextBox box2 = new TextBox();
- TextRun tr2 = box2.getTextRun();
- tr2.setRunType(TextHeaderAtom.CENTRE_BODY_TYPE);
- tr2.setText(
- "http://poi.apache.org/hslf/\r" +
- "http://people.apache.org/~yegor");
- box2.setAnchor(new Rectangle(108, 306, 504, 138));
- slide.addShape(box2);
- }
-}
+++ /dev/null
-/* ====================================================================
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-==================================================================== */
-
-package org.apache.poi.hslf.examples;
-
-import org.apache.poi.hslf.usermodel.SlideShow;
-import org.apache.poi.hslf.usermodel.RichTextRun;
-import org.apache.poi.hslf.model.Slide;
-import org.apache.poi.hslf.model.TextBox;
-
-import java.io.FileOutputStream;
-
-/**
- * How to create a single-level bulleted list
- * and change some of the bullet attributes
- *
- * @author Yegor Kozlov
- */
-public final class BulletsDemo {
-
- public static void main(String[] args) throws Exception {
-
- SlideShow ppt = new SlideShow();
-
- Slide slide = ppt.createSlide();
-
- TextBox shape = new TextBox();
- RichTextRun rt = shape.getTextRun().getRichTextRuns()[0];
- shape.setText(
- "January\r" +
- "February\r" +
- "March\r" +
- "April");
- rt.setFontSize(42);
- rt.setBullet(true);
- rt.setBulletOffset(0); //bullet offset
- rt.setTextOffset(50); //text offset (should be greater than bullet offset)
- rt.setBulletChar('\u263A'); //bullet character
- slide.addShape(shape);
-
- shape.setAnchor(new java.awt.Rectangle(50, 50, 500, 300)); //position of the text box in the slide
- slide.addShape(shape);
-
- FileOutputStream out = new FileOutputStream("bullets.ppt");
- ppt.write(out);
- out.close();
- }
-}
+++ /dev/null
-/* ====================================================================
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-==================================================================== */
-
-package org.apache.poi.hslf.examples;
-
-import org.apache.poi.hslf.usermodel.SlideShow;
-import org.apache.poi.hslf.usermodel.RichTextRun;
-import org.apache.poi.hslf.model.*;
-
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.awt.*;
-
-/**
- * Demonstrates how to create hyperlinks in PowerPoint presentations
- *
- * @author Yegor Kozlov
- */
-public final class CreateHyperlink {
-
- public static void main(String[] args) throws Exception {
- SlideShow ppt = new SlideShow();
-
- Slide slide = ppt.createSlide();
-
- TextBox shape = new TextBox();
- shape.setText("Apache POI");
- Rectangle anchor = new Rectangle(100, 100, 200, 50);
- shape.setAnchor(anchor);
-
- String text = shape.getText();
- Hyperlink link = new Hyperlink();
- link.setAddress("http://www.apache.org");
- link.setTitle(shape.getText());
- int linkId = ppt.addHyperlink(link);
-
- shape.setHyperlink(linkId, 0, text.length());
-
- slide.addShape(shape);
-
- FileOutputStream out = new FileOutputStream("hyperlink.ppt");
- ppt.write(out);
- out.close();
-
- }
-}
+++ /dev/null
-/* ====================================================================
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-==================================================================== */
-
-package org.apache.poi.hslf.examples;
-
-import org.apache.poi.hslf.usermodel.*;
-import org.apache.poi.hslf.model.*;
-import org.apache.poi.hssf.usermodel.HSSFWorkbook;
-import org.apache.poi.hwpf.HWPFDocument;
-import org.apache.poi.hwpf.usermodel.Range;
-import org.apache.poi.hwpf.usermodel.Paragraph;
-
-import java.io.*;
-
-/**
- * Demonstrates how you can extract misc embedded data from a ppt file
- *
- * @author Yegor Kozlov
- */
-public final class DataExtraction {
-
- public static void main(String args[]) throws Exception {
-
- if (args.length == 0) {
- usage();
- return;
- }
-
- FileInputStream is = new FileInputStream(args[0]);
- SlideShow ppt = new SlideShow(is);
- is.close();
-
- //extract all sound files embedded in this presentation
- SoundData[] sound = ppt.getSoundData();
- for (int i = 0; i < sound.length; i++) {
- String type = sound[i].getSoundType(); //*.wav
- String name = sound[i].getSoundName(); //typically file name
- byte[] data = sound[i].getData(); //raw bytes
-
- //save the sound on disk
- FileOutputStream out = new FileOutputStream(name + type);
- out.write(data);
- out.close();
- }
-
- //extract embedded OLE documents
- Slide[] slide = ppt.getSlides();
- for (int i = 0; i < slide.length; i++) {
- Shape[] shape = slide[i].getShapes();
- for (int j = 0; j < shape.length; j++) {
- if (shape[j] instanceof OLEShape) {
- OLEShape ole = (OLEShape) shape[j];
- ObjectData data = ole.getObjectData();
- String name = ole.getInstanceName();
- if ("Worksheet".equals(name)) {
-
- //read xls
- HSSFWorkbook wb = new HSSFWorkbook(data.getData());
-
- } else if ("Document".equals(name)) {
- HWPFDocument doc = new HWPFDocument(data.getData());
- //read the word document
- Range r = doc.getRange();
- for(int k = 0; k < r.numParagraphs(); k++) {
- Paragraph p = r.getParagraph(k);
- System.out.println(p.text());
- }
-
- //save on disk
- FileOutputStream out = new FileOutputStream(name + "-("+(j)+").doc");
- doc.write(out);
- out.close();
- } else {
- FileOutputStream out = new FileOutputStream(ole.getProgID() + "-"+(j+1)+".dat");
- InputStream dis = data.getData();
- byte[] chunk = new byte[2048];
- int count;
- while ((count = dis.read(chunk)) >= 0) {
- out.write(chunk,0,count);
- }
- is.close();
- out.close();
- }
- }
-
- }
- }
-
- //Pictures
- for (int i = 0; i < slide.length; i++) {
- Shape[] shape = slide[i].getShapes();
- for (int j = 0; j < shape.length; j++) {
- if (shape[j] instanceof Picture) {
- Picture p = (Picture) shape[j];
- PictureData data = p.getPictureData();
- String name = p.getPictureName();
- int type = data.getType();
- String ext;
- switch (type) {
- case Picture.JPEG:
- ext = ".jpg";
- break;
- case Picture.PNG:
- ext = ".png";
- break;
- case Picture.WMF:
- ext = ".wmf";
- break;
- case Picture.EMF:
- ext = ".emf";
- break;
- case Picture.PICT:
- ext = ".pict";
- break;
- case Picture.DIB:
- ext = ".dib";
- break;
- default:
- continue;
- }
- FileOutputStream out = new FileOutputStream("pict-" + j + ext);
- out.write(data.getData());
- out.close();
- }
-
- }
- }
-
- }
-
- private static void usage(){
- System.out.println("Usage: DataExtraction ppt");
- }
-}
+++ /dev/null
-/* ====================================================================
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-==================================================================== */
-
-package org.apache.poi.hslf.examples;
-
-import org.apache.poi.hslf.usermodel.SlideShow;
-import org.apache.poi.hslf.model.*;
-
-import java.awt.*;
-import java.io.FileOutputStream;
-import java.io.FileInputStream;
-
-/**
- * Demonstrates how to draw into a slide using the HSLF Graphics2D driver.
- *
- * @author Yegor Kozlov
- */
-public final class Graphics2DDemo {
-
- /**
- * A simple bar chart demo
- */
- public static void main(String[] args) throws Exception {
- SlideShow ppt = new SlideShow();
-
- //bar chart data. The first value is the bar color, the second is the width
- Object[] def = new Object[]{
- Color.yellow, new Integer(40),
- Color.green, new Integer(60),
- Color.gray, new Integer(30),
- Color.red, new Integer(80),
- };
-
- Slide slide = ppt.createSlide();
-
- ShapeGroup group = new ShapeGroup();
- //define position of the drawing in the slide
- Rectangle bounds = new java.awt.Rectangle(200, 100, 350, 300);
- group.setAnchor(bounds);
- group.setCoordinates(new java.awt.Rectangle(0, 0, 100, 100));
- slide.addShape(group);
- Graphics2D graphics = new PPGraphics2D(group);
-
- //draw a simple bar graph
- int x = 10, y = 10;
- graphics.setFont(new Font("Arial", Font.BOLD, 10));
- for (int i = 0, idx = 1; i < def.length; i+=2, idx++) {
- graphics.setColor(Color.black);
- int width = ((Integer)def[i+1]).intValue();
- graphics.drawString("Q" + idx, x-5, y+10);
- graphics.drawString(width + "%", x + width+3, y + 10);
- graphics.setColor((Color)def[i]);
- graphics.fill(new Rectangle(x, y, width, 10));
- y += 15;
- }
- graphics.setColor(Color.black);
- graphics.setFont(new Font("Arial", Font.BOLD, 14));
- graphics.draw(group.getCoordinates());
- graphics.drawString("Performance", x + 30, y + 10);
-
- FileOutputStream out = new FileOutputStream("hslf-graphics.ppt");
- ppt.write(out);
- out.close();
- }
-
-}
+++ /dev/null
-/* ====================================================================
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-==================================================================== */
-package org.apache.poi.hslf.examples;
-
-import org.apache.poi.hslf.usermodel.SlideShow;
-import org.apache.poi.hslf.model.HeadersFooters;
-import org.apache.poi.hslf.model.Slide;
-
-import java.io.FileOutputStream;
-
-/**
- * Demonstrates how to set headers / footers
- *
- * @author Yegor Kozlov
- */
-public class HeadersFootersDemo {
- public static void main(String[] args) throws Exception {
- SlideShow ppt = new SlideShow();
-
- HeadersFooters slideHeaders = ppt.getSlideHeadersFooters();
- slideHeaders.setFootersText("Created by POI-HSLF");
- slideHeaders.setSlideNumberVisible(true);
- slideHeaders.setDateTimeText("custom date time");
-
- HeadersFooters notesHeaders = ppt.getNotesHeadersFooters();
- notesHeaders.setFootersText("My notes footers");
- notesHeaders.setHeaderText("My notes header");
-
- Slide slide = ppt.createSlide();
-
- FileOutputStream out = new FileOutputStream("headers_footers.ppt");
- ppt.write(out);
- out.close();
-
- }
-
-}
+++ /dev/null
-/* ====================================================================
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-==================================================================== */
-
-package org.apache.poi.hslf.examples;
-
-import org.apache.poi.hslf.usermodel.SlideShow;
-import org.apache.poi.hslf.model.Slide;
-import org.apache.poi.hslf.model.TextRun;
-import org.apache.poi.hslf.model.Hyperlink;
-import org.apache.poi.hslf.model.Shape;
-
-import java.io.FileInputStream;
-
-/**
- * Demonstrates how to read hyperlinks from a presentation
- *
- * @author Yegor Kozlov
- */
-public final class Hyperlinks {
-
- public static void main(String[] args) throws Exception {
- for (int i = 0; i < args.length; i++) {
- FileInputStream is = new FileInputStream(args[i]);
- SlideShow ppt = new SlideShow(is);
- is.close();
-
- Slide[] slide = ppt.getSlides();
- for (int j = 0; j < slide.length; j++) {
- System.out.println("slide " + slide[j].getSlideNumber());
-
- //read hyperlinks from the slide's text runs
- System.out.println("reading hyperlinks from the text runs");
- TextRun[] txt = slide[j].getTextRuns();
- for (int k = 0; k < txt.length; k++) {
- String text = txt[k].getText();
- Hyperlink[] links = txt[k].getHyperlinks();
- if(links != null) for (int l = 0; l < links.length; l++) {
- Hyperlink link = links[l];
- String title = link.getTitle();
- String address = link.getAddress();
- System.out.println(" " + title);
- System.out.println(" " + address);
- String substring = text.substring(link.getStartIndex(), link.getEndIndex()-1);//in ppt end index is inclusive
- System.out.println(" " + substring);
- }
- }
-
- //in PowerPoint you can assign a hyperlink to a shape without text,
- //for example to a Line object. The code below demonstrates how to
- //read such hyperlinks
- System.out.println(" reading hyperlinks from the slide's shapes");
- Shape[] sh = slide[j].getShapes();
- for (int k = 0; k < sh.length; k++) {
- Hyperlink link = sh[k].getHyperlink();
- if(link != null) {
- String title = link.getTitle();
- String address = link.getAddress();
- System.out.println(" " + title);
- System.out.println(" " + address);
- }
- }
- }
-
- }
-
- }
-}
+++ /dev/null
-/* ====================================================================
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-==================================================================== */
-
-package org.apache.poi.hslf.examples;
-
-import org.apache.poi.hslf.usermodel.*;
-import org.apache.poi.hslf.model.*;
-import org.apache.poi.hslf.record.TextHeaderAtom;
-
-import javax.imageio.ImageIO;
-import java.io.IOException;
-import java.io.FileOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.awt.*;
-import java.awt.image.BufferedImage;
-import java.awt.geom.AffineTransform;
-import java.awt.geom.Rectangle2D;
-
-/**
- * Demonstrates how you can use HSLF to convert each slide into a PNG image
- *
- * @author Yegor Kozlov
- */
-public final class PPT2PNG {
-
- public static void main(String args[]) throws Exception {
-
- if (args.length == 0) {
- usage();
- return;
- }
-
- int slidenum = -1;
- float scale = 1;
- String file = null;
-
- for (int i = 0; i < args.length; i++) {
- if (args[i].startsWith("-")) {
- if ("-scale".equals(args[i])){
- scale = Float.parseFloat(args[++i]);
- } else if ("-slide".equals(args[i])) {
- slidenum = Integer.parseInt(args[++i]);
- }
- } else {
- file = args[i];
- }
- }
- if(file == null){
- usage();
- return;
- }
-
- FileInputStream is = new FileInputStream(file);
- SlideShow ppt = new SlideShow(is);
- is.close();
-
- Dimension pgsize = ppt.getPageSize();
- int width = (int)(pgsize.width*scale);
- int height = (int)(pgsize.height*scale);
-
- Slide[] slide = ppt.getSlides();
- for (int i = 0; i < slide.length; i++) {
- if (slidenum != -1 && slidenum != (i+1)) continue;
-
- String title = slide[i].getTitle();
- System.out.println("Rendering slide "+slide[i].getSlideNumber() + (title == null ? "" : ": " + title));
-
- BufferedImage img = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
- Graphics2D graphics = img.createGraphics();
- graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
- graphics.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
- graphics.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC);
- graphics.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON);
-
- graphics.setPaint(Color.white);
- graphics.fill(new Rectangle2D.Float(0, 0, width, height));
-
- graphics.scale((double)width/pgsize.width, (double)height/pgsize.height);
-
- slide[i].draw(graphics);
-
- String fname = file.replaceAll("\\.ppt", "-" + (i+1) + ".png");
- FileOutputStream out = new FileOutputStream(fname);
- ImageIO.write(img, "png", out);
- out.close();
- }
- }
-
- private static void usage(){
- System.out.println("Usage: PPT2PNG [-scale <scale> -slide <num>] ppt");
- }
-}
+++ /dev/null
-/* ====================================================================
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-==================================================================== */
-package org.apache.poi.hslf.examples;
-import org.apache.poi.ddf.*;
-import org.apache.poi.hslf.model.*;
-import org.apache.poi.hslf.record.InteractiveInfo;
-import org.apache.poi.hslf.record.InteractiveInfoAtom;
-import org.apache.poi.hslf.record.Record;
-import org.apache.poi.hslf.usermodel.*;
-import java.io.FileInputStream;
-import java.util.Iterator;
-import java.util.List;
-
-/**
- * For each slide iterate over shapes and found associated sound data.
- *
- * @author Yegor Kozlov
- */
-public class SoundFinder {
- public static void main(String[] args) throws Exception {
- SlideShow ppt = new SlideShow(new FileInputStream(args[0]));
- SoundData[] sounds = ppt.getSoundData();
-
- Slide[] slide = ppt.getSlides();
- for (int i = 0; i < slide.length; i++) {
- Shape[] shape = slide[i].getShapes();
- for (int j = 0; j < shape.length; j++) {
- int soundRef = getSoundReference(shape[j]);
- if(soundRef != -1) {
- System.out.println("Slide["+i+"], shape["+j+"], soundRef: "+soundRef);
- System.out.println(" " + sounds[soundRef].getSoundName());
- System.out.println(" " + sounds[soundRef].getSoundType());
- }
- }
- }
- }
-
- /**
- * Check if a given shape is associated with a sound.
- * @return 0-based reference to a sound in the sound collection
- * or -1 if the shape is not associated with a sound
- */
- protected static int getSoundReference(Shape shape){
- int soundRef = -1;
- //dive into the shape container and search for InteractiveInfoAtom
- EscherContainerRecord spContainer = shape.getSpContainer();
- List spchild = spContainer.getChildRecords();
- for (Iterator it = spchild.iterator(); it.hasNext();) {
- EscherRecord obj = (EscherRecord) it.next();
- if (obj.getRecordId() == EscherClientDataRecord.RECORD_ID) {
- byte[] data = obj.serialize();
- Record[] records = Record.findChildRecords(data, 8,
-data.length - 8);
- for (int j = 0; j < records.length; j++) {
- if (records[j] instanceof InteractiveInfo) {
- InteractiveInfoAtom info = ((InteractiveInfo)records[j]).getInteractiveInfoAtom();
- if (info.getAction() == InteractiveInfoAtom.ACTION_MEDIA) {
- soundRef = info.getSoundRef();
- }
- }
- }
- }
- }
- return soundRef;
- }
-}
+++ /dev/null
-/* ====================================================================
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-==================================================================== */
-
-package org.apache.poi.hslf.examples;
-
-import org.apache.poi.hslf.usermodel.SlideShow;
-import org.apache.poi.hslf.usermodel.RichTextRun;
-import org.apache.poi.hslf.model.*;
-
-import java.awt.*;
-import java.io.FileOutputStream;
-
-/**
- * Demonstrates how to create tables
- *
- * @author Yegor Kozlov
- */
-public final class TableDemo {
-
- public static void main(String[] args) throws Exception {
-
- //test data for the first taable
- String[][] txt1 = {
- {"INPUT FILE", "NUMBER OF RECORDS"},
- {"Item File", "11,559"},
- {"Vendor File", "502"},
- {"Purchase History File - # of PO\u2019s\r(12/01/04 - 05/31/06)", "12,852"},
- {"Purchase History File - # of PO Lines\r(12/01/04 - 05/31/06)", "53,523" },
- {"Total PO History Spend", "$10,172,038"}
- };
-
- SlideShow ppt = new SlideShow();
-
- Slide slide = ppt.createSlide();
-
- //six rows, two columns
- Table table1 = new Table(6, 2);
- for (int i = 0; i < txt1.length; i++) {
- for (int j = 0; j < txt1[i].length; j++) {
- TableCell cell = table1.getCell(i, j);
- cell.setText(txt1[i][j]);
- RichTextRun rt = cell.getTextRun().getRichTextRuns()[0];
- rt.setFontName("Arial");
- rt.setFontSize(10);
- if(i == 0){
- cell.getFill().setForegroundColor(new Color(227, 227, 227));
- } else {
- rt.setBold(true);
- }
- cell.setVerticalAlignment(TextBox.AnchorMiddle);
- cell.setHorizontalAlignment(TextBox.AlignCenter);
- }
- }
-
- Line border1 = table1.createBorder();
- border1.setLineColor(Color.black);
- border1.setLineWidth(1.0);
- table1.setAllBorders(border1);
-
- table1.setColumnWidth(0, 300);
- table1.setColumnWidth(1, 150);
-
- slide.addShape(table1);
- int pgWidth = ppt.getPageSize().width;
- table1.moveTo((pgWidth - table1.getAnchor().width)/2, 100);
-
- //test data for the second taable
- String[][] txt2 = {
- {"Data Source"},
- {"CAS Internal Metrics - Item Master Summary\r" +
- "CAS Internal Metrics - Vendor Summary\r" +
- "CAS Internal Metrics - PO History Summary"}
- };
-
- //two rows, one column
- Table table2 = new Table(2, 1);
- for (int i = 0; i < txt2.length; i++) {
- for (int j = 0; j < txt2[i].length; j++) {
- TableCell cell = table2.getCell(i, j);
- cell.setText(txt2[i][j]);
- RichTextRun rt = cell.getTextRun().getRichTextRuns()[0];
- rt.setFontSize(10);
- rt.setFontName("Arial");
- if(i == 0){
- cell.getFill().setForegroundColor(new Color(0, 51, 102));
- rt.setFontColor(Color.white);
- rt.setBold(true);
- rt.setFontSize(14);
- cell.setHorizontalAlignment(TextBox.AlignCenter);
- } else {
- rt.setBullet(true);
- rt.setFontSize(12);
- cell.setHorizontalAlignment(TextBox.AlignLeft);
- }
- cell.setVerticalAlignment(TextBox.AnchorMiddle);
- }
- }
- table2.setColumnWidth(0, 300);
- table2.setRowHeight(0, 30);
- table2.setRowHeight(1, 70);
-
- Line border2 = table2.createBorder();
- table2.setOutsideBorders(border2);
-
- slide.addShape(table2);
- table2.moveTo(200, 400);
-
- FileOutputStream out = new FileOutputStream("hslf-table.ppt");
- ppt.write(out);
- out.close();
-
- }
-}
+++ /dev/null
-/* ====================================================================
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-==================================================================== */
-
-package org.apache.poi.hsmf.examples;
-
-import java.io.ByteArrayInputStream;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.io.PrintWriter;
-import java.util.Iterator;
-import java.util.Map;
-
-import org.apache.poi.hsmf.MAPIMessage;
-import org.apache.poi.hsmf.exceptions.ChunkNotFoundException;
-
-/**
- * Reads one or several Outlook MSG files and for each of them creates
- * a text file from available chunks and a directory that contains
- * attachments.
- *
- * @author Bruno Girin
- *
- */
-public class Msg2txt {
-
- /**
- * The stem used to create file names for the text file and the directory
- * that contains the attachments.
- */
- private String fileNameStem;
-
- /**
- * The Outlook MSG file being processed.
- */
- private MAPIMessage msg;
-
- public Msg2txt(String fileName) throws IOException {
- fileNameStem = fileName;
- if(fileNameStem.endsWith(".msg") || fileNameStem.endsWith(".MSG")) {
- fileNameStem = fileNameStem.substring(0, fileNameStem.length() - 4);
- }
- msg = new MAPIMessage(fileName);
- }
-
- /**
- * Processes the message.
- *
- * @throws IOException if an exception occurs while writing the message out
- */
- public void processMessage() throws IOException {
- String txtFileName = fileNameStem + ".txt";
- String attDirName = fileNameStem + "-att";
- PrintWriter txtOut = null;
- try {
- txtOut = new PrintWriter(txtFileName);
- try {
- String displayFrom = msg.getDisplayFrom();
- txtOut.println("From: "+displayFrom);
- } catch (ChunkNotFoundException e) {
- // ignore
- }
- try {
- String displayTo = msg.getDisplayTo();
- txtOut.println("To: "+displayTo);
- } catch (ChunkNotFoundException e) {
- // ignore
- }
- try {
- String displayCC = msg.getDisplayCC();
- txtOut.println("CC: "+displayCC);
- } catch (ChunkNotFoundException e) {
- // ignore
- }
- try {
- String displayBCC = msg.getDisplayBCC();
- txtOut.println("BCC: "+displayBCC);
- } catch (ChunkNotFoundException e) {
- // ignore
- }
- try {
- String subject = msg.getSubject();
- txtOut.println("Subject: "+subject);
- } catch (ChunkNotFoundException e) {
- // ignore
- }
- try {
- String body = msg.getTextBody();
- txtOut.println(body);
- } catch (ChunkNotFoundException e) {
- System.err.println("No message body");
- }
- Map attachmentMap = msg.getAttachmentFiles();
- if(attachmentMap.size() > 0) {
- File d = new File(attDirName);
- if(d.mkdir()) {
- for(
- Iterator ii = attachmentMap.entrySet().iterator();
- ii.hasNext();
- ) {
- Map.Entry entry = (Map.Entry)ii.next();
- processAttachment(d, entry.getKey().toString(),
- (ByteArrayInputStream)entry.getValue());
- }
- } else {
- System.err.println("Can't create directory "+attDirName);
- }
- }
- } finally {
- if(txtOut != null) {
- txtOut.close();
- }
- }
- }
-
- /**
- * Processes a single attachment: reads it from the Outlook MSG file and
- * writes it to disk as an individual file.
- *
- * @param dir the directory in which to write the attachment file
- * @param fileName the name of the attachment file
- * @param fileIn the input stream that contains the attachment's data
- * @throws IOException when any of the file operations fails
- */
- public void processAttachment(File dir, String fileName,
- ByteArrayInputStream fileIn) throws IOException {
- File f = new File(dir, fileName);
- OutputStream fileOut = null;
- try {
- fileOut = new FileOutputStream(f);
- byte[] buffer = new byte[2048];
- int bNum = fileIn.read(buffer);
- while(bNum > 0) {
- fileOut.write(buffer);
- bNum = fileIn.read(buffer);
- }
- } finally {
- try {
- if(fileIn != null) {
- fileIn.close();
- }
- } finally {
- if(fileOut != null) {
- fileOut.close();
- }
- }
- }
- }
-
- /**
- * Processes the list of arguments as a list of names of Outlook MSG files.
- *
- * @param args the list of MSG files to process
- */
- public static void main(String[] args) {
- if(args.length <= 0) {
- System.err.println("No files names provided");
- } else {
- for(int i = 0; i < args.length; i++) {
- try {
- Msg2txt processor = new Msg2txt(args[i]);
- processor.processMessage();
- } catch (IOException e) {
- System.err.println("Could not process "+args[i]+": "+e);
- }
- }
- }
- }
-
-}
+++ /dev/null
-/* ====================================================================
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-==================================================================== */
-
-package org.apache.poi.hwpf;
-
-import org.apache.poi.hwpf.HWPFDocument;
-import org.apache.poi.hwpf.usermodel.*;
-import org.apache.poi.hwpf.model.*;
-
-import java.io.*;
-
-public final class Word2Forrest
-{
- Writer _out;
- HWPFDocument _doc;
-
- public Word2Forrest(HWPFDocument doc, OutputStream stream)
- throws IOException, UnsupportedEncodingException
- {
- OutputStreamWriter out = new OutputStreamWriter (stream, "UTF-8");
- _out = out;
- _doc = doc;
-
- init ();
- openDocument ();
- openBody ();
-
- Range r = doc.getRange ();
- StyleSheet styleSheet = doc.getStyleSheet ();
-
- int sectionLevel = 0;
- int lenParagraph = r.numParagraphs ();
- boolean inCode = false;
- for (int x = 0; x < lenParagraph; x++)
- {
- Paragraph p = r.getParagraph (x);
- String text = p.text ();
- if (text.trim ().length () == 0)
- {
- continue;
- }
- StyleDescription paragraphStyle = styleSheet.getStyleDescription (p.
- getStyleIndex ());
- String styleName = paragraphStyle.getName();
- if (styleName.startsWith ("Heading"))
- {
- if (inCode)
- {
- closeSource();
- inCode = false;
- }
-
- int headerLevel = Integer.parseInt (styleName.substring (8));
- if (headerLevel > sectionLevel)
- {
- openSection ();
- }
- else
- {
- for (int y = 0; y < (sectionLevel - headerLevel) + 1; y++)
- {
- closeSection ();
- }
- openSection ();
- }
- sectionLevel = headerLevel;
- openTitle ();
- writePlainText (text);
- closeTitle ();
- }
- else
- {
- int cruns = p.numCharacterRuns ();
- CharacterRun run = p.getCharacterRun (0);
- String fontName = run.getFontName();
- if (fontName.startsWith ("Courier"))
- {
- if (!inCode)
- {
- openSource ();
- inCode = true;
- }
- writePlainText (p.text());
- }
- else
- {
- if (inCode)
- {
- inCode = false;
- closeSource();
- }
- openParagraph();
- writePlainText(p.text());
- closeParagraph();
- }
- }
- }
- for (int x = 0; x < sectionLevel; x++)
- {
- closeSection();
- }
- closeBody();
- closeDocument();
- _out.flush();
-
- }
-
- public void init ()
- throws IOException
- {
- _out.write ("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n");
- _out.write ("<!DOCTYPE document PUBLIC \"-//APACHE//DTD Documentation V1.1//EN\" \"./dtd/document-v11.dtd\">\r\n");
- }
-
- public void openDocument ()
- throws IOException
- {
- _out.write ("<document>\r\n");
- }
- public void closeDocument ()
- throws IOException
- {
- _out.write ("</document>\r\n");
- }
-
-
- public void openBody ()
- throws IOException
- {
- _out.write ("<body>\r\n");
- }
-
- public void closeBody ()
- throws IOException
- {
- _out.write ("</body>\r\n");
- }
-
-
- public void openSection ()
- throws IOException
- {
- _out.write ("<section>");
-
- }
-
- public void closeSection ()
- throws IOException
- {
- _out.write ("</section>");
-
- }
-
- public void openTitle ()
- throws IOException
- {
- _out.write ("<title>");
- }
-
- public void closeTitle ()
- throws IOException
- {
- _out.write ("</title>");
- }
-
- public void writePlainText (String text)
- throws IOException
- {
- _out.write (text);
- }
-
- public void openParagraph ()
- throws IOException
- {
- _out.write ("<p>");
- }
-
- public void closeParagraph ()
- throws IOException
- {
- _out.write ("</p>");
- }
-
- public void openSource ()
- throws IOException
- {
- _out.write ("<source><![CDATA[");
- }
- public void closeSource ()
- throws IOException
- {
- _out.write ("]]></source>");
- }
-
-
- public static void main(String[] args)
- {
- try
- {
- OutputStream out = new FileOutputStream("c:\\test.xml");
-
- new Word2Forrest(new HWPFDocument(new FileInputStream(args[0])), out);
- out.close();
- }
- catch (Throwable t)
- {
- t.printStackTrace();
- }
-
- }
-}
+++ /dev/null
-Manifest-Version: 1.0
\ No newline at end of file