Compare commits

..

5 Commits

Author SHA1 Message Date
Joe Schaefer c13aa38adf move poi to top level
git-svn-id: https://svn.apache.org/repos/asf/poi/branches/performance-branch@550311 13f79535-47bb-0310-9956-ffa450edef68
2007-06-25 01:51:34 +00:00
Andrew C. Oliver 824a0eea49 please go to the branch, oh please oh please oh please... I goofed apparently before
and the reason the performance branch was so broken was I didn't check in HSSFRow the new HSSFRow!! doh!


git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/branches/performance-branch@353038 13f79535-47bb-0310-9956-ffa450edef68
2003-03-29 23:20:51 +00:00
Andrew C. Oliver 3d7da30cab forgot a file
PR:
Obtained from:
Submitted by:
Reviewed by:


git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/branches/performance-branch@352983 13f79535-47bb-0310-9956-ffa450edef68
2003-01-06 04:43:38 +00:00
Andrew C. Oliver fea5acbbe9 First go at performance refactor. Most unit tests working, some have to be removed to compile (need to get things up to spec as far as new patches)
PR:
Obtained from:
Submitted by:
Reviewed by:


git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/branches/performance-branch@352982 13f79535-47bb-0310-9956-ffa450edef68
2003-01-05 19:04:40 +00:00
No Author 888bdbf619 This commit was manufactured by cvs2svn to create branch
'performance-branch'.

git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/branches/performance-branch@352981 13f79535-47bb-0310-9956-ffa450edef68
2003-01-03 11:30:48 +00:00
1926 changed files with 215889 additions and 171383 deletions

42
.ci/Jenkinsfile vendored
View File

@ -1,42 +0,0 @@
properties(
[
disableConcurrentBuilds()
]
)
node('linux && docker') {
try {
stage('Checkout') {
//branch name from Jenkins environment variables
echo "My branch is: ${env.BRANCH_NAME}"
// this doesn't grab tags pointing to this branch
//checkout scm
// this hack does... https://issues.jenkins.io/browse/JENKINS-45164
checkout([
$class: 'GitSCM',
branches: [[name: 'refs/heads/'+env.BRANCH_NAME]],
extensions: [[$class: 'CloneOption', noTags: false, shallow: false, depth: 0, reference: '']],
userRemoteConfigs: scm.userRemoteConfigs,
])
sh '''
set -euxo pipefail
git checkout "$BRANCH_NAME" --
git reset --hard "origin/$BRANCH_NAME"
'''
}
stage('Build + Deploy') {
sh 'curl --compressed -sL https://code.moparisthebest.com/moparisthebest/self-ci/raw/branch/master/build-ci.sh | bash'
}
currentBuild.result = 'SUCCESS'
} catch (Exception err) {
currentBuild.result = 'FAILURE'
} finally {
stage('Email') {
step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: 'admin.jenkins@moparisthebest.com', sendToIndividuals: true])
}
deleteDir()
}
}

View File

@ -1,36 +0,0 @@
#!/bin/bash
set -euxo pipefail
# Java 14+ java.lang.Record is ambiguous with hssf.Record :'(
[ $JAVA_VERSION -lt 7 -o $JAVA_VERSION -gt 13 ] && echo "build does not support JAVA_VERSION: $JAVA_VERSION" && exit 0
echo "starting build for JAVA_VERSION: $JAVA_VERSION"
# grab all deps with java 8
[ $JAVA_VERSION -eq 7 ] && run-java 8 mvn dependency:go-offline
# install deps
mvn install -DskipTests=true -Dmaven.javadoc.skip=true -B -V
if [ $JAVA_VERSION -lt 12 ]
then
# clean and test
mvn clean test -B
else
# clean and test
mvn clean test -B -Djava.version=7 # java12+ minimum target is 7, not 6
fi
# publish only from java 6 and master branch
if [ "$BRANCH_NAME" == "master" -a $JAVA_VERSION -eq 7 ]
then
echo 'deploying to maven'
# java 7 cannot do modern SSL, use java 8 to deploy
run-java 8 mvn deploy -Dmaven.test.skip=true -B
mkdir -p release
find -type f -name '*.jar' -print0 | xargs -0n1 -I {} mv '{}' 'release/'
fi
echo 'build success!'
exit 0

10
.classpath Normal file
View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src/testcases"/>
<classpathentry kind="src" path="src/java"/>
<classpathentry kind="src" path="src/examples/src"/>
<classpathentry kind="var" path="JRE_LIB" rootpath="JRE_SRCROOT" sourcepath="JRE_SRC"/>
<classpathentry kind="lib" path="tools/cents/junit.cent/lib/junit-3.7.jar"/>
<classpathentry kind="lib" path="lib/core/commons-logging-1.0.jar"/>
<classpathentry kind="output" path="build"/>
</classpath>

9
.cvsignore Normal file
View File

@ -0,0 +1,9 @@
*.properties
dist
*.el
*.ipr
*.iws
build.number
log*.*
*.log
build

22
.gitignore vendored
View File

@ -1,22 +0,0 @@
classes
workbook.xls
bak
*.iws
build.number
*.el
TEST-org.apache.poi*.xml
build
.settings
scripts
*.ipr
untitled1.jpx
*.iml
log*.*
dist
*.log
bin
.ant-targets-build.xml
out
.idea
.gradle
target

17
.project Normal file
View File

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>POI</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

View File

