diff --git a/build.gradle b/build.gradle index debb97b3bf..bb5580639f 100644 --- a/build.gradle +++ b/build.gradle @@ -14,6 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. ==================================================================== */ + buildscript { repositories { maven { url "https://plugins.gradle.org/m2/" } @@ -85,15 +86,15 @@ allprojects { } /** - Define things that are only necessary in sub-projects, but not in the master-project itself - */ subprojects { //Put instructions for each sub project, but not the master apply plugin: 'java-library' apply plugin: 'jacoco' apply plugin: 'maven-publish' + apply plugin: 'signing' + version = '5.0.1-SNAPSHOT' ext { @@ -122,12 +123,8 @@ subprojects { options.deprecation = true } - tasks.withType(Jar) { - duplicatesStrategy = 'fail' - } - - sourceCompatibility = 1.8 - targetCompatibility = 1.8 + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 repositories { mavenCentral() @@ -145,7 +142,41 @@ subprojects { task wrapper(type: Wrapper){ // https://stackoverflow.com/a/65701523/2066598 - gradleVersion = '6.8' + gradleVersion = '7.0.1' + } + + java { + withJavadocJar() + withSourcesJar() + } + + javadoc { + failOnError = true + maxMemory = "1024M" + doFirst { + options { + if (JavaVersion.current().isJava9Compatible()) { + addBooleanOption('html5', true) + } + addBooleanOption('Xdoclint:all,-missing', true) + links 'https://poi.apache.org/apidocs/dev/' + links 'https://docs.oracle.com/javase/8/docs/api/' + links 'https://xmlbeans.apache.org/docs/5.0.0/' + use = true + splitIndex = true + source = "1.8" + } + } + } + + tasks.withType(Jar) { + duplicatesStrategy = 'fail' + destinationDirectory = file("../build/dist/maven/${project.archivesBaseName}") + + doLast { + ant.checksum(file: it.archivePath, algorithm: 'SHA-256', fileext: '.sha256', format: 'MD5SUM') + ant.checksum(file: it.archivePath, algorithm: 'SHA-512', fileext: '.sha512', format: 'MD5SUM') + } } jar { @@ -154,6 +185,17 @@ 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") + } + + sourcesJar { + destinationDirectory = file("../build/dist/maven/${project.archivesBaseName}") + exclude 'META-INF/services/**' + } + test { // make XML test-results available for Jenkins CI useJUnitPlatform() @@ -176,7 +218,21 @@ subprojects { maxHeapSize = "768m" // Specifying the local via system properties did not work, so we set them this way - jvmArgs '-Duser.language=en -Duser.country=US' + jvmArgs << [ + '-Djava.io.tmpdir=build', + '-DPOI.testdata.path=../test-data', + '-Djava.awt.headless=true', + '-Djava.locale.providers=JRE,CLDR', + '-Duser.language=en', + '-Duser.country=US', + '-Djavax.xml.stream.XMLInputFactory=com.sun.xml.internal.stream.XMLInputFactoryImpl', + "-Dversion.id=${project.version}", + '-ea', + '-Djunit.jupiter.execution.parallel.enabled=true', + '-Djunit.jupiter.execution.parallel.config.strategy=fixed', + '-Djunit.jupiter.execution.parallel.config.fixed.parallelism=3' + // -Xjit:verbose={compileStart|compileEnd},vlog=build/jit.log${no.jit.sherlock} ... if ${isIBMVM} + ] // show standard out and standard error of the test JVM(s) on the console //testLogging.showStandardStreams = true @@ -190,6 +246,23 @@ subprojects { systemProperties['java.locale.providers'] = 'JRE,CLDR' systemProperties['junit.jupiter.execution.parallel.enabled'] = 'false' + + doFirst { + if (JavaVersion.current() != JavaVersion.VERSION_1_8) { + jvmArgs += [ + '-Dsun.reflect.debugModuleAccessChecks=true', + '-Dcom.sun.xml.bind.v2.bytecode.ClassTailor.noOptimize=true', + '--illegal-access=warn', + + // see https://github.com/java9-modularity/gradle-modules-plugin/issues/97 + // opposed to the recommendation there, it doesn't work to add ... to the dependencies + // testRuntimeOnly 'org.junit.platform:junit-platform-launcher:1.7.1' + // gradles gradle-worker.jar is still not a JPMS module and thus runs as unnamed module + '--add-exports','org.junit.platform.commons/org.junit.platform.commons.util=ALL-UNNAMED', + '--add-exports','org.junit.platform.commons/org.junit.platform.commons.logging=ALL-UNNAMED', + ] + } + } } jacoco { @@ -242,10 +315,15 @@ subprojects { publications { POI(MavenPublication) { groupId 'org.apache.poi' + artifactId project.archivesBaseName + + from components.java pom { packaging = 'jar' url = 'https://poi.apache.org/' + name = 'Apache POI' + description = 'Apache POI - Java API To Access Microsoft Format Files' mailingLists { mailingList { @@ -278,7 +356,9 @@ subprojects { withXml { def r = asElement() def doc = r.getOwnerDocument() - def asl = doc.createComment(new File('../legal/HEADER').text) + def hdr = new File('../legal/HEADER') + if (!hdr.exists()) hdr = new File('legal/HEADER') + def asl = doc.createComment(hdr.text) // adding ASF header before root node is ignored // doc.insertBefore(asl, doc.getDocumentElement()) r.insertBefore(asl, r.getFirstChild()) @@ -287,18 +367,12 @@ subprojects { } } } -} -// Make JavaDoc behave similar to Ant, i.e. be a bit more lenient -// and define amount of memory -// https://blog.joda.org/2014/02/turning-off-doclint-in-jdk-8-javadoc.html -if (JavaVersion.current().isJava8Compatible()) { - allprojects { - tasks.withType(Javadoc) { - options.addStringOption('Xdoclint:none', '-quiet') - maxMemory="384M" - } - } + generatePomFileForPOIPublication.destination = "../build/dist/maven/${project.archivesBaseName}/${project.archivesBaseName}-${project.version}.pom" + + signing { + sign publishing.publications.POI + } } // initial try to provide a combined JavaDoc, grouping is still missing here, though! @@ -313,6 +387,7 @@ task allJavaDoc(type: Javadoc) { // for possible options see https://docs.gradle.org/current/javadoc/org/gradle/external/javadoc/StandardJavadocDocletOptions.html options.use = true options.splitIndex = true + options.addBooleanOption('Xdoclint:all,-missing', true) title = 'POI API Documentation' options.bottom = 'Copyright ' + new Date().format('yyyy') + ' The Apache Software Foundation or\n' + diff --git a/poi-examples/build.gradle b/poi-examples/build.gradle index 21bb62e598..2f704cd184 100644 --- a/poi-examples/build.gradle +++ b/poi-examples/build.gradle @@ -43,12 +43,6 @@ final String MODULE_NAME = 'org.apache.poi.examples' final Pattern MODULE_REGEX = ~'\\.jar$' final List MAIN_MODULE_PATH = sourceSets.main.runtimeClasspath.findAll{ it.path =~ MODULE_REGEX }.collect{ it.parent }.unique() -java { - sourceCompatibility = JavaVersion.VERSION_1_8 - targetCompatibility = JavaVersion.VERSION_1_8 - withSourcesJar() -} - task compileJava9(type: JavaCompile) { dependsOn 'compileJava', ':poi-ooxml:jar', ':poi-scratchpad:jar' @@ -83,7 +77,3 @@ jar { attributes('Automatic-Module-Name': MODULE_NAME, 'Multi-Release': 'true') } } - -sourcesJar { - destinationDirectory = file("../build/dist/maven/${project.archivesBaseName}") -} diff --git a/poi-examples/src/main/java/org/apache/poi/examples/hpsf/CopyCompare.java b/poi-examples/src/main/java/org/apache/poi/examples/hpsf/CopyCompare.java index c24afe1376..d933b23e22 100644 --- a/poi-examples/src/main/java/org/apache/poi/examples/hpsf/CopyCompare.java +++ b/poi-examples/src/main/java/org/apache/poi/examples/hpsf/CopyCompare.java @@ -42,23 +42,23 @@ import org.apache.poi.poifs.filesystem.POIFSFileSystem; import org.apache.poi.util.TempFile; /** - *
This class copies a POI file system to a new file and compares the copy - * with the original.
+ * This class copies a POI file system to a new file and compares the copy + * with the original. *- *
Property set streams are copied logically, i.e. the application + * Property set streams are copied logically, i.e. the application * establishes a {@link org.apache.poi.hpsf.PropertySet} of an original property * set, creates a {@link org.apache.poi.hpsf.PropertySet} and writes the * {@link org.apache.poi.hpsf.PropertySet} to the destination POI file * system. - Streams which are no property set streams are copied bit by - * bit.
+ * bit. *- *
The comparison of the POI file systems is done logically. That means that + * The comparison of the POI file systems is done logically. That means that * the two disk files containing the POI file systems do not need to be * exactly identical. However, both POI file systems must contain the same * files, and most of these files must be bitwise identical. Property set * streams, however, are compared logically: they must have the same sections * with the same attributes, and the sections must contain the same properties. - * Details like the ordering of the properties do not matter.
+ * Details like the ordering of the properties do not matter. */ @SuppressWarnings({"java:S106","java:S4823"}) public final class CopyCompare { diff --git a/poi-examples/src/main/java/org/apache/poi/examples/xssf/eventusermodel/LoadPasswordProtectedXlsxStreaming.java b/poi-examples/src/main/java/org/apache/poi/examples/xssf/eventusermodel/LoadPasswordProtectedXlsxStreaming.java index 96ba25e396..25c900965a 100644 --- a/poi-examples/src/main/java/org/apache/poi/examples/xssf/eventusermodel/LoadPasswordProtectedXlsxStreaming.java +++ b/poi-examples/src/main/java/org/apache/poi/examples/xssf/eventusermodel/LoadPasswordProtectedXlsxStreaming.java @@ -30,10 +30,10 @@ import org.apache.poi.xssf.eventusermodel.XSSFReader.SheetIterator; /** * An example that loads a password protected workbook and counts the sheets. * The example highlights how to do this in streaming way. - *AesZipFileZipEntrySource
is used to ensure that temp files are encrypted.
- * + *
SXSSFWorkbookWithCustomZipEntrySource
extends SXSSFWorkbook to ensure temp files are encrypted.
- * + *
AesZipFileZipEntrySource
is used to ensure that temp files are encrypted.
- * * Its purpose is to provide a way to manipulate a workbook in the course * of an ExcelAnt task. The idea being to model a way for test writers to @@ -36,7 +36,7 @@ import org.apache.tools.ant.Task; * class you write to manipulate the workbook. *
* In order to use this tag you must write a class that implements the
- *
+ * this POIXMLDocumentPart to the {@link PackagePart} of the given
+ * parameter value.
*
- * There can be multiple references to the given {@link POIXMLDocumentPart}
+ * There can be multiple references to the given POIXMLDocumentPart
* and only the first in the order of creation is returned.
*
- * @param part The {@link POIXMLDocumentPart} for which the according
+ * @param part The POIXMLDocumentPart for which the according
* relation-id shall be found.
* @return The value of the {@link PackageRelationship#getId()} or null, if
* parts are not related.
@@ -326,7 +327,7 @@ public class POIXMLDocumentPart {
/**
* Remove the relation to the specified part in this package and remove the
- * part, if it is no longer needed.
+ * part, if it is no longer needed.
*
* If there are multiple relationships to the same part, this will only
* remove the first relationship in the order of creation. The removal
@@ -340,7 +341,7 @@ public class POIXMLDocumentPart {
/**
* Remove the relation to the specified part in this package and remove the
- * part, if it is no longer needed and flag is set to true.
+ * part, if it is no longer needed and flag is set to true.
*
* If there are multiple relationships to the same part, this will only
* remove the first relationship in the order of creation. The removal
@@ -358,7 +359,7 @@ public class POIXMLDocumentPart {
/**
* Remove the relation to the specified part in this package and remove the
- * part, if it is no longer needed.
+ * part, if it is no longer needed.
*
* If there are multiple relationships to the same part, this will only
* remove the first relationship in the order of creation. The removal
@@ -413,7 +414,7 @@ public class POIXMLDocumentPart {
/**
* Returns the parent POIXMLDocumentPart. All parts except root have not-null parent.
*
- * @return the parent POIXMLDocumentPart or
- * This method only exists to allow access to protected {@link POIXMLDocumentPart#onDocumentRead()}
+ *
+ * @deprecated This method only exists to allow access to protected {@link POIXMLDocumentPart#onDocumentRead()}
* from {@link XWPFDocument} without reflection. It should be removed.
*
* @param part the part which is to be read
diff --git a/poi-ooxml/src/main/java/org/apache/poi/poifs/crypt/dsig/facets/SignatureFacet.java b/poi-ooxml/src/main/java/org/apache/poi/poifs/crypt/dsig/facets/SignatureFacet.java
index cc1a803ce6..9c82d86e4b 100644
--- a/poi-ooxml/src/main/java/org/apache/poi/poifs/crypt/dsig/facets/SignatureFacet.java
+++ b/poi-ooxml/src/main/java/org/apache/poi/poifs/crypt/dsig/facets/SignatureFacet.java
@@ -60,7 +60,6 @@ public interface SignatureFacet {
* @param document the signature document to be used for imports
* @param references list of reference definitions
* @param objects objects to be signed/included in the signature document
- * @throws XMLSignatureException
*/
default void preSign(
SignatureInfo signatureInfo
@@ -78,7 +77,6 @@ public interface SignatureFacet {
*
* @param signatureInfo the signature info object holding the OPCPackage and other document related data
* @param document the signature document to be modified
- * @throws MarshalException
*/
default void postSign(SignatureInfo signatureInfo, Document document) throws MarshalException {
diff --git a/poi-ooxml/src/main/java/org/apache/poi/poifs/crypt/dsig/services/RevocationData.java b/poi-ooxml/src/main/java/org/apache/poi/poifs/crypt/dsig/services/RevocationData.java
index e0bdc05623..24430c3ac1 100644
--- a/poi-ooxml/src/main/java/org/apache/poi/poifs/crypt/dsig/services/RevocationData.java
+++ b/poi-ooxml/src/main/java/org/apache/poi/poifs/crypt/dsig/services/RevocationData.java
@@ -48,8 +48,6 @@ public class RevocationData {
/**
* Adds a CRL to this revocation data set.
- *
- * @param encodedCrl
*/
public void addCRL(byte[] encodedCrl) {
this.crls.add(encodedCrl);
@@ -57,8 +55,6 @@ public class RevocationData {
/**
* Adds a CRL to this revocation data set.
- *
- * @param crl
*/
public void addCRL(X509CRL crl) {
byte[] encodedCrl;
@@ -73,8 +69,6 @@ public class RevocationData {
/**
* Adds an OCSP response to this revocation data set.
- *
- * @param encodedOcsp
*/
public void addOCSP(byte[] encodedOcsp) {
this.ocsps.add(encodedOcsp);
@@ -99,10 +93,10 @@ public class RevocationData {
}
/**
- * Returns
@@ -94,9 +95,9 @@ public abstract class XDDFChartData {
*
*
* @deprecated since POI 4.1.1
- * @return
*/
@Deprecated
+ @Removal(version = "5.3")
public List
* A typical implementation would be
*
- *
* The size is specified using a percentage.
* Positive values indicate superscript, negative values indicate subscript.
- *
* The size is specified using a percentage.
- *
* The size is specified using a percentage.
- *
- * The value
- * The value
*
- * The following order of inheritance is assumed:
+ * The following order of inheritance is assumed:
* IExcelAntWorkbookHandler
interface. After writing the
+ * {@code IExcelAntWorkbookHandler} interface. After writing the
* class you should package it and it's dependencies into a jar file to
* add as library in your Ant build file.
*/
diff --git a/poi-excelant/src/main/java/org/apache/poi/ss/excelant/util/ExcelAntWorkbookUtil.java b/poi-excelant/src/main/java/org/apache/poi/ss/excelant/util/ExcelAntWorkbookUtil.java
index 69616c5310..0bb0cb2ec2 100644
--- a/poi-excelant/src/main/java/org/apache/poi/ss/excelant/util/ExcelAntWorkbookUtil.java
+++ b/poi-excelant/src/main/java/org/apache/poi/ss/excelant/util/ExcelAntWorkbookUtil.java
@@ -187,8 +187,6 @@ public class ExcelAntWorkbookUtil extends Typedef {
/**
* Returns the Workbook instance associated with this WorkbookUtil.
- *
- * @return
*/
public Workbook getWorkbook() {
return workbook;
@@ -197,8 +195,6 @@ public class ExcelAntWorkbookUtil extends Typedef {
/**
* Returns the fileName that was used to initialize this instance. May
* return null if the instance was constructed from a Workbook object.
- *
- * @return
*/
public String getFileName() {
return excelFileName;
@@ -206,8 +202,6 @@ public class ExcelAntWorkbookUtil extends Typedef {
/**
* Returns the list of sheet names.
- *
- * @return
*/
public Listnull
for the root element.
+ * @return the parent POIXMLDocumentPart or {@code null} for the root element.
*/
public final POIXMLDocumentPart getParent() {
return parent;
@@ -719,8 +720,8 @@ public class POIXMLDocumentPart {
/**
* Internal method, do not use!
- * true
if this revocation data set holds OCSP
+ * Returns {@code true} if this revocation data set holds OCSP
* responses.
*
- * @return true
if this revocation data set holds OCSP
+ * @return {@code true} if this revocation data set holds OCSP
* responses.
*/
public boolean hasOCSPs() {
@@ -110,18 +104,18 @@ public class RevocationData {
}
/**
- * Returns true
if this revocation data set holds CRLs.
+ * Returns {@code true} if this revocation data set holds CRLs.
*
- * @return true
if this revocation data set holds CRLs.
+ * @return {@code true} if this revocation data set holds CRLs.
*/
public boolean hasCRLs() {
return !this.crls.isEmpty();
}
/**
- * Returns true
if this revocation data is not empty.
+ * Returns {@code true} if this revocation data is not empty.
*
- * @return true
if this revocation data is not empty.
+ * @return {@code true} if this revocation data is not empty.
*/
public boolean hasRevocationDataEntries() {
return hasOCSPs() || hasCRLs();
diff --git a/poi-ooxml/src/main/java/org/apache/poi/poifs/crypt/dsig/services/TimeStampServiceValidator.java b/poi-ooxml/src/main/java/org/apache/poi/poifs/crypt/dsig/services/TimeStampServiceValidator.java
index e15fbd4f86..d7938e68b1 100644
--- a/poi-ooxml/src/main/java/org/apache/poi/poifs/crypt/dsig/services/TimeStampServiceValidator.java
+++ b/poi-ooxml/src/main/java/org/apache/poi/poifs/crypt/dsig/services/TimeStampServiceValidator.java
@@ -35,7 +35,6 @@ public interface TimeStampServiceValidator {
/**
* Validates the given certificate chain.
*
- * @param certificateChain
* @param revocationData
* the optional data container that should be filled with
* revocation data that was used to validate the given
diff --git a/poi-ooxml/src/main/java/org/apache/poi/xddf/usermodel/chart/XDDFChart.java b/poi-ooxml/src/main/java/org/apache/poi/xddf/usermodel/chart/XDDFChart.java
index 8ac25748d8..3a213bfe7f 100644
--- a/poi-ooxml/src/main/java/org/apache/poi/xddf/usermodel/chart/XDDFChart.java
+++ b/poi-ooxml/src/main/java/org/apache/poi/xddf/usermodel/chart/XDDFChart.java
@@ -141,7 +141,7 @@ public abstract class XDDFChart extends POIXMLDocumentPart implements TextContai
* @param part
* the package part holding the chart data, the content type must
* be
- * application/vnd.openxmlformats-officedocument.drawingml.chart+xml
+ * {@code application/vnd.openxmlformats-officedocument.drawingml.chart+xml}
* @since POI 3.14-Beta1
*/
protected XDDFChart(PackagePart part) throws IOException, XmlException {
@@ -411,13 +411,11 @@ public abstract class XDDFChart extends POIXMLDocumentPart implements TextContai
series.plot();
XDDFDataSource> categoryDS = series.getCategoryData();
XDDFNumericalDataSource extends Number> valuesDS = series.getValuesData();
- if (categoryDS == null || valuesDS == null
- || categoryDS.isCellRange() || valuesDS.isCellRange()
- || categoryDS.isLiteral() || valuesDS.isLiteral()) {
- // let's assume the data is already in the sheet
- } else {
+ if (categoryDS != null && !categoryDS.isCellRange() && !categoryDS.isLiteral() &&
+ valuesDS != null && !valuesDS.isCellRange() && !valuesDS.isLiteral()) {
fillSheet(sheet, categoryDS, valuesDS);
}
+ // otherwise let's assume the data is already in the sheet
}
}
@@ -774,7 +772,6 @@ public abstract class XDDFChart extends POIXMLDocumentPart implements TextContai
* @param chartFactory
* factory object of POIXMLFactory (XWPFFactory/XSLFFactory)
* @return return the new package part
- * @throws InvalidFormatException
* @since POI 4.0.0
*/
private PackagePart createWorksheetPart(POIXMLRelation chartWorkbookRelation, POIXMLFactory chartFactory)
@@ -787,10 +784,7 @@ public abstract class XDDFChart extends POIXMLDocumentPart implements TextContai
/**
* this method write the XSSFWorkbook object data into embedded excel file
*
- * @param workbook
- * XSSFworkbook object
- * @throws IOException
- * @throws InvalidFormatException
+ * @param workbook XSSFworkbook object
* @since POI 4.0.0
*/
public void saveWorkbook(XSSFWorkbook workbook) throws IOException, InvalidFormatException {
@@ -953,8 +947,6 @@ public abstract class XDDFChart extends POIXMLDocumentPart implements TextContai
}
/**
- * @param range
- * @return
* @since POI 4.0.0
*/
public String formatRange(CellRangeAddress range) {
@@ -969,12 +961,11 @@ public abstract class XDDFChart extends POIXMLDocumentPart implements TextContai
* @since POI 4.0.0
*/
private XSSFSheet getSheet() {
- XSSFSheet sheet = null;
try {
- sheet = getWorkbook().getSheetAt(0);
- } catch (InvalidFormatException | IOException ife) {
+ return getWorkbook().getSheetAt(0);
+ } catch (InvalidFormatException | IOException ignored) {
+ return null;
}
- return sheet;
}
/**
@@ -983,7 +974,6 @@ public abstract class XDDFChart extends POIXMLDocumentPart implements TextContai
* writing xssfworkbook object into output stream of embedded part
*
* @return returns the packagepart of embedded file
- * @throws InvalidFormatException
* @since POI 4.0.0
*/
private PackagePart getWorksheetPart() throws InvalidFormatException {
@@ -1006,8 +996,6 @@ public abstract class XDDFChart extends POIXMLDocumentPart implements TextContai
/**
* @return returns the workbook object of embedded excel file
- * @throws IOException
- * @throws InvalidFormatException
* @since POI 4.0.0
*/
public XSSFWorkbook getWorkbook() throws IOException, InvalidFormatException {
@@ -1087,8 +1075,8 @@ public abstract class XDDFChart extends POIXMLDocumentPart implements TextContai
public void replaceReferences(XSSFSheet newSheet) {
for (XDDFChartData data : getChartSeries()) {
for (XDDFChartData.Series series : data.series) {
- XDDFDataSource newCategory = series.categoryData;
- XDDFNumericalDataSource newValues = series.valuesData;
+ XDDFDataSource> newCategory = series.categoryData;
+ XDDFNumericalDataSource extends Number> newValues = series.valuesData;
try {
if (series.categoryData != null && series.categoryData.isReference()) {
String ref = series.categoryData.getDataRangeReference();
@@ -1097,7 +1085,7 @@ public abstract class XDDFChart extends POIXMLDocumentPart implements TextContai
? XDDFDataSourcesFactory.fromNumericCellRange(newSheet, rangeAddress)
: XDDFDataSourcesFactory.fromStringCellRange(newSheet, rangeAddress);
if (newCategory.isNumeric()) {
- ((XDDFNumericalDataSource) newCategory).setFormatCode(series.categoryData.getFormatCode());
+ ((XDDFNumericalDataSource extends Number>) newCategory).setFormatCode(series.categoryData.getFormatCode());
}
}
if (series.valuesData!= null && series.valuesData.isReference()) {
diff --git a/poi-ooxml/src/main/java/org/apache/poi/xddf/usermodel/chart/XDDFChartData.java b/poi-ooxml/src/main/java/org/apache/poi/xddf/usermodel/chart/XDDFChartData.java
index 365d3f37fd..ead08bc197 100644
--- a/poi-ooxml/src/main/java/org/apache/poi/xddf/usermodel/chart/XDDFChartData.java
+++ b/poi-ooxml/src/main/java/org/apache/poi/xddf/usermodel/chart/XDDFChartData.java
@@ -26,6 +26,7 @@ import java.util.Map;
import org.apache.poi.ss.util.CellReference;
import org.apache.poi.util.Beta;
import org.apache.poi.util.Internal;
+import org.apache.poi.util.Removal;
import org.apache.poi.xddf.usermodel.XDDFFillProperties;
import org.apache.poi.xddf.usermodel.XDDFLineProperties;
import org.apache.poi.xddf.usermodel.XDDFShapeProperties;
@@ -81,7 +82,7 @@ public abstract class XDDFChartData {
}
/**
- * Calls to getSeries().add(series)
or to getSeries().remove(series)
+ * Calls to {@code getSeries().add(series)} or to {@code getSeries().remove(series)}
* may corrupt the workbook.
*
* XDDFChartData
.
+ * This method should be implemented in every class that extends {@code XDDFChartData}.
*
- *
- * @param n
+ *
- protected void removeCTSeries(int n) {
- chart.removeSer(n);
- }
-
- *
{@code
+ * protected void removeCTSeries(int n) {
+ * chart.removeSer(n);
+ * }
+ * }
*/
@Internal
protected abstract void removeCTSeries(int n);
@@ -195,7 +193,7 @@ public abstract class XDDFChartData {
}
if (cache.sizeOfPtArray() < 1) {
cache.addNewPtCount().setVal(1);
- cache.addNewPt().setIdx(0);;
+ cache.addNewPt().setIdx(0);
}
cache.getPtArray(0).setV(title);
}
@@ -255,7 +253,7 @@ public abstract class XDDFChartData {
}
/**
- * If a data point definition with the given index
exists, then remove it.
+ * If a data point definition with the given {@code index} exists, then remove it.
* Otherwise do nothing.
*
* @param index
@@ -267,19 +265,19 @@ public abstract class XDDFChartData {
for (int i = 0; i < points.size(); i++) {
if (points.get(i).getIdx().getVal() == index) {
points.remove(i);
- i = points.size();
+ break;
}
}
}
/**
- * If a data point definition with the given index
exists, then return it.
+ * If a data point definition with the given {@code index} exists, then return it.
* Otherwise create a new data point definition and return it.
*
* @param index
* data point index.
* @return
- * the data point with the given index
.
+ * the data point with the given {@code index}.
* @since POI 5.0.1
*/
public XDDFDataPoint getDataPoint(long index) {
diff --git a/poi-ooxml/src/main/java/org/apache/poi/xddf/usermodel/text/XDDFTextRun.java b/poi-ooxml/src/main/java/org/apache/poi/xddf/usermodel/text/XDDFTextRun.java
index 0817f23592..40adadcc57 100644
--- a/poi-ooxml/src/main/java/org/apache/poi/xddf/usermodel/text/XDDFTextRun.java
+++ b/poi-ooxml/src/main/java/org/apache/poi/xddf/usermodel/text/XDDFTextRun.java
@@ -48,7 +48,7 @@ import org.openxmlformats.schemas.drawingml.x2006.main.STTextUnderlineType;
@Beta
public class XDDFTextRun {
- private XDDFTextParagraph _parent;
+ private final XDDFTextParagraph _parent;
private XDDFRunProperties _properties;
private CTTextLineBreak _tlb;
private CTTextField _tf;
@@ -320,9 +320,6 @@ public class XDDFTextRun {
* null
unsets the
+ * font size in points. The value {@code null} unsets the
* size for this run.
*
*
null
unsets the kerning for this run.
+ * The value {@code null} unsets the kerning for this run.
* null
.
+ * If this attribute is omitted then returns {@code null}.
*/
public Double getCharacterKerning() {
return findDefinedProperty(
@@ -468,7 +459,7 @@ public class XDDFTextRun {
* negative values to condense.
* null
unsets the spacing for this run.
+ * The value {@code null} unsets the spacing for this run.
* null
.
+ * If this attribute is omitted then returns {@code null}.
*/
public Double getCharacterSpacing() {
return findDefinedProperty(
diff --git a/poi-ooxml/src/main/java/org/apache/poi/xdgf/usermodel/section/CombinedIterable.java b/poi-ooxml/src/main/java/org/apache/poi/xdgf/usermodel/section/CombinedIterable.java
index 2d6f251bb4..a89e26c51e 100644
--- a/poi-ooxml/src/main/java/org/apache/poi/xdgf/usermodel/section/CombinedIterable.java
+++ b/poi-ooxml/src/main/java/org/apache/poi/xdgf/usermodel/section/CombinedIterable.java
@@ -21,13 +21,10 @@ import java.util.Collections;
import java.util.Iterator;
import java.util.Map.Entry;
import java.util.NoSuchElementException;
-import java.util.Set;
import java.util.SortedMap;
/**
* An iterator used to iterate over the base and master items
- *
- * @param
*
double
.
+ * @exception NumberFormatException if the cell value isn't a parsable {@code double}.
* @see DataFormatter for turning this number into a string similar to that which Excel would render this number as.
*/
@Override
@@ -320,9 +316,6 @@ public final class XSSFCell extends CellBase {
}
}
- /**
- * {@inheritDoc}
- */
@Override
public void setCellValueImpl(double value) {
_cell.setT(STCellType.N);
@@ -385,10 +378,14 @@ public final class XSSFCell extends CellBase {
}
}
break;
- case FORMULA:
- checkFormulaCachedValueType(CellType.STRING, getBaseCellType(false));
+ case FORMULA: {
+ CellType cachedValueType = getBaseCellType(false);
+ if (cachedValueType != CellType.STRING) {
+ throw typeMismatch(CellType.STRING, cachedValueType, true);
+ }
rt = new XSSFRichTextString(_cell.isSetV() ? _cell.getV() : "");
break;
+ }
default:
throw typeMismatch(CellType.STRING, cellType, false);
}
@@ -396,23 +393,11 @@ public final class XSSFCell extends CellBase {
return rt;
}
- private static void checkFormulaCachedValueType(CellType expectedTypeCode, CellType cachedValueType) {
- if (cachedValueType != expectedTypeCode) {
- throw typeMismatch(expectedTypeCode, cachedValueType, true);
- }
- }
-
- /**
- * {@inheritDoc}
- */
@Override
protected void setCellValueImpl(String value) {
setCellValueImpl(new XSSFRichTextString(value));
}
- /**
- * {@inheritDoc}
- */
@Override
protected void setCellValueImpl(RichTextString str) {
CellType cellType = getCellType();
@@ -434,7 +419,7 @@ public final class XSSFCell extends CellBase {
}
/**
- * Return a formula for the cell, for example, SUM(C4:E4)
+ * Return a formula for the cell, for example, {@code SUM(C4:E4)}
*
* @return a formula for the cell
* @throws IllegalStateException if the cell type returned by {@link #getCellType()} is not {@link CellType#FORMULA}
@@ -517,8 +502,8 @@ public final class XSSFCell extends CellBase {
* {@link FormulaEvaluator} instances based on this workbook.
*
*
- * @param formula the formula to set, e.g. "SUM(C4:E4)"
.
- * If the argument is null
then the current formula is removed.
+ * @param formula the formula to set, e.g. {@code "SUM(C4:E4)"}.
+ * If the argument is {@code null} then the current formula is removed.
* @throws org.apache.poi.ss.formula.FormulaParseException if the formula has incorrect syntax or is otherwise invalid
* @throws IllegalStateException if the operation is not allowed, for example,
* when the cell is a part of a multi-cell array formula
@@ -657,10 +642,8 @@ public final class XSSFCell extends CellBase {
* @return true if the cell is of a formula type POI can handle
*/
private boolean isFormulaCell() {
- if ( (_cell.isSetF() && _cell.getF().getT() != STCellFormulaType.DATA_TABLE ) || getSheet().isCellInArrayFormulaContext(this)) {
- return true;
- }
- return false;
+ return (_cell.isSetF() && _cell.getF().getT() != STCellFormulaType.DATA_TABLE)
+ || getSheet().isCellInArrayFormulaContext(this);
}
/**
@@ -732,7 +715,7 @@ public final class XSSFCell extends CellBase {
*
* @return the value of the cell as a date
* @throws IllegalStateException if the cell type returned by {@link #getCellType()} is {@link CellType#STRING}
- * @exception NumberFormatException if the cell value isn't a parsable double
.
+ * @exception NumberFormatException if the cell value isn't a parsable {@code double}.
* @see DataFormatter for formatting this date into a string similar to how excel does.
*/
@Override
@@ -753,7 +736,7 @@ public final class XSSFCell extends CellBase {
*
* @return the value of the cell as a LocalDateTime
* @throws IllegalStateException if the cell type returned by {@link #getCellType()} is {@link CellType#STRING}
- * @exception NumberFormatException if the cell value isn't a parsable double
.
+ * @exception NumberFormatException if the cell value isn't a parsable {@code double}.
* @see DataFormatter for formatting this date into a string similar to how excel does.
*/
@Override
@@ -767,27 +750,18 @@ public final class XSSFCell extends CellBase {
return DateUtil.getLocalDateTime(value, date1904);
}
- /**
- * {@inheritDoc}
- */
@Override
protected void setCellValueImpl(Date value) {
boolean date1904 = getSheet().getWorkbook().isDate1904();
setCellValue(DateUtil.getExcelDate(value, date1904));
}
- /**
- * {@inheritDoc}
- */
@Override
protected void setCellValueImpl(LocalDateTime value) {
boolean date1904 = getSheet().getWorkbook().isDate1904();
setCellValue(DateUtil.getExcelDate(value, date1904));
}
- /**
- * {@inheritDoc}
- */
@Override
protected void setCellValueImpl(Calendar value) {
boolean date1904 = getSheet().getWorkbook().isDate1904();
@@ -861,9 +835,6 @@ public final class XSSFCell extends CellBase {
_cell.setV(error.getString());
}
- /**
- * {@inheritDoc}
- */
@Override
public void setAsActiveCell() {
getSheet().setActiveCell(getAddress());
@@ -902,7 +873,6 @@ public final class XSSFCell extends CellBase {
/**
* Needed by bug #62834, which points out getCellFormula() expects an evaluation context or creates a new one,
* so if there is one in use, it needs to be carried on through.
- * @param cellType
* @param evalWb BaseXSSFEvaluationWorkbook already in use, or null if a new implicit one should be used
*/
protected void setCellType(CellType cellType, BaseXSSFEvaluationWorkbook evalWb) {
@@ -1003,7 +973,7 @@ public final class XSSFCell extends CellBase {
*
*
* @return the raw cell value as contained in the underlying CTCell bean,
- * null
for blank cells.
+ * {@code null} for blank cells.
*/
public String getRawValue() {
return _cell.getV();
@@ -1034,7 +1004,7 @@ public final class XSSFCell extends CellBase {
/**
* Returns cell comment associated with this cell
*
- * @return the cell comment associated with this cell or null
+ * @return the cell comment associated with this cell or {@code null}
*/
@Override
public XSSFComment getCellComment() {
@@ -1074,7 +1044,7 @@ public final class XSSFCell extends CellBase {
/**
* Returns hyperlink associated with this cell
*
- * @return hyperlink associated with this cell or null
if not found
+ * @return hyperlink associated with this cell or {@code null} if not found
*/
@Override
public XSSFHyperlink getHyperlink() {
diff --git a/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFChart.java b/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFChart.java
index e5646a41d6..0ca01fee96 100644
--- a/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFChart.java
+++ b/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFChart.java
@@ -17,25 +17,31 @@
package org.apache.poi.xssf.usermodel;
+import static org.apache.poi.ooxml.POIXMLTypeLoader.DEFAULT_XML_OPTIONS;
+
+import java.io.IOException;
+import java.io.OutputStream;
+
+import javax.xml.namespace.QName;
+
import org.apache.poi.ooxml.POIXMLFactory;
import org.apache.poi.ooxml.POIXMLRelation;
import org.apache.poi.openxml4j.opc.PackagePart;
-import org.apache.poi.util.Removal;
import org.apache.poi.xddf.usermodel.chart.XDDFChart;
import org.apache.xmlbeans.XmlException;
import org.apache.xmlbeans.XmlObject;
import org.apache.xmlbeans.XmlOptions;
-import org.openxmlformats.schemas.drawingml.x2006.chart.*;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTChartSpace;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTPageMargins;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTPlotArea;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTPrintSettings;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTStrRef;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTTitle;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTTx;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.w3c.dom.Text;
-import javax.xml.namespace.QName;
-import java.io.IOException;
-import java.io.OutputStream;
-
-import static org.apache.poi.ooxml.POIXMLTypeLoader.DEFAULT_XML_OPTIONS;
-
/**
* Represents a SpreadsheetML Chart
*/
@@ -60,7 +66,7 @@ public final class XSSFChart extends XDDFChart {
* @param part
* the package part holding the chart data, the content type must
* be
- * application/vnd.openxmlformats-officedocument.drawingml.chart+xml
+ * {@code application/vnd.openxmlformats-officedocument.drawingml.chart+xml}
*
* @since POI 3.14-Beta1
*/
@@ -204,8 +210,6 @@ public final class XSSFChart extends XDDFChart {
/**
* Set the formula expression to use for the chart title
- *
- * @param formula
*/
public void setTitleFormula(String formula) {
CTTitle ctTitle;
diff --git a/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFClientAnchor.java b/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFClientAnchor.java
index 428a06ddf1..02299a2b31 100644
--- a/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFClientAnchor.java
+++ b/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFClientAnchor.java
@@ -191,8 +191,6 @@ public class XSSFClientAnchor extends XSSFAnchor implements ClientAnchor {
}
/**
- * @param sheet
- * @param row
* @return height in twips (1/20th of point) for row or default
*/
private static float getRowHeight(XSSFSheet sheet, int row) {
@@ -208,54 +206,59 @@ public class XSSFClientAnchor extends XSSFAnchor implements ClientAnchor {
return cell2 != null ? cell2 : calcCell(getCell1(), size.getCx(), size.getCy());
}
+ @Override
public short getCol1() {
return (short)getCell1().getCol();
}
/**
* @throws NullPointerException if cell1 is null (fixed position)
- * @see org.apache.poi.ss.usermodel.ClientAnchor#setCol1(int)
*/
+ @Override
public void setCol1(int col1) {
cell1.setCol(col1);
}
+ @Override
public short getCol2() {
return (short) getCell2().getCol();
}
/**
* @throws NullPointerException if cell2 is null (fixed size)
- * @see org.apache.poi.ss.usermodel.ClientAnchor#setCol2(int)
*/
+ @Override
public void setCol2(int col2) {
cell2.setCol(col2);
}
+ @Override
public int getRow1() {
return getCell1().getRow();
}
/**
* @throws NullPointerException if cell1 is null (fixed position)
- * @see org.apache.poi.ss.usermodel.ClientAnchor#setRow1(int)
*/
+ @Override
public void setRow1(int row1) {
cell1.setRow(row1);
}
+ @Override
public int getRow2() {
return getCell2().getRow();
}
/**
* @throws NullPointerException if cell2 is null (fixed size)
- * @see org.apache.poi.ss.usermodel.ClientAnchor#setRow2(int)
*/
+ @Override
public void setRow2(int row2) {
cell2.setRow(row2);
}
+ @Override
public int getDx1() {
return Math.toIntExact(POIXMLUnits.parseLength(getCell1().xgetColOff()));
}
@@ -264,10 +267,12 @@ public class XSSFClientAnchor extends XSSFAnchor implements ClientAnchor {
* @throws NullPointerException if cell1 is null (fixed position)
* @see org.apache.poi.ss.usermodel.ChildAnchor#setDx1(int)
*/
+ @Override
public void setDx1(int dx1) {
cell1.setColOff(dx1);
}
+ @Override
public int getDy1() {
return Math.toIntExact(POIXMLUnits.parseLength(getCell1().xgetRowOff()));
}
@@ -276,10 +281,12 @@ public class XSSFClientAnchor extends XSSFAnchor implements ClientAnchor {
* @throws NullPointerException if cell1 is null (fixed position)
* @see org.apache.poi.ss.usermodel.ChildAnchor#setDy1(int)
*/
+ @Override
public void setDy1(int dy1) {
cell1.setRowOff(dy1);
}
+ @Override
public int getDy2() {
return Math.toIntExact(POIXMLUnits.parseLength(getCell2().xgetRowOff()));
}
@@ -288,10 +295,12 @@ public class XSSFClientAnchor extends XSSFAnchor implements ClientAnchor {
* @throws NullPointerException if cell2 is null (fixed size)
* @see org.apache.poi.ss.usermodel.ChildAnchor#setDy2(int)
*/
+ @Override
public void setDy2(int dy2) {
cell2.setRowOff(dy2);
}
+ @Override
public int getDx2() {
return Math.toIntExact(POIXMLUnits.parseLength(getCell2().xgetColOff()));
}
@@ -300,13 +309,14 @@ public class XSSFClientAnchor extends XSSFAnchor implements ClientAnchor {
* @throws NullPointerException if cell2 is null (fixed size)
* @see org.apache.poi.ss.usermodel.ChildAnchor#setDx2(int)
*/
+ @Override
public void setDx2(int dx2) {
cell2.setColOff(dx2);
}
@Override
public boolean equals(Object o) {
- if (o == null || !(o instanceof XSSFClientAnchor)) return false;
+ if (!(o instanceof XSSFClientAnchor)) return false;
XSSFClientAnchor anchor = (XSSFClientAnchor) o;
return getDx1() == anchor.getDx1() &&
@@ -369,7 +379,6 @@ public class XSSFClientAnchor extends XSSFAnchor implements ClientAnchor {
/**
* Sets the top-left absolute position of the object. To use this, "from" must be set to null.
- * @param position
* @since POI 3.17 beta 1
*/
public void setPosition(CTPoint2D position) {
@@ -387,7 +396,6 @@ public class XSSFClientAnchor extends XSSFAnchor implements ClientAnchor {
/**
* Sets the size of the object. To use this, "to" must be set to null.
- * @param size
* @since POI 3.17 beta 1
*/
public void setSize(CTPositiveSize2D size) {
diff --git a/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFConditionalFormattingRule.java b/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFConditionalFormattingRule.java
index 829acbbd30..a6f21e5e7b 100644
--- a/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFConditionalFormattingRule.java
+++ b/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFConditionalFormattingRule.java
@@ -51,10 +51,10 @@ import org.openxmlformats.schemas.spreadsheetml.x2006.main.STIconSetType;
*/
public class XSSFConditionalFormattingRule implements ConditionalFormattingRule {
private final CTCfRule _cfRule;
- private XSSFSheet _sh;
+ private final XSSFSheet _sh;
- private static Mapnull
.
+ * @return - border formatting object, never returns {@code null}.
*/
+ @Override
public XSSFBorderFormatting createBorderFormatting(){
CTDxf dxf = getDxf(true);
CTBorder border;
@@ -155,8 +157,9 @@ public class XSSFConditionalFormattingRule implements ConditionalFormattingRule
}
/**
- * @return - border formatting object if defined, null
otherwise
+ * @return - border formatting object if defined, {@code null} otherwise
*/
+ @Override
public XSSFBorderFormatting getBorderFormatting(){
CTDxf dxf = getDxf(false);
if(dxf == null || !dxf.isSetBorder()) return null;
@@ -168,8 +171,9 @@ public class XSSFConditionalFormattingRule implements ConditionalFormattingRule
* Create a new font formatting structure if it does not exist,
* otherwise just return existing object.
*
- * @return - font formatting object, never returns null
.
+ * @return - font formatting object, never returns {@code null}.
*/
+ @Override
public XSSFFontFormatting createFontFormatting(){
CTDxf dxf = getDxf(true);
CTFont font;
@@ -183,8 +187,9 @@ public class XSSFConditionalFormattingRule implements ConditionalFormattingRule
}
/**
- * @return - font formatting object if defined, null
otherwise
+ * @return - font formatting object if defined, {@code null} otherwise
*/
+ @Override
public XSSFFontFormatting getFontFormatting(){
CTDxf dxf = getDxf(false);
if(dxf == null || !dxf.isSetFont()) return null;
@@ -196,8 +201,9 @@ public class XSSFConditionalFormattingRule implements ConditionalFormattingRule
* Create a new pattern formatting structure if it does not exist,
* otherwise just return existing object.
*
- * @return - pattern formatting object, never returns null
.
+ * @return - pattern formatting object, never returns {@code null}.
*/
+ @Override
public XSSFPatternFormatting createPatternFormatting(){
CTDxf dxf = getDxf(true);
CTFill fill;
@@ -211,8 +217,9 @@ public class XSSFConditionalFormattingRule implements ConditionalFormattingRule
}
/**
- * @return - pattern formatting object if defined, null
otherwise
+ * @return - pattern formatting object if defined, {@code null} otherwise
*/
+ @Override
public XSSFPatternFormatting getPatternFormatting(){
CTDxf dxf = getDxf(false);
if(dxf == null || !dxf.isSetFill()) return null;
@@ -221,8 +228,6 @@ public class XSSFConditionalFormattingRule implements ConditionalFormattingRule
}
/**
- *
- * @param color
* @return data bar formatting
*/
public XSSFDataBarFormatting createDataBarFormatting(XSSFColor color) {
@@ -234,12 +239,7 @@ public class XSSFConditionalFormattingRule implements ConditionalFormattingRule
_cfRule.setType(STCfType.DATA_BAR);
// Ensure the right element
- CTDataBar bar = null;
- if (_cfRule.isSetDataBar()) {
- bar = _cfRule.getDataBar();
- } else {
- bar = _cfRule.addNewDataBar();
- }
+ CTDataBar bar = _cfRule.isSetDataBar() ? _cfRule.getDataBar() : _cfRule.addNewDataBar();
// Set the color
bar.setColor(color.getCTColor());
@@ -252,6 +252,7 @@ public class XSSFConditionalFormattingRule implements ConditionalFormattingRule
// Wrap and return
return new XSSFDataBarFormatting(bar, _sh.getWorkbook().getStylesSource().getIndexedColors());
}
+ @Override
public XSSFDataBarFormatting getDataBarFormatting() {
if (_cfRule.isSetDataBar()) {
CTDataBar bar = _cfRule.getDataBar();
@@ -270,12 +271,7 @@ public class XSSFConditionalFormattingRule implements ConditionalFormattingRule
_cfRule.setType(STCfType.ICON_SET);
// Ensure the right element
- CTIconSet icons = null;
- if (_cfRule.isSetIconSet()) {
- icons = _cfRule.getIconSet();
- } else {
- icons = _cfRule.addNewIconSet();
- }
+ CTIconSet icons = _cfRule.isSetIconSet() ? _cfRule.getIconSet() : _cfRule.addNewIconSet();
// Set the type of the icon set
if (iconSet.name != null) {
STIconSetType.Enum xIconSet = STIconSetType.Enum.forString(iconSet.name);
@@ -294,6 +290,7 @@ public class XSSFConditionalFormattingRule implements ConditionalFormattingRule
// Wrap and return
return new XSSFIconMultiStateFormatting(icons);
}
+ @Override
public XSSFIconMultiStateFormatting getMultiStateFormatting() {
if (_cfRule.isSetIconSet()) {
CTIconSet icons = _cfRule.getIconSet();
@@ -312,12 +309,7 @@ public class XSSFConditionalFormattingRule implements ConditionalFormattingRule
_cfRule.setType(STCfType.COLOR_SCALE);
// Ensure the right element
- CTColorScale scale = null;
- if (_cfRule.isSetColorScale()) {
- scale = _cfRule.getColorScale();
- } else {
- scale = _cfRule.addNewColorScale();
- }
+ CTColorScale scale = _cfRule.isSetColorScale() ? _cfRule.getColorScale() : _cfRule.addNewColorScale();
// Add a default set of thresholds and colors
if (scale.sizeOfCfvoArray() == 0) {
@@ -338,6 +330,7 @@ public class XSSFConditionalFormattingRule implements ConditionalFormattingRule
// Wrap and return
return new XSSFColorScaleFormatting(scale, _sh.getWorkbook().getStylesSource().getIndexedColors());
}
+ @Override
public XSSFColorScaleFormatting getColorScaleFormatting() {
if (_cfRule.isSetColorScale()) {
CTColorScale scale = _cfRule.getColorScale();
@@ -349,8 +342,8 @@ public class XSSFConditionalFormattingRule implements ConditionalFormattingRule
/**
* Return the number format from the dxf style record if present, null if not
- * @see org.apache.poi.ss.usermodel.ConditionalFormattingRule#getNumberFormat()
*/
+ @Override
public ExcelNumberFormat getNumberFormat() {
CTDxf dxf = getDxf(false);
if(dxf == null || !dxf.isSetNumFmt()) return null;
@@ -369,12 +362,13 @@ public class XSSFConditionalFormattingRule implements ConditionalFormattingRule
/**
* Will return null if {@link #getConditionType()} != {@link ConditionType#FILTER}
- * @see org.apache.poi.ss.usermodel.ConditionalFormattingRule#getConditionFilterType()
*/
+ @Override
public ConditionFilterType getConditionFilterType() {
return filterTypeLookup.get(_cfRule.getType());
}
+ @Override
public ConditionFilterData getFilterConfiguration() {
return new XSSFConditionFilterData(_cfRule);
}
@@ -384,7 +378,6 @@ public class XSSFConditionalFormattingRule implements ConditionalFormattingRule
* {@link ConditionType#CELL_VALUE_IS}
* * MUST be a constant from {@link org.apache.poi.ss.usermodel.ComparisonOperator} - *
* * @return the conditional format operator */ @@ -413,13 +406,12 @@ public class XSSFConditionalFormattingRule implements ConditionalFormattingRule * this field is the first operand of the comparison. * If type is {@link ConditionType#FORMULA}, this formula is used * to determine if the conditional formatting is applied. - * ** If comparison type is {@link ConditionType#FORMULA} the formula MUST be a Boolean function - *
* * @return the first formula */ + @Override public String getFormula1(){ return _cfRule.sizeOfFormulaArray() > 0 ? _cfRule.getFormulaArray(0) : null; } @@ -431,10 +423,12 @@ public class XSSFConditionalFormattingRule implements ConditionalFormattingRule * * @return the second formula */ + @Override public String getFormula2(){ return _cfRule.sizeOfFormulaArray() == 2 ? _cfRule.getFormulaArray(1) : null; } + @Override public String getText() { return _cfRule.getText(); } @@ -443,6 +437,7 @@ public class XSSFConditionalFormattingRule implements ConditionalFormattingRule * Conditional format rules don't define stripes, so always 0 * @see org.apache.poi.ss.usermodel.DifferentialStyleProvider#getStripeSize() */ + @Override public int getStripeSize() { return 0; } diff --git a/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFConnector.java b/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFConnector.java index 6624d0aa27..f1d3ba8b38 100644 --- a/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFConnector.java +++ b/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFConnector.java @@ -42,7 +42,7 @@ public final class XSSFConnector extends XSSFShape { private static CTConnector prototype; - private CTConnector ctShape; + private final CTConnector ctShape; /** * Construct a new XSSFConnector object. @@ -128,6 +128,7 @@ public final class XSSFConnector extends XSSFShape { ctShape.getSpPr().getPrstGeom().setPrst(STShapeType.Enum.forInt(type)); } + @Override protected CTShapeProperties getShapeProperties(){ return ctShape.getSpPr(); } diff --git a/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFDataValidationConstraint.java b/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFDataValidationConstraint.java index 3dc04c2ed3..396b01d05c 100644 --- a/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFDataValidationConstraint.java +++ b/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFDataValidationConstraint.java @@ -36,7 +36,7 @@ public class XSSFDataValidationConstraint implements DataValidationConstraint { private String formula1; private String formula2; - private int validationType = -1; + private final int validationType; private int operator = -1; private String[] explicitListOfValues; @@ -73,10 +73,8 @@ public class XSSFDataValidationConstraint implements DataValidationConstraint { /** * This is the constructor called using the OOXML raw data. Excel overloads formula1 to also encode explicit value lists, * so this constructor has to check for and parse that syntax. - * @param validationType - * @param operator * @param formula1 Overloaded: formula1 or list of explicit values - * @param formula2 (formula1 is a list of explicit values, this is ignored: usenull
)
+ * @param formula2 (formula1 is a list of explicit values, this is ignored: use {@code null})
*/
public XSSFDataValidationConstraint(int validationType, int operator, String formula1, String formula2) {
super();
@@ -101,6 +99,7 @@ public class XSSFDataValidationConstraint implements DataValidationConstraint {
/* (non-Javadoc)
* @see org.apache.poi.ss.usermodel.DataValidationConstraint#getExplicitListValues()
*/
+ @Override
public String[] getExplicitListValues() {
return explicitListOfValues;
}
@@ -108,6 +107,7 @@ public class XSSFDataValidationConstraint implements DataValidationConstraint {
/* (non-Javadoc)
* @see org.apache.poi.ss.usermodel.DataValidationConstraint#getFormula1()
*/
+ @Override
public String getFormula1() {
return formula1;
}
@@ -115,6 +115,7 @@ public class XSSFDataValidationConstraint implements DataValidationConstraint {
/* (non-Javadoc)
* @see org.apache.poi.ss.usermodel.DataValidationConstraint#getFormula2()
*/
+ @Override
public String getFormula2() {
return formula2;
}
@@ -122,6 +123,7 @@ public class XSSFDataValidationConstraint implements DataValidationConstraint {
/* (non-Javadoc)
* @see org.apache.poi.ss.usermodel.DataValidationConstraint#getOperator()
*/
+ @Override
public int getOperator() {
return operator;
}
@@ -129,6 +131,7 @@ public class XSSFDataValidationConstraint implements DataValidationConstraint {
/* (non-Javadoc)
* @see org.apache.poi.ss.usermodel.DataValidationConstraint#getValidationType()
*/
+ @Override
public int getValidationType() {
return validationType;
}
@@ -136,6 +139,7 @@ public class XSSFDataValidationConstraint implements DataValidationConstraint {
/* (non-Javadoc)
* @see org.apache.poi.ss.usermodel.DataValidationConstraint#setExplicitListValues(java.lang.String[])
*/
+ @Override
public void setExplicitListValues(String[] explicitListValues) {
this.explicitListOfValues = explicitListValues;
@@ -143,8 +147,7 @@ public class XSSFDataValidationConstraint implements DataValidationConstraint {
// further, Excel has no escaping for commas in explicit lists, so we don't need to worry about that.
if ( explicitListOfValues!=null && explicitListOfValues.length > 0 ) {
StringBuilder builder = new StringBuilder(QUOTE);
- for (int i = 0; i < explicitListValues.length; i++) {
- String string = explicitListValues[i];
+ for (String string : explicitListValues) {
if (builder.length() > 1) {
builder.append(LIST_SEPARATOR);
}
@@ -158,6 +161,7 @@ public class XSSFDataValidationConstraint implements DataValidationConstraint {
/* (non-Javadoc)
* @see org.apache.poi.ss.usermodel.DataValidationConstraint#setFormula1(java.lang.String)
*/
+ @Override
public void setFormula1(String formula1) {
this.formula1 = removeLeadingEquals(formula1);
}
@@ -182,6 +186,7 @@ public class XSSFDataValidationConstraint implements DataValidationConstraint {
/* (non-Javadoc)
* @see org.apache.poi.ss.usermodel.DataValidationConstraint#setFormula2(java.lang.String)
*/
+ @Override
public void setFormula2(String formula2) {
this.formula2 = removeLeadingEquals(formula2);
}
@@ -189,6 +194,7 @@ public class XSSFDataValidationConstraint implements DataValidationConstraint {
/* (non-Javadoc)
* @see org.apache.poi.ss.usermodel.DataValidationConstraint#setOperator(int)
*/
+ @Override
public void setOperator(int operator) {
this.operator = operator;
}
diff --git a/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFDxfStyleProvider.java b/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFDxfStyleProvider.java
index 72fe8959a5..f161e8f65c 100644
--- a/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFDxfStyleProvider.java
+++ b/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFDxfStyleProvider.java
@@ -38,9 +38,7 @@ public class XSSFDxfStyleProvider implements DifferentialStyleProvider {
private final int stripeSize;
/**
- * @param dxf
* @param stripeSize 0 for non-stripe styles, > 1 for stripes
- * @param colorMap
*/
public XSSFDxfStyleProvider(CTDxf dxf, int stripeSize, IndexedColorMap colorMap) {
this.stripeSize = stripeSize;
@@ -63,22 +61,27 @@ public class XSSFDxfStyleProvider implements DifferentialStyleProvider {
}
}
+ @Override
public BorderFormatting getBorderFormatting() {
return border;
}
+ @Override
public FontFormatting getFontFormatting() {
return font;
}
+ @Override
public ExcelNumberFormat getNumberFormat() {
return number;
}
+ @Override
public PatternFormatting getPatternFormatting() {
return fill;
}
+ @Override
public int getStripeSize() {
return stripeSize;
}
diff --git a/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFEvaluationSheet.java b/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFEvaluationSheet.java
index 18b663c2b3..53b9276751 100644
--- a/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFEvaluationSheet.java
+++ b/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFEvaluationSheet.java
@@ -51,17 +51,18 @@ final class XSSFEvaluationSheet implements EvaluationSheet {
public int getLastRowNum() {
return _xs.getLastRowNum();
}
-
+
/* (non-Javadoc)
* @see org.apache.poi.ss.formula.EvaluationSheet#isRowHidden(int)
* @since POI 4.1.0
*/
+ @Override
public boolean isRowHidden(int rowIndex) {
final XSSFRow row = _xs.getRow(rowIndex);
if (row == null) return false;
return row.getZeroHeight();
}
-
+
/* (non-JavaDoc), inherit JavaDoc from EvaluationWorkbook
* @since POI 3.15 beta 3
*/
@@ -69,7 +70,7 @@ final class XSSFEvaluationSheet implements EvaluationSheet {
public void clearAllCachedResultValues() {
_cellCache = null;
}
-
+
@Override
public EvaluationCell getCell(int rowIndex, int columnIndex) {
// shortcut evaluation if reference is outside the bounds of existing data
@@ -91,10 +92,10 @@ final class XSSFEvaluationSheet implements EvaluationSheet {
}
}
}
-
+
final CellKey key = new CellKey(rowIndex, columnIndex);
EvaluationCell evalcell = _cellCache.get(key);
-
+
// If cache is stale, update cache with this one cell
// This is a compromise between rebuilding the entire cache
// (which would quickly defeat the benefit of the cache)
@@ -115,17 +116,17 @@ final class XSSFEvaluationSheet implements EvaluationSheet {
return evalcell;
}
-
+
private static class CellKey {
private final int _row;
private final int _col;
private int _hash = -1; //lazily computed
-
+
protected CellKey(int row, int col) {
_row = row;
_col = col;
}
-
+
@Override
public int hashCode() {
if ( _hash == -1 ) {
@@ -133,7 +134,7 @@ final class XSSFEvaluationSheet implements EvaluationSheet {
}
return _hash;
}
-
+
@Override
public boolean equals(Object obj) {
if (!(obj instanceof CellKey)) {
diff --git a/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFEvenFooter.java b/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFEvenFooter.java
index 8234793c3e..8e27980b78 100644
--- a/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFEvenFooter.java
+++ b/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFEvenFooter.java
@@ -23,32 +23,31 @@ import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTHeaderFooter;
/**
* - * Even page footer value. Corresponds to even printed pages. - * Even page(s) in the sheet may not be printed, for example, if the print area is specified to be - * a range such that it falls outside an even page's scope. - * If no even footer is specified, then the odd footer's value is assumed for even page footers. + * Even page footer value. Corresponds to even printed pages. + * Even page(s) in the sheet may not be printed, for example, if the print area is specified to be + * a range such that it falls outside an even page's scope. + * If no even footer is specified, then the odd footer's value is assumed for even page footers. *
* The even footer is activated by the "Different Even/Odd" Header/Footer property for the sheet. * If this property is not set, the even footer is ignored, and the odd footer is used instead. *
* Creating an even header or footer sets this property by default, so all you need to do to * get an even header or footer to display is to create one. Likewise, if both the even header - * and footer are usnset, then this property is unset, and the odd header and footer are used + * and footer are usnset, then this property is unset, and the odd header and footer are used * for even pages. *
*/ public class XSSFEvenFooter extends XSSFHeaderFooter implements Footer{ - + /** * Create an instance of XSSFEvenFooter from the supplied XML bean * @see XSSFSheet#getEvenFooter() - * @param headerFooter */ protected XSSFEvenFooter(CTHeaderFooter headerFooter) { super(headerFooter); headerFooter.setDifferentOddEven(true); } - + /** * Get the content text representing the footer * @return text @@ -57,14 +56,14 @@ public class XSSFEvenFooter extends XSSFHeaderFooter implements Footer{ public String getText() { return getHeaderFooter().getEvenFooter(); } - + /** * Set a text for the footer. If null, unset the value. If unsetting and there is no * Even Header for this sheet, the "DifferentEvenOdd" property for this sheet is * unset. - * + * * @see XSSFHeaderFooter to see how to create a string with Header/Footer Formatting Syntax - * @param text - a string representing the footer. + * @param text - a string representing the footer. */ @Override public void setText(String text) { diff --git a/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFEvenHeader.java b/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFEvenHeader.java index dfd9d179b8..45600cfc9d 100644 --- a/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFEvenHeader.java +++ b/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFEvenHeader.java @@ -42,9 +42,8 @@ public class XSSFEvenHeader extends XSSFHeaderFooter implements Header { /** * Create an instance of XSSFEvenHeader from the supplied XML bean. If an even * header is created, The property "DifferentOddEven" is set for this sheet as well. - * + * * @see XSSFSheet#getEvenHeader() - * @param headerFooter */ protected XSSFEvenHeader(CTHeaderFooter headerFooter) { super(headerFooter); @@ -53,7 +52,7 @@ public class XSSFEvenHeader extends XSSFHeaderFooter implements Header { /** * Get the content text representing this header - * + * * @return text */ @Override @@ -65,7 +64,7 @@ public class XSSFEvenHeader extends XSSFHeaderFooter implements Header { * Set a text for the header. If null, unset the value. If unsetting and there is no * Even Footer for this sheet, the "DifferentEvenOdd" property for this sheet is * unset. - * + * * @see XSSFHeaderFooter to see how to create a string with Header/Footer * Formatting Syntax * @param text diff --git a/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFFirstFooter.java b/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFFirstFooter.java index 4bccf9ef1e..3ce5cd5dd9 100644 --- a/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFFirstFooter.java +++ b/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFFirstFooter.java @@ -23,8 +23,8 @@ import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTHeaderFooter; /** *- * First page footer content. Corresponds to first printed page. - * The first logical page in the sheet may not be printed, for example, if the print area is specified to + * First page footer content. Corresponds to first printed page. + * The first logical page in the sheet may not be printed, for example, if the print area is specified to * be a range such that it falls outside the first page's scope. *
* The first page footer is activated by the "Different First" Header/Footer property for the sheet. @@ -41,13 +41,12 @@ public class XSSFFirstFooter extends XSSFHeaderFooter implements Footer{ /** * Create an instance of XSSFFirstFooter from the supplied XML bean * @see XSSFSheet#getFirstFooter() - * @param headerFooter */ protected XSSFFirstFooter(CTHeaderFooter headerFooter) { super(headerFooter); headerFooter.setDifferentFirst(true); } - + /** * Get the content text representing the footer * @return text @@ -56,13 +55,13 @@ public class XSSFFirstFooter extends XSSFHeaderFooter implements Footer{ public String getText() { return getHeaderFooter().getFirstFooter(); } - + /** - * Set a text for the footer. If null unset the value. If unsetting this header results + * Set a text for the footer. If null unset the value. If unsetting this header results * in no First Header, or footer for the sheet, the 'differentFirst' property is unset as well. - * + * * @see XSSFHeaderFooter to see how to create a string with Header/Footer Formatting Syntax - * @param text - a string representing the footer. + * @param text - a string representing the footer. */ @Override public void setText(String text) { diff --git a/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFFirstHeader.java b/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFFirstHeader.java index 4cb2254d2f..9d7d69c370 100644 --- a/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFFirstHeader.java +++ b/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFFirstHeader.java @@ -22,32 +22,29 @@ import org.apache.poi.xssf.usermodel.extensions.XSSFHeaderFooter; import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTHeaderFooter; /** - *
* First page header content. Corresponds to first printed page. - * The first logical page in the sheet may not be printed, for example, if the print area is specified to + * The first logical page in the sheet may not be printed, for example, if the print area is specified to * be a range such that it falls outside the first page's scope. - *
+ *
* The first page header is activated by the "Different First" Header/Footer property for the sheet. * If this property is not set, the first page header is ignored. - *
+ *
* Creating a first page header or footer sets this property by default, so all you need to do to * get an first page header or footer to display is to create one. Likewise, if both the first page * header and footer are usnset, then this property is unset, and the first page header and footer * are ignored. - *
*/ public class XSSFFirstHeader extends XSSFHeaderFooter implements Header{ /** * Create an instance of XSSFFirstHeader from the supplied XML bean * @see XSSFSheet#getFirstHeader() - * @param headerFooter */ protected XSSFFirstHeader(CTHeaderFooter headerFooter) { super(headerFooter); headerFooter.setDifferentFirst(true); } - + /** * Get the content text representing this header * @return text @@ -56,13 +53,13 @@ public class XSSFFirstHeader extends XSSFHeaderFooter implements Header{ public String getText() { return getHeaderFooter().getFirstHeader(); } - + /** - * Set a text for the header. If null unset the value. If unsetting this header results + * Set a text for the header. If null unset the value. If unsetting this header results * in no First Header, or footer for the sheet, the 'differentFirst' property is unset as well. - * + * * @see XSSFHeaderFooter to see how to create a string with Header/Footer Formatting Syntax - * @param text - a string representing the header. + * @param text - a string representing the header. */ @Override public void setText(String text) { diff --git a/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFFont.java b/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFFont.java index 02bfd2e9de..b39e8b7b1e 100644 --- a/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFFont.java +++ b/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFFont.java @@ -64,7 +64,7 @@ public class XSSFFont implements Font { private IndexedColorMap _indexedColorMap; private ThemesTable _themes; - private CTFont _ctFont; + private final CTFont _ctFont; private int _index; /** @@ -113,6 +113,7 @@ public class XSSFFont implements Font { * * @return boolean - bold */ + @Override public boolean getBold() { CTBooleanProperty bold = _ctFont.sizeOfBArray() == 0 ? null : _ctFont.getBArray(0); return (bold != null && bold.getVal()); @@ -124,6 +125,7 @@ public class XSSFFont implements Font { * @return int - character-set (0-255) * @see FontCharset */ + @Override public int getCharSet() { CTIntProperty charset = _ctFont.sizeOfCharsetArray() == 0 ? null : _ctFont.getCharsetArray(0); return charset == null ? FontCharset.ANSI.getNativeId() : FontCharset.valueOf(charset.getVal()).getNativeId(); @@ -137,6 +139,7 @@ public class XSSFFont implements Font { * @return short - indexed color to use * @see IndexedColors */ + @Override public short getColor() { CTColor color = _ctFont.sizeOfColorArray() == 0 ? null : _ctFont.getColorArray(0); if (color == null) return IndexedColors.BLACK.getIndex(); @@ -194,6 +197,7 @@ public class XSSFFont implements Font { * @return short - height in 1/20ths of a point * @see #getFontHeightInPoints() */ + @Override public short getFontHeight() { return (short)(getFontHeightRaw()*Font.TWIPS_PER_POINT); } @@ -206,6 +210,7 @@ public class XSSFFont implements Font { * @return short - height in the familiar unit of measure - points * @see #getFontHeight() */ + @Override public short getFontHeightInPoints() { return (short)getFontHeightRaw(); } @@ -227,6 +232,7 @@ public class XSSFFont implements Font { * * @return String - a string representing the name of the font to use */ + @Override public String getFontName() { CTFontName name = _ctFont.sizeOfNameArray() == 0 ? null : _ctFont.getNameArray(0); return name == null ? DEFAULT_FONT_NAME : name.getVal(); @@ -237,6 +243,7 @@ public class XSSFFont implements Font { * * @return boolean - value for italic */ + @Override public boolean getItalic() { CTBooleanProperty italic = _ctFont.sizeOfIArray() == 0 ? null : _ctFont.getIArray(0); return italic != null && italic.getVal(); @@ -247,6 +254,7 @@ public class XSSFFont implements Font { * * @return boolean - value for strikeout */ + @Override public boolean getStrikeout() { CTBooleanProperty strike = _ctFont.sizeOfStrikeArray() == 0 ? null : _ctFont.getStrikeArray(0); return strike != null && strike.getVal(); @@ -260,6 +268,7 @@ public class XSSFFont implements Font { * @see Font#SS_SUPER * @see Font#SS_SUB */ + @Override public short getTypeOffset() { CTVerticalAlignFontProperty vAlign = _ctFont.sizeOfVertAlignArray() == 0 ? null : _ctFont.getVertAlignArray(0); if (vAlign == null) { @@ -284,6 +293,7 @@ public class XSSFFont implements Font { * @return byte - underlining type * @see org.apache.poi.ss.usermodel.FontUnderline */ + @Override public byte getUnderline() { CTUnderlineProperty underline = _ctFont.sizeOfUArray() == 0 ? null : _ctFont.getUArray(0); if (underline != null) { @@ -298,6 +308,7 @@ public class XSSFFont implements Font { * * @param bold - boldness to use */ + @Override public void setBold(boolean bold) { if(bold){ CTBooleanProperty ctBold = _ctFont.sizeOfBArray() == 0 ? _ctFont.addNewB() : _ctFont.getBArray(0); @@ -313,6 +324,7 @@ public class XSSFFont implements Font { * @param charset - charset * @see FontCharset */ + @Override public void setCharSet(byte charset) { int cs = charset & 0xff; setCharSet(cs); @@ -324,6 +336,7 @@ public class XSSFFont implements Font { * @param charset - charset * @see FontCharset */ + @Override public void setCharSet(int charset) { FontCharset fontCharset = FontCharset.valueOf(charset); if(fontCharset != null) { @@ -336,7 +349,6 @@ public class XSSFFont implements Font { /** * set character-set to use. * - * @param charSet * @deprecated use {@link #setCharSet(FontCharset)} instead */ @Deprecated @@ -356,7 +368,6 @@ public class XSSFFont implements Font { /** * set character-set to use. * - * @param charSet * @since 5.0.0 */ public void setCharSet(FontCharset charSet) { @@ -378,6 +389,7 @@ public class XSSFFont implements Font { * @see #DEFAULT_FONT_COLOR - Note: default font color * @see IndexedColors */ + @Override public void setColor(short color) { CTColor ctColor = _ctFont.sizeOfColorArray() == 0 ? _ctFont.addNewColor() : _ctFont.getColorArray(0); switch (color) { @@ -415,6 +427,7 @@ public class XSSFFont implements Font { * * @param height - height in points */ + @Override public void setFontHeight(short height) { setFontHeight((double) height/Font.TWIPS_PER_POINT); } @@ -434,6 +447,7 @@ public class XSSFFont implements Font { * * @see #setFontHeight */ + @Override public void setFontHeightInPoints(short height) { setFontHeight((double)height); } @@ -459,6 +473,7 @@ public class XSSFFont implements Font { * @param name - value representing the name of the font to use * @see #DEFAULT_FONT_NAME */ + @Override public void setFontName(String name) { CTFontName fontName = _ctFont.sizeOfNameArray() == 0 ? _ctFont.addNewName() : _ctFont.getNameArray(0); fontName.setVal(name == null ? DEFAULT_FONT_NAME : name); @@ -471,6 +486,7 @@ public class XSSFFont implements Font { * * @param italic - value for italics or not */ + @Override public void setItalic(boolean italic) { if(italic){ CTBooleanProperty bool = _ctFont.sizeOfIArray() == 0 ? _ctFont.addNewI() : _ctFont.getIArray(0); @@ -487,6 +503,7 @@ public class XSSFFont implements Font { * * @param strikeout - value for strikeout or not */ + @Override public void setStrikeout(boolean strikeout) { if(strikeout) { CTBooleanProperty strike = _ctFont.sizeOfStrikeArray() == 0 ? _ctFont.addNewStrike() : _ctFont.getStrikeArray(0); @@ -506,15 +523,13 @@ public class XSSFFont implements Font { * @see #SS_SUPER * @see #SS_SUB */ + @Override public void setTypeOffset(short offset) { if(offset == Font.SS_NONE){ _ctFont.setVertAlignArray(null); } else { CTVerticalAlignFontProperty offsetProperty = _ctFont.sizeOfVertAlignArray() == 0 ? _ctFont.addNewVertAlign() : _ctFont.getVertAlignArray(0); switch (offset) { - case Font.SS_NONE: - offsetProperty.setVal(STVerticalAlignRun.BASELINE); - break; case Font.SS_SUB: offsetProperty.setVal(STVerticalAlignRun.SUBSCRIPT); break; @@ -534,6 +549,7 @@ public class XSSFFont implements Font { * @param underline - underline type to use * @see FontUnderline */ + @Override public void setUnderline(byte underline) { setUnderline(FontUnderline.valueOf(underline)); } diff --git a/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFFormulaEvaluator.java b/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFFormulaEvaluator.java index ccd1799955..6a6e6e1a52 100644 --- a/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFFormulaEvaluator.java +++ b/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFFormulaEvaluator.java @@ -103,6 +103,7 @@ public final class XSSFFormulaEvaluator extends BaseXSSFFormulaEvaluator { /** * Turns a XSSFCell into a XSSFEvaluationCell */ + @Override protected EvaluationCell toEvaluationCell(Cell cell) { if (!(cell instanceof XSSFCell)){ throw new IllegalArgumentException("Unexpected type of cell: " + cell.getClass() + "." + diff --git a/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFGraphicFrame.java b/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFGraphicFrame.java index 2892e93f0d..9d53abd5dc 100644 --- a/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFGraphicFrame.java +++ b/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFGraphicFrame.java @@ -43,7 +43,7 @@ public final class XSSFGraphicFrame extends XSSFShape { private static CTGraphicalObjectFrame prototype; - private CTGraphicalObjectFrame graphicFrame; + private final CTGraphicalObjectFrame graphicFrame; /** * Construct a new XSSFGraphicFrame object. @@ -145,7 +145,8 @@ public final class XSSFGraphicFrame extends XSSFShape { * Returns the frame anchor. * @return the XSSFClientAnchor anchor this frame is attached to */ - public XSSFClientAnchor getAnchor() { + @Override + public XSSFClientAnchor getAnchor() { return (XSSFClientAnchor) anchor; } @@ -174,7 +175,7 @@ public final class XSSFGraphicFrame extends XSSFShape { /** * The low level code to insert {@codediff --git a/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFHeaderFooterProperties.java b/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFHeaderFooterProperties.java index af3f8c29fc..338d9b31f5 100644 --- a/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFHeaderFooterProperties.java +++ b/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFHeaderFooterProperties.java @@ -25,16 +25,14 @@ import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTHeaderFooter; * All Header/Footer properties for a sheet are scoped to the sheet. This includes Different First Page, * and Different Even/Odd. These properties can be set or unset explicitly in this class. Note that while * Scale With Document and Align With Margins default to unset, Different First, and Different Even/Odd - * are updated automatically as headers and footers are added and removed. + * are updated automatically as headers and footers are added and removed. * */ public class XSSFHeaderFooterProperties { - private CTHeaderFooter headerFooter; + private final CTHeaderFooter headerFooter; /** * Create an instance of XSSFHeaderFooterProperties from the supplied XML bean - * - * @param headerFooter */ public XSSFHeaderFooterProperties(CTHeaderFooter headerFooter) { this.headerFooter = headerFooter; @@ -54,58 +52,58 @@ public class XSSFHeaderFooterProperties { * returns alignWithMargins attribute */ public boolean getAlignWithMargins() { - return getHeaderFooter().isSetAlignWithMargins() ? getHeaderFooter().getAlignWithMargins() : false; + return getHeaderFooter().isSetAlignWithMargins() && getHeaderFooter().getAlignWithMargins(); } - + /** * returns differentFirst attribute */ public boolean getDifferentFirst() { - return getHeaderFooter().isSetDifferentFirst() ? getHeaderFooter().getDifferentFirst() : false; + return getHeaderFooter().isSetDifferentFirst() && getHeaderFooter().getDifferentFirst(); } - + /** * returns differentOddEven attribute */ public boolean getDifferentOddEven() { - return getHeaderFooter().isSetDifferentOddEven() ? getHeaderFooter().getDifferentOddEven() : false; + return getHeaderFooter().isSetDifferentOddEven() && getHeaderFooter().getDifferentOddEven(); } - + /** * returns scaleWithDoc attribute */ public boolean getScaleWithDoc() { - return getHeaderFooter().isSetScaleWithDoc() ? getHeaderFooter().getScaleWithDoc() : false; + return getHeaderFooter().isSetScaleWithDoc() && getHeaderFooter().getScaleWithDoc(); } - + /** * set alignWithMargins attribute */ public void setAlignWithMargins(boolean flag) { getHeaderFooter().setAlignWithMargins(flag); } - + /** * set differentFirst attribute */ public void setDifferentFirst(boolean flag) { getHeaderFooter().setDifferentFirst(flag); } - + /** * set differentOddEven attribute */ public void setDifferentOddEven(boolean flag) { getHeaderFooter().setDifferentOddEven(flag); } - + /** * set scaleWithDoc attribute */ public void setScaleWithDoc(boolean flag) { getHeaderFooter().setScaleWithDoc(flag); } - + /** * remove alignWithMargins attribute */ @@ -114,7 +112,7 @@ public class XSSFHeaderFooterProperties { getHeaderFooter().unsetAlignWithMargins(); } } - + /** * remove differentFirst attribute */ @@ -123,7 +121,7 @@ public class XSSFHeaderFooterProperties { getHeaderFooter().unsetDifferentFirst(); } } - + /** * remove differentOddEven attribute */ @@ -132,7 +130,7 @@ public class XSSFHeaderFooterProperties { getHeaderFooter().unsetDifferentOddEven(); } } - + /** * remove scaleWithDoc attribute */ diff --git a/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFLineBreak.java b/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFLineBreak.java index 99596992b9..0887656553 100644 --- a/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFLineBreak.java +++ b/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFLineBreak.java @@ -38,6 +38,7 @@ class XSSFLineBreak extends XSSFTextRun { /** * Always throws IllegalStateException. You cannot change text of a line break. */ + @Override public void setText(String text){ throw new IllegalStateException("You cannot change text of a line break, it is always '\\n'"); } diff --git a/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFOddFooter.java b/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFOddFooter.java index 1e2239d8d3..5cacff490e 100644 --- a/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFOddFooter.java +++ b/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFOddFooter.java @@ -23,7 +23,7 @@ import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTHeaderFooter; /** * Odd page footer value. Corresponds to odd printed pages. - * Odd page(s) in the sheet may not be printed, for example, if the print area is specified to be + * Odd page(s) in the sheet may not be printed, for example, if the print area is specified to be * a range such that it falls outside an odd page's scope. * */ @@ -32,12 +32,11 @@ public class XSSFOddFooter extends XSSFHeaderFooter implements Footer{ /** * Create an instance of XSSFOddFooter from the supplied XML bean * @see XSSFSheet#getOddFooter() - * @param headerFooter */ protected XSSFOddFooter(CTHeaderFooter headerFooter) { super(headerFooter); } - + /** * Get the content text representing the footer * @return text @@ -46,11 +45,11 @@ public class XSSFOddFooter extends XSSFHeaderFooter implements Footer{ public String getText() { return getHeaderFooter().getOddFooter(); } - + /** * Set a text for the footer. If null unset the value. * @see XSSFHeaderFooter to see how to create a string with Header/Footer Formatting Syntax - * @param text - a string representing the footer. + * @param text - a string representing the footer. */ @Override public void setText(String text) { diff --git a/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFOddHeader.java b/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFOddHeader.java index 1cce6e59be..d4133a94cd 100644 --- a/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFOddHeader.java +++ b/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFOddHeader.java @@ -22,8 +22,8 @@ import org.apache.poi.xssf.usermodel.extensions.XSSFHeaderFooter; import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTHeaderFooter; /** - * Odd page header value. Corresponds to odd printed pages. - * Odd page(s) in the sheet may not be printed, for example, if the print area is specified to be + * Odd page header value. Corresponds to odd printed pages. + * Odd page(s) in the sheet may not be printed, for example, if the print area is specified to be * a range such that it falls outside an odd page's scope. * */ @@ -32,12 +32,11 @@ public class XSSFOddHeader extends XSSFHeaderFooter implements Header{ /** * Create an instance of XSSFOddHeader from the supplied XML bean * @see XSSFSheet#getOddHeader() - * @param headerFooter */ protected XSSFOddHeader(CTHeaderFooter headerFooter) { super(headerFooter); } - + /** * Get the content text representing this header * @return text @@ -46,11 +45,11 @@ public class XSSFOddHeader extends XSSFHeaderFooter implements Header{ public String getText() { return getHeaderFooter().getOddHeader(); } - + /** * Set a text for the header. If null unset the value * @see XSSFHeaderFooter to see how to create a string with Header/Footer Formatting Syntax - * @param text - a string representing the header. + * @param text - a string representing the header. */ @Override public void setText(String text) { diff --git a/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFPicture.java b/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFPicture.java index a3fcd66719..077d21e2e4 100644 --- a/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFPicture.java +++ b/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFPicture.java @@ -46,7 +46,7 @@ import org.openxmlformats.schemas.drawingml.x2006.spreadsheetDrawing.CTPictureNo public final class XSSFPicture extends XSSFShape implements Picture { private static final Logger LOG = LogManager.getLogger(XSSFPicture.class); - /** + /* * Column width measured as the number of characters of the maximum digit width of the * numbers 0, 1, 2, ..., 9 as rendered in the normal style's font. There are 4 pixels of margin * padding (two on each side), plus 1 pixel padding for the gridlines. @@ -63,7 +63,7 @@ public final class XSSFPicture extends XSSFShape implements Picture { /** * This object specifies a picture object and all its properties */ - private CTPicture ctPicture; + private final CTPicture ctPicture; /** * Construct a new XSSFPicture object. This constructor is called from @@ -140,6 +140,7 @@ public final class XSSFPicture extends XSSFShape implements Picture { * * @see #resize(double, double) */ + @Override public void resize(){ resize(Double.MAX_VALUE); } @@ -149,6 +150,7 @@ public final class XSSFPicture extends XSSFShape implements Picture { * * @see #resize(double, double) */ + @Override public void resize(double scale) { resize(scale, scale); } @@ -159,19 +161,18 @@ public final class XSSFPicture extends XSSFShape implements Picture { * Please note, that this method works correctly only for workbooks * with the default font size (Calibri 11pt for .xlsx). * If the default font is changed the resized image can be streched vertically or horizontally. - * ** * and * - *- *
* * @param scaleX the amount by which the image width is multiplied relative to the original width, * when set to {@link Double#MAX_VALUE} the width of the embedded image is used * @param scaleY the amount by which the image height is multiplied relative to the original height, * when set to {@link Double#MAX_VALUE} the height of the embedded image is used */ + @Override public void resize(double scaleX, double scaleY){ XSSFClientAnchor anchor = getClientAnchor(); XSSFClientAnchor pref = getPreferredSize(scaleX,scaleY); @@ -197,6 +198,7 @@ public final class XSSFPicture extends XSSFShape implements Picture { * * @return XSSFClientAnchor with the preferred size for this image */ + @Override public XSSFClientAnchor getPreferredSize(){ return getPreferredSize(1); } @@ -218,6 +220,7 @@ public final class XSSFPicture extends XSSFShape implements Picture { * @param scaleY the amount by which image height is multiplied relative to the original height. * @return XSSFClientAnchor with the preferred size for this image */ + @Override public XSSFClientAnchor getPreferredSize(double scaleX, double scaleY){ Dimension dim = ImageUtils.setPreferredSize(this, scaleX, scaleY); CTPositiveSize2D size2d = ctPicture.getSpPr().getXfrm().getExt(); @@ -250,6 +253,7 @@ public final class XSSFPicture extends XSSFShape implements Picture { * * @return image dimension in pixels */ + @Override public Dimension getImageDimension() { XSSFPictureData picData = getPictureData(); return getImageDimension(picData.getPackagePart(), picData.getPictureType()); @@ -260,11 +264,13 @@ public final class XSSFPicture extends XSSFShape implements Picture { * * @return picture data for this shape */ + @Override public XSSFPictureData getPictureData() { String blipId = ctPicture.getBlipFill().getBlip().getEmbed(); return (XSSFPictureData)getDrawing().getRelationById(blipId); } + @Override protected CTShapeProperties getShapeProperties(){ return ctPicture.getSpPr(); } diff --git a/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFShape.java b/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFShape.java index 8f7489434c..caf3699fb3 100644 --- a/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFShape.java +++ b/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFShape.java @@ -125,8 +125,6 @@ public abstract class XSSFShape implements Shape { /** * Sets the line style. - * - * @param lineStyle */ public void setLineStyle( int lineStyle ) { CTShapeProperties props = getShapeProperties(); diff --git a/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFTable.java b/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFTable.java index f8b8486ac4..dfe5a51e59 100644 --- a/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFTable.java +++ b/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFTable.java @@ -32,14 +32,12 @@ import java.util.Locale; import org.apache.poi.ooxml.POIXMLDocumentPart; import org.apache.poi.openxml4j.opc.PackagePart; import org.apache.poi.ss.SpreadsheetVersion; -import org.apache.poi.ss.usermodel.CellType; import org.apache.poi.ss.usermodel.DataFormatter; import org.apache.poi.ss.usermodel.Table; import org.apache.poi.ss.usermodel.TableStyleInfo; import org.apache.poi.ss.util.AreaReference; import org.apache.poi.ss.util.CellReference; import org.apache.poi.util.Internal; -import org.apache.poi.util.Removal; import org.apache.poi.util.StringUtil; import org.apache.poi.xssf.usermodel.helpers.XSSFXmlColumnPr; import org.apache.xmlbeans.XmlException; @@ -358,6 +356,7 @@ public class XSSFTable extends POIXMLDocumentPart implements Table { /** * @return the name of the Table, if set */ + @Override public String getName() { if (name == null && ctTable.getName() != null) { setName(ctTable.getName()); @@ -383,6 +382,7 @@ public class XSSFTable extends POIXMLDocumentPart implements Table { * @return the table style name, if set * @since 3.17 beta 1 */ + @Override public String getStyleName() { if (styleName == null && ctTable.isSetTableStyleInfo()) { setStyleName(ctTable.getTableStyleInfo().getName()); @@ -628,7 +628,7 @@ public class XSSFTable extends POIXMLDocumentPart implements Table { * and {@link #getEndCellReference()}. * The next call to {@link #getStartCellReference()} and * {@link #getEndCellReference()} will synchronize the - * cell references with the underlyingresize(1.0,1.0)
keeps the original size,
- *resize(0.5,0.5)
resize to 50% of the original,
- *resize(2.0,2.0)
resizes to 200% of the original.
+ * {@code resize(1.0,1.0)} keeps the original size,
+ * {@code resize(0.5,0.5)} resize to 50% of the original,
+ * {@code resize(2.0,2.0)} resizes to 200% of the original.
*resize({@link Double#MAX_VALUE},{@link Double#MAX_VALUE})
resizes to the dimension of the embedded image. - *CTTable
. + * cell references with the underlying {@code CTTable}. * Thus this method is inexpensive. * * @since POI 3.15 beta 3 @@ -645,7 +645,7 @@ public class XSSFTable extends POIXMLDocumentPart implements Table { * {@linkplain #getTotalsRowCount() totals rows}. (Note: in this version * autofiltering is ignored) * - * Returns0
if the start or end cell references are not set. + * Returns {@code 0} if the start or end cell references are not set. * * Does not track updates to underlying changes to CTTable To synchronize * with changes to the underlying CTTable, call {@link #updateReferences()}. @@ -667,7 +667,7 @@ public class XSSFTable extends POIXMLDocumentPart implements Table { * Get the number of data rows in this table. This does not include any * header rows or totals rows. * - * Returns0
if the start or end cell references are not set. + * Returns {@code 0} if the start or end cell references are not set. * * Does not track updates to underlying changes to CTTable To synchronize * with changes to the underlying CTTable, call {@link #updateReferences()}. @@ -821,9 +821,9 @@ public class XSSFTable extends POIXMLDocumentPart implements Table { } /** - * Gets the relative column index of a column in this table having the header namecolumn
. + * Gets the relative column index of a column in this table having the header name {@code column}. * The column index is relative to the left-most column in the table, 0-indexed. - * Returns-1
ifcolumn
is not a header name in table. + * Returns {@code -1} if {@code column} is not a header name in table. * * Column Header names are case-insensitive * @@ -832,6 +832,7 @@ public class XSSFTable extends POIXMLDocumentPart implements Table { * * @since 3.15 beta 2 */ + @Override public int findColumnIndex(String columnHeader) { if (columnHeader == null) return -1; if (columnMap == null) { @@ -849,12 +850,13 @@ public class XSSFTable extends POIXMLDocumentPart implements Table { // Table column names with special characters need a single quote escape // but the escape is not present in the column definition Integer idx = columnMap.get(caseInsensitive(columnHeader.replace("'", ""))); - return idx == null ? -1 : idx.intValue(); + return idx == null ? -1 : idx; } /** * @since 3.15 beta 2 */ + @Override public String getSheetName() { return getXSSFSheet().getSheetName(); } @@ -866,6 +868,7 @@ public class XSSFTable extends POIXMLDocumentPart implements Table { * @since 3.15 beta 2 * @see #getTotalsRowCount() */ + @Override public boolean isHasTotalsRow() { return ctTable.getTotalsRowShown(); } @@ -876,6 +879,7 @@ public class XSSFTable extends POIXMLDocumentPart implements Table { * doesn't define how they would be implemented. * @since 3.17 beta 1 */ + @Override public int getTotalsRowCount() { return (int) ctTable.getTotalsRowCount(); } @@ -885,6 +889,7 @@ public class XSSFTable extends POIXMLDocumentPart implements Table { * Values > 1 might be used by Excel for pivot tables? * @since 3.17 beta 1 */ + @Override public int getHeaderRowCount() { return (int) ctTable.getHeaderRowCount(); } @@ -892,6 +897,7 @@ public class XSSFTable extends POIXMLDocumentPart implements Table { /** * @since 3.15 beta 2 */ + @Override public int getStartColIndex() { return getStartCellReference().getCol(); } @@ -899,6 +905,7 @@ public class XSSFTable extends POIXMLDocumentPart implements Table { /** * @since 3.15 beta 2 */ + @Override public int getStartRowIndex() { return getStartCellReference().getRow(); } @@ -906,6 +913,7 @@ public class XSSFTable extends POIXMLDocumentPart implements Table { /** * @since 3.15 beta 2 */ + @Override public int getEndColIndex() { return getEndCellReference().getCol(); } @@ -913,6 +921,7 @@ public class XSSFTable extends POIXMLDocumentPart implements Table { /** * @since 3.15 beta 2 */ + @Override public int getEndRowIndex() { return getEndCellReference().getRow(); } @@ -920,6 +929,7 @@ public class XSSFTable extends POIXMLDocumentPart implements Table { /** * @since 3.17 beta 1 */ + @Override public TableStyleInfo getStyle() { if (! ctTable.isSetTableStyleInfo()) return null; return new XSSFTableStyleInfo(((XSSFSheet) getParent()).getWorkbook().getStylesSource(), ctTable.getTableStyleInfo()); @@ -929,18 +939,16 @@ public class XSSFTable extends POIXMLDocumentPart implements Table { * @see org.apache.poi.ss.usermodel.Table#contains(org.apache.poi.ss.usermodel.Cell) * @since 3.17 beta 1 */ + @Override public boolean contains(CellReference cell) { if (cell == null) return false; // check if cell is on the same sheet as the table if ( ! getSheetName().equals(cell.getSheetName())) return false; // check if the cell is inside the table - if (cell.getRow() >= getStartRowIndex() + return cell.getRow() >= getStartRowIndex() && cell.getRow() <= getEndRowIndex() && cell.getCol() >= getStartColIndex() - && cell.getCol() <= getEndColIndex()) { - return true; - } - return false; + && cell.getCol() <= getEndColIndex(); } /** diff --git a/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFTableStyle.java b/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFTableStyle.java index 852f91c62d..6497f727b4 100644 --- a/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFTableStyle.java +++ b/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFTableStyle.java @@ -49,8 +49,6 @@ public class XSSFTableStyle implements TableStyle { /** * @param index style definition index or built-in ordinal depending on use - * @param dxfs - * @param tableStyle * @param colorMap indexed color map - default or custom * @see TableStyle#getIndex() */ @@ -99,10 +97,12 @@ public class XSSFTableStyle implements TableStyle { } } + @Override public String getName() { return name; } + @Override public int getIndex() { return index; } @@ -110,10 +110,12 @@ public class XSSFTableStyle implements TableStyle { /** * Always false for these, these are user defined styles */ + @Override public boolean isBuiltin() { return false; } + @Override public DifferentialStyleProvider getStyle(TableStyleType type) { return elementMap.get(type); } diff --git a/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFTableStyleInfo.java b/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFTableStyleInfo.java index fc515e6edb..39b7991e8f 100644 --- a/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFTableStyleInfo.java +++ b/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFTableStyleInfo.java @@ -33,11 +33,7 @@ public class XSSFTableStyleInfo implements TableStyleInfo { private boolean rowStripes; private boolean firstColumn; private boolean lastColumn; - - /** - * @param stylesTable - * @param tableStyleInfo - */ + public XSSFTableStyleInfo(StylesTable stylesTable, CTTableStyleInfo tableStyleInfo) { this.columnStripes = tableStyleInfo.getShowColumnStripes(); this.rowStripes = tableStyleInfo.getShowRowStripes(); @@ -48,6 +44,7 @@ public class XSSFTableStyleInfo implements TableStyleInfo { this.styleInfo = tableStyleInfo; } + @Override public boolean isShowColumnStripes() { return columnStripes; } @@ -56,6 +53,7 @@ public class XSSFTableStyleInfo implements TableStyleInfo { styleInfo.setShowColumnStripes(show); } + @Override public boolean isShowRowStripes() { return rowStripes; } @@ -64,6 +62,7 @@ public class XSSFTableStyleInfo implements TableStyleInfo { styleInfo.setShowRowStripes(show); } + @Override public boolean isShowFirstColumn() { return firstColumn; } @@ -72,6 +71,7 @@ public class XSSFTableStyleInfo implements TableStyleInfo { styleInfo.setShowFirstColumn(showFirstColumn); } + @Override public boolean isShowLastColumn() { return lastColumn; } @@ -80,6 +80,7 @@ public class XSSFTableStyleInfo implements TableStyleInfo { styleInfo.setShowLastColumn(showLastColumn); } + @Override public String getName() { return style.getName(); } @@ -88,6 +89,7 @@ public class XSSFTableStyleInfo implements TableStyleInfo { style = stylesTable.getTableStyle(name); } + @Override public TableStyle getStyle() { return style; } diff --git a/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFTextRun.java b/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFTextRun.java index 1809e16cd5..0dfa82149e 100644 --- a/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFTextRun.java +++ b/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFTextRun.java @@ -91,7 +91,7 @@ public class XSSFTextRun { /** * * @param fontSize font size in points. - * The value of-1
unsets the Sz attribute from the underlying xml bean + * The value of {@code -1} unsets the Sz attribute from the underlying xml bean */ public void setFontSize(double fontSize){ CTTextCharacterProperties rPr = getRPr(); @@ -158,7 +158,7 @@ public class XSSFTextRun { * Specifies the typeface, or name of the font that is to be used for this text run. * * @param typeface the font to apply to this text run. - * The value ofnull
unsets the Typeface attribute from the underlying xml. + * The value of {@code null} unsets the Typeface attribute from the underlying xml. */ public void setFont(String typeface){ setFontFamily(typeface, (byte)-1, (byte)-1, false); @@ -241,9 +241,6 @@ public class XSSFTextRun { ** The size is specified using a percentage. * Positive values indicate superscript, negative values indicate subscript. - *
- * - * @param baselineOffset */ public void setBaselineOffset(double baselineOffset){ getRPr().setBaseline((int) baselineOffset * 1000); diff --git a/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFVBAPart.java b/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFVBAPart.java index b5efa0951a..8aeb3a689b 100644 --- a/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFVBAPart.java +++ b/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFVBAPart.java @@ -33,18 +33,19 @@ public class XSSFVBAPart extends POIXMLDocumentPart { * Construct XSSFVBAPart from a package part * * @param part the package part holding the VBA data, - * + * * @since POI 3.14-Beta1 */ protected XSSFVBAPart(PackagePart part) { super(part); } - + /** * Like *PictureData, VBA objects store the actual content in the part * directly without keeping a copy like all others therefore we need to * handle them differently. */ + @Override protected void prepareForCommit() { // do not clear the part here } diff --git a/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/extensions/XSSFHeaderFooter.java b/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/extensions/XSSFHeaderFooter.java index b404ac4618..2872c3ff16 100644 --- a/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/extensions/XSSFHeaderFooter.java +++ b/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/extensions/XSSFHeaderFooter.java @@ -121,15 +121,13 @@ import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTHeaderFooter; * */ public abstract class XSSFHeaderFooter implements HeaderFooter { - private HeaderFooterHelper helper; - private CTHeaderFooter headerFooter; + private final HeaderFooterHelper helper; + private final CTHeaderFooter headerFooter; private boolean stripFields; /** * Create an instance of XSSFAbstractHeaderFooter from the supplied XML bean - * - * @param headerFooter */ public XSSFHeaderFooter(CTHeaderFooter headerFooter) { this.headerFooter = headerFooter; @@ -160,7 +158,7 @@ public abstract class XSSFHeaderFooter implements HeaderFooter { /** * Are fields currently being stripped from the text that this - * {@link XSSFHeaderFooter} returns? Default is false, but can be changed + * XSSFHeaderFooter returns? Default is false, but can be changed */ public boolean areFieldsStripped() { return stripFields; @@ -169,8 +167,6 @@ public abstract class XSSFHeaderFooter implements HeaderFooter { /** * Should fields (eg macros) be stripped from the text that this class * returns? Default is not to strip. - * - * @param stripFields */ public void setAreFieldsStripped(boolean stripFields) { this.stripFields = stripFields; diff --git a/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/helpers/XSSFFormulaUtils.java b/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/helpers/XSSFFormulaUtils.java index 3799f6c6d7..36ed86d912 100644 --- a/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/helpers/XSSFFormulaUtils.java +++ b/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/helpers/XSSFFormulaUtils.java @@ -19,7 +19,6 @@ package org.apache.poi.xssf.usermodel.helpers; -import java.util.Iterator; import java.util.List; import org.apache.poi.ooxml.POIXMLDocumentPart; @@ -59,11 +58,9 @@ public final class XSSFFormulaUtils { * Update sheet name in all charts, formulas and named ranges. * Called from {@link XSSFWorkbook#setSheetName(int, String)} *- *
* The idea is to parse every formula and render it back to string * with the updated sheet name. This is done by parsing into Ptgs, * looking for ones with sheet references in them, and changing those - *
* * @param sheetIndex the 0-based index of the sheet being changed * @param oldName the old sheet name @@ -93,9 +90,7 @@ public final class XSSFFormulaUtils { for (POIXMLDocumentPart r : rels) { if (r instanceof XSSFDrawing) { XSSFDrawing dg = (XSSFDrawing) r; - Iteratorit = dg.getCharts().iterator(); - while (it.hasNext()) { - XSSFChart chart = it.next(); + for (XSSFChart chart : dg.getCharts()) { Node dom = chart.getCTChartSpace().getDomNode(); updateDomSheetReference(dom, oldName, newName); } diff --git a/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/IBody.java b/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/IBody.java index 3c8be00a0f..dd80502fe5 100644 --- a/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/IBody.java +++ b/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/IBody.java @@ -41,7 +41,7 @@ public interface IBody { * * @return the Part, to which the body belongs */ - public POIXMLDocumentPart getPart(); + POIXMLDocumentPart getPart(); /** * get the PartType of the body, for example @@ -49,26 +49,26 @@ public interface IBody { * * @return the PartType of the body */ - public BodyType getPartType(); + BodyType getPartType(); /** * Returns an Iterator with paragraphs and tables, * in the order that they occur in the text. */ - public List getBodyElements(); + List getBodyElements(); /** * Returns the paragraph(s) that holds * the text of the header or footer. */ - public List getParagraphs(); + List getParagraphs(); /** * Return the table(s) that holds the text * of the IBodyPart, for complex cases * where a paragraph isn't used. */ - public List getTables(); + List getTables(); /** * Returns the paragraph corresponding to the provided {@link CTP}. @@ -77,58 +77,47 @@ public interface IBody { * @return The paragraph corresponding to the {@link CTP}, or {@code null} if there is no corresponding paragraph in * this body. */ - public XWPFParagraph getParagraph(CTP p); + XWPFParagraph getParagraph(CTP p); /** * if there is a corresponding {@link XWPFTable} of the parameter ctTable in the tableList of this header * the method will return this table * if there is no corresponding {@link XWPFTable} the method will return null - * - * @param ctTable */ - public XWPFTable getTable(CTTbl ctTable); + XWPFTable getTable(CTTbl ctTable); /** * Returns the paragraph that of position pos */ - public XWPFParagraph getParagraphArray(int pos); + XWPFParagraph getParagraphArray(int pos); /** * Returns the table at position pos */ - public XWPFTable getTableArray(int pos); + XWPFTable getTableArray(int pos); /** * inserts a new paragraph at position of the cursor - * - * @param cursor */ - public XWPFParagraph insertNewParagraph(XmlCursor cursor); + XWPFParagraph insertNewParagraph(XmlCursor cursor); /** * inserts a new Table at the cursor position. - * - * @param cursor */ - public XWPFTable insertNewTbl(XmlCursor cursor); + XWPFTable insertNewTbl(XmlCursor cursor); /** * inserts a new Table at position pos - * - * @param pos - * @param table */ void insertTable(int pos, XWPFTable table); /** * returns the TableCell to which the Table belongs - * - * @param cell */ - public XWPFTableCell getTableCell(CTTc cell); + XWPFTableCell getTableCell(CTTc cell); /** * Return XWPFDocument */ - public XWPFDocument getXWPFDocument(); + XWPFDocument getXWPFDocument(); } diff --git a/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/ISDTContent.java b/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/ISDTContent.java index d0c185e888..5536043c82 100644 --- a/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/ISDTContent.java +++ b/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/ISDTContent.java @@ -17,18 +17,17 @@ package org.apache.poi.xwpf.usermodel; +import org.apache.poi.util.Beta; + /** * Experimental interface to offer rudimentary read-only processing of * of the contentblock of an SDT/ContentControl. - * - *
- *
- * WARNING - APIs expected to change rapidly */ +@Beta public interface ISDTContent { - public String getText(); + String getText(); - public String toString(); + String toString(); } diff --git a/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFChart.java b/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFChart.java index 495cde1bf9..126a553f36 100644 --- a/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFChart.java +++ b/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFChart.java @@ -68,7 +68,7 @@ public class XWPFChart extends XDDFChart { * Construct a chart from a package part. * * @param part the package part holding the chart data, - * the content type must be
application/vnd.openxmlformats-officedocument.drawingml.chart+xml
+ * the content type must be {@code application/vnd.openxmlformats-officedocument.drawingml.chart+xml} * @since POI 4.0.0 */ protected XWPFChart(PackagePart part) throws IOException, XmlException { @@ -105,30 +105,7 @@ public class XWPFChart extends XDDFChart { @Override public boolean equals(Object obj) { - /** - * In case two objects ARE equal, but its not the same instance, this - * implementation will always run through the whole - * byte-array-comparison before returning true. If this will turn into a - * performance issue, two possible approaches are available:
- * a) Use the checksum only and take the risk that two images might have - * the same CRC32 sum, although they are not the same.
- * b) Use a second (or third) checksum algorithm to minimise the chance - * that two images have the same checksums but are not equal (e.g. - * CRC32, MD5 and SHA-1 checksums, additionally compare the - * data-byte-array lengths). - */ - if (obj == this) { - return true; - } - - if (obj == null) { - return false; - } - - if (!(obj instanceof XWPFChart)) { - return false; - } - return false; + return obj == this; } @Override @@ -141,8 +118,6 @@ public class XWPFChart extends XDDFChart { * * @param chartRelId the relation id of this chart in its parent document. * @param run the text run to which this chart will be inlined. - * @throws InvalidFormatException - * @throws IOException * @since POI 4.0.0 */ protected void attach(String chartRelId, XWPFRun run) @@ -215,7 +190,6 @@ public class XWPFChart extends XDDFChart { /** * get margin from Top * - * @param margin * @since POI 4.0.0 */ public long getChartTopMargin(long margin) { @@ -235,7 +209,6 @@ public class XWPFChart extends XDDFChart { /** * get margin from Bottom * - * @param margin * @since POI 4.0.0 */ public long getChartBottomMargin(long margin) { @@ -255,7 +228,6 @@ public class XWPFChart extends XDDFChart { /** * get margin from left * - * @param margin * @since POI 4.0.0 */ public long getChartLeftMargin(long margin) { @@ -275,7 +247,6 @@ public class XWPFChart extends XDDFChart { /** * get margin from Right * - * @param margin * @since POI 4.0.0 */ public long getChartRightMargin(long margin) { diff --git a/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFComments.java b/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFComments.java index 49cbb08976..2d5fea4fbb 100644 --- a/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFComments.java +++ b/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFComments.java @@ -47,8 +47,8 @@ import static org.apache.poi.ooxml.POIXMLTypeLoader.DEFAULT_XML_OPTIONS; public class XWPFComments extends POIXMLDocumentPart { XWPFDocument document; - private Listcomments = new ArrayList<>(); - private List pictures = new ArrayList<>(); + private final List comments = new ArrayList<>(); + private final List pictures = new ArrayList<>(); private CTComments ctComments; /** @@ -192,8 +192,6 @@ public class XWPFComments extends POIXMLDocumentPart { /** * Get the list of {@link XWPFComment} in the Comments part. - * - * @return */ public List getComments() { return comments; @@ -203,7 +201,6 @@ public class XWPFComments extends POIXMLDocumentPart { * Get the specified comment by position * * @param pos Array position of the comment - * @return */ public XWPFComment getComment(int pos) { if (pos >= 0 && pos < ctComments.sizeOfCommentArray()) { @@ -229,14 +226,11 @@ public class XWPFComments extends POIXMLDocumentPart { /** * Get the specified comment by ctComment - * - * @param ctComment - * @return */ public XWPFComment getComment(CTComment ctComment) { - for (int i = 0; i < comments.size(); i++) { - if (comments.get(i).getCtComment() == ctComment) { - return comments.get(i); + for (XWPFComment comment : comments) { + if (comment.getCtComment() == ctComment) { + return comment; } } return null; @@ -246,7 +240,6 @@ public class XWPFComments extends POIXMLDocumentPart { * Create a new comment and add it to the document. * * @param cid comment Id - * @return */ public XWPFComment createComment(BigInteger cid) { CTComment ctComment = ctComments.addNewComment(); diff --git a/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFFooter.java b/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFFooter.java index 07375a223b..c6a5cf2201 100644 --- a/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFFooter.java +++ b/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFFooter.java @@ -89,7 +89,7 @@ public class XWPFFooter extends XWPFHeaderFooter { @Override protected void onDocumentRead() throws IOException { super.onDocumentRead(); - FtrDocument ftrDocument = null; + FtrDocument ftrDocument; try (InputStream is = getPackagePart().getInputStream()) { ftrDocument = FtrDocument.Factory.parse(is, DEFAULT_XML_OPTIONS); headerFooter = ftrDocument.getFtr(); @@ -125,6 +125,7 @@ public class XWPFFooter extends XWPFHeaderFooter { * * @see org.apache.poi.xwpf.usermodel.IBody#getPartType() */ + @Override public BodyType getPartType() { return BodyType.FOOTER; } diff --git a/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFHeader.java b/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFHeader.java index fe12c8df70..5d7bc2885a 100644 --- a/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFHeader.java +++ b/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFHeader.java @@ -86,13 +86,11 @@ public class XWPFHeader extends XWPFHeaderFooter { /** * reads the document - * - * @throws IOException */ @Override protected void onDocumentRead() throws IOException { super.onDocumentRead(); - HdrDocument hdrDocument = null; + HdrDocument hdrDocument; try (InputStream is = getPackagePart().getInputStream()) { hdrDocument = HdrDocument.Factory.parse(is, DEFAULT_XML_OPTIONS); headerFooter = hdrDocument.getHdr(); @@ -128,6 +126,7 @@ public class XWPFHeader extends XWPFHeaderFooter { * * @see org.apache.poi.xwpf.usermodel.IBody#getPartType() */ + @Override public BodyType getPartType() { return BodyType.HEADER; } diff --git a/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFNumbering.java b/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFNumbering.java index 292c831b03..53ff91fe77 100644 --- a/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFNumbering.java +++ b/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFNumbering.java @@ -68,7 +68,7 @@ public class XWPFNumbering extends POIXMLDocumentPart { */ @Override protected void onDocumentRead() throws IOException { - NumberingDocument numberingDoc = null; + NumberingDocument numberingDoc; InputStream is; is = getPackagePart().getInputStream(); try { @@ -105,8 +105,6 @@ public class XWPFNumbering extends POIXMLDocumentPart { /** * Sets the ctNumbering - * - * @param numbering */ public void setNumbering(CTNumbering numbering) { ctNumbering = numbering; @@ -116,7 +114,6 @@ public class XWPFNumbering extends POIXMLDocumentPart { /** * Checks whether number with numID exists * - * @param numID * @return boolean true if num exist, false if num not exist */ public boolean numExist(BigInteger numID) { @@ -129,8 +126,6 @@ public class XWPFNumbering extends POIXMLDocumentPart { /** * add a new number to the numbering document - * - * @param num */ public BigInteger addNum(XWPFNum num) { ctNumbering.addNewNum(); @@ -157,9 +152,6 @@ public class XWPFNumbering extends POIXMLDocumentPart { /** * Add a new num with an abstractNumID and a numID - * - * @param abstractNumID - * @param numID */ public void addNum(BigInteger abstractNumID, BigInteger numID) { CTNum ctNum = this.ctNumbering.addNewNum(); @@ -173,7 +165,6 @@ public class XWPFNumbering extends POIXMLDocumentPart { /** * get Num by NumID * - * @param numID * @return abstractNum with NumId if no Num exists with that NumID * null will be returned */ @@ -188,7 +179,6 @@ public class XWPFNumbering extends POIXMLDocumentPart { /** * get AbstractNum by abstractNumID * - * @param abstractNumID * @return abstractNum with abstractNumId if no abstractNum exists with that abstractNumID * null will be returned */ @@ -207,7 +197,6 @@ public class XWPFNumbering extends POIXMLDocumentPart { * the BigInteger Value of it will be returned. * If no equal abstractNum is existing null will be returned * - * @param abstractNum * @return BigInteger */ public BigInteger getIdOfAbstractNum(XWPFAbstractNum abstractNum) { @@ -227,8 +216,6 @@ public class XWPFNumbering extends POIXMLDocumentPart { /** * add a new AbstractNum and return its AbstractNumID - * - * @param abstractNum */ public BigInteger addAbstractNum(XWPFAbstractNum abstractNum) { int pos = abstractNums.size(); @@ -246,7 +233,6 @@ public class XWPFNumbering extends POIXMLDocumentPart { /** * remove an existing abstractNum * - * @param abstractNumID * @return true if abstractNum with abstractNumID exists in NumberingArray, * false if abstractNum with abstractNumID not exists */ @@ -268,7 +254,6 @@ public class XWPFNumbering extends POIXMLDocumentPart { * If the AbstractNumID not exists * return null * - * @param numID * @return abstractNumID */ public BigInteger getAbstractNumID(BigInteger numID) { diff --git a/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFPicture.java b/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFPicture.java index 5449c3bfd7..da22abe359 100644 --- a/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFPicture.java +++ b/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFPicture.java @@ -25,9 +25,9 @@ import org.openxmlformats.schemas.drawingml.x2006.picture.CTPicture; public class XWPFPicture { - private CTPicture ctPic; - private String description; - private XWPFRun run; + private final CTPicture ctPic; + private final String description; + private final XWPFRun run; public XWPFPicture(CTPicture ctPic, XWPFRun run) { this.run = run; @@ -37,8 +37,6 @@ public class XWPFPicture { /** * Link Picture with PictureData - * - * @param rel */ public void setPictureReference(PackageRelationship rel) { ctPic.getBlipFill().getBlip().setEmbed(rel.getId()); diff --git a/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFSDTContent.java b/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFSDTContent.java index eaaf94d873..74ab5de4ac 100644 --- a/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFSDTContent.java +++ b/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFSDTContent.java @@ -19,6 +19,7 @@ package org.apache.poi.xwpf.usermodel; import java.util.ArrayList; import java.util.List; +import org.apache.poi.util.Beta; import org.apache.xmlbeans.XmlCursor; import org.apache.xmlbeans.XmlObject; import org.openxmlformats.schemas.wordprocessingml.x2006.main.*; @@ -26,11 +27,8 @@ import org.openxmlformats.schemas.wordprocessingml.x2006.main.*; /** * Experimental class to offer rudimentary read-only processing of * of the contentblock of an SDT/ContentControl. - * - *
- *
- * WARNING - APIs expected to change rapidly */ +@Beta public class XWPFSDTContent implements ISDTContent { // private final IBody part; @@ -39,7 +37,7 @@ public class XWPFSDTContent implements ISDTContent { // private List
*tables = new ArrayList<>(); // private List runs = new ArrayList<>(); // private List contentControls = new ArrayList<>(); - private List bodyElements = new ArrayList<>(); + private final List bodyElements = new ArrayList<>(); public XWPFSDTContent(CTSdtContentRun sdtRun, IBody part, IRunBody parent) { if (sdtRun == null) { diff --git a/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFStyle.java b/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFStyle.java index c141d8c2c8..70f6d4de47 100644 --- a/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFStyle.java +++ b/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFStyle.java @@ -25,21 +25,10 @@ public class XWPFStyle { protected XWPFStyles styles; private CTStyle ctStyle; - /** - * constructor - * - * @param style - */ public XWPFStyle(CTStyle style) { this(style, null); } - /** - * constructor - * - * @param style - * @param styles - */ public XWPFStyle(CTStyle style, XWPFStyles styles) { this.ctStyle = style; this.styles = styles; @@ -56,8 +45,6 @@ public class XWPFStyle { /** * set styleID - * - * @param styleId */ public void setStyleId(String styleId) { ctStyle.setStyleId(styleId); @@ -74,8 +61,6 @@ public class XWPFStyle { /** * set styleType - * - * @param type */ public void setType(STStyleType.Enum type) { ctStyle.setType(type); @@ -83,8 +68,6 @@ public class XWPFStyle { /** * set style - * - * @param style */ public void setStyle(CTStyle style) { this.ctStyle = style; @@ -144,8 +127,6 @@ public class XWPFStyle { /** * compares the names of the Styles - * - * @param compStyle */ public boolean hasSameName(XWPFStyle compStyle) { CTStyle ctCompStyle = compStyle.getCTStyle(); @@ -153,4 +134,4 @@ public class XWPFStyle { return name.equals(ctStyle.getName().getVal()); } -}//end class +} diff --git a/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFTable.java b/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFTable.java index e95057f342..7721609879 100644 --- a/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFTable.java +++ b/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFTable.java @@ -141,7 +141,7 @@ public class XWPFTable implements IBodyElement, ISDTContents { // Unused: UUF_UNUSED_PUBLIC_OR_PROTECTED_FIELD //protected List styleIDs; protected IBody part; - private CTTbl ctTbl; + private final CTTbl ctTbl; public XWPFTable(CTTbl table, IBody part, int row, int col) { this(table, part); @@ -243,8 +243,8 @@ public class XWPFTable implements IBodyElement, ISDTContents { if (tableRows.size() == 0) { createRow(); } - for (int i = 0; i < tableRows.size(); i++) { - tableRows.get(i).createCell(); + for (XWPFTableRow tableRow : tableRows) { + tableRow.createCell(); } } @@ -1046,7 +1046,6 @@ public class XWPFTable implements IBodyElement, ISDTContents { /** * inserts a new tablerow * - * @param pos * @return the inserted row */ public XWPFTableRow insertNewTableRow(int pos) { @@ -1081,8 +1080,6 @@ public class XWPFTable implements IBodyElement, ISDTContents { /** * returns the type of the BodyElement Table - * - * @see org.apache.poi.xwpf.usermodel.IBodyElement#getElementType() */ @Override public BodyElementType getElementType() { @@ -1195,14 +1192,12 @@ public class XWPFTable implements IBodyElement, ISDTContents { switch (typeValue.intValue()) { case STTblWidth.INT_NIL: return TableWidthType.NIL; - case STTblWidth.INT_AUTO: - return TableWidthType.AUTO; case STTblWidth.INT_DXA: return TableWidthType.DXA; case STTblWidth.INT_PCT: return TableWidthType.PCT; default: - // Should never get here + case STTblWidth.INT_AUTO: return TableWidthType.AUTO; } } @@ -1284,11 +1279,9 @@ public class XWPFTable implements IBodyElement, ISDTContents { if (!currentType.equals(widthType)) { STTblWidth.Enum stWidthType = widthType.getStWidthType(); ctWidth.setType(stWidthType); - switch (stWidthType.intValue()) { - case STTblWidth.INT_PCT: + if (stWidthType.intValue() == STTblWidth.INT_PCT) { setWidthPercentage(ctWidth, DEFAULT_PERCENTAGE_WIDTH); - break; - default: + } else { ctWidth.setW(BigInteger.ZERO); } } diff --git a/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFTableCell.java b/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFTableCell.java index 4c4cfd7820..0f014c45da 100644 --- a/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFTableCell.java +++ b/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFTableCell.java @@ -119,9 +119,8 @@ public class XWPFTableCell implements IBody, ICell { /** * returns an Iterator with paragraphs and tables - * - * @see org.apache.poi.xwpf.usermodel.IBody#getBodyElements() */ + @Override public List getBodyElements() { return Collections.unmodifiableList(bodyElements); } @@ -136,6 +135,7 @@ public class XWPFTableCell implements IBody, ICell { /** * returns a list of paragraphs */ + @Override public List getParagraphs() { return Collections.unmodifiableList(paragraphs); } @@ -221,7 +221,7 @@ public class XWPFTableCell implements IBody, ICell { /** * Get the vertical alignment of the cell. * - * @return the cell alignment enum value or null
+ * @return the cell alignment enum value or {@code null} * if no vertical alignment is set. */ public XWPFVertAlign getVerticalAlignment() { @@ -253,6 +253,7 @@ public class XWPFTableCell implements IBody, ICell { * @param cursor The XmlCursor structure created with XmlBeans * @return the inserted paragraph */ + @Override public XWPFParagraph insertNewParagraph(final XmlCursor cursor) { if (!isCursorInTableCell(cursor)) { return null; @@ -291,6 +292,7 @@ public class XWPFTableCell implements IBody, ICell { return newP; } + @Override public XWPFTable insertNewTbl(final XmlCursor cursor) { if (isCursorInTableCell(cursor)) { String uri = CTTbl.type.getName().getNamespaceURI(); @@ -339,9 +341,7 @@ public class XWPFTableCell implements IBody, ICell { return result; } - /** - * @see org.apache.poi.xwpf.usermodel.IBody#getParagraphArray(int) - */ + @Override public XWPFParagraph getParagraphArray(int pos) { if (pos >= 0 && pos < paragraphs.size()) { return paragraphs.get(pos); @@ -351,25 +351,21 @@ public class XWPFTableCell implements IBody, ICell { /** * get the to which the TableCell belongs - * - * @see org.apache.poi.xwpf.usermodel.IBody#getPart() */ + @Override public POIXMLDocumentPart getPart() { return tableRow.getTable().getPart(); } - /** - * @see org.apache.poi.xwpf.usermodel.IBody#getPartType() - */ + @Override public BodyType getPartType() { return BodyType.TABLECELL; } /** * get a table by its CTTbl-Object - * - * @see org.apache.poi.xwpf.usermodel.IBody#getTable(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTbl) */ + @Override public XWPFTable getTable(CTTbl ctTable) { for (int i = 0; i < tables.size(); i++) { if (getTables().get(i).getCTTbl() == ctTable) return getTables().get(i); @@ -377,9 +373,7 @@ public class XWPFTableCell implements IBody, ICell { return null; } - /** - * @see org.apache.poi.xwpf.usermodel.IBody#getTableArray(int) - */ + @Override public XWPFTable getTableArray(int pos) { if(pos >= 0 && pos < tables.size()) { return tables.get(pos); @@ -387,18 +381,15 @@ public class XWPFTableCell implements IBody, ICell { return null; } - /** - * @see org.apache.poi.xwpf.usermodel.IBody#getTables() - */ + @Override public ListgetTables() { return Collections.unmodifiableList(tables); } /** * inserts an existing XWPFTable to the arrays bodyElements and tables - * - * @see org.apache.poi.xwpf.usermodel.IBody#insertTable(int, org.apache.poi.xwpf.usermodel.XWPFTable) */ + @Override public void insertTable(int pos, XWPFTable table) { bodyElements.add(pos, table); int i = 0; @@ -482,6 +473,7 @@ public class XWPFTableCell implements IBody, ICell { /** * get the TableCell which belongs to the TableCell */ + @Override public XWPFTableCell getTableCell(CTTc cell) { XmlCursor cursor = cell.newCursor(); cursor.toParent(); @@ -508,6 +500,7 @@ public class XWPFTableCell implements IBody, ICell { return tr.getTableCell(cell); } + @Override public XWPFDocument getXWPFDocument() { return part.getXWPFDocument(); } diff --git a/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFTableRow.java b/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFTableRow.java index 838688ffa9..da96c8320b 100644 --- a/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFTableRow.java +++ b/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFTableRow.java @@ -41,8 +41,8 @@ import org.openxmlformats.schemas.wordprocessingml.x2006.main.STHeightRule; * the child {@link XWPFTableCell}s */ public class XWPFTableRow { - private CTRow ctRow; - private XWPFTable table; + private final CTRow ctRow; + private final XWPFTable table; private List tableCells; public XWPFTableRow(CTRow row, XWPFTable table) { @@ -123,8 +123,6 @@ public class XWPFTableRow { * its attribute values). If omitted, then the table row shall automatically * resize its height to the height required by its contents (the equivalent * of an hRule value of auto). - * - * @param height */ public void setHeight(int height) { CTTrPr properties = getTrPr(); @@ -221,9 +219,9 @@ public class XWPFTableRow { * if there is no XWPFTableCell which belongs to the parameter CTTc cell null will be returned */ public XWPFTableCell getTableCell(CTTc cell) { - for (int i = 0; i < tableCells.size(); i++) { - if (tableCells.get(i).getCTTc() == cell) - return tableCells.get(i); + for (XWPFTableCell tableCell : tableCells) { + if (tableCell.getCTTc() == cell) + return tableCell; } return null; } diff --git a/poi-ooxml/src/test/java/org/apache/poi/xdgf/usermodel/section/TestCombinedIterator.java b/poi-ooxml/src/test/java/org/apache/poi/xdgf/usermodel/section/TestCombinedIterator.java index 5679c28cd9..6232cfd62f 100644 --- a/poi-ooxml/src/test/java/org/apache/poi/xdgf/usermodel/section/TestCombinedIterator.java +++ b/poi-ooxml/src/test/java/org/apache/poi/xdgf/usermodel/section/TestCombinedIterator.java @@ -29,7 +29,7 @@ import org.junit.jupiter.api.Test; class TestCombinedIterator { - void testIteration(CombinedIterable iterable, String... expected) { + void testIteration(Iterable iterable, String... expected) { Iterator iter = iterable.iterator(); @@ -49,8 +49,7 @@ class TestCombinedIterator { base.put(2L, "B2"); base.put(3L, "B3"); - testIteration(new CombinedIterable<>(base, null), "B1", "B2", - "B3"); + testIteration(createIter(base, null), "B1", "B2", "B3"); } @Test @@ -66,8 +65,7 @@ class TestCombinedIterator { master.put(5L, "M5"); master.put(6L, "M6"); - testIteration(new CombinedIterable<>(base, master), "B1", "B2", - "B3", "M4", "M5", "M6"); + testIteration(createIter(base, master), "B1", "B2", "B3", "M4", "M5", "M6"); } @Test @@ -83,8 +81,7 @@ class TestCombinedIterator { master.put(2L, "M2"); master.put(3L, "M3"); - testIteration(new CombinedIterable<>(base, master), "M1", "M2", - "M3", "B4", "B5", "B6"); + testIteration(createIter(base, master), "M1", "M2", "M3", "B4", "B5", "B6"); } @Test @@ -100,8 +97,7 @@ class TestCombinedIterator { master.put(4L, "M4"); master.put(6L, "M6"); - testIteration(new CombinedIterable<>(base, master), "B1", "M2", - "B3", "M4", "B5", "M6"); + testIteration(createIter(base, master), "B1", "M2", "B3", "M4", "B5", "M6"); } @Test @@ -119,8 +115,7 @@ class TestCombinedIterator { master.put(7L, "M7"); master.put(8L, "M8"); - testIteration(new CombinedIterable<>(base, master), "B1", "B2", - "M3", "M4", "B5", "B6", "M7", "M8"); + testIteration(createIter(base, master), "B1", "B2", "M3", "M4", "B5", "B6", "M7", "M8"); } @Test @@ -136,8 +131,7 @@ class TestCombinedIterator { master.put(2L, "M2"); master.put(3L, "M3"); - testIteration(new CombinedIterable<>(base, master), "B1", "B2", - "B3"); + testIteration(createIter(base, master), "B1", "B2", "B3"); } @Test @@ -154,7 +148,12 @@ class TestCombinedIterator { master.put(3L, "M3"); master.put(4L, "M4"); - testIteration(new CombinedIterable<>(base, master), "B1", "B2", - "B3", "M4"); + testIteration(createIter(base, master), "B1", "B2", "B3", "M4"); + } + + + private static Iterable createIter(SortedMap map1, SortedMap map2) { + // TODO: try to use commons collection and remove CombinedIterable + return new CombinedIterable<>(map1, map2); } } diff --git a/poi-scratchpad/build.gradle b/poi-scratchpad/build.gradle index 4669dc98dc..c88cfeae14 100644 --- a/poi-scratchpad/build.gradle +++ b/poi-scratchpad/build.gradle @@ -56,13 +56,6 @@ final Pattern MODULE_REGEX = ~'\\.jar$' final List MAIN_MODULE_PATH = sourceSets.main.runtimeClasspath.findAll{ it.path =~ MODULE_REGEX }.collect{ it.parent }.unique() final List TEST_MODULE_PATH = sourceSets.test.runtimeClasspath.findAll{ it.path =~ MODULE_REGEX && !(it.path =~ MODULE_NOT_REGEX) }.collect{ it.parent }.unique() -java { - sourceCompatibility = JavaVersion.VERSION_1_8 - targetCompatibility = JavaVersion.VERSION_1_8 - withJavadocJar() - withSourcesJar() -} - task compileJava9(type: JavaCompile) { dependsOn 'compileJava', ':poi:jar' @@ -142,23 +135,9 @@ task testJar(type: Jar, dependsOn: testClasses) { } } -sourcesJar { - destinationDirectory = file("../build/dist/maven/${project.archivesBaseName}") - exclude 'META-INF/services/**' -} - javadoc { - failOnError = true doFirst { options { - if (JavaVersion.current().isJava9Compatible()) { - addBooleanOption('html5', true) - } - links 'https://poi.apache.org/apidocs/dev/' - links 'https://docs.oracle.com/javase/8/docs/api/' - use = true - splitIndex = true - source = "1.8" classpath += configurations.javadocs.files } } @@ -171,39 +150,10 @@ artifacts { test { dependsOn { testJar } - useJUnitPlatform() - doFirst { - jvmArgs = [ - '-Djava.io.tmpdir=build', - '-DPOI.testdata.path=../test-data', - '-Djava.awt.headless=true', - '-Djava.locale.providers=JRE,CLDR', - '-Duser.language=en', - '-Duser.country=US', - '-Djavax.xml.stream.XMLInputFactory=com.sun.xml.internal.stream.XMLInputFactoryImpl', - "-Dversion.id=${project.version}", - '-ea', - '-Djunit.jupiter.execution.parallel.enabled=true', - '-Djunit.jupiter.execution.parallel.config.strategy=fixed', - '-Djunit.jupiter.execution.parallel.config.fixed.parallelism=3' - // -Xjit:verbose={compileStart|compileEnd},vlog=build/jit.log${no.jit.sherlock} ... if ${isIBMVM} - ] if (JavaVersion.current() != JavaVersion.VERSION_1_8) { jvmArgs += [ - '-Dsun.reflect.debugModuleAccessChecks=true', - '-Dcom.sun.xml.bind.v2.bytecode.ClassTailor.noOptimize=true', - '--illegal-access=warn', - '--add-modules', MODULE_NAME, - - // see https://github.com/java9-modularity/gradle-modules-plugin/issues/97 - // opposed to the recommendation there, it doesn't work to add ... to the dependencies - // testRuntimeOnly 'org.junit.platform:junit-platform-launcher:1.7.1' - // gradles gradle-worker.jar is still not a JPMS module and thus runs as unnamed module - '--add-exports','org.junit.platform.commons/org.junit.platform.commons.util=ALL-UNNAMED', - '--add-exports','org.junit.platform.commons/org.junit.platform.commons.logging=ALL-UNNAMED', - '--module-path', '../build/dist/maven/poi-scratchpad-tests:' + files(TEST_MODULE_PATH).asPath, ] } @@ -213,10 +163,6 @@ test { publishing { publications { POI(MavenPublication) { - artifactId project.archivesBaseName - - from components.java - pom { name = 'Apache POI' description = 'Apache POI - Java API To Access Microsoft Format Files (Scratchpad)' @@ -224,5 +170,3 @@ publishing { } } } - -generatePomFileForPOIPublication.destination = "../build/dist/maven/${project.archivesBaseName}/${project.archivesBaseName}-${project.version}.pom" diff --git a/poi-scratchpad/src/main/java/org/apache/poi/hslf/extractor/QuickButCruddyTextExtractor.java b/poi-scratchpad/src/main/java/org/apache/poi/hslf/extractor/QuickButCruddyTextExtractor.java index 1c2a0e6d79..ec17e6d525 100644 --- a/poi-scratchpad/src/main/java/org/apache/poi/hslf/extractor/QuickButCruddyTextExtractor.java +++ b/poi-scratchpad/src/main/java/org/apache/poi/hslf/extractor/QuickButCruddyTextExtractor.java @@ -55,7 +55,7 @@ import org.apache.poi.util.LittleEndian; public final class QuickButCruddyTextExtractor { private POIFSFileSystem fs; private InputStream is; - private byte[] pptContents; + private final byte[] pptContents; /** * Really basic text extractor, that will also return lots of crud text. @@ -78,7 +78,6 @@ public final class QuickButCruddyTextExtractor { /** * Creates an extractor from a given file name - * @param fileName */ @SuppressWarnings("resource") public QuickButCruddyTextExtractor(String fileName) throws IOException { @@ -87,7 +86,6 @@ public final class QuickButCruddyTextExtractor { /** * Creates an extractor from a given input stream - * @param iStream */ @SuppressWarnings("resource") public QuickButCruddyTextExtractor(InputStream iStream) throws IOException { @@ -97,7 +95,6 @@ public final class QuickButCruddyTextExtractor { /** * Creates an extractor from a POIFS Filesystem - * @param poifs */ public QuickButCruddyTextExtractor(POIFSFileSystem poifs) throws IOException { fs = poifs; @@ -192,9 +189,7 @@ public final class QuickButCruddyTextExtractor { String text = cs.getText(); // Ignore the ones we know to be rubbish - if(text.equals("___PPT10")) { - } else if(text.equals("Default Design")) { - } else { + if (!"___PPT10".equals(text) && !"Default Design".equals(text)) { textV.add(text); } } diff --git a/poi-scratchpad/src/main/java/org/apache/poi/hslf/model/ActiveXShape.java b/poi-scratchpad/src/main/java/org/apache/poi/hslf/model/ActiveXShape.java index f8c02deac7..26af08bd80 100644 --- a/poi-scratchpad/src/main/java/org/apache/poi/hslf/model/ActiveXShape.java +++ b/poi-scratchpad/src/main/java/org/apache/poi/hslf/model/ActiveXShape.java @@ -46,7 +46,7 @@ public final class ActiveXShape extends HSLFPictureShape { public static final int DEFAULT_ACTIVEX_THUMBNAIL = -1; /** - * Create a new Picture
+ * Create a new {@code Picture} * * @param pictureData the picture data */ @@ -56,10 +56,10 @@ public final class ActiveXShape extends HSLFPictureShape { } /** - * Create aPicture
object + * Create a {@code Picture} object * - * @param escherRecord theEscherSpContainer
record which holds information about - * this picture in theSlide
+ * @param escherRecord the {@code EscherSpContainer} record which holds information about + * this picture in the {@code Slide} * @param parent the parent shape of this picture */ protected ActiveXShape(EscherContainerRecord escherRecord, ShapeContainerparent){ @@ -69,13 +69,14 @@ public final class ActiveXShape extends HSLFPictureShape { /** * Create a new Placeholder and initialize internal structures * - * @return the created EscherContainerRecord
which holds shape data + * @return the created {@code EscherContainerRecord} which holds shape data */ @Override protected EscherContainerRecord createSpContainer(int idx, boolean isChild) { EscherContainerRecord ecr = super.createSpContainer(idx, isChild); EscherSpRecord spRecord = ecr.getChildById(EscherSpRecord.RECORD_ID); + assert(spRecord != null); spRecord.setFlags(EscherSpRecord.FLAG_HAVEANCHOR | EscherSpRecord.FLAG_HASSHAPETYPE | EscherSpRecord.FLAG_OLESHAPE); setShapeType(ShapeType.HOST_CONTROL); @@ -114,8 +115,6 @@ public final class ActiveXShape extends HSLFPictureShape { /** * Set a property of this ActiveX control - * @param key - * @param value */ public void setProperty(String key, String value){ @@ -133,7 +132,7 @@ public final class ActiveXShape extends HSLFPictureShape { if (lst == null) { return null; } - + for (Record ch : lst.getChildRecords()) { if(ch instanceof ExControl){ ExControl c = (ExControl)ch; diff --git a/poi-scratchpad/src/main/java/org/apache/poi/hslf/model/Polygon.java b/poi-scratchpad/src/main/java/org/apache/poi/hslf/model/Polygon.java index 3c4e8b04cf..2f3aa0941f 100644 --- a/poi-scratchpad/src/main/java/org/apache/poi/hslf/model/Polygon.java +++ b/poi-scratchpad/src/main/java/org/apache/poi/hslf/model/Polygon.java @@ -40,7 +40,7 @@ public final class Polygon extends HSLFAutoShape { /** * Create a Polygon object and initialize it from the supplied Record container. * - * @param escherRecordEscherSpContainer
container which holds information about this shape + * @param escherRecord {@code EscherSpContainer} container which holds information about this shape * @param parent the parent of the shape */ protected Polygon(EscherContainerRecord escherRecord, ShapeContainerparent){ @@ -69,9 +69,6 @@ public final class Polygon extends HSLFAutoShape { /** * Set the polygon vertices - * - * @param xPoints - * @param yPoints */ public void setPoints(float[] xPoints, float[] yPoints) { @@ -147,10 +144,9 @@ public final class Polygon extends HSLFAutoShape { private float findBiggest( float[] values ) { float result = Float.MIN_VALUE; - for ( int i = 0; i < values.length; i++ ) - { - if (values[i] > result) - result = values[i]; + for (float value : values) { + if (value > result) + result = value; } return result; } @@ -158,10 +154,9 @@ public final class Polygon extends HSLFAutoShape { private float findSmallest( float[] values ) { float result = Float.MAX_VALUE; - for ( int i = 0; i < values.length; i++ ) - { - if (values[i] < result) - result = values[i]; + for (float value : values) { + if (value < result) + result = value; } return result; } diff --git a/poi-scratchpad/src/main/java/org/apache/poi/hslf/model/textproperties/BitMaskTextProp.java b/poi-scratchpad/src/main/java/org/apache/poi/hslf/model/textproperties/BitMaskTextProp.java index 17d5ea5610..92ab8c6b0a 100644 --- a/poi-scratchpad/src/main/java/org/apache/poi/hslf/model/textproperties/BitMaskTextProp.java +++ b/poi-scratchpad/src/main/java/org/apache/poi/hslf/model/textproperties/BitMaskTextProp.java @@ -37,9 +37,9 @@ import org.apache.poi.util.GenericRecordUtil; public abstract class BitMaskTextProp extends TextProp { protected static final Logger LOG = LogManager.getLogger(BitMaskTextProp.class); - private String[] subPropNames; - private int[] subPropMasks; - private boolean[] subPropMatches; + private final String[] subPropNames; + private final int[] subPropMasks; + private final boolean[] subPropMatches; /** Fetch the list of the names of the sub properties */ public String[] getSubPropNames() { return subPropNames; } @@ -141,9 +141,6 @@ public abstract class BitMaskTextProp extends TextProp { /** * Convenience method to set a value with mask, without splitting it into the subvalues - * - * @param val - * @param writeMask */ public void setValueWithMask(int val, int writeMask) { setWriteMask(writeMask); diff --git a/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/SlideListWithText.java b/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/SlideListWithText.java index b57207e41d..685e42b4ab 100644 --- a/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/SlideListWithText.java +++ b/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/SlideListWithText.java @@ -64,7 +64,7 @@ public final class SlideListWithText extends RecordContainer { */ public static final int NOTES = 2; - private byte[] _header; + private final byte[] _header; private SlideAtomsSet[] slideAtomsSets; @@ -124,7 +124,6 @@ public final class SlideListWithText extends RecordContainer { /** * Add a new SlidePersistAtom, to the end of the current list, * and update the internal list of SlidePersistAtoms - * @param spa */ public void addSlidePersistAtom(SlidePersistAtom spa) { // Add the new SlidePersistAtom at the end @@ -164,12 +163,14 @@ public final class SlideListWithText extends RecordContainer { /** * Return the value we were given at creation */ + @Override public long getRecordType() { return _type; } /** * Write the contents of the record back, so it can be written * to disk */ + @Override public void writeOut(OutputStream out) throws IOException { writeOut(_header[0],_header[1],_type,_children,out); } @@ -182,8 +183,8 @@ public final class SlideListWithText extends RecordContainer { * along with some others. */ public static class SlideAtomsSet { - private SlidePersistAtom slidePersistAtom; - private org.apache.poi.hslf.record.Record[] slideRecords; + private final SlidePersistAtom slidePersistAtom; + private final org.apache.poi.hslf.record.Record[] slideRecords; /** Get the SlidePersistAtom, which gives details on the Slide this text is associated with */ public SlidePersistAtom getSlidePersistAtom() { return slidePersistAtom; } diff --git a/poi-scratchpad/src/main/java/org/apache/poi/hslf/usermodel/HSLFBackground.java b/poi-scratchpad/src/main/java/org/apache/poi/hslf/usermodel/HSLFBackground.java index eac3d846fb..c734ce28fb 100644 --- a/poi-scratchpad/src/main/java/org/apache/poi/hslf/usermodel/HSLFBackground.java +++ b/poi-scratchpad/src/main/java/org/apache/poi/hslf/usermodel/HSLFBackground.java @@ -30,6 +30,7 @@ public final class HSLFBackground extends HSLFShape implements Background - * Represents a Shape which is the elemental object that composes a drawing. + * Represents a Shape which is the elemental object that composes a drawing. * This class is a wrapper around EscherSpContainer which holds all information * about a shape in PowerPoint document. - * * When you add a shape, you usually specify the dimensions of the shape and the position * of the upper'left corner of the bounding box for the shape relative to the upper'left * corner of the page, worksheet, or slide. Distances in the drawing layer are measured * in points (72 points = 1 inch). - *
- **/ public abstract class HSLFShape implements Shape
{ private static final Logger LOG = LogManager.getLogger(HSLFShape.class); @@ -79,12 +75,12 @@ public abstract class HSLFShape implements Shape { /** * Parent of this shape. - * null
for the topmost shapes. + * {@code null} for the topmost shapes. */ - private ShapeContainer_parent; + private final ShapeContainer _parent; /** - * The Sheet
this shape belongs to + * The {@code Sheet} this shape belongs to */ private HSLFSheet _sheet; @@ -92,11 +88,11 @@ public abstract class HSLFShape implements Shape{ * Fill */ private HSLFFill _fill; - + /** * Create a Shape object. This constructor is used when an existing Shape is read from from a PowerPoint document. * - * @param escherRecord EscherSpContainer
container which holds information about this shape + * @param escherRecord {@code EscherSpContainer} container which holds information about this shape * @param parent the parent of this Shape */ protected HSLFShape(EscherContainerRecord escherRecord, ShapeContainerparent){ @@ -233,12 +229,12 @@ public abstract class HSLFShape implements Shape { /** * Helper method to return escher child by record ID * - * @return escher record or null
if not found. + * @return escher record or {@code null} if not found. */ public staticT getEscherChild(EscherContainerRecord owner, int recordId){ return owner.getChildById((short)recordId); } - + /** * @since POI 3.14-Beta2 */ @@ -249,18 +245,18 @@ public abstract class HSLFShape implements Shape { public T getEscherChild(int recordId){ return _escherContainer.getChildById((short)recordId); } - + /** * @since POI 3.14-Beta2 */ public T getEscherChild(EscherRecordTypes recordId){ return getEscherChild(recordId.typeID); } - + /** * Returns escher property by id. * - * @return escher property or null
if not found. + * @return escher property or {@code null} if not found. * * @deprecated use {@link #getEscherProperty(EscherPropertyTypes)} instead */ @@ -273,7 +269,7 @@ public abstract class HSLFShape implements Shape{ /** * Returns escher property by type. * - * @return escher property or null
if not found. + * @return escher property or {@code null} if not found. */ public staticT getEscherProperty(AbstractEscherOptRecord opt, EscherPropertyTypes type){ return (opt == null) ? null : opt.lookup(type); @@ -428,7 +424,7 @@ public abstract class HSLFShape implements Shape { } /** - * @return the SlideShow
this shape belongs to + * @return the {@code SlideShow} this shape belongs to */ @Override public HSLFSheet getSheet(){ @@ -436,7 +432,7 @@ public abstract class HSLFShape implements Shape{ } /** - * Assign the SlideShow
this shape belongs to + * Assign the {@code SlideShow} this shape belongs to * * @param sheet owner of this shape */ @@ -491,10 +487,10 @@ public abstract class HSLFShape implements Shape{ col = applySysIndexProcedure(ecr, col); return col; } - + return new Color(rgb[0], rgb[1], rgb[2]); } - + private Color getSysIndexColor(EscherColorRef ecr) { SysIndexSource sis = ecr.getSysIndexSource(); if (sis == null) { @@ -502,7 +498,7 @@ public abstract class HSLFShape implements Shape { PresetColor pc = PresetColor.valueOfNativeId(sysIdx); return (pc != null) ? pc.color : null; } - + // TODO: check for recursive loops, when color getter also reference // a different color type switch (sis) { @@ -554,17 +550,17 @@ public abstract class HSLFShape implements Shape { default: break; } - + return null; } - + private Color applySysIndexProcedure(EscherColorRef ecr, Color col) { - + final SysIndexProcedure sip = ecr.getSysIndexProcedure(); if (col == null || sip == null) { return col; } - + switch (sip) { case DARKEN_COLOR: { // see java.awt.Color#darken() @@ -572,29 +568,29 @@ public abstract class HSLFShape implements Shape { int r = (int)Math.rint(col.getRed()*FACTOR); int g = (int)Math.rint(col.getGreen()*FACTOR); int b = (int)Math.rint(col.getBlue()*FACTOR); - return new Color(r,g,b); + return new Color(r,g,b); } case LIGHTEN_COLOR: { double FACTOR = (0xFF-ecr.getRGB()[2])/255.; - + int r = col.getRed(); int g = col.getGreen(); int b = col.getBlue(); - + r += Math.rint((0xFF-r)*FACTOR); g += Math.rint((0xFF-g)*FACTOR); b += Math.rint((0xFF-b)*FACTOR); - + return new Color(r,g,b); } default: // TODO ... break; } - + return col; } - + double getAlpha(EscherPropertyTypes opacityProperty) { AbstractEscherOptRecord opt = getEscherOptRecord(); EscherSimpleProperty op = getEscherProperty(opt, opacityProperty); @@ -602,7 +598,7 @@ public abstract class HSLFShape implements Shape { int opacity = (op == null) ? defaultOpacity : op.getPropertyValue(); return Units.fixedPointToDouble(opacity); } - + Color toRGB(int val){ int a = (val >> 24) & 0xFF; int b = (val >> 16) & 0xFF; @@ -669,12 +665,12 @@ public abstract class HSLFShape implements Shape { } return opt; } - + public boolean getFlipHorizontal(){ EscherSpRecord spRecord = getEscherChild(EscherSpRecord.RECORD_ID); return (spRecord.getFlags()& EscherSpRecord.FLAG_FLIPHORIZ) != 0; } - + public void setFlipHorizontal(boolean flip) { EscherSpRecord spRecord = getEscherChild(EscherSpRecord.RECORD_ID); int flag = spRecord.getFlags() | EscherSpRecord.FLAG_FLIPHORIZ; @@ -685,7 +681,7 @@ public abstract class HSLFShape implements Shape { EscherSpRecord spRecord = getEscherChild(EscherSpRecord.RECORD_ID); return (spRecord.getFlags()& EscherSpRecord.FLAG_FLIPVERT) != 0; } - + public void setFlipVertical(boolean flip) { EscherSpRecord spRecord = getEscherChild(EscherSpRecord.RECORD_ID); int flag = spRecord.getFlags() | EscherSpRecord.FLAG_FLIPVERT; @@ -696,7 +692,7 @@ public abstract class HSLFShape implements Shape { int rot = getEscherProperty(EscherPropertyTypes.TRANSFORM__ROTATION); return Units.fixedPointToDouble(rot); } - + public void setRotation(double theta){ int rot = Units.doubleToFixedPoint(theta % 360.0); setEscherProperty(EscherPropertyTypes.TRANSFORM__ROTATION, rot); @@ -726,7 +722,7 @@ public abstract class HSLFShape implements Shape { /** * Search for EscherClientDataRecord, if found, convert its contents into an array of HSLF records * - * @return an array of HSLF records contained in the shape's EscherClientDataRecord or null
+ * @return an array of HSLF records contained in the shape's EscherClientDataRecord or {@code null} */ protected List extends Record> getClientRecords() { HSLFEscherClientDataRecord clientData = getClientData(false); @@ -736,7 +732,7 @@ public abstract class HSLFShape implements Shape{ /** * Create a new HSLF-specific EscherClientDataRecord * - * @param create if true, create the missing record + * @param create if true, create the missing record * @return the client record or null if it was missing and create wasn't activated */ protected HSLFEscherClientDataRecord getClientData(boolean create) { diff --git a/poi-scratchpad/src/main/java/org/apache/poi/hslf/usermodel/HSLFTextParagraph.java b/poi-scratchpad/src/main/java/org/apache/poi/hslf/usermodel/HSLFTextParagraph.java index 3f1e48c6af..318b0ffded 100644 --- a/poi-scratchpad/src/main/java/org/apache/poi/hslf/usermodel/HSLFTextParagraph.java +++ b/poi-scratchpad/src/main/java/org/apache/poi/hslf/usermodel/HSLFTextParagraph.java @@ -86,14 +86,6 @@ import org.apache.poi.util.Units; public final class HSLFTextParagraph implements TextParagraph { private static final Logger LOG = LogManager.getLogger(HSLFTextParagraph.class); - /** - * How to align the text - */ - /* package */static final int AlignLeft = 0; - /* package */static final int AlignCenter = 1; - /* package */static final int AlignRight = 2; - /* package */static final int AlignJustify = 3; - // Note: These fields are protected to help with unit testing // Other classes shouldn't really go playing with them! private final TextHeaderAtom _headerAtom; @@ -120,19 +112,23 @@ public final class HSLFTextParagraph implements TextParagraph getTabStops() { final List tabStops; - final TextRulerAtom textRuler; if (getSheet() instanceof HSLFSlideMaster) { final HSLFTabStopPropCollection tpc = getMasterPropVal(_paragraphStyle, HSLFTabStopPropCollection.NAME); if (tpc == null) { return null; } tabStops = tpc.getTabStops(); - textRuler = null; } else { - textRuler = (TextRulerAtom)_headerAtom.getParentRecord().findFirstOfType(RecordTypes.TextRulerAtom.typeID); + final TextRulerAtom textRuler = (TextRulerAtom) _headerAtom.getParentRecord().findFirstOfType(RecordTypes.TextRulerAtom.typeID); if (textRuler == null) { return null; } tabStops = textRuler.getTabStops(); } - return tabStops.stream().map((tabStop) -> new HSLFTabStopDecorator(tabStop)).collect(Collectors.toList()); + return tabStops.stream().map(HSLFTabStopDecorator::new).collect(Collectors.toList()); } @Override @@ -836,11 +816,11 @@ public final class HSLFTextParagraph implements TextParagraph runs = p.getTextRuns(); - for (int rlen=0,rIdx=0; rIdx < runs.size(); csIdx+=rlen, rIdx++) { + for (int rlen,rIdx=0; rIdx < runs.size(); csIdx+=rlen, rIdx++) { HSLFTextRun run = runs.get(rIdx); rlen = run.getLength(); if (csIdx < h.getEndIndex() && h.getStartIndex() < csIdx+rlen) { @@ -1722,8 +1701,6 @@ public final class HSLFTextParagraph implements TextParagraph palette) { this.palette = palette; diff --git a/poi-scratchpad/src/main/java/org/apache/poi/hwmf/record/HwmfEscape.java b/poi-scratchpad/src/main/java/org/apache/poi/hwmf/record/HwmfEscape.java index c56ae3f17f..39586fdd7e 100644 --- a/poi-scratchpad/src/main/java/org/apache/poi/hwmf/record/HwmfEscape.java +++ b/poi-scratchpad/src/main/java/org/apache/poi/hwmf/record/HwmfEscape.java @@ -223,6 +223,7 @@ public class HwmfEscape implements HwmfRecord { return escapeFunction; } + @SuppressWarnings("unchecked") public T getEscapeData() { return (T)escapeData; } diff --git a/poi-scratchpad/src/main/java/org/apache/poi/hwmf/record/HwmfFill.java b/poi-scratchpad/src/main/java/org/apache/poi/hwmf/record/HwmfFill.java index 90fe33881e..4dda258df2 100644 --- a/poi-scratchpad/src/main/java/org/apache/poi/hwmf/record/HwmfFill.java +++ b/poi-scratchpad/src/main/java/org/apache/poi/hwmf/record/HwmfFill.java @@ -171,10 +171,12 @@ public class HwmfFill { */ int regionIndex; + @Override public HwmfRecordType getWmfRecordType() { return HwmfRecordType.paintRegion; } + @Override public int init(LittleEndianInputStream leis, long recordSize, int recordFunction) throws IOException { regionIndex = leis.readUShort(); return LittleEndianConsts.SHORT_SIZE; diff --git a/poi-scratchpad/src/main/java/org/apache/poi/hwmf/record/HwmfRecord.java b/poi-scratchpad/src/main/java/org/apache/poi/hwmf/record/HwmfRecord.java index b68af18460..17a89185c7 100644 --- a/poi-scratchpad/src/main/java/org/apache/poi/hwmf/record/HwmfRecord.java +++ b/poi-scratchpad/src/main/java/org/apache/poi/hwmf/record/HwmfRecord.java @@ -31,10 +31,9 @@ public interface HwmfRecord extends GenericRecord { * * @param leis the little endian input stream * @return count of processed bytes - * @throws IOException */ int init(LittleEndianInputStream leis, long recordSize, int recordFunction) throws IOException; - + /** * Apply the record settings to the graphics context * @@ -43,7 +42,7 @@ public interface HwmfRecord extends GenericRecord { void draw(HwmfGraphics ctx); @Override - default Enum getGenericRecordType() { + default Enum> getGenericRecordType() { return getWmfRecordType(); } } diff --git a/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/CharIndexTranslator.java b/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/CharIndexTranslator.java index da2e913b1c..f8665be8d4 100644 --- a/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/CharIndexTranslator.java +++ b/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/CharIndexTranslator.java @@ -44,7 +44,6 @@ public interface CharIndexTranslator { /** * Check if index is in table * - * @param bytePos * @return true if index in table, false if not */ boolean isIndexInTable(int bytePos); @@ -52,7 +51,6 @@ public interface CharIndexTranslator { /** * Return first index >= bytePos that is in table * - * @param bytePos * @return first index greater or equal to bytePos that is in table */ int lookIndexForward(int bytePos); @@ -60,7 +58,6 @@ public interface CharIndexTranslator { /** * Return last index <= bytePos that is in table * - * @param bytePos * @return last index less of equal to bytePos that is in table */ int lookIndexBackward(int bytePos); diff --git a/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/FileInformationBlock.java b/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/FileInformationBlock.java index 0fb355cc4a..ecb125b6e8 100644 --- a/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/FileInformationBlock.java +++ b/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/FileInformationBlock.java @@ -38,7 +38,7 @@ import static org.apache.logging.log4j.util.Unbox.box; /** * The File Information Block (FIB). Holds pointers * to various bits of the file, and lots of flags which - * specify properties of the document.
+ * specify properties of the document. *
*
- The {@link FibBase} class, holds the first 32 bytes.
*- The next part, the fibRgW / FibRgW97, is handled by the {@link FibRgW97}.
@@ -244,12 +244,12 @@ public final class FileInformationBlock { // field info for ( FieldsDocumentPart part : FieldsDocumentPart.values() ) - knownFieldSet.add( Integer.valueOf( part.getFibFieldsField() ) ); + knownFieldSet.add(part.getFibFieldsField()); // bookmarks - knownFieldSet.add( Integer.valueOf( FIBFieldHandler.PLCFBKF ) ); - knownFieldSet.add( Integer.valueOf( FIBFieldHandler.PLCFBKL ) ); - knownFieldSet.add( Integer.valueOf( FIBFieldHandler.STTBFBKMK ) ); + knownFieldSet.add(FIBFieldHandler.PLCFBKF); + knownFieldSet.add(FIBFieldHandler.PLCFBKL); + knownFieldSet.add(FIBFieldHandler.STTBFBKMK); // notes for ( NoteType noteType : NoteType.values() ) { diff --git a/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/OldCHPBinTable.java b/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/OldCHPBinTable.java index 04fdd322a2..24c2a95610 100644 --- a/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/OldCHPBinTable.java +++ b/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/OldCHPBinTable.java @@ -33,13 +33,7 @@ import org.apache.poi.util.LittleEndian; public final class OldCHPBinTable extends CHPBinTable { /** - * Constructor used to read an old-style binTable - * in from a Word document. - * - * @param documentStream - * @param offset - * @param size - * @param fcMin + * Constructor used to read an old-style binTable in from a Word document. */ public OldCHPBinTable(byte[] documentStream, int offset, int size, int fcMin, OldTextPieceTable tpt) diff --git a/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/OldTextPiece.java b/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/OldTextPiece.java index b14c38223d..22289ae954 100644 --- a/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/OldTextPiece.java +++ b/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/OldTextPiece.java @@ -52,7 +52,6 @@ public class OldTextPiece extends TextPiece { /** * @return nothing, ever. Always throws an UnsupportedOperationException - * @throws UnsupportedOperationException */ @NotImplemented @Override @@ -77,8 +76,8 @@ public class OldTextPiece extends TextPiece { * * @param start Local start position, in characters * @param end Local end position, in characters - * @throws UnsupportedOperationException */ + @Override @Deprecated @NotImplemented public String substring(int start, int end) { @@ -89,6 +88,7 @@ public class OldTextPiece extends TextPiece { * Not implemented for OldTextPiece. * Always throws UnsupportedOperationException */ + @Override @Deprecated @NotImplemented public void adjustForDelete(int start, int length) { @@ -98,6 +98,7 @@ public class OldTextPiece extends TextPiece { /** * Returns the length, in bytes */ + @Override public int bytesLength() { return rawBytes.length; } diff --git a/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/OldTextPieceTable.java b/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/OldTextPieceTable.java index e6a0887f32..478af6a272 100644 --- a/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/OldTextPieceTable.java +++ b/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/OldTextPieceTable.java @@ -94,7 +94,7 @@ public class OldTextPieceTable extends TextPieceTable { // into order, if they're not already Collections.sort(_textPieces); _textPiecesFCOrder = new ArrayList<>(_textPieces); - _textPiecesFCOrder.sort(new FCComparator()); + _textPiecesFCOrder.sort(byFilePosition()); } diff --git a/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/PlexOfCps.java b/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/PlexOfCps.java index 658cb60c9e..6c8ee4dd46 100644 --- a/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/PlexOfCps.java +++ b/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/PlexOfCps.java @@ -39,8 +39,8 @@ public final class PlexOfCps { private static final int MAX_RECORD_LENGTH = 10_485_760; private int _iMac; - private int _cbStruct; - private List_props; + private final int _cbStruct; + private final List _props; public PlexOfCps(int sizeOfStruct) { _props = new ArrayList<>(); @@ -69,18 +69,10 @@ public final class PlexOfCps { void adjust(int startCp, int shift) { for (GenericPropertyNode node : _props) { if (node.getStart() > startCp) { - if (node.getStart() + shift < startCp) { - node.setStart(startCp); - } else { - node.setStart(node.getStart() + shift); - } + node.setStart(Math.max(node.getStart() + shift, startCp)); } if (node.getEnd() >= startCp) { - if (node.getEnd() + shift < startCp) { - node.setEnd(startCp); - } else { - node.setEnd(node.getEnd() + shift); - } + node.setEnd(Math.max(node.getEnd() + shift, startCp)); } } } diff --git a/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/PlfLfo.java b/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/PlfLfo.java index 79b8587bae..b92c2d41b2 100644 --- a/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/PlfLfo.java +++ b/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/PlfLfo.java @@ -162,7 +162,6 @@ public class PlfLfo /** * @param ilfo 1-based index * @return The {@link LFO} stored at the given index - * @throws NoSuchElementException */ public LFO getLfo( int ilfo ) throws NoSuchElementException { @@ -177,7 +176,6 @@ public class PlfLfo /** * @param ilfo 1-based index * @return The {@link LFOData} stored at the given index - * @throws NoSuchElementException */ public LFOData getLfoData( int ilfo ) throws NoSuchElementException { diff --git a/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/TextPiece.java b/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/TextPiece.java index 0c606cbf03..bdb9ba492a 100644 --- a/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/TextPiece.java +++ b/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/TextPiece.java @@ -32,9 +32,9 @@ import org.apache.poi.util.StringUtil; */ @Internal public class TextPiece extends PropertyNode { - private boolean _usesUnicode; + private final boolean _usesUnicode; - private PieceDescriptor _pd; + private final PieceDescriptor _pd; public TextPiece(TextPiece other) { super(other); @@ -142,6 +142,7 @@ public class TextPiece extends PropertyNode { * @param start The start position for the delete, in characters * @param length The number of characters to delete */ + @Override @Deprecated public void adjustForDelete(int start, int length) { int myStart = getStart(); diff --git a/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/TextPieceTable.java b/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/TextPieceTable.java index 22434de9a2..5f8c4da5ee 100644 --- a/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/TextPieceTable.java +++ b/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/TextPieceTable.java @@ -18,7 +18,6 @@ package org.apache.poi.hwpf.model; import java.io.ByteArrayOutputStream; import java.io.IOException; -import java.io.Serializable; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; @@ -114,7 +113,7 @@ public class TextPieceTable implements CharIndexTranslator { // into order, if they're not already Collections.sort(_textPieces); _textPiecesFCOrder = new ArrayList<>(_textPieces); - _textPiecesFCOrder.sort(new FCComparator()); + _textPiecesFCOrder.sort(byFilePosition()); } protected TextPiece newTextPiece(int nodeStartChars, int nodeEndChars, byte[] buf, PieceDescriptor pd) { @@ -125,7 +124,7 @@ public class TextPieceTable implements CharIndexTranslator { _textPieces.add(piece); _textPiecesFCOrder.add(piece); Collections.sort(_textPieces); - _textPiecesFCOrder.sort(new FCComparator()); + _textPiecesFCOrder.sort(byFilePosition()); } /** @@ -169,6 +168,7 @@ public class TextPieceTable implements CharIndexTranslator { return false; } + @Override public int getByteIndex(int charPos) { int byteCount = 0; for (TextPiece tp : _textPieces) { @@ -308,6 +308,7 @@ public class TextPieceTable implements CharIndexTranslator { return _textPieces.hashCode(); } + @Override public boolean isIndexInTable(int bytePos) { for (TextPiece tp : _textPiecesFCOrder) { int pieceStart = tp.getPieceDescriptor().getFilePosition(); @@ -339,6 +340,7 @@ public class TextPieceTable implements CharIndexTranslator { return false; } + @Override public int lookIndexBackward(final int startBytePos) { int bytePos = startBytePos; int lastEnd = 0; @@ -361,6 +363,7 @@ public class TextPieceTable implements CharIndexTranslator { return bytePos; } + @Override public int lookIndexForward(final int startBytePos) { if (_textPiecesFCOrder.isEmpty()) throw new IllegalStateException("Text pieces table is empty"); @@ -433,10 +436,7 @@ public class TextPieceTable implements CharIndexTranslator { return textPlex.toByteArray(); } - protected static class FCComparator implements Comparator , Serializable { - public int compare(TextPiece textPiece, TextPiece textPiece1) { - return Integer.compare(textPiece.getPieceDescriptor().fc, textPiece1 - .getPieceDescriptor().fc); - } + static Comparator byFilePosition() { + return Comparator.comparing(t -> t.getPieceDescriptor().getFilePosition()); } } diff --git a/poi-scratchpad/src/main/java/org/apache/poi/hwpf/usermodel/HeaderStories.java b/poi-scratchpad/src/main/java/org/apache/poi/hwpf/usermodel/HeaderStories.java index b15757ae03..8df6f545c7 100644 --- a/poi-scratchpad/src/main/java/org/apache/poi/hwpf/usermodel/HeaderStories.java +++ b/poi-scratchpad/src/main/java/org/apache/poi/hwpf/usermodel/HeaderStories.java @@ -34,7 +34,7 @@ import org.apache.poi.hwpf.model.SubdocumentType; * as offsets are not yet updated! */ public final class HeaderStories { - private Range headerStories; + private final Range headerStories; private PlexOfCps plcfHdd; private boolean stripFields; @@ -50,7 +50,7 @@ public final class HeaderStories { if (fib.getSubdocumentTextStreamLength( SubdocumentType.HEADER ) == 0) return; - + if(fib.getPlcfHddSize() == 0) { return; } @@ -58,7 +58,7 @@ public final class HeaderStories { // Handle the PlcfHdd /* * Page 88: - * + * * "The plcfhdd, a table whose location and length within the file is * stored in fib.fcPlcfhdd and fib.cbPlcfhdd, describes where the text * of each header/footer begins. If there are n headers/footers stored @@ -69,11 +69,11 @@ public final class HeaderStories { * plcfhdd. Note: at the limit CP - 1, Word always places a chEop as a * placeholder which is never displayed as part of the header/footer. * This allows Word to change an existing header/footer to be empty. - * + * * If there are n header/footers, the n+2nd CP entry value is always 1 * greater than the n+1st CP entry value. A paragraph end (ASCII 13) is * always stored at the file position marked by the n+1st CP value. - * + * * The transformation in a full saved file from a header/footer CP to an * offset from the beginning of a file (fc) is * fc=fib.fcMin+ccpText+ccpFtn+cp." @@ -83,7 +83,7 @@ public final class HeaderStories { } /** - * @deprecated 3.8 beta 4 + * @deprecated 3.8 beta 4 */ @Deprecated public String getFootnoteSeparator() @@ -92,7 +92,7 @@ public final class HeaderStories { } /** - * @deprecated 3.8 beta 4 + * @deprecated 3.8 beta 4 */ @Deprecated public String getFootnoteContSeparator() @@ -101,7 +101,7 @@ public final class HeaderStories { } /** - * @deprecated 3.8 beta 4 + * @deprecated 3.8 beta 4 */ @Deprecated public String getFootnoteContNote() @@ -110,7 +110,7 @@ public final class HeaderStories { } /** - * @deprecated 3.8 beta 4 + * @deprecated 3.8 beta 4 */ @Deprecated public String getEndnoteSeparator() @@ -119,7 +119,7 @@ public final class HeaderStories { } /** - * @deprecated 3.8 beta 4 + * @deprecated 3.8 beta 4 */ @Deprecated public String getEndnoteContSeparator() @@ -128,7 +128,7 @@ public final class HeaderStories { } /** - * @deprecated 3.8 beta 4 + * @deprecated 3.8 beta 4 */ @Deprecated public String getEndnoteContNote() @@ -167,27 +167,27 @@ public final class HeaderStories { } /** - * @deprecated 3.8 beta 4 + * @deprecated 3.8 beta 4 */ @Deprecated public String getEvenHeader() { return getAt(6+0); } /** - * @deprecated 3.8 beta 4 + * @deprecated 3.8 beta 4 */ @Deprecated public String getOddHeader() { return getAt(6+1); } /** - * @deprecated 3.8 beta 4 + * @deprecated 3.8 beta 4 */ @Deprecated public String getFirstHeader() { return getAt(6+4); } - + public Range getEvenHeaderSubrange() { return getSubrangeAt(6+0); @@ -198,7 +198,7 @@ public final class HeaderStories { public Range getFirstHeaderSubrange() { return getSubrangeAt(6+4); } - + /** * Returns the correct, defined header for the given * one based page @@ -226,7 +226,7 @@ public final class HeaderStories { } /** - * @deprecated 3.8 beta 4 + * @deprecated 3.8 beta 4 */ @Deprecated public String getEvenFooter() @@ -235,7 +235,7 @@ public final class HeaderStories { } /** - * @deprecated 3.8 beta 4 + * @deprecated 3.8 beta 4 */ @Deprecated public String getOddFooter() @@ -244,7 +244,7 @@ public final class HeaderStories { } /** - * @deprecated 3.8 beta 4 + * @deprecated 3.8 beta 4 */ @Deprecated public String getFirstFooter() @@ -370,7 +370,7 @@ public final class HeaderStories { /** * Are fields currently being stripped from - * the text that this {@link HeaderStories} returns? + * the text that this HeaderStories returns? * Default is false, but can be changed */ public boolean areFieldsStripped() { @@ -380,7 +380,6 @@ public final class HeaderStories { * Should fields (eg macros) be stripped from * the text that this class returns? * Default is not to strip. - * @param stripFields */ public void setAreFieldsStripped(boolean stripFields) { this.stripFields = stripFields; diff --git a/poi-scratchpad/src/main/java/org/apache/poi/hwpf/usermodel/Picture.java b/poi-scratchpad/src/main/java/org/apache/poi/hwpf/usermodel/Picture.java index d4283a612b..26bfc0546a 100644 --- a/poi-scratchpad/src/main/java/org/apache/poi/hwpf/usermodel/Picture.java +++ b/poi-scratchpad/src/main/java/org/apache/poi/hwpf/usermodel/Picture.java @@ -30,15 +30,19 @@ import org.apache.logging.log4j.Logger; import org.apache.poi.ddf.EscherBSERecord; import org.apache.poi.ddf.EscherBlipRecord; import org.apache.poi.ddf.EscherComplexProperty; +import org.apache.poi.ddf.EscherContainerRecord; import org.apache.poi.ddf.EscherOptRecord; import org.apache.poi.ddf.EscherProperty; import org.apache.poi.ddf.EscherPropertyTypes; import org.apache.poi.ddf.EscherRecord; +import org.apache.poi.ddf.EscherRecordTypes; +import org.apache.poi.ddf.EscherSimpleProperty; import org.apache.poi.hwpf.model.PICF; import org.apache.poi.hwpf.model.PICFAndOfficeArtData; import org.apache.poi.sl.image.ImageHeaderPNG; import org.apache.poi.util.IOUtils; import org.apache.poi.util.StringUtil; +import org.apache.poi.util.Units; /** * Represents embedded picture extracted from Word Document @@ -264,42 +268,42 @@ public final class Picture { /** * @return The amount the picture has been cropped on the left in twips - * @deprecated POI 3.8 beta 4. */ - @Deprecated - public int getDxaCropLeft() - { - // TODO: use new properties - // if (_picfAndOfficeArtData == null || _picfAndOfficeArtData.getShape() - // == null) - // return 0; - // - // final EscherContainerRecord shape = _picfAndOfficeArtData.getShape(); - // EscherOptRecord optRecord = shape.getChildById( (short) 0xF00B ); - // if (optRecord == null) - // return 0; - // - // EscherProperty property = optRecord.lookup( 0x0102 ); - // if (property == null || !(property instanceof EscherSimpleProperty)) - // return 0; - // - // EscherSimpleProperty simpleProperty = (EscherSimpleProperty) - // property; - // return simpleProperty.getPropertyValue(); - + public int getDxaCropLeft() { return _picf.getDxaReserved1(); } /** - * @return The amount the picture has been cropped on the right in twips - * @deprecated POI 3.8 beta 4. + * The location, expressed as a fraction of the image width, of the left side of + * the crop rectangle. A value of 0 specifies that the left side of the image is uncropped. + * Positive values specify cropping into the image. Negative values specify cropping out from the + * image. The default value for this property is 0. + * + * @return the left crop percent */ - @Deprecated - public int getDxaCropRight() - { + public double getCropLeft() { + return getCrop(EscherPropertyTypes.BLIP__CROPFROMLEFT); + } + + /** + * @return The amount the picture has been cropped on the right in twips + */ + public int getDxaCropRight() { return _picf.getDxaReserved2(); } + /** + * the location of the right side, expressed as a fraction of the image width, of + * the crop rectangle. A value of 0 specifies that the right side of the image is uncropped. + * Positive values specify cropping into the image. Negative values specify cropping out from the + * image. The default value for this property is 0. + * + * @return the right crop percent + */ + public double getCropRight() { + return getCrop(EscherPropertyTypes.BLIP__CROPFROMRIGHT); + } + /** * Gets the initial width of the picture, in twips, prior to cropping or * scaling. @@ -313,24 +317,57 @@ public final class Picture { /** * @return The amount the picture has been cropped on the bottom in twips - * @deprecated POI 3.8 beta 5. */ - @Deprecated - public int getDyaCropBottom() - { + public int getDyaCropBottom() { return _picf.getDyaReserved2(); } /** - * @return The amount the picture has been cropped on the top in twips - * @deprecated POI 3.8 beta 5. + * the location, expressed as a fraction of the image height, of the bottom of + * the crop rectangle. A value of 0 specifies that the bottom of the image is uncropped. + * Positive values specify cropping into the image. Negative values specify cropping out from the + * image. The default value for this property is 0 + * + * @return the bottom crop percent */ - @Deprecated - public int getDyaCropTop() - { + public double getCropBottom() { + return getCrop(EscherPropertyTypes.BLIP__CROPFROMBOTTOM); + } + + /** + * @return The amount the picture has been cropped on the top in twips + */ + public int getDyaCropTop() { return _picf.getDyaReserved1(); } + /** + * the location, expressed as a fraction of the image height, of the top of the crop + * rectangle. A value of 0 specifies that the top of the image is uncropped. Positive values + * specify cropping into the image. Negative values specify cropping out from the image. The default + * value for this property is 0. + * + * @return the top crop percent + */ + public double getCropTop() { + return getCrop(EscherPropertyTypes.BLIP__CROPFROMTOP); + } + + private double getCrop(EscherPropertyTypes propType) { + EscherContainerRecord shape; + if (_picfAndOfficeArtData != null && (shape = _picfAndOfficeArtData.getShape()) != null) { + EscherOptRecord optRecord = shape.getChildById(EscherRecordTypes.OPT.typeID); + if (optRecord != null) { + EscherProperty property = optRecord.lookup(propType); + if (property instanceof EscherSimpleProperty) { + EscherSimpleProperty simpleProperty = (EscherSimpleProperty) property; + return Units.fixedPointToDouble(simpleProperty.getPropertyValue()); + } + } + } + return 0; + } + /** * Gets the initial height of the picture, in twips, prior to cropping or * scaling. @@ -490,62 +527,59 @@ public final class Picture { + ( fileExt.length() > 0 ? "." + fileExt : "" ); } - public PictureType suggestPictureType() - { + public PictureType suggestPictureType() { if (_blipRecords.size() != 1 ) { return PictureType.UNKNOWN; } EscherRecord escherRecord = _blipRecords.get( 0 ); - switch ( escherRecord.getRecordId() ) - { - case (short) 0xF007: - { + if (escherRecord instanceof EscherBSERecord) { EscherBSERecord bseRecord = (EscherBSERecord) escherRecord; - switch ( bseRecord.getBlipTypeWin32() ) - { - case 0x00: - return PictureType.UNKNOWN; - case 0x01: - return PictureType.UNKNOWN; - case 0x02: - return PictureType.EMF; - case 0x03: - return PictureType.WMF; - case 0x04: - return PictureType.PICT; - case 0x05: - return PictureType.JPEG; - case 0x06: - return PictureType.PNG; - case 0x07: - return PictureType.BMP; - case 0x11: - return PictureType.TIFF; - case 0x12: - return PictureType.JPEG; - default: - return PictureType.UNKNOWN; + switch ( bseRecord.getBlipTypeWin32() ) { + case 0x00: + return PictureType.UNKNOWN; + case 0x01: + return PictureType.UNKNOWN; + case 0x02: + return PictureType.EMF; + case 0x03: + return PictureType.WMF; + case 0x04: + return PictureType.PICT; + case 0x05: + return PictureType.JPEG; + case 0x06: + return PictureType.PNG; + case 0x07: + return PictureType.BMP; + case 0x11: + return PictureType.TIFF; + case 0x12: + return PictureType.JPEG; + default: + return PictureType.UNKNOWN; } } - case (short) 0xF01A: - return PictureType.EMF; - case (short) 0xF01B: - return PictureType.WMF; - case (short) 0xF01C: - return PictureType.PICT; - case (short) 0xF01D: - return PictureType.JPEG; - case (short) 0xF01E: - return PictureType.PNG; - case (short) 0xF01F: - return PictureType.BMP; - case (short) 0xF029: - return PictureType.TIFF; - case (short) 0xF02A: - return PictureType.JPEG; - default: - return PictureType.UNKNOWN; + + Enum> recordType = escherRecord.getGenericRecordType(); + assert (recordType instanceof EscherRecordTypes); + switch ((EscherRecordTypes)recordType) { + case BLIP_EMF: + return PictureType.EMF; + case BLIP_WMF: + return PictureType.WMF; + case BLIP_PICT: + return PictureType.PICT; + case BLIP_JPEG: + return PictureType.JPEG; + case BLIP_PNG: + return PictureType.PNG; + case BLIP_DIB: + return PictureType.BMP; + case BLIP_TIFF: + return PictureType.TIFF; + default: + return PictureType.UNKNOWN; } } diff --git a/poi-scratchpad/src/main/java/org/apache/poi/hwpf/util/DoubleByteUtil.java b/poi-scratchpad/src/main/java/org/apache/poi/hwpf/util/DoubleByteUtil.java index 5d55711ed9..6c8ef1214b 100644 --- a/poi-scratchpad/src/main/java/org/apache/poi/hwpf/util/DoubleByteUtil.java +++ b/poi-scratchpad/src/main/java/org/apache/poi/hwpf/util/DoubleByteUtil.java @@ -40,9 +40,6 @@ public class DoubleByteUtil * We know MS zero-padded ascii, and we drop those. * There may be areas for improvement in this. * - * @param data - * @param offset - * @param lengthInBytes * @return Decoded String */ public static String cp950ToString(byte[] data, int offset, int lengthInBytes) { diff --git a/poi-scratchpad/src/test/java/org/apache/poi/hwpf/converter/TestWordToHtmlConverter.java b/poi-scratchpad/src/test/java/org/apache/poi/hwpf/converter/TestWordToHtmlConverter.java index a7e8b1fec7..ed42294333 100644 --- a/poi-scratchpad/src/test/java/org/apache/poi/hwpf/converter/TestWordToHtmlConverter.java +++ b/poi-scratchpad/src/test/java/org/apache/poi/hwpf/converter/TestWordToHtmlConverter.java @@ -100,7 +100,7 @@ public class TestWordToHtmlConverter { }) void testFile(String file, String contains) throws Exception { - boolean emulatePictureStorage = file.contains("picture"); + boolean emulatePictureStorage = !file.contains("equation"); String result = getHtmlText(file, emulatePictureStorage); assertNotNull(result); diff --git a/poi/build.gradle b/poi/build.gradle index 23d024c516..df8997bf8c 100644 --- a/poi/build.gradle +++ b/poi/build.gradle @@ -50,6 +50,7 @@ dependencies { testImplementation "org.junit.jupiter:junit-jupiter-api:${junitVersion}" testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:${junitVersion}" + // needed for locating the external references javadocs project(':poi-ooxml') javadocs project(':poi-scratchpad') } @@ -59,13 +60,6 @@ final Pattern MODULE_NOT_REGEX = ~'(poi[/\\\\][^/\\\\]+$|batik-script)' final Pattern MODULE_REGEX = ~'\\.jar$' final List MODULE_PATH = sourceSets.test.runtimeClasspath.findAll{ it.path =~ MODULE_REGEX && !(it.path =~ MODULE_NOT_REGEX) }.collect{ it.parent }.unique() -java { - sourceCompatibility = JavaVersion.VERSION_1_8 - targetCompatibility = JavaVersion.VERSION_1_8 - withJavadocJar() - withSourcesJar() -} - task compileJava9(type: JavaCompile) { dependsOn 'compileJava' @@ -110,8 +104,6 @@ task cacheTest9(type: Copy) { } jar { - destinationDirectory = file("../build/dist/maven/${project.archivesBaseName}") - if (JavaVersion.current() == JavaVersion.VERSION_1_8) { into('META-INF/versions/9') { from JAVA9_SRC include '*.class' @@ -145,24 +137,12 @@ task testJar(type: Jar, dependsOn: testClasses) { } } -sourcesJar { - destinationDirectory = file("../build/dist/maven/${project.archivesBaseName}") - exclude 'META-INF/services/**' -} - javadoc { - failOnError = true + dependsOn configurations.javadocs.dependencies.collect{ ':' + it.dependencyProject.name + ':compileJava' } + doFirst { options { - if (JavaVersion.current().isJava9Compatible()) { - addBooleanOption('html5', true) - } - links 'https://poi.apache.org/apidocs/dev/' - links 'https://docs.oracle.com/javase/8/docs/api/' - use = true - splitIndex = true - source = "1.8" - classpath += configurations.javadocs.files + classpath += files(configurations.javadocs.dependencies.collect{ it.dependencyProject.sourceSets.main.output.classesDirs }) } } } @@ -174,39 +154,10 @@ artifacts { test { dependsOn { testJar } - useJUnitPlatform() - doFirst { - jvmArgs = [ - '-Djava.io.tmpdir=build', - '-DPOI.testdata.path=../test-data', - '-Djava.awt.headless=true', - '-Djava.locale.providers=JRE,CLDR', - '-Duser.language=en', - '-Duser.country=US', - '-Djavax.xml.stream.XMLInputFactory=com.sun.xml.internal.stream.XMLInputFactoryImpl', - "-Dversion.id=${project.version}", - '-ea', - '-Djunit.jupiter.execution.parallel.enabled=true', - '-Djunit.jupiter.execution.parallel.config.strategy=fixed', - '-Djunit.jupiter.execution.parallel.config.fixed.parallelism=3' - // -Xjit:verbose={compileStart|compileEnd},vlog=build/jit.log${no.jit.sherlock} ... if ${isIBMVM} - ] if (JavaVersion.current() != JavaVersion.VERSION_1_8) { - jvmArgs += [ - '-Dsun.reflect.debugModuleAccessChecks=true', - '-Dcom.sun.xml.bind.v2.bytecode.ClassTailor.noOptimize=true', - '--illegal-access=warn', - + jvmArgs << [ '--add-modules', MODULE_NAME, - - // see https://github.com/java9-modularity/gradle-modules-plugin/issues/97 - // opposed to the recommendation there, it doesn't work to add ... to the dependencies - // testRuntimeOnly 'org.junit.platform:junit-platform-launcher:1.7.1' - // gradles gradle-worker.jar is still not a JPMS module and thus runs as unnamed module - '--add-exports','org.junit.platform.commons/org.junit.platform.commons.util=ALL-UNNAMED', - '--add-exports','org.junit.platform.commons/org.junit.platform.commons.logging=ALL-UNNAMED', - '--module-path', '../build/dist/maven/poi-tests:' + files(MODULE_PATH).asPath, ] } @@ -216,16 +167,10 @@ test { publishing { publications { POI(MavenPublication) { - artifactId project.archivesBaseName - - from components.java - pom { - name = 'Apache POI' + name = 'Apache POI - Common' description = 'Apache POI - Java API To Access Microsoft Format Files' } } } -} - -generatePomFileForPOIPublication.destination = "../build/dist/maven/${project.archivesBaseName}/${project.archivesBaseName}-${project.version}.pom" +} \ No newline at end of file diff --git a/poi/src/main/java/org/apache/poi/ddf/EscherRecordTypes.java b/poi/src/main/java/org/apache/poi/ddf/EscherRecordTypes.java index c65169e001..4f11dab6c0 100644 --- a/poi/src/main/java/org/apache/poi/ddf/EscherRecordTypes.java +++ b/poi/src/main/java/org/apache/poi/ddf/EscherRecordTypes.java @@ -79,6 +79,7 @@ public enum EscherRecordTypes { BLIP_JPEG(0xf018 + 5 /* 0xf01d */, "BlipJpeg", null, EscherBitmapBlip::new), BLIP_PNG(0xf018 + 6 /* 0xf01e */, "BlipPng", null, EscherBitmapBlip::new), BLIP_DIB(0xf018 + 7 /* 0xf01f */, "BlipDib", null, EscherBitmapBlip::new), + BLIP_TIFF(0xf018 + 17 /* 0xf029 */, "BlipTiff", null, EscherBitmapBlip::new), BLIP_END(0xf117, "Blip", "msofbtBlip", null), REGROUP_ITEMS(0xf118, null, null, null), SELECTION(0xf119, null, null, null), @@ -111,6 +112,11 @@ public enum EscherRecordTypes { Stream.of(values()).collect(Collectors.toMap(EscherRecordTypes::getTypeId, Function.identity())); public static EscherRecordTypes forTypeID(int typeID) { + // Section 2.2.23: 0xF02A is treated as 0xF01D + if (typeID == 0xF02A) { + return EscherRecordTypes.BLIP_JPEG; + } + EscherRecordTypes rt = LOOKUP.get((short)typeID); return (rt != null) ? rt : EscherRecordTypes.UNKNOWN; } diff --git a/poi/src/main/java/org/apache/poi/ddf/EscherShapePathProperty.java b/poi/src/main/java/org/apache/poi/ddf/EscherShapePathProperty.java index 0d0f422155..fd8da317f7 100644 --- a/poi/src/main/java/org/apache/poi/ddf/EscherShapePathProperty.java +++ b/poi/src/main/java/org/apache/poi/ddf/EscherShapePathProperty.java @@ -30,9 +30,6 @@ public class EscherShapePathProperty extends EscherSimpleProperty { /** * Create an instance of an escher shape path property. - * - * @param propertyNumber - * @param shapePath */ public EscherShapePathProperty( short propertyNumber, int shapePath ) { super( propertyNumber, false, false, shapePath ); diff --git a/poi/src/main/java/org/apache/poi/extractor/ExtractorFactory.java b/poi/src/main/java/org/apache/poi/extractor/ExtractorFactory.java index d7363a5e8a..b804ec9fd5 100644 --- a/poi/src/main/java/org/apache/poi/extractor/ExtractorFactory.java +++ b/poi/src/main/java/org/apache/poi/extractor/ExtractorFactory.java @@ -30,6 +30,7 @@ import java.util.stream.StreamSupport; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.apache.poi.EmptyFileException; +import org.apache.poi.OldFileFormatException; import org.apache.poi.hssf.extractor.ExcelExtractor; import org.apache.poi.poifs.crypt.Decryptor; import org.apache.poi.poifs.filesystem.DirectoryEntry; diff --git a/poi/src/main/java/org/apache/poi/hssf/record/ProtectionRev4Record.java b/poi/src/main/java/org/apache/poi/hssf/record/ProtectionRev4Record.java index dff1c5cffd..14c8327588 100644 --- a/poi/src/main/java/org/apache/poi/hssf/record/ProtectionRev4Record.java +++ b/poi/src/main/java/org/apache/poi/hssf/record/ProtectionRev4Record.java @@ -26,7 +26,7 @@ import org.apache.poi.util.GenericRecordUtil; import org.apache.poi.util.LittleEndianOutput; /** - * Describes whether this is a protected shared/tracked workbook + * Describes whether this is a protected shared/tracked workbook */ public final class ProtectionRev4Record extends StandardRecord { public static final short sid = 0x01AF; @@ -69,14 +69,17 @@ public final class ProtectionRev4Record extends StandardRecord { return protectedFlag.isSet(_options); } + @Override public void serialize(LittleEndianOutput out) { out.writeShort(_options); } + @Override protected int getDataSize() { return 2; } + @Override public short getSid() { return sid; } diff --git a/poi/src/main/java/org/apache/poi/hssf/record/RKRecord.java b/poi/src/main/java/org/apache/poi/hssf/record/RKRecord.java index d6737ad00d..183b5e3f7d 100644 --- a/poi/src/main/java/org/apache/poi/hssf/record/RKRecord.java +++ b/poi/src/main/java/org/apache/poi/hssf/record/RKRecord.java @@ -29,7 +29,7 @@ import org.apache.poi.util.LittleEndianOutput; * This is part of a bizarre scheme to save disk space and memory (gee look at all the other whole * records that are in the file just "cause".., far better to waste processor cycles on this then * leave on of those "valuable" records out). - * We support this in READ-ONLY mode. HSSF converts these to NUMBER records
+ * We support this in READ-ONLY mode. HSSF converts these to NUMBER records * * @see org.apache.poi.hssf.record.NumberRecord */ @@ -40,7 +40,7 @@ public final class RKRecord extends CellRecord { public static final short RK_INTEGER = 2; public static final short RK_INTEGER_TIMES_100 = 3; - private int field_4_rk_number; + private final int field_4_rk_number; public RKRecord(RKRecord other) { super(other); diff --git a/poi/src/main/java/org/apache/poi/hssf/record/WriteAccessRecord.java b/poi/src/main/java/org/apache/poi/hssf/record/WriteAccessRecord.java index f1bf1373c3..6607d85487 100644 --- a/poi/src/main/java/org/apache/poi/hssf/record/WriteAccessRecord.java +++ b/poi/src/main/java/org/apache/poi/hssf/record/WriteAccessRecord.java @@ -31,7 +31,7 @@ import org.apache.poi.util.StringUtil; * Title: Write Access Record (0x005C)
* * Description: Stores the username of that who owns the spreadsheet generator (on unix the user's - * login, on Windoze its the name you typed when you installed the thing)
+ * login, on Windoze its the name you typed when you installed the thing) */ public final class WriteAccessRecord extends StandardRecord { public static final short sid = 0x005C; @@ -124,6 +124,7 @@ public final class WriteAccessRecord extends StandardRecord { return field_1_username; } + @Override public void serialize(LittleEndianOutput out) { String username = getUsername(); boolean is16bit = StringUtil.hasMultibyte(username); @@ -140,10 +141,12 @@ public final class WriteAccessRecord extends StandardRecord { out.write(PADDING, 0, paddingSize); } + @Override protected int getDataSize() { return DATA_SIZE; } + @Override public short getSid() { return sid; } diff --git a/poi/src/main/java/org/apache/poi/hssf/record/aggregates/MergedCellsTable.java b/poi/src/main/java/org/apache/poi/hssf/record/aggregates/MergedCellsTable.java index 667f736c6c..a3550106e8 100644 --- a/poi/src/main/java/org/apache/poi/hssf/record/aggregates/MergedCellsTable.java +++ b/poi/src/main/java/org/apache/poi/hssf/record/aggregates/MergedCellsTable.java @@ -40,7 +40,6 @@ public final class MergedCellsTable extends RecordAggregate { /** * reads zero or more consecutive {@link MergeCellsRecord}s - * @param rs */ public void read(RecordStream rs) { while (rs.peekNextClass() == MergeCellsRecord.class) { @@ -92,8 +91,8 @@ public final class MergedCellsTable extends RecordAggregate { } } public void addRecords(MergeCellsRecord[] mcrs) { - for (int i = 0; i < mcrs.length; i++) { - addMergeCellsRecord(mcrs[i]); + for (MergeCellsRecord mcr : mcrs) { + addMergeCellsRecord(mcr); } } diff --git a/poi/src/main/java/org/apache/poi/hssf/record/chart/TickRecord.java b/poi/src/main/java/org/apache/poi/hssf/record/chart/TickRecord.java index 434f9aa74e..f5a0e05536 100644 --- a/poi/src/main/java/org/apache/poi/hssf/record/chart/TickRecord.java +++ b/poi/src/main/java/org/apache/poi/hssf/record/chart/TickRecord.java @@ -32,7 +32,7 @@ import org.apache.poi.util.BitFieldFactory; import org.apache.poi.util.LittleEndianOutput; /** - * The Tick record defines how tick marks and label positioning/formatting
+ * The Tick record defines how tick marks and label positioning/formatting */ public final class TickRecord extends StandardRecord { public static final short sid = 0x101E; @@ -90,6 +90,7 @@ public final class TickRecord extends StandardRecord { field_12_zero5 = in.readShort(); } + @Override public void serialize(LittleEndianOutput out) { out.writeByte(field_1_majorTickType); out.writeByte(field_2_minorTickType); @@ -105,10 +106,12 @@ public final class TickRecord extends StandardRecord { out.writeShort(field_12_zero5); } + @Override protected int getDataSize() { return 1 + 1 + 1 + 1 + 4 + 8 + 8 + 2 + 2 + 2; } + @Override public short getSid() { return sid; diff --git a/poi/src/main/java/org/apache/poi/hssf/record/common/UnicodeString.java b/poi/src/main/java/org/apache/poi/hssf/record/common/UnicodeString.java index d9b56d7e7d..f087facd8e 100644 --- a/poi/src/main/java/org/apache/poi/hssf/record/common/UnicodeString.java +++ b/poi/src/main/java/org/apache/poi/hssf/record/common/UnicodeString.java @@ -42,7 +42,7 @@ import static org.apache.logging.log4j.util.Unbox.box; /** * Unicode String - just standard fields that are in several records. * It is considered more desirable then repeating it in all of them.
- * This is often called a XLUnicodeRichExtendedString in MS documentation.
+ * This is often called a XLUnicodeRichExtendedString in MS documentation. */ public class UnicodeString implements Comparable
, Duplicatable, GenericRecord { private static final Logger LOG = LogManager.getLogger(UnicodeString.class); @@ -445,6 +445,7 @@ public class UnicodeString implements Comparable , Duplicatable, G } } + @Override public int compareTo(UnicodeString str) { int result = getString().compareTo(str.getString()); diff --git a/poi/src/main/java/org/apache/poi/hssf/usermodel/EscherGraphics.java b/poi/src/main/java/org/apache/poi/hssf/usermodel/EscherGraphics.java index 4e3c4bd1ca..0fc1ca3e3d 100644 --- a/poi/src/main/java/org/apache/poi/hssf/usermodel/EscherGraphics.java +++ b/poi/src/main/java/org/apache/poi/hssf/usermodel/EscherGraphics.java @@ -48,15 +48,14 @@ import java.text.AttributedCharacterIterator; * verticalPointsPerPixel. This the amount the font should be scaled by when * you issue commands such as drawString(). A good way to calculate this * is to use the follow formula: - * - *
- * multipler = groupHeightInPoints / heightOfGroup - *+ *{@code + * multiplier = groupHeightInPoints / heightOfGroup + * }** The height of the group is calculated fairly simply by calculating the * difference between the y coordinates of the bounding box of the shape. The * height of the group can be calculated by using a convenience called - *
HSSFClientAnchor.getAnchorHeightInPoints()
. + * {@code HSSFClientAnchor.getAnchorHeightInPoints()}. * */ public class EscherGraphics extends Graphics { @@ -64,7 +63,7 @@ public class EscherGraphics extends Graphics { private final HSSFShapeGroup escherGroup; private final HSSFWorkbook workbook; - private float verticalPointsPerPixel = 1.0f; + private final float verticalPointsPerPixel; private final float verticalPixelsPerPoint; private Color foreground; private Color background = Color.white; @@ -290,7 +289,7 @@ public class EscherGraphics extends Graphics { if (str == null || str.isEmpty()) return; - Font excelFont = font; + Font excelFont; if ( font.getName().equals( "SansSerif" ) ) { excelFont = new Font( "Arial", font.getStyle(), (int) ( font.getSize() / verticalPixelsPerPoint ) ); @@ -374,18 +373,18 @@ public class EscherGraphics extends Graphics { * Fills a (closed) polygon, as defined by a pair of arrays, which * hold the x and y coordinates. *- * This draws the polygon, with
nPoint
line segments. - * The firstnPoint - 1
line segments are + * This draws the polygon, with {@code nPoint} line segments. + * The first {@code nPoint - 1} line segments are * drawn between sequential points - * (xPoints[i],yPoints[i],xPoints[i+1],yPoints[i+1]
). + * ({@code xPoints[i],yPoints[i],xPoints[i+1],yPoints[i+1]}). * The final line segment is a closing one, from the last point to * the first (assuming they are different). ** The area inside of the polygon is defined by using an * even-odd fill rule (also known as the alternating rule), and * the area inside of it is filled. - * @param xPoints array of the
x
coordinates. - * @param yPoints array of they
coordinates. + * @param xPoints array of the {@code x} coordinates. + * @param yPoints array of the {@code y} coordinates. * @param nPoints the total number of points in the polygon. * @see Graphics#drawPolygon(int[], int[], int) */ @@ -407,10 +406,9 @@ public class EscherGraphics extends Graphics { private int findBiggest( int[] values ) { int result = Integer.MIN_VALUE; - for ( int i = 0; i < values.length; i++ ) - { - if (values[i] > result) - result = values[i]; + for (int value : values) { + if (value > result) + result = value; } return result; } @@ -418,10 +416,9 @@ public class EscherGraphics extends Graphics { private int findSmallest( int[] values ) { int result = Integer.MAX_VALUE; - for ( int i = 0; i < values.length; i++ ) - { - if (values[i] < result) - result = values[i]; + for (int value : values) { + if (value < result) + result = value; } return result; } diff --git a/poi/src/main/java/org/apache/poi/hssf/usermodel/EscherGraphics2d.java b/poi/src/main/java/org/apache/poi/hssf/usermodel/EscherGraphics2d.java index a5e3516ab0..6ef38c71ee 100644 --- a/poi/src/main/java/org/apache/poi/hssf/usermodel/EscherGraphics2d.java +++ b/poi/src/main/java/org/apache/poi/hssf/usermodel/EscherGraphics2d.java @@ -59,21 +59,20 @@ import java.util.Map; * This the amount the font should be scaled by when * you issue commands such as drawString(). A good way to calculate this * is to use the follow formula: - *- *
+ **{@code * multipler = groupHeightInPoints / heightOfGroup - *+ * }* The height of the group is calculated fairly simply by calculating the * difference between the y coordinates of the bounding box of the shape. The * height of the group can be calculated by using a convenience called - *
HSSFClientAnchor.getAnchorHeightInPoints()
. + * {@code HSSFClientAnchor.getAnchorHeightInPoints()}. * */ public final class EscherGraphics2d extends Graphics2D { private static final Logger LOG = LogManager.getLogger(EscherGraphics2d.class); - private EscherGraphics _escherGraphics; + private final EscherGraphics _escherGraphics; private BufferedImage _img; private AffineTransform _trans; private Stroke _stroke; @@ -92,11 +91,13 @@ public final class EscherGraphics2d extends Graphics2D { setColor(Color.black); } + @Override public void addRenderingHints(Map, ?> map) { getG2D().addRenderingHints(map); } + @Override public void clearRect(int i, int j, int k, int l) { Paint paint1 = getPaint(); @@ -105,6 +106,7 @@ public final class EscherGraphics2d extends Graphics2D { setPaint(paint1); } + @Override public void clip(Shape shape) { if(getDeviceclip() != null) @@ -117,22 +119,26 @@ public final class EscherGraphics2d extends Graphics2D { setClip(shape); } + @Override public void clipRect(int x, int y, int width, int height) { clip(new Rectangle(x,y,width,height)); } + @Override public void copyArea(int x, int y, int width, int height, int dx, int dy) { getG2D().copyArea(x,y,width,height,dx,dy); } + @Override public Graphics create() { return new EscherGraphics2d(_escherGraphics); } + @Override public void dispose() { getEscherGraphics().dispose(); @@ -140,6 +146,7 @@ public final class EscherGraphics2d extends Graphics2D { getImg().flush(); } + @Override public void draw(Shape shape) { if (shape instanceof Line2D) @@ -159,17 +166,20 @@ public final class EscherGraphics2d extends Graphics2D { } } + @Override public void drawArc(int x, int y, int width, int height, int startAngle, int arcAngle) { draw(new Arc2D.Float(x, y, width, height, startAngle, arcAngle, 0)); } + @Override public void drawGlyphVector(GlyphVector g, float x, float y) { fill(g.getOutline(x, y)); } + @Override public boolean drawImage(Image image, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, Color bgColor, ImageObserver imageobserver) { @@ -177,18 +187,21 @@ public final class EscherGraphics2d extends Graphics2D { return true; } + @Override public boolean drawImage(Image image, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, ImageObserver imageobserver) { LOG.atWarn().log("drawImage() not supported"); return drawImage(image, dx1, dy1, dx2, dy2, sx1, sy1, sx2, sy2, null, imageobserver); } + @Override public boolean drawImage(Image image, int dx1, int dy1, int dx2, int dy2, Color bgColor, ImageObserver imageobserver) { LOG.atWarn().log("drawImage() not supported"); return true; } + @Override public boolean drawImage(Image img, int x, int y, int width, int height, ImageObserver observer) @@ -196,16 +209,19 @@ public final class EscherGraphics2d extends Graphics2D { return drawImage(img, x,y,width,height, null, observer); } + @Override public boolean drawImage(Image image, int x, int y, Color bgColor, ImageObserver imageobserver) { return drawImage(image, x, y, image.getWidth(imageobserver), image.getHeight(imageobserver), bgColor, imageobserver); } + @Override public boolean drawImage(Image image, int x, int y, ImageObserver imageobserver) { return drawImage(image, x, y, image.getWidth(imageobserver), image.getHeight(imageobserver), imageobserver); } + @Override public boolean drawImage(Image image, AffineTransform affinetransform, ImageObserver imageobserver) { AffineTransform affinetransform1 = (AffineTransform)getTrans().clone(); @@ -215,6 +231,7 @@ public final class EscherGraphics2d extends Graphics2D { return true; } + @Override public void drawImage(BufferedImage bufferedimage, BufferedImageOp op, int x, int y) { BufferedImage img = op.filter(bufferedimage, null); @@ -226,6 +243,7 @@ public final class EscherGraphics2d extends Graphics2D { getEscherGraphics().drawLine(x1,y1,x2,y2, width); } + @Override public void drawLine(int x1, int y1, int x2, int y2) { int width = 0; @@ -236,18 +254,21 @@ public final class EscherGraphics2d extends Graphics2D { // draw(new GeneralPath(new java.awt.geom.Line2D.Float(x1, y1, x2, y2))); } + @Override public void drawOval(int x, int y, int width, int height) { getEscherGraphics().drawOval(x,y,width,height); // draw(new java.awt.geom.Ellipse2D.Float(x, y, width, height)); } + @Override public void drawPolygon(int[] xPoints, int[] yPoints, int nPoints) { getEscherGraphics().drawPolygon(xPoints, yPoints, nPoints); } + @Override public void drawPolyline(int[] xPoints, int[] yPoints, int nPoints) { if(nPoints > 0) @@ -261,16 +282,19 @@ public final class EscherGraphics2d extends Graphics2D { } } + @Override public void drawRect(int x, int y, int width, int height) { _escherGraphics.drawRect(x,y,width,height); } + @Override public void drawRenderableImage(RenderableImage renderableimage, AffineTransform affinetransform) { drawRenderedImage(renderableimage.createDefaultRendering(), affinetransform); } + @Override public void drawRenderedImage(RenderedImage renderedimage, AffineTransform affinetransform) { BufferedImage bufferedimage = new BufferedImage(renderedimage.getColorModel(), renderedimage.getData().createCompatibleWritableRaster(), false, null); @@ -278,21 +302,25 @@ public final class EscherGraphics2d extends Graphics2D { drawImage(bufferedimage, affinetransform, null); } + @Override public void drawRoundRect(int i, int j, int k, int l, int i1, int j1) { draw(new RoundRectangle2D.Float(i, j, k, l, i1, j1)); } + @Override public void drawString(String string, float x, float y) { getEscherGraphics().drawString(string, (int)x, (int)y); } + @Override public void drawString(String string, int x, int y) { getEscherGraphics().drawString(string, x, y); } + @Override public void drawString(AttributedCharacterIterator attributedcharacteriterator, float x, float y) { TextLayout textlayout = new TextLayout(attributedcharacteriterator, getFontRenderContext()); @@ -302,21 +330,25 @@ public final class EscherGraphics2d extends Graphics2D { setPaint(paint1); } + @Override public void drawString(AttributedCharacterIterator attributedcharacteriterator, int x, int y) { getEscherGraphics().drawString(attributedcharacteriterator, x, y); } + @Override public void fill(Shape shape) { LOG.atWarn().log("fill(Shape) not supported"); } + @Override public void fillArc(int i, int j, int k, int l, int i1, int j1) { fill(new Arc2D.Float(i, j, k, l, i1, j1, 2)); } + @Override public void fillOval(int x, int y, int width, int height) { _escherGraphics.fillOval(x,y,width,height); @@ -326,42 +358,47 @@ public final class EscherGraphics2d extends Graphics2D { * Fills a (closed) polygon, as defined by a pair of arrays, which * hold the x and y coordinates. *- * This draws the polygon, with
nPoint
line segments. - * The firstnPoint - 1
line segments are + * This draws the polygon, with {@code nPoint} line segments. + * The first {@code nPoint - 1} line segments are * drawn between sequential points - * (xPoints[i],yPoints[i],xPoints[i+1],yPoints[i+1]
). + * ({@code xPoints[i],yPoints[i],xPoints[i+1],yPoints[i+1]}). * The final line segment is a closing one, from the last point to * the first (assuming they are different). ** The area inside of the polygon is defined by using an * even-odd fill rule (also known as the alternating rule), and * the area inside of it is filled. - * @param xPoints array of the
x
coordinates. - * @param yPoints array of they
coordinates. + * @param xPoints array of the {@code x} coordinates. + * @param yPoints array of the {@code y} coordinates. * @param nPoints the total number of points in the polygon. * @see Graphics#drawPolygon(int[], int[], int) */ + @Override public void fillPolygon(int[] xPoints, int[] yPoints, int nPoints) { _escherGraphics.fillPolygon(xPoints, yPoints, nPoints); } + @Override public void fillRect(int x, int y, int width, int height) { getEscherGraphics().fillRect(x,y,width,height); } + @Override public void fillRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight) { fill(new RoundRectangle2D.Float(x, y, width, height, arcWidth, arcHeight)); } + @Override public Color getBackground() { return getEscherGraphics().getBackground(); } + @Override public Shape getClip() { try @@ -374,6 +411,7 @@ public final class EscherGraphics2d extends Graphics2D { } } + @Override public Rectangle getClipBounds() { if(getDeviceclip() != null) { @@ -383,62 +421,74 @@ public final class EscherGraphics2d extends Graphics2D { return null; } + @Override public Color getColor() { return _escherGraphics.getColor(); } + @Override public Composite getComposite() { return getG2D().getComposite(); } + @Override public GraphicsConfiguration getDeviceConfiguration() { return getG2D().getDeviceConfiguration(); } + @Override public Font getFont() { return getEscherGraphics().getFont(); } + @Override public FontMetrics getFontMetrics(Font font) { return getEscherGraphics().getFontMetrics(font); } + @Override public FontRenderContext getFontRenderContext() { getG2D().setTransform(getTrans()); return getG2D().getFontRenderContext(); } + @Override public Paint getPaint() { return _paint; } + @Override public Object getRenderingHint(RenderingHints.Key key) { return getG2D().getRenderingHint(key); } + @Override public RenderingHints getRenderingHints() { return getG2D().getRenderingHints(); } + @Override public Stroke getStroke() { return _stroke; } + @Override public AffineTransform getTransform() { return (AffineTransform)getTrans().clone(); } + @Override public boolean hit(Rectangle rectangle, Shape shape, boolean flag) { getG2D().setTransform(getTrans()); @@ -447,51 +497,61 @@ public final class EscherGraphics2d extends Graphics2D { return getG2D().hit(rectangle, shape, flag); } + @Override public void rotate(double d) { getTrans().rotate(d); } + @Override public void rotate(double d, double d1, double d2) { getTrans().rotate(d, d1, d2); } + @Override public void scale(double d, double d1) { getTrans().scale(d, d1); } + @Override public void setBackground(Color c) { getEscherGraphics().setBackground(c); } + @Override public void setClip(int i, int j, int k, int l) { setClip(new Rectangle(i, j, k, l)); } + @Override public void setClip(Shape shape) { setDeviceclip( getTrans().createTransformedShape(shape) ); } + @Override public void setColor(Color c) { _escherGraphics.setColor(c); } + @Override public void setComposite(Composite composite) { getG2D().setComposite(composite); } + @Override public void setFont(Font font) { getEscherGraphics().setFont(font); } + @Override public void setPaint(Paint paint1) { if(paint1 != null) @@ -502,51 +562,61 @@ public final class EscherGraphics2d extends Graphics2D { } } + @Override public void setPaintMode() { getEscherGraphics().setPaintMode(); } + @Override public void setRenderingHint(RenderingHints.Key key, Object obj) { getG2D().setRenderingHint(key, obj); } + @Override public void setRenderingHints(Map, ?> map) { getG2D().setRenderingHints(map); } + @Override public void setStroke(Stroke s) { _stroke = s; } + @Override public void setTransform(AffineTransform affinetransform) { setTrans( (AffineTransform)affinetransform.clone() ); } + @Override public void setXORMode(Color color1) { getEscherGraphics().setXORMode(color1); } + @Override public void shear(double d, double d1) { getTrans().shear(d, d1); } + @Override public void transform(AffineTransform affinetransform) { getTrans().concatenate(affinetransform); } + @Override public void translate(double d, double d1) { getTrans().translate(d, d1); } + @Override public void translate(int i, int j) { getTrans().translate(i, j); diff --git a/poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFCell.java b/poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFCell.java index a48313176a..84df071015 100644 --- a/poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFCell.java +++ b/poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFCell.java @@ -56,7 +56,6 @@ import org.apache.poi.ss.util.CellRangeAddress; import org.apache.poi.ss.util.CellReference; import org.apache.poi.ss.util.NumberToTextConverter; import org.apache.poi.util.LocaleUtil; -import org.apache.poi.util.Removal; /** * High level representation of a cell in a row of a spreadsheet. @@ -68,7 +67,6 @@ import org.apache.poi.util.Removal; ** Cells should have their number (0 based) before being added to a row. Only * cells that have values should be added. - *
*/ public class HSSFCell extends CellBase { private static final String FILE_FORMAT_NAME = "BIFF8"; @@ -119,9 +117,6 @@ public class HSSFCell extends CellBase { setCellType(CellType.BLANK, false, row, col,xfindex); } - /** - * {@inheritDoc} - */ @Override protected SpreadsheetVersion getSpreadsheetVersion() { return SpreadsheetVersion.EXCEL97; @@ -132,6 +127,7 @@ public class HSSFCell extends CellBase { * * @return the HSSFSheet that owns this cell */ + @Override public HSSFSheet getSheet() { return _sheet; } @@ -141,6 +137,7 @@ public class HSSFCell extends CellBase { * * @return the HSSFRow that owns this cell */ + @Override public HSSFRow getRow() { int rowIndex = getRowIndex(); return _sheet.getRow(rowIndex); @@ -190,13 +187,11 @@ public class HSSFCell extends CellBase { _stringValue = new HSSFRichTextString(book.getWorkbook(), (LabelSSTRecord ) cval); break; - case BLANK : - break; - case FORMULA : _stringValue=new HSSFRichTextString(((FormulaRecordAggregate) cval).getStringValue()); break; + case BLANK : default : break; } @@ -428,9 +423,6 @@ public class HSSFCell extends CellBase { return _cellType; } - /** - * {@inheritDoc} - */ @Override @SuppressWarnings("fallthrough") protected void setCellValueImpl(double value) { @@ -458,6 +450,7 @@ public class HSSFCell extends CellBase { * @see DateUtil * @see org.apache.poi.ss.usermodel.DateUtil */ + @Override protected void setCellValueImpl(Date value) { setCellValue(DateUtil.getExcelDate(value, _book.getWorkbook().isUsing1904DateWindowing())); } @@ -469,29 +462,21 @@ public class HSSFCell extends CellBase { * @see DateUtil * @see org.apache.poi.ss.usermodel.DateUtil */ + @Override protected void setCellValueImpl(LocalDateTime value) { setCellValue(DateUtil.getExcelDate(value, _book.getWorkbook().isUsing1904DateWindowing())); } - /** - * {@inheritDoc} - */ @Override protected void setCellValueImpl(Calendar value) { setCellValue( DateUtil.getExcelDate(value, _book.getWorkbook().isUsing1904DateWindowing()) ); } - /** - * {@inheritDoc} - */ @Override protected void setCellValueImpl(String value) { setCellValueImpl(new HSSFRichTextString(value)); } - /** - * {@inheritDoc} - */ @Override protected void setCellValueImpl(RichTextString value) { if (_cellType == CellType.FORMULA) { @@ -526,9 +511,6 @@ public class HSSFCell extends CellBase { _stringValue.setUnicodeString(_book.getWorkbook().getSSTString(index)); } - /** - * {@inheritDoc} - */ @Override protected void setCellFormulaImpl(String formula) { // formula cells always have a value. If the cell is blank (either initially or after removing an @@ -640,6 +622,7 @@ public class HSSFCell extends CellBase { } } + @Override public String getCellFormula() { if (!(_record instanceof FormulaRecordAggregate)) { throw typeMismatch(CellType.FORMULA, _cellType, true); @@ -668,6 +651,7 @@ public class HSSFCell extends CellBase { * number into a string similar to that which * Excel would render this number as. */ + @Override public double getNumericCellValue() { switch(_cellType) { @@ -692,6 +676,7 @@ public class HSSFCell extends CellBase { * See {@link HSSFDataFormatter} for formatting * this date into a string similar to how excel does. */ + @Override public Date getDateCellValue() { if (_cellType == CellType.BLANK) { @@ -711,6 +696,7 @@ public class HSSFCell extends CellBase { * See {@link HSSFDataFormatter} for formatting * this date into a string similar to how excel does. */ + @Override public LocalDateTime getLocalDateTimeCellValue() { if (_cellType == CellType.BLANK) { @@ -728,6 +714,7 @@ public class HSSFCell extends CellBase { * For blank cells we return an empty string. * For formulaCells that are not string Formulas, we throw an exception */ + @Override public String getStringCellValue() { HSSFRichTextString str = getRichStringCellValue(); @@ -739,6 +726,7 @@ public class HSSFCell extends CellBase { * For blank cells we return an empty string. * For formulaCells that are not string Formulas, we throw an exception */ + @Override public HSSFRichTextString getRichStringCellValue() { switch(_cellType) { @@ -764,6 +752,7 @@ public class HSSFCell extends CellBase { * precalculated value, for booleans we'll set its value. For other types we * will change the cell to a boolean cell and set its value. */ + @Override @SuppressWarnings("fallthrough") public void setCellValue(boolean value) { int row=_record.getRow(); @@ -793,6 +782,8 @@ public class HSSFCell extends CellBase { * For error code byte, see {@link FormulaError}. * @deprecated 3.15 beta 2. Use {@link #setCellErrorValue(FormulaError)} instead. */ + @Override + @Deprecated public void setCellErrorValue(byte errorCode) { FormulaError error = FormulaError.forInt(errorCode); setCellErrorValue(error); @@ -948,6 +939,7 @@ public class HSSFCell extends CellBase { * @see org.apache.poi.hssf.usermodel.HSSFWorkbook#createCellStyle() * @see org.apache.poi.hssf.usermodel.HSSFWorkbook#getCellStyleAt(int) */ + @Override public void setCellStyle(CellStyle style) { setCellStyle( (HSSFCellStyle)style ); } @@ -977,6 +969,7 @@ public class HSSFCell extends CellBase { * object. * @see org.apache.poi.hssf.usermodel.HSSFWorkbook#getCellStyleAt(int) */ + @Override public HSSFCellStyle getCellStyle() { short styleIndex=_record.getXFIndex(); @@ -1006,9 +999,6 @@ public class HSSFCell extends CellBase { } } - /** - * {@inheritDoc} - */ @Override public void setAsActiveCell() { @@ -1062,6 +1052,7 @@ public class HSSFCell extends CellBase { * * @param comment comment associated with this cell */ + @Override public void setCellComment(Comment comment){ if(comment == null) { removeCellComment(); @@ -1078,6 +1069,7 @@ public class HSSFCell extends CellBase { * * @return comment associated with this cell */ + @Override public HSSFComment getCellComment(){ if (_comment == null) { _comment = _sheet.findCellComment(_record.getRow(), _record.getColumn()); @@ -1091,6 +1083,7 @@ public class HSSFCell extends CellBase { * WARNING - some versions of excel will loose * all comments after performing this action! */ + @Override public void removeCellComment() { HSSFComment comment = _sheet.findCellComment(_record.getRow(), _record.getColumn()); _comment = null; @@ -1101,7 +1094,7 @@ public class HSSFCell extends CellBase { } /** - * @return hyperlink associated with this cell or
null
if not found + * @return hyperlink associated with this cell or {@code null} if not found */ @Override public HSSFHyperlink getHyperlink(){ @@ -1151,6 +1144,7 @@ public class HSSFCell extends CellBase { /** * Removes the hyperlink for this cell, if there is one. */ + @Override public void removeHyperlink() { for (Iteratorit = _sheet.getSheet().getRecords().iterator(); it.hasNext();) { RecordBase rec = it.next(); @@ -1193,6 +1187,7 @@ public class HSSFCell extends CellBase { agg.setParsedExpression(ptgsForCell); } + @Override public CellRangeAddress getArrayFormulaRange() { if (_cellType != CellType.FORMULA) { String ref = new CellReference(this).formatAsString(); @@ -1202,6 +1197,7 @@ public class HSSFCell extends CellBase { return ((FormulaRecordAggregate)_record).getArrayFormulaRange(); } + @Override public boolean isPartOfArrayFormulaGroup() { return _cellType == CellType.FORMULA && ((FormulaRecordAggregate) _record).isPartOfArrayFormula(); } diff --git a/poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFChildAnchor.java b/poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFChildAnchor.java index a7a88c6b6b..5f7ff508c4 100644 --- a/poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFChildAnchor.java +++ b/poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFChildAnchor.java @@ -27,7 +27,6 @@ public final class HSSFChildAnchor extends HSSFAnchor { /** * create anchor from existing file - * @param escherChildAnchorRecord */ public HSSFChildAnchor(EscherChildAnchorRecord escherChildAnchorRecord) { this._escherChildAnchor = escherChildAnchorRecord; @@ -108,11 +107,13 @@ public final class HSSFChildAnchor extends HSSFAnchor { } + @Override public boolean isHorizontallyFlipped() { return _isHorizontallyFlipped; } + @Override public boolean isVerticallyFlipped() { return _isVerticallyFlipped; } diff --git a/poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFComment.java b/poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFComment.java index c62bd4daf1..af6ac8b4f2 100644 --- a/poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFComment.java +++ b/poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFComment.java @@ -66,7 +66,6 @@ public class HSSFComment extends HSSFTextbox implements Comment { /** * Construct a new comment with the given parent and anchor. * - * @param parent * @param anchor defines position of this anchor in the sheet */ public HSSFComment(HSSFShape parent, HSSFAnchor anchor) { @@ -100,6 +99,7 @@ public class HSSFComment extends HSSFTextbox implements Comment { protected EscherContainerRecord createSpContainer() { EscherContainerRecord spContainer = super.createSpContainer(); EscherOptRecord opt = spContainer.getChildById(EscherOptRecord.RECORD_ID); + assert(opt != null); opt.removeEscherProperty(EscherPropertyTypes.TEXT__TEXTLEFT); opt.removeEscherProperty(EscherPropertyTypes.TEXT__TEXTRIGHT); opt.removeEscherProperty(EscherPropertyTypes.TEXT__TEXTTOP); @@ -147,7 +147,7 @@ public class HSSFComment extends HSSFTextbox implements Comment { /** * Sets whether this comment is visible. * - * @param visible true
if the comment is visible,false
otherwise + * @param visible {@code true} if the comment is visible, {@code false} otherwise */ @Override public void setVisible(boolean visible) { @@ -158,7 +158,7 @@ public class HSSFComment extends HSSFTextbox implements Comment { /** * Returns whether this comment is visible. * - * @returntrue
if the comment is visible,false
otherwise + * @return {@code true} if the comment is visible, {@code false} otherwise */ @Override public boolean isVisible() { @@ -253,9 +253,7 @@ public class HSSFComment extends HSSFTextbox implements Comment { * Do we know which cell this comment belongs to? */ public boolean hasPosition() { - if (_note == null) return false; - if (getColumn() < 0 || getRow() < 0) return false; - return true; + return _note != null && getColumn() >= 0 && getRow() >= 0; } @Override diff --git a/poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFEvaluationSheet.java b/poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFEvaluationSheet.java index dd6c1f09df..12716407d3 100644 --- a/poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFEvaluationSheet.java +++ b/poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFEvaluationSheet.java @@ -36,7 +36,7 @@ final class HSSFEvaluationSheet implements EvaluationSheet { public HSSFSheet getHSSFSheet() { return _hs; } - + /* (non-Javadoc) * @see org.apache.poi.ss.formula.EvaluationSheet#getlastRowNum() * @since POI 4.0.0 @@ -50,6 +50,7 @@ final class HSSFEvaluationSheet implements EvaluationSheet { * @see org.apache.poi.ss.formula.EvaluationSheet#isRowHidden(int) * @since POI 4.1.0 */ + @Override public boolean isRowHidden(int rowIndex) { HSSFRow row = _hs.getRow(rowIndex); if (row == null) return false; @@ -71,7 +72,7 @@ final class HSSFEvaluationSheet implements EvaluationSheet { /* (non-JavaDoc), inherit JavaDoc from EvaluationSheet * @since POI 3.15 beta 3 - */ + */ @Override public void clearAllCachedResultValues() { } diff --git a/poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFFont.java b/poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFFont.java index 2cdb4e8b7e..fb7a7a74cb 100644 --- a/poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFFont.java +++ b/poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFFont.java @@ -49,8 +49,8 @@ public final class HSSFFont implements Font { public static final String FONT_ARIAL = "Arial"; - private FontRecord font; - private int index; + private final FontRecord font; + private final int index; /** Creates a new instance of HSSFFont */ @@ -66,6 +66,7 @@ public final class HSSFFont implements Font { * @see #FONT_ARIAL */ + @Override public void setFontName(String name) { font.setFontName(name); @@ -76,6 +77,7 @@ public final class HSSFFont implements Font { * @return String representing the name of the font to use * @see #FONT_ARIAL */ + @Override public String getFontName() { return font.getFontName(); @@ -99,6 +101,7 @@ public final class HSSFFont implements Font { * @see #setFontHeightInPoints(short) */ + @Override public void setFontHeight(short height) { font.setFontHeight(height); @@ -110,6 +113,7 @@ public final class HSSFFont implements Font { * @see #setFontHeight(short) */ + @Override public void setFontHeightInPoints(short height) { font.setFontHeight(( short ) (height * Font.TWIPS_PER_POINT)); @@ -122,6 +126,7 @@ public final class HSSFFont implements Font { * @see #getFontHeightInPoints() */ + @Override public short getFontHeight() { return font.getFontHeight(); @@ -133,6 +138,7 @@ public final class HSSFFont implements Font { * @see #getFontHeight() */ + @Override public short getFontHeightInPoints() { return ( short ) (font.getFontHeight() / Font.TWIPS_PER_POINT); @@ -143,6 +149,7 @@ public final class HSSFFont implements Font { * @param italic italics or not */ + @Override public void setItalic(boolean italic) { font.setItalic(italic); @@ -153,6 +160,7 @@ public final class HSSFFont implements Font { * @return italics or not */ + @Override public boolean getItalic() { return font.isItalic(); @@ -163,6 +171,7 @@ public final class HSSFFont implements Font { * @param strikeout or not */ + @Override public void setStrikeout(boolean strikeout) { font.setStrikeout(strikeout); @@ -173,6 +182,7 @@ public final class HSSFFont implements Font { * @return strikeout or not */ + @Override public boolean getStrikeout() { return font.isStruckout(); @@ -185,6 +195,7 @@ public final class HSSFFont implements Font { * @see #COLOR_RED */ + @Override public void setColor(short color) { font.setColorPaletteIndex(color); @@ -197,6 +208,7 @@ public final class HSSFFont implements Font { * @see #COLOR_RED * @see org.apache.poi.hssf.usermodel.HSSFPalette#getColor(short) */ + @Override public short getColor() { return font.getColorPaletteIndex(); @@ -214,6 +226,7 @@ public final class HSSFFont implements Font { /** * sets the font to be bold or not */ + @Override public void setBold(boolean bold) { if (bold) @@ -225,6 +238,7 @@ public final class HSSFFont implements Font { /** * get if the font is bold or not */ + @Override public boolean getBold() { return font.getBoldWeight() == BOLDWEIGHT_BOLD; @@ -238,6 +252,7 @@ public final class HSSFFont implements Font { * @see #SS_SUB */ + @Override public void setTypeOffset(short offset) { font.setSuperSubScript(offset); @@ -251,6 +266,7 @@ public final class HSSFFont implements Font { * @see #SS_SUB */ + @Override public short getTypeOffset() { return font.getSuperSubScript(); @@ -266,6 +282,7 @@ public final class HSSFFont implements Font { * @see #U_DOUBLE_ACCOUNTING */ + @Override public void setUnderline(byte underline) { font.setUnderline(underline); @@ -281,6 +298,7 @@ public final class HSSFFont implements Font { * @see #U_DOUBLE_ACCOUNTING */ + @Override public byte getUnderline() { return font.getUnderline(); @@ -294,6 +312,7 @@ public final class HSSFFont implements Font { * @see #DEFAULT_CHARSET * @see #SYMBOL_CHARSET */ + @Override public int getCharSet() { byte charset = font.getCharset(); @@ -310,6 +329,7 @@ public final class HSSFFont implements Font { * @see #DEFAULT_CHARSET * @see #SYMBOL_CHARSET */ + @Override public void setCharSet(int charset) { byte cs = (byte)charset; @@ -325,6 +345,7 @@ public final class HSSFFont implements Font { * @see #DEFAULT_CHARSET * @see #SYMBOL_CHARSET */ + @Override public void setCharSet(byte charset) { font.setCharset(charset); @@ -347,14 +368,14 @@ public final class HSSFFont implements Font { if (obj instanceof HSSFFont) { final HSSFFont other = (HSSFFont) obj; if (font == null) { - if (other.font != null) - return false; - } else if (!font.equals(other.font)) - return false; - if (index != other.index) - return false; - return true; - } + if (other.font != null) { + return false; + } + } else if (!font.equals(other.font)) { + return false; + } + return index == other.index; + } return false; } } diff --git a/poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFFormulaEvaluator.java b/poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFFormulaEvaluator.java index f8ab24a0e8..b64a501866 100644 --- a/poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFFormulaEvaluator.java +++ b/poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFFormulaEvaluator.java @@ -50,7 +50,7 @@ public class HSSFFormulaEvaluator extends BaseFormulaEvaluator { } /** * @param workbook The workbook to perform the formula evaluations in - * @param stabilityClassifier used to optimise caching performance. Passnull
+ * @param stabilityClassifier used to optimise caching performance. Pass {@code null} * for the (conservative) assumption that any cell may have its definition changed after * evaluation begins. */ @@ -60,10 +60,10 @@ public class HSSFFormulaEvaluator extends BaseFormulaEvaluator { /** * @param workbook The workbook to perform the formula evaluations in - * @param stabilityClassifier used to optimise caching performance. Passnull
+ * @param stabilityClassifier used to optimise caching performance. Pass {@code null} * for the (conservative) assumption that any cell may have its definition changed after * evaluation begins. - * @param udfFinder passnull
for default (AnalysisToolPak only) + * @param udfFinder pass {@code null} for default (AnalysisToolPak only) */ private HSSFFormulaEvaluator(HSSFWorkbook workbook, IStabilityClassifier stabilityClassifier, UDFFinder udfFinder) { super(new WorkbookEvaluator(HSSFEvaluationWorkbook.create(workbook), stabilityClassifier, udfFinder)); @@ -72,15 +72,15 @@ public class HSSFFormulaEvaluator extends BaseFormulaEvaluator { /** * @param workbook The workbook to perform the formula evaluations in - * @param stabilityClassifier used to optimise caching performance. Passnull
+ * @param stabilityClassifier used to optimise caching performance. Pass {@code null} * for the (conservative) assumption that any cell may have its definition changed after * evaluation begins. - * @param udfFinder passnull
for default (AnalysisToolPak only) + * @param udfFinder pass {@code null} for default (AnalysisToolPak only) */ public static HSSFFormulaEvaluator create(HSSFWorkbook workbook, IStabilityClassifier stabilityClassifier, UDFFinder udfFinder) { return new HSSFFormulaEvaluator(workbook, stabilityClassifier, udfFinder); } - + @Override protected RichTextString createRichTextString(String str) { return new HSSFRichTextString(str); @@ -140,7 +140,7 @@ public class HSSFFormulaEvaluator extends BaseFormulaEvaluator { public void notifySetFormula(Cell cell) { _bookEvaluator.notifyUpdateCell(new HSSFEvaluationCell((HSSFCell)cell)); } - + @Override public HSSFCell evaluateInCell(Cell cell) { return (HSSFCell) super.evaluateInCell(cell); @@ -196,6 +196,7 @@ public class HSSFFormulaEvaluator extends BaseFormulaEvaluator { * Returns a CellValue wrapper around the supplied ValueEval instance. * @param cell The cell with the formula */ + @Override protected CellValue evaluateFormulaCellValue(Cell cell) { ValueEval eval = _bookEvaluator.evaluate(new HSSFEvaluationCell((HSSFCell)cell)); if (eval instanceof BoolEval) { @@ -216,13 +217,11 @@ public class HSSFFormulaEvaluator extends BaseFormulaEvaluator { throw new RuntimeException("Unexpected eval class (" + eval.getClass().getName() + ")"); } - /** {@inheritDoc} */ @Override public void setIgnoreMissingWorkbooks(boolean ignore){ _bookEvaluator.setIgnoreMissingWorkbooks(ignore); } - /** {@inheritDoc} */ @Override public void setDebugEvaluationOutputForNextEval(boolean value){ _bookEvaluator.setDebugEvaluationOutputForNextEval(value); diff --git a/poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFHyperlink.java b/poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFHyperlink.java index 1b51235bc8..348ca4723e 100644 --- a/poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFHyperlink.java +++ b/poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFHyperlink.java @@ -66,9 +66,7 @@ public class HSSFHyperlink implements Hyperlink { } /** - * Initialize the hyperlink by aHyperlinkRecord
record - * - * @param record + * Initialize the hyperlink by a {@code HyperlinkRecord} record */ protected HSSFHyperlink( HyperlinkRecord record ) { diff --git a/poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFPatternFormatting.java b/poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFPatternFormatting.java index 1f521c509e..2c29ebc72a 100644 --- a/poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFPatternFormatting.java +++ b/poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFPatternFormatting.java @@ -32,7 +32,7 @@ public class HSSFPatternFormatting implements org.apache.poi.ss.usermodel.Patter protected HSSFPatternFormatting(CFRuleBase cfRuleRecord, HSSFWorkbook workbook) { this.workbook = workbook; - this.cfRuleRecord = cfRuleRecord; + this.cfRuleRecord = cfRuleRecord; this.patternFormatting = cfRuleRecord.getPatternFormatting(); } @@ -41,10 +41,12 @@ public class HSSFPatternFormatting implements org.apache.poi.ss.usermodel.Patter return patternFormatting; } + @Override public HSSFColor getFillBackgroundColorColor() { return workbook.getCustomPalette().getColor(getFillBackgroundColor()); } + @Override public HSSFColor getFillForegroundColorColor() { return workbook.getCustomPalette().getColor(getFillForegroundColor()); } @@ -52,6 +54,7 @@ public class HSSFPatternFormatting implements org.apache.poi.ss.usermodel.Patter /** * @see org.apache.poi.hssf.record.cf.PatternFormatting#getFillBackgroundColor() */ + @Override public short getFillBackgroundColor() { return (short)patternFormatting.getFillBackgroundColor(); @@ -60,6 +63,7 @@ public class HSSFPatternFormatting implements org.apache.poi.ss.usermodel.Patter /** * @see org.apache.poi.hssf.record.cf.PatternFormatting#getFillForegroundColor() */ + @Override public short getFillForegroundColor() { return (short)patternFormatting.getFillForegroundColor(); @@ -68,11 +72,13 @@ public class HSSFPatternFormatting implements org.apache.poi.ss.usermodel.Patter /** * @see org.apache.poi.hssf.record.cf.PatternFormatting#getFillPattern() */ + @Override public short getFillPattern() { return (short)patternFormatting.getFillPattern(); } + @Override public void setFillBackgroundColor(Color bg) { HSSFColor hcolor = HSSFColor.toHSSFColor(bg); if (hcolor == null) { @@ -82,6 +88,7 @@ public class HSSFPatternFormatting implements org.apache.poi.ss.usermodel.Patter } } + @Override public void setFillForegroundColor(Color fg) { HSSFColor hcolor = HSSFColor.toHSSFColor(fg); if (hcolor == null) { @@ -92,9 +99,9 @@ public class HSSFPatternFormatting implements org.apache.poi.ss.usermodel.Patter } /** - * @param bg * @see org.apache.poi.hssf.record.cf.PatternFormatting#setFillBackgroundColor(int) */ + @Override public void setFillBackgroundColor(short bg) { patternFormatting.setFillBackgroundColor(bg); @@ -105,9 +112,9 @@ public class HSSFPatternFormatting implements org.apache.poi.ss.usermodel.Patter } /** - * @param fg * @see org.apache.poi.hssf.record.cf.PatternFormatting#setFillForegroundColor(int) */ + @Override public void setFillForegroundColor(short fg) { patternFormatting.setFillForegroundColor(fg); @@ -118,9 +125,9 @@ public class HSSFPatternFormatting implements org.apache.poi.ss.usermodel.Patter } /** - * @param fp * @see org.apache.poi.hssf.record.cf.PatternFormatting#setFillPattern(int) */ + @Override public void setFillPattern(short fp) { patternFormatting.setFillPattern(fp); diff --git a/poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFPictureData.java b/poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFPictureData.java index 9dd6079624..802bf28e30 100644 --- a/poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFPictureData.java +++ b/poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFPictureData.java @@ -42,7 +42,7 @@ public class HSSFPictureData implements PictureData /** * Underlying escher blip record containing the bitmap data. */ - private EscherBlipRecord blip; + private final EscherBlipRecord blip; /** * Constructs a picture object. @@ -57,6 +57,7 @@ public class HSSFPictureData implements PictureData /* (non-Javadoc) * @see org.apache.poi.hssf.usermodel.PictureData#getData() */ + @Override public byte[] getData() { return new ImageHeaderPNG(blip.getPicturedata()).extractPNG(); } @@ -77,8 +78,9 @@ public class HSSFPictureData implements PictureData /** * @see #getFormat - * @return 'wmf', 'jpeg' etc depending on the format. nevernull
+ * @return 'wmf', 'jpeg' etc depending on the format. never {@code null} */ + @Override public String suggestFileExtension() { switch (EscherRecordTypes.forTypeID(blip.getRecordId())) { case BLIP_WMF: @@ -93,14 +95,17 @@ public class HSSFPictureData implements PictureData return "jpeg"; case BLIP_DIB: return "dib"; + case BLIP_TIFF: + return "tif"; default: return ""; } } - + /** * Returns the mime type for the image */ + @Override public String getMimeType() { switch (EscherRecordTypes.forTypeID(blip.getRecordId())) { case BLIP_WMF: @@ -115,11 +120,13 @@ public class HSSFPictureData implements PictureData return "image/jpeg"; case BLIP_DIB: return "image/bmp"; + case BLIP_TIFF: + return "image/tiff"; default: return "image/unknown"; } } - + /** * @return the POI internal image type, 0 if unknown image type (was -1 prior to 5.0.0 but * that was inconsistent with other {@link PictureData} implementations) @@ -131,6 +138,7 @@ public class HSSFPictureData implements PictureData * @see Workbook#PICTURE_TYPE_PNG * @see Workbook#PICTURE_TYPE_WMF */ + @Override public int getPictureType() { switch (EscherRecordTypes.forTypeID(blip.getRecordId())) { case BLIP_WMF: @@ -145,8 +153,10 @@ public class HSSFPictureData implements PictureData return Workbook.PICTURE_TYPE_JPEG; case BLIP_DIB: return Workbook.PICTURE_TYPE_DIB; + case BLIP_TIFF: + // not another int constant ... default: return 0; - } + } } } diff --git a/poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFRichTextString.java b/poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFRichTextString.java index 34b95d7fa0..fbb6eec534 100644 --- a/poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFRichTextString.java +++ b/poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFRichTextString.java @@ -33,18 +33,18 @@ import org.apache.poi.ss.usermodel.RichTextString; * Note, that in certain cases creating too many HSSFRichTextString cells may cause Excel 2003 and lower to crash * when changing the color of the cells and then saving the Excel file. Compare two snippets that produce equivalent output: * - *+ * }+ *{@code * HSSFCell hssfCell = row.createCell(idx); * //rich text consists of two runs * HSSFRichTextString richString = new HSSFRichTextString( "Hello, World!" ); * richString.applyFont( 0, 6, font1 ); * richString.applyFont( 6, 13, font2 ); * hssfCell.setCellValue( richString ); - *
+ *{@code * //create a cell style and assign the first font to it * HSSFCellStyle style = workbook.createCellStyle(); * style.setFont(font1); @@ -56,7 +56,7 @@ import org.apache.poi.ss.usermodel.RichTextString; * HSSFRichTextString richString = new HSSFRichTextString( "Hello, World!" ); * richString.applyFont( 6, 13, font2 ); * hssfCell.setCellValue( richString ); - *
+ * }
*
* Excel always uses the latter approach: for a reach text containing N runs Excel saves the font of the first run in the cell's
* style and subsequent N-1 runs override this font.
@@ -126,6 +126,7 @@ public final class HSSFRichTextString implements Comparable
*
- * The implementation is split into the following packages:
+ * The implementation is split into the following packages:
*
*
*
- *
epsilon
of value
, in absolute terms.
+ * {@code epsilon} of {@code value}, in absolute terms.
* @param maxDenominator maximum denominator value allowed.
* @param maxIterations maximum number of convergents
* @throws RuntimeException if the continued fraction failed to
@@ -79,7 +78,7 @@ public class SimpleFraction {
double r0 = value;
long a0 = (long)Math.floor(r0);
if (a0 > overflow) {
- throw new IllegalArgumentException("Overflow trying to convert "+value+" to fraction ("+a0+"/"+1l+")");
+ throw new IllegalArgumentException("Overflow trying to convert "+value+" to fraction ("+a0+"/"+ 1L +")");
}
// check for (almost) integer arguments, which should not go
@@ -141,7 +140,7 @@ public class SimpleFraction {
/**
* Create a fraction given a numerator and denominator.
- * @param numerator
+ * @param numerator the numerator
* @param denominator maxDenominator The maximum allowed value for denominator
*/
public SimpleFraction(int numerator, int denominator)
diff --git a/poi/src/main/java/org/apache/poi/ss/formula/BaseFormulaEvaluator.java b/poi/src/main/java/org/apache/poi/ss/formula/BaseFormulaEvaluator.java
index fa9989c02b..f7d6157c44 100644
--- a/poi/src/main/java/org/apache/poi/ss/formula/BaseFormulaEvaluator.java
+++ b/poi/src/main/java/org/apache/poi/ss/formula/BaseFormulaEvaluator.java
@@ -29,7 +29,7 @@ import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
/**
- * Common functionality across file formats for evaluating formula cells.
+ * Common functionality across file formats for evaluating formula cells.
*/
public abstract class BaseFormulaEvaluator implements FormulaEvaluator, WorkbookEvaluatorProvider {
protected final WorkbookEvaluator _bookEvaluator;
@@ -91,8 +91,8 @@ public abstract class BaseFormulaEvaluator implements FormulaEvaluator, Workbook
* evaluateInCell() when the call should not modify the contents of the
* original cell.
*
- * @param cell may be null
signifying that the cell is not present (or blank)
- * @return null
if the supplied cell is null
or blank
+ * @param cell may be {@code null} signifying that the cell is not present (or blank)
+ * @return {@code null} if the supplied cell is {@code null} or blank
*/
@Override
public CellValue evaluate(Cell cell) {
@@ -281,13 +281,11 @@ public abstract class BaseFormulaEvaluator implements FormulaEvaluator, Workbook
}
}
- /** {@inheritDoc} */
@Override
public void setIgnoreMissingWorkbooks(boolean ignore){
_bookEvaluator.setIgnoreMissingWorkbooks(ignore);
}
- /** {@inheritDoc} */
@Override
public void setDebugEvaluationOutputForNextEval(boolean value){
_bookEvaluator.setDebugEvaluationOutputForNextEval(value);
diff --git a/poi/src/main/java/org/apache/poi/ss/formula/CacheAreaEval.java b/poi/src/main/java/org/apache/poi/ss/formula/CacheAreaEval.java
index e8c8d5a0ac..a26edcaf81 100644
--- a/poi/src/main/java/org/apache/poi/ss/formula/CacheAreaEval.java
+++ b/poi/src/main/java/org/apache/poi/ss/formula/CacheAreaEval.java
@@ -31,47 +31,50 @@ import org.apache.poi.ss.util.CellReference;
*/
public final class CacheAreaEval extends AreaEvalBase {
-
+
/* Value Containter */
private final ValueEval[] _values;
-
+
public CacheAreaEval(AreaI ptg, ValueEval[] values) {
super(ptg);
_values = values;
}
-
+
public CacheAreaEval(int firstRow, int firstColumn, int lastRow, int lastColumn, ValueEval[] values) {
super(firstRow, firstColumn, lastRow, lastColumn);
_values = values;
}
-
+
+ @Override
public ValueEval getRelativeValue(int relativeRowIndex, int relativeColumnIndex) {
return getRelativeValue(-1, relativeRowIndex, relativeColumnIndex);
}
-
+
+ @Override
public ValueEval getRelativeValue(int sheetIndex, int relativeRowIndex, int relativeColumnIndex) {
int oneDimensionalIndex = relativeRowIndex * getWidth() + relativeColumnIndex;
return _values[oneDimensionalIndex];
}
+ @Override
public AreaEval offset(int relFirstRowIx, int relLastRowIx,
int relFirstColIx, int relLastColIx) {
-
+
AreaI area = new OffsetArea(getFirstRow(), getFirstColumn(),
relFirstRowIx, relLastRowIx, relFirstColIx, relLastColIx);
-
+
int height = area.getLastRow() - area.getFirstRow() + 1;
int width = area.getLastColumn() - area.getFirstColumn() + 1;
ValueEval[] newVals = new ValueEval[height * width];
-
+
int startRow = area.getFirstRow() - getFirstRow();
int startCol = area.getFirstColumn() - getFirstColumn();
-
+
for (int j = 0; j < height; j++) {
for (int i = 0; i < width; i++) {
ValueEval temp;
-
+
/* CacheAreaEval is only temporary value representation, does not equal sheet selection
* so any attempts going beyond the selection results in BlankEval
*/
@@ -81,13 +84,14 @@ public final class CacheAreaEval extends AreaEvalBase {
else {
temp = _values[(startRow + j) * getWidth() + (startCol + i)];
}
- newVals[j * width + i] = temp;
+ newVals[j * width + i] = temp;
}
}
return new CacheAreaEval(area, newVals);
}
+ @Override
public TwoDEval getRow(int rowIndex) {
if (rowIndex >= getHeight()) {
throw new IllegalArgumentException("Invalid rowIndex " + rowIndex
@@ -95,13 +99,14 @@ public final class CacheAreaEval extends AreaEvalBase {
}
int absRowIndex = getFirstRow() + rowIndex;
ValueEval[] values = new ValueEval[getWidth()];
-
+
for (int i = 0; i < values.length; i++) {
values[i] = getRelativeValue(rowIndex, i);
}
return new CacheAreaEval(absRowIndex, getFirstColumn() , absRowIndex, getLastColumn(), values);
}
+ @Override
public TwoDEval getColumn(int columnIndex) {
if (columnIndex >= getWidth()) {
throw new IllegalArgumentException("Invalid columnIndex " + columnIndex
@@ -109,14 +114,14 @@ public final class CacheAreaEval extends AreaEvalBase {
}
int absColIndex = getFirstColumn() + columnIndex;
ValueEval[] values = new ValueEval[getHeight()];
-
+
for (int i = 0; i < values.length; i++) {
values[i] = getRelativeValue(i, columnIndex);
}
-
+
return new CacheAreaEval(getFirstRow(), absColIndex, getLastRow(), absColIndex, values);
}
-
+
public String toString() {
CellReference crA = new CellReference(getFirstRow(), getFirstColumn());
CellReference crB = new CellReference(getLastRow(), getLastColumn());
diff --git a/poi/src/main/java/org/apache/poi/ss/formula/ConditionalFormattingEvaluator.java b/poi/src/main/java/org/apache/poi/ss/formula/ConditionalFormattingEvaluator.java
index 269b8f292a..e8556c9a80 100644
--- a/poi/src/main/java/org/apache/poi/ss/formula/ConditionalFormattingEvaluator.java
+++ b/poi/src/main/java/org/apache/poi/ss/formula/ConditionalFormattingEvaluator.java
@@ -38,17 +38,15 @@ import org.apache.poi.ss.util.CellReference;
/**
* Evaluates Conditional Formatting constraints.
* - * For performance reasons, this class keeps a cache of all previously evaluated rules and cells. + * For performance reasons, this class keeps a cache of all previously evaluated rules and cells. * Be sure to call {@link #clearAllCachedFormats()} if any conditional formats are modified, added, or deleted, * and {@link #clearAllCachedValues()} whenever cell values change. - *
- * */ public class ConditionalFormattingEvaluator { private final WorkbookEvaluator workbookEvaluator; private final Workbook workbook; - + /** * All the underlying structures, for both HSSF and XSSF, repeatedly go to the raw bytes/XML for the * different pieces used in the ConditionalFormatting* structures. That's highly inefficient, @@ -56,12 +54,12 @@ public class ConditionalFormattingEvaluator { *
* Instead we need a cached version that is discarded when definitions change. *
- * Sheets don't implement equals, and since its an interface,
+ * Sheets don't implement equals, and since its an interface,
* there's no guarantee instances won't be recreated on the fly by some implementation.
* So we use sheet name.
*/
private final Map
* TODO: eventually this should work like {@link EvaluationCache#notifyUpdateCell(int, int, EvaluationCell)}
@@ -102,7 +100,7 @@ public class ConditionalFormattingEvaluator {
/**
* lazy load by sheet since reading can be expensive
- *
+ *
* @param sheet The sheet to look at
* @return unmodifiable list of rules
*/
@@ -131,43 +129,43 @@ public class ConditionalFormattingEvaluator {
}
return Collections.unmodifiableList(rules);
}
-
+
/**
- * This checks all applicable {@link ConditionalFormattingRule}s for the cell's sheet,
+ * This checks all applicable {@link ConditionalFormattingRule}s for the cell's sheet,
* in defined "priority" order, returning the matches if any. This is a property currently
- * not exposed from
* Most cells will have zero or one applied rule, but it is possible to define multiple rules
* that apply at the same time to the same cell, thus the List result.
*
- * Note that to properly apply conditional rules, care must be taken to offset the base
+ * Note that to properly apply conditional rules, care must be taken to offset the base
* formula by the relative position of the current cell, or the wrong value is checked.
* This is handled by {@link WorkbookEvaluator#evaluate(String, CellReference, CellRangeAddressBase)}.
*
* If the cell exists and is a formula cell, its cached value may be used for rule evaluation, so
- * make sure it is up to date. If values have changed, it is best to call
+ * make sure it is up to date. If values have changed, it is best to call
* {@link FormulaEvaluator#evaluateFormulaCell(Cell)} or {@link FormulaEvaluator#evaluateAll()} first,
- * or the wrong conditional results may be returned.
- *
+ * or the wrong conditional results may be returned.
+ *
* @param cellRef NOTE: if no sheet name is specified, this uses the workbook active sheet
* @return Unmodifiable List of {@link EvaluationConditionalFormatRule}s that apply to the current cell value,
- * in priority order, as evaluated by Excel (smallest priority # for XSSF, definition order for HSSF),
+ * in priority order, as evaluated by Excel (smallest priority # for XSSF, definition order for HSSF),
* or null if none apply
*/
public List
* Most cells will have zero or one applied rule, but it is possible to define multiple rules
* that apply at the same time to the same cell, thus the List result.
*
- * Note that to properly apply conditional rules, care must be taken to offset the base
+ * Note that to properly apply conditional rules, care must be taken to offset the base
* formula by the relative position of the current cell, or the wrong value is checked.
* This is handled by {@link WorkbookEvaluator#evaluate(String, CellReference, CellRangeAddressBase)}.
*
* If the cell exists and is a formula cell, its cached value may be used for rule evaluation, so
- * make sure it is up to date. If values have changed, it is best to call
+ * make sure it is up to date. If values have changed, it is best to call
* {@link FormulaEvaluator#evaluateFormulaCell(Cell)} or {@link FormulaEvaluator#evaluateAll()} first,
- * or the wrong conditional results may be returned.
- *
+ * or the wrong conditional results may be returned.
+ *
* @param cell The cell to look for
* @return Unmodifiable List of {@link EvaluationConditionalFormatRule}s that apply to the current cell value,
- * in priority order, as evaluated by Excel (smallest priority # for XSSF, definition order for HSSF),
+ * in priority order, as evaluated by Excel (smallest priority # for XSSF, definition order for HSSF),
* or null if none apply
*/
public List
+ * EXTERNALNAME (5.39) records and Array tokens.
*/
public final class ConstantValueParser {
// note - these (non-combinable) enum values are sparse.
@@ -59,7 +59,7 @@ public final class ConstantValueParser {
in.readLong(); // 8 byte 'not used' field
return EMPTY_REPRESENTATION;
case TYPE_NUMBER:
- return Double.valueOf(in.readDouble());
+ return in.readDouble();
case TYPE_STRING:
return StringUtil.readUnicodeString(in);
case TYPE_BOOLEAN:
@@ -88,7 +88,7 @@ public final class ConstantValueParser {
public static int getEncodedSize(Object[] values) {
// start with one byte 'type' code for each value
- int result = values.length * 1;
+ int result = values.length;
for (Object value : values) {
result += getEncodedSize(value);
}
@@ -126,14 +126,14 @@ public final class ConstantValueParser {
if (value instanceof Boolean) {
Boolean bVal = ((Boolean)value);
out.writeByte(TYPE_BOOLEAN);
- long longVal = bVal.booleanValue() ? 1L : 0L;
+ long longVal = bVal ? 1L : 0L;
out.writeLong(longVal);
return;
}
if (value instanceof Double) {
Double dVal = (Double) value;
out.writeByte(TYPE_NUMBER);
- out.writeDouble(dVal.doubleValue());
+ out.writeDouble(dVal);
return;
}
if (value instanceof String) {
diff --git a/poi/src/main/java/org/apache/poi/ss/formula/eval/AreaEval.java b/poi/src/main/java/org/apache/poi/ss/formula/eval/AreaEval.java
index c2ce411685..97e387147a 100644
--- a/poi/src/main/java/org/apache/poi/ss/formula/eval/AreaEval.java
+++ b/poi/src/main/java/org/apache/poi/ss/formula/eval/AreaEval.java
@@ -50,7 +50,7 @@ public interface AreaEval extends TwoDEval, ThreeDEval {
/**
* @return the ValueEval from within this area at the specified row and col index. Never
- *
+ * Implementation of Excel formula token '%'.
*/
public final class PercentEval extends Fixed1ArgFunction {
@@ -32,6 +32,7 @@ public final class PercentEval extends Fixed1ArgFunction {
// enforce singleton
}
+ @Override
public ValueEval evaluate(int srcRowIndex, int srcColumnIndex, ValueEval arg0) {
double d;
try {
diff --git a/poi/src/main/java/org/apache/poi/ss/formula/eval/forked/ForkedEvaluationSheet.java b/poi/src/main/java/org/apache/poi/ss/formula/eval/forked/ForkedEvaluationSheet.java
index 73fbe00a7a..8fe9d0cbbd 100644
--- a/poi/src/main/java/org/apache/poi/ss/formula/eval/forked/ForkedEvaluationSheet.java
+++ b/poi/src/main/java/org/apache/poi/ss/formula/eval/forked/ForkedEvaluationSheet.java
@@ -42,7 +42,7 @@ import org.apache.poi.util.Internal;
final class ForkedEvaluationSheet implements EvaluationSheet {
private final EvaluationSheet _masterSheet;
-
+
/**
* Only cells which have been split are put in this map. (This has been done to conserve memory).
*/
@@ -52,7 +52,7 @@ final class ForkedEvaluationSheet implements EvaluationSheet {
_masterSheet = masterSheet;
_sharedCellsByRowCol = new HashMap<>();
}
-
+
/* (non-Javadoc)
* @see org.apache.poi.ss.formula.EvaluationSheet#getlastRowNum()
* @since POI 4.0.0
@@ -61,15 +61,16 @@ final class ForkedEvaluationSheet implements EvaluationSheet {
public int getLastRowNum() {
return _masterSheet.getLastRowNum();
}
-
+
/* (non-Javadoc)
* @see org.apache.poi.ss.formula.EvaluationSheet#isRowHidden(int)
* @since POI 4.1.0
*/
+ @Override
public boolean isRowHidden(int rowIndex) {
return _masterSheet.isRowHidden(rowIndex);
}
-
+
@Override
public EvaluationCell getCell(int rowIndex, int columnIndex) {
RowColKey key = new RowColKey(rowIndex, columnIndex);
@@ -102,8 +103,7 @@ final class ForkedEvaluationSheet implements EvaluationSheet {
RowColKey[] keys = new RowColKey[_sharedCellsByRowCol.size()];
_sharedCellsByRowCol.keySet().toArray(keys);
Arrays.sort(keys);
- for (int i = 0; i < keys.length; i++) {
- RowColKey key = keys[i];
+ for (RowColKey key : keys) {
Row row = sheet.getRow(key.getRowIndex());
if (row == null) {
row = sheet.createRow(key.getRowIndex());
@@ -125,14 +125,14 @@ final class ForkedEvaluationSheet implements EvaluationSheet {
/* (non-Javadoc)
* leave the map alone, if it needs resetting, reusing this class is probably a bad idea.
* @see org.apache.poi.ss.formula.EvaluationSheet#clearAllCachedResultValues()
- *
+ *
* @since POI 3.15 beta 3
*/
@Override
public void clearAllCachedResultValues() {
_masterSheet.clearAllCachedResultValues();
}
-
+
// FIXME: serves same purpose as org.apache.poi.xssf.usermodel.XSSFEvaluationSheet$CellKey
private static final class RowColKey implements Comparable
+ * Implementation for Excel Bin2Dec() function.
*
* Syntax:
@@ -42,6 +42,7 @@ public class Bin2Dec extends Fixed1ArgFunction implements FreeRefFunction {
public static final FreeRefFunction instance = new Bin2Dec();
+ @Override
public ValueEval evaluate(int srcRowIndex, int srcColumnIndex, ValueEval numberVE) {
final String number;
if (numberVE instanceof RefEval) {
@@ -113,6 +114,7 @@ public class Bin2Dec extends Fixed1ArgFunction implements FreeRefFunction {
return s2;
}
+ @Override
public ValueEval evaluate(ValueEval[] args, OperationEvaluationContext ec) {
if (args.length != 1) {
return ErrorEval.VALUE_INVALID;
diff --git a/poi/src/main/java/org/apache/poi/ss/formula/functions/Code.java b/poi/src/main/java/org/apache/poi/ss/formula/functions/Code.java
index 784500f095..96f2a13204 100644
--- a/poi/src/main/java/org/apache/poi/ss/formula/functions/Code.java
+++ b/poi/src/main/java/org/apache/poi/ss/formula/functions/Code.java
@@ -20,7 +20,7 @@ package org.apache.poi.ss.formula.functions;
import org.apache.poi.ss.formula.eval.*;
/**
- * Implementation for Excel CODE () function.
+ * Implementation for Excel CODE () function.
*
* Syntax:
@@ -30,6 +30,7 @@ import org.apache.poi.ss.formula.eval.*;
*/
public class Code extends Fixed1ArgFunction {
+ @Override
public ValueEval evaluate(int srcRowIndex, int srcColumnIndex, ValueEval textArg) {
ValueEval veText1;
diff --git a/poi/src/main/java/org/apache/poi/ss/formula/functions/Complex.java b/poi/src/main/java/org/apache/poi/ss/formula/functions/Complex.java
index 5950260d95..a10c54a758 100644
--- a/poi/src/main/java/org/apache/poi/ss/formula/functions/Complex.java
+++ b/poi/src/main/java/org/apache/poi/ss/formula/functions/Complex.java
@@ -27,13 +27,12 @@ import org.apache.poi.ss.formula.eval.StringEval;
import org.apache.poi.ss.formula.eval.ValueEval;
/**
- * Implementation for Excel COMPLEX () function.
+ * Implementation for Excel COMPLEX () function.
*
* Syntax:
* Converts real and imaginary coefficients into a complex number of the form x + yi or x + yj.
*
- *
* All complex number functions accept "i" and "j" for suffix, but neither "I" nor "J".
* Using uppercase results in the #VALUE! error value. All functions that accept two
* or more complex numbers require that all suffixes match.
@@ -41,11 +40,9 @@ import org.apache.poi.ss.formula.eval.ValueEval;
* real_num The real coefficient of the complex number.
* If this argument is nonnumeric, this function returns the #VALUE! error value.
*
- *
* i_num The imaginary coefficient of the complex number.
* If this argument is nonnumeric, this function returns the #VALUE! error value.
*
- *
* suffix The suffix for the imaginary component of the complex number.
*
*
* Syntax:
+ * DATEVALUE(date_text)
*
* The DATEVALUE function converts a date that is stored as text to a serial number that Excel
* recognizes as a date. For example, the formula =DATEVALUE("1/1/2008") returns 39448, the
diff --git a/poi/src/main/java/org/apache/poi/ss/formula/functions/Delta.java b/poi/src/main/java/org/apache/poi/ss/formula/functions/Delta.java
index b2b24ce69c..047bac18d3 100644
--- a/poi/src/main/java/org/apache/poi/ss/formula/functions/Delta.java
+++ b/poi/src/main/java/org/apache/poi/ss/formula/functions/Delta.java
@@ -25,7 +25,7 @@ import org.apache.poi.ss.formula.eval.OperandResolver;
import org.apache.poi.ss.formula.eval.ValueEval;
/**
- * Implementation for Excel DELTA() function.
+ * Implementation for Excel DELTA() function.
*
* Syntax:
@@ -45,6 +45,7 @@ public final class Delta extends Fixed2ArgFunction implements FreeRefFunction {
private static final NumberEval ONE = new NumberEval(1);
private static final NumberEval ZERO = new NumberEval(0);
+ @Override
public ValueEval evaluate(int srcRowIndex, int srcColumnIndex, ValueEval arg1, ValueEval arg2) {
try {
Double number1 = evaluateValue(arg1, srcRowIndex, srcColumnIndex);
@@ -62,6 +63,7 @@ public final class Delta extends Fixed2ArgFunction implements FreeRefFunction {
}
}
+ @Override
public ValueEval evaluate(ValueEval[] args, OperationEvaluationContext ec) {
if (args.length == 2) {
return evaluate(ec.getRowIndex(), ec.getColumnIndex(), args[0], args[1]);
diff --git a/poi/src/main/java/org/apache/poi/ss/formula/functions/EOMonth.java b/poi/src/main/java/org/apache/poi/ss/formula/functions/EOMonth.java
index f0c5c4bb5b..68f92abec5 100644
--- a/poi/src/main/java/org/apache/poi/ss/formula/functions/EOMonth.java
+++ b/poi/src/main/java/org/apache/poi/ss/formula/functions/EOMonth.java
@@ -29,12 +29,12 @@ import org.apache.poi.ss.usermodel.DateUtil;
import org.apache.poi.util.LocaleUtil;
/**
- * Implementation for the Excel EOMONTH() function.
+ * Implementation for the Excel EOMONTH() function.
*
- * EOMONTH() returns the date of the last day of a month..
+ * EOMONTH() returns the date of the last day of a month.
*
* Syntax:
+ * EOMONTH(start_date,months)
*
* start_date is the starting date of the calculation
* months is the number of months to be added to start_date,
diff --git a/poi/src/main/java/org/apache/poi/ss/formula/functions/FactDouble.java b/poi/src/main/java/org/apache/poi/ss/formula/functions/FactDouble.java
index 70efd0c6a4..a2e44f3867 100644
--- a/poi/src/main/java/org/apache/poi/ss/formula/functions/FactDouble.java
+++ b/poi/src/main/java/org/apache/poi/ss/formula/functions/FactDouble.java
@@ -24,7 +24,7 @@ import java.math.BigInteger;
import java.util.HashMap;
/**
- * Implementation for Excel FACTDOUBLE() function.
+ * Implementation for Excel FACTDOUBLE() function.
*
* Syntax:
@@ -46,6 +46,7 @@ public class FactDouble extends Fixed1ArgFunction implements FreeRefFunction {
//Caching of previously calculated factorial for speed
static HashMap
+ * Returns a frequency distribution as a vertical array
*
* Syntax
+ * FREQUENCY(data_array, bins_array)
*
* data_array Required. An array of or reference to a set of values for which you want to count frequencies.
* If data_array contains no values, FREQUENCY returns an array of zeros.
+ * Implementation for Excel HEX2DEC() function.
*
* Syntax:
@@ -40,6 +40,7 @@ public class Hex2Dec extends Fixed1ArgFunction implements FreeRefFunction {
static final int HEXADECIMAL_BASE = 16;
static final int MAX_NUMBER_OF_PLACES = 10;
+ @Override
public ValueEval evaluate(int srcRowIndex, int srcColumnIndex, ValueEval numberVE) {
final String hex;
if (numberVE instanceof RefEval) {
@@ -55,6 +56,7 @@ public class Hex2Dec extends Fixed1ArgFunction implements FreeRefFunction {
}
}
+ @Override
public ValueEval evaluate(ValueEval[] args, OperationEvaluationContext ec) {
if (args.length != 1) {
return ErrorEval.VALUE_INVALID;
diff --git a/poi/src/main/java/org/apache/poi/ss/formula/functions/ImReal.java b/poi/src/main/java/org/apache/poi/ss/formula/functions/ImReal.java
index 6c4a4d7f2e..024fb119db 100644
--- a/poi/src/main/java/org/apache/poi/ss/formula/functions/ImReal.java
+++ b/poi/src/main/java/org/apache/poi/ss/formula/functions/ImReal.java
@@ -27,7 +27,7 @@ import org.apache.poi.ss.formula.eval.StringEval;
import org.apache.poi.ss.formula.eval.ValueEval;
/**
- * Implementation for Excel ImReal() function.
+ * Implementation for Excel ImReal() function.
*
* Syntax:
@@ -45,6 +45,7 @@ public class ImReal extends Fixed1ArgFunction implements FreeRefFunction {
public static final FreeRefFunction instance = new ImReal();
+ @Override
public ValueEval evaluate(int srcRowIndex, int srcColumnIndex, ValueEval inumberVE) {
ValueEval veText1;
try {
@@ -55,38 +56,24 @@ public class ImReal extends Fixed1ArgFunction implements FreeRefFunction {
String iNumber = OperandResolver.coerceValueToString(veText1);
Matcher m = Imaginary.COMPLEX_NUMBER_PATTERN.matcher(iNumber);
- boolean result = m.matches();
-
- String real = "";
- if (result) {
- String realGroup = m.group(2);
- boolean hasRealPart = realGroup.length() != 0;
-
- if (realGroup.length() == 0) {
- return new StringEval(String.valueOf(0));
- }
-
- if (hasRealPart) {
- String sign = "";
- String realSign = m.group(Imaginary.GROUP1_REAL_SIGN);
- if (realSign.length() != 0 && !(realSign.equals("+"))) {
- sign = realSign;
- }
-
- String groupRealNumber = m.group(Imaginary.GROUP2_IMAGINARY_INTEGER_OR_DOUBLE);
- if (groupRealNumber.length() != 0) {
- real = sign + groupRealNumber;
- } else {
- real = sign + "1";
- }
- }
- } else {
+ if (!m.matches()) {
return ErrorEval.NUM_ERROR;
}
- return new StringEval(real);
+ String realGroup = m.group(2);
+ if (realGroup.isEmpty()) {
+ return new StringEval("0");
+ }
+
+ String realSign = m.group(Imaginary.GROUP1_REAL_SIGN);
+ String groupRealNumber = m.group(Imaginary.GROUP2_IMAGINARY_INTEGER_OR_DOUBLE);
+ String sign = "+".equals(realSign) ? "" : realSign;
+ String real = groupRealNumber.isEmpty() ? "1" : groupRealNumber;
+
+ return new StringEval(sign + real);
}
+ @Override
public ValueEval evaluate(ValueEval[] args, OperationEvaluationContext ec) {
if (args.length != 1) {
return ErrorEval.VALUE_INVALID;
diff --git a/poi/src/main/java/org/apache/poi/ss/formula/functions/Imaginary.java b/poi/src/main/java/org/apache/poi/ss/formula/functions/Imaginary.java
index 3a22097f0d..012aacdd01 100644
--- a/poi/src/main/java/org/apache/poi/ss/formula/functions/Imaginary.java
+++ b/poi/src/main/java/org/apache/poi/ss/formula/functions/Imaginary.java
@@ -24,7 +24,7 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
- * Implementation for Excel IMAGINARY() function.
+ * Implementation for Excel IMAGINARY() function.
*
* Syntax:
@@ -56,6 +56,7 @@ public class Imaginary extends Fixed1ArgFunction implements FreeRefFunction {
public static final int GROUP3_IMAGINARY_SIGN = 3;
public static final int GROUP4_IMAGINARY_INTEGER_OR_DOUBLE = 4;
+ @Override
public ValueEval evaluate(int srcRowIndex, int srcColumnIndex, ValueEval inumberVE) {
ValueEval veText1;
try {
@@ -98,6 +99,7 @@ public class Imaginary extends Fixed1ArgFunction implements FreeRefFunction {
return new StringEval(imaginary);
}
+ @Override
public ValueEval evaluate(ValueEval[] args, OperationEvaluationContext ec) {
if (args.length != 1) {
return ErrorEval.VALUE_INVALID;
diff --git a/poi/src/main/java/org/apache/poi/ss/formula/functions/Intercept.java b/poi/src/main/java/org/apache/poi/ss/formula/functions/Intercept.java
index 706d777596..8d9ab52762 100644
--- a/poi/src/main/java/org/apache/poi/ss/formula/functions/Intercept.java
+++ b/poi/src/main/java/org/apache/poi/ss/formula/functions/Intercept.java
@@ -28,7 +28,7 @@ import org.apache.poi.ss.formula.functions.LinearRegressionFunction.FUNCTION;
* Calculates the INTERCEPT of the linear regression line that is used to predict y values from x values
+ * INTERCEPT(arrayX, arrayY)
*/
public final class Intercept extends Fixed2ArgFunction {
@@ -37,6 +37,7 @@ public final class Intercept extends Fixed2ArgFunction {
func = new LinearRegressionFunction(FUNCTION.INTERCEPT);
}
+ @Override
public ValueEval evaluate(int srcRowIndex, int srcColumnIndex,
ValueEval arg0, ValueEval arg1) {
return func.evaluate(srcRowIndex, srcColumnIndex, arg0, arg1);
diff --git a/poi/src/main/java/org/apache/poi/ss/formula/functions/Oct2Dec.java b/poi/src/main/java/org/apache/poi/ss/formula/functions/Oct2Dec.java
index 260aa3cb1e..dd17a63de8 100644
--- a/poi/src/main/java/org/apache/poi/ss/formula/functions/Oct2Dec.java
+++ b/poi/src/main/java/org/apache/poi/ss/formula/functions/Oct2Dec.java
@@ -23,7 +23,7 @@ import org.apache.poi.ss.formula.eval.OperandResolver;
import org.apache.poi.ss.formula.eval.ValueEval;
/**
- * Implementation for Excel Oct2Dec() function.
+ * Implementation for Excel Oct2Dec() function.
*
* Converts an octal number to decimal.
* Implementation for Excel QUOTIENT () function.
+ * Implementation for Excel QUOTIENT () function.
*
* Syntax:
- *
* Numerator is the dividend.
* Denominator is the divisor.
*
@@ -41,16 +40,17 @@ public class Quotient extends Fixed2ArgFunction implements FreeRefFunction {
public static final FreeRefFunction instance = new Quotient();
+ @Override
public ValueEval evaluate(int srcRowIndex, int srcColumnIndex, ValueEval venumerator, ValueEval vedenominator) {
- double enumerator = 0;
+ double enumerator;
try {
enumerator = OperandResolver.coerceValueToDouble(venumerator);
} catch (EvaluationException e) {
return ErrorEval.VALUE_INVALID;
}
- double denominator = 0;
+ double denominator;
try {
denominator = OperandResolver.coerceValueToDouble(vedenominator);
} catch (EvaluationException e) {
@@ -64,6 +64,7 @@ public class Quotient extends Fixed2ArgFunction implements FreeRefFunction {
return new NumberEval((int)(enumerator / denominator));
}
+ @Override
public ValueEval evaluate(ValueEval[] args, OperationEvaluationContext ec) {
if (args.length != 2) {
return ErrorEval.VALUE_INVALID;
diff --git a/poi/src/main/java/org/apache/poi/ss/formula/functions/Rept.java b/poi/src/main/java/org/apache/poi/ss/formula/functions/Rept.java
index 952a1bed16..686deb0ac4 100644
--- a/poi/src/main/java/org/apache/poi/ss/formula/functions/Rept.java
+++ b/poi/src/main/java/org/apache/poi/ss/formula/functions/Rept.java
@@ -24,7 +24,7 @@ import org.apache.poi.ss.formula.eval.StringEval;
import org.apache.poi.ss.formula.eval.ValueEval;
/**
- * Implementation for Excel REPT () function.
+ * Implementation for Excel REPT () function.
*
* Syntax:
@@ -41,6 +41,7 @@ import org.apache.poi.ss.formula.eval.ValueEval;
public class Rept extends Fixed2ArgFunction {
+ @Override
public ValueEval evaluate(int srcRowIndex, int srcColumnIndex, ValueEval text, ValueEval number_times) {
ValueEval veText1;
@@ -50,7 +51,7 @@ public class Rept extends Fixed2ArgFunction {
return e.getErrorEval();
}
String strText1 = OperandResolver.coerceValueToString(veText1);
- double numberOfTime = 0;
+ double numberOfTime;
try {
numberOfTime = OperandResolver.coerceValueToDouble(number_times);
} catch (EvaluationException e) {
diff --git a/poi/src/main/java/org/apache/poi/ss/formula/functions/Roman.java b/poi/src/main/java/org/apache/poi/ss/formula/functions/Roman.java
index f822990dc3..4464ee4cff 100644
--- a/poi/src/main/java/org/apache/poi/ss/formula/functions/Roman.java
+++ b/poi/src/main/java/org/apache/poi/ss/formula/functions/Roman.java
@@ -24,13 +24,12 @@ import org.apache.poi.ss.formula.eval.StringEval;
import org.apache.poi.ss.formula.eval.ValueEval;
/**
- * Implementation for Excel Roman() function.
+ * Implementation for Excel Roman() function.
*
* Syntax:
* Converts an arabic numeral to roman, as text.
*
- *
* Number Required. The Arabic numeral you want converted.
* Form Optional. A number specifying the type of roman numeral you want.
* The roman numeral style ranges from Classic to Simplified, becoming more concise as the value of form increases.
@@ -79,6 +78,7 @@ public class Roman extends Fixed2ArgFunction {
+ @Override
public ValueEval evaluate(int srcRowIndex, int srcColumnIndex, ValueEval numberVE, ValueEval formVE) {
final int number;
try {
diff --git a/poi/src/main/java/org/apache/poi/ss/formula/functions/Slope.java b/poi/src/main/java/org/apache/poi/ss/formula/functions/Slope.java
index 645ae933e7..37fbe3e6fb 100644
--- a/poi/src/main/java/org/apache/poi/ss/formula/functions/Slope.java
+++ b/poi/src/main/java/org/apache/poi/ss/formula/functions/Slope.java
@@ -28,7 +28,7 @@ import org.apache.poi.ss.formula.functions.LinearRegressionFunction.FUNCTION;
* Calculates the SLOPE of the linear regression line that is used to predict y values from x values
+ * SLOPE(arrayX, arrayY)
*/
public final class Slope extends Fixed2ArgFunction {
@@ -37,6 +37,7 @@ public final class Slope extends Fixed2ArgFunction {
func = new LinearRegressionFunction(FUNCTION.SLOPE);
}
+ @Override
public ValueEval evaluate(int srcRowIndex, int srcColumnIndex,
ValueEval arg0, ValueEval arg1) {
return func.evaluate(srcRowIndex, srcColumnIndex, arg0, arg1);
diff --git a/poi/src/main/java/org/apache/poi/ss/formula/functions/WeekNum.java b/poi/src/main/java/org/apache/poi/ss/formula/functions/WeekNum.java
index eec44cc86f..9585a88ee2 100644
--- a/poi/src/main/java/org/apache/poi/ss/formula/functions/WeekNum.java
+++ b/poi/src/main/java/org/apache/poi/ss/formula/functions/WeekNum.java
@@ -29,13 +29,12 @@ import org.apache.poi.ss.usermodel.DateUtil;
import org.apache.poi.util.LocaleUtil;
/**
- * Implementation for Excel WeekNum() function.
+ * Implementation for Excel WeekNum() function.
*
* Syntax:
* Returns a number that indicates where the week falls numerically within a year.
*
- *
* Serial_num is a date within the week. Dates should be entered by using the DATE function,
* or as results of other formulas or functions. For example, use DATE(2008,5,23)
* for the 23rd day of May, 2008. Problems can occur if dates are entered as text.
@@ -46,6 +45,7 @@ import org.apache.poi.util.LocaleUtil;
public class WeekNum extends Fixed2ArgFunction implements FreeRefFunction {
public static final FreeRefFunction instance = new WeekNum();
+ @Override
public ValueEval evaluate(int srcRowIndex, int srcColumnIndex, ValueEval serialNumVE, ValueEval returnTypeVE) {
double serialNum;
try {
@@ -80,6 +80,7 @@ public class WeekNum extends Fixed2ArgFunction implements FreeRefFunction {
return cal.get(Calendar.WEEK_OF_YEAR);
}
+ @Override
public ValueEval evaluate(ValueEval[] args, OperationEvaluationContext ec) {
if (args.length == 2) {
return evaluate(ec.getRowIndex(), ec.getColumnIndex(), args[0], args[1]);
diff --git a/poi/src/main/java/org/apache/poi/ss/usermodel/BuiltinFormats.java b/poi/src/main/java/org/apache/poi/ss/usermodel/BuiltinFormats.java
index c430888178..e56e6e4a2b 100644
--- a/poi/src/main/java/org/apache/poi/ss/usermodel/BuiltinFormats.java
+++ b/poi/src/main/java/org/apache/poi/ss/usermodel/BuiltinFormats.java
@@ -18,7 +18,7 @@ package org.apache.poi.ss.usermodel;
/**
* Utility to identify built-in formats. The following is a list of the formats as
- * returned by this class.
+ * returned by this class.
*
* 0, "General"
*/
public final class BuiltinFormats {
/**
@@ -108,7 +107,7 @@ public final class BuiltinFormats {
"reserved-0x22",
"reserved-0x23",
"reserved-0x24",
-
+
"#,##0_);(#,##0)",
"#,##0_);[Red](#,##0)",
"#,##0.00_);(#,##0.00)",
@@ -135,7 +134,7 @@ public final class BuiltinFormats {
* Get the format string that matches the given format index
*
* @param index of a built in format
- * @return string represented at index of format or
* Enum names match the OOXML spec values exactly, so {@link #valueOf(String)} will work.
- *
+ *
* @since 3.17 beta 1
*/
public enum TableStyleType {
/***/
wholeTable {
+ @Override
public CellRangeAddressBase getRange(Table table, CellReference cell) {
return new CellRangeAddress(table.getStartRowIndex(), table.getEndRowIndex(), table.getStartColIndex(), table.getEndColIndex());
}
@@ -49,6 +50,7 @@ public enum TableStyleType {
pageFieldValues, // pivot only
/***/
firstColumnStripe{
+ @Override
public CellRangeAddressBase getRange(Table table, CellReference cell) {
TableStyleInfo info = table.getStyle();
if (! info.isShowColumnStripes()) return null;
@@ -56,11 +58,11 @@ public enum TableStyleType {
DifferentialStyleProvider c2Style = info.getStyle().getStyle(secondColumnStripe);
int c1Stripe = c1Style == null ? 1 : Math.max(1, c1Style.getStripeSize());
int c2Stripe = c2Style == null ? 1 : Math.max(1, c2Style.getStripeSize());
-
+
int firstStart = table.getStartColIndex();
int secondStart = firstStart + c1Stripe;
final int c = cell.getCol();
-
+
// look for the stripe containing c, accounting for the style element stripe size
// could do fancy math, but tables can't be that wide, a simple loop is fine
// if not in this type of stripe, return null
@@ -76,10 +78,11 @@ public enum TableStyleType {
},
/***/
secondColumnStripe{
+ @Override
public CellRangeAddressBase getRange(Table table, CellReference cell) {
TableStyleInfo info = table.getStyle();
if (! info.isShowColumnStripes()) return null;
-
+
DifferentialStyleProvider c1Style = info.getStyle().getStyle(firstColumnStripe);
DifferentialStyleProvider c2Style = info.getStyle().getStyle(secondColumnStripe);
int c1Stripe = c1Style == null ? 1 : Math.max(1, c1Style.getStripeSize());
@@ -88,7 +91,7 @@ public enum TableStyleType {
int firstStart = table.getStartColIndex();
int secondStart = firstStart + c1Stripe;
final int c = cell.getCol();
-
+
// look for the stripe containing c, accounting for the style element stripe size
// could do fancy math, but tables can't be that wide, a simple loop is fine
// if not in this type of stripe, return null
@@ -104,10 +107,11 @@ public enum TableStyleType {
},
/***/
firstRowStripe {
+ @Override
public CellRangeAddressBase getRange(Table table, CellReference cell) {
TableStyleInfo info = table.getStyle();
if (! info.isShowRowStripes()) return null;
-
+
DifferentialStyleProvider c1Style = info.getStyle().getStyle(firstRowStripe);
DifferentialStyleProvider c2Style = info.getStyle().getStyle(secondRowStripe);
int c1Stripe = c1Style == null ? 1 : Math.max(1, c1Style.getStripeSize());
@@ -116,7 +120,7 @@ public enum TableStyleType {
int firstStart = table.getStartRowIndex() + table.getHeaderRowCount();
int secondStart = firstStart + c1Stripe;
final int c = cell.getRow();
-
+
// look for the stripe containing c, accounting for the style element stripe size
// could do fancy math, but tables can't be that wide, a simple loop is fine
// if not in this type of stripe, return null
@@ -132,10 +136,11 @@ public enum TableStyleType {
},
/***/
secondRowStripe{
+ @Override
public CellRangeAddressBase getRange(Table table, CellReference cell) {
TableStyleInfo info = table.getStyle();
if (! info.isShowRowStripes()) return null;
-
+
DifferentialStyleProvider c1Style = info.getStyle().getStyle(firstRowStripe);
DifferentialStyleProvider c2Style = info.getStyle().getStyle(secondRowStripe);
int c1Stripe = c1Style == null ? 1 : Math.max(1, c1Style.getStripeSize());
@@ -144,7 +149,7 @@ public enum TableStyleType {
int firstStart = table.getStartRowIndex() + table.getHeaderRowCount();
int secondStart = firstStart + c1Stripe;
final int c = cell.getRow();
-
+
// look for the stripe containing c, accounting for the style element stripe size
// could do fancy math, but tables can't be that wide, a simple loop is fine
// if not in this type of stripe, return null
@@ -160,6 +165,7 @@ public enum TableStyleType {
},
/***/
lastColumn {
+ @Override
public CellRangeAddressBase getRange(Table table, CellReference cell) {
if (! table.getStyle().isShowLastColumn()) return null;
return new CellRangeAddress(table.getStartRowIndex(), table.getEndRowIndex(), table.getEndColIndex(), table.getEndColIndex());
@@ -167,6 +173,7 @@ public enum TableStyleType {
},
/***/
firstColumn {
+ @Override
public CellRangeAddressBase getRange(Table table, CellReference cell) {
if (! table.getStyle().isShowFirstColumn()) return null;
return new CellRangeAddress(table.getStartRowIndex(), table.getEndRowIndex(), table.getStartColIndex(), table.getStartColIndex());
@@ -174,6 +181,7 @@ public enum TableStyleType {
},
/***/
headerRow {
+ @Override
public CellRangeAddressBase getRange(Table table, CellReference cell) {
if (table.getHeaderRowCount() < 1) return null;
return new CellRangeAddress(table.getStartRowIndex(), table.getStartRowIndex() + table.getHeaderRowCount() -1, table.getStartColIndex(), table.getEndColIndex());
@@ -181,6 +189,7 @@ public enum TableStyleType {
},
/***/
totalRow {
+ @Override
public CellRangeAddressBase getRange(Table table, CellReference cell) {
if (table.getTotalsRowCount() < 1) return null;
return new CellRangeAddress(table.getEndRowIndex() - table.getTotalsRowCount() +1, table.getEndRowIndex(), table.getStartColIndex(), table.getEndColIndex());
@@ -188,6 +197,7 @@ public enum TableStyleType {
},
/***/
firstHeaderCell {
+ @Override
public CellRangeAddressBase getRange(Table table, CellReference cell) {
if (table.getHeaderRowCount() < 1) return null;
return new CellRangeAddress(table.getStartRowIndex(), table.getStartRowIndex(), table.getStartColIndex(), table.getStartColIndex());
@@ -195,6 +205,7 @@ public enum TableStyleType {
},
/***/
lastHeaderCell {
+ @Override
public CellRangeAddressBase getRange(Table table, CellReference cell) {
if (table.getHeaderRowCount() < 1) return null;
return new CellRangeAddress(table.getStartRowIndex(), table.getStartRowIndex(), table.getEndColIndex(), table.getEndColIndex());
@@ -202,6 +213,7 @@ public enum TableStyleType {
},
/***/
firstTotalCell {
+ @Override
public CellRangeAddressBase getRange(Table table, CellReference cell) {
if (table.getTotalsRowCount() < 1) return null;
return new CellRangeAddress(table.getEndRowIndex() - table.getTotalsRowCount() +1, table.getEndRowIndex(), table.getStartColIndex(), table.getStartColIndex());
@@ -209,6 +221,7 @@ public enum TableStyleType {
},
/***/
lastTotalCell {
+ @Override
public CellRangeAddressBase getRange(Table table, CellReference cell) {
if (table.getTotalsRowCount() < 1) return null;
return new CellRangeAddress(table.getEndRowIndex() - table.getTotalsRowCount() +1, table.getEndRowIndex(), table.getEndColIndex(), table.getEndColIndex());
@@ -242,7 +255,7 @@ public enum TableStyleType {
/***/
thirdRowSubheading,
;
-
+
/**
* A range is returned only for the part of the table matching this enum instance and containing the given cell.
* Null is returned for all other cases, such as:
@@ -255,9 +268,9 @@ public enum TableStyleType {
* The returned range can be used to determine how style options may or may not apply to this cell.
* For example, {@link #wholeTable} borders only apply to the outer boundary of a table, while the
* rest of the styling, such as font and color, could apply to all the interior cells as well.
- *
+ *
* @param table table to evaluate
- * @param cell to evaluate
+ * @param cell to evaluate
* @return range in the table representing this class of cells, if it contains the given cell, or null if not applicable.
* Stripe style types return only the stripe range containing the given cell, or null.
*/
@@ -265,7 +278,7 @@ public enum TableStyleType {
if (cell == null) return null;
return appliesTo(table, new CellReference(cell.getSheet().getSheetName(), cell.getRowIndex(), cell.getColumnIndex(), true, true));
}
-
+
/**
* A range is returned only for the part of the table matching this enum instance and containing the given cell reference.
* Null is returned for all other cases, such as:
@@ -278,9 +291,9 @@ public enum TableStyleType {
* The returned range can be used to determine how style options may or may not apply to this cell.
* For example, {@link #wholeTable} borders only apply to the outer boundary of a table, while the
* rest of the styling, such as font and color, could apply to all the interior cells as well.
- *
+ *
* @param table table to evaluate
- * @param cell CellReference to evaluate
+ * @param cell CellReference to evaluate
* @return range in the table representing this class of cells, if it contains the given cell, or null if not applicable.
* Stripe style types return only the stripe range containing the given cell, or null.
*/
@@ -288,7 +301,7 @@ public enum TableStyleType {
if (table == null || cell == null) return null;
if ( ! cell.getSheetName().equals(table.getSheetName())) return null;
if ( ! table.contains(cell)) return null;
-
+
final CellRangeAddressBase range = getRange(table, cell);
if (range != null && range.isInRange(cell.getRow(), cell.getCol())) return range;
// else
@@ -297,8 +310,6 @@ public enum TableStyleType {
/**
* Calls {@link #getRange(Table, CellReference)}. Use that instead for performance.
- * @param table
- * @param cell
* @return default is unimplemented/null
* @see #getRange(Table, CellReference)
*/
@@ -306,11 +317,8 @@ public enum TableStyleType {
if (cell == null) return null;
return getRange(table, new CellReference(cell.getSheet().getSheetName(), cell.getRowIndex(), cell.getColumnIndex(), true, true));
}
-
+
/**
- *
- * @param table
- * @param cell
* @return default is unimplemented/null
*/
public CellRangeAddressBase getRange(Table table, CellReference cell) {
diff --git a/poi/src/main/java/org/apache/poi/ss/util/CellRangeAddress.java b/poi/src/main/java/org/apache/poi/ss/util/CellRangeAddress.java
index 328148d3c4..a8a1dbc897 100644
--- a/poi/src/main/java/org/apache/poi/ss/util/CellRangeAddress.java
+++ b/poi/src/main/java/org/apache/poi/ss/util/CellRangeAddress.java
@@ -23,7 +23,7 @@ import org.apache.poi.ss.formula.SheetNameFormatter;
import org.apache.poi.util.LittleEndianOutput;
/**
- * See OOO documentation: excelfileformat.pdf sec 2.5.14 - 'Cell Range Address'
+ * See OOO documentation: excelfileformat.pdf sec 2.5.14 - 'Cell Range Address'
*
* In the Microsoft documentation, this is also known as a
* Ref8U - see page 831 of version 1.0 of the documentation.
diff --git a/poi/src/main/java/org/apache/poi/ss/util/CellRangeAddressBase.java b/poi/src/main/java/org/apache/poi/ss/util/CellRangeAddressBase.java
index 7ae0eada45..4b33846716 100644
--- a/poi/src/main/java/org/apache/poi/ss/util/CellRangeAddressBase.java
+++ b/poi/src/main/java/org/apache/poi/ss/util/CellRangeAddressBase.java
@@ -52,8 +52,7 @@ public abstract class CellRangeAddressBase implements Iterable
- * A {@link PropertyTemplate} is a template that can be applied to any sheet in
+ * A PropertyTemplate is a template that can be applied to any sheet in
* a project. It contains all the border type and color attributes needed to
* draw all the borders for a single sheet. That template can be applied to any
* sheet in any workbook.
- *
- * This class requires the full spreadsheet to be in memory, so
+ *
+ * This class requires the full spreadsheet to be in memory, so
* {@link org.apache.poi.xssf.streaming.SXSSFWorkbook} Spreadsheets are not
- * supported. The same {@link PropertyTemplate} can, however, be applied to both
+ * supported. The same PropertyTemplate can, however, be applied to both
* {@link HSSFWorkbook} and {@link org.apache.poi.xssf.usermodel.XSSFWorkbook}
* objects if necessary. Portions of the border that fall outside the max range
* of the {@link Workbook} sheet are ignored.
*
* This would replace {@link RegionUtil}.
*
* Draws the top border for a range of cells
*
* Draws the bottom border for a range of cells
*
*
+ * Locale Collection
*
* This enum can be used to map between Windows LCID and Java {@link java.util.Locale Locales}
*
diff --git a/poi/src/main/java/org/apache/poi/util/LocaleUtil.java b/poi/src/main/java/org/apache/poi/util/LocaleUtil.java
index 5e6619645c..860999c25e 100644
--- a/poi/src/main/java/org/apache/poi/util/LocaleUtil.java
+++ b/poi/src/main/java/org/apache/poi/util/LocaleUtil.java
@@ -115,9 +115,6 @@ public final class LocaleUtil {
/**
* Convenience method - month is 0-based as in java.util.Calendar
*
- * @param year
- * @param month
- * @param day
* @return a calendar for the user locale and time zone, and the given date
*/
public static Calendar getLocaleCalendar(int year, int month, int day) {
@@ -127,12 +124,6 @@ public final class LocaleUtil {
/**
* Convenience method - month is 0-based as in java.util.Calendar
*
- * @param year
- * @param month
- * @param day
- * @param hour
- * @param minute
- * @param second
* @return a calendar for the user locale and time zone, and the given date
*/
public static Calendar getLocaleCalendar(int year, int month, int day, int hour, int minute, int second) {
diff --git a/poi/src/test/resources/log4j2-test.xml b/poi/src/test/resources/log4j2-test.xml
index 4737e9569a..eb8148f876 100644
--- a/poi/src/test/resources/log4j2-test.xml
+++ b/poi/src/test/resources/log4j2-test.xml
@@ -31,8 +31,8 @@
CTCfRule
in XSSFConditionalFormattingRule
.
+ * not exposed from {@code CTCfRule} in {@code XSSFConditionalFormattingRule}.
* CTCfRule
in XSSFConditionalFormattingRule
.
+ * not exposed from {@code CTCfRule} in {@code XSSFConditionalFormattingRule}.
* ,Set
int
s (possibly stored in the Excel file) to FormulaType
s.
- * @param code
+ * Used to transition from {@code int}s (possibly stored in the Excel file) to {@code FormulaType}s.
* @return FormulaType
* @throws IllegalArgumentException if code is out of range
* @since POI 3.15 beta 3.
diff --git a/poi/src/main/java/org/apache/poi/ss/formula/LazyAreaEval.java b/poi/src/main/java/org/apache/poi/ss/formula/LazyAreaEval.java
index f10cfe6de9..5510b72e19 100644
--- a/poi/src/main/java/org/apache/poi/ss/formula/LazyAreaEval.java
+++ b/poi/src/main/java/org/apache/poi/ss/formula/LazyAreaEval.java
@@ -41,23 +41,27 @@ final class LazyAreaEval extends AreaEvalBase {
_evaluator = evaluator;
}
- public ValueEval getRelativeValue(int relativeRowIndex, int relativeColumnIndex) {
+ @Override
+ public ValueEval getRelativeValue(int relativeRowIndex, int relativeColumnIndex) {
return getRelativeValue(getFirstSheetIndex(), relativeRowIndex, relativeColumnIndex);
}
- public ValueEval getRelativeValue(int sheetIndex, int relativeRowIndex, int relativeColumnIndex) {
+ @Override
+ public ValueEval getRelativeValue(int sheetIndex, int relativeRowIndex, int relativeColumnIndex) {
int rowIx = (relativeRowIndex + getFirstRow() ) ;
int colIx = (relativeColumnIndex + getFirstColumn() ) ;
return _evaluator.getEvalForCell(sheetIndex, rowIx, colIx);
}
+ @Override
public AreaEval offset(int relFirstRowIx, int relLastRowIx, int relFirstColIx, int relLastColIx) {
AreaI area = new OffsetArea(getFirstRow(), getFirstColumn(),
relFirstRowIx, relLastRowIx, relFirstColIx, relLastColIx);
return new LazyAreaEval(area, _evaluator);
}
- public LazyAreaEval getRow(int rowIndex) {
+ @Override
+ public LazyAreaEval getRow(int rowIndex) {
if (rowIndex >= getHeight()) {
throw new IllegalArgumentException("Invalid rowIndex " + rowIndex
+ ". Allowable range is (0.." + getHeight() + ").");
@@ -65,6 +69,7 @@ final class LazyAreaEval extends AreaEvalBase {
int absRowIx = getFirstRow() + rowIndex;
return new LazyAreaEval(absRowIx, getFirstColumn(), absRowIx, getLastColumn(), _evaluator);
}
+ @Override
public LazyAreaEval getColumn(int columnIndex) {
if (columnIndex >= getWidth()) {
throw new IllegalArgumentException("Invalid columnIndex " + columnIndex
@@ -89,17 +94,18 @@ final class LazyAreaEval extends AreaEvalBase {
/**
* @return whether cell at rowIndex and columnIndex is a subtotal
*/
- public boolean isSubTotal(int rowIndex, int columnIndex){
+ @Override
+ public boolean isSubTotal(int rowIndex, int columnIndex){
// delegate the query to the sheet evaluator which has access to internal ptgs
SheetRefEvaluator _sre = _evaluator.getSheetEvaluator(_evaluator.getFirstSheetIndex());
return _sre.isSubTotal(getFirstRow() + rowIndex, getFirstColumn() + columnIndex);
}
-
+
/**
* @return whether the row at rowIndex is hidden
- * @see org.apache.poi.ss.formula.eval.AreaEvalBase#isRowHidden(int)
*/
- public boolean isRowHidden(int rowIndex) {
+ @Override
+ public boolean isRowHidden(int rowIndex) {
// delegate the query to the sheet evaluator which has access to internal ptgs
SheetRefEvaluator _sre = _evaluator.getSheetEvaluator(_evaluator.getFirstSheetIndex());
return _sre.isRowHidden(getFirstRow() + rowIndex);
diff --git a/poi/src/main/java/org/apache/poi/ss/formula/OperatorEnum.java b/poi/src/main/java/org/apache/poi/ss/formula/OperatorEnum.java
new file mode 100644
index 0000000000..2fdc7cb096
--- /dev/null
+++ b/poi/src/main/java/org/apache/poi/ss/formula/OperatorEnum.java
@@ -0,0 +1,198 @@
+/* ====================================================================
+ 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.ss.formula;
+
+import org.apache.poi.util.Internal;
+
+/**
+ * Not calling it OperatorType to avoid confusion for now with other classes.
+ * Definition order matches OOXML type ID indexes.
+ * Note that this has NO_COMPARISON as the first item, unlike the similar
+ * DataValidation operator enum. Thanks, Microsoft.
+ */
+@Internal
+enum OperatorEnum {
+ // always false/invalid
+ NO_COMPARISON(OperatorEnum::noComp, false),
+ BETWEEN(OperatorEnum::between, false),
+ NOT_BETWEEN(OperatorEnum::notBetween, true),
+ EQUAL(OperatorEnum::equal, false),
+ NOT_EQUAL(OperatorEnum::notEqual, true),
+ GREATER_THAN(OperatorEnum::greaterThan, false),
+ LESS_THAN(OperatorEnum::lessThan, false),
+ GREATER_OR_EQUAL(OperatorEnum::greaterOrEqual, false),
+ LESS_OR_EQUAL(OperatorEnum::lessOrEqual, false) ;
+
+ private interface CompareOp {
+ true
if the area has just a single row, this also includes
+ * @return {@code true} if the area has just a single row, this also includes
* the trivial case when the area has just a single cell.
*/
- boolean isRow();
+ default boolean isRow() {
+ return false;
+ }
/**
- * @return true
if the area has just a single column, this also includes
+ * @return {@code true} if the area has just a single column, this also includes
* the trivial case when the area has just a single cell.
*/
boolean isColumn();
/**
* @param rowIndex relative row index (zero based)
- * @return a single row {@link TwoDEval}
+ * @return a single row TwoDEval
*/
TwoDEval getRow(int rowIndex);
/**
* @param columnIndex relative column index (zero based)
- * @return a single column {@link TwoDEval}
+ * @return a single column TwoDEval
*/
TwoDEval getColumn(int columnIndex);
@@ -65,10 +67,8 @@ public interface TwoDEval extends ValueEval {
* @return true if the cell at row and col is a subtotal
*/
boolean isSubTotal(int rowIndex, int columnIndex);
-
+
/**
- *
- * @param rowIndex
* @return true if the row is hidden
* @see Subtotal
*/
diff --git a/poi/src/main/java/org/apache/poi/ss/formula/constant/ConstantValueParser.java b/poi/src/main/java/org/apache/poi/ss/formula/constant/ConstantValueParser.java
index 4487dc83ba..b68e957ea0 100644
--- a/poi/src/main/java/org/apache/poi/ss/formula/constant/ConstantValueParser.java
+++ b/poi/src/main/java/org/apache/poi/ss/formula/constant/ConstantValueParser.java
@@ -24,7 +24,7 @@ import org.apache.poi.util.StringUtil;
/**
* To support Constant Values (2.5.7) as required by the CRN record.
* This class is also used for two dimensional arrays which are encoded by
- * EXTERNALNAME (5.39) records and Array tokens.null
(possibly {@link BlankEval}). The specified indexes should be absolute
+ * {@code null} (possibly {@link BlankEval}). The specified indexes should be absolute
* indexes in the sheet and not relative indexes within the area.
*/
ValueEval getAbsoluteValue(int row, int col);
@@ -59,34 +59,32 @@ public interface AreaEval extends TwoDEval, ThreeDEval {
* returns true if the cell at row and col specified
* as absolute indexes in the sheet is contained in
* this area.
- * @param row
- * @param col
*/
boolean contains(int row, int col);
/**
* returns true if the specified col is in range
- * @param col
*/
boolean containsColumn(int col);
/**
* returns true if the specified row is in range
- * @param row
*/
boolean containsRow(int row);
+ @Override
int getWidth();
+ @Override
int getHeight();
/**
* @return the ValueEval from within this area at the specified relativeRowIndex and
- * relativeColumnIndex. Never null
(possibly {@link BlankEval}). The
+ * relativeColumnIndex. Never {@code null} (possibly {@link BlankEval}). The
* specified indexes should relative to the top left corner of this area.
*/
ValueEval getRelativeValue(int relativeRowIndex, int relativeColumnIndex);
/**
- * Creates an {@link AreaEval} offset by a relative amount from from the upper left cell
+ * Creates an AreaEval offset by a relative amount from from the upper left cell
* of this area
*/
AreaEval offset(int relFirstRowIx, int relLastRowIx, int relFirstColIx, int relLastColIx);
diff --git a/poi/src/main/java/org/apache/poi/ss/formula/eval/AreaEvalBase.java b/poi/src/main/java/org/apache/poi/ss/formula/eval/AreaEvalBase.java
index 0903f51f29..624fa42eb9 100644
--- a/poi/src/main/java/org/apache/poi/ss/formula/eval/AreaEvalBase.java
+++ b/poi/src/main/java/org/apache/poi/ss/formula/eval/AreaEvalBase.java
@@ -59,30 +59,37 @@ public abstract class AreaEvalBase implements AreaEval {
this(sheets, ptg.getFirstRow(), ptg.getFirstColumn(), ptg.getLastRow(), ptg.getLastColumn());
}
+ @Override
public final int getFirstColumn() {
return _firstColumn;
}
+ @Override
public final int getFirstRow() {
return _firstRow;
}
+ @Override
public final int getLastColumn() {
return _lastColumn;
}
+ @Override
public final int getLastRow() {
return _lastRow;
}
+ @Override
public int getFirstSheetIndex() {
return _firstSheet;
}
- public int getLastSheetIndex() {
+ @Override
+ public int getLastSheetIndex() {
return _lastSheet;
}
- public final ValueEval getAbsoluteValue(int row, int col) {
+ @Override
+ public final ValueEval getAbsoluteValue(int row, int col) {
int rowOffsetIx = row - _firstRow;
int colOffsetIx = col - _firstColumn;
@@ -97,40 +104,50 @@ public abstract class AreaEvalBase implements AreaEval {
return getRelativeValue(rowOffsetIx, colOffsetIx);
}
+ @Override
public final boolean contains(int row, int col) {
return _firstRow <= row && _lastRow >= row
&& _firstColumn <= col && _lastColumn >= col;
}
+ @Override
public final boolean containsRow(int row) {
return _firstRow <= row && _lastRow >= row;
}
+ @Override
public final boolean containsColumn(int col) {
return _firstColumn <= col && _lastColumn >= col;
}
+ @Override
public final boolean isColumn() {
return _firstColumn == _lastColumn;
}
+ @Override
public final boolean isRow() {
return _firstRow == _lastRow;
}
+ @Override
public int getHeight() {
return _lastRow-_firstRow+1;
}
- public final ValueEval getValue(int row, int col) {
+ @Override
+ public final ValueEval getValue(int row, int col) {
return getRelativeValue(row, col);
}
- public final ValueEval getValue(int sheetIndex, int row, int col) {
+ @Override
+ public final ValueEval getValue(int sheetIndex, int row, int col) {
return getRelativeValue(sheetIndex, row, col);
}
+ @Override
public abstract ValueEval getRelativeValue(int relativeRowIndex, int relativeColumnIndex);
public abstract ValueEval getRelativeValue(int sheetIndex, int relativeRowIndex, int relativeColumnIndex);
+ @Override
public int getWidth() {
return _lastColumn-_firstColumn+1;
}
@@ -139,7 +156,8 @@ public abstract class AreaEvalBase implements AreaEval {
* @return whether cell at rowIndex and columnIndex is a subtotal.
* By default return false which means 'don't care about subtotals'
*/
- public boolean isSubTotal(int rowIndex, int columnIndex) {
+ @Override
+ public boolean isSubTotal(int rowIndex, int columnIndex) {
return false;
}
@@ -147,7 +165,8 @@ public abstract class AreaEvalBase implements AreaEval {
* @return false by default, meaning all rows are calculated
* @see org.apache.poi.ss.formula.TwoDEval#isRowHidden(int)
*/
- public boolean isRowHidden(int rowIndex) {
+ @Override
+ public boolean isRowHidden(int rowIndex) {
return false;
}
}
diff --git a/poi/src/main/java/org/apache/poi/ss/formula/eval/PercentEval.java b/poi/src/main/java/org/apache/poi/ss/formula/eval/PercentEval.java
index dcaaf9802e..f78dfabc01 100644
--- a/poi/src/main/java/org/apache/poi/ss/formula/eval/PercentEval.java
+++ b/poi/src/main/java/org/apache/poi/ss/formula/eval/PercentEval.java
@@ -22,7 +22,7 @@ import org.apache.poi.ss.formula.functions.Function;
/**
- * Implementation of Excel formula token '%'.
Bin2Dec (number)
*
CODE (text )
*
COMPLEX (real_num,i_num,suffix )
*
*
- * DATEVALUE(date_text)
DELTA (number1,number2 )
*
- * EOMONTH(start_date,months)
FACTDOUBLE (number)
*
- * Returns a frequency distribution as a vertical array
- * FREQUENCY(data_array, bins_array)
@@ -43,6 +43,7 @@ public class Frequency extends Fixed2ArgFunction {
// enforce singleton
}
+ @Override
public ValueEval evaluate(int srcRowIndex, int srcColumnIndex, ValueEval arg0, ValueEval arg1) {
MatrixFunction.MutableValueCollector collector = new MatrixFunction.MutableValueCollector(false, false);
diff --git a/poi/src/main/java/org/apache/poi/ss/formula/functions/Hex2Dec.java b/poi/src/main/java/org/apache/poi/ss/formula/functions/Hex2Dec.java
index d80ce76235..d322a622b8 100644
--- a/poi/src/main/java/org/apache/poi/ss/formula/functions/Hex2Dec.java
+++ b/poi/src/main/java/org/apache/poi/ss/formula/functions/Hex2Dec.java
@@ -21,7 +21,7 @@ import org.apache.poi.ss.formula.OperationEvaluationContext;
import org.apache.poi.ss.formula.eval.*;
/**
- * Implementation for Excel HEX2DEC() function.
HEX2DEC (number)
*
ImReal (Inumber)
*
IMAGINARY (Inumber)
*
* (http://introcs.cs.princeton.edu/java/97data/LinearRegression.java.html)
* Syntax:
- * INTERCEPT(arrayX, arrayY)
QUOTIENT(Numerator,Denominator)
*
REPT (text,number_times )
*
Roman (number,form)
*
* (http://introcs.cs.princeton.edu/java/97data/LinearRegression.java.html)
* Syntax:
- * SLOPE(arrayX, arrayY)
WeekNum (Serial_num,Return_type)
*
* 1, "0"
@@ -59,7 +59,6 @@ package org.apache.poi.ss.usermodel;
* 0x30, "##0.0E+0"
* 0x31, "@" - This is text format.
* 0x31 "text" - Alias for "@"
- * null
if there is not a built-in format at that index
+ * @return string represented at index of format or {@code null} if there is not a built-in format at that index
*/
public static String getBuiltinFormat(int index) {
if (index < 0 || index >=_formats.length) {
@@ -147,7 +146,7 @@ public final class BuiltinFormats {
/**
* Get the format index that matches the given format string.
* Automatically converts "text" to excel's format string to represent text.
- *
+ *
* @param pFmt string matching a built-in format
* @return index of format or -1 if undefined.
*/
@@ -158,10 +157,10 @@ public final class BuiltinFormats {
for (String f : _formats) {
i++;
if (f.equals(fmt)) {
- return i;
+ return i;
}
}
-
+
return -1;
}
}
diff --git a/poi/src/main/java/org/apache/poi/ss/usermodel/Comment.java b/poi/src/main/java/org/apache/poi/ss/usermodel/Comment.java
index c39040cfe3..ea7a49ab32 100644
--- a/poi/src/main/java/org/apache/poi/ss/usermodel/Comment.java
+++ b/poi/src/main/java/org/apache/poi/ss/usermodel/Comment.java
@@ -24,17 +24,17 @@ public interface Comment {
/**
* Sets whether this comment is visible.
*
- * @param visible true
if the comment is visible, false
otherwise
+ * @param visible {@code true} if the comment is visible, {@code false} otherwise
*/
void setVisible(boolean visible);
/**
* Returns whether this comment is visible.
*
- * @return true
if the comment is visible, false
otherwise
+ * @return {@code true} if the comment is visible, {@code false} otherwise
*/
boolean isVisible();
-
+
/**
* Get the address of the cell that this comment is attached to
*
@@ -42,20 +42,17 @@ public interface Comment {
* @since 3.15-beta1
*/
CellAddress getAddress();
-
+
/**
* Set the address of the cell that this comment is attached to
*
- * @param addr
* @since 3.15-beta1
*/
void setAddress(CellAddress addr);
-
+
/**
* Set the address of the cell that this comment is attached to
*
- * @param row
- * @param col
* @since 3.15-beta1
*/
void setAddress(int row, int col);
@@ -101,11 +98,11 @@ public interface Comment {
* @param author the name of the original author of the comment
*/
void setAuthor(String author);
-
+
/**
* Fetches the rich text string of the comment
*/
- public RichTextString getString();
+ RichTextString getString();
/**
* Sets the rich text string used by this comment.
@@ -118,10 +115,10 @@ public interface Comment {
* Return defines position of this anchor in the sheet.
* The anchor is the yellow box/balloon that is rendered on top of the sheets
* when the comment is visible.
- *
+ *
* To associate a comment with a different cell, use {@link #setAddress}.
*
* @return defines position of this anchor in the sheet
*/
- public ClientAnchor getClientAnchor();
+ ClientAnchor getClientAnchor();
}
\ No newline at end of file
diff --git a/poi/src/main/java/org/apache/poi/ss/usermodel/ExcelNumberFormat.java b/poi/src/main/java/org/apache/poi/ss/usermodel/ExcelNumberFormat.java
index ee544f7c9a..09ea6eb165 100644
--- a/poi/src/main/java/org/apache/poi/ss/usermodel/ExcelNumberFormat.java
+++ b/poi/src/main/java/org/apache/poi/ss/usermodel/ExcelNumberFormat.java
@@ -16,7 +16,7 @@
2012 - Alfresco Software, Ltd.
Alfresco Software has modified source of this file
- The details of changes as svn diff can be found in svn at location root/projects/3rd-party/src
+ The details of changes as svn diff can be found in svn at location root/projects/3rd-party/src
==================================================================== */
package org.apache.poi.ss.usermodel;
@@ -32,16 +32,15 @@ public class ExcelNumberFormat {
private final int idx;
private final String format;
-
+
/**
- * @param style
* @return null if the style is null, instance from style data format values otherwise
*/
public static ExcelNumberFormat from(CellStyle style) {
if (style == null) return null;
return new ExcelNumberFormat(style.getDataFormat(), style.getDataFormatString());
}
-
+
/**
* @param cell cell to extract format from
* @param cfEvaluator ConditionalFormattingEvaluator to use, or null if none in this context
@@ -49,9 +48,9 @@ public class ExcelNumberFormat {
*/
public static ExcelNumberFormat from(Cell cell, ConditionalFormattingEvaluator cfEvaluator) {
if (cell == null) return null;
-
+
ExcelNumberFormat nf = null;
-
+
if (cfEvaluator != null) {
// first one wins (priority order, per Excel help)
ListXSSFTable.updateHeaders()
is called to reset the cache.
+ * unless {@code XSSFTable.updateHeaders()} is called to reset the cache.
* @param columnHeader the column header name to get the table column index of
- * @return column index corresponding to columnHeader
+ * @return column index corresponding to {@code columnHeader}
*/
int findColumnIndex(String columnHeader);
/**
@@ -115,7 +115,6 @@ public interface Table {
/**
* checks if the given cell is part of the table. Includes checking that they are on the same sheet.
- * @param cell
* @return true if the table and cell are on the same sheet and the cell is within the table range.
* @since 3.17 beta 1
* @see #contains(CellReference) (prefered, faster execution and handles undefined cells)
diff --git a/poi/src/main/java/org/apache/poi/ss/usermodel/TableStyle.java b/poi/src/main/java/org/apache/poi/ss/usermodel/TableStyle.java
index b4e5e19835..0311aa9086 100644
--- a/poi/src/main/java/org/apache/poi/ss/usermodel/TableStyle.java
+++ b/poi/src/main/java/org/apache/poi/ss/usermodel/TableStyle.java
@@ -21,7 +21,7 @@ package org.apache.poi.ss.usermodel;
* Data table style definition. Includes style elements for various table components.
* Any number of style elements may be represented, and any cell may be styled by
* multiple elements. The order of elements in {@link TableStyleType} defines precedence.
- *
+ *
* @since 3.17 beta 1
*/
public interface TableStyle {
@@ -30,25 +30,23 @@ public interface TableStyle {
* @return name (may be a built-in name)
*/
String getName();
-
+
/**
* Some clients may care where in the table style list this definition came from, so we'll track it.
- * The spec only references these by name, unlike Dxf records, which these definitions reference by index
+ * The spec only references these by name, unlike Dxf records, which these definitions reference by index
* (XML definition order). Nice of MS to be consistent when defining the ECMA standard.
* Use org.apache.poi.xssf.usermodel.XSSFBuiltinTableStyle.isBuiltinStyle(TableStyle) to determine whether the index is for a built-in style or explicit user style
* @return index from org.apache.poi.xssf.model.StylesTable.getExplicitTableStyle(String) or org.apache.poi.xssf.usermodel.XSSFBuiltinTableStyle.ordinal()
*/
int getIndex();
-
+
/**
*
* @return true if this is a built-in style defined in the OOXML specification, false if it is a user style
*/
boolean isBuiltin();
-
+
/**
- *
- * @param type
* @return style definition for the given type, or null if not defined in this style.
*/
DifferentialStyleProvider getStyle(TableStyleType type);
diff --git a/poi/src/main/java/org/apache/poi/ss/usermodel/TableStyleType.java b/poi/src/main/java/org/apache/poi/ss/usermodel/TableStyleType.java
index 870436a3b4..04a8d27c44 100644
--- a/poi/src/main/java/org/apache/poi/ss/usermodel/TableStyleType.java
+++ b/poi/src/main/java/org/apache/poi/ss/usermodel/TableStyleType.java
@@ -33,12 +33,13 @@ import org.apache.poi.ss.util.CellReference;
* first style is found defining a value for that property.
*
*
*
diff --git a/poi/src/main/java/org/apache/poi/util/DocumentFormatException.java b/poi/src/main/java/org/apache/poi/util/DocumentFormatException.java
index e53202235c..e1c0f06a8a 100644
--- a/poi/src/main/java/org/apache/poi/util/DocumentFormatException.java
+++ b/poi/src/main/java/org/apache/poi/util/DocumentFormatException.java
@@ -39,11 +39,8 @@ public class DocumentFormatException extends RuntimeException {
/**
* Syntactic sugar to check whether a DocumentFormatException should
- * be thrown. If assertTrue is java.util.Date
or java.util.Calendar
+ * Object.toString()
+ * false
, this will throw this
+ * be thrown. If assertTrue is {@code false}, this will throw this
* exception with the message.
- *
- * @param assertTrue
- * @param message
*/
public static void check(boolean assertTrue, String message) {
if (!assertTrue) {
diff --git a/poi/src/main/java/org/apache/poi/util/GenericRecordUtil.java b/poi/src/main/java/org/apache/poi/util/GenericRecordUtil.java
index 50a6f3b59a..f788ec8667 100644
--- a/poi/src/main/java/org/apache/poi/util/GenericRecordUtil.java
+++ b/poi/src/main/java/org/apache/poi/util/GenericRecordUtil.java
@@ -32,7 +32,7 @@ public final class GenericRecordUtil {
public static Map