diff --git a/.github/workflows/test-gradle.yml b/.github/workflows/test-gradle.yml index 3b9034053f3..204e5db9e19 100644 --- a/.github/workflows/test-gradle.yml +++ b/.github/workflows/test-gradle.yml @@ -5,9 +5,9 @@ name: Java CI with Gradle on: push: - branches: [ trunk ] + branches: [ trunk, 5.5.x ] pull_request: - branches: [ trunk ] + branches: [ trunk, 5.5.x ] permissions: {} diff --git a/build.gradle b/build.gradle index 5d728f20b3c..9c905736607 100644 --- a/build.gradle +++ b/build.gradle @@ -89,7 +89,7 @@ allprojects { // apply plugin: 'eclipse' apply plugin: 'idea' - version = '5.5.0' + version = '5.5.1' } /** @@ -107,10 +107,10 @@ subprojects { apply plugin: 'com.adarshr.test-logger' ext { - bouncyCastleVersion = '1.82' - commonsCodecVersion = '1.19.0' + bouncyCastleVersion = '1.83' + commonsCodecVersion = '1.20.0' commonsCompressVersion = '1.28.0' - commonsIoVersion = '2.20.0' + commonsIoVersion = '2.21.0' commonsMathVersion = '3.6.1' junitVersion = '5.13.4' log4jVersion = '2.24.3' @@ -119,7 +119,7 @@ subprojects { xmlbeansVersion = '5.3.0' batikVersion = '1.19' graphics2dVersion = '3.0.5' - pdfboxVersion = '3.0.5' + pdfboxVersion = '3.0.6' saxonVersion = '12.9' xmlSecVersion = '3.0.6' apiGuardianVersion = '1.1.2' @@ -132,7 +132,7 @@ subprojects { JAVA9_OUT = layout.buildDirectory.dir('classes/java9/main/').get().asFile.absolutePath TEST9_SRC = 'src/test/java9' TEST9_OUT = layout.buildDirectory.dir('classes/java9/test/').get().asFile.absolutePath - VERSIONS9 = 'META-INF/versions/9' + VERSIONS9 = '/META-INF/versions/9' NO_SCRATCHPAD = (findProperty("scratchpad.ignore") == "true") SAXON_TEST = (findProperty("saxon.test") == "true") diff --git a/build.xml b/build.xml index b7f4b9730c1..eee7febfaed 100644 --- a/build.xml +++ b/build.xml @@ -42,7 +42,7 @@ under the License. The Apache POI project Ant build. - + diff --git a/jenkins/create_jobs.groovy b/jenkins/create_jobs.groovy index 980fbebdc54..ef90ec6d077 100644 --- a/jenkins/create_jobs.groovy +++ b/jenkins/create_jobs.groovy @@ -1,3 +1,20 @@ +/* ==================================================================== + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +==================================================================== */ + // This script is used as input to the Jenkins Job DSL plugin to create all the build-jobs that // Apache POI uses on the public Jenkins instance at https://ci-builds.apache.org/job/POI/ // diff --git a/osgi/pom.xml b/osgi/pom.xml index da2ed82d604..41592b43b98 100644 --- a/osgi/pom.xml +++ b/osgi/pom.xml @@ -24,12 +24,12 @@ org.apache.poi poi-bundle bundle - 5.5.0 + 5.5.1 Apache POI OSGi bundle UTF-8 - 5.5.0 + 5.5.1 4.14.0 diff --git a/poi-ooxml/src/main/java/org/apache/poi/xssf/streaming/SXSSFRow.java b/poi-ooxml/src/main/java/org/apache/poi/xssf/streaming/SXSSFRow.java index 0e9a2db55f5..91a579032b2 100644 --- a/poi-ooxml/src/main/java/org/apache/poi/xssf/streaming/SXSSFRow.java +++ b/poi-ooxml/src/main/java/org/apache/poi/xssf/streaming/SXSSFRow.java @@ -111,7 +111,7 @@ public void setCollapsed(Boolean collapsed) { * Use this to create new cells within the row and return it. *

* The cell that is returned is a {@link CellType#BLANK}. The type can be changed - * either through calling {@code setCellValue} or {@code setCellType}. + * either through calling {@code setCellValue} or {@code setCellFormula}. * * @param column - the column number this cell represents (zero-based) * @return Cell a high level representation of the created cell. @@ -128,7 +128,7 @@ public SXSSFCell createCell(int column) * Use this to create new cells within the row and return it. *

* The cell that is returned is a {@link CellType#BLANK}. The type can be changed - * either through calling setCellValue or setCellType. + * either through calling setCellValue or setCellFormula. * * @param column - the column number this cell represents (zero-based) * @return Cell a high level representation of the created cell. diff --git a/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFRow.java b/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFRow.java index 5e6bd25c467..0c1b6db4996 100644 --- a/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFRow.java +++ b/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFRow.java @@ -187,7 +187,7 @@ public int hashCode() { * Use this to create new cells within the row and return it. *

* The cell that is returned is a {@link CellType#BLANK}. The type can be changed - * either through calling {@code setCellValue} or {@code setCellType}. + * either through calling {@code setCellValue} or {@code setCellFormula}. *

* @param columnIndex - the column number this cell represents * @return Cell a high level representation of the created cell. diff --git a/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFDocument.java b/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFDocument.java index 56db1b04208..18572dda048 100644 --- a/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFDocument.java +++ b/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFDocument.java @@ -1144,8 +1144,8 @@ public boolean removeBodyElement(int pos) { * copies content of a paragraph to an existing paragraph in the list paragraphs at position pos */ public void setParagraph(XWPFParagraph paragraph, int pos) { - paragraphs.set(pos, paragraph); ctDocument.getBody().setPArray(pos, paragraph.getCTP()); + paragraphs.set(pos, (XWPFParagraph) bodyElements.get(pos)); /* TODO update body element, update xwpf element, verify that * incoming paragraph belongs to this document or if not, XML was * copied properly (namespace-abbreviations, etc.) diff --git a/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFParagraph.java b/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFParagraph.java index d572da627e8..89a681ecf8c 100644 --- a/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFParagraph.java +++ b/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFParagraph.java @@ -1457,6 +1457,9 @@ private CTPBdr getCTPBrd(boolean create) { */ private CTSpacing getCTSpacing(boolean create) { CTPPr pr = getCTPPr(create); + if (pr == null) { + return null; + } CTSpacing ct = pr.getSpacing(); if (create && ct == null) { ct = pr.addNewSpacing(); diff --git a/poi-ooxml/src/test/java/org/apache/poi/xssf/usermodel/TestXSSFSheetShiftRowsAndColumns.java b/poi-ooxml/src/test/java/org/apache/poi/xssf/usermodel/TestXSSFSheetShiftRowsAndColumns.java index e31332027a8..8d09b8a90af 100644 --- a/poi-ooxml/src/test/java/org/apache/poi/xssf/usermodel/TestXSSFSheetShiftRowsAndColumns.java +++ b/poi-ooxml/src/test/java/org/apache/poi/xssf/usermodel/TestXSSFSheetShiftRowsAndColumns.java @@ -71,7 +71,6 @@ void setup() throws IOException { final XSSFRow row = sheet.createRow(nRow); for (int nCol = 0; nCol < numCols; ++nCol) { final XSSFCell cell = row.createCell(nCol); - cell.setCellType(CellType.STRING); cell.setCellValue(String.format(Locale.US, "Row %d col %d", nRow, nCol)); } } diff --git a/poi-ooxml/src/test/java/org/apache/poi/xwpf/usermodel/TestXWPFParagraph.java b/poi-ooxml/src/test/java/org/apache/poi/xwpf/usermodel/TestXWPFParagraph.java index 2aaf6b1072a..5ef646a77cc 100644 --- a/poi-ooxml/src/test/java/org/apache/poi/xwpf/usermodel/TestXWPFParagraph.java +++ b/poi-ooxml/src/test/java/org/apache/poi/xwpf/usermodel/TestXWPFParagraph.java @@ -921,6 +921,50 @@ void testSearchText() throws Exception { } } + @Test + void testGettersWithEmptyParagraphProperties() throws IOException { + try (XWPFDocument doc = XWPFTestDataSamples.openSampleDocument("emptyPPr.docx")) { + XWPFParagraph p = doc.getParagraphArray(0); + + assertNull(p.getNumID()); + assertNull(p.getNumIlvl()); + assertNull(p.getNumFmt()); + assertNull(p.getNumLevelText()); + assertNull(p.getNumStartOverride()); + assertFalse(p.isKeepNext()); + + assertFalse(p.isAlignmentSet()); + assertEquals(ParagraphAlignment.LEFT, p.getAlignment()); + assertEquals(TextAlignment.AUTO, p.getVerticalAlignment()); + + assertEquals(Borders.NONE, p.getBorderTop()); + assertEquals(Borders.NONE, p.getBorderBottom()); + assertEquals(Borders.NONE, p.getBorderLeft()); + assertEquals(Borders.NONE, p.getBorderRight()); + assertEquals(Borders.NONE, p.getBorderBetween()); + + assertEquals(-1, p.getSpacingAfter()); + assertEquals(-1, p.getSpacingAfterLines()); + assertEquals(-1, p.getSpacingBefore()); + assertEquals(-1, p.getSpacingBeforeLines()); + assertEquals(-1, p.getSpacingBetween()); + assertEquals(LineSpacingRule.AUTO, p.getSpacingLineRule()); + + assertEquals(-1, p.getIndentationLeft()); + assertEquals(-1, p.getIndentationLeftChars()); + assertEquals(-1, p.getIndentationRight()); + assertEquals(-1, p.getIndentationRightChars()); + assertEquals(-1, p.getIndentationHanging()); + assertEquals(-1, p.getIndentationFirstLine()); + + assertFalse(p.isPageBreak()); + assertFalse(p.isWordWrapped()); + + assertNull(p.getStyleID()); + assertNull(p.getStyle()); + } + } + private static void checkSearchText(XWPFParagraph paragraph, String search, int beginRun, int endRun, int beginText, int endText, int beginChar, int endChar) { TextSegment result = paragraph.searchText(search, new PositionInParagraph()); diff --git a/poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFRow.java b/poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFRow.java index c0b7188409d..ad1ba4fe2da 100644 --- a/poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFRow.java +++ b/poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFRow.java @@ -114,7 +114,7 @@ public final class HSSFRow implements Row, Comparable { * Use this to create new cells within the row and return it. *

* The cell that is returned is a {@link CellType#BLANK}. The type can be changed - * either through calling setCellValue or setCellType. + * either through calling setCellValue or setCellFormula. * * @param column - the column number this cell represents * @@ -125,7 +125,7 @@ public final class HSSFRow implements Row, Comparable { @Override public HSSFCell createCell(int column) { - return this.createCell(column,CellType.BLANK); + return this.createCell(column, CellType.BLANK); } /** @@ -133,7 +133,7 @@ public HSSFCell createCell(int column) *

* The cell that is returned will be of the requested type. * The type can be changed either through calling setCellValue - * or setCellType, but there is a small overhead to doing this, + * or setCellFormula, but there is a small overhead to doing this, * so it is best to create the required type up front. * * @param columnIndex - the column number this cell represents diff --git a/poi/src/main/java/org/apache/poi/logging/NoOpLogger.java b/poi/src/main/java/org/apache/poi/logging/NoOpLogger.java index 1880d370622..3b17ed186e8 100644 --- a/poi/src/main/java/org/apache/poi/logging/NoOpLogger.java +++ b/poi/src/main/java/org/apache/poi/logging/NoOpLogger.java @@ -1,17 +1,19 @@ -/* Copyright 2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +/* ==================================================================== + 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.logging; diff --git a/poi/src/main/java/org/apache/poi/logging/PoiLogManager.java b/poi/src/main/java/org/apache/poi/logging/PoiLogManager.java index 2404d55706c..2da065311fa 100644 --- a/poi/src/main/java/org/apache/poi/logging/PoiLogManager.java +++ b/poi/src/main/java/org/apache/poi/logging/PoiLogManager.java @@ -1,17 +1,19 @@ -/* Copyright 2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +/* ==================================================================== + 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.logging; diff --git a/poi/src/main/java/org/apache/poi/ss/usermodel/Row.java b/poi/src/main/java/org/apache/poi/ss/usermodel/Row.java index 2ddb9572747..14303dc06fa 100644 --- a/poi/src/main/java/org/apache/poi/ss/usermodel/Row.java +++ b/poi/src/main/java/org/apache/poi/ss/usermodel/Row.java @@ -30,7 +30,7 @@ public interface Row extends Iterable { * Use this to create new cells within the row and return it. *

* The cell that is returned is a {@link CellType#BLANK}. The type can be changed - * either through calling setCellValue or setCellType. + * either through calling setCellValue or setCellFormula. * * @param column - the column number this cell represents * @return Cell a high level representation of the created cell. @@ -44,7 +44,7 @@ public interface Row extends Iterable { *

* The cell that is returned will be of the requested type. * The type can be changed either through calling setCellValue - * or setCellType, but there is a small overhead to doing this, + * or setCellFormula, but there is a small overhead to doing this, * so it is best to create of the required type up front. * * @param column - the column number this cell represents diff --git a/test-data/document/emptyPPr.docx b/test-data/document/emptyPPr.docx new file mode 100644 index 00000000000..7ef696b1e13 Binary files /dev/null and b/test-data/document/emptyPPr.docx differ