@ -1,24 +0,0 @@
POI Fast Calc
======================
[![Build Status](https://ci.moparisthe.best/job/moparisthebest/job/poi/job/master/badge/icon%3Fstyle=plastic)](https://ci.moparisthe.best/job/moparisthebest/job/poi/job/master/)
A Java library to calculate Excel formulas quickly.
This is a fork of [Apache POI](https://poi.apache.org/) version [3.16](https://github.com/apache/poi/tree/REL_3_16_FINAL)
that serves simply to calculate formulas quickly, it supports XLSX (Excel 2007) row/column limits in the HSSF engine for
much faster evaluation than XML-backed XSSF is capable of, with the drawback that it can't read or write XLS/XLSX files
from or to disk. Read the [email thread](https://lists.apache.org/thread.html/0bc90a3ed386edddfcb9b93ce6c262ad145a6b0433d0fcfe70ef10a2@%3Cdev.poi.apache.org%3E)
with my original proposed patch to upstream poi for background.
To use, add this to your maven pom.xml:
```xml
<dependency>
<groupId>com.moparisthebest.poi</groupId>
<artifactId>poi-fast-calc</artifactId>
<version>3.16-SNAPSHOT</version>
</dependency>
```
The `org.apache.poi` package has been renamed `com.moparisthebest.poi` and all dependencies removed,
so this can cleanly live aside modern/newer upstream poi forever, and shouldn't ever need to change.

2
appendcp.bat Normal file
View File

@ -0,0 +1,2 @@
set CLASSPATH=%CLASSPATH%;%1

14
build.bat Executable file
View File

@ -0,0 +1,14 @@
@echo off
set OLD_ANT_HOME=%ANT_HOME%
set ANT_HOME=tools\antipede
set OLD_CLASSPATH=%CLASSPATH%
set CLASSPATH=
for %%i in (.\lib\endorsed\*.jar) do call appendcp.bat %%i
echo Using classpath: "%CLASSPATH%"
call %ANT_HOME%\bin\ant -emacs -logger org.apache.tools.ant.NoBannerLogger %1 %2 %3 %4 %5 %6 %7 %8 %9
set ANT_HOME=%OLD_ANT_HOME%
set CLASSPATH=%OLD_CLASSPATH%

40
build.sh Executable file
View File

@ -0,0 +1,40 @@
#!/bin/sh
# ----- Verify and Set Required Environment Variables -------------------------
if [ "$JAVA_HOME" = "" ] ; then
echo You must set JAVA_HOME to point at your Java Development Kit installation
exit 1
fi
chmod u+x ./tools/antipede/bin/antRun
chmod u+x ./tools/antipede/bin/ant
# ----- Verify and Set Required Environment Variables -------------------------
if [ "$TERM" = "cygwin" ] ; then
S=';'
else
S=':'
fi
# ----- Set Up The Runtime Classpath ------------------------------------------
OLD_ANT_HOME=$ANT_HOME
unset ANT_HOME
CP=$CLASSPATH
export CP
unset CLASSPATH
CLASSPATH="`echo ./lib/endorsed/*.jar | tr ' ' $S`"
export CLASSPATH
echo Using classpath: \"$CLASSPATH\"
$PWD/./tools/antipede/bin/ant -emacs -logger org.apache.tools.ant.NoBannerLogger $@
unset CLASSPATH
CLASSPATH=$CP
export CLASSPATH
ANT_HOME=OLD_ANT_HOME
export ANT_HOME

477
build.xml Normal file
View File

@ -0,0 +1,477 @@
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="./tools/antipede/resources/stylesheets/build.xsl"?>
<!--<!DOCTYPE project SYSTEM "./tools/antipede/build.dtd" >-->
<!DOCTYPE project [
<!-- antipede -->
<!ENTITY import-antipede SYSTEM "./tools/antipede/build.xtarget">
]>
<project default="interactive" basedir="." name="project build file">
<description>
* ===================================== *
| Krysalis Centipede Build System |
* ===================================== *
by
Nicola Ken Barozzi (nicolaken@apache.org)
Marc Johnson (mjohnson@apache.org)
For a simple interactive build, simply
run the build script (build.bar or build.sh)
</description>
<!-- =================================================================== -->
<!-- Basic build targets for the project -->
<!-- =================================================================== -->
<!-- =================================================================== -->
<!-- Interactive build -->
<!-- =================================================================== -->
<target name="interactive" description="Interactive Build" depends="-init">
<echo>
--------------------------------------------------------------
${xgump.module.project.name} ${xgump.module.project.version.major}.${xgump.module.project.version.minor} [${YEAR}]
--------------------------------------------------------------
Using ${ant.version}
Build file ${ant.file}
--------------------------------------------------------------
These are the most common build targets.
You can also invoke them directly; see build.xml for more info.
Builds will be in /build directory, distributions in /dist.
all -------------- creates the jars and the site
compile ---------- compiles the source code
test ------------- performs the jUnit tests
jar -------------- create the jar files
docs ------------- generates the html docs - clean not needed
javadocs --------- generates the API documentation
site ------------- generates the html site (docs+reports)
clean ------------ cleans the build directory
dist ------------- creates src and bin distributions
scratchpad ------- build-run scratchpad code
contrib ---------- build-run contributed code
generate-records - generate excel records
generate-types --- generate word types
</echo>
<property name="input.selection" value="all"/>
<centipede-user-input name="input.selection">Please select a target </centipede-user-input>
<antcall target="call-cent">
<param name="cent-name" value="centipede"/>
<param name="cent-target" value="splash"/>
</antcall>
<antcall target="${input.selection}"/>
</target>
<!-- =================================================================== -->
<!-- Interactive scratchpad builds -->
<!-- =================================================================== -->
<target name="scratchpad" depends="compile" description="Interactive Scratchpad Build">
<echo>
--------------------------------------------------------------
${xgump.module.project.name} ${xgump.module.project.version.major}.${xgump.module.project.version.minor} SCRATCHPAD
--------------------------------------------------------------
Building with ${ant.version}
using build file ${ant.file}
--------------------------------------------------------------
These are SCRATCHPAD BUILDS. They are not guaranteed to work.
You have been warned.
-
-
-
-
-
-
</echo>
<property name="input.selection" value=""/>
<centipede-user-input name="input.selection">Please select a target </centipede-user-input>
<ant antfile="${xlayout.source.scratchpad.targets.dir}/${input.selection}/xbuild.xml"/>
</target>
<!-- =================================================================== -->
<!-- Interactive contrib builds -->
<!-- =================================================================== -->
<target name="contrib" depends="compile" description="Interactive Contributors' Build">
<echo>
--------------------------------------------------------------
${xgump.module.project.name} ${xgump.module.project.version.major}.${xgump.module.project.version.minor} CONTRIB
--------------------------------------------------------------
Building with ${ant.version}
using build file ${ant.file}
--------------------------------------------------------------
These are CONTRIB BUILDS. They are not guaranteed to work.
You have been warned.
poibrowser - POIBrowser 0.10 GUI POI Viewer
sheetviewer - SheetViewer 0.20 GUI Applet/Application Viewer for XLS files
-
-
-
-
</echo>
<property name="input.selection" value="poibrowser"/>
<centipede-user-input name="input.selection">Please select a target </centipede-user-input>
<ant antfile="${xlayout.source.contributions.targets.dir}/${input.selection}/xbuild.xml"/>
</target>
<!-- ================================== -->
<!-- Compile -->
<!-- ================================== -->
<target name="compile" depends="-init"
description="Compile java source code">
<antcall target="call-cent">
<param name="cent-name" value="automagic"/>
<param name="cent-target" value="compile"/>
</antcall>
</target>
<!-- ================================== -->
<!-- Build jars -->
<!-- ================================== -->
<target name="jar" depends="-init"
description="Compile java source code">
<antcall target="call-cent">
<param name="cent-name" value="automagic"/>
<param name="cent-target" value="jar"/>
</antcall>
</target>
<!-- ====================================== -->
<!-- dist target wo single build checks -->
<!-- ====================================== -->
<target name="dist" depends="-init"
description="Build distribution packages wo single build checks">
<antcall target="call-cent">
<param name="cent-name" value="automagic"/>
<param name="cent-target" value="dist"/>
</antcall>
</target>
<!-- ================================== -->
<!-- Clean build dir -->
<!-- ================================== -->
<target name="clean" depends="-init"
description="Compile java source code">
<antcall target="call-cent">
<param name="cent-name" value="automagic"/>
<param name="cent-target" value="clean"/>
</antcall>
</target>
<!-- ================================== -->
<!-- Run Junit tests -->
<!-- ================================== -->
<target name="test" depends="-init"
description="Compile java source code">
<antcall target="call-cent">
<param name="cent-name" value="automagic"/>
<param name="cent-target" value="test"/>
</antcall>
</target>
<!-- ================================== -->
<!-- Generate project metrics -->
<!-- ================================== -->
<target name="metrics" depends="-init"
description="Generate project metrics">
<antcall target="call-cent">
<param name="cent-name" value="automagic"/>
<param name="cent-target" value="metrics"/>
</antcall>
</target>
<!-- ================================== -->
<!-- Generates the documentation -->
<!-- ================================== -->
<target name="docs" depends="-init"
description="Compile java source code">
<antcall target="call-cent">
<param name="cent-name" value="automagic"/>
<param name="cent-target" value="docs"/>
</antcall>
</target>
<!-- ================================== -->
<!-- Generates the site -->
<!-- ================================== -->
<target name="site"
description="Makes all the site doco"
depends="-init">
<antcall target="call-cent">
<param name="cent-name" value="automagic"/>
<param name="cent-target" value="site"/>
</antcall>
</target>
<!-- ================================== -->
<!-- Generates the java docs -->
<!-- ================================== -->
<target name="javadocs" depends="-init"
description="Compile java source code">
<antcall target="call-cent">
<param name="cent-name" value="automagic"/>
<param name="cent-target" value="javadocs"/>
</antcall>
</target>
<!-- ================================== -->
<!-- Generate records -->
<!-- ================================== -->
<target name="generate-records" depends="-init"
description="generate-records">
<ant antfile="${xlayout.source.targets.dir}/record-generation/xbuild.xml"
target="generate-records"/>
</target>
<!-- ================================== -->
<!-- Generate types -->
<!-- ================================== -->
<target name="generate-types" depends="-init"
description="generate-types">
<ant antfile="${xlayout.source.targets.dir}/record-generation/xbuild.xml"
target="generate-types"/>
</target>
<!-- ================================== -->
<!-- Test the main module stuff -->
<!-- ================================== -->
<target name="testmodule"
depends="clean, docs, compile, test, jar, metrics, javadocs"
description="Testing that all major targets work; useful before a commit"/>
<!-- ================================== -->
<!-- Test the main module stuff 2 -->
<!-- ================================== -->
<target name="testtargets"
description="Testing that all major targets work indipendently; useful before a commit">
<antcall target="clean"/>
<antcall target="compile"/>
<antcall target="clean"/>
<antcall target="test"/>
<antcall target="clean"/>
<antcall target="jar"/>
<antcall target="clean"/>
<antcall target="docs"/>
<antcall target="clean"/>
<antcall target="metrics"/>
<antcall target="clean"/>
<antcall target="javadocs"/>
</target>
<!-- ================================== -->
<!-- Test 4 distribution -->
<!-- ================================== -->
<target name="testall" depends="-init"
description="Make big full test">
<antcall target="gump"/>
<antcall target="dist"/>
</target>
<!-- ================================== -->
<!-- Target used by Gump -->
<!-- ================================== -->
<target name="gump"
depends="-init, compile, test, jar, metrics, javadocs"
description="Target used by Gump"/>
<!-- ================================== -->
<!-- Generate all -->
<!-- ================================== -->
<target name="all"
depends="-init, jar, site"
description="Generate all"/>
<!-- =================================================================== -->
<!-- Import Ant-Centipede -init targets - sets up basic build stuff -->
<!-- =================================================================== -->
<!--
This is the target that initializes tasks and properties used
commonly in every other target.
Remember to add depends="-init" to every target, so that this
target is called before any other.
This target is internal; to make it unusable from the commandline,
its name starts with a hyphen. To make it invisible when
using -projecthelp, it lacks a description.
-->
&import-antipede;
<!-- ================================== -->
<!-- POI specific extensions to the the build file -->
<!-- ================================== -->
<patternset id="teststhatfail">
</patternset>
<!-- ================================== -->
<!-- run tests one at a time -->
<!-- ================================== -->
<target name="single-test" if="testcase" depends="-init,compile-tests"
description="--> runs the single unit test defined in the testcase property">
<junit2 printsummary="no" haltonfailure="${junit.test.haltonfailure}" fork="yes">
<formatter type="xml" />
<formatter type="plain" usefile="no"/>
<sysproperty key="UTIL.testdata.path"
value="${xlayout.source.test.dir}/org/apache/poi/util/data"/>
<sysproperty key="HSSF.testdata.path"
value="${xlayout.source.test.dir}/org/apache/poi/hssf/data"/>
<sysproperty key="HPSF.testdata.path"
value="${xlayout.source.test.dir}/org/apache/poi/hpsf/data"/>
<classpath>
<path>
<fileset dir="." casesensitive="yes">
<patternset>
<include name="${cents.dir}/*.${cent.dir.suffix}/${cent.lib.dir.name}/*.jar"/>
<include name="${cents.dir}/*.${cent.dir.suffix}/${cent.lib.dir.name}/*.zip"/>
</patternset>
</fileset>
<fileset dir="${xlayout.library.dir}" casesensitive="yes">
<patternset>
<include name="*/*.jar"/>
<include name="*/*.zip"/>
</patternset>
</fileset>
<fileset dir="${xlayout.source.scratchpad.library.dir}" casesensitive="yes">
<patternset>
<include name="*.jar"/>
<include name="*.zip"/>
</patternset>
</fileset>
<fileset dir="${xlayout.source.examples.library.dir}" casesensitive="yes">
<patternset>
<include name="*.jar"/>
<include name="*.zip"/>
</patternset>
</fileset>
</path>
<pathelement path="${xlayout.build.classes.dir}" />
<pathelement location="${xlayout.build.test.dir}" />
<pathelement location="${xlayout.build.classes.dir}" />
</classpath>
<test name="${testcase}" />
</junit2>
</target>
<target name="compile-tests" depends="-init,compile">
<mkdir dir="${xlayout.build.test.dir}"/>
<!-- Compile tests -->
<javac srcdir="${xlayout.source.test.dir}"
destdir="${xlayout.build.test.dir}"
debug= "${build.compiler.debug}"
optimize= "${build.compiler.optimize}"
deprecation="${build.compiler.deprecation}"
target= "${build.compiler.vm}"
nowarn= "false">
<classpath>
<path>
<fileset dir="." casesensitive="yes">
<patternset>
<include name="${cents.dir}/*.${cent.dir.suffix}/${cent.lib.dir.name}/*.jar"/>
<include name="${cents.dir}/*.${cent.dir.suffix}/${cent.lib.dir.name}/*.zip"/>
</patternset>
</fileset>
<fileset dir="${xlayout.library.dir}" casesensitive="yes">
<patternset>
<include name="*/*.jar"/>
<include name="*/*.zip"/>
</patternset>
</fileset>
<fileset dir="${xlayout.source.scratchpad.library.dir}" casesensitive="yes">
<patternset>
<include name="*.jar"/>
<include name="*.zip"/>
</patternset>
</fileset>
<fileset dir="${xlayout.source.examples.library.dir}" casesensitive="yes">
<patternset>
<include name="*.jar"/>
<include name="*.zip"/>
</patternset>
</fileset>
</path>
<pathelement path="${xlayout.build.classes.dir}" />
</classpath>
</javac>
</target>
</project>

131
centibuild.xml Normal file
View File

@ -0,0 +1,131 @@
<?xml version="1.0"?>
<project default="interactive" basedir="." name="project build file">
<description>
* ===================================== *
| Krysalis Centipede Build System |
* ===================================== *
by
Nicola Ken Barozzi (nicolaken@apache.org)
Marc Johnson (mjohnson@apache.org)
For a simple interactive build, simply
run the build script (build.bar or build.sh)
</description>
<import file="${ant.home}/src/core/xbuild.xml"/>
<taskdef file="${ant.home}/src/core/tasks.properties"/>
<importcent name="java" />
<importcent name="junit" />
<!-- commenting these out till the base build works on Gump
<importcent name="checkstyle" />
<importcent name="forrest" />
<importcent name="changelog" />
<importcent name="changelog" />
-->
<!-- =================================================================== -->
<!-- Basic build targets for the project -->
<!-- =================================================================== -->
<!-- =================================================================== -->
<!-- Interactive build -->
<!-- =================================================================== -->
<target name="interactive" description="Interactive Build">
<echo>
--------------------------------------------------------------
${jxpath:/references/module.xml/root/module/project[1]/@name} [${YEAR}]
--------------------------------------------------------------
Using ${ant.version}
Build file ${ant.file}
--------------------------------------------------------------
These are the most common build targets.
You can also invoke them directly; see build.xml for more info.
Builds will be in /build directory, distributions in /dist.
all -------------- creates the jars and the site
compile ---------- compiles the source code
test ------------- performs the jUnit tests
jar -------------- create the jar files
docs ------------- generates the html docs - clean not needed
javadocs --------- generates the API documentation
site ------------- generates the html site (docs+reports)
clean ------------ cleans the build directory
dist ------------- creates src and bin distributions
scratchpad ------- build-run scratchpad code
contrib ---------- build-run contributed code
generate-records - generate excel records
generate-types --- generate word types
poibrowser - POIBrowser 0.10 GUI POI Viewer
sheetviewer - SheetViewer 0.20 GUI Applet/Application Viewer for XLS files
</echo>
<input message="Please select a target "
addproperty="input.selection"/>
<condition property="do.abort">
<equals arg1="" arg2="input.selection" />
</condition>
<fail if="do.abort">Build aborted by user.</fail>
<antrun target="splash"/>
<antrun target="${input.selection}"/>
</target>
<!-- ================================== -->
<!-- Generate records -->
<!-- ================================== -->
<target name="generate-records"
description="generate-records">
<ant antfile="${project.src.dir}/targets/record-generation/xbuild.xml"
target="generate-records"/>
</target>
<!-- ================================== -->
<!-- Generate types -->
<!-- ================================== -->
<target name="generate-types"
description="generate-types">
<ant antfile="${project.src.dir}/targets/record-generation/xbuild.xml"
target="generate-types"/>
</target>
<!-- ================================== -->
<!-- Target used by Gump -->
<!-- ================================== -->
<target name="gump"
depends="compile, package, test"
description="Target used by Gump"/>
<!-- ================================== -->
<!-- Generate all -->
<!-- ================================== -->
<target name="all"
depends="package"
description="Generate all"/>
</project>

119
index.html Normal file
View File

@ -0,0 +1,119 @@
<html>
<head>
<title>Apache Jakarta POI</title>
<style type="text/css">
body { color: #000000;
background-color: #ffffff; }
a:active { color: #ff0000; }
a:visited { color: #551a8b; }
a:link { color: #0000bb; }
a.title { font-weight: bold; font-size: 110%; }
h1, h2, h3, h4, h5, h6 { font-family: avantgarde, sans-serif;
font-weight: bold }
h1 { font-size: 180% }
h2 { font-size: 150% }
h3, h4 { font-size: 120% }
ul { margin-left: 1em; padding: 0pt; border: 0pt; }
</style>
</head>
<body>
<table align="center" height="40" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><img src="src/documentation/images/group-logo.gif"/></td>
<td align="center" width="100%"></td>
<td><img src="src/documentation/images/poi-logo.png"/></td>
</tr>
</table>
<hr hr="hr"/>
<div align="center" class="titlepage">
<h1>Apache Jakarta POI</h1>
<p>
<strong>Version 1.5-dev</strong>
<br br="br"/>
<strong><script language="JavaScript">
<!-- Begin
var m = document.lastModified;
var p = m.length-8;
document.write(m.substring(p, 0));
// End -->
</script></strong>
</p>
</div>
<table align="center">
<tbody>
<tr><td>
<ul>
<li> <a href="status.xml" class="title">status.xml</a>
<br br="br"/>(status of the project and community)</li>
<li> <a href="module.xml" class="title">module.xml</a>
<br br="br"/>(extended Gump descriptor of the software module)</li>
<li> <a href="build.xml" class="title">build.xml</a>
<br br="br"/>(main build file)</li>
<li> <a href="layout.xml" class="title">layout.xml</a>
<br br="br"/>(layout of the project directories)</li>
<li> <a href="properties.xml" class="title">properties.xml</a>
<br br="br"/>(properties used for building the project)</li>
</ul>
</td>
<td>
<ul>
<li> <a href="build/docs/index.html" class="title">Documentation</a>
<br br="br"/>(run "build docs" first)</li>
<li> <a href="build/docs/javadocs/index.html" class="title">Javadocs</a>
<br br="br"/>(run "build javadocs" first)</li>
<li> <a href="build/docs/tests/junit/index.html" class="title">Unit test results</a>
<br br="br"/>(run "build test" first)</li>
<li> <a href="build/docs/metrics/jdepend/index.html" class="title">Code metrics</a>
<br br="br"/>(run "build metrics" first)</li>
<li> <a href="build.number" class="title">Local build number</a>
<br br="br"/>(how many builds have been done locally)</li>
</ul>
</td>
</tr>
<tr>
<td>
<br/>
<ul>
<li> <a href="http://jakarta.apache.org/poi/" class="title"
>Project Site</a>
<br br="br"/>(online)</li>
</ul>
</td>
<td>
<br/>
<ul>
<li> <a href="http://www.krysalis.org/centipede/" class="title"
>Krysalis Centipede build system site</a>
<br br="br"/>(online)</li>
</ul>
</td>
</tr>
</tbody>
</table>
<br/>
<address>
<hr hr="hr"/>
Copyright &#x00A9;2002 Apache Software Foundation. All Rights Reserved.
</address>
</body>
</html>

77
layout.xml Normal file
View File

@ -0,0 +1,77 @@
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="tools/antipede/resources/stylesheets/layout.xsl"?>
<layout dir=".">
<legal dir="./legal"/>
<library dir="./lib">
<endorsed dir="./lib/endorsed"/>
<core dir="./lib/core"/>
<optional dir="./lib/optional"/>
</library>
<source dir="./src">
<targets dir="./src/targets"/>
<java dir="./src/java"/>
<test dir="./src/testcases"/>
<documentation dir="./src/documentation">
<content dir="./src/documentation/xdocs">
<xdocs dir="./src/documentation/xdocs"/>
</content>
<resources dir="./src/documentation/images">
<images dir="./src/documentation/images"/>
</resources>
</documentation>
<scratchpad dir="./src/scratchpad">
<targets dir="./src/scratchpad/targets"/>
<java dir="./src/scratchpad/src"/>
<library dir="./src/scratchpad/lib"/>
</scratchpad>
<contributions dir="./src/contrib">
<targets dir="./src/contrib/targets"/>
<java dir="./src/contrib/src"/>
<library dir="./src/contrib/lib"/>
</contributions>
<examples dir="./src/examples">
<targets dir="./src/examples/targets"/>
<java dir="./src/examples/src"/>
<library dir="./src/examples/lib"/>
</examples>
</source>
<build dir="./build">
<java dir="./build/java"/>
<classes dir="./build/classes"/>
<test dir="./build/testcases"/>
<work dir="./build/work"/>
<documentation dir="./build/docs">
<javadocs dir="./build/docs/javadocs"/>
<test dir="./build/docs/tests"/>
<metrics dir="./build/docs/metrics"/>
</documentation>
<scratchpad dir="./build/scratchpad">
<java dir="./build/scratchpad/java"/>
<classes dir="./build/scratchpad/classes"/>
<library dir="./build/scratchpad/lib"/>
</scratchpad>
<contributions dir="./build/contrib">
<java dir="./build/contrib/java"/>
<classes dir="./build/contrib/classes"/>
<library dir="./build/contrib/lib"/>
</contributions>
<examples dir="./build/examples">
<java dir="./build/examples/java"/>
<classes dir="./build/examples/classes"/>
<library dir="./build/examples/lib"/>
</examples>
</build>
<distributions dir="./dist">
<source dir="./dist/src"/>
<bin dir="./dist/bin">
<library dir="./dist/bin/lib">
<core dir="./dist/bin/lib"/>
<optional dir="./dist/bin/lib/optional"/>
</library>
<documentation dir="./dist/bin/build/docs"/>
<info dir="./dist/bin"/>
<build dir="./dist/bin/build"/>
<legal dir="./dist/bin/legal"/>
</bin>
</distributions>
</layout>

590
legal/LICENSE Normal file → Executable file
View File

@ -1,537 +1,53 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed 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.
APACHE POI SUBCOMPONENTS:
Apache POI includes subcomponents with separate copyright notices and
license terms. Your use of these subcomponents is subject to the terms
and conditions of the following licenses:
Office Open XML schemas (ooxml-schemas-1.*.jar)
The Office Open XML schema definitions used by Apache POI are
a part of the Office Open XML ECMA Specification (ECMA-376, [1]).
As defined in section 9.4 of the ECMA bylaws [2], this specification
is available to all interested parties without restriction:
9.4 All documents when approved shall be made available to
all interested parties without restriction.
Furthermore, both Microsoft and Adobe have granted patent licenses
to this work [3,4,5].
[1] http://www.ecma-international.org/publications/standards/Ecma-376.htm
[2] http://www.ecma-international.org/memento/Ecmabylaws.htm
[3] http://www.microsoft.com/openspecifications/en/us/programs/osp/default.aspx
[4] http://www.ecma-international.org/publications/files/ECMA-ST/Ecma%20PATENT/
Patent%20statements%20ok/ECMA-376%20Edition%202%20Microsoft%20Patent%20Declaration.pdf
[5] http://www.ecma-international.org/publications/files/ECMA-ST/Ecma%20PATENT/
Patent%20statements%20ok/ECMA-376%20Adobe%20Patent%20Declaration.pdf
Bouncy Castle library (bcprov-*.jar, bcpg-*.jar, bcpkix-*.jar)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to
deal in the Software without restriction, including without limitation the
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
sell copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
IN THE SOFTWARE.
JUnit test library (junit-4.*.jar) & JaCoCo (*jacoco*)
Eclipse Public License - v 1.0
THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC
LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM
CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
1. DEFINITIONS
"Contribution" means:
a) in the case of the initial Contributor, the initial code and documentation
distributed under this Agreement, and
b) in the case of each subsequent Contributor:
i) changes to the Program, and
ii) additions to the Program;
where such changes and/or additions to the Program originate from and are
distributed by that particular Contributor. A Contribution 'originates' from
a Contributor if it was added to the Program by such Contributor itself or
anyone acting on such Contributor's behalf. Contributions do not include
additions to the Program which: (i) are separate modules of software
distributed in conjunction with the Program under their own license agreement,
and (ii) are not derivative works of the Program.
"Contributor" means any person or entity that distributes the Program.
"Licensed Patents" mean patent claims licensable by a Contributor which are
necessarily infringed by the use or sale of its Contribution alone or when
combined with the Program.
"Program" means the Contributions distributed in accordance with this Agreement.
"Recipient" means anyone who receives the Program under this Agreement,
including all Contributors.
2. GRANT OF RIGHTS
a) Subject to the terms of this Agreement, each Contributor hereby grants
Recipient a non-exclusive, worldwide, royalty-free copyright license to
reproduce, prepare derivative works of, publicly display, publicly
perform, distribute and sublicense the Contribution of such Contributor,
if any, and such derivative works, in source code and object code form.
b) Subject to the terms of this Agreement, each Contributor hereby grants
Recipient a non-exclusive, worldwide, royalty-free patent license under
Licensed Patents to make, use, sell, offer to sell, import and otherwise
transfer the Contribution of such Contributor, if any, in source code
and object code form. This patent license shall apply to the combination
of the Contribution and the Program if, at the time the Contribution is
added by the Contributor, such addition of the Contribution causes such
combination to be covered by the Licensed Patents. The patent license
shall not apply to any other combinations which include the Contribution.
No hardware per se is licensed hereunder.
c) Recipient understands that although each Contributor grants the licenses
to its Contributions set forth herein, no assurances are provided by any
Contributor that the Program does not infringe the patent or other
intellectual property rights of any other entity. Each Contributor
disclaims any liability to Recipient for claims brought by any other
entity based on infringement of intellectual property rights or
otherwise. As a condition to exercising the rights and licenses granted
hereunder, each Recipient hereby assumes sole responsibility to secure
any other intellectual property rights needed, if any. For example, if
a third party patent license is required to allow Recipient to distribute
the Program, it is Recipient's responsibility to acquire that license
before distributing the Program.
d) Each Contributor represents that to its knowledge it has sufficient
copyright rights in its Contribution, if any, to grant the copyright
license set forth in this Agreement.
3. REQUIREMENTS
A Contributor may choose to distribute the Program in object code form under
its own license agreement, provided that:
a) it complies with the terms and conditions of this Agreement; and
b) its license agreement:
i) effectively disclaims on behalf of all Contributors all warranties and
conditions, express and implied, including warranties or conditions of
title and non-infringement, and implied warranties or conditions of
merchantability and fitness for a particular purpose;
ii) effectively excludes on behalf of all Contributors all liability for
damages, including direct, indirect, special, incidental and
consequential damages, such as lost profits;
iii) states that any provisions which differ from this Agreement are
offered by that Contributor alone and not by any other party; and
iv) states that source code for the Program is available from such
Contributor, and informs licensees how to obtain it in a reasonable
manner on or through a medium customarily used for software exchange.
When the Program is made available in source code form:
a) it must be made available under this Agreement; and
b) a copy of this Agreement must be included with each copy of the Program.
Contributors may not remove or alter any copyright notices contained
within the Program.
Each Contributor must identify itself as the originator of its Contribution,
if any, in a manner that reasonably allows subsequent Recipients to identify
the originator of the Contribution.
4. COMMERCIAL DISTRIBUTION
Commercial distributors of software may accept certain responsibilities with
respect to end users, business partners and the like. While this license is
intended to facilitate the commercial use of the Program, the Contributor
who includes the Program in a commercial product offering should do so in a
manner which does not create potential liability for other Contributors.
Therefore, if a Contributor includes the Program in a commercial product
offering, such Contributor ("Commercial Contributor") hereby agrees to
defend and indemnify every other Contributor ("Indemnified Contributor")
against any losses, damages and costs (collectively "Losses") arising from
claims, lawsuits and other legal actions brought by a third party against
the Indemnified Contributor to the extent caused by the acts or omissions
of such Commercial Contributor in connection with its distribution of the
Program in a commercial product offering. The obligations in this section
do not apply to any claims or Losses relating to any actual or alleged
intellectual property infringement. In order to qualify, an Indemnified
Contributor must: a) promptly notify the Commercial Contributor in writing
of such claim, and b) allow the Commercial Contributor to control, and
cooperate with the Commercial Contributor in, the defense and any related
settlement negotiations. The Indemnified Contributor may participate in any
such claim at its own expense.
For example, a Contributor might include the Program in a commercial product
offering, Product X. That Contributor is then a Commercial Contributor. If
that Commercial Contributor then makes performance claims, or offers
warranties related to Product X, those performance claims and warranties are
such Commercial Contributor's responsibility alone. Under this section, the
Commercial Contributor would have to defend claims against the other
Contributors related to those performance claims and warranties, and if a
court requires any other Contributor to pay any damages as a result, the
Commercial Contributor must pay those damages.
5. NO WARRANTY
EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON
AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER
EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR
CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A
PARTICULAR PURPOSE. Each Recipient is solely responsible for determining the
appropriateness of using and distributing the Program and assumes all risks
associated with its exercise of rights under this Agreement , including but
not limited to the risks and costs of program errors, compliance with
applicable laws, damage to or loss of data, programs or equipment, and
unavailability or interruption of operations.
6. DISCLAIMER OF LIABILITY
EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY
CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION
LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE
EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY
OF SUCH DAMAGES.
7. GENERAL
If any provision of this Agreement is invalid or unenforceable under
applicable law, it shall not affect the validity or enforceability of the
remainder of the terms of this Agreement, and without further action by the
parties hereto, such provision shall be reformed to the minimum extent
necessary to make such provision valid and enforceable.
If Recipient institutes patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Program itself
(excluding combinations of the Program with other software or hardware)
infringes such Recipient's patent(s), then such Recipient's rights granted
under Section 2(b) shall terminate as of the date such litigation is filed.
All Recipient's rights under this Agreement shall terminate if it fails to
comply with any of the material terms or conditions of this Agreement and
does not cure such failure in a reasonable period of time after becoming
aware of such noncompliance. If all Recipient's rights under this Agreement
terminate, Recipient agrees to cease use and distribution of the Program as
soon as reasonably practicable. However, Recipient's obligations under this
Agreement and any licenses granted by Recipient relating to the Program
shall continue and survive.
Everyone is permitted to copy and distribute copies of this Agreement, but
in order to avoid inconsistency the Agreement is copyrighted and may only
be modified in the following manner. The Agreement Steward reserves the
right to publish new versions (including revisions) of this Agreement from
time to time. No one other than the Agreement Steward has the right to
modify this Agreement. The Eclipse Foundation is the initial Agreement
Steward. The Eclipse Foundation may assign the responsibility to serve as
the Agreement Steward to a suitable separate entity. Each new version of
the Agreement will be given a distinguishing version number. The Program
(including Contributions) may always be distributed subject to the version
of the Agreement under which it was received. In addition, after a new
version of the Agreement is published, Contributor may elect to distribute
the Program (including its Contributions) under the new version. Except as
expressly stated in Sections 2(a) and 2(b) above, Recipient receives no
rights or licenses to the intellectual property of any Contributor under
this Agreement, whether expressly, by implication, estoppel or otherwise.
All rights in the Program not expressly granted under this Agreement are
reserved.
This Agreement is governed by the laws of the State of New York and the
intellectual property laws of the United States of America. No party to this
Agreement will bring a legal action under this Agreement more than one year
after the cause of action arose. Each party waives its rights to a jury
trial in any resulting litigation.
Hamcrest library (hamcrest-*.jar) & CuvesAPI / Curve API
BSD License
Copyright (c) 2000-2006, www.hamcrest.org
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer. Redistributions in binary
form must reproduce the above copyright notice, this list of conditions and
the following disclaimer in the documentation and/or other materials
provided with the distribution.
Neither the name of Hamcrest nor the names of its contributors may be used
to endorse or promote products derived from this software without specific
prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
SLF4J library (slf4j-api-*.jar)
Copyright (c) 2004-2013 QOS.ch
All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
inbot-utils (https://github.com/Inbot/inbot-utils)
The MIT License (MIT)
Copyright (c) 2015 Inbot
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache POI" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache POI", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/

48
legal/LICENSE.ant Normal file
View File

@ -0,0 +1,48 @@
/*
* ============================================================================
* The Apache Software License, Version 1.1
* ============================================================================
*
* Copyright (C) 1999 The Apache Software Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modifica-
* tion, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. The end-user documentation included with the redistribution, if any, must
* include the following acknowledgment: "This product includes software
* developed by the Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself, if
* and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Ant" and "Apache Software Foundation" must not be used to
* endorse or promote products derived from this software without prior
* written permission. For written permission, please contact
* apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache", nor may
* "Apache" appear in their name, without prior written permission of the
* Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
* DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* on behalf of the Apache Software Foundation. For more information on the
* Apache Software Foundation, please see <http://www.apache.org/>.
*
*/

50
legal/LICENSE.apache Executable file
View File

@ -0,0 +1,50 @@
/*
============================================================================
The Apache Software License, Version 1.1
============================================================================
Copyright (C) @year@ The Apache Software Foundation. All rights reserved.
Redistribution and use in source and binary forms, with or without modifica-
tion, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. The end-user documentation included with the redistribution, if any, must
include the following acknowledgment: "This product includes software
developed by the Apache Software Foundation (http://www.apache.org/)."
Alternately, this acknowledgment may appear in the software itself, if
and wherever such third-party acknowledgments normally appear.
4. The names "Apache Cocoon" and "Apache Software Foundation" must not be
used to endorse or promote products derived from this software without
prior written permission. For written permission, please contact
apache@apache.org.
5. Products derived from this software may not be called "Apache", nor may
"Apache" appear in their name, without prior written permission of the
Apache Software Foundation.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This software consists of voluntary contributions made by many individuals
on behalf of the Apache Software Foundation and was originally created by
Stefano Mazzocchi <stefano@apache.org>. For more information on the Apache
Software Foundation, please see <http://www.apache.org/>.
*/

View File

@ -0,0 +1,65 @@
/*
* $Header$
* $Revision$
* $Date$
*
* ====================================================================
*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999-2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Commons", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/

52
legal/LICENSE.krysalis Normal file
View File

@ -0,0 +1,52 @@
The Krysalis Patchy Software License, Version 1.1_01
Copyright (c) 2002 Nicola Ken Barozzi. All rights reserved.
This Licence is compatible with the BSD licence as described and
approved by http://www.opensource.org/, and is based on the
Apache Software Licence Version 1.1.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the
distribution.
3. The end-user documentation included with the redistribution,
if any, must include the following acknowledgment:
"This product includes software developed for project
Krysalis (http://www.krysalis.org/)."
Alternately, this acknowledgment may appear in the software itself,
if and wherever such third-party acknowledgments normally appear.
4. The names "Krysalis" and "Nicola Ken Barozzi" and
"Krysalis Centipede" must not be used to endorse or promote products
derived from this software without prior written permission. For
written permission, please contact krysalis@nicolaken.org.
5. Products derived from this software may not be called "Krysalis",
"Krysalis Centipede", nor may "Krysalis" appear in their name,
without prior written permission of Nicola Ken Barozzi.
6. This software may contain voluntary contributions made by many
individuals, who decided to donate the code to this project in
respect of this licence.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE KRYSALIS PROJECT OR
ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
====================================================================

55
legal/LICENSE.xalan Normal file
View File

@ -0,0 +1,55 @@
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xalan" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation and was
* originally based on software copyright (c) 1999, Lotus
* Development Corporation., http://www.lotus.com. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/

56
legal/LICENSE.xerces Normal file
View File

@ -0,0 +1,56 @@
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xerces" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation and was
* originally based on software copyright (c) 1999, International
* Business Machines, Inc., http://www.ibm.com. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/

10
legal/LICENSE.xml-apis Normal file
View File

@ -0,0 +1,10 @@
xml-apis is covered by The Apache Software License, Version 1.1
FIXME: Put license text in here once it is available at
http://cvs.apache.org/viewcvs.cgi/xml-commons/

View File

@ -1,27 +0,0 @@
Apache POI
Copyright 2003-2017 The Apache Software Foundation
This product includes software developed by
The Apache Software Foundation (https://www.apache.org/).
This product contains parts that were originally based on software from BEA.
Copyright (c) 2000-2003, BEA Systems, <http://www.bea.com/> (dead link),
which was acquired by Oracle Corporation in 2008.
<http://www.oracle.com/us/corporate/Acquisitions/bea/index.html>
<https://en.wikipedia.org/wiki/BEA_Systems>
This product contains W3C XML Schema documents. Copyright 2001-2003 (c)
World Wide Web Consortium (Massachusetts Institute of Technology, European
Research Consortium for Informatics and Mathematics, Keio University)
This product contains the Piccolo XML Parser for Java
(http://piccolo.sourceforge.net/). Copyright 2002 Yuval Oren.
This product contains the chunks_parse_cmds.tbl file from the vsdump program.
Copyright (C) 2006-2007 Valek Filippov (frob@df.ru)
This product contains parts of the eID Applet project
<http://eid-applet.googlecode.com> and <https://github.com/e-Contract/eid-applet>.
Copyright (c) 2009-2014
FedICT (federal ICT department of Belgium), e-Contract.be BVBA (https://www.e-contract.be),
Bart Hanssens from FedICT

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
lib/endorsed/xml-apis.jar Normal file

Binary file not shown.

BIN
lib/optional/log4j-core.jar Normal file

Binary file not shown.

129
module.xml Normal file
View File

@ -0,0 +1,129 @@
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="tools/antipede/resources/stylesheets/module.xsl"?>
<?xml-stylesheet type="text/css" href="tools/antipede/resources/stylesheets/module.css"?>
<module name="jakarta-poi">
<url href="http://jakarta.apache.org/poi/"/>
<cvs repository="jakarta"/>
<mailing-lists>
<mailing-list user="developer"
mail="poi-dev@jakarta.apache.org"
subscribe="poi-dev-subscribe@jakarta.apache.org"
unsubscribe="poi-dev-unsubscribe@jakarta.apache.org"/>
</mailing-lists>
<description>
The POI project consists of APIs for manipulating various file formats
based upon Microsoft's OLE 2 Compound Document format using pure Java.
</description>
<detailed>
A common misconception is that POI writes Excel files. POI is the
name of the project. POI contains several components, one of which,
HSSF, writes Excel files. The following are components of the entire
POI project.POIFS is the oldest and most stable part of the project.
It is our port of the OLE 2 Compound Document Format to pure Java.
It supports both read and write functionality. All of our components
ultimately rely on it by definition. HSSF is our port of the
Microsoft Excel 97(-2002) file format (BIFF8) to pure Java.
It supports read and write capability. HDF is our port of the
Microsoft Word 97 file format to pure Java.
It supports read and write capability. This component is in the early
stages of design. Jump in!
</detailed>
<what>
<goal>just do it</goal>
</what>
<why>
Why not?
</why>
<vendor>Apache Software Foundation</vendor>
<licence>This software is released under the Apache Software License 1.1.
For detailed legal and licensing issues, please read the LICENSE.* files
in the /legal directory.
</licence>
<credits>
<credit>This software includes software developed by the Krysalis Project
(http://www.krysalis.org/).
</credit>
</credits>
<project name="jakarta-poi">
<version major="1"
minor="9"
fix ="0"
tag="dev"/>
<package>org.apache.poi</package>
<ant buildfile="centibuild.xml" basedir="." target="gump" vm="1.2">
<property name="ant.home" reference="home" project="krysalis-centipede"/>
</ant>
<!-- Project jars POI *build* strictly depends on -->
<!-- needed for build -->
<depend project="xml-xerces"/>
<depend project="xml-xalan2"/>
<depend project="jakarta-ant"/>
<depend project="jakarta-ant-embed-optional"/>
<depend property="jxpath.jar" project="commons-jxpath"/>
<depend project="ant-contrib"/>
<depend project="krysalis-ant-tasks"/>
<depend project="krysalis-ruper"/>
<depend project="commons-vfs"/>
<depend project="commons-cli"/>
<depend project="jakarta-regexp"/>
<depend project="commons-jjar"/>
<depend project="junit"/>
<!-- needed for POI -->
<depend project="commons-logging"/>
<!-- Project jars POI build can use -->
<option project="jakarta-log4j"/>
<!-- Work dirs to be included in classpath -->
<work nested="build/jakarta-poi/classes"/>
<work nested="build/jakarta-poi/junit/classes"/>
<!-- Build home -->
<home nested="build/jakarta-poi"/>
<!-- Source dirs with type -->
<code type="java/plain" dir="src/java"/>
<test type="test/junit" dir="src/testcases"/>
<documentation type="xml/forrest" dir="src/documentation"/>
<!-- POI jars - the result of the build -->
<jar name="jakarta-poi.jar" id="poi"/>
<!-- POI Javadocs - location in the build dirs -->
<javadoc parent="build/jakarta-poi/docs/apidocs"/>
<!-- Getting ready for automatic site updates
<deliver fromdir="build/jakarta-poi/docs"
tosite="jakarta-apache-org"
todir="poi/" />
-->
<nag to="poi-dev@jakarta.apache.org"
from="Nicola Ken Barozzi &lt;nicolaken@apache.org&gt;"/>
</project>
</module>

101
pom.xml
View File

@ -1,101 +0,0 @@
<?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">
<parent>
<groupId>org.sonatype.oss</groupId>
<artifactId>oss-parent</artifactId>
<version>9</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>com.moparisthebest.poi</groupId>
<artifactId>poi-fast-calc</artifactId>
<version>3.17-SNAPSHOT</version>
<packaging>jar</packaging>
<name>POI Fast Calc</name>
<url>https://code.moparisthebest.com/moparisthebest/poi</url>
<description>POI Fast Calc - Java API To Calculate Excel formulas quickly</description>
<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>moparisthebest.com</name>
<url>https://www.moparisthebest.com</url>
</organization>
<scm>
<connection>scm:git:https://code.moparisthebest.com/moparisthebest/poi.git</connection>
<developerConnection>scm:git:https://code.moparisthebest.com/moparisthebest/poi.git</developerConnection>
<url>https://code.moparisthebest.com/moparisthebest/poi</url>
</scm>
<properties>
<java.version>1.6</java.version>
<maven.compiler.source>${java.version}</maven.compiler.source>
<maven.compiler.target>${java.version}</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<pushChanges>false</pushChanges>
<localCheckout>true</localCheckout>
<!-- default argline for junit tests, java 9+ requires much less memory than 6/7/8, but more runs faster -->
<test.argLine>-Xmx4096m</test.argLine>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
<version>4.12</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.1</version>
<configuration>
<verbose>true</verbose>
<fork>true</fork>
<argLine>${test.argLine}</argLine>
</configuration>
</plugin>
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>1.6.5</version>
<extensions>true</extensions>
<configuration>
<serverId>ossrh</serverId>
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
<autoReleaseAfterClose>true</autoReleaseAfterClose>
</configuration>
</plugin>
</plugins>
</build>
</project>

112
properties.xml Normal file
View File

@ -0,0 +1,112 @@
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="tools/antipede/resources/stylesheets/properties.xsl"?>
<!-- Build properties - these override any property specified in the build -->
<properties>
<!-- Properties of the build -->
<build>
<!-- What to tell the compiler -->
<compiler
emacs="on"
warnings="true"
pedantic="false"
depend="true"
fulldepend="true"
debug="on"
optimize="off"
deprecation="on"
nowarn="off"
type="classic"
vm="1.2" />
</build>
<forrest>
<cent>
<project skin="forrest-site"/>
<project content-dir="src/documentation"/>
<project xdocs-dir="src/documentation/xdocs"/>
<project images-dir="src/documentation/images"/>
</cent>
</forrest>
<java>
<cent>
<javadoc overview="src/java/overview.html" />
<!-- <javadocs group="POIFS org.apache.poi.poifs*,HSSF org.apache.poi.hssf*,HPSF org.apache.poi.hpsf*,">
<altenative views="uml">
<uml prefix="uml-" suffix="" extension="html"/>
</altenative>
</javadocs>
-->
</cent>
</java>
<junit>
<cent>
<extra>
<sysproperty key="UTIL.testdata.path"
value="./src/testcases/org/apache/poi/util/data"/>
<sysproperty key="HSSF.testdata.path"
value="./src/testcases/org/apache/poi/hssf/data"/>
<sysproperty key="HPSF.testdata.path"
value="./src/testcases/org/apache/poi/hpsf/data"/>
</extra>
</cent>
</junit>
<!-- deprecated properties -->
<centipede>
<tools>
<cents repository="http://krysalis.org/jars/">
<!-- not currently used by POI
<antidote/>
<xmldoclet/> -->
<centipede>
<javadocs group="POIFS org.apache.poi.poifs*,HSSF org.apache.poi.hssf*,HPSF org.apache.poi.hpsf*,">
<altenative views="uml">
<uml prefix="uml-" suffix="" extension="html"/>
</altenative>
</javadocs>
</centipede>
<junit/>
<jdepend/>
<checkstyle/>
<javasrc/>
<umldoclet/>
<forrest>
<!-- available skins:
basic
jakarta-site
avalon-site
scarab-site
xml-apache-site
forrest-site (Work In Progress)
-->
<skin
name="avalon-site">
<navlinks>
<link1
href="http://www.apache.org/">apache</link1>
<link2
href="http://jakarta.apache.org/">jakarta</link2>
<link3
href="http://jakarta.apache.org/poi/">POI</link3>
</navlinks>
<logo>
<group
src="images/group-logo.gif"
href="http://jakarta.apache.org" />
<project
src="images/poi-logo.png"
href="http://jakarta.apache.org/poi/" />
</logo>
</skin>
</forrest>
</cents>
</tools>
</centipede>
</properties>

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1 @@
CVS happy

View File

@ -0,0 +1,270 @@
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2000 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
* Portions of this software are based upon public domain software
* originally written at the National Center for Supercomputing Applications,
* University of Illinois, Urbana-Champaign.
*/
package org.apache.poi.contrib.poibrowser;
import java.io.*;
import java.util.*;
import org.apache.poi.hpsf.ClassID;
/**
* <p>Provides utility methods for encoding and decoding hexadecimal
* data.</p>
*
* @author Rainer Klute (klute@rainer-klute.de) - with portions from Tomcat
* @version $Id$
* @since 2002-01-24
*/
public class Codec
{
/**
* <p>The nibbles' hexadecimal values. A nibble is a half byte.</p>
*/
protected static final byte hexval[] =
{(byte) '0', (byte) '1', (byte) '2', (byte) '3',
(byte) '4', (byte) '5', (byte) '6', (byte) '7',
(byte) '8', (byte) '9', (byte) 'A', (byte) 'B',
(byte) 'C', (byte) 'D', (byte) 'E', (byte) 'F'};
/**
* <p>Converts a string into its hexadecimal notation.</p>
*
* <p><strong>FIXME:</strong> If this method is called frequently,
* it should directly implement the algorithm in the called method
* in order to avoid creating a string instance.</p>
*/
public static String hexEncode(final String s)
{
return hexEncode(s.getBytes());
}
/**
* <p>Converts a byte array into its hexadecimal notation.</p>
*/
public static String hexEncode(final byte[] s)
{
return hexEncode(s, 0, s.length);
}
/**
* <p>Converts a part of a byte array into its hexadecimal
* notation.</p>
*/
public static String hexEncode(final byte[] s, final int offset,
final int length)
{
StringBuffer b = new StringBuffer(length * 2);
for (int i = offset; i < offset + length; i++)
{
int c = s[i];
b.append((char) hexval[(c & 0xF0) >> 4]);
b.append((char) hexval[(c & 0x0F) >> 0]);
}
return b.toString();
}
/**
* <p>Converts a single byte into its hexadecimal notation.</p>
*/
public static String hexEncode(final byte b)
{
StringBuffer sb = new StringBuffer(2);
sb.append((char) hexval[(b & 0xF0) >> 4]);
sb.append((char) hexval[(b & 0x0F) >> 0]);
return sb.toString();
}
/**
* <p>Converts an int value (32-bit) into its hexadecimal
* notation.</p>
*/
public static String hexEncode(final int i)
{
StringBuffer sb = new StringBuffer(8);
sb.append((char) hexval[(i & 0xF0000000) >> 28]);
sb.append((char) hexval[(i & 0x0F000000) >> 24]);
sb.append((char) hexval[(i & 0x00F00000) >> 20]);
sb.append((char) hexval[(i & 0x000F0000) >> 16]);
sb.append((char) hexval[(i & 0x0000F000) >> 12]);
sb.append((char) hexval[(i & 0x00000F00) >> 8]);
sb.append((char) hexval[(i & 0x000000F0) >> 4]);
sb.append((char) hexval[(i & 0x0000000F) >> 0]);
return sb.toString();
}
/**
* <p>Converts a long value (64-bit) into its hexadecimal
* notation.</p>
*/
public static String hexEncode(final long l)
{
StringBuffer sb = new StringBuffer(16);
sb.append((l & 0xFFFFFFFF00000000L) >> 32);
sb.append((l & 0x00000000FFFFFFFFL) >> 0);
return sb.toString();
}
/**
* <p>Converts a class ID into its hexadecimal notation.</p>
*/
public static String hexEncode(final ClassID classID)
{
return hexEncode(classID.getBytes());
}
/**
* <p>Decodes the hexadecimal representation of a sequence of
* bytes into a byte array. Each character in the string
* represents a nibble (half byte) and must be one of the
* characters '0'-'9', 'A'-'F' or 'a'-'f'.</p>
*
* @param s The string to be decoded
*
* @return The bytes
*
* @throw IllegalArgumentException if the string does not contain
* a valid representation of a byte sequence.
*/
public static byte[] hexDecode(final String s)
{
final int length = s.length();
/* The string to be converted must have an even number of
characters. */
if (length % 2 == 1)
throw new IllegalArgumentException
("String has odd length " + length);
byte[] b = new byte[length / 2];
char[] c = new char[length];
s.toUpperCase().getChars(0, length, c, 0);
for (int i = 0; i < length; i += 2)
b[i/2] = (byte) (decodeNibble(c[i]) << 4 & 0xF0 |
decodeNibble(c[i+1]) & 0x0F);
return b;
}
/**
* <p>Decodes a nibble.</p>
*
* @param c A character in the range '0'-'9' or 'A'-'F'. Lower
* case is not supported here.
*
* @return The decoded nibble in the range 0-15
*
* @throws IllegalArgumentException if <em>c</em> is not a
* permitted character
*/
protected static byte decodeNibble(final char c)
{
for (byte i = 0; i < hexval.length; i++)
if ((byte) c == hexval[i])
return i;
throw new IllegalArgumentException("\"" + c + "\"" +
" does not represent a nibble.");
}
/**
* <p>For testing.</p>
*/
public static void main(final String args[])
throws IOException
{
final BufferedReader in =
new BufferedReader(new InputStreamReader(System.in));
String s;
do
{
s = in.readLine();
if (s != null)
{
String bytes = hexEncode(s);
System.out.print("Hex encoded (String): ");
System.out.println(bytes);
System.out.print("Hex encoded (byte[]): ");
System.out.println(hexEncode(s.getBytes()));
System.out.print("Re-decoded (byte[]): ");
System.out.println(new String(hexDecode(bytes)));
}
}
while (s != null);
}
}

View File

@ -0,0 +1,121 @@
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2000 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
* Portions of this software are based upon public domain software
* originally written at the National Center for Supercomputing Applications,
* University of Illinois, Urbana-Champaign.
*/
package org.apache.poi.contrib.poibrowser;
import java.io.*;
import org.apache.poi.poifs.filesystem.*;
/**
* <p>Describes the most important (whatever that is) features of a
* {@link POIFSDocument}.</p>
*
* @author Rainer Klute (klute@rainer-klute.de)
* @version $Id$
* @since 2002-02-05
*/
public class DocumentDescriptor
{
String name;
POIFSDocumentPath path;
DocumentInputStream stream;
int size;
byte[] bytes;
/**
* <p>Creates a {@link DocumentDescriptor}.</p>
*
* @param name The stream's name.
*
* @param path The stream's path in the POI filesystem hierarchy.
*
* @param stream The stream.
*
* @param nrOfBytes The maximum number of bytes to display in a
* dump starting at the beginning of the stream.
*/
public DocumentDescriptor(final String name,
final POIFSDocumentPath path,
final DocumentInputStream stream,
final int nrOfBytes)
{
this.name = name;
this.path = path;
this.stream = stream;
try
{
size = stream.available();
if (stream.markSupported())
{
stream.mark(nrOfBytes);
final byte[] b = new byte[nrOfBytes];
final int read = stream.read(b, 0, Math.min(size, b.length));
bytes = new byte[read];
System.arraycopy(b, 0, bytes, 0, read);
stream.reset();
}
}
catch (IOException ex)
{
System.out.println(ex);
}
}
}

View File

@ -0,0 +1,120 @@
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2000 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
* Portions of this software are based upon public domain software
* originally written at the National Center for Supercomputing Applications,
* University of Illinois, Urbana-Champaign.
*/
package org.apache.poi.contrib.poibrowser;
import java.awt.*;
import javax.swing.*;
import javax.swing.tree.*;
/**
* <p>{@link TreeCellRenderer} for a {@link DocumentDescriptor}. The
* renderer is extremly rudimentary since displays only the document's
* name, its size and its fist few bytes.</p>
*
* @author Rainer Klute (klute@rainer-klute.de)
* @version $Id$
* @since 2002-02-05
*/
public class DocumentDescriptorRenderer extends DefaultTreeCellRenderer
{
public Component getTreeCellRendererComponent(final JTree tree,
final Object value,
final boolean selected,
final boolean expanded,
final boolean leaf,
final int row,
final boolean hasFocus)
{
final DocumentDescriptor d = (DocumentDescriptor)
((DefaultMutableTreeNode) value).getUserObject();
final JPanel p = new JPanel();
final JTextArea text = new JTextArea();
text.append(renderAsString(d));
text.setFont(new Font("Monospaced", Font.PLAIN, 10));
p.add(text);
if (selected)
Util.invert(text);
return p;
}
/**
* <p>Renders {@link DocumentDescriptor} as a string.</p>
*/
protected String renderAsString(final DocumentDescriptor d)
{
final StringBuffer b = new StringBuffer();
b.append("Name: ");
b.append(d.name);
b.append(" (");
b.append(Codec.hexEncode(d.name));
b.append(") \n");
b.append("Size: ");
b.append(d.size);
b.append(" bytes\n");
b.append("First bytes: ");
b.append(Codec.hexEncode(d.bytes));
return b.toString();
}
}

View File

@ -0,0 +1,187 @@
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2000 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
* Portions of this software are based upon public domain software
* originally written at the National Center for Supercomputing Applications,
* University of Illinois, Urbana-Champaign.
*/
package org.apache.poi.contrib.poibrowser;
import java.awt.*;
import javax.swing.*;
import javax.swing.tree.*;
import java.util.*;
/**
* <p>This is a {@link TreeCellRenderer} implementation which is able
* to render arbitrary objects. The {@link ExtendableTreeCellRenderer}
* does not do the rendering itself but instead dispatches to
* class-specific renderers. A class/renderer pair must be registered
* using the {@link #register} method. If a class has no registered
* renderer, the renderer of its closest superclass is used. Since the
* {@link ExtendableTreeCellRenderer} always has a default renderer
* for the {@link Object} class, rendering is always possible. The
* default {@link Object} renderer can be replaced by another renderer
* but it cannot be unregistered.</p>
*
* @author Rainer Klute (klute@rainer-klute.de)
* @version $Id$
* @since 2002-01-22
*/
public class ExtendableTreeCellRenderer implements TreeCellRenderer
{
/**
* <p>Maps classes to renderers.</p>
*/
protected Map renderers;
public ExtendableTreeCellRenderer()
{
renderers = new HashMap();
register(Object.class, new DefaultTreeCellRenderer()
{
public Component getTreeCellRendererComponent
(JTree tree, Object value, boolean selected,
boolean expanded, boolean leaf, int row, boolean hasFocus)
{
final String s = value.toString();
final JLabel l = new JLabel(s + " ");
if (selected)
{
Util.invert(l);
l.setOpaque(true);
}
return l;
}
});
}
/**
* <p>Registers a renderer for a class.</p>
**/
public void register(final Class c, final TreeCellRenderer renderer)
{
renderers.put(c, renderer);
}
/**
* <p>Unregisters a renderer for a class. The renderer for the
* {@link Object} class cannot be unregistered.</p>
*/
public void unregister(final Class c)
{
if (c == Object.class)
throw new IllegalArgumentException
("Renderer for Object cannot be unregistered.");
renderers.put(c, null);
}
/**
* <p>Renders an object in a tree cell depending of the object's
* class.</p>
*
* @see TreeCellRenderer#getTreeCellRendererComponent
*/
public Component getTreeCellRendererComponent
(final JTree tree, final Object value, final boolean selected,
final boolean expanded, final boolean leaf, final int row,
final boolean hasFocus)
{
final String NULL = "null";
TreeCellRenderer r;
Object userObject;
if (value == null)
userObject = NULL;
else
{
userObject = ((DefaultMutableTreeNode) value).getUserObject();
if (userObject == null)
userObject = NULL;
}
r = findRenderer(userObject.getClass());
return r.getTreeCellRendererComponent
(tree, value, selected, expanded, leaf, row,
hasFocus);
}
/**
* <p>Find the renderer for the specified class.</p>
*/
protected TreeCellRenderer findRenderer(final Class c)
{
final TreeCellRenderer r = (TreeCellRenderer) renderers.get(c);
if (r != null)
/* The class has a renderer. */
return r;
/* The class has no renderer, try the superclass, if any. */
final Class superclass = c.getSuperclass();
if (superclass != null)
return findRenderer(superclass);
else
return null;
}
}

View File

@ -0,0 +1,166 @@
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2000 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
* Portions of this software are based upon public domain software
* originally written at the National Center for Supercomputing Applications,
* University of Illinois, Urbana-Champaign.
*/
package org.apache.poi.contrib.poibrowser;
import java.awt.event.*;
import java.io.*;
import javax.swing.*;
import javax.swing.tree.*;
import org.apache.poi.poifs.eventfilesystem.*;
/**
* <p>The main class of the POI Browser. It shows the structure of POI
* filesystems (Microsoft Office documents) in a {@link
* JTree}. Specify their filenames on the command line!</p>
*
* @see POIFSReader
*
* @author Rainer Klute (klute@rainer-klute.de)
* @version $Id$
* @since 2002-01-19
*/
public class POIBrowser extends JFrame
{
/**
* <p>The tree's root node must be visible to all methods.</p>
*/
protected MutableTreeNode rootNode;
/**
* <p>Takes a bunch of file names as command line parameters,
* opens each of them as a POI filesystem and displays their
* internal structures in a {@link JTree}.</p>
*/
public static void main(String[] args)
{
new POIBrowser().run(args);
}
protected void run(String[] args)
{
addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{
System.exit(0);
}
});
/* Create the tree model with a root node. The latter is
* invisible but it must be present because a tree model
* always needs a root. */
rootNode = new DefaultMutableTreeNode("POI Filesystems");
DefaultTreeModel treeModel = new DefaultTreeModel(rootNode);
/* Create the tree UI element. */
final JTree treeUI = new JTree(treeModel);
getContentPane().add(new JScrollPane(treeUI));
/* Add the POI filesystems to the tree. */
int displayedFiles = 0;
for (int i = 0; i < args.length; i++)
{
final String filename = args[i];
try
{
POIFSReader r = new POIFSReader();
r.registerListener(new TreeReaderListener(filename, rootNode));
r.read(new FileInputStream(filename));
displayedFiles++;
}
catch (IOException ex)
{
System.err.println(filename + ": " + ex);
}
catch (Throwable t)
{
System.err.println("Unexpected exception while reading \"" +
filename + "\":");
t.printStackTrace(System.err);
}
}
/* Exit if there is no file to display (none specified or only
* files with problems). */
if (displayedFiles == 0)
{
System.out.println("No POI filesystem(s) to display.");
System.exit(0);
}
/* Make the tree UI element visible. */
treeUI.setRootVisible(true);
treeUI.setShowsRootHandles(true);
ExtendableTreeCellRenderer etcr = new ExtendableTreeCellRenderer();
etcr.register(DocumentDescriptor.class,
new DocumentDescriptorRenderer());
etcr.register(PropertySetDescriptor.class,
new PropertySetDescriptorRenderer());
treeUI.setCellRenderer(etcr);
setSize(600, 450);
setTitle("POI Browser 0.07");
setVisible(true);
}
}

