diff options
6 files changed, 76 insertions, 58 deletions
diff --git a/src/java/org/apache/poi/hssf/record/StyleRecord.java b/src/java/org/apache/poi/hssf/record/StyleRecord.java index ef2f703617..77e677485d 100644 --- a/src/java/org/apache/poi/hssf/record/StyleRecord.java +++ b/src/java/org/apache/poi/hssf/record/StyleRecord.java @@ -61,7 +61,7 @@ public final class StyleRecord extends StandardRecord { field_3_outline_style_level = in.readByte(); } else { int field_2_name_length = in.readShort(); - + if(in.remaining() < 1) { // Some files from Crystal Reports lack the is16BitUnicode byte // the remaining fields, which is naughty @@ -71,7 +71,7 @@ public final class StyleRecord extends StandardRecord { // guess this is OK if the string length is zero field_4_name = ""; } else { - + field_3_stringHasMultibyte = in.readByte() != 0x00; if (field_3_stringHasMultibyte) { field_4_name = StringUtil.readUnicodeLE(in, field_2_name_length); @@ -92,7 +92,7 @@ public final class StyleRecord extends StandardRecord { /** * get the actual index of the style extended format record - * @see #getXFIndex() + * @see #getXFIndex() * @return index of the xf record */ public int getXFIndex() { @@ -138,6 +138,7 @@ public final class StyleRecord extends StandardRecord { return field_4_name; } + @Override public String toString() { StringBuffer sb = new StringBuffer(); @@ -155,16 +156,18 @@ public final class StyleRecord extends StandardRecord { return sb.toString(); } - + + @Override protected int getDataSize() { if (isBuiltin()) { return 4; // short, byte, byte } - return 2 // short xf index - + 3 // str len + flag + return 2 // short xf index + + 3 // str len + flag + field_4_name.length() * (field_3_stringHasMultibyte ? 2 : 1); } + @Override public void serialize(LittleEndianOutput out) { out.writeShort(field_1_xf_index); if (isBuiltin()) { @@ -181,6 +184,7 @@ public final class StyleRecord extends StandardRecord { } } + @Override public short getSid() { return sid; } diff --git a/src/java/org/apache/poi/ss/formula/atp/AnalysisToolPak.java b/src/java/org/apache/poi/ss/formula/atp/AnalysisToolPak.java index d73a31ee8e..551ff75474 100644 --- a/src/java/org/apache/poi/ss/formula/atp/AnalysisToolPak.java +++ b/src/java/org/apache/poi/ss/formula/atp/AnalysisToolPak.java @@ -21,7 +21,7 @@ import org.apache.poi.ss.formula.udf.UDFFinder; import java.util.*; /** - * Analysis Toolpack Function Definitions + * Analysis Toolpack Function Definitions */ public final class AnalysisToolPak implements UDFFinder { @@ -229,9 +229,9 @@ public final class AnalysisToolPak implements UDFFinder { if(metaData != null) { throw new IllegalArgumentException(name + " is a built-in Excel function. " + "Use FunctoinEval.registerFunction(String name, Function func) instead."); - } else { - throw new IllegalArgumentException(name + " is not a function from the Excel Analysis Toolpack."); } + + throw new IllegalArgumentException(name + " is not a function from the Excel Analysis Toolpack."); } FreeRefFunction f = inst.findFunction(name); if(f != null && !(f instanceof NotImplemented)) { diff --git a/src/ooxml/java/org/apache/poi/POIXMLDocumentPart.java b/src/ooxml/java/org/apache/poi/POIXMLDocumentPart.java index fe147b6228..97af09c268 100644 --- a/src/ooxml/java/org/apache/poi/POIXMLDocumentPart.java +++ b/src/ooxml/java/org/apache/poi/POIXMLDocumentPart.java @@ -106,7 +106,7 @@ public class POIXMLDocumentPart { * * @param part - The package part that holds xml data represenring this sheet. * @param rel - the relationship of the given package part - * @see #read(POIXMLFactory, java.util.Map) + * @see #read(POIXMLFactory, java.util.Map) */ public POIXMLDocumentPart(PackagePart part, PackageRelationship rel){ this.packagePart = part; @@ -131,7 +131,7 @@ public class POIXMLDocumentPart { /** * When you open something like a theme, call this to * re-base the XML Document onto the core child of the - * current core document + * current core document */ protected final void rebase(OPCPackage pkg) throws InvalidFormatException { PackageRelationshipCollection cores = @@ -179,7 +179,7 @@ public class POIXMLDocumentPart { * {@link POIXMLDocumentPart} to the {@link PackagePart} of the target * {@link POIXMLDocumentPart} with a {@link PackageRelationship#getId()} * matching the given parameter value. - * + * * @param id * The relation id to look for * @return the target part of the relation, or null, if none exists @@ -193,7 +193,7 @@ public class POIXMLDocumentPart { * {@link PackageRelationship}, that sources from the {@link PackagePart} of * this {@link POIXMLDocumentPart} to the {@link PackagePart} of the given * parameter value. - * + * * @param part * The {@link POIXMLDocumentPart} for which the according * relation-id shall be found. @@ -233,7 +233,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. - * + * * @param part * The related part, to which the relation shall be removed. * @param removeUnusedParts @@ -343,7 +343,8 @@ public class POIXMLDocumentPart { * @param noRelation if true, then no relationship is added. * @return the created child POIXMLDocumentPart */ - protected final POIXMLDocumentPart createRelationship(POIXMLRelation descriptor, POIXMLFactory factory, int idx, boolean noRelation){ + @SuppressWarnings("null") + protected final POIXMLDocumentPart createRelationship(POIXMLRelation descriptor, POIXMLFactory factory, int idx, boolean noRelation){ try { PackagePartName ppName = PackagingURIHelper.createPartName(descriptor.getFileName(idx)); PackageRelationship rel = null; @@ -414,7 +415,7 @@ public class POIXMLDocumentPart { } } } - + /** * Get the PackagePart that is the target of a relationship from this Part. * diff --git a/src/testcases/org/apache/poi/POIDataSamples.java b/src/testcases/org/apache/poi/POIDataSamples.java index 6cdf7ce8f5..b335215390 100644 --- a/src/testcases/org/apache/poi/POIDataSamples.java +++ b/src/testcases/org/apache/poi/POIDataSamples.java @@ -16,7 +16,12 @@ ==================================================================== */
package org.apache.poi;
-import java.io.*;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
/**
* Centralises logic for finding/opening sample files
@@ -219,16 +224,20 @@ public final class POIDataSamples { _is = is;
}
- public int read() throws IOException {
+ @Override
+ public int read() throws IOException {
return _is.read();
}
- public int read(byte[] b, int off, int len) throws IOException {
+ @Override
+ public int read(byte[] b, int off, int len) throws IOException {
return _is.read(b, off, len);
}
- public boolean markSupported() {
+ @Override
+ public boolean markSupported() {
return false;
}
- public void close() throws IOException {
+ @Override
+ public void close() throws IOException {
_is.close();
}
}
diff --git a/src/testcases/org/apache/poi/hssf/usermodel/AllUserModelTests.java b/src/testcases/org/apache/poi/hssf/usermodel/AllUserModelTests.java index e71289c149..8363449bfa 100644 --- a/src/testcases/org/apache/poi/hssf/usermodel/AllUserModelTests.java +++ b/src/testcases/org/apache/poi/hssf/usermodel/AllUserModelTests.java @@ -71,9 +71,8 @@ public class AllUserModelTests { result.addTestSuite(TestRowStyle.class); result.addTestSuite(TestSanityChecker.class); result.addTestSuite(TestSheetHiding.class); - if (false) { // deliberately avoiding this one - result.addTestSuite(TestUnfixedBugs.class); - } + /* deliberately avoiding this one + result.addTestSuite(TestUnfixedBugs.class);*/ result.addTestSuite(TestUnicodeWorkbook.class); result.addTestSuite(TestNonStandardWorkbookStreamNames.class); result.addTestSuite(TestWorkbook.class); diff --git a/src/testcases/org/apache/poi/ss/usermodel/BaseTestRow.java b/src/testcases/org/apache/poi/ss/usermodel/BaseTestRow.java index eb185471f4..d013beaf21 100644 --- a/src/testcases/org/apache/poi/ss/usermodel/BaseTestRow.java +++ b/src/testcases/org/apache/poi/ss/usermodel/BaseTestRow.java @@ -89,36 +89,41 @@ public abstract class BaseTestRow extends TestCase { public void testRemoveCell() { Workbook workbook = _testDataProvider.createWorkbook(); - Sheet sheet = workbook.createSheet(); - Row row = sheet.createRow(0); - - assertEquals(0, row.getPhysicalNumberOfCells()); - assertEquals(-1, row.getLastCellNum()); - assertEquals(-1, row.getFirstCellNum()); - - row.createCell(1); - assertEquals(2, row.getLastCellNum()); - assertEquals(1, row.getFirstCellNum()); - assertEquals(1, row.getPhysicalNumberOfCells()); - row.createCell(3); - assertEquals(4, row.getLastCellNum()); - assertEquals(1, row.getFirstCellNum()); - assertEquals(2, row.getPhysicalNumberOfCells()); - row.removeCell(row.getCell(3)); - assertEquals(2, row.getLastCellNum()); - assertEquals(1, row.getFirstCellNum()); - assertEquals(1, row.getPhysicalNumberOfCells()); - row.removeCell(row.getCell(1)); - assertEquals(-1, row.getLastCellNum()); - assertEquals(-1, row.getFirstCellNum()); - assertEquals(0, row.getPhysicalNumberOfCells()); + { + Sheet sheet = workbook.createSheet(); + Row row = sheet.createRow(0); + + assertEquals(0, row.getPhysicalNumberOfCells()); + assertEquals(-1, row.getLastCellNum()); + assertEquals(-1, row.getFirstCellNum()); + + row.createCell(1); + assertEquals(2, row.getLastCellNum()); + assertEquals(1, row.getFirstCellNum()); + assertEquals(1, row.getPhysicalNumberOfCells()); + row.createCell(3); + assertEquals(4, row.getLastCellNum()); + assertEquals(1, row.getFirstCellNum()); + assertEquals(2, row.getPhysicalNumberOfCells()); + row.removeCell(row.getCell(3)); + assertEquals(2, row.getLastCellNum()); + assertEquals(1, row.getFirstCellNum()); + assertEquals(1, row.getPhysicalNumberOfCells()); + row.removeCell(row.getCell(1)); + assertEquals(-1, row.getLastCellNum()); + assertEquals(-1, row.getFirstCellNum()); + assertEquals(0, row.getPhysicalNumberOfCells()); + } workbook = _testDataProvider.writeOutAndReadBack(workbook); - sheet = workbook.getSheetAt(0); - row = sheet.getRow(0); - assertEquals(-1, row.getLastCellNum()); - assertEquals(-1, row.getFirstCellNum()); - assertEquals(0, row.getPhysicalNumberOfCells()); + + { + Sheet sheet = workbook.getSheetAt(0); + Row row = sheet.getRow(0); + assertEquals(-1, row.getLastCellNum()); + assertEquals(-1, row.getFirstCellNum()); + assertEquals(0, row.getPhysicalNumberOfCells()); + } } public void baseTestRowBounds(int maxRowNum) { @@ -387,30 +392,30 @@ public abstract class BaseTestRow extends TestCase { assertTrue(cell2 == it.next()); assertEquals(Cell.CELL_TYPE_STRING, cell5.getCellType()); } - + public void testRowStyle() { Workbook workbook = _testDataProvider.createWorkbook(); Sheet sheet = workbook.createSheet("test"); Row row1 = sheet.createRow(0); Row row2 = sheet.createRow(1); - + // Won't be styled currently assertEquals(false, row1.isFormatted()); assertEquals(false, row2.isFormatted()); assertEquals(null, row1.getRowStyle()); assertEquals(null, row2.getRowStyle()); - + // Style one CellStyle style = workbook.createCellStyle(); style.setDataFormat((short)4); row2.setRowStyle(style); - + // Check assertEquals(false, row1.isFormatted()); assertEquals(true, row2.isFormatted()); assertEquals(null, row1.getRowStyle()); assertEquals(style, row2.getRowStyle()); - + // Save, load and re-check workbook = _testDataProvider.writeOutAndReadBack(workbook); sheet = workbook.getSheetAt(0); @@ -418,7 +423,7 @@ public abstract class BaseTestRow extends TestCase { row1 = sheet.getRow(0); row2 = sheet.getRow(1); style = workbook.getCellStyleAt(style.getIndex()); - + assertEquals(false, row1.isFormatted()); assertEquals(true, row2.isFormatted()); assertEquals(null, row1.getRowStyle()); |