aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--build.gradle119
-rw-r--r--poi-examples/build.gradle10
-rw-r--r--poi-examples/src/main/java/org/apache/poi/examples/hpsf/CopyCompare.java12
-rw-r--r--poi-examples/src/main/java/org/apache/poi/examples/xssf/eventusermodel/LoadPasswordProtectedXlsxStreaming.java6
-rw-r--r--poi-examples/src/main/java/org/apache/poi/examples/xssf/streaming/SavePasswordProtectedXlsx.java6
-rw-r--r--poi-examples/src/main/java/org/apache/poi/examples/xssf/usermodel/LoadPasswordProtectedXlsx.java6
-rw-r--r--poi-excelant/build.gradle57
-rw-r--r--poi-excelant/src/main/java/org/apache/poi/ss/excelant/ExcelAntHandlerTask.java4
-rw-r--r--poi-excelant/src/main/java/org/apache/poi/ss/excelant/util/ExcelAntWorkbookUtil.java37
-rw-r--r--poi-integration/build.gradle33
-rw-r--r--poi-ooxml-full/build.gradle29
-rw-r--r--poi-ooxml-lite/build.gradle4
-rw-r--r--poi-ooxml/build.gradle54
-rw-r--r--poi-ooxml/src/main/java/org/apache/poi/ooxml/POIXMLDocumentPart.java31
-rw-r--r--poi-ooxml/src/main/java/org/apache/poi/poifs/crypt/dsig/facets/SignatureFacet.java2
-rw-r--r--poi-ooxml/src/main/java/org/apache/poi/poifs/crypt/dsig/services/RevocationData.java18
-rw-r--r--poi-ooxml/src/main/java/org/apache/poi/poifs/crypt/dsig/services/TimeStampServiceValidator.java1
-rw-r--r--poi-ooxml/src/main/java/org/apache/poi/xddf/usermodel/chart/XDDFChart.java34
-rw-r--r--poi-ooxml/src/main/java/org/apache/poi/xddf/usermodel/chart/XDDFChartData.java30
-rw-r--r--poi-ooxml/src/main/java/org/apache/poi/xddf/usermodel/text/XDDFTextRun.java21
-rw-r--r--poi-ooxml/src/main/java/org/apache/poi/xdgf/usermodel/section/CombinedIterable.java17
-rw-r--r--poi-ooxml/src/main/java/org/apache/poi/xslf/usermodel/XSLFShape.java2
-rw-r--r--poi-ooxml/src/main/java/org/apache/poi/xssf/model/ThemesTable.java27
-rw-r--r--poi-ooxml/src/main/java/org/apache/poi/xssf/streaming/SXSSFEvaluationSheet.java1
-rw-r--r--poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/BaseXSSFFormulaEvaluator.java6
-rw-r--r--poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/DefaultIndexedColorMap.java5
-rw-r--r--poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFBuiltinTableStyle.java34
-rw-r--r--poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFCell.java70
-rw-r--r--poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFChart.java26
-rw-r--r--poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFClientAnchor.java26
-rw-r--r--poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFConditionalFormattingRule.java65
-rw-r--r--poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFConnector.java3
-rw-r--r--poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFDataValidationConstraint.java18
-rw-r--r--poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFDxfStyleProvider.java7
-rw-r--r--poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFEvaluationSheet.java19
-rw-r--r--poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFEvenFooter.java21
-rw-r--r--poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFEvenHeader.java7
-rw-r--r--poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFFirstFooter.java15
-rw-r--r--poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFFirstHeader.java19
-rw-r--r--poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFFont.java28
-rw-r--r--poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFFormulaEvaluator.java1
-rw-r--r--poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFGraphicFrame.java7
-rw-r--r--poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFHeaderFooterProperties.java36
-rw-r--r--poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFLineBreak.java1
-rw-r--r--poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFOddFooter.java9
-rw-r--r--poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFOddHeader.java11
-rw-r--r--poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFPicture.java20
-rw-r--r--poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFShape.java2
-rw-r--r--poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFTable.java34
-rw-r--r--poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFTableStyle.java6
-rw-r--r--poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFTableStyleInfo.java12
-rw-r--r--poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFTextRun.java7
-rw-r--r--poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFVBAPart.java5
-rw-r--r--poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/extensions/XSSFHeaderFooter.java10
-rw-r--r--poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/helpers/XSSFFormulaUtils.java7
-rw-r--r--poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/IBody.java37
-rw-r--r--poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/ISDTContent.java11
-rw-r--r--poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFChart.java33
-rw-r--r--poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFComments.java17
-rw-r--r--poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFFooter.java3
-rw-r--r--poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFHeader.java5
-rw-r--r--poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFNumbering.java17
-rw-r--r--poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFPicture.java8
-rw-r--r--poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFSDTContent.java8
-rw-r--r--poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFStyle.java21
-rw-r--r--poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFTable.java19
-rw-r--r--poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFTableCell.java35
-rw-r--r--poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFTableRow.java12
-rw-r--r--poi-ooxml/src/test/java/org/apache/poi/xdgf/usermodel/section/TestCombinedIterator.java29
-rw-r--r--poi-scratchpad/build.gradle56
-rw-r--r--poi-scratchpad/src/main/java/org/apache/poi/hslf/extractor/QuickButCruddyTextExtractor.java9
-rw-r--r--poi-scratchpad/src/main/java/org/apache/poi/hslf/model/ActiveXShape.java15
-rw-r--r--poi-scratchpad/src/main/java/org/apache/poi/hslf/model/Polygon.java19
-rw-r--r--poi-scratchpad/src/main/java/org/apache/poi/hslf/model/textproperties/BitMaskTextProp.java9
-rw-r--r--poi-scratchpad/src/main/java/org/apache/poi/hslf/record/SlideListWithText.java9
-rw-r--r--poi-scratchpad/src/main/java/org/apache/poi/hslf/usermodel/HSLFBackground.java1
-rw-r--r--poi-scratchpad/src/main/java/org/apache/poi/hslf/usermodel/HSLFComment.java8
-rw-r--r--poi-scratchpad/src/main/java/org/apache/poi/hslf/usermodel/HSLFShape.java72
-rw-r--r--poi-scratchpad/src/main/java/org/apache/poi/hslf/usermodel/HSLFTextParagraph.java43
-rw-r--r--poi-scratchpad/src/main/java/org/apache/poi/hwmf/draw/HwmfDrawProperties.java2
-rw-r--r--poi-scratchpad/src/main/java/org/apache/poi/hwmf/record/HwmfEscape.java1
-rw-r--r--poi-scratchpad/src/main/java/org/apache/poi/hwmf/record/HwmfFill.java2
-rw-r--r--poi-scratchpad/src/main/java/org/apache/poi/hwmf/record/HwmfRecord.java5
-rw-r--r--poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/CharIndexTranslator.java3
-rw-r--r--poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/FileInformationBlock.java10
-rw-r--r--poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/OldCHPBinTable.java8
-rw-r--r--poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/OldTextPiece.java5
-rw-r--r--poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/OldTextPieceTable.java2
-rw-r--r--poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/PlexOfCps.java16
-rw-r--r--poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/PlfLfo.java2
-rw-r--r--poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/TextPiece.java5
-rw-r--r--poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/TextPieceTable.java16
-rw-r--r--poi-scratchpad/src/main/java/org/apache/poi/hwpf/usermodel/HeaderStories.java41
-rw-r--r--poi-scratchpad/src/main/java/org/apache/poi/hwpf/usermodel/Picture.java184
-rw-r--r--poi-scratchpad/src/main/java/org/apache/poi/hwpf/util/DoubleByteUtil.java3
-rw-r--r--poi-scratchpad/src/test/java/org/apache/poi/hwpf/converter/TestWordToHtmlConverter.java2
-rw-r--r--poi/build.gradle69
-rw-r--r--poi/src/main/java/org/apache/poi/ddf/EscherRecordTypes.java6
-rw-r--r--poi/src/main/java/org/apache/poi/ddf/EscherShapePathProperty.java3
-rw-r--r--poi/src/main/java/org/apache/poi/extractor/ExtractorFactory.java1
-rw-r--r--poi/src/main/java/org/apache/poi/hssf/record/ProtectionRev4Record.java5
-rw-r--r--poi/src/main/java/org/apache/poi/hssf/record/RKRecord.java4
-rw-r--r--poi/src/main/java/org/apache/poi/hssf/record/WriteAccessRecord.java5
-rw-r--r--poi/src/main/java/org/apache/poi/hssf/record/aggregates/MergedCellsTable.java5
-rw-r--r--poi/src/main/java/org/apache/poi/hssf/record/chart/TickRecord.java5
-rw-r--r--poi/src/main/java/org/apache/poi/hssf/record/common/UnicodeString.java3
-rw-r--r--poi/src/main/java/org/apache/poi/hssf/usermodel/EscherGraphics.java37
-rw-r--r--poi/src/main/java/org/apache/poi/hssf/usermodel/EscherGraphics2d.java90
-rw-r--r--poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFCell.java50
-rw-r--r--poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFChildAnchor.java3
-rw-r--r--poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFComment.java10
-rw-r--r--poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFEvaluationSheet.java5
-rw-r--r--poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFFont.java41
-rw-r--r--poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFFormulaEvaluator.java17
-rw-r--r--poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFHyperlink.java4
-rw-r--r--poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFPatternFormatting.java15
-rw-r--r--poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFPictureData.java20
-rw-r--r--poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFRichTextString.java18
-rw-r--r--poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFShapeContainer.java13
-rw-r--r--poi/src/main/java/org/apache/poi/poifs/crypt/ChunkedCipherOutputStream.java63
-rw-r--r--poi/src/main/java/org/apache/poi/poifs/crypt/EncryptionHeader.java21
-rw-r--r--poi/src/main/java/org/apache/poi/poifs/crypt/package-info.java2
-rw-r--r--poi/src/main/java/org/apache/poi/poifs/filesystem/DirectoryEntry.java40
-rw-r--r--poi/src/main/java/org/apache/poi/poifs/filesystem/DirectoryNode.java24
-rw-r--r--poi/src/main/java/org/apache/poi/poifs/filesystem/FilteringDirectoryNode.java29
-rw-r--r--poi/src/main/java/org/apache/poi/sl/usermodel/Sheet.java6
-rw-r--r--poi/src/main/java/org/apache/poi/ss/format/SimpleFraction.java7
-rw-r--r--poi/src/main/java/org/apache/poi/ss/formula/BaseFormulaEvaluator.java8
-rw-r--r--poi/src/main/java/org/apache/poi/ss/formula/CacheAreaEval.java35
-rw-r--r--poi/src/main/java/org/apache/poi/ss/formula/ConditionalFormattingEvaluator.java78
-rw-r--r--poi/src/main/java/org/apache/poi/ss/formula/EvaluationConditionalFormatRule.java373
-rw-r--r--poi/src/main/java/org/apache/poi/ss/formula/EvaluationSheet.java9
-rw-r--r--poi/src/main/java/org/apache/poi/ss/formula/FormulaType.java25
-rw-r--r--poi/src/main/java/org/apache/poi/ss/formula/LazyAreaEval.java20
-rw-r--r--poi/src/main/java/org/apache/poi/ss/formula/OperatorEnum.java198
-rw-r--r--poi/src/main/java/org/apache/poi/ss/formula/SharedFormula.java5
-rw-r--r--poi/src/main/java/org/apache/poi/ss/formula/TwoDEval.java16
-rw-r--r--poi/src/main/java/org/apache/poi/ss/formula/constant/ConstantValueParser.java10
-rw-r--r--poi/src/main/java/org/apache/poi/ss/formula/eval/AreaEval.java12
-rw-r--r--poi/src/main/java/org/apache/poi/ss/formula/eval/AreaEvalBase.java31
-rw-r--r--poi/src/main/java/org/apache/poi/ss/formula/eval/PercentEval.java3
-rw-r--r--poi/src/main/java/org/apache/poi/ss/formula/eval/forked/ForkedEvaluationSheet.java16
-rw-r--r--poi/src/main/java/org/apache/poi/ss/formula/functions/Bin2Dec.java4
-rw-r--r--poi/src/main/java/org/apache/poi/ss/formula/functions/Code.java3
-rw-r--r--poi/src/main/java/org/apache/poi/ss/formula/functions/Complex.java8
-rw-r--r--poi/src/main/java/org/apache/poi/ss/formula/functions/DateValue.java2
-rw-r--r--poi/src/main/java/org/apache/poi/ss/formula/functions/Delta.java4
-rw-r--r--poi/src/main/java/org/apache/poi/ss/formula/functions/EOMonth.java6
-rw-r--r--poi/src/main/java/org/apache/poi/ss/formula/functions/FactDouble.java4
-rw-r--r--poi/src/main/java/org/apache/poi/ss/formula/functions/Frequency.java5
-rw-r--r--poi/src/main/java/org/apache/poi/ss/formula/functions/Hex2Dec.java4
-rw-r--r--poi/src/main/java/org/apache/poi/ss/formula/functions/ImReal.java43
-rw-r--r--poi/src/main/java/org/apache/poi/ss/formula/functions/Imaginary.java4
-rw-r--r--poi/src/main/java/org/apache/poi/ss/formula/functions/Intercept.java3
-rw-r--r--poi/src/main/java/org/apache/poi/ss/formula/functions/Oct2Dec.java4
-rw-r--r--poi/src/main/java/org/apache/poi/ss/formula/functions/Quotient.java9
-rw-r--r--poi/src/main/java/org/apache/poi/ss/formula/functions/Rept.java5
-rw-r--r--poi/src/main/java/org/apache/poi/ss/formula/functions/Roman.java4
-rw-r--r--poi/src/main/java/org/apache/poi/ss/formula/functions/Slope.java3
-rw-r--r--poi/src/main/java/org/apache/poi/ss/formula/functions/WeekNum.java5
-rw-r--r--poi/src/main/java/org/apache/poi/ss/usermodel/BuiltinFormats.java13
-rw-r--r--poi/src/main/java/org/apache/poi/ss/usermodel/Comment.java21
-rw-r--r--poi/src/main/java/org/apache/poi/ss/usermodel/ExcelNumberFormat.java19
-rw-r--r--poi/src/main/java/org/apache/poi/ss/usermodel/Table.java5
-rw-r--r--poi/src/main/java/org/apache/poi/ss/usermodel/TableStyle.java12
-rw-r--r--poi/src/main/java/org/apache/poi/ss/usermodel/TableStyleType.java52
-rw-r--r--poi/src/main/java/org/apache/poi/ss/util/CellRangeAddress.java2
-rw-r--r--poi/src/main/java/org/apache/poi/ss/util/CellRangeAddressBase.java7
-rw-r--r--poi/src/main/java/org/apache/poi/ss/util/PropertyTemplate.java84
-rw-r--r--poi/src/main/java/org/apache/poi/ss/util/SheetBuilder.java5
-rw-r--r--poi/src/main/java/org/apache/poi/util/DocumentFormatException.java5
-rw-r--r--poi/src/main/java/org/apache/poi/util/GenericRecordUtil.java2
-rw-r--r--poi/src/main/java/org/apache/poi/util/LocaleID.java2
-rw-r--r--poi/src/main/java/org/apache/poi/util/LocaleUtil.java9
-rw-r--r--poi/src/test/resources/log4j2-test.xml4
175 files changed, 1705 insertions, 2018 deletions
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 = '<![CDATA[<i>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;
/**
- * <p>This class copies a POI file system to a new file and compares the copy
- * with the original.</p>
+ * This class copies a POI file system to a new file and compares the copy
+ * with the original.
* <p>
- * <p>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.</p>
+ * bit.
* <p>
- * <p>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.</p>
+ * 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.
- * <p><ul>
+ * <ul>
* <li>The example demonstrates that all temp files are removed.
- * <li><code>AesZipFileZipEntrySource</code> is used to ensure that temp files are encrypted.
- * </ul><p>
+ * <li>{@code AesZipFileZipEntrySource} is used to ensure that temp files are encrypted.
+ * </ul>
*/
@SuppressWarnings({"java:S106","java:S4823","java:S1192"})
public final class LoadPasswordProtectedXlsxStreaming {
diff --git a/poi-examples/src/main/java/org/apache/poi/examples/xssf/streaming/SavePasswordProtectedXlsx.java b/poi-examples/src/main/java/org/apache/poi/examples/xssf/streaming/SavePasswordProtectedXlsx.java
index f991047db7..df5b7004cf 100644
--- a/poi-examples/src/main/java/org/apache/poi/examples/xssf/streaming/SavePasswordProtectedXlsx.java
+++ b/poi-examples/src/main/java/org/apache/poi/examples/xssf/streaming/SavePasswordProtectedXlsx.java
@@ -41,10 +41,10 @@ import org.apache.poi.xssf.streaming.SXSSFSheet;
/**
* An example that outputs a simple generated workbook that is password protected.
* The example highlights how to do this in streaming way.
- * <p><ul>
+ * <ul>
* <li>The example demonstrates that all temp files are removed.
- * <li><code>SXSSFWorkbookWithCustomZipEntrySource</code> extends SXSSFWorkbook to ensure temp files are encrypted.
- * </ul><p>
+ * <li>{@code SXSSFWorkbookWithCustomZipEntrySource} extends SXSSFWorkbook to ensure temp files are encrypted.
+ * </ul>
*/
@SuppressWarnings({"java:S106","java:S4823","java:S1192"})
public final class SavePasswordProtectedXlsx {
diff --git a/poi-examples/src/main/java/org/apache/poi/examples/xssf/usermodel/LoadPasswordProtectedXlsx.java b/poi-examples/src/main/java/org/apache/poi/examples/xssf/usermodel/LoadPasswordProtectedXlsx.java
index 1ca5c34307..e3b93f8595 100644
--- a/poi-examples/src/main/java/org/apache/poi/examples/xssf/usermodel/LoadPasswordProtectedXlsx.java
+++ b/poi-examples/src/main/java/org/apache/poi/examples/xssf/usermodel/LoadPasswordProtectedXlsx.java
@@ -32,10 +32,10 @@ import org.apache.poi.xssf.usermodel.XSSFWorkbook;
/**
* An example that loads a password protected workbook and counts the sheets.
- * <p><ul>
+ * <ul>
* <li>The example demonstrates that all temp files are removed.
- * <li><code>AesZipFileZipEntrySource</code> is used to ensure that temp files are encrypted.
- * </ul></p>
+ * <li>{@code AesZipFileZipEntrySource} is used to ensure that temp files are encrypted.
+ * </ul>
*/
@SuppressWarnings({"java:S106","java:S4823","java:S1192"})
public final class LoadPasswordProtectedXlsx {
diff --git a/poi-excelant/build.gradle b/poi-excelant/build.gradle
index 7d31dc74bc..2a6cb1403e 100644
--- a/poi-excelant/build.gradle
+++ b/poi-excelant/build.gradle
@@ -47,6 +47,7 @@ dependencies {
testImplementation project(path: ':poi-ooxml', configuration: 'tests')
testImplementation project(path: ':poi-scratchpad', configuration: 'tests')
testImplementation 'com.google.guava:guava:30.0-jre'
+ testImplementation 'org.apache.logging.log4j:log4j-slf4j-impl:2.14.1'
}
final String MODULE_NAME = 'org.apache.poi.excelant'
@@ -60,13 +61,6 @@ final String OOXML_LITE_REPORT = '../build/ooxml-lite-report'
final String OOXML_LITE_JAR = "../build/dist/maven/poi-ooxml-lite/poi-ooxml-lite-${project.version}.jar"
final String OOXML_LITE_INCLUDES = "^(com/microsoft/schemas|org/(etsi|openxmlformats|w3/)|org/apache/poi/schemas)"
-java {
- sourceCompatibility = JavaVersion.VERSION_1_8
- targetCompatibility = JavaVersion.VERSION_1_8
- withJavadocJar()
- withSourcesJar()
-}
-
task compileJava9(type: JavaCompile) {
dependsOn 'compileJava', ':poi-ooxml:jar', ':poi-scratchpad:jar'
@@ -146,18 +140,6 @@ task testJar(type: Jar, dependsOn: testClasses) {
}
}
-sourcesJar {
- destinationDirectory = file("../build/dist/maven/${project.archivesBaseName}")
-}
-
-javadoc {
-// fails currently, need to fix the sources
- failOnError = false
-// if(JavaVersion.current().isJava9Compatible()) {
-// options.addBooleanOption('html5', true)
-// }
-}
-
artifacts {
tests testJar
}
@@ -165,40 +147,13 @@ 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',
+ jvmArgs += [
"-javaagent:${OOXML_LITE_AGENT}=${OOXML_LITE_REPORT}|${OOXML_LITE_INCLUDES}",
- '-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-excelant-tests:' + files(TEST_MODULE_PATH).asPath,
]
}
@@ -208,16 +163,10 @@ test {
publishing {
publications {
POI(MavenPublication) {
- artifactId project.archivesBaseName
-
- from components.java
-
pom {
- name = 'Apache POI - API based on OPC and OOXML schemas'
+ name = 'Apache POI - ExcelAnt'
description = 'Apache POI - Java API To Access Microsoft Format Files'
}
}
}
}
-
-generatePomFileForPOIPublication.destination = "../build/dist/maven/${project.archivesBaseName}/${project.archivesBaseName}-${project.version}.pom"
diff --git a/poi-excelant/src/main/java/org/apache/poi/ss/excelant/ExcelAntHandlerTask.java b/poi-excelant/src/main/java/org/apache/poi/ss/excelant/ExcelAntHandlerTask.java
index 23c2583da8..b2f9266d76 100644
--- a/poi-excelant/src/main/java/org/apache/poi/ss/excelant/ExcelAntHandlerTask.java
+++ b/poi-excelant/src/main/java/org/apache/poi/ss/excelant/ExcelAntHandlerTask.java
@@ -23,7 +23,7 @@ import org.apache.tools.ant.Project;
import org.apache.tools.ant.Task;
/**
- * This is the class that backs the <handler> tag in the Ant task.
+ * This is the class that backs the {@code <handler>} tag in the Ant task.
* <p>
* 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.
* <p>
* In order to use this tag you must write a class that implements the
- * <code>IExcelAntWorkbookHandler</code> 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 List<String> getSheets() {
ArrayList<String> sheets = new ArrayList<>();
@@ -224,9 +218,6 @@ public class ExcelAntWorkbookUtil extends Typedef {
/**
* This method uses a String in standard Excel format (SheetName!CellId) to
* locate the cell and set it to the value of the double in value.
- *
- * @param cellName
- * @param value
*/
public void setDoubleValue(String cellName, double value) {
log("starting setCellValue()", Project.MSG_DEBUG);
@@ -240,9 +231,6 @@ public class ExcelAntWorkbookUtil extends Typedef {
/**
* Utility method for setting the value of a Cell with a String.
- *
- * @param cellName
- * @param value
*/
public void setStringValue(String cellName, String value) {
Cell cell = getCell(cellName);
@@ -251,9 +239,6 @@ public class ExcelAntWorkbookUtil extends Typedef {
/**
* Utility method for setting the value of a Cell with a Formula.
- *
- * @param cellName
- * @param formula
*/
public void setFormulaValue(String cellName, String formula) {
Cell cell = getCell(cellName);
@@ -262,8 +247,6 @@ public class ExcelAntWorkbookUtil extends Typedef {
/**
* Utility method for setting the value of a Cell with a Date.
- * @param cellName
- * @param date
*/
public void setDateValue(String cellName, Date date) {
Cell cell = getCell(cellName);
@@ -272,15 +255,11 @@ public class ExcelAntWorkbookUtil extends Typedef {
/**
* Uses a String in standard Excel format (SheetName!CellId) to locate a
* cell and evaluate it.
- *
- * @param cellName
- * @param expectedValue
- * @param precision
*/
public ExcelAntEvaluationResult evaluateCell(String cellName, double expectedValue,
double precision) {
- ExcelAntEvaluationResult evalResults = null;
+ ExcelAntEvaluationResult evalResults;
Cell cell = getCell(cellName);
@@ -304,12 +283,11 @@ public class ExcelAntWorkbookUtil extends Typedef {
"Evaluation passed without error within in range.", delta, cellName);
}
} else {
- String errorMeaning = null;
+ String errorMeaning;
try {
errorMeaning = FormulaError.forInt(resultOfEval.getErrorValue()).getString();
} catch(IllegalArgumentException iae) {
- errorMeaning = "unknown error code: " +
- Byte.toString(resultOfEval.getErrorValue());
+ errorMeaning = "unknown error code: " + resultOfEval.getErrorValue();
}
evalResults = new ExcelAntEvaluationResult(true, false,
@@ -325,9 +303,6 @@ public class ExcelAntWorkbookUtil extends Typedef {
/**
* Returns a Cell as a String value.
- *
- * @param cellName
- * @return
*/
public String getCellAsString(String cellName) {
Cell cell = getCell(cellName);
@@ -337,9 +312,6 @@ public class ExcelAntWorkbookUtil extends Typedef {
/**
* Returns the value of the Cell as a double.
- *
- * @param cellName
- * @return
*/
public double getCellAsDouble(String cellName) {
Cell cell = getCell(cellName);
@@ -349,9 +321,6 @@ public class ExcelAntWorkbookUtil extends Typedef {
* Returns a cell reference based on a String in standard Excel format
* (SheetName!CellId). This method will create a new cell if the
* requested cell isn't initialized yet.
- *
- * @param cellName
- * @return
*/
private Cell getCell(String cellName) {
CellReference cellRef = new CellReference(cellName);
diff --git a/poi-integration/build.gradle b/poi-integration/build.gradle
index 0cf8087976..22114ba9b4 100644
--- a/poi-integration/build.gradle
+++ b/poi-integration/build.gradle
@@ -46,6 +46,7 @@ dependencies {
testImplementation project(path:':poi-ooxml', configuration:'tests')
testImplementation project(path:':poi-scratchpad', configuration:'tests')
testImplementation project(path: ':poi-ooxml-lite-agent', configuration: 'archives')
+ testImplementation 'org.apache.logging.log4j:log4j-slf4j-impl:2.14.1'
}
final String MODULE_NAME = 'org.apache.poi.stress'
@@ -125,45 +126,15 @@ 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',
+ jvmArgs += [
"-javaagent:${OOXML_LITE_AGENT}=${OOXML_LITE_REPORT}|${OOXML_LITE_INCLUDES}",
-
- '-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-integration-tests:' + files(TEST_MODULE_PATH).asPath,
]
}
}
}
-
-generatePomFileForPOIPublication.destination = "../build/dist/maven/${project.archivesBaseName}/${project.archivesBaseName}-${project.version}.pom"
diff --git a/poi-ooxml-full/build.gradle b/poi-ooxml-full/build.gradle
index ea1804a30b..f922a706f1 100644
--- a/poi-ooxml-full/build.gradle
+++ b/poi-ooxml-full/build.gradle
@@ -54,8 +54,6 @@ final List MAIN_MODULE_PATH = sourceSets.main.runtimeClasspath.findAll{ it.path
compileJava {
dependsOn 'generate_beans'
- sourceCompatibility = 8
- targetCompatibility = 8
}
task compileJava9(type: JavaCompile) {
@@ -133,26 +131,6 @@ task generate_beans(dependsOn: copy_xsds) {
}
}
-tasks.withType(Jar) {
- destinationDirectory = file("../build/dist/maven/${project.archivesBaseName}")
-}
-
-javadoc {
- failOnError = true
- maxMemory = "1024M"
- doFirst {
- options {
- if (JavaVersion.current().isJava9Compatible()) {
- addBooleanOption('html5', true)
- }
- links 'https://xmlbeans.apache.org/docs/5.0.0/'
- use = true
- splitIndex = true
- source = "1.8"
- }
- }
-}
-
task sourceJar(type: Jar) {
classifier 'sources'
from sourceSets.main.allJava
@@ -175,11 +153,6 @@ jar {
publishing {
publications {
POI(MavenPublication) {
- artifactId "${project.archivesBaseName}"
-
- from components.java
- artifact tasks.sourceJar
-
pom {
name = 'Apache POI - OOXML schemas (full)'
description =
@@ -189,5 +162,3 @@ publishing {
}
}
}
-
-generatePomFileForPOIPublication.destination = "../build/dist/maven/${project.archivesBaseName}/${project.archivesBaseName}-${project.version}.pom"
diff --git a/poi-ooxml-lite/build.gradle b/poi-ooxml-lite/build.gradle
index 485f572c62..a5245419d6 100644
--- a/poi-ooxml-lite/build.gradle
+++ b/poi-ooxml-lite/build.gradle
@@ -1,6 +1,4 @@
-import java.util.function.Function
import java.util.regex.Pattern
-import java.util.stream.Collectors
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
@@ -89,7 +87,9 @@ java {
targetCompatibility = JavaVersion.VERSION_1_8
}
+processResources.dependsOn 'compileOoxmlLite'
compileJava.dependsOn 'compileOoxmlLite'
+sourcesJar.dependsOn 'compileOoxmlLite'
task compileJava9(type: JavaCompile, dependsOn: 'compileJava') {
sourceCompatibility = 9
diff --git a/poi-ooxml/build.gradle b/poi-ooxml/build.gradle
index fcc8d79470..0450e9464a 100644
--- a/poi-ooxml/build.gradle
+++ b/poi-ooxml/build.gradle
@@ -73,6 +73,11 @@ dependencies {
testImplementation 'org.openjdk.jmh:jmh-generator-annprocess:1.26'
testImplementation 'com.google.guava:guava:30.0-jre'
+ // prevent slf4j warnings coming from xmlsec -> slf4j-api 1.7.30 dependency
+ // see https://logging.apache.org/log4j/2.x/log4j-slf4j-impl/
+ testImplementation 'org.apache.logging.log4j:log4j-slf4j-impl:2.14.1'
+
+
broken "org.apache.xmlgraphics:batik-script:${batikVersion}"
javadocs project(':poi')
@@ -89,14 +94,6 @@ final String OOXML_LITE_AGENT = "../build/dist/maven/poi-ooxml-lite-agent/poi-oo
final String OOXML_LITE_REPORT = '../build/ooxml-lite-report'
final String OOXML_LITE_INCLUDES = "^(com/microsoft/schemas|org/(etsi|openxmlformats|w3/)|org/apache/poi/schemas)"
-java {
- sourceCompatibility = JavaVersion.VERSION_1_8
- targetCompatibility = JavaVersion.VERSION_1_8
- withJavadocJar()
- withSourcesJar()
-}
-
-
compileJava {
dependsOn 'fixBatik'
}
@@ -180,11 +177,6 @@ task testJar(type: Jar, dependsOn: testClasses) {
}
}
-sourcesJar {
- destinationDirectory = file("../build/dist/maven/${project.archivesBaseName}")
- exclude 'META-INF/services/**'
-}
-
// based on https://github.com/moditect/moditect-gradle-plugin/issues/12
task fixBatik(type: Zip) {
ant.mkdir(dir: "${buildDir}/brokenJars")
@@ -223,41 +215,13 @@ 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',
+ jvmArgs += [
"-javaagent:${OOXML_LITE_AGENT}=${OOXML_LITE_REPORT}|${OOXML_LITE_INCLUDES}",
-
- '-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-ooxml-tests:' + files(TEST_MODULE_PATH).asPath,
]
}
@@ -267,10 +231,6 @@ test {
publishing {
publications {
POI(MavenPublication) {
- artifactId project.archivesBaseName
-
- from components.java
-
pom {
name = 'Apache POI - API based on OPC and OOXML schemas'
description = 'Apache POI - Java API To Access Microsoft Format Files'
@@ -278,5 +238,3 @@ publishing {
}
}
}
-
-generatePomFileForPOIPublication.destination = "../build/dist/maven/${project.archivesBaseName}/${project.archivesBaseName}-${project.version}.pom"
diff --git a/poi-ooxml/src/main/java/org/apache/poi/ooxml/POIXMLDocumentPart.java b/poi-ooxml/src/main/java/org/apache/poi/ooxml/POIXMLDocumentPart.java
index 4696e71de9..7de36c588a 100644
--- a/poi-ooxml/src/main/java/org/apache/poi/ooxml/POIXMLDocumentPart.java
+++ b/poi-ooxml/src/main/java/org/apache/poi/ooxml/POIXMLDocumentPart.java
@@ -196,6 +196,7 @@ public class POIXMLDocumentPart {
* @throws IllegalStateException if there are more than one core document relations
*/
protected final void rebase(OPCPackage pkg) throws InvalidFormatException {
+ // TODO: check why pkg parameter is not used ???
PackageRelationshipCollection cores =
packagePart.getRelationshipsByType(coreDocumentRel);
if (cores.size() != 1) {
@@ -240,10 +241,10 @@ public class POIXMLDocumentPart {
}
/**
- * Returns the target {@link POIXMLDocumentPart}, where a
+ * Returns the target POIXMLDocumentPart, where a
* {@link PackageRelationship} is set from the {@link PackagePart} of this
- * {@link POIXMLDocumentPart} to the {@link PackagePart} of the target
- * {@link POIXMLDocumentPart} with a {@link PackageRelationship#getId()}
+ * POIXMLDocumentPart to the {@link PackagePart} of the target
+ * POIXMLDocumentPart with a {@link PackageRelationship#getId()}
* matching the given parameter value.
*
* @param id The relation id to look for
@@ -257,8 +258,8 @@ public class POIXMLDocumentPart {
/**
* Returns the target {@link RelationPart}, where a
* {@link PackageRelationship} is set from the {@link PackagePart} of this
- * {@link POIXMLDocumentPart} to the {@link PackagePart} of the target
- * {@link POIXMLDocumentPart} with a {@link PackageRelationship#getId()}
+ * POIXMLDocumentPart to the {@link PackagePart} of the target
+ * POIXMLDocumentPart with a {@link PackageRelationship#getId()}
* matching the given parameter value.
*
* @param id The relation id to look for
@@ -272,13 +273,13 @@ public class POIXMLDocumentPart {
/**
* Returns the first {@link PackageRelationship#getId()} of the
* {@link PackageRelationship}, that sources from the {@link PackagePart} of
- * this {@link POIXMLDocumentPart} to the {@link PackagePart} of the given
- * parameter value.<p>
+ * this POIXMLDocumentPart to the {@link PackagePart} of the given
+ * parameter value.
* <p>
- * 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.<p>
+ * part, if it is no longer needed.
* <p>
* 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.<p>
+ * part, if it is no longer needed and flag is set to true.
* <p>
* 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.<p>
+ * part, if it is no longer needed.
* <p>
* 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 <code>null</code> 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!
- * <p>
- * 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 <code>true</code> if this revocation data set holds OCSP
+ * Returns {@code true} if this revocation data set holds OCSP
* responses.
*
- * @return <code>true</code> 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 <code>true</code> if this revocation data set holds CRLs.
+ * Returns {@code true} if this revocation data set holds CRLs.
*
- * @return <code>true</code> 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 <code>true</code> if this revocation data is not empty.
+ * Returns {@code true} if this revocation data is not empty.
*
- * @return <code>true</code> 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
- * <code>application/vnd.openxmlformats-officedocument.drawingml.chart+xml</code>
+ * {@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 <code>getSeries().add(series)</code> or to <code>getSeries().remove(series)</code>
+ * Calls to {@code getSeries().add(series)} or to {@code getSeries().remove(series)}
* may corrupt the workbook.
*
* <p>
@@ -94,9 +95,9 @@ public abstract class XDDFChartData {
* </ul>
*
* @deprecated since POI 4.1.1
- * @return
*/
@Deprecated
+ @Removal(version = "5.3")
public List<Series> getSeries() {
return Collections.unmodifiableList(series);
}
@@ -119,18 +120,15 @@ public abstract class XDDFChartData {
}
/**
- * This method should be implemented in every class that extends <code>XDDFChartData</code>.
+ * This method should be implemented in every class that extends {@code XDDFChartData}.
* <p>
* A typical implementation would be
*
- * <pre><code>
- protected void removeCTSeries(int n) {
- chart.removeSer(n);
- }
-
- * </code></pre>
- *
- * @param n
+ * <pre>{@code
+ * protected void removeCTSeries(int n) {
+ * chart.removeSer(n);
+ * }
+ * }</pre>
*/
@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 <code>index</code> 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 <code>index</code> 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 <code>index</code>.
+ * 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 {
* <p>
* The size is specified using a percentage.
* Positive values indicate superscript, negative values indicate subscript.
- * </p>
- *
- * @param offset
*/
public void setBaseline(Double offset) {
if (offset == null) {
@@ -336,9 +333,6 @@ public class XDDFTextRun {
* Set whether the text in this run is formatted as superscript.
* <p>
* The size is specified using a percentage.
- * </p>
- *
- * @param offset
*/
public void setSuperscript(Double offset) {
setBaseline(offset == null ? null : Math.abs(offset));
@@ -348,9 +342,6 @@ public class XDDFTextRun {
* Set whether the text in this run is formatted as subscript.
* <p>
* The size is specified using a percentage.
- * </p>
- *
- * @param offset
*/
public void setSubscript(Double offset) {
setBaseline(offset == null ? null : -Math.abs(offset));
@@ -407,7 +398,7 @@ public class XDDFTextRun {
/**
* @param size
- * font size in points. The value <code>null</code> unsets the
+ * font size in points. The value {@code null} unsets the
* size for this run.
* <dl>
* <dt>Minimum inclusive =</dt>
@@ -432,7 +423,7 @@ public class XDDFTextRun {
/**
* Set the kerning of characters within a text run.
* <p>
- * The value <code>null</code> unsets the kerning for this run.
+ * The value {@code null} unsets the kerning for this run.
* </p>
*
* @param kerning
@@ -451,7 +442,7 @@ public class XDDFTextRun {
/**
*
* @return the kerning of characters within a text run,
- * If this attribute is omitted then returns <code>null</code>.
+ * 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.
* </p>
* <p>
- * The value <code>null</code> unsets the spacing for this run.
+ * The value {@code null} unsets the spacing for this run.
* </p>
*
* @param spacing
@@ -487,7 +478,7 @@ public class XDDFTextRun {
/**
*
* @return the spacing between characters within a text run,
- * If this attribute is omitted then returns <code>null</code>.
+ * 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 <T>
*/
public class CombinedIterable<T> implements Iterable<T> {
@@ -43,14 +40,8 @@ public class CombinedIterable<T> implements Iterable<T> {
@Override
public Iterator<T> iterator() {
- final Iterator<Entry<Long, T>> vmasterI;
-
- if (_masterItems != null) {
- vmasterI = _masterItems.entrySet().iterator();
- } else {
- final Set<Entry<Long, T>> empty = Collections.emptySet();
- vmasterI = empty.iterator();
- }
+ final Iterator<Entry<Long, T>> vmasterI = (_masterItems == null)
+ ? Collections.emptyIterator() : _masterItems.entrySet().iterator();
return new Iterator<T>() {
@@ -60,8 +51,8 @@ public class CombinedIterable<T> implements Iterable<T> {
Entry<Long, T> currentMaster;
// grab the iterator for both
- Iterator<Entry<Long, T>> baseI = _baseItems.entrySet().iterator();
- Iterator<Entry<Long, T>> masterI = vmasterI;
+ final Iterator<Entry<Long, T>> baseI = _baseItems.entrySet().iterator();
+ final Iterator<Entry<Long, T>> masterI = vmasterI;
@Override
public boolean hasNext() {
diff --git a/poi-ooxml/src/main/java/org/apache/poi/xslf/usermodel/XSLFShape.java b/poi-ooxml/src/main/java/org/apache/poi/xslf/usermodel/XSLFShape.java
index ba546e8f16..0fccb9e8ad 100644
--- a/poi-ooxml/src/main/java/org/apache/poi/xslf/usermodel/XSLFShape.java
+++ b/poi-ooxml/src/main/java/org/apache/poi/xslf/usermodel/XSLFShape.java
@@ -315,7 +315,7 @@ public abstract class XSLFShape implements Shape<XSLFShape,XSLFTextParagraph> {
/**
* Walk up the inheritance tree and fetch shape properties.<p>
*
- * The following order of inheritance is assumed:<p>
+ * The following order of inheritance is assumed:
* <ol>
* <li>slide
* <li>slideLayout
diff --git a/poi-ooxml/src/main/java/org/apache/poi/xssf/model/ThemesTable.java b/poi-ooxml/src/main/java/org/apache/poi/xssf/model/ThemesTable.java
index 0e68bceacf..c5ec2bfd9b 100644
--- a/poi-ooxml/src/main/java/org/apache/poi/xssf/model/ThemesTable.java
+++ b/poi-ooxml/src/main/java/org/apache/poi/xssf/model/ThemesTable.java
@@ -49,12 +49,12 @@ public class ThemesTable extends POIXMLDocumentPart implements Themes {
HLINK(10,"Hlink"),
FOLHLINK(11,"FolHlink"),
UNKNOWN(-1,null);
-
+
public static ThemeElement byId(int idx) {
if (idx >= values().length || idx < 0) return UNKNOWN;
return values()[idx];
}
- private ThemeElement(int idx, String name) {
+ ThemeElement(int idx, String name) {
this.idx = idx; this.name = name;
}
public final int idx;
@@ -62,7 +62,7 @@ public class ThemesTable extends POIXMLDocumentPart implements Themes {
}
private IndexedColorMap colorMap;
- private ThemeDocument theme;
+ private final ThemeDocument theme;
/**
* Create a new, empty ThemesTable
@@ -72,23 +72,23 @@ public class ThemesTable extends POIXMLDocumentPart implements Themes {
theme = ThemeDocument.Factory.newInstance();
theme.addNewTheme().addNewThemeElements();
}
-
+
/**
* Construct a ThemesTable.
* @param part A PackagePart.
- *
+ *
* @since POI 3.14-Beta1
*/
public ThemesTable(PackagePart part) throws IOException {
super(part);
-
+
try {
theme = ThemeDocument.Factory.parse(part.getInputStream(), DEFAULT_XML_OPTIONS);
} catch(XmlException e) {
throw new IOException(e.getLocalizedMessage(), e);
}
}
-
+
/**
* Construct a ThemesTable from an existing ThemeDocument.
* @param theme A ThemeDocument.
@@ -99,12 +99,11 @@ public class ThemesTable extends POIXMLDocumentPart implements Themes {
/**
* called from {@link StylesTable} when setting theme, used to adjust colors if a custom indexed mapping is defined
- * @param colorMap
*/
protected void setColorMap(IndexedColorMap colorMap) {
this.colorMap = colorMap;
}
-
+
/**
* Convert a theme "index" (as used by fonts etc) into a color.
* @param idx A theme "index"
@@ -133,7 +132,7 @@ public class ThemesTable extends POIXMLDocumentPart implements Themes {
default: return null;
}
- byte[] rgb = null;
+ byte[] rgb;
if (ctColor.isSetSrgbClr()) {
// Color is a regular one
rgb = ctColor.getSrgbClr().getVal();
@@ -143,9 +142,9 @@ public class ThemesTable extends POIXMLDocumentPart implements Themes {
} else {
return null;
}
- return new XSSFColor(rgb, colorMap);
+ return new XSSFColor(rgb, colorMap);
}
-
+
/**
* If the colour is based on a theme, then inherit
* information (currently just colours) from it as
@@ -170,10 +169,10 @@ public class ThemesTable extends POIXMLDocumentPart implements Themes {
// All done
}
-
+
/**
* Write this table out as XML.
- *
+ *
* @param out The stream to write to.
* @throws IOException if an error occurs while writing.
*/
diff --git a/poi-ooxml/src/main/java/org/apache/poi/xssf/streaming/SXSSFEvaluationSheet.java b/poi-ooxml/src/main/java/org/apache/poi/xssf/streaming/SXSSFEvaluationSheet.java
index 306b7eeb10..3f19893da8 100644
--- a/poi-ooxml/src/main/java/org/apache/poi/xssf/streaming/SXSSFEvaluationSheet.java
+++ b/poi-ooxml/src/main/java/org/apache/poi/xssf/streaming/SXSSFEvaluationSheet.java
@@ -49,6 +49,7 @@ final class SXSSFEvaluationSheet implements EvaluationSheet {
* @see org.apache.poi.ss.formula.EvaluationSheet#isRowHidden(int)
* @since POI 4.1.0
*/
+ @Override
public boolean isRowHidden(int rowIndex) {
SXSSFRow row = _xs.getRow(rowIndex);
if (row == null) return false;
diff --git a/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/BaseXSSFFormulaEvaluator.java b/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/BaseXSSFFormulaEvaluator.java
index bbad20e518..c38dd70438 100644
--- a/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/BaseXSSFFormulaEvaluator.java
+++ b/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/BaseXSSFFormulaEvaluator.java
@@ -47,10 +47,11 @@ public abstract class BaseXSSFFormulaEvaluator extends BaseFormulaEvaluator {
* Turns a XSSFCell / SXSSFCell into a XSSFEvaluationCell
*/
protected abstract EvaluationCell toEvaluationCell(Cell cell);
-
+
/**
* Returns a CellValue wrapper around the supplied ValueEval instance.
*/
+ @Override
protected CellValue evaluateFormulaCellValue(Cell cell) {
EvaluationCell evalCell = toEvaluationCell(cell);
ValueEval eval = _bookEvaluator.evaluate(evalCell);
@@ -71,7 +72,8 @@ public abstract class BaseXSSFFormulaEvaluator extends BaseFormulaEvaluator {
}
throw new RuntimeException("Unexpected eval class (" + eval.getClass().getName() + ")");
}
-
+
+ @Override
protected void setCellType(Cell cell, CellType cellType) {
if (cell instanceof XSSFCell) {
EvaluationWorkbook evaluationWorkbook = getEvaluationWorkbook();
diff --git a/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/DefaultIndexedColorMap.java b/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/DefaultIndexedColorMap.java
index 0d2980b4b1..31865bb64b 100644
--- a/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/DefaultIndexedColorMap.java
+++ b/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/DefaultIndexedColorMap.java
@@ -23,15 +23,12 @@ import org.apache.poi.hssf.util.HSSFColor;
*/
public class DefaultIndexedColorMap implements IndexedColorMap {
- /**
- * @see org.apache.poi.xssf.usermodel.IndexedColorMap#getRGB(int)
- */
+ @Override
public byte[] getRGB(int index) {
return getDefaultRGB(index);
}
/**
- * @param index
* @return RGB bytes from HSSF default color by index
*/
public static byte[] getDefaultRGB(int index) {
diff --git a/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFBuiltinTableStyle.java b/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFBuiltinTableStyle.java
index 5e65241e46..8364108723 100644
--- a/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFBuiltinTableStyle.java
+++ b/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFBuiltinTableStyle.java
@@ -18,7 +18,6 @@
package org.apache.poi.xssf.usermodel;
import java.io.ByteArrayInputStream;
-import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.util.EnumMap;
@@ -343,7 +342,7 @@ public enum XSSFBuiltinTableStyle {
*/
private static final Map<XSSFBuiltinTableStyle, TableStyle> styleMap = new EnumMap<>(XSSFBuiltinTableStyle.class);
- private XSSFBuiltinTableStyle() {
+ XSSFBuiltinTableStyle() {
}
/**
@@ -357,7 +356,6 @@ public enum XSSFBuiltinTableStyle {
/**
* NOTE: only checks by name, not definition.
*
- * @param style
* @return true if the style represents a built-in style, false if it is null or a custom style
*/
public static boolean isBuiltinStyle(TableStyle style) {
@@ -423,22 +421,20 @@ public enum XSSFBuiltinTableStyle {
}
}
- private static String styleXML(Node dxfsNode, Node tableStyleNode) throws IOException, TransformerException {
+ private static String styleXML(Node dxfsNode, Node tableStyleNode) throws TransformerException {
// built-ins doc uses 1-based dxf indexing, Excel uses 0 based.
// add a dummy node to adjust properly.
dxfsNode.insertBefore(dxfsNode.getOwnerDocument().createElement("dxf"), dxfsNode.getFirstChild());
- StringBuilder sb = new StringBuilder(1024);
- sb.append("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n")
- .append("<styleSheet xmlns=\"http://schemas.openxmlformats.org/spreadsheetml/2006/main\" ")
- .append("xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" ")
- .append("xmlns:x14ac=\"http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac\" ")
- .append("xmlns:x16r2=\"http://schemas.microsoft.com/office/spreadsheetml/2015/02/main\" ")
- .append("mc:Ignorable=\"x14ac x16r2\">\n");
- sb.append(writeToString(dxfsNode));
- sb.append(writeToString(tableStyleNode));
- sb.append("</styleSheet>");
- return sb.toString();
+ return "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n" +
+ "<styleSheet xmlns=\"http://schemas.openxmlformats.org/spreadsheetml/2006/main\" " +
+ "xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" " +
+ "xmlns:x14ac=\"http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac\" " +
+ "xmlns:x16r2=\"http://schemas.microsoft.com/office/spreadsheetml/2015/02/main\" " +
+ "mc:Ignorable=\"x14ac x16r2\">\n" +
+ writeToString(dxfsNode) +
+ writeToString(tableStyleNode) +
+ "</styleSheet>";
}
private static String writeToString(Node node) throws TransformerException {
@@ -458,27 +454,27 @@ public enum XSSFBuiltinTableStyle {
private final XSSFBuiltinTableStyle builtIn;
private final TableStyle style;
- /**
- * @param builtIn
- * @param style
- */
protected XSSFBuiltinTypeStyleStyle(XSSFBuiltinTableStyle builtIn, TableStyle style) {
this.builtIn = builtIn;
this.style = style;
}
+ @Override
public String getName() {
return style.getName();
}
+ @Override
public int getIndex() {
return builtIn.ordinal();
}
+ @Override
public boolean isBuiltin() {
return true;
}
+ @Override
public DifferentialStyleProvider getStyle(TableStyleType type) {
return style.getStyle(type);
}
diff --git a/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFCell.java b/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFCell.java
index 67a7a3dbb8..1900d7705c 100644
--- a/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFCell.java
+++ b/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFCell.java
@@ -49,10 +49,9 @@ import org.apache.poi.ss.util.CellReference;
import org.apache.poi.util.Beta;
import org.apache.poi.util.Internal;
import org.apache.poi.util.LocaleUtil;
-import org.apache.poi.util.Removal;
+import org.apache.poi.xssf.model.CalculationChain;
import org.apache.poi.xssf.model.SharedStringsTable;
import org.apache.poi.xssf.model.StylesTable;
-import org.apache.poi.xssf.model.CalculationChain;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCell;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCellFormula;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.STCellFormulaType;
@@ -99,12 +98,12 @@ public final class XSSFCell extends CellBase {
* Table of strings shared across this workbook.
* If two cells contain the same string, then the cell value is the same index into SharedStringsTable
*/
- private SharedStringsTable _sharedStringSource;
+ private final SharedStringsTable _sharedStringSource;
/**
* Table of cell styles shared across all cells in a workbook.
*/
- private StylesTable _stylesSource;
+ private final StylesTable _stylesSource;
/**
* Construct a XSSFCell.
@@ -127,9 +126,6 @@ public final class XSSFCell extends CellBase {
_stylesSource = row.getSheet().getWorkbook().getStylesSource();
}
- /**
- * {@inheritDoc}
- */
@Override
protected SpreadsheetVersion getSpreadsheetVersion() {
return SpreadsheetVersion.EXCEL2007;
@@ -290,7 +286,7 @@ public final class XSSFCell extends CellBase {
* </p>
* @return the value of the cell as a number
* @throws IllegalStateException if the cell type returned by {@link #getCellType()} is {@link CellType#STRING}
- * @exception NumberFormatException if the cell value isn't a parsable <code>double</code>.
+ * @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, <code>SUM(C4:E4)</code>
+ * 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.
* </p>
*
- * @param formula the formula to set, e.g. <code>"SUM(C4:E4)"</code>.
- * If the argument is <code>null</code> 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 {
* </p>
* @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 <code>double</code>.
+ * @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 {
* </p>
* @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 <code>double</code>.
+ * @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 {
* </p>
*
* @return the raw cell value as contained in the underlying CTCell bean,
- * <code>null</code> 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 <code>null</code>
+ * @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 <code>null</code> 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
- * <code>application/vnd.openxmlformats-officedocument.drawingml.chart+xml</code>
+ * {@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 Map<STCfType.Enum, ConditionType> typeLookup = new HashMap<>();
- private static Map<STCfType.Enum, ConditionFilterType> filterTypeLookup = new HashMap<>();
+ private static final Map<STCfType.Enum, ConditionType> typeLookup = new HashMap<>();
+ private static final Map<STCfType.Enum, ConditionFilterType> filterTypeLookup = new HashMap<>();
static {
typeLookup.put(STCfType.CELL_IS, ConditionType.CELL_VALUE_IS);
typeLookup.put(STCfType.EXPRESSION, ConditionType.FORMULA);
@@ -95,7 +95,6 @@ public class XSSFConditionalFormattingRule implements ConditionalFormattingRule
/**
* NOTE: does not set priority, so this assumes the rule will not be added to the sheet yet
- * @param sh
*/
/*package*/ XSSFConditionalFormattingRule(XSSFSheet sh){
_cfRule = CTCfRule.Factory.newInstance();
@@ -126,12 +125,14 @@ public class XSSFConditionalFormattingRule implements ConditionalFormattingRule
return dxf;
}
+ @Override
public int getPriority() {
final int priority = _cfRule.getPriority();
// priorities start at 1, if it is less, it is undefined, use definition order in caller
return priority >=1 ? priority : 0;
}
+ @Override
public boolean getStopIfTrue() {
return _cfRule.getStopIfTrue();
}
@@ -140,8 +141,9 @@ public class XSSFConditionalFormattingRule implements ConditionalFormattingRule
* Create a new border formatting structure if it does not exist,
* otherwise just return existing object.
*
- * @return - border formatting object, never returns <code>null</code>.
+ * @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, <code>null</code> 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 <code>null</code>.
+ * @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, <code>null</code> 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 <code>null</code>.
+ * @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, <code>null</code> 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}
* <p>
* MUST be a constant from {@link org.apache.poi.ss.usermodel.ComparisonOperator}
- * </p>
*
* @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.
- * </p>
* <p>
* If comparison type is {@link ConditionType#FORMULA} the formula MUST be a Boolean function
- * </p>
*
* @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: use <code>null</code>)
+ * @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, &gt; 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;
/**
* <p>
- * 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.
* </p><p>
* 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.
* </p><p>
* 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.
* </p>
*/
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;
/**
* <p>
- * 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.
* </p><p>
* 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;
/**
- * <p>
* 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.
- * </p><p>
+ * <p>
* 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.
- * </p><p>
+ * <p>
* 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.
- * </p>
*/
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 {@code <c:chart>} tag into
- * {@code<a:graphicData>}.
+ * {@code <a:graphicData>}.
*
* Here is the schema (ECMA-376):
* <pre>
diff --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.
* </p>
*/
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.
- * </p>
* <p>
- * <code>resize(1.0,1.0)</code> keeps the original size,<br>
- * <code>resize(0.5,0.5)</code> resize to 50% of the original,<br>
- * <code>resize(2.0,2.0)</code> resizes to 200% of the original.<br>
+ * {@code resize(1.0,1.0)} keeps the original size,<br>
+ * {@code resize(0.5,0.5)} resize to 50% of the original,<br>
+ * {@code resize(2.0,2.0)} resizes to 200% of the original.<br>
* <code>resize({@link Double#MAX_VALUE},{@link Double#MAX_VALUE})</code> resizes to the dimension of the embedded image.
- * </p>
*
* @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 underlying <code>CTTable</code>.
+ * 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)
*
- * Returns <code>0</code> 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.
*
- * Returns <code>0</code> 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 name <code>column</code>.
+ * 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 <code>-1</code> if <code>column</code> 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 &gt; 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 <code>-1</code> 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 of <code>null</code> 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 {
* <p>
* The size is specified using a percentage.
* Positive values indicate superscript, negative values indicate subscript.
- * </p>
- *
- * @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)}
* <p>
- * <p>
* 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
- * </p>
*
* @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;
- Iterator<XSSFChart> it = 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<IBodyElement> getBodyElements();
+ List<IBodyElement> getBodyElements();
/**
* Returns the paragraph(s) that holds
* the text of the header or footer.
*/
- public List<XWPFParagraph> getParagraphs();
+ List<XWPFParagraph> getParagraphs();
/**
* Return the table(s) that holds the text
* of the IBodyPart, for complex cases
* where a paragraph isn't used.
*/
- public List<XWPFTable> getTables();
+ List<XWPFTable> 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.
- * <p>
- * <p>
- * <p>
- * 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 <code>application/vnd.openxmlformats-officedocument.drawingml.chart+xml</code>
+ * 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:<br>
- * a) Use the checksum only and take the risk that two images might have
- * the same CRC32 sum, although they are not the same.<br>
- * 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 List<XWPFComment> comments = new ArrayList<>();
- private List<XWPFPictureData> pictures = new ArrayList<>();
+ private final List<XWPFComment> comments = new ArrayList<>();
+ private final List<XWPFPictureData> 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<XWPFComment> 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.
- * <p>
- * <p>
- * <p>
- * 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<XWPFTable> tables = new ArrayList<>();
// private List<XWPFRun> runs = new ArrayList<>();
// private List<XWPFSDT> contentControls = new ArrayList<>();
- private List<ISDTContents> bodyElements = new ArrayList<>();
+ private final List<ISDTContents> 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<String> 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<IBodyElement> getBodyElements() {
return Collections.unmodifiableList(bodyElements);
}
@@ -136,6 +135,7 @@ public class XWPFTableCell implements IBody, ICell {
/**
* returns a list of paragraphs
*/
+ @Override
public List<XWPFParagraph> 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 <code>null</code>
+ * @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 List<XWPFTable> getTables() {
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<XWPFTableCell> 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<String> iterable, String... expected) {
+ void testIteration(Iterable<String> iterable, String... expected) {
Iterator<String> 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 <T> Iterable<T> createIter(SortedMap<Long, T> map1, SortedMap<Long, T> 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 <code>Picture</code>
+ * Create a new {@code Picture}
*
* @param pictureData the picture data
*/
@@ -56,10 +56,10 @@ public final class ActiveXShape extends HSLFPictureShape {
}
/**
- * Create a <code>Picture</code> object
+ * Create a {@code Picture} object
*
- * @param escherRecord the <code>EscherSpContainer</code> record which holds information about
- * this picture in the <code>Slide</code>
+ * @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, ShapeContainer<HSLFShape,HSLFTextParagraph> parent){
@@ -69,13 +69,14 @@ public final class ActiveXShape extends HSLFPictureShape {
/**
* Create a new Placeholder and initialize internal structures
*
- * @return the created <code>EscherContainerRecord</code> 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 escherRecord <code>EscherSpContainer</code> 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, ShapeContainer<HSLFShape,HSLFTextParagraph> parent){
@@ -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<HSLFSh
super(escherRecord, parent);
}
+ @Override
protected EscherContainerRecord createSpContainer(boolean isChild) {
return null;
}
diff --git a/poi-scratchpad/src/main/java/org/apache/poi/hslf/usermodel/HSLFComment.java b/poi-scratchpad/src/main/java/org/apache/poi/hslf/usermodel/HSLFComment.java
index 0548fca452..c5618f0c59 100644
--- a/poi-scratchpad/src/main/java/org/apache/poi/hslf/usermodel/HSLFComment.java
+++ b/poi-scratchpad/src/main/java/org/apache/poi/hslf/usermodel/HSLFComment.java
@@ -25,7 +25,7 @@ import java.awt.geom.Point2D;
import java.util.Date;
public final class HSLFComment implements Comment {
- private Comment2000 _comment2000;
+ private final Comment2000 _comment2000;
public HSLFComment(Comment2000 comment2000) {
_comment2000 = comment2000;
@@ -38,6 +38,7 @@ public final class HSLFComment implements Comment {
/**
* Get the Author of this comment
*/
+ @Override
public String getAuthor() {
return _comment2000.getAuthor();
}
@@ -45,6 +46,7 @@ public final class HSLFComment implements Comment {
/**
* Set the Author of this comment
*/
+ @Override
public void setAuthor(String author) {
_comment2000.setAuthor(author);
}
@@ -52,6 +54,7 @@ public final class HSLFComment implements Comment {
/**
* Get the Author's Initials of this comment
*/
+ @Override
public String getAuthorInitials() {
return _comment2000.getAuthorInitials();
}
@@ -59,6 +62,7 @@ public final class HSLFComment implements Comment {
/**
* Set the Author's Initials of this comment
*/
+ @Override
public void setAuthorInitials(String initials) {
_comment2000.setAuthorInitials(initials);
}
@@ -66,6 +70,7 @@ public final class HSLFComment implements Comment {
/**
* Get the text of this comment
*/
+ @Override
public String getText() {
return _comment2000.getText();
}
@@ -73,6 +78,7 @@ public final class HSLFComment implements Comment {
/**
* Set the text of this comment
*/
+ @Override
public void setText(String text) {
_comment2000.setText(text);
}
diff --git a/poi-scratchpad/src/main/java/org/apache/poi/hslf/usermodel/HSLFShape.java b/poi-scratchpad/src/main/java/org/apache/poi/hslf/usermodel/HSLFShape.java
index 8fed381c38..f06230a4ce 100644
--- a/poi-scratchpad/src/main/java/org/apache/poi/hslf/usermodel/HSLFShape.java
+++ b/poi-scratchpad/src/main/java/org/apache/poi/hslf/usermodel/HSLFShape.java
@@ -55,18 +55,14 @@ import org.apache.poi.util.StringUtil;
import org.apache.poi.util.Units;
/**
- * <p>
- * 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.
- * </p>
* <p>
* 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).
- * </p>
- * <p>
*/
public abstract class HSLFShape implements Shape<HSLFShape,HSLFTextParagraph> {
private static final Logger LOG = LogManager.getLogger(HSLFShape.class);
@@ -79,12 +75,12 @@ public abstract class HSLFShape implements Shape<HSLFShape,HSLFTextParagraph> {
/**
* Parent of this shape.
- * <code>null</code> for the topmost shapes.
+ * {@code null} for the topmost shapes.
*/
- private ShapeContainer<HSLFShape,HSLFTextParagraph> _parent;
+ private final ShapeContainer<HSLFShape,HSLFTextParagraph> _parent;
/**
- * The <code>Sheet</code> this shape belongs to
+ * The {@code Sheet} this shape belongs to
*/
private HSLFSheet _sheet;
@@ -92,11 +88,11 @@ public abstract class HSLFShape implements Shape<HSLFShape,HSLFTextParagraph> {
* 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 <code>EscherSpContainer</code> 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, ShapeContainer<HSLFShape,HSLFTextParagraph> parent){
@@ -233,12 +229,12 @@ public abstract class HSLFShape implements Shape<HSLFShape,HSLFTextParagraph> {
/**
* Helper method to return escher child by record ID
*
- * @return escher record or <code>null</code> if not found.
+ * @return escher record or {@code null} if not found.
*/
public static <T extends EscherRecord> T 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<HSLFShape,HSLFTextParagraph> {
public <T extends EscherRecord> T getEscherChild(int recordId){
return _escherContainer.getChildById((short)recordId);
}
-
+
/**
* @since POI 3.14-Beta2
*/
public <T extends EscherRecord> T getEscherChild(EscherRecordTypes recordId){
return getEscherChild(recordId.typeID);
}
-
+
/**
* Returns escher property by id.
*
- * @return escher property or <code>null</code> 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<HSLFShape,HSLFTextParagraph> {
/**
* Returns escher property by type.
*
- * @return escher property or <code>null</code> if not found.
+ * @return escher property or {@code null} if not found.
*/
public static <T extends EscherProperty> T getEscherProperty(AbstractEscherOptRecord opt, EscherPropertyTypes type){
return (opt == null) ? null : opt.lookup(type);
@@ -428,7 +424,7 @@ public abstract class HSLFShape implements Shape<HSLFShape,HSLFTextParagraph> {
}
/**
- * @return the <code>SlideShow</code> 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<HSLFShape,HSLFTextParagraph> {
}
/**
- * Assign the <code>SlideShow</code> 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<HSLFShape,HSLFTextParagraph> {
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<HSLFShape,HSLFTextParagraph> {
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<HSLFShape,HSLFTextParagraph> {
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<HSLFShape,HSLFTextParagraph> {
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<HSLFShape,HSLFTextParagraph> {
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<HSLFShape,HSLFTextParagraph> {
}
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<HSLFShape,HSLFTextParagraph> {
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<HSLFShape,HSLFTextParagraph> {
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<HSLFShape,HSLFTextParagraph> {
/**
* 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 <code>null</code>
+ * @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<HSLFShape,HSLFTextParagraph> {
/**
* 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<HSLFShape,HSLFTextParagraph,HSLFTextRun> {
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<HSLFShape,HSLFText
this.tabStop = tabStop;
}
+ @Override
public double getPositionInPoints() {
return tabStop.getPositionInPoints();
}
+ @Override
public void setPositionInPoints(double position) {
tabStop.setPositionInPoints(position);
setDirty();
}
+ @Override
public TabStopType getType() {
return tabStop.getType();
}
+ @Override
public void setType(TabStopType type) {
tabStop.setType(type);
setDirty();
@@ -165,18 +161,6 @@ public final class HSLFTextParagraph implements TextParagraph<HSLFShape,HSLFText
setParagraphStyle(new TextPropCollection(1, TextPropType.paragraph));
}
- /* package */HSLFTextParagraph(HSLFTextParagraph other) {
- _headerAtom = other._headerAtom;
- _byteAtom = other._byteAtom;
- _charAtom = other._charAtom;
- _parentShape = other._parentShape;
- _sheet = other._sheet;
- _ruler = other._ruler;
- shapeId = other.shapeId;
- parentList = other.parentList;
- setParagraphStyle(other._paragraphStyle);
- }
-
public void addTextRun(HSLFTextRun run) {
_runs.add(run);
}
@@ -248,8 +232,6 @@ public final class HSLFTextParagraph implements TextParagraph<HSLFShape,HSLFText
/**
* Sets the index of the paragraph in the SLWT container
- *
- * @param index
*/
protected void setIndex(int index) {
if (_headerAtom != null) {
@@ -636,7 +618,7 @@ public final class HSLFTextParagraph implements TextParagraph<HSLFShape,HSLFText
* Sets the bullet character
*/
public void setBulletChar(Character c) {
- Integer val = (c == null) ? null : (int)c.charValue();
+ Integer val = (c == null) ? null : (int) c;
setParagraphTextPropVal("bullet.char", val);
}
@@ -765,23 +747,21 @@ public final class HSLFTextParagraph implements TextParagraph<HSLFShape,HSLFText
@Override
public List<? extends TabStop> getTabStops() {
final List<HSLFTabStop> 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<HSLFShape,HSLFText
private boolean getFlag(int index) {
BitMaskTextProp tp = getPropVal(_paragraphStyle, ParagraphFlagsTextProp.NAME);
- return (tp == null) ? false : tp.getSubValue(index);
+ return tp != null && tp.getSubValue(index);
}
private void setFlag(int index, boolean value) {
- BitMaskTextProp tp = (BitMaskTextProp)_paragraphStyle.addWithName(ParagraphFlagsTextProp.NAME);
+ BitMaskTextProp tp = _paragraphStyle.addWithName(ParagraphFlagsTextProp.NAME);
tp.setSubValue(value, index);
setDirty();
}
@@ -1047,7 +1027,6 @@ public final class HSLFTextParagraph implements TextParagraph<HSLFShape,HSLFText
StringUtil.putCompressedUnicode(rawText, byteText, 0);
byteAtom.setText(byteText);
}
- assert (newRecord != null);
RecordContainer _txtbox = headerAtom.getParentRecord();
Record[] cr = _txtbox.getChildRecords();
@@ -1528,7 +1507,7 @@ public final class HSLFTextParagraph implements TextParagraph<HSLFShape,HSLFText
break;
}
List<HSLFTextRun> 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<HSLFShape,HSLFText
}
/**
- * {@inheritDoc}
- *
* @see RoundTripHFPlaceholder12
*/
@Override
diff --git a/poi-scratchpad/src/main/java/org/apache/poi/hwmf/draw/HwmfDrawProperties.java b/poi-scratchpad/src/main/java/org/apache/poi/hwmf/draw/HwmfDrawProperties.java
index f0993b24da..ebb3a0234a 100644
--- a/poi-scratchpad/src/main/java/org/apache/poi/hwmf/draw/HwmfDrawProperties.java
+++ b/poi-scratchpad/src/main/java/org/apache/poi/hwmf/draw/HwmfDrawProperties.java
@@ -322,8 +322,6 @@ public class HwmfDrawProperties {
/**
* Sets the current palette.
* It's the callers duty to set a modifiable copy of the palette.
- *
- * @param palette
*/
public void setPalette(List<PaletteEntry> 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 extends HwmfEscapeData> 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 &gt;= 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 &lt;= 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;
/**
* <p>The File Information Block (FIB). Holds pointers
* to various bits of the file, and lots of flags which
- * specify properties of the document.<p>
+ * specify properties of the document.
* <ul>
* <li>The {@link FibBase} class, holds the first 32 bytes.</li>
* <li>The next part, the fibRgW / FibRgW97, is handled by the {@link FibRgW97}.</li>
@@ -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<GenericPropertyNode> _props;
+ private final int _cbStruct;
+ private final List<GenericPropertyNode> _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<TextPiece> {
- 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<TextPiece> {
* @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<TextPiece>, Serializable {
- public int compare(TextPiece textPiece, TextPiece textPiece1) {
- return Integer.compare(textPiece.getPieceDescriptor().fc, textPiece1
- .getPieceDescriptor().fc);
- }
+ static Comparator<TextPiece> 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,43 +268,43 @@ 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();
}
/**
+ * 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
+ */
+ public double getCropLeft() {
+ return getCrop(EscherPropertyTypes.BLIP__CROPFROMLEFT);
+ }
+
+ /**
* @return The amount the picture has been cropped on the right in twips
- * @deprecated POI 3.8 beta 4.
*/
- @Deprecated
- public int getDxaCropRight()
- {
+ 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,25 +317,58 @@ 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();
}
/**
+ * 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
+ */
+ public double getCropBottom() {
+ return getCrop(EscherPropertyTypes.BLIP__CROPFROMBOTTOM);
+ }
+
+ /**
* @return The amount the picture has been cropped on the top in twips
- * @deprecated POI 3.8 beta 5.
*/
- @Deprecated
- public int getDyaCropTop()
- {
+ 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:
+ 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;
+ }
+ }
+
+ Enum<?> recordType = escherRecord.getGenericRecordType();
+ assert (recordType instanceof EscherRecordTypes);
+ switch ((EscherRecordTypes)recordType) {
+ case BLIP_EMF:
return PictureType.EMF;
- case 0x03:
+ case BLIP_WMF:
return PictureType.WMF;
- case 0x04:
+ case BLIP_PICT:
return PictureType.PICT;
- case 0x05:
+ case BLIP_JPEG:
return PictureType.JPEG;
- case 0x06:
+ case BLIP_PNG:
return PictureType.PNG;
- case 0x07:
+ case BLIP_DIB:
return PictureType.BMP;
- case 0x11:
+ case BLIP_TIFF:
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;
}
}
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<p>
+ * 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<p>
+ * 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)<p>
*
* 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)<p>
+ * 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<p>
+ * 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.<p>
- * This is often called a XLUnicodeRichExtendedString in MS documentation.<p>
+ * This is often called a XLUnicodeRichExtendedString in MS documentation.
*/
public class UnicodeString implements Comparable<UnicodeString>, Duplicatable, GenericRecord {
private static final Logger LOG = LogManager.getLogger(UnicodeString.class);
@@ -445,6 +445,7 @@ public class UnicodeString implements Comparable<UnicodeString>, 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:
- * <p>
- * <pre>
- * multipler = groupHeightInPoints / heightOfGroup
- * </pre>
+ * <pre>{@code
+ * multiplier = groupHeightInPoints / heightOfGroup
+ * }</pre>
* <p>
* 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
- * <code>HSSFClientAnchor.getAnchorHeightInPoints()</code>.
+ * {@code HSSFClientAnchor.getAnchorHeightInPoints()}.
* </blockquote>
*/
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 <i>x</i> and <i>y</i> coordinates.
* <p>
- * This draws the polygon, with <code>nPoint</code> line segments.
- * The first <code>nPoint&nbsp;-&nbsp;1</code> line segments are
+ * This draws the polygon, with {@code nPoint} line segments.
+ * The first {@code nPoint&nbsp;-&nbsp;1} line segments are
* drawn between sequential points
- * (<code>xPoints[i],yPoints[i],xPoints[i+1],yPoints[i+1]</code>).
+ * ({@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).
* <p>
* 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 <code>x</code> coordinates.
- * @param yPoints array of the <code>y</code> 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:
- * <p>
- * <pre>
+ * <pre>{@code
* multipler = groupHeightInPoints / heightOfGroup
- * </pre>
+ * }</pre>
* <p>
* 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
- * <code>HSSFClientAnchor.getAnchorHeightInPoints()</code>.
+ * {@code HSSFClientAnchor.getAnchorHeightInPoints()}.
* </blockquote>
*/
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 <i>x</i> and <i>y</i> coordinates.
* <p>
- * This draws the polygon, with <code>nPoint</code> line segments.
- * The first <code>nPoint&nbsp;-&nbsp;1</code> line segments are
+ * This draws the polygon, with {@code nPoint} line segments.
+ * The first {@code nPoint&nbsp;-&nbsp;1} line segments are
* drawn between sequential points
- * (<code>xPoints[i],yPoints[i],xPoints[i+1],yPoints[i+1]</code>).
+ * ({@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).
* <p>
* 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 <code>x</code> coordinates.
- * @param yPoints array of the <code>y</code> 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;
* <p>
* Cells should have their number (0 based) before being added to a row. Only
* cells that have values should be added.
- * <p>
*/
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 <code>null</code> 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 (Iterator<RecordBase> it = _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 <code>true</code> if the comment is visible, <code>false</code> 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.
*
- * @return <code>true</code> if the comment is visible, <code>false</code> 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. Pass <code>null</code>
+ * @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. Pass <code>null</code>
+ * @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 pass <code>null</code> 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. Pass <code>null</code>
+ * @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 pass <code>null</code> 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 a <code>HyperlinkRecord</code> 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. never <code>null</code>
+ * @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:
*
- * <p><blockquote><pre>
+ * <pre>{@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 );
- * </pre></blockquote>
+ * }</pre>
*
* and
*
- * <p><blockquote><pre>
+ * <pre>{@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 );
- * </pre></blockquote><p>
+ * }</pre><p>
*
* 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<HSSFRichTextString>,
* @param endIndex The end index to apply the font to (exclusive)
* @param fontIndex The font to use.
*/
+ @Override
public void applyFont(int startIndex, int endIndex, short fontIndex) {
if (startIndex > endIndex)
throw new IllegalArgumentException("Start index must be less than end index.");
@@ -167,6 +168,7 @@ public final class HSSFRichTextString implements Comparable<HSSFRichTextString>,
* @param endIndex The end index to apply to font to (exclusive)
* @param font The index of the font to use.
*/
+ @Override
public void applyFont(int startIndex, int endIndex, Font font) {
applyFont(startIndex, endIndex, (short)font.getIndex());
}
@@ -175,6 +177,7 @@ public final class HSSFRichTextString implements Comparable<HSSFRichTextString>,
* Sets the font of the entire string.
* @param font The font to use.
*/
+ @Override
public void applyFont(Font font) {
applyFont(0, _string.getCharCount(), font);
}
@@ -182,6 +185,7 @@ public final class HSSFRichTextString implements Comparable<HSSFRichTextString>,
/**
* Removes any formatting that may have been applied to the string.
*/
+ @Override
public void clearFormatting() {
_string = cloneStringIfRequired();
_string.clearFormatting();
@@ -191,6 +195,7 @@ public final class HSSFRichTextString implements Comparable<HSSFRichTextString>,
/**
* Returns the plain string representation.
*/
+ @Override
public String getString() {
return _string.getString();
}
@@ -224,6 +229,7 @@ public final class HSSFRichTextString implements Comparable<HSSFRichTextString>,
/**
* @return the number of characters in the text.
*/
+ @Override
public int length() {
return _string.getCharCount();
}
@@ -258,6 +264,7 @@ public final class HSSFRichTextString implements Comparable<HSSFRichTextString>,
*
* @see #NO_FONT
*/
+ @Override
public int numFormattingRuns() {
return _string.getFormatRunCount();
}
@@ -267,6 +274,7 @@ public final class HSSFRichTextString implements Comparable<HSSFRichTextString>,
* @param index the index of the formatting run
* @return the index within the string.
*/
+ @Override
public int getIndexOfFormattingRun(int index) {
FormatRun r = _string.getFormatRun(index);
return r.getCharacterPos();
@@ -286,6 +294,7 @@ public final class HSSFRichTextString implements Comparable<HSSFRichTextString>,
/**
* Compares one rich text string to another.
*/
+ @Override
public int compareTo(HSSFRichTextString r) {
return _string.compareTo(r._string);
}
@@ -318,6 +327,7 @@ public final class HSSFRichTextString implements Comparable<HSSFRichTextString>,
*
* @param fontIndex the font to apply.
*/
+ @Override
public void applyFont( short fontIndex ) {
applyFont(0, _string.getCharCount(), fontIndex);
}
diff --git a/poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFShapeContainer.java b/poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFShapeContainer.java
index 28f7894dd0..bc389d0a54 100644
--- a/poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFShapeContainer.java
+++ b/poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFShapeContainer.java
@@ -33,9 +33,8 @@ public interface HSSFShapeContainer extends ShapeContainer<HSSFShape>
/**
* add shape to the list of child records
- * @param shape
*/
- public void addShape(HSSFShape shape);
+ void addShape(HSSFShape shape);
/**
* set coordinates of this group relative to the parent
@@ -47,27 +46,27 @@ public interface HSSFShapeContainer extends ShapeContainer<HSSFShape>
/**
*@return The top left x coordinate of this group.
*/
- public int getX1();
+ int getX1();
/**
*@return The top left y coordinate of this group.
*/
- public int getY1();
+ int getY1();
/**
*@return The bottom right x coordinate of this group.
*/
- public int getX2();
+ int getX2();
/**
* @return The bottom right y coordinate of this group.
*/
- public int getY2();
+ int getY2();
/**
* remove first level shapes
* @param shape to be removed
* @return true if shape is removed else return false
*/
- public boolean removeShape(HSSFShape shape);
+ boolean removeShape(HSSFShape shape);
}
diff --git a/poi/src/main/java/org/apache/poi/poifs/crypt/ChunkedCipherOutputStream.java b/poi/src/main/java/org/apache/poi/poifs/crypt/ChunkedCipherOutputStream.java
index 5270fc0461..9cd5c224ba 100644
--- a/poi/src/main/java/org/apache/poi/poifs/crypt/ChunkedCipherOutputStream.java
+++ b/poi/src/main/java/org/apache/poi/poifs/crypt/ChunkedCipherOutputStream.java
@@ -26,10 +26,7 @@ import java.io.IOException;
import java.io.OutputStream;
import java.security.GeneralSecurityException;
-import javax.crypto.BadPaddingException;
import javax.crypto.Cipher;
-import javax.crypto.IllegalBlockSizeException;
-import javax.crypto.ShortBufferException;
import com.zaxxer.sparsebits.SparseBitSet;
import org.apache.logging.log4j.LogManager;
@@ -37,7 +34,6 @@ import org.apache.logging.log4j.Logger;
import org.apache.poi.EncryptedDocumentException;
import org.apache.poi.poifs.filesystem.DirectoryNode;
import org.apache.poi.poifs.filesystem.POIFSWriterEvent;
-import org.apache.poi.poifs.filesystem.POIFSWriterListener;
import org.apache.poi.util.IOUtils;
import org.apache.poi.util.Internal;
import org.apache.poi.util.LittleEndian;
@@ -63,7 +59,7 @@ public abstract class ChunkedCipherOutputStream extends FilterOutputStream {
private long pos;
private long totalPos;
private long written;
-
+
// the cipher can't be final, because for the last chunk we change the padding
// and therefore need to change the cipher too
private Cipher cipher;
@@ -133,7 +129,7 @@ public abstract class ChunkedCipherOutputStream extends FilterOutputStream {
public void writePlain(byte[] b, int off, int len) throws IOException {
write(b, off, len, true);
}
-
+
protected void write(byte[] b, int off, int len, boolean writePlain) throws IOException {
if (len == 0) {
return;
@@ -214,10 +210,6 @@ public abstract class ChunkedCipherOutputStream extends FilterOutputStream {
/**
* Helper function for overriding the cipher invocation, i.e. XOR doesn't use a cipher
* and uses it's own implementation
- *
- * @throws BadPaddingException
- * @throws IllegalBlockSizeException
- * @throws ShortBufferException
*/
protected int invokeCipher(int posInChunk, boolean doFinal) throws GeneralSecurityException, IOException {
byte[] plain = (plainByteFlags.isEmpty()) ? null : chunk.clone();
@@ -250,10 +242,10 @@ public abstract class ChunkedCipherOutputStream extends FilterOutputStream {
i = plainByteFlags.nextSetBit(i+1);
}
}
-
+
return ciLen;
}
-
+
@Override
public void close() throws IOException {
if (isClosed) {
@@ -271,14 +263,14 @@ public abstract class ChunkedCipherOutputStream extends FilterOutputStream {
if (fileOut != null) {
int oleStreamSize = (int)(fileOut.length()+LittleEndianConsts.LONG_SIZE);
calculateChecksum(fileOut, (int)pos);
- dir.createDocument(DEFAULT_POIFS_ENTRY, oleStreamSize, new EncryptedPackageWriter());
+ dir.createDocument(DEFAULT_POIFS_ENTRY, oleStreamSize, this::processPOIFSWriterEvent);
createEncryptionInfoEntry(dir, fileOut);
}
} catch (GeneralSecurityException e) {
throw new IOException(e);
}
}
-
+
protected byte[] getChunk() {
return chunk;
}
@@ -304,31 +296,28 @@ public abstract class ChunkedCipherOutputStream extends FilterOutputStream {
*/
public void setNextRecordSize(int recordSize, boolean isPlain) {
}
-
- private class EncryptedPackageWriter implements POIFSWriterListener {
- @Override
- public void processPOIFSWriterEvent(POIFSWriterEvent event) {
- try {
- try (OutputStream os = event.getStream();
- FileInputStream fis = new FileInputStream(fileOut)) {
-
- // StreamSize (8 bytes): An unsigned integer that specifies the number of bytes used by data
- // encrypted within the EncryptedData field, not including the size of the StreamSize field.
- // Note that the actual size of the \EncryptedPackage stream (1) can be larger than this
- // value, depending on the block size of the chosen encryption algorithm
- byte[] buf = new byte[LittleEndianConsts.LONG_SIZE];
- LittleEndian.putLong(buf, 0, pos);
- os.write(buf);
-
- IOUtils.copy(fis, os);
- }
- if (!fileOut.delete()) {
- LOG.atError().log("Can't delete temporary encryption file: {}", fileOut);
- }
- } catch (IOException e) {
- throw new EncryptedDocumentException(e);
+ private void processPOIFSWriterEvent(POIFSWriterEvent event) {
+ try {
+ try (OutputStream os = event.getStream();
+ FileInputStream fis = new FileInputStream(fileOut)) {
+
+ // StreamSize (8 bytes): An unsigned integer that specifies the number of bytes used by data
+ // encrypted within the EncryptedData field, not including the size of the StreamSize field.
+ // Note that the actual size of the \EncryptedPackage stream (1) can be larger than this
+ // value, depending on the block size of the chosen encryption algorithm
+ byte[] buf = new byte[LittleEndianConsts.LONG_SIZE];
+ LittleEndian.putLong(buf, 0, pos);
+ os.write(buf);
+
+ IOUtils.copy(fis, os);
+ }
+
+ if (!fileOut.delete()) {
+ LOG.atError().log("Can't delete temporary encryption file: {}", fileOut);
}
+ } catch (IOException e) {
+ throw new EncryptedDocumentException(e);
}
}
}
diff --git a/poi/src/main/java/org/apache/poi/poifs/crypt/EncryptionHeader.java b/poi/src/main/java/org/apache/poi/poifs/crypt/EncryptionHeader.java
index f10dda09bd..b39ec150cd 100644
--- a/poi/src/main/java/org/apache/poi/poifs/crypt/EncryptionHeader.java
+++ b/poi/src/main/java/org/apache/poi/poifs/crypt/EncryptionHeader.java
@@ -30,24 +30,6 @@ import org.apache.poi.common.usermodel.GenericRecord;
* The constants are largely based on ZIP constants.
*/
public abstract class EncryptionHeader implements GenericRecord, Duplicatable {
- public static final int ALGORITHM_RC4 = CipherAlgorithm.rc4.ecmaId;
- public static final int ALGORITHM_AES_128 = CipherAlgorithm.aes128.ecmaId;
- public static final int ALGORITHM_AES_192 = CipherAlgorithm.aes192.ecmaId;
- public static final int ALGORITHM_AES_256 = CipherAlgorithm.aes256.ecmaId;
-
- public static final int HASH_NONE = HashAlgorithm.none.ecmaId;
- public static final int HASH_SHA1 = HashAlgorithm.sha1.ecmaId;
- public static final int HASH_SHA256 = HashAlgorithm.sha256.ecmaId;
- public static final int HASH_SHA384 = HashAlgorithm.sha384.ecmaId;
- public static final int HASH_SHA512 = HashAlgorithm.sha512.ecmaId;
-
- public static final int PROVIDER_RC4 = CipherProvider.rc4.ecmaId;
- public static final int PROVIDER_AES = CipherProvider.aes.ecmaId;
-
- public static final int MODE_ECB = ChainingMode.ecb.ecmaId;
- public static final int MODE_CBC = ChainingMode.cbc.ecmaId;
- public static final int MODE_CFB = ChainingMode.cfb.ecmaId;
-
private int flags;
private int sizeExtra;
private CipherAlgorithm cipherAlgorithm;
@@ -125,8 +107,6 @@ public abstract class EncryptionHeader implements GenericRecord, Duplicatable {
* Sets the keySize (in bits). Before calling this method, make sure
* to set the cipherAlgorithm, as the amount of keyBits gets validated against
* the list of allowed keyBits of the corresponding cipherAlgorithm
- *
- * @param keyBits
*/
public void setKeySize(int keyBits) {
this.keyBits = keyBits;
@@ -170,6 +150,7 @@ public abstract class EncryptionHeader implements GenericRecord, Duplicatable {
this.cspName = cspName;
}
+ @Override
public abstract EncryptionHeader copy();
@Override
diff --git a/poi/src/main/java/org/apache/poi/poifs/crypt/package-info.java b/poi/src/main/java/org/apache/poi/poifs/crypt/package-info.java
index df27963002..e0ded04672 100644
--- a/poi/src/main/java/org/apache/poi/poifs/crypt/package-info.java
+++ b/poi/src/main/java/org/apache/poi/poifs/crypt/package-info.java
@@ -18,7 +18,7 @@
/**
* Implementation of the ECMA-376 and MS-propritary document encryptions<p>
*
- * The implementation is split into the following packages:<p>
+ * The implementation is split into the following packages:
*
* <ul>
* <li>This package contains common functions for both current implemented cipher modes.</li>
diff --git a/poi/src/main/java/org/apache/poi/poifs/filesystem/DirectoryEntry.java b/poi/src/main/java/org/apache/poi/poifs/filesystem/DirectoryEntry.java
index ed4f8c2bc5..bf70286dea 100644
--- a/poi/src/main/java/org/apache/poi/poifs/filesystem/DirectoryEntry.java
+++ b/poi/src/main/java/org/apache/poi/poifs/filesystem/DirectoryEntry.java
@@ -32,9 +32,7 @@ import org.apache.poi.hpsf.ClassID;
* managed by a Filesystem instance.
*/
-public interface DirectoryEntry
- extends Entry, Iterable<Entry>
-{
+public interface DirectoryEntry extends Entry, Iterable<Entry> {
/**
* get an iterator of the Entry instances contained directly in
@@ -47,7 +45,7 @@ public interface DirectoryEntry
* implementations of Entry.
*/
- public Iterator<Entry> getEntries();
+ Iterator<Entry> getEntries();
/**
* get the names of all the Entries contained directly in this
@@ -58,7 +56,7 @@ public interface DirectoryEntry
* getEntry(String), which may be empty (if this
* DirectoryEntry is empty)
*/
- public Set<String> getEntryNames();
+ Set<String> getEntryNames();
/**
* is this DirectoryEntry empty?
@@ -66,7 +64,7 @@ public interface DirectoryEntry
* @return true if this instance contains no Entry instances
*/
- public boolean isEmpty();
+ boolean isEmpty();
/**
* find out how many Entry instances are contained directly within
@@ -76,13 +74,13 @@ public interface DirectoryEntry
* Entry instances
*/
- public int getEntryCount();
+ int getEntryCount();
/**
* Checks if entry with specified name present
*/
- public boolean hasEntry( final String name );
+ boolean hasEntry( final String name );
/**
* get a specified Entry by name
@@ -96,8 +94,7 @@ public interface DirectoryEntry
* name exists in this DirectoryEntry
*/
- public Entry getEntry(final String name)
- throws FileNotFoundException;
+ Entry getEntry(final String name) throws FileNotFoundException;
/**
* create a new DocumentEntry
@@ -107,12 +104,9 @@ public interface DirectoryEntry
* DocumentEntry
*
* @return the new DocumentEntry
- *
- * @exception IOException
*/
- public DocumentEntry createDocument(final String name,
- final InputStream stream)
+ DocumentEntry createDocument(final String name, final InputStream stream)
throws IOException;
/**
@@ -123,12 +117,9 @@ public interface DirectoryEntry
* @param writer the writer of the new DocumentEntry
*
* @return the new DocumentEntry
- *
- * @exception IOException
*/
- public DocumentEntry createDocument(final String name, final int size,
- final POIFSWriterListener writer)
+ DocumentEntry createDocument(final String name, final int size, final POIFSWriterListener writer)
throws IOException;
/**
@@ -137,26 +128,21 @@ public interface DirectoryEntry
* @param name the name of the new DirectoryEntry
*
* @return the new DirectoryEntry
- *
- * @exception IOException
*/
-
- public DirectoryEntry createDirectory(final String name)
- throws IOException;
+ DirectoryEntry createDirectory(final String name) throws IOException;
/**
* Gets the storage clsid of the directory entry
*
* @return storage Class ID
*/
- public ClassID getStorageClsid();
+ ClassID getStorageClsid();
/**
* Sets the storage clsid for the directory entry
*
* @param clsidStorage storage Class ID
*/
- public void setStorageClsid(ClassID clsidStorage);
-
-} // end public interface DirectoryEntry
+ void setStorageClsid(ClassID clsidStorage);
+}
diff --git a/poi/src/main/java/org/apache/poi/poifs/filesystem/DirectoryNode.java b/poi/src/main/java/org/apache/poi/poifs/filesystem/DirectoryNode.java
index e91da26fb5..a3a12eb6e9 100644
--- a/poi/src/main/java/org/apache/poi/poifs/filesystem/DirectoryNode.java
+++ b/poi/src/main/java/org/apache/poi/poifs/filesystem/DirectoryNode.java
@@ -250,20 +250,22 @@ public class DirectoryNode
* implementations of Entry.
*/
+ @Override
public Iterator<Entry> getEntries()
{
return _entries.iterator();
}
-
+
/**
* get the names of all the Entries contained directly in this
* instance (in other words, names of children only; no grandchildren
* etc).
*
* @return the names of all the entries that may be retrieved with
- * getEntry(String), which may be empty (if this
+ * getEntry(String), which may be empty (if this
* DirectoryEntry is empty)
*/
+ @Override
public Set<String> getEntryNames()
{
return _byname.keySet();
@@ -275,6 +277,7 @@ public class DirectoryNode
* @return true if this instance contains no Entry instances
*/
+ @Override
public boolean isEmpty()
{
return _entries.isEmpty();
@@ -288,11 +291,13 @@ public class DirectoryNode
* Entry instances
*/
+ @Override
public int getEntryCount()
{
return _entries.size();
}
+ @Override
public boolean hasEntry( String name )
{
return name != null && _byname.containsKey( name );
@@ -310,6 +315,7 @@ public class DirectoryNode
* name exists in this DirectoryEntry
*/
+ @Override
public Entry getEntry(final String name) throws FileNotFoundException {
Entry rval = null;
@@ -345,6 +351,7 @@ public class DirectoryNode
* @exception IOException if the document can't be created
*/
+ @Override
public DocumentEntry createDocument(final String name,
final InputStream stream)
throws IOException
@@ -364,6 +371,7 @@ public class DirectoryNode
* @exception IOException if the document can't be created
*/
+ @Override
public DocumentEntry createDocument(final String name, final int size,
final POIFSWriterListener writer)
throws IOException
@@ -381,6 +389,7 @@ public class DirectoryNode
* @exception IOException if the directory can't be created
*/
+ @Override
public DirectoryEntry createDirectory(final String name)
throws IOException
{
@@ -396,7 +405,7 @@ public class DirectoryNode
}
/**
- * Set the contents of a document, creating if needed,
+ * Set the contents of a document, creating if needed,
* otherwise updating. Returns the created / updated DocumentEntry
*
* @param name the name of the new or existing DocumentEntry
@@ -420,12 +429,13 @@ public class DirectoryNode
return existing;
}
}
-
+
/**
* Gets the storage clsid of the directory entry
*
* @return storage Class ID
*/
+ @Override
public ClassID getStorageClsid()
{
return getProperty().getStorageClsid();
@@ -436,6 +446,7 @@ public class DirectoryNode
*
* @param clsidStorage storage Class ID
*/
+ @Override
public void setStorageClsid(ClassID clsidStorage)
{
getProperty().setStorageClsid(clsidStorage);
@@ -485,6 +496,7 @@ public class DirectoryNode
* @return an array of Object; may not be null, but may be empty
*/
+ @Override
public Object [] getViewableArray()
{
return new Object[ 0 ];
@@ -497,6 +509,7 @@ public class DirectoryNode
* @return an Iterator; may not be null, but may have an empty
* back end store
*/
+ @Override
public Iterator<Object> getViewableIterator() {
List<Object> components = new ArrayList<>();
@@ -513,6 +526,7 @@ public class DirectoryNode
* a viewer should call getViewableIterator
*/
+ @Override
public boolean preferArray()
{
return false;
@@ -525,6 +539,7 @@ public class DirectoryNode
* @return short description
*/
+ @Override
public String getShortDescription()
{
return getName();
@@ -533,6 +548,7 @@ public class DirectoryNode
/**
* Returns an Iterator over all the entries
*/
+ @Override
public Iterator<Entry> iterator() {
return getEntries();
}
diff --git a/poi/src/main/java/org/apache/poi/poifs/filesystem/FilteringDirectoryNode.java b/poi/src/main/java/org/apache/poi/poifs/filesystem/FilteringDirectoryNode.java
index 717247c5b6..609578aaa9 100644
--- a/poi/src/main/java/org/apache/poi/poifs/filesystem/FilteringDirectoryNode.java
+++ b/poi/src/main/java/org/apache/poi/poifs/filesystem/FilteringDirectoryNode.java
@@ -45,13 +45,13 @@ public class FilteringDirectoryNode implements DirectoryEntry
/**
* The names of our entries to exclude
*/
- private Set<String> excludes;
+ private final Set<String> excludes;
/**
* Excludes of our child directories
*/
- private Map<String,List<String>> childExcludes;
+ private final Map<String,List<String>> childExcludes;
- private DirectoryEntry directory;
+ private final DirectoryEntry directory;
/**
* Creates a filter round the specified directory, which
@@ -88,28 +88,34 @@ public class FilteringDirectoryNode implements DirectoryEntry
}
}
+ @Override
public DirectoryEntry createDirectory(String name) throws IOException {
return directory.createDirectory(name);
}
+ @Override
public DocumentEntry createDocument(String name, InputStream stream)
throws IOException {
return directory.createDocument(name, stream);
}
+ @Override
public DocumentEntry createDocument(String name, int size,
POIFSWriterListener writer) throws IOException {
return directory.createDocument(name, size, writer);
}
+ @Override
public Iterator<Entry> getEntries() {
return new FilteringIterator();
}
+ @Override
public Iterator<Entry> iterator() {
return getEntries();
}
+ @Override
public int getEntryCount() {
int size = directory.getEntryCount();
for (String excl : excludes) {
@@ -120,6 +126,7 @@ public class FilteringDirectoryNode implements DirectoryEntry
return size;
}
+ @Override
public Set<String> getEntryNames() {
Set<String> names = new HashSet<>();
for (String name : directory.getEntryNames()) {
@@ -130,10 +137,12 @@ public class FilteringDirectoryNode implements DirectoryEntry
return names;
}
+ @Override
public boolean isEmpty() {
return (getEntryCount() == 0);
}
+ @Override
public boolean hasEntry(String name) {
if (excludes.contains(name)) {
return false;
@@ -141,6 +150,7 @@ public class FilteringDirectoryNode implements DirectoryEntry
return directory.hasEntry(name);
}
+ @Override
public Entry getEntry(String name) throws FileNotFoundException {
if (excludes.contains(name)) {
throw new FileNotFoundException(name);
@@ -158,40 +168,48 @@ public class FilteringDirectoryNode implements DirectoryEntry
return entry;
}
+ @Override
public ClassID getStorageClsid() {
return directory.getStorageClsid();
}
+ @Override
public void setStorageClsid(ClassID clsidStorage) {
directory.setStorageClsid(clsidStorage);
}
+ @Override
public boolean delete() {
return directory.delete();
}
+ @Override
public boolean renameTo(String newName) {
return directory.renameTo(newName);
}
+ @Override
public String getName() {
return directory.getName();
}
+ @Override
public DirectoryEntry getParent() {
return directory.getParent();
}
+ @Override
public boolean isDirectoryEntry() {
return true;
}
+ @Override
public boolean isDocumentEntry() {
return false;
}
private class FilteringIterator implements Iterator<Entry> {
- private Iterator<Entry> parent;
+ private final Iterator<Entry> parent;
private Entry next;
private FilteringIterator() {
@@ -209,10 +227,12 @@ public class FilteringDirectoryNode implements DirectoryEntry
}
}
+ @Override
public boolean hasNext() {
return (next != null);
}
+ @Override
public Entry next() {
if (!hasNext()) {
throw new NoSuchElementException();
@@ -223,6 +243,7 @@ public class FilteringDirectoryNode implements DirectoryEntry
return e;
}
+ @Override
public void remove() {
throw new UnsupportedOperationException("Remove not supported");
}
diff --git a/poi/src/main/java/org/apache/poi/sl/usermodel/Sheet.java b/poi/src/main/java/org/apache/poi/sl/usermodel/Sheet.java
index ae7cd179bc..347c19f23d 100644
--- a/poi/src/main/java/org/apache/poi/sl/usermodel/Sheet.java
+++ b/poi/src/main/java/org/apache/poi/sl/usermodel/Sheet.java
@@ -35,15 +35,13 @@ public interface Sheet<
* check this setting in the sheet XML
*/
boolean getFollowMasterGraphics();
-
+
MasterSheet<S,P> getMasterSheet();
Background<S,P> getBackground();
-
+
/**
* Convenience method to draw a sheet to a graphics context
- *
- * @param graphics
*/
void draw(Graphics2D graphics);
diff --git a/poi/src/main/java/org/apache/poi/ss/format/SimpleFraction.java b/poi/src/main/java/org/apache/poi/ss/format/SimpleFraction.java
index e56430cc5c..f781cd71f7 100644
--- a/poi/src/main/java/org/apache/poi/ss/format/SimpleFraction.java
+++ b/poi/src/main/java/org/apache/poi/ss/format/SimpleFraction.java
@@ -59,14 +59,13 @@ public class SimpleFraction {
* <li><a href="http://mathworld.wolfram.com/ContinuedFraction.html">
* Continued Fraction</a> equations (11) and (22)-(26)</li>
* </ul>
- * </p>
*
* Based on org.apache.commons.math.fraction.Fraction from Apache Commons-Math.
* YK: The only reason of having this class is to avoid dependency on the Commons-Math jar.
*
* @param value the double value to convert to a fraction.
* @param epsilon maximum error allowed. The resulting fraction is within
- * <code>epsilon</code> of <code>value</code>, 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.<p>
+ * 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 <code>null</code> signifying that the cell is not present (or blank)
- * @return <code>null</code> if the supplied cell is <code>null</code> 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.<p>
*
- * 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.
- * <p>
- *
*/
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 {
* <p>
* Instead we need a cached version that is discarded when definitions change.
* <p>
- * 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<String, List<EvaluationConditionalFormatRule>> formats = new HashMap<>();
-
+
/**
* Evaluating rules for cells in their region(s) is expensive, so we want to cache them,
* and empty/reevaluate the cache when values change.
@@ -76,21 +74,21 @@ public class ConditionalFormattingEvaluator {
this.workbook = wb;
this.workbookEvaluator = provider._getWorkbookEvaluator();
}
-
+
protected WorkbookEvaluator getWorkbookEvaluator() {
return workbookEvaluator;
}
-
+
/**
- * Call this whenever rules are added, reordered, or removed, or a rule formula is changed
+ * Call this whenever rules are added, reordered, or removed, or a rule formula is changed
* (not the formula inputs but the formula expression itself)
*/
public void clearAllCachedFormats() {
formats.clear();
}
-
+
/**
- * Call this whenever cell values change in the workbook, so condional formats are re-evaluated
+ * Call this whenever cell values change in the workbook, so condional formats are re-evaluated
* for all cells.
* <p>
* 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 <code>CTCfRule</code> in <code>XSSFConditionalFormattingRule</code>.
+ * not exposed from {@code CTCfRule} in {@code XSSFConditionalFormattingRule}.
* <p>
* 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.
* <p>
- * 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)}.
* <p>
* 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<EvaluationConditionalFormatRule> getConditionalFormattingForCell(final CellReference cellRef) {
List<EvaluationConditionalFormatRule> rules = values.get(cellRef);
-
+
if (rules == null) {
// compute and cache them
rules = new ArrayList<>();
-
+
final Sheet sheet;
if (cellRef.getSheetName() != null) {
sheet = workbook.getSheet(cellRef.getSheetName());
} else {
sheet = workbook.getSheetAt(workbook.getActiveSheetIndex());
}
-
+
/*
* Per Excel help:
* https://support.office.com/en-us/article/Manage-conditional-formatting-rule-precedence-e09711a3-48df-4bcb-b82c-9d8b8b22463d#__toc269129417
@@ -176,7 +174,7 @@ public class ConditionalFormattingEvaluator {
*/
boolean stopIfTrue = false;
for (EvaluationConditionalFormatRule rule : getRules(sheet)) {
-
+
if (stopIfTrue) {
continue; // a previous rule matched and wants no more evaluations
}
@@ -189,40 +187,40 @@ public class ConditionalFormattingEvaluator {
Collections.sort(rules);
values.put(cellRef, rules);
}
-
+
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 <code>CTCfRule</code> in <code>XSSFConditionalFormattingRule</code>.
+ * not exposed from {@code CTCfRule} in {@code XSSFConditionalFormattingRule}.
* <p>
* 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.
* <p>
- * 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)}.
* <p>
* 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<EvaluationConditionalFormatRule> getConditionalFormattingForCell(Cell cell) {
return getConditionalFormattingForCell(getRef(cell));
}
-
+
public static CellReference getRef(Cell cell) {
return new CellReference(cell.getSheet().getSheetName(), cell.getRowIndex(), cell.getColumnIndex(), false, false);
}
-
+
/**
* Retrieve all formatting rules for the sheet with the given name.
*
@@ -232,7 +230,7 @@ public class ConditionalFormattingEvaluator {
public List<EvaluationConditionalFormatRule> getFormatRulesForSheet(String sheetName) {
return getFormatRulesForSheet(workbook.getSheet(sheetName));
}
-
+
/**
* Retrieve all formatting rules for the given sheet.
*
@@ -242,7 +240,7 @@ public class ConditionalFormattingEvaluator {
public List<EvaluationConditionalFormatRule> getFormatRulesForSheet(Sheet sheet) {
return getRules(sheet);
}
-
+
/**
* Conditional formatting rules can apply only to cells in the sheet to which they are attached.
* The POI data model does not have a back-reference to the owning sheet, so it must be passed in separately.
@@ -262,7 +260,7 @@ public class ConditionalFormattingEvaluator {
}
return Collections.emptyList();
}
-
+
/**
* Retrieve all cells where the given formatting rule evaluates to true.
*
@@ -272,7 +270,7 @@ public class ConditionalFormattingEvaluator {
public List<Cell> getMatchingCells(EvaluationConditionalFormatRule rule) {
final List<Cell> cells = new ArrayList<>();
final Sheet sheet = rule.getSheet();
-
+
for (CellRangeAddress region : rule.getRegions()) {
for (int r = region.getFirstRow(); r <= region.getLastRow(); r++) {
final Row row = sheet.getRow(r);
@@ -284,7 +282,7 @@ public class ConditionalFormattingEvaluator {
if (cell == null) {
continue;
}
-
+
List<EvaluationConditionalFormatRule> cellRules = getConditionalFormattingForCell(cell);
if (cellRules.contains(rule)) {
cells.add(cell);
diff --git a/poi/src/main/java/org/apache/poi/ss/formula/EvaluationConditionalFormatRule.java b/poi/src/main/java/org/apache/poi/ss/formula/EvaluationConditionalFormatRule.java
index afb4a09f9d..b1c3504f2b 100644
--- a/poi/src/main/java/org/apache/poi/ss/formula/EvaluationConditionalFormatRule.java
+++ b/poi/src/main/java/org/apache/poi/ss/formula/EvaluationConditionalFormatRule.java
@@ -29,6 +29,7 @@ import java.util.Locale;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
+import java.util.function.Function;
import org.apache.poi.ss.formula.eval.BlankEval;
import org.apache.poi.ss.formula.eval.BoolEval;
@@ -102,12 +103,7 @@ public class EvaluationConditionalFormatRule implements Comparable<EvaluationCon
private final DecimalFormat decimalTextFormat;
/**
- *
- * @param workbookEvaluator
- * @param sheet
- * @param formatting
* @param formattingIndex for priority, zero based
- * @param rule
* @param ruleIndex for priority, zero based, if this is an HSSF rule. Unused for XSSF rules
* @param regions could be read from formatting, but every call creates new objects in a new array.
* this allows calling it once per formatting instance, and re-using the array.
@@ -241,7 +237,6 @@ public class EvaluationConditionalFormatRule implements Comparable<EvaluationCon
/**
* Defined as equal sheet name and formatting and rule indexes
- * @see java.lang.Object#equals(java.lang.Object)
*/
@Override
public boolean equals(Object obj) {
@@ -263,7 +258,6 @@ public class EvaluationConditionalFormatRule implements Comparable<EvaluationCon
* <p>
* HSSF priority is based on definition/persistence order.
*
- * @param o
* @return comparison based on sheet name, formatting index, and rule priority
*/
@Override
@@ -294,7 +288,6 @@ public class EvaluationConditionalFormatRule implements Comparable<EvaluationCon
}
/**
- * @param ref
* @return true if this rule evaluates to true for the given cell
*/
/* package */ boolean matches(CellReference ref) {
@@ -448,74 +441,15 @@ public class EvaluationConditionalFormatRule implements Comparable<EvaluationCon
return false;
}
- return getMeaningfulValues(region, false, new ValueFunction() {
- @Override
- public Set<ValueAndFormat> evaluate(List<ValueAndFormat> allValues) {
- final ConditionFilterData conf = rule.getFilterConfiguration();
-
- if (! conf.getBottom()) {
- allValues.sort(Collections.reverseOrder());
- } else {
- Collections.sort(allValues);
- }
-
- int limit = Math.toIntExact(conf.getRank());
- if (conf.getPercent()) {
- limit = allValues.size() * limit / 100;
- }
- if (allValues.size() <= limit) {
- return new HashSet<>(allValues);
- }
-
- return new HashSet<>(allValues.subList(0, limit));
- }
- }).contains(cv);
+ return getMeaningfulValues(region, false, this::evaluateTop10).contains(cv);
case UNIQUE_VALUES:
// Per Excel help, "duplicate" means matching value AND format
// https://support.office.com/en-us/article/Filter-for-unique-values-or-remove-duplicate-values-ccf664b0-81d6-449b-bbe1-8daaec1e83c2
- return getMeaningfulValues(region, true, new ValueFunction() {
- @Override
- public Set<ValueAndFormat> evaluate(List<ValueAndFormat> allValues) {
- Collections.sort(allValues);
-
- final Set<ValueAndFormat> unique = new HashSet<>();
-
- for (int i = 0; i < allValues.size(); i++) {
- final ValueAndFormat v = allValues.get(i);
- // skip this if the current value matches the next one, or is the last one and matches the previous one
- if ( (i < allValues.size()-1 && v.equals(allValues.get(i+1)) ) || ( i > 0 && i == allValues.size()-1 && v.equals(allValues.get(i-1)) ) ) {
- // current value matches next value, skip both
- i++;
- continue;
- }
- unique.add(v);
- }
-
- return unique;
- }
- }).contains(cv);
+ return getMeaningfulValues(region, true, this::evaluateUniqueValues).contains(cv);
case DUPLICATE_VALUES:
// Per Excel help, "duplicate" means matching value AND format
// https://support.office.com/en-us/article/Filter-for-unique-values-or-remove-duplicate-values-ccf664b0-81d6-449b-bbe1-8daaec1e83c2
- return getMeaningfulValues(region, true, new ValueFunction() {
- @Override
- public Set<ValueAndFormat> evaluate(List<ValueAndFormat> allValues) {
- Collections.sort(allValues);
-
- final Set<ValueAndFormat> dup = new HashSet<>();
-
- for (int i = 0; i < allValues.size(); i++) {
- final ValueAndFormat v = allValues.get(i);
- // skip this if the current value matches the next one, or is the last one and matches the previous one
- if ( (i < allValues.size()-1 && v.equals(allValues.get(i+1)) ) || ( i > 0 && i == allValues.size()-1 && v.equals(allValues.get(i-1)) ) ) {
- // current value matches next value, add one
- dup.add(v);
- i++;
- }
- }
- return dup;
- }
- }).contains(cv);
+ return getMeaningfulValues(region, true, this::evaluateDuplicateValues).contains(cv);
case ABOVE_AVERAGE:
// from testing, Excel only operates on numbers and dates (which are stored as numbers) in the range.
// numbers stored as text are ignored, but numbers formatted as text are treated as numbers.
@@ -523,33 +457,15 @@ public class EvaluationConditionalFormatRule implements Comparable<EvaluationCon
final ConditionFilterData conf = rule.getFilterConfiguration();
// actually ordered, so iteration order is predictable
- List<ValueAndFormat> values = new ArrayList<>(getMeaningfulValues(region, false, new ValueFunction() {
- @Override
- public Set<ValueAndFormat> evaluate(List<ValueAndFormat> allValues) {
- double total = 0;
- ValueEval[] pop = new ValueEval[allValues.size()];
- for (int i = 0; i < allValues.size(); i++) {
- ValueAndFormat v = allValues.get(i);
- total += v.value.doubleValue();
- pop[i] = new NumberEval(v.value.doubleValue());
- }
-
- final Set<ValueAndFormat> avgSet = new LinkedHashSet<>(1);
- avgSet.add(new ValueAndFormat(Double.valueOf(allValues.size() == 0 ? 0 : total / allValues.size()), null, decimalTextFormat));
-
- final double stdDev = allValues.size() <= 1 ? 0 : ((NumberEval) AggregateFunction.STDEV.evaluate(pop, 0, 0)).getNumberValue();
- avgSet.add(new ValueAndFormat(Double.valueOf(stdDev), null, decimalTextFormat));
- return avgSet;
- }
- }));
+ List<ValueAndFormat> values = new ArrayList<>(getMeaningfulValues(region, false, this::evaluateAboveAverage));
Double val = cv.isNumber() ? cv.getValue() : null;
if (val == null) {
return false;
}
- double avg = values.get(0).value.doubleValue();
- double stdDev = values.get(1).value.doubleValue();
+ double avg = values.get(0).value;
+ double stdDev = values.get(1).value;
/*
* use StdDev, aboveAverage, equalAverage to find:
@@ -557,7 +473,7 @@ public class EvaluationConditionalFormatRule implements Comparable<EvaluationCon
* operator type
*/
- Double comp = Double.valueOf(conf.getStdDev() > 0 ? (avg + (conf.getAboveAverage() ? 1 : -1) * stdDev * conf.getStdDev()) : avg) ;
+ Double comp = conf.getStdDev() > 0 ? (avg + (conf.getAboveAverage() ? 1 : -1) * stdDev * conf.getStdDev()) : avg;
final OperatorEnum op;
if (conf.getAboveAverage()) {
@@ -576,10 +492,10 @@ public class EvaluationConditionalFormatRule implements Comparable<EvaluationCon
return op.isValid(val, comp, null);
case CONTAINS_TEXT:
// implemented both by a cfRule "text" attribute and a formula. Use the text.
- return text == null ? false : cv.toString().toLowerCase(LocaleUtil.getUserLocale()).contains(lowerText);
+ return text != null && cv.toString().toLowerCase(LocaleUtil.getUserLocale()).contains(lowerText);
case NOT_CONTAINS_TEXT:
// implemented both by a cfRule "text" attribute and a formula. Use the text.
- return text == null ? true : ! cv.toString().toLowerCase(LocaleUtil.getUserLocale()).contains(lowerText);
+ return text == null || !cv.toString().toLowerCase(LocaleUtil.getUserLocale()).contains(lowerText);
case BEGINS_WITH:
// implemented both by a cfRule "text" attribute and a formula. Use the text.
return cv.toString().toLowerCase(LocaleUtil.getUserLocale()).startsWith(lowerText);
@@ -616,14 +532,88 @@ public class EvaluationConditionalFormatRule implements Comparable<EvaluationCon
}
}
+ private Set<ValueAndFormat> evaluateTop10(List<ValueAndFormat> allValues) {
+ final ConditionFilterData conf = rule.getFilterConfiguration();
+
+ if (! conf.getBottom()) {
+ allValues.sort(Collections.reverseOrder());
+ } else {
+ Collections.sort(allValues);
+ }
+
+ int limit = Math.toIntExact(conf.getRank());
+ if (conf.getPercent()) {
+ limit = allValues.size() * limit / 100;
+ }
+ if (allValues.size() <= limit) {
+ return new HashSet<>(allValues);
+ }
+
+ return new HashSet<>(allValues.subList(0, limit));
+ }
+
+ private Set<ValueAndFormat> evaluateUniqueValues(List<ValueAndFormat> allValues) {
+ Collections.sort(allValues);
+
+ final Set<ValueAndFormat> unique = new HashSet<>();
+
+ for (int i = 0; i < allValues.size(); i++) {
+ final ValueAndFormat v = allValues.get(i);
+ // skip this if the current value matches the next one, or is the last one and matches the previous one
+ if ( (i < allValues.size()-1 && v.equals(allValues.get(i+1)) ) || ( i > 0 && i == allValues.size()-1 && v.equals(allValues.get(i-1)) ) ) {
+ // current value matches next value, skip both
+ i++;
+ continue;
+ }
+ unique.add(v);
+ }
+
+ return unique;
+ }
+
+ public Set<ValueAndFormat> evaluateDuplicateValues(List<ValueAndFormat> allValues) {
+ Collections.sort(allValues);
+
+ final Set<ValueAndFormat> dup = new HashSet<>();
+
+ for (int i = 0; i < allValues.size(); i++) {
+ final ValueAndFormat v = allValues.get(i);
+ // skip this if the current value matches the next one, or is the last one and matches the previous one
+ if ( (i < allValues.size()-1 && v.equals(allValues.get(i+1)) ) || ( i > 0 && i == allValues.size()-1 && v.equals(allValues.get(i-1)) ) ) {
+ // current value matches next value, add one
+ dup.add(v);
+ i++;
+ }
+ }
+ return dup;
+ }
+
+ private Set<ValueAndFormat> evaluateAboveAverage(List<ValueAndFormat> allValues) {
+ double total = 0;
+ ValueEval[] pop = new ValueEval[allValues.size()];
+ for (int i = 0; i < allValues.size(); i++) {
+ ValueAndFormat v = allValues.get(i);
+ total += v.value;
+ pop[i] = new NumberEval(v.value);
+ }
+
+ final Set<ValueAndFormat> avgSet = new LinkedHashSet<>(1);
+ avgSet.add(new ValueAndFormat(allValues.size() == 0 ? 0 : total / allValues.size(), null, decimalTextFormat));
+
+ final double stdDev = allValues.size() <= 1 ? 0 : ((NumberEval) AggregateFunction.STDEV.evaluate(pop, 0, 0)).getNumberValue();
+ avgSet.add(new ValueAndFormat(stdDev, null, decimalTextFormat));
+ return avgSet;
+ }
+
/**
* from testing, Excel only operates on numbers and dates (which are stored as numbers) in the range.
* numbers stored as text are ignored, but numbers formatted as text are treated as numbers.
*
- * @param region
+ * @param func instances evaluate the values for a region and return the positive matches for the function type.
+ *
* @return the meaningful values in the range of cells specified
*/
- private Set<ValueAndFormat> getMeaningfulValues(CellRangeAddress region, boolean withText, ValueFunction func) {
+ private Set<ValueAndFormat> getMeaningfulValues(CellRangeAddress region, boolean withText, Function<List<ValueAndFormat>,Set<ValueAndFormat>> func) {
Set<ValueAndFormat> values = meaningfulRegionValues.get(region);
if (values != null) {
return values;
@@ -645,7 +635,7 @@ public class EvaluationConditionalFormatRule implements Comparable<EvaluationCon
}
}
- values = func.evaluate(allValues);
+ values = func.apply(allValues);
meaningfulRegionValues.put(region, values);
return values;
@@ -660,7 +650,7 @@ public class EvaluationConditionalFormatRule implements Comparable<EvaluationCon
}
switch (type) {
case NUMERIC:
- return new ValueAndFormat(Double.valueOf(cell.getNumericCellValue()), format, decimalTextFormat);
+ return new ValueAndFormat(cell.getNumericCellValue(), format, decimalTextFormat);
case STRING:
case BOOLEAN:
return new ValueAndFormat(cell.getStringCellValue(), format);
@@ -670,192 +660,6 @@ public class EvaluationConditionalFormatRule implements Comparable<EvaluationCon
}
return new ValueAndFormat("", "");
}
- /**
- * instances evaluate the values for a region and return the positive matches for the function type.
- * TODO: when we get to use Java 8, this is obviously a Lambda Function.
- */
- protected interface ValueFunction {
-
- /**
- *
- * @param values
- * @return the desired values for the rules implemented by the current instance
- */
- Set<ValueAndFormat> evaluate(List<ValueAndFormat> values);
- }
-
- /**
- * 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.
- */
- public static enum OperatorEnum {
- NO_COMPARISON {
- /** always false/invalid */
- @Override
- public <C extends Comparable<C>> boolean isValid(C cellValue, C v1, C v2) {
- return false;
- }
- },
- BETWEEN {
- @Override
- public <C extends Comparable<C>> boolean isValid(C cellValue, C v1, C v2) {
- if (v1 == null) {
- if (cellValue instanceof Number) {
- // use zero for null
- double n1 = 0;
- double n2 = v2 == null ? 0 : ((Number) v2).doubleValue();
- return Double.compare( ((Number) cellValue).doubleValue(), n1) >= 0 && Double.compare(((Number) cellValue).doubleValue(), n2) <= 0;
- } else if (cellValue instanceof String) {
- String n1 = "";
- String n2 = v2 == null ? "" : (String) v2;
- return ((String) cellValue).compareToIgnoreCase(n1) >= 0 && ((String) cellValue).compareToIgnoreCase(n2) <= 0;
- } else if (cellValue instanceof Boolean) return false;
- return false; // just in case - not a typical possibility
- }
- return cellValue.compareTo(v1) >= 0 && cellValue.compareTo(v2) <= 0;
- }
- },
- NOT_BETWEEN {
- @Override
- public <C extends Comparable<C>> boolean isValid(C cellValue, C v1, C v2) {
- if (v1 == null) {
- if (cellValue instanceof Number) {
- // use zero for null
- double n1 = 0;
- double n2 = v2 == null ? 0 : ((Number) v2).doubleValue();
- return Double.compare( ((Number) cellValue).doubleValue(), n1) < 0 || Double.compare(((Number) cellValue).doubleValue(), n2) > 0;
- } else if (cellValue instanceof String) {
- String n1 = "";
- String n2 = v2 == null ? "" : (String) v2;
- return ((String) cellValue).compareToIgnoreCase(n1) < 0 || ((String) cellValue).compareToIgnoreCase(n2) > 0;
- } else if (cellValue instanceof Boolean) return true;
- return false; // just in case - not a typical possibility
- }
- return cellValue.compareTo(v1) < 0 || cellValue.compareTo(v2) > 0;
- }
-
- public boolean isValidForIncompatibleTypes() {
- return true;
- }
- },
- EQUAL {
- @Override
- public <C extends Comparable<C>> boolean isValid(C cellValue, C v1, C v2) {
- if (v1 == null) {
- if (cellValue instanceof Number) {
- // use zero for null
- return Double.compare( ((Number) cellValue).doubleValue(), 0) == 0;
- } else if (cellValue instanceof String) {
- return false; // even an empty string is not equal the empty cell, only another empty cell is, handled higher up
- } else if (cellValue instanceof Boolean) return false;
- return false; // just in case - not a typical possibility
- }
- // need to avoid instanceof, to work around a 1.6 compiler bug
- if (cellValue.getClass() == String.class) {
- return cellValue.toString().compareToIgnoreCase(v1.toString()) == 0;
- }
- return cellValue.compareTo(v1) == 0;
- }
- },
- NOT_EQUAL {
- @Override
- public <C extends Comparable<C>> boolean isValid(C cellValue, C v1, C v2) {
- if (v1 == null) {
- return true; // non-null not equal null, returns true
- }
- // need to avoid instanceof, to work around a 1.6 compiler bug
- if (cellValue.getClass() == String.class) {
- return cellValue.toString().compareToIgnoreCase(v1.toString()) == 0;
- }
- return cellValue.compareTo(v1) != 0;
- }
-
- public boolean isValidForIncompatibleTypes() {
- return true;
- }
- },
- GREATER_THAN {
- @Override
- public <C extends Comparable<C>> boolean isValid(C cellValue, C v1, C v2) {
- if (v1 == null) {
- if (cellValue instanceof Number) {
- // use zero for null
- return Double.compare( ((Number) cellValue).doubleValue(), 0) > 0;
- } else if (cellValue instanceof String) {
- return true; // non-null string greater than empty cell
- } else if (cellValue instanceof Boolean) return true;
- return false; // just in case - not a typical possibility
- }
- return cellValue.compareTo(v1) > 0;
- }
- },
- LESS_THAN {
- @Override
- public <C extends Comparable<C>> boolean isValid(C cellValue, C v1, C v2) {
- if (v1 == null) {
- if (cellValue instanceof Number) {
- // use zero for null
- return Double.compare( ((Number) cellValue).doubleValue(), 0) < 0;
- } else if (cellValue instanceof String) {
- return false; // non-null string greater than empty cell
- } else if (cellValue instanceof Boolean) return false;
- return false; // just in case - not a typical possibility
- }
- return cellValue.compareTo(v1) < 0;
- }
- },
- GREATER_OR_EQUAL {
- @Override
- public <C extends Comparable<C>> boolean isValid(C cellValue, C v1, C v2) {
- if (v1 == null) {
- if (cellValue instanceof Number) {
- // use zero for null
- return Double.compare( ((Number) cellValue).doubleValue(), 0) >= 0;
- } else if (cellValue instanceof String) {
- return true; // non-null string greater than empty cell
- } else if (cellValue instanceof Boolean) return true;
- return false; // just in case - not a typical possibility
- }
- return cellValue.compareTo(v1) >= 0;
- }
- },
- LESS_OR_EQUAL {
- @Override
- public <C extends Comparable<C>> boolean isValid(C cellValue, C v1, C v2) {
- if (v1 == null) {
- if (cellValue instanceof Number) {
- // use zero for null
- return Double.compare( ((Number) cellValue).doubleValue(), 0) <= 0;
- } else if (cellValue instanceof String) {
- return false; // non-null string not less than empty cell
- } else if (cellValue instanceof Boolean) return false; // for completeness
- return false; // just in case - not a typical possibility
- }
- return cellValue.compareTo(v1) <= 0;
- }
- },
- ;
-
- /**
- * Evaluates comparison using operator instance rules
- * @param cellValue won't be null, assumption is previous checks handled that
- * @param v1 if null, per Excel behavior various results depending on the type of cellValue and the specific enum instance
- * @param v2 null if not needed. If null when needed, various results, per Excel behavior
- * @return true if the comparison is valid
- */
- public abstract <C extends Comparable<C>> boolean isValid(C cellValue, C v1, C v2);
-
- /**
- * Called when the cell and comparison values are of different data types
- * Needed for negation operators, which should return true.
- * @return true if this comparison is true when the types to compare are different
- */
- public boolean isValidForIncompatibleTypes() {
- return false;
- }
- }
/**
* Note: this class has a natural ordering that is inconsistent with equals.
@@ -914,7 +718,6 @@ public class EvaluationConditionalFormatRule implements Comparable<EvaluationCon
/**
* Note: this class has a natural ordering that is inconsistent with equals.
- * @param o
* @return value comparison
*/
@Override
diff --git a/poi/src/main/java/org/apache/poi/ss/formula/EvaluationSheet.java b/poi/src/main/java/org/apache/poi/ss/formula/EvaluationSheet.java
index 885ba81985..f9d7cd053a 100644
--- a/poi/src/main/java/org/apache/poi/ss/formula/EvaluationSheet.java
+++ b/poi/src/main/java/org/apache/poi/ss/formula/EvaluationSheet.java
@@ -26,7 +26,7 @@ import org.apache.poi.util.Internal;
public interface EvaluationSheet {
/**
- * @return <code>null</code> if there is no cell at the specified coordinates
+ * @return {@code null} if there is no cell at the specified coordinates
*/
EvaluationCell getCell(int rowIndex, int columnIndex);
@@ -37,19 +37,18 @@ public interface EvaluationSheet {
* @see EvaluationWorkbook#clearAllCachedResultValues()
* @since POI 3.15 beta 3
*/
- public void clearAllCachedResultValues();
+ void clearAllCachedResultValues();
/**
* @return last row index referenced on this sheet, for evaluation optimization
* @since POI 4.0.0
*/
- public int getLastRowNum();
+ int getLastRowNum();
/**
* Used by SUBTOTAL and similar functions that have options to ignore hidden rows
- * @param rowIndex
* @return true if the row is hidden, false if not
* @since POI 4.1.0
*/
- public boolean isRowHidden(int rowIndex);
+ boolean isRowHidden(int rowIndex);
}
diff --git a/poi/src/main/java/org/apache/poi/ss/formula/FormulaType.java b/poi/src/main/java/org/apache/poi/ss/formula/FormulaType.java
index fa154e6d42..5986132b29 100644
--- a/poi/src/main/java/org/apache/poi/ss/formula/FormulaType.java
+++ b/poi/src/main/java/org/apache/poi/ss/formula/FormulaType.java
@@ -21,59 +21,58 @@ import org.apache.poi.util.Internal;
/**
* Enumeration of various formula types.
- *
+ *
* See Sections 3 and 4.8 of https://www.openoffice.org/sc/excelfileformat.pdf
*/
@Internal
public enum FormulaType {
/** Regular cell formula */
CELL(true),
-
+
/**
* A Shared Formula ("{=SUM(A1:E1*{1,2,3,4,5}}")
- *
+ *
* Similar to an array formula, but stored in a SHAREDFMLA instead of ARRAY record as a file size optimization.
* See Section 4.8 of https://www.openoffice.org/sc/excelfileformat.pdf
*/
SHARED(true),
-
+
/**
* An Array formula ("{=SUM(A1:E1*{1,2,3,4,5}}")
* https://support.office.com/en-us/article/Guidelines-and-examples-of-array-formulas-7D94A64E-3FF3-4686-9372-ECFD5CAA57C7
*/
ARRAY(false),
-
+
/** Conditional formatting */
CONDFORMAT(true),
-
+
/** Named range */
NAMEDRANGE(false),
-
+
/**
* This constant is currently very specific. The exact differences from general data
* validation formulas or conditional format formulas is not known yet
*/
DATAVALIDATION_LIST(false);
-
+
/** formula is expected to return a single value vs. multiple values */
private final boolean isSingleValue ;
/**
* @since POI 3.15 beta 3.
*/
- private FormulaType(boolean singleValue) {
+ FormulaType(boolean singleValue) {
this.isSingleValue = singleValue;
}
-
+
/**
* @return true if this formula type only returns single values, false if it can return multiple values (arrays, ranges, etc.)
*/
public boolean isSingleValue() {
return isSingleValue;
}
-
+
/**
- * Used to transition from <code>int</code>s (possibly stored in the Excel file) to <code>FormulaType</code>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 {
+ <C extends Comparable<C>> boolean isValid(C cellValue, C v1, C v2);
+ }
+
+ private final CompareOp compareOp;
+ private final boolean validForIncompatibleTypes;
+
+ OperatorEnum(CompareOp compareOp, boolean validForIncompatibleTypes) {
+ this.compareOp = compareOp;
+ this.validForIncompatibleTypes = validForIncompatibleTypes;
+ }
+
+ /**
+ * Evaluates comparison using operator instance rules
+ * @param cellValue won't be null, assumption is previous checks handled that
+ * @param v1 if null, per Excel behavior various results depending on the type of cellValue and the specific enum instance
+ * @param v2 null if not needed. If null when needed, various results, per Excel behavior
+ * @return true if the comparison is valid
+ */
+ <C extends Comparable<C>> boolean isValid(C cellValue, C v1, C v2) {
+ return compareOp.isValid(cellValue, v1, v2);
+ }
+
+ /**
+ * Called when the cell and comparison values are of different data types
+ * Needed for negation operators, which should return true.
+ * @return true if this comparison is true when the types to compare are different
+ */
+ boolean isValidForIncompatibleTypes() {
+ return validForIncompatibleTypes;
+ }
+
+ private static <C extends Comparable<C>> boolean noComp(C cellValue, C v1, C v2) {
+ return false;
+ }
+
+ private static <C extends Comparable<C>> boolean between(C cellValue, C v1, C v2) {
+ if (v1 == null) {
+ if (cellValue instanceof Number) {
+ // use zero for null
+ double n1 = 0;
+ double n2 = v2 == null ? 0 : ((Number) v2).doubleValue();
+ return Double.compare( ((Number) cellValue).doubleValue(), n1) >= 0 && Double.compare(((Number) cellValue).doubleValue(), n2) <= 0;
+ } else if (cellValue instanceof String) {
+ String n1 = "";
+ String n2 = v2 == null ? "" : (String) v2;
+ return ((String) cellValue).compareToIgnoreCase(n1) >= 0 && ((String) cellValue).compareToIgnoreCase(n2) <= 0;
+ } else if (cellValue instanceof Boolean) return false;
+ return false; // just in case - not a typical possibility
+ }
+ return cellValue.compareTo(v1) >= 0 && cellValue.compareTo(v2) <= 0;
+ }
+
+ private static <C extends Comparable<C>> boolean notBetween(C cellValue, C v1, C v2) {
+ if (v1 == null) {
+ if (cellValue instanceof Number) {
+ // use zero for null
+ double n1 = 0;
+ double n2 = v2 == null ? 0 : ((Number) v2).doubleValue();
+ return Double.compare( ((Number) cellValue).doubleValue(), n1) < 0 || Double.compare(((Number) cellValue).doubleValue(), n2) > 0;
+ } else if (cellValue instanceof String) {
+ String n1 = "";
+ String n2 = v2 == null ? "" : (String) v2;
+ return ((String) cellValue).compareToIgnoreCase(n1) < 0 || ((String) cellValue).compareToIgnoreCase(n2) > 0;
+ } else {
+ // just in case - not a typical possibility
+ return cellValue instanceof Boolean;
+ }
+ }
+ return cellValue.compareTo(v1) < 0 || cellValue.compareTo(v2) > 0;
+ }
+
+ private static <C extends Comparable<C>> boolean equal(C cellValue, C v1, C v2) {
+ if (v1 == null) {
+ if (cellValue instanceof Number) {
+ // use zero for null
+ return Double.compare( ((Number) cellValue).doubleValue(), 0) == 0;
+ } else if (cellValue instanceof String) {
+ return false; // even an empty string is not equal the empty cell, only another empty cell is, handled higher up
+ } else if (cellValue instanceof Boolean) return false;
+ return false; // just in case - not a typical possibility
+ }
+ // need to avoid instanceof, to work around a 1.6 compiler bug
+ if (cellValue.getClass() == String.class) {
+ return cellValue.toString().compareToIgnoreCase(v1.toString()) == 0;
+ }
+ return cellValue.compareTo(v1) == 0;
+ }
+
+ private static <C extends Comparable<C>> boolean notEqual(C cellValue, C v1, C v2) {
+ if (v1 == null) {
+ return true; // non-null not equal null, returns true
+ }
+ // need to avoid instanceof, to work around a 1.6 compiler bug
+ if (cellValue.getClass() == String.class) {
+ return cellValue.toString().compareToIgnoreCase(v1.toString()) == 0;
+ }
+ return cellValue.compareTo(v1) != 0;
+ }
+
+ private static <C extends Comparable<C>> boolean greaterThan(C cellValue, C v1, C v2) {
+ if (v1 == null) {
+ if (cellValue instanceof Number) {
+ // use zero for null
+ return Double.compare( ((Number) cellValue).doubleValue(), 0) > 0;
+ } else if (cellValue instanceof String) {
+ return true; // non-null string greater than empty cell
+ } else {
+ // just in case - not a typical possibility
+ return cellValue instanceof Boolean;
+ }
+ }
+ return cellValue.compareTo(v1) > 0;
+ }
+
+ private static <C extends Comparable<C>> boolean lessThan(C cellValue, C v1, C v2) {
+ if (v1 == null) {
+ if (cellValue instanceof Number) {
+ // use zero for null
+ return Double.compare( ((Number) cellValue).doubleValue(), 0) < 0;
+ } else if (cellValue instanceof String) {
+ return false; // non-null string greater than empty cell
+ } else if (cellValue instanceof Boolean) return false;
+ return false; // just in case - not a typical possibility
+ }
+ return cellValue.compareTo(v1) < 0;
+ }
+
+ private static <C extends Comparable<C>> boolean greaterOrEqual(C cellValue, C v1, C v2) {
+ if (v1 == null) {
+ if (cellValue instanceof Number) {
+ // use zero for null
+ return Double.compare( ((Number) cellValue).doubleValue(), 0) >= 0;
+ } else if (cellValue instanceof String) {
+ return true; // non-null string greater than empty cell
+ } else {
+ // just in case - not a typical possibility
+ return cellValue instanceof Boolean;
+ }
+ }
+ return cellValue.compareTo(v1) >= 0;
+ }
+
+ private static <C extends Comparable<C>> boolean lessOrEqual(C cellValue, C v1, C v2) {
+ if (v1 == null) {
+ if (cellValue instanceof Number) {
+ // use zero for null
+ return Double.compare( ((Number) cellValue).doubleValue(), 0) <= 0;
+ } else if (cellValue instanceof String) {
+ return false; // non-null string not less than empty cell
+ } else if (cellValue instanceof Boolean) return false; // for completeness
+ return false; // just in case - not a typical possibility
+ }
+ return cellValue.compareTo(v1) <= 0;
+ }
+
+}
diff --git a/poi/src/main/java/org/apache/poi/ss/formula/SharedFormula.java b/poi/src/main/java/org/apache/poi/ss/formula/SharedFormula.java
index ed7e58b3bd..aca085565e 100644
--- a/poi/src/main/java/org/apache/poi/ss/formula/SharedFormula.java
+++ b/poi/src/main/java/org/apache/poi/ss/formula/SharedFormula.java
@@ -38,8 +38,6 @@ public class SharedFormula {
* were it not shared.
*
* @param ptgs parsed tokens of the shared formula
- * @param formulaRow
- * @param formulaColumn
*/
public Ptg[] convertSharedFormulas(Ptg[] ptgs, int formulaRow, int formulaColumn) {
@@ -72,9 +70,8 @@ public class SharedFormula {
} else if (ptg instanceof OperandPtg) {
// Any subclass of OperandPtg is mutable, so it's safest to not share these instances.
ptg = ((OperandPtg) ptg).copy();
- } else {
- // all other Ptgs are immutable and can be shared
}
+ // all other Ptgs are immutable and can be shared
newPtgStack[k] = ptg;
}
return newPtgStack;
diff --git a/poi/src/main/java/org/apache/poi/ss/formula/TwoDEval.java b/poi/src/main/java/org/apache/poi/ss/formula/TwoDEval.java
index f3c8c974f5..8f347ff10e 100644
--- a/poi/src/main/java/org/apache/poi/ss/formula/TwoDEval.java
+++ b/poi/src/main/java/org/apache/poi/ss/formula/TwoDEval.java
@@ -38,25 +38,27 @@ public interface TwoDEval extends ValueEval {
int getHeight();
/**
- * @return <code>true</code> 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 <code>true</code> 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.<p>
+ * 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
- * <code>null</code> (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 <code>null</code> (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 '%'. <p>
+ * 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<RowColKey>{
private final int _rowIndex;
diff --git a/poi/src/main/java/org/apache/poi/ss/formula/functions/Bin2Dec.java b/poi/src/main/java/org/apache/poi/ss/formula/functions/Bin2Dec.java
index e2c5100a97..1ad45ea75e 100644
--- a/poi/src/main/java/org/apache/poi/ss/formula/functions/Bin2Dec.java
+++ b/poi/src/main/java/org/apache/poi/ss/formula/functions/Bin2Dec.java
@@ -24,7 +24,7 @@ import org.apache.poi.ss.formula.eval.RefEval;
import org.apache.poi.ss.formula.eval.ValueEval;
/**
- * Implementation for Excel Bin2Dec() function.<p>
+ * Implementation for Excel Bin2Dec() function.
* <p>
* <b>Syntax</b>:<br> <b>Bin2Dec </b>(<b>number</b>)<br>
* <p>
@@ -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.<p>
+ * Implementation for Excel CODE () function.
* <p>
* <b>Syntax</b>:<br> <b>CODE </b>(<b>text</b> )<br>
* <p>
@@ -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.<p>
+ * Implementation for Excel COMPLEX () function.
* <p>
* <b>Syntax</b>:<br> <b>COMPLEX </b>(<b>real_num</b>,<b>i_num</b>,<b>suffix </b> )<br>
* <p>
* Converts real and imaginary coefficients into a complex number of the form x + yi or x + yj.
* <p>
- * <p>
* 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;
* <b>real_num</b> The real coefficient of the complex number.
* If this argument is nonnumeric, this function returns the #VALUE! error value.
* <p>
- * <p>
* <b>i_num</b> The imaginary coefficient of the complex number.
* If this argument is nonnumeric, this function returns the #VALUE! error value.
* <p>
- * <p>
* <b>suffix</b> The suffix for the imaginary component of the complex number.
* <ul>
* <li>If omitted, suffix is assumed to be "i".</li>
@@ -59,10 +56,12 @@ public class Complex extends Var2or3ArgFunction implements FreeRefFunction {
public static final String DEFAULT_SUFFIX = "i";
public static final String SUPPORTED_SUFFIX = "j";
+ @Override
public ValueEval evaluate(int srcRowIndex, int srcColumnIndex, ValueEval real_num, ValueEval i_num) {
return this.evaluate(srcRowIndex, srcColumnIndex, real_num, i_num, new StringEval(DEFAULT_SUFFIX));
}
+ @Override
public ValueEval evaluate(int srcRowIndex, int srcColumnIndex, ValueEval real_num, ValueEval i_num, ValueEval suffix) {
ValueEval veText1;
try {
@@ -135,6 +134,7 @@ public class Complex extends Var2or3ArgFunction implements FreeRefFunction {
return (number == Math.floor(number)) && !Double.isInfinite(number);
}
+ @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/DateValue.java b/poi/src/main/java/org/apache/poi/ss/formula/functions/DateValue.java
index e4f9aa0d64..57a6733f6e 100644
--- a/poi/src/main/java/org/apache/poi/ss/formula/functions/DateValue.java
+++ b/poi/src/main/java/org/apache/poi/ss/formula/functions/DateValue.java
@@ -29,7 +29,7 @@ import org.apache.poi.ss.usermodel.DateUtil;
* Implementation for the DATEVALUE() Excel function.<p>
*
* <b>Syntax:</b><br>
- * <b>DATEVALUE</b>(<b>date_text</b>)<p>
+ * <b>DATEVALUE</b>(<b>date_text</b>)
* <p>
* The <b>DATEVALUE</b> function converts a date that is stored as text to a serial number that Excel
* recognizes as a date. For example, the formula <b>=DATEVALUE("1/1/2008")</b> 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.<p>
+ * Implementation for Excel DELTA() function.
* <p>
* <b>Syntax</b>:<br> <b>DELTA </b>(<b>number1</b>,<b>number2</b> )<br>
* <p>
@@ -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.<p>
+ * Implementation for the Excel EOMONTH() function.
* <p>
- * EOMONTH() returns the date of the last day of a month..<p>
+ * EOMONTH() returns the date of the last day of a month.
* <p>
* <b>Syntax</b>:<br>
- * <b>EOMONTH</b>(<b>start_date</b>,<b>months</b>)<p>
+ * <b>EOMONTH</b>(<b>start_date</b>,<b>months</b>)
* <p>
* <b>start_date</b> is the starting date of the calculation
* <b>months</b> is the number of months to be added to <b>start_date</b>,
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.<p>
+ * Implementation for Excel FACTDOUBLE() function.
* <p>
* <b>Syntax</b>:<br> <b>FACTDOUBLE </b>(<b>number</b>)<br>
* <p>
@@ -46,6 +46,7 @@ public class FactDouble extends Fixed1ArgFunction implements FreeRefFunction {
//Caching of previously calculated factorial for speed
static HashMap<Integer, BigInteger> cache = new HashMap<>();
+ @Override
public ValueEval evaluate(int srcRowIndex, int srcColumnIndex, ValueEval numberVE) {
int number;
try {
@@ -75,6 +76,7 @@ public class FactDouble extends Fixed1ArgFunction implements FreeRefFunction {
return result;
}
+ @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/Frequency.java b/poi/src/main/java/org/apache/poi/ss/formula/functions/Frequency.java
index 94fa553521..62795f27da 100644
--- a/poi/src/main/java/org/apache/poi/ss/formula/functions/Frequency.java
+++ b/poi/src/main/java/org/apache/poi/ss/formula/functions/Frequency.java
@@ -26,10 +26,10 @@ import java.util.Arrays;
/**
* Implementation of Excel 'Analysis ToolPak' function FREQUENCY()<br>
- * Returns a frequency distribution as a vertical array<p>
+ * Returns a frequency distribution as a vertical array
* <p>
* <b>Syntax</b><br>
- * <b>FREQUENCY</b>(<b>data_array</b>, <b>bins_array</b>)<p>
+ * <b>FREQUENCY</b>(<b>data_array</b>, <b>bins_array</b>)
* <p>
* <b>data_array</b> 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.<br>
@@ -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.<p>
+ * Implementation for Excel HEX2DEC() function.
* <p>
* <b>Syntax</b>:<br> <b>HEX2DEC </b>(<b>number</b>)<br>
* <p>
@@ -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.<p>
+ * Implementation for Excel ImReal() function.
* <p>
* <b>Syntax</b>:<br> <b>ImReal </b>(<b>Inumber</b>)<br>
* <p>
@@ -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.<p>
+ * Implementation for Excel IMAGINARY() function.
* <p>
* <b>Syntax</b>:<br> <b>IMAGINARY </b>(<b>Inumber</b>)<br>
* <p>
@@ -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<br>
* (http://introcs.cs.princeton.edu/java/97data/LinearRegression.java.html)
* <b>Syntax</b>:<br>
- * <b>INTERCEPT</b>(<b>arrayX</b>, <b>arrayY</b>)<p>
+ * <b>INTERCEPT</b>(<b>arrayX</b>, <b>arrayY</b>)
*/
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;
/**
- * <p>Implementation for Excel Oct2Dec() function.<p>
+ * <p>Implementation for Excel Oct2Dec() function.
* <p>
* Converts an octal number to decimal.
* </p>
@@ -44,6 +44,7 @@ public class Oct2Dec extends Fixed1ArgFunction implements FreeRefFunction {
static final int MAX_NUMBER_OF_PLACES = 10;
static final int OCTAL_BASE = 8;
+ @Override
public ValueEval evaluate(int srcRowIndex, int srcColumnIndex, ValueEval numberVE) {
String octal = OperandResolver.coerceValueToString(numberVE);
try {
@@ -53,6 +54,7 @@ public class Oct2Dec 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/Quotient.java b/poi/src/main/java/org/apache/poi/ss/formula/functions/Quotient.java
index 9bac12fc3d..19ae7235ed 100644
--- a/poi/src/main/java/org/apache/poi/ss/formula/functions/Quotient.java
+++ b/poi/src/main/java/org/apache/poi/ss/formula/functions/Quotient.java
@@ -23,11 +23,10 @@ import org.apache.poi.ss.formula.eval.ValueEval;
import org.apache.poi.ss.formula.eval.*;
/**
- * <p>Implementation for Excel QUOTIENT () function.<p>
+ * <p>Implementation for Excel QUOTIENT () function.
* <p>
* <b>Syntax</b>:<br> <b>QUOTIENT</b>(<b>Numerator</b>,<b>Denominator</b>)<br>
* <p>
- * <p>
* 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.<p>
+ * Implementation for Excel REPT () function.
* <p>
* <b>Syntax</b>:<br> <b>REPT </b>(<b>text</b>,<b>number_times</b> )<br>
* <p>
@@ -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.<p>
+ * Implementation for Excel Roman() function.
* <p>
* <b>Syntax</b>:<br> <b>Roman </b>(<b>number</b>,<b>form</b>)<br>
* <p>
* Converts an arabic numeral to roman, as text.
* <p>
- * <p>
* Number Required. The Arabic numeral you want converted.<p>
* 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<br>
* (http://introcs.cs.princeton.edu/java/97data/LinearRegression.java.html)
* <b>Syntax</b>:<br>
- * <b>SLOPE</b>(<b>arrayX</b>, <b>arrayY</b>)<p>
+ * <b>SLOPE</b>(<b>arrayX</b>, <b>arrayY</b>)
*/
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.<p>
+ * Implementation for Excel WeekNum() function.
* <p>
* <b>Syntax</b>:<br> <b>WeekNum </b>(<b>Serial_num</b>,<b>Return_type</b>)<br>
* <p>
* Returns a number that indicates where the week falls numerically within a year.
* <p>
- * <p>
* 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.<p>
+ * returned by this class.
*<p>
* 0, "General"<br>
* 1, "0"<br>
@@ -59,7 +59,6 @@ package org.apache.poi.ss.usermodel;
* 0x30, "##0.0E+0"<br>
* 0x31, "@" - This is text format.<br>
* 0x31 "text" - Alias for "@"<br>
- * <p>
*/
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 <code>null</code> 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.<br>
* 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 <code>true</code> if the comment is visible, <code>false</code> otherwise
+ * @param visible {@code true} if the comment is visible, {@code false} otherwise
*/
void setVisible(boolean visible);
/**
* Returns whether this comment is visible.
*
- * @return <code>true</code> if the comment is visible, <code>false</code> 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)
List<EvaluationConditionalFormatRule> rules = cfEvaluator.getConditionalFormattingForCell(cell);
@@ -66,7 +65,7 @@ public class ExcelNumberFormat {
}
return nf;
}
-
+
/**
* Use this carefully, prefer factory methods to ensure id/format relationships are not broken or confused.
* Left public so {@link ConditionalFormattingRule#getNumberFormat()} implementations can use it.
@@ -77,8 +76,8 @@ public class ExcelNumberFormat {
this.idx = idx;
this.format = format;
}
-
-
+
+
/**
*
@@ -87,7 +86,7 @@ public class ExcelNumberFormat {
public int getIdx() {
return idx;
}
-
+
/**
*
* @return Excel number format string for the index
diff --git a/poi/src/main/java/org/apache/poi/ss/usermodel/Table.java b/poi/src/main/java/org/apache/poi/ss/usermodel/Table.java
index 049218a663..abfc810a16 100644
--- a/poi/src/main/java/org/apache/poi/ss/usermodel/Table.java
+++ b/poi/src/main/java/org/apache/poi/ss/usermodel/Table.java
@@ -71,9 +71,9 @@ public interface Table {
* Returns the index of a given named column in the table (names are case insensitive in XSSF).
* Note this list is lazily loaded and cached for performance.
* Changes to the underlying table structure are not reflected in later calls
- * unless <code>XSSFTable.updateHeaders()</code> 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 <code>columnHeader</code>
+ * @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.
* <p>
* 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'<p>
+ * See OOO documentation: excelfileformat.pdf sec 2.5.14 - 'Cell Range Address'
*
* <p>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<CellAddress>, Dup
/** range ending columns are equal */
RIGHT,
/** a cell or range is completely inside another range, without touching any edges (a cell in this position can't be in any others) */
- INSIDE,
- ;
+ INSIDE
}
private int _firstRow;
private int _firstCol;
@@ -81,7 +80,6 @@ public abstract class CellRangeAddressBase implements Iterable<CellAddress>, Dup
}
/**
* Runs a bounds check for row numbers
- * @param row
*/
private static void validateRow(int row, SpreadsheetVersion ssVersion) {
int maxrow = ssVersion.getLastRowIndex();
@@ -91,7 +89,6 @@ public abstract class CellRangeAddressBase implements Iterable<CellAddress>, Dup
/**
* Runs a bounds check for column numbers
- * @param column
*/
private static void validateColumn(int column, SpreadsheetVersion ssVersion) {
int maxcol = ssVersion.getLastColumnIndex();
@@ -231,8 +228,6 @@ public abstract class CellRangeAddressBase implements Iterable<CellAddress>, Dup
/**
* Useful for logic like table/range styling, where some elements apply based on relative position in a range.
- * @param rowInd
- * @param colInd
* @return set of {@link CellPosition}s occupied by the given coordinates. Empty if the coordinates are not in the range, never null.
* @since 3.17 beta 1
*/
diff --git a/poi/src/main/java/org/apache/poi/ss/util/PropertyTemplate.java b/poi/src/main/java/org/apache/poi/ss/util/PropertyTemplate.java
index b19ea9f713..cf789d7450 100644
--- a/poi/src/main/java/org/apache/poi/ss/util/PropertyTemplate.java
+++ b/poi/src/main/java/org/apache/poi/ss/util/PropertyTemplate.java
@@ -34,19 +34,19 @@ import org.apache.poi.ss.usermodel.Workbook;
/**
* <p>
- * 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.
* </p>
- *
+ *
* <p>
* This would replace {@link RegionUtil}.
* </p>
@@ -57,7 +57,7 @@ public final class PropertyTemplate {
* This is a list of cell properties for one shot application to a range of
* cells at a later time.
*/
- private Map<CellAddress, Map<String, Object>> _propertyTemplate;
+ private final Map<CellAddress, Map<String, Object>> _propertyTemplate;
/**
* Create a PropertyTemplate object
@@ -65,7 +65,7 @@ public final class PropertyTemplate {
public PropertyTemplate() {
_propertyTemplate = new HashMap<>();
}
-
+
/**
* Create a PropertyTemplate object from another PropertyTemplate
*
@@ -77,11 +77,11 @@ public final class PropertyTemplate {
_propertyTemplate.put(new CellAddress(entry.getKey()), cloneCellProperties(entry.getValue()));
}
}
-
+
private Map<CellAddress,Map<String, Object>> getTemplate() {
return _propertyTemplate;
}
-
+
private static Map<String, Object> cloneCellProperties(Map<String, Object> properties) {
Map<String, Object> newProperties = new HashMap<>();
for(Map.Entry<String, Object> entry : properties.entrySet()) {
@@ -89,12 +89,12 @@ public final class PropertyTemplate {
}
return newProperties;
}
-
+
/**
* Draws a group of cell borders for a cell range. The borders are not
* applied to the cells at this time, just the template is drawn. To apply
* the drawn borders to a sheet, use {@link #applyBorders}.
- *
+ *
* @param range
* - {@link CellRangeAddress} range of cells on which borders are
* drawn.
@@ -158,7 +158,7 @@ public final class PropertyTemplate {
* Draws a group of cell borders for a cell range. The borders are not
* applied to the cells at this time, just the template is drawn. To apply
* the drawn borders to a sheet, use {@link #applyBorders}.
- *
+ *
* @param range
* - {@link CellRangeAddress} range of cells on which borders are
* drawn.
@@ -183,7 +183,7 @@ public final class PropertyTemplate {
* <p>
* Draws the top border for a range of cells
* </p>
- *
+ *
* @param range
* - {@link CellRangeAddress} range of cells on which borders are
* drawn.
@@ -206,7 +206,7 @@ public final class PropertyTemplate {
* <p>
* Draws the bottom border for a range of cells
* </p>
- *
+ *
* @param range
* - {@link CellRangeAddress} range of cells on which borders are
* drawn.
@@ -405,10 +405,10 @@ public final class PropertyTemplate {
}
/**
- * Removes all border properties from this {@link PropertyTemplate} for the
+ * Removes all border properties from this PropertyTemplate for the
* specified range.
- *
- * @parm range - {@link CellRangeAddress} range of cells to remove borders.
+ *
+ * @param range - {@link CellRangeAddress} range of cells to remove borders.
*/
private void removeBorders(CellRangeAddress range) {
Set<String> properties = new HashSet<>();
@@ -752,10 +752,10 @@ public final class PropertyTemplate {
}
/**
- * Removes all border properties from this {@link PropertyTemplate} for the
+ * Removes all border properties from this PropertyTemplate for the
* specified range.
- *
- * @parm range - {@link CellRangeAddress} range of cells to remove borders.
+ *
+ * @param range - {@link CellRangeAddress} range of cells to remove borders.
*/
private void removeBorderColors(CellRangeAddress range) {
Set<String> properties = new HashSet<>();
@@ -772,24 +772,14 @@ public final class PropertyTemplate {
}
/**
- * Adds a property to this {@link PropertyTemplate} for a given cell
- *
- * @param row
- * @param col
- * @param property
- * @param value
+ * Adds a property to this PropertyTemplate for a given cell
*/
private void addProperty(int row, int col, String property, short value) {
addProperty(row, col, property, Short.valueOf(value));
}
/**
- * Adds a property to this {@link PropertyTemplate} for a given cell
- *
- * @param row
- * @param col
- * @param property
- * @param value
+ * Adds a property to this PropertyTemplate for a given cell
*/
private void addProperty(int row, int col, String property, Object value) {
CellAddress cell = new CellAddress(row, col);
@@ -802,12 +792,8 @@ public final class PropertyTemplate {
}
/**
- * Removes a set of properties from this {@link PropertyTemplate} for a
+ * Removes a set of properties from this PropertyTemplate for a
* given cell
- *
- * @param row
- * @param col
- * @param properties
*/
private void removeProperties(int row, int col, Set<String> properties) {
CellAddress cell = new CellAddress(row, col);
@@ -824,8 +810,6 @@ public final class PropertyTemplate {
/**
* Retrieves the number of borders assigned to a cell
- *
- * @param cell
*/
public int getNumBorders(CellAddress cell) {
Map<String, Object> cellProperties = _propertyTemplate.get(cell);
@@ -849,9 +833,6 @@ public final class PropertyTemplate {
/**
* Retrieves the number of borders assigned to a cell
- *
- * @param row
- * @param col
*/
public int getNumBorders(int row, int col) {
return getNumBorders(new CellAddress(row, col));
@@ -859,8 +840,6 @@ public final class PropertyTemplate {
/**
* Retrieves the number of border colors assigned to a cell
- *
- * @param cell
*/
public int getNumBorderColors(CellAddress cell) {
Map<String, Object> cellProperties = _propertyTemplate.get(cell);
@@ -884,9 +863,6 @@ public final class PropertyTemplate {
/**
* Retrieves the number of border colors assigned to a cell
- *
- * @param row
- * @param col
*/
public int getNumBorderColors(int row, int col) {
return getNumBorderColors(new CellAddress(row, col));
@@ -894,9 +870,6 @@ public final class PropertyTemplate {
/**
* Retrieves the border style for a given cell
- *
- * @param cell
- * @param property
*/
public BorderStyle getBorderStyle(CellAddress cell, String property) {
BorderStyle value = BorderStyle.NONE;
@@ -912,10 +885,6 @@ public final class PropertyTemplate {
/**
* Retrieves the border style for a given cell
- *
- * @param row
- * @param col
- * @param property
*/
public BorderStyle getBorderStyle(int row, int col, String property) {
return getBorderStyle(new CellAddress(row, col), property);
@@ -923,9 +892,6 @@ public final class PropertyTemplate {
/**
* Retrieves the border style for a given cell
- *
- * @param cell
- * @param property
*/
public short getTemplateProperty(CellAddress cell, String property) {
short value = 0;
@@ -941,10 +907,6 @@ public final class PropertyTemplate {
/**
* Retrieves the border style for a given cell
- *
- * @param row
- * @param col
- * @param property
*/
public short getTemplateProperty(int row, int col, String property) {
return getTemplateProperty(new CellAddress(row, col), property);
diff --git a/poi/src/main/java/org/apache/poi/ss/util/SheetBuilder.java b/poi/src/main/java/org/apache/poi/ss/util/SheetBuilder.java
index cff608a0a9..1801dedb3f 100644
--- a/poi/src/main/java/org/apache/poi/ss/util/SheetBuilder.java
+++ b/poi/src/main/java/org/apache/poi/ss/util/SheetBuilder.java
@@ -81,14 +81,13 @@ public class SheetBuilder {
* cells), creates cells if either corresponding array value is not
* null or createEmptyCells property is true.
* The conversion is performed in the following way:
- * <p>
* <ul>
* <li>Numbers become numeric cells.</li>
- * <li><code>java.util.Date</code> or <code>java.util.Calendar</code>
+ * <li>{@code java.util.Date} or {@code java.util.Calendar}
* instances become date cells.</li>
* <li>String with leading '=' char become formulas (leading '='
* will be truncated).</li>
- * <li>Other objects become strings via <code>Object.toString()</code>
+ * <li>Other objects become strings via {@code Object.toString()}
* method call.</li>
* </ul>
*
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 <code>false</code>, 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<String, Supplier<?>>
getGenericProperties(String val1, Supplier<?> sup1) {
- return Collections.unmodifiableMap(Collections.singletonMap(val1, sup1));
+ return Collections.singletonMap(val1, sup1);
}
public static Map<String, Supplier<?>> getGenericProperties(
diff --git a/poi/src/main/java/org/apache/poi/util/LocaleID.java b/poi/src/main/java/org/apache/poi/util/LocaleID.java
index 975442b5bc..6438adf535 100644
--- a/poi/src/main/java/org/apache/poi/util/LocaleID.java
+++ b/poi/src/main/java/org/apache/poi/util/LocaleID.java
@@ -27,7 +27,7 @@ import java.util.stream.Collectors;
import java.util.stream.Stream;
/**
- * Locale Collection<p>
+ * Locale Collection
* <p>
* 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 @@
<Logger name="org.apache.poi.hdgf.chunks.ChunkFactory" level="ERROR" />
<Logger name="org.apache.poi.hslf.model.textproperties.BitMaskTextProp" level="ERROR" />
<Logger name="org.apache.poi.hslf.usermodel.HSLFTextParagraph" level="ERROR" />
- <Logger name="org.apache.poi.openxml4j.opc.ZipPackage" level="ERROR" />
- <Logger name="org.apache.poi.POIDocument" level="WARN" />
+ <Logger name="org.apache.poi.openxml4j.opc.ZipPackage" level="FATAL" />
+ <Logger name="org.apache.poi.POIDocument" level="FATAL" />
<Logger name="org.apache.poi.openxml4j.opc.OPCPackage" level="ERROR" />
<Logger name="org.apache.poi.xssf.usermodel.XSSFWorkbook" level="ERROR" />
<Logger name="org.apache.poi.hslf.usermodel.HSLFGroupShape" level="WARN" />