View File

@ -0,0 +1,113 @@
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2000 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
* Portions of this software are based upon public domain software
* originally written at the National Center for Supercomputing Applications,
* University of Illinois, Urbana-Champaign.
*/
package org.apache.poi.contrib.poibrowser;
import java.io.*;
import org.apache.poi.hpsf.*;
import org.apache.poi.poifs.filesystem.*;
/**
* <p>Describes the most important (whatever that is) features of a
* stream containing a {@link PropertySet}.</p>
*
* @author Rainer Klute (klute@rainer-klute.de)
* @version $Id$
* @since 2002-02-05
*/
public class PropertySetDescriptor extends DocumentDescriptor
{
protected PropertySet propertySet;
/**
* <p>Returns this {@link PropertySetDescriptor}'s {@link
* PropertySet}.</p>
*/
public PropertySet getPropertySet()
{
return propertySet;
}
/**
* <p>Creates a {@link PropertySetDescriptor} by reading a {@link
* PropertySet} from a {@link DocumentInputStream}.</p>
*
* @param name The stream's name.
*
* @param path The stream's path in the POI filesystem hierarchy.
*
* @param stream The stream.
*
* @param nrOfBytes The maximum number of bytes to display in a
* dump starting at the beginning of the stream.
*/
public PropertySetDescriptor(final String name,
final POIFSDocumentPath path,
final DocumentInputStream stream,
final int nrOfBytesToDump)
throws NoPropertySetStreamException, MarkUnsupportedException,
UnexpectedPropertySetTypeException, IOException
{
super(name, path, stream, nrOfBytesToDump);
propertySet = PropertySetFactory.create(stream);
}
}

View File

@ -0,0 +1,193 @@
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2000 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
* Portions of this software are based upon public domain software
* originally written at the National Center for Supercomputing Applications,
* University of Illinois, Urbana-Champaign.
*/
package org.apache.poi.contrib.poibrowser;
import java.awt.*;
import java.util.Iterator;
import java.util.List;
import javax.swing.*;
import javax.swing.tree.*;
import org.apache.poi.hpsf.*;
import org.apache.poi.hpsf.wellknown.*;
/**
* <p>Renders a {@link PropertySetDescriptor} by more or less dumping
* the stuff into a {@link JTextArea}.</p>
*
* @author Rainer Klute (klute@rainer-klute.de)
* @version $Id$
* @since 2002-02-05
*/
public class PropertySetDescriptorRenderer extends DocumentDescriptorRenderer
{
public Component getTreeCellRendererComponent(final JTree tree,
final Object value,
final boolean selected,
final boolean expanded,
final boolean leaf,
final int row,
final boolean hasFocus)
{
final PropertySetDescriptor d = (PropertySetDescriptor)
((DefaultMutableTreeNode) value).getUserObject();
final PropertySet ps = d.getPropertySet();
final JPanel p = new JPanel();
final JTextArea text = new JTextArea();
text.setBackground(new Color(200, 255, 200));
text.setFont(new Font("Monospaced", Font.PLAIN, 10));
text.append(renderAsString(d));
text.append("\nByte order: " +
Codec.hexEncode(ps.getByteOrder()));
text.append("\nFormat: " +
Codec.hexEncode(ps.getFormat()));
text.append("\nOS version: " +
Codec.hexEncode(ps.getOSVersion()));
text.append("\nClass ID: " +
Codec.hexEncode(ps.getClassID()));
text.append("\nSection count: " + ps.getSectionCount());
text.append(sectionsToString(ps.getSections()));
p.add(text);
if (ps instanceof SummaryInformation)
{
/* Use the convenience methods. */
final SummaryInformation si = (SummaryInformation) ps;
text.append("\n");
text.append("\nTitle: " + si.getTitle());
text.append("\nSubject: " + si.getSubject());
text.append("\nAuthor: " + si.getAuthor());
text.append("\nKeywords: " + si.getKeywords());
text.append("\nComments: " + si.getComments());
text.append("\nTemplate: " + si.getTemplate());
text.append("\nLast Author: " + si.getLastAuthor());
text.append("\nRev. Number: " + si.getRevNumber());
text.append("\nEdit Time: " + si.getEditTime());
text.append("\nLast Printed: " + si.getLastPrinted());
text.append("\nCreate Date/Time: " + si.getCreateDateTime());
text.append("\nLast Save Date/Time: " + si.getLastSaveDateTime());
text.append("\nPage Count: " + si.getPageCount());
text.append("\nWord Count: " + si.getWordCount());
text.append("\nChar Count: " + si.getCharCount());
// text.append("\nThumbnail: " + si.getThumbnail());
text.append("\nApplication Name: " + si.getApplicationName());
text.append("\nSecurity: " + si.getSecurity());
}
if (selected)
Util.invert(text);
return p;
}
/**
* <p>Returns a string representation of a list of {@link
* Section}s.</p>
*/
protected String sectionsToString(final List sections)
{
final StringBuffer b = new StringBuffer();
int count = 1;
for (Iterator i = sections.iterator(); i.hasNext();)
{
Section s = (Section) i.next();
b.append(toString(s, "Section " + count++));
}
return b.toString();
}
/**
* <p>Returns a string representation of a {@link Section}.</p>
*/
protected String toString(final Section s, final String name)
{
final StringBuffer b = new StringBuffer();
b.append("\n" + name + " Format ID: ");
b.append(Codec.hexEncode(s.getFormatID()));
b.append("\n" + name + " Offset: " + s.getOffset());
b.append("\n" + name + " Section size: " + s.getSize());
b.append("\n" + name + " Property count: " + s.getPropertyCount());
final Property[] properties = s.getProperties();
for (int i = 0; i < properties.length; i++)
{
final Property p = properties[i];
final Object value = p.getValue();
b.append("\n" + name + " ");
b.append("PID_");
b.append(p.getID());
b.append(' ');
b.append(s.getPIDString(p.getID()) + ": ");
if (value instanceof byte[])
{
byte[] b2 = (byte[]) value;
b.append("0x" + Codec.hexEncode(b2, 0, 4));
b.append(' ');
b.append("0x" + Codec.hexEncode(b2, 4, b2.length - 4));
}
else
b.append(value.toString());
}
return b.toString();
}
}

View File

@ -0,0 +1,277 @@
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2000 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
* Portions of this software are based upon public domain software
* originally written at the National Center for Supercomputing Applications,
* University of Illinois, Urbana-Champaign.
*/
package org.apache.poi.contrib.poibrowser;
import java.io.*;
import java.util.*;
import javax.swing.tree.*;
import org.apache.poi.hpsf.*;
import org.apache.poi.poifs.eventfilesystem.*;
import org.apache.poi.poifs.filesystem.*;
/**
* <p>Organizes document information in a tree model in order to be
* e.g. displayed in a Swing {@link JTree}. An instance of this class
* is created with a root tree node ({@link MutableTreeNode}) and
* registered as a {@link POIFSReaderListener} with a {@link
* POIFSReader}. While the latter processes a POI filesystem it calls
* this class' {@link #processPOIFSReaderEvent} for each document it
* has been registered for. This method appends the document it
* processes at the appropriate position into the tree rooted at the
* above mentioned root tree node.</p>
*
* <p>The root tree node should be the root tree node of a {@link
* TreeModel}.</p>
*
* <p>A top-level element in the tree model, i.e. an immediate child
* node of the root node, describes a POI filesystem as such. It is
* suggested to use the file's name (as seen by the operating system)
* but it could be any other string.</p>
*
* <p>The value of a tree node is a {@link DocumentDescriptor}. Unlike
* a {@link POIFSDocument} which may be as heavy as many megabytes, an
* instance of {@link DocumentDescriptor} is a light-weight object and
* contains only some meta-information about a document.</p>
*
* @author Rainer Klute (klute@rainer-klute.de)
* @version $Id$
* @since 2002-01-24
*/
public class TreeReaderListener implements POIFSReaderListener
{
/**
* <p>The tree's root node. POI filesystems get attached to this
* node as children.</p>
*/
protected MutableTreeNode rootNode;
/**
* <p>Maps filenames and POI document paths to their associated
* tree nodes.</p>
*/
protected Map pathToNode;
/**
* <p>The name of the file this {@link TreeReaderListener}
* processes. It is used to identify a top-level element in the
* tree. Alternatively any other string can be used. It is just a
* label which should identify a POI filesystem.</p>
*/
protected String filename;
/**
* <p>Creates a {@link TreeReaderListener} which should then be
* registered with a {@link POIFSReader}.</p>
*
* @param filename The name of the POI filesystem, i.e. the name
* of the file the POI filesystem resides in. Alternatively any
* other string can be used.
*
* @param rootNode All document information will be attached as
* descendands to this tree node.
*/
public TreeReaderListener(final String filename,
final MutableTreeNode rootNode)
{
this.filename = filename;
this.rootNode = rootNode;
pathToNode = new HashMap(15); // Should be a reasonable guess.
}
/** <p>The number of bytes to dump.</p> */
private int nrOfBytes = 50;
public void setNrOfBytes(final int nrOfBytes)
{
this.nrOfBytes = nrOfBytes;
}
public int getNrOfBytes()
{
return nrOfBytes;
}
/**
* <p>A document in the POI filesystem has been opened for
* reading. This method retrieves properties of the document and
* adds them to a tree model.</p>
*/
public void processPOIFSReaderEvent(final POIFSReaderEvent event)
{
DocumentDescriptor d;
final DocumentInputStream is = event.getStream();
if (!is.markSupported())
throw new UnsupportedOperationException(is.getClass().getName() +
" does not support mark().");
/* Try do handle this document as a property set. We receive
* an exception if is no property set and handle it as a
* document of some other format. We are not concerned about
* that document's details. */
try
{
d = new PropertySetDescriptor(event.getName(), event.getPath(),
is, nrOfBytes);
}
catch (HPSFException ex)
{
d = new DocumentDescriptor(event.getName(), event.getPath(),
is, nrOfBytes);
}
catch (Throwable t)
{
System.err.println
("Unexpected exception while processing " +
event.getName() + " in " + event.getPath().toString());
t.printStackTrace(System.err);
throw new RuntimeException(t.getMessage());
}
try
{
is.close();
}
catch (IOException ex)
{
System.err.println
("Unexpected exception while closing " +
event.getName() + " in " + event.getPath().toString());
ex.printStackTrace(System.err);
}
final MutableTreeNode parentNode = getNode(d.path, filename, rootNode);
final MutableTreeNode nameNode = new DefaultMutableTreeNode(d.name);
parentNode.insert(nameNode, 0);
final MutableTreeNode dNode = new DefaultMutableTreeNode(d);
nameNode.insert(dNode, 0);
}
/**
* <p>Locates the parent node for a document entry in the tree
* model. If the parent node does not yet exist it will be
* created, too. This is done recursively, if needed.</p>
*
* @param path The tree node for this path is located.
*
* @param fsName The name of the POI filesystem. This is just a
* string which is displayed in the tree at the top lovel.
*
* @param root The root node.
*/
private MutableTreeNode getNode(final POIFSDocumentPath path,
final String fsName,
final MutableTreeNode root)
{
MutableTreeNode n = (MutableTreeNode) pathToNode.get(path);
if (n != null)
/* Node found in map, just return it. */
return n;
if (path.length() == 0)
{
/* This is the root path of the POI filesystem. Its tree
* node is resp. must be located below the tree node of
* the POI filesystem itself. This is a tree node with the
* POI filesystem's name (this the operating system file's
* name) as its key it the path-to-node map. */
n = (MutableTreeNode) pathToNode.get(fsName);
if (n == null)
{
/* A tree node for the POI filesystem does not yet
* exist. */
n = new DefaultMutableTreeNode(fsName);
pathToNode.put(fsName, n);
root.insert(n, 0);
}
return n;
}
else
{
/* The path is somewhere down in the POI filesystem's
* hierarchy. We need the tree node of this path's parent
* and attach our new node to it. */
final String name = path.getComponent(path.length() - 1);
final POIFSDocumentPath parentPath = path.getParent();
final MutableTreeNode parentNode =
getNode(parentPath, fsName, root);
n = new DefaultMutableTreeNode(name);
pathToNode.put(path, n);
parentNode.insert(n, 0);
return n;
}
}
private String s(final Object o)
{
if (o == null)
return "null";
else
return o.getClass().getName() + '@' + o.hashCode();
}
}

View File

@ -0,0 +1,89 @@
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2000 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
* Portions of this software are based upon public domain software
* originally written at the National Center for Supercomputing Applications,
* University of Illinois, Urbana-Champaign.
*/
package org.apache.poi.contrib.poibrowser;
import java.awt.*;
import javax.swing.*;
/**
* <p>Contains various (well, just one at the moment) static utility
* methods.</p>
*
* @author Rainer Klute (klute@rainer-klute.de)
* @version $Id$
* @since 2002-01-25
*/
public class Util
{
/**
* <p>Makes a Swing component inverted by swapping its foreground
* and background colors. Hint: Depending on your needs it might
* also be a good idea to call <tt>c.setOpaque(true)</tt>.</p>
*/
public static void invert(final JComponent c)
{
final Color invBackground = c.getForeground();
final Color invForeground = c.getBackground();
c.setBackground(invBackground);
c.setForeground(invForeground);
}
}

View File

@ -0,0 +1,62 @@
<!doctype html public "-//W3C//DTD HTML 4.0//EN//">
<html>
<head>
<title></title>
</head>
<body>
<div>
<p>The <strong>POI Browser</strong> is a very simple Swing GUI tool that
displays the internal structure of a Microsoft Office file. It concentrates
on streams in the <em>Horrible Property Set Format (HPSF)</em>. In order to
access these streams the POI Browser uses the package
<tt>org.apache.poi.hpsf</tt>.</p>
<p>A file in Microsoft's Office format can be seen as a filesystem within a
file. For example, a Word document like <var>sample.doc</var> is just a
simple file from the operation system's point of view. However, internally
it is organized into various directories and files. For example,
<var>sample.doc</var> might consist of the three internal files (or
"streams", as Microsoft calls them) <tt>\001CompObj</tt>,
<tt>\005SummaryInformation</tt>, and <tt>WordDocument</tt>. (In these names
\001 and \005 denote the unprintable characters with the character codes 1
and 5, respectively.) A more complicated Word file typically contains a
directory named <tt>ObjectPool</tt> with more directories and files nested
within it.</p>
<p>The POI Browser makes these internal structures visible. It takes one or
more Microsoft files as input on the command line and shows directories and
files in a tree-like structure. On the top-level POI Browser displays the
(operating system) filenames. An internal file (i.e. a "stream" or a
"document") is shown with its name, its size and a hexadecimal dump of its
first bytes.</p>
<p>The POI Browser pays special attention to property set streams. For
example, the <tt>\005SummaryInformation</tt> stream contains information
like title and author of the document. The POI Browser opens every stream
in a POI filesystem. If it encounters a property set stream, it displays
not just its first bytes but analyses the whole stream and displays its
contents in a more or less readable manner.</p>
</div>
</body>
</html>
<!-- Keep this comment at the end of the file
Local variables:
sgml-default-dtd-file:"HTML_4.0_Strict.ced"
mode: html
sgml-omittag:t
sgml-shorttag:nil
sgml-namecase-general:t
sgml-general-insert-case:lower
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
sgml-parent-document:nil
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
-->

View File

@ -0,0 +1,546 @@
package org.apache.poi.hssf.contrib.view;
import java.awt.*;
import javax.swing.border.AbstractBorder;
import org.apache.poi.hssf.usermodel.HSSFCellStyle;
/**
* This is an attempt to implement Excel style borders for the SheetViewer.
* Mostly just overrides stuff so the javadoc won't appear here but will
* appear in the generated stuff.
*
* @author Andrew C. Oliver (acoliver at apache dot org)
* @author Jason Height
*/
public class SVBorder extends AbstractBorder {
private Color northColor = null;
private Color eastColor = null;
private Color southColor = null;
private Color westColor = null;
private int northBorderType = HSSFCellStyle.BORDER_NONE;
private int eastBorderType =HSSFCellStyle.BORDER_NONE;
private int southBorderType = HSSFCellStyle.BORDER_NONE;
private int westBorderType = HSSFCellStyle.BORDER_NONE;
private boolean northBorder=false;
private boolean eastBorder=false;
private boolean southBorder=false;
private boolean westBorder=false;
private boolean selected = false;
public void setBorder(Color northColor, Color eastColor,
Color southColor, Color westColor,
int northBorderType, int eastBorderType,
int southBorderType, int westBorderType,
boolean selected) {
this.eastColor = eastColor;
this.southColor = southColor;
this.westColor = westColor;
this.northBorderType = northBorderType;
this.eastBorderType = eastBorderType;
this.southBorderType = southBorderType;
this.westBorderType = westBorderType;
this.northBorder=northBorderType != HSSFCellStyle.BORDER_NONE;
this.eastBorder=eastBorderType != HSSFCellStyle.BORDER_NONE;
this.southBorder=southBorderType != HSSFCellStyle.BORDER_NONE;
this.westBorder=westBorderType != HSSFCellStyle.BORDER_NONE;
this.selected = selected;
}
public void paintBorder(Component c, Graphics g, int x, int y, int width,
int height) {
Color oldColor = g.getColor();
paintSelectedBorder(g, x, y, width, height);
paintNormalBorders(g, x, y, width, height);
paintDottedBorders(g, x, y, width, height);
paintDashedBorders(g, x, y, width, height);
paintDoubleBorders(g, x, y, width, height);
paintDashDotDotBorders(g, x, y, width, height);
g.setColor(oldColor);
}
/**
* Called by paintBorder to paint the border of a selected cell.
* The paramaters are the Graphics object, location and dimensions of the
* cell.
*/
private void paintSelectedBorder(Graphics g, int x, int y, int width,
int height) {
if (selected) {
//Need to setup thickness of 2
g.setColor(Color.black);
//paint the border
g.drawRect(x,y,width-1,height-1);
//paint the filled rectangle at the bottom left hand position
g.fillRect(x+width-5, y+height-5, 5, 5);
}
}
/**
* Called by paintBorder to paint the various versions of normal line
* borders for a cell.
*/
private void paintNormalBorders(Graphics g, int x, int y, int width,
int height) {
if (northBorder &&
((northBorderType == HSSFCellStyle.BORDER_THIN) ||
(northBorderType == HSSFCellStyle.BORDER_MEDIUM) ||
(northBorderType == HSSFCellStyle.BORDER_THICK)
)
) {
int thickness = getThickness(northBorderType);
g.setColor(northColor);
for (int k=0; k < thickness; k++) {
g.drawLine(x,y+k,width,y+k);
}
}
if (eastBorder &&
((eastBorderType == HSSFCellStyle.BORDER_THIN) ||
(eastBorderType == HSSFCellStyle.BORDER_MEDIUM) ||
(eastBorderType == HSSFCellStyle.BORDER_THICK)
)
) {
int thickness = getThickness(eastBorderType);
g.setColor(eastColor);
for (int k=0; k < thickness; k++) {
g.drawLine(width-k,y,width-k,height);
}
}
if (southBorder &&
((southBorderType == HSSFCellStyle.BORDER_THIN) ||
(southBorderType == HSSFCellStyle.BORDER_MEDIUM) ||
(southBorderType == HSSFCellStyle.BORDER_THICK)
)
) {
int thickness = getThickness(southBorderType);
g.setColor(southColor);
for (int k=0; k < thickness; k++) {
g.drawLine(x,height - k,width,height - k);
}
}
if (westBorder &&
((westBorderType == HSSFCellStyle.BORDER_THIN) ||
(westBorderType == HSSFCellStyle.BORDER_MEDIUM) ||
(westBorderType == HSSFCellStyle.BORDER_THICK)
)
) {
int thickness = getThickness(westBorderType);
g.setColor(westColor);
for (int k=0; k < thickness; k++) {
g.drawLine(x+k,y,x+k,height);
}
}
}
/**
* Called by paintBorder to paint the dotted line
* borders for a cell.
*/
private void paintDottedBorders(Graphics g, int x, int y, int width,
int height) {
if (northBorder &&
northBorderType == HSSFCellStyle.BORDER_DOTTED) {
int thickness = getThickness(northBorderType);
g.setColor(northColor);
for (int k=0; k < thickness; k++) {
for (int xc = x; xc < width; xc=xc+2) {
g.drawLine(xc,y+k,xc,y+k);
}
}
}
if (eastBorder &&
eastBorderType == HSSFCellStyle.BORDER_DOTTED
) {
int thickness = getThickness(eastBorderType);
thickness++; //need for dotted borders to show up east
g.setColor(eastColor);
for (int k=0; k < thickness; k++) {
for (int yc=y;yc < height; yc=yc+2) {
g.drawLine(width-k,yc,width-k,yc);
}
}
}
if (southBorder &&
southBorderType == HSSFCellStyle.BORDER_DOTTED
) {
int thickness = getThickness(southBorderType);
thickness++;
g.setColor(southColor);
for (int k=0; k < thickness; k++) {
for (int xc = x; xc < width; xc=xc+2) {
g.drawLine(xc,height-k,xc,height-k);
}
}
}
if (westBorder &&
westBorderType == HSSFCellStyle.BORDER_DOTTED
) {
int thickness = getThickness(westBorderType);
// thickness++;
g.setColor(westColor);
for (int k=0; k < thickness; k++) {
for (int yc=y;yc < height; yc=yc+2) {
g.drawLine(x+k,yc,x+k,yc);
}
}
}
}
/**
* Called by paintBorder to paint the various versions of dotted line
* borders for a cell.
*/
private void paintDashedBorders(Graphics g, int x, int y, int width,
int height) {
if (northBorder &&
((northBorderType == HSSFCellStyle.BORDER_DASHED) ||
(northBorderType == HSSFCellStyle.BORDER_HAIR))
) {
int thickness = getThickness(northBorderType);
int dashlength = 1;
if (northBorderType == HSSFCellStyle.BORDER_DASHED)
dashlength = 2;
g.setColor(northColor);
for (int k=0; k < thickness; k++) {
for (int xc = x; xc < width; xc=xc+5) {
g.drawLine(xc,y+k,xc+dashlength,y+k);
}
}
}
if (eastBorder &&
((eastBorderType == HSSFCellStyle.BORDER_DASHED) ||
(eastBorderType == HSSFCellStyle.BORDER_HAIR))
) {
int thickness = getThickness(eastBorderType);
thickness++; //need for dotted borders to show up east
int dashlength = 1;
if (eastBorderType == HSSFCellStyle.BORDER_DASHED)
dashlength = 2;
g.setColor(eastColor);
for (int k=0; k < thickness; k++) {
for (int yc=y;yc < height; yc=yc+5) {
g.drawLine(width-k,yc,width-k,yc+dashlength);
}
}
}
if (southBorder &&
((southBorderType == HSSFCellStyle.BORDER_DASHED) ||
(southBorderType == HSSFCellStyle.BORDER_HAIR))
) {
int thickness = getThickness(southBorderType);
thickness++;
int dashlength = 1;
if (southBorderType == HSSFCellStyle.BORDER_DASHED)
dashlength = 2;
g.setColor(southColor);
for (int k=0; k < thickness; k++) {
for (int xc = x; xc < width; xc=xc+5) {
g.drawLine(xc,height-k,xc+dashlength,height-k);
}
}
}
if (westBorder &&
((westBorderType == HSSFCellStyle.BORDER_DASHED) ||
(westBorderType == HSSFCellStyle.BORDER_HAIR))
) {
int thickness = getThickness(westBorderType);
// thickness++;
int dashlength = 1;
if (westBorderType == HSSFCellStyle.BORDER_DASHED)
dashlength = 2;
g.setColor(westColor);
for (int k=0; k < thickness; k++) {
for (int yc=y;yc < height; yc=yc+5) {
g.drawLine(x+k,yc,x+k,yc+dashlength);
}
}
}
}
/**
* Called by paintBorder to paint the double line
* borders for a cell.
*/
private void paintDoubleBorders(Graphics g, int x, int y, int width,
int height) {
if (northBorder &&
northBorderType == HSSFCellStyle.BORDER_DOUBLE) {
g.setColor(northColor);
int leftx=x;
int rightx=width;
// if there are borders on the west or east then
// the second line shouldn't cross them
if (westBorder)
leftx = x+3;
if (eastBorder)
rightx = width-3;
g.drawLine(x,y,width,y);
g.drawLine(leftx,y+2,rightx,y+2);
}
if (eastBorder &&
eastBorderType == HSSFCellStyle.BORDER_DOUBLE
) {
int thickness = getThickness(eastBorderType);
thickness++; //need for dotted borders to show up east
g.setColor(eastColor);
int topy=y;
int bottomy=height;
if (northBorder)
topy=y+3;
if (southBorder)
bottomy=height-3;
g.drawLine(width-1,y,width-1,height);
g.drawLine(width-3,topy,width-3,bottomy);
}
if (southBorder &&
southBorderType == HSSFCellStyle.BORDER_DOUBLE
) {
g.setColor(southColor);
int leftx=y;
int rightx=width;
if (westBorder)
leftx=x+3;
if (eastBorder)
rightx=width-3;
g.drawLine(x,height - 1,width,height - 1);
g.drawLine(leftx,height - 3,rightx,height - 3);
}
if (westBorder &&
westBorderType == HSSFCellStyle.BORDER_DOUBLE
) {
int thickness = getThickness(westBorderType);
// thickness++;
g.setColor(westColor);
int topy=y;
int bottomy=height-3;
if (northBorder)
topy=y+2;
if (southBorder)
bottomy=height-3;
g.drawLine(x,y,x,height);
g.drawLine(x+2,topy,x+2,bottomy);
}
}
/**
* Called by paintBorder to paint the various versions of dash dot dot line
* borders for a cell.
*/
private void paintDashDotDotBorders(Graphics g, int x, int y, int width,
int height) {
if (northBorder &&
((northBorderType == HSSFCellStyle.BORDER_DASH_DOT_DOT) ||
(northBorderType == HSSFCellStyle.BORDER_MEDIUM_DASH_DOT_DOT))
) {
int thickness = getThickness(northBorderType);
g.setColor(northColor);
for (int l=x; l < width;) {
l=l+drawDashDotDot(g, l, y, thickness, true, true);
}
}
if (eastBorder &&
((eastBorderType == HSSFCellStyle.BORDER_DASH_DOT_DOT) ||
(eastBorderType == HSSFCellStyle.BORDER_MEDIUM_DASH_DOT_DOT))
) {
int thickness = getThickness(eastBorderType);
g.setColor(eastColor);
for (int l=y;l < height;) {
//System.err.println("drawing east");
l=l+drawDashDotDot(g,width-1,l,thickness,false,false);
}
}
if (southBorder &&
((southBorderType == HSSFCellStyle.BORDER_DASH_DOT_DOT) ||
(southBorderType == HSSFCellStyle.BORDER_MEDIUM_DASH_DOT_DOT))
) {
int thickness = getThickness(southBorderType);
g.setColor(southColor);
for (int l=x; l < width;) {
//System.err.println("drawing south");
l=l+drawDashDotDot(g, l, height-1, thickness, true, false);
}
}
if (westBorder &&
((westBorderType == HSSFCellStyle.BORDER_DASH_DOT_DOT) ||
(westBorderType == HSSFCellStyle.BORDER_MEDIUM_DASH_DOT_DOT))
) {
int thickness = getThickness(westBorderType);
g.setColor(westColor);
for (int l=y;l < height;) {
//System.err.println("drawing west");
l=l+drawDashDotDot(g,x,l,thickness,false,true);
}
}
}
/**
* Draws one dash dot dot horizontally or vertically with thickness drawn
* incrementally to either the right or left.
*
* @param g graphics object for drawing with
* @param x the x origin of the line
* @param y the y origin of the line
* @param thickness the thickness of the line
* @param horizontal or vertical (true for horizontal)
* @param right/bottom or left/top thickness (true for right or top),
* if true then the x or y origin will be incremented to provide
* thickness, if false, they'll be decremented. For vertical
* borders, x is incremented or decremented, for horizontal its y.
* Just set to true for north and west, and false for east and
* south.
* @returns length - returns the length of the line.
*/
private int drawDashDotDot(Graphics g,int x, int y, int thickness,
boolean horizontal,
boolean rightBottom) {
for (int t=0; t < thickness; t++) {
if (!rightBottom) {
t = 0 - t; //add negative thickness so we go the other way
//then we'll decrement instead of increment.
}
if (horizontal) {
g.drawLine(x,y+t,x+5,y+t);
g.drawLine(x+8,y+t,x+10,y+t);
g.drawLine(x+13,y+t,x+15,y+t);
} else {
g.drawLine(x+t,y,x+t,y+5);
g.drawLine(x+t,y+8,x+t,y+10);
g.drawLine(x+t,y+13,x+t,y+15);
}
}
return 18;
}
/**
* @returns the line thickness for a border based on border type
*/
private int getThickness(int thickness) {
int retval=1;
switch (thickness) {
case HSSFCellStyle.BORDER_THIN:
retval=2;
break;
case HSSFCellStyle.BORDER_MEDIUM:
retval=3;
break;
case HSSFCellStyle.BORDER_THICK:
retval=4;
break;
case HSSFCellStyle.BORDER_DASHED:
retval=1;
break;
case HSSFCellStyle.BORDER_DASH_DOT_DOT:
retval=1;
break;
case HSSFCellStyle.BORDER_MEDIUM_DASH_DOT_DOT:
retval=3;
break;
case HSSFCellStyle.BORDER_HAIR:
retval=1;
break;
default:
retval=1;
}
return retval;
}
}

View File

@ -0,0 +1,256 @@
/*
* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache POI" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache POI", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.poi.hssf.contrib.view;
import java.text.*;
/**
* This class is used to format cells into their fractional format.
*
* I cant be 100% sure that the same fractional value will be displayed as in
* excel but then again it is a lossy formating mode anyway
*
* @author Jason Height
* @created 15 July 2002
*/
public class SVFractionalFormat extends Format {
private short ONE_DIGIT = 1;
private short TWO_DIGIT = 2;
private short THREE_DIGIT = 3;
private short UNITS = 4;
private int units = 1;
private short mode = -1;
/** Constructs a new FractionalFormatter
*
* The formatStr defines how the number will be formatted
* # ?/? Up to one digit
* # ??/?? Up to two digits
* # ???/??? Up to three digits
* # ?/2 In halves
* # ?/4 In quarters
* # ?/8 In eighths
* # ?/16 In sixteenths
* # ?/10 In tenths
* # ?/100 In hundredths
*/
public SVFractionalFormat(String formatStr) {
if ("# ?/?".equals(formatStr))
mode = ONE_DIGIT;
else if ("# ??/??".equals(formatStr))
mode = TWO_DIGIT;
else if ("# ???/???".equals(formatStr))
mode = THREE_DIGIT;
else if ("# ?/2".equals(formatStr)) {
mode = UNITS;
units = 2;
} else if ("# ?/4".equals(formatStr)) {
mode = UNITS;
units = 4;
} else if ("# ?/8".equals(formatStr)) {
mode = UNITS;
units = 8;
} else if ("# ?/16".equals(formatStr)) {
mode = UNITS;
units = 16;
} else if ("# ?/10".equals(formatStr)) {
mode = UNITS;
units = 10;
} else if ("# ?/100".equals(formatStr)) {
mode = UNITS;
units = 100;
}
}
/**
* Returns a fractional string representation of a double to a maximum denominator size
*
* This code has been translated to java from the following web page.
* http://www.codeproject.com/cpp/fraction.asp
* Originally coded in c++ By Dean Wyant dwyant@mindspring.com
* The code on the web page is freely available.
*
* @param f Description of the Parameter
* @param MaxDen Description of the Parameter
* @return Description of the Return Value
*/
private String format(final double f, final int MaxDen) {
long Whole = (long)f;
int sign = 1;
if (f < 0) {
sign = -1;
}
double Precision = 0.00001;
double AllowedError = Precision;
double d = Math.abs(f);
d -= Whole;
double Frac = d;
double Diff = Frac;
long Num = 1;
long Den = 0;
long A = 0;
long B = 0;
long i = 0;
if (Frac > Precision) {
while (true) {
d = 1.0 / d;
i = (long) (d + Precision);
d -= i;
if (A > 0) {
Num = i * Num + B;
}
Den = (long) (Num / Frac + 0.5);
Diff = Math.abs((double) Num / Den - Frac);
if (Den > MaxDen) {
if (A > 0) {
Num = A;
Den = (long) (Num / Frac + 0.5);
Diff = Math.abs((double) Num / Den - Frac);
} else {
Den = MaxDen;
Num = 1;
Diff = Math.abs((double) Num / Den - Frac);
if (Diff > Frac) {
Num = 0;
Den = 1;
// Keeps final check below from adding 1 and keeps Den from being 0
Diff = Frac;
}
}
break;
}
if ((Diff <= AllowedError) || (d < Precision)) {
break;
}
Precision = AllowedError / Diff;
// This calcualtion of Precision does not always provide results within
// Allowed Error. It compensates for loss of significant digits that occurs.
// It helps to round the inprecise reciprocal values to i.
B = A;
A = Num;
}
}
if (Num == Den) {
Whole++;
Num = 0;
Den = 0;
} else if (Den == 0) {
Num = 0;
}
if (sign < 0) {
if (Whole == 0) {
Num = -Num;
} else {
Whole = -Whole;
}
}
return new StringBuffer().append(Whole).append(" ").append(Num).append("/").append(Den).toString();
}
/** This method formats the double in the units specified.
* The usints could be any number but in this current implementation it is
* halves (2), quaters (4), eigths (8) etc
*/
private String formatUnit(double f, int units) {
long Whole = (long)f;
f -= Whole;
long Num = Math.round(f * units);
return new StringBuffer().append(Whole).append(" ").append(Num).append("/").append(units).toString();
}
public final String format(double val) {
if (mode == ONE_DIGIT) {
return format(val, 9);
} else if (mode == TWO_DIGIT) {
return format(val, 99);
} else if (mode == THREE_DIGIT) {
return format(val, 999);
} else if (mode == UNITS) {
return formatUnit(val , units);
}
throw new RuntimeException("Unexpected Case");
}
public StringBuffer format(Object obj,
StringBuffer toAppendTo,
FieldPosition pos) {
if (obj instanceof Number) {
toAppendTo.append(format(((Number)obj).doubleValue()));
return toAppendTo;
}
else throw new IllegalArgumentException("Can only handle Numbers");
}
public Object parseObject(String source,
ParsePosition status) {
//JMH TBD
return null;
}
public Object parseObject(String source)
throws ParseException {
//JMH TBD
return null;
}
public Object clone() {
//JMH TBD
return null;
}
}

View File

@ -0,0 +1,126 @@
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache POI" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache POI", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.poi.hssf.contrib.view;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import javax.swing.*;
import javax.swing.table.*;
import javax.swing.event.*;
import org.apache.poi.hssf.usermodel.*;
/**
* This class presents the row header to the table.
*
*
* @author Jason Height
*/
public class SVRowHeader extends JList {
/** This model simply returns an integer number up to the number of rows
* that are present in the sheet.
*
*/
private class SVRowHeaderModel extends AbstractListModel {
private HSSFSheet sheet;
public SVRowHeaderModel(HSSFSheet sheet) {
this.sheet = sheet;
}
public int getSize() { return sheet.getPhysicalNumberOfRows(); }
public Object getElementAt(int index) {
return Integer.toString(index+1);
}
}
/** Renderes the row number*/
private class RowHeaderRenderer extends JLabel implements ListCellRenderer {
private HSSFSheet sheet;
private int extraHeight;
RowHeaderRenderer(HSSFSheet sheet, JTable table, int extraHeight) {
this.sheet = sheet;
this.extraHeight = extraHeight;
JTableHeader header = table.getTableHeader();
setOpaque(true);
setBorder(UIManager.getBorder("TableHeader.cellBorder"));
setHorizontalAlignment(CENTER);
setForeground(header.getForeground());
setBackground(header.getBackground());
setFont(header.getFont());
}
public Component getListCellRendererComponent( JList list,
Object value, int index, boolean isSelected, boolean cellHasFocus) {
Dimension d = getPreferredSize();
int rowHeight = (int)sheet.getRow(index).getHeightInPoints();
d.height = rowHeight+extraHeight;
setPreferredSize(d);
setText((value == null) ? "" : value.toString());
return this;
}
}
public SVRowHeader(HSSFSheet sheet, JTable table, int extraHeight) {
ListModel lm = new SVRowHeaderModel(sheet);
this.setModel(lm);
setFixedCellWidth(50);
setCellRenderer(new RowHeaderRenderer(sheet, table, extraHeight));
}
}

View File

@ -0,0 +1,243 @@
/*
* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache POI" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache POI", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.poi.hssf.contrib.view;
import java.awt.*;
import java.awt.event.*;
import java.text.*;
import java.util.*;
import javax.swing.*;
import javax.swing.border.*;
import javax.swing.table.*;
import org.apache.poi.hssf.usermodel.*;
import org.apache.poi.hssf.util.HSSFColor;
/**
* Sheet Viewer Table Cell Editor -- not commented via javadoc as it
* nearly completely consists of overridden methods.
*
* @author Jason Height
* @created 16 July 2002
*/
public class SVTableCellEditor extends AbstractCellEditor implements TableCellEditor, ActionListener {
private static final Color black = getAWTColor(new HSSFColor.BLACK());
private static final Color white = getAWTColor(new HSSFColor.WHITE());
private Hashtable colors = HSSFColor.getIndexHash();
private HSSFWorkbook wb;
private JTextField editor;
private HSSFCell editorValue;
public SVTableCellEditor(HSSFWorkbook wb) {
this.wb = wb;
this.editor = new JTextField();
}
/**
* Gets the cellEditable attribute of the SVTableCellEditor object
*
* @return The cellEditable value
*/
public boolean isCellEditable(java.util.EventObject e) {
if (e instanceof MouseEvent) {
return ((MouseEvent) e).getClickCount() >= 2;
}
return false;
}
public boolean shouldSelectCell(EventObject anEvent) {
return true;
}
public boolean startCellEditing(EventObject anEvent) {
System.out.println("Start Cell Editing");
return true;
}
public boolean stopCellEditing() {
System.out.println("Stop Cell Editing");
fireEditingStopped();
return true;
}
public void cancelCellEditing() {
System.out.println("Cancel Cell Editing");
fireEditingCanceled();
}
public void actionPerformed(ActionEvent e) {
System.out.println("Action performed");
stopCellEditing();
}
/**
* Gets the cellEditorValue attribute of the SVTableCellEditor object
*
* @return The cellEditorValue value
*/
public Object getCellEditorValue() {
System.out.println("GetCellEditorValue");
//JMH Look at when this method is called. Should it return a HSSFCell?
return editor.getText();
}
/**
* Gets the tableCellEditorComponent attribute of the SVTableCellEditor object
*
* @return The tableCellEditorComponent value
*/
public Component getTableCellEditorComponent(JTable table, Object value,
boolean isSelected,
int row,
int column) {
System.out.println("GetTableCellEditorComponent");
HSSFCell cell = (HSSFCell) value;
if (cell != null) {
HSSFCellStyle style = cell.getCellStyle();
HSSFFont f = wb.getFontAt(style.getFontIndex());
boolean isbold = f.getBoldweight() > HSSFFont.BOLDWEIGHT_NORMAL;
boolean isitalics = f.getItalic();
int fontstyle = Font.PLAIN;
if (isbold) fontstyle = Font.BOLD;
if (isitalics) fontstyle = fontstyle | Font.ITALIC;
int fontheight = f.getFontHeightInPoints();
if (fontheight == 9) fontheight = 10; //fix for stupid ol Windows
Font font = new Font(f.getFontName(),fontstyle,fontheight);
editor.setFont(font);
if (style.getFillPattern() == HSSFCellStyle.SOLID_FOREGROUND) {
editor.setBackground(getAWTColor(style.getFillForegroundColor(), white));
} else editor.setBackground(white);
editor.setForeground(getAWTColor(f.getColor(), black));
//Set the value that is rendered for the cell
switch (cell.getCellType()) {
case HSSFCell.CELL_TYPE_BLANK:
editor.setText("");
break;
case HSSFCell.CELL_TYPE_BOOLEAN:
if (cell.getBooleanCellValue()) {
editor.setText("true");
} else {
editor.setText("false");
}
break;
case HSSFCell.CELL_TYPE_NUMERIC:
editor.setText(Double.toString(cell.getNumericCellValue()));
break;
case HSSFCell.CELL_TYPE_STRING:
editor.setText(cell.getStringCellValue());
break;
case HSSFCell.CELL_TYPE_FORMULA:
default:
editor.setText("?");
}
switch (style.getAlignment()) {
case HSSFCellStyle.ALIGN_LEFT:
case HSSFCellStyle.ALIGN_JUSTIFY:
case HSSFCellStyle.ALIGN_FILL:
editor.setHorizontalAlignment(SwingConstants.LEFT);
break;
case HSSFCellStyle.ALIGN_CENTER:
case HSSFCellStyle.ALIGN_CENTER_SELECTION:
editor.setHorizontalAlignment(SwingConstants.CENTER);
break;
case HSSFCellStyle.ALIGN_GENERAL:
case HSSFCellStyle.ALIGN_RIGHT:
editor.setHorizontalAlignment(SwingConstants.RIGHT);
break;
default:
editor.setHorizontalAlignment(SwingConstants.LEFT);
break;
}
}
return editor;
}
/** This method retrieves the AWT Color representation from the colour hash table
*
*/
private final Color getAWTColor(int index, Color deflt) {
HSSFColor clr = (HSSFColor)colors.get(new Integer(index));
if (clr == null) return deflt;
return getAWTColor(clr);
}
private static final Color getAWTColor(HSSFColor clr) {
short[] rgb = clr.getTriplet();
return new Color(rgb[0],rgb[1],rgb[2]);
}
}

View File

@ -0,0 +1,315 @@
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache POI" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache POI", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.poi.hssf.contrib.view;
import java.util.Hashtable;
import javax.swing.*;
import javax.swing.table.TableCellRenderer;
import javax.swing.border.*;
import java.awt.Component;
import java.awt.Color;
import java.awt.Rectangle;
import java.awt.Font;
import java.io.Serializable;
import java.text.*;
import org.apache.poi.hssf.usermodel.*;
import org.apache.poi.hssf.util.HSSFColor;
/**
* Sheet Viewer Table Cell Render -- not commented via javadoc as it
* nearly completely consists of overridden methods.
*
* @author Andrew C. Oliver
*/
public class SVTableCellRenderer extends JLabel
implements TableCellRenderer, Serializable
{
protected static Border noFocusBorder = new EmptyBorder(1, 1, 1, 1);
protected SVBorder cellBorder = new SVBorder();
private HSSFWorkbook wb = null;
/** This class holds the references to the predefined cell formats.
*/
private class CellFormatter {
private Format[] textFormatter;
private DecimalFormat generalNumberFormat = new DecimalFormat("0");
public CellFormatter() {
textFormatter = new Format[0x31];
textFormatter[0x01] = new DecimalFormat("0");
textFormatter[0x02] = new DecimalFormat("0.00");
textFormatter[0x03] = new DecimalFormat("#,##0");
textFormatter[0x04] = new DecimalFormat("#,##0.00");
textFormatter[0x05] = new DecimalFormat("$#,##0;$#,##0");
textFormatter[0x06] = new DecimalFormat("$#,##0;$#,##0");
textFormatter[0x07] = new DecimalFormat("$#,##0.00;$#,##0.00");
textFormatter[0x08] = new DecimalFormat("$#,##0.00;$#,##0.00");
textFormatter[0x09] = new DecimalFormat("0%");
textFormatter[0x0A] = new DecimalFormat("0.00%");
textFormatter[0x0B] = new DecimalFormat("0.00E0");
textFormatter[0x0C] = new SVFractionalFormat("# ?/?");
textFormatter[0x0D] = new SVFractionalFormat("# ??/??");
textFormatter[0x0E] = new SimpleDateFormat("M/d/yy");
textFormatter[0x0F] = new SimpleDateFormat("d-MMM-yy");
textFormatter[0x10] = new SimpleDateFormat("d-MMM");
textFormatter[0x11] = new SimpleDateFormat("MMM-yy");
textFormatter[0x12] = new SimpleDateFormat("h:mm a");
textFormatter[0x13] = new SimpleDateFormat("h:mm:ss a");
textFormatter[0x14] = new SimpleDateFormat("h:mm");
textFormatter[0x15] = new SimpleDateFormat("h:mm:ss");
textFormatter[0x16] = new SimpleDateFormat("M/d/yy h:mm");
// 0x17 - 0x24 reserved for international and undocumented 0x25, "(#,##0_);(#,##0)"
//start at 0x26
//jmh need to do colour
//"(#,##0_);[Red](#,##0)"
textFormatter[0x26] = new DecimalFormat("#,##0;#,##0");
//jmh need to do colour
//(#,##0.00_);(#,##0.00)
textFormatter[0x27] = new DecimalFormat("#,##0.00;#,##0.00");
textFormatter[0x28] = new DecimalFormat("#,##0.00;#,##0.00");
//?? textFormatter[0x29] = new DecimalFormat("_(*#,##0_);_(*(#,##0);_(* \"-\"_);_(@_)");
//?? textFormatter[0x2A] = new DecimalFormat("_($*#,##0_);_($*(#,##0);_($* \"-\"_);_(@_)");
//?? textFormatter[0x2B] = new DecimalFormat("_(*#,##0.00_);_(*(#,##0.00);_(*\"-\"??_);_(@_)");
//?? textFormatter[0x2C] = new DecimalFormat("_($*#,##0.00_);_($*(#,##0.00);_($*\"-\"??_);_(@_)");
textFormatter[0x2D] = new SimpleDateFormat("mm:ss");
//?? textFormatter[0x2E] = new SimpleDateFormat("[h]:mm:ss");
textFormatter[0x2F] = new SimpleDateFormat("mm:ss.0");
textFormatter[0x30] = new DecimalFormat("##0.0E0");
}
public String format(short index, Object value) {
if (index == 0)
return value.toString();
if (textFormatter[index] == null)
throw new RuntimeException("Sorry. I cant handle the format code :"+Integer.toHexString(index));
return textFormatter[index].format(value);
}
public String format(short index, double value) {
if (index == 0)
return generalNumberFormat.format(value);
if (textFormatter[index] == null)
throw new RuntimeException("Sorry. I cant handle the format code :"+Integer.toHexString(index));
if (textFormatter[index] instanceof DecimalFormat) {
return ((DecimalFormat)textFormatter[index]).format(value);
}
if (textFormatter[index] instanceof SVFractionalFormat) {
return ((SVFractionalFormat)textFormatter[index]).format(value);
}
throw new RuntimeException("Sorry. I cant handle a non decimal formatter for a decimal value :"+Integer.toHexString(index));
}
public boolean useRedColor(short index, double value) {
return (((index == 0x06)||(index == 0x08)||(index == 0x26) || (index == 0x27)) && (value < 0));
}
}
private final CellFormatter cellFormatter = new CellFormatter();
public SVTableCellRenderer(HSSFWorkbook wb) {
super();
setOpaque(true);
setBorder(noFocusBorder);
this.wb = wb;
}
public Component getTableCellRendererComponent(JTable table, Object value,
boolean isSelected, boolean hasFocus, int row, int column) {
boolean isBorderSet = false;
//If the JTables default cell renderer has been setup correctly the
//value will be the HSSFCell that we are trying to render
HSSFCell c = (HSSFCell)value;
if (c != null) {
HSSFCellStyle s = c.getCellStyle();
HSSFFont f = wb.getFontAt(s.getFontIndex());
setFont(SVTableUtils.makeFont(f));
if (s.getFillPattern() == HSSFCellStyle.SOLID_FOREGROUND) {
setBackground(SVTableUtils.getAWTColor(s.getFillForegroundColor(), SVTableUtils.white));
} else setBackground(SVTableUtils.white);
setForeground(SVTableUtils.getAWTColor(f.getColor(), SVTableUtils.black));
cellBorder.setBorder(SVTableUtils.getAWTColor(s.getTopBorderColor(), SVTableUtils.black),
SVTableUtils.getAWTColor(s.getRightBorderColor(), SVTableUtils.black),
SVTableUtils.getAWTColor(s.getBottomBorderColor(), SVTableUtils.black),
SVTableUtils.getAWTColor(s.getLeftBorderColor(), SVTableUtils.black),
s.getBorderTop(), s.getBorderRight(),
s.getBorderBottom(), s.getBorderLeft(),
hasFocus);
setBorder(cellBorder);
isBorderSet=true;
//Set the value that is rendered for the cell
switch (c.getCellType()) {
case HSSFCell.CELL_TYPE_BLANK:
setValue("");
break;
case HSSFCell.CELL_TYPE_BOOLEAN:
if (c.getBooleanCellValue()) {
setValue("true");
} else {
setValue("false");
}
break;
case HSSFCell.CELL_TYPE_NUMERIC:
short format = s.getDataFormat();
double numericValue = c.getNumericCellValue();
if (cellFormatter.useRedColor(format, numericValue))
setForeground(Color.red);
else setForeground(null);
setValue(cellFormatter.format(format, c.getNumericCellValue()));
break;
case HSSFCell.CELL_TYPE_STRING:
setValue(c.getStringCellValue());
break;
case HSSFCell.CELL_TYPE_FORMULA:
default:
setValue("?");
}
//Set the text alignment of the cell
switch (s.getAlignment()) {
case HSSFCellStyle.ALIGN_LEFT:
case HSSFCellStyle.ALIGN_JUSTIFY:
case HSSFCellStyle.ALIGN_FILL:
setHorizontalAlignment(SwingConstants.LEFT);
break;
case HSSFCellStyle.ALIGN_CENTER:
case HSSFCellStyle.ALIGN_CENTER_SELECTION:
setHorizontalAlignment(SwingConstants.CENTER);
break;
case HSSFCellStyle.ALIGN_GENERAL:
case HSSFCellStyle.ALIGN_RIGHT:
setHorizontalAlignment(SwingConstants.RIGHT);
break;
default:
setHorizontalAlignment(SwingConstants.LEFT);
break;
}
} else {
setValue("");
setBackground(SVTableUtils.white);
}
if (hasFocus) {
if (!isBorderSet) {
//This is the border to paint when there is no border
//and the cell has focus
cellBorder.setBorder(SVTableUtils.black,
SVTableUtils.black,
SVTableUtils.black,
SVTableUtils.black,
HSSFCellStyle.BORDER_NONE,
HSSFCellStyle.BORDER_NONE,
HSSFCellStyle.BORDER_NONE,
HSSFCellStyle.BORDER_NONE,
isSelected);
setBorder(cellBorder);
}
if (table.isCellEditable(row, column)) {
setForeground( UIManager.getColor("Table.focusCellForeground") );
setBackground( UIManager.getColor("Table.focusCellBackground") );
}
} else if (!isBorderSet) {
setBorder(noFocusBorder);
}
// ---- begin optimization to avoid painting background ----
Color back = getBackground();
boolean colorMatch = (back != null) && ( back.equals(table.getBackground()) ) && table.isOpaque();
setOpaque(!colorMatch);
// ---- end optimization to aviod painting background ----
return this;
}
public void validate() {}
public void revalidate() {}
public void repaint(long tm, int x, int y, int width, int height) {}
public void repaint(Rectangle r) { }
protected void firePropertyChange(String propertyName, Object oldValue, Object newValue) {
// Strings get interned...
if (propertyName=="text") {
super.firePropertyChange(propertyName, oldValue, newValue);
}
}
public void firePropertyChange(String propertyName, boolean oldValue, boolean newValue) { }
/**
* Sets the string to either the value or "" if the value is null.
*
*/
protected void setValue(Object value) {
setText((value == null) ? "" : value.toString());
}
}

View File

@ -0,0 +1,123 @@
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache POI" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache POI", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.poi.hssf.contrib.view;
import java.util.Iterator;
import javax.swing.table.*;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFCell;
/**
* Sheet Viewer Table Model - The model for the Sheet Viewer just overrides things.
* @author Andrew C. Oliver
*/
public class SVTableModel extends AbstractTableModel {
private HSSFSheet st = null;
int maxcol = 0;
public SVTableModel(HSSFSheet st, int maxcol) {
this.st = st;
this.maxcol=maxcol;
}
public SVTableModel(HSSFSheet st) {
this.st = st;
Iterator i = st.rowIterator();
while (i.hasNext()) {
HSSFRow row = (HSSFRow)i.next();
if (maxcol < (row.getLastCellNum()+1)) {
this.maxcol = row.getLastCellNum();
}
}
}
public int getColumnCount() {
return this.maxcol+1;
}
public Object getValueAt(int row, int col) {
HSSFRow r = st.getRow(row);
HSSFCell c = null;
if (r != null) {
c = r.getCell((short)col);
}
return c;
}
public int getRowCount() {
return st.getLastRowNum() + 1;
}
public Class getColumnClass(int c) {
return HSSFCell.class;
}
public boolean isCellEditable(int rowIndex, int columnIndex) {
return true;
}
public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
if (aValue != null)
System.out.println("SVTableModel.setValueAt. value type = "+aValue.getClass().getName());
else System.out.println("SVTableModel.setValueAt. value type = null");
}
}

View File

@ -0,0 +1,135 @@
/*
* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache POI" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache POI", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.poi.hssf.contrib.view;
import java.util.*;
import java.awt.*;
import javax.swing.border.*;
import org.apache.poi.hssf.usermodel.*;
import org.apache.poi.hssf.util.*;
/**
* SVTableCell Editor and Renderer helper functions.
*
* @author Jason Height
* @created 16 July 2002
*/
public class SVTableUtils {
private final static Hashtable colors = HSSFColor.getIndexHash();
/** Description of the Field */
public final static Color black = getAWTColor(new HSSFColor.BLACK());
/** Description of the Field */
public final static Color white = getAWTColor(new HSSFColor.WHITE());
/** Description of the Field */
public static Border noFocusBorder = new EmptyBorder(1, 1, 1, 1);
/**
* Creates a new font for a specific cell style
*
* @param wb Description of the Parameter
* @param style Description of the Parameter
* @return Description of the Return Value
*/
public static Font makeFont(HSSFFont font) {
boolean isbold = font.getBoldweight() > HSSFFont.BOLDWEIGHT_NORMAL;
boolean isitalics = font.getItalic();
int fontstyle = Font.PLAIN;
if (isbold) {
fontstyle = Font.BOLD;
}
if (isitalics) {
fontstyle = fontstyle | Font.ITALIC;
}
int fontheight = font.getFontHeightInPoints();
if (fontheight == 9) {
//fix for stupid ol Windows
fontheight = 10;
}
return new Font(font.getFontName(), fontstyle, fontheight);
}
/**
* This method retrieves the AWT Color representation from the colour hash table
*
* @param index Description of the Parameter
* @param deflt Description of the Parameter
* @return The aWTColor value
*/
public final static Color getAWTColor(int index, Color deflt) {
HSSFColor clr = (HSSFColor) colors.get(new Integer(index));
if (clr == null) {
return deflt;
}
return getAWTColor(clr);
}
/**
* Gets the aWTColor attribute of the SVTableUtils class
*
* @param clr Description of the Parameter
* @return The aWTColor value
*/
public final static Color getAWTColor(HSSFColor clr) {
short[] rgb = clr.getTriplet();
return new Color(rgb[0], rgb[1], rgb[2]);
}
}

View File

@ -0,0 +1,207 @@
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache POI" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache POI", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.poi.hssf.contrib.view;
import java.awt.*;
import java.awt.event.*;
import java.net.*;
import java.applet.*;
import java.io.*;
import javax.swing.*;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFCell;
/**
* Sheet Viewer - Views XLS files via HSSF. Can be used as an applet with
* filename="" or as a applications (pass the filename as the first parameter).
* Or you can pass it a URL in a "url" parameter when run as an applet or just
* that first parameter must start with http:// and it will guess its a url. I
* only tested it as an applet though, so it probably won't work...you fix it.
*
* @author Andrew C. Oliver
* @author Jason Height
*/
public class SViewer extends JApplet {
private SViewerPanel panel;
boolean isStandalone = false;
String filename = null;
/**Get a parameter value*/
public String getParameter(String key, String def) {
return isStandalone ? System.getProperty(key, def) :
(getParameter(key) != null ? getParameter(key) : def);
}
/**Construct the applet*/
public SViewer() {
}
/**Initialize the applet*/
public void init() {
try {
jbInit();
}
catch(Exception e) {
e.printStackTrace();
System.exit(1);
}
}
/**Component initialization*/
private void jbInit() throws Exception {
InputStream i = null;
boolean isurl = false;
if (filename == null) filename = getParameter("filename");
if (filename == null || filename.substring(0,7).equals("http://")) {
isurl = true;
if (filename == null) filename = getParameter("url");
i = getXLSFromURL(filename);
}
HSSFWorkbook wb = null;
if (isurl) {
wb = constructWorkbook(i);
} else {
wb = constructWorkbook(filename);
}
panel = new SViewerPanel(wb, false);
getContentPane().setLayout(new BorderLayout());
getContentPane().add(panel, BorderLayout.CENTER);
}
private HSSFWorkbook constructWorkbook(String filename) throws FileNotFoundException, IOException {
HSSFWorkbook wb = null;
FileInputStream in = new FileInputStream(filename);
wb = new HSSFWorkbook(in);
in.close();
return wb;
}
private HSSFWorkbook constructWorkbook(InputStream in) throws IOException {
HSSFWorkbook wb = null;
wb = new HSSFWorkbook(in);
in.close();
return wb;
}
/**Start the applet*/
public void start() {
}
/**Stop the applet*/
public void stop() {
}
/**Destroy the applet*/
public void destroy() {
}
/**Get Applet information*/
public String getAppletInfo() {
return "Applet Information";
}
/**Get parameter info*/
public String[][] getParameterInfo() {
return null;
}
/**
* opens a url and returns an inputstream
*
*/
private InputStream getXLSFromURL(String urlstring) throws MalformedURLException, IOException {
URL url = new URL(urlstring);
URLConnection uc = url.openConnection();
String field = uc.getHeaderField(0);
for (int i=0;field != null; i++) {
System.out.println(field);
field = uc.getHeaderField(i);
}
BufferedInputStream is = new BufferedInputStream(uc.getInputStream());
return is;
}
/**Main method*/
public static void main(String[] args) {
SViewer applet = new SViewer();
applet.isStandalone = true;
applet.filename = args[0];
Frame frame;
frame = new Frame() {
protected void processWindowEvent(WindowEvent e) {
super.processWindowEvent(e);
if (e.getID() == WindowEvent.WINDOW_CLOSING) {
System.exit(0);
}
}
public synchronized void setTitle(String title) {
super.setTitle(title);
enableEvents(AWTEvent.WINDOW_EVENT_MASK);
}
};
frame.setTitle("Applet Frame");
frame.add(applet, BorderLayout.CENTER);
applet.init();
applet.start();
frame.setSize(400,320);
Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
frame.setLocation((d.width - frame.getSize().width) / 2, (d.height - frame.getSize().height) / 2);
frame.setVisible(true);
}
}

View File

@ -0,0 +1,329 @@
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache POI" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache POI", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.poi.hssf.contrib.view;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import javax.swing.*;
import javax.swing.table.*;
import javax.swing.event.*;
import org.apache.poi.hssf.usermodel.*;
/**
* This class presents the sheets to the user.
*
*
* @author Andrew C. Oliver
* @author Jason Height
*/
public class SViewerPanel extends JPanel {
/** This field is the magic number to convert from a Character width to a
* java pixel width.
*
* When the "normal" font size in a workbook changes, this effects all
* of the heights and widths. Unfortunately there is no way to retrieve this
* information, hence the MAGIC number.
*
* This number may only work for the normal style font size of Arial size 10.
*
*/
private static final int magicCharFactor = 7;
/** Reference to the woorkbook that is being displayed*/
private HSSFWorkbook wb;
/** Reference to the tabs component*/
private JTabbedPane sheetPane;
/** Reference to the cell renderer that is used to render all cells*/
private SVTableCellRenderer cellRenderer;
/** Reference to the cell editor that is used to edit all cells.
* Only constructed if editing is allowed
*/
private SVTableCellEditor cellEditor;
/** Flag indicating if editing is allowed. Otherwise the viewer is in
* view only mode.
*/
private boolean allowEdits;
/**Construct the representation of the workbook*/
public SViewerPanel(HSSFWorkbook wb, boolean allowEdits) {
this.wb = wb;
this.allowEdits = allowEdits;
initialiseGui();
}
private void initialiseGui() {
cellRenderer = new SVTableCellRenderer(this.wb);
if (allowEdits)
cellEditor = new SVTableCellEditor(this.wb);
//Initialise the Panel
sheetPane = new JTabbedPane(JTabbedPane.BOTTOM);
if (allowEdits)
sheetPane.addMouseListener(createTabListener());
int sheetCount = wb.getNumberOfSheets();
for (int i=0; i<sheetCount;i++) {
String sheetName = wb.getSheetName(i);
//Add the new sheet to the tabbed pane
sheetPane.addTab(sheetName, makeSheetView(wb.getSheetAt(i)));
}
setLayout(new BorderLayout());
add(sheetPane, BorderLayout.CENTER);
}
protected JComponent makeSheetView(HSSFSheet sheet) {
JTable sheetView = new JTable(new SVTableModel(sheet));
sheetView.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
sheetView.setDefaultRenderer(HSSFCell.class, cellRenderer);
if (allowEdits)
sheetView.setDefaultEditor(HSSFCell.class, cellEditor);
JTableHeader header = sheetView.getTableHeader();
//Dont allow column reordering
header.setReorderingAllowed(false);
//Only allow column resizing if editing is allowed
header.setResizingAllowed(allowEdits);
//Set the columns the correct size
TableColumnModel columns = sheetView.getColumnModel();
for (int i=0; i< columns.getColumnCount(); i++) {
TableColumn column = columns.getColumn(i);
short width = sheet.getColumnWidth((short)i);
//256 is because the width is in 256ths of a character
column.setPreferredWidth(width/256*magicCharFactor);
}
//Set the rows to the correct size
int rows = sheet.getPhysicalNumberOfRows();
Insets insets = cellRenderer.getInsets();
//Need to include the insets in the calculation of the row height to use.
int extraHeight = insets.bottom+insets.top;
for (int i=0; i< rows; i++) {
HSSFRow row = sheet.getRow(i);
if (row == null) {
sheetView.setRowHeight(i, (int)sheet.getDefaultRowHeightInPoints()+extraHeight);
} else {
sheetView.setRowHeight(i, (int)row.getHeightInPoints()+extraHeight);
}
}
//Add the row header to the sheet
SVRowHeader rowHeader = new SVRowHeader(sheet, sheetView, extraHeight);
JScrollPane scroll = new JScrollPane( sheetView );
scroll.setRowHeaderView(rowHeader);
return scroll;
}
public void paint(Graphics g) {
//JMH I am only overriding this to get a picture of the time taken to paint
long start = System.currentTimeMillis();
super.paint(g);
long elapsed = System.currentTimeMillis()-start;
System.out.println("Paint time = "+elapsed);
}
protected MouseListener createTabListener() {
return new TabListener();
}
/** This class defines the default MouseListener that listens to
* mouse events in the tabbed pane
*
* The default is to popup a menu when the event occurs over a tab
*/
private class TabListener implements MouseListener {
public JPopupMenu popup;
public TabListener() {
popup = new JPopupMenu("Sheet");
popup.add(createInsertSheetAction());
popup.add(createDeleteSheetAction());
popup.add(createRenameSheetAction());
}
protected Action createInsertSheetAction() {
return new InsertSheetAction();
}
protected Action createDeleteSheetAction() {
return new DeleteSheetAction();
}
protected Action createRenameSheetAction() {
return new RenameSheetAction();
}
/** This method will display the popup if the mouseevent is a popup event
* and the event occurred over a tab
*/
protected void checkPopup(MouseEvent e) {
if (e.isPopupTrigger()) {
int tab = sheetPane.getUI().tabForCoordinate(sheetPane, e.getX(), e.getY());
if (tab != -1) {
popup.show(sheetPane, e.getX(), e.getY());
}
}
}
public void mouseClicked(MouseEvent e) {
checkPopup(e);
}
public void mousePressed(MouseEvent e) {
checkPopup(e);
}
public void mouseReleased(MouseEvent e) {
checkPopup(e);
}
public void mouseEntered(MouseEvent e) {}
public void mouseExited(MouseEvent e) {}
}
/** This class defines the action that is performed when the sheet is renamed*/
private class RenameSheetAction extends AbstractAction {
public RenameSheetAction() {
super("Rename");
}
public void actionPerformed(ActionEvent e) {
int tabIndex = sheetPane.getSelectedIndex();
if (tabIndex != -1) {
String newSheetName = (String)JOptionPane.showInputDialog(sheetPane, "Enter a new Sheetname", "Rename Sheet", JOptionPane.QUESTION_MESSAGE);
if (newSheetName != null) {
wb.setSheetName(tabIndex, newSheetName);
sheetPane.setTitleAt(tabIndex, newSheetName);
}
}
}
}
/** This class defines the action that is performed when a sheet is inserted*/
private class InsertSheetAction extends AbstractAction {
public InsertSheetAction() {
super("Insert");
}
public void actionPerformed(ActionEvent e) {
//Create a new sheet then search for the sheet and make sure that the
//sheetPane shows it.
HSSFSheet newSheet = wb.createSheet();
for (int i=0; i<wb.getNumberOfSheets();i++) {
HSSFSheet sheet = wb.getSheetAt(i);
if (newSheet == sheet) {
sheetPane.insertTab(wb.getSheetName(i), null, makeSheetView(sheet), null, i);
}
}
}
}
/** This class defines the action that is performed when the sheet is deleted*/
private class DeleteSheetAction extends AbstractAction {
public DeleteSheetAction() {
super("Delete");
}
public void actionPerformed(ActionEvent e) {
int tabIndex = sheetPane.getSelectedIndex();
if (tabIndex != -1) {
if (JOptionPane.showConfirmDialog(sheetPane, "Are you sure that you want to delete the selected sheet", "Delete Sheet?", JOptionPane.OK_CANCEL_OPTION) == JOptionPane.OK_OPTION) {
wb.removeSheetAt(tabIndex);
sheetPane.remove(tabIndex);
}
}
}
}
public boolean isEditable() {
return allowEdits;
}
/**Main method*/
public static void main(String[] args) {
try {
FileInputStream in = new FileInputStream(args[0]);
HSSFWorkbook wb = new HSSFWorkbook(in);
in.close();
SViewerPanel p = new SViewerPanel(wb, true);
JFrame frame;
frame = new JFrame() {
protected void processWindowEvent(WindowEvent e) {
super.processWindowEvent(e);
if (e.getID() == WindowEvent.WINDOW_CLOSING) {
System.exit(0);
}
}
public synchronized void setTitle(String title) {
super.setTitle(title);
enableEvents(AWTEvent.WINDOW_EVENT_MASK);
}
};
frame.setTitle("Viewer Frame");
frame.getContentPane().add(p, BorderLayout.CENTER);
frame.setSize(800,640);
Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
frame.setLocation((d.width - frame.getSize().width) / 2, (d.height - frame.getSize().height) / 2);
frame.setVisible(true);
} catch (IOException ex) {
ex.printStackTrace();
System.exit(1);
}
}
}

