Some IDE warning fixes and unit test adjustments

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1763482 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Dominik Stadler 2016-10-05 19:59:44 +00:00
parent d0bb2912ec
commit 924a1a96d9
3 changed files with 24 additions and 26 deletions

View File

@ -205,9 +205,9 @@ public final class HSSFRow implements Row, Comparable<HSSFRow> {
* records too. * records too.
*/ */
protected void removeAllCells() { protected void removeAllCells() {
for(int i=0; i<cells.length; i++) { for (HSSFCell cell : cells) {
if(cells[i] != null) { if (cell != null) {
removeCell(cells[i], true); removeCell(cell, true);
} }
} }
cells=new HSSFCell[INITIAL_CAPACITY]; cells=new HSSFCell[INITIAL_CAPACITY];
@ -232,9 +232,9 @@ public final class HSSFRow implements Row, Comparable<HSSFRow> {
row.setFirstCol(colIx); row.setFirstCol(colIx);
} else if (colIx > row.getLastCol()) { } else if (colIx > row.getLastCol()) {
row.setLastCol(colIx + 1); row.setLastCol(colIx + 1);
} else { } /*else {
// added cell is within first and last cells // added cell is within first and last cells
} }*/
} }
// TODO - RowRecord column boundaries need to be updated for cell comments too // TODO - RowRecord column boundaries need to be updated for cell comments too
return hcell; return hcell;
@ -446,10 +446,9 @@ public final class HSSFRow implements Row, Comparable<HSSFRow> {
@Override @Override
public int getPhysicalNumberOfCells() public int getPhysicalNumberOfCells()
{ {
int count=0; int count = 0;
for(int i=0;i<cells.length;i++) for (HSSFCell cell : cells) {
{ if (cell != null) count++;
if(cells[i]!=null) count++;
} }
return count; return count;
} }

View File

@ -64,10 +64,8 @@ public final class NumberEval implements NumericValueEval, StringValueEval {
return _stringValue; return _stringValue;
} }
public final String toString() { public final String toString() {
StringBuffer sb = new StringBuffer(64); return getClass().getName() + " [" +
sb.append(getClass().getName()).append(" ["); getStringValue() +
sb.append(getStringValue()); "]";
sb.append("]");
return sb.toString();
} }
} }

View File

@ -27,14 +27,7 @@ import static org.junit.Assert.assertTrue;
import java.io.IOException; import java.io.IOException;
import java.util.List; import java.util.List;
import org.apache.poi.ddf.EscherBoolProperty; import org.apache.poi.ddf.*;
import org.apache.poi.ddf.EscherContainerRecord;
import org.apache.poi.ddf.EscherDgRecord;
import org.apache.poi.ddf.EscherOptRecord;
import org.apache.poi.ddf.EscherProperties;
import org.apache.poi.ddf.EscherSimpleProperty;
import org.apache.poi.ddf.EscherSpRecord;
import org.apache.poi.ddf.EscherTextboxRecord;
import org.apache.poi.hssf.HSSFTestDataSamples; import org.apache.poi.hssf.HSSFTestDataSamples;
import org.apache.poi.hssf.record.CommonObjectDataSubRecord; import org.apache.poi.hssf.record.CommonObjectDataSubRecord;
import org.apache.poi.hssf.record.EscherAggregate; import org.apache.poi.hssf.record.EscherAggregate;
@ -160,6 +153,9 @@ public class TestDrawingShapes {
HSSFClientAnchor anchor = new HSSFClientAnchor(10, 10, 50, 50, (short) 2, 2, (short) 4, 4); HSSFClientAnchor anchor = new HSSFClientAnchor(10, 10, 50, 50, (short) 2, 2, (short) 4, 4);
anchor.setAnchorType(AnchorType.MOVE_DONT_RESIZE); anchor.setAnchorType(AnchorType.MOVE_DONT_RESIZE);
assertEquals(AnchorType.MOVE_DONT_RESIZE, anchor.getAnchorType()); assertEquals(AnchorType.MOVE_DONT_RESIZE, anchor.getAnchorType());
//noinspection deprecation
anchor.setAnchorType(AnchorType.MOVE_DONT_RESIZE.value);
assertEquals(AnchorType.MOVE_DONT_RESIZE, anchor.getAnchorType());
HSSFSimpleShape rectangle = drawing.createSimpleShape(anchor); HSSFSimpleShape rectangle = drawing.createSimpleShape(anchor);
rectangle.setShapeType(HSSFSimpleShape.OBJECT_TYPE_RECTANGLE); rectangle.setShapeType(HSSFSimpleShape.OBJECT_TYPE_RECTANGLE);
@ -175,8 +171,13 @@ public class TestDrawingShapes {
rectangle.setWrapText(HSSFSimpleShape.WRAP_NONE); rectangle.setWrapText(HSSFSimpleShape.WRAP_NONE);
rectangle.setString(new HSSFRichTextString("teeeest")); rectangle.setString(new HSSFRichTextString("teeeest"));
assertEquals(rectangle.getLineStyleColor(), 1111); assertEquals(rectangle.getLineStyleColor(), 1111);
assertEquals(((EscherSimpleProperty)((EscherOptRecord)HSSFTestHelper.getEscherContainer(rectangle).getChildById(EscherOptRecord.RECORD_ID)) EscherContainerRecord escherContainer = HSSFTestHelper.getEscherContainer(rectangle);
.lookup(EscherProperties.TEXT__TEXTID)).getPropertyValue(), "teeeest".hashCode()); assertNotNull(escherContainer);
EscherRecord childById = escherContainer.getChildById(EscherOptRecord.RECORD_ID);
assertNotNull(childById);
EscherProperty lookup = ((EscherOptRecord) childById).lookup(EscherProperties.TEXT__TEXTID);
assertNotNull(lookup);
assertEquals(((EscherSimpleProperty) lookup).getPropertyValue(), "teeeest".hashCode());
assertEquals(rectangle.isNoFill(), true); assertEquals(rectangle.isNoFill(), true);
assertEquals(rectangle.getWrapText(), HSSFSimpleShape.WRAP_NONE); assertEquals(rectangle.getWrapText(), HSSFSimpleShape.WRAP_NONE);
assertEquals(rectangle.getString().getString(), "teeeest"); assertEquals(rectangle.getString().getString(), "teeeest");