mirror of
https://github.com/apache/poi.git
synced 2026-02-27 12:30:08 +08:00
git-svn-id: https://svn.apache.org/repos/asf/poi/branches/mv@1886101 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
commit
2932ba4207
49
log4j/.classpath
Normal file
49
log4j/.classpath
Normal file
@ -0,0 +1,49 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src/java"/>
|
||||
<classpathentry kind="src" path="src/testcases"/>
|
||||
<classpathentry kind="src" path="src/resources/main"/>
|
||||
<classpathentry kind="src" path="src/ooxml/java"/>
|
||||
<classpathentry kind="src" path="src/ooxml/testcases"/>
|
||||
<classpathentry kind="src" path="src/resources/ooxml"/>
|
||||
<classpathentry kind="src" path="src/scratchpad/src"/>
|
||||
<classpathentry kind="src" path="src/scratchpad/testcases"/>
|
||||
<classpathentry kind="src" path="src/resources/scratchpad"/>
|
||||
<classpathentry kind="src" path="src/contrib/poi-ruby/java"/>
|
||||
<classpathentry kind="src" path="src/examples/src"/>
|
||||
<classpathentry kind="src" path="src/excelant/java"/>
|
||||
<classpathentry kind="src" path="src/excelant/testcases"/>
|
||||
<classpathentry kind="src" path="src/excelant/resources"/>
|
||||
<classpathentry kind="src" path="src/integrationtest"/>
|
||||
<classpathentry kind="lib" path="lib/ant-1.10.1.jar"/>
|
||||
<classpathentry kind="lib" path="lib/ant-launcher-1.10.1.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="lib/ooxml/xmlbeans-4.0.0.jar" sourcepath="lib/ooxml/xmlbeans-4.0.0-sources.jar"/>
|
||||
<classpathentry kind="lib" path="lib/hamcrest-core-1.3.jar"/>
|
||||
<classpathentry kind="lib" path="lib/junit-4.13.1.jar"/>
|
||||
<classpathentry kind="lib" path="lib/ooxml/curvesapi-1.06.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="build/dist/maven/poi-ooxml-full/poi-ooxml-full-5.0.0-SNAPSHOT.jar" sourcepath="build/xmlbean-sources"/>
|
||||
<classpathentry kind="lib" path="lib/main-tests/jmh-core-1.26.jar"/>
|
||||
<classpathentry kind="lib" path="lib/main-tests/jmh-generator-annprocess-1.26.jar"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
|
||||
<classpathentry exported="true" kind="lib" path="compile-lib/slf4j-api-1.7.30.jar"/>
|
||||
<classpathentry kind="lib" path="lib/ooxml-provided/bcpkix-jdk15on-1.67.jar"/>
|
||||
<classpathentry kind="lib" path="lib/ooxml-provided/bcprov-jdk15on-1.67.jar"/>
|
||||
<classpathentry kind="lib" path="lib/ooxml-tests/reflections-0.9.12.jar"/>
|
||||
<classpathentry kind="lib" path="lib/ooxml-tests/guava-30.0-jre.jar"/>
|
||||
<classpathentry kind="lib" path="lib/ooxml-tests/javassist-3.27.0-GA.jar"/>
|
||||
<classpathentry kind="lib" path="lib/ooxml-tests/log4j-1.2.17.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="lib/ooxml-provided/xmlsec-2.2.0.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="lib/commons-codec-1.15.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="lib/commons-logging-1.2.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="lib/commons-collections4-4.4.jar"/>
|
||||
<classpathentry kind="lib" path="lib/commons-math3-3.6.1.jar"/>
|
||||
<classpathentry kind="lib" path="lib/main-tests/xmlunit-core-2.8.0.jar"/>
|
||||
<classpathentry kind="lib" path="lib/objenesis-2.6.jar"/>
|
||||
<classpathentry kind="lib" path="lib/commons-compress-1.20.jar"/>
|
||||
<classpathentry kind="lib" path="lib/mockito-core-3.6.0.jar"/>
|
||||
<classpathentry kind="lib" path="lib/main-tests/byte-buddy-1.10.18.jar"/>
|
||||
<classpathentry kind="lib" path="lib/main-tests/byte-buddy-agent-1.10.18.jar"/>
|
||||
<classpathentry kind="lib" path="compile-lib/batik-all-1.12.jar"/>
|
||||
<classpathentry kind="lib" path="lib/SparseBitSet-1.2.jar"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
1
log4j/.gitattributes
vendored
Normal file
1
log4j/.gitattributes
vendored
Normal file
@ -0,0 +1 @@
|
||||
test-data/hmef/quick-contents/quick.html text eol=lf
|
||||
54
log4j/.github/workflows/test-ant.yml
vendored
Normal file
54
log4j/.github/workflows/test-ant.yml
vendored
Normal file
@ -0,0 +1,54 @@
|
||||
|
||||
# This workflow will build a Java project with Ant
|
||||
# For more information see: https://docs.github.com/en/free-pro-team@latest/actions/guides/building-and-testing-java-with-ant
|
||||
|
||||
name: Java CI with Ant
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ trunk ]
|
||||
pull_request:
|
||||
branches: [ trunk ]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ${{ matrix.os }}
|
||||
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [ubuntu-latest]
|
||||
# for now verify JDK 8 and 11
|
||||
java: [ 8, 11.0.x ]
|
||||
|
||||
name: Java ${{ matrix.java }} build
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Setup java ${{ matrix.java }}
|
||||
uses: actions/setup-java@v1
|
||||
with:
|
||||
java-version: ${{ matrix.java }}
|
||||
|
||||
- name: Set up Ant
|
||||
id: setup-ant
|
||||
run: |
|
||||
wget https://www.apache.org/dist/ant/binaries/apache-ant-1.10.9-bin.tar.gz
|
||||
tar --exclude=apache-ant-1.10.9/manual -xzvf apache-ant-1.10.9-bin.tar.gz
|
||||
ANT_HOME=`pwd`/apache-ant-1.10.9 apache-ant-1.10.9/bin/ant -version
|
||||
|
||||
- name: Cache downloaded third-party libraries
|
||||
uses: actions/cache@v2.1.3
|
||||
with:
|
||||
# A list of files, directories, and wildcard patterns to cache and restore
|
||||
path: lib
|
||||
# An explicit key for restoring and saving the cache
|
||||
key: poi-third-party-libs
|
||||
|
||||
- name: Fetch site via SVN
|
||||
id: setup-doc-site
|
||||
run: |
|
||||
svn co https://svn.apache.org/repos/asf/poi/site/src/documentation src/documentation
|
||||
|
||||
- name: Build with Ant
|
||||
run: ANT_HOME=`pwd`/apache-ant-1.10.9 apache-ant-1.10.9/bin/ant clean jenkins
|
||||
37
log4j/.github/workflows/test-gradle.yml
vendored
Normal file
37
log4j/.github/workflows/test-gradle.yml
vendored
Normal file
@ -0,0 +1,37 @@
|
||||
# This workflow will build a Java project with Gradle
|
||||
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle
|
||||
|
||||
name: Java CI with Gradle
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ trunk ]
|
||||
pull_request:
|
||||
branches: [ trunk ]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Set up JDK 1.8
|
||||
uses: actions/setup-java@v1
|
||||
with:
|
||||
java-version: 1.8
|
||||
|
||||
- name: Cache
|
||||
uses: actions/cache@v2.1.3
|
||||
with:
|
||||
# A list of files, directories, and wildcard patterns to cache and restore
|
||||
path: lib
|
||||
# An explicit key for restoring and saving the cache
|
||||
key: poi-third-party-libs
|
||||
|
||||
- name: Grant execute permission for gradlew
|
||||
run: chmod +x gradlew
|
||||
|
||||
- name: Build with Gradle
|
||||
run: ./gradlew check
|
||||
34
log4j/.github/workflows/test-maven.yml
vendored
Normal file
34
log4j/.github/workflows/test-maven.yml
vendored
Normal file
@ -0,0 +1,34 @@
|
||||
# This workflow will build a Java project with Maven
|
||||
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven
|
||||
|
||||
name: Java CI with Maven
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ trunk ]
|
||||
pull_request:
|
||||
branches: [ trunk ]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Set up JDK 1.8
|
||||
uses: actions/setup-java@v1
|
||||
with:
|
||||
java-version: 1.8
|
||||
|
||||
- name: Cache
|
||||
uses: actions/cache@v2.1.3
|
||||
with:
|
||||
# A list of files, directories, and wildcard patterns to cache and restore
|
||||
path: lib
|
||||
# An explicit key for restoring and saving the cache
|
||||
key: poi-third-party-libs
|
||||
|
||||
- name: Build with Maven
|
||||
run: (cd sonar && mvn -B validate package --file pom.xml)
|
||||
49
log4j/.gitignore
vendored
Normal file
49
log4j/.gitignore
vendored
Normal file
@ -0,0 +1,49 @@
|
||||
classes
|
||||
workbook.xls
|
||||
bak
|
||||
build.number
|
||||
*.el
|
||||
scripts
|
||||
untitled1.jpx
|
||||
log*.*
|
||||
*.log
|
||||
|
||||
forrest.properties
|
||||
compile-lib/
|
||||
ooxml-lib/
|
||||
ooxml-testlib/
|
||||
|
||||
# Eclipse
|
||||
/bin
|
||||
.settings
|
||||
|
||||
# Tests
|
||||
junit*.properties
|
||||
TEST-org.apache.poi*.xml
|
||||
|
||||
# Sonar
|
||||
.sonar
|
||||
sonar/main/src/
|
||||
sonar/ooxml/src/
|
||||
sonar/scratchpad/src/
|
||||
sonar/ooxml-full/src/
|
||||
sonar/examples/src/
|
||||
sonar/excelant/src/
|
||||
sonar/target
|
||||
sonar/*/target
|
||||
|
||||
# IntelliJ
|
||||
/out/
|
||||
.idea
|
||||
*.iml
|
||||
*.iws
|
||||
*.ipr
|
||||
|
||||
# Gradle
|
||||
.gradle
|
||||
|
||||
# Ant
|
||||
.ant-targets-build.xml
|
||||
build
|
||||
dist
|
||||
lib/
|
||||
18
log4j/.project
Normal file
18
log4j/.project
Normal file
@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>ApachePOI</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.sonar.ide.eclipse.core.sonarNature</nature>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
2
log4j/.settings/com.vaadin.designer.prefs
Normal file
2
log4j/.settings/com.vaadin.designer.prefs
Normal file
@ -0,0 +1,2 @@
|
||||
applicationTheme=Project structure is not supported.
|
||||
eclipse.preferences.version=1
|
||||
2
log4j/.settings/org.eclipse.core.resources.prefs
Normal file
2
log4j/.settings/org.eclipse.core.resources.prefs
Normal file
@ -0,0 +1,2 @@
|
||||
eclipse.preferences.version=1
|
||||
encoding/<project>=UTF-8
|
||||
419
log4j/.settings/org.eclipse.jdt.core.prefs
Normal file
419
log4j/.settings/org.eclipse.jdt.core.prefs
Normal file
@ -0,0 +1,419 @@
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.codeComplete.argumentPrefixes=
|
||||
org.eclipse.jdt.core.codeComplete.argumentSuffixes=
|
||||
org.eclipse.jdt.core.codeComplete.fieldPrefixes=
|
||||
org.eclipse.jdt.core.codeComplete.fieldSuffixes=
|
||||
org.eclipse.jdt.core.codeComplete.localPrefixes=
|
||||
org.eclipse.jdt.core.codeComplete.localSuffixes=
|
||||
org.eclipse.jdt.core.codeComplete.staticFieldPrefixes=
|
||||
org.eclipse.jdt.core.codeComplete.staticFieldSuffixes=
|
||||
org.eclipse.jdt.core.codeComplete.staticFinalFieldPrefixes=
|
||||
org.eclipse.jdt.core.codeComplete.staticFinalFieldSuffixes=
|
||||
org.eclipse.jdt.core.compiler.annotation.inheritNullAnnotations=disabled
|
||||
org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore
|
||||
org.eclipse.jdt.core.compiler.annotation.nonnull=org.eclipse.jdt.annotation.NonNull
|
||||
org.eclipse.jdt.core.compiler.annotation.nonnull.secondary=
|
||||
org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annotation.NonNullByDefault
|
||||
org.eclipse.jdt.core.compiler.annotation.nonnullbydefault.secondary=
|
||||
org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable
|
||||
org.eclipse.jdt.core.compiler.annotation.nullable.secondary=
|
||||
org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
|
||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||
org.eclipse.jdt.core.compiler.compliance=1.8
|
||||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
||||
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
||||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
||||
org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning
|
||||
org.eclipse.jdt.core.compiler.problem.deadCode=warning
|
||||
org.eclipse.jdt.core.compiler.problem.deprecation=warning
|
||||
org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
|
||||
org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning
|
||||
org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning
|
||||
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
|
||||
org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning
|
||||
org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning
|
||||
org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=warning
|
||||
org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning
|
||||
org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=warning
|
||||
org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled
|
||||
org.eclipse.jdt.core.compiler.problem.missingSerialVersion=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning
|
||||
org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning
|
||||
org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.nonnullParameterAnnotationDropped=warning
|
||||
org.eclipse.jdt.core.compiler.problem.nonnullTypeVariableFromLegacyInvocation=warning
|
||||
org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error
|
||||
org.eclipse.jdt.core.compiler.problem.nullReference=warning
|
||||
org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error
|
||||
org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=warning
|
||||
org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning
|
||||
org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.pessimisticNullAnalysisForFreeTypeVariables=warning
|
||||
org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning
|
||||
org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning
|
||||
org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning
|
||||
org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
|
||||
org.eclipse.jdt.core.compiler.problem.syntacticNullAnalysisForFields=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
|
||||
org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=enabled
|
||||
org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
|
||||
org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning
|
||||
org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning
|
||||
org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled
|
||||
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled
|
||||
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.unusedExceptionParameter=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unusedImport=warning
|
||||
org.eclipse.jdt.core.compiler.problem.unusedLabel=warning
|
||||
org.eclipse.jdt.core.compiler.problem.unusedLocal=warning
|
||||
org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled
|
||||
org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
|
||||
org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
|
||||
org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
|
||||
org.eclipse.jdt.core.compiler.source=1.8
|
||||
org.eclipse.jdt.core.formatter.align_fields_grouping_blank_lines=2147483647
|
||||
org.eclipse.jdt.core.formatter.align_type_members_on_columns=false
|
||||
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=0
|
||||
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_assignment=0
|
||||
org.eclipse.jdt.core.formatter.alignment_for_binary_expression=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_compact_if=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=80
|
||||
org.eclipse.jdt.core.formatter.alignment_for_enum_constants=0
|
||||
org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_expressions_in_for_loop_header=0
|
||||
org.eclipse.jdt.core.formatter.alignment_for_method_declaration=0
|
||||
org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_parameterized_type_references=0
|
||||
org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_resources_in_try=80
|
||||
org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_type_arguments=0
|
||||
org.eclipse.jdt.core.formatter.alignment_for_type_parameters=0
|
||||
org.eclipse.jdt.core.formatter.alignment_for_union_type_in_multicatch=16
|
||||
org.eclipse.jdt.core.formatter.blank_lines_after_imports=1
|
||||
org.eclipse.jdt.core.formatter.blank_lines_after_package=1
|
||||
org.eclipse.jdt.core.formatter.blank_lines_before_field=0
|
||||
org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration=0
|
||||
org.eclipse.jdt.core.formatter.blank_lines_before_imports=1
|
||||
org.eclipse.jdt.core.formatter.blank_lines_before_member_type=1
|
||||
org.eclipse.jdt.core.formatter.blank_lines_before_method=1
|
||||
org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk=1
|
||||
org.eclipse.jdt.core.formatter.blank_lines_before_package=0
|
||||
org.eclipse.jdt.core.formatter.blank_lines_between_import_groups=1
|
||||
org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations=1
|
||||
org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration=end_of_line
|
||||
org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration=end_of_line
|
||||
org.eclipse.jdt.core.formatter.brace_position_for_array_initializer=end_of_line
|
||||
org.eclipse.jdt.core.formatter.brace_position_for_block=end_of_line
|
||||
org.eclipse.jdt.core.formatter.brace_position_for_block_in_case=end_of_line
|
||||
org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration=end_of_line
|
||||
org.eclipse.jdt.core.formatter.brace_position_for_enum_constant=end_of_line
|
||||
org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration=end_of_line
|
||||
org.eclipse.jdt.core.formatter.brace_position_for_lambda_body=end_of_line
|
||||
org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=end_of_line
|
||||
org.eclipse.jdt.core.formatter.brace_position_for_switch=end_of_line
|
||||
org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=end_of_line
|
||||
org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment=false
|
||||
org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment=false
|
||||
org.eclipse.jdt.core.formatter.comment.format_block_comments=true
|
||||
org.eclipse.jdt.core.formatter.comment.format_header=false
|
||||
org.eclipse.jdt.core.formatter.comment.format_html=true
|
||||
org.eclipse.jdt.core.formatter.comment.format_javadoc_comments=true
|
||||
org.eclipse.jdt.core.formatter.comment.format_line_comments=true
|
||||
org.eclipse.jdt.core.formatter.comment.format_source_code=true
|
||||
org.eclipse.jdt.core.formatter.comment.indent_parameter_description=true
|
||||
org.eclipse.jdt.core.formatter.comment.indent_root_tags=true
|
||||
org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags=insert
|
||||
org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=insert
|
||||
org.eclipse.jdt.core.formatter.comment.line_length=80
|
||||
org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries=true
|
||||
org.eclipse.jdt.core.formatter.comment.new_lines_at_javadoc_boundaries=true
|
||||
org.eclipse.jdt.core.formatter.comment.preserve_white_space_between_code_and_line_comments=false
|
||||
org.eclipse.jdt.core.formatter.compact_else_if=true
|
||||
org.eclipse.jdt.core.formatter.continuation_indentation=2
|
||||
org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer=2
|
||||
org.eclipse.jdt.core.formatter.disabling_tag=@formatter\:off
|
||||
org.eclipse.jdt.core.formatter.enabling_tag=@formatter\:on
|
||||
org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line=false
|
||||
org.eclipse.jdt.core.formatter.format_line_comment_starting_on_first_column=true
|
||||
org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header=true
|
||||
org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header=true
|
||||
org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header=true
|
||||
org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header=true
|
||||
org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases=true
|
||||
org.eclipse.jdt.core.formatter.indent_empty_lines=false
|
||||
org.eclipse.jdt.core.formatter.indent_statements_compare_to_block=true
|
||||
org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true
|
||||
org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true
|
||||
org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=false
|
||||
org.eclipse.jdt.core.formatter.indentation.size=4
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_enum_constant=insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field=insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable=insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method=insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_package=insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_type=insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_after_label=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_after_type_annotation=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration=insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration=insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block=insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant=insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body=insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_binary_operator=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_ellipsis=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_lambda_arrow=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_try=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_try_resources=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_unary_operator=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_binary_operator=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_try=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_ellipsis=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_lambda_arrow=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_try=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_semicolon=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_try_resources=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_unary_operator=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation=do not insert
|
||||
org.eclipse.jdt.core.formatter.join_lines_in_comments=true
|
||||
org.eclipse.jdt.core.formatter.join_wrapped_lines=true
|
||||
org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line=false
|
||||
org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line=false
|
||||
org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line=false
|
||||
org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=false
|
||||
org.eclipse.jdt.core.formatter.lineSplit=80
|
||||
org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column=false
|
||||
org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column=false
|
||||
org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body=0
|
||||
org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve=1
|
||||
org.eclipse.jdt.core.formatter.parentheses_positions_in_annotation=common_lines
|
||||
org.eclipse.jdt.core.formatter.parentheses_positions_in_catch_clause=common_lines
|
||||
org.eclipse.jdt.core.formatter.parentheses_positions_in_enum_constant_declaration=common_lines
|
||||
org.eclipse.jdt.core.formatter.parentheses_positions_in_for_statment=common_lines
|
||||
org.eclipse.jdt.core.formatter.parentheses_positions_in_if_while_statement=common_lines
|
||||
org.eclipse.jdt.core.formatter.parentheses_positions_in_lambda_declaration=common_lines
|
||||
org.eclipse.jdt.core.formatter.parentheses_positions_in_method_delcaration=common_lines
|
||||
org.eclipse.jdt.core.formatter.parentheses_positions_in_method_invocation=common_lines
|
||||
org.eclipse.jdt.core.formatter.parentheses_positions_in_switch_statement=common_lines
|
||||
org.eclipse.jdt.core.formatter.parentheses_positions_in_try_clause=common_lines
|
||||
org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=true
|
||||
org.eclipse.jdt.core.formatter.tabulation.char=space
|
||||
org.eclipse.jdt.core.formatter.tabulation.size=4
|
||||
org.eclipse.jdt.core.formatter.use_on_off_tags=false
|
||||
org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false
|
||||
org.eclipse.jdt.core.formatter.wrap_before_assignment_operator=false
|
||||
org.eclipse.jdt.core.formatter.wrap_before_binary_operator=true
|
||||
org.eclipse.jdt.core.formatter.wrap_before_conditional_operator=true
|
||||
org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch=true
|
||||
org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested=true
|
||||
org.eclipse.jdt.core.javaFormatter=org.eclipse.jdt.core.defaultJavaFormatter
|
||||
131
log4j/.settings/org.eclipse.jdt.ui.prefs
Normal file
131
log4j/.settings/org.eclipse.jdt.ui.prefs
Normal file
File diff suppressed because one or more lines are too long
4
log4j/.settings/org.moreunit.core.prefs
Normal file
4
log4j/.settings/org.moreunit.core.prefs
Normal file
@ -0,0 +1,4 @@
|
||||
eclipse.preferences.version=1
|
||||
org.moreunit.core.anyLanguage.srcFolderPathTemplate=${srcProject}
|
||||
org.moreunit.core.anyLanguage.testFileNameTemplate=${srcFile}Test
|
||||
org.moreunit.core.anyLanguage.testFolderPathTemplate=${srcProject}
|
||||
4
log4j/.settings/org.moreunit.prefs
Normal file
4
log4j/.settings/org.moreunit.prefs
Normal file
@ -0,0 +1,4 @@
|
||||
eclipse.preferences.version=1
|
||||
org.moreunit.preferences.version=2
|
||||
org.moreunit.unitsourcefolder=ApachePOI\:src/java\:ApachePOI\:src/testcases\#ApachePOI\:src/java\:ApachePOI\:src/ooxml/testcases\#ApachePOI\:src/java\:ApachePOI\:src/scratchpad/testcases\#ApachePOI\:src/java\:ApachePOI\:src/excelant/testcases\#ApachePOI\:src/java\:ApachePOI\:src/integrationtest
|
||||
org.moreunit.useprojectsettings=true
|
||||
14
log4j/.travis.yml
Normal file
14
log4j/.travis.yml
Normal file
@ -0,0 +1,14 @@
|
||||
dist: bionic
|
||||
language: java
|
||||
jdk:
|
||||
- openjdk11
|
||||
before_install:
|
||||
- wget https://www.apache.org/dist/ant/binaries/apache-ant-1.10.9-bin.tar.gz
|
||||
- tar -xzvf apache-ant-1.10.9-bin.tar.gz
|
||||
- export PATH=`pwd`/apache-ant-1.10.9/bin:$PATH
|
||||
- echo $(ant -version)
|
||||
- svn co https://svn.apache.org/repos/asf/poi/site/src/documentation src/documentation
|
||||
install: /bin/true
|
||||
before_script: /bin/true
|
||||
script:
|
||||
- ant clean jenkins
|
||||
2686
log4j/KEYS
Normal file
2686
log4j/KEYS
Normal file
File diff suppressed because it is too large
Load Diff
104
log4j/README.rst
Normal file
104
log4j/README.rst
Normal file
@ -0,0 +1,104 @@
|
||||
|
||||
Apache POI
|
||||
======================
|
||||
|
||||
A Java library for reading and writing Microsoft Office binary and OOXML file formats.
|
||||
|
||||
The Apache POI Project's mission is to create and maintain Java APIs for manipulating various file formats based upon the Office Open XML standards (OOXML) and Microsoft's OLE 2 Compound Document format (OLE2). In short, you can read and write MS Excel files using Java. In addition, you can read and write MS Word and MS PowerPoint files using Java. Apache POI is your Java Excel solution (for Excel 97-2008). We have a complete API for porting other OOXML and OLE2 formats and welcome others to participate.
|
||||
|
||||
OLE2 files include most Microsoft Office files such as XLS, DOC, and PPT as well as MFC serialization API based file formats. The project provides APIs for the OLE2 Filesystem (POIFS) and OLE2 Document Properties (HPSF).
|
||||
|
||||
Office OpenXML Format is the new standards based XML file format found in Microsoft Office 2007 and 2008. This includes XLSX, DOCX and PPTX. The project provides a low level API to support the Open Packaging Conventions using openxml4j.
|
||||
|
||||
For each MS Office application there exists a component module that attempts to provide a common high level Java api to both OLE2 and OOXML document formats. This is most developed for Excel workbooks (SS=HSSF+XSSF). Work is progressing for Word documents (WP=HWPF+XWPF) and PowerPoint presentations (SL=HSLF+XSLF).
|
||||
|
||||
The project has some support for Outlook (HSMF). Microsoft opened the specifications to this format in October 2007. We would welcome contributions.
|
||||
|
||||
There are also projects for Visio (HDGF and XDGF), TNEF (HMEF), and Publisher (HPBF).
|
||||
|
||||
This library includes the following components, roughly in descending order of maturity:
|
||||
|
||||
* Excel spreadsheets (Common SS = HSSF, XSSF, and SXSSF)
|
||||
* PowerPoint slideshows (Common SL = HSLF and XSLF)
|
||||
* Word processing documents (Common WP = HWPF and XWPF)
|
||||
* Outlook email (HSMF and HMEF)
|
||||
* Visio diagrams (HDGF and XDGF)
|
||||
* Publisher (HPBF)
|
||||
|
||||
And lower-level, supporting components:
|
||||
|
||||
* OLE2 Filesystem (POIFS)
|
||||
* OLE2 Document Properties (HPSF)
|
||||
* TNEF (HMEF) for Outlook winmail.dat files
|
||||
* OpenXML4J (OOXML)
|
||||
|
||||
| Components named H??F are for reading or writing OLE2 binary formats.
|
||||
| Components named X??F are for reading or writing OpenOffice XML (OOXML) formats.
|
||||
|
||||
Getting started
|
||||
------------------
|
||||
|
||||
Website: https://poi.apache.org/
|
||||
|
||||
`Mailing lists`_:
|
||||
|
||||
* `Developers`_
|
||||
* `Users`_
|
||||
* `General`_ (release announcements)
|
||||
|
||||
Bug tracker:
|
||||
|
||||
* `Bugzilla`_
|
||||
* `GitHub pull requests`_
|
||||
|
||||
Source code:
|
||||
|
||||
* Official `Apache Subversion repo`_ at apache.org
|
||||
* `ViewVC repo browser`_ at apache.org
|
||||
* `GitHub git mirror`_ at github.com
|
||||
|
||||
Requires Java 1.8 or later.
|
||||
|
||||
Contributing
|
||||
------------------
|
||||
|
||||
* Download and install svn or git, Java JDK 1.8+, and Apache Ant 1.8+ or Gradle
|
||||
|
||||
* Check out the code from svn or git
|
||||
|
||||
* Import the project into Eclipse or your favorite IDE
|
||||
|
||||
* Write a unit test:
|
||||
|
||||
* Binary formats and Common APIs: src/testcases/org/apache/poi/
|
||||
* OOXML APIs only: src/ooxml/testcases/org/apache/poi/
|
||||
* Scratchpad (Binary formats): src/scratchpad/testcases/org/apache/poi/
|
||||
* Test files: test-data/
|
||||
|
||||
* Navigate the source, make changes, and run unit tests to verify
|
||||
|
||||
* Binary formats and Common APIs: src/java/org/apache/poi/
|
||||
* OOXML APIs only: src/ooxml/java/org/apache/poi/
|
||||
* Scratchpad (Binary formats): src/scratchpad/src/org/apache/poi/
|
||||
* Examples: src/examples/src/org/apache/poi/
|
||||
|
||||
* More info: `How To Build page`_ at apache.org
|
||||
|
||||
Building jar files
|
||||
------------------
|
||||
|
||||
To build the jar files for poi, poi-ooxml, poi-ooxml-lite, poi-ooxml-full and poi-examples::
|
||||
|
||||
ant jar
|
||||
|
||||
.. _Mailing lists: https://poi.apache.org/mailinglists.html
|
||||
.. _Developers: https://lists.apache.org/list.html?dev@poi.apache.org
|
||||
.. _Users: https://lists.apache.org/list.html?user@poi.apache.org
|
||||
.. _General: https://lists.apache.org/list.html?general@poi.apache.org
|
||||
.. _Bugzilla: https://bz.apache.org/bugzilla/buglist.cgi?product=POI
|
||||
.. _GitHub pull requests: https://github.com/apache/poi/pulls
|
||||
|
||||
.. _Apache Subversion repo: https://svn.apache.org/repos/asf/poi/trunk
|
||||
.. _ViewVC repo browser: https://svn.apache.org/viewvc/poi/trunk
|
||||
.. _GitHub git mirror: https://github.com/apache/poi
|
||||
.. _How To Build page: http://poi.apache.org/devel/
|
||||
453
log4j/build.gradle
Normal file
453
log4j/build.gradle
Normal file
@ -0,0 +1,453 @@
|
||||
/* ====================================================================
|
||||
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.
|
||||
==================================================================== */
|
||||
buildscript {
|
||||
repositories {
|
||||
maven { url "https://plugins.gradle.org/m2/" }
|
||||
}
|
||||
|
||||
dependencies {
|
||||
// 2.x fails with "Could not get unknown property 'me'"
|
||||
classpath 'me.champeau.gradle:japicmp-gradle-plugin:0.1.2'
|
||||
classpath "org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:3.0"
|
||||
}
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
// Only add the plugin for Sonar if enabled
|
||||
if (project.hasProperty('enableSonar')) {
|
||||
println 'Enabling Sonar support'
|
||||
apply plugin: "org.sonarqube"
|
||||
}
|
||||
|
||||
// For help converting an Ant build to a Gradle build, see
|
||||
// https://docs.gradle.org/current/userguide/ant.html
|
||||
|
||||
configurations {
|
||||
antLibs {
|
||||
attributes {
|
||||
attribute(Bundling.BUNDLING_ATTRIBUTE, objects.named(Bundling, Bundling.EXTERNAL))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
antLibs("org.junit.jupiter:junit-jupiter:5.7.0")
|
||||
antLibs("org.apache.ant:ant-junitlauncher:1.10.9")
|
||||
}
|
||||
|
||||
ant.taskdef(name: "junit",
|
||||
classname: "org.apache.tools.ant.taskdefs.optional.junitlauncher.confined.JUnitLauncherTask",
|
||||
classpath: configurations.antLibs.asPath)
|
||||
|
||||
wrapper {
|
||||
gradleVersion = '6.8'
|
||||
}
|
||||
|
||||
task adjustWrapperPropertiesFile {
|
||||
doLast {
|
||||
ant.replaceregexp(match:'^#.*', replace:'', flags:'g', byline:true) {
|
||||
fileset(dir: project.projectDir, includes: 'gradle/wrapper/gradle-wrapper.properties')
|
||||
}
|
||||
new File(project.projectDir, 'gradle/wrapper/gradle-wrapper.properties').with { it.text = it.readLines().findAll { it }.sort().join('\n') }
|
||||
ant.fixcrlf(file: 'gradle/wrapper/gradle-wrapper.properties', eol: 'lf')
|
||||
}
|
||||
}
|
||||
wrapper.finalizedBy adjustWrapperPropertiesFile
|
||||
|
||||
|
||||
// helper method to download a jar file manually from an URL, e.g. XMLBeans 4.0.0
|
||||
def urlFile = { url, name ->
|
||||
File file = new File("$buildDir/download/${name}.jar")
|
||||
file.parentFile.mkdirs()
|
||||
if (!file.exists()) {
|
||||
new URL(url).withInputStream { downloadStream ->
|
||||
file.withOutputStream { fileOut ->
|
||||
fileOut << downloadStream
|
||||
}
|
||||
}
|
||||
}
|
||||
files(file.absolutePath)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Define properties for all projects, including this one
|
||||
|
||||
*/
|
||||
allprojects {
|
||||
apply plugin: 'eclipse'
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Define things that are only necessary in sub-projects, but not in the master-project itself
|
||||
|
||||
*/
|
||||
subprojects {
|
||||
//Put instructions for each sub project, but not the master
|
||||
apply plugin: 'java'
|
||||
apply plugin: 'jacoco'
|
||||
|
||||
// See https://github.com/melix/japicmp-gradle-plugin
|
||||
apply plugin: 'me.champeau.gradle.japicmp'
|
||||
|
||||
version = '5.0.1-SNAPSHOT'
|
||||
ext {
|
||||
bouncyCastleVersion = '1.67'
|
||||
commonsCodecVersion = '1.15'
|
||||
commonsCompressVersion = '1.20'
|
||||
commonsMathVersion = '3.6.1'
|
||||
japicmpversion = '5.0.0'
|
||||
junitVersion = '5.7.0'
|
||||
mockitoVersion = '3.6.0'
|
||||
hamcrestVersion = '2.2'
|
||||
slf4jVersion = '1.7.30'
|
||||
xmlbeansVersion = '4.0.0'
|
||||
}
|
||||
|
||||
tasks.withType(JavaCompile) {
|
||||
options.encoding = 'UTF-8'
|
||||
}
|
||||
|
||||
sourceCompatibility = 1.8
|
||||
targetCompatibility = 1.8
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven {
|
||||
url 'https://repository.apache.org/content/repositories/releases'
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
testCompile "org.junit.jupiter:junit-jupiter:${junitVersion}"
|
||||
testCompile "org.mockito:mockito-core:${mockitoVersion}"
|
||||
testCompile "org.hamcrest:hamcrest:${hamcrestVersion}"
|
||||
}
|
||||
|
||||
jar {
|
||||
manifest {
|
||||
attributes 'Implementation-Title': 'Apache POI', 'Implementation-Version': version
|
||||
}
|
||||
}
|
||||
|
||||
test {
|
||||
// make XML test-results available for Jenkins CI
|
||||
useJUnitPlatform()
|
||||
reports {
|
||||
junitXml.enabled = true
|
||||
}
|
||||
|
||||
// Exclude some tests that are not actually tests or do not run cleanly on purpose
|
||||
exclude '**/BaseTestBorderStyle.class'
|
||||
exclude '**/BaseTestCellUtil.class'
|
||||
exclude '**/TestUnfixedBugs.class'
|
||||
exclude '**/TestOneFile.class'
|
||||
|
||||
// Exclude Test Suites
|
||||
exclude '**/All*Tests.class'
|
||||
exclude '**/HSSFTests.class'
|
||||
|
||||
// set heap size for the test JVM(s)
|
||||
minHeapSize = "128m"
|
||||
maxHeapSize = "768m"
|
||||
|
||||
// Specifying the local via system properties did not work, so we set them this way
|
||||
jvmArgs '-Duser.language=en -Duser.country=US'
|
||||
|
||||
// show standard out and standard error of the test JVM(s) on the console
|
||||
//testLogging.showStandardStreams = true
|
||||
|
||||
// http://forums.gradle.org/gradle/topics/jacoco_related_failure_in_multiproject_build
|
||||
systemProperties['user.dir'] = workingDir
|
||||
|
||||
systemProperties['POI.testdata.path'] = '../../test-data'
|
||||
|
||||
// this is necessary for JDK 9+ to keep formatting dates the same way as in previous JDK-versions
|
||||
systemProperties['java.locale.providers'] = 'JRE,CLDR'
|
||||
}
|
||||
|
||||
jacoco {
|
||||
toolVersion = '0.8.6'
|
||||
}
|
||||
|
||||
jacocoTestReport {
|
||||
reports {
|
||||
xml.enabled true
|
||||
}
|
||||
}
|
||||
|
||||
// ensure the build-dir exists
|
||||
projectDir.mkdirs()
|
||||
|
||||
if (project.hasProperty('enableSonar')) {
|
||||
// See https://docs.sonarqube.org/latest/analysis/scan/sonarscanner-for-gradle/ and
|
||||
// https://docs.sonarqube.org/display/SONARQUBE52/Analyzing+with+SonarQube+Scanner+for+Gradle
|
||||
// for documentation of properties.
|
||||
//
|
||||
// Some additional properties are currently set in the Jenkins-DSL, see jenksin/create_jobs.groovy
|
||||
//
|
||||
sonarqube {
|
||||
properties {
|
||||
// as we currently use build/<module>/ as project-basedir, we need to tell Sonar to use
|
||||
// the root-folder as "basedir" for the projects
|
||||
property "sonar.projectBaseDir", "$projectDir/../.."
|
||||
// currently supported providers on Jenkins: "hg,git": property "sonar.scm.provider", "svn"
|
||||
|
||||
// the plugin seems to not detect our non-standard build-layout
|
||||
property "sonar.junit.reportPaths", "$projectDir/build/test-results/test"
|
||||
property "sonar.coverage.jacoco.xmlReportPaths", "$projectDir/build/reports/jacoco/test/jacocoTestReport.xml"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
task(japicmp, type: me.champeau.gradle.ArtifactJapicmpTask, dependsOn: jar) {
|
||||
to = jar.archivePath
|
||||
onlyModified = true
|
||||
onlyBinaryIncompatibleModified = true
|
||||
failOnModification = false
|
||||
txtOutputFile = file("$buildDir/reports/japi.txt")
|
||||
htmlOutputFile = file("$buildDir/reports/japi.html")
|
||||
}
|
||||
}
|
||||
|
||||
project('main') {
|
||||
sourceSets.main.java.srcDirs = ['../../src/java']
|
||||
sourceSets.main.resources.srcDirs = ['../../src/resources/main']
|
||||
sourceSets.test.java.srcDirs = ['../../src/testcases']
|
||||
|
||||
dependencies {
|
||||
compile "commons-codec:commons-codec:${commonsCodecVersion}"
|
||||
compile 'commons-logging:commons-logging:1.2'
|
||||
compile 'org.apache.commons:commons-collections4:4.4'
|
||||
compile "org.apache.commons:commons-math3:${commonsMathVersion}"
|
||||
compile "org.slf4j:slf4j-api:${slf4jVersion}"
|
||||
compile 'javax.activation:activation:1.1.1'
|
||||
compile 'com.zaxxer:SparseBitSet:1.2'
|
||||
|
||||
testCompile 'org.reflections:reflections:0.9.12'
|
||||
testRuntime "org.slf4j:slf4j-simple:${slf4jVersion}"
|
||||
}
|
||||
|
||||
jar {
|
||||
manifest {
|
||||
attributes 'Automatic-Module-Name': 'org.apache.poi.main'
|
||||
}
|
||||
}
|
||||
|
||||
// Create a separate jar for test-code to depend on it in other projects
|
||||
// See http://stackoverflow.com/questions/5144325/gradle-test-dependency
|
||||
task testJar(type: Jar, dependsOn: testClasses) {
|
||||
baseName = "test-${project.archivesBaseName}"
|
||||
from sourceSets.test.output
|
||||
}
|
||||
|
||||
configurations {
|
||||
tests
|
||||
}
|
||||
|
||||
artifacts {
|
||||
tests testJar
|
||||
}
|
||||
|
||||
japicmp.baseline = "org.apache.poi:poi:${japicmpversion}@jar"
|
||||
}
|
||||
|
||||
project('ooxml') {
|
||||
|
||||
sourceSets.main.java.srcDirs = ['../../src/ooxml/java']
|
||||
sourceSets.main.resources.srcDirs = ['../../src/ooxml/resources', '../../src/resources/ooxml']
|
||||
sourceSets.test.java.srcDirs = ['../../src/ooxml/testcases']
|
||||
|
||||
configurations {
|
||||
antdep
|
||||
}
|
||||
|
||||
dependencies {
|
||||
antdep 'org.apache.ant:ant:1.10.9'
|
||||
}
|
||||
|
||||
// we need to ensure that the custom ant tasks are compiled before we import the build.xml file
|
||||
ant.mkdir(dir: "../../build/poi-ant-contrib")
|
||||
ant.javac(srcdir: "../../src/excelant/poi-ant-contrib"
|
||||
, destdir: "../../build/poi-ant-contrib"
|
||||
, classpath: configurations.antdep.asPath
|
||||
, includeantruntime: "true"
|
||||
, excludes: "Junit5Progress.java"
|
||||
)
|
||||
|
||||
// for now import the ant-task for building the jars from build.xml
|
||||
// we need to rename the tasks as e.g. task "jar" conflicts with :ooxml:jar
|
||||
ant.importBuild('../../build.xml') { antTargetName ->
|
||||
'ant-' + antTargetName
|
||||
}
|
||||
compileJava.dependsOn 'ant-compile-ooxml-xsds'
|
||||
|
||||
dependencies {
|
||||
compile "org.apache.xmlbeans:xmlbeans:${xmlbeansVersion}"
|
||||
compile 'org.apache.commons:commons-collections4:4.4'
|
||||
compile "org.apache.commons:commons-math3:${commonsMathVersion}"
|
||||
compile "org.apache.commons:commons-compress:${commonsCompressVersion}"
|
||||
compile 'org.apache.santuario:xmlsec:2.2.0'
|
||||
compile "org.bouncycastle:bcpkix-jdk15on:${bouncyCastleVersion}"
|
||||
compile 'com.github.virtuald:curvesapi:1.06'
|
||||
compile 'com.zaxxer:SparseBitSet:1.2'
|
||||
|
||||
// compile only, don't add it to our dist as it blows up the size
|
||||
compile 'org.apache.xmlgraphics:batik-all:1.13'
|
||||
compile 'xml-apis:xml-apis-ext:1.3.04'
|
||||
compile 'org.apache.xmlgraphics:xmlgraphics-commons:2.4'
|
||||
|
||||
compile 'org.apache.pdfbox:pdfbox:2.0.22'
|
||||
compile 'org.apache.pdfbox:fontbox:2.0.22'
|
||||
compile 'de.rototor.pdfbox:graphics2d:0.30'
|
||||
|
||||
// for ooxml-lite, should we move this somewhere else?
|
||||
compile "org.junit.jupiter:junit-jupiter:${junitVersion}"
|
||||
|
||||
compile project(':main')
|
||||
compile project(':scratchpad') // TODO: get rid of this dependency!
|
||||
compile files("../../build/dist/maven/poi-ooxml-full/poi-ooxml-full-${version}.jar")
|
||||
|
||||
testCompile 'org.xmlunit:xmlunit-core:2.8.0'
|
||||
testCompile 'org.reflections:reflections:0.9.12'
|
||||
testCompile project(path: ':main', configuration: 'tests')
|
||||
testCompile 'org.openjdk.jmh:jmh-core:1.26'
|
||||
testCompile 'org.openjdk.jmh:jmh-generator-annprocess:1.26'
|
||||
testCompile 'com.google.guava:guava:30.0-jre'
|
||||
}
|
||||
|
||||
jar {
|
||||
manifest {
|
||||
attributes 'Automatic-Module-Name': 'org.apache.poi.ooxml'
|
||||
}
|
||||
}
|
||||
|
||||
japicmp.baseline = "org.apache.poi:poi:${japicmpversion}@jar"
|
||||
|
||||
test {
|
||||
// for some reason catching the OOM does not work when run from Gradle
|
||||
exclude '**/MemoryUsage.class'
|
||||
}
|
||||
}
|
||||
|
||||
project('examples') {
|
||||
sourceSets.main.java.srcDirs = ['../../src/examples/src']
|
||||
|
||||
dependencies {
|
||||
compile project(':main')
|
||||
compile project(':ooxml')
|
||||
compile project(':scratchpad')
|
||||
|
||||
compile "org.apache.xmlbeans:xmlbeans:${xmlbeansVersion}"
|
||||
|
||||
compile files("../../build/dist/maven/poi-ooxml-full/poi-ooxml-full-${version}.jar")
|
||||
compile "org.apache.commons:commons-compress:${commonsCompressVersion}"
|
||||
}
|
||||
|
||||
japicmp.enabled = false
|
||||
}
|
||||
|
||||
|
||||
project('excelant') {
|
||||
sourceSets.main.java.srcDirs = ['../../src/excelant/java']
|
||||
sourceSets.main.resources.srcDirs = ['../../src/excelant/resources']
|
||||
sourceSets.test.java.srcDirs = ['../../src/excelant/testcases']
|
||||
|
||||
dependencies {
|
||||
compile 'org.apache.ant:ant:1.10.9'
|
||||
|
||||
compile project(':main')
|
||||
compile project(':ooxml')
|
||||
|
||||
testCompile project(path: ':main', configuration: 'tests')
|
||||
}
|
||||
|
||||
jar {
|
||||
manifest {
|
||||
attributes 'Automatic-Module-Name': 'org.apache.poi.excelant'
|
||||
}
|
||||
}
|
||||
|
||||
japicmp.baseline = "org.apache.poi:poi-excelant:${japicmpversion}@jar"
|
||||
}
|
||||
|
||||
project('integrationtest') {
|
||||
sourceSets.test.java.srcDirs = ['../../src/integrationtest']
|
||||
|
||||
dependencies {
|
||||
compile 'org.apache.ant:ant:1.10.9'
|
||||
|
||||
compile project(':main')
|
||||
compile project(':ooxml')
|
||||
compile project(':scratchpad')
|
||||
compile project(':examples')
|
||||
|
||||
testCompile "org.apache.xmlbeans:xmlbeans:${xmlbeansVersion}"
|
||||
|
||||
testCompile files("../../build/dist/maven/poi-ooxml-full/poi-ooxml-full-${version}.jar")
|
||||
testCompile files(this.project(':ooxml').sourceSets.test.runtimeClasspath)
|
||||
}
|
||||
|
||||
jar {
|
||||
manifest {
|
||||
attributes 'Automatic-Module-Name': 'org.apache.poi.integrationtest'
|
||||
}
|
||||
}
|
||||
|
||||
test {
|
||||
// exclude these from the normal test-run
|
||||
exclude '**/TestAllFiles.class'
|
||||
exclude '**/*FileHandler.class'
|
||||
exclude '**/RecordsStresser.class'
|
||||
}
|
||||
|
||||
task integrationTest(type: Test) {
|
||||
// these are just tests used during development of more test-code
|
||||
exclude '**/*FileHandler.class'
|
||||
exclude '**/RecordStresser.class'
|
||||
}
|
||||
|
||||
japicmp.enabled = false
|
||||
}
|
||||
|
||||
project('scratchpad') {
|
||||
sourceSets.main.java.srcDirs = ['../../src/scratchpad/src']
|
||||
sourceSets.main.resources.srcDirs = ['../../src/resources/scratchpad']
|
||||
sourceSets.test.java.srcDirs = ['../../src/scratchpad/testcases']
|
||||
|
||||
dependencies {
|
||||
compile project(':main')
|
||||
compile "commons-codec:commons-codec:${commonsCodecVersion}"
|
||||
compile "org.apache.commons:commons-math3:${commonsMathVersion}"
|
||||
|
||||
// cyclic-dependency here: compile project(':ooxml')
|
||||
|
||||
testCompile project(path: ':main', configuration: 'tests')
|
||||
}
|
||||
|
||||
jar {
|
||||
manifest {
|
||||
attributes 'Automatic-Module-Name': 'org.apache.poi.scratchpad'
|
||||
}
|
||||
}
|
||||
|
||||
japicmp.baseline = "org.apache.poi:poi:${japicmpversion}@jar"
|
||||
}
|
||||
3148
log4j/build.xml
Normal file
3148
log4j/build.xml
Normal file
File diff suppressed because it is too large
Load Diff
198
log4j/doap_POI.rdf
Normal file
198
log4j/doap_POI.rdf
Normal file
@ -0,0 +1,198 @@
|
||||
<?xml version="1.0"?>
|
||||
<?xml-stylesheet type="text/xsl"?>
|
||||
<rdf:RDF xml:lang="en"
|
||||
xmlns="http://usefulinc.com/ns/doap#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:asfext="http://projects.apache.org/ns/asfext#"
|
||||
xmlns:foaf="http://xmlns.com/foaf/0.1/">
|
||||
<!--
|
||||
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 rdf:about="https://poi.apache.org">
|
||||
<created>2006-01-26</created>
|
||||
<license rdf:resource="https://spdx.org/licenses/Apache-2.0" />
|
||||
<name>Apache POI</name>
|
||||
<homepage rdf:resource="https://poi.apache.org" />
|
||||
<asfext:pmc rdf:resource="https://poi.apache.org" />
|
||||
<shortdesc>Java API To Access Microsoft Document File Formats</shortdesc>
|
||||
<description>APIs for manipulating various file formats based upon Open Office XML (ECMA-376) and Microsoft's OLE 2 Compound Document formats using pure Java. Apache POI is your Java Excel, Word and PowerPoint solution. We have a complete API for porting other OOXML and OLE 2 Compound Document formats and welcome others to participate.</description>
|
||||
<bug-database rdf:resource="https://issues.apache.org/bugzilla/buglist.cgi?product=POI" />
|
||||
<mailing-list rdf:resource="https://poi.apache.org/mailinglists.html" />
|
||||
<download-page rdf:resource="https://www.apache.org/dyn/closer.lua/poi/" />
|
||||
<programming-language>Java</programming-language>
|
||||
<category rdf:resource="https://projects.apache.org/category/content" />
|
||||
<category rdf:resource="https://projects.apache.org/category/library" />
|
||||
<release>
|
||||
<Version>
|
||||
<name>Apache POI 5.0.0</name>
|
||||
<created>2021-01-17</created>
|
||||
<revision>5.0.0</revision>
|
||||
</Version>
|
||||
</release>
|
||||
<release>
|
||||
<Version>
|
||||
<name>Apache POI 4.1.2</name>
|
||||
<created>2020-02-14</created>
|
||||
<revision>4.1.2</revision>
|
||||
</Version>
|
||||
</release>
|
||||
<release>
|
||||
<Version>
|
||||
<name>Apache POI 4.1.1</name>
|
||||
<created>2019-10-20</created>
|
||||
<revision>4.1.1</revision>
|
||||
</Version>
|
||||
</release>
|
||||
<release>
|
||||
<Version>
|
||||
<name>Apache POI 4.1.0</name>
|
||||
<created>2019-04-08</created>
|
||||
<revision>4.1.0</revision>
|
||||
</Version>
|
||||
</release>
|
||||
<release>
|
||||
<Version>
|
||||
<name>Apache POI 4.0.1</name>
|
||||
<created>2018-12-03</created>
|
||||
<revision>4.0.1</revision>
|
||||
</Version>
|
||||
</release>
|
||||
<release>
|
||||
<Version>
|
||||
<name>Apache POI 4.0.0</name>
|
||||
<created>2018-09-07</created>
|
||||
<revision>4.0.0</revision>
|
||||
</Version>
|
||||
</release>
|
||||
<release>
|
||||
<Version>
|
||||
<name>Apache POI 3.17</name>
|
||||
<created>2017-09-15</created>
|
||||
<revision>3.17</revision>
|
||||
</Version>
|
||||
</release>
|
||||
<release>
|
||||
<Version>
|
||||
<name>Apache POI 3.16</name>
|
||||
<created>2017-04-19</created>
|
||||
<revision>3.16</revision>
|
||||
</Version>
|
||||
</release>
|
||||
<release>
|
||||
<Version>
|
||||
<name>Apache POI 3.15</name>
|
||||
<created>2016-09-21</created>
|
||||
<revision>3.15</revision>
|
||||
</Version>
|
||||
</release>
|
||||
<release>
|
||||
<Version>
|
||||
<name>Apache POI 3.14</name>
|
||||
<created>2016-03-05</created>
|
||||
<revision>3.14</revision>
|
||||
</Version>
|
||||
</release>
|
||||
<release>
|
||||
<Version>
|
||||
<name>Apache POI 3.13</name>
|
||||
<created>2015-09-29</created>
|
||||
<revision>3.13</revision>
|
||||
</Version>
|
||||
</release>
|
||||
<release>
|
||||
<Version>
|
||||
<name>Apache POI 3.12</name>
|
||||
<created>2015-05-11</created>
|
||||
<revision>3.12</revision>
|
||||
</Version>
|
||||
</release>
|
||||
<release>
|
||||
<Version>
|
||||
<name>Apache POI 3.11</name>
|
||||
<created>2014-12-21</created>
|
||||
<revision>3.11</revision>
|
||||
</Version>
|
||||
</release>
|
||||
<release>
|
||||
<Version>
|
||||
<name>Apache POI 3.10.1</name>
|
||||
<created>2014-08-18</created>
|
||||
<revision>3.10.1</revision>
|
||||
</Version>
|
||||
</release>
|
||||
<release>
|
||||
<Version>
|
||||
<name>Apache POI 3.10</name>
|
||||
<created>2014-02-08</created>
|
||||
<revision>3.10</revision>
|
||||
</Version>
|
||||
</release>
|
||||
<release>
|
||||
<Version>
|
||||
<name>Apache POI 3.9</name>
|
||||
<created>2012-12-03</created>
|
||||
<revision>3.9</revision>
|
||||
</Version>
|
||||
</release>
|
||||
<release>
|
||||
<Version>
|
||||
<name>Apache POI 3.8</name>
|
||||
<created>2012-03-26</created>
|
||||
<revision>3.8</revision>
|
||||
</Version>
|
||||
</release>
|
||||
<release>
|
||||
<Version>
|
||||
<name>Apache POI 3.7</name>
|
||||
<created>2010-10-29</created>
|
||||
<revision>3.7</revision>
|
||||
</Version>
|
||||
</release>
|
||||
<release>
|
||||
<Version>
|
||||
<name>Apache POI 3.6</name>
|
||||
<created>2009-12-14</created>
|
||||
<revision>3.6</revision>
|
||||
</Version>
|
||||
</release>
|
||||
<release>
|
||||
<Version>
|
||||
<name>Apache POI 3.5</name>
|
||||
<created>2009-09-28</created>
|
||||
<revision>3.5</revision>
|
||||
</Version>
|
||||
</release>
|
||||
<release>
|
||||
<Version>
|
||||
<name>Apache POI 3.2</name>
|
||||
<created>2008-10-19</created>
|
||||
<revision>3.2</revision>
|
||||
</Version>
|
||||
</release>
|
||||
<repository>
|
||||
<SVNRepository>
|
||||
<location rdf:resource="https://svn.apache.org/repos/asf/poi/"/>
|
||||
<browse rdf:resource="https://svn.apache.org/viewvc/poi/"/>
|
||||
</SVNRepository>
|
||||
</repository>
|
||||
<maintainer>
|
||||
<foaf:Person>
|
||||
<foaf:name>POI Committers</foaf:name>
|
||||
<foaf:mbox rdf:resource="mailto:dev@poi.apache.org"/>
|
||||
</foaf:Person>
|
||||
</maintainer>
|
||||
</Project>
|
||||
</rdf:RDF>
|
||||
75
log4j/file-leak-detector.exclude
Normal file
75
log4j/file-leak-detector.exclude
Normal file
@ -0,0 +1,75 @@
|
||||
# JaCoCo Agent
|
||||
sun.instrument.InstrumentationImpl.loadClassAndStartAgent
|
||||
org.jacoco.agent.rt.internal_14f7ee5.output.FileOutput.openFile
|
||||
|
||||
# Ant Junit
|
||||
org.apache.tools.ant.taskdefs.optional.junit.XMLJUnitResultFormatter.getDocumentBuilder
|
||||
|
||||
# JVM
|
||||
sun.security.jca.ProviderConfig.doLoadProvider
|
||||
java.util.ResourceBundle.getBundle
|
||||
|
||||
# Codepage support loads classes
|
||||
java.nio.charset.Charset.lookupViaProviders
|
||||
|
||||
# Ant
|
||||
org.apache.tools.ant.Main.getAntVersion
|
||||
org.apache.tools.ant.taskdefs.Antlib.createAntlib
|
||||
|
||||
# XML Parser
|
||||
com.sun.org.apache.xerces.internal.utils.SecuritySupport.getResourceBundle
|
||||
com.sun.org.apache.xml.internal.serializer.OutputPropertiesFactory.loadPropertiesFile
|
||||
javax.xml.parsers.FactoryFinder.findJarServiceProvider
|
||||
javax.xml.stream.FactoryFinder.findJarServiceProvider
|
||||
|
||||
# XMLBeans
|
||||
org.apache.xmlbeans.impl.regex.RegexParser.setLocale
|
||||
org.apache.xmlbeans.impl.schema.SchemaTypeSystemImpl$XsbReader.getLoaderStream
|
||||
com.sun.xml.internal.bind.v2.runtime.property.ArrayElementNodeProperty.<init>
|
||||
com.sun.xml.internal.bind.v2.runtime.property.AttributeProperty.<init>
|
||||
com.sun.xml.internal.bind.v2.runtime.property.SingleElementNodeProperty.<init>
|
||||
com.sun.xml.bind.v2.runtime.reflect.opt.AccessorInjector.tailor
|
||||
|
||||
# JCA
|
||||
sun.security.jca.ProviderConfig.getProvider
|
||||
javax.crypto.JceSecurity.setupJurisdictionPolicies
|
||||
javax.crypto.Cipher.getMaxAllowedKeyLength
|
||||
|
||||
# IntelliJ
|
||||
com.intellij.junit4.JUnit4TestRunnerUtil.<clinit>
|
||||
com.intellij.rt.coverage.instrumentation.AbstractIntellijClassfileTransformer.getOrLoadClassReader
|
||||
|
||||
# OpenJPA/Derby (regression testing)
|
||||
org.apache.derby.impl.services.stream.SingleStream.PBmakeFileHPW
|
||||
org.apache.derby.impl.io.DirFile.getExclusiveFileLock
|
||||
org.apache.derby.impl.store.raw.data.RAFContainer.run
|
||||
org.apache.derby.impl.store.raw.log.LogToFile.run
|
||||
org.apache.derby.client.net.OpenSocketAction.run
|
||||
org.apache.openjpa.enhance.InstrumentationFactory.loadVMClass
|
||||
org.apache.openjpa.enhance.PCEnhancer.<init>
|
||||
org.apache.openjpa.lib.util.J2DoPrivHelper$7.run
|
||||
serp.bytecode.BCClass.read
|
||||
serp.util.Strings.toClass
|
||||
|
||||
# Java
|
||||
sun.util.resources.LocaleData.getBundle
|
||||
sun.util.LocaleServiceProviderPool.<init>
|
||||
sun.util.calendar.LocalGregorianCalendar.getLocalGregorianCalendar
|
||||
sun.net.www.protocol.jar.JarURLConnection.getInputStream
|
||||
sun.text.normalizer.ICUData.getStream
|
||||
sun.font.T2KFontScaler.initNativeScaler
|
||||
sun.font.SunFontManager.loadFonts
|
||||
sun.font.FontManagerFactory.getInstance
|
||||
sun.font.TrueTypeFont.open
|
||||
sun.reflect.misc.MethodUtil.<clinit>
|
||||
java.util.logging.Logger.findSystemResourceBundle
|
||||
java.text.BreakIterator.getBundle
|
||||
sun.java2d.SunGraphicsEnvironment.<init>
|
||||
org.kohsuke.file_leak_detector.AgentMain.runHttpServer
|
||||
org.apache.log4j.FileAppender.setFile
|
||||
sun.launcher.LauncherHelper.validateMainClass
|
||||
sun.util.locale.provider.RuleBasedBreakIterator$1.run
|
||||
java.util.ServiceLoader$LazyIterator.hasNextService
|
||||
|
||||
# other third party libs
|
||||
net.bytebuddy.dynamic.ClassFileLocator$ForClassLoader.locate
|
||||
BIN
log4j/gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
BIN
log4j/gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
Binary file not shown.
5
log4j/gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
5
log4j/gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
185
log4j/gradlew
vendored
Executable file
185
log4j/gradlew
vendored
Executable file
@ -0,0 +1,185 @@
|
||||
#!/usr/bin/env sh
|
||||
|
||||
#
|
||||
# Copyright 2015 the original author or authors.
|
||||
#
|
||||
# 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
|
||||
#
|
||||
# https://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.
|
||||
#
|
||||
|
||||
##############################################################################
|
||||
##
|
||||
## Gradle start up script for UN*X
|
||||
##
|
||||
##############################################################################
|
||||
|
||||
# Attempt to set APP_HOME
|
||||
# Resolve links: $0 may be a link
|
||||
PRG="$0"
|
||||
# Need this for relative symlinks.
|
||||
while [ -h "$PRG" ] ; do
|
||||
ls=`ls -ld "$PRG"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
PRG="$link"
|
||||
else
|
||||
PRG=`dirname "$PRG"`"/$link"
|
||||
fi
|
||||
done
|
||||
SAVED="`pwd`"
|
||||
cd "`dirname \"$PRG\"`/" >/dev/null
|
||||
APP_HOME="`pwd -P`"
|
||||
cd "$SAVED" >/dev/null
|
||||
|
||||
APP_NAME="Gradle"
|
||||
APP_BASE_NAME=`basename "$0"`
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD="maximum"
|
||||
|
||||
warn () {
|
||||
echo "$*"
|
||||
}
|
||||
|
||||
die () {
|
||||
echo
|
||||
echo "$*"
|
||||
echo
|
||||
exit 1
|
||||
}
|
||||
|
||||
# OS specific support (must be 'true' or 'false').
|
||||
cygwin=false
|
||||
msys=false
|
||||
darwin=false
|
||||
nonstop=false
|
||||
case "`uname`" in
|
||||
CYGWIN* )
|
||||
cygwin=true
|
||||
;;
|
||||
Darwin* )
|
||||
darwin=true
|
||||
;;
|
||||
MINGW* )
|
||||
msys=true
|
||||
;;
|
||||
NONSTOP* )
|
||||
nonstop=true
|
||||
;;
|
||||
esac
|
||||
|
||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||
|
||||
|
||||
# Determine the Java command to use to start the JVM.
|
||||
if [ -n "$JAVA_HOME" ] ; then
|
||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||
# IBM's JDK on AIX uses strange locations for the executables
|
||||
JAVACMD="$JAVA_HOME/jre/sh/java"
|
||||
else
|
||||
JAVACMD="$JAVA_HOME/bin/java"
|
||||
fi
|
||||
if [ ! -x "$JAVACMD" ] ; then
|
||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
else
|
||||
JAVACMD="java"
|
||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
|
||||
# Increase the maximum file descriptors if we can.
|
||||
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
|
||||
MAX_FD_LIMIT=`ulimit -H -n`
|
||||
if [ $? -eq 0 ] ; then
|
||||
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
|
||||
MAX_FD="$MAX_FD_LIMIT"
|
||||
fi
|
||||
ulimit -n $MAX_FD
|
||||
if [ $? -ne 0 ] ; then
|
||||
warn "Could not set maximum file descriptor limit: $MAX_FD"
|
||||
fi
|
||||
else
|
||||
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
|
||||
fi
|
||||
fi
|
||||
|
||||
# For Darwin, add options to specify how the application appears in the dock
|
||||
if $darwin; then
|
||||
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
||||
fi
|
||||
|
||||
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
|
||||
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
||||
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
||||
|
||||
JAVACMD=`cygpath --unix "$JAVACMD"`
|
||||
|
||||
# We build the pattern for arguments to be converted via cygpath
|
||||
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
|
||||
SEP=""
|
||||
for dir in $ROOTDIRSRAW ; do
|
||||
ROOTDIRS="$ROOTDIRS$SEP$dir"
|
||||
SEP="|"
|
||||
done
|
||||
OURCYGPATTERN="(^($ROOTDIRS))"
|
||||
# Add a user-defined pattern to the cygpath arguments
|
||||
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
|
||||
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
|
||||
fi
|
||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||
i=0
|
||||
for arg in "$@" ; do
|
||||
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
|
||||
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
|
||||
|
||||
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
|
||||
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
|
||||
else
|
||||
eval `echo args$i`="\"$arg\""
|
||||
fi
|
||||
i=`expr $i + 1`
|
||||
done
|
||||
case $i in
|
||||
0) set -- ;;
|
||||
1) set -- "$args0" ;;
|
||||
2) set -- "$args0" "$args1" ;;
|
||||
3) set -- "$args0" "$args1" "$args2" ;;
|
||||
4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
||||
5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
||||
6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
||||
7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
||||
8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
||||
9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
# Escape application args
|
||||
save () {
|
||||
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
|
||||
echo " "
|
||||
}
|
||||
APP_ARGS=`save "$@"`
|
||||
|
||||
# Collect all arguments for the java command, following the shell quoting and substitution rules
|
||||
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
|
||||
|
||||
exec "$JAVACMD" "$@"
|
||||
104
log4j/gradlew.bat
vendored
Normal file
104
log4j/gradlew.bat
vendored
Normal file
@ -0,0 +1,104 @@
|
||||
@rem
|
||||
@rem Copyright 2015 the original author or authors.
|
||||
@rem
|
||||
@rem Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@rem you may not use this file except in compliance with the License.
|
||||
@rem You may obtain a copy of the License at
|
||||
@rem
|
||||
@rem https://www.apache.org/licenses/LICENSE-2.0
|
||||
@rem
|
||||
@rem Unless required by applicable law or agreed to in writing, software
|
||||
@rem distributed under the License is distributed on an "AS IS" BASIS,
|
||||
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
@rem See the License for the specific language governing permissions and
|
||||
@rem limitations under the License.
|
||||
@rem
|
||||
|
||||
@if "%DEBUG%" == "" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@rem Gradle startup script for Windows
|
||||
@rem
|
||||
@rem ##########################################################################
|
||||
|
||||
@rem Set local scope for the variables with windows NT shell
|
||||
if "%OS%"=="Windows_NT" setlocal
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%" == "" set DIRNAME=.
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
|
||||
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
|
||||
|
||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
|
||||
|
||||
@rem Find java.exe
|
||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if "%ERRORLEVEL%" == "0" goto init
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:findJavaFromJavaHome
|
||||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto init
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:init
|
||||
@rem Get command-line arguments, handling Windows variants
|
||||
|
||||
if not "%OS%" == "Windows_NT" goto win9xME_args
|
||||
|
||||
:win9xME_args
|
||||
@rem Slurp the command line arguments.
|
||||
set CMD_LINE_ARGS=
|
||||
set _SKIP=2
|
||||
|
||||
:win9xME_args_slurp
|
||||
if "x%~1" == "x" goto execute
|
||||
|
||||
set CMD_LINE_ARGS=%*
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if "%ERRORLEVEL%"=="0" goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
||||
exit /b 1
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
||||
:omega
|
||||
752
log4j/jenkins/create_jobs.groovy
Normal file
752
log4j/jenkins/create_jobs.groovy
Normal file
@ -0,0 +1,752 @@
|
||||
// This script is used as input to the Jenkins Job DSL plugin to create all the build-jobs that
|
||||
// Apache POI uses on the public Jenkins instance at https://ci-builds.apache.org/job/POI/
|
||||
//
|
||||
// See https://github.com/jenkinsci/job-dsl-plugin/wiki for information about the DSL, you can
|
||||
// use https://job-dsl.herokuapp.com/ to validate the code before checkin
|
||||
//
|
||||
|
||||
def triggerSundays = '''
|
||||
# only run this once per week on Sundays
|
||||
H H * * 0
|
||||
'''
|
||||
|
||||
def xercesUrl = 'https://repo1.maven.org/maven2/xerces/xercesImpl/2.6.1/xercesImpl-2.6.1.jar'
|
||||
def xercesLib = './xercesImpl-2.6.1.jar'
|
||||
|
||||
def poijobs = [
|
||||
[ name: 'POI-DSL-1.8', trigger: 'H */12 * * *'
|
||||
],
|
||||
[ name: 'POI-DSL-OpenJDK', jdk: 'OpenJDK 1.8', trigger: 'H */12 * * *',
|
||||
// only a limited set of nodes still have OpenJDK 8 (on Ubuntu) installed
|
||||
slaves: 'ubuntu',
|
||||
skipcigame: true
|
||||
],
|
||||
[ name: 'POI-DSL-1.10', jdk: '1.10', trigger: triggerSundays, skipcigame: true,
|
||||
// let's save some CPU cycles here, 10 had EOL in September 2018
|
||||
disabled: true
|
||||
],
|
||||
[ name: 'POI-DSL-1.11', jdk: '1.11', trigger: triggerSundays, skipcigame: true
|
||||
],
|
||||
[ name: 'POI-DSL-1.12', jdk: '1.12', trigger: triggerSundays, skipcigame: true,
|
||||
// let's save some CPU cycles here, 12 is not a LTS and JDK 13 is GA as of 17 September 2019
|
||||
disabled: true
|
||||
],
|
||||
[ name: 'POI-DSL-1.13', jdk: '1.13', trigger: triggerSundays, skipcigame: true,
|
||||
// let's save some CPU cycles here, 13 is not a LTS and JDK 14 is GA as of 17 March 2020
|
||||
disabled: true
|
||||
],
|
||||
[ name: 'POI-DSL-1.14', jdk: '1.14', trigger: triggerSundays, skipcigame: true,
|
||||
// let's save some CPU cycles here, 14 is not a LTS and JDK 15 is GA as of 15 September 2020
|
||||
disabled: true
|
||||
],
|
||||
[ name: 'POI-DSL-1.15', jdk: '1.15', trigger: triggerSundays, skipcigame: true
|
||||
],
|
||||
// building with JDK 16 fails currently because of findbugs/spotbugs
|
||||
// therefore we do not set a trigger for now and only run it manually
|
||||
[ name: 'POI-DSL-1.16', jdk: '1.16', trigger: '', skipcigame: true
|
||||
],
|
||||
[ name: 'POI-DSL-IBM-JDK', jdk: 'IBMJDK', trigger: triggerSundays, skipcigame: true
|
||||
],
|
||||
[ name: 'POI-DSL-old-Xerces', trigger: triggerSundays,
|
||||
shell: "test -s ${xercesLib} || wget -O ${xercesLib} ${xercesUrl}\n",
|
||||
// the property triggers using Xerces as XML Parser and previously showed some exception that can occur
|
||||
properties: ["-Dadditionaljar=${xercesLib}"]
|
||||
],
|
||||
[ name: 'POI-DSL-Maven', trigger: 'H */4 * * *', maven: true
|
||||
],
|
||||
[ name: 'POI-DSL-regenerate-javadoc', trigger: triggerSundays, javadoc: true
|
||||
],
|
||||
[ name: 'POI-DSL-API-Check', trigger: '@daily', apicheck: true
|
||||
],
|
||||
[ name: 'POI-DSL-Gradle', trigger: triggerSundays, email: 'centic@apache.org', gradle: true,
|
||||
// Gradle will not run any tests if the code is up-to-date, therefore manually mark the files as updated
|
||||
addShell: 'touch --no-create build/*/build/test-results/TEST-*.xml build/*/build/test-results/test/TEST-*.xml'
|
||||
],
|
||||
[ name: 'POI-DSL-no-scratchpad', trigger: triggerSundays, noScratchpad: true
|
||||
],
|
||||
[ name: 'POI-DSL-SonarQube', jdk: '1.11', trigger: 'H 7 * * *', maven: true, sonar: true, skipcigame: true,
|
||||
email: 'kiwiwings@apache.org'
|
||||
],
|
||||
// set trigger empty as it is not stable yet, we can remove the Sonar Maven run when this is fully working
|
||||
[ name: 'POI-DSL-SonarQube-Gradle', jdk: '1.11', trigger: '', gradle: true, sonar: true, skipcigame: true
|
||||
],
|
||||
[ name: 'POI-DSL-Windows-1.8', trigger: 'H */12 * * *', windows: true, slaves: 'Windows'
|
||||
],
|
||||
[ name: 'POI-DSL-Windows-1.12', jdk: '1.12', trigger: triggerSundays, windows: true, slaves: 'Windows', skipcigame: true,
|
||||
// let's save some CPU cycles here, 12 is not a LTS and JDK 13 is GA now
|
||||
disabled: true
|
||||
],
|
||||
[ name: 'POI-DSL-Windows-1.14', jdk: '1.14', trigger: triggerSundays, windows: true, slaves: 'Windows', skipcigame: true
|
||||
],
|
||||
[ name: 'POI-DSL-Github-PullRequests', trigger: '', githubpr: true, skipcigame: true,
|
||||
// ensure the file which is needed from the separate documentation module does exist
|
||||
// as we are checking out from git, we do not have the reference checked out here
|
||||
addShell: 'mkdir -p src/documentation\ntouch src/documentation/RELEASE-NOTES.txt'
|
||||
],
|
||||
]
|
||||
|
||||
def xmlbeansjobs = [
|
||||
[ name: 'POI-XMLBeans-DSL-1.8', jdk: '1.8', trigger: 'H */12 * * *', skipcigame: true,
|
||||
],
|
||||
[ name: 'POI-XMLBeans-DSL-1.11', jdk: '1.11', trigger: triggerSundays, skipcigame: true,
|
||||
],
|
||||
[ name: 'POI-XMLBeans-DSL-1.12', jdk: '1.12', trigger: triggerSundays, skipcigame: true,
|
||||
// let's save some CPU cycles here, 12 is not a LTS and JDK 13 is GA now
|
||||
disabled: true
|
||||
],
|
||||
[ name: 'POI-XMLBeans-DSL-1.14', jdk: '1.14', trigger: triggerSundays, skipcigame: true,
|
||||
// let's save some CPU cycles here, 14 is not a LTS and JDK 15 is GA now
|
||||
disabled: true
|
||||
],
|
||||
[ name: 'POI-XMLBeans-DSL-1.15', jdk: '1.15', trigger: triggerSundays, skipcigame: true,
|
||||
]
|
||||
]
|
||||
|
||||
def svnBase = 'https://svn.apache.org/repos/asf/poi/trunk'
|
||||
def xmlbeansSvnBase = 'https://svn.apache.org/repos/asf/xmlbeans/trunk'
|
||||
|
||||
def defaultJdk = '1.8'
|
||||
def defaultTrigger = 'H/15 * * * *' // check SCM every 60/15 = 4 minutes
|
||||
def defaultEmail = 'dev@poi.apache.org'
|
||||
def defaultAnt = 'ant_1.10_latest'
|
||||
def defaultAntWindows = 'ant_1.10_latest_windows'
|
||||
def defaultMaven = 'maven_3_latest'
|
||||
// H29 seems to have very little memory
|
||||
def defaultSlaves = '(ubuntu)&&!beam&&!cloud-slave&&!H29'
|
||||
|
||||
def jdkMapping = [
|
||||
'1.8': 'jdk_1.8_latest',
|
||||
'1.10': 'jdk_10_latest',
|
||||
'1.11': 'jdk_11_latest',
|
||||
'1.12': 'jdk_12_latest',
|
||||
'1.13': 'jdk_13_latest',
|
||||
'1.14': 'jdk_14_latest',
|
||||
'1.15': 'jdk_15_latest',
|
||||
'1.16': 'jdk_16_latest',
|
||||
'OpenJDK 1.8': 'openjdk_1.8.0_252',
|
||||
'IBMJDK': 'ibmjdk_1.8.0_261',
|
||||
]
|
||||
|
||||
static def shellEx(def context, String cmd, def poijob) {
|
||||
if (poijob.windows) {
|
||||
context.batchFile(cmd)
|
||||
} else {
|
||||
context.shell(cmd)
|
||||
}
|
||||
}
|
||||
|
||||
def defaultDesc = '''
|
||||
<img src="https://poi.apache.org/images/project-header.png" />
|
||||
<p>
|
||||
Apache POI - the Java API for Microsoft Documents
|
||||
</p>
|
||||
<p>
|
||||
<b>This is an automatically generated Job Config, do not edit it here!
|
||||
Instead change the Jenkins Job DSL at <a href="https://svn.apache.org/repos/asf/poi/trunk/jenkins">https://svn.apache.org/repos/asf/poi/trunk/jenkins</a>,
|
||||
see <a href="https://github.com/jenkinsci/job-dsl-plugin/wiki">https://github.com/jenkinsci/job-dsl-plugin/wiki</a>
|
||||
for more details about the DSL.</b>
|
||||
</p>'''
|
||||
|
||||
def apicheckDesc = '''
|
||||
<p>
|
||||
<b><a href="https://sonarcloud.io/dashboard?id=poi-parent" target="_blank">Sonar reports</a></b> -
|
||||
<p>
|
||||
<b><a href="lastSuccessfulBuild/artifact/build/main/build/reports/japi.html">API Check POI</a></b>
|
||||
<b><a href="lastSuccessfulBuild/artifact/build/ooxml/build/reports/japi.html">API Check POI-OOXML</a></b>
|
||||
<b><a href="lastSuccessfulBuild/artifact/build/excelant/build/reports/japi.html">API Check POI-Excelant</a></b>
|
||||
<b><a href="lastSuccessfulBuild/artifact/build/scratchpad/build/reports/japi.html">API Check POI-Scratchpad</a></b>
|
||||
|
||||
</p>
|
||||
'''
|
||||
|
||||
def sonarDesc = '''
|
||||
<p>
|
||||
<b><a href="lastSuccessfulBuild/findbugsResult/" target="_blank">Findbugs report of latest build</a></b> -
|
||||
<b><a href="https://sonarcloud.io/dashboard?id=poi-parent" target="_blank">Sonar reports</a></b> -
|
||||
<b><a href="lastSuccessfulBuild/artifact/build/coverage/index.html" target="_blank">Coverage of latest build</a></b>
|
||||
</p>
|
||||
'''
|
||||
|
||||
def shellCmdsUnix =
|
||||
'''# show which files are currently modified in the working copy
|
||||
svn status || true
|
||||
|
||||
# print out information about which exact version of java we are using
|
||||
echo Java-Home: $JAVA_HOME
|
||||
ls -al $JAVA_HOME/
|
||||
ls -al $JAVA_HOME/bin
|
||||
$JAVA_HOME/bin/java -version
|
||||
|
||||
echo which java
|
||||
which java
|
||||
java -version
|
||||
|
||||
echo which javac
|
||||
which javac
|
||||
javac -version
|
||||
|
||||
echo Ant-Home: $ANT_HOME
|
||||
ls -al $ANT_HOME
|
||||
echo which ant
|
||||
which ant || true
|
||||
ant -version
|
||||
|
||||
echo '<project default="test"><target name="test"><echo>Java ${ant.java.version}/${java.version}</echo><exec executable="javac"><arg value="-version"/></exec></target></project>' > build.javacheck.xml
|
||||
ant -f build.javacheck.xml -v
|
||||
|
||||
POIJOBSHELL
|
||||
|
||||
# ignore any error message
|
||||
exit 0'''
|
||||
|
||||
def shellCmdsWin =
|
||||
'''@echo off
|
||||
:: show which files are currently modified in the working copy
|
||||
svn status
|
||||
|
||||
:: print out information about which exact version of java we are using
|
||||
echo Java-Home: %JAVA_HOME%
|
||||
dir "%JAVA_HOME:\\\\=\\%"
|
||||
"%JAVA_HOME%/bin/java" -version
|
||||
|
||||
POIJOBSHELL
|
||||
|
||||
:: ignore any error message
|
||||
exit /b 0'''
|
||||
|
||||
poijobs.each { poijob ->
|
||||
def jdkKey = poijob.jdk ?: defaultJdk
|
||||
def trigger = poijob.trigger ?: defaultTrigger
|
||||
def email = poijob.email ?: defaultEmail
|
||||
def slaves = poijob.slaves ?: defaultSlaves + (poijob.slaveAdd ?: '')
|
||||
def antRT = poijob.windows ? defaultAntWindows : defaultAnt
|
||||
|
||||
job('POI/' + poijob.name) {
|
||||
if (poijob.disabled) {
|
||||
disabled()
|
||||
}
|
||||
|
||||
description( defaultDesc + (poijob.apicheck ? apicheckDesc : sonarDesc) )
|
||||
logRotator {
|
||||
numToKeep(5)
|
||||
artifactNumToKeep(1)
|
||||
}
|
||||
label(slaves)
|
||||
environmentVariables {
|
||||
env('LANG', 'en_US.UTF-8')
|
||||
if(jdkKey == '1.10') {
|
||||
// when using JDK 9/10 for running Ant, we need to provide more modules for the forbidden-api-checks task
|
||||
// on JDK 11 and newer there is no such module any more, so do not add it here
|
||||
env('ANT_OPTS', '--add-modules=java.xml.bind --add-opens=java.xml/com.sun.org.apache.xerces.internal.util=ALL-UNNAMED --add-opens=java.base/java.lang=ALL-UNNAMED')
|
||||
}
|
||||
env('FORREST_HOME', poijob.windows ? 'f:\\jenkins\\tools\\forrest\\latest' : '/home/jenkins/tools/forrest/latest')
|
||||
}
|
||||
|
||||
wrappers {
|
||||
timeout {
|
||||
absolute(180)
|
||||
abortBuild()
|
||||
writeDescription('Build was aborted due to timeout')
|
||||
}
|
||||
preBuildCleanup {
|
||||
/* remove xmlbeans while 4.0 is not stable */
|
||||
includePattern('**/lib/ooxml/xmlbeans*.jar')
|
||||
includePattern('**/lib/ooxml/ooxml*.jar')
|
||||
includePattern('sonar/*/target/**')
|
||||
/* remove ooxml-schemas while the builds migrate to 5th edition */
|
||||
includePattern('build/xmlbean-*/**')
|
||||
}
|
||||
if(poijob.sonar) {
|
||||
credentialsBinding {
|
||||
string('POI_SONAR_TOKEN', 'sonarcloud-poi')
|
||||
}
|
||||
configure { project ->
|
||||
project / buildWrappers << 'hudson.plugins.sonar.SonarBuildWrapper' {}
|
||||
}
|
||||
}
|
||||
}
|
||||
jdk(jdkMapping.get(jdkKey))
|
||||
scm {
|
||||
if (poijob.githubpr) {
|
||||
git {
|
||||
remote {
|
||||
github('apache/poi')
|
||||
refspec('+refs/pull/*:refs/remotes/origin/pr/*')
|
||||
}
|
||||
branch('${sha1}')
|
||||
}
|
||||
} else {
|
||||
svn(svnBase) { svnNode ->
|
||||
svnNode / browser(class: 'hudson.scm.browsers.ViewSVN') /
|
||||
url << 'https://svn.apache.org/viewcvs.cgi/?root=Apache-SVN'
|
||||
}
|
||||
}
|
||||
}
|
||||
checkoutRetryCount(3)
|
||||
|
||||
if (poijob.githubpr) {
|
||||
throttleConcurrentBuilds {
|
||||
maxPerNode(1)
|
||||
maxTotal(1)
|
||||
}
|
||||
parameters {
|
||||
/* plugin not available:
|
||||
gitParam('sha1') {
|
||||
description('Pull request')
|
||||
type('BRANCH')
|
||||
}*/
|
||||
stringParam('sha1', 'origin/pr/9/head', 'Provide a branch-spec, e.g. origin/pr/9/head')
|
||||
}
|
||||
triggers {
|
||||
pullRequestBuildTrigger()
|
||||
/*githubPullRequest {
|
||||
admins(['centic9', 'poi-benchmark', 'tballison', 'gagravarr', 'onealj', 'pjfanning', 'Alain-Bearez'])
|
||||
userWhitelist(['centic9', 'poi-benchmark', 'tballison', 'gagravarr', 'onealj', 'pjfanning', 'Alain-Bearez'])
|
||||
orgWhitelist(['apache'])
|
||||
cron('H/5 * * * *')
|
||||
triggerPhrase('OK to test')
|
||||
}*/
|
||||
}
|
||||
} else {
|
||||
triggers {
|
||||
scm(trigger)
|
||||
}
|
||||
}
|
||||
|
||||
def shellcmds = (poijob.windows ? shellCmdsWin : shellCmdsUnix).replace('POIJOBSHELL', poijob.shell ?: '')
|
||||
|
||||
// Create steps and publishers depending on the type of Job that is selected
|
||||
if(poijob.maven) {
|
||||
steps {
|
||||
shellEx(delegate, shellcmds, poijob)
|
||||
maven {
|
||||
goals('clean')
|
||||
rootPOM('sonar/pom.xml')
|
||||
localRepository(LocalRepositoryLocation.LOCAL_TO_WORKSPACE)
|
||||
mavenInstallation(defaultMaven)
|
||||
}
|
||||
maven {
|
||||
if (poijob.sonar) {
|
||||
goals('clean package sonar:sonar')
|
||||
property('sonar.login', '${POI_SONAR_TOKEN}')
|
||||
} else {
|
||||
goals('package')
|
||||
}
|
||||
rootPOM('sonar/pom.xml')
|
||||
mavenOpts('-Xmx2g')
|
||||
mavenOpts('-Xms256m')
|
||||
mavenOpts('-XX:-OmitStackTraceInFastThrow')
|
||||
localRepository(LocalRepositoryLocation.LOCAL_TO_WORKSPACE)
|
||||
mavenInstallation(defaultMaven)
|
||||
}
|
||||
}
|
||||
publishers {
|
||||
if (!poijob.skipcigame) {
|
||||
configure { project ->
|
||||
project / publishers << 'hudson.plugins.cigame.GamePublisher' {}
|
||||
}
|
||||
}
|
||||
if (!poijob.sonar) {
|
||||
archiveJunit('sonar/*/target/surefire-reports/TEST-*.xml') {
|
||||
testDataPublishers {
|
||||
publishTestStabilityData()
|
||||
}
|
||||
}
|
||||
}
|
||||
mailer(email, false, false)
|
||||
}
|
||||
} else if (poijob.javadoc) {
|
||||
steps {
|
||||
shellEx(delegate, shellcmds, poijob)
|
||||
ant {
|
||||
targets(['clean', 'javadocs'] + (poijob.properties ?: []))
|
||||
prop('coverage.enabled', true)
|
||||
// Properties did not work, so I had to use targets instead
|
||||
//properties(poijob.properties ?: '')
|
||||
antInstallation(antRT)
|
||||
}
|
||||
shellEx(delegate, 'zip -r build/javadocs.zip build/site/apidocs', poijob)
|
||||
}
|
||||
publishers {
|
||||
if (!poijob.skipcigame) {
|
||||
configure { project ->
|
||||
project / publishers << 'hudson.plugins.cigame.GamePublisher' {}
|
||||
}
|
||||
}
|
||||
mailer(email, false, false)
|
||||
}
|
||||
} else if (poijob.apicheck) {
|
||||
steps {
|
||||
shellEx(delegate, shellcmds, poijob)
|
||||
gradle {
|
||||
tasks('japicmp')
|
||||
useWrapper(true)
|
||||
}
|
||||
}
|
||||
publishers {
|
||||
archiveArtifacts('build/*/build/reports/japi.html')
|
||||
if (!poijob.skipcigame) {
|
||||
configure { project ->
|
||||
project / publishers << 'hudson.plugins.cigame.GamePublisher' {}
|
||||
}
|
||||
}
|
||||
mailer(email, false, false)
|
||||
}
|
||||
} else if(poijob.sonar) {
|
||||
steps {
|
||||
shellEx(delegate, shellcmds, poijob)
|
||||
|
||||
gradle {
|
||||
switches('-PenableSonar')
|
||||
switches('-Dsonar.login=${POI_SONAR_TOKEN}')
|
||||
switches('-Dsonar.organization=apache')
|
||||
switches('-Dsonar.projectKey=poi-parent')
|
||||
switches('-Dsonar.host.url=https://sonarcloud.io')
|
||||
tasks('check')
|
||||
tasks('jacocoTestReport')
|
||||
tasks('sonarqube')
|
||||
useWrapper(false)
|
||||
}
|
||||
}
|
||||
publishers {
|
||||
if (!poijob.skipcigame) {
|
||||
configure { project ->
|
||||
project / publishers << 'hudson.plugins.cigame.GamePublisher' {}
|
||||
}
|
||||
}
|
||||
mailer(email, false, false)
|
||||
}
|
||||
} else {
|
||||
steps {
|
||||
shellEx(delegate, shellcmds, poijob)
|
||||
if(poijob.addShell) {
|
||||
shellEx(delegate, poijob.addShell, poijob)
|
||||
}
|
||||
// For Jobs that should still have the default set of publishers we can configure different steps here
|
||||
if(poijob.gradle) {
|
||||
gradle {
|
||||
tasks('check')
|
||||
useWrapper(false)
|
||||
}
|
||||
} else if (poijob.noScratchpad) {
|
||||
ant {
|
||||
targets(['clean', 'compile'] + (poijob.properties ?: []))
|
||||
prop('coverage.enabled', true)
|
||||
antInstallation(antRT)
|
||||
}
|
||||
ant {
|
||||
targets(['-Dscratchpad.ignore=true', 'jacocotask', 'test-all', 'testcoveragereport'] + (poijob.properties ?: []))
|
||||
prop('coverage.enabled', true)
|
||||
antInstallation(antRT)
|
||||
}
|
||||
} else {
|
||||
ant {
|
||||
targets(['clean', 'jenkins'] + (poijob.properties ?: []))
|
||||
prop('coverage.enabled', true)
|
||||
// Properties did not work, so I had to use targets instead
|
||||
//properties(poijob.properties ?: '')
|
||||
antInstallation(antRT)
|
||||
}
|
||||
ant {
|
||||
targets(['run'] + (poijob.properties ?: []))
|
||||
buildFile('src/integrationtest/build.xml')
|
||||
// Properties did not work, so I had to use targets instead
|
||||
//properties(poijob.properties ?: '')
|
||||
antInstallation(antRT)
|
||||
}
|
||||
}
|
||||
}
|
||||
publishers {
|
||||
recordIssues {
|
||||
tools {
|
||||
spotBugs {
|
||||
pattern('build/findbugs.xml')
|
||||
reportEncoding('UTF-8')
|
||||
}
|
||||
}
|
||||
}
|
||||
// in archive, junit and jacoco publishers, matches beneath build/*/build/... are for Gradle-build results
|
||||
archiveArtifacts('build/dist/*.tar.gz,build/findbugs.html,build/coverage/**,build/integration-test-results/**,lib/ooxml/**,build/*/build/libs/*.jar')
|
||||
warnings(['Java Compiler (javac)', 'JavaDoc Tool'], null) {
|
||||
resolveRelativePaths()
|
||||
}
|
||||
archiveJunit('build/ooxml-test-results/*.xml,build/scratchpad-test-results/*.xml,build/test-results/*.xml,build/excelant-test-results/*.xml,build/integration-test-results/*.xml,build/*/build/test-results/test/TEST-*.xml,build/*/build/test-results/TEST-*.xml') {
|
||||
testDataPublishers {
|
||||
publishTestStabilityData()
|
||||
}
|
||||
}
|
||||
jacocoCodeCoverage {
|
||||
classPattern('build/classes,build/excelant-classes,build/ooxml-classes,build/scratchpad-classes,build/*/build/classes')
|
||||
execPattern('build/*.exec,build/*/build/jacoco/*.exec')
|
||||
sourcePattern('src/java,src/excelant/java,src/ooxml/java,src/scratchpad/src')
|
||||
exclusionPattern('com/microsoft/**,org/openxmlformats/**,org/etsi/**,org/w3/**,schemaorg*/**,schemasMicrosoft*/**,org/apache/poi/hdf/model/hdftypes/definitions/*.class,org/apache/poi/hwpf/model/types/*.class,org/apache/poi/hssf/usermodel/DummyGraphics2d.class,org/apache/poi/sl/draw/binding/*.class')
|
||||
}
|
||||
|
||||
if (!poijob.skipcigame) {
|
||||
configure { project ->
|
||||
project / publishers << 'hudson.plugins.cigame.GamePublisher' {}
|
||||
}
|
||||
}
|
||||
mailer(email, false, false)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (poijob.githubpr) {
|
||||
configure {
|
||||
it / 'properties' << 'com.cloudbees.jenkins.plugins.git.vmerge.JobPropertyImpl'(plugin: 'git-validated-merge') {
|
||||
credentialsId('ASF_Cloudbees_Jenkins_ci-builds')
|
||||
postBuildPushFailureHandler(class: 'com.cloudbees.jenkins.plugins.git.vmerge.pbph.PushFailureIsFailure')
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
xmlbeansjobs.each { xjob ->
|
||||
def jdkKey = xjob.jdk ?: defaultJdk
|
||||
def trigger = xjob.trigger ?: defaultTrigger
|
||||
def email = xjob.email ?: defaultEmail
|
||||
def slaves = xjob.slaves ?: defaultSlaves + (xjob.slaveAdd ?: '')
|
||||
def antRT = xjob.windows ? defaultAntWindows : defaultAnt
|
||||
|
||||
job('POI/' + xjob.name) {
|
||||
if (xjob.disabled) {
|
||||
disabled()
|
||||
}
|
||||
|
||||
description( defaultDesc + (xjob.apicheck ? apicheckDesc : sonarDesc) )
|
||||
logRotator {
|
||||
numToKeep(5)
|
||||
artifactNumToKeep(1)
|
||||
}
|
||||
label(slaves)
|
||||
environmentVariables {
|
||||
env('LANG', 'en_US.UTF-8')
|
||||
if(jdkKey == '1.10') {
|
||||
// when using JDK 9/10 for running Ant, we need to provide more modules for the forbidden-api-checks task
|
||||
// on JDK 11 and newer there is no such module any more, so do not add it here
|
||||
env('ANT_OPTS', '--add-modules=java.xml.bind --add-opens=java.xml/com.sun.org.apache.xerces.internal.util=ALL-UNNAMED --add-opens=java.base/java.lang=ALL-UNNAMED')
|
||||
} else if (jdkKey == '1.11' || jdkKey == '1.12' || jdkKey == '1.13' || jdkKey == '1.14' || jdkKey == '1.15' || jdkKey == '1.16') {
|
||||
env('ANT_OPTS', '--add-opens=java.xml/com.sun.org.apache.xerces.internal.util=ALL-UNNAMED --add-opens=java.base/java.lang=ALL-UNNAMED')
|
||||
}
|
||||
// will be needed for forbidden-apis-check: env('ANT_HOME', xjob.windows ? 'f:\\jenkins\\tools\\ant\\latest' : '/usr/share/ant')
|
||||
env('FORREST_HOME', xjob.windows ? 'f:\\jenkins\\tools\\forrest\\latest' : '/home/jenkins/tools/forrest/latest')
|
||||
}
|
||||
wrappers {
|
||||
timeout {
|
||||
absolute(180)
|
||||
abortBuild()
|
||||
writeDescription('Build was aborted due to timeout')
|
||||
}
|
||||
}
|
||||
jdk(jdkMapping.get(jdkKey))
|
||||
scm {
|
||||
svn(xmlbeansSvnBase) { svnNode ->
|
||||
svnNode / browser(class: 'hudson.scm.browsers.ViewSVN') /
|
||||
url << 'https://svn.apache.org/viewcvs.cgi/?root=Apache-SVN'
|
||||
}
|
||||
}
|
||||
checkoutRetryCount(3)
|
||||
|
||||
triggers {
|
||||
scm(trigger)
|
||||
}
|
||||
|
||||
def shellcmds = (xjob.windows ? shellCmdsWin : shellCmdsUnix).replace('POIJOBSHELL', xjob.shell ?: '')
|
||||
|
||||
// Create steps and publishers depending on the type of Job that is selected
|
||||
steps {
|
||||
shellEx(delegate, shellcmds, xjob)
|
||||
if(xjob.addShell) {
|
||||
shellEx(delegate, xjob.addShell, xjob)
|
||||
}
|
||||
ant {
|
||||
targets(['clean'])
|
||||
antInstallation(antRT)
|
||||
}
|
||||
ant {
|
||||
targets(['jenkins'])
|
||||
antInstallation(antRT)
|
||||
}
|
||||
}
|
||||
publishers {
|
||||
archiveArtifacts('build/*.jar,build/*.zip')
|
||||
|
||||
warnings(['Java Compiler (javac)', 'JavaDoc Tool'], null) {
|
||||
resolveRelativePaths()
|
||||
}
|
||||
archiveJunit('build/test-results/TEST-*.xml') {
|
||||
testDataPublishers {
|
||||
publishTestStabilityData()
|
||||
}
|
||||
}
|
||||
recordIssues {
|
||||
tools {
|
||||
spotBugs {
|
||||
pattern('build/findbugs.xml')
|
||||
reportEncoding('UTF-8')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!xjob.skipcigame) {
|
||||
configure { project ->
|
||||
project / publishers << 'hudson.plugins.cigame.GamePublisher' {}
|
||||
}
|
||||
}
|
||||
mailer(email, false, false)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Add a special job which spans a two-dimensional matrix of all JDKs that we want to use and
|
||||
all worker nodes that we would like to use and test if the java and ant binaries are available
|
||||
on that machine correctly.
|
||||
*/
|
||||
matrixJob('POI/POI-DSL-Test-Environment') {
|
||||
description(
|
||||
'''Check installed version of Java/Ant on all build-nodes
|
||||
|
||||
This job is used to verify which machines actually have the required programs installed.
|
||||
|
||||
Unfortunately we often see builds break because of changes/new machines...''')
|
||||
|
||||
/*throttleConcurrentBuilds {
|
||||
maxPerNode(1)
|
||||
maxTotal(1)
|
||||
}*/
|
||||
logRotator {
|
||||
numToKeep(1)
|
||||
artifactNumToKeep(1)
|
||||
}
|
||||
axes {
|
||||
jdk(
|
||||
'jdk_1.8_latest',
|
||||
'jdk_10_latest',
|
||||
'jdk_11_latest',
|
||||
'jdk_12_latest',
|
||||
'jdk_13_latest',
|
||||
'jdk_14_latest',
|
||||
'jdk_15_latest',
|
||||
'jdk_16_latest',
|
||||
'openjdk_1.8.0_252',
|
||||
'ibmjdk_1.8.0_261'
|
||||
)
|
||||
// Note H50 is reserved according to it's node-descripion
|
||||
label('Nodes','H22','H23','H24','H25','H26','H27','H28','H29','H30','H31','H32','H33','H34','H35','H36','H37','H38','H39','H40','H41','H42','H43','H44','H48','lucene1','lucene2','master')
|
||||
}
|
||||
steps {
|
||||
conditionalSteps {
|
||||
condition {
|
||||
fileExists('/usr', BaseDir.WORKSPACE)
|
||||
runner('DontRun')
|
||||
steps {
|
||||
shell(
|
||||
'''which svn || true
|
||||
which javac
|
||||
javac -version
|
||||
echo '<?xml version="1.0"?><project name="POI Build" default="test"><target name="test"><echo>Using Ant: ${ant.version} from ${ant.home}</echo></target></project>' > build.xml
|
||||
''')
|
||||
ant {
|
||||
antInstallation(defaultAnt)
|
||||
}
|
||||
|
||||
shell(
|
||||
'''which mvn || true
|
||||
mvn -version || true
|
||||
echo '<project><modelVersion>4.0.0</modelVersion><groupId>org.apache.poi</groupId><artifactId>build-tst</artifactId><version>1.0.0</version></project>' > pom.xml
|
||||
''')
|
||||
maven {
|
||||
goals('package')
|
||||
mavenInstallation(defaultMaven)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
conditionalSteps {
|
||||
condition {
|
||||
fileExists('c:\\windows', BaseDir.WORKSPACE)
|
||||
runner('DontRun')
|
||||
steps {
|
||||
batchFile {
|
||||
command(
|
||||
'''@echo off
|
||||
echo .
|
||||
where javac.exe
|
||||
echo .
|
||||
javac -version
|
||||
echo .
|
||||
echo ^<?xml version=^"1.0^"?^>^<project name=^"POI Build^" default=^"test^"^>^<target name=^"test^"^>^<echo^>Using Ant: ${ant.version} from ${ant.home}, ant detected Java ${ant.java.version} (may be different than actual Java sometimes...), using Java: ${java.version}/${java.runtime.version}/${java.vm.version}/${java.vm.name} from ${java.vm.vendor} on ${os.name}: ${os.version}^</echo^>^</target^>^</project^> > build.xml
|
||||
''')
|
||||
}
|
||||
ant {
|
||||
antInstallation(defaultAntWindows)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* I tried to put the view into a sub-folder/sub-view, but failed, there are multiple related
|
||||
plugins so this is all a bit confusing :(, see also https://issues.apache.org/jira/browse/INFRA-14002
|
||||
dashboardView("P/POI-new") {
|
||||
columns {
|
||||
status()
|
||||
weather()
|
||||
configureProject()
|
||||
buildButton()
|
||||
cronTrigger()
|
||||
lastBuildConsole()
|
||||
name()
|
||||
lastSuccess()
|
||||
lastFailure()
|
||||
lastDuration()
|
||||
//lastSuccessDescription()
|
||||
jacoco()
|
||||
}
|
||||
description("<table>\n" +
|
||||
" <tr>\n" +
|
||||
" <td><img src=\"https://poi.apache.org/images/project-header.png\" /></td>\n" +
|
||||
" <td> \n" +
|
||||
" <p>Apache POI - the Java API for Microsoft Documents</p>\n" +
|
||||
" <p><b>Most of the POI Jobs are automatically generated by Jenkins Job DSL\n" +
|
||||
" at <a href=\"https://svn.apache.org/repos/asf/poi/trunk/jenkins\">https://svn.apache.org/repos/asf/poi/trunk/jenkins</a>,<br/>\n" +
|
||||
" see <a href=\"https://github.com/jenkinsci/job-dsl-plugin/wiki\">https://github.com/jenkinsci/job-dsl-plugin/wiki</a>\n" +
|
||||
" for more details about the DSL.</b>\n" +
|
||||
" </p>\n" +
|
||||
" <p>\n" +
|
||||
" <b><a href=\"job/POI-DSL-1.8/lastSuccessfulBuild/findbugsResult/\" target=\"_blank\">Findbugs report of latest build</a></b> -\n" +
|
||||
" <b><a href=\"https://sonarcloud.io/dashboard?id=poi-parent\" target=\"_blank\">Sonar reports</a></b> -\n" +
|
||||
" <b><a href=\"job/POI-DSL-1.8/lastSuccessfulBuild/artifact/build/coverage/index.html\" target=\"_blank\">Coverage of latest build</a></b>\n" +
|
||||
" </p>\n" +
|
||||
" </td>\n" +
|
||||
" </tr>\n" +
|
||||
"</table>")
|
||||
filterBuildQueue(false)
|
||||
filterExecutors(false)
|
||||
|
||||
// Job selection
|
||||
jobs {*/
|
||||
//regex(/.*POI.*/)
|
||||
/*}
|
||||
|
||||
// Layout
|
||||
topPortlets {
|
||||
jenkinsJobsList {
|
||||
displayName('POI jobs')
|
||||
}
|
||||
}
|
||||
leftPortlets {
|
||||
testStatisticsChart()
|
||||
}
|
||||
rightPortlets {
|
||||
testTrendChart()
|
||||
}
|
||||
bottomPortlets {
|
||||
testStatisticsGrid()
|
||||
buildStatistics()
|
||||
}
|
||||
}*/
|
||||
335
log4j/legal/LICENSE
Normal file
335
log4j/legal/LICENSE
Normal file
@ -0,0 +1,335 @@
|
||||
|
||||
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 (poi-ooxml-full-*.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)
|
||||
|
||||
Copyright (c) 2000 - 2021 The Legion of the Bouncy Castle Inc.
|
||||
(https://www.bouncycastle.org)
|
||||
|
||||
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.
|
||||
|
||||
CurvesAPI / Curve API
|
||||
|
||||
BSD License
|
||||
|
||||
Copyright (c) 2000-2015 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-2017 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.
|
||||
24
log4j/legal/NOTICE
Normal file
24
log4j/legal/NOTICE
Normal file
@ -0,0 +1,24 @@
|
||||
Apache POI
|
||||
Copyright 2003-2021 The Apache Software Foundation
|
||||
|
||||
This product includes software developed at
|
||||
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 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-2018
|
||||
FedICT (federal ICT department of Belgium), e-Contract.be BVBA (https://www.e-contract.be),
|
||||
Bart Hanssens from FedICT
|
||||
78
log4j/maven/poi-examples.pom
Normal file
78
log4j/maven/poi-examples.pom
Normal file
@ -0,0 +1,78 @@
|
||||
<?xml version="1.0"?>
|
||||
<!--
|
||||
|
||||
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
contributor license agreements. See the NOTICE file distributed with
|
||||
this work for additional information regarding copyright ownership.
|
||||
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
(the "License"); you may not use this file except in compliance with
|
||||
the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
-->
|
||||
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi-examples</artifactId>
|
||||
<version>@VERSION@</version>
|
||||
<packaging>jar</packaging>
|
||||
<name>Apache POI</name>
|
||||
<url>https://poi.apache.org/</url>
|
||||
<description>Apache POI Examples</description>
|
||||
|
||||
<mailingLists>
|
||||
<mailingList>
|
||||
<name>POI Users List</name>
|
||||
<subscribe>user-subscribe@poi.apache.org</subscribe>
|
||||
<unsubscribe>user-unsubscribe@poi.apache.org</unsubscribe>
|
||||
<archive>http://mail-archives.apache.org/mod_mbox/poi-user/</archive>
|
||||
</mailingList>
|
||||
<mailingList>
|
||||
<name>POI Developer List</name>
|
||||
<subscribe>dev-subscribe@poi.apache.org</subscribe>
|
||||
<unsubscribe>dev-unsubscribe@poi.apache.org</unsubscribe>
|
||||
<archive>http://mail-archives.apache.org/mod_mbox/poi-dev/</archive>
|
||||
</mailingList>
|
||||
</mailingLists>
|
||||
|
||||
<licenses>
|
||||
<license>
|
||||
<name>Apache License, Version 2.0</name>
|
||||
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
|
||||
</license>
|
||||
</licenses>
|
||||
|
||||
<organization>
|
||||
<name>Apache Software Foundation</name>
|
||||
<url>http://www.apache.org/</url>
|
||||
</organization>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi</artifactId>
|
||||
<version>@VERSION@</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi-scratchpad</artifactId>
|
||||
<version>@VERSION@</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi-ooxml</artifactId>
|
||||
<version>@VERSION@</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
78
log4j/maven/poi-excelant.pom
Normal file
78
log4j/maven/poi-excelant.pom
Normal file
@ -0,0 +1,78 @@
|
||||
<?xml version="1.0"?>
|
||||
<!--
|
||||
|
||||
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
contributor license agreements. See the NOTICE file distributed with
|
||||
this work for additional information regarding copyright ownership.
|
||||
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
(the "License"); you may not use this file except in compliance with
|
||||
the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
-->
|
||||
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi-excelant</artifactId>
|
||||
<version>@VERSION@</version>
|
||||
<packaging>jar</packaging>
|
||||
<name>Apache POI</name>
|
||||
<url>https://poi.apache.org/</url>
|
||||
<description>Apache POI Excel Ant Tasks</description>
|
||||
|
||||
<mailingLists>
|
||||
<mailingList>
|
||||
<name>POI Users List</name>
|
||||
<subscribe>user-subscribe@poi.apache.org</subscribe>
|
||||
<unsubscribe>user-unsubscribe@poi.apache.org</unsubscribe>
|
||||
<archive>http://mail-archives.apache.org/mod_mbox/poi-user/</archive>
|
||||
</mailingList>
|
||||
<mailingList>
|
||||
<name>POI Developer List</name>
|
||||
<subscribe>dev-subscribe@poi.apache.org</subscribe>
|
||||
<unsubscribe>dev-unsubscribe@poi.apache.org</unsubscribe>
|
||||
<archive>http://mail-archives.apache.org/mod_mbox/poi-dev/</archive>
|
||||
</mailingList>
|
||||
</mailingLists>
|
||||
|
||||
<licenses>
|
||||
<license>
|
||||
<name>Apache License, Version 2.0</name>
|
||||
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
|
||||
</license>
|
||||
</licenses>
|
||||
|
||||
<organization>
|
||||
<name>Apache Software Foundation</name>
|
||||
<url>http://www.apache.org/</url>
|
||||
</organization>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi</artifactId>
|
||||
<version>@VERSION@</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi-ooxml</artifactId>
|
||||
<version>@VERSION@</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.ant</groupId>
|
||||
<artifactId>ant</artifactId>
|
||||
<version>1.10.9</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
70
log4j/maven/poi-ooxml-full.pom
Normal file
70
log4j/maven/poi-ooxml-full.pom
Normal file
@ -0,0 +1,70 @@
|
||||
<?xml version="1.0"?>
|
||||
<!--
|
||||
|
||||
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
contributor license agreements. See the NOTICE file distributed with
|
||||
this work for additional information regarding copyright ownership.
|
||||
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
(the "License"); you may not use this file except in compliance with
|
||||
the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
-->
|
||||
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi-ooxml-full</artifactId>
|
||||
<version>@VERSION@</version>
|
||||
<packaging>jar</packaging>
|
||||
<name>Apache POI - OOXML schemas (full)</name>
|
||||
<description>XmlBeans generated from the Ecma supplied xsds (since POI 5.0.0, the 5th edition is used):
|
||||
https://www.ecma-international.org/publications/standards/Ecma-376.htm</description>
|
||||
<url>https://poi.apache.org/</url>
|
||||
|
||||
<mailingLists>
|
||||
<mailingList>
|
||||
<name>POI Users List</name>
|
||||
<subscribe>user-subscribe@poi.apache.org</subscribe>
|
||||
<unsubscribe>user-unsubscribe@poi.apache.org</unsubscribe>
|
||||
<archive>http://mail-archives.apache.org/mod_mbox/poi-user/</archive>
|
||||
</mailingList>
|
||||
<mailingList>
|
||||
<name>POI Developer List</name>
|
||||
<subscribe>dev-subscribe@poi.apache.org</subscribe>
|
||||
<unsubscribe>dev-unsubscribe@poi.apache.org</unsubscribe>
|
||||
<archive>http://mail-archives.apache.org/mod_mbox/poi-dev/</archive>
|
||||
</mailingList>
|
||||
</mailingLists>
|
||||
|
||||
<licenses>
|
||||
<license>
|
||||
<name>Apache License, Version 2.0</name>
|
||||
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
|
||||
<distribution>repo</distribution>
|
||||
</license>
|
||||
</licenses>
|
||||
|
||||
<organization>
|
||||
<name>Apache Software Foundation</name>
|
||||
<url>http://www.apache.org/</url>
|
||||
</organization>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.apache.xmlbeans</groupId>
|
||||
<artifactId>xmlbeans</artifactId>
|
||||
<version>4.0.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
76
log4j/maven/poi-ooxml-lite.pom
Normal file
76
log4j/maven/poi-ooxml-lite.pom
Normal file
@ -0,0 +1,76 @@
|
||||
<?xml version="1.0"?>
|
||||
<!--
|
||||
|
||||
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
contributor license agreements. See the NOTICE file distributed with
|
||||
this work for additional information regarding copyright ownership.
|
||||
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
(the "License"); you may not use this file except in compliance with
|
||||
the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
-->
|
||||
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi-ooxml-lite</artifactId>
|
||||
<version>@VERSION@</version>
|
||||
<packaging>jar</packaging>
|
||||
<name>Apache POI - OOXML Schemas (lite)</name>
|
||||
<url>https://poi.apache.org/</url>
|
||||
<description>Apache POI - Java API To Access Microsoft Format Files</description>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>apache-releases-repo</id>
|
||||
<name>apache releases repo</name>
|
||||
<url>https://repository.apache.org/content/repositories/releases</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<mailingLists>
|
||||
<mailingList>
|
||||
<name>POI Users List</name>
|
||||
<subscribe>user-subscribe@poi.apache.org</subscribe>
|
||||
<unsubscribe>user-unsubscribe@poi.apache.org</unsubscribe>
|
||||
<archive>http://mail-archives.apache.org/mod_mbox/poi-user/</archive>
|
||||
</mailingList>
|
||||
<mailingList>
|
||||
<name>POI Developer List</name>
|
||||
<subscribe>dev-subscribe@poi.apache.org</subscribe>
|
||||
<unsubscribe>dev-unsubscribe@poi.apache.org</unsubscribe>
|
||||
<archive>http://mail-archives.apache.org/mod_mbox/poi-dev/</archive>
|
||||
</mailingList>
|
||||
</mailingLists>
|
||||
|
||||
<licenses>
|
||||
<license>
|
||||
<name>Apache License, Version 2.0</name>
|
||||
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
|
||||
</license>
|
||||
</licenses>
|
||||
|
||||
<organization>
|
||||
<name>Apache Software Foundation</name>
|
||||
<url>http://www.apache.org/</url>
|
||||
</organization>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.apache.xmlbeans</groupId>
|
||||
<artifactId>xmlbeans</artifactId>
|
||||
<version>4.0.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
117
log4j/maven/poi-ooxml.pom
Normal file
117
log4j/maven/poi-ooxml.pom
Normal file
@ -0,0 +1,117 @@
|
||||
<?xml version="1.0"?><!--
|
||||
|
||||
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
contributor license agreements. See the NOTICE file distributed with
|
||||
this work for additional information regarding copyright ownership.
|
||||
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
(the "License"); you may not use this file except in compliance with
|
||||
the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
-->
|
||||
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi-ooxml</artifactId>
|
||||
<version>@VERSION@</version>
|
||||
<packaging>jar</packaging>
|
||||
<name>Apache POI - API based on OPC and OOXML schemas</name>
|
||||
<url>https://poi.apache.org/</url>
|
||||
<description>Apache POI - Java API To Access Microsoft Format Files</description>
|
||||
|
||||
<mailingLists>
|
||||
<mailingList>
|
||||
<name>POI Users List</name>
|
||||
<subscribe>user-subscribe@poi.apache.org</subscribe>
|
||||
<unsubscribe>user-unsubscribe@poi.apache.org</unsubscribe>
|
||||
<archive>http://mail-archives.apache.org/mod_mbox/poi-user/</archive>
|
||||
</mailingList>
|
||||
<mailingList>
|
||||
<name>POI Developer List</name>
|
||||
<subscribe>dev-subscribe@poi.apache.org</subscribe>
|
||||
<unsubscribe>dev-unsubscribe@poi.apache.org</unsubscribe>
|
||||
<archive>http://mail-archives.apache.org/mod_mbox/poi-dev/</archive>
|
||||
</mailingList>
|
||||
</mailingLists>
|
||||
|
||||
<licenses>
|
||||
<license>
|
||||
<name>Apache License, Version 2.0</name>
|
||||
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
|
||||
</license>
|
||||
</licenses>
|
||||
|
||||
<organization>
|
||||
<name>Apache Software Foundation</name>
|
||||
<url>http://www.apache.org/</url>
|
||||
</organization>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi</artifactId>
|
||||
<version>@VERSION@</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi-ooxml-lite</artifactId>
|
||||
<version>@VERSION@</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-compress</artifactId>
|
||||
<version>1.20</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.virtuald</groupId>
|
||||
<artifactId>curvesapi</artifactId>
|
||||
<version>1.06</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.bouncycastle</groupId>
|
||||
<artifactId>bcpkix-jdk15on</artifactId>
|
||||
<version>1.68</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.bouncycastle</groupId>
|
||||
<artifactId>bcprov-jdk15on</artifactId>
|
||||
<version>1.68</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.santuario</groupId>
|
||||
<artifactId>xmlsec</artifactId>
|
||||
<version>2.2.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.xmlgraphics</groupId>
|
||||
<artifactId>batik-all</artifactId>
|
||||
<version>1.13</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>commons-logging</groupId>
|
||||
<artifactId>commons-logging</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>de.rototor.pdfbox</groupId>
|
||||
<artifactId>graphics2d</artifactId>
|
||||
<version>0.30</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>commons-logging</groupId>
|
||||
<artifactId>commons-logging</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
68
log4j/maven/poi-scratchpad.pom
Normal file
68
log4j/maven/poi-scratchpad.pom
Normal file
@ -0,0 +1,68 @@
|
||||
<?xml version="1.0"?>
|
||||
<!--
|
||||
|
||||
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
contributor license agreements. See the NOTICE file distributed with
|
||||
this work for additional information regarding copyright ownership.
|
||||
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
(the "License"); you may not use this file except in compliance with
|
||||
the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
-->
|
||||
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi-scratchpad</artifactId>
|
||||
<version>@VERSION@</version>
|
||||
<packaging>jar</packaging>
|
||||
<name>Apache POI</name>
|
||||
<url>https://poi.apache.org/</url>
|
||||
<description>Apache POI - Java API To Access Microsoft Format Files</description>
|
||||
|
||||
<mailingLists>
|
||||
<mailingList>
|
||||
<name>POI Users List</name>
|
||||
<subscribe>user-subscribe@poi.apache.org</subscribe>
|
||||
<unsubscribe>user-unsubscribe@poi.apache.org</unsubscribe>
|
||||
<archive>http://mail-archives.apache.org/mod_mbox/poi-user/</archive>
|
||||
</mailingList>
|
||||
<mailingList>
|
||||
<name>POI Developer List</name>
|
||||
<subscribe>dev-subscribe@poi.apache.org</subscribe>
|
||||
<unsubscribe>dev-unsubscribe@poi.apache.org</unsubscribe>
|
||||
<archive>http://mail-archives.apache.org/mod_mbox/poi-dev/</archive>
|
||||
</mailingList>
|
||||
</mailingLists>
|
||||
|
||||
<licenses>
|
||||
<license>
|
||||
<name>Apache License, Version 2.0</name>
|
||||
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
|
||||
</license>
|
||||
</licenses>
|
||||
|
||||
<organization>
|
||||
<name>Apache Software Foundation</name>
|
||||
<url>http://www.apache.org/</url>
|
||||
</organization>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi</artifactId>
|
||||
<version>@VERSION@</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
91
log4j/maven/poi.pom
Normal file
91
log4j/maven/poi.pom
Normal file
@ -0,0 +1,91 @@
|
||||
<?xml version="1.0"?><!--
|
||||
|
||||
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
contributor license agreements. See the NOTICE file distributed with
|
||||
this work for additional information regarding copyright ownership.
|
||||
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
(the "License"); you may not use this file except in compliance with
|
||||
the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
-->
|
||||
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi</artifactId>
|
||||
<version>@VERSION@</version>
|
||||
<packaging>jar</packaging>
|
||||
<name>Apache POI</name>
|
||||
<url>https://poi.apache.org/</url>
|
||||
<description>Apache POI - Java API To Access Microsoft Format Files</description>
|
||||
|
||||
<mailingLists>
|
||||
<mailingList>
|
||||
<name>POI Users List</name>
|
||||
<subscribe>user-subscribe@poi.apache.org</subscribe>
|
||||
<unsubscribe>user-unsubscribe@poi.apache.org</unsubscribe>
|
||||
<archive>http://mail-archives.apache.org/mod_mbox/poi-user/</archive>
|
||||
</mailingList>
|
||||
<mailingList>
|
||||
<name>POI Developer List</name>
|
||||
<subscribe>dev-subscribe@poi.apache.org</subscribe>
|
||||
<unsubscribe>dev-unsubscribe@poi.apache.org</unsubscribe>
|
||||
<archive>http://mail-archives.apache.org/mod_mbox/poi-dev/</archive>
|
||||
</mailingList>
|
||||
</mailingLists>
|
||||
|
||||
<licenses>
|
||||
<license>
|
||||
<name>Apache License, Version 2.0</name>
|
||||
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
|
||||
</license>
|
||||
</licenses>
|
||||
|
||||
<organization>
|
||||
<name>Apache Software Foundation</name>
|
||||
<url>http://www.apache.org/</url>
|
||||
</organization>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
<version>1.7.30</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>jcl-over-slf4j</artifactId>
|
||||
<version>1.7.30</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-codec</groupId>
|
||||
<artifactId>commons-codec</artifactId>
|
||||
<version>1.15</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-collections4</artifactId>
|
||||
<version>4.4</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-math3</artifactId>
|
||||
<version>3.6.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.zaxxer</groupId>
|
||||
<artifactId>SparseBitSet</artifactId>
|
||||
<version>1.2</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
67
log4j/osgi/README.md
Normal file
67
log4j/osgi/README.md
Normal file
@ -0,0 +1,67 @@
|
||||
# Apache POI OSGi Bundle
|
||||
|
||||
The POI bundle is an Uber jar which exports all the POI classes, XML Beans, OOXML Schemas and required dependencies. The current size is around 21 MB.
|
||||
The bundle is self-contained and can be used out of the box in a bare OSGi container.
|
||||
|
||||
## Embedded Dependencies
|
||||
The bundle embeds all the jars from lib/main:
|
||||
|
||||
- SparseBitSet
|
||||
- curvesapi
|
||||
- commons-math3
|
||||
- commons-compress
|
||||
- commons-collections4
|
||||
- commons-codec
|
||||
|
||||
## Optional Dependencies
|
||||
|
||||
1. Apache Batik
|
||||
Required to render WMF/EMF images. The OSGi bundle is provided by ServiceMix and available in Maven Central: https://mvnrepository.com/artifact/org.apache.servicemix.bundles/org.apache.servicemix.bundles.batik/1.13_1
|
||||
2. Saxon
|
||||
Required if using as the XSLT and XQuery Processor engine in XML Beans.
|
||||
Available in Maven Central: https://mvnrepository.com/artifact/net.sf.saxon/saxon/8.9.0.4-osgi
|
||||
3. Apache XML Security for Java, Bouncy Castle and XML Commons Resolver
|
||||
These are required to sign or validate signed Office documents. The OSGi bundles are available in Maven Central:
|
||||
|
||||
- Apache XML Security for Java: https://mvnrepository.com/artifact/org.apache.santuario/xmlsec/2.2.0
|
||||
|
||||
- XML Commons Resolver: https://mvnrepository.com/artifact/xml-resolver/xml-resolver/1.2-osgi
|
||||
|
||||
- Bouncy Castle: https://mvnrepository.com/artifact/org.bouncycastle/bcprov-ext-jdk15on/1.66, https://mvnrepository.com/artifact/org.bouncycastle/bcpkix-jdk15on/1.66
|
||||
4. PDFBox and PDFBox Graphics2D
|
||||
Required to render to PDF documents.
|
||||
The required jars can be downloaded from:
|
||||
|
||||
- PDFBox:
|
||||
https://mvnrepository.com/artifact/org.apache.pdfbox/pdfbox
|
||||
https://mvnrepository.com/artifact/org.apache.pdfbox/fontbox
|
||||
- PDFBox Graphics2D:
|
||||
https://mvnrepository.com/artifact/de.rototor.pdfbox/graphics2d
|
||||
|
||||
## Blocked Imports
|
||||
|
||||
The Bundle Maven Plugin performs a thorough inspection of the dependencies on external packages and by default includes them all in the <Import-Package> section.
|
||||
|
||||
Transitive dependencies from XML Beans not required by POI:
|
||||
|
||||
- !com.github.javaparser.*,
|
||||
- !org.apache.tools.ant.*
|
||||
|
||||
Optional codecs pulled by Commons-Compress. Not used by POI
|
||||
|
||||
- !com.github.luben.zstd.*,
|
||||
- !org.tukaani.xz.*,
|
||||
- !org.brotli.dec.*,
|
||||
|
||||
Internal APIs which are no more in JPMS
|
||||
|
||||
- !sun.misc.*
|
||||
|
||||
## Integration Testing
|
||||
|
||||
The project tests the bundle using the Pax Exam framework which executes junit tests within an OSGi container started by Maven. The current version uses the Apache Felix driver but the framework should not matter, same tests will pass with the Karaf or Equinox drivers.
|
||||
|
||||
When running integration tests Maven starts a bare Apache Felix OSGi container, deploys the POI bundle and runs a few simple tests to validate the code is working fine, e.g. create a spreadsheet, serialize it to a byte array and read back.
|
||||
|
||||
|
||||
|
||||
238
log4j/osgi/pom.xml
Normal file
238
log4j/osgi/pom.xml
Normal file
@ -0,0 +1,238 @@
|
||||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<!--
|
||||
Licensed to the Apache Software Foundation (ASF) under one
|
||||
or more contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. The ASF licenses this file
|
||||
to you under the Apache License, Version 2.0 (the
|
||||
"License"); you may not use this file except in compliance
|
||||
with the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing,
|
||||
software distributed under the License is distributed on an
|
||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, either express or implied. See the License for the
|
||||
specific language governing permissions and limitations
|
||||
under the License.
|
||||
-->
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi-bundle</artifactId>
|
||||
<packaging>bundle</packaging>
|
||||
<version>5.0.1-SNAPSHOT</version>
|
||||
|
||||
<name>Apache POI OSGi bundle</name>
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<poi.version>5.0.0-SNAPSHOT</poi.version>
|
||||
<pax.exam.version>4.12.0</pax.exam.version>
|
||||
</properties>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.8.0</version>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.felix</groupId>
|
||||
<artifactId>maven-bundle-plugin</artifactId>
|
||||
<version>4.2.1</version>
|
||||
<extensions>true</extensions>
|
||||
<configuration>
|
||||
<instructions>
|
||||
<Bundle-Activator>
|
||||
org.apache.poi.osgi.Activator
|
||||
</Bundle-Activator>
|
||||
<Export-Package>
|
||||
org.apache.poi.*,
|
||||
org.openxmlformats.schemas.*,
|
||||
com.microsoft.schemas.*,
|
||||
org.w3.x2000.x09.xmldsig.*,
|
||||
org.etsi.uri.x01903.v13.*,
|
||||
org.apache.xmlbeans.*,
|
||||
org.apache.commons.compress.*,
|
||||
com.zaxxer.sparsebits.*,
|
||||
com.graphbuilder.*
|
||||
</Export-Package>
|
||||
<Import-Package>
|
||||
!org.apache.poi.*,
|
||||
!org.openxmlformats.schemas.*,
|
||||
!com.microsoft.schemas.*,
|
||||
!org.w3.x2000.x09.xmldsig.*,
|
||||
!org.etsi.uri.x01903.*,
|
||||
!org.apache.xmlbeans.*,
|
||||
!org.apache.commons.compress.*,
|
||||
!com.zaxxer.sparsebits.*,
|
||||
!com.graphbuilder.*,
|
||||
org.apache.batik.*;resolution:=optional,
|
||||
org.apache.pdfbox.*;resolution:=optional,
|
||||
org.apache.fontbox.*;resolution:=optional,
|
||||
de.rototor.pdfbox.graphics2d.*;resolution:=optional,
|
||||
net.sf.saxon.*;resolution:=optional,
|
||||
!com.github.javaparser.*,
|
||||
!org.apache.tools.ant.*,
|
||||
!sun.misc.*,
|
||||
org.apache.jcp.xml.dsig.internal.dom;resolution:=optional,
|
||||
org.apache.xml.resolver.*;resolution:=optional,
|
||||
org.apache.xml.security.*;resolution:=optional,
|
||||
org.bouncycastle.*;resolution:=optional,
|
||||
org.apache.commons.logging.*;resolution:=optional,
|
||||
org.slf4j.*;resolution:=optional,
|
||||
!com.github.luben.zstd.*,
|
||||
!org.tukaani.xz.*,
|
||||
!org.brotli.dec.*,
|
||||
*
|
||||
</Import-Package>
|
||||
<Embed-Dependency>
|
||||
poi;inline=true,
|
||||
poi-scratchpad;inline=true,
|
||||
poi-ooxml;inline=true,
|
||||
poi-ooxml-lite;inline=true,
|
||||
xmlbeans;inline=true,
|
||||
SparseBitSet,
|
||||
curvesapi,
|
||||
commons-math3,
|
||||
commons-compress,
|
||||
commons-collections4,
|
||||
commons-codec
|
||||
</Embed-Dependency>
|
||||
<Embed-Directory>lib</Embed-Directory>
|
||||
<Embed-Transitive>true</Embed-Transitive>
|
||||
</instructions>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-failsafe-plugin</artifactId>
|
||||
<version>2.22.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>integration-test</goal>
|
||||
<goal>verify</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<systemProperties>
|
||||
<property>
|
||||
<name>bundle.filename</name>
|
||||
<value>${basedir}/target/${project.build.finalName}.jar</value>
|
||||
</property>
|
||||
</systemProperties>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi</artifactId>
|
||||
<version>${poi.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi-ooxml</artifactId>
|
||||
<version>${poi.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi-scratchpad</artifactId>
|
||||
<version>${poi.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi-ooxml-lite</artifactId>
|
||||
<version>${poi.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Pax Exam Testing -->
|
||||
|
||||
<!-- an OSGi framework -->
|
||||
<dependency>
|
||||
<groupId>org.osgi</groupId>
|
||||
<artifactId>org.osgi.core</artifactId>
|
||||
<version>4.3.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.felix</groupId>
|
||||
<artifactId>org.apache.felix.framework</artifactId>
|
||||
<version>6.0.3</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- JUnit -->
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<scope>test</scope>
|
||||
<version>4.13.1</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Pax Exam -->
|
||||
<dependency>
|
||||
<groupId>org.ops4j.pax.exam</groupId>
|
||||
<artifactId>pax-exam</artifactId>
|
||||
<version>${pax.exam.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.ops4j.pax.exam</groupId>
|
||||
<artifactId>pax-exam-junit4</artifactId>
|
||||
<version>${pax.exam.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.ops4j.pax.exam</groupId>
|
||||
<artifactId>pax-exam-cm</artifactId>
|
||||
<version>${pax.exam.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.ops4j.pax.exam</groupId>
|
||||
<artifactId>pax-exam-container-forked</artifactId>
|
||||
<version>${pax.exam.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.ops4j.pax.url</groupId>
|
||||
<artifactId>pax-url-link</artifactId>
|
||||
<scope>test</scope>
|
||||
<version>2.5.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.ops4j.pax.url</groupId>
|
||||
<artifactId>pax-url-classpath</artifactId>
|
||||
<scope>test</scope>
|
||||
<version>2.5.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.ops4j.pax.exam</groupId>
|
||||
<artifactId>pax-exam-link-assembly</artifactId>
|
||||
<version>${pax.exam.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.inject</groupId>
|
||||
<artifactId>javax.inject</artifactId>
|
||||
<version>1</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-simple</artifactId>
|
||||
<version>1.7.30</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
||||
60
log4j/osgi/src/main/java/org/apache/poi/osgi/Activator.java
Normal file
60
log4j/osgi/src/main/java/org/apache/poi/osgi/Activator.java
Normal file
@ -0,0 +1,60 @@
|
||||
/* ====================================================================
|
||||
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
contributor license agreements. See the NOTICE file distributed with
|
||||
this work for additional information regarding copyright ownership.
|
||||
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
(the "License"); you may not use this file except in compliance with
|
||||
the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
==================================================================== */
|
||||
|
||||
package org.apache.poi.osgi;
|
||||
|
||||
import org.apache.poi.extractor.ExtractorFactory;
|
||||
import org.apache.poi.extractor.MainExtractorFactory;
|
||||
import org.apache.poi.extractor.ole2.OLE2ScratchpadExtractorFactory;
|
||||
import org.apache.poi.hslf.usermodel.HSLFSlideShowFactory;
|
||||
import org.apache.poi.hssf.usermodel.HSSFWorkbookFactory;
|
||||
import org.apache.poi.ooxml.extractor.POIXMLExtractorFactory;
|
||||
import org.apache.poi.sl.usermodel.SlideShowFactory;
|
||||
import org.apache.poi.ss.usermodel.WorkbookFactory;
|
||||
import org.apache.poi.xslf.usermodel.XSLFSlideShowFactory;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbookFactory;
|
||||
import org.osgi.framework.BundleActivator;
|
||||
import org.osgi.framework.BundleContext;
|
||||
|
||||
public class Activator implements BundleActivator {
|
||||
|
||||
@Override
|
||||
public void start(BundleContext context) {
|
||||
WorkbookFactory.addProvider(new HSSFWorkbookFactory());
|
||||
WorkbookFactory.addProvider(new XSSFWorkbookFactory());
|
||||
|
||||
SlideShowFactory.addProvider(new HSLFSlideShowFactory());
|
||||
SlideShowFactory.addProvider(new XSLFSlideShowFactory());
|
||||
|
||||
ExtractorFactory.addProvider(new OLE2ScratchpadExtractorFactory());
|
||||
ExtractorFactory.addProvider(new POIXMLExtractorFactory());
|
||||
ExtractorFactory.addProvider(new MainExtractorFactory());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stop(BundleContext context) {
|
||||
WorkbookFactory.removeProvider(HSSFWorkbookFactory.class);
|
||||
WorkbookFactory.removeProvider(XSSFWorkbookFactory.class);
|
||||
|
||||
SlideShowFactory.removeProvider(HSLFSlideShowFactory.class);
|
||||
SlideShowFactory.removeProvider(XSLFSlideShowFactory.class);
|
||||
|
||||
ExtractorFactory.removeProvider(OLE2ScratchpadExtractorFactory.class);
|
||||
ExtractorFactory.removeProvider(POIXMLExtractorFactory.class);
|
||||
ExtractorFactory.removeProvider(MainExtractorFactory.class);
|
||||
}
|
||||
}
|
||||
49
log4j/osgi/src/test/java/org/apache/poi/osgi/BaseOSGiTestCase.java
Executable file
49
log4j/osgi/src/test/java/org/apache/poi/osgi/BaseOSGiTestCase.java
Executable file
@ -0,0 +1,49 @@
|
||||
/* ====================================================================
|
||||
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
contributor license agreements. See the NOTICE file distributed with
|
||||
this work for additional information regarding copyright ownership.
|
||||
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
(the "License"); you may not use this file except in compliance with
|
||||
the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
==================================================================== */
|
||||
|
||||
package org.apache.poi.osgi;
|
||||
|
||||
import org.ops4j.pax.exam.Configuration;
|
||||
import org.ops4j.pax.exam.Option;
|
||||
import org.osgi.framework.BundleContext;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import static org.ops4j.pax.exam.CoreOptions.*;
|
||||
|
||||
/**
|
||||
* Test to ensure that all our main formats can create, write
|
||||
* and read back in, when running under OSGi
|
||||
*/
|
||||
public class BaseOSGiTestCase {
|
||||
|
||||
@Inject
|
||||
private BundleContext bc;
|
||||
|
||||
@Configuration
|
||||
public Option[] configuration() throws IOException {
|
||||
String bundlePath = System.getProperty("bundle.filename");
|
||||
if(bundlePath == null){
|
||||
throw new IllegalStateException("-Dbundle.filename property is not set.");
|
||||
}
|
||||
return options(
|
||||
junitBundles(),
|
||||
bundle(new File(bundlePath).toURI().toURL().toString()));
|
||||
}
|
||||
}
|
||||
120
log4j/osgi/src/test/java/org/apache/poi/osgi/OSGiExtractorsIT.java
Executable file
120
log4j/osgi/src/test/java/org/apache/poi/osgi/OSGiExtractorsIT.java
Executable file
@ -0,0 +1,120 @@
|
||||
/* ====================================================================
|
||||
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
contributor license agreements. See the NOTICE file distributed with
|
||||
this work for additional information regarding copyright ownership.
|
||||
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
(the "License"); you may not use this file except in compliance with
|
||||
the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
==================================================================== */
|
||||
|
||||
package org.apache.poi.osgi;
|
||||
|
||||
import org.apache.poi.extractor.ExtractorFactory;
|
||||
import org.apache.poi.hslf.usermodel.HSLFSlideShow;
|
||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
||||
import org.apache.poi.sl.usermodel.Slide;
|
||||
import org.apache.poi.sl.usermodel.SlideShow;
|
||||
import org.apache.poi.sl.usermodel.TextBox;
|
||||
import org.apache.poi.sl.usermodel.TextShape;
|
||||
import org.apache.poi.ss.usermodel.Sheet;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
import org.apache.poi.xslf.usermodel.XMLSlideShow;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.ops4j.pax.exam.junit.PaxExam;
|
||||
import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
|
||||
import org.ops4j.pax.exam.spi.reactors.PerClass;
|
||||
|
||||
import java.awt.*;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
/**
|
||||
* Test to ensure that all our main formats can create, write
|
||||
* and read back in, when running under OSGi
|
||||
*/
|
||||
@RunWith(PaxExam.class)
|
||||
@ExamReactorStrategy(PerClass.class)
|
||||
public class OSGiExtractorsIT extends BaseOSGiTestCase {
|
||||
|
||||
|
||||
byte[] createSlideShow(SlideShow ppt) throws Exception {
|
||||
Slide<?, ?> slide = ppt.createSlide();
|
||||
|
||||
TextBox<?, ?> box = slide.createTextBox();
|
||||
box.setTextPlaceholder(TextShape.TextPlaceholder.TITLE);
|
||||
box.setText("Hello, World!");
|
||||
box.setAnchor(new Rectangle(36, 15, 648, 65));
|
||||
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
ppt.write(out);
|
||||
return out.toByteArray();
|
||||
}
|
||||
|
||||
byte[] createWorkbook(Workbook wb) throws Exception {
|
||||
Sheet s = wb.createSheet("OSGi");
|
||||
s.createRow(0).createCell(0).setCellValue("Hello, World!");
|
||||
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
wb.write(out);
|
||||
return out.toByteArray();
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* this should invoke OLE2ScratchpadExtractorFactory
|
||||
*/
|
||||
@Test
|
||||
public void testHSLF() throws Exception {
|
||||
byte[] bytes = createSlideShow(new HSLFSlideShow());
|
||||
ByteArrayInputStream is = new ByteArrayInputStream(bytes);
|
||||
|
||||
String text = ExtractorFactory.createExtractor(is).getText().trim();
|
||||
assertEquals("Hello, World!", text);
|
||||
}
|
||||
|
||||
/**
|
||||
* this should invoke POIXMLExtractorFactory
|
||||
*/
|
||||
@Test
|
||||
public void testXSLF() throws Exception {
|
||||
byte[] bytes = createSlideShow(new XMLSlideShow());
|
||||
ByteArrayInputStream is = new ByteArrayInputStream(bytes);
|
||||
|
||||
String text = ExtractorFactory.createExtractor(is).getText().trim();
|
||||
assertEquals("Hello, World!", text);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHSSF() throws Exception {
|
||||
byte[] bytes = createWorkbook(new HSSFWorkbook());
|
||||
ByteArrayInputStream is = new ByteArrayInputStream(bytes);
|
||||
|
||||
String text = ExtractorFactory.createExtractor(is).getText().trim();
|
||||
assertEquals("OSGi\nHello, World!", text);
|
||||
}
|
||||
|
||||
/**
|
||||
* this should invoke POIXMLExtractorFactory
|
||||
*/
|
||||
@Test
|
||||
public void testXSSF() throws Exception {
|
||||
byte[] bytes = createWorkbook(new XSSFWorkbook());
|
||||
ByteArrayInputStream is = new ByteArrayInputStream(bytes);
|
||||
|
||||
String text = ExtractorFactory.createExtractor(is).getText().trim();
|
||||
assertEquals("OSGi\nHello, World!", text);
|
||||
}
|
||||
}
|
||||
98
log4j/osgi/src/test/java/org/apache/poi/osgi/OSGiSlideShowIT.java
Executable file
98
log4j/osgi/src/test/java/org/apache/poi/osgi/OSGiSlideShowIT.java
Executable file
@ -0,0 +1,98 @@
|
||||
/* ====================================================================
|
||||
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
contributor license agreements. See the NOTICE file distributed with
|
||||
this work for additional information regarding copyright ownership.
|
||||
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
(the "License"); you may not use this file except in compliance with
|
||||
the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
==================================================================== */
|
||||
|
||||
package org.apache.poi.osgi;
|
||||
|
||||
import org.apache.poi.hslf.usermodel.HSLFSlideShow;
|
||||
import org.apache.poi.sl.usermodel.*;
|
||||
import org.apache.poi.xslf.usermodel.XMLSlideShow;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.ops4j.pax.exam.junit.PaxExam;
|
||||
import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
|
||||
import org.ops4j.pax.exam.spi.reactors.PerClass;
|
||||
|
||||
import java.awt.*;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
/**
|
||||
* Test to ensure that all our main formats can create, write
|
||||
* and read back in, when running under OSGi
|
||||
*/
|
||||
@RunWith(PaxExam.class)
|
||||
@ExamReactorStrategy(PerClass.class)
|
||||
public class OSGiSlideShowIT extends BaseOSGiTestCase {
|
||||
|
||||
|
||||
// create a workbook, validate and write back
|
||||
void testSS(SlideShow ppt) throws Exception {
|
||||
Slide<?, ?> slide = ppt.createSlide();
|
||||
|
||||
TextBox<?, ?> box1 = slide.createTextBox();
|
||||
box1.setTextPlaceholder(TextShape.TextPlaceholder.TITLE);
|
||||
box1.setText("HSLF in a Nutshell");
|
||||
box1.setAnchor(new Rectangle(36, 15, 648, 65));
|
||||
|
||||
TextBox<?, ?> box2 = slide.createTextBox();
|
||||
box2.setTextPlaceholder(TextShape.TextPlaceholder.BODY);
|
||||
box2.setText(
|
||||
"HSLF provides a way to read, create and modify MS PowerPoint presentations\r" +
|
||||
"Pure Java API - you don't need PowerPoint to read and write *.ppt files\r" +
|
||||
"Comprehensive support of PowerPoint objects\r" +
|
||||
"Rich text\r" +
|
||||
"Tables\r" +
|
||||
"Shapes\r" +
|
||||
"Pictures\r" +
|
||||
"Master slides\r" +
|
||||
"Access to low level data structures"
|
||||
);
|
||||
|
||||
List<? extends TextParagraph<?, ?, ?>> tp = box2.getTextParagraphs();
|
||||
for (int i : new byte[]{0, 1, 2, 8}) {
|
||||
tp.get(i).getTextRuns().get(0).setFontSize(28d);
|
||||
}
|
||||
for (int i : new byte[]{3, 4, 5, 6, 7}) {
|
||||
tp.get(i).getTextRuns().get(0).setFontSize(24d);
|
||||
tp.get(i).setIndentLevel(1);
|
||||
}
|
||||
box2.setAnchor(new Rectangle(36, 80, 648, 400));
|
||||
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
ppt.write(baos);
|
||||
ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
|
||||
|
||||
ppt = SlideShowFactory.create(bais);
|
||||
assertEquals(1, ppt.getSlides().size());
|
||||
slide = (Slide) ppt.getSlides().iterator().next();
|
||||
assertEquals(2, slide.getShapes().size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHSLF() throws Exception {
|
||||
testSS(new HSLFSlideShow());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testXSLF() throws Exception {
|
||||
testSS(new XMLSlideShow());
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,85 @@
|
||||
/* ====================================================================
|
||||
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
contributor license agreements. See the NOTICE file distributed with
|
||||
this work for additional information regarding copyright ownership.
|
||||
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
(the "License"); you may not use this file except in compliance with
|
||||
the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
==================================================================== */
|
||||
|
||||
package org.apache.poi.osgi;
|
||||
|
||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
||||
import org.apache.poi.ss.usermodel.Sheet;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
import org.apache.poi.ss.usermodel.WorkbookFactory;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.ops4j.pax.exam.junit.PaxExam;
|
||||
import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
|
||||
import org.ops4j.pax.exam.spi.reactors.PerClass;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
/**
|
||||
* Test to ensure that all our main formats can create, write
|
||||
* and read back in, when running under OSGi
|
||||
*/
|
||||
@RunWith(PaxExam.class)
|
||||
@ExamReactorStrategy(PerClass.class)
|
||||
public class OSGiSpreadsheetIT extends BaseOSGiTestCase {
|
||||
|
||||
|
||||
// create a workbook, validate and write back
|
||||
void testWorkbook(Workbook wb) throws Exception {
|
||||
Sheet s = wb.createSheet("OSGi");
|
||||
s.createRow(0).createCell(0).setCellValue("With OSGi");
|
||||
s.createRow(1).createCell(0).setCellFormula("SUM(A1:B3)");
|
||||
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
wb.write(baos);
|
||||
ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
|
||||
|
||||
wb = WorkbookFactory.create(bais);
|
||||
assertEquals(1, wb.getNumberOfSheets());
|
||||
|
||||
s = wb.getSheet("OSGi");
|
||||
assertEquals("With OSGi", s.getRow(0).getCell(0).toString());
|
||||
assertEquals("SUM(A1:B3)", s.getRow(1).getCell(0).toString());
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHSSF() throws Exception {
|
||||
testWorkbook(new HSSFWorkbook());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testXSSF() throws Exception {
|
||||
testWorkbook(new XSSFWorkbook());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSXSSF() throws Exception {
|
||||
testWorkbook(new XSSFWorkbook());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFormulaEvaluation() throws Exception {
|
||||
testWorkbook(new XSSFWorkbook());
|
||||
}
|
||||
|
||||
}
|
||||
128
log4j/patch.xml
Normal file
128
log4j/patch.xml
Normal file
@ -0,0 +1,128 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
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.
|
||||
-->
|
||||
<!--
|
||||
=======================================================================
|
||||
Use Apache Ant to generate a patch file.
|
||||
=======================================================================
|
||||
-->
|
||||
<project name="create-patch" default="patchpackage" basedir=".">
|
||||
<property environment="env"/>
|
||||
<property name="patch.package" value="patch.tar.gz"/>
|
||||
<property name="patch.file" value="patch.txt"/>
|
||||
|
||||
<condition property="svn.found">
|
||||
<or>
|
||||
<available file="svn" filepath="${env.PATH}"/>
|
||||
<available file="svn.exe" filepath="${env.PATH}"/>
|
||||
<available file="svn.exe" filepath="${env.Path}"/>
|
||||
</or>
|
||||
</condition>
|
||||
|
||||
<target name="createpatch">
|
||||
<fail unless="svn.found" message="You need a version of svn to create the patch"/>
|
||||
<exec executable="svn" output="${patch.file}">
|
||||
<arg value="diff"/>
|
||||
</exec>
|
||||
</target>
|
||||
|
||||
<target name="newfiles">
|
||||
<exec executable="svn" output="${patch.file}.tmp">
|
||||
<arg value="status"/>
|
||||
</exec>
|
||||
|
||||
<!-- prepare the list of files to include in patch.tar.gz -->
|
||||
<loadfile srcfile="${patch.file}.tmp" property="tar.file.list">
|
||||
<filterchain>
|
||||
<!-- capture any new files -->
|
||||
<linecontainsregexp>
|
||||
<regexp pattern="^(\?|A)......"/>
|
||||
</linecontainsregexp>
|
||||
<!-- filter out the first six characters -->
|
||||
<tokenfilter>
|
||||
<replaceregex pattern="^(.......)" replace=""/>
|
||||
</tokenfilter>
|
||||
<!--remove line breaks -->
|
||||
<striplinebreaks/>
|
||||
</filterchain>
|
||||
</loadfile>
|
||||
</target>
|
||||
|
||||
<target name="patchpackage" depends="createpatch,newfiles">
|
||||
<delete file="${patch.package}"/>
|
||||
<tar includes="${tar.file.list}"
|
||||
destfile="${patch.package}"
|
||||
basedir="."
|
||||
compression="gzip" >
|
||||
</tar>
|
||||
<delete file="${patch.file}.tmp"/>
|
||||
</target>
|
||||
|
||||
<target name="apply"
|
||||
description="apply patch.tar.gz files generated by patchpackage">
|
||||
|
||||
<!--
|
||||
extract patch.tar.gz to svn working copy
|
||||
$ tar xvzf patch.tar.gz
|
||||
-->
|
||||
<echo message="extracting ${patch.file} to working copy"/>
|
||||
<untar src="${patch.package}"
|
||||
dest="."
|
||||
failOnEmptyArchive="true"
|
||||
compression="gzip">
|
||||
</untar>
|
||||
|
||||
<!--
|
||||
Apply the changes from patch.txt
|
||||
$ svn patch patch.txt
|
||||
-->
|
||||
<echo message="svn patch ${patch.file}"/>
|
||||
<fail unless="svn.found" message="You need a version of svn to create the patch"/>
|
||||
<exec executable="svn">
|
||||
<arg value="patch"/>
|
||||
<arg value="${patch.file}"/>
|
||||
</exec>
|
||||
<delete file="${patch.file}"/>
|
||||
|
||||
<!--
|
||||
get a list of all new files in patch.tar.gz and store in tar.file.list filelist
|
||||
$ tar tf patch.tar.gz | grep -v patch\.txt | xargs svn add
|
||||
-->
|
||||
<echo message="Getting ${patch.file} file list"/>
|
||||
<delete dir="${patch.package}.tmp" quiet="false" failonerror="false" />
|
||||
<untar src="${patch.package}"
|
||||
dest="${patch.package}.tmp"
|
||||
failOnEmptyArchive="true"
|
||||
compression="gzip">
|
||||
</untar>
|
||||
<fileset dir="${patch.package}.tmp"
|
||||
id="tar.file.list"
|
||||
excludes="${patch.file}"/>
|
||||
|
||||
<!-- add new files -->
|
||||
<echo message="Adding new files to svn working copy"/>
|
||||
<apply executable="svn"
|
||||
relative="true">
|
||||
<arg value="add"/>
|
||||
<fileset refid="tar.file.list"/>
|
||||
</apply>
|
||||
|
||||
<delete dir="${patch.package}.tmp"/>
|
||||
|
||||
</target>
|
||||
|
||||
</project>
|
||||
10
log4j/settings.gradle
Normal file
10
log4j/settings.gradle
Normal file
@ -0,0 +1,10 @@
|
||||
rootProject.name = 'poi'
|
||||
|
||||
include 'main', 'ooxml', 'excelant', 'examples', 'scratchpad', 'integrationtest'
|
||||
|
||||
project(':main').projectDir = new File(settingsDir, 'build/main')
|
||||
project(':ooxml').projectDir = new File(settingsDir, 'build/ooxml')
|
||||
project(':excelant').projectDir = new File(settingsDir, 'build/excelant')
|
||||
project(':examples').projectDir = new File(settingsDir, 'build/examples')
|
||||
project(':scratchpad').projectDir = new File(settingsDir, 'build/scratchpad')
|
||||
project(':integrationtest').projectDir = new File(settingsDir, 'build/integrationtest')
|
||||
74
log4j/sonar/examples/pom.xml
Normal file
74
log4j/sonar/examples/pom.xml
Normal file
@ -0,0 +1,74 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
|
||||
http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi-parent</artifactId>
|
||||
<version>5.0.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>poi-examples</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>Apache POI Examples package</name>
|
||||
|
||||
<properties>
|
||||
<!-- There are no junit tests in the examples module -->
|
||||
<maven.test.skip>true</maven.test.skip>
|
||||
</properties>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<!-- copy sources, resources and tests in place as otherwise Sonar does not pick them up correctly! -->
|
||||
<plugin>
|
||||
<artifactId>maven-resources-plugin</artifactId>
|
||||
<version>${maven.plugin.resources.version}</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>copy-sources</id>
|
||||
<!-- here the phase you need -->
|
||||
<phase>generate-sources</phase>
|
||||
<goals>
|
||||
<goal>copy-resources</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<outputDirectory>${basedir}/src/main/java</outputDirectory>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>../../src/examples/src</directory>
|
||||
</resource>
|
||||
</resources>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<!-- clean copied sources afterwards -->
|
||||
<plugin>
|
||||
<artifactId>maven-clean-plugin</artifactId>
|
||||
<version>${maven.plugin.clean.version}</version>
|
||||
<configuration>
|
||||
<filesets>
|
||||
<fileset>
|
||||
<directory>src</directory>
|
||||
<followSymlinks>false</followSymlinks>
|
||||
</fileset>
|
||||
</filesets>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>poi-main</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>poi-ooxml</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
114
log4j/sonar/excelant/pom.xml
Normal file
114
log4j/sonar/excelant/pom.xml
Normal file
@ -0,0 +1,114 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
|
||||
http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi-parent</artifactId>
|
||||
<version>5.0.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>poi-excelant</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>Apache POI ExcelAnt package</name>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<!-- copy sources, resources and tests in place as otherwise Sonar does not pick them up correctly! -->
|
||||
<plugin>
|
||||
<artifactId>maven-resources-plugin</artifactId>
|
||||
<version>${maven.plugin.resources.version}</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>copy-sources</id>
|
||||
<!-- here the phase you need -->
|
||||
<phase>generate-sources</phase>
|
||||
<goals>
|
||||
<goal>copy-resources</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<outputDirectory>${basedir}/src/main/java</outputDirectory>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>../../src/excelant/java</directory>
|
||||
</resource>
|
||||
</resources>
|
||||
</configuration>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>copy-resources</id>
|
||||
<!-- here the phase you need -->
|
||||
<phase>generate-resources</phase>
|
||||
<goals>
|
||||
<goal>copy-resources</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<outputDirectory>${basedir}/src/main/resources</outputDirectory>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>../../src/excelant/resources</directory>
|
||||
</resource>
|
||||
</resources>
|
||||
</configuration>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>copy-tests</id>
|
||||
<!-- here the phase you need -->
|
||||
<phase>generate-test-sources</phase>
|
||||
<goals>
|
||||
<goal>copy-resources</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<outputDirectory>${basedir}/src/test/java</outputDirectory>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>../../src/excelant/testcases</directory>
|
||||
</resource>
|
||||
</resources>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<!-- clean copied sources afterwards -->
|
||||
<plugin>
|
||||
<artifactId>maven-clean-plugin</artifactId>
|
||||
<version>${maven.plugin.clean.version}</version>
|
||||
<configuration>
|
||||
<filesets>
|
||||
<fileset>
|
||||
<directory>src</directory>
|
||||
<followSymlinks>false</followSymlinks>
|
||||
</fileset>
|
||||
</filesets>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>poi-main</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>poi-main</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<type>test-jar</type>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>poi-ooxml</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.ant</groupId>
|
||||
<artifactId>ant</artifactId>
|
||||
<version>1.10.9</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
122
log4j/sonar/integration-test/pom.xml
Normal file
122
log4j/sonar/integration-test/pom.xml
Normal file
@ -0,0 +1,122 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
|
||||
http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi-parent</artifactId>
|
||||
<version>5.0.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>integration-test</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>Apache POI integration test</name>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<!-- copy sources, resources and tests in place as otherwise Sonar does not pick them up correctly! -->
|
||||
<plugin>
|
||||
<artifactId>maven-resources-plugin</artifactId>
|
||||
<!-- <version>${mavnen.plugin.resources.version}</version>-->
|
||||
<executions>
|
||||
<execution>
|
||||
<id>copy-tests</id>
|
||||
<phase>generate-test-sources</phase>
|
||||
<goals>
|
||||
<goal>copy-resources</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<outputDirectory>${basedir}/src/test/java</outputDirectory>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>../../src/integrationtest</directory>
|
||||
</resource>
|
||||
<resource>
|
||||
<directory>../../src/testcases</directory>
|
||||
<includes>
|
||||
<include>org/apache/poi/POIDataSamples.java</include>
|
||||
<include>org/apache/poi/util/NullPrintStream.java</include>
|
||||
<include>org/apache/poi/util/NullOutputStream.java</include>
|
||||
<include>org/apache/poi/hssf/HSSFTestDataSamples.java</include>
|
||||
</includes>
|
||||
</resource>
|
||||
</resources>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
<!-- clean copied sources afterwards -->
|
||||
<plugin>
|
||||
<artifactId>maven-clean-plugin</artifactId>
|
||||
<version>${maven.plugin.clean.version}</version>
|
||||
<configuration>
|
||||
<filesets>
|
||||
<fileset>
|
||||
<directory>src</directory>
|
||||
<followSymlinks>false</followSymlinks>
|
||||
</fileset>
|
||||
<fileset>
|
||||
<directory>build</directory>
|
||||
<followSymlinks>false</followSymlinks>
|
||||
</fileset>
|
||||
</filesets>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
|
||||
<!-- set jvm parameters for surefire plugin -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>${maven.plugin.surefire.version}</version>
|
||||
<configuration>
|
||||
<argLine>@{argLine} -Duser.language=en -Duser.country=US -Xmx1024m -Djava.io.tmpdir=${basedir}/target/tmp -XX:-OmitStackTraceInFastThrow</argLine>
|
||||
<workingDirectory>../..</workingDirectory>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>poi-ooxml</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>poi-scratchpad</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>poi-examples</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.reflections</groupId>
|
||||
<artifactId>reflections</artifactId>
|
||||
<version>0.9.12</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.openjdk.jmh</groupId>
|
||||
<artifactId>jmh-core</artifactId>
|
||||
<version>1.27</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.ant</groupId>
|
||||
<artifactId>ant</artifactId>
|
||||
<version>1.10.9</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
|
||||
|
||||
</dependencies>
|
||||
</project>
|
||||
134
log4j/sonar/main/pom.xml
Normal file
134
log4j/sonar/main/pom.xml
Normal file
@ -0,0 +1,134 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
|
||||
http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi-parent</artifactId>
|
||||
<version>5.0.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>poi-main</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>Apache POI Main package</name>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<!-- copy sources, resources and tests in place as otherwise Sonar does not pick them up correctly! -->
|
||||
<plugin>
|
||||
<artifactId>maven-resources-plugin</artifactId>
|
||||
<version>${maven.plugin.resources.version}</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>copy-sources</id>
|
||||
<phase>generate-sources</phase>
|
||||
<goals>
|
||||
<goal>copy-resources</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<outputDirectory>${basedir}/src/main/java</outputDirectory>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>../../src/java</directory>
|
||||
</resource>
|
||||
</resources>
|
||||
</configuration>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>copy-resources</id>
|
||||
<phase>generate-resources</phase>
|
||||
<goals>
|
||||
<goal>copy-resources</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<outputDirectory>${basedir}/src/main/resources</outputDirectory>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>../../src/resources/main</directory>
|
||||
</resource>
|
||||
</resources>
|
||||
</configuration>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>copy-tests</id>
|
||||
<!-- here the phase you need -->
|
||||
<phase>generate-test-sources</phase>
|
||||
<goals>
|
||||
<goal>copy-resources</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<outputDirectory>${basedir}/src/test/java</outputDirectory>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>../../src/testcases</directory>
|
||||
</resource>
|
||||
</resources>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
<!-- clean copied sources afterwards -->
|
||||
<plugin>
|
||||
<artifactId>maven-clean-plugin</artifactId>
|
||||
<version>${maven.plugin.clean.version}</version>
|
||||
<configuration>
|
||||
<filesets>
|
||||
<fileset>
|
||||
<directory>src</directory>
|
||||
<followSymlinks>false</followSymlinks>
|
||||
</fileset>
|
||||
</filesets>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<!-- provide the test-jar for other modules -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<version>${maven.plugin.jar.version}</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>test-jar</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
<version>1.7.30</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>jcl-over-slf4j</artifactId>
|
||||
<version>1.7.30</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-codec</groupId>
|
||||
<artifactId>commons-codec</artifactId>
|
||||
<version>1.15</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-collections4</artifactId>
|
||||
<version>4.4</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-math3</artifactId>
|
||||
<version>3.6.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.zaxxer</groupId>
|
||||
<artifactId>SparseBitSet</artifactId>
|
||||
<version>1.2</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
156
log4j/sonar/ooxml-full/pom.xml
Normal file
156
log4j/sonar/ooxml-full/pom.xml
Normal file
@ -0,0 +1,156 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
|
||||
http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi-parent</artifactId>
|
||||
<version>5.0.1-SNAPSHOT</version>
|
||||
<relativePath>..</relativePath>
|
||||
</parent>
|
||||
<artifactId>poi-ooxml-lite</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>Apache POI - Openxmlformats Schema package</name>
|
||||
|
||||
<properties>
|
||||
<!-- see http://docs.codehaus.org/display/SONAR/Narrowing+the+Focus for details of this property -->
|
||||
<sonar.exclusions>target/generated-sources/*</sonar.exclusions>
|
||||
<maven.compiler.fork>true</maven.compiler.fork>
|
||||
</properties>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-antrun-plugin</artifactId>
|
||||
<version>${maven.plugin.antrun.version}</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>copy-xmltype-and-xsdconfig</id>
|
||||
<phase>generate-sources</phase>
|
||||
<goals>
|
||||
<goal>run</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<target>
|
||||
<property name="xsdir" value="${basedir}/../../src/ooxml/resources/org/apache/poi"/>
|
||||
<copy todir="${basedir}/target/schemas">
|
||||
<zipfileset src="${xsdir}/schemas/OfficeOpenXML-XMLSchema-Transitional.zip"/>
|
||||
<zipfileset src="${xsdir}/schemas/OpenPackagingConventions-XMLSchema.zip" includes="opc-digSig.xsd,opc-relationships.xsd"/>
|
||||
<fileset dir="${xsdir}/xdgf" includes="*.xsd,*.xsdconfig"/>
|
||||
<fileset dir="${xsdir}/schemas" includes="*.xsd,*.xsdconfig"/>
|
||||
<fileset dir="${xsdir}/poifs/crypt" includes="signatureInfo.xsd"/>
|
||||
</copy>
|
||||
</target>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>exec-maven-plugin</artifactId>
|
||||
<version>3.0.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>process-sources</phase>
|
||||
<goals>
|
||||
<!-- need to use exec instead of java, because SchemaCompiler calls System.exit() -->
|
||||
<goal>exec</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<executable>java</executable>
|
||||
<arguments>
|
||||
<argument>-classpath</argument>
|
||||
<!-- automatically creates the classpath using all project dependencies,
|
||||
also adding the project build directory -->
|
||||
<classpath/>
|
||||
<argument>org.apache.xmlbeans.impl.tool.SchemaCompiler</argument>
|
||||
<argument>-srconly</argument>
|
||||
<argument>-name</argument>
|
||||
<argument>ooxml</argument>
|
||||
<argument>-repackage</argument>
|
||||
<argument>org.apache.xmlbeans.metadata:org.apache.poi.schemas.ooxml</argument>
|
||||
<argument>-d</argument>
|
||||
<argument>${basedir}/target/generated-resources</argument>
|
||||
<argument>-src</argument>
|
||||
<argument>${basedir}/target/generated-sources</argument>
|
||||
<argument>${basedir}/target/schemas</argument>
|
||||
</arguments>
|
||||
<additionalClasspathElements>
|
||||
<additionalClasspathElement>
|
||||
${basedir}/../../lib/ooxml/xmlbeans-4.0.0.jar
|
||||
</additionalClasspathElement>
|
||||
</additionalClasspathElements>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>build-helper-maven-plugin</artifactId>
|
||||
<version>3.2.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>add-source</id>
|
||||
<goals>
|
||||
<goal>add-source</goal>
|
||||
<goal>add-resource</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>${basedir}/target/generated-resources</directory>
|
||||
</resource>
|
||||
<resource>
|
||||
<directory>${basedir}/../../src/multimodule/ooxml-full/java9</directory>
|
||||
<targetPath>META-INF/versions/9</targetPath>
|
||||
<includes>
|
||||
<include>*.class</include>
|
||||
</includes>
|
||||
</resource>
|
||||
</resources>
|
||||
<sources>
|
||||
<source>${basedir}/target/generated-sources</source>
|
||||
</sources>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<version>3.2.0</version>
|
||||
<configuration>
|
||||
<archive>
|
||||
<manifestEntries>
|
||||
<Multi-Release>true</Multi-Release>
|
||||
<Automatic-Module-Name>org.apache.poi.ooxml.schemas</Automatic-Module-Name>
|
||||
</manifestEntries>
|
||||
</archive>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>poi-main</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>poi-scratchpad</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.xmlbeans</groupId>
|
||||
<artifactId>xmlbeans</artifactId>
|
||||
<version>${xmlbeans.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
1
log4j/sonar/ooxml-full/xmlbeans.marker
Normal file
1
log4j/sonar/ooxml-full/xmlbeans.marker
Normal file
@ -0,0 +1 @@
|
||||
This purpose of this marker file is solely to activate the xmlbeans maven profile.
|
||||
199
log4j/sonar/ooxml/pom.xml
Normal file
199
log4j/sonar/ooxml/pom.xml
Normal file
@ -0,0 +1,199 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
|
||||
http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi-parent</artifactId>
|
||||
<version>5.0.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>poi-ooxml</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>Apache POI OOXML package</name>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<!-- copy sources, resources and tests in place as otherwise Sonar does not pick them up correctly! -->
|
||||
<plugin>
|
||||
<artifactId>maven-resources-plugin</artifactId>
|
||||
<version>${maven.plugin.resources.version}</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>copy-sources</id>
|
||||
<phase>generate-sources</phase>
|
||||
<goals>
|
||||
<goal>copy-resources</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<outputDirectory>${basedir}/src/main/java</outputDirectory>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>../../src/ooxml/java</directory>
|
||||
</resource>
|
||||
</resources>
|
||||
</configuration>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>copy-resources</id>
|
||||
<phase>generate-resources</phase>
|
||||
<goals>
|
||||
<goal>copy-resources</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<outputDirectory>${basedir}/src/main/resources</outputDirectory>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>../../src/resources/ooxml</directory>
|
||||
</resource>
|
||||
</resources>
|
||||
</configuration>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>copy-tests</id>
|
||||
<phase>generate-test-sources</phase>
|
||||
<goals>
|
||||
<goal>copy-resources</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<outputDirectory>${basedir}/src/test/java</outputDirectory>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>../../src/ooxml/testcases</directory>
|
||||
</resource>
|
||||
</resources>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
<!-- clean copied sources afterwards -->
|
||||
<plugin>
|
||||
<artifactId>maven-clean-plugin</artifactId>
|
||||
<version>${maven.plugin.clean.version}</version>
|
||||
<configuration>
|
||||
<filesets>
|
||||
<fileset>
|
||||
<directory>src</directory>
|
||||
<followSymlinks>false</followSymlinks>
|
||||
</fileset>
|
||||
<fileset>
|
||||
<directory>build</directory>
|
||||
<followSymlinks>false</followSymlinks>
|
||||
</fileset>
|
||||
</filesets>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<!-- set jvm parameters for surefire plugin -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>${maven.plugin.surefire.version}</version>
|
||||
<configuration>
|
||||
<argLine>@{argLine} -Duser.language=en -Duser.country=US -Xmx1024m
|
||||
-Djava.io.tmpdir=${basedir}/target/tmp -XX:-OmitStackTraceInFastThrow
|
||||
</argLine>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>poi-ooxml-lite</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>poi-main</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>poi-main</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<type>test-jar</type>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.xmlbeans</groupId>
|
||||
<artifactId>xmlbeans</artifactId>
|
||||
<version>${xmlbeans.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.bouncycastle</groupId>
|
||||
<artifactId>bcpkix-jdk15on</artifactId>
|
||||
<version>1.68</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.bouncycastle</groupId>
|
||||
<artifactId>bcprov-jdk15on</artifactId>
|
||||
<version>1.68</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.santuario</groupId>
|
||||
<artifactId>xmlsec</artifactId>
|
||||
<version>2.2.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-compress</artifactId>
|
||||
<version>1.20</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.virtuald</groupId>
|
||||
<artifactId>curvesapi</artifactId>
|
||||
<version>1.06</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.xmlgraphics</groupId>
|
||||
<artifactId>batik-all</artifactId>
|
||||
<version>1.13</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>commons-logging</groupId>
|
||||
<artifactId>commons-logging</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>de.rototor.pdfbox</groupId>
|
||||
<artifactId>graphics2d</artifactId>
|
||||
<version>0.30</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>commons-logging</groupId>
|
||||
<artifactId>commons-logging</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.reflections</groupId>
|
||||
<artifactId>reflections</artifactId>
|
||||
<version>0.9.12</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.openjdk.jmh</groupId>
|
||||
<artifactId>jmh-core</artifactId>
|
||||
<version>1.27</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.openjdk.jmh</groupId>
|
||||
<artifactId>jmh-generator-annprocess</artifactId>
|
||||
<version>1.27</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.guava</groupId>
|
||||
<artifactId>guava</artifactId>
|
||||
<version>30.1-jre</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
222
log4j/sonar/pom.xml
Normal file
222
log4j/sonar/pom.xml
Normal file
@ -0,0 +1,222 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi-parent</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
<version>5.0.1-SNAPSHOT</version>
|
||||
<name>Apache POI - the Java API for Microsoft Documents</name>
|
||||
<description>Maven build of Apache POI for Sonar checks</description>
|
||||
<url>https://poi.apache.org/</url>
|
||||
|
||||
<mailingLists>
|
||||
<mailingList>
|
||||
<name>POI Users List</name>
|
||||
<subscribe>user-subscribe@poi.apache.org</subscribe>
|
||||
<unsubscribe>user-unsubscribe@poi.apache.org</unsubscribe>
|
||||
<archive>http://mail-archives.apache.org/mod_mbox/poi-user/</archive>
|
||||
</mailingList>
|
||||
<mailingList>
|
||||
<name>POI Developer List</name>
|
||||
<subscribe>dev-subscribe@poi.apache.org</subscribe>
|
||||
<unsubscribe>dev-unsubscribe@poi.apache.org</unsubscribe>
|
||||
<archive>http://mail-archives.apache.org/mod_mbox/poi-dev/</archive>
|
||||
</mailingList>
|
||||
</mailingLists>
|
||||
|
||||
<licenses>
|
||||
<license>
|
||||
<name>Apache License, Version 2.0</name>
|
||||
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
|
||||
</license>
|
||||
</licenses>
|
||||
|
||||
<organization>
|
||||
<name>Apache Software Foundation</name>
|
||||
<url>http://www.apache.org/</url>
|
||||
</organization>
|
||||
|
||||
<issueManagement>
|
||||
<system>Bugzilla</system>
|
||||
<url>https://bz.apache.org/bugzilla/</url>
|
||||
</issueManagement>
|
||||
|
||||
<scm>
|
||||
<connection>scm:svn:https://svn.apache.org/repos/asf/poi/trunk</connection>
|
||||
<developerConnection>scm:svn:https://svn.apache.org/repos/asf/poi/trunk</developerConnection>
|
||||
<url>https://svn.apache.org/viewvc/poi</url>
|
||||
</scm>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>apache-releases-repo</id>
|
||||
<name>apache releases repo</name>
|
||||
<url>https://repository.apache.org/content/repositories/releases</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<modules>
|
||||
<module>main</module>
|
||||
<module>ooxml-full</module>
|
||||
<module>ooxml</module>
|
||||
<module>scratchpad</module>
|
||||
<module>excelant</module>
|
||||
<module>examples</module>
|
||||
<module>integration-test</module>
|
||||
</modules>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<!-- Try to disable running SVN blame as it causes errors here because the source is copied from the actual SVN location here! -->
|
||||
<sonar.scm.disabled>true</sonar.scm.disabled>
|
||||
|
||||
<sonar.organization>apache</sonar.organization>
|
||||
<sonar.projectKey>poi-parent</sonar.projectKey>
|
||||
<sonar.moduleKey>${project.artifactId}</sonar.moduleKey>
|
||||
|
||||
<sonar.host.url>https://sonarcloud.io</sonar.host.url>
|
||||
<!-- sonar.jacoco.reportPaths>target/jacoco.exec</sonar.jacoco.reportPaths -->
|
||||
<sonar.coverage.jacoco.xmlReportPaths>target/site/jacoco/jacoco.xml</sonar.coverage.jacoco.xmlReportPaths>
|
||||
|
||||
<!-- define some of the third-party or plugin-versions globally to use the same in all modules -->
|
||||
<xmlbeans.version>4.0.0</xmlbeans.version>
|
||||
<junit.version>5.7.0</junit.version>
|
||||
<xmlunit.version>2.8.2</xmlunit.version>
|
||||
<mockito.version>3.6.28</mockito.version>
|
||||
<maven.plugin.resources.version>3.2.0</maven.plugin.resources.version>
|
||||
<maven.plugin.jar.version>3.2.0</maven.plugin.jar.version>
|
||||
<maven.plugin.clean.version>3.1.0</maven.plugin.clean.version>
|
||||
<maven.plugin.download.version>1.6.0</maven.plugin.download.version>
|
||||
<maven.plugin.antrun.version>3.0.0</maven.plugin.antrun.version>
|
||||
<maven.plugin.surefire.version>3.0.0-M5</maven.plugin.surefire.version>
|
||||
</properties>
|
||||
|
||||
<build>
|
||||
<pluginManagement>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.8.1</version>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</pluginManagement>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>${maven.plugin.surefire.version}</version>
|
||||
<configuration>
|
||||
<printSummary>false</printSummary>
|
||||
<systemPropertyVariables>
|
||||
<POI.testdata.path>../../test-data</POI.testdata.path>
|
||||
<java.awt.headless>true</java.awt.headless>
|
||||
<org.apache.poi.util.POILogger>org.apache.poi.util.NullLogger</org.apache.poi.util.POILogger>
|
||||
</systemPropertyVariables>
|
||||
<!-- use to following to analyze OOM issues: -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/tmp -->
|
||||
<argLine>@{argLine} -Duser.language=en -Duser.country=US -Xmx1024m -Djava.io.tmpdir=${basedir}/target/tmp -XX:-OmitStackTraceInFastThrow</argLine>
|
||||
<excludes>
|
||||
<exclude>**/All*Tests.java</exclude>
|
||||
<exclude>**/TestUnfixedBugs.java</exclude>
|
||||
<exclude>**/TestcaseRecordInputStream.java</exclude>
|
||||
<exclude>**/POITestCase.java</exclude>
|
||||
<!-- TODO: error about no public construct, seems to run with JUnit 3.8... -->
|
||||
<exclude>**/TestWordToConverterSuite*.java</exclude>
|
||||
<exclude>**/TestExcelConverterSuite*.java</exclude>
|
||||
</excludes>
|
||||
<!--test>TestPPTX2PNG</test-->
|
||||
<!--parallel>both</parallel>
|
||||
<threadCount>10</threadCount-->
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.jacoco</groupId>
|
||||
<artifactId>jacoco-maven-plugin</artifactId>
|
||||
<version>0.8.6</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>prepare-agent</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>report</id>
|
||||
<phase>prepare-package</phase>
|
||||
<goals>
|
||||
<goal>report</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter</artifactId>
|
||||
<version>${junit.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.xmlunit</groupId>
|
||||
<artifactId>xmlunit-core</artifactId>
|
||||
<version>${xmlunit.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
<version>${mockito.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.hamcrest</groupId>
|
||||
<artifactId>hamcrest</artifactId>
|
||||
<version>2.2</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<profiles>
|
||||
<!-- We need a fair amount of memory to compile the xml schema, -->
|
||||
<!-- but limit it in case it goes wrong! -->
|
||||
<!-- Pick the right amount based on 32 vs 64 bit jvm -->
|
||||
<!-- ********************************************************** -->
|
||||
<!-- If you are using IntelliJ, you might want to check -->
|
||||
<!-- http://stackoverflow.com/questions/24115142 -->
|
||||
<!-- ********************************************************** -->
|
||||
<profile>
|
||||
<id>32bitstuff</id>
|
||||
<activation>
|
||||
<property>
|
||||
<name>sun.arch.data.model</name>
|
||||
<value>32</value>
|
||||
</property>
|
||||
</activation>
|
||||
<properties>
|
||||
<maven.compiler.maxmem>512m</maven.compiler.maxmem>
|
||||
<argLine>-Xmx768m</argLine>
|
||||
</properties>
|
||||
</profile>
|
||||
|
||||
<profile>
|
||||
<id>64bitstuff</id>
|
||||
<activation>
|
||||
<property>
|
||||
<name>sun.arch.data.model</name>
|
||||
<value>64</value>
|
||||
</property>
|
||||
</activation>
|
||||
<properties>
|
||||
<maven.compiler.maxmem>768m</maven.compiler.maxmem>
|
||||
<argLine>-Xmx1024m</argLine>
|
||||
</properties>
|
||||
</profile>
|
||||
|
||||
</profiles>
|
||||
</project>
|
||||
109
log4j/sonar/scratchpad/pom.xml
Normal file
109
log4j/sonar/scratchpad/pom.xml
Normal file
@ -0,0 +1,109 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
|
||||
http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi-parent</artifactId>
|
||||
<version>5.0.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>poi-scratchpad</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>Apache POI Scratchpad package</name>
|
||||
|
||||
<properties>
|
||||
<!-- Exclude some generated code from Sonar analysis -->
|
||||
<sonar.exclusions>src/main/java/org/apache/poi/hwpf/model/types/*,src/main/java/org/apache/poi/hdf/model/hdftypes/definitions/*</sonar.exclusions>
|
||||
</properties>
|
||||
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<!-- copy sources, resources and tests in place as otherwise Sonar does not pick them up correctly! -->
|
||||
<plugin>
|
||||
<artifactId>maven-resources-plugin</artifactId>
|
||||
<version>${maven.plugin.resources.version}</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>copy-sources</id>
|
||||
<!-- here the phase you need -->
|
||||
<phase>generate-sources</phase>
|
||||
<goals>
|
||||
<goal>copy-resources</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<outputDirectory>${basedir}/src/main/java</outputDirectory>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>../../src/scratchpad/src</directory>
|
||||
</resource>
|
||||
</resources>
|
||||
</configuration>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>copy-resources</id>
|
||||
<!-- here the phase you need -->
|
||||
<phase>generate-resources</phase>
|
||||
<goals>
|
||||
<goal>copy-resources</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<outputDirectory>${basedir}/src/main/resources</outputDirectory>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>../../src/resources/scratchpad</directory>
|
||||
</resource>
|
||||
</resources>
|
||||
</configuration>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>copy-tests</id>
|
||||
<!-- here the phase you need -->
|
||||
<phase>generate-test-sources</phase>
|
||||
<goals>
|
||||
<goal>copy-resources</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<outputDirectory>${basedir}/src/test/java</outputDirectory>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>../../src/scratchpad/testcases</directory>
|
||||
</resource>
|
||||
</resources>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<!-- clean copied sources afterwards -->
|
||||
<plugin>
|
||||
<artifactId>maven-clean-plugin</artifactId>
|
||||
<version>${maven.plugin.clean.version}</version>
|
||||
<configuration>
|
||||
<filesets>
|
||||
<fileset>
|
||||
<directory>src</directory>
|
||||
<followSymlinks>false</followSymlinks>
|
||||
</fileset>
|
||||
</filesets>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>poi-main</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>poi-main</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<type>test-jar</type>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
332
log4j/src/contrib/poi-ruby/Makefile
Normal file
332
log4j/src/contrib/poi-ruby/Makefile
Normal file
@ -0,0 +1,332 @@
|
||||
# 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.
|
||||
|
||||
|
||||
# Makefile for building Poi4R
|
||||
#
|
||||
# Supported operating systems: Linux, Mac OS X and Windows.
|
||||
# See INSTALL file for requirements.
|
||||
#
|
||||
# Steps to build
|
||||
# 1. Edit the sections below as documented
|
||||
# 2. make all
|
||||
# 3. make install
|
||||
#
|
||||
# The install target installs the Poi4R python extension in python's
|
||||
# site-packages directory. On Mac OS X, it also installs the gcj runtime
|
||||
# libraries into $(PREFIX)/lib.
|
||||
#
|
||||
# To successfully import the Poi4R extension into Ruby, all required
|
||||
# libraries need to be found. If the locations you chose are non-standard,
|
||||
# the relevant DYLD_LIBRARY_PATH (Mac OS X), LD_LIBRARY_PATH (Linux), or
|
||||
# PATH (Windows) need to be set accordingly.
|
||||
#
|
||||
|
||||
|
||||
VERSION=0.1.0
|
||||
POI_VER=$(shell grep '<property name="version.id"' ../../../build.xml | awk -F'"' '{print $$4}')
|
||||
RUBY_VER=1.8
|
||||
|
||||
POI4R:=$(shell pwd)
|
||||
POI=$(POI4R)/poi-$(POI_VER)
|
||||
#DEBUG=1
|
||||
|
||||
#
|
||||
# You need to uncomment and edit the variables below in the section
|
||||
# corresponding to your operating system.
|
||||
#
|
||||
# PREFIX: where programs are normally installed on your system (Unix).
|
||||
# PREFIX_RUBY: where your version of python is installed.
|
||||
# GCJ_HOME: where GCC/GCJ is installed.
|
||||
# Windows drive-absolute paths need to be expressed cygwin style.
|
||||
#
|
||||
|
||||
# Mac OS X (Darwin)
|
||||
#PREFIX=/usr/local
|
||||
#PREFIX_RUBY=/Library/Frameworks/Ruby.framework/Versions/$(RUBY_VER)
|
||||
#SWIG=$(PREFIX)/bin/swig
|
||||
#GCJ_HOME=/usr/local/gcc-3.4.1
|
||||
#DB=$(POI4R)/db-$(DB_VER)
|
||||
#PREFIX_DB=/usr/local/BerkeleyDB.$(DB_LIB_VER)
|
||||
|
||||
# Linux
|
||||
PREFIX=/usr
|
||||
PREFIX_RUBY=$(PREFIX)
|
||||
SWIG=$(PREFIX)/bin/swig
|
||||
GCJ_HOME=/usr
|
||||
#DB=$(POI4R)/db-$(DB_VER)
|
||||
#PREFIX_DB=$(PREFIX)/BerkeleyDB.$(DB_LIB_VER)
|
||||
|
||||
# Windows
|
||||
#PREFIX_RUBY=/cygdrive/o/Python-2.3.2
|
||||
#SWIG=/cygdrive/c/utils/bin/swig.exe
|
||||
#GCJ_HOME=/cygdrive/o/mingw-3.1
|
||||
#DB=/cygdrive/o/db-$(DB_VER)
|
||||
#PREFIX_DB=$(DB)
|
||||
|
||||
#
|
||||
# No edits required below
|
||||
#
|
||||
|
||||
OS=$(shell uname)
|
||||
ifeq ($(findstring CYGWIN,$(OS)),CYGWIN)
|
||||
OS=Cygwin
|
||||
endif
|
||||
ifeq ($(findstring WINNT,$(OS)),WINNT)
|
||||
OS=Cygwin
|
||||
endif
|
||||
|
||||
ifeq ($(DEBUG),1)
|
||||
COMP_OPT=DEBUG=1
|
||||
SUFFIX=d
|
||||
_SUFFIX=_d
|
||||
BINDIR=debug
|
||||
else
|
||||
COMP_OPT=
|
||||
SUFFIX=
|
||||
_SUFFIX=
|
||||
BINDIR=release
|
||||
endif
|
||||
|
||||
SWIG_OPT=-DSWIG_COBJECT_TYPES -DPOI4R_VER="'$(VERSION)'" -DPOI_VER="'$(POI_VER)'"
|
||||
|
||||
JCCFLAGS=--encoding=UTF-8
|
||||
#JCCFLAGS=--encoding=UTF-8 -findirect-dispatch
|
||||
|
||||
ifeq ($(OS),Darwin)
|
||||
RUBY_SITE=$(PREFIX_RUBY)/lib/ruby$(RUBY_VER)/site-packages
|
||||
RUBY_INC=$(PREFIX_RUBY)/lib/ruby$(RUBY_VER)
|
||||
POI4R=$(BINDIR)/poi4r.so
|
||||
ifeq ($(DEBUG),1)
|
||||
CCFLAGS=-O0 -g
|
||||
LDFLAGS=-g
|
||||
else
|
||||
CCFLAGS=-O2
|
||||
LDFLAGS=
|
||||
endif
|
||||
else
|
||||
|
||||
ifeq ($(OS),Linux)
|
||||
RUBY_SITE=$(PREFIX_RUBY)/lib/ruby/site-ruby/$(RUBY_VER)/
|
||||
RUBY_INC=$(PREFIX_RUBY)/lib/ruby/$(RUBY_VER)/i686-linux
|
||||
POI4R_LIB=$(BINDIR)/poi4r.so
|
||||
ifeq ($(DEBUG),1)
|
||||
CCFLAGS=-O0 -g -fPIC
|
||||
LDFLAGS=-g
|
||||
else
|
||||
CCFLAGS=-O2 -fPIC
|
||||
LDFLAGS=
|
||||
endif
|
||||
else
|
||||
|
||||
ifeq ($(OS),Cygwin)
|
||||
RUBY_SITE=`cygpath -aw $(PREFIX_RUBY)/Lib/site-packages`
|
||||
RUBY_INC=`cygpath -aw $(PREFIX_RUBY)/Include`
|
||||
RUBY_PC=`cygpath -aw $(PREFIX_RUBY)/PC`
|
||||
POI4R_LIB=$(BINDIR)/poi4r$(_SUFFIX).so
|
||||
ifeq ($(DEBUG),1)
|
||||
CCFLAGS=-O -g
|
||||
LDFLAGS=-g
|
||||
else
|
||||
CCFLAGS=-O2
|
||||
LDFLAGS=
|
||||
endif
|
||||
else
|
||||
|
||||
RUBY=unknown
|
||||
RUBY_SITE=unknown
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
CLASSES=$(BINDIR)/classes
|
||||
JAR_CLASSES=$(CLASSES)/jar
|
||||
|
||||
CC=$(GCJ_HOME)/bin/gcc
|
||||
CXX=$(GCJ_HOME)/bin/g++
|
||||
JCC=$(GCJ_HOME)/bin/gcj
|
||||
JCCH=$(GCJ_HOME)/bin/gcjh
|
||||
JAR=$(GCJ_HOME)/bin/jar
|
||||
POI_ZIP=poi-$(POI_VER).jar
|
||||
POI_JAR=poi-$(POI_VER).jar
|
||||
POI_JAR_WC=poi-$(POI_VER)-*.jar
|
||||
|
||||
POI4R_CP:=$(BINDIR)/$(POI_JAR):$(CLASSES)
|
||||
|
||||
OBJS=$(BINDIR)/poi.o $(BINDIR)/io.java.o $(BINDIR)/io.cpp.o
|
||||
|
||||
LIBS=$(POI4R_LIB)
|
||||
|
||||
default: all
|
||||
|
||||
patches:
|
||||
|
||||
|
||||
env:
|
||||
ifndef PREFIX_RUBY
|
||||
@echo Operating system is $(OS)
|
||||
@echo You need to edit that section of the Makefile
|
||||
@false
|
||||
else
|
||||
@true
|
||||
endif
|
||||
|
||||
|
||||
$(BINDIR):
|
||||
mkdir -p $(BINDIR)/classes/jar
|
||||
|
||||
|
||||
DISTRIB=Poi-$(VERSION)
|
||||
|
||||
ifeq ($(OS),Cygwin)
|
||||
POI4R_CP:=`cygpath -awp $(POI4R_CP)`
|
||||
endif
|
||||
|
||||
|
||||
ifeq ($(OS),Cygwin)
|
||||
_poi=`cygpath -aw $(POI)`
|
||||
else
|
||||
_poi=$(POI)
|
||||
endif
|
||||
|
||||
$(BINDIR)/$(POI_JAR):
|
||||
cp ../../../build/dist/$(POI_JAR_WC) $(BINDIR)/$(POI_JAR)
|
||||
cd $(JAR_CLASSES); $(JAR) -xf ../../$(POI_JAR)
|
||||
|
||||
$(BINDIR)/io.java.o: java/org/apache/poi/RubyOutputStream.java
|
||||
$(JCC) $(JCCFLAGS) -C -d $(CLASSES) java/org/apache/poi/RubyOutputStream.java
|
||||
$(JCC) $(JCCFLAGS) $(CCFLAGS) -I$(GCJ_HOME)/include -c -o $@ java/org/apache/poi/RubyOutputStream.java
|
||||
|
||||
$(CLASSES)/org/apache/poi/RubyOutputStream.h: $(BINDIR)/io.java.o Makefile
|
||||
mkdir -p $(CLASSES)/org/apache/poi/hssf/usermodel
|
||||
$(JCCH) -d $(CLASSES) --classpath=$(JAR_CLASSES) org.apache.poi.hssf.usermodel.HSSFWorkbook
|
||||
$(JCCH) -d $(CLASSES) --classpath=$(JAR_CLASSES) org.apache.poi.hssf.usermodel.HSSFSheet
|
||||
$(JCCH) -d $(CLASSES) --classpath=$(JAR_CLASSES) org.apache.poi.hssf.usermodel.HSSFRow
|
||||
$(JCCH) -d $(CLASSES) --classpath=$(JAR_CLASSES) org.apache.poi.hssf.usermodel.HSSFCell
|
||||
$(JCCH) -d $(CLASSES) --classpath=$(JAR_CLASSES) org.apache.poi.hssf.usermodel.HSSFHeader
|
||||
$(JCCH) -d $(CLASSES) --classpath=$(JAR_CLASSES) org.apache.poi.hssf.usermodel.HSSFFooter
|
||||
$(JCCH) -d $(CLASSES) --classpath=$(JAR_CLASSES) org.apache.poi.hssf.usermodel.HSSFFont
|
||||
$(JCCH) -d $(CLASSES) --classpath=$(JAR_CLASSES) org.apache.poi.hssf.usermodel.HSSFDataFormat
|
||||
$(JCCH) -d $(CLASSES) --classpath=$(JAR_CLASSES) org.apache.poi.hssf.usermodel.HSSFCellStyle
|
||||
$(JCCH) -d $(CLASSES) --classpath=$(CLASSES) org.apache.poi.RubyOutputStream
|
||||
|
||||
|
||||
$(BINDIR)/io.cpp.o: $(CLASSES)/org/apache/poi/RubyOutputStream.h cpp/RubyIO.cpp $(BINDIR)/io.java.o
|
||||
$(JCC) -I$(RUBY_INC) -I$(GCJ_HOME)/include -I$(CLASSES) $(CCFLAGS) -c -o $@ cpp/RubyIO.cpp
|
||||
|
||||
$(BINDIR)/poi.o: $(BINDIR)/$(POI_JAR)
|
||||
$(JCC) $(JCCFLAGS) $(CCFLAGS) -c -o $@ $(BINDIR)/$(POI_JAR)
|
||||
|
||||
Poi4R_wrap.cxx: $(BINDIR)/io.cpp.o Poi4R.i
|
||||
ifdef SWIG
|
||||
$(SWIG) $(SWIG_OPT) -I$(CLASSES) -c++ -ruby Poi4R.i
|
||||
endif
|
||||
|
||||
|
||||
ifeq ($(OS),Darwin)
|
||||
$(POI4R_LIB): $(OBJS) Poi4R_wrap.cxx
|
||||
$(CXX) -shared -bundle -o $@ $(CCFLAGS) $(SWIG_OPT) $(DB_INC) -I$(GCJ_HOME)/include -I$(CLASSES) -I$(RUBY_INC) Poi4R_wrap.cxx $(OBJS) -L$(GCJ_HOME)/lib -lgcj -liconv -undefined suppress -flat_namespace -multiply_defined suppress
|
||||
else
|
||||
|
||||
ifeq ($(OS),Linux)
|
||||
$(POI4R_LIB): $(OBJS) Poi4R_wrap.cxx
|
||||
$(CXX) -shared -o $@ $(CCFLAGS) $(SWIG_OPT) $(DB_INC) -I$(CLASSES) -I$(RUBY_INC) Poi4R_wrap.cxx $(OBJS) -lgcj
|
||||
else
|
||||
|
||||
ifeq ($(OS),Cygwin)
|
||||
$(POI4R_LIB): $(OBJS) Poi4R_wrap.cxx
|
||||
$(CXX) -c $(CCFLAGS) $(PYDBG) -D_NO_OLDNAMES -D_off_t=off_t $(SWIG_OPT) $(DB_INC) -I$(CLASSES) -I$(RUBY_PC) -I$(RUBY_INC) -o $(BINDIR)/Poi4R_wrap.o Poi4R_wrap.cxx
|
||||
$(CXX) -shared $(LDFLAGS) -o $@ $(OBJS) `cygpath -aw $(PREFIX_RUBY)/python23$(_SUFFIX).dll` $(BINDIR)/Poi4R_wrap.o -lgcj -lwin32k -lws2_32
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
|
||||
all: env $(BINDIR) $(LIBS)
|
||||
@echo build of $(POI4R_LIB) complete
|
||||
|
||||
install:: all
|
||||
install Poi4R.rb $(RUBY_SITE)
|
||||
install $(POI4R_LIB) $(RUBY_SITE)
|
||||
|
||||
ifeq ($(OS),Darwin)
|
||||
install::
|
||||
install $(GCJ_HOME)/lib/libgcj.5.dylib $(PREFIX)/lib
|
||||
install $(GCJ_HOME)/lib/libstdc++.6.dylib $(PREFIX)/lib
|
||||
install $(GCJ_HOME)/lib/libgcc_s.1.0.dylib $(PREFIX)/lib
|
||||
else
|
||||
|
||||
ifeq ($(OS),Linux)
|
||||
install::
|
||||
|
||||
else
|
||||
|
||||
ifeq ($(OS),Cygwin)
|
||||
install::
|
||||
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
|
||||
clean:
|
||||
rm -rf $(BINDIR) Poi4R.rb* Poi4R_wrap.cxx
|
||||
|
||||
realclean: clean
|
||||
rm -rf $(POI) $(STORE) $(DISTRIB)
|
||||
|
||||
distrib::
|
||||
mkdir -p $(DISTRIB)/python
|
||||
install Poi4R.rb $(DISTRIB)/python
|
||||
install $(POI4R_LIB) $(DISTRIB)/python
|
||||
install README $(DISTRIB)
|
||||
|
||||
ifeq ($(OS),Darwin)
|
||||
distrib::
|
||||
ifdef DB
|
||||
mkdir -p $(DISTRIB)/db
|
||||
install $(LIBDB_JAVA_LIB) $(DISTRIB)/db
|
||||
install libdb_java-$(DB_LIB_VER).la.osx $(DISTRIB)/db
|
||||
endif
|
||||
mkdir -p $(DISTRIB)/gcj
|
||||
install $(GCJ_HOME)/lib/libgcj.5.dylib $(DISTRIB)/gcj
|
||||
install $(GCJ_HOME)/lib/libstdc++.6.dylib $(DISTRIB)/gcj
|
||||
install $(GCJ_HOME)/lib/libgcc_s.1.0.dylib $(DISTRIB)/gcj
|
||||
else
|
||||
|
||||
ifeq ($(OS),Linux)
|
||||
distrib::
|
||||
ifdef DB
|
||||
mkdir -p $(DISTRIB)/db
|
||||
install $(LIBDB_JAVA_LIB) $(DISTRIB)/db
|
||||
endif
|
||||
mkdir -p $(DISTRIB)/gcj
|
||||
install $(GCJ_HOME)/lib/libgcj.so.5 $(DISTRIB)/gcj
|
||||
install $(GCJ_HOME)/lib/libstdc++.so.6 $(DISTRIB)/gcj
|
||||
install $(GCJ_HOME)/lib/libgcc_s.so.1 $(DISTRIB)/gcj
|
||||
else
|
||||
|
||||
ifeq ($(OS),Cygwin)
|
||||
distrib::
|
||||
ifdef DB
|
||||
mkdir -p $(DISTRIB)/db
|
||||
install $(LIBDB_JAVA_LIB) $(DISTRIB)/db
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
614
log4j/src/contrib/poi-ruby/Poi4R.i
Normal file
614
log4j/src/contrib/poi-ruby/Poi4R.i
Normal file
@ -0,0 +1,614 @@
|
||||
/* ====================================================================
|
||||
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.
|
||||
==================================================================== */
|
||||
|
||||
%module poi4r
|
||||
|
||||
|
||||
%{
|
||||
|
||||
#include <gcj/cni.h>
|
||||
#include <java/lang/Object.h>
|
||||
#include <java/lang/Thread.h>
|
||||
#include <java/lang/ThreadGroup.h>
|
||||
#include <java/lang/Runnable.h>
|
||||
#include <java/lang/String.h>
|
||||
#include <java/lang/Throwable.h>
|
||||
#include <java/lang/Comparable.h>
|
||||
#include <java/lang/Integer.h>
|
||||
#include <java/lang/Long.h>
|
||||
#include <java/lang/Float.h>
|
||||
#include <java/lang/Double.h>
|
||||
#include <java/io/StringWriter.h>
|
||||
#include <java/io/PrintWriter.h>
|
||||
#include <java/util/HashMap.h>
|
||||
#include <java/util/Date.h>
|
||||
#include <java/util/Calendar.h>
|
||||
#include <java/lang/System.h>
|
||||
|
||||
#include "org/apache/poi/hssf/usermodel/HSSFWorkbook.h"
|
||||
#include "org/apache/poi/hssf/usermodel/HSSFSheet.h"
|
||||
#include "org/apache/poi/hssf/usermodel/HSSFRow.h"
|
||||
#include "org/apache/poi/hssf/usermodel/HSSFCell.h"
|
||||
#include "org/apache/poi/hssf/usermodel/HSSFFont.h"
|
||||
#include "org/apache/poi/hssf/usermodel/HSSFCellStyle.h"
|
||||
#include "org/apache/poi/hssf/usermodel/HSSFDataFormat.h"
|
||||
#include "org/apache/poi/hssf/usermodel/HSSFHeader.h"
|
||||
#include "org/apache/poi/hssf/usermodel/HSSFFooter.h"
|
||||
#include "org/apache/poi/RubyOutputStream.h"
|
||||
|
||||
|
||||
typedef ::org::apache::poi::hssf::usermodel::HSSFWorkbook *jhworkbook;
|
||||
typedef ::org::apache::poi::hssf::usermodel::HSSFSheet *jhsheet;
|
||||
typedef ::org::apache::poi::hssf::usermodel::HSSFRow *jhrow;
|
||||
typedef ::org::apache::poi::hssf::usermodel::HSSFCell *jhcell;
|
||||
typedef ::org::apache::poi::hssf::usermodel::HSSFCellStyle *jhcellstyle;
|
||||
typedef ::org::apache::poi::hssf::usermodel::HSSFFont *jhfont;
|
||||
typedef ::org::apache::poi::hssf::usermodel::HSSFFooter *jhfooter;
|
||||
typedef ::org::apache::poi::hssf::usermodel::HSSFHeader *jhheader;
|
||||
typedef ::org::apache::poi::hssf::usermodel::HSSFDataFormat *jhdataformat;
|
||||
|
||||
typedef ::java::util::Date *jdate;
|
||||
typedef ::java::util::Calendar *jcalendar;
|
||||
typedef ::java::io::OutputStream *joutputstream;
|
||||
typedef ::java::io::InputStream *jinputstream;
|
||||
typedef ::java::util::Collection *jstringCollection;
|
||||
typedef ::java::util::Collection *jtermCollection;
|
||||
typedef ::java::util::Locale *jlocale;
|
||||
typedef ::java::lang::Comparable *jcomparable;
|
||||
typedef JArray<jobject> *jobjectArray;
|
||||
typedef JArray<jstring> *jstringArray;
|
||||
|
||||
|
||||
static java::lang::Thread *nextThread;
|
||||
static java::util::HashMap *objects;
|
||||
|
||||
|
||||
static void store_reference(jobject object) {
|
||||
java::lang::Integer *ji =new java::lang::Integer(java::lang::System::identityHashCode(object));
|
||||
jobject jo = objects->get(ji);
|
||||
if (!jo) {
|
||||
// printf("put object in hash\n");
|
||||
objects->put(ji,object);
|
||||
}
|
||||
}
|
||||
static VALUE jo2rv(jobject object, swig_type_info *descriptor)
|
||||
{
|
||||
if (object == NULL)
|
||||
{
|
||||
return Qnil;
|
||||
}
|
||||
else
|
||||
{
|
||||
return SWIG_NewPointerObj((void *) object, descriptor, 0);
|
||||
}
|
||||
}
|
||||
static int cvtptr(VALUE value, void **jo, swig_type_info *info)
|
||||
{
|
||||
if (SWIG_ConvertPtr(value, jo, info, 0) == 0)
|
||||
return 0;
|
||||
else
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
static int rv2jo(VALUE rv, jobject *jo, swig_type_info *descriptor)
|
||||
{
|
||||
if (NIL_P(rv))
|
||||
*jo = NULL;
|
||||
else
|
||||
{
|
||||
java::lang::Object *javaObj;
|
||||
|
||||
if (cvtptr(rv, (void **) &javaObj, descriptor) == -1)
|
||||
return 0;
|
||||
|
||||
*jo = javaObj;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
static jstring r2j(VALUE object)
|
||||
{
|
||||
if (NIL_P(object)){
|
||||
return NULL;
|
||||
}
|
||||
else {
|
||||
char *ps = STR2CSTR(object);
|
||||
jstring js = JvNewStringLatin1(ps);
|
||||
|
||||
if (!js)
|
||||
{
|
||||
rb_raise(rb_eRuntimeError, "ruby str cannot be converted to java: %s",ps);
|
||||
}
|
||||
|
||||
return js;
|
||||
}
|
||||
}
|
||||
|
||||
VALUE j2r(jstring js)
|
||||
{
|
||||
if (!js)
|
||||
{
|
||||
return Qnil;
|
||||
}
|
||||
else
|
||||
{
|
||||
jint len = JvGetStringUTFLength(js);
|
||||
char buf[len + 1];
|
||||
|
||||
JvGetStringUTFRegion(js, 0, len, buf);
|
||||
buf[len] = '\0';
|
||||
|
||||
return rb_str_new2(buf);
|
||||
}
|
||||
}
|
||||
|
||||
static void free_java_obj(void* arg1) {
|
||||
jobject object =(jobject) arg1;
|
||||
java::lang::Integer *ji =new java::lang::Integer(java::lang::System::identityHashCode(object));
|
||||
jobject jo = objects->get(ji);
|
||||
if (jo) {
|
||||
// printf("removed object from hash\n");
|
||||
objects->remove(ji);
|
||||
}
|
||||
}
|
||||
|
||||
static void raise_ruby_error(java::lang::Throwable *e) {
|
||||
java::io::StringWriter *buffer = new java::io::StringWriter();
|
||||
java::io::PrintWriter *writer = new java::io::PrintWriter(buffer);
|
||||
e->printStackTrace(writer);
|
||||
writer->close();
|
||||
jstring message = buffer->toString();
|
||||
jint len = JvGetStringUTFLength(message);
|
||||
char buf[len + 1];
|
||||
JvGetStringUTFRegion(message, 0, len, buf);
|
||||
buf[len] = '\0';
|
||||
rb_raise(rb_eRuntimeError, "error calling poi \n %s", buf);
|
||||
}
|
||||
|
||||
%}
|
||||
|
||||
typedef long jint;
|
||||
typedef long long jlong;
|
||||
typedef char jbyte;
|
||||
typedef float jfloat;
|
||||
typedef float jdouble;
|
||||
typedef int jshort;
|
||||
typedef bool jboolean;
|
||||
|
||||
%typemap(in) SWIGTYPE * {
|
||||
|
||||
if (!rv2jo($input, (jobject *) &$1, $1_descriptor))
|
||||
rb_raise(rb_eRuntimeError, "Unrecoverable error in SWIG typemapping");
|
||||
}
|
||||
%typemap(out) SWIGTYPE * {
|
||||
|
||||
$result = jo2rv($1, $1_descriptor);
|
||||
}
|
||||
|
||||
%typemap(in) org::apache::poi::hssf::usermodel::HSSFWorkbook{
|
||||
|
||||
if (!rv2jo($input, (jobject *) &$1,
|
||||
$descriptor(org::apache::poi::hssf::usermodel::HSSFWorkbook *)))
|
||||
SWIG_fail;
|
||||
}
|
||||
%typemap(out) org::apache::poi::hssf::usermodel::HSSFWorkbook {
|
||||
$result = jo2rv($1, $descriptor(org::apache::poi::hssf::usermodel::HSSFWorkbook *));
|
||||
}
|
||||
|
||||
%typemap(in) jhsheet{
|
||||
|
||||
if (!rv2jo($input, (jobject *) &$1,
|
||||
$descriptor(org::apache::poi::hssf::usermodel::HSSFSheet *)))
|
||||
SWIG_fail;
|
||||
}
|
||||
%typemap(out) jhsheet {
|
||||
|
||||
$result = jo2rv($1, $descriptor(org::apache::poi::hssf::usermodel::HSSFSheet *));
|
||||
}
|
||||
%typemap(in) jhrow{
|
||||
|
||||
if (!rv2jo($input, (jobject *) &$1,
|
||||
$descriptor(org::apache::poi::hssf::usermodel::HSSFRow *)))
|
||||
SWIG_fail;
|
||||
}
|
||||
%typemap(out) jhrow {
|
||||
|
||||
$result = jo2rv($1, $descriptor(org::apache::poi::hssf::usermodel::HSSFRow *));
|
||||
}
|
||||
%typemap(in) jhcell{
|
||||
|
||||
if (!rv2jo($input, (jobject *) &$1,
|
||||
$descriptor(org::apache::poi::hssf::usermodel::HSSFCell *)))
|
||||
SWIG_fail;
|
||||
}
|
||||
%typemap(out) jhcell {
|
||||
|
||||
$result = jo2rv($1, $descriptor(org::apache::poi::hssf::usermodel::HSSFCell *));
|
||||
}
|
||||
%typemap(in) jhfont{
|
||||
|
||||
if (!rv2jo($input, (jobject *) &$1,
|
||||
$descriptor(org::apache::poi::hssf::usermodel::HSSFFont *)))
|
||||
rb_raise(rb_eRuntimeError, "Unrecoverable error in SWIG typemapping of HSSFFont");
|
||||
}
|
||||
|
||||
%typemap(out) jhfont {
|
||||
|
||||
$result = jo2rv($1, $descriptor(org::apache::poi::hssf::usermodel::HSSFFont *));
|
||||
}
|
||||
|
||||
%typemap(in) jhcellstyle{
|
||||
|
||||
if (!rv2jo($input, (jobject *) &$1,
|
||||
$descriptor(org::apache::poi::hssf::usermodel::HSSFCellStyle *)))
|
||||
rb_raise(rb_eRuntimeError, "Unrecoverable error in SWIG typemapping of HSSFCellStyle");
|
||||
}
|
||||
%typemap(out) jhcellstyle {
|
||||
|
||||
$result = jo2rv($1, $descriptor(org::apache::poi::hssf::usermodel::HSSFCellStyle *));
|
||||
}
|
||||
%typemap(in) jhdataformat{
|
||||
|
||||
if (!rv2jo($input, (jobject *) &$1,
|
||||
$descriptor(org::apache::poi::hssf::usermodel::HSSFDataFormat *)))
|
||||
rb_raise(rb_eRuntimeError, "Unrecoverable error in SWIG typemapping of HSSFDataFormat");
|
||||
}
|
||||
%typemap(out) jhdataformat {
|
||||
|
||||
$result = jo2rv($1, $descriptor(org::apache::poi::hssf::usermodel::HSSFDataFormat *));
|
||||
}
|
||||
|
||||
|
||||
%typemap(in) jstring {
|
||||
$1 = r2j($input);
|
||||
}
|
||||
%typemap(out) jstring {
|
||||
$result = j2r($1);
|
||||
}
|
||||
%typecheck(SWIG_TYPECHECK_STRING) jstring {
|
||||
$1 = ( NIL_P($input) || TYPE($input)==T_STRING );
|
||||
}
|
||||
|
||||
%typemap(in) joutputstream {
|
||||
|
||||
jlong ptr;
|
||||
if (!rb_respond_to($input, rb_intern("putc"))) rb_raise(rb_eTypeError,"Expected IO");
|
||||
*(VALUE *) &ptr = (VALUE) $input;
|
||||
$1 = new org::apache::poi::RubyOutputStream(ptr);
|
||||
}
|
||||
%typemap(in) jcalendar {
|
||||
$1 = java::util::Calendar::getInstance();
|
||||
//$1->setTimeInMillis((long long) NUM2DBL(rb_funcall($input,rb_intern("to_i"),0,NULL))*1000.0);
|
||||
$1->set(FIX2INT(rb_funcall($input,rb_intern("year"),0,NULL)),
|
||||
FIX2INT(rb_funcall($input,rb_intern("mon"),0,NULL))-1,
|
||||
FIX2INT(rb_funcall($input,rb_intern("day"),0,NULL)),
|
||||
FIX2INT(rb_funcall($input,rb_intern("hour"),0,NULL)),
|
||||
FIX2INT(rb_funcall($input,rb_intern("min"),0,NULL)),
|
||||
FIX2INT(rb_funcall($input,rb_intern("sec"),0,NULL))
|
||||
);
|
||||
}
|
||||
|
||||
%typecheck(SWIG_TYPECHECK_POINTER) jcalendar {
|
||||
$1 = rb_respond_to($input, rb_intern("asctime"));
|
||||
}
|
||||
|
||||
%typemap(out) jdate {
|
||||
jlong t = ((jdate) $1)->getTime();
|
||||
//TODO: separate seconds and microsecs
|
||||
int ts=t/1000;
|
||||
$result=rb_time_new((time_t) ts, 0 );
|
||||
}
|
||||
|
||||
|
||||
%freefunc org::apache::poi::hssf::usermodel::HSSFWorkbook "free_java_obj";
|
||||
|
||||
%exception {
|
||||
try {
|
||||
$action
|
||||
} catch (java::lang::Throwable *e) {
|
||||
raise_ruby_error(e);
|
||||
}
|
||||
}
|
||||
%exception org::apache::poi::hssf::usermodel::HSSFWorkbook::HSSFWorkbook {
|
||||
try {
|
||||
$action
|
||||
store_reference(result);
|
||||
} catch (java::lang::Throwable *e) {
|
||||
raise_ruby_error(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
namespace java {
|
||||
namespace lang {
|
||||
class Object {
|
||||
jstring toString();
|
||||
};
|
||||
%nodefault;
|
||||
class System : public Object {
|
||||
public:
|
||||
static jstring getProperty(jstring);
|
||||
static jstring getProperty(jstring, jstring);
|
||||
static void load(jstring);
|
||||
static void loadLibrary(jstring);
|
||||
static void mapLibraryName(jstring);
|
||||
static void runFinalization();
|
||||
static void setProperty(jstring, jstring);
|
||||
};
|
||||
%makedefault;
|
||||
}
|
||||
namespace io {
|
||||
%nodefault;
|
||||
class InputStream : public ::java::lang::Object {
|
||||
};
|
||||
class OutputStream : public ::java::lang::Object {
|
||||
};
|
||||
|
||||
%makedefault;
|
||||
}
|
||||
namespace util {
|
||||
class Date : public ::java::lang::Object {
|
||||
public:
|
||||
Date();
|
||||
Date(jlong);
|
||||
void setTime(jlong);
|
||||
jstring toString();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
namespace org {
|
||||
namespace apache {
|
||||
namespace poi {
|
||||
namespace hssf {
|
||||
namespace usermodel {
|
||||
%nodefault;
|
||||
class HSSFWorkbook : public ::java::lang::Object {
|
||||
public:
|
||||
HSSFWorkbook();
|
||||
jstring getSheetName(jint);
|
||||
jint getNumberOfSheets();
|
||||
void setSheetOrder(jstring,jint);
|
||||
void setSheetName(jint,jstring);
|
||||
void setSheetName(jint,jstring,jshort);
|
||||
jint getSheetIndex(jstring);
|
||||
jhsheet createSheet();
|
||||
jhsheet cloneSheet(jint);
|
||||
jhsheet createSheet(jstring);
|
||||
jhsheet getSheetAt(jint);
|
||||
jhsheet getSheet(jstring);
|
||||
void removeSheetAt(jint);
|
||||
jhcellstyle createCellStyle();
|
||||
jhfont createFont();
|
||||
jhdataformat createDataFormat();
|
||||
void write(joutputstream);
|
||||
|
||||
};
|
||||
|
||||
class HSSFSheet : public ::java::lang::Object {
|
||||
public:
|
||||
jhrow createRow(jint);
|
||||
jhrow getRow(jint);
|
||||
jhfooter getFooter();
|
||||
jhheader getHeader();
|
||||
};
|
||||
class HSSFRow : public ::java::lang::Object {
|
||||
public:
|
||||
jhcell createCell(jshort);
|
||||
jhcell getCell(jshort);
|
||||
//jboolean getProtect(); //only in 2.5
|
||||
|
||||
};
|
||||
class HSSFCell : public ::java::lang::Object {
|
||||
public:
|
||||
void setCellValue(jdouble);
|
||||
void setCellValue(jstring);
|
||||
void setCellValue(jboolean);
|
||||
void setCellValue(jcalendar);
|
||||
void setCellFormula(jstring);
|
||||
jstring getStringCellValue();
|
||||
jdouble getNumericCellValue();
|
||||
jdate getDateCellValue();
|
||||
jstring getCellFormula();
|
||||
jboolean getBooleanCellValue();
|
||||
jint getCellType();
|
||||
jshort getEncoding();
|
||||
void setAsActiveCell();
|
||||
|
||||
void setCellStyle(jhcellstyle);
|
||||
void setEncoding(jshort encoding);
|
||||
|
||||
static const jint CELL_TYPE_BLANK;
|
||||
static const jint CELL_TYPE_BOOLEAN;
|
||||
static const jint CELL_TYPE_ERROR;
|
||||
static const jint CELL_TYPE_FORMULA;
|
||||
static const jint CELL_TYPE_NUMERIC;
|
||||
static const jint CELL_TYPE_STRING;
|
||||
|
||||
static const jshort ENCODING_COMPRESSED_UNICODE;
|
||||
static const jshort ENCODING_UTF_16;
|
||||
};
|
||||
class HSSFCellStyle : public ::java::lang::Object {
|
||||
public:
|
||||
static const jshort ALIGN_CENTER;
|
||||
static const jshort ALIGN_CENTER_SELECTION;
|
||||
static const jshort ALIGN_FILL;
|
||||
static const jshort ALIGN_GENERAL;
|
||||
static const jshort ALIGN_JUSTIFY;
|
||||
static const jshort ALIGN_LEFT;
|
||||
static const jshort ALIGN_RIGHT;
|
||||
static const jshort ALT_BARS;
|
||||
static const jshort BIG_SPOTS;
|
||||
static const jshort BORDER_DASH_DOT;
|
||||
static const jshort BORDER_DASH_DOT_DOT;
|
||||
static const jshort BORDER_DASHED;
|
||||
static const jshort BORDER_DOTTED;
|
||||
static const jshort BORDER_DOUBLE;
|
||||
static const jshort BORDER_HAIR;
|
||||
static const jshort BORDER_MEDIUM;
|
||||
static const jshort BORDER_MEDIUM_DASH_DOT;
|
||||
static const jshort BORDER_MEDIUM_DASH_DOT_DOT;
|
||||
static const jshort BORDER_MEDIUM_DASHED;
|
||||
static const jshort BORDER_NONE;
|
||||
static const jshort BORDER_SLANTED_DASH_DOT;
|
||||
static const jshort BORDER_THICK;
|
||||
static const jshort BORDER_THIN;
|
||||
static const jshort BRICKS;
|
||||
static const jshort DIAMONDS;
|
||||
static const jshort FINE_DOTS;
|
||||
static const jshort NO_FILL;
|
||||
static const jshort SOLID_FOREGROUND;
|
||||
static const jshort SPARSE_DOTS;
|
||||
static const jshort SQUARES;
|
||||
static const jshort THICK_BACKWARD_DIAG;
|
||||
static const jshort THICK_FORWARD_DIAG;
|
||||
static const jshort THICK_HORZ_BANDS;
|
||||
static const jshort THICK_VERT_BANDS;
|
||||
static const jshort THIN_BACKWARD_DIAG;
|
||||
static const jshort THIN_FORWARD_DIAG;
|
||||
static const jshort THIN_HORZ_BANDS;
|
||||
static const jshort THIN_VERT_BANDS;
|
||||
static const jshort VERTICAL_BOTTOM;
|
||||
static const jshort VERTICAL_CENTER;
|
||||
static const jshort VERTICAL_JUSTIFY;
|
||||
static const jshort VERTICAL_TOP;
|
||||
|
||||
jshort getAlignment();
|
||||
jshort getBorderBottom();
|
||||
jshort getBorderLeft();
|
||||
jshort getBorderRight();
|
||||
jshort getBorderTop();
|
||||
jshort getBottomBorderColor();
|
||||
jshort getDataFormat();
|
||||
jshort getFillBackgroundColor();
|
||||
jshort getFillForegroundColor();
|
||||
jshort getFillPattern();
|
||||
jshort getFontIndex();
|
||||
jboolean getHidden();
|
||||
jshort getIndention();
|
||||
jshort getIndex();
|
||||
jshort getLeftBorderColor();
|
||||
jboolean getLocked();
|
||||
jshort getRightBorderColor();
|
||||
jshort getRotation();
|
||||
jshort getTopBorderColor();
|
||||
jshort getVerticalAlignment();
|
||||
jboolean getWrapText();
|
||||
void setAlignment(jshort) ;
|
||||
void setBorderBottom(jshort );
|
||||
void setBorderLeft(jshort );
|
||||
void setBorderRight(jshort );
|
||||
void setBorderTop(jshort );
|
||||
void setBottomBorderColor(jshort );
|
||||
void setDataFormat(jshort );
|
||||
void setFillBackgroundColor(jshort );
|
||||
void setFillForegroundColor(jshort );
|
||||
void setFillPattern(jshort );
|
||||
void setFont(jhfont );
|
||||
void setHidden(jboolean );
|
||||
void setIndention(jshort );
|
||||
void setLeftBorderColor(jshort );
|
||||
void setLocked(jboolean );
|
||||
void setRightBorderColor(jshort );
|
||||
void setRotation(jshort );
|
||||
void setTopBorderColor(jshort );
|
||||
void setVerticalAlignment(jshort );
|
||||
void setWrapText(jboolean );
|
||||
};
|
||||
class HSSFDataFormat : public ::java::lang::Object {
|
||||
public:
|
||||
static jstring getBuiltinFormat(jshort);
|
||||
static jshort getBuiltinFormat(jstring);
|
||||
jstring getFormat(jshort);
|
||||
jshort getFormat(jstring);
|
||||
static jint getNumberOfBuiltinBuiltinFormats();
|
||||
//TODO static jlist getBuiltinFormats();
|
||||
|
||||
};
|
||||
class HSSFFont : public ::java::lang::Object {
|
||||
public:
|
||||
static const jshort BOLDWEIGHT_BOLD;
|
||||
static const jshort BOLDWEIGHT_NORMAL;
|
||||
static const jshort COLOR_NORMAL;
|
||||
static const jshort COLOR_RED;
|
||||
static const jstring FONT_ARIAL;
|
||||
static const jshort SS_NONE;
|
||||
static const jshort SS_SUB;
|
||||
static const jshort SS_SUPER;
|
||||
static const jshort U_DOUBLE;
|
||||
static const jshort U_DOUBLE_ACCOUNTING;
|
||||
static const jshort U_NONE;
|
||||
static const jshort U_SINGLE;
|
||||
static const jshort U_SINGLE_ACCOUNTING;
|
||||
|
||||
jshort getBoldweight();
|
||||
jshort getColor();
|
||||
jshort getFontHeight();
|
||||
jshort getFontHeightInPoints();
|
||||
jstring getFontName();
|
||||
jshort getIndex();
|
||||
jboolean getItalic();
|
||||
jboolean getStrikeout();
|
||||
jshort getTypeOffset();
|
||||
jshort getUnderline();
|
||||
void setBoldweight(jshort );
|
||||
void setColor(jshort );
|
||||
void setFontHeight(jshort );
|
||||
void setFontHeightInPoints(jshort );
|
||||
void setFontName(jstring );
|
||||
void setItalic(jboolean );
|
||||
void setStrikeout(jboolean );
|
||||
void setTypeOffset(jshort );
|
||||
void setUnderline(jshort );
|
||||
};
|
||||
%makedefault;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
%init %{
|
||||
|
||||
JvCreateJavaVM(NULL);
|
||||
JvAttachCurrentThread(NULL, NULL);
|
||||
|
||||
nextThread = new java::lang::Thread();
|
||||
objects = new java::util::HashMap();
|
||||
|
||||
java::util::HashMap *props = (java::util::HashMap *)
|
||||
java::lang::System::getProperties();
|
||||
props->put(JvNewStringUTF("inRuby"), objects);
|
||||
|
||||
JvInitClass(&org::apache::poi::hssf::usermodel::HSSFFont::class$);
|
||||
JvInitClass(&org::apache::poi::hssf::usermodel::HSSFCell::class$);
|
||||
JvInitClass(&org::apache::poi::hssf::usermodel::HSSFSheet::class$);
|
||||
JvInitClass(&org::apache::poi::hssf::usermodel::HSSFCellStyle::class$);
|
||||
|
||||
%}
|
||||
|
||||
44
log4j/src/contrib/poi-ruby/cpp/RubyIO.cpp
Normal file
44
log4j/src/contrib/poi-ruby/cpp/RubyIO.cpp
Normal file
@ -0,0 +1,44 @@
|
||||
/* ====================================================================
|
||||
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.
|
||||
==================================================================== */
|
||||
#include <gcj/cni.h>
|
||||
|
||||
#include "ruby.h"
|
||||
#include "org/apache/poi/RubyOutputStream.h"
|
||||
|
||||
|
||||
/**
|
||||
* The native functions declared in org.apache.poi.RubyoutputStream
|
||||
*
|
||||
* @author aviks
|
||||
*/
|
||||
|
||||
namespace org {
|
||||
namespace apache {
|
||||
namespace poi {
|
||||
|
||||
void RubyOutputStream::close(void)
|
||||
{
|
||||
rb_funcall3((VALUE ) rubyIO, rb_intern("close"), 0, NULL);
|
||||
}
|
||||
|
||||
void RubyOutputStream::write(jint toWrite)
|
||||
{
|
||||
rb_funcall((VALUE ) rubyIO, rb_intern("putc"),1,INT2FIX(toWrite));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,62 @@
|
||||
/* ====================================================================
|
||||
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
contributor license agreements. See the NOTICE file distributed with
|
||||
this work for additional information regarding copyright ownership.
|
||||
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
(the "License"); you may not use this file except in compliance with
|
||||
the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
==================================================================== */
|
||||
|
||||
|
||||
package org.apache.poi;
|
||||
|
||||
|
||||
import java.io.OutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* @author aviks
|
||||
* Wrap a java.io.OutputStream around a Ruby IO object
|
||||
*/
|
||||
|
||||
public class RubyOutputStream extends OutputStream {
|
||||
|
||||
//pointer to native ruby VALUE
|
||||
protected long rubyIO;
|
||||
|
||||
public RubyOutputStream (long rubyIO)
|
||||
{
|
||||
this.rubyIO = rubyIO;
|
||||
// incRef();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void finalize()
|
||||
throws Throwable
|
||||
{
|
||||
// decRef();
|
||||
}
|
||||
|
||||
// protected native void incRef();
|
||||
// protected native void decRef();
|
||||
|
||||
@Override
|
||||
public native void close()
|
||||
throws IOException;
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see java.io.OutputStream#write(int)
|
||||
*/
|
||||
@Override
|
||||
public native void write(int arg0) throws IOException;
|
||||
}
|
||||
|
||||
100
log4j/src/contrib/poi-ruby/tests/tc_base_tests.rb
Normal file
100
log4j/src/contrib/poi-ruby/tests/tc_base_tests.rb
Normal file
@ -0,0 +1,100 @@
|
||||
# ====================================================================
|
||||
# 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.
|
||||
# ====================================================================
|
||||
|
||||
require 'test/unit'
|
||||
require 'release/poi4r'
|
||||
|
||||
class TC_base_tests < Test::Unit::TestCase
|
||||
|
||||
def setup()
|
||||
end
|
||||
|
||||
def test_get_constant
|
||||
h=Poi4r::HSSFWorkbook.new
|
||||
s=h.createSheet("Sheet1")
|
||||
r=s.createRow(0)
|
||||
c=r.createCell(0)
|
||||
assert_equal(3,Poi4r::HSSFCell.CELL_TYPE_BLANK,"Constant CELL_TYPE_BLANK")
|
||||
end
|
||||
|
||||
def test_base
|
||||
system("rm test.xls")
|
||||
h=Poi4r::HSSFWorkbook.new
|
||||
|
||||
#Test Sheet Creation
|
||||
s=h.createSheet("Sheet1")
|
||||
s=h.createSheet("Sheet2")
|
||||
assert_equal(2,h.getNumberOfSheets(),"Number of sheets is 2")
|
||||
|
||||
#Test setting cell values
|
||||
s=h.getSheetAt(0)
|
||||
r=s.createRow(0)
|
||||
c=r.createCell(0)
|
||||
c.setCellValue(1.5)
|
||||
assert_equal(c.getNumericCellValue(),1.5,"Numeric Cell Value")
|
||||
c=r.createCell(1)
|
||||
c.setCellValue("Ruby")
|
||||
assert_equal(c.getStringCellValue(),"Ruby","String Cell Value")
|
||||
#Test error handling
|
||||
assert_raise (RuntimeError) {c.getNumericCellValue()}
|
||||
|
||||
#Test styles
|
||||
st = h.createCellStyle()
|
||||
c=r.createCell(2)
|
||||
st.setAlignment(Poi4r::HSSFCellStyle.ALIGN_CENTER)
|
||||
c.setCellStyle(st)
|
||||
c.setCellValue("centr'd")
|
||||
|
||||
#Date handling
|
||||
c=r.createCell(3)
|
||||
t1=Time.now
|
||||
c.setCellValue(Time.now)
|
||||
t2= c.getDateCellValue().gmtime
|
||||
assert_equal(t1.year,t2.year,"year")
|
||||
assert_equal(t1.mon,t2.mon,"month")
|
||||
assert_equal(t1.day,t2.day,"day")
|
||||
assert_equal(t1.hour,t2.hour,"hour")
|
||||
assert_equal(t1.min,t2.min,"min")
|
||||
assert_equal(t1.sec,t2.sec,"sec")
|
||||
st=h.createCellStyle();
|
||||
st.setDataFormat(Poi4r::HSSFDataFormat.getBuiltinFormat("m/d/yy h:mm"))
|
||||
c.setCellStyle(st)
|
||||
|
||||
#Fonts
|
||||
c=r.createCell(4)
|
||||
font = h.createFont();
|
||||
font.setFontHeightInPoints(24);
|
||||
font.setFontName("Courier New");
|
||||
font.setItalic(true);
|
||||
font.setStrikeout(true);
|
||||
style = h.createCellStyle();
|
||||
style.setFont(font);
|
||||
c.setCellValue("This is a test of fonts");
|
||||
c.setCellStyle(style);
|
||||
|
||||
#Formulas
|
||||
c=r.createCell(5)
|
||||
c.setCellFormula("A1*2")
|
||||
assert_equal("A1*2",c.getCellFormula,"formula")
|
||||
|
||||
#Test writing
|
||||
h.write(File.new("test.xls","w"))
|
||||
assert_nothing_raised {File.new("test.xls","r")}
|
||||
#h.write(0.1)
|
||||
end
|
||||
|
||||
end
|
||||
32
log4j/src/contrib/poi-ruby/tests/tc_gc.rb
Normal file
32
log4j/src/contrib/poi-ruby/tests/tc_gc.rb
Normal file
@ -0,0 +1,32 @@
|
||||
# ====================================================================
|
||||
# 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.
|
||||
# ====================================================================
|
||||
|
||||
require 'test/unit'
|
||||
require 'release/poi4r'
|
||||
|
||||
class TC_gc < Test::Unit::TestCase
|
||||
def test_premature_collection
|
||||
h=Poi4r::HSSFWorkbook.new
|
||||
h.createSheet("Sheet1");
|
||||
5000.times do
|
||||
hh=Poi4r::HSSFWorkbook.new
|
||||
GC.start()
|
||||
end
|
||||
assert_equal(1,h.getNumberOfSheets(),"Number of sheets")
|
||||
end
|
||||
end
|
||||
|
||||
20
log4j/src/contrib/poi-ruby/tests/ts_all.rb
Normal file
20
log4j/src/contrib/poi-ruby/tests/ts_all.rb
Normal file
@ -0,0 +1,20 @@
|
||||
# ====================================================================
|
||||
# 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.
|
||||
# ====================================================================
|
||||
|
||||
require 'test/unit'
|
||||
require 'tests/tc_base_tests'
|
||||
require 'tests/tc_gc'
|
||||
0
log4j/src/contrib/testcases/dummy.txt
Normal file
0
log4j/src/contrib/testcases/dummy.txt
Normal file
36
log4j/src/examples/clojure/SpreadSheetDemo.clj
Normal file
36
log4j/src/examples/clojure/SpreadSheetDemo.clj
Normal file
@ -0,0 +1,36 @@
|
||||
/* ====================================================================
|
||||
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.
|
||||
==================================================================== */
|
||||
|
||||
(ns poi.core
|
||||
(:gen-class)
|
||||
(:use [clojure.java.io :only [input-stream]])
|
||||
(:import [org.apache.poi.ss.usermodel WorkbookFactory DataFormatter]))
|
||||
|
||||
|
||||
(defn sheets [wb] (map #(.getSheetAt wb %1) (range 0 (.getNumberOfSheets wb))))
|
||||
|
||||
(defn print-all [wb]
|
||||
(let [df (DataFormatter.)]
|
||||
(doseq [sheet (sheets wb)]
|
||||
(doseq [row (seq sheet)]
|
||||
(doseq [cell (seq row)]
|
||||
(println (.formatAsString (.getAddress cell)) ": " (.formatCellValue df cell)))))))
|
||||
|
||||
(defn -main [& args]
|
||||
(when-let [name (first args)]
|
||||
(let [wb (WorkbookFactory/create (input-stream name))]
|
||||
(print-all wb))))
|
||||
108
log4j/src/examples/groovy/SpreadSheetDemo.groovy
Normal file
108
log4j/src/examples/groovy/SpreadSheetDemo.groovy
Normal file
@ -0,0 +1,108 @@
|
||||
/* ====================================================================
|
||||
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.
|
||||
==================================================================== */
|
||||
|
||||
import org.apache.poi.ss.usermodel.*
|
||||
import org.apache.poi.ss.util.*
|
||||
import java.io.File
|
||||
|
||||
if (args.length == 0) {
|
||||
println "Use:"
|
||||
println " SpreadSheetDemo <excel-file> [output-file]"
|
||||
return 1
|
||||
}
|
||||
|
||||
File f = new File(args[0])
|
||||
DataFormatter formatter = new DataFormatter()
|
||||
WorkbookFactory.create(f,null,true).withCloseable { workbook ->
|
||||
println "Has ${workbook.getNumberOfSheets()} sheets"
|
||||
|
||||
// Dump the contents of the spreadsheet
|
||||
(0..<workbook.getNumberOfSheets()).each { sheetNum ->
|
||||
println "Sheet ${sheetNum} is called ${workbook.getSheetName(sheetNum)}"
|
||||
|
||||
def sheet = workbook.getSheetAt(sheetNum)
|
||||
sheet.each { row ->
|
||||
def nonEmptyCells = row.grep { c -> c.getCellType() != Cell.CELL_TYPE_BLANK }
|
||||
println " Row ${row.getRowNum()} has ${nonEmptyCells.size()} non-empty cells:"
|
||||
nonEmptyCells.each { c ->
|
||||
def cRef = [c] as CellReference
|
||||
println " * ${cRef.formatAsString()} = ${formatter.formatCellValue(c)}"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Add two new sheets and populate
|
||||
CellStyle headerStyle = makeHeaderStyle(workbook)
|
||||
Sheet ns1 = workbook.createSheet("Generated 1")
|
||||
exportHeader(ns1, headerStyle, null, ["ID","Title","Num"] as String[])
|
||||
ns1.createRow(1).createCell(0).setCellValue("TODO - Populate with data")
|
||||
|
||||
Sheet ns2 = workbook.createSheet("Generated 2")
|
||||
exportHeader(ns2, headerStyle, "This is a demo sheet",
|
||||
["ID","Title","Date","Author","Num"] as String[])
|
||||
ns2.createRow(2).createCell(0).setCellValue(1)
|
||||
ns2.createRow(3).createCell(0).setCellValue(4)
|
||||
ns2.createRow(4).createCell(0).setCellValue(1)
|
||||
|
||||
// Save
|
||||
File output = File.createTempFile("output-", (f.getName() =~ /(\.\w+$)/)[0][0])
|
||||
output.withOutputStream { os -> workbook.write(os) }
|
||||
println "Saved as ${output}"
|
||||
}
|
||||
|
||||
CellStyle makeHeaderStyle(Workbook wb) {
|
||||
int HEADER_HEIGHT = 18
|
||||
CellStyle style = wb.createCellStyle()
|
||||
|
||||
style.setFillForegroundColor(IndexedColors.AQUA.getIndex())
|
||||
style.setFillPattern(FillPatternType.SOLID_FOREGROUND)
|
||||
|
||||
Font font = wb.createFont()
|
||||
font.setFontHeightInPoints((short)HEADER_HEIGHT)
|
||||
font.setBold(true)
|
||||
style.setFont(font)
|
||||
|
||||
return style
|
||||
}
|
||||
void exportHeader(Sheet s, CellStyle headerStyle, String info, String[] headers) {
|
||||
Row r
|
||||
int rn = 0
|
||||
int HEADER_HEIGHT = 18
|
||||
// Do they want an info row at the top?
|
||||
if (info != null && !info.isEmpty()) {
|
||||
r = s.createRow(rn)
|
||||
r.setHeightInPoints(HEADER_HEIGHT+1)
|
||||
rn++
|
||||
|
||||
Cell c = r.createCell(0)
|
||||
c.setCellValue(info)
|
||||
c.setCellStyle(headerStyle)
|
||||
s.addMergedRegion(new CellRangeAddress(0,0,0,headers.length-1))
|
||||
}
|
||||
// Create the header row, of the right size
|
||||
r = s.createRow(rn)
|
||||
r.setHeightInPoints(HEADER_HEIGHT+1)
|
||||
// Add the column headings
|
||||
headers.eachWithIndex { col, idx ->
|
||||
Cell c = r.createCell(idx)
|
||||
c.setCellValue(col)
|
||||
c.setCellStyle(headerStyle)
|
||||
s.autoSizeColumn(idx)
|
||||
}
|
||||
// Make all the columns filterable
|
||||
s.setAutoFilter(new CellRangeAddress(rn, rn, 0, headers.length-1))
|
||||
}
|
||||
43
log4j/src/examples/groovy/build.gradle
Normal file
43
log4j/src/examples/groovy/build.gradle
Normal file
@ -0,0 +1,43 @@
|
||||
/* ====================================================================
|
||||
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.
|
||||
==================================================================== */
|
||||
|
||||
// Add the POI core and OOXML support dependencies into your gradle build,
|
||||
// along with all of Groovy so it can run as a standalone script
|
||||
apply plugin: 'groovy'
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
dependencies {
|
||||
compile 'org.codehaus.groovy:groovy-all:2.4.13'
|
||||
compile 'org.apache.poi:poi:5.0.0'
|
||||
compile 'org.apache.poi:poi-ooxml:5.0.0'
|
||||
}
|
||||
|
||||
// Our files are in the current directory
|
||||
sourceSets {
|
||||
main { groovy { srcDirs = ['.'] } }
|
||||
}
|
||||
|
||||
// Run out read demo by default
|
||||
tasks.withType(JavaExec) {
|
||||
classpath = sourceSets.main.runtimeClasspath
|
||||
}
|
||||
task runScript(type: JavaExec) {
|
||||
main = "SpreadSheetDemo"
|
||||
args = ["../../../test-data/spreadsheet/Simple.xls"]
|
||||
}
|
||||
defaultTasks 'runScript'
|
||||
116
log4j/src/examples/jsp/HSSFExample.jsp
Normal file
116
log4j/src/examples/jsp/HSSFExample.jsp
Normal file
@ -0,0 +1,116 @@
|
||||
<!--
|
||||
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.
|
||||
-->
|
||||
<%@page contentType="text/html"
|
||||
import="java.io.*,org.apache.poi.poifs.filesystem.POIFSFileSystem,org.apache.poi
|
||||
.hssf.record.*,org.apache.poi.hssf.model.*,org.apache.poi.hssf.usermodel.*,org.a
|
||||
pache.poi.hssf.util.*" %>
|
||||
<html>
|
||||
<head><title>Read Excel file </title>
|
||||
</head>
|
||||
<body>
|
||||
An example of using Jakarta POI's HSSF package to read an excel spreadsheet:
|
||||
|
||||
|
||||
<form name="form1" method="get" action="">
|
||||
Select an Excel file to read.
|
||||
<input type="file" name="xls_filename" onChange="form1.submit()">
|
||||
</form>
|
||||
|
||||
<%
|
||||
String filename = request.getParameter("xls_filename");
|
||||
if (filename != null && !filename.isEmpty()) {
|
||||
%>
|
||||
<br>You chose the file <%= filename %>.
|
||||
<br><br>It's contents are:
|
||||
<%
|
||||
try
|
||||
{
|
||||
|
||||
// create a poi workbook from the excel spreadsheet file
|
||||
POIFSFileSystem fs =
|
||||
new POIFSFileSystem(new FileInputStream(filename));
|
||||
HSSFWorkbook wb = new HSSFWorkbook(fs);
|
||||
|
||||
for (int k = 0; k < wb.getNumberOfSheets(); k++)
|
||||
{
|
||||
%>
|
||||
<br><br>Sheet <%= k %> <br>
|
||||
<%
|
||||
|
||||
HSSFSheet sheet = wb.getSheetAt(k);
|
||||
int rows = sheet.getPhysicalNumberOfRows();
|
||||
|
||||
for (int r = 0; r < rows; r++)
|
||||
{
|
||||
HSSFRow row = sheet.getRow(r);
|
||||
if (row != null) {
|
||||
int cells = row.getPhysicalNumberOfCells();
|
||||
%>
|
||||
<br><b>ROW <%=
|
||||
row.getRowNum() %> </b>
|
||||
<%
|
||||
for (short c = 0; c < cells; c++)
|
||||
{
|
||||
HSSFCell cell = row.getCell(c);
|
||||
if (cell != null) {
|
||||
String value = null;
|
||||
|
||||
switch (cell.getCellType())
|
||||
{
|
||||
|
||||
case HSSFCell.CELL_TYPE_FORMULA :
|
||||
value = "FORMULA ";
|
||||
break;
|
||||
|
||||
case HSSFCell.CELL_TYPE_NUMERIC :
|
||||
value = "NUMERIC value="
|
||||
+ cell.getNumericCellValue
|
||||
();
|
||||
break;
|
||||
|
||||
case HSSFCell.CELL_TYPE_STRING :
|
||||
value = "STRING value="
|
||||
+ cell.getStringCellValue();
|
||||
break;
|
||||
|
||||
default :
|
||||
}
|
||||
%>
|
||||
<%= "CELL col="
|
||||
|
||||
+ cell.getColumnIndex()
|
||||
+ " VALUE=" + value %>
|
||||
<%
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
%>
|
||||
Error occurred: <%= e.getMessage() %>
|
||||
<%
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
%>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
1
log4j/src/examples/lib/dummy.txt
Normal file
1
log4j/src/examples/lib/dummy.txt
Normal file
@ -0,0 +1 @@
|
||||
Dummy file so this directory is not deleted by CVS. It's required for the build.
|
||||
56
log4j/src/examples/scala/XSSFMain.scala
Normal file
56
log4j/src/examples/scala/XSSFMain.scala
Normal file
@ -0,0 +1,56 @@
|
||||
/* ====================================================================
|
||||
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.
|
||||
==================================================================== */
|
||||
|
||||
// Import the required classes
|
||||
import org.apache.poi.ss.usermodel.{WorkbookFactory, DataFormatter}
|
||||
import java.io.{File, FileOutputStream}
|
||||
|
||||
object XSSFMain extends App {
|
||||
|
||||
// Automatically convert Java collections to Scala equivalents
|
||||
import scala.collection.JavaConversions._
|
||||
|
||||
// Read the contents of the workbook
|
||||
val workbook = WorkbookFactory.create(new File("SampleSS.xlsx"))
|
||||
val formatter = new DataFormatter()
|
||||
for {
|
||||
// Iterate and print the sheets
|
||||
(sheet, i) <- workbook.zipWithIndex
|
||||
_ = println(s"Sheet $i of ${workbook.getNumberOfSheets}: ${sheet.getSheetName}")
|
||||
|
||||
// Iterate and print the rows
|
||||
row <- sheet
|
||||
_ = println(s"\tRow ${row.getRowNum}")
|
||||
|
||||
// Iterate and print the cells
|
||||
cell <- row
|
||||
} {
|
||||
println(s"\t\t${cell.getCellAddress}: ${formatter.formatCellValue(cell)}")
|
||||
}
|
||||
|
||||
// Add a sheet to the workbook
|
||||
val sheet = workbook.createSheet("new sheet")
|
||||
val row = sheet.createRow(7)
|
||||
val cell = row.createCell(42)
|
||||
cell.setAsActiveCell()
|
||||
cell.setCellValue("The answer to life, the universe, and everything")
|
||||
|
||||
// Save the updated workbook as a new file
|
||||
val fos = new FileOutputStream("SampleSS-updated.xlsx")
|
||||
workbook.write(fos)
|
||||
workbook.close()
|
||||
}
|
||||
23
log4j/src/examples/scala/build.sbt
Normal file
23
log4j/src/examples/scala/build.sbt
Normal file
@ -0,0 +1,23 @@
|
||||
/* ====================================================================
|
||||
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.
|
||||
==================================================================== */
|
||||
|
||||
// Add the POI core and OOXML support dependencies into your build.sbt
|
||||
libraryDependencies ++= Seq(
|
||||
"org.apache.poi" % "poi" % "5.0.0",
|
||||
"org.apache.poi" % "poi-ooxml" % "5.0.0",
|
||||
"org.apache.poi" % "poi-ooxml-lite" "5.0.0",
|
||||
)
|
||||
@ -0,0 +1,89 @@
|
||||
/*
|
||||
* ====================================================================
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* ====================================================================
|
||||
*/
|
||||
|
||||
package org.apache.poi.examples.crypt;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.security.GeneralSecurityException;
|
||||
import java.util.Optional;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import org.apache.poi.poifs.crypt.Decryptor;
|
||||
import org.apache.poi.poifs.crypt.EncryptionInfo;
|
||||
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
|
||||
|
||||
/**
|
||||
* Tries a list of possible passwords for an OOXML protected file
|
||||
*
|
||||
* Note that this isn't very fast, and is aimed at when you have
|
||||
* just a few passwords to check.
|
||||
* For serious processing, you'd be best off grabbing the hash
|
||||
* out with POI or office2john.py, then running that against
|
||||
* "John The Ripper" or GPU enabled version of "hashcat"
|
||||
*/
|
||||
public final class OOXMLPasswordsTry {
|
||||
|
||||
private OOXMLPasswordsTry() {}
|
||||
|
||||
@SuppressWarnings({"java:S106","java:S4823"})
|
||||
public static void main(String[] args) throws Exception {
|
||||
if (args.length < 2) {
|
||||
System.err.println("Use:");
|
||||
System.err.println(" OOXMLPasswordsTry <file.ooxml> <wordlist>");
|
||||
System.exit(1);
|
||||
}
|
||||
String ooxml = args[0];
|
||||
String words = args[1];
|
||||
|
||||
System.out.println("Trying passwords from " + words + " against " + ooxml);
|
||||
System.out.println();
|
||||
|
||||
try (POIFSFileSystem fs = new POIFSFileSystem(new File(ooxml), true)) {
|
||||
EncryptionInfo info = new EncryptionInfo(fs);
|
||||
Decryptor d = Decryptor.getInstance(info);
|
||||
|
||||
final long start = System.currentTimeMillis();
|
||||
final int[] count = { 0 };
|
||||
Predicate<String> counter = s -> {
|
||||
if (++count[0] % 1000 == 0) {
|
||||
int secs = (int) ((System.currentTimeMillis() - start) / 1000);
|
||||
System.out.println("Done " + count[0] + " passwords, " + secs + " seconds, last password " + s);
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
// Try each password in turn, reporting progress
|
||||
try (Stream<String> lines = Files.lines(Paths.get(words))) {
|
||||
Optional<String> found = lines.filter(counter).filter(w -> isValid(d, w)).findFirst();
|
||||
System.out.println(found.map(s -> "Password found: " + s).orElse("Error - No password matched"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isValid(Decryptor dec, String password) {
|
||||
try {
|
||||
return dec.verifyPassword(password);
|
||||
} catch (GeneralSecurityException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,200 @@
|
||||
/* ====================================================================
|
||||
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
contributor license agreements. See the NOTICE file distributed with
|
||||
this work for additional information regarding copyright ownership.
|
||||
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
(the "License"); you may not use this file except in compliance with
|
||||
the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
==================================================================== */
|
||||
|
||||
package org.apache.poi.examples.hpsf;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.PrintStream;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
|
||||
import org.apache.poi.hpsf.DocumentSummaryInformation;
|
||||
import org.apache.poi.hpsf.HPSFException;
|
||||
import org.apache.poi.hpsf.HPSFRuntimeException;
|
||||
import org.apache.poi.hpsf.PropertySet;
|
||||
import org.apache.poi.hpsf.PropertySetFactory;
|
||||
import org.apache.poi.hpsf.SummaryInformation;
|
||||
import org.apache.poi.hpsf.WritingNotSupportedException;
|
||||
import org.apache.poi.poifs.eventfilesystem.POIFSReader;
|
||||
import org.apache.poi.poifs.eventfilesystem.POIFSReaderEvent;
|
||||
import org.apache.poi.poifs.filesystem.DirectoryEntry;
|
||||
import org.apache.poi.poifs.filesystem.DocumentInputStream;
|
||||
import org.apache.poi.poifs.filesystem.EntryUtils;
|
||||
import org.apache.poi.poifs.filesystem.POIFSDocumentPath;
|
||||
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
|
||||
import org.apache.poi.util.TempFile;
|
||||
|
||||
/**
|
||||
* <p>This class copies a POI file system to a new file and compares the copy
|
||||
* with the original.</p>
|
||||
* <p>
|
||||
* <p>Property set streams are copied logically, i.e. the application
|
||||
* establishes a {@link org.apache.poi.hpsf.PropertySet} of an original property
|
||||
* set, creates a {@link org.apache.poi.hpsf.PropertySet} and writes the
|
||||
* {@link org.apache.poi.hpsf.PropertySet} to the destination POI file
|
||||
* system. - Streams which are no property set streams are copied bit by
|
||||
* bit.</p>
|
||||
* <p>
|
||||
* <p>The comparison of the POI file systems is done logically. That means that
|
||||
* the two disk files containing the POI file systems do not need to be
|
||||
* exactly identical. However, both POI file systems must contain the same
|
||||
* files, and most of these files must be bitwise identical. Property set
|
||||
* streams, however, are compared logically: they must have the same sections
|
||||
* with the same attributes, and the sections must contain the same properties.
|
||||
* Details like the ordering of the properties do not matter.</p>
|
||||
*/
|
||||
@SuppressWarnings({"java:S106","java:S4823"})
|
||||
public final class CopyCompare {
|
||||
private CopyCompare() {}
|
||||
|
||||
private static final ThreadLocal<PrintStream> out = ThreadLocal.withInitial(() -> System.out);
|
||||
|
||||
/**
|
||||
* Runs the example program. The application expects one or two arguments:
|
||||
*
|
||||
* <ol>
|
||||
* <li>The first argument is the disk file name of the POI filesystem to copy.</li>
|
||||
* <li>The second argument is optional. If it is given, it is the name of
|
||||
* a disk file the copy of the POI filesystem will be written to. If it is
|
||||
* not given, the copy will be written to a temporary file which will be
|
||||
* deleted at the end of the program.</li>
|
||||
* </ol>
|
||||
*
|
||||
* @param args Command-line arguments.
|
||||
* @throws IOException if any I/O exception occurs.
|
||||
* @throws UnsupportedEncodingException if a character encoding is not
|
||||
* supported.
|
||||
*/
|
||||
public static void main(final String[] args) throws IOException {
|
||||
String originalFileName = null;
|
||||
String copyFileName = null;
|
||||
|
||||
// Check the command-line arguments.
|
||||
if (args.length == 1) {
|
||||
originalFileName = args[0];
|
||||
File f = TempFile.createTempFile("CopyOfPOIFileSystem-", ".ole2");
|
||||
f.deleteOnExit();
|
||||
copyFileName = f.getAbsolutePath();
|
||||
} else if (args.length == 2) {
|
||||
originalFileName = args[0];
|
||||
copyFileName = args[1];
|
||||
} else {
|
||||
System.err.println("Usage: CopyCompare originPOIFS [copyPOIFS]");
|
||||
System.exit(1);
|
||||
}
|
||||
|
||||
|
||||
// Read the origin POIFS using the eventing API.
|
||||
final POIFSReader r = new POIFSReader();
|
||||
try (final POIFSFileSystem poiFs = new POIFSFileSystem();
|
||||
OutputStream fos = new FileOutputStream(copyFileName)) {
|
||||
r.registerListener(e -> handleEvent(poiFs, e));
|
||||
r.setNotifyEmptyDirectories(true);
|
||||
|
||||
r.read(new File(originalFileName));
|
||||
|
||||
// Write the new POIFS to disk.
|
||||
poiFs.writeFilesystem(fos);
|
||||
}
|
||||
|
||||
// Read all documents from the original POI file system and compare them with
|
||||
// the equivalent document from the copy.
|
||||
try (POIFSFileSystem opfs = new POIFSFileSystem(new File(originalFileName));
|
||||
POIFSFileSystem cpfs = new POIFSFileSystem(new File(copyFileName))) {
|
||||
final DirectoryEntry oRoot = opfs.getRoot();
|
||||
final DirectoryEntry cRoot = cpfs.getRoot();
|
||||
out.get().println(EntryUtils.areDirectoriesIdentical(oRoot, cRoot) ? "Equal" : "Not equal");
|
||||
}
|
||||
}
|
||||
|
||||
public static void setOut(PrintStream ps) {
|
||||
out.set(ps);
|
||||
}
|
||||
|
||||
private interface InputStreamSupplier {
|
||||
InputStream get() throws IOException, WritingNotSupportedException;
|
||||
}
|
||||
|
||||
/**
|
||||
* The method is called by POI's eventing API for each file in the origin POIFS.
|
||||
*/
|
||||
public static void handleEvent(final POIFSFileSystem poiFs, final POIFSReaderEvent event) {
|
||||
// The following declarations are shortcuts for accessing the "event" object.
|
||||
final DocumentInputStream stream = event.getStream();
|
||||
|
||||
try {
|
||||
|
||||
// Find out whether the current document is a property set stream or not.
|
||||
InputStreamSupplier su;
|
||||
if (stream != null && PropertySet.isPropertySetStream(stream)) {
|
||||
// Yes, the current document is a property set stream. Let's create
|
||||
// a PropertySet instance from it.
|
||||
PropertySet ps = PropertySetFactory.create(stream);
|
||||
|
||||
// Copy the property set to the destination POI file system.
|
||||
final PropertySet mps;
|
||||
if (ps instanceof DocumentSummaryInformation) {
|
||||
mps = new DocumentSummaryInformation(ps);
|
||||
} else if (ps instanceof SummaryInformation) {
|
||||
mps = new SummaryInformation(ps);
|
||||
} else {
|
||||
mps = new PropertySet(ps);
|
||||
}
|
||||
su = mps::toInputStream;
|
||||
} else {
|
||||
// No, the current document is not a property set stream.
|
||||
// We copy it unmodified to the destination POIFS.
|
||||
su = event::getStream;
|
||||
}
|
||||
|
||||
try (InputStream is = su.get()) {
|
||||
final POIFSDocumentPath path = event.getPath();
|
||||
|
||||
// Ensures that the directory hierarchy for a document in a POI fileystem is in place.
|
||||
// Get the root directory. It does not have to be created since it always exists in a POIFS.
|
||||
DirectoryEntry de = poiFs.getRoot();
|
||||
if (File.separator.equals(path.toString())) {
|
||||
de.setStorageClsid(event.getStorageClassId());
|
||||
}
|
||||
|
||||
for (int i=0; i<path.length(); i++) {
|
||||
String subDir = path.getComponent(i);
|
||||
if (de.hasEntry(subDir)) {
|
||||
de = (DirectoryEntry)de.getEntry(subDir);
|
||||
} else {
|
||||
de = de.createDirectory(subDir);
|
||||
if (i == path.length()-1) {
|
||||
de.setStorageClsid(event.getStorageClassId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (event.getName() != null) {
|
||||
de.createDocument(event.getName(), is);
|
||||
}
|
||||
}
|
||||
|
||||
} catch (HPSFException | IOException ex) {
|
||||
// According to the definition of the processPOIFSReaderEvent method we cannot pass checked
|
||||
// exceptions to the caller.
|
||||
throw new HPSFRuntimeException("Could not read file " + event.getPath() + "/" + event.getName(), ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,159 @@
|
||||
/* ====================================================================
|
||||
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
contributor license agreements. See the NOTICE file distributed with
|
||||
this work for additional information regarding copyright ownership.
|
||||
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
(the "License"); you may not use this file except in compliance with
|
||||
the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
==================================================================== */
|
||||
|
||||
package org.apache.poi.examples.hpsf;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.util.Date;
|
||||
|
||||
import org.apache.poi.hpsf.CustomProperties;
|
||||
import org.apache.poi.hpsf.DocumentSummaryInformation;
|
||||
import org.apache.poi.hpsf.PropertySetFactory;
|
||||
import org.apache.poi.hpsf.SummaryInformation;
|
||||
import org.apache.poi.poifs.filesystem.DirectoryEntry;
|
||||
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
|
||||
|
||||
/**
|
||||
* <p>This is a sample application showing how to easily modify properties in
|
||||
* the summary information and in the document summary information. The
|
||||
* application reads the name of a POI filesystem from the command line and
|
||||
* performs the following actions:</p>
|
||||
*
|
||||
* <ul>
|
||||
*
|
||||
* <li><p>Open the POI filesystem.</p></li>
|
||||
*
|
||||
* <li><p>Read the summary information.</p></li>
|
||||
*
|
||||
* <li><p>Read and print the "author" property.</p></li>
|
||||
*
|
||||
* <li><p>Change the author to "Rainer Klute".</p></li>
|
||||
*
|
||||
* <li><p>Read the document summary information.</p></li>
|
||||
*
|
||||
* <li><p>Read and print the "category" property.</p></li>
|
||||
*
|
||||
* <li><p>Change the category to "POI example".</p></li>
|
||||
*
|
||||
* <li><p>Read the custom properties (if available).</p></li>
|
||||
*
|
||||
* <li><p>Insert a new custom property.</p></li>
|
||||
*
|
||||
* <li><p>Write the custom properties back to the document summary
|
||||
* information.</p></li>
|
||||
*
|
||||
* <li><p>Write the summary information to the POI filesystem.</p></li>
|
||||
*
|
||||
* <li><p>Write the document summary information to the POI filesystem.</p></li>
|
||||
*
|
||||
* <li><p>Write the POI filesystem back to the original file.</p></li>
|
||||
*
|
||||
* </ol>
|
||||
*/
|
||||
@SuppressWarnings({"java:S106","java:S4823"})
|
||||
public final class ModifyDocumentSummaryInformation {
|
||||
|
||||
private ModifyDocumentSummaryInformation() {}
|
||||
|
||||
/**
|
||||
* <p>Main method - see class description.</p>
|
||||
*
|
||||
* @param args The command-line parameters.
|
||||
*/
|
||||
public static void main(final String[] args) throws Exception {
|
||||
/* Read the name of the POI filesystem to modify from the command line.
|
||||
* For brevity to boundary check is performed on the command-line
|
||||
* arguments. */
|
||||
File summaryFile = new File(args[0]);
|
||||
|
||||
/* Open the POI filesystem. */
|
||||
try (POIFSFileSystem poifs = new POIFSFileSystem(summaryFile, false)) {
|
||||
|
||||
/* Read the summary information. */
|
||||
DirectoryEntry dir = poifs.getRoot();
|
||||
SummaryInformation si;
|
||||
try {
|
||||
si = (SummaryInformation) PropertySetFactory.create(
|
||||
dir, SummaryInformation.DEFAULT_STREAM_NAME);
|
||||
} catch (FileNotFoundException ex) {
|
||||
// There is no summary information yet. We have to create a new one
|
||||
si = PropertySetFactory.newSummaryInformation();
|
||||
}
|
||||
assert(si != null);
|
||||
|
||||
/* Change the author to "Rainer Klute". Any former author value will
|
||||
* be lost. If there has been no author yet, it will be created. */
|
||||
si.setAuthor("Rainer Klute");
|
||||
System.out.println("Author changed to " + si.getAuthor() + ".");
|
||||
|
||||
|
||||
/* Handling the document summary information is analogous to handling
|
||||
* the summary information. An additional feature, however, are the
|
||||
* custom properties. */
|
||||
|
||||
/* Read the document summary information. */
|
||||
DocumentSummaryInformation dsi;
|
||||
try {
|
||||
dsi = (DocumentSummaryInformation) PropertySetFactory.create(
|
||||
dir, DocumentSummaryInformation.DEFAULT_STREAM_NAME);
|
||||
} catch (FileNotFoundException ex) {
|
||||
/* There is no document summary information yet. We have to create a
|
||||
* new one. */
|
||||
dsi = PropertySetFactory.newDocumentSummaryInformation();
|
||||
}
|
||||
assert(dsi != null);
|
||||
|
||||
/* Change the category to "POI example". Any former category value will
|
||||
* be lost. If there has been no category yet, it will be created. */
|
||||
dsi.setCategory("POI example");
|
||||
System.out.println("Category changed to " + dsi.getCategory() + ".");
|
||||
|
||||
/* Read the custom properties. If there are no custom properties yet,
|
||||
* the application has to create a new CustomProperties object. It will
|
||||
* serve as a container for custom properties. */
|
||||
CustomProperties customProperties = dsi.getCustomProperties();
|
||||
if (customProperties == null)
|
||||
customProperties = new CustomProperties();
|
||||
|
||||
/* Insert some custom properties into the container. */
|
||||
customProperties.put("Key 1", "Value 1");
|
||||
customProperties.put("Schl\u00fcssel 2", "Wert 2");
|
||||
customProperties.put("Sample Number", 12345);
|
||||
customProperties.put("Sample Boolean", Boolean.TRUE);
|
||||
customProperties.put("Sample Date", new Date());
|
||||
|
||||
/* Read a custom property. */
|
||||
Object value = customProperties.get("Sample Number");
|
||||
System.out.println("Custom Sample Number is now " + value);
|
||||
|
||||
/* Write the custom properties back to the document summary
|
||||
* information. */
|
||||
dsi.setCustomProperties(customProperties);
|
||||
|
||||
/* Write the summary information and the document summary information
|
||||
* to the POI filesystem. */
|
||||
si.write(dir, SummaryInformation.DEFAULT_STREAM_NAME);
|
||||
dsi.write(dir, DocumentSummaryInformation.DEFAULT_STREAM_NAME);
|
||||
|
||||
/* Write the POI filesystem back to the original file. Please note that
|
||||
* in production code you should take care when write directly to the
|
||||
* origin, to make sure you don't loose things on error */
|
||||
poifs.writeFilesystem();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,109 @@
|
||||
/* ====================================================================
|
||||
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
contributor license agreements. See the NOTICE file distributed with
|
||||
this work for additional information regarding copyright ownership.
|
||||
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
(the "License"); you may not use this file except in compliance with
|
||||
the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
==================================================================== */
|
||||
|
||||
package org.apache.poi.examples.hpsf;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.poi.hpsf.HPSFRuntimeException;
|
||||
import org.apache.poi.hpsf.NoPropertySetStreamException;
|
||||
import org.apache.poi.hpsf.Property;
|
||||
import org.apache.poi.hpsf.PropertySet;
|
||||
import org.apache.poi.hpsf.PropertySetFactory;
|
||||
import org.apache.poi.hpsf.Section;
|
||||
import org.apache.poi.poifs.eventfilesystem.POIFSReader;
|
||||
import org.apache.poi.poifs.eventfilesystem.POIFSReaderEvent;
|
||||
|
||||
/**
|
||||
* <p>Sample application showing how to read a document's custom property set.
|
||||
* Call it with the document's file name as command-line parameter.</p>
|
||||
*
|
||||
* <p>Explanations can be found in the HPSF HOW-TO.</p>
|
||||
*/
|
||||
@SuppressWarnings({"java:S106","java:S4823"})
|
||||
public final class ReadCustomPropertySets {
|
||||
|
||||
private ReadCustomPropertySets() {}
|
||||
|
||||
/**
|
||||
* <p>Runs the example program.</p>
|
||||
*
|
||||
* @param args Command-line arguments (unused).
|
||||
* @throws IOException if any I/O exception occurs.
|
||||
*/
|
||||
public static void main(final String[] args) throws IOException {
|
||||
final String filename = args[0];
|
||||
POIFSReader r = new POIFSReader();
|
||||
|
||||
/* Register a listener for *all* documents. */
|
||||
r.registerListener(ReadCustomPropertySets::processPOIFSReaderEvent);
|
||||
r.read(new File(filename));
|
||||
}
|
||||
|
||||
|
||||
public static void processPOIFSReaderEvent(final POIFSReaderEvent event) {
|
||||
final String streamName = event.getPath() + event.getName();
|
||||
PropertySet ps;
|
||||
try {
|
||||
ps = PropertySetFactory.create(event.getStream());
|
||||
} catch (NoPropertySetStreamException ex) {
|
||||
out("No property set stream: \"" + streamName + "\"");
|
||||
return;
|
||||
} catch (Exception ex) {
|
||||
throw new HPSFRuntimeException("Property set stream \"" + streamName + "\": " + ex);
|
||||
}
|
||||
|
||||
/* Print the name of the property set stream: */
|
||||
out("Property set stream \"" + streamName + "\":");
|
||||
|
||||
/* Print the number of sections: */
|
||||
final long sectionCount = ps.getSectionCount();
|
||||
out(" No. of sections: " + sectionCount);
|
||||
|
||||
/* Print the list of sections: */
|
||||
List<Section> sections = ps.getSections();
|
||||
int nr = 0;
|
||||
for (Section sec : sections) {
|
||||
/* Print a single section: */
|
||||
out(" Section " + nr++ + ":");
|
||||
String s = sec.getFormatID().toString();
|
||||
s = s.substring(0, s.length() - 1);
|
||||
out(" Format ID: " + s);
|
||||
|
||||
/* Print the number of properties in this section. */
|
||||
int propertyCount = sec.getPropertyCount();
|
||||
out(" No. of properties: " + propertyCount);
|
||||
|
||||
/* Print the properties: */
|
||||
Property[] properties = sec.getProperties();
|
||||
for (Property p : properties) {
|
||||
/* Print a single property: */
|
||||
long id = p.getID();
|
||||
long type = p.getType();
|
||||
Object value = p.getValue();
|
||||
out(" Property ID: " + id + ", type: " + type +
|
||||
", value: " + value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void out(final String msg) {
|
||||
System.out.println(msg);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,64 @@
|
||||
/* ====================================================================
|
||||
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
contributor license agreements. See the NOTICE file distributed with
|
||||
this work for additional information regarding copyright ownership.
|
||||
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
(the "License"); you may not use this file except in compliance with
|
||||
the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
==================================================================== */
|
||||
|
||||
package org.apache.poi.examples.hpsf;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.apache.poi.hpsf.PropertySetFactory;
|
||||
import org.apache.poi.hpsf.SummaryInformation;
|
||||
import org.apache.poi.poifs.eventfilesystem.POIFSReader;
|
||||
import org.apache.poi.poifs.eventfilesystem.POIFSReaderEvent;
|
||||
|
||||
/**
|
||||
* <p>Sample application showing how to read a OLE 2 document's
|
||||
* title. Call it with the document's file name as command line
|
||||
* parameter.</p>
|
||||
*
|
||||
* <p>Explanations can be found in the HPSF HOW-TO.</p>
|
||||
*/
|
||||
@SuppressWarnings({"java:S106","java:S4823"})
|
||||
public final class ReadTitle {
|
||||
private ReadTitle() {}
|
||||
|
||||
/**
|
||||
* <p>Runs the example program.</p>
|
||||
*
|
||||
* @param args Command-line arguments. The first command-line argument must
|
||||
* be the name of a POI filesystem to read.
|
||||
* @throws IOException if any I/O exception occurs.
|
||||
*/
|
||||
public static void main(final String[] args) throws IOException {
|
||||
final String filename = args[0];
|
||||
POIFSReader r = new POIFSReader();
|
||||
r.registerListener(ReadTitle::processPOIFSReaderEvent, SummaryInformation.DEFAULT_STREAM_NAME);
|
||||
r.read(new File(filename));
|
||||
}
|
||||
|
||||
|
||||
private static void processPOIFSReaderEvent(final POIFSReaderEvent event) {
|
||||
SummaryInformation si;
|
||||
try {
|
||||
si = (SummaryInformation) PropertySetFactory.create(event.getStream());
|
||||
} catch (Exception ex) {
|
||||
throw new RuntimeException("Property set stream \"" + event.getPath() + event.getName() + "\": " + ex);
|
||||
}
|
||||
final String title = si.getTitle();
|
||||
System.out.println(title != null ? "Title: \"" + title + "\"" : "Document has no title.");
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,174 @@
|
||||
/* ====================================================================
|
||||
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
contributor license agreements. See the NOTICE file distributed with
|
||||
this work for additional information regarding copyright ownership.
|
||||
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
(the "License"); you may not use this file except in compliance with
|
||||
the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
==================================================================== */
|
||||
|
||||
package org.apache.poi.examples.hpsf;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
|
||||
import org.apache.poi.hpsf.HPSFRuntimeException;
|
||||
import org.apache.poi.hpsf.MarkUnsupportedException;
|
||||
import org.apache.poi.hpsf.NoPropertySetStreamException;
|
||||
import org.apache.poi.hpsf.PropertySet;
|
||||
import org.apache.poi.hpsf.PropertySetFactory;
|
||||
import org.apache.poi.hpsf.Section;
|
||||
import org.apache.poi.hpsf.SummaryInformation;
|
||||
import org.apache.poi.hpsf.Variant;
|
||||
import org.apache.poi.hpsf.WritingNotSupportedException;
|
||||
import org.apache.poi.hpsf.wellknown.PropertyIDMap;
|
||||
import org.apache.poi.poifs.eventfilesystem.POIFSReader;
|
||||
import org.apache.poi.poifs.eventfilesystem.POIFSReaderEvent;
|
||||
import org.apache.poi.poifs.filesystem.DirectoryEntry;
|
||||
import org.apache.poi.poifs.filesystem.DocumentInputStream;
|
||||
import org.apache.poi.poifs.filesystem.POIFSDocumentPath;
|
||||
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
|
||||
|
||||
/**
|
||||
* <p>This class is a sample application which shows how to write or modify the
|
||||
* author and title property of an OLE 2 document. This could be done in two
|
||||
* different ways:</p>
|
||||
*
|
||||
* <ul>
|
||||
*
|
||||
* <li><p>The first approach is to open the OLE 2 file as a POI filesystem
|
||||
* (see class {@link POIFSFileSystem}), read the summary information property
|
||||
* set (see classes {@link SummaryInformation} and {@link PropertySet}), write
|
||||
* the author and title properties into it and write the property set back into
|
||||
* the POI filesystem.</p></li>
|
||||
*
|
||||
* <li><p>The second approach does not modify the original POI filesystem, but
|
||||
* instead creates a new one. All documents from the original POIFS are copied
|
||||
* to the destination POIFS, except for the summary information stream. The
|
||||
* latter is modified by setting the author and title property before writing
|
||||
* it to the destination POIFS. It there are several summary information streams
|
||||
* in the original POIFS - e.g. in subordinate directories - they are modified
|
||||
* just the same.</p></li>
|
||||
*
|
||||
* </ul>
|
||||
*
|
||||
* <p>This sample application takes the second approach. It expects the name of
|
||||
* the existing POI filesystem's name as its first command-line parameter and
|
||||
* the name of the output POIFS as the second command-line argument. The
|
||||
* program then works as described above: It copies nearly all documents
|
||||
* unmodified from the input POI filesystem to the output POI filesystem. If it
|
||||
* encounters a summary information stream it reads its properties. Then it sets
|
||||
* the "author" and "title" properties to new values and writes the modified
|
||||
* summary information stream into the output file.</p>
|
||||
*
|
||||
* <p>Further explanations can be found in the HPSF HOW-TO.</p>
|
||||
*/
|
||||
@SuppressWarnings({"java:S106","java:S4823"})
|
||||
public final class WriteAuthorAndTitle {
|
||||
private WriteAuthorAndTitle() {}
|
||||
|
||||
/**
|
||||
* <p>Runs the example program.</p>
|
||||
*
|
||||
* @param args Command-line arguments. The first command-line argument must
|
||||
* be the name of a POI filesystem to read.
|
||||
* @throws IOException if any I/O exception occurs.
|
||||
*/
|
||||
public static void main(final String[] args) throws IOException {
|
||||
/* Check whether we have exactly two command-line arguments. */
|
||||
if (args.length != 2) {
|
||||
System.err.println("Usage: WriteAuthorAndTitle originPOIFS destinationPOIFS");
|
||||
System.exit(1);
|
||||
}
|
||||
|
||||
/* Read the names of the origin and destination POI filesystems. */
|
||||
final String srcName = args[0];
|
||||
final String dstName = args[1];
|
||||
|
||||
/* Read the origin POIFS using the eventing API. The real work is done
|
||||
* in the class ModifySICopyTheRest which is registered here as a
|
||||
* POIFSReader. */
|
||||
try (POIFSFileSystem poifs = new POIFSFileSystem();
|
||||
OutputStream out = new FileOutputStream(dstName)) {
|
||||
final POIFSReader r = new POIFSReader();
|
||||
r.registerListener(e -> handleEvent(poifs, e));
|
||||
r.read(new File(srcName));
|
||||
|
||||
/* Write the new POIFS to disk. */
|
||||
poifs.writeFilesystem(out);
|
||||
}
|
||||
}
|
||||
|
||||
private interface InputStreamSupplier {
|
||||
InputStream get() throws IOException, WritingNotSupportedException;
|
||||
}
|
||||
|
||||
/**
|
||||
* The method is called by POI's eventing API for each file in the origin POIFS.
|
||||
*/
|
||||
private static void handleEvent(final POIFSFileSystem poiFs, final POIFSReaderEvent event) {
|
||||
// The following declarations are shortcuts for accessing the "event" object.
|
||||
final DocumentInputStream stream = event.getStream();
|
||||
|
||||
try {
|
||||
final InputStreamSupplier isSup;
|
||||
|
||||
// Find out whether the current document is a property set stream or not.
|
||||
if (PropertySet.isPropertySetStream(stream)) {
|
||||
// Yes, the current document is a property set stream. Let's create a PropertySet instance from it.
|
||||
PropertySet ps = PropertySetFactory.create(stream);
|
||||
|
||||
// Now we know that we really have a property set.
|
||||
// The next step is to find out whether it is a summary information or not.
|
||||
if (ps.isSummaryInformation()) {
|
||||
// Create a mutable property set as a copy of the original read-only property set.
|
||||
ps = new PropertySet(ps);
|
||||
|
||||
// Retrieve the section containing the properties to modify.
|
||||
// A summary information property set contains exactly one section.
|
||||
final Section s = ps.getSections().get(0);
|
||||
|
||||
// Set the properties.
|
||||
s.setProperty(PropertyIDMap.PID_AUTHOR, Variant.VT_LPSTR, "Rainer Klute");
|
||||
s.setProperty(PropertyIDMap.PID_TITLE, Variant.VT_LPWSTR, "Test");
|
||||
}
|
||||
|
||||
isSup = ps::toInputStream;
|
||||
} else {
|
||||
// No, the current document is not a property set stream. We copy it unmodified to the destination POIFS.
|
||||
isSup = event::getStream;
|
||||
}
|
||||
|
||||
try (InputStream is = isSup.get()) {
|
||||
final POIFSDocumentPath path = event.getPath();
|
||||
|
||||
// Ensures that the directory hierarchy for a document in a POI fileystem is in place.
|
||||
// Get the root directory. It does not have to be created since it always exists in a POIFS.
|
||||
DirectoryEntry de = poiFs.getRoot();
|
||||
|
||||
for (int i=0; i<path.length(); i++) {
|
||||
String subDir = path.getComponent(i);
|
||||
de = (de.hasEntry(subDir)) ? (DirectoryEntry)de.getEntry(subDir) : de.createDirectory(subDir);
|
||||
}
|
||||
|
||||
de.createDocument(event.getName(), is);
|
||||
}
|
||||
|
||||
} catch (MarkUnsupportedException | WritingNotSupportedException | IOException | NoPropertySetStreamException ex) {
|
||||
// According to the definition of the processPOIFSReaderEvent method we cannot pass checked
|
||||
// exceptions to the caller.
|
||||
throw new HPSFRuntimeException("Could not read file " + event.getPath() + "/" + event.getName(), ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,104 @@
|
||||
/* ====================================================================
|
||||
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
contributor license agreements. See the NOTICE file distributed with
|
||||
this work for additional information regarding copyright ownership.
|
||||
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
(the "License"); you may not use this file except in compliance with
|
||||
the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
==================================================================== */
|
||||
|
||||
package org.apache.poi.examples.hpsf;
|
||||
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
import org.apache.poi.hpsf.Property;
|
||||
import org.apache.poi.hpsf.PropertySet;
|
||||
import org.apache.poi.hpsf.Section;
|
||||
import org.apache.poi.hpsf.SummaryInformation;
|
||||
import org.apache.poi.hpsf.Variant;
|
||||
import org.apache.poi.hpsf.WritingNotSupportedException;
|
||||
import org.apache.poi.hpsf.wellknown.PropertyIDMap;
|
||||
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
|
||||
|
||||
/**
|
||||
* <p>This class is a simple sample application showing how to create a property
|
||||
* set and write it to disk.</p>
|
||||
*/
|
||||
@SuppressWarnings({"java:S106","java:S4823"})
|
||||
public final class WriteTitle {
|
||||
|
||||
private WriteTitle() {}
|
||||
|
||||
/**
|
||||
* <p>Runs the example program.</p>
|
||||
*
|
||||
* @param args Command-line arguments. The first and only command-line
|
||||
* argument is the name of the POI file system to create.
|
||||
* @throws IOException if any I/O exception occurs.
|
||||
* @throws WritingNotSupportedException if HPSF does not (yet) support
|
||||
* writing a certain property type.
|
||||
*/
|
||||
public static void main(final String[] args)
|
||||
throws WritingNotSupportedException, IOException
|
||||
{
|
||||
/* Check whether we have exactly one command-line argument. */
|
||||
if (args.length != 1)
|
||||
{
|
||||
System.err.println("Usage: " + WriteTitle.class.getName() + "destinationPOIFS");
|
||||
System.exit(1);
|
||||
}
|
||||
|
||||
final String fileName = args[0];
|
||||
|
||||
/* Create a mutable property set. Initially it contains a single section
|
||||
* with no properties. */
|
||||
final PropertySet mps = new PropertySet();
|
||||
|
||||
/* Retrieve the section the property set already contains. */
|
||||
final Section ms = mps.getSections().get(0);
|
||||
|
||||
/* Turn the property set into a summary information property. This is
|
||||
* done by setting the format ID of its first section to
|
||||
* SectionIDMap.SUMMARY_INFORMATION_ID. */
|
||||
ms.setFormatID(SummaryInformation.FORMAT_ID);
|
||||
|
||||
/* Create an empty property. */
|
||||
final Property p = new Property();
|
||||
|
||||
/* Fill the property with appropriate settings so that it specifies the
|
||||
* document's title. */
|
||||
p.setID(PropertyIDMap.PID_TITLE);
|
||||
p.setType(Variant.VT_LPWSTR);
|
||||
p.setValue("Sample title");
|
||||
|
||||
/* Place the property into the section. */
|
||||
ms.setProperty(p);
|
||||
|
||||
/* Create the POI file system the property set is to be written to.
|
||||
* For writing the property set into a POI file system it has to be
|
||||
* handed over to the POIFS.createDocument() method as an input stream
|
||||
* which produces the bytes making out the property set stream. */
|
||||
try (final POIFSFileSystem poiFs = new POIFSFileSystem();
|
||||
final InputStream is = mps.toInputStream();
|
||||
final FileOutputStream fos = new FileOutputStream(fileName)) {
|
||||
|
||||
/* Create the summary information property set in the POI file
|
||||
* system. It is given the default name most (if not all) summary
|
||||
* information property sets have. */
|
||||
poiFs.createDocument(is, SummaryInformation.DEFAULT_STREAM_NAME);
|
||||
|
||||
/* Write the whole POI file system to a disk file. */
|
||||
poiFs.writeFilesystem(fos);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,460 @@
|
||||
/* ====================================================================
|
||||
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
contributor license agreements. See the NOTICE file distributed with
|
||||
this work for additional information regarding copyright ownership.
|
||||
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
(the "License"); you may not use this file except in compliance with
|
||||
the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
==================================================================== */
|
||||
|
||||
package org.apache.poi.examples.hslf;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Font;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.poi.hslf.usermodel.HSLFSlideShow;
|
||||
import org.apache.poi.sl.draw.DrawTableShape;
|
||||
import org.apache.poi.sl.draw.SLGraphics;
|
||||
import org.apache.poi.sl.usermodel.AutoShape;
|
||||
import org.apache.poi.sl.usermodel.GroupShape;
|
||||
import org.apache.poi.sl.usermodel.ShapeType;
|
||||
import org.apache.poi.sl.usermodel.Slide;
|
||||
import org.apache.poi.sl.usermodel.SlideShow;
|
||||
import org.apache.poi.sl.usermodel.TableCell;
|
||||
import org.apache.poi.sl.usermodel.TableShape;
|
||||
import org.apache.poi.sl.usermodel.TextBox;
|
||||
import org.apache.poi.sl.usermodel.TextParagraph;
|
||||
import org.apache.poi.sl.usermodel.TextRun;
|
||||
import org.apache.poi.sl.usermodel.TextShape.TextPlaceholder;
|
||||
import org.apache.poi.sl.usermodel.VerticalAlignment;
|
||||
|
||||
/**
|
||||
* Presentation for Fast Feather Track on ApacheconEU 2008
|
||||
*
|
||||
* @author Yegor Kozlov
|
||||
*/
|
||||
@SuppressWarnings("java:S1192")
|
||||
public final class ApacheconEU08 {
|
||||
|
||||
private ApacheconEU08() {}
|
||||
|
||||
public static void main(String[] args) throws IOException {
|
||||
// use HSLFSlideShow or XMLSlideShow
|
||||
try (SlideShow<?,?> ppt = new HSLFSlideShow()) {
|
||||
ppt.setPageSize(new Dimension(720, 540));
|
||||
|
||||
slide1(ppt);
|
||||
slide2(ppt);
|
||||
slide3(ppt);
|
||||
slide4(ppt);
|
||||
slide5(ppt);
|
||||
slide6(ppt);
|
||||
slide7(ppt);
|
||||
slide8(ppt);
|
||||
slide9(ppt);
|
||||
slide10(ppt);
|
||||
slide11(ppt);
|
||||
slide12(ppt);
|
||||
|
||||
String ext = ppt.getClass().getName().contains("HSLF") ? "ppt" : "pptx";
|
||||
try (FileOutputStream out = new FileOutputStream("apachecon_eu_08." + ext)) {
|
||||
ppt.write(out);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void slide1(SlideShow<?,?> ppt) throws IOException {
|
||||
Slide<?,?> slide = ppt.createSlide();
|
||||
|
||||
TextBox<?,?> box1 = slide.createTextBox();
|
||||
box1.setTextPlaceholder(TextPlaceholder.CENTER_TITLE);
|
||||
box1.setText("POI-HSLF");
|
||||
box1.setAnchor(new Rectangle(54, 78, 612, 115));
|
||||
|
||||
TextBox<?,?> box2 = slide.createTextBox();
|
||||
box2.setTextPlaceholder(TextPlaceholder.CENTER_BODY);
|
||||
box2.setText("Java API To Access Microsoft PowerPoint Format Files");
|
||||
box2.setAnchor(new Rectangle(108, 204, 504, 138));
|
||||
|
||||
TextBox<?,?> box3 = slide.createTextBox();
|
||||
box3.getTextParagraphs().get(0).getTextRuns().get(0).setFontSize(32d);
|
||||
box3.setText(
|
||||
"Yegor Kozlov\r" +
|
||||
"yegor - apache - org");
|
||||
box3.setHorizontalCentered(true);
|
||||
box3.setAnchor(new Rectangle(206, 348, 310, 84));
|
||||
}
|
||||
|
||||
public static void slide2(SlideShow<?,?> ppt) throws IOException {
|
||||
Slide<?,?> slide = ppt.createSlide();
|
||||
|
||||
TextBox<?,?> box1 = slide.createTextBox();
|
||||
box1.setTextPlaceholder(TextPlaceholder.TITLE);
|
||||
box1.setText("What is HSLF?");
|
||||
box1.setAnchor(new Rectangle(36, 21, 648, 90));
|
||||
|
||||
TextBox<?,?> box2 = slide.createTextBox();
|
||||
box2.setTextPlaceholder(TextPlaceholder.BODY);
|
||||
box2.setText("HorribleSLideshowFormat is the POI Project's pure Java implementation " +
|
||||
"of the Powerpoint binary file format. \r" +
|
||||
"POI sub-project since 2005\r" +
|
||||
"Started by Nick Burch, Yegor Kozlov joined soon after");
|
||||
box2.setAnchor(new Rectangle(36, 126, 648, 356));
|
||||
}
|
||||
|
||||
public static void slide3(SlideShow<?,?> ppt) throws IOException {
|
||||
Slide<?,?> slide = ppt.createSlide();
|
||||
|
||||
TextBox<?,?> box1 = slide.createTextBox();
|
||||
box1.setTextPlaceholder(TextPlaceholder.TITLE);
|
||||
box1.setText("HSLF in a Nutshell");
|
||||
box1.setAnchor(new Rectangle(36, 15, 648, 65));
|
||||
|
||||
TextBox<?,?> box2 = slide.createTextBox();
|
||||
box2.setTextPlaceholder(TextPlaceholder.BODY);
|
||||
box2.setText(
|
||||
"HSLF provides a way to read, create and modify MS PowerPoint presentations\r" +
|
||||
"Pure Java API - you don't need PowerPoint to read and write *.ppt files\r" +
|
||||
"Comprehensive support of PowerPoint objects\r" +
|
||||
"Rich text\r" +
|
||||
"Tables\r" +
|
||||
"Shapes\r" +
|
||||
"Pictures\r" +
|
||||
"Master slides\r" +
|
||||
"Access to low level data structures"
|
||||
);
|
||||
|
||||
List<? extends TextParagraph<?,?,?>> tp = box2.getTextParagraphs();
|
||||
for (int i : new byte[]{0,1,2,8}) {
|
||||
tp.get(i).getTextRuns().get(0).setFontSize(28d);
|
||||
}
|
||||
for (int i : new byte[]{3,4,5,6,7}) {
|
||||
tp.get(i).getTextRuns().get(0).setFontSize(24d);
|
||||
tp.get(i).setIndentLevel(1);
|
||||
}
|
||||
box2.setAnchor(new Rectangle(36, 80, 648, 400));
|
||||
}
|
||||
|
||||
public static void slide4(SlideShow<?,?> ppt) throws IOException {
|
||||
Slide<?,?> slide = ppt.createSlide();
|
||||
|
||||
String[][] txt1 = {
|
||||
{"Note"},
|
||||
{"This presentation was created programmatically using POI HSLF"}
|
||||
};
|
||||
TableShape<?,?> table1 = slide.createTable(2, 1);
|
||||
for (int i = 0; i < txt1.length; i++) {
|
||||
for (int j = 0; j < txt1[i].length; j++) {
|
||||
TableCell<?,?> cell = table1.getCell(i, j);
|
||||
cell.setText(txt1[i][j]);
|
||||
TextRun rt = cell.getTextParagraphs().get(0).getTextRuns().get(0);
|
||||
rt.setFontSize(10d);
|
||||
rt.setFontFamily("Arial");
|
||||
rt.setBold(true);
|
||||
if(i == 0){
|
||||
rt.setFontSize(32d);
|
||||
rt.setFontColor(Color.white);
|
||||
cell.setFillColor(new Color(0, 153, 204));
|
||||
} else {
|
||||
rt.setFontSize(28d);
|
||||
cell.setFillColor(new Color(235, 239, 241));
|
||||
}
|
||||
cell.setVerticalAlignment(VerticalAlignment.MIDDLE);
|
||||
}
|
||||
}
|
||||
|
||||
DrawTableShape dts = new DrawTableShape(table1);
|
||||
dts.setAllBorders(1.0, Color.black);
|
||||
dts.setOutsideBorders(4.0);
|
||||
|
||||
table1.setColumnWidth(0, 450);
|
||||
table1.setRowHeight(0, 50);
|
||||
table1.setRowHeight(1, 80);
|
||||
|
||||
Dimension dim = ppt.getPageSize();
|
||||
Rectangle2D oldAnchor = table1.getAnchor();
|
||||
table1.setAnchor(new Rectangle2D.Double((dim.width-450)/2d, 100, oldAnchor.getWidth(), oldAnchor.getHeight()));
|
||||
|
||||
TextBox<?,?> box1 = slide.createTextBox();
|
||||
box1.setHorizontalCentered(true);
|
||||
box1.getTextParagraphs().get(0).getTextRuns().get(0).setFontSize(24d);
|
||||
box1.setText("The source code is available at\r" +
|
||||
"http://people.apache.org/~yegor/apachecon_eu08/");
|
||||
box1.setAnchor(new Rectangle(80, 356, 553, 65));
|
||||
}
|
||||
|
||||
public static void slide5(SlideShow<?,?> ppt) throws IOException {
|
||||
Slide<?,?> slide = ppt.createSlide();
|
||||
|
||||
TextBox<?,?> box1 = slide.createTextBox();
|
||||
box1.setTextPlaceholder(TextPlaceholder.TITLE);
|
||||
box1.setText("HSLF in Action - 1\rData Extraction");
|
||||
box1.setAnchor(new Rectangle(36, 21, 648, 100));
|
||||
|
||||
TextBox<?,?> box2 = slide.createTextBox();
|
||||
box2.setTextPlaceholder(TextPlaceholder.BODY);
|
||||
box2.setText(
|
||||
"Text from slides and notes\r" +
|
||||
"Images\r" +
|
||||
"Shapes and their properties (type, position in the slide, color, font, etc.)");
|
||||
box2.setAnchor(new Rectangle(36, 150, 648, 300));
|
||||
}
|
||||
|
||||
public static void slide6(SlideShow<?,?> ppt) throws IOException {
|
||||
Slide<?,?> slide = ppt.createSlide();
|
||||
|
||||
TextBox<?,?> box1 = slide.createTextBox();
|
||||
box1.setTextPlaceholder(TextPlaceholder.TITLE);
|
||||
box1.setText("HSLF in Action - 2");
|
||||
box1.setAnchor(new Rectangle(36, 20, 648, 90));
|
||||
|
||||
TextBox<?,?> box2 = slide.createTextBox();
|
||||
box2.getTextParagraphs().get(0).getTextRuns().get(0).setFontSize(18d);
|
||||
box2.setText("Creating a simple presentation from scratch");
|
||||
box2.setAnchor(new Rectangle(170, 100, 364, 30));
|
||||
|
||||
TextBox<?,?> box3 = slide.createTextBox();
|
||||
TextRun rt3 = box3.getTextParagraphs().get(0).getTextRuns().get(0);
|
||||
rt3.setFontFamily("Courier New");
|
||||
rt3.setFontSize(8d);
|
||||
box3.setText(
|
||||
"SlideShow ppt = new SlideShow();\u000b" +
|
||||
"Slide slide = ppt.createSlide();\u000b" +
|
||||
"\u000b" +
|
||||
"TextBox box2 = new TextBox();\u000b" +
|
||||
"box2.setHorizontalAlignment(TextBox.AlignCenter);\u000b" +
|
||||
"box2.setVerticalAlignment(TextBox.AnchorMiddle);\u000b" +
|
||||
"box2.getTextRun().setText(\"Java Code\");\u000b" +
|
||||
"box2.getFill().setForegroundColor(new Color(187, 224, 227));\u000b" +
|
||||
"box2.setLineColor(Color.black);\u000b" +
|
||||
"box2.setLineWidth(0.75);\u000b" +
|
||||
"box2.setAnchor(new Rectangle(66, 243, 170, 170));\u000b" +
|
||||
"slide.addShape(box2);\u000b" +
|
||||
"\u000b" +
|
||||
"TextBox box3 = new TextBox();\u000b" +
|
||||
"box3.setHorizontalAlignment(TextBox.AlignCenter);\u000b" +
|
||||
"box3.setVerticalAlignment(TextBox.AnchorMiddle);\u000b" +
|
||||
"box3.getTextRun().setText(\"*.ppt file\");\u000b" +
|
||||
"box3.setLineWidth(0.75);\u000b" +
|
||||
"box3.setLineColor(Color.black);\u000b" +
|
||||
"box3.getFill().setForegroundColor(new Color(187, 224, 227));\u000b" +
|
||||
"box3.setAnchor(new Rectangle(473, 243, 170, 170));\u000b" +
|
||||
"slide.addShape(box3);\u000b" +
|
||||
"\u000b" +
|
||||
"AutoShape box4 = new AutoShape(ShapeTypes.Arrow);\u000b" +
|
||||
"box4.getFill().setForegroundColor(new Color(187, 224, 227));\u000b" +
|
||||
"box4.setLineWidth(0.75);\u000b" +
|
||||
"box4.setLineColor(Color.black);\u000b" +
|
||||
"box4.setAnchor(new Rectangle(253, 288, 198, 85));\u000b" +
|
||||
"slide.addShape(box4);\u000b" +
|
||||
"\u000b" +
|
||||
"FileOutputStream out = new FileOutputStream(\"hslf-demo.ppt\");\u000b" +
|
||||
"ppt.write(out);\u000b" +
|
||||
"out.close();");
|
||||
box3.setAnchor(new Rectangle(30, 150, 618, 411));
|
||||
box3.setHorizontalCentered(true);
|
||||
}
|
||||
|
||||
public static void slide7(SlideShow<?,?> ppt) throws IOException {
|
||||
Slide<?,?> slide = ppt.createSlide();
|
||||
|
||||
TextBox<?,?> box2 = slide.createTextBox();
|
||||
box2.setHorizontalCentered(true);
|
||||
box2.setVerticalAlignment(VerticalAlignment.MIDDLE);
|
||||
box2.setText("Java Code");
|
||||
box2.setFillColor(new Color(187, 224, 227));
|
||||
box2.setStrokeStyle(0.75, Color.black);
|
||||
box2.setAnchor(new Rectangle(66, 243, 170, 170));
|
||||
|
||||
TextBox<?,?> box3 = slide.createTextBox();
|
||||
box3.setHorizontalCentered(true);
|
||||
box3.setVerticalAlignment(VerticalAlignment.MIDDLE);
|
||||
box3.setText("*.ppt file");
|
||||
box3.setFillColor(new Color(187, 224, 227));
|
||||
box3.setStrokeStyle(0.75, Color.black);
|
||||
box3.setAnchor(new Rectangle(473, 243, 170, 170));
|
||||
|
||||
AutoShape<?,?> box4 = slide.createAutoShape();
|
||||
box4.setShapeType(ShapeType.RIGHT_ARROW);
|
||||
box4.setFillColor(new Color(187, 224, 227));
|
||||
box4.setStrokeStyle(0.75, Color.black);
|
||||
box4.setAnchor(new Rectangle(253, 288, 198, 85));
|
||||
}
|
||||
|
||||
public static void slide8(SlideShow<?,?> ppt) throws IOException {
|
||||
Slide<?,?> slide = ppt.createSlide();
|
||||
|
||||
TextBox<?,?> box1 = slide.createTextBox();
|
||||
box1.setTextPlaceholder(TextPlaceholder.TITLE);
|
||||
box1.setText("Wait, there is more!");
|
||||
box1.setAnchor(new Rectangle(36, 21, 648, 90));
|
||||
|
||||
TextBox<?,?> box2 = slide.createTextBox();
|
||||
box2.setTextPlaceholder(TextPlaceholder.BODY);
|
||||
box2.setText(
|
||||
"Rich text\r" +
|
||||
"Tables\r" +
|
||||
"Pictures (JPEG, PNG, BMP, WMF, PICT)\r" +
|
||||
"Comprehensive formatting features");
|
||||
box2.setAnchor(new Rectangle(36, 126, 648, 356));
|
||||
}
|
||||
|
||||
public static void slide9(SlideShow<?,?> ppt) throws IOException {
|
||||
Slide<?,?> slide = ppt.createSlide();
|
||||
|
||||
TextBox<?,?> box1 = slide.createTextBox();
|
||||
box1.setTextPlaceholder(TextPlaceholder.TITLE);
|
||||
box1.setText("HSLF in Action - 3");
|
||||
box1.setAnchor(new Rectangle(36, 20, 648, 50));
|
||||
|
||||
TextBox<?,?> box2 = slide.createTextBox();
|
||||
box2.getTextParagraphs().get(0).getTextRuns().get(0).setFontSize(18d);
|
||||
box2.setText("PPGraphics2D: PowerPoint Graphics2D driver");
|
||||
box2.setAnchor(new Rectangle(178, 70, 387, 30));
|
||||
|
||||
TextBox<?,?> box3 = slide.createTextBox();
|
||||
TextRun rt3 = box3.getTextParagraphs().get(0).getTextRuns().get(0);
|
||||
rt3.setFontFamily("Courier New");
|
||||
rt3.setFontSize(8d);
|
||||
box3.setText(
|
||||
"//bar chart data. The first value is the bar color, the second is the width\u000b" +
|
||||
"Object[] def = new Object[]{\u000b" +
|
||||
" Color.yellow, new Integer(100),\u000b" +
|
||||
" Color.green, new Integer(150),\u000b" +
|
||||
" Color.gray, new Integer(75),\u000b" +
|
||||
" Color.red, new Integer(200),\u000b" +
|
||||
"};\u000b" +
|
||||
"\u000b" +
|
||||
"SlideShow ppt = new SlideShow();\u000b" +
|
||||
"Slide slide = ppt.createSlide();\u000b" +
|
||||
"\u000b" +
|
||||
"ShapeGroup group = new ShapeGroup();\u000b" +
|
||||
"//define position of the drawing in the slide\u000b" +
|
||||
"Rectangle bounds = new java.awt.Rectangle(200, 100, 350, 300);\u000b" +
|
||||
"group.setAnchor(bounds);\u000b" +
|
||||
"slide.addShape(group);\u000b" +
|
||||
"Graphics2D graphics = new PPGraphics2D(group);\u000b" +
|
||||
"\u000b" +
|
||||
"//draw a simple bar graph\u000b" +
|
||||
"int x = bounds.x + 50, y = bounds.y + 50;\u000b" +
|
||||
"graphics.setFont(new Font(\"Arial\", Font.BOLD, 10));\u000b" +
|
||||
"for (int i = 0, idx = 1; i < def.length; i+=2, idx++) {\u000b" +
|
||||
" graphics.setColor(Color.black);\u000b" +
|
||||
" int width = ((Integer)def[i+1]).intValue();\u000b" +
|
||||
" graphics.drawString(\"Q\" + idx, x-20, y+20);\u000b" +
|
||||
" graphics.drawString(width + \"%\", x + width + 10, y + 20);\u000b" +
|
||||
" graphics.setColor((Color)def[i]);\u000b" +
|
||||
" graphics.fill(new Rectangle(x, y, width, 30));\u000b" +
|
||||
" y += 40;\u000b" +
|
||||
"}\u000b" +
|
||||
"graphics.setColor(Color.black);\u000b" +
|
||||
"graphics.setFont(new Font(\"Arial\", Font.BOLD, 14));\u000b" +
|
||||
"graphics.draw(bounds);\u000b" +
|
||||
"graphics.drawString(\"Performance\", x + 70, y + 40);\u000b" +
|
||||
"\u000b" +
|
||||
"FileOutputStream out = new FileOutputStream(\"hslf-demo.ppt\");\u000b" +
|
||||
"ppt.write(out);\u000b" +
|
||||
"out.close();");
|
||||
box3.setAnchor(new Rectangle(96, 110, 499, 378));
|
||||
box3.setHorizontalCentered(true);
|
||||
}
|
||||
|
||||
public static void slide10(SlideShow<?,?> ppt) throws IOException {
|
||||
//bar chart data. The first value is the bar color, the second is the width
|
||||
Object[] def = new Object[]{
|
||||
Color.yellow, 100,
|
||||
Color.green, 150,
|
||||
Color.gray, 75,
|
||||
Color.red, 200,
|
||||
};
|
||||
|
||||
Slide<?,?> slide = ppt.createSlide();
|
||||
|
||||
GroupShape<?,?> group = slide.createGroup();
|
||||
//define position of the drawing in the slide
|
||||
Rectangle bounds = new java.awt.Rectangle(200, 100, 350, 300);
|
||||
group.setAnchor(bounds);
|
||||
Graphics2D graphics = new SLGraphics(group);
|
||||
|
||||
//draw a simple bar graph
|
||||
int x = bounds.x + 50;
|
||||
int y = bounds.y + 50;
|
||||
graphics.setFont(new Font("Arial", Font.BOLD, 10));
|
||||
for (int i = 0, idx = 1; i < def.length; i+=2, idx++) {
|
||||
graphics.setColor(Color.black);
|
||||
int width = (Integer) def[i + 1];
|
||||
graphics.drawString("Q" + idx, x-20, y+20);
|
||||
graphics.drawString(width + "%", x + width + 10, y + 20);
|
||||
graphics.setColor((Color)def[i]);
|
||||
graphics.fill(new Rectangle(x, y, width, 30));
|
||||
y += 40;
|
||||
}
|
||||
graphics.setColor(Color.black);
|
||||
graphics.setFont(new Font("Arial", Font.BOLD, 14));
|
||||
graphics.draw(bounds);
|
||||
graphics.drawString("Performance", x + 70, y + 40);
|
||||
|
||||
}
|
||||
|
||||
public static void slide11(SlideShow<?,?> ppt) throws IOException {
|
||||
Slide<?,?> slide = ppt.createSlide();
|
||||
|
||||
TextBox<?,?> box1 = slide.createTextBox();
|
||||
box1.setTextPlaceholder(TextPlaceholder.TITLE);
|
||||
box1.setText("HSLF Development Plans");
|
||||
box1.setAnchor(new Rectangle(36, 21, 648, 90));
|
||||
|
||||
TextBox<?,?> box2 = slide.createTextBox();
|
||||
box2.setTextPlaceholder(TextPlaceholder.BODY);
|
||||
box2.setText(
|
||||
"Support for more PowerPoint functionality\r" +
|
||||
"Rendering slides into java.awt.Graphics2D\r" +
|
||||
"A way to export slides into images or other formats\r" +
|
||||
"Integration with Apache FOP - Formatting Objects Processor\r" +
|
||||
"Transformation of XSL-FO into PPT\r" +
|
||||
"PPT2PDF transcoder"
|
||||
);
|
||||
|
||||
List<? extends TextParagraph<?,?,?>> tp = box2.getTextParagraphs();
|
||||
for (int i : new byte[]{0,1,3}) {
|
||||
tp.get(i).getTextRuns().get(0).setFontSize(28d);
|
||||
}
|
||||
for (int i : new byte[]{2,4,5}) {
|
||||
tp.get(i).getTextRuns().get(0).setFontSize(24d);
|
||||
tp.get(i).setIndentLevel(1);
|
||||
}
|
||||
|
||||
box2.setAnchor(new Rectangle(36, 126, 648, 400));
|
||||
}
|
||||
|
||||
public static void slide12(SlideShow<?,?> ppt) throws IOException {
|
||||
Slide<?,?> slide = ppt.createSlide();
|
||||
|
||||
TextBox<?,?> box1 = slide.createTextBox();
|
||||
box1.setTextPlaceholder(TextPlaceholder.CENTER_TITLE);
|
||||
box1.setText("Questions?");
|
||||
box1.setAnchor(new Rectangle(54, 167, 612, 115));
|
||||
|
||||
TextBox<?,?> box2 = slide.createTextBox();
|
||||
box2.setTextPlaceholder(TextPlaceholder.CENTER_BODY);
|
||||
box2.setText(
|
||||
"https://poi.apache.org/hslf/\r" +
|
||||
"http://people.apache.org/~yegor");
|
||||
box2.setAnchor(new Rectangle(108, 306, 504, 138));
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,60 @@
|
||||
/* ====================================================================
|
||||
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
contributor license agreements. See the NOTICE file distributed with
|
||||
this work for additional information regarding copyright ownership.
|
||||
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
(the "License"); you may not use this file except in compliance with
|
||||
the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
==================================================================== */
|
||||
|
||||
package org.apache.poi.examples.hslf;
|
||||
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.apache.poi.hslf.usermodel.HSLFSlide;
|
||||
import org.apache.poi.hslf.usermodel.HSLFSlideShow;
|
||||
import org.apache.poi.hslf.usermodel.HSLFTextBox;
|
||||
import org.apache.poi.hslf.usermodel.HSLFTextParagraph;
|
||||
|
||||
/**
|
||||
* How to create a single-level bulleted list
|
||||
* and change some of the bullet attributes
|
||||
*/
|
||||
public final class BulletsDemo {
|
||||
|
||||
public static void main(String[] args) throws IOException {
|
||||
try (HSLFSlideShow ppt = new HSLFSlideShow()) {
|
||||
HSLFSlide slide = ppt.createSlide();
|
||||
|
||||
HSLFTextBox shape = new HSLFTextBox();
|
||||
HSLFTextParagraph rt = shape.getTextParagraphs().get(0);
|
||||
rt.getTextRuns().get(0).setFontSize(42d);
|
||||
rt.setBullet(true);
|
||||
rt.setIndent(0d); //bullet offset
|
||||
rt.setLeftMargin(50d); //text offset (should be greater than bullet offset)
|
||||
rt.setBulletChar('\u263A'); //bullet character
|
||||
shape.setText(
|
||||
"January\r" +
|
||||
"February\r" +
|
||||
"March\r" +
|
||||
"April");
|
||||
slide.addShape(shape);
|
||||
|
||||
shape.setAnchor(new java.awt.Rectangle(50, 50, 500, 300)); //position of the text box in the slide
|
||||
slide.addShape(shape);
|
||||
|
||||
try (FileOutputStream out = new FileOutputStream("bullets.ppt")) {
|
||||
ppt.write(out);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,64 @@
|
||||
/* ====================================================================
|
||||
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
contributor license agreements. See the NOTICE file distributed with
|
||||
this work for additional information regarding copyright ownership.
|
||||
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
(the "License"); you may not use this file except in compliance with
|
||||
the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
==================================================================== */
|
||||
|
||||
package org.apache.poi.examples.hslf;
|
||||
|
||||
import java.awt.Rectangle;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.apache.poi.hslf.usermodel.HSLFHyperlink;
|
||||
import org.apache.poi.hslf.usermodel.HSLFSlide;
|
||||
import org.apache.poi.hslf.usermodel.HSLFSlideShow;
|
||||
import org.apache.poi.hslf.usermodel.HSLFTextBox;
|
||||
|
||||
/**
|
||||
* Demonstrates how to create hyperlinks in PowerPoint presentations
|
||||
*/
|
||||
public final class CreateHyperlink {
|
||||
|
||||
private CreateHyperlink() {}
|
||||
|
||||
public static void main(String[] args) throws IOException {
|
||||
try (HSLFSlideShow ppt = new HSLFSlideShow()) {
|
||||
HSLFSlide slideA = ppt.createSlide();
|
||||
ppt.createSlide();
|
||||
HSLFSlide slideC = ppt.createSlide();
|
||||
|
||||
// link to a URL
|
||||
HSLFTextBox textBox1 = slideA.createTextBox();
|
||||
textBox1.setText("Apache POI");
|
||||
textBox1.setAnchor(new Rectangle(100, 100, 200, 50));
|
||||
|
||||
HSLFHyperlink link1 = textBox1.getTextParagraphs().get(0).getTextRuns().get(0).createHyperlink();
|
||||
link1.linkToUrl("http://www.apache.org");
|
||||
link1.setLabel(textBox1.getText());
|
||||
|
||||
// link to another slide
|
||||
HSLFTextBox textBox2 = slideA.createTextBox();
|
||||
textBox2.setText("Go to slide #3");
|
||||
textBox2.setAnchor(new Rectangle(100, 300, 200, 50));
|
||||
|
||||
HSLFHyperlink link2 = textBox2.getTextParagraphs().get(0).getTextRuns().get(0).createHyperlink();
|
||||
link2.linkToSlide(slideC);
|
||||
|
||||
try (FileOutputStream out = new FileOutputStream("hyperlink.ppt")) {
|
||||
ppt.write(out);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,148 @@
|
||||
/* ====================================================================
|
||||
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
contributor license agreements. See the NOTICE file distributed with
|
||||
this work for additional information regarding copyright ownership.
|
||||
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
(the "License"); you may not use this file except in compliance with
|
||||
the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
==================================================================== */
|
||||
|
||||
package org.apache.poi.examples.hslf;
|
||||
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
import org.apache.poi.hslf.usermodel.HSLFObjectData;
|
||||
import org.apache.poi.hslf.usermodel.HSLFObjectShape;
|
||||
import org.apache.poi.hslf.usermodel.HSLFPictureData;
|
||||
import org.apache.poi.hslf.usermodel.HSLFPictureShape;
|
||||
import org.apache.poi.hslf.usermodel.HSLFShape;
|
||||
import org.apache.poi.hslf.usermodel.HSLFSlide;
|
||||
import org.apache.poi.hslf.usermodel.HSLFSlideShow;
|
||||
import org.apache.poi.hslf.usermodel.HSLFSoundData;
|
||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
||||
import org.apache.poi.hwpf.HWPFDocument;
|
||||
import org.apache.poi.hwpf.usermodel.Paragraph;
|
||||
import org.apache.poi.hwpf.usermodel.Range;
|
||||
import org.apache.poi.util.IOUtils;
|
||||
|
||||
/**
|
||||
* Demonstrates how you can extract misc embedded data from a ppt file
|
||||
*/
|
||||
@SuppressWarnings({"java:S106","java:S4823"})
|
||||
public final class DataExtraction {
|
||||
|
||||
private DataExtraction() {}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
|
||||
if (args.length == 0) {
|
||||
usage();
|
||||
return;
|
||||
}
|
||||
|
||||
try (FileInputStream fis = new FileInputStream(args[0]);
|
||||
HSLFSlideShow ppt = new HSLFSlideShow(fis)) {
|
||||
|
||||
//extract all sound files embedded in this presentation
|
||||
HSLFSoundData[] sound = ppt.getSoundData();
|
||||
for (HSLFSoundData aSound : sound) {
|
||||
handleSound(aSound);
|
||||
}
|
||||
|
||||
int oleIdx = -1;
|
||||
int picIdx = -1;
|
||||
for (HSLFSlide slide : ppt.getSlides()) {
|
||||
//extract embedded OLE documents
|
||||
for (HSLFShape shape : slide.getShapes()) {
|
||||
if (shape instanceof HSLFObjectShape) {
|
||||
handleShape((HSLFObjectShape) shape, ++oleIdx);
|
||||
} else if (shape instanceof HSLFPictureShape) {
|
||||
handlePicture((HSLFPictureShape) shape, ++picIdx);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void handleShape(HSLFObjectShape ole, int oleIdx) throws IOException {
|
||||
HSLFObjectData data = ole.getObjectData();
|
||||
String name = ole.getInstanceName();
|
||||
switch (name == null ? "" : name) {
|
||||
case "Worksheet":
|
||||
//read xls
|
||||
handleWorkbook(data, name, oleIdx);
|
||||
break;
|
||||
case "Document":
|
||||
//read the word document
|
||||
handleDocument(data, name, oleIdx);
|
||||
break;
|
||||
default:
|
||||
handleUnknown(data, ole.getProgId(), oleIdx);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static void handleWorkbook(HSLFObjectData data, String name, int oleIdx) throws IOException {
|
||||
try (InputStream is = data.getInputStream();
|
||||
HSSFWorkbook wb = new HSSFWorkbook(is);
|
||||
FileOutputStream out = new FileOutputStream(name + "-(" + (oleIdx) + ").xls")) {
|
||||
wb.write(out);
|
||||
}
|
||||
}
|
||||
|
||||
private static void handleDocument(HSLFObjectData data, String name, int oleIdx) throws IOException {
|
||||
try (InputStream is = data.getInputStream();
|
||||
HWPFDocument doc = new HWPFDocument(is);
|
||||
FileOutputStream out = new FileOutputStream(name + "-(" + (oleIdx) + ").doc")) {
|
||||
Range r = doc.getRange();
|
||||
for (int k = 0; k < r.numParagraphs(); k++) {
|
||||
Paragraph p = r.getParagraph(k);
|
||||
System.out.println(p.text());
|
||||
}
|
||||
|
||||
//save on disk
|
||||
doc.write(out);
|
||||
}
|
||||
}
|
||||
|
||||
private static void handleUnknown(HSLFObjectData data, String name, int oleIdx) throws IOException {
|
||||
try (InputStream is = data.getInputStream();
|
||||
FileOutputStream out = new FileOutputStream(name + "-" + (oleIdx + 1) + ".dat")) {
|
||||
IOUtils.copy(is, out);
|
||||
}
|
||||
}
|
||||
|
||||
private static void handlePicture(HSLFPictureShape p, int picIdx) throws IOException {
|
||||
HSLFPictureData data = p.getPictureData();
|
||||
String ext = data.getType().extension;
|
||||
try (FileOutputStream out = new FileOutputStream("pict-" + picIdx + ext)) {
|
||||
out.write(data.getData());
|
||||
}
|
||||
}
|
||||
|
||||
private static void handleSound(HSLFSoundData aSound) throws IOException {
|
||||
String type = aSound.getSoundType(); //*.wav
|
||||
String name = aSound.getSoundName(); //typically file name
|
||||
|
||||
//save the sound on disk
|
||||
try (FileOutputStream out = new FileOutputStream(name + type)) {
|
||||
out.write(aSound.getData());
|
||||
}
|
||||
}
|
||||
|
||||
private static void usage(){
|
||||
System.out.println("Usage: DataExtraction ppt");
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,82 @@
|
||||
/* ====================================================================
|
||||
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
contributor license agreements. See the NOTICE file distributed with
|
||||
this work for additional information regarding copyright ownership.
|
||||
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
(the "License"); you may not use this file except in compliance with
|
||||
the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
==================================================================== */
|
||||
|
||||
package org.apache.poi.examples.hslf;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Font;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Rectangle;
|
||||
import java.io.FileOutputStream;
|
||||
|
||||
import org.apache.poi.hslf.usermodel.HSLFGroupShape;
|
||||
import org.apache.poi.hslf.usermodel.HSLFSlide;
|
||||
import org.apache.poi.hslf.usermodel.HSLFSlideShow;
|
||||
import org.apache.poi.sl.draw.SLGraphics;
|
||||
|
||||
/**
|
||||
* Demonstrates how to draw into a slide using the HSLF Graphics2D driver.
|
||||
*/
|
||||
public final class Graphics2DDemo {
|
||||
|
||||
private Graphics2DDemo() {}
|
||||
|
||||
/**
|
||||
* A simple bar chart demo
|
||||
*/
|
||||
public static void main(String[] args) throws Exception {
|
||||
try (HSLFSlideShow ppt = new HSLFSlideShow();
|
||||
FileOutputStream out = new FileOutputStream("hslf-graphics.ppt")) {
|
||||
//bar chart data. The first value is the bar color, the second is the width
|
||||
Object[] def = {
|
||||
Color.yellow, 40,
|
||||
Color.green, 60,
|
||||
Color.gray, 30,
|
||||
Color.red, 80,
|
||||
};
|
||||
|
||||
HSLFSlide slide = ppt.createSlide();
|
||||
|
||||
HSLFGroupShape group = new HSLFGroupShape();
|
||||
//define position of the drawing in the slide
|
||||
Rectangle bounds = new Rectangle(200, 100, 350, 300);
|
||||
group.setAnchor(bounds);
|
||||
group.setInteriorAnchor(new Rectangle(0, 0, 100, 100));
|
||||
slide.addShape(group);
|
||||
Graphics2D graphics = new SLGraphics(group);
|
||||
|
||||
//draw a simple bar graph
|
||||
int x = 10, y = 10;
|
||||
graphics.setFont(new Font("Arial", Font.BOLD, 10));
|
||||
for (int i = 0, idx = 1; i < def.length; i += 2, idx++) {
|
||||
graphics.setColor(Color.black);
|
||||
int width = (Integer) def[i + 1];
|
||||
graphics.drawString("Q" + idx, x - 5, y + 10);
|
||||
graphics.drawString(width + "%", x + width + 3, y + 10);
|
||||
graphics.setColor((Color) def[i]);
|
||||
graphics.fill(new Rectangle(x, y, width, 10));
|
||||
y += 15;
|
||||
}
|
||||
graphics.setColor(Color.black);
|
||||
graphics.setFont(new Font("Arial", Font.BOLD, 14));
|
||||
graphics.draw(group.getInteriorAnchor());
|
||||
graphics.drawString("Performance", x + 30, y + 10);
|
||||
|
||||
ppt.write(out);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,50 @@
|
||||
/* ====================================================================
|
||||
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
contributor license agreements. See the NOTICE file distributed with
|
||||
this work for additional information regarding copyright ownership.
|
||||
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
(the "License"); you may not use this file except in compliance with
|
||||
the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
==================================================================== */
|
||||
package org.apache.poi.examples.hslf;
|
||||
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.apache.poi.hslf.model.HeadersFooters;
|
||||
import org.apache.poi.hslf.usermodel.HSLFSlideShow;
|
||||
|
||||
/**
|
||||
* Demonstrates how to set headers / footers
|
||||
*/
|
||||
public final class HeadersFootersDemo {
|
||||
private HeadersFootersDemo() {}
|
||||
|
||||
public static void main(String[] args) throws IOException {
|
||||
try (HSLFSlideShow ppt = new HSLFSlideShow()) {
|
||||
HeadersFooters slideHeaders = ppt.getSlideHeadersFooters();
|
||||
slideHeaders.setFootersText("Created by POI-HSLF");
|
||||
slideHeaders.setSlideNumberVisible(true);
|
||||
slideHeaders.setDateTimeText("custom date time");
|
||||
|
||||
HeadersFooters notesHeaders = ppt.getNotesHeadersFooters();
|
||||
notesHeaders.setFootersText("My notes footers");
|
||||
notesHeaders.setHeaderText("My notes header");
|
||||
|
||||
ppt.createSlide();
|
||||
|
||||
try (FileOutputStream out = new FileOutputStream("headers_footers.ppt")) {
|
||||
ppt.write(out);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,77 @@
|
||||
/* ====================================================================
|
||||
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
contributor license agreements. See the NOTICE file distributed with
|
||||
this work for additional information regarding copyright ownership.
|
||||
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
(the "License"); you may not use this file except in compliance with
|
||||
the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
==================================================================== */
|
||||
|
||||
package org.apache.poi.examples.hslf;
|
||||
|
||||
import java.io.FileInputStream;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import org.apache.poi.hslf.usermodel.HSLFHyperlink;
|
||||
import org.apache.poi.hslf.usermodel.HSLFSimpleShape;
|
||||
import org.apache.poi.hslf.usermodel.HSLFSlide;
|
||||
import org.apache.poi.hslf.usermodel.HSLFSlideShow;
|
||||
import org.apache.poi.hslf.usermodel.HSLFTextParagraph;
|
||||
import org.apache.poi.hslf.usermodel.HSLFTextRun;
|
||||
|
||||
/**
|
||||
* Demonstrates how to read hyperlinks from a presentation
|
||||
*/
|
||||
@SuppressWarnings({"java:S106", "java:S4823"})
|
||||
public final class Hyperlinks {
|
||||
|
||||
private Hyperlinks() {}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
for (String arg : args) {
|
||||
try (FileInputStream is = new FileInputStream(arg);
|
||||
HSLFSlideShow ppt = new HSLFSlideShow(is)) {
|
||||
|
||||
for (HSLFSlide slide : ppt.getSlides()) {
|
||||
System.out.println("\nslide " + slide.getSlideNumber());
|
||||
|
||||
// read hyperlinks from the slide's text runs
|
||||
System.out.println("- reading hyperlinks from the text runs");
|
||||
slide.getTextParagraphs().stream().
|
||||
flatMap(List::stream).
|
||||
map(HSLFTextParagraph::getTextRuns).
|
||||
flatMap(List::stream).
|
||||
forEach(run -> out(run.getHyperlink(), run));
|
||||
|
||||
// in PowerPoint you can assign a hyperlink to a shape without text,
|
||||
// for example to a Line object. The code below demonstrates how to
|
||||
// read such hyperlinks
|
||||
System.out.println("- reading hyperlinks from the slide's shapes");
|
||||
slide.getShapes().stream().
|
||||
filter(sh -> sh instanceof HSLFSimpleShape).
|
||||
forEach(sh -> out(((HSLFSimpleShape) sh).getHyperlink(), null));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void out(HSLFHyperlink link, HSLFTextRun run) {
|
||||
if (link == null) {
|
||||
return;
|
||||
}
|
||||
String rawText = run == null ? null : run.getRawText();
|
||||
//in ppt end index is inclusive
|
||||
String formatStr = "title: %1$s, address: %2$s" + (rawText == null ? "" : ", start: %3$s, end: %4$s, substring: %5$s");
|
||||
String line = String.format(Locale.ROOT, formatStr, link.getLabel(), link.getAddress(), link.getStartIndex(), link.getEndIndex(), rawText);
|
||||
System.out.println(line);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,69 @@
|
||||
/* ====================================================================
|
||||
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
contributor license agreements. See the NOTICE file distributed with
|
||||
this work for additional information regarding copyright ownership.
|
||||
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
(the "License"); you may not use this file except in compliance with
|
||||
the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
==================================================================== */
|
||||
package org.apache.poi.examples.hslf;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.apache.poi.hslf.record.InteractiveInfoAtom;
|
||||
import org.apache.poi.hslf.record.RecordTypes;
|
||||
import org.apache.poi.hslf.usermodel.HSLFShape;
|
||||
import org.apache.poi.hslf.usermodel.HSLFSlide;
|
||||
import org.apache.poi.hslf.usermodel.HSLFSlideShow;
|
||||
import org.apache.poi.hslf.usermodel.HSLFSoundData;
|
||||
|
||||
/**
|
||||
* For each slide iterate over shapes and found associated sound data.
|
||||
*/
|
||||
@SuppressWarnings({"java:S106", "java:S4823"})
|
||||
public final class SoundFinder {
|
||||
private SoundFinder() {}
|
||||
|
||||
public static void main(String[] args) throws IOException {
|
||||
try (FileInputStream fis = new FileInputStream(args[0])) {
|
||||
try (HSLFSlideShow ppt = new HSLFSlideShow(fis)) {
|
||||
HSLFSoundData[] sounds = ppt.getSoundData();
|
||||
|
||||
for (HSLFSlide slide : ppt.getSlides()) {
|
||||
for (HSLFShape shape : slide.getShapes()) {
|
||||
int soundRef = getSoundReference(shape);
|
||||
if (soundRef == -1) continue;
|
||||
|
||||
|
||||
System.out.println("Slide[" + slide.getSlideNumber() + "], shape[" + shape.getShapeId() + "], soundRef: " + soundRef);
|
||||
System.out.println(" " + sounds[soundRef].getSoundName());
|
||||
System.out.println(" " + sounds[soundRef].getSoundType());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a given shape is associated with a sound.
|
||||
* @return 0-based reference to a sound in the sound collection
|
||||
* or -1 if the shape is not associated with a sound
|
||||
*/
|
||||
private static int getSoundReference(HSLFShape shape){
|
||||
int soundRef = -1;
|
||||
//dive into the shape container and search for InteractiveInfoAtom
|
||||
InteractiveInfoAtom info = shape.getClientDataRecord(RecordTypes.InteractiveInfo.typeID);
|
||||
if (info != null && info.getAction() == InteractiveInfoAtom.ACTION_MEDIA) {
|
||||
soundRef = info.getSoundRef();
|
||||
}
|
||||
return soundRef;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,132 @@
|
||||
/* ====================================================================
|
||||
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
contributor license agreements. See the NOTICE file distributed with
|
||||
this work for additional information regarding copyright ownership.
|
||||
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
(the "License"); you may not use this file except in compliance with
|
||||
the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
==================================================================== */
|
||||
|
||||
package org.apache.poi.examples.hslf;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.io.FileOutputStream;
|
||||
|
||||
import org.apache.poi.hslf.usermodel.HSLFSlide;
|
||||
import org.apache.poi.hslf.usermodel.HSLFSlideShow;
|
||||
import org.apache.poi.hslf.usermodel.HSLFTable;
|
||||
import org.apache.poi.hslf.usermodel.HSLFTableCell;
|
||||
import org.apache.poi.hslf.usermodel.HSLFTextRun;
|
||||
import org.apache.poi.sl.draw.DrawTableShape;
|
||||
import org.apache.poi.sl.usermodel.TextParagraph.TextAlign;
|
||||
import org.apache.poi.sl.usermodel.VerticalAlignment;
|
||||
|
||||
/**
|
||||
* Demonstrates how to create tables
|
||||
*/
|
||||
public final class TableDemo {
|
||||
|
||||
//test data for the first table
|
||||
static final String[][] txt1 = {
|
||||
{"INPUT FILE", "NUMBER OF RECORDS"},
|
||||
{"Item File", "11,559"},
|
||||
{"Vendor File", "502"},
|
||||
{"Purchase History File - # of PO\u2019s\r(12/01/04 - 05/31/06)", "12,852"},
|
||||
{"Purchase History File - # of PO Lines\r(12/01/04 - 05/31/06)", "53,523" },
|
||||
{"Total PO History Spend", "$10,172,038"}
|
||||
};
|
||||
|
||||
//test data for the second taable
|
||||
static final String[][] txt2 = {
|
||||
{"Data Source"},
|
||||
{"CAS Internal Metrics - Item Master Summary\r" +
|
||||
"CAS Internal Metrics - Vendor Summary\r" +
|
||||
"CAS Internal Metrics - PO History Summary"}
|
||||
};
|
||||
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
try (HSLFSlideShow ppt = new HSLFSlideShow()) {
|
||||
HSLFSlide slide = ppt.createSlide();
|
||||
create1stTable(slide);
|
||||
create2ndTable(slide);
|
||||
|
||||
try (FileOutputStream out = new FileOutputStream("hslf-table.ppt")) {
|
||||
ppt.write(out);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void create1stTable(HSLFSlide slide) {
|
||||
//six rows, two columns
|
||||
HSLFTable table1 = slide.createTable(6, 2);
|
||||
for (int i = 0; i < txt1.length; i++) {
|
||||
for (int j = 0; j < txt1[i].length; j++) {
|
||||
HSLFTableCell cell = table1.getCell(i, j);
|
||||
HSLFTextRun rt = cell.getTextParagraphs().get(0).getTextRuns().get(0);
|
||||
rt.setFontFamily("Arial");
|
||||
rt.setFontSize(10d);
|
||||
if(i == 0){
|
||||
cell.getFill().setForegroundColor(new Color(227, 227, 227));
|
||||
} else {
|
||||
rt.setBold(true);
|
||||
}
|
||||
cell.setVerticalAlignment(VerticalAlignment.MIDDLE);
|
||||
cell.setHorizontalCentered(true);
|
||||
cell.setText(txt1[i][j]);
|
||||
}
|
||||
}
|
||||
|
||||
DrawTableShape dts1 = new DrawTableShape(table1);
|
||||
dts1.setAllBorders(1.0, Color.black);
|
||||
|
||||
table1.setColumnWidth(0, 300);
|
||||
table1.setColumnWidth(1, 150);
|
||||
|
||||
int pgWidth = slide.getSlideShow().getPageSize().width;
|
||||
table1.moveTo((pgWidth - table1.getAnchor().getWidth())/2., 100.);
|
||||
}
|
||||
|
||||
static void create2ndTable(HSLFSlide slide) {
|
||||
//two rows, one column
|
||||
HSLFTable table2 = slide.createTable(2, 1);
|
||||
for (int i = 0; i < txt2.length; i++) {
|
||||
for (int j = 0; j < txt2[i].length; j++) {
|
||||
HSLFTableCell cell = table2.getCell(i, j);
|
||||
HSLFTextRun rt = cell.getTextParagraphs().get(0).getTextRuns().get(0);
|
||||
rt.setFontSize(10d);
|
||||
rt.setFontFamily("Arial");
|
||||
if(i == 0){
|
||||
cell.getFill().setForegroundColor(new Color(0, 51, 102));
|
||||
rt.setFontColor(Color.white);
|
||||
rt.setBold(true);
|
||||
rt.setFontSize(14d);
|
||||
cell.setHorizontalCentered(true);
|
||||
} else {
|
||||
rt.getTextParagraph().setBullet(true);
|
||||
rt.setFontSize(12d);
|
||||
rt.getTextParagraph().setTextAlign(TextAlign.LEFT);
|
||||
cell.setHorizontalCentered(false);
|
||||
}
|
||||
cell.setVerticalAlignment(VerticalAlignment.MIDDLE);
|
||||
cell.setText(txt2[i][j]);
|
||||
}
|
||||
}
|
||||
table2.setColumnWidth(0, 300);
|
||||
table2.setRowHeight(0, 30);
|
||||
table2.setRowHeight(1, 70);
|
||||
|
||||
DrawTableShape dts2 = new DrawTableShape(table2);
|
||||
dts2.setOutsideBorders(Color.black, 1.0);
|
||||
|
||||
table2.moveTo(200, 400);
|
||||
}
|
||||
}
|
||||
158
log4j/src/examples/src/org/apache/poi/examples/hsmf/Msg2txt.java
Normal file
158
log4j/src/examples/src/org/apache/poi/examples/hsmf/Msg2txt.java
Normal file
@ -0,0 +1,158 @@
|
||||
/* ====================================================================
|
||||
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
contributor license agreements. See the NOTICE file distributed with
|
||||
this work for additional information regarding copyright ownership.
|
||||
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
(the "License"); you may not use this file except in compliance with
|
||||
the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
==================================================================== */
|
||||
|
||||
package org.apache.poi.examples.hsmf;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.io.PrintWriter;
|
||||
|
||||
import org.apache.poi.hsmf.MAPIMessage;
|
||||
import org.apache.poi.hsmf.datatypes.AttachmentChunks;
|
||||
import org.apache.poi.hsmf.exceptions.ChunkNotFoundException;
|
||||
|
||||
/**
|
||||
* Reads one or several Outlook MSG files and for each of them creates
|
||||
* a text file from available chunks and a directory that contains
|
||||
* attachments.
|
||||
*/
|
||||
@SuppressWarnings({"java:S106","java:S4823"})
|
||||
public class Msg2txt {
|
||||
|
||||
/**
|
||||
* The stem used to create file names for the text file and the directory
|
||||
* that contains the attachments.
|
||||
*/
|
||||
private String fileNameStem;
|
||||
|
||||
/**
|
||||
* The Outlook MSG file being processed.
|
||||
*/
|
||||
private MAPIMessage msg;
|
||||
|
||||
public Msg2txt(String fileName) throws IOException {
|
||||
fileNameStem = fileName;
|
||||
if(fileNameStem.endsWith(".msg") || fileNameStem.endsWith(".MSG")) {
|
||||
fileNameStem = fileNameStem.substring(0, fileNameStem.length() - 4);
|
||||
}
|
||||
msg = new MAPIMessage(fileName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Processes the message.
|
||||
*
|
||||
* @throws IOException if an exception occurs while writing the message out
|
||||
*/
|
||||
public void processMessage() throws IOException {
|
||||
String txtFileName = fileNameStem + ".txt";
|
||||
String attDirName = fileNameStem + "-att";
|
||||
try (PrintWriter txtOut = new PrintWriter(txtFileName, "UTF-8")) {
|
||||
try {
|
||||
String displayFrom = msg.getDisplayFrom();
|
||||
txtOut.println("From: " + displayFrom);
|
||||
} catch (ChunkNotFoundException e) {
|
||||
// ignore
|
||||
}
|
||||
try {
|
||||
String displayTo = msg.getDisplayTo();
|
||||
txtOut.println("To: " + displayTo);
|
||||
} catch (ChunkNotFoundException e) {
|
||||
// ignore
|
||||
}
|
||||
try {
|
||||
String displayCC = msg.getDisplayCC();
|
||||
txtOut.println("CC: " + displayCC);
|
||||
} catch (ChunkNotFoundException e) {
|
||||
// ignore
|
||||
}
|
||||
try {
|
||||
String displayBCC = msg.getDisplayBCC();
|
||||
txtOut.println("BCC: " + displayBCC);
|
||||
} catch (ChunkNotFoundException e) {
|
||||
// ignore
|
||||
}
|
||||
try {
|
||||
String subject = msg.getSubject();
|
||||
txtOut.println("Subject: " + subject);
|
||||
} catch (ChunkNotFoundException e) {
|
||||
// ignore
|
||||
}
|
||||
try {
|
||||
String body = msg.getTextBody();
|
||||
txtOut.println(body);
|
||||
} catch (ChunkNotFoundException e) {
|
||||
System.err.println("No message body");
|
||||
}
|
||||
|
||||
AttachmentChunks[] attachments = msg.getAttachmentFiles();
|
||||
if (attachments.length > 0) {
|
||||
File d = new File(attDirName);
|
||||
if (d.mkdir()) {
|
||||
for (AttachmentChunks attachment : attachments) {
|
||||
processAttachment(attachment, d);
|
||||
}
|
||||
} else {
|
||||
System.err.println("Can't create directory " + attDirName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Processes a single attachment: reads it from the Outlook MSG file and
|
||||
* writes it to disk as an individual file.
|
||||
*
|
||||
* @param attachment the chunk group describing the attachment
|
||||
* @param dir the directory in which to write the attachment file
|
||||
* @throws IOException when any of the file operations fails
|
||||
*/
|
||||
public void processAttachment(AttachmentChunks attachment,
|
||||
File dir) throws IOException {
|
||||
String fileName = attachment.getAttachFileName().toString();
|
||||
if(attachment.getAttachLongFileName() != null) {
|
||||
fileName = attachment.getAttachLongFileName().toString();
|
||||
}
|
||||
|
||||
File f = new File(dir, fileName);
|
||||
try (OutputStream fileOut = new FileOutputStream(f)) {
|
||||
fileOut.write(attachment.getAttachData().getValue());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Processes the list of arguments as a list of names of Outlook MSG files.
|
||||
*
|
||||
* @param args the list of MSG files to process
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
if(args.length <= 0) {
|
||||
System.err.println("No files names provided");
|
||||
} else {
|
||||
for (String arg : args) {
|
||||
try {
|
||||
Msg2txt processor = new Msg2txt(arg);
|
||||
processor.processMessage();
|
||||
} catch (IOException e) {
|
||||
System.err.println("Could not process " + arg + ": " + e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,326 @@
|
||||
/* ====================================================================
|
||||
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
contributor license agreements. See the NOTICE file distributed with
|
||||
this work for additional information regarding copyright ownership.
|
||||
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
(the "License"); you may not use this file except in compliance with
|
||||
the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
==================================================================== */
|
||||
|
||||
package org.apache.poi.examples.hssf.eventusermodel;
|
||||
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.poi.hssf.eventusermodel.EventWorkbookBuilder.SheetRecordCollectingListener;
|
||||
import org.apache.poi.hssf.eventusermodel.FormatTrackingHSSFListener;
|
||||
import org.apache.poi.hssf.eventusermodel.HSSFEventFactory;
|
||||
import org.apache.poi.hssf.eventusermodel.HSSFListener;
|
||||
import org.apache.poi.hssf.eventusermodel.HSSFRequest;
|
||||
import org.apache.poi.hssf.eventusermodel.MissingRecordAwareHSSFListener;
|
||||
import org.apache.poi.hssf.eventusermodel.dummyrecord.LastCellOfRowDummyRecord;
|
||||
import org.apache.poi.hssf.eventusermodel.dummyrecord.MissingCellDummyRecord;
|
||||
import org.apache.poi.hssf.model.HSSFFormulaParser;
|
||||
import org.apache.poi.hssf.record.BOFRecord;
|
||||
import org.apache.poi.hssf.record.BlankRecord;
|
||||
import org.apache.poi.hssf.record.BoolErrRecord;
|
||||
import org.apache.poi.hssf.record.BoundSheetRecord;
|
||||
import org.apache.poi.hssf.record.FormulaRecord;
|
||||
import org.apache.poi.hssf.record.LabelRecord;
|
||||
import org.apache.poi.hssf.record.LabelSSTRecord;
|
||||
import org.apache.poi.hssf.record.NoteRecord;
|
||||
import org.apache.poi.hssf.record.NumberRecord;
|
||||
import org.apache.poi.hssf.record.RKRecord;
|
||||
import org.apache.poi.hssf.record.SSTRecord;
|
||||
import org.apache.poi.hssf.record.StringRecord;
|
||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
||||
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
|
||||
|
||||
/**
|
||||
* A XLS -> CSV processor, that uses the MissingRecordAware
|
||||
* EventModel code to ensure it outputs all columns and rows.
|
||||
* @author Nick Burch
|
||||
*/
|
||||
@SuppressWarnings({"java:S106","java:S4823"})
|
||||
public class XLS2CSVmra implements HSSFListener {
|
||||
private final int minColumns;
|
||||
private final POIFSFileSystem fs;
|
||||
private final PrintStream output;
|
||||
|
||||
private int lastRowNumber;
|
||||
private int lastColumnNumber;
|
||||
|
||||
/** Should we output the formula, or the value it has? */
|
||||
private final boolean outputFormulaValues = true;
|
||||
|
||||
/** For parsing Formulas */
|
||||
private SheetRecordCollectingListener workbookBuildingListener;
|
||||
private HSSFWorkbook stubWorkbook;
|
||||
|
||||
// Records we pick up as we process
|
||||
private SSTRecord sstRecord;
|
||||
private FormatTrackingHSSFListener formatListener;
|
||||
|
||||
/** So we known which sheet we're on */
|
||||
private int sheetIndex = -1;
|
||||
private BoundSheetRecord[] orderedBSRs;
|
||||
private final List<BoundSheetRecord> boundSheetRecords = new ArrayList<>();
|
||||
|
||||
// For handling formulas with string results
|
||||
private int nextRow;
|
||||
private int nextColumn;
|
||||
private boolean outputNextStringRecord;
|
||||
|
||||
/**
|
||||
* Creates a new XLS -> CSV converter
|
||||
* @param fs The POIFSFileSystem to process
|
||||
* @param output The PrintStream to output the CSV to
|
||||
* @param minColumns The minimum number of columns to output, or -1 for no minimum
|
||||
*/
|
||||
public XLS2CSVmra(POIFSFileSystem fs, PrintStream output, int minColumns) {
|
||||
this.fs = fs;
|
||||
this.output = output;
|
||||
this.minColumns = minColumns;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new XLS -> CSV converter
|
||||
* @param filename The file to process
|
||||
* @param minColumns The minimum number of columns to output, or -1 for no minimum
|
||||
*/
|
||||
public XLS2CSVmra(String filename, int minColumns) throws IOException {
|
||||
this(
|
||||
new POIFSFileSystem(new FileInputStream(filename)),
|
||||
System.out, minColumns
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initiates the processing of the XLS file to CSV
|
||||
*/
|
||||
public void process() throws IOException {
|
||||
MissingRecordAwareHSSFListener listener = new MissingRecordAwareHSSFListener(this);
|
||||
formatListener = new FormatTrackingHSSFListener(listener);
|
||||
|
||||
HSSFEventFactory factory = new HSSFEventFactory();
|
||||
HSSFRequest request = new HSSFRequest();
|
||||
|
||||
if(outputFormulaValues) {
|
||||
request.addListenerForAllRecords(formatListener);
|
||||
} else {
|
||||
workbookBuildingListener = new SheetRecordCollectingListener(formatListener);
|
||||
request.addListenerForAllRecords(workbookBuildingListener);
|
||||
}
|
||||
|
||||
factory.processWorkbookEvents(request, fs);
|
||||
}
|
||||
|
||||
/**
|
||||
* Main HSSFListener method, processes events, and outputs the
|
||||
* CSV as the file is processed.
|
||||
*/
|
||||
@Override
|
||||
public void processRecord(org.apache.poi.hssf.record.Record record) {
|
||||
int thisRow = -1;
|
||||
int thisColumn = -1;
|
||||
String thisStr = null;
|
||||
|
||||
switch (record.getSid())
|
||||
{
|
||||
case BoundSheetRecord.sid:
|
||||
boundSheetRecords.add((BoundSheetRecord)record);
|
||||
break;
|
||||
case BOFRecord.sid:
|
||||
BOFRecord br = (BOFRecord)record;
|
||||
if(br.getType() == BOFRecord.TYPE_WORKSHEET) {
|
||||
// Create sub workbook if required
|
||||
if(workbookBuildingListener != null && stubWorkbook == null) {
|
||||
stubWorkbook = workbookBuildingListener.getStubHSSFWorkbook();
|
||||
}
|
||||
|
||||
// Output the worksheet name
|
||||
// Works by ordering the BSRs by the location of
|
||||
// their BOFRecords, and then knowing that we
|
||||
// process BOFRecords in byte offset order
|
||||
sheetIndex++;
|
||||
if(orderedBSRs == null) {
|
||||
orderedBSRs = BoundSheetRecord.orderByBofPosition(boundSheetRecords);
|
||||
}
|
||||
output.println();
|
||||
output.println(
|
||||
orderedBSRs[sheetIndex].getSheetname() +
|
||||
" [" + (sheetIndex+1) + "]:"
|
||||
);
|
||||
}
|
||||
break;
|
||||
|
||||
case SSTRecord.sid:
|
||||
sstRecord = (SSTRecord) record;
|
||||
break;
|
||||
|
||||
case BlankRecord.sid:
|
||||
BlankRecord brec = (BlankRecord) record;
|
||||
|
||||
thisRow = brec.getRow();
|
||||
thisColumn = brec.getColumn();
|
||||
thisStr = "";
|
||||
break;
|
||||
case BoolErrRecord.sid:
|
||||
BoolErrRecord berec = (BoolErrRecord) record;
|
||||
|
||||
thisRow = berec.getRow();
|
||||
thisColumn = berec.getColumn();
|
||||
thisStr = "";
|
||||
break;
|
||||
|
||||
case FormulaRecord.sid:
|
||||
FormulaRecord frec = (FormulaRecord) record;
|
||||
|
||||
thisRow = frec.getRow();
|
||||
thisColumn = frec.getColumn();
|
||||
|
||||
if(outputFormulaValues) {
|
||||
if(Double.isNaN( frec.getValue() )) {
|
||||
// Formula result is a string
|
||||
// This is stored in the next record
|
||||
outputNextStringRecord = true;
|
||||
nextRow = frec.getRow();
|
||||
nextColumn = frec.getColumn();
|
||||
} else {
|
||||
thisStr = formatListener.formatNumberDateCell(frec);
|
||||
}
|
||||
} else {
|
||||
thisStr = '"' +
|
||||
HSSFFormulaParser.toFormulaString(stubWorkbook, frec.getParsedExpression()) + '"';
|
||||
}
|
||||
break;
|
||||
case StringRecord.sid:
|
||||
if(outputNextStringRecord) {
|
||||
// String for formula
|
||||
StringRecord srec = (StringRecord)record;
|
||||
thisStr = srec.getString();
|
||||
thisRow = nextRow;
|
||||
thisColumn = nextColumn;
|
||||
outputNextStringRecord = false;
|
||||
}
|
||||
break;
|
||||
|
||||
case LabelRecord.sid:
|
||||
LabelRecord lrec = (LabelRecord) record;
|
||||
|
||||
thisRow = lrec.getRow();
|
||||
thisColumn = lrec.getColumn();
|
||||
thisStr = '"' + lrec.getValue() + '"';
|
||||
break;
|
||||
case LabelSSTRecord.sid:
|
||||
LabelSSTRecord lsrec = (LabelSSTRecord) record;
|
||||
|
||||
thisRow = lsrec.getRow();
|
||||
thisColumn = lsrec.getColumn();
|
||||
if(sstRecord == null) {
|
||||
thisStr = '"' + "(No SST Record, can't identify string)" + '"';
|
||||
} else {
|
||||
thisStr = '"' + sstRecord.getString(lsrec.getSSTIndex()).toString() + '"';
|
||||
}
|
||||
break;
|
||||
case NoteRecord.sid:
|
||||
NoteRecord nrec = (NoteRecord) record;
|
||||
|
||||
thisRow = nrec.getRow();
|
||||
thisColumn = nrec.getColumn();
|
||||
// TODO: Find object to match nrec.getShapeId()
|
||||
thisStr = '"' + "(TODO)" + '"';
|
||||
break;
|
||||
case NumberRecord.sid:
|
||||
NumberRecord numrec = (NumberRecord) record;
|
||||
|
||||
thisRow = numrec.getRow();
|
||||
thisColumn = numrec.getColumn();
|
||||
|
||||
// Format
|
||||
thisStr = formatListener.formatNumberDateCell(numrec);
|
||||
break;
|
||||
case RKRecord.sid:
|
||||
RKRecord rkrec = (RKRecord) record;
|
||||
|
||||
thisRow = rkrec.getRow();
|
||||
thisColumn = rkrec.getColumn();
|
||||
thisStr = '"' + "(TODO)" + '"';
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
// Handle new row
|
||||
if(thisRow != -1 && thisRow != lastRowNumber) {
|
||||
lastColumnNumber = -1;
|
||||
}
|
||||
|
||||
// Handle missing column
|
||||
if(record instanceof MissingCellDummyRecord) {
|
||||
MissingCellDummyRecord mc = (MissingCellDummyRecord)record;
|
||||
thisRow = mc.getRow();
|
||||
thisColumn = mc.getColumn();
|
||||
thisStr = "";
|
||||
}
|
||||
|
||||
// If we got something to print out, do so
|
||||
if(thisStr != null) {
|
||||
if(thisColumn > 0) {
|
||||
output.print(',');
|
||||
}
|
||||
output.print(thisStr);
|
||||
}
|
||||
|
||||
// Update column and row count
|
||||
if(thisRow > -1)
|
||||
lastRowNumber = thisRow;
|
||||
if(thisColumn > -1)
|
||||
lastColumnNumber = thisColumn;
|
||||
|
||||
// Handle end of row
|
||||
if(record instanceof LastCellOfRowDummyRecord) {
|
||||
// Print out any missing commas if needed
|
||||
if(minColumns > 0) {
|
||||
// Columns are 0 based
|
||||
if(lastColumnNumber == -1) { lastColumnNumber = 0; }
|
||||
for(int i=lastColumnNumber; i<(minColumns); i++) {
|
||||
output.print(',');
|
||||
}
|
||||
}
|
||||
|
||||
// We're onto a new row
|
||||
lastColumnNumber = -1;
|
||||
|
||||
// End the row
|
||||
output.println();
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
if(args.length < 1) {
|
||||
System.err.println("Use:");
|
||||
System.err.println(" XLS2CSVmra <xls file> [min columns]");
|
||||
System.exit(1);
|
||||
}
|
||||
|
||||
int minColumns = -1;
|
||||
if(args.length >= 2) {
|
||||
minColumns = Integer.parseInt(args[1]);
|
||||
}
|
||||
|
||||
XLS2CSVmra xls2csv = new XLS2CSVmra(args[0], minColumns);
|
||||
xls2csv.process();
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,23 @@
|
||||
/* ====================================================================
|
||||
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
contributor license agreements. See the NOTICE file distributed with
|
||||
this work for additional information regarding copyright ownership.
|
||||
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
(the "License"); you may not use this file except in compliance with
|
||||
the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
==================================================================== */
|
||||
|
||||
|
||||
package org.apache.poi.examples.hssf.usermodel;
|
||||
|
||||
/* Placeholder - this is now handled in the Common SS example **/
|
||||
public class AddDimensionedImage extends org.apache.poi.examples.ss.AddDimensionedImage {
|
||||
}
|
||||
@ -0,0 +1,72 @@
|
||||
|
||||
/* ====================================================================
|
||||
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
contributor license agreements. See the NOTICE file distributed with
|
||||
this work for additional information regarding copyright ownership.
|
||||
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
(the "License"); you may not use this file except in compliance with
|
||||
the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
==================================================================== */
|
||||
|
||||
|
||||
package org.apache.poi.examples.hssf.usermodel;
|
||||
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.apache.poi.hssf.usermodel.HSSFCell;
|
||||
import org.apache.poi.hssf.usermodel.HSSFCellStyle;
|
||||
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.ss.usermodel.HorizontalAlignment;
|
||||
|
||||
/**
|
||||
* Shows how various alignment options work.
|
||||
*
|
||||
* @author Glen Stampoultzis (glens at apache.org)
|
||||
*/
|
||||
public class Alignment {
|
||||
public static void main(String[] args) throws IOException {
|
||||
try (HSSFWorkbook wb = new HSSFWorkbook()) {
|
||||
HSSFSheet sheet = wb.createSheet("new sheet");
|
||||
HSSFRow row = sheet.createRow(2);
|
||||
createCell(wb, row, 0, HorizontalAlignment.CENTER);
|
||||
createCell(wb, row, 1, HorizontalAlignment.CENTER_SELECTION);
|
||||
createCell(wb, row, 2, HorizontalAlignment.FILL);
|
||||
createCell(wb, row, 3, HorizontalAlignment.GENERAL);
|
||||
createCell(wb, row, 4, HorizontalAlignment.JUSTIFY);
|
||||
createCell(wb, row, 5, HorizontalAlignment.LEFT);
|
||||
createCell(wb, row, 6, HorizontalAlignment.RIGHT);
|
||||
|
||||
// Write the output to a file
|
||||
try (FileOutputStream fileOut = new FileOutputStream("workbook.xls")) {
|
||||
wb.write(fileOut);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a cell and aligns it a certain way.
|
||||
*
|
||||
* @param wb the workbook
|
||||
* @param row the row to create the cell in
|
||||
* @param column the column number to create the cell in
|
||||
* @param align the alignment for the cell.
|
||||
*/
|
||||
private static void createCell(HSSFWorkbook wb, HSSFRow row, int column, HorizontalAlignment align) {
|
||||
HSSFCell cell = row.createCell(column);
|
||||
cell.setCellValue("Align It");
|
||||
HSSFCellStyle cellStyle = wb.createCellStyle();
|
||||
cellStyle.setAlignment(align);
|
||||
cell.setCellStyle(cellStyle);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,169 @@
|
||||
/* ====================================================================
|
||||
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
contributor license agreements. See the NOTICE file distributed with
|
||||
this work for additional information regarding copyright ownership.
|
||||
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
(the "License"); you may not use this file except in compliance with
|
||||
the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
==================================================================== */
|
||||
|
||||
package org.apache.poi.examples.hssf.usermodel;
|
||||
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.apache.poi.hssf.usermodel.HSSFCell;
|
||||
import org.apache.poi.hssf.usermodel.HSSFCellStyle;
|
||||
import org.apache.poi.hssf.usermodel.HSSFDataFormat;
|
||||
import org.apache.poi.hssf.usermodel.HSSFFont;
|
||||
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.HSSFColor.HSSFColorPredefined;
|
||||
import org.apache.poi.ss.usermodel.BorderStyle;
|
||||
import org.apache.poi.ss.usermodel.FillPatternType;
|
||||
|
||||
/**
|
||||
* Demonstrates many features of the user API at once. Used in the HOW-TO guide.
|
||||
*/
|
||||
public class BigExample {
|
||||
public static void main(String[] args) throws IOException {
|
||||
int rownum;
|
||||
|
||||
// create a new workbook
|
||||
try (HSSFWorkbook wb = new HSSFWorkbook()) {
|
||||
// create a new sheet
|
||||
HSSFSheet s = wb.createSheet();
|
||||
// declare a row object reference
|
||||
HSSFRow r;
|
||||
// declare a cell object reference
|
||||
HSSFCell c;
|
||||
// create 3 cell styles
|
||||
HSSFCellStyle cs = wb.createCellStyle();
|
||||
HSSFCellStyle cs2 = wb.createCellStyle();
|
||||
HSSFCellStyle cs3 = wb.createCellStyle();
|
||||
// create 2 fonts objects
|
||||
HSSFFont f = wb.createFont();
|
||||
HSSFFont f2 = wb.createFont();
|
||||
|
||||
//set font 1 to 12 point type
|
||||
f.setFontHeightInPoints((short) 12);
|
||||
//make it red
|
||||
f.setColor(HSSFColorPredefined.RED.getIndex());
|
||||
// make it bold
|
||||
//arial is the default font
|
||||
f.setBold(true);
|
||||
|
||||
//set font 2 to 10 point type
|
||||
f2.setFontHeightInPoints((short) 10);
|
||||
//make it the color at palette index 0xf (white)
|
||||
f2.setColor(HSSFColorPredefined.WHITE.getIndex());
|
||||
//make it bold
|
||||
f2.setBold(true);
|
||||
|
||||
//set cell style
|
||||
cs.setFont(f);
|
||||
//set the cell format see HSSFDataFormat for a full list
|
||||
cs.setDataFormat(HSSFDataFormat.getBuiltinFormat("($#,##0_);[Red]($#,##0)"));
|
||||
|
||||
//set a thin border
|
||||
cs2.setBorderBottom(BorderStyle.THIN);
|
||||
//fill w fg fill color
|
||||
cs2.setFillPattern(FillPatternType.SOLID_FOREGROUND);
|
||||
// set foreground fill to red
|
||||
cs2.setFillForegroundColor(HSSFColorPredefined.RED.getIndex());
|
||||
|
||||
// set the font
|
||||
cs2.setFont(f2);
|
||||
|
||||
// set the sheet name to HSSF Test
|
||||
wb.setSheetName(0, "HSSF Test");
|
||||
// create a sheet with 300 rows (0-299)
|
||||
for (rownum = 0; rownum < 300; rownum++) {
|
||||
// create a row
|
||||
r = s.createRow(rownum);
|
||||
// on every other row
|
||||
if ((rownum % 2) == 0) {
|
||||
// make the row height bigger (in twips - 1/20 of a point)
|
||||
r.setHeight((short) 0x249);
|
||||
}
|
||||
|
||||
// create 50 cells (0-49) (the += 2 becomes apparent later
|
||||
for (int cellnum = 0; cellnum < 50; cellnum += 2) {
|
||||
// create a numeric cell
|
||||
c = r.createCell(cellnum);
|
||||
// do some goofy math to demonstrate decimals
|
||||
c.setCellValue((rownum * 10000.0) + cellnum
|
||||
+ (rownum / 1000.0)
|
||||
+ (cellnum / 10000.0));
|
||||
|
||||
// on every other row
|
||||
if ((rownum % 2) == 0) {
|
||||
// set this cell to the first cell style we defined
|
||||
c.setCellStyle(cs);
|
||||
}
|
||||
|
||||
// create a string cell (see why += 2 in the
|
||||
c = r.createCell(cellnum + 1);
|
||||
|
||||
// set the cell's string value to "TEST"
|
||||
c.setCellValue("TEST");
|
||||
// make this column a bit wider
|
||||
s.setColumnWidth(cellnum + 1, (int) ((50 * 8) / ((double) 1 / 20)));
|
||||
|
||||
// on every other row
|
||||
if ((rownum % 2) == 0) {
|
||||
// set this to the white on red cell style
|
||||
// we defined above
|
||||
c.setCellStyle(cs2);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//draw a thick black border on the row at the bottom using BLANKS
|
||||
// advance 2 rows
|
||||
rownum++;
|
||||
rownum++;
|
||||
|
||||
r = s.createRow(rownum);
|
||||
|
||||
// define the third style to be the default
|
||||
// except with a thick black border at the bottom
|
||||
cs3.setBorderBottom(BorderStyle.THICK);
|
||||
|
||||
//create 50 cells
|
||||
for (int cellnum = 0; cellnum < 50; cellnum++) {
|
||||
//create a blank type cell (no value)
|
||||
c = r.createCell(cellnum);
|
||||
// set it to the thick black border style
|
||||
c.setCellStyle(cs3);
|
||||
}
|
||||
|
||||
//end draw thick black border
|
||||
|
||||
|
||||
// demonstrate adding/naming and deleting a sheet
|
||||
// create a sheet, set its title then delete it
|
||||
wb.createSheet();
|
||||
wb.setSheetName(1, "DeletedSheet");
|
||||
wb.removeSheetAt(1);
|
||||
//end deleted sheet
|
||||
|
||||
// create a new file
|
||||
try (FileOutputStream out = new FileOutputStream("workbook.xls")) {
|
||||
// write the workbook to the output stream
|
||||
// close our file (don't blow out our file handles
|
||||
wb.write(out);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,64 @@
|
||||
/* ====================================================================
|
||||
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
contributor license agreements. See the NOTICE file distributed with
|
||||
this work for additional information regarding copyright ownership.
|
||||
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
(the "License"); you may not use this file except in compliance with
|
||||
the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
==================================================================== */
|
||||
|
||||
package org.apache.poi.examples.hssf.usermodel;
|
||||
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.apache.poi.hssf.usermodel.HSSFCell;
|
||||
import org.apache.poi.hssf.usermodel.HSSFCellStyle;
|
||||
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.HSSFColor.HSSFColorPredefined;
|
||||
import org.apache.poi.ss.usermodel.BorderStyle;
|
||||
|
||||
/**
|
||||
* Demonstrates how to create borders around cells.
|
||||
*/
|
||||
public class Borders {
|
||||
public static void main(String[] args) throws IOException {
|
||||
try (HSSFWorkbook wb = new HSSFWorkbook()) {
|
||||
HSSFSheet sheet = wb.createSheet("new sheet");
|
||||
|
||||
// Create a row and put some cells in it. Rows are 0 based.
|
||||
HSSFRow row = sheet.createRow(1);
|
||||
|
||||
// Create a cell and put a value in it.
|
||||
HSSFCell cell = row.createCell(1);
|
||||
cell.setCellValue(4);
|
||||
|
||||
// Style the cell with borders all around.
|
||||
HSSFCellStyle style = wb.createCellStyle();
|
||||
style.setBorderBottom(BorderStyle.THIN);
|
||||
style.setBottomBorderColor(HSSFColorPredefined.BLACK.getIndex());
|
||||
style.setBorderLeft(BorderStyle.THIN);
|
||||
style.setLeftBorderColor(HSSFColorPredefined.GREEN.getIndex());
|
||||
style.setBorderRight(BorderStyle.THIN);
|
||||
style.setRightBorderColor(HSSFColorPredefined.BLUE.getIndex());
|
||||
style.setBorderTop(BorderStyle.MEDIUM_DASHED);
|
||||
style.setTopBorderColor(HSSFColorPredefined.ORANGE.getIndex());
|
||||
cell.setCellStyle(style);
|
||||
|
||||
// Write the output to a file
|
||||
try (FileOutputStream fileOut = new FileOutputStream("workbook.xls")) {
|
||||
wb.write(fileOut);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,124 @@
|
||||
/* ====================================================================
|
||||
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
contributor license agreements. See the NOTICE file distributed with
|
||||
this work for additional information regarding copyright ownership.
|
||||
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
(the "License"); you may not use this file except in compliance with
|
||||
the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
==================================================================== */
|
||||
|
||||
package org.apache.poi.examples.hssf.usermodel;
|
||||
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.apache.poi.hssf.usermodel.HSSFComment;
|
||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
||||
import org.apache.poi.ss.usermodel.Cell;
|
||||
import org.apache.poi.ss.usermodel.ClientAnchor;
|
||||
import org.apache.poi.ss.usermodel.Comment;
|
||||
import org.apache.poi.ss.usermodel.CreationHelper;
|
||||
import org.apache.poi.ss.usermodel.Drawing;
|
||||
import org.apache.poi.ss.usermodel.Font;
|
||||
import org.apache.poi.ss.usermodel.IndexedColors;
|
||||
import org.apache.poi.ss.usermodel.RichTextString;
|
||||
import org.apache.poi.ss.usermodel.Sheet;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
import org.apache.poi.ss.usermodel.WorkbookFactory;
|
||||
|
||||
/**
|
||||
* Demonstrates how to work with excel cell comments.<p>
|
||||
*
|
||||
* Excel comment is a kind of a text shape,
|
||||
* so inserting a comment is very similar to placing a text box in a worksheet
|
||||
*/
|
||||
public class CellComments {
|
||||
|
||||
public static void main(String[] args) throws IOException {
|
||||
createWorkbook(false, ".xls");
|
||||
createWorkbook(true, ".xlsx");
|
||||
}
|
||||
|
||||
private static void createWorkbook(boolean xssf, String extension) throws IOException {
|
||||
try (Workbook wb = WorkbookFactory.create(xssf)) {
|
||||
Sheet sheet = wb.createSheet("Cell comments in POI " + extension);
|
||||
CreationHelper creationHelper = wb.getCreationHelper();
|
||||
|
||||
// Create the drawing patriarch. This is the top level container for all shapes including cell comments.
|
||||
Drawing<?> patr = sheet.createDrawingPatriarch();
|
||||
|
||||
//create a cell in row 3
|
||||
Cell cell1 = sheet.createRow(3).createCell(1);
|
||||
cell1.setCellValue(creationHelper.createRichTextString("Hello, World"));
|
||||
|
||||
//anchor defines size and position of the comment in worksheet
|
||||
ClientAnchor clientAnchor = creationHelper.createClientAnchor();
|
||||
clientAnchor.setCol1(4);
|
||||
clientAnchor.setRow1(2);
|
||||
clientAnchor.setCol2(6);
|
||||
clientAnchor.setRow2(5);
|
||||
Comment comment1 = patr.createCellComment(clientAnchor);
|
||||
|
||||
// set text in the comment
|
||||
comment1.setString(creationHelper.createRichTextString("We can set comments in POI"));
|
||||
|
||||
//set comment author.
|
||||
//you can see it in the status bar when moving mouse over the commented cell
|
||||
comment1.setAuthor("Apache Software Foundation");
|
||||
|
||||
// The first way to assign comment to a cell is via Cell.setCellComment method
|
||||
cell1.setCellComment(comment1);
|
||||
|
||||
//create another cell in row 6
|
||||
Cell cell2 = sheet.createRow(6).createCell(1);
|
||||
cell2.setCellValue(36.6);
|
||||
|
||||
|
||||
clientAnchor = creationHelper.createClientAnchor();
|
||||
clientAnchor.setCol1(4);
|
||||
clientAnchor.setRow1(8);
|
||||
clientAnchor.setCol2(6);
|
||||
clientAnchor.setRow2(11);
|
||||
Comment comment2 = patr.createCellComment(clientAnchor);
|
||||
//modify background color of the comment, only available in HSSF currently
|
||||
if (wb instanceof HSSFWorkbook) {
|
||||
((HSSFComment) comment2).setFillColor(204, 236, 255);
|
||||
}
|
||||
|
||||
RichTextString string = creationHelper.createRichTextString("Normal body temperature");
|
||||
|
||||
//apply custom font to the text in the comment
|
||||
Font font = wb.createFont();
|
||||
font.setFontName("Arial");
|
||||
font.setFontHeightInPoints((short) 10);
|
||||
font.setBold(true);
|
||||
font.setColor(IndexedColors.RED.getIndex());
|
||||
string.applyFont(font);
|
||||
|
||||
comment2.setString(string);
|
||||
comment2.setVisible(true); //by default comments are hidden. This one is always visible.
|
||||
|
||||
comment2.setAuthor("Bill Gates");
|
||||
|
||||
/*
|
||||
* The second way to assign comment to a cell is to implicitly specify its row and column.
|
||||
* Note, it is possible to set row and column of a non-existing cell.
|
||||
* It works, the comment is visible.
|
||||
*/
|
||||
comment2.setRow(6);
|
||||
comment2.setColumn(1);
|
||||
|
||||
try (FileOutputStream out = new FileOutputStream("poi_comment" + extension)) {
|
||||
wb.write(out);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,46 @@
|
||||
/* ====================================================================
|
||||
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
contributor license agreements. See the NOTICE file distributed with
|
||||
this work for additional information regarding copyright ownership.
|
||||
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
(the "License"); you may not use this file except in compliance with
|
||||
the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
==================================================================== */
|
||||
|
||||
package org.apache.poi.examples.hssf.usermodel;
|
||||
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.Date;
|
||||
|
||||
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.ss.usermodel.FormulaError;
|
||||
|
||||
public class CellTypes {
|
||||
public static void main(String[] args) throws IOException {
|
||||
try (HSSFWorkbook wb = new HSSFWorkbook()) {
|
||||
HSSFSheet sheet = wb.createSheet("new sheet");
|
||||
HSSFRow row = sheet.createRow(2);
|
||||
row.createCell(0).setCellValue(1.1);
|
||||
row.createCell(1).setCellValue(new Date());
|
||||
row.createCell(2).setCellValue("a string");
|
||||
row.createCell(3).setCellValue(true);
|
||||
row.createCell(4).setCellErrorValue(FormulaError.NUM);
|
||||
|
||||
// Write the output to a file
|
||||
try (FileOutputStream fileOut = new FileOutputStream("workbook.xls")) {
|
||||
wb.write(fileOut);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,55 @@
|
||||
/* ====================================================================
|
||||
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
contributor license agreements. See the NOTICE file distributed with
|
||||
this work for additional information regarding copyright ownership.
|
||||
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
(the "License"); you may not use this file except in compliance with
|
||||
the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
==================================================================== */
|
||||
|
||||
package org.apache.poi.examples.hssf.usermodel;
|
||||
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
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;
|
||||
|
||||
/**
|
||||
* Illustrates how to create cell values.
|
||||
*
|
||||
* @author Glen Stampoultzis (glens at apache.org)
|
||||
*/
|
||||
public class CreateCells {
|
||||
public static void main(String[] args) throws IOException {
|
||||
try (HSSFWorkbook wb = new HSSFWorkbook()) {
|
||||
HSSFSheet sheet = wb.createSheet("new sheet");
|
||||
|
||||
// Create a row and put some cells in it. Rows are 0 based.
|
||||
HSSFRow row = sheet.createRow(0);
|
||||
// Create a cell and put a value in it.
|
||||
HSSFCell cell = row.createCell(0);
|
||||
cell.setCellValue(1);
|
||||
|
||||
// Or do it on one line.
|
||||
row.createCell(1).setCellValue(1.2);
|
||||
row.createCell(2).setCellValue("This is a string");
|
||||
row.createCell(3).setCellValue(true);
|
||||
|
||||
// Write the output to a file
|
||||
try (FileOutputStream fileOut = new FileOutputStream("workbook.xls")) {
|
||||
wb.write(fileOut);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,62 @@
|
||||
/* ====================================================================
|
||||
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
contributor license agreements. See the NOTICE file distributed with
|
||||
this work for additional information regarding copyright ownership.
|
||||
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
(the "License"); you may not use this file except in compliance with
|
||||
the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
==================================================================== */
|
||||
|
||||
package org.apache.poi.examples.hssf.usermodel;
|
||||
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.Date;
|
||||
|
||||
import org.apache.poi.hssf.usermodel.HSSFCell;
|
||||
import org.apache.poi.hssf.usermodel.HSSFCellStyle;
|
||||
import org.apache.poi.hssf.usermodel.HSSFDataFormat;
|
||||
import org.apache.poi.hssf.usermodel.HSSFRow;
|
||||
import org.apache.poi.hssf.usermodel.HSSFSheet;
|
||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
||||
|
||||
/**
|
||||
* An example on how to cells with dates. The important thing to note
|
||||
* about dates is that they are really normal numeric cells that are
|
||||
* formatted specially.
|
||||
*/
|
||||
public class CreateDateCells {
|
||||
public static void main(String[] args) throws IOException {
|
||||
try (HSSFWorkbook wb = new HSSFWorkbook()) {
|
||||
HSSFSheet sheet = wb.createSheet("new sheet");
|
||||
|
||||
// Create a row and put some cells in it. Rows are 0 based.
|
||||
HSSFRow row = sheet.createRow(0);
|
||||
|
||||
// Create a cell and put a date value in it. The first cell is not styled as a date.
|
||||
HSSFCell cell = row.createCell(0);
|
||||
cell.setCellValue(new Date());
|
||||
|
||||
// we style the second cell as a date (and time). It is important to create a new cell style from the workbook
|
||||
// otherwise you can end up modifying the built in style and effecting not only this cell but other cells.
|
||||
HSSFCellStyle cellStyle = wb.createCellStyle();
|
||||
cellStyle.setDataFormat(HSSFDataFormat.getBuiltinFormat("m/d/yy h:mm"));
|
||||
cell = row.createCell(1);
|
||||
cell.setCellValue(new Date());
|
||||
cell.setCellStyle(cellStyle);
|
||||
|
||||
// Write the output to a file
|
||||
try (FileOutputStream fileOut = new FileOutputStream("workbook.xls")) {
|
||||
wb.write(fileOut);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,78 @@
|
||||
/* ====================================================================
|
||||
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
contributor license agreements. See the NOTICE file distributed with
|
||||
this work for additional information regarding copyright ownership.
|
||||
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
(the "License"); you may not use this file except in compliance with
|
||||
the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
==================================================================== */
|
||||
package org.apache.poi.examples.hssf.usermodel;
|
||||
|
||||
import java.io.Closeable;
|
||||
import java.io.FileInputStream;
|
||||
|
||||
import org.apache.poi.hslf.usermodel.HSLFSlideShow;
|
||||
import org.apache.poi.hssf.usermodel.HSSFObjectData;
|
||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
||||
import org.apache.poi.hwpf.HWPFDocument;
|
||||
import org.apache.poi.poifs.filesystem.DirectoryNode;
|
||||
import org.apache.poi.poifs.filesystem.Entry;
|
||||
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
|
||||
|
||||
/**
|
||||
* Demonstrates how you can extract embedded data from a .xls file
|
||||
*/
|
||||
@SuppressWarnings({"java:S106","java:S4823","java:S1192"})
|
||||
public final class EmbeddedObjects {
|
||||
private EmbeddedObjects() {}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public static void main(String[] args) throws Exception {
|
||||
try (
|
||||
FileInputStream fis = new FileInputStream(args[0]);
|
||||
POIFSFileSystem fs = new POIFSFileSystem(fis);
|
||||
HSSFWorkbook workbook = new HSSFWorkbook(fs)
|
||||
) {
|
||||
for (HSSFObjectData obj : workbook.getAllEmbeddedObjects()) {
|
||||
//the OLE2 Class Name of the object
|
||||
String oleName = obj.getOLE2ClassName();
|
||||
DirectoryNode dn = (obj.hasDirectoryEntry()) ? (DirectoryNode) obj.getDirectory() : null;
|
||||
Closeable document = null;
|
||||
switch (oleName) {
|
||||
case "Worksheet":
|
||||
document = new HSSFWorkbook(dn, fs, false);
|
||||
break;
|
||||
case "Document":
|
||||
document = new HWPFDocument(dn);
|
||||
break;
|
||||
case "Presentation":
|
||||
document = new HSLFSlideShow(dn);
|
||||
break;
|
||||
default:
|
||||
if (dn != null) {
|
||||
// The DirectoryEntry is a DocumentNode. Examine its entries to find out what it is
|
||||
for (Entry entry : dn) {
|
||||
String name = entry.getName();
|
||||
}
|
||||
} else {
|
||||
// There is no DirectoryEntry
|
||||
// Recover the object's data from the HSSFObjectData instance.
|
||||
byte[] objectData = obj.getObjectData();
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (document != null) {
|
||||
document.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,122 @@
|
||||
|
||||
/* ====================================================================
|
||||
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
contributor license agreements. See the NOTICE file distributed with
|
||||
this work for additional information regarding copyright ownership.
|
||||
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
(the "License"); you may not use this file except in compliance with
|
||||
the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
==================================================================== */
|
||||
|
||||
package org.apache.poi.examples.hssf.usermodel;
|
||||
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
import org.apache.poi.hssf.eventusermodel.HSSFEventFactory;
|
||||
import org.apache.poi.hssf.eventusermodel.HSSFListener;
|
||||
import org.apache.poi.hssf.eventusermodel.HSSFRequest;
|
||||
import org.apache.poi.hssf.record.BOFRecord;
|
||||
import org.apache.poi.hssf.record.BoundSheetRecord;
|
||||
import org.apache.poi.hssf.record.LabelSSTRecord;
|
||||
import org.apache.poi.hssf.record.NumberRecord;
|
||||
import org.apache.poi.hssf.record.RowRecord;
|
||||
import org.apache.poi.hssf.record.SSTRecord;
|
||||
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
|
||||
|
||||
/**
|
||||
* This example shows how to use the event API for reading a file.
|
||||
*/
|
||||
@SuppressWarnings({"java:S106","java:S4823"})
|
||||
public class EventExample implements HSSFListener {
|
||||
private SSTRecord sstrec;
|
||||
|
||||
/**
|
||||
* This method listens for incoming records and handles them as required.
|
||||
* @param record The record that was found while reading.
|
||||
*/
|
||||
@Override
|
||||
public void processRecord(org.apache.poi.hssf.record.Record record)
|
||||
{
|
||||
switch (record.getSid())
|
||||
{
|
||||
// the BOFRecord can represent either the beginning of a sheet or the workbook
|
||||
case BOFRecord.sid:
|
||||
BOFRecord bof = (BOFRecord) record;
|
||||
if (bof.getType() == BOFRecord.TYPE_WORKBOOK)
|
||||
{
|
||||
System.out.println("Encountered workbook");
|
||||
// assigned to the class level member
|
||||
} else if (bof.getType() == BOFRecord.TYPE_WORKSHEET)
|
||||
{
|
||||
System.out.println("Encountered sheet reference");
|
||||
}
|
||||
break;
|
||||
case BoundSheetRecord.sid:
|
||||
BoundSheetRecord bsr = (BoundSheetRecord) record;
|
||||
System.out.println("New sheet named: " + bsr.getSheetname());
|
||||
break;
|
||||
case RowRecord.sid:
|
||||
RowRecord rowrec = (RowRecord) record;
|
||||
System.out.println("Row found, first column at "
|
||||
+ rowrec.getFirstCol() + " last column at " + rowrec.getLastCol());
|
||||
break;
|
||||
case NumberRecord.sid:
|
||||
NumberRecord numrec = (NumberRecord) record;
|
||||
System.out.println("Cell found with value " + numrec.getValue()
|
||||
+ " at row " + numrec.getRow() + " and column " + numrec.getColumn());
|
||||
break;
|
||||
// SSTRecords store a array of unique strings used in Excel.
|
||||
case SSTRecord.sid:
|
||||
sstrec = (SSTRecord) record;
|
||||
for (int k = 0; k < sstrec.getNumUniqueStrings(); k++)
|
||||
{
|
||||
System.out.println("String table value " + k + " = " + sstrec.getString(k));
|
||||
}
|
||||
break;
|
||||
case LabelSSTRecord.sid:
|
||||
LabelSSTRecord lrec = (LabelSSTRecord) record;
|
||||
System.out.println("String cell found with value "
|
||||
+ sstrec.getString(lrec.getSSTIndex()));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Read an excel file and spit out what we find.
|
||||
*
|
||||
* @param args Expect one argument that is the file to read.
|
||||
* @throws IOException When there is an error processing the file.
|
||||
*/
|
||||
public static void main(String[] args) throws IOException
|
||||
{
|
||||
// create a new file input stream with the input file specified
|
||||
// at the command line
|
||||
try (FileInputStream fin = new FileInputStream(args[0])) {
|
||||
// create a new org.apache.poi.poifs.filesystem.Filesystem
|
||||
try (POIFSFileSystem poifs = new POIFSFileSystem(fin)) {
|
||||
// get the Workbook (excel part) stream in a InputStream
|
||||
try (InputStream din = poifs.createDocumentInputStream("Workbook")) {
|
||||
// construct out HSSFRequest object
|
||||
HSSFRequest req = new HSSFRequest();
|
||||
// lazy listen for ALL records with the listener shown above
|
||||
req.addListenerForAllRecords(new EventExample());
|
||||
// create our event factory
|
||||
HSSFEventFactory factory = new HSSFEventFactory();
|
||||
// process our events based on the document input stream
|
||||
factory.processEvents(req, din);
|
||||
}
|
||||
}
|
||||
}
|
||||
System.out.println("done.");
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,64 @@
|
||||
/* ====================================================================
|
||||
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
contributor license agreements. See the NOTICE file distributed with
|
||||
this work for additional information regarding copyright ownership.
|
||||
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
(the "License"); you may not use this file except in compliance with
|
||||
the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
==================================================================== */
|
||||
|
||||
package org.apache.poi.examples.hssf.usermodel;
|
||||
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.apache.poi.hssf.usermodel.HSSFCell;
|
||||
import org.apache.poi.hssf.usermodel.HSSFCellStyle;
|
||||
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.HSSFColor.HSSFColorPredefined;
|
||||
import org.apache.poi.ss.usermodel.FillPatternType;
|
||||
|
||||
/**
|
||||
* Shows how to use various fills.
|
||||
*/
|
||||
public class FrillsAndFills {
|
||||
public static void main(String[] args) throws IOException {
|
||||
try (HSSFWorkbook wb = new HSSFWorkbook()) {
|
||||
HSSFSheet sheet = wb.createSheet("new sheet");
|
||||
|
||||
// Create a row and put some cells in it. Rows are 0 based.
|
||||
HSSFRow row = sheet.createRow(1);
|
||||
|
||||
// Aqua background
|
||||
HSSFCellStyle style = wb.createCellStyle();
|
||||
style.setFillBackgroundColor(HSSFColorPredefined.AQUA.getIndex());
|
||||
style.setFillPattern(FillPatternType.BIG_SPOTS);
|
||||
HSSFCell cell = row.createCell(1);
|
||||
cell.setCellValue("X");
|
||||
cell.setCellStyle(style);
|
||||
|
||||
// Orange "foreground", foreground being the fill foreground not the font color.
|
||||
style = wb.createCellStyle();
|
||||
style.setFillForegroundColor(HSSFColorPredefined.ORANGE.getIndex());
|
||||
style.setFillPattern(FillPatternType.SOLID_FOREGROUND);
|
||||
cell = row.createCell(2);
|
||||
cell.setCellValue("X");
|
||||
cell.setCellStyle(style);
|
||||
|
||||
// Write the output to a file
|
||||
try (FileOutputStream fileOut = new FileOutputStream("workbook.xls")) {
|
||||
wb.write(fileOut);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,251 @@
|
||||
/* ====================================================================
|
||||
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
contributor license agreements. See the NOTICE file distributed with
|
||||
this work for additional information regarding copyright ownership.
|
||||
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
(the "License"); you may not use this file except in compliance with
|
||||
the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
==================================================================== */
|
||||
|
||||
package org.apache.poi.examples.hssf.usermodel;
|
||||
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.apache.poi.hssf.usermodel.HSSFCell;
|
||||
import org.apache.poi.hssf.usermodel.HSSFCellStyle;
|
||||
import org.apache.poi.hssf.usermodel.HSSFDataFormat;
|
||||
import org.apache.poi.hssf.usermodel.HSSFFont;
|
||||
import org.apache.poi.hssf.usermodel.HSSFRichTextString;
|
||||
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.ss.usermodel.BorderStyle;
|
||||
import org.apache.poi.ss.usermodel.FillPatternType;
|
||||
import org.apache.poi.ss.util.CellRangeAddress;
|
||||
|
||||
/**
|
||||
* File for HSSF testing/examples
|
||||
*
|
||||
* THIS IS NOT THE MAIN HSSF FILE!! This is a utility for testing functionality.
|
||||
* It does contain sample API usage that may be educational to regular API
|
||||
* users.
|
||||
*/
|
||||
@SuppressWarnings({"java:S106","java:S4823"})
|
||||
public final class HSSFReadWrite {
|
||||
|
||||
private HSSFReadWrite() {}
|
||||
|
||||
/**
|
||||
* creates an {@link HSSFWorkbook} with the specified OS filename.
|
||||
*/
|
||||
private static HSSFWorkbook readFile(String filename) throws IOException {
|
||||
try (FileInputStream fis = new FileInputStream(filename)) {
|
||||
return new HSSFWorkbook(fis); // NOSONAR - should not be closed here
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* given a filename this outputs a sample sheet with just a set of
|
||||
* rows/cells.
|
||||
*/
|
||||
private static void testCreateSampleSheet(String outputFilename) throws IOException {
|
||||
try (HSSFWorkbook wb = new HSSFWorkbook();
|
||||
FileOutputStream out = new FileOutputStream(outputFilename)) {
|
||||
HSSFSheet s = wb.createSheet();
|
||||
HSSFCellStyle cs = wb.createCellStyle();
|
||||
HSSFCellStyle cs2 = wb.createCellStyle();
|
||||
HSSFCellStyle cs3 = wb.createCellStyle();
|
||||
HSSFFont f = wb.createFont();
|
||||
HSSFFont f2 = wb.createFont();
|
||||
|
||||
f.setFontHeightInPoints((short) 12);
|
||||
f.setColor((short) 0xA);
|
||||
f.setBold(true);
|
||||
f2.setFontHeightInPoints((short) 10);
|
||||
f2.setColor((short) 0xf);
|
||||
f2.setBold(true);
|
||||
cs.setFont(f);
|
||||
cs.setDataFormat(HSSFDataFormat.getBuiltinFormat("($#,##0_);[Red]($#,##0)"));
|
||||
cs2.setBorderBottom(BorderStyle.THIN);
|
||||
cs2.setFillPattern(FillPatternType.SOLID_FOREGROUND);
|
||||
cs2.setFillForegroundColor((short) 0xA);
|
||||
cs2.setFont(f2);
|
||||
wb.setSheetName(0, "HSSF Test");
|
||||
int rownum;
|
||||
for (rownum = 0; rownum < 300; rownum++) {
|
||||
HSSFRow r = s.createRow(rownum);
|
||||
if ((rownum % 2) == 0) {
|
||||
r.setHeight((short) 0x249);
|
||||
}
|
||||
|
||||
for (int cellnum = 0; cellnum < 50; cellnum += 2) {
|
||||
HSSFCell c = r.createCell(cellnum);
|
||||
c.setCellValue((rownum * 10000.0) + cellnum
|
||||
+ (rownum / 1000.0) + (cellnum / 10000.0));
|
||||
if ((rownum % 2) == 0) {
|
||||
c.setCellStyle(cs);
|
||||
}
|
||||
c = r.createCell(cellnum + 1);
|
||||
c.setCellValue(new HSSFRichTextString("TEST"));
|
||||
// 50 characters divided by 1/20th of a point
|
||||
s.setColumnWidth(cellnum + 1, (int) (50 * 8 / 0.05));
|
||||
if ((rownum % 2) == 0) {
|
||||
c.setCellStyle(cs2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// draw a thick black border on the row at the bottom using BLANKS
|
||||
rownum++;
|
||||
rownum++;
|
||||
HSSFRow r = s.createRow(rownum);
|
||||
cs3.setBorderBottom(BorderStyle.THICK);
|
||||
for (int cellnum = 0; cellnum < 50; cellnum++) {
|
||||
HSSFCell c = r.createCell(cellnum);
|
||||
c.setCellStyle(cs3);
|
||||
}
|
||||
s.addMergedRegion(new CellRangeAddress(0, 3, 0, 3));
|
||||
s.addMergedRegion(new CellRangeAddress(100, 110, 100, 110));
|
||||
|
||||
// end draw thick black border
|
||||
// create a sheet, set its title then delete it
|
||||
wb.createSheet();
|
||||
wb.setSheetName(1, "DeletedSheet");
|
||||
wb.removeSheetAt(1);
|
||||
|
||||
// end deleted sheet
|
||||
wb.write(out);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method main
|
||||
*
|
||||
* Given 1 argument takes that as the filename, inputs it and dumps the
|
||||
* cell values/types out to sys.out.<br>
|
||||
*
|
||||
* given 2 arguments where the second argument is the word "write" and the
|
||||
* first is the filename - writes out a sample (test) spreadsheet
|
||||
* see {@link HSSFReadWrite#testCreateSampleSheet(String)}.<br>
|
||||
*
|
||||
* given 2 arguments where the first is an input filename and the second
|
||||
* an output filename (not write), attempts to fully read in the
|
||||
* spreadsheet and fully write it out.<br>
|
||||
*
|
||||
* given 3 arguments where the first is an input filename and the second an
|
||||
* output filename (not write) and the third is "modify1", attempts to read in the
|
||||
* spreadsheet, deletes rows 0-24, 74-99. Changes cell at row 39, col 3 to
|
||||
* "MODIFIED CELL" then writes it out. Hence this is "modify test 1". If you
|
||||
* take the output from the write test, you'll have a valid scenario.
|
||||
*/
|
||||
public static void main(String[] args) throws Exception {
|
||||
if (args.length < 1) {
|
||||
System.err.println("At least one argument expected");
|
||||
return;
|
||||
}
|
||||
|
||||
String fileName = args[0];
|
||||
if (args.length < 2) {
|
||||
|
||||
try (HSSFWorkbook wb = HSSFReadWrite.readFile(fileName)) {
|
||||
System.out.println("Data dump:\n");
|
||||
|
||||
for (int k = 0; k < wb.getNumberOfSheets(); k++) {
|
||||
HSSFSheet sheet = wb.getSheetAt(k);
|
||||
int rows = sheet.getPhysicalNumberOfRows();
|
||||
System.out.println("Sheet " + k + " \"" + wb.getSheetName(k) + "\" has " + rows + " row(s).");
|
||||
for (int r = 0; r < rows; r++) {
|
||||
HSSFRow row = sheet.getRow(r);
|
||||
if (row == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
System.out.println("\nROW " + row.getRowNum() + " has " + row.getPhysicalNumberOfCells() + " cell(s).");
|
||||
for (int c = 0; c < row.getLastCellNum(); c++) {
|
||||
HSSFCell cell = row.getCell(c);
|
||||
String value;
|
||||
|
||||
if (cell != null) {
|
||||
switch (cell.getCellType()) {
|
||||
|
||||
case FORMULA:
|
||||
value = "FORMULA value=" + cell.getCellFormula();
|
||||
break;
|
||||
|
||||
case NUMERIC:
|
||||
value = "NUMERIC value=" + cell.getNumericCellValue();
|
||||
break;
|
||||
|
||||
case STRING:
|
||||
value = "STRING value=" + cell.getStringCellValue();
|
||||
break;
|
||||
|
||||
case BLANK:
|
||||
value = "<BLANK>";
|
||||
break;
|
||||
|
||||
case BOOLEAN:
|
||||
value = "BOOLEAN value-" + cell.getBooleanCellValue();
|
||||
break;
|
||||
|
||||
case ERROR:
|
||||
value = "ERROR value=" + cell.getErrorCellValue();
|
||||
break;
|
||||
|
||||
default:
|
||||
value = "UNKNOWN value of type " + cell.getCellType();
|
||||
}
|
||||
System.out.println("CELL col=" + cell.getColumnIndex() + " VALUE=" + value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (args.length == 2) {
|
||||
if ("write".equalsIgnoreCase(args[1])) {
|
||||
System.out.println("Write mode");
|
||||
long time = System.currentTimeMillis();
|
||||
HSSFReadWrite.testCreateSampleSheet(fileName);
|
||||
|
||||
System.out.println("" + (System.currentTimeMillis() - time) + " ms generation time");
|
||||
} else {
|
||||
System.out.println("readwrite test");
|
||||
try (HSSFWorkbook wb = HSSFReadWrite.readFile(fileName);
|
||||
FileOutputStream stream = new FileOutputStream(args[1])) {
|
||||
wb.write(stream);
|
||||
}
|
||||
}
|
||||
} else if (args.length == 3 && "modify1".equalsIgnoreCase(args[2])) {
|
||||
// delete row 0-24, row 74 - 99 && change cell 3 on row 39 to string "MODIFIED CELL!!"
|
||||
|
||||
try (HSSFWorkbook wb = HSSFReadWrite.readFile(fileName);
|
||||
FileOutputStream stream = new FileOutputStream(args[1])) {
|
||||
HSSFSheet sheet = wb.getSheetAt(0);
|
||||
|
||||
for (int k = 0; k < 25; k++) {
|
||||
HSSFRow row = sheet.getRow(k);
|
||||
sheet.removeRow(row);
|
||||
}
|
||||
for (int k = 74; k < 100; k++) {
|
||||
HSSFRow row = sheet.getRow(k);
|
||||
sheet.removeRow(row);
|
||||
}
|
||||
HSSFRow row = sheet.getRow(39);
|
||||
HSSFCell cell = row.getCell(3);
|
||||
cell.setCellValue("MODIFIED CELL!!!!!");
|
||||
|
||||
wb.write(stream);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,45 @@
|
||||
/* ====================================================================
|
||||
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
contributor license agreements. See the NOTICE file distributed with
|
||||
this work for additional information regarding copyright ownership.
|
||||
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
(the "License"); you may not use this file except in compliance with
|
||||
the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
==================================================================== */
|
||||
|
||||
package org.apache.poi.examples.hssf.usermodel;
|
||||
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
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;
|
||||
|
||||
/**
|
||||
* Test if hyperlink formula, with url that got more than 127 characters, works
|
||||
*/
|
||||
public class HyperlinkFormula {
|
||||
public static void main(String[] args) throws IOException {
|
||||
try (HSSFWorkbook wb = new HSSFWorkbook()) {
|
||||
HSSFSheet sheet = wb.createSheet("new sheet");
|
||||
HSSFRow row = sheet.createRow(0);
|
||||
|
||||
HSSFCell cell = row.createCell(0);
|
||||
cell.setCellFormula("HYPERLINK(\"http://127.0.0.1:8080/toto/truc/index.html?test=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\", \"test\")");
|
||||
|
||||
try (FileOutputStream fileOut = new FileOutputStream("workbook.xls")) {
|
||||
wb.write(fileOut);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,97 @@
|
||||
/* ====================================================================
|
||||
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
contributor license agreements. See the NOTICE file distributed with
|
||||
this work for additional information regarding copyright ownership.
|
||||
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
(the "License"); you may not use this file except in compliance with
|
||||
the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
==================================================================== */
|
||||
|
||||
package org.apache.poi.examples.hssf.usermodel;
|
||||
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.apache.poi.common.usermodel.HyperlinkType;
|
||||
import org.apache.poi.hssf.usermodel.HSSFCell;
|
||||
import org.apache.poi.hssf.usermodel.HSSFCellStyle;
|
||||
import org.apache.poi.hssf.usermodel.HSSFCreationHelper;
|
||||
import org.apache.poi.hssf.usermodel.HSSFFont;
|
||||
import org.apache.poi.hssf.usermodel.HSSFHyperlink;
|
||||
import org.apache.poi.hssf.usermodel.HSSFSheet;
|
||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
||||
import org.apache.poi.hssf.util.HSSFColor.HSSFColorPredefined;
|
||||
import org.apache.poi.ss.usermodel.Font;
|
||||
|
||||
/**
|
||||
* Demonstrates how to create hyperlinks.
|
||||
*/
|
||||
public class Hyperlinks {
|
||||
|
||||
public static void main(String[] args) throws IOException {
|
||||
try (HSSFWorkbook wb = new HSSFWorkbook()) {
|
||||
HSSFCreationHelper helper = wb.getCreationHelper();
|
||||
|
||||
//cell style for hyperlinks
|
||||
//by default hyperlinks are blue and underlined
|
||||
HSSFCellStyle hlinkStyle = wb.createCellStyle();
|
||||
HSSFFont hlinkFont = wb.createFont();
|
||||
hlinkFont.setUnderline(Font.U_SINGLE);
|
||||
hlinkFont.setColor(HSSFColorPredefined.BLUE.getIndex());
|
||||
hlinkStyle.setFont(hlinkFont);
|
||||
|
||||
HSSFCell cell;
|
||||
HSSFSheet sheet = wb.createSheet("Hyperlinks");
|
||||
|
||||
//URL
|
||||
cell = sheet.createRow(0).createCell(0);
|
||||
cell.setCellValue("URL Link");
|
||||
HSSFHyperlink link = helper.createHyperlink(HyperlinkType.URL);
|
||||
link.setAddress("https://poi.apache.org/");
|
||||
cell.setHyperlink(link);
|
||||
cell.setCellStyle(hlinkStyle);
|
||||
|
||||
//link to a file in the current directory
|
||||
cell = sheet.createRow(1).createCell(0);
|
||||
cell.setCellValue("File Link");
|
||||
link = helper.createHyperlink(HyperlinkType.FILE);
|
||||
link.setAddress("link1.xls");
|
||||
cell.setHyperlink(link);
|
||||
cell.setCellStyle(hlinkStyle);
|
||||
|
||||
//e-mail link
|
||||
cell = sheet.createRow(2).createCell(0);
|
||||
cell.setCellValue("Email Link");
|
||||
link = helper.createHyperlink(HyperlinkType.EMAIL);
|
||||
//note, if subject contains white spaces, make sure they are url-encoded
|
||||
link.setAddress("mailto:poi@apache.org?subject=Hyperlinks");
|
||||
cell.setHyperlink(link);
|
||||
cell.setCellStyle(hlinkStyle);
|
||||
|
||||
//link to a place in this workbook
|
||||
|
||||
//create a target sheet and cell
|
||||
HSSFSheet sheet2 = wb.createSheet("Target Sheet");
|
||||
sheet2.createRow(0).createCell(0).setCellValue("Target Cell");
|
||||
|
||||
cell = sheet.createRow(3).createCell(0);
|
||||
cell.setCellValue("Worksheet Link");
|
||||
link = helper.createHyperlink(HyperlinkType.DOCUMENT);
|
||||
link.setAddress("'Target Sheet'!A1");
|
||||
cell.setHyperlink(link);
|
||||
cell.setCellStyle(hlinkStyle);
|
||||
|
||||
try (FileOutputStream out = new FileOutputStream("hssf-links.xls")) {
|
||||
wb.write(out);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,541 @@
|
||||
/* ====================================================================
|
||||
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
contributor license agreements. See the NOTICE file distributed with
|
||||
this work for additional information regarding copyright ownership.
|
||||
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
(the "License"); you may not use this file except in compliance with
|
||||
the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
==================================================================== */
|
||||
|
||||
|
||||
package org.apache.poi.examples.hssf.usermodel;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.poi.hssf.usermodel.HSSFCell;
|
||||
import org.apache.poi.hssf.usermodel.HSSFCellStyle;
|
||||
import org.apache.poi.hssf.usermodel.HSSFDataFormat;
|
||||
import org.apache.poi.hssf.usermodel.HSSFRichTextString;
|
||||
import org.apache.poi.hssf.usermodel.HSSFRow;
|
||||
import org.apache.poi.hssf.usermodel.HSSFSheet;
|
||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
||||
|
||||
/**
|
||||
* This class contains code that demonstrates how to insert plain, numbered
|
||||
* and bulleted lists into an Excel spreadsheet cell.
|
||||
*
|
||||
* Look at the code contained in the demonstrateMethodCalls() method. It calls
|
||||
* other methods that create plain, numbered and bulleted single and
|
||||
* multi-level lists. The demonstrateMethodCalls() method appears at the top
|
||||
* of the class definition.
|
||||
*
|
||||
* Though different methods are provided to construct single and multi-level
|
||||
* plain, numbered and bulleted lists, close examination will reveal that they
|
||||
* are not strictly necessary. If the inputs to the listInCell() and
|
||||
* multilLevelListInCell() methods are constructed to include the bullet
|
||||
* character or the item numbers then these methods alone may be sufficient.
|
||||
*
|
||||
* @author Mark Beardsley [msb at apache.org]
|
||||
*/
|
||||
@SuppressWarnings({"java:S106","java:S4823"})
|
||||
public class InCellLists {
|
||||
|
||||
// This character looks like a solid, black, loser case letter 'o'
|
||||
// positioned up from the base line of the text.
|
||||
private static final char BULLET_CHARACTER = '\u2022';
|
||||
|
||||
// The tab character - \t - cannot be used to create a tab space
|
||||
// within a cell as it is rendered as a square. Therefore, four
|
||||
// spaces are used to simulate that character.
|
||||
private static final String TAB = " ";
|
||||
|
||||
/**
|
||||
* Call each of the list creation methods.
|
||||
*
|
||||
* @param outputFilename A String that encapsulates the name of and path to
|
||||
* the Excel spreadsheet file this code will create.
|
||||
*/
|
||||
public void demonstrateMethodCalls(String outputFilename) throws IOException {
|
||||
try (HSSFWorkbook workbook = new HSSFWorkbook()) {
|
||||
HSSFSheet sheet = workbook.createSheet("In Cell Lists");
|
||||
HSSFRow row = sheet.createRow(0);
|
||||
|
||||
// Create a cell at A1 and insert a single, bulleted, item into
|
||||
// that cell.
|
||||
HSSFCell cell = row.createCell(0);
|
||||
this.bulletedItemInCell(workbook, "List Item", cell);
|
||||
|
||||
// Create a cell at A2 and insert a plain list - that is one
|
||||
// whose items are neither bulleted or numbered - into that cell.
|
||||
row = sheet.createRow(1);
|
||||
cell = row.createCell(0);
|
||||
List<String> listItems = new ArrayList<>();
|
||||
listItems.add("List Item One.");
|
||||
listItems.add("List Item Two.");
|
||||
listItems.add("List Item Three.");
|
||||
listItems.add("List Item Four.");
|
||||
this.listInCell(workbook, listItems, cell);
|
||||
// The row height and cell width are set here to ensure that the
|
||||
// list may be seen.
|
||||
row.setHeight((short) 1100);
|
||||
sheet.setColumnWidth(0, 9500);
|
||||
|
||||
// Create a cell at A3 and insert a numbered list into that cell.
|
||||
// Note that a couple of items have been added to the listItems
|
||||
// ArrayList
|
||||
row = sheet.createRow(2);
|
||||
cell = row.createCell(0);
|
||||
listItems.add("List Item Five.");
|
||||
listItems.add("List Item Six.");
|
||||
this.numberedListInCell(workbook, listItems, cell, 1, 2);
|
||||
row.setHeight((short) 1550);
|
||||
|
||||
// Create a cell at A4 and insert a numbered list into that cell.
|
||||
// Note that a couple of items have been added to the listItems
|
||||
// ArrayList
|
||||
row = sheet.createRow(3);
|
||||
cell = row.createCell(0);
|
||||
listItems.add("List Item Seven.");
|
||||
listItems.add("List Item Eight.");
|
||||
listItems.add("List Item Nine.");
|
||||
listItems.add("List Item Ten.");
|
||||
this.bulletedListInCell(workbook, listItems, cell);
|
||||
row.setHeight((short) 2550);
|
||||
|
||||
// Insert a plain, multi-level list into cell A5. Note that
|
||||
// the major difference here is that the list items are passed as
|
||||
// an ArrayList of MultiLevelListItems. Note that an ArrayList
|
||||
// of instances of an inner class was used here in preference to
|
||||
// a Hashtable or HashMap as the ArrayList will preserve the
|
||||
// ordering of the items added to it; the first item added will
|
||||
// be the first item recovered and the last item added, the last
|
||||
// item recovered. Alternatively, a LinkedHashMap could be used
|
||||
// to preserve order.
|
||||
row = sheet.createRow(4);
|
||||
cell = row.createCell(0);
|
||||
List<MultiLevelListItem> multiLevelListItems = new ArrayList<>();
|
||||
listItems = new ArrayList<>();
|
||||
listItems.add("ML List Item One - Sub Item One.");
|
||||
listItems.add("ML List Item One - Sub Item Two.");
|
||||
listItems.add("ML List Item One - Sub Item Three.");
|
||||
listItems.add("ML List Item One - Sub Item Four.");
|
||||
multiLevelListItems.add(new MultiLevelListItem("List Item One.", listItems));
|
||||
// Passing either null or an empty ArrayList will signal that
|
||||
// there are no lower level items associated with the top level
|
||||
// item
|
||||
multiLevelListItems.add(new MultiLevelListItem("List Item Two.", null));
|
||||
multiLevelListItems.add(new MultiLevelListItem("List Item Three.", null));
|
||||
listItems = new ArrayList<>();
|
||||
listItems.add("ML List Item Four - Sub Item One.");
|
||||
listItems.add("ML List Item Four - Sub Item Two.");
|
||||
listItems.add("ML List Item Four - Sub Item Three.");
|
||||
multiLevelListItems.add(new MultiLevelListItem("List Item Four.", listItems));
|
||||
this.multiLevelListInCell(workbook, multiLevelListItems, cell);
|
||||
row.setHeight((short) 2800);
|
||||
|
||||
// Insert a numbered multi-level list into cell A6. Note that the
|
||||
// same ArrayList as constructed for the above plain multi-level
|
||||
// list example will be re-used
|
||||
row = sheet.createRow(5);
|
||||
cell = row.createCell(0);
|
||||
this.multiLevelNumberedListInCell(workbook, multiLevelListItems,
|
||||
cell, 1, 1, 1, 2);
|
||||
row.setHeight((short) 2800);
|
||||
|
||||
// Insert a numbered multi-level list into cell A7. Note that the
|
||||
// same ArrayList as constructed for the plain multi-level list
|
||||
// example will be re-used
|
||||
row = sheet.createRow(6);
|
||||
cell = row.createCell(0);
|
||||
this.multiLevelBulletedListInCell(workbook, multiLevelListItems, cell);
|
||||
row.setHeight((short) 2800);
|
||||
|
||||
// Save the completed workbook
|
||||
try (FileOutputStream fos = new FileOutputStream(new File(outputFilename))) {
|
||||
workbook.write(fos);
|
||||
}
|
||||
} catch (IOException ioEx) {
|
||||
System.out.println("Caught a: " + ioEx.getClass().getName());
|
||||
System.out.println("Message: " + ioEx.getMessage());
|
||||
System.out.println("Stacktrace follows...........");
|
||||
ioEx.printStackTrace(System.out);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Inserts a single bulleted item into a cell.
|
||||
*
|
||||
* @param workbook A reference to the HSSFWorkbook that 'contains' the
|
||||
* cell.
|
||||
* @param listItem An instance of the String class encapsulating the
|
||||
* items text.
|
||||
* @param cell An instance of the HSSFCell class that encapsulates a
|
||||
* reference to the spreadsheet cell into which the list item
|
||||
* will be written.
|
||||
*/
|
||||
public void bulletedItemInCell(HSSFWorkbook workbook, String listItem, HSSFCell cell) {
|
||||
// A format String must be built to ensure that the contents of the
|
||||
// cell appear as a bulleted item.
|
||||
HSSFDataFormat format = workbook.createDataFormat();
|
||||
String formatString = InCellLists.BULLET_CHARACTER + " @";
|
||||
int formatIndex = format.getFormat(formatString);
|
||||
|
||||
// Construct an HSSFCellStyle and set it's data formt to use the
|
||||
// object created above.
|
||||
HSSFCellStyle bulletStyle = workbook.createCellStyle();
|
||||
bulletStyle.setDataFormat((short)formatIndex);
|
||||
|
||||
// Set the cells contents and style.
|
||||
cell.setCellValue(new HSSFRichTextString(listItem));
|
||||
cell.setCellStyle(bulletStyle);
|
||||
}
|
||||
|
||||
/**
|
||||
* Inserts a list of plain items - that is items that are neither
|
||||
* numbered or bulleted - into a single cell.
|
||||
*
|
||||
* @param workbook A reference to the HSSFWorkbook that 'contains' the
|
||||
* cell.
|
||||
* @param listItems An ArrayList whose elements encapsulate the text for
|
||||
* the list's items.
|
||||
* @param cell An instance of the HSSFCell class that encapsulates a
|
||||
* reference to the spreadsheet cell into which the list
|
||||
* will be written.
|
||||
*/
|
||||
public void listInCell(HSSFWorkbook workbook, List<String> listItems, HSSFCell cell) {
|
||||
StringBuilder buffer = new StringBuilder();
|
||||
HSSFCellStyle wrapStyle = workbook.createCellStyle();
|
||||
wrapStyle.setWrapText(true);
|
||||
for(String listItem : listItems) {
|
||||
buffer.append(listItem);
|
||||
buffer.append("\n");
|
||||
}
|
||||
// The StringBuilder's contents are the source for the contents
|
||||
// of the cell.
|
||||
cell.setCellValue(new HSSFRichTextString(buffer.toString().trim()));
|
||||
cell.setCellStyle(wrapStyle);
|
||||
}
|
||||
|
||||
/**
|
||||
* Inserts a numbered list into a single cell.
|
||||
*
|
||||
* @param workbook A reference to the HSSFWorkbook that 'contains' the
|
||||
* cell.
|
||||
* @param listItems An ArrayList whose elements encapsulate the text for
|
||||
* the lists items.
|
||||
* @param cell An instance of the HSSFCell class that encapsulates a
|
||||
* reference to the spreadsheet cell into which the list
|
||||
* will be written.
|
||||
* @param startingValue A primitive int containing the number for the first
|
||||
* item in the list.
|
||||
* @param increment A primitive int containing the value that should be used
|
||||
* to calculate subsequent item numbers.
|
||||
*/
|
||||
public void numberedListInCell(HSSFWorkbook workbook,
|
||||
List<String> listItems,
|
||||
HSSFCell cell,
|
||||
int startingValue,
|
||||
int increment) {
|
||||
StringBuilder buffer = new StringBuilder();
|
||||
int itemNumber = startingValue;
|
||||
// Note that again, an HSSFCellStye object is required and that
|
||||
// it's wrap text property should be set to 'true'
|
||||
HSSFCellStyle wrapStyle = workbook.createCellStyle();
|
||||
wrapStyle.setWrapText(true);
|
||||
// Note that the basic method is identical to the listInCell() method
|
||||
// with one difference; a number prefixed to the items text.
|
||||
for(String listItem : listItems) {
|
||||
buffer.append(itemNumber).append(". ");
|
||||
buffer.append(listItem);
|
||||
buffer.append("\n");
|
||||
itemNumber += increment;
|
||||
}
|
||||
// The StringBuilder's contents are the source for the contents
|
||||
// of the cell.
|
||||
cell.setCellValue(new HSSFRichTextString(buffer.toString().trim()));
|
||||
cell.setCellStyle(wrapStyle);
|
||||
}
|
||||
|
||||
/**
|
||||
* Insert a bulleted list into a cell.
|
||||
*
|
||||
* @param workbook A reference to the HSSFWorkbook that 'contains' the
|
||||
* cell.
|
||||
* @param listItems An ArrayList whose elements encapsulate the text for
|
||||
* the lists items.
|
||||
* @param cell An instance of the HSSFCell class that encapsulates a
|
||||
* reference to the spreadsheet cell into which the list
|
||||
* will be written.
|
||||
*/
|
||||
public void bulletedListInCell(HSSFWorkbook workbook,
|
||||
List<String> listItems,
|
||||
HSSFCell cell) {
|
||||
StringBuilder buffer = new StringBuilder();
|
||||
// Note that again, an HSSFCellStye object is required and that
|
||||
// it's wrap text property should be set to 'true'
|
||||
HSSFCellStyle wrapStyle = workbook.createCellStyle();
|
||||
wrapStyle.setWrapText(true);
|
||||
// Note that the basic method is identical to the listInCell() method
|
||||
// with one difference; the bullet character prefixed to the items text.
|
||||
for(String listItem : listItems) {
|
||||
buffer.append(InCellLists.BULLET_CHARACTER + " ");
|
||||
buffer.append(listItem);
|
||||
buffer.append("\n");
|
||||
}
|
||||
// The StringBuilder's contents are the source for the contents
|
||||
// of the cell.
|
||||
cell.setCellValue(new HSSFRichTextString(buffer.toString().trim()));
|
||||
cell.setCellStyle(wrapStyle);
|
||||
}
|
||||
|
||||
/**
|
||||
* Insert a multi-level list into a cell.
|
||||
*
|
||||
* @param workbook A reference to the HSSFWorkbook that 'contains' the
|
||||
* cell.
|
||||
* @param multiLevelListItems An ArrayList whose elements contain instances
|
||||
* of the MultiLevelListItem class. Each element
|
||||
* encapsulates the text for the high level item
|
||||
* along with an ArrayList. Each element of this
|
||||
* ArrayList encapsulates the text for a lower
|
||||
* level item.
|
||||
* @param cell An instance of the HSSFCell class that encapsulates a
|
||||
* reference to the spreadsheet cell into which the list
|
||||
* will be written.
|
||||
*/
|
||||
public void multiLevelListInCell(HSSFWorkbook workbook,
|
||||
List<MultiLevelListItem> multiLevelListItems,
|
||||
HSSFCell cell) {
|
||||
StringBuilder buffer = new StringBuilder();
|
||||
// Note that again, an HSSFCellStye object is required and that
|
||||
// it's wrap text property should be set to 'true'
|
||||
HSSFCellStyle wrapStyle = workbook.createCellStyle();
|
||||
wrapStyle.setWrapText(true);
|
||||
// Step through the ArrayList of MultilLevelListItem instances.
|
||||
for(MultiLevelListItem multiLevelListItem : multiLevelListItems) {
|
||||
// For each element in the ArrayList, get the text for the high
|
||||
// level list item......
|
||||
buffer.append(multiLevelListItem.getItemText());
|
||||
buffer.append("\n");
|
||||
// and then an ArrayList whose elements encapsulate the text
|
||||
// for the lower level list items.
|
||||
List<String> lowerLevelItems = multiLevelListItem.getLowerLevelItems();
|
||||
if (lowerLevelItems == null || lowerLevelItems.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
for(String item : lowerLevelItems) {
|
||||
buffer.append(InCellLists.TAB);
|
||||
buffer.append(item);
|
||||
buffer.append("\n");
|
||||
}
|
||||
}
|
||||
// The StringBuilder's contents are the source for the contents
|
||||
// of the cell.
|
||||
cell.setCellValue(new HSSFRichTextString(buffer.toString().trim()));
|
||||
cell.setCellStyle(wrapStyle);
|
||||
}
|
||||
|
||||
/**
|
||||
* Insert a multi-level list into a cell.
|
||||
*
|
||||
* @param workbook A reference to the HSSFWorkbook that 'contains' the
|
||||
* cell.
|
||||
* @param multiLevelListItems An ArrayList whose elements contain instances
|
||||
* of the MultiLevelListItem class. Each element
|
||||
* encapsulates the text for the high level item
|
||||
* along with an ArrayList. Each element of this
|
||||
* ArrayList encapsulates the text for a lower
|
||||
* level item.
|
||||
* @param cell An instance of the HSSFCell class that encapsulates a
|
||||
* reference to the spreadsheet cell into which the list
|
||||
* will be written.
|
||||
* @param highLevelStartingValue A primitive int containing the number
|
||||
* for the first high level item in the list.
|
||||
* @param highLevelIncrement A primitive int containing the value that
|
||||
* should be used to calculate the number of
|
||||
* subsequent high level item.
|
||||
* @param lowLevelStartingValue A primitive int will containing the number
|
||||
* for the first low level item associated
|
||||
* with a high level item.
|
||||
* @param lowLevelIncrement A primitive int containing the value that
|
||||
* should be used to calculate the number of
|
||||
* subsequent low level item.
|
||||
*/
|
||||
public void multiLevelNumberedListInCell(HSSFWorkbook workbook,
|
||||
List<MultiLevelListItem> multiLevelListItems,
|
||||
HSSFCell cell,
|
||||
int highLevelStartingValue,
|
||||
int highLevelIncrement,
|
||||
int lowLevelStartingValue,
|
||||
int lowLevelIncrement) {
|
||||
StringBuilder buffer = new StringBuilder();
|
||||
int highLevelItemNumber = highLevelStartingValue;
|
||||
// Note that again, an HSSFCellStye object is required and that
|
||||
// it's wrap text property should be set to 'true'
|
||||
HSSFCellStyle wrapStyle = workbook.createCellStyle();
|
||||
wrapStyle.setWrapText(true);
|
||||
// Step through the ArrayList of MultilLevelListItem instances.
|
||||
for(MultiLevelListItem multiLevelListItem : multiLevelListItems) {
|
||||
// For each element in the ArrayList, get the text for the high
|
||||
// level list item......
|
||||
buffer.append(highLevelItemNumber);
|
||||
buffer.append(". ");
|
||||
buffer.append(multiLevelListItem.getItemText());
|
||||
buffer.append("\n");
|
||||
// and then an ArrayList whose elements encapsulate the text
|
||||
// for the lower level list items.
|
||||
List<String> lowerLevelItems = multiLevelListItem.getLowerLevelItems();
|
||||
if(lowerLevelItems != null && !lowerLevelItems.isEmpty()) {
|
||||
int lowLevelItemNumber = lowLevelStartingValue;
|
||||
for(String item : lowerLevelItems) {
|
||||
buffer.append(InCellLists.TAB);
|
||||
buffer.append(highLevelItemNumber);
|
||||
buffer.append(".");
|
||||
buffer.append(lowLevelItemNumber);
|
||||
buffer.append(" ");
|
||||
buffer.append(item);
|
||||
buffer.append("\n");
|
||||
lowLevelItemNumber += lowLevelIncrement;
|
||||
}
|
||||
}
|
||||
highLevelItemNumber += highLevelIncrement;
|
||||
}
|
||||
// The StringBuilder's contents are the source for the contents
|
||||
// of the cell.
|
||||
cell.setCellValue(new HSSFRichTextString(buffer.toString().trim()));
|
||||
cell.setCellStyle(wrapStyle);
|
||||
}
|
||||
|
||||
/**
|
||||
* Insert a bulleted multi-level list into a cell.
|
||||
*
|
||||
* @param workbook A reference to the HSSFWorkbook that 'contains' the
|
||||
* cell.
|
||||
* @param multiLevelListItems An ArrayList whose elements contain instances
|
||||
* of the MultiLevelListItem class. Each element
|
||||
* encapsulates the text for the high level item
|
||||
* along with an ArrayList. Each element of this
|
||||
* ArrayList encapsulates the text for a lower
|
||||
* level item.
|
||||
* @param cell An instance of the HSSFCell class that encapsulates a
|
||||
* reference to the spreadsheet cell into which the list
|
||||
* will be written.
|
||||
*/
|
||||
public void multiLevelBulletedListInCell(HSSFWorkbook workbook,
|
||||
List<MultiLevelListItem> multiLevelListItems,
|
||||
HSSFCell cell) {
|
||||
StringBuilder buffer = new StringBuilder();
|
||||
// Note that again, an HSSFCellStye object is required and that
|
||||
// it's wrap text property should be set to 'true'
|
||||
HSSFCellStyle wrapStyle = workbook.createCellStyle();
|
||||
wrapStyle.setWrapText(true);
|
||||
// Step through the ArrayList of MultilLevelListItem instances.
|
||||
for(MultiLevelListItem multiLevelListItem : multiLevelListItems) {
|
||||
// For each element in the ArrayList, get the text for the high
|
||||
// level list item......
|
||||
buffer.append(InCellLists.BULLET_CHARACTER);
|
||||
buffer.append(" ");
|
||||
buffer.append(multiLevelListItem.getItemText());
|
||||
buffer.append("\n");
|
||||
// and then an ArrayList whose elements encapsulate the text
|
||||
// for the lower level list items.
|
||||
List<String> lowerLevelItems = multiLevelListItem.getLowerLevelItems();
|
||||
if(lowerLevelItems != null && !lowerLevelItems.isEmpty()) {
|
||||
for(String item : lowerLevelItems) {
|
||||
buffer.append(InCellLists.TAB);
|
||||
buffer.append(InCellLists.BULLET_CHARACTER);
|
||||
buffer.append(" ");
|
||||
buffer.append(item);
|
||||
buffer.append("\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
// The StringBuilder's contents are the source for the contents
|
||||
// of the cell.
|
||||
cell.setCellValue(new HSSFRichTextString(buffer.toString().trim()));
|
||||
cell.setCellStyle(wrapStyle);
|
||||
}
|
||||
|
||||
/**
|
||||
* The main entry point to the program. Demonstrates how to call the method
|
||||
* that will create an Excel workbook containing many different sorts of
|
||||
* lists.
|
||||
*
|
||||
* @param args the command line arguments.
|
||||
*/
|
||||
public static void main(String[] args) throws IOException {
|
||||
new InCellLists().demonstrateMethodCalls("Latest In Cell List.xls");
|
||||
}
|
||||
|
||||
/**
|
||||
* An instance of this inner class models an item or element in a
|
||||
* multi-level list. Each multi-level list item consists of the text for the
|
||||
* high level items and an ArrayList containing the text for each of the
|
||||
* associated lower level items. When written into a cell, each multi-level
|
||||
* list item will have this general appearance.
|
||||
*
|
||||
* Item One
|
||||
* Sub Item One.
|
||||
* Sub Item Two.
|
||||
* Item Two
|
||||
* Sub Item One.
|
||||
* Sub Item Two.
|
||||
* etc.
|
||||
*
|
||||
* It would be quite possible to modify this class to model much more
|
||||
* complex list structures descending through two, three or even more
|
||||
* levels.
|
||||
*/
|
||||
public final class MultiLevelListItem {
|
||||
|
||||
private String itemText;
|
||||
private List<String> lowerLevelItems;
|
||||
|
||||
/**
|
||||
* Create a new instance of the MultiLevelListItem class using the
|
||||
* following parameters.
|
||||
*
|
||||
* @param itemText A String that encapsulates the text for the high
|
||||
* level list item.
|
||||
* @param lowerLevelItems An ArrayList whose elements encapsulate the
|
||||
* text for the associated lower level list
|
||||
* items.
|
||||
*/
|
||||
public MultiLevelListItem(String itemText, List<String> lowerLevelItems) {
|
||||
this.itemText = itemText;
|
||||
this.lowerLevelItems = lowerLevelItems;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the text for the high level list item.
|
||||
*
|
||||
* @return A String that encapsulates the text for the high level list
|
||||
* item.
|
||||
*/
|
||||
public String getItemText() {
|
||||
return(this.itemText);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the text for the associated lower level list items.
|
||||
*
|
||||
* @return An ArrayList whose elements each encapsulate the text for a
|
||||
* single associated lower level list item.
|
||||
*/
|
||||
public List<String> getLowerLevelItems() {
|
||||
return lowerLevelItems;
|
||||
}
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user