View File

@ -0,0 +1,818 @@
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache POI" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache POI", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.poi.hssf.usermodel;
import org.apache.poi.hssf.record.*;
import org.apache.poi.hssf.record.formula.Area3DPtg;
import java.util.ArrayList;
import java.util.List;
import java.util.Stack;
/**
* Has methods for construction of a chart object.
*
* @author Glen Stampoultzis (glens at apache.org)
*/
public class HSSFChart
{
/**
* Creates a bar chart. API needs some work. :)
* <p>
* NOTE: Does not yet work... checking it in just so others
* can take a look.
*/
public void createBarChart( HSSFWorkbook workbook, HSSFSheet sheet )
{
List records = new ArrayList();
records.add( createMSDrawingObjectRecord() );
records.add( createOBJRecord() );
records.add( createBOFRecord() );
records.add( createHeaderRecord() );
records.add( createFooterRecord() );
records.add( createHCenterRecord() );
records.add( createVCenterRecord() );
records.add( createPrintSetupRecord() );
// unknown 33
records.add( createFontBasisRecord1() );
records.add( createFontBasisRecord2() );
records.add( createProtectRecord() );
records.add( createUnitsRecord() );
records.add( createChartRecord( 0, 0, 30434904, 19031616 ) );
records.add( createBeginRecord() );
records.add( createSCLRecord( (short) 1, (short) 1 ) );
records.add( createPlotGrowthRecord( 65536, 65536 ) );
records.add( createFrameRecord1() );
records.add( createBeginRecord() );
records.add( createLineFormatRecord(true) );
records.add( createAreaFormatRecord1() );
records.add( createEndRecord() );
records.add( createSeriesRecord() );
records.add( createBeginRecord() );
records.add( createTitleLinkedDataRecord() );
records.add( createValuesLinkedDataRecord() );
records.add( createCategoriesLinkedDataRecord() );
records.add( createDataFormatRecord() );
// records.add(createBeginRecord());
// unknown
// records.add(createEndRecord());
records.add( createSeriesToChartGroupRecord() );
records.add( createEndRecord() );
records.add( createSheetPropsRecord() );
records.add( createDefaultTextRecord( DefaultDataLabelTextPropertiesRecord.CATEGORY_DATA_TYPE_ALL_TEXT_CHARACTERISTIC ) );
records.add( createAllTextRecord() );
records.add( createBeginRecord() );
// unknown
records.add( createFontIndexRecord( 5 ) );
records.add( createDirectLinkRecord() );
records.add( createEndRecord() );
records.add( createDefaultTextRecord( (short) 3 ) ); // eek, undocumented text type
records.add( createUnknownTextRecord() );
records.add( createBeginRecord() );
records.add( createFontIndexRecord( (short) 6 ) );
records.add( createDirectLinkRecord() );
records.add( createEndRecord() );
records.add( createAxisUsedRecord( (short) 1 ) );
createAxisRecords( records );
records.add( createEndRecord() );
records.add( createDimensionsRecord() );
records.add( createSeriesIndexRecord(2) );
records.add( createSeriesIndexRecord(1) );
records.add( createSeriesIndexRecord(3) );
records.add( createEOFRecord() );
//sheet.insertChartRecords( records );
//workbook.insertChartRecord();
}
private EOFRecord createEOFRecord()
{
return new EOFRecord();
}
private SeriesIndexRecord createSeriesIndexRecord( int index )
{
SeriesIndexRecord r = new SeriesIndexRecord();
r.setIndex((short)index);
return r;
}
private DimensionsRecord createDimensionsRecord()
{
DimensionsRecord r = new DimensionsRecord();
r.setFirstRow(0);
r.setLastRow(31);
r.setFirstCol((short)0);
r.setLastCol((short)1);
return r;
}
private HCenterRecord createHCenterRecord()
{
HCenterRecord r = new HCenterRecord();
r.setHCenter(false);
return r;
}
private VCenterRecord createVCenterRecord()
{
VCenterRecord r = new VCenterRecord();
r.setVCenter(false);
return r;
}
private PrintSetupRecord createPrintSetupRecord()
{
PrintSetupRecord r = new PrintSetupRecord();
r.setPaperSize((short)0);
r.setScale((short)18);
r.setPageStart((short)1);
r.setFitWidth((short)1);
r.setFitHeight((short)1);
r.setLeftToRight(false);
r.setLandscape(false);
r.setValidSettings(true);
r.setNoColor(false);
r.setDraft(false);
r.setNotes(false);
r.setNoOrientation(false);
r.setUsePage(false);
r.setHResolution((short)0);
r.setVResolution((short)0);
r.setHeaderMargin(0.5);
r.setFooterMargin(0.5);
r.setCopies((short)15); // what the ??
return r;
}
private FontBasisRecord createFontBasisRecord1()
{
FontBasisRecord r = new FontBasisRecord();
r.setXBasis((short)9120);
r.setYBasis((short)5640);
r.setHeightBasis((short)200);
r.setScale((short)0);
r.setIndexToFontTable((short)5);
return r;
}
private FontBasisRecord createFontBasisRecord2()
{
FontBasisRecord r = createFontBasisRecord1();
r.setIndexToFontTable((short)6);
return r;
}
private ProtectRecord createProtectRecord()
{
ProtectRecord r = new ProtectRecord();
r.setProtect(false);
return r;
}
private FooterRecord createFooterRecord()
{
FooterRecord r = new FooterRecord();
r.setFooter(null);
return r;
}
private HeaderRecord createHeaderRecord()
{
HeaderRecord r = new HeaderRecord();
r.setHeader(null);
return r;
}
private BOFRecord createBOFRecord()
{
BOFRecord r = new BOFRecord();
r.setVersion((short)600);
r.setType((short)20);
r.setBuild((short)0x1CFE);
r.setBuildYear((short)1997);
r.setHistoryBitMask(0x40C9);
r.setRequiredVersion(106);
return r;
}
private UnknownRecord createOBJRecord()
{
byte[] data = {
(byte) 0x15, (byte) 0x00, (byte) 0x12, (byte) 0x00, (byte) 0x05, (byte) 0x00, (byte) 0x02, (byte) 0x00, (byte) 0x11, (byte) 0x60, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0xB8, (byte) 0x03,
(byte) 0x87, (byte) 0x03, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
};
return new UnknownRecord( (short) 0x005D, (short) 0x001a, data );
}
private UnknownRecord createMSDrawingObjectRecord()
{
// Since we haven't created this object yet we'll just put in the raw
// form for the moment.
byte[] data = {
(byte)0x0F, (byte)0x00, (byte)0x02, (byte)0xF0, (byte)0xC0, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x10, (byte)0x00, (byte)0x08, (byte)0xF0, (byte)0x08, (byte)0x00, (byte)0x00, (byte)0x00,
(byte)0x02, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x02, (byte)0x04, (byte)0x00, (byte)0x00, (byte)0x0F, (byte)0x00, (byte)0x03, (byte)0xF0, (byte)0xA8, (byte)0x00, (byte)0x00, (byte)0x00,
(byte)0x0F, (byte)0x00, (byte)0x04, (byte)0xF0, (byte)0x28, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x01, (byte)0x00, (byte)0x09, (byte)0xF0, (byte)0x10, (byte)0x00, (byte)0x00, (byte)0x00,
(byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00,
(byte)0x02, (byte)0x00, (byte)0x0A, (byte)0xF0, (byte)0x08, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x04, (byte)0x00, (byte)0x00, (byte)0x05, (byte)0x00, (byte)0x00, (byte)0x00,
(byte)0x0F, (byte)0x00, (byte)0x04, (byte)0xF0, (byte)0x70, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x92, (byte)0x0C, (byte)0x0A, (byte)0xF0, (byte)0x08, (byte)0x00, (byte)0x00, (byte)0x00,
(byte)0x02, (byte)0x04, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x0A, (byte)0x00, (byte)0x00, (byte)0x93, (byte)0x00, (byte)0x0B, (byte)0xF0, (byte)0x36, (byte)0x00, (byte)0x00, (byte)0x00,
(byte)0x7F, (byte)0x00, (byte)0x04, (byte)0x01, (byte)0x04, (byte)0x01, (byte)0xBF, (byte)0x00, (byte)0x08, (byte)0x00, (byte)0x08, (byte)0x00, (byte)0x81, (byte)0x01, (byte)0x4E, (byte)0x00,
(byte)0x00, (byte)0x08, (byte)0x83, (byte)0x01, (byte)0x4D, (byte)0x00, (byte)0x00, (byte)0x08, (byte)0xBF, (byte)0x01, (byte)0x10, (byte)0x00, (byte)0x11, (byte)0x00, (byte)0xC0, (byte)0x01,
(byte)0x4D, (byte)0x00, (byte)0x00, (byte)0x08, (byte)0xFF, (byte)0x01, (byte)0x08, (byte)0x00, (byte)0x08, (byte)0x00, (byte)0x3F, (byte)0x02, (byte)0x00, (byte)0x00, (byte)0x02, (byte)0x00,
(byte)0xBF, (byte)0x03, (byte)0x00, (byte)0x00, (byte)0x08, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x10, (byte)0xF0, (byte)0x12, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00,
(byte)0x04, (byte)0x00, (byte)0xC0, (byte)0x02, (byte)0x0A, (byte)0x00, (byte)0xF4, (byte)0x00, (byte)0x0E, (byte)0x00, (byte)0x66, (byte)0x01, (byte)0x20, (byte)0x00, (byte)0xE9, (byte)0x00,
(byte)0x00, (byte)0x00, (byte)0x11, (byte)0xF0, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00
};
return new UnknownRecord((short)0x00EC, (short)0x00C8, data);
}
private void createAxisRecords( List records )
{
records.add( createAxisParentRecord() );
records.add( createBeginRecord() );
records.add( createAxisRecord( AxisRecord.AXIS_TYPE_CATEGORY_OR_X_AXIS ) );
records.add( createBeginRecord() );
records.add( createCategorySeriesAxisRecord() );
records.add( createAxisOptionsRecord() );
records.add( createTickRecord1() );
records.add( createEndRecord() );
records.add( createAxisRecord( AxisRecord.AXIS_TYPE_VALUE_AXIS ) );
records.add( createBeginRecord() );
records.add( createValueRangeRecord() );
records.add( createTickRecord2() );
records.add( createAxisLineFormatRecord( AxisLineFormatRecord.AXIS_TYPE_MAJOR_GRID_LINE ) );
records.add( createLineFormatRecord(false) );
records.add( createEndRecord() );
records.add( createPlotAreaRecord() );
records.add( createFrameRecord2() );
records.add( createBeginRecord() );
records.add( createLineFormatRecord2() );
records.add( createAreaFormatRecord2() );
records.add( createEndRecord() );
records.add( createChartFormatRecord() );
records.add( createBeginRecord() );
records.add( createBarRecord() );
// unknown 1022
records.add( createLegendRecord() );
records.add( createBeginRecord() );
// unknown 104f
records.add( createTextRecord() );
records.add( createBeginRecord() );
// unknown 104f
records.add( createLinkedDataRecord() );
records.add( createEndRecord() );
records.add( createEndRecord() );
records.add( createEndRecord() );
records.add( createEndRecord() );
}
private LinkedDataRecord createLinkedDataRecord()
{
LinkedDataRecord r = new LinkedDataRecord();
r.setLinkType(LinkedDataRecord.LINK_TYPE_TITLE_OR_TEXT);
r.setReferenceType(LinkedDataRecord.REFERENCE_TYPE_DIRECT);
r.setCustomNumberFormat(false);
r.setIndexNumberFmtRecord((short)0);
r.setFormulaOfLink( new LinkedDataFormulaField() );
return r;
}
private TextRecord createTextRecord()
{
TextRecord r = new TextRecord();
r.setHorizontalAlignment(TextRecord.HORIZONTAL_ALIGNMENT_CENTER);
r.setVerticalAlignment(TextRecord.VERTICAL_ALIGNMENT_CENTER);
r.setDisplayMode((short)1);
r.setRgbColor(0x00000000);
r.setX(-37);
r.setY(-60);
r.setWidth(0);
r.setHeight(0);
r.setAutoColor(true);
r.setShowKey(false);
r.setShowValue(false);
r.setVertical(false);
r.setAutoGeneratedText(true);
r.setGenerated(true);
r.setAutoLabelDeleted(false);
r.setAutoBackground(true);
r.setRotation((short)0);
r.setShowCategoryLabelAsPercentage(false);
r.setShowValueAsPercentage(false);
r.setShowBubbleSizes(false);
r.setShowLabel(false);
r.setIndexOfColorValue((short)77);
r.setDataLabelPlacement((short)0);
r.setTextRotation((short)0);
return r;
}
private LegendRecord createLegendRecord()
{
LegendRecord r = new LegendRecord();
r.setXAxisUpperLeft(3542);
r.setYAxisUpperLeft(1566);
r.setXSize(437);
r.setYSize(213);
r.setType(LegendRecord.TYPE_RIGHT);
r.setSpacing(LegendRecord.SPACING_MEDIUM);
r.setAutoPosition(true);
r.setAutoSeries(true);
r.setAutoXPositioning(true);
r.setAutoYPositioning(true);
r.setVertical(true);
r.setDataTable(false);
return r;
}
private BarRecord createBarRecord()
{
BarRecord r = new BarRecord();
r.setBarSpace((short)0);
r.setCategorySpace((short)150);
r.setHorizontal(false);
r.setStacked(false);
r.setDisplayAsPercentage(false);
r.setShadow(false);
return r;
}
private ChartFormatRecord createChartFormatRecord()
{
ChartFormatRecord r = new ChartFormatRecord();
r.setXPosition(0);
r.setYPosition(0);
r.setWidth(0);
r.setHeight(0);
r.setVaryDisplayPattern(false);
return r;
}
private PlotAreaRecord createPlotAreaRecord()
{
PlotAreaRecord r = new PlotAreaRecord( );
return r;
}
private AxisLineFormatRecord createAxisLineFormatRecord( short format )
{
AxisLineFormatRecord r = new AxisLineFormatRecord();
r.setAxisType( format );
return r;
}
private ValueRangeRecord createValueRangeRecord()
{
ValueRangeRecord r = new ValueRangeRecord();
r.setMinimumAxisValue( 0.0 );
r.setMaximumAxisValue( 0.0 );
r.setMajorIncrement( 0 );
r.setMinorIncrement( 0 );
r.setCategoryAxisCross( 0 );
r.setAutomaticMinimum( true );
r.setAutomaticMaximum( true );
r.setAutomaticMajor( true );
r.setAutomaticMinor( true );
r.setAutomaticCategoryCrossing( true );
r.setLogarithmicScale( false );
r.setValuesInReverse( false );
r.setCrossCategoryAxisAtMaximum( false );
r.setReserved( true ); // what's this do??
return r;
}
private TickRecord createTickRecord1()
{
TickRecord r = new TickRecord();
r.setMajorTickType( (byte) 2 );
r.setMinorTickType( (byte) 0 );
r.setLabelPosition( (byte) 3 );
r.setBackground( (byte) 1 );
r.setLabelColorRgb( 0 );
r.setZero1( (short) 0 );
r.setZero2( (short) 0 );
r.setZero3( (short) 45 );
r.setAutorotate( true );
r.setAutoTextBackground( true );
r.setRotation( (short) 0 );
r.setAutorotate( true );
r.setTickColor( (short) 77 );
return r;
}
private TickRecord createTickRecord2()
{
TickRecord r = createTickRecord1();
r.setZero3((short)0);
return r;
}
private AxisOptionsRecord createAxisOptionsRecord()
{
AxisOptionsRecord r = new AxisOptionsRecord();
r.setMinimumCategory( (short) -28644 );
r.setMaximumCategory( (short) -28715 );
r.setMajorUnitValue( (short) 2 );
r.setMajorUnit( (short) 0 );
r.setMinorUnitValue( (short) 1 );
r.setMinorUnit( (short) 0 );
r.setBaseUnit( (short) 0 );
r.setCrossingPoint( (short) -28644 );
r.setDefaultMinimum( true );
r.setDefaultMaximum( true );
r.setDefaultMajor( true );
r.setDefaultMinorUnit( true );
r.setIsDate( true );
r.setDefaultBase( true );
r.setDefaultCross( true );
r.setDefaultDateSettings( true );
return r;
}
private CategorySeriesAxisRecord createCategorySeriesAxisRecord()
{
CategorySeriesAxisRecord r = new CategorySeriesAxisRecord();
r.setCrossingPoint( (short) 1 );
r.setLabelFrequency( (short) 1 );
r.setTickMarkFrequency( (short) 1 );
r.setValueAxisCrossing( true );
r.setCrossesFarRight( false );
r.setReversed( false );
return r;
}
private AxisRecord createAxisRecord( short axisType )
{
AxisRecord r = new AxisRecord();
r.setAxisType( axisType );
return r;
}
private AxisParentRecord createAxisParentRecord()
{
AxisParentRecord r = new AxisParentRecord();
r.setAxisType( AxisParentRecord.AXIS_TYPE_MAIN );
r.setX( 479 );
r.setY( 221 );
r.setWidth( 2995 );
r.setHeight( 2902 );
return r;
}
private AxisUsedRecord createAxisUsedRecord( short numAxis )
{
AxisUsedRecord r = new AxisUsedRecord();
r.setNumAxis( numAxis );
return r;
}
private LinkedDataRecord createDirectLinkRecord()
{
LinkedDataRecord r = new LinkedDataRecord();
r.setLinkType( LinkedDataRecord.LINK_TYPE_TITLE_OR_TEXT );
r.setReferenceType( LinkedDataRecord.REFERENCE_TYPE_DIRECT );
r.setCustomNumberFormat( false );
r.setIndexNumberFmtRecord( (short) 0 );
r.setFormulaOfLink( new LinkedDataFormulaField() );
return r;
}
private FontIndexRecord createFontIndexRecord( int index )
{
FontIndexRecord r = new FontIndexRecord();
r.setFontIndex( (short) index );
return r;
}
private TextRecord createAllTextRecord()
{
TextRecord r = new TextRecord();
r.setHorizontalAlignment( TextRecord.HORIZONTAL_ALIGNMENT_CENTER );
r.setVerticalAlignment( TextRecord.VERTICAL_ALIGNMENT_CENTER );
r.setDisplayMode( TextRecord.DISPLAY_MODE_TRANSPARENT );
r.setRgbColor( 0 );
r.setX( -37 );
r.setY( -60 );
r.setWidth( 0 );
r.setHeight( 0 );
r.setAutoColor( true );
r.setShowKey( false );
r.setShowValue( true );
r.setVertical( false );
r.setAutoGeneratedText( true );
r.setGenerated( true );
r.setAutoLabelDeleted( false );
r.setAutoBackground( true );
r.setRotation( (short) 0 );
r.setShowCategoryLabelAsPercentage( false );
r.setShowValueAsPercentage( false );
r.setShowBubbleSizes( false );
r.setShowLabel( false );
r.setIndexOfColorValue( (short) 77 );
r.setDataLabelPlacement( (short) 0 );
r.setTextRotation( (short) 0 );
return r;
}
private TextRecord createUnknownTextRecord()
{
TextRecord r = new TextRecord();
r.setHorizontalAlignment( TextRecord.HORIZONTAL_ALIGNMENT_CENTER );
r.setVerticalAlignment( TextRecord.VERTICAL_ALIGNMENT_CENTER );
r.setDisplayMode( TextRecord.DISPLAY_MODE_TRANSPARENT );
r.setRgbColor( 0 );
r.setX( -37 );
r.setY( -60 );
r.setWidth( 0 );
r.setHeight( 0 );
r.setAutoColor( true );
r.setShowKey( false );
r.setShowValue( false );
r.setVertical( false );
r.setAutoGeneratedText( true );
r.setGenerated( true );
r.setAutoLabelDeleted( false );
r.setAutoBackground( true );
r.setRotation( (short) 0 );
r.setShowCategoryLabelAsPercentage( false );
r.setShowValueAsPercentage( false );
r.setShowBubbleSizes( false );
r.setShowLabel( false );
r.setIndexOfColorValue( (short) 77 );
r.setDataLabelPlacement( (short) 11088 );
r.setTextRotation( (short) 0 );
return r;
}
private DefaultDataLabelTextPropertiesRecord createDefaultTextRecord( short categoryDataType )
{
DefaultDataLabelTextPropertiesRecord r = new DefaultDataLabelTextPropertiesRecord();
r.setCategoryDataType( categoryDataType );
return r;
}
private SheetPropertiesRecord createSheetPropsRecord()
{
SheetPropertiesRecord r = new SheetPropertiesRecord();
r.setChartTypeManuallyFormatted( false );
r.setPlotVisibleOnly( true );
r.setDoNotSizeWithWindow( false );
r.setDefaultPlotDimensions( true );
r.setAutoPlotArea( false );
return r;
}
private SeriesToChartGroupRecord createSeriesToChartGroupRecord()
{
return new SeriesToChartGroupRecord();
}
private DataFormatRecord createDataFormatRecord()
{
DataFormatRecord r = new DataFormatRecord();
r.setPointNumber( (short) -1 );
r.setSeriesIndex( (short) 0 );
r.setSeriesNumber( (short) 0 );
r.setUseExcel4Colors( false );
return r;
}
private LinkedDataRecord createCategoriesLinkedDataRecord()
{
LinkedDataRecord r = new LinkedDataRecord();
r.setLinkType( LinkedDataRecord.LINK_TYPE_CATEGORIES );
r.setReferenceType( LinkedDataRecord.REFERENCE_TYPE_WORKSHEET );
r.setCustomNumberFormat( false );
r.setIndexNumberFmtRecord( (short) 0 );
LinkedDataFormulaField formula = new LinkedDataFormulaField();
Stack tokens = new Stack();
Area3DPtg p = new Area3DPtg();
p.setExternSheetIndex( (short) 0 );
p.setFirstColumn( (short) 1 );
p.setLastColumn( (short) 1 );
p.setFirstRow( (short) 0 );
p.setLastRow( (short) 31 );
tokens.add( p );
formula.setFormulaTokens( tokens );
r.setFormulaOfLink( formula );
return r;
}
private LinkedDataRecord createValuesLinkedDataRecord()
{
LinkedDataRecord r = new LinkedDataRecord();
r.setLinkType( LinkedDataRecord.LINK_TYPE_VALUES );
r.setReferenceType( LinkedDataRecord.REFERENCE_TYPE_WORKSHEET );
r.setCustomNumberFormat( false );
r.setIndexNumberFmtRecord( (short) 0 );
LinkedDataFormulaField formula = new LinkedDataFormulaField();
Stack tokens = new Stack();
Area3DPtg p = new Area3DPtg();
p.setExternSheetIndex( (short) 0 );
p.setFirstColumn( (short) 0 );
p.setLastColumn( (short) 0 );
p.setFirstRow( (short) 0 );
p.setLastRow( (short) 31 );
tokens.add( p );
formula.setFormulaTokens( tokens );
r.setFormulaOfLink( formula );
return r;
}
private LinkedDataRecord createTitleLinkedDataRecord()
{
LinkedDataRecord r = new LinkedDataRecord();
r.setLinkType( LinkedDataRecord.LINK_TYPE_TITLE_OR_TEXT );
r.setReferenceType( LinkedDataRecord.REFERENCE_TYPE_DIRECT );
r.setCustomNumberFormat( false );
r.setIndexNumberFmtRecord( (short) 0 );
r.setFormulaOfLink( new LinkedDataFormulaField() );
return r;
}
private SeriesRecord createSeriesRecord()
{
SeriesRecord r = new SeriesRecord();
r.setCategoryDataType( SeriesRecord.CATEGORY_DATA_TYPE_NUMERIC );
r.setValuesDataType( SeriesRecord.VALUES_DATA_TYPE_NUMERIC );
r.setNumCategories( (short) 32 );
r.setNumValues( (short) 31 );
r.setBubbleSeriesType( SeriesRecord.BUBBLE_SERIES_TYPE_NUMERIC );
r.setNumBubbleValues( (short) 0 );
return r;
}
private EndRecord createEndRecord()
{
return new EndRecord();
}
private AreaFormatRecord createAreaFormatRecord1()
{
AreaFormatRecord r = new AreaFormatRecord();
r.setForegroundColor( 16777215 ); // RGB Color
r.setBackgroundColor( 0 ); // RGB Color
r.setPattern( (short) 1 ); // TODO: Add Pattern constants to record
r.setAutomatic( true );
r.setInvert( false );
r.setForecolorIndex( (short) 78 );
r.setBackcolorIndex( (short) 77 );
return r;
}
private AreaFormatRecord createAreaFormatRecord2()
{
AreaFormatRecord r = new AreaFormatRecord();
r.setForegroundColor(0x00c0c0c0);
r.setBackgroundColor(0x00000000);
r.setPattern((short)1);
r.setAutomatic(false);
r.setInvert(false);
r.setForecolorIndex((short)22);
r.setBackcolorIndex((short)79);
return r;
}
private LineFormatRecord createLineFormatRecord( boolean drawTicks )
{
LineFormatRecord r = new LineFormatRecord();
r.setLineColor( 0 );
r.setLinePattern( LineFormatRecord.LINE_PATTERN_SOLID );
r.setWeight( (short) -1 );
r.setAuto( true );
r.setDrawTicks( drawTicks );
r.setColourPaletteIndex( (short) 77 ); // what colour is this?
return r;
}
private LineFormatRecord createLineFormatRecord2()
{
LineFormatRecord r = new LineFormatRecord();
r.setLineColor( 0x00808080 );
r.setLinePattern( (short) 0 );
r.setWeight( (short) 0 );
r.setAuto( false );
r.setDrawTicks( false );
r.setUnknown( false );
r.setColourPaletteIndex( (short) 23 );
return r;
}
private FrameRecord createFrameRecord1()
{
FrameRecord r = new FrameRecord();
r.setBorderType( FrameRecord.BORDER_TYPE_REGULAR );
r.setAutoSize( false );
r.setAutoPosition( true );
return r;
}
private FrameRecord createFrameRecord2()
{
FrameRecord r = new FrameRecord();
r.setBorderType( FrameRecord.BORDER_TYPE_REGULAR );
r.setAutoSize( true );
r.setAutoPosition( true );
return r;
}
private PlotGrowthRecord createPlotGrowthRecord( int horizScale, int vertScale )
{
PlotGrowthRecord r = new PlotGrowthRecord();
r.setHorizontalScale( horizScale );
r.setVerticalScale( vertScale );
return r;
}
private SCLRecord createSCLRecord( short numerator, short denominator )
{
SCLRecord r = new SCLRecord();
r.setDenominator( denominator );
r.setNumerator( numerator );
return r;
}
private BeginRecord createBeginRecord()
{
return new BeginRecord();
}
private ChartRecord createChartRecord( int x, int y, int width, int height )
{
ChartRecord r = new ChartRecord();
r.setX( x );
r.setY( y );
r.setWidth( width );
r.setHeight( height );
return r;
}
private UnitsRecord createUnitsRecord()
{
UnitsRecord r = new UnitsRecord();
r.setUnits( (short) 0 );
return r;
}
}

View File

@ -0,0 +1,290 @@
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache POI" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache POI", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.poi.hssf.usermodel.contrib;
import org.apache.commons.beanutils.PropertyUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.exception.NestableException;
import org.apache.poi.hssf.usermodel.*;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
/**
* Various utility functions that make working with a cells and rows easier. The various
* methods that deal with style's allow you to create your HSSFCellStyles as you need them.
* When you apply a style change to a cell, the code will attempt to see if a style already
* exists that meets your needs. If not, then it will create a new style. This is to prevent
* creating too many styles. there is an upper limit in Excel on the number of styles that
* can be supported.
*
*@author Eric Pugh epugh@upstate.com
*/
public class HSSFCellUtil
{
private static HashMap unicodeMappings = new HashMap();
/**
* Get a row from the spreadsheet, and create it if it doesn't exist.
*
*@param rowCounter The 0 based row number
*@param sheet The sheet that the row is part of.
*@return The row indicated by the rowCounter
*/
public static HSSFRow getRow( int rowCounter, HSSFSheet sheet )
{
HSSFRow row = sheet.getRow( (short) rowCounter );
if ( row == null )
{
row = sheet.createRow( (short) rowCounter );
}
return row;
}
/**
* Get a specific cell from a row. If the cell doesn't exist, then create it.
*
*@param row The row that the cell is part of
*@param column The column index that the cell is in.
*@return The cell indicated by the column.
*/
public static HSSFCell getCell( HSSFRow row, int column )
{
HSSFCell cell = row.getCell( (short) column );
if ( cell == null )
{
cell = row.createCell( (short) column );
}
return cell;
}
/**
* Creates a cell, gives it a value, and applies a style if provided
*
* @param row the row to create the cell in
* @param column the column index to create the cell in
* @param value The value of the cell
* @param style If the style is not null, then set
* @return A new HSSFCell
*/
public static HSSFCell createCell( HSSFRow row, int column, String value, HSSFCellStyle style )
{
HSSFCell cell = getCell( row, column );
cell.setCellValue( value );
if ( style != null )
{
cell.setCellStyle( style );
}
return cell;
}
/**
* Create a cell, and give it a value.
*
*@param row the row to create the cell in
*@param column the column index to create the cell in
*@param value The value of the cell
*@return A new HSSFCell.
*/
public static HSSFCell createCell( HSSFRow row, int column, String value )
{
return createCell( row, column, value, null );
}
/**
* Take a cell, and align it.
*
*@param cell the cell to set the alignment for
*@param workbook The workbook that is being worked with.
*@param align the column alignment to use.
*@exception NestableException Thrown if an error happens.
*
* @see HSSFCellStyle for alignment options
*/
public static void setAlignment( HSSFCell cell, HSSFWorkbook workbook, short align ) throws NestableException
{
setCellStyleProperty( cell, workbook, "alignment", new Short( align ) );
}
/**
* Take a cell, and apply a font to it
*
*@param cell the cell to set the alignment for
*@param workbook The workbook that is being worked with.
*@param font The HSSFFont that you want to set...
*@exception NestableException Thrown if an error happens.
*/
public static void setFont( HSSFCell cell, HSSFWorkbook workbook, HSSFFont font ) throws NestableException
{
setCellStyleProperty( cell, workbook, "font", font );
}
/**
* This method attempt to find an already existing HSSFCellStyle that matches
* what you want the style to be. If it does not find the style, then it
* creates a new one. If it does create a new one, then it applyies the
* propertyName and propertyValue to the style. This is nessasary because
* Excel has an upper limit on the number of Styles that it supports.
*
*@param workbook The workbook that is being worked with.
*@param propertyName The name of the property that is to be
* changed.
*@param propertyValue The value of the property that is to be
* changed.
*@param cell The cell that needs it's style changes
*@exception NestableException Thrown if an error happens.
*/
public static void setCellStyleProperty( HSSFCell cell, HSSFWorkbook workbook, String propertyName, Object propertyValue )
throws NestableException
{
try
{
HSSFCellStyle originalStyle = cell.getCellStyle();
HSSFCellStyle newStyle = null;
Map values = PropertyUtils.describe( originalStyle );
values.put( propertyName, propertyValue );
values.remove( "index" );
// index seems like what index the cellstyle is in the list of styles for a workbook.
// not good to compare on!
short numberCellStyles = workbook.getNumCellStyles();
for ( short i = 0; i < numberCellStyles; i++ )
{
HSSFCellStyle wbStyle = workbook.getCellStyleAt( i );
Map wbStyleMap = PropertyUtils.describe( wbStyle );
wbStyleMap.remove( "index" );
if ( wbStyleMap.equals( values ) )
{
newStyle = wbStyle;
break;
}
}
if ( newStyle == null )
{
newStyle = workbook.createCellStyle();
newStyle.setFont( workbook.getFontAt( originalStyle.getFontIndex() ) );
PropertyUtils.copyProperties( newStyle, originalStyle );
PropertyUtils.setProperty( newStyle, propertyName, propertyValue );
}
cell.setCellStyle( newStyle );
}
catch ( Exception e )
{
e.printStackTrace();
throw new NestableException( "Couldn't setCellStyleProperty.", e );
}
}
/**
* Looks for text in the cell that should be unicode, like &alpha; and provides the
* unicode version of it.
*
*@param cell The cell to check for unicode values
*@return transalted to unicode
*/
public static HSSFCell translateUnicodeValues( HSSFCell cell )
{
String s = cell.getStringCellValue();
boolean foundUnicode = false;
for ( Iterator i = unicodeMappings.entrySet().iterator(); i.hasNext(); )
{
Map.Entry entry = (Map.Entry) i.next();
String key = (String) entry.getKey();
if ( s.toLowerCase().indexOf( key ) != -1 )
{
s = StringUtils.replace( s, key, "" + entry.getValue().toString() + "" );
foundUnicode = true;
}
}
if ( foundUnicode )
{
cell.setEncoding( HSSFCell.ENCODING_UTF_16 );
cell.setCellValue( s );
}
return cell;
}
static
{
unicodeMappings.put( "&alpha;", "\u03B1" );
unicodeMappings.put( "&gamma;", "\u03B3" );
unicodeMappings.put( "&epsilon;", "\u03B5" );
unicodeMappings.put( "&theta;", "\u03B8" );
}
}

View File

@ -0,0 +1,266 @@
/*
* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache POI" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache POI", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.poi.hssf.usermodel.contrib;
import org.apache.log4j.Category;
import org.apache.poi.hssf.usermodel.HSSFCellStyle;
import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.hssf.util.Region;
import org.apache.commons.lang.exception.NestableException;
/**
* Various utility functions that make working with a region of cells easier.
*
*@author Eric Pugh epugh@upstate.com
*@created July 29, 2002
*/
public class HSSFRegionUtil {
private static Category log = Category.getInstance( HSSFRegionUtil.class.getName() );
/** Constructor for the HSSFRegionUtil object */
public HSSFRegionUtil() { }
/**
* Sets the left border for a region of cells by manipulating the cell style
* of the indidual cells on the left
*
*@param border The new border
*@param region The region that should have the border
*@param workbook The workbook that the region is on.
*@param sheet The sheet that the region is on.
*@exception NestableException Thrown if the CellStyle can't be changed
*/
public static void setBorderLeft( short border, Region region, HSSFSheet sheet, HSSFWorkbook workbook )
throws NestableException {
int rowStart = region.getRowFrom();
int rowEnd = region.getRowTo();
int column = region.getColumnFrom();
for ( int i = rowStart; i <= rowEnd; i++ ) {
HSSFRow row = HSSFCellUtil.getRow( i, sheet );
HSSFCell cell = HSSFCellUtil.getCell( row, column );
HSSFCellUtil.setCellStyleProperty( cell, workbook, "borderLeft", new Short( border ) );
}
}
/**
* Sets the leftBorderColor attribute of the HSSFRegionUtil object
*
*@param color The color of the border
*@param region The region that should have the border
*@param workbook The workbook that the region is on.
*@param sheet The sheet that the region is on.
*@exception NestableException Thrown if the CellStyle can't be changed
* properly.
*/
public static void setLeftBorderColor( short color, Region region, HSSFSheet sheet, HSSFWorkbook workbook )
throws NestableException {
int rowStart = region.getRowFrom();
int rowEnd = region.getRowTo();
int column = region.getColumnFrom();
for ( int i = rowStart; i <= rowEnd; i++ ) {
HSSFRow row = HSSFCellUtil.getRow( i, sheet );
HSSFCell cell = HSSFCellUtil.getCell( row, column );
HSSFCellUtil.setCellStyleProperty( cell, workbook, "leftBorderColor", new Short( color ) );
}
}
/**
* Sets the borderRight attribute of the HSSFRegionUtil object
*
*@param border The new border
*@param region The region that should have the border
*@param workbook The workbook that the region is on.
*@param sheet The sheet that the region is on.
*@exception NestableException Thrown if the CellStyle can't be changed
*/
public static void setBorderRight( short border, Region region, HSSFSheet sheet, HSSFWorkbook workbook )
throws NestableException {
int rowStart = region.getRowFrom();
int rowEnd = region.getRowTo();
int column = region.getColumnTo();
for ( int i = rowStart; i <= rowEnd; i++ ) {
HSSFRow row = HSSFCellUtil.getRow( i, sheet );
HSSFCell cell = HSSFCellUtil.getCell( row, column );
HSSFCellUtil.setCellStyleProperty( cell, workbook, "borderRight", new Short( border ) );
}
}
/**
* Sets the rightBorderColor attribute of the HSSFRegionUtil object
*
*@param color The color of the border
*@param region The region that should have the border
*@param workbook The workbook that the region is on.
*@param sheet The sheet that the region is on.
*@exception NestableException Thrown if the CellStyle can't be changed
* properly.
*/
public static void setRightBorderColor( short color, Region region, HSSFSheet sheet, HSSFWorkbook workbook )
throws NestableException {
int rowStart = region.getRowFrom();
int rowEnd = region.getRowTo();
int column = region.getColumnTo();
for ( int i = rowStart; i <= rowEnd; i++ ) {
HSSFRow row = HSSFCellUtil.getRow( i, sheet );
HSSFCell cell = HSSFCellUtil.getCell( row, column );
HSSFCellUtil.setCellStyleProperty( cell, workbook, "rightBorderColor", new Short( color ) );
}
}
/**
* Sets the borderBottom attribute of the HSSFRegionUtil object
*
*@param border The new border
*@param region The region that should have the border
*@param workbook The workbook that the region is on.
*@param sheet The sheet that the region is on.
*@exception NestableException Thrown if the CellStyle can't be changed
*/
public static void setBorderBottom( short border, Region region, HSSFSheet sheet, HSSFWorkbook workbook )
throws NestableException {
int colStart = region.getColumnFrom();
int colEnd = region.getColumnTo();
int rowIndex = region.getRowTo();
HSSFRow row = HSSFCellUtil.getRow( rowIndex, sheet );
for ( int i = colStart; i <= colEnd; i++ ) {
HSSFCell cell = HSSFCellUtil.getCell( row, i );
HSSFCellUtil.setCellStyleProperty( cell, workbook, "borderBottom", new Short( border ) );
}
}
/**
* Sets the bottomBorderColor attribute of the HSSFRegionUtil object
*
*@param color The color of the border
*@param region The region that should have the border
*@param workbook The workbook that the region is on.
*@param sheet The sheet that the region is on.
*@exception NestableException Thrown if the CellStyle can't be changed
* properly.
*/
public static void setBottomBorderColor( short color, Region region, HSSFSheet sheet, HSSFWorkbook workbook )
throws NestableException {
int colStart = region.getColumnFrom();
int colEnd = region.getColumnTo();
int rowIndex = region.getRowTo();
HSSFRow row = HSSFCellUtil.getRow( rowIndex, sheet );
for ( int i = colStart; i <= colEnd; i++ ) {
HSSFCell cell = HSSFCellUtil.getCell( row, i );
HSSFCellUtil.setCellStyleProperty( cell, workbook, "bottomBorderColor", new Short( color ) );
}
}
/**
* Sets the borderBottom attribute of the HSSFRegionUtil object
*
*@param border The new border
*@param region The region that should have the border
*@param workbook The workbook that the region is on.
*@param sheet The sheet that the region is on.
*@exception NestableException Thrown if the CellStyle can't be changed
*/
public static void setBorderTop( short border, Region region, HSSFSheet sheet, HSSFWorkbook workbook )
throws NestableException {
int colStart = region.getColumnFrom();
int colEnd = region.getColumnTo();
int rowIndex = region.getRowFrom();
HSSFRow row = HSSFCellUtil.getRow( rowIndex, sheet );
for ( int i = colStart; i <= colEnd; i++ ) {
HSSFCell cell = HSSFCellUtil.getCell( row, i );
HSSFCellUtil.setCellStyleProperty( cell, workbook, "borderTop", new Short( border ) );
}
}
/**
* Sets the topBorderColor attribute of the HSSFRegionUtil object
*
*@param color The color of the border
*@param region The region that should have the border
*@param workbook The workbook that the region is on.
*@param sheet The sheet that the region is on.
*@exception NestableException Thrown if the CellStyle can't be changed
* properly.
*/
public static void setTopBorderColor( short color, Region region, HSSFSheet sheet, HSSFWorkbook workbook )
throws NestableException {
int colStart = region.getColumnFrom();
int colEnd = region.getColumnTo();
int rowIndex = region.getRowFrom();
HSSFRow row = HSSFCellUtil.getRow( rowIndex, sheet );
for ( int i = colStart; i <= colEnd; i++ ) {
HSSFCell cell = HSSFCellUtil.getCell( row, i );
HSSFCellUtil.setCellStyleProperty( cell, workbook, "topBorderColor", new Short( color ) );
}
}
}

View File

@ -0,0 +1,37 @@
<project default="poibrowser" basedir="../../" name="POIBrowser build">
<property name="build.root" value="build"/>
<!-- =================================================================== -->
<!-- GUI Run Target -->
<!-- =================================================================== -->
<target name="poibrowser">
<property name="contrib.input.selection" value=""/>
<centipede-user-input name="contrib.input.selection">Please select a file to view </centipede-user-input>
<java classname="org.apache.poi.contrib.poibrowser.POIBrowser" fork="true">
<arg value="${contrib.input.selection}"/>
<classpath>
<pathelement path="${xlayout.build.contributions.classes.dir}"/>
<pathelement path="${xlayout.build.classes.dir}"/>
<path>
<fileset dir="${xlayout.library.dir}" casesensitive="yes">
<patternset>
<include name="*/*.jar"/>
<include name="*/*.zip"/>
</patternset>
</fileset>
<fileset dir="${xlayout.source.contributions.library.dir}" casesensitive="yes">
<patternset>
<include name="*.jar"/>
<include name="*.zip"/>
</patternset>
</fileset>
</path>
</classpath>
</java>
</target>
</project>

View File

@ -0,0 +1,37 @@
<project default="sheetviewer" basedir="../../" name="Sheet Viewer build">
<property name="build.root" value="build"/>
<!-- =================================================================== -->
<!-- GUI Run Target -->
<!-- =================================================================== -->
<target name="sheetviewer">
<property name="contrib.input.selection" value=""/>
<centipede-user-input name="contrib.input.selection">Please select a file/url to view </centipede-user-input>
<java classname="org.apache.poi.hssf.contrib.view.SViewer" fork="true">
<arg value="${contrib.input.selection}"/>
<classpath>
<pathelement path="${xlayout.build.contributions.classes.dir}"/>
<pathelement path="${xlayout.build.classes.dir}"/>
<path>
<fileset dir="${xlayout.library.dir}" casesensitive="yes">
<patternset>
<include name="*/*.jar"/>
<include name="*/*.zip"/>
</patternset>
</fileset>
<fileset dir="${xlayout.source.contributions.library.dir}" casesensitive="yes">
<patternset>
<include name="*.jar"/>
<include name="*.zip"/>
</patternset>
</fileset>
</path>
</classpath>
</java>
</target>
</project>

View File

@ -0,0 +1,18 @@
- build distributions
- sign distributions
- Generate announcements and HEADER.html
- upload distributions to correct dir
- tag CVS
- generate www pages and upload
- bump release ID
- send announcements to announcement@apache.org, announcements@xml.apache.org, announcements@jakarta.apache.org
- news to newsgroups: comp.lang.java.softwaretools
- post stories on
*) jakarta news page
*) theserverside.com
*) freshmeat.net
*) www.javaworld.com
*) www.javalobby.com
*) www.jguru.com
*) www.slashdot.org
(and follow them up)

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

BIN
src/documentation/images/add.jpg Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

BIN
src/documentation/images/fix.jpg Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 932 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 39 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.4 KiB

Some files were not shown because too many files have changed in this diff Show More