...
 
Commits (12)
    https://gitcode.net/int/poi/-/commit/1c1cff43570dd5e2ab54f68ddade9f034530a2e3 gradle 8.2.1 2023-08-17T08:48:31+00:00 PJ Fanning fanningpj@apache.org git-svn-id: <a href="https://svn.apache.org/repos/asf/poi/trunk@1911737" rel="nofollow noreferrer noopener" target="_blank">https://svn.apache.org/repos/asf/poi/trunk@1911737</a> 13f79535-47bb-0310-9956-ffa450edef68 https://gitcode.net/int/poi/-/commit/1bdfdcc7934d3c00b5f1a846ede0caffc66ef66a [bug-66988] Fully replace content of XWPFTableCell on setText. Thanks to Anto... 2023-08-18T08:48:18+00:00 PJ Fanning fanningpj@apache.org [bug-66988] Fully replace content of XWPFTableCell on setText. Thanks to Anton Oellerer. This closes #503 git-svn-id: <a href="https://svn.apache.org/repos/asf/poi/trunk@1911749" rel="nofollow noreferrer noopener" target="_blank">https://svn.apache.org/repos/asf/poi/trunk@1911749</a> 13f79535-47bb-0310-9956-ffa450edef68 https://gitcode.net/int/poi/-/commit/f07be05484209e2de35817826db26473786b9c58 gradle 8.3 2023-08-18T09:43:49+00:00 PJ Fanning fanningpj@apache.org git-svn-id: <a href="https://svn.apache.org/repos/asf/poi/trunk@1911751" rel="nofollow noreferrer noopener" target="_blank">https://svn.apache.org/repos/asf/poi/trunk@1911751</a> 13f79535-47bb-0310-9956-ffa450edef68 https://gitcode.net/int/poi/-/commit/c3f42018315b3cdecb1b9e44fdff93124f8f1295 change test broken by bug-66988 change 2023-08-18T13:08:13+00:00 PJ Fanning fanningpj@apache.org git-svn-id: <a href="https://svn.apache.org/repos/asf/poi/trunk@1911755" rel="nofollow noreferrer noopener" target="_blank">https://svn.apache.org/repos/asf/poi/trunk@1911755</a> 13f79535-47bb-0310-9956-ffa450edef68 https://gitcode.net/int/poi/-/commit/5a4193b14d839c29fef76d80573be2f0d7c516ff batik 1.17 2023-08-21T15:16:27+00:00 PJ Fanning fanningpj@apache.org git-svn-id: <a href="https://svn.apache.org/repos/asf/poi/trunk@1911828" rel="nofollow noreferrer noopener" target="_blank">https://svn.apache.org/repos/asf/poi/trunk@1911828</a> 13f79535-47bb-0310-9956-ffa450edef68 https://gitcode.net/int/poi/-/commit/1b88529d072a9d4462c445a9953b898cb37c6913 Bug 66425: Avoid a NullPointerException found via oss-fuzz 2023-08-22T14:22:06+00:00 Dominik Stadler centic@apache.org We try to avoid throwing NullPointerException, but it was possible to trigger one here with a specially crafted input-file Should fix <a href="https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=61644" rel="nofollow noreferrer noopener" target="_blank">https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=61644</a> git-svn-id: <a href="https://svn.apache.org/repos/asf/poi/trunk@1911842" rel="nofollow noreferrer noopener" target="_blank">https://svn.apache.org/repos/asf/poi/trunk@1911842</a> 13f79535-47bb-0310-9956-ffa450edef68 https://gitcode.net/int/poi/-/commit/fd29772be6b3410629eff5bc376b489852d7ee6d Bug 66425: Avoid a ClassCastException found via oss-fuzz 2023-08-23T08:26:27+00:00 Dominik Stadler centic@apache.org We try to avoid throwing ClassCastException, but it was possible to trigger one here with a specially crafted input-file Should fix <a href="https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=61578" rel="nofollow noreferrer noopener" target="_blank">https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=61578</a> git-svn-id: <a href="https://svn.apache.org/repos/asf/poi/trunk@1911860" rel="nofollow noreferrer noopener" target="_blank">https://svn.apache.org/repos/asf/poi/trunk@1911860</a> 13f79535-47bb-0310-9956-ffa450edef68 https://gitcode.net/int/poi/-/commit/0654bf9d87da525765eaba7a8e7242a05c48ee02 Bug 66425: Avoid a NullPointerException found via oss-fuzz 2023-08-23T09:30:00+00:00 Dominik Stadler centic@apache.org We try to avoid throwing NullPointerException, but it was possible to trigger one here with a specially crafted input-file Should fix <a href="https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=61520" rel="nofollow noreferrer noopener" target="_blank">https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=61520</a> git-svn-id: <a href="https://svn.apache.org/repos/asf/poi/trunk@1911863" rel="nofollow noreferrer noopener" target="_blank">https://svn.apache.org/repos/asf/poi/trunk@1911863</a> 13f79535-47bb-0310-9956-ffa450edef68 https://gitcode.net/int/poi/-/commit/e4ba9822cc4fe70de83aad413b2b21eef551661f Bug 66425: Avoid a NullPointerException found via oss-fuzz 2023-08-23T10:00:16+00:00 Dominik Stadler centic@apache.org ArrayIndexOutOfBoundsException has different message depending on JDK git-svn-id: <a href="https://svn.apache.org/repos/asf/poi/trunk@1911864" rel="nofollow noreferrer noopener" target="_blank">https://svn.apache.org/repos/asf/poi/trunk@1911864</a> 13f79535-47bb-0310-9956-ffa450edef68 https://gitcode.net/int/poi/-/commit/cdb2ba13989badf60d88c75daf69c94ae6ac2e13 Bug 66425: Avoid a NullPointerException found via oss-fuzz 2023-08-24T08:48:45+00:00 Dominik Stadler centic@apache.org We try to avoid throwing NullPointerException, but it was possible to trigger one here with a specially crafted input-file Should fix <a href="https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=61441" rel="nofollow noreferrer noopener" target="_blank">https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=61441</a> git-svn-id: <a href="https://svn.apache.org/repos/asf/poi/trunk@1911890" rel="nofollow noreferrer noopener" target="_blank">https://svn.apache.org/repos/asf/poi/trunk@1911890</a> 13f79535-47bb-0310-9956-ffa450edef68 https://gitcode.net/int/poi/-/commit/29990737157a4af2e2462252a44db665671e2a6e Apply some IDE suggestions, add tests, set unit-test to isolated 2023-08-24T08:53:01+00:00 Dominik Stadler centic@apache.org Without Isolation, one test did change static settings and thus could cause flaky tests git-svn-id: <a href="https://svn.apache.org/repos/asf/poi/trunk@1911891" rel="nofollow noreferrer noopener" target="_blank">https://svn.apache.org/repos/asf/poi/trunk@1911891</a> 13f79535-47bb-0310-9956-ffa450edef68 https://gitcode.net/int/poi/-/commit/9c0c9ac8e40b46da282ccaf18a7fbe202be2dfa0 slf4j 2.0.9 2023-09-04T14:57:03+00:00 PJ Fanning fanningpj@apache.org git-svn-id: <a href="https://svn.apache.org/repos/asf/poi/trunk@1912088" rel="nofollow noreferrer noopener" target="_blank">https://svn.apache.org/repos/asf/poi/trunk@1912088</a> 13f79535-47bb-0310-9956-ffa450edef68
