Merge branch 'trunk' into asf-site

This commit is contained in:
PJ Fanning 2026-02-16 20:00:27 +01:00
commit d701e1da65
178 changed files with 4242 additions and 2890 deletions

View File

@ -34,9 +34,16 @@ plugins {
id 'com.dorongold.task-tree' version '4.0.1'
id 'org.nosphere.apache.rat' version '0.8.1'
id 'distribution'
id 'com.github.spotbugs' version '6.4.7' // 6.2.0+ requires JDK 11
// 6.2.0+ requires JDK 11
// this is the version of the Gradle plugin, it usually includes a
// different version of spotbugs itself
// Latest spotbugs: https://github.com/spotbugs/spotbugs
// Latest gradle plugin: https://plugins.gradle.org/plugin/com.github.spotbugs
id 'com.github.spotbugs' version '6.4.8'
id 'de.thetaphi.forbiddenapis' version '3.10'
id 'org.sonarqube' version '7.1.0.6387'
id 'org.sonarqube' version '7.2.2.6593'
id 'org.cyclonedx.bom' version '2.4.1'
id 'com.adarshr.test-logger' version '4.0.0'
}
@ -108,13 +115,13 @@ subprojects {
ext {
bouncyCastleVersion = '1.83'
commonsCodecVersion = '1.20.0'
commonsCodecVersion = '1.21.0'
commonsCompressVersion = '1.28.0'
commonsIoVersion = '2.21.0'
commonsMathVersion = '3.6.1'
junitVersion = '5.13.4'
log4jVersion = '2.24.3'
mockitoVersion = '5.20.0'
log4jVersion = '2.25.3'
mockitoVersion = '5.21.0'
hamcrestVersion = '3.0'
xmlbeansVersion = '5.3.0'
batikVersion = '1.19'
@ -210,7 +217,7 @@ subprojects {
links 'https://poi.apache.org/apidocs/dev/'
if (jdkVersion >= 23) links 'https://docs.oracle.com/en/java/javase/23/docs/api/' else links 'https://docs.oracle.com/en/java/javase/11/docs/api/'
links 'https://xmlbeans.apache.org/docs/5.0.0/'
links 'https://commons.apache.org/proper/commons-compress/apidocs/'
links 'https://javadoc.io/doc/org.apache.commons/commons-compress/1.27.1/'
use = true
splitIndex = true
source = "11"
@ -227,14 +234,14 @@ subprojects {
tasks.withType(Jar).configureEach {
duplicatesStrategy = DuplicatesStrategy.FAIL
destinationDirectory = file("../build/dist/maven/${project.archivesBaseName}")
destinationDirectory = file("../build/dist/maven/${base.archivesName.get()}")
doLast {
// make sure we do not have distribution jar-files with different versions
// in the build-dir as those lead to strange errors about "duplicate modules"
// when building java9 JPMS class files ("java9")
ant.delete(failOnError: true, verbose: true) {
fileset(dir: "../build/dist/maven/${project.archivesBaseName}", erroronmissingdir: false) {
fileset(dir: "../build/dist/maven/${base.archivesName.get()}", erroronmissingdir: false) {
include(name: '*.jar')
exclude(name: "*${version}.jar")
exclude(name: "*${version}-sources.jar")
@ -260,7 +267,7 @@ subprojects {
}
// use failOnError=false for -javadoc and -tests as not all modules create this directory
ant.delete(failOnError: false, verbose: true) {
fileset(dir: "../build/dist/maven/${project.archivesBaseName}-javadoc", erroronmissingdir: false) {
fileset(dir: "../build/dist/maven/${base.archivesName.get()}-javadoc", erroronmissingdir: false) {
include(name: '*-javadoc.jar')
exclude(name: "*${version}-javadoc.jar")
@ -275,7 +282,7 @@ subprojects {
}
}
ant.delete(failOnError: false, verbose: true) {
fileset(dir: "../build/dist/maven/${project.archivesBaseName}-tests", erroronmissingdir: false) {
fileset(dir: "../build/dist/maven/${base.archivesName.get()}-tests", erroronmissingdir: false) {
include(name: '*-tests.jar')
exclude(name: "*${version}-tests.jar")
@ -290,8 +297,8 @@ subprojects {
}
}
ant.checksum(file: it.archivePath, algorithm: 'SHA-256', fileext: '.sha256', format: 'MD5SUM')
ant.checksum(file: it.archivePath, algorithm: 'SHA-512', fileext: '.sha512', format: 'MD5SUM')
ant.checksum(file: it.archiveFile.get().asFile, algorithm: 'SHA-256', fileext: '.sha256', format: 'MD5SUM')
ant.checksum(file: it.archiveFile.get().asFile, algorithm: 'SHA-512', fileext: '.sha512', format: 'MD5SUM')
}
}
@ -319,11 +326,11 @@ subprojects {
javadocJar {
// if javadocs and binaries are in the same directory, JPMS complaints about duplicated modules
// in the module-path
destinationDirectory = file("../build/dist/maven/${project.archivesBaseName}-javadoc")
destinationDirectory = file("../build/dist/maven/${base.archivesName.get()}-javadoc")
}
sourcesJar {
destinationDirectory = file("../build/dist/maven/${project.archivesBaseName}")
destinationDirectory = file("../build/dist/maven/${base.archivesName.get()}")
exclude 'META-INF/services/**'
}
@ -503,8 +510,8 @@ subprojects {
publishing {
publications {
POI(MavenPublication) {
groupId 'org.apache.poi'
artifactId project.archivesBaseName
groupId = 'org.apache.poi'
artifactId = base.archivesName.get()
from components.java
@ -585,7 +592,7 @@ subprojects {
}
}
generatePomFileForPOIPublication.destination = "../build/dist/maven/${project.archivesBaseName}/${project.archivesBaseName}-${project.version}.pom"
generatePomFileForPOIPublication.destination = "../build/dist/maven/${base.archivesName.get()}/${base.archivesName.get()}-${project.version}.pom"
tasks.withType(GenerateModuleMetadata).configureEach {
enabled = false

View File

@ -268,7 +268,7 @@ under the License.
<dependency prefix="main.commons-math3" artifact="org.apache.commons:commons-math3:3.6.1" usage="main"/>
<dependency prefix="main.commons-io" artifact="commons-io:commons-io:2.20.0" usage="main"/>
<dependency prefix="main.com.zaxxer" artifact="com.zaxxer:SparseBitSet:1.3" usage="main"/>
<dependency prefix="main.log4j-api" artifact="org.apache.logging.log4j:log4j-api:2.24.3" usage="main"/>
<dependency prefix="main.log4j-api" artifact="org.apache.logging.log4j:log4j-api:2.25.3" usage="main"/>
<dependency prefix="main.junit-api" artifact="org.junit.jupiter:junit-jupiter-api:5.13.4" usage="main-tests"/>
<dependency prefix="main.junit-jengine" artifact="org.junit.jupiter:junit-jupiter-engine:5.13.4" usage="main-tests"/>
@ -288,7 +288,7 @@ under the License.
<dependency prefix="main.byte-buddy" artifact="net.bytebuddy:byte-buddy:1.17.5" usage="main-tests"/>
<dependency prefix="main.byte-buddy-agent" artifact="net.bytebuddy:byte-buddy-agent:1.17.5" usage="main-tests"/>
<dependency prefix="main.objenesis" artifact="org.objenesis:objenesis:3.1" usage="main-tests"/>
<dependency prefix="main.log4j-core" artifact="org.apache.logging.log4j:log4j-core:2.24.3" usage="main-tests"/>
<dependency prefix="main.log4j-core" artifact="org.apache.logging.log4j:log4j-core:2.25.3" usage="main-tests"/>
<dependency prefix="main.commons-logging" artifact="commons-logging:commons-logging:1.2" usage="main-tests"/>
<dependency prefix="main.ant" artifact="org.apache.ant:ant:1.10.15" usage="excelant"/>

188
gradlew.bat vendored
View File

@ -1,94 +1,94 @@
@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
@rem SPDX-License-Identifier: Apache-2.0
@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=.
@rem This is normally unused
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% equ 0 goto execute
echo. 1>&2
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto execute
echo. 1>&2
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2
goto fail
:execute
@rem Setup the command line
set CLASSPATH=
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %*
:end
@rem End local scope for the variables with windows NT shell
if %ERRORLEVEL% equ 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!
set EXIT_CODE=%ERRORLEVEL%
if %EXIT_CODE% equ 0 set EXIT_CODE=1
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
exit /b %EXIT_CODE%
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega
@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
@rem SPDX-License-Identifier: Apache-2.0
@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=.
@rem This is normally unused
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% equ 0 goto execute
echo. 1>&2
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto execute
echo. 1>&2
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2
goto fail
:execute
@rem Setup the command line
set CLASSPATH=
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %*
:end
@rem End local scope for the variables with windows NT shell
if %ERRORLEVEL% equ 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!
set EXIT_CODE=%ERRORLEVEL%
if %EXIT_CODE% equ 0 set EXIT_CODE=1
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
exit /b %EXIT_CODE%
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega

View File

@ -1,5 +1,5 @@
Apache POI
Copyright 2003-2025 The Apache Software Foundation
Copyright 2003-2026 The Apache Software Foundation
This product includes software developed at
The Apache Software Foundation (https://www.apache.org/).

View File

@ -231,7 +231,7 @@
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.24.3</version>
<version>2.25.3</version>
<scope>test</scope>
</dependency>
</dependencies>

View File

@ -67,7 +67,7 @@ tasks.register('compileJava9', JavaCompile) {
jar {
dependsOn compileJava9
destinationDirectory = file("../build/dist/maven/${project.archivesBaseName}")
destinationDirectory = file("../build/dist/maven/${base.archivesName.get()}")
manifest {
attributes('Automatic-Module-Name': MODULE_NAME, 'Multi-Release': 'true')

View File

@ -1,251 +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.xslf.usermodel;
import java.awt.Rectangle;
import java.awt.image.BufferedImage;
import java.io.ByteArrayOutputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URL;
import java.text.DecimalFormat;
import javax.imageio.ImageIO;
import javax.xml.namespace.QName;
import org.apache.poi.openxml4j.opc.PackagePart;
import org.apache.poi.openxml4j.opc.PackagePartName;
import org.apache.poi.openxml4j.opc.PackageRelationship;
import org.apache.poi.openxml4j.opc.PackagingURIHelper;
import org.apache.poi.openxml4j.opc.TargetMode;
import org.apache.poi.sl.usermodel.PictureData.PictureType;
import org.apache.xmlbeans.XmlCursor;
import org.openxmlformats.schemas.drawingml.x2006.main.CTHyperlink;
import org.openxmlformats.schemas.officeDocument.x2006.relationships.STRelationshipId;
import org.openxmlformats.schemas.presentationml.x2006.main.CTApplicationNonVisualDrawingProps;
import org.openxmlformats.schemas.presentationml.x2006.main.CTExtension;
import org.openxmlformats.schemas.presentationml.x2006.main.CTPicture;
import org.openxmlformats.schemas.presentationml.x2006.main.CTSlide;
import org.openxmlformats.schemas.presentationml.x2006.main.CTTLCommonMediaNodeData;
import org.openxmlformats.schemas.presentationml.x2006.main.CTTLCommonTimeNodeData;
import org.openxmlformats.schemas.presentationml.x2006.main.CTTimeNodeList;
import org.openxmlformats.schemas.presentationml.x2006.main.STTLTimeIndefinite;
import org.openxmlformats.schemas.presentationml.x2006.main.STTLTimeNodeFillType;
import org.openxmlformats.schemas.presentationml.x2006.main.STTLTimeNodeRestartType;
import org.openxmlformats.schemas.presentationml.x2006.main.STTLTimeNodeType;
import com.xuggle.mediatool.IMediaReader;
import com.xuggle.mediatool.MediaListenerAdapter;
import com.xuggle.mediatool.ToolFactory;
import com.xuggle.mediatool.event.IVideoPictureEvent;
import com.xuggle.xuggler.Global;
import com.xuggle.xuggler.IContainer;
import com.xuggle.xuggler.io.InputOutputStreamHandler;
/**
* Adding multiple videos to a slide
*
* need the Xuggler 5.4 jars:
* &lt;repositories&gt;
* &lt;repository&gt;
* &lt;id&gt;xuggle repo&lt;/id&gt;
* &lt;url&gt;http://xuggle.googlecode.com/svn/trunk/repo/share/java/&lt;/url&gt;
* &lt;/repository&gt;
* &lt;/repositories&gt;
* ...
* &lt;dependency&gt;
* &lt;groupId&gt;xuggle&lt;/groupId&gt;
* &lt;artifactId&gt;xuggle-xuggler&lt;/artifactId&gt;
* &lt;version&gt;5.4&lt;/version&gt;
* &lt;/dependency&gt;
*
* @see <a href="http://stackoverflow.com/questions/15197300/apache-poi-xslf-adding-movie-to-the-slide">Apache POI XSLF Adding movie to the slide</a>
* @see <a href="http://apache-poi.1045710.n5.nabble.com/Question-about-embedded-video-in-PPTX-files-tt5718461.html">Question about embedded video in PPTX files</a>
*/
public class AddVideoToPptx {
static DecimalFormat df_time = new DecimalFormat("0.####");
public static void main(String[] args) throws Exception {
URL video = new URL("http://archive.org/download/test-mpeg/test-mpeg.mpg");
// URL video = new URL("file:test-mpeg.mpg");
XMLSlideShow pptx = new XMLSlideShow();
// add video file
String videoFileName = video.getPath().substring(video.getPath().lastIndexOf('/')+1);
PackagePartName partName = PackagingURIHelper.createPartName("/ppt/media/"+videoFileName);
PackagePart part = pptx.getPackage().createPart(partName, "video/mpeg");
OutputStream partOs = part.getOutputStream();
InputStream fis = video.openStream();
byte buf[] = new byte[1024];
for (int readBytes; (readBytes = fis.read(buf)) != -1; partOs.write(buf, 0, readBytes));
fis.close();
partOs.close();
XSLFSlide slide1 = pptx.createSlide();
XSLFPictureShape pv1 = addPreview(pptx, slide1, part, 5, 50, 50);
addVideo(pptx, slide1, part, pv1, 5);
addTimingInfo(slide1, pv1);
XSLFPictureShape pv2 = addPreview(pptx, slide1, part, 9, 50, 250);
addVideo(pptx, slide1, part, pv2, 9);
addTimingInfo(slide1, pv2);
FileOutputStream fos = new FileOutputStream("pptx-with-video.pptx");
pptx.write(fos);
fos.close();
pptx.close();
}
static XSLFPictureShape addPreview(XMLSlideShow pptx, XSLFSlide slide1, PackagePart videoPart, double seconds, int x, int y) throws IOException {
// get preview after 5 sec.
IContainer ic = IContainer.make();
InputOutputStreamHandler iosh = new InputOutputStreamHandler(videoPart.getInputStream());
if (ic.open(iosh, IContainer.Type.READ, null) < 0) return null;
IMediaReader mediaReader = ToolFactory.makeReader(ic);
// stipulate that we want BufferedImages created in BGR 24bit color space
mediaReader.setBufferedImageTypeToGenerate(BufferedImage.TYPE_3BYTE_BGR);
ImageSnapListener isl = new ImageSnapListener(seconds);
mediaReader.addListener(isl);
// read out the contents of the media file and
// dispatch events to the attached listener
while (!isl.hasFired && mediaReader.readPacket() == null) ;
mediaReader.close();
ic.close();
// add snapshot
BufferedImage image1 = isl.image;
ByteArrayOutputStream bos = new ByteArrayOutputStream();
ImageIO.write(image1, "jpeg", bos);
XSLFPictureData snap = pptx.addPicture(bos.toByteArray(), PictureType.JPEG);
XSLFPictureShape pic1 = slide1.createPicture(snap);
pic1.setAnchor(new Rectangle(x, y, image1.getWidth(), image1.getHeight()));
return pic1;
}
static void addVideo(XMLSlideShow pptx, XSLFSlide slide1, PackagePart videoPart, XSLFPictureShape pic1, double seconds) throws IOException {
// add video shape
PackagePartName partName = videoPart.getPartName();
PackageRelationship prsEmbed1 = slide1.getPackagePart().addRelationship(partName, TargetMode.INTERNAL, "http://schemas.microsoft.com/office/2007/relationships/media");
PackageRelationship prsExec1 = slide1.getPackagePart().addRelationship(partName, TargetMode.INTERNAL, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/video");
CTPicture xpic1 = (CTPicture)pic1.getXmlObject();
CTHyperlink link1 = xpic1.getNvPicPr().getCNvPr().addNewHlinkClick();
link1.setId("");
link1.setAction("ppaction://media");
// add video relation
CTApplicationNonVisualDrawingProps nvPr = xpic1.getNvPicPr().getNvPr();
nvPr.addNewVideoFile().setLink(prsExec1.getId());
CTExtension ext = nvPr.addNewExtLst().addNewExt();
// see http://msdn.microsoft.com/en-us/library/dd950140(v=office.12).aspx
ext.setUri("{DAA4B4D4-6D71-4841-9C94-3DE7FCFB9230}");
String p14Ns = "http://schemas.microsoft.com/office/powerpoint/2010/main";
try (XmlCursor cur = ext.newCursor()) {
cur.toEndToken();
cur.beginElement(new QName(p14Ns, "media", "p14"));
cur.insertNamespace("p14", p14Ns);
cur.insertAttributeWithValue(new QName(STRelationshipId.type.getName().getNamespaceURI(), "embed"), prsEmbed1.getId());
cur.beginElement(new QName(p14Ns, "trim", "p14"));
cur.insertAttributeWithValue("st", df_time.format(seconds*1000.0));
}
}
static void addTimingInfo(XSLFSlide slide1, XSLFPictureShape pic1) {
// add slide timing information, so video can be controlled
CTSlide xslide = slide1.getXmlObject();
CTTimeNodeList ctnl;
if (!xslide.isSetTiming()) {
CTTLCommonTimeNodeData ctn = xslide.addNewTiming().addNewTnLst().addNewPar().addNewCTn();
ctn.setDur(STTLTimeIndefinite.INDEFINITE);
ctn.setRestart(STTLTimeNodeRestartType.NEVER);
ctn.setNodeType(STTLTimeNodeType.TM_ROOT);
ctnl = ctn.addNewChildTnLst();
} else {
ctnl = xslide.getTiming().getTnLst().getParArray(0).getCTn().getChildTnLst();
}
CTTLCommonMediaNodeData cmedia = ctnl.addNewVideo().addNewCMediaNode();
cmedia.setVol(80000);
CTTLCommonTimeNodeData ctn = cmedia.addNewCTn();
ctn.setFill(STTLTimeNodeFillType.HOLD);
ctn.setDisplay(false);
ctn.addNewStCondLst().addNewCond().setDelay(STTLTimeIndefinite.INDEFINITE);
cmedia.addNewTgtEl().addNewSpTgt().setSpid(""+pic1.getShapeId());
}
static class ImageSnapListener extends MediaListenerAdapter {
final double SECONDS_BETWEEN_FRAMES;
final long MICRO_SECONDS_BETWEEN_FRAMES;
boolean hasFired = false;
BufferedImage image = null;
// The video stream index, used to ensure we display frames from one and
// only one video stream from the media container.
int mVideoStreamIndex = -1;
// Time of last frame write
long mLastPtsWrite = Global.NO_PTS;
public ImageSnapListener(double seconds) {
SECONDS_BETWEEN_FRAMES = seconds;
MICRO_SECONDS_BETWEEN_FRAMES =
(long)(Global.DEFAULT_PTS_PER_SECOND * SECONDS_BETWEEN_FRAMES);
}
@Override
public void onVideoPicture(IVideoPictureEvent event) {
if (event.getStreamIndex() != mVideoStreamIndex) {
// if the selected video stream id is not yet set, go ahead an
// select this lucky video stream
if (mVideoStreamIndex != -1) return;
mVideoStreamIndex = event.getStreamIndex();
}
long evtTS = event.getTimeStamp();
// if uninitialized, back date mLastPtsWrite to get the very first frame
if (mLastPtsWrite == Global.NO_PTS)
mLastPtsWrite = Math.max(0, evtTS - MICRO_SECONDS_BETWEEN_FRAMES);
// if its time to write the next frame
if (evtTS - mLastPtsWrite >= MICRO_SECONDS_BETWEEN_FRAMES) {
if (!hasFired) {
image = event.getImage();
hasFired = true;
}
// update last write time
mLastPtsWrite += MICRO_SECONDS_BETWEEN_FRAMES;
}
}
}
}
/*
* ====================================================================
* 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.xslf.usermodel;
import java.awt.Rectangle;
import java.awt.image.BufferedImage;
import java.io.ByteArrayOutputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URL;
import java.text.DecimalFormat;
import javax.imageio.ImageIO;
import javax.xml.namespace.QName;
import org.apache.poi.openxml4j.opc.PackagePart;
import org.apache.poi.openxml4j.opc.PackagePartName;
import org.apache.poi.openxml4j.opc.PackageRelationship;
import org.apache.poi.openxml4j.opc.PackagingURIHelper;
import org.apache.poi.openxml4j.opc.TargetMode;
import org.apache.poi.sl.usermodel.PictureData.PictureType;
import org.apache.xmlbeans.XmlCursor;
import org.openxmlformats.schemas.drawingml.x2006.main.CTHyperlink;
import org.openxmlformats.schemas.officeDocument.x2006.relationships.STRelationshipId;
import org.openxmlformats.schemas.presentationml.x2006.main.CTApplicationNonVisualDrawingProps;
import org.openxmlformats.schemas.presentationml.x2006.main.CTExtension;
import org.openxmlformats.schemas.presentationml.x2006.main.CTPicture;
import org.openxmlformats.schemas.presentationml.x2006.main.CTSlide;
import org.openxmlformats.schemas.presentationml.x2006.main.CTTLCommonMediaNodeData;
import org.openxmlformats.schemas.presentationml.x2006.main.CTTLCommonTimeNodeData;
import org.openxmlformats.schemas.presentationml.x2006.main.CTTimeNodeList;
import org.openxmlformats.schemas.presentationml.x2006.main.STTLTimeIndefinite;
import org.openxmlformats.schemas.presentationml.x2006.main.STTLTimeNodeFillType;
import org.openxmlformats.schemas.presentationml.x2006.main.STTLTimeNodeRestartType;
import org.openxmlformats.schemas.presentationml.x2006.main.STTLTimeNodeType;
import com.xuggle.mediatool.IMediaReader;
import com.xuggle.mediatool.MediaListenerAdapter;
import com.xuggle.mediatool.ToolFactory;
import com.xuggle.mediatool.event.IVideoPictureEvent;
import com.xuggle.xuggler.Global;
import com.xuggle.xuggler.IContainer;
import com.xuggle.xuggler.io.InputOutputStreamHandler;
/**
* Adding multiple videos to a slide
*
* need the Xuggler 5.4 jars:
* &lt;repositories&gt;
* &lt;repository&gt;
* &lt;id&gt;xuggle repo&lt;/id&gt;
* &lt;url&gt;http://xuggle.googlecode.com/svn/trunk/repo/share/java/&lt;/url&gt;
* &lt;/repository&gt;
* &lt;/repositories&gt;
* ...
* &lt;dependency&gt;
* &lt;groupId&gt;xuggle&lt;/groupId&gt;
* &lt;artifactId&gt;xuggle-xuggler&lt;/artifactId&gt;
* &lt;version&gt;5.4&lt;/version&gt;
* &lt;/dependency&gt;
*
* @see <a href="http://stackoverflow.com/questions/15197300/apache-poi-xslf-adding-movie-to-the-slide">Apache POI XSLF Adding movie to the slide</a>
* @see <a href="http://apache-poi.1045710.n5.nabble.com/Question-about-embedded-video-in-PPTX-files-tt5718461.html">Question about embedded video in PPTX files</a>
*/
public class AddVideoToPptx {
static DecimalFormat df_time = new DecimalFormat("0.####");
public static void main(String[] args) throws Exception {
URL video = new URL("http://archive.org/download/test-mpeg/test-mpeg.mpg");
// URL video = new URL("file:test-mpeg.mpg");
XMLSlideShow pptx = new XMLSlideShow();
// add video file
String videoFileName = video.getPath().substring(video.getPath().lastIndexOf('/')+1);
PackagePartName partName = PackagingURIHelper.createPartName("/ppt/media/"+videoFileName);
PackagePart part = pptx.getPackage().createPart(partName, "video/mpeg");
OutputStream partOs = part.getOutputStream();
InputStream fis = video.openStream();
byte buf[] = new byte[1024];
for (int readBytes; (readBytes = fis.read(buf)) != -1; partOs.write(buf, 0, readBytes));
fis.close();
partOs.close();
XSLFSlide slide1 = pptx.createSlide();
XSLFPictureShape pv1 = addPreview(pptx, slide1, part, 5, 50, 50);
addVideo(pptx, slide1, part, pv1, 5);
addTimingInfo(slide1, pv1);
XSLFPictureShape pv2 = addPreview(pptx, slide1, part, 9, 50, 250);
addVideo(pptx, slide1, part, pv2, 9);
addTimingInfo(slide1, pv2);
FileOutputStream fos = new FileOutputStream("pptx-with-video.pptx");
pptx.write(fos);
fos.close();
pptx.close();
}
static XSLFPictureShape addPreview(XMLSlideShow pptx, XSLFSlide slide1, PackagePart videoPart, double seconds, int x, int y) throws IOException {
// get preview after 5 sec.
IContainer ic = IContainer.make();
InputOutputStreamHandler iosh = new InputOutputStreamHandler(videoPart.getInputStream());
if (ic.open(iosh, IContainer.Type.READ, null) < 0) return null;
IMediaReader mediaReader = ToolFactory.makeReader(ic);
// stipulate that we want BufferedImages created in BGR 24bit color space
mediaReader.setBufferedImageTypeToGenerate(BufferedImage.TYPE_3BYTE_BGR);
ImageSnapListener isl = new ImageSnapListener(seconds);
mediaReader.addListener(isl);
// read out the contents of the media file and
// dispatch events to the attached listener
while (!isl.hasFired && mediaReader.readPacket() == null) ;
mediaReader.close();
ic.close();
// add snapshot
BufferedImage image1 = isl.image;
ByteArrayOutputStream bos = new ByteArrayOutputStream();
ImageIO.write(image1, "jpeg", bos);
XSLFPictureData snap = pptx.addPicture(bos.toByteArray(), PictureType.JPEG);
XSLFPictureShape pic1 = slide1.createPicture(snap);
pic1.setAnchor(new Rectangle(x, y, image1.getWidth(), image1.getHeight()));
return pic1;
}
static void addVideo(XMLSlideShow pptx, XSLFSlide slide1, PackagePart videoPart, XSLFPictureShape pic1, double seconds) throws IOException {
// add video shape
PackagePartName partName = videoPart.getPartName();
PackageRelationship prsEmbed1 = slide1.getPackagePart().addRelationship(partName, TargetMode.INTERNAL, "http://schemas.microsoft.com/office/2007/relationships/media");
PackageRelationship prsExec1 = slide1.getPackagePart().addRelationship(partName, TargetMode.INTERNAL, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/video");
CTPicture xpic1 = (CTPicture)pic1.getXmlObject();
CTHyperlink link1 = xpic1.getNvPicPr().getCNvPr().addNewHlinkClick();
link1.setId("");
link1.setAction("ppaction://media");
// add video relation
CTApplicationNonVisualDrawingProps nvPr = xpic1.getNvPicPr().getNvPr();
nvPr.addNewVideoFile().setLink(prsExec1.getId());
CTExtension ext = nvPr.addNewExtLst().addNewExt();
// see http://msdn.microsoft.com/en-us/library/dd950140(v=office.12).aspx
ext.setUri("{DAA4B4D4-6D71-4841-9C94-3DE7FCFB9230}");
String p14Ns = "http://schemas.microsoft.com/office/powerpoint/2010/main";
try (XmlCursor cur = ext.newCursor()) {
cur.toEndToken();
cur.beginElement(new QName(p14Ns, "media", "p14"));
cur.insertNamespace("p14", p14Ns);
cur.insertAttributeWithValue(new QName(STRelationshipId.type.getName().getNamespaceURI(), "embed"), prsEmbed1.getId());
cur.beginElement(new QName(p14Ns, "trim", "p14"));
cur.insertAttributeWithValue("st", df_time.format(seconds*1000.0));
}
}
static void addTimingInfo(XSLFSlide slide1, XSLFPictureShape pic1) {
// add slide timing information, so video can be controlled
CTSlide xslide = slide1.getXmlObject();
CTTimeNodeList ctnl;
if (!xslide.isSetTiming()) {
CTTLCommonTimeNodeData ctn = xslide.addNewTiming().addNewTnLst().addNewPar().addNewCTn();
ctn.setDur(STTLTimeIndefinite.INDEFINITE);
ctn.setRestart(STTLTimeNodeRestartType.NEVER);
ctn.setNodeType(STTLTimeNodeType.TM_ROOT);
ctnl = ctn.addNewChildTnLst();
} else {
ctnl = xslide.getTiming().getTnLst().getParArray(0).getCTn().getChildTnLst();
}
CTTLCommonMediaNodeData cmedia = ctnl.addNewVideo().addNewCMediaNode();
cmedia.setVol(80000);
CTTLCommonTimeNodeData ctn = cmedia.addNewCTn();
ctn.setFill(STTLTimeNodeFillType.HOLD);
ctn.setDisplay(false);
ctn.addNewStCondLst().addNewCond().setDelay(STTLTimeIndefinite.INDEFINITE);
cmedia.addNewTgtEl().addNewSpTgt().setSpid(""+pic1.getShapeId());
}
static class ImageSnapListener extends MediaListenerAdapter {
final double SECONDS_BETWEEN_FRAMES;
final long MICRO_SECONDS_BETWEEN_FRAMES;
boolean hasFired = false;
BufferedImage image = null;
// The video stream index, used to ensure we display frames from one and
// only one video stream from the media container.
int mVideoStreamIndex = -1;
// Time of last frame write
long mLastPtsWrite = Global.NO_PTS;
public ImageSnapListener(double seconds) {
SECONDS_BETWEEN_FRAMES = seconds;
MICRO_SECONDS_BETWEEN_FRAMES =
(long)(Global.DEFAULT_PTS_PER_SECOND * SECONDS_BETWEEN_FRAMES);
}
@Override
public void onVideoPicture(IVideoPictureEvent event) {
if (event.getStreamIndex() != mVideoStreamIndex) {
// if the selected video stream id is not yet set, go ahead an
// select this lucky video stream
if (mVideoStreamIndex != -1) return;
mVideoStreamIndex = event.getStreamIndex();
}
long evtTS = event.getTimeStamp();
// if uninitialized, back date mLastPtsWrite to get the very first frame
if (mLastPtsWrite == Global.NO_PTS)
mLastPtsWrite = Math.max(0, evtTS - MICRO_SECONDS_BETWEEN_FRAMES);
// if its time to write the next frame
if (evtTS - mLastPtsWrite >= MICRO_SECONDS_BETWEEN_FRAMES) {
if (!hasFired) {
image = event.getImage();
hasFired = true;
}
// update last write time
mLastPtsWrite += MICRO_SECONDS_BETWEEN_FRAMES;
}
}
}
}

View File

@ -1,12 +1,12 @@
10 languages with most speakers as first language
countries,speakers,language
58,315,العربية
4,243,বাংলা
38,1299,中文
118,378,English
4,260,हिन्दी
2,128,日本語
15,223,português
6,119,ਪੰਜਾਬੀ
18,154,Русский язык
31,442,español
10 languages with most speakers as first language
countries,speakers,language
58,315,العربية
4,243,বাংলা
38,1299,中文
118,378,English
4,260,हिन्दी
2,128,日本語
15,223,português
6,119,ਪੰਜਾਬੀ
18,154,Русский язык
31,442,español

View File

@ -1,4 +1,4 @@
My Chart
First 1.0
Second 3.0
My Chart
First 1.0
Second 3.0
Third 4.0

View File

@ -1,12 +1,12 @@
10 languages with most speakers as first language
countries,speakers,language
58,315,العربية
4,243,বাংলা
38,1299,中文
118,378,English
4,260,हिन्दी
2,128,日本語
15,223,português
6,119,ਪੰਜਾਬੀ
18,154,Русский язык
31,442,español
10 languages with most speakers as first language
countries,speakers,language
58,315,العربية
4,243,বাংলা
38,1299,中文
118,378,English
4,260,हिन्दी
2,128,日本語
15,223,português
6,119,ਪੰਜਾਬੀ
18,154,Русский язык
31,442,español

View File

@ -95,7 +95,7 @@ tasks.register('compileTest9', JavaCompile) {
jar {
dependsOn compileJava9
destinationDirectory = file("../build/dist/maven/${project.archivesBaseName}")
destinationDirectory = file("../build/dist/maven/${base.archivesName.get()}")
manifest {
attributes('Automatic-Module-Name': MODULE_NAME, 'Multi-Release': 'true')
@ -119,7 +119,7 @@ sourcesJar {
// 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, compileTest9 ] ) {
destinationDirectory = file("../build/dist/maven/${project.archivesBaseName}-tests")
destinationDirectory = file("../build/dist/maven/${base.archivesName.get()}-tests")
setArchiveClassifier 'tests'
// ignore second module-info.class from main

View File

@ -109,7 +109,7 @@ tasks.register('compileTest9', JavaCompile) {
jar {
destinationDirectory = file("../build/dist/maven/${project.archivesBaseName}")
destinationDirectory = file("../build/dist/maven/${base.archivesName.get()}")
manifest {
attributes('Automatic-Module-Name': MODULE_NAME, 'Multi-Release': 'true')
@ -119,7 +119,7 @@ jar {
// 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, compileTest9 ] ) {
destinationDirectory = file("../build/dist/maven/${project.archivesBaseName}-tests")
destinationDirectory = file("../build/dist/maven/${base.archivesName.get()}-tests")
setArchiveClassifier 'tests'
// ignore second module-info.class from main
@ -156,9 +156,13 @@ test {
}
}
javadoc { enabled(false) }
javadoc {
enabled = false
}
sourcesJar { enabled(false) }
sourcesJar {
enabled = false
}
generateMetadataFileForPOIPublication.enabled = false
publishPOIPublicationToMavenLocal.enabled = false

View File

@ -29,6 +29,8 @@ public enum FileHandlerKnown {
HSLF,
HSMF,
HSSF,
HEMF,
HWMF,
HWPF,
OPC,
POIFS,

View File

@ -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.stress;
import static org.junit.jupiter.api.Assertions.assertInstanceOf;
import java.awt.geom.Rectangle2D;
import java.awt.image.BufferedImage;
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import org.apache.poi.hemf.record.emf.HemfRecord;
import org.apache.poi.hemf.record.emf.HemfRecordType;
import org.apache.poi.hemf.record.emf.HemfText;
import org.apache.poi.hemf.usermodel.HemfPicture;
import org.junit.jupiter.api.Test;
public class HEMFFileHandler implements FileHandler {
@Override
public void handleExtracting(File file) throws Exception {
try (InputStream stream = new BufferedInputStream(new FileInputStream(file))) {
HemfPicture picture = new HemfPicture(stream);
// mimic a bit what e.g. Tika does to extract some information from .emf files
for (HemfRecord record : picture.getRecords()) {
if (record.getEmfRecordType().equals(HemfRecordType.extTextOutW)) {
assertInstanceOf(HemfText.EmfExtTextOutW.class, record);
HemfText.EmfExtTextOutW textOut = (HemfText.EmfExtTextOutW) record;
textOut.getText(StandardCharsets.UTF_16LE);
} else if (record.getEmfRecordType().equals(HemfRecordType.extTextOutA)) {
assertInstanceOf(HemfText.EmfExtTextOutA.class, record);
HemfText.EmfExtTextOutA textOut = (HemfText.EmfExtTextOutA) record;
textOut.getText(StandardCharsets.UTF_8);
}
}
}
}
@Override
public void handleAdditional(File file) throws Exception {
// no additional checks for now
}
@Override
public void handleFile(InputStream stream, String path) throws Exception {
HemfPicture picture = new HemfPicture(stream);
for (HemfRecord record : picture.getRecords()) {
record.getEmfRecordType();
record.getGenericRecordType();
}
BufferedImage dest = new BufferedImage(256, 256, BufferedImage.TYPE_INT_ARGB);
picture.draw(dest.createGraphics(), new Rectangle2D.Double(0, 0, 256, 256));
}
@Test
void test() throws Exception {
String file = "test-data/slideshow/wrench.emf";
try (InputStream stream = new BufferedInputStream(new FileInputStream(file))) {
handleFile(stream, file);
}
handleExtracting(new File(file));
}
}

View File

@ -0,0 +1,93 @@
/* ====================================================================
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.stress;
import static org.junit.jupiter.api.Assertions.assertInstanceOf;
import java.awt.image.BufferedImage;
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.nio.charset.Charset;
import org.apache.poi.hwmf.record.HwmfFont;
import org.apache.poi.hwmf.record.HwmfRecord;
import org.apache.poi.hwmf.record.HwmfRecordType;
import org.apache.poi.hwmf.record.HwmfText;
import org.apache.poi.hwmf.usermodel.HwmfPicture;
import org.apache.poi.util.LocaleUtil;
import org.junit.jupiter.api.Test;
public class HWMFFileHandler implements FileHandler {
@Override
public void handleExtracting(File file) throws Exception {
try (InputStream stream = new BufferedInputStream(new FileInputStream(file))) {
HwmfPicture picture = new HwmfPicture(stream);
Charset charset = LocaleUtil.CHARSET_1252;
// mimic a bit what e.g. Tika does to extract some information from .wmf files
for (HwmfRecord record : picture.getRecords()) {
if (record.getWmfRecordType().equals(HwmfRecordType.createFontIndirect)) {
HwmfFont font = ((HwmfText.WmfCreateFontIndirect) record).getFont();
charset = (font.getCharset() == null || font.getCharset().getCharset() == null) ?
LocaleUtil.CHARSET_1252 : font.getCharset().getCharset();
}
if (record.getWmfRecordType().equals(HwmfRecordType.extTextOut)) {
assertInstanceOf(HwmfText.WmfExtTextOut.class, record);
HwmfText.WmfExtTextOut textOut = (HwmfText.WmfExtTextOut) record;
textOut.getText(charset);
} else if (record.getWmfRecordType().equals(HwmfRecordType.textOut)) {
assertInstanceOf(HwmfText.WmfTextOut.class, record);
HwmfText.WmfTextOut textOut = (HwmfText.WmfTextOut) record;
textOut.getText(charset);
}
}
}
}
@Override
public void handleAdditional(File file) throws Exception {
// no additional checks for now
}
@Override
public void handleFile(InputStream stream, String path) throws Exception {
HwmfPicture picture = new HwmfPicture(stream);
for (HwmfRecord record : picture.getRecords()) {
record.getWmfRecordType();
record.getGenericRecordType();
}
BufferedImage dest = new BufferedImage(256, 256, BufferedImage.TYPE_INT_ARGB);
picture.draw(dest.createGraphics());
}
@Test
void test() throws Exception {
String file = "test-data/slideshow/santa.wmf";
try (InputStream stream = new BufferedInputStream(new FileInputStream(file))) {
handleFile(stream, file);
}
handleExtracting(new File(file));
}
}

View File

@ -29,6 +29,7 @@ import java.lang.ref.WeakReference;
import org.apache.commons.io.output.UnsynchronizedByteArrayOutputStream;
import org.apache.poi.sl.draw.Drawable;
import org.apache.poi.sl.usermodel.GroupShape;
import org.apache.poi.sl.usermodel.MasterSheet;
import org.apache.poi.sl.usermodel.Notes;
import org.apache.poi.sl.usermodel.PictureData;
import org.apache.poi.sl.usermodel.Shape;
@ -76,8 +77,11 @@ public abstract class SlideShowHandler extends POIFSFileHandler {
}
}
for (Shape<?,?> shape : s.getMasterSheet()) {
readShapes(shape);
MasterSheet<?, ?> masterSheet = s.getMasterSheet();
if (masterSheet != null) {
for (Shape<?,?> shape : masterSheet) {
readShapes(shape);
}
}
}
}

View File

@ -37,6 +37,8 @@ public abstract class SpreadsheetHandler extends AbstractFileHandler {
// try to access some of the content
readContent(wb);
extractEmbedded(wb);
// write out the file
writeToArray(wb);

View File

@ -144,8 +144,14 @@ public class TestAllFiles {
"document/clusterfuzz-testcase-POIHWPFFuzzer-5696094627495936.doc",
"spreadsheet/clusterfuzz-testcase-minimized-POIHSSFFuzzer-4657005060816896.xls",
"diagram/clusterfuzz-testcase-minimized-POIHDGFFuzzer-4913778037489664.vsd",
"diagram/clusterfuzz-testcase-minimized-POIHDGFFuzzer-6478389109981184.vsd"
});
"diagram/clusterfuzz-testcase-minimized-POIHDGFFuzzer-6478389109981184.vsd",
"publisher/clusterfuzz-testcase-minimized-POIHPBFFuzzer-4918886059278336.pub",
"publisher/clusterfuzz-testcase-minimized-POIHPBFFuzzer-4918886059278336.pub",
"publisher/clusterfuzz-testcase-minimized-POIHPBFFuzzer-6325615354773504.pub",
"spreadsheet/clusterfuzz-testcase-minimized-POIHSSFFuzzer-4734163573080064.xls",
"spreadsheet/rde.imf.ru_sites_default_files_rde_documents_vodootvedenie_2020.xlsb.xls",
"publisher/clusterfuzz-testcase-minimized-POIHPBFFuzzer-6325615354773504.pub",
});
private static final Set<String> EXPECTED_FAILURES = StressTestUtils.unmodifiableHashSet(
"document/truncated62886.docx",

View File

@ -78,7 +78,7 @@ public class XSSFBFileHandler extends AbstractFileHandler {
XSSFBEventBasedExcelExtractor ex = new XSSFBEventBasedExcelExtractor(pkg);
String txt = ex.getText();
if (txt.length() < 1) {
throw new RuntimeException("Should have gotten some text.");
throw new IllegalArgumentException("Should have gotten some text.");
}
}

View File

@ -1,39 +1,39 @@
<?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.
====================================================================
-->
<xs:schema xmlns="http://schemas.microsoft.com/office/2006/keyEncryptor/certificate" xmlns:e="http://schemas.microsoft.com/office/2006/encryption" xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://schemas.microsoft.com/office/2006/keyEncryptor/certificate" elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:import namespace="http://schemas.microsoft.com/office/2006/encryption" schemaLocation="encryptionInfo.xsd"/>
<xs:simpleType name="ST_PasswordKeyEncryptorUri">
<xs:restriction base="xs:token">
<xs:enumeration value="http://schemas.microsoft.com/office/2006/keyEncryptor/certificate"/>
</xs:restriction>
</xs:simpleType>
<xs:complexType name="CT_CertificateKeyEncryptor">
<xs:attribute name="encryptedKeyValue" type="xs:base64Binary" use="required">
<xs:annotation><xs:documentation>A base64-encoded value that specifies the encrypted form of the intermediate key, which is encrypted with the public key contained within the X509Certificate attribute.</xs:documentation></xs:annotation>
</xs:attribute>
<xs:attribute name="X509Certificate" type="xs:base64Binary" use="required">
<xs:annotation><xs:documentation>A base64-encoded value that specifies a DER-encoded X.509 certificate (1) used to encrypt the intermediate key. The certificate (1) MUST contain only the public portion of the public-private key pair.</xs:documentation></xs:annotation>
</xs:attribute>
<xs:attribute name="certVerifier" type="xs:base64Binary" use="required">
<xs:annotation><xs:documentation>A base64-encoded value that specifies the HMAC of the binary data obtained by base64-decoding the X509Certificate attribute. The hashing algorithm used to derive the HMAC MUST be the hashing algorithm specified for the Encryption.keyData element. The secret key used to derive the HMAC MUST be the intermediate key. If the intermediate key is reset, any CertificateKeyEncryptor elements are also reset to contain the new intermediate key, except that the certVerifier attribute MUST match the value calculated using the current intermediate key, to verify that the CertificateKeyEncryptor element actually encrypted the current intermediate key. If a CertificateKeyEncryptor element does not have a correct certVerifier attribute, it MUST be discarded.</xs:documentation></xs:annotation>
</xs:attribute>
</xs:complexType>
<xs:element name="encryptedKey" type="CT_CertificateKeyEncryptor"/>
</xs:schema>
<?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.
====================================================================
-->
<xs:schema xmlns="http://schemas.microsoft.com/office/2006/keyEncryptor/certificate" xmlns:e="http://schemas.microsoft.com/office/2006/encryption" xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://schemas.microsoft.com/office/2006/keyEncryptor/certificate" elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:import namespace="http://schemas.microsoft.com/office/2006/encryption" schemaLocation="encryptionInfo.xsd"/>
<xs:simpleType name="ST_PasswordKeyEncryptorUri">
<xs:restriction base="xs:token">
<xs:enumeration value="http://schemas.microsoft.com/office/2006/keyEncryptor/certificate"/>
</xs:restriction>
</xs:simpleType>
<xs:complexType name="CT_CertificateKeyEncryptor">
<xs:attribute name="encryptedKeyValue" type="xs:base64Binary" use="required">
<xs:annotation><xs:documentation>A base64-encoded value that specifies the encrypted form of the intermediate key, which is encrypted with the public key contained within the X509Certificate attribute.</xs:documentation></xs:annotation>
</xs:attribute>
<xs:attribute name="X509Certificate" type="xs:base64Binary" use="required">
<xs:annotation><xs:documentation>A base64-encoded value that specifies a DER-encoded X.509 certificate (1) used to encrypt the intermediate key. The certificate (1) MUST contain only the public portion of the public-private key pair.</xs:documentation></xs:annotation>
</xs:attribute>
<xs:attribute name="certVerifier" type="xs:base64Binary" use="required">
<xs:annotation><xs:documentation>A base64-encoded value that specifies the HMAC of the binary data obtained by base64-decoding the X509Certificate attribute. The hashing algorithm used to derive the HMAC MUST be the hashing algorithm specified for the Encryption.keyData element. The secret key used to derive the HMAC MUST be the intermediate key. If the intermediate key is reset, any CertificateKeyEncryptor elements are also reset to contain the new intermediate key, except that the certVerifier attribute MUST match the value calculated using the current intermediate key, to verify that the CertificateKeyEncryptor element actually encrypted the current intermediate key. If a CertificateKeyEncryptor element does not have a correct certVerifier attribute, it MUST be discarded.</xs:documentation></xs:annotation>
</xs:attribute>
</xs:complexType>
<xs:element name="encryptedKey" type="CT_CertificateKeyEncryptor"/>
</xs:schema>

View File

@ -1,24 +1,24 @@
<?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.
====================================================================
-->
<xb:config xmlns:xb="http://xml.apache.org/xmlbeans/2004/02/xbean/config" xmlns:c="http://schemas.microsoft.com/office/2006/keyEncryptor/certificate">
<xb:qname name="c:encryptedKey" javaname="EncryptedCertificateKey"/>
<?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.
====================================================================
-->
<xb:config xmlns:xb="http://xml.apache.org/xmlbeans/2004/02/xbean/config" xmlns:c="http://schemas.microsoft.com/office/2006/keyEncryptor/certificate">
<xb:qname name="c:encryptedKey" javaname="EncryptedCertificateKey"/>
</xb:config>

View File

@ -1,259 +1,259 @@
<?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.
====================================================================
-->
<xs:schema xmlns="http://schemas.microsoft.com/office/2006/encryption" xmlns:p="http://schemas.microsoft.com/office/2006/keyEncryptor/password" xmlns:c="http://schemas.microsoft.com/office/2006/keyEncryptor/certificate" xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://schemas.microsoft.com/office/2006/encryption" elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:import namespace="http://schemas.microsoft.com/office/2006/keyEncryptor/password" schemaLocation="encryptionPassword.xsd"/>
<xs:import namespace="http://schemas.microsoft.com/office/2006/keyEncryptor/certificate" schemaLocation="encryptionCertificate.xsd"/>
<xs:simpleType name="ST_SaltSize">
<xs:annotation>
<xs:documentation>An unsigned integer that specifies the number of bytes used by a salt. It MUST be at least 1 and no greater than 65,536.</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:unsignedInt">
<xs:minInclusive value="1"/>
<xs:maxInclusive value="65536"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="ST_BlockSize">
<xs:annotation>
<xs:documentation>An unsigned integer that specifies the number of bytes used to encrypt one block of data. It MUST be at least 2, no greater than 4096, and a multiple of 2.</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:unsignedInt">
<xs:minInclusive value="2"/>
<xs:maxInclusive value="4096"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="ST_KeyBits">
<xs:annotation>
<xs:documentation>An unsigned integer that specifies the number of bits used by an encryption algorithm. It MUST be at least 8 and a multiple of 8.</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:unsignedInt">
<xs:minInclusive value="8"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="ST_HashSize">
<xs:annotation>
<xs:documentation>An unsigned integer that specifies the number of bytes used by a hash value. It MUST be at least 1, no greater than 65,536, and the same number of bytes as the hash algorithm emits.</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:unsignedInt">
<xs:minInclusive value="1"/>
<xs:maxInclusive value="65536"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="ST_SpinCount">
<xs:annotation>
<xs:documentation>An unsigned integer that specifies the number of times to iterate on a hash of a password. It MUST NOT be greater than 10,000,000.</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:unsignedInt">
<xs:minInclusive value="0"/>
<xs:maxInclusive value="10000000"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="ST_CipherAlgorithm">
<xs:annotation>
<xs:appinfo>modified for poi - list is restricted to given list in [ms-offcrypto]</xs:appinfo>
<xs:documentation>A string that specifies the cipher algorithm. Values that are not defined MAY be used, and a compliant implementation is not required to support all defined values. Any algorithm that can be resolved by name by the underlying operating system can be used for hashing or encryption. Only block algorithms are supported for encryption. AES-128 is the default encryption algorithm, and SHA-1 is the default hashing algorithm if no other algorithms have been configured.</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:token">
<xs:enumeration value="AES">
<xs:annotation>
<xs:documentation>MUST conform to the AES algorithm.</xs:documentation>
</xs:annotation>
</xs:enumeration>
<xs:enumeration value="RC2">
<xs:annotation>
<xs:documentation>MUST conform to the algorithm as specified in [RFC2268] (http://tools.ietf.org/html/rfc2268). The use of RC2 is not recommended. If RC2 is used with a key length of less than 128 bits, documents could interoperate incorrectly across different versions of Windows.</xs:documentation>
</xs:annotation>
</xs:enumeration>
<xs:enumeration value="RC4">
<xs:annotation>
<xs:documentation>MUST NOT be used.</xs:documentation>
</xs:annotation>
</xs:enumeration>
<xs:enumeration value="DES">
<xs:annotation>
<xs:documentation>MUST conform to the DES algorithm. The use of DES is not recommended. If DES is used, the key length specified in the KeyBits element is required to be set to 64 for 56-bit encryption, and the key decrypted from encryptedKeyValue of KeyEncryptor is required to include the DES parity bits.</xs:documentation>
</xs:annotation>
</xs:enumeration>
<xs:enumeration value="DESX">
<xs:annotation>
<xs:documentation>MUST conform to the algorithm as specified in [DRAFT-DESX] (http://tools.ietf.org/html/draft-ietf-ipsec-ciph-desx-00). The use of DESX is not recommended. If DESX is used, documents could interoperate incorrectly across different versions of Windows.</xs:documentation>
</xs:annotation>
</xs:enumeration>
<xs:enumeration value="3DES">
<xs:annotation>
<xs:documentation>MUST conform to the algorithm as specified in [RFC1851] (http://tools.ietf.org/html/rfc1851). If 3DES or 3DES_112 is used, the key length specified in the KeyBits element is required to be set to 192 for 168-bit encryption and 128 for 112-bit encryption, and the key decrypted from encryptedKeyValue of KeyEncryptor is required to include the DES parity bits.</xs:documentation>
</xs:annotation>
</xs:enumeration>
<xs:enumeration value="3DES_112">
<xs:annotation>
<xs:documentation>see 3DES</xs:documentation>
</xs:annotation>
</xs:enumeration>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="ST_CipherChaining">
<xs:annotation>
<xs:documentation>A string that specifies the chaining mode used by CipherAlgorithm. For more details about chaining modes, see [BCMO800-38A] (http://csrc.nist.gov/publications/nistpubs/800-38a/sp800-38a.pdf).</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:token">
<xs:enumeration value="ChainingModeCBC">
<xs:annotation>
<xs:documentation>block chaining (CBC)</xs:documentation>
</xs:annotation>
</xs:enumeration>
<xs:enumeration value="ChainingModeCFB">
<xs:annotation>
<xs:documentation>Cipher feedback chaining (CFB), with an 8-bit window</xs:documentation>
</xs:annotation>
</xs:enumeration>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="ST_HashAlgorithm">
<xs:annotation>
<xs:appinfo>modified for poi - list is restricted to given list in [ms-offcrypto]</xs:appinfo>
<xs:documentation>A string specifying a hashing algorithm. Values that are not defined MAY be used, and a compliant implementation is not required to support all defined values.</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:token">
<xs:enumeration value="SHA1">
<xs:annotation>
<xs:documentation>MUST conform to the algorithm as specified in [RFC4634] (http://tools.ietf.org/html/rfc4634).</xs:documentation>
</xs:annotation>
</xs:enumeration>
<xs:enumeration value="SHA256">
<xs:annotation>
<xs:documentation>see SHA1</xs:documentation>
</xs:annotation>
</xs:enumeration>
<xs:enumeration value="SHA384">
<xs:annotation>
<xs:documentation>see SHA1</xs:documentation>
</xs:annotation>
</xs:enumeration>
<xs:enumeration value="SHA512">
<xs:annotation>
<xs:documentation>see SHA1</xs:documentation>
</xs:annotation>
</xs:enumeration>
<xs:enumeration value="MD5">
<xs:annotation>
<xs:documentation>MUST conform to MD5.</xs:documentation>
</xs:annotation>
</xs:enumeration>
<xs:enumeration value="MD4">
<xs:annotation>
<xs:documentation>MUST conform to the algorithm as specified in [RFC1320] (http://tools.ietf.org/html/rfc1320).</xs:documentation>
</xs:annotation>
</xs:enumeration>
<xs:enumeration value="MD2">
<xs:annotation>
<xs:documentation>MUST conform to the algorithm as specified in [RFC1319] (http://tools.ietf.org/html/rfc1319).</xs:documentation>
</xs:annotation>
</xs:enumeration>
<xs:enumeration value="RIPEMD-128">
<xs:annotation>
<xs:documentation>MUST conform to the hash functions specified in [ISO/IEC 10118]. (https://en.wikipedia.org/wiki/RIPEMD)</xs:documentation>
</xs:annotation>
</xs:enumeration>
<xs:enumeration value="RIPEMD-160">
<xs:annotation>
<xs:documentation>see RIPEMD-128 (https://en.wikipedia.org/wiki/RIPEMD)</xs:documentation>
</xs:annotation>
</xs:enumeration>
<xs:enumeration value="WHIRLPOOL">
<xs:annotation>
<xs:documentation>see RIPEMD-128 (https://en.wikipedia.org/wiki/ISO/IEC_10118-3)</xs:documentation>
</xs:annotation>
</xs:enumeration>
</xs:restriction>
</xs:simpleType>
<xs:complexType name="CT_KeyData">
<xs:annotation>
<xs:documentation>A complex type that specifies the encryption used within this element. The saltValue attribute is a base64-encoded binary value that is randomly generated. The number of bytes required to decode the saltValue attribute MUST be equal to the value of the saltSize attribute.</xs:documentation>
</xs:annotation>
<xs:attribute name="saltSize" type="ST_SaltSize" use="required"/>
<xs:attribute name="blockSize" type="ST_BlockSize" use="required"/>
<xs:attribute name="keyBits" type="ST_KeyBits" use="required"/>
<xs:attribute name="hashSize" type="ST_HashSize" use="required"/>
<xs:attribute name="cipherAlgorithm" type="ST_CipherAlgorithm" use="required"/>
<xs:attribute name="cipherChaining" type="ST_CipherChaining" use="required"/>
<xs:attribute name="hashAlgorithm" type="ST_HashAlgorithm" use="required"/>
<xs:attribute name="saltValue" type="xs:base64Binary" use="required"/>
</xs:complexType>
<xs:complexType name="CT_DataIntegrity">
<xs:annotation>
<xs:documentation>A complex type that specifies data used to verify whether the encrypted data passes an integrity check. It MUST be generated using the method specified in section 2.3.4.14 (http://msdn.microsoft.com/en-us/library/dd924068(v=office.12).aspx).</xs:documentation>
</xs:annotation>
<xs:attribute name="encryptedHmacKey" type="xs:base64Binary" use="required">
<xs:annotation>
<xs:documentation>A base64-encoded value that specifies an encrypted key used in calculating the encryptedHmacValue.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="encryptedHmacValue" type="xs:base64Binary" use="required">
<xs:annotation>
<xs:documentation>A base64-encoded value that specifies an HMAC derived from encryptedHmacKey and the encrypted data.</xs:documentation>
</xs:annotation>
</xs:attribute>
</xs:complexType>
<xs:complexType name="CT_KeyEncryptor">
<xs:annotation>
<xs:appinfo>modified for POI</xs:appinfo>
<xs:documentation>A complex type that specifies the parameters used to encrypt an intermediate key, which is used to perform the final encryption of the document. To ensure extensibility, arbitrary elements can be defined to encrypt the intermediate key. The intermediate key MUST be the same for all KeyEncryptor elements.</xs:documentation>
</xs:annotation>
<xs:choice>
<xs:element ref="p:encryptedKey"/>
<xs:element ref="c:encryptedKey"/>
</xs:choice>
<xs:attribute name="uri">
<xs:annotation>
<xs:appinfo>modified for POI</xs:appinfo>
</xs:annotation>
<xs:simpleType>
<xs:restriction base="xs:token">
<xs:enumeration value="http://schemas.microsoft.com/office/2006/keyEncryptor/password"/>
<xs:enumeration value="http://schemas.microsoft.com/office/2006/keyEncryptor/certificate"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:complexType>
<xs:complexType name="CT_KeyEncryptors">
<xs:annotation>
<xs:documentation>A sequence of KeyEncryptor elements. Exactly one KeyEncryptors element MUST be present, and the KeyEncryptors element MUST contain at least one KeyEncryptor.</xs:documentation>
</xs:annotation>
<xs:sequence>
<xs:element name="keyEncryptor" type="CT_KeyEncryptor" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="CT_Encryption">
<xs:sequence>
<xs:element name="keyData" type="CT_KeyData"/>
<xs:element name="dataIntegrity" type="CT_DataIntegrity">
<xs:annotation>
<xs:appinfo>modified for POI</xs:appinfo>
<xs:documentation>All ECMA-376 documents [ECMA-376] encrypted by Microsoft Office using agile encryption will have a DataIntegrity element present. The schema allows for a DataIntegrity element to not be present because the encryption schema can be used by applications that do not create ECMA-376 documents [ECMA-376].</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="keyEncryptors" type="CT_KeyEncryptors">
<xs:annotation>
<xs:documentation>The KeyEncryptor element, which MUST be used when encrypting password-protected agile encryption documents, is either a PasswordKeyEncryptor or a CertificateKeyEncryptor. Exactly one PasswordKeyEncryptor MUST be present. Zero or more CertificateKeyEncryptor elements are contained within the KeyEncryptors element.</xs:documentation>
</xs:annotation>
</xs:element>
</xs:sequence>
</xs:complexType>
<xs:element name="encryption" type="CT_Encryption"/>
</xs:schema>
<?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.
====================================================================
-->
<xs:schema xmlns="http://schemas.microsoft.com/office/2006/encryption" xmlns:p="http://schemas.microsoft.com/office/2006/keyEncryptor/password" xmlns:c="http://schemas.microsoft.com/office/2006/keyEncryptor/certificate" xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://schemas.microsoft.com/office/2006/encryption" elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:import namespace="http://schemas.microsoft.com/office/2006/keyEncryptor/password" schemaLocation="encryptionPassword.xsd"/>
<xs:import namespace="http://schemas.microsoft.com/office/2006/keyEncryptor/certificate" schemaLocation="encryptionCertificate.xsd"/>
<xs:simpleType name="ST_SaltSize">
<xs:annotation>
<xs:documentation>An unsigned integer that specifies the number of bytes used by a salt. It MUST be at least 1 and no greater than 65,536.</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:unsignedInt">
<xs:minInclusive value="1"/>
<xs:maxInclusive value="65536"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="ST_BlockSize">
<xs:annotation>
<xs:documentation>An unsigned integer that specifies the number of bytes used to encrypt one block of data. It MUST be at least 2, no greater than 4096, and a multiple of 2.</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:unsignedInt">
<xs:minInclusive value="2"/>
<xs:maxInclusive value="4096"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="ST_KeyBits">
<xs:annotation>
<xs:documentation>An unsigned integer that specifies the number of bits used by an encryption algorithm. It MUST be at least 8 and a multiple of 8.</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:unsignedInt">
<xs:minInclusive value="8"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="ST_HashSize">
<xs:annotation>
<xs:documentation>An unsigned integer that specifies the number of bytes used by a hash value. It MUST be at least 1, no greater than 65,536, and the same number of bytes as the hash algorithm emits.</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:unsignedInt">
<xs:minInclusive value="1"/>
<xs:maxInclusive value="65536"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="ST_SpinCount">
<xs:annotation>
<xs:documentation>An unsigned integer that specifies the number of times to iterate on a hash of a password. It MUST NOT be greater than 10,000,000.</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:unsignedInt">
<xs:minInclusive value="0"/>
<xs:maxInclusive value="10000000"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="ST_CipherAlgorithm">
<xs:annotation>
<xs:appinfo>modified for poi - list is restricted to given list in [ms-offcrypto]</xs:appinfo>
<xs:documentation>A string that specifies the cipher algorithm. Values that are not defined MAY be used, and a compliant implementation is not required to support all defined values. Any algorithm that can be resolved by name by the underlying operating system can be used for hashing or encryption. Only block algorithms are supported for encryption. AES-128 is the default encryption algorithm, and SHA-1 is the default hashing algorithm if no other algorithms have been configured.</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:token">
<xs:enumeration value="AES">
<xs:annotation>
<xs:documentation>MUST conform to the AES algorithm.</xs:documentation>
</xs:annotation>
</xs:enumeration>
<xs:enumeration value="RC2">
<xs:annotation>
<xs:documentation>MUST conform to the algorithm as specified in [RFC2268] (http://tools.ietf.org/html/rfc2268). The use of RC2 is not recommended. If RC2 is used with a key length of less than 128 bits, documents could interoperate incorrectly across different versions of Windows.</xs:documentation>
</xs:annotation>
</xs:enumeration>
<xs:enumeration value="RC4">
<xs:annotation>
<xs:documentation>MUST NOT be used.</xs:documentation>
</xs:annotation>
</xs:enumeration>
<xs:enumeration value="DES">
<xs:annotation>
<xs:documentation>MUST conform to the DES algorithm. The use of DES is not recommended. If DES is used, the key length specified in the KeyBits element is required to be set to 64 for 56-bit encryption, and the key decrypted from encryptedKeyValue of KeyEncryptor is required to include the DES parity bits.</xs:documentation>
</xs:annotation>
</xs:enumeration>
<xs:enumeration value="DESX">
<xs:annotation>
<xs:documentation>MUST conform to the algorithm as specified in [DRAFT-DESX] (http://tools.ietf.org/html/draft-ietf-ipsec-ciph-desx-00). The use of DESX is not recommended. If DESX is used, documents could interoperate incorrectly across different versions of Windows.</xs:documentation>
</xs:annotation>
</xs:enumeration>
<xs:enumeration value="3DES">
<xs:annotation>
<xs:documentation>MUST conform to the algorithm as specified in [RFC1851] (http://tools.ietf.org/html/rfc1851). If 3DES or 3DES_112 is used, the key length specified in the KeyBits element is required to be set to 192 for 168-bit encryption and 128 for 112-bit encryption, and the key decrypted from encryptedKeyValue of KeyEncryptor is required to include the DES parity bits.</xs:documentation>
</xs:annotation>
</xs:enumeration>
<xs:enumeration value="3DES_112">
<xs:annotation>
<xs:documentation>see 3DES</xs:documentation>
</xs:annotation>
</xs:enumeration>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="ST_CipherChaining">
<xs:annotation>
<xs:documentation>A string that specifies the chaining mode used by CipherAlgorithm. For more details about chaining modes, see [BCMO800-38A] (http://csrc.nist.gov/publications/nistpubs/800-38a/sp800-38a.pdf).</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:token">
<xs:enumeration value="ChainingModeCBC">
<xs:annotation>
<xs:documentation>block chaining (CBC)</xs:documentation>
</xs:annotation>
</xs:enumeration>
<xs:enumeration value="ChainingModeCFB">
<xs:annotation>
<xs:documentation>Cipher feedback chaining (CFB), with an 8-bit window</xs:documentation>
</xs:annotation>
</xs:enumeration>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="ST_HashAlgorithm">
<xs:annotation>
<xs:appinfo>modified for poi - list is restricted to given list in [ms-offcrypto]</xs:appinfo>
<xs:documentation>A string specifying a hashing algorithm. Values that are not defined MAY be used, and a compliant implementation is not required to support all defined values.</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:token">
<xs:enumeration value="SHA1">
<xs:annotation>
<xs:documentation>MUST conform to the algorithm as specified in [RFC4634] (http://tools.ietf.org/html/rfc4634).</xs:documentation>
</xs:annotation>
</xs:enumeration>
<xs:enumeration value="SHA256">
<xs:annotation>
<xs:documentation>see SHA1</xs:documentation>
</xs:annotation>
</xs:enumeration>
<xs:enumeration value="SHA384">
<xs:annotation>
<xs:documentation>see SHA1</xs:documentation>
</xs:annotation>
</xs:enumeration>
<xs:enumeration value="SHA512">
<xs:annotation>
<xs:documentation>see SHA1</xs:documentation>
</xs:annotation>
</xs:enumeration>
<xs:enumeration value="MD5">
<xs:annotation>
<xs:documentation>MUST conform to MD5.</xs:documentation>
</xs:annotation>
</xs:enumeration>
<xs:enumeration value="MD4">
<xs:annotation>
<xs:documentation>MUST conform to the algorithm as specified in [RFC1320] (http://tools.ietf.org/html/rfc1320).</xs:documentation>
</xs:annotation>
</xs:enumeration>
<xs:enumeration value="MD2">
<xs:annotation>
<xs:documentation>MUST conform to the algorithm as specified in [RFC1319] (http://tools.ietf.org/html/rfc1319).</xs:documentation>
</xs:annotation>
</xs:enumeration>
<xs:enumeration value="RIPEMD-128">
<xs:annotation>
<xs:documentation>MUST conform to the hash functions specified in [ISO/IEC 10118]. (https://en.wikipedia.org/wiki/RIPEMD)</xs:documentation>
</xs:annotation>
</xs:enumeration>
<xs:enumeration value="RIPEMD-160">
<xs:annotation>
<xs:documentation>see RIPEMD-128 (https://en.wikipedia.org/wiki/RIPEMD)</xs:documentation>
</xs:annotation>
</xs:enumeration>
<xs:enumeration value="WHIRLPOOL">
<xs:annotation>
<xs:documentation>see RIPEMD-128 (https://en.wikipedia.org/wiki/ISO/IEC_10118-3)</xs:documentation>
</xs:annotation>
</xs:enumeration>
</xs:restriction>
</xs:simpleType>
<xs:complexType name="CT_KeyData">
<xs:annotation>
<xs:documentation>A complex type that specifies the encryption used within this element. The saltValue attribute is a base64-encoded binary value that is randomly generated. The number of bytes required to decode the saltValue attribute MUST be equal to the value of the saltSize attribute.</xs:documentation>
</xs:annotation>
<xs:attribute name="saltSize" type="ST_SaltSize" use="required"/>
<xs:attribute name="blockSize" type="ST_BlockSize" use="required"/>
<xs:attribute name="keyBits" type="ST_KeyBits" use="required"/>
<xs:attribute name="hashSize" type="ST_HashSize" use="required"/>
<xs:attribute name="cipherAlgorithm" type="ST_CipherAlgorithm" use="required"/>
<xs:attribute name="cipherChaining" type="ST_CipherChaining" use="required"/>
<xs:attribute name="hashAlgorithm" type="ST_HashAlgorithm" use="required"/>
<xs:attribute name="saltValue" type="xs:base64Binary" use="required"/>
</xs:complexType>
<xs:complexType name="CT_DataIntegrity">
<xs:annotation>
<xs:documentation>A complex type that specifies data used to verify whether the encrypted data passes an integrity check. It MUST be generated using the method specified in section 2.3.4.14 (http://msdn.microsoft.com/en-us/library/dd924068(v=office.12).aspx).</xs:documentation>
</xs:annotation>
<xs:attribute name="encryptedHmacKey" type="xs:base64Binary" use="required">
<xs:annotation>
<xs:documentation>A base64-encoded value that specifies an encrypted key used in calculating the encryptedHmacValue.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="encryptedHmacValue" type="xs:base64Binary" use="required">
<xs:annotation>
<xs:documentation>A base64-encoded value that specifies an HMAC derived from encryptedHmacKey and the encrypted data.</xs:documentation>
</xs:annotation>
</xs:attribute>
</xs:complexType>
<xs:complexType name="CT_KeyEncryptor">
<xs:annotation>
<xs:appinfo>modified for POI</xs:appinfo>
<xs:documentation>A complex type that specifies the parameters used to encrypt an intermediate key, which is used to perform the final encryption of the document. To ensure extensibility, arbitrary elements can be defined to encrypt the intermediate key. The intermediate key MUST be the same for all KeyEncryptor elements.</xs:documentation>
</xs:annotation>
<xs:choice>
<xs:element ref="p:encryptedKey"/>
<xs:element ref="c:encryptedKey"/>
</xs:choice>
<xs:attribute name="uri">
<xs:annotation>
<xs:appinfo>modified for POI</xs:appinfo>
</xs:annotation>
<xs:simpleType>
<xs:restriction base="xs:token">
<xs:enumeration value="http://schemas.microsoft.com/office/2006/keyEncryptor/password"/>
<xs:enumeration value="http://schemas.microsoft.com/office/2006/keyEncryptor/certificate"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:complexType>
<xs:complexType name="CT_KeyEncryptors">
<xs:annotation>
<xs:documentation>A sequence of KeyEncryptor elements. Exactly one KeyEncryptors element MUST be present, and the KeyEncryptors element MUST contain at least one KeyEncryptor.</xs:documentation>
</xs:annotation>
<xs:sequence>
<xs:element name="keyEncryptor" type="CT_KeyEncryptor" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="CT_Encryption">
<xs:sequence>
<xs:element name="keyData" type="CT_KeyData"/>
<xs:element name="dataIntegrity" type="CT_DataIntegrity">
<xs:annotation>
<xs:appinfo>modified for POI</xs:appinfo>
<xs:documentation>All ECMA-376 documents [ECMA-376] encrypted by Microsoft Office using agile encryption will have a DataIntegrity element present. The schema allows for a DataIntegrity element to not be present because the encryption schema can be used by applications that do not create ECMA-376 documents [ECMA-376].</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="keyEncryptors" type="CT_KeyEncryptors">
<xs:annotation>
<xs:documentation>The KeyEncryptor element, which MUST be used when encrypting password-protected agile encryption documents, is either a PasswordKeyEncryptor or a CertificateKeyEncryptor. Exactly one PasswordKeyEncryptor MUST be present. Zero or more CertificateKeyEncryptor elements are contained within the KeyEncryptors element.</xs:documentation>
</xs:annotation>
</xs:element>
</xs:sequence>
</xs:complexType>
<xs:element name="encryption" type="CT_Encryption"/>
</xs:schema>

View File

@ -1,25 +1,25 @@
<?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.
====================================================================
-->
<xb:config xmlns:xb="http://xml.apache.org/xmlbeans/2004/02/xbean/config" xmlns:c="http://schemas.microsoft.com/office/2006/keyEncryptor/certificate" xmlns:p="http://schemas.microsoft.com/office/2006/keyEncryptor/password">
<xb:qname name="c:encryptedKey" javaname="EncryptedCertificateKey"/>
<xb:qname name="p:encryptedKey" javaname="EncryptedPasswordKey"/>
<?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.
====================================================================
-->
<xb:config xmlns:xb="http://xml.apache.org/xmlbeans/2004/02/xbean/config" xmlns:c="http://schemas.microsoft.com/office/2006/keyEncryptor/certificate" xmlns:p="http://schemas.microsoft.com/office/2006/keyEncryptor/password">
<xb:qname name="c:encryptedKey" javaname="EncryptedCertificateKey"/>
<xb:qname name="p:encryptedKey" javaname="EncryptedPasswordKey"/>
</xb:config>

View File

@ -1,66 +1,66 @@
<?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.
====================================================================
-->
<xs:schema xmlns="http://schemas.microsoft.com/office/2006/keyEncryptor/password" xmlns:e="http://schemas.microsoft.com/office/2006/encryption" xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://schemas.microsoft.com/office/2006/keyEncryptor/password" elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:import namespace="http://schemas.microsoft.com/office/2006/encryption" schemaLocation="encryptionInfo.xsd"/>
<xs:simpleType name="ST_PasswordKeyEncryptorUri">
<xs:restriction base="xs:token">
<xs:enumeration value="http://schemas.microsoft.com/office/2006/keyEncryptor/password"/>
</xs:restriction>
</xs:simpleType>
<xs:complexType name="CT_PasswordKeyEncryptor">
<xs:attribute name="saltSize" type="e:ST_SaltSize" use="required">
<xs:annotation><xs:documentation>A SaltSize that specifies the size of the salt for a PasswordKeyEncryptor.</xs:documentation></xs:annotation>
</xs:attribute>
<xs:attribute name="blockSize" type="e:ST_BlockSize" use="required">
<xs:annotation><xs:documentation>A BlockSize that specifies the block size for a PasswordKeyEncryptor.</xs:documentation></xs:annotation>
</xs:attribute>
<xs:attribute name="keyBits" type="e:ST_KeyBits" use="required">
<xs:annotation><xs:documentation>A KeyBits that specifies the number of bits for a PasswordKeyEncryptor.</xs:documentation></xs:annotation>
</xs:attribute>
<xs:attribute name="hashSize" type="e:ST_HashSize" use="required">
<xs:annotation><xs:documentation>A HashSize that specifies the size of the binary form of the hash for a PasswordKeyEncryptor.</xs:documentation></xs:annotation>
</xs:attribute>
<xs:attribute name="cipherAlgorithm" type="e:ST_CipherAlgorithm" use="required">
<xs:annotation><xs:documentation>A CipherAlgorithm that specifies the cipher algorithm for a PasswordKeyEncryptor. The cipher algorithm specified MUST be the same as the cipher algorithm specified for the Encryption.keyData element.</xs:documentation></xs:annotation>
</xs:attribute>
<xs:attribute name="cipherChaining" type="e:ST_CipherChaining" use="required">
<xs:annotation><xs:documentation>A CipherChaining that specifies the cipher chaining mode for a PasswordKeyEncryptor.</xs:documentation></xs:annotation>
</xs:attribute>
<xs:attribute name="hashAlgorithm" type="e:ST_HashAlgorithm" use="required">
<xs:annotation><xs:documentation>A HashAlgorithm that specifies the hashing algorithm for a PasswordKeyEncryptor. The hashing algorithm specified MUST be the same as the hashing algorithm specified for the Encryption.keyData element.</xs:documentation></xs:annotation>
</xs:attribute>
<xs:attribute name="saltValue" type="xs:base64Binary" use="required">
<xs:annotation><xs:documentation>A base64-encoded binary byte array that specifies the salt value for a PasswordKeyEncryptor. The number of bytes required by the decoded form of this element MUST be saltSize.</xs:documentation></xs:annotation>
</xs:attribute>
<xs:attribute name="spinCount" type="e:ST_SpinCount" use="required">
<xs:annotation><xs:documentation>A SpinCount that specifies the spin count for a PasswordKeyEncryptor.</xs:documentation></xs:annotation>
</xs:attribute>
<xs:attribute name="encryptedVerifierHashInput" type="xs:base64Binary" use="required">
<xs:annotation><xs:documentation>A base64-encoded value that specifies the encrypted verifier hash input for a PasswordKeyEncryptor used in password verification.</xs:documentation></xs:annotation>
</xs:attribute>
<xs:attribute name="encryptedVerifierHashValue" type="xs:base64Binary" use="required">
<xs:annotation><xs:documentation>A base64-encoded value that specifies the encrypted verifier hash value for a PasswordKeyEncryptor used in password verification.</xs:documentation></xs:annotation>
</xs:attribute>
<xs:attribute name="encryptedKeyValue" type="xs:base64Binary" use="required">
<xs:annotation><xs:documentation>A base64-encoded value that specifies the encrypted form of the intermediate key.</xs:documentation></xs:annotation>
</xs:attribute>
</xs:complexType>
<xs:element name="encryptedKey" type="CT_PasswordKeyEncryptor"/>
</xs:schema>
<?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.
====================================================================
-->
<xs:schema xmlns="http://schemas.microsoft.com/office/2006/keyEncryptor/password" xmlns:e="http://schemas.microsoft.com/office/2006/encryption" xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://schemas.microsoft.com/office/2006/keyEncryptor/password" elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:import namespace="http://schemas.microsoft.com/office/2006/encryption" schemaLocation="encryptionInfo.xsd"/>
<xs:simpleType name="ST_PasswordKeyEncryptorUri">
<xs:restriction base="xs:token">
<xs:enumeration value="http://schemas.microsoft.com/office/2006/keyEncryptor/password"/>
</xs:restriction>
</xs:simpleType>
<xs:complexType name="CT_PasswordKeyEncryptor">
<xs:attribute name="saltSize" type="e:ST_SaltSize" use="required">
<xs:annotation><xs:documentation>A SaltSize that specifies the size of the salt for a PasswordKeyEncryptor.</xs:documentation></xs:annotation>
</xs:attribute>
<xs:attribute name="blockSize" type="e:ST_BlockSize" use="required">
<xs:annotation><xs:documentation>A BlockSize that specifies the block size for a PasswordKeyEncryptor.</xs:documentation></xs:annotation>
</xs:attribute>
<xs:attribute name="keyBits" type="e:ST_KeyBits" use="required">
<xs:annotation><xs:documentation>A KeyBits that specifies the number of bits for a PasswordKeyEncryptor.</xs:documentation></xs:annotation>
</xs:attribute>
<xs:attribute name="hashSize" type="e:ST_HashSize" use="required">
<xs:annotation><xs:documentation>A HashSize that specifies the size of the binary form of the hash for a PasswordKeyEncryptor.</xs:documentation></xs:annotation>
</xs:attribute>
<xs:attribute name="cipherAlgorithm" type="e:ST_CipherAlgorithm" use="required">
<xs:annotation><xs:documentation>A CipherAlgorithm that specifies the cipher algorithm for a PasswordKeyEncryptor. The cipher algorithm specified MUST be the same as the cipher algorithm specified for the Encryption.keyData element.</xs:documentation></xs:annotation>
</xs:attribute>
<xs:attribute name="cipherChaining" type="e:ST_CipherChaining" use="required">
<xs:annotation><xs:documentation>A CipherChaining that specifies the cipher chaining mode for a PasswordKeyEncryptor.</xs:documentation></xs:annotation>
</xs:attribute>
<xs:attribute name="hashAlgorithm" type="e:ST_HashAlgorithm" use="required">
<xs:annotation><xs:documentation>A HashAlgorithm that specifies the hashing algorithm for a PasswordKeyEncryptor. The hashing algorithm specified MUST be the same as the hashing algorithm specified for the Encryption.keyData element.</xs:documentation></xs:annotation>
</xs:attribute>
<xs:attribute name="saltValue" type="xs:base64Binary" use="required">
<xs:annotation><xs:documentation>A base64-encoded binary byte array that specifies the salt value for a PasswordKeyEncryptor. The number of bytes required by the decoded form of this element MUST be saltSize.</xs:documentation></xs:annotation>
</xs:attribute>
<xs:attribute name="spinCount" type="e:ST_SpinCount" use="required">
<xs:annotation><xs:documentation>A SpinCount that specifies the spin count for a PasswordKeyEncryptor.</xs:documentation></xs:annotation>
</xs:attribute>
<xs:attribute name="encryptedVerifierHashInput" type="xs:base64Binary" use="required">
<xs:annotation><xs:documentation>A base64-encoded value that specifies the encrypted verifier hash input for a PasswordKeyEncryptor used in password verification.</xs:documentation></xs:annotation>
</xs:attribute>
<xs:attribute name="encryptedVerifierHashValue" type="xs:base64Binary" use="required">
<xs:annotation><xs:documentation>A base64-encoded value that specifies the encrypted verifier hash value for a PasswordKeyEncryptor used in password verification.</xs:documentation></xs:annotation>
</xs:attribute>
<xs:attribute name="encryptedKeyValue" type="xs:base64Binary" use="required">
<xs:annotation><xs:documentation>A base64-encoded value that specifies the encrypted form of the intermediate key.</xs:documentation></xs:annotation>
</xs:attribute>
</xs:complexType>
<xs:element name="encryptedKey" type="CT_PasswordKeyEncryptor"/>
</xs:schema>

View File

@ -1,24 +1,24 @@
<?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.
====================================================================
-->
<xb:config xmlns:xb="http://xml.apache.org/xmlbeans/2004/02/xbean/config" xmlns:p="http://schemas.microsoft.com/office/2006/keyEncryptor/password">
<xb:qname name="p:encryptedKey" javaname="EncryptedPasswordKey"/>
<?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.
====================================================================
-->
<xb:config xmlns:xb="http://xml.apache.org/xmlbeans/2004/02/xbean/config" xmlns:p="http://schemas.microsoft.com/office/2006/keyEncryptor/password">
<xb:qname name="p:encryptedKey" javaname="EncryptedPasswordKey"/>
</xb:config>

View File

@ -1,103 +1,103 @@
<?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.
====================================================================
-->
<xsd:schema targetNamespace="http://schemas.microsoft.com/office/2006/digsig" elementFormDefault="qualified" xmlns="http://schemas.microsoft.com/office/2006/digsig" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:simpleType name="ST_PositiveInteger">
<xsd:restriction base="xsd:int">
<xsd:minExclusive value="0"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType name="ST_SignatureComments">
<xsd:restriction base="xsd:string">
<xsd:maxLength value="255"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType name="ST_SignatureProviderUrl">
<xsd:restriction base="xsd:string">
<xsd:maxLength value="2083"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType name="ST_SignatureText">
<xsd:restriction base="xsd:string">
<xsd:maxLength value="100"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType name="ST_SignatureType">
<xsd:restriction base="xsd:int">
<xsd:enumeration value="1"/>
<xsd:enumeration value="2"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType name="ST_Version">
<xsd:restriction base="xsd:string">
<xsd:maxLength value="64"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType name="ST_UniqueIdentifierWithBraces">
<xsd:restriction base="xsd:string">
<xsd:pattern value="\{[0-9a-fA-F]{8}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{12}\}|"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:group name="EG_RequiredChildren">
<xsd:sequence>
<xsd:element name="SetupID" type="ST_UniqueIdentifierWithBraces"/>
<xsd:element name="SignatureText" type="ST_SignatureText"/>
<xsd:element name="SignatureImage" type="xsd:base64Binary"/>
<xsd:element name="SignatureComments" type="ST_SignatureComments"/>
<xsd:element name="WindowsVersion" type="ST_Version"/>
<xsd:element name="OfficeVersion" type="ST_Version"/>
<xsd:element name="ApplicationVersion" type="ST_Version"/>
<xsd:element name="Monitors" type="ST_PositiveInteger"/>
<xsd:element name="HorizontalResolution" type="ST_PositiveInteger"/>
<xsd:element name="VerticalResolution" type="ST_PositiveInteger"/>
<xsd:element name="ColorDepth" type="ST_PositiveInteger"/>
<xsd:element name="SignatureProviderId" type="ST_UniqueIdentifierWithBraces"/>
<xsd:element name="SignatureProviderUrl" type="ST_SignatureProviderUrl"/>
<xsd:element name="SignatureProviderDetails" type="xsd:int"/>
<xsd:element name="SignatureType" type="ST_SignatureType"/>
</xsd:sequence>
</xsd:group>
<xsd:group name="EG_OptionalChildren">
<xsd:sequence>
<xsd:element name="DelegateSuggestedSigner" type="xsd:string"/>
<xsd:element name="DelegateSuggestedSigner2" type="xsd:string"/>
<xsd:element name="DelegateSuggestedSignerEmail" type="xsd:string"/>
<xsd:element name="ManifestHashAlgorithm" type="xsd:anyURI" minOccurs="0"/>
</xsd:sequence>
</xsd:group>
<xsd:group name="EG_OptionalChildrenV2">
<xsd:sequence>
<xsd:element name="Address1" type="xsd:string"/>
<xsd:element name="Address2" type="xsd:string"/>
</xsd:sequence>
</xsd:group>
<xsd:complexType name="CT_SignatureInfoV1">
<xsd:sequence>
<xsd:group ref="EG_RequiredChildren"/>
<xsd:group ref="EG_OptionalChildren" minOccurs="0"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="CT_SignatureInfoV2">
<xsd:sequence>
<xsd:group ref="EG_OptionalChildrenV2" minOccurs="0"/>
</xsd:sequence>
</xsd:complexType>
<xsd:element name="SignatureInfoV1" type="CT_SignatureInfoV1"/>
<xsd:element name="SignatureInfoV2" type="CT_SignatureInfoV2"/>
<?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.
====================================================================
-->
<xsd:schema targetNamespace="http://schemas.microsoft.com/office/2006/digsig" elementFormDefault="qualified" xmlns="http://schemas.microsoft.com/office/2006/digsig" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:simpleType name="ST_PositiveInteger">
<xsd:restriction base="xsd:int">
<xsd:minExclusive value="0"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType name="ST_SignatureComments">
<xsd:restriction base="xsd:string">
<xsd:maxLength value="255"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType name="ST_SignatureProviderUrl">
<xsd:restriction base="xsd:string">
<xsd:maxLength value="2083"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType name="ST_SignatureText">
<xsd:restriction base="xsd:string">
<xsd:maxLength value="100"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType name="ST_SignatureType">
<xsd:restriction base="xsd:int">
<xsd:enumeration value="1"/>
<xsd:enumeration value="2"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType name="ST_Version">
<xsd:restriction base="xsd:string">
<xsd:maxLength value="64"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType name="ST_UniqueIdentifierWithBraces">
<xsd:restriction base="xsd:string">
<xsd:pattern value="\{[0-9a-fA-F]{8}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{12}\}|"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:group name="EG_RequiredChildren">
<xsd:sequence>
<xsd:element name="SetupID" type="ST_UniqueIdentifierWithBraces"/>
<xsd:element name="SignatureText" type="ST_SignatureText"/>
<xsd:element name="SignatureImage" type="xsd:base64Binary"/>
<xsd:element name="SignatureComments" type="ST_SignatureComments"/>
<xsd:element name="WindowsVersion" type="ST_Version"/>
<xsd:element name="OfficeVersion" type="ST_Version"/>
<xsd:element name="ApplicationVersion" type="ST_Version"/>
<xsd:element name="Monitors" type="ST_PositiveInteger"/>
<xsd:element name="HorizontalResolution" type="ST_PositiveInteger"/>
<xsd:element name="VerticalResolution" type="ST_PositiveInteger"/>
<xsd:element name="ColorDepth" type="ST_PositiveInteger"/>
<xsd:element name="SignatureProviderId" type="ST_UniqueIdentifierWithBraces"/>
<xsd:element name="SignatureProviderUrl" type="ST_SignatureProviderUrl"/>
<xsd:element name="SignatureProviderDetails" type="xsd:int"/>
<xsd:element name="SignatureType" type="ST_SignatureType"/>
</xsd:sequence>
</xsd:group>
<xsd:group name="EG_OptionalChildren">
<xsd:sequence>
<xsd:element name="DelegateSuggestedSigner" type="xsd:string"/>
<xsd:element name="DelegateSuggestedSigner2" type="xsd:string"/>
<xsd:element name="DelegateSuggestedSignerEmail" type="xsd:string"/>
<xsd:element name="ManifestHashAlgorithm" type="xsd:anyURI" minOccurs="0"/>
</xsd:sequence>
</xsd:group>
<xsd:group name="EG_OptionalChildrenV2">
<xsd:sequence>
<xsd:element name="Address1" type="xsd:string"/>
<xsd:element name="Address2" type="xsd:string"/>
</xsd:sequence>
</xsd:group>
<xsd:complexType name="CT_SignatureInfoV1">
<xsd:sequence>
<xsd:group ref="EG_RequiredChildren"/>
<xsd:group ref="EG_OptionalChildren" minOccurs="0"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="CT_SignatureInfoV2">
<xsd:sequence>
<xsd:group ref="EG_OptionalChildrenV2" minOccurs="0"/>
</xsd:sequence>
</xsd:complexType>
<xsd:element name="SignatureInfoV1" type="CT_SignatureInfoV1"/>
<xsd:element name="SignatureInfoV2" type="CT_SignatureInfoV2"/>
</xsd:schema>

View File

@ -1,466 +1,466 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema targetNamespace="http://uri.etsi.org/01903/v1.3.2#" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://uri.etsi.org/01903/v1.3.2#" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" elementFormDefault="qualified">
<xsd:import namespace="http://www.w3.org/2000/09/xmldsig#" schemaLocation="http://www.w3.org/TR/2002/REC-xmldsig-core-20020212/xmldsig-core-schema.xsd"/>
<!-- Start auxiliary types definitions: AnyType, ObjectIdentifierType,
EncapsulatedPKIDataType and containers for time-stamp tokens -->
<!-- Start AnyType -->
<xsd:element name="Any" type="AnyType"/>
<xsd:complexType name="AnyType" mixed="true">
<xsd:sequence minOccurs="0" maxOccurs="unbounded">
<xsd:any namespace="##any" processContents="lax"/>
</xsd:sequence>
<xsd:anyAttribute namespace="##any"/>
</xsd:complexType>
<!-- End AnyType -->
<!-- Start ObjectIdentifierType-->
<xsd:element name="ObjectIdentifier" type="ObjectIdentifierType"/>
<xsd:complexType name="ObjectIdentifierType">
<xsd:sequence>
<xsd:element name="Identifier" type="IdentifierType"/>
<xsd:element name="Description" type="xsd:string" minOccurs="0"/>
<xsd:element name="DocumentationReferences" type="DocumentationReferencesType" minOccurs="0"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="IdentifierType">
<xsd:simpleContent>
<xsd:extension base="xsd:anyURI">
<xsd:attribute name="Qualifier" type="QualifierType" use="optional"/>
</xsd:extension>
</xsd:simpleContent>
</xsd:complexType>
<xsd:simpleType name="QualifierType">
<xsd:restriction base="xsd:string">
<xsd:enumeration value="OIDAsURI"/>
<xsd:enumeration value="OIDAsURN"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:complexType name="DocumentationReferencesType">
<xsd:sequence maxOccurs="unbounded">
<xsd:element name="DocumentationReference" type="xsd:anyURI"/>
</xsd:sequence>
</xsd:complexType>
<!-- End ObjectIdentifierType-->
<!-- Start EncapsulatedPKIDataType-->
<xsd:element name="EncapsulatedPKIData" type="EncapsulatedPKIDataType"/>
<xsd:complexType name="EncapsulatedPKIDataType">
<xsd:simpleContent>
<xsd:extension base="xsd:base64Binary">
<xsd:attribute name="Id" type="xsd:ID" use="optional"/>
<xsd:attribute name="Encoding" type="xsd:anyURI" use="optional"/>
</xsd:extension>
</xsd:simpleContent>
</xsd:complexType>
<!-- End EncapsulatedPKIDataType -->
<!-- Start time-stamp containers types -->
<!-- Start GenericTimeStampType -->
<xsd:element name="Include" type="IncludeType"/>
<xsd:complexType name="IncludeType">
<xsd:attribute name="URI" type="xsd:anyURI" use="required"/>
<xsd:attribute name="referencedData" type="xsd:boolean" use="optional"/>
</xsd:complexType>
<xsd:element name="ReferenceInfo" type="ReferenceInfoType"/>
<xsd:complexType name="ReferenceInfoType">
<xsd:sequence>
<xsd:element ref="ds:DigestMethod"/>
<xsd:element ref="ds:DigestValue"/>
</xsd:sequence>
<xsd:attribute name="Id" type="xsd:ID" use="optional"/>
<xsd:attribute name="URI" type="xsd:anyURI" use="optional"/>
</xsd:complexType>
<xsd:complexType name="GenericTimeStampType" abstract="true">
<xsd:sequence>
<xsd:choice minOccurs="0">
<xsd:element ref="Include" minOccurs="0" maxOccurs="unbounded"/>
<xsd:element ref="ReferenceInfo" maxOccurs="unbounded"/>
</xsd:choice>
<xsd:element ref="ds:CanonicalizationMethod" minOccurs="0"/>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="EncapsulatedTimeStamp" type="EncapsulatedPKIDataType"/>
<xsd:element name="XMLTimeStamp" type="AnyType"/>
</xsd:choice>
</xsd:sequence>
<xsd:attribute name="Id" type="xsd:ID" use="optional"/>
</xsd:complexType>
<!-- End GenericTimeStampType -->
<!-- Start XAdESTimeStampType -->
<xsd:element name="XAdESTimeStamp" type="XAdESTimeStampType"/>
<xsd:complexType name="XAdESTimeStampType">
<xsd:complexContent>
<xsd:restriction base="GenericTimeStampType">
<xsd:sequence>
<xsd:element ref="Include" minOccurs="0" maxOccurs="unbounded"/>
<xsd:element ref="ds:CanonicalizationMethod" minOccurs="0"/>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="EncapsulatedTimeStamp" type="EncapsulatedPKIDataType"/>
<xsd:element name="XMLTimeStamp" type="AnyType"/>
</xsd:choice>
</xsd:sequence>
<xsd:attribute name="Id" type="xsd:ID" use="optional"/>
</xsd:restriction>
</xsd:complexContent>
</xsd:complexType>
<!-- End XAdESTimeStampType -->
<!-- Start OtherTimeStampType -->
<xsd:element name="OtherTimeStamp" type="OtherTimeStampType"/>
<xsd:complexType name="OtherTimeStampType">
<xsd:complexContent>
<xsd:restriction base="GenericTimeStampType">
<xsd:sequence>
<xsd:element ref="ReferenceInfo" maxOccurs="unbounded"/>
<xsd:element ref="ds:CanonicalizationMethod" minOccurs="0"/>
<xsd:choice>
<xsd:element name="EncapsulatedTimeStamp" type="EncapsulatedPKIDataType"/>
<xsd:element name="XMLTimeStamp" type="AnyType"/>
</xsd:choice>
</xsd:sequence>
<xsd:attribute name="Id" type="xsd:ID" use="optional"/>
</xsd:restriction>
</xsd:complexContent>
</xsd:complexType>
<!-- End OtherTimeStampType -->
<!-- End time-stamp containers types -->
<!-- End auxiliary types definitions-->
<!-- Start container types -->
<!-- Start QualifyingProperties -->
<xsd:element name="QualifyingProperties" type="QualifyingPropertiesType"/>
<xsd:complexType name="QualifyingPropertiesType">
<xsd:sequence>
<xsd:element name="SignedProperties" type="SignedPropertiesType" minOccurs="0"/>
<xsd:element name="UnsignedProperties" type="UnsignedPropertiesType" minOccurs="0"/>
</xsd:sequence>
<xsd:attribute name="Target" type="xsd:anyURI" use="required"/>
<xsd:attribute name="Id" type="xsd:ID" use="optional"/>
</xsd:complexType>
<!-- End QualifyingProperties -->
<!-- Start SignedProperties-->
<xsd:element name="SignedProperties" type="SignedPropertiesType"/>
<xsd:complexType name="SignedPropertiesType">
<xsd:sequence>
<xsd:element name="SignedSignatureProperties" type="SignedSignaturePropertiesType" minOccurs="0"/>
<xsd:element name="SignedDataObjectProperties" type="SignedDataObjectPropertiesType" minOccurs="0"/>
</xsd:sequence>
<xsd:attribute name="Id" type="xsd:ID" use="optional"/>
</xsd:complexType>
<!-- End SignedProperties-->
<!-- Start UnsignedProperties-->
<xsd:element name="UnsignedProperties" type="UnsignedPropertiesType"/>
<xsd:complexType name="UnsignedPropertiesType">
<xsd:sequence>
<xsd:element name="UnsignedSignatureProperties" type="UnsignedSignaturePropertiesType" minOccurs="0"/>
<xsd:element name="UnsignedDataObjectProperties" type="UnsignedDataObjectPropertiesType" minOccurs="0"/>
</xsd:sequence>
<xsd:attribute name="Id" type="xsd:ID" use="optional"/>
</xsd:complexType>
<!-- End UnsignedProperties-->
<!-- Start SignedSignatureProperties-->
<xsd:element name="SignedSignatureProperties" type="SignedSignaturePropertiesType"/>
<xsd:complexType name="SignedSignaturePropertiesType">
<xsd:sequence>
<xsd:element name="SigningTime" type="xsd:dateTime" minOccurs="0"/>
<xsd:element name="SigningCertificate" type="CertIDListType" minOccurs="0"/>
<xsd:element name="SignaturePolicyIdentifier" type="SignaturePolicyIdentifierType" minOccurs="0"/>
<xsd:element name="SignatureProductionPlace" type="SignatureProductionPlaceType" minOccurs="0"/>
<xsd:element name="SignerRole" type="SignerRoleType" minOccurs="0"/>
</xsd:sequence>
<xsd:attribute name="Id" type="xsd:ID" use="optional"/>
</xsd:complexType>
<!-- End SignedSignatureProperties-->
<!-- Start SignedDataObjectProperties-->
<xsd:element name="SignedDataObjectProperties" type="SignedDataObjectPropertiesType"/>
<xsd:complexType name="SignedDataObjectPropertiesType">
<xsd:sequence>
<xsd:element name="DataObjectFormat" type="DataObjectFormatType" minOccurs="0" maxOccurs="unbounded"/>
<xsd:element name="CommitmentTypeIndication" type="CommitmentTypeIndicationType" minOccurs="0" maxOccurs="unbounded"/>
<xsd:element name="AllDataObjectsTimeStamp" type="XAdESTimeStampType" minOccurs="0" maxOccurs="unbounded"/>
<xsd:element name="IndividualDataObjectsTimeStamp" type="XAdESTimeStampType" minOccurs="0" maxOccurs="unbounded"/>
</xsd:sequence>
<xsd:attribute name="Id" type="xsd:ID" use="optional"/>
</xsd:complexType>
<!-- End SignedDataObjectProperties-->
<!-- Start UnsignedSignatureProperties-->
<xsd:element name="UnsignedSignatureProperties" type="UnsignedSignaturePropertiesType"/>
<xsd:complexType name="UnsignedSignaturePropertiesType">
<xsd:choice maxOccurs="unbounded">
<xsd:element name="CounterSignature" type="CounterSignatureType"/>
<xsd:element name="SignatureTimeStamp" type="XAdESTimeStampType"/>
<xsd:element name="CompleteCertificateRefs" type="CompleteCertificateRefsType"/>
<xsd:element name="CompleteRevocationRefs" type="CompleteRevocationRefsType"/>
<xsd:element name="AttributeCertificateRefs" type="CompleteCertificateRefsType"/>
<xsd:element name="AttributeRevocationRefs" type="CompleteRevocationRefsType"/>
<xsd:element name="SigAndRefsTimeStamp" type="XAdESTimeStampType"/>
<xsd:element name="RefsOnlyTimeStamp" type="XAdESTimeStampType"/>
<xsd:element name="CertificateValues" type="CertificateValuesType"/>
<xsd:element name="RevocationValues" type="RevocationValuesType"/>
<xsd:element name="AttrAuthoritiesCertValues" type="CertificateValuesType"/>
<xsd:element name="AttributeRevocationValues" type="RevocationValuesType"/>
<xsd:element name="ArchiveTimeStamp" type="XAdESTimeStampType"/>
<xsd:any namespace="##other"/>
</xsd:choice>
<xsd:attribute name="Id" type="xsd:ID" use="optional"/>
</xsd:complexType>
<!-- End UnsignedSignatureProperties-->
<!-- Start UnsignedDataObjectProperties-->
<xsd:element name="UnsignedDataObjectProperties" type="UnsignedDataObjectPropertiesType"/>
<xsd:complexType name="UnsignedDataObjectPropertiesType">
<xsd:sequence>
<xsd:element name="UnsignedDataObjectProperty" type="AnyType" maxOccurs="unbounded"/>
</xsd:sequence>
<xsd:attribute name="Id" type="xsd:ID" use="optional"/>
</xsd:complexType>
<!-- End UnsignedDataObjectProperties-->
<!-- Start QualifyingPropertiesReference-->
<xsd:element name="QualifyingPropertiesReference" type="QualifyingPropertiesReferenceType"/>
<xsd:complexType name="QualifyingPropertiesReferenceType">
<xsd:attribute name="URI" type="xsd:anyURI" use="required"/>
<xsd:attribute name="Id" type="xsd:ID" use="optional"/>
</xsd:complexType>
<!-- End QualifyingPropertiesReference-->
<!-- End container types -->
<!-- Start SigningTime element -->
<xsd:element name="SigningTime" type="xsd:dateTime"/>
<!-- End SigningTime element -->
<!-- Start SigningCertificate -->
<xsd:element name="SigningCertificate" type="CertIDListType"/>
<xsd:complexType name="CertIDListType">
<xsd:sequence>
<xsd:element name="Cert" type="CertIDType" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="CertIDType">
<xsd:sequence>
<xsd:element name="CertDigest" type="DigestAlgAndValueType"/>
<xsd:element name="IssuerSerial" type="ds:X509IssuerSerialType"/>
</xsd:sequence>
<xsd:attribute name="URI" type="xsd:anyURI" use="optional"/>
</xsd:complexType>
<xsd:complexType name="DigestAlgAndValueType">
<xsd:sequence>
<xsd:element ref="ds:DigestMethod"/>
<xsd:element ref="ds:DigestValue"/>
</xsd:sequence>
</xsd:complexType>
<!-- End SigningCertificate -->
<!-- Start SignaturePolicyIdentifier -->
<xsd:element name="SignaturePolicyIdentifier" type="SignaturePolicyIdentifierType"/>
<xsd:complexType name="SignaturePolicyIdentifierType">
<xsd:choice>
<xsd:element name="SignaturePolicyId" type="SignaturePolicyIdType"/>
<xsd:element name="SignaturePolicyImplied"/>
</xsd:choice>
</xsd:complexType>
<xsd:complexType name="SignaturePolicyIdType">
<xsd:sequence>
<xsd:element name="SigPolicyId" type="ObjectIdentifierType"/>
<xsd:element ref="ds:Transforms" minOccurs="0"/>
<xsd:element name="SigPolicyHash" type="DigestAlgAndValueType"/>
<xsd:element name="SigPolicyQualifiers" type="SigPolicyQualifiersListType" minOccurs="0"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="SigPolicyQualifiersListType">
<xsd:sequence>
<xsd:element name="SigPolicyQualifier" type="AnyType" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
<xsd:element name="SPURI" type="xsd:anyURI"/>
<xsd:element name="SPUserNotice" type="SPUserNoticeType"/>
<xsd:complexType name="SPUserNoticeType">
<xsd:sequence>
<xsd:element name="NoticeRef" type="NoticeReferenceType" minOccurs="0"/>
<xsd:element name="ExplicitText" type="xsd:string" minOccurs="0"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="NoticeReferenceType">
<xsd:sequence>
<xsd:element name="Organization" type="xsd:string"/>
<xsd:element name="NoticeNumbers" type="IntegerListType"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="IntegerListType">
<xsd:sequence>
<xsd:element name="int" type="xsd:integer" minOccurs="0" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
<!-- End SignaturePolicyIdentifier -->
<!-- Start CounterSignature -->
<xsd:element name="CounterSignature" type="CounterSignatureType"/>
<xsd:complexType name="CounterSignatureType">
<xsd:sequence>
<xsd:element ref="ds:Signature"/>
</xsd:sequence>
</xsd:complexType>
<!-- End CounterSignature -->
<!-- Start DataObjectFormat -->
<xsd:element name="DataObjectFormat" type="DataObjectFormatType"/>
<xsd:complexType name="DataObjectFormatType">
<xsd:sequence>
<xsd:element name="Description" type="xsd:string" minOccurs="0"/>
<xsd:element name="ObjectIdentifier" type="ObjectIdentifierType" minOccurs="0"/>
<xsd:element name="MimeType" type="xsd:string" minOccurs="0"/>
<xsd:element name="Encoding" type="xsd:anyURI" minOccurs="0"/>
</xsd:sequence>
<xsd:attribute name="ObjectReference" type="xsd:anyURI" use="required"/>
</xsd:complexType>
<!-- End DataObjectFormat -->
<!-- Start CommitmentTypeIndication -->
<xsd:element name="CommitmentTypeIndication" type="CommitmentTypeIndicationType"/>
<xsd:complexType name="CommitmentTypeIndicationType">
<xsd:sequence>
<xsd:element name="CommitmentTypeId" type="ObjectIdentifierType"/>
<xsd:choice>
<xsd:element name="ObjectReference" type="xsd:anyURI" maxOccurs="unbounded"/>
<xsd:element name="AllSignedDataObjects"/>
</xsd:choice>
<xsd:element name="CommitmentTypeQualifiers" type="CommitmentTypeQualifiersListType" minOccurs="0"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="CommitmentTypeQualifiersListType">
<xsd:sequence>
<xsd:element name="CommitmentTypeQualifier" type="AnyType" minOccurs="0" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
<!-- End CommitmentTypeIndication -->
<!-- Start SignatureProductionPlace -->
<xsd:element name="SignatureProductionPlace" type="SignatureProductionPlaceType"/>
<xsd:complexType name="SignatureProductionPlaceType">
<xsd:sequence>
<xsd:element name="City" type="xsd:string" minOccurs="0"/>
<xsd:element name="StateOrProvince" type="xsd:string" minOccurs="0"/>
<xsd:element name="PostalCode" type="xsd:string" minOccurs="0"/>
<xsd:element name="CountryName" type="xsd:string" minOccurs="0"/>
</xsd:sequence>
</xsd:complexType>
<!-- End SignatureProductionPlace -->
<!-- Start SignerRole -->
<xsd:element name="SignerRole" type="SignerRoleType"/>
<xsd:complexType name="SignerRoleType">
<xsd:sequence>
<xsd:element name="ClaimedRoles" type="ClaimedRolesListType" minOccurs="0"/>
<xsd:element name="CertifiedRoles" type="CertifiedRolesListType" minOccurs="0"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="ClaimedRolesListType">
<xsd:sequence>
<xsd:element name="ClaimedRole" type="AnyType" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="CertifiedRolesListType">
<xsd:sequence>
<xsd:element name="CertifiedRole" type="EncapsulatedPKIDataType" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
<!-- End SignerRole -->
<xsd:element name="AllDataObjectsTimeStamp" type="XAdESTimeStampType"/>
<xsd:element name="IndividualDataObjectsTimeStamp" type="XAdESTimeStampType"/>
<xsd:element name="SignatureTimeStamp" type="XAdESTimeStampType"/>
<!-- Start CompleteCertificateRefs -->
<xsd:element name="CompleteCertificateRefs" type="CompleteCertificateRefsType"/>
<xsd:complexType name="CompleteCertificateRefsType">
<xsd:sequence>
<xsd:element name="CertRefs" type="CertIDListType"/>
</xsd:sequence>
<xsd:attribute name="Id" type="xsd:ID" use="optional"/>
</xsd:complexType>
<!-- End CompleteCertificateRefs -->
<!-- Start CompleteRevocationRefs-->
<xsd:element name="CompleteRevocationRefs" type="CompleteRevocationRefsType"/>
<xsd:complexType name="CompleteRevocationRefsType">
<xsd:sequence>
<xsd:element name="CRLRefs" type="CRLRefsType" minOccurs="0"/>
<xsd:element name="OCSPRefs" type="OCSPRefsType" minOccurs="0"/>
<xsd:element name="OtherRefs" type="OtherCertStatusRefsType" minOccurs="0"/>
</xsd:sequence>
<xsd:attribute name="Id" type="xsd:ID" use="optional"/>
</xsd:complexType>
<xsd:complexType name="CRLRefsType">
<xsd:sequence>
<xsd:element name="CRLRef" type="CRLRefType" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="CRLRefType">
<xsd:sequence>
<xsd:element name="DigestAlgAndValue" type="DigestAlgAndValueType"/>
<xsd:element name="CRLIdentifier" type="CRLIdentifierType" minOccurs="0"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="CRLIdentifierType">
<xsd:sequence>
<xsd:element name="Issuer" type="xsd:string"/>
<xsd:element name="IssueTime" type="xsd:dateTime"/>
<xsd:element name="Number" type="xsd:integer" minOccurs="0"/>
</xsd:sequence>
<xsd:attribute name="URI" type="xsd:anyURI" use="optional"/>
</xsd:complexType>
<xsd:complexType name="OCSPRefsType">
<xsd:sequence>
<xsd:element name="OCSPRef" type="OCSPRefType" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="OCSPRefType">
<xsd:sequence>
<xsd:element name="OCSPIdentifier" type="OCSPIdentifierType"/>
<xsd:element name="DigestAlgAndValue" type="DigestAlgAndValueType" minOccurs="0"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="ResponderIDType">
<xsd:choice>
<xsd:element name="ByName" type="xsd:string"/>
<xsd:element name="ByKey" type="xsd:base64Binary"/>
</xsd:choice>
</xsd:complexType>
<xsd:complexType name="OCSPIdentifierType">
<xsd:sequence>
<xsd:element name="ResponderID" type="ResponderIDType"/>
<xsd:element name="ProducedAt" type="xsd:dateTime"/>
</xsd:sequence>
<xsd:attribute name="URI" type="xsd:anyURI" use="optional"/>
</xsd:complexType>
<xsd:complexType name="OtherCertStatusRefsType">
<xsd:sequence>
<xsd:element name="OtherRef" type="AnyType" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
<!-- End CompleteRevocationRefs-->
<xsd:element name="AttributeCertificateRefs" type="CompleteCertificateRefsType"/>
<xsd:element name="AttributeRevocationRefs" type="CompleteRevocationRefsType"/>
<xsd:element name="SigAndRefsTimeStamp" type="XAdESTimeStampType"/>
<xsd:element name="RefsOnlyTimeStamp" type="XAdESTimeStampType"/>
<!-- Start CertificateValues -->
<xsd:element name="CertificateValues" type="CertificateValuesType"/>
<xsd:complexType name="CertificateValuesType">
<xsd:choice minOccurs="0" maxOccurs="unbounded">
<xsd:element name="EncapsulatedX509Certificate" type="EncapsulatedPKIDataType"/>
<xsd:element name="OtherCertificate" type="AnyType"/>
</xsd:choice>
<xsd:attribute name="Id" type="xsd:ID" use="optional"/>
</xsd:complexType>
<!-- End CertificateValues -->
<!-- Start RevocationValues-->
<xsd:element name="RevocationValues" type="RevocationValuesType"/>
<xsd:complexType name="RevocationValuesType">
<xsd:sequence>
<xsd:element name="CRLValues" type="CRLValuesType" minOccurs="0"/>
<xsd:element name="OCSPValues" type="OCSPValuesType" minOccurs="0"/>
<xsd:element name="OtherValues" type="OtherCertStatusValuesType" minOccurs="0"/>
</xsd:sequence>
<xsd:attribute name="Id" type="xsd:ID" use="optional"/>
</xsd:complexType>
<xsd:complexType name="CRLValuesType">
<xsd:sequence>
<xsd:element name="EncapsulatedCRLValue" type="EncapsulatedPKIDataType" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="OCSPValuesType">
<xsd:sequence>
<xsd:element name="EncapsulatedOCSPValue" type="EncapsulatedPKIDataType" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="OtherCertStatusValuesType">
<xsd:sequence>
<xsd:element name="OtherValue" type="AnyType" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
<!-- End RevocationValues-->
<xsd:element name="AttrAuthoritiesCertValues" type="CertificateValuesType"/>
<xsd:element name="AttributeRevocationValues" type="RevocationValuesType"/>
<xsd:element name="ArchiveTimeStamp" type="XAdESTimeStampType"/>
</xsd:schema>
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema targetNamespace="http://uri.etsi.org/01903/v1.3.2#" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://uri.etsi.org/01903/v1.3.2#" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" elementFormDefault="qualified">
<xsd:import namespace="http://www.w3.org/2000/09/xmldsig#" schemaLocation="http://www.w3.org/TR/2002/REC-xmldsig-core-20020212/xmldsig-core-schema.xsd"/>
<!-- Start auxiliary types definitions: AnyType, ObjectIdentifierType,
EncapsulatedPKIDataType and containers for time-stamp tokens -->
<!-- Start AnyType -->
<xsd:element name="Any" type="AnyType"/>
<xsd:complexType name="AnyType" mixed="true">
<xsd:sequence minOccurs="0" maxOccurs="unbounded">
<xsd:any namespace="##any" processContents="lax"/>
</xsd:sequence>
<xsd:anyAttribute namespace="##any"/>
</xsd:complexType>
<!-- End AnyType -->
<!-- Start ObjectIdentifierType-->
<xsd:element name="ObjectIdentifier" type="ObjectIdentifierType"/>
<xsd:complexType name="ObjectIdentifierType">
<xsd:sequence>
<xsd:element name="Identifier" type="IdentifierType"/>
<xsd:element name="Description" type="xsd:string" minOccurs="0"/>
<xsd:element name="DocumentationReferences" type="DocumentationReferencesType" minOccurs="0"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="IdentifierType">
<xsd:simpleContent>
<xsd:extension base="xsd:anyURI">
<xsd:attribute name="Qualifier" type="QualifierType" use="optional"/>
</xsd:extension>
</xsd:simpleContent>
</xsd:complexType>
<xsd:simpleType name="QualifierType">
<xsd:restriction base="xsd:string">
<xsd:enumeration value="OIDAsURI"/>
<xsd:enumeration value="OIDAsURN"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:complexType name="DocumentationReferencesType">
<xsd:sequence maxOccurs="unbounded">
<xsd:element name="DocumentationReference" type="xsd:anyURI"/>
</xsd:sequence>
</xsd:complexType>
<!-- End ObjectIdentifierType-->
<!-- Start EncapsulatedPKIDataType-->
<xsd:element name="EncapsulatedPKIData" type="EncapsulatedPKIDataType"/>
<xsd:complexType name="EncapsulatedPKIDataType">
<xsd:simpleContent>
<xsd:extension base="xsd:base64Binary">
<xsd:attribute name="Id" type="xsd:ID" use="optional"/>
<xsd:attribute name="Encoding" type="xsd:anyURI" use="optional"/>
</xsd:extension>
</xsd:simpleContent>
</xsd:complexType>
<!-- End EncapsulatedPKIDataType -->
<!-- Start time-stamp containers types -->
<!-- Start GenericTimeStampType -->
<xsd:element name="Include" type="IncludeType"/>
<xsd:complexType name="IncludeType">
<xsd:attribute name="URI" type="xsd:anyURI" use="required"/>
<xsd:attribute name="referencedData" type="xsd:boolean" use="optional"/>
</xsd:complexType>
<xsd:element name="ReferenceInfo" type="ReferenceInfoType"/>
<xsd:complexType name="ReferenceInfoType">
<xsd:sequence>
<xsd:element ref="ds:DigestMethod"/>
<xsd:element ref="ds:DigestValue"/>
</xsd:sequence>
<xsd:attribute name="Id" type="xsd:ID" use="optional"/>
<xsd:attribute name="URI" type="xsd:anyURI" use="optional"/>
</xsd:complexType>
<xsd:complexType name="GenericTimeStampType" abstract="true">
<xsd:sequence>
<xsd:choice minOccurs="0">
<xsd:element ref="Include" minOccurs="0" maxOccurs="unbounded"/>
<xsd:element ref="ReferenceInfo" maxOccurs="unbounded"/>
</xsd:choice>
<xsd:element ref="ds:CanonicalizationMethod" minOccurs="0"/>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="EncapsulatedTimeStamp" type="EncapsulatedPKIDataType"/>
<xsd:element name="XMLTimeStamp" type="AnyType"/>
</xsd:choice>
</xsd:sequence>
<xsd:attribute name="Id" type="xsd:ID" use="optional"/>
</xsd:complexType>
<!-- End GenericTimeStampType -->
<!-- Start XAdESTimeStampType -->
<xsd:element name="XAdESTimeStamp" type="XAdESTimeStampType"/>
<xsd:complexType name="XAdESTimeStampType">
<xsd:complexContent>
<xsd:restriction base="GenericTimeStampType">
<xsd:sequence>
<xsd:element ref="Include" minOccurs="0" maxOccurs="unbounded"/>
<xsd:element ref="ds:CanonicalizationMethod" minOccurs="0"/>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="EncapsulatedTimeStamp" type="EncapsulatedPKIDataType"/>
<xsd:element name="XMLTimeStamp" type="AnyType"/>
</xsd:choice>
</xsd:sequence>
<xsd:attribute name="Id" type="xsd:ID" use="optional"/>
</xsd:restriction>
</xsd:complexContent>
</xsd:complexType>
<!-- End XAdESTimeStampType -->
<!-- Start OtherTimeStampType -->
<xsd:element name="OtherTimeStamp" type="OtherTimeStampType"/>
<xsd:complexType name="OtherTimeStampType">
<xsd:complexContent>
<xsd:restriction base="GenericTimeStampType">
<xsd:sequence>
<xsd:element ref="ReferenceInfo" maxOccurs="unbounded"/>
<xsd:element ref="ds:CanonicalizationMethod" minOccurs="0"/>
<xsd:choice>
<xsd:element name="EncapsulatedTimeStamp" type="EncapsulatedPKIDataType"/>
<xsd:element name="XMLTimeStamp" type="AnyType"/>
</xsd:choice>
</xsd:sequence>
<xsd:attribute name="Id" type="xsd:ID" use="optional"/>
</xsd:restriction>
</xsd:complexContent>
</xsd:complexType>
<!-- End OtherTimeStampType -->
<!-- End time-stamp containers types -->
<!-- End auxiliary types definitions-->
<!-- Start container types -->
<!-- Start QualifyingProperties -->
<xsd:element name="QualifyingProperties" type="QualifyingPropertiesType"/>
<xsd:complexType name="QualifyingPropertiesType">
<xsd:sequence>
<xsd:element name="SignedProperties" type="SignedPropertiesType" minOccurs="0"/>
<xsd:element name="UnsignedProperties" type="UnsignedPropertiesType" minOccurs="0"/>
</xsd:sequence>
<xsd:attribute name="Target" type="xsd:anyURI" use="required"/>
<xsd:attribute name="Id" type="xsd:ID" use="optional"/>
</xsd:complexType>
<!-- End QualifyingProperties -->
<!-- Start SignedProperties-->
<xsd:element name="SignedProperties" type="SignedPropertiesType"/>
<xsd:complexType name="SignedPropertiesType">
<xsd:sequence>
<xsd:element name="SignedSignatureProperties" type="SignedSignaturePropertiesType" minOccurs="0"/>
<xsd:element name="SignedDataObjectProperties" type="SignedDataObjectPropertiesType" minOccurs="0"/>
</xsd:sequence>
<xsd:attribute name="Id" type="xsd:ID" use="optional"/>
</xsd:complexType>
<!-- End SignedProperties-->
<!-- Start UnsignedProperties-->
<xsd:element name="UnsignedProperties" type="UnsignedPropertiesType"/>
<xsd:complexType name="UnsignedPropertiesType">
<xsd:sequence>
<xsd:element name="UnsignedSignatureProperties" type="UnsignedSignaturePropertiesType" minOccurs="0"/>
<xsd:element name="UnsignedDataObjectProperties" type="UnsignedDataObjectPropertiesType" minOccurs="0"/>
</xsd:sequence>
<xsd:attribute name="Id" type="xsd:ID" use="optional"/>
</xsd:complexType>
<!-- End UnsignedProperties-->
<!-- Start SignedSignatureProperties-->
<xsd:element name="SignedSignatureProperties" type="SignedSignaturePropertiesType"/>
<xsd:complexType name="SignedSignaturePropertiesType">
<xsd:sequence>
<xsd:element name="SigningTime" type="xsd:dateTime" minOccurs="0"/>
<xsd:element name="SigningCertificate" type="CertIDListType" minOccurs="0"/>
<xsd:element name="SignaturePolicyIdentifier" type="SignaturePolicyIdentifierType" minOccurs="0"/>
<xsd:element name="SignatureProductionPlace" type="SignatureProductionPlaceType" minOccurs="0"/>
<xsd:element name="SignerRole" type="SignerRoleType" minOccurs="0"/>
</xsd:sequence>
<xsd:attribute name="Id" type="xsd:ID" use="optional"/>
</xsd:complexType>
<!-- End SignedSignatureProperties-->
<!-- Start SignedDataObjectProperties-->
<xsd:element name="SignedDataObjectProperties" type="SignedDataObjectPropertiesType"/>
<xsd:complexType name="SignedDataObjectPropertiesType">
<xsd:sequence>
<xsd:element name="DataObjectFormat" type="DataObjectFormatType" minOccurs="0" maxOccurs="unbounded"/>
<xsd:element name="CommitmentTypeIndication" type="CommitmentTypeIndicationType" minOccurs="0" maxOccurs="unbounded"/>
<xsd:element name="AllDataObjectsTimeStamp" type="XAdESTimeStampType" minOccurs="0" maxOccurs="unbounded"/>
<xsd:element name="IndividualDataObjectsTimeStamp" type="XAdESTimeStampType" minOccurs="0" maxOccurs="unbounded"/>
</xsd:sequence>
<xsd:attribute name="Id" type="xsd:ID" use="optional"/>
</xsd:complexType>
<!-- End SignedDataObjectProperties-->
<!-- Start UnsignedSignatureProperties-->
<xsd:element name="UnsignedSignatureProperties" type="UnsignedSignaturePropertiesType"/>
<xsd:complexType name="UnsignedSignaturePropertiesType">
<xsd:choice maxOccurs="unbounded">
<xsd:element name="CounterSignature" type="CounterSignatureType"/>
<xsd:element name="SignatureTimeStamp" type="XAdESTimeStampType"/>
<xsd:element name="CompleteCertificateRefs" type="CompleteCertificateRefsType"/>
<xsd:element name="CompleteRevocationRefs" type="CompleteRevocationRefsType"/>
<xsd:element name="AttributeCertificateRefs" type="CompleteCertificateRefsType"/>
<xsd:element name="AttributeRevocationRefs" type="CompleteRevocationRefsType"/>
<xsd:element name="SigAndRefsTimeStamp" type="XAdESTimeStampType"/>
<xsd:element name="RefsOnlyTimeStamp" type="XAdESTimeStampType"/>
<xsd:element name="CertificateValues" type="CertificateValuesType"/>
<xsd:element name="RevocationValues" type="RevocationValuesType"/>
<xsd:element name="AttrAuthoritiesCertValues" type="CertificateValuesType"/>
<xsd:element name="AttributeRevocationValues" type="RevocationValuesType"/>
<xsd:element name="ArchiveTimeStamp" type="XAdESTimeStampType"/>
<xsd:any namespace="##other"/>
</xsd:choice>
<xsd:attribute name="Id" type="xsd:ID" use="optional"/>
</xsd:complexType>
<!-- End UnsignedSignatureProperties-->
<!-- Start UnsignedDataObjectProperties-->
<xsd:element name="UnsignedDataObjectProperties" type="UnsignedDataObjectPropertiesType"/>
<xsd:complexType name="UnsignedDataObjectPropertiesType">
<xsd:sequence>
<xsd:element name="UnsignedDataObjectProperty" type="AnyType" maxOccurs="unbounded"/>
</xsd:sequence>
<xsd:attribute name="Id" type="xsd:ID" use="optional"/>
</xsd:complexType>
<!-- End UnsignedDataObjectProperties-->
<!-- Start QualifyingPropertiesReference-->
<xsd:element name="QualifyingPropertiesReference" type="QualifyingPropertiesReferenceType"/>
<xsd:complexType name="QualifyingPropertiesReferenceType">
<xsd:attribute name="URI" type="xsd:anyURI" use="required"/>
<xsd:attribute name="Id" type="xsd:ID" use="optional"/>
</xsd:complexType>
<!-- End QualifyingPropertiesReference-->
<!-- End container types -->
<!-- Start SigningTime element -->
<xsd:element name="SigningTime" type="xsd:dateTime"/>
<!-- End SigningTime element -->
<!-- Start SigningCertificate -->
<xsd:element name="SigningCertificate" type="CertIDListType"/>
<xsd:complexType name="CertIDListType">
<xsd:sequence>
<xsd:element name="Cert" type="CertIDType" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="CertIDType">
<xsd:sequence>
<xsd:element name="CertDigest" type="DigestAlgAndValueType"/>
<xsd:element name="IssuerSerial" type="ds:X509IssuerSerialType"/>
</xsd:sequence>
<xsd:attribute name="URI" type="xsd:anyURI" use="optional"/>
</xsd:complexType>
<xsd:complexType name="DigestAlgAndValueType">
<xsd:sequence>
<xsd:element ref="ds:DigestMethod"/>
<xsd:element ref="ds:DigestValue"/>
</xsd:sequence>
</xsd:complexType>
<!-- End SigningCertificate -->
<!-- Start SignaturePolicyIdentifier -->
<xsd:element name="SignaturePolicyIdentifier" type="SignaturePolicyIdentifierType"/>
<xsd:complexType name="SignaturePolicyIdentifierType">
<xsd:choice>
<xsd:element name="SignaturePolicyId" type="SignaturePolicyIdType"/>
<xsd:element name="SignaturePolicyImplied"/>
</xsd:choice>
</xsd:complexType>
<xsd:complexType name="SignaturePolicyIdType">
<xsd:sequence>
<xsd:element name="SigPolicyId" type="ObjectIdentifierType"/>
<xsd:element ref="ds:Transforms" minOccurs="0"/>
<xsd:element name="SigPolicyHash" type="DigestAlgAndValueType"/>
<xsd:element name="SigPolicyQualifiers" type="SigPolicyQualifiersListType" minOccurs="0"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="SigPolicyQualifiersListType">
<xsd:sequence>
<xsd:element name="SigPolicyQualifier" type="AnyType" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
<xsd:element name="SPURI" type="xsd:anyURI"/>
<xsd:element name="SPUserNotice" type="SPUserNoticeType"/>
<xsd:complexType name="SPUserNoticeType">
<xsd:sequence>
<xsd:element name="NoticeRef" type="NoticeReferenceType" minOccurs="0"/>
<xsd:element name="ExplicitText" type="xsd:string" minOccurs="0"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="NoticeReferenceType">
<xsd:sequence>
<xsd:element name="Organization" type="xsd:string"/>
<xsd:element name="NoticeNumbers" type="IntegerListType"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="IntegerListType">
<xsd:sequence>
<xsd:element name="int" type="xsd:integer" minOccurs="0" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
<!-- End SignaturePolicyIdentifier -->
<!-- Start CounterSignature -->
<xsd:element name="CounterSignature" type="CounterSignatureType"/>
<xsd:complexType name="CounterSignatureType">
<xsd:sequence>
<xsd:element ref="ds:Signature"/>
</xsd:sequence>
</xsd:complexType>
<!-- End CounterSignature -->
<!-- Start DataObjectFormat -->
<xsd:element name="DataObjectFormat" type="DataObjectFormatType"/>
<xsd:complexType name="DataObjectFormatType">
<xsd:sequence>
<xsd:element name="Description" type="xsd:string" minOccurs="0"/>
<xsd:element name="ObjectIdentifier" type="ObjectIdentifierType" minOccurs="0"/>
<xsd:element name="MimeType" type="xsd:string" minOccurs="0"/>
<xsd:element name="Encoding" type="xsd:anyURI" minOccurs="0"/>
</xsd:sequence>
<xsd:attribute name="ObjectReference" type="xsd:anyURI" use="required"/>
</xsd:complexType>
<!-- End DataObjectFormat -->
<!-- Start CommitmentTypeIndication -->
<xsd:element name="CommitmentTypeIndication" type="CommitmentTypeIndicationType"/>
<xsd:complexType name="CommitmentTypeIndicationType">
<xsd:sequence>
<xsd:element name="CommitmentTypeId" type="ObjectIdentifierType"/>
<xsd:choice>
<xsd:element name="ObjectReference" type="xsd:anyURI" maxOccurs="unbounded"/>
<xsd:element name="AllSignedDataObjects"/>
</xsd:choice>
<xsd:element name="CommitmentTypeQualifiers" type="CommitmentTypeQualifiersListType" minOccurs="0"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="CommitmentTypeQualifiersListType">
<xsd:sequence>
<xsd:element name="CommitmentTypeQualifier" type="AnyType" minOccurs="0" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
<!-- End CommitmentTypeIndication -->
<!-- Start SignatureProductionPlace -->
<xsd:element name="SignatureProductionPlace" type="SignatureProductionPlaceType"/>
<xsd:complexType name="SignatureProductionPlaceType">
<xsd:sequence>
<xsd:element name="City" type="xsd:string" minOccurs="0"/>
<xsd:element name="StateOrProvince" type="xsd:string" minOccurs="0"/>
<xsd:element name="PostalCode" type="xsd:string" minOccurs="0"/>
<xsd:element name="CountryName" type="xsd:string" minOccurs="0"/>
</xsd:sequence>
</xsd:complexType>
<!-- End SignatureProductionPlace -->
<!-- Start SignerRole -->
<xsd:element name="SignerRole" type="SignerRoleType"/>
<xsd:complexType name="SignerRoleType">
<xsd:sequence>
<xsd:element name="ClaimedRoles" type="ClaimedRolesListType" minOccurs="0"/>
<xsd:element name="CertifiedRoles" type="CertifiedRolesListType" minOccurs="0"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="ClaimedRolesListType">
<xsd:sequence>
<xsd:element name="ClaimedRole" type="AnyType" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="CertifiedRolesListType">
<xsd:sequence>
<xsd:element name="CertifiedRole" type="EncapsulatedPKIDataType" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
<!-- End SignerRole -->
<xsd:element name="AllDataObjectsTimeStamp" type="XAdESTimeStampType"/>
<xsd:element name="IndividualDataObjectsTimeStamp" type="XAdESTimeStampType"/>
<xsd:element name="SignatureTimeStamp" type="XAdESTimeStampType"/>
<!-- Start CompleteCertificateRefs -->
<xsd:element name="CompleteCertificateRefs" type="CompleteCertificateRefsType"/>
<xsd:complexType name="CompleteCertificateRefsType">
<xsd:sequence>
<xsd:element name="CertRefs" type="CertIDListType"/>
</xsd:sequence>
<xsd:attribute name="Id" type="xsd:ID" use="optional"/>
</xsd:complexType>
<!-- End CompleteCertificateRefs -->
<!-- Start CompleteRevocationRefs-->
<xsd:element name="CompleteRevocationRefs" type="CompleteRevocationRefsType"/>
<xsd:complexType name="CompleteRevocationRefsType">
<xsd:sequence>
<xsd:element name="CRLRefs" type="CRLRefsType" minOccurs="0"/>
<xsd:element name="OCSPRefs" type="OCSPRefsType" minOccurs="0"/>
<xsd:element name="OtherRefs" type="OtherCertStatusRefsType" minOccurs="0"/>
</xsd:sequence>
<xsd:attribute name="Id" type="xsd:ID" use="optional"/>
</xsd:complexType>
<xsd:complexType name="CRLRefsType">
<xsd:sequence>
<xsd:element name="CRLRef" type="CRLRefType" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="CRLRefType">
<xsd:sequence>
<xsd:element name="DigestAlgAndValue" type="DigestAlgAndValueType"/>
<xsd:element name="CRLIdentifier" type="CRLIdentifierType" minOccurs="0"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="CRLIdentifierType">
<xsd:sequence>
<xsd:element name="Issuer" type="xsd:string"/>
<xsd:element name="IssueTime" type="xsd:dateTime"/>
<xsd:element name="Number" type="xsd:integer" minOccurs="0"/>
</xsd:sequence>
<xsd:attribute name="URI" type="xsd:anyURI" use="optional"/>
</xsd:complexType>
<xsd:complexType name="OCSPRefsType">
<xsd:sequence>
<xsd:element name="OCSPRef" type="OCSPRefType" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="OCSPRefType">
<xsd:sequence>
<xsd:element name="OCSPIdentifier" type="OCSPIdentifierType"/>
<xsd:element name="DigestAlgAndValue" type="DigestAlgAndValueType" minOccurs="0"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="ResponderIDType">
<xsd:choice>
<xsd:element name="ByName" type="xsd:string"/>
<xsd:element name="ByKey" type="xsd:base64Binary"/>
</xsd:choice>
</xsd:complexType>
<xsd:complexType name="OCSPIdentifierType">
<xsd:sequence>
<xsd:element name="ResponderID" type="ResponderIDType"/>
<xsd:element name="ProducedAt" type="xsd:dateTime"/>
</xsd:sequence>
<xsd:attribute name="URI" type="xsd:anyURI" use="optional"/>
</xsd:complexType>
<xsd:complexType name="OtherCertStatusRefsType">
<xsd:sequence>
<xsd:element name="OtherRef" type="AnyType" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
<!-- End CompleteRevocationRefs-->
<xsd:element name="AttributeCertificateRefs" type="CompleteCertificateRefsType"/>
<xsd:element name="AttributeRevocationRefs" type="CompleteRevocationRefsType"/>
<xsd:element name="SigAndRefsTimeStamp" type="XAdESTimeStampType"/>
<xsd:element name="RefsOnlyTimeStamp" type="XAdESTimeStampType"/>
<!-- Start CertificateValues -->
<xsd:element name="CertificateValues" type="CertificateValuesType"/>
<xsd:complexType name="CertificateValuesType">
<xsd:choice minOccurs="0" maxOccurs="unbounded">
<xsd:element name="EncapsulatedX509Certificate" type="EncapsulatedPKIDataType"/>
<xsd:element name="OtherCertificate" type="AnyType"/>
</xsd:choice>
<xsd:attribute name="Id" type="xsd:ID" use="optional"/>
</xsd:complexType>
<!-- End CertificateValues -->
<!-- Start RevocationValues-->
<xsd:element name="RevocationValues" type="RevocationValuesType"/>
<xsd:complexType name="RevocationValuesType">
<xsd:sequence>
<xsd:element name="CRLValues" type="CRLValuesType" minOccurs="0"/>
<xsd:element name="OCSPValues" type="OCSPValuesType" minOccurs="0"/>
<xsd:element name="OtherValues" type="OtherCertStatusValuesType" minOccurs="0"/>
</xsd:sequence>
<xsd:attribute name="Id" type="xsd:ID" use="optional"/>
</xsd:complexType>
<xsd:complexType name="CRLValuesType">
<xsd:sequence>
<xsd:element name="EncapsulatedCRLValue" type="EncapsulatedPKIDataType" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="OCSPValuesType">
<xsd:sequence>
<xsd:element name="EncapsulatedOCSPValue" type="EncapsulatedPKIDataType" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="OtherCertStatusValuesType">
<xsd:sequence>
<xsd:element name="OtherValue" type="AnyType" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
<!-- End RevocationValues-->
<xsd:element name="AttrAuthoritiesCertValues" type="CertificateValuesType"/>
<xsd:element name="AttributeRevocationValues" type="RevocationValuesType"/>
<xsd:element name="ArchiveTimeStamp" type="XAdESTimeStampType"/>
</xsd:schema>

View File

@ -1,15 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema targetNamespace="http://uri.etsi.org/01903/v1.4.1#" xmlns="http://uri.etsi.org/01903/v1.4.1#" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xades="http://uri.etsi.org/01903/v1.3.2#" elementFormDefault="qualified">
<xsd:import namespace="http://uri.etsi.org/01903/v1.3.2#" schemaLocation="http://uri.etsi.org/01903/v1.3.2/XAdES.xsd"/>
<!-- Start CertificateValues -->
<xsd:element name="TimeStampValidationData" type="ValidationDataType"/>
<xsd:complexType name="ValidationDataType">
<xsd:sequence>
<xsd:element ref="xades:CertificateValues" minOccurs="0"/>
<xsd:element ref="xades:RevocationValues" minOccurs="0"/>
</xsd:sequence>
<xsd:attribute name="Id" type="xsd:ID" use="optional"/>
<xsd:attribute name="URI" type="xsd:anyURI" use="optional"/>
</xsd:complexType>
<xsd:element name="ArchiveTimeStamp" type="xades:XAdESTimeStampType"/>
</xsd:schema>
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema targetNamespace="http://uri.etsi.org/01903/v1.4.1#" xmlns="http://uri.etsi.org/01903/v1.4.1#" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xades="http://uri.etsi.org/01903/v1.3.2#" elementFormDefault="qualified">
<xsd:import namespace="http://uri.etsi.org/01903/v1.3.2#" schemaLocation="http://uri.etsi.org/01903/v1.3.2/XAdES.xsd"/>
<!-- Start CertificateValues -->
<xsd:element name="TimeStampValidationData" type="ValidationDataType"/>
<xsd:complexType name="ValidationDataType">
<xsd:sequence>
<xsd:element ref="xades:CertificateValues" minOccurs="0"/>
<xsd:element ref="xades:RevocationValues" minOccurs="0"/>
</xsd:sequence>
<xsd:attribute name="Id" type="xsd:ID" use="optional"/>
<xsd:attribute name="URI" type="xsd:anyURI" use="optional"/>
</xsd:complexType>
<xsd:element name="ArchiveTimeStamp" type="xades:XAdESTimeStampType"/>
</xsd:schema>

View File

@ -1,50 +1,50 @@
<?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.
====================================================================
-->
<xb:config xmlns:xb="http://xml.apache.org/xmlbeans/2004/02/xbean/config">
<xb:namespace uri="urn:schemas-microsoft-com:office:office">
<xb:package>com.microsoft.schemas.office.office</xb:package>
</xb:namespace>
<xb:namespace uri="urn:schemas-microsoft-com:office:excel">
<xb:package>com.microsoft.schemas.office.excel</xb:package>
</xb:namespace>
<xb:namespace uri="urn:schemas-microsoft-com:office:word">
<xb:package>com.microsoft.schemas.office.word</xb:package>
</xb:namespace>
<xb:namespace uri="urn:schemas-microsoft-com:office:powerpoint">
<xb:package>com.microsoft.schemas.office.powerpoint</xb:package>
</xb:namespace>
<xb:namespace uri="urn:schemas-microsoft-com:vml">
<xb:package>com.microsoft.schemas.vml</xb:package>
</xb:namespace>
<xb:namespace uri="http://schemas.openxmlformats.org/markup-compatibility/2006">
<xb:package>com.microsoft.schemas.compatibility</xb:package>
</xb:namespace>
<xb:namespace uri="urn:schemas-poi-apache-org:vmldrawing">
<xb:package>org.apache.poi.schemas.vmldrawing</xb:package>
</xb:namespace>
<?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.
====================================================================
-->
<xb:config xmlns:xb="http://xml.apache.org/xmlbeans/2004/02/xbean/config">
<xb:namespace uri="urn:schemas-microsoft-com:office:office">
<xb:package>com.microsoft.schemas.office.office</xb:package>
</xb:namespace>
<xb:namespace uri="urn:schemas-microsoft-com:office:excel">
<xb:package>com.microsoft.schemas.office.excel</xb:package>
</xb:namespace>
<xb:namespace uri="urn:schemas-microsoft-com:office:word">
<xb:package>com.microsoft.schemas.office.word</xb:package>
</xb:namespace>
<xb:namespace uri="urn:schemas-microsoft-com:office:powerpoint">
<xb:package>com.microsoft.schemas.office.powerpoint</xb:package>
</xb:namespace>
<xb:namespace uri="urn:schemas-microsoft-com:vml">
<xb:package>com.microsoft.schemas.vml</xb:package>
</xb:namespace>
<xb:namespace uri="http://schemas.openxmlformats.org/markup-compatibility/2006">
<xb:package>com.microsoft.schemas.compatibility</xb:package>
</xb:namespace>
<xb:namespace uri="urn:schemas-poi-apache-org:vmldrawing">
<xb:package>org.apache.poi.schemas.vmldrawing</xb:package>
</xb:namespace>
</xb:config>

View File

@ -22,8 +22,8 @@ sourceSets {
}
dependencies {
api 'net.bytebuddy:byte-buddy:1.18.2'
api 'net.bytebuddy:byte-buddy-agent:1.18.2'
api 'net.bytebuddy:byte-buddy:1.18.5'
api 'net.bytebuddy:byte-buddy-agent:1.18.5'
api "org.apache.xmlbeans:xmlbeans:${xmlbeansVersion}"
}
@ -56,7 +56,7 @@ tasks.register('compileJava9', JavaCompile) {
}
jar {
destinationDirectory = file("../build/dist/maven/${project.archivesBaseName}")
destinationDirectory = file("../build/dist/maven/${base.archivesName.get()}")
manifest {
attributes (

View File

@ -107,7 +107,7 @@ task compileJava9(type: JavaCompile, dependsOn: 'compileJava') {
}
jar {
destinationDirectory = file("../build/dist/maven/${project.archivesBaseName}")
destinationDirectory = file("../build/dist/maven/${base.archivesName.get()}")
doFirst {
File clazzFile = file("${OOXML_LITE_REPORT}.clazz")

View File

@ -62,7 +62,7 @@ dependencies {
// and uncomment the line below to use a pre-built version of poi-ooxml-full.
// Try to use the last release version of poi-ooxml-full. You might be unlucky if
// recent unreleased changes in poi-ooxml-full are needed.
// api "org.apache.poi:poi-ooxml-full:5.5.0"
// api "org.apache.poi:poi-ooxml-full:5.5.1"
api "org.apache.xmlbeans:xmlbeans:${xmlbeansVersion}"
api "org.apache.commons:commons-compress:${commonsCompressVersion}"
@ -187,7 +187,7 @@ tasks.register('compileTest9', JavaCompile) {
jar {
destinationDirectory = file("../build/dist/maven/${project.archivesBaseName}")
destinationDirectory = file("../build/dist/maven/${base.archivesName.get()}")
manifest {
attributes('Automatic-Module-Name': MODULE_NAME, 'Multi-Release': 'true')
@ -197,7 +197,7 @@ jar {
// 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) {
destinationDirectory = file("../build/dist/maven/${project.archivesBaseName}-tests")
destinationDirectory = file("../build/dist/maven/${base.archivesName.get()}-tests")
setArchiveClassifier 'tests'
// ignore second module-info.class from main

View File

@ -1,44 +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.
==================================================================== */
package org.apache.poi.ooxml;
import org.apache.poi.openxml4j.opc.PackageRelationshipTypes;
import java.net.URI;
/**
* Represents a hyperlink relationship.
*
* @since 5.3.0
*/
public class HyperlinkRelationship extends ReferenceRelationship {
/**
* Initializes a new instance of the HyperlinkRelationship.
*
* @param hyperlinkUri The target uri of the hyperlink relationship.
* @param isExternal Is the URI external.
* @param id The relationship ID.
*/
protected HyperlinkRelationship(POIXMLDocumentPart container, URI hyperlinkUri, boolean isExternal, String id) {
super(container, hyperlinkUri, isExternal, PackageRelationshipTypes.HYPERLINK_PART, id);
}
@Override
public String getRelationshipType() {
return PackageRelationshipTypes.HYPERLINK_PART;
}
}
/* ====================================================================
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.ooxml;
import org.apache.poi.openxml4j.opc.PackageRelationshipTypes;
import java.net.URI;
/**
* Represents a hyperlink relationship.
*
* @since 5.3.0
*/
public class HyperlinkRelationship extends ReferenceRelationship {
/**
* Initializes a new instance of the HyperlinkRelationship.
*
* @param hyperlinkUri The target uri of the hyperlink relationship.
* @param isExternal Is the URI external.
* @param id The relationship ID.
*/
protected HyperlinkRelationship(POIXMLDocumentPart container, URI hyperlinkUri, boolean isExternal, String id) {
super(container, hyperlinkUri, isExternal, PackageRelationshipTypes.HYPERLINK_PART, id);
}
@Override
public String getRelationshipType() {
return PackageRelationshipTypes.HYPERLINK_PART;
}
}

View File

@ -45,6 +45,7 @@ import org.apache.poi.xssf.usermodel.XSSFRelation;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.apache.poi.xwpf.usermodel.XWPFDocument;
import org.apache.poi.xwpf.usermodel.XWPFRelation;
import org.apache.xmlbeans.XmlException;
/**
* Represents an entry of a OOXML package.
@ -258,7 +259,7 @@ public class POIXMLDocumentPart {
*/
public final POIXMLDocumentPart getRelationById(String id) {
RelationPart rp = getRelationPartById(id);
return (rp == null) ? null : rp.getDocumentPart();
return rp == null ? null : rp.getDocumentPart();
}
/**
@ -668,8 +669,22 @@ public class POIXMLDocumentPart {
POIXMLDocumentPart childPart = context.get(p);
if (childPart == null) {
childPart = factory.createDocumentPart(this, p);
//here we are checking if part if embedded and excel then set it to chart class
try {
childPart = factory.createDocumentPart(this, p);
} catch (POIXMLException e) {
if (e.getCause() instanceof XmlException
&& XSSFRelation.CHART.getRelation().equals(rel.getRelationshipType())) {
// https://github.com/apache/poi/pull/982
// only allow this skipping event for charts
// we need to be careful about not catching every exception here because
// issues like zip bomb exceptions need to thrown and not ignored
LOG.atWarn().log("Skipped unsupported part: {}", e.getMessage());
continue;
} else {
throw e;
}
}
//here we are checking if part is embedded and excel then set it to chart class
//so that at the time to writing we can also write updated embedded part
if (this instanceof XDDFChart && childPart instanceof XSSFWorkbook) {
((XDDFChart) this).setWorkbook((XSSFWorkbook) childPart);
@ -782,7 +797,7 @@ public class POIXMLDocumentPart {
* @since 5.3.0
*/
public final HyperlinkRelationship createHyperlink(URI uri, boolean isExternal, String relId) {
PackageRelationship pr = packagePart.addRelationship(uri, isExternal ? TargetMode.EXTERNAL : TargetMode.INTERNAL,
packagePart.addRelationship(uri, isExternal ? TargetMode.EXTERNAL : TargetMode.INTERNAL,
PackageRelationshipTypes.HYPERLINK_PART, relId);
HyperlinkRelationship hyperlink = new HyperlinkRelationship(this, uri, isExternal, relId);
referenceRelationships.put(relId, hyperlink);

View File

@ -1,79 +1,79 @@
/* ====================================================================
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.ooxml;
import org.apache.poi.openxml4j.opc.PackageRelationship;
import org.apache.poi.openxml4j.opc.TargetMode;
import java.net.URI;
/**
* Defines a reference relationship. A reference relationship can be internal or external.
*
* @since 5.3.0
*/
public abstract class ReferenceRelationship {
private POIXMLDocumentPart container;
private final String relationshipType;
private final boolean external;
private final String id;
private final URI uri;
protected ReferenceRelationship(POIXMLDocumentPart container, PackageRelationship packageRelationship) {
if (packageRelationship == null) {
throw new IllegalArgumentException("packageRelationship");
}
this.container = container;
this.relationshipType = packageRelationship.getRelationshipType();
this.uri = packageRelationship.getTargetURI();
this.external = packageRelationship.getTargetMode() == TargetMode.EXTERNAL;
this.id = packageRelationship.getId();
}
protected ReferenceRelationship(POIXMLDocumentPart container, URI targetUri, boolean isExternal, String relationshipType, String id) {
if (targetUri == null) {
throw new NullPointerException("targetUri cannot be null");
}
this.container = container;
this.relationshipType = relationshipType;
this.uri = targetUri;
this.id = id;
this.external = isExternal;
}
public POIXMLDocumentPart getContainer() {
return container;
}
public String getRelationshipType() {
return relationshipType;
}
public boolean isExternal() {
return external;
}
public String getId() {
return id;
}
public URI getUri() {
return uri;
}
}
/* ====================================================================
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.ooxml;
import org.apache.poi.openxml4j.opc.PackageRelationship;
import org.apache.poi.openxml4j.opc.TargetMode;
import java.net.URI;
/**
* Defines a reference relationship. A reference relationship can be internal or external.
*
* @since 5.3.0
*/
public abstract class ReferenceRelationship {
private POIXMLDocumentPart container;
private final String relationshipType;
private final boolean external;
private final String id;
private final URI uri;
protected ReferenceRelationship(POIXMLDocumentPart container, PackageRelationship packageRelationship) {
if (packageRelationship == null) {
throw new IllegalArgumentException("packageRelationship");
}
this.container = container;
this.relationshipType = packageRelationship.getRelationshipType();
this.uri = packageRelationship.getTargetURI();
this.external = packageRelationship.getTargetMode() == TargetMode.EXTERNAL;
this.id = packageRelationship.getId();
}
protected ReferenceRelationship(POIXMLDocumentPart container, URI targetUri, boolean isExternal, String relationshipType, String id) {
if (targetUri == null) {
throw new NullPointerException("targetUri cannot be null");
}
this.container = container;
this.relationshipType = relationshipType;
this.uri = targetUri;
this.id = id;
this.external = isExternal;
}
public POIXMLDocumentPart getContainer() {
return container;
}
public String getRelationshipType() {
return relationshipType;
}
public boolean isExternal() {
return external;
}
public String getId() {
return id;
}
public URI getUri() {
return uri;
}
}

View File

@ -1875,7 +1875,10 @@ public abstract class OPCPackage implements RelationshipSource, Closeable {
public abstract boolean isClosed();
protected void closeParts() {
partList.closeParts();
// might not be initialized fully yet
if (partList != null) {
partList.closeParts();
}
}
@Override

View File

@ -47,6 +47,10 @@ public class RelLineTo implements GeometryRow {
for (CellType cell : row.getCellArray()) {
String cellName = cell.getN();
if (cellName == null) {
throw new IllegalStateException("Cannot create a ReLineTo object without a cell-name indicating 'X' or 'Y' direction");
}
if (cellName.equals("X")) {
x = XDGFCell.parseDoubleValue(cell);
} else if (cellName.equals("Y")) {

View File

@ -748,4 +748,51 @@ public class XMLSlideShow extends POIXMLDocument
RelationPart rp = target.addRelation(null, XSLFRelation.IMAGES, pictureData);
return rp.getRelationship().getId();
}
/**
* Returns the number that shall be displayed on the first slide of the presentation.
* Subsequent slides will be numbered sequentially from this number.
* The default value is 1 if the property is not set in the presentation file.
*
* @return The starting number for the first slide (default is 1).
* @since 6.0.0
*/
public int getFirstSlideNumber() {
// CTPresentation.getFirstSlideNum() returns the default value of 1
// if the 'firstSlideNum' attribute is not set, as per OOXML standard.
return getCTPresentation().getFirstSlideNum();
}
/**
* Sets the custom number that shall be displayed on the first slide of the presentation.
* Subsequent slides will be numbered sequentially from this number.
*
* The value is restricted to the range [0, 9999] as defined in the Microsoft Office
* Implementation Information for ISO/IEC 29500 (MS-OI29500), specifically in
* Part 1, Section 19.2.1.26, presentation (Presentation), which restricts the
* XML Schema int datatype.
*
* @param num The starting number for the first slide (must be between 0 and 9999).
* @throws IllegalArgumentException if the provided number is outside the allowed range [0, 9999].
* @since 6.0.0
*/
public void setFirstSlideNumber(int num) {
// We enforce the PowerPoint application constraint (0 <= num <= 9999)
// to ensure that a valid file, as rendered by PowerPoint, is created.
if (num < 0 || num > 9999) {
throw new IllegalArgumentException(
"First slide number must be between 0 and 9999 (inclusive), as required by MS-OI29500 (Part 1, Section 19.2.1.26).");
}
// Sets the attribute on the underlying CTPresentation object.
getCTPresentation().setFirstSlideNum(num);
}
/**
* Unsets the custom first slide number, reverting the numbering to the default (1).
* This removes the 'firstSlideNum' attribute from presentation.xml.
* @since 6.0.0
*/
public void unsetFirstSlideNumber() {
getCTPresentation().unsetFirstSlideNum();
}
}

View File

@ -44,7 +44,7 @@ public class XSLFAutoShape extends XSLFTextShape implements AutoShape<XSLFShape,
static XSLFAutoShape create(CTShape shape, XSLFSheet sheet) {
if (shape.getSpPr().isSetCustGeom()) {
return new XSLFFreeformShape(shape, sheet);
} else if (shape.getNvSpPr().getCNvSpPr().isSetTxBox()) {
} else if (shape.getNvSpPr().getCNvSpPr() != null && shape.getNvSpPr().getCNvSpPr().isSetTxBox()) {
return new XSLFTextBox(shape, sheet);
} else {
return new XSLFAutoShape(shape, sheet);

View File

@ -181,6 +181,10 @@ public class XSLFDiagram extends XSLFGraphicFrame {
textShapeCT.setNvSpPr((CTShapeNonVisual) nonVisualCt.copy());
textShapeCT.getNvSpPr().getCNvSpPr().setTxBox(true);
if (msShapeCt.getSpPr() == null || msShapeCt.getSpPr().getXfrm() == null || msShapeCt.getTxXfrm() == null) {
throw new IllegalStateException("Invalid content in diagram, cannot extract text");
}
textShapeProps.setXfrm(msShapeCt.getTxXfrm());
int shapeRotation = msShapeCt.getSpPr().getXfrm().getRot();
int textRotation = msShapeCt.getTxXfrm().getRot();

View File

@ -189,7 +189,7 @@ public class XSLFPictureShape extends XSLFSimpleShape
}
protected CTBlip getBlip(){
return getBlipFill().getBlip();
return getBlipFill() == null ? null : getBlipFill().getBlip();
}
@SuppressWarnings("WeakerAccess")
@ -216,7 +216,7 @@ public class XSLFPictureShape extends XSLFSimpleShape
@Override
public Insets getClipping(){
CTRelativeRect r = getBlipFill().getSrcRect();
CTRelativeRect r = getBlipFill() == null ? null : getBlipFill().getSrcRect();
return (r == null) ? null : new Insets(
POIXMLUnits.parsePercent(r.xgetT()),
@ -225,6 +225,14 @@ public class XSLFPictureShape extends XSLFSimpleShape
POIXMLUnits.parsePercent(r.xgetR()));
}
public int getAlpha() {
CTBlip blip = getBlip();
if (blip == null) {
return FULLY_OPAQUE_ALPHA_VALUE;
}
return blip.sizeOfAlphaModFixArray() > 0 ? POIXMLUnits.parsePercent(blip.getAlphaModFixArray(0).xgetAmt()) : FULLY_OPAQUE_ALPHA_VALUE;
}
/**
* Add a SVG image reference
* @param svgPic a previously imported svg image

View File

@ -535,7 +535,7 @@ public abstract class XSLFSimpleShape extends XSLFShape
@Override
public boolean fetch(XSLFShape shape) {
CTLineProperties ln = getLn(shape, false);
if (ln == null || !ln.isSetPrstDash()) {
if (ln == null || !ln.isSetPrstDash() || ln.getPrstDash().getVal() == null) {
return false;
}
@ -548,7 +548,7 @@ public abstract class XSLFSimpleShape extends XSLFShape
LineDash dash = fetcher.getValue();
if (dash == null) {
CTLineProperties defaultLn = getDefaultLineProperties();
if (defaultLn != null && defaultLn.isSetPrstDash()) {
if (defaultLn != null && defaultLn.isSetPrstDash() && defaultLn.getPrstDash().getVal() != null) {
dash = LineDash.fromOoxmlId(defaultLn.getPrstDash().getVal().intValue());
}
}

View File

@ -340,6 +340,9 @@ public class XSLFTable extends XSLFGraphicFrame implements Iterable<XSLFTableRow
String styleId = tab.getTblPr().getTableStyleId();
XSLFTableStyles styles = getSheet().getSlideShow().getTableStyles();
if (styles == null) {
return null;
}
for (XSLFTableStyle style : styles.getStyles()) {
if (style.getStyleId().equals(styleId)) {
return style;

View File

@ -438,7 +438,8 @@ public class XSLFTableCell extends XSLFTextShape implements TableCell<XSLFShape,
}
CTTablePartStyle tps = getTablePartStyle(null);
if (tps == null || !tps.isSetTcStyle()) {
if (tps == null || !tps.isSetTcStyle() ||
(!tps.getTcStyle().isSetFill() && !tps.getTcStyle().isSetFillRef())) {
tps = getTablePartStyle(TablePartStyle.wholeTbl);
if (tps == null || !tps.isSetTcStyle()) {
return null;
@ -504,10 +505,18 @@ public class XSLFTableCell extends XSLFTextShape implements TableCell<XSLFShape,
int br = row + (firstRow ? 1 : 0);
int bc = col + (firstCol ? 1 : 0);
if (bandRow && (br & 1) == 0) {
tps = TablePartStyle.band1H;
} else if (bandCol && (bc & 1) == 0) {
tps = TablePartStyle.band1V;
if (bandRow) {
if ((br & 1) == 0) {
tps = TablePartStyle.band1H;
} else {
tps = TablePartStyle.band2H;
}
} else if (bandCol) {
if ((bc & 1) == 0) {
tps = TablePartStyle.band1V;
} else {
tps = TablePartStyle.band2V;
}
}
}
@ -734,6 +743,9 @@ public class XSLFTableCell extends XSLFTextShape implements TableCell<XSLFShape,
@Override
public PaintStyle getFontColor() {
CTTableStyleTextStyle txStyle = getTextStyle();
if (!containsColor(txStyle)) {
txStyle = getFallbackTextStyle();
}
if (txStyle == null) {
// No table styling, so just use the text run output
return super.getFontColor();
@ -798,11 +810,27 @@ public class XSLFTableCell extends XSLFTextShape implements TableCell<XSLFShape,
}
}
private boolean containsColor(CTTableStyleTextStyle tcTxStyle) {
if (tcTxStyle == null) {
return false;
}
if (!tcTxStyle.isSetHslClr() && !tcTxStyle.isSetPrstClr() && !tcTxStyle.isSetSchemeClr()
&& !tcTxStyle.isSetScrgbClr() && !tcTxStyle.isSetSrgbClr() && !tcTxStyle.isSetSysClr()) {
return false;
}
return true;
}
private CTTableStyleTextStyle getTextStyle() {
CTTablePartStyle tps = getTablePartStyle(null);
if (tps == null || !tps.isSetTcTxStyle()) {
tps = getTablePartStyle(TablePartStyle.wholeTbl);
return getFallbackTextStyle();
}
return tps.getTcTxStyle();
}
private CTTableStyleTextStyle getFallbackTextStyle() {
CTTablePartStyle tps = getTablePartStyle(TablePartStyle.wholeTbl);
return (tps == null) ? null : tps.getTcTxStyle();
}
}

View File

@ -58,7 +58,6 @@ import org.openxmlformats.schemas.drawingml.x2006.main.CTTextLineBreak;
import org.openxmlformats.schemas.drawingml.x2006.main.CTTextNormalAutofit;
import org.openxmlformats.schemas.drawingml.x2006.main.STTextStrikeType;
import org.openxmlformats.schemas.drawingml.x2006.main.STTextUnderlineType;
import org.openxmlformats.schemas.drawingml.x2006.main.impl.CTSRgbColorImpl;
/**
* Represents a run of text within the containing text body. The run element is the
@ -191,6 +190,10 @@ public class XSLFTextRun implements TextRun, HighlightColorSupport {
}
final CTSRgbColor rgbCol = col.getSrgbClr();
if (rgbCol == null) {
return;
}
final byte[] cols = rgbCol.getVal();
final SolidPaint paint = DrawPaint.createSolidPaint(new Color(0xFF & cols[0], 0xFF & cols[1], 0xFF & cols[2]));
highlightColor.accept(paint);
@ -811,6 +814,9 @@ public class XSLFTextRun implements TextRun, HighlightColorSupport {
if (typeface.startsWith("+mj-") || typeface.startsWith("+mn-")) {
// "+mj-lt".equals(typeface) || "+mn-lt".equals(typeface)
final XSLFTheme theme = _p.getParentShape().getSheet().getTheme();
if (theme == null) {
return null;
}
CTFontScheme fontTheme = theme.getXmlObject().getThemeElements().getFontScheme();
CTFontCollection coll = typeface.startsWith("+mj-")
? fontTheme.getMajorFont() : fontTheme.getMinorFont();

View File

@ -88,7 +88,7 @@ public class XSSFBSheetHandler extends XSSFBParser {
/**
* Creates a handler that converts numeric and date cells to formatted strings via {@link
* DataFormatter}.
*
*
* <p>Select this overload when the consumer expects formatted string values rather than raw
* cell representations.
*
@ -224,6 +224,10 @@ public class XSSFBSheetHandler extends XSSFBParser {
}
private ExcelNumberFormat getExcelNumberFormat() {
if (styles == null) {
throw new IllegalStateException("Cannot read information because styles-table is not available");
}
int styleIdx = cellBuffer.getStyleIdx();
String formatString = styles.getNumberFormatString(styleIdx);
short styleIndex = styles.getNumberFormatIndex(styleIdx);
@ -399,7 +403,7 @@ public class XSSFBSheetHandler extends XSSFBParser {
rkBuffer[4] = b0;
System.arraycopy(data, offset + 1, rkBuffer, 5, 3);
double d = 0.0;
double d;
if (floatingPoint) {
d = LittleEndian.getDouble(rkBuffer);
} else {

View File

@ -436,8 +436,16 @@ public class XSSFReader {
sheetPkg.getRelationshipsByType(XSSFRelation.SHEET_COMMENTS.getRelation());
if (!commentsList.isEmpty()) {
PackageRelationship comments = commentsList.getRelationship(0);
if (comments == null) {
LOGGER.warn("Failed to find sheet comments packageRelationship");
return null;
}
PackagePartName commentsName = PackagingURIHelper.createPartName(comments.getTargetURI());
PackagePart commentsPart = sheetPkg.getPackage().getPart(commentsName);
if (commentsPart == null) {
LOGGER.warn("Failed to find sheet comments: {}", commentsName);
return null;
}
return parseComments(commentsPart);
}
} catch (InvalidFormatException|IOException e) {

View File

@ -156,7 +156,7 @@ public class XSSFExportToXml implements Comparator<String>{
indexMap.clear();
xpaths.sort(this);
indexMap.clear();
for(String xpath : xpaths) {
XSSFSingleXmlCell simpleXmlCell = singleXmlCellsMappings.get(xpath);
@ -170,7 +170,7 @@ public class XSSFExportToXml implements Comparator<String>{
if (cell!=null) {
Node currentNode = getNodeByXPath(xpath,doc.getFirstChild(),doc,false);
mapCellOnNode(cell,currentNode);
//remove nodes which are empty in order to keep the output xml valid
// FIXME: what should be done if currentNode.getTextContent() is null?
if ("".equals(currentNode.getTextContent()) && currentNode.getParentNode() != null) {
@ -192,6 +192,11 @@ public class XSSFExportToXml implements Comparator<String>{
for(int i = startRow; i<= endRow; i++) {
XSSFRow row = sheet.getRow(i);
// some external created files can miss rows
if (row == null) {
continue;
}
Node tableRootNode = getNodeByXPath(table.getCommonXpath(), doc.getFirstChild(), doc, true);
short startColumnIndex = table.getStartCellReference().getCol();
@ -255,7 +260,7 @@ public class XSSFExportToXml implements Comparator<String>{
Schema schema = factory.newSchema(source);
Validator validator = schema.newValidator();
validator.validate(new DOMSource(xml));
//if no exceptions where raised, the document is valid
return true;
} catch(IOException e) {
@ -289,8 +294,8 @@ public class XSSFExportToXml implements Comparator<String>{
}
}
break;
case NUMERIC:
case NUMERIC:
if (DateUtil.isCellDateFormatted(cell)) {
value = getFormattedDate(cell);
} else {
@ -459,7 +464,7 @@ public class XSSFExportToXml implements Comparator<String>{
}
return Integer.compare(leftIndexOf, rightIndexOf);
}
private int getAndStoreIndex(String samePath,String withoutNamespace) {
String withPath = samePath+"/"+withoutNamespace;
return indexMap.getOrDefault(withPath, -1);
@ -470,7 +475,7 @@ public class XSSFExportToXml implements Comparator<String>{
if(returnNode != null) {
return returnNode;
}
return node.getAttributes().getNamedItem("name");
}

View File

@ -219,6 +219,7 @@ public final class XSSFCell extends CellBase {
*/
@Override
public void setCellValue(boolean value) {
removeInlineString();
_cell.setT(STCellType.B);
_cell.setV(value ? TRUE_AS_STRING : FALSE_AS_STRING);
}
@ -263,6 +264,7 @@ public final class XSSFCell extends CellBase {
@Override
public void setCellValueImpl(double value) {
removeInlineString();
_cell.setT(STCellType.N);
_cell.setV(String.valueOf(value));
}
@ -356,27 +358,23 @@ public final class XSSFCell extends CellBase {
@Override
protected void setCellValueImpl(RichTextString str) {
removeInlineString();
CellType cellType = getCellType();
if (cellType == CellType.FORMULA) {
_cell.setV(str.getString());
_cell.setT(STCellType.STR);
} else if (str instanceof XSSFRichTextString) {
_cell.setT(STCellType.S);
XSSFRichTextString rt = (XSSFRichTextString)str;
rt.setStylesTableReference(_stylesSource);
int sRef = _sharedStringSource.addSharedStringItem(rt);
_cell.setV(Integer.toString(sRef));
} else {
if(_cell.getT() == STCellType.INLINE_STR) {
//set the 'pre-evaluated result
_cell.setV(str.getString());
} else if (str instanceof XSSFRichTextString) {
_cell.setT(STCellType.S);
XSSFRichTextString rt = (XSSFRichTextString)str;
rt.setStylesTableReference(_stylesSource);
int sRef = _sharedStringSource.addSharedStringItem(rt);
_cell.setV(Integer.toString(sRef));
} else {
_cell.setT(STCellType.S);
XSSFRichTextString rt = new XSSFRichTextString(str.getString());
rt.setStylesTableReference(_stylesSource);
int sRef = _sharedStringSource.addSharedStringItem(rt);
_cell.setV(Integer.toString(sRef));
}
_cell.setT(STCellType.S);
XSSFRichTextString rt = new XSSFRichTextString(str.getString());
rt.setStylesTableReference(_stylesSource);
int sRef = _sharedStringSource.addSharedStringItem(rt);
_cell.setV(Integer.toString(sRef));
}
}
@ -410,7 +408,9 @@ public final class XSSFCell extends CellBase {
/* In an excel generated array formula, the formula property might be set, but the string is empty in related cells */
if (f == null || f.getStringValue().isEmpty()) {
XSSFCell cell = getSheet().getFirstCellInArrayFormula(this);
return cell.getCellFormula(fpb);
if (!equals(cell)) {
return cell.getCellFormula(fpb);
}
}
}
if (f == null) {
@ -519,6 +519,12 @@ public final class XSSFCell extends CellBase {
}
}
private void removeInlineString() {
if (_cell.isSetIs()) {
_cell.unsetIs();
}
}
/**
* Returns column index of this cell
*

View File

@ -263,10 +263,15 @@ public final class XSSFPicture extends XSSFShape implements Picture {
/**
* Return picture data for this shape
*
* @return picture data for this shape
* @return picture data for this shape or null if
* the data cannot be retrieved
*/
@Override
public XSSFPictureData getPictureData() {
if (ctPicture.getBlipFill().getBlip() == null) {
return null;
}
String blipId = ctPicture.getBlipFill().getBlip().getEmbed();
return (XSSFPictureData)getDrawing().getRelationById(blipId);
}

View File

@ -211,7 +211,9 @@ public class XSSFTable extends POIXMLDocumentPart implements Table {
List<XSSFTableColumn> columns = new ArrayList<>();
CTTableColumns ctTableColumns = ctTable.getTableColumns();
if (ctTableColumns != null) {
for (CTTableColumn column : ctTableColumns.getTableColumnList()) {
// Use Array and not List-based access, as list-iteration is
// very slow for large tables
for (CTTableColumn column : ctTableColumns.getTableColumnArray()) {
XSSFTableColumn tableColumn = new XSSFTableColumn(this, column);
columns.add(tableColumn);
}
@ -308,11 +310,12 @@ public class XSSFTable extends POIXMLDocumentPart implements Table {
tableStart.getCol() + newColumnCount - 1);
AreaReference newTableArea = new AreaReference(tableStart, newTableEnd, version);
// setCellRef also calls updateHeaders()
setCellRef(newTableArea);
} else {
updateHeaders();
}
updateHeaders();
return getColumns().get(columnIndex);
}
@ -353,7 +356,9 @@ public class XSSFTable extends POIXMLDocumentPart implements Table {
CTTableColumns tableColumns = ctTable.getTableColumns();
tableColumns.removeTableColumn(columnIndex);
tableColumns.setCount(tableColumns.getTableColumnList().size());
// Use Array and not List-based access, as list-iteration is
// very slow for large tables
tableColumns.setCount(tableColumns.getTableColumnArray().length);
updateReferences();
updateHeaders();
}
@ -406,7 +411,7 @@ public class XSSFTable extends POIXMLDocumentPart implements Table {
try {
ctTable.getTableStyleInfo().unsetName();
} catch (Exception e) {
LOG.atDebug().log("Failed to unset style name", e);
LOG.atDebug().log("Failed to unset style name: {}", e);
}
}
styleName = null;
@ -821,13 +826,19 @@ public class XSSFTable extends POIXMLDocumentPart implements Table {
int cellnum = firstHeaderColumn;
CTTableColumns ctTableColumns = getCTTable().getTableColumns();
if(ctTableColumns != null) {
for (CTTableColumn col : ctTableColumns.getTableColumnList()) {
// Use Array and not List-based access, as list-iteration is
// very slow for large tables
for (CTTableColumn col : ctTableColumns.getTableColumnArray()) {
XSSFCell cell = row.getCell(cellnum);
if (cell != null) {
String colName = formatter.formatCellValue(cell);
colName = colName.replace("\n", "_x000a_");
colName = colName.replace("\r", "_x000d_");
col.setName(colName);
// setName() is costly, let's only run it when necessary
if (!colName.equals(col.getName())) {
col.setName(colName);
}
}
cellnum++;
}

View File

@ -256,15 +256,24 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook, Date1904Su
*/
public XSSFWorkbook(OPCPackage pkg) throws IOException {
super(pkg);
this.xssfFactory = XSSFFactory.getInstance();
beforeDocumentRead();
try {
this.xssfFactory = XSSFFactory.getInstance();
// Build a tree of POIXMLDocumentParts, this workbook being the root
load(this.xssfFactory);
beforeDocumentRead();
// some broken Workbooks miss this...
setBookViewsIfMissing();
// Build a tree of POIXMLDocumentParts, this workbook being the root
load(this.xssfFactory);
// some broken Workbooks miss this...
setBookViewsIfMissing();
} catch (IOException | RuntimeException e) {
// close the package on exception to avoid file handle leaks
pkg.revert();
// rethrow exception
throw e;
}
}
/**
@ -1218,6 +1227,10 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook, Date1904Su
*/
@Override
public XSSFSheet getSheet(String name) {
if (name == null) {
throw new IllegalArgumentException("Encountered an empty name when looking up sheets by name");
}
for (XSSFSheet sheet : sheets) {
if (name.equalsIgnoreCase(sheet.getSheetName())) {
return sheet;

View File

@ -38,7 +38,7 @@ import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTWorksheet;
*/
public class ColumnHelper {
private CTWorksheet worksheet;
private final CTWorksheet worksheet;
public ColumnHelper(CTWorksheet worksheet) {
super();
@ -264,9 +264,10 @@ public class ColumnHelper {
CTCol col = getOrCreateColumn1Based(index+1, false);
col.setBestFit(bestFit);
}
public void setCustomWidth(long index, boolean bestFit) {
public void setCustomWidth(long index, boolean useCustomWidth) {
CTCol col = getOrCreateColumn1Based(index+1, true);
col.setCustomWidth(bestFit);
col.setCustomWidth(useCustomWidth);
}
public void setColWidth(long index, double width) {
@ -302,10 +303,15 @@ public class ColumnHelper {
col.setStyle(styleId);
}
// Returns -1 if no column is found for the given index
/**
* Get the default style index for the given column index
*
* @return The style-index or -1 if no column is found for the given index
*/
public int getColDefaultStyle(long index) {
if (getColumn(index, false) != null) {
return (int) getColumn(index, false).getStyle();
final CTCol column = getColumn(index, false);
if (column != null) {
return (int) column.getStyle();
}
return -1;
}
@ -330,4 +336,4 @@ public class ColumnHelper {
}
return -1;
}
}
}

View File

@ -123,6 +123,11 @@ public class XWPFEndnotes extends XWPFAbstractFootnotesEndnotes {
@Override
protected void commit() throws IOException {
// cannot save anything if class is not initialized fully
if (ctEndnotes == null) {
return;
}
XmlOptions xmlOptions = new XmlOptions(DEFAULT_XML_OPTIONS);
xmlOptions.setSaveSyntheticDocumentElement(new QName(CTEndnotes.type.getName().getNamespaceURI(), "endnotes"));
PackagePart part = getPackagePart();

View File

@ -17,6 +17,7 @@
package org.apache.poi.xwpf.usermodel;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.apache.poi.util.Beta;
@ -107,6 +108,15 @@ public class XWPFSDTContent implements ISDTContent {
}
}
/**
* Get the body elements inside this SDT content element.
* @return Unmodifiable list containing body elements.
* @since 6.0.0
*/
public List<ISDTContents> getBodyElements() {
return Collections.unmodifiableList(bodyElements);
}
@Override
public String getText() {
StringBuilder text = new StringBuilder();

View File

@ -27,7 +27,9 @@ import org.apache.xmlbeans.XmlOptions;
import org.openxmlformats.schemas.drawingml.x2006.main.CTBaseStyles;
import org.openxmlformats.schemas.drawingml.x2006.main.CTColor;
import org.openxmlformats.schemas.drawingml.x2006.main.CTColorScheme;
import org.openxmlformats.schemas.drawingml.x2006.main.CTFontCollection;
import org.openxmlformats.schemas.drawingml.x2006.main.CTOfficeStyleSheet;
import org.openxmlformats.schemas.drawingml.x2006.main.CTSupplementalFont;
import org.openxmlformats.schemas.drawingml.x2006.main.ThemeDocument;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.*;
@ -67,11 +69,19 @@ public class XWPFTheme extends POIXMLDocumentPart {
_theme = theme.getXmlObject();
}
/**
* @return the underlying CTOfficeStyleSheet instance.
* @since 6.0.0
*/
public CTOfficeStyleSheet getCTOfficeStyleSheet() {
return _theme;
}
/**
*
* @return name of this theme, e.g. "Office Theme"
*/
public String getName(){
public String getName() {
return _theme.getName();
}
@ -80,7 +90,7 @@ public class XWPFTheme extends POIXMLDocumentPart {
*
* @param name name of this theme
*/
public void setName(String name){
public void setName(String name) {
_theme.setName(name);
}
@ -132,23 +142,79 @@ public class XWPFTheme extends POIXMLDocumentPart {
}
/**
* @return typeface of the major font to use in a document.
* @return typeface of the major font to use in a document (possibly <code>null</code>).
* Typically, the major font is used for heading areas of a document.
*
*/
@SuppressWarnings("WeakerAccess")
public String getMajorFont(){
return _theme.getThemeElements().getFontScheme().getMajorFont().getLatin().getTypeface();
public String getMajorFont() {
CTFontCollection majorFonts = getMajorFonts();
return majorFonts == null || majorFonts.getLatin() == null ?
null : majorFonts.getLatin().getTypeface();
}
/**
* @return typeface of the minor font to use in a document.
* @return typeface of the minor font to use in a document (possibly <code>null</code>).
* Typically, the minor font is used for normal text or paragraph areas.
*
*/
@SuppressWarnings("WeakerAccess")
public String getMinorFont(){
return _theme.getThemeElements().getFontScheme().getMinorFont().getLatin().getTypeface();
public String getMinorFont() {
CTFontCollection minorFonts = getMinorFonts();
return minorFonts == null || minorFonts.getLatin() == null ?
null : minorFonts.getLatin().getTypeface();
}
/**
* @param script a 4-letter script code, e.g. "Latn", "Jpan"
* @return typeface of the major font for the given script (possibly <code>null</code>)
* @since 6.0.0
*/
public String getMajorFontForScript(String script) {
CTFontCollection majorFonts = getMajorFonts();
return majorFonts == null ? null : getFontTypeface(majorFonts, script);
}
/**
* @param script a 4-letter script code, e.g. "Latn", "Jpan"
* @return typeface of the minor font for the given script (possibly <code>null</code>)
* @since 6.0.0
*/
public String getMinorFontForScript(String script) {
CTFontCollection minorFonts = getMinorFonts();
return minorFonts == null ? null : getFontTypeface(minorFonts, script);
}
private CTFontCollection getMajorFonts() {
if (_theme == null
|| _theme.getThemeElements() == null
|| _theme.getThemeElements().getFontScheme() == null
|| _theme.getThemeElements().getFontScheme().getMajorFont() == null) {
return null;
}
return _theme.getThemeElements().getFontScheme().getMajorFont();
}
private CTFontCollection getMinorFonts() {
if (_theme == null
|| _theme.getThemeElements() == null
|| _theme.getThemeElements().getFontScheme() == null
|| _theme.getThemeElements().getFontScheme().getMinorFont() == null) {
return null;
}
return _theme.getThemeElements().getFontScheme().getMinorFont();
}
private static String getFontTypeface(CTFontCollection fontCollection, String script) {
CTSupplementalFont[] fonts = fontCollection.getFontArray();
if (fonts != null) {
for (CTSupplementalFont font : fonts) {
if (font.getScript() != null && font.getScript().equals(script)) {
return font.getTypeface();
}
}
}
return null;
}
/**

File diff suppressed because one or more lines are too long

View File

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<presetTableStyles>
<TableStyleMedium28>
<dxfs count="7">

View File

@ -19,7 +19,7 @@ package org.apache.poi.ooxml;
import static org.apache.poi.hssf.HSSFTestDataSamples.openSampleFileStream;
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import java.io.ByteArrayInputStream;
@ -28,7 +28,6 @@ import java.io.InputStream;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.apache.poi.openxml4j.opc.OPCPackage;
import org.apache.poi.poifs.filesystem.DocumentFactoryHelper;
import org.apache.poi.poifs.filesystem.FileMagic;
import org.apache.poi.util.IOUtils;
import org.junit.jupiter.api.Test;
@ -66,7 +65,7 @@ class TestDetectAsOOXML {
InputStream is = FileMagic.prepareToCheckMagic(testInput);
// detect header
assertFalse(FileMagic.valueOf(is) == FileMagic.OOXML);
assertNotEquals(FileMagic.OOXML, FileMagic.valueOf(is));
// check if InputStream is still intact
byte[] act = IOUtils.toByteArray(is);

View File

@ -19,12 +19,21 @@ package org.apache.poi.openxml4j;
import org.apache.poi.hssf.HSSFTestDataSamples;
import org.apache.poi.ooxml.TrackingInputStream;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.apache.poi.openxml4j.opc.OPCPackage;
import org.apache.poi.openxml4j.opc.PackageAccess;
import org.apache.poi.openxml4j.opc.PackagePart;
import org.apache.poi.openxml4j.opc.PackagePartCollection;
import org.apache.poi.openxml4j.opc.PackagePartName;
import org.apache.poi.openxml4j.opc.ZipPackage;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.IOException;
import java.io.OutputStream;
class TestOPCPackage {
@Test
void testPackageCloseClosesInputStream() throws Exception {
@ -48,4 +57,10 @@ class TestOPCPackage {
}
}
@Test
void testCloseWithEmptyList() throws IOException {
OPCPackage pkg = new ZipPackage();
pkg.close();
}
}

View File

@ -22,8 +22,9 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assumptions.assumeFalse;
import java.awt.Dimension;
import java.awt.*;
import java.awt.geom.Rectangle2D;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.io.InputStream;
@ -117,4 +118,33 @@ class TestDrawPictureShape {
return val;
}
}
@Test
void testAlphaXSLFPictureShape() throws IOException {
SlideShow<?,?> ss = openSampleDocument("picture-transparency.pptx");
// First slide contains a fully opaque bitmap
verifySlideFirstPixelColor(ss.getSlides().get(0), new Color(0, 0, 0, 255));
// Second slide contains a 20% transparency bitmap (255*0.8=204)
verifySlideFirstPixelColor(ss.getSlides().get(1), new Color(0, 0, 0, 204));
// Third slide contains a 60% transparency bitmap (255*0.4=102)
verifySlideFirstPixelColor(ss.getSlides().get(2), new Color(0, 0, 0, 102));
// Fourth slide contains a fully transparent bitmap
verifySlideFirstPixelColor(ss.getSlides().get(3), new Color(0, 0, 0, 0));
}
private void verifySlideFirstPixelColor(Slide<?,?> slide, Color color) {
PictureShape<?,?> picShape = null;
for (Shape<?,?> shape : slide.getShapes()) {
if (shape instanceof PictureShape) {
picShape = (PictureShape<?,?>)shape;
break;
}
}
assertNotNull(picShape);
BufferedImage img = new BufferedImage(100, 100, BufferedImage.TYPE_INT_ARGB);
new DrawPictureShape(picShape).draw(img.createGraphics());
assertEquals(Transparency.TRANSLUCENT, img.getTransparency());
assertEquals(color, new Color(img.getRGB(0, 0), true));
}
}

View File

@ -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.xslf.draw.geom;
import static org.junit.jupiter.api.Assertions.assertThrows;
import java.awt.geom.Path2D;
import org.apache.poi.sl.draw.geom.ArcToCommand;
import org.apache.poi.sl.draw.geom.Context;
import org.apache.poi.sl.draw.geom.CustomGeometry;
import org.junit.jupiter.api.Test;
class TestXSLFArcTo {
@Test
void test() {
ArcToCommand arc = new ArcToCommand();
CustomGeometry geom = new CustomGeometry();
Context ctx = new Context(geom, null, null) {
@Override
public double getValue(String key) {
return 1.0;
}
};
Path2D.Double path = new Path2D.Double();
path.moveTo(1.0, 1.0);
path.lineTo(2.0, 2.0);
arc.execute(path, ctx);
}
@Test
void testPointFails() {
ArcToCommand arc = new ArcToCommand();
CustomGeometry geom = new CustomGeometry();
Context ctx = new Context(geom, null, null) {
@Override
public double getValue(String key) {
return 1.0;
}
};
assertThrows(IllegalStateException.class,
() -> arc.execute(new Path2D.Double(), ctx));
}
}

View File

@ -16,10 +16,6 @@
==================================================================== */
package org.apache.poi.xslf.usermodel;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertSame;
import java.awt.Dimension;
import java.awt.Rectangle;
import java.io.ByteArrayInputStream;
@ -34,6 +30,12 @@ import org.apache.poi.sl.usermodel.Placeholder;
import org.apache.poi.xslf.XSLFTestDataSamples;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertSame;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertThrows;
class TestXSLFSlideShow {
@Test
void testCreateSlide() throws IOException {
@ -327,4 +329,96 @@ class TestXSLFSlideShow {
}
}
}
/**
* Test getting the first slide number, which defaults to 1.
* The first slide number is stored in the presentation.xml part.
*/
@Test
void testGetFirstSlideNumberDefault() throws IOException {
try (XMLSlideShow ppt = new XMLSlideShow()) {
// Default value when attribute is not present should be 1 (as per OOXML standard and CTPresentation logic)
assertEquals(1, ppt.getFirstSlideNumber());
}
}
/**
* Test setting, getting, and persisting the custom first slide number.
*/
@Test
void testSetAndPersistFirstSlideNumber() throws IOException {
final int customStartNum = 5;
final int zeroStartNum = 0;
final int maxStartNum = 9999;
try (XMLSlideShow ppt = new XMLSlideShow()) {
// 1. Set to a custom positive number (e.g., 5)
ppt.setFirstSlideNumber(customStartNum);
assertEquals(customStartNum, ppt.getFirstSlideNumber());
// Check persistence by writing out and reading back
try (XMLSlideShow ppt2 = XSLFTestDataSamples.writeOutAndReadBack(ppt)) {
assertEquals(customStartNum, ppt2.getFirstSlideNumber(),
"The custom first slide number should persist after save/load.");
}
// 2. Set to minimum valid number (0)
ppt.setFirstSlideNumber(zeroStartNum);
assertEquals(zeroStartNum, ppt.getFirstSlideNumber());
// 3. Set to maximum valid number (9999)
ppt.setFirstSlideNumber(maxStartNum);
assertEquals(maxStartNum, ppt.getFirstSlideNumber());
}
}
/**
* Test unsetting the first slide number, which should revert it to the default (1).
*/
@Test
void testUnsetFirstSlideNumber() throws IOException {
try (XMLSlideShow ppt = new XMLSlideShow()) {
// 1. Set a custom number
ppt.setFirstSlideNumber(50);
assertEquals(50, ppt.getFirstSlideNumber());
// 2. Unset it
ppt.unsetFirstSlideNumber();
// It should return the default value (1) after unsetting
assertEquals(1, ppt.getFirstSlideNumber(),
"Unsetting the first slide number should revert it to the default of 1.");
// Check persistence after unsetting
try (XMLSlideShow ppt2 = XSLFTestDataSamples.writeOutAndReadBack(ppt)) {
assertEquals(1, ppt2.getFirstSlideNumber(),
"The first slide number should remain the default (1) after unset and save/load.");
// Ensure the attribute is actually removed from the CTPresentation object
// Note: We access the internal object to confirm removal, which is acceptable in test code.
assertFalse(ppt2.getCTPresentation().isSetFirstSlideNum(),
"The 'firstSlideNum' attribute should be unset (removed) in the XML.");
}
}
}
/**
* Test that setting an invalid first slide number (outside [0, 9999]) throws an exception.
*/
@Test
void testSetFirstSlideNumberValidation() throws IOException {
try (XMLSlideShow ppt = new XMLSlideShow()) {
// Test case: Negative number
assertThrows(IllegalArgumentException.class, () ->
ppt.setFirstSlideNumber(-1),
"Negative number should throw IllegalArgumentException.");
// Test case: Number greater than 9999
assertThrows(IllegalArgumentException.class, () ->
ppt.setFirstSlideNumber(10000),
"Number greater than 9999 should throw IllegalArgumentException.");
// Ensure the value hasn't changed from the default after failed attempts
assertEquals(1, ppt.getFirstSlideNumber());
}
}
}

View File

@ -19,6 +19,7 @@ package org.apache.poi.xslf.usermodel;
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertInstanceOf;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertSame;
@ -36,12 +37,8 @@ import java.io.IOException;
import java.util.List;
import org.apache.poi.sl.draw.DrawTableShape;
import org.apache.poi.sl.usermodel.ShapeType;
import org.apache.poi.sl.usermodel.Slide;
import org.apache.poi.sl.usermodel.StrokeStyle;
import org.apache.poi.sl.usermodel.*;
import org.apache.poi.sl.usermodel.TableCell.BorderEdge;
import org.apache.poi.sl.usermodel.TextParagraph;
import org.apache.poi.sl.usermodel.VerticalAlignment;
import org.apache.poi.util.RandomSingleton;
import org.apache.poi.util.TempFile;
import org.apache.poi.xslf.XSLFTestDataSamples;
@ -84,6 +81,7 @@ class TestXSLFTable {
tab.removeColumn(0);
tab.removeColumn(tab.getNumberOfColumns() - 1);
assertEquals(data[0].length, tab.getNumberOfColumns());
assertNull(tab.getTableStyle());
int startRow = rowIdx-1;
@ -167,7 +165,7 @@ class TestXSLFTable {
XSLFSlide slide = ppt.getSlides().get(3);
List<XSLFShape> shapes = slide.getShapes();
assertEquals(1, shapes.size());
assertTrue(shapes.get(0) instanceof XSLFTable);
assertInstanceOf(XSLFTable.class, shapes.get(0));
XSLFTable tbl = (XSLFTable)shapes.get(0);
assertEquals(3, tbl.getNumberOfColumns());
assertEquals(6, tbl.getNumberOfRows());
@ -179,6 +177,7 @@ class TestXSLFTable {
assertEquals(90.0, tbl.getColumnWidth(0), 0);
assertEquals(240.0, tbl.getColumnWidth(1), 0);
assertEquals(150.0, tbl.getColumnWidth(2), 0);
assertNotNull(tbl.getTableStyle());
for(XSLFTableRow row : tbl){
// all rows have the same height
@ -211,7 +210,7 @@ class TestXSLFTable {
assertNotNull(tbl.getCTTable());
assertNotNull(tbl.getCTTable().getTblGrid());
assertNotNull(tbl.getCTTable().getTblPr());
assertTrue(tbl.getXmlObject() instanceof CTGraphicalObjectFrame);
assertInstanceOf(CTGraphicalObjectFrame.class, tbl.getXmlObject());
assertEquals("Table 2", tbl.getShapeName());
assertEquals(2, tbl.getShapeId());
assertEquals(0, tbl.getRows().size());
@ -220,6 +219,7 @@ class TestXSLFTable {
assertEquals(0, tbl.getNumberOfColumns());
assertEquals(0, tbl.getNumberOfRows());
assertNull(tbl.getTableStyle());
XSLFTableRow row0 = tbl.addRow();
assertNotNull(row0.getXmlObject());
@ -285,6 +285,7 @@ class TestXSLFTable {
XMLSlideShow ss = XSLFTestDataSamples.openSampleDocument("shapes.pptx");
XSLFSlide sl = ss.getSlides().get(0);
XSLFTable tab = (XSLFTable)sl.getShapes().get(4);
assertNotNull(tab.getTableStyle());
sl.removeShape(tab);
XMLSlideShow ss2 = XSLFTestDataSamples.writeOutAndReadBack(ss);
@ -309,6 +310,7 @@ class TestXSLFTable {
XSLFTableCell tc0 = tr.addCell();
tc0.setText("bla bla bla bla");
tab.setColumnWidth(0, 50);
assertNull(tab.getTableStyle());
// usually text height == 88, but font rendering is platform dependent
// so we use something more reliable
@ -359,7 +361,76 @@ class TestXSLFTable {
new DrawTableShape(newTable).setAllBorders(3., StrokeStyle.LineDash.LG_DASH_DOT, Color.BLUE);
assertEquals(3, newTable.getCTTable().getTblGrid().sizeOfGridColArray());
assertNull(newTable.getTableStyle());
}
}
}
private void verifyTableCellStyleColors(XSLFTableCell cell, String text, Color fontColor, Color fillColor) {
assertEquals(text, cell.getText());
PaintStyle colorText1 = cell.getTextParagraphs().get(0).getTextRuns().get(0).getFontColor();
assertInstanceOf(PaintStyle.SolidPaint.class, colorText1);
assertEquals(fontColor, ((PaintStyle.SolidPaint)colorText1).getSolidColor().getColor());
assertEquals(fillColor, cell.getFillColor());
}
@Test
void testTableCellStyle() throws IOException {
XMLSlideShow ppt = XSLFTestDataSamples.openSampleDocument("table-with-different-font-colors.pptx");
// First slide: test row-related table styles
List<XSLFShape> shapes = ppt.getSlides().get(0).getShapes();
assertEquals(1, shapes.size());
assertInstanceOf(XSLFTable.class, shapes.get(0));
XSLFTable tbl = (XSLFTable)shapes.get(0);
assertEquals(4, tbl.getNumberOfColumns());
assertEquals(4, tbl.getNumberOfRows());
assertNotNull(tbl.getCTTable());
assertNotNull(tbl.getTableStyle());
// Yellow font color due to "first row" table style
verifyTableCellStyleColors(tbl.getRows().get(0).getCells().get(0), "Text 1",
new Color(255, 255, 0), new Color(21, 96, 130));
// Dark green font color due to direct format
verifyTableCellStyleColors(tbl.getRows().get(0).getCells().get(2), "Text 3",
new Color(0, 176, 80), new Color(21, 96, 130));
// Grey font color due to "even row" table style + fallback
verifyTableCellStyleColors(tbl.getRows().get(1).getCells().get(0), "Text 5",
new Color(119, 119, 119), new Color(204, 210, 216));
// Light blue font color due to "odd row" table style
verifyTableCellStyleColors(tbl.getRows().get(2).getCells().get(0), "Text 9",
new Color(0, 255, 255), new Color(231, 234, 237));
// Red font color due to direct format
verifyTableCellStyleColors(tbl.getRows().get(2).getCells().get(2), "Text 11",
new Color(255, 0, 0), new Color(231, 234, 237));
// Blue font color due to "last row" table style
verifyTableCellStyleColors(tbl.getRows().get(3).getCells().get(0), "Text 13",
new Color(0, 0, 255), new Color(21, 96, 130));
// Second slide: test column-related table styles
shapes = ppt.getSlides().get(1).getShapes();
assertEquals(1, shapes.size());
assertInstanceOf(XSLFTable.class, shapes.get(0));
tbl = (XSLFTable)shapes.get(0);
assertEquals(4, tbl.getNumberOfColumns());
assertEquals(4, tbl.getNumberOfRows());
assertNotNull(tbl.getCTTable());
assertNotNull(tbl.getTableStyle());
// Green font color due to "first column" table style
verifyTableCellStyleColors(tbl.getRows().get(0).getCells().get(0), "Text 1",
new Color(0, 255, 0), new Color(21, 96, 130));
// Grey font color due to "even column" table style + fallback
verifyTableCellStyleColors(tbl.getRows().get(0).getCells().get(1), "Text 2",
new Color(119, 119, 119), new Color(204, 210, 216));
// Light blue font color due to "odd column" table style
verifyTableCellStyleColors(tbl.getRows().get(0).getCells().get(2), "Text 3",
new Color(0, 255, 255), new Color(231, 234, 237));
// Red font color due to "last column" table style
verifyTableCellStyleColors(tbl.getRows().get(0).getCells().get(3), "Text 4",
new Color(255, 0, 0), new Color(21, 96, 130));
ppt.close();
}
}

View File

@ -982,4 +982,4 @@ class TestXSLFTextShape {
assertEquals(textExp, textAct);
}
}
}
}

View File

@ -677,6 +677,20 @@ public final class TestXSSFExportToXML {
}
}
@Test
void testMissingRow() throws Exception {
try (XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("xxe_in_schema.xlsx")) {
// delete the row to cause a null-row
wb.getSheetAt(0).removeRow(wb.getSheetAt(0).getRow(9));
for (XSSFMap map : wb.getCustomXMLMappings()) {
XSSFExportToXml exporter = new XSSFExportToXml(map);
UnsynchronizedByteArrayOutputStream bos = UnsynchronizedByteArrayOutputStream.builder().get();
assertThrows(SAXParseException.class, () -> exporter.exportToXML(bos, true));
}
}
}
private static class XPathNSContext implements NamespaceContext {
final Map<String,String> nsMap = new HashMap<>();

View File

@ -1,122 +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.xssf.streaming;
import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.IOException;
import java.io.InputStream;
import org.apache.commons.io.output.UnsynchronizedByteArrayOutputStream;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.junit.jupiter.api.Test;
/**
* Test creates cells in reverse column order in XSSF and SXSSF and expects
* saved files to have fixed the order.
*
* This is necessary because if columns in the saved file are out of order
* Excel will show a repair dialog when opening the file and removing data.
*/
public final class TestOutOfOrderColumns {
@Test
void outOfOrderColumnsXSSF() throws IOException {
try (
XSSFWorkbook wb = new XSSFWorkbook();
UnsynchronizedByteArrayOutputStream bos = UnsynchronizedByteArrayOutputStream.builder().get()
) {
XSSFSheet sheet = wb.createSheet();
Row row = sheet.createRow(0);
// create cells in reverse order
row.createCell(1).setCellValue("def");
row.createCell(0).setCellValue("abc");
wb.write(bos);
validateOrder(bos.toInputStream());
}
}
@Test
void outOfOrderColumnsSXSSF() throws IOException {
try (
SXSSFWorkbook wb = new SXSSFWorkbook();
UnsynchronizedByteArrayOutputStream bos = UnsynchronizedByteArrayOutputStream.builder().get()
) {
Sheet sheet = wb.createSheet();
Row row = sheet.createRow(0);
// create cells in reverse order
row.createCell(1).setCellValue("xyz");
row.createCell(0).setCellValue("uvw");
wb.write(bos);
validateOrder(bos.toInputStream());
}
}
@Test
/** this is the problematic case, as XSSF column sorting is skipped when saving with SXSSF. */
void mixOfXSSFAndSXSSF() throws IOException {
try (
XSSFWorkbook wb = new XSSFWorkbook();
UnsynchronizedByteArrayOutputStream bos = UnsynchronizedByteArrayOutputStream.builder().get()
) {
XSSFSheet sheet = wb.createSheet();
Row row1 = sheet.createRow(0);
// create cells in reverse order
row1.createCell(1).setCellValue("def");
row1.createCell(0).setCellValue("abc");
try (SXSSFWorkbook sxssfWorkbook = new SXSSFWorkbook(wb)) {
Sheet sSheet = sxssfWorkbook.getSheetAt(0);
Row row2 = sSheet.createRow(1);
// create cells in reverse order
row2.createCell(1).setCellValue("xyz");
row2.createCell(0).setCellValue("uvw");
sxssfWorkbook.write(bos);
validateOrder(bos.toInputStream());
}
}
}
private void validateOrder(InputStream is) throws IOException {
// test if saved cells are in order
try (XSSFWorkbook xssfWorkbook = new XSSFWorkbook(is)) {
XSSFSheet xssfSheet = xssfWorkbook.getSheetAt(0);
Row resultRow = xssfSheet.getRow(0);
// POI doesn't show stored order because _cells TreeMap sorts it automatically.
// The only way to test is to compare the xml.
String s = resultRow.toString();
assertTrue(s.matches("(?s).*A1.*B1.*"), "unexpected order: " + s);
}
}
}
/*
* ====================================================================
* 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.xssf.streaming;
import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.IOException;
import java.io.InputStream;
import org.apache.commons.io.output.UnsynchronizedByteArrayOutputStream;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.junit.jupiter.api.Test;
/**
* Test creates cells in reverse column order in XSSF and SXSSF and expects
* saved files to have fixed the order.
*
* This is necessary because if columns in the saved file are out of order
* Excel will show a repair dialog when opening the file and removing data.
*/
public final class TestOutOfOrderColumns {
@Test
void outOfOrderColumnsXSSF() throws IOException {
try (
XSSFWorkbook wb = new XSSFWorkbook();
UnsynchronizedByteArrayOutputStream bos = UnsynchronizedByteArrayOutputStream.builder().get()
) {
XSSFSheet sheet = wb.createSheet();
Row row = sheet.createRow(0);
// create cells in reverse order
row.createCell(1).setCellValue("def");
row.createCell(0).setCellValue("abc");
wb.write(bos);
validateOrder(bos.toInputStream());
}
}
@Test
void outOfOrderColumnsSXSSF() throws IOException {
try (
SXSSFWorkbook wb = new SXSSFWorkbook();
UnsynchronizedByteArrayOutputStream bos = UnsynchronizedByteArrayOutputStream.builder().get()
) {
Sheet sheet = wb.createSheet();
Row row = sheet.createRow(0);
// create cells in reverse order
row.createCell(1).setCellValue("xyz");
row.createCell(0).setCellValue("uvw");
wb.write(bos);
validateOrder(bos.toInputStream());
}
}
@Test
/** this is the problematic case, as XSSF column sorting is skipped when saving with SXSSF. */
void mixOfXSSFAndSXSSF() throws IOException {
try (
XSSFWorkbook wb = new XSSFWorkbook();
UnsynchronizedByteArrayOutputStream bos = UnsynchronizedByteArrayOutputStream.builder().get()
) {
XSSFSheet sheet = wb.createSheet();
Row row1 = sheet.createRow(0);
// create cells in reverse order
row1.createCell(1).setCellValue("def");
row1.createCell(0).setCellValue("abc");
try (SXSSFWorkbook sxssfWorkbook = new SXSSFWorkbook(wb)) {
Sheet sSheet = sxssfWorkbook.getSheetAt(0);
Row row2 = sSheet.createRow(1);
// create cells in reverse order
row2.createCell(1).setCellValue("xyz");
row2.createCell(0).setCellValue("uvw");
sxssfWorkbook.write(bos);
validateOrder(bos.toInputStream());
}
}
}
private void validateOrder(InputStream is) throws IOException {
// test if saved cells are in order
try (XSSFWorkbook xssfWorkbook = new XSSFWorkbook(is)) {
XSSFSheet xssfSheet = xssfWorkbook.getSheetAt(0);
Row resultRow = xssfSheet.getRow(0);
// POI doesn't show stored order because _cells TreeMap sorts it automatically.
// The only way to test is to compare the xml.
String s = resultRow.toString();
assertTrue(s.matches("(?s).*A1.*B1.*"), "unexpected order: " + s);
}
}
}

View File

@ -27,6 +27,7 @@ import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.IOException;
import java.time.LocalDateTime;
import java.util.List;
import org.apache.poi.common.usermodel.HyperlinkType;
@ -61,6 +62,7 @@ import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.EnumSource;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCell;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCellFormula;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTRst;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.STCellFormulaType;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.STCellType;
@ -762,4 +764,89 @@ public final class TestXSSFCell extends BaseTestXCell {
Cell cell = new XSSFWorkbook().createSheet().createRow(0).createCell(0);
assertThrows(IllegalStateException.class, cell::getErrorCellValue);
}
@Test
void setStringToBlank() throws IOException {
try (XSSFWorkbook wb = new XSSFWorkbook()) {
XSSFSheet sheet = wb.createSheet();
XSSFCell cell = sheet.createRow(0).createCell(0);
cell.setCellValue("test123");
cell.setCellType(CellType.BLANK);
assertEquals("", cell.getStringCellValue());
}
}
@Test
void setInlineStringToNewStringValue() throws IOException {
try (XSSFWorkbook wb = new XSSFWorkbook()) {
XSSFSheet sheet = wb.createSheet();
XSSFCell cell = sheet.createRow(0).createCell(0);
setInlineString(cell, "text123");
cell.setCellValue("newValue");
assertEquals("newValue", cell.getStringCellValue());
assertFalse(cell.getCTCell().isSetIs(), "cell has InlineString XML struct still?");
}
}
@Test
void setInlineStringToNewNumberValue() throws IOException {
try (XSSFWorkbook wb = new XSSFWorkbook()) {
XSSFSheet sheet = wb.createSheet();
XSSFCell cell = sheet.createRow(0).createCell(0);
setInlineString(cell, "text123");
cell.setCellValue(123.456d);
assertEquals(123.456d, cell.getNumericCellValue());
assertFalse(cell.getCTCell().isSetIs(), "cell has InlineString XML struct still?");
}
}
@Test
void setInlineStringToNewLocalDateValue() throws IOException {
try (XSSFWorkbook wb = new XSSFWorkbook()) {
XSSFSheet sheet = wb.createSheet();
XSSFCell cell = sheet.createRow(0).createCell(0);
setInlineString(cell, "text123");
LocalDateTime ldt = LocalDateTime.parse("2025-12-18T19:01:34");
cell.setCellValue(ldt);
assertEquals(ldt, cell.getLocalDateTimeCellValue());
assertFalse(cell.getCTCell().isSetIs(), "cell has InlineString XML struct still?");
}
}
@Test
void setInlineStringToBlank() throws IOException {
try (XSSFWorkbook wb = new XSSFWorkbook()) {
XSSFSheet sheet = wb.createSheet();
XSSFCell cell = sheet.createRow(0).createCell(0);
setInlineString(cell, "text123");
cell.setCellType(CellType.BLANK);
assertEquals("", cell.getStringCellValue());
assertFalse(cell.getCTCell().isSetIs(), "cell has InlineString XML struct still?");
}
}
@Test
void setFormulaToBlank() throws IOException {
try (XSSFWorkbook wb = new XSSFWorkbook()) {
XSSFSheet sheet = wb.createSheet();
XSSFCell cell = sheet.createRow(0).createCell(0);
cell.setCellFormula("ISODD(1)");
cell.setCellValue("3.14");
assertTrue(cell.getCTCell().isSetF(), "cell has formula XML struct?");
assertEquals("ISODD(1)", cell.getCellFormula());
assertEquals("3.14", cell.getStringCellValue());
cell.setCellType(CellType.BLANK);
assertEquals("", cell.getStringCellValue());
assertFalse(cell.getCTCell().isSetF(), "cell has formula XML struct still?");
}
}
private static void setInlineString(XSSFCell cell, String text) {
cell.setCellType(CellType.STRING);
CTRst rst = CTRst.Factory.newInstance();
rst.setT(text);
cell.getCTCell().setT(STCellType.INLINE_STR);
cell.getCTCell().setIs(rst);
assertEquals(text, cell.getStringCellValue());
}
}

View File

@ -39,7 +39,6 @@ import org.junit.jupiter.api.Test;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTTable;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTTableColumn;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTTableStyleInfo;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTWorksheet;
import static org.junit.jupiter.api.Assertions.*;
@ -784,4 +783,19 @@ public final class TestXSSFTable {
}
}
}
@Test
void testGetStyleNameNull() throws IOException {
try (XSSFWorkbook wb = new XSSFWorkbook()) {
XSSFSheet sh = wb.createSheet();
AreaReference tableArea = new AreaReference("B2:B6", wb.getSpreadsheetVersion());
XSSFTable table = sh.createTable(tableArea);
assertNull(table.getStyleName());
table.getCTTable().setTableStyleInfo(CTTableStyleInfo.Factory.newInstance());
assertNull(table.getStyleName());
}
}
}

View File

@ -252,7 +252,7 @@ public final class TestColumnHelper {
}
/**
* Creates and adds a hidden column and then a best fit column with the given min/max pairs.
* Creates and adds a hidden column and then the best fit column with the given min/max pairs.
* Suitable for testing handling of overlap.
*/
private static CTCols createHiddenAndBestFitColsWithHelper(int hiddenMin, int hiddenMax, int bestFitMin, int bestFitMax) {
@ -404,7 +404,6 @@ public final class TestColumnHelper {
return count;
}
@SuppressWarnings("deprecation")
@Test
void testColumnsCollapsed() throws IOException {
try (XSSFWorkbook wb = new XSSFWorkbook()) {

View File

@ -44,6 +44,7 @@ import org.apache.poi.openxml4j.opc.PackageAccess;
import org.apache.poi.openxml4j.opc.PackagePart;
import org.apache.poi.openxml4j.opc.PackagePartName;
import org.apache.poi.openxml4j.opc.PackagingURIHelper;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.apache.poi.xwpf.XWPFTestDataSamples;
import org.apache.poi.xwpf.extractor.XWPFWordExtractor;
import org.apache.xmlbeans.XmlCursor;
@ -512,11 +513,22 @@ public final class TestXWPFDocument {
try (XWPFDocument doc = new XWPFDocument(
POIDataSamples.getDocumentInstance().openResourceAsStream("unicode-path.docx"))) {
// expect exception here
assertNotNull(doc);
}
});
assertEquals("InvalidFormatException", ex.getCause().getClass().getSimpleName());
}
@Test
void testChartExIgnored() throws IOException {
// see https://github.com/apache/poi/pull/982
try (XWPFDocument doc = new XWPFDocument(
POIDataSamples.getDocumentInstance().openResourceAsStream("chartex.docx"))) {
assertNotNull(doc);
}
}
@Test
@Disabled("XWPF should be able to write to a new Stream when opened Read-Only")
void testWriteFromReadOnlyOPC() throws Exception {
@ -535,4 +547,13 @@ public final class TestXWPFDocument {
}
}
}
@Test
void testFileHandleLeak() {
//noinspection resource
assertThrows(POIXMLException.class,
// Use XSSFWorkbook on purpose here to trigger missing closing of file-handle
() -> new XSSFWorkbook(
POIDataSamples.getDocumentInstance().getFile("clusterfuzz-testcase-minimized-POIXWPFFuzzer-4791943399604224.docx")));
}
}

View File

@ -95,6 +95,29 @@ public final class TestXWPFSDT {
}
}
@Test
void testGetSDTContentBodyElements() throws Exception {
try (XWPFDocument doc = XWPFTestDataSamples.openSampleDocument("Bug54849.docx")) {
IBodyElement sdtBodyElement = doc.getBodyElements().get(2);
assertTrue(sdtBodyElement instanceof XWPFSDT, "sdtBodyElement instance of XWPFSDT");
XWPFSDTContent content = (XWPFSDTContent) ((XWPFSDT) sdtBodyElement).getContent();
assertEquals(3, content.getBodyElements().size(), "elements inside SDT");
ISDTContents c1 = content.getBodyElements().get(0);
assertTrue(c1 instanceof XWPFParagraph, "c1 instance of XWPFParagraph");
assertEquals("Rich_text_pre_table", ((XWPFParagraph) c1).getText());
ISDTContents c2 = content.getBodyElements().get(1);
assertTrue(c2 instanceof XWPFTable, "c2 instance of XWPFTable");
assertEquals(3, ((XWPFTable) c2).getNumberOfRows(), "rows in table inside SDT");
assertEquals("Rich_text_cell1", ((XWPFTable) c2).getRow(0).getCell(0).getText());
ISDTContents c3 = content.getBodyElements().get(2);
assertTrue(c3 instanceof XWPFParagraph, "c3 instance of XWPFParagraph");
assertEquals("Rich_text_post_table", ((XWPFParagraph) c3).getText());
}
}
/**
* POI-54771 and TIKA-1317
*/

View File

@ -21,11 +21,13 @@ import org.apache.poi.xslf.usermodel.XSLFColor;
import org.apache.poi.xwpf.XWPFTestDataSamples;
import org.junit.jupiter.api.Test;
import org.openxmlformats.schemas.drawingml.x2006.main.CTColor;
import org.openxmlformats.schemas.drawingml.x2006.main.CTOfficeStyleSheet;
import java.awt.*;
import java.io.IOException;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
public final class TestXWPFTheme {
@ -36,6 +38,11 @@ public final class TestXWPFTheme {
assertEquals("Office Theme", theme.getName());
assertEquals("Cambria", theme.getMajorFont());
assertEquals("Calibri", theme.getMinorFont());
assertEquals("Angsana New", theme.getMajorFontForScript("Thai"));
assertEquals("Cordia New", theme.getMinorFontForScript("Thai"));
CTOfficeStyleSheet styleSheet = theme.getCTOfficeStyleSheet();
assertNotNull(styleSheet);
assertEquals("Office", styleSheet.getThemeElements().getFontScheme().getName());
CTColor accent1 = theme.getCTColor("accent1");
XSLFColor color = new XSLFColor(accent1, null, null, null);
assertEquals(new Color(79, 129, 189), color.getColor());

View File

@ -200,6 +200,7 @@ module org.apache.poi.ooxml {
opens org.apache.poi.xssf.streaming to org.junit.platform.commons;
opens org.apache.poi.xssf.util to org.junit.platform.commons;
opens org.apache.poi.xslf.draw to org.junit.platform.commons;
opens org.apache.poi.xslf.draw.geom to org.junit.platform.commons;
opens org.apache.poi.xslf.usermodel to org.junit.platform.commons;
opens org.apache.poi.xslf.model to org.junit.platform.commons;
opens org.apache.poi.xslf.util to org.junit.platform.commons;

View File

@ -88,7 +88,7 @@ tasks.register('compileTest9', JavaCompile) {
jar {
destinationDirectory = file("../build/dist/maven/${project.archivesBaseName}")
destinationDirectory = file("../build/dist/maven/${base.archivesName.get()}")
manifest {
attributes('Automatic-Module-Name': MODULE_NAME, 'Multi-Release': 'true')
@ -98,7 +98,7 @@ jar {
// 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) {
destinationDirectory = file("../build/dist/maven/${project.archivesBaseName}-tests")
destinationDirectory = file("../build/dist/maven/${base.archivesName.get()}-tests")
setArchiveClassifier 'tests'
// ignore second module-info.class from main

View File

@ -39,10 +39,14 @@ import org.apache.poi.hwmf.record.HwmfDraw;
import org.apache.poi.hwmf.record.HwmfDraw.WmfSelectObject;
import org.apache.poi.util.GenericRecordJsonWriter;
import org.apache.poi.util.GenericRecordUtil;
import org.apache.poi.util.IOUtils;
import org.apache.poi.util.LittleEndianConsts;
import org.apache.poi.util.LittleEndianInputStream;
public final class HemfDraw {
// arbitrary limit to avoid OOM on malformed files. This may need increasing if "normal" files have more than this
public static final int MAX_NUMBER_OF_POLYGONS = 100_000;
private HemfDraw() {}
/**
@ -501,6 +505,7 @@ public final class HemfDraw {
size += 2 * LittleEndianConsts.INT_SIZE;
// An array of 32-bit unsigned integers that specifies the point count for each polygon.
IOUtils.safelyAllocateCheck(numberOfPolygons, MAX_NUMBER_OF_POLYGONS);
long[] polygonPointCount = new long[(int)numberOfPolygons];
size += numberOfPolygons * LittleEndianConsts.INT_SIZE;

View File

@ -24,6 +24,8 @@ import java.io.IOException;
import java.util.Map;
import java.util.function.Supplier;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.poi.common.usermodel.GenericRecord;
import org.apache.poi.hemf.draw.HemfGraphics;
import org.apache.poi.hemf.draw.HemfGraphics.EmfRenderState;
@ -38,6 +40,8 @@ import org.apache.poi.util.LittleEndianInputStream;
@Internal
public class HemfPlusHeader implements HemfPlusRecord {
private static final Logger log = LogManager.getLogger(HemfPlusHeader.class);
/**
* The GraphicsVersion enumeration defines versions of operating system graphics that are used to
* create EMF+ metafiles.
@ -89,7 +93,12 @@ public class HemfPlusHeader implements HemfPlusRecord {
this.flags = flags;
version.init(leis);
assert(version.getMetafileSignature() == 0xDBC01 && version.getGraphicsVersion() != null);
if (version.getMetafileSignature() != 0xDBC01) {
log.atWarn().log("Had invalid meta-file signature, expected " + 0xDBC01 + ", had: " + version.getMetafileSignature());
}
if (version.getGraphicsVersion() == null) {
log.atWarn().log("Encountered empty graphics version in emf file");
}
emfPlusFlags = leis.readUInt();

View File

@ -47,6 +47,7 @@ import org.apache.poi.ddf.EscherSpgrRecord;
import org.apache.poi.ddf.EscherTextboxRecord;
import org.apache.poi.sl.usermodel.ShapeType;
import org.apache.poi.util.GenericRecordUtil;
import org.apache.poi.util.IOUtils;
import org.apache.poi.util.LittleEndian;
/**
@ -65,6 +66,7 @@ import org.apache.poi.util.LittleEndian;
// would require a wrapping class
public final class PPDrawing extends RecordAtom implements Iterable<EscherRecord> {
public static final int MAX_RECORD_SIZE = 20_000_000;
private final byte[] _header;
private long _type;
@ -214,8 +216,9 @@ public final class PPDrawing extends RecordAtom implements Iterable<EscherRecord
// Write out our header
out.write(_header);
// Now grab the children's data
byte[] b = new byte[newSize];
// Now grab the children's data, but fail if it tries to allocate
// too much
byte[] b = IOUtils.safelyAllocate(newSize, MAX_RECORD_SIZE);
int done = 0;
dgContainer.serialize(done, b);

View File

@ -25,6 +25,7 @@ import java.util.Collections;
import java.util.List;
import org.apache.logging.log4j.Logger;
import org.apache.poi.ddf.EscherProperty;
import org.apache.poi.logging.PoiLogManager;
import org.apache.poi.ddf.AbstractEscherOptRecord;
import org.apache.poi.ddf.EscherArrayProperty;
@ -217,7 +218,7 @@ public final class HSLFFill {
/**
* The shape this background applies to
*/
private HSLFShape shape;
private final HSLFShape shape;
/**
* Construct a {@code Fill} object for a shape.
@ -244,7 +245,12 @@ public final class HSLFFill {
if (!FILL_USE_FILLED.isSet(propVal) && masterProp != null) {
int masterId = masterProp.getPropertyValue();
HSLFShape o = shape.getSheet().getMasterSheet().getShapes().stream().filter(s -> s.getShapeId() == masterId).findFirst().orElse(null);
HSLFMasterSheet masterSheet = shape.getSheet().getMasterSheet();
if (masterSheet == null) {
return null;
}
HSLFShape o = masterSheet.getShapes().stream().filter(s -> s.getShapeId() == masterId).findFirst().orElse(null);
return o != null ? o.getFillStyle().getPaint() : null;
}
@ -452,7 +458,6 @@ public final class HSLFFill {
}
}
@SuppressWarnings("resource")
EscherBSERecord getEscherBSERecord(int idx){
HSLFSheet sheet = shape.getSheet();
if(sheet == null) {
@ -555,11 +560,10 @@ public final class HSLFFill {
/**
* {@code PictureData} object used in a texture, pattern of picture fill.
*/
@SuppressWarnings("resource")
public HSLFPictureData getPictureData(){
AbstractEscherOptRecord opt = shape.getEscherOptRecord();
EscherSimpleProperty p = HSLFShape.getEscherProperty(opt, EscherPropertyTypes.FILL__PATTERNTEXTURE);
if (p == null) {
EscherProperty p = HSLFShape.getEscherProperty(opt, EscherPropertyTypes.FILL__PATTERNTEXTURE);
if (!(p instanceof EscherSimpleProperty)) {
return null;
}
@ -570,7 +574,7 @@ public final class HSLFFill {
EscherContainerRecord dggContainer = doc.getPPDrawingGroup().getDggContainer();
EscherContainerRecord bstore = HSLFShape.getEscherChild(dggContainer, EscherContainerRecord.BSTORE_CONTAINER);
int idx = p.getPropertyValue();
int idx = ((EscherSimpleProperty)p).getPropertyValue();
if (idx == 0){
LOG.atWarn().log("no reference to picture data found ");
} else {

View File

@ -78,7 +78,7 @@ implements HSLFShapeContainer, GroupShape<HSLFShape,HSLFTextParagraph> {
public void setAnchor(Rectangle2D anchor) {
EscherClientAnchorRecord clientAnchor = getEscherChild(EscherClientAnchorRecord.RECORD_ID);
boolean isInitialized = !(clientAnchor.getDx1() == 0 && clientAnchor.getRow1() == 0);
if (isInitialized) {
moveAndScale(anchor);
} else {
@ -113,7 +113,7 @@ implements HSLFShapeContainer, GroupShape<HSLFShape,HSLFTextParagraph> {
protected void setExteriorAnchor(Rectangle2D anchor) {
EscherClientAnchorRecord clientAnchor = getEscherChild(EscherClientAnchorRecord.RECORD_ID);
//hack. internal variable EscherClientAnchorRecord.shortRecord can be
//initialized only in fillFields(). We need to set shortRecord=false;
byte[] header = new byte[16];
@ -131,7 +131,7 @@ implements HSLFShapeContainer, GroupShape<HSLFShape,HSLFTextParagraph> {
// TODO: does this make sense?
setInteriorAnchor(anchor);
}
/**
* Create a new ShapeGroup and create an instance of <code>EscherSpgrContainer</code> which represents a group of shapes
*/
@ -186,7 +186,7 @@ implements HSLFShapeContainer, GroupShape<HSLFShape,HSLFTextParagraph> {
double scaleY = (anchorSrc.getHeight() == 0) ? 0 : anchorDest.getHeight() / anchorSrc.getHeight();
setExteriorAnchor(anchorDest);
for (HSLFShape shape : getShapes()) {
Rectangle2D chanchor = shape.getAnchor();
double x = anchorDest.getX()+(chanchor.getX()-anchorSrc.getX())*scaleX;
@ -204,12 +204,16 @@ implements HSLFShapeContainer, GroupShape<HSLFShape,HSLFTextParagraph> {
* @return the anchor of this shape group
*/
@Override
public Rectangle2D getAnchor(){
public Rectangle2D getAnchor() {
EscherClientAnchorRecord clientAnchor = getEscherChild(EscherClientAnchorRecord.RECORD_ID);
int x1,y1,x2,y2;
if(clientAnchor == null){
if(clientAnchor == null) {
LOG.atInfo().log("EscherClientAnchorRecord was not found for shape group. Searching for EscherChildAnchorRecord.");
EscherChildAnchorRecord rec = getEscherChild(EscherChildAnchorRecord.RECORD_ID);
if (rec == null) {
throw new IllegalStateException("Cannot get anchor, neither had an EscherClientAnchorRecord nor an EscherChildAnchorRecord");
}
x1 = rec.getDx1();
y1 = rec.getDy1();
x2 = rec.getDx2();
@ -293,7 +297,7 @@ implements HSLFShapeContainer, GroupShape<HSLFShape,HSLFTextParagraph> {
isFirst = false;
continue;
}
if(r instanceof EscherContainerRecord) {
// Create the Shape for it
EscherContainerRecord container = (EscherContainerRecord)r;

View File

@ -228,4 +228,9 @@ public class HSLFPictureShape extends HSLFSimpleShape implements PictureShape<HS
int fixedPoint = prop.getPropertyValue();
return Units.fixedPointToDouble(fixedPoint);
}
}
public int getAlpha() {
return Math.toIntExact(
(long) (super.getAlpha(EscherPropertyTypes.FILL__FILLOPACITY) * 100000));
}
}

View File

@ -266,7 +266,7 @@ public abstract class HSLFShape implements Shape<HSLFShape,HSLFTextParagraph> {
* @return escher property or {@code null} if not found.
*/
public static <T extends EscherProperty> T getEscherProperty(AbstractEscherOptRecord opt, EscherPropertyTypes type){
return (opt == null) ? null : opt.lookup(type);
return opt == null ? null : opt.lookup(type);
}
/**
@ -408,11 +408,13 @@ public abstract class HSLFShape implements Shape<HSLFShape,HSLFTextParagraph> {
if (fSchemeIndex && sheet != null) {
//red is the index to the color scheme
ColorSchemeAtom ca = sheet.getColorScheme();
int schemeColor = ca.getColor(ecr.getSchemeIndex());
if (ca != null) {
int schemeColor = ca.getColor(ecr.getSchemeIndex());
rgb[0] = (schemeColor >> 0) & 0xFF;
rgb[1] = (schemeColor >> 8) & 0xFF;
rgb[2] = (schemeColor >> 16) & 0xFF;
rgb[0] = (schemeColor >> 0) & 0xFF;
rgb[1] = (schemeColor >> 8) & 0xFF;
rgb[2] = (schemeColor >> 16) & 0xFF;
}
} else if (fPaletteIndex) {
//TODO
} else if (fPaletteRGB) {
@ -657,9 +659,9 @@ public abstract class HSLFShape implements Shape<HSLFShape,HSLFTextParagraph> {
}
/**
* Search for EscherClientDataRecord, if found, convert its contents into an array of HSLF records
* Search for EscherClientDataRecord, if found, convert its contents into a list of HSLF records
*
* @return an array of HSLF records contained in the shape's EscherClientDataRecord or {@code null}
* @return a list of HSLF records contained in the shape's EscherClientDataRecord or {@code null}
*/
protected List<? extends Record> getClientRecords() {
HSLFEscherClientDataRecord clientData = getClientData(false);

View File

@ -112,6 +112,10 @@ public final class HSLFSlideMaster extends HSLFMasterSheet {
return null;
}
final TxMasterStyleAtom t = _txmaster[txtype];
if (t == null) {
throw new IllegalStateException("Cannot get master-style for type " + txtype);
}
final List<TextPropCollection> styles = isCharacter ? t.getCharacterStyles() : t.getParagraphStyles();
// TODO: what is the reaction for readOnly=false and styles.isEmpty()?
final int minLevel = Math.min(level, styles.size()-1);

View File

@ -714,7 +714,10 @@ public final class HSLFTextParagraph implements TextParagraph<HSLFShape,HSLFText
return getDefaultFontFamily();
}
HSLFFontInfo ppFont = getSheet().getSlideShow().getFont(tp.getValue());
assert(ppFont != null);
if (ppFont == null) {
throw new IllegalStateException("Could not get font from slide-show for bullet-font '" + tp.getValue() + "'");
}
return ppFont.getTypeface();
}
@ -1665,6 +1668,9 @@ public final class HSLFTextParagraph implements TextParagraph<HSLFShape,HSLFText
return null;
}
ColorSchemeAtom ca = sheet.getColorScheme();
if (ca == null) {
throw new IllegalStateException("Cannot read color scheme from sheet");
}
tmp = new Color(ca.getColor(cidx), true);
break;
// Color is an sRGB value specified by red, green, and blue fields.

View File

@ -351,7 +351,7 @@ implements TextShape<HSLFShape,HSLFTextParagraph> {
return -1;
}
List<HSLFTextParagraph> paras = HSLFTextParagraph.findTextParagraphs(_txtbox, getSheet());
return (paras.isEmpty() || paras.get(0).getIndex() == -1) ? -1 : paras.get(0).getRunType();
return (paras == null || paras.isEmpty() || paras.get(0).getIndex() == -1) ? -1 : paras.get(0).getRunType();
}
/**

View File

@ -51,6 +51,9 @@ import org.apache.poi.util.RecordFormatException;
* The DeviceIndependentBitmap Object defines an image in device-independent bitmap (DIB) format.
*/
public class HwmfBitmapDib implements GenericRecord {
// arbitrarily selected; may need to increase
private static final int DEFAULT_MAX_HEIGHT_WIDTH = 10_000;
protected static int MAX_HEIGHT_WIDTH = DEFAULT_MAX_HEIGHT_WIDTH;
private static final Logger LOG = PoiLogManager.getLogger(HwmfBitmapDib.class);
private static final int BMP_HEADER_SIZE = 14;
@ -243,7 +246,8 @@ public class HwmfBitmapDib implements GenericRecord {
// The size and format of this data is determined by information in the DIBHeaderInfo field. If
// it is a BitmapCoreHeader, the size in bytes MUST be calculated as follows:
int bodySize = ((((headerWidth * headerPlanes * headerBitCount.flag + 31) & ~31) / 8) * Math.abs(headerHeight));
int bodySize = ((((headerWidth * headerPlanes *
(headerBitCount == null ? 0 : headerBitCount.flag) + 31) & ~31) / 8) * Math.abs(headerHeight));
// This formula SHOULD also be used to calculate the size of aData when DIBHeaderInfo is a
// BitmapInfoHeader Object, using values from that object, but only if its Compression value is
@ -348,6 +352,10 @@ public class HwmfBitmapDib implements GenericRecord {
}
protected int readColors(LittleEndianInputStream leis) throws IOException {
if (headerBitCount == null) {
return 0;
}
switch (headerBitCount) {
default:
case BI_BITCOUNT_0:
@ -527,6 +535,13 @@ public class HwmfBitmapDib implements GenericRecord {
return new BufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB);
}
if (headerHeight > MAX_HEIGHT_WIDTH || headerWidth > MAX_HEIGHT_WIDTH) {
throw new RecordFormatException("The width or height specified in the header exceed the current "
+ "limit. Height: " + headerHeight + ", width: " + headerWidth +
", Max width/height: " + MAX_HEIGHT_WIDTH +
". Limits can be adjusted via 'HwmfBitmapDib.setMaxHeightWidth'");
}
BufferedImage bi = new BufferedImage(headerWidth, headerHeight, BufferedImage.TYPE_INT_ARGB);
Graphics2D g = bi.createGraphics();
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
@ -554,4 +569,21 @@ public class HwmfBitmapDib implements GenericRecord {
g.dispose();
return bi;
}
/**
* Adjust limit to prevent broken images from exceeding available
* memory when being drawn.
*
* @param length the max number of pixel of width/height to allow for images
*/
public static void setMaxHeightWidth(int length) {
MAX_HEIGHT_WIDTH = length;
}
/**
* @return the max number of pixel of width/height to allow for images
*/
public static int getMaxHeightWidth() {
return MAX_HEIGHT_WIDTH;
}
}

View File

@ -23,6 +23,8 @@ import java.util.LinkedHashMap;
import java.util.Map;
import java.util.function.Supplier;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.poi.common.usermodel.GenericRecord;
import org.apache.poi.hwmf.draw.HwmfGraphics;
import org.apache.poi.util.GenericRecordJsonWriter;
@ -37,6 +39,8 @@ import org.apache.poi.util.LittleEndianInputStream;
*/
@SuppressWarnings("WeakerAccess")
public class HwmfEscape implements HwmfRecord {
private static final Logger log = LogManager.getLogger(HwmfEscape.class);
private static final int MAX_OBJECT_SIZE = 0xFFFF;
public enum EscapeFunction {
@ -307,7 +311,9 @@ public class HwmfEscape implements HwmfRecord {
// A 32-bit unsigned integer that identifies the type of comment in this record.
// This value MUST be 0x00000001.
commentType = leis.readInt();
assert(commentType == 0x00000001);
if (commentType != 0x00000001) {
HwmfEscape.log.atWarn().log("Unexpected comment-type: {}", commentType);
}
// A 32-bit unsigned integer that specifies EMF metafile interoperability. This SHOULD be 0x00010000.
version = leis.readInt();

View File

@ -511,8 +511,18 @@ public class HwmfMisc {
@Override
public int init(LittleEndianInputStream leis, long recordSize, int recordFunction) throws IOException {
style = HwmfBrushStyle.valueOf(leis.readUShort());
colorUsage = ColorUsage.valueOf(leis.readUShort());
int brushStyle = leis.readUShort();
style = HwmfBrushStyle.valueOf(brushStyle);
if (style == null) {
throw new IllegalArgumentException("Could not read brush-style " + brushStyle);
}
int colorUsageEnum = leis.readUShort();
colorUsage = ColorUsage.valueOf(colorUsageEnum);
if (colorUsage == null) {
throw new IllegalArgumentException("Could not read color-usage " + colorUsage);
}
int size = 2*LittleEndianConsts.SHORT_SIZE;
switch (style) {
case BS_SOLID:

View File

@ -237,9 +237,8 @@ public final class TestHMEFMessage {
static void assertContents(String filename, byte[] actual) throws IOException {
try (InputStream stream = _samples.openResourceAsStream("quick-contents/" + filename)) {
byte[] expected = IOUtils.toByteArray(stream);
assertArrayEquals(expected, actual);
assertArrayEquals(expected, actual, "Data comparison failed for " + filename);
}
}
}

View File

@ -37,6 +37,7 @@ public class TestPPTXMLDump extends BaseTestPPTIterating {
LOCAL_EXCLUDED.add("clusterfuzz-testcase-minimized-POIHSLFFuzzer-6360479850954752.ppt");
LOCAL_EXCLUDED.add("ppt_with_png_encrypted.ppt");
LOCAL_EXCLUDED.add("clusterfuzz-testcase-minimized-POIHSLFFuzzer-6614960949821440.ppt");
LOCAL_EXCLUDED.add("60f557c0a46bcb0068b1c3e15589dac383307bc8.ppt");
}
@Test

View File

@ -32,6 +32,7 @@ public class TestSlideIdListing extends BaseTestPPTIterating {
static {
LOCAL_EXCLUDED.add("clusterfuzz-testcase-minimized-POIHSLFFuzzer-5306877435838464.ppt");
LOCAL_EXCLUDED.add("clusterfuzz-testcase-minimized-POIHSLFFuzzer-6360479850954752.ppt");
LOCAL_EXCLUDED.add("clusterfuzz-testcase-minimized-POIHSLFFuzzer-6028723156746240.ppt");
}
@Test

View File

@ -39,6 +39,7 @@ public class TestSlideShowDumper extends BaseTestPPTIterating {
FAILING.add("41384.ppt");
FAILING.add("bug56240.ppt");
FAILING.add("clusterfuzz-testcase-minimized-POIHSLFFuzzer-6360479850954752.ppt");
FAILING.add("60f557c0a46bcb0068b1c3e15589dac383307bc8.ppt");
}
static final Set<String> LOCAL_EXCLUDED = new HashSet<>();

View File

@ -25,12 +25,14 @@ import java.util.Set;
import org.apache.poi.EmptyFileException;
import org.apache.poi.hslf.HSLFTestDataSamples;
import org.apache.poi.util.RecordFormatException;
import org.junit.jupiter.api.Test;
public class TestSlideShowRecordDumper extends BaseTestPPTIterating {
static final Set<String> LOCAL_EXCLUDED = new HashSet<>();
static {
LOCAL_EXCLUDED.add("clusterfuzz-testcase-minimized-POIHSLFFuzzer-6360479850954752.ppt");
LOCAL_EXCLUDED.add("clusterfuzz-testcase-minimized-POIHSLFFuzzer-6028723156746240.ppt");
}
@Test
@ -58,7 +60,7 @@ public class TestSlideShowRecordDumper extends BaseTestPPTIterating {
void runOneFile(File pFile) throws Exception {
try {
SlideShowRecordDumper.main(new String[]{pFile.getAbsolutePath()});
} catch (IllegalStateException e) {
} catch (IllegalStateException | RecordFormatException e) {
if (!LOCAL_EXCLUDED.contains(pFile.getName())) {
throw e;
}

View File

@ -24,12 +24,14 @@ import java.util.HashSet;
import java.util.Set;
import org.apache.poi.EmptyFileException;
import org.apache.poi.util.RecordFormatException;
import org.junit.jupiter.api.Test;
public class TestUserEditAndPersistListing extends BaseTestPPTIterating {
static final Set<String> LOCAL_EXCLUDED = new HashSet<>();
static {
LOCAL_EXCLUDED.add("clusterfuzz-testcase-minimized-POIHSLFFuzzer-6360479850954752.ppt");
LOCAL_EXCLUDED.add("clusterfuzz-testcase-minimized-POIHSLFFuzzer-6028723156746240.ppt");
}
@Test
@ -42,7 +44,7 @@ public class TestUserEditAndPersistListing extends BaseTestPPTIterating {
void runOneFile(File pFile) throws Exception {
try {
UserEditAndPersistListing.main(new String[]{pFile.getAbsolutePath()});
} catch (IllegalStateException e) {
} catch (IllegalStateException | RecordFormatException e) {
if (!LOCAL_EXCLUDED.contains(pFile.getName())) {
throw e;
}

View File

@ -19,8 +19,10 @@ package org.apache.poi.hwmf;
import static org.apache.poi.POITestCase.assertContains;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertInstanceOf;
import static org.junit.jupiter.api.Assertions.assertThrows;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
@ -35,6 +37,7 @@ import org.apache.poi.hwmf.record.HwmfRecord;
import org.apache.poi.hwmf.record.HwmfRecordType;
import org.apache.poi.hwmf.record.HwmfText;
import org.apache.poi.hwmf.usermodel.HwmfPicture;
import org.apache.poi.util.IOUtils;
import org.apache.poi.util.LocaleUtil;
import org.apache.poi.util.RecordFormatException;
import org.junit.jupiter.api.Disabled;
@ -42,6 +45,7 @@ import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.CsvSource;
@SuppressWarnings("UnnecessaryUnicodeEscape")
public class TestHwmfParsing {
private static final POIDataSamples samples = POIDataSamples.getSlideShowInstance();
@ -54,7 +58,8 @@ public class TestHwmfParsing {
@CsvSource({
"santa.wmf, 581",
/* Bug 65063 */
"empty-polygon-close.wmf, 272"
"empty-polygon-close.wmf, 272",
"file-45.wmf, 1315"
})
void parse(String file, int recordCnt) throws IOException {
try (InputStream fis = samples.openResourceAsStream(file)) {
@ -71,6 +76,20 @@ public class TestHwmfParsing {
}
}
@Test
void testInvalid() throws Exception {
try (InputStream is = samples.openResourceAsStream("santa.wmf")) {
byte[] bytes = IOUtils.toByteArray(is);
// simulate an invalid commentType, it should be logged and ignored
bytes[34] = (byte)255;
bytes[35] = (byte)255;
HwmfPicture wmf = new HwmfPicture(new ByteArrayInputStream(bytes));
List<HwmfRecord> records = wmf.getRecords();
assertEquals(581, records.size());
}
}
@Test
@Disabled("If we decide we can use common crawl file specified, we can turn this back on")
@ -91,6 +110,8 @@ public class TestHwmfParsing {
charset = (font.getCharset().getCharset() == null) ? LocaleUtil.CHARSET_1252 : font.getCharset().getCharset();
}
if (r.getWmfRecordType().equals(HwmfRecordType.extTextOut)) {
assertInstanceOf(HwmfText.WmfExtTextOut.class, r);
HwmfText.WmfExtTextOut textOut = (HwmfText.WmfExtTextOut)r;
sb.append(textOut.getText(charset)).append("\n");
}
@ -103,7 +124,7 @@ public class TestHwmfParsing {
@Test
void testShift_JIS() throws Exception {
//this file derives from common crawl: see Bug 60677
HwmfPicture wmf = null;
final HwmfPicture wmf;
try (InputStream fis = samples.openResourceAsStream("60677.wmf")) {
wmf = new HwmfPicture(fis);
}
@ -119,6 +140,8 @@ public class TestHwmfParsing {
charset = (font.getCharset().getCharset() == null) ? LocaleUtil.CHARSET_1252 : font.getCharset().getCharset();
}
if (r.getWmfRecordType().equals(HwmfRecordType.extTextOut)) {
assertInstanceOf(HwmfText.WmfExtTextOut.class, r);
HwmfText.WmfExtTextOut textOut = (HwmfText.WmfExtTextOut)r;
sb.append(textOut.getText(charset)).append("\n");
}
@ -128,11 +151,11 @@ public class TestHwmfParsing {
}
@Test
void testLengths() throws Exception {
void testLengths() {
//both substring and length rely on char, not codepoints.
//This test confirms that the substring calls in HwmfText
//will not truncate even beyond-bmp data.
//The last character (Deseret AY U+1040C) is comprised of 2 utf16 surrogates/codepoints
//The last character (Deseret AY U+1040C) consists of 2 utf16 surrogates/codepoints
String s = "\u666E\u6797\u65AF\uD801\uDC0C";
Charset utf16LE = StandardCharsets.UTF_16LE;
byte[] bytes = s.getBytes(utf16LE);

View File

@ -61,7 +61,8 @@ public class TestWordToConverterSuite {
"clusterfuzz-testcase-minimized-POIHWPFFuzzer-4947285593948160.doc",
"clusterfuzz-testcase-minimized-POIHWPFFuzzer-5440721166139392.doc",
"clusterfuzz-testcase-minimized-POIHWPFFuzzer-5050208641482752.doc",
"clusterfuzz-testcase-minimized-POIHWPFFuzzer-6610789829836800.doc"
"clusterfuzz-testcase-minimized-POIHWPFFuzzer-6610789829836800.doc",
"clusterfuzz-testcase-minimized-POIHWPFFuzzer-5832867957309440.doc"
);
public static Stream<Arguments> files() {

View File

@ -54,7 +54,8 @@ public class TestWordToTextConverter {
"clusterfuzz-testcase-minimized-POIHWPFFuzzer-4947285593948160.doc",
"clusterfuzz-testcase-minimized-POIHWPFFuzzer-5440721166139392.doc",
"clusterfuzz-testcase-minimized-POIHWPFFuzzer-5050208641482752.doc",
"clusterfuzz-testcase-minimized-POIHWPFFuzzer-6610789829836800.doc"
"clusterfuzz-testcase-minimized-POIHWPFFuzzer-6610789829836800.doc",
"clusterfuzz-testcase-minimized-POIHWPFFuzzer-5832867957309440.doc"
);
/**

View File

@ -124,7 +124,7 @@ jar {
// 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, compileTest9 ]) {
destinationDirectory = file("../build/dist/maven/${project.archivesBaseName}-tests")
destinationDirectory = file("../build/dist/maven/${base.archivesName.get()}-tests")
setArchiveClassifier 'tests'
// ignore second module-info.class from main
@ -138,11 +138,11 @@ task testJar(type: Jar, dependsOn: [ testClasses, compileTest9 ]) {
}
javadoc {
dependsOn configurations.javadocs.dependencies.collect{ ':' + it.dependencyProject.name + ':compileJava' }
dependsOn configurations.javadocs.dependencies.collect{ ':' + project.project(it.path).name + ':compileJava' }
doFirst {
options {
classpath += files(configurations.javadocs.dependencies.collect{ it.dependencyProject.sourceSets.main.output.classesDirs })
classpath += files(configurations.javadocs.dependencies.collect{ project.project(it.path).sourceSets.main.output.classesDirs })
}
}
}

View File

@ -473,6 +473,7 @@ public abstract class POIDocument implements Closeable {
* to a new POIFSFileSystem
*
* @param newDirectory the new directory
* @throws IOException if accessing the file-system fails.
*/
@Internal
protected void replaceDirectory(DirectoryNode newDirectory) throws IOException {

View File

@ -118,7 +118,7 @@ public final class EscherArrayProperty extends EscherComplexProperty implements
private void rewriteArray(int numberOfElements, boolean copyToNewLen) {
int expectedArraySize = numberOfElements * getActualSizeOfElements(getSizeOfElements()) + FIXED_SIZE;
resizeComplexData(expectedArraySize, copyToNewLen ? expectedArraySize : getComplexData().length);
resizeComplexData(expectedArraySize, copyToNewLen ? expectedArraySize : getComplexSize());
}
public int getNumberOfElementsInMemory() {
@ -181,7 +181,7 @@ public final class EscherArrayProperty extends EscherComplexProperty implements
// the code here seems to depend on complexData already being
// sized correctly via the constructor
int cdLen = getComplexData().length;
int cdLen = getComplexSize();
int arraySize = getActualSizeOfElements(sizeOfElements) * numElements;
if (arraySize == cdLen) {
// The stored data size in the simple block excludes the header size
@ -190,7 +190,7 @@ public final class EscherArrayProperty extends EscherComplexProperty implements
}
setComplexData(data, offset);
}
return getComplexData().length;
return getComplexSize();
}
/**
@ -202,7 +202,7 @@ public final class EscherArrayProperty extends EscherComplexProperty implements
@Override
public int serializeSimplePart(byte[] data, int pos) {
LittleEndian.putShort(data, pos, getId());
int recordSize = getComplexData().length;
int recordSize = getComplexSize();
if (!sizeIncludesHeaderSize) {
recordSize -= 6;
}

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