......@@ -67,7 +67,7 @@ configurations {
dependencies {
antLibs("org.junit.jupiter:junit-jupiter:5.10.0")
antLibs("org.apache.ant:ant-junitlauncher:1.10.12")
antLibs("org.apache.ant:ant-junitlauncher:1.10.14")
}
ant.taskdef(name: "junit",
......@@ -76,7 +76,7 @@ ant.taskdef(name: "junit",
wrapper {
gradleVersion = '8.1.1'
gradleVersion = '8.3'
}
task adjustWrapperPropertiesFile {
......@@ -127,9 +127,9 @@ subprojects {
mockitoVersion = '4.11.0'
hamcrestVersion = '2.2'
xmlbeansVersion = '5.1.1'
batikVersion = '1.16'
graphics2dVersion = '0.43'
pdfboxVersion = '2.0.29'
batikVersion = '1.17'
graphics2dVersion = '3.0.0'
pdfboxVersion = '3.0.0'
saxonVersion = '11.5'
apiGuardianVersion = '1.1.2'
......@@ -151,7 +151,7 @@ subprojects {
all {
resolutionStrategy {
force "commons-io:commons-io:${commonsIoVersion}"
force 'org.slf4j:slf4j-api:2.0.7'
force 'org.slf4j:slf4j-api:2.0.9'
force 'com.fasterxml.woodstox:woodstox-core:6.5.1'
}
}
......
......@@ -306,28 +306,28 @@ under the License.
<!-- svg/batik/pdf libs - not part of the distribution - move batik to its own directory because of JPMS module-path issues -->
<dependency prefix="svg.xml-apis-ext" artifact="xml-apis:xml-apis-ext:1.3.04" usage="ooxml-batik"/>
<dependency prefix="svg.xmlgraphics-commons" artifact="org.apache.xmlgraphics:xmlgraphics-commons:2.7" usage="ooxml-batik"/>
<dependency prefix="svg.batik-anim" artifact="org.apache.xmlgraphics:batik-anim:1.16" usage="ooxml-batik"/>
<dependency prefix="svg.batik-awt-util" artifact="org.apache.xmlgraphics:batik-awt-util:1.16" usage="ooxml-batik"/>
<dependency prefix="svg.batik-bridge" artifact="org.apache.xmlgraphics:batik-bridge:1.16" usage="ooxml-batik"/>
<dependency prefix="svg.batik-codec" artifact="org.apache.xmlgraphics:batik-codec:1.16" usage="ooxml-batik"/>
<dependency prefix="svg.batik-constants" artifact="org.apache.xmlgraphics:batik-constants:1.16" usage="ooxml-batik"/>
<dependency prefix="svg.batik-css" artifact="org.apache.xmlgraphics:batik-css:1.16" usage="ooxml-batik"/>
<dependency prefix="svg.batik-dom" artifact="org.apache.xmlgraphics:batik-dom:1.16" usage="ooxml-batik"/>
<dependency prefix="svg.batik-ext" artifact="org.apache.xmlgraphics:batik-ext:1.16" usage="ooxml-batik"/>
<dependency prefix="svg.batik-gvt" artifact="org.apache.xmlgraphics:batik-gvt:1.16" usage="ooxml-batik"/>
<dependency prefix="svg.batik-i18n" artifact="org.apache.xmlgraphics:batik-i18n:1.16" usage="ooxml-batik"/>
<dependency prefix="svg.batik-parser" artifact="org.apache.xmlgraphics:batik-parser:1.16" usage="ooxml-batik"/>
<dependency prefix="svg.batik-script" artifact="org.apache.xmlgraphics:batik-script:1.16" usage="ooxml-batik"/>
<dependency prefix="svg.batik-shared-resources" artifact="org.apache.xmlgraphics:batik-shared-resources:1.16" usage="ooxml-batik"/>
<dependency prefix="svg.batik-svg-dom" artifact="org.apache.xmlgraphics:batik-svg-dom:1.16" usage="ooxml-batik"/>
<dependency prefix="svg.batik-svggen" artifact="org.apache.xmlgraphics:batik-svggen:1.16" usage="ooxml-batik"/>
<dependency prefix="svg.batik-svgrasterizer" artifact="org.apache.xmlgraphics:batik-svgrasterizer:1.16" usage="ooxml-batik"/>
<dependency prefix="svg.batik-transcoder" artifact="org.apache.xmlgraphics:batik-transcoder:1.16" usage="ooxml-batik"/>
<dependency prefix="svg.batik-util" artifact="org.apache.xmlgraphics:batik-util:1.16" usage="ooxml-batik"/>
<dependency prefix="svg.batik-xml" artifact="org.apache.xmlgraphics:batik-xml:1.16" usage="ooxml-batik"/>
<dependency prefix="pdf.pdfbox" artifact="org.apache.pdfbox:pdfbox:2.0.29" usage="ooxml-provided"/>
<dependency prefix="pdf.fontbox" artifact="org.apache.pdfbox:fontbox:2.0.29" usage="ooxml-provided"/>
<dependency prefix="pdf.graphics2d" artifact="de.rototor.pdfbox:graphics2d:0.43" usage="ooxml-provided"/>
<dependency prefix="svg.batik-anim" artifact="org.apache.xmlgraphics:batik-anim:1.17" usage="ooxml-batik"/>
<dependency prefix="svg.batik-awt-util" artifact="org.apache.xmlgraphics:batik-awt-util:1.17" usage="ooxml-batik"/>
<dependency prefix="svg.batik-bridge" artifact="org.apache.xmlgraphics:batik-bridge:1.17" usage="ooxml-batik"/>
<dependency prefix="svg.batik-codec" artifact="org.apache.xmlgraphics:batik-codec:1.17" usage="ooxml-batik"/>
<dependency prefix="svg.batik-constants" artifact="org.apache.xmlgraphics:batik-constants:1.17" usage="ooxml-batik"/>
<dependency prefix="svg.batik-css" artifact="org.apache.xmlgraphics:batik-css:1.17" usage="ooxml-batik"/>
<dependency prefix="svg.batik-dom" artifact="org.apache.xmlgraphics:batik-dom:1.17" usage="ooxml-batik"/>
<dependency prefix="svg.batik-ext" artifact="org.apache.xmlgraphics:batik-ext:1.17" usage="ooxml-batik"/>
<dependency prefix="svg.batik-gvt" artifact="org.apache.xmlgraphics:batik-gvt:1.17" usage="ooxml-batik"/>
<dependency prefix="svg.batik-i18n" artifact="org.apache.xmlgraphics:batik-i18n:1.17" usage="ooxml-batik"/>
<dependency prefix="svg.batik-parser" artifact="org.apache.xmlgraphics:batik-parser:1.17" usage="ooxml-batik"/>
<dependency prefix="svg.batik-script" artifact="org.apache.xmlgraphics:batik-script:1.17" usage="ooxml-batik"/>
<dependency prefix="svg.batik-shared-resources" artifact="org.apache.xmlgraphics:batik-shared-resources:1.17" usage="ooxml-batik"/>
<dependency prefix="svg.batik-svg-dom" artifact="org.apache.xmlgraphics:batik-svg-dom:1.17" usage="ooxml-batik"/>
<dependency prefix="svg.batik-svggen" artifact="org.apache.xmlgraphics:batik-svggen:1.17" usage="ooxml-batik"/>
<dependency prefix="svg.batik-svgrasterizer" artifact="org.apache.xmlgraphics:batik-svgrasterizer:1.17" usage="ooxml-batik"/>
<dependency prefix="svg.batik-transcoder" artifact="org.apache.xmlgraphics:batik-transcoder:1.17" usage="ooxml-batik"/>
<dependency prefix="svg.batik-util" artifact="org.apache.xmlgraphics:batik-util:1.17" usage="ooxml-batik"/>
<dependency prefix="svg.batik-xml" artifact="org.apache.xmlgraphics:batik-xml:1.17" usage="ooxml-batik"/>
<dependency prefix="pdf.pdfbox" artifact="org.apache.pdfbox:pdfbox:3.0.0" usage="ooxml-provided"/>
<dependency prefix="pdf.fontbox" artifact="org.apache.pdfbox:fontbox:3.0.0" usage="ooxml-provided"/>
<dependency prefix="pdf.graphics2d" artifact="de.rototor.pdfbox:graphics2d:3.0.0" usage="ooxml-provided"/>
<!-- jars in the ooxml-lib directory, see the fetch-ooxml-jars target-->
<dependency prefix="ooxml.curvesapi" artifact="com.github.virtuald:curvesapi:1.08" usage="ooxml"/>
......@@ -338,7 +338,7 @@ under the License.
<dependency prefix="ooxml.test.reflections" artifact="org.reflections:reflections:0.10.2" usage="ooxml-tests"/>
<dependency prefix="ooxml.test.guava" artifact="com.google.guava:guava:32.1.1-jre" usage="ooxml-tests"/>
<dependency prefix="ooxml.test.javassist" artifact="org.javassist:javassist:3.27.0-GA" usage="ooxml-tests"/>
<dependency prefix="ooxml.test.slf4j-api" artifact="org.slf4j:slf4j-api:2.0.7" usage="ooxml-tests"/>
<dependency prefix="ooxml.test.slf4j-api" artifact="org.slf4j:slf4j-api:2.0.9" usage="ooxml-tests"/>
<dependency prefix="ooxml.test.opczip" artifact="com.github.rzymek:opczip:1.2.0" usage="ooxml-tests"/>
<!-- coverage libs -->
......
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
......@@ -83,7 +83,8 @@ done
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
......@@ -115,7 +116,7 @@ esac
# Loop in case we encounter an error.
for attempt in 1 2 3; do
if [ ! -e "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" ]; then
if ! curl -s -S --retry 3 -L -o "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" "https://raw.githubusercontent.com/gradle/gradle/v8.2.1/gradle/wrapper/gradle-wrapper.jar"; then
if ! curl -s -S --retry 3 -L -o "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" "https://raw.githubusercontent.com/gradle/gradle/v8.3/gradle/wrapper/gradle-wrapper.jar"; then
rm -f "$APP_HOME/gradle/wrapper/gradle-wrapper.jar"
# Pause for a bit before looping in case the server throttled us.
sleep 5
......@@ -143,10 +144,13 @@ location of your Java installation."
fi
else
JAVACMD=java
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
if ! command -v java >/dev/null 2>&1
then
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
fi
# Increase the maximum file descriptors if we can.
......
......@@ -31,7 +31,7 @@ sourceSets {
}
dependencies {
api 'org.apache.ant:ant:1.10.12'
api 'org.apache.ant:ant:1.10.14'
api project(':poi-ooxml')
compileOnly project(path: ':poi-ooxml', configuration: 'archives')
......@@ -43,7 +43,7 @@ dependencies {
}
testImplementation 'com.google.guava:guava:32.1.1-jre'
testImplementation "org.apache.logging.log4j:log4j-slf4j2-impl:${log4jVersion}"
testImplementation 'org.slf4j:slf4j-simple:2.0.7'
testImplementation 'org.slf4j:slf4j-simple:2.0.9'
testRuntimeOnly "org.apiguardian:apiguardian-api:${apiGuardianVersion}"
}
......
......@@ -39,7 +39,7 @@ sourceSets {
}
dependencies {
testImplementation 'org.apache.ant:ant:1.10.12'
testImplementation 'org.apache.ant:ant:1.10.14'
testImplementation 'org.apache.commons:commons-collections4:4.4'
testImplementation 'com.google.guava:guava:32.1.1-jre'
......@@ -76,7 +76,7 @@ dependencies {
}
testImplementation project(path: ':poi-ooxml-lite-agent', configuration: 'archives')
testImplementation "org.apache.logging.log4j:log4j-slf4j2-impl:${log4jVersion}"
testImplementation 'org.slf4j:slf4j-simple:2.0.7'
testImplementation 'org.slf4j:slf4j-simple:2.0.9'
testRuntimeOnly "org.apiguardian:apiguardian-api:${apiGuardianVersion}"
}
......
......@@ -217,6 +217,8 @@ public class XSSFFileHandler extends SpreadsheetHandler {
}
handleExtracting(file);
handleAdditional(file);
}
@Test
......
......@@ -125,7 +125,7 @@ dependencies {
// prevent slf4j warnings coming from xmlsec -> slf4j-api 1.7.x dependency
// see https://logging.apache.org/log4j/2.x/log4j-slf4j-impl/
testImplementation "org.apache.logging.log4j:log4j-slf4j2-impl:${log4jVersion}"
testImplementation 'org.slf4j:slf4j-simple:2.0.7'
testImplementation 'org.slf4j:slf4j-simple:2.0.9'
broken("org.apache.xmlgraphics:batik-script:${batikVersion}"){
exclude group: 'xalan', module: 'xalan'
......
......@@ -44,15 +44,10 @@ public final class PackageRelationshipCollection implements Iterable<PackageRela
*/
private final TreeMap<String, PackageRelationship> relationshipsByID = new TreeMap<>();
/**
* Package relationships ordered by type.
*/
private final TreeMap<String, PackageRelationship> relationshipsByType = new TreeMap<>();
/**
* A lookup of internal relationships to avoid
*/
private HashMap<String, PackageRelationship> internalRelationshipsByTargetName = new HashMap<>();
private final HashMap<String, PackageRelationship> internalRelationshipsByTargetName = new HashMap<>();
/**
......@@ -195,7 +190,6 @@ public final class PackageRelationshipCollection implements Iterable<PackageRela
(relPart == null ? "<null>" : relPart.getId()) + " for relationship: " + relPart);
}
relationshipsByID.put(relPart.getId(), relPart);
relationshipsByType.put(relPart.getRelationshipType(), relPart);
}
/**
......@@ -214,8 +208,8 @@ public final class PackageRelationshipCollection implements Iterable<PackageRela
*/
public PackageRelationship addRelationship(URI targetUri,
TargetMode targetMode, String relationshipType, String id) {
if (id == null || id.length() == 0) {
// Generate a unique ID is id parameter is null.
if (id == null || id.isEmpty()) {
// Generate a unique ID if id parameter is null.
if (nextRelationshipId == -1) {
nextRelationshipId = size() + 1;
}
......@@ -245,7 +239,6 @@ public final class PackageRelationshipCollection implements Iterable<PackageRela
PackageRelationship rel = relationshipsByID.get(id);
if (rel != null) {
relationshipsByID.remove(rel.getId());
relationshipsByType.values().remove(rel);
internalRelationshipsByTargetName.values().remove(rel);
}
}
......@@ -277,6 +270,11 @@ public final class PackageRelationshipCollection implements Iterable<PackageRela
* @return The package relationship identified by the specified id.
*/
public PackageRelationship getRelationshipByID(String id) {
if (id == null) {
throw new IllegalArgumentException("Cannot read relationship, provided ID is empty: " + id +
", having relationships: " + relationshipsByID.keySet());
}
return relationshipsByID.get(id);
}
......@@ -418,7 +416,6 @@ public final class PackageRelationshipCollection implements Iterable<PackageRela
*/
public void clear() {
relationshipsByID.clear();
relationshipsByType.clear();
internalRelationshipsByTargetName.clear();
}
......
......@@ -57,8 +57,10 @@ public abstract class XWPFAbstractFootnotesEndnotes extends POIXMLDocumentPart {
public XWPFAbstractFootnoteEndnote getFootnoteById(int id) {
for (XWPFAbstractFootnoteEndnote note : listFootnote) {
if (note.getCTFtnEdn().getId().intValue() == id)
if (note.getCTFtnEdn().getId() != null &&
note.getCTFtnEdn().getId().intValue() == id) {
return note;
}
}
return null;
}
......
......@@ -233,7 +233,7 @@ public class XWPFDocument extends POIXMLDocument implements Document, IBody {
}
}
// Sort out headers and footers
if (doc.getDocument().getBody().getSectPr() != null) {
if (doc.getDocument().getBody() != null && doc.getDocument().getBody().getSectPr() != null) {
headerFooterPolicy = new XWPFHeaderFooterPolicy(this);
}
......
......@@ -421,7 +421,28 @@ public class XWPFTableCell implements IBody, ICell {
return text.toString();
}
/**
* Set the text of the cell to the passed string, replacing previous content. Up until POI 5.2.3, this method appended the text, which is now done
* by {@link XWPFTableCell#appendText(String)}.
*
* @param text The text to replace the cell content with
*/
public void setText(String text) {
XWPFParagraph par = paragraphs.isEmpty() ? addParagraph() : paragraphs.get(0);
while (!par.runsIsEmpty()) {
par.removeRun(0);
}
par.createRun().setText(text);
}
/**
* Append the passed string to the cell content.
* This was the behaviour of {@link XWPFTableCell#setText(String)} before POI 5.2.4
*
* @param text The text to append to the cells content.
* @since POI 5.2.4
*/
public void appendText(String text) {
XWPFParagraph par = paragraphs.isEmpty() ? addParagraph() : paragraphs.get(0);
par.createRun().setText(text);
}
......
......@@ -22,6 +22,7 @@ import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.apache.poi.openxml4j.opc.OPCPackage;
import org.apache.poi.openxml4j.util.ZipSecureFile;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.parallel.Isolated;
import java.io.File;
import java.io.IOException;
......@@ -30,6 +31,7 @@ import java.io.InputStream;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;
@Isolated // changes static values, so other tests should not run at the same time
class TestOPCPackageFileLimit {
@Test
void testWithReducedFileLimit() throws InvalidFormatException {
......
......@@ -67,6 +67,12 @@ public final class TestReadOnlySharedStringsTable {
assertEquals(i1.getString(), rtbl.getItemAt(i).getString());
assertEquals(i1.getString(), rtbl2.getItemAt(i).getString());
}
// verify invalid indices
assertThrows(IllegalStateException.class,
() -> rtbl.getItemAt(stbl.getUniqueCount()));
assertThrows(IndexOutOfBoundsException.class,
() -> rtbl.getItemAt(-1));
}
}
}
......
......@@ -262,8 +262,7 @@ class TestXWPFTableCell {
cell.setText("test text 1");
assertEquals("test text 1", cell.getText());
// currently the text is added, I am not sure if this is expected or not...
cell.setText("test text 2");
cell.appendText("test text 2");
assertEquals("test text 1test text 2", cell.getText());
}
......@@ -284,4 +283,15 @@ class TestXWPFTableCell {
XWPFTableCell readCell = readDoc.getTableArray(0).getRow(0).getCell(0);
assertEquals(0, readCell.getParagraphs().size());
}
@Test
void bug66988() throws IOException {
try (XWPFDocument document = XWPFTestDataSamples.openSampleDocument("Bug66988.docx")) {
XWPFTableCell cell = document.getTableArray(0).getRow(0).getCell(0);
cell.appendText("World");
assertEquals("HelloWorld", cell.getText());
cell.setText("FooBar");
assertEquals("FooBar", cell.getText());
}
}
}
......@@ -404,7 +404,11 @@ public final class HSLFSlideShowImpl extends POIDocument implements Closeable {
return;
}
DocumentEntry entry = (DocumentEntry) getDirectory().getEntry("Pictures");
final Entry en = getDirectory().getEntry("Pictures");
if (!(en instanceof DocumentEntry)) {
throw new IllegalArgumentException("Had unexpected type of entry for name: Pictures: " + en.getClass());
}
DocumentEntry entry = (DocumentEntry) en;
EscherContainerRecord blipStore = getBlipStore();
byte[] pictstream;
try (DocumentInputStream is = getDirectory().createDocumentInputStream(entry)) {
......@@ -1081,17 +1085,17 @@ public final class HSLFSlideShowImpl extends POIDocument implements Closeable {
int count;
@Override
public void write(int b) throws IOException {
public void write(int b) {
count++;
}
@Override
public void write(byte[] b) throws IOException {
public void write(byte[] b) {
count += b.length;
}
@Override
public void write(byte[] b, int off, int len) throws IOException {
public void write(byte[] b, int off, int len) {
count += len;
}
......
......@@ -21,6 +21,7 @@ import org.apache.poi.hslf.HSLFTestDataSamples;
import org.junit.jupiter.api.Test;
import java.io.File;
import java.io.IOException;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
......@@ -31,6 +32,7 @@ public class TestPPTXMLDump extends BaseTestPPTIterating {
static final Set<String> LOCAL_EXCLUDED = new HashSet<>();
static {
LOCAL_EXCLUDED.add("clusterfuzz-testcase-minimized-POIHSLFFuzzer-5306877435838464.ppt");
LOCAL_EXCLUDED.add("clusterfuzz-testcase-minimized-POIHSLFFuzzer-6032591399288832.ppt");
}
@Test
......@@ -49,7 +51,7 @@ public class TestPPTXMLDump extends BaseTestPPTIterating {
void runOneFile(File pFile) throws Exception {
try {
PPTXMLDump.main(new String[]{pFile.getAbsolutePath()});
} catch (IndexOutOfBoundsException e) {
} catch (IndexOutOfBoundsException | IOException e) {
if (!LOCAL_EXCLUDED.contains(pFile.getName())) {
throw e;
}
......
......@@ -44,7 +44,7 @@ dependencies {
api "org.apache.logging.log4j:log4j-api:${log4jVersion}"
testImplementation 'org.reflections:reflections:0.10.2'
testImplementation 'org.apache.ant:ant:1.10.12'
testImplementation 'org.apache.ant:ant:1.10.14'
testImplementation "org.junit.jupiter:junit-jupiter-api:${junitVersion}"
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:${junitVersion